From 014b93406ed2a605027466f9f3e3815c19e5d77a Mon Sep 17 00:00:00 2001 From: Louis-Antoine Date: Fri, 31 Jan 2020 15:29:22 +0100 Subject: [PATCH 0001/1080] Store most data in gamestate instead of server config packet --- src/d_clisrv.c | 82 +------------------------------------------------- src/d_clisrv.h | 8 ----- src/p_saveg.c | 19 ++++++++++-- 3 files changed, 17 insertions(+), 92 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index ee4e62b91..694240579 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -1117,40 +1117,6 @@ static void GetPackets(void); static cl_mode_t cl_mode = CL_SEARCHING; -// Player name send/load - -static void CV_SavePlayerNames(UINT8 **p) -{ - INT32 i = 0; - // Players in game only. - for (; i < MAXPLAYERS; ++i) - { - if (!playeringame[i]) - { - WRITEUINT8(*p, 0); - continue; - } - WRITESTRING(*p, player_names[i]); - } -} - -static void CV_LoadPlayerNames(UINT8 **p) -{ - INT32 i = 0; - char tmp_name[MAXPLAYERNAME+1]; - tmp_name[MAXPLAYERNAME] = 0; - - 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); - } -} - #ifdef CLIENT_LOADINGSCREEN // // CL_DrawConnectionStatus @@ -1412,8 +1378,6 @@ static void SV_SendPlayerInfo(INT32 node) */ static boolean SV_SendServerConfig(INT32 node) { - INT32 i; - UINT8 *p, *op; boolean waspacketsent; netbuffer->packettype = PT_SERVERCFG; @@ -1429,32 +1393,10 @@ static boolean SV_SendServerConfig(INT32 node) netbuffer->u.servercfg.gametype = (UINT8)gametype; netbuffer->u.servercfg.modifiedgame = (UINT8)modifiedgame; - // 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)); - memset(netbuffer->u.servercfg.playercolor, 0xFF, sizeof(netbuffer->u.servercfg.playercolor)); - memset(netbuffer->u.servercfg.playeravailabilities, 0xFF, sizeof(netbuffer->u.servercfg.playeravailabilities)); - - memset(netbuffer->u.servercfg.adminplayers, -1, sizeof(netbuffer->u.servercfg.adminplayers)); - - for (i = 0; i < MAXPLAYERS; i++) - { - netbuffer->u.servercfg.adminplayers[i] = (SINT8)adminplayers[i]; - - if (!playeringame[i]) - continue; - netbuffer->u.servercfg.playerskins[i] = (UINT8)players[i].skin; - netbuffer->u.servercfg.playercolor[i] = (UINT8)players[i].skincolor; - netbuffer->u.servercfg.playeravailabilities[i] = (UINT32)LONG(players[i].availabilities); - } - memcpy(netbuffer->u.servercfg.server_context, server_context, 8); - op = p = netbuffer->u.servercfg.varlengthinputs; - CV_SavePlayerNames(&p); - CV_SaveNetVars(&p); { - const size_t len = sizeof (serverconfig_pak) + (size_t)(p - op); + const size_t len = sizeof (serverconfig_pak); #ifdef DEBUGFILE if (debugfile) @@ -3813,9 +3755,6 @@ static void HandlePacketFromAwayNode(SINT8 node) case PT_SERVERCFG: // Positive response of client join request { - INT32 j; - UINT8 *scp; - if (server && serverrunning && node != servernode) { // but wait I thought I'm the server? Net_CloseConnection(node); @@ -3831,8 +3770,6 @@ static void HandlePacketFromAwayNode(SINT8 node) maketic = gametic = neededtic = (tic_t)LONG(netbuffer->u.servercfg.gametic); G_SetGametype(netbuffer->u.servercfg.gametype); modifiedgame = netbuffer->u.servercfg.modifiedgame; - for (j = 0; j < MAXPLAYERS; j++) - adminplayers[j] = netbuffer->u.servercfg.adminplayers[j]; memcpy(server_context, netbuffer->u.servercfg.server_context, 8); } @@ -3851,23 +3788,6 @@ static void HandlePacketFromAwayNode(SINT8 node) #endif DEBFILE(va("Server accept join gametic=%u mynode=%d\n", gametic, mynode)); - memset(playeringame, 0, sizeof(playeringame)); - for (j = 0; j < MAXPLAYERS; j++) - { - if (netbuffer->u.servercfg.playerskins[j] == 0xFF - && netbuffer->u.servercfg.playercolor[j] == 0xFF - && netbuffer->u.servercfg.playeravailabilities[j] == 0xFFFFFFFF) - continue; // not in game - - playeringame[j] = true; - players[j].availabilities = (UINT32)LONG(netbuffer->u.servercfg.playeravailabilities[j]); - SetPlayerSkinByNum(j, (INT32)netbuffer->u.servercfg.playerskins[j]); - players[j].skincolor = netbuffer->u.servercfg.playercolor[j]; - } - - scp = netbuffer->u.servercfg.varlengthinputs; - CV_LoadPlayerNames(&scp); - CV_LoadNetVars(&scp); #ifdef JOININGAME /// \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 df93fe31d..a48ab91a9 100644 --- a/src/d_clisrv.h +++ b/src/d_clisrv.h @@ -305,18 +305,10 @@ typedef struct UINT8 clientnode; UINT8 gamestate; - // 0xFF == not in game; else player skin num - UINT8 playerskins[MAXPLAYERS]; - UINT8 playercolor[MAXPLAYERS]; - UINT32 playeravailabilities[MAXPLAYERS]; - UINT8 gametype; UINT8 modifiedgame; - SINT8 adminplayers[MAXPLAYERS]; // Needs to be signed char server_context[8]; // Unique context id, generated at server startup. - - UINT8 varlengthinputs[0]; // Playernames and netvars } ATTRPACK serverconfig_pak; typedef struct { diff --git a/src/p_saveg.c b/src/p_saveg.c index 853856880..19c5b532e 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -107,13 +107,16 @@ static void P_NetArchivePlayers(void) for (i = 0; i < MAXPLAYERS; i++) { + WRITESINT8(save_p, (SINT8)adminplayers[i]); + if (!playeringame[i]) continue; flags = 0; - // no longer send ticcmds, player name, skin, or color + // no longer send ticcmds + WRITESTRINGN(save_p, player_names[i], MAXPLAYERNAME); WRITEANGLE(save_p, players[i].aiming); WRITEANGLE(save_p, players[i].drawangle); WRITEANGLE(save_p, players[i].awayviewaiming); @@ -140,6 +143,9 @@ static void P_NetArchivePlayers(void) WRITEUINT16(save_p, players[i].flashpal); WRITEUINT16(save_p, players[i].flashcount); + WRITEUINT8(save_p, players[i].skincolor); + WRITEINT32(save_p, players[i].skin); + WRITEUINT32(save_p, players[i].availabilities); WRITEUINT32(save_p, players[i].score); WRITEFIXED(save_p, players[i].dashspeed); WRITESINT8(save_p, players[i].lives); @@ -314,6 +320,8 @@ static void P_NetUnArchivePlayers(void) for (i = 0; i < MAXPLAYERS; i++) { + adminplayers[i] = (INT32)READSINT8(save_p); + // Do NOT memset player struct to 0 // other areas may initialize data elsewhere //memset(&players[i], 0, sizeof (player_t)); @@ -321,9 +329,8 @@ static void P_NetUnArchivePlayers(void) continue; // NOTE: sending tics should (hopefully) no longer be necessary - // sending player names, skin and color should not be necessary at all! - // (that data is handled in the server config now) + READSTRINGN(save_p, player_names[i], MAXPLAYERNAME); players[i].aiming = READANGLE(save_p); players[i].drawangle = READANGLE(save_p); players[i].awayviewaiming = READANGLE(save_p); @@ -350,6 +357,9 @@ static void P_NetUnArchivePlayers(void) players[i].flashpal = READUINT16(save_p); players[i].flashcount = READUINT16(save_p); + players[i].skincolor = READUINT8(save_p); + players[i].skin = READINT32(save_p); + players[i].availabilities = READUINT32(save_p); players[i].score = READUINT32(save_p); players[i].dashspeed = READFIXED(save_p); // dashing speed players[i].lives = READSINT8(save_p); @@ -3983,6 +3993,7 @@ static void P_NetArchiveMisc(void) WRITEINT16(save_p, gamemap); WRITEINT16(save_p, gamestate); + WRITEINT16(save_p, gametype); { UINT32 pig = 0; @@ -4065,6 +4076,8 @@ static inline boolean P_NetUnArchiveMisc(void) G_SetGamestate(READINT16(save_p)); + gametype = READINT16(save_p); + { UINT32 pig = READUINT32(save_p); for (i = 0; i < MAXPLAYERS; i++) From d02c4c0cc7e0d9e9bc776ecf5f89d58191cb697f Mon Sep 17 00:00:00 2001 From: Louis-Antoine Date: Fri, 31 Jan 2020 15:57:04 +0100 Subject: [PATCH 0002/1080] Add "resendgamestate" command --- src/d_clisrv.c | 120 +++++++++++++++++++++++++++++++++++++++++++++---- src/d_clisrv.h | 3 ++ src/d_main.c | 2 +- src/d_net.c | 3 ++ src/g_game.c | 2 +- src/p_saveg.c | 19 +++++--- src/p_saveg.h | 4 +- src/p_setup.c | 27 +++++++---- src/p_setup.h | 2 +- 9 files changed, 153 insertions(+), 29 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 694240579..c1703b82d 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -121,6 +121,7 @@ static ticcmd_t localcmds2; static boolean cl_packetmissed; // here it is for the secondary local player (splitscreen) static UINT8 mynode; // my address pointofview server +static boolean cl_redownloadinggamestate = false; static UINT8 localtextcmd[MAXTEXTCMD]; static UINT8 localtextcmd2[MAXTEXTCMD]; // splitscreen @@ -1429,7 +1430,7 @@ static boolean SV_SendServerConfig(INT32 node) #ifdef JOININGAME #define SAVEGAMESIZE (768*1024) -static void SV_SendSaveGame(INT32 node) +static void SV_SendSaveGame(INT32 node, boolean resending) { size_t length, compressedlen; UINT8 *savebuffer; @@ -1447,7 +1448,7 @@ static void SV_SendSaveGame(INT32 node) // Leave room for the uncompressed length. save_p = savebuffer + sizeof(UINT32); - P_SaveNetGame(); + P_SaveNetGame(resending); length = save_p - savebuffer; if (length > SAVEGAMESIZE) @@ -1520,7 +1521,7 @@ static void SV_SavedGame(void) return; } - P_SaveNetGame(); + P_SaveNetGame(false); length = save_p - savebuffer; if (length > SAVEGAMESIZE) @@ -1543,7 +1544,7 @@ static void SV_SavedGame(void) #define TMPSAVENAME "$$$.sav" -static void CL_LoadReceivedSavegame(void) +static void CL_LoadReceivedSavegame(boolean reloading) { UINT8 *savebuffer = NULL; size_t length, decompressedlen; @@ -1579,7 +1580,7 @@ static void CL_LoadReceivedSavegame(void) automapactive = false; // load a base level - if (P_LoadNetGame()) + if (P_LoadNetGame(reloading)) { const INT32 actnum = mapheaderinfo[gamemap-1]->actnum; CONS_Printf(M_GetText("Map is now \"%s"), G_BuildMapName(gamemap)); @@ -1611,6 +1612,32 @@ static void CL_LoadReceivedSavegame(void) consistancy[gametic%BACKUPTICS] = Consistancy(); CON_ToggleOff(); } + +static void CL_ReloadReceivedSavegame(void) +{ + INT32 i; + + for (i = 0; i < MAXPLAYERS; i++) + { +#ifdef HAVE_BLUA + LUA_InvalidatePlayer(&players[i]); +#endif + sprintf(player_names[i], "Player %d", i + 1); + } + + CL_LoadReceivedSavegame(true); + + if (neededtic < gametic) + neededtic = gametic; + maketic = neededtic; + + camera.subsector = R_PointInSubsector(camera.x, camera.y); + camera2.subsector = R_PointInSubsector(camera2.x, camera2.y); + + cl_redownloadinggamestate = false; + + CONS_Printf(M_GetText("Game state reloaded\n")); +} #endif #ifndef NONET @@ -1950,7 +1977,7 @@ static boolean CL_ServerConnectionTicker(boolean viams, const char *tmpsave, tic if (fileneeded[0].status == FS_FOUND) { // Gamestate is now handled within CL_LoadReceivedSavegame() - CL_LoadReceivedSavegame(); + CL_LoadReceivedSavegame(false); cl_mode = CL_CONNECTED; } // don't break case continue to CL_CONNECTED else @@ -2974,6 +3001,32 @@ static void Got_KickCmd(UINT8 **p, INT32 playernum) CL_RemovePlayer(pnum, kickreason); } +static void Command_ResendGamestate(void) +{ + if (COM_Argc() == 1) + { + CONS_Printf(M_GetText("resendgamestate : resend the game state to a player\n")); + return; + } + else if (client) + { + CONS_Printf(M_GetText("Only the server can use this.\n")); + return; + } + + const SINT8 playernum = nametonum(COM_Argv(1)); + if (playernum == -1 || playernum == 0) + return; + + // Send a PT_WILLRESENDGAMESTATE packet to the client so they know what's going on + netbuffer->packettype = PT_WILLRESENDGAMESTATE; + if (!HSendPacket(playernode[playernum], true, 0, 0)) + { + CONS_Alert(CONS_ERROR, M_GetText("A problem occured, please try again.\n")); + return; + } +} + consvar_t cv_allownewplayer = {"allowjoin", "On", CV_NETVAR, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL }; consvar_t cv_joinnextround = {"joinnextround", "Off", CV_NETVAR, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; /// \todo not done static CV_PossibleValue_t maxplayers_cons_t[] = {{2, "MIN"}, {32, "MAX"}, {0, NULL}}; @@ -3012,6 +3065,7 @@ void D_ClientServerInit(void) COM_AddCommand("reloadbans", Command_ReloadBan); COM_AddCommand("connect", Command_connect); COM_AddCommand("nodes", Command_Nodes); + COM_AddCommand("resendgamestate", Command_ResendGamestate); #ifdef PACKETDROP COM_AddCommand("drop", Command_Drop); COM_AddCommand("droprate", Command_Droprate); @@ -3082,6 +3136,7 @@ void SV_ResetServer(void) mynode = 0; cl_packetmissed = false; + cl_redownloadinggamestate = false; if (dedicated) { @@ -3598,7 +3653,7 @@ static void HandleConnect(SINT8 node) { if ((gamestate == GS_LEVEL || gamestate == GS_INTERMISSION) && newnode) { - SV_SendSaveGame(node); // send a complete game state + SV_SendSaveGame(node, false); // send a complete game state DEBFILE("send savegame\n"); } SV_AddWaitingPlayers(names[0], names[1]); @@ -3665,6 +3720,42 @@ static void HandleServerInfo(SINT8 node) } #endif +static void PT_WillResendGamestate(void) +{ + char tmpsave[256]; + + if (server || cl_redownloadinggamestate) + return; + + // Send back a PT_CANRESENDGAMESTATE packet to the server + // so they know they can start sending the game state + netbuffer->packettype = PT_CANRESENDGAMESTATE; + if (!HSendPacket(servernode, true, 0, 0)) + return; + + CONS_Printf(M_GetText("Reloading game state...\n")); + + sprintf(tmpsave, "%s" PATHSEP TMPSAVENAME, srb2home); + + // Don't get a corrupt savegame error because tmpsave already exists + if (FIL_FileExists(tmpsave) && unlink(tmpsave) == -1) + I_Error("Can't delete %s\n", tmpsave); + + CL_PrepareDownloadSaveGame(tmpsave); + + cl_redownloadinggamestate = true; +} + +static void PT_CanResendGamestate(SINT8 node) +{ + if (client || sendingsavegame[node]) + return; + + CONS_Printf(M_GetText("Resending game state to %s...\n"), player_names[nodetoplayer[node]]); + + SV_SendSaveGame(node, true); // Resend a complete game state +} + /** Handles a packet received from a node that isn't in game * * \param node The packet sender @@ -4107,6 +4198,9 @@ static void HandlePacketFromPlayer(SINT8 node) Net_CloseConnection(node); nodeingame[node] = false; break; + case PT_CANRESENDGAMESTATE: + PT_CanResendGamestate(node); + break; // -------------------------------------------- CLIENT RECEIVE ---------- case PT_RESYNCHEND: // Only accept PT_RESYNCHEND from the server. @@ -4136,6 +4230,9 @@ static void HandlePacketFromPlayer(SINT8 node) break; } + if (cl_redownloadinggamestate) + break; + realstart = ExpandTics(netbuffer->u.serverpak.starttic); realend = realstart + netbuffer->u.serverpak.numtics; @@ -4234,6 +4331,9 @@ static void HandlePacketFromPlayer(SINT8 node) if (client) Got_Filetxpak(); break; + case PT_WILLRESENDGAMESTATE: + PT_WillResendGamestate(); + break; default: DEBFILE(va("UNKNOWN PACKET TYPE RECEIVED %d from host %d\n", netbuffer->packettype, node)); @@ -4876,7 +4976,11 @@ void NetUpdate(void) if (client) { - if (!resynch_local_inprogress) + // If the client just finished redownloading the game state, load it + if (cl_redownloadinggamestate && fileneeded[0].status == FS_FOUND) + CL_ReloadReceivedSavegame(); + + if (!(resynch_local_inprogress || cl_redownloadinggamestate)) CL_SendClientCmd(); // Send tic cmd hu_resynching = resynch_local_inprogress; } diff --git a/src/d_clisrv.h b/src/d_clisrv.h index a48ab91a9..6761b47cc 100644 --- a/src/d_clisrv.h +++ b/src/d_clisrv.h @@ -67,6 +67,9 @@ typedef enum PT_RESYNCHEND, // Player is now resynched and is being requested to remake the gametic PT_RESYNCHGET, // Player got resynch packet + PT_WILLRESENDGAMESTATE, // Hey Client, I am about to resend you the gamestate! + PT_CANRESENDGAMESTATE, // Okay Server, I'm ready to receive it, you can go ahead. + // Add non-PT_CANFAIL packet types here to avoid breaking MS compatibility. PT_CANFAIL, // This is kind of a priority. Anything bigger than CANFAIL diff --git a/src/d_main.c b/src/d_main.c index 15d3c8041..f70f80b32 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -1514,7 +1514,7 @@ void D_SRB2Main(void) { levelstarttic = gametic; G_SetGamestate(GS_LEVEL); - if (!P_LoadLevel(false)) + if (!P_LoadLevel(false, false)) I_Quit(); // fail so reset game stuff } } diff --git a/src/d_net.c b/src/d_net.c index 573c9cfe9..648d5683f 100644 --- a/src/d_net.c +++ b/src/d_net.c @@ -799,6 +799,9 @@ static const char *packettypename[NUMPACKETTYPE] = "RESYNCHEND", "RESYNCHGET", + "WILLRESENDGAMESTATE", + "CANRESENDGAMESTATE", + "FILEFRAGMENT", "TEXTCMD", "TEXTCMD2", diff --git a/src/g_game.c b/src/g_game.c index f5d7cd2fb..4f9e7a580 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1839,7 +1839,7 @@ void G_DoLoadLevel(boolean resetplayer) } // Setup the level. - if (!P_LoadLevel(false)) // this never returns false? + if (!P_LoadLevel(false, false)) // this never returns false? { // fail so reset game stuff Command_ExitGame_f(); diff --git a/src/p_saveg.c b/src/p_saveg.c index 19c5b532e..1e65098cf 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -3985,12 +3985,14 @@ static inline void P_UnArchiveSPGame(INT16 mapoverride) playeringame[consoleplayer] = true; } -static void P_NetArchiveMisc(void) +static void P_NetArchiveMisc(boolean resending) { INT32 i; WRITEUINT32(save_p, ARCHIVEBLOCK_MISC); + if (resending) + WRITEUINT32(save_p, gametic); WRITEINT16(save_p, gamemap); WRITEINT16(save_p, gamestate); WRITEINT16(save_p, gametype); @@ -4056,13 +4058,16 @@ static void P_NetArchiveMisc(void) WRITEUINT8(save_p, 0x2e); } -static inline boolean P_NetUnArchiveMisc(void) +static inline boolean P_NetUnArchiveMisc(boolean reloading) { INT32 i; if (READUINT32(save_p) != ARCHIVEBLOCK_MISC) I_Error("Bad $$$.sav at archive block Misc"); + if (reloading) + gametic = READUINT32(save_p); + gamemap = READINT16(save_p); // gamemap changed; we assume that its map header is always valid, @@ -4091,7 +4096,7 @@ static inline boolean P_NetUnArchiveMisc(void) tokenlist = READUINT32(save_p); - if (!P_LoadLevel(true)) + if (!P_LoadLevel(true, reloading)) return false; // get the time @@ -4192,14 +4197,14 @@ void P_SaveGame(void) P_ArchiveLuabanksAndConsistency(); } -void P_SaveNetGame(void) +void P_SaveNetGame(boolean resending) { thinker_t *th; mobj_t *mobj; INT32 i = 1; // don't start from 0, it'd be confused with a blank pointer otherwise CV_SaveNetVars(&save_p); - P_NetArchiveMisc(); + P_NetArchiveMisc(resending); // Assign the mobjnumber for pointer tracking for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next) @@ -4250,10 +4255,10 @@ boolean P_LoadGame(INT16 mapoverride) return true; } -boolean P_LoadNetGame(void) +boolean P_LoadNetGame(boolean reloading) { CV_LoadNetVars(&save_p); - if (!P_NetUnArchiveMisc()) + if (!P_NetUnArchiveMisc(reloading)) return false; P_NetUnArchivePlayers(); if (gamestate == GS_LEVEL) diff --git a/src/p_saveg.h b/src/p_saveg.h index 16d47bea8..b75c02117 100644 --- a/src/p_saveg.h +++ b/src/p_saveg.h @@ -22,9 +22,9 @@ // These are the load / save game routines. void P_SaveGame(void); -void P_SaveNetGame(void); +void P_SaveNetGame(boolean resending); boolean P_LoadGame(INT16 mapoverride); -boolean P_LoadNetGame(void); +boolean P_LoadNetGame(boolean reloading); mobj_t *P_FindNewPosition(UINT32 oldposition); diff --git a/src/p_setup.c b/src/p_setup.c index 729ee00c2..95552a2d0 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2777,8 +2777,6 @@ static void P_InitLevelSettings(void) leveltime = 0; - localaiming = 0; - localaiming2 = 0; modulothing = 0; // special stage tokens, emeralds, and ring total @@ -2893,6 +2891,9 @@ void P_RespawnThings(void) P_InitLevelSettings(); + localaiming = 0; + localaiming2 = 0; + P_SpawnMapThings(true); // restore skybox viewpoint/centerpoint if necessary, set them to defaults if we can't do that @@ -3387,7 +3388,7 @@ static void P_InitGametype(void) * \param fromnetsave If true, skip some stuff because we're loading a netgame snapshot. * \todo Clean up, refactor, split up; get rid of the bloat. */ -boolean P_LoadLevel(boolean fromnetsave) +boolean P_LoadLevel(boolean fromnetsave, boolean reloadinggamestate) { // use gamemap to get map number. // 99% of the things already did, so. @@ -3457,7 +3458,10 @@ boolean P_LoadLevel(boolean fromnetsave) players[consoleplayer].viewz = 1; // Cancel all d_main.c fadeouts (keep fade in though). - wipegamestate = FORCEWIPEOFF; + if (reloadinggamestate) + wipegamestate = gamestate; // Don't fade if reloading the gamestate + else + wipegamestate = FORCEWIPEOFF; wipestyleflags = 0; // Special stage fade to white @@ -3491,7 +3495,7 @@ boolean P_LoadLevel(boolean fromnetsave) // Let's fade to black here // But only if we didn't do the special stage wipe - if (rendermode != render_none && !ranspecialwipe) + if (rendermode != render_none && !(ranspecialwipe || reloadinggamestate)) P_RunLevelWipe(); if (!titlemapinaction) @@ -3622,7 +3626,12 @@ boolean P_LoadLevel(boolean fromnetsave) if (!fromnetsave) P_InitGametype(); - P_InitCamera(); + if (!reloadinggamestate) + { + P_InitCamera(); + localaiming = 0; + localaiming2 = 0; + } // clear special respawning que iquehead = iquetail = 0; @@ -3633,7 +3642,7 @@ boolean P_LoadLevel(boolean fromnetsave) P_MapEnd(); // Remove the loading shit from the screen - if (rendermode != render_none && !titlemapinaction) + if (rendermode != render_none && !(titlemapinaction || reloadinggamestate)) F_WipeColorFill(levelfadecol); if (precache || dedicated) @@ -3671,8 +3680,8 @@ boolean P_LoadLevel(boolean fromnetsave) #endif } - // No render mode, stop here. - if (rendermode == render_none) + // No render mode or reloading gamestate, stop here. + if (rendermode == render_none || reloadinggamestate) return true; // Title card! diff --git a/src/p_setup.h b/src/p_setup.h index d7e2d8861..c638bafca 100644 --- a/src/p_setup.h +++ b/src/p_setup.h @@ -97,7 +97,7 @@ void P_SetupLevelSky(INT32 skynum, boolean global); void P_ScanThings(INT16 mapnum, INT16 wadnum, INT16 lumpnum); #endif void P_RespawnThings(void); -boolean P_LoadLevel(boolean fromnetsave); +boolean P_LoadLevel(boolean fromnetsave, boolean reloadinggamestate); #ifdef HWRENDER void HWR_SetupLevel(void); #endif From a927d67259c27cf66dffcbdc47df9383bc0b70f9 Mon Sep 17 00:00:00 2001 From: Louis-Antoine Date: Fri, 28 Feb 2020 18:17:37 +0100 Subject: [PATCH 0003/1080] Fix warning --- src/d_clisrv.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index c1703b82d..8eeda23a6 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -3003,6 +3003,8 @@ static void Got_KickCmd(UINT8 **p, INT32 playernum) static void Command_ResendGamestate(void) { + SINT8 playernum; + if (COM_Argc() == 1) { CONS_Printf(M_GetText("resendgamestate : resend the game state to a player\n")); @@ -3014,7 +3016,7 @@ static void Command_ResendGamestate(void) return; } - const SINT8 playernum = nametonum(COM_Argv(1)); + playernum = nametonum(COM_Argv(1)); if (playernum == -1 || playernum == 0) return; From 4f7591a044d07c89f811bc6b179e90070db226bd Mon Sep 17 00:00:00 2001 From: Louis-Antoine Date: Sat, 29 Feb 2020 13:40:15 +0100 Subject: [PATCH 0004/1080] Rename packet --- src/d_clisrv.c | 10 +++++----- src/d_clisrv.h | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 8eeda23a6..42e7b472f 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -3729,9 +3729,9 @@ static void PT_WillResendGamestate(void) if (server || cl_redownloadinggamestate) return; - // Send back a PT_CANRESENDGAMESTATE packet to the server + // Send back a PT_CANRECEIVEGAMESTATE packet to the server // so they know they can start sending the game state - netbuffer->packettype = PT_CANRESENDGAMESTATE; + netbuffer->packettype = PT_CANRECEIVEGAMESTATE; if (!HSendPacket(servernode, true, 0, 0)) return; @@ -3748,7 +3748,7 @@ static void PT_WillResendGamestate(void) cl_redownloadinggamestate = true; } -static void PT_CanResendGamestate(SINT8 node) +static void PT_CanReceiveGamestate(SINT8 node) { if (client || sendingsavegame[node]) return; @@ -4200,8 +4200,8 @@ static void HandlePacketFromPlayer(SINT8 node) Net_CloseConnection(node); nodeingame[node] = false; break; - case PT_CANRESENDGAMESTATE: - PT_CanResendGamestate(node); + case PT_CANRECEIVEGAMESTATE: + PT_CanReceiveGamestate(node); break; // -------------------------------------------- CLIENT RECEIVE ---------- case PT_RESYNCHEND: diff --git a/src/d_clisrv.h b/src/d_clisrv.h index 6761b47cc..5b4b7d2d8 100644 --- a/src/d_clisrv.h +++ b/src/d_clisrv.h @@ -68,7 +68,7 @@ typedef enum PT_RESYNCHGET, // Player got resynch packet PT_WILLRESENDGAMESTATE, // Hey Client, I am about to resend you the gamestate! - PT_CANRESENDGAMESTATE, // Okay Server, I'm ready to receive it, you can go ahead. + PT_CANRECEIVEGAMESTATE, // Okay Server, I'm ready to receive it, you can go ahead. // Add non-PT_CANFAIL packet types here to avoid breaking MS compatibility. From 846560910d28b7f0766fe4730dd6492bba79008a Mon Sep 17 00:00:00 2001 From: Louis-Antoine Date: Sun, 1 Mar 2020 03:22:47 +0100 Subject: [PATCH 0005/1080] Obliterate resynch Okay, more precisely this substitutes the old resynch with the newly added gamestate resend code. --- src/d_clisrv.c | 706 ++----------------------------------------------- src/d_clisrv.h | 171 +----------- src/hu_stuff.c | 2 +- 3 files changed, 31 insertions(+), 848 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index f04676162..6b68c4a18 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -83,6 +83,7 @@ char playeraddress[MAXPLAYERS][64]; // The actual timeout will be longer depending on the savegame length tic_t jointimeout = (10*TICRATE); static boolean sendingsavegame[MAXNETNODES]; // Are we sending the savegame? +static boolean resendingsavegame[MAXNETNODES]; // Are we resending the savegame? static tic_t freezetimeout[MAXNETNODES]; // Until when can this node freeze the server before getting a timeout? UINT16 pingmeasurecount = 1; @@ -102,15 +103,8 @@ static tic_t maketic; static INT16 consistancy[BACKUPTICS]; -// Resynching shit! -static UINT32 resynch_score[MAXNETNODES]; // "score" for kicking -- if this gets too high then cfail kick -static UINT16 resynch_delay[MAXNETNODES]; // delay time before the player can be considered to have desynched -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. static UINT8 player_joining = false; -UINT8 hu_resynching = 0; +UINT8 hu_redownloadinggamestate = 0; UINT8 adminpassmd5[16]; boolean adminpasswordset = false; @@ -504,597 +498,6 @@ void ReadLmpExtraData(UINT8 **demo_pointer, INT32 playernum) // end extra data function for lmps // ----------------------------------------------------------------- -// ----------------------------------------------------------------- -// resynch player data -// ----------------------------------------------------------------- -static inline void resynch_write_player(resynch_pak *rsp, const size_t i) -{ - size_t j; - - rsp->playernum = (UINT8)i; - - // Do not send anything visual related. - // Only send data that we need to know for physics. - rsp->playerstate = (UINT8)players[i].playerstate; //playerstate_t - rsp->pflags = (UINT32)LONG(players[i].pflags); //pflags_t - rsp->panim = (UINT8)players[i].panim; //panim_t - - rsp->aiming = (angle_t)LONG(players[i].aiming); - rsp->currentweapon = LONG(players[i].currentweapon); - rsp->ringweapons = LONG(players[i].ringweapons); - - rsp->ammoremoval = (UINT16)SHORT(players[i].ammoremoval); - rsp->ammoremovaltimer = (tic_t)LONG(players[i].ammoremovaltimer); - rsp->ammoremovalweapon = LONG(players[i].ammoremovalweapon); - - for (j = 0; j < NUMPOWERS; ++j) - rsp->powers[j] = (UINT16)SHORT(players[i].powers[j]); - - // Score is resynched in the rspfirm resync packet - rsp->rings = SHORT(players[i].rings); - rsp->spheres = SHORT(players[i].spheres); - rsp->lives = players[i].lives; - rsp->continues = players[i].continues; - rsp->scoreadd = players[i].scoreadd; - rsp->xtralife = players[i].xtralife; - rsp->pity = players[i].pity; - - rsp->skincolor = players[i].skincolor; - rsp->skin = LONG(players[i].skin); - rsp->availabilities = LONG(players[i].availabilities); - // Just in case Lua does something like - // modify these at runtime - rsp->camerascale = (fixed_t)LONG(players[i].camerascale); - rsp->shieldscale = (fixed_t)LONG(players[i].shieldscale); - rsp->normalspeed = (fixed_t)LONG(players[i].normalspeed); - rsp->runspeed = (fixed_t)LONG(players[i].runspeed); - rsp->thrustfactor = players[i].thrustfactor; - rsp->accelstart = players[i].accelstart; - rsp->acceleration = players[i].acceleration; - rsp->charability = players[i].charability; - rsp->charability2 = players[i].charability2; - rsp->charflags = (UINT32)LONG(players[i].charflags); - rsp->thokitem = (UINT32)LONG(players[i].thokitem); //mobjtype_t - rsp->spinitem = (UINT32)LONG(players[i].spinitem); //mobjtype_t - rsp->revitem = (UINT32)LONG(players[i].revitem); //mobjtype_t - rsp->followitem = (UINT32)LONG(players[i].followitem); //mobjtype_t - rsp->actionspd = (fixed_t)LONG(players[i].actionspd); - rsp->mindash = (fixed_t)LONG(players[i].mindash); - rsp->maxdash = (fixed_t)LONG(players[i].maxdash); - rsp->jumpfactor = (fixed_t)LONG(players[i].jumpfactor); - rsp->playerheight = (fixed_t)LONG(players[i].height); - rsp->playerspinheight = (fixed_t)LONG(players[i].spinheight); - - rsp->speed = (fixed_t)LONG(players[i].speed); - rsp->secondjump = players[i].secondjump; - rsp->fly1 = players[i].fly1; - rsp->glidetime = (tic_t)LONG(players[i].glidetime); - rsp->climbing = players[i].climbing; - rsp->deadtimer = players[i].deadtimer; - rsp->exiting = (tic_t)LONG(players[i].exiting); - rsp->homing = players[i].homing; - rsp->dashmode = (tic_t)LONG(players[i].dashmode); - rsp->skidtime = (tic_t)LONG(players[i].skidtime); - rsp->cmomx = (fixed_t)LONG(players[i].cmomx); - rsp->cmomy = (fixed_t)LONG(players[i].cmomy); - rsp->rmomx = (fixed_t)LONG(players[i].rmomx); - rsp->rmomy = (fixed_t)LONG(players[i].rmomy); - - rsp->weapondelay = LONG(players[i].weapondelay); - rsp->tossdelay = LONG(players[i].tossdelay); - - rsp->starpostx = SHORT(players[i].starpostx); - rsp->starposty = SHORT(players[i].starposty); - rsp->starpostz = SHORT(players[i].starpostz); - rsp->starpostnum = LONG(players[i].starpostnum); - rsp->starposttime = (tic_t)LONG(players[i].starposttime); - rsp->starpostangle = (angle_t)LONG(players[i].starpostangle); - rsp->starpostscale = (fixed_t)LONG(players[i].starpostscale); - - rsp->maxlink = LONG(players[i].maxlink); - rsp->dashspeed = (fixed_t)LONG(players[i].dashspeed); - rsp->angle_pos = (angle_t)LONG(players[i].angle_pos); - rsp->old_angle_pos = (angle_t)LONG(players[i].old_angle_pos); - rsp->bumpertime = (tic_t)LONG(players[i].bumpertime); - rsp->flyangle = LONG(players[i].flyangle); - rsp->drilltimer = (tic_t)LONG(players[i].drilltimer); - rsp->linkcount = LONG(players[i].linkcount); - rsp->linktimer = (tic_t)LONG(players[i].linktimer); - rsp->anotherflyangle = LONG(players[i].anotherflyangle); - rsp->nightstime = (tic_t)LONG(players[i].nightstime); - rsp->drillmeter = LONG(players[i].drillmeter); - rsp->drilldelay = players[i].drilldelay; - rsp->bonustime = players[i].bonustime; - rsp->mare = players[i].mare; - rsp->lastsidehit = SHORT(players[i].lastsidehit); - rsp->lastlinehit = SHORT(players[i].lastlinehit); - - rsp->losstime = (tic_t)LONG(players[i].losstime); - rsp->timeshit = players[i].timeshit; - rsp->onconveyor = LONG(players[i].onconveyor); - - rsp->hasmo = false; - //Transfer important mo information if the player has a body. - //This lets us resync players even if they are dead. - if (!players[i].mo) - return; - rsp->hasmo = true; - - rsp->health = LONG(players[i].mo->health); - rsp->angle = (angle_t)LONG(players[i].mo->angle); - rsp->rollangle = (angle_t)LONG(players[i].mo->rollangle); - rsp->x = LONG(players[i].mo->x); - rsp->y = LONG(players[i].mo->y); - rsp->z = LONG(players[i].mo->z); - rsp->momx = LONG(players[i].mo->momx); - rsp->momy = LONG(players[i].mo->momy); - rsp->momz = LONG(players[i].mo->momz); - rsp->friction = LONG(players[i].mo->friction); - rsp->movefactor = LONG(players[i].mo->movefactor); - - rsp->sprite = (spritenum_t)LONG(players[i].mo->sprite); - rsp->frame = LONG(players[i].mo->frame); - rsp->sprite2 = players[i].mo->sprite2; - rsp->anim_duration = SHORT(players[i].mo->anim_duration); - rsp->tics = LONG(players[i].mo->tics); - rsp->statenum = (statenum_t)LONG(players[i].mo->state-states); // :( - rsp->eflags = (UINT16)SHORT(players[i].mo->eflags); - rsp->flags = LONG(players[i].mo->flags); - rsp->flags2 = LONG(players[i].mo->flags2); - - rsp->radius = LONG(players[i].mo->radius); - rsp->height = LONG(players[i].mo->height); - rsp->scale = LONG(players[i].mo->scale); - rsp->destscale = LONG(players[i].mo->destscale); - rsp->scalespeed = LONG(players[i].mo->scalespeed); -} - -static void resynch_read_player(resynch_pak *rsp) -{ - INT32 i = rsp->playernum, j; - mobj_t *savedmo = players[i].mo; - - // Do not send anything visual related. - // Only send data that we need to know for physics. - players[i].playerstate = (UINT8)rsp->playerstate; //playerstate_t - players[i].pflags = (UINT32)LONG(rsp->pflags); //pflags_t - players[i].panim = (UINT8)rsp->panim; //panim_t - - players[i].aiming = (angle_t)LONG(rsp->aiming); - players[i].currentweapon = LONG(rsp->currentweapon); - players[i].ringweapons = LONG(rsp->ringweapons); - - players[i].ammoremoval = (UINT16)SHORT(rsp->ammoremoval); - players[i].ammoremovaltimer = (tic_t)LONG(rsp->ammoremovaltimer); - players[i].ammoremovalweapon = LONG(rsp->ammoremovalweapon); - - for (j = 0; j < NUMPOWERS; ++j) - players[i].powers[j] = (UINT16)SHORT(rsp->powers[j]); - - // Score is resynched in the rspfirm resync packet - players[i].rings = SHORT(rsp->rings); - players[i].spheres = SHORT(rsp->spheres); - players[i].lives = rsp->lives; - players[i].continues = rsp->continues; - players[i].scoreadd = rsp->scoreadd; - players[i].xtralife = rsp->xtralife; - players[i].pity = rsp->pity; - - players[i].skincolor = rsp->skincolor; - players[i].skin = LONG(rsp->skin); - players[i].availabilities = LONG(rsp->availabilities); - // Just in case Lua does something like - // modify these at runtime - players[i].camerascale = (fixed_t)LONG(rsp->camerascale); - players[i].shieldscale = (fixed_t)LONG(rsp->shieldscale); - players[i].normalspeed = (fixed_t)LONG(rsp->normalspeed); - players[i].runspeed = (fixed_t)LONG(rsp->runspeed); - players[i].thrustfactor = rsp->thrustfactor; - players[i].accelstart = rsp->accelstart; - players[i].acceleration = rsp->acceleration; - players[i].charability = rsp->charability; - players[i].charability2 = rsp->charability2; - players[i].charflags = (UINT32)LONG(rsp->charflags); - players[i].thokitem = (UINT32)LONG(rsp->thokitem); //mobjtype_t - players[i].spinitem = (UINT32)LONG(rsp->spinitem); //mobjtype_t - players[i].revitem = (UINT32)LONG(rsp->revitem); //mobjtype_t - players[i].followitem = (UINT32)LONG(rsp->followitem); //mobjtype_t - players[i].actionspd = (fixed_t)LONG(rsp->actionspd); - players[i].mindash = (fixed_t)LONG(rsp->mindash); - players[i].maxdash = (fixed_t)LONG(rsp->maxdash); - players[i].jumpfactor = (fixed_t)LONG(rsp->jumpfactor); - players[i].height = (fixed_t)LONG(rsp->playerheight); - players[i].spinheight = (fixed_t)LONG(rsp->playerspinheight); - - players[i].speed = (fixed_t)LONG(rsp->speed); - players[i].secondjump = rsp->secondjump; - players[i].fly1 = rsp->fly1; - players[i].glidetime = (tic_t)LONG(rsp->glidetime); - players[i].climbing = rsp->climbing; - players[i].deadtimer = rsp->deadtimer; - players[i].exiting = (tic_t)LONG(rsp->exiting); - players[i].homing = rsp->homing; - players[i].dashmode = (tic_t)LONG(rsp->dashmode); - players[i].skidtime = (tic_t)LONG(rsp->skidtime); - players[i].cmomx = (fixed_t)LONG(rsp->cmomx); - players[i].cmomy = (fixed_t)LONG(rsp->cmomy); - players[i].rmomx = (fixed_t)LONG(rsp->rmomx); - players[i].rmomy = (fixed_t)LONG(rsp->rmomy); - - players[i].weapondelay = LONG(rsp->weapondelay); - players[i].tossdelay = LONG(rsp->tossdelay); - - players[i].starpostx = SHORT(rsp->starpostx); - players[i].starposty = SHORT(rsp->starposty); - players[i].starpostz = SHORT(rsp->starpostz); - players[i].starpostnum = LONG(rsp->starpostnum); - players[i].starposttime = (tic_t)LONG(rsp->starposttime); - players[i].starpostangle = (angle_t)LONG(rsp->starpostangle); - players[i].starpostscale = (fixed_t)LONG(rsp->starpostscale); - - players[i].maxlink = LONG(rsp->maxlink); - players[i].dashspeed = (fixed_t)LONG(rsp->dashspeed); - players[i].angle_pos = (angle_t)LONG(rsp->angle_pos); - players[i].old_angle_pos = (angle_t)LONG(rsp->old_angle_pos); - players[i].bumpertime = (tic_t)LONG(rsp->bumpertime); - players[i].flyangle = LONG(rsp->flyangle); - players[i].drilltimer = (tic_t)LONG(rsp->drilltimer); - players[i].linkcount = LONG(rsp->linkcount); - players[i].linktimer = (tic_t)LONG(rsp->linktimer); - players[i].anotherflyangle = LONG(rsp->anotherflyangle); - players[i].nightstime = (tic_t)LONG(rsp->nightstime); - players[i].drillmeter = LONG(rsp->drillmeter); - players[i].drilldelay = rsp->drilldelay; - players[i].bonustime = rsp->bonustime; - players[i].mare = rsp->mare; - players[i].lastsidehit = SHORT(rsp->lastsidehit); - players[i].lastlinehit = SHORT(rsp->lastlinehit); - - players[i].losstime = (tic_t)LONG(rsp->losstime); - players[i].timeshit = rsp->timeshit; - players[i].onconveyor = LONG(rsp->onconveyor); - - //We get a packet for each player in game. - if (!playeringame[i]) - return; - - //...but keep old mo even if it is corrupt or null! - players[i].mo = savedmo; - - //Transfer important mo information if they have a valid mo. - if (!rsp->hasmo) - return; - - //server thinks player has a body. - //Give them a new body that can be then manipulated by the server's info. - if (!players[i].mo) //client thinks it has no body. - P_SpawnPlayer(i); - - //At this point, the player should have a body, whether they were respawned or not. - P_UnsetThingPosition(players[i].mo); - players[i].mo->angle = (angle_t)LONG(rsp->angle); - players[i].mo->rollangle = (angle_t)LONG(rsp->rollangle); - players[i].mo->eflags = (UINT16)SHORT(rsp->eflags); - players[i].mo->flags = LONG(rsp->flags); - players[i].mo->flags2 = LONG(rsp->flags2); - players[i].mo->friction = LONG(rsp->friction); - players[i].mo->health = LONG(rsp->health); - players[i].mo->momx = LONG(rsp->momx); - players[i].mo->momy = LONG(rsp->momy); - players[i].mo->momz = LONG(rsp->momz); - players[i].mo->movefactor = LONG(rsp->movefactor); - - // Don't use P_SetMobjStateNF to restore state, write/read all the values manually! - // This should stop those stupid console errors, hopefully. - // -- Monster Iestyn - players[i].mo->sprite = (spritenum_t)LONG(rsp->sprite); - players[i].mo->frame = LONG(rsp->frame); - players[i].mo->sprite2 = rsp->sprite2; - players[i].mo->anim_duration = SHORT(rsp->anim_duration); - players[i].mo->tics = LONG(rsp->tics); - players[i].mo->state = &states[LONG(rsp->statenum)]; - - players[i].mo->x = LONG(rsp->x); - players[i].mo->y = LONG(rsp->y); - players[i].mo->z = LONG(rsp->z); - players[i].mo->radius = LONG(rsp->radius); - players[i].mo->height = LONG(rsp->height); - // P_SetScale is redundant for this, as all related variables are already restored properly. - players[i].mo->scale = LONG(rsp->scale); - players[i].mo->destscale = LONG(rsp->destscale); - players[i].mo->scalespeed = LONG(rsp->scalespeed); - - // And finally, SET THE MOBJ SKIN damn it. - if ((players[i].powers[pw_carry] == CR_NIGHTSMODE) && (skins[players[i].skin].sprites[SPR2_NFLY].numframes == 0)) - { - players[i].mo->skin = &skins[DEFAULTNIGHTSSKIN]; - players[i].mo->color = skins[DEFAULTNIGHTSSKIN].prefcolor; // this will be corrected by thinker to super flash - } - else - { - players[i].mo->skin = &skins[players[i].skin]; - players[i].mo->color = players[i].skincolor; // this will be corrected by thinker to super flash/mario star - } - - P_SetThingPosition(players[i].mo); -} - -static inline void resynch_write_ctf(resynchend_pak *rst) -{ - mobj_t *mflag; - UINT8 i, j; - - for (i = 0, mflag = redflag; i < 2; ++i, mflag = blueflag) - { - rst->flagx[i] = rst->flagy[i] = rst->flagz[i] = 0; - rst->flagloose[i] = rst->flagflags[i] = 0; - rst->flagplayer[i] = -1; - - if (!mflag) - { - // Should be held by a player - for (j = 0; j < MAXPLAYERS; ++j) - { - // GF_REDFLAG is 1, GF_BLUEFLAG is 2 - // redflag handling is i=0, blueflag is i=1 - // so check for gotflag == (i+1) - if (!playeringame[j] || players[j].gotflag != (i+1)) - continue; - 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; - } - - rst->flagx[i] = (fixed_t)LONG(mflag->x); - rst->flagy[i] = (fixed_t)LONG(mflag->y); - rst->flagz[i] = (fixed_t)LONG(mflag->z); - rst->flagflags[i] = LONG(mflag->flags2); - rst->flagloose[i] = LONG(mflag->fuse); // Dropped or not? - } -} - -static inline void resynch_read_ctf(resynchend_pak *p) -{ - UINT8 i; - - for (i = 0; i < MAXPLAYERS; ++i) - players[i].gotflag = 0; - - // Red flag - if (p->flagplayer[0] == -2) - ; // The server doesn't even know what happened to it... - else if (p->flagplayer[0] != -1) // Held by a player - { - if (!playeringame[p->flagplayer[0]]) - I_Error("Invalid red flag player %d who isn't in the game!", (INT32)p->flagplayer[0]); - players[p->flagplayer[0]].gotflag = GF_REDFLAG; - if (redflag) - { - P_RemoveMobj(redflag); - redflag = NULL; - } - } - else - { - if (!redflag) - redflag = P_SpawnMobj(0,0,0,MT_REDFLAG); - - P_UnsetThingPosition(redflag); - redflag->x = (fixed_t)LONG(p->flagx[0]); - redflag->y = (fixed_t)LONG(p->flagy[0]); - redflag->z = (fixed_t)LONG(p->flagz[0]); - redflag->flags2 = LONG(p->flagflags[0]); - redflag->fuse = LONG(p->flagloose[0]); - P_SetThingPosition(redflag); - } - - // Blue flag - if (p->flagplayer[1] == -2) - ; // The server doesn't even know what happened to it... - else if (p->flagplayer[1] != -1) // Held by a player - { - if (!playeringame[p->flagplayer[1]]) - I_Error("Invalid blue flag player %d who isn't in the game!", (INT32)p->flagplayer[1]); - players[p->flagplayer[1]].gotflag = GF_BLUEFLAG; - if (blueflag) - { - P_RemoveMobj(blueflag); - blueflag = NULL; - } - } - else - { - if (!blueflag) - blueflag = P_SpawnMobj(0,0,0,MT_BLUEFLAG); - - P_UnsetThingPosition(blueflag); - blueflag->x = (fixed_t)LONG(p->flagx[1]); - blueflag->y = (fixed_t)LONG(p->flagy[1]); - blueflag->z = (fixed_t)LONG(p->flagz[1]); - blueflag->flags2 = LONG(p->flagflags[1]); - blueflag->fuse = LONG(p->flagloose[1]); - P_SetThingPosition(blueflag); - } -} - -static inline void resynch_write_others(resynchend_pak *rst) -{ - UINT8 i; - - rst->ingame = 0; - rst->outofcoop = 0; - - for (i = 0; i < MAXPLAYERS; ++i) - { - if (!playeringame[i]) - { - rst->ctfteam[i] = 0; - rst->score[i] = 0; - rst->numboxes[i] = 0; - rst->totalring[i] = 0; - rst->realtime[i] = 0; - rst->laps[i] = 0; - continue; - } - - if (!players[i].spectator) - rst->ingame |= (1<outofcoop |= (1<ctfteam[i] = (INT32)LONG(players[i].ctfteam); - rst->score[i] = (UINT32)LONG(players[i].score); - rst->numboxes[i] = SHORT(players[i].numboxes); - rst->totalring[i] = SHORT(players[i].totalring); - rst->realtime[i] = (tic_t)LONG(players[i].realtime); - rst->laps[i] = players[i].laps; - } - - // endian safeness - rst->ingame = (UINT32)LONG(rst->ingame); -} - -static inline void resynch_read_others(resynchend_pak *p) -{ - UINT8 i; - UINT32 loc_ingame = (UINT32)LONG(p->ingame); - UINT32 loc_outofcoop = (UINT32)LONG(p->outofcoop); - - for (i = 0; i < MAXPLAYERS; ++i) - { - // We don't care if they're in the game or not, just write all the data. - players[i].spectator = !(loc_ingame & (1<ctfteam[i]); // no, 0 does not mean spectator, at least not in Match - players[i].score = (UINT32)LONG(p->score[i]); - players[i].numboxes = SHORT(p->numboxes[i]); - players[i].totalring = SHORT(p->totalring[i]); - players[i].realtime = (tic_t)LONG(p->realtime[i]); - players[i].laps = p->laps[i]; - } -} - -static void SV_InitResynchVars(INT32 node) -{ - resynch_delay[node] = TICRATE; // initial one second delay - resynch_score[node] = 0; // clean slate - resynch_status[node] = 0x00; - resynch_inprogress[node] = false; - memset(resynch_sent[node], 0, MAXPLAYERS); -} - -static void SV_RequireResynch(INT32 node) -{ - INT32 i; - - resynch_delay[node] = 10; // Delay before you can fail sync again - resynch_score[node] += 200; // Add score for initial desynch - resynch_status[node] = 0xFFFFFFFF; // No players assumed synched - resynch_inprogress[node] = true; // so we know to send a PT_RESYNCHEND after sync - - // Initial setup - memset(resynch_sent[node], 0, MAXPLAYERS); - for (i = 0; i < MAXPLAYERS; ++i) - { - if (!playeringame[i]) // Player not in game so just drop it from required synch - resynch_status[node] &= ~(1<>1)+1; - } -} - -static void SV_SendResynch(INT32 node) -{ - INT32 i, j; - - if (!nodeingame[node]) - { - // player left during resynch - // so obviously we don't need to do any of this anymore - resynch_inprogress[node] = false; - return; - } - - // resynched? - if (!resynch_status[node]) - { - // you are now synched - resynch_inprogress[node] = false; - - netbuffer->packettype = PT_RESYNCHEND; - - netbuffer->u.resynchend.randomseed = P_GetRandSeed(); - if (gametyperules & GTR_TEAMFLAGS) - resynch_write_ctf(&netbuffer->u.resynchend); - resynch_write_others(&netbuffer->u.resynchend); - - HSendPacket(node, true, 0, (sizeof(resynchend_pak))); - return; - } - - netbuffer->packettype = PT_RESYNCHING; - for (i = 0, j = 0; i < MAXPLAYERS; ++i) - { - // if already synched don't bother - if (!(resynch_status[node] & 1<u.resynchpak, i); - HSendPacket(node, false, 0, (sizeof(resynch_pak))); - - resynch_sent[node][i] = TICRATE; - resynch_score[node] += 2; // penalty for send - - if (++j > 3) - break; - } - - if (resynch_score[node] > (unsigned)cv_resynchattempts.value*250) - { - SendKick(nodetoplayer[node], KICK_MSG_CON_FAIL | KICK_MSG_KEEP_BODY); - resynch_score[node] = 0; - } -} - -static void CL_AcknowledgeResynch(resynch_pak *rsp) -{ - resynch_read_player(rsp); - - netbuffer->packettype = PT_RESYNCHGET; - netbuffer->u.resynchgot = rsp->playernum; - HSendPacket(servernode, true, 0, sizeof(UINT8)); -} - -static void SV_AcknowledgeResynchAck(INT32 node, UINT8 rsg) -{ - if (rsg >= MAXPLAYERS) - resynch_score[node] += 16384; // lol. - else - { - resynch_status[node] &= ~(1<packettype = PT_RECEIVEDGAMESTATE; + HSendPacket(servernode, true, 0, 0); } static void CL_ReloadReceivedSavegame(void) @@ -2535,7 +1943,6 @@ void CL_Reset(void) multiplayer = false; servernode = 0; server = true; - resynch_local_inprogress = false; doomcom->numnodes = 1; doomcom->numslots = 1; SV_StopServer(); @@ -3112,7 +2519,7 @@ static void ResetNode(INT32 node) nodewaiting[node] = 0; playerpernode[node] = 0; sendingsavegame[node] = false; - SV_InitResynchVars(node); + resendingsavegame[node] = false; } void SV_ResetServer(void) @@ -3634,12 +3041,6 @@ static void HandleConnect(SINT8 node) #endif 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 (cv_joinnextround.value && gameaction == ga_nothing) G_SetGamestate(GS_WAITINGPLAYERS); if (!SV_SendServerConfig(node)) @@ -3762,6 +3163,7 @@ static void PT_CanReceiveGamestate(SINT8 node) CONS_Printf(M_GetText("Resending game state to %s...\n"), player_names[nodetoplayer[node]]); SV_SendSaveGame(node, true); // Resend a complete game state + resendingsavegame[node] = true; } /** Handles a packet received from a node that isn't in game @@ -3976,11 +3378,6 @@ static void HandlePacketFromPlayer(SINT8 node) switch (netbuffer->packettype) { // -------------------------------------------- SERVER RECEIVE ---------- - case PT_RESYNCHGET: - if (client) - break; - SV_AcknowledgeResynchAck(netconsole, netbuffer->u.resynchgot); - break; case PT_CLIENTCMD: case PT_CLIENT2CMD: case PT_CLIENTMIS: @@ -3990,10 +3387,6 @@ static void HandlePacketFromPlayer(SINT8 node) if (client) break; - // Ignore tics from those not synched - if (resynch_inprogress[node] && nettics[node] == gametic) - break; - // To save bytes, only the low byte of tic numbers are sent // Use ExpandTics to figure out what the rest of the bytes are realstart = ExpandTics(netbuffer->u.clientpak.client_tic); @@ -4020,9 +3413,6 @@ static void HandlePacketFromPlayer(SINT8 node) || netbuffer->packettype == PT_NODEKEEPALIVEMIS) break; - // If a client sends a ticcmd it should mean they are done receiving the savegame - sendingsavegame[node] = false; - // As long as clients send valid ticcmds, the server can keep running, so reset the timeout /// \todo Use a separate cvar for that kind of timeout? freezetimeout[node] = I_GetTime() + connectiontimeout; @@ -4047,21 +3437,19 @@ static void HandlePacketFromPlayer(SINT8 node) G_MoveTiccmd(&netcmds[maketic%BACKUPTICS][(UINT8)nodetoplayer2[node]], &netbuffer->u.client2pak.cmd2, 1); - // A delay before we check resynching - // Used on join or just after a synch fail - if (resynch_delay[node]) - { - --resynch_delay[node]; - break; - } // Check player consistancy during the level if (realstart <= gametic && realstart > gametic - BACKUPTICS+1 && gamestate == GS_LEVEL - && consistancy[realstart%BACKUPTICS] != SHORT(netbuffer->u.clientpak.consistancy)) + && consistancy[realstart%BACKUPTICS] != SHORT(netbuffer->u.clientpak.consistancy) + && !resendingsavegame[node]) { - SV_RequireResynch(node); - - if (cv_resynchattempts.value && resynch_score[node] <= (unsigned)cv_resynchattempts.value*250) + if (cv_resynchattempts.value) { + // Tell the client we are about to resend them the gamestate + netbuffer->packettype = PT_WILLRESENDGAMESTATE; + HSendPacket(node, true, 0, 0); + + resendingsavegame[node] = true; + if (cv_blamecfail.value) CONS_Printf(M_GetText("Synch failure for player %d (%s); expected %hd, got %hd\n"), netconsole+1, player_names[netconsole], @@ -4081,8 +3469,6 @@ static void HandlePacketFromPlayer(SINT8 node) break; } } - else if (resynch_score[node]) - --resynch_score[node]; break; case PT_TEXTCMD2: // splitscreen special netconsole = nodetoplayer2[node]; @@ -4211,25 +3597,11 @@ static void HandlePacketFromPlayer(SINT8 node) case PT_CANRECEIVEGAMESTATE: PT_CanReceiveGamestate(node); break; -// -------------------------------------------- CLIENT RECEIVE ---------- - case PT_RESYNCHEND: - // Only accept PT_RESYNCHEND from the server. - if (node != servernode) - { - CONS_Alert(CONS_WARNING, M_GetText("%s received from non-host %d\n"), "PT_RESYNCHEND", node); - if (server) - SendKick(netconsole, KICK_MSG_CON_FAIL | KICK_MSG_KEEP_BODY); - break; - } - resynch_local_inprogress = false; - - P_SetRandSeed(netbuffer->u.resynchend.randomseed); - - if (gametyperules & GTR_TEAMFLAGS) - resynch_read_ctf(&netbuffer->u.resynchend); - resynch_read_others(&netbuffer->u.resynchend); - + case PT_RECEIVEDGAMESTATE: + sendingsavegame[node] = false; + resendingsavegame[node] = false; break; +// -------------------------------------------- CLIENT RECEIVE ---------- case PT_SERVERTICS: // Only accept PT_SERVERTICS from the server. if (node != servernode) @@ -4293,18 +3665,6 @@ static void HandlePacketFromPlayer(SINT8 node) "IRC or Discord so it can be fixed.\n", (INT32)realstart, (INT32)realend, (INT32)neededtic);*/ } break; - case PT_RESYNCHING: - // Only accept PT_RESYNCHING from the server. - if (node != servernode) - { - CONS_Alert(CONS_WARNING, M_GetText("%s received from non-host %d\n"), "PT_RESYNCHING", node); - if (server) - SendKick(netconsole, KICK_MSG_CON_FAIL | KICK_MSG_KEEP_BODY); - break; - } - resynch_local_inprogress = true; - CL_AcknowledgeResynch(&netbuffer->u.resynchpak); - break; case PT_PING: // Only accept PT_PING from the server. if (node != servernode) @@ -4832,7 +4192,7 @@ void TryRunTics(tic_t realtics) if (player_joining) return; - if (neededtic > gametic && !resynch_local_inprogress) + if (neededtic > gametic) { if (advancedemo) { @@ -4991,9 +4351,9 @@ void NetUpdate(void) if (cl_redownloadinggamestate && fileneeded[0].status == FS_FOUND) CL_ReloadReceivedSavegame(); - if (!(resynch_local_inprogress || cl_redownloadinggamestate)) + if (!cl_redownloadinggamestate) CL_SendClientCmd(); // Send tic cmd - hu_resynching = resynch_local_inprogress; + hu_redownloadinggamestate = cl_redownloadinggamestate; } else { @@ -5001,7 +4361,7 @@ void NetUpdate(void) { INT32 counts; - hu_resynching = false; + hu_redownloadinggamestate = false; firstticstosend = gametic; for (i = 0; i < MAXNETNODES; i++) @@ -5011,18 +4371,6 @@ void NetUpdate(void) // Don't erase tics not acknowledged counts = realtics; - for (i = 0; i < MAXNETNODES; ++i) - if (resynch_inprogress[i]) - { - if (!nodeingame[i] || nettics[i] == gametic) - { - SV_SendResynch(i); - counts = -666; - } - else - counts = 0; // Let the client catch up with the server - } - // Do not make tics while resynching if (counts != -666) { @@ -5040,7 +4388,7 @@ void NetUpdate(void) neededtic = maketic; // The server is a client too } else - hu_resynching = true; + hu_redownloadinggamestate = true; } } Net_AckTicker(); diff --git a/src/d_clisrv.h b/src/d_clisrv.h index 0f1998d51..81ea17638 100644 --- a/src/d_clisrv.h +++ b/src/d_clisrv.h @@ -64,11 +64,10 @@ typedef enum PT_REQUESTFILE, // Client requests a file transfer PT_ASKINFOVIAMS, // Packet from the MS requesting info be sent to new client. // If this ID changes, update masterserver definition. - PT_RESYNCHEND, // Player is now resynched and is being requested to remake the gametic - PT_RESYNCHGET, // Player got resynch packet PT_WILLRESENDGAMESTATE, // Hey Client, I am about to resend you the gamestate! - PT_CANRECEIVEGAMESTATE, // Okay Server, I'm ready to receive it, you can go ahead. + PT_CANRECEIVEGAMESTATE, // Okay Server, I'm ready to receive it, you can go ahead. + PT_RECEIVEDGAMESTATE, // Thank you Server, I am ready to play again! // Add non-PT_CANFAIL packet types here to avoid breaking MS compatibility. @@ -82,8 +81,6 @@ typedef enum PT_TEXTCMD2, // Splitscreen text commands. PT_CLIENTJOIN, // Client wants to join; used in start game. PT_NODETIMEOUT, // Packet sent to self if the connection times out. - PT_RESYNCHING, // Packet sent to resync players. - // Blocks game advance until synched. PT_LOGIN, // Login attempt from the client. @@ -136,165 +133,6 @@ typedef struct ticcmd_t cmds[45]; // Normally [BACKUPTIC][MAXPLAYERS] but too large } ATTRPACK servertics_pak; -// Sent to client when all consistency data -// for players has been restored -typedef struct -{ - UINT32 randomseed; - - // CTF flag stuff - SINT8 flagplayer[2]; - INT32 flagloose[2]; - INT32 flagflags[2]; - fixed_t flagx[2]; - fixed_t flagy[2]; - fixed_t flagz[2]; - - UINT32 ingame; // Spectator bit for each player - UINT32 outofcoop; // outofcoop bit for each player - INT32 ctfteam[MAXPLAYERS]; // Which team? (can't be 1 bit, since in regular Match there are no teams) - - // Resynch game scores and the like all at once - UINT32 score[MAXPLAYERS]; // Everyone's score - INT16 numboxes[MAXPLAYERS]; - INT16 totalring[MAXPLAYERS]; - tic_t realtime[MAXPLAYERS]; - UINT8 laps[MAXPLAYERS]; -} ATTRPACK resynchend_pak; - -typedef struct -{ - // Player stuff - UINT8 playernum; - - // Do not send anything visual related. - // Only send data that we need to know for physics. - UINT8 playerstate; // playerstate_t - UINT32 pflags; // pflags_t - UINT8 panim; // panim_t - - angle_t aiming; - INT32 currentweapon; - INT32 ringweapons; - UINT16 ammoremoval; - tic_t ammoremovaltimer; - INT32 ammoremovalweapon; - UINT16 powers[NUMPOWERS]; - - // Score is resynched in the confirm resync packet - INT16 rings; - INT16 spheres; - SINT8 lives; - SINT8 continues; - UINT8 scoreadd; - SINT8 xtralife; - SINT8 pity; - - UINT8 skincolor; - INT32 skin; - UINT32 availabilities; - // Just in case Lua does something like - // modify these at runtime - fixed_t camerascale; - fixed_t shieldscale; - fixed_t normalspeed; - fixed_t runspeed; - UINT8 thrustfactor; - UINT8 accelstart; - UINT8 acceleration; - UINT8 charability; - UINT8 charability2; - UINT32 charflags; - UINT32 thokitem; // mobjtype_t - UINT32 spinitem; // mobjtype_t - UINT32 revitem; // mobjtype_t - UINT32 followitem; // mobjtype_t - fixed_t actionspd; - fixed_t mindash; - fixed_t maxdash; - fixed_t jumpfactor; - fixed_t playerheight; - fixed_t playerspinheight; - - fixed_t speed; - UINT8 secondjump; - UINT8 fly1; - tic_t glidetime; - UINT8 climbing; - INT32 deadtimer; - tic_t exiting; - UINT8 homing; - tic_t dashmode; - tic_t skidtime; - fixed_t cmomx; - fixed_t cmomy; - fixed_t rmomx; - fixed_t rmomy; - - INT32 weapondelay; - INT32 tossdelay; - - INT16 starpostx; - INT16 starposty; - INT16 starpostz; - INT32 starpostnum; - tic_t starposttime; - angle_t starpostangle; - fixed_t starpostscale; - - INT32 maxlink; - fixed_t dashspeed; - angle_t angle_pos; - angle_t old_angle_pos; - tic_t bumpertime; - INT32 flyangle; - tic_t drilltimer; - INT32 linkcount; - tic_t linktimer; - INT32 anotherflyangle; - tic_t nightstime; - INT32 drillmeter; - UINT8 drilldelay; - UINT8 bonustime; - UINT8 mare; - INT16 lastsidehit, lastlinehit; - - tic_t losstime; - UINT8 timeshit; - INT32 onconveyor; - - //player->mo stuff - UINT8 hasmo; // Boolean - - INT32 health; - angle_t angle; - angle_t rollangle; - fixed_t x; - fixed_t y; - fixed_t z; - fixed_t momx; - fixed_t momy; - fixed_t momz; - fixed_t friction; - fixed_t movefactor; - - spritenum_t sprite; - UINT32 frame; - UINT8 sprite2; - UINT16 anim_duration; - INT32 tics; - statenum_t statenum; - UINT32 flags; - UINT32 flags2; - UINT16 eflags; - - fixed_t radius; - fixed_t height; - fixed_t scale; - fixed_t destscale; - fixed_t scalespeed; -} ATTRPACK resynch_pak; - typedef struct { UINT8 version; // Different versions don't work @@ -430,9 +268,6 @@ typedef struct client2cmd_pak client2pak; // 200 bytes servertics_pak serverpak; // 132495 bytes (more around 360, no?) serverconfig_pak servercfg; // 773 bytes - resynchend_pak resynchend; // - resynch_pak resynchpak; // - UINT8 resynchgot; // UINT8 textcmd[MAXTEXTCMD+1]; // 66049 bytes (wut??? 64k??? More like 257 bytes...) filetx_pak filetxpak; // 139 bytes clientconfig_pak clientcfg; // 136 bytes @@ -567,7 +402,7 @@ UINT8 GetFreeXCmdSize(void); void D_MD5PasswordPass(const UINT8 *buffer, size_t len, const char *salt, void *dest); -extern UINT8 hu_resynching; +extern UINT8 hu_redownloadinggamestate; extern UINT8 adminpassmd5[16]; extern boolean adminpasswordset; diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 98f3ca5a9..561c04677 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -2206,7 +2206,7 @@ void HU_Drawer(void) HU_DrawCrosshair2(); // draw desynch text - if (hu_resynching) + if (hu_redownloadinggamestate) { static UINT32 resynch_ticker = 0; char resynch_text[14]; From 46d8546f49335334092e0a67219bb914866d77b3 Mon Sep 17 00:00:00 2001 From: Louis-Antoine Date: Sun, 1 Mar 2020 03:26:15 +0100 Subject: [PATCH 0006/1080] Update packet names --- src/d_net.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/d_net.c b/src/d_net.c index 140226990..703e9810e 100644 --- a/src/d_net.c +++ b/src/d_net.c @@ -796,18 +796,15 @@ static const char *packettypename[NUMPACKETTYPE] = "REQUESTFILE", "ASKINFOVIAMS", - "RESYNCHEND", - "RESYNCHGET", - "WILLRESENDGAMESTATE", - "CANRESENDGAMESTATE", + "CANRECEIVEGAMESTATE", + "RECEIVEDGAMESTATE", "FILEFRAGMENT", "TEXTCMD", "TEXTCMD2", "CLIENTJOIN", "NODETIMEOUT", - "RESYNCHING", "PING" }; From b85ac6537804b7ea38ebb5cba69d3ae33d3ad50b Mon Sep 17 00:00:00 2001 From: Louis-Antoine Date: Sun, 8 Mar 2020 20:04:29 +0100 Subject: [PATCH 0007/1080] Fix missing break --- src/d_clisrv.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index de477c99b..9e0294152 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -3604,6 +3604,7 @@ static void HandlePacketFromPlayer(SINT8 node) break; case PT_CANRECEIVEGAMESTATE: PT_CanReceiveGamestate(node); + break; #ifdef HAVE_BLUA case PT_ASKLUAFILE: if (server && luafiletransfers && luafiletransfers->nodestatus[node] == LFTNS_ASKED) From a7e99ab5cfd2acb306542c448dfb6af9140e4d28 Mon Sep 17 00:00:00 2001 From: Nev3r Date: Sun, 12 Apr 2020 11:56:36 +0200 Subject: [PATCH 0008/1080] Added static multitag read and storage on mapload. --- src/CMakeLists.txt | 2 ++ src/Makefile | 1 + src/doomdata.h | 3 +++ src/p_setup.c | 50 +++++++++++++++++++++++++++++++++++++++++++++- src/r_defs.h | 4 ++++ src/taglist.c | 8 ++++++++ src/taglist.h | 14 +++++++++++++ 7 files changed, 81 insertions(+), 1 deletion(-) create mode 100644 src/taglist.c create mode 100644 src/taglist.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b0a593bb1..7f18407ac 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -164,6 +164,7 @@ set(SRB2_CORE_GAME_SOURCES p_telept.c p_tick.c p_user.c + taglist.c p_local.h p_maputl.h @@ -175,6 +176,7 @@ set(SRB2_CORE_GAME_SOURCES p_slopes.h p_spec.h p_tick.h + taglist.h ) if(NOT (CMAKE_CXX_COMPILER_ID MATCHES "Clang")) diff --git a/src/Makefile b/src/Makefile index fdf9c78b7..d27883563 100644 --- a/src/Makefile +++ b/src/Makefile @@ -474,6 +474,7 @@ OBJS:=$(i_main_o) \ $(OBJDIR)/r_patch.o \ $(OBJDIR)/r_portal.o \ $(OBJDIR)/screen.o \ + $(OBJDIR)/taglist.o \ $(OBJDIR)/v_video.o \ $(OBJDIR)/s_sound.o \ $(OBJDIR)/sounds.o \ diff --git a/src/doomdata.h b/src/doomdata.h index d9bfb43b1..884c043a4 100644 --- a/src/doomdata.h +++ b/src/doomdata.h @@ -23,6 +23,8 @@ // Some global defines, that configure the game. #include "doomdef.h" +#include "taglist.h" + // // Map level types. // The following data structures define the persistent format @@ -204,6 +206,7 @@ typedef struct INT16 z; UINT8 extrainfo; INT16 tag; + taglist_t tags; struct mobj_s *mobj; } mapthing_t; diff --git a/src/p_setup.c b/src/p_setup.c index 871fb14fe..e4658d742 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -81,6 +81,8 @@ #include "fastcmp.h" // textmap parsing +#include "taglist.h" + // // Map MD5, calculated on level load. // Sent to clients in PT_SERVERINFO. @@ -935,6 +937,8 @@ static void P_LoadSectors(UINT8 *data) ss->lightlevel = SHORT(ms->lightlevel); ss->special = SHORT(ms->special); ss->tag = SHORT(ms->tag); + if (ss->tag) + Tag_Add(&ss->tags, ss->tag); ss->floor_xoffs = ss->floor_yoffs = 0; ss->ceiling_xoffs = ss->ceiling_yoffs = 0; @@ -1049,6 +1053,8 @@ static void P_LoadLinedefs(UINT8 *data) ld->flags = SHORT(mld->flags); ld->special = SHORT(mld->special); ld->tag = SHORT(mld->tag); + if (ld->tag) + Tag_Add(&ld->tags, ld->tag); memset(ld->args, 0, NUMLINEARGS*sizeof(*ld->args)); memset(ld->stringargs, 0x00, NUMLINESTRINGARGS*sizeof(*ld->stringargs)); ld->alpha = FRACUNIT; @@ -1398,7 +1404,21 @@ static void ParseTextmapSectorParameter(UINT32 i, char *param, char *val) else if (fastcmp(param, "special")) sectors[i].special = atol(val); else if (fastcmp(param, "id")) + { sectors[i].tag = atol(val); + if (sectors[i].tag) + Tag_Add(§ors[i].tags, sectors[i].tag); + } + else if (fastcmp(param, "moreids")) + { + char* id = val; + while (id) + { + Tag_Add(§ors[i].tags, atol(id)); + if ((id = strchr(id, ' '))) + id++; + } + } else if (fastcmp(param, "xpanningfloor")) sectors[i].floor_xoffs = FLOAT_TO_FIXED(atof(val)); else if (fastcmp(param, "ypanningfloor")) @@ -1434,7 +1454,21 @@ static void ParseTextmapSidedefParameter(UINT32 i, char *param, char *val) static void ParseTextmapLinedefParameter(UINT32 i, char *param, char *val) { if (fastcmp(param, "id")) + { lines[i].tag = atol(val); + if (lines[i].tag) + Tag_Add(&lines[i].tags, lines[i].tag); + } + else if (fastcmp(param, "moreids")) + { + char* id = val; + while (id) + { + Tag_Add(&lines[i].tags, atol(id)); + if ((id = strchr(id, ' '))) + id++; + } + } else if (fastcmp(param, "special")) lines[i].special = atol(val); else if (fastcmp(param, "v1")) @@ -1501,8 +1535,22 @@ static void ParseTextmapLinedefParameter(UINT32 i, char *param, char *val) static void ParseTextmapThingParameter(UINT32 i, char *param, char *val) { if (fastcmp(param, "id")) + { mapthings[i].tag = atol(val); - if (fastcmp(param, "x")) + if (mapthings[i].tag) + Tag_Add(&mapthings[i].tags, mapthings[i].tag); + } + else if (fastcmp(param, "moreids")) + { + char* id = val; + while (id) + { + Tag_Add(&mapthings[i].tags, atol(id)); + if ((id = strchr(id, ' '))) + id++; + } + } + else if (fastcmp(param, "x")) mapthings[i].x = atol(val); else if (fastcmp(param, "y")) mapthings[i].y = atol(val); diff --git a/src/r_defs.h b/src/r_defs.h index 943f54761..ab35b2055 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -30,6 +30,8 @@ #define POLYOBJECTS +#include "taglist.h" + // // ClipWallSegment // Clips the given range of columns @@ -290,6 +292,7 @@ typedef struct sector_s INT16 lightlevel; INT16 special; UINT16 tag; + taglist_t tags; INT32 nexttag, firsttag; // for fast tag searches // origin for any sounds played by the sector @@ -413,6 +416,7 @@ typedef struct line_s INT16 flags; INT16 special; INT16 tag; + taglist_t tags; INT32 args[NUMLINEARGS]; char *stringargs[NUMLINESTRINGARGS]; diff --git a/src/taglist.c b/src/taglist.c new file mode 100644 index 000000000..9090d4e0b --- /dev/null +++ b/src/taglist.c @@ -0,0 +1,8 @@ +#include "taglist.h" +#include "z_zone.h" + +void Tag_Add (taglist_t* list, const UINT16 tag) +{ + list->tags = Z_Realloc(list->tags, (list->count + 1) * sizeof(list->tags), PU_LEVEL, NULL); + list->tags[list->count++] = tag; +} diff --git a/src/taglist.h b/src/taglist.h new file mode 100644 index 000000000..744918d7c --- /dev/null +++ b/src/taglist.h @@ -0,0 +1,14 @@ +#include "doomtype.h" + +#ifndef __R_TAGLIST__ +#define __R_TAGLIST__ + +/// Multitag list. +typedef struct +{ + UINT16* tags; + UINT16 count; +} taglist_t; + +void Tag_Add (taglist_t* list, const UINT16 tag); +#endif //__R_TAGLIST__ From ab2619d5386336044b1d13e0f9785d7ad4f808ba Mon Sep 17 00:00:00 2001 From: Nev3r Date: Sun, 12 Apr 2020 13:04:15 +0200 Subject: [PATCH 0009/1080] Wrap P_FindSectorFromLineTag() is now a wrapper for P_FindSectorFromTag(). --- src/p_spec.c | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/src/p_spec.c b/src/p_spec.c index cf4ab3da3..529c50e4d 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -998,23 +998,7 @@ static sector_t *P_FindModelCeilingSector(fixed_t ceildestheight, INT32 secnum) */ INT32 P_FindSectorFromLineTag(line_t *line, INT32 start) { - if (line->tag == -1) - { - start++; - - if (start >= (INT32)numsectors) - return -1; - - return start; - } - else - { - start = start >= 0 ? sectors[start].nexttag : - sectors[(unsigned)line->tag % numsectors].firsttag; - while (start >= 0 && sectors[start].tag != line->tag) - start = sectors[start].nexttag; - return start; - } + return P_FindSectorFromTag(line->tag, start); } /** Searches the tag lists for the next sector with a given tag. From bfd48c4c83d34d667648f31c8edf034f5f88f2ae Mon Sep 17 00:00:00 2001 From: Nev3r Date: Sun, 12 Apr 2020 13:05:21 +0200 Subject: [PATCH 0010/1080] add Tag_Compare() --- src/taglist.c | 14 ++++++++++++++ src/taglist.h | 1 + 2 files changed, 15 insertions(+) diff --git a/src/taglist.c b/src/taglist.c index 9090d4e0b..ceaebf9aa 100644 --- a/src/taglist.c +++ b/src/taglist.c @@ -6,3 +6,17 @@ void Tag_Add (taglist_t* list, const UINT16 tag) list->tags = Z_Realloc(list->tags, (list->count + 1) * sizeof(list->tags), PU_LEVEL, NULL); list->tags[list->count++] = tag; } + +boolean Tag_Compare (const taglist_t* list1, const taglist_t* list2) +{ + size_t i; + + if (list1->count != list2->count) + return false; + + for (i = 0; i < list1->count; i++) + if (list1->tags[i] != list2->tags[i]) + return false; + + return true; +} diff --git a/src/taglist.h b/src/taglist.h index 744918d7c..62fac0d82 100644 --- a/src/taglist.h +++ b/src/taglist.h @@ -11,4 +11,5 @@ typedef struct } taglist_t; void Tag_Add (taglist_t* list, const UINT16 tag); +boolean Tag_Compare (const taglist_t* list1, const taglist_t* list2); #endif //__R_TAGLIST__ From fe4ab5d29f5d68759820912bc3762d5803d6a968 Mon Sep 17 00:00:00 2001 From: Nev3r Date: Sun, 12 Apr 2020 13:14:39 +0200 Subject: [PATCH 0011/1080] Use Tags_Compare wrapper on software renderer to compare sector tags. --- src/r_bsp.c | 5 +++-- src/r_segs.c | 7 ++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/r_bsp.c b/src/r_bsp.c index 77ab2a82f..e581e6687 100644 --- a/src/r_bsp.c +++ b/src/r_bsp.c @@ -21,6 +21,7 @@ #include "p_local.h" // camera #include "p_slopes.h" #include "z_zone.h" // Check R_Prep3DFloors +#include "taglist.h" seg_t *curline; side_t *sidedef; @@ -376,7 +377,7 @@ boolean R_IsEmptyLine(seg_t *line, sector_t *front, sector_t *back) // Consider colormaps && back->extra_colormap == front->extra_colormap && ((!front->ffloors && !back->ffloors) - || front->tag == back->tag)); + || Tags_Compare(&front->tags, &back->tags))); } // @@ -488,7 +489,7 @@ static void R_AddLine(seg_t *line) #endif !line->sidedef->midtexture && ((!frontsector->ffloors && !backsector->ffloors) - || (frontsector->tag == backsector->tag))) + || Tags_Compare(&frontsector->tags, &backsector->tags))) return; // line is empty, don't even bother goto clippass; // treat like wide open window instead diff --git a/src/r_segs.c b/src/r_segs.c index e777ab2d0..1d6a56467 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -25,6 +25,7 @@ #include "p_local.h" // Camera... #include "p_slopes.h" #include "console.h" // con_clipviewtop +#include "taglist.h" // OPTIMIZE: closed two sided lines as single sided @@ -2014,7 +2015,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) || backsector->floorlightsec != frontsector->floorlightsec //SoM: 4/3/2000: Check for colormaps || frontsector->extra_colormap != backsector->extra_colormap - || (frontsector->ffloors != backsector->ffloors && frontsector->tag != backsector->tag)) + || (frontsector->ffloors != backsector->ffloors && !Tags_Compare(&frontsector->tags, &backsector->tags)) { markfloor = true; } @@ -2045,7 +2046,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) || backsector->ceilinglightsec != frontsector->ceilinglightsec //SoM: 4/3/2000: Check for colormaps || frontsector->extra_colormap != backsector->extra_colormap - || (frontsector->ffloors != backsector->ffloors && frontsector->tag != backsector->tag)) + || (frontsector->ffloors != backsector->ffloors && !Tags_Compare(&frontsector->tags, &backsector->tags)) { markceiling = true; } @@ -2135,7 +2136,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) rw_bottomtexturemid += sidedef->rowoffset; // allocate space for masked texture tables - if (frontsector && backsector && frontsector->tag != backsector->tag && (backsector->ffloors || frontsector->ffloors)) + if (frontsector && backsector && !Tags_Compare(&frontsector->tags, &backsector->tags) && (backsector->ffloors || frontsector->ffloors)) { ffloor_t *rover; ffloor_t *r2; From 64e2e7c12f5e9c40000c113f39c602a6bcedd43c Mon Sep 17 00:00:00 2001 From: Nev3r Date: Sun, 12 Apr 2020 13:16:33 +0200 Subject: [PATCH 0012/1080] Use Tags_Compare wrapper in the OpenGL renderer, as well. --- src/hardware/hw_main.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 235505341..05b7c997f 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -1862,7 +1862,7 @@ static void HWR_StoreWallRange(double startfrac, double endfrac) //Hurdler: 3d-floors test #ifdef R_FAKEFLOORS - if (gr_frontsector && gr_backsector && gr_frontsector->tag != gr_backsector->tag && (gr_backsector->ffloors || gr_frontsector->ffloors)) + if (gr_frontsector && gr_backsector && !Tags_Compare(&gr_frontsector->tags, &gr_backsector->tags) && (gr_backsector->ffloors || gr_frontsector->ffloors)) { ffloor_t * rover; fixed_t highcut = 0, lowcut = 0; @@ -2662,7 +2662,7 @@ static void HWR_AddLine(seg_t * line) #endif !line->sidedef->midtexture && ((!gr_frontsector->ffloors && !gr_backsector->ffloors) - || (gr_frontsector->tag == gr_backsector->tag))) + || Tags_Compare(&gr_frontsector->tags, &gr_backsector->tags))) return; // line is empty, don't even bother // treat like wide open window instead HWR_ProcessSeg(); // Doesn't need arguments because they're defined globally :D @@ -2704,7 +2704,7 @@ static void HWR_AddLine(seg_t * line) #endif !line->sidedef->midtexture && ((!gr_frontsector->ffloors && !gr_backsector->ffloors) - || (gr_frontsector->tag == gr_backsector->tag))) + || Tags_Compare(&gr_frontsector->tags, &gr_backsector->tags))) return; // line is empty, don't even bother goto clippass; // treat like wide open window instead From 38e92aecfd8ec57e53d398bf4149ac6f9f785287 Mon Sep 17 00:00:00 2001 From: Nev3r Date: Sun, 12 Apr 2020 15:03:14 +0200 Subject: [PATCH 0013/1080] Fix Tags_Compare() typo to Tag_Compare(). --- src/hardware/hw_main.c | 6 +++--- src/r_bsp.c | 4 ++-- src/r_segs.c | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 05b7c997f..7ebdb0f07 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -1862,7 +1862,7 @@ static void HWR_StoreWallRange(double startfrac, double endfrac) //Hurdler: 3d-floors test #ifdef R_FAKEFLOORS - if (gr_frontsector && gr_backsector && !Tags_Compare(&gr_frontsector->tags, &gr_backsector->tags) && (gr_backsector->ffloors || gr_frontsector->ffloors)) + if (gr_frontsector && gr_backsector && !Tag_Compare(&gr_frontsector->tags, &gr_backsector->tags) && (gr_backsector->ffloors || gr_frontsector->ffloors)) { ffloor_t * rover; fixed_t highcut = 0, lowcut = 0; @@ -2662,7 +2662,7 @@ static void HWR_AddLine(seg_t * line) #endif !line->sidedef->midtexture && ((!gr_frontsector->ffloors && !gr_backsector->ffloors) - || Tags_Compare(&gr_frontsector->tags, &gr_backsector->tags))) + || Tag_Compare(&gr_frontsector->tags, &gr_backsector->tags))) return; // line is empty, don't even bother // treat like wide open window instead HWR_ProcessSeg(); // Doesn't need arguments because they're defined globally :D @@ -2704,7 +2704,7 @@ static void HWR_AddLine(seg_t * line) #endif !line->sidedef->midtexture && ((!gr_frontsector->ffloors && !gr_backsector->ffloors) - || Tags_Compare(&gr_frontsector->tags, &gr_backsector->tags))) + || Tag_Compare(&gr_frontsector->tags, &gr_backsector->tags))) return; // line is empty, don't even bother goto clippass; // treat like wide open window instead diff --git a/src/r_bsp.c b/src/r_bsp.c index e581e6687..e360e4376 100644 --- a/src/r_bsp.c +++ b/src/r_bsp.c @@ -377,7 +377,7 @@ boolean R_IsEmptyLine(seg_t *line, sector_t *front, sector_t *back) // Consider colormaps && back->extra_colormap == front->extra_colormap && ((!front->ffloors && !back->ffloors) - || Tags_Compare(&front->tags, &back->tags))); + || Tag_Compare(&front->tags, &back->tags))); } // @@ -489,7 +489,7 @@ static void R_AddLine(seg_t *line) #endif !line->sidedef->midtexture && ((!frontsector->ffloors && !backsector->ffloors) - || Tags_Compare(&frontsector->tags, &backsector->tags))) + || Tag_Compare(&frontsector->tags, &backsector->tags))) return; // line is empty, don't even bother goto clippass; // treat like wide open window instead diff --git a/src/r_segs.c b/src/r_segs.c index 1d6a56467..4fc74ce9d 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -2015,7 +2015,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) || backsector->floorlightsec != frontsector->floorlightsec //SoM: 4/3/2000: Check for colormaps || frontsector->extra_colormap != backsector->extra_colormap - || (frontsector->ffloors != backsector->ffloors && !Tags_Compare(&frontsector->tags, &backsector->tags)) + || (frontsector->ffloors != backsector->ffloors && !Tag_Compare(&frontsector->tags, &backsector->tags))) { markfloor = true; } @@ -2046,7 +2046,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) || backsector->ceilinglightsec != frontsector->ceilinglightsec //SoM: 4/3/2000: Check for colormaps || frontsector->extra_colormap != backsector->extra_colormap - || (frontsector->ffloors != backsector->ffloors && !Tags_Compare(&frontsector->tags, &backsector->tags)) + || (frontsector->ffloors != backsector->ffloors && !Tag_Compare(&frontsector->tags, &backsector->tags))) { markceiling = true; } @@ -2136,7 +2136,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) rw_bottomtexturemid += sidedef->rowoffset; // allocate space for masked texture tables - if (frontsector && backsector && !Tags_Compare(&frontsector->tags, &backsector->tags) && (backsector->ffloors || frontsector->ffloors)) + if (frontsector && backsector && !Tag_Compare(&frontsector->tags, &backsector->tags) && (backsector->ffloors || frontsector->ffloors)) { ffloor_t *rover; ffloor_t *r2; From 07b4d0ee3d028b2298c6c9a1aac1218736de864f Mon Sep 17 00:00:00 2001 From: Nev3r Date: Sun, 12 Apr 2020 15:16:04 +0200 Subject: [PATCH 0014/1080] Add lookup tag tables construction. --- src/p_spec.c | 35 +++++++++++++++++++++++++++++------ src/taglist.c | 36 ++++++++++++++++++++++++++++++++++++ src/taglist.h | 15 +++++++++++++++ 3 files changed, 80 insertions(+), 6 deletions(-) diff --git a/src/p_spec.c b/src/p_spec.c index 529c50e4d..53e7f5916 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -1578,6 +1578,7 @@ void P_RunNightsCapsuleTouchExecutors(mobj_t *actor, boolean entering, boolean e static inline void P_InitTagLists(void) { register size_t i; + size_t j; for (i = numsectors - 1; i != (size_t)-1; i--) { @@ -1592,6 +1593,28 @@ static inline void P_InitTagLists(void) lines[i].nexttag = lines[j].firsttag; lines[j].firsttag = (INT32)i; } + + for (i = 0; i < MAXTAGS; i++) + { + tags_sectors[i] = NULL; + tags_lines[i] = NULL; + tags_mapthings[i] = NULL; + } + for (i = 0; i < numsectors; i++) + { + for (j = 0; j < sectors[i].tags.count; j++) + Taglist_AddToSectors(sectors[i].tags.tags[j], i); + } + for (i = 0; i < numlines; i++) + { + for (j = 0; j < lines[i].tags.count; j++) + Taglist_AddToLines(lines[i].tags.tags[j], i); + } + for (i = 0; i < nummapthings; i++) + { + for (j = 0; j < mapthings[i].tags.count; j++) + Taglist_AddToMapthings(mapthings[i].tags.tags[j], i); + } } /** Finds minimum light from an adjacent sector. @@ -2025,7 +2048,7 @@ boolean P_RunTriggerLinedef(line_t *triggerline, mobj_t *actor, sector_t *caller INT32 triggercolor = (INT32)sides[triggerline->sidenum[0]].toptexture; UINT8 color = (actor->player ? actor->player->powers[pw_dye] : actor->color); boolean invert = (triggerline->flags & ML_NOCLIMB ? true : false); - + if (invert ^ (triggercolor != color)) return false; } @@ -4034,23 +4057,23 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) } } break; - + case 463: // Dye object { INT32 color = sides[line->sidenum[0]].toptexture; - + if (mo) { if (color < 0 || color >= MAXTRANSLATIONS) return; - + var1 = 0; var2 = color; A_Dye(mo); } } break; - + #ifdef POLYOBJECTS case 480: // Polyobj_DoorSlide case 481: // Polyobj_DoorSwing @@ -7271,7 +7294,7 @@ void P_SpawnSpecials(boolean fromnetsave) case 331: case 333: break; - + // Object dye executors case 334: case 336: diff --git a/src/taglist.c b/src/taglist.c index ceaebf9aa..087f069c4 100644 --- a/src/taglist.c +++ b/src/taglist.c @@ -20,3 +20,39 @@ boolean Tag_Compare (const taglist_t* list1, const taglist_t* list2) return true; } + +void Taglist_AddToSectors (const size_t tag, const size_t itemid) +{ + taggroup_t* tagelems; + if (!tags_sectors[tag]) + tags_sectors[tag] = Z_Calloc(sizeof(taggroup_t), PU_LEVEL, NULL); + + tagelems = tags_sectors[tag]; + tagelems->count++; + tagelems->elements = Z_Realloc(tagelems->elements, tagelems->count * sizeof(size_t), PU_LEVEL, NULL); + tagelems->elements[tagelems->count - 1] = itemid; +} + +void Taglist_AddToLines (const size_t tag, const size_t itemid) +{ + taggroup_t* tagelems; + if (!tags_lines[tag]) + tags_lines[tag] = Z_Calloc(sizeof(taggroup_t), PU_LEVEL, NULL); + + tagelems = tags_lines[tag]; + tagelems->count++; + tagelems->elements = Z_Realloc(tagelems->elements, tagelems->count * sizeof(size_t), PU_LEVEL, NULL); + tagelems->elements[tagelems->count - 1] = itemid; +} + +void Taglist_AddToMapthings (const size_t tag, const size_t itemid) +{ + taggroup_t* tagelems; + if (!tags_mapthings[tag]) + tags_mapthings[tag] = Z_Calloc(sizeof(taggroup_t), PU_LEVEL, NULL); + + tagelems = tags_mapthings[tag]; + tagelems->count++; + tagelems->elements = Z_Realloc(tagelems->elements, tagelems->count * sizeof(size_t), PU_LEVEL, NULL); + tagelems->elements[tagelems->count - 1] = itemid; +} diff --git a/src/taglist.h b/src/taglist.h index 62fac0d82..51cc82ce9 100644 --- a/src/taglist.h +++ b/src/taglist.h @@ -12,4 +12,19 @@ typedef struct void Tag_Add (taglist_t* list, const UINT16 tag); boolean Tag_Compare (const taglist_t* list1, const taglist_t* list2); + +typedef struct +{ + size_t *elements; + size_t count; +} taggroup_t; + +#define MAXTAGS 65536 +taggroup_t* tags_sectors[MAXTAGS]; +taggroup_t* tags_lines[MAXTAGS]; +taggroup_t* tags_mapthings[MAXTAGS]; + +void Taglist_AddToSectors (const size_t tag, const size_t itemid); +void Taglist_AddToLines (const size_t tag, const size_t itemid); +void Taglist_AddToMapthings (const size_t tag, const size_t itemid); #endif //__R_TAGLIST__ From f7f9b68bb955ed192b45c4e244140d76185fc173 Mon Sep 17 00:00:00 2001 From: Nev3r Date: Sun, 12 Apr 2020 16:28:47 +0200 Subject: [PATCH 0015/1080] Introduce tagged element iteration macros. --- src/taglist.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/taglist.h b/src/taglist.h index 51cc82ce9..e44696d3e 100644 --- a/src/taglist.h +++ b/src/taglist.h @@ -28,3 +28,24 @@ void Taglist_AddToSectors (const size_t tag, const size_t itemid); void Taglist_AddToLines (const size_t tag, const size_t itemid); void Taglist_AddToMapthings (const size_t tag, const size_t itemid); #endif //__R_TAGLIST__ + +#define Tag_IterateSectors(tag, sc)\ +size_t kk;\ +if(tags_sectors[tag])\ + for(kk = 0, sc = tags_sectors[tag]->elements[0];\ + kk < tags_sectors[tag]->count;\ + sc = tags_sectors[tag]->elements[++kk]) + +#define Tag_IterateLines(tag, li)\ +size_t kk;\ +if(tags_lines[tag])\ + for(kk = 0, li = tags_lines[tag]->elements[0];\ + kk < tags_lines[tag]->count;\ + li = tags_lines[tag]->elements[++kk]) + +#define Tag_IterateMapthings(tag, mt)\ +size_t kk;\ +if(tags_mapthings[tag])\ + for(kk = 0, mt = tags_mapthings[tag]->elements[0];\ + kk < tags_mapthings[tag]->count;\ + mt = tags_mapthings[tag]->elements[++kk]) From cb2571b12cbe9bbddf5807cf43c9d15315f78cd6 Mon Sep 17 00:00:00 2001 From: Nev3r Date: Sun, 12 Apr 2020 17:52:38 +0200 Subject: [PATCH 0016/1080] Rename the macros, reshape them slightly to avoid mixed declarations, and add a finalizer. --- src/taglist.h | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/taglist.h b/src/taglist.h index e44696d3e..3fe24fdcb 100644 --- a/src/taglist.h +++ b/src/taglist.h @@ -29,23 +29,25 @@ void Taglist_AddToLines (const size_t tag, const size_t itemid); void Taglist_AddToMapthings (const size_t tag, const size_t itemid); #endif //__R_TAGLIST__ -#define Tag_IterateSectors(tag, sc)\ -size_t kk;\ +#define TAG_ITER_SECTORS(tag, sc)\ if(tags_sectors[tag])\ +{ size_t kk;\ for(kk = 0, sc = tags_sectors[tag]->elements[0];\ kk < tags_sectors[tag]->count;\ sc = tags_sectors[tag]->elements[++kk]) -#define Tag_IterateLines(tag, li)\ -size_t kk;\ +#define TAG_ITER_LINES(tag, li)\ if(tags_lines[tag])\ +{ size_t kk;\ for(kk = 0, li = tags_lines[tag]->elements[0];\ kk < tags_lines[tag]->count;\ li = tags_lines[tag]->elements[++kk]) -#define Tag_IterateMapthings(tag, mt)\ -size_t kk;\ +#define TAG_ITER_THINGS(tag, mt)\ if(tags_mapthings[tag])\ +{ size_t kk;\ for(kk = 0, mt = tags_mapthings[tag]->elements[0];\ kk < tags_mapthings[tag]->count;\ mt = tags_mapthings[tag]->elements[++kk]) + +#define TAG_ITER_END } From 499c88450128d3329e0c884d7f3bbb3d15d9dd6f Mon Sep 17 00:00:00 2001 From: Nev3r Date: Sun, 12 Apr 2020 18:52:47 +0200 Subject: [PATCH 0017/1080] Add multitag support to FOF spawners. --- src/p_spec.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/p_spec.c b/src/p_spec.c index 53e7f5916..e0bfbbe23 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -7484,9 +7484,10 @@ static void P_AddFakeFloorsByLine(size_t line, ffloortype_e ffloorflags, thinker { INT32 s; size_t sec = sides[*lines[line].sidenum].sector-sectors; - - for (s = -1; (s = P_FindSectorFromLineTag(lines+line, s)) >= 0 ;) - P_AddFakeFloor(§ors[s], §ors[sec], lines+line, ffloorflags, secthinkers); + line_t* li = lines + line; + TAG_ITER_SECTORS(li->tag, s) + P_AddFakeFloor(§ors[s], §ors[sec], li, ffloorflags, secthinkers); + TAG_ITER_END } /* From 0d1f8988692fcabb28063448f68cdc210df3c49e Mon Sep 17 00:00:00 2001 From: Nev3r Date: Sun, 12 Apr 2020 19:05:17 +0200 Subject: [PATCH 0018/1080] Added disabled test code in P_FindSectorFromTag(). --- src/p_spec.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/p_spec.c b/src/p_spec.c index e0bfbbe23..4c6d1d407 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -1020,6 +1020,25 @@ INT32 P_FindSectorFromTag(INT16 tag, INT32 start) return start; } +#if 0 + INT32 tpos = 0; + + if (tags_sectors[tag]) + { + // Resume previous position. + if (start != -1) + for (; tpos < tags_sectors[(UINT16)tag]->count;) + if (start == tags_sectors[(UINT16)tag]->elements[tpos++]) + break; + + if (tpos >= tags_sectors[(UINT16)tag]->count) + return -1; + + return tags_sectors[(UINT16)tag]->elements[tpos++]; + } + + return -1; +#else else { start = start >= 0 ? sectors[start].nexttag : @@ -1028,6 +1047,7 @@ INT32 P_FindSectorFromTag(INT16 tag, INT32 start) start = sectors[start].nexttag; return start; } +#endif } /** Searches the tag lists for the next line tagged to a line. From de07c04f5cd20853fdbf587818572395d44d2ae8 Mon Sep 17 00:00:00 2001 From: Nev3r Date: Mon, 13 Apr 2020 13:09:58 +0200 Subject: [PATCH 0019/1080] Make the macros and their usage relatively cleaner. --- src/p_spec.c | 2 +- src/taglist.h | 29 +++++++++-------------------- 2 files changed, 10 insertions(+), 21 deletions(-) diff --git a/src/p_spec.c b/src/p_spec.c index 4c6d1d407..ce89a6887 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -7502,12 +7502,12 @@ void P_SpawnSpecials(boolean fromnetsave) */ static void P_AddFakeFloorsByLine(size_t line, ffloortype_e ffloorflags, thinkerlist_t *secthinkers) { + TAG_ITER_C INT32 s; size_t sec = sides[*lines[line].sidenum].sector-sectors; line_t* li = lines + line; TAG_ITER_SECTORS(li->tag, s) P_AddFakeFloor(§ors[s], §ors[sec], li, ffloorflags, secthinkers); - TAG_ITER_END } /* diff --git a/src/taglist.h b/src/taglist.h index 3fe24fdcb..7572b8042 100644 --- a/src/taglist.h +++ b/src/taglist.h @@ -29,25 +29,14 @@ void Taglist_AddToLines (const size_t tag, const size_t itemid); void Taglist_AddToMapthings (const size_t tag, const size_t itemid); #endif //__R_TAGLIST__ -#define TAG_ITER_SECTORS(tag, sc)\ -if(tags_sectors[tag])\ -{ size_t kk;\ - for(kk = 0, sc = tags_sectors[tag]->elements[0];\ - kk < tags_sectors[tag]->count;\ - sc = tags_sectors[tag]->elements[++kk]) +#define TAG_ITER_C size_t kkkk; -#define TAG_ITER_LINES(tag, li)\ -if(tags_lines[tag])\ -{ size_t kk;\ - for(kk = 0, li = tags_lines[tag]->elements[0];\ - kk < tags_lines[tag]->count;\ - li = tags_lines[tag]->elements[++kk]) +#define TAG_ITER(group, tag, id)\ +if (group[tag])\ + for(id = group[tag]->elements[kkkk = 0] = 0;\ + kkkk < group[tag]->count;\ + id = group[tag]->elements[++kkkk]) -#define TAG_ITER_THINGS(tag, mt)\ -if(tags_mapthings[tag])\ -{ size_t kk;\ - for(kk = 0, mt = tags_mapthings[tag]->elements[0];\ - kk < tags_mapthings[tag]->count;\ - mt = tags_mapthings[tag]->elements[++kk]) - -#define TAG_ITER_END } +#define TAG_ITER_SECTORS(tag, id) TAG_ITER(tags_sectors, tag, id) +#define TAG_ITER_LINES(tag, id) TAG_ITER(tags_lines, tag, id) +#define TAG_ITER_THINGS(tag, id) TAG_ITER(tags_mapthings, tag, id) From 909268d175ef420e50e0b799a24175a4e72e36a4 Mon Sep 17 00:00:00 2001 From: Nev3r Date: Mon, 13 Apr 2020 13:10:38 +0200 Subject: [PATCH 0020/1080] Replace P_FindLineFromLineTag() instances with macros and remove its code. --- src/p_spec.c | 69 ++++++---------------------------------------------- 1 file changed, 8 insertions(+), 61 deletions(-) diff --git a/src/p_spec.c b/src/p_spec.c index ce89a6887..c5186b531 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -1050,65 +1050,6 @@ INT32 P_FindSectorFromTag(INT16 tag, INT32 start) #endif } -/** Searches the tag lists for the next line tagged to a line. - * - * \param line Tagged line used as a reference. - * \param start -1 to start anew, or the result of a previous call to keep - * searching. - * \return Number of the next tagged line found. - * \sa P_FindSectorFromLineTag - */ -static INT32 P_FindLineFromLineTag(const line_t *line, INT32 start) -{ - if (line->tag == -1) - { - start++; - - if (start >= (INT32)numlines) - return -1; - - return start; - } - else - { - start = start >= 0 ? lines[start].nexttag : - lines[(unsigned)line->tag % numlines].firsttag; - while (start >= 0 && lines[start].tag != line->tag) - start = lines[start].nexttag; - return start; - } -} -#if 0 -/** Searches the tag lists for the next line with a given tag and special. - * - * \param tag Tag number. - * \param start -1 to start anew, or the result of a previous call to keep - * searching. - * \return Number of next suitable line found. - * \sa P_FindLineFromLineTag - * \author Graue - */ -static INT32 P_FindLineFromTag(INT32 tag, INT32 start) -{ - if (tag == -1) - { - start++; - - if (start >= numlines) - return -1; - - return start; - } - else - { - start = start >= 0 ? lines[start].nexttag : - lines[(unsigned)tag % numlines].firsttag; - while (start >= 0 && lines[start].tag != tag) - start = lines[start].nexttag; - return start; - } -} -#endif // // P_FindSpecialLineFromTag // @@ -6771,13 +6712,16 @@ void P_SpawnSpecials(boolean fromnetsave) if (sectors[s].lines[j]->special >= 100 && sectors[s].lines[j]->special < 300) Add_MasterDisappearer(abs(lines[i].dx>>FRACBITS), abs(lines[i].dy>>FRACBITS), abs(sides[lines[i].sidenum[0]].sector->floorheight>>FRACBITS), (INT32)(sectors[s].lines[j]-lines), (INT32)i); } else // Find FOFs by effect sector tag - for (s = -1; (s = P_FindLineFromLineTag(lines + i, s)) >= 0 ;) + { + TAG_ITER_C + TAG_ITER_LINES((lines + i)->tag, s) { if ((size_t)s == i) continue; if (sides[lines[s].sidenum[0]].sector->tag == sides[lines[i].sidenum[0]].sector->tag) Add_MasterDisappearer(abs(lines[i].dx>>FRACBITS), abs(lines[i].dy>>FRACBITS), abs(sides[lines[i].sidenum[0]].sector->floorheight>>FRACBITS), s, (INT32)i); } + } break; case 65: // Bridge Thinker @@ -7899,10 +7843,13 @@ static void P_SpawnScrollers(void) // scroll wall according to linedef // (same direction and speed as scrolling floors) case 502: - for (s = -1; (s = P_FindLineFromLineTag(l, s)) >= 0 ;) + { + TAG_ITER_C + TAG_ITER_LINES(l->tag, s) if (s != (INT32)i) Add_Scroller(sc_side, dx, dy, control, lines[s].sidenum[0], accel, 0); break; + } case 505: s = lines[i].sidenum[0]; From dbf0f14dc4373ec7192b60a13ce99359ad0c288a Mon Sep 17 00:00:00 2001 From: Nev3r Date: Mon, 13 Apr 2020 13:27:45 +0200 Subject: [PATCH 0021/1080] Replace P_FindSectorFromLineTag() in p_floor.c --- src/p_floor.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/p_floor.c b/src/p_floor.c index b8b40df3c..78616bdfe 100644 --- a/src/p_floor.c +++ b/src/p_floor.c @@ -2028,8 +2028,9 @@ void T_NoEnemiesSector(levelspecthink_t *nobaddies) msecnode_t *node; mobj_t *thing; boolean FOFsector = false; + TAG_ITER_C - while ((secnum = P_FindSectorFromLineTag(nobaddies->sourceline, secnum)) >= 0) + TAG_ITER_SECTORS(nobaddies->sourceline->tag, secnum) { sec = §ors[secnum]; @@ -2039,13 +2040,14 @@ void T_NoEnemiesSector(levelspecthink_t *nobaddies) for (i = 0; i < sec->linecount; i++) { INT32 targetsecnum = -1; + TAG_ITER_C if (sec->lines[i]->special < 100 || sec->lines[i]->special >= 300) continue; FOFsector = true; - while ((targetsecnum = P_FindSectorFromLineTag(sec->lines[i], targetsecnum)) >= 0) + TAG_ITER_SECTORS(sec->lines[i]->tag, targetsecnum) { targetsec = §ors[targetsecnum]; @@ -2171,6 +2173,7 @@ void T_EachTimeThinker(levelspecthink_t *eachtime) fixed_t bottomheight, topheight; msecnode_t *node; ffloor_t *rover; + TAG_ITER_C for (i = 0; i < MAXPLAYERS; i++) { @@ -2191,7 +2194,7 @@ void T_EachTimeThinker(levelspecthink_t *eachtime) playersOnArea[i] = false; } - while ((secnum = P_FindSectorFromLineTag(eachtime->sourceline, secnum)) >= 0) + TAG_ITER_SECTORS(eachtime->sourceline->tag, secnum) { sec = §ors[secnum]; @@ -2208,13 +2211,14 @@ void T_EachTimeThinker(levelspecthink_t *eachtime) for (i = 0; i < sec->linecount; i++) { INT32 targetsecnum = -1; + TAG_ITER_C if (sec->lines[i]->special < 100 || sec->lines[i]->special >= 300) continue; FOFsector = true; - while ((targetsecnum = P_FindSectorFromLineTag(sec->lines[i], targetsecnum)) >= 0) + TAG_ITER_SECTORS(sec->lines[i]->tag, targetsecnum) { targetsec = §ors[targetsecnum]; @@ -2740,8 +2744,9 @@ INT32 EV_DoFloor(line_t *line, floor_e floortype) INT32 secnum = -1; sector_t *sec; floormove_t *dofloor; + TAG_ITER_C - while ((secnum = P_FindSectorFromLineTag(line, secnum)) >= 0) + TAG_ITER_SECTORS(line->tag, secnum) { sec = §ors[secnum]; @@ -2959,9 +2964,10 @@ INT32 EV_DoElevator(line_t *line, elevator_e elevtype, boolean customspeed) INT32 rtn = 0; sector_t *sec; elevator_t *elevator; + TAG_ITER_C // act on all sectors with the same tag as the triggering linedef - while ((secnum = P_FindSectorFromLineTag(line,secnum)) >= 0) + TAG_ITER_SECTORS(line->tag, secnum) { sec = §ors[secnum]; From e820b9e369156353d5c4f7f9a3c947cb193bc3f3 Mon Sep 17 00:00:00 2001 From: Nev3r Date: Mon, 13 Apr 2020 19:45:41 +0200 Subject: [PATCH 0022/1080] Fixed a typo worthy of divine punishment. --- src/taglist.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/taglist.h b/src/taglist.h index 7572b8042..2a2dbfcb3 100644 --- a/src/taglist.h +++ b/src/taglist.h @@ -33,7 +33,7 @@ void Taglist_AddToMapthings (const size_t tag, const size_t itemid); #define TAG_ITER(group, tag, id)\ if (group[tag])\ - for(id = group[tag]->elements[kkkk = 0] = 0;\ + for(id = group[tag]->elements[kkkk = 0];\ kkkk < group[tag]->count;\ id = group[tag]->elements[++kkkk]) From 8495b5989046832e4458735ed9876d11073c350a Mon Sep 17 00:00:00 2001 From: Nev3r Date: Tue, 14 Apr 2020 18:53:05 +0200 Subject: [PATCH 0023/1080] Added hilarious -1 tag support for the iteration macros. --- src/taglist.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/taglist.h b/src/taglist.h index 2a2dbfcb3..5dab7315f 100644 --- a/src/taglist.h +++ b/src/taglist.h @@ -31,12 +31,12 @@ void Taglist_AddToMapthings (const size_t tag, const size_t itemid); #define TAG_ITER_C size_t kkkk; -#define TAG_ITER(group, tag, id)\ -if (group[tag])\ - for(id = group[tag]->elements[kkkk = 0];\ - kkkk < group[tag]->count;\ - id = group[tag]->elements[++kkkk]) +#define TAG_ITER(group, grouptotal, tag, id)\ +if (group[tag] || tag == -1) for(\ + tag != -1 ? (id = group[tag]->elements[kkkk = 0]) : (id = 0);\ + tag != -1 ? (kkkk < group[tag]->count) : (id < grouptotal);\ + tag != -1 ? (id = group[tag]->elements[++kkkk]) : (id++)) -#define TAG_ITER_SECTORS(tag, id) TAG_ITER(tags_sectors, tag, id) -#define TAG_ITER_LINES(tag, id) TAG_ITER(tags_lines, tag, id) -#define TAG_ITER_THINGS(tag, id) TAG_ITER(tags_mapthings, tag, id) +#define TAG_ITER_SECTORS(tag, id) TAG_ITER(tags_sectors, numsectors, tag, id) +#define TAG_ITER_LINES(tag, id) TAG_ITER(tags_lines, numlines, tag, id) +#define TAG_ITER_THINGS(tag, id) TAG_ITER(tags_mapthings, nummapthings, tag, id) From 5df60f8e156d72930c4d4ff7403298c847023164 Mon Sep 17 00:00:00 2001 From: Nev3r Date: Tue, 14 Apr 2020 20:59:04 +0200 Subject: [PATCH 0024/1080] Make use of functions for the tag lists iterations instead of bloated macros. --- src/taglist.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++ src/taglist.h | 22 ++++++++++----------- 2 files changed, 66 insertions(+), 11 deletions(-) diff --git a/src/taglist.c b/src/taglist.c index 087f069c4..2e91cd770 100644 --- a/src/taglist.c +++ b/src/taglist.c @@ -1,5 +1,6 @@ #include "taglist.h" #include "z_zone.h" +#include "r_data.h" void Tag_Add (taglist_t* list, const UINT16 tag) { @@ -56,3 +57,57 @@ void Taglist_AddToMapthings (const size_t tag, const size_t itemid) tagelems->elements = Z_Realloc(tagelems->elements, tagelems->count * sizeof(size_t), PU_LEVEL, NULL); tagelems->elements[tagelems->count - 1] = itemid; } + +INT32 Tag_Iterate_Sectors (const INT16 tag, const size_t p) +{ + if (tag == -1) + { + if (p < numsectors) + return p; + return -1; + } + + if (tags_sectors[tag]) + { + if (p < tags_sectors[tag]->count) + return tags_sectors[tag]->elements[p]; + return -1; + } + return -1; +} + +INT32 Tag_Iterate_Lines (const INT16 tag, const size_t p) +{ + if (tag == -1) + { + if (p < numlines) + return p; + return -1; + } + + if (tags_lines[tag]) + { + if (p < tags_lines[tag]->count) + return tags_lines[tag]->elements[p]; + return -1; + } + return -1; +} + +INT32 Tag_Iterate_Things (const INT16 tag, const size_t p) +{ + if (tag == -1) + { + if (p < nummapthings) + return p; + return -1; + } + + if (tags_mapthings[tag]) + { + if (p < tags_mapthings[tag]->count) + return tags_mapthings[tag]->elements[p]; + return -1; + } + return -1; +} diff --git a/src/taglist.h b/src/taglist.h index 5dab7315f..ca3a7d834 100644 --- a/src/taglist.h +++ b/src/taglist.h @@ -1,8 +1,8 @@ -#include "doomtype.h" - #ifndef __R_TAGLIST__ #define __R_TAGLIST__ +#include "doomtype.h" + /// Multitag list. typedef struct { @@ -27,16 +27,16 @@ taggroup_t* tags_mapthings[MAXTAGS]; void Taglist_AddToSectors (const size_t tag, const size_t itemid); void Taglist_AddToLines (const size_t tag, const size_t itemid); void Taglist_AddToMapthings (const size_t tag, const size_t itemid); -#endif //__R_TAGLIST__ + +INT32 Tag_Iterate_Sectors (const INT16 tag, const size_t p); +INT32 Tag_Iterate_Lines (const INT16 tag, const size_t p); +INT32 Tag_Iterate_Things (const INT16 tag, const size_t p); #define TAG_ITER_C size_t kkkk; +#define TAG_ITER(fn, tag, id) for(kkkk = 0; (id = fn(tag, kkkk)) >= 0; kkkk++) -#define TAG_ITER(group, grouptotal, tag, id)\ -if (group[tag] || tag == -1) for(\ - tag != -1 ? (id = group[tag]->elements[kkkk = 0]) : (id = 0);\ - tag != -1 ? (kkkk < group[tag]->count) : (id < grouptotal);\ - tag != -1 ? (id = group[tag]->elements[++kkkk]) : (id++)) +#define TAG_ITER_SECTORS(tag, id) TAG_ITER(Tag_Iterate_Sectors, tag, id) +#define TAG_ITER_LINES(tag, id) TAG_ITER(Tag_Iterate_Lines, tag, id) +#define TAG_ITER_THINGS(tag, id) TAG_ITER(Tag_Iterate_Things, tag, id) -#define TAG_ITER_SECTORS(tag, id) TAG_ITER(tags_sectors, numsectors, tag, id) -#define TAG_ITER_LINES(tag, id) TAG_ITER(tags_lines, numlines, tag, id) -#define TAG_ITER_THINGS(tag, id) TAG_ITER(tags_mapthings, nummapthings, tag, id) +#endif //__R_TAGLIST__ From 24baf5bea0431835b675d96ec97f241ef5e3ee0a Mon Sep 17 00:00:00 2001 From: Nev3r Date: Tue, 14 Apr 2020 22:19:18 +0200 Subject: [PATCH 0025/1080] Replace P_FindSectorFromLineTag() with its corresponding macro for most cases. --- src/p_ceilng.c | 6 ++- src/p_spec.c | 107 ++++++++++++++++++++++++++----------------------- 2 files changed, 60 insertions(+), 53 deletions(-) diff --git a/src/p_ceilng.c b/src/p_ceilng.c index c65156b6f..a6e8e8cda 100644 --- a/src/p_ceilng.c +++ b/src/p_ceilng.c @@ -398,8 +398,9 @@ INT32 EV_DoCeiling(line_t *line, ceiling_e type) INT32 secnum = -1; sector_t *sec; ceiling_t *ceiling; + TAG_ITER_C - while ((secnum = P_FindSectorFromLineTag(line,secnum)) >= 0) + TAG_ITER_SECTORS(line->tag, secnum) { sec = §ors[secnum]; @@ -618,8 +619,9 @@ INT32 EV_DoCrush(line_t *line, ceiling_e type) INT32 secnum = -1; sector_t *sec; ceiling_t *ceiling; + TAG_ITER_C - while ((secnum = P_FindSectorFromLineTag(line,secnum)) >= 0) + TAG_ITER_SECTORS(line->tag, secnum) { sec = §ors[secnum]; diff --git a/src/p_spec.c b/src/p_spec.c index c5186b531..1f9b6099b 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -2442,6 +2442,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) { INT32 secnum = -1; mobj_t *bot = NULL; + TAG_ITER_C I_Assert(!mo || !P_MobjWasRemoved(mo)); // If mo is there, mo must be valid! @@ -2469,7 +2470,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) newceilinglightsec = line->frontsector->ceilinglightsec; // act on all sectors with the same tag as the triggering linedef - while ((secnum = P_FindSectorFromLineTag(line, secnum)) >= 0) + TAG_ITER_SECTORS(line->tag, secnum) { if (sectors[secnum].lightingdata) { @@ -2524,7 +2525,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) case 409: // Change tagged sectors' tag // (formerly "Change calling sectors' tag", but behavior was changed) { - while ((secnum = P_FindSectorFromLineTag(line, secnum)) >= 0) + TAG_ITER_SECTORS(line->tag, secnum) P_ChangeSectorTag(secnum,(INT16)(sides[line->sidenum[0]].textureoffset>>FRACBITS)); break; } @@ -2534,7 +2535,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) break; case 411: // Stop floor/ceiling movement in tagged sector(s) - while ((secnum = P_FindSectorFromLineTag(line, secnum)) >= 0) + TAG_ITER_SECTORS(line->tag, secnum) { if (sectors[secnum].floordata) { @@ -2604,7 +2605,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) } else { - if ((secnum = P_FindSectorFromLineTag(line, -1)) < 0) + if ((secnum = Tag_Iterate_Sectors(line->tag, 0)) < 0) return; dest = P_GetObjectTypeInSectorNum(MT_TELEPORTMAN, secnum); @@ -2719,7 +2720,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) // Additionally play the sound from tagged sectors' soundorgs sector_t *sec; - while ((secnum = P_FindSectorFromLineTag(line, secnum)) >= 0) + TAG_ITER_SECTORS(line->tag, secnum) { sec = §ors[secnum]; S_StartSound(&sec->soundorg, sfxnum); @@ -2834,7 +2835,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) break; case 416: // Spawn adjustable fire flicker - while ((secnum = P_FindSectorFromLineTag(line, secnum)) >= 0) + TAG_ITER_SECTORS(line->tag, secnum) { if (line->flags & ML_NOCLIMB && line->backsector) { @@ -2868,7 +2869,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) break; case 417: // Spawn adjustable glowing light - while ((secnum = P_FindSectorFromLineTag(line, secnum)) >= 0) + TAG_ITER_SECTORS(line->tag, secnum) { if (line->flags & ML_NOCLIMB && line->backsector) { @@ -2902,7 +2903,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) break; case 418: // Spawn adjustable strobe flash (unsynchronized) - while ((secnum = P_FindSectorFromLineTag(line, secnum)) >= 0) + TAG_ITER_SECTORS(line->tag, secnum) { if (line->flags & ML_NOCLIMB && line->backsector) { @@ -2936,7 +2937,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) break; case 419: // Spawn adjustable strobe flash (synchronized) - while ((secnum = P_FindSectorFromLineTag(line, secnum)) >= 0) + TAG_ITER_SECTORS(line->tag, secnum) { if (line->flags & ML_NOCLIMB && line->backsector) { @@ -2984,7 +2985,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) break; case 421: // Stop lighting effect in tagged sectors - while ((secnum = P_FindSectorFromLineTag(line, secnum)) >= 0) + TAG_ITER_SECTORS(line->tag, secnum) if (sectors[secnum].lightingdata) { P_RemoveThinker(&((elevator_t *)sectors[secnum].lightingdata)->thinker); @@ -2999,7 +3000,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) if ((!mo || !mo->player) && !titlemapinaction) // only players have views, and title screens return; - if ((secnum = P_FindSectorFromLineTag(line, -1)) < 0) + if ((secnum = Tag_Iterate_Sectors(line->tag, 0)) < 0) return; altview = P_GetObjectTypeInSectorNum(MT_ALTVIEWMAN, secnum); @@ -3318,7 +3319,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) if (line->sidenum[1] != 0xffff) state = (statenum_t)sides[line->sidenum[1]].toptexture; - while ((secnum = P_FindSectorFromLineTag(line, secnum)) >= 0) + TAG_ITER_SECTORS(line->tag, secnum) { boolean tryagain; sec = sectors + secnum; @@ -3473,7 +3474,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) // Except it is activated by linedef executor, not level load // This could even override existing colormaps I believe // -- Monster Iestyn 14/06/18 - for (secnum = -1; (secnum = P_FindSectorFromLineTag(line, secnum)) >= 0 ;) + TAG_ITER_SECTORS(line->tag, secnum) { P_ResetColormapFader(§ors[secnum]); @@ -3801,7 +3802,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) } case 455: // Fade colormap - for (secnum = -1; (secnum = P_FindSectorFromLineTag(line, secnum)) >= 0 ;) + TAG_ITER_SECTORS(line->tag, secnum) { extracolormap_t *source_exc, *dest_exc, *exc; INT32 speed = (INT32)((line->flags & ML_DONTPEGBOTTOM) || !sides[line->sidenum[0]].rowoffset) && line->sidenum[1] != 0xFFFF ? @@ -3890,7 +3891,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) break; case 456: // Stop fade colormap - for (secnum = -1; (secnum = P_FindSectorFromLineTag(line, secnum)) >= 0 ;) + TAG_ITER_SECTORS(line->tag, secnum) P_ResetColormapFader(§ors[secnum]); break; @@ -3904,7 +3905,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) boolean persist = (line->flags & ML_EFFECT2); mobj_t *anchormo; - if ((secnum = P_FindSectorFromLineTag(line, -1)) < 0) + if ((secnum = Tag_Iterate_Sectors(line->tag, 0)) < 0) return; anchormo = P_GetObjectTypeInSectorNum(MT_ANGLEMAN, secnum); @@ -6547,10 +6548,11 @@ void P_SpawnSpecials(boolean fromnetsave) INT32 s; size_t sec; ffloortype_e ffloorflags; + TAG_ITER_C case 1: // Definable gravity per sector sec = sides[*lines[i].sidenum].sector - sectors; - for (s = -1; (s = P_FindSectorFromLineTag(lines + i, s)) >= 0 ;) + TAG_ITER_SECTORS(lines[i].tag, s) { sectors[s].gravity = §ors[sec].floorheight; // This allows it to change in realtime! @@ -6574,7 +6576,7 @@ void P_SpawnSpecials(boolean fromnetsave) case 5: // Change camera info sec = sides[*lines[i].sidenum].sector - sectors; - for (s = -1; (s = P_FindSectorFromLineTag(lines + i, s)) >= 0 ;) + TAG_ITER_SECTORS(lines[i].tag, s) P_AddCameraScanner(§ors[sec], §ors[s], R_PointToAngle2(lines[i].v2->x, lines[i].v2->y, lines[i].v1->x, lines[i].v1->y)); break; @@ -6601,7 +6603,7 @@ void P_SpawnSpecials(boolean fromnetsave) P_ApplyFlatAlignment(lines + i, lines[i].frontsector, flatangle, xoffs, yoffs); else { - for (s = -1; (s = P_FindSectorFromLineTag(lines + i, s)) >= 0;) + TAG_ITER_SECTORS(lines[i].tag, s) P_ApplyFlatAlignment(lines + i, sectors + s, flatangle, xoffs, yoffs); } } @@ -6612,7 +6614,7 @@ void P_SpawnSpecials(boolean fromnetsave) break; case 8: // Sector Parameters - for (s = -1; (s = P_FindSectorFromLineTag(lines + i, s)) >= 0 ;) + TAG_ITER_SECTORS(lines[i].tag, s) { if (lines[i].flags & ML_NOCLIMB) { @@ -6640,7 +6642,7 @@ void P_SpawnSpecials(boolean fromnetsave) 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 ;) + TAG_ITER_SECTORS(lines[i].tag, s) sectors[s].cullheight = &lines[i]; // This allows it to change in realtime! break; @@ -6701,19 +6703,18 @@ void P_SpawnSpecials(boolean fromnetsave) case 63: // support for drawn heights coming from different sector sec = sides[*lines[i].sidenum].sector-sectors; - for (s = -1; (s = P_FindSectorFromLineTag(lines + i, s)) >= 0 ;) + TAG_ITER_SECTORS(lines[i].tag, s) sectors[s].heightsec = (INT32)sec; break; case 64: // Appearing/Disappearing FOF option if (lines[i].flags & ML_BLOCKMONSTERS) { // Find FOFs by control sector tag - for (s = -1; (s = P_FindSectorFromLineTag(lines + i, s)) >= 0 ;) + TAG_ITER_SECTORS(lines[i].tag, s) for (j = 0; (unsigned)j < sectors[s].linecount; j++) if (sectors[s].lines[j]->special >= 100 && sectors[s].lines[j]->special < 300) Add_MasterDisappearer(abs(lines[i].dx>>FRACBITS), abs(lines[i].dy>>FRACBITS), abs(sides[lines[i].sidenum[0]].sector->floorheight>>FRACBITS), (INT32)(sectors[s].lines[j]-lines), (INT32)i); } else // Find FOFs by effect sector tag { - TAG_ITER_C TAG_ITER_LINES((lines + i)->tag, s) { if ((size_t)s == i) @@ -6732,15 +6733,15 @@ void P_SpawnSpecials(boolean fromnetsave) break; case 66: // Displace floor by front sector - for (s = -1; (s = P_FindSectorFromLineTag(lines + i, s)) >= 0 ;) + TAG_ITER_SECTORS(lines[i].tag, s) P_AddPlaneDisplaceThinker(pd_floor, P_AproxDistance(lines[i].dx, lines[i].dy)>>8, sides[lines[i].sidenum[0]].sector-sectors, s, !!(lines[i].flags & ML_NOCLIMB)); break; case 67: // Displace ceiling by front sector - for (s = -1; (s = P_FindSectorFromLineTag(lines + i, s)) >= 0 ;) + TAG_ITER_SECTORS(lines[i].tag, s) P_AddPlaneDisplaceThinker(pd_ceiling, P_AproxDistance(lines[i].dx, lines[i].dy)>>8, sides[lines[i].sidenum[0]].sector-sectors, s, !!(lines[i].flags & ML_NOCLIMB)); break; case 68: // Displace both floor AND ceiling by front sector - for (s = -1; (s = P_FindSectorFromLineTag(lines + i, s)) >= 0 ;) + TAG_ITER_SECTORS(lines[i].tag, s) P_AddPlaneDisplaceThinker(pd_both, P_AproxDistance(lines[i].dx, lines[i].dy)>>8, sides[lines[i].sidenum[0]].sector-sectors, s, !!(lines[i].flags & ML_NOCLIMB)); break; @@ -7115,7 +7116,7 @@ void P_SpawnSpecials(boolean fromnetsave) case 251: // A THWOMP! sec = sides[*lines[i].sidenum].sector - sectors; - for (s = -1; (s = P_FindSectorFromLineTag(lines + i, s)) >= 0 ;) + TAG_ITER_SECTORS(lines[i].tag, s) { P_AddThwompThinker(§ors[sec], §ors[s], &lines[i]); P_AddFakeFloor(§ors[s], §ors[sec], lines + i, @@ -7163,7 +7164,7 @@ void P_SpawnSpecials(boolean fromnetsave) sec = sides[*lines[i].sidenum].sector - sectors; // No longer totally disrupts netgames - for (s = -1; (s = P_FindSectorFromLineTag(lines + i, s)) >= 0 ;) + TAG_ITER_SECTORS(lines[i].tag, s) EV_AddLaserThinker(§ors[s], §ors[sec], lines + i, secthinkers); break; @@ -7355,46 +7356,46 @@ void P_SpawnSpecials(boolean fromnetsave) case 600: // floor lighting independently (e.g. lava) sec = sides[*lines[i].sidenum].sector-sectors; - for (s = -1; (s = P_FindSectorFromLineTag(lines + i, s)) >= 0 ;) + TAG_ITER_SECTORS(lines[i].tag, s) sectors[s].floorlightsec = (INT32)sec; break; case 601: // ceiling lighting independently sec = sides[*lines[i].sidenum].sector-sectors; - for (s = -1; (s = P_FindSectorFromLineTag(lines + i, s)) >= 0 ;) + TAG_ITER_SECTORS(lines[i].tag, s) sectors[s].ceilinglightsec = (INT32)sec; break; case 602: // Adjustable pulsating light sec = sides[*lines[i].sidenum].sector - sectors; - for (s = -1; (s = P_FindSectorFromLineTag(lines + i, s)) >= 0 ;) + TAG_ITER_SECTORS(lines[i].tag, s) P_SpawnAdjustableGlowingLight(§ors[sec], §ors[s], P_AproxDistance(lines[i].dx, lines[i].dy)>>FRACBITS); break; case 603: // Adjustable flickering light sec = sides[*lines[i].sidenum].sector - sectors; - for (s = -1; (s = P_FindSectorFromLineTag(lines + i, s)) >= 0 ;) + TAG_ITER_SECTORS(lines[i].tag, s) P_SpawnAdjustableFireFlicker(§ors[sec], §ors[s], P_AproxDistance(lines[i].dx, lines[i].dy)>>FRACBITS); break; case 604: // Adjustable Blinking Light (unsynchronized) sec = sides[*lines[i].sidenum].sector - sectors; - for (s = -1; (s = P_FindSectorFromLineTag(lines + i, s)) >= 0 ;) + TAG_ITER_SECTORS(lines[i].tag, s) P_SpawnAdjustableStrobeFlash(§ors[sec], §ors[s], abs(lines[i].dx)>>FRACBITS, abs(lines[i].dy)>>FRACBITS, false); break; case 605: // Adjustable Blinking Light (synchronized) sec = sides[*lines[i].sidenum].sector - sectors; - for (s = -1; (s = P_FindSectorFromLineTag(lines + i, s)) >= 0 ;) + TAG_ITER_SECTORS(lines[i].tag, s) P_SpawnAdjustableStrobeFlash(§ors[sec], §ors[s], abs(lines[i].dx)>>FRACBITS, abs(lines[i].dy)>>FRACBITS, true); break; case 606: // HACK! Copy colormaps. Just plain colormaps. - for (s = -1; (s = P_FindSectorFromLineTag(lines + i, s)) >= 0 ;) + TAG_ITER_SECTORS(lines[i].tag, s) sectors[s].extra_colormap = sectors[s].spawn_extra_colormap = sides[lines[i].sidenum[0]].colormap_data; break; @@ -7560,6 +7561,7 @@ void T_Scroll(scroll_t *s) size_t i; INT32 sect; ffloor_t *rover; + TAG_ITER_C case sc_side: // scroll wall texture side = sides + s->affectee; @@ -7596,7 +7598,7 @@ void T_Scroll(scroll_t *s) if (!is3dblock) continue; - for (sect = -1; (sect = P_FindSectorFromTag(line->tag, sect)) >= 0 ;) + TAG_ITER_SECTORS(line->tag, sect) { sector_t *psec; psec = sectors + sect; @@ -7809,10 +7811,11 @@ static void P_SpawnScrollers(void) switch (special) { register INT32 s; + TAG_ITER_C case 513: // scroll effect ceiling case 533: // scroll and carry objects on ceiling - for (s = -1; (s = P_FindSectorFromLineTag(l, s)) >= 0 ;) + TAG_ITER_SECTORS(l->tag, s) Add_Scroller(sc_ceiling, -dx, dy, control, s, accel, l->flags & ML_NOCLIMB); if (special != 533) break; @@ -7821,13 +7824,13 @@ static void P_SpawnScrollers(void) case 523: // carry objects on ceiling dx = FixedMul(dx, CARRYFACTOR); dy = FixedMul(dy, CARRYFACTOR); - for (s = -1; (s = P_FindSectorFromLineTag(l, s)) >= 0 ;) + TAG_ITER_SECTORS(l->tag, s) Add_Scroller(sc_carry_ceiling, dx, dy, control, s, accel, l->flags & ML_NOCLIMB); break; case 510: // scroll effect floor case 530: // scroll and carry objects on floor - for (s = -1; (s = P_FindSectorFromLineTag(l, s)) >= 0 ;) + TAG_ITER_SECTORS(l->tag, s) Add_Scroller(sc_floor, -dx, dy, control, s, accel, l->flags & ML_NOCLIMB); if (special != 530) break; @@ -7836,7 +7839,7 @@ static void P_SpawnScrollers(void) case 520: // carry objects on floor dx = FixedMul(dx, CARRYFACTOR); dy = FixedMul(dy, CARRYFACTOR); - for (s = -1; (s = P_FindSectorFromLineTag(l, s)) >= 0 ;) + TAG_ITER_SECTORS(l->tag, s) Add_Scroller(sc_carry, dx, dy, control, s, accel, l->flags & ML_NOCLIMB); break; @@ -7844,7 +7847,6 @@ static void P_SpawnScrollers(void) // (same direction and speed as scrolling floors) case 502: { - TAG_ITER_C TAG_ITER_LINES(l->tag, s) if (s != (INT32)i) Add_Scroller(sc_side, dx, dy, control, lines[s].sidenum[0], accel, 0); @@ -7915,8 +7917,9 @@ void T_Disappear(disappear_t *d) { ffloor_t *rover; register INT32 s; + TAG_ITER_C - for (s = -1; (s = P_FindSectorFromLineTag(&lines[d->affectee], s)) >= 0 ;) + TAG_ITER_SECTORS(lines[d->affectee].tag, s) { for (rover = sectors[s].ffloors; rover; rover = rover->next) { @@ -8649,6 +8652,7 @@ static void P_SpawnFriction(void) fixed_t strength; // frontside texture offset controls magnitude fixed_t friction; // friction value to be applied during movement INT32 movefactor; // applied to each player move to simulate inertia + TAG_ITER_C for (i = 0; i < numlines; i++, l++) if (l->special == 540) @@ -8673,7 +8677,7 @@ static void P_SpawnFriction(void) else movefactor = FRACUNIT; - for (s = -1; (s = P_FindSectorFromLineTag(l, s)) >= 0 ;) + TAG_ITER_SECTORS(l->tag, s) Add_Friction(friction, movefactor, s, -1); } } @@ -9203,20 +9207,21 @@ static void P_SpawnPushers(void) line_t *l = lines; register INT32 s; mobj_t *thing; + TAG_ITER_C for (i = 0; i < numlines; i++, l++) switch (l->special) { case 541: // wind - for (s = -1; (s = P_FindSectorFromLineTag(l, s)) >= 0 ;) + TAG_ITER_SECTORS(l->tag, s) Add_Pusher(p_wind, l->dx, l->dy, NULL, s, -1, l->flags & ML_NOCLIMB, l->flags & ML_EFFECT4); break; case 544: // current - for (s = -1; (s = P_FindSectorFromLineTag(l, s)) >= 0 ;) + TAG_ITER_SECTORS(l->tag, s) Add_Pusher(p_current, l->dx, l->dy, NULL, s, -1, l->flags & ML_NOCLIMB, l->flags & ML_EFFECT4); break; case 547: // push/pull - for (s = -1; (s = P_FindSectorFromLineTag(l, s)) >= 0 ;) + TAG_ITER_SECTORS(l->tag, s) { thing = P_GetPushThing(s); if (thing) // No MT_P* means no effect @@ -9224,19 +9229,19 @@ static void P_SpawnPushers(void) } break; case 545: // current up - for (s = -1; (s = P_FindSectorFromLineTag(l, s)) >= 0 ;) + TAG_ITER_SECTORS(l->tag, s) Add_Pusher(p_upcurrent, l->dx, l->dy, NULL, s, -1, l->flags & ML_NOCLIMB, l->flags & ML_EFFECT4); break; case 546: // current down - for (s = -1; (s = P_FindSectorFromLineTag(l, s)) >= 0 ;) + TAG_ITER_SECTORS(l->tag, s) Add_Pusher(p_downcurrent, l->dx, l->dy, NULL, s, -1, l->flags & ML_NOCLIMB, l->flags & ML_EFFECT4); break; case 542: // wind up - for (s = -1; (s = P_FindSectorFromLineTag(l, s)) >= 0 ;) + TAG_ITER_SECTORS(l->tag, s) Add_Pusher(p_upwind, l->dx, l->dy, NULL, s, -1, l->flags & ML_NOCLIMB, l->flags & ML_EFFECT4); break; case 543: // wind down - for (s = -1; (s = P_FindSectorFromLineTag(l, s)) >= 0 ;) + TAG_ITER_SECTORS(l->tag, s) Add_Pusher(p_downwind, l->dx, l->dy, NULL, s, -1, l->flags & ML_NOCLIMB, l->flags & ML_EFFECT4); break; } From 25102ab4afc24f504d6b0e05416ec8233fce25db Mon Sep 17 00:00:00 2001 From: Nev3r Date: Tue, 14 Apr 2020 22:22:48 +0200 Subject: [PATCH 0026/1080] Remove P_FindSectorFromLineTag() --- src/p_spec.c | 14 -------------- src/p_spec.h | 1 - 2 files changed, 15 deletions(-) diff --git a/src/p_spec.c b/src/p_spec.c index 9d4b741c5..6e7e06823 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -988,26 +988,12 @@ static sector_t *P_FindModelCeilingSector(fixed_t ceildestheight, INT32 secnum) } #endif -/** Searches the tag lists for the next sector tagged to a line. - * - * \param line Tagged line used as a reference. - * \param start -1 to start at the beginning, or the result of a previous call - * to keep searching. - * \return Number of the next tagged sector found. - * \sa P_FindSectorFromTag, P_FindLineFromLineTag - */ -INT32 P_FindSectorFromLineTag(line_t *line, INT32 start) -{ - return P_FindSectorFromTag(line->tag, start); -} - /** Searches the tag lists for the next sector with a given tag. * * \param tag Tag number to look for. * \param start -1 to start anew, or the result of a previous call to keep * searching. * \return Number of the next tagged sector found. - * \sa P_FindSectorFromLineTag */ INT32 P_FindSectorFromTag(INT16 tag, INT32 start) { diff --git a/src/p_spec.h b/src/p_spec.h index d756f1942..590eb476b 100644 --- a/src/p_spec.h +++ b/src/p_spec.h @@ -55,7 +55,6 @@ fixed_t P_FindNextLowestFloor(sector_t *sec, fixed_t currentheight); fixed_t P_FindLowestCeilingSurrounding(sector_t *sec); fixed_t P_FindHighestCeilingSurrounding(sector_t *sec); -INT32 P_FindSectorFromLineTag(line_t *line, INT32 start); INT32 P_FindSectorFromTag(INT16 tag, INT32 start); INT32 P_FindSpecialLineFromTag(INT16 special, INT16 tag, INT32 start); From d51870333456bccb6bf6f137119015501efda19d Mon Sep 17 00:00:00 2001 From: Nev3r Date: Tue, 14 Apr 2020 23:33:56 +0200 Subject: [PATCH 0027/1080] Replaces P_FindSectorFromTag() occurrences with its corresponding macro and vanishes it from existence. --- src/p_floor.c | 30 ++++++++++++------------ src/p_lights.c | 4 +++- src/p_slopes.c | 4 ++-- src/p_spec.c | 63 ++++++-------------------------------------------- src/p_spec.h | 1 - 5 files changed, 27 insertions(+), 75 deletions(-) diff --git a/src/p_floor.c b/src/p_floor.c index fbcb1274b..5d57263d3 100644 --- a/src/p_floor.c +++ b/src/p_floor.c @@ -687,6 +687,7 @@ void T_BounceCheese(levelspecthink_t *bouncer) fixed_t floorheight; sector_t *actionsector; INT32 i; + TAG_ITER_C if (bouncer->sector->crumblestate == 4 || bouncer->sector->crumblestate == 1 || bouncer->sector->crumblestate == 2) // Oops! Crumbler says to remove yourself! @@ -701,7 +702,7 @@ void T_BounceCheese(levelspecthink_t *bouncer) } // You can use multiple target sectors, but at your own risk!!! - for (i = -1; (i = P_FindSectorFromTag(bouncer->sourceline->tag, i)) >= 0 ;) + TAG_ITER_SECTORS(bouncer->sourceline->tag, i) { actionsector = §ors[i]; actionsector->moved = true; @@ -844,6 +845,7 @@ void T_StartCrumble(elevator_t *elevator) ffloor_t *rover; sector_t *sector; INT32 i; + TAG_ITER_C // Once done, the no-return thinker just sits there, // constantly 'returning'... kind of an oxymoron, isn't it? @@ -873,7 +875,7 @@ void T_StartCrumble(elevator_t *elevator) } else if (++elevator->distance == 0) // Reposition back to original spot { - for (i = -1; (i = P_FindSectorFromTag(elevator->sourceline->tag, i)) >= 0 ;) + TAG_ITER_SECTORS(elevator->sourceline->tag, i) { sector = §ors[i]; @@ -904,7 +906,7 @@ void T_StartCrumble(elevator_t *elevator) // Flash to indicate that the platform is about to return. if (elevator->distance > -224 && (leveltime % ((abs(elevator->distance)/8) + 1) == 0)) { - for (i = -1; (i = P_FindSectorFromTag(elevator->sourceline->tag, i)) >= 0 ;) + TAG_ITER_SECTORS(elevator->sourceline->tag, i) { sector = §ors[i]; @@ -1000,7 +1002,7 @@ void T_StartCrumble(elevator_t *elevator) P_RemoveThinker(&elevator->thinker); } - for (i = -1; (i = P_FindSectorFromTag(elevator->sourceline->tag, i)) >= 0 ;) + TAG_ITER_SECTORS(elevator->sourceline->tag, i) { sector = §ors[i]; sector->moved = true; @@ -1016,6 +1018,7 @@ void T_StartCrumble(elevator_t *elevator) void T_MarioBlock(levelspecthink_t *block) { INT32 i; + TAG_ITER_C #define speed vars[1] #define direction vars[2] @@ -1057,8 +1060,7 @@ void T_MarioBlock(levelspecthink_t *block) block->sector->ceilspeed = 0; block->direction = 0; } - - for (i = -1; (i = P_FindSectorFromTag((INT16)block->vars[0], i)) >= 0 ;) + TAG_ITER_SECTORS((INT16)block->vars[0], i) P_RecalcPrecipInSector(§ors[i]); #undef speed @@ -1151,9 +1153,7 @@ void T_FloatSector(levelspecthink_t *floater) // Just find the first sector with the tag. // Doesn't work with multiple sectors that have different floor/ceiling heights. - secnum = P_FindSectorFromTag((INT16)floater->vars[0], -1); - - if (secnum > 0) + if ((secnum = Tag_Iterate_Sectors((INT16)floater->vars[0], 0)) >= 0) actionsector = §ors[secnum]; else actionsector = NULL; @@ -1288,9 +1288,7 @@ void T_ThwompSector(levelspecthink_t *thwomp) // Just find the first sector with the tag. // Doesn't work with multiple sectors that have different floor/ceiling heights. - secnum = P_FindSectorFromTag((INT16)thwomp->vars[0], -1); - - if (secnum > 0) + if ((secnum = Tag_Iterate_Sectors((INT16)thwomp->vars[0], 0)) >= 0) { actionsector = §ors[secnum]; @@ -1860,11 +1858,12 @@ void T_RaiseSector(levelspecthink_t *raise) boolean playeronme = false, active = false; fixed_t ceilingdestination, floordestination; result_e res = 0; + TAG_ITER_C if (raise->sector->crumblestate >= 3 || raise->sector->ceilingdata) return; - for (i = -1; (i = P_FindSectorFromTag(raise->sourceline->tag, i)) >= 0 ;) + TAG_ITER_SECTORS(raise->sourceline->tag, i) { sector = §ors[i]; @@ -2057,7 +2056,7 @@ void T_RaiseSector(levelspecthink_t *raise) raise->sector->ceilspeed = 42; raise->sector->floorspeed = raise->vars[3]*raise->vars[8]; - for (i = -1; (i = P_FindSectorFromTag(raise->sourceline->tag, i)) >= 0 ;) + TAG_ITER_SECTORS(raise->sourceline->tag, i) P_RecalcPrecipInSector(§ors[i]); } @@ -2726,6 +2725,7 @@ INT32 EV_StartCrumble(sector_t *sec, ffloor_t *rover, boolean floating, elevator_t *elevator; sector_t *foundsec; INT32 i; + TAG_ITER_C // If floor is already activated, skip it if (sec->floordata) @@ -2778,7 +2778,7 @@ INT32 EV_StartCrumble(sector_t *sec, ffloor_t *rover, boolean floating, elevator->sector->crumblestate = 2; - for (i = -1; (i = P_FindSectorFromTag(elevator->sourceline->tag, i)) >= 0 ;) + TAG_ITER_SECTORS(elevator->sourceline->tag, i) { foundsec = §ors[i]; diff --git a/src/p_lights.c b/src/p_lights.c index 371077a30..bb8ef6989 100644 --- a/src/p_lights.c +++ b/src/p_lights.c @@ -374,8 +374,10 @@ void P_FadeLightBySector(sector_t *sector, INT32 destvalue, INT32 speed, boolean void P_FadeLight(INT16 tag, INT32 destvalue, INT32 speed, boolean ticbased, boolean force) { INT32 i; + TAG_ITER_C + // search all sectors for ones with tag - for (i = -1; (i = P_FindSectorFromTag(tag, i)) >= 0 ;) + TAG_ITER_SECTORS(tag, i) { if (!force && ticbased // always let speed fader execute && sectors[i].lightingdata diff --git a/src/p_slopes.c b/src/p_slopes.c index c4ef28666..63a7aeb20 100644 --- a/src/p_slopes.c +++ b/src/p_slopes.c @@ -549,11 +549,11 @@ static boolean P_SetSlopeFromTag(sector_t *sec, INT32 tag, boolean ceiling) { INT32 i; pslope_t **secslope = ceiling ? &sec->c_slope : &sec->f_slope; + TAG_ITER_C if (!tag || *secslope) return false; - - for (i = -1; (i = P_FindSectorFromTag(tag, i)) >= 0;) + TAG_ITER_SECTORS(tag, i) { pslope_t *srcslope = ceiling ? sectors[i].c_slope : sectors[i].f_slope; if (srcslope) diff --git a/src/p_spec.c b/src/p_spec.c index 6e7e06823..8b5b5ac9b 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -988,54 +988,6 @@ static sector_t *P_FindModelCeilingSector(fixed_t ceildestheight, INT32 secnum) } #endif -/** Searches the tag lists for the next sector with a given tag. - * - * \param tag Tag number to look for. - * \param start -1 to start anew, or the result of a previous call to keep - * searching. - * \return Number of the next tagged sector found. - */ -INT32 P_FindSectorFromTag(INT16 tag, INT32 start) -{ - if (tag == -1) - { - start++; - - if (start >= (INT32)numsectors) - return -1; - - return start; - } -#if 0 - INT32 tpos = 0; - - if (tags_sectors[tag]) - { - // Resume previous position. - if (start != -1) - for (; tpos < tags_sectors[(UINT16)tag]->count;) - if (start == tags_sectors[(UINT16)tag]->elements[tpos++]) - break; - - if (tpos >= tags_sectors[(UINT16)tag]->count) - return -1; - - return tags_sectors[(UINT16)tag]->elements[tpos++]; - } - - return -1; -#else - else - { - start = start >= 0 ? sectors[start].nexttag : - sectors[(unsigned)tag % numsectors].firsttag; - while (start >= 0 && sectors[start].tag != tag) - start = sectors[start].nexttag; - return start; - } -#endif -} - // // P_FindSpecialLineFromTag // @@ -3181,7 +3133,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) ffloor_t *rover; // FOF that we are going to crumble boolean foundrover = false; // for debug, "Can't find a FOF" message - for (secnum = -1; (secnum = P_FindSectorFromTag(sectag, secnum)) >= 0 ;) + TAG_ITER_SECTORS(sectag, secnum) { sec = sectors + secnum; @@ -3365,7 +3317,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) boolean foundrover = false; // for debug, "Can't find a FOF" message ffloortype_e oldflags; // store FOF's old flags - for (secnum = -1; (secnum = P_FindSectorFromTag(sectag, secnum)) >= 0 ;) + TAG_ITER_SECTORS(sectag, secnum) { sec = sectors + secnum; @@ -3423,7 +3375,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) if (line->flags & ML_NOCLIMB) // don't respawn! respawn = false; - for (secnum = -1; (secnum = P_FindSectorFromTag(sectag, secnum)) >= 0 ;) + TAG_ITER_SECTORS(sectag, secnum) { sec = sectors + secnum; @@ -3608,7 +3560,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) ffloor_t *rover; // FOF that we are going to operate boolean foundrover = false; // for debug, "Can't find a FOF" message - for (secnum = -1; (secnum = P_FindSectorFromTag(sectag, secnum)) >= 0 ;) + TAG_ITER_SECTORS(sectag, secnum) { sec = sectors + secnum; @@ -3672,7 +3624,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) boolean foundrover = false; // for debug, "Can't find a FOF" message size_t j = 0; // sec->ffloors is saved as ffloor #0, ss->ffloors->next is #1, etc - for (secnum = -1; (secnum = P_FindSectorFromTag(sectag, secnum)) >= 0 ;) + TAG_ITER_SECTORS(sectag, secnum) { sec = sectors + secnum; @@ -3757,7 +3709,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) ffloor_t *rover; // FOF that we are going to operate boolean foundrover = false; // for debug, "Can't find a FOF" message - for (secnum = -1; (secnum = P_FindSectorFromTag(sectag, secnum)) >= 0 ;) + TAG_ITER_SECTORS(sectag, secnum) { sec = sectors + secnum; @@ -7617,8 +7569,7 @@ void T_Scroll(scroll_t *s) if (!is3dblock) continue; - - for (sect = -1; (sect = P_FindSectorFromTag(line->tag, sect)) >= 0 ;) + TAG_ITER_SECTORS(line->tag, sect) { sector_t *psec; psec = sectors + sect; diff --git a/src/p_spec.h b/src/p_spec.h index 590eb476b..271c04c08 100644 --- a/src/p_spec.h +++ b/src/p_spec.h @@ -55,7 +55,6 @@ fixed_t P_FindNextLowestFloor(sector_t *sec, fixed_t currentheight); fixed_t P_FindLowestCeilingSurrounding(sector_t *sec); fixed_t P_FindHighestCeilingSurrounding(sector_t *sec); -INT32 P_FindSectorFromTag(INT16 tag, INT32 start); INT32 P_FindSpecialLineFromTag(INT16 special, INT16 tag, INT32 start); INT32 P_FindMinSurroundingLight(sector_t *sector, INT32 max); From 439fde3434940b1abacf10af9b701e5b7d8ad77b Mon Sep 17 00:00:00 2001 From: Nev3r Date: Tue, 14 Apr 2020 23:59:22 +0200 Subject: [PATCH 0028/1080] Replace most P_FindSpecialLineFromTag() cases with Tag_FindLineSpecial(), which settle with the first found result. --- src/p_enemy.c | 8 ++++---- src/p_floor.c | 2 +- src/p_mobj.c | 9 ++++----- src/p_polyobj.c | 2 +- src/p_slopes.c | 2 +- src/p_spec.c | 10 +++++----- src/p_user.c | 8 ++++---- src/taglist.c | 16 ++++++++++++++++ src/taglist.h | 2 ++ 9 files changed, 38 insertions(+), 21 deletions(-) diff --git a/src/p_enemy.c b/src/p_enemy.c index 2341be6d3..8f96c1dee 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -6107,7 +6107,7 @@ void A_RockSpawn(mobj_t *actor) { mobj_t *mo; mobjtype_t type; - INT32 i = P_FindSpecialLineFromTag(12, (INT16)actor->threshold, -1); + INT32 i = Tag_FindLineSpecial(12, (INT16)actor->threshold); line_t *line; fixed_t dist; fixed_t randomoomph; @@ -8794,19 +8794,19 @@ void A_Dye(mobj_t *actor) #endif if (color >= MAXTRANSLATIONS) return; - + if (!color) target->colorized = false; else target->colorized = true; - + // What if it's a player? if (target->player) { target->player->powers[pw_dye] = color; return; } - + target->color = color; } diff --git a/src/p_floor.c b/src/p_floor.c index 5d57263d3..bcb546a5c 100644 --- a/src/p_floor.c +++ b/src/p_floor.c @@ -2549,7 +2549,7 @@ void EV_CrumbleChain(sector_t *sec, ffloor_t *rover) if (controlsec->tag != 0) { - INT32 tagline = P_FindSpecialLineFromTag(14, controlsec->tag, -1); + INT32 tagline = Tag_FindLineSpecial(14, controlsec->tag); if (tagline != -1) { if (sides[lines[tagline].sidenum[0]].toptexture) diff --git a/src/p_mobj.c b/src/p_mobj.c index aaea9d49b..c004d3257 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -3552,7 +3552,7 @@ static boolean P_CameraCheckHeat(camera_t *thiscam) // see if we are in water sector = thiscam->subsector->sector; - if (P_FindSpecialLineFromTag(13, sector->tag, -1) != -1) + if (Tag_FindLineSpecial(13, sector->tag) != -1) return true; if (sector->ffloors) @@ -3573,7 +3573,7 @@ static boolean P_CameraCheckHeat(camera_t *thiscam) *rover->bottomheight)) continue; - if (P_FindSpecialLineFromTag(13, rover->master->frontsector->tag, -1) != -1) + if (Tag_FindLineSpecial(13, rover->master->frontsector->tag) != -1) return true; } } @@ -12035,8 +12035,7 @@ static boolean P_SetupMace(mapthing_t *mthing, mobj_t *mobj, boolean *doangle) const size_t mthingi = (size_t)(mthing - mapthings); // Find the corresponding linedef special, using angle as tag - // P_FindSpecialLineFromTag works here now =D - line = P_FindSpecialLineFromTag(9, mthing->angle, -1); + line = Tag_FindLineSpecial(9, mthing->angle); if (line == -1) { @@ -12346,7 +12345,7 @@ static boolean P_SetupParticleGen(mapthing_t *mthing, mobj_t *mobj) const size_t mthingi = (size_t)(mthing - mapthings); // Find the corresponding linedef special, using angle as tag - line = P_FindSpecialLineFromTag(15, mthing->angle, -1); + line = Tag_FindLineSpecial(15, mthing->angle); if (line == -1) { diff --git a/src/p_polyobj.c b/src/p_polyobj.c index 7baa24994..cfe12db13 100644 --- a/src/p_polyobj.c +++ b/src/p_polyobj.c @@ -238,7 +238,7 @@ boolean P_BBoxInsidePolyobj(polyobj_t *po, fixed_t *bbox) // void Polyobj_GetInfo(INT16 poid, INT32 *poflags, INT32 *parentID, INT32 *potrans) { - INT32 i = P_FindSpecialLineFromTag(POLYINFO_SPECIALNUM, poid, -1); + INT32 i = Tag_FindLineSpecial(POLYINFO_SPECIALNUM, poid); if (i == -1) return; // no extra settings to apply, let's leave it diff --git a/src/p_slopes.c b/src/p_slopes.c index 63a7aeb20..9b147f046 100644 --- a/src/p_slopes.c +++ b/src/p_slopes.c @@ -139,7 +139,7 @@ void T_DynamicSlopeVert (dynplanethink_t* th) INT32 l; for (i = 0; i < 3; i++) { - l = P_FindSpecialLineFromTag(799, th->tags[i], -1); + l = Tag_FindLineSpecial(799, th->tags[i]); if (l != -1) { th->vex[i].z = lines[l].frontsector->floorheight; } diff --git a/src/p_spec.c b/src/p_spec.c index 8b5b5ac9b..1977e7a89 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -4535,7 +4535,7 @@ DoneSection2: if (player->powers[pw_flashing] != 0 && player->powers[pw_flashing] < TICRATE/2) break; - i = P_FindSpecialLineFromTag(4, sector->tag, -1); + i = Tag_FindLineSpecial(4, sector->tag); if (i != -1) { @@ -4647,7 +4647,7 @@ DoneSection2: // 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); + lineindex = Tag_FindLineSpecial(2, sector->tag); if (gametype == GT_COOP && lineindex != -1) // Custom exit! { @@ -4772,7 +4772,7 @@ DoneSection2: break; // Find line #3 tagged to this sector - lineindex = P_FindSpecialLineFromTag(3, sector->tag, -1); + lineindex = Tag_FindLineSpecial(3, sector->tag); if (lineindex == -1) { @@ -4854,7 +4854,7 @@ DoneSection2: break; // Find line #3 tagged to this sector - lineindex = P_FindSpecialLineFromTag(3, sector->tag, -1); + lineindex = Tag_FindLineSpecial(3, sector->tag); if (lineindex == -1) { @@ -5001,7 +5001,7 @@ DoneSection2: memset(&resulthigh, 0x00, sizeof(resulthigh)); // Find line #11 tagged to this sector - lineindex = P_FindSpecialLineFromTag(11, sector->tag, -1); + lineindex = Tag_FindLineSpecial(11, sector->tag); if (lineindex == -1) { diff --git a/src/p_user.c b/src/p_user.c index 994eb7007..131eedd9c 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -10654,7 +10654,7 @@ static void P_CalcPostImg(player_t *player) // see if we are in heat (no, not THAT kind of heat...) - if (P_FindSpecialLineFromTag(13, sector->tag, -1) != -1) + if (Tag_FindLineSpecial(13, sector->tag) != -1) *type = postimg_heat; else if (sector->ffloors) { @@ -10673,7 +10673,7 @@ static void P_CalcPostImg(player_t *player) if (pviewheight >= topheight || pviewheight <= bottomheight) continue; - if (P_FindSpecialLineFromTag(13, rover->master->frontsector->tag, -1) != -1) + if (Tag_FindLineSpecial(13, rover->master->frontsector->tag) != -1) *type = postimg_heat; } } @@ -10778,7 +10778,7 @@ static INT32 P_GetMinecartSpecialLine(sector_t *sec) return line; if (sec->tag != 0) - line = P_FindSpecialLineFromTag(16, sec->tag, -1); + line = Tag_FindLineSpecial(16, sec->tag); // Also try for lines facing the sector itself, with tag 0. { @@ -12213,7 +12213,7 @@ void P_PlayerThink(player_t *player) player->powers[pw_nocontrol]--; else player->powers[pw_nocontrol] = 0; - + //pw_super acts as a timer now if (player->powers[pw_super] && (player->mo->state < &states[S_PLAY_SUPER_TRANS1] diff --git a/src/taglist.c b/src/taglist.c index 2e91cd770..4b3ed1981 100644 --- a/src/taglist.c +++ b/src/taglist.c @@ -111,3 +111,19 @@ INT32 Tag_Iterate_Things (const INT16 tag, const size_t p) } return -1; } + +INT32 Tag_FindLineSpecial(const INT16 tag, const INT16 special) +{ + TAG_ITER_C + INT32 i; + + TAG_ITER_LINES(tag, i) + { + if (i == -1) + return -1; + + if (lines[i].special == special) + return i; + } + return -1; +} diff --git a/src/taglist.h b/src/taglist.h index ca3a7d834..9be0013f3 100644 --- a/src/taglist.h +++ b/src/taglist.h @@ -32,6 +32,8 @@ INT32 Tag_Iterate_Sectors (const INT16 tag, const size_t p); INT32 Tag_Iterate_Lines (const INT16 tag, const size_t p); INT32 Tag_Iterate_Things (const INT16 tag, const size_t p); +INT32 Tag_FindLineSpecial(const INT16 tag, const INT16 special); + #define TAG_ITER_C size_t kkkk; #define TAG_ITER(fn, tag, id) for(kkkk = 0; (id = fn(tag, kkkk)) >= 0; kkkk++) From 2d9b0e49067582fc8b73f867281503fa835a7083 Mon Sep 17 00:00:00 2001 From: Nev3r Date: Wed, 15 Apr 2020 09:32:19 +0200 Subject: [PATCH 0029/1080] Fix the args in Tag_FindLineSpecial() being swapped. --- src/taglist.c | 2 +- src/taglist.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/taglist.c b/src/taglist.c index 4b3ed1981..61b8a147d 100644 --- a/src/taglist.c +++ b/src/taglist.c @@ -112,7 +112,7 @@ INT32 Tag_Iterate_Things (const INT16 tag, const size_t p) return -1; } -INT32 Tag_FindLineSpecial(const INT16 tag, const INT16 special) +INT32 Tag_FindLineSpecial(const INT16 special, const INT16 tag) { TAG_ITER_C INT32 i; diff --git a/src/taglist.h b/src/taglist.h index 9be0013f3..59ecd6106 100644 --- a/src/taglist.h +++ b/src/taglist.h @@ -32,7 +32,7 @@ INT32 Tag_Iterate_Sectors (const INT16 tag, const size_t p); INT32 Tag_Iterate_Lines (const INT16 tag, const size_t p); INT32 Tag_Iterate_Things (const INT16 tag, const size_t p); -INT32 Tag_FindLineSpecial(const INT16 tag, const INT16 special); +INT32 Tag_FindLineSpecial(const INT16 special, const INT16 tag); #define TAG_ITER_C size_t kkkk; #define TAG_ITER(fn, tag, id) for(kkkk = 0; (id = fn(tag, kkkk)) >= 0; kkkk++) From f9b1acb8139fb613335d363d30bf5a7ed5a30a92 Mon Sep 17 00:00:00 2001 From: Nev3r Date: Wed, 15 Apr 2020 09:41:21 +0200 Subject: [PATCH 0030/1080] reworked Tag_FindLineSpecial() --- src/taglist.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/taglist.c b/src/taglist.c index 61b8a147d..f00f62ca4 100644 --- a/src/taglist.c +++ b/src/taglist.c @@ -114,16 +114,20 @@ INT32 Tag_Iterate_Things (const INT16 tag, const size_t p) INT32 Tag_FindLineSpecial(const INT16 special, const INT16 tag) { - TAG_ITER_C INT32 i; - TAG_ITER_LINES(tag, i) + if (tag == -1) { - if (i == -1) - return -1; - - if (lines[i].special == special) - return i; + for (i = 0; i < numlines; i++) + if (lines[i].special == special) + return i; + } + else if (tags_lines[tag]) + { + taggroup_t *tagged = tags_lines[tag]; + for (i = 0; i < tagged->count; i++) + if (lines[tagged->elements[i]].special == special) + return tagged->elements[i]; } return -1; } From 7d3d71c418fa6d4e5426e5c8a5d866e110c336ef Mon Sep 17 00:00:00 2001 From: Nev3r Date: Wed, 15 Apr 2020 10:05:59 +0200 Subject: [PATCH 0031/1080] Get rid of the last case of P_FindSpecialLineFromTag() in the main code. --- src/r_bsp.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/r_bsp.c b/src/r_bsp.c index e360e4376..d003db666 100644 --- a/src/r_bsp.c +++ b/src/r_bsp.c @@ -451,21 +451,25 @@ static void R_AddLine(seg_t *line) // Portal line if (line->linedef->special == 40 && line->side == 0) { + // Render portal if recursiveness limit hasn't been reached. + // Otherwise, render the wall normally. if (portalrender < cv_maxportals.value) { - // Find the other side! - INT32 line2 = P_FindSpecialLineFromTag(40, line->linedef->tag, -1); - if (line->linedef == &lines[line2]) - line2 = P_FindSpecialLineFromTag(40, line->linedef->tag, line2); - if (line2 >= 0) // found it! + size_t p; + INT16 tag = line->linedef->tag; + INT32 li1 = line->linedef-lines; + INT32 li2; + + for (p = 0; (li2 = Tag_Iterate_Lines(tag, p)) >= 0; p++) { - Portal_Add2Lines(line->linedef-lines, line2, x1, x2); // Remember the lines for later rendering - //return; // Don't fill in that space now! + // Skip invalid lines. + if ((tag != lines[li2].tag) || (lines[li1].special != lines[li2].special) || (li1 == li2)) + continue; + + Portal_Add2Lines(li1, li2, x1, x2); goto clipsolid; } } - // Recursed TOO FAR (viewing a portal within a portal) - // So uhhh, render it as a normal wall instead or something ??? } // Single sided line? From 95c7690a40352e5cc73c7e313ffd5c487df48de7 Mon Sep 17 00:00:00 2001 From: Nev3r Date: Wed, 15 Apr 2020 10:16:49 +0200 Subject: [PATCH 0032/1080] Remove P_FindSpecialLineFromTag() --- src/lua_baselib.c | 12 ------------ src/p_spec.c | 32 -------------------------------- src/p_spec.h | 2 -- 3 files changed, 46 deletions(-) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 48a503828..884588160 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -1915,17 +1915,6 @@ static int lib_pFindHighestCeilingSurrounding(lua_State *L) return 1; } -static int lib_pFindSpecialLineFromTag(lua_State *L) -{ - INT16 special = (INT16)luaL_checkinteger(L, 1); - INT16 line = (INT16)luaL_checkinteger(L, 2); - INT32 start = (INT32)luaL_optinteger(L, 3, -1); - NOHUD - INLEVEL - lua_pushinteger(L, P_FindSpecialLineFromTag(special, line, start)); - return 1; -} - static int lib_pSwitchWeather(lua_State *L) { INT32 weathernum = (INT32)luaL_checkinteger(L, 1); @@ -3213,7 +3202,6 @@ static luaL_Reg lib[] = { {"P_FindNextLowestFloor",lib_pFindNextLowestFloor}, {"P_FindLowestCeilingSurrounding",lib_pFindLowestCeilingSurrounding}, {"P_FindHighestCeilingSurrounding",lib_pFindHighestCeilingSurrounding}, - {"P_FindSpecialLineFromTag",lib_pFindSpecialLineFromTag}, {"P_SwitchWeather",lib_pSwitchWeather}, {"P_LinedefExecute",lib_pLinedefExecute}, {"P_SpawnLightningFlash",lib_pSpawnLightningFlash}, diff --git a/src/p_spec.c b/src/p_spec.c index 1977e7a89..2e8f1b685 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -988,38 +988,6 @@ static sector_t *P_FindModelCeilingSector(fixed_t ceildestheight, INT32 secnum) } #endif -// -// P_FindSpecialLineFromTag -// -INT32 P_FindSpecialLineFromTag(INT16 special, INT16 tag, INT32 start) -{ - if (tag == -1) - { - start++; - - // This redundant check stops the compiler from complaining about function expansion - // elsewhere for some reason and everything is awful - if (start >= (INT32)numlines) - return -1; - - while (start < (INT32)numlines && lines[start].special != special) - start++; - - if (start >= (INT32)numlines) - return -1; - - return start; - } - else - { - start = start >= 0 ? lines[start].nexttag : - lines[(unsigned)tag % numlines].firsttag; - while (start >= 0 && (lines[start].tag != tag || lines[start].special != special)) - start = lines[start].nexttag; - return start; - } -} - // haleyjd: temporary define #ifdef POLYOBJECTS diff --git a/src/p_spec.h b/src/p_spec.h index 271c04c08..1e9ff1c41 100644 --- a/src/p_spec.h +++ b/src/p_spec.h @@ -55,8 +55,6 @@ fixed_t P_FindNextLowestFloor(sector_t *sec, fixed_t currentheight); fixed_t P_FindLowestCeilingSurrounding(sector_t *sec); fixed_t P_FindHighestCeilingSurrounding(sector_t *sec); -INT32 P_FindSpecialLineFromTag(INT16 special, INT16 tag, INT32 start); - INT32 P_FindMinSurroundingLight(sector_t *sector, INT32 max); void P_SetupSignExit(player_t *player); From 786e448f165d2a32560982785078ae6ce96bd6ad Mon Sep 17 00:00:00 2001 From: Nev3r Date: Wed, 15 Apr 2020 10:17:14 +0200 Subject: [PATCH 0033/1080] Do not add -1 to the global taglists. --- src/taglist.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/taglist.c b/src/taglist.c index f00f62ca4..fcce7adc3 100644 --- a/src/taglist.c +++ b/src/taglist.c @@ -25,6 +25,10 @@ boolean Tag_Compare (const taglist_t* list1, const taglist_t* list2) void Taglist_AddToSectors (const size_t tag, const size_t itemid) { taggroup_t* tagelems; + + if (tag == -1) + return; + if (!tags_sectors[tag]) tags_sectors[tag] = Z_Calloc(sizeof(taggroup_t), PU_LEVEL, NULL); @@ -40,6 +44,9 @@ void Taglist_AddToLines (const size_t tag, const size_t itemid) if (!tags_lines[tag]) tags_lines[tag] = Z_Calloc(sizeof(taggroup_t), PU_LEVEL, NULL); + if (tag == -1) + return; + tagelems = tags_lines[tag]; tagelems->count++; tagelems->elements = Z_Realloc(tagelems->elements, tagelems->count * sizeof(size_t), PU_LEVEL, NULL); @@ -52,6 +59,9 @@ void Taglist_AddToMapthings (const size_t tag, const size_t itemid) if (!tags_mapthings[tag]) tags_mapthings[tag] = Z_Calloc(sizeof(taggroup_t), PU_LEVEL, NULL); + if (tag == -1) + return; + tagelems = tags_mapthings[tag]; tagelems->count++; tagelems->elements = Z_Realloc(tagelems->elements, tagelems->count * sizeof(size_t), PU_LEVEL, NULL); From 1d572c5b2c1516b22cd004c5cd92e741fbe8edde Mon Sep 17 00:00:00 2001 From: Nev3r Date: Thu, 16 Apr 2020 14:37:01 +0200 Subject: [PATCH 0034/1080] Fix fuckup in the -1 tag bailout on the global tag lists. --- src/taglist.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/taglist.c b/src/taglist.c index fcce7adc3..5174fe2d7 100644 --- a/src/taglist.c +++ b/src/taglist.c @@ -41,12 +41,13 @@ void Taglist_AddToSectors (const size_t tag, const size_t itemid) void Taglist_AddToLines (const size_t tag, const size_t itemid) { taggroup_t* tagelems; - if (!tags_lines[tag]) - tags_lines[tag] = Z_Calloc(sizeof(taggroup_t), PU_LEVEL, NULL); if (tag == -1) return; + if (!tags_lines[tag]) + tags_lines[tag] = Z_Calloc(sizeof(taggroup_t), PU_LEVEL, NULL); + tagelems = tags_lines[tag]; tagelems->count++; tagelems->elements = Z_Realloc(tagelems->elements, tagelems->count * sizeof(size_t), PU_LEVEL, NULL); @@ -56,12 +57,13 @@ void Taglist_AddToLines (const size_t tag, const size_t itemid) void Taglist_AddToMapthings (const size_t tag, const size_t itemid) { taggroup_t* tagelems; - if (!tags_mapthings[tag]) - tags_mapthings[tag] = Z_Calloc(sizeof(taggroup_t), PU_LEVEL, NULL); if (tag == -1) return; + if (!tags_mapthings[tag]) + tags_mapthings[tag] = Z_Calloc(sizeof(taggroup_t), PU_LEVEL, NULL); + tagelems = tags_mapthings[tag]; tagelems->count++; tagelems->elements = Z_Realloc(tagelems->elements, tagelems->count * sizeof(size_t), PU_LEVEL, NULL); From c0b4090924bab2ccb225e1a207e3e976a86a4abb Mon Sep 17 00:00:00 2001 From: Nev3r Date: Thu, 16 Apr 2020 18:48:57 +0200 Subject: [PATCH 0035/1080] Clean up type inconsistency on tags. --- src/taglist.c | 70 +++++++++++++++++++++++++-------------------------- src/taglist.h | 27 +++++++++++--------- 2 files changed, 50 insertions(+), 47 deletions(-) diff --git a/src/taglist.c b/src/taglist.c index 5174fe2d7..bfa5814dd 100644 --- a/src/taglist.c +++ b/src/taglist.c @@ -2,7 +2,7 @@ #include "z_zone.h" #include "r_data.h" -void Tag_Add (taglist_t* list, const UINT16 tag) +void Tag_Add (taglist_t* list, const mtag_t tag) { list->tags = Z_Realloc(list->tags, (list->count + 1) * sizeof(list->tags), PU_LEVEL, NULL); list->tags[list->count++] = tag; @@ -22,121 +22,121 @@ boolean Tag_Compare (const taglist_t* list1, const taglist_t* list2) return true; } -void Taglist_AddToSectors (const size_t tag, const size_t itemid) +void Taglist_AddToSectors (const mtag_t tag, const size_t itemid) { taggroup_t* tagelems; - if (tag == -1) + if (tag == MTAG_GLOBAL) return; - if (!tags_sectors[tag]) - tags_sectors[tag] = Z_Calloc(sizeof(taggroup_t), PU_LEVEL, NULL); + if (!tags_sectors[(UINT16)tag]) + tags_sectors[(UINT16)tag] = Z_Calloc(sizeof(taggroup_t), PU_LEVEL, NULL); - tagelems = tags_sectors[tag]; + tagelems = tags_sectors[(UINT16)tag]; tagelems->count++; tagelems->elements = Z_Realloc(tagelems->elements, tagelems->count * sizeof(size_t), PU_LEVEL, NULL); tagelems->elements[tagelems->count - 1] = itemid; } -void Taglist_AddToLines (const size_t tag, const size_t itemid) +void Taglist_AddToLines (const mtag_t tag, const size_t itemid) { taggroup_t* tagelems; - if (tag == -1) + if (tag == MTAG_GLOBAL) return; - if (!tags_lines[tag]) - tags_lines[tag] = Z_Calloc(sizeof(taggroup_t), PU_LEVEL, NULL); + if (!tags_lines[(UINT16)tag]) + tags_lines[(UINT16)tag] = Z_Calloc(sizeof(taggroup_t), PU_LEVEL, NULL); - tagelems = tags_lines[tag]; + tagelems = tags_lines[(UINT16)tag]; tagelems->count++; tagelems->elements = Z_Realloc(tagelems->elements, tagelems->count * sizeof(size_t), PU_LEVEL, NULL); tagelems->elements[tagelems->count - 1] = itemid; } -void Taglist_AddToMapthings (const size_t tag, const size_t itemid) +void Taglist_AddToMapthings (const mtag_t tag, const size_t itemid) { taggroup_t* tagelems; - if (tag == -1) + if (tag == MTAG_GLOBAL) return; - if (!tags_mapthings[tag]) - tags_mapthings[tag] = Z_Calloc(sizeof(taggroup_t), PU_LEVEL, NULL); + if (!tags_mapthings[(UINT16)tag]) + tags_mapthings[(UINT16)tag] = Z_Calloc(sizeof(taggroup_t), PU_LEVEL, NULL); - tagelems = tags_mapthings[tag]; + tagelems = tags_mapthings[(UINT16)tag]; tagelems->count++; tagelems->elements = Z_Realloc(tagelems->elements, tagelems->count * sizeof(size_t), PU_LEVEL, NULL); tagelems->elements[tagelems->count - 1] = itemid; } -INT32 Tag_Iterate_Sectors (const INT16 tag, const size_t p) +INT32 Tag_Iterate_Sectors (const mtag_t tag, const size_t p) { - if (tag == -1) + if (tag == MTAG_GLOBAL) { if (p < numsectors) return p; return -1; } - if (tags_sectors[tag]) + if (tags_sectors[(UINT16)tag]) { - if (p < tags_sectors[tag]->count) - return tags_sectors[tag]->elements[p]; + if (p < tags_sectors[(UINT16)tag]->count) + return tags_sectors[(UINT16)tag]->elements[p]; return -1; } return -1; } -INT32 Tag_Iterate_Lines (const INT16 tag, const size_t p) +INT32 Tag_Iterate_Lines (const mtag_t tag, const size_t p) { - if (tag == -1) + if (tag == MTAG_GLOBAL) { if (p < numlines) return p; return -1; } - if (tags_lines[tag]) + if (tags_lines[(UINT16)tag]) { - if (p < tags_lines[tag]->count) - return tags_lines[tag]->elements[p]; + if (p < tags_lines[(UINT16)tag]->count) + return tags_lines[(UINT16)tag]->elements[p]; return -1; } return -1; } -INT32 Tag_Iterate_Things (const INT16 tag, const size_t p) +INT32 Tag_Iterate_Things (const mtag_t tag, const size_t p) { - if (tag == -1) + if (tag == MTAG_GLOBAL) { if (p < nummapthings) return p; return -1; } - if (tags_mapthings[tag]) + if (tags_mapthings[(UINT16)tag]) { - if (p < tags_mapthings[tag]->count) - return tags_mapthings[tag]->elements[p]; + if (p < tags_mapthings[(UINT16)tag]->count) + return tags_mapthings[(UINT16)tag]->elements[p]; return -1; } return -1; } -INT32 Tag_FindLineSpecial(const INT16 special, const INT16 tag) +INT32 Tag_FindLineSpecial(const INT16 special, const mtag_t tag) { INT32 i; - if (tag == -1) + if (tag == MTAG_GLOBAL) { for (i = 0; i < numlines; i++) if (lines[i].special == special) return i; } - else if (tags_lines[tag]) + else if (tags_lines[(UINT16)tag]) { - taggroup_t *tagged = tags_lines[tag]; + taggroup_t *tagged = tags_lines[(UINT16)tag]; for (i = 0; i < tagged->count; i++) if (lines[tagged->elements[i]].special == special) return tagged->elements[i]; diff --git a/src/taglist.h b/src/taglist.h index 59ecd6106..67665434c 100644 --- a/src/taglist.h +++ b/src/taglist.h @@ -3,14 +3,18 @@ #include "doomtype.h" +typedef INT16 mtag_t; +#define MAXTAGS UINT16_MAX +#define MTAG_GLOBAL -1 + /// Multitag list. typedef struct { - UINT16* tags; + mtag_t* tags; UINT16 count; } taglist_t; -void Tag_Add (taglist_t* list, const UINT16 tag); +void Tag_Add (taglist_t* list, const mtag_t tag); boolean Tag_Compare (const taglist_t* list1, const taglist_t* list2); typedef struct @@ -19,18 +23,17 @@ typedef struct size_t count; } taggroup_t; -#define MAXTAGS 65536 -taggroup_t* tags_sectors[MAXTAGS]; -taggroup_t* tags_lines[MAXTAGS]; -taggroup_t* tags_mapthings[MAXTAGS]; +taggroup_t* tags_sectors[MAXTAGS + 1]; +taggroup_t* tags_lines[MAXTAGS + 1]; +taggroup_t* tags_mapthings[MAXTAGS + 1]; -void Taglist_AddToSectors (const size_t tag, const size_t itemid); -void Taglist_AddToLines (const size_t tag, const size_t itemid); -void Taglist_AddToMapthings (const size_t tag, const size_t itemid); +void Taglist_AddToSectors (const mtag_t tag, const size_t itemid); +void Taglist_AddToLines (const mtag_t tag, const size_t itemid); +void Taglist_AddToMapthings (const mtag_t tag, const size_t itemid); -INT32 Tag_Iterate_Sectors (const INT16 tag, const size_t p); -INT32 Tag_Iterate_Lines (const INT16 tag, const size_t p); -INT32 Tag_Iterate_Things (const INT16 tag, const size_t p); +INT32 Tag_Iterate_Sectors (const mtag_t tag, const size_t p); +INT32 Tag_Iterate_Lines (const mtag_t tag, const size_t p); +INT32 Tag_Iterate_Things (const mtag_t tag, const size_t p); INT32 Tag_FindLineSpecial(const INT16 special, const INT16 tag); From 944716c45a207283799587014422137a4cd6f110 Mon Sep 17 00:00:00 2001 From: Nev3r Date: Fri, 17 Apr 2020 09:56:20 +0200 Subject: [PATCH 0036/1080] Add auxiliary functions to the taglist library. --- src/taglist.c | 41 +++++++++++++++++++++++++++++++++++++++++ src/taglist.h | 6 ++++++ 2 files changed, 47 insertions(+) diff --git a/src/taglist.c b/src/taglist.c index bfa5814dd..0b7c8e23b 100644 --- a/src/taglist.c +++ b/src/taglist.c @@ -8,6 +8,47 @@ void Tag_Add (taglist_t* list, const mtag_t tag) list->tags[list->count++] = tag; } +/// Sets the first tag entry in a taglist. +void Tag_FSet (taglist_t* list, const mtag_t tag) +{ + if (!list->count) + { + Tag_Add(list, tag); + return; + } + + list->tags[0] = tag; +} + +/// Gets the first tag entry in a taglist. +mtag_t Tag_FGet (const taglist_t* list) +{ + if (list->count) + return list->tags[0]; + + return 0; +} + +boolean Tag_Find (const taglist_t* list, const mtag_t tag) +{ + size_t i; + for (i = 0; i < list->count; i++) + if (list->tags[i] == tag) + return true; + + return false; +} + +boolean Tag_Share (const taglist_t* list1, const taglist_t* list2) +{ + size_t i; + for (i = 0; i < list1->count; i++) + if (Tag_Find(list2, list1->tags[i])) + return true; + + return false; +} + boolean Tag_Compare (const taglist_t* list1, const taglist_t* list2) { size_t i; diff --git a/src/taglist.h b/src/taglist.h index 67665434c..c22f9f277 100644 --- a/src/taglist.h +++ b/src/taglist.h @@ -15,6 +15,12 @@ typedef struct } taglist_t; void Tag_Add (taglist_t* list, const mtag_t tag); + +void Tag_FSet (taglist_t* list, const mtag_t tag); +mtag_t Tag_FGet (const taglist_t* list); +boolean Tag_Find (const taglist_t* list, const mtag_t tag); +boolean Tag_Share (const taglist_t* list1, const taglist_t* list2); + boolean Tag_Compare (const taglist_t* list1, const taglist_t* list2); typedef struct From 81be6b4067dd5b55a6b35562e90de306bce1667e Mon Sep 17 00:00:00 2001 From: Nev3r Date: Fri, 17 Apr 2020 10:04:11 +0200 Subject: [PATCH 0037/1080] Thing-based slope vertexes use taglists now. --- src/p_setup.c | 2 ++ src/p_slopes.c | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index 7c06d5b7f..bf85e7146 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2836,6 +2836,8 @@ static void P_ConvertBinaryMap(void) switch (mapthings[i].type) { case 750: + Tag_Add(&mapthings[i].tags, mapthings[i].angle); + break; case 760: case 761: case 762: diff --git a/src/p_slopes.c b/src/p_slopes.c index 9b147f046..447c5fd93 100644 --- a/src/p_slopes.c +++ b/src/p_slopes.c @@ -426,11 +426,11 @@ static pslope_t *MakeViaMapthings(INT16 tag1, INT16 tag2, INT16 tag3, UINT8 flag if (mt->type != 750) // Haha, I'm hijacking the old Chaos Spawn thingtype for something! continue; - if (!vertices[0] && mt->tag == tag1) + if (!vertices[0] && Tag_Find(&mt->tags, tag1)) vertices[0] = mt; - else if (!vertices[1] && mt->tag == tag2) + else if (!vertices[1] && Tag_Find(&mt->tags, tag2)) vertices[1] = mt; - else if (!vertices[2] && mt->tag == tag3) + else if (!vertices[2] && Tag_Find(&mt->tags, tag3)) vertices[2] = mt; } From 4fc07473fdc885e79ae4e01e4d9f423945bf7e09 Mon Sep 17 00:00:00 2001 From: Nev3r Date: Fri, 17 Apr 2020 10:05:50 +0200 Subject: [PATCH 0038/1080] Skybox spawning now uses the taglists. --- src/p_mobj.c | 11 +++++++---- src/p_setup.c | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index c004d3257..5203c092f 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -12584,17 +12584,20 @@ static boolean P_SetupSpawnedMapThing(mapthing_t *mthing, mobj_t *mobj, boolean break; } case MT_SKYBOX: - if (mthing->tag < 0 || mthing->tag > 15) + { + mtag_t tag = Tag_FGet(&mthing->tags); + if (tag < 0 || tag > 15) { - CONS_Debug(DBG_GAMELOGIC, "P_SetupSpawnedMapThing: Skybox ID %d of mapthing %s is not between 0 and 15!\n", mthing->tag, sizeu1((size_t)(mthing - mapthings))); + CONS_Debug(DBG_GAMELOGIC, "P_SetupSpawnedMapThing: Skybox ID %d of mapthing %s is not between 0 and 15!\n", tag, sizeu1((size_t)(mthing - mapthings))); break; } if (mthing->options & MTF_OBJECTSPECIAL) - skyboxcenterpnts[mthing->tag] = mobj; + skyboxcenterpnts[tag] = mobj; else - skyboxviewpnts[mthing->tag] = mobj; + skyboxviewpnts[tag] = mobj; break; + } case MT_EGGSTATUE: if (mthing->options & MTF_EXTRA) { diff --git a/src/p_setup.c b/src/p_setup.c index bf85e7146..931a7cd8f 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2844,7 +2844,7 @@ static void P_ConvertBinaryMap(void) mapthings[i].tag = mapthings[i].angle; break; case 780: - mapthings[i].tag = mapthings[i].extrainfo; + Tag_FSet(&mapthings[i].tags, mapthings[i].extrainfo); break; default: break; From b9decb2837d1ba977f3bcbd2db474afcb1f2c9c7 Mon Sep 17 00:00:00 2001 From: Nev3r Date: Fri, 17 Apr 2020 10:30:38 +0200 Subject: [PATCH 0039/1080] Polyobject spawning now use the taglist. --- src/p_polyobj.c | 22 ++++++++++++---------- src/p_setup.c | 2 +- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/p_polyobj.c b/src/p_polyobj.c index cfe12db13..3e4491fe2 100644 --- a/src/p_polyobj.c +++ b/src/p_polyobj.c @@ -539,7 +539,7 @@ static void Polyobj_findExplicit(polyobj_t *po) if (segs[i].linedef->special != POLYOBJ_EXPLICIT_LINE) continue; - Polyobj_GetInfo(segs[i].linedef->tag, &polyID, &parentID, NULL); + Polyobj_GetInfo(Tag_FGet(&segs[i].linedef->tags), &polyID, &parentID, NULL); if (polyID == po->id && parentID > 0) { @@ -622,7 +622,7 @@ static void Polyobj_spawnPolyObj(INT32 num, mobj_t *spawnSpot, INT32 id) if (seg->linedef->special != POLYOBJ_START_LINE) continue; - if (seg->linedef->tag != po->id) + if (Tag_FGet(&seg->linedef->tags) != po->id) continue; Polyobj_GetInfo(po->id, &poflags, &parentID, &potrans); // apply extra settings if they exist! @@ -659,7 +659,7 @@ static void Polyobj_spawnPolyObj(INT32 num, mobj_t *spawnSpot, INT32 id) if (po->isBad) return; - Polyobj_GetInfo(po->segs[0]->linedef->tag, NULL, NULL, &parent); + Polyobj_GetInfo(Tag_FGet(&po->segs[0]->linedef->tags), NULL, NULL, &parent); po->parent = parent; if (po->parent == po->id) // do not allow a self-reference po->parent = -1; @@ -707,10 +707,11 @@ static void Polyobj_moveToSpawnSpot(mapthing_t *anchor) polyobj_t *po; vertex_t dist, sspot; size_t i; + mtag_t tag = Tag_FGet(&anchor->tags); - if (!(po = Polyobj_GetForNum(anchor->tag))) + if (!(po = Polyobj_GetForNum(tag))) { - CONS_Debug(DBG_POLYOBJ, "Bad polyobject %d for anchor point\n", anchor->tag); + CONS_Debug(DBG_POLYOBJ, "Bad polyobject %d for anchor point\n", tag); return; } @@ -1574,7 +1575,7 @@ void Polyobj_InitLevel(void) { qitem = (mobjqitem_t *)M_QueueIterator(&spawnqueue); - Polyobj_spawnPolyObj(i, qitem->mo, qitem->mo->spawnpoint->tag); + Polyobj_spawnPolyObj(i, qitem->mo, Tag_FGet(&qitem->mo->spawnpoint->tags)); } // move polyobjects to spawn points @@ -2943,10 +2944,11 @@ INT32 EV_DoPolyObjFlag(line_t *pfdata) polymove_t *th; size_t i; INT32 start; + mtag_t tag = Tag_FGet(&pfdata->tags); - if (!(po = Polyobj_GetForNum(pfdata->tag))) + if (!(po = Polyobj_GetForNum(tag))) { - CONS_Debug(DBG_POLYOBJ, "EV_DoPolyFlag: bad polyobj %d\n", pfdata->tag); + CONS_Debug(DBG_POLYOBJ, "EV_DoPolyFlag: bad polyobj %d\n", tag); return 0; } @@ -2969,7 +2971,7 @@ INT32 EV_DoPolyObjFlag(line_t *pfdata) po->thinker = &th->thinker; // set fields - th->polyObjNum = pfdata->tag; + th->polyObjNum = tag; th->distance = 0; th->speed = P_AproxDistance(pfdata->dx, pfdata->dy)>>FRACBITS; th->angle = R_PointToAngle2(pfdata->v1->x, pfdata->v1->y, pfdata->v2->x, pfdata->v2->y)>>ANGLETOFINESHIFT; @@ -2985,7 +2987,7 @@ INT32 EV_DoPolyObjFlag(line_t *pfdata) start = 0; while ((po = Polyobj_GetChild(oldpo, &start))) { - pfdata->tag = po->id; + Tag_FSet(&pfdata->tags, po->id); EV_DoPolyObjFlag(pfdata); } diff --git a/src/p_setup.c b/src/p_setup.c index 931a7cd8f..2a514b50e 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2841,7 +2841,7 @@ static void P_ConvertBinaryMap(void) case 760: case 761: case 762: - mapthings[i].tag = mapthings[i].angle; + Tag_FSet(&mapthings[i].tags, mapthings[i].angle); break; case 780: Tag_FSet(&mapthings[i].tags, mapthings[i].extrainfo); From e59480e4cffa0a780397955b9dd5c891425c5d94 Mon Sep 17 00:00:00 2001 From: Nev3r Date: Fri, 17 Apr 2020 10:34:24 +0200 Subject: [PATCH 0040/1080] Portal lines now use the taglist's first element. --- src/r_bsp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/r_bsp.c b/src/r_bsp.c index d003db666..d5c18056c 100644 --- a/src/r_bsp.c +++ b/src/r_bsp.c @@ -456,14 +456,14 @@ static void R_AddLine(seg_t *line) if (portalrender < cv_maxportals.value) { size_t p; - INT16 tag = line->linedef->tag; + mtag_t tag = Tag_FGet(&line->linedef->tags); INT32 li1 = line->linedef-lines; INT32 li2; for (p = 0; (li2 = Tag_Iterate_Lines(tag, p)) >= 0; p++) { // Skip invalid lines. - if ((tag != lines[li2].tag) || (lines[li1].special != lines[li2].special) || (li1 == li2)) + if ((tag != Tag_FGet(&lines[li2].tags)) || (lines[li1].special != lines[li2].special) || (li1 == li2)) continue; Portal_Add2Lines(li1, li2, x1, x2); From 61c3e12d637a79a69cef4a53f0e04574173bc0a7 Mon Sep 17 00:00:00 2001 From: Nev3r Date: Fri, 17 Apr 2020 10:41:26 +0200 Subject: [PATCH 0041/1080] Make a commented out debug code account for taglists. --- src/p_user.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index 131eedd9c..c2f122ace 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -12342,12 +12342,14 @@ void P_PlayerThink(player_t *player) sector_t *controlsec; for (j=0; jtags); // Does this sector have a colormap? for (i=0; itag) + if (lines[i].special == 606 && linetag == controlsectag) break; } if (i == numlines) - CONS_Debug(DBG_GAMELOGIC, "%d, %d\n", j, sectors[j].tag); + CONS_Debug(DBG_GAMELOGIC, "%d, %d\n", j, sectag); } } From a5bc3fb507e2a1260d3427eb12f13074adcf4b45 Mon Sep 17 00:00:00 2001 From: Nev3r Date: Fri, 17 Apr 2020 10:52:12 +0200 Subject: [PATCH 0042/1080] P_SpawnSpecials() line special spawn sequence now uses the taglist, until we move on to using args[0]. --- src/p_spec.c | 48 +++++++++++++++++++++++++----------------------- 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/src/p_spec.c b/src/p_spec.c index 2e8f1b685..7abf8cbf4 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -6396,6 +6396,8 @@ void P_SpawnSpecials(boolean fromnetsave) // Init line EFFECTs for (i = 0; i < numlines; i++) { + mtag_t tag = Tag_FGet(&lines[i].tags); + if (lines[i].special != 7) // This is a hack. I can at least hope nobody wants to prevent flat alignment in netgames... { // set line specials to 0 here too, same reason as above @@ -6423,7 +6425,7 @@ void P_SpawnSpecials(boolean fromnetsave) case 1: // Definable gravity per sector sec = sides[*lines[i].sidenum].sector - sectors; - TAG_ITER_SECTORS(lines[i].tag, s) + TAG_ITER_SECTORS(tag, s) { sectors[s].gravity = §ors[sec].floorheight; // This allows it to change in realtime! @@ -6447,7 +6449,7 @@ void P_SpawnSpecials(boolean fromnetsave) case 5: // Change camera info sec = sides[*lines[i].sidenum].sector - sectors; - TAG_ITER_SECTORS(lines[i].tag, s) + TAG_ITER_SECTORS(tag, s) P_AddCameraScanner(§ors[sec], §ors[s], R_PointToAngle2(lines[i].v2->x, lines[i].v2->y, lines[i].v1->x, lines[i].v1->y)); break; @@ -6470,22 +6472,22 @@ void P_SpawnSpecials(boolean fromnetsave) } //If no tag is given, apply to front sector - if (lines[i].tag == 0) + if (tag == 0) P_ApplyFlatAlignment(lines + i, lines[i].frontsector, flatangle, xoffs, yoffs); else { - TAG_ITER_SECTORS(lines[i].tag, s) + TAG_ITER_SECTORS(tag, s) P_ApplyFlatAlignment(lines + i, sectors + s, flatangle, xoffs, yoffs); } } else // Otherwise, print a helpful warning. Can I do no less? CONS_Alert(CONS_WARNING, M_GetText("Flat alignment linedef (tag %d) doesn't have anything to do.\nConsider changing the linedef's flag configuration or removing it entirely.\n"), - lines[i].tag); + tag); break; case 8: // Sector Parameters - TAG_ITER_SECTORS(lines[i].tag, s) + TAG_ITER_SECTORS(tag, s) { if (lines[i].flags & ML_NOCLIMB) { @@ -6513,7 +6515,7 @@ void P_SpawnSpecials(boolean fromnetsave) case 10: // Vertical culling plane for sprites and FOFs sec = sides[*lines[i].sidenum].sector - sectors; - TAG_ITER_SECTORS(lines[i].tag, s) + TAG_ITER_SECTORS(tag, s) sectors[s].cullheight = &lines[i]; // This allows it to change in realtime! break; @@ -6574,13 +6576,13 @@ void P_SpawnSpecials(boolean fromnetsave) case 63: // support for drawn heights coming from different sector sec = sides[*lines[i].sidenum].sector-sectors; - TAG_ITER_SECTORS(lines[i].tag, s) + TAG_ITER_SECTORS(tag, s) sectors[s].heightsec = (INT32)sec; break; case 64: // Appearing/Disappearing FOF option if (lines[i].flags & ML_BLOCKMONSTERS) { // Find FOFs by control sector tag - TAG_ITER_SECTORS(lines[i].tag, s) + TAG_ITER_SECTORS(tag, s) for (j = 0; (unsigned)j < sectors[s].linecount; j++) if (sectors[s].lines[j]->special >= 100 && sectors[s].lines[j]->special < 300) Add_MasterDisappearer(abs(lines[i].dx>>FRACBITS), abs(lines[i].dy>>FRACBITS), abs(sides[lines[i].sidenum[0]].sector->floorheight>>FRACBITS), (INT32)(sectors[s].lines[j]-lines), (INT32)i); @@ -6597,15 +6599,15 @@ void P_SpawnSpecials(boolean fromnetsave) break; case 66: // Displace floor by front sector - TAG_ITER_SECTORS(lines[i].tag, s) + TAG_ITER_SECTORS(tag, s) P_AddPlaneDisplaceThinker(pd_floor, P_AproxDistance(lines[i].dx, lines[i].dy)>>8, sides[lines[i].sidenum[0]].sector-sectors, s, !!(lines[i].flags & ML_NOCLIMB)); break; case 67: // Displace ceiling by front sector - TAG_ITER_SECTORS(lines[i].tag, s) + TAG_ITER_SECTORS(tag, s) P_AddPlaneDisplaceThinker(pd_ceiling, P_AproxDistance(lines[i].dx, lines[i].dy)>>8, sides[lines[i].sidenum[0]].sector-sectors, s, !!(lines[i].flags & ML_NOCLIMB)); break; case 68: // Displace both floor AND ceiling by front sector - TAG_ITER_SECTORS(lines[i].tag, s) + TAG_ITER_SECTORS(tag, s) P_AddPlaneDisplaceThinker(pd_both, P_AproxDistance(lines[i].dx, lines[i].dy)>>8, sides[lines[i].sidenum[0]].sector-sectors, s, !!(lines[i].flags & ML_NOCLIMB)); break; @@ -6980,7 +6982,7 @@ void P_SpawnSpecials(boolean fromnetsave) case 251: // A THWOMP! sec = sides[*lines[i].sidenum].sector - sectors; - TAG_ITER_SECTORS(lines[i].tag, s) + TAG_ITER_SECTORS(tag, s) { P_AddThwompThinker(§ors[sec], §ors[s], &lines[i]); P_AddFakeFloor(§ors[s], §ors[sec], lines + i, @@ -7028,7 +7030,7 @@ void P_SpawnSpecials(boolean fromnetsave) sec = sides[*lines[i].sidenum].sector - sectors; // No longer totally disrupts netgames - TAG_ITER_SECTORS(lines[i].tag, s) + TAG_ITER_SECTORS(tag, s) EV_AddLaserThinker(§ors[s], §ors[sec], lines + i, secthinkers); break; @@ -7039,7 +7041,7 @@ void P_SpawnSpecials(boolean fromnetsave) P_AddFakeFloorsByLine(i, fofflags, secthinkers); } else - I_Error("Custom FOF (tag %d) found without a linedef back side!", lines[i].tag); + I_Error("Custom FOF (tag %d) found without a linedef back side!", tag); break; case 300: // Linedef executor (combines with sector special 974/975) and commands @@ -7174,7 +7176,7 @@ void P_SpawnSpecials(boolean fromnetsave) { CONS_Alert(CONS_WARNING, M_GetText("Boss enable linedef (tag %d) has an invalid texture x offset.\nConsider changing it or removing it entirely.\n"), - lines[i].tag); + tag); break; } if (!(lines[i].flags & ML_NOCLIMB)) @@ -7220,46 +7222,46 @@ void P_SpawnSpecials(boolean fromnetsave) case 600: // floor lighting independently (e.g. lava) sec = sides[*lines[i].sidenum].sector-sectors; - TAG_ITER_SECTORS(lines[i].tag, s) + TAG_ITER_SECTORS(tag, s) sectors[s].floorlightsec = (INT32)sec; break; case 601: // ceiling lighting independently sec = sides[*lines[i].sidenum].sector-sectors; - TAG_ITER_SECTORS(lines[i].tag, s) + TAG_ITER_SECTORS(tag, s) sectors[s].ceilinglightsec = (INT32)sec; break; case 602: // Adjustable pulsating light sec = sides[*lines[i].sidenum].sector - sectors; - TAG_ITER_SECTORS(lines[i].tag, s) + TAG_ITER_SECTORS(tag, s) P_SpawnAdjustableGlowingLight(§ors[sec], §ors[s], P_AproxDistance(lines[i].dx, lines[i].dy)>>FRACBITS); break; case 603: // Adjustable flickering light sec = sides[*lines[i].sidenum].sector - sectors; - TAG_ITER_SECTORS(lines[i].tag, s) + TAG_ITER_SECTORS(tag, s) P_SpawnAdjustableFireFlicker(§ors[sec], §ors[s], P_AproxDistance(lines[i].dx, lines[i].dy)>>FRACBITS); break; case 604: // Adjustable Blinking Light (unsynchronized) sec = sides[*lines[i].sidenum].sector - sectors; - TAG_ITER_SECTORS(lines[i].tag, s) + TAG_ITER_SECTORS(tag, s) P_SpawnAdjustableStrobeFlash(§ors[sec], §ors[s], abs(lines[i].dx)>>FRACBITS, abs(lines[i].dy)>>FRACBITS, false); break; case 605: // Adjustable Blinking Light (synchronized) sec = sides[*lines[i].sidenum].sector - sectors; - TAG_ITER_SECTORS(lines[i].tag, s) + TAG_ITER_SECTORS(tag, s) P_SpawnAdjustableStrobeFlash(§ors[sec], §ors[s], abs(lines[i].dx)>>FRACBITS, abs(lines[i].dy)>>FRACBITS, true); break; case 606: // HACK! Copy colormaps. Just plain colormaps. - TAG_ITER_SECTORS(lines[i].tag, s) + TAG_ITER_SECTORS(tag, s) sectors[s].extra_colormap = sectors[s].spawn_extra_colormap = sides[lines[i].sidenum[0]].colormap_data; break; From dd46b1ab4498770b275f019c488f8222d30fa03a Mon Sep 17 00:00:00 2001 From: Nev3r Date: Fri, 17 Apr 2020 11:04:44 +0200 Subject: [PATCH 0043/1080] P_ConvertBinaryMap() line conversion now uses the first tag from taglists. --- src/p_setup.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index 2a514b50e..54a3d27c5 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2728,6 +2728,8 @@ static void P_ConvertBinaryMap(void) for (i = 0; i < numlines; i++) { + mtag_t tag = Tag_FGet(&lines[i].tags); + switch (lines[i].special) { case 443: //Call Lua function @@ -2778,7 +2780,7 @@ static void P_ConvertBinaryMap(void) else if (lines[i].special == 715) lines[i].args[0] = 3; - lines[i].args[1] = lines[i].tag; + lines[i].args[1] = tag; if (lines[i].flags & ML_EFFECT6) { @@ -2810,9 +2812,9 @@ static void P_ConvertBinaryMap(void) case 721: //Copy front side ceiling slope case 722: //Copy front side floor and ceiling slope if (lines[i].special != 721) - lines[i].args[0] = lines[i].tag; + lines[i].args[0] = tag; if (lines[i].special != 720) - lines[i].args[1] = lines[i].tag; + lines[i].args[1] = tag; lines[i].special = 720; break; case 900: //Translucent wall (10%) From 209b8e76782c40302846e31a6a59946189b0e405 Mon Sep 17 00:00:00 2001 From: Nev3r Date: Fri, 17 Apr 2020 11:21:40 +0200 Subject: [PATCH 0044/1080] Map loading should consider tag 0 as a valid tag and add its respective entries just like the rest of tags. --- src/p_setup.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index 54a3d27c5..f2323e532 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -936,8 +936,7 @@ static void P_LoadSectors(UINT8 *data) ss->lightlevel = SHORT(ms->lightlevel); ss->special = SHORT(ms->special); ss->tag = SHORT(ms->tag); - if (ss->tag) - Tag_Add(&ss->tags, ss->tag); + Tag_FSet(&ss->tags, ss->tag); ss->floor_xoffs = ss->floor_yoffs = 0; ss->ceiling_xoffs = ss->ceiling_yoffs = 0; @@ -1052,8 +1051,7 @@ static void P_LoadLinedefs(UINT8 *data) ld->flags = SHORT(mld->flags); ld->special = SHORT(mld->special); ld->tag = SHORT(mld->tag); - if (ld->tag) - Tag_Add(&ld->tags, ld->tag); + Tag_FSet(&ld->tags, ld->tag); memset(ld->args, 0, NUMLINEARGS*sizeof(*ld->args)); memset(ld->stringargs, 0x00, NUMLINESTRINGARGS*sizeof(*ld->stringargs)); ld->alpha = FRACUNIT; @@ -1284,6 +1282,7 @@ static void P_LoadThings(UINT8 *data) mt->options = READUINT16(data); mt->extrainfo = (UINT8)(mt->type >> 12); mt->tag = 0; + Tag_FSet(&mt->tags, mt->tag); mt->type &= 4095; @@ -1405,8 +1404,7 @@ static void ParseTextmapSectorParameter(UINT32 i, char *param, char *val) else if (fastcmp(param, "id")) { sectors[i].tag = atol(val); - if (sectors[i].tag) - Tag_Add(§ors[i].tags, sectors[i].tag); + Tag_FSet(§ors[i].tags, sectors[i].tag); } else if (fastcmp(param, "moreids")) { @@ -1455,8 +1453,7 @@ static void ParseTextmapLinedefParameter(UINT32 i, char *param, char *val) if (fastcmp(param, "id")) { lines[i].tag = atol(val); - if (lines[i].tag) - Tag_Add(&lines[i].tags, lines[i].tag); + Tag_FSet(&lines[i].tags, lines[i].tag); } else if (fastcmp(param, "moreids")) { @@ -1536,8 +1533,7 @@ static void ParseTextmapThingParameter(UINT32 i, char *param, char *val) if (fastcmp(param, "id")) { mapthings[i].tag = atol(val); - if (mapthings[i].tag) - Tag_Add(&mapthings[i].tags, mapthings[i].tag); + Tag_FSet(&mapthings[i].tags, mapthings[i].tag); } else if (fastcmp(param, "moreids")) { @@ -1678,6 +1674,7 @@ static void P_LoadTextmap(void) sc->special = 0; sc->tag = 0; + Tag_FSet(&sc->tags, 0); sc->floor_xoffs = sc->floor_yoffs = 0; sc->ceiling_xoffs = sc->ceiling_yoffs = 0; @@ -1685,6 +1682,7 @@ static void P_LoadTextmap(void) sc->floorpic_angle = sc->ceilingpic_angle = 0; TextmapParse(sectorsPos[i], i, ParseTextmapSectorParameter); + P_InitializeSector(sc); TextmapFixFlatOffsets(sc); } @@ -1696,6 +1694,8 @@ static void P_LoadTextmap(void) ld->flags = 0; ld->special = 0; ld->tag = 0; + Tag_FSet(&ld->tags, 0); + memset(ld->args, 0, NUMLINEARGS*sizeof(*ld->args)); memset(ld->stringargs, 0x00, NUMLINESTRINGARGS*sizeof(*ld->stringargs)); ld->alpha = FRACUNIT; @@ -1743,6 +1743,7 @@ static void P_LoadTextmap(void) mt->z = 0; mt->extrainfo = 0; mt->tag = 0; + Tag_FSet(&mt->tags, 0); mt->mobj = NULL; TextmapParse(mapthingsPos[i], i, ParseTextmapThingParameter); From b690d35a9941420e0643fef069712a34d1a34500 Mon Sep 17 00:00:00 2001 From: Nev3r Date: Fri, 17 Apr 2020 11:43:37 +0200 Subject: [PATCH 0045/1080] Move the global taglist init functionality to the taglist files. --- src/p_spec.c | 23 +---------------------- src/taglist.c | 33 ++++++++++++++++++++++++++++++--- src/taglist.h | 4 +--- 3 files changed, 32 insertions(+), 28 deletions(-) diff --git a/src/p_spec.c b/src/p_spec.c index 7abf8cbf4..4e833ba6d 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -1445,7 +1445,6 @@ void P_RunNightsCapsuleTouchExecutors(mobj_t *actor, boolean entering, boolean e static inline void P_InitTagLists(void) { register size_t i; - size_t j; for (i = numsectors - 1; i != (size_t)-1; i--) { @@ -1461,27 +1460,7 @@ static inline void P_InitTagLists(void) lines[j].firsttag = (INT32)i; } - for (i = 0; i < MAXTAGS; i++) - { - tags_sectors[i] = NULL; - tags_lines[i] = NULL; - tags_mapthings[i] = NULL; - } - for (i = 0; i < numsectors; i++) - { - for (j = 0; j < sectors[i].tags.count; j++) - Taglist_AddToSectors(sectors[i].tags.tags[j], i); - } - for (i = 0; i < numlines; i++) - { - for (j = 0; j < lines[i].tags.count; j++) - Taglist_AddToLines(lines[i].tags.tags[j], i); - } - for (i = 0; i < nummapthings; i++) - { - for (j = 0; j < mapthings[i].tags.count; j++) - Taglist_AddToMapthings(mapthings[i].tags.tags[j], i); - } + Taglist_InitGlobalTables(); } /** Finds minimum light from an adjacent sector. diff --git a/src/taglist.c b/src/taglist.c index 0b7c8e23b..99d23bf5f 100644 --- a/src/taglist.c +++ b/src/taglist.c @@ -63,7 +63,7 @@ boolean Tag_Compare (const taglist_t* list1, const taglist_t* list2) return true; } -void Taglist_AddToSectors (const mtag_t tag, const size_t itemid) +static void Taglist_AddToSectors (const mtag_t tag, const size_t itemid) { taggroup_t* tagelems; @@ -79,7 +79,7 @@ void Taglist_AddToSectors (const mtag_t tag, const size_t itemid) tagelems->elements[tagelems->count - 1] = itemid; } -void Taglist_AddToLines (const mtag_t tag, const size_t itemid) +static void Taglist_AddToLines (const mtag_t tag, const size_t itemid) { taggroup_t* tagelems; @@ -95,7 +95,7 @@ void Taglist_AddToLines (const mtag_t tag, const size_t itemid) tagelems->elements[tagelems->count - 1] = itemid; } -void Taglist_AddToMapthings (const mtag_t tag, const size_t itemid) +static void Taglist_AddToMapthings (const mtag_t tag, const size_t itemid) { taggroup_t* tagelems; @@ -111,6 +111,33 @@ void Taglist_AddToMapthings (const mtag_t tag, const size_t itemid) tagelems->elements[tagelems->count - 1] = itemid; } +void Taglist_InitGlobalTables(void) +{ + size_t i, j; + + for (i = 0; i < MAXTAGS; i++) + { + tags_sectors[i] = NULL; + tags_lines[i] = NULL; + tags_mapthings[i] = NULL; + } + for (i = 0; i < numsectors; i++) + { + for (j = 0; j < sectors[i].tags.count; j++) + Taglist_AddToSectors(sectors[i].tags.tags[j], i); + } + for (i = 0; i < numlines; i++) + { + for (j = 0; j < lines[i].tags.count; j++) + Taglist_AddToLines(lines[i].tags.tags[j], i); + } + for (i = 0; i < nummapthings; i++) + { + for (j = 0; j < mapthings[i].tags.count; j++) + Taglist_AddToMapthings(mapthings[i].tags.tags[j], i); + } +} + INT32 Tag_Iterate_Sectors (const mtag_t tag, const size_t p) { if (tag == MTAG_GLOBAL) diff --git a/src/taglist.h b/src/taglist.h index c22f9f277..b14c316ff 100644 --- a/src/taglist.h +++ b/src/taglist.h @@ -33,9 +33,7 @@ taggroup_t* tags_sectors[MAXTAGS + 1]; taggroup_t* tags_lines[MAXTAGS + 1]; taggroup_t* tags_mapthings[MAXTAGS + 1]; -void Taglist_AddToSectors (const mtag_t tag, const size_t itemid); -void Taglist_AddToLines (const mtag_t tag, const size_t itemid); -void Taglist_AddToMapthings (const mtag_t tag, const size_t itemid); +void Taglist_InitGlobalTables(void); INT32 Tag_Iterate_Sectors (const mtag_t tag, const size_t p); INT32 Tag_Iterate_Lines (const mtag_t tag, const size_t p); From e3dfdb448eba67832c2fc9d4060be92458fb564d Mon Sep 17 00:00:00 2001 From: Nev3r Date: Fri, 17 Apr 2020 18:14:15 +0200 Subject: [PATCH 0046/1080] Add currently unused auxiliary function. --- src/taglist.c | 6 ++++++ src/taglist.h | 2 ++ 2 files changed, 8 insertions(+) diff --git a/src/taglist.c b/src/taglist.c index 99d23bf5f..1849c314c 100644 --- a/src/taglist.c +++ b/src/taglist.c @@ -111,6 +111,12 @@ static void Taglist_AddToMapthings (const mtag_t tag, const size_t itemid) tagelems->elements[tagelems->count - 1] = itemid; } +void Tag_SectorFSet (const size_t id, const mtag_t tag) +{ + sector_t* sec = §ors[id]; + Tag_FSet(&sec->tags, tag); +} + void Taglist_InitGlobalTables(void) { size_t i, j; diff --git a/src/taglist.h b/src/taglist.h index b14c316ff..050bebed7 100644 --- a/src/taglist.h +++ b/src/taglist.h @@ -23,6 +23,8 @@ boolean Tag_Share (const taglist_t* list1, const taglist_t* list2); boolean Tag_Compare (const taglist_t* list1, const taglist_t* list2); +void Tag_SectorFSet (const size_t id, const mtag_t tag); + typedef struct { size_t *elements; From b5eaad42fc89bff79730e836ab635d897204dc35 Mon Sep 17 00:00:00 2001 From: Nev3r Date: Fri, 17 Apr 2020 18:15:25 +0200 Subject: [PATCH 0047/1080] Carry over a considerable case regarding accessing the old tag vars. --- src/p_mobj.c | 30 ++++++++----- src/p_setup.c | 2 +- src/p_slopes.c | 3 -- src/p_spec.c | 120 ++++++++++++++++++++++++++++--------------------- src/p_user.c | 69 +++++++++++++++++----------- 5 files changed, 130 insertions(+), 94 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index 5203c092f..a65d3bbf3 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -4621,7 +4621,7 @@ static boolean P_Boss4MoveCage(mobj_t *mobj, fixed_t delta) for (snum = sectors[tag%numsectors].firsttag; snum != -1; snum = sector->nexttag) { sector = §ors[snum]; - if (sector->tag != tag) + if (!Tag_Find(§or->tags, tag)) continue; sector->floorheight += delta; sector->ceilingheight += delta; @@ -4715,9 +4715,9 @@ static void P_Boss4DestroyCage(mobj_t *mobj) next = sector->nexttag; sector->nexttag = -1; - if (sector->tag != tag) + if (!Tag_Find(§or->tags, tag)) continue; - sector->tag = 0; + Tag_SectorFSet(sector - sectors, 0); // Destroy the FOFs. for (a = 0; a < sector->numattached; a++) @@ -10036,11 +10036,12 @@ void P_MobjThinker(mobj_t *mobj) // Sector special (2,8) 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); + sector_t *sec2 = P_ThingOnSpecial3DFloor(mobj); if (sec2 && GETSECSPECIAL(sec2->special, 2) == 1) - P_LinedefExecute(sec2->tag, mobj, sec2); + { + mtag_t tag = Tag_FGet(&sec2->tags); + P_LinedefExecute(tag, mobj, sec2); + } } if (mobj->scale != mobj->destscale) @@ -10264,14 +10265,19 @@ void P_PushableThinker(mobj_t *mobj) sec = mobj->subsector->sector; if (GETSECSPECIAL(sec->special, 2) == 1 && mobj->z == sec->floorheight) - P_LinedefExecute(sec->tag, mobj, sec); + { + mtag_t tag = Tag_FGet(&sec->tags); + P_LinedefExecute(tag, mobj, sec); + } + // else if (GETSECSPECIAL(sec->special, 2) == 8) { - sector_t *sec2; - - sec2 = P_ThingOnSpecial3DFloor(mobj); + sector_t *sec2 = P_ThingOnSpecial3DFloor(mobj); if (sec2 && GETSECSPECIAL(sec2->special, 2) == 1) - P_LinedefExecute(sec2->tag, mobj, sec2); + { + mtag_t tag = Tag_FGet(&sec2->tags); + P_LinedefExecute(tag, mobj, sec2); + } } // it has to be pushable RIGHT NOW for this part to happen diff --git a/src/p_setup.c b/src/p_setup.c index f2323e532..2cbc2ceae 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -1241,7 +1241,7 @@ static void P_LoadSidedefs(UINT8 *data) || (msd->toptexture[0] >= 'A' && msd->toptexture[0] <= 'F')) sd->toptexture = axtoi(msd->toptexture); else - I_Error("Custom FOF (tag %d) needs a value in the linedef's back side upper texture field.", sd->line->tag); + I_Error("Custom FOF (line id %d) needs a value in the linedef's back side upper texture field.", sd->line - lines); sd->midtexture = R_TextureNumForName(msd->midtexture); sd->bottomtexture = R_TextureNumForName(msd->bottomtexture); diff --git a/src/p_slopes.c b/src/p_slopes.c index 447c5fd93..39a49084b 100644 --- a/src/p_slopes.c +++ b/src/p_slopes.c @@ -405,9 +405,6 @@ static void line_SpawnViaLine(const int linenum, const boolean spawnthinker) P_AddDynSlopeThinker(cslope, DP_BACKCEIL, line, extent, NULL, NULL); } } - - if(!line->tag) - return; } /// Creates a new slope from three mapthings with the specified IDs diff --git a/src/p_spec.c b/src/p_spec.c index 4e833ba6d..6c47e24c1 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -2061,7 +2061,7 @@ void P_LinedefExecute(INT16 tag, mobj_t *actor, sector_t *caller) for (masterline = 0; masterline < numlines; masterline++) { - if (lines[masterline].tag != tag) + if (Tag_FGet(&lines[masterline].tags) != tag) continue; // "No More Enemies" and "Level Load" take care of themselves. @@ -2327,6 +2327,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) { INT32 secnum = -1; mobj_t *bot = NULL; + mtag_t tag = Tag_FGet(&line->tags); TAG_ITER_C I_Assert(!mo || !P_MobjWasRemoved(mo)); // If mo is there, mo must be valid! @@ -2355,7 +2356,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) newceilinglightsec = line->frontsector->ceilinglightsec; // act on all sectors with the same tag as the triggering linedef - TAG_ITER_SECTORS(line->tag, secnum) + TAG_ITER_SECTORS(tag, secnum) { if (sectors[secnum].lightingdata) { @@ -2410,7 +2411,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) case 409: // Change tagged sectors' tag // (formerly "Change calling sectors' tag", but behavior was changed) { - TAG_ITER_SECTORS(line->tag, secnum) + TAG_ITER_SECTORS(tag, secnum) P_ChangeSectorTag(secnum,(INT16)(sides[line->sidenum[0]].textureoffset>>FRACBITS)); break; } @@ -2420,7 +2421,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) break; case 411: // Stop floor/ceiling movement in tagged sector(s) - TAG_ITER_SECTORS(line->tag, secnum) + TAG_ITER_SECTORS(tag, secnum) { if (sectors[secnum].floordata) { @@ -2490,7 +2491,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) } else { - if ((secnum = Tag_Iterate_Sectors(line->tag, 0)) < 0) + if ((secnum = Tag_Iterate_Sectors(tag, 0)) < 0) return; dest = P_GetObjectTypeInSectorNum(MT_TELEPORTMAN, secnum); @@ -2597,7 +2598,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) return; } - if (line->tag != 0) // Do special stuff only if a non-zero linedef tag is set + if (tag != 0) // Do special stuff only if a non-zero linedef tag is set { // Play sounds from tagged sectors' origins. if (line->flags & ML_EFFECT5) // Repeat Midtexture @@ -2605,7 +2606,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) // Additionally play the sound from tagged sectors' soundorgs sector_t *sec; - TAG_ITER_SECTORS(line->tag, secnum) + TAG_ITER_SECTORS(tag, secnum) { sec = §ors[secnum]; S_StartSound(&sec->soundorg, sfxnum); @@ -2625,7 +2626,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) if (!camobj) continue; - if (foundit || (camobj->subsector->sector->tag == line->tag)) + if (foundit || (camobj->subsector->sector->tag == tag)) { foundit = true; break; @@ -2634,7 +2635,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) // Only trigger if mobj is touching the tag for(rover = camobj->subsector->sector->ffloors; rover; rover = rover->next) { - if (rover->master->frontsector->tag != line->tag) + if (rover->master->frontsector->tag != tag) continue; if (camobj->z > P_GetSpecialTopZ(camobj, sectors + rover->secnum, camobj->subsector->sector)) @@ -2720,7 +2721,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) break; case 416: // Spawn adjustable fire flicker - TAG_ITER_SECTORS(line->tag, secnum) + TAG_ITER_SECTORS(tag, secnum) { if (line->flags & ML_NOCLIMB && line->backsector) { @@ -2754,7 +2755,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) break; case 417: // Spawn adjustable glowing light - TAG_ITER_SECTORS(line->tag, secnum) + TAG_ITER_SECTORS(tag, secnum) { if (line->flags & ML_NOCLIMB && line->backsector) { @@ -2788,7 +2789,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) break; case 418: // Spawn adjustable strobe flash (unsynchronized) - TAG_ITER_SECTORS(line->tag, secnum) + TAG_ITER_SECTORS(tag, secnum) { if (line->flags & ML_NOCLIMB && line->backsector) { @@ -2822,7 +2823,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) break; case 419: // Spawn adjustable strobe flash (synchronized) - TAG_ITER_SECTORS(line->tag, secnum) + TAG_ITER_SECTORS(tag, secnum) { if (line->flags & ML_NOCLIMB && line->backsector) { @@ -2856,7 +2857,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) break; case 420: // Fade light levels in tagged sectors to new value - P_FadeLight(line->tag, + P_FadeLight(tag, (line->flags & ML_DONTPEGBOTTOM) ? max(sides[line->sidenum[0]].textureoffset>>FRACBITS, 0) : line->frontsector->lightlevel, // failsafe: if user specifies Back Y Offset and NOT Front Y Offset, use the Back Offset // to be consistent with other light and fade specials @@ -2870,7 +2871,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) break; case 421: // Stop lighting effect in tagged sectors - TAG_ITER_SECTORS(line->tag, secnum) + TAG_ITER_SECTORS(tag, secnum) if (sectors[secnum].lightingdata) { P_RemoveThinker(&((elevator_t *)sectors[secnum].lightingdata)->thinker); @@ -2885,7 +2886,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) if ((!mo || !mo->player) && !titlemapinaction) // only players have views, and title screens return; - if ((secnum = Tag_Iterate_Sectors(line->tag, 0)) < 0) + if ((secnum = Tag_Iterate_Sectors(tag, 0)) < 0) return; altview = P_GetObjectTypeInSectorNum(MT_ALTVIEWMAN, secnum); @@ -3062,8 +3063,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) continue; scroller = (scroll_t *)th; - - if (sectors[scroller->affectee].tag != line->tag) + if (!Tag_Find(§ors[scroller->affectee].tags, tag)) continue; scroller->dx = FixedMul(line->dx>>SCROLL_SHIFT, CARRYFACTOR); @@ -3139,12 +3139,13 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) size_t linenum; side_t *set = &sides[line->sidenum[0]], *this; boolean always = !(line->flags & ML_NOCLIMB); // If noclimb: Only change mid texture if mid texture already exists on tagged lines, etc. + for (linenum = 0; linenum < numlines; linenum++) { if (lines[linenum].special == 439) continue; // Don't override other set texture lines! - if (lines[linenum].tag != line->tag) + if (!Tag_Find(&lines[linenum].tags, tag)) continue; // Find tagged lines // Front side @@ -3204,7 +3205,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) if (line->sidenum[1] != 0xffff) state = (statenum_t)sides[line->sidenum[1]].toptexture; - TAG_ITER_SECTORS(line->tag, secnum) + TAG_ITER_SECTORS(tag, secnum) { boolean tryagain; sec = sectors + secnum; @@ -3359,7 +3360,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) // Except it is activated by linedef executor, not level load // This could even override existing colormaps I believe // -- Monster Iestyn 14/06/18 - TAG_ITER_SECTORS(line->tag, secnum) + TAG_ITER_SECTORS(tag, secnum) { P_ResetColormapFader(§ors[secnum]); @@ -3424,7 +3425,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) { CONS_Alert(CONS_WARNING, M_GetText("Skybox switch linedef (tag %d) doesn't have anything to do.\nConsider changing the linedef's flag configuration or removing it entirely.\n"), - line->tag); + tag); } else { @@ -3462,7 +3463,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) { CONS_Alert(CONS_WARNING, M_GetText("Boss enable linedef (tag %d) has an invalid texture x offset.\nConsider changing it or removing it entirely.\n"), - line->tag); + tag); break; } if (line->flags & ML_NOCLIMB) @@ -3479,7 +3480,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) } case 450: // Execute Linedef Executor - for recursion - P_LinedefExecute(line->tag, mo, NULL); + P_LinedefExecute(tag, mo, NULL); break; case 451: // Execute Random Linedef Executor @@ -3687,7 +3688,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) } case 455: // Fade colormap - TAG_ITER_SECTORS(line->tag, secnum) + TAG_ITER_SECTORS(tag, secnum) { extracolormap_t *source_exc, *dest_exc, *exc; INT32 speed = (INT32)((line->flags & ML_DONTPEGBOTTOM) || !sides[line->sidenum[0]].rowoffset) && line->sidenum[1] != 0xFFFF ? @@ -3776,7 +3777,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) break; case 456: // Stop fade colormap - TAG_ITER_SECTORS(line->tag, secnum) + TAG_ITER_SECTORS(tag, secnum) P_ResetColormapFader(§ors[secnum]); break; @@ -3790,7 +3791,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) boolean persist = (line->flags & ML_EFFECT2); mobj_t *anchormo; - if ((secnum = Tag_Iterate_Sectors(line->tag, 0)) < 0) + if ((secnum = Tag_Iterate_Sectors(tag, 0)) < 0) return; anchormo = P_GetObjectTypeInSectorNum(MT_ANGLEMAN, secnum); @@ -3821,7 +3822,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) { INT32 promptnum = max(0, (sides[line->sidenum[0]].textureoffset>>FRACBITS)-1); INT32 pagenum = max(0, (sides[line->sidenum[0]].rowoffset>>FRACBITS)-1); - INT32 postexectag = abs((line->sidenum[1] != 0xFFFF) ? sides[line->sidenum[1]].textureoffset>>FRACBITS : line->tag); + INT32 postexectag = abs((line->sidenum[1] != 0xFFFF) ? sides[line->sidenum[1]].textureoffset>>FRACBITS : tag); boolean closetextprompt = (line->flags & ML_BLOCKMONSTERS); //boolean allplayers = (line->flags & ML_NOCLIMB); @@ -4258,6 +4259,7 @@ void P_ProcessSpecialSector(player_t *player, sector_t *sector, sector_t *rovers INT32 i = 0; INT32 section1, section2, section3, section4; INT32 special; + mtag_t sectag = Tag_FGet(§or->tags); section1 = GETSECSPECIAL(sector->special, 1); section2 = GETSECSPECIAL(sector->special, 2); @@ -4411,7 +4413,7 @@ void P_ProcessSpecialSector(player_t *player, sector_t *sector, sector_t *rovers case 6: // Linedef executor (7 Emeralds) case 7: // Linedef executor (NiGHTS Mare) if (!player->bot) - P_LinedefExecute(sector->tag, player->mo, sector); + P_LinedefExecute(sectag, player->mo, sector); break; case 8: // Tells pushable things to check FOFs break; @@ -4440,13 +4442,16 @@ void P_ProcessSpecialSector(player_t *player, sector_t *sector, sector_t *rovers sector->special = 0; // Move the button down + Tag_FSet(&junk.tags, 680); junk.tag = 680; EV_DoElevator(&junk, elevateDown, false); // Open the top FOF + Tag_FSet(&junk.tags, 681); junk.tag = 681; EV_DoFloor(&junk, raiseFloorToNearestFast); // Open the bottom FOF + Tag_FSet(&junk.tags, 682); junk.tag = 682; EV_DoCeiling(&junk, lowerToLowestFast); @@ -4482,7 +4487,7 @@ DoneSection2: if (player->powers[pw_flashing] != 0 && player->powers[pw_flashing] < TICRATE/2) break; - i = Tag_FindLineSpecial(4, sector->tag); + i = Tag_FindLineSpecial(4, sectag); if (i != -1) { @@ -4495,7 +4500,7 @@ DoneSection2: if (linespeed == 0) { - CONS_Debug(DBG_GAMELOGIC, "ERROR: Speed pad (tag %d) at zero speed.\n", sector->tag); + CONS_Debug(DBG_GAMELOGIC, "ERROR: Speed pad (tag %d) at zero speed.\n", sectag); break; } @@ -4594,7 +4599,7 @@ DoneSection2: // 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 = Tag_FindLineSpecial(2, sector->tag); + lineindex = Tag_FindLineSpecial(2, sectag); if (gametype == GT_COOP && lineindex != -1) // Custom exit! { @@ -4719,7 +4724,7 @@ DoneSection2: break; // Find line #3 tagged to this sector - lineindex = Tag_FindLineSpecial(3, sector->tag); + lineindex = Tag_FindLineSpecial(3, sectag); if (lineindex == -1) { @@ -4801,7 +4806,7 @@ DoneSection2: break; // Find line #3 tagged to this sector - lineindex = Tag_FindLineSpecial(3, sector->tag); + lineindex = Tag_FindLineSpecial(3, sectag); if (lineindex == -1) { @@ -4948,7 +4953,7 @@ DoneSection2: memset(&resulthigh, 0x00, sizeof(resulthigh)); // Find line #11 tagged to this sector - lineindex = Tag_FindLineSpecial(11, sector->tag); + lineindex = Tag_FindLineSpecial(11, sectag); if (lineindex == -1) { @@ -7294,9 +7299,10 @@ static void P_AddFakeFloorsByLine(size_t line, ffloortype_e ffloorflags, thinker { TAG_ITER_C INT32 s; + mtag_t tag = Tag_FGet(&lines[line].tags); size_t sec = sides[*lines[line].sidenum].sector-sectors; line_t* li = lines + line; - TAG_ITER_SECTORS(li->tag, s) + TAG_ITER_SECTORS(tag, s) P_AddFakeFloor(§ors[s], §ors[sec], li, ffloorflags, secthinkers); } @@ -7443,7 +7449,7 @@ void T_Scroll(scroll_t *s) if (!is3dblock) continue; - TAG_ITER_SECTORS(line->tag, sect) + TAG_ITER_SECTORS(Tag_FGet(&line->tags), sect) { sector_t *psec; psec = sectors + sect; @@ -7518,7 +7524,7 @@ void T_Scroll(scroll_t *s) if (!is3dblock) continue; - TAG_ITER_SECTORS(line->tag, sect) + TAG_ITER_SECTORS(Tag_FGet(&line->tags), sect) { sector_t *psec; psec = sectors + sect; @@ -7616,6 +7622,7 @@ static void P_SpawnScrollers(void) { size_t i; line_t *l = lines; + mtag_t tag; for (i = 0; i < numlines; i++, l++) { @@ -7624,6 +7631,8 @@ static void P_SpawnScrollers(void) INT32 control = -1, accel = 0; // no control sector or acceleration INT32 special = l->special; + tag = Tag_FGet(&l->tags); + // These types are same as the ones they get set to except that the // first side's sector's heights cause scrolling when they change, and // this linedef controls the direction and speed of the scrolling. The @@ -7659,7 +7668,7 @@ static void P_SpawnScrollers(void) case 513: // scroll effect ceiling case 533: // scroll and carry objects on ceiling - TAG_ITER_SECTORS(l->tag, s) + TAG_ITER_SECTORS(tag, s) Add_Scroller(sc_ceiling, -dx, dy, control, s, accel, l->flags & ML_NOCLIMB); if (special != 533) break; @@ -7668,13 +7677,13 @@ static void P_SpawnScrollers(void) case 523: // carry objects on ceiling dx = FixedMul(dx, CARRYFACTOR); dy = FixedMul(dy, CARRYFACTOR); - TAG_ITER_SECTORS(l->tag, s) + TAG_ITER_SECTORS(tag, s) Add_Scroller(sc_carry_ceiling, dx, dy, control, s, accel, l->flags & ML_NOCLIMB); break; case 510: // scroll effect floor case 530: // scroll and carry objects on floor - TAG_ITER_SECTORS(l->tag, s) + TAG_ITER_SECTORS(tag, s) Add_Scroller(sc_floor, -dx, dy, control, s, accel, l->flags & ML_NOCLIMB); if (special != 530) break; @@ -7683,7 +7692,7 @@ static void P_SpawnScrollers(void) case 520: // carry objects on floor dx = FixedMul(dx, CARRYFACTOR); dy = FixedMul(dy, CARRYFACTOR); - TAG_ITER_SECTORS(l->tag, s) + TAG_ITER_SECTORS(tag, s) Add_Scroller(sc_carry, dx, dy, control, s, accel, l->flags & ML_NOCLIMB); break; @@ -7691,7 +7700,7 @@ static void P_SpawnScrollers(void) // (same direction and speed as scrolling floors) case 502: { - TAG_ITER_LINES(l->tag, s) + TAG_ITER_LINES(tag, s) if (s != (INT32)i) Add_Scroller(sc_side, dx, dy, control, lines[s].sidenum[0], accel, 0); break; @@ -7761,9 +7770,10 @@ void T_Disappear(disappear_t *d) { ffloor_t *rover; register INT32 s; + mtag_t afftag = Tag_FGet(&lines[d->affectee].tags); TAG_ITER_C - TAG_ITER_SECTORS(lines[d->affectee].tag, s) + TAG_ITER_SECTORS(afftag, s) { for (rover = sectors[s].ffloors; rover; rover = rover->next) { @@ -8492,6 +8502,7 @@ static void P_SpawnFriction(void) { size_t i; line_t *l = lines; + mtag_t tag; register INT32 s; fixed_t strength; // frontside texture offset controls magnitude fixed_t friction; // friction value to be applied during movement @@ -8501,6 +8512,7 @@ static void P_SpawnFriction(void) for (i = 0; i < numlines; i++, l++) if (l->special == 540) { + tag = Tag_FGet(&l->tags); strength = sides[l->sidenum[0]].textureoffset>>FRACBITS; if (strength > 0) // sludge strength = strength*2; // otherwise, the maximum sludginess value is +967... @@ -8521,7 +8533,7 @@ static void P_SpawnFriction(void) else movefactor = FRACUNIT; - TAG_ITER_SECTORS(l->tag, s) + TAG_ITER_SECTORS(tag, s) Add_Friction(friction, movefactor, s, -1); } } @@ -9049,23 +9061,26 @@ static void P_SpawnPushers(void) { size_t i; line_t *l = lines; + mtag_t tag; register INT32 s; mobj_t *thing; TAG_ITER_C for (i = 0; i < numlines; i++, l++) + { + tag = Tag_FGet(&l->tags); switch (l->special) { case 541: // wind - TAG_ITER_SECTORS(l->tag, s) + TAG_ITER_SECTORS(tag, s) Add_Pusher(p_wind, l->dx, l->dy, NULL, s, -1, l->flags & ML_NOCLIMB, l->flags & ML_EFFECT4); break; case 544: // current - TAG_ITER_SECTORS(l->tag, s) + TAG_ITER_SECTORS(tag, s) Add_Pusher(p_current, l->dx, l->dy, NULL, s, -1, l->flags & ML_NOCLIMB, l->flags & ML_EFFECT4); break; case 547: // push/pull - TAG_ITER_SECTORS(l->tag, s) + TAG_ITER_SECTORS(tag, s) { thing = P_GetPushThing(s); if (thing) // No MT_P* means no effect @@ -9073,20 +9088,21 @@ static void P_SpawnPushers(void) } break; case 545: // current up - TAG_ITER_SECTORS(l->tag, s) + TAG_ITER_SECTORS(tag, s) Add_Pusher(p_upcurrent, l->dx, l->dy, NULL, s, -1, l->flags & ML_NOCLIMB, l->flags & ML_EFFECT4); break; case 546: // current down - TAG_ITER_SECTORS(l->tag, s) + TAG_ITER_SECTORS(tag, s) Add_Pusher(p_downcurrent, l->dx, l->dy, NULL, s, -1, l->flags & ML_NOCLIMB, l->flags & ML_EFFECT4); break; case 542: // wind up - TAG_ITER_SECTORS(l->tag, s) + TAG_ITER_SECTORS(tag, s) Add_Pusher(p_upwind, l->dx, l->dy, NULL, s, -1, l->flags & ML_NOCLIMB, l->flags & ML_EFFECT4); break; case 543: // wind down - TAG_ITER_SECTORS(l->tag, s) + TAG_ITER_SECTORS(tag, s) Add_Pusher(p_downwind, l->dx, l->dy, NULL, s, -1, l->flags & ML_NOCLIMB, l->flags & ML_EFFECT4); break; } + } } diff --git a/src/p_user.c b/src/p_user.c index c2f122ace..9fea83ec2 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -10629,6 +10629,7 @@ static void P_CalcPostImg(player_t *player) postimg_t *type; INT32 *param; fixed_t pviewheight; + size_t i; if (player->mo->eflags & MFE_VERTICALFLIP) pviewheight = player->mo->z + player->mo->height - player->viewheight; @@ -10653,28 +10654,45 @@ static void P_CalcPostImg(player_t *player) } // see if we are in heat (no, not THAT kind of heat...) - - if (Tag_FindLineSpecial(13, sector->tag) != -1) - *type = postimg_heat; - else if (sector->ffloors) + for (i = 0; i < sector->tags.count; i++) { - ffloor_t *rover; - fixed_t topheight; - fixed_t bottomheight; - - for (rover = sector->ffloors; rover; rover = rover->next) + if (Tag_FindLineSpecial(13, sector->tags.tags[i]) != -1) { - if (!(rover->flags & FF_EXISTS)) - continue; + *type = postimg_heat; + break; + } + else if (sector->ffloors) + { + ffloor_t *rover; + fixed_t topheight; + fixed_t bottomheight; + boolean gotres = false; - topheight = *rover->t_slope ? P_GetZAt(*rover->t_slope, player->mo->x, player->mo->y) : *rover->topheight; - bottomheight = *rover->b_slope ? P_GetZAt(*rover->b_slope, player->mo->x, player->mo->y) : *rover->bottomheight; + for (rover = sector->ffloors; rover; rover = rover->next) + { + size_t j; - if (pviewheight >= topheight || pviewheight <= bottomheight) - continue; + if (!(rover->flags & FF_EXISTS)) + continue; - if (Tag_FindLineSpecial(13, rover->master->frontsector->tag) != -1) - *type = postimg_heat; + topheight = *rover->t_slope ? P_GetZAt(*rover->t_slope, player->mo->x, player->mo->y) : *rover->topheight; + bottomheight = *rover->b_slope ? P_GetZAt(*rover->b_slope, player->mo->x, player->mo->y) : *rover->bottomheight; + + if (pviewheight >= topheight || pviewheight <= bottomheight) + continue; + + for (j = 0; j < rover->master->frontsector->tags.count; j++) + { + if (Tag_FindLineSpecial(13, rover->master->frontsector->tags.tags[j]) != -1) + { + *type = postimg_heat; + gotres = true; + break; + } + } + } + if (gotres) + break; } } @@ -10773,22 +10791,21 @@ static sector_t *P_GetMinecartSector(fixed_t x, fixed_t y, fixed_t z, fixed_t *n static INT32 P_GetMinecartSpecialLine(sector_t *sec) { INT32 line = -1; + size_t i; if (!sec) return line; - if (sec->tag != 0) - line = Tag_FindLineSpecial(16, sec->tag); + for (i = 0; i < sec->tags.count; i++) + if (sec->tags.tags[i] != 0) + line = Tag_FindLineSpecial(16, sec->tags.tags[i]); // Also try for lines facing the sector itself, with tag 0. + for (i = 0; i < sec->linecount; i++) { - UINT32 i; - for (i = 0; i < sec->linecount; i++) - { - line_t *li = sec->lines[i]; - if (li->tag == 0 && li->special == 16 && li->frontsector == sec) - line = li - lines; - } + line_t *li = sec->lines[i]; + if (Tag_Find(&li->tags, 0) && li->special == 16 && li->frontsector == sec) + line = li - lines; } return line; From 7904856e8e595692d0b5a1cf366b662277b056f5 Mon Sep 17 00:00:00 2001 From: Nev3r Date: Fri, 17 Apr 2020 22:26:04 +0200 Subject: [PATCH 0048/1080] Remove presumably the remaining old tag references in the gamelogic. --- src/p_ceilng.c | 10 ++++++---- src/p_enemy.c | 5 +++++ src/p_floor.c | 47 +++++++++++++++++++++++++++++------------------ src/p_inter.c | 1 + src/p_mobj.c | 10 +++++++--- src/p_spec.c | 48 ++++++++++++++++++++++++------------------------ 6 files changed, 72 insertions(+), 49 deletions(-) diff --git a/src/p_ceilng.c b/src/p_ceilng.c index a6e8e8cda..e80859189 100644 --- a/src/p_ceilng.c +++ b/src/p_ceilng.c @@ -398,9 +398,10 @@ INT32 EV_DoCeiling(line_t *line, ceiling_e type) INT32 secnum = -1; sector_t *sec; ceiling_t *ceiling; + mtag_t tag = Tag_FGet(&line->tags); TAG_ITER_C - TAG_ITER_SECTORS(line->tag, secnum) + TAG_ITER_SECTORS(tag, secnum) { sec = §ors[secnum]; @@ -598,7 +599,7 @@ INT32 EV_DoCeiling(line_t *line, ceiling_e type) } - ceiling->tag = sec->tag; + ceiling->tag = tag; ceiling->type = type; firstone = 0; } @@ -619,9 +620,10 @@ INT32 EV_DoCrush(line_t *line, ceiling_e type) INT32 secnum = -1; sector_t *sec; ceiling_t *ceiling; + mtag_t tag = Tag_FGet(&line->tags); TAG_ITER_C - TAG_ITER_SECTORS(line->tag, secnum) + TAG_ITER_SECTORS(tag, secnum) { sec = §ors[secnum]; @@ -676,7 +678,7 @@ INT32 EV_DoCrush(line_t *line, ceiling_e type) break; } - ceiling->tag = sec->tag; + ceiling->tag = tag; ceiling->type = type; } return rtn; diff --git a/src/p_enemy.c b/src/p_enemy.c index 8f96c1dee..a51d76cb0 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -3865,11 +3865,15 @@ void A_BossDeath(mobj_t *mo) else { // Bring the egg trap up to the surface + // Incredibly shitty code ahead junk.tag = LE_CAPSULE0; + Tag_FSet(&junk.tags, LE_CAPSULE0); EV_DoElevator(&junk, elevateHighest, false); junk.tag = LE_CAPSULE1; + Tag_FSet(&junk.tags, LE_CAPSULE1); EV_DoElevator(&junk, elevateUp, false); junk.tag = LE_CAPSULE2; + Tag_FSet(&junk.tags, LE_CAPSULE2); EV_DoElevator(&junk, elevateHighest, false); if (mapheaderinfo[gamemap-1]->muspostbossname[0] && @@ -3993,6 +3997,7 @@ bossjustdie: case MT_KOOPA: { junk.tag = LE_KOOPA; + Tag_FSet(&junk.tags, LE_KOOPA); EV_DoCeiling(&junk, raiseToHighest); return; } diff --git a/src/p_floor.c b/src/p_floor.c index bcb546a5c..91c264435 100644 --- a/src/p_floor.c +++ b/src/p_floor.c @@ -687,6 +687,7 @@ void T_BounceCheese(levelspecthink_t *bouncer) fixed_t floorheight; sector_t *actionsector; INT32 i; + mtag_t tag = Tag_FGet(&bouncer->sourceline->tags); TAG_ITER_C if (bouncer->sector->crumblestate == 4 || bouncer->sector->crumblestate == 1 @@ -702,7 +703,7 @@ void T_BounceCheese(levelspecthink_t *bouncer) } // You can use multiple target sectors, but at your own risk!!! - TAG_ITER_SECTORS(bouncer->sourceline->tag, i) + TAG_ITER_SECTORS(tag, i) { actionsector = §ors[i]; actionsector->moved = true; @@ -845,6 +846,7 @@ void T_StartCrumble(elevator_t *elevator) ffloor_t *rover; sector_t *sector; INT32 i; + mtag_t tag = Tag_FGet(&elevator->sourceline->tags); TAG_ITER_C // Once done, the no-return thinker just sits there, @@ -875,7 +877,7 @@ void T_StartCrumble(elevator_t *elevator) } else if (++elevator->distance == 0) // Reposition back to original spot { - TAG_ITER_SECTORS(elevator->sourceline->tag, i) + TAG_ITER_SECTORS(tag, i) { sector = §ors[i]; @@ -906,7 +908,7 @@ void T_StartCrumble(elevator_t *elevator) // Flash to indicate that the platform is about to return. if (elevator->distance > -224 && (leveltime % ((abs(elevator->distance)/8) + 1) == 0)) { - TAG_ITER_SECTORS(elevator->sourceline->tag, i) + TAG_ITER_SECTORS(tag, i) { sector = §ors[i]; @@ -1002,7 +1004,7 @@ void T_StartCrumble(elevator_t *elevator) P_RemoveThinker(&elevator->thinker); } - TAG_ITER_SECTORS(elevator->sourceline->tag, i) + TAG_ITER_SECTORS(tag, i) { sector = §ors[i]; sector->moved = true; @@ -1456,9 +1458,10 @@ void T_NoEnemiesSector(levelspecthink_t *nobaddies) msecnode_t *node; mobj_t *thing; boolean FOFsector = false; + mtag_t tag = Tag_FGet(&nobaddies->sourceline->tags); TAG_ITER_C - TAG_ITER_SECTORS(nobaddies->sourceline->tag, secnum) + TAG_ITER_SECTORS(tag, secnum) { sec = §ors[secnum]; @@ -1468,6 +1471,7 @@ void T_NoEnemiesSector(levelspecthink_t *nobaddies) for (i = 0; i < sec->linecount; i++) { INT32 targetsecnum = -1; + mtag_t tag2 = Tag_FGet(&sec->lines[i]->tags); TAG_ITER_C if (sec->lines[i]->special < 100 || sec->lines[i]->special >= 300) @@ -1475,7 +1479,7 @@ void T_NoEnemiesSector(levelspecthink_t *nobaddies) FOFsector = true; - TAG_ITER_SECTORS(sec->lines[i]->tag, targetsecnum) + TAG_ITER_SECTORS(tag2, targetsecnum) { targetsec = §ors[targetsecnum]; @@ -1513,7 +1517,7 @@ void T_NoEnemiesSector(levelspecthink_t *nobaddies) } } - CONS_Debug(DBG_GAMELOGIC, "Running no-more-enemies exec with tag of %d\n", nobaddies->sourceline->tag); + CONS_Debug(DBG_GAMELOGIC, "Running no-more-enemies exec with tag of %d\n", tag); // No enemies found, run the linedef exec and terminate this thinker P_RunTriggerLinedef(nobaddies->sourceline, NULL, NULL); @@ -1601,6 +1605,7 @@ void T_EachTimeThinker(levelspecthink_t *eachtime) fixed_t bottomheight, topheight; msecnode_t *node; ffloor_t *rover; + mtag_t tag = Tag_FGet(&eachtime->sourceline->tags); TAG_ITER_C for (i = 0; i < MAXPLAYERS; i++) @@ -1622,7 +1627,7 @@ void T_EachTimeThinker(levelspecthink_t *eachtime) playersOnArea[i] = false; } - TAG_ITER_SECTORS(eachtime->sourceline->tag, secnum) + TAG_ITER_SECTORS(tag, secnum) { sec = §ors[secnum]; @@ -1639,6 +1644,7 @@ void T_EachTimeThinker(levelspecthink_t *eachtime) for (i = 0; i < sec->linecount; i++) { INT32 targetsecnum = -1; + mtag_t tag2 = Tag_FGet(&sec->lines[i]->tags); TAG_ITER_C if (sec->lines[i]->special < 100 || sec->lines[i]->special >= 300) @@ -1646,7 +1652,7 @@ void T_EachTimeThinker(levelspecthink_t *eachtime) FOFsector = true; - TAG_ITER_SECTORS(sec->lines[i]->tag, targetsecnum) + TAG_ITER_SECTORS(tag2, targetsecnum) { targetsec = §ors[targetsecnum]; @@ -1828,7 +1834,7 @@ void T_EachTimeThinker(levelspecthink_t *eachtime) } } - CONS_Debug(DBG_GAMELOGIC, "Trying to activate each time executor with tag %d\n", eachtime->sourceline->tag); + CONS_Debug(DBG_GAMELOGIC, "Trying to activate each time executor with tag %d\n", tag); // 03/08/14 -Monster Iestyn // No more stupid hacks involving changing eachtime->sourceline's tag or special or whatever! @@ -1858,12 +1864,13 @@ void T_RaiseSector(levelspecthink_t *raise) boolean playeronme = false, active = false; fixed_t ceilingdestination, floordestination; result_e res = 0; + mtag_t tag = Tag_FGet(&raise->sourceline->tags); TAG_ITER_C if (raise->sector->crumblestate >= 3 || raise->sector->ceilingdata) return; - TAG_ITER_SECTORS(raise->sourceline->tag, i) + TAG_ITER_SECTORS(tag, i) { sector = §ors[i]; @@ -2056,7 +2063,7 @@ void T_RaiseSector(levelspecthink_t *raise) raise->sector->ceilspeed = 42; raise->sector->floorspeed = raise->vars[3]*raise->vars[8]; - TAG_ITER_SECTORS(raise->sourceline->tag, i) + TAG_ITER_SECTORS(tag, i) P_RecalcPrecipInSector(§ors[i]); } @@ -2173,9 +2180,10 @@ INT32 EV_DoFloor(line_t *line, floor_e floortype) INT32 secnum = -1; sector_t *sec; floormove_t *dofloor; + mtag_t tag = Tag_FGet(&line->tags); TAG_ITER_C - TAG_ITER_SECTORS(line->tag, secnum) + TAG_ITER_SECTORS(tag, secnum) { sec = §ors[secnum]; @@ -2393,10 +2401,11 @@ INT32 EV_DoElevator(line_t *line, elevator_e elevtype, boolean customspeed) INT32 rtn = 0; sector_t *sec; elevator_t *elevator; + mtag_t tag = Tag_FGet(&line->tags); TAG_ITER_C // act on all sectors with the same tag as the triggering linedef - TAG_ITER_SECTORS(line->tag, secnum) + TAG_ITER_SECTORS(tag, secnum) { sec = §ors[secnum]; @@ -2519,6 +2528,7 @@ void EV_CrumbleChain(sector_t *sec, ffloor_t *rover) INT16 flags; sector_t *controlsec = rover->master->frontsector; + mtag_t tag = Tag_FGet(&controlsec->tags); if (sec == NULL) { @@ -2547,9 +2557,9 @@ void EV_CrumbleChain(sector_t *sec, ffloor_t *rover) lifetime = 3*TICRATE; flags = 0; - if (controlsec->tag != 0) + if (tag != 0) { - INT32 tagline = Tag_FindLineSpecial(14, controlsec->tag); + INT32 tagline = Tag_FindLineSpecial(14, tag); if (tagline != -1) { if (sides[lines[tagline].sidenum[0]].toptexture) @@ -2725,6 +2735,7 @@ INT32 EV_StartCrumble(sector_t *sec, ffloor_t *rover, boolean floating, elevator_t *elevator; sector_t *foundsec; INT32 i; + mtag_t tag = Tag_FGet(&rover->master->tags); TAG_ITER_C // If floor is already activated, skip it @@ -2778,7 +2789,7 @@ INT32 EV_StartCrumble(sector_t *sec, ffloor_t *rover, boolean floating, elevator->sector->crumblestate = 2; - TAG_ITER_SECTORS(elevator->sourceline->tag, i) + TAG_ITER_SECTORS(tag, i) { foundsec = §ors[i]; @@ -2822,7 +2833,7 @@ INT32 EV_MarioBlock(ffloor_t *rover, sector_t *sector, mobj_t *puncher) // Set up the fields block->sector = roversec; - block->vars[0] = sector->tag; // actionsector + block->vars[0] = Tag_FGet(§or->tags); // actionsector block->vars[1] = 4*FRACUNIT; // speed block->vars[2] = 1; // Up // direction block->vars[3] = block->sector->floorheight; // floorwasheight diff --git a/src/p_inter.c b/src/p_inter.c index 30e3c31b1..0cdbe57b2 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -1377,6 +1377,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) return; junk.tag = LE_AXE; + Tag_FSet(&junk.tags, LE_AXE); EV_DoElevator(&junk, bridgeFall, false); // scan the remaining thinkers to find koopa diff --git a/src/p_mobj.c b/src/p_mobj.c index a65d3bbf3..180376727 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -3548,16 +3548,19 @@ static boolean P_CameraCheckHeat(camera_t *thiscam) { sector_t *sector; fixed_t halfheight = thiscam->z + (thiscam->height >> 1); + size_t i; // see if we are in water sector = thiscam->subsector->sector; - if (Tag_FindLineSpecial(13, sector->tag) != -1) - return true; + for (i = 0; i < sector->tags.count; i++) + if (Tag_FindLineSpecial(13, sector->tags.tags[i]) != -1) + return true; if (sector->ffloors) { ffloor_t *rover; + size_t j; for (rover = sector->ffloors; rover; rover = rover->next) { @@ -3573,7 +3576,8 @@ static boolean P_CameraCheckHeat(camera_t *thiscam) *rover->bottomheight)) continue; - if (Tag_FindLineSpecial(13, rover->master->frontsector->tag) != -1) + for (j = 0; j < rover->master->frontsector->tags.count; j++) + if (Tag_FindLineSpecial(13, rover->master->frontsector->tags.tags[j]) != -1) return true; } } diff --git a/src/p_spec.c b/src/p_spec.c index 6c47e24c1..a0c46f3ac 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -1000,7 +1000,7 @@ static boolean PolyDoor(line_t *line) { polydoordata_t pdd; - pdd.polyObjNum = line->tag; // polyobject id + pdd.polyObjNum = Tag_FGet(&line->tags); // polyobject id switch(line->special) { @@ -1041,7 +1041,7 @@ static boolean PolyMove(line_t *line) { polymovedata_t pmd; - pmd.polyObjNum = line->tag; + pmd.polyObjNum = Tag_FGet(&line->tags); pmd.speed = sides[line->sidenum[0]].textureoffset / 8; pmd.angle = R_PointToAngle2(line->v1->x, line->v1->y, line->v2->x, line->v2->y); pmd.distance = sides[line->sidenum[0]].rowoffset; @@ -1059,7 +1059,7 @@ static boolean PolyMove(line_t *line) // static void PolyInvisible(line_t *line) { - INT32 polyObjNum = line->tag; + INT32 polyObjNum = Tag_FGet(&line->tags); polyobj_t *po; if (!(po = Polyobj_GetForNum(polyObjNum))) @@ -1087,7 +1087,7 @@ static void PolyInvisible(line_t *line) // static void PolyVisible(line_t *line) { - INT32 polyObjNum = line->tag; + INT32 polyObjNum = Tag_FGet(&line->tags); polyobj_t *po; if (!(po = Polyobj_GetForNum(polyObjNum))) @@ -1115,7 +1115,7 @@ static void PolyVisible(line_t *line) // static void PolyTranslucency(line_t *line) { - INT32 polyObjNum = line->tag; + INT32 polyObjNum = Tag_FGet(&line->tags); polyobj_t *po; if (!(po = Polyobj_GetForNum(polyObjNum))) @@ -1156,7 +1156,7 @@ static void PolyTranslucency(line_t *line) // static boolean PolyFade(line_t *line) { - INT32 polyObjNum = line->tag; + INT32 polyObjNum = Tag_FGet(&line->tags); polyobj_t *po; polyfadedata_t pfd; @@ -1227,7 +1227,7 @@ static boolean PolyWaypoint(line_t *line) { polywaypointdata_t pwd; - pwd.polyObjNum = line->tag; + pwd.polyObjNum = Tag_FGet(&line->tags); pwd.speed = sides[line->sidenum[0]].textureoffset / 8; pwd.sequence = sides[line->sidenum[0]].rowoffset >> FRACBITS; // Sequence # pwd.reverse = (line->flags & ML_EFFECT1) == ML_EFFECT1; // Reverse? @@ -1247,7 +1247,7 @@ static boolean PolyRotate(line_t *line) { polyrotdata_t prd; - prd.polyObjNum = line->tag; + prd.polyObjNum = Tag_FGet(&line->tags); prd.speed = sides[line->sidenum[0]].textureoffset >> FRACBITS; // angular speed prd.distance = sides[line->sidenum[0]].rowoffset >> FRACBITS; // angular distance @@ -1276,7 +1276,7 @@ static boolean PolyDisplace(line_t *line) { polydisplacedata_t pdd; - pdd.polyObjNum = line->tag; + pdd.polyObjNum = Tag_FGet(&line->tags); pdd.controlSector = line->frontsector; pdd.dx = line->dx>>8; @@ -1293,7 +1293,7 @@ static boolean PolyRotDisplace(line_t *line) polyrotdisplacedata_t pdd; fixed_t anginter, distinter; - pdd.polyObjNum = line->tag; + pdd.polyObjNum = Tag_FGet(&line->tags); pdd.controlSector = line->frontsector; // Rotate 'anginter' interval for each 'distinter' interval from the control sector. @@ -2412,12 +2412,12 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) // (formerly "Change calling sectors' tag", but behavior was changed) { TAG_ITER_SECTORS(tag, secnum) - P_ChangeSectorTag(secnum,(INT16)(sides[line->sidenum[0]].textureoffset>>FRACBITS)); + Tag_SectorFSet(secnum,(INT16)(sides[line->sidenum[0]].textureoffset>>FRACBITS)); break; } case 410: // Change front sector's tag - P_ChangeSectorTag((UINT32)(line->frontsector - sectors), (INT16)(sides[line->sidenum[0]].textureoffset>>FRACBITS)); + Tag_SectorFSet((UINT32)(line->frontsector - sectors), (INT16)(sides[line->sidenum[0]].textureoffset>>FRACBITS)); break; case 411: // Stop floor/ceiling movement in tagged sector(s) @@ -2626,7 +2626,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) if (!camobj) continue; - if (foundit || (camobj->subsector->sector->tag == tag)) + if (foundit || Tag_Find(&camobj->subsector->sector->tags, tag)) { foundit = true; break; @@ -2635,7 +2635,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) // Only trigger if mobj is touching the tag for(rover = camobj->subsector->sector->ffloors; rover; rover = rover->next) { - if (rover->master->frontsector->tag != tag) + if (!Tag_Find(&rover->master->frontsector->tags, tag)) continue; if (camobj->z > P_GetSpecialTopZ(camobj, sectors + rover->secnum, camobj->subsector->sector)) @@ -3092,7 +3092,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) for (rover = sec->ffloors; rover; rover = rover->next) { - if (rover->master->frontsector->tag == foftag) + if (Tag_Find(&rover->master->frontsector->tags, foftag)) { foundrover = true; @@ -3277,7 +3277,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) for (rover = sec->ffloors; rover; rover = rover->next) { - if (rover->master->frontsector->tag == foftag) + if (Tag_Find(&rover->master->frontsector->tags, foftag)) { foundrover = true; @@ -3335,7 +3335,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) for (rover = sec->ffloors; rover; rover = rover->next) { - if (rover->master->frontsector->tag == foftag) + if (Tag_Find(&rover->master->frontsector->tags, foftag)) { foundrover = true; @@ -3520,7 +3520,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) for (rover = sec->ffloors; rover; rover = rover->next) { - if (rover->master->frontsector->tag == foftag) + if (Tag_Find(&rover->master->frontsector->tags, foftag)) { foundrover = true; @@ -3584,7 +3584,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) for (rover = sec->ffloors; rover; rover = rover->next) { - if (rover->master->frontsector->tag == foftag) + if (Tag_Find(&rover->master->frontsector->tags, foftag)) { foundrover = true; @@ -3669,7 +3669,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) for (rover = sec->ffloors; rover; rover = rover->next) { - if (rover->master->frontsector->tag == foftag) + if (Tag_Find(&rover->master->frontsector->tags, foftag)) { foundrover = true; @@ -5774,7 +5774,7 @@ static ffloor_t *P_AddFakeFloor(sector_t *sec, sector_t *sec2, line_t *master, f if ((flags & FF_FLOATBOB)) { - P_AddFloatThinker(sec2, sec->tag, master); + P_AddFloatThinker(sec2, Tag_FGet(&master->tags), master); CheckForFloatBob = true; } @@ -6011,7 +6011,7 @@ static inline void P_AddThwompThinker(sector_t *sec, sector_t *actionsector, lin // set up the fields according to the type of elevator action thwomp->sector = sec; - thwomp->vars[0] = actionsector->tag; + thwomp->vars[0] = Tag_FGet(&sourceline->tags); thwomp->floorwasheight = thwomp->sector->floorheight; thwomp->ceilingwasheight = thwomp->sector->ceilingheight; thwomp->direction = 0; @@ -6572,11 +6572,11 @@ void P_SpawnSpecials(boolean fromnetsave) Add_MasterDisappearer(abs(lines[i].dx>>FRACBITS), abs(lines[i].dy>>FRACBITS), abs(sides[lines[i].sidenum[0]].sector->floorheight>>FRACBITS), (INT32)(sectors[s].lines[j]-lines), (INT32)i); } else // Find FOFs by effect sector tag { - TAG_ITER_LINES((lines + i)->tag, s) + TAG_ITER_LINES(tag, s) { if ((size_t)s == i) continue; - if (sides[lines[s].sidenum[0]].sector->tag == sides[lines[i].sidenum[0]].sector->tag) + if (Tag_Find(&sides[lines[s].sidenum[0]].sector->tags, Tag_FGet(&sides[lines[i].sidenum[0]].sector->tags))) Add_MasterDisappearer(abs(lines[i].dx>>FRACBITS), abs(lines[i].dy>>FRACBITS), abs(sides[lines[i].sidenum[0]].sector->floorheight>>FRACBITS), s, (INT32)i); } } From ae07b7c96c92c15fa5658011024f96e59d046d66 Mon Sep 17 00:00:00 2001 From: Nev3r Date: Fri, 17 Apr 2020 22:29:26 +0200 Subject: [PATCH 0049/1080] Netsynch the sector local taglists. --- src/p_saveg.c | 24 ++++++++++++++++++++---- src/p_setup.c | 11 ++++++++--- 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index 4449a9d2b..ebdc251e6 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -798,7 +798,7 @@ static boolean P_AreStringArgsEqual(const line_t *li, const line_t *spawnli) // static void P_NetArchiveWorld(void) { - size_t i; + size_t i, j; INT32 statsec = 0, statline = 0; const line_t *li = lines; const line_t *spawnli = spawnlines; @@ -849,7 +849,7 @@ static void P_NetArchiveWorld(void) if (ss->ceilingpic_angle != spawnss->ceilingpic_angle) diff2 |= SD_CEILANG; - if (ss->tag != spawnss->tag) + if (!Tag_Compare(&ss->tags, &spawnss->tags)) diff2 |= SD_TAG; if (ss->nexttag != spawnss->nexttag || ss->firsttag != spawnss->firsttag) diff3 |= SD_TAGLIST; @@ -912,7 +912,12 @@ static void P_NetArchiveWorld(void) WRITEANGLE(put, ss->floorpic_angle); if (diff2 & SD_CEILANG) WRITEANGLE(put, ss->ceilingpic_angle); - if (diff2 & SD_TAG) // save only the tag + if (diff2 & SD_TAG) + { + WRITEUINT32(put, ss->tags.count); + for (j = 0; j < ss->tags.count; j++) + WRITEINT16(put, ss->tags.tags[j]); + } WRITEINT16(put, ss->tag); if (diff3 & SD_TAGLIST) // save both firsttag and nexttag { // either of these could be changed even if tag isn't @@ -1076,7 +1081,7 @@ static void P_NetArchiveWorld(void) // static void P_NetUnArchiveWorld(void) { - UINT16 i; + UINT16 i, j; line_t *li; side_t *si; UINT8 *get; @@ -1150,6 +1155,17 @@ static void P_NetUnArchiveWorld(void) if (diff2 & SD_CEILANG) sectors[i].ceilingpic_angle = READANGLE(get); if (diff2 & SD_TAG) + { + size_t ncount = READUINT32(get); + if (ncount != sectors[i].tags.count) + { + sectors[i].tags.count = ncount; + sectors[i].tags.tags = Z_Realloc(sectors[i].tags.tags, ncount*sizeof(mtag_t), PU_LEVEL, NULL); + } + + for (j = 0; j < ncount; j++) + sectors[i].tags.tags[j] = READINT16(get); + } sectors[i].tag = READINT16(get); // DON'T use P_ChangeSectorTag if (diff3 & SD_TAGLIST) { diff --git a/src/p_setup.c b/src/p_setup.c index 2cbc2ceae..d92eb929c 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -936,7 +936,7 @@ static void P_LoadSectors(UINT8 *data) ss->lightlevel = SHORT(ms->lightlevel); ss->special = SHORT(ms->special); ss->tag = SHORT(ms->tag); - Tag_FSet(&ss->tags, ss->tag); + Tag_FSet(&ss->tags, SHORT(ms->tag)); ss->floor_xoffs = ss->floor_yoffs = 0; ss->ceiling_xoffs = ss->ceiling_yoffs = 0; @@ -1051,7 +1051,7 @@ static void P_LoadLinedefs(UINT8 *data) ld->flags = SHORT(mld->flags); ld->special = SHORT(mld->special); ld->tag = SHORT(mld->tag); - Tag_FSet(&ld->tags, ld->tag); + Tag_FSet(&ld->tags, SHORT(mld->tag)); memset(ld->args, 0, NUMLINEARGS*sizeof(*ld->args)); memset(ld->stringargs, 0x00, NUMLINESTRINGARGS*sizeof(*ld->stringargs)); ld->alpha = FRACUNIT; @@ -1282,7 +1282,7 @@ static void P_LoadThings(UINT8 *data) mt->options = READUINT16(data); mt->extrainfo = (UINT8)(mt->type >> 12); mt->tag = 0; - Tag_FSet(&mt->tags, mt->tag); + Tag_FSet(&mt->tags, 0); mt->type &= 4095; @@ -2921,6 +2921,7 @@ static boolean P_LoadMapFromFile(void) { virtres_t *virt = vres_GetMap(lastloadedmaplumpnum); virtlump_t *textmap = vres_Find(virt, "TEXTMAP"); + size_t i; udmf = textmap != NULL; if (!P_LoadMapData(virt)) @@ -2942,6 +2943,10 @@ static boolean P_LoadMapFromFile(void) memcpy(spawnlines, lines, numlines * sizeof(*lines)); memcpy(spawnsides, sides, numsides * sizeof(*sides)); + for (i = 0; i < numsectors; i++) + if (sectors[i].tags.count) + spawnsectors[i].tags.tags = memcpy(Z_Malloc(sectors[i].tags.count*sizeof(mtag_t), PU_LEVEL, NULL), sectors[i].tags.tags, sectors[i].tags.count*sizeof(mtag_t)); + P_MakeMapMD5(virt, &mapmd5); vres_Free(virt); From 6c12e6701dc9ad8e0aaf0bdd19d3c079670cefd5 Mon Sep 17 00:00:00 2001 From: Nev3r Date: Fri, 17 Apr 2020 22:30:16 +0200 Subject: [PATCH 0050/1080] Make the Lua interface return/set the first tags from the local taglists. --- src/lua_maplib.c | 6 +++--- src/lua_mobjlib.c | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/lua_maplib.c b/src/lua_maplib.c index a3bdd9aa8..a6b45e406 100644 --- a/src/lua_maplib.c +++ b/src/lua_maplib.c @@ -537,7 +537,7 @@ static int sector_get(lua_State *L) lua_pushinteger(L, sector->special); return 1; case sector_tag: - lua_pushinteger(L, sector->tag); + lua_pushinteger(L, Tag_FGet(§or->tags)); return 1; case sector_thinglist: // thinglist lua_pushcfunction(L, lib_iterateSectorThinglist); @@ -636,7 +636,7 @@ static int sector_set(lua_State *L) sector->special = (INT16)luaL_checkinteger(L, 3); break; case sector_tag: - P_ChangeSectorTag((UINT32)(sector - sectors), (INT16)luaL_checkinteger(L, 3)); + Tag_SectorFSet((UINT32)(sector - sectors), (INT16)luaL_checkinteger(L, 3)); break; } return 0; @@ -770,7 +770,7 @@ static int line_get(lua_State *L) lua_pushinteger(L, line->special); return 1; case line_tag: - lua_pushinteger(L, line->tag); + lua_pushinteger(L, Tag_FGet(&line->tags)); return 1; case line_args: LUA_PushUserdata(L, line->args, META_LINEARGS); diff --git a/src/lua_mobjlib.c b/src/lua_mobjlib.c index 8d2aad91e..127ba607c 100644 --- a/src/lua_mobjlib.c +++ b/src/lua_mobjlib.c @@ -780,7 +780,7 @@ static int mapthing_get(lua_State *L) else if(fastcmp(field,"extrainfo")) number = mt->extrainfo; else if(fastcmp(field,"tag")) - number = mt->tag; + number = Tag_FGet(&mt->tags); else if(fastcmp(field,"mobj")) { LUA_PushUserdata(L, mt->mobj, META_MOBJ); return 1; @@ -824,7 +824,7 @@ static int mapthing_set(lua_State *L) mt->extrainfo = (UINT8)extrainfo; } else if (fastcmp(field,"tag")) - mt->tag = (INT16)luaL_checkinteger(L, 3); + Tag_FSet(&mt->tags, (INT16)luaL_checkinteger(L, 3)); else if(fastcmp(field,"mobj")) mt->mobj = *((mobj_t **)luaL_checkudata(L, 3, META_MOBJ)); else From 0c2fb80ec90154cf490e845397e1bc34e0b1bc39 Mon Sep 17 00:00:00 2001 From: Nev3r Date: Fri, 17 Apr 2020 22:41:04 +0200 Subject: [PATCH 0051/1080] Fuck. --- src/p_saveg.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index ebdc251e6..8e3a4b037 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -918,7 +918,6 @@ static void P_NetArchiveWorld(void) for (j = 0; j < ss->tags.count; j++) WRITEINT16(put, ss->tags.tags[j]); } - WRITEINT16(put, ss->tag); if (diff3 & SD_TAGLIST) // save both firsttag and nexttag { // either of these could be changed even if tag isn't WRITEINT32(put, ss->firsttag); From e2a98a15911d3d5ccde49b1bbafd1c1c734da0de Mon Sep 17 00:00:00 2001 From: Nev3r Date: Fri, 17 Apr 2020 23:02:16 +0200 Subject: [PATCH 0052/1080] Double fuck. --- src/p_saveg.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index 8e3a4b037..e5241ec8a 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -1165,7 +1165,6 @@ static void P_NetUnArchiveWorld(void) for (j = 0; j < ncount; j++) sectors[i].tags.tags[j] = READINT16(get); } - sectors[i].tag = READINT16(get); // DON'T use P_ChangeSectorTag if (diff3 & SD_TAGLIST) { sectors[i].firsttag = READINT32(get); From 9eb17e4104237b15b095d81eabb0455a0f1ad917 Mon Sep 17 00:00:00 2001 From: Nev3r Date: Fri, 17 Apr 2020 23:30:07 +0200 Subject: [PATCH 0053/1080] Remove P_ChangeSectorTag(). --- src/p_spec.c | 61 ---------------------------------------------------- src/p_spec.h | 1 - 2 files changed, 62 deletions(-) diff --git a/src/p_spec.c b/src/p_spec.c index a0c46f3ac..5f5510372 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -1315,67 +1315,6 @@ static boolean PolyRotDisplace(line_t *line) #endif // ifdef POLYOBJECTS -/** Changes a sector's tag. - * Used by the linedef executor tag changer and by crumblers. - * - * \param sector Sector whose tag will be changed. - * \param newtag New tag number for this sector. - * \sa P_InitTagLists, P_FindSectorFromTag - * \author Graue - */ -void P_ChangeSectorTag(UINT32 sector, INT16 newtag) -{ - INT16 oldtag; - INT32 i; - - I_Assert(sector < numsectors); - - if ((oldtag = sectors[sector].tag) == newtag) - return; - - // first you have to remove it from the old tag's taglist - i = sectors[(unsigned)oldtag % numsectors].firsttag; - - if (i == -1) // shouldn't happen - I_Error("Corrupt tag list for sector %u\n", sector); - else if ((UINT32)i == sector) - sectors[(unsigned)oldtag % numsectors].firsttag = sectors[sector].nexttag; - else - { - while (sectors[i].nexttag != -1 && (UINT32)sectors[i].nexttag < sector ) - i = sectors[i].nexttag; - - sectors[i].nexttag = sectors[sector].nexttag; - } - - sectors[sector].tag = newtag; - - // now add it to the new tag's taglist - if ((UINT32)sectors[(unsigned)newtag % numsectors].firsttag > sector) - { - sectors[sector].nexttag = sectors[(unsigned)newtag % numsectors].firsttag; - sectors[(unsigned)newtag % numsectors].firsttag = sector; - } - else - { - i = sectors[(unsigned)newtag % numsectors].firsttag; - - if (i == -1) - { - sectors[(unsigned)newtag % numsectors].firsttag = sector; - sectors[sector].nexttag = -1; - } - else - { - while (sectors[i].nexttag != -1 && (UINT32)sectors[i].nexttag < sector ) - i = sectors[i].nexttag; - - sectors[sector].nexttag = sectors[i].nexttag; - sectors[i].nexttag = sector; - } - } -} - // // P_RunNightserizeExecutors // diff --git a/src/p_spec.h b/src/p_spec.h index 1e9ff1c41..7c290c6f3 100644 --- a/src/p_spec.h +++ b/src/p_spec.h @@ -64,7 +64,6 @@ void P_SwitchWeather(INT32 weathernum); boolean P_RunTriggerLinedef(line_t *triggerline, mobj_t *actor, sector_t *caller); void P_LinedefExecute(INT16 tag, mobj_t *actor, sector_t *caller); -void P_ChangeSectorTag(UINT32 sector, INT16 newtag); void P_RunNightserizeExecutors(mobj_t *actor); void P_RunDeNightserizeExecutors(mobj_t *actor); void P_RunNightsLapExecutors(mobj_t *actor); From 7c11091c40d86479ef97836fddb2628505acd618 Mon Sep 17 00:00:00 2001 From: Nev3r Date: Fri, 17 Apr 2020 23:30:47 +0200 Subject: [PATCH 0054/1080] Remove old tag list netgame packing/unpacking. --- src/p_saveg.c | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index e5241ec8a..4fdc3d488 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -851,8 +851,6 @@ static void P_NetArchiveWorld(void) if (!Tag_Compare(&ss->tags, &spawnss->tags)) diff2 |= SD_TAG; - if (ss->nexttag != spawnss->nexttag || ss->firsttag != spawnss->firsttag) - diff3 |= SD_TAGLIST; if (ss->extra_colormap != spawnss->extra_colormap) diff3 |= SD_COLORMAP; @@ -918,11 +916,6 @@ static void P_NetArchiveWorld(void) for (j = 0; j < ss->tags.count; j++) WRITEINT16(put, ss->tags.tags[j]); } - if (diff3 & SD_TAGLIST) // save both firsttag and nexttag - { // either of these could be changed even if tag isn't - WRITEINT32(put, ss->firsttag); - WRITEINT32(put, ss->nexttag); - } if (diff3 & SD_COLORMAP) WRITEUINT32(put, CheckAddNetColormapToList(ss->extra_colormap)); @@ -1165,11 +1158,6 @@ static void P_NetUnArchiveWorld(void) for (j = 0; j < ncount; j++) sectors[i].tags.tags[j] = READINT16(get); } - if (diff3 & SD_TAGLIST) - { - sectors[i].firsttag = READINT32(get); - sectors[i].nexttag = READINT32(get); - } if (diff3 & SD_COLORMAP) sectors[i].extra_colormap = GetNetColormapFromList(READUINT32(get)); From 38c665fa79f9a31b148d4b30eeeb2c1308bfbcf1 Mon Sep 17 00:00:00 2001 From: Nev3r Date: Fri, 17 Apr 2020 23:31:08 +0200 Subject: [PATCH 0055/1080] Remove old taglist access from Lua. --- src/lua_maplib.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/lua_maplib.c b/src/lua_maplib.c index a6b45e406..a8d445a6f 100644 --- a/src/lua_maplib.c +++ b/src/lua_maplib.c @@ -94,8 +94,6 @@ enum line_e { line_slopetype, line_frontsector, line_backsector, - line_firsttag, - line_nexttag, line_text, line_callcount }; @@ -118,8 +116,6 @@ static const char *const line_opt[] = { "slopetype", "frontsector", "backsector", - "firsttag", - "nexttag", "text", "callcount", NULL}; @@ -815,12 +811,6 @@ static int line_get(lua_State *L) case line_backsector: LUA_PushUserdata(L, line->backsector, META_SECTOR); return 1; - case line_firsttag: - lua_pushinteger(L, line->firsttag); - return 1; - case line_nexttag: - lua_pushinteger(L, line->nexttag); - return 1; case line_text: lua_pushstring(L, line->text); return 1; From d775a42e93a274fd054aaf07991381aec1902fc6 Mon Sep 17 00:00:00 2001 From: Nev3r Date: Fri, 17 Apr 2020 23:32:24 +0200 Subject: [PATCH 0056/1080] Rewrote a bit of the boss 4 code, which still requires working dynamic global tag lists. --- src/p_mobj.c | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index 180376727..9cfc15113 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -4622,16 +4622,18 @@ static boolean P_Boss4MoveCage(mobj_t *mobj, fixed_t delta) const UINT16 tag = 65534 + (mobj->spawnpoint ? mobj->spawnpoint->extrainfo*LE_PARAMWIDTH : 0); INT32 snum; sector_t *sector; - for (snum = sectors[tag%numsectors].firsttag; snum != -1; snum = sector->nexttag) + boolean gotcage = false; + TAG_ITER_C + + TAG_ITER_SECTORS(tag, snum) { sector = §ors[snum]; - if (!Tag_Find(§or->tags, tag)) - continue; sector->floorheight += delta; sector->ceilingheight += delta; P_CheckSector(sector, true); + gotcage = true; } - return sectors[tag%numsectors].firsttag != -1; + return gotcage; } // Move Boss4's arms to angle @@ -4703,22 +4705,15 @@ static void P_Boss4PinchSpikeballs(mobj_t *mobj, angle_t angle, fixed_t dz) static void P_Boss4DestroyCage(mobj_t *mobj) { const UINT16 tag = 65534 + (mobj->spawnpoint ? mobj->spawnpoint->extrainfo*LE_PARAMWIDTH : 0); - INT32 snum, next; + INT32 snum; size_t a; sector_t *sector, *rsec; ffloor_t *rover; + TAG_ITER_C - // This will be the final iteration of sector tag. - // We'll destroy the tag list as we go. - next = sectors[tag%numsectors].firsttag; - sectors[tag%numsectors].firsttag = -1; - - for (snum = next; snum != -1; snum = next) + TAG_ITER_SECTORS(tag, snum) { sector = §ors[snum]; - - next = sector->nexttag; - sector->nexttag = -1; if (!Tag_Find(§or->tags, tag)) continue; Tag_SectorFSet(sector - sectors, 0); From e87ad0fb384ea27a80be3da403ce988235a204e9 Mon Sep 17 00:00:00 2001 From: Nev3r Date: Sat, 18 Apr 2020 00:05:55 +0200 Subject: [PATCH 0057/1080] Delete old taglists. --- src/p_setup.c | 3 --- src/p_spec.c | 16 ---------------- src/r_defs.h | 2 -- 3 files changed, 21 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index d92eb929c..baa71c6b3 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -852,8 +852,6 @@ static void P_LoadVertices(UINT8 *data) static void P_InitializeSector(sector_t *ss) { - ss->nexttag = ss->firsttag = -1; - memset(&ss->soundorg, 0, sizeof(ss->soundorg)); ss->validcount = 0; @@ -976,7 +974,6 @@ static void P_InitializeLinedef(line_t *ld) #ifdef WALLSPLATS ld->splats = NULL; #endif - ld->firsttag = ld->nexttag = -1; #ifdef POLYOBJECTS ld->polyobj = NULL; #endif diff --git a/src/p_spec.c b/src/p_spec.c index 5f5510372..81a5e0e49 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -1383,22 +1383,6 @@ void P_RunNightsCapsuleTouchExecutors(mobj_t *actor, boolean entering, boolean e */ static inline void P_InitTagLists(void) { - register size_t i; - - for (i = numsectors - 1; i != (size_t)-1; i--) - { - size_t j = (unsigned)sectors[i].tag % numsectors; - sectors[i].nexttag = sectors[j].firsttag; - sectors[j].firsttag = (INT32)i; - } - - for (i = numlines - 1; i != (size_t)-1; i--) - { - size_t j = (unsigned)lines[i].tag % numlines; - lines[i].nexttag = lines[j].firsttag; - lines[j].firsttag = (INT32)i; - } - Taglist_InitGlobalTables(); } diff --git a/src/r_defs.h b/src/r_defs.h index 6dc9cf66e..41d141ce8 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -293,7 +293,6 @@ typedef struct sector_s INT16 special; UINT16 tag; taglist_t tags; - INT32 nexttag, firsttag; // for fast tag searches // origin for any sounds played by the sector // also considered the center for e.g. Mario blocks @@ -433,7 +432,6 @@ typedef struct line_s #if 1//#ifdef WALLSPLATS void *splats; // wallsplat_t list #endif - INT32 firsttag, nexttag; // improves searches for tags. #ifdef POLYOBJECTS polyobj_t *polyobj; // Belongs to a polyobject? #endif From aa0d76f8faf072c4c07c8bb209210bad2708ff9c Mon Sep 17 00:00:00 2001 From: Nev3r Date: Sat, 18 Apr 2020 00:23:24 +0200 Subject: [PATCH 0058/1080] Delete tags. --- src/doomdata.h | 1 - src/p_enemy.c | 4 ---- src/p_inter.c | 1 - src/p_setup.c | 21 +++------------------ src/p_spec.c | 5 +---- src/r_defs.h | 2 -- 6 files changed, 4 insertions(+), 30 deletions(-) diff --git a/src/doomdata.h b/src/doomdata.h index 884c043a4..8621a362a 100644 --- a/src/doomdata.h +++ b/src/doomdata.h @@ -205,7 +205,6 @@ typedef struct UINT16 options; INT16 z; UINT8 extrainfo; - INT16 tag; taglist_t tags; struct mobj_s *mobj; } mapthing_t; diff --git a/src/p_enemy.c b/src/p_enemy.c index a51d76cb0..72aac711e 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -3866,13 +3866,10 @@ void A_BossDeath(mobj_t *mo) { // Bring the egg trap up to the surface // Incredibly shitty code ahead - junk.tag = LE_CAPSULE0; Tag_FSet(&junk.tags, LE_CAPSULE0); EV_DoElevator(&junk, elevateHighest, false); - junk.tag = LE_CAPSULE1; Tag_FSet(&junk.tags, LE_CAPSULE1); EV_DoElevator(&junk, elevateUp, false); - junk.tag = LE_CAPSULE2; Tag_FSet(&junk.tags, LE_CAPSULE2); EV_DoElevator(&junk, elevateHighest, false); @@ -3996,7 +3993,6 @@ bossjustdie: } case MT_KOOPA: { - junk.tag = LE_KOOPA; Tag_FSet(&junk.tags, LE_KOOPA); EV_DoCeiling(&junk, raiseToHighest); return; diff --git a/src/p_inter.c b/src/p_inter.c index 0cdbe57b2..efe23d500 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -1376,7 +1376,6 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) if (player->bot) return; - junk.tag = LE_AXE; Tag_FSet(&junk.tags, LE_AXE); EV_DoElevator(&junk, bridgeFall, false); diff --git a/src/p_setup.c b/src/p_setup.c index baa71c6b3..fe0818249 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -933,7 +933,6 @@ static void P_LoadSectors(UINT8 *data) ss->lightlevel = SHORT(ms->lightlevel); ss->special = SHORT(ms->special); - ss->tag = SHORT(ms->tag); Tag_FSet(&ss->tags, SHORT(ms->tag)); ss->floor_xoffs = ss->floor_yoffs = 0; @@ -1047,7 +1046,6 @@ static void P_LoadLinedefs(UINT8 *data) { ld->flags = SHORT(mld->flags); ld->special = SHORT(mld->special); - ld->tag = SHORT(mld->tag); Tag_FSet(&ld->tags, SHORT(mld->tag)); memset(ld->args, 0, NUMLINEARGS*sizeof(*ld->args)); memset(ld->stringargs, 0x00, NUMLINESTRINGARGS*sizeof(*ld->stringargs)); @@ -1278,7 +1276,6 @@ static void P_LoadThings(UINT8 *data) mt->type = READUINT16(data); mt->options = READUINT16(data); mt->extrainfo = (UINT8)(mt->type >> 12); - mt->tag = 0; Tag_FSet(&mt->tags, 0); mt->type &= 4095; @@ -1399,10 +1396,7 @@ static void ParseTextmapSectorParameter(UINT32 i, char *param, char *val) else if (fastcmp(param, "special")) sectors[i].special = atol(val); else if (fastcmp(param, "id")) - { - sectors[i].tag = atol(val); - Tag_FSet(§ors[i].tags, sectors[i].tag); - } + Tag_FSet(§ors[i].tags, atol(val)); else if (fastcmp(param, "moreids")) { char* id = val; @@ -1448,10 +1442,7 @@ static void ParseTextmapSidedefParameter(UINT32 i, char *param, char *val) static void ParseTextmapLinedefParameter(UINT32 i, char *param, char *val) { if (fastcmp(param, "id")) - { - lines[i].tag = atol(val); - Tag_FSet(&lines[i].tags, lines[i].tag); - } + Tag_FSet(&lines[i].tags, atol(val)); else if (fastcmp(param, "moreids")) { char* id = val; @@ -1528,10 +1519,7 @@ static void ParseTextmapLinedefParameter(UINT32 i, char *param, char *val) static void ParseTextmapThingParameter(UINT32 i, char *param, char *val) { if (fastcmp(param, "id")) - { - mapthings[i].tag = atol(val); - Tag_FSet(&mapthings[i].tags, mapthings[i].tag); - } + Tag_FSet(&mapthings[i].tags, atol(val)); else if (fastcmp(param, "moreids")) { char* id = val; @@ -1670,7 +1658,6 @@ static void P_LoadTextmap(void) sc->lightlevel = 255; sc->special = 0; - sc->tag = 0; Tag_FSet(&sc->tags, 0); sc->floor_xoffs = sc->floor_yoffs = 0; @@ -1690,7 +1677,6 @@ static void P_LoadTextmap(void) ld->v1 = ld->v2 = NULL; ld->flags = 0; ld->special = 0; - ld->tag = 0; Tag_FSet(&ld->tags, 0); memset(ld->args, 0, NUMLINEARGS*sizeof(*ld->args)); @@ -1739,7 +1725,6 @@ static void P_LoadTextmap(void) mt->options = 0; mt->z = 0; mt->extrainfo = 0; - mt->tag = 0; Tag_FSet(&mt->tags, 0); mt->mobj = NULL; diff --git a/src/p_spec.c b/src/p_spec.c index 81a5e0e49..ccce18e30 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -4366,16 +4366,13 @@ void P_ProcessSpecialSector(player_t *player, sector_t *sector, sector_t *rovers // Move the button down Tag_FSet(&junk.tags, 680); - junk.tag = 680; EV_DoElevator(&junk, elevateDown, false); // Open the top FOF Tag_FSet(&junk.tags, 681); - junk.tag = 681; EV_DoFloor(&junk, raiseFloorToNearestFast); // Open the bottom FOF Tag_FSet(&junk.tags, 682); - junk.tag = 682; EV_DoCeiling(&junk, lowerToLowestFast); // Mark all players with the time to exit thingy! @@ -5549,7 +5546,7 @@ static ffloor_t *P_AddFakeFloor(sector_t *sec, sector_t *sec2, line_t *master, f { fixed_t tempceiling = sec2->ceilingheight; //flip the sector around and print an error instead of crashing 12.1.08 -Inuyasha - CONS_Alert(CONS_ERROR, M_GetText("A FOF tagged %d has a top height below its bottom.\n"), master->tag); + CONS_Alert(CONS_ERROR, M_GetText("FOF (line %d) has a top height below its bottom.\n"), master - lines); sec2->ceilingheight = sec2->floorheight; sec2->floorheight = tempceiling; } diff --git a/src/r_defs.h b/src/r_defs.h index 41d141ce8..72e3675cb 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -291,7 +291,6 @@ typedef struct sector_s INT32 ceilingpic; INT16 lightlevel; INT16 special; - UINT16 tag; taglist_t tags; // origin for any sounds played by the sector @@ -409,7 +408,6 @@ typedef struct line_s // Animation related. INT16 flags; INT16 special; - INT16 tag; taglist_t tags; INT32 args[NUMLINEARGS]; char *stringargs[NUMLINESTRINGARGS]; From b7c4ed9c6bb0edb8f94ca2afa94c26e49cc3646d Mon Sep 17 00:00:00 2001 From: Nev3r Date: Sat, 18 Apr 2020 11:34:59 +0200 Subject: [PATCH 0059/1080] Implement dynamic global taggroups/lists functionality. --- src/p_saveg.c | 10 ++++ src/taglist.c | 131 +++++++++++++++++++++++++++++++++++--------------- src/taglist.h | 3 ++ 3 files changed, 106 insertions(+), 38 deletions(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index 4fdc3d488..4a414e9e1 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -1149,6 +1149,12 @@ static void P_NetUnArchiveWorld(void) if (diff2 & SD_TAG) { size_t ncount = READUINT32(get); + + // Remove entries from global lists. + for (j = 0; j < sectors[i].tags.count; j++) + Taggroup_Remove(tags_sectors, sectors[i].tags.tags[j], i); + + // Reallocate if size differs. if (ncount != sectors[i].tags.count) { sectors[i].tags.count = ncount; @@ -1157,6 +1163,10 @@ static void P_NetUnArchiveWorld(void) for (j = 0; j < ncount; j++) sectors[i].tags.tags[j] = READINT16(get); + + // Add new entries. + for (j = 0; j < sectors[i].tags.count; j++) + Taggroup_Remove(tags_sectors, sectors[i].tags.tags[j], i); } if (diff3 & SD_COLORMAP) diff --git a/src/taglist.c b/src/taglist.c index 1849c314c..3b0135abd 100644 --- a/src/taglist.c +++ b/src/taglist.c @@ -63,58 +63,97 @@ boolean Tag_Compare (const taglist_t* list1, const taglist_t* list2) return true; } -static void Taglist_AddToSectors (const mtag_t tag, const size_t itemid) + +size_t Taggroup_Find (const taggroup_t *group, const size_t id) { - taggroup_t* tagelems; + size_t i; + + if (!group) + return -1; + + for (i = 0; i < group->count; i++) + if (group->elements[i] == id) + return i; + + return -1; +} + +void Taggroup_Add (taggroup_t *garray[], const mtag_t tag, size_t id) +{ + taggroup_t *group; if (tag == MTAG_GLOBAL) return; - if (!tags_sectors[(UINT16)tag]) - tags_sectors[(UINT16)tag] = Z_Calloc(sizeof(taggroup_t), PU_LEVEL, NULL); + group = garray[(UINT16)tag]; - tagelems = tags_sectors[(UINT16)tag]; - tagelems->count++; - tagelems->elements = Z_Realloc(tagelems->elements, tagelems->count * sizeof(size_t), PU_LEVEL, NULL); - tagelems->elements[tagelems->count - 1] = itemid; + // Don't add duplicate entries. + if (Taggroup_Find(group, id) != (size_t)-1) + return; + + // Create group if empty. + if (!group) + group = garray[(UINT16)tag] = Z_Calloc(sizeof(taggroup_t), PU_LEVEL, NULL); + + group->count++; + group->elements = Z_Realloc(group->elements, group->count * sizeof(size_t), PU_LEVEL, NULL); + group->elements[group->count - 1] = id; +} + +void Taggroup_Remove (taggroup_t *garray[], const mtag_t tag, size_t id) +{ + taggroup_t *group; + size_t rempos; + size_t newcount; + + if (tag == MTAG_GLOBAL) + return; + + group = garray[(UINT16)tag]; + + if ((rempos = Taggroup_Find(group, id)) == (size_t)-1) + return; + + // Strip away taggroup if no elements left. + if (!(newcount = --group->count)) + { + Z_Free(group->elements); + Z_Free(group); + garray[(UINT16)tag] = NULL; + } + else + { + size_t *newelements = Z_Malloc(newcount * sizeof(size_t), PU_LEVEL, NULL); + size_t i; + + // Copy the previous entries save for the one to remove. + for (i = 0; i < rempos; i++) + newelements[i] = group->elements[i]; + + for (i = rempos + 1; i < group->count; i++) + newelements[i - 1] = group->elements[i]; + + Z_Free(group->elements); + group->elements = newelements; + group->count = newcount; + } +} + +// Initialization. + +static void Taglist_AddToSectors (const mtag_t tag, const size_t itemid) +{ + Taggroup_Add(tags_sectors, tag, itemid); } static void Taglist_AddToLines (const mtag_t tag, const size_t itemid) { - taggroup_t* tagelems; - - if (tag == MTAG_GLOBAL) - return; - - if (!tags_lines[(UINT16)tag]) - tags_lines[(UINT16)tag] = Z_Calloc(sizeof(taggroup_t), PU_LEVEL, NULL); - - tagelems = tags_lines[(UINT16)tag]; - tagelems->count++; - tagelems->elements = Z_Realloc(tagelems->elements, tagelems->count * sizeof(size_t), PU_LEVEL, NULL); - tagelems->elements[tagelems->count - 1] = itemid; + Taggroup_Add(tags_lines, tag, itemid); } static void Taglist_AddToMapthings (const mtag_t tag, const size_t itemid) { - taggroup_t* tagelems; - - if (tag == MTAG_GLOBAL) - return; - - if (!tags_mapthings[(UINT16)tag]) - tags_mapthings[(UINT16)tag] = Z_Calloc(sizeof(taggroup_t), PU_LEVEL, NULL); - - tagelems = tags_mapthings[(UINT16)tag]; - tagelems->count++; - tagelems->elements = Z_Realloc(tagelems->elements, tagelems->count * sizeof(size_t), PU_LEVEL, NULL); - tagelems->elements[tagelems->count - 1] = itemid; -} - -void Tag_SectorFSet (const size_t id, const mtag_t tag) -{ - sector_t* sec = §ors[id]; - Tag_FSet(&sec->tags, tag); + Taggroup_Add(tags_mapthings, tag, itemid); } void Taglist_InitGlobalTables(void) @@ -144,6 +183,8 @@ void Taglist_InitGlobalTables(void) } } +// Iteration, inagme search. + INT32 Tag_Iterate_Sectors (const mtag_t tag, const size_t p) { if (tag == MTAG_GLOBAL) @@ -217,3 +258,17 @@ INT32 Tag_FindLineSpecial(const INT16 special, const mtag_t tag) } return -1; } + +// Ingame list manipulation. + +void Tag_SectorFSet (const size_t id, const mtag_t tag) +{ + sector_t* sec = §ors[id]; + mtag_t curtag = Tag_FGet(&sec->tags); + if (curtag == tag) + return; + + Taggroup_Remove(tags_sectors, curtag, id); + Taggroup_Add(tags_sectors, tag, id); + Tag_FSet(&sec->tags, tag); +} diff --git a/src/taglist.h b/src/taglist.h index 050bebed7..d1acff6cb 100644 --- a/src/taglist.h +++ b/src/taglist.h @@ -35,6 +35,9 @@ taggroup_t* tags_sectors[MAXTAGS + 1]; taggroup_t* tags_lines[MAXTAGS + 1]; taggroup_t* tags_mapthings[MAXTAGS + 1]; +void Taggroup_Add (taggroup_t *garray[], const mtag_t tag, size_t id); +void Taggroup_Remove (taggroup_t *garray[], const mtag_t tag, size_t id); + void Taglist_InitGlobalTables(void); INT32 Tag_Iterate_Sectors (const mtag_t tag, const size_t p); From 6eaaa744f4b6f30f1db4a6987e20c4e5e32d6a89 Mon Sep 17 00:00:00 2001 From: Nev3r Date: Sun, 19 Apr 2020 12:21:22 +0200 Subject: [PATCH 0060/1080] Taggroups are now sorted when a new entry is added. --- src/taglist.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/src/taglist.c b/src/taglist.c index 3b0135abd..2c1ac85d7 100644 --- a/src/taglist.c +++ b/src/taglist.c @@ -81,6 +81,7 @@ size_t Taggroup_Find (const taggroup_t *group, const size_t id) void Taggroup_Add (taggroup_t *garray[], const mtag_t tag, size_t id) { taggroup_t *group; + size_t i; // Insert position. if (tag == MTAG_GLOBAL) return; @@ -93,11 +94,35 @@ void Taggroup_Add (taggroup_t *garray[], const mtag_t tag, size_t id) // Create group if empty. if (!group) + { + i = 0; group = garray[(UINT16)tag] = Z_Calloc(sizeof(taggroup_t), PU_LEVEL, NULL); + } + else + { + // Keep the group element ids in an ascending order. + // Find the location to insert the element to. + for (i = 0; i < group->count; i++) + if (group->elements[i] > id) + break; + + group->elements = Z_Realloc(group->elements, (group->count + 1) * sizeof(size_t), PU_LEVEL, NULL); + + // Offset existing elements to make room for the new one. + if (i < group->count) + { + // Temporary memory block for copying. + size_t size = group->count - i; + size_t *temp = malloc(size); + memcpy(temp, &group->elements[i], size); + memcpy(&group->elements[i + 1], temp, size); + free(temp); + } + } group->count++; group->elements = Z_Realloc(group->elements, group->count * sizeof(size_t), PU_LEVEL, NULL); - group->elements[group->count - 1] = id; + group->elements[i] = id; } void Taggroup_Remove (taggroup_t *garray[], const mtag_t tag, size_t id) From 9ac60a62b3f48232c0192733718ed2211b94dec1 Mon Sep 17 00:00:00 2001 From: Nev3r Date: Sun, 19 Apr 2020 13:13:17 +0200 Subject: [PATCH 0061/1080] Fix cage issue with boss 4. --- src/p_mobj.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index 9cfc15113..15394746a 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -4714,9 +4714,6 @@ static void P_Boss4DestroyCage(mobj_t *mobj) TAG_ITER_SECTORS(tag, snum) { sector = §ors[snum]; - if (!Tag_Find(§or->tags, tag)) - continue; - Tag_SectorFSet(sector - sectors, 0); // Destroy the FOFs. for (a = 0; a < sector->numattached; a++) From 9f06903d7284553dbeb77ee6ae9ea40693998318 Mon Sep 17 00:00:00 2001 From: Nev3r Date: Sat, 11 Jul 2020 11:01:05 +0200 Subject: [PATCH 0062/1080] What the fuck was I thinking? Fixed really stupid brainless code piece involving polyobject spawnpoint tagging. --- src/p_setup.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index e073cc110..981d02360 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -3180,11 +3180,11 @@ static void P_ConvertBinaryMap(void) { INT32 check = -1; INT32 firstline = -1; - mtag_t tag = Tag_FGet(&lines[check].tags); + mtag_t tag = mapthings[i].angle; TAG_ITER_C - Tag_FSet(&mapthings[i].tags, mapthings[i].angle); + Tag_FSet(&mapthings[i].tags, tag); TAG_ITER_LINES(tag, check) { From d26c7654ff1a2a6f75cf2fd40714687de3a844ca Mon Sep 17 00:00:00 2001 From: Zachary McAlpin Date: Fri, 17 Jul 2020 00:08:38 -0500 Subject: [PATCH 0063/1080] Ported Lat's PlayerCmd hook to vanilla SRB2 --- src/g_game.c | 7 +++++++ src/lua_baselib.c | 9 ++++++--- src/lua_hook.h | 6 +++++- src/lua_hooklib.c | 46 ++++++++++++++++++++++++++++++++++++++++++++- src/lua_infolib.c | 27 ++++++++++++++++++++++++++ src/lua_maplib.c | 7 +++++++ src/lua_mobjlib.c | 5 +++++ src/lua_playerlib.c | 7 +++++++ 8 files changed, 109 insertions(+), 5 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index cce4ac822..ecd1d5208 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1675,6 +1675,13 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) } } + /* Note: Lat originally made the PlayerCmd hook for SRB2 Kart so credit goes to him. + Also, unlike in SRB2 Kart, the cmd's variables cannot be set using the PlayerCmd, because + it is recommended to use the PreThinkFrame to set the cmd's variables, because PreThinkFrame is actually synched, + unlike the PlayerCmd hook. */ + if (gamestate == GS_LEVEL) + LUAh_PlayerCmd(player, cmd); + //Reset away view if a command is given. if (ssplayer == 1 && (cmd->forwardmove || cmd->sidemove || cmd->buttons) && displayplayer != consoleplayer) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 3f62ef890..0e60cbb90 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -32,9 +32,12 @@ #include "lua_script.h" #include "lua_libs.h" #include "lua_hud.h" // hud_running errors +#include "lua_hook.h" // hook_cmd_running errors #define NOHUD if (hud_running)\ -return luaL_error(L, "HUD rendering code should not call this function!"); +return luaL_error(L, "HUD rendering code should not call this function!");\ +else if (hook_cmd_running)\ +return luaL_error(L, "CMD building code should not call this function!"); boolean luaL_checkboolean(lua_State *L, int narg) { luaL_checktype(L, narg, LUA_TBOOLEAN); @@ -2593,8 +2596,8 @@ static int lib_sStartSound(lua_State *L) } if (!player || P_IsLocalPlayer(player)) { - if (hud_running) - origin = NULL; // HUD rendering startsound shouldn't have an origin, just remove it instead of having a retarded error. + if (hud_running || hook_cmd_running) + origin = NULL; // HUD rendering and CMD building startsound shouldn't have an origin, just remove it instead of having a retarded error. S_StartSound(origin, sound_id); } diff --git a/src/lua_hook.h b/src/lua_hook.h index 48f6cab32..47850812f 100644 --- a/src/lua_hook.h +++ b/src/lua_hook.h @@ -59,11 +59,14 @@ enum hook { hook_PlayerThink, hook_ShouldJingleContinue, hook_GameQuit, + hook_PlayerCmd, hook_MAX // last hook }; extern const char *const hookNames[]; +extern boolean hook_cmd_running; + void LUAh_MapChange(INT16 mapnumber); // Hook for map change (before load) void LUAh_MapLoad(void); // Hook for map load void LUAh_PlayerJoin(int playernum); // Hook for Got_AddPlayer @@ -113,4 +116,5 @@ boolean LUAh_SeenPlayer(player_t *player, player_t *seenfriend); // Hook for MT_ #endif #define LUAh_PlayerThink(player) LUAh_PlayerHook(player, hook_PlayerThink) // Hook for P_PlayerThink boolean LUAh_ShouldJingleContinue(player_t *player, const char *musname); // Hook for whether a jingle of the given music should continue playing -void LUAh_GameQuit(void); // Hook for game quitting \ No newline at end of file +void LUAh_GameQuit(void); // Hook for game quitting +boolean LUAh_PlayerCmd(player_t *player, ticcmd_t *cmd); // Hook for building player's ticcmd struct (Ported from SRB2Kart) diff --git a/src/lua_hooklib.c b/src/lua_hooklib.c index 5cfd1bd3d..9157b08d6 100644 --- a/src/lua_hooklib.c +++ b/src/lua_hooklib.c @@ -71,6 +71,7 @@ const char *const hookNames[hook_MAX+1] = { "PlayerThink", "ShouldJingleContinue", "GameQuit", + "PlayerCmd", NULL }; @@ -1793,6 +1794,49 @@ void LUAh_GameQuit(void) hookp->error = true; } } - + lua_pop(gL, 1); // Pop error handler } + +// Hook for building player's ticcmd struct (Ported from SRB2Kart) +boolean hook_cmd_running = false; +boolean LUAh_PlayerCmd(player_t *player, ticcmd_t *cmd) +{ + hook_p hookp; + boolean hooked = false; + if (!gL || !(hooksAvailable[hook_PlayerCmd/8] & (1<next) + { + if (hookp->type != hook_PlayerCmd) + continue; + + if (lua_gettop(gL) == 1) + { + LUA_PushUserdata(gL, player, META_PLAYER); + LUA_PushUserdata(gL, cmd, META_TICCMD); + } + PushHook(gL, hookp); + lua_pushvalue(gL, -3); + lua_pushvalue(gL, -3); + if (lua_pcall(gL, 2, 1, 1)) { + if (!hook->error || cv_debug & DBG_LUA) + CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); + lua_pop(gL, 1); + hookp->error = true; + continue; + } + if (lua_toboolean(gL, -1)) + hooked = true; + lua_pop(gL, 1); + } + + lua_settop(gL, 0); + lua_cmd_running = false; + return hooked; +} diff --git a/src/lua_infolib.c b/src/lua_infolib.c index b3e92f833..0bd388b5b 100644 --- a/src/lua_infolib.c +++ b/src/lua_infolib.c @@ -25,6 +25,7 @@ #include "lua_script.h" #include "lua_libs.h" #include "lua_hud.h" // hud_running errors +#include "lua_hook.h" // hook_cmd_running errors extern CV_PossibleValue_t Color_cons_t[]; extern UINT8 skincolor_modified[]; @@ -165,6 +166,8 @@ static int lib_setSpr2default(lua_State *L) if (hud_running) return luaL_error(L, "Do not alter spr2defaults[] in HUD rendering code!"); + if (hook_cmd_running) + return luaL_error(L, "Do not alter spr2defaults[] in CMD building code!"); // todo: maybe allow setting below first freeslot..? step 1 is toggling this, step 2 is testing to see whether it's net-safe #ifdef SETALLSPR2DEFAULTS @@ -371,6 +374,8 @@ static int lib_setSpriteInfo(lua_State *L) return luaL_error(L, "Do not alter spriteinfo_t from within a hook or coroutine!"); if (hud_running) return luaL_error(L, "Do not alter spriteinfo_t in HUD rendering code!"); + if (hook_cmd_running) + return luaL_error(L, "Do not alter spriteinfo_t in CMD building code!"); lua_remove(L, 1); { @@ -455,6 +460,8 @@ static int spriteinfo_set(lua_State *L) return luaL_error(L, "Do not alter spriteinfo_t from within a hook or coroutine!"); if (hud_running) return luaL_error(L, "Do not alter spriteinfo_t in HUD rendering code!"); + if (hook_cmd_running) + return luaL_error(L, "Do not alter spriteinfo_t in CMD building code!"); I_Assert(sprinfo != NULL); @@ -533,6 +540,8 @@ static int pivotlist_set(lua_State *L) return luaL_error(L, "Do not alter spriteframepivot_t from within a hook or coroutine!"); if (hud_running) return luaL_error(L, "Do not alter spriteframepivot_t in HUD rendering code!"); + if (hook_cmd_running) + return luaL_error(L, "Do not alter spriteframepivot_t in CMD building code!"); I_Assert(pivotlist != NULL); @@ -587,6 +596,8 @@ static int framepivot_set(lua_State *L) return luaL_error(L, "Do not alter spriteframepivot_t from within a hook or coroutine!"); if (hud_running) return luaL_error(L, "Do not alter spriteframepivot_t in HUD rendering code!"); + if (hook_cmd_running) + return luaL_error(L, "Do not alter spriteframepivot_t in CMD building code!"); I_Assert(framepivot != NULL); @@ -686,6 +697,8 @@ static int lib_setState(lua_State *L) if (hud_running) return luaL_error(L, "Do not alter states in HUD rendering code!"); + if (hook_cmd_running) + return luaL_error(L, "Do not alter states in CMD building code!"); // clear the state to start with, in case of missing table elements memset(state,0,sizeof(state_t)); @@ -1006,6 +1019,8 @@ static int lib_setMobjInfo(lua_State *L) if (hud_running) return luaL_error(L, "Do not alter mobjinfo in HUD rendering code!"); + if (hook_cmd_running) + return luaL_error(L, "Do not alter mobjinfo in CMD building code!"); // clear the mobjinfo to start with, in case of missing table elements memset(info,0,sizeof(mobjinfo_t)); @@ -1173,6 +1188,8 @@ static int mobjinfo_set(lua_State *L) if (hud_running) return luaL_error(L, "Do not alter mobjinfo in HUD rendering code!"); + if (hook_cmd_running) + return luaL_error(L, "Do not alter mobjinfo in CMD building code!"); I_Assert(info != NULL); I_Assert(info >= mobjinfo); @@ -1295,6 +1312,8 @@ static int lib_setSfxInfo(lua_State *L) if (hud_running) return luaL_error(L, "Do not alter sfxinfo in HUD rendering code!"); + if (hook_cmd_running) + return luaL_error(L, "Do not alter sfxinfo in CMD building code!"); lua_pushnil(L); while (lua_next(L, 1)) { @@ -1376,6 +1395,8 @@ static int sfxinfo_set(lua_State *L) if (hud_running) return luaL_error(L, "Do not alter S_sfx in HUD rendering code!"); + if (hook_cmd_running) + return luaL_error(L, "Do not alter S_sfx in CMD building code!"); I_Assert(sfx != NULL); @@ -1443,6 +1464,8 @@ static int lib_setluabanks(lua_State *L) if (hud_running) return luaL_error(L, "Do not alter luabanks[] in HUD rendering code!"); + if (hook_cmd_running) + return luaL_error(L, "Do not alter luabanks[] in CMD building code!"); lua_remove(L, 1); // don't care about luabanks[] dummy userdata. @@ -1523,6 +1546,8 @@ static int lib_setSkinColor(lua_State *L) if (hud_running) return luaL_error(L, "Do not alter skincolors in HUD rendering code!"); + if (hook_cmd_running) + return luaL_error(L, "Do not alter skincolors in CMD building code!"); // clear the skincolor to start with, in case of missing table elements memset(info,0,sizeof(skincolor_t)); @@ -1697,6 +1722,8 @@ static int colorramp_set(lua_State *L) return luaL_error(L, LUA_QL("skincolor_t") " field 'ramp' index %d out of range (0 - %d)", n, COLORRAMPSIZE-1); if (hud_running) return luaL_error(L, "Do not alter skincolor_t in HUD rendering code!"); + if (hook_cmd_running) + return luaL_error(L, "Do not alter skincolor_t in CMD building code!"); colorramp[n] = i; skincolor_modified[cnum] = true; return 0; diff --git a/src/lua_maplib.c b/src/lua_maplib.c index 144a6b3f1..3c088f482 100644 --- a/src/lua_maplib.c +++ b/src/lua_maplib.c @@ -21,6 +21,7 @@ #include "lua_script.h" #include "lua_libs.h" #include "lua_hud.h" // hud_running errors +#include "lua_hook.h" // hook_cmd_running errors #include "dehacked.h" #include "fastcmp.h" @@ -577,6 +578,8 @@ static int sector_set(lua_State *L) if (hud_running) return luaL_error(L, "Do not alter sector_t in HUD rendering code!"); + if (hook_cmd_running) + return luaL_error(L, "Do not alter sector_t in CMD building code!"); switch(field) { @@ -1716,6 +1719,8 @@ static int ffloor_set(lua_State *L) if (hud_running) return luaL_error(L, "Do not alter ffloor_t in HUD rendering code!"); + if (hook_cmd_running) + return luaL_error(L, "Do not alter ffloor_t in CMD building code!"); switch(field) { @@ -1840,6 +1845,8 @@ static int slope_set(lua_State *L) if (hud_running) return luaL_error(L, "Do not alter pslope_t in HUD rendering code!"); + if (hook_cmd_running) + return luaL_error(L, "Do not alter pslope_t in CMD building code!"); switch(field) // todo: reorganize this shit { diff --git a/src/lua_mobjlib.c b/src/lua_mobjlib.c index e2826e160..2f0b2ce66 100644 --- a/src/lua_mobjlib.c +++ b/src/lua_mobjlib.c @@ -20,6 +20,7 @@ #include "lua_script.h" #include "lua_libs.h" #include "lua_hud.h" // hud_running errors +#include "lua_hook.h" // hook_cmd_running errors static const char *const array_opt[] ={"iterate",NULL}; @@ -427,6 +428,8 @@ static int mobj_set(lua_State *L) if (hud_running) return luaL_error(L, "Do not alter mobj_t in HUD rendering code!"); + if (hook_cmd_running) + return luaL_error(L, "Do not alter mobj_t in CMD building code!"); switch(field) { @@ -808,6 +811,8 @@ static int mapthing_set(lua_State *L) if (hud_running) return luaL_error(L, "Do not alter mapthing_t in HUD rendering code!"); + if (hook_cmd_running) + return luaL_error(L, "Do not alter mapthing_t in CMD building code!"); if(fastcmp(field,"x")) mt->x = (INT16)luaL_checkinteger(L, 3); diff --git a/src/lua_playerlib.c b/src/lua_playerlib.c index 1ce9be525..8c5ce5282 100644 --- a/src/lua_playerlib.c +++ b/src/lua_playerlib.c @@ -20,6 +20,7 @@ #include "lua_script.h" #include "lua_libs.h" #include "lua_hud.h" // hud_running errors +#include "lua_hook.h" // hook_cmd_running errors static int lib_iteratePlayers(lua_State *L) { @@ -400,6 +401,8 @@ static int player_set(lua_State *L) if (hud_running) return luaL_error(L, "Do not alter player_t in HUD rendering code!"); + if (hook_cmd_running) + return luaL_error(L, "Do not alter player_t in CMD building code!"); if (fastcmp(field,"mo") || fastcmp(field,"realmo")) { mobj_t *newmo = *((mobj_t **)luaL_checkudata(L, 3, META_MOBJ)); @@ -770,6 +773,8 @@ static int power_set(lua_State *L) return luaL_error(L, LUA_QL("powertype_t") " cannot be %d", (INT16)p); if (hud_running) return luaL_error(L, "Do not alter player_t in HUD rendering code!"); + if (hook_cmd_running) + return luaL_error(L, "Do not alter player_t in CMD building code!"); powers[p] = i; return 0; } @@ -815,6 +820,8 @@ static int ticcmd_set(lua_State *L) if (hud_running) return luaL_error(L, "Do not alter player_t in HUD rendering code!"); + if (hook_cmd_running) + return luaL_error(L, "Do not alter player_t in CMD building code!"); if (fastcmp(field,"forwardmove")) cmd->forwardmove = (SINT8)luaL_checkinteger(L, 3); From c42e06221d1df8cc2822337e6297fef1297dbaff Mon Sep 17 00:00:00 2001 From: Zachary McAlpin Date: Fri, 17 Jul 2020 00:33:07 -0500 Subject: [PATCH 0064/1080] Bruh I screwed up --- src/lua_hooklib.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lua_hooklib.c b/src/lua_hooklib.c index 9157b08d6..95d352b27 100644 --- a/src/lua_hooklib.c +++ b/src/lua_hooklib.c @@ -1804,7 +1804,7 @@ boolean LUAh_PlayerCmd(player_t *player, ticcmd_t *cmd) { hook_p hookp; boolean hooked = false; - if (!gL || !(hooksAvailable[hook_PlayerCmd/8] & (1<error || cv_debug & DBG_LUA) + if (!hookp->error || cv_debug & DBG_LUA) CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); lua_pop(gL, 1); hookp->error = true; @@ -1837,6 +1837,6 @@ boolean LUAh_PlayerCmd(player_t *player, ticcmd_t *cmd) } lua_settop(gL, 0); - lua_cmd_running = false; + hook_cmd_running = false; return hooked; } From cbba71051d072b84a5497cb8bb1588e717bf4baa Mon Sep 17 00:00:00 2001 From: Zachary McAlpin Date: Sat, 25 Jul 2020 20:08:41 -0500 Subject: [PATCH 0065/1080] Allow cmd to be modified using the PlayerCmd hook --- src/lua_playerlib.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/lua_playerlib.c b/src/lua_playerlib.c index 8c5ce5282..412dc3eff 100644 --- a/src/lua_playerlib.c +++ b/src/lua_playerlib.c @@ -820,8 +820,6 @@ static int ticcmd_set(lua_State *L) if (hud_running) return luaL_error(L, "Do not alter player_t in HUD rendering code!"); - if (hook_cmd_running) - return luaL_error(L, "Do not alter player_t in CMD building code!"); if (fastcmp(field,"forwardmove")) cmd->forwardmove = (SINT8)luaL_checkinteger(L, 3); From 3b55c9e94070820d827a843568c3f8899dc69b81 Mon Sep 17 00:00:00 2001 From: Nev3r Date: Wed, 29 Jul 2020 14:52:21 +0200 Subject: [PATCH 0066/1080] Fix FOF intersections in multitagging for the software renderer. --- src/r_segs.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/r_segs.c b/src/r_segs.c index 5bf9b5c82..52c19d96e 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -2141,6 +2141,9 @@ void R_StoreWallRange(INT32 start, INT32 stop) for (r2 = frontsector->ffloors; r2; r2 = r2->next) { + if (r2->master == rover->master) // Skip if same control line. + continue; + if (!(r2->flags & FF_EXISTS) || !(r2->flags & FF_RENDERSIDES)) continue; From 729c8b2ec6cab99ed838a301ce938d9b04801406 Mon Sep 17 00:00:00 2001 From: Nev3r Date: Wed, 29 Jul 2020 14:53:27 +0200 Subject: [PATCH 0067/1080] Fix FOF intersections with multitags for the OpenGL in a kind of hacky way. --- src/hardware/hw_main.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 98b736b30..219bc905e 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -1627,6 +1627,9 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom continue; if (*rover->topheight < lowcut || *rover->bottomheight > highcut) continue; + if (Tag_Find(&gl_frontsector->tags, rover->master->args[0])) // Skip FOF if on both sectors by checking arg0. Hacky but it works. + continue; + texnum = R_GetTextureNum(sides[rover->master->sidenum[0]].midtexture); @@ -1761,6 +1764,8 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom continue; if (*rover->topheight < lowcut || *rover->bottomheight > highcut) continue; + if (Tag_Find(&gl_backsector->tags, rover->master->args[0])) // Skip FOF if on both sectors by checking arg0. Hacky but it works. + continue; texnum = R_GetTextureNum(sides[rover->master->sidenum[0]].midtexture); From c914ac99b4e39110bca1203b4d12e9078d406656 Mon Sep 17 00:00:00 2001 From: Nev3r Date: Wed, 29 Jul 2020 17:26:43 +0200 Subject: [PATCH 0068/1080] Bring back P_FindSpecialLineFromTag() for backwards compatibility reasons; emulate the old taglist behavior for this function. --- src/lua_baselib.c | 13 +++++++++++++ src/taglist.c | 42 ++++++++++++++++++++++++++++++++++++++++++ src/taglist.h | 3 ++- 3 files changed, 57 insertions(+), 1 deletion(-) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index a8a45ba20..5d1db5641 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -32,6 +32,7 @@ #include "lua_script.h" #include "lua_libs.h" #include "lua_hud.h" // hud_running errors +#include "taglist.h" // P_FindSpecialLineFromTag #define NOHUD if (hud_running)\ return luaL_error(L, "HUD rendering code should not call this function!"); @@ -2094,6 +2095,17 @@ static int lib_pFindHighestCeilingSurrounding(lua_State *L) return 1; } +static int lib_pFindSpecialLineFromTag(lua_State *L) +{ + INT16 special = (INT16)luaL_checkinteger(L, 1); + INT16 line = (INT16)luaL_checkinteger(L, 2); + INT32 start = (INT32)luaL_optinteger(L, 3, -1); + NOHUD + INLEVEL + lua_pushinteger(L, P_FindSpecialLineFromTag(special, line, start)); + return 1; +} + static int lib_pSwitchWeather(lua_State *L) { INT32 weathernum = (INT32)luaL_checkinteger(L, 1); @@ -3581,6 +3593,7 @@ static luaL_Reg lib[] = { {"P_FindNextLowestFloor",lib_pFindNextLowestFloor}, {"P_FindLowestCeilingSurrounding",lib_pFindLowestCeilingSurrounding}, {"P_FindHighestCeilingSurrounding",lib_pFindHighestCeilingSurrounding}, + {"P_FindSpecialLineFromTag",lib_pFindSpecialLineFromTag}, {"P_SwitchWeather",lib_pSwitchWeather}, {"P_LinedefExecute",lib_pLinedefExecute}, {"P_SpawnLightningFlash",lib_pSpawnLightningFlash}, diff --git a/src/taglist.c b/src/taglist.c index 2c1ac85d7..7fd2601c7 100644 --- a/src/taglist.c +++ b/src/taglist.c @@ -284,6 +284,48 @@ INT32 Tag_FindLineSpecial(const INT16 special, const mtag_t tag) return -1; } +/// Backwards compatibility iteration function for Lua scripts. +INT32 P_FindSpecialLineFromTag(INT16 special, INT16 tag, INT32 start) +{ + if (tag == -1) + { + start++; + + if (start >= (INT32)numlines) + return -1; + + while (start < (INT32)numlines && lines[start].special != special) + start++; + + return start; + } + else + { + size_t p = 0; + INT32 id; + + // For backwards compatibility's sake, simulate the old linked taglist behavior: + // Iterate through the taglist and find the "start" line's position in the list, + // And start checking with the next one (if it exists). + if (start != -1) + { + for (; (id = Tag_Iterate_Lines(tag, p)) >= 0; p++) + if (id == start) + { + p++; + break; + } + } + + for (; (id = Tag_Iterate_Lines(tag, p)) >= 0; p++) + if (lines[id].special == special) + return id; + + return -1; + } +} + + // Ingame list manipulation. void Tag_SectorFSet (const size_t id, const mtag_t tag) diff --git a/src/taglist.h b/src/taglist.h index d1acff6cb..7c3b4ad52 100644 --- a/src/taglist.h +++ b/src/taglist.h @@ -44,7 +44,8 @@ INT32 Tag_Iterate_Sectors (const mtag_t tag, const size_t p); INT32 Tag_Iterate_Lines (const mtag_t tag, const size_t p); INT32 Tag_Iterate_Things (const mtag_t tag, const size_t p); -INT32 Tag_FindLineSpecial(const INT16 special, const INT16 tag); +INT32 Tag_FindLineSpecial(const INT16 special, const mtag_t tag); +INT32 P_FindSpecialLineFromTag(INT16 special, INT16 tag, INT32 start); #define TAG_ITER_C size_t kkkk; #define TAG_ITER(fn, tag, id) for(kkkk = 0; (id = fn(tag, kkkk)) >= 0; kkkk++) From 0520725069a121af42c3f3b4dbe9f20c169bc5c0 Mon Sep 17 00:00:00 2001 From: Nev3r Date: Fri, 31 Jul 2020 14:55:26 +0200 Subject: [PATCH 0069/1080] Fix the OpenGL FOF issue with a different approach. Not fond of it either but at least it works. --- src/hardware/hw_main.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 219bc905e..777fd6f1c 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -1621,15 +1621,18 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom { for (rover = gl_backsector->ffloors; rover; rover = rover->next) { + // Skip if it exists on both sectors. + ffloor_t * r2; + for (r2 = gl_frontsector->ffloors; r2; r2 = r2->next) + if (rover->master == r2->master) + continue; + if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_RENDERSIDES)) continue; if (!(rover->flags & FF_ALLSIDES) && rover->flags & FF_INVERTSIDES) continue; if (*rover->topheight < lowcut || *rover->bottomheight > highcut) continue; - if (Tag_Find(&gl_frontsector->tags, rover->master->args[0])) // Skip FOF if on both sectors by checking arg0. Hacky but it works. - continue; - texnum = R_GetTextureNum(sides[rover->master->sidenum[0]].midtexture); @@ -1758,14 +1761,18 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom { for (rover = gl_frontsector->ffloors; rover; rover = rover->next) { + // Skip if it exists on both sectors. + ffloor_t * r2; + for (r2 = gl_backsector->ffloors; r2; r2 = r2->next) + if (rover->master == r2->master) + continue; + if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_RENDERSIDES)) continue; if (!(rover->flags & FF_ALLSIDES || rover->flags & FF_INVERTSIDES)) continue; if (*rover->topheight < lowcut || *rover->bottomheight > highcut) continue; - if (Tag_Find(&gl_backsector->tags, rover->master->args[0])) // Skip FOF if on both sectors by checking arg0. Hacky but it works. - continue; texnum = R_GetTextureNum(sides[rover->master->sidenum[0]].midtexture); From ba5d09eb2eb5f833bb9dccde832f8ded64071c8c Mon Sep 17 00:00:00 2001 From: Nev3r Date: Fri, 31 Jul 2020 22:38:37 +0200 Subject: [PATCH 0070/1080] Fix smooth brain bruhments. --- src/hardware/hw_main.c | 16 ++++++++++++++-- src/r_segs.c | 5 ++++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 777fd6f1c..a1d7797ea 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -1621,11 +1621,17 @@ static 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) - continue; + { + bothsides = true; + break; + } + + if (bothsides) continue; if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_RENDERSIDES)) continue; @@ -1761,11 +1767,17 @@ static 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) - continue; + { + bothsides = true; + break; + } + + if (bothsides) continue; if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_RENDERSIDES)) continue; diff --git a/src/r_segs.c b/src/r_segs.c index 52c19d96e..92b605180 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -2142,7 +2142,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) for (r2 = frontsector->ffloors; r2; r2 = r2->next) { if (r2->master == rover->master) // Skip if same control line. - continue; + break; if (!(r2->flags & FF_EXISTS) || !(r2->flags & FF_RENDERSIDES)) continue; @@ -2199,6 +2199,9 @@ void R_StoreWallRange(INT32 start, INT32 stop) for (r2 = backsector->ffloors; r2; r2 = r2->next) { + if (r2->master == rover->master) // Skip if same control line. + break; + if (!(r2->flags & FF_EXISTS) || !(r2->flags & FF_RENDERSIDES)) continue; From 74dfa9f700326497d3fa1922d582a32a5f702cd2 Mon Sep 17 00:00:00 2001 From: Jaime Passos Date: Fri, 7 Aug 2020 18:17:05 -0300 Subject: [PATCH 0071/1080] Shader code cleanup --- src/hardware/hw_defs.h | 37 ++++ src/hardware/hw_drv.h | 12 +- src/hardware/hw_main.c | 113 ++++++----- src/hardware/hw_main.h | 9 +- src/hardware/hw_md2.c | 2 +- src/hardware/r_opengl/r_opengl.c | 325 +++++++++++++++---------------- src/sdl/hwsym_sdl.c | 5 +- src/sdl/i_video.c | 9 +- src/w_wad.c | 4 +- 9 files changed, 286 insertions(+), 230 deletions(-) diff --git a/src/hardware/hw_defs.h b/src/hardware/hw_defs.h index 715c45ef3..5a5b23f2f 100644 --- a/src/hardware/hw_defs.h +++ b/src/hardware/hw_defs.h @@ -132,6 +132,43 @@ typedef struct FLOAT t; // t texture ordinate (t over w) } FOutVector; +#ifdef GL_SHADERS +// Predefined shader types +enum +{ + SHADER_DEFAULT = 0, + + SHADER_FLOOR, + SHADER_WALL, + SHADER_SPRITE, + SHADER_MODEL, SHADER_MODEL_LIGHTING, + SHADER_WATER, + SHADER_FOG, + SHADER_SKY, + + NUMBASESHADERS, +}; + +// Maximum amount of shader programs +// Must be higher than NUMBASESHADERS +#define HWR_MAXSHADERS 16 + +// Shader sources (vertex and fragment) +typedef struct +{ + char *vertex; + char *fragment; +} shadersource_t; + +// Custom shader reference table +typedef struct +{ + const char *type; + INT32 id; +} customshaderxlat_t; + +#endif + // ========================================================================== // RENDER MODES diff --git a/src/hardware/hw_drv.h b/src/hardware/hw_drv.h index 6f039cc3a..62eea9280 100644 --- a/src/hardware/hw_drv.h +++ b/src/hardware/hw_drv.h @@ -68,14 +68,13 @@ EXPORT void HWRAPI(DrawScreenFinalTexture) (int width, int height); EXPORT void HWRAPI(PostImgRedraw) (float points[SCREENVERTS][SCREENVERTS][2]); // jimita -EXPORT boolean HWRAPI(LoadShaders) (void); -EXPORT void HWRAPI(KillShaders) (void); +EXPORT boolean HWRAPI(CompileShaders) (void); +EXPORT void HWRAPI(CleanShaders) (void); EXPORT void HWRAPI(SetShader) (int shader); EXPORT void HWRAPI(UnSetShader) (void); EXPORT void HWRAPI(SetShaderInfo) (hwdshaderinfo_t info, INT32 value); -EXPORT void HWRAPI(LoadCustomShader) (int number, char *shader, size_t size, boolean fragment); -EXPORT boolean HWRAPI(InitCustomShaders) (void); +EXPORT void HWRAPI(LoadCustomShader) (int number, char *code, size_t size, boolean isfragment); // ========================================================================== // HWR DRIVER OBJECT, FOR CLIENT PROGRAM @@ -120,14 +119,13 @@ struct hwdriver_s MakeScreenFinalTexture pfnMakeScreenFinalTexture; DrawScreenFinalTexture pfnDrawScreenFinalTexture; - LoadShaders pfnLoadShaders; - KillShaders pfnKillShaders; + CompileShaders pfnCompileShaders; + CleanShaders pfnCleanShaders; SetShader pfnSetShader; UnSetShader pfnUnSetShader; SetShaderInfo pfnSetShaderInfo; LoadCustomShader pfnLoadCustomShader; - InitCustomShaders pfnInitCustomShaders; }; extern struct hwdriver_s hwdriver; diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index ddc935f0d..ca9fc36f3 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -560,11 +560,11 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool PolyFlags |= PF_Masked|PF_Modulated; if (PolyFlags & PF_Fog) - shader = 6; // fog shader + shader = SHADER_FOG; // fog shader else if (PolyFlags & PF_Ripple) - shader = 5; // water shader + shader = SHADER_WATER; // water shader else - shader = 1; // floor shader + shader = SHADER_FLOOR; // floor shader HWR_ProcessPolygon(&Surf, planeVerts, nrPlaneVerts, PolyFlags, shader, false); @@ -761,7 +761,7 @@ static void HWR_DrawSegsSplats(FSurfaceInfo * pSurf) break; } - HWD.pfnSetShader(2); // wall shader + HWD.pfnSetShader(SHADER_WALL); // wall shader HWD.pfnDrawPolygon(&pSurf, wallVerts, 4, i|PF_Modulated|PF_Decal); } } @@ -798,7 +798,7 @@ static void HWR_ProjectWall(FOutVector *wallVerts, FSurfaceInfo *pSurf, FBITFIEL { HWR_Lighting(pSurf, lightlevel, wallcolormap); - HWR_ProcessPolygon(pSurf, wallVerts, 4, blendmode|PF_Modulated|PF_Occlude, 2, false); // wall shader + HWR_ProcessPolygon(pSurf, wallVerts, 4, blendmode|PF_Modulated|PF_Occlude, SHADER_WALL, false); // wall shader #ifdef WALLSPLATS if (gl_curline->linedef->splats && cv_splats.value) @@ -2833,7 +2833,7 @@ static void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling, else blendmode |= PF_Masked|PF_Modulated|PF_Clip; - HWR_ProcessPolygon(&Surf, planeVerts, nrPlaneVerts, blendmode, 1, false); // floor shader + HWR_ProcessPolygon(&Surf, planeVerts, nrPlaneVerts, blendmode, SHADER_FLOOR, false); // floor shader } static void HWR_AddPolyObjectPlanes(void) @@ -3645,7 +3645,7 @@ static void HWR_DrawDropShadow(mobj_t *thing, fixed_t scale) HWR_Lighting(&sSurf, 0, colormap); sSurf.PolyColor.s.alpha = alpha; - HWR_ProcessPolygon(&sSurf, shadowVerts, 4, PF_Translucent|PF_Modulated|PF_Clip, 3, false); // sprite shader + HWR_ProcessPolygon(&sSurf, shadowVerts, 4, PF_Translucent|PF_Modulated|PF_Clip, SHADER_SPRITE, false); // sprite shader } // This is expecting a pointer to an array containing 4 wallVerts for a sprite @@ -3919,7 +3919,7 @@ static void HWR_SplitSprite(gl_vissprite_t *spr) Surf.PolyColor.s.alpha = alpha; - HWR_ProcessPolygon(&Surf, wallVerts, 4, blend|PF_Modulated|PF_Clip, 3, false); // sprite shader + HWR_ProcessPolygon(&Surf, wallVerts, 4, blend|PF_Modulated|PF_Clip, SHADER_SPRITE, false); // sprite shader if (use_linkdraw_hack) HWR_LinkDrawHackAdd(wallVerts, spr); @@ -3948,7 +3948,7 @@ static void HWR_SplitSprite(gl_vissprite_t *spr) Surf.PolyColor.s.alpha = alpha; - HWR_ProcessPolygon(&Surf, wallVerts, 4, blend|PF_Modulated|PF_Clip, 3, false); // sprite shader + HWR_ProcessPolygon(&Surf, wallVerts, 4, blend|PF_Modulated|PF_Clip, SHADER_SPRITE, false); // sprite shader if (use_linkdraw_hack) HWR_LinkDrawHackAdd(wallVerts, spr); @@ -4108,7 +4108,7 @@ static void HWR_DrawSprite(gl_vissprite_t *spr) if (!occlusion) use_linkdraw_hack = true; } - HWR_ProcessPolygon(&Surf, wallVerts, 4, blend|PF_Modulated|PF_Clip, 3, false); // sprite shader + HWR_ProcessPolygon(&Surf, wallVerts, 4, blend|PF_Modulated|PF_Clip, SHADER_SPRITE, false); // sprite shader if (use_linkdraw_hack) HWR_LinkDrawHackAdd(wallVerts, spr); @@ -4210,7 +4210,7 @@ static inline void HWR_DrawPrecipitationSprite(gl_vissprite_t *spr) blend = PF_Translucent|PF_Occlude; } - HWR_ProcessPolygon(&Surf, wallVerts, 4, blend|PF_Modulated|PF_Clip, 3, false); // sprite shader + HWR_ProcessPolygon(&Surf, wallVerts, 4, blend|PF_Modulated|PF_Clip, SHADER_SPRITE, false); // sprite shader } #endif @@ -5302,7 +5302,7 @@ static void HWR_DrawSkyBackground(player_t *player) v[0].t = v[1].t -= ((float) angle / angleturn); } - HWD.pfnSetShader(7); // sky shader + HWD.pfnSetShader(SHADER_SKY); // sky shader HWD.pfnDrawPolygon(NULL, v, 4, 0); HWD.pfnSetShader(0); } @@ -5927,7 +5927,6 @@ void HWR_Startup(void) // do this once if (!startupdone) { - INT32 i; CONS_Printf("HWR_Startup()...\n"); HWR_InitPolyPool(); @@ -5938,10 +5937,8 @@ void HWR_Startup(void) HWR_InitLight(); #endif - // read every custom shader - for (i = 0; i < numwadfiles; i++) - HWR_ReadShaders(i, (wadfiles[i]->type == RET_PK3)); - if (!HWR_LoadShaders()) + HWR_LoadAllCustomShaders(); + if (!HWR_CompileShaders()) gl_shadersavailable = false; } @@ -6033,7 +6030,7 @@ void HWR_RenderWall(FOutVector *wallVerts, FSurfaceInfo *pSurf, FBITFIELD blend, pSurf->PolyColor.s.alpha = alpha; // put the alpha back after lighting - shader = 2; // wall shader + shader = SHADER_WALL; // wall shader if (blend & PF_Environment) blendmode |= PF_Occlude; // PF_Occlude must be used for solid objects @@ -6041,7 +6038,7 @@ void HWR_RenderWall(FOutVector *wallVerts, FSurfaceInfo *pSurf, FBITFIELD blend, if (fogwall) { blendmode |= PF_Fog; - shader = 6; // fog shader + shader = SHADER_FOG; // fog shader } blendmode |= PF_Modulated; // No PF_Occlude means overlapping (incorrect) transparency @@ -6226,13 +6223,7 @@ void HWR_DrawScreenFinalTexture(int width, int height) } // jimita 18032019 -typedef struct -{ - char type[16]; - INT32 id; -} shaderxlat_t; - -static inline UINT16 HWR_CheckShader(UINT16 wadnum) +static inline UINT16 HWR_FindShaderDefs(UINT16 wadnum) { UINT16 i; lumpinfo_t *lump_p; @@ -6245,12 +6236,34 @@ static inline UINT16 HWR_CheckShader(UINT16 wadnum) return INT16_MAX; } -boolean HWR_LoadShaders(void) +boolean HWR_CompileShaders(void) { - return HWD.pfnInitCustomShaders(); + return HWD.pfnCompileShaders(); } -void HWR_ReadShaders(UINT16 wadnum, boolean PK3) +customshaderxlat_t shaderxlat[] = +{ + {"Flat", SHADER_FLOOR}, + {"WallTexture", SHADER_WALL}, + {"Sprite", SHADER_SPRITE}, + {"Model", SHADER_MODEL}, + {"ModelLighting", SHADER_MODEL_LIGHTING}, + {"WaterRipple", SHADER_WATER}, + {"Fog", SHADER_FOG}, + {"Sky", SHADER_SKY}, + {NULL, 0}, +}; + +void HWR_LoadAllCustomShaders(void) +{ + INT32 i; + + // read every custom shader + for (i = 0; i < numwadfiles; i++) + HWR_LoadCustomShadersFromFile(i, (wadfiles[i]->type == RET_PK3)); +} + +void HWR_LoadCustomShadersFromFile(UINT16 wadnum, boolean PK3) { UINT16 lump; char *shaderdef, *line; @@ -6261,19 +6274,7 @@ void HWR_ReadShaders(UINT16 wadnum, boolean PK3) int shadertype = 0; int i; - #define SHADER_TYPES 7 - shaderxlat_t shaderxlat[SHADER_TYPES] = - { - {"Flat", 1}, - {"WallTexture", 2}, - {"Sprite", 3}, - {"Model", 4}, - {"WaterRipple", 5}, - {"Fog", 6}, - {"Sky", 7}, - }; - - lump = HWR_CheckShader(wadnum); + lump = HWR_FindShaderDefs(wadnum); if (lump == INT16_MAX) return; @@ -6299,7 +6300,7 @@ void HWR_ReadShaders(UINT16 wadnum, boolean PK3) value = strtok(NULL, "\r\n "); if (!value) { - CONS_Alert(CONS_WARNING, "HWR_ReadShaders: Missing shader type (file %s, line %d)\n", wadfiles[wadnum]->filename, linenum); + CONS_Alert(CONS_WARNING, "HWR_LoadCustomShadersFromFile: Missing shader type (file %s, line %d)\n", wadfiles[wadnum]->filename, linenum); stoken = strtok(NULL, "\r\n"); // skip end of line goto skip_lump; } @@ -6318,19 +6319,19 @@ skip_lump: value = strtok(NULL, "\r\n= "); if (!value) { - CONS_Alert(CONS_WARNING, "HWR_ReadShaders: Missing shader target (file %s, line %d)\n", wadfiles[wadnum]->filename, linenum); + CONS_Alert(CONS_WARNING, "HWR_LoadCustomShadersFromFile: Missing shader target (file %s, line %d)\n", wadfiles[wadnum]->filename, linenum); stoken = strtok(NULL, "\r\n"); // skip end of line goto skip_field; } if (!shadertype) { - CONS_Alert(CONS_ERROR, "HWR_ReadShaders: Missing shader type (file %s, line %d)\n", wadfiles[wadnum]->filename, linenum); + CONS_Alert(CONS_ERROR, "HWR_LoadCustomShadersFromFile: Missing shader type (file %s, line %d)\n", wadfiles[wadnum]->filename, linenum); Z_Free(line); return; } - for (i = 0; i < SHADER_TYPES; i++) + for (i = 0; shaderxlat[i].type; i++) { if (!stricmp(shaderxlat[i].type, stoken)) { @@ -6356,7 +6357,7 @@ skip_lump: if (shader_lumpnum == INT16_MAX) { - CONS_Alert(CONS_ERROR, "HWR_ReadShaders: Missing shader source %s (file %s, line %d)\n", shader_lumpname, wadfiles[wadnum]->filename, linenum); + CONS_Alert(CONS_ERROR, "HWR_LoadCustomShadersFromFile: Missing shader source %s (file %s, line %d)\n", shader_lumpname, wadfiles[wadnum]->filename, linenum); Z_Free(shader_lumpname); continue; } @@ -6382,4 +6383,22 @@ skip_field: return; } +const char *HWR_GetShaderName(INT32 shader) +{ + INT32 i; + + if (shader) + { + for (i = 0; shaderxlat[i].type; i++) + { + if (shaderxlat[i].id == shader) + return shaderxlat[i].type; + } + + return "Unknown"; + } + + return "Default"; +} + #endif // HWRENDER diff --git a/src/hardware/hw_main.h b/src/hardware/hw_main.h index ddb3696b6..c1b55340f 100644 --- a/src/hardware/hw_main.h +++ b/src/hardware/hw_main.h @@ -68,8 +68,13 @@ void HWR_DrawScreenFinalTexture(int width, int height); void HWR_Lighting(FSurfaceInfo *Surface, INT32 light_level, extracolormap_t *colormap); UINT8 HWR_FogBlockAlpha(INT32 light, extracolormap_t *colormap); // Let's see if this can work -void HWR_ReadShaders(UINT16 wadnum, boolean PK3); -boolean HWR_LoadShaders(void); +boolean HWR_CompileShaders(void); + +void HWR_LoadAllCustomShaders(void); +void HWR_LoadCustomShadersFromFile(UINT16 wadnum, boolean PK3); +const char *HWR_GetShaderName(INT32 shader); + +extern customshaderxlat_t shaderxlat[]; extern CV_PossibleValue_t granisotropicmode_cons_t[]; diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index fa5156758..b25041448 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -1549,7 +1549,7 @@ boolean HWR_DrawModel(gl_vissprite_t *spr) p.mirror = atransform.mirror; // from Kart #endif - HWD.pfnSetShader(4); // model shader + HWD.pfnSetShader(SHADER_MODEL); // model shader HWD.pfnDrawModel(md2->model, frame, durs, tics, nextFrame, &p, finalscale, flip, hflip, &Surf); } diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index 461966224..1686bc0b5 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -91,9 +91,10 @@ static GLuint startScreenWipe = 0; static GLuint endScreenWipe = 0; static GLuint finalScreenTexture = 0; -// Lactozilla: Set shader programs and uniforms +// Lactozilla: Shader functions static void *Shader_Load(FSurfaceInfo *Surface, GLRGBAFloat *poly, GLRGBAFloat *tint, GLRGBAFloat *fade); static void Shader_SetUniforms(FSurfaceInfo *Surface, GLRGBAFloat *poly, GLRGBAFloat *tint, GLRGBAFloat *fade); +static void Shader_CompileError(const char *message, GLuint program, INT32 shadernum); // shortcut for ((float)1/i) static const GLfloat byte2float[256] = { @@ -576,15 +577,12 @@ static PFNglUniform2fv pglUniform2fv; static PFNglUniform3fv pglUniform3fv; static PFNglGetUniformLocation pglGetUniformLocation; -#define MAXSHADERS 16 -#define MAXSHADERPROGRAMS 16 - // 18032019 -static char *gl_customvertexshaders[MAXSHADERS]; -static char *gl_customfragmentshaders[MAXSHADERS]; static GLuint gl_currentshaderprogram = 0; static boolean gl_shaderprogramchanged = true; +static shadersource_t gl_customshaders[HWR_MAXSHADERS]; + // 13062019 typedef enum { @@ -608,17 +606,59 @@ typedef struct gl_shaderprogram_s boolean custom; GLint uniforms[gluniform_max+1]; } gl_shaderprogram_t; -static gl_shaderprogram_t gl_shaderprograms[MAXSHADERPROGRAMS]; +static gl_shaderprogram_t gl_shaderprograms[HWR_MAXSHADERS]; // Shader info static INT32 shader_leveltime = 0; -// ======================== -// Fragment shader macros -// ======================== +// ================ +// Vertex shaders +// ================ // -// GLSL Software fragment shader +// Generic vertex shader +// + +#define GLSL_DEFAULT_VERTEX_SHADER \ + "void main()\n" \ + "{\n" \ + "gl_Position = gl_ProjectionMatrix * gl_ModelViewMatrix * gl_Vertex;\n" \ + "gl_FrontColor = gl_Color;\n" \ + "gl_TexCoord[0].xy = gl_MultiTexCoord0.xy;\n" \ + "gl_ClipVertex = gl_ModelViewMatrix * gl_Vertex;\n" \ + "}\0" + +// replicates the way fixed function lighting is used by the model lighting option, +// stores the lighting result to gl_Color +// (ambient lighting of 0.75 and diffuse lighting from above) +#define GLSL_MODEL_LIGHTING_VERTEX_SHADER \ + "void main()\n" \ + "{\n" \ + "float nDotVP = dot(gl_Normal, vec3(0, 1, 0));\n" \ + "float light = 0.75 + max(nDotVP, 0.0);\n" \ + "gl_Position = gl_ProjectionMatrix * gl_ModelViewMatrix * gl_Vertex;\n" \ + "gl_FrontColor = vec4(light, light, light, 1.0);\n" \ + "gl_TexCoord[0].xy = gl_MultiTexCoord0.xy;\n" \ + "gl_ClipVertex = gl_ModelViewMatrix * gl_Vertex;\n" \ + "}\0" + +// ================== +// Fragment shaders +// ================== + +// +// Generic fragment shader +// + +#define GLSL_DEFAULT_FRAGMENT_SHADER \ + "uniform sampler2D tex;\n" \ + "uniform vec4 poly_color;\n" \ + "void main(void) {\n" \ + "gl_FragColor = texture2D(tex, gl_TexCoord[0].st) * poly_color;\n" \ + "}\0" + +// +// Software fragment shader // #define GLSL_DOOM_COLORMAP \ @@ -760,110 +800,51 @@ static INT32 shader_leveltime = 0; "}\0" // -// GLSL generic fragment shader +// Sky fragment shader // -#define GLSL_DEFAULT_FRAGMENT_SHADER \ +#define GLSL_SKY_FRAGMENT_SHADER \ "uniform sampler2D tex;\n" \ - "uniform vec4 poly_color;\n" \ "void main(void) {\n" \ - "gl_FragColor = texture2D(tex, gl_TexCoord[0].st) * poly_color;\n" \ - "}\0" + "gl_FragColor = texture2D(tex, gl_TexCoord[0].st);\n" \ + "}\0" \ -static const char *fragment_shaders[] = { - // Default fragment shader - GLSL_DEFAULT_FRAGMENT_SHADER, +// ================ +// Shader sources +// ================ - // Floor fragment shader - GLSL_SOFTWARE_FRAGMENT_SHADER, +static struct { + const char *vertex; + const char *fragment; +} const gl_shadersources[] = { + // Default shader + {GLSL_DEFAULT_VERTEX_SHADER, GLSL_DEFAULT_FRAGMENT_SHADER}, - // Wall fragment shader - GLSL_SOFTWARE_FRAGMENT_SHADER, + // Floor shader + {GLSL_DEFAULT_VERTEX_SHADER, GLSL_SOFTWARE_FRAGMENT_SHADER}, - // Sprite fragment shader - GLSL_SOFTWARE_FRAGMENT_SHADER, + // Wall shader + {GLSL_DEFAULT_VERTEX_SHADER, GLSL_SOFTWARE_FRAGMENT_SHADER}, - // Model fragment shader - GLSL_SOFTWARE_FRAGMENT_SHADER, + // Sprite shader + {GLSL_DEFAULT_VERTEX_SHADER, GLSL_SOFTWARE_FRAGMENT_SHADER}, - // Water fragment shader - GLSL_WATER_FRAGMENT_SHADER, + // Model shader + {GLSL_DEFAULT_VERTEX_SHADER, GLSL_SOFTWARE_FRAGMENT_SHADER}, - // Fog fragment shader - GLSL_FOG_FRAGMENT_SHADER, + // Model shader + diffuse lighting from above + {GLSL_MODEL_LIGHTING_VERTEX_SHADER, GLSL_SOFTWARE_MODEL_LIGHTING_FRAGMENT_SHADER}, - // Sky fragment shader - "uniform sampler2D tex;\n" - "void main(void) {\n" - "gl_FragColor = texture2D(tex, gl_TexCoord[0].st);\n" - "}\0", + // Water shader + {GLSL_DEFAULT_VERTEX_SHADER, GLSL_WATER_FRAGMENT_SHADER}, - // Model fragment shader + diffuse lighting from above - GLSL_SOFTWARE_MODEL_LIGHTING_FRAGMENT_SHADER, + // Fog shader + {GLSL_DEFAULT_VERTEX_SHADER, GLSL_FOG_FRAGMENT_SHADER}, - NULL, -}; + // Sky shader + {GLSL_DEFAULT_VERTEX_SHADER, GLSL_SKY_FRAGMENT_SHADER}, -// ====================== -// Vertex shader macros -// ====================== - -// -// GLSL generic vertex shader -// - -#define GLSL_DEFAULT_VERTEX_SHADER \ - "void main()\n" \ - "{\n" \ - "gl_Position = gl_ProjectionMatrix * gl_ModelViewMatrix * gl_Vertex;\n" \ - "gl_FrontColor = gl_Color;\n" \ - "gl_TexCoord[0].xy = gl_MultiTexCoord0.xy;\n" \ - "gl_ClipVertex = gl_ModelViewMatrix * gl_Vertex;\n" \ - "}\0" - -// replicates the way fixed function lighting is used by the model lighting option, -// stores the lighting result to gl_Color -// (ambient lighting of 0.75 and diffuse lighting from above) -#define GLSL_MODEL_LIGHTING_VERTEX_SHADER \ - "void main()\n" \ - "{\n" \ - "float nDotVP = dot(gl_Normal, vec3(0, 1, 0));\n" \ - "float light = 0.75 + max(nDotVP, 0.0);\n" \ - "gl_Position = gl_ProjectionMatrix * gl_ModelViewMatrix * gl_Vertex;\n" \ - "gl_FrontColor = vec4(light, light, light, 1.0);\n" \ - "gl_TexCoord[0].xy = gl_MultiTexCoord0.xy;\n" \ - "gl_ClipVertex = gl_ModelViewMatrix * gl_Vertex;\n" \ - "}\0" - -static const char *vertex_shaders[] = { - // Default vertex shader - GLSL_DEFAULT_VERTEX_SHADER, - - // Floor vertex shader - GLSL_DEFAULT_VERTEX_SHADER, - - // Wall vertex shader - GLSL_DEFAULT_VERTEX_SHADER, - - // Sprite vertex shader - GLSL_DEFAULT_VERTEX_SHADER, - - // Model vertex shader - GLSL_DEFAULT_VERTEX_SHADER, - - // Water vertex shader - GLSL_DEFAULT_VERTEX_SHADER, - - // Fog vertex shader - GLSL_DEFAULT_VERTEX_SHADER, - - // Sky vertex shader - GLSL_DEFAULT_VERTEX_SHADER, - - // Model vertex shader + diffuse lighting from above - GLSL_MODEL_LIGHTING_VERTEX_SHADER, - - NULL, + {NULL, NULL}, }; #endif // GL_SHADERS @@ -909,7 +890,7 @@ void SetupGLFunc4(void) } // jimita -EXPORT boolean HWRAPI(LoadShaders) (void) +EXPORT boolean HWRAPI(CompileShaders) (void) { #ifdef GL_SHADERS GLuint gl_vertShader, gl_fragShader; @@ -917,25 +898,23 @@ EXPORT boolean HWRAPI(LoadShaders) (void) if (!pglUseProgram) return false; - gl_customvertexshaders[0] = NULL; - gl_customfragmentshaders[0] = NULL; + gl_customshaders[0].vertex = NULL; + gl_customshaders[0].fragment = NULL; - for (i = 0; vertex_shaders[i] && fragment_shaders[i]; i++) + for (i = 0; gl_shadersources[i].vertex && gl_shadersources[i].fragment; i++) { gl_shaderprogram_t *shader; - const GLchar* vert_shader = vertex_shaders[i]; - const GLchar* frag_shader = fragment_shaders[i]; - boolean custom = ((gl_customvertexshaders[i] || gl_customfragmentshaders[i]) && (i > 0)); + const GLchar *vert_shader = gl_shadersources[i].vertex; + const GLchar *frag_shader = gl_shadersources[i].fragment; + boolean custom = ((gl_customshaders[i].vertex || gl_customshaders[i].fragment) && (i > 0)); // 18032019 - if (gl_customvertexshaders[i]) - vert_shader = gl_customvertexshaders[i]; - if (gl_customfragmentshaders[i]) - frag_shader = gl_customfragmentshaders[i]; + if (gl_customshaders[i].vertex) + vert_shader = gl_customshaders[i].vertex; + if (gl_customshaders[i].fragment) + frag_shader = gl_customshaders[i].fragment; - if (i >= MAXSHADERS) - break; - if (i >= MAXSHADERPROGRAMS) + if (i >= HWR_MAXSHADERS) break; shader = &gl_shaderprograms[i]; @@ -948,7 +927,7 @@ EXPORT boolean HWRAPI(LoadShaders) (void) gl_vertShader = pglCreateShader(GL_VERTEX_SHADER); if (!gl_vertShader) { - GL_MSG_Error("LoadShaders: Error creating vertex shader %d\n", i); + GL_MSG_Error("CompileShaders: Error creating vertex shader %s\n", HWR_GetShaderName(i)); continue; } @@ -959,15 +938,7 @@ EXPORT boolean HWRAPI(LoadShaders) (void) pglGetShaderiv(gl_vertShader, GL_COMPILE_STATUS, &result); if (result == GL_FALSE) { - GLchar* infoLog; - GLint logLength; - - pglGetShaderiv(gl_vertShader, GL_INFO_LOG_LENGTH, &logLength); - - infoLog = malloc(logLength); - pglGetShaderInfoLog(gl_vertShader, logLength, NULL, infoLog); - - GL_MSG_Error("LoadShaders: Error compiling vertex shader %d\n%s", i, infoLog); + Shader_CompileError("Error compiling vertex shader", gl_vertShader, i); continue; } @@ -977,7 +948,7 @@ EXPORT boolean HWRAPI(LoadShaders) (void) gl_fragShader = pglCreateShader(GL_FRAGMENT_SHADER); if (!gl_fragShader) { - GL_MSG_Error("LoadShaders: Error creating fragment shader %d\n", i); + GL_MSG_Error("CompileShaders: Error creating fragment shader %s\n", HWR_GetShaderName(i)); continue; } @@ -988,15 +959,7 @@ EXPORT boolean HWRAPI(LoadShaders) (void) pglGetShaderiv(gl_fragShader, GL_COMPILE_STATUS, &result); if (result == GL_FALSE) { - GLchar* infoLog; - GLint logLength; - - pglGetShaderiv(gl_fragShader, GL_INFO_LOG_LENGTH, &logLength); - - infoLog = malloc(logLength); - pglGetShaderInfoLog(gl_fragShader, logLength, NULL, infoLog); - - GL_MSG_Error("LoadShaders: Error compiling fragment shader %d\n%s", i, infoLog); + Shader_CompileError("Error compiling fragment shader", gl_fragShader, i); continue; } @@ -1017,7 +980,7 @@ EXPORT boolean HWRAPI(LoadShaders) (void) { shader->program = 0; shader->custom = false; - GL_MSG_Error("LoadShaders: Error linking shader program %d\n", i); + GL_MSG_Error("CompileShaders: Error linking shader program %s\n", HWR_GetShaderName(i)); continue; } @@ -1037,8 +1000,10 @@ EXPORT boolean HWRAPI(LoadShaders) (void) #undef GETUNI } -#endif return true; +#else + return false; +#endif } // @@ -1066,25 +1031,34 @@ EXPORT void HWRAPI(SetShaderInfo) (hwdshaderinfo_t info, INT32 value) // // Custom shader loading // -EXPORT void HWRAPI(LoadCustomShader) (int number, char *shader, size_t size, boolean fragment) +EXPORT void HWRAPI(LoadCustomShader) (int number, char *code, size_t size, boolean isfragment) { #ifdef GL_SHADERS - if (!pglUseProgram) return; - if (number < 1 || number > MAXSHADERS) - I_Error("LoadCustomShader(): cannot load shader %d (max %d)", number, MAXSHADERS); + shadersource_t *shader; - if (fragment) - { - gl_customfragmentshaders[number] = malloc(size+1); - strncpy(gl_customfragmentshaders[number], shader, size); - gl_customfragmentshaders[number][size] = 0; + if (!pglUseProgram) + return; + + if (number < 1 || number > HWR_MAXSHADERS) + I_Error("LoadCustomShader: cannot load shader %d (min 1, max %d)", number, HWR_MAXSHADERS); + else if (code == NULL) + I_Error("LoadCustomShader: empty shader"); + + shader = &gl_customshaders[number]; + +#define COPYSHADER(source) { \ + if (shader->source) \ + free(shader->source); \ + shader->source = malloc(size+1); \ + strncpy(shader->source, code, size); \ + shader->source[size] = 0; \ } + + if (isfragment) + COPYSHADER(fragment) else - { - gl_customvertexshaders[number] = malloc(size+1); - strncpy(gl_customvertexshaders[number], shader, size); - gl_customvertexshaders[number][size] = 0; - } + COPYSHADER(vertex) + #else (void)number; (void)shader; @@ -1093,14 +1067,6 @@ EXPORT void HWRAPI(LoadCustomShader) (int number, char *shader, size_t size, boo #endif } -EXPORT boolean HWRAPI(InitCustomShaders) (void) -{ -#ifdef GL_SHADERS - KillShaders(); - return LoadShaders(); -#endif -} - EXPORT void HWRAPI(SetShader) (int shader) { #ifdef GL_SHADERS @@ -1108,9 +1074,9 @@ EXPORT void HWRAPI(SetShader) (int shader) { // If using model lighting, set the appropriate shader. // However don't override a custom shader. - // Should use an enum or something... - if (shader == 4 && model_lighting && !gl_shaderprograms[4].custom) - shader = 8; + if (shader == SHADER_MODEL && model_lighting + && !(gl_shaderprograms[SHADER_MODEL].custom && !gl_shaderprograms[SHADER_MODEL_LIGHTING].custom)) + shader = SHADER_MODEL_LIGHTING; if ((GLuint)shader != gl_currentshaderprogram) { gl_currentshaderprogram = shader; @@ -1135,9 +1101,23 @@ EXPORT void HWRAPI(UnSetShader) (void) #endif } -EXPORT void HWRAPI(KillShaders) (void) +EXPORT void HWRAPI(CleanShaders) (void) { - // unused......................... + INT32 i; + + for (i = 1; i < HWR_MAXSHADERS; i++) + { + shadersource_t *shader = &gl_customshaders[i]; + + if (shader->vertex) + free(shader->vertex); + + if (shader->fragment) + free(shader->fragment); + + shader->vertex = NULL; + shader->fragment = NULL; + } } // -----------------+ @@ -1996,6 +1976,25 @@ static void Shader_SetUniforms(FSurfaceInfo *Surface, GLRGBAFloat *poly, GLRGBAF #endif } +static void Shader_CompileError(const char *message, GLuint program, INT32 shadernum) +{ + GLchar *infoLog = NULL; + GLint logLength; + + pglGetShaderiv(program, GL_INFO_LOG_LENGTH, &logLength); + + if (logLength) + { + infoLog = malloc(logLength); + pglGetShaderInfoLog(program, logLength, NULL, infoLog); + } + + GL_MSG_Error("CompileShaders: %s (%s)\n%s", message, HWR_GetShaderName(shadernum), (infoLog ? infoLog : "")); + + if (infoLog) + free(infoLog); +} + // code that is common between DrawPolygon and DrawIndexedTriangles // the corona thing is there too, i have no idea if that stuff works with DrawIndexedTriangles and batching static void PreparePolygon(FSurfaceInfo *pSurf, FOutVector *pOutVerts, FBITFIELD PolyFlags) diff --git a/src/sdl/hwsym_sdl.c b/src/sdl/hwsym_sdl.c index 416c8d2f5..e545bbb63 100644 --- a/src/sdl/hwsym_sdl.c +++ b/src/sdl/hwsym_sdl.c @@ -104,14 +104,13 @@ void *hwSym(const char *funcName,void *handle) GETFUNC(MakeScreenFinalTexture); GETFUNC(DrawScreenFinalTexture); - GETFUNC(LoadShaders); - GETFUNC(KillShaders); + GETFUNC(CompileShaders); + GETFUNC(CleanShaders); GETFUNC(SetShader); GETFUNC(UnSetShader); GETFUNC(SetShaderInfo); GETFUNC(LoadCustomShader); - GETFUNC(InitCustomShaders); #else //HWRENDER if (0 == strcmp("FinishUpdate", funcName)) diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index 01194a02f..fb6cbea74 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -1660,7 +1660,7 @@ static void Impl_SetWindowName(const char *title) static void Impl_SetWindowIcon(void) { if (window && icoSurface) - SDL_SetWindowIcon(window, icoSurface); + SDL_SetWindowIcon(window, icoSurface); } static void Impl_VideoSetupSDLBuffer(void) @@ -1770,7 +1770,7 @@ void I_StartupGraphics(void) // Window icon #ifdef HAVE_IMAGE icoSurface = IMG_ReadXPMFromArray(SDL_icon_xpm); -#endif +#endif // Fury: we do window initialization after GL setup to allow // SDL_GL_LoadLibrary to work well on Windows @@ -1855,14 +1855,13 @@ void VID_StartupOpenGL(void) HWD.pfnMakeScreenFinalTexture=hwSym("MakeScreenFinalTexture",NULL); HWD.pfnDrawScreenFinalTexture=hwSym("DrawScreenFinalTexture",NULL); - HWD.pfnLoadShaders = hwSym("LoadShaders",NULL); - HWD.pfnKillShaders = hwSym("KillShaders",NULL); + HWD.pfnCompileShaders = hwSym("CompileShaders",NULL); + HWD.pfnCleanShaders = hwSym("CleanShaders",NULL); HWD.pfnSetShader = hwSym("SetShader",NULL); HWD.pfnUnSetShader = hwSym("UnSetShader",NULL); HWD.pfnSetShaderInfo = hwSym("SetShaderInfo",NULL); HWD.pfnLoadCustomShader = hwSym("LoadCustomShader",NULL); - HWD.pfnInitCustomShaders= hwSym("InitCustomShaders",NULL); vid_opengl_state = HWD.pfnInit() ? 1 : -1; // let load the OpenGL library diff --git a/src/w_wad.c b/src/w_wad.c index e4a19f30e..a54075121 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -852,8 +852,8 @@ UINT16 W_InitFile(const char *filename, boolean mainfile, boolean startup) // Read shaders from file if (rendermode == render_opengl && (vid_opengl_state == 1)) { - HWR_ReadShaders(numwadfiles - 1, (type == RET_PK3)); - HWR_LoadShaders(); + HWR_LoadCustomShadersFromFile(numwadfiles - 1, (type == RET_PK3)); + HWR_CompileShaders(); } #endif // HWRENDER From 91ed56ef40e96629d65a28201ff9b6589e641f2a Mon Sep 17 00:00:00 2001 From: Jaime Passos Date: Sat, 8 Aug 2020 05:16:47 -0300 Subject: [PATCH 0072/1080] Refactor patch loading --- src/console.c | 5 +- src/d_main.c | 37 +---- src/dehacked.c | 2 +- src/f_finale.c | 25 +--- src/hardware/hw_cache.c | 244 ++++++++++++++----------------- src/hardware/hw_data.h | 15 +- src/hardware/hw_draw.c | 93 ++++++------ src/hardware/hw_drv.h | 2 + src/hardware/hw_glob.h | 27 ++-- src/hardware/hw_main.c | 58 ++++---- src/hardware/hw_main.h | 6 +- src/hardware/hw_md2.c | 205 +++++++++++++++----------- src/hardware/r_opengl/r_opengl.c | 15 +- src/hu_stuff.c | 3 - src/lua_infolib.c | 4 +- src/m_menu.c | 43 +----- src/r_data.c | 6 +- src/r_defs.h | 22 ++- src/r_main.c | 8 - src/r_main.h | 1 - src/r_patch.c | 220 ++++++++++++++++------------ src/r_patch.h | 20 ++- src/r_segs.c | 2 +- src/r_things.c | 18 +-- src/screen.c | 3 - src/sdl/hwsym_sdl.c | 1 + src/sdl/i_video.c | 5 +- src/st_stuff.c | 3 - src/v_video.c | 10 +- src/w_wad.c | 71 +++------ src/w_wad.h | 7 - src/win32/win_dll.c | 2 + src/y_inter.c | 73 +-------- src/z_zone.c | 27 ---- src/z_zone.h | 6 - 35 files changed, 557 insertions(+), 732 deletions(-) diff --git a/src/console.c b/src/console.c index aac94d473..280dc4f22 100644 --- a/src/console.c +++ b/src/console.c @@ -1555,7 +1555,7 @@ static void CON_DrawBackpic(void) // then fill the sides with a solid color. if (x > 0) { - column_t *column = (column_t *)((UINT8 *)(con_backpic) + LONG(con_backpic->columnofs[0])); + column_t *column = (column_t *)((UINT8 *)(con_backpic->columns) + (con_backpic->columnofs[0])); if (!column->topdelta) { UINT8 *source = (UINT8 *)(column) + 3; @@ -1648,9 +1648,6 @@ void CON_Drawer(void) if (!con_started || !graphics_started) return; - if (needpatchrecache) - HU_LoadGraphics(); - if (con_recalc) { CON_RecalcSize(); diff --git a/src/d_main.c b/src/d_main.c index 6bc42da14..ee3ce699c 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -110,8 +110,6 @@ boolean devparm = false; // started game with -devparm boolean singletics = false; // timedemo boolean lastdraw = false; -static void D_CheckRendererState(void); - postimg_t postimgtype = postimg_none; INT32 postimgparam; postimg_t postimgtype2 = postimg_none; @@ -245,9 +243,7 @@ static void D_Display(void) // create plane polygons, if necessary. // 3. Functions related to switching video // modes (resolution) are called. - // 4. Patch data is freed from memory, - // and recached if necessary. - // 5. The frame is ready to be drawn! + // 4. The frame is ready to be drawn! // stop movie if needs to change renderer if (setrenderneeded && (moviemode == MM_APNG)) @@ -284,9 +280,6 @@ static void D_Display(void) forcerefresh = true; // force background redraw } - // Lactozilla: Renderer switching - D_CheckRendererState(); - // draw buffered stuff to screen // Used only by linux GGI version I_UpdateNoBlit(); @@ -679,26 +672,6 @@ static void D_Display(void) I_FinishUpdate(); // page flip or blit buffer rs_swaptime = I_GetTimeMicros() - rs_swaptime; } - - needpatchflush = false; - needpatchrecache = false; -} - -// Check the renderer's state -// after a possible renderer switch. -void D_CheckRendererState(void) -{ - // flush all patches from memory - if (needpatchflush) - { - Z_FlushCachedPatches(); - needpatchflush = false; - } - - // some patches have been freed, - // so cache them again - if (needpatchrecache) - R_ReloadHUDGraphics(); } // ========================================================================= @@ -1433,18 +1406,10 @@ void D_SRB2Main(void) if ((setrenderneeded != 0) && (setrenderneeded != rendermode)) { CONS_Printf(M_GetText("Switching the renderer...\n")); - Z_PreparePatchFlush(); - - // set needpatchflush / needpatchrecache true for D_CheckRendererState - needpatchflush = true; - needpatchrecache = true; // Set cv_renderer to the new render mode VID_CheckRenderer(); SCR_ChangeRendererCVars(rendermode); - - // check the renderer's state - D_CheckRendererState(); } wipegamestate = gamestate; diff --git a/src/dehacked.c b/src/dehacked.c index 9d6729dc2..c801dcde9 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -1046,7 +1046,7 @@ static void readspriteinfo(MYFILE *f, INT32 num, boolean sprite2) #ifdef ROTSPRITE if ((sprites != NULL) && (!sprite2)) - R_FreeSingleRotSprite(&sprites[num]); + R_FreeRotSprite(&sprites[num]); #endif do diff --git a/src/f_finale.c b/src/f_finale.c index 8d39a7533..7cc5467c2 100644 --- a/src/f_finale.c +++ b/src/f_finale.c @@ -1901,13 +1901,6 @@ void F_EndingDrawer(void) INT32 x, y, i, j, parallaxticker; patch_t *rockpat; - if (needpatchrecache) - { - F_CacheEnding(); - if (goodending && finalecount >= INFLECTIONPOINT) // time to swap some assets - F_CacheGoodEnding(); - } - if (!goodending || finalecount < INFLECTIONPOINT) rockpat = W_CachePatchName("ROID0000", PU_PATCH); else @@ -2706,17 +2699,12 @@ static void F_FigureActiveTtScale(void) SINT8 newttscale = max(1, min(6, vid.dupx)); SINT8 oldttscale = activettscale; - if (needpatchrecache) - ttloaded[0] = ttloaded[1] = ttloaded[2] = ttloaded[3] = ttloaded[4] = ttloaded[5] = 0; - else - { - if (newttscale == testttscale) - return; + if (newttscale == testttscale) + return; - // We have a new ttscale, so load gfx - if(oldttscale > 0) - F_UnloadAlacroixGraphics(oldttscale); - } + // We have a new ttscale, so load gfx + if(oldttscale > 0) + F_UnloadAlacroixGraphics(oldttscale); testttscale = newttscale; @@ -2750,9 +2738,6 @@ void F_TitleScreenDrawer(void) if (modeattacking) return; // We likely came here from retrying. Don't do a damn thing. - if (needpatchrecache && (curttmode != TTMODE_ALACROIX)) - F_CacheTitleScreen(); - // Draw that sky! if (curbgcolor >= 0) V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, curbgcolor); diff --git a/src/hardware/hw_cache.c b/src/hardware/hw_cache.c index ed3b6afee..a26721169 100644 --- a/src/hardware/hw_cache.c +++ b/src/hardware/hw_cache.c @@ -309,7 +309,7 @@ static void HWR_DrawPatchInCache(GLMipmap_t *mipmap, // Draw each column to the block cache for (; ncols--; block += bpp, xfrac += xfracstep) { - patchcol = (const column_t *)((const UINT8 *)realpatch + LONG(realpatch->columnofs[xfrac>>FRACBITS])); + patchcol = (const column_t *)((const UINT8 *)realpatch->columns + (realpatch->columnofs[xfrac>>FRACBITS])); HWR_DrawColumnInCache(patchcol, block, mipmap, pblockheight, blockmodulo, @@ -323,7 +323,7 @@ static void HWR_DrawPatchInCache(GLMipmap_t *mipmap, static void HWR_DrawTexturePatchInCache(GLMipmap_t *mipmap, INT32 pblockwidth, INT32 pblockheight, texture_t *texture, texpatch_t *patch, - const patch_t *realpatch) + const softwarepatch_t *realpatch) { INT32 x, x1, x2; INT32 col, ncols; @@ -394,7 +394,7 @@ static void HWR_DrawTexturePatchInCache(GLMipmap_t *mipmap, bpp = format2bpp(mipmap->format); if (bpp < 1 || bpp > 4) - I_Error("HWR_DrawPatchInCache: no drawer defined for this bpp (%d)\n",bpp); + I_Error("HWR_DrawTexturePatchInCache: no drawer defined for this bpp (%d)\n",bpp); // NOTE: should this actually be pblockwidth*bpp? blockmodulo = pblockwidth*bpp; @@ -449,7 +449,7 @@ static void HWR_GenerateTexture(INT32 texnum, GLMapTexture_t *grtex) UINT8 *block; texture_t *texture; texpatch_t *patch; - patch_t *realpatch; + softwarepatch_t *realpatch; UINT8 *pdata; INT32 blockwidth, blockheight, blocksize; @@ -505,7 +505,7 @@ static void HWR_GenerateTexture(INT32 texnum, GLMapTexture_t *grtex) boolean dealloc = true; size_t lumplength = W_LumpLengthPwad(patch->wad, patch->lump); pdata = W_CacheLumpNumPwad(patch->wad, patch->lump, PU_CACHE); - realpatch = (patch_t *)pdata; + realpatch = (softwarepatch_t *)pdata; #ifndef NO_PNG_LUMPS if (R_IsLumpPNG((UINT8 *)realpatch, lumplength)) @@ -547,36 +547,20 @@ static void HWR_GenerateTexture(INT32 texnum, GLMapTexture_t *grtex) // patch may be NULL if grMipmap has been initialised already and makebitmap is false void HWR_MakePatch (const patch_t *patch, GLPatch_t *grPatch, GLMipmap_t *grMipmap, boolean makebitmap) { -#ifndef NO_PNG_LUMPS - // lump is a png so convert it - size_t len = W_LumpLengthPwad(grPatch->wadnum, grPatch->lumpnum); - if ((patch != NULL) && R_IsLumpPNG((const UINT8 *)patch, len)) - patch = R_PNGToPatch((const UINT8 *)patch, len, NULL); -#endif - - // don't do it twice (like a cache) if (grMipmap->width == 0) { - // save the original patch header so that the GLPatch can be casted - // into a standard patch_t struct and the existing code can get the - // orginal patch dimensions and offsets. - grPatch->width = SHORT(patch->width); - grPatch->height = SHORT(patch->height); - grPatch->leftoffset = SHORT(patch->leftoffset); - grPatch->topoffset = SHORT(patch->topoffset); - grMipmap->width = grMipmap->height = 1; - while (grMipmap->width < grPatch->width) grMipmap->width <<= 1; - while (grMipmap->height < grPatch->height) grMipmap->height <<= 1; + while (grMipmap->width < patch->width) grMipmap->width <<= 1; + while (grMipmap->height < patch->height) grMipmap->height <<= 1; // no wrap around, no chroma key grMipmap->flags = 0; + // setup the texture info grMipmap->format = patchformat; - //grPatch->max_s = grPatch->max_t = 1.0f; - grPatch->max_s = (float)grPatch->width / (float)grMipmap->width; - grPatch->max_t = (float)grPatch->height / (float)grMipmap->height; + grPatch->max_s = (float)patch->width / (float)grMipmap->width; + grPatch->max_t = (float)patch->height / (float)grMipmap->height; } Z_Free(grMipmap->data); @@ -588,7 +572,7 @@ void HWR_MakePatch (const patch_t *patch, GLPatch_t *grPatch, GLMipmap_t *grMipm HWR_DrawPatchInCache(grMipmap, grMipmap->width, grMipmap->height, - grPatch->width, grPatch->height, + patch->width, patch->height, patch); } } @@ -608,13 +592,33 @@ void HWR_InitTextureCache(void) gl_flats = NULL; } -// Callback function for HWR_FreeTextureCache. -static void FreeMipmapColormap(INT32 patchnum, void *patch) +void HWR_FreeTexture(patch_t *patch) { - GLPatch_t* const pat = patch; - (void)patchnum; //unused + if (patch->hardware) + { + GLPatch_t *grPatch = patch->hardware; + + HWR_FreeTextureColormaps(patch); + + if (grPatch->mipmap && (rendermode == render_opengl)) + HWD.pfnDeleteTexture(grPatch->mipmap); + + Z_Free(patch->hardware); + } + + patch->hardware = NULL; +} + +// Called by HWR_FreeTextureCache. +void HWR_FreeTextureColormaps(patch_t *patch) +{ + GLPatch_t *pat; // The patch must be valid, obviously + if (!patch) + return; + + pat = patch->hardware; if (!pat) return; @@ -642,6 +646,7 @@ static void FreeMipmapColormap(INT32 patchnum, void *patch) if (next->data) Z_Free(next->data); next->data = NULL; + HWD.pfnDeleteTexture(next); // Free the old colormap mipmap from memory. free(next); @@ -663,7 +668,11 @@ void HWR_FreeMipmapCache(void) // Alam: free the Z_Blocks before freeing it's users // free all patch colormaps after each level: must be done after ClearMipMapCache! for (i = 0; i < numwadfiles; i++) - M_AATreeIterate(wadfiles[i]->hwrcache, FreeMipmapColormap); + { + INT32 j = 0; + for (; j < wadfiles[i]->numlumps; j++) + HWR_FreeTextureColormaps(wadfiles[i]->patchcache[j]); + } } void HWR_FreeTextureCache(void) @@ -733,7 +742,6 @@ GLMapTexture_t *HWR_GetTexture(INT32 tex) // If hardware does not have the texture, then call pfnSetTexture to upload it if (!grtex->mipmap.downloaded) HWD.pfnSetTexture(&grtex->mipmap); - HWR_SetCurrentTexture(&grtex->mipmap); // The system-memory data can be purged now. @@ -809,14 +817,13 @@ void HWR_LiterallyGetFlat(lumpnum_t flatlumpnum) if (flatlumpnum == LUMPERROR) return; - grmip = HWR_GetCachedGLPatch(flatlumpnum)->mipmap; + grmip = ((GLPatch_t *)HWR_GetCachedGLPatch(flatlumpnum)->hardware)->mipmap; if (!grmip->downloaded && !grmip->data) HWR_CacheFlat(grmip, flatlumpnum); // If hardware does not have the texture, then call pfnSetTexture to upload it if (!grmip->downloaded) HWD.pfnSetTexture(grmip); - HWR_SetCurrentTexture(grmip); // The system-memory data can be purged now. @@ -854,7 +861,6 @@ void HWR_GetLevelFlat(levelflat_t *levelflat) // If hardware does not have the texture, then call pfnSetTexture to upload it if (!grtex->mipmap.downloaded) HWD.pfnSetTexture(&grtex->mipmap); - HWR_SetCurrentTexture(&grtex->mipmap); // The system-memory data can be purged now. @@ -864,89 +870,61 @@ void HWR_GetLevelFlat(levelflat_t *levelflat) HWR_SetCurrentTexture(NULL); } -// -// HWR_LoadMappedPatch(): replace the skin color of the sprite in cache -// : load it first in doom cache if not already -// -static void HWR_LoadMappedPatch(GLMipmap_t *grmip, GLPatch_t *gpatch) +// --------------------+ +// HWR_LoadPatchMipmap : Generates a patch into a mipmap, usually the mipmap inside the patch itself +// --------------------+ +static void HWR_LoadPatchMipmap(patch_t *patch, GLMipmap_t *grMipmap) { - if (!grmip->downloaded && !grmip->data) - { - patch_t *patch = gpatch->rawpatch; - if (!patch) - patch = W_CacheLumpNumPwad(gpatch->wadnum, gpatch->lumpnum, PU_STATIC); - HWR_MakePatch(patch, gpatch, grmip, true); - - // You can't free rawpatch for some reason? - // (Obviously I can't, sprite rotation needs that...) - if (!gpatch->rawpatch) - Z_Free(patch); - } + GLPatch_t *grPatch = patch->hardware; + if (!grMipmap->downloaded && !grMipmap->data) + HWR_MakePatch(patch, grPatch, grMipmap, true); // If hardware does not have the texture, then call pfnSetTexture to upload it - if (!grmip->downloaded) - HWD.pfnSetTexture(grmip); - - HWR_SetCurrentTexture(grmip); + if (!grMipmap->downloaded) + HWD.pfnSetTexture(grMipmap); + HWR_SetCurrentTexture(grMipmap); // The system-memory data can be purged now. - Z_ChangeTag(grmip->data, PU_HWRCACHE_UNLOCKED); + Z_ChangeTag(grMipmap->data, PU_HWRCACHE_UNLOCKED); } // -----------------+ // HWR_GetPatch : Download a patch to the hardware cache and make it ready for use // -----------------+ -void HWR_GetPatch(GLPatch_t *gpatch) +void HWR_GetPatch(patch_t *patch) { - // is it in hardware cache - if (!gpatch->mipmap->downloaded && !gpatch->mipmap->data) - { - // load the software patch, PU_STATIC or the Z_Malloc for hardware patch will - // flush the software patch before the conversion! oh yeah I suffered - patch_t *ptr = gpatch->rawpatch; - if (!ptr) - ptr = W_CacheLumpNumPwad(gpatch->wadnum, gpatch->lumpnum, PU_STATIC); - HWR_MakePatch(ptr, gpatch, gpatch->mipmap, true); - - // this is inefficient.. but the hardware patch in heap is purgeable so it should - // not fragment memory, and besides the REAL cache here is the hardware memory - if (!gpatch->rawpatch) - Z_Free(ptr); - } - - // If hardware does not have the texture, then call pfnSetTexture to upload it - if (!gpatch->mipmap->downloaded) - HWD.pfnSetTexture(gpatch->mipmap); - - HWR_SetCurrentTexture(gpatch->mipmap); - - // The system-memory patch data can be purged now. - Z_ChangeTag(gpatch->mipmap->data, PU_HWRCACHE_UNLOCKED); + if (!patch->hardware) + Patch_CreateGL(patch); + HWR_LoadPatchMipmap(patch, ((GLPatch_t *)patch->hardware)->mipmap); } - // -------------------+ // HWR_GetMappedPatch : Same as HWR_GetPatch for sprite color // -------------------+ -void HWR_GetMappedPatch(GLPatch_t *gpatch, const UINT8 *colormap) +void HWR_GetMappedPatch(patch_t *patch, const UINT8 *colormap) { - GLMipmap_t *grmip, *newmip; + GLPatch_t *grPatch; + GLMipmap_t *grMipmap, *newMipmap; + + if (!patch->hardware) + Patch_CreateGL(patch); + grPatch = patch->hardware; if (colormap == colormaps || colormap == NULL) { - // Load the default (green) color in doom cache (temporary?) AND hardware cache - HWR_GetPatch(gpatch); + // Load the default (green) color in hardware cache + HWR_GetPatch(patch); return; } // search for the mimmap // skip the first (no colormap translated) - for (grmip = gpatch->mipmap; grmip->nextcolormap; ) + for (grMipmap = grPatch->mipmap; grMipmap->nextcolormap; ) { - grmip = grmip->nextcolormap; - if (grmip->colormap == colormap) + grMipmap = grMipmap->nextcolormap; + if (grMipmap->colormap == colormap) { - HWR_LoadMappedPatch(grmip, gpatch); + HWR_LoadPatchMipmap(patch, grMipmap); return; } } @@ -957,13 +935,13 @@ void HWR_GetMappedPatch(GLPatch_t *gpatch, const UINT8 *colormap) // (it have a liste of mipmap) // this malloc is cleared in HWR_FreeTextureCache // (...) unfortunately z_malloc fragment alot the memory :(so malloc is better - newmip = calloc(1, sizeof (*newmip)); - if (newmip == NULL) + newMipmap = calloc(1, sizeof (*newMipmap)); + if (newMipmap == NULL) I_Error("%s: Out of memory", "HWR_GetMappedPatch"); - grmip->nextcolormap = newmip; + grMipmap->nextcolormap = newMipmap; - newmip->colormap = colormap; - HWR_LoadMappedPatch(newmip, gpatch); + newMipmap->colormap = colormap; + HWR_LoadPatchMipmap(patch, newMipmap); } void HWR_UnlockCachedPatch(GLPatch_t *gpatch) @@ -1053,79 +1031,73 @@ static void HWR_DrawPicInCache(UINT8 *block, INT32 pblockwidth, INT32 pblockheig // HWR_GetPic : Download a Doom pic (raw row encoded with no 'holes') // Returns : // -----------------+ -GLPatch_t *HWR_GetPic(lumpnum_t lumpnum) +patch_t *HWR_GetPic(lumpnum_t lumpnum) { - GLPatch_t *grpatch = HWR_GetCachedGLPatch(lumpnum); - if (!grpatch->mipmap->downloaded && !grpatch->mipmap->data) + patch_t *patch = HWR_GetCachedGLPatch(lumpnum); + GLPatch_t *grPatch = (GLPatch_t *)(patch->hardware); + + if (!grPatch->mipmap->downloaded && !grPatch->mipmap->data) { pic_t *pic; UINT8 *block; size_t len; pic = W_CacheLumpNum(lumpnum, PU_CACHE); - grpatch->width = SHORT(pic->width); - grpatch->height = SHORT(pic->height); + patch->width = SHORT(pic->width); + patch->height = SHORT(pic->height); len = W_LumpLength(lumpnum) - sizeof (pic_t); - grpatch->leftoffset = 0; - grpatch->topoffset = 0; - - grpatch->mipmap->width = (UINT16)grpatch->width; - grpatch->mipmap->height = (UINT16)grpatch->height; + grPatch->mipmap->width = (UINT16)patch->width; + grPatch->mipmap->height = (UINT16)patch->height; if (pic->mode == PALETTE) - grpatch->mipmap->format = textureformat; // can be set by driver + grPatch->mipmap->format = textureformat; // can be set by driver else - grpatch->mipmap->format = picmode2GR[pic->mode]; + grPatch->mipmap->format = picmode2GR[pic->mode]; - Z_Free(grpatch->mipmap->data); + Z_Free(grPatch->mipmap->data); // allocate block - block = MakeBlock(grpatch->mipmap); + block = MakeBlock(grPatch->mipmap); - if (grpatch->width == SHORT(pic->width) && - grpatch->height == SHORT(pic->height) && - format2bpp(grpatch->mipmap->format) == format2bpp(picmode2GR[pic->mode])) + if (patch->width == SHORT(pic->width) && + patch->height == SHORT(pic->height) && + format2bpp(grPatch->mipmap->format) == format2bpp(picmode2GR[pic->mode])) { // no conversion needed - M_Memcpy(grpatch->mipmap->data, pic->data,len); + M_Memcpy(grPatch->mipmap->data, pic->data,len); } else HWR_DrawPicInCache(block, SHORT(pic->width), SHORT(pic->height), - SHORT(pic->width)*format2bpp(grpatch->mipmap->format), + SHORT(pic->width)*format2bpp(grPatch->mipmap->format), pic, - format2bpp(grpatch->mipmap->format)); + format2bpp(grPatch->mipmap->format)); Z_Unlock(pic); Z_ChangeTag(block, PU_HWRCACHE_UNLOCKED); - grpatch->mipmap->flags = 0; - grpatch->max_s = grpatch->max_t = 1.0f; + grPatch->mipmap->flags = 0; + grPatch->max_s = grPatch->max_t = 1.0f; } - HWD.pfnSetTexture(grpatch->mipmap); - //CONS_Debug(DBG_RENDER, "picloaded at %x as texture %d\n",grpatch->mipmap.data, grpatch->mipmap.downloaded); + HWD.pfnSetTexture(grPatch->mipmap); + //CONS_Debug(DBG_RENDER, "picloaded at %x as texture %d\n",grPatch->mipmap->data, grPatch->mipmap->downloaded); - return grpatch; + return patch; } -GLPatch_t *HWR_GetCachedGLPatchPwad(UINT16 wadnum, UINT16 lumpnum) +patch_t *HWR_GetCachedGLPatchPwad(UINT16 wadnum, UINT16 lumpnum) { - aatree_t *hwrcache = wadfiles[wadnum]->hwrcache; - GLPatch_t *grpatch; - - if (!(grpatch = M_AATreeGet(hwrcache, lumpnum))) + lumpcache_t *lumpcache = wadfiles[wadnum]->patchcache; + if (!lumpcache[lumpnum]) { - grpatch = Z_Calloc(sizeof(GLPatch_t), PU_HWRPATCHINFO, NULL); - grpatch->wadnum = wadnum; - grpatch->lumpnum = lumpnum; - grpatch->mipmap = Z_Calloc(sizeof(GLMipmap_t), PU_HWRPATCHINFO, NULL); - M_AATreeSet(hwrcache, lumpnum, grpatch); + void *ptr = Z_Calloc(sizeof(patch_t), PU_PATCH, &lumpcache[lumpnum]); + Patch_Create(NULL, 0, ptr); + Patch_AllocateHardwarePatch(ptr); } - - return grpatch; + return (patch_t *)(lumpcache[lumpnum]); } -GLPatch_t *HWR_GetCachedGLPatch(lumpnum_t lumpnum) +patch_t *HWR_GetCachedGLPatch(lumpnum_t lumpnum) { return HWR_GetCachedGLPatchPwad(WADFILENUM(lumpnum),LUMPNUM(lumpnum)); } @@ -1218,7 +1190,7 @@ static void HWR_CacheFadeMask(GLMipmap_t *grMipmap, lumpnum_t fademasklumpnum) void HWR_GetFadeMask(lumpnum_t fademasklumpnum) { - GLMipmap_t *grmip = HWR_GetCachedGLPatch(fademasklumpnum)->mipmap; + GLMipmap_t *grmip = ((GLPatch_t *)HWR_GetCachedGLPatch(fademasklumpnum)->hardware)->mipmap; if (!grmip->downloaded && !grmip->data) HWR_CacheFadeMask(grmip, fademasklumpnum); diff --git a/src/hardware/hw_data.h b/src/hardware/hw_data.h index e5477d729..6a872d258 100644 --- a/src/hardware/hw_data.h +++ b/src/hardware/hw_data.h @@ -73,23 +73,10 @@ struct GLMapTexture_s typedef struct GLMapTexture_s GLMapTexture_t; -// a cached patch as converted to hardware format, holding the original patch_t -// header so that the existing code can retrieve ->width, ->height as usual -// This is returned by W_CachePatchNum()/W_CachePatchName(), when rendermode -// is 'render_opengl'. Else it returns the normal patch_t data. - +// a cached patch as converted to hardware format struct GLPatch_s { - // the 4 first fields come right away from the original patch_t - INT16 width; - INT16 height; - INT16 leftoffset; // pixels to the left of origin - INT16 topoffset; // pixels below the origin - // float max_s,max_t; - UINT16 wadnum; // the software patch lump num for when the hardware patch - UINT16 lumpnum; // was flushed, and we need to re-create it - void *rawpatch; // :^) GLMipmap_t *mipmap; } ATTRPACK; typedef struct GLPatch_s GLPatch_t; diff --git a/src/hardware/hw_draw.c b/src/hardware/hw_draw.c index f5a984d5d..a4e1df496 100644 --- a/src/hardware/hw_draw.c +++ b/src/hardware/hw_draw.c @@ -68,10 +68,11 @@ static UINT8 softwaretranstogl_lo[11] = { 0, 12, 24, 36, 48, 60, 71, 83, 95,111 // Notes : x,y : positions relative to the original Doom resolution // : textes(console+score) + menus + status bar // -----------------+ -void HWR_DrawPatch(GLPatch_t *gpatch, INT32 x, INT32 y, INT32 option) +void HWR_DrawPatch(patch_t *gpatch, INT32 x, INT32 y, INT32 option) { FOutVector v[4]; FBITFIELD flags; + GLPatch_t *hwrPatch; // 3--2 // | /| @@ -84,6 +85,7 @@ void HWR_DrawPatch(GLPatch_t *gpatch, INT32 x, INT32 y, INT32 option) // make patch ready in hardware cache HWR_GetPatch(gpatch); + hwrPatch = ((GLPatch_t *)gpatch->hardware); switch (option & V_SCALEPATCHMASK) { @@ -103,17 +105,17 @@ void HWR_DrawPatch(GLPatch_t *gpatch, INT32 x, INT32 y, INT32 option) if (option & V_NOSCALESTART) sdupx = sdupy = 2.0f; - v[0].x = v[3].x = (x*sdupx-SHORT(gpatch->leftoffset)*pdupx)/vid.width - 1; - v[2].x = v[1].x = (x*sdupx+(SHORT(gpatch->width)-SHORT(gpatch->leftoffset))*pdupx)/vid.width - 1; - v[0].y = v[1].y = 1-(y*sdupy-SHORT(gpatch->topoffset)*pdupy)/vid.height; - v[2].y = v[3].y = 1-(y*sdupy+(SHORT(gpatch->height)-SHORT(gpatch->topoffset))*pdupy)/vid.height; + v[0].x = v[3].x = (x*sdupx-(gpatch->leftoffset)*pdupx)/vid.width - 1; + v[2].x = v[1].x = (x*sdupx+(gpatch->width-gpatch->leftoffset)*pdupx)/vid.width - 1; + v[0].y = v[1].y = 1-(y*sdupy-(gpatch->topoffset)*pdupy)/vid.height; + v[2].y = v[3].y = 1-(y*sdupy+(gpatch->height-gpatch->topoffset)*pdupy)/vid.height; v[0].z = v[1].z = v[2].z = v[3].z = 1.0f; v[0].s = v[3].s = 0.0f; - v[2].s = v[1].s = gpatch->max_s; + v[2].s = v[1].s = hwrPatch->max_s; v[0].t = v[1].t = 0.0f; - v[2].t = v[3].t = gpatch->max_t; + v[2].t = v[3].t = hwrPatch->max_t; flags = PF_Translucent|PF_NoDepthTest; @@ -126,13 +128,14 @@ void HWR_DrawPatch(GLPatch_t *gpatch, INT32 x, INT32 y, INT32 option) HWD.pfnDrawPolygon(NULL, v, 4, flags); } -void HWR_DrawStretchyFixedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale, fixed_t vscale, INT32 option, const UINT8 *colormap) +void HWR_DrawStretchyFixedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale, fixed_t vscale, INT32 option, const UINT8 *colormap) { FOutVector v[4]; FBITFIELD flags; float cx = FIXED_TO_FLOAT(x); float cy = FIXED_TO_FLOAT(y); UINT8 alphalevel = ((option & V_ALPHAMASK) >> V_ALPHASHIFT); + GLPatch_t *hwrPatch; // 3--2 // | /| @@ -151,6 +154,8 @@ void HWR_DrawStretchyFixedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t else HWR_GetMappedPatch(gpatch, colormap); + hwrPatch = ((GLPatch_t *)gpatch->hardware); + dupx = (float)vid.dupx; dupy = (float)vid.dupy; @@ -181,13 +186,13 @@ void HWR_DrawStretchyFixedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t // left offset if (option & V_FLIP) - offsetx = (float)(SHORT(gpatch->width) - SHORT(gpatch->leftoffset)) * fscalew; + offsetx = (float)(gpatch->width - gpatch->leftoffset) * fscalew; else - offsetx = (float)SHORT(gpatch->leftoffset) * fscalew; + offsetx = (float)(gpatch->leftoffset) * fscalew; // top offset // TODO: make some kind of vertical version of V_FLIP, maybe by deprecating V_OFFSET in future?!? - offsety = (float)SHORT(gpatch->topoffset) * fscaleh; + offsety = (float)(gpatch->topoffset) * fscaleh; if ((option & (V_NOSCALESTART|V_OFFSET)) == (V_NOSCALESTART|V_OFFSET)) // Multiply by dupx/dupy for crosshairs { @@ -277,17 +282,14 @@ void HWR_DrawStretchyFixedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t // if it's meant to cover the whole screen, black out the rest (ONLY IF TOP LEFT ISN'T TRANSPARENT) // cx and cy are possibly *slightly* off from float maths // This is done before here compared to software because we directly alter cx and cy to centre - if (cx >= -0.1f && cx <= 0.1f && SHORT(gpatch->width) == BASEVIDWIDTH && cy >= -0.1f && cy <= 0.1f && SHORT(gpatch->height) == BASEVIDHEIGHT) + if (cx >= -0.1f && cx <= 0.1f && (gpatch->width) == BASEVIDWIDTH && cy >= -0.1f && cy <= 0.1f && SHORT(gpatch->height) == BASEVIDHEIGHT) { - // Need to temporarily cache the real patch to get the colour of the top left pixel - patch_t *realpatch = W_CacheSoftwarePatchNumPwad(gpatch->wadnum, gpatch->lumpnum, PU_STATIC); - const column_t *column = (const column_t *)((const UINT8 *)(realpatch) + LONG((realpatch)->columnofs[0])); + const column_t *column = (const column_t *)((const UINT8 *)(gpatch->columns) + (gpatch->columnofs[0])); if (!column->topdelta) { const UINT8 *source = (const UINT8 *)(column) + 3; HWR_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, (column->topdelta == 0xff ? 31 : source[0])); } - Z_Free(realpatch); } // centre screen if (fabsf((float)vid.width - (float)BASEVIDWIDTH * dupx) > 1.0E-36f) @@ -317,13 +319,13 @@ void HWR_DrawStretchyFixedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t if (pscale != FRACUNIT || (splitscreen && option & V_PERPLAYER)) { - fwidth = (float)SHORT(gpatch->width) * fscalew * dupx; - fheight = (float)SHORT(gpatch->height) * fscaleh * dupy; + fwidth = (float)(gpatch->width) * fscalew * dupx; + fheight = (float)(gpatch->height) * fscaleh * dupy; } else { - fwidth = (float)SHORT(gpatch->width) * dupx; - fheight = (float)SHORT(gpatch->height) * dupy; + fwidth = (float)(gpatch->width) * dupx; + fheight = (float)(gpatch->height) * dupy; } // positions of the cx, cy, are between 0 and vid.width/vid.height now, we need them to be between -1 and 1 @@ -345,17 +347,17 @@ void HWR_DrawStretchyFixedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t if (option & V_FLIP) { - v[0].s = v[3].s = gpatch->max_s; + v[0].s = v[3].s = hwrPatch->max_s; v[2].s = v[1].s = 0.0f; } else { v[0].s = v[3].s = 0.0f; - v[2].s = v[1].s = gpatch->max_s; + v[2].s = v[1].s = hwrPatch->max_s; } v[0].t = v[1].t = 0.0f; - v[2].t = v[3].t = gpatch->max_t; + v[2].t = v[3].t = hwrPatch->max_t; flags = PF_Translucent|PF_NoDepthTest; @@ -380,13 +382,14 @@ void HWR_DrawStretchyFixedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t HWD.pfnDrawPolygon(NULL, v, 4, flags); } -void HWR_DrawCroppedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale, INT32 option, fixed_t sx, fixed_t sy, fixed_t w, fixed_t h) +void HWR_DrawCroppedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale, INT32 option, fixed_t sx, fixed_t sy, fixed_t w, fixed_t h) { FOutVector v[4]; FBITFIELD flags; float cx = FIXED_TO_FLOAT(x); float cy = FIXED_TO_FLOAT(y); UINT8 alphalevel = ((option & V_ALPHAMASK) >> V_ALPHASHIFT); + GLPatch_t *hwrPatch; // 3--2 // | /| @@ -399,6 +402,7 @@ void HWR_DrawCroppedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscal // make patch ready in hardware cache HWR_GetPatch(gpatch); + hwrPatch = ((GLPatch_t *)gpatch->hardware); dupx = (float)vid.dupx; dupy = (float)vid.dupy; @@ -438,15 +442,12 @@ void HWR_DrawCroppedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscal // This is done before here compared to software because we directly alter cx and cy to centre if (cx >= -0.1f && cx <= 0.1f && SHORT(gpatch->width) == BASEVIDWIDTH && cy >= -0.1f && cy <= 0.1f && SHORT(gpatch->height) == BASEVIDHEIGHT) { - // Need to temporarily cache the real patch to get the colour of the top left pixel - patch_t *realpatch = W_CacheSoftwarePatchNumPwad(gpatch->wadnum, gpatch->lumpnum, PU_STATIC); - const column_t *column = (const column_t *)((const UINT8 *)(realpatch) + LONG((realpatch)->columnofs[0])); + const column_t *column = (const column_t *)((const UINT8 *)(gpatch->columns) + (gpatch->columnofs[0])); if (!column->topdelta) { const UINT8 *source = (const UINT8 *)(column) + 3; HWR_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, (column->topdelta == 0xff ? 31 : source[0])); } - Z_Free(realpatch); } // centre screen if (fabsf((float)vid.width - (float)BASEVIDWIDTH * dupx) > 1.0E-36f) @@ -469,11 +470,11 @@ void HWR_DrawCroppedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscal fwidth = w; fheight = h; - if (fwidth > SHORT(gpatch->width)) - fwidth = SHORT(gpatch->width); + if (fwidth > gpatch->width) + fwidth = gpatch->width; - if (fheight > SHORT(gpatch->height)) - fheight = SHORT(gpatch->height); + if (fheight > gpatch->height) + fheight = gpatch->height; if (pscale != FRACUNIT) { @@ -503,17 +504,17 @@ void HWR_DrawCroppedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscal v[0].z = v[1].z = v[2].z = v[3].z = 1.0f; - v[0].s = v[3].s = ((sx )/(float)SHORT(gpatch->width) )*gpatch->max_s; - if (sx + w > SHORT(gpatch->width)) - v[2].s = v[1].s = gpatch->max_s; + v[0].s = v[3].s = ((sx)/(float)(gpatch->width))*hwrPatch->max_s; + if (sx + w > gpatch->width) + v[2].s = v[1].s = hwrPatch->max_s; else - v[2].s = v[1].s = ((sx+w)/(float)SHORT(gpatch->width) )*gpatch->max_s; + v[2].s = v[1].s = ((sx+w)/(float)(gpatch->width))*hwrPatch->max_s; - v[0].t = v[1].t = ((sy )/(float)SHORT(gpatch->height))*gpatch->max_t; - if (sy + h > SHORT(gpatch->height)) - v[2].t = v[3].t = gpatch->max_t; + v[0].t = v[1].t = ((sy)/(float)(gpatch->height))*hwrPatch->max_t; + if (sy + h > gpatch->height) + v[2].t = v[3].t = hwrPatch->max_t; else - v[2].t = v[3].t = ((sy+h)/(float)SHORT(gpatch->height))*gpatch->max_t; + v[2].t = v[3].t = ((sy+h)/(float)(gpatch->height))*hwrPatch->max_t; flags = PF_Translucent|PF_NoDepthTest; @@ -541,7 +542,7 @@ void HWR_DrawCroppedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscal void HWR_DrawPic(INT32 x, INT32 y, lumpnum_t lumpnum) { FOutVector v[4]; - const GLPatch_t *patch; + const patch_t *patch; // make pic ready in hardware cache patch = HWR_GetPic(lumpnum); @@ -558,10 +559,10 @@ void HWR_DrawPic(INT32 x, INT32 y, lumpnum_t lumpnum) v[0].z = v[1].z = v[2].z = v[3].z = 1.0f; - v[0].s = v[3].s = 0; - v[2].s = v[1].s = patch->max_s; - v[0].t = v[1].t = 0; - v[2].t = v[3].t = patch->max_t; + v[0].s = v[3].s = 0; + v[2].s = v[1].s = ((GLPatch_t *)patch->hardware)->max_s; + v[0].t = v[1].t = 0; + v[2].t = v[3].t = ((GLPatch_t *)patch->hardware)->max_t; //Hurdler: Boris, the same comment as above... but maybe for pics @@ -934,7 +935,7 @@ void HWR_DrawViewBorder(INT32 clearlines) INT32 top, side; INT32 baseviewwidth, baseviewheight; INT32 basewindowx, basewindowy; - GLPatch_t *patch; + patch_t *patch; // if (gl_viewwidth == vid.width) // return; diff --git a/src/hardware/hw_drv.h b/src/hardware/hw_drv.h index 6f039cc3a..cc1354909 100644 --- a/src/hardware/hw_drv.h +++ b/src/hardware/hw_drv.h @@ -42,6 +42,7 @@ EXPORT void HWRAPI(SetBlend) (FBITFIELD PolyFlags); EXPORT void HWRAPI(ClearBuffer) (FBOOLEAN ColorMask, FBOOLEAN DepthMask, FRGBAFloat *ClearColor); EXPORT void HWRAPI(SetTexture) (FTextureInfo *TexInfo); EXPORT void HWRAPI(UpdateTexture) (FTextureInfo *TexInfo); +EXPORT void HWRAPI(DeleteTexture) (FTextureInfo *TexInfo); EXPORT void HWRAPI(ReadRect) (INT32 x, INT32 y, INT32 width, INT32 height, INT32 dst_stride, UINT16 *dst_data); EXPORT void HWRAPI(GClipRect) (INT32 minx, INT32 miny, INT32 maxx, INT32 maxy, float nearclip); EXPORT void HWRAPI(ClearMipMapCache) (void); @@ -96,6 +97,7 @@ struct hwdriver_s ClearBuffer pfnClearBuffer; SetTexture pfnSetTexture; UpdateTexture pfnUpdateTexture; + DeleteTexture pfnDeleteTexture; ReadRect pfnReadRect; GClipRect pfnGClipRect; ClearMipMapCache pfnClearMipMapCache; diff --git a/src/hardware/hw_glob.h b/src/hardware/hw_glob.h index 6ede8448b..94c553535 100644 --- a/src/hardware/hw_glob.h +++ b/src/hardware/hw_glob.h @@ -64,8 +64,7 @@ typedef struct gl_vissprite_s float x1, x2; float tz, ty; float tracertz; // for MF2_LINKDRAW sprites, this contains tracer's tz for use in sorting - //lumpnum_t patchlumpnum; - GLPatch_t *gpatch; + patch_t *gpatch; boolean flip; UINT8 translucency; //alpha level 0-255 mobj_t *mobj; // NOTE: This is a precipmobj_t if precip is true !!! Watch out. @@ -86,25 +85,33 @@ extern size_t addsubsector; void HWR_InitPolyPool(void); void HWR_FreePolyPool(void); +void HWR_FreeExtraSubsectors(void); + // -------- // hw_cache.c // -------- void HWR_InitTextureCache(void); void HWR_FreeTextureCache(void); void HWR_FreeMipmapCache(void); -void HWR_FreeExtraSubsectors(void); +patch_t *HWR_GetCachedGLPatchPwad(UINT16 wad, UINT16 lump); +patch_t *HWR_GetCachedGLPatch(lumpnum_t lumpnum); + +void HWR_GetPatch(patch_t *patch); +void HWR_GetMappedPatch(patch_t *patch, const UINT8 *colormap); +void HWR_GetFadeMask(lumpnum_t fademasklumpnum); +patch_t *HWR_GetPic(lumpnum_t lumpnum); + +GLMapTexture_t *HWR_GetTexture(INT32 tex); void HWR_GetLevelFlat(levelflat_t *levelflat); void HWR_LiterallyGetFlat(lumpnum_t flatlumpnum); -GLMapTexture_t *HWR_GetTexture(INT32 tex); -void HWR_GetPatch(GLPatch_t *gpatch); -void HWR_GetMappedPatch(GLPatch_t *gpatch, const UINT8 *colormap); + +void HWR_FreeTexture(patch_t *patch); +void HWR_FreeTextureColormaps(patch_t *patch); void HWR_UnlockCachedPatch(GLPatch_t *gpatch); -GLPatch_t *HWR_GetPic(lumpnum_t lumpnum); + void HWR_SetPalette(RGBA_t *palette); -GLPatch_t *HWR_GetCachedGLPatchPwad(UINT16 wad, UINT16 lump); -GLPatch_t *HWR_GetCachedGLPatch(lumpnum_t lumpnum); -void HWR_GetFadeMask(lumpnum_t fademasklumpnum); + // -------- // hw_draw.c diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index ddc935f0d..7ba7f911c 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -706,7 +706,7 @@ static void HWR_DrawSegsSplats(FSurfaceInfo * pSurf) { FOutVector wallVerts[4]; wallsplat_t *splat; - GLPatch_t *gpatch; + patch_t *gpatch; fixed_t i; // seg bbox fixed_t segbbox[4]; @@ -3549,7 +3549,7 @@ static boolean HWR_DoCulling(line_t *cullheight, line_t *viewcullheight, float v static void HWR_DrawDropShadow(mobj_t *thing, fixed_t scale) { - GLPatch_t *gpatch; + patch_t *gpatch; FOutVector shadowVerts[4]; FSurfaceInfo sSurf; float fscale; float fx; float fy; float offset; @@ -3575,12 +3575,12 @@ static void HWR_DrawDropShadow(mobj_t *thing, fixed_t scale) if (alpha >= 255) return; alpha = 255 - alpha; - gpatch = (GLPatch_t *)W_CachePatchName("DSHADOW", PU_CACHE); - if (!(gpatch && gpatch->mipmap->format)) return; + gpatch = (patch_t *)W_CachePatchName("DSHADOW", PU_CACHE); + if (!(gpatch && ((GLPatch_t *)gpatch->hardware)->mipmap->format)) return; HWR_GetPatch(gpatch); scalemul = FixedMul(FRACUNIT - floordiff/640, scale); - scalemul = FixedMul(scalemul, (thing->radius*2) / SHORT(gpatch->height)); + scalemul = FixedMul(scalemul, (thing->radius*2) / gpatch->height); fscale = FIXED_TO_FLOAT(scalemul); fx = FIXED_TO_FLOAT(thing->x); @@ -3592,9 +3592,9 @@ static void HWR_DrawDropShadow(mobj_t *thing, fixed_t scale) // 0--1 if (thing && fabsf(fscale - 1.0f) > 1.0E-36f) - offset = (SHORT(gpatch->height)/2) * fscale; + offset = ((gpatch->height)/2) * fscale; else - offset = (float)(SHORT(gpatch->height)/2); + offset = (float)((gpatch->height)/2); shadowVerts[2].x = shadowVerts[3].x = fx + offset; shadowVerts[1].x = shadowVerts[0].x = fx - offset; @@ -3624,10 +3624,10 @@ static void HWR_DrawDropShadow(mobj_t *thing, fixed_t scale) } shadowVerts[0].s = shadowVerts[3].s = 0; - shadowVerts[2].s = shadowVerts[1].s = gpatch->max_s; + shadowVerts[2].s = shadowVerts[1].s = ((GLPatch_t *)gpatch->hardware)->max_s; shadowVerts[3].t = shadowVerts[2].t = 0; - shadowVerts[0].t = shadowVerts[1].t = gpatch->max_t; + shadowVerts[0].t = shadowVerts[1].t = ((GLPatch_t *)gpatch->hardware)->max_t; if (thing->subsector->sector->numlights) { @@ -3687,7 +3687,7 @@ static void HWR_SplitSprite(gl_vissprite_t *spr) float this_scale = 1.0f; FOutVector wallVerts[4]; FOutVector baseWallVerts[4]; // This is what the verts should end up as - GLPatch_t *gpatch; + patch_t *gpatch; FSurfaceInfo Surf; const boolean hires = (spr->mobj && spr->mobj->skin && ((skin_t *)spr->mobj->skin)->flags & SF_HIRES); extracolormap_t *colormap; @@ -3715,7 +3715,7 @@ static void HWR_SplitSprite(gl_vissprite_t *spr) if (hires) this_scale = this_scale * FIXED_TO_FLOAT(((skin_t *)spr->mobj->skin)->highresscale); - gpatch = spr->gpatch; //W_CachePatchNum(spr->patchlumpnum, PU_CACHE); + gpatch = spr->gpatch; // cache the patch in the graphics card memory //12/12/99: Hurdler: same comment as above (for md2) @@ -3740,25 +3740,25 @@ static void HWR_SplitSprite(gl_vissprite_t *spr) if (spr->flip) { - baseWallVerts[0].s = baseWallVerts[3].s = gpatch->max_s; + baseWallVerts[0].s = baseWallVerts[3].s = ((GLPatch_t *)gpatch->hardware)->max_s; baseWallVerts[2].s = baseWallVerts[1].s = 0; } else { baseWallVerts[0].s = baseWallVerts[3].s = 0; - baseWallVerts[2].s = baseWallVerts[1].s = gpatch->max_s; + baseWallVerts[2].s = baseWallVerts[1].s = ((GLPatch_t *)gpatch->hardware)->max_s; } // flip the texture coords (look familiar?) if (spr->vflip) { - baseWallVerts[3].t = baseWallVerts[2].t = gpatch->max_t; + baseWallVerts[3].t = baseWallVerts[2].t = ((GLPatch_t *)gpatch->hardware)->max_t; baseWallVerts[0].t = baseWallVerts[1].t = 0; } else { baseWallVerts[3].t = baseWallVerts[2].t = 0; - baseWallVerts[0].t = baseWallVerts[1].t = gpatch->max_t; + baseWallVerts[0].t = baseWallVerts[1].t = ((GLPatch_t *)gpatch->hardware)->max_t; } // if it has a dispoffset, push it a little towards the camera @@ -3963,7 +3963,7 @@ static void HWR_DrawSprite(gl_vissprite_t *spr) { float this_scale = 1.0f; FOutVector wallVerts[4]; - GLPatch_t *gpatch; // sprite patch converted to hardware + patch_t *gpatch; // sprite patch converted to hardware FSurfaceInfo Surf; const boolean hires = (spr->mobj && spr->mobj->skin && ((skin_t *)spr->mobj->skin)->flags & SF_HIRES); //const boolean papersprite = (spr->mobj && (spr->mobj->frame & FF_PAPERSPRITE)); @@ -3990,7 +3990,7 @@ static void HWR_DrawSprite(gl_vissprite_t *spr) // sure to do it the right way. So actually, we keep normal sprite // in memory and we add the md2 model if it exists for that sprite - gpatch = spr->gpatch; //W_CachePatchNum(spr->patchlumpnum, PU_CACHE); + gpatch = spr->gpatch; #ifdef ALAM_LIGHTING if (!(spr->mobj->flags2 & MF2_DEBRIS) && (spr->mobj->sprite != SPR_PLAY || @@ -4021,21 +4021,21 @@ static void HWR_DrawSprite(gl_vissprite_t *spr) if (spr->flip) { - wallVerts[0].s = wallVerts[3].s = gpatch->max_s; + wallVerts[0].s = wallVerts[3].s = ((GLPatch_t *)gpatch->hardware)->max_s; wallVerts[2].s = wallVerts[1].s = 0; }else{ wallVerts[0].s = wallVerts[3].s = 0; - wallVerts[2].s = wallVerts[1].s = gpatch->max_s; + wallVerts[2].s = wallVerts[1].s = ((GLPatch_t *)gpatch->hardware)->max_s; } // flip the texture coords (look familiar?) if (spr->vflip) { - wallVerts[3].t = wallVerts[2].t = gpatch->max_t; + wallVerts[3].t = wallVerts[2].t = ((GLPatch_t *)gpatch->hardware)->max_t; wallVerts[0].t = wallVerts[1].t = 0; }else{ wallVerts[3].t = wallVerts[2].t = 0; - wallVerts[0].t = wallVerts[1].t = gpatch->max_t; + wallVerts[0].t = wallVerts[1].t = ((GLPatch_t *)gpatch->hardware)->max_t; } // cache the patch in the graphics card memory @@ -4121,7 +4121,7 @@ static inline void HWR_DrawPrecipitationSprite(gl_vissprite_t *spr) { FBITFIELD blend = 0; FOutVector wallVerts[4]; - GLPatch_t *gpatch; // sprite patch converted to hardware + patch_t *gpatch; // sprite patch converted to hardware FSurfaceInfo Surf; if (!spr->mobj) @@ -4131,7 +4131,7 @@ static inline void HWR_DrawPrecipitationSprite(gl_vissprite_t *spr) return; // cache sprite graphics - gpatch = spr->gpatch; //W_CachePatchNum(spr->patchlumpnum, PU_CACHE); + gpatch = spr->gpatch; // create the sprite billboard // @@ -4153,10 +4153,10 @@ static inline void HWR_DrawPrecipitationSprite(gl_vissprite_t *spr) HWR_RotateSpritePolyToAim(spr, wallVerts, true); wallVerts[0].s = wallVerts[3].s = 0; - wallVerts[2].s = wallVerts[1].s = gpatch->max_s; + wallVerts[2].s = wallVerts[1].s = ((GLPatch_t *)gpatch->hardware)->max_s; wallVerts[3].t = wallVerts[2].t = 0; - wallVerts[0].t = wallVerts[1].t = gpatch->max_t; + wallVerts[0].t = wallVerts[1].t = ((GLPatch_t *)gpatch->hardware)->max_t; // cache the patch in the graphics card memory //12/12/99: Hurdler: same comment as above (for md2) @@ -5014,13 +5014,12 @@ static void HWR_ProjectSprite(mobj_t *thing) vis->tz = tz; // Keep tz for the simple sprite sorting that happens vis->tracertz = tracertz; vis->dispoffset = dispoffset; // Monster Iestyn: 23/11/15: HARDWARE SUPPORT AT LAST - //vis->patchlumpnum = sprframe->lumppat[rot]; #ifdef ROTSPRITE if (rotsprite) - vis->gpatch = (GLPatch_t *)rotsprite; + vis->gpatch = (patch_t *)rotsprite; else #endif - vis->gpatch = (GLPatch_t *)W_CachePatchNum(sprframe->lumppat[rot], PU_CACHE); + vis->gpatch = (patch_t *)W_CachePatchNum(sprframe->lumppat[rot], PU_CACHE); vis->flip = flip; vis->mobj = thing; vis->z1 = z1; @@ -5155,8 +5154,7 @@ static void HWR_ProjectPrecipitationSprite(precipmobj_t *thing) vis->z2 = z2; vis->tz = tz; vis->dispoffset = 0; // Monster Iestyn: 23/11/15: HARDWARE SUPPORT AT LAST - //vis->patchlumpnum = sprframe->lumppat[rot]; - vis->gpatch = (GLPatch_t *)W_CachePatchNum(sprframe->lumppat[rot], PU_CACHE); + vis->gpatch = (patch_t *)W_CachePatchNum(sprframe->lumppat[rot], PU_CACHE); vis->flip = flip; vis->mobj = (mobj_t *)thing; diff --git a/src/hardware/hw_main.h b/src/hardware/hw_main.h index ddb3696b6..3bcef05de 100644 --- a/src/hardware/hw_main.h +++ b/src/hardware/hw_main.h @@ -35,9 +35,9 @@ void HWR_DrawViewBorder(INT32 clearlines); void HWR_DrawFlatFill(INT32 x, INT32 y, INT32 w, INT32 h, lumpnum_t flatlumpnum); void HWR_InitTextureMapping(void); void HWR_SetViewSize(void); -void HWR_DrawPatch(GLPatch_t *gpatch, INT32 x, INT32 y, INT32 option); -void HWR_DrawStretchyFixedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale, fixed_t vscale, INT32 option, const UINT8 *colormap); -void HWR_DrawCroppedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t scale, INT32 option, fixed_t sx, fixed_t sy, fixed_t w, fixed_t h); +void HWR_DrawPatch(patch_t *gpatch, INT32 x, INT32 y, INT32 option); +void HWR_DrawStretchyFixedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale, fixed_t vscale, INT32 option, const UINT8 *colormap); +void HWR_DrawCroppedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t scale, INT32 option, fixed_t sx, fixed_t sy, fixed_t w, fixed_t h); void HWR_MakePatch(const patch_t *patch, GLPatch_t *grPatch, GLMipmap_t *grMipmap, boolean makebitmap); void HWR_CreatePlanePolygons(INT32 bspnum); void HWR_CreateStaticLightmaps(INT32 bspnum); diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index fa5156758..caef0a02d 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -348,48 +348,53 @@ static GLTextureFormat_t PCX_Load(const char *filename, int *w, int *h, // -----------------+ static void md2_loadTexture(md2_t *model) { - GLPatch_t *grpatch; + patch_t *patch; + GLPatch_t *grPatch = NULL; const char *filename = model->filename; if (model->grpatch) { - grpatch = model->grpatch; - Z_Free(grpatch->mipmap->data); + patch = model->grpatch; + grPatch = (GLPatch_t *)(patch->hardware); + if (grPatch) + Z_Free(grPatch->mipmap->data); } else - { - grpatch = Z_Calloc(sizeof *grpatch, PU_HWRPATCHINFO, - &(model->grpatch)); - grpatch->mipmap = Z_Calloc(sizeof (GLMipmap_t), PU_HWRPATCHINFO, NULL); - } + model->grpatch = patch = Patch_Create(NULL, 0, NULL); - if (!grpatch->mipmap->downloaded && !grpatch->mipmap->data) + if (!patch->hardware) + Patch_AllocateHardwarePatch(patch); + + if (grPatch == NULL) + grPatch = (GLPatch_t *)(patch->hardware); + + if (!grPatch->mipmap->downloaded && !grPatch->mipmap->data) { int w = 0, h = 0; UINT32 size; RGBA_t *image; #ifdef HAVE_PNG - grpatch->mipmap->format = PNG_Load(filename, &w, &h, grpatch); - if (grpatch->mipmap->format == 0) + grPatch->mipmap->format = PNG_Load(filename, &w, &h, grPatch); + if (grPatch->mipmap->format == 0) #endif - grpatch->mipmap->format = PCX_Load(filename, &w, &h, grpatch); - if (grpatch->mipmap->format == 0) + grPatch->mipmap->format = PCX_Load(filename, &w, &h, grPatch); + if (grPatch->mipmap->format == 0) { model->notexturefile = true; // mark it so its not searched for again repeatedly return; } - grpatch->mipmap->downloaded = 0; - grpatch->mipmap->flags = 0; + grPatch->mipmap->downloaded = 0; + grPatch->mipmap->flags = 0; - grpatch->width = (INT16)w; - grpatch->height = (INT16)h; - grpatch->mipmap->width = (UINT16)w; - grpatch->mipmap->height = (UINT16)h; + patch->width = (INT16)w; + patch->height = (INT16)h; + grPatch->mipmap->width = (UINT16)w; + grPatch->mipmap->height = (UINT16)h; // Lactozilla: Apply colour cube - image = grpatch->mipmap->data; + image = grPatch->mipmap->data; size = w*h; while (size--) { @@ -397,7 +402,7 @@ static void md2_loadTexture(md2_t *model) image++; } } - HWD.pfnSetTexture(grpatch->mipmap); + HWD.pfnSetTexture(grPatch->mipmap); } // -----------------+ @@ -405,48 +410,53 @@ static void md2_loadTexture(md2_t *model) // -----------------+ static void md2_loadBlendTexture(md2_t *model) { - GLPatch_t *grpatch; + patch_t *patch; + GLPatch_t *grPatch = NULL; char *filename = Z_Malloc(strlen(model->filename)+7, PU_STATIC, NULL); - strcpy(filename, model->filename); + strcpy(filename, model->filename); FIL_ForceExtension(filename, "_blend.png"); if (model->blendgrpatch) { - grpatch = model->blendgrpatch; - Z_Free(grpatch->mipmap->data); + patch = model->blendgrpatch; + grPatch = (GLPatch_t *)(patch->hardware); + if (grPatch) + Z_Free(grPatch->mipmap->data); } else - { - grpatch = Z_Calloc(sizeof *grpatch, PU_HWRPATCHINFO, - &(model->blendgrpatch)); - grpatch->mipmap = Z_Calloc(sizeof (GLMipmap_t), PU_HWRPATCHINFO, NULL); - } + model->blendgrpatch = patch = Patch_Create(NULL, 0, NULL); - if (!grpatch->mipmap->downloaded && !grpatch->mipmap->data) + if (!patch->hardware) + Patch_AllocateHardwarePatch(patch); + + if (grPatch == NULL) + grPatch = (GLPatch_t *)(patch->hardware); + + if (!grPatch->mipmap->downloaded && !grPatch->mipmap->data) { int w = 0, h = 0; #ifdef HAVE_PNG - grpatch->mipmap->format = PNG_Load(filename, &w, &h, grpatch); - if (grpatch->mipmap->format == 0) + grPatch->mipmap->format = PNG_Load(filename, &w, &h, grPatch); + if (grPatch->mipmap->format == 0) #endif - grpatch->mipmap->format = PCX_Load(filename, &w, &h, grpatch); - if (grpatch->mipmap->format == 0) + grPatch->mipmap->format = PCX_Load(filename, &w, &h, grPatch); + if (grPatch->mipmap->format == 0) { model->noblendfile = true; // mark it so its not searched for again repeatedly Z_Free(filename); return; } - grpatch->mipmap->downloaded = 0; - grpatch->mipmap->flags = 0; + grPatch->mipmap->downloaded = 0; + grPatch->mipmap->flags = 0; - grpatch->width = (INT16)w; - grpatch->height = (INT16)h; - grpatch->mipmap->width = (UINT16)w; - grpatch->mipmap->height = (UINT16)h; + patch->width = (INT16)w; + patch->height = (INT16)h; + grPatch->mipmap->width = (UINT16)w; + grPatch->mipmap->height = (UINT16)h; } - HWD.pfnSetTexture(grpatch->mipmap); // We do need to do this so that it can be cleared and knows to recreate it when necessary + HWD.pfnSetTexture(grPatch->mipmap); // We do need to do this so that it can be cleared and knows to recreate it when necessary Z_Free(filename); } @@ -664,8 +674,10 @@ spritemodelfound: #define SETBRIGHTNESS(brightness,r,g,b) \ brightness = (UINT8)(((1063*(UINT16)(r))/5000) + ((3576*(UINT16)(g))/5000) + ((361*(UINT16)(b))/5000)) -static void HWR_CreateBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch, GLMipmap_t *grmip, INT32 skinnum, skincolornum_t color) +static void HWR_CreateBlendedTexture(patch_t *gpatch, patch_t *blendgpatch, GLMipmap_t *grMipmap, INT32 skinnum, skincolornum_t color) { + GLPatch_t *hwrPatch = gpatch->hardware; + GLPatch_t *hwrBlendPatch = blendgpatch->hardware; UINT16 w = gpatch->width, h = gpatch->height; UINT32 size = w*h; RGBA_t *image, *blendimage, *cur, blendcolor; @@ -678,28 +690,29 @@ static void HWR_CreateBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch, memset(translation, 0, sizeof(translation)); memset(cutoff, 0, sizeof(cutoff)); - if (grmip->width == 0) + if (grMipmap->width == 0) { - grmip->width = gpatch->width; - grmip->height = gpatch->height; + grMipmap->width = gpatch->width; + grMipmap->height = gpatch->height; // no wrap around, no chroma key - grmip->flags = 0; + grMipmap->flags = 0; + // setup the texture info - grmip->format = GL_TEXFMT_RGBA; + grMipmap->format = GL_TEXFMT_RGBA; } - if (grmip->data) + if (grMipmap->data) { - Z_Free(grmip->data); - grmip->data = NULL; + Z_Free(grMipmap->data); + grMipmap->data = NULL; } - cur = Z_Malloc(size*4, PU_HWRMODELTEXTURE, &grmip->data); + cur = Z_Malloc(size*4, PU_HWRMODELTEXTURE, &grMipmap->data); memset(cur, 0x00, size*4); - image = gpatch->mipmap->data; - blendimage = blendgpatch->mipmap->data; + image = hwrPatch->mipmap->data; + blendimage = hwrBlendPatch->mipmap->data; // TC_METALSONIC includes an actual skincolor translation, on top of its flashing. if (skinnum == TC_METALSONIC) @@ -1038,37 +1051,39 @@ skippixel: #undef SETBRIGHTNESS -static void HWR_GetBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch, INT32 skinnum, const UINT8 *colormap, skincolornum_t color) +static void HWR_GetBlendedTexture(patch_t *patch, patch_t *blendpatch, INT32 skinnum, const UINT8 *colormap, skincolornum_t color) { // mostly copied from HWR_GetMappedPatch, hence the similarities and comment - GLMipmap_t *grmip, *newmip; + GLPatch_t *grPatch = patch->hardware; + GLPatch_t *grBlendPatch = NULL; + GLMipmap_t *grMipmap, *newMipmap; - if (colormap == colormaps || colormap == NULL) + if (blendpatch == NULL || colormap == colormaps || colormap == NULL) { // Don't do any blending - HWD.pfnSetTexture(gpatch->mipmap); + HWD.pfnSetTexture(grPatch->mipmap); return; } - if ((blendgpatch && blendgpatch->mipmap->format) - && (gpatch->width != blendgpatch->width || gpatch->height != blendgpatch->height)) + if ((blendpatch && (grBlendPatch = blendpatch->hardware) && grBlendPatch->mipmap->format) + && (patch->width != blendpatch->width || patch->height != blendpatch->height)) { // Blend image exists, but it's bad. - HWD.pfnSetTexture(gpatch->mipmap); + HWD.pfnSetTexture(grPatch->mipmap); return; } // search for the mipmap // skip the first (no colormap translated) - for (grmip = gpatch->mipmap; grmip->nextcolormap; ) + for (grMipmap = grPatch->mipmap; grMipmap->nextcolormap; ) { - grmip = grmip->nextcolormap; - if (grmip->colormap == colormap) + grMipmap = grMipmap->nextcolormap; + if (grMipmap->colormap == colormap) { - if (grmip->downloaded && grmip->data) + if (grMipmap->downloaded && grMipmap->data) { - HWD.pfnSetTexture(grmip); // found the colormap, set it to the correct texture - Z_ChangeTag(grmip->data, PU_HWRMODELTEXTURE_UNLOCKED); + HWD.pfnSetTexture(grMipmap); // found the colormap, set it to the correct texture + Z_ChangeTag(grMipmap->data, PU_HWRMODELTEXTURE_UNLOCKED); return; } } @@ -1081,16 +1096,16 @@ static void HWR_GetBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch, INT // (it have a liste of mipmap) // this malloc is cleared in HWR_FreeTextureCache // (...) unfortunately z_malloc fragment alot the memory :(so malloc is better - newmip = calloc(1, sizeof (*newmip)); - if (newmip == NULL) + newMipmap = calloc(1, sizeof (*newMipmap)); + if (newMipmap == NULL) I_Error("%s: Out of memory", "HWR_GetBlendedTexture"); - grmip->nextcolormap = newmip; - newmip->colormap = colormap; + grMipmap->nextcolormap = newMipmap; + newMipmap->colormap = colormap; - HWR_CreateBlendedTexture(gpatch, blendgpatch, newmip, skinnum, color); + HWR_CreateBlendedTexture(patch, blendpatch, newMipmap, skinnum, color); - HWD.pfnSetTexture(newmip); - Z_ChangeTag(newmip->data, PU_HWRMODELTEXTURE_UNLOCKED); + HWD.pfnSetTexture(newMipmap); + Z_ChangeTag(newMipmap->data, PU_HWRMODELTEXTURE_UNLOCKED); } #define NORMALFOG 0x00000000 @@ -1177,9 +1192,11 @@ static UINT8 HWR_GetModelSprite2(md2_t *md2, skin_t *skin, UINT8 spr2, player_t return spr2; } -static void adjustTextureCoords(model_t *model, GLPatch_t *gpatch) +static void adjustTextureCoords(model_t *model, patch_t *patch) { int i; + GLPatch_t *gpatch = ((GLPatch_t *)patch->hardware); + for (i = 0; i < model->numMeshes; i++) { int j; @@ -1264,7 +1281,8 @@ boolean HWR_DrawModel(gl_vissprite_t *spr) // Look at HWR_ProjectSprite for more { - GLPatch_t *gpatch; + patch_t *gpatch, *blendgpatch; + GLPatch_t *hwrPatch = NULL, *hwrBlendPatch = NULL; INT32 durs = spr->mobj->state->tics; INT32 tics = spr->mobj->tics; //mdlframe_t *next = NULL; @@ -1309,14 +1327,26 @@ boolean HWR_DrawModel(gl_vissprite_t *spr) // texture loading before model init, so it knows if sprite graphics are used, which // means that texture coordinates have to be adjusted gpatch = md2->grpatch; - if (!gpatch || ((!gpatch->mipmap->format || !gpatch->mipmap->downloaded) && !md2->notexturefile)) - md2_loadTexture(md2); - gpatch = md2->grpatch; // Load it again, because it isn't being loaded into gpatch after md2_loadtexture... + if (gpatch) + hwrPatch = ((GLPatch_t *)gpatch->hardware); - if ((gpatch && gpatch->mipmap->format) // don't load the blend texture if the base texture isn't available - && (!md2->blendgrpatch - || ((!((GLPatch_t *)md2->blendgrpatch)->mipmap->format || !((GLPatch_t *)md2->blendgrpatch)->mipmap->downloaded) - && !md2->noblendfile))) + if (!gpatch || !hwrPatch + || ((!hwrPatch->mipmap->format || !hwrPatch->mipmap->downloaded) && !md2->notexturefile)) + md2_loadTexture(md2); + + // Load it again, because it isn't being loaded into gpatch after md2_loadtexture... + gpatch = md2->grpatch; + if (gpatch) + hwrPatch = ((GLPatch_t *)gpatch->hardware); + + // Load blend texture + blendgpatch = md2->blendgrpatch; + if (blendgpatch) + hwrBlendPatch = ((GLPatch_t *)blendgpatch->hardware); + + if ((gpatch && hwrPatch && hwrPatch->mipmap->format) // don't load the blend texture if the base texture isn't available + && (!blendgpatch || !hwrBlendPatch + || ((!hwrBlendPatch->mipmap->format || !hwrBlendPatch->mipmap->downloaded) && !md2->noblendfile))) md2_loadBlendTexture(md2); if (md2->error) @@ -1332,7 +1362,7 @@ boolean HWR_DrawModel(gl_vissprite_t *spr) md2_printModelInfo(md2->model); // if model uses sprite patch as texture, then // adjust texture coordinates to take power of two textures into account - if (!gpatch || !gpatch->mipmap->format) + if (!gpatch || !hwrPatch->mipmap->format) adjustTextureCoords(md2->model, spr->gpatch); HWD.pfnCreateModelVBOs(md2->model); } @@ -1352,7 +1382,7 @@ boolean HWR_DrawModel(gl_vissprite_t *spr) finalscale = md2->scale; //Hurdler: arf, I don't like that implementation at all... too much crappy - if (gpatch && gpatch->mipmap->format) // else if meant that if a texture couldn't be loaded, it would just end up using something else's texture + if (gpatch && hwrPatch && hwrPatch->mipmap->format) // else if meant that if a texture couldn't be loaded, it would just end up using something else's texture { INT32 skinnum = TC_DEFAULT; @@ -1385,13 +1415,12 @@ boolean HWR_DrawModel(gl_vissprite_t *spr) } // Translation or skin number found - HWR_GetBlendedTexture(gpatch, (GLPatch_t *)md2->blendgrpatch, skinnum, spr->colormap, (skincolornum_t)spr->mobj->color); + HWR_GetBlendedTexture(gpatch, blendgpatch, skinnum, spr->colormap, (skincolornum_t)spr->mobj->color); } else { // Sprite - gpatch = spr->gpatch; //W_CachePatchNum(spr->patchlumpnum, PU_CACHE); - HWR_GetMappedPatch(gpatch, spr->colormap); + HWR_GetMappedPatch(spr->gpatch, spr->colormap); } if (spr->mobj->frame & FF_ANIMATE) diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index 461966224..fbe65bc17 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -1317,6 +1317,17 @@ void SetStates(void) } +// -----------------+ +// DeleteTexture : Deletes a texture from the GPU and frees its data +// -----------------+ +EXPORT void HWRAPI(DeleteTexture) (FTextureInfo *pTexInfo) +{ + if (pTexInfo->downloaded) + pglDeleteTextures(1, (GLuint *)&pTexInfo->downloaded); + pTexInfo->downloaded = 0; +} + + // -----------------+ // Flush : flush OpenGL textures // : Clear list of downloaded mipmaps @@ -1327,9 +1338,7 @@ void Flush(void) while (gl_cachehead) { - if (gl_cachehead->downloaded) - pglDeleteTextures(1, (GLuint *)&gl_cachehead->downloaded); - gl_cachehead->downloaded = 0; + DeleteTexture(gl_cachehead); gl_cachehead = gl_cachehead->nextmipmap; } gl_cachetail = gl_cachehead = NULL; //Hurdler: well, gl_cachehead is already NULL diff --git a/src/hu_stuff.c b/src/hu_stuff.c index b61192533..ff9f274fc 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -2038,9 +2038,6 @@ static void HU_DrawDemoInfo(void) // void HU_Drawer(void) { - if (needpatchrecache) - R_ReloadHUDGraphics(); - #ifndef NONET // draw chat string plus cursor if (chat_on) diff --git a/src/lua_infolib.c b/src/lua_infolib.c index 830d97625..712983cac 100644 --- a/src/lua_infolib.c +++ b/src/lua_infolib.c @@ -379,7 +379,7 @@ static int lib_setSpriteInfo(lua_State *L) return luaL_error(L, "spriteinfo[] index %d out of range (1 - %d)", i, NUMSPRITES-1); #ifdef ROTSPRITE if (sprites != NULL) - R_FreeSingleRotSprite(&sprites[i]); + R_FreeRotSprite(&sprites[i]); #endif info = &spriteinfo[i]; // get the spriteinfo to assign to. } @@ -464,7 +464,7 @@ static int spriteinfo_set(lua_State *L) #ifdef ROTSPRITE if (sprites != NULL) - R_FreeSingleRotSprite(&sprites[sprinfo-spriteinfo]); + R_FreeRotSprite(&sprites[sprinfo-spriteinfo]); #endif if (fastcmp(field, "pivot")) diff --git a/src/m_menu.c b/src/m_menu.c index 59d297e1a..3d6b1c0fa 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1490,7 +1490,7 @@ static menuitem_t OP_SoundOptionsMenu[] = {IT_STRING | IT_CVAR, NULL, "MIDI Music", &cv_gamemidimusic, 36}, {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "MIDI Music Volume", &cv_midimusicvolume, 41}, - + {IT_STRING | IT_CVAR, NULL, "Music Preference", &cv_musicpref, 51}, {IT_HEADER, NULL, "Miscellaneous", NULL, 61}, @@ -5593,9 +5593,6 @@ static void M_DrawLevelPlatterWideMap(UINT8 row, UINT8 col, INT32 x, INT32 y, bo if (map <= 0) return; - if (needpatchrecache) - M_CacheLevelPlatter(); - // A 564x100 image of the level as entry MAPxxW if (!(levelselect.rows[row].mapavailable[col])) { @@ -5627,9 +5624,6 @@ static void M_DrawLevelPlatterMap(UINT8 row, UINT8 col, INT32 x, INT32 y, boolea if (map <= 0) return; - if (needpatchrecache) - M_CacheLevelPlatter(); - // A 160x100 image of the level as entry MAPxxP if (!(levelselect.rows[row].mapavailable[col])) { @@ -6452,10 +6446,6 @@ static void M_DrawAddons(void) return; } - // Lactozilla: Load addons menu patches. - if (needpatchrecache) - M_LoadAddonsPatches(); - if (Playing()) V_DrawCenteredString(BASEVIDWIDTH/2, 5, warningflags, "Adding files mid-game may cause problems."); else @@ -7610,9 +7600,6 @@ static void M_DrawSoundTest(void) fixed_t hscale = FRACUNIT/2, vscale = FRACUNIT/2, bounce = 0; UINT8 frame[4] = {0, 0, -1, SKINCOLOR_RUBY}; - if (needpatchrecache) - M_CacheSoundTest(); - // let's handle the ticker first. ideally we'd tick this somewhere else, BUT... if (curplaying) { @@ -8260,9 +8247,6 @@ static void M_DrawLoadGameData(void) if (vid.width != BASEVIDWIDTH*vid.dupx) hsep = (hsep*vid.width)/(BASEVIDWIDTH*vid.dupx); - if (needpatchrecache) - M_CacheLoadGameData(); - for (i = -2; i <= 2; i++) { savetodraw = (saveSlotSelected + i + numsaves)%numsaves; @@ -8966,7 +8950,6 @@ void M_ForceSaveSlotSelected(INT32 sslot) // CHARACTER SELECT // ================ -// lactozilla: sometimes the renderer changes and these patches don't exist anymore static void M_CacheCharacterSelectEntry(INT32 i, INT32 skinnum) { if (!(description[i].picname[0])) @@ -8987,22 +8970,6 @@ static void M_CacheCharacterSelectEntry(INT32 i, INT32 skinnum) description[i].namepic = W_CachePatchName(description[i].nametag, PU_PATCH); } -static void M_CacheCharacterSelect(void) -{ - INT32 i, skinnum; - - for (i = 0; i < MAXSKINS; i++) - { - if (!description[i].used) - continue; - - // Already set in M_SetupChoosePlayer - skinnum = description[i].skinnum[0]; - if ((skinnum != -1) && (R_SkinUsable(-1, skinnum))) - M_CacheCharacterSelectEntry(i, skinnum); - } -} - static UINT8 M_SetupChoosePlayerDirect(INT32 choice) { INT32 skinnum; @@ -9209,10 +9176,6 @@ static void M_DrawSetupChoosePlayerMenu(void) INT32 x, y; INT32 w = (vid.width/vid.dupx); - // lactozilla: the renderer changed so recache patches - if (needpatchrecache) - M_CacheCharacterSelect(); - if (abs(char_scroll) > FRACUNIT) char_scroll -= (char_scroll>>2); else // close enough. @@ -10584,10 +10547,6 @@ void M_DrawMarathon(void) angle_t fa; INT32 dupz = (vid.dupx < vid.dupy ? vid.dupx : vid.dupy), xspan = (vid.width/dupz), yspan = (vid.height/dupz), diffx = (xspan - BASEVIDWIDTH)/2, diffy = (yspan - BASEVIDHEIGHT)/2, maxy = BASEVIDHEIGHT + diffy; - // lactozilla: the renderer changed so recache patches - if (needpatchrecache) - M_CacheCharacterSelect(); - curbgxspeed = 0; curbgyspeed = 18; diff --git a/src/r_data.c b/src/r_data.c index befb73c20..4b2ff7484 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -482,7 +482,7 @@ static UINT8 *R_GenerateTexture(size_t texnum) UINT8 *blocktex; texture_t *texture; texpatch_t *patch; - patch_t *realpatch; + softwarepatch_t *realpatch; UINT8 *pdata; int x, x1, x2, i, width, height; size_t blocksize; @@ -512,7 +512,7 @@ static UINT8 *R_GenerateTexture(size_t texnum) lumpnum = patch->lump; lumplength = W_LumpLengthPwad(wadnum, lumpnum); pdata = W_CacheLumpNumPwad(wadnum, lumpnum, PU_CACHE); - realpatch = (patch_t *)pdata; + realpatch = (softwarepatch_t *)pdata; #ifndef NO_PNG_LUMPS if (R_IsLumpPNG((UINT8 *)realpatch, lumplength)) @@ -608,7 +608,7 @@ static UINT8 *R_GenerateTexture(size_t texnum) lumpnum = patch->lump; pdata = W_CacheLumpNumPwad(wadnum, lumpnum, PU_CACHE); lumplength = W_LumpLengthPwad(wadnum, lumpnum); - realpatch = (patch_t *)pdata; + realpatch = (softwarepatch_t *)pdata; dealloc = true; #ifndef NO_PNG_LUMPS diff --git a/src/r_defs.h b/src/r_defs.h index 132106bc8..10fc99ccd 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -652,16 +652,26 @@ typedef enum RGBA32 = 4, // 32 bit rgba } pic_mode_t; -#if defined(_MSC_VER) -#pragma pack(1) -#endif - // Patches. // A patch holds one or more columns. // Patches are used for sprites and all masked pictures, and we compose // textures from the TEXTURES list of patches. // -// WARNING: this structure is cloned in GLPatch_t +typedef struct +{ + INT16 width, height; + INT16 leftoffset, topoffset; + + INT32 *columnofs; // Column offsets. This is relative to patch->columns + UINT8 *columns; // Software column data + + void *hardware; // OpenGL patch, allocated whenever necessary +} patch_t; + +#if defined(_MSC_VER) +#pragma pack(1) +#endif + typedef struct { INT16 width; // bounding box size @@ -670,7 +680,7 @@ typedef struct INT16 topoffset; // pixels below the origin INT32 columnofs[8]; // only [width] used // the [0] is &columnofs[width] -} ATTRPACK patch_t; +} ATTRPACK softwarepatch_t; #ifdef _MSC_VER #pragma warning(disable : 4200) diff --git a/src/r_main.c b/src/r_main.c index 4f79dd8db..b70e6f25f 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -1572,14 +1572,6 @@ void R_InitHardwareMode(void) } #endif -void R_ReloadHUDGraphics(void) -{ - CONS_Debug(DBG_RENDER, "R_ReloadHUDGraphics()...\n"); - ST_LoadGraphics(); - HU_LoadGraphics(); - ST_ReloadSkinFaceGraphics(); -} - // ========================================================================= // ENGINE COMMANDS & VARS // ========================================================================= diff --git a/src/r_main.h b/src/r_main.h index 729ec6973..cc098462d 100644 --- a/src/r_main.h +++ b/src/r_main.h @@ -115,7 +115,6 @@ void R_Init(void); #ifdef HWRENDER void R_InitHardwareMode(void); #endif -void R_ReloadHUDGraphics(void); void R_CheckViewMorph(void); void R_ApplyViewMorph(void); diff --git a/src/r_patch.c b/src/r_patch.c index 8980eda58..783c1fbec 100644 --- a/src/r_patch.c +++ b/src/r_patch.c @@ -50,6 +50,98 @@ static unsigned char imgbuf[1<<26]; +// +// Creates a patch. +// Assumes a PU_PATCH zone memory tag and no user, but can always be set later +// + +patch_t *Patch_Create(softwarepatch_t *source, size_t srcsize, void *dest) +{ + patch_t *patch = (dest == NULL) ? Z_Calloc(sizeof(patch_t), PU_PATCH, NULL) : (patch_t *)(dest); + + if (source) + { + INT32 col, colsize; + size_t size = sizeof(INT32) * source->width; + size_t offs = (sizeof(INT16) * 4) + size; + + patch->width = source->width; + patch->height = source->height; + patch->leftoffset = source->leftoffset; + patch->topoffset = source->topoffset; + patch->columnofs = Z_Calloc(size, PU_PATCH, NULL); + + for (col = 0; col < source->width; col++) + { + // This makes the column offsets relative to the column data itself, + // instead of the entire patch data + patch->columnofs[col] = LONG(source->columnofs[col]) - offs; + } + + if (!srcsize) + I_Error("R_CreatePatch: no source size!"); + + colsize = (INT32)(srcsize) - (INT32)offs; + if (colsize <= 0) + I_Error("R_CreatePatch: no column data!"); + + patch->columns = Z_Calloc(colsize, PU_PATCH, NULL); + M_Memcpy(patch->columns, ((UINT8 *)source + LONG(source->columnofs[0])), colsize); + } + + if (patch->hardware) + I_Error("wtf?\n"); + + return patch; +} + +// +// Frees a patch from memory. +// + +void Patch_Free(patch_t *patch) +{ +#ifdef HWRENDER + if (patch->hardware) + HWR_FreeTexture(patch); +#endif + + if (patch->columnofs) + Z_Free(patch->columnofs); + if (patch->columns) + Z_Free(patch->columns); + + Z_Free(patch); +} + +#ifdef HWRENDER +// +// Allocates a hardware patch. +// + +void *Patch_AllocateHardwarePatch(patch_t *patch) +{ + if (!patch->hardware) + { + GLPatch_t *grPatch = Z_Calloc(sizeof(GLPatch_t), PU_HWRPATCHINFO, &patch->hardware); + grPatch->mipmap = Z_Calloc(sizeof(GLMipmap_t), PU_HWRPATCHINFO, &grPatch->mipmap); + } + return (void *)(patch->hardware); +} + +// +// Creates a hardware patch. +// + +void *Patch_CreateGL(patch_t *patch) +{ + GLPatch_t *grPatch = (GLPatch_t *)Patch_AllocateHardwarePatch(patch); + if (!grPatch->mipmap->data) // Run HWR_MakePatch in all cases, to recalculate some things + HWR_MakePatch(patch, grPatch, grPatch->mipmap, false); + return grPatch; +} +#endif // HWRENDER + // // R_CheckIfPatch // @@ -177,7 +269,7 @@ void R_PatchToFlat(patch_t *patch, UINT8 *flat) for (col = 0; col < SHORT(patch->width); col++, desttop++) { INT32 topdelta, prevdelta = -1; - column = (column_t *)((UINT8 *)patch + LONG(patch->columnofs[col])); + column = (column_t *)((UINT8 *)patch->columns + (patch->columnofs[col])); while (column->topdelta != 0xff) { @@ -220,7 +312,7 @@ void R_PatchToMaskedFlat(patch_t *patch, UINT16 *raw, boolean flip) for (col = 0; col < SHORT(patch->width); col++, desttop++) { INT32 topdelta, prevdelta = -1; - column = (column_t *)((UINT8 *)patch + LONG(patch->columnofs[flip ? (patch->width-1-col) : col])); + column = (column_t *)((UINT8 *)patch->columns + (patch->columnofs[flip ? (patch->width-1-col) : col])); while (column->topdelta != 0xff) { topdelta = column->topdelta; @@ -244,7 +336,7 @@ void R_PatchToMaskedFlat(patch_t *patch, UINT16 *raw, boolean flip) // // Convert a flat to a patch. // -patch_t *R_FlatToPatch(UINT8 *raw, UINT16 width, UINT16 height, UINT16 leftoffset, UINT16 topoffset, size_t *destsize, boolean transparency) +softwarepatch_t *R_FlatToPatch(UINT8 *raw, UINT16 width, UINT16 height, UINT16 leftoffset, UINT16 topoffset, size_t *destsize, boolean transparency) { UINT32 x, y; UINT8 *img; @@ -350,7 +442,7 @@ patch_t *R_FlatToPatch(UINT8 *raw, UINT16 width, UINT16 height, UINT16 leftoffse if (destsize != NULL) *destsize = size; - return (patch_t *)img; + return (softwarepatch_t *)img; } // @@ -359,7 +451,7 @@ patch_t *R_FlatToPatch(UINT8 *raw, UINT16 width, UINT16 height, UINT16 leftoffse // Convert a masked flat to a patch. // Explanation of "masked" flats in R_PatchToMaskedFlat. // -patch_t *R_MaskedFlatToPatch(UINT16 *raw, UINT16 width, UINT16 height, UINT16 leftoffset, UINT16 topoffset, size_t *destsize) +softwarepatch_t *R_MaskedFlatToPatch(UINT16 *raw, UINT16 width, UINT16 height, UINT16 leftoffset, UINT16 topoffset, size_t *destsize) { UINT32 x, y; UINT8 *img; @@ -464,7 +556,7 @@ patch_t *R_MaskedFlatToPatch(UINT16 *raw, UINT16 width, UINT16 height, UINT16 le if (destsize != NULL) *destsize = size; - return (patch_t *)img; + return (softwarepatch_t *)img; } // @@ -736,7 +828,7 @@ UINT8 *R_PNGToFlat(UINT16 *width, UINT16 *height, UINT8 *png, size_t size) // // Convert a PNG to a patch. // -patch_t *R_PNGToPatch(const UINT8 *png, size_t size, size_t *destsize) +softwarepatch_t *R_PNGToPatch(const UINT8 *png, size_t size, size_t *destsize) { UINT16 width, height; INT16 topoffset = 0, leftoffset = 0; @@ -981,7 +1073,7 @@ static void R_ParseSpriteInfo(boolean spr2) #ifdef ROTSPRITE if ((sprites != NULL) && (!spr2)) - R_FreeSingleRotSprite(&sprites[sprnum]); + R_FreeRotSprite(&sprites[sprnum]); #endif // Left Curly Brace @@ -1143,10 +1235,10 @@ static UINT16 GetPatchPixel(patch_t *patch, INT32 x, INT32 y, boolean flip) column_t *column; UINT8 *source; - if (x >= 0 && x < SHORT(patch->width)) + if (x >= 0 && x < patch->width) { INT32 topdelta, prevdelta = -1; - column = (column_t *)((UINT8 *)patch + LONG(patch->columnofs[flip ? (patch->width-1-x) : x])); + column = (column_t *)((UINT8 *)patch->columns + (patch->columnofs[flip ? (patch->width-1-x) : x])); while (column->topdelta != 0xff) { topdelta = column->topdelta; @@ -1194,8 +1286,8 @@ void R_CacheRotSprite(spritenum_t sprnum, UINT8 frame, spriteinfo_t *sprinfo, sp { UINT32 i; INT32 angle; - patch_t *patch; - patch_t *newpatch; + patch_t *patch, *newpatch; + softwarepatch_t *swpatch; UINT16 *rawdst; size_t size; INT32 bflip = (flip != 0x00); @@ -1212,28 +1304,14 @@ void R_CacheRotSprite(spritenum_t sprnum, UINT8 frame, spriteinfo_t *sprinfo, sp INT32 width, height, leftoffset; fixed_t ca, sa; lumpnum_t lump = sprframe->lumppat[rot]; -#ifndef NO_PNG_LUMPS - size_t lumplength; -#endif if (lump == LUMPERROR) return; - patch = (patch_t *)W_CacheLumpNum(lump, PU_STATIC); -#ifndef NO_PNG_LUMPS - lumplength = W_LumpLength(lump); - - if (R_IsLumpPNG((UINT8 *)patch, lumplength)) - patch = R_PNGToPatch((UINT8 *)patch, lumplength, NULL); - else -#endif - // Because there's something wrong with SPR_DFLM, I guess - if (!R_CheckIfPatch(lump)) - return; - - width = SHORT(patch->width); - height = SHORT(patch->height); - leftoffset = SHORT(patch->leftoffset); + patch = (patch_t *)W_CachePatchNum(lump, PU_STATIC); + width = patch->width; + height = patch->height; + leftoffset = patch->leftoffset; // rotation pivot px = SPRITE_XCENTER; @@ -1345,37 +1423,33 @@ void R_CacheRotSprite(spritenum_t sprnum, UINT8 frame, spriteinfo_t *sprinfo, sp } // make patch - newpatch = R_MaskedFlatToPatch(rawdst, newwidth, newheight, 0, 0, &size); + swpatch = R_MaskedFlatToPatch(rawdst, newwidth, newheight, 0, 0, &size); { - newpatch->leftoffset = (newpatch->width / 2) + (leftoffset - px); - newpatch->topoffset = (newpatch->height / 2) + (SHORT(patch->topoffset) - py); + swpatch->leftoffset = (swpatch->width / 2) + (leftoffset - px); + swpatch->topoffset = (swpatch->height / 2) + (patch->topoffset - py); } //BP: we cannot use special tric in hardware mode because feet in ground caused by z-buffer if (rendermode != render_none) // not for psprite - newpatch->topoffset += FEETADJUST>>FRACBITS; + swpatch->topoffset += FEETADJUST>>FRACBITS; // P_PrecacheLevel if (devparm) spritememory += size; // convert everything to little-endian, for big-endian support - newpatch->width = SHORT(newpatch->width); - newpatch->height = SHORT(newpatch->height); - newpatch->leftoffset = SHORT(newpatch->leftoffset); - newpatch->topoffset = SHORT(newpatch->topoffset); + swpatch->width = SHORT(swpatch->width); + swpatch->height = SHORT(swpatch->height); + swpatch->leftoffset = SHORT(swpatch->leftoffset); + swpatch->topoffset = SHORT(swpatch->topoffset); + + newpatch = Patch_Create(swpatch, size, NULL); #ifdef HWRENDER if (rendermode == render_opengl) - { - GLPatch_t *grPatch = Z_Calloc(sizeof(GLPatch_t), PU_HWRPATCHINFO, NULL); - grPatch->mipmap = Z_Calloc(sizeof(GLMipmap_t), PU_HWRPATCHINFO, NULL); - grPatch->rawpatch = newpatch; - sprframe->rotsprite.patch[rot][angle] = (patch_t *)grPatch; - HWR_MakePatch(newpatch, grPatch, grPatch->mipmap, false); - } - else -#endif // HWRENDER - sprframe->rotsprite.patch[rot][angle] = newpatch; + Patch_CreateGL(newpatch); +#endif + + sprframe->rotsprite.patch[rot][angle] = newpatch; // free rotated image data Z_Free(rawdst); @@ -1386,6 +1460,7 @@ void R_CacheRotSprite(spritenum_t sprnum, UINT8 frame, spriteinfo_t *sprinfo, sp // free image data Z_Free(patch); + Z_Free(swpatch); } #undef SPRITE_XCENTER #undef SPRITE_YCENTER @@ -1394,11 +1469,11 @@ void R_CacheRotSprite(spritenum_t sprnum, UINT8 frame, spriteinfo_t *sprinfo, sp } // -// R_FreeSingleRotSprite +// R_FreeRotSprite // // Free sprite rotation data from memory, for a single spritedef. // -void R_FreeSingleRotSprite(spritedef_t *spritedef) +void R_FreeRotSprite(spritedef_t *spritedef) { UINT8 frame; INT32 rot, ang; @@ -1414,30 +1489,8 @@ void R_FreeSingleRotSprite(spritedef_t *spritedef) { patch_t *rotsprite = sprframe->rotsprite.patch[rot][ang]; if (rotsprite) - { -#ifdef HWRENDER - if (rendermode == render_opengl) - { - GLPatch_t *grPatch = (GLPatch_t *)rotsprite; - if (grPatch->rawpatch) - { - Z_Free(grPatch->rawpatch); - grPatch->rawpatch = NULL; - } - if (grPatch->mipmap) - { - if (grPatch->mipmap->data) - { - Z_Free(grPatch->mipmap->data); - grPatch->mipmap->data = NULL; - } - Z_Free(grPatch->mipmap); - grPatch->mipmap = NULL; - } - } -#endif - Z_Free(rotsprite); - } + Patch_Free(rotsprite); + rotsprite = NULL; } sprframe->rotsprite.cached &= ~(1<sprites; for (i = 0; i < NUMPLAYERSPRITES*2; i++) { - R_FreeSingleRotSprite(skinsprites); + R_FreeRotSprite(skinsprites); skinsprites++; } } - -// -// R_FreeAllRotSprite -// -// Free ALL sprite rotation data from memory. -// -void R_FreeAllRotSprite(void) -{ - INT32 i; - size_t s; - for (s = 0; s < numsprites; s++) - R_FreeSingleRotSprite(&sprites[s]); - for (i = 0; i < numskins; ++i) - R_FreeSkinRotSprite(i); -} #endif diff --git a/src/r_patch.h b/src/r_patch.h index a2db6320c..de4981fba 100644 --- a/src/r_patch.h +++ b/src/r_patch.h @@ -37,21 +37,30 @@ typedef struct boolean available; } spriteinfo_t; +// Patch functions +patch_t *Patch_Create(softwarepatch_t *source, size_t srcsize, void *dest); +void Patch_Free(patch_t *patch); + +#ifdef HWRENDER +void *Patch_AllocateHardwarePatch(patch_t *patch); +void *Patch_CreateGL(patch_t *patch); +#endif + // Conversions between patches / flats / textures... boolean R_CheckIfPatch(lumpnum_t lump); void R_TextureToFlat(size_t tex, UINT8 *flat); void R_PatchToFlat(patch_t *patch, UINT8 *flat); void R_PatchToMaskedFlat(patch_t *patch, UINT16 *raw, boolean flip); -patch_t *R_FlatToPatch(UINT8 *raw, UINT16 width, UINT16 height, UINT16 leftoffset, UINT16 topoffset, size_t *destsize, boolean transparency); -patch_t *R_MaskedFlatToPatch(UINT16 *raw, UINT16 width, UINT16 height, UINT16 leftoffset, UINT16 topoffset, size_t *destsize); +softwarepatch_t *R_FlatToPatch(UINT8 *raw, UINT16 width, UINT16 height, UINT16 leftoffset, UINT16 topoffset, size_t *destsize, boolean transparency); +softwarepatch_t *R_MaskedFlatToPatch(UINT16 *raw, UINT16 width, UINT16 height, UINT16 leftoffset, UINT16 topoffset, size_t *destsize); -// Portable Network Graphics +// PNGs boolean R_IsLumpPNG(const UINT8 *d, size_t s); #define W_ThrowPNGError(lumpname, wadfilename) I_Error("W_Wad: Lump \"%s\" in file \"%s\" is a .png - please convert to either Doom or Flat (raw) image format.", lumpname, wadfilename); // Fears Of LJ Sonic #ifndef NO_PNG_LUMPS UINT8 *R_PNGToFlat(UINT16 *width, UINT16 *height, UINT8 *png, size_t size); -patch_t *R_PNGToPatch(const UINT8 *png, size_t size, size_t *destsize); +softwarepatch_t *R_PNGToPatch(const UINT8 *png, size_t size, size_t *destsize); boolean R_PNGDimensions(UINT8 *png, INT16 *width, INT16 *height, size_t size); #endif @@ -64,11 +73,10 @@ void R_ParseSPRTINFOLump(UINT16 wadNum, UINT16 lumpNum); #ifdef ROTSPRITE INT32 R_GetRollAngle(angle_t rollangle); void R_CacheRotSprite(spritenum_t sprnum, UINT8 frame, spriteinfo_t *sprinfo, spriteframe_t *sprframe, INT32 rot, UINT8 flip); -void R_FreeSingleRotSprite(spritedef_t *spritedef); +void R_FreeRotSprite(spritedef_t *spritedef); void R_FreeSkinRotSprite(size_t skinnum); extern fixed_t rollcosang[ROTANGLES]; extern fixed_t rollsinang[ROTANGLES]; -void R_FreeAllRotSprite(void); #endif #endif // __R_PATCH__ diff --git a/src/r_segs.c b/src/r_segs.c index d9fc75838..177827892 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -217,7 +217,7 @@ static void R_DrawWallSplats(void) continue; // draw the texture - col = (column_t *)((UINT8 *)patch + LONG(patch->columnofs[texturecolumn])); + col = (column_t *)((UINT8 *)patch->columns + (patch->columnofs[texturecolumn])); R_DrawSplatColumn(col); } } // next splat diff --git a/src/r_things.c b/src/r_things.c index c0795acd5..0636a880d 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -228,7 +228,7 @@ boolean R_AddSingleSpriteDef(const char *sprname, spritedef_t *spritedef, UINT16 UINT8 frame; UINT8 rotation; lumpinfo_t *lumpinfo; - patch_t patch; + softwarepatch_t patch; UINT8 numadded = 0; memset(sprtemp,0xFF, sizeof (sprtemp)); @@ -241,7 +241,7 @@ boolean R_AddSingleSpriteDef(const char *sprname, spritedef_t *spritedef, UINT16 if (spritedef->numframes) // (then spriteframes is not null) { #ifdef ROTSPRITE - R_FreeSingleRotSprite(spritedef); + R_FreeRotSprite(spritedef); #endif // copy the already defined sprite frames M_Memcpy(sprtemp, spritedef->spriteframes, @@ -277,7 +277,7 @@ boolean R_AddSingleSpriteDef(const char *sprname, spritedef_t *spritedef, UINT16 W_ReadLumpHeaderPwad(wadnum, l, &patch, sizeof (patch_t), 0); #ifndef NO_PNG_LUMPS { - patch_t *png = W_CacheLumpNumPwad(wadnum, l, PU_STATIC); + softwarepatch_t *png = W_CacheLumpNumPwad(wadnum, l, PU_STATIC); size_t len = W_LumpLengthPwad(wadnum, l); // lump is a png so convert it if (R_IsLumpPNG((UINT8 *)png, len)) @@ -398,7 +398,7 @@ boolean R_AddSingleSpriteDef(const char *sprname, spritedef_t *spritedef, UINT16 spritedef->numframes < maxframe) // more frames are defined ? { #ifdef ROTSPRITE - R_FreeSingleRotSprite(spritedef); + R_FreeRotSprite(spritedef); #endif Z_Free(spritedef->spriteframes); spritedef->spriteframes = NULL; @@ -910,7 +910,7 @@ static void R_DrawVisSprite(vissprite_t *vis) sprtopscreen = (centeryfrac - FixedMul(dc_texturemid, spryscale)); dc_iscale = (0xffffffffu / (unsigned)spryscale); - column = (column_t *)((UINT8 *)patch + LONG(patch->columnofs[texturecolumn])); + column = (column_t *)((UINT8 *)patch->columns + (patch->columnofs[texturecolumn])); localcolfunc (column); } @@ -928,9 +928,9 @@ static void R_DrawVisSprite(vissprite_t *vis) texturecolumn = frac>>FRACBITS; if (texturecolumn < 0 || texturecolumn >= pwidth) I_Error("R_DrawSpriteRange: bad texturecolumn at %d from end", vis->x2 - dc_x); - column = (column_t *)((UINT8 *)patch + LONG(patch->columnofs[texturecolumn])); + column = (column_t *)((UINT8 *)patch->columns + (patch->columnofs[texturecolumn])); #else - column = (column_t *)((UINT8 *)patch + LONG(patch->columnofs[frac>>FRACBITS])); + column = (column_t *)((UINT8 *)patch->columns + (patch->columnofs[frac>>FRACBITS])); #endif localcolfunc (column); } @@ -995,9 +995,9 @@ static void R_DrawPrecipitationVisSprite(vissprite_t *vis) if (texturecolumn < 0 || texturecolumn >= SHORT(patch->width)) I_Error("R_DrawPrecipitationSpriteRange: bad texturecolumn"); - column = (column_t *)((UINT8 *)patch + LONG(patch->columnofs[texturecolumn])); + column = (column_t *)((UINT8 *)patch->columns + (patch->columnofs[texturecolumn])); #else - column = (column_t *)((UINT8 *)patch + LONG(patch->columnofs[frac>>FRACBITS])); + column = (column_t *)((UINT8 *)patch->columns + (patch->columnofs[frac>>FRACBITS])); #endif R_DrawMaskedColumn(column); } diff --git a/src/screen.c b/src/screen.c index e7ff9e735..f5d19cada 100644 --- a/src/screen.c +++ b/src/screen.c @@ -202,9 +202,6 @@ void SCR_SetMode(void) // Lactozilla: Renderer switching if (setrenderneeded) { - Z_PreparePatchFlush(); - needpatchflush = true; - needpatchrecache = true; VID_CheckRenderer(); if (!setmodeneeded) VID_SetMode(vid.modenum); diff --git a/src/sdl/hwsym_sdl.c b/src/sdl/hwsym_sdl.c index 416c8d2f5..e1845fac8 100644 --- a/src/sdl/hwsym_sdl.c +++ b/src/sdl/hwsym_sdl.c @@ -86,6 +86,7 @@ void *hwSym(const char *funcName,void *handle) GETFUNC(ClearBuffer); GETFUNC(SetTexture); GETFUNC(UpdateTexture); + GETFUNC(DeleteTexture); GETFUNC(ReadRect); GETFUNC(GClipRect); GETFUNC(ClearMipMapCache); diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index 01194a02f..1bb48e468 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -1660,7 +1660,7 @@ static void Impl_SetWindowName(const char *title) static void Impl_SetWindowIcon(void) { if (window && icoSurface) - SDL_SetWindowIcon(window, icoSurface); + SDL_SetWindowIcon(window, icoSurface); } static void Impl_VideoSetupSDLBuffer(void) @@ -1770,7 +1770,7 @@ void I_StartupGraphics(void) // Window icon #ifdef HAVE_IMAGE icoSurface = IMG_ReadXPMFromArray(SDL_icon_xpm); -#endif +#endif // Fury: we do window initialization after GL setup to allow // SDL_GL_LoadLibrary to work well on Windows @@ -1836,6 +1836,7 @@ void VID_StartupOpenGL(void) HWD.pfnClearBuffer = hwSym("ClearBuffer",NULL); HWD.pfnSetTexture = hwSym("SetTexture",NULL); HWD.pfnUpdateTexture = hwSym("UpdateTexture",NULL); + HWD.pfnDeleteTexture = hwSym("DeleteTexture",NULL); HWD.pfnReadRect = hwSym("ReadRect",NULL); HWD.pfnGClipRect = hwSym("GClipRect",NULL); HWD.pfnClearMipMapCache = hwSym("ClearMipMapCache",NULL); diff --git a/src/st_stuff.c b/src/st_stuff.c index d5aa5fbac..f6ba94fcc 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -2755,9 +2755,6 @@ static void ST_overlayDrawer(void) void ST_Drawer(void) { - if (needpatchrecache) - R_ReloadHUDGraphics(); - #ifdef SEENAMES if (cv_seenames.value && cv_allowseenames.value && displayplayer == consoleplayer && seenplayer && seenplayer->mo) { diff --git a/src/v_video.c b/src/v_video.c index b88c4838b..7f07852fa 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -531,7 +531,7 @@ void V_DrawStretchyFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, fixed_t vsca //if (rendermode != render_soft && !con_startup) // Why? if (rendermode == render_opengl) { - HWR_DrawStretchyFixedPatch((GLPatch_t *)patch, x, y, pscale, vscale, scrn, colormap); + HWR_DrawStretchyFixedPatch(patch, x, y, pscale, vscale, scrn, colormap); return; } #endif @@ -716,7 +716,7 @@ void V_DrawStretchyFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, fixed_t vsca // if it's meant to cover the whole screen, black out the rest (ONLY IF TOP LEFT ISN'T TRANSPARENT) if (x == 0 && SHORT(patch->width) == BASEVIDWIDTH && y == 0 && SHORT(patch->height) == BASEVIDHEIGHT) { - column = (const column_t *)((const UINT8 *)(patch) + LONG(patch->columnofs[0])); + column = (const column_t *)((const UINT8 *)(patch->columns) + (patch->columnofs[0])); if (!column->topdelta) { source = (const UINT8 *)(column) + 3; @@ -784,7 +784,7 @@ void V_DrawStretchyFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, fixed_t vsca if (x+offx >= vid.width) // don't draw off the right of the screen (WRAP PREVENTION) break; } - column = (const column_t *)((const UINT8 *)(patch) + LONG(patch->columnofs[col>>FRACBITS])); + column = (const column_t *)((const UINT8 *)(patch->columns) + (patch->columnofs[col>>FRACBITS])); while (column->topdelta != 0xff) { @@ -831,7 +831,7 @@ void V_DrawCroppedPatch(fixed_t x, fixed_t y, fixed_t pscale, INT32 scrn, patch_ //if (rendermode != render_soft && !con_startup) // Not this again if (rendermode == render_opengl) { - HWR_DrawCroppedPatch((GLPatch_t*)patch,x,y,pscale,scrn,sx,sy,w,h); + HWR_DrawCroppedPatch(patch,x,y,pscale,scrn,sx,sy,w,h); return; } #endif @@ -1007,7 +1007,7 @@ void V_DrawCroppedPatch(fixed_t x, fixed_t y, fixed_t pscale, INT32 scrn, patch_ continue; if (x >= vid.width) // don't draw off the right of the screen (WRAP PREVENTION) break; - column = (const column_t *)((const UINT8 *)(patch) + LONG(patch->columnofs[col>>FRACBITS])); + column = (const column_t *)((const UINT8 *)(patch->columns) + (patch->columnofs[col>>FRACBITS])); while (column->topdelta != 0xff) { diff --git a/src/w_wad.c b/src/w_wad.c index e4a19f30e..f40f4eb4a 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -836,11 +836,6 @@ UINT16 W_InitFile(const char *filename, boolean mainfile, boolean startup) Z_Calloc(numlumps * sizeof (*wadfile->lumpcache), PU_STATIC, &wadfile->lumpcache); Z_Calloc(numlumps * sizeof (*wadfile->patchcache), PU_STATIC, &wadfile->patchcache); -#ifdef HWRENDER - // allocates GLPatch info structures and store them in a tree - wadfile->hwrcache = M_AATreeAlloc(AATREE_ZUSER); -#endif - // // add the wadfile // @@ -1676,13 +1671,7 @@ void *W_CacheSoftwarePatchNumPwad(UINT16 wad, UINT16 lump, INT32 tag) if (!lumpcache[lump]) { size_t len = W_LumpLengthPwad(wad, lump); - void *ptr, *lumpdata; -#ifndef NO_PNG_LUMPS - void *srcdata = NULL; -#endif - - ptr = Z_Malloc(len, tag, &lumpcache[lump]); - lumpdata = Z_Malloc(len, tag, NULL); + void *ptr, *dest, *lumpdata = Z_Malloc(len, PU_STATIC, NULL); // read the lump in full W_ReadLumpHeaderPwad(wad, lump, lumpdata, 0, 0); @@ -1692,14 +1681,25 @@ void *W_CacheSoftwarePatchNumPwad(UINT16 wad, UINT16 lump, INT32 tag) if (R_IsLumpPNG((UINT8 *)lumpdata, len)) { size_t newlen; - srcdata = R_PNGToPatch((UINT8 *)lumpdata, len, &newlen); - ptr = Z_Realloc(ptr, newlen, tag, &lumpcache[lump]); - M_Memcpy(ptr, srcdata, newlen); - Z_Free(srcdata); + void *converted = R_PNGToPatch((UINT8 *)lumpdata, len, &newlen); + ptr = Z_Malloc(newlen, PU_STATIC, NULL); + M_Memcpy(ptr, converted, newlen); + Z_Free(converted); + len = newlen; } else // just copy it into the patch cache #endif + { + ptr = Z_Malloc(len, PU_STATIC, NULL); M_Memcpy(ptr, lumpdata, len); + } + + Z_Free(lumpdata); + + dest = Z_Calloc(sizeof(patch_t), tag, &lumpcache[lump]); + Patch_Create(ptr, len, dest); + + Z_Free(ptr); } else Z_ChangeTag(lumpcache[lump], tag); @@ -1714,45 +1714,22 @@ void *W_CacheSoftwarePatchNum(lumpnum_t lumpnum, INT32 tag) void *W_CachePatchNumPwad(UINT16 wad, UINT16 lump, INT32 tag) { -#ifdef HWRENDER - GLPatch_t *grPatch; -#endif + patch_t *patch; if (!TestValidLump(wad, lump)) return NULL; + patch = W_CacheSoftwarePatchNumPwad(wad, lump, tag); + #ifdef HWRENDER // Software-only compile cache the data without conversion if (rendermode == render_soft || rendermode == render_none) #endif - { - return W_CacheSoftwarePatchNumPwad(wad, lump, tag); - } + return (void *)patch; + #ifdef HWRENDER - - grPatch = HWR_GetCachedGLPatchPwad(wad, lump); - - if (grPatch->mipmap->data) - { - if (tag == PU_CACHE) - tag = PU_HWRCACHE; - Z_ChangeTag(grPatch->mipmap->data, tag); - } - else - { - patch_t *ptr = NULL; - - // Only load the patch if we haven't initialised the grPatch yet - if (grPatch->mipmap->width == 0) - ptr = W_CacheLumpNumPwad(grPatch->wadnum, grPatch->lumpnum, PU_STATIC); - - // Run HWR_MakePatch in all cases, to recalculate some things - HWR_MakePatch(ptr, grPatch, grPatch->mipmap, false); - Z_Free(ptr); - } - - // return GLPatch_t, which can be casted to (patch_t) with valid patch header info - return (void *)grPatch; + Patch_CreateGL(patch); + return (void *)patch; #endif } @@ -1767,7 +1744,7 @@ void W_UnlockCachedPatch(void *patch) // have different lifetimes from software's. #ifdef HWRENDER if (rendermode == render_opengl) - HWR_UnlockCachedPatch((GLPatch_t*)patch); + HWR_UnlockCachedPatch((GLPatch_t *)((patch_t *)patch)->hardware); else #endif Z_Unlock(patch); diff --git a/src/w_wad.h b/src/w_wad.h index fddc65529..ee3df9cf4 100644 --- a/src/w_wad.h +++ b/src/w_wad.h @@ -102,10 +102,6 @@ virtlump_t* vres_Find(const virtres_t*, const char*); #define lumpcache_t void * -#ifdef HWRENDER -#include "m_aatree.h" -#endif - // Resource type of the WAD. Yeah, I know this sounds dumb, but I'll leave it like this until I clean up the code further. typedef enum restype { @@ -123,9 +119,6 @@ typedef struct wadfile_s lumpinfo_t *lumpinfo; lumpcache_t *lumpcache; lumpcache_t *patchcache; -#ifdef HWRENDER - aatree_t *hwrcache; // patches are cached in renderer's native format -#endif UINT16 numlumps; // this wad's number of resources FILE *handle; UINT32 filesize; // for network diff --git a/src/win32/win_dll.c b/src/win32/win_dll.c index 3f6c5e290..54526975e 100644 --- a/src/win32/win_dll.c +++ b/src/win32/win_dll.c @@ -107,6 +107,7 @@ static loadfunc_t hwdFuncTable[] = { {"ClearBuffer@12", &hwdriver.pfnClearBuffer}, {"SetTexture@4", &hwdriver.pfnSetTexture}, {"UpdateTexture@4", &hwdriver.pfnUpdateTexture}, + {"DeleteTexture@4", &hwdriver.pfnDeleteTexture}, {"ReadRect@24", &hwdriver.pfnReadRect}, {"GClipRect@20", &hwdriver.pfnGClipRect}, {"ClearMipMapCache@0", &hwdriver.pfnClearMipMapCache}, @@ -139,6 +140,7 @@ static loadfunc_t hwdFuncTable[] = { {"ClearBuffer", &hwdriver.pfnClearBuffer}, {"SetTexture", &hwdriver.pfnSetTexture}, {"UpdateTexture", &hwdriver.pfnUpdateTexture}, + {"DeleteTexture", &hwdriver.pfnDeleteTexture}, {"ReadRect", &hwdriver.pfnReadRect}, {"GClipRect", &hwdriver.pfnGClipRect}, {"ClearMipMapCache", &hwdriver.pfnClearMipMapCache}, diff --git a/src/y_inter.c b/src/y_inter.c index d857d60dc..4810ce7fa 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -158,7 +158,6 @@ typedef struct boolean usebuffer = false; static boolean useinterpic; -static boolean safetorender = true; static y_buffer_t *y_buffer; static INT32 intertic; @@ -175,7 +174,6 @@ static void Y_CalculateCompetitionWinners(void); static void Y_CalculateTimeRaceWinners(void); static void Y_CalculateMatchWinners(void); static void Y_UnloadData(void); -static void Y_CleanupData(void); // Stuff copy+pasted from st_stuff.c #define ST_DrawNumFromHud(h,n) V_DrawTallNum(hudinfo[h].x, hudinfo[h].y, hudinfo[h].f, n) @@ -322,19 +320,6 @@ void Y_IntermissionDrawer(void) if (intertype == int_none || rendermode == render_none) return; - // Lactozilla: Renderer switching - if (needpatchrecache) - { - Y_CleanupData(); - safetorender = false; - } - - if (!safetorender) - V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 31); - - if (!safetorender) - goto dontdrawbg; - if (useinterpic) V_DrawScaledPatch(0, 0, 0, interpic); else if (!usetile) @@ -372,7 +357,6 @@ void Y_IntermissionDrawer(void) if (!LUA_HudEnabled(hud_intermissiontally)) goto skiptallydrawer; -dontdrawbg: if (intertype == int_coop) { INT32 bonusy; @@ -422,17 +406,14 @@ dontdrawbg: bonusy = 150; // Total - if (safetorender) - { - V_DrawScaledPatch(152, bonusy, 0, data.coop.ptotal); - V_DrawTallNum(BASEVIDWIDTH - 68, bonusy + 1, 0, data.coop.total); - } + V_DrawScaledPatch(152, bonusy, 0, data.coop.ptotal); + V_DrawTallNum(BASEVIDWIDTH - 68, bonusy + 1, 0, data.coop.total); bonusy -= (3*SHORT(tallnum[0]->height)/2) + 1; // Draw bonuses for (i = 3; i >= 0; --i) { - if (data.coop.bonuses[i].display && safetorender) + if (data.coop.bonuses[i].display) { V_DrawScaledPatch(152, bonusy, 0, data.coop.bonuspatches[i]); V_DrawTallNum(BASEVIDWIDTH - 68, bonusy + 1, 0, data.coop.bonuses[i].points); @@ -661,8 +642,7 @@ dontdrawbg: char strtime[10]; // draw the header - if (safetorender) - V_DrawScaledPatch(112, 2, 0, data.match.result); + V_DrawScaledPatch(112, 2, 0, data.match.result); // draw the level name V_DrawCenteredString(BASEVIDWIDTH/2, 20, 0, data.match.levelstring); @@ -1218,8 +1198,6 @@ void Y_StartIntermission(void) I_Error("endtic is dirty"); #endif - safetorender = true; - if (!multiplayer) { timer = 0; @@ -2067,7 +2045,6 @@ void Y_EndIntermission(void) } #define UNLOAD(x) if (x) {Z_ChangeTag(x, PU_CACHE);} x = NULL; -#define CLEANUP(x) x = NULL; // // Y_UnloadData @@ -2118,45 +2095,3 @@ static void Y_UnloadData(void) break; } } - -static void Y_CleanupData(void) -{ - // unload the background patches - CLEANUP(bgpatch); - CLEANUP(bgtile); - CLEANUP(interpic); - - switch (intertype) - { - case int_coop: - // unload the coop and single player patches - CLEANUP(data.coop.bonuspatches[3]); - CLEANUP(data.coop.bonuspatches[2]); - CLEANUP(data.coop.bonuspatches[1]); - CLEANUP(data.coop.bonuspatches[0]); - CLEANUP(data.coop.ptotal); - break; - case int_spec: - // unload the special stage patches - //CLEANUP(data.spec.cemerald); - //CLEANUP(data.spec.nowsuper); - CLEANUP(data.spec.bonuspatches[1]); - CLEANUP(data.spec.bonuspatches[0]); - CLEANUP(data.spec.pscore); - CLEANUP(data.spec.pcontinues); - break; - case int_match: - case int_race: - CLEANUP(data.match.result); - break; - case int_ctf: - CLEANUP(data.match.blueflag); - CLEANUP(data.match.redflag); - break; - default: - //without this default, - //int_none, int_tag, int_chaos, and int_classicrace - //are not handled - break; - } -} diff --git a/src/z_zone.c b/src/z_zone.c index 2387a1143..7a6dfe040 100644 --- a/src/z_zone.c +++ b/src/z_zone.c @@ -499,33 +499,6 @@ void Z_FreeTags(INT32 lowtag, INT32 hightag) // Utility functions // ----------------- -// for renderer switching -boolean needpatchflush = false; -boolean needpatchrecache = false; - -// flush all patches from memory -void Z_FlushCachedPatches(void) -{ - CONS_Debug(DBG_RENDER, "Z_FlushCachedPatches()...\n"); - Z_FreeTag(PU_PATCH); - Z_FreeTag(PU_HUDGFX); - Z_FreeTag(PU_HWRPATCHINFO); - Z_FreeTag(PU_HWRMODELTEXTURE); - Z_FreeTag(PU_HWRCACHE); - Z_FreeTag(PU_HWRCACHE_UNLOCKED); - Z_FreeTag(PU_HWRPATCHINFO_UNLOCKED); - Z_FreeTag(PU_HWRMODELTEXTURE_UNLOCKED); -} - -// happens before a renderer switch -void Z_PreparePatchFlush(void) -{ - CONS_Debug(DBG_RENDER, "Z_PreparePatchFlush()...\n"); -#ifdef ROTSPRITE - R_FreeAllRotSprite(); -#endif -} - // starting value of nextcleanup #define CLEANUPCOUNT 2000 diff --git a/src/z_zone.h b/src/z_zone.h index 5cbcc6655..c9dafc1ae 100644 --- a/src/z_zone.h +++ b/src/z_zone.h @@ -144,10 +144,4 @@ size_t Z_TagsUsage(INT32 lowtag, INT32 hightag); char *Z_StrDup(const char *in); #define Z_Unlock(p) (void)p // TODO: remove this now that NDS code has been removed -// For renderer switching -extern boolean needpatchflush; -extern boolean needpatchrecache; -void Z_FlushCachedPatches(void); -void Z_PreparePatchFlush(void); - #endif From 2a0e47e28fb2aa5ae2ae127d2563c08dad92101f Mon Sep 17 00:00:00 2001 From: Jaime Passos Date: Sat, 8 Aug 2020 14:56:04 -0300 Subject: [PATCH 0073/1080] Remove LUA_PATCH_SAFETY --- src/doomdef.h | 3 -- src/lua_hudlib.c | 80 ------------------------------------------------ src/r_defs.h | 18 ----------- 3 files changed, 101 deletions(-) diff --git a/src/doomdef.h b/src/doomdef.h index fab83d38c..d45bd3fad 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -629,9 +629,6 @@ extern const char *compdate, *comptime, *comprevision, *compbranch; /// \note Required for proper collision with moving sloped surfaces that have sector specials on them. #define SECTORSPECIALSAFTERTHINK -/// Cache patches in Lua in a way that renderer switching will work flawlessly. -//#define LUA_PATCH_SAFETY - /// Sprite rotation #define ROTSPRITE #define ROTANGLES 72 // Needs to be a divisor of 360 (45, 60, 90, 120...) diff --git a/src/lua_hudlib.c b/src/lua_hudlib.c index 4aa70574b..d8375e1e8 100644 --- a/src/lua_hudlib.c +++ b/src/lua_hudlib.c @@ -35,11 +35,6 @@ static UINT8 hud_enabled[(hud_MAX/8)+1]; static UINT8 hudAvailable; // hud hooks field -#ifdef LUA_PATCH_SAFETY -static patchinfo_t *patchinfo, *patchinfohead; -static int numluapatches; -#endif - // must match enum hud in lua_hud.h static const char *const hud_disable_options[] = { "stagetitle", @@ -292,11 +287,7 @@ static int colormap_get(lua_State *L) static int patch_get(lua_State *L) { -#ifdef LUA_PATCH_SAFETY patch_t *patch = *((patch_t **)luaL_checkudata(L, 1, META_PATCH)); -#else - patchinfo_t *patch = *((patchinfo_t **)luaL_checkudata(L, 1, META_PATCH)); -#endif enum patch field = luaL_checkoption(L, 2, NULL, patch_opt); // patches are invalidated when switching renderers @@ -403,59 +394,8 @@ static int libd_patchExists(lua_State *L) static int libd_cachePatch(lua_State *L) { -#ifdef LUA_PATCH_SAFETY - int i; - lumpnum_t lumpnum; - patchinfo_t *luapat; - patch_t *realpatch; - - HUDONLY - - luapat = patchinfohead; - lumpnum = W_CheckNumForLongName(luaL_checkstring(L, 1)); - if (lumpnum == LUMPERROR) - lumpnum = W_GetNumForLongName("MISSING"); - - for (i = 0; i < numluapatches; i++) - { - // check if already cached - if (luapat->wadnum == WADFILENUM(lumpnum) && luapat->lumpnum == LUMPNUM(lumpnum)) - { - LUA_PushUserdata(L, luapat, META_PATCH); - return 1; - } - luapat = luapat->next; - if (!luapat) - break; - } - - if (numluapatches > 0) - { - patchinfo->next = Z_Malloc(sizeof(patchinfo_t), PU_STATIC, NULL); - patchinfo = patchinfo->next; - } - else - { - patchinfo = Z_Malloc(sizeof(patchinfo_t), PU_STATIC, NULL); - patchinfohead = patchinfo; - } - - realpatch = W_CachePatchNum(lumpnum, PU_PATCH); - - patchinfo->width = realpatch->width; - patchinfo->height = realpatch->height; - patchinfo->leftoffset = realpatch->leftoffset; - patchinfo->topoffset = realpatch->topoffset; - - patchinfo->wadnum = WADFILENUM(lumpnum); - patchinfo->lumpnum = LUMPNUM(lumpnum); - - LUA_PushUserdata(L, patchinfo, META_PATCH); - numluapatches++; -#else HUDONLY LUA_PushUserdata(L, W_CachePatchLongName(luaL_checkstring(L, 1), PU_PATCH), META_PATCH); -#endif return 1; } @@ -651,22 +591,14 @@ static int libd_draw(lua_State *L) { INT32 x, y, flags; patch_t *patch; -#ifdef LUA_PATCH_SAFETY - patchinfo_t *luapat; -#endif const UINT8 *colormap = NULL; HUDONLY x = luaL_checkinteger(L, 1); y = luaL_checkinteger(L, 2); -#ifdef LUA_PATCH_SAFETY - luapat = *((patchinfo_t **)luaL_checkudata(L, 3, META_PATCH)); - patch = W_CachePatchNum((luapat->wadnum<<16)+luapat->lumpnum, PU_PATCH); -#else patch = *((patch_t **)luaL_checkudata(L, 3, META_PATCH)); if (!patch) return LUA_ErrInvalid(L, "patch_t"); -#endif flags = luaL_optinteger(L, 4, 0); if (!lua_isnoneornil(L, 5)) colormap = *((UINT8 **)luaL_checkudata(L, 5, META_COLORMAP)); @@ -682,9 +614,6 @@ static int libd_drawScaled(lua_State *L) fixed_t x, y, scale; INT32 flags; patch_t *patch; -#ifdef LUA_PATCH_SAFETY - patchinfo_t *luapat; -#endif const UINT8 *colormap = NULL; HUDONLY @@ -693,14 +622,9 @@ static int libd_drawScaled(lua_State *L) scale = luaL_checkinteger(L, 3); if (scale < 0) return luaL_error(L, "negative scale"); -#ifdef LUA_PATCH_SAFETY - luapat = *((patchinfo_t **)luaL_checkudata(L, 4, META_PATCH)); - patch = W_CachePatchNum((luapat->wadnum<<16)+luapat->lumpnum, PU_PATCH); -#else patch = *((patch_t **)luaL_checkudata(L, 4, META_PATCH)); if (!patch) return LUA_ErrInvalid(L, "patch_t"); -#endif flags = luaL_optinteger(L, 5, 0); if (!lua_isnoneornil(L, 6)) colormap = *((UINT8 **)luaL_checkudata(L, 6, META_COLORMAP)); @@ -1247,10 +1171,6 @@ int LUA_HudLib(lua_State *L) { memset(hud_enabled, 0xff, (hud_MAX/8)+1); -#ifdef LUA_PATCH_SAFETY - numluapatches = 0; -#endif - lua_newtable(L); // HUD registry table lua_newtable(L); luaL_register(L, NULL, lib_draw); diff --git a/src/r_defs.h b/src/r_defs.h index 10fc99ccd..becf2aed8 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -727,24 +727,6 @@ typedef enum SRF_NONE = 0xff // Initial value } spriterotateflags_t; // SRF's up! -// Same as a patch_t, except just the header -// and the wadnum/lumpnum combination that points -// to wherever the patch is in memory. -struct patchinfo_s -{ - INT16 width; // bounding box size - INT16 height; - INT16 leftoffset; // pixels to the left of origin - INT16 topoffset; // pixels below the origin - - UINT16 wadnum; // the software patch lump num for when the patch - UINT16 lumpnum; // was flushed, and we need to re-create it - - // next patchinfo_t in memory - struct patchinfo_s *next; -}; -typedef struct patchinfo_s patchinfo_t; - // // Sprites are patches with a special naming convention so they can be // recognized by R_InitSprites. From b565b805a95ef3ad6d087244339b9c487fc1d3a3 Mon Sep 17 00:00:00 2001 From: bartuinceQR Date: Wed, 12 Aug 2020 22:49:41 +0300 Subject: [PATCH 0074/1080] chain homing --- src/p_user.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/p_user.c b/src/p_user.c index 44793b0cc..f501c8a1e 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -5041,7 +5041,7 @@ static void P_DoJumpStuff(player_t *player, ticcmd_t *cmd) else if (player->pflags & (PF_GLIDING|PF_SLIDING|PF_SHIELDABILITY)) // If the player has used an ability previously ; else if ((player->powers[pw_shield] & SH_NOSTACK) && !player->powers[pw_super] && !(player->pflags & PF_USEDOWN) - && ((!(player->pflags & PF_THOKKED) || ((player->powers[pw_shield] & SH_NOSTACK) == SH_BUBBLEWRAP && player->secondjump == UINT8_MAX)))) // thokked is optional if you're bubblewrapped + && ((!(player->pflags & PF_THOKKED) || (((player->powers[pw_shield] & SH_NOSTACK) == SH_BUBBLEWRAP || (player->powers[pw_shield] & SH_NOSTACK) == SH_ATTRACT) && player->secondjump == UINT8_MAX) ))) // thokked is optional if you're bubblewrapped / 3dblasted { if ((player->powers[pw_shield] & SH_NOSTACK) == SH_ATTRACT) { @@ -5093,6 +5093,7 @@ static void P_DoJumpStuff(player_t *player, ticcmd_t *cmd) case SH_ATTRACT: player->pflags |= PF_THOKKED|PF_SHIELDABILITY; player->homing = 2; + player->secondjump = 0; P_SetTarget(&player->mo->target, P_SetTarget(&player->mo->tracer, lockonshield)); if (lockonshield) { @@ -5484,6 +5485,8 @@ static void P_DoJumpStuff(player_t *player, ticcmd_t *cmd) { if (!P_HomingAttack(player->mo, player->mo->tracer)) { + player->pflags &= ~PF_SHIELDABILITY; + player->secondjump = UINT8_MAX; P_SetObjectMomZ(player->mo, 6*FRACUNIT, false); if (player->mo->eflags & MFE_UNDERWATER) player->mo->momz = FixedMul(player->mo->momz, FRACUNIT/3); From aa19bce4a9f29031130a44178afed0c5c5bb4c56 Mon Sep 17 00:00:00 2001 From: James R Date: Fri, 14 Aug 2020 00:00:16 -0700 Subject: [PATCH 0075/1080] Autocomplete aliases in console --- src/command.c | 30 ++++++++++++++++++-- src/command.h | 2 ++ src/console.c | 77 ++++++++++++++++++++++++++++++++++++--------------- 3 files changed, 85 insertions(+), 24 deletions(-) diff --git a/src/command.c b/src/command.c index 0a46839f3..d8ecb4c24 100644 --- a/src/command.c +++ b/src/command.c @@ -560,7 +560,7 @@ static boolean COM_Exists(const char *com_name) * \param partial The partial name of the command (potentially). * \param skips Number of commands to skip. * \return The complete command name, or NULL. - * \sa CV_CompleteVar + * \sa CV_CompleteAlias, CV_CompleteVar */ const char *COM_CompleteCommand(const char *partial, INT32 skips) { @@ -581,6 +581,32 @@ const char *COM_CompleteCommand(const char *partial, INT32 skips) return NULL; } +/** Completes the name of an alias. + * + * \param partial The partial name of the alias (potentially). + * \param skips Number of aliases to skip. + * \return The complete alias name, or NULL. + * \sa CV_CompleteCommand, CV_CompleteVar + */ +const char *COM_CompleteAlias(const char *partial, INT32 skips) +{ + cmdalias_t *a; + size_t len; + + len = strlen(partial); + + if (!len) + return NULL; + + // check functions + for (a = com_alias; a; a = a->next) + if (!strncmp(partial, a->name, len)) + if (!skips--) + return a->name; + + return NULL; +} + /** Parses a single line of text into arguments and tries to execute it. * The text can come from the command buffer, a remote client, or stdin. * @@ -1321,7 +1347,7 @@ static const char *CV_StringValue(const char *var_name) * \param partial The partial name of the variable (potentially). * \param skips Number of variables to skip. * \return The complete variable name, or NULL. - * \sa COM_CompleteCommand + * \sa COM_CompleteCommand, CV_CompleteAlias */ const char *CV_CompleteVar(char *partial, INT32 skips) { diff --git a/src/command.h b/src/command.h index b39153a65..07ce1da95 100644 --- a/src/command.h +++ b/src/command.h @@ -49,6 +49,8 @@ size_t COM_FirstOption(void); // match existing command or NULL const char *COM_CompleteCommand(const char *partial, INT32 skips); +const char *COM_CompleteAlias(const char *partial, INT32 skips); + // insert at queu (at end of other command) #define COM_BufAddText(s) COM_BufAddTextEx(s, 0) void COM_BufAddTextEx(const char *btext, int flags); diff --git a/src/console.c b/src/console.c index 0235b9bd4..82e59642f 100644 --- a/src/console.c +++ b/src/console.c @@ -870,9 +870,14 @@ boolean CON_Responder(event_t *ev) // sequential completions a la 4dos static char completion[80]; - static INT32 comskips, varskips; - const char *cmd = ""; + static INT32 skips; + + static INT32 com_skips; + static INT32 var_skips; + static INT32 alias_skips; + + const char *cmd = NULL; INT32 key; if (chat_on) @@ -1007,7 +1012,6 @@ boolean CON_Responder(event_t *ev) if (!input_len || input_len >= 40 || strchr(inputlines[inputline], ' ')) return true; strcpy(completion, inputlines[inputline]); - comskips = varskips = 0; } len = strlen(completion); @@ -1023,6 +1027,14 @@ boolean CON_Responder(event_t *ev) CONS_Printf(" \x83" "%s" "\x80" "%s\n", completion, cmd+len); if (i == 0) CONS_Printf(" (none)\n"); + //and finally aliases + CONS_Printf("Aliases:\n"); + for (i = 0, cmd = COM_CompleteAlias(completion, i); cmd; cmd = COM_CompleteAlias(completion, ++i)) + CONS_Printf(" \x83" "%s" "\x80" "%s\n", completion, cmd+len); + if (i == 0) CONS_Printf(" (none)\n"); + + completion[0] = 0; + return true; } // --- @@ -1091,43 +1103,64 @@ boolean CON_Responder(event_t *ev) if (!input_len || input_len >= 40 || strchr(inputlines[inputline], ' ')) return true; strcpy(completion, inputlines[inputline]); - comskips = varskips = 0; + skips = 0; + com_skips = 0; + var_skips = 0; + alias_skips = 0; } else { if (shiftdown) { - if (comskips < 0) - { - if (--varskips < 0) - comskips = -comskips - 2; - } - else if (comskips > 0) comskips--; + if (skips > 0) + skips--; } else { - if (comskips < 0) varskips++; - else comskips++; + skips++; } } - if (comskips >= 0) + if (skips <= com_skips) { - cmd = COM_CompleteCommand(completion, comskips); - if (!cmd) // dirty: make sure if comskips is zero, to have a neg value - comskips = -comskips - 1; + cmd = COM_CompleteCommand(completion, skips); + + if (cmd && skips == com_skips) + { + com_skips ++; + var_skips ++; + alias_skips++; + } + } + + if (!cmd && skips <= var_skips) + { + cmd = CV_CompleteVar(completion, skips - com_skips); + + if (cmd && skips == var_skips) + { + var_skips ++; + alias_skips++; + } + } + + if (!cmd && skips <= alias_skips) + { + cmd = COM_CompleteAlias(completion, skips - var_skips); + + if (cmd && skips == alias_skips) + { + alias_skips++; + } } - if (comskips < 0) - cmd = CV_CompleteVar(completion, varskips); if (cmd) + { CON_InputSetString(va("%s ", cmd)); + } else { - if (comskips > 0) - comskips--; - else if (varskips > 0) - varskips--; + skips--; } return true; From 1751d7afeda393f601979fced7f3e1ada3f8e100 Mon Sep 17 00:00:00 2001 From: Jaime Passos Date: Fri, 14 Aug 2020 20:48:15 -0300 Subject: [PATCH 0076/1080] Cache the console patch only once in CON_DrawBackpic --- src/console.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/console.c b/src/console.c index 280dc4f22..e9c0138d7 100644 --- a/src/console.c +++ b/src/console.c @@ -1543,8 +1543,8 @@ static void CON_DrawBackpic(void) if (piclump == LUMPERROR) piclump = W_GetNumForName("MISSING"); - // Cache the Software patch. - con_backpic = W_CacheSoftwarePatchNum(piclump, PU_PATCH); + // Cache the patch. + con_backpic = W_CachePatchNum(piclump, PU_PATCH); // Center the backpic, and draw a vertically cropped patch. w = (con_backpic->width * vid.dupx); @@ -1567,8 +1567,7 @@ static void CON_DrawBackpic(void) } } - // Cache the patch normally. - con_backpic = W_CachePatchNum(piclump, PU_PATCH); + // Draw the patch. V_DrawCroppedPatch(x << FRACBITS, 0, FRACUNIT, V_NOSCALESTART, con_backpic, 0, ( BASEVIDHEIGHT - h ), BASEVIDWIDTH, h); From 78cc4a78d0e9c9a26e723e38dbb629279883dc0f Mon Sep 17 00:00:00 2001 From: Jaime Passos Date: Fri, 14 Aug 2020 22:27:16 -0300 Subject: [PATCH 0077/1080] Refactor renderer switching --- src/android/i_video.c | 12 ++- src/console.c | 28 ++++--- src/console.h | 4 + src/d_main.c | 45 +++++------- src/dummy/i_video.c | 12 ++- src/hardware/hw_cache.c | 94 +++++++++++++++++------- src/hardware/hw_glob.h | 10 ++- src/hardware/hw_main.c | 15 +++- src/hardware/hw_main.h | 1 - src/hardware/hw_md2.c | 2 +- src/i_video.h | 8 +- src/m_menu.c | 15 +++- src/p_setup.c | 14 ++-- src/p_setup.h | 2 +- src/r_data.c | 4 +- src/r_main.c | 12 --- src/r_main.h | 3 - src/screen.c | 158 ++++++++++++---------------------------- src/screen.h | 26 +++++-- src/sdl/i_video.c | 103 ++++++++++++++++---------- src/v_video.c | 33 +++++++++ src/v_video.h | 3 + src/w_wad.c | 2 +- src/win32/win_vid.c | 8 +- 24 files changed, 343 insertions(+), 271 deletions(-) diff --git a/src/android/i_video.c b/src/android/i_video.c index 1909cd71a..a38078a5d 100644 --- a/src/android/i_video.c +++ b/src/android/i_video.c @@ -9,6 +9,7 @@ #include "utils/Log.h" rendermode_t rendermode = render_soft; +rendermode_t chosenrendermode = render_none; boolean highcolor = false; @@ -52,8 +53,15 @@ INT32 VID_SetMode(INT32 modenum) return 0; } -void VID_CheckRenderer(void) {} -void VID_CheckGLLoaded(rendermode_t oldrender) {} +boolean VID_CheckRenderer(void) +{ + return false; +} + +void VID_CheckGLLoaded(rendermode_t oldrender) +{ + (void)oldrender; +} const char *VID_GetModeName(INT32 modenum) { diff --git a/src/console.c b/src/console.c index e9c0138d7..630feb2aa 100644 --- a/src/console.c +++ b/src/console.c @@ -45,7 +45,8 @@ #define MAXHUDLINES 20 static boolean con_started = false; // console has been initialised - boolean con_startup = false; // true at game startup, screen need refreshing + boolean con_startup = false; // true at game startup + boolean con_refresh = false; // screen needs refreshing static boolean con_forcepic = true; // at startup toggle console translucency when first off boolean con_recalc; // set true when screen size has changed @@ -406,7 +407,8 @@ void CON_Init(void) if (!dedicated) { con_started = true; - con_startup = true; // need explicit screen refresh until we are in Doom loop + con_startup = true; + con_refresh = true; // needs explicit screen refresh until we are in the main game loop consoletoggle = false; CV_RegisterVar(&cons_msgtimeout); CV_RegisterVar(&cons_hudlines); @@ -419,7 +421,8 @@ void CON_Init(void) else { con_started = true; - con_startup = false; // need explicit screen refresh until we are in Doom loop + con_startup = false; + con_refresh = false; // disable explicit screen refresh consoletoggle = true; } } @@ -1293,16 +1296,19 @@ void CONS_Printf(const char *fmt, ...) con_scrollup = 0; // if not in display loop, force screen update - if (con_startup && (!setrenderneeded)) + if (con_refresh) { -#ifdef _WINDOWS - patch_t *con_backpic = W_CachePatchName("CONSBACK", PU_PATCH); +#if defined(_WINDOWS) + if (con_startup) + { + patch_t *con_backpic = W_CachePatchName("CONSBACK", PU_PATCH); - // Jimita: CON_DrawBackpic just called V_DrawScaledPatch - V_DrawScaledPatch(0, 0, 0, con_backpic); + // Jimita: CON_DrawBackpic just called V_DrawScaledPatch + V_DrawScaledPatch(0, 0, 0, con_backpic); - W_UnlockCachedPatch(con_backpic); - I_LoadingScreen(txt); // Win32/OS2 only + W_UnlockCachedPatch(con_backpic); + I_LoadingScreen(txt); // Win32/OS2 only + } #else // here we display the console text CON_Drawer(); @@ -1369,7 +1375,7 @@ void CONS_Debug(INT32 debugflags, const char *fmt, ...) // void CONS_Error(const char *msg) { -#ifdef RPC_NO_WINDOWS_H +#if defined(RPC_NO_WINDOWS_H) && defined(_WINDOWS) if (!graphics_started) { MessageBoxA(vid.WndParent, msg, "SRB2 Warning", MB_OK); diff --git a/src/console.h b/src/console.h index 2be92d62b..6f38ca8d0 100644 --- a/src/console.h +++ b/src/console.h @@ -20,8 +20,12 @@ boolean CON_Responder(event_t *ev); // set true when screen size has changed, to adapt console extern boolean con_recalc; +// console being displayed at game startup extern boolean con_startup; +// needs explicit screen refresh until we are in the main game loop +extern boolean con_refresh; + // top clip value for view render: do not draw part of view hidden by console extern INT32 con_clipviewtop; diff --git a/src/d_main.c b/src/d_main.c index ee3ce699c..6144abd85 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -220,7 +220,6 @@ INT16 wipetypepost = -1; static void D_Display(void) { - INT32 setrenderstillneeded = 0; boolean forcerefresh = false; static boolean wipe = false; INT32 wipedefindex = 0; @@ -245,36 +244,21 @@ static void D_Display(void) // modes (resolution) are called. // 4. The frame is ready to be drawn! - // stop movie if needs to change renderer - if (setrenderneeded && (moviemode == MM_APNG)) - M_StopMovie(); - - // check for change of renderer or screen size (video mode) + // Check for change of renderer or screen size (video mode) if ((setrenderneeded || setmodeneeded) && !wipe) - { - if (setrenderneeded) - { - CONS_Debug(DBG_RENDER, "setrenderneeded set (%d)\n", setrenderneeded); - setrenderstillneeded = setrenderneeded; - } SCR_SetMode(); // change video mode - } - if (vid.recalc || setrenderstillneeded) - { + // Recalc the screen + if (vid.recalc) SCR_Recalc(); // NOTE! setsizeneeded is set by SCR_Recalc() -#ifdef HWRENDER - // Shoot! The screen texture was flushed! - if ((rendermode == render_opengl) && (gamestate == GS_INTERMISSION)) - usebuffer = false; -#endif - } + // View morph if (rendermode == render_soft && !splitscreen) R_CheckViewMorph(); - // change the view size if needed - if (setsizeneeded || setrenderstillneeded) + // Change the view size if needed + // Set by changing video mode or renderer + if (setsizeneeded) { R_ExecuteSetViewSize(); forcerefresh = true; // force background redraw @@ -697,6 +681,7 @@ void D_SRB2Loop(void) oldentertics = I_GetTime(); // end of loading screen: CONS_Printf() will no more call FinishUpdate() + con_refresh = false; con_startup = false; // make sure to do a d_display to init mode _before_ load a level @@ -1402,14 +1387,20 @@ void D_SRB2Main(void) // set user default mode or mode set at cmdline SCR_CheckDefaultMode(); - // Lactozilla: Does the render mode need to change? - if ((setrenderneeded != 0) && (setrenderneeded != rendermode)) + // Lactozilla: Check if the render mode needs to change. + if (setrenderneeded) { CONS_Printf(M_GetText("Switching the renderer...\n")); + // Switch the renderer in the interface + if (VID_CheckRenderer()) + con_refresh = true; // Allow explicit screen refresh again + // Set cv_renderer to the new render mode - VID_CheckRenderer(); - SCR_ChangeRendererCVars(rendermode); + CV_StealthSetValue(&cv_renderer, rendermode); +#ifdef HWRENDER + CV_StealthSetValue(&cv_newrenderer, rendermode); +#endif } wipegamestate = gamestate; diff --git a/src/dummy/i_video.c b/src/dummy/i_video.c index 56ead3672..38a67ef37 100644 --- a/src/dummy/i_video.c +++ b/src/dummy/i_video.c @@ -3,6 +3,7 @@ #include "../i_video.h" rendermode_t rendermode = render_none; +rendermode_t chosenrendermode = render_none; boolean highcolor = false; @@ -40,8 +41,15 @@ INT32 VID_SetMode(INT32 modenum) return 0; } -void VID_CheckRenderer(void) {} -void VID_CheckGLLoaded(rendermode_t oldrender) {} +boolean VID_CheckRenderer(void) +{ + return false; +} + +void VID_CheckGLLoaded(rendermode_t oldrender) +{ + (void)oldrender; +} const char *VID_GetModeName(INT32 modenum) { diff --git a/src/hardware/hw_cache.c b/src/hardware/hw_cache.c index a26721169..901c0184a 100644 --- a/src/hardware/hw_cache.c +++ b/src/hardware/hw_cache.c @@ -585,23 +585,27 @@ void HWR_MakePatch (const patch_t *patch, GLPatch_t *grPatch, GLMipmap_t *grMipm static size_t gl_numtextures = 0; // Texture count static GLMapTexture_t *gl_textures; // For all textures static GLMapTexture_t *gl_flats; // For all (texture) flats, as normal flats don't need to be cached - -void HWR_InitTextureCache(void) -{ - gl_textures = NULL; - gl_flats = NULL; -} +boolean gl_maptexturesloaded = false; void HWR_FreeTexture(patch_t *patch) { + if (!patch) + return; + if (patch->hardware) { GLPatch_t *grPatch = patch->hardware; HWR_FreeTextureColormaps(patch); - if (grPatch->mipmap && (rendermode == render_opengl)) - HWD.pfnDeleteTexture(grPatch->mipmap); + if (grPatch->mipmap) + { + if (vid.glstate == VID_GL_LIBRARY_LOADED) + HWD.pfnDeleteTexture(grPatch->mipmap); + if (grPatch->mipmap->data) + Z_Free(grPatch->mipmap->data); + Z_Free(grPatch->mipmap); + } Z_Free(patch->hardware); } @@ -609,7 +613,7 @@ void HWR_FreeTexture(patch_t *patch) patch->hardware = NULL; } -// Called by HWR_FreeTextureCache. +// Called by HWR_FreePatchCache. void HWR_FreeTextureColormaps(patch_t *patch) { GLPatch_t *pat; @@ -653,10 +657,22 @@ void HWR_FreeTextureColormaps(patch_t *patch) } } -void HWR_FreeMipmapCache(void) +static void HWR_FreePatchCache(boolean freeall) { INT32 i; + for (i = 0; i < numwadfiles; i++) + { + INT32 j = 0; + for (; j < wadfiles[i]->numlumps; j++) + (freeall ? HWR_FreeTexture : HWR_FreeTextureColormaps)(wadfiles[i]->patchcache[j]); + } +} + +void HWR_ClearAllTextures(void) +{ + HWR_FreeMapTextures(); + // free references to the textures HWD.pfnClearMipMapCache(); @@ -666,19 +682,38 @@ void HWR_FreeMipmapCache(void) Z_FreeTag(PU_HWRCACHE_UNLOCKED); // Alam: free the Z_Blocks before freeing it's users - // free all patch colormaps after each level: must be done after ClearMipMapCache! - for (i = 0; i < numwadfiles; i++) - { - INT32 j = 0; - for (; j < wadfiles[i]->numlumps; j++) - HWR_FreeTextureColormaps(wadfiles[i]->patchcache[j]); - } + HWR_FreePatchCache(true); } -void HWR_FreeTextureCache(void) +// free all patch colormaps after each level: must be done after ClearMipMapCache! +void HWR_FreeColormapCache(void) { - // free references to the textures - HWR_FreeMipmapCache(); + HWR_FreePatchCache(false); +} + +void HWR_InitMapTextures(void) +{ + gl_textures = NULL; + gl_flats = NULL; + gl_maptexturesloaded = false; +} + +static void FreeMapTexture(GLMapTexture_t *tex) +{ + HWD.pfnDeleteTexture(&tex->mipmap); + if (tex->mipmap.data) + Z_Free(tex->mipmap.data); +} + +void HWR_FreeMapTextures(void) +{ + size_t i; + + for (i = 0; i < gl_numtextures; i++) + { + FreeMapTexture(&gl_textures[i]); + FreeMapTexture(&gl_flats[i]); + } // now the heap don't have any 'user' pointing to our // texturecache info, we can free it @@ -689,12 +724,13 @@ void HWR_FreeTextureCache(void) gl_textures = NULL; gl_flats = NULL; gl_numtextures = 0; + gl_maptexturesloaded = false; } -void HWR_LoadTextures(size_t pnumtextures) +void HWR_LoadMapTextures(size_t pnumtextures) { // we must free it since numtextures changed - HWR_FreeTextureCache(); + HWR_FreeMapTextures(); // Why not Z_Malloc? gl_numtextures = pnumtextures; @@ -704,7 +740,9 @@ void HWR_LoadTextures(size_t pnumtextures) // Doesn't tell you which it _is_, but hopefully // should never ever happen (right?!) if ((gl_textures == NULL) || (gl_flats == NULL)) - I_Error("HWR_LoadTextures: ran out of memory for OpenGL textures. Sad!"); + I_Error("HWR_LoadMapTextures: ran out of memory for OpenGL textures. Sad!"); + + gl_maptexturesloaded = true; } void HWR_SetPalette(RGBA_t *palette) @@ -814,10 +852,13 @@ static void HWR_CacheTextureAsFlat(GLMipmap_t *grMipmap, INT32 texturenum) void HWR_LiterallyGetFlat(lumpnum_t flatlumpnum) { GLMipmap_t *grmip; + patch_t *patch; + if (flatlumpnum == LUMPERROR) return; - grmip = ((GLPatch_t *)HWR_GetCachedGLPatch(flatlumpnum)->hardware)->mipmap; + patch = HWR_GetCachedGLPatch(flatlumpnum); + grmip = ((GLPatch_t *)Patch_AllocateHardwarePatch(patch))->mipmap; if (!grmip->downloaded && !grmip->data) HWR_CacheFlat(grmip, flatlumpnum); @@ -933,7 +974,7 @@ void HWR_GetMappedPatch(patch_t *patch, const UINT8 *colormap) //BP: WARNING: don't free it manually without clearing the cache of harware renderer // (it have a liste of mipmap) - // this malloc is cleared in HWR_FreeTextureCache + // this malloc is cleared in HWR_FreeColormapCache // (...) unfortunately z_malloc fragment alot the memory :(so malloc is better newMipmap = calloc(1, sizeof (*newMipmap)); if (newMipmap == NULL) @@ -1190,7 +1231,8 @@ static void HWR_CacheFadeMask(GLMipmap_t *grMipmap, lumpnum_t fademasklumpnum) void HWR_GetFadeMask(lumpnum_t fademasklumpnum) { - GLMipmap_t *grmip = ((GLPatch_t *)HWR_GetCachedGLPatch(fademasklumpnum)->hardware)->mipmap; + patch_t *patch = HWR_GetCachedGLPatch(fademasklumpnum); + GLMipmap_t *grmip = ((GLPatch_t *)Patch_AllocateHardwarePatch(patch))->mipmap; if (!grmip->downloaded && !grmip->data) HWR_CacheFadeMask(grmip, fademasklumpnum); diff --git a/src/hardware/hw_glob.h b/src/hardware/hw_glob.h index 94c553535..b16a0f231 100644 --- a/src/hardware/hw_glob.h +++ b/src/hardware/hw_glob.h @@ -90,9 +90,11 @@ void HWR_FreeExtraSubsectors(void); // -------- // hw_cache.c // -------- -void HWR_InitTextureCache(void); -void HWR_FreeTextureCache(void); -void HWR_FreeMipmapCache(void); +void HWR_InitMapTextures(void); +void HWR_LoadMapTextures(size_t pnumtextures); +void HWR_FreeMapTextures(void); + +extern boolean gl_maptexturesloaded; patch_t *HWR_GetCachedGLPatchPwad(UINT16 wad, UINT16 lump); patch_t *HWR_GetCachedGLPatch(lumpnum_t lumpnum); @@ -108,6 +110,8 @@ void HWR_LiterallyGetFlat(lumpnum_t flatlumpnum); void HWR_FreeTexture(patch_t *patch); void HWR_FreeTextureColormaps(patch_t *patch); +void HWR_ClearAllTextures(void); +void HWR_FreeColormapCache(void); void HWR_UnlockCachedPatch(GLPatch_t *gpatch); void HWR_SetPalette(RGBA_t *palette); diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 7ba7f911c..e9d52c791 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -5930,7 +5930,7 @@ void HWR_Startup(void) HWR_InitPolyPool(); HWR_AddSessionCommands(); - HWR_InitTextureCache(); + HWR_InitMapTextures(); HWR_InitModels(); #ifdef ALAM_LIGHTING HWR_InitLight(); @@ -5954,9 +5954,20 @@ void HWR_Startup(void) // -------------------------------------------------------------------------- void HWR_Switch(void) { + // Add session commands + HWR_AddSessionCommands(); + // Set special states from CVARs HWD.pfnSetSpecialState(HWD_SET_TEXTUREFILTERMODE, cv_glfiltermode.value); HWD.pfnSetSpecialState(HWD_SET_TEXTUREANISOTROPICMODE, cv_glanisotropicmode.value); + + // Load textures + if (!gl_maptexturesloaded) + HWR_LoadMapTextures(numtextures); + + // Create plane polygons + if (gamestate == GS_LEVEL || (gamestate == GS_TITLESCREEN && titlemapinaction)) + HWR_LoadLevel(); } // -------------------------------------------------------------------------- @@ -5967,7 +5978,7 @@ void HWR_Shutdown(void) CONS_Printf("HWR_Shutdown()\n"); HWR_FreeExtraSubsectors(); HWR_FreePolyPool(); - HWR_FreeTextureCache(); + HWR_FreeMapTextures(); HWD.pfnFlushScreenTextures(); } diff --git a/src/hardware/hw_main.h b/src/hardware/hw_main.h index 3bcef05de..780572a85 100644 --- a/src/hardware/hw_main.h +++ b/src/hardware/hw_main.h @@ -41,7 +41,6 @@ void HWR_DrawCroppedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t scale, void HWR_MakePatch(const patch_t *patch, GLPatch_t *grPatch, GLMipmap_t *grMipmap, boolean makebitmap); void HWR_CreatePlanePolygons(INT32 bspnum); void HWR_CreateStaticLightmaps(INT32 bspnum); -void HWR_LoadTextures(size_t pnumtextures); void HWR_DrawFill(INT32 x, INT32 y, INT32 w, INT32 h, INT32 color); void HWR_DrawFadeFill(INT32 x, INT32 y, INT32 w, INT32 h, INT32 color, UINT16 actualcolor, UINT8 strength); void HWR_DrawConsoleFill(INT32 x, INT32 y, INT32 w, INT32 h, INT32 color, UINT32 actualcolor); // Lat: separate flags from color since color needs to be an uint to work right. diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index caef0a02d..057ef62c1 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -1094,7 +1094,7 @@ static void HWR_GetBlendedTexture(patch_t *patch, patch_t *blendpatch, INT32 ski //BP: WARNING: don't free it manually without clearing the cache of harware renderer // (it have a liste of mipmap) - // this malloc is cleared in HWR_FreeTextureCache + // this malloc is cleared in HWR_FreeColormapCache // (...) unfortunately z_malloc fragment alot the memory :(so malloc is better newMipmap = calloc(1, sizeof (*newMipmap)); if (newMipmap == NULL) diff --git a/src/i_video.h b/src/i_video.h index 98ed7f38a..ab48881d4 100644 --- a/src/i_video.h +++ b/src/i_video.h @@ -36,10 +36,9 @@ typedef enum */ extern rendermode_t rendermode; -/** \brief OpenGL state - 0 = never loaded, 1 = loaded successfully, -1 = failed loading +/** \brief render mode set by command line arguments */ -extern INT32 vid_opengl_state; +extern rendermode_t chosenrendermode; /** \brief use highcolor modes if true */ @@ -90,8 +89,9 @@ INT32 VID_GetModeForSize(INT32 w, INT32 h); INT32 VID_SetMode(INT32 modenum); /** \brief Checks the render state + \return true if the renderer changed */ -void VID_CheckRenderer(void); +boolean VID_CheckRenderer(void); /** \brief Load OpenGL mode */ diff --git a/src/m_menu.c b/src/m_menu.c index 3d6b1c0fa..0e60dce0c 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -2149,15 +2149,22 @@ menu_t OP_PlaystyleDef = { static void M_VideoOptions(INT32 choice) { (void)choice; + + OP_VideoOptionsMenu[op_video_renderer].status = (IT_TRANSTEXT | IT_PAIR); + OP_VideoOptionsMenu[op_video_renderer].patch = "Renderer"; + OP_VideoOptionsMenu[op_video_renderer].text = "Software"; + #ifdef HWRENDER - if (vid_opengl_state == -1) + if (vid.glstate != VID_GL_LIBRARY_ERROR) { - OP_VideoOptionsMenu[op_video_renderer].status = (IT_TRANSTEXT | IT_PAIR); - OP_VideoOptionsMenu[op_video_renderer].patch = "Renderer"; - OP_VideoOptionsMenu[op_video_renderer].text = "Software"; + OP_VideoOptionsMenu[op_video_renderer].status = (IT_STRING | IT_CVAR); + OP_VideoOptionsMenu[op_video_renderer].patch = NULL; + OP_VideoOptionsMenu[op_video_renderer].text = "Renderer"; } + CV_StealthSetValue(&cv_newrenderer, cv_renderer.value); #endif + M_SetupNextMenu(&OP_VideoOptionsDef); } diff --git a/src/p_setup.c b/src/p_setup.c index ceb96df40..0105a06da 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -4146,13 +4146,11 @@ boolean P_LoadLevel(boolean fromnetsave) #ifdef HWRENDER // not win32 only 19990829 by Kin // Lactozilla: Free extrasubsectors regardless of renderer. - // Maybe we're not in OpenGL anymore. - if (extrasubsectors) - free(extrasubsectors); - extrasubsectors = NULL; - // stuff like HWR_CreatePlanePolygons is called there + HWR_FreeExtraSubsectors(); + + // Create plane polygons. if (rendermode == render_opengl) - HWR_SetupLevel(); + HWR_LoadLevel(); #endif // oh god I hope this helps @@ -4238,7 +4236,7 @@ boolean P_LoadLevel(boolean fromnetsave) } #ifdef HWRENDER -void HWR_SetupLevel(void) +void HWR_LoadLevel(void) { // Lactozilla (December 8, 2019) // Level setup used to free EVERY mipmap from memory. @@ -4249,7 +4247,7 @@ void HWR_SetupLevel(void) // when the texture list is loaded. // Sal: Unfortunately, NOT freeing them causes the dreaded Color Bug. - HWR_FreeMipmapCache(); + HWR_FreeColormapCache(); #ifdef ALAM_LIGHTING // BP: reset light between levels (we draw preview frame lights on current frame) diff --git a/src/p_setup.h b/src/p_setup.h index e7150c0ae..497870628 100644 --- a/src/p_setup.h +++ b/src/p_setup.h @@ -99,7 +99,7 @@ void P_ScanThings(INT16 mapnum, INT16 wadnum, INT16 lumpnum); void P_RespawnThings(void); boolean P_LoadLevel(boolean fromnetsave); #ifdef HWRENDER -void HWR_SetupLevel(void); +void HWR_LoadLevel(void); #endif boolean P_AddWadFile(const char *wadfilename); boolean P_RunSOC(const char *socfilename); diff --git a/src/r_data.c b/src/r_data.c index 4b2ff7484..dc2c41150 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -33,7 +33,7 @@ #endif #ifdef HWRENDER -#include "hardware/hw_main.h" // HWR_LoadTextures +#include "hardware/hw_main.h" // HWR_LoadMapTextures #endif #if defined(_MSC_VER) @@ -1084,7 +1084,7 @@ void R_LoadTextures(void) #ifdef HWRENDER if (rendermode == render_opengl) - HWR_LoadTextures(numtextures); + HWR_LoadMapTextures(numtextures); #endif } diff --git a/src/r_main.c b/src/r_main.c index b70e6f25f..883ac0abf 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -1560,18 +1560,6 @@ void R_RenderPlayerView(player_t *player) free(masks); } -// Lactozilla: Renderer switching -#ifdef HWRENDER -void R_InitHardwareMode(void) -{ - HWR_AddSessionCommands(); - HWR_Switch(); - HWR_LoadTextures(numtextures); - if (gamestate == GS_LEVEL || (gamestate == GS_TITLESCREEN && titlemapinaction)) - HWR_SetupLevel(); -} -#endif - // ========================================================================= // ENGINE COMMANDS & VARS // ========================================================================= diff --git a/src/r_main.h b/src/r_main.h index cc098462d..6c0aec3f5 100644 --- a/src/r_main.h +++ b/src/r_main.h @@ -112,9 +112,6 @@ extern consvar_t cv_tailspickup; // Called by startup code. void R_Init(void); -#ifdef HWRENDER -void R_InitHardwareMode(void); -#endif void R_CheckViewMorph(void); void R_ApplyViewMorph(void); diff --git a/src/screen.c b/src/screen.c index f5d19cada..d460e1f6d 100644 --- a/src/screen.c +++ b/src/screen.c @@ -28,6 +28,7 @@ #include "d_main.h" #include "d_clisrv.h" #include "f_finale.h" +#include "y_inter.h" // usebuffer #include "i_sound.h" // closed captions #include "s_sound.h" // ditto #include "g_game.h" // ditto @@ -63,7 +64,6 @@ consvar_t cv_scr_height = {"scr_height", "800", CV_SAVE, CV_Unsigned, NULL, 0, N consvar_t cv_scr_depth = {"scr_depth", "16 bits", CV_SAVE, scr_depth_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_renderview = {"renderview", "On", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -static void SCR_ActuallyChangeRenderer(void); CV_PossibleValue_t cv_renderer_t[] = { {1, "Software"}, #ifdef HWRENDER @@ -71,7 +71,7 @@ CV_PossibleValue_t cv_renderer_t[] = { #endif {0, NULL} }; -consvar_t cv_renderer = {"renderer", "Software", CV_SAVE|CV_NOLUA|CV_CALL, cv_renderer_t, SCR_ChangeRenderer, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_renderer = {"renderer", "Software", CV_SAVE|CV_NOLUA|CV_CALL, cv_renderer_t, SCR_SetTargetRenderer, 0, NULL, NULL, 0, 0, NULL}; static void SCR_ChangeFullscreen(void); @@ -202,11 +202,15 @@ void SCR_SetMode(void) // Lactozilla: Renderer switching if (setrenderneeded) { + // stop recording movies (APNG only) + if (setrenderneeded && (moviemode == MM_APNG)) + M_StopMovie(); + VID_CheckRenderer(); - if (!setmodeneeded) - VID_SetMode(vid.modenum); + vid.recalc = 1; } + // Set the video mode in the video interface. if (setmodeneeded) VID_SetMode(--setmodeneeded); @@ -276,34 +280,9 @@ void SCR_Startup(void) vid.modenum = 0; - vid.dupx = vid.width / BASEVIDWIDTH; - vid.dupy = vid.height / BASEVIDHEIGHT; - vid.dupx = vid.dupy = (vid.dupx < vid.dupy ? vid.dupx : vid.dupy); - vid.fdupx = FixedDiv(vid.width*FRACUNIT, BASEVIDWIDTH*FRACUNIT); - vid.fdupy = FixedDiv(vid.height*FRACUNIT, BASEVIDHEIGHT*FRACUNIT); - -#ifdef HWRENDER - if (rendermode != render_opengl && rendermode != render_none) // This was just placing it incorrectly at non aspect correct resolutions in opengl -#endif - vid.fdupx = vid.fdupy = (vid.fdupx < vid.fdupy ? vid.fdupx : vid.fdupy); - - vid.meddupx = (UINT8)(vid.dupx >> 1) + 1; - vid.meddupy = (UINT8)(vid.dupy >> 1) + 1; -#ifdef HWRENDER - vid.fmeddupx = vid.meddupx*FRACUNIT; - vid.fmeddupy = vid.meddupy*FRACUNIT; -#endif - - vid.smalldupx = (UINT8)(vid.dupx / 3) + 1; - vid.smalldupy = (UINT8)(vid.dupy / 3) + 1; -#ifdef HWRENDER - vid.fsmalldupx = vid.smalldupx*FRACUNIT; - vid.fsmalldupy = vid.smalldupy*FRACUNIT; -#endif - - vid.baseratio = FRACUNIT; - V_Init(); + V_Recalc(); + CV_RegisterVar(&cv_ticrate); CV_RegisterVar(&cv_constextsize); @@ -320,38 +299,7 @@ void SCR_Recalc(void) // bytes per pixel quick access scr_bpp = vid.bpp; - // scale 1,2,3 times in x and y the patches for the menus and overlays... - // calculated once and for all, used by routines in v_video.c - vid.dupx = vid.width / BASEVIDWIDTH; - vid.dupy = vid.height / BASEVIDHEIGHT; - vid.dupx = vid.dupy = (vid.dupx < vid.dupy ? vid.dupx : vid.dupy); - vid.fdupx = FixedDiv(vid.width*FRACUNIT, BASEVIDWIDTH*FRACUNIT); - vid.fdupy = FixedDiv(vid.height*FRACUNIT, BASEVIDHEIGHT*FRACUNIT); - -#ifdef HWRENDER - //if (rendermode != render_opengl && rendermode != render_none) // This was just placing it incorrectly at non aspect correct resolutions in opengl - // 13/11/18: - // The above is no longer necessary, since we want OpenGL to be just like software now - // -- Monster Iestyn -#endif - vid.fdupx = vid.fdupy = (vid.fdupx < vid.fdupy ? vid.fdupx : vid.fdupy); - - //vid.baseratio = FixedDiv(vid.height << FRACBITS, BASEVIDHEIGHT << FRACBITS); - vid.baseratio = FRACUNIT; - - vid.meddupx = (UINT8)(vid.dupx >> 1) + 1; - vid.meddupy = (UINT8)(vid.dupy >> 1) + 1; -#ifdef HWRENDER - vid.fmeddupx = vid.meddupx*FRACUNIT; - vid.fmeddupy = vid.meddupy*FRACUNIT; -#endif - - vid.smalldupx = (UINT8)(vid.dupx / 3) + 1; - vid.smalldupy = (UINT8)(vid.dupy / 3) + 1; -#ifdef HWRENDER - vid.fsmalldupx = vid.smalldupx*FRACUNIT; - vid.fsmalldupy = vid.smalldupy*FRACUNIT; -#endif + V_Recalc(); // toggle off (then back on) the automap because some screensize-dependent values will // be calculated next time the automap is activated. @@ -371,6 +319,12 @@ void SCR_Recalc(void) // vid.recalc lasts only for the next refresh... con_recalc = true; am_recalc = true; + +#ifdef HWRENDER + // Shoot! The screen texture was flushed! + if ((rendermode == render_opengl) && (gamestate == GS_INTERMISSION)) + usebuffer = false; +#endif } // Check for screen cmd-line parms: to force a resolution. @@ -408,7 +362,19 @@ void SCR_CheckDefaultMode(void) setmodeneeded = VID_GetModeForSize(cv_scr_width.value, cv_scr_height.value) + 1; } - SCR_ActuallyChangeRenderer(); + if (cv_renderer.value != (signed)rendermode) + { + if (chosenrendermode == render_none) // nothing set at command line + SCR_ChangeRenderer(); + else + { + // Set cv_renderer to the current render mode + CV_StealthSetValue(&cv_renderer, rendermode); +#ifdef HWRENDER + CV_StealthSetValue(&cv_newrenderer, rendermode); +#endif + } + } } // sets the modenum as the new default video mode to be saved in the config file @@ -438,67 +404,33 @@ void SCR_ChangeFullscreen(void) #endif } -static int target_renderer = 0; - -void SCR_ActuallyChangeRenderer(void) +void SCR_SetTargetRenderer(void) { - setrenderneeded = target_renderer; + if (!con_refresh) + SCR_ChangeRenderer(); +} + +void SCR_ChangeRenderer(void) +{ + if ((signed)rendermode == cv_renderer.value) + return; #ifdef HWRENDER - // Well, it didn't even load anyway. - if ((vid_opengl_state == -1) && (setrenderneeded == render_opengl)) + // Check if OpenGL loaded successfully (or wasn't disabled) before switching to it. + if ((vid.glstate == VID_GL_LIBRARY_ERROR) + && (cv_renderer.value == render_opengl)) { if (M_CheckParm("-nogl")) CONS_Alert(CONS_ERROR, "OpenGL rendering was disabled!\n"); else CONS_Alert(CONS_ERROR, "OpenGL never loaded\n"); - setrenderneeded = 0; return; } #endif - // setting the same renderer twice WILL crash your game, so let's not, please - if (rendermode == setrenderneeded) - setrenderneeded = 0; -} - -// Lactozilla: Renderer switching -void SCR_ChangeRenderer(void) -{ - setrenderneeded = 0; - - if (con_startup) - { - target_renderer = cv_renderer.value; -#ifdef HWRENDER - if (M_CheckParm("-opengl") && (vid_opengl_state == 1)) - target_renderer = rendermode = render_opengl; - else -#endif - if (M_CheckParm("-software")) - target_renderer = rendermode = render_soft; - // set cv_renderer back - SCR_ChangeRendererCVars(rendermode); - return; - } - - if (cv_renderer.value == 1) - target_renderer = render_soft; - else if (cv_renderer.value == 2) - target_renderer = render_opengl; - SCR_ActuallyChangeRenderer(); -} - -void SCR_ChangeRendererCVars(INT32 mode) -{ - // set cv_renderer back - if (mode == render_soft) - CV_StealthSetValue(&cv_renderer, 1); - else if (mode == render_opengl) - CV_StealthSetValue(&cv_renderer, 2); -#ifdef HWRENDER - CV_StealthSetValue(&cv_newrenderer, cv_renderer.value); -#endif + // Set the new render mode + setrenderneeded = cv_renderer.value; + con_refresh = false; } boolean SCR_IsAspectCorrect(INT32 width, INT32 height) diff --git a/src/screen.h b/src/screen.h index 91ec175f4..3f6c91d05 100644 --- a/src/screen.h +++ b/src/screen.h @@ -72,10 +72,16 @@ typedef struct viddef_s #ifdef HWRENDER INT32/*fixed_t*/ fsmalldupx, fsmalldupy; INT32/*fixed_t*/ fmeddupx, fmeddupy; + INT32 glstate; #endif } viddef_t; -#define VIDWIDTH vid.width -#define VIDHEIGHT vid.height + +enum +{ + VID_GL_LIBRARY_NOTLOADED = 0, + VID_GL_LIBRARY_LOADED = 1, + VID_GL_LIBRARY_ERROR = -1, +}; // internal additional info for vesa modes only typedef struct @@ -171,10 +177,10 @@ extern boolean R_SSE2; extern viddef_t vid; extern INT32 setmodeneeded; // mode number to set if needed, or 0 +extern UINT8 setrenderneeded; void SCR_ChangeRenderer(void); -void SCR_ChangeRendererCVars(INT32 mode); -extern UINT8 setrenderneeded; +void SCR_SetTargetRenderer(void); extern INT32 scr_bpp; extern UINT8 *scr_borderpatch; // patch used to fill the view borders @@ -188,17 +194,23 @@ extern consvar_t cv_newrenderer; // wait for page flipping to end or not extern consvar_t cv_vidwait; +// Initialize the screen +void SCR_Startup(void); + // Change video mode, only at the start of a refresh. void SCR_SetMode(void); + +// Set drawer functions for Software void SCR_SetDrawFuncs(void); + // Recalc screen size dependent stuff void SCR_Recalc(void); + // Check parms once at startup void SCR_CheckDefaultMode(void); -// Set the mode number which is saved in the config -void SCR_SetDefaultMode (void); -void SCR_Startup (void); +// Set the mode number which is saved in the config +void SCR_SetDefaultMode(void); FUNCMATH boolean SCR_IsAspectCorrect(INT32 width, INT32 height); diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index 1bb48e468..3e31e4450 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -95,7 +95,7 @@ static INT32 numVidModes = -1; static char vidModeName[33][32]; // allow 33 different modes rendermode_t rendermode = render_soft; -static rendermode_t chosenrendermode = render_soft; // set by command line arguments +rendermode_t chosenrendermode = render_none; // set by command line arguments boolean highcolor = false; @@ -105,7 +105,6 @@ static consvar_t cv_stretch = {"stretch", "Off", CV_SAVE|CV_NOSHOWHELP, CV_OnOff static consvar_t cv_alwaysgrabmouse = {"alwaysgrabmouse", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; UINT8 graphics_started = 0; // Is used in console.c and screen.c -INT32 vid_opengl_state = 0; // To disable fullscreen at startup; is set in VID_PrepareModeList boolean allow_fullscreen = false; @@ -1443,7 +1442,8 @@ static SDL_bool Impl_CreateContext(void) { // Renderer-specific stuff #ifdef HWRENDER - if ((rendermode == render_opengl) && (vid_opengl_state != -1)) + if ((rendermode == render_opengl) + && (vid.glstate != VID_GL_LIBRARY_ERROR)) { if (!sdlglcontext) sdlglcontext = SDL_GL_CreateContext(window); @@ -1479,30 +1479,29 @@ static SDL_bool Impl_CreateContext(void) void VID_CheckGLLoaded(rendermode_t oldrender) { #ifdef HWRENDER - if (vid_opengl_state == -1) // Well, it didn't work the first time anyway. + if (vid.glstate == VID_GL_LIBRARY_ERROR) // Well, it didn't work the first time anyway. { CONS_Alert(CONS_ERROR, "OpenGL never loaded\n"); rendermode = oldrender; if (chosenrendermode == render_opengl) // fallback to software rendermode = render_soft; - if (setrenderneeded) - { - CV_StealthSetValue(&cv_renderer, oldrender); - CV_StealthSetValue(&cv_newrenderer, oldrender); - setrenderneeded = 0; - } + + CV_StealthSetValue(&cv_renderer, oldrender); + CV_StealthSetValue(&cv_newrenderer, oldrender); } #endif } -void VID_CheckRenderer(void) +boolean VID_CheckRenderer(void) { boolean rendererchanged = false; boolean contextcreated = false; +#ifdef HWRENDER rendermode_t oldrenderer = rendermode; +#endif if (dedicated) - return; + return false; if (setrenderneeded) { @@ -1516,11 +1515,12 @@ void VID_CheckRenderer(void) // Initialise OpenGL before calling SDLSetMode!!! // This is because SDLSetMode calls OglSdlSurface. - if (vid_opengl_state == 0) + if (vid.glstate == VID_GL_LIBRARY_NOTLOADED) { VID_StartupOpenGL(); + // Loaded successfully! - if (vid_opengl_state == 1) + if (vid.glstate == VID_GL_LIBRARY_LOADED) { // Destroy the current window, if it exists. if (window) @@ -1543,7 +1543,7 @@ void VID_CheckRenderer(void) contextcreated = true; } } - else if (vid_opengl_state == -1) + else if (vid.glstate == VID_GL_LIBRARY_ERROR) rendererchanged = false; } #endif @@ -1565,27 +1565,22 @@ void VID_CheckRenderer(void) bufSurface = NULL; } - if (rendererchanged) - { #ifdef HWRENDER - if (vid_opengl_state == 1) // Only if OpenGL ever loaded! - HWR_FreeTextureCache(); + if (rendererchanged && vid.glstate == VID_GL_LIBRARY_LOADED) // Only if OpenGL ever loaded! + HWR_ClearAllTextures(); #endif - SCR_SetDrawFuncs(); - } + + SCR_SetDrawFuncs(); } #ifdef HWRENDER - else if (rendermode == render_opengl) + else if (rendermode == render_opengl && rendererchanged) { - if (rendererchanged) - { - R_InitHardwareMode(); - V_SetPalette(0); - } + HWR_Switch(); + V_SetPalette(0); } -#else - (void)oldrenderer; #endif + + return rendererchanged; } INT32 VID_SetMode(INT32 modeNum) @@ -1626,7 +1621,7 @@ static SDL_bool Impl_CreateWindow(SDL_bool fullscreen) flags |= SDL_WINDOW_BORDERLESS; #ifdef HWRENDER - if (vid_opengl_state == 1) + if (vid.glstate == VID_GL_LIBRARY_LOADED) flags |= SDL_WINDOW_OPENGL; #endif @@ -1747,12 +1742,44 @@ void I_StartupGraphics(void) framebuffer = SDL_TRUE; } -#ifdef HWRENDER - if (M_CheckParm("-opengl")) - chosenrendermode = rendermode = render_opengl; + // Renderer choices + // Takes priority over the config. + if (M_CheckParm("-renderer")) + { + INT32 i = 0; + CV_PossibleValue_t *renderer_list = cv_renderer_t; + const char *modeparm = M_GetNextParm(); + while (renderer_list[i].strvalue) + { + if (!stricmp(modeparm, renderer_list[i].strvalue)) + { + chosenrendermode = renderer_list[i].value; + break; + } + i++; + } + } + + // Choose Software renderer else if (M_CheckParm("-software")) + chosenrendermode = render_soft; + +#ifdef HWRENDER + // Choose OpenGL renderer + else if (M_CheckParm("-opengl")) + chosenrendermode = render_opengl; + + // Don't startup OpenGL + if (M_CheckParm("-nogl")) + { + vid.glstate = VID_GL_LIBRARY_ERROR; + if (chosenrendermode == render_opengl) + chosenrendermode = render_none; + } #endif - chosenrendermode = rendermode = render_soft; + + if (chosenrendermode != render_none) + rendermode = chosenrendermode; usesdl2soft = M_CheckParm("-softblit"); borderlesswindow = M_CheckParm("-borderless"); @@ -1761,9 +1788,7 @@ void I_StartupGraphics(void) VID_Command_ModeList_f(); #ifdef HWRENDER - if (M_CheckParm("-nogl")) - vid_opengl_state = -1; // Don't startup OpenGL - else if (chosenrendermode == render_opengl) + if (rendermode == render_opengl) VID_StartupOpenGL(); #endif @@ -1865,9 +1890,9 @@ void VID_StartupOpenGL(void) HWD.pfnLoadCustomShader = hwSym("LoadCustomShader",NULL); HWD.pfnInitCustomShaders= hwSym("InitCustomShaders",NULL); - vid_opengl_state = HWD.pfnInit() ? 1 : -1; // let load the OpenGL library + vid.glstate = HWD.pfnInit() ? VID_GL_LIBRARY_LOADED : VID_GL_LIBRARY_ERROR; // let load the OpenGL library - if (vid_opengl_state == -1) + if (vid.glstate == VID_GL_LIBRARY_ERROR) { rendermode = render_soft; setrenderneeded = 0; diff --git a/src/v_video.c b/src/v_video.c index 7f07852fa..89ffea6cf 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -3719,3 +3719,36 @@ void V_Init(void) CONS_Debug(DBG_RENDER, " screens[%d] = %x\n", i, screens[i]); #endif } + +void V_Recalc(void) +{ + // scale 1,2,3 times in x and y the patches for the menus and overlays... + // calculated once and for all, used by routines in v_video.c and v_draw.c + vid.dupx = vid.width / BASEVIDWIDTH; + vid.dupy = vid.height / BASEVIDHEIGHT; + vid.dupx = vid.dupy = (vid.dupx < vid.dupy ? vid.dupx : vid.dupy); + vid.fdupx = FixedDiv(vid.width*FRACUNIT, BASEVIDWIDTH*FRACUNIT); + vid.fdupy = FixedDiv(vid.height*FRACUNIT, BASEVIDHEIGHT*FRACUNIT); + +#ifdef HWRENDER + //if (rendermode != render_opengl && rendermode != render_none) // This was just placing it incorrectly at non aspect correct resolutions in opengl + // 13/11/18: + // The above is no longer necessary, since we want OpenGL to be just like software now + // -- Monster Iestyn +#endif + vid.fdupx = vid.fdupy = (vid.fdupx < vid.fdupy ? vid.fdupx : vid.fdupy); + + vid.meddupx = (UINT8)(vid.dupx >> 1) + 1; + vid.meddupy = (UINT8)(vid.dupy >> 1) + 1; +#ifdef HWRENDER + vid.fmeddupx = vid.meddupx*FRACUNIT; + vid.fmeddupy = vid.meddupy*FRACUNIT; +#endif + + vid.smalldupx = (UINT8)(vid.dupx / 3) + 1; + vid.smalldupy = (UINT8)(vid.dupy / 3) + 1; +#ifdef HWRENDER + vid.fsmalldupx = vid.smalldupx*FRACUNIT; + vid.fsmalldupy = vid.smalldupy*FRACUNIT; +#endif +} diff --git a/src/v_video.h b/src/v_video.h index 9f7a9a9e9..96bc7db89 100644 --- a/src/v_video.h +++ b/src/v_video.h @@ -37,6 +37,9 @@ cv_allcaps; // Allocates buffer screens, call before R_Init. void V_Init(void); +// Recalculates the viddef (dupx, dupy, etc.) according to the current screen resolution. +void V_Recalc(void); + // Color look-up table #define COLORBITS 6 #define SHIFTCOLORBITS (8-COLORBITS) diff --git a/src/w_wad.c b/src/w_wad.c index f40f4eb4a..0d329302a 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -845,7 +845,7 @@ UINT16 W_InitFile(const char *filename, boolean mainfile, boolean startup) #ifdef HWRENDER // Read shaders from file - if (rendermode == render_opengl && (vid_opengl_state == 1)) + if (rendermode == render_opengl && (vid.glstate == VID_GL_LIBRARY_LOADED)) { HWR_ReadShaders(numwadfiles - 1, (type == RET_PK3)); HWR_LoadShaders(); diff --git a/src/win32/win_vid.c b/src/win32/win_vid.c index 716f38089..6a74a08d2 100644 --- a/src/win32/win_vid.c +++ b/src/win32/win_vid.c @@ -48,6 +48,7 @@ // this is the CURRENT rendermode!! very important: used by w_wad, and much other code rendermode_t rendermode = render_soft; +rendermode_t chosenrendermode = render_none; // set by command line arguments static void OnTop_OnChange(void); // synchronize page flipping with screen refresh static CV_PossibleValue_t CV_NeverOnOff[] = {{-1, "Never"}, {0, "Off"}, {1, "On"}, {0, NULL}}; @@ -56,7 +57,6 @@ static consvar_t cv_stretch = {"stretch", "On", CV_SAVE|CV_NOSHOWHELP, CV_OnOff, static consvar_t cv_ontop = {"ontop", "Never", 0, CV_NeverOnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; boolean highcolor; -int vid_opengl_state = 0; static BOOL bDIBMode; // means we are using DIB instead of DirectDraw surfaces static LPBITMAPINFO bmiMain = NULL; @@ -952,7 +952,11 @@ INT32 VID_SetMode(INT32 modenum) return 1; } -void VID_CheckRenderer(void) {} +boolean VID_CheckRenderer(void) +{ + return false; +} + void VID_CheckGLLoaded(rendermode_t oldrender) { (void)oldrender; From 8863e13fde2e2e1189185483aea4e033e67aa08c Mon Sep 17 00:00:00 2001 From: Jaime Passos Date: Sat, 15 Aug 2020 20:14:36 -0300 Subject: [PATCH 0078/1080] Rename R_CheckIfPatch --- src/p_setup.c | 2 +- src/r_patch.c | 18 ++++++------------ src/r_patch.h | 3 ++- 3 files changed, 9 insertions(+), 14 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index 0105a06da..8d7904bb0 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -603,7 +603,7 @@ texturefound: { flatfound: /* This could be a flat, patch, or PNG. */ - if (R_CheckIfPatch(flatnum)) + if (Patch_CheckIfDoom((patch_t *)W_CacheLumpNum(flatnum, PU_STATIC), W_LumpLength(flatnum))) levelflat->type = LEVELFLAT_PATCH; else { diff --git a/src/r_patch.c b/src/r_patch.c index 783c1fbec..9a5364f9a 100644 --- a/src/r_patch.c +++ b/src/r_patch.c @@ -143,29 +143,23 @@ void *Patch_CreateGL(patch_t *patch) #endif // HWRENDER // -// R_CheckIfPatch +// Patch_CheckIfDoom // -// Returns true if the lump is a valid patch. +// Returns true if the lump is a valid Doom patch. // -boolean R_CheckIfPatch(lumpnum_t lump) +boolean Patch_CheckIfDoom(softwarepatch_t *patch, size_t length) { - size_t size; INT16 width, height; - patch_t *patch; boolean result; - size = W_LumpLength(lump); - // minimum length of a valid Doom patch - if (size < 13) + if (length < 13) return false; - patch = (patch_t *)W_CacheLumpNum(lump, PU_STATIC); - width = SHORT(patch->width); height = SHORT(patch->height); - result = (height > 0 && height <= 16384 && width > 0 && width <= 16384 && width < (INT16)(size / 4)); + result = (height > 0 && height <= 16384 && width > 0 && width <= 16384 && width < (INT16)(length / 4)); if (result) { @@ -180,7 +174,7 @@ boolean R_CheckIfPatch(lumpnum_t lump) UINT32 ofs = LONG(patch->columnofs[x]); // Need one byte for an empty column (but there's patches that don't know that!) - if (ofs < (UINT32)width * 4 + 8 || ofs >= (UINT32)size) + if (ofs < (UINT32)width * 4 + 8 || ofs >= (UINT32)length) { result = false; break; diff --git a/src/r_patch.h b/src/r_patch.h index de4981fba..9fe5fde72 100644 --- a/src/r_patch.h +++ b/src/r_patch.h @@ -46,8 +46,9 @@ void *Patch_AllocateHardwarePatch(patch_t *patch); void *Patch_CreateGL(patch_t *patch); #endif +boolean Patch_CheckIfDoom(softwarepatch_t *patch, size_t length); + // Conversions between patches / flats / textures... -boolean R_CheckIfPatch(lumpnum_t lump); void R_TextureToFlat(size_t tex, UINT8 *flat); void R_PatchToFlat(patch_t *patch, UINT8 *flat); void R_PatchToMaskedFlat(patch_t *patch, UINT16 *raw, boolean flip); From 92c4993d672a506762334f5d9146e3cf113b44a5 Mon Sep 17 00:00:00 2001 From: Jaime Passos Date: Sat, 15 Aug 2020 21:52:01 -0300 Subject: [PATCH 0079/1080] Introduce Doom patch format into picture formats Fixes sprite rotation --- src/hardware/hw_cache.c | 4 +- src/p_setup.c | 4 +- src/r_patch.c | 3 - src/r_picformats.c | 155 +++++++++++++++++++++++++++------------- src/r_picformats.h | 10 ++- src/r_textures.c | 6 +- src/r_things.c | 2 +- src/w_wad.c | 2 +- 8 files changed, 122 insertions(+), 64 deletions(-) diff --git a/src/hardware/hw_cache.c b/src/hardware/hw_cache.c index 138301d01..631aa056b 100644 --- a/src/hardware/hw_cache.c +++ b/src/hardware/hw_cache.c @@ -516,13 +516,13 @@ static void HWR_GenerateTexture(INT32 texnum, GLMapTexture_t *grtex) { // Dummy variables. INT32 pngwidth, pngheight; - realpatch = (softwarepatch_t *)Picture_PNGConvert(pdata, PICFMT_PATCH, &pngwidth, &pngheight, NULL, NULL, lumplength, NULL, 0); + realpatch = (softwarepatch_t *)Picture_PNGConvert(pdata, PICFMT_DOOMPATCH, &pngwidth, &pngheight, NULL, NULL, lumplength, NULL, 0); } else #endif #ifdef WALLFLATS if (texture->type == TEXTURETYPE_FLAT) - realpatch = (softwarepatch_t *)Picture_Convert(PICFMT_FLAT, pdata, PICFMT_PATCH, 0, NULL, texture->width, texture->height, 0, 0, 0); + realpatch = (softwarepatch_t *)Picture_Convert(PICFMT_FLAT, pdata, PICFMT_DOOMPATCH, 0, NULL, texture->width, texture->height, 0, 0, 0); else #endif { diff --git a/src/p_setup.c b/src/p_setup.c index 5e0b0304b..78f78f0c8 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -549,7 +549,7 @@ Ploadflat (levelflat_t *levelflat, const char *flatname, boolean resize) lumpnum_t flatnum; int texturenum; - patch_t *flatpatch; + UINT8 *flatpatch; size_t lumplength; size_t i; @@ -609,7 +609,7 @@ flatfound: /* This could be a flat, patch, or PNG. */ flatpatch = W_CacheLumpNum(flatnum, PU_CACHE); lumplength = W_LumpLength(flatnum); - if (Picture_CheckIfPatch(flatpatch, lumplength)) + if (Picture_CheckIfDoomPatch((softwarepatch_t *)flatpatch, lumplength)) levelflat->type = LEVELFLAT_PATCH; else { diff --git a/src/r_patch.c b/src/r_patch.c index e70d0cb7c..281523fd2 100644 --- a/src/r_patch.c +++ b/src/r_patch.c @@ -57,9 +57,6 @@ patch_t *Patch_Create(softwarepatch_t *source, size_t srcsize, void *dest) M_Memcpy(patch->columns, ((UINT8 *)source + LONG(source->columnofs[0])), colsize); } - if (patch->hardware) - I_Error("wtf?\n"); - return patch; } diff --git a/src/r_picformats.c b/src/r_picformats.c index e351466c9..d42d36a00 100644 --- a/src/r_picformats.c +++ b/src/r_picformats.c @@ -118,7 +118,7 @@ void *Picture_PatchConvert( UINT8 *imgptr = imgbuf; UINT8 *colpointers, *startofspan; size_t size = 0; - softwarepatch_t *inpatch = NULL; + patch_t *inpatch = NULL; INT32 inbpp = Picture_FormatBPP(informat); (void)insize; // ignore @@ -140,10 +140,21 @@ void *Picture_PatchConvert( if (Picture_IsPatchFormat(informat)) { inpatch = (patch_t *)picture; - inwidth = SHORT(inpatch->width); - inheight = SHORT(inpatch->height); - inleftoffset = SHORT(inpatch->leftoffset); - intopoffset = SHORT(inpatch->topoffset); + if (Picture_IsDoomPatchFormat(informat)) + { + softwarepatch_t *doompatch = (softwarepatch_t *)picture; + inwidth = SHORT(doompatch->width); + inheight = SHORT(doompatch->height); + inleftoffset = SHORT(doompatch->leftoffset); + intopoffset = SHORT(doompatch->topoffset); + } + else + { + inwidth = inpatch->width; + inheight = inpatch->height; + inleftoffset = inpatch->leftoffset; + intopoffset = inpatch->topoffset; + } } // Write image size and offset @@ -273,6 +284,7 @@ void *Picture_PatchConvert( switch (outformat) { case PICFMT_PATCH32: + case PICFMT_DOOMPATCH32: { if (inbpp == PICDEPTH_32BPP) { @@ -292,6 +304,7 @@ void *Picture_PatchConvert( break; } case PICFMT_PATCH16: + case PICFMT_DOOMPATCH16: if (inbpp == PICDEPTH_32BPP) { RGBA_t in = *(RGBA_t *)input; @@ -338,7 +351,18 @@ void *Picture_PatchConvert( if (outsize != NULL) *outsize = size; - return img; + + if (Picture_IsInternalPatchFormat(outformat)) + { + patch_t *converted = Patch_Create((softwarepatch_t *)img, size, NULL); +#ifdef HWRENDER + Patch_CreateGL(converted); +#endif + Z_Free(img); + return converted; + } + else + return img; } /** Converts a picture to a flat. @@ -389,8 +413,17 @@ void *Picture_FlatConvert( if (Picture_IsPatchFormat(informat)) { inpatch = (patch_t *)picture; - inwidth = SHORT(inpatch->width); - inheight = SHORT(inpatch->height); + if (Picture_IsDoomPatchFormat(informat)) + { + softwarepatch_t *doompatch = ((softwarepatch_t *)picture); + inwidth = SHORT(doompatch->width); + inheight = SHORT(doompatch->height); + } + else + { + inwidth = inpatch->width; + inheight = inpatch->height; + } } size = (inwidth * inheight) * (outbpp / 8); @@ -501,22 +534,25 @@ void *Picture_GetPatchPixel( UINT8 *s8 = NULL; UINT16 *s16 = NULL; UINT32 *s32 = NULL; + softwarepatch_t *doompatch = (softwarepatch_t *)patch; + INT16 width; if (patch == NULL) I_Error("Picture_GetPatchPixel: patch == NULL"); - if (x >= 0 && x < SHORT(patch->width)) - { - INT32 topdelta, prevdelta = -1; - INT32 colofs = 0; + width = (Picture_IsDoomPatchFormat(informat) ? patch->width : SHORT(patch->width)); - if (flags & PICFLAGS_XFLIP) - colofs = LONG(patch->columnofs[(SHORT(patch->width)-1)-x]); - else - colofs = LONG(patch->columnofs[x]); + if (x >= 0 && x < width) + { + INT32 colx = (flags & PICFLAGS_XFLIP) ? (width-1)-x : x; + INT32 topdelta, prevdelta = -1; + INT32 colofs = (Picture_IsDoomPatchFormat(informat) ? LONG(patch->columnofs[colx]) : patch->columnofs[colx]); // Column offsets are pointers so no casting required - column = (column_t *)((UINT8 *)patch + colofs); + if (Picture_IsDoomPatchFormat(informat)) + column = (column_t *)((UINT8 *)doompatch + colofs); + else + column = (column_t *)((UINT8 *)patch->columns + colofs); while (column->topdelta != 0xff) { @@ -525,25 +561,25 @@ void *Picture_GetPatchPixel( topdelta += prevdelta; prevdelta = topdelta; s8 = (UINT8 *)(column) + 3; - if (informat == PICFMT_PATCH32) + if (Picture_FormatBPP(informat) == PICDEPTH_32BPP) s32 = (UINT32 *)s8; - else if (informat == PICFMT_PATCH16) + else if (Picture_FormatBPP(informat) == PICDEPTH_16BPP) s16 = (UINT16 *)s8; for (ofs = 0; ofs < column->length; ofs++) { if ((topdelta + ofs) == y) { - if (informat == PICFMT_PATCH32) + if (Picture_FormatBPP(informat) == PICDEPTH_32BPP) return &s32[ofs]; - else if (informat == PICFMT_PATCH16) + else if (Picture_FormatBPP(informat) == PICDEPTH_16BPP) return &s16[ofs]; - else // PICFMT_PATCH + else // PICDEPTH_8BPP return &s8[ofs]; } } - if (informat == PICFMT_PATCH32) + if (Picture_FormatBPP(informat) == PICDEPTH_32BPP) column = (column_t *)((UINT32 *)column + column->length); - else if (informat == PICFMT_PATCH16) + else if (Picture_FormatBPP(informat) == PICDEPTH_16BPP) column = (column_t *)((UINT16 *)column + column->length); else column = (column_t *)((UINT8 *)column + column->length); @@ -566,15 +602,18 @@ INT32 Picture_FormatBPP(pictureformat_t format) { case PICFMT_PATCH32: case PICFMT_FLAT32: + case PICFMT_DOOMPATCH32: case PICFMT_PNG: bpp = PICDEPTH_32BPP; break; case PICFMT_PATCH16: case PICFMT_FLAT16: + case PICFMT_DOOMPATCH16: bpp = PICDEPTH_16BPP; break; case PICFMT_PATCH: case PICFMT_FLAT: + case PICFMT_DOOMPATCH: bpp = PICDEPTH_8BPP; break; default: @@ -590,7 +629,43 @@ INT32 Picture_FormatBPP(pictureformat_t format) */ boolean Picture_IsPatchFormat(pictureformat_t format) { - return (format == PICFMT_PATCH || format == PICFMT_PATCH16 || format == PICFMT_PATCH32); + return (Picture_IsInternalPatchFormat(format) || Picture_IsDoomPatchFormat(format)); +} + +/** Checks if the specified picture format is an internal patch. + * + * \param format Input picture format. + * \return True if the picture format is an internal patch, false if not. + */ +boolean Picture_IsInternalPatchFormat(pictureformat_t format) +{ + switch (format) + { + case PICFMT_PATCH: + case PICFMT_PATCH16: + case PICFMT_PATCH32: + return true; + default: + return false; + } +} + +/** Checks if the specified picture format is a Doom patch. + * + * \param format Input picture format. + * \return True if the picture format is a Doom patch, false if not. + */ +boolean Picture_IsDoomPatchFormat(pictureformat_t format) +{ + switch (format) + { + case PICFMT_DOOMPATCH: + case PICFMT_DOOMPATCH16: + case PICFMT_DOOMPATCH32: + return true; + default: + return false; + } } /** Checks if the specified picture format is a flat. @@ -604,13 +679,13 @@ boolean Picture_IsFlatFormat(pictureformat_t format) } /** Returns true if the lump is a valid Doom patch. - * PICFMT_PATCH only, I think?? + * PICFMT_DOOMPATCH only. * * \param patch Input patch. * \param picture Input patch size. * \return True if the input patch is valid. */ -boolean Picture_CheckIfPatch(softwarepatch_t *patch, size_t size) +boolean Picture_CheckIfDoomPatch(softwarepatch_t *patch, size_t size) { INT16 width, height; boolean result; @@ -1461,7 +1536,6 @@ void R_CacheRotSprite(spritenum_t sprnum, UINT8 frame, spriteinfo_t *sprinfo, sp { INT32 angle; patch_t *patch, *newpatch; - softwarepatch_t *swpatch; UINT16 *rawdst; size_t size; pictureflags_t bflip = (flip) ? PICFLAGS_XFLIP : 0; @@ -1598,32 +1672,19 @@ void R_CacheRotSprite(spritenum_t sprnum, UINT8 frame, spriteinfo_t *sprinfo, sp } // make patch - swpatch = (softwarepatch_t *)Picture_Convert(PICFMT_FLAT16, rawdst, PICFMT_PATCH, 0, &size, newwidth, newheight, 0, 0, 0); + newpatch = (patch_t *)Picture_Convert(PICFMT_FLAT16, rawdst, PICFMT_PATCH, 0, &size, newwidth, newheight, 0, 0, 0); { - swpatch->leftoffset = (swpatch->width / 2) + (leftoffset - px); - swpatch->topoffset = (swpatch->height / 2) + (patch->topoffset - py); + newpatch->leftoffset = (newpatch->width / 2) + (leftoffset - px); + newpatch->topoffset = (newpatch->height / 2) + (patch->topoffset - py); } //BP: we cannot use special tric in hardware mode because feet in ground caused by z-buffer if (rendermode != render_none) // not for psprite - swpatch->topoffset += FEETADJUST>>FRACBITS; + newpatch->topoffset += FEETADJUST>>FRACBITS; // P_PrecacheLevel if (devparm) spritememory += size; - // convert everything to little-endian, for big-endian support - swpatch->width = SHORT(swpatch->width); - swpatch->height = SHORT(swpatch->height); - swpatch->leftoffset = SHORT(swpatch->leftoffset); - swpatch->topoffset = SHORT(swpatch->topoffset); - - newpatch = Patch_Create(swpatch, size, NULL); - -#ifdef HWRENDER - if (rendermode == render_opengl) - Patch_CreateGL(newpatch); -#endif - sprframe->rotsprite.patch[rot][angle] = newpatch; // free rotated image data @@ -1632,10 +1693,6 @@ void R_CacheRotSprite(spritenum_t sprnum, UINT8 frame, spriteinfo_t *sprinfo, sp // This rotation is cached now sprframe->rotsprite.cached |= (1<type == TEXTURETYPE_FLAT) - realpatch = (softwarepatch_t *)Picture_Convert(PICFMT_FLAT, pdata, PICFMT_PATCH, 0, NULL, texture->width, texture->height, 0, 0, 0); + realpatch = (softwarepatch_t *)Picture_Convert(PICFMT_FLAT, pdata, PICFMT_DOOMPATCH, 0, NULL, texture->width, texture->height, 0, 0, 0); else #endif { @@ -608,7 +608,7 @@ void *R_GetLevelFlat(levelflat_t *levelflat) levelflat->height = ds_flatheight = SHORT(patch->height); levelflat->picture = Z_Malloc(levelflat->width * levelflat->height, PU_LEVEL, NULL); - converted = Picture_FlatConvert(PICFMT_PATCH, patch, PICFMT_FLAT, 0, &size, levelflat->width, levelflat->height, patch->topoffset, patch->leftoffset, 0); + converted = Picture_FlatConvert(PICFMT_DOOMPATCH, patch, PICFMT_FLAT, 0, &size, levelflat->width, levelflat->height, patch->topoffset, patch->leftoffset, 0); M_Memcpy(levelflat->picture, converted, size); Z_Free(converted); } diff --git a/src/r_things.c b/src/r_things.c index 9b32a6d5f..8bbf21b54 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -286,7 +286,7 @@ boolean R_AddSingleSpriteDef(const char *sprname, spritedef_t *spritedef, UINT16 // Dummy variables. INT32 pngwidth, pngheight; INT16 topoffset, leftoffset; - patch_t *converted = (patch_t *)Picture_PNGConvert((UINT8 *)png, PICFMT_PATCH, &pngwidth, &pngheight, &topoffset, &leftoffset, len, NULL, 0); + patch_t *converted = (patch_t *)Picture_PNGConvert((UINT8 *)png, PICFMT_DOOMPATCH, &pngwidth, &pngheight, &topoffset, &leftoffset, len, NULL, 0); M_Memcpy(&patch, converted, sizeof(INT16)*4); // only copy the header because that's all we need Z_Free(converted); } diff --git a/src/w_wad.c b/src/w_wad.c index 21004e6e8..1a1e08da9 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -1684,7 +1684,7 @@ void *W_CacheSoftwarePatchNumPwad(UINT16 wad, UINT16 lump, INT32 tag) { size_t newlen; INT32 pngwidth, pngheight; // Dummy variables. - void *converted = Picture_PNGConvert((UINT8 *)lumpdata, PICFMT_PATCH, &pngwidth, &pngheight, NULL, NULL, len, &newlen, 0); + void *converted = Picture_PNGConvert((UINT8 *)lumpdata, PICFMT_DOOMPATCH, &pngwidth, &pngheight, NULL, NULL, len, &newlen, 0); ptr = Z_Malloc(newlen, PU_STATIC, NULL); M_Memcpy(ptr, converted, newlen); Z_Free(converted); From 77e438d4bd859febbc1a4cde9bee8f2ed0de9b3b Mon Sep 17 00:00:00 2001 From: Nev3r Date: Sun, 16 Aug 2020 11:33:00 +0200 Subject: [PATCH 0080/1080] Some commenting tweaks. --- src/taglist.c | 2 +- src/taglist.h | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/taglist.c b/src/taglist.c index 7fd2601c7..bc5a166fd 100644 --- a/src/taglist.c +++ b/src/taglist.c @@ -208,7 +208,7 @@ void Taglist_InitGlobalTables(void) } } -// Iteration, inagme search. +// Iteration, ingame search. INT32 Tag_Iterate_Sectors (const mtag_t tag, const size_t p) { diff --git a/src/taglist.h b/src/taglist.h index 7c3b4ad52..896344c13 100644 --- a/src/taglist.h +++ b/src/taglist.h @@ -47,9 +47,12 @@ INT32 Tag_Iterate_Things (const mtag_t tag, const size_t p); INT32 Tag_FindLineSpecial(const INT16 special, const mtag_t tag); INT32 P_FindSpecialLineFromTag(INT16 special, INT16 tag, INT32 start); -#define TAG_ITER_C size_t kkkk; -#define TAG_ITER(fn, tag, id) for(kkkk = 0; (id = fn(tag, kkkk)) >= 0; kkkk++) +// Use this macro to declare the iterator position variable. +#define TAG_ITER_C size_t tag_iterator_pos; +#define TAG_ITER(fn, tag, id) for(tag_iterator_pos = 0; (id = fn(tag, tag_iterator_pos)) >= 0; tag_iterator_pos++) + +// Use these macros as wrappers for the taglist iterations. #define TAG_ITER_SECTORS(tag, id) TAG_ITER(Tag_Iterate_Sectors, tag, id) #define TAG_ITER_LINES(tag, id) TAG_ITER(Tag_Iterate_Lines, tag, id) #define TAG_ITER_THINGS(tag, id) TAG_ITER(Tag_Iterate_Things, tag, id) From 4173b15c8e71e3614641d50a4bb0220eb280ef45 Mon Sep 17 00:00:00 2001 From: GoldenTails Date: Thu, 13 Aug 2020 23:33:47 -0500 Subject: [PATCH 0081/1080] Expose V_GetStringColormap to Lua via v.getStringColormap(). --- src/lua_hudlib.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/lua_hudlib.c b/src/lua_hudlib.c index 4aa70574b..6b87dc930 100644 --- a/src/lua_hudlib.c +++ b/src/lua_hudlib.c @@ -992,6 +992,19 @@ static int libd_getColormap(lua_State *L) return 1; } +static int libd_getStringColormap(lua_State *L) +{ + INT32 flags = luaL_checkinteger(L, 1); + UINT8* colormap = NULL; + HUDONLY + colormap = V_GetStringColormap(flags & V_CHARCOLORMASK); + if (colormap) { + LUA_PushUserdata(L, colormap, META_COLORMAP); // push as META_COLORMAP userdata, specifically for patches to use! + return 1; + } + return 0; +} + static int libd_fadeScreen(lua_State *L) { UINT16 color = luaL_checkinteger(L, 1); @@ -1142,6 +1155,7 @@ static luaL_Reg lib_draw[] = { {"getSpritePatch", libd_getSpritePatch}, {"getSprite2Patch", libd_getSprite2Patch}, {"getColormap", libd_getColormap}, + {"getStringColormap", libd_getStringColormap}, // drawing {"draw", libd_draw}, {"drawScaled", libd_drawScaled}, From dcaad758f49d6f3d9b64742f5988ec6239647c99 Mon Sep 17 00:00:00 2001 From: Jaime Passos Date: Mon, 7 Sep 2020 02:23:07 -0300 Subject: [PATCH 0082/1080] Improved memory management for patches --- src/dehacked.c | 8 -- src/f_finale.c | 294 ++++++++++++++++++++--------------------- src/hardware/hw_main.c | 12 +- src/lua_hudlib.c | 12 +- src/lua_infolib.c | 9 -- src/m_menu.c | 7 +- src/p_setup.c | 4 + src/r_data.c | 2 +- src/r_defs.h | 1 - src/r_patch.c | 22 ++- src/r_patch.h | 3 + src/r_picformats.c | 256 ++++++++++++++--------------------- src/r_picformats.h | 4 +- src/r_things.c | 17 +-- src/st_stuff.c | 8 +- src/y_inter.c | 7 +- src/z_zone.c | 32 +++++ src/z_zone.h | 14 +- 18 files changed, 344 insertions(+), 368 deletions(-) diff --git a/src/dehacked.c b/src/dehacked.c index 613c683f3..bb5e811ff 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -1046,11 +1046,6 @@ static void readspriteinfo(MYFILE *f, INT32 num, boolean sprite2) spriteinfo_t *info = Z_Calloc(sizeof(spriteinfo_t), PU_STATIC, NULL); info->available = true; -#ifdef ROTSPRITE - if ((sprites != NULL) && (!sprite2)) - R_FreeRotSprite(&sprites[num]); -#endif - do { lastline = f->curpos; @@ -1179,9 +1174,6 @@ static void readspriteinfo(MYFILE *f, INT32 num, boolean sprite2) size_t skinnum = skinnumbers[i]; skin_t *skin = &skins[skinnum]; spriteinfo_t *sprinfo = skin->sprinfo; -#ifdef ROTSPRITE - R_FreeSkinRotSprite(skinnum); -#endif M_Memcpy(&sprinfo[num], info, sizeof(spriteinfo_t)); } } diff --git a/src/f_finale.c b/src/f_finale.c index 7cc5467c2..2a5e0b3c6 100644 --- a/src/f_finale.c +++ b/src/f_finale.c @@ -528,78 +528,78 @@ static void F_IntroDrawScene(void) case 0: break; case 1: - background = W_CachePatchName("INTRO1", PU_PATCH); + background = W_CachePatchName("INTRO1", PU_PATCH_LOWPRIORITY); break; case 2: - background = W_CachePatchName("INTRO2", PU_PATCH); + background = W_CachePatchName("INTRO2", PU_PATCH_LOWPRIORITY); break; case 3: - background = W_CachePatchName("INTRO3", PU_PATCH); + background = W_CachePatchName("INTRO3", PU_PATCH_LOWPRIORITY); break; case 4: - background = W_CachePatchName("INTRO4", PU_PATCH); + background = W_CachePatchName("INTRO4", PU_PATCH_LOWPRIORITY); break; case 5: if (intro_curtime >= 5*TICRATE) - background = W_CachePatchName("RADAR", PU_PATCH); + background = W_CachePatchName("RADAR", PU_PATCH_LOWPRIORITY); else - background = W_CachePatchName("DRAT", PU_PATCH); + background = W_CachePatchName("DRAT", PU_PATCH_LOWPRIORITY); break; case 6: - background = W_CachePatchName("INTRO6", PU_PATCH); + background = W_CachePatchName("INTRO6", PU_PATCH_LOWPRIORITY); cx = 180; cy = 8; break; case 7: { if (intro_curtime >= 7*TICRATE + ((TICRATE/7)*2)) - background = W_CachePatchName("SGRASS5", PU_PATCH); + background = W_CachePatchName("SGRASS5", PU_PATCH_LOWPRIORITY); else if (intro_curtime >= 7*TICRATE + (TICRATE/7)) - background = W_CachePatchName("SGRASS4", PU_PATCH); + background = W_CachePatchName("SGRASS4", PU_PATCH_LOWPRIORITY); else if (intro_curtime >= 7*TICRATE) - background = W_CachePatchName("SGRASS3", PU_PATCH); + background = W_CachePatchName("SGRASS3", PU_PATCH_LOWPRIORITY); else if (intro_curtime >= 6*TICRATE) - background = W_CachePatchName("SGRASS2", PU_PATCH); + background = W_CachePatchName("SGRASS2", PU_PATCH_LOWPRIORITY); else - background = W_CachePatchName("SGRASS1", PU_PATCH); + background = W_CachePatchName("SGRASS1", PU_PATCH_LOWPRIORITY); break; } case 8: - background = W_CachePatchName("WATCHING", PU_PATCH); + background = W_CachePatchName("WATCHING", PU_PATCH_LOWPRIORITY); break; case 9: - background = W_CachePatchName("ZOOMING", PU_PATCH); + background = W_CachePatchName("ZOOMING", PU_PATCH_LOWPRIORITY); break; case 10: break; case 11: - background = W_CachePatchName("INTRO5", PU_PATCH); + background = W_CachePatchName("INTRO5", PU_PATCH_LOWPRIORITY); break; case 12: - background = W_CachePatchName("REVENGE", PU_PATCH); + background = W_CachePatchName("REVENGE", PU_PATCH_LOWPRIORITY); cx = 208; cy = 8; break; case 13: - background = W_CachePatchName("CONFRONT", PU_PATCH); + background = W_CachePatchName("CONFRONT", PU_PATCH_LOWPRIORITY); cy += 48; break; case 14: - background = W_CachePatchName("TAILSSAD", PU_PATCH); + background = W_CachePatchName("TAILSSAD", PU_PATCH_LOWPRIORITY); bgxoffs = 144; cx = 8; cy = 8; break; case 15: if (intro_curtime >= 7*TICRATE) - background = W_CachePatchName("SONICDO2", PU_PATCH); + background = W_CachePatchName("SONICDO2", PU_PATCH_LOWPRIORITY); else - background = W_CachePatchName("SONICDO1", PU_PATCH); + background = W_CachePatchName("SONICDO1", PU_PATCH_LOWPRIORITY); cx = 224; cy = 8; break; case 16: - background = W_CachePatchName("INTRO7", PU_PATCH); + background = W_CachePatchName("INTRO7", PU_PATCH_LOWPRIORITY); break; default: break; @@ -629,30 +629,30 @@ static void F_IntroDrawScene(void) S_ChangeMusicInternal("_stjr", false); x = (BASEVIDWIDTH< 6) { - V_DrawSciencePatch(x, y, 0, (patch = W_CachePatchName("WAHH2", PU_PATCH)), aspect); + V_DrawSciencePatch(x, y, 0, (patch = W_CachePatchName("WAHH2", PU_PATCH_LOWPRIORITY)), aspect); W_UnlockCachedPatch(patch); } if (finalecount > 10) { - V_DrawSciencePatch(x, y, 0, (patch = W_CachePatchName("WAHH3", PU_PATCH)), aspect); + V_DrawSciencePatch(x, y, 0, (patch = W_CachePatchName("WAHH3", PU_PATCH_LOWPRIORITY)), aspect); W_UnlockCachedPatch(patch); } if (finalecount > 14) { - V_DrawSciencePatch(x, y, 0, (patch = W_CachePatchName("WAHH4", PU_PATCH)), aspect); + V_DrawSciencePatch(x, y, 0, (patch = W_CachePatchName("WAHH4", PU_PATCH_LOWPRIORITY)), aspect); W_UnlockCachedPatch(patch); } } else if (finalecount-30 < 20) { // Big eggy - background = W_CachePatchName("FEEDIN", PU_PATCH); + background = W_CachePatchName("FEEDIN", PU_PATCH_LOWPRIORITY); x = (BASEVIDWIDTH< 4*TICRATE) { // Door is being raised! int ftime = (finalecount-TICRATE/2-4*TICRATE); y -= FixedDiv((ftime*ftime)< 5*TICRATE && timetonext < 6*TICRATE) { if (!(finalecount & 3)) - background = W_CachePatchName("BRITEGG1", PU_PATCH); + background = W_CachePatchName("BRITEGG1", PU_PATCH_LOWPRIORITY); else - background = W_CachePatchName("DARKEGG1", PU_PATCH); + background = W_CachePatchName("DARKEGG1", PU_PATCH_LOWPRIORITY); V_DrawSmallScaledPatch(0, 0, 0, background); } else if (timetonext > 3*TICRATE && timetonext < 4*TICRATE) { if (!(finalecount & 3)) - background = W_CachePatchName("BRITEGG2", PU_PATCH); + background = W_CachePatchName("BRITEGG2", PU_PATCH_LOWPRIORITY); else - background = W_CachePatchName("DARKEGG2", PU_PATCH); + background = W_CachePatchName("DARKEGG2", PU_PATCH_LOWPRIORITY); V_DrawSmallScaledPatch(0, 0, 0, background); } else if (timetonext > 1*TICRATE && timetonext < 2*TICRATE) { if (!(finalecount & 3)) - background = W_CachePatchName("BRITEGG3", PU_PATCH); + background = W_CachePatchName("BRITEGG3", PU_PATCH_LOWPRIORITY); else - background = W_CachePatchName("DARKEGG3", PU_PATCH); + background = W_CachePatchName("DARKEGG3", PU_PATCH_LOWPRIORITY); V_DrawSmallScaledPatch(0, 0, 0, background); } @@ -766,79 +766,79 @@ static void F_IntroDrawScene(void) knucklesx += sonicx; sonicx += P_ReturnThrustX(NULL, finalecount * ANG10, 3); - V_DrawSmallScaledPatch(skyx, 0, 0, (patch = W_CachePatchName("INTROSKY", PU_PATCH))); + V_DrawSmallScaledPatch(skyx, 0, 0, (patch = W_CachePatchName("INTROSKY", PU_PATCH_LOWPRIORITY))); V_DrawSmallScaledPatch(skyx - 320, 0, 0, patch); W_UnlockCachedPatch(patch); - V_DrawSmallScaledPatch(grassx, 0, 0, (patch = W_CachePatchName("INTROGRS", PU_PATCH))); + V_DrawSmallScaledPatch(grassx, 0, 0, (patch = W_CachePatchName("INTROGRS", PU_PATCH_LOWPRIORITY))); V_DrawSmallScaledPatch(grassx - 320, 0, 0, patch); W_UnlockCachedPatch(patch); if (finalecount & 1) { // Sonic - V_DrawSmallScaledPatch(sonicx, 54, 0, (patch = W_CachePatchName("RUN2", PU_PATCH))); + V_DrawSmallScaledPatch(sonicx, 54, 0, (patch = W_CachePatchName("RUN2", PU_PATCH_LOWPRIORITY))); W_UnlockCachedPatch(patch); // Appendages if (finalecount & 2) { // Sonic's feet - V_DrawSmallScaledPatch(sonicx - 8, 92, 0, (patch = W_CachePatchName("PEELOUT4", PU_PATCH))); + V_DrawSmallScaledPatch(sonicx - 8, 92, 0, (patch = W_CachePatchName("PEELOUT4", PU_PATCH_LOWPRIORITY))); W_UnlockCachedPatch(patch); // Tails' tails - V_DrawSmallScaledPatch(tailsx, tailsy, 0, (patch = W_CachePatchName("HELICOP2", PU_PATCH))); + V_DrawSmallScaledPatch(tailsx, tailsy, 0, (patch = W_CachePatchName("HELICOP2", PU_PATCH_LOWPRIORITY))); W_UnlockCachedPatch(patch); } else { // Sonic's feet - V_DrawSmallScaledPatch(sonicx - 8, 92, 0, (patch = W_CachePatchName("PEELOUT2", PU_PATCH))); + V_DrawSmallScaledPatch(sonicx - 8, 92, 0, (patch = W_CachePatchName("PEELOUT2", PU_PATCH_LOWPRIORITY))); W_UnlockCachedPatch(patch); // Tails' tails - V_DrawSmallScaledPatch(tailsx, tailsy, 0, (patch = W_CachePatchName("HELICOP1", PU_PATCH))); + V_DrawSmallScaledPatch(tailsx, tailsy, 0, (patch = W_CachePatchName("HELICOP1", PU_PATCH_LOWPRIORITY))); W_UnlockCachedPatch(patch); } // Tails - V_DrawSmallScaledPatch(tailsx, tailsy, 0, (patch = W_CachePatchName("FLY2", PU_PATCH))); + V_DrawSmallScaledPatch(tailsx, tailsy, 0, (patch = W_CachePatchName("FLY2", PU_PATCH_LOWPRIORITY))); W_UnlockCachedPatch(patch); // Knuckles - V_DrawSmallScaledPatch(knucklesx, knucklesy, 0, (patch = W_CachePatchName("GLIDE2", PU_PATCH))); + V_DrawSmallScaledPatch(knucklesx, knucklesy, 0, (patch = W_CachePatchName("GLIDE2", PU_PATCH_LOWPRIORITY))); W_UnlockCachedPatch(patch); } else { // Sonic - V_DrawSmallScaledPatch(sonicx, 54, 0, (patch = W_CachePatchName("RUN1", PU_PATCH))); + V_DrawSmallScaledPatch(sonicx, 54, 0, (patch = W_CachePatchName("RUN1", PU_PATCH_LOWPRIORITY))); W_UnlockCachedPatch(patch); // Appendages if (finalecount & 2) { // Sonic's feet - V_DrawSmallScaledPatch(sonicx - 8, 92, 0, (patch = W_CachePatchName("PEELOUT3", PU_PATCH))); + V_DrawSmallScaledPatch(sonicx - 8, 92, 0, (patch = W_CachePatchName("PEELOUT3", PU_PATCH_LOWPRIORITY))); W_UnlockCachedPatch(patch); // Tails' tails - V_DrawSmallScaledPatch(tailsx, tailsy, 0, (patch = W_CachePatchName("HELICOP2", PU_PATCH))); + V_DrawSmallScaledPatch(tailsx, tailsy, 0, (patch = W_CachePatchName("HELICOP2", PU_PATCH_LOWPRIORITY))); W_UnlockCachedPatch(patch); } else { // Sonic's feet - V_DrawSmallScaledPatch(sonicx - 8, 92, 0, (patch = W_CachePatchName("PEELOUT1", PU_PATCH))); + V_DrawSmallScaledPatch(sonicx - 8, 92, 0, (patch = W_CachePatchName("PEELOUT1", PU_PATCH_LOWPRIORITY))); W_UnlockCachedPatch(patch); // Tails' tails - V_DrawSmallScaledPatch(tailsx, tailsy, 0, (patch = W_CachePatchName("HELICOP1", PU_PATCH))); + V_DrawSmallScaledPatch(tailsx, tailsy, 0, (patch = W_CachePatchName("HELICOP1", PU_PATCH_LOWPRIORITY))); W_UnlockCachedPatch(patch); } // Tails - V_DrawSmallScaledPatch(tailsx, tailsy, 0, (patch = W_CachePatchName("FLY1", PU_PATCH))); + V_DrawSmallScaledPatch(tailsx, tailsy, 0, (patch = W_CachePatchName("FLY1", PU_PATCH_LOWPRIORITY))); W_UnlockCachedPatch(patch); // Knuckles - V_DrawSmallScaledPatch(knucklesx, knucklesy, 0, (patch = W_CachePatchName("GLIDE1", PU_PATCH))); + V_DrawSmallScaledPatch(knucklesx, knucklesy, 0, (patch = W_CachePatchName("GLIDE1", PU_PATCH_LOWPRIORITY))); W_UnlockCachedPatch(patch); } @@ -871,8 +871,8 @@ static void F_IntroDrawScene(void) y += (30*(FRACUNIT-scale)); } - rockpat = W_CachePatchName(va("ROID00%.2d", 34 - (worktics % 35)), PU_PATCH); - glow = W_CachePatchName(va("ENDGLOW%.1d", 2+(worktics & 1)), PU_PATCH); + rockpat = W_CachePatchName(va("ROID00%.2d", 34 - (worktics % 35)), PU_PATCH_LOWPRIORITY); + glow = W_CachePatchName(va("ENDGLOW%.1d", 2+(worktics & 1)), PU_PATCH_LOWPRIORITY); if (worktics >= 5) trans = (worktics-5)>>1; @@ -986,7 +986,7 @@ void F_IntroDrawer(void) { if (intro_scenenum == 5 && intro_curtime == 5*TICRATE) { - patch_t *radar = W_CachePatchName("RADAR", PU_PATCH); + patch_t *radar = W_CachePatchName("RADAR", PU_PATCH_LOWPRIORITY); F_WipeStartScreen(); F_WipeColorFill(31); @@ -999,7 +999,7 @@ void F_IntroDrawer(void) } else if (intro_scenenum == 7 && intro_curtime == 6*TICRATE) // Force a wipe here { - patch_t *grass = W_CachePatchName("SGRASS2", PU_PATCH); + patch_t *grass = W_CachePatchName("SGRASS2", PU_PATCH_LOWPRIORITY); F_WipeStartScreen(); F_WipeColorFill(31); @@ -1012,7 +1012,7 @@ void F_IntroDrawer(void) } /*else if (intro_scenenum == 12 && intro_curtime == 7*TICRATE) { - patch_t *confront = W_CachePatchName("CONFRONT", PU_PATCH); + patch_t *confront = W_CachePatchName("CONFRONT", PU_PATCH_LOWPRIORITY); F_WipeStartScreen(); F_WipeColorFill(31); @@ -1025,7 +1025,7 @@ void F_IntroDrawer(void) }*/ if (intro_scenenum == 15 && intro_curtime == 7*TICRATE) { - patch_t *sdo = W_CachePatchName("SONICDO2", PU_PATCH); + patch_t *sdo = W_CachePatchName("SONICDO2", PU_PATCH_LOWPRIORITY); F_WipeStartScreen(); F_WipeColorFill(31); @@ -1361,14 +1361,14 @@ void F_CreditDrawer(void) V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 31); // Zig Zagz - V_DrawScaledPatch(-16, zagpos, V_SNAPTOLEFT, W_CachePatchName("LTZIGZAG", PU_PATCH)); - V_DrawScaledPatch(-16, zagpos - 320, V_SNAPTOLEFT, W_CachePatchName("LTZIGZAG", PU_PATCH)); - V_DrawScaledPatch(BASEVIDWIDTH + 16, zagpos, V_SNAPTORIGHT|V_FLIP, W_CachePatchName("LTZIGZAG", PU_PATCH)); - V_DrawScaledPatch(BASEVIDWIDTH + 16, zagpos - 320, V_SNAPTORIGHT|V_FLIP, W_CachePatchName("LTZIGZAG", PU_PATCH)); + V_DrawScaledPatch(-16, zagpos, V_SNAPTOLEFT, W_CachePatchName("LTZIGZAG", PU_PATCH_LOWPRIORITY)); + V_DrawScaledPatch(-16, zagpos - 320, V_SNAPTOLEFT, W_CachePatchName("LTZIGZAG", PU_PATCH_LOWPRIORITY)); + V_DrawScaledPatch(BASEVIDWIDTH + 16, zagpos, V_SNAPTORIGHT|V_FLIP, W_CachePatchName("LTZIGZAG", PU_PATCH_LOWPRIORITY)); + V_DrawScaledPatch(BASEVIDWIDTH + 16, zagpos - 320, V_SNAPTORIGHT|V_FLIP, W_CachePatchName("LTZIGZAG", PU_PATCH_LOWPRIORITY)); // Draw background pictures first for (i = 0; credits_pics[i].patch; i++) - V_DrawSciencePatch(credits_pics[i].x<>1); + V_DrawSciencePatch(credits_pics[i].x<>1); // Dim the background V_DrawFadeScreen(0xFF00, 16); @@ -1577,14 +1577,14 @@ void F_GameEvaluationDrawer(void) if (goodending) { - rockpat = W_CachePatchName(va("ROID00%.2d", 34 - (finalecount % 35)), PU_PATCH); - glow = W_CachePatchName(va("ENDGLOW%.1d", 2+(finalecount & 1)), PU_PATCH); + rockpat = W_CachePatchName(va("ROID00%.2d", 34 - (finalecount % 35)), PU_PATCH_LOWPRIORITY); + glow = W_CachePatchName(va("ENDGLOW%.1d", 2+(finalecount & 1)), PU_PATCH_LOWPRIORITY); x -= FRACUNIT; } else { - rockpat = W_CachePatchName("ROID0000", PU_LEVEL); - glow = W_CachePatchName(va("ENDGLOW%.1d", (finalecount & 1)), PU_PATCH); + rockpat = W_CachePatchName("ROID0000", PU_PATCH_LOWPRIORITY); + glow = W_CachePatchName(va("ENDGLOW%.1d", (finalecount & 1)), PU_PATCH_LOWPRIORITY); } if (finalecount >= 5) @@ -1616,20 +1616,20 @@ void F_GameEvaluationDrawer(void) // if j == 0 - alternate between 0 and 1 // 1 - 1 and 2 // 2 - 2 and not rendered - V_DrawFixedPatch(x+sparkloffs[j-1][0], y+sparkloffs[j-1][1], FRACUNIT, 0, W_CachePatchName(va("ENDSPKL%.1d", (j - ((sparklloop & 1) ? 0 : 1))), PU_PATCH), R_GetTranslationColormap(TC_DEFAULT, SKINCOLOR_AQUA, GTC_CACHE)); + V_DrawFixedPatch(x+sparkloffs[j-1][0], y+sparkloffs[j-1][1], FRACUNIT, 0, W_CachePatchName(va("ENDSPKL%.1d", (j - ((sparklloop & 1) ? 0 : 1))), PU_PATCH_LOWPRIORITY), R_GetTranslationColormap(TC_DEFAULT, SKINCOLOR_AQUA, GTC_CACHE)); } j--; } } else { - patch_t *eggrock = W_CachePatchName("ENDEGRK5", PU_PATCH); + patch_t *eggrock = W_CachePatchName("ENDEGRK5", PU_PATCH_LOWPRIORITY); V_DrawFixedPatch(x, y, scale, 0, eggrock, colormap[0]); if (trans < 10) V_DrawFixedPatch(x, y, scale, trans<spriteframes[XTRA_ENDING]; - endfwrk[0] = W_CachePatchNum(sprframe->lumppat[0], PU_PATCH); + endfwrk[0] = W_CachePatchNum(sprframe->lumppat[0], PU_PATCH_LOWPRIORITY); sprframe = &sprdef->spriteframes[XTRA_ENDING+1]; - endfwrk[1] = W_CachePatchNum(sprframe->lumppat[0], PU_PATCH); + endfwrk[1] = W_CachePatchNum(sprframe->lumppat[0], PU_PATCH_LOWPRIORITY); sprframe = &sprdef->spriteframes[XTRA_ENDING+2]; - endfwrk[2] = W_CachePatchNum(sprframe->lumppat[0], PU_PATCH); + endfwrk[2] = W_CachePatchNum(sprframe->lumppat[0], PU_PATCH_LOWPRIORITY); } else // Show a star if your character doesn't have an ending firework display. (Basically the MISSINGs for this) { - endfwrk[0] = W_CachePatchName("ENDFWRK3", PU_PATCH); - endfwrk[1] = W_CachePatchName("ENDFWRK4", PU_PATCH); - endfwrk[2] = W_CachePatchName("ENDFWRK5", PU_PATCH); + endfwrk[0] = W_CachePatchName("ENDFWRK3", PU_PATCH_LOWPRIORITY); + endfwrk[1] = W_CachePatchName("ENDFWRK4", PU_PATCH_LOWPRIORITY); + endfwrk[2] = W_CachePatchName("ENDFWRK5", PU_PATCH_LOWPRIORITY); } - endbrdr[0] = W_CachePatchName("ENDBRDR2", PU_PATCH); + endbrdr[0] = W_CachePatchName("ENDBRDR2", PU_PATCH_LOWPRIORITY); } else { // eggman, skin nonspecific - endfwrk[0] = W_CachePatchName("ENDFWRK0", PU_PATCH); - endfwrk[1] = W_CachePatchName("ENDFWRK1", PU_PATCH); - endfwrk[2] = W_CachePatchName("ENDFWRK2", PU_PATCH); + endfwrk[0] = W_CachePatchName("ENDFWRK0", PU_PATCH_LOWPRIORITY); + endfwrk[1] = W_CachePatchName("ENDFWRK1", PU_PATCH_LOWPRIORITY); + endfwrk[2] = W_CachePatchName("ENDFWRK2", PU_PATCH_LOWPRIORITY); - endbrdr[0] = W_CachePatchName("ENDBRDR0", PU_LEVEL); + endbrdr[0] = W_CachePatchName("ENDBRDR0", PU_PATCH_LOWPRIORITY); } } static void F_CacheGoodEnding(void) { - endegrk[0] = W_CachePatchName("ENDEGRK2", PU_PATCH); - endegrk[1] = W_CachePatchName("ENDEGRK3", PU_PATCH); + endegrk[0] = W_CachePatchName("ENDEGRK2", PU_PATCH_LOWPRIORITY); + endegrk[1] = W_CachePatchName("ENDEGRK3", PU_PATCH_LOWPRIORITY); - endglow[0] = W_CachePatchName("ENDGLOW2", PU_PATCH); - endglow[1] = W_CachePatchName("ENDGLOW3", PU_PATCH); + endglow[0] = W_CachePatchName("ENDGLOW2", PU_PATCH_LOWPRIORITY); + endglow[1] = W_CachePatchName("ENDGLOW3", PU_PATCH_LOWPRIORITY); - endxpld[0] = W_CachePatchName("ENDEGRK4", PU_PATCH); + endxpld[0] = W_CachePatchName("ENDEGRK4", PU_PATCH_LOWPRIORITY); } void F_StartEnding(void) @@ -1902,9 +1902,9 @@ void F_EndingDrawer(void) patch_t *rockpat; if (!goodending || finalecount < INFLECTIONPOINT) - rockpat = W_CachePatchName("ROID0000", PU_PATCH); + rockpat = W_CachePatchName("ROID0000", PU_PATCH_LOWPRIORITY); else - rockpat = W_CachePatchName(va("ROID00%.2d", 34 - ((finalecount - INFLECTIONPOINT) % 35)), PU_PATCH); + rockpat = W_CachePatchName(va("ROID00%.2d", 34 - ((finalecount - INFLECTIONPOINT) % 35)), PU_PATCH_LOWPRIORITY); V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 31); @@ -2241,7 +2241,7 @@ void F_EndingDrawer(void) eemeralds_cur[0] += (360< 20) @@ -2388,11 +2388,11 @@ void F_SkyScroll(INT32 scrollxspeed, INT32 scrollyspeed, const char *patchname) if (!scrollxspeed && !scrollyspeed) { - V_DrawPatchFill(W_CachePatchName(patchname, PU_PATCH)); + V_DrawPatchFill(W_CachePatchName(patchname, PU_PATCH_LOWPRIORITY)); return; } - pat = W_CachePatchName(patchname, PU_PATCH); + pat = W_CachePatchName(patchname, PU_PATCH_LOWPRIORITY); patwidth = SHORT(pat->width); patheight = SHORT(pat->height); @@ -2431,7 +2431,7 @@ void F_SkyScroll(INT32 scrollxspeed, INT32 scrollyspeed, const char *patchname) lumpnum = W_CheckNumForName(name); \ if (lumpnum != LUMPERROR) \ { \ - arr[0] = W_CachePatchName(name, PU_LEVEL); \ + arr[0] = W_CachePatchName(name, PU_PATCH_LOWPRIORITY); \ arr[min(1, maxf-1)] = 0; \ } \ else if (strlen(name) <= 6) \ @@ -2444,7 +2444,7 @@ else if (strlen(name) <= 6) \ lumpname[8] = 0; \ lumpnum = W_CheckNumForName(lumpname); \ if (lumpnum != LUMPERROR) \ - arr[i] = W_CachePatchName(lumpname, PU_LEVEL); \ + arr[i] = W_CachePatchName(lumpname, PU_PATCH_LOWPRIORITY); \ else \ break; \ } \ @@ -2459,21 +2459,21 @@ static void F_CacheTitleScreen(void) { case TTMODE_OLD: case TTMODE_NONE: - ttbanner = W_CachePatchName("TTBANNER", PU_LEVEL); - ttwing = W_CachePatchName("TTWING", PU_LEVEL); - ttsonic = W_CachePatchName("TTSONIC", PU_LEVEL); - ttswave1 = W_CachePatchName("TTSWAVE1", PU_LEVEL); - ttswave2 = W_CachePatchName("TTSWAVE2", PU_LEVEL); - ttswip1 = W_CachePatchName("TTSWIP1", PU_LEVEL); - ttsprep1 = W_CachePatchName("TTSPREP1", PU_LEVEL); - ttsprep2 = W_CachePatchName("TTSPREP2", PU_LEVEL); - ttspop1 = W_CachePatchName("TTSPOP1", PU_LEVEL); - ttspop2 = W_CachePatchName("TTSPOP2", PU_LEVEL); - ttspop3 = W_CachePatchName("TTSPOP3", PU_LEVEL); - ttspop4 = W_CachePatchName("TTSPOP4", PU_LEVEL); - ttspop5 = W_CachePatchName("TTSPOP5", PU_LEVEL); - ttspop6 = W_CachePatchName("TTSPOP6", PU_LEVEL); - ttspop7 = W_CachePatchName("TTSPOP7", PU_LEVEL); + ttbanner = W_CachePatchName("TTBANNER", PU_PATCH_LOWPRIORITY); + ttwing = W_CachePatchName("TTWING", PU_PATCH_LOWPRIORITY); + ttsonic = W_CachePatchName("TTSONIC", PU_PATCH_LOWPRIORITY); + ttswave1 = W_CachePatchName("TTSWAVE1", PU_PATCH_LOWPRIORITY); + ttswave2 = W_CachePatchName("TTSWAVE2", PU_PATCH_LOWPRIORITY); + ttswip1 = W_CachePatchName("TTSWIP1", PU_PATCH_LOWPRIORITY); + ttsprep1 = W_CachePatchName("TTSPREP1", PU_PATCH_LOWPRIORITY); + ttsprep2 = W_CachePatchName("TTSPREP2", PU_PATCH_LOWPRIORITY); + ttspop1 = W_CachePatchName("TTSPOP1", PU_PATCH_LOWPRIORITY); + ttspop2 = W_CachePatchName("TTSPOP2", PU_PATCH_LOWPRIORITY); + ttspop3 = W_CachePatchName("TTSPOP3", PU_PATCH_LOWPRIORITY); + ttspop4 = W_CachePatchName("TTSPOP4", PU_PATCH_LOWPRIORITY); + ttspop5 = W_CachePatchName("TTSPOP5", PU_PATCH_LOWPRIORITY); + ttspop6 = W_CachePatchName("TTSPOP6", PU_PATCH_LOWPRIORITY); + ttspop7 = W_CachePatchName("TTSPOP7", PU_PATCH_LOWPRIORITY); break; // don't load alacroix gfx yet; we do that upon first draw. @@ -2593,7 +2593,7 @@ void F_StartTitleScreen(void) static void F_UnloadAlacroixGraphics(SINT8 oldttscale) { - // This all gets freed by PU_LEVEL when exiting the menus. + // This all gets freed by PU_PATCH_LOWPRIORITY when exiting the menus. // When re-visiting the menus (e.g., from exiting in-game), the gfx are force-reloaded. // So leftover addresses here should not be a problem. @@ -3701,7 +3701,7 @@ void F_ContinueDrawer(void) V_DrawLevelTitle(x - (V_LevelNameWidth("Continue?")>>1), 16, 0, "Continue?"); // Two stars... - patch = W_CachePatchName("CONTSTAR", PU_PATCH); + patch = W_CachePatchName("CONTSTAR", PU_PATCH_LOWPRIORITY); V_DrawScaledPatch(x-32, 160, 0, patch); V_DrawScaledPatch(x+32, 160, 0, patch); @@ -3709,14 +3709,14 @@ void F_ContinueDrawer(void) if (timeleft > 9) { numbuf[7] = '1'; - V_DrawScaledPatch(x - 10, 160, 0, W_CachePatchName(numbuf, PU_PATCH)); + V_DrawScaledPatch(x - 10, 160, 0, W_CachePatchName(numbuf, PU_PATCH_LOWPRIORITY)); numbuf[7] = '0'; - V_DrawScaledPatch(x + 10, 160, 0, W_CachePatchName(numbuf, PU_PATCH)); + V_DrawScaledPatch(x + 10, 160, 0, W_CachePatchName(numbuf, PU_PATCH_LOWPRIORITY)); } else { numbuf[7] = '0'+timeleft; - V_DrawScaledPatch(x, 160, 0, W_CachePatchName(numbuf, PU_PATCH)); + V_DrawScaledPatch(x, 160, 0, W_CachePatchName(numbuf, PU_PATCH_LOWPRIORITY)); } // Draw the continue markers! Show continues. @@ -3745,7 +3745,7 @@ void F_ContinueDrawer(void) } // Spotlight - V_DrawScaledPatch(x, 140, 0, W_CachePatchName("CONTSPOT", PU_PATCH)); + V_DrawScaledPatch(x, 140, 0, W_CachePatchName("CONTSPOT", PU_PATCH_LOWPRIORITY)); // warping laser if (continuetime) @@ -3782,7 +3782,7 @@ void F_ContinueDrawer(void) #define drawchar(dx, dy, n) {\ sprdef = &contskins[n]->sprites[cont_spr2[n][0]];\ sprframe = &sprdef->spriteframes[cont_spr2[n][1]];\ - patch = W_CachePatchNum(sprframe->lumppat[cont_spr2[n][2]], PU_PATCH);\ + patch = W_CachePatchNum(sprframe->lumppat[cont_spr2[n][2]], PU_PATCH_LOWPRIORITY);\ V_DrawFixedPatch((dx), (dy), contskins[n]->highresscale, (sprframe->flip & (1<scene[scenenum].pichires[picnum]) V_DrawSmallScaledPatch(picxpos, picypos, 0, - W_CachePatchName(cutscenes[cutnum]->scene[scenenum].picname[picnum], PU_PATCH)); + W_CachePatchName(cutscenes[cutnum]->scene[scenenum].picname[picnum], PU_PATCH_LOWPRIORITY)); else V_DrawScaledPatch(picxpos,picypos, 0, - W_CachePatchName(cutscenes[cutnum]->scene[scenenum].picname[picnum], PU_PATCH)); + W_CachePatchName(cutscenes[cutnum]->scene[scenenum].picname[picnum], PU_PATCH_LOWPRIORITY)); } if (dofadenow && rendermode != render_none) @@ -4536,10 +4536,10 @@ void F_TextPromptDrawer(void) { if (textprompts[cutnum]->page[scenenum].pichires[picnum]) V_DrawSmallScaledPatch(picxpos, picypos, 0, - W_CachePatchName(textprompts[cutnum]->page[scenenum].picname[picnum], PU_PATCH)); + W_CachePatchName(textprompts[cutnum]->page[scenenum].picname[picnum], PU_PATCH_LOWPRIORITY)); else V_DrawScaledPatch(picxpos,picypos, 0, - W_CachePatchName(textprompts[cutnum]->page[scenenum].picname[picnum], PU_PATCH)); + W_CachePatchName(textprompts[cutnum]->page[scenenum].picname[picnum], PU_PATCH_LOWPRIORITY)); } // Draw background @@ -4549,7 +4549,7 @@ void F_TextPromptDrawer(void) if (iconlump != LUMPERROR) { INT32 iconx, icony, scale, scaledsize; - patch = W_CachePatchName(textprompts[cutnum]->page[scenenum].iconname, PU_PATCH); + patch = W_CachePatchName(textprompts[cutnum]->page[scenenum].iconname, PU_PATCH_LOWPRIORITY); // scale and center if (patch->width > patch->height) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 486b03f33..a8644bb9a 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -733,7 +733,7 @@ static void HWR_DrawSegsSplats(FSurfaceInfo * pSurf) if (!M_PointInBox(segbbox,splat->v1.x,splat->v1.y) && !M_PointInBox(segbbox,splat->v2.x,splat->v2.y)) continue; - gpatch = W_CachePatchNum(splat->patch, PU_PATCH); + gpatch = W_CachePatchNum(splat->patch, PU_SPRITE); HWR_GetPatch(gpatch); wallVerts[0].x = wallVerts[3].x = FIXED_TO_FLOAT(splat->v1.x); @@ -3586,7 +3586,7 @@ static void HWR_DrawDropShadow(mobj_t *thing, fixed_t scale) if (alpha >= 255) return; alpha = 255 - alpha; - gpatch = (patch_t *)W_CachePatchName("DSHADOW", PU_CACHE); + gpatch = (patch_t *)W_CachePatchName("DSHADOW", PU_SPRITE); if (!(gpatch && ((GLPatch_t *)gpatch->hardware)->mipmap->format)) return; HWR_GetPatch(gpatch); @@ -4901,8 +4901,8 @@ static void HWR_ProjectSprite(mobj_t *thing) if (thing->rollangle) { rollangle = R_GetRollAngle(thing->rollangle); - if (!(sprframe->rotsprite.cached & (1<sprite, (thing->frame & FF_FRAMEMASK), sprinfo, sprframe, rot, flip); + if (sprframe->rotsprite.patch[rot][rollangle] == NULL) + R_CacheRotSprite(thing->sprite, (thing->frame & FF_FRAMEMASK), sprinfo, sprframe, rot, rollangle, flip); rotsprite = sprframe->rotsprite.patch[rot][rollangle]; if (rotsprite != NULL) { @@ -5030,7 +5030,7 @@ static void HWR_ProjectSprite(mobj_t *thing) vis->gpatch = (patch_t *)rotsprite; else #endif - vis->gpatch = (patch_t *)W_CachePatchNum(sprframe->lumppat[rot], PU_CACHE); + vis->gpatch = (patch_t *)W_CachePatchNum(sprframe->lumppat[rot], PU_SPRITE); vis->flip = flip; vis->mobj = thing; vis->z1 = z1; @@ -5165,7 +5165,7 @@ static void HWR_ProjectPrecipitationSprite(precipmobj_t *thing) vis->z2 = z2; vis->tz = tz; vis->dispoffset = 0; // Monster Iestyn: 23/11/15: HARDWARE SUPPORT AT LAST - vis->gpatch = (patch_t *)W_CachePatchNum(sprframe->lumppat[rot], PU_CACHE); + vis->gpatch = (patch_t *)W_CachePatchNum(sprframe->lumppat[rot], PU_SPRITE); vis->flip = flip; vis->mobj = (mobj_t *)thing; diff --git a/src/lua_hudlib.c b/src/lua_hudlib.c index d8375e1e8..69e807d50 100644 --- a/src/lua_hudlib.c +++ b/src/lua_hudlib.c @@ -458,8 +458,8 @@ static int libd_getSpritePatch(lua_State *L) INT32 rot = R_GetRollAngle(rollangle); if (rot) { - if (!(sprframe->rotsprite.cached & (1<flip & (1<rotsprite.patch[angle][rot] == NULL) + R_CacheRotSprite(i, frame, NULL, sprframe, angle, rot, sprframe->flip & (1<rotsprite.patch[angle][rot], META_PATCH); lua_pushboolean(L, false); lua_pushboolean(L, true); @@ -469,7 +469,7 @@ static int libd_getSpritePatch(lua_State *L) #endif // push both the patch and it's "flip" value - LUA_PushUserdata(L, W_CachePatchNum(sprframe->lumppat[angle], PU_PATCH), META_PATCH); + LUA_PushUserdata(L, W_CachePatchNum(sprframe->lumppat[angle], PU_SPRITE), META_PATCH); lua_pushboolean(L, (sprframe->flip & (1<rotsprite.cached & (1<flip & (1<rotsprite.patch[angle][rot] == NULL) + R_CacheRotSprite(SPR_PLAY, frame, &skins[i].sprinfo[j], sprframe, angle, rot, sprframe->flip & (1<rotsprite.patch[angle][rot], META_PATCH); lua_pushboolean(L, false); lua_pushboolean(L, true); @@ -582,7 +582,7 @@ static int libd_getSprite2Patch(lua_State *L) #endif // push both the patch and it's "flip" value - LUA_PushUserdata(L, W_CachePatchNum(sprframe->lumppat[angle], PU_PATCH), META_PATCH); + LUA_PushUserdata(L, W_CachePatchNum(sprframe->lumppat[angle], PU_SPRITE), META_PATCH); lua_pushboolean(L, (sprframe->flip & (1<= NUMSPRITES) return luaL_error(L, "spriteinfo[] index %d out of range (1 - %d)", i, NUMSPRITES-1); -#ifdef ROTSPRITE - if (sprites != NULL) - R_FreeRotSprite(&sprites[i]); -#endif info = &spriteinfo[i]; // get the spriteinfo to assign to. } luaL_checktype(L, 2, LUA_TTABLE); // check that we've been passed a table. @@ -463,11 +459,6 @@ static int spriteinfo_set(lua_State *L) lua_remove(L, 1); // remove field lua_settop(L, 1); // leave only one value -#ifdef ROTSPRITE - if (sprites != NULL) - R_FreeRotSprite(&sprites[sprinfo-spriteinfo]); -#endif - if (fastcmp(field, "pivot")) { // pivot[] is a table diff --git a/src/m_menu.c b/src/m_menu.c index 0e60dce0c..3c6397ebb 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -5840,8 +5840,6 @@ static void M_DrawNightsAttackSuperSonic(void) const UINT8 *colormap = R_GetTranslationColormap(TC_DEFAULT, SKINCOLOR_YELLOW, GTC_CACHE); INT32 timer = (ntsatkdrawtimer/4) % 2; angle_t fa = (FixedAngle(((ntsatkdrawtimer * 4) % 360)<>ANGLETOFINESHIFT) & FINEMASK; - ntssupersonic[0] = W_CachePatchName("NTSSONC1", PU_PATCH); - ntssupersonic[1] = W_CachePatchName("NTSSONC2", PU_PATCH); V_DrawFixedPatch(235<menuitems[itemOn].text,PU_CACHE); + pic_t *pictest = (pic_t *)W_CacheLumpName(currentMenu->menuitems[itemOn].text,PU_CACHE); if (!pictest->zero) V_DrawScaledPic(0,0,0,W_GetNumForName(currentMenu->menuitems[itemOn].text)); else @@ -10153,6 +10151,9 @@ static void M_NightsAttack(INT32 choice) // This is really just to make sure Sonic is the played character, just in case M_PatchSkinNameTable(); + ntssupersonic[0] = W_CachePatchName("NTSSONC1", PU_PATCH); + ntssupersonic[1] = W_CachePatchName("NTSSONC2", PU_PATCH); + G_SetGamestate(GS_TIMEATTACK); // do this before M_SetupNextMenu so that menu meta state knows that we're switching titlemapinaction = TITLEMAP_OFF; // Nope don't give us HOMs please M_SetupNextMenu(&SP_NightsAttackDef); diff --git a/src/p_setup.c b/src/p_setup.c index 78f78f0c8..ef1ae9eba 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -4090,6 +4090,8 @@ boolean P_LoadLevel(boolean fromnetsave) // Clear pointers that would be left dangling by the purge R_FlushTranslationColormapCache(); + Patch_FreeTag(PU_PATCH_LOWPRIORITY); + Patch_FreeTag(PU_SPRITE_ROTATED); Z_FreeTags(PU_LEVEL, PU_PURGELEVEL - 1); #if defined (WALLSPLATS) || defined (FLOORSPLATS) @@ -4475,6 +4477,8 @@ boolean P_AddWadFile(const char *wadfilename) // // search for sprite replacements // + Patch_FreeTag(PU_SPRITE); + Patch_FreeTag(PU_SPRITE_ROTATED); R_AddSpriteDefs(wadnum); // Reload it all anyway, just in case they diff --git a/src/r_data.c b/src/r_data.c index 0e0e613f4..3c7d76d21 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -1308,7 +1308,7 @@ void R_PrecacheLevel(void) lump = sf->lumppat[a];\ if (devparm)\ spritememory += W_LumpLength(lump);\ - W_CachePatchNum(lump, PU_PATCH);\ + W_CachePatchNum(lump, PU_SPRITE);\ } // see R_InitSprites for more about lumppat,lumpid switch (sf->rotate) diff --git a/src/r_defs.h b/src/r_defs.h index becf2aed8..679b0fa35 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -711,7 +711,6 @@ typedef struct typedef struct { patch_t *patch[16][ROTANGLES]; - UINT16 cached; } rotsprite_t; #endif/*ROTSPRITE*/ diff --git a/src/r_patch.c b/src/r_patch.c index 281523fd2..d3dff0e33 100644 --- a/src/r_patch.c +++ b/src/r_patch.c @@ -64,7 +64,7 @@ patch_t *Patch_Create(softwarepatch_t *source, size_t srcsize, void *dest) // Frees a patch from memory. // -void Patch_Free(patch_t *patch) +static void Patch_FreeData(patch_t *patch) { #ifdef HWRENDER if (patch->hardware) @@ -75,10 +75,30 @@ void Patch_Free(patch_t *patch) Z_Free(patch->columnofs); if (patch->columns) Z_Free(patch->columns); +} +void Patch_Free(patch_t *patch) +{ + Patch_FreeData(patch); Z_Free(patch); } +// +// Frees patches with a tag range. +// + +static boolean Patch_FreeTagsCallback(void *mem) +{ + patch_t *patch = (patch_t *)mem; + Patch_FreeData(patch); + return true; +} + +void Patch_FreeTags(INT32 lowtag, INT32 hightag) +{ + Z_IterateTags(lowtag, hightag, Patch_FreeTagsCallback); +} + #ifdef HWRENDER // // Allocates a hardware patch. diff --git a/src/r_patch.h b/src/r_patch.h index 2caa8d0e4..c460e7d09 100644 --- a/src/r_patch.h +++ b/src/r_patch.h @@ -19,6 +19,9 @@ patch_t *Patch_Create(softwarepatch_t *source, size_t srcsize, void *dest); void Patch_Free(patch_t *patch); +#define Patch_FreeTag(tagnum) Patch_FreeTags(tagnum, tagnum) +void Patch_FreeTags(INT32 lowtag, INT32 hightag); + #ifdef HWRENDER void *Patch_AllocateHardwarePatch(patch_t *patch); void *Patch_CreateGL(patch_t *patch); diff --git a/src/r_picformats.c b/src/r_picformats.c index d42d36a00..078901fab 100644 --- a/src/r_picformats.c +++ b/src/r_picformats.c @@ -1350,11 +1350,6 @@ static void R_ParseSpriteInfo(boolean spr2) info = Z_Calloc(sizeof(spriteinfo_t), PU_STATIC, NULL); info->available = true; -#ifdef ROTSPRITE - if ((sprites != NULL) && (!spr2)) - R_FreeRotSprite(&sprites[sprnum]); -#endif - // Left Curly Brace sprinfoToken = M_GetToken(NULL); if (sprinfoToken == NULL) @@ -1415,9 +1410,6 @@ static void R_ParseSpriteInfo(boolean spr2) size_t skinnum = skinnumbers[i]; skin_t *skin = &skins[skinnum]; spriteinfo_t *sprinfo = skin->sprinfo; -#ifdef ROTSPRITE - R_FreeSkinRotSprite(skinnum); -#endif M_Memcpy(&sprinfo[spr2num], info, sizeof(spriteinfo_t)); } } @@ -1532,24 +1524,28 @@ INT32 R_GetRollAngle(angle_t rollangle) // // Create a rotated sprite. // -void R_CacheRotSprite(spritenum_t sprnum, UINT8 frame, spriteinfo_t *sprinfo, spriteframe_t *sprframe, INT32 rot, UINT8 flip) +void R_CacheRotSprite(spritenum_t sprnum, UINT8 frame, spriteinfo_t *sprinfo, spriteframe_t *sprframe, INT32 rot, INT32 angle, UINT8 flip) { - INT32 angle; patch_t *patch, *newpatch; UINT16 *rawdst; size_t size; pictureflags_t bflip = (flip) ? PICFLAGS_XFLIP : 0; + // Don't cache angle = 0 + if (angle < 1 || angle >= ROTANGLES) + return; + #define SPRITE_XCENTER (leftoffset) #define SPRITE_YCENTER (height / 2) #define ROTSPRITE_XCENTER (newwidth / 2) #define ROTSPRITE_YCENTER (newheight / 2) - if (!(sprframe->rotsprite.cached & (1<rotsprite.patch[rot][angle] == NULL) { INT32 dx, dy; INT32 px, py; INT32 width, height, leftoffset; + INT32 newwidth, newheight; fixed_t ca, sa; lumpnum_t lump = sprframe->lumppat[rot]; @@ -1579,172 +1575,116 @@ void R_CacheRotSprite(spritenum_t sprnum, UINT8 frame, spriteinfo_t *sprinfo, sp leftoffset = width - leftoffset; } - // Don't cache angle = 0 - for (angle = 1; angle < ROTANGLES; angle++) + ca = rollcosang[angle]; + sa = rollsinang[angle]; + + // Find the dimensions of the rotated patch. { - INT32 newwidth, newheight; + INT32 w1 = abs(FixedMul(width << FRACBITS, ca) - FixedMul(height << FRACBITS, sa)); + INT32 w2 = abs(FixedMul(-(width << FRACBITS), ca) - FixedMul(height << FRACBITS, sa)); + INT32 h1 = abs(FixedMul(width << FRACBITS, sa) + FixedMul(height << FRACBITS, ca)); + INT32 h2 = abs(FixedMul(-(width << FRACBITS), sa) + FixedMul(height << FRACBITS, ca)); + w1 = FixedInt(FixedCeil(w1 + (FRACUNIT/2))); + w2 = FixedInt(FixedCeil(w2 + (FRACUNIT/2))); + h1 = FixedInt(FixedCeil(h1 + (FRACUNIT/2))); + h2 = FixedInt(FixedCeil(h2 + (FRACUNIT/2))); + newwidth = max(width, max(w1, w2)); + newheight = max(height, max(h1, h2)); + } - ca = rollcosang[angle]; - sa = rollsinang[angle]; + // check boundaries + { + fixed_t top[2][2]; + fixed_t bottom[2][2]; - // Find the dimensions of the rotated patch. - { - INT32 w1 = abs(FixedMul(width << FRACBITS, ca) - FixedMul(height << FRACBITS, sa)); - INT32 w2 = abs(FixedMul(-(width << FRACBITS), ca) - FixedMul(height << FRACBITS, sa)); - INT32 h1 = abs(FixedMul(width << FRACBITS, sa) + FixedMul(height << FRACBITS, ca)); - INT32 h2 = abs(FixedMul(-(width << FRACBITS), sa) + FixedMul(height << FRACBITS, ca)); - w1 = FixedInt(FixedCeil(w1 + (FRACUNIT/2))); - w2 = FixedInt(FixedCeil(w2 + (FRACUNIT/2))); - h1 = FixedInt(FixedCeil(h1 + (FRACUNIT/2))); - h2 = FixedInt(FixedCeil(h2 + (FRACUNIT/2))); - newwidth = max(width, max(w1, w2)); - newheight = max(height, max(h1, h2)); - } + top[0][0] = FixedMul((-ROTSPRITE_XCENTER) << FRACBITS, ca) + FixedMul((-ROTSPRITE_YCENTER) << FRACBITS, sa) + (px << FRACBITS); + top[0][1] = FixedMul((-ROTSPRITE_XCENTER) << FRACBITS, sa) + FixedMul((-ROTSPRITE_YCENTER) << FRACBITS, ca) + (py << FRACBITS); + top[1][0] = FixedMul((newwidth-ROTSPRITE_XCENTER) << FRACBITS, ca) + FixedMul((-ROTSPRITE_YCENTER) << FRACBITS, sa) + (px << FRACBITS); + top[1][1] = FixedMul((newwidth-ROTSPRITE_XCENTER) << FRACBITS, sa) + FixedMul((-ROTSPRITE_YCENTER) << FRACBITS, ca) + (py << FRACBITS); - // check boundaries - { - fixed_t top[2][2]; - fixed_t bottom[2][2]; + bottom[0][0] = FixedMul((-ROTSPRITE_XCENTER) << FRACBITS, ca) + FixedMul((newheight-ROTSPRITE_YCENTER) << FRACBITS, sa) + (px << FRACBITS); + bottom[0][1] = -FixedMul((-ROTSPRITE_XCENTER) << FRACBITS, sa) + FixedMul((newheight-ROTSPRITE_YCENTER) << FRACBITS, ca) + (py << FRACBITS); + bottom[1][0] = FixedMul((newwidth-ROTSPRITE_XCENTER) << FRACBITS, ca) + FixedMul((newheight-ROTSPRITE_YCENTER) << FRACBITS, sa) + (px << FRACBITS); + bottom[1][1] = -FixedMul((newwidth-ROTSPRITE_XCENTER) << FRACBITS, sa) + FixedMul((newheight-ROTSPRITE_YCENTER) << FRACBITS, ca) + (py << FRACBITS); - top[0][0] = FixedMul((-ROTSPRITE_XCENTER) << FRACBITS, ca) + FixedMul((-ROTSPRITE_YCENTER) << FRACBITS, sa) + (px << FRACBITS); - top[0][1] = FixedMul((-ROTSPRITE_XCENTER) << FRACBITS, sa) + FixedMul((-ROTSPRITE_YCENTER) << FRACBITS, ca) + (py << FRACBITS); - top[1][0] = FixedMul((newwidth-ROTSPRITE_XCENTER) << FRACBITS, ca) + FixedMul((-ROTSPRITE_YCENTER) << FRACBITS, sa) + (px << FRACBITS); - top[1][1] = FixedMul((newwidth-ROTSPRITE_XCENTER) << FRACBITS, sa) + FixedMul((-ROTSPRITE_YCENTER) << FRACBITS, ca) + (py << FRACBITS); + top[0][0] >>= FRACBITS; + top[0][1] >>= FRACBITS; + top[1][0] >>= FRACBITS; + top[1][1] >>= FRACBITS; - bottom[0][0] = FixedMul((-ROTSPRITE_XCENTER) << FRACBITS, ca) + FixedMul((newheight-ROTSPRITE_YCENTER) << FRACBITS, sa) + (px << FRACBITS); - bottom[0][1] = -FixedMul((-ROTSPRITE_XCENTER) << FRACBITS, sa) + FixedMul((newheight-ROTSPRITE_YCENTER) << FRACBITS, ca) + (py << FRACBITS); - bottom[1][0] = FixedMul((newwidth-ROTSPRITE_XCENTER) << FRACBITS, ca) + FixedMul((newheight-ROTSPRITE_YCENTER) << FRACBITS, sa) + (px << FRACBITS); - bottom[1][1] = -FixedMul((newwidth-ROTSPRITE_XCENTER) << FRACBITS, sa) + FixedMul((newheight-ROTSPRITE_YCENTER) << FRACBITS, ca) + (py << FRACBITS); - - top[0][0] >>= FRACBITS; - top[0][1] >>= FRACBITS; - top[1][0] >>= FRACBITS; - top[1][1] >>= FRACBITS; - - bottom[0][0] >>= FRACBITS; - bottom[0][1] >>= FRACBITS; - bottom[1][0] >>= FRACBITS; - bottom[1][1] >>= FRACBITS; + bottom[0][0] >>= FRACBITS; + bottom[0][1] >>= FRACBITS; + bottom[1][0] >>= FRACBITS; + bottom[1][1] >>= FRACBITS; #define BOUNDARYWCHECK(b) (b[0] < 0 || b[0] >= width) #define BOUNDARYHCHECK(b) (b[1] < 0 || b[1] >= height) #define BOUNDARYADJUST(x) x *= 2 - // top left/right - if (BOUNDARYWCHECK(top[0]) || BOUNDARYWCHECK(top[1])) - BOUNDARYADJUST(newwidth); - // bottom left/right - else if (BOUNDARYWCHECK(bottom[0]) || BOUNDARYWCHECK(bottom[1])) - BOUNDARYADJUST(newwidth); - // top left/right - if (BOUNDARYHCHECK(top[0]) || BOUNDARYHCHECK(top[1])) - BOUNDARYADJUST(newheight); - // bottom left/right - else if (BOUNDARYHCHECK(bottom[0]) || BOUNDARYHCHECK(bottom[1])) - BOUNDARYADJUST(newheight); + // top left/right + if (BOUNDARYWCHECK(top[0]) || BOUNDARYWCHECK(top[1])) + BOUNDARYADJUST(newwidth); + // bottom left/right + else if (BOUNDARYWCHECK(bottom[0]) || BOUNDARYWCHECK(bottom[1])) + BOUNDARYADJUST(newwidth); + // top left/right + if (BOUNDARYHCHECK(top[0]) || BOUNDARYHCHECK(top[1])) + BOUNDARYADJUST(newheight); + // bottom left/right + else if (BOUNDARYHCHECK(bottom[0]) || BOUNDARYHCHECK(bottom[1])) + BOUNDARYADJUST(newheight); #undef BOUNDARYWCHECK #undef BOUNDARYHCHECK #undef BOUNDARYADJUST - } - - // Draw the rotated sprite to a temporary buffer. - size = (newwidth * newheight); - if (!size) - size = (width * height); - rawdst = Z_Calloc(size * sizeof(UINT16), PU_STATIC, NULL); - - for (dy = 0; dy < newheight; dy++) - { - for (dx = 0; dx < newwidth; dx++) - { - INT32 x = (dx-ROTSPRITE_XCENTER) << FRACBITS; - INT32 y = (dy-ROTSPRITE_YCENTER) << FRACBITS; - INT32 sx = FixedMul(x, ca) + FixedMul(y, sa) + (px << FRACBITS); - INT32 sy = -FixedMul(x, sa) + FixedMul(y, ca) + (py << FRACBITS); - sx >>= FRACBITS; - sy >>= FRACBITS; - if (sx >= 0 && sy >= 0 && sx < width && sy < height) - { - void *input = Picture_GetPatchPixel(patch, PICFMT_PATCH, sx, sy, bflip); - if (input != NULL) - rawdst[(dy*newwidth)+dx] = (0xFF00 | (*(UINT8 *)input)); - } - } - } - - // make patch - newpatch = (patch_t *)Picture_Convert(PICFMT_FLAT16, rawdst, PICFMT_PATCH, 0, &size, newwidth, newheight, 0, 0, 0); - { - newpatch->leftoffset = (newpatch->width / 2) + (leftoffset - px); - newpatch->topoffset = (newpatch->height / 2) + (patch->topoffset - py); - } - - //BP: we cannot use special tric in hardware mode because feet in ground caused by z-buffer - if (rendermode != render_none) // not for psprite - newpatch->topoffset += FEETADJUST>>FRACBITS; - - // P_PrecacheLevel - if (devparm) spritememory += size; - - sprframe->rotsprite.patch[rot][angle] = newpatch; - - // free rotated image data - Z_Free(rawdst); } - // This rotation is cached now - sprframe->rotsprite.cached |= (1<>= FRACBITS; + sy >>= FRACBITS; + if (sx >= 0 && sy >= 0 && sx < width && sy < height) + { + void *input = Picture_GetPatchPixel(patch, PICFMT_PATCH, sx, sy, bflip); + if (input != NULL) + rawdst[(dy*newwidth)+dx] = (0xFF00 | (*(UINT8 *)input)); + } + } + } + + // make patch + newpatch = (patch_t *)Picture_Convert(PICFMT_FLAT16, rawdst, PICFMT_PATCH, 0, &size, newwidth, newheight, 0, 0, 0); + Z_ChangeTag(newpatch, PU_SPRITE_ROTATED); + { + newpatch->leftoffset = (newpatch->width / 2) + (leftoffset - px); + newpatch->topoffset = (newpatch->height / 2) + (patch->topoffset - py); + } + + //BP: we cannot use special tric in hardware mode because feet in ground caused by z-buffer + if (rendermode != render_none) // not for psprite + newpatch->topoffset += FEETADJUST>>FRACBITS; + + // P_PrecacheLevel + if (devparm) spritememory += size; + + Z_SetUser(newpatch, &sprframe->rotsprite.patch[rot][angle]); + + // free rotated image data + Z_Free(rawdst); } #undef SPRITE_XCENTER #undef SPRITE_YCENTER #undef ROTSPRITE_XCENTER #undef ROTSPRITE_YCENTER } - -// -// R_FreeRotSprite -// -// Free sprite rotation data from memory, for a single spritedef. -// -void R_FreeRotSprite(spritedef_t *spritedef) -{ - UINT8 frame; - INT32 rot, ang; - - for (frame = 0; frame < spritedef->numframes; frame++) - { - spriteframe_t *sprframe = &spritedef->spriteframes[frame]; - for (rot = 0; rot < 16; rot++) - { - if (sprframe->rotsprite.cached & (1<rotsprite.patch[rot][ang]; - if (rotsprite) - Patch_Free(rotsprite); - rotsprite = NULL; - } - sprframe->rotsprite.cached &= ~(1<sprites; - for (i = 0; i < NUMPLAYERSPRITES*2; i++) - { - R_FreeRotSprite(skinsprites); - skinsprites++; - } -} #endif diff --git a/src/r_picformats.h b/src/r_picformats.h index f303b9e3d..4f5c60ee1 100644 --- a/src/r_picformats.h +++ b/src/r_picformats.h @@ -126,9 +126,7 @@ void R_ParseSPRTINFOLump(UINT16 wadNum, UINT16 lumpNum); // Sprite rotation #ifdef ROTSPRITE INT32 R_GetRollAngle(angle_t rollangle); -void R_CacheRotSprite(spritenum_t sprnum, UINT8 frame, spriteinfo_t *sprinfo, spriteframe_t *sprframe, INT32 rot, UINT8 flip); -void R_FreeRotSprite(spritedef_t *spritedef); -void R_FreeSkinRotSprite(size_t skinnum); +void R_CacheRotSprite(spritenum_t sprnum, UINT8 frame, spriteinfo_t *sprinfo, spriteframe_t *sprframe, INT32 rot, INT32 angle, UINT8 flip); extern fixed_t rollcosang[ROTANGLES]; extern fixed_t rollsinang[ROTANGLES]; #endif diff --git a/src/r_things.c b/src/r_things.c index 8bbf21b54..e4465dfa9 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -107,7 +107,6 @@ static void R_InstallSpriteLump(UINT16 wad, // graphics patch // rotsprite #ifdef ROTSPRITE - sprtemp[frame].rotsprite.cached = 0; for (r = 0; r < 16; r++) { for (ang = 0; ang < ROTANGLES; ang++) @@ -241,9 +240,6 @@ boolean R_AddSingleSpriteDef(const char *sprname, spritedef_t *spritedef, UINT16 // if so, it might patch only certain frames, not all if (spritedef->numframes) // (then spriteframes is not null) { -#ifdef ROTSPRITE - R_FreeRotSprite(spritedef); -#endif // copy the already defined sprite frames M_Memcpy(sprtemp, spritedef->spriteframes, spritedef->numframes * sizeof (spriteframe_t)); @@ -402,9 +398,6 @@ boolean R_AddSingleSpriteDef(const char *sprname, spritedef_t *spritedef, UINT16 if (spritedef->numframes && // has been allocated spritedef->numframes < maxframe) // more frames are defined ? { -#ifdef ROTSPRITE - R_FreeRotSprite(spritedef); -#endif Z_Free(spritedef->spriteframes); spritedef->spriteframes = NULL; } @@ -1237,7 +1230,7 @@ static void R_ProjectDropShadow(mobj_t *thing, vissprite_t *vis, fixed_t scale, scalemul = FixedMul(FRACUNIT - floordiff/640, scale); - patch = W_CachePatchName("DSHADOW", PU_CACHE); + patch = W_CachePatchName("DSHADOW", PU_SPRITE); xscale = FixedDiv(projection, tz); yscale = FixedDiv(projectiony, tz); shadowxscale = FixedMul(thing->radius*2, scalemul); @@ -1533,8 +1526,8 @@ static void R_ProjectSprite(mobj_t *thing) if (thing->rollangle) { rollangle = R_GetRollAngle(thing->rollangle); - if (!(sprframe->rotsprite.cached & (1<sprite, frame, sprinfo, sprframe, rot, flip); + if (sprframe->rotsprite.patch[rot][rollangle] == NULL) + R_CacheRotSprite(thing->sprite, frame, sprinfo, sprframe, rot, rollangle, flip); rotsprite = sprframe->rotsprite.patch[rot][rollangle]; if (rotsprite != NULL) { @@ -1823,7 +1816,7 @@ static void R_ProjectSprite(mobj_t *thing) vis->patch = rotsprite; else #endif - vis->patch = W_CachePatchNum(sprframe->lumppat[rot], PU_CACHE); + vis->patch = W_CachePatchNum(sprframe->lumppat[rot], PU_SPRITE); // // determine the colormap (lightlevel & special effects) @@ -2006,7 +1999,7 @@ static void R_ProjectPrecipitationSprite(precipmobj_t *thing) //Fab: lumppat is the lump number of the patch to use, this is different // than lumpid for sprites-in-pwad : the graphics are patched - vis->patch = W_CachePatchNum(sprframe->lumppat[0], PU_CACHE); + vis->patch = W_CachePatchNum(sprframe->lumppat[0], PU_SPRITE); // specific translucency if (thing->frame & FF_TRANSMASK) diff --git a/src/st_stuff.c b/src/st_stuff.c index f6ba94fcc..5f3d75f44 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -232,7 +232,7 @@ void ST_doPaletteStuff(void) void ST_UnloadGraphics(void) { - Z_FreeTag(PU_HUDGFX); + Patch_FreeTag(PU_HUDGFX); } void ST_LoadGraphics(void) @@ -2080,21 +2080,21 @@ static void ST_drawNiGHTSHUD(void) if (stplyr->powers[pw_nights_superloop]) { pwr = stplyr->powers[pw_nights_superloop]; - V_DrawSmallScaledPatch(110, 44, 0, W_CachePatchName("NPRUA0",PU_CACHE)); + V_DrawSmallScaledPatch(110, 44, 0, W_CachePatchName("NPRUA0",PU_SPRITE)); V_DrawThinString(106, 52, V_MONOSPACE, va("%2d.%02d", pwr/TICRATE, G_TicsToCentiseconds(pwr))); } if (stplyr->powers[pw_nights_helper]) { pwr = stplyr->powers[pw_nights_helper]; - V_DrawSmallScaledPatch(150, 44, 0, W_CachePatchName("NPRUC0",PU_CACHE)); + V_DrawSmallScaledPatch(150, 44, 0, W_CachePatchName("NPRUC0",PU_SPRITE)); V_DrawThinString(146, 52, V_MONOSPACE, va("%2d.%02d", pwr/TICRATE, G_TicsToCentiseconds(pwr))); } if (stplyr->powers[pw_nights_linkfreeze]) { pwr = stplyr->powers[pw_nights_linkfreeze]; - V_DrawSmallScaledPatch(190, 44, 0, W_CachePatchName("NPRUE0",PU_CACHE)); + V_DrawSmallScaledPatch(190, 44, 0, W_CachePatchName("NPRUE0",PU_SPRITE)); V_DrawThinString(186, 52, V_MONOSPACE, va("%2d.%02d", pwr/TICRATE, G_TicsToCentiseconds(pwr))); } } diff --git a/src/y_inter.c b/src/y_inter.c index 4810ce7fa..961311593 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -2044,18 +2044,13 @@ void Y_EndIntermission(void) usebuffer = false; } -#define UNLOAD(x) if (x) {Z_ChangeTag(x, PU_CACHE);} x = NULL; +#define UNLOAD(x) if (x) {Patch_Free(x);} x = NULL; // // Y_UnloadData // static void Y_UnloadData(void) { - // In hardware mode, don't Z_ChangeTag a pointer returned by W_CachePatchName(). - // It doesn't work and is unnecessary. - if (rendermode != render_soft) - return; - // unload the background patches UNLOAD(bgpatch); UNLOAD(bgtile); diff --git a/src/z_zone.c b/src/z_zone.c index 02f9a9920..b704e1a30 100644 --- a/src/z_zone.c +++ b/src/z_zone.c @@ -496,6 +496,33 @@ void Z_FreeTags(INT32 lowtag, INT32 hightag) } } +/** Iterates through all memory for a given set of tags. + * + * \param lowtag The lowest tag to consider. + * \param hightag The highest tag to consider. + * \param iterfunc The iterator function. + */ +void Z_IterateTags(INT32 lowtag, INT32 hightag, boolean (*iterfunc)(void *)) +{ + memblock_t *block, *next; + + if (!iterfunc) + I_Error("Z_IterateTags: no iterator function was given"); + + for (block = head.next; block != &head; block = next) + { + next = block->next; // get link before possibly freeing + + if (block->tag >= lowtag && block->tag <= hightag) + { + void *mem = (UINT8 *)block->hdr + sizeof *block->hdr; + boolean free = iterfunc(mem); + if (free) + Z_Free(mem); + } + } +} + // ----------------- // Utility functions // ----------------- @@ -772,6 +799,11 @@ static void Command_Memfree_f(void) CONS_Printf(M_GetText("Static : %7s KB\n"), sizeu1(Z_TagUsage(PU_STATIC)>>10)); CONS_Printf(M_GetText("Static (sound) : %7s KB\n"), sizeu1(Z_TagUsage(PU_SOUND)>>10)); CONS_Printf(M_GetText("Static (music) : %7s KB\n"), sizeu1(Z_TagUsage(PU_MUSIC)>>10)); + CONS_Printf(M_GetText("Patches : %7s KB\n"), sizeu1(Z_TagUsage(PU_PATCH)>>10)); + CONS_Printf(M_GetText("Patches (low) : %7s KB\n"), sizeu1(Z_TagUsage(PU_PATCH_LOWPRIORITY)>>10)); + CONS_Printf(M_GetText("Sprites : %7s KB\n"), sizeu1(Z_TagUsage(PU_SPRITE)>>10)); + CONS_Printf(M_GetText("Sprites (rotated) : %7s KB\n"), sizeu1(Z_TagUsage(PU_SPRITE_ROTATED)>>10)); + 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("Special thinker : %7s KB\n"), sizeu1(Z_TagUsage(PU_LEVSPEC)>>10)); diff --git a/src/z_zone.h b/src/z_zone.h index c9dafc1ae..90a6de8eb 100644 --- a/src/z_zone.h +++ b/src/z_zone.h @@ -42,8 +42,12 @@ enum PU_SOUND = 11, // static while playing PU_MUSIC = 12, // static while playing - PU_HUDGFX = 13, // static until WAD added - PU_PATCH = 14, // static until renderer change + + PU_PATCH = 14, // static entire execution time + PU_PATCH_LOWPRIORITY = 15, // lower priority patch, static until level exited + PU_SPRITE = 16, // sprite patch, static until WAD added + PU_SPRITE_ROTATED = 17, // sprite patch, static until level exited or WAD added + PU_HUDGFX = 18, // HUD patch, static until WAD added PU_HWRPATCHINFO = 21, // Hardware GLPatch_t struct for OpenGL texture cache PU_HWRPATCHCOLMIPMAP = 22, // Hardware GLMipmap_t struct colormap variation of patch @@ -63,7 +67,7 @@ enum PU_HWRCACHE_UNLOCKED = 102, // 'unlocked' PU_HWRCACHE memory: // 'second-level' cache for graphics // stored in hardware format and downloaded as needed - PU_HWRPATCHINFO_UNLOCKED = 103, // 'unlocked' PU_HWRPATCHINFO memory + PU_HWRPATCHINFO_UNLOCKED = 103, // 'unlocked' PU_HWRPATCHINFO memory PU_HWRMODELTEXTURE_UNLOCKED = 104, // 'unlocked' PU_HWRMODELTEXTURE memory }; @@ -107,6 +111,10 @@ void *Z_ReallocAlign(void *ptr, size_t size, INT32 tag, void *user, INT32 alignb #define Z_FreeTag(tagnum) Z_FreeTags(tagnum, tagnum) void Z_FreeTags(INT32 lowtag, INT32 hightag); +// Iterate memory by tag +#define Z_IterateTag(tagnum, func) Z_IterateTags(tagnum, tagnum, func) +void Z_IterateTags(INT32 lowtag, INT32 hightag, boolean (*iterfunc)(void *)); + // // Utility functions // From 7e9bc0d103718a3ba6d65541d672e1299bb71f41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartu=20=C4=B0nce?= Date: Tue, 8 Sep 2020 03:03:48 +0300 Subject: [PATCH 0083/1080] no message --- src/p_user.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/p_user.c b/src/p_user.c index b8e7d1746..f6061c9dc 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -5041,7 +5041,7 @@ static void P_DoJumpStuff(player_t *player, ticcmd_t *cmd) else if (player->pflags & (PF_GLIDING|PF_SLIDING|PF_SHIELDABILITY)) // If the player has used an ability previously ; else if ((player->powers[pw_shield] & SH_NOSTACK) && !player->powers[pw_super] && !(player->pflags & PF_SPINDOWN) - && ((!(player->pflags & PF_THOKKED) || ((player->powers[pw_shield] & SH_NOSTACK) == SH_BUBBLEWRAP && player->secondjump == UINT8_MAX)))) // thokked is optional if you're bubblewrapped + && ((!(player->pflags & PF_THOKKED) || (((player->powers[pw_shield] & SH_NOSTACK) == SH_BUBBLEWRAP || (player->powers[pw_shield] & SH_NOSTACK) == SH_ATTRACT) && player->secondjump == UINT8_MAX) ))) // thokked is optional if you're bubblewrapped / 3dblasted { if ((player->powers[pw_shield] & SH_NOSTACK) == SH_ATTRACT) { @@ -5093,6 +5093,7 @@ static void P_DoJumpStuff(player_t *player, ticcmd_t *cmd) case SH_ATTRACT: player->pflags |= PF_THOKKED|PF_SHIELDABILITY; player->homing = 2; + player->secondjump = 0; P_SetTarget(&player->mo->target, P_SetTarget(&player->mo->tracer, lockonshield)); if (lockonshield) { @@ -5484,6 +5485,8 @@ static void P_DoJumpStuff(player_t *player, ticcmd_t *cmd) { if (!P_HomingAttack(player->mo, player->mo->tracer)) { + player->pflags &= ~PF_SHIELDABILITY; + player->secondjump = UINT8_MAX; P_SetObjectMomZ(player->mo, 6*FRACUNIT, false); if (player->mo->eflags & MFE_UNDERWATER) player->mo->momz = FixedMul(player->mo->momz, FRACUNIT/3); From d5beae97382027750992d6a18615cab49b9020f0 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Tue, 8 Sep 2020 18:08:08 +0100 Subject: [PATCH 0084/1080] Begin work on adding access to polyobjects in Lua: * create new file lua_polyobjlib.c * made a stub LUA_PolyObjLib function * added META_POLYOBJ to lua_libs.h * updated makefile, CMake and MSVC project files for lua_polyobjlib.c --- src/CMakeLists.txt | 1 + src/blua/Makefile.cfg | 1 + src/lua_libs.h | 3 +++ src/lua_polyobjlib.c | 22 ++++++++++++++++++++++ src/lua_script.c | 1 + src/sdl/Srb2SDL-vc10.vcxproj | 1 + src/sdl/Srb2SDL-vc10.vcxproj.filters | 3 +++ 7 files changed, 32 insertions(+) create mode 100644 src/lua_polyobjlib.c diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 6e3da126b..0eb13c690 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -261,6 +261,7 @@ set(SRB2_LUA_SOURCES lua_mathlib.c lua_mobjlib.c lua_playerlib.c + lua_polyobjlib.c lua_script.c lua_skinlib.c lua_thinkerlib.c diff --git a/src/blua/Makefile.cfg b/src/blua/Makefile.cfg index 12ea064b4..eae95ba3a 100644 --- a/src/blua/Makefile.cfg +++ b/src/blua/Makefile.cfg @@ -47,5 +47,6 @@ OBJS:=$(OBJS) \ $(OBJDIR)/lua_skinlib.o \ $(OBJDIR)/lua_thinkerlib.o \ $(OBJDIR)/lua_maplib.o \ + $(OBJDIR)/lua_polyobjlib.o \ $(OBJDIR)/lua_blockmaplib.o \ $(OBJDIR)/lua_hudlib.o diff --git a/src/lua_libs.h b/src/lua_libs.h index f987c79fd..b25e18a47 100644 --- a/src/lua_libs.h +++ b/src/lua_libs.h @@ -50,6 +50,8 @@ extern lua_State *gL; #define META_VECTOR3 "VECTOR3_T" #define META_MAPHEADER "MAPHEADER_T*" +#define META_POLYOBJ "POLYOBJ_T*" + #define META_CVAR "CONSVAR_T*" #define META_SECTORLINES "SECTOR_T*LINES" @@ -88,5 +90,6 @@ int LUA_PlayerLib(lua_State *L); int LUA_SkinLib(lua_State *L); int LUA_ThinkerLib(lua_State *L); int LUA_MapLib(lua_State *L); +int LUA_PolyObjLib(lua_State *L); int LUA_BlockmapLib(lua_State *L); int LUA_HudLib(lua_State *L); diff --git a/src/lua_polyobjlib.c b/src/lua_polyobjlib.c new file mode 100644 index 000000000..682288258 --- /dev/null +++ b/src/lua_polyobjlib.c @@ -0,0 +1,22 @@ +// SONIC ROBO BLAST 2 +//----------------------------------------------------------------------------- +// Copyright (C) 2020 by Iestyn "Monster Iestyn" Jealous. +// Copyright (C) 2016-2020 by Sonic Team Junior. +// +// This program is free software distributed under the +// terms of the GNU General Public License, version 2. +// See the 'LICENSE' file for more details. +//----------------------------------------------------------------------------- +/// \file lua_polyobjlib.c +/// \brief polyobject library for Lua scripting + +#include "doomdef.h" +#include "p_local.h" +#include "p_polyobj.h" +#include "lua_script.h" +#include "lua_libs.h" + +int LUA_PolyObjLib(lua_State *L) +{ + return 0; +} diff --git a/src/lua_script.c b/src/lua_script.c index 0260f018a..9562c89d2 100644 --- a/src/lua_script.c +++ b/src/lua_script.c @@ -50,6 +50,7 @@ static lua_CFunction liblist[] = { LUA_SkinLib, // skin_t, skins[] LUA_ThinkerLib, // thinker_t LUA_MapLib, // line_t, side_t, sector_t, subsector_t + LUA_PolyObjLib, // polyobj_t LUA_BlockmapLib, // blockmap stuff LUA_HudLib, // HUD stuff NULL diff --git a/src/sdl/Srb2SDL-vc10.vcxproj b/src/sdl/Srb2SDL-vc10.vcxproj index c6cef56de..43aa003b9 100644 --- a/src/sdl/Srb2SDL-vc10.vcxproj +++ b/src/sdl/Srb2SDL-vc10.vcxproj @@ -400,6 +400,7 @@ + diff --git a/src/sdl/Srb2SDL-vc10.vcxproj.filters b/src/sdl/Srb2SDL-vc10.vcxproj.filters index 04a1b5fa5..592b9f80c 100644 --- a/src/sdl/Srb2SDL-vc10.vcxproj.filters +++ b/src/sdl/Srb2SDL-vc10.vcxproj.filters @@ -720,6 +720,9 @@ LUA + + LUA + LUA From 05fe86ffdcbf0e33d72be1366645c00e0b2b33ad Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Tue, 8 Sep 2020 18:29:10 +0100 Subject: [PATCH 0085/1080] * started functions for accessing/editing META_POLYOBJ (bare minimum atm) * added the "PolyObjects" array as a global var, with index and len functions, as well as its own iterate function --- src/lua_polyobjlib.c | 108 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 107 insertions(+), 1 deletion(-) diff --git a/src/lua_polyobjlib.c b/src/lua_polyobjlib.c index 682288258..6778b4240 100644 --- a/src/lua_polyobjlib.c +++ b/src/lua_polyobjlib.c @@ -16,7 +16,113 @@ #include "lua_script.h" #include "lua_libs.h" -int LUA_PolyObjLib(lua_State *L) +enum polyobj_e { + polyobj_valid = 0, +}; +static const char *const polyobj_opt[] = { + "valid", + NULL}; + +static int polyobj_get(lua_State *L) { + polyobj_t *polyobj = *((polyobj_t **)luaL_checkudata(L, 1, META_POLYOBJ)); + enum polyobj_e field = luaL_checkoption(L, 2, NULL, polyobj_opt); + + if (!polyobj) { + if (field == polyobj_valid) { + lua_pushboolean(L, false); + return 1; + } + return LUA_ErrInvalid(L, "polyobj_t"); + } + + switch (field) + { + case polyobj_valid: + lua_pushboolean(L, true); + break; + } + return 1; +}; + +static int polyobj_set(lua_State *L) +{ + return luaL_error(L, LUA_QL("polyobj_t") " struct cannot be edited by Lua."); // this is just temporary +} + +static int lib_iteratePolyObjects(lua_State *L) +{ + INT32 i = -1; + if (lua_gettop(L) < 2) + { + //return luaL_error(L, "Don't call PolyObjects.iterate() directly, use it as 'for polyobj in PolyObjects.iterate do end'."); + lua_pushcfunction(L, lib_iteratePolyObjects); + return 1; + } + lua_settop(L, 2); + lua_remove(L, 1); // state is unused. + if (!lua_isnil(L, 1)) + i = (INT32)(*((polyobj_t **)luaL_checkudata(L, 1, META_POLYOBJ)) - PolyObjects); + for (i++; i < numPolyObjects; i++) + { + LUA_PushUserdata(L, &PolyObjects[i], META_POLYOBJ); + return 1; + } + return 0; +} + +static int lib_getPolyObject(lua_State *L) +{ + const char *field; + INT32 i; + + // find PolyObject by number + if (lua_type(L, 2) == LUA_TNUMBER) + { + i = luaL_checkinteger(L, 2); + if (i < 0 || i >= numPolyObjects) + return luaL_error(L, "PolyObjects[] index %d out of range (0 - %d)", i, numPolyObjects-1); + LUA_PushUserdata(L, &PolyObjects[i], META_POLYOBJ); + return 1; + } + + field = luaL_checkstring(L, 2); + // special function iterate + if (fastcmp(field,"iterate")) + { + lua_pushcfunction(L, lib_iteratePolyObjects); + return 1; + } + return 0; +} + +static int lib_numPolyObjects(lua_State *L) +{ + lua_pushinteger(L, numPolyObjects); + return 1; +} + +int LUA_PolyObjLib(lua_State *L) +{ + luaL_newmetatable(L, META_POLYOBJ); + lua_pushcfunction(L, polyobj_get); + lua_setfield(L, -2, "__index"); + + lua_pushcfunction(L, polyobj_set); + lua_setfield(L, -2, "__newindex"); + + //lua_pushcfunction(L, polyobj_num); + //lua_setfield(L, -2, "__len"); + lua_pop(L,1); + + lua_newuserdata(L, 0); + lua_createtable(L, 0, 2); + lua_pushcfunction(L, lib_getPolyObject); + lua_setfield(L, -2, "__index"); + + lua_pushcfunction(L, lib_numPolyObjects); + lua_setfield(L, -2, "__len"); + lua_setmetatable(L, -2); + lua_setglobal(L, "PolyObjects"); return 0; } From 0bc7eb32e9df89719ecc5004d9b060ded31b663c Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Tue, 8 Sep 2020 18:55:16 +0100 Subject: [PATCH 0086/1080] make sure to include fastcmp.h, whoops --- src/lua_polyobjlib.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/lua_polyobjlib.c b/src/lua_polyobjlib.c index 6778b4240..9adaf1270 100644 --- a/src/lua_polyobjlib.c +++ b/src/lua_polyobjlib.c @@ -11,6 +11,7 @@ /// \brief polyobject library for Lua scripting #include "doomdef.h" +#include "fastcmp.h" #include "p_local.h" #include "p_polyobj.h" #include "lua_script.h" From 60b49b5ecd9a8aa5c41eab65914bfba45bee0193 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Tue, 8 Sep 2020 18:56:00 +0100 Subject: [PATCH 0087/1080] Fix STJr copyright years, this file was obviously only created today, not 4 years ago! --- src/lua_polyobjlib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lua_polyobjlib.c b/src/lua_polyobjlib.c index 9adaf1270..2fef43e76 100644 --- a/src/lua_polyobjlib.c +++ b/src/lua_polyobjlib.c @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 2020 by Iestyn "Monster Iestyn" Jealous. -// Copyright (C) 2016-2020 by Sonic Team Junior. +// Copyright (C) 2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. From 33c96ab1aa1f84750dd0abaaf6082535584a5a80 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Tue, 8 Sep 2020 21:42:51 +0100 Subject: [PATCH 0088/1080] * added access to id, parent, angle, damage, thrust, flags in polyobj_t * #polyobj now returns the index id for the polyobj in PolyObjects * Polyobj_GetForNum is implemented in Lua as PolyObjects.GetForNum() --- src/lua_polyobjlib.c | 62 +++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 59 insertions(+), 3 deletions(-) diff --git a/src/lua_polyobjlib.c b/src/lua_polyobjlib.c index 2fef43e76..ab1467265 100644 --- a/src/lua_polyobjlib.c +++ b/src/lua_polyobjlib.c @@ -19,9 +19,21 @@ enum polyobj_e { polyobj_valid = 0, + polyobj_id, + polyobj_parent, + polyobj_angle, + polyobj_damage, + polyobj_thrust, + polyobj_flags }; static const char *const polyobj_opt[] = { "valid", + "id", + "parent", + "angle", + "damage", + "thrust", + "flags", NULL}; static int polyobj_get(lua_State *L) @@ -42,15 +54,42 @@ static int polyobj_get(lua_State *L) case polyobj_valid: lua_pushboolean(L, true); break; + case polyobj_id: + lua_pushinteger(L, polyobj->id); + break; + case polyobj_parent: + lua_pushinteger(L, polyobj->parent); + break; + case polyobj_angle: + lua_pushangle(L, polyobj->angle); + break; + case polyobj_damage: + lua_pushinteger(L, polyobj->damage); + break; + case polyobj_thrust: + lua_pushfixed(L, polyobj->thrust); + break; + case polyobj_flags: + lua_pushinteger(L, polyobj->flags); + break; } return 1; -}; +} static int polyobj_set(lua_State *L) { return luaL_error(L, LUA_QL("polyobj_t") " struct cannot be edited by Lua."); // this is just temporary } +static int polyobj_num(lua_State *L) +{ + polyobj_t *polyobj = *((polyobj_t **)luaL_checkudata(L, 1, META_POLYOBJ)); + if (!polyobj) + return luaL_error(L, "accessed polyobj_t doesn't exist anymore."); + lua_pushinteger(L, polyobj-PolyObjects); + return 1; +} + static int lib_iteratePolyObjects(lua_State *L) { INT32 i = -1; @@ -72,6 +111,17 @@ static int lib_iteratePolyObjects(lua_State *L) return 0; } +static int lib_PolyObject_getfornum(lua_State *L) +{ + INT32 id = (INT32)luaL_checkinteger(L, 1); + + if (!numPolyObjects) + return 0; // if there's no PolyObjects then bail out here + + LUA_PushUserdata(L, Polyobj_GetForNum(id), META_POLYOBJ); + return 1; +} + static int lib_getPolyObject(lua_State *L) { const char *field; @@ -94,6 +144,12 @@ static int lib_getPolyObject(lua_State *L) lua_pushcfunction(L, lib_iteratePolyObjects); return 1; } + // find PolyObject by ID + else if (fastcmp(field,"GetForNum")) // name could probably be better + { + lua_pushcfunction(L, lib_PolyObject_getfornum); + return 1; + } return 0; } @@ -112,8 +168,8 @@ int LUA_PolyObjLib(lua_State *L) lua_pushcfunction(L, polyobj_set); lua_setfield(L, -2, "__newindex"); - //lua_pushcfunction(L, polyobj_num); - //lua_setfield(L, -2, "__len"); + lua_pushcfunction(L, polyobj_num); + lua_setfield(L, -2, "__len"); lua_pop(L,1); lua_newuserdata(L, 0); From 5fc58de94f77963c6905f26c3b096dd186192817 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Tue, 8 Sep 2020 22:10:11 +0100 Subject: [PATCH 0089/1080] * added access to translucency and triggertag in polyobj_t * added POF_ flags to INT_CONST in dehacked.c --- src/dehacked.c | 19 +++++++++++++++++++ src/lua_polyobjlib.c | 12 +++++++++++- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/src/dehacked.c b/src/dehacked.c index 4c7ffaa96..5be7dbbc9 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -9906,6 +9906,25 @@ struct { {"FF_COLORMAPONLY",FF_COLORMAPONLY}, ///< Only copy the colormap, not the lightlevel {"FF_GOOWATER",FF_GOOWATER}, ///< Used with ::FF_SWIMMABLE. Makes thick bouncey goop. + // PolyObject flags + {"POF_CLIPLINES",POF_CLIPLINES}, ///< Test against lines for collision + {"POF_CLIPPLANES",POF_CLIPPLANES}, ///< Test against tops and bottoms for collision + {"POF_SOLID",POF_SOLID}, ///< Clips things. + {"POF_TESTHEIGHT",POF_TESTHEIGHT}, ///< Test line collision with heights + {"POF_RENDERSIDES",POF_RENDERSIDES}, ///< Renders the sides. + {"POF_RENDERTOP",POF_RENDERTOP}, ///< Renders the top. + {"POF_RENDERBOTTOM",POF_RENDERBOTTOM}, ///< Renders the bottom. + {"POF_RENDERPLANES",POF_RENDERPLANES}, ///< Renders top and bottom. + {"POF_RENDERALL",POF_RENDERALL}, ///< Renders everything. + {"POF_INVERT",POF_INVERT}, ///< Inverts collision (like a cage). + {"POF_INVERTPLANES",POF_INVERTPLANES}, ///< Render inside planes. + {"POF_INVERTPLANESONLY",POF_INVERTPLANESONLY}, ///< Only render inside planes. + {"POF_PUSHABLESTOP",POF_PUSHABLESTOP}, ///< Pushables will stop movement. + {"POF_LDEXEC",POF_LDEXEC}, ///< This PO triggers a linedef executor. + {"POF_ONESIDE",POF_ONESIDE}, ///< Only use the first side of the linedef. + {"POF_NOSPECIALS",POF_NOSPECIALS}, ///< Don't apply sector specials. + {"POF_SPLAT",POF_SPLAT}, ///< Use splat flat renderer (treat cyan pixels as invisible). + #ifdef HAVE_LUA_SEGS // Node flags {"NF_SUBSECTOR",NF_SUBSECTOR}, // Indicate a leaf. diff --git a/src/lua_polyobjlib.c b/src/lua_polyobjlib.c index ab1467265..85cb8fc69 100644 --- a/src/lua_polyobjlib.c +++ b/src/lua_polyobjlib.c @@ -24,7 +24,9 @@ enum polyobj_e { polyobj_angle, polyobj_damage, polyobj_thrust, - polyobj_flags + polyobj_flags, + polyobj_translucency, + polyobj_triggertag }; static const char *const polyobj_opt[] = { "valid", @@ -34,6 +36,8 @@ static const char *const polyobj_opt[] = { "damage", "thrust", "flags", + "translucency", + "triggertag", NULL}; static int polyobj_get(lua_State *L) @@ -72,6 +76,12 @@ static int polyobj_get(lua_State *L) case polyobj_flags: lua_pushinteger(L, polyobj->flags); break; + case polyobj_translucency: + lua_pushinteger(L, polyobj->translucency); + break; + case polyobj_triggertag: + lua_pushinteger(L, polyobj->triggertag); + break; } return 1; } From 625aeb1560ae60a55129be647e67ec00eff56d2e Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Wed, 9 Sep 2020 16:09:08 +0100 Subject: [PATCH 0090/1080] lua_script.c fixes: * make sure polyobj_t userdata is invalidated at level load * add support for syncing polyobj_t Lua variables in netgames --- src/lua_script.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/lua_script.c b/src/lua_script.c index 9562c89d2..f94a88473 100644 --- a/src/lua_script.c +++ b/src/lua_script.c @@ -24,6 +24,7 @@ #include "p_saveg.h" #include "p_local.h" #include "p_slopes.h" // for P_SlopeById +#include "p_polyobj.h" // polyobj_t, PolyObjects #ifdef LUA_ALLOW_BYTECODE #include "d_netfil.h" // for LUA_DumpFile #endif @@ -775,6 +776,8 @@ void LUA_InvalidateLevel(void) LUA_InvalidateUserdata(&sides[i]); for (i = 0; i < numvertexes; i++) LUA_InvalidateUserdata(&vertexes[i]); + for (i = 0; i < (size_t)numPolyObjects; i++) + LUA_InvalidateUserdata(&PolyObjects[i]); #ifdef HAVE_LUA_SEGS for (i = 0; i < numsegs; i++) LUA_InvalidateUserdata(&segs[i]); @@ -833,6 +836,7 @@ enum ARCH_NODE, #endif ARCH_FFLOOR, + ARCH_POLYOBJ, ARCH_SLOPE, ARCH_MAPHEADER, ARCH_SKINCOLOR, @@ -859,6 +863,7 @@ static const struct { {META_NODE, ARCH_NODE}, #endif {META_FFLOOR, ARCH_FFLOOR}, + {META_POLYOBJ, ARCH_POLYOBJ}, {META_SLOPE, ARCH_SLOPE}, {META_MAPHEADER, ARCH_MAPHEADER}, {META_SKINCOLOR, ARCH_SKINCOLOR}, @@ -1127,6 +1132,17 @@ static UINT8 ArchiveValue(int TABLESINDEX, int myindex) } break; } + case ARCH_POLYOBJ: + { + polyobj_t *polyobj = *((polyobj_t **)lua_touserdata(gL, myindex)); + if (!polyobj) + WRITEUINT8(save_p, ARCH_NULL); + else { + WRITEUINT8(save_p, ARCH_POLYOBJ); + WRITEUINT16(save_p, polyobj-PolyObjects); + } + break; + } case ARCH_SLOPE: { pslope_t *slope = *((pslope_t **)lua_touserdata(gL, myindex)); @@ -1382,6 +1398,9 @@ static UINT8 UnArchiveValue(int TABLESINDEX) LUA_PushUserdata(gL, rover, META_FFLOOR); break; } + case ARCH_POLYOBJ: + LUA_PushUserdata(gL, &PolyObjects[READUINT16(save_p)], META_POLYOBJ); + break; case ARCH_SLOPE: LUA_PushUserdata(gL, P_SlopeById(READUINT16(save_p)), META_SLOPE); break; From e6136eb113fd4a231b989a8e15626d0fc16af92a Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Wed, 9 Sep 2020 16:56:48 +0100 Subject: [PATCH 0091/1080] lua_blockmaplib.c: added "polyobjs" option to searchBlockmap function also updated my copyright years in this file B) --- src/lua_blockmaplib.c | 56 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 55 insertions(+), 1 deletion(-) diff --git a/src/lua_blockmaplib.c b/src/lua_blockmaplib.c index 5aae73284..1949d56bb 100644 --- a/src/lua_blockmaplib.c +++ b/src/lua_blockmaplib.c @@ -1,6 +1,6 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- -// Copyright (C) 2016 by Iestyn "Monster Iestyn" Jealous. +// Copyright (C) 2016-2020 by Iestyn "Monster Iestyn" Jealous. // Copyright (C) 2016-2020 by Sonic Team Junior. // // This program is free software distributed under the @@ -13,6 +13,7 @@ #include "doomdef.h" #include "p_local.h" #include "r_main.h" // validcount +#include "p_polyobj.h" #include "lua_script.h" #include "lua_libs.h" //#include "lua_hud.h" // hud_running errors @@ -20,6 +21,7 @@ static const char *const search_opt[] = { "objects", "lines", + "polyobjs", NULL}; // a quickly-made function pointer typedef used by lib_searchBlockmap... @@ -167,6 +169,55 @@ static UINT8 lib_searchBlockmap_Lines(lua_State *L, INT32 x, INT32 y, mobj_t *th return 0; // Everything was checked. } +// Helper function for "polyobjs" search +static UINT8 lib_searchBlockmap_PolyObjs(lua_State *L, INT32 x, INT32 y, mobj_t *thing) +{ + INT32 offset; + polymaplink_t *plink; // haleyjd 02/22/06 + + if (x < 0 || y < 0 || x >= bmapwidth || y >= bmapheight) + return 0; + + offset = y*bmapwidth + x; + + // haleyjd 02/22/06: consider polyobject lines + plink = polyblocklinks[offset]; + + while (plink) + { + polyobj_t *po = plink->po; + + if (po->validcount != validcount) // if polyobj hasn't been checked + { + po->validcount = validcount; + + lua_pushvalue(L, 1); + LUA_PushUserdata(L, thing, META_MOBJ); + LUA_PushUserdata(L, po, META_POLYOBJ); + if (lua_pcall(gL, 2, 1, 0)) { + if (!blockfuncerror || cv_debug & DBG_LUA) + CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); + lua_pop(gL, 1); + blockfuncerror = true; + return 0; // *shrugs* + } + if (!lua_isnil(gL, -1)) + { // if nil, continue + if (lua_toboolean(gL, -1)) + return 2; // stop whole search + else + return 1; // stop block search + } + lua_pop(gL, 1); + if (P_MobjWasRemoved(thing)) + return 2; + } + plink = (polymaplink_t *)(plink->link.next); + } + + return 0; // Everything was checked. +} + // The searchBlockmap function // arguments: searchBlockmap(searchtype, function, mobj, [x1, x2, y1, y2]) // return value: @@ -195,6 +246,9 @@ static int lib_searchBlockmap(lua_State *L) case 1: // "lines" searchFunc = lib_searchBlockmap_Lines; break; + case 2: // "polyobjs" + searchFunc = lib_searchBlockmap_PolyObjs; + break; } // the mobj we are searching around, the "calling" mobj we could say From 89e989d6b12ebdab714a7e9323e6fb14062470bd Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Wed, 9 Sep 2020 17:06:36 +0100 Subject: [PATCH 0092/1080] added "sector" as a Lua-exclusive shortcut to polyobj->lines[0]->backsector in polyobj_t --- src/lua_polyobjlib.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/lua_polyobjlib.c b/src/lua_polyobjlib.c index 85cb8fc69..4b583be26 100644 --- a/src/lua_polyobjlib.c +++ b/src/lua_polyobjlib.c @@ -21,6 +21,7 @@ enum polyobj_e { polyobj_valid = 0, polyobj_id, polyobj_parent, + polyobj_sector, polyobj_angle, polyobj_damage, polyobj_thrust, @@ -32,6 +33,7 @@ static const char *const polyobj_opt[] = { "valid", "id", "parent", + "sector", "angle", "damage", "thrust", @@ -64,6 +66,9 @@ static int polyobj_get(lua_State *L) case polyobj_parent: lua_pushinteger(L, polyobj->parent); break; + case polyobj_sector: // shortcut that exists only in Lua! + LUA_PushUserdata(L, polyobj->lines[0]->backsector, META_SECTOR); + break; case polyobj_angle: lua_pushangle(L, polyobj->angle); break; From 5f9183370125fcefbd4d70aeac709d45aa8136d5 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Wed, 9 Sep 2020 17:31:44 +0100 Subject: [PATCH 0093/1080] lua_maplib.c changes now that polyobj_t is supported: * added line.polyobj for line_t * added subsector.polyList iteration function, for iterating polyobjs in a subsector * added seg.polyseg for seg_t, in case we ever reenable support for segs/nodes --- src/lua_maplib.c | 59 +++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 56 insertions(+), 3 deletions(-) diff --git a/src/lua_maplib.c b/src/lua_maplib.c index 216818d29..6c83a16c5 100644 --- a/src/lua_maplib.c +++ b/src/lua_maplib.c @@ -16,6 +16,7 @@ #include "p_setup.h" #include "z_zone.h" #include "p_slopes.h" +#include "p_polyobj.h" #include "r_main.h" #include "lua_script.h" @@ -67,6 +68,7 @@ enum subsector_e { subsector_sector, subsector_numlines, subsector_firstline, + subsector_polyList }; static const char *const subsector_opt[] = { @@ -74,6 +76,7 @@ static const char *const subsector_opt[] = { "sector", "numlines", "firstline", + "polyList", NULL}; enum line_e { @@ -97,6 +100,7 @@ enum line_e { line_backsector, line_firsttag, line_nexttag, + line_polyobj, line_text, line_callcount }; @@ -122,6 +126,7 @@ static const char *const line_opt[] = { "backsector", "firsttag", "nexttag", + "polyobj", "text", "callcount", NULL}; @@ -222,6 +227,7 @@ enum seg_e { seg_linedef, seg_frontsector, seg_backsector, + seg_polyseg }; static const char *const seg_opt[] = { @@ -235,6 +241,7 @@ static const char *const seg_opt[] = { "linedef", "frontsector", "backsector", + "polyseg", NULL}; enum node_e { @@ -324,9 +331,9 @@ static const char *const vector_opt[] = { static const char *const array_opt[] ={"iterate",NULL}; static const char *const valid_opt[] ={"valid",NULL}; -/////////////////////////////////// -// sector list iterate functions // -/////////////////////////////////// +///////////////////////////////////////////// +// sector/subsector list iterate functions // +///////////////////////////////////////////// // iterates through a sector's thinglist! static int lib_iterateSectorThinglist(lua_State *L) @@ -398,6 +405,41 @@ static int lib_iterateSectorFFloors(lua_State *L) return 0; } +// iterates through a subsector's polyList! (for polyobj_t) +static int lib_iterateSubSectorPolylist(lua_State *L) +{ + polyobj_t *state = NULL; + polyobj_t *po = NULL; + + INLEVEL + + if (lua_gettop(L) < 2) + return luaL_error(L, "Don't call subsector.polyList() directly, use it as 'for polyobj in subsector.polyList do end'."); + + if (!lua_isnil(L, 1)) + state = *((polyobj_t **)luaL_checkudata(L, 1, META_POLYOBJ)); + else + return 0; // no polylist to iterate through sorry! + + lua_settop(L, 2); + lua_remove(L, 1); // remove state now. + + if (!lua_isnil(L, 1)) + { + po = *((polyobj_t **)luaL_checkudata(L, 1, META_POLYOBJ)); + po = (polyobj_t *)(po->link.next); + } + else + po = state; // state is used as the "start" of the polylist + + if (po) + { + LUA_PushUserdata(L, po, META_POLYOBJ); + return 1; + } + return 0; +} + static int sector_iterate(lua_State *L) { lua_pushvalue(L, lua_upvalueindex(1)); // iterator function, or the "generator" @@ -684,6 +726,11 @@ static int subsector_get(lua_State *L) case subsector_firstline: lua_pushinteger(L, subsector->firstline); return 1; + case subsector_polyList: // polyList + lua_pushcfunction(L, lib_iterateSubSectorPolylist); + LUA_PushUserdata(L, subsector->polyList, META_POLYOBJ); + lua_pushcclosure(L, sector_iterate, 2); // push lib_iterateSubSectorPolylist and subsector->polyList as upvalues for the function + return 1; } return 0; } @@ -827,6 +874,9 @@ static int line_get(lua_State *L) case line_nexttag: lua_pushinteger(L, line->nexttag); return 1; + case line_polyobj: + LUA_PushUserdata(L, line->polyobj, META_POLYOBJ); + return 1; case line_text: lua_pushstring(L, line->text); return 1; @@ -1089,6 +1139,9 @@ static int seg_get(lua_State *L) case seg_backsector: LUA_PushUserdata(L, seg->backsector, META_SECTOR); return 1; + case seg_polyseg: + LUA_PushUserdata(L, seg->polyseg, META_POLYOBJ); + return 1; } return 0; } From f86dad29791013969b5c43f913c94cece3285d0f Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Wed, 9 Sep 2020 18:09:32 +0100 Subject: [PATCH 0094/1080] Added new functions as variables of polyobj_t: * po.pointInside(po, x, y) as a wrapper for P_PointInsidePolyobj * po.mobjTouching(po, mo) as a wrapper for P_MobjTouchingPolyobj * po.mobjInside(po, mo) as a wrapper for P_MobjInsidePolyobj I can confirm that ":" syntax works with all the above, e.g. po:mobjInside(mo) --- src/lua_polyobjlib.c | 61 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 60 insertions(+), 1 deletion(-) diff --git a/src/lua_polyobjlib.c b/src/lua_polyobjlib.c index 4b583be26..605780d2f 100644 --- a/src/lua_polyobjlib.c +++ b/src/lua_polyobjlib.c @@ -18,6 +18,7 @@ #include "lua_libs.h" enum polyobj_e { + // properties polyobj_valid = 0, polyobj_id, polyobj_parent, @@ -27,9 +28,14 @@ enum polyobj_e { polyobj_thrust, polyobj_flags, polyobj_translucency, - polyobj_triggertag + polyobj_triggertag, + // special functions + polyobj_pointInside, + polyobj_mobjTouching, + polyobj_mobjInside }; static const char *const polyobj_opt[] = { + // properties "valid", "id", "parent", @@ -40,8 +46,50 @@ static const char *const polyobj_opt[] = { "flags", "translucency", "triggertag", + // special functions + "pointInside", + "mobjTouching", + "mobjInside", NULL}; +static int lib_polyobj_PointInside(lua_State *L) +{ + polyobj_t *po = *((polyobj_t **)luaL_checkudata(L, 1, META_POLYOBJ)); + fixed_t x = luaL_checkfixed(L, 2); + fixed_t y = luaL_checkfixed(L, 3); + INLEVEL + if (!po) + return LUA_ErrInvalid(L, "polyobj_t"); + lua_pushboolean(L, P_PointInsidePolyobj(po, x, y)); + return 1; +} + +static int lib_polyobj_MobjTouching(lua_State *L) +{ + polyobj_t *po = *((polyobj_t **)luaL_checkudata(L, 1, META_POLYOBJ)); + mobj_t *mo = *((mobj_t **)luaL_checkudata(L, 2, META_MOBJ)); + INLEVEL + if (!po) + return LUA_ErrInvalid(L, "polyobj_t"); + if (!mo) + return LUA_ErrInvalid(L, "mobj_t"); + lua_pushboolean(L, P_MobjTouchingPolyobj(po, mo)); + return 1; +} + +static int lib_polyobj_MobjInside(lua_State *L) +{ + polyobj_t *po = *((polyobj_t **)luaL_checkudata(L, 1, META_POLYOBJ)); + mobj_t *mo = *((mobj_t **)luaL_checkudata(L, 2, META_MOBJ)); + INLEVEL + if (!po) + return LUA_ErrInvalid(L, "polyobj_t"); + if (!mo) + return LUA_ErrInvalid(L, "mobj_t"); + lua_pushboolean(L, P_MobjInsidePolyobj(po, mo)); + return 1; +} + static int polyobj_get(lua_State *L) { polyobj_t *polyobj = *((polyobj_t **)luaL_checkudata(L, 1, META_POLYOBJ)); @@ -57,6 +105,7 @@ static int polyobj_get(lua_State *L) switch (field) { + // properties case polyobj_valid: lua_pushboolean(L, true); break; @@ -87,6 +136,16 @@ static int polyobj_get(lua_State *L) case polyobj_triggertag: lua_pushinteger(L, polyobj->triggertag); break; + // special functions + case polyobj_pointInside: + lua_pushcfunction(L, lib_polyobj_PointInside); + break; + case polyobj_mobjTouching: + lua_pushcfunction(L, lib_polyobj_MobjTouching); + break; + case polyobj_mobjInside: + lua_pushcfunction(L, lib_polyobj_MobjInside); + break; } return 1; } From 4ce161f9c30b302188fc6f405e873c2cadfe3239 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Wed, 9 Sep 2020 19:38:56 +0100 Subject: [PATCH 0095/1080] Added the functions Polyobj_moveXY and Polyobj_rotate to Lua as polyobj.moveXY and polyobj.rotate --- src/lua_polyobjlib.c | 55 ++++++++++++++++++++++++++++++++++++++++---- src/p_polyobj.c | 4 ++-- src/p_polyobj.h | 2 ++ 3 files changed, 55 insertions(+), 6 deletions(-) diff --git a/src/lua_polyobjlib.c b/src/lua_polyobjlib.c index 605780d2f..c43cac665 100644 --- a/src/lua_polyobjlib.c +++ b/src/lua_polyobjlib.c @@ -16,6 +16,10 @@ #include "p_polyobj.h" #include "lua_script.h" #include "lua_libs.h" +#include "lua_hud.h" // hud_running errors + +#define NOHUD if (hud_running)\ +return luaL_error(L, "HUD rendering code should not call this function!"); enum polyobj_e { // properties @@ -29,10 +33,13 @@ enum polyobj_e { polyobj_flags, polyobj_translucency, polyobj_triggertag, - // special functions + // special functions - utility polyobj_pointInside, polyobj_mobjTouching, - polyobj_mobjInside + polyobj_mobjInside, + // special functions - manipulation + polyobj_moveXY, + polyobj_rotate }; static const char *const polyobj_opt[] = { // properties @@ -46,12 +53,16 @@ static const char *const polyobj_opt[] = { "flags", "translucency", "triggertag", - // special functions + // special functions - utility "pointInside", "mobjTouching", "mobjInside", + // special functions - manipulation + "moveXY", + "rotate", NULL}; +// special functions - utility static int lib_polyobj_PointInside(lua_State *L) { polyobj_t *po = *((polyobj_t **)luaL_checkudata(L, 1, META_POLYOBJ)); @@ -90,6 +101,35 @@ static int lib_polyobj_MobjInside(lua_State *L) return 1; } +// special functions - manipulation +static int lib_polyobj_moveXY(lua_State *L) +{ + polyobj_t *po = *((polyobj_t **)luaL_checkudata(L, 1, META_POLYOBJ)); + fixed_t x = luaL_checkfixed(L, 2); + fixed_t y = luaL_checkfixed(L, 3); + boolean checkmobjs = lua_opttrueboolean(L, 4); + NOHUD + INLEVEL + if (!po) + return LUA_ErrInvalid(L, "polyobj_t"); + lua_pushboolean(L, Polyobj_moveXY(po, x, y, checkmobjs)); + return 1; +} + +static int lib_polyobj_rotate(lua_State *L) +{ + polyobj_t *po = *((polyobj_t **)luaL_checkudata(L, 1, META_POLYOBJ)); + angle_t delta = luaL_checkangle(L, 2); + UINT8 turnthings = (UINT8)luaL_optinteger(L, 3, 0); // don't turn anything by default? (could change this if not desired) + boolean checkmobjs = lua_opttrueboolean(L, 4); + NOHUD + INLEVEL + if (!po) + return LUA_ErrInvalid(L, "polyobj_t"); + lua_pushboolean(L, Polyobj_rotate(po, delta, turnthings, checkmobjs)); + return 1; +} + static int polyobj_get(lua_State *L) { polyobj_t *polyobj = *((polyobj_t **)luaL_checkudata(L, 1, META_POLYOBJ)); @@ -136,7 +176,7 @@ static int polyobj_get(lua_State *L) case polyobj_triggertag: lua_pushinteger(L, polyobj->triggertag); break; - // special functions + // special functions - utility case polyobj_pointInside: lua_pushcfunction(L, lib_polyobj_PointInside); break; @@ -146,6 +186,13 @@ static int polyobj_get(lua_State *L) case polyobj_mobjInside: lua_pushcfunction(L, lib_polyobj_MobjInside); break; + // special functions - manipulation + case polyobj_moveXY: + lua_pushcfunction(L, lib_polyobj_moveXY); + break; + case polyobj_rotate: + lua_pushcfunction(L, lib_polyobj_rotate); + break; } return 1; } diff --git a/src/p_polyobj.c b/src/p_polyobj.c index b0a794ddf..63d062c22 100644 --- a/src/p_polyobj.c +++ b/src/p_polyobj.c @@ -976,7 +976,7 @@ static INT32 Polyobj_clipThings(polyobj_t *po, line_t *line) // Moves a polyobject on the x-y plane. -static boolean Polyobj_moveXY(polyobj_t *po, fixed_t x, fixed_t y, boolean checkmobjs) +boolean Polyobj_moveXY(polyobj_t *po, fixed_t x, fixed_t y, boolean checkmobjs) { size_t i; vertex_t vec; @@ -1162,7 +1162,7 @@ static void Polyobj_rotateThings(polyobj_t *po, vector2_t origin, angle_t delta, } // Rotates a polyobject around its start point. -static boolean Polyobj_rotate(polyobj_t *po, angle_t delta, UINT8 turnthings, boolean checkmobjs) +boolean Polyobj_rotate(polyobj_t *po, angle_t delta, UINT8 turnthings, boolean checkmobjs) { size_t i; angle_t angle; diff --git a/src/p_polyobj.h b/src/p_polyobj.h index f24caca4e..8c2946965 100644 --- a/src/p_polyobj.h +++ b/src/p_polyobj.h @@ -336,6 +336,8 @@ typedef struct polyfadedata_s // Functions // +boolean Polyobj_moveXY(polyobj_t *po, fixed_t x, fixed_t y, boolean checkmobjs); +boolean Polyobj_rotate(polyobj_t *po, angle_t delta, UINT8 turnthings, boolean checkmobjs); polyobj_t *Polyobj_GetForNum(INT32 id); void Polyobj_InitLevel(void); void Polyobj_MoveOnLoad(polyobj_t *po, angle_t angle, fixed_t x, fixed_t y); From 78f799861870188c42058a5e0ead7ea6e1095a8e Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Wed, 9 Sep 2020 21:15:02 +0100 Subject: [PATCH 0096/1080] Added polyobj.vertices and polyobj.lines to Lua --- src/lua_libs.h | 2 + src/lua_polyobjlib.c | 154 +++++++++++++++++++++++++++++++++++++++++++ src/lua_script.c | 4 ++ 3 files changed, 160 insertions(+) diff --git a/src/lua_libs.h b/src/lua_libs.h index b25e18a47..03bd99cd2 100644 --- a/src/lua_libs.h +++ b/src/lua_libs.h @@ -60,6 +60,8 @@ extern lua_State *gL; #define META_LINESTRINGARGS "LINE_T*STRINGARGS" #define META_THINGARGS "MAPTHING_T*ARGS" #define META_THINGSTRINGARGS "MAPTHING_T*STRINGARGS" +#define META_POLYOBJVERTICES "POLYOBJ_T*VERTICES" +#define META_POLYOBJLINES "POLYOBJ_T*LINES" #ifdef HAVE_LUA_SEGS #define META_NODEBBOX "NODE_T*BBOX" #define META_NODECHILDREN "NODE_T*CHILDREN" diff --git a/src/lua_polyobjlib.c b/src/lua_polyobjlib.c index c43cac665..b0f22e74f 100644 --- a/src/lua_polyobjlib.c +++ b/src/lua_polyobjlib.c @@ -26,6 +26,8 @@ enum polyobj_e { polyobj_valid = 0, polyobj_id, polyobj_parent, + polyobj_vertices, + polyobj_lines, polyobj_sector, polyobj_angle, polyobj_damage, @@ -46,6 +48,8 @@ static const char *const polyobj_opt[] = { "valid", "id", "parent", + "vertices", + "lines", "sector", "angle", "damage", @@ -62,6 +66,126 @@ static const char *const polyobj_opt[] = { "rotate", NULL}; +static const char *const valid_opt[] ={"valid",NULL}; + +//////////////////////// +// polyobj.vertices[] // +//////////////////////// + +// polyobj.vertices, i -> polyobj.vertices[i] +// polyobj.vertices.valid, for validity checking +// +// see sectorlines_get in lua_maplib.c +// +static int polyobjvertices_get(lua_State *L) +{ + vertex_t ***polyverts = *((vertex_t ****)luaL_checkudata(L, 1, META_POLYOBJVERTICES)); + size_t i; + size_t numofverts = 0; + lua_settop(L, 2); + if (!lua_isnumber(L, 2)) + { + int field = luaL_checkoption(L, 2, NULL, valid_opt); + if (!polyverts || !(*polyverts)) + { + if (field == 0) { + lua_pushboolean(L, 0); + return 1; + } + return luaL_error(L, "accessed polyobj_t.vertices doesn't exist anymore."); + } else if (field == 0) { + lua_pushboolean(L, 1); + return 1; + } + } + + numofverts = (size_t)(*(size_t *)(((size_t)polyverts) - (offsetof(polyobj_t, vertices) - offsetof(polyobj_t, numVertices)))); + + if (!numofverts) + return luaL_error(L, "no vertices found!"); + + i = (size_t)lua_tointeger(L, 2); + if (i >= numofverts) + return 0; + LUA_PushUserdata(L, (*polyverts)[i], META_VERTEX); + return 1; +} + +// #(polyobj.vertices) -> polyobj.numVertices +static int polyobjvertices_num(lua_State *L) +{ + vertex_t ***polyverts = *((vertex_t ****)luaL_checkudata(L, 1, META_POLYOBJVERTICES)); + size_t numofverts = 0; + + if (!polyverts || !(*polyverts)) + return luaL_error(L, "accessed polyobj_t.vertices doesn't exist anymore."); + + numofverts = (size_t)(*(size_t *)(((size_t)polyverts) - (offsetof(polyobj_t, vertices) - offsetof(polyobj_t, numVertices)))); + lua_pushinteger(L, numofverts); + return 1; +} + +///////////////////// +// polyobj.lines[] // +///////////////////// + +// polyobj.lines, i -> polyobj.lines[i] +// polyobj.lines.valid, for validity checking +// +// see sectorlines_get in lua_maplib.c +// +static int polyobjlines_get(lua_State *L) +{ + line_t ***polylines = *((line_t ****)luaL_checkudata(L, 1, META_POLYOBJLINES)); + size_t i; + size_t numoflines = 0; + lua_settop(L, 2); + if (!lua_isnumber(L, 2)) + { + int field = luaL_checkoption(L, 2, NULL, valid_opt); + if (!polylines || !(*polylines)) + { + if (field == 0) { + lua_pushboolean(L, 0); + return 1; + } + return luaL_error(L, "accessed polyobj_t.lines doesn't exist anymore."); + } else if (field == 0) { + lua_pushboolean(L, 1); + return 1; + } + } + + numoflines = (size_t)(*(size_t *)(((size_t)polylines) - (offsetof(polyobj_t, lines) - offsetof(polyobj_t, numLines)))); + + if (!numoflines) + return luaL_error(L, "no lines found!"); + + i = (size_t)lua_tointeger(L, 2); + if (i >= numoflines) + return 0; + LUA_PushUserdata(L, (*polylines)[i], META_LINE); + return 1; +} + +// #(polyobj.lines) -> polyobj.numLines +static int polyobjlines_num(lua_State *L) +{ + line_t ***polylines = *((line_t ****)luaL_checkudata(L, 1, META_POLYOBJLINES)); + size_t numoflines = 0; + + if (!polylines || !(*polylines)) + return luaL_error(L, "accessed polyobj_t.lines doesn't exist anymore."); + + numoflines = (size_t)(*(size_t *)(((size_t)polylines) - (offsetof(polyobj_t, lines) - offsetof(polyobj_t, numLines)))); + lua_pushinteger(L, numoflines); + return 1; +} + +///////////////////////////////// +// polyobj_t function wrappers // +///////////////////////////////// + // special functions - utility static int lib_polyobj_PointInside(lua_State *L) { @@ -130,6 +254,10 @@ static int lib_polyobj_rotate(lua_State *L) return 1; } +/////////////// +// polyobj_t // +/////////////// + static int polyobj_get(lua_State *L) { polyobj_t *polyobj = *((polyobj_t **)luaL_checkudata(L, 1, META_POLYOBJ)); @@ -155,6 +283,12 @@ static int polyobj_get(lua_State *L) case polyobj_parent: lua_pushinteger(L, polyobj->parent); break; + case polyobj_vertices: // vertices + LUA_PushUserdata(L, &polyobj->vertices, META_POLYOBJVERTICES); // push the address of the "vertices" member in the struct, to allow our hacks to work + break; + case polyobj_lines: // lines + LUA_PushUserdata(L, &polyobj->lines, META_POLYOBJLINES); // push the address of the "lines" member in the struct, to allow our hacks to work + break; case polyobj_sector: // shortcut that exists only in Lua! LUA_PushUserdata(L, polyobj->lines[0]->backsector, META_SECTOR); break; @@ -211,6 +345,10 @@ static int polyobj_num(lua_State *L) return 1; } +/////////////////// +// PolyObjects[] // +/////////////////// + static int lib_iteratePolyObjects(lua_State *L) { INT32 i = -1; @@ -282,6 +420,22 @@ static int lib_numPolyObjects(lua_State *L) int LUA_PolyObjLib(lua_State *L) { + luaL_newmetatable(L, META_POLYOBJVERTICES); + lua_pushcfunction(L, polyobjvertices_get); + lua_setfield(L, -2, "__index"); + + lua_pushcfunction(L, polyobjvertices_num); + lua_setfield(L, -2, "__len"); + lua_pop(L, 1); + + luaL_newmetatable(L, META_POLYOBJLINES); + lua_pushcfunction(L, polyobjlines_get); + lua_setfield(L, -2, "__index"); + + lua_pushcfunction(L, polyobjlines_num); + lua_setfield(L, -2, "__len"); + lua_pop(L, 1); + luaL_newmetatable(L, META_POLYOBJ); lua_pushcfunction(L, polyobj_get); lua_setfield(L, -2, "__index"); diff --git a/src/lua_script.c b/src/lua_script.c index f94a88473..ae7f479f6 100644 --- a/src/lua_script.c +++ b/src/lua_script.c @@ -777,7 +777,11 @@ void LUA_InvalidateLevel(void) for (i = 0; i < numvertexes; i++) LUA_InvalidateUserdata(&vertexes[i]); for (i = 0; i < (size_t)numPolyObjects; i++) + { LUA_InvalidateUserdata(&PolyObjects[i]); + LUA_InvalidateUserdata(&PolyObjects[i].vertices); + LUA_InvalidateUserdata(&PolyObjects[i].lines); + } #ifdef HAVE_LUA_SEGS for (i = 0; i < numsegs; i++) LUA_InvalidateUserdata(&segs[i]); From 097986b1d9b1ec2247851d945f45e5b86427e756 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Wed, 9 Sep 2020 21:24:07 +0100 Subject: [PATCH 0097/1080] added polyobj_t to userdataType list (also added slope_t, vector2_t and vector3_t since they were all missing from here) --- src/lua_baselib.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 6b25e32ea..1b576eebb 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -170,8 +170,13 @@ static const struct { {META_SEG, "seg_t"}, {META_NODE, "node_t"}, #endif + {META_SLOPE, "slope_t"}, + {META_VECTOR2, "vector2_t"}, + {META_VECTOR3, "vector3_t"}, {META_MAPHEADER, "mapheader_t"}, + {META_POLYOBJ, "polyobj_t"}, + {META_CVAR, "consvar_t"}, {META_SECTORLINES, "sector_t.lines"}, From 782e559adfbfbab0f5ccca6168d0bba527f21165 Mon Sep 17 00:00:00 2001 From: Tatsuru <44866610+Ikkarin@users.noreply.github.com> Date: Sun, 13 Sep 2020 12:33:18 -0300 Subject: [PATCH 0098/1080] Check for sector_t userdata as well --- src/lua_baselib.c | 161 ++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 135 insertions(+), 26 deletions(-) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 6b25e32ea..1b1f4059d 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -2588,24 +2588,42 @@ static int lib_rGetNameByColor(lua_State *L) //////////// static int lib_sStartSound(lua_State *L) { - const void *origin = NULL; + void *origin = NULL; + const char *origtype; sfxenum_t sound_id = luaL_checkinteger(L, 2); player_t *player = NULL; //NOHUD + if (sound_id >= NUMSFX) return luaL_error(L, "sfx %d out of range (0 - %d)", sound_id, NUMSFX-1); - if (!lua_isnil(L, 1)) - { - origin = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); - if (!origin) - return LUA_ErrInvalid(L, "mobj_t"); - } + if (!lua_isnone(L, 3) && lua_isuserdata(L, 3)) { player = *((player_t **)luaL_checkudata(L, 3, META_PLAYER)); if (!player) return LUA_ErrInvalid(L, "player_t"); } + if (!lua_isnil(L, 1)) + { + lua_settop(L, 1); + + origtype = GetUserdataUType(L); + + if (fasticmp(origtype, "mobj_t")) + { + origin = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); + if (!origin) + return LUA_ErrInvalid(L, "mobj_t"); + } + else if (fasticmp(origtype, "sector_t")) + { + origin = *((sector_t **)luaL_checkudata(L, 1, META_SECTOR)); + if (!origin) + return LUA_ErrInvalid(L, "sector_t"); + } + else + return LUA_ErrInvalid(L, "mobj_t/sector_t"); + } if (!player || P_IsLocalPlayer(player)) { if (hud_running) @@ -2618,18 +2636,13 @@ static int lib_sStartSound(lua_State *L) static int lib_sStartSoundAtVolume(lua_State *L) { - const void *origin = NULL; + void *origin = NULL; + const char *origtype; sfxenum_t sound_id = luaL_checkinteger(L, 2); INT32 volume = (INT32)luaL_checkinteger(L, 3); player_t *player = NULL; //NOHUD - if (!lua_isnil(L, 1)) - { - origin = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); - if (!origin) - return LUA_ErrInvalid(L, "mobj_t"); - } if (sound_id >= NUMSFX) return luaL_error(L, "sfx %d out of range (0 - %d)", sound_id, NUMSFX-1); if (!lua_isnone(L, 4) && lua_isuserdata(L, 4)) @@ -2638,6 +2651,27 @@ static int lib_sStartSoundAtVolume(lua_State *L) if (!player) return LUA_ErrInvalid(L, "player_t"); } + if (!lua_isnil(L, 1)) + { + lua_settop(L, 1); + + origtype = GetUserdataUType(L); + + if (fasticmp(origtype, "mobj_t")) + { + origin = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); + if (!origin) + return LUA_ErrInvalid(L, "mobj_t"); + } + else if (fasticmp(origtype, "sector_t")) + { + origin = *((sector_t **)luaL_checkudata(L, 1, META_SECTOR)); + if (!origin) + return LUA_ErrInvalid(L, "sector_t"); + } + else + return LUA_ErrInvalid(L, "mobj_t/sector_t"); + } if (!player || P_IsLocalPlayer(player)) S_StartSoundAtVolume(origin, sound_id, volume); return 0; @@ -2645,23 +2679,60 @@ static int lib_sStartSoundAtVolume(lua_State *L) static int lib_sStopSound(lua_State *L) { - void *origin = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); + void *origin = NULL; + const char *origtype; //NOHUD - if (!origin) - return LUA_ErrInvalid(L, "mobj_t"); + origtype = GetUserdataUType(L); + + if (fasticmp(origtype, "mobj_t")) + { + origin = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); + if (!origin) + return LUA_ErrInvalid(L, "mobj_t"); + } + else if (fasticmp(origtype, "sector_t")) + { + origin = *((sector_t **)luaL_checkudata(L, 1, META_SECTOR)); + if (!origin) + return LUA_ErrInvalid(L, "sector_t"); + } + else + return LUA_ErrInvalid(L, "mobj_t/sector_t"); + S_StopSound(origin); return 0; } static int lib_sStopSoundByID(lua_State *L) { - void *origin = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); + void *origin = NULL; + const char *origtype; sfxenum_t sound_id = luaL_checkinteger(L, 2); //NOHUD - if (!origin) - return LUA_ErrInvalid(L, "mobj_t"); + if (sound_id >= NUMSFX) return luaL_error(L, "sfx %d out of range (0 - %d)", sound_id, NUMSFX-1); + if (!lua_isnil(L, 1)) + { + lua_settop(L, 1); + + origtype = GetUserdataUType(L); + + if (fasticmp(origtype, "mobj_t")) + { + origin = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); + if (!origin) + return LUA_ErrInvalid(L, "mobj_t"); + } + else if (fasticmp(origtype, "sector_t")) + { + origin = *((sector_t **)luaL_checkudata(L, 1, META_SECTOR)); + if (!origin) + return LUA_ErrInvalid(L, "sector_t"); + } + else + return LUA_ErrInvalid(L, "mobj_t/sector_t"); + } S_StopSoundByID(origin, sound_id); return 0; @@ -2887,11 +2958,28 @@ static int lib_sSetMusicPosition(lua_State *L) static int lib_sOriginPlaying(lua_State *L) { - void *origin = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); + void *origin = NULL; + const char *origtype; //NOHUD INLEVEL - if (!origin) - return LUA_ErrInvalid(L, "mobj_t"); + + origtype = GetUserdataUType(L); + + if (fasticmp(origtype, "mobj_t")) + { + origin = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); + if (!origin) + return LUA_ErrInvalid(L, "mobj_t"); + } + else if (fasticmp(origtype, "sector_t")) + { + origin = *((sector_t **)luaL_checkudata(L, 1, META_SECTOR)); + if (!origin) + return LUA_ErrInvalid(L, "sector_t"); + } + else + return LUA_ErrInvalid(L, "mobj_t/sector_t"); + lua_pushboolean(L, S_OriginPlaying(origin)); return 1; } @@ -2908,14 +2996,35 @@ static int lib_sIdPlaying(lua_State *L) static int lib_sSoundPlaying(lua_State *L) { - void *origin = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); + void *origin = NULL; + const char *origtype; sfxenum_t id = luaL_checkinteger(L, 2); //NOHUD INLEVEL - if (!origin) - return LUA_ErrInvalid(L, "mobj_t"); if (id >= NUMSFX) return luaL_error(L, "sfx %d out of range (0 - %d)", id, NUMSFX-1); + if (!lua_isnil(L, 1)) + { + lua_settop(L, 1); + + origtype = GetUserdataUType(L); + + if (fasticmp(origtype, "mobj_t")) + { + origin = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); + if (!origin) + return LUA_ErrInvalid(L, "mobj_t"); + } + else if (fasticmp(origtype, "sector_t")) + { + origin = *((sector_t **)luaL_checkudata(L, 1, META_SECTOR)); + if (!origin) + return LUA_ErrInvalid(L, "sector_t"); + } + else + return LUA_ErrInvalid(L, "mobj_t/sector_t"); + } + lua_pushboolean(L, S_SoundPlaying(origin, id)); return 1; } From 454682df70d364a4e69262888cb52fca23f88d01 Mon Sep 17 00:00:00 2001 From: Tatsuru <44866610+Ikkarin@users.noreply.github.com> Date: Sun, 13 Sep 2020 13:54:43 -0300 Subject: [PATCH 0099/1080] Use the sector's actual soundorg (how did it even work) --- src/lua_baselib.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 1b1f4059d..bc9c7b43e 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -2620,6 +2620,8 @@ static int lib_sStartSound(lua_State *L) origin = *((sector_t **)luaL_checkudata(L, 1, META_SECTOR)); if (!origin) return LUA_ErrInvalid(L, "sector_t"); + + origin = &((sector_t *)origin)->soundorg; } else return LUA_ErrInvalid(L, "mobj_t/sector_t"); @@ -2668,6 +2670,8 @@ static int lib_sStartSoundAtVolume(lua_State *L) origin = *((sector_t **)luaL_checkudata(L, 1, META_SECTOR)); if (!origin) return LUA_ErrInvalid(L, "sector_t"); + + origin = &((sector_t *)origin)->soundorg; } else return LUA_ErrInvalid(L, "mobj_t/sector_t"); @@ -2682,6 +2686,7 @@ static int lib_sStopSound(lua_State *L) void *origin = NULL; const char *origtype; //NOHUD + lua_settop(L, 1); origtype = GetUserdataUType(L); if (fasticmp(origtype, "mobj_t")) @@ -2695,6 +2700,8 @@ static int lib_sStopSound(lua_State *L) origin = *((sector_t **)luaL_checkudata(L, 1, META_SECTOR)); if (!origin) return LUA_ErrInvalid(L, "sector_t"); + + origin = &((sector_t *)origin)->soundorg; } else return LUA_ErrInvalid(L, "mobj_t/sector_t"); @@ -2729,6 +2736,8 @@ static int lib_sStopSoundByID(lua_State *L) origin = *((sector_t **)luaL_checkudata(L, 1, META_SECTOR)); if (!origin) return LUA_ErrInvalid(L, "sector_t"); + + origin = &((sector_t *)origin)->soundorg; } else return LUA_ErrInvalid(L, "mobj_t/sector_t"); @@ -2962,7 +2971,7 @@ static int lib_sOriginPlaying(lua_State *L) const char *origtype; //NOHUD INLEVEL - + lua_settop(L, 1); origtype = GetUserdataUType(L); if (fasticmp(origtype, "mobj_t")) @@ -2976,6 +2985,8 @@ static int lib_sOriginPlaying(lua_State *L) origin = *((sector_t **)luaL_checkudata(L, 1, META_SECTOR)); if (!origin) return LUA_ErrInvalid(L, "sector_t"); + + origin = &((sector_t *)origin)->soundorg; } else return LUA_ErrInvalid(L, "mobj_t/sector_t"); @@ -3020,6 +3031,8 @@ static int lib_sSoundPlaying(lua_State *L) origin = *((sector_t **)luaL_checkudata(L, 1, META_SECTOR)); if (!origin) return LUA_ErrInvalid(L, "sector_t"); + + origin = &((sector_t *)origin)->soundorg; } else return LUA_ErrInvalid(L, "mobj_t/sector_t"); From 8d65ce81c7416d7c53954582f19793da75794351 Mon Sep 17 00:00:00 2001 From: Tatsuru <44866610+Ikkarin@users.noreply.github.com> Date: Sun, 13 Sep 2020 14:30:02 -0300 Subject: [PATCH 0100/1080] Legacy moment --- src/s_sound.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/s_sound.c b/src/s_sound.c index 0442c6219..fc6ddb691 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -1043,7 +1043,6 @@ void S_ClearSfx(void) static void S_StopChannel(INT32 cnum) { - INT32 i; channel_t *c = &channels[cnum]; if (c->sfxinfo) @@ -1052,17 +1051,12 @@ 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; - // degrade usefulness of sound data c->sfxinfo->usefulness--; - c->sfxinfo = 0; } + + c->origin = NULL; } // From 0f2e063de018ab40502a438afcb52e791669a9f4 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Sun, 13 Sep 2020 21:38:16 +0100 Subject: [PATCH 0101/1080] Added the ability to modify parent, flags, translucency in polyobj_t (attempting to edit polyobj.angle just gives you an error message saying to use polyobj:rotate() instead) --- src/lua_polyobjlib.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/src/lua_polyobjlib.c b/src/lua_polyobjlib.c index b0f22e74f..c4dfa8ae4 100644 --- a/src/lua_polyobjlib.c +++ b/src/lua_polyobjlib.c @@ -333,7 +333,33 @@ static int polyobj_get(lua_State *L) static int polyobj_set(lua_State *L) { - return luaL_error(L, LUA_QL("polyobj_t") " struct cannot be edited by Lua."); // this is just temporary + polyobj_t *polyobj = *((polyobj_t **)luaL_checkudata(L, 1, META_POLYOBJ)); + enum polyobj_e field = luaL_checkoption(L, 2, NULL, polyobj_opt); + + if (!polyobj) + return LUA_ErrInvalid(L, "polyobj_t"); + + if (hud_running) + return luaL_error(L, "Do not alter polyobj_t in HUD rendering code!"); + + switch (field) + { + default: + return luaL_error(L, LUA_QL("polyobj_t") " field " LUA_QS " cannot be modified.", polyobj_opt[field]); + case polyobj_angle: + return luaL_error(L, LUA_QL("polyobj_t") " field " LUA_QS " should not be set directly. Use the function " LUA_QL("polyobj:rotate(angle)") " instead.", polyobj_opt[field]); + case polyobj_parent: + polyobj->parent = luaL_checkinteger(L, 3); + break; + case polyobj_flags: + polyobj->flags = luaL_checkinteger(L, 3); + break; + case polyobj_translucency: + polyobj->translucency = luaL_checkinteger(L, 3); + break; + } + + return 0; } static int polyobj_num(lua_State *L) From 013714a26f7f3150b1b2b63db42b3916721acb80 Mon Sep 17 00:00:00 2001 From: Tatsuru <44866610+Ikkarin@users.noreply.github.com> Date: Mon, 14 Sep 2020 17:33:15 -0300 Subject: [PATCH 0102/1080] Encapsulate userdata checks --- src/lua_baselib.c | 167 ++++++++++------------------------------------ 1 file changed, 37 insertions(+), 130 deletions(-) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index bc9c7b43e..47d685b1c 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -2586,10 +2586,36 @@ static int lib_rGetNameByColor(lua_State *L) // S_SOUND //////////// +static int GetValidSoundOrigin(lua_State *L, void **origin) +{ + const char *type; + + lua_settop(L, 1); + type = GetUserdataUType(L); + + if (fasticmp(type, "mobj_t")) + { + *origin = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); + if (!(*origin)) + return LUA_ErrInvalid(L, "mobj_t"); + return 1; + } + else if (fasticmp(type, "sector_t")) + { + *origin = *((sector_t **)luaL_checkudata(L, 1, META_SECTOR)); + if (!(*origin)) + return LUA_ErrInvalid(L, "sector_t"); + + *origin = &((sector_t *)(*origin))->soundorg; + return 1; + } + + return LUA_ErrInvalid(L, "mobj_t/sector_t"); +} + static int lib_sStartSound(lua_State *L) { void *origin = NULL; - const char *origtype; sfxenum_t sound_id = luaL_checkinteger(L, 2); player_t *player = NULL; //NOHUD @@ -2604,28 +2630,8 @@ static int lib_sStartSound(lua_State *L) return LUA_ErrInvalid(L, "player_t"); } if (!lua_isnil(L, 1)) - { - lua_settop(L, 1); - - origtype = GetUserdataUType(L); - - if (fasticmp(origtype, "mobj_t")) - { - origin = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); - if (!origin) - return LUA_ErrInvalid(L, "mobj_t"); - } - else if (fasticmp(origtype, "sector_t")) - { - origin = *((sector_t **)luaL_checkudata(L, 1, META_SECTOR)); - if (!origin) - return LUA_ErrInvalid(L, "sector_t"); - - origin = &((sector_t *)origin)->soundorg; - } - else - return LUA_ErrInvalid(L, "mobj_t/sector_t"); - } + if (!GetValidSoundOrigin(L, &origin)) + return 0; if (!player || P_IsLocalPlayer(player)) { if (hud_running) @@ -2639,7 +2645,6 @@ static int lib_sStartSound(lua_State *L) static int lib_sStartSoundAtVolume(lua_State *L) { void *origin = NULL; - const char *origtype; sfxenum_t sound_id = luaL_checkinteger(L, 2); INT32 volume = (INT32)luaL_checkinteger(L, 3); player_t *player = NULL; @@ -2654,56 +2659,19 @@ static int lib_sStartSoundAtVolume(lua_State *L) return LUA_ErrInvalid(L, "player_t"); } if (!lua_isnil(L, 1)) - { - lua_settop(L, 1); - - origtype = GetUserdataUType(L); - - if (fasticmp(origtype, "mobj_t")) - { - origin = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); - if (!origin) - return LUA_ErrInvalid(L, "mobj_t"); - } - else if (fasticmp(origtype, "sector_t")) - { - origin = *((sector_t **)luaL_checkudata(L, 1, META_SECTOR)); - if (!origin) - return LUA_ErrInvalid(L, "sector_t"); - - origin = &((sector_t *)origin)->soundorg; - } - else + if (!GetValidSoundOrigin(L, &origin)) return LUA_ErrInvalid(L, "mobj_t/sector_t"); - } + if (!player || P_IsLocalPlayer(player)) - S_StartSoundAtVolume(origin, sound_id, volume); + S_StartSoundAtVolume(origin, sound_id, volume); return 0; } static int lib_sStopSound(lua_State *L) { void *origin = NULL; - const char *origtype; //NOHUD - lua_settop(L, 1); - origtype = GetUserdataUType(L); - - if (fasticmp(origtype, "mobj_t")) - { - origin = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); - if (!origin) - return LUA_ErrInvalid(L, "mobj_t"); - } - else if (fasticmp(origtype, "sector_t")) - { - origin = *((sector_t **)luaL_checkudata(L, 1, META_SECTOR)); - if (!origin) - return LUA_ErrInvalid(L, "sector_t"); - - origin = &((sector_t *)origin)->soundorg; - } - else + if (!GetValidSoundOrigin(L, &origin)) return LUA_ErrInvalid(L, "mobj_t/sector_t"); S_StopSound(origin); @@ -2713,35 +2681,14 @@ static int lib_sStopSound(lua_State *L) static int lib_sStopSoundByID(lua_State *L) { void *origin = NULL; - const char *origtype; sfxenum_t sound_id = luaL_checkinteger(L, 2); //NOHUD if (sound_id >= NUMSFX) return luaL_error(L, "sfx %d out of range (0 - %d)", sound_id, NUMSFX-1); if (!lua_isnil(L, 1)) - { - lua_settop(L, 1); - - origtype = GetUserdataUType(L); - - if (fasticmp(origtype, "mobj_t")) - { - origin = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); - if (!origin) - return LUA_ErrInvalid(L, "mobj_t"); - } - else if (fasticmp(origtype, "sector_t")) - { - origin = *((sector_t **)luaL_checkudata(L, 1, META_SECTOR)); - if (!origin) - return LUA_ErrInvalid(L, "sector_t"); - - origin = &((sector_t *)origin)->soundorg; - } - else + if (!GetValidSoundOrigin(L, &origin)) return LUA_ErrInvalid(L, "mobj_t/sector_t"); - } S_StopSoundByID(origin, sound_id); return 0; @@ -2968,27 +2915,9 @@ static int lib_sSetMusicPosition(lua_State *L) static int lib_sOriginPlaying(lua_State *L) { void *origin = NULL; - const char *origtype; //NOHUD INLEVEL - lua_settop(L, 1); - origtype = GetUserdataUType(L); - - if (fasticmp(origtype, "mobj_t")) - { - origin = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); - if (!origin) - return LUA_ErrInvalid(L, "mobj_t"); - } - else if (fasticmp(origtype, "sector_t")) - { - origin = *((sector_t **)luaL_checkudata(L, 1, META_SECTOR)); - if (!origin) - return LUA_ErrInvalid(L, "sector_t"); - - origin = &((sector_t *)origin)->soundorg; - } - else + if (!GetValidSoundOrigin(L, &origin)) return LUA_ErrInvalid(L, "mobj_t/sector_t"); lua_pushboolean(L, S_OriginPlaying(origin)); @@ -3008,35 +2937,13 @@ static int lib_sIdPlaying(lua_State *L) static int lib_sSoundPlaying(lua_State *L) { void *origin = NULL; - const char *origtype; sfxenum_t id = luaL_checkinteger(L, 2); //NOHUD INLEVEL if (id >= NUMSFX) return luaL_error(L, "sfx %d out of range (0 - %d)", id, NUMSFX-1); - if (!lua_isnil(L, 1)) - { - lua_settop(L, 1); - - origtype = GetUserdataUType(L); - - if (fasticmp(origtype, "mobj_t")) - { - origin = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); - if (!origin) - return LUA_ErrInvalid(L, "mobj_t"); - } - else if (fasticmp(origtype, "sector_t")) - { - origin = *((sector_t **)luaL_checkudata(L, 1, META_SECTOR)); - if (!origin) - return LUA_ErrInvalid(L, "sector_t"); - - origin = &((sector_t *)origin)->soundorg; - } - else - return LUA_ErrInvalid(L, "mobj_t/sector_t"); - } + if (!GetValidSoundOrigin(L, &origin)) + return LUA_ErrInvalid(L, "mobj_t/sector_t"); lua_pushboolean(L, S_SoundPlaying(origin, id)); return 1; From 2bb5b42960255112dd6758f744b0d1e95ac8cd53 Mon Sep 17 00:00:00 2001 From: lachwright Date: Wed, 16 Sep 2020 16:50:10 +0930 Subject: [PATCH 0103/1080] Allow JumpSpin abilities to be used with non-ability shields --- src/p_user.c | 216 +++++++++++++++++++++++++++------------------------ 1 file changed, 115 insertions(+), 101 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index b8e7d1746..4d0252c63 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -5006,6 +5006,118 @@ static void P_DoTwinSpin(player_t *player) P_SetPlayerMobjState(player->mo, S_PLAY_TWINSPIN); } +// +// returns true if the player used a shield ability, false otherwise +// passing in the mobjs from P_DoJumpStuff is a bit hackily specific, but I don't care enough to make a more elaborate solution (I think that is more appropriately approached with a more general MT_LOCKON spawning system) +// +static boolean P_PlayerShieldThink(player_t *player, ticcmd_t *cmd, mobj_t *lockonthok, mobj_t *visual) +{ + mobj_t *lockonshield = NULL; + + if ((player->powers[pw_shield] & SH_NOSTACK) && !player->powers[pw_super] && !(player->pflags & PF_SPINDOWN) + && ((!(player->pflags & PF_THOKKED) || ((player->powers[pw_shield] & SH_NOSTACK) == SH_BUBBLEWRAP && player->secondjump == UINT8_MAX)))) // thokked is optional if you're bubblewrapped + { + if ((player->powers[pw_shield] & SH_NOSTACK) == SH_ATTRACT) + { + if ((lockonshield = P_LookForEnemies(player, false, false))) + { + if (P_IsLocalPlayer(player)) // Only display it on your own view. + { + boolean dovis = true; + if (lockonshield == lockonthok) + { + if (leveltime & 2) + dovis = false; + else if (visual) + P_RemoveMobj(visual); + } + if (dovis) + { + visual = P_SpawnMobj(lockonshield->x, lockonshield->y, lockonshield->z, MT_LOCKON); // positioning, flip handled in P_SceneryThinker + P_SetTarget(&visual->target, lockonshield); + P_SetMobjStateNF(visual, visual->info->spawnstate+1); + } + } + } + } + if (cmd->buttons & BT_SPIN && !LUAh_ShieldSpecial(player)) // Spin button effects + { + // Force stop + if ((player->powers[pw_shield] & ~(SH_FORCEHP|SH_STACK)) == SH_FORCE) + { + player->pflags |= PF_THOKKED|PF_SHIELDABILITY; + player->mo->momx = player->mo->momy = player->mo->momz = 0; + S_StartSound(player->mo, sfx_ngskid); + } + else + { + switch (player->powers[pw_shield] & SH_NOSTACK) + { + // Whirlwind jump/Thunder jump + case SH_WHIRLWIND: + case SH_THUNDERCOIN: + P_DoJumpShield(player); + break; + // Armageddon pow + case SH_ARMAGEDDON: + player->pflags |= PF_THOKKED|PF_SHIELDABILITY; + P_BlackOw(player); + break; + // Attraction blast + case SH_ATTRACT: + player->pflags |= PF_THOKKED|PF_SHIELDABILITY; + player->homing = 2; + P_SetTarget(&player->mo->target, P_SetTarget(&player->mo->tracer, lockonshield)); + if (lockonshield) + { + player->mo->angle = R_PointToAngle2(player->mo->x, player->mo->y, lockonshield->x, lockonshield->y); + player->pflags &= ~PF_NOJUMPDAMAGE; + P_SetPlayerMobjState(player->mo, S_PLAY_ROLL); + S_StartSound(player->mo, sfx_s3k40); + player->homing = 3*TICRATE; + } + else + S_StartSound(player->mo, sfx_s3ka6); + break; + // Elemental stomp/Bubble bounce + case SH_ELEMENTAL: + case SH_BUBBLEWRAP: + { + boolean elem = ((player->powers[pw_shield] & SH_NOSTACK) == SH_ELEMENTAL); + player->pflags |= PF_THOKKED|PF_SHIELDABILITY; + if (elem) + { + player->mo->momx = player->mo->momy = 0; + S_StartSound(player->mo, sfx_s3k43); + } + else + { + player->mo->momx -= (player->mo->momx/3); + player->mo->momy -= (player->mo->momy/3); + player->pflags &= ~PF_NOJUMPDAMAGE; + P_SetPlayerMobjState(player->mo, S_PLAY_ROLL); + S_StartSound(player->mo, sfx_s3k44); + } + player->secondjump = 0; + P_SetObjectMomZ(player->mo, -24*FRACUNIT, false); + break; + } + // Flame burst + case SH_FLAMEAURA: + player->pflags |= PF_THOKKED|PF_SHIELDABILITY; + P_Thrust(player->mo, player->mo->angle, FixedMul(30*FRACUNIT - FixedSqrt(FixedDiv(player->speed, player->mo->scale)), player->mo->scale)); + player->drawangle = player->mo->angle; + S_StartSound(player->mo, sfx_s3k43); + default: + break; + } + } + } + return player->pflags & PF_SHIELDABILITY; + } + return false; +} + // // P_DoJumpStuff // @@ -5013,7 +5125,7 @@ static void P_DoTwinSpin(player_t *player) // static void P_DoJumpStuff(player_t *player, ticcmd_t *cmd) { - mobj_t *lockonthok = NULL, *lockonshield = NULL, *visual = NULL; + mobj_t *lockonthok = NULL, *visual = NULL; if (player->pflags & PF_JUMPSTASIS) return; @@ -5040,106 +5152,8 @@ static void P_DoJumpStuff(player_t *player, ticcmd_t *cmd) ; else if (player->pflags & (PF_GLIDING|PF_SLIDING|PF_SHIELDABILITY)) // If the player has used an ability previously ; - else if ((player->powers[pw_shield] & SH_NOSTACK) && !player->powers[pw_super] && !(player->pflags & PF_SPINDOWN) - && ((!(player->pflags & PF_THOKKED) || ((player->powers[pw_shield] & SH_NOSTACK) == SH_BUBBLEWRAP && player->secondjump == UINT8_MAX)))) // thokked is optional if you're bubblewrapped - { - if ((player->powers[pw_shield] & SH_NOSTACK) == SH_ATTRACT) - { - if ((lockonshield = P_LookForEnemies(player, false, false))) - { - if (P_IsLocalPlayer(player)) // Only display it on your own view. - { - boolean dovis = true; - if (lockonshield == lockonthok) - { - if (leveltime & 2) - dovis = false; - else if (visual) - P_RemoveMobj(visual); - } - if (dovis) - { - visual = P_SpawnMobj(lockonshield->x, lockonshield->y, lockonshield->z, MT_LOCKON); // positioning, flip handled in P_SceneryThinker - P_SetTarget(&visual->target, lockonshield); - P_SetMobjStateNF(visual, visual->info->spawnstate+1); - } - } - } - } - if (cmd->buttons & BT_SPIN && !LUAh_ShieldSpecial(player)) // Spin button effects - { - // Force stop - if ((player->powers[pw_shield] & ~(SH_FORCEHP|SH_STACK)) == SH_FORCE) - { - player->pflags |= PF_THOKKED|PF_SHIELDABILITY; - player->mo->momx = player->mo->momy = player->mo->momz = 0; - S_StartSound(player->mo, sfx_ngskid); - } - else - { - switch (player->powers[pw_shield] & SH_NOSTACK) - { - // Whirlwind jump/Thunder jump - case SH_WHIRLWIND: - case SH_THUNDERCOIN: - P_DoJumpShield(player); - break; - // Armageddon pow - case SH_ARMAGEDDON: - player->pflags |= PF_THOKKED|PF_SHIELDABILITY; - P_BlackOw(player); - break; - // Attraction blast - case SH_ATTRACT: - player->pflags |= PF_THOKKED|PF_SHIELDABILITY; - player->homing = 2; - P_SetTarget(&player->mo->target, P_SetTarget(&player->mo->tracer, lockonshield)); - if (lockonshield) - { - player->mo->angle = R_PointToAngle2(player->mo->x, player->mo->y, lockonshield->x, lockonshield->y); - player->pflags &= ~PF_NOJUMPDAMAGE; - P_SetPlayerMobjState(player->mo, S_PLAY_ROLL); - S_StartSound(player->mo, sfx_s3k40); - player->homing = 3*TICRATE; - } - else - S_StartSound(player->mo, sfx_s3ka6); - break; - // Elemental stomp/Bubble bounce - case SH_ELEMENTAL: - case SH_BUBBLEWRAP: - { - boolean elem = ((player->powers[pw_shield] & SH_NOSTACK) == SH_ELEMENTAL); - player->pflags |= PF_THOKKED|PF_SHIELDABILITY; - if (elem) - { - player->mo->momx = player->mo->momy = 0; - S_StartSound(player->mo, sfx_s3k43); - } - else - { - player->mo->momx -= (player->mo->momx/3); - player->mo->momy -= (player->mo->momy/3); - player->pflags &= ~PF_NOJUMPDAMAGE; - P_SetPlayerMobjState(player->mo, S_PLAY_ROLL); - S_StartSound(player->mo, sfx_s3k44); - } - player->secondjump = 0; - P_SetObjectMomZ(player->mo, -24*FRACUNIT, false); - break; - } - // Flame burst - case SH_FLAMEAURA: - player->pflags |= PF_THOKKED|PF_SHIELDABILITY; - P_Thrust(player->mo, player->mo->angle, FixedMul(30*FRACUNIT - FixedSqrt(FixedDiv(player->speed, player->mo->scale)), player->mo->scale)); - player->drawangle = player->mo->angle; - S_StartSound(player->mo, sfx_s3k43); - default: - break; - } - } - } - } + else if (P_PlayerShieldThink(player, cmd, lockonthok, visual)) + ; else if ((cmd->buttons & BT_SPIN)) { if (!(player->pflags & PF_SPINDOWN) && P_SuperReady(player)) From 1447aba96429771337cf4915aaa250cbbabfa020 Mon Sep 17 00:00:00 2001 From: Riku Salminen <38985578+Riku-S@users.noreply.github.com> Date: Wed, 23 Sep 2020 21:26:51 +0300 Subject: [PATCH 0104/1080] Updated 16 bit momentum values to 32 bit in demos, changed demo version --- src/g_demo.c | 108 ++++++++++++++++++++++++++------------------------- 1 file changed, 56 insertions(+), 52 deletions(-) diff --git a/src/g_demo.c b/src/g_demo.c index 57a955cb1..c7460fa3c 100644 --- a/src/g_demo.c +++ b/src/g_demo.c @@ -94,7 +94,7 @@ demoghost *ghosts = NULL; // DEMO RECORDING // -#define DEMOVERSION 0x000d +#define DEMOVERSION 0x000e #define DEMOHEADER "\xF0" "SRB2Replay" "\x0F" #define DF_GHOST 0x01 // This demo contains ghost data too! @@ -346,31 +346,31 @@ void G_WriteGhostTic(mobj_t *ghost) { // For moving normally: // Store one full byte of movement, plus one byte of fractional movement. - INT16 momx = (INT16)((ghost->x-oldghost.x)>>8); - INT16 momy = (INT16)((ghost->y-oldghost.y)>>8); + fixed_t momx = ghost->x-oldghost.x; + fixed_t momy = ghost->y-oldghost.y; if (momx != oldghost.momx || momy != oldghost.momy) { oldghost.momx = momx; oldghost.momy = momy; ziptic |= GZT_MOMXY; - WRITEINT16(demo_p,momx); - WRITEINT16(demo_p,momy); + WRITEFIXED(demo_p,momx); + WRITEFIXED(demo_p,momy); } - momx = (INT16)((ghost->z-oldghost.z)>>8); + momx = ghost->z-oldghost.z; if (momx != oldghost.momz) { oldghost.momz = momx; ziptic |= GZT_MOMZ; - WRITEINT16(demo_p,momx); + WRITEFIXED(demo_p,momx); } // This SHOULD set oldghost.x/y/z to match ghost->x/y/z // but it keeps the fractional loss of one byte, // so it will hopefully be made up for in future tics. - oldghost.x += oldghost.momx<<8; - oldghost.y += oldghost.momy<<8; - oldghost.z += oldghost.momz<<8; + oldghost.x += oldghost.momx; + oldghost.y += oldghost.momy; + oldghost.z += oldghost.momz; } #undef MAXMOM @@ -464,7 +464,7 @@ void G_WriteGhostTic(mobj_t *ghost) if (ghost->player && ghost->player->followmobj && !(ghost->player->followmobj->sprite == SPR_NULL || (ghost->player->followmobj->flags2 & MF2_DONTDRAW))) // bloats tails runs but what can ya do { - INT16 temp; + fixed_t temp; UINT8 *followtic_p = demo_p++; UINT8 followtic = 0; @@ -492,12 +492,12 @@ void G_WriteGhostTic(mobj_t *ghost) WRITEFIXED(demo_p,ghost->player->followmobj->scale); } - temp = (INT16)((ghost->player->followmobj->x-ghost->x)>>8); - WRITEINT16(demo_p,temp); - temp = (INT16)((ghost->player->followmobj->y-ghost->y)>>8); - WRITEINT16(demo_p,temp); - temp = (INT16)((ghost->player->followmobj->z-ghost->z)>>8); - WRITEINT16(demo_p,temp); + temp = ghost->player->followmobj->x-ghost->x; + WRITEFIXED(demo_p,temp); + temp = ghost->player->followmobj->y-ghost->y; + WRITEFIXED(demo_p,temp); + temp = ghost->player->followmobj->z-ghost->z; + WRITEFIXED(demo_p,temp); if (followtic & FZT_SKIN) WRITEUINT8(demo_p,ghost->player->followmobj->sprite2); WRITEUINT16(demo_p,ghost->player->followmobj->sprite); @@ -547,11 +547,11 @@ void G_ConsGhostTic(void) { if (ziptic & GZT_MOMXY) { - oldghost.momx = READINT16(demo_p)<<8; - oldghost.momy = READINT16(demo_p)<<8; + oldghost.momx = (demoversion < 0x000e) ? READINT16(demo_p)<<8 : READFIXED(demo_p); + oldghost.momy = (demoversion < 0x000e) ? READINT16(demo_p)<<8 : READFIXED(demo_p); } if (ziptic & GZT_MOMZ) - oldghost.momz = READINT16(demo_p)<<8; + oldghost.momz = (demoversion < 0x000e) ? READINT16(demo_p)<<8 : READFIXED(demo_p); oldghost.x += oldghost.momx; oldghost.y += oldghost.momy; oldghost.z += oldghost.momz; @@ -627,9 +627,10 @@ void G_ConsGhostTic(void) } if (followtic & FZT_SCALE) demo_p += sizeof(fixed_t); - demo_p += sizeof(INT16); - demo_p += sizeof(INT16); - demo_p += sizeof(INT16); + // momx, momy and momz + demo_p += (demoversion < 0x000e) ? sizeof(UINT16) : sizeof(fixed_t); + demo_p += (demoversion < 0x000e) ? sizeof(UINT16) : sizeof(fixed_t); + demo_p += (demoversion < 0x000e) ? sizeof(UINT16) : sizeof(fixed_t); if (followtic & FZT_SKIN) demo_p++; demo_p += sizeof(UINT16); @@ -697,11 +698,11 @@ void G_GhostTicker(void) { if (ziptic & GZT_MOMXY) { - g->oldmo.momx = READINT16(g->p)<<8; - g->oldmo.momy = READINT16(g->p)<<8; + g->oldmo.momx = (g->version < 0x000e) ? READINT16(g->p)<<8 : READFIXED(g->p); + g->oldmo.momy = (g->version < 0x000e) ? READINT16(g->p)<<8 : READFIXED(g->p); } if (ziptic & GZT_MOMZ) - g->oldmo.momz = READINT16(g->p)<<8; + g->oldmo.momz = (g->version < 0x000e) ? READINT16(g->p)<<8 : READFIXED(g->p); g->oldmo.x += g->oldmo.momx; g->oldmo.y += g->oldmo.momy; g->oldmo.z += g->oldmo.momz; @@ -905,11 +906,11 @@ void G_GhostTicker(void) P_SetScale(follow, follow->destscale); P_UnsetThingPosition(follow); - temp = READINT16(g->p)<<8; + temp = (g->version < 0x000e) ? READINT16(g->p)<<8 : READFIXED(g->p); follow->x = g->mo->x + temp; - temp = READINT16(g->p)<<8; + temp = (g->version < 0x000e) ? READINT16(g->p)<<8 : READFIXED(g->p); follow->y = g->mo->y + temp; - temp = READINT16(g->p)<<8; + temp = (g->version < 0x000e) ? READINT16(g->p)<<8 : READFIXED(g->p); follow->z = g->mo->z + temp; P_SetThingPosition(follow); if (followtic & FZT_SKIN) @@ -1010,11 +1011,11 @@ void G_ReadMetalTic(mobj_t *metal) { if (ziptic & GZT_MOMXY) { - oldmetal.momx = READINT16(metal_p)<<8; - oldmetal.momy = READINT16(metal_p)<<8; + oldmetal.momx = (metalversion < 0x000e) ? READINT16(metal_p)<<8 : READFIXED(metal_p); + oldmetal.momy = (metalversion < 0x000e) ? READINT16(metal_p)<<8 : READFIXED(metal_p); } if (ziptic & GZT_MOMZ) - oldmetal.momz = READINT16(metal_p)<<8; + oldmetal.momz = (metalversion < 0x000e) ? READINT16(metal_p)<<8 : READFIXED(metal_p); oldmetal.x += oldmetal.momx; oldmetal.y += oldmetal.momy; oldmetal.z += oldmetal.momz; @@ -1149,11 +1150,11 @@ void G_ReadMetalTic(mobj_t *metal) P_SetScale(follow, follow->destscale); P_UnsetThingPosition(follow); - temp = READINT16(metal_p)<<8; + temp = (metalversion < 0x000e) ? READINT16(metal_p)<<8 : READFIXED(metal_p); follow->x = metal->x + temp; - temp = READINT16(metal_p)<<8; + temp = (metalversion < 0x000e) ? READINT16(metal_p)<<8 : READFIXED(metal_p); follow->y = metal->y + temp; - temp = READINT16(metal_p)<<8; + temp = (metalversion < 0x000e) ? READINT16(metal_p)<<8 : READFIXED(metal_p); follow->z = metal->z + temp; P_SetThingPosition(follow); if (followtic & FZT_SKIN) @@ -1213,32 +1214,32 @@ void G_WriteMetalTic(mobj_t *metal) else { // For moving normally: - // Store one full byte of movement, plus one byte of fractional movement. - INT16 momx = (INT16)((metal->x-oldmetal.x)>>8); - INT16 momy = (INT16)((metal->y-oldmetal.y)>>8); + // Store movement as a fixed value + fixed_t momx = metal->x-oldmetal.x; + fixed_t momy = metal->y-oldmetal.y; if (momx != oldmetal.momx || momy != oldmetal.momy) { oldmetal.momx = momx; oldmetal.momy = momy; ziptic |= GZT_MOMXY; - WRITEINT16(demo_p,momx); - WRITEINT16(demo_p,momy); + WRITEFIXED(demo_p,momx); + WRITEFIXED(demo_p,momy); } - momx = (INT16)((metal->z-oldmetal.z)>>8); + momx = metal->z-oldmetal.z; if (momx != oldmetal.momz) { oldmetal.momz = momx; ziptic |= GZT_MOMZ; - WRITEINT16(demo_p,momx); + WRITEFIXED(demo_p,momx); } // This SHOULD set oldmetal.x/y/z to match metal->x/y/z // but it keeps the fractional loss of one byte, // so it will hopefully be made up for in future tics. - oldmetal.x += oldmetal.momx<<8; - oldmetal.y += oldmetal.momy<<8; - oldmetal.z += oldmetal.momz<<8; + oldmetal.x += oldmetal.momx; + oldmetal.y += oldmetal.momy; + oldmetal.z += oldmetal.momz; } #undef MAXMOM @@ -1307,7 +1308,7 @@ void G_WriteMetalTic(mobj_t *metal) if (metal->player && metal->player->followmobj && !(metal->player->followmobj->sprite == SPR_NULL || (metal->player->followmobj->flags2 & MF2_DONTDRAW))) { - INT16 temp; + fixed_t temp; UINT8 *followtic_p = demo_p++; UINT8 followtic = 0; @@ -1335,12 +1336,12 @@ void G_WriteMetalTic(mobj_t *metal) WRITEFIXED(demo_p,metal->player->followmobj->scale); } - temp = (INT16)((metal->player->followmobj->x-metal->x)>>8); - WRITEINT16(demo_p,temp); - temp = (INT16)((metal->player->followmobj->y-metal->y)>>8); - WRITEINT16(demo_p,temp); - temp = (INT16)((metal->player->followmobj->z-metal->z)>>8); - WRITEINT16(demo_p,temp); + temp = metal->player->followmobj->x-metal->x; + WRITEFIXED(demo_p,temp); + temp = metal->player->followmobj->y-metal->y; + WRITEFIXED(demo_p,temp); + temp = metal->player->followmobj->z-metal->z; + WRITEFIXED(demo_p,temp); if (followtic & FZT_SKIN) WRITEUINT8(demo_p,metal->player->followmobj->sprite2); WRITEUINT16(demo_p,metal->player->followmobj->sprite); @@ -1818,6 +1819,7 @@ void G_DoPlayDemo(char *defdemoname) demoversion = READUINT16(demo_p); switch(demoversion) { + case 0x000d: case DEMOVERSION: // latest always supported cnamelen = MAXCOLORNAME; break; @@ -2073,6 +2075,7 @@ void G_AddGhost(char *defdemoname) ghostversion = READUINT16(p); switch(ghostversion) { + case 0x000d: case DEMOVERSION: // latest always supported cnamelen = MAXCOLORNAME; break; @@ -2324,6 +2327,7 @@ void G_DoPlayMetal(void) switch(metalversion) { case DEMOVERSION: // latest always supported + case 0x000d: // There are checks wheter the momentum is from older demo versions or not case 0x000c: // all that changed between then and now was longer color name break; // too old, cannot support. From b261e17fdd45bcff5f534eb93c3dc7cabaf086e6 Mon Sep 17 00:00:00 2001 From: Riku Salminen Date: Wed, 23 Sep 2020 15:29:03 -0400 Subject: [PATCH 0105/1080] Update g_demo.c, Remove old comments of fractional loss of one byte --- src/g_demo.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/g_demo.c b/src/g_demo.c index c7460fa3c..23fa06a3a 100644 --- a/src/g_demo.c +++ b/src/g_demo.c @@ -345,7 +345,6 @@ void G_WriteGhostTic(mobj_t *ghost) else { // For moving normally: - // Store one full byte of movement, plus one byte of fractional movement. fixed_t momx = ghost->x-oldghost.x; fixed_t momy = ghost->y-oldghost.y; if (momx != oldghost.momx @@ -366,8 +365,6 @@ void G_WriteGhostTic(mobj_t *ghost) } // This SHOULD set oldghost.x/y/z to match ghost->x/y/z - // but it keeps the fractional loss of one byte, - // so it will hopefully be made up for in future tics. oldghost.x += oldghost.momx; oldghost.y += oldghost.momy; oldghost.z += oldghost.momz; @@ -1235,8 +1232,6 @@ void G_WriteMetalTic(mobj_t *metal) } // This SHOULD set oldmetal.x/y/z to match metal->x/y/z - // but it keeps the fractional loss of one byte, - // so it will hopefully be made up for in future tics. oldmetal.x += oldmetal.momx; oldmetal.y += oldmetal.momy; oldmetal.z += oldmetal.momz; From e947007920317f206be7b5391b1d8342f5b555f7 Mon Sep 17 00:00:00 2001 From: Riku Salminen <38985578+Riku-S@users.noreply.github.com> Date: Wed, 23 Sep 2020 22:37:06 +0300 Subject: [PATCH 0106/1080] Wrote 3 lines in 1, as Zwip-Zwap Zapony suggested --- src/g_demo.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/g_demo.c b/src/g_demo.c index 23fa06a3a..5f153cb5b 100644 --- a/src/g_demo.c +++ b/src/g_demo.c @@ -625,9 +625,7 @@ void G_ConsGhostTic(void) if (followtic & FZT_SCALE) demo_p += sizeof(fixed_t); // momx, momy and momz - demo_p += (demoversion < 0x000e) ? sizeof(UINT16) : sizeof(fixed_t); - demo_p += (demoversion < 0x000e) ? sizeof(UINT16) : sizeof(fixed_t); - demo_p += (demoversion < 0x000e) ? sizeof(UINT16) : sizeof(fixed_t); + demo_p += (demoversion < 0x000e) ? sizeof(UINT16) * 3 : sizeof(fixed_t) * 3; if (followtic & FZT_SKIN) demo_p++; demo_p += sizeof(UINT16); From 021061d80bd97a87973f372df840e224a162ba7a Mon Sep 17 00:00:00 2001 From: GoldenTails Date: Wed, 23 Sep 2020 22:28:29 -0500 Subject: [PATCH 0107/1080] Expose MODVERSION to Lua (because for some reason it wasn't). The wiki even states its existence! --- src/dehacked.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/dehacked.c b/src/dehacked.c index 88a633976..c9a50e6d1 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -9517,6 +9517,7 @@ struct { {"RING_DIST",RING_DIST}, {"PUSHACCEL",PUSHACCEL}, {"MODID",MODID}, // I don't know, I just thought it would be cool for a wad to potentially know what mod it was loaded into. + {"MODVERSION",MODVERSION}, // or what version of the mod this is. {"CODEBASE",CODEBASE}, // or what release of SRB2 this is. {"NEWTICRATE",NEWTICRATE}, // TICRATE*NEWTICRATERATIO {"NEWTICRATERATIO",NEWTICRATERATIO}, From 07a57d0419ff1b588071abcfe844f36552c88370 Mon Sep 17 00:00:00 2001 From: Snu Date: Tue, 29 Sep 2020 09:45:34 +0100 Subject: [PATCH 0108/1080] Add SF_CANBREAKWALLS, SF_CANBREAKFLOORS and SF_BUSTABLEBUSTER --- src/d_player.h | 3 +++ src/dehacked.c | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/d_player.h b/src/d_player.h index 26086a331..03579be28 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -51,6 +51,9 @@ typedef enum SF_NONIGHTSSUPER = 1<<15, // Disable super colors for NiGHTS (if you have SF_SUPER) SF_NOSUPERSPRITES = 1<<16, // Don't use super sprites while super SF_NOSUPERJUMPBOOST = 1<<17, // Disable the jump boost given while super (i.e. Knuckles) + SF_CANBREAKWALLS = 1<<18, // Can naturally break walls on contact? (i.e. Knuckles) + SF_CANBREAKFLOORS = 1<<19, // Can naturally break floors on contact? + SF_BUSTABLEBUSTER = SF_CANBREAKWALLS|SF_CANBREAKFLOORS, // Convenience skinflag. // free up to and including 1<<31 } skinflags_t; diff --git a/src/dehacked.c b/src/dehacked.c index d02dc3d24..9cd181256 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -9666,6 +9666,9 @@ struct { {"SF_NONIGHTSSUPER",SF_NONIGHTSSUPER}, {"SF_NOSUPERSPRITES",SF_NOSUPERSPRITES}, {"SF_NOSUPERJUMPBOOST",SF_NOSUPERJUMPBOOST}, + {"SF_CANBREAKWALLS",SF_CANBREAKWALLS}, + {"SF_CANBREAKFLOORS",SF_CANBREAKFLOORS}, + {"SF_BUSTABLEBUSTER",SF_BUSTABLEBUSTER}, // Dashmode constants {"DASHMODE_THRESHOLD",DASHMODE_THRESHOLD}, From d07422bda13d050794721d87312da2898111b699 Mon Sep 17 00:00:00 2001 From: Snu Date: Tue, 29 Sep 2020 10:32:45 +0100 Subject: [PATCH 0109/1080] Change breaking walls requirement from CA_GLIDEANDCLIMB to SF_CANBREAKWALLS. --- 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 261e4b28c..8701f8a73 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -2564,7 +2564,7 @@ static boolean P_PlayerCanBust(player_t *player, ffloor_t *rover) } // Strong abilities can break even FF_STRONGBUST. - if (player->charability == CA_GLIDEANDCLIMB) + if (player->charflags & SF_CANBREAKWALLS) return true; if (player->pflags & PF_BOUNCING) From 04b749f1f91f89f5adae2cf79102c4d3211979c4 Mon Sep 17 00:00:00 2001 From: Snu Date: Tue, 29 Sep 2020 11:05:04 +0100 Subject: [PATCH 0110/1080] Remove SF_BUSTABLEBUSTER, change SF_CANBREAKFLOORS to a pflags; PF_CANBREAKFLOORS --- src/d_player.h | 3 +-- src/dehacked.c | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/d_player.h b/src/d_player.h index 03579be28..794dc5640 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -52,8 +52,6 @@ typedef enum SF_NOSUPERSPRITES = 1<<16, // Don't use super sprites while super SF_NOSUPERJUMPBOOST = 1<<17, // Disable the jump boost given while super (i.e. Knuckles) SF_CANBREAKWALLS = 1<<18, // Can naturally break walls on contact? (i.e. Knuckles) - SF_CANBREAKFLOORS = 1<<19, // Can naturally break floors on contact? - SF_BUSTABLEBUSTER = SF_CANBREAKWALLS|SF_CANBREAKFLOORS, // Convenience skinflag. // free up to and including 1<<31 } skinflags_t; @@ -158,6 +156,7 @@ typedef enum PF_FORCESTRAFE = 1<<28, // Turning inputs are translated into strafing inputs PF_CANCARRY = 1<<29, // Can carry another player? PF_FINISHED = 1<<30, // The player finished the level. NOT the same as exiting + PF_CANBREAKFLOORS = 1<<31, // The player can break floors. // up to 1<<31 is free } pflags_t; diff --git a/src/dehacked.c b/src/dehacked.c index 9cd181256..77e7fed4a 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -9089,6 +9089,7 @@ static const char *const PLAYERFLAG_LIST[] = { "FORCESTRAFE", // Translate turn inputs into strafe inputs "CANCARRY", // Can carry? "FINISHED", + "CANBREAKFLOORS", // Can break floors? NULL // stop loop here. }; @@ -9667,8 +9668,6 @@ struct { {"SF_NOSUPERSPRITES",SF_NOSUPERSPRITES}, {"SF_NOSUPERJUMPBOOST",SF_NOSUPERJUMPBOOST}, {"SF_CANBREAKWALLS",SF_CANBREAKWALLS}, - {"SF_CANBREAKFLOORS",SF_CANBREAKFLOORS}, - {"SF_BUSTABLEBUSTER",SF_BUSTABLEBUSTER}, // Dashmode constants {"DASHMODE_THRESHOLD",DASHMODE_THRESHOLD}, From 90fbb752fa6bf7f2a7de6dd8d04d273498dc66e5 Mon Sep 17 00:00:00 2001 From: Snu Date: Tue, 29 Sep 2020 12:58:36 +0100 Subject: [PATCH 0111/1080] Add functionality to PF_CANBREAKFLOORS --- src/p_user.c | 45 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index 8701f8a73..ed9de48bf 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -2611,10 +2611,51 @@ static void P_CheckBustableBlocks(player_t *player) if ((netgame || multiplayer) && player->spectator) return; + + // First iteration, check for floors we're touching directly (PF_CANBREAKFLOORS) + if (player->pflags & PF_CANBREAKFLOORS) + { + for (node = player->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; + + for (rover = node->m_sector->ffloors; rover; rover = rover->next) + { + // Make sure it's a bustable. (And that it actually exists!) + if (!(rover->flags & FF_EXISTS)) + continue; + + if (!(rover->flags & FF_BUSTUP)) + continue; + + topheight = P_GetFOFTopZ(player->mo, node->m_sector, rover, player->mo->x, player->mo->y, NULL) - player->mo->momz; + bottomheight = P_GetFOFBottomZ(player->mo, node->m_sector, rover, player->mo->x, player->mo->y, NULL) - player->mo->momz; + + if (player->mo->z > topheight) + continue; + + if (player->mo->z + player->mo->height < bottomheight) + continue; + + EV_CrumbleChain(NULL, rover); // node->m_sector + + // Run a linedef executor?? + if (rover->master->flags & ML_EFFECT5) + P_LinedefExecute((INT16)(P_AproxDistance(rover->master->dx, rover->master->dy)>>FRACBITS), player->mo, node->m_sector); + } + } + } + oldx = player->mo->x; oldy = player->mo->y; - + if (!(player->pflags & PF_BOUNCING)) // Bouncers only get to break downwards, not sideways { P_UnsetThingPosition(player->mo); @@ -2633,7 +2674,7 @@ static void P_CheckBustableBlocks(player_t *player) if (!node->m_sector->ffloors) continue; - + for (rover = node->m_sector->ffloors; rover; rover = rover->next) { if (!P_PlayerCanBust(player, rover)) From 75042d781f94923c7e540f7d005cd2c9ed682d15 Mon Sep 17 00:00:00 2001 From: Snu Date: Tue, 29 Sep 2020 13:47:48 +0100 Subject: [PATCH 0112/1080] Fix characters without SF_CANBREAKWALLS not being able to climb bustable walls. --- src/p_map.c | 2 +- src/p_user.c | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/p_map.c b/src/p_map.c index b7ad14808..4732ebeeb 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -3341,7 +3341,7 @@ static void PTR_GlideClimbTraverse(line_t *li) { for (rover = checksector->ffloors; rover; rover = rover->next) { - if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_BLOCKPLAYER) || (rover->flags & FF_BUSTUP)) + if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_BLOCKPLAYER) || ((rover->flags & FF_BUSTUP) && (slidemo->player->charflags & SF_CANBREAKWALLS))) continue; topheight = P_GetFFloorTopZAt (rover, slidemo->x, slidemo->y); diff --git a/src/p_user.c b/src/p_user.c index ed9de48bf..c56c91d79 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3255,7 +3255,7 @@ static void P_DoClimbing(player_t *player) for (rover = glidesector->sector->ffloors; rover; rover = rover->next) { - if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_BLOCKPLAYER) || (rover->flags & FF_BUSTUP)) + if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_BLOCKPLAYER) || ((rover->flags & FF_BUSTUP) && (player->charflags & SF_CANBREAKWALLS))) continue; floorclimb = true; @@ -3296,7 +3296,7 @@ static void P_DoClimbing(player_t *player) // Is there a FOF directly below this one that we can move onto? for (roverbelow = glidesector->sector->ffloors; roverbelow; roverbelow = roverbelow->next) { - if (!(roverbelow->flags & FF_EXISTS) || !(roverbelow->flags & FF_BLOCKPLAYER) || (roverbelow->flags & FF_BUSTUP)) + if (!(roverbelow->flags & FF_EXISTS) || !(roverbelow->flags & FF_BLOCKPLAYER) || ((rover->flags & FF_BUSTUP) && (player->charflags & SF_CANBREAKWALLS))) continue; if (roverbelow == rover) @@ -3341,7 +3341,7 @@ static void P_DoClimbing(player_t *player) // Is there a FOF directly below this one that we can move onto? for (roverbelow = glidesector->sector->ffloors; roverbelow; roverbelow = roverbelow->next) { - if (!(roverbelow->flags & FF_EXISTS) || !(roverbelow->flags & FF_BLOCKPLAYER) || (roverbelow->flags & FF_BUSTUP)) + if (!(roverbelow->flags & FF_EXISTS) || !(roverbelow->flags & FF_BLOCKPLAYER) || ((rover->flags & FF_BUSTUP) && (player->charflags & SF_CANBREAKWALLS))) continue; if (roverbelow == rover) @@ -3398,7 +3398,7 @@ static void P_DoClimbing(player_t *player) ffloor_t *rover; for (rover = glidesector->sector->ffloors; rover; rover = rover->next) { - if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_BLOCKPLAYER) || (rover->flags & FF_BUSTUP)) + if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_BLOCKPLAYER) || ((rover->flags & FF_BUSTUP) && (player->charflags & SF_CANBREAKWALLS))) continue; bottomheight = P_GetFFloorBottomZAt(rover, player->mo->x, player->mo->y); @@ -3438,7 +3438,7 @@ static void P_DoClimbing(player_t *player) ffloor_t *rover; for (rover = glidesector->sector->ffloors; rover; rover = rover->next) { - if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_BLOCKPLAYER) || (rover->flags & FF_BUSTUP)) + if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_BLOCKPLAYER) || ((rover->flags & FF_BUSTUP) && (player->charflags & SF_CANBREAKWALLS))) continue; topheight = P_GetFFloorTopZAt(rover, player->mo->x, player->mo->y); From cd4f755e534ade05a2080e5ddb76ece6d0af0dfa Mon Sep 17 00:00:00 2001 From: Snu Date: Tue, 29 Sep 2020 13:52:35 +0100 Subject: [PATCH 0113/1080] Replace all instances of SF_CANBREAKWALLS and PF_CANBREAKFLOORS with SF_CANBUSTWALLS and PF_CANBUSTFLOORS, respectively. --- src/d_player.h | 4 ++-- src/dehacked.c | 4 ++-- src/p_map.c | 2 +- src/p_user.c | 16 ++++++++-------- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/d_player.h b/src/d_player.h index 794dc5640..ae269cb53 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -51,7 +51,7 @@ typedef enum SF_NONIGHTSSUPER = 1<<15, // Disable super colors for NiGHTS (if you have SF_SUPER) SF_NOSUPERSPRITES = 1<<16, // Don't use super sprites while super SF_NOSUPERJUMPBOOST = 1<<17, // Disable the jump boost given while super (i.e. Knuckles) - SF_CANBREAKWALLS = 1<<18, // Can naturally break walls on contact? (i.e. Knuckles) + SF_CANBUSTWALLS = 1<<18, // Can naturally bust walls on contact? (i.e. Knuckles) // free up to and including 1<<31 } skinflags_t; @@ -156,7 +156,7 @@ typedef enum PF_FORCESTRAFE = 1<<28, // Turning inputs are translated into strafing inputs PF_CANCARRY = 1<<29, // Can carry another player? PF_FINISHED = 1<<30, // The player finished the level. NOT the same as exiting - PF_CANBREAKFLOORS = 1<<31, // The player can break floors. + PF_CANBUSTFLOORS = 1<<31, // The player can bust floors on contact. // up to 1<<31 is free } pflags_t; diff --git a/src/dehacked.c b/src/dehacked.c index 77e7fed4a..5e422f974 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -9089,7 +9089,7 @@ static const char *const PLAYERFLAG_LIST[] = { "FORCESTRAFE", // Translate turn inputs into strafe inputs "CANCARRY", // Can carry? "FINISHED", - "CANBREAKFLOORS", // Can break floors? + "CANBUSTFLOORS", // Can bust floors? NULL // stop loop here. }; @@ -9667,7 +9667,7 @@ struct { {"SF_NONIGHTSSUPER",SF_NONIGHTSSUPER}, {"SF_NOSUPERSPRITES",SF_NOSUPERSPRITES}, {"SF_NOSUPERJUMPBOOST",SF_NOSUPERJUMPBOOST}, - {"SF_CANBREAKWALLS",SF_CANBREAKWALLS}, + {"SF_CANBUSTWALLS",SF_CANBUSTWALLS}, // Dashmode constants {"DASHMODE_THRESHOLD",DASHMODE_THRESHOLD}, diff --git a/src/p_map.c b/src/p_map.c index 4732ebeeb..a055eb252 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -3341,7 +3341,7 @@ static void PTR_GlideClimbTraverse(line_t *li) { for (rover = checksector->ffloors; rover; rover = rover->next) { - if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_BLOCKPLAYER) || ((rover->flags & FF_BUSTUP) && (slidemo->player->charflags & SF_CANBREAKWALLS))) + if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_BLOCKPLAYER) || ((rover->flags & FF_BUSTUP) && (slidemo->player->charflags & SF_CANBUSTWALLS))) continue; topheight = P_GetFFloorTopZAt (rover, slidemo->x, slidemo->y); diff --git a/src/p_user.c b/src/p_user.c index c56c91d79..c3ff223e6 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -2564,7 +2564,7 @@ static boolean P_PlayerCanBust(player_t *player, ffloor_t *rover) } // Strong abilities can break even FF_STRONGBUST. - if (player->charflags & SF_CANBREAKWALLS) + if (player->charflags & SF_CANBUSTWALLS) return true; if (player->pflags & PF_BOUNCING) @@ -2612,8 +2612,8 @@ static void P_CheckBustableBlocks(player_t *player) if ((netgame || multiplayer) && player->spectator) return; - // First iteration, check for floors we're touching directly (PF_CANBREAKFLOORS) - if (player->pflags & PF_CANBREAKFLOORS) + // First iteration, check for floors we're touching directly (PF_CANBUSTFLOORS) + if (player->pflags & PF_CANBUSTFLOORS) { for (node = player->mo->touching_sectorlist; node; node = node->m_sectorlist_next) { @@ -3255,7 +3255,7 @@ static void P_DoClimbing(player_t *player) for (rover = glidesector->sector->ffloors; rover; rover = rover->next) { - if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_BLOCKPLAYER) || ((rover->flags & FF_BUSTUP) && (player->charflags & SF_CANBREAKWALLS))) + if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_BLOCKPLAYER) || ((rover->flags & FF_BUSTUP) && (player->charflags & SF_CANBUSTWALLS))) continue; floorclimb = true; @@ -3296,7 +3296,7 @@ static void P_DoClimbing(player_t *player) // Is there a FOF directly below this one that we can move onto? for (roverbelow = glidesector->sector->ffloors; roverbelow; roverbelow = roverbelow->next) { - if (!(roverbelow->flags & FF_EXISTS) || !(roverbelow->flags & FF_BLOCKPLAYER) || ((rover->flags & FF_BUSTUP) && (player->charflags & SF_CANBREAKWALLS))) + if (!(roverbelow->flags & FF_EXISTS) || !(roverbelow->flags & FF_BLOCKPLAYER) || ((rover->flags & FF_BUSTUP) && (player->charflags & SF_CANBUSTWALLS))) continue; if (roverbelow == rover) @@ -3341,7 +3341,7 @@ static void P_DoClimbing(player_t *player) // Is there a FOF directly below this one that we can move onto? for (roverbelow = glidesector->sector->ffloors; roverbelow; roverbelow = roverbelow->next) { - if (!(roverbelow->flags & FF_EXISTS) || !(roverbelow->flags & FF_BLOCKPLAYER) || ((rover->flags & FF_BUSTUP) && (player->charflags & SF_CANBREAKWALLS))) + if (!(roverbelow->flags & FF_EXISTS) || !(roverbelow->flags & FF_BLOCKPLAYER) || ((rover->flags & FF_BUSTUP) && (player->charflags & SF_CANBUSTWALLS))) continue; if (roverbelow == rover) @@ -3398,7 +3398,7 @@ static void P_DoClimbing(player_t *player) ffloor_t *rover; for (rover = glidesector->sector->ffloors; rover; rover = rover->next) { - if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_BLOCKPLAYER) || ((rover->flags & FF_BUSTUP) && (player->charflags & SF_CANBREAKWALLS))) + if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_BLOCKPLAYER) || ((rover->flags & FF_BUSTUP) && (player->charflags & SF_CANBUSTWALLS))) continue; bottomheight = P_GetFFloorBottomZAt(rover, player->mo->x, player->mo->y); @@ -3438,7 +3438,7 @@ static void P_DoClimbing(player_t *player) ffloor_t *rover; for (rover = glidesector->sector->ffloors; rover; rover = rover->next) { - if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_BLOCKPLAYER) || ((rover->flags & FF_BUSTUP) && (player->charflags & SF_CANBREAKWALLS))) + if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_BLOCKPLAYER) || ((rover->flags & FF_BUSTUP) && (player->charflags & SF_CANBUSTWALLS))) continue; topheight = P_GetFFloorTopZAt(rover, player->mo->x, player->mo->y); From afcadb323278e0f25115011a0b4d1b901861ec4a Mon Sep 17 00:00:00 2001 From: Snu Date: Tue, 29 Sep 2020 20:16:06 +0100 Subject: [PATCH 0114/1080] Remove all instances of PF_CANBUSTFLOORS --- src/d_player.h | 1 - src/dehacked.c | 1 - src/p_user.c | 41 ----------------------------------------- 3 files changed, 43 deletions(-) diff --git a/src/d_player.h b/src/d_player.h index ae269cb53..581f59766 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -156,7 +156,6 @@ typedef enum PF_FORCESTRAFE = 1<<28, // Turning inputs are translated into strafing inputs PF_CANCARRY = 1<<29, // Can carry another player? PF_FINISHED = 1<<30, // The player finished the level. NOT the same as exiting - PF_CANBUSTFLOORS = 1<<31, // The player can bust floors on contact. // up to 1<<31 is free } pflags_t; diff --git a/src/dehacked.c b/src/dehacked.c index 5e422f974..37a4d03cb 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -9089,7 +9089,6 @@ static const char *const PLAYERFLAG_LIST[] = { "FORCESTRAFE", // Translate turn inputs into strafe inputs "CANCARRY", // Can carry? "FINISHED", - "CANBUSTFLOORS", // Can bust floors? NULL // stop loop here. }; diff --git a/src/p_user.c b/src/p_user.c index c3ff223e6..be1f990e0 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -2612,47 +2612,6 @@ static void P_CheckBustableBlocks(player_t *player) if ((netgame || multiplayer) && player->spectator) return; - // First iteration, check for floors we're touching directly (PF_CANBUSTFLOORS) - if (player->pflags & PF_CANBUSTFLOORS) - { - for (node = player->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; - - for (rover = node->m_sector->ffloors; rover; rover = rover->next) - { - // Make sure it's a bustable. (And that it actually exists!) - if (!(rover->flags & FF_EXISTS)) - continue; - - if (!(rover->flags & FF_BUSTUP)) - continue; - - topheight = P_GetFOFTopZ(player->mo, node->m_sector, rover, player->mo->x, player->mo->y, NULL) - player->mo->momz; - bottomheight = P_GetFOFBottomZ(player->mo, node->m_sector, rover, player->mo->x, player->mo->y, NULL) - player->mo->momz; - - if (player->mo->z > topheight) - continue; - - if (player->mo->z + player->mo->height < bottomheight) - continue; - - EV_CrumbleChain(NULL, rover); // node->m_sector - - // Run a linedef executor?? - if (rover->master->flags & ML_EFFECT5) - P_LinedefExecute((INT16)(P_AproxDistance(rover->master->dx, rover->master->dy)>>FRACBITS), player->mo, node->m_sector); - } - } - } - oldx = player->mo->x; oldy = player->mo->y; From ca88db00cdf77055615db7b6cd19e06ca401e3cf Mon Sep 17 00:00:00 2001 From: Snu Date: Wed, 30 Sep 2020 07:56:57 +0100 Subject: [PATCH 0115/1080] Create P_CeilingzAtPos function --- src/p_local.h | 1 + src/p_map.c | 46 +++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 46 insertions(+), 1 deletion(-) diff --git a/src/p_local.h b/src/p_local.h index 9873a20af..525c1a3bd 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -424,6 +424,7 @@ void P_Initsecnode(void); void P_RadiusAttack(mobj_t *spot, mobj_t *source, fixed_t damagedist, UINT8 damagetype, boolean sightcheck); fixed_t P_FloorzAtPos(fixed_t x, fixed_t y, fixed_t z, fixed_t height); +fixed_t P_CeilingzAtPos(fixed_t x, fixed_t y, fixed_t z, fixed_t height); boolean PIT_PushableMoved(mobj_t *thing); boolean P_DoSpring(mobj_t *spring, mobj_t *object); diff --git a/src/p_map.c b/src/p_map.c index b7ad14808..d26b1707d 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -4953,7 +4953,7 @@ void P_MapEnd(void) } // P_FloorzAtPos -// Returns the floorz of the XYZ position // TODO: Need ceilingpos function too +// Returns the floorz of the XYZ position // Tails 05-26-2003 fixed_t P_FloorzAtPos(fixed_t x, fixed_t y, fixed_t z, fixed_t height) { @@ -4997,3 +4997,47 @@ fixed_t P_FloorzAtPos(fixed_t x, fixed_t y, fixed_t z, fixed_t height) return floorz; } + +// P_CeilingZAtPos +// Returns the ceilinz of the XYZ position +fixed_t P_CeilingzAtPos(fixed_t x, fixed_t y, fixed_t z, fixed_t height) +{ + sector_t *sec = R_PointInSubsector(x, y)->sector; + fixed_t ceilingz = P_GetSectorCeilingZAt(sec, x, y); + + if (sec->ffloors) + { + ffloor_t *rover; + fixed_t delta1, delta2, thingtop = z + height; + + for (rover = sec->ffloors; rover; rover = rover->next) + { + fixed_t topheight, bottomheight; + if (!(rover->flags & FF_EXISTS)) + continue; + + if ((!(rover->flags & FF_SOLID || rover->flags & FF_QUICKSAND) || (rover->flags & FF_SWIMMABLE))) + continue; + + topheight = P_GetFFloorTopZAt (rover, x, y); + bottomheight = P_GetFFloorBottomZAt(rover, x, y); + + if (rover->flags & FF_QUICKSAND) + { + if (z < topheight && bottomheight < thingtop) + { + if (ceilingz < z) + ceilingz = z; + } + continue; + } + + delta1 = z - (bottomheight + ((topheight - bottomheight)/2)); + delta2 = thingtop - (bottomheight + ((topheight - bottomheight)/2)); + if (bottomheight > ceilingz && abs(delta1) < abs(delta2)) + ceilingz = bottomheight; + } + } + + return ceilingz; +} \ No newline at end of file From feb011ee5222e81f21c1b816ea780106c2d54f1c Mon Sep 17 00:00:00 2001 From: Snu Date: Wed, 30 Sep 2020 07:58:41 +0100 Subject: [PATCH 0116/1080] Expose function to Lua --- src/lua_baselib.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 775d9ec02..b3e423300 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -1601,6 +1601,18 @@ static int lib_pFloorzAtPos(lua_State *L) return 1; } +static int lib_pCeilingzAtPos(lua_State *L) +{ + fixed_t x = luaL_checkfixed(L, 1); + fixed_t y = luaL_checkfixed(L, 2); + fixed_t z = luaL_checkfixed(L, 3); + fixed_t height = luaL_checkfixed(L, 4); + //HUDSAFE + INLEVEL + lua_pushfixed(L, P_CeilingzAtPos(x, y, z, height)); + return 1; +} + static int lib_pDoSpring(lua_State *L) { mobj_t *spring = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); @@ -3316,7 +3328,8 @@ static luaL_Reg lib[] = { {"P_CheckSight", lib_pCheckSight}, {"P_CheckHoopPosition",lib_pCheckHoopPosition}, {"P_RadiusAttack",lib_pRadiusAttack}, - {"P_FloorzAtPos",lib_pFloorzAtPos}, + {"P_FloorzAtPos",lib_pCeilingzAtPos}, + {"P_CeilingzAtPos",lib_pFloorzAtPos}, {"P_DoSpring",lib_pDoSpring}, // p_inter From 82ceddb2bedebb4a3e12e6e7dbfaa7f2a3262f4d Mon Sep 17 00:00:00 2001 From: Snu Date: Wed, 30 Sep 2020 08:10:28 +0100 Subject: [PATCH 0117/1080] god damnit --- src/lua_baselib.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index b3e423300..e376fbea5 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -3328,8 +3328,8 @@ static luaL_Reg lib[] = { {"P_CheckSight", lib_pCheckSight}, {"P_CheckHoopPosition",lib_pCheckHoopPosition}, {"P_RadiusAttack",lib_pRadiusAttack}, - {"P_FloorzAtPos",lib_pCeilingzAtPos}, - {"P_CeilingzAtPos",lib_pFloorzAtPos}, + {"P_FloorzAtPos",lib_pFloorzAtPos}, + {"P_CeilingzAtPos",lib_pCeilingzAtPos}, {"P_DoSpring",lib_pDoSpring}, // p_inter From 8a00b47b38903a2f004f193853cba26684d0a098 Mon Sep 17 00:00:00 2001 From: Snu Date: Wed, 30 Sep 2020 08:40:21 +0100 Subject: [PATCH 0118/1080] Make the function ACTUALLY work --- src/p_map.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/p_map.c b/src/p_map.c index d26b1707d..c2e028472 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -5024,9 +5024,9 @@ fixed_t P_CeilingzAtPos(fixed_t x, fixed_t y, fixed_t z, fixed_t height) if (rover->flags & FF_QUICKSAND) { - if (z < topheight && bottomheight < thingtop) + if (thingtop > bottomheight && topheight > z) { - if (ceilingz < z) + if (ceilingz > z) ceilingz = z; } continue; @@ -5034,7 +5034,7 @@ fixed_t P_CeilingzAtPos(fixed_t x, fixed_t y, fixed_t z, fixed_t height) delta1 = z - (bottomheight + ((topheight - bottomheight)/2)); delta2 = thingtop - (bottomheight + ((topheight - bottomheight)/2)); - if (bottomheight > ceilingz && abs(delta1) < abs(delta2)) + if (bottomheight < ceilingz && abs(delta1) > abs(delta2)) ceilingz = bottomheight; } } From bfd8bd7564a81bd13c1737569e43d3c2870d74a2 Mon Sep 17 00:00:00 2001 From: Snu Date: Wed, 30 Sep 2020 08:44:43 +0100 Subject: [PATCH 0119/1080] comment typo --- 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 c2e028472..2851fa826 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -4999,7 +4999,7 @@ fixed_t P_FloorzAtPos(fixed_t x, fixed_t y, fixed_t z, fixed_t height) } // P_CeilingZAtPos -// Returns the ceilinz of the XYZ position +// Returns the ceilingz of the XYZ position fixed_t P_CeilingzAtPos(fixed_t x, fixed_t y, fixed_t z, fixed_t height) { sector_t *sec = R_PointInSubsector(x, y)->sector; From 386db4b7a1c0b134347322ac6dcfc968ea2d60f3 Mon Sep 17 00:00:00 2001 From: Steel Titanium Date: Fri, 2 Oct 2020 15:45:43 -0400 Subject: [PATCH 0120/1080] Model fallback --- src/hardware/hw_md2.c | 54 ++++++++++++++++++++++++++++++++----------- 1 file changed, 41 insertions(+), 13 deletions(-) diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index 5f5130896..9d43105e0 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -92,7 +92,13 @@ static void md2_freeModel (model_t *model) static model_t *md2_readModel(const char *filename) { //Filename checking fixed ~Monster Iestyn and Golden - return LoadModel(va("%s"PATHSEP"%s", srb2home, filename), PU_STATIC); + if (FIL_FileExists(va("%s"PATHSEP"%s", srb2home, filename))) + return LoadModel(va("%s"PATHSEP"%s", srb2home, filename), PU_STATIC); + + if (FIL_FileExists(va("%s"PATHSEP"%s", srb2path, filename))) + return LoadModel(va("%s"PATHSEP"%s", srb2path, filename), PU_STATIC); + + return NULL; } static inline void md2_printModelInfo (model_t *model) @@ -160,8 +166,12 @@ static GLTextureFormat_t PNG_Load(const char *filename, int *w, int *h, GLPatch_ png_FILE = fopen(pngfilename, "rb"); if (!png_FILE) { + pngfilename = va("%s"PATHSEP"models"PATHSEP"%s", srb2path, filename); + FIL_ForceExtension(pngfilename, ".png"); + png_FILE = fopen(pngfilename, "rb"); //CONS_Debug(DBG_RENDER, "M_SavePNG: Error on opening %s for loading\n", filename); - return 0; + if (!png_FILE) + return 0; } png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, @@ -288,7 +298,13 @@ static GLTextureFormat_t PCX_Load(const char *filename, int *w, int *h, FIL_ForceExtension(pcxfilename, ".pcx"); file = fopen(pcxfilename, "rb"); if (!file) - return 0; + { + pcxfilename = va("%s"PATHSEP"models"PATHSEP"%s", srb2path, filename); + FIL_ForceExtension(pcxfilename, ".pcx"); + file = fopen(pcxfilename, "rb"); + if (!file) + return 0; + } if (fread(&header, sizeof (PcxHeader), 1, file) != 1) { @@ -493,11 +509,15 @@ void HWR_InitModels(void) if (!f) { - CONS_Printf("%s %s\n", M_GetText("Error while loading models.dat:"), strerror(errno)); - nomd2s = true; - return; + f = fopen(va("%s"PATHSEP"%s", srb2path, "models.dat"), "rt"); + if (!f) + { + CONS_Printf("%s %s\n", M_GetText("Error while loading models.dat:"), strerror(errno)); + nomd2s = true; + return; + } } - + // length of the player model prefix prefixlen = strlen(PLAYERMODELPREFIX); @@ -569,9 +589,13 @@ void HWR_AddPlayerModel(int skin) // For skins that were added after startup if (!f) { - CONS_Printf("Error while loading models.dat\n"); - nomd2s = true; - return; + f = fopen(va("%s"PATHSEP"%s", srb2path, "models.dat"), "rt"); + if (!f) + { + CONS_Printf("%s %s\n", M_GetText("Error while loading models.dat:"), strerror(errno)); + nomd2s = true; + return; + } } // length of the player model prefix @@ -624,9 +648,13 @@ void HWR_AddSpriteModel(size_t spritenum) // For sprites that were added after s if (!f) { - CONS_Printf("Error while loading models.dat\n"); - nomd2s = true; - return; + f = fopen(va("%s"PATHSEP"%s", srb2path, "models.dat"), "rt"); + if (!f) + { + CONS_Printf("%s %s\n", M_GetText("Error while loading models.dat:"), strerror(errno)); + nomd2s = true; + return; + } } // Check for any models that match the names of sprite names! From 121c7da8090b3796c1d74ae196f57236a3c9f8c6 Mon Sep 17 00:00:00 2001 From: Louis-Antoine Date: Sat, 3 Oct 2020 16:31:04 +0200 Subject: [PATCH 0121/1080] Let Lua scripts relink tables to their metatables when unarchiving This is done through the new "registermetatable" function, in a somewhat similar fashion to "freeslot" but for metatables: it must be called at script load to tell SRB2 your metatable can be automatically relinked during the unarchiving process. --- src/lua_baselib.c | 28 ++++++++++++++++++++++++++++ src/lua_libs.h | 1 + src/lua_script.c | 34 +++++++++++++++++++++++++++++++++- 3 files changed, 62 insertions(+), 1 deletion(-) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 6b25e32ea..6bdc65786 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -238,6 +238,33 @@ static int lib_userdataType(lua_State *L) return luaL_typerror(L, 1, "userdata"); } +// Takes a metatable as first and only argument +// Only callable during script loading +static int lib_registermetatable(lua_State *L) +{ + static UINT32 nextid = 1; + + if (!lua_lumploading) + return luaL_error(L, "This function cannot be called from within a hook or coroutine!"); + luaL_checktype(L, 1, LUA_TTABLE); + + lua_getfield(L, LUA_REGISTRYINDEX, LREG_METATABLES); // 2 + // registry.metatables[metatable] = nextid + lua_pushvalue(L, 1); // 3 + lua_pushnumber(L, nextid); // 4 + lua_settable(L, 2); + + // registry.metatables[nextid] = metatable + lua_pushnumber(L, nextid); // 3 + lua_pushvalue(L, 1); // 4 + lua_settable(L, 2); + lua_pop(L, 1); + + nextid++; + + return 0; +} + static int lib_isPlayerAdmin(lua_State *L) { player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); @@ -3433,6 +3460,7 @@ static luaL_Reg lib[] = { {"chatprint", lib_chatprint}, {"chatprintf", lib_chatprintf}, {"userdataType", lib_userdataType}, + {"registermetatable", lib_registermetatable}, {"IsPlayerAdmin", lib_isPlayerAdmin}, {"reserveLuabanks", lib_reserveLuabanks}, diff --git a/src/lua_libs.h b/src/lua_libs.h index f987c79fd..e1b2a2d1c 100644 --- a/src/lua_libs.h +++ b/src/lua_libs.h @@ -16,6 +16,7 @@ extern lua_State *gL; #define LREG_EXTVARS "LUA_VARS" #define LREG_STATEACTION "STATE_ACTION" #define LREG_ACTIONS "MOBJ_ACTION" +#define LREG_METATABLES "METATABLES" #define META_STATE "STATE_T*" #define META_MOBJINFO "MOBJINFO_T*" diff --git a/src/lua_script.c b/src/lua_script.c index 0260f018a..0edcbe6ba 100644 --- a/src/lua_script.c +++ b/src/lua_script.c @@ -437,6 +437,10 @@ static void LUA_ClearState(void) lua_newtable(L); lua_setfield(L, LUA_REGISTRYINDEX, LREG_VALID); + // make LREG_METATABLES table for all registered metatables + lua_newtable(L); + lua_setfield(L, LUA_REGISTRYINDEX, LREG_METATABLES); + // open srb2 libraries for(i = 0; liblist[i]; i++) { lua_pushcfunction(L, liblist[i]); @@ -1269,8 +1273,22 @@ static void ArchiveTables(void) lua_pop(gL, 1); } - lua_pop(gL, 1); WRITEUINT8(save_p, ARCH_TEND); + + // Write metatable ID + if (lua_getmetatable(gL, -1)) + { + // registry.metatables[metatable] + lua_getfield(gL, LUA_REGISTRYINDEX, LREG_METATABLES); + lua_pushvalue(gL, -2); + lua_gettable(gL, -2); + WRITEUINT16(save_p, lua_isnil(gL, -1) ? 0 : lua_tointeger(gL, -1)); + lua_pop(gL, 3); + } + else + WRITEUINT16(save_p, 0); + + lua_pop(gL, 1); } } @@ -1438,6 +1456,7 @@ static void UnArchiveTables(void) { int TABLESINDEX; UINT16 i, n; + UINT16 metatableid; if (!gL) return; @@ -1462,6 +1481,19 @@ static void UnArchiveTables(void) else lua_rawset(gL, -3); } + + metatableid = READUINT16(save_p); + if (metatableid) + { + // setmetatable(table, registry.metatables[metatableid]) + lua_getfield(gL, LUA_REGISTRYINDEX, LREG_METATABLES); + lua_rawgeti(gL, -1, metatableid); + if (lua_isnil(gL, -1)) + I_Error("Unknown metatable ID %d\n", metatableid); + lua_setmetatable(gL, -3); + lua_pop(gL, 1); + } + lua_pop(gL, 1); } } From 684b868524e984b6db6ff8e988aaf20a4644b575 Mon Sep 17 00:00:00 2001 From: Hannu Hanhi Date: Sat, 3 Oct 2020 18:45:56 +0300 Subject: [PATCH 0122/1080] Add error message when the GDI Generic OpenGL renderer is encountered in Windows --- src/sdl/ogl_sdl.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/sdl/ogl_sdl.c b/src/sdl/ogl_sdl.c index edc69b21d..04214ad03 100644 --- a/src/sdl/ogl_sdl.c +++ b/src/sdl/ogl_sdl.c @@ -167,6 +167,18 @@ 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: %s\n", gl_extensions); + + if (strcmp((const char*)gl_renderer, "GDI Generic") == 0 && + strcmp((const char*)gl_version, "1.1.0") == 0) + { + // Oh no... Windows gave us the GDI Generic rasterizer, so something is wrong... + // The game will crash later on when unsupported OpenGL commands are encountered. + // Instead of a nondescript crash, show a more informative error message. + // Also set the renderer variable back to software so the next launch won't + // repeat this error. + CV_StealthSet(&cv_renderer, "Software"); + I_Error("OpenGL Error: Failed to access the GPU. There may be an issue with your graphics drivers."); + } } first_init = true; From e49032eaf74331162ad491963fe99ce9d4a979a4 Mon Sep 17 00:00:00 2001 From: Louis-Antoine Date: Sat, 3 Oct 2020 18:40:37 +0200 Subject: [PATCH 0123/1080] Let Lua scripts access userdata metatables --- src/lua_baselib.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 6bdc65786..6f9bcbb23 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -240,7 +240,7 @@ static int lib_userdataType(lua_State *L) // Takes a metatable as first and only argument // Only callable during script loading -static int lib_registermetatable(lua_State *L) +static int lib_registerMetatable(lua_State *L) { static UINT32 nextid = 1; @@ -265,6 +265,16 @@ static int lib_registermetatable(lua_State *L) return 0; } +// Takes a string as only argument and returns the metatable +// associated to the userdata type this string refers to +// Returns nil if the string does not refer to a valid userdata type +static int lib_userdataMetatable(lua_State *L) +{ + const char *udname = luaL_checkstring(L, 1); + luaL_getmetatable(L, udname); + return 1; +} + static int lib_isPlayerAdmin(lua_State *L) { player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); @@ -3460,7 +3470,8 @@ static luaL_Reg lib[] = { {"chatprint", lib_chatprint}, {"chatprintf", lib_chatprintf}, {"userdataType", lib_userdataType}, - {"registermetatable", lib_registermetatable}, + {"registerMetatable", lib_registerMetatable}, + {"userdataMetatable", lib_userdataMetatable}, {"IsPlayerAdmin", lib_isPlayerAdmin}, {"reserveLuabanks", lib_reserveLuabanks}, From 2ae5c020501274b26e309f7f75de8f727a97254d Mon Sep 17 00:00:00 2001 From: GoldenTails Date: Sat, 3 Oct 2020 13:24:47 -0500 Subject: [PATCH 0124/1080] Fix some theoretical crashes when using the P_*XYMovement, P_*ZMovement, and P_RailThinker functions. --- src/lua_baselib.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 6b25e32ea..3979d3e39 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -910,44 +910,52 @@ static int lib_pMaceRotate(lua_State *L) static int lib_pRailThinker(lua_State *L) { mobj_t *mobj = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); + mobj_t *ptmthing = tmthing; NOHUD INLEVEL if (!mobj) return LUA_ErrInvalid(L, "mobj_t"); lua_pushboolean(L, P_RailThinker(mobj)); + P_SetTarget(&tmthing, ptmthing); return 1; } static int lib_pXYMovement(lua_State *L) { mobj_t *actor = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); + mobj_t *ptmthing = tmthing; NOHUD INLEVEL if (!actor) return LUA_ErrInvalid(L, "mobj_t"); P_XYMovement(actor); + P_SetTarget(&tmthing, ptmthing); return 0; } static int lib_pRingXYMovement(lua_State *L) { mobj_t *actor = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); + mobj_t *ptmthing = tmthing; NOHUD INLEVEL if (!actor) return LUA_ErrInvalid(L, "mobj_t"); P_RingXYMovement(actor); + P_SetTarget(&tmthing, ptmthing); return 0; } static int lib_pSceneryXYMovement(lua_State *L) { mobj_t *actor = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); + mobj_t *ptmthing = tmthing; NOHUD INLEVEL if (!actor) return LUA_ErrInvalid(L, "mobj_t"); P_SceneryXYMovement(actor); + P_SetTarget(&tmthing, ptmthing); return 0; } @@ -959,6 +967,7 @@ static int lib_pZMovement(lua_State *L) if (!actor) return LUA_ErrInvalid(L, "mobj_t"); lua_pushboolean(L, P_ZMovement(actor)); + P_CheckPosition(actor, actor->x, actor->y); return 1; } @@ -970,6 +979,7 @@ static int lib_pRingZMovement(lua_State *L) if (!actor) return LUA_ErrInvalid(L, "mobj_t"); P_RingZMovement(actor); + P_CheckPosition(actor, actor->x, actor->y); return 0; } @@ -981,6 +991,7 @@ static int lib_pSceneryZMovement(lua_State *L) if (!actor) return LUA_ErrInvalid(L, "mobj_t"); lua_pushboolean(L, P_SceneryZMovement(actor)); + P_CheckPosition(actor, actor->x, actor->y); return 1; } @@ -992,6 +1003,7 @@ static int lib_pPlayerZMovement(lua_State *L) if (!actor) return LUA_ErrInvalid(L, "mobj_t"); P_PlayerZMovement(actor); + P_CheckPosition(actor, actor->x, actor->y); return 0; } From 0aa1b16fd1bd3462290461775fd07aec65c2d3be Mon Sep 17 00:00:00 2001 From: Steel Titanium Date: Sat, 3 Oct 2020 19:53:59 -0400 Subject: [PATCH 0125/1080] Provide a default exe manifest --- src/win32/Srb2win.rc | 10 ++++++++++ src/win32/srb2win.exe.manifest | 22 ++++++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 src/win32/srb2win.exe.manifest diff --git a/src/win32/Srb2win.rc b/src/win32/Srb2win.rc index 5ba366bda..d5d59922c 100644 --- a/src/win32/Srb2win.rc +++ b/src/win32/Srb2win.rc @@ -22,6 +22,16 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US #pragma code_page(1252) #endif //_WIN32*/ +#ifndef RT_MANIFEST +#define RT_MANIFEST 24 +#endif + +#ifndef CREATEPROCESS_MANIFEST_RESOURCE_ID +#define CREATEPROCESS_MANIFEST_RESOURCE_ID 1 +#endif + +CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST srb2win.exe.manifest + ///////////////////////////////////////////////////////////////////////////// // // Icon diff --git a/src/win32/srb2win.exe.manifest b/src/win32/srb2win.exe.manifest new file mode 100644 index 000000000..d3b8355cb --- /dev/null +++ b/src/win32/srb2win.exe.manifest @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + From 2cc8de2bdd33c8f3475481568d4d57184dc6b802 Mon Sep 17 00:00:00 2001 From: gm3k4g Date: Mon, 5 Oct 2020 00:12:13 +0300 Subject: [PATCH 0126/1080] Added splitscreen command line parameter --- src/d_main.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/d_main.c b/src/d_main.c index d1a414018..c4cde87a3 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -1589,6 +1589,12 @@ void D_SRB2Main(void) ultimatemode = true; } + if (M_CheckParm("-splitscreen")) + { + autostart = true; + splitscreen = true; + } + // rei/miru: bootmap (Idea: starts the game on a predefined map) if (bootmap && !(M_CheckParm("-warp") && M_IsNextParm())) { From 0b74818771acd338302c39dabedc3b329d6b0c35 Mon Sep 17 00:00:00 2001 From: GoldenTails Date: Sun, 4 Oct 2020 21:02:20 -0500 Subject: [PATCH 0127/1080] Give the addfile command variable argument support. --- src/d_netcmd.c | 187 ++++++++++++++++++++++++++++--------------------- 1 file changed, 108 insertions(+), 79 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 4208e4c4f..a61bf0651 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -3248,97 +3248,126 @@ static void Got_RunSOCcmd(UINT8 **cp, INT32 playernum) */ static void Command_Addfile(void) { - const char *fn, *p; - char buf[256]; - char *buf_p = buf; - INT32 i; - int musiconly; // W_VerifyNMUSlumps isn't boolean + size_t argc = COM_Argc(); // amount of arguments total + size_t curarg; // current argument index - if (COM_Argc() != 2) + const char *addedfiles[argc]; // list of filenames already processed + size_t numfilesadded = 0; // the amount of filenames processed + + if (argc < 2) { CONS_Printf(M_GetText("addfile : load wad file\n")); return; } - else - fn = COM_Argv(1); - // Disallow non-printing characters and semicolons. - for (i = 0; fn[i] != '\0'; i++) - if (!isprint(fn[i]) || fn[i] == ';') - return; - - musiconly = W_VerifyNMUSlumps(fn); - - if (!musiconly) + // start at one to skip command name + for (curarg = 1; curarg < argc; curarg++) { - // ... But only so long as they contain nothing more then music and sprites. - if (netgame && !(server || IsPlayerAdmin(consoleplayer))) + const char *fn, *p; + char buf[256]; + char *buf_p = buf; + INT32 i; + int musiconly; // W_VerifyNMUSlumps isn't boolean + boolean fileadded = false; + + fn = COM_Argv(curarg); + + // For the amount of filenames previously processed... + for (size_t ii = 0; ii < numfilesadded; ii++) { - CONS_Printf(M_GetText("Only the server or a remote admin can use this.\n")); - return; - } - G_SetGameModified(multiplayer); - } - - // Add file on your client directly if it is trivial, or you aren't in a netgame. - if (!(netgame || multiplayer) || musiconly) - { - P_AddWadFile(fn); - return; - } - - p = fn+strlen(fn); - while(--p >= fn) - if (*p == '\\' || *p == '/' || *p == ':') - break; - ++p; - - // check total packet size and no of files currently loaded - // See W_LoadWadFile in w_wad.c - if ((numwadfiles >= MAX_WADFILES) - || ((packetsizetally + nameonlylength(fn) + 22) > MAXFILENEEDED*sizeof(UINT8))) - { - CONS_Alert(CONS_ERROR, M_GetText("Too many files loaded to add %s\n"), fn); - return; - } - - WRITESTRINGN(buf_p,p,240); - - // calculate and check md5 - { - UINT8 md5sum[16]; -#ifdef NOMD5 - memset(md5sum,0,16); -#else - FILE *fhandle; - - if ((fhandle = W_OpenWadFile(&fn, true)) != NULL) - { - tic_t t = I_GetTime(); - CONS_Debug(DBG_SETUP, "Making MD5 for %s\n",fn); - md5_stream(fhandle, md5sum); - CONS_Debug(DBG_SETUP, "MD5 calc for %s took %f second\n", fn, (float)(I_GetTime() - t)/TICRATE); - fclose(fhandle); - } - else // file not found - return; - - for (i = 0; i < numwadfiles; i++) - { - if (!memcmp(wadfiles[i]->md5sum, md5sum, 16)) + // If this is one of them, don't try to add it. + if (!strcmp(fn, addedfiles[ii])) { - CONS_Alert(CONS_ERROR, M_GetText("%s is already loaded\n"), fn); - return; + fileadded = true; + break; } } -#endif - WRITEMEM(buf_p, md5sum, 16); - } - if (IsPlayerAdmin(consoleplayer) && (!server)) // Request to add file - SendNetXCmd(XD_REQADDFILE, buf, buf_p - buf); - else - SendNetXCmd(XD_ADDFILE, buf, buf_p - buf); + // If we've added this one, skip to the next one. + if (fileadded) + continue; + + // Disallow non-printing characters and semicolons. + for (i = 0; fn[i] != '\0'; i++) + if (!isprint(fn[i]) || fn[i] == ';') + return; + + musiconly = W_VerifyNMUSlumps(fn); + + if (!musiconly) + { + // ... But only so long as they contain nothing more then music and sprites. + if (netgame && !(server || IsPlayerAdmin(consoleplayer))) + { + CONS_Printf(M_GetText("Only the server or a remote admin can use this.\n")); + continue; + } + G_SetGameModified(multiplayer); + } + + // Add file on your client directly if it is trivial, or you aren't in a netgame. + if (!(netgame || multiplayer) || musiconly) + { + P_AddWadFile(fn); + addedfiles[numfilesadded++] = fn; + continue; + } + + p = fn+strlen(fn); + while(--p >= fn) + if (*p == '\\' || *p == '/' || *p == ':') + break; + ++p; + + // check total packet size and no of files currently loaded + // See W_LoadWadFile in w_wad.c + if ((numwadfiles >= MAX_WADFILES) + || ((packetsizetally + nameonlylength(fn) + 22) > MAXFILENEEDED*sizeof(UINT8))) + { + CONS_Alert(CONS_ERROR, M_GetText("Too many files loaded to add %s\n"), fn); + return; + } + + WRITESTRINGN(buf_p,p,240); + + // calculate and check md5 + { + UINT8 md5sum[16]; +#ifdef NOMD5 + memset(md5sum,0,16); +#else + FILE *fhandle; + + if ((fhandle = W_OpenWadFile(&fn, true)) != NULL) + { + tic_t t = I_GetTime(); + CONS_Debug(DBG_SETUP, "Making MD5 for %s\n",fn); + md5_stream(fhandle, md5sum); + CONS_Debug(DBG_SETUP, "MD5 calc for %s took %f second\n", fn, (float)(I_GetTime() - t)/TICRATE); + fclose(fhandle); + } + else // file not found + continue; + + for (i = 0; i < numwadfiles; i++) + { + if (!memcmp(wadfiles[i]->md5sum, md5sum, 16)) + { + CONS_Alert(CONS_ERROR, M_GetText("%s is already loaded\n"), fn); + continue; + } + } +#endif + WRITEMEM(buf_p, md5sum, 16); + } + + addedfiles[numfilesadded++] = fn; + + if (IsPlayerAdmin(consoleplayer) && (!server)) // Request to add file + SendNetXCmd(XD_REQADDFILE, buf, buf_p - buf); + else + SendNetXCmd(XD_ADDFILE, buf, buf_p - buf); + } } static void Got_RequestAddfilecmd(UINT8 **cp, INT32 playernum) From 2d3a58916717fa45b98c7e7f694b3fd619e7ec6f Mon Sep 17 00:00:00 2001 From: GoldenTails Date: Sun, 4 Oct 2020 21:03:29 -0500 Subject: [PATCH 0128/1080] Add warning when files are skipped due to being previously processed. --- src/d_netcmd.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index a61bf0651..9de6b2844 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -3285,7 +3285,10 @@ static void Command_Addfile(void) // If we've added this one, skip to the next one. if (fileadded) + { + CONS_Alert(CONS_WARNING, M_GetText("Already processed %s, skipping\n"), fn); continue; + } // Disallow non-printing characters and semicolons. for (i = 0; fn[i] != '\0'; i++) From d5848e78fc640cff8f98b21cc989a86521acf41c Mon Sep 17 00:00:00 2001 From: GoldenTails Date: Tue, 6 Oct 2020 03:37:23 -0500 Subject: [PATCH 0129/1080] Update help message to mention supported file extensions, and change the description to "Load add-ons" --- 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 9de6b2844..a96ea1a90 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -3256,7 +3256,7 @@ static void Command_Addfile(void) if (argc < 2) { - CONS_Printf(M_GetText("addfile : load wad file\n")); + CONS_Printf(M_GetText("addfile [filename2...] [...]: Load add-ons\n")); return; } From 48ca58f580ee85d7d40d60e54d1eff4ed5e72837 Mon Sep 17 00:00:00 2001 From: sphere Date: Tue, 6 Oct 2020 16:49:53 +0200 Subject: [PATCH 0130/1080] Don't count demo playback as visiting a level. --- 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 996e9ec30..b5164e558 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -4187,7 +4187,7 @@ boolean P_LoadLevel(boolean fromnetsave) nextmapoverride = 0; skipstats = 0; - if (!(netgame || multiplayer) && (!modifiedgame || savemoddata)) + if (!(netgame || multiplayer || demoplayback) && (!modifiedgame || savemoddata)) mapvisited[gamemap-1] |= MV_VISITED; else mapvisited[gamemap-1] |= MV_MP; // you want to record that you've been there this session, but not permanently From f210316d8a0540e0738565c3e4abe6a74effa597 Mon Sep 17 00:00:00 2001 From: sphere Date: Tue, 6 Oct 2020 19:06:06 +0200 Subject: [PATCH 0131/1080] Only set MV_MP in multiplayer or a netgame. --- 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 b5164e558..55840a0f2 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -4189,7 +4189,7 @@ boolean P_LoadLevel(boolean fromnetsave) if (!(netgame || multiplayer || demoplayback) && (!modifiedgame || savemoddata)) mapvisited[gamemap-1] |= MV_VISITED; - else + else if (netgame || multiplayer) mapvisited[gamemap-1] |= MV_MP; // you want to record that you've been there this session, but not permanently levelloading = false; From e393093e73a5ca87da4d5ee4da81152893e3b39c Mon Sep 17 00:00:00 2001 From: Zachary McAlpin Date: Tue, 6 Oct 2020 16:43:14 -0500 Subject: [PATCH 0132/1080] Update comment --- src/g_game.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index ea9a561be..7e4bf4fa7 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1677,10 +1677,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) } } - /* Note: Lat originally made the PlayerCmd hook for SRB2 Kart so credit goes to him. - Also, unlike in SRB2 Kart, the cmd's variables cannot be set using the PlayerCmd, because - it is recommended to use the PreThinkFrame to set the cmd's variables, because PreThinkFrame is actually synched, - unlike the PlayerCmd hook. */ + // Note: Lat originally made the PlayerCmd hook for SRB2 Kart so credit goes to him. if (gamestate == GS_LEVEL) LUAh_PlayerCmd(player, cmd); From 0f3c87a70564626d3c3d214ea0456073890b9929 Mon Sep 17 00:00:00 2001 From: Zachary McAlpin Date: Tue, 6 Oct 2020 16:54:23 -0500 Subject: [PATCH 0133/1080] Made states unmodifable in CMD building code --- src/lua_infolib.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/lua_infolib.c b/src/lua_infolib.c index c98aa57d1..5e5a1dbc4 100644 --- a/src/lua_infolib.c +++ b/src/lua_infolib.c @@ -919,6 +919,8 @@ static int state_set(lua_State *L) if (hud_running) return luaL_error(L, "Do not alter states in HUD rendering code!"); + if (hook_cmd_running) + return luaL_error(L, "Do not alter states in CMD building code!"); if (fastcmp(field,"sprite")) { value = luaL_checknumber(L, 3); From dbd79a29a4a87ed6b21e609425dbaa66e81bddb8 Mon Sep 17 00:00:00 2001 From: James R Date: Tue, 6 Oct 2020 23:04:23 -0700 Subject: [PATCH 0134/1080] Replace C90's junk with a modest macro --- src/android/i_cdmus.c | 4 +- src/android/i_video.c | 2 +- src/command.c | 2 +- src/command.h | 4 + src/console.c | 12 +-- src/d_clisrv.c | 28 +++---- src/d_netcmd.c | 185 ++++++++++++++++++++--------------------- src/dummy/i_cdmus.c | 4 +- src/dummy/i_video.c | 2 +- src/filesrch.c | 12 +-- src/g_game.c | 126 ++++++++++++++-------------- src/g_input.c | 10 +-- src/hardware/hw_main.c | 40 +++++---- src/http-mserv.c | 25 +++--- src/m_anigif.c | 8 +- src/m_cheat.c | 8 +- src/m_menu.c | 42 +++++----- src/m_misc.c | 30 +++---- src/mserv.c | 6 +- src/p_mobj.c | 10 +-- src/p_user.c | 52 ++++++------ src/r_main.c | 38 ++++----- src/s_sound.c | 40 ++++----- src/screen.c | 12 +-- src/sdl/i_video.c | 6 +- src/sdl/mixer_sound.c | 6 +- src/v_video.c | 44 +++++----- src/win32/win_cd.c | 4 +- src/win32/win_sys.c | 2 +- src/win32/win_vid.c | 6 +- 30 files changed, 384 insertions(+), 386 deletions(-) diff --git a/src/android/i_cdmus.c b/src/android/i_cdmus.c index 426bc5dc9..12063745b 100644 --- a/src/android/i_cdmus.c +++ b/src/android/i_cdmus.c @@ -8,8 +8,8 @@ UINT8 cdaudio_started = 0; -consvar_t cd_volume = {"cd_volume","18",CV_SAVE,soundvolume_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cdUpdate = {"cd_update","1",CV_SAVE, NULL, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cd_volume = CVAR_INIT ("cd_volume","18",CV_SAVE,soundvolume_cons_t, NULL); +consvar_t cdUpdate = CVAR_INIT ("cd_update","1",CV_SAVE, NULL, NULL); void I_InitCD(void){} diff --git a/src/android/i_video.c b/src/android/i_video.c index 1909cd71a..18f92955a 100644 --- a/src/android/i_video.c +++ b/src/android/i_video.c @@ -16,7 +16,7 @@ boolean allow_fullscreen = false; -consvar_t cv_vidwait = {"vid_wait", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_vidwait = CVAR_INIT ("vid_wait", "On", CV_SAVE, CV_OnOff, NULL); void I_StartupGraphics(void){} void I_ShutdownGraphics(void){} diff --git a/src/command.c b/src/command.c index f2a9813e2..59f14e2f5 100644 --- a/src/command.c +++ b/src/command.c @@ -79,7 +79,7 @@ CV_PossibleValue_t CV_Natural[] = {{1, "MIN"}, {999999999, "MAX"}, {0, NULL}}; // First implementation is 26 (2.1.21), so earlier configs default at 25 (2.1.20) // Also set CV_HIDEN during runtime, after config is loaded static boolean execversion_enabled = false; -consvar_t cv_execversion = {"execversion","25",CV_CALL,CV_Unsigned, CV_EnforceExecVersion, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_execversion = CVAR_INIT ("execversion","25",CV_CALL,CV_Unsigned, CV_EnforceExecVersion); // for default joyaxis detection static boolean joyaxis_default = false; diff --git a/src/command.h b/src/command.h index b39153a65..8275d0fd1 100644 --- a/src/command.h +++ b/src/command.h @@ -144,6 +144,10 @@ typedef struct consvar_s //NULL, NULL, 0, NULL, NULL |, 0, NULL, NULL, 0, 0, NUL struct consvar_s *next; } consvar_t; +/* name, defaultvalue, flags, PossibleValue, func */ +#define CVAR_INIT( ... ) \ +{ __VA_ARGS__, 0, NULL, NULL, 0U, (char)0, NULL } + #ifdef OLD22DEMOCOMPAT typedef struct old_demo_var old_demo_var_t; diff --git a/src/console.c b/src/console.c index 21f660a56..b0a1bd485 100644 --- a/src/console.c +++ b/src/console.c @@ -124,22 +124,22 @@ static void CONS_backcolor_Change(void); static char con_buffer[CON_BUFFERSIZE]; // how many seconds the hud messages lasts on the screen -static consvar_t cons_msgtimeout = {"con_hudtime", "5", CV_SAVE, CV_Unsigned, NULL, 0, NULL, NULL, 0, 0, NULL}; +static consvar_t cons_msgtimeout = CVAR_INIT ("con_hudtime", "5", CV_SAVE, CV_Unsigned, NULL); // number of lines displayed on the HUD -static consvar_t cons_hudlines = {"con_hudlines", "5", CV_CALL|CV_SAVE, CV_Unsigned, CONS_hudlines_Change, 0, NULL, NULL, 0, 0, NULL}; +static consvar_t cons_hudlines = CVAR_INIT ("con_hudlines", "5", CV_CALL|CV_SAVE, CV_Unsigned, CONS_hudlines_Change); // number of lines console move per frame // (con_speed needs a limit, apparently) 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}; +static consvar_t cons_speed = CVAR_INIT ("con_speed", "8", CV_SAVE, speed_cons_t, 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 = CVAR_INIT ("con_height", "50", CV_SAVE, CV_Unsigned, NULL); static CV_PossibleValue_t backpic_cons_t[] = {{0, "translucent"}, {1, "picture"}, {0, NULL}}; // whether to use console background picture, or translucent mode -static consvar_t cons_backpic = {"con_backpic", "translucent", CV_SAVE, backpic_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +static consvar_t cons_backpic = CVAR_INIT ("con_backpic", "translucent", CV_SAVE, backpic_cons_t, NULL); static CV_PossibleValue_t backcolor_cons_t[] = {{0, "White"}, {1, "Black"}, {2, "Sepia"}, {3, "Brown"}, {4, "Pink"}, {5, "Raspberry"}, @@ -151,7 +151,7 @@ static CV_PossibleValue_t backcolor_cons_t[] = {{0, "White"}, {1, "Black"}, { {0, NULL}}; -consvar_t cons_backcolor = {"con_backcolor", "Green", CV_CALL|CV_SAVE, backcolor_cons_t, CONS_backcolor_Change, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cons_backcolor = CVAR_INIT ("con_backcolor", "Green", CV_CALL|CV_SAVE, backcolor_cons_t, CONS_backcolor_Change); static void CON_Print(char *msg); diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 36e607d45..c9490410b 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -157,10 +157,10 @@ ticcmd_t netcmds[BACKUPTICS][MAXPLAYERS]; static textcmdtic_t *textcmds[TEXTCMD_HASH_SIZE] = {NULL}; -consvar_t cv_showjoinaddress = {"showjoinaddress", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_showjoinaddress = CVAR_INIT ("showjoinaddress", "Off", CV_SAVE, CV_OnOff, NULL); static CV_PossibleValue_t playbackspeed_cons_t[] = {{1, "MIN"}, {10, "MAX"}, {0, NULL}}; -consvar_t cv_playbackspeed = {"playbackspeed", "1", 0, playbackspeed_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_playbackspeed = CVAR_INIT ("playbackspeed", "1", 0, playbackspeed_cons_t, NULL); static inline void *G_DcpyTiccmd(void* dest, const ticcmd_t* src, const size_t n) { @@ -2119,7 +2119,7 @@ static void SV_SendSaveGame(INT32 node) #ifdef DUMPCONSISTENCY #define TMPSAVENAME "badmath.sav" -static consvar_t cv_dumpconsistency = {"dumpconsistency", "Off", CV_NETVAR, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +static consvar_t cv_dumpconsistency = CVAR_INIT ("dumpconsistency", "Off", CV_NETVAR, CV_OnOff, NULL); static void SV_SavedGame(void) { @@ -3675,29 +3675,29 @@ static void Got_KickCmd(UINT8 **p, INT32 playernum) } static CV_PossibleValue_t netticbuffer_cons_t[] = {{0, "MIN"}, {3, "MAX"}, {0, NULL}}; -consvar_t cv_netticbuffer = {"netticbuffer", "1", CV_SAVE, netticbuffer_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_netticbuffer = CVAR_INIT ("netticbuffer", "1", CV_SAVE, netticbuffer_cons_t, NULL); -consvar_t cv_allownewplayer = {"allowjoin", "On", CV_NETVAR, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL }; -consvar_t cv_joinnextround = {"joinnextround", "Off", CV_NETVAR, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; /// \todo not done +consvar_t cv_allownewplayer = CVAR_INIT ("allowjoin", "On", CV_NETVAR, CV_OnOff, NULL); +consvar_t cv_joinnextround = CVAR_INIT ("joinnextround", "Off", CV_NETVAR, CV_OnOff, NULL); /// \todo not done static CV_PossibleValue_t maxplayers_cons_t[] = {{2, "MIN"}, {32, "MAX"}, {0, NULL}}; -consvar_t cv_maxplayers = {"maxplayers", "8", CV_SAVE, maxplayers_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_maxplayers = CVAR_INIT ("maxplayers", "8", CV_SAVE, maxplayers_cons_t, NULL); static CV_PossibleValue_t joindelay_cons_t[] = {{1, "MIN"}, {3600, "MAX"}, {0, "Off"}, {0, NULL}}; -consvar_t cv_joindelay = {"joindelay", "10", CV_SAVE, joindelay_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_joindelay = CVAR_INIT ("joindelay", "10", CV_SAVE, joindelay_cons_t, NULL); static CV_PossibleValue_t rejointimeout_cons_t[] = {{1, "MIN"}, {60 * FRACUNIT, "MAX"}, {0, "Off"}, {0, NULL}}; -consvar_t cv_rejointimeout = {"rejointimeout", "Off", CV_SAVE|CV_FLOAT, rejointimeout_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_rejointimeout = CVAR_INIT ("rejointimeout", "Off", CV_SAVE|CV_FLOAT, rejointimeout_cons_t, NULL); static CV_PossibleValue_t resynchattempts_cons_t[] = {{1, "MIN"}, {20, "MAX"}, {0, "No"}, {0, NULL}}; -consvar_t cv_resynchattempts = {"resynchattempts", "10", CV_SAVE, resynchattempts_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL }; -consvar_t cv_blamecfail = {"blamecfail", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL }; +consvar_t cv_resynchattempts = CVAR_INIT ("resynchattempts", "10", CV_SAVE, resynchattempts_cons_t, NULL); +consvar_t cv_blamecfail = CVAR_INIT ("blamecfail", "Off", CV_SAVE, CV_OnOff, NULL); // max file size to send to a player (in kilobytes) static CV_PossibleValue_t maxsend_cons_t[] = {{0, "MIN"}, {51200, "MAX"}, {0, NULL}}; -consvar_t cv_maxsend = {"maxsend", "4096", CV_SAVE, maxsend_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_noticedownload = {"noticedownload", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_maxsend = CVAR_INIT ("maxsend", "4096", CV_SAVE, maxsend_cons_t, NULL); +consvar_t cv_noticedownload = CVAR_INIT ("noticedownload", "Off", CV_SAVE, CV_OnOff, NULL); // Speed of file downloading (in packets per tic) static CV_PossibleValue_t downloadspeed_cons_t[] = {{0, "MIN"}, {32, "MAX"}, {0, NULL}}; -consvar_t cv_downloadspeed = {"downloadspeed", "16", CV_SAVE, downloadspeed_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_downloadspeed = CVAR_INIT ("downloadspeed", "16", CV_SAVE, downloadspeed_cons_t, NULL); static void Got_AddPlayer(UINT8 **p, INT32 playernum); diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 4208e4c4f..6f4bcdb1d 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -197,186 +197,179 @@ static CV_PossibleValue_t matchboxes_cons_t[] = {{0, "Normal"}, {1, "Mystery"}, static CV_PossibleValue_t chances_cons_t[] = {{0, "MIN"}, {9, "MAX"}, {0, NULL}}; static CV_PossibleValue_t pause_cons_t[] = {{0, "Server"}, {1, "All"}, {0, NULL}}; -consvar_t cv_showinputjoy = {"showinputjoy", "Off", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_showinputjoy = CVAR_INIT ("showinputjoy", "Off", 0, CV_OnOff, NULL); #ifdef NETGAME_DEVMODE -static consvar_t cv_fishcake = {"fishcake", "Off", CV_CALL|CV_NOSHOWHELP|CV_RESTRICT, CV_OnOff, Fishcake_OnChange, 0, NULL, NULL, 0, 0, NULL}; +static consvar_t cv_fishcake = CVAR_INIT ("fishcake", "Off", CV_CALL|CV_NOSHOWHELP|CV_RESTRICT, CV_OnOff, Fishcake_OnChange); #endif -static consvar_t cv_dummyconsvar = {"dummyconsvar", "Off", CV_CALL|CV_NOSHOWHELP, CV_OnOff, - DummyConsvar_OnChange, 0, NULL, NULL, 0, 0, NULL}; +static consvar_t cv_dummyconsvar = CVAR_INIT ("dummyconsvar", "Off", CV_CALL|CV_NOSHOWHELP, CV_OnOff, DummyConsvar_OnChange); -consvar_t cv_restrictskinchange = {"restrictskinchange", "Yes", CV_NETVAR|CV_CHEAT, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_allowteamchange = {"allowteamchange", "Yes", CV_NETVAR, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_restrictskinchange = CVAR_INIT ("restrictskinchange", "Yes", CV_NETVAR|CV_CHEAT, CV_YesNo, NULL); +consvar_t cv_allowteamchange = CVAR_INIT ("allowteamchange", "Yes", CV_NETVAR, CV_YesNo, NULL); -consvar_t cv_startinglives = {"startinglives", "3", CV_NETVAR|CV_CHEAT, startingliveslimit_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_startinglives = CVAR_INIT ("startinglives", "3", CV_NETVAR|CV_CHEAT, startingliveslimit_cons_t, NULL); static CV_PossibleValue_t respawntime_cons_t[] = {{1, "MIN"}, {30, "MAX"}, {0, "Off"}, {0, NULL}}; -consvar_t cv_respawntime = {"respawndelay", "3", CV_NETVAR|CV_CHEAT, respawntime_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_respawntime = CVAR_INIT ("respawndelay", "3", CV_NETVAR|CV_CHEAT, respawntime_cons_t, NULL); -consvar_t cv_competitionboxes = {"competitionboxes", "Mystery", CV_NETVAR|CV_CHEAT, competitionboxes_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_competitionboxes = CVAR_INIT ("competitionboxes", "Mystery", CV_NETVAR|CV_CHEAT, competitionboxes_cons_t, NULL); #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", "Ally/Foe", CV_SAVE, seenames_cons_t, 0, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_allowseenames = {"allowseenames", "Yes", CV_NETVAR, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_seenames = CVAR_INIT ("seenames", "Ally/Foe", CV_SAVE, seenames_cons_t, 0); +consvar_t cv_allowseenames = CVAR_INIT ("allowseenames", "Yes", CV_NETVAR, CV_YesNo, NULL); #endif // names -consvar_t cv_playername = {"name", "Sonic", CV_SAVE|CV_CALL|CV_NOINIT, NULL, Name_OnChange, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_playername2 = {"name2", "Tails", CV_SAVE|CV_CALL|CV_NOINIT, NULL, Name2_OnChange, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_playername = CVAR_INIT ("name", "Sonic", CV_SAVE|CV_CALL|CV_NOINIT, NULL, Name_OnChange); +consvar_t cv_playername2 = CVAR_INIT ("name2", "Tails", CV_SAVE|CV_CALL|CV_NOINIT, NULL, Name2_OnChange); // player colors UINT16 lastgoodcolor = SKINCOLOR_BLUE, lastgoodcolor2 = SKINCOLOR_BLUE; -consvar_t cv_playercolor = {"color", "Blue", CV_CALL|CV_NOINIT, Color_cons_t, Color_OnChange, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_playercolor2 = {"color2", "Orange", CV_CALL|CV_NOINIT, Color_cons_t, Color2_OnChange, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_playercolor = CVAR_INIT ("color", "Blue", CV_CALL|CV_NOINIT, Color_cons_t, Color_OnChange); +consvar_t cv_playercolor2 = CVAR_INIT ("color2", "Orange", CV_CALL|CV_NOINIT, Color_cons_t, Color2_OnChange); // player's skin, saved for commodity, when using a favorite skins wad.. -consvar_t cv_skin = {"skin", DEFAULTSKIN, CV_CALL|CV_NOINIT, NULL, Skin_OnChange, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_skin2 = {"skin2", DEFAULTSKIN2, CV_CALL|CV_NOINIT, NULL, Skin2_OnChange, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_skin = CVAR_INIT ("skin", DEFAULTSKIN, CV_CALL|CV_NOINIT, NULL, Skin_OnChange); +consvar_t cv_skin2 = CVAR_INIT ("skin2", DEFAULTSKIN2, CV_CALL|CV_NOINIT, NULL, Skin2_OnChange); // saved versions of the above six -consvar_t cv_defaultplayercolor = {"defaultcolor", "Blue", CV_SAVE, Color_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_defaultplayercolor2 = {"defaultcolor2", "Orange", CV_SAVE, Color_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_defaultskin = {"defaultskin", DEFAULTSKIN, CV_SAVE, NULL, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_defaultskin2 = {"defaultskin2", DEFAULTSKIN2, CV_SAVE, NULL, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_defaultplayercolor = CVAR_INIT ("defaultcolor", "Blue", CV_SAVE, Color_cons_t, NULL); +consvar_t cv_defaultplayercolor2 = CVAR_INIT ("defaultcolor2", "Orange", CV_SAVE, Color_cons_t, NULL); +consvar_t cv_defaultskin = CVAR_INIT ("defaultskin", DEFAULTSKIN, CV_SAVE, NULL, NULL); +consvar_t cv_defaultskin2 = CVAR_INIT ("defaultskin2", DEFAULTSKIN2, CV_SAVE, NULL, NULL); -consvar_t cv_skipmapcheck = {"skipmapcheck", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_skipmapcheck = CVAR_INIT ("skipmapcheck", "Off", CV_SAVE, CV_OnOff, NULL); INT32 cv_debug; -consvar_t cv_usemouse = {"use_mouse", "On", CV_SAVE|CV_CALL,usemouse_cons_t, I_StartupMouse, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_usemouse2 = {"use_mouse2", "Off", CV_SAVE|CV_CALL,usemouse_cons_t, I_StartupMouse2, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_usemouse = CVAR_INIT ("use_mouse", "On", CV_SAVE|CV_CALL,usemouse_cons_t, I_StartupMouse); +consvar_t cv_usemouse2 = CVAR_INIT ("use_mouse2", "Off", CV_SAVE|CV_CALL,usemouse_cons_t, I_StartupMouse2); -consvar_t cv_usejoystick = {"use_gamepad", "1", CV_SAVE|CV_CALL, usejoystick_cons_t, - I_InitJoystick, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_usejoystick2 = {"use_gamepad2", "2", CV_SAVE|CV_CALL, usejoystick_cons_t, - I_InitJoystick2, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_usejoystick = CVAR_INIT ("use_gamepad", "1", CV_SAVE|CV_CALL, usejoystick_cons_t, I_InitJoystick); +consvar_t cv_usejoystick2 = CVAR_INIT ("use_gamepad2", "2", CV_SAVE|CV_CALL, usejoystick_cons_t, I_InitJoystick2); #if (defined (LJOYSTICK) || defined (HAVE_SDL)) #ifdef LJOYSTICK -consvar_t cv_joyport = {"padport", "/dev/js0", CV_SAVE, joyport_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_joyport2 = {"padport2", "/dev/js0", CV_SAVE, joyport_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; //Alam: for later +consvar_t cv_joyport = CVAR_INIT ("padport", "/dev/js0", CV_SAVE, joyport_cons_t, NULL); +consvar_t cv_joyport2 = CVAR_INIT ("padport2", "/dev/js0", CV_SAVE, joyport_cons_t, NULL); //Alam: for later #endif -consvar_t cv_joyscale = {"padscale", "1", CV_SAVE|CV_CALL, NULL, I_JoyScale, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_joyscale2 = {"padscale2", "1", CV_SAVE|CV_CALL, NULL, I_JoyScale2, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_joyscale = CVAR_INIT ("padscale", "1", CV_SAVE|CV_CALL, NULL, I_JoyScale); +consvar_t cv_joyscale2 = CVAR_INIT ("padscale2", "1", CV_SAVE|CV_CALL, NULL, I_JoyScale2); #else -consvar_t cv_joyscale = {"padscale", "1", CV_SAVE|CV_HIDEN, NULL, NULL, 0, NULL, NULL, 0, 0, NULL}; //Alam: Dummy for save -consvar_t cv_joyscale2 = {"padscale2", "1", CV_SAVE|CV_HIDEN, NULL, NULL, 0, NULL, NULL, 0, 0, NULL}; //Alam: Dummy for save +consvar_t cv_joyscale = CVAR_INIT ("padscale", "1", CV_SAVE|CV_HIDEN, NULL, NULL); //Alam: Dummy for save +consvar_t cv_joyscale2 = CVAR_INIT ("padscale2", "1", CV_SAVE|CV_HIDEN, NULL, NULL); //Alam: Dummy for save #endif #if (defined (__unix__) && !defined (MSDOS)) || defined(__APPLE__) || defined (UNIXCOMMON) -consvar_t cv_mouse2port = {"mouse2port", "/dev/gpmdata", CV_SAVE, mouse2port_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_mouse2opt = {"mouse2opt", "0", CV_SAVE, NULL, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_mouse2port = CVAR_INIT ("mouse2port", "/dev/gpmdata", CV_SAVE, mouse2port_cons_t, NULL); +consvar_t cv_mouse2opt = CVAR_INIT ("mouse2opt", "0", CV_SAVE, NULL, NULL); #else -consvar_t cv_mouse2port = {"mouse2port", "COM2", CV_SAVE, mouse2port_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_mouse2port = CVAR_INIT ("mouse2port", "COM2", CV_SAVE, mouse2port_cons_t, NULL); #endif -consvar_t cv_matchboxes = {"matchboxes", "Normal", CV_NETVAR|CV_CHEAT, matchboxes_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_specialrings = {"specialrings", "On", CV_NETVAR, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_powerstones = {"powerstones", "On", CV_NETVAR, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_matchboxes = CVAR_INIT ("matchboxes", "Normal", CV_NETVAR|CV_CHEAT, matchboxes_cons_t, NULL); +consvar_t cv_specialrings = CVAR_INIT ("specialrings", "On", CV_NETVAR, CV_OnOff, NULL); +consvar_t cv_powerstones = CVAR_INIT ("powerstones", "On", CV_NETVAR, CV_OnOff, NULL); -consvar_t cv_recycler = {"tv_recycler", "5", CV_NETVAR|CV_CHEAT, chances_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_teleporters = {"tv_teleporter", "5", CV_NETVAR|CV_CHEAT, chances_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_superring = {"tv_superring", "5", CV_NETVAR|CV_CHEAT, chances_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_supersneakers = {"tv_supersneaker", "5", CV_NETVAR|CV_CHEAT, chances_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_invincibility = {"tv_invincibility", "5", CV_NETVAR|CV_CHEAT, chances_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_jumpshield = {"tv_jumpshield", "5", CV_NETVAR|CV_CHEAT, chances_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_watershield = {"tv_watershield", "5", CV_NETVAR|CV_CHEAT, chances_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_ringshield = {"tv_ringshield", "5", CV_NETVAR|CV_CHEAT, chances_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_forceshield = {"tv_forceshield", "5", CV_NETVAR|CV_CHEAT, chances_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_bombshield = {"tv_bombshield", "5", CV_NETVAR|CV_CHEAT, chances_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_1up = {"tv_1up", "5", CV_NETVAR|CV_CHEAT, chances_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_eggmanbox = {"tv_eggman", "5", CV_NETVAR|CV_CHEAT, chances_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_recycler = CVAR_INIT ("tv_recycler", "5", CV_NETVAR|CV_CHEAT, chances_cons_t, NULL); +consvar_t cv_teleporters = CVAR_INIT ("tv_teleporter", "5", CV_NETVAR|CV_CHEAT, chances_cons_t, NULL); +consvar_t cv_superring = CVAR_INIT ("tv_superring", "5", CV_NETVAR|CV_CHEAT, chances_cons_t, NULL); +consvar_t cv_supersneakers = CVAR_INIT ("tv_supersneaker", "5", CV_NETVAR|CV_CHEAT, chances_cons_t, NULL); +consvar_t cv_invincibility = CVAR_INIT ("tv_invincibility", "5", CV_NETVAR|CV_CHEAT, chances_cons_t, NULL); +consvar_t cv_jumpshield = CVAR_INIT ("tv_jumpshield", "5", CV_NETVAR|CV_CHEAT, chances_cons_t, NULL); +consvar_t cv_watershield = CVAR_INIT ("tv_watershield", "5", CV_NETVAR|CV_CHEAT, chances_cons_t, NULL); +consvar_t cv_ringshield = CVAR_INIT ("tv_ringshield", "5", CV_NETVAR|CV_CHEAT, chances_cons_t, NULL); +consvar_t cv_forceshield = CVAR_INIT ("tv_forceshield", "5", CV_NETVAR|CV_CHEAT, chances_cons_t, NULL); +consvar_t cv_bombshield = CVAR_INIT ("tv_bombshield", "5", CV_NETVAR|CV_CHEAT, chances_cons_t, NULL); +consvar_t cv_1up = CVAR_INIT ("tv_1up", "5", CV_NETVAR|CV_CHEAT, chances_cons_t, NULL); +consvar_t cv_eggmanbox = CVAR_INIT ("tv_eggman", "5", CV_NETVAR|CV_CHEAT, chances_cons_t, NULL); -consvar_t cv_ringslinger = {"ringslinger", "No", CV_NETVAR|CV_NOSHOWHELP|CV_CALL|CV_CHEAT, CV_YesNo, - Ringslinger_OnChange, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_gravity = {"gravity", "0.5", CV_RESTRICT|CV_FLOAT|CV_CALL, NULL, Gravity_OnChange, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_ringslinger = CVAR_INIT ("ringslinger", "No", CV_NETVAR|CV_NOSHOWHELP|CV_CALL|CV_CHEAT, CV_YesNo, Ringslinger_OnChange); +consvar_t cv_gravity = CVAR_INIT ("gravity", "0.5", CV_RESTRICT|CV_FLOAT|CV_CALL, NULL, Gravity_OnChange); -consvar_t cv_soundtest = {"soundtest", "0", CV_CALL, NULL, SoundTest_OnChange, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_soundtest = CVAR_INIT ("soundtest", "0", CV_CALL, NULL, SoundTest_OnChange); static CV_PossibleValue_t minitimelimit_cons_t[] = {{15, "MIN"}, {9999, "MAX"}, {0, NULL}}; -consvar_t cv_countdowntime = {"countdowntime", "60", CV_NETVAR|CV_CHEAT, minitimelimit_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_countdowntime = CVAR_INIT ("countdowntime", "60", CV_NETVAR|CV_CHEAT, minitimelimit_cons_t, NULL); -consvar_t cv_touchtag = {"touchtag", "Off", CV_NETVAR, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_hidetime = {"hidetime", "30", CV_NETVAR|CV_CALL, minitimelimit_cons_t, Hidetime_OnChange, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_touchtag = CVAR_INIT ("touchtag", "Off", CV_NETVAR, CV_OnOff, NULL); +consvar_t cv_hidetime = CVAR_INIT ("hidetime", "30", CV_NETVAR|CV_CALL, minitimelimit_cons_t, Hidetime_OnChange); -consvar_t cv_autobalance = {"autobalance", "Off", CV_NETVAR|CV_CALL, CV_OnOff, AutoBalance_OnChange, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_teamscramble = {"teamscramble", "Off", CV_NETVAR|CV_CALL|CV_NOINIT, teamscramble_cons_t, TeamScramble_OnChange, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_scrambleonchange = {"scrambleonchange", "Off", CV_NETVAR, teamscramble_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_autobalance = CVAR_INIT ("autobalance", "Off", CV_NETVAR|CV_CALL, CV_OnOff, AutoBalance_OnChange); +consvar_t cv_teamscramble = CVAR_INIT ("teamscramble", "Off", CV_NETVAR|CV_CALL|CV_NOINIT, teamscramble_cons_t, TeamScramble_OnChange); +consvar_t cv_scrambleonchange = CVAR_INIT ("scrambleonchange", "Off", CV_NETVAR, teamscramble_cons_t, NULL); -consvar_t cv_friendlyfire = {"friendlyfire", "Off", CV_NETVAR, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_itemfinder = {"itemfinder", "Off", CV_CALL, CV_OnOff, ItemFinder_OnChange, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_friendlyfire = CVAR_INIT ("friendlyfire", "Off", CV_NETVAR, CV_OnOff, NULL); +consvar_t cv_itemfinder = CVAR_INIT ("itemfinder", "Off", CV_CALL, CV_OnOff, ItemFinder_OnChange); // Scoring type options -consvar_t cv_overtime = {"overtime", "Yes", CV_NETVAR, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_overtime = CVAR_INIT ("overtime", "Yes", CV_NETVAR, CV_YesNo, NULL); -consvar_t cv_rollingdemos = {"rollingdemos", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_rollingdemos = CVAR_INIT ("rollingdemos", "On", CV_SAVE, CV_OnOff, NULL); static CV_PossibleValue_t timetic_cons_t[] = {{0, "Classic"}, {1, "Centiseconds"}, {2, "Mania"}, {3, "Tics"}, {0, NULL}}; -consvar_t cv_timetic = {"timerres", "Classic", CV_SAVE, timetic_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_timetic = CVAR_INIT ("timerres", "Classic", CV_SAVE, timetic_cons_t, NULL); static CV_PossibleValue_t powerupdisplay_cons_t[] = {{0, "Never"}, {1, "First-person only"}, {2, "Always"}, {0, NULL}}; -consvar_t cv_powerupdisplay = {"powerupdisplay", "First-person only", CV_SAVE, powerupdisplay_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_powerupdisplay = CVAR_INIT ("powerupdisplay", "First-person only", CV_SAVE, powerupdisplay_cons_t, NULL); static CV_PossibleValue_t pointlimit_cons_t[] = {{1, "MIN"}, {MAXSCORE, "MAX"}, {0, "None"}, {0, NULL}}; -consvar_t cv_pointlimit = {"pointlimit", "None", CV_NETVAR|CV_CALL|CV_NOINIT, pointlimit_cons_t, - PointLimit_OnChange, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_pointlimit = CVAR_INIT ("pointlimit", "None", CV_NETVAR|CV_CALL|CV_NOINIT, pointlimit_cons_t, PointLimit_OnChange); static CV_PossibleValue_t timelimit_cons_t[] = {{1, "MIN"}, {30, "MAX"}, {0, "None"}, {0, NULL}}; -consvar_t cv_timelimit = {"timelimit", "None", CV_NETVAR|CV_CALL|CV_NOINIT, timelimit_cons_t, - TimeLimit_OnChange, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_timelimit = CVAR_INIT ("timelimit", "None", CV_NETVAR|CV_CALL|CV_NOINIT, timelimit_cons_t, TimeLimit_OnChange); static CV_PossibleValue_t numlaps_cons_t[] = {{1, "MIN"}, {50, "MAX"}, {0, NULL}}; -consvar_t cv_numlaps = {"numlaps", "4", CV_NETVAR|CV_CALL|CV_NOINIT, numlaps_cons_t, - NumLaps_OnChange, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_numlaps = CVAR_INIT ("numlaps", "4", CV_NETVAR|CV_CALL|CV_NOINIT, numlaps_cons_t, NumLaps_OnChange); static CV_PossibleValue_t basenumlaps_cons_t[] = {{1, "MIN"}, {50, "MAX"}, {0, "Map default"}, {0, NULL}}; -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_basenumlaps = CVAR_INIT ("basenumlaps", "Map default", CV_NETVAR|CV_CALL|CV_CHEAT, basenumlaps_cons_t, BaseNumLaps_OnChange); // Point and time limits for every gametype INT32 pointlimits[NUMGAMETYPES]; INT32 timelimits[NUMGAMETYPES]; // log elemental hazards -- not a netvar, is local to current player -consvar_t cv_hazardlog = {"hazardlog", "Yes", 0, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_hazardlog = CVAR_INIT ("hazardlog", "Yes", 0, CV_YesNo, NULL); -consvar_t cv_forceskin = {"forceskin", "None", CV_NETVAR|CV_CALL|CV_CHEAT, NULL, ForceSkin_OnChange, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_downloading = {"downloading", "On", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_allowexitlevel = {"allowexitlevel", "No", CV_NETVAR, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_forceskin = CVAR_INIT ("forceskin", "None", CV_NETVAR|CV_CALL|CV_CHEAT, NULL, ForceSkin_OnChange); +consvar_t cv_downloading = CVAR_INIT ("downloading", "On", 0, CV_OnOff, NULL); +consvar_t cv_allowexitlevel = CVAR_INIT ("allowexitlevel", "No", CV_NETVAR, CV_YesNo, NULL); -consvar_t cv_killingdead = {"killingdead", "Off", CV_NETVAR, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_killingdead = CVAR_INIT ("killingdead", "Off", CV_NETVAR, CV_OnOff, NULL); -consvar_t cv_netstat = {"netstat", "Off", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; // show bandwidth statistics +consvar_t cv_netstat = CVAR_INIT ("netstat", "Off", 0, CV_OnOff, NULL); // show bandwidth statistics static CV_PossibleValue_t nettimeout_cons_t[] = {{TICRATE/7, "MIN"}, {60*TICRATE, "MAX"}, {0, NULL}}; -consvar_t cv_nettimeout = {"nettimeout", "350", CV_CALL|CV_SAVE, nettimeout_cons_t, NetTimeout_OnChange, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_nettimeout = CVAR_INIT ("nettimeout", "350", CV_CALL|CV_SAVE, nettimeout_cons_t, NetTimeout_OnChange); static CV_PossibleValue_t jointimeout_cons_t[] = {{5*TICRATE, "MIN"}, {60*TICRATE, "MAX"}, {0, NULL}}; -consvar_t cv_jointimeout = {"jointimeout", "350", CV_CALL|CV_SAVE, jointimeout_cons_t, JoinTimeout_OnChange, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_maxping = {"maxping", "0", CV_SAVE, CV_Unsigned, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_jointimeout = CVAR_INIT ("jointimeout", "350", CV_CALL|CV_SAVE, jointimeout_cons_t, JoinTimeout_OnChange); +consvar_t cv_maxping = CVAR_INIT ("maxping", "0", CV_SAVE, CV_Unsigned, NULL); static CV_PossibleValue_t pingtimeout_cons_t[] = {{8, "MIN"}, {120, "MAX"}, {0, NULL}}; -consvar_t cv_pingtimeout = {"pingtimeout", "10", CV_SAVE, pingtimeout_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_pingtimeout = CVAR_INIT ("pingtimeout", "10", CV_SAVE, pingtimeout_cons_t, NULL); // show your ping on the HUD next to framerate. Defaults to warning only (shows up if your ping is > maxping) static CV_PossibleValue_t showping_cons_t[] = {{0, "Off"}, {1, "Always"}, {2, "Warning"}, {0, NULL}}; -consvar_t cv_showping = {"showping", "Warning", CV_SAVE, showping_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_showping = CVAR_INIT ("showping", "Warning", CV_SAVE, showping_cons_t, NULL); // Intermission time Tails 04-19-2002 static CV_PossibleValue_t inttime_cons_t[] = {{0, "MIN"}, {3600, "MAX"}, {0, NULL}}; -consvar_t cv_inttime = {"inttime", "10", CV_NETVAR, inttime_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_inttime = CVAR_INIT ("inttime", "10", CV_NETVAR, inttime_cons_t, NULL); static CV_PossibleValue_t coopstarposts_cons_t[] = {{0, "Per-player"}, {1, "Shared"}, {2, "Teamwork"}, {0, NULL}}; -consvar_t cv_coopstarposts = {"coopstarposts", "Per-player", CV_NETVAR|CV_CALL, coopstarposts_cons_t, CoopStarposts_OnChange, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_coopstarposts = CVAR_INIT ("coopstarposts", "Per-player", CV_NETVAR|CV_CALL, coopstarposts_cons_t, CoopStarposts_OnChange); static CV_PossibleValue_t cooplives_cons_t[] = {{0, "Infinite"}, {1, "Per-player"}, {2, "Avoid Game Over"}, {3, "Single pool"}, {0, NULL}}; -consvar_t cv_cooplives = {"cooplives", "Avoid Game Over", CV_NETVAR|CV_CALL|CV_CHEAT, cooplives_cons_t, CoopLives_OnChange, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_cooplives = CVAR_INIT ("cooplives", "Avoid Game Over", CV_NETVAR|CV_CALL|CV_CHEAT, cooplives_cons_t, CoopLives_OnChange); static CV_PossibleValue_t advancemap_cons_t[] = {{0, "Off"}, {1, "Next"}, {2, "Random"}, {0, NULL}}; -consvar_t cv_advancemap = {"advancemap", "Next", CV_NETVAR, advancemap_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_advancemap = CVAR_INIT ("advancemap", "Next", CV_NETVAR, advancemap_cons_t, NULL); static CV_PossibleValue_t playersforexit_cons_t[] = {{0, "One"}, {1, "1/4"}, {2, "Half"}, {3, "3/4"}, {4, "All"}, {0, NULL}}; -consvar_t cv_playersforexit = {"playersforexit", "All", CV_NETVAR, playersforexit_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_playersforexit = CVAR_INIT ("playersforexit", "All", CV_NETVAR, playersforexit_cons_t, NULL); -consvar_t cv_exitmove = {"exitmove", "On", CV_NETVAR|CV_CALL, CV_OnOff, ExitMove_OnChange, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_exitmove = CVAR_INIT ("exitmove", "On", CV_NETVAR|CV_CALL, CV_OnOff, ExitMove_OnChange); -consvar_t cv_runscripts = {"runscripts", "Yes", 0, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_runscripts = CVAR_INIT ("runscripts", "Yes", 0, CV_YesNo, NULL); -consvar_t cv_pause = {"pausepermission", "Server", CV_NETVAR, pause_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_mute = {"mute", "Off", CV_NETVAR|CV_CALL, CV_OnOff, Mute_OnChange, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_pause = CVAR_INIT ("pausepermission", "Server", CV_NETVAR, pause_cons_t, NULL); +consvar_t cv_mute = CVAR_INIT ("mute", "Off", CV_NETVAR|CV_CALL, CV_OnOff, Mute_OnChange); -consvar_t cv_sleep = {"cpusleep", "1", CV_SAVE, sleeping_cons_t, NULL, -1, NULL, NULL, 0, 0, NULL}; +consvar_t cv_sleep = CVAR_INIT ("cpusleep", "1", CV_SAVE, sleeping_cons_t, NULL); char timedemo_name[256]; boolean timedemo_csv; diff --git a/src/dummy/i_cdmus.c b/src/dummy/i_cdmus.c index fc35eb9cf..94b8fa30e 100644 --- a/src/dummy/i_cdmus.c +++ b/src/dummy/i_cdmus.c @@ -8,8 +8,8 @@ UINT8 cdaudio_started = 0; -consvar_t cd_volume = {"cd_volume","31",CV_SAVE,soundvolume_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cdUpdate = {"cd_update","1",CV_SAVE, NULL, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cd_volume = CVAR_INIT ("cd_volume","31",CV_SAVE,soundvolume_cons_t, NULL); +consvar_t cdUpdate = CVAR_INIT ("cd_update","1",CV_SAVE, NULL, NULL); void I_InitCD(void){} diff --git a/src/dummy/i_video.c b/src/dummy/i_video.c index 56ead3672..2b0478220 100644 --- a/src/dummy/i_video.c +++ b/src/dummy/i_video.c @@ -8,7 +8,7 @@ boolean highcolor = false; boolean allow_fullscreen = false; -consvar_t cv_vidwait = {"vid_wait", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_vidwait = CVAR_INIT ("vid_wait", "On", CV_SAVE, CV_OnOff, NULL); void I_StartupGraphics(void){} void I_ShutdownGraphics(void){} diff --git a/src/filesrch.c b/src/filesrch.c index 13d73b6f4..cb53d07be 100644 --- a/src/filesrch.c +++ b/src/filesrch.c @@ -312,18 +312,18 @@ static CV_PossibleValue_t addons_cons_t[] = {{0, "Default"}, #endif {3, "CUSTOM"}, {0, NULL}}; -consvar_t cv_addons_option = {"addons_option", "Default", CV_SAVE|CV_CALL, addons_cons_t, Addons_option_Onchange, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_addons_folder = {"addons_folder", "", CV_SAVE, NULL, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_addons_option = CVAR_INIT ("addons_option", "Default", CV_SAVE|CV_CALL, addons_cons_t, Addons_option_Onchange); +consvar_t cv_addons_folder = CVAR_INIT ("addons_folder", "", CV_SAVE, NULL, NULL); static CV_PossibleValue_t addons_md5_cons_t[] = {{0, "Name"}, {1, "Contents"}, {0, NULL}}; -consvar_t cv_addons_md5 = {"addons_md5", "Name", CV_SAVE, addons_md5_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_addons_md5 = CVAR_INIT ("addons_md5", "Name", CV_SAVE, addons_md5_cons_t, NULL); -consvar_t cv_addons_showall = {"addons_showall", "No", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_addons_showall = CVAR_INIT ("addons_showall", "No", CV_SAVE, CV_YesNo, NULL); -consvar_t cv_addons_search_case = {"addons_search_case", "No", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_addons_search_case = CVAR_INIT ("addons_search_case", "No", CV_SAVE, CV_YesNo, NULL); static CV_PossibleValue_t addons_search_type_cons_t[] = {{0, "Start"}, {1, "Anywhere"}, {0, NULL}}; -consvar_t cv_addons_search_type = {"addons_search_type", "Anywhere", CV_SAVE, addons_search_type_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_addons_search_type = CVAR_INIT ("addons_search_type", "Anywhere", CV_SAVE, addons_search_type_cons_t, NULL); char menupath[1024]; size_t menupathindex[menudepth]; diff --git a/src/g_game.c b/src/g_game.c index ed39124e6..30f4a7320 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -297,100 +297,100 @@ static CV_PossibleValue_t joyaxis_cons_t[] = {{0, "None"}, // don't mind me putting these here, I was lazy to figure out where else I could put those without blowing up the compiler. // it automatically becomes compact with 20+ players, but if you like it, I guess you can turn that on! -consvar_t cv_compactscoreboard= {"compactscoreboard", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_compactscoreboard= CVAR_INIT ("compactscoreboard", "Off", CV_SAVE, CV_OnOff, NULL); // chat timer thingy static CV_PossibleValue_t chattime_cons_t[] = {{5, "MIN"}, {999, "MAX"}, {0, NULL}}; -consvar_t cv_chattime = {"chattime", "8", CV_SAVE, chattime_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_chattime = CVAR_INIT ("chattime", "8", CV_SAVE, chattime_cons_t, NULL); // chatwidth static CV_PossibleValue_t chatwidth_cons_t[] = {{64, "MIN"}, {300, "MAX"}, {0, NULL}}; -consvar_t cv_chatwidth = {"chatwidth", "150", CV_SAVE, chatwidth_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_chatwidth = CVAR_INIT ("chatwidth", "150", CV_SAVE, chatwidth_cons_t, NULL); // chatheight static CV_PossibleValue_t chatheight_cons_t[] = {{6, "MIN"}, {22, "MAX"}, {0, NULL}}; -consvar_t cv_chatheight= {"chatheight", "8", CV_SAVE, chatheight_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_chatheight= CVAR_INIT ("chatheight", "8", CV_SAVE, chatheight_cons_t, NULL); // chat notifications (do you want to hear beeps? I'd understand if you didn't.) -consvar_t cv_chatnotifications= {"chatnotifications", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_chatnotifications= CVAR_INIT ("chatnotifications", "On", CV_SAVE, CV_OnOff, NULL); // chat spam protection (why would you want to disable that???) -consvar_t cv_chatspamprotection= {"chatspamprotection", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_chatspamprotection= CVAR_INIT ("chatspamprotection", "On", CV_SAVE, CV_OnOff, NULL); // minichat text background -consvar_t cv_chatbacktint = {"chatbacktint", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_chatbacktint = CVAR_INIT ("chatbacktint", "On", CV_SAVE, CV_OnOff, NULL); // old shit console chat. (mostly exists for stuff like terminal, not because I cared if anyone liked the old chat.) static CV_PossibleValue_t consolechat_cons_t[] = {{0, "Window"}, {1, "Console"}, {2, "Window (Hidden)"}, {0, NULL}}; -consvar_t cv_consolechat = {"chatmode", "Window", CV_SAVE, consolechat_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_consolechat = CVAR_INIT ("chatmode", "Window", CV_SAVE, consolechat_cons_t, NULL); // Pause game upon window losing focus -consvar_t cv_pauseifunfocused = {"pauseifunfocused", "Yes", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_pauseifunfocused = CVAR_INIT ("pauseifunfocused", "Yes", CV_SAVE, CV_YesNo, NULL); -consvar_t cv_crosshair = {"crosshair", "Cross", CV_SAVE, crosshair_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_crosshair2 = {"crosshair2", "Cross", CV_SAVE, crosshair_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_invertmouse = {"invertmouse", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_alwaysfreelook = {"alwaysmlook", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_invertmouse2 = {"invertmouse2", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_alwaysfreelook2 = {"alwaysmlook2", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_chasefreelook = {"chasemlook", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_chasefreelook2 = {"chasemlook2", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_mousemove = {"mousemove", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_mousemove2 = {"mousemove2", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_crosshair = CVAR_INIT ("crosshair", "Cross", CV_SAVE, crosshair_cons_t, NULL); +consvar_t cv_crosshair2 = CVAR_INIT ("crosshair2", "Cross", CV_SAVE, crosshair_cons_t, NULL); +consvar_t cv_invertmouse = CVAR_INIT ("invertmouse", "Off", CV_SAVE, CV_OnOff, NULL); +consvar_t cv_alwaysfreelook = CVAR_INIT ("alwaysmlook", "On", CV_SAVE, CV_OnOff, NULL); +consvar_t cv_invertmouse2 = CVAR_INIT ("invertmouse2", "Off", CV_SAVE, CV_OnOff, NULL); +consvar_t cv_alwaysfreelook2 = CVAR_INIT ("alwaysmlook2", "On", CV_SAVE, CV_OnOff, NULL); +consvar_t cv_chasefreelook = CVAR_INIT ("chasemlook", "Off", CV_SAVE, CV_OnOff, NULL); +consvar_t cv_chasefreelook2 = CVAR_INIT ("chasemlook2", "Off", CV_SAVE, CV_OnOff, NULL); +consvar_t cv_mousemove = CVAR_INIT ("mousemove", "Off", CV_SAVE, CV_OnOff, NULL); +consvar_t cv_mousemove2 = CVAR_INIT ("mousemove2", "Off", CV_SAVE, CV_OnOff, NULL); // previously "analog", "analog2", "useranalog", and "useranalog2", invalidating 2.1-era copies of config.cfg // changed because it'd be nice to see people try out our actually good controls with gamepads now autobrake exists consvar_t cv_analog[2] = { - {"sessionanalog", "Off", CV_CALL|CV_NOSHOWHELP, CV_OnOff, Analog_OnChange, 0, NULL, NULL, 0, 0, NULL}, - {"sessionanalog2", "Off", CV_CALL|CV_NOSHOWHELP, CV_OnOff, Analog2_OnChange, 0, NULL, NULL, 0, 0, NULL} + CVAR_INIT ("sessionanalog", "Off", CV_CALL|CV_NOSHOWHELP, CV_OnOff, Analog_OnChange), + CVAR_INIT ("sessionanalog2", "Off", CV_CALL|CV_NOSHOWHELP, CV_OnOff, Analog2_OnChange), }; consvar_t cv_useranalog[2] = { - {"configanalog", "Off", CV_SAVE|CV_CALL|CV_NOSHOWHELP, CV_OnOff, UserAnalog_OnChange, 0, NULL, NULL, 0, 0, NULL}, - {"configanalog2", "Off", CV_SAVE|CV_CALL|CV_NOSHOWHELP, CV_OnOff, UserAnalog2_OnChange, 0, NULL, NULL, 0, 0, NULL} + CVAR_INIT ("configanalog", "Off", CV_SAVE|CV_CALL|CV_NOSHOWHELP, CV_OnOff, UserAnalog_OnChange), + CVAR_INIT ("configanalog2", "Off", CV_SAVE|CV_CALL|CV_NOSHOWHELP, CV_OnOff, UserAnalog2_OnChange), }; // deez New User eXperiences static CV_PossibleValue_t directionchar_cons_t[] = {{0, "Camera"}, {1, "Movement"}, {2, "Simple Locked"}, {0, NULL}}; consvar_t cv_directionchar[2] = { - {"directionchar", "Movement", CV_SAVE|CV_CALL, directionchar_cons_t, DirectionChar_OnChange, 0, NULL, NULL, 0, 0, NULL}, - {"directionchar2", "Movement", CV_SAVE|CV_CALL, directionchar_cons_t, DirectionChar2_OnChange, 0, NULL, NULL, 0, 0, NULL} + CVAR_INIT ("directionchar", "Movement", CV_SAVE|CV_CALL, directionchar_cons_t, DirectionChar_OnChange), + CVAR_INIT ("directionchar2", "Movement", CV_SAVE|CV_CALL, directionchar_cons_t, DirectionChar2_OnChange), }; -consvar_t cv_autobrake = {"autobrake", "On", CV_SAVE|CV_CALL, CV_OnOff, AutoBrake_OnChange, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_autobrake2 = {"autobrake2", "On", CV_SAVE|CV_CALL, CV_OnOff, AutoBrake2_OnChange, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_autobrake = CVAR_INIT ("autobrake", "On", CV_SAVE|CV_CALL, CV_OnOff, AutoBrake_OnChange); +consvar_t cv_autobrake2 = CVAR_INIT ("autobrake2", "On", CV_SAVE|CV_CALL, CV_OnOff, AutoBrake2_OnChange); // hi here's some new controls static CV_PossibleValue_t zerotoone_cons_t[] = {{0, "MIN"}, {FRACUNIT, "MAX"}, {0, NULL}}; consvar_t cv_cam_shiftfacing[2] = { - {"cam_shiftfacingchar", "0.33", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, - {"cam2_shiftfacingchar", "0.33", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, + CVAR_INIT ("cam_shiftfacingchar", "0.33", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL), + CVAR_INIT ("cam2_shiftfacingchar", "0.33", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL), }; consvar_t cv_cam_turnfacing[2] = { - {"cam_turnfacingchar", "0.25", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, - {"cam2_turnfacingchar", "0.25", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, + CVAR_INIT ("cam_turnfacingchar", "0.25", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL), + CVAR_INIT ("cam2_turnfacingchar", "0.25", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL), }; consvar_t cv_cam_turnfacingability[2] = { - {"cam_turnfacingability", "0.125", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, - {"cam2_turnfacingability", "0.125", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, + CVAR_INIT ("cam_turnfacingability", "0.125", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL), + CVAR_INIT ("cam2_turnfacingability", "0.125", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL), }; consvar_t cv_cam_turnfacingspindash[2] = { - {"cam_turnfacingspindash", "0.5", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, - {"cam2_turnfacingspindash", "0.5", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, + CVAR_INIT ("cam_turnfacingspindash", "0.5", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL), + CVAR_INIT ("cam2_turnfacingspindash", "0.5", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL), }; consvar_t cv_cam_turnfacinginput[2] = { - {"cam_turnfacinginput", "0.25", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, - {"cam2_turnfacinginput", "0.25", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, + CVAR_INIT ("cam_turnfacinginput", "0.25", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL), + CVAR_INIT ("cam2_turnfacinginput", "0.25", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL), }; static CV_PossibleValue_t centertoggle_cons_t[] = {{0, "Hold"}, {1, "Toggle"}, {2, "Sticky Hold"}, {0, NULL}}; consvar_t cv_cam_centertoggle[2] = { - {"cam_centertoggle", "Hold", CV_SAVE, centertoggle_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, - {"cam2_centertoggle", "Hold", CV_SAVE, centertoggle_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, + CVAR_INIT ("cam_centertoggle", "Hold", CV_SAVE, centertoggle_cons_t, NULL), + CVAR_INIT ("cam2_centertoggle", "Hold", CV_SAVE, centertoggle_cons_t, NULL), }; static CV_PossibleValue_t lockedinput_cons_t[] = {{0, "Strafe"}, {1, "Turn"}, {0, NULL}}; consvar_t cv_cam_lockedinput[2] = { - {"cam_lockedinput", "Strafe", CV_SAVE, lockedinput_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, - {"cam2_lockedinput", "Strafe", CV_SAVE, lockedinput_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, + CVAR_INIT ("cam_lockedinput", "Strafe", CV_SAVE, lockedinput_cons_t, NULL), + CVAR_INIT ("cam2_lockedinput", "Strafe", CV_SAVE, lockedinput_cons_t, NULL), }; static CV_PossibleValue_t lockedassist_cons_t[] = { @@ -402,8 +402,8 @@ static CV_PossibleValue_t lockedassist_cons_t[] = { {0, NULL} }; consvar_t cv_cam_lockonboss[2] = { - {"cam_lockaimassist", "Bosses", CV_SAVE, lockedassist_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, - {"cam2_lockaimassist", "Bosses", CV_SAVE, lockedassist_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, + CVAR_INIT ("cam_lockaimassist", "Bosses", CV_SAVE, lockedassist_cons_t, NULL), + CVAR_INIT ("cam2_lockaimassist", "Bosses", CV_SAVE, lockedassist_cons_t, NULL), }; typedef enum @@ -422,27 +422,27 @@ typedef enum AXISFIRENORMAL, } axis_input_e; -consvar_t cv_turnaxis = {"joyaxis_turn", "X-Rudder", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_moveaxis = {"joyaxis_move", "Y-Axis", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_sideaxis = {"joyaxis_side", "X-Axis", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_lookaxis = {"joyaxis_look", "Y-Rudder-", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_jumpaxis = {"joyaxis_jump", "None", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_spinaxis = {"joyaxis_spin", "None", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_fireaxis = {"joyaxis_fire", "Z-Axis-", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_firenaxis = {"joyaxis_firenormal", "Z-Axis", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_deadzone = {"joy_deadzone", "0.125", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_digitaldeadzone = {"joy_digdeadzone", "0.25", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_turnaxis = CVAR_INIT ("joyaxis_turn", "X-Rudder", CV_SAVE, joyaxis_cons_t, NULL); +consvar_t cv_moveaxis = CVAR_INIT ("joyaxis_move", "Y-Axis", CV_SAVE, joyaxis_cons_t, NULL); +consvar_t cv_sideaxis = CVAR_INIT ("joyaxis_side", "X-Axis", CV_SAVE, joyaxis_cons_t, NULL); +consvar_t cv_lookaxis = CVAR_INIT ("joyaxis_look", "Y-Rudder-", CV_SAVE, joyaxis_cons_t, NULL); +consvar_t cv_jumpaxis = CVAR_INIT ("joyaxis_jump", "None", CV_SAVE, joyaxis_cons_t, NULL); +consvar_t cv_spinaxis = CVAR_INIT ("joyaxis_spin", "None", CV_SAVE, joyaxis_cons_t, NULL); +consvar_t cv_fireaxis = CVAR_INIT ("joyaxis_fire", "Z-Axis-", CV_SAVE, joyaxis_cons_t, NULL); +consvar_t cv_firenaxis = CVAR_INIT ("joyaxis_firenormal", "Z-Axis", CV_SAVE, joyaxis_cons_t, NULL); +consvar_t cv_deadzone = CVAR_INIT ("joy_deadzone", "0.125", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL); +consvar_t cv_digitaldeadzone = CVAR_INIT ("joy_digdeadzone", "0.25", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL); -consvar_t cv_turnaxis2 = {"joyaxis2_turn", "X-Rudder", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_moveaxis2 = {"joyaxis2_move", "Y-Axis", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_sideaxis2 = {"joyaxis2_side", "X-Axis", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_lookaxis2 = {"joyaxis2_look", "Y-Rudder-", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_jumpaxis2 = {"joyaxis2_jump", "None", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_spinaxis2 = {"joyaxis2_spin", "None", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_fireaxis2 = {"joyaxis2_fire", "Z-Axis-", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_firenaxis2 = {"joyaxis2_firenormal", "Z-Axis", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_deadzone2 = {"joy_deadzone2", "0.125", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_digitaldeadzone2 = {"joy_digdeadzone2", "0.25", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_turnaxis2 = CVAR_INIT ("joyaxis2_turn", "X-Rudder", CV_SAVE, joyaxis_cons_t, NULL); +consvar_t cv_moveaxis2 = CVAR_INIT ("joyaxis2_move", "Y-Axis", CV_SAVE, joyaxis_cons_t, NULL); +consvar_t cv_sideaxis2 = CVAR_INIT ("joyaxis2_side", "X-Axis", CV_SAVE, joyaxis_cons_t, NULL); +consvar_t cv_lookaxis2 = CVAR_INIT ("joyaxis2_look", "Y-Rudder-", CV_SAVE, joyaxis_cons_t, NULL); +consvar_t cv_jumpaxis2 = CVAR_INIT ("joyaxis2_jump", "None", CV_SAVE, joyaxis_cons_t, NULL); +consvar_t cv_spinaxis2 = CVAR_INIT ("joyaxis2_spin", "None", CV_SAVE, joyaxis_cons_t, NULL); +consvar_t cv_fireaxis2 = CVAR_INIT ("joyaxis2_fire", "Z-Axis-", CV_SAVE, joyaxis_cons_t, NULL); +consvar_t cv_firenaxis2 = CVAR_INIT ("joyaxis2_firenormal", "Z-Axis", CV_SAVE, joyaxis_cons_t, NULL); +consvar_t cv_deadzone2 = CVAR_INIT ("joy_deadzone2", "0.125", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL); +consvar_t cv_digitaldeadzone2 = CVAR_INIT ("joy_digdeadzone2", "0.25", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL); #ifdef SEENAMES player_t *seenplayer; // player we're aiming at right now diff --git a/src/g_input.c b/src/g_input.c index 1cf6990c9..d3c21e774 100644 --- a/src/g_input.c +++ b/src/g_input.c @@ -25,11 +25,11 @@ static CV_PossibleValue_t mousesens_cons_t[] = {{1, "MIN"}, {MAXMOUSESENSITIVITY static CV_PossibleValue_t onecontrolperkey_cons_t[] = {{1, "One"}, {2, "Several"}, {0, NULL}}; // mouse values are used once -consvar_t cv_mousesens = {"mousesens", "20", CV_SAVE, mousesens_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_mousesens2 = {"mousesens2", "20", CV_SAVE, mousesens_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_mouseysens = {"mouseysens", "20", CV_SAVE, mousesens_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_mouseysens2 = {"mouseysens2", "20", CV_SAVE, mousesens_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_controlperkey = {"controlperkey", "One", CV_SAVE, onecontrolperkey_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_mousesens = CVAR_INIT ("mousesens", "20", CV_SAVE, mousesens_cons_t, NULL); +consvar_t cv_mousesens2 = CVAR_INIT ("mousesens2", "20", CV_SAVE, mousesens_cons_t, NULL); +consvar_t cv_mouseysens = CVAR_INIT ("mouseysens", "20", CV_SAVE, mousesens_cons_t, NULL); +consvar_t cv_mouseysens2 = CVAR_INIT ("mouseysens2", "20", CV_SAVE, mousesens_cons_t, NULL); +consvar_t cv_controlperkey = CVAR_INIT ("controlperkey", "One", CV_SAVE, onecontrolperkey_cons_t, NULL); INT32 mousex, mousey; INT32 mlooky; // like mousey but with a custom sensitivity for mlook diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index cbfcfff87..991b51aee 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -1958,7 +1958,7 @@ static cliprange_t * hw_newend; static cliprange_t gl_solidsegs[MAXSEGS]; // needs fix: walls are incorrectly clipped one column less -static consvar_t cv_glclipwalls = {"gr_clipwalls", "Off", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +static consvar_t cv_glclipwalls = CVAR_INIT ("gr_clipwalls", "Off", 0, CV_OnOff, NULL); static void printsolidsegs(void) { @@ -5997,34 +5997,32 @@ static CV_PossibleValue_t glfiltermode_cons_t[]= {{HWD_SET_TEXTUREFILTER_POINTSA {0, NULL}}; CV_PossibleValue_t granisotropicmode_cons_t[] = {{1, "MIN"}, {16, "MAX"}, {0, NULL}}; -consvar_t cv_glshaders = {"gr_shaders", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_fovchange = {"gr_fovchange", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_glshaders = CVAR_INIT ("gr_shaders", "On", CV_SAVE, CV_OnOff, NULL); +consvar_t cv_fovchange = CVAR_INIT ("gr_fovchange", "Off", CV_SAVE, CV_OnOff, NULL); #ifdef ALAM_LIGHTING -consvar_t cv_gldynamiclighting = {"gr_dynamiclighting", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_glstaticlighting = {"gr_staticlighting", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_glcoronas = {"gr_coronas", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_glcoronasize = {"gr_coronasize", "1", CV_SAVE|CV_FLOAT, 0, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_gldynamiclighting = CVAR_INIT ("gr_dynamiclighting", "On", CV_SAVE, CV_OnOff, NULL); +consvar_t cv_glstaticlighting = CVAR_INIT ("gr_staticlighting", "On", CV_SAVE, CV_OnOff, NULL); +consvar_t cv_glcoronas = CVAR_INIT ("gr_coronas", "On", CV_SAVE, CV_OnOff, NULL); +consvar_t cv_glcoronasize = CVAR_INIT ("gr_coronasize", "1", CV_SAVE|CV_FLOAT, 0, NULL); #endif -consvar_t cv_glmodels = {"gr_models", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_glmodelinterpolation = {"gr_modelinterpolation", "Sometimes", CV_SAVE, grmodelinterpolation_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_glmodellighting = {"gr_modellighting", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_glmodels = CVAR_INIT ("gr_models", "Off", CV_SAVE, CV_OnOff, NULL); +consvar_t cv_glmodelinterpolation = CVAR_INIT ("gr_modelinterpolation", "Sometimes", CV_SAVE, grmodelinterpolation_cons_t, NULL); +consvar_t cv_glmodellighting = CVAR_INIT ("gr_modellighting", "Off", CV_SAVE, CV_OnOff, NULL); -consvar_t cv_glshearing = {"gr_shearing", "Off", CV_SAVE, grshearing_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_glspritebillboarding = {"gr_spritebillboarding", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_glskydome = {"gr_skydome", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_glfakecontrast = {"gr_fakecontrast", "Smooth", CV_SAVE, grfakecontrast_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_glslopecontrast = {"gr_slopecontrast", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_glshearing = CVAR_INIT ("gr_shearing", "Off", CV_SAVE, grshearing_cons_t, NULL); +consvar_t cv_glspritebillboarding = CVAR_INIT ("gr_spritebillboarding", "Off", CV_SAVE, CV_OnOff, NULL); +consvar_t cv_glskydome = CVAR_INIT ("gr_skydome", "On", CV_SAVE, CV_OnOff, NULL); +consvar_t cv_glfakecontrast = CVAR_INIT ("gr_fakecontrast", "Smooth", CV_SAVE, grfakecontrast_cons_t, NULL); +consvar_t cv_glslopecontrast = CVAR_INIT ("gr_slopecontrast", "Off", CV_SAVE, CV_OnOff, NULL); -consvar_t cv_glfiltermode = {"gr_filtermode", "Nearest", CV_SAVE|CV_CALL, glfiltermode_cons_t, - CV_glfiltermode_OnChange, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_glanisotropicmode = {"gr_anisotropicmode", "1", CV_CALL, granisotropicmode_cons_t, - CV_glanisotropic_OnChange, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_glfiltermode = CVAR_INIT ("gr_filtermode", "Nearest", CV_SAVE|CV_CALL, glfiltermode_cons_t, CV_glfiltermode_OnChange); +consvar_t cv_glanisotropicmode = CVAR_INIT ("gr_anisotropicmode", "1", CV_CALL, granisotropicmode_cons_t, CV_glanisotropic_OnChange); -consvar_t cv_glsolvetjoin = {"gr_solvetjoin", "On", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_glsolvetjoin = CVAR_INIT ("gr_solvetjoin", "On", 0, CV_OnOff, NULL); -consvar_t cv_glbatching = {"gr_batching", "On", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_glbatching = CVAR_INIT ("gr_batching", "On", 0, CV_OnOff, NULL); static void CV_glfiltermode_OnChange(void) { diff --git a/src/http-mserv.c b/src/http-mserv.c index a76827184..7c7d04495 100644 --- a/src/http-mserv.c +++ b/src/http-mserv.c @@ -36,20 +36,23 @@ Documentation available here. static void MasterServer_Debug_OnChange (void); -consvar_t cv_masterserver_timeout = { - "masterserver_timeout", "5", CV_SAVE, CV_Unsigned, - NULL, 0, NULL, NULL, 0, 0, NULL/* C90 moment */ -}; +consvar_t cv_masterserver_timeout = CVAR_INIT +( + "masterserver_timeout", "5", CV_SAVE, CV_Unsigned, + NULL +); -consvar_t cv_masterserver_debug = { +consvar_t cv_masterserver_debug = CVAR_INIT +( "masterserver_debug", "Off", CV_SAVE|CV_CALL, CV_OnOff, - MasterServer_Debug_OnChange, 0, NULL, NULL, 0, 0, NULL/* C90 moment */ -}; + MasterServer_Debug_OnChange +); -consvar_t cv_masterserver_token = { - "masterserver_token", "", CV_SAVE, NULL, - NULL, 0, NULL, NULL, 0, 0, NULL/* C90 moment */ -}; +consvar_t cv_masterserver_token = CVAR_INIT +( + "masterserver_token", "", CV_SAVE, NULL, + NULL +); #ifdef MASTERSERVER diff --git a/src/m_anigif.c b/src/m_anigif.c index 7c2bb359e..f30effb9b 100644 --- a/src/m_anigif.c +++ b/src/m_anigif.c @@ -29,10 +29,10 @@ // GIFs are always little-endian #include "byteptr.h" -consvar_t cv_gif_optimize = {"gif_optimize", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_gif_downscale = {"gif_downscale", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_gif_dynamicdelay = {"gif_dynamicdelay", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_gif_localcolortable = {"gif_localcolortable", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_gif_optimize = CVAR_INIT ("gif_optimize", "On", CV_SAVE, CV_OnOff, NULL); +consvar_t cv_gif_downscale = CVAR_INIT ("gif_downscale", "On", CV_SAVE, CV_OnOff, NULL); +consvar_t cv_gif_dynamicdelay = CVAR_INIT ("gif_dynamicdelay", "On", CV_SAVE, CV_OnOff, NULL); +consvar_t cv_gif_localcolortable = CVAR_INIT ("gif_localcolortable", "On", CV_SAVE, CV_OnOff, NULL); #ifdef HAVE_ANIGIF static boolean gif_optimize = false; // So nobody can do something dumb diff --git a/src/m_cheat.c b/src/m_cheat.c index a3f6d3daf..349f00c48 100644 --- a/src/m_cheat.c +++ b/src/m_cheat.c @@ -967,10 +967,10 @@ static CV_PossibleValue_t op_speed_t[] = {{1, "MIN"}, {128, "MAX"}, {0, NULL}}; static CV_PossibleValue_t op_flags_t[] = {{0, "MIN"}, {15, "MAX"}, {0, NULL}}; static CV_PossibleValue_t op_hoopflags_t[] = {{0, "MIN"}, {15, "MAX"}, {0, NULL}}; -consvar_t cv_mapthingnum = {"op_mapthingnum", "0", CV_NOTINNET, op_mapthing_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_speed = {"op_speed", "16", CV_NOTINNET, op_speed_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_opflags = {"op_flags", "0", CV_NOTINNET, op_flags_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_ophoopflags = {"op_hoopflags", "4", CV_NOTINNET, op_hoopflags_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_mapthingnum = CVAR_INIT ("op_mapthingnum", "0", CV_NOTINNET, op_mapthing_t, NULL); +consvar_t cv_speed = CVAR_INIT ("op_speed", "16", CV_NOTINNET, op_speed_t, NULL); +consvar_t cv_opflags = CVAR_INIT ("op_flags", "0", CV_NOTINNET, op_flags_t, NULL); +consvar_t cv_ophoopflags = CVAR_INIT ("op_hoopflags", "4", CV_NOTINNET, op_hoopflags_t, NULL); boolean objectplacing = false; mobjtype_t op_currentthing = 0; // For the object placement mode diff --git a/src/m_menu.c b/src/m_menu.c index c7786a496..6e0d520ae 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -412,23 +412,23 @@ static void Dummymares_OnChange(void); // CONSOLE VARIABLES AND THEIR POSSIBLE VALUES GO HERE. // ========================================================================== -consvar_t cv_showfocuslost = {"showfocuslost", "Yes", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL }; +consvar_t cv_showfocuslost = CVAR_INIT ("showfocuslost", "Yes", CV_SAVE, CV_YesNo, NULL); static CV_PossibleValue_t map_cons_t[] = { {1,"MIN"}, {NUMMAPS, "MAX"}, {0,NULL} }; -consvar_t cv_nextmap = {"nextmap", "1", CV_HIDEN|CV_CALL, map_cons_t, Nextmap_OnChange, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_nextmap = CVAR_INIT ("nextmap", "1", CV_HIDEN|CV_CALL, map_cons_t, Nextmap_OnChange); static CV_PossibleValue_t skins_cons_t[MAXSKINS+1] = {{1, DEFAULTSKIN}}; -consvar_t cv_chooseskin = {"chooseskin", DEFAULTSKIN, CV_HIDEN|CV_CALL, skins_cons_t, Nextmap_OnChange, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_chooseskin = CVAR_INIT ("chooseskin", DEFAULTSKIN, CV_HIDEN|CV_CALL, skins_cons_t, Nextmap_OnChange); // This gametype list is integral for many different reasons. // When you add gametypes here, don't forget to update them in dehacked.c and doomstat.h! CV_PossibleValue_t gametype_cons_t[NUMGAMETYPES+1]; -consvar_t cv_newgametype = {"newgametype", "Co-op", CV_HIDEN|CV_CALL, gametype_cons_t, Newgametype_OnChange, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_newgametype = CVAR_INIT ("newgametype", "Co-op", CV_HIDEN|CV_CALL, gametype_cons_t, Newgametype_OnChange); static CV_PossibleValue_t serversort_cons_t[] = { {0,"Ping"}, @@ -439,22 +439,22 @@ static CV_PossibleValue_t serversort_cons_t[] = { {5,"Gametype"}, {0,NULL} }; -consvar_t cv_serversort = {"serversort", "Ping", CV_HIDEN | CV_CALL, serversort_cons_t, M_SortServerList, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_serversort = CVAR_INIT ("serversort", "Ping", CV_HIDEN | CV_CALL, serversort_cons_t, M_SortServerList); // first time memory -consvar_t cv_tutorialprompt = {"tutorialprompt", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_tutorialprompt = CVAR_INIT ("tutorialprompt", "On", CV_SAVE, CV_OnOff, NULL); // autorecord demos for time attack -static consvar_t cv_autorecord = {"autorecord", "Yes", 0, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; +static consvar_t cv_autorecord = CVAR_INIT ("autorecord", "Yes", 0, CV_YesNo, NULL); CV_PossibleValue_t ghost_cons_t[] = {{0, "Hide"}, {1, "Show"}, {2, "Show All"}, {0, NULL}}; CV_PossibleValue_t ghost2_cons_t[] = {{0, "Hide"}, {1, "Show"}, {0, NULL}}; -consvar_t cv_ghost_bestscore = {"ghost_bestscore", "Show", CV_SAVE, ghost_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_ghost_besttime = {"ghost_besttime", "Show", CV_SAVE, ghost_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_ghost_bestrings = {"ghost_bestrings", "Show", CV_SAVE, ghost_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_ghost_last = {"ghost_last", "Show", CV_SAVE, ghost_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_ghost_guest = {"ghost_guest", "Show", CV_SAVE, ghost2_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_ghost_bestscore = CVAR_INIT ("ghost_bestscore", "Show", CV_SAVE, ghost_cons_t, NULL); +consvar_t cv_ghost_besttime = CVAR_INIT ("ghost_besttime", "Show", CV_SAVE, ghost_cons_t, NULL); +consvar_t cv_ghost_bestrings = CVAR_INIT ("ghost_bestrings", "Show", CV_SAVE, ghost_cons_t, NULL); +consvar_t cv_ghost_last = CVAR_INIT ("ghost_last", "Show", CV_SAVE, ghost_cons_t, NULL); +consvar_t cv_ghost_guest = CVAR_INIT ("ghost_guest", "Show", CV_SAVE, ghost2_cons_t, NULL); //Console variables used solely in the menu system. //todo: add a way to use non-console variables in the menu @@ -468,19 +468,19 @@ static CV_PossibleValue_t dummymares_cons_t[] = { {-1, "END"}, {0,"Overall"}, {1,"Mare 1"}, {2,"Mare 2"}, {3,"Mare 3"}, {4,"Mare 4"}, {5,"Mare 5"}, {6,"Mare 6"}, {7,"Mare 7"}, {8,"Mare 8"}, {0,NULL} }; -static consvar_t cv_dummyteam = {"dummyteam", "Spectator", CV_HIDEN, dummyteam_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -static consvar_t cv_dummyscramble = {"dummyscramble", "Random", CV_HIDEN, dummyscramble_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -static consvar_t cv_dummyrings = {"dummyrings", "0", CV_HIDEN, ringlimit_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -static consvar_t cv_dummylives = {"dummylives", "0", CV_HIDEN, liveslimit_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -static consvar_t cv_dummycontinues = {"dummycontinues", "0", CV_HIDEN, contlimit_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -static consvar_t cv_dummymares = {"dummymares", "Overall", CV_HIDEN|CV_CALL, dummymares_cons_t, Dummymares_OnChange, 0, NULL, NULL, 0, 0, NULL}; +static consvar_t cv_dummyteam = CVAR_INIT ("dummyteam", "Spectator", CV_HIDEN, dummyteam_cons_t, NULL); +static consvar_t cv_dummyscramble = CVAR_INIT ("dummyscramble", "Random", CV_HIDEN, dummyscramble_cons_t, NULL); +static consvar_t cv_dummyrings = CVAR_INIT ("dummyrings", "0", CV_HIDEN, ringlimit_cons_t, NULL); +static consvar_t cv_dummylives = CVAR_INIT ("dummylives", "0", CV_HIDEN, liveslimit_cons_t, NULL); +static consvar_t cv_dummycontinues = CVAR_INIT ("dummycontinues", "0", CV_HIDEN, contlimit_cons_t, NULL); +static consvar_t cv_dummymares = CVAR_INIT ("dummymares", "Overall", CV_HIDEN|CV_CALL, dummymares_cons_t, Dummymares_OnChange); CV_PossibleValue_t marathon_cons_t[] = {{0, "Standard"}, {1, "Live Event Backup"}, {2, "Ultimate"}, {0, NULL}}; CV_PossibleValue_t loadless_cons_t[] = {{0, "Realtime"}, {1, "In-game"}, {0, NULL}}; -consvar_t cv_dummymarathon = {"dummymarathon", "Standard", CV_HIDEN, marathon_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_dummycutscenes = {"dummycutscenes", "Off", CV_HIDEN, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_dummyloadless = {"dummyloadless", "In-game", CV_HIDEN, loadless_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_dummymarathon = CVAR_INIT ("dummymarathon", "Standard", CV_HIDEN, marathon_cons_t, NULL); +consvar_t cv_dummycutscenes = CVAR_INIT ("dummycutscenes", "Off", CV_HIDEN, CV_OnOff, NULL); +consvar_t cv_dummyloadless = CVAR_INIT ("dummyloadless", "In-game", CV_HIDEN, loadless_cons_t, NULL); // ========================================================================== // ORGANIZATION START. diff --git a/src/m_misc.c b/src/m_misc.c index 42890cb08..d97d8f94b 100644 --- a/src/m_misc.c +++ b/src/m_misc.c @@ -102,16 +102,16 @@ typedef off_t off64_t; #endif static CV_PossibleValue_t screenshot_cons_t[] = {{0, "Default"}, {1, "HOME"}, {2, "SRB2"}, {3, "CUSTOM"}, {0, NULL}}; -consvar_t cv_screenshot_option = {"screenshot_option", "Default", CV_SAVE|CV_CALL, screenshot_cons_t, Screenshot_option_Onchange, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_screenshot_folder = {"screenshot_folder", "", CV_SAVE, NULL, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_screenshot_option = CVAR_INIT ("screenshot_option", "Default", CV_SAVE|CV_CALL, screenshot_cons_t, Screenshot_option_Onchange); +consvar_t cv_screenshot_folder = CVAR_INIT ("screenshot_folder", "", CV_SAVE, NULL, NULL); -consvar_t cv_screenshot_colorprofile = {"screenshot_colorprofile", "Yes", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_screenshot_colorprofile = CVAR_INIT ("screenshot_colorprofile", "Yes", CV_SAVE, CV_YesNo, NULL); static CV_PossibleValue_t moviemode_cons_t[] = {{MM_GIF, "GIF"}, {MM_APNG, "aPNG"}, {MM_SCREENSHOT, "Screenshots"}, {0, NULL}}; -consvar_t cv_moviemode = {"moviemode_mode", "GIF", CV_SAVE|CV_CALL, moviemode_cons_t, Moviemode_mode_Onchange, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_moviemode = CVAR_INIT ("moviemode_mode", "GIF", CV_SAVE|CV_CALL, moviemode_cons_t, Moviemode_mode_Onchange); -consvar_t cv_movie_option = {"movie_option", "Default", CV_SAVE|CV_CALL, screenshot_cons_t, Moviemode_option_Onchange, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_movie_folder = {"movie_folder", "", CV_SAVE, NULL, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_movie_option = CVAR_INIT ("movie_option", "Default", CV_SAVE|CV_CALL, screenshot_cons_t, Moviemode_option_Onchange); +consvar_t cv_movie_folder = CVAR_INIT ("movie_folder", "", CV_SAVE, NULL, NULL); static CV_PossibleValue_t zlib_mem_level_t[] = { {1, "(Min Memory) 1"}, @@ -153,16 +153,16 @@ static CV_PossibleValue_t apng_delay_t[] = { // zlib memory usage is as follows: // (1 << (zlib_window_bits+2)) + (1 << (zlib_level+9)) -consvar_t cv_zlib_memory = {"png_memory_level", "7", CV_SAVE, zlib_mem_level_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_zlib_level = {"png_compress_level", "(Optimal) 6", CV_SAVE, zlib_level_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_zlib_strategy = {"png_strategy", "Normal", CV_SAVE, zlib_strategy_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_zlib_window_bits = {"png_window_size", "32k", CV_SAVE, zlib_window_bits_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_zlib_memory = CVAR_INIT ("png_memory_level", "7", CV_SAVE, zlib_mem_level_t, NULL); +consvar_t cv_zlib_level = CVAR_INIT ("png_compress_level", "(Optimal) 6", CV_SAVE, zlib_level_t, NULL); +consvar_t cv_zlib_strategy = CVAR_INIT ("png_strategy", "Normal", CV_SAVE, zlib_strategy_t, NULL); +consvar_t cv_zlib_window_bits = CVAR_INIT ("png_window_size", "32k", CV_SAVE, zlib_window_bits_t, NULL); -consvar_t cv_zlib_memorya = {"apng_memory_level", "(Max Memory) 9", CV_SAVE, zlib_mem_level_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_zlib_levela = {"apng_compress_level", "4", CV_SAVE, zlib_level_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_zlib_strategya = {"apng_strategy", "RLE", CV_SAVE, zlib_strategy_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_zlib_window_bitsa = {"apng_window_size", "32k", CV_SAVE, zlib_window_bits_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_apng_delay = {"apng_speed", "1x", CV_SAVE, apng_delay_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_zlib_memorya = CVAR_INIT ("apng_memory_level", "(Max Memory) 9", CV_SAVE, zlib_mem_level_t, NULL); +consvar_t cv_zlib_levela = CVAR_INIT ("apng_compress_level", "4", CV_SAVE, zlib_level_t, NULL); +consvar_t cv_zlib_strategya = CVAR_INIT ("apng_strategy", "RLE", CV_SAVE, zlib_strategy_t, NULL); +consvar_t cv_zlib_window_bitsa = CVAR_INIT ("apng_window_size", "32k", CV_SAVE, zlib_window_bits_t, NULL); +consvar_t cv_apng_delay = CVAR_INIT ("apng_speed", "1x", CV_SAVE, apng_delay_t, NULL); boolean takescreenshot = false; // Take a screenshot this tic diff --git a/src/mserv.c b/src/mserv.c index 27d479797..fa646b899 100644 --- a/src/mserv.c +++ b/src/mserv.c @@ -61,10 +61,10 @@ static CV_PossibleValue_t masterserver_update_rate_cons_t[] = { {0,NULL} }; -consvar_t cv_masterserver = {"masterserver", "https://mb.srb2.org/MS/0", CV_SAVE|CV_CALL, NULL, MasterServer_OnChange, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_servername = {"servername", "SRB2 server", CV_SAVE|CV_CALL|CV_NOINIT, NULL, Update_parameters, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_masterserver = CVAR_INIT ("masterserver", "https://mb.srb2.org/MS/0", CV_SAVE|CV_CALL, NULL, MasterServer_OnChange); +consvar_t cv_servername = CVAR_INIT ("servername", "SRB2 server", CV_SAVE|CV_CALL|CV_NOINIT, NULL, Update_parameters); -consvar_t cv_masterserver_update_rate = {"masterserver_update_rate", "15", CV_SAVE|CV_CALL|CV_NOINIT, masterserver_update_rate_cons_t, Update_parameters, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_masterserver_update_rate = CVAR_INIT ("masterserver_update_rate", "15", CV_SAVE|CV_CALL|CV_NOINIT, masterserver_update_rate_cons_t, Update_parameters); INT16 ms_RoomId = -1; diff --git a/src/p_mobj.c b/src/p_mobj.c index badf19372..de4385fa7 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -36,10 +36,10 @@ #include "m_cond.h" static CV_PossibleValue_t CV_BobSpeed[] = {{0, "MIN"}, {4*FRACUNIT, "MAX"}, {0, NULL}}; -consvar_t cv_movebob = {"movebob", "1.0", CV_FLOAT|CV_SAVE, CV_BobSpeed, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_movebob = CVAR_INIT ("movebob", "1.0", CV_FLOAT|CV_SAVE, CV_BobSpeed, NULL); #ifdef WALLSPLATS -consvar_t cv_splats = {"splats", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_splats = CVAR_INIT ("splats", "On", CV_SAVE, CV_OnOff, NULL); #endif actioncache_t actioncachehead; @@ -11047,10 +11047,10 @@ void P_RemoveSavegameMobj(mobj_t *mobj) } static CV_PossibleValue_t respawnitemtime_cons_t[] = {{1, "MIN"}, {300, "MAX"}, {0, NULL}}; -consvar_t cv_itemrespawntime = {"respawnitemtime", "30", CV_NETVAR|CV_CHEAT, respawnitemtime_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_itemrespawn = {"respawnitem", "On", CV_NETVAR, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_itemrespawntime = CVAR_INIT ("respawnitemtime", "30", CV_NETVAR|CV_CHEAT, respawnitemtime_cons_t, NULL); +consvar_t cv_itemrespawn = CVAR_INIT ("respawnitem", "On", CV_NETVAR, CV_OnOff, NULL); static CV_PossibleValue_t flagtime_cons_t[] = {{0, "MIN"}, {300, "MAX"}, {0, NULL}}; -consvar_t cv_flagtime = {"flagtime", "30", CV_NETVAR|CV_CHEAT, flagtime_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_flagtime = CVAR_INIT ("flagtime", "30", CV_NETVAR|CV_CHEAT, flagtime_cons_t, NULL); void P_SpawnPrecipitation(void) { diff --git a/src/p_user.c b/src/p_user.c index b8e7d1746..4c24e1a21 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -9631,45 +9631,45 @@ static CV_PossibleValue_t rotation_cons_t[] = {{1, "MIN"}, {25, "MAX"}, {0, NULL static CV_PossibleValue_t CV_CamRotate[] = {{-720, "MIN"}, {720, "MAX"}, {0, NULL}}; static CV_PossibleValue_t multiplier_cons_t[] = {{0, "MIN"}, {3*FRACUNIT, "MAX"}, {0, NULL}}; -consvar_t cv_cam_dist = {"cam_curdist", "160", CV_FLOAT, NULL, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_cam_height = {"cam_curheight", "25", CV_FLOAT, NULL, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_cam_still = {"cam_still", "Off", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_cam_speed = {"cam_speed", "0.3", CV_FLOAT|CV_SAVE, CV_CamSpeed, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_cam_rotate = {"cam_rotate", "0", CV_CALL|CV_NOINIT, CV_CamRotate, CV_CamRotate_OnChange, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_cam_rotspeed = {"cam_rotspeed", "10", CV_SAVE, rotation_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_cam_turnmultiplier = {"cam_turnmultiplier", "1.0", CV_FLOAT|CV_SAVE, multiplier_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_cam_orbit = {"cam_orbit", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_cam_adjust = {"cam_adjust", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_cam2_dist = {"cam2_curdist", "160", CV_FLOAT, NULL, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_cam2_height = {"cam2_curheight", "25", CV_FLOAT, NULL, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_cam2_still = {"cam2_still", "Off", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_cam2_speed = {"cam2_speed", "0.3", CV_FLOAT|CV_SAVE, CV_CamSpeed, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_cam2_rotate = {"cam2_rotate", "0", CV_CALL|CV_NOINIT, CV_CamRotate, CV_CamRotate2_OnChange, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_cam2_rotspeed = {"cam2_rotspeed", "10", CV_SAVE, rotation_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_cam2_turnmultiplier = {"cam2_turnmultiplier", "1.0", CV_FLOAT|CV_SAVE, multiplier_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_cam2_orbit = {"cam2_orbit", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_cam2_adjust = {"cam2_adjust", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_cam_dist = CVAR_INIT ("cam_curdist", "160", CV_FLOAT, NULL, NULL); +consvar_t cv_cam_height = CVAR_INIT ("cam_curheight", "25", CV_FLOAT, NULL, NULL); +consvar_t cv_cam_still = CVAR_INIT ("cam_still", "Off", 0, CV_OnOff, NULL); +consvar_t cv_cam_speed = CVAR_INIT ("cam_speed", "0.3", CV_FLOAT|CV_SAVE, CV_CamSpeed, NULL); +consvar_t cv_cam_rotate = CVAR_INIT ("cam_rotate", "0", CV_CALL|CV_NOINIT, CV_CamRotate, CV_CamRotate_OnChange); +consvar_t cv_cam_rotspeed = CVAR_INIT ("cam_rotspeed", "10", CV_SAVE, rotation_cons_t, NULL); +consvar_t cv_cam_turnmultiplier = CVAR_INIT ("cam_turnmultiplier", "1.0", CV_FLOAT|CV_SAVE, multiplier_cons_t, NULL); +consvar_t cv_cam_orbit = CVAR_INIT ("cam_orbit", "Off", CV_SAVE, CV_OnOff, NULL); +consvar_t cv_cam_adjust = CVAR_INIT ("cam_adjust", "On", CV_SAVE, CV_OnOff, NULL); +consvar_t cv_cam2_dist = CVAR_INIT ("cam2_curdist", "160", CV_FLOAT, NULL, NULL); +consvar_t cv_cam2_height = CVAR_INIT ("cam2_curheight", "25", CV_FLOAT, NULL, NULL); +consvar_t cv_cam2_still = CVAR_INIT ("cam2_still", "Off", 0, CV_OnOff, NULL); +consvar_t cv_cam2_speed = CVAR_INIT ("cam2_speed", "0.3", CV_FLOAT|CV_SAVE, CV_CamSpeed, NULL); +consvar_t cv_cam2_rotate = CVAR_INIT ("cam2_rotate", "0", CV_CALL|CV_NOINIT, CV_CamRotate, CV_CamRotate2_OnChange); +consvar_t cv_cam2_rotspeed = CVAR_INIT ("cam2_rotspeed", "10", CV_SAVE, rotation_cons_t, NULL); +consvar_t cv_cam2_turnmultiplier = CVAR_INIT ("cam2_turnmultiplier", "1.0", CV_FLOAT|CV_SAVE, multiplier_cons_t, NULL); +consvar_t cv_cam2_orbit = CVAR_INIT ("cam2_orbit", "Off", CV_SAVE, CV_OnOff, NULL); +consvar_t cv_cam2_adjust = CVAR_INIT ("cam2_adjust", "On", CV_SAVE, CV_OnOff, NULL); // [standard vs simple][p1 or p2] consvar_t cv_cam_savedist[2][2] = { { // standard - {"cam_dist", "160", CV_FLOAT|CV_SAVE|CV_CALL, NULL, CV_UpdateCamDist, 0, NULL, NULL, 0, 0, NULL}, - {"cam2_dist", "160", CV_FLOAT|CV_SAVE|CV_CALL, NULL, CV_UpdateCam2Dist, 0, NULL, NULL, 0, 0, NULL} + CVAR_INIT ("cam_dist", "160", CV_FLOAT|CV_SAVE|CV_CALL, NULL, CV_UpdateCamDist), + CVAR_INIT ("cam2_dist", "160", CV_FLOAT|CV_SAVE|CV_CALL, NULL, CV_UpdateCam2Dist), }, { // simple - {"cam_simpledist", "224", CV_FLOAT|CV_SAVE|CV_CALL, NULL, CV_UpdateCamDist, 0, NULL, NULL, 0, 0, NULL}, - {"cam2_simpledist", "224", CV_FLOAT|CV_SAVE|CV_CALL, NULL, CV_UpdateCam2Dist, 0, NULL, NULL, 0, 0, NULL} + CVAR_INIT ("cam_simpledist", "224", CV_FLOAT|CV_SAVE|CV_CALL, NULL, CV_UpdateCamDist), + CVAR_INIT ("cam2_simpledist", "224", CV_FLOAT|CV_SAVE|CV_CALL, NULL, CV_UpdateCam2Dist), } }; consvar_t cv_cam_saveheight[2][2] = { { // standard - {"cam_height", "25", CV_FLOAT|CV_SAVE|CV_CALL, NULL, CV_UpdateCamDist, 0, NULL, NULL, 0, 0, NULL}, - {"cam2_height", "25", CV_FLOAT|CV_SAVE|CV_CALL, NULL, CV_UpdateCam2Dist, 0, NULL, NULL, 0, 0, NULL} + CVAR_INIT ("cam_height", "25", CV_FLOAT|CV_SAVE|CV_CALL, NULL, CV_UpdateCamDist), + CVAR_INIT ("cam2_height", "25", CV_FLOAT|CV_SAVE|CV_CALL, NULL, CV_UpdateCam2Dist), }, { // simple - {"cam_simpleheight", "48", CV_FLOAT|CV_SAVE|CV_CALL, NULL, CV_UpdateCamDist, 0, NULL, NULL, 0, 0, NULL}, - {"cam2_simpleheight", "48", CV_FLOAT|CV_SAVE|CV_CALL, NULL, CV_UpdateCam2Dist, 0, NULL, NULL, 0, 0, NULL} + CVAR_INIT ("cam_simpleheight", "48", CV_FLOAT|CV_SAVE|CV_CALL, NULL, CV_UpdateCamDist), + CVAR_INIT ("cam2_simpleheight", "48", CV_FLOAT|CV_SAVE|CV_CALL, NULL, CV_UpdateCam2Dist), } }; diff --git a/src/r_main.c b/src/r_main.c index ef898de94..9613e2ac1 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -143,31 +143,31 @@ static void FlipCam2_OnChange(void); void SendWeaponPref(void); void SendWeaponPref2(void); -consvar_t cv_tailspickup = {"tailspickup", "On", CV_NETVAR, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_chasecam = {"chasecam", "On", CV_CALL, CV_OnOff, ChaseCam_OnChange, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_chasecam2 = {"chasecam2", "On", CV_CALL, CV_OnOff, ChaseCam2_OnChange, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_flipcam = {"flipcam", "No", CV_SAVE|CV_CALL|CV_NOINIT, CV_YesNo, FlipCam_OnChange, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_flipcam2 = {"flipcam2", "No", CV_SAVE|CV_CALL|CV_NOINIT, CV_YesNo, FlipCam2_OnChange, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_tailspickup = CVAR_INIT ("tailspickup", "On", CV_NETVAR, CV_OnOff, NULL); +consvar_t cv_chasecam = CVAR_INIT ("chasecam", "On", CV_CALL, CV_OnOff, ChaseCam_OnChange); +consvar_t cv_chasecam2 = CVAR_INIT ("chasecam2", "On", CV_CALL, CV_OnOff, ChaseCam2_OnChange); +consvar_t cv_flipcam = CVAR_INIT ("flipcam", "No", CV_SAVE|CV_CALL|CV_NOINIT, CV_YesNo, FlipCam_OnChange); +consvar_t cv_flipcam2 = CVAR_INIT ("flipcam2", "No", CV_SAVE|CV_CALL|CV_NOINIT, CV_YesNo, FlipCam2_OnChange); -consvar_t cv_shadow = {"shadow", "On", 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_allowmlook = {"allowmlook", "Yes", CV_NETVAR, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_showhud = {"showhud", "Yes", CV_CALL, CV_YesNo, R_SetViewSize, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_translucenthud = {"translucenthud", "10", CV_SAVE, translucenthud_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_shadow = CVAR_INIT ("shadow", "On", CV_SAVE, CV_OnOff, NULL); +consvar_t cv_skybox = CVAR_INIT ("skybox", "On", CV_SAVE, CV_OnOff, NULL); +consvar_t cv_allowmlook = CVAR_INIT ("allowmlook", "Yes", CV_NETVAR, CV_YesNo, NULL); +consvar_t cv_showhud = CVAR_INIT ("showhud", "Yes", CV_CALL, CV_YesNo, R_SetViewSize); +consvar_t cv_translucenthud = CVAR_INIT ("translucenthud", "10", CV_SAVE, translucenthud_cons_t, NULL); -consvar_t cv_translucency = {"translucency", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_drawdist = {"drawdist", "Infinite", CV_SAVE, drawdist_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_drawdist_nights = {"drawdist_nights", "2048", CV_SAVE, drawdist_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_drawdist_precip = {"drawdist_precip", "1024", CV_SAVE, drawdist_precip_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -//consvar_t cv_precipdensity = {"precipdensity", "Moderate", CV_SAVE, precipdensity_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_fov = {"fov", "90", CV_FLOAT|CV_CALL, fov_cons_t, Fov_OnChange, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_translucency = CVAR_INIT ("translucency", "On", CV_SAVE, CV_OnOff, NULL); +consvar_t cv_drawdist = CVAR_INIT ("drawdist", "Infinite", CV_SAVE, drawdist_cons_t, NULL); +consvar_t cv_drawdist_nights = CVAR_INIT ("drawdist_nights", "2048", CV_SAVE, drawdist_cons_t, NULL); +consvar_t cv_drawdist_precip = CVAR_INIT ("drawdist_precip", "1024", CV_SAVE, drawdist_precip_cons_t, NULL); +//consvar_t cv_precipdensity = CVAR_INIT ("precipdensity", "Moderate", CV_SAVE, precipdensity_cons_t, NULL); +consvar_t cv_fov = CVAR_INIT ("fov", "90", CV_FLOAT|CV_CALL, fov_cons_t, Fov_OnChange); // Okay, whoever said homremoval causes a performance hit should be shot. -consvar_t cv_homremoval = {"homremoval", "No", CV_SAVE, homremoval_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_homremoval = CVAR_INIT ("homremoval", "No", CV_SAVE, homremoval_cons_t, NULL); -consvar_t cv_maxportals = {"maxportals", "2", CV_SAVE, maxportals_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_maxportals = CVAR_INIT ("maxportals", "2", CV_SAVE, maxportals_cons_t, NULL); -consvar_t cv_renderstats = {"renderstats", "Off", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_renderstats = CVAR_INIT ("renderstats", "Off", 0, CV_OnOff, NULL); void SplitScreen_OnChange(void) { diff --git a/src/s_sound.c b/src/s_sound.c index 1885cfcf9..388b309a1 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -65,21 +65,21 @@ static boolean S_CheckQueue(void); #endif #ifdef _WINDOWS -consvar_t cv_samplerate = {"samplerate", "44100", 0, CV_Unsigned, NULL, 44100, NULL, NULL, 0, 0, NULL}; //Alam: For easy hacking? +consvar_t cv_samplerate = CVAR_INIT ("samplerate", "44100", 0, CV_Unsigned, NULL); //Alam: For easy hacking? #else -consvar_t cv_samplerate = {"samplerate", "22050", 0, CV_Unsigned, NULL, 22050, NULL, NULL, 0, 0, NULL}; //Alam: For easy hacking? +consvar_t cv_samplerate = CVAR_INIT ("samplerate", "22050", 0, CV_Unsigned, NULL); //Alam: For easy hacking? #endif // stereo reverse -consvar_t stereoreverse = {"stereoreverse", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t stereoreverse = CVAR_INIT ("stereoreverse", "Off", CV_SAVE, CV_OnOff, NULL); // if true, all sounds are loaded at game startup -static consvar_t precachesound = {"precachesound", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +static consvar_t precachesound = CVAR_INIT ("precachesound", "Off", CV_SAVE, CV_OnOff, NULL); // actual general (maximum) sound & music volume, saved into the config -consvar_t cv_soundvolume = {"soundvolume", "18", CV_SAVE, soundvolume_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_digmusicvolume = {"digmusicvolume", "18", CV_SAVE, soundvolume_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_midimusicvolume = {"midimusicvolume", "18", CV_SAVE, soundvolume_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_soundvolume = CVAR_INIT ("soundvolume", "18", CV_SAVE, soundvolume_cons_t, NULL); +consvar_t cv_digmusicvolume = CVAR_INIT ("digmusicvolume", "18", CV_SAVE, soundvolume_cons_t, NULL); +consvar_t cv_midimusicvolume = CVAR_INIT ("midimusicvolume", "18", CV_SAVE, soundvolume_cons_t, NULL); static void Captioning_OnChange(void) { @@ -88,27 +88,27 @@ static void Captioning_OnChange(void) S_StartSound(NULL, sfx_menu1); } -consvar_t cv_closedcaptioning = {"closedcaptioning", "Off", CV_SAVE|CV_CALL, CV_OnOff, Captioning_OnChange, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_closedcaptioning = CVAR_INIT ("closedcaptioning", "Off", CV_SAVE|CV_CALL, CV_OnOff, Captioning_OnChange); // number of channels available -consvar_t cv_numChannels = {"snd_channels", "32", CV_SAVE|CV_CALL, CV_Unsigned, SetChannelsNum, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_numChannels = CVAR_INIT ("snd_channels", "32", CV_SAVE|CV_CALL, CV_Unsigned, SetChannelsNum); -static consvar_t surround = {"surround", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +static consvar_t surround = CVAR_INIT ("surround", "Off", CV_SAVE, CV_OnOff, NULL); -consvar_t cv_resetmusic = {"resetmusic", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_resetmusicbyheader = {"resetmusicbyheader", "Yes", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_resetmusic = CVAR_INIT ("resetmusic", "Off", CV_SAVE, CV_OnOff, NULL); +consvar_t cv_resetmusicbyheader = CVAR_INIT ("resetmusicbyheader", "Yes", CV_SAVE, CV_YesNo, NULL); static CV_PossibleValue_t cons_1upsound_t[] = { {0, "Jingle"}, {1, "Sound"}, {0, NULL} }; -consvar_t cv_1upsound = {"1upsound", "Jingle", CV_SAVE, cons_1upsound_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_1upsound = CVAR_INIT ("1upsound", "Jingle", CV_SAVE, cons_1upsound_t, NULL); // Sound system toggles, saved into the config -consvar_t cv_gamedigimusic = {"digimusic", "On", CV_SAVE|CV_CALL|CV_NOINIT, CV_OnOff, GameDigiMusic_OnChange, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_gamemidimusic = {"midimusic", "On", CV_SAVE|CV_CALL|CV_NOINIT, CV_OnOff, GameMIDIMusic_OnChange, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_gamesounds = {"sounds", "On", CV_SAVE|CV_CALL|CV_NOINIT, CV_OnOff, GameSounds_OnChange, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_gamedigimusic = CVAR_INIT ("digimusic", "On", CV_SAVE|CV_CALL|CV_NOINIT, CV_OnOff, GameDigiMusic_OnChange); +consvar_t cv_gamemidimusic = CVAR_INIT ("midimusic", "On", CV_SAVE|CV_CALL|CV_NOINIT, CV_OnOff, GameMIDIMusic_OnChange); +consvar_t cv_gamesounds = CVAR_INIT ("sounds", "On", CV_SAVE|CV_CALL|CV_NOINIT, CV_OnOff, GameSounds_OnChange); // Music preference static CV_PossibleValue_t cons_musicpref_t[] = { @@ -116,16 +116,16 @@ static CV_PossibleValue_t cons_musicpref_t[] = { {1, "MIDI"}, {0, NULL} }; -consvar_t cv_musicpref = {"musicpref", "Digital", CV_SAVE|CV_CALL|CV_NOINIT, cons_musicpref_t, MusicPref_OnChange, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_musicpref = CVAR_INIT ("musicpref", "Digital", CV_SAVE|CV_CALL|CV_NOINIT, cons_musicpref_t, MusicPref_OnChange); // Window focus sound sytem toggles -consvar_t cv_playmusicifunfocused = {"playmusicifunfocused", "No", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_playsoundsifunfocused = {"playsoundsifunfocused", "No", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_playmusicifunfocused = CVAR_INIT ("playmusicifunfocused", "No", CV_SAVE, CV_YesNo, NULL); +consvar_t cv_playsoundsifunfocused = CVAR_INIT ("playsoundsifunfocused", "No", CV_SAVE, CV_YesNo, NULL); #ifdef HAVE_OPENMPT openmpt_module *openmpt_mhandle = NULL; static CV_PossibleValue_t interpolationfilter_cons_t[] = {{0, "Default"}, {1, "None"}, {2, "Linear"}, {4, "Cubic"}, {8, "Windowed sinc"}, {0, NULL}}; -consvar_t cv_modfilter = {"modfilter", "0", CV_SAVE|CV_CALL, interpolationfilter_cons_t, ModFilter_OnChange, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_modfilter = CVAR_INIT ("modfilter", "0", CV_SAVE|CV_CALL, interpolationfilter_cons_t, ModFilter_OnChange); #endif #define S_MAX_VOLUME 127 diff --git a/src/screen.c b/src/screen.c index 6dadd25c3..048480fb2 100644 --- a/src/screen.c +++ b/src/screen.c @@ -58,10 +58,10 @@ UINT8 setrenderneeded = 0; static CV_PossibleValue_t scr_depth_cons_t[] = {{8, "8 bits"}, {16, "16 bits"}, {24, "24 bits"}, {32, "32 bits"}, {0, NULL}}; //added : 03-02-98: default screen mode, as loaded/saved in config -consvar_t cv_scr_width = {"scr_width", "1280", CV_SAVE, CV_Unsigned, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_scr_height = {"scr_height", "800", CV_SAVE, CV_Unsigned, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_scr_depth = {"scr_depth", "16 bits", CV_SAVE, scr_depth_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_renderview = {"renderview", "On", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_scr_width = CVAR_INIT ("scr_width", "1280", CV_SAVE, CV_Unsigned, NULL); +consvar_t cv_scr_height = CVAR_INIT ("scr_height", "800", CV_SAVE, CV_Unsigned, NULL); +consvar_t cv_scr_depth = CVAR_INIT ("scr_depth", "16 bits", CV_SAVE, scr_depth_cons_t, NULL); +consvar_t cv_renderview = CVAR_INIT ("renderview", "On", 0, CV_OnOff, NULL); static void SCR_ActuallyChangeRenderer(void); static CV_PossibleValue_t cv_renderer_t[] = { @@ -71,11 +71,11 @@ static CV_PossibleValue_t cv_renderer_t[] = { #endif {0, NULL} }; -consvar_t cv_renderer = {"renderer", "Software", CV_SAVE|CV_NOLUA|CV_CALL, cv_renderer_t, SCR_ChangeRenderer, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_renderer = CVAR_INIT ("renderer", "Software", CV_SAVE|CV_NOLUA|CV_CALL, cv_renderer_t, SCR_ChangeRenderer); static void SCR_ChangeFullscreen(void); -consvar_t cv_fullscreen = {"fullscreen", "Yes", CV_SAVE|CV_CALL, CV_YesNo, SCR_ChangeFullscreen, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_fullscreen = CVAR_INIT ("fullscreen", "Yes", CV_SAVE|CV_CALL, CV_YesNo, SCR_ChangeFullscreen); // ========================================================================= // SCREEN VARIABLES diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index c8f67da77..749dab4fa 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -100,9 +100,9 @@ static rendermode_t chosenrendermode = render_soft; // set by command line argum boolean highcolor = false; // synchronize page flipping with screen refresh -consvar_t cv_vidwait = {"vid_wait", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -static consvar_t cv_stretch = {"stretch", "Off", CV_SAVE|CV_NOSHOWHELP, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -static consvar_t cv_alwaysgrabmouse = {"alwaysgrabmouse", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_vidwait = CVAR_INIT ("vid_wait", "On", CV_SAVE, CV_OnOff, NULL); +static consvar_t cv_stretch = CVAR_INIT ("stretch", "Off", CV_SAVE|CV_NOSHOWHELP, CV_OnOff, NULL); +static consvar_t cv_alwaysgrabmouse = CVAR_INIT ("alwaysgrabmouse", "Off", CV_SAVE, CV_OnOff, NULL); UINT8 graphics_started = 0; // Is used in console.c and screen.c INT32 vid_opengl_state = 0; diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index 25e7fde89..c64164caa 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -196,9 +196,9 @@ static void MidiSoundfontPath_Onchange(void) // make sure that s_sound.c does not already verify these // which happens when: defined(HAVE_MIXERX) && !defined(HAVE_MIXER) static CV_PossibleValue_t midiplayer_cons_t[] = {{MIDI_OPNMIDI, "OPNMIDI"}, {MIDI_Fluidsynth, "Fluidsynth"}, {MIDI_Timidity, "Timidity"}, {MIDI_Native, "Native"}, {0, NULL}}; -consvar_t cv_midiplayer = {"midiplayer", "OPNMIDI" /*MIDI_OPNMIDI*/, CV_CALL|CV_NOINIT|CV_SAVE, midiplayer_cons_t, Midiplayer_Onchange, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_midisoundfontpath = {"midisoundfont", "sf2/8bitsf.SF2", CV_CALL|CV_NOINIT|CV_SAVE, NULL, MidiSoundfontPath_Onchange, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_miditimiditypath = {"midisoundbank", "./timidity", CV_SAVE, NULL, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_midiplayer = CVAR_INIT ("midiplayer", "OPNMIDI" /*MIDI_OPNMIDI*/, CV_CALL|CV_NOINIT|CV_SAVE, midiplayer_cons_t, Midiplayer_Onchange); +consvar_t cv_midisoundfontpath = CVAR_INIT ("midisoundfont", "sf2/8bitsf.SF2", CV_CALL|CV_NOINIT|CV_SAVE, NULL, MidiSoundfontPath_Onchange); +consvar_t cv_miditimiditypath = CVAR_INIT ("midisoundbank", "./timidity", CV_SAVE, NULL, NULL); #endif static void var_cleanup(void) diff --git a/src/v_video.c b/src/v_video.c index ecc34a54b..9c91261de 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -43,45 +43,45 @@ UINT8 *screens[5]; // screens[4] = fade screen end, postimage tempoarary buffer static CV_PossibleValue_t ticrate_cons_t[] = {{0, "No"}, {1, "Full"}, {2, "Compact"}, {0, NULL}}; -consvar_t cv_ticrate = {"showfps", "No", CV_SAVE, ticrate_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_ticrate = CVAR_INIT ("showfps", "No", CV_SAVE, ticrate_cons_t, NULL); static void CV_palette_OnChange(void); static CV_PossibleValue_t gamma_cons_t[] = {{-15, "MIN"}, {5, "MAX"}, {0, NULL}}; -consvar_t cv_globalgamma = {"gamma", "0", CV_SAVE|CV_CALL, gamma_cons_t, CV_palette_OnChange, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_globalgamma = CVAR_INIT ("gamma", "0", CV_SAVE|CV_CALL, gamma_cons_t, CV_palette_OnChange); static CV_PossibleValue_t saturation_cons_t[] = {{0, "MIN"}, {10, "MAX"}, {0, NULL}}; -consvar_t cv_globalsaturation = {"saturation", "10", CV_SAVE|CV_CALL, saturation_cons_t, CV_palette_OnChange, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_globalsaturation = CVAR_INIT ("saturation", "10", CV_SAVE|CV_CALL, saturation_cons_t, CV_palette_OnChange); #define huecoloursteps 4 static CV_PossibleValue_t hue_cons_t[] = {{0, "MIN"}, {(huecoloursteps*6)-1, "MAX"}, {0, NULL}}; -consvar_t cv_rhue = {"rhue", "0", CV_SAVE|CV_CALL, hue_cons_t, CV_palette_OnChange, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_yhue = {"yhue", "4", CV_SAVE|CV_CALL, hue_cons_t, CV_palette_OnChange, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_ghue = {"ghue", "8", CV_SAVE|CV_CALL, hue_cons_t, CV_palette_OnChange, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_chue = {"chue", "12", CV_SAVE|CV_CALL, hue_cons_t, CV_palette_OnChange, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_bhue = {"bhue", "16", CV_SAVE|CV_CALL, hue_cons_t, CV_palette_OnChange, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_mhue = {"mhue", "20", CV_SAVE|CV_CALL, hue_cons_t, CV_palette_OnChange, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_rhue = CVAR_INIT ("rhue", "0", CV_SAVE|CV_CALL, hue_cons_t, CV_palette_OnChange); +consvar_t cv_yhue = CVAR_INIT ("yhue", "4", CV_SAVE|CV_CALL, hue_cons_t, CV_palette_OnChange); +consvar_t cv_ghue = CVAR_INIT ("ghue", "8", CV_SAVE|CV_CALL, hue_cons_t, CV_palette_OnChange); +consvar_t cv_chue = CVAR_INIT ("chue", "12", CV_SAVE|CV_CALL, hue_cons_t, CV_palette_OnChange); +consvar_t cv_bhue = CVAR_INIT ("bhue", "16", CV_SAVE|CV_CALL, hue_cons_t, CV_palette_OnChange); +consvar_t cv_mhue = CVAR_INIT ("mhue", "20", CV_SAVE|CV_CALL, hue_cons_t, CV_palette_OnChange); -consvar_t cv_rgamma = {"rgamma", "0", CV_SAVE|CV_CALL, gamma_cons_t, CV_palette_OnChange, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_ygamma = {"ygamma", "0", CV_SAVE|CV_CALL, gamma_cons_t, CV_palette_OnChange, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_ggamma = {"ggamma", "0", CV_SAVE|CV_CALL, gamma_cons_t, CV_palette_OnChange, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_cgamma = {"cgamma", "0", CV_SAVE|CV_CALL, gamma_cons_t, CV_palette_OnChange, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_bgamma = {"bgamma", "0", CV_SAVE|CV_CALL, gamma_cons_t, CV_palette_OnChange, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_mgamma = {"mgamma", "0", CV_SAVE|CV_CALL, gamma_cons_t, CV_palette_OnChange, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_rgamma = CVAR_INIT ("rgamma", "0", CV_SAVE|CV_CALL, gamma_cons_t, CV_palette_OnChange); +consvar_t cv_ygamma = CVAR_INIT ("ygamma", "0", CV_SAVE|CV_CALL, gamma_cons_t, CV_palette_OnChange); +consvar_t cv_ggamma = CVAR_INIT ("ggamma", "0", CV_SAVE|CV_CALL, gamma_cons_t, CV_palette_OnChange); +consvar_t cv_cgamma = CVAR_INIT ("cgamma", "0", CV_SAVE|CV_CALL, gamma_cons_t, CV_palette_OnChange); +consvar_t cv_bgamma = CVAR_INIT ("bgamma", "0", CV_SAVE|CV_CALL, gamma_cons_t, CV_palette_OnChange); +consvar_t cv_mgamma = CVAR_INIT ("mgamma", "0", CV_SAVE|CV_CALL, gamma_cons_t, CV_palette_OnChange); -consvar_t cv_rsaturation = {"rsaturation", "10", CV_SAVE|CV_CALL, saturation_cons_t, CV_palette_OnChange, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_ysaturation = {"ysaturation", "10", CV_SAVE|CV_CALL, saturation_cons_t, CV_palette_OnChange, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_gsaturation = {"gsaturation", "10", CV_SAVE|CV_CALL, saturation_cons_t, CV_palette_OnChange, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_csaturation = {"csaturation", "10", CV_SAVE|CV_CALL, saturation_cons_t, CV_palette_OnChange, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_bsaturation = {"bsaturation", "10", CV_SAVE|CV_CALL, saturation_cons_t, CV_palette_OnChange, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_msaturation = {"msaturation", "10", CV_SAVE|CV_CALL, saturation_cons_t, CV_palette_OnChange, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_rsaturation = CVAR_INIT ("rsaturation", "10", CV_SAVE|CV_CALL, saturation_cons_t, CV_palette_OnChange); +consvar_t cv_ysaturation = CVAR_INIT ("ysaturation", "10", CV_SAVE|CV_CALL, saturation_cons_t, CV_palette_OnChange); +consvar_t cv_gsaturation = CVAR_INIT ("gsaturation", "10", CV_SAVE|CV_CALL, saturation_cons_t, CV_palette_OnChange); +consvar_t cv_csaturation = CVAR_INIT ("csaturation", "10", CV_SAVE|CV_CALL, saturation_cons_t, CV_palette_OnChange); +consvar_t cv_bsaturation = CVAR_INIT ("bsaturation", "10", CV_SAVE|CV_CALL, saturation_cons_t, CV_palette_OnChange); +consvar_t cv_msaturation = CVAR_INIT ("msaturation", "10", CV_SAVE|CV_CALL, saturation_cons_t, CV_palette_OnChange); static CV_PossibleValue_t constextsize_cons_t[] = { {V_NOSCALEPATCH, "Small"}, {V_SMALLSCALEPATCH, "Medium"}, {V_MEDSCALEPATCH, "Large"}, {0, "Huge"}, {0, NULL}}; static void CV_constextsize_OnChange(void); -consvar_t cv_constextsize = {"con_textsize", "Medium", CV_SAVE|CV_CALL, constextsize_cons_t, CV_constextsize_OnChange, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_constextsize = CVAR_INIT ("con_textsize", "Medium", CV_SAVE|CV_CALL, constextsize_cons_t, CV_constextsize_OnChange); // local copy of the palette for V_GetColor() RGBA_t *pLocalPalette = NULL; diff --git a/src/win32/win_cd.c b/src/win32/win_cd.c index 2586b8440..324c24928 100644 --- a/src/win32/win_cd.c +++ b/src/win32/win_cd.c @@ -161,13 +161,13 @@ static BOOL wasPlaying; //static INT cdVolume = 0; // current cd volume (0-31) // 0-31 like Music & Sfx, though CD hardware volume is 0-255. -consvar_t cd_volume = {"cd_volume","18",CV_SAVE,soundvolume_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cd_volume = CVAR_INIT ("cd_volume","18",CV_SAVE,soundvolume_cons_t, NULL); // allow Update for next/loop track // some crap cd drivers take up to // a second for a simple 'busy' check.. // (on those Update can be disabled) -consvar_t cdUpdate = {"cd_update","1",CV_SAVE, NULL, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cdUpdate = CVAR_INIT ("cd_update","1",CV_SAVE, NULL, NULL); #if (__GNUC__ > 6) #pragma GCC diagnostic push diff --git a/src/win32/win_sys.c b/src/win32/win_sys.c index a374a2587..da0d5b47e 100644 --- a/src/win32/win_sys.c +++ b/src/win32/win_sys.c @@ -3658,7 +3658,7 @@ const CPUInfoFlags *I_CPUInfo(void) } static void CPUAffinity_OnChange(void); -static consvar_t cv_cpuaffinity = {"cpuaffinity", "-1", CV_CALL, NULL, CPUAffinity_OnChange, 0, NULL, NULL, 0, 0, NULL}; +static consvar_t cv_cpuaffinity = CVAR_INIT ("cpuaffinity", "-1", CV_CALL, NULL, CPUAffinity_OnChange); typedef HANDLE (WINAPI *p_GetCurrentProcess) (VOID); static p_GetCurrentProcess pfnGetCurrentProcess = NULL; diff --git a/src/win32/win_vid.c b/src/win32/win_vid.c index 716f38089..931e006eb 100644 --- a/src/win32/win_vid.c +++ b/src/win32/win_vid.c @@ -51,9 +51,9 @@ rendermode_t rendermode = render_soft; static void OnTop_OnChange(void); // synchronize page flipping with screen refresh static CV_PossibleValue_t CV_NeverOnOff[] = {{-1, "Never"}, {0, "Off"}, {1, "On"}, {0, NULL}}; -consvar_t cv_vidwait = {"vid_wait", "On", CV_SAVE, CV_OnOff, OnTop_OnChange, 0, NULL, NULL, 0, 0, NULL}; -static consvar_t cv_stretch = {"stretch", "On", CV_SAVE|CV_NOSHOWHELP, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -static consvar_t cv_ontop = {"ontop", "Never", 0, CV_NeverOnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_vidwait = CVAR_INIT ("vid_wait", "On", CV_SAVE, CV_OnOff, OnTop_OnChange); +static consvar_t cv_stretch = CVAR_INIT ("stretch", "On", CV_SAVE|CV_NOSHOWHELP, CV_OnOff, NULL); +static consvar_t cv_ontop = CVAR_INIT ("ontop", "Never", 0, CV_NeverOnOff, NULL); boolean highcolor; int vid_opengl_state = 0; From b3d8ed7d43a338b8edff13ea072747e6693d46d7 Mon Sep 17 00:00:00 2001 From: James R Date: Tue, 6 Oct 2020 23:32:11 -0700 Subject: [PATCH 0135/1080] Revert netvars after leaving a netgame --- src/command.c | 32 ++++++++++++++++++++++++++++++++ src/command.h | 15 ++++++++++++++- src/d_clisrv.c | 1 + 3 files changed, 47 insertions(+), 1 deletion(-) diff --git a/src/command.c b/src/command.c index 59f14e2f5..c8f1aeccc 100644 --- a/src/command.c +++ b/src/command.c @@ -1280,6 +1280,7 @@ void CV_RegisterVar(consvar_t *variable) consvar_vars = variable; } variable->string = variable->zstring = NULL; + memset(&variable->revert, 0, sizeof variable->revert); variable->changed = 0; // new variable has not been modified by the user #ifdef PARANOIA @@ -1676,8 +1677,19 @@ static void CV_LoadVars(UINT8 **p, serverloading = true; for (cvar = consvar_vars; cvar; cvar = cvar->next) + { if (cvar->flags & CV_NETVAR) + { + if (client && cvar->revert.v.string == NULL) + { + cvar->revert.v.const_munge = cvar->string; + cvar->revert.allocated = ( cvar->zstring != NULL ); + cvar->zstring = NULL;/* don't free this */ + } + Setvalue(cvar, cvar->defaultvalue, true); + } + } count = READUINT16(*p); while (count--) @@ -1691,6 +1703,26 @@ static void CV_LoadVars(UINT8 **p, serverloading = false; } +void CV_RevertNetVars(void) +{ + consvar_t * cvar; + + for (cvar = consvar_vars; cvar; cvar = cvar->next) + { + if (cvar->revert.v.string != NULL) + { + Setvalue(cvar, cvar->revert.v.string, false); + + if (cvar->revert.allocated) + { + Z_Free(cvar->revert.v.string); + } + + cvar->revert.v.string = NULL; + } + } +} + void CV_LoadNetVars(UINT8 **p) { CV_LoadVars(p, ReadNetVar); diff --git a/src/command.h b/src/command.h index 8275d0fd1..96813dc2c 100644 --- a/src/command.h +++ b/src/command.h @@ -138,6 +138,16 @@ typedef struct consvar_s //NULL, NULL, 0, NULL, NULL |, 0, NULL, NULL, 0, 0, NUL const char *string; // value in string char *zstring; // Either NULL or same as string. // If non-NULL, must be Z_Free'd later. + struct + { + char allocated; // whether to Z_Free + union + { + char * string; + const char * const_munge; + } v; + } revert; // value of netvar before joining netgame + UINT16 netid; // used internaly : netid for send end receive // used only with CV_NETVAR char changed; // has variable been changed by the user? 0 = no, 1 = yes @@ -146,7 +156,7 @@ typedef struct consvar_s //NULL, NULL, 0, NULL, NULL |, 0, NULL, NULL, 0, 0, NUL /* name, defaultvalue, flags, PossibleValue, func */ #define CVAR_INIT( ... ) \ -{ __VA_ARGS__, 0, NULL, NULL, 0U, (char)0, NULL } +{ __VA_ARGS__, 0, NULL, NULL, {0}, 0U, (char)0, NULL } #ifdef OLD22DEMOCOMPAT typedef struct old_demo_var old_demo_var_t; @@ -206,6 +216,9 @@ void CV_SaveVars(UINT8 **p, boolean in_demo); #define CV_SaveNetVars(p) CV_SaveVars(p, false) void CV_LoadNetVars(UINT8 **p); +// then revert after leaving a netgame +void CV_RevertNetVars(void); + #define CV_SaveDemoVars(p) CV_SaveVars(p, true) void CV_LoadDemoVars(UINT8 **p); diff --git a/src/d_clisrv.c b/src/d_clisrv.c index c9490410b..ceff769da 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -3208,6 +3208,7 @@ void CL_Reset(void) doomcom->numslots = 1; SV_StopServer(); SV_ResetServer(); + CV_RevertNetVars(); // make sure we don't leave any fileneeded gunk over from a failed join fileneedednum = 0; From b71c75d2ecadd54e9195ffe1ecccdb79c31ea4cb Mon Sep 17 00:00:00 2001 From: sphere Date: Thu, 8 Oct 2020 18:45:20 +0200 Subject: [PATCH 0136/1080] A special stage is a special stage, even outside of coop. --- src/g_game.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index ed39124e6..c1c892250 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -3514,7 +3514,7 @@ INT32 G_GetGametypeByName(const char *gametypestr) // boolean G_IsSpecialStage(INT32 mapnum) { - if (gametype != GT_COOP || modeattacking == ATTACKING_RECORD) + if (modeattacking == ATTACKING_RECORD) return false; if (mapnum >= sstage_start && mapnum <= sstage_end) return true; @@ -5158,4 +5158,3 @@ INT32 G_TicsToMilliseconds(tic_t tics) { return (INT32)((tics%TICRATE) * (1000.00f/TICRATE)); } - From 0811f60b2a5634c587e39ec22c8408bb948f8e88 Mon Sep 17 00:00:00 2001 From: Jaime Passos Date: Fri, 9 Oct 2020 02:06:13 -0300 Subject: [PATCH 0137/1080] Let the server or an admin toggle clients' custom shaders --- src/hardware/hw_defs.h | 10 + src/hardware/hw_drv.h | 2 +- src/hardware/hw_main.c | 41 ++-- src/hardware/hw_main.h | 4 +- src/hardware/r_opengl/r_opengl.c | 371 +++++++++++++++++-------------- src/sdl/ogl_sdl.c | 2 +- src/w_wad.c | 2 + 7 files changed, 250 insertions(+), 182 deletions(-) diff --git a/src/hardware/hw_defs.h b/src/hardware/hw_defs.h index 607d21ef5..644ab0ca2 100644 --- a/src/hardware/hw_defs.h +++ b/src/hardware/hw_defs.h @@ -295,6 +295,16 @@ enum hwdsetspecialstate typedef enum hwdsetspecialstate hwdspecialstate_t; +// Lactozilla: Shader options +enum hwdshaderoption +{ + HWD_SHADEROPTION_OFF, + HWD_SHADEROPTION_ON, + HWD_SHADEROPTION_NOCUSTOM, +}; + +typedef enum hwdshaderoption hwdshaderoption_t; + // Lactozilla: Shader info // Generally set at the start of the frame. enum hwdshaderinfo diff --git a/src/hardware/hw_drv.h b/src/hardware/hw_drv.h index aaa41e86f..266134105 100644 --- a/src/hardware/hw_drv.h +++ b/src/hardware/hw_drv.h @@ -70,7 +70,7 @@ EXPORT void HWRAPI(PostImgRedraw) (float points[SCREENVERTS][SCREENVERTS][2]); // jimita EXPORT boolean HWRAPI(CompileShaders) (void); EXPORT void HWRAPI(CleanShaders) (void); -EXPORT void HWRAPI(SetShader) (int shader); +EXPORT void HWRAPI(SetShader) (int type); EXPORT void HWRAPI(UnSetShader) (void); EXPORT void HWRAPI(SetShaderInfo) (hwdshaderinfo_t info, INT32 value); diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index a7015b3dc..60ec669e4 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -5555,6 +5555,20 @@ static void HWR_SetTransformAiming(FTransform *trans, player_t *player, boolean trans->anglex = (float)(gl_aimingangle>>ANGLETOFINESHIFT)*(360.0f/(float)FINEANGLES); } +// +// Sets the shader state. +// +static void HWR_SetShaderState(void) +{ + hwdshaderoption_t state = cv_glshaders.value; + + if (!cv_glallowshaders.value) + state = (cv_glshaders.value == HWD_SHADEROPTION_ON ? HWD_SHADEROPTION_NOCUSTOM : cv_glshaders.value); + + HWD.pfnSetSpecialState(HWD_SET_SHADERS, (INT32)state); + HWD.pfnSetShader(SHADER_DEFAULT); +} + // ========================================================================== // Same as rendering the player view, but from the skybox object // ========================================================================== @@ -5673,8 +5687,7 @@ void HWR_RenderSkyboxView(INT32 viewnumber, player_t *player) HWD.pfnSetTransform(&atransform); // Reset the shader state. - HWD.pfnSetSpecialState(HWD_SET_SHADERS, cv_glshaders.value); - HWD.pfnSetShader(SHADER_DEFAULT); + HWR_SetShaderState(); validcount++; @@ -5886,8 +5899,7 @@ void HWR_RenderPlayerView(INT32 viewnumber, player_t *player) HWD.pfnSetTransform(&atransform); // Reset the shader state. - HWD.pfnSetSpecialState(HWD_SET_SHADERS, cv_glshaders.value); - HWD.pfnSetShader(SHADER_DEFAULT); + HWR_SetShaderState(); rs_numbspcalls = 0; rs_numpolyobjects = 0; @@ -5982,9 +5994,10 @@ void HWR_RenderPlayerView(INT32 viewnumber, player_t *player) // 3D ENGINE COMMANDS // ========================================================================== -static CV_PossibleValue_t grmodelinterpolation_cons_t[] = {{0, "Off"}, {1, "Sometimes"}, {2, "Always"}, {0, NULL}}; -static CV_PossibleValue_t grfakecontrast_cons_t[] = {{0, "Off"}, {1, "On"}, {2, "Smooth"}, {0, NULL}}; -static CV_PossibleValue_t grshearing_cons_t[] = {{0, "Off"}, {1, "On"}, {2, "Third-person"}, {0, NULL}}; +static CV_PossibleValue_t glshaders_cons_t[] = {{HWD_SHADEROPTION_OFF, "Off"}, {HWD_SHADEROPTION_ON, "On"}, {HWD_SHADEROPTION_NOCUSTOM, "Ignore custom shaders"}, {0, NULL}}; +static CV_PossibleValue_t glmodelinterpolation_cons_t[] = {{0, "Off"}, {1, "Sometimes"}, {2, "Always"}, {0, NULL}}; +static CV_PossibleValue_t glfakecontrast_cons_t[] = {{0, "Off"}, {1, "On"}, {2, "Smooth"}, {0, NULL}}; +static CV_PossibleValue_t glshearing_cons_t[] = {{0, "Off"}, {1, "On"}, {2, "Third-person"}, {0, NULL}}; static void CV_glfiltermode_OnChange(void); static void CV_glanisotropic_OnChange(void); @@ -5995,9 +6008,10 @@ static CV_PossibleValue_t glfiltermode_cons_t[]= {{HWD_SET_TEXTUREFILTER_POINTSA {HWD_SET_TEXTUREFILTER_MIXED2, "Nearest_Linear"}, {HWD_SET_TEXTUREFILTER_MIXED3, "Nearest_Mipmap"}, {0, NULL}}; -CV_PossibleValue_t granisotropicmode_cons_t[] = {{1, "MIN"}, {16, "MAX"}, {0, NULL}}; +CV_PossibleValue_t glanisotropicmode_cons_t[] = {{1, "MIN"}, {16, "MAX"}, {0, NULL}}; -consvar_t cv_glshaders = {"gr_shaders", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_glshaders = {"gr_shaders", "On", CV_SAVE, glshaders_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_glallowshaders = {"gr_allowshaders", "On", CV_NETVAR, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_fovchange = {"gr_fovchange", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; #ifdef ALAM_LIGHTING @@ -6008,18 +6022,18 @@ consvar_t cv_glcoronasize = {"gr_coronasize", "1", CV_SAVE|CV_FLOAT, 0, NULL, 0, #endif consvar_t cv_glmodels = {"gr_models", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_glmodelinterpolation = {"gr_modelinterpolation", "Sometimes", CV_SAVE, grmodelinterpolation_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_glmodelinterpolation = {"gr_modelinterpolation", "Sometimes", CV_SAVE, glmodelinterpolation_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_glmodellighting = {"gr_modellighting", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_glshearing = {"gr_shearing", "Off", CV_SAVE, grshearing_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_glshearing = {"gr_shearing", "Off", CV_SAVE, glshearing_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_glspritebillboarding = {"gr_spritebillboarding", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_glskydome = {"gr_skydome", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_glfakecontrast = {"gr_fakecontrast", "Smooth", CV_SAVE, grfakecontrast_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_glfakecontrast = {"gr_fakecontrast", "Smooth", CV_SAVE, glfakecontrast_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_glslopecontrast = {"gr_slopecontrast", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_glfiltermode = {"gr_filtermode", "Nearest", CV_SAVE|CV_CALL, glfiltermode_cons_t, CV_glfiltermode_OnChange, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_glanisotropicmode = {"gr_anisotropicmode", "1", CV_CALL, granisotropicmode_cons_t, +consvar_t cv_glanisotropicmode = {"gr_anisotropicmode", "1", CV_CALL, glanisotropicmode_cons_t, CV_glanisotropic_OnChange, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_glsolvetjoin = {"gr_solvetjoin", "On", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -6059,6 +6073,7 @@ void HWR_AddCommands(void) CV_RegisterVar(&cv_glfakecontrast); CV_RegisterVar(&cv_glshearing); CV_RegisterVar(&cv_glshaders); + CV_RegisterVar(&cv_glallowshaders); CV_RegisterVar(&cv_glfiltermode); CV_RegisterVar(&cv_glsolvetjoin); diff --git a/src/hardware/hw_main.h b/src/hardware/hw_main.h index 9bce49b25..12c6f9fc5 100644 --- a/src/hardware/hw_main.h +++ b/src/hardware/hw_main.h @@ -78,7 +78,7 @@ const char *HWR_GetShaderName(INT32 shader); extern customshaderxlat_t shaderxlat[]; -extern CV_PossibleValue_t granisotropicmode_cons_t[]; +extern CV_PossibleValue_t glanisotropicmode_cons_t[]; #ifdef ALAM_LIGHTING extern consvar_t cv_gldynamiclighting; @@ -87,7 +87,7 @@ extern consvar_t cv_glcoronas; extern consvar_t cv_glcoronasize; #endif -extern consvar_t cv_glshaders; +extern consvar_t cv_glshaders, cv_glallowshaders; extern consvar_t cv_glmodels; extern consvar_t cv_glmodelinterpolation; extern consvar_t cv_glmodellighting; diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index db3c6a17d..1d2852d91 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -91,13 +91,6 @@ static GLuint startScreenWipe = 0; static GLuint endScreenWipe = 0; static GLuint finalScreenTexture = 0; -// Lactozilla: Shader functions -static void *Shader_Load(FSurfaceInfo *Surface, GLRGBAFloat *poly, GLRGBAFloat *tint, GLRGBAFloat *fade); -static void Shader_SetUniforms(FSurfaceInfo *Surface, GLRGBAFloat *poly, GLRGBAFloat *tint, GLRGBAFloat *fade); -static void Shader_CompileError(const char *message, GLuint program, INT32 shadernum); - -static GLRGBAFloat shader_defaultcolor = {1.0f, 1.0f, 1.0f, 1.0f}; - // shortcut for ((float)1/i) static const GLfloat byte2float[256] = { 0.000000f, 0.003922f, 0.007843f, 0.011765f, 0.015686f, 0.019608f, 0.023529f, 0.027451f, @@ -533,8 +526,8 @@ boolean SetupGLfunc(void) return true; } -static boolean gl_allowshaders = false; static boolean gl_shadersenabled = false; +static hwdshaderoption_t gl_allowshaders = HWD_SHADEROPTION_OFF; #ifdef GL_SHADERS typedef GLuint (APIENTRY *PFNglCreateShader) (GLenum); @@ -544,6 +537,7 @@ typedef void (APIENTRY *PFNglGetShaderiv) (GLuint, GLenum, GLint*); typedef void (APIENTRY *PFNglGetShaderInfoLog) (GLuint, GLsizei, GLsizei*, GLchar*); typedef void (APIENTRY *PFNglDeleteShader) (GLuint); typedef GLuint (APIENTRY *PFNglCreateProgram) (void); +typedef void (APIENTRY *PFNglDeleteProgram) (GLuint); typedef void (APIENTRY *PFNglAttachShader) (GLuint, GLuint); typedef void (APIENTRY *PFNglLinkProgram) (GLuint); typedef void (APIENTRY *PFNglGetProgramiv) (GLuint, GLenum, GLint*); @@ -565,6 +559,7 @@ static PFNglGetShaderiv pglGetShaderiv; static PFNglGetShaderInfoLog pglGetShaderInfoLog; static PFNglDeleteShader pglDeleteShader; static PFNglCreateProgram pglCreateProgram; +static PFNglDeleteProgram pglDeleteProgram; static PFNglAttachShader pglAttachShader; static PFNglLinkProgram pglLinkProgram; static PFNglGetProgramiv pglGetProgramiv; @@ -579,12 +574,6 @@ static PFNglUniform2fv pglUniform2fv; static PFNglUniform3fv pglUniform3fv; static PFNglGetUniformLocation pglGetUniformLocation; -// 18032019 -static GLuint gl_currentshaderprogram = 0; -static boolean gl_shaderprogramchanged = true; - -static shadersource_t gl_customshaders[HWR_MAXSHADERS]; - // 13062019 typedef enum { @@ -602,17 +591,37 @@ typedef enum gluniform_max, } gluniform_t; -typedef struct gl_shaderprogram_s +typedef struct gl_shader_s { GLuint program; - boolean custom; GLint uniforms[gluniform_max+1]; -} gl_shaderprogram_t; -static gl_shaderprogram_t gl_shaderprograms[HWR_MAXSHADERS]; + boolean custom; +} gl_shader_t; + +static gl_shader_t gl_shaders[HWR_MAXSHADERS]; +static gl_shader_t gl_usershaders[HWR_MAXSHADERS]; +static shadersource_t gl_customshaders[HWR_MAXSHADERS]; + +// 09102020 +typedef struct gl_shaderstate_s +{ + gl_shader_t *current; + GLuint type; + GLuint program; + boolean changed; +} gl_shaderstate_t; +static gl_shaderstate_t gl_shaderstate; // Shader info static INT32 shader_leveltime = 0; +// Lactozilla: Shader functions +static boolean Shader_CompileProgram(gl_shader_t *shader, GLint i, const GLchar *vert_shader, const GLchar *frag_shader); +static void Shader_CompileError(const char *message, GLuint program, INT32 shadernum); +static void Shader_SetUniforms(FSurfaceInfo *Surface, GLRGBAFloat *poly, GLRGBAFloat *tint, GLRGBAFloat *fade); + +static GLRGBAFloat shader_defaultcolor = {1.0f, 1.0f, 1.0f, 1.0f}; + // ================ // Vertex shaders // ================ @@ -873,6 +882,7 @@ void SetupGLFunc4(void) pglGetShaderInfoLog = GetGLFunc("glGetShaderInfoLog"); pglDeleteShader = GetGLFunc("glDeleteShader"); pglCreateProgram = GetGLFunc("glCreateProgram"); + pglDeleteProgram = GetGLFunc("glDeleteProgram"); pglAttachShader = GetGLFunc("glAttachShader"); pglLinkProgram = GetGLFunc("glLinkProgram"); pglGetProgramiv = GetGLFunc("glGetProgramiv"); @@ -896,20 +906,40 @@ void SetupGLFunc4(void) EXPORT boolean HWRAPI(CompileShaders) (void) { #ifdef GL_SHADERS - GLuint gl_vertShader, gl_fragShader; - GLint i, result; + GLint i; - if (!pglUseProgram) return false; + if (!pglUseProgram) + return false; - gl_customshaders[0].vertex = NULL; - gl_customshaders[0].fragment = NULL; + gl_customshaders[SHADER_DEFAULT].vertex = NULL; + gl_customshaders[SHADER_DEFAULT].fragment = NULL; for (i = 0; gl_shadersources[i].vertex && gl_shadersources[i].fragment; i++) { - gl_shaderprogram_t *shader; + gl_shader_t *shader, *usershader; const GLchar *vert_shader = gl_shadersources[i].vertex; const GLchar *frag_shader = gl_shadersources[i].fragment; - boolean custom = ((gl_customshaders[i].vertex || gl_customshaders[i].fragment) && (i > 0)); + + if (i >= HWR_MAXSHADERS) + break; + + shader = &gl_shaders[i]; + usershader = &gl_usershaders[i]; + + if (shader->program) + pglDeleteProgram(shader->program); + if (usershader->program) + pglDeleteProgram(usershader->program); + + shader->program = 0; + usershader->program = 0; + + if (!Shader_CompileProgram(shader, i, vert_shader, frag_shader)) + shader->program = 0; + + // Compile custom shader + if ((i == SHADER_DEFAULT) || !(gl_customshaders[i].vertex || gl_customshaders[i].fragment)) + continue; // 18032019 if (gl_customshaders[i].vertex) @@ -917,92 +947,15 @@ EXPORT boolean HWRAPI(CompileShaders) (void) if (gl_customshaders[i].fragment) frag_shader = gl_customshaders[i].fragment; - if (i >= HWR_MAXSHADERS) - break; - - shader = &gl_shaderprograms[i]; - shader->program = 0; - shader->custom = custom; - - // - // Load and compile vertex shader - // - gl_vertShader = pglCreateShader(GL_VERTEX_SHADER); - if (!gl_vertShader) + if (!Shader_CompileProgram(usershader, i, vert_shader, frag_shader)) { - GL_MSG_Error("CompileShaders: Error creating vertex shader %s\n", HWR_GetShaderName(i)); - continue; + GL_MSG_Warning("CompileShaders: Could not compile custom shader program for %s\n", HWR_GetShaderName(i)); + usershader->program = 0; } - - pglShaderSource(gl_vertShader, 1, &vert_shader, NULL); - pglCompileShader(gl_vertShader); - - // check for compile errors - pglGetShaderiv(gl_vertShader, GL_COMPILE_STATUS, &result); - if (result == GL_FALSE) - { - Shader_CompileError("Error compiling vertex shader", gl_vertShader, i); - continue; - } - - // - // Load and compile fragment shader - // - gl_fragShader = pglCreateShader(GL_FRAGMENT_SHADER); - if (!gl_fragShader) - { - GL_MSG_Error("CompileShaders: Error creating fragment shader %s\n", HWR_GetShaderName(i)); - continue; - } - - pglShaderSource(gl_fragShader, 1, &frag_shader, NULL); - pglCompileShader(gl_fragShader); - - // check for compile errors - pglGetShaderiv(gl_fragShader, GL_COMPILE_STATUS, &result); - if (result == GL_FALSE) - { - Shader_CompileError("Error compiling fragment shader", gl_fragShader, i); - continue; - } - - shader->program = pglCreateProgram(); - pglAttachShader(shader->program, gl_vertShader); - pglAttachShader(shader->program, gl_fragShader); - pglLinkProgram(shader->program); - - // check link status - pglGetProgramiv(shader->program, GL_LINK_STATUS, &result); - - // delete the shader objects - pglDeleteShader(gl_vertShader); - pglDeleteShader(gl_fragShader); - - // couldn't link? - if (result != GL_TRUE) - { - shader->program = 0; - shader->custom = false; - GL_MSG_Error("CompileShaders: Error linking shader program %s\n", HWR_GetShaderName(i)); - continue; - } - - // 13062019 -#define GETUNI(uniform) pglGetUniformLocation(shader->program, uniform); - - // lighting - shader->uniforms[gluniform_poly_color] = GETUNI("poly_color"); - shader->uniforms[gluniform_tint_color] = GETUNI("tint_color"); - shader->uniforms[gluniform_fade_color] = GETUNI("fade_color"); - shader->uniforms[gluniform_lighting] = GETUNI("lighting"); - shader->uniforms[gluniform_fade_start] = GETUNI("fade_start"); - shader->uniforms[gluniform_fade_end] = GETUNI("fade_end"); - - // misc. (custom shaders) - shader->uniforms[gluniform_leveltime] = GETUNI("leveltime"); - -#undef GETUNI } + + SetShader(SHADER_DEFAULT); + return true; #else return false; @@ -1070,26 +1023,45 @@ EXPORT void HWRAPI(LoadCustomShader) (int number, char *code, size_t size, boole #endif } -EXPORT void HWRAPI(SetShader) (int shader) +EXPORT void HWRAPI(SetShader) (int type) { #ifdef GL_SHADERS - if (gl_allowshaders) + if (gl_allowshaders != HWD_SHADEROPTION_OFF) { + gl_shader_t *shader = gl_shaderstate.current; + // If using model lighting, set the appropriate shader. // However don't override a custom shader. - if (shader == SHADER_MODEL && model_lighting - && !(gl_shaderprograms[SHADER_MODEL].custom && !gl_shaderprograms[SHADER_MODEL_LIGHTING].custom)) - shader = SHADER_MODEL_LIGHTING; - if ((GLuint)shader != gl_currentshaderprogram) + if (type == SHADER_MODEL && model_lighting + && !(gl_shaders[SHADER_MODEL].custom && !gl_shaders[SHADER_MODEL_LIGHTING].custom)) + type = SHADER_MODEL_LIGHTING; + + if ((shader == NULL) || (GLuint)type != gl_shaderstate.type) { - gl_currentshaderprogram = shader; - gl_shaderprogramchanged = true; + gl_shader_t *baseshader = &gl_shaders[type]; + gl_shader_t *usershader = &gl_usershaders[type]; + + if (usershader->program) + shader = (gl_allowshaders == HWD_SHADEROPTION_NOCUSTOM) ? baseshader : usershader; + else + shader = baseshader; + + gl_shaderstate.current = shader; + gl_shaderstate.type = type; + gl_shaderstate.changed = true; } - gl_shadersenabled = true; + + if (gl_shaderstate.program != shader->program) + { + gl_shaderstate.program = shader->program; + gl_shaderstate.changed = true; + } + + gl_shadersenabled = (shader->program != 0); return; } #else - (void)shader; + (void)type; #endif gl_shadersenabled = false; } @@ -1097,11 +1069,15 @@ EXPORT void HWRAPI(SetShader) (int shader) EXPORT void HWRAPI(UnSetShader) (void) { #ifdef GL_SHADERS - gl_shadersenabled = false; - gl_currentshaderprogram = 0; - if (!pglUseProgram) return; - pglUseProgram(0); + gl_shaderstate.current = NULL; + gl_shaderstate.type = 0; + gl_shaderstate.program = 0; + + if (pglUseProgram) + pglUseProgram(0); #endif + + gl_shadersenabled = false; } EXPORT void HWRAPI(CleanShaders) (void) @@ -1901,42 +1877,24 @@ EXPORT void HWRAPI(SetTexture) (FTextureInfo *pTexInfo) } } -static void *Shader_Load(FSurfaceInfo *Surface, GLRGBAFloat *poly, GLRGBAFloat *tint, GLRGBAFloat *fade) -{ -#ifdef GL_SHADERS - if (gl_shadersenabled && pglUseProgram) - { - gl_shaderprogram_t *shader = &gl_shaderprograms[gl_currentshaderprogram]; - if (shader->program) - { - if (gl_shaderprogramchanged) - { - pglUseProgram(gl_shaderprograms[gl_currentshaderprogram].program); - gl_shaderprogramchanged = false; - } - Shader_SetUniforms(Surface, poly, tint, fade); - return shader; - } - else - pglUseProgram(0); - } -#else - (void)Surface; - (void)poly; - (void)tint; - (void)fade; -#endif - return NULL; -} - static void Shader_SetUniforms(FSurfaceInfo *Surface, GLRGBAFloat *poly, GLRGBAFloat *tint, GLRGBAFloat *fade) { #ifdef GL_SHADERS - if (gl_shadersenabled) + gl_shader_t *shader = gl_shaderstate.current; + + if (gl_shadersenabled && (shader != NULL) && pglUseProgram) { - gl_shaderprogram_t *shader = &gl_shaderprograms[gl_currentshaderprogram]; if (!shader->program) + { + pglUseProgram(0); return; + } + + if (gl_shaderstate.changed) + { + pglUseProgram(shader->program); + gl_shaderstate.changed = false; + } // Color uniforms can be left NULL and will be set to white (1.0f, 1.0f, 1.0f, 1.0f) if (poly == NULL) @@ -1989,6 +1947,97 @@ static void Shader_SetUniforms(FSurfaceInfo *Surface, GLRGBAFloat *poly, GLRGBAF #endif } +static boolean Shader_CompileProgram(gl_shader_t *shader, GLint i, const GLchar *vert_shader, const GLchar *frag_shader) +{ + GLuint gl_vertShader, gl_fragShader; + GLint result; + + // + // Load and compile vertex shader + // + gl_vertShader = pglCreateShader(GL_VERTEX_SHADER); + if (!gl_vertShader) + { + GL_MSG_Error("Shader_CompileProgram: Error creating vertex shader %s\n", HWR_GetShaderName(i)); + return false; + } + + pglShaderSource(gl_vertShader, 1, &vert_shader, NULL); + pglCompileShader(gl_vertShader); + + // check for compile errors + pglGetShaderiv(gl_vertShader, GL_COMPILE_STATUS, &result); + if (result == GL_FALSE) + { + Shader_CompileError("Error compiling vertex shader", gl_vertShader, i); + pglDeleteShader(gl_vertShader); + return false; + } + + // + // Load and compile fragment shader + // + gl_fragShader = pglCreateShader(GL_FRAGMENT_SHADER); + if (!gl_fragShader) + { + GL_MSG_Error("Shader_CompileProgram: Error creating fragment shader %s\n", HWR_GetShaderName(i)); + pglDeleteShader(gl_vertShader); + pglDeleteShader(gl_fragShader); + return false; + } + + pglShaderSource(gl_fragShader, 1, &frag_shader, NULL); + pglCompileShader(gl_fragShader); + + // check for compile errors + pglGetShaderiv(gl_fragShader, GL_COMPILE_STATUS, &result); + if (result == GL_FALSE) + { + Shader_CompileError("Error compiling fragment shader", gl_fragShader, i); + pglDeleteShader(gl_vertShader); + pglDeleteShader(gl_fragShader); + return false; + } + + shader->program = pglCreateProgram(); + pglAttachShader(shader->program, gl_vertShader); + pglAttachShader(shader->program, gl_fragShader); + pglLinkProgram(shader->program); + + // check link status + pglGetProgramiv(shader->program, GL_LINK_STATUS, &result); + + // delete the shader objects + pglDeleteShader(gl_vertShader); + pglDeleteShader(gl_fragShader); + + // couldn't link? + if (result != GL_TRUE) + { + GL_MSG_Error("Shader_CompileProgram: Error linking shader program %s\n", HWR_GetShaderName(i)); + pglDeleteProgram(shader->program); + return false; + } + + // 13062019 +#define GETUNI(uniform) pglGetUniformLocation(shader->program, uniform); + + // lighting + shader->uniforms[gluniform_poly_color] = GETUNI("poly_color"); + shader->uniforms[gluniform_tint_color] = GETUNI("tint_color"); + shader->uniforms[gluniform_fade_color] = GETUNI("fade_color"); + shader->uniforms[gluniform_lighting] = GETUNI("lighting"); + shader->uniforms[gluniform_fade_start] = GETUNI("fade_start"); + shader->uniforms[gluniform_fade_end] = GETUNI("fade_end"); + + // misc. (custom shaders) + shader->uniforms[gluniform_leveltime] = GETUNI("leveltime"); + +#undef GETUNI + + return true; +} + static void Shader_CompileError(const char *message, GLuint program, INT32 shadernum) { GLchar *infoLog = NULL; @@ -2002,7 +2051,7 @@ static void Shader_CompileError(const char *message, GLuint program, INT32 shade pglGetShaderInfoLog(program, logLength, NULL, infoLog); } - GL_MSG_Error("CompileShaders: %s (%s)\n%s", message, HWR_GetShaderName(shadernum), (infoLog ? infoLog : "")); + GL_MSG_Error("Shader_CompileProgram: %s (%s)\n%s", message, HWR_GetShaderName(shadernum), (infoLog ? infoLog : "")); if (infoLog) free(infoLog); @@ -2112,7 +2161,7 @@ static void PreparePolygon(FSurfaceInfo *pSurf, FOutVector *pOutVerts, FBITFIELD pglColor4ubv(c); } - Shader_Load(pSurf, &poly, &tint, &fade); + Shader_SetUniforms(pSurf, &poly, &tint, &fade); } // -----------------+ @@ -2158,7 +2207,7 @@ EXPORT void HWRAPI(RenderSkyDome) (gl_sky_t *sky) { int i, j; - Shader_Load(NULL, NULL, NULL, NULL); + Shader_SetUniforms(NULL, NULL, NULL, NULL); // Build the sky dome! Yes! if (sky->rebuild) @@ -2250,15 +2299,7 @@ EXPORT void HWRAPI(SetSpecialState) (hwdspecialstate_t IdState, INT32 Value) break; case HWD_SET_SHADERS: - switch (Value) - { - case 1: - gl_allowshaders = true; - break; - default: - gl_allowshaders = false; - break; - } + gl_allowshaders = (hwdshaderoption_t)Value; break; case HWD_SET_TEXTUREFILTERMODE: @@ -2607,7 +2648,7 @@ static void DrawModelEx(model_t *model, INT32 frameIndex, INT32 duration, INT32 fade.blue = byte2float[Surface->FadeColor.s.blue]; fade.alpha = byte2float[Surface->FadeColor.s.alpha]; - Shader_Load(Surface, &poly, &tint, &fade); + Shader_SetUniforms(Surface, &poly, &tint, &fade); pglEnable(GL_CULL_FACE); pglEnable(GL_NORMALIZE); diff --git a/src/sdl/ogl_sdl.c b/src/sdl/ogl_sdl.c index edc69b21d..98f2f4894 100644 --- a/src/sdl/ogl_sdl.c +++ b/src/sdl/ogl_sdl.c @@ -177,7 +177,7 @@ boolean OglSdlSurface(INT32 w, INT32 h) SetupGLFunc4(); - granisotropicmode_cons_t[1].value = maximumAnisotropy; + glanisotropicmode_cons_t[1].value = maximumAnisotropy; SDL_GL_SetSwapInterval(cv_vidwait.value ? 1 : 0); diff --git a/src/w_wad.c b/src/w_wad.c index fd70f8ec3..3bfb52781 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -2082,6 +2082,8 @@ int W_VerifyNMUSlumps(const char *filename) {"YB_", 3}, // Intermission graphics, goes with the above {"M_", 2}, // As does menu stuff {"MUSICDEF", 8}, // Song definitions (thanks kart) + {"SHADERS", 7}, // OpenGL shader definitions + {"SH_", 3}, // GLSL shader {NULL, 0}, }; From 76d16473b958df3db79f61a170f6cb0b4fa32b9c Mon Sep 17 00:00:00 2001 From: sphere Date: Fri, 9 Oct 2020 05:55:10 -0400 Subject: [PATCH 0138/1080] how did this even happen --- src/g_game.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/g_game.c b/src/g_game.c index c1c892250..33464cb03 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -5158,3 +5158,4 @@ INT32 G_TicsToMilliseconds(tic_t tics) { return (INT32)((tics%TICRATE) * (1000.00f/TICRATE)); } + From a17446f9056f4c3a93e024dd29702d76d2c6fd36 Mon Sep 17 00:00:00 2001 From: James R Date: Fri, 9 Oct 2020 13:16:56 -0700 Subject: [PATCH 0139/1080] Oops, go straight to evaluation if not in a netgame serverrunning means that you are actually the server. --- 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 f7c798b4b..db9c4864f 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -2019,7 +2019,7 @@ boolean G_Responder(event_t *ev) if (F_CreditResponder(ev)) { // Skip credits for everyone - if (! serverrunning)/* hahahahahaha */ + if (! netgame) F_StartGameEvaluation(); else if (server || IsPlayerAdmin(consoleplayer)) SendNetXCmd(XD_EXITLEVEL, NULL, 0); From 1c751fdf0f9445d3cf86f50b7b9ecb4c4c139374 Mon Sep 17 00:00:00 2001 From: Zippy_Zolton Date: Fri, 9 Oct 2020 15:42:55 -0500 Subject: [PATCH 0140/1080] I am going to die :D --- src/p_mobj.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index de4385fa7..ffa247053 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -11956,9 +11956,6 @@ static mobjtype_t P_GetMobjtypeSubstitute(mapthing_t *mthing, mobjtype_t i) return MT_SCORE1K_BOX; // 1,000 } - if (mariomode && i == MT_ROSY) - return MT_TOAD; // don't remove on penalty of death - return i; } From aa102dcea0b9695dad339db468d0f2dc59af0866 Mon Sep 17 00:00:00 2001 From: James R Date: Fri, 9 Oct 2020 15:06:09 -0700 Subject: [PATCH 0141/1080] Add CV_SAVE to netvars dumpconsistency allowjoin joinnextround restrictskinchange allowteamchange startinglives respawndelay competitionboxes allowseenames matchboxes specialrings powerstones countdowntime touchtag hidetime autobalance teamscramble scrambleonchange friendlyfire overtime pointlimit timelimit basenumlaps allowexitlevel inttime coopstarposts cooplives advancemap playersforexit exitmove pausepermission respawnitemtime respawnitem flagtime tv_recycler tv_teleporter tv_superring tv_supersneaker tv_invincibility tv_jumpshield tv_watershield tv_ringshield tv_forceshield tv_bombshield tv_1up tv_eggmanbox --- src/d_clisrv.c | 6 ++-- src/d_netcmd.c | 80 +++++++++++++++++++++++++------------------------- src/p_mobj.c | 6 ++-- 3 files changed, 46 insertions(+), 46 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index ceff769da..3c813eee4 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -2119,7 +2119,7 @@ static void SV_SendSaveGame(INT32 node) #ifdef DUMPCONSISTENCY #define TMPSAVENAME "badmath.sav" -static consvar_t cv_dumpconsistency = CVAR_INIT ("dumpconsistency", "Off", CV_NETVAR, CV_OnOff, NULL); +static consvar_t cv_dumpconsistency = CVAR_INIT ("dumpconsistency", "Off", CV_SAVE|CV_NETVAR, CV_OnOff, NULL); static void SV_SavedGame(void) { @@ -3678,8 +3678,8 @@ static void Got_KickCmd(UINT8 **p, INT32 playernum) static CV_PossibleValue_t netticbuffer_cons_t[] = {{0, "MIN"}, {3, "MAX"}, {0, NULL}}; consvar_t cv_netticbuffer = CVAR_INIT ("netticbuffer", "1", CV_SAVE, netticbuffer_cons_t, NULL); -consvar_t cv_allownewplayer = CVAR_INIT ("allowjoin", "On", CV_NETVAR, CV_OnOff, NULL); -consvar_t cv_joinnextround = CVAR_INIT ("joinnextround", "Off", CV_NETVAR, CV_OnOff, NULL); /// \todo not done +consvar_t cv_allownewplayer = CVAR_INIT ("allowjoin", "On", CV_SAVE|CV_NETVAR, CV_OnOff, NULL); +consvar_t cv_joinnextround = CVAR_INIT ("joinnextround", "Off", CV_SAVE|CV_NETVAR, CV_OnOff, NULL); /// \todo not done static CV_PossibleValue_t maxplayers_cons_t[] = {{2, "MIN"}, {32, "MAX"}, {0, NULL}}; consvar_t cv_maxplayers = CVAR_INIT ("maxplayers", "8", CV_SAVE, maxplayers_cons_t, NULL); static CV_PossibleValue_t joindelay_cons_t[] = {{1, "MIN"}, {3600, "MAX"}, {0, "Off"}, {0, NULL}}; diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 6f4bcdb1d..c2579b4ab 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -204,20 +204,20 @@ static consvar_t cv_fishcake = CVAR_INIT ("fishcake", "Off", CV_CALL|CV_NOSHOWHE #endif static consvar_t cv_dummyconsvar = CVAR_INIT ("dummyconsvar", "Off", CV_CALL|CV_NOSHOWHELP, CV_OnOff, DummyConsvar_OnChange); -consvar_t cv_restrictskinchange = CVAR_INIT ("restrictskinchange", "Yes", CV_NETVAR|CV_CHEAT, CV_YesNo, NULL); -consvar_t cv_allowteamchange = CVAR_INIT ("allowteamchange", "Yes", CV_NETVAR, CV_YesNo, NULL); +consvar_t cv_restrictskinchange = CVAR_INIT ("restrictskinchange", "Yes", CV_SAVE|CV_NETVAR|CV_CHEAT, CV_YesNo, NULL); +consvar_t cv_allowteamchange = CVAR_INIT ("allowteamchange", "Yes", CV_SAVE|CV_NETVAR, CV_YesNo, NULL); -consvar_t cv_startinglives = CVAR_INIT ("startinglives", "3", CV_NETVAR|CV_CHEAT, startingliveslimit_cons_t, NULL); +consvar_t cv_startinglives = CVAR_INIT ("startinglives", "3", CV_SAVE|CV_NETVAR|CV_CHEAT, startingliveslimit_cons_t, NULL); static CV_PossibleValue_t respawntime_cons_t[] = {{1, "MIN"}, {30, "MAX"}, {0, "Off"}, {0, NULL}}; -consvar_t cv_respawntime = CVAR_INIT ("respawndelay", "3", CV_NETVAR|CV_CHEAT, respawntime_cons_t, NULL); +consvar_t cv_respawntime = CVAR_INIT ("respawndelay", "3", CV_SAVE|CV_NETVAR|CV_CHEAT, respawntime_cons_t, NULL); -consvar_t cv_competitionboxes = CVAR_INIT ("competitionboxes", "Mystery", CV_NETVAR|CV_CHEAT, competitionboxes_cons_t, NULL); +consvar_t cv_competitionboxes = CVAR_INIT ("competitionboxes", "Mystery", CV_SAVE|CV_NETVAR|CV_CHEAT, competitionboxes_cons_t, NULL); #ifdef SEENAMES static CV_PossibleValue_t seenames_cons_t[] = {{0, "Off"}, {1, "Colorless"}, {2, "Team"}, {3, "Ally/Foe"}, {0, NULL}}; consvar_t cv_seenames = CVAR_INIT ("seenames", "Ally/Foe", CV_SAVE, seenames_cons_t, 0); -consvar_t cv_allowseenames = CVAR_INIT ("allowseenames", "Yes", CV_NETVAR, CV_YesNo, NULL); +consvar_t cv_allowseenames = CVAR_INIT ("allowseenames", "Yes", CV_SAVE|CV_NETVAR, CV_YesNo, NULL); #endif // names @@ -264,22 +264,22 @@ consvar_t cv_mouse2opt = CVAR_INIT ("mouse2opt", "0", CV_SAVE, NULL, NULL); consvar_t cv_mouse2port = CVAR_INIT ("mouse2port", "COM2", CV_SAVE, mouse2port_cons_t, NULL); #endif -consvar_t cv_matchboxes = CVAR_INIT ("matchboxes", "Normal", CV_NETVAR|CV_CHEAT, matchboxes_cons_t, NULL); -consvar_t cv_specialrings = CVAR_INIT ("specialrings", "On", CV_NETVAR, CV_OnOff, NULL); -consvar_t cv_powerstones = CVAR_INIT ("powerstones", "On", CV_NETVAR, CV_OnOff, NULL); +consvar_t cv_matchboxes = CVAR_INIT ("matchboxes", "Normal", CV_SAVE|CV_NETVAR|CV_CHEAT, matchboxes_cons_t, NULL); +consvar_t cv_specialrings = CVAR_INIT ("specialrings", "On", CV_SAVE|CV_NETVAR, CV_OnOff, NULL); +consvar_t cv_powerstones = CVAR_INIT ("powerstones", "On", CV_SAVE|CV_NETVAR, CV_OnOff, NULL); -consvar_t cv_recycler = CVAR_INIT ("tv_recycler", "5", CV_NETVAR|CV_CHEAT, chances_cons_t, NULL); -consvar_t cv_teleporters = CVAR_INIT ("tv_teleporter", "5", CV_NETVAR|CV_CHEAT, chances_cons_t, NULL); -consvar_t cv_superring = CVAR_INIT ("tv_superring", "5", CV_NETVAR|CV_CHEAT, chances_cons_t, NULL); -consvar_t cv_supersneakers = CVAR_INIT ("tv_supersneaker", "5", CV_NETVAR|CV_CHEAT, chances_cons_t, NULL); -consvar_t cv_invincibility = CVAR_INIT ("tv_invincibility", "5", CV_NETVAR|CV_CHEAT, chances_cons_t, NULL); -consvar_t cv_jumpshield = CVAR_INIT ("tv_jumpshield", "5", CV_NETVAR|CV_CHEAT, chances_cons_t, NULL); -consvar_t cv_watershield = CVAR_INIT ("tv_watershield", "5", CV_NETVAR|CV_CHEAT, chances_cons_t, NULL); -consvar_t cv_ringshield = CVAR_INIT ("tv_ringshield", "5", CV_NETVAR|CV_CHEAT, chances_cons_t, NULL); -consvar_t cv_forceshield = CVAR_INIT ("tv_forceshield", "5", CV_NETVAR|CV_CHEAT, chances_cons_t, NULL); -consvar_t cv_bombshield = CVAR_INIT ("tv_bombshield", "5", CV_NETVAR|CV_CHEAT, chances_cons_t, NULL); -consvar_t cv_1up = CVAR_INIT ("tv_1up", "5", CV_NETVAR|CV_CHEAT, chances_cons_t, NULL); -consvar_t cv_eggmanbox = CVAR_INIT ("tv_eggman", "5", CV_NETVAR|CV_CHEAT, chances_cons_t, NULL); +consvar_t cv_recycler = CVAR_INIT ("tv_recycler", "5", CV_SAVE|CV_NETVAR|CV_CHEAT, chances_cons_t, NULL); +consvar_t cv_teleporters = CVAR_INIT ("tv_teleporter", "5", CV_SAVE|CV_NETVAR|CV_CHEAT, chances_cons_t, NULL); +consvar_t cv_superring = CVAR_INIT ("tv_superring", "5", CV_SAVE|CV_NETVAR|CV_CHEAT, chances_cons_t, NULL); +consvar_t cv_supersneakers = CVAR_INIT ("tv_supersneaker", "5", CV_SAVE|CV_NETVAR|CV_CHEAT, chances_cons_t, NULL); +consvar_t cv_invincibility = CVAR_INIT ("tv_invincibility", "5", CV_SAVE|CV_NETVAR|CV_CHEAT, chances_cons_t, NULL); +consvar_t cv_jumpshield = CVAR_INIT ("tv_jumpshield", "5", CV_SAVE|CV_NETVAR|CV_CHEAT, chances_cons_t, NULL); +consvar_t cv_watershield = CVAR_INIT ("tv_watershield", "5", CV_SAVE|CV_NETVAR|CV_CHEAT, chances_cons_t, NULL); +consvar_t cv_ringshield = CVAR_INIT ("tv_ringshield", "5", CV_SAVE|CV_NETVAR|CV_CHEAT, chances_cons_t, NULL); +consvar_t cv_forceshield = CVAR_INIT ("tv_forceshield", "5", CV_SAVE|CV_NETVAR|CV_CHEAT, chances_cons_t, NULL); +consvar_t cv_bombshield = CVAR_INIT ("tv_bombshield", "5", CV_SAVE|CV_NETVAR|CV_CHEAT, chances_cons_t, NULL); +consvar_t cv_1up = CVAR_INIT ("tv_1up", "5", CV_SAVE|CV_NETVAR|CV_CHEAT, chances_cons_t, NULL); +consvar_t cv_eggmanbox = CVAR_INIT ("tv_eggman", "5", CV_SAVE|CV_NETVAR|CV_CHEAT, chances_cons_t, NULL); consvar_t cv_ringslinger = CVAR_INIT ("ringslinger", "No", CV_NETVAR|CV_NOSHOWHELP|CV_CALL|CV_CHEAT, CV_YesNo, Ringslinger_OnChange); consvar_t cv_gravity = CVAR_INIT ("gravity", "0.5", CV_RESTRICT|CV_FLOAT|CV_CALL, NULL, Gravity_OnChange); @@ -287,20 +287,20 @@ consvar_t cv_gravity = CVAR_INIT ("gravity", "0.5", CV_RESTRICT|CV_FLOAT|CV_CALL consvar_t cv_soundtest = CVAR_INIT ("soundtest", "0", CV_CALL, NULL, SoundTest_OnChange); static CV_PossibleValue_t minitimelimit_cons_t[] = {{15, "MIN"}, {9999, "MAX"}, {0, NULL}}; -consvar_t cv_countdowntime = CVAR_INIT ("countdowntime", "60", CV_NETVAR|CV_CHEAT, minitimelimit_cons_t, NULL); +consvar_t cv_countdowntime = CVAR_INIT ("countdowntime", "60", CV_SAVE|CV_NETVAR|CV_CHEAT, minitimelimit_cons_t, NULL); -consvar_t cv_touchtag = CVAR_INIT ("touchtag", "Off", CV_NETVAR, CV_OnOff, NULL); -consvar_t cv_hidetime = CVAR_INIT ("hidetime", "30", CV_NETVAR|CV_CALL, minitimelimit_cons_t, Hidetime_OnChange); +consvar_t cv_touchtag = CVAR_INIT ("touchtag", "Off", CV_SAVE|CV_NETVAR, CV_OnOff, NULL); +consvar_t cv_hidetime = CVAR_INIT ("hidetime", "30", CV_SAVE|CV_NETVAR|CV_CALL, minitimelimit_cons_t, Hidetime_OnChange); -consvar_t cv_autobalance = CVAR_INIT ("autobalance", "Off", CV_NETVAR|CV_CALL, CV_OnOff, AutoBalance_OnChange); -consvar_t cv_teamscramble = CVAR_INIT ("teamscramble", "Off", CV_NETVAR|CV_CALL|CV_NOINIT, teamscramble_cons_t, TeamScramble_OnChange); -consvar_t cv_scrambleonchange = CVAR_INIT ("scrambleonchange", "Off", CV_NETVAR, teamscramble_cons_t, NULL); +consvar_t cv_autobalance = CVAR_INIT ("autobalance", "Off", CV_SAVE|CV_NETVAR|CV_CALL, CV_OnOff, AutoBalance_OnChange); +consvar_t cv_teamscramble = CVAR_INIT ("teamscramble", "Off", CV_SAVE|CV_NETVAR|CV_CALL|CV_NOINIT, teamscramble_cons_t, TeamScramble_OnChange); +consvar_t cv_scrambleonchange = CVAR_INIT ("scrambleonchange", "Off", CV_SAVE|CV_NETVAR, teamscramble_cons_t, NULL); -consvar_t cv_friendlyfire = CVAR_INIT ("friendlyfire", "Off", CV_NETVAR, CV_OnOff, NULL); +consvar_t cv_friendlyfire = CVAR_INIT ("friendlyfire", "Off", CV_SAVE|CV_NETVAR, CV_OnOff, NULL); consvar_t cv_itemfinder = CVAR_INIT ("itemfinder", "Off", CV_CALL, CV_OnOff, ItemFinder_OnChange); // Scoring type options -consvar_t cv_overtime = CVAR_INIT ("overtime", "Yes", CV_NETVAR, CV_YesNo, NULL); +consvar_t cv_overtime = CVAR_INIT ("overtime", "Yes", CV_SAVE|CV_NETVAR, CV_YesNo, NULL); consvar_t cv_rollingdemos = CVAR_INIT ("rollingdemos", "On", CV_SAVE, CV_OnOff, NULL); @@ -311,13 +311,13 @@ static CV_PossibleValue_t powerupdisplay_cons_t[] = {{0, "Never"}, {1, "First-pe consvar_t cv_powerupdisplay = CVAR_INIT ("powerupdisplay", "First-person only", CV_SAVE, powerupdisplay_cons_t, NULL); static CV_PossibleValue_t pointlimit_cons_t[] = {{1, "MIN"}, {MAXSCORE, "MAX"}, {0, "None"}, {0, NULL}}; -consvar_t cv_pointlimit = CVAR_INIT ("pointlimit", "None", CV_NETVAR|CV_CALL|CV_NOINIT, pointlimit_cons_t, PointLimit_OnChange); +consvar_t cv_pointlimit = CVAR_INIT ("pointlimit", "None", CV_SAVE|CV_NETVAR|CV_CALL|CV_NOINIT, pointlimit_cons_t, PointLimit_OnChange); static CV_PossibleValue_t timelimit_cons_t[] = {{1, "MIN"}, {30, "MAX"}, {0, "None"}, {0, NULL}}; -consvar_t cv_timelimit = CVAR_INIT ("timelimit", "None", CV_NETVAR|CV_CALL|CV_NOINIT, timelimit_cons_t, TimeLimit_OnChange); +consvar_t cv_timelimit = CVAR_INIT ("timelimit", "None", CV_SAVE|CV_NETVAR|CV_CALL|CV_NOINIT, timelimit_cons_t, TimeLimit_OnChange); static CV_PossibleValue_t numlaps_cons_t[] = {{1, "MIN"}, {50, "MAX"}, {0, NULL}}; consvar_t cv_numlaps = CVAR_INIT ("numlaps", "4", CV_NETVAR|CV_CALL|CV_NOINIT, numlaps_cons_t, NumLaps_OnChange); static CV_PossibleValue_t basenumlaps_cons_t[] = {{1, "MIN"}, {50, "MAX"}, {0, "Map default"}, {0, NULL}}; -consvar_t cv_basenumlaps = CVAR_INIT ("basenumlaps", "Map default", CV_NETVAR|CV_CALL|CV_CHEAT, basenumlaps_cons_t, BaseNumLaps_OnChange); +consvar_t cv_basenumlaps = CVAR_INIT ("basenumlaps", "Map default", CV_SAVE|CV_NETVAR|CV_CALL|CV_CHEAT, basenumlaps_cons_t, BaseNumLaps_OnChange); // Point and time limits for every gametype INT32 pointlimits[NUMGAMETYPES]; @@ -328,7 +328,7 @@ consvar_t cv_hazardlog = CVAR_INIT ("hazardlog", "Yes", 0, CV_YesNo, NULL); consvar_t cv_forceskin = CVAR_INIT ("forceskin", "None", CV_NETVAR|CV_CALL|CV_CHEAT, NULL, ForceSkin_OnChange); consvar_t cv_downloading = CVAR_INIT ("downloading", "On", 0, CV_OnOff, NULL); -consvar_t cv_allowexitlevel = CVAR_INIT ("allowexitlevel", "No", CV_NETVAR, CV_YesNo, NULL); +consvar_t cv_allowexitlevel = CVAR_INIT ("allowexitlevel", "No", CV_SAVE|CV_NETVAR, CV_YesNo, NULL); consvar_t cv_killingdead = CVAR_INIT ("killingdead", "Off", CV_NETVAR, CV_OnOff, NULL); @@ -348,25 +348,25 @@ consvar_t cv_showping = CVAR_INIT ("showping", "Warning", CV_SAVE, showping_cons // Intermission time Tails 04-19-2002 static CV_PossibleValue_t inttime_cons_t[] = {{0, "MIN"}, {3600, "MAX"}, {0, NULL}}; -consvar_t cv_inttime = CVAR_INIT ("inttime", "10", CV_NETVAR, inttime_cons_t, NULL); +consvar_t cv_inttime = CVAR_INIT ("inttime", "10", CV_SAVE|CV_NETVAR, inttime_cons_t, NULL); static CV_PossibleValue_t coopstarposts_cons_t[] = {{0, "Per-player"}, {1, "Shared"}, {2, "Teamwork"}, {0, NULL}}; -consvar_t cv_coopstarposts = CVAR_INIT ("coopstarposts", "Per-player", CV_NETVAR|CV_CALL, coopstarposts_cons_t, CoopStarposts_OnChange); +consvar_t cv_coopstarposts = CVAR_INIT ("coopstarposts", "Per-player", CV_SAVE|CV_NETVAR|CV_CALL, coopstarposts_cons_t, CoopStarposts_OnChange); static CV_PossibleValue_t cooplives_cons_t[] = {{0, "Infinite"}, {1, "Per-player"}, {2, "Avoid Game Over"}, {3, "Single pool"}, {0, NULL}}; -consvar_t cv_cooplives = CVAR_INIT ("cooplives", "Avoid Game Over", CV_NETVAR|CV_CALL|CV_CHEAT, cooplives_cons_t, CoopLives_OnChange); +consvar_t cv_cooplives = CVAR_INIT ("cooplives", "Avoid Game Over", CV_SAVE|CV_NETVAR|CV_CALL|CV_CHEAT, cooplives_cons_t, CoopLives_OnChange); static CV_PossibleValue_t advancemap_cons_t[] = {{0, "Off"}, {1, "Next"}, {2, "Random"}, {0, NULL}}; -consvar_t cv_advancemap = CVAR_INIT ("advancemap", "Next", CV_NETVAR, advancemap_cons_t, NULL); +consvar_t cv_advancemap = CVAR_INIT ("advancemap", "Next", CV_SAVE|CV_NETVAR, advancemap_cons_t, NULL); static CV_PossibleValue_t playersforexit_cons_t[] = {{0, "One"}, {1, "1/4"}, {2, "Half"}, {3, "3/4"}, {4, "All"}, {0, NULL}}; -consvar_t cv_playersforexit = CVAR_INIT ("playersforexit", "All", CV_NETVAR, playersforexit_cons_t, NULL); +consvar_t cv_playersforexit = CVAR_INIT ("playersforexit", "All", CV_SAVE|CV_NETVAR, playersforexit_cons_t, NULL); -consvar_t cv_exitmove = CVAR_INIT ("exitmove", "On", CV_NETVAR|CV_CALL, CV_OnOff, ExitMove_OnChange); +consvar_t cv_exitmove = CVAR_INIT ("exitmove", "On", CV_SAVE|CV_NETVAR|CV_CALL, CV_OnOff, ExitMove_OnChange); consvar_t cv_runscripts = CVAR_INIT ("runscripts", "Yes", 0, CV_YesNo, NULL); -consvar_t cv_pause = CVAR_INIT ("pausepermission", "Server", CV_NETVAR, pause_cons_t, NULL); +consvar_t cv_pause = CVAR_INIT ("pausepermission", "Server", CV_SAVE|CV_NETVAR, pause_cons_t, NULL); consvar_t cv_mute = CVAR_INIT ("mute", "Off", CV_NETVAR|CV_CALL, CV_OnOff, Mute_OnChange); consvar_t cv_sleep = CVAR_INIT ("cpusleep", "1", CV_SAVE, sleeping_cons_t, NULL); diff --git a/src/p_mobj.c b/src/p_mobj.c index de4385fa7..8d3566167 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -11047,10 +11047,10 @@ void P_RemoveSavegameMobj(mobj_t *mobj) } static CV_PossibleValue_t respawnitemtime_cons_t[] = {{1, "MIN"}, {300, "MAX"}, {0, NULL}}; -consvar_t cv_itemrespawntime = CVAR_INIT ("respawnitemtime", "30", CV_NETVAR|CV_CHEAT, respawnitemtime_cons_t, NULL); -consvar_t cv_itemrespawn = CVAR_INIT ("respawnitem", "On", CV_NETVAR, CV_OnOff, NULL); +consvar_t cv_itemrespawntime = CVAR_INIT ("respawnitemtime", "30", CV_SAVE|CV_NETVAR|CV_CHEAT, respawnitemtime_cons_t, NULL); +consvar_t cv_itemrespawn = CVAR_INIT ("respawnitem", "On", CV_SAVE|CV_NETVAR, CV_OnOff, NULL); static CV_PossibleValue_t flagtime_cons_t[] = {{0, "MIN"}, {300, "MAX"}, {0, NULL}}; -consvar_t cv_flagtime = CVAR_INIT ("flagtime", "30", CV_NETVAR|CV_CHEAT, flagtime_cons_t, NULL); +consvar_t cv_flagtime = CVAR_INIT ("flagtime", "30", CV_SAVE|CV_NETVAR|CV_CHEAT, flagtime_cons_t, NULL); void P_SpawnPrecipitation(void) { From f5e4d076b9a7a99238b392752fdf86e11c0be0b3 Mon Sep 17 00:00:00 2001 From: James R Date: Fri, 9 Oct 2020 15:23:16 -0700 Subject: [PATCH 0142/1080] Add CV_NETVAR to server affecting cvars showjoinaddress maxplayers joindelay rejointimeout resynchattempts blamecfail maxsend noticedownload downloadspeed jointimeout maxping pingtimeout servername --- src/d_clisrv.c | 18 +++++++++--------- src/d_netcmd.c | 6 +++--- src/mserv.c | 2 +- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 3c813eee4..b6974b6cd 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -157,7 +157,7 @@ ticcmd_t netcmds[BACKUPTICS][MAXPLAYERS]; static textcmdtic_t *textcmds[TEXTCMD_HASH_SIZE] = {NULL}; -consvar_t cv_showjoinaddress = CVAR_INIT ("showjoinaddress", "Off", CV_SAVE, CV_OnOff, NULL); +consvar_t cv_showjoinaddress = CVAR_INIT ("showjoinaddress", "Off", CV_SAVE|CV_NETVAR, CV_OnOff, NULL); static CV_PossibleValue_t playbackspeed_cons_t[] = {{1, "MIN"}, {10, "MAX"}, {0, NULL}}; consvar_t cv_playbackspeed = CVAR_INIT ("playbackspeed", "1", 0, playbackspeed_cons_t, NULL); @@ -3681,24 +3681,24 @@ consvar_t cv_netticbuffer = CVAR_INIT ("netticbuffer", "1", CV_SAVE, netticbuffe consvar_t cv_allownewplayer = CVAR_INIT ("allowjoin", "On", CV_SAVE|CV_NETVAR, CV_OnOff, NULL); consvar_t cv_joinnextround = CVAR_INIT ("joinnextround", "Off", CV_SAVE|CV_NETVAR, CV_OnOff, NULL); /// \todo not done static CV_PossibleValue_t maxplayers_cons_t[] = {{2, "MIN"}, {32, "MAX"}, {0, NULL}}; -consvar_t cv_maxplayers = CVAR_INIT ("maxplayers", "8", CV_SAVE, maxplayers_cons_t, NULL); +consvar_t cv_maxplayers = CVAR_INIT ("maxplayers", "8", CV_SAVE|CV_NETVAR, maxplayers_cons_t, NULL); static CV_PossibleValue_t joindelay_cons_t[] = {{1, "MIN"}, {3600, "MAX"}, {0, "Off"}, {0, NULL}}; -consvar_t cv_joindelay = CVAR_INIT ("joindelay", "10", CV_SAVE, joindelay_cons_t, NULL); +consvar_t cv_joindelay = CVAR_INIT ("joindelay", "10", CV_SAVE|CV_NETVAR, joindelay_cons_t, NULL); static CV_PossibleValue_t rejointimeout_cons_t[] = {{1, "MIN"}, {60 * FRACUNIT, "MAX"}, {0, "Off"}, {0, NULL}}; -consvar_t cv_rejointimeout = CVAR_INIT ("rejointimeout", "Off", CV_SAVE|CV_FLOAT, rejointimeout_cons_t, NULL); +consvar_t cv_rejointimeout = CVAR_INIT ("rejointimeout", "Off", CV_SAVE|CV_NETVAR|CV_FLOAT, rejointimeout_cons_t, NULL); static CV_PossibleValue_t resynchattempts_cons_t[] = {{1, "MIN"}, {20, "MAX"}, {0, "No"}, {0, NULL}}; -consvar_t cv_resynchattempts = CVAR_INIT ("resynchattempts", "10", CV_SAVE, resynchattempts_cons_t, NULL); -consvar_t cv_blamecfail = CVAR_INIT ("blamecfail", "Off", CV_SAVE, CV_OnOff, NULL); +consvar_t cv_resynchattempts = CVAR_INIT ("resynchattempts", "10", CV_SAVE|CV_NETVAR, resynchattempts_cons_t, NULL); +consvar_t cv_blamecfail = CVAR_INIT ("blamecfail", "Off", CV_SAVE|CV_NETVAR, CV_OnOff, NULL); // max file size to send to a player (in kilobytes) static CV_PossibleValue_t maxsend_cons_t[] = {{0, "MIN"}, {51200, "MAX"}, {0, NULL}}; -consvar_t cv_maxsend = CVAR_INIT ("maxsend", "4096", CV_SAVE, maxsend_cons_t, NULL); -consvar_t cv_noticedownload = CVAR_INIT ("noticedownload", "Off", CV_SAVE, CV_OnOff, NULL); +consvar_t cv_maxsend = CVAR_INIT ("maxsend", "4096", CV_SAVE|CV_NETVAR, maxsend_cons_t, NULL); +consvar_t cv_noticedownload = CVAR_INIT ("noticedownload", "Off", CV_SAVE|CV_NETVAR, CV_OnOff, NULL); // Speed of file downloading (in packets per tic) static CV_PossibleValue_t downloadspeed_cons_t[] = {{0, "MIN"}, {32, "MAX"}, {0, NULL}}; -consvar_t cv_downloadspeed = CVAR_INIT ("downloadspeed", "16", CV_SAVE, downloadspeed_cons_t, NULL); +consvar_t cv_downloadspeed = CVAR_INIT ("downloadspeed", "16", CV_SAVE|CV_NETVAR, downloadspeed_cons_t, NULL); static void Got_AddPlayer(UINT8 **p, INT32 playernum); diff --git a/src/d_netcmd.c b/src/d_netcmd.c index c2579b4ab..f3c3f54dc 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -336,11 +336,11 @@ consvar_t cv_netstat = CVAR_INIT ("netstat", "Off", 0, CV_OnOff, NULL); // show static CV_PossibleValue_t nettimeout_cons_t[] = {{TICRATE/7, "MIN"}, {60*TICRATE, "MAX"}, {0, NULL}}; consvar_t cv_nettimeout = CVAR_INIT ("nettimeout", "350", CV_CALL|CV_SAVE, nettimeout_cons_t, NetTimeout_OnChange); static CV_PossibleValue_t jointimeout_cons_t[] = {{5*TICRATE, "MIN"}, {60*TICRATE, "MAX"}, {0, NULL}}; -consvar_t cv_jointimeout = CVAR_INIT ("jointimeout", "350", CV_CALL|CV_SAVE, jointimeout_cons_t, JoinTimeout_OnChange); -consvar_t cv_maxping = CVAR_INIT ("maxping", "0", CV_SAVE, CV_Unsigned, NULL); +consvar_t cv_jointimeout = CVAR_INIT ("jointimeout", "350", CV_CALL|CV_SAVE|CV_NETVAR, jointimeout_cons_t, JoinTimeout_OnChange); +consvar_t cv_maxping = CVAR_INIT ("maxping", "0", CV_SAVE|CV_NETVAR, CV_Unsigned, NULL); static CV_PossibleValue_t pingtimeout_cons_t[] = {{8, "MIN"}, {120, "MAX"}, {0, NULL}}; -consvar_t cv_pingtimeout = CVAR_INIT ("pingtimeout", "10", CV_SAVE, pingtimeout_cons_t, NULL); +consvar_t cv_pingtimeout = CVAR_INIT ("pingtimeout", "10", CV_SAVE|CV_NETVAR, pingtimeout_cons_t, NULL); // show your ping on the HUD next to framerate. Defaults to warning only (shows up if your ping is > maxping) static CV_PossibleValue_t showping_cons_t[] = {{0, "Off"}, {1, "Always"}, {2, "Warning"}, {0, NULL}}; diff --git a/src/mserv.c b/src/mserv.c index fa646b899..dfb417415 100644 --- a/src/mserv.c +++ b/src/mserv.c @@ -62,7 +62,7 @@ static CV_PossibleValue_t masterserver_update_rate_cons_t[] = { }; consvar_t cv_masterserver = CVAR_INIT ("masterserver", "https://mb.srb2.org/MS/0", CV_SAVE|CV_CALL, NULL, MasterServer_OnChange); -consvar_t cv_servername = CVAR_INIT ("servername", "SRB2 server", CV_SAVE|CV_CALL|CV_NOINIT, NULL, Update_parameters); +consvar_t cv_servername = CVAR_INIT ("servername", "SRB2 server", CV_SAVE|CV_NETVAR|CV_CALL|CV_NOINIT, NULL, Update_parameters); consvar_t cv_masterserver_update_rate = CVAR_INIT ("masterserver_update_rate", "15", CV_SAVE|CV_CALL|CV_NOINIT, masterserver_update_rate_cons_t, Update_parameters); From b67807dd048e6053df523a91ffb7261ff97da8de Mon Sep 17 00:00:00 2001 From: James R Date: Fri, 9 Oct 2020 16:22:17 -0700 Subject: [PATCH 0143/1080] When save/loading config use revert value for netvars if you are not the server --- src/command.c | 85 ++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 77 insertions(+), 8 deletions(-) diff --git a/src/command.c b/src/command.c index c8f1aeccc..74c4789d1 100644 --- a/src/command.c +++ b/src/command.c @@ -1393,6 +1393,18 @@ static void Setvalue(consvar_t *var, const char *valstr, boolean stealth) for (i = MAXVAL+1; var->PossibleValue[i].strvalue; i++) if (v == var->PossibleValue[i].value || !stricmp(var->PossibleValue[i].strvalue, valstr)) { + if (client && execversion_enabled) + { + if (var->revert.allocated) + { + Z_Free(var->revert.v.string); + } + + var->revert.v.const_munge = var->PossibleValue[i].strvalue; + + return; + } + var->value = var->PossibleValue[i].value; var->string = var->PossibleValue[i].strvalue; goto finish; @@ -1453,12 +1465,36 @@ static void Setvalue(consvar_t *var, const char *valstr, boolean stealth) // ...or not. goto badinput; found: + if (client && execversion_enabled) + { + if (var->revert.allocated) + { + Z_Free(var->revert.v.string); + } + + var->revert.v.const_munge = var->PossibleValue[i].strvalue; + + return; + } + var->value = var->PossibleValue[i].value; var->string = var->PossibleValue[i].strvalue; goto finish; } } + if (client && execversion_enabled) + { + if (var->revert.allocated) + { + Z_Free(var->revert.v.string); + } + + var->revert.v.string = Z_StrDup(valstr); + + return; + } + // free the old value string Z_Free(var->zstring); @@ -1796,6 +1832,14 @@ static void CV_SetCVar(consvar_t *var, const char *value, boolean stealth) // send the value of the variable UINT8 buf[128]; UINT8 *p = buf; + + // Loading from a config in a netgame? Set revert value. + if (client && execversion_enabled) + { + Setvalue(var, value, true); + return; + } + if (!(server || (addedtogame && IsPlayerAdmin(consoleplayer)))) { CONS_Printf(M_GetText("Only the server or admin can change: %s %s\n"), var->name, var->string); @@ -2329,18 +2373,43 @@ void CV_SaveVariables(FILE *f) { char stringtowrite[MAXTEXTCMD+1]; - // Silly hack for Min/Max vars - if (!strcmp(cvar->string, "MAX") || !strcmp(cvar->string, "MIN")) + const char * string; + + if (cvar->revert.v.string != NULL) { - if (cvar->flags & CV_FLOAT) - sprintf(stringtowrite, "%f", FIXED_TO_FLOAT(cvar->value)); - else - sprintf(stringtowrite, "%d", cvar->value); + string = cvar->revert.v.string; } else - strcpy(stringtowrite, cvar->string); + { + string = cvar->string; + } - fprintf(f, "%s \"%s\"\n", cvar->name, stringtowrite); + // Silly hack for Min/Max vars +#define MINVAL 0 +#define MAXVAL 1 + if ( + cvar->PossibleValue != NULL && + cvar->PossibleValue[0].strvalue && + stricmp(cvar->PossibleValue[0].strvalue, "MIN") == 0 + ){ // bounded cvar + int which = stricmp(string, "MAX") == 0; + + if (which || stricmp(string, "MIN") == 0) + { + INT32 value = cvar->PossibleValue[which].value; + + if (cvar->flags & CV_FLOAT) + sprintf(stringtowrite, "%f", FIXED_TO_FLOAT(value)); + else + sprintf(stringtowrite, "%d", value); + + string = stringtowrite; + } + } +#undef MINVAL +#undef MAXVAL + + fprintf(f, "%s \"%s\"\n", cvar->name, string); } } From 4b5cb8025b4a65669d70b70158acfa3d4bf186fd Mon Sep 17 00:00:00 2001 From: James R Date: Fri, 9 Oct 2020 16:28:03 -0700 Subject: [PATCH 0144/1080] Show revert value of cvar with help command --- src/command.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/command.c b/src/command.c index 74c4789d1..7bf6b3152 100644 --- a/src/command.c +++ b/src/command.c @@ -875,6 +875,9 @@ static void COM_Help_f(void) CONS_Printf(" Current value: %s\n", cvar->string); else CONS_Printf(" Current value: %d\n", cvar->value); + + if (cvar->revert.v.string != NULL && strcmp(cvar->revert.v.string, cvar->string) != 0) + CONS_Printf(" Value before netgame: %s\n", cvar->revert.v.string); } else { From c5a3a61b28b5ed61293e05f84310108ecf49d6f1 Mon Sep 17 00:00:00 2001 From: Jaime Passos Date: Sat, 10 Oct 2020 01:00:39 -0300 Subject: [PATCH 0145/1080] Make 3D floors cull areas below or above them to reduce overdraw (2) --- src/r_main.c | 2 + src/r_main.h | 1 + src/r_segs.c | 136 +++++++++++++++++++++++++++++++++++++++++++-------- 3 files changed, 118 insertions(+), 21 deletions(-) diff --git a/src/r_main.c b/src/r_main.c index 9613e2ac1..0c13e3423 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -151,6 +151,7 @@ consvar_t cv_flipcam2 = CVAR_INIT ("flipcam2", "No", CV_SAVE|CV_CALL|CV_NOINIT, consvar_t cv_shadow = CVAR_INIT ("shadow", "On", CV_SAVE, CV_OnOff, NULL); consvar_t cv_skybox = CVAR_INIT ("skybox", "On", CV_SAVE, CV_OnOff, NULL); +consvar_t cv_ffloorclip = CVAR_INIT ("ffloorclip", "On", CV_SAVE, CV_OnOff, NULL); consvar_t cv_allowmlook = CVAR_INIT ("allowmlook", "Yes", CV_NETVAR, CV_YesNo, NULL); consvar_t cv_showhud = CVAR_INIT ("showhud", "Yes", CV_CALL, CV_YesNo, R_SetViewSize); consvar_t cv_translucenthud = CVAR_INIT ("translucenthud", "10", CV_SAVE, translucenthud_cons_t, NULL); @@ -1615,6 +1616,7 @@ void R_RegisterEngineStuff(void) CV_RegisterVar(&cv_shadow); CV_RegisterVar(&cv_skybox); + CV_RegisterVar(&cv_ffloorclip); CV_RegisterVar(&cv_cam_dist); CV_RegisterVar(&cv_cam_still); diff --git a/src/r_main.h b/src/r_main.h index 89b359c55..5466d2a25 100644 --- a/src/r_main.h +++ b/src/r_main.h @@ -107,6 +107,7 @@ extern consvar_t cv_chasecam, cv_chasecam2; extern consvar_t cv_flipcam, cv_flipcam2; extern consvar_t cv_shadow; +extern consvar_t cv_ffloorclip; extern consvar_t cv_translucency; extern consvar_t cv_drawdist, cv_drawdist_nights, cv_drawdist_precip; extern consvar_t cv_fov; diff --git a/src/r_segs.c b/src/r_segs.c index d9fc75838..8f6acef45 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -55,6 +55,15 @@ static INT32 worldtop, worldbottom, worldhigh, worldlow; static INT32 worldtopslope, worldbottomslope, worldhighslope, worldlowslope; // worldtop/bottom at end of slope static fixed_t rw_toptextureslide, rw_midtextureslide, rw_bottomtextureslide; // Defines how to adjust Y offsets along the wall for slopes static fixed_t rw_midtextureback, rw_midtexturebackslide; // Values for masked midtexture height calculation + +// Lactozilla: 3D floor clipping +static boolean rw_floormarked = false; +static boolean rw_ceilingmarked = false; + +static INT32 *rw_silhouette = NULL; +static fixed_t *rw_tsilheight = NULL; +static fixed_t *rw_bsilheight = NULL; + static fixed_t pixhigh, pixlow, pixhighstep, pixlowstep; static fixed_t topfrac, topstep; static fixed_t bottomfrac, bottomstep; @@ -686,6 +695,19 @@ static void R_DrawRepeatFlippedMaskedColumn(column_t *col) } while (sprtopscreen < sprbotscreen); } +// Returns true if a fake floor is translucent. +static boolean R_IsFFloorTranslucent(visffloor_t *pfloor) +{ + if (pfloor->polyobj) + return (pfloor->polyobj->translucency > 0); + + // Polyobjects have no ffloors, and they're handled in the conditional above. + if (pfloor->ffloor != NULL) + return (pfloor->ffloor->flags & FF_TRANSLUCENT); + + return false; +} + // // R_RenderThickSideRange // Renders all the thick sides in the given range. @@ -1188,7 +1210,7 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) // R_ExpandPlaneY // -// A simple function to modify a vsplane's top and bottom for a particular column +// A simple function to modify a visplane's top and bottom for a particular column // Sort of like R_ExpandPlane in r_plane.c, except this is vertical expansion static inline void R_ExpandPlaneY(visplane_t *pl, INT32 x, INT16 top, INT16 bottom) { @@ -1198,6 +1220,14 @@ static inline void R_ExpandPlaneY(visplane_t *pl, INT32 x, INT16 top, INT16 bott if (pl->bottom[x] < bottom) pl->bottom[x] = bottom; } +// R_FFloorCanClip +// +// Returns true if a fake floor can clip a column away. +static boolean R_FFloorCanClip(visffloor_t *pfloor) +{ + return (cv_ffloorclip.value && !R_IsFFloorTranslucent(pfloor) && !pfloor->polyobj); +} + // // R_RenderSegLoop // Draws zero, one, or two textures (and possibly a masked @@ -1281,6 +1311,11 @@ static void R_RenderSegLoop (void) if (numffloors) { + INT16 fftop, ffbottom; + + rw_floormarked = false; + rw_ceilingmarked = false; + firstseg->frontscale[rw_x] = frontscale[rw_x]; top = ceilingclip[rw_x]+1; // PRBoom bottom = floorclip[rw_x]-1; // PRBoom @@ -1311,8 +1346,30 @@ static void R_RenderSegLoop (void) { if (top_w <= bottom_w) { - ffloor[i].plane->top[rw_x] = (INT16)top_w; - ffloor[i].plane->bottom[rw_x] = (INT16)bottom_w; + fftop = (INT16)top_w; + ffbottom = (INT16)bottom_w; + + ffloor[i].plane->top[rw_x] = fftop; + ffloor[i].plane->bottom[rw_x] = ffbottom; + + // Lactozilla: Cull part of the column by the 3D floor if it can't be seen + // "bottom" is the top pixel of the floor column + if (ffbottom >= bottom-1 && R_FFloorCanClip(&ffloor[i])) + { + rw_floormarked = true; + floorclip[rw_x] = fftop; + if (yh > fftop) + yh = fftop; + + if (markfloor && floorplane) + floorplane->top[rw_x] = bottom; + + if (rw_silhouette) + { + (*rw_silhouette) |= SIL_BOTTOM; + (*rw_bsilheight) = INT32_MAX; + } + } } } } @@ -1337,8 +1394,30 @@ static void R_RenderSegLoop (void) { if (top_w <= bottom_w) { - ffloor[i].plane->top[rw_x] = (INT16)top_w; - ffloor[i].plane->bottom[rw_x] = (INT16)bottom_w; + fftop = (INT16)top_w; + ffbottom = (INT16)bottom_w; + + ffloor[i].plane->top[rw_x] = fftop; + ffloor[i].plane->bottom[rw_x] = ffbottom; + + // Lactozilla: Cull part of the column by the 3D floor if it can't be seen + // "top" is the height of the ceiling column + if (fftop <= top+1 && R_FFloorCanClip(&ffloor[i])) + { + rw_ceilingmarked = true; + ceilingclip[rw_x] = ffbottom; + if (yl < ffbottom) + yl = ffbottom; + + if (markceiling && ceilingplane) + ceilingplane->bottom[rw_x] = top; + + if (rw_silhouette) + { + (*rw_silhouette) |= SIL_TOP; + (*rw_tsilheight) = INT32_MIN; + } + } } } } @@ -1444,20 +1523,25 @@ static void R_RenderSegLoop (void) // dont draw anything more for this column, since // a midtexture blocks the view - ceilingclip[rw_x] = (INT16)viewheight; - floorclip[rw_x] = -1; + if (!rw_ceilingmarked) + ceilingclip[rw_x] = (INT16)viewheight; + if (!rw_floormarked) + floorclip[rw_x] = -1; } else { // note: don't use min/max macros, since casting from INT32 to INT16 is involved here - if (markceiling) + if (markceiling && (!rw_ceilingmarked)) ceilingclip[rw_x] = (yl >= 0) ? ((yl > viewheight) ? (INT16)viewheight : (INT16)((INT16)yl - 1)) : -1; - if (markfloor) + if (markfloor && (!rw_floormarked)) floorclip[rw_x] = (yh < viewheight) ? ((yh < -1) ? -1 : (INT16)((INT16)yh + 1)) : (INT16)viewheight; } } else { + INT16 topclip = (yl >= 0) ? ((yl > viewheight) ? (INT16)viewheight : (INT16)((INT16)yl - 1)) : -1; + INT16 bottomclip = (yh < viewheight) ? ((yh < -1) ? -1 : (INT16)((INT16)yh + 1)) : (INT16)viewheight; + // two sided line if (toptexture) { @@ -1471,7 +1555,10 @@ static void R_RenderSegLoop (void) if (mid >= yl) // back ceiling lower than front ceiling ? { if (yl >= viewheight) // entirely off bottom of screen - ceilingclip[rw_x] = (INT16)viewheight; + { + if (!rw_ceilingmarked) + ceilingclip[rw_x] = (INT16)viewheight; + } else if (mid >= 0) // safe to draw top texture { dc_yl = yl; @@ -1482,14 +1569,14 @@ static void R_RenderSegLoop (void) colfunc(); ceilingclip[rw_x] = (INT16)mid; } - else // entirely off top of screen + else if (!rw_ceilingmarked) // entirely off top of screen ceilingclip[rw_x] = -1; } - else - ceilingclip[rw_x] = (yl >= 0) ? ((yl > viewheight) ? (INT16)viewheight : (INT16)((INT16)yl - 1)) : -1; + else if (!rw_ceilingmarked) + ceilingclip[rw_x] = topclip; } - else if (markceiling) // no top wall - ceilingclip[rw_x] = (yl >= 0) ? ((yl > viewheight) ? (INT16)viewheight : (INT16)((INT16)yl - 1)) : -1; + else if (markceiling && (!rw_ceilingmarked)) // no top wall + ceilingclip[rw_x] = topclip; if (bottomtexture) { @@ -1504,7 +1591,10 @@ static void R_RenderSegLoop (void) if (mid <= yh) // back floor higher than front floor ? { if (yh < 0) // entirely off top of screen - floorclip[rw_x] = -1; + { + if (!rw_floormarked) + floorclip[rw_x] = -1; + } else if (mid < viewheight) // safe to draw bottom texture { dc_yl = mid; @@ -1516,14 +1606,14 @@ static void R_RenderSegLoop (void) colfunc(); floorclip[rw_x] = (INT16)mid; } - else // entirely off bottom of screen + else if (!rw_floormarked) // entirely off bottom of screen floorclip[rw_x] = (INT16)viewheight; } - else - floorclip[rw_x] = (yh < viewheight) ? ((yh < -1) ? -1 : (INT16)((INT16)yh + 1)) : (INT16)viewheight; + else if (!rw_floormarked) + floorclip[rw_x] = bottomclip; } - else if (markfloor) // no bottom wall - floorclip[rw_x] = (yh < viewheight) ? ((yh < -1) ? -1 : (INT16)((INT16)yh + 1)) : (INT16)viewheight; + else if (markfloor && (!rw_floormarked)) // no bottom wall + floorclip[rw_x] = bottomclip; } if (maskedtexture || numthicksides) @@ -2786,6 +2876,10 @@ void R_StoreWallRange(INT32 start, INT32 stop) } } + rw_silhouette = &(ds_p->silhouette); + rw_tsilheight = &(ds_p->tsilheight); + rw_bsilheight = &(ds_p->bsilheight); + #ifdef WALLSPLATS if (linedef->splats && cv_splats.value) { From 0021a9aeaf4bbd406a2650eb87fafe8dd42cf5c0 Mon Sep 17 00:00:00 2001 From: Jaime Passos Date: Sat, 10 Oct 2020 13:37:23 -0300 Subject: [PATCH 0146/1080] Fix bug --- src/r_segs.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/r_segs.c b/src/r_segs.c index 8f6acef45..2cd7ebab2 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -1309,13 +1309,13 @@ static void R_RenderSegLoop (void) R_ExpandPlaneY(floorplane, rw_x, top, bottom); } + rw_floormarked = false; + rw_ceilingmarked = false; + if (numffloors) { INT16 fftop, ffbottom; - rw_floormarked = false; - rw_ceilingmarked = false; - firstseg->frontscale[rw_x] = frontscale[rw_x]; top = ceilingclip[rw_x]+1; // PRBoom bottom = floorclip[rw_x]-1; // PRBoom From 4d847f42235e06098cc80e40085ec47af75a21b0 Mon Sep 17 00:00:00 2001 From: Jaime Passos Date: Sat, 10 Oct 2020 14:09:59 -0300 Subject: [PATCH 0147/1080] Compare the PNG's palette with the game's palette instead of assuming they are the same --- src/r_picformats.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/r_picformats.c b/src/r_picformats.c index 95fe23aeb..feec2abf4 100644 --- a/src/r_picformats.c +++ b/src/r_picformats.c @@ -887,8 +887,24 @@ static png_bytep *PNG_Read( // matches the color count of SRB2's palette: 256 colors. if (png_get_PLTE(png_ptr, png_info_ptr, &palette, &palette_size)) { - if (palette_size == 256) + if (palette_size == 256 && pMasterPalette) + { + png_colorp pal = palette; + INT32 i; + usepal = true; + + for (i = 0; i < 256; i++) + { + UINT32 rgb = R_PutRgbaRGBA(pal->red, pal->green, pal->blue, 0xFF); + if (rgb != pMasterPalette[i].rgba) + { + usepal = false; + break; + } + pal++; + } + } } // If any of the tRNS colors have an alpha lower than 0xFF, and that From 06c0932ab4d3f1984d25ef3de886ec9ad94e2897 Mon Sep 17 00:00:00 2001 From: Jaime Passos Date: Sat, 10 Oct 2020 14:12:22 -0300 Subject: [PATCH 0148/1080] Only check the tRNS (trans) chunk if the image is still palettized --- src/r_picformats.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/src/r_picformats.c b/src/r_picformats.c index feec2abf4..8d7cf37f2 100644 --- a/src/r_picformats.c +++ b/src/r_picformats.c @@ -909,20 +909,23 @@ static png_bytep *PNG_Read( // If any of the tRNS colors have an alpha lower than 0xFF, and that // color is present on the image, the palette flag is disabled. - png_get_tRNS(png_ptr, png_info_ptr, &trans, &trans_num, &trans_values); - - if (trans && trans_num == 256) + if (usepal) { - int i; - for (i = 0; i < trans_num; i++) + png_get_tRNS(png_ptr, png_info_ptr, &trans, &trans_num, &trans_values); + + if (trans && trans_num == 256) { - // libpng will transform this image into RGB even if - // the transparent index does not exist in the image, - // and there is no way around that. - if (trans[i] < 0xFF) + INT32 i; + for (i = 0; i < trans_num; i++) { - usepal = false; - break; + // libpng will transform this image into RGB even if + // the transparent index does not exist in the image, + // and there is no way around that. + if (trans[i] < 0xFF) + { + usepal = false; + break; + } } } } From 4f20a2016594dc739ab74ba5f6346e2f61e4c766 Mon Sep 17 00:00:00 2001 From: Hannu Hanhi Date: Sat, 10 Oct 2020 21:08:24 +0300 Subject: [PATCH 0149/1080] Performance stats --- src/CMakeLists.txt | 2 + src/Makefile | 1 + src/d_clisrv.c | 5 +- src/d_main.c | 95 +---- src/d_netcmd.c | 6 + src/d_netcmd.h | 2 + src/hardware/hw_batching.c | 28 +- src/hardware/hw_main.c | 68 ++-- src/hardware/hw_main.h | 27 +- src/lua_hooklib.c | 42 +++ src/m_perfstats.c | 541 +++++++++++++++++++++++++++ src/m_perfstats.h | 42 +++ src/p_map.c | 4 + src/p_tick.c | 13 + src/r_bsp.c | 4 +- src/r_main.c | 48 +-- src/r_main.h | 28 +- src/r_things.c | 2 +- src/sdl/Srb2SDL-vc10.vcxproj | 2 + src/sdl/Srb2SDL-vc10.vcxproj.filters | 6 + 20 files changed, 778 insertions(+), 188 deletions(-) create mode 100644 src/m_perfstats.c create mode 100644 src/m_perfstats.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 962f8f87a..48c2b4eaa 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -32,6 +32,7 @@ set(SRB2_CORE_SOURCES m_fixed.c m_menu.c m_misc.c + m_perfstats.c m_queue.c m_random.c md5.c @@ -97,6 +98,7 @@ set(SRB2_CORE_HEADERS m_fixed.h m_menu.h m_misc.h + m_perfstats.h m_queue.h m_random.h m_swap.h diff --git a/src/Makefile b/src/Makefile index ee0d50625..e365dcc95 100644 --- a/src/Makefile +++ b/src/Makefile @@ -486,6 +486,7 @@ OBJS:=$(i_main_o) \ $(OBJDIR)/m_fixed.o \ $(OBJDIR)/m_menu.o \ $(OBJDIR)/m_misc.o \ + $(OBJDIR)/m_perfstats.o \ $(OBJDIR)/m_random.o \ $(OBJDIR)/m_queue.o \ $(OBJDIR)/info.o \ diff --git a/src/d_clisrv.c b/src/d_clisrv.c index c9490410b..a6f7cc1c8 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -44,6 +44,7 @@ #include "lua_script.h" #include "lua_hook.h" #include "md5.h" +#include "m_perfstats.h" #ifndef NONET // cl loading screen @@ -5443,14 +5444,14 @@ void TryRunTics(tic_t realtics) { DEBFILE(va("============ Running tic %d (local %d)\n", gametic, localgametic)); - rs_tictime = I_GetTimeMicros(); + ps_tictime = I_GetTimeMicros(); G_Ticker((gametic % NEWTICRATERATIO) == 0); ExtraDataTicker(); gametic++; consistancy[gametic%BACKUPTICS] = Consistancy(); - rs_tictime = I_GetTimeMicros() - rs_tictime; + ps_tictime = I_GetTimeMicros() - ps_tictime; // Leave a certain amount of tics present in the net buffer as long as we've ran at least one tic this frame. if (client && gamestate == GS_LEVEL && leveltime > 3 && neededtic <= gametic + cv_netticbuffer.value) diff --git a/src/d_main.c b/src/d_main.c index d1a414018..41eb59ca7 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -67,6 +67,7 @@ #include "keys.h" #include "filesrch.h" // refreshdirmenu, mainwadstally #include "g_input.h" // tutorial mode control scheming +#include "m_perfstats.h" #ifdef CMAKECONFIG #include "config.h" @@ -435,7 +436,7 @@ static void D_Display(void) if (!automapactive && !dedicated && cv_renderview.value) { - rs_rendercalltime = I_GetTimeMicros(); + ps_rendercalltime = I_GetTimeMicros(); if (players[displayplayer].mo || players[displayplayer].playerstate == PST_DEAD) { topleft = screens[0] + viewwindowy*vid.width + viewwindowx; @@ -482,7 +483,7 @@ static void D_Display(void) if (postimgtype2) V_DoPostProcessor(1, postimgtype2, postimgparam2); } - rs_rendercalltime = I_GetTimeMicros() - rs_rendercalltime; + ps_rendercalltime = I_GetTimeMicros() - ps_rendercalltime; } if (lastdraw) @@ -496,7 +497,7 @@ static void D_Display(void) lastdraw = false; } - rs_uitime = I_GetTimeMicros(); + ps_uitime = I_GetTimeMicros(); if (gamestate == GS_LEVEL) { @@ -509,7 +510,7 @@ static void D_Display(void) } else { - rs_uitime = I_GetTimeMicros(); + ps_uitime = I_GetTimeMicros(); } } @@ -551,7 +552,7 @@ static void D_Display(void) CON_Drawer(); - rs_uitime = I_GetTimeMicros() - rs_uitime; + ps_uitime = I_GetTimeMicros() - ps_uitime; // // wipe update @@ -632,90 +633,14 @@ static void D_Display(void) V_DrawRightAlignedString(BASEVIDWIDTH, BASEVIDHEIGHT-ST_HEIGHT-10, V_YELLOWMAP, s); } - if (cv_renderstats.value) + if (cv_perfstats.value) { - char s[50]; - int frametime = I_GetTimeMicros() - rs_prevframetime; - int divisor = 1; - rs_prevframetime = I_GetTimeMicros(); - - if (rs_rendercalltime > 10000) divisor = 1000; - - snprintf(s, sizeof s - 1, "ft %d", frametime / divisor); - V_DrawThinString(30, 10, V_MONOSPACE | V_YELLOWMAP, s); - snprintf(s, sizeof s - 1, "rtot %d", rs_rendercalltime / divisor); - V_DrawThinString(30, 20, V_MONOSPACE | V_YELLOWMAP, s); - snprintf(s, sizeof s - 1, "bsp %d", rs_bsptime / divisor); - V_DrawThinString(30, 30, V_MONOSPACE | V_YELLOWMAP, s); - snprintf(s, sizeof s - 1, "nbsp %d", rs_numbspcalls); - V_DrawThinString(80, 10, V_MONOSPACE | V_BLUEMAP, s); - snprintf(s, sizeof s - 1, "nspr %d", rs_numsprites); - V_DrawThinString(80, 20, V_MONOSPACE | V_BLUEMAP, s); - snprintf(s, sizeof s - 1, "nnod %d", rs_numdrawnodes); - V_DrawThinString(80, 30, V_MONOSPACE | V_BLUEMAP, s); - snprintf(s, sizeof s - 1, "npob %d", rs_numpolyobjects); - V_DrawThinString(80, 40, V_MONOSPACE | V_BLUEMAP, s); - if (rendermode == render_opengl) // OpenGL specific stats - { -#ifdef HWRENDER - snprintf(s, sizeof s - 1, "nsrt %d", rs_hw_nodesorttime / divisor); - V_DrawThinString(30, 40, V_MONOSPACE | V_YELLOWMAP, s); - snprintf(s, sizeof s - 1, "ndrw %d", rs_hw_nodedrawtime / divisor); - V_DrawThinString(30, 50, V_MONOSPACE | V_YELLOWMAP, s); - snprintf(s, sizeof s - 1, "ssrt %d", rs_hw_spritesorttime / divisor); - V_DrawThinString(30, 60, V_MONOSPACE | V_YELLOWMAP, s); - snprintf(s, sizeof s - 1, "sdrw %d", rs_hw_spritedrawtime / divisor); - V_DrawThinString(30, 70, V_MONOSPACE | V_YELLOWMAP, s); - snprintf(s, sizeof s - 1, "ui %d", rs_uitime / divisor); - V_DrawThinString(30, 80, V_MONOSPACE | V_YELLOWMAP, s); - snprintf(s, sizeof s - 1, "fin %d", rs_swaptime / divisor); - V_DrawThinString(30, 90, V_MONOSPACE | V_YELLOWMAP, s); - snprintf(s, sizeof s - 1, "tic %d", rs_tictime / divisor); - V_DrawThinString(30, 105, V_MONOSPACE | V_GRAYMAP, s); - if (cv_glbatching.value) - { - snprintf(s, sizeof s - 1, "bsrt %d", rs_hw_batchsorttime / divisor); - V_DrawThinString(80, 55, V_MONOSPACE | V_REDMAP, s); - snprintf(s, sizeof s - 1, "bdrw %d", rs_hw_batchdrawtime / divisor); - V_DrawThinString(80, 65, V_MONOSPACE | V_REDMAP, s); - - snprintf(s, sizeof s - 1, "npol %d", rs_hw_numpolys); - V_DrawThinString(130, 10, V_MONOSPACE | V_PURPLEMAP, s); - snprintf(s, sizeof s - 1, "ndc %d", rs_hw_numcalls); - V_DrawThinString(130, 20, V_MONOSPACE | V_PURPLEMAP, s); - snprintf(s, sizeof s - 1, "nshd %d", rs_hw_numshaders); - V_DrawThinString(130, 30, V_MONOSPACE | V_PURPLEMAP, s); - snprintf(s, sizeof s - 1, "nvrt %d", rs_hw_numverts); - V_DrawThinString(130, 40, V_MONOSPACE | V_PURPLEMAP, s); - snprintf(s, sizeof s - 1, "ntex %d", rs_hw_numtextures); - V_DrawThinString(185, 10, V_MONOSPACE | V_PURPLEMAP, s); - snprintf(s, sizeof s - 1, "npf %d", rs_hw_numpolyflags); - V_DrawThinString(185, 20, V_MONOSPACE | V_PURPLEMAP, s); - snprintf(s, sizeof s - 1, "ncol %d", rs_hw_numcolors); - V_DrawThinString(185, 30, V_MONOSPACE | V_PURPLEMAP, s); - } -#endif - } - else // software specific stats - { - snprintf(s, sizeof s - 1, "prtl %d", rs_sw_portaltime / divisor); - V_DrawThinString(30, 40, V_MONOSPACE | V_YELLOWMAP, s); - snprintf(s, sizeof s - 1, "plns %d", rs_sw_planetime / divisor); - V_DrawThinString(30, 50, V_MONOSPACE | V_YELLOWMAP, s); - snprintf(s, sizeof s - 1, "mskd %d", rs_sw_maskedtime / divisor); - V_DrawThinString(30, 60, V_MONOSPACE | V_YELLOWMAP, s); - snprintf(s, sizeof s - 1, "ui %d", rs_uitime / divisor); - V_DrawThinString(30, 70, V_MONOSPACE | V_YELLOWMAP, s); - snprintf(s, sizeof s - 1, "fin %d", rs_swaptime / divisor); - V_DrawThinString(30, 80, V_MONOSPACE | V_YELLOWMAP, s); - snprintf(s, sizeof s - 1, "tic %d", rs_tictime / divisor); - V_DrawThinString(30, 95, V_MONOSPACE | V_GRAYMAP, s); - } + M_DrawPerfStats(); } - rs_swaptime = I_GetTimeMicros(); + ps_swaptime = I_GetTimeMicros(); I_FinishUpdate(); // page flip or blit buffer - rs_swaptime = I_GetTimeMicros() - rs_swaptime; + ps_swaptime = I_GetTimeMicros() - ps_swaptime; } needpatchflush = false; diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 6f4bcdb1d..80bf11552 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -371,6 +371,10 @@ consvar_t cv_mute = CVAR_INIT ("mute", "Off", CV_NETVAR|CV_CALL, CV_OnOff, Mute_ consvar_t cv_sleep = CVAR_INIT ("cpusleep", "1", CV_SAVE, sleeping_cons_t, NULL); +static CV_PossibleValue_t perfstats_cons_t[] = { + {0, "Off"}, {1, "Rendering"}, {2, "Logic"}, {3, "ThinkFrame"}, {0, NULL}}; +consvar_t cv_perfstats = CVAR_INIT ("perfstats", "Off", 0, perfstats_cons_t, NULL); + char timedemo_name[256]; boolean timedemo_csv; char timedemo_csv_id[256]; @@ -864,6 +868,8 @@ void D_RegisterClientCommands(void) CV_RegisterVar(&cv_soundtest); + CV_RegisterVar(&cv_perfstats); + // ingame object placing COM_AddCommand("objectplace", Command_ObjectPlace_f); COM_AddCommand("writethings", Command_Writethings_f); diff --git a/src/d_netcmd.h b/src/d_netcmd.h index 897c28968..841f71acd 100644 --- a/src/d_netcmd.h +++ b/src/d_netcmd.h @@ -114,6 +114,8 @@ extern consvar_t cv_skipmapcheck; extern consvar_t cv_sleep; +extern consvar_t cv_perfstats; + extern char timedemo_name[256]; extern boolean timedemo_csv; extern char timedemo_csv_id[256]; diff --git a/src/hardware/hw_batching.c b/src/hardware/hw_batching.c index 492cea5fa..a63be3a72 100644 --- a/src/hardware/hw_batching.c +++ b/src/hardware/hw_batching.c @@ -235,13 +235,13 @@ void HWR_RenderBatches(void) currently_batching = false;// no longer collecting batches if (!polygonArraySize) { - rs_hw_numpolys = rs_hw_numcalls = rs_hw_numshaders = rs_hw_numtextures = rs_hw_numpolyflags = rs_hw_numcolors = 0; + ps_hw_numpolys = ps_hw_numcalls = ps_hw_numshaders = ps_hw_numtextures = ps_hw_numpolyflags = ps_hw_numcolors = 0; return;// nothing to draw } // init stats vars - rs_hw_numpolys = polygonArraySize; - rs_hw_numcalls = rs_hw_numverts = 0; - rs_hw_numshaders = rs_hw_numtextures = rs_hw_numpolyflags = rs_hw_numcolors = 1; + ps_hw_numpolys = polygonArraySize; + ps_hw_numcalls = ps_hw_numverts = 0; + ps_hw_numshaders = ps_hw_numtextures = ps_hw_numpolyflags = ps_hw_numcolors = 1; // init polygonIndexArray for (i = 0; i < polygonArraySize; i++) { @@ -249,12 +249,12 @@ void HWR_RenderBatches(void) } // sort polygons - rs_hw_batchsorttime = I_GetTimeMicros(); + ps_hw_batchsorttime = I_GetTimeMicros(); if (cv_glshaders.value && gl_shadersavailable) qsort(polygonIndexArray, polygonArraySize, sizeof(unsigned int), comparePolygons); else qsort(polygonIndexArray, polygonArraySize, sizeof(unsigned int), comparePolygonsNoShaders); - rs_hw_batchsorttime = I_GetTimeMicros() - rs_hw_batchsorttime; + ps_hw_batchsorttime = I_GetTimeMicros() - ps_hw_batchsorttime; // sort order // 1. shader // 2. texture @@ -262,7 +262,7 @@ void HWR_RenderBatches(void) // 4. colors + light level // not sure about what order of the last 2 should be, or if it even matters - rs_hw_batchdrawtime = I_GetTimeMicros(); + ps_hw_batchdrawtime = I_GetTimeMicros(); currentShader = polygonArray[polygonIndexArray[0]].shader; currentTexture = polygonArray[polygonIndexArray[0]].texture; @@ -398,8 +398,8 @@ void HWR_RenderBatches(void) // execute draw call HWD.pfnDrawIndexedTriangles(¤tSurfaceInfo, finalVertexArray, finalIndexWritePos, currentPolyFlags, finalVertexIndexArray); // update stats - rs_hw_numcalls++; - rs_hw_numverts += finalIndexWritePos; + ps_hw_numcalls++; + ps_hw_numverts += finalIndexWritePos; // reset write positions finalVertexWritePos = 0; finalIndexWritePos = 0; @@ -416,7 +416,7 @@ void HWR_RenderBatches(void) currentShader = nextShader; changeShader = false; - rs_hw_numshaders++; + ps_hw_numshaders++; } if (changeTexture) { @@ -425,21 +425,21 @@ void HWR_RenderBatches(void) currentTexture = nextTexture; changeTexture = false; - rs_hw_numtextures++; + ps_hw_numtextures++; } if (changePolyFlags) { currentPolyFlags = nextPolyFlags; changePolyFlags = false; - rs_hw_numpolyflags++; + ps_hw_numpolyflags++; } if (changeSurfaceInfo) { currentSurfaceInfo = nextSurfaceInfo; changeSurfaceInfo = false; - rs_hw_numcolors++; + ps_hw_numcolors++; } // and that should be it? } @@ -447,7 +447,7 @@ void HWR_RenderBatches(void) polygonArraySize = 0; unsortedVertexArraySize = 0; - rs_hw_batchdrawtime = I_GetTimeMicros() - rs_hw_batchdrawtime; + ps_hw_batchdrawtime = I_GetTimeMicros() - ps_hw_batchdrawtime; } diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 991b51aee..e564c3869 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -146,21 +146,22 @@ static angle_t gl_aimingangle; static void HWR_SetTransformAiming(FTransform *trans, player_t *player, boolean skybox); // Render stats -int rs_hw_nodesorttime = 0; -int rs_hw_nodedrawtime = 0; -int rs_hw_spritesorttime = 0; -int rs_hw_spritedrawtime = 0; +int ps_hw_skyboxtime = 0; +int ps_hw_nodesorttime = 0; +int ps_hw_nodedrawtime = 0; +int ps_hw_spritesorttime = 0; +int ps_hw_spritedrawtime = 0; // Render stats for batching -int rs_hw_numpolys = 0; -int rs_hw_numverts = 0; -int rs_hw_numcalls = 0; -int rs_hw_numshaders = 0; -int rs_hw_numtextures = 0; -int rs_hw_numpolyflags = 0; -int rs_hw_numcolors = 0; -int rs_hw_batchsorttime = 0; -int rs_hw_batchdrawtime = 0; +int ps_hw_numpolys = 0; +int ps_hw_numverts = 0; +int ps_hw_numcalls = 0; +int ps_hw_numshaders = 0; +int ps_hw_numtextures = 0; +int ps_hw_numpolyflags = 0; +int ps_hw_numcolors = 0; +int ps_hw_batchsorttime = 0; +int ps_hw_batchdrawtime = 0; boolean gl_shadersavailable = true; @@ -3188,7 +3189,7 @@ static void HWR_Subsector(size_t num) } // for render stats - rs_numpolyobjects += numpolys; + ps_numpolyobjects += numpolys; // Sort polyobjects R_SortPolyObjects(sub); @@ -3296,7 +3297,7 @@ static void HWR_RenderBSPNode(INT32 bspnum) // Decide which side the view point is on INT32 side; - rs_numbspcalls++; + ps_numbspcalls++; // Found a subsector? if (bspnum & NF_SUBSECTOR) @@ -4502,7 +4503,7 @@ static void HWR_CreateDrawNodes(void) // that is already lying around. This should all be in some sort of linked list or lists. sortindex = Z_Calloc(sizeof(size_t) * (numplanes + numpolyplanes + numwalls), PU_STATIC, NULL); - rs_hw_nodesorttime = I_GetTimeMicros(); + ps_hw_nodesorttime = I_GetTimeMicros(); for (i = 0; i < numplanes; i++, p++) { @@ -4522,7 +4523,7 @@ static void HWR_CreateDrawNodes(void) sortindex[p] = p; } - rs_numdrawnodes = p; + ps_numdrawnodes = p; // p is the number of stuff to sort @@ -4557,9 +4558,9 @@ static void HWR_CreateDrawNodes(void) } } - rs_hw_nodesorttime = I_GetTimeMicros() - rs_hw_nodesorttime; + ps_hw_nodesorttime = I_GetTimeMicros() - ps_hw_nodesorttime; - rs_hw_nodedrawtime = I_GetTimeMicros(); + ps_hw_nodedrawtime = I_GetTimeMicros(); // Okay! Let's draw it all! Woo! HWD.pfnSetTransform(&atransform); @@ -4596,7 +4597,7 @@ static void HWR_CreateDrawNodes(void) } } - rs_hw_nodedrawtime = I_GetTimeMicros() - rs_hw_nodedrawtime; + ps_hw_nodedrawtime = I_GetTimeMicros() - ps_hw_nodedrawtime; numwalls = 0; numplanes = 0; @@ -5777,8 +5778,10 @@ void HWR_RenderPlayerView(INT32 viewnumber, player_t *player) if (viewnumber == 0) // Only do it if it's the first screen being rendered HWD.pfnClearBuffer(true, false, &ClearColor); // Clear the Color Buffer, stops HOMs. Also seems to fix the skybox issue on Intel GPUs. + ps_hw_skyboxtime = I_GetTimeMicros(); if (skybox && drawsky) // If there's a skybox and we should be drawing the sky, draw the skybox HWR_RenderSkyboxView(viewnumber, player); // This is drawn before everything else so it is placed behind + ps_hw_skyboxtime = I_GetTimeMicros() - ps_hw_skyboxtime; { // do we really need to save player (is it not the same)? @@ -5889,9 +5892,9 @@ void HWR_RenderPlayerView(INT32 viewnumber, player_t *player) HWD.pfnSetSpecialState(HWD_SET_SHADERS, cv_glshaders.value); HWD.pfnSetShader(0); - rs_numbspcalls = 0; - rs_numpolyobjects = 0; - rs_bsptime = I_GetTimeMicros(); + ps_numbspcalls = 0; + ps_numpolyobjects = 0; + ps_bsptime = I_GetTimeMicros(); validcount++; @@ -5929,7 +5932,7 @@ void HWR_RenderPlayerView(INT32 viewnumber, player_t *player) } #endif - rs_bsptime = I_GetTimeMicros() - rs_bsptime; + ps_bsptime = I_GetTimeMicros() - ps_bsptime; if (cv_glbatching.value) HWR_RenderBatches(); @@ -5944,22 +5947,22 @@ void HWR_RenderPlayerView(INT32 viewnumber, player_t *player) #endif // Draw MD2 and sprites - rs_numsprites = gl_visspritecount; - rs_hw_spritesorttime = I_GetTimeMicros(); + ps_numsprites = gl_visspritecount; + ps_hw_spritesorttime = I_GetTimeMicros(); HWR_SortVisSprites(); - rs_hw_spritesorttime = I_GetTimeMicros() - rs_hw_spritesorttime; - rs_hw_spritedrawtime = I_GetTimeMicros(); + ps_hw_spritesorttime = I_GetTimeMicros() - ps_hw_spritesorttime; + ps_hw_spritedrawtime = I_GetTimeMicros(); HWR_DrawSprites(); - rs_hw_spritedrawtime = I_GetTimeMicros() - rs_hw_spritedrawtime; + ps_hw_spritedrawtime = I_GetTimeMicros() - ps_hw_spritedrawtime; #ifdef NEWCORONAS //Hurdler: they must be drawn before translucent planes, what about gl fog? HWR_DrawCoronas(); #endif - rs_numdrawnodes = 0; - rs_hw_nodesorttime = 0; - rs_hw_nodedrawtime = 0; + ps_numdrawnodes = 0; + ps_hw_nodesorttime = 0; + ps_hw_nodedrawtime = 0; if (numplanes || numpolyplanes || numwalls) //Hurdler: render 3D water and transparent walls after everything { HWR_CreateDrawNodes(); @@ -6061,7 +6064,6 @@ void HWR_AddCommands(void) CV_RegisterVar(&cv_glfiltermode); CV_RegisterVar(&cv_glsolvetjoin); - CV_RegisterVar(&cv_renderstats); CV_RegisterVar(&cv_glbatching); #ifndef NEWCLIP diff --git a/src/hardware/hw_main.h b/src/hardware/hw_main.h index d70bb6d72..4bf197d7f 100644 --- a/src/hardware/hw_main.h +++ b/src/hardware/hw_main.h @@ -108,21 +108,22 @@ extern FTransform atransform; // Render stats -extern int rs_hw_nodesorttime; -extern int rs_hw_nodedrawtime; -extern int rs_hw_spritesorttime; -extern int rs_hw_spritedrawtime; +extern int ps_hw_skyboxtime; +extern int ps_hw_nodesorttime; +extern int ps_hw_nodedrawtime; +extern int ps_hw_spritesorttime; +extern int ps_hw_spritedrawtime; // Render stats for batching -extern int rs_hw_numpolys; -extern int rs_hw_numverts; -extern int rs_hw_numcalls; -extern int rs_hw_numshaders; -extern int rs_hw_numtextures; -extern int rs_hw_numpolyflags; -extern int rs_hw_numcolors; -extern int rs_hw_batchsorttime; -extern int rs_hw_batchdrawtime; +extern int ps_hw_numpolys; +extern int ps_hw_numverts; +extern int ps_hw_numcalls; +extern int ps_hw_numshaders; +extern int ps_hw_numtextures; +extern int ps_hw_numpolyflags; +extern int ps_hw_numcolors; +extern int ps_hw_batchsorttime; +extern int ps_hw_batchdrawtime; extern boolean gl_shadersavailable; diff --git a/src/lua_hooklib.c b/src/lua_hooklib.c index 8840c81a0..a5d4af412 100644 --- a/src/lua_hooklib.c +++ b/src/lua_hooklib.c @@ -23,6 +23,10 @@ #include "lua_hook.h" #include "lua_hud.h" // hud_running errors +#include "m_perfstats.h" +#include "d_netcmd.h" // for cv_perfstats +#include "i_system.h" // I_GetTimeMicros + static UINT8 hooksAvailable[(hook_MAX/8)+1]; const char *const hookNames[hook_MAX+1] = { @@ -269,6 +273,7 @@ boolean LUAh_MobjHook(mobj_t *mo, enum hook which) if (hookp->type != which) continue; + ps_lua_mobjhooks++; if (lua_gettop(gL) == 1) LUA_PushUserdata(gL, mo, META_MOBJ); PushHook(gL, hookp); @@ -290,6 +295,7 @@ boolean LUAh_MobjHook(mobj_t *mo, enum hook which) if (hookp->type != which) continue; + ps_lua_mobjhooks++; if (lua_gettop(gL) == 1) LUA_PushUserdata(gL, mo, META_MOBJ); PushHook(gL, hookp); @@ -325,6 +331,7 @@ boolean LUAh_PlayerHook(player_t *plr, enum hook which) if (hookp->type != which) continue; + ps_lua_mobjhooks++; if (lua_gettop(gL) == 1) LUA_PushUserdata(gL, plr, META_PLAYER); PushHook(gL, hookp); @@ -456,6 +463,9 @@ void LUAh_PreThinkFrame(void) void LUAh_ThinkFrame(void) { hook_p hookp; + // variables used by perf stats + int hook_index = 0; + int time_taken = 0; if (!gL || !(hooksAvailable[hook_ThinkFrame/8] & (1<<(hook_ThinkFrame%8)))) return; @@ -466,6 +476,8 @@ void LUAh_ThinkFrame(void) if (hookp->type != hook_ThinkFrame) continue; + if (cv_perfstats.value == 3) + time_taken = I_GetTimeMicros(); PushHook(gL, hookp); if (lua_pcall(gL, 0, 0, 1)) { if (!hookp->error || cv_debug & DBG_LUA) @@ -473,6 +485,16 @@ void LUAh_ThinkFrame(void) lua_pop(gL, 1); hookp->error = true; } + if (cv_perfstats.value == 3) + { + lua_Debug ar; + time_taken = I_GetTimeMicros() - time_taken; + // we need the function, let's just retrieve it again + PushHook(gL, hookp); + lua_getinfo(gL, ">S", &ar); + PS_SetThinkFrameHookInfo(hook_index, time_taken, ar.short_src); + hook_index++; + } } lua_pop(gL, 1); // Pop error handler @@ -523,6 +545,7 @@ UINT8 LUAh_MobjCollideHook(mobj_t *thing1, mobj_t *thing2, enum hook which) if (hookp->type != which) continue; + ps_lua_mobjhooks++; if (lua_gettop(gL) == 1) { LUA_PushUserdata(gL, thing1, META_MOBJ); @@ -553,6 +576,7 @@ UINT8 LUAh_MobjCollideHook(mobj_t *thing1, mobj_t *thing2, enum hook which) if (hookp->type != which) continue; + ps_lua_mobjhooks++; if (lua_gettop(gL) == 1) { LUA_PushUserdata(gL, thing1, META_MOBJ); @@ -600,6 +624,7 @@ UINT8 LUAh_MobjLineCollideHook(mobj_t *thing, line_t *line, enum hook which) if (hookp->type != which) continue; + ps_lua_mobjhooks++; if (lua_gettop(gL) == 1) { LUA_PushUserdata(gL, thing, META_MOBJ); @@ -630,6 +655,7 @@ UINT8 LUAh_MobjLineCollideHook(mobj_t *thing, line_t *line, enum hook which) if (hookp->type != which) continue; + ps_lua_mobjhooks++; if (lua_gettop(gL) == 1) { LUA_PushUserdata(gL, thing, META_MOBJ); @@ -675,6 +701,7 @@ boolean LUAh_MobjThinker(mobj_t *mo) // Look for all generic mobj thinker hooks for (hookp = mobjthinkerhooks[MT_NULL]; hookp; hookp = hookp->next) { + ps_lua_mobjhooks++; if (lua_gettop(gL) == 1) LUA_PushUserdata(gL, mo, META_MOBJ); PushHook(gL, hookp); @@ -693,6 +720,7 @@ boolean LUAh_MobjThinker(mobj_t *mo) for (hookp = mobjthinkerhooks[mo->type]; hookp; hookp = hookp->next) { + ps_lua_mobjhooks++; if (lua_gettop(gL) == 1) LUA_PushUserdata(gL, mo, META_MOBJ); PushHook(gL, hookp); @@ -732,6 +760,7 @@ boolean LUAh_TouchSpecial(mobj_t *special, mobj_t *toucher) if (hookp->type != hook_TouchSpecial) continue; + ps_lua_mobjhooks++; if (lua_gettop(gL) == 1) { LUA_PushUserdata(gL, special, META_MOBJ); @@ -757,6 +786,7 @@ boolean LUAh_TouchSpecial(mobj_t *special, mobj_t *toucher) if (hookp->type != hook_TouchSpecial) continue; + ps_lua_mobjhooks++; if (lua_gettop(gL) == 1) { LUA_PushUserdata(gL, special, META_MOBJ); @@ -800,6 +830,7 @@ UINT8 LUAh_ShouldDamage(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 if (hookp->type != hook_ShouldDamage) continue; + ps_lua_mobjhooks++; if (lua_gettop(gL) == 1) { LUA_PushUserdata(gL, target, META_MOBJ); @@ -835,6 +866,7 @@ UINT8 LUAh_ShouldDamage(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 { if (hookp->type != hook_ShouldDamage) continue; + ps_lua_mobjhooks++; if (lua_gettop(gL) == 1) { LUA_PushUserdata(gL, target, META_MOBJ); @@ -889,6 +921,7 @@ boolean LUAh_MobjDamage(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 if (hookp->type != hook_MobjDamage) continue; + ps_lua_mobjhooks++; if (lua_gettop(gL) == 1) { LUA_PushUserdata(gL, target, META_MOBJ); @@ -920,6 +953,7 @@ boolean LUAh_MobjDamage(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 if (hookp->type != hook_MobjDamage) continue; + ps_lua_mobjhooks++; if (lua_gettop(gL) == 1) { LUA_PushUserdata(gL, target, META_MOBJ); @@ -969,6 +1003,7 @@ boolean LUAh_MobjDeath(mobj_t *target, mobj_t *inflictor, mobj_t *source, UINT8 if (hookp->type != hook_MobjDeath) continue; + ps_lua_mobjhooks++; if (lua_gettop(gL) == 1) { LUA_PushUserdata(gL, target, META_MOBJ); @@ -998,6 +1033,7 @@ boolean LUAh_MobjDeath(mobj_t *target, mobj_t *inflictor, mobj_t *source, UINT8 if (hookp->type != hook_MobjDeath) continue; + ps_lua_mobjhooks++; if (lua_gettop(gL) == 1) { LUA_PushUserdata(gL, target, META_MOBJ); @@ -1190,6 +1226,7 @@ boolean LUAh_LinedefExecute(line_t *line, mobj_t *mo, sector_t *sector) if (strcmp(hookp->s.str, line->stringargs[0])) continue; + ps_lua_mobjhooks++; if (lua_gettop(gL) == 1) { LUA_PushUserdata(gL, line, META_LINE); @@ -1364,6 +1401,7 @@ boolean LUAh_MapThingSpawn(mobj_t *mo, mapthing_t *mthing) if (hookp->type != hook_MapThingSpawn) continue; + ps_lua_mobjhooks++; if (lua_gettop(gL) == 1) { LUA_PushUserdata(gL, mo, META_MOBJ); @@ -1389,6 +1427,7 @@ boolean LUAh_MapThingSpawn(mobj_t *mo, mapthing_t *mthing) if (hookp->type != hook_MapThingSpawn) continue; + ps_lua_mobjhooks++; if (lua_gettop(gL) == 1) { LUA_PushUserdata(gL, mo, META_MOBJ); @@ -1430,6 +1469,7 @@ boolean LUAh_FollowMobj(player_t *player, mobj_t *mobj) if (hookp->type != hook_FollowMobj) continue; + ps_lua_mobjhooks++; if (lua_gettop(gL) == 1) { LUA_PushUserdata(gL, player, META_PLAYER); @@ -1455,6 +1495,7 @@ boolean LUAh_FollowMobj(player_t *player, mobj_t *mobj) if (hookp->type != hook_FollowMobj) continue; + ps_lua_mobjhooks++; if (lua_gettop(gL) == 1) { LUA_PushUserdata(gL, player, META_PLAYER); @@ -1495,6 +1536,7 @@ UINT8 LUAh_PlayerCanDamage(player_t *player, mobj_t *mobj) if (hookp->type != hook_PlayerCanDamage) continue; + ps_lua_mobjhooks++; if (lua_gettop(gL) == 1) { LUA_PushUserdata(gL, player, META_PLAYER); diff --git a/src/m_perfstats.c b/src/m_perfstats.c new file mode 100644 index 000000000..df1e31b5e --- /dev/null +++ b/src/m_perfstats.c @@ -0,0 +1,541 @@ +// SONIC ROBO BLAST 2 +//----------------------------------------------------------------------------- +// Copyright (C) 1998-2000 by DooM Legacy Team. +// Copyright (C) 1999-2020 by Sonic Team Junior. +// +// This program is free software distributed under the +// terms of the GNU General Public License, version 2. +// See the 'LICENSE' file for more details. +//----------------------------------------------------------------------------- +/// \file m_perfstats.c +/// \brief Performance measurement tools. + +#include "m_perfstats.h" +#include "v_video.h" +#include "i_video.h" +#include "d_netcmd.h" +#include "r_main.h" +#include "i_system.h" +#include "z_zone.h" +#include "p_local.h" + +#ifdef HWRENDER +#include "hardware/hw_main.h" +#endif + +int ps_tictime = 0; + +int ps_playerthink_time = 0; +int ps_thinkertime = 0; + +int ps_thlist_times[NUM_THINKERLISTS]; +static const char* thlist_names[] = { + "Polyobjects: %d", + "Main: %d", + "Mobjs: %d", + "Dynamic slopes: %d", + "Precipitation: %d", + NULL +}; +static const char* thlist_shortnames[] = { + "plyobjs %d", + "main %d", + "mobjs %d", + "dynslop %d", + "precip %d", + NULL +}; + +int ps_checkposition_calls = 0; + +int ps_lua_thinkframe_time = 0; +int ps_lua_mobjhooks = 0; + +// dynamically allocated resizeable array for thinkframe hook stats +ps_hookinfo_t *thinkframe_hooks = NULL; +int thinkframe_hooks_length = 0; +int thinkframe_hooks_capacity = 16; + +void PS_SetThinkFrameHookInfo(int index, UINT32 time_taken, char* short_src) +{ + if (!thinkframe_hooks) + { + // array needs to be initialized + thinkframe_hooks = Z_Malloc(sizeof(ps_hookinfo_t) * thinkframe_hooks_capacity, PU_STATIC, NULL); + } + if (index >= thinkframe_hooks_capacity) + { + // array needs more space, realloc with double size + thinkframe_hooks_capacity *= 2; + thinkframe_hooks = Z_Realloc(thinkframe_hooks, + sizeof(ps_hookinfo_t) * thinkframe_hooks_capacity, PU_STATIC, NULL); + } + thinkframe_hooks[index].time_taken = time_taken; + memcpy(thinkframe_hooks[index].short_src, short_src, LUA_IDSIZE * sizeof(char)); + // since the values are set sequentially from begin to end, the last call should leave + // the correct value to this variable + thinkframe_hooks_length = index + 1; +} + +void M_DrawPerfStats(void) +{ + char s[100]; + int currenttime = I_GetTimeMicros(); + int frametime = currenttime - ps_prevframetime; + ps_prevframetime = currenttime; + + if (cv_perfstats.value == 1) // rendering + { + if (vid.width < 640 || vid.height < 400) // low resolution + { + snprintf(s, sizeof s - 1, "frmtime %d", frametime); + V_DrawThinString(20, 10, V_MONOSPACE | V_YELLOWMAP, s); + if (!(gamestate == GS_LEVEL || (gamestate == GS_TITLESCREEN && titlemapinaction))) + { + snprintf(s, sizeof s - 1, "ui %d", ps_uitime); + V_DrawThinString(20, 18, V_MONOSPACE | V_YELLOWMAP, s); + snprintf(s, sizeof s - 1, "finupdt %d", ps_swaptime); + V_DrawThinString(20, 26, V_MONOSPACE | V_YELLOWMAP, s); + snprintf(s, sizeof s - 1, "logic %d", ps_tictime); + V_DrawThinString(20, 38, V_MONOSPACE | V_GRAYMAP, s); + return; + } + snprintf(s, sizeof s - 1, "drwtime %d", ps_rendercalltime); + V_DrawThinString(20, 18, V_MONOSPACE | V_YELLOWMAP, s); + snprintf(s, sizeof s - 1, "bspcall %d", ps_numbspcalls); + V_DrawThinString(90, 10, V_MONOSPACE | V_BLUEMAP, s); + snprintf(s, sizeof s - 1, "sprites %d", ps_numsprites); + V_DrawThinString(90, 18, V_MONOSPACE | V_BLUEMAP, s); + snprintf(s, sizeof s - 1, "drwnode %d", ps_numdrawnodes); + V_DrawThinString(90, 26, V_MONOSPACE | V_BLUEMAP, s); + snprintf(s, sizeof s - 1, "plyobjs %d", ps_numpolyobjects); + V_DrawThinString(90, 34, V_MONOSPACE | V_BLUEMAP, s); +#ifdef HWRENDER + if (rendermode == render_opengl) // OpenGL specific stats + { + snprintf(s, sizeof s - 1, "skybox %d", ps_hw_skyboxtime); + V_DrawThinString(24, 26, V_MONOSPACE | V_YELLOWMAP, s); + snprintf(s, sizeof s - 1, "bsptime %d", ps_bsptime); + V_DrawThinString(24, 34, V_MONOSPACE | V_YELLOWMAP, s); + snprintf(s, sizeof s - 1, "nodesrt %d", ps_hw_nodesorttime); + V_DrawThinString(24, 42, V_MONOSPACE | V_YELLOWMAP, s); + snprintf(s, sizeof s - 1, "nodedrw %d", ps_hw_nodedrawtime); + V_DrawThinString(24, 50, V_MONOSPACE | V_YELLOWMAP, s); + snprintf(s, sizeof s - 1, "sprsort %d", ps_hw_spritesorttime); + V_DrawThinString(24, 58, V_MONOSPACE | V_YELLOWMAP, s); + snprintf(s, sizeof s - 1, "sprdraw %d", ps_hw_spritedrawtime); + V_DrawThinString(24, 66, V_MONOSPACE | V_YELLOWMAP, s); + snprintf(s, sizeof s - 1, "other %d", + ps_rendercalltime - ps_hw_skyboxtime - ps_bsptime - ps_hw_nodesorttime + - ps_hw_nodedrawtime - ps_hw_spritesorttime - ps_hw_spritedrawtime + - ps_hw_batchsorttime - ps_hw_batchdrawtime); + V_DrawThinString(24, 74, V_MONOSPACE | V_YELLOWMAP, s); + snprintf(s, sizeof s - 1, "ui %d", ps_uitime); + V_DrawThinString(20, 82, V_MONOSPACE | V_YELLOWMAP, s); + snprintf(s, sizeof s - 1, "finupdt %d", ps_swaptime); + V_DrawThinString(20, 90, V_MONOSPACE | V_YELLOWMAP, s); + snprintf(s, sizeof s - 1, "logic %d", ps_tictime); + V_DrawThinString(20, 102, V_MONOSPACE | V_GRAYMAP, s); + if (cv_glbatching.value) + { + snprintf(s, sizeof s - 1, "batsort %d", ps_hw_batchsorttime); + V_DrawThinString(90, 46, V_MONOSPACE | V_REDMAP, s); + snprintf(s, sizeof s - 1, "batdraw %d", ps_hw_batchdrawtime); + V_DrawThinString(90, 54, V_MONOSPACE | V_REDMAP, s); + + snprintf(s, sizeof s - 1, "polygon %d", ps_hw_numpolys); + V_DrawThinString(155, 10, V_MONOSPACE | V_PURPLEMAP, s); + snprintf(s, sizeof s - 1, "drwcall %d", ps_hw_numcalls); + V_DrawThinString(155, 18, V_MONOSPACE | V_PURPLEMAP, s); + snprintf(s, sizeof s - 1, "shaders %d", ps_hw_numshaders); + V_DrawThinString(155, 26, V_MONOSPACE | V_PURPLEMAP, s); + snprintf(s, sizeof s - 1, "vertex %d", ps_hw_numverts); + V_DrawThinString(155, 34, V_MONOSPACE | V_PURPLEMAP, s); + snprintf(s, sizeof s - 1, "texture %d", ps_hw_numtextures); + V_DrawThinString(220, 10, V_MONOSPACE | V_PURPLEMAP, s); + snprintf(s, sizeof s - 1, "polyflg %d", ps_hw_numpolyflags); + V_DrawThinString(220, 18, V_MONOSPACE | V_PURPLEMAP, s); + snprintf(s, sizeof s - 1, "colors %d", ps_hw_numcolors); + V_DrawThinString(220, 26, V_MONOSPACE | V_PURPLEMAP, s); + } + else + { + // reset these vars so the "other" measurement isn't off + ps_hw_batchsorttime = 0; + ps_hw_batchdrawtime = 0; + } + } + else // software specific stats +#endif + { + snprintf(s, sizeof s - 1, "bsptime %d", ps_bsptime); + V_DrawThinString(24, 26, V_MONOSPACE | V_YELLOWMAP, s); + snprintf(s, sizeof s - 1, "sprclip %d", ps_sw_spritecliptime); + V_DrawThinString(24, 34, V_MONOSPACE | V_YELLOWMAP, s); + snprintf(s, sizeof s - 1, "portals %d", ps_sw_portaltime); + V_DrawThinString(24, 42, V_MONOSPACE | V_YELLOWMAP, s); + snprintf(s, sizeof s - 1, "planes %d", ps_sw_planetime); + V_DrawThinString(24, 50, V_MONOSPACE | V_YELLOWMAP, s); + snprintf(s, sizeof s - 1, "masked %d", ps_sw_maskedtime); + V_DrawThinString(24, 58, V_MONOSPACE | V_YELLOWMAP, s); + snprintf(s, sizeof s - 1, "other %d", + ps_rendercalltime - ps_bsptime - ps_sw_spritecliptime + - ps_sw_portaltime - ps_sw_planetime - ps_sw_maskedtime); + V_DrawThinString(24, 66, V_MONOSPACE | V_YELLOWMAP, s); + snprintf(s, sizeof s - 1, "ui %d", ps_uitime); + V_DrawThinString(20, 74, V_MONOSPACE | V_YELLOWMAP, s); + snprintf(s, sizeof s - 1, "finupdt %d", ps_swaptime); + V_DrawThinString(20, 82, V_MONOSPACE | V_YELLOWMAP, s); + snprintf(s, sizeof s - 1, "logic %d", ps_tictime); + V_DrawThinString(20, 94, V_MONOSPACE | V_GRAYMAP, s); + } + } + else // high resolution + { + snprintf(s, sizeof s - 1, "Frame time: %d", frametime); + V_DrawSmallString(20, 10, V_MONOSPACE | V_ALLOWLOWERCASE | V_YELLOWMAP, s); + if (!(gamestate == GS_LEVEL || (gamestate == GS_TITLESCREEN && titlemapinaction))) + { + snprintf(s, sizeof s - 1, "UI render: %d", ps_uitime); + V_DrawSmallString(20, 15, V_MONOSPACE | V_ALLOWLOWERCASE | V_YELLOWMAP, s); + snprintf(s, sizeof s - 1, "I_FinishUpdate: %d", ps_swaptime); + V_DrawSmallString(20, 20, V_MONOSPACE | V_ALLOWLOWERCASE | V_YELLOWMAP, s); + snprintf(s, sizeof s - 1, "Game logic: %d", ps_tictime); + V_DrawSmallString(20, 30, V_MONOSPACE | V_ALLOWLOWERCASE | V_GRAYMAP, s); + return; + } + snprintf(s, sizeof s - 1, "3d rendering: %d", ps_rendercalltime); + V_DrawSmallString(20, 15, V_MONOSPACE | V_ALLOWLOWERCASE | V_YELLOWMAP, s); + snprintf(s, sizeof s - 1, "BSP calls: %d", ps_numbspcalls); + V_DrawSmallString(115, 10, V_MONOSPACE | V_ALLOWLOWERCASE | V_BLUEMAP, s); + snprintf(s, sizeof s - 1, "Sprites: %d", ps_numsprites); + V_DrawSmallString(115, 15, V_MONOSPACE | V_ALLOWLOWERCASE | V_BLUEMAP, s); + snprintf(s, sizeof s - 1, "Drawnodes: %d", ps_numdrawnodes); + V_DrawSmallString(115, 20, V_MONOSPACE | V_ALLOWLOWERCASE | V_BLUEMAP, s); + snprintf(s, sizeof s - 1, "Polyobjects: %d", ps_numpolyobjects); + V_DrawSmallString(115, 25, V_MONOSPACE | V_ALLOWLOWERCASE | V_BLUEMAP, s); +#ifdef HWRENDER + if (rendermode == render_opengl) // OpenGL specific stats + { + snprintf(s, sizeof s - 1, "Skybox render: %d", ps_hw_skyboxtime); + V_DrawSmallString(24, 20, V_MONOSPACE | V_ALLOWLOWERCASE | V_YELLOWMAP, s); + snprintf(s, sizeof s - 1, "RenderBSPNode: %d", ps_bsptime); + V_DrawSmallString(24, 25, V_MONOSPACE | V_ALLOWLOWERCASE | V_YELLOWMAP, s); + snprintf(s, sizeof s - 1, "Drwnode sort: %d", ps_hw_nodesorttime); + V_DrawSmallString(24, 30, V_MONOSPACE | V_ALLOWLOWERCASE | V_YELLOWMAP, s); + snprintf(s, sizeof s - 1, "Drwnode render: %d", ps_hw_nodedrawtime); + V_DrawSmallString(24, 35, V_MONOSPACE | V_ALLOWLOWERCASE | V_YELLOWMAP, s); + snprintf(s, sizeof s - 1, "Sprite sort: %d", ps_hw_spritesorttime); + V_DrawSmallString(24, 40, V_MONOSPACE | V_ALLOWLOWERCASE | V_YELLOWMAP, s); + snprintf(s, sizeof s - 1, "Sprite render: %d", ps_hw_spritedrawtime); + V_DrawSmallString(24, 45, V_MONOSPACE | V_ALLOWLOWERCASE | V_YELLOWMAP, s); + // Remember to update this calculation when adding more 3d rendering stats! + snprintf(s, sizeof s - 1, "Other: %d", + ps_rendercalltime - ps_hw_skyboxtime - ps_bsptime - ps_hw_nodesorttime + - ps_hw_nodedrawtime - ps_hw_spritesorttime - ps_hw_spritedrawtime + - ps_hw_batchsorttime - ps_hw_batchdrawtime); + V_DrawSmallString(24, 50, V_MONOSPACE | V_ALLOWLOWERCASE | V_YELLOWMAP, s); + snprintf(s, sizeof s - 1, "UI render: %d", ps_uitime); + V_DrawSmallString(20, 55, V_MONOSPACE | V_ALLOWLOWERCASE | V_YELLOWMAP, s); + snprintf(s, sizeof s - 1, "I_FinishUpdate: %d", ps_swaptime); + V_DrawSmallString(20, 60, V_MONOSPACE | V_ALLOWLOWERCASE | V_YELLOWMAP, s); + snprintf(s, sizeof s - 1, "Game logic: %d", ps_tictime); + V_DrawSmallString(20, 70, V_MONOSPACE | V_ALLOWLOWERCASE | V_GRAYMAP, s); + if (cv_glbatching.value) + { + snprintf(s, sizeof s - 1, "Batch sort: %d", ps_hw_batchsorttime); + V_DrawSmallString(115, 35, V_MONOSPACE | V_ALLOWLOWERCASE | V_REDMAP, s); + snprintf(s, sizeof s - 1, "Batch render: %d", ps_hw_batchdrawtime); + V_DrawSmallString(115, 40, V_MONOSPACE | V_ALLOWLOWERCASE | V_REDMAP, s); + + snprintf(s, sizeof s - 1, "Polygons: %d", ps_hw_numpolys); + V_DrawSmallString(200, 10, V_MONOSPACE | V_ALLOWLOWERCASE | V_PURPLEMAP, s); + snprintf(s, sizeof s - 1, "Vertices: %d", ps_hw_numverts); + V_DrawSmallString(200, 15, V_MONOSPACE | V_ALLOWLOWERCASE | V_PURPLEMAP, s); + snprintf(s, sizeof s - 1, "Draw calls: %d", ps_hw_numcalls); + V_DrawSmallString(200, 25, V_MONOSPACE | V_ALLOWLOWERCASE | V_PURPLEMAP, s); + snprintf(s, sizeof s - 1, "Shaders: %d", ps_hw_numshaders); + V_DrawSmallString(200, 30, V_MONOSPACE | V_ALLOWLOWERCASE | V_PURPLEMAP, s); + snprintf(s, sizeof s - 1, "Textures: %d", ps_hw_numtextures); + V_DrawSmallString(200, 35, V_MONOSPACE | V_ALLOWLOWERCASE | V_PURPLEMAP, s); + snprintf(s, sizeof s - 1, "Polyflags: %d", ps_hw_numpolyflags); + V_DrawSmallString(200, 40, V_MONOSPACE | V_ALLOWLOWERCASE | V_PURPLEMAP, s); + snprintf(s, sizeof s - 1, "Colors: %d", ps_hw_numcolors); + V_DrawSmallString(200, 45, V_MONOSPACE | V_ALLOWLOWERCASE | V_PURPLEMAP, s); + } + else + { + // reset these vars so the "other" measurement isn't off + ps_hw_batchsorttime = 0; + ps_hw_batchdrawtime = 0; + } + } + else // software specific stats +#endif + { + snprintf(s, sizeof s - 1, "RenderBSPNode: %d", ps_bsptime); + V_DrawSmallString(24, 20, V_MONOSPACE | V_ALLOWLOWERCASE | V_YELLOWMAP, s); + snprintf(s, sizeof s - 1, "R_ClipSprites: %d", ps_sw_spritecliptime); + V_DrawSmallString(24, 25, V_MONOSPACE | V_ALLOWLOWERCASE | V_YELLOWMAP, s); + snprintf(s, sizeof s - 1, "Portals+Skybox: %d", ps_sw_portaltime); + V_DrawSmallString(24, 30, V_MONOSPACE | V_ALLOWLOWERCASE | V_YELLOWMAP, s); + snprintf(s, sizeof s - 1, "R_DrawPlanes: %d", ps_sw_planetime); + V_DrawSmallString(24, 35, V_MONOSPACE | V_ALLOWLOWERCASE | V_YELLOWMAP, s); + snprintf(s, sizeof s - 1, "R_DrawMasked: %d", ps_sw_maskedtime); + V_DrawSmallString(24, 40, V_MONOSPACE | V_ALLOWLOWERCASE | V_YELLOWMAP, s); + // Remember to update this calculation when adding more 3d rendering stats! + snprintf(s, sizeof s - 1, "Other: %d", + ps_rendercalltime - ps_bsptime - ps_sw_spritecliptime + - ps_sw_portaltime - ps_sw_planetime - ps_sw_maskedtime); + V_DrawSmallString(24, 45, V_MONOSPACE | V_ALLOWLOWERCASE | V_YELLOWMAP, s); + snprintf(s, sizeof s - 1, "UI render: %d", ps_uitime); + V_DrawSmallString(20, 50, V_MONOSPACE | V_ALLOWLOWERCASE | V_YELLOWMAP, s); + snprintf(s, sizeof s - 1, "I_FinishUpdate: %d", ps_swaptime); + V_DrawSmallString(20, 55, V_MONOSPACE | V_ALLOWLOWERCASE | V_YELLOWMAP, s); + snprintf(s, sizeof s - 1, "Game logic: %d", ps_tictime); + V_DrawSmallString(20, 65, V_MONOSPACE | V_ALLOWLOWERCASE | V_GRAYMAP, s); + } + } + } + else if (cv_perfstats.value == 2) // logic + { + int i = 0; + thinker_t *thinker; + int thinkercount = 0; + int polythcount = 0; + int mainthcount = 0; + int mobjcount = 0; + int nothinkcount = 0; + int scenerycount = 0; + int dynslopethcount = 0; + int precipcount = 0; + int removecount = 0; + // y offset for drawing columns + int yoffset1 = 0; + int yoffset2 = 0; + + for (i = 0; i < NUM_THINKERLISTS; i++) + { + for (thinker = thlist[i].next; thinker != &thlist[i]; thinker = thinker->next) + { + thinkercount++; + if (thinker->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) + removecount++; + else if (i == THINK_POLYOBJ) + polythcount++; + else if (i == THINK_MAIN) + mainthcount++; + else if (i == THINK_MOBJ) + { + if (thinker->function.acp1 == (actionf_p1)P_MobjThinker) + { + mobj_t *mobj = (mobj_t*)thinker; + mobjcount++; + if (mobj->flags & MF_NOTHINK) + nothinkcount++; + else if (mobj->flags & MF_SCENERY) + scenerycount++; + } + } + else if (i == THINK_DYNSLOPE) + dynslopethcount++; + else if (i == THINK_PRECIP) + precipcount++; + } + } + + if (vid.width < 640 || vid.height < 400) // low resolution + { + snprintf(s, sizeof s - 1, "logic %d", ps_tictime); + V_DrawThinString(20, 10, V_MONOSPACE | V_YELLOWMAP, s); + if (!(gamestate == GS_LEVEL || (gamestate == GS_TITLESCREEN && titlemapinaction))) + return; + snprintf(s, sizeof s - 1, "plrthnk %d", ps_playerthink_time); + V_DrawThinString(24, 18, V_MONOSPACE | V_YELLOWMAP, s); + snprintf(s, sizeof s - 1, "thnkers %d", ps_thinkertime); + V_DrawThinString(24, 26, V_MONOSPACE | V_YELLOWMAP, s); + for (i = 0; i < NUM_THINKERLISTS; i++) + { + yoffset1 += 8; + snprintf(s, sizeof s - 1, thlist_shortnames[i], ps_thlist_times[i]); + V_DrawThinString(28, 26+yoffset1, V_MONOSPACE | V_YELLOWMAP, s); + } + snprintf(s, sizeof s - 1, "lthinkf %d", ps_lua_thinkframe_time); + V_DrawThinString(24, 34+yoffset1, V_MONOSPACE | V_YELLOWMAP, s); + snprintf(s, sizeof s - 1, "other %d", + ps_tictime - ps_playerthink_time - ps_thinkertime - ps_lua_thinkframe_time); + V_DrawThinString(24, 42+yoffset1, V_MONOSPACE | V_YELLOWMAP, s); + + snprintf(s, sizeof s - 1, "thnkers %d", thinkercount); + V_DrawThinString(90, 10, V_MONOSPACE | V_BLUEMAP, s); + snprintf(s, sizeof s - 1, "plyobjs %d", polythcount); + V_DrawThinString(94, 18, V_MONOSPACE | V_BLUEMAP, s); + snprintf(s, sizeof s - 1, "main %d", mainthcount); + V_DrawThinString(94, 26, V_MONOSPACE | V_BLUEMAP, s); + snprintf(s, sizeof s - 1, "mobjs %d", mobjcount); + V_DrawThinString(94, 34, V_MONOSPACE | V_BLUEMAP, s); + snprintf(s, sizeof s - 1, "regular %d", mobjcount - scenerycount - nothinkcount); + V_DrawThinString(98, 42, V_MONOSPACE | V_BLUEMAP, s); + snprintf(s, sizeof s - 1, "scenery %d", scenerycount); + V_DrawThinString(98, 50, V_MONOSPACE | V_BLUEMAP, s); + if (nothinkcount) + { + snprintf(s, sizeof s - 1, "nothink %d", nothinkcount); + V_DrawThinString(98, 58, V_MONOSPACE | V_BLUEMAP, s); + yoffset2 += 8; + } + snprintf(s, sizeof s - 1, "dynslop %d", dynslopethcount); + V_DrawThinString(94, 58+yoffset2, V_MONOSPACE | V_BLUEMAP, s); + snprintf(s, sizeof s - 1, "precip %d", precipcount); + V_DrawThinString(94, 66+yoffset2, V_MONOSPACE | V_BLUEMAP, s); + snprintf(s, sizeof s - 1, "remove %d", removecount); + V_DrawThinString(94, 74+yoffset2, V_MONOSPACE | V_BLUEMAP, s); + + snprintf(s, sizeof s - 1, "lmhooks %d", ps_lua_mobjhooks); + V_DrawThinString(170, 10, V_MONOSPACE | V_PURPLEMAP, s); + snprintf(s, sizeof s - 1, "chkpos %d", ps_checkposition_calls); + V_DrawThinString(170, 18, V_MONOSPACE | V_PURPLEMAP, s); + } + else // high resolution + { + snprintf(s, sizeof s - 1, "Game logic: %d", ps_tictime); + V_DrawSmallString(20, 10, V_MONOSPACE | V_ALLOWLOWERCASE | V_YELLOWMAP, s); + if (!(gamestate == GS_LEVEL || (gamestate == GS_TITLESCREEN && titlemapinaction))) + return; + snprintf(s, sizeof s - 1, "P_PlayerThink: %d", ps_playerthink_time); + V_DrawSmallString(24, 15, V_MONOSPACE | V_ALLOWLOWERCASE | V_YELLOWMAP, s); + snprintf(s, sizeof s - 1, "P_RunThinkers: %d", ps_thinkertime); + V_DrawSmallString(24, 20, V_MONOSPACE | V_ALLOWLOWERCASE | V_YELLOWMAP, s); + for (i = 0; i < NUM_THINKERLISTS; i++) + { + yoffset1 += 5; + snprintf(s, sizeof s - 1, thlist_names[i], ps_thlist_times[i]); + V_DrawSmallString(28, 20+yoffset1, V_MONOSPACE | V_ALLOWLOWERCASE | V_YELLOWMAP, s); + } + snprintf(s, sizeof s - 1, "LUAh_ThinkFrame: %d", ps_lua_thinkframe_time); + V_DrawSmallString(24, 25+yoffset1, V_MONOSPACE | V_ALLOWLOWERCASE | V_YELLOWMAP, s); + snprintf(s, sizeof s - 1, "Other: %d", + ps_tictime - ps_playerthink_time - ps_thinkertime - ps_lua_thinkframe_time); + V_DrawSmallString(24, 30+yoffset1, V_MONOSPACE | V_ALLOWLOWERCASE | V_YELLOWMAP, s); + + snprintf(s, sizeof s - 1, "Thinkers: %d", thinkercount); + V_DrawSmallString(115, 10+yoffset2, V_MONOSPACE | V_ALLOWLOWERCASE | V_BLUEMAP, s); + snprintf(s, sizeof s - 1, "Polyobjects: %d", polythcount); + V_DrawSmallString(119, 15+yoffset2, V_MONOSPACE | V_ALLOWLOWERCASE | V_BLUEMAP, s); + snprintf(s, sizeof s - 1, "Main: %d", mainthcount); + V_DrawSmallString(119, 20+yoffset2, V_MONOSPACE | V_ALLOWLOWERCASE | V_BLUEMAP, s); + snprintf(s, sizeof s - 1, "Mobjs: %d", mobjcount); + V_DrawSmallString(119, 25+yoffset2, V_MONOSPACE | V_ALLOWLOWERCASE | V_BLUEMAP, s); + snprintf(s, sizeof s - 1, "Regular: %d", mobjcount - scenerycount - nothinkcount); + V_DrawSmallString(123, 30+yoffset2, V_MONOSPACE | V_ALLOWLOWERCASE | V_BLUEMAP, s); + snprintf(s, sizeof s - 1, "Scenery: %d", scenerycount); + V_DrawSmallString(123, 35+yoffset2, V_MONOSPACE | V_ALLOWLOWERCASE | V_BLUEMAP, s); + if (nothinkcount) + { + snprintf(s, sizeof s - 1, "Nothink: %d", nothinkcount); + V_DrawSmallString(123, 40+yoffset2, V_MONOSPACE | V_ALLOWLOWERCASE | V_BLUEMAP, s); + yoffset2 += 5; + } + snprintf(s, sizeof s - 1, "Dynamic slopes: %d", dynslopethcount); + V_DrawSmallString(119, 40+yoffset2, V_MONOSPACE | V_ALLOWLOWERCASE | V_BLUEMAP, s); + snprintf(s, sizeof s - 1, "Precipitation: %d", precipcount); + V_DrawSmallString(119, 45+yoffset2, V_MONOSPACE | V_ALLOWLOWERCASE | V_BLUEMAP, s); + snprintf(s, sizeof s - 1, "Pending removal: %d", removecount); + V_DrawSmallString(119, 50+yoffset2, V_MONOSPACE | V_ALLOWLOWERCASE | V_BLUEMAP, s); + + snprintf(s, sizeof s - 1, "Calls:"); + V_DrawSmallString(212, 10, V_MONOSPACE | V_ALLOWLOWERCASE | V_PURPLEMAP, s); + snprintf(s, sizeof s - 1, "Lua mobj hooks: %d", ps_lua_mobjhooks); + V_DrawSmallString(216, 15, V_MONOSPACE | V_ALLOWLOWERCASE | V_PURPLEMAP, s); + snprintf(s, sizeof s - 1, "P_CheckPosition: %d", ps_checkposition_calls); + V_DrawSmallString(216, 20, V_MONOSPACE | V_ALLOWLOWERCASE | V_PURPLEMAP, s); + } + } + else if (cv_perfstats.value == 3) // lua thinkframe + { + if (!(gamestate == GS_LEVEL || (gamestate == GS_TITLESCREEN && titlemapinaction))) + return; + if (vid.width < 640 || vid.height < 400) // low resolution + { + // it's not gonna fit very well.. + V_DrawThinString(30, 30, V_MONOSPACE | V_ALLOWLOWERCASE | V_YELLOWMAP, "Not available for resolutions below 640x400"); + } + else // high resolution + { + int i; + // text writing position + int x = 2; + int y = 4; + UINT32 text_color; + char tempbuffer[LUA_IDSIZE]; + char last_mod_name[LUA_IDSIZE]; + last_mod_name[0] = '\0'; + for (i = 0; i < thinkframe_hooks_length; i++) + { + char* str = thinkframe_hooks[i].short_src; + char* tempstr = tempbuffer; + int len = (int)strlen(str); + char* str_ptr; + if (strcmp(".lua", str + len - 4) == 0) + { + str[len-4] = '\0'; // remove .lua at end + len -= 4; + } + // we locate the wad/pk3 name in the string and compare it to + // what we found on the previous iteration. + // if the name has changed, print it out on the screen + strcpy(tempstr, str); + str_ptr = strrchr(tempstr, '|'); + if (str_ptr) + { + *str_ptr = '\0'; + str = str_ptr + 1; // this is the name of the hook without the mod file name + str_ptr = strrchr(tempstr, PATHSEP[0]); + if (str_ptr) + tempstr = str_ptr + 1; + // tempstr should now point to the mod name, (wad/pk3) possibly truncated + if (strcmp(tempstr, last_mod_name) != 0) + { + strcpy(last_mod_name, tempstr); + len = (int)strlen(tempstr); + if (len > 25) + tempstr += len - 25; + snprintf(s, sizeof s - 1, "%s", tempstr); + V_DrawSmallString(x, y, V_MONOSPACE | V_ALLOWLOWERCASE | V_GRAYMAP, s); + y += 4; // repeated code! + if (y > 192) + { + y = 4; + x += 106; + if (x > 214) + break; + } + } + text_color = V_YELLOWMAP; + } + else + { + // probably a standalone lua file + // cut off the folder if it's there + str_ptr = strrchr(tempstr, PATHSEP[0]); + if (str_ptr) + str = str_ptr + 1; + text_color = 0; // white + } + len = (int)strlen(str); + if (len > 20) + str += len - 20; + snprintf(s, sizeof s - 1, "%20s: %u", str, thinkframe_hooks[i].time_taken); + V_DrawSmallString(x, y, V_MONOSPACE | V_ALLOWLOWERCASE | text_color, s); + y += 4; // repeated code! + if (y > 192) + { + y = 4; + x += 106; + if (x > 214) + break; + } + } + } + } +} diff --git a/src/m_perfstats.h b/src/m_perfstats.h new file mode 100644 index 000000000..4fc45597d --- /dev/null +++ b/src/m_perfstats.h @@ -0,0 +1,42 @@ +// SONIC ROBO BLAST 2 +//----------------------------------------------------------------------------- +// Copyright (C) 1998-2000 by DooM Legacy Team. +// Copyright (C) 1999-2020 by Sonic Team Junior. +// +// This program is free software distributed under the +// terms of the GNU General Public License, version 2. +// See the 'LICENSE' file for more details. +//----------------------------------------------------------------------------- +/// \file m_perfstats.h +/// \brief Performance measurement tools. + +#ifndef __M_PERFSTATS_H__ +#define __M_PERFSTATS_H__ + +#include "doomdef.h" +#include "lua_script.h" +#include "p_local.h" + +extern int ps_tictime; + +extern int ps_playerthink_time; +extern int ps_thinkertime; + +extern int ps_thlist_times[]; + +extern int ps_checkposition_calls; + +extern int ps_lua_thinkframe_time; +extern int ps_lua_mobjhooks; + +typedef struct +{ + UINT32 time_taken; + char short_src[LUA_IDSIZE]; +} ps_hookinfo_t; + +void PS_SetThinkFrameHookInfo(int index, UINT32 time_taken, char* short_src); + +void M_DrawPerfStats(void); + +#endif \ No newline at end of file diff --git a/src/p_map.c b/src/p_map.c index 74c2790f7..ddf17a0d8 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -33,6 +33,8 @@ #include "lua_hook.h" +#include "m_perfstats.h" // ps_checkposition_calls + fixed_t tmbbox[4]; mobj_t *tmthing; static INT32 tmflags; @@ -2019,6 +2021,8 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) subsector_t *newsubsec; boolean blockval = true; + ps_checkposition_calls++; + I_Assert(thing != NULL); #ifdef PARANOIA if (P_MobjWasRemoved(thing)) diff --git a/src/p_tick.c b/src/p_tick.c index f84ae96c0..451e5e626 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -21,6 +21,8 @@ #include "m_random.h" #include "lua_script.h" #include "lua_hook.h" +#include "m_perfstats.h" +#include "i_system.h" // I_GetTimeMicros // Object place #include "m_cheat.h" @@ -321,6 +323,7 @@ static inline void P_RunThinkers(void) size_t i; for (i = 0; i < NUM_THINKERLISTS; i++) { + ps_thlist_times[i] = I_GetTimeMicros(); for (currentthinker = thlist[i].next; currentthinker != &thlist[i]; currentthinker = currentthinker->next) { #ifdef PARANOIA @@ -328,6 +331,7 @@ static inline void P_RunThinkers(void) #endif currentthinker->function.acp1(currentthinker); } + ps_thlist_times[i] = I_GetTimeMicros() - ps_thlist_times[i]; } } @@ -641,11 +645,16 @@ void P_Ticker(boolean run) if (demoplayback) G_ReadDemoTiccmd(&players[consoleplayer].cmd, 0); + ps_lua_mobjhooks = 0; + ps_checkposition_calls = 0; + LUAh_PreThinkFrame(); + ps_playerthink_time = I_GetTimeMicros(); for (i = 0; i < MAXPLAYERS; i++) if (playeringame[i] && players[i].mo && !P_MobjWasRemoved(players[i].mo)) P_PlayerThink(&players[i]); + ps_playerthink_time = I_GetTimeMicros() - ps_playerthink_time; } // Keep track of how long they've been playing! @@ -660,14 +669,18 @@ void P_Ticker(boolean run) if (run) { + ps_thinkertime = I_GetTimeMicros(); P_RunThinkers(); + ps_thinkertime = I_GetTimeMicros() - ps_thinkertime; // Run any "after all the other thinkers" stuff for (i = 0; i < MAXPLAYERS; i++) if (playeringame[i] && players[i].mo && !P_MobjWasRemoved(players[i].mo)) P_PlayerAfterThink(&players[i]); + ps_lua_thinkframe_time = I_GetTimeMicros(); LUAh_ThinkFrame(); + ps_lua_thinkframe_time = I_GetTimeMicros() - ps_lua_thinkframe_time; } // Run shield positioning diff --git a/src/r_bsp.c b/src/r_bsp.c index a430ef040..56d038b44 100644 --- a/src/r_bsp.c +++ b/src/r_bsp.c @@ -799,7 +799,7 @@ static void R_AddPolyObjects(subsector_t *sub) } // for render stats - rs_numpolyobjects += numpolys; + ps_numpolyobjects += numpolys; // sort polyobjects R_SortPolyObjects(sub); @@ -1239,7 +1239,7 @@ void R_RenderBSPNode(INT32 bspnum) node_t *bsp; INT32 side; - rs_numbspcalls++; + ps_numbspcalls++; while (!(bspnum & NF_SUBSECTOR)) // Found a subsector? { diff --git a/src/r_main.c b/src/r_main.c index 9613e2ac1..4138df5b6 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -100,22 +100,22 @@ lighttable_t *zlight[LIGHTLEVELS][MAXLIGHTZ]; extracolormap_t *extra_colormaps = NULL; // Render stats -int rs_prevframetime = 0; -int rs_rendercalltime = 0; -int rs_uitime = 0; -int rs_swaptime = 0; -int rs_tictime = 0; +int ps_prevframetime = 0; +int ps_rendercalltime = 0; +int ps_uitime = 0; +int ps_swaptime = 0; -int rs_bsptime = 0; +int ps_bsptime = 0; -int rs_sw_portaltime = 0; -int rs_sw_planetime = 0; -int rs_sw_maskedtime = 0; +int ps_sw_spritecliptime = 0; +int ps_sw_portaltime = 0; +int ps_sw_planetime = 0; +int ps_sw_maskedtime = 0; -int rs_numbspcalls = 0; -int rs_numsprites = 0; -int rs_numdrawnodes = 0; -int rs_numpolyobjects = 0; +int ps_numbspcalls = 0; +int ps_numsprites = 0; +int ps_numdrawnodes = 0; +int ps_numpolyobjects = 0; static CV_PossibleValue_t drawdist_cons_t[] = { {256, "256"}, {512, "512"}, {768, "768"}, @@ -1489,11 +1489,11 @@ void R_RenderPlayerView(player_t *player) mytotal = 0; ProfZeroTimer(); #endif - rs_numbspcalls = rs_numpolyobjects = rs_numdrawnodes = 0; - rs_bsptime = I_GetTimeMicros(); + ps_numbspcalls = ps_numpolyobjects = ps_numdrawnodes = 0; + ps_bsptime = I_GetTimeMicros(); R_RenderBSPNode((INT32)numnodes - 1); - rs_bsptime = I_GetTimeMicros() - rs_bsptime; - rs_numsprites = visspritecount; + ps_bsptime = I_GetTimeMicros() - ps_bsptime; + ps_numsprites = visspritecount; #ifdef TIMING RDMSR(0x10, &mycount); mytotal += mycount; // 64bit add @@ -1503,7 +1503,9 @@ void R_RenderPlayerView(player_t *player) //profile stuff --------------------------------------------------------- Mask_Post(&masks[nummasks - 1]); + ps_sw_spritecliptime = I_GetTimeMicros(); R_ClipSprites(drawsegs, NULL); + ps_sw_spritecliptime = I_GetTimeMicros() - ps_sw_spritecliptime; // Add skybox portals caused by sky visplanes. @@ -1511,7 +1513,7 @@ void R_RenderPlayerView(player_t *player) Portal_AddSkyboxPortals(); // Portal rendering. Hijacks the BSP traversal. - rs_sw_portaltime = I_GetTimeMicros(); + ps_sw_portaltime = I_GetTimeMicros(); if (portal_base) { portal_t *portal; @@ -1551,20 +1553,20 @@ void R_RenderPlayerView(player_t *player) Portal_Remove(portal); } } - rs_sw_portaltime = I_GetTimeMicros() - rs_sw_portaltime; + ps_sw_portaltime = I_GetTimeMicros() - ps_sw_portaltime; - rs_sw_planetime = I_GetTimeMicros(); + ps_sw_planetime = I_GetTimeMicros(); R_DrawPlanes(); #ifdef FLOORSPLATS R_DrawVisibleFloorSplats(); #endif - rs_sw_planetime = I_GetTimeMicros() - rs_sw_planetime; + ps_sw_planetime = I_GetTimeMicros() - ps_sw_planetime; // draw mid texture and sprite // And now 3D floors/sides! - rs_sw_maskedtime = I_GetTimeMicros(); + ps_sw_maskedtime = I_GetTimeMicros(); R_DrawMasked(masks, nummasks); - rs_sw_maskedtime = I_GetTimeMicros() - rs_sw_maskedtime; + ps_sw_maskedtime = I_GetTimeMicros() - ps_sw_maskedtime; free(masks); } diff --git a/src/r_main.h b/src/r_main.h index 89b359c55..383055f9a 100644 --- a/src/r_main.h +++ b/src/r_main.h @@ -78,24 +78,22 @@ boolean R_DoCulling(line_t *cullheight, line_t *viewcullheight, fixed_t vz, fixe // Render stats -extern consvar_t cv_renderstats; +extern int ps_prevframetime;// time when previous frame was rendered +extern int ps_rendercalltime; +extern int ps_uitime; +extern int ps_swaptime; -extern int rs_prevframetime;// time when previous frame was rendered -extern int rs_rendercalltime; -extern int rs_uitime; -extern int rs_swaptime; -extern int rs_tictime; +extern int ps_bsptime; -extern int rs_bsptime; +extern int ps_sw_spritecliptime; +extern int ps_sw_portaltime; +extern int ps_sw_planetime; +extern int ps_sw_maskedtime; -extern int rs_sw_portaltime; -extern int rs_sw_planetime; -extern int rs_sw_maskedtime; - -extern int rs_numbspcalls; -extern int rs_numsprites; -extern int rs_numdrawnodes; -extern int rs_numpolyobjects; +extern int ps_numbspcalls; +extern int ps_numsprites; +extern int ps_numdrawnodes; +extern int ps_numpolyobjects; // // REFRESH - the actual rendering functions. diff --git a/src/r_things.c b/src/r_things.c index 382eed560..cc205f9ea 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -2531,7 +2531,7 @@ static drawnode_t *R_CreateDrawNode(drawnode_t *link) node->ffloor = NULL; node->sprite = NULL; - rs_numdrawnodes++; + ps_numdrawnodes++; return node; } diff --git a/src/sdl/Srb2SDL-vc10.vcxproj b/src/sdl/Srb2SDL-vc10.vcxproj index 755fa68e6..ef1941c19 100644 --- a/src/sdl/Srb2SDL-vc10.vcxproj +++ b/src/sdl/Srb2SDL-vc10.vcxproj @@ -262,6 +262,7 @@ + @@ -417,6 +418,7 @@ + diff --git a/src/sdl/Srb2SDL-vc10.vcxproj.filters b/src/sdl/Srb2SDL-vc10.vcxproj.filters index 3bbcd9cb5..3b285b869 100644 --- a/src/sdl/Srb2SDL-vc10.vcxproj.filters +++ b/src/sdl/Srb2SDL-vc10.vcxproj.filters @@ -348,6 +348,9 @@ M_Misc + + M_Misc + M_Misc @@ -762,6 +765,9 @@ M_Misc + + M_Misc + M_Misc From 465693b2424e6cc703e6cfbd6bb3ab1e239b3170 Mon Sep 17 00:00:00 2001 From: Hannu Hanhi Date: Sat, 10 Oct 2020 22:23:33 +0300 Subject: [PATCH 0150/1080] Put newline to end of m_perfstats.h --- src/m_perfstats.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/m_perfstats.h b/src/m_perfstats.h index 4fc45597d..1db46025e 100644 --- a/src/m_perfstats.h +++ b/src/m_perfstats.h @@ -39,4 +39,4 @@ void PS_SetThinkFrameHookInfo(int index, UINT32 time_taken, char* short_src); void M_DrawPerfStats(void); -#endif \ No newline at end of file +#endif From 6e5f71dd45dc27d567bc3a6aae1e83fbb00bb387 Mon Sep 17 00:00:00 2001 From: Jaime Passos Date: Sat, 10 Oct 2020 18:43:26 -0300 Subject: [PATCH 0151/1080] Refactor patch rotation --- src/CMakeLists.txt | 1 + src/Makefile | 1 + src/hardware/hw_main.c | 16 +- src/lua_hudlib.c | 10 +- src/p_setup.c | 4 +- src/r_defs.h | 22 ++- src/r_patch.c | 21 ++- src/r_patch.h | 8 + src/r_patchrotation.c | 248 +++++++++++++++++++++++++ src/r_picformats.c | 194 +------------------ src/r_picformats.h | 8 - src/r_things.c | 19 +- src/sdl/Srb2SDL-vc10.vcxproj | 4 + src/sdl/Srb2SDL-vc10.vcxproj.filters | 16 +- src/win32/Srb2win-vc10.vcxproj | 4 + src/win32/Srb2win-vc10.vcxproj.filters | 17 +- src/z_zone.c | 26 +-- src/z_zone.h | 7 +- 18 files changed, 371 insertions(+), 255 deletions(-) create mode 100644 src/r_patchrotation.c diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ba574f414..9c2326399 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -129,6 +129,7 @@ set(SRB2_CORE_RENDER_SOURCES r_things.c r_textures.c r_patch.c + r_patchrotation.c r_picformats.c r_portal.c diff --git a/src/Makefile b/src/Makefile index f50840920..bdbb35363 100644 --- a/src/Makefile +++ b/src/Makefile @@ -519,6 +519,7 @@ OBJS:=$(i_main_o) \ $(OBJDIR)/r_things.o \ $(OBJDIR)/r_textures.o \ $(OBJDIR)/r_patch.o \ + $(OBJDIR)/r_patchrotation.o \ $(OBJDIR)/r_picformats.o \ $(OBJDIR)/r_portal.o \ $(OBJDIR)/screen.o \ diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index e60645eb6..fe0aa2f35 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -4754,7 +4754,9 @@ static void HWR_ProjectSprite(mobj_t *thing) float gz, gzt; spritedef_t *sprdef; spriteframe_t *sprframe; +#ifdef ROTSPRITE spriteinfo_t *sprinfo; +#endif md2_t *md2; size_t lumpoff; unsigned rot; @@ -4824,12 +4826,16 @@ static void HWR_ProjectSprite(mobj_t *thing) if (thing->skin && thing->sprite == SPR_PLAY) { sprdef = &((skin_t *)thing->skin)->sprites[thing->sprite2]; +#ifdef ROTSPRITE sprinfo = &((skin_t *)thing->skin)->sprinfo[thing->sprite2]; +#endif } else { sprdef = &sprites[thing->sprite]; - sprinfo = NULL; +#ifdef ROTSPRITE + sprinfo = &spriteinfo[thing->sprite]; +#endif } if (rot >= sprdef->numframes) @@ -4839,7 +4845,9 @@ static void HWR_ProjectSprite(mobj_t *thing) thing->sprite = states[S_UNKNOWN].sprite; thing->frame = states[S_UNKNOWN].frame; sprdef = &sprites[thing->sprite]; - sprinfo = NULL; +#ifdef ROTSPRITE + sprinfo = &spriteinfo[thing->sprite]; +#endif rot = thing->frame&FF_FRAMEMASK; thing->state->sprite = thing->sprite; thing->state->frame = thing->frame; @@ -4901,9 +4909,7 @@ static void HWR_ProjectSprite(mobj_t *thing) if (thing->rollangle) { rollangle = R_GetRollAngle(thing->rollangle); - if (sprframe->rotsprite.patch[rot][rollangle] == NULL) - R_CacheRotSprite(thing->sprite, (thing->frame & FF_FRAMEMASK), sprinfo, sprframe, rot, rollangle, flip); - rotsprite = sprframe->rotsprite.patch[rot][rollangle]; + rotsprite = Patch_GetRotatedSprite(sprframe, (thing->frame & FF_FRAMEMASK), rot, flip, sprinfo, rollangle); if (rotsprite != NULL) { spr_width = SHORT(rotsprite->width) << FRACBITS; diff --git a/src/lua_hudlib.c b/src/lua_hudlib.c index ba3342b44..335e6cfbc 100644 --- a/src/lua_hudlib.c +++ b/src/lua_hudlib.c @@ -458,9 +458,8 @@ static int libd_getSpritePatch(lua_State *L) INT32 rot = R_GetRollAngle(rollangle); if (rot) { - if (sprframe->rotsprite.patch[angle][rot] == NULL) - R_CacheRotSprite(i, frame, NULL, sprframe, angle, rot, sprframe->flip & (1<rotsprite.patch[angle][rot], META_PATCH); + patch_t *rotsprite = Patch_GetRotatedSprite(sprframe, frame, angle, sprframe->flip & (1<rotsprite.patch[angle][rot] == NULL) - R_CacheRotSprite(SPR_PLAY, frame, &skins[i].sprinfo[j], sprframe, angle, rot, sprframe->flip & (1<rotsprite.patch[angle][rot], META_PATCH); + patch_t *rotsprite = Patch_GetRotatedSprite(sprframe, frame, angle, sprframe->flip & (1<height = source->height; patch->leftoffset = source->leftoffset; patch->topoffset = source->topoffset; - patch->columnofs = Z_Calloc(size, PU_PATCH, NULL); + patch->columnofs = Z_Calloc(size, PU_PATCH_DATA, NULL); for (col = 0; col < source->width; col++) { @@ -53,7 +53,7 @@ patch_t *Patch_Create(softwarepatch_t *source, size_t srcsize, void *dest) if (colsize <= 0) I_Error("R_CreatePatch: no column data!"); - patch->columns = Z_Calloc(colsize, PU_PATCH, NULL); + patch->columns = Z_Calloc(colsize, PU_PATCH_DATA, NULL); M_Memcpy(patch->columns, ((UINT8 *)source + LONG(source->columnofs[0])), colsize); } @@ -71,6 +71,23 @@ static void Patch_FreeData(patch_t *patch) HWR_FreeTexture(patch); #endif +#ifdef ROTSPRITE + if (patch->rotated) + { + rotsprite_t *rotsprite = patch->rotated; + INT32 i = 0; + + for (; i < rotsprite->angles; i++) + { + if (rotsprite->patches[i]) + Patch_Free(rotsprite->patches[i]); + } + + Z_Free(rotsprite->patches); + Z_Free(rotsprite); + } +#endif + if (patch->columnofs) Z_Free(patch->columnofs); if (patch->columns) diff --git a/src/r_patch.h b/src/r_patch.h index c460e7d09..71f185c9d 100644 --- a/src/r_patch.h +++ b/src/r_patch.h @@ -27,4 +27,12 @@ void *Patch_AllocateHardwarePatch(patch_t *patch); void *Patch_CreateGL(patch_t *patch); #endif +#ifdef ROTSPRITE +void Patch_Rotate(patch_t *patch, INT32 angle, INT32 xpivot, INT32 ypivot, boolean flip); +patch_t *Patch_GetRotated(patch_t *patch, INT32 angle, boolean flip); +patch_t *Patch_GetRotatedSprite(spriteframe_t *sprite, size_t frame, size_t spriteangle, boolean flip, void *info, INT32 rotationangle);INT32 R_GetRollAngle(angle_t rollangle); +extern fixed_t rollcosang[ROTANGLES]; +extern fixed_t rollsinang[ROTANGLES]; +#endif + #endif // __R_PATCH__ diff --git a/src/r_patchrotation.c b/src/r_patchrotation.c new file mode 100644 index 000000000..77544c3ac --- /dev/null +++ b/src/r_patchrotation.c @@ -0,0 +1,248 @@ +// SONIC ROBO BLAST 2 +//----------------------------------------------------------------------------- +// Copyright (C) 2018-2020 by Jaime "Lactozilla" Passos. +// +// This program is free software distributed under the +// terms of the GNU General Public License, version 2. +// See the 'LICENSE' file for more details. +//----------------------------------------------------------------------------- +/// \file r_patchrotation.c +/// \brief Patch rotation. + +#include "r_patch.h" +#include "r_picformats.h" +#include "r_things.h" // FEETADJUST +#include "z_zone.h" +#include "w_wad.h" + +#ifdef ROTSPRITE + +static rotsprite_t *RotatedPatch_Create(INT32 numangles); +static void RotatedPatch_DoRotation(rotsprite_t *rotsprite, patch_t *patch, INT32 angle, INT32 xpivot, INT32 ypivot, boolean flip); + +fixed_t rollcosang[ROTANGLES]; +fixed_t rollsinang[ROTANGLES]; + +INT32 R_GetRollAngle(angle_t rollangle) +{ + INT32 ra = AngleFixed(rollangle)>>FRACBITS; +#if (ROTANGDIFF > 1) + ra += (ROTANGDIFF/2); +#endif + ra /= ROTANGDIFF; + ra %= ROTANGLES; + return ra; +} + +patch_t *Patch_GetRotated(patch_t *patch, INT32 angle, boolean flip) +{ + rotsprite_t *rotsprite = patch->rotated; + if (rotsprite == NULL || angle < 1 || angle >= ROTANGLES) + return NULL; + + if (flip) + angle += rotsprite->angles; + + return rotsprite->patches[angle]; +} + +patch_t *Patch_GetRotatedSprite(spriteframe_t *sprite, size_t frame, size_t spriteangle, boolean flip, void *info, INT32 rotationangle) +{ + rotsprite_t *rotsprite = sprite->rotated[spriteangle]; + spriteinfo_t *sprinfo = (spriteinfo_t *)info; + INT32 idx = rotationangle; + + if (rotationangle < 1 || rotationangle >= ROTANGLES) + return NULL; + + if (rotsprite == NULL) + { + rotsprite = RotatedPatch_Create(ROTANGLES); + sprite->rotated[spriteangle] = rotsprite; + } + + if (flip) + idx += rotsprite->angles; + + if (rotsprite->patches[idx] == NULL) + { + patch_t *patch; + INT32 xpivot = 0, ypivot = 0; + lumpnum_t lump = sprite->lumppat[spriteangle]; + + if (lump == LUMPERROR) + return NULL; + + patch = W_CachePatchNum(lump, PU_SPRITE); + + if (sprinfo->available) + { + xpivot = sprinfo->pivot[frame].x; + ypivot = sprinfo->pivot[frame].y; + } + else + { + xpivot = patch->leftoffset; + ypivot = patch->height / 2; + } + + RotatedPatch_DoRotation(rotsprite, patch, rotationangle, xpivot, ypivot, flip); + } + + return rotsprite->patches[idx]; +} + +void Patch_Rotate(patch_t *patch, INT32 angle, INT32 xpivot, INT32 ypivot, boolean flip) +{ + if (patch->rotated == NULL) + patch->rotated = RotatedPatch_Create(ROTANGLES); + RotatedPatch_DoRotation(patch->rotated, patch, angle, xpivot, ypivot, flip); +} + +rotsprite_t *RotatedPatch_Create(INT32 numangles) +{ + rotsprite_t *rotsprite = Z_Calloc(sizeof(rotsprite_t), PU_STATIC, NULL); + rotsprite->angles = numangles; + rotsprite->patches = Z_Calloc(rotsprite->angles * 2 * sizeof(void *), PU_STATIC, NULL); + return rotsprite; +} + +void RotatedPatch_DoRotation(rotsprite_t *rotsprite, patch_t *patch, INT32 angle, INT32 xpivot, INT32 ypivot, boolean flip) +{ + patch_t *rotated; + UINT16 *rawdst; + size_t size; + pictureflags_t bflip = (flip) ? PICFLAGS_XFLIP : 0; + + INT32 width = patch->width; + INT32 height = patch->height; + INT32 leftoffset = patch->leftoffset; + INT32 newwidth, newheight; + + INT32 dx, dy; + fixed_t ca = rollcosang[angle]; + fixed_t sa = rollsinang[angle]; + INT32 idx = angle; + + // Don't cache angle = 0 + if (angle < 1 || angle >= ROTANGLES) + return; + +#define ROTSPRITE_XCENTER (newwidth / 2) +#define ROTSPRITE_YCENTER (newheight / 2) + + if (flip) + idx += rotsprite->angles; + + if (rotsprite->patches[idx]) + return; + + if (bflip) + { + xpivot = width - xpivot; + leftoffset = width - leftoffset; + } + + // Find the dimensions of the rotated patch. + { + INT32 w1 = abs(FixedMul(width << FRACBITS, ca) - FixedMul(height << FRACBITS, sa)); + INT32 w2 = abs(FixedMul(-(width << FRACBITS), ca) - FixedMul(height << FRACBITS, sa)); + INT32 h1 = abs(FixedMul(width << FRACBITS, sa) + FixedMul(height << FRACBITS, ca)); + INT32 h2 = abs(FixedMul(-(width << FRACBITS), sa) + FixedMul(height << FRACBITS, ca)); + w1 = FixedInt(FixedCeil(w1 + (FRACUNIT/2))); + w2 = FixedInt(FixedCeil(w2 + (FRACUNIT/2))); + h1 = FixedInt(FixedCeil(h1 + (FRACUNIT/2))); + h2 = FixedInt(FixedCeil(h2 + (FRACUNIT/2))); + newwidth = max(width, max(w1, w2)); + newheight = max(height, max(h1, h2)); + } + + // check boundaries + { + fixed_t top[2][2]; + fixed_t bottom[2][2]; + + top[0][0] = FixedMul((-ROTSPRITE_XCENTER) << FRACBITS, ca) + FixedMul((-ROTSPRITE_YCENTER) << FRACBITS, sa) + (xpivot << FRACBITS); + top[0][1] = FixedMul((-ROTSPRITE_XCENTER) << FRACBITS, sa) + FixedMul((-ROTSPRITE_YCENTER) << FRACBITS, ca) + (ypivot << FRACBITS); + top[1][0] = FixedMul((newwidth-ROTSPRITE_XCENTER) << FRACBITS, ca) + FixedMul((-ROTSPRITE_YCENTER) << FRACBITS, sa) + (xpivot << FRACBITS); + top[1][1] = FixedMul((newwidth-ROTSPRITE_XCENTER) << FRACBITS, sa) + FixedMul((-ROTSPRITE_YCENTER) << FRACBITS, ca) + (ypivot << FRACBITS); + + bottom[0][0] = FixedMul((-ROTSPRITE_XCENTER) << FRACBITS, ca) + FixedMul((newheight-ROTSPRITE_YCENTER) << FRACBITS, sa) + (xpivot << FRACBITS); + bottom[0][1] = -FixedMul((-ROTSPRITE_XCENTER) << FRACBITS, sa) + FixedMul((newheight-ROTSPRITE_YCENTER) << FRACBITS, ca) + (ypivot << FRACBITS); + bottom[1][0] = FixedMul((newwidth-ROTSPRITE_XCENTER) << FRACBITS, ca) + FixedMul((newheight-ROTSPRITE_YCENTER) << FRACBITS, sa) + (xpivot << FRACBITS); + bottom[1][1] = -FixedMul((newwidth-ROTSPRITE_XCENTER) << FRACBITS, sa) + FixedMul((newheight-ROTSPRITE_YCENTER) << FRACBITS, ca) + (ypivot << FRACBITS); + + top[0][0] >>= FRACBITS; + top[0][1] >>= FRACBITS; + top[1][0] >>= FRACBITS; + top[1][1] >>= FRACBITS; + + bottom[0][0] >>= FRACBITS; + bottom[0][1] >>= FRACBITS; + bottom[1][0] >>= FRACBITS; + bottom[1][1] >>= FRACBITS; + +#define BOUNDARYWCHECK(b) (b[0] < 0 || b[0] >= width) +#define BOUNDARYHCHECK(b) (b[1] < 0 || b[1] >= height) +#define BOUNDARYADJUST(x) x *= 2 + // top left/right + if (BOUNDARYWCHECK(top[0]) || BOUNDARYWCHECK(top[1])) + BOUNDARYADJUST(newwidth); + // bottom left/right + else if (BOUNDARYWCHECK(bottom[0]) || BOUNDARYWCHECK(bottom[1])) + BOUNDARYADJUST(newwidth); + // top left/right + if (BOUNDARYHCHECK(top[0]) || BOUNDARYHCHECK(top[1])) + BOUNDARYADJUST(newheight); + // bottom left/right + else if (BOUNDARYHCHECK(bottom[0]) || BOUNDARYHCHECK(bottom[1])) + BOUNDARYADJUST(newheight); +#undef BOUNDARYWCHECK +#undef BOUNDARYHCHECK +#undef BOUNDARYADJUST + } + + // Draw the rotated sprite to a temporary buffer. + size = (newwidth * newheight); + if (!size) + size = (width * height); + rawdst = Z_Calloc(size * sizeof(UINT16), PU_STATIC, NULL); + + for (dy = 0; dy < newheight; dy++) + { + for (dx = 0; dx < newwidth; dx++) + { + INT32 x = (dx-ROTSPRITE_XCENTER) << FRACBITS; + INT32 y = (dy-ROTSPRITE_YCENTER) << FRACBITS; + INT32 sx = FixedMul(x, ca) + FixedMul(y, sa) + (xpivot << FRACBITS); + INT32 sy = -FixedMul(x, sa) + FixedMul(y, ca) + (ypivot << FRACBITS); + sx >>= FRACBITS; + sy >>= FRACBITS; + if (sx >= 0 && sy >= 0 && sx < width && sy < height) + { + void *input = Picture_GetPatchPixel(patch, PICFMT_PATCH, sx, sy, bflip); + if (input != NULL) + rawdst[(dy*newwidth)+dx] = (0xFF00 | (*(UINT8 *)input)); + } + } + } + + // make patch + rotated = (patch_t *)Picture_Convert(PICFMT_FLAT16, rawdst, PICFMT_PATCH, 0, &size, newwidth, newheight, 0, 0, 0); + + Z_ChangeTag(rotated, PU_PATCH_ROTATED); + Z_SetUser(rotated, (void **)(&rotsprite->patches[angle])); + + rotated->leftoffset = (rotated->width / 2) + (leftoffset - xpivot); + rotated->topoffset = (rotated->height / 2) + (patch->topoffset - ypivot); + + //BP: we cannot use special tric in hardware mode because feet in ground caused by z-buffer + rotated->topoffset += FEETADJUST>>FRACBITS; + + // free rotated image data + Z_Free(rawdst); + +#undef ROTSPRITE_XCENTER +#undef ROTSPRITE_YCENTER +} +#endif diff --git a/src/r_picformats.c b/src/r_picformats.c index 7b44d21f1..8ec78663e 100644 --- a/src/r_picformats.c +++ b/src/r_picformats.c @@ -17,11 +17,10 @@ #include "i_video.h" #include "r_data.h" #include "r_patch.h" -#include "r_textures.h" -#include "r_draw.h" -#include "r_patch.h" #include "r_picformats.h" +#include "r_textures.h" #include "r_things.h" +#include "r_draw.h" #include "v_video.h" #include "z_zone.h" #include "w_wad.h" @@ -1672,192 +1671,3 @@ void R_LoadSpriteInfoLumps(UINT16 wadnum, UINT16 numlumps) R_ParseSPRTINFOLump(wadnum, i); } } - -#ifdef ROTSPRITE -// -// R_GetRollAngle -// -// Angles precalculated in R_InitSprites. -// -fixed_t rollcosang[ROTANGLES]; -fixed_t rollsinang[ROTANGLES]; -INT32 R_GetRollAngle(angle_t rollangle) -{ - INT32 ra = AngleFixed(rollangle)>>FRACBITS; -#if (ROTANGDIFF > 1) - ra += (ROTANGDIFF/2); -#endif - ra /= ROTANGDIFF; - ra %= ROTANGLES; - return ra; -} - -// -// R_CacheRotSprite -// -// Create a rotated sprite. -// -void R_CacheRotSprite(spritenum_t sprnum, UINT8 frame, spriteinfo_t *sprinfo, spriteframe_t *sprframe, INT32 rot, INT32 angle, UINT8 flip) -{ - patch_t *patch, *newpatch; - UINT16 *rawdst; - size_t size; - pictureflags_t bflip = (flip) ? PICFLAGS_XFLIP : 0; - - // Don't cache angle = 0 - if (angle < 1 || angle >= ROTANGLES) - return; - -#define SPRITE_XCENTER (leftoffset) -#define SPRITE_YCENTER (height / 2) -#define ROTSPRITE_XCENTER (newwidth / 2) -#define ROTSPRITE_YCENTER (newheight / 2) - - if (sprframe->rotsprite.patch[rot][angle] == NULL) - { - INT32 dx, dy; - INT32 px, py; - INT32 width, height, leftoffset; - INT32 newwidth, newheight; - fixed_t ca, sa; - lumpnum_t lump = sprframe->lumppat[rot]; - - if (lump == LUMPERROR) - return; - - patch = (patch_t *)W_CachePatchNum(lump, PU_STATIC); - width = patch->width; - height = patch->height; - leftoffset = patch->leftoffset; - - // rotation pivot - px = SPRITE_XCENTER; - py = SPRITE_YCENTER; - - // get correct sprite info for sprite - if (sprinfo == NULL) - sprinfo = &spriteinfo[sprnum]; - if (sprinfo->available) - { - px = sprinfo->pivot[frame].x; - py = sprinfo->pivot[frame].y; - } - if (bflip) - { - px = width - px; - leftoffset = width - leftoffset; - } - - ca = rollcosang[angle]; - sa = rollsinang[angle]; - - // Find the dimensions of the rotated patch. - { - INT32 w1 = abs(FixedMul(width << FRACBITS, ca) - FixedMul(height << FRACBITS, sa)); - INT32 w2 = abs(FixedMul(-(width << FRACBITS), ca) - FixedMul(height << FRACBITS, sa)); - INT32 h1 = abs(FixedMul(width << FRACBITS, sa) + FixedMul(height << FRACBITS, ca)); - INT32 h2 = abs(FixedMul(-(width << FRACBITS), sa) + FixedMul(height << FRACBITS, ca)); - w1 = FixedInt(FixedCeil(w1 + (FRACUNIT/2))); - w2 = FixedInt(FixedCeil(w2 + (FRACUNIT/2))); - h1 = FixedInt(FixedCeil(h1 + (FRACUNIT/2))); - h2 = FixedInt(FixedCeil(h2 + (FRACUNIT/2))); - newwidth = max(width, max(w1, w2)); - newheight = max(height, max(h1, h2)); - } - - // check boundaries - { - fixed_t top[2][2]; - fixed_t bottom[2][2]; - - top[0][0] = FixedMul((-ROTSPRITE_XCENTER) << FRACBITS, ca) + FixedMul((-ROTSPRITE_YCENTER) << FRACBITS, sa) + (px << FRACBITS); - top[0][1] = FixedMul((-ROTSPRITE_XCENTER) << FRACBITS, sa) + FixedMul((-ROTSPRITE_YCENTER) << FRACBITS, ca) + (py << FRACBITS); - top[1][0] = FixedMul((newwidth-ROTSPRITE_XCENTER) << FRACBITS, ca) + FixedMul((-ROTSPRITE_YCENTER) << FRACBITS, sa) + (px << FRACBITS); - top[1][1] = FixedMul((newwidth-ROTSPRITE_XCENTER) << FRACBITS, sa) + FixedMul((-ROTSPRITE_YCENTER) << FRACBITS, ca) + (py << FRACBITS); - - bottom[0][0] = FixedMul((-ROTSPRITE_XCENTER) << FRACBITS, ca) + FixedMul((newheight-ROTSPRITE_YCENTER) << FRACBITS, sa) + (px << FRACBITS); - bottom[0][1] = -FixedMul((-ROTSPRITE_XCENTER) << FRACBITS, sa) + FixedMul((newheight-ROTSPRITE_YCENTER) << FRACBITS, ca) + (py << FRACBITS); - bottom[1][0] = FixedMul((newwidth-ROTSPRITE_XCENTER) << FRACBITS, ca) + FixedMul((newheight-ROTSPRITE_YCENTER) << FRACBITS, sa) + (px << FRACBITS); - bottom[1][1] = -FixedMul((newwidth-ROTSPRITE_XCENTER) << FRACBITS, sa) + FixedMul((newheight-ROTSPRITE_YCENTER) << FRACBITS, ca) + (py << FRACBITS); - - top[0][0] >>= FRACBITS; - top[0][1] >>= FRACBITS; - top[1][0] >>= FRACBITS; - top[1][1] >>= FRACBITS; - - bottom[0][0] >>= FRACBITS; - bottom[0][1] >>= FRACBITS; - bottom[1][0] >>= FRACBITS; - bottom[1][1] >>= FRACBITS; - -#define BOUNDARYWCHECK(b) (b[0] < 0 || b[0] >= width) -#define BOUNDARYHCHECK(b) (b[1] < 0 || b[1] >= height) -#define BOUNDARYADJUST(x) x *= 2 - // top left/right - if (BOUNDARYWCHECK(top[0]) || BOUNDARYWCHECK(top[1])) - BOUNDARYADJUST(newwidth); - // bottom left/right - else if (BOUNDARYWCHECK(bottom[0]) || BOUNDARYWCHECK(bottom[1])) - BOUNDARYADJUST(newwidth); - // top left/right - if (BOUNDARYHCHECK(top[0]) || BOUNDARYHCHECK(top[1])) - BOUNDARYADJUST(newheight); - // bottom left/right - else if (BOUNDARYHCHECK(bottom[0]) || BOUNDARYHCHECK(bottom[1])) - BOUNDARYADJUST(newheight); -#undef BOUNDARYWCHECK -#undef BOUNDARYHCHECK -#undef BOUNDARYADJUST - } - - // Draw the rotated sprite to a temporary buffer. - size = (newwidth * newheight); - if (!size) - size = (width * height); - rawdst = Z_Calloc(size * sizeof(UINT16), PU_STATIC, NULL); - - for (dy = 0; dy < newheight; dy++) - { - for (dx = 0; dx < newwidth; dx++) - { - INT32 x = (dx-ROTSPRITE_XCENTER) << FRACBITS; - INT32 y = (dy-ROTSPRITE_YCENTER) << FRACBITS; - INT32 sx = FixedMul(x, ca) + FixedMul(y, sa) + (px << FRACBITS); - INT32 sy = -FixedMul(x, sa) + FixedMul(y, ca) + (py << FRACBITS); - sx >>= FRACBITS; - sy >>= FRACBITS; - if (sx >= 0 && sy >= 0 && sx < width && sy < height) - { - void *input = Picture_GetPatchPixel(patch, PICFMT_PATCH, sx, sy, bflip); - if (input != NULL) - rawdst[(dy*newwidth)+dx] = (0xFF00 | (*(UINT8 *)input)); - } - } - } - - // make patch - newpatch = (patch_t *)Picture_Convert(PICFMT_FLAT16, rawdst, PICFMT_PATCH, 0, &size, newwidth, newheight, 0, 0, 0); - Z_ChangeTag(newpatch, PU_SPRITE_ROTATED); - { - newpatch->leftoffset = (newpatch->width / 2) + (leftoffset - px); - newpatch->topoffset = (newpatch->height / 2) + (patch->topoffset - py); - } - - //BP: we cannot use special tric in hardware mode because feet in ground caused by z-buffer - if (rendermode != render_none) // not for psprite - newpatch->topoffset += FEETADJUST>>FRACBITS; - - // P_PrecacheLevel - if (devparm) spritememory += size; - - Z_SetUser(newpatch, &sprframe->rotsprite.patch[rot][angle]); - - // free rotated image data - Z_Free(rawdst); - } -#undef SPRITE_XCENTER -#undef SPRITE_YCENTER -#undef ROTSPRITE_XCENTER -#undef ROTSPRITE_YCENTER -} -#endif diff --git a/src/r_picformats.h b/src/r_picformats.h index e6c4aa17a..8d3999013 100644 --- a/src/r_picformats.h +++ b/src/r_picformats.h @@ -125,12 +125,4 @@ extern spriteinfo_t spriteinfo[NUMSPRITES]; void R_LoadSpriteInfoLumps(UINT16 wadnum, UINT16 numlumps); void R_ParseSPRTINFOLump(UINT16 wadNum, UINT16 lumpNum); -// Sprite rotation -#ifdef ROTSPRITE -INT32 R_GetRollAngle(angle_t rollangle); -void R_CacheRotSprite(spritenum_t sprnum, UINT8 frame, spriteinfo_t *sprinfo, spriteframe_t *sprframe, INT32 rot, INT32 angle, UINT8 flip); -extern fixed_t rollcosang[ROTANGLES]; -extern fixed_t rollsinang[ROTANGLES]; -#endif - #endif // __R_PICFORMATS__ diff --git a/src/r_things.c b/src/r_things.c index a9a5c42fc..b7d7302f8 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -97,7 +97,7 @@ static void R_InstallSpriteLump(UINT16 wad, // graphics patch { char cn = R_Frame2Char(frame), cr = R_Rotation2Char(rotation); // for debugging - INT32 r, ang; + INT32 r; lumpnum_t lumppat = wad; lumppat <<= 16; lumppat += lump; @@ -105,14 +105,10 @@ static void R_InstallSpriteLump(UINT16 wad, // graphics patch if (maxframe ==(size_t)-1 || frame > maxframe) maxframe = frame; - // rotsprite #ifdef ROTSPRITE for (r = 0; r < 16; r++) - { - for (ang = 0; ang < ROTANGLES; ang++) - sprtemp[frame].rotsprite.patch[r][ang] = NULL; - } -#endif/*ROTSPRITE*/ + sprtemp[frame].rotated[r] = NULL; +#endif if (rotation == 0) { @@ -1454,7 +1450,7 @@ static void R_ProjectSprite(mobj_t *thing) thing->frame = states[S_UNKNOWN].frame; sprdef = &sprites[thing->sprite]; #ifdef ROTSPRITE - sprinfo = NULL; + sprinfo = &spriteinfo[thing->sprite]; #endif frame = thing->frame&FF_FRAMEMASK; } @@ -1463,7 +1459,7 @@ static void R_ProjectSprite(mobj_t *thing) { sprdef = &sprites[thing->sprite]; #ifdef ROTSPRITE - sprinfo = NULL; + sprinfo = &spriteinfo[thing->sprite]; #endif if (frame >= sprdef->numframes) @@ -1478,6 +1474,7 @@ static void R_ProjectSprite(mobj_t *thing) thing->sprite = states[S_UNKNOWN].sprite; thing->frame = states[S_UNKNOWN].frame; sprdef = &sprites[thing->sprite]; + sprinfo = &spriteinfo[thing->sprite]; frame = thing->frame&FF_FRAMEMASK; } } @@ -1539,9 +1536,7 @@ static void R_ProjectSprite(mobj_t *thing) if (thing->rollangle) { rollangle = R_GetRollAngle(thing->rollangle); - if (sprframe->rotsprite.patch[rot][rollangle] == NULL) - R_CacheRotSprite(thing->sprite, frame, sprinfo, sprframe, rot, rollangle, flip); - rotsprite = sprframe->rotsprite.patch[rot][rollangle]; + rotsprite = Patch_GetRotatedSprite(sprframe, (thing->frame & FF_FRAMEMASK), rot, flip, sprinfo, rollangle); if (rotsprite != NULL) { spr_width = SHORT(rotsprite->width) << FRACBITS; diff --git a/src/sdl/Srb2SDL-vc10.vcxproj b/src/sdl/Srb2SDL-vc10.vcxproj index 755fa68e6..b66cea963 100644 --- a/src/sdl/Srb2SDL-vc10.vcxproj +++ b/src/sdl/Srb2SDL-vc10.vcxproj @@ -282,6 +282,8 @@ + + @@ -449,6 +451,8 @@ true + + diff --git a/src/sdl/Srb2SDL-vc10.vcxproj.filters b/src/sdl/Srb2SDL-vc10.vcxproj.filters index 3bbcd9cb5..3291db6c9 100644 --- a/src/sdl/Srb2SDL-vc10.vcxproj.filters +++ b/src/sdl/Srb2SDL-vc10.vcxproj.filters @@ -474,12 +474,18 @@ Hw_Hardware - + + R_Rend + + R_Rend R_Rend + + R_Rend + R_Rend @@ -952,12 +958,18 @@ Hw_Hardware - + + R_Rend + + R_Rend R_Rend + + R_Rend + R_Rend diff --git a/src/win32/Srb2win-vc10.vcxproj b/src/win32/Srb2win-vc10.vcxproj index 52617037b..3e8af3b0e 100644 --- a/src/win32/Srb2win-vc10.vcxproj +++ b/src/win32/Srb2win-vc10.vcxproj @@ -298,6 +298,8 @@ true + + @@ -454,6 +456,8 @@ + + diff --git a/src/win32/Srb2win-vc10.vcxproj.filters b/src/win32/Srb2win-vc10.vcxproj.filters index 0689a4ac0..7279368f1 100644 --- a/src/win32/Srb2win-vc10.vcxproj.filters +++ b/src/win32/Srb2win-vc10.vcxproj.filters @@ -469,9 +469,18 @@ Hw_Hardware + + R_Rend + + + R_Rend + R_Rend + + R_Rend + R_Rend @@ -886,12 +895,18 @@ Hw_Hardware - + + R_Rend + + R_Rend R_Rend + + R_Rend + R_Rend diff --git a/src/z_zone.c b/src/z_zone.c index b704e1a30..ad64a3a07 100644 --- a/src/z_zone.c +++ b/src/z_zone.c @@ -795,19 +795,19 @@ static void Command_Memfree_f(void) Z_CheckHeap(-1); CONS_Printf("\x82%s", M_GetText("Memory Info\n")); - CONS_Printf(M_GetText("Total heap used : %7s KB\n"), sizeu1(Z_TotalUsage()>>10)); - CONS_Printf(M_GetText("Static : %7s KB\n"), sizeu1(Z_TagUsage(PU_STATIC)>>10)); - CONS_Printf(M_GetText("Static (sound) : %7s KB\n"), sizeu1(Z_TagUsage(PU_SOUND)>>10)); - CONS_Printf(M_GetText("Static (music) : %7s KB\n"), sizeu1(Z_TagUsage(PU_MUSIC)>>10)); - CONS_Printf(M_GetText("Patches : %7s KB\n"), sizeu1(Z_TagUsage(PU_PATCH)>>10)); - CONS_Printf(M_GetText("Patches (low) : %7s KB\n"), sizeu1(Z_TagUsage(PU_PATCH_LOWPRIORITY)>>10)); - CONS_Printf(M_GetText("Sprites : %7s KB\n"), sizeu1(Z_TagUsage(PU_SPRITE)>>10)); - CONS_Printf(M_GetText("Sprites (rotated) : %7s KB\n"), sizeu1(Z_TagUsage(PU_SPRITE_ROTATED)>>10)); - 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("Special thinker : %7s KB\n"), sizeu1(Z_TagUsage(PU_LEVSPEC)>>10)); - CONS_Printf(M_GetText("All purgable : %7s KB\n"), + CONS_Printf(M_GetText("Total heap used : %7s KB\n"), sizeu1(Z_TotalUsage()>>10)); + CONS_Printf(M_GetText("Static : %7s KB\n"), sizeu1(Z_TagUsage(PU_STATIC)>>10)); + CONS_Printf(M_GetText("Static (sound) : %7s KB\n"), sizeu1(Z_TagUsage(PU_SOUND)>>10)); + CONS_Printf(M_GetText("Static (music) : %7s KB\n"), sizeu1(Z_TagUsage(PU_MUSIC)>>10)); + CONS_Printf(M_GetText("Patches : %7s KB\n"), sizeu1(Z_TagUsage(PU_PATCH)>>10)); + CONS_Printf(M_GetText("Patches (low priority) : %7s KB\n"), sizeu1(Z_TagUsage(PU_PATCH_LOWPRIORITY)>>10)); + CONS_Printf(M_GetText("Patches (rotated) : %7s KB\n"), sizeu1(Z_TagUsage(PU_PATCH_ROTATED)>>10)); + CONS_Printf(M_GetText("Sprites : %7s KB\n"), sizeu1(Z_TagUsage(PU_SPRITE)>>10)); + 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("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)); #ifdef HWRENDER diff --git a/src/z_zone.h b/src/z_zone.h index 90a6de8eb..e80a45e7f 100644 --- a/src/z_zone.h +++ b/src/z_zone.h @@ -45,9 +45,10 @@ enum PU_PATCH = 14, // static entire execution time PU_PATCH_LOWPRIORITY = 15, // lower priority patch, static until level exited - PU_SPRITE = 16, // sprite patch, static until WAD added - PU_SPRITE_ROTATED = 17, // sprite patch, static until level exited or WAD added - PU_HUDGFX = 18, // HUD patch, static until WAD added + PU_PATCH_ROTATED = 16, // rotated patch, static until level exited or WAD added + PU_PATCH_DATA = 17, // patch data, lifetime depends on the patch that owns it + PU_SPRITE = 18, // sprite patch, static until WAD added + PU_HUDGFX = 19, // HUD patch, static until WAD added PU_HWRPATCHINFO = 21, // Hardware GLPatch_t struct for OpenGL texture cache PU_HWRPATCHCOLMIPMAP = 22, // Hardware GLMipmap_t struct colormap variation of patch From b2f45986ad2adce76cb41ef1428340ebe3386559 Mon Sep 17 00:00:00 2001 From: Jaime Passos Date: Sat, 10 Oct 2020 18:53:05 -0300 Subject: [PATCH 0152/1080] Add r_patchrotation.h --- src/CMakeLists.txt | 1 + src/r_patch.h | 2 -- src/r_patchrotation.c | 9 ++------- src/r_patchrotation.h | 21 +++++++++++++++++++++ src/r_things.c | 1 + 5 files changed, 25 insertions(+), 9 deletions(-) create mode 100644 src/r_patchrotation.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 9c2326399..819b9cc35 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -148,6 +148,7 @@ set(SRB2_CORE_RENDER_SOURCES r_things.h r_textures.h r_patch.h + r_patchrotation.h r_picformats.h r_portal.h ) diff --git a/src/r_patch.h b/src/r_patch.h index 71f185c9d..6991d3637 100644 --- a/src/r_patch.h +++ b/src/r_patch.h @@ -31,8 +31,6 @@ void *Patch_CreateGL(patch_t *patch); void Patch_Rotate(patch_t *patch, INT32 angle, INT32 xpivot, INT32 ypivot, boolean flip); patch_t *Patch_GetRotated(patch_t *patch, INT32 angle, boolean flip); patch_t *Patch_GetRotatedSprite(spriteframe_t *sprite, size_t frame, size_t spriteangle, boolean flip, void *info, INT32 rotationangle);INT32 R_GetRollAngle(angle_t rollangle); -extern fixed_t rollcosang[ROTANGLES]; -extern fixed_t rollsinang[ROTANGLES]; #endif #endif // __R_PATCH__ diff --git a/src/r_patchrotation.c b/src/r_patchrotation.c index 77544c3ac..83eb4eeba 100644 --- a/src/r_patchrotation.c +++ b/src/r_patchrotation.c @@ -1,6 +1,6 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- -// Copyright (C) 2018-2020 by Jaime "Lactozilla" Passos. +// Copyright (C) 2020 by Jaime "Lactozilla" Passos. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -9,17 +9,12 @@ /// \file r_patchrotation.c /// \brief Patch rotation. -#include "r_patch.h" -#include "r_picformats.h" +#include "r_patchrotation.h" #include "r_things.h" // FEETADJUST #include "z_zone.h" #include "w_wad.h" #ifdef ROTSPRITE - -static rotsprite_t *RotatedPatch_Create(INT32 numangles); -static void RotatedPatch_DoRotation(rotsprite_t *rotsprite, patch_t *patch, INT32 angle, INT32 xpivot, INT32 ypivot, boolean flip); - fixed_t rollcosang[ROTANGLES]; fixed_t rollsinang[ROTANGLES]; diff --git a/src/r_patchrotation.h b/src/r_patchrotation.h new file mode 100644 index 000000000..2744f71d2 --- /dev/null +++ b/src/r_patchrotation.h @@ -0,0 +1,21 @@ +// SONIC ROBO BLAST 2 +//----------------------------------------------------------------------------- +// Copyright (C) 2020 by Jaime "Lactozilla" Passos. +// +// This program is free software distributed under the +// terms of the GNU General Public License, version 2. +// See the 'LICENSE' file for more details. +//----------------------------------------------------------------------------- +/// \file r_patchrotation.h +/// \brief Patch rotation. + +#include "r_patch.h" +#include "r_picformats.h" + +#ifdef ROTSPRITE +rotsprite_t *RotatedPatch_Create(INT32 numangles); +void RotatedPatch_DoRotation(rotsprite_t *rotsprite, patch_t *patch, INT32 angle, INT32 xpivot, INT32 ypivot, boolean flip); + +extern fixed_t rollcosang[ROTANGLES]; +extern fixed_t rollsinang[ROTANGLES]; +#endif diff --git a/src/r_things.c b/src/r_things.c index b7d7302f8..33b9820c8 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -25,6 +25,7 @@ #include "i_system.h" #include "r_things.h" #include "r_patch.h" +#include "r_patchrotation.h" #include "r_picformats.h" #include "r_plane.h" #include "r_portal.h" From 6145442a34ad838009d15bdb36d0a443dc1f77a5 Mon Sep 17 00:00:00 2001 From: Jaime Passos Date: Sat, 10 Oct 2020 19:06:29 -0300 Subject: [PATCH 0153/1080] Fix rotated flipped patches --- src/r_patchrotation.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/r_patchrotation.c b/src/r_patchrotation.c index 83eb4eeba..803e159ef 100644 --- a/src/r_patchrotation.c +++ b/src/r_patchrotation.c @@ -127,17 +127,15 @@ void RotatedPatch_DoRotation(rotsprite_t *rotsprite, patch_t *patch, INT32 angle #define ROTSPRITE_YCENTER (newheight / 2) if (flip) - idx += rotsprite->angles; - - if (rotsprite->patches[idx]) - return; - - if (bflip) { + idx += rotsprite->angles; xpivot = width - xpivot; leftoffset = width - leftoffset; } + if (rotsprite->patches[idx]) + return; + // Find the dimensions of the rotated patch. { INT32 w1 = abs(FixedMul(width << FRACBITS, ca) - FixedMul(height << FRACBITS, sa)); @@ -226,7 +224,7 @@ void RotatedPatch_DoRotation(rotsprite_t *rotsprite, patch_t *patch, INT32 angle rotated = (patch_t *)Picture_Convert(PICFMT_FLAT16, rawdst, PICFMT_PATCH, 0, &size, newwidth, newheight, 0, 0, 0); Z_ChangeTag(rotated, PU_PATCH_ROTATED); - Z_SetUser(rotated, (void **)(&rotsprite->patches[angle])); + Z_SetUser(rotated, (void **)(&rotsprite->patches[idx])); rotated->leftoffset = (rotated->width / 2) + (leftoffset - xpivot); rotated->topoffset = (rotated->height / 2) + (patch->topoffset - ypivot); From 8bc8946be888f8b0e1c08369a39ecbc99f914a59 Mon Sep 17 00:00:00 2001 From: James R Date: Sat, 10 Oct 2020 16:43:09 -0700 Subject: [PATCH 0154/1080] Turn the lua sector lines hack into a macro --- src/doomtype.h | 8 ++++++++ src/lua_maplib.c | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/doomtype.h b/src/doomtype.h index 0aa3e23e0..4e13ba96d 100644 --- a/src/doomtype.h +++ b/src/doomtype.h @@ -371,4 +371,12 @@ typedef UINT32 tic_t; #define WSTRING2(s) L ## s #define WSTRING(s) WSTRING2 (s) +/* +A hack by Monster Iestyn: Return a pointer to a field of +a struct from a pointer to another field in the struct. +Needed for some lua shenanigans. +*/ +#define FIELDFROM( type, field, have, want ) \ + (void *)((intptr_t)(field) - offsetof (type, have) + offsetof (type, want)) + #endif //__DOOMTYPE__ diff --git a/src/lua_maplib.c b/src/lua_maplib.c index 12a0be27d..132c81e48 100644 --- a/src/lua_maplib.c +++ b/src/lua_maplib.c @@ -447,7 +447,7 @@ static int sectorlines_get(lua_State *L) // get the "linecount" by shifting our retrieved memory address of "lines" to where "linecount" is in the sector_t, then dereferencing the result // we need this to determine the array's actual size, and therefore also the maximum value allowed as an index // this only works if seclines is actually a pointer to a sector's lines member in memory, oh boy - numoflines = (size_t)(*(size_t *)(((size_t)seclines) - (offsetof(sector_t, lines) - offsetof(sector_t, linecount)))); + numoflines = *(size_t *)FIELDFROM (sector_t, seclines, lines,/* -> */linecount); /* OLD HACK // check first linedef to figure which of its sectors owns this sector->lines pointer From 7f8ec74c274e0bdd3b9f35d8c329ae7707456022 Mon Sep 17 00:00:00 2001 From: James R Date: Sat, 10 Oct 2020 17:40:01 -0700 Subject: [PATCH 0155/1080] Use the macro in sectorlines_num too --- src/lua_maplib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lua_maplib.c b/src/lua_maplib.c index 132c81e48..855ec9482 100644 --- a/src/lua_maplib.c +++ b/src/lua_maplib.c @@ -481,7 +481,7 @@ static int sectorlines_num(lua_State *L) return luaL_error(L, "accessed sector_t.lines doesn't exist anymore."); // see comments in the _get function above - numoflines = (size_t)(*(size_t *)(((size_t)seclines) - (offsetof(sector_t, lines) - offsetof(sector_t, linecount)))); + numoflines = *(size_t *)FIELDFROM (sector_t, seclines, lines,/* -> */linecount); lua_pushinteger(L, numoflines); return 1; } From b808b3ef410f5060436af5d2f2e9943d79e8d7d4 Mon Sep 17 00:00:00 2001 From: Jaime Passos Date: Sun, 11 Oct 2020 03:39:31 -0300 Subject: [PATCH 0156/1080] Move calculation of rotated patch dimensions into its own function Simplify rotation code when the pivot isn't in the center --- src/r_patch.c | 4 +- src/r_patchrotation.c | 176 ++++++++++++++++++++++++------------------ 2 files changed, 102 insertions(+), 78 deletions(-) diff --git a/src/r_patch.c b/src/r_patch.c index e12341401..9ca04dd55 100644 --- a/src/r_patch.c +++ b/src/r_patch.c @@ -47,11 +47,11 @@ patch_t *Patch_Create(softwarepatch_t *source, size_t srcsize, void *dest) } if (!srcsize) - I_Error("R_CreatePatch: no source size!"); + I_Error("Patch_Create: no source size!"); colsize = (INT32)(srcsize) - (INT32)offs; if (colsize <= 0) - I_Error("R_CreatePatch: no column data!"); + I_Error("Patch_Create: no column data!"); patch->columns = Z_Calloc(colsize, PU_PATCH_DATA, NULL); M_Memcpy(patch->columns, ((UINT8 *)source + LONG(source->columnofs[0])), colsize); diff --git a/src/r_patchrotation.c b/src/r_patchrotation.c index 803e159ef..98e3a7687 100644 --- a/src/r_patchrotation.c +++ b/src/r_patchrotation.c @@ -82,6 +82,9 @@ patch_t *Patch_GetRotatedSprite(spriteframe_t *sprite, size_t frame, size_t spri } RotatedPatch_DoRotation(rotsprite, patch, rotationangle, xpivot, ypivot, flip); + + //BP: we cannot use special tric in hardware mode because feet in ground caused by z-buffer + ((patch_t *)rotsprite->patches[idx])->topoffset += FEETADJUST>>FRACBITS; } return rotsprite->patches[idx]; @@ -102,10 +105,32 @@ rotsprite_t *RotatedPatch_Create(INT32 numangles) return rotsprite; } +static void RotatedPatch_CalculateDimensions( + INT32 width, INT32 height, + fixed_t ca, fixed_t sa, + INT32 *newwidth, INT32 *newheight) +{ + fixed_t fixedwidth = (width * FRACUNIT); + fixed_t fixedheight = (height * FRACUNIT); + + fixed_t w1 = abs(FixedMul(fixedwidth, ca) - FixedMul(fixedheight, sa)); + fixed_t w2 = abs(FixedMul(-fixedwidth, ca) - FixedMul(fixedheight, sa)); + fixed_t h1 = abs(FixedMul(fixedwidth, sa) + FixedMul(fixedheight, ca)); + fixed_t h2 = abs(FixedMul(-fixedwidth, sa) + FixedMul(fixedheight, ca)); + + w1 = FixedInt(FixedCeil(w1 + (FRACUNIT/2))); + w2 = FixedInt(FixedCeil(w2 + (FRACUNIT/2))); + h1 = FixedInt(FixedCeil(h1 + (FRACUNIT/2))); + h2 = FixedInt(FixedCeil(h2 + (FRACUNIT/2))); + + *newwidth = max(width, max(w1, w2)); + *newheight = max(height, max(h1, h2)); +} + void RotatedPatch_DoRotation(rotsprite_t *rotsprite, patch_t *patch, INT32 angle, INT32 xpivot, INT32 ypivot, boolean flip) { patch_t *rotated; - UINT16 *rawdst; + UINT16 *rawdst, *rawconv; size_t size; pictureflags_t bflip = (flip) ? PICFLAGS_XFLIP : 0; @@ -114,18 +139,20 @@ void RotatedPatch_DoRotation(rotsprite_t *rotsprite, patch_t *patch, INT32 angle INT32 leftoffset = patch->leftoffset; INT32 newwidth, newheight; - INT32 dx, dy; fixed_t ca = rollcosang[angle]; fixed_t sa = rollsinang[angle]; + fixed_t xcenter, ycenter; INT32 idx = angle; + INT32 x, y; + INT32 sx, sy; + INT32 dx, dy; + INT32 ox, oy; + INT32 minx, miny, maxx, maxy; // Don't cache angle = 0 if (angle < 1 || angle >= ROTANGLES) return; -#define ROTSPRITE_XCENTER (newwidth / 2) -#define ROTSPRITE_YCENTER (newheight / 2) - if (flip) { idx += rotsprite->angles; @@ -137,63 +164,21 @@ void RotatedPatch_DoRotation(rotsprite_t *rotsprite, patch_t *patch, INT32 angle return; // Find the dimensions of the rotated patch. + RotatedPatch_CalculateDimensions(width, height, ca, sa, &newwidth, &newheight); + + xcenter = (xpivot * FRACUNIT); + ycenter = (ypivot * FRACUNIT); + + if (xpivot != width / 2 || ypivot != height / 2) { - INT32 w1 = abs(FixedMul(width << FRACBITS, ca) - FixedMul(height << FRACBITS, sa)); - INT32 w2 = abs(FixedMul(-(width << FRACBITS), ca) - FixedMul(height << FRACBITS, sa)); - INT32 h1 = abs(FixedMul(width << FRACBITS, sa) + FixedMul(height << FRACBITS, ca)); - INT32 h2 = abs(FixedMul(-(width << FRACBITS), sa) + FixedMul(height << FRACBITS, ca)); - w1 = FixedInt(FixedCeil(w1 + (FRACUNIT/2))); - w2 = FixedInt(FixedCeil(w2 + (FRACUNIT/2))); - h1 = FixedInt(FixedCeil(h1 + (FRACUNIT/2))); - h2 = FixedInt(FixedCeil(h2 + (FRACUNIT/2))); - newwidth = max(width, max(w1, w2)); - newheight = max(height, max(h1, h2)); + newwidth *= 2; + newheight *= 2; } - // check boundaries - { - fixed_t top[2][2]; - fixed_t bottom[2][2]; - - top[0][0] = FixedMul((-ROTSPRITE_XCENTER) << FRACBITS, ca) + FixedMul((-ROTSPRITE_YCENTER) << FRACBITS, sa) + (xpivot << FRACBITS); - top[0][1] = FixedMul((-ROTSPRITE_XCENTER) << FRACBITS, sa) + FixedMul((-ROTSPRITE_YCENTER) << FRACBITS, ca) + (ypivot << FRACBITS); - top[1][0] = FixedMul((newwidth-ROTSPRITE_XCENTER) << FRACBITS, ca) + FixedMul((-ROTSPRITE_YCENTER) << FRACBITS, sa) + (xpivot << FRACBITS); - top[1][1] = FixedMul((newwidth-ROTSPRITE_XCENTER) << FRACBITS, sa) + FixedMul((-ROTSPRITE_YCENTER) << FRACBITS, ca) + (ypivot << FRACBITS); - - bottom[0][0] = FixedMul((-ROTSPRITE_XCENTER) << FRACBITS, ca) + FixedMul((newheight-ROTSPRITE_YCENTER) << FRACBITS, sa) + (xpivot << FRACBITS); - bottom[0][1] = -FixedMul((-ROTSPRITE_XCENTER) << FRACBITS, sa) + FixedMul((newheight-ROTSPRITE_YCENTER) << FRACBITS, ca) + (ypivot << FRACBITS); - bottom[1][0] = FixedMul((newwidth-ROTSPRITE_XCENTER) << FRACBITS, ca) + FixedMul((newheight-ROTSPRITE_YCENTER) << FRACBITS, sa) + (xpivot << FRACBITS); - bottom[1][1] = -FixedMul((newwidth-ROTSPRITE_XCENTER) << FRACBITS, sa) + FixedMul((newheight-ROTSPRITE_YCENTER) << FRACBITS, ca) + (ypivot << FRACBITS); - - top[0][0] >>= FRACBITS; - top[0][1] >>= FRACBITS; - top[1][0] >>= FRACBITS; - top[1][1] >>= FRACBITS; - - bottom[0][0] >>= FRACBITS; - bottom[0][1] >>= FRACBITS; - bottom[1][0] >>= FRACBITS; - bottom[1][1] >>= FRACBITS; - -#define BOUNDARYWCHECK(b) (b[0] < 0 || b[0] >= width) -#define BOUNDARYHCHECK(b) (b[1] < 0 || b[1] >= height) -#define BOUNDARYADJUST(x) x *= 2 - // top left/right - if (BOUNDARYWCHECK(top[0]) || BOUNDARYWCHECK(top[1])) - BOUNDARYADJUST(newwidth); - // bottom left/right - else if (BOUNDARYWCHECK(bottom[0]) || BOUNDARYWCHECK(bottom[1])) - BOUNDARYADJUST(newwidth); - // top left/right - if (BOUNDARYHCHECK(top[0]) || BOUNDARYHCHECK(top[1])) - BOUNDARYADJUST(newheight); - // bottom left/right - else if (BOUNDARYHCHECK(bottom[0]) || BOUNDARYHCHECK(bottom[1])) - BOUNDARYADJUST(newheight); -#undef BOUNDARYWCHECK -#undef BOUNDARYHCHECK -#undef BOUNDARYADJUST - } + minx = newwidth; + miny = newheight; + maxx = 0; + maxy = 0; // Draw the rotated sprite to a temporary buffer. size = (newwidth * newheight); @@ -205,37 +190,76 @@ void RotatedPatch_DoRotation(rotsprite_t *rotsprite, patch_t *patch, INT32 angle { for (dx = 0; dx < newwidth; dx++) { - INT32 x = (dx-ROTSPRITE_XCENTER) << FRACBITS; - INT32 y = (dy-ROTSPRITE_YCENTER) << FRACBITS; - INT32 sx = FixedMul(x, ca) + FixedMul(y, sa) + (xpivot << FRACBITS); - INT32 sy = -FixedMul(x, sa) + FixedMul(y, ca) + (ypivot << FRACBITS); + x = (dx - (newwidth / 2)) * FRACUNIT; + y = (dy - (newheight / 2)) * FRACUNIT; + sx = FixedMul(x, ca) + FixedMul(y, sa) + xcenter; + sy = -FixedMul(x, sa) + FixedMul(y, ca) + ycenter; + sx >>= FRACBITS; sy >>= FRACBITS; + if (sx >= 0 && sy >= 0 && sx < width && sy < height) { void *input = Picture_GetPatchPixel(patch, PICFMT_PATCH, sx, sy, bflip); if (input != NULL) - rawdst[(dy*newwidth)+dx] = (0xFF00 | (*(UINT8 *)input)); + { + rawdst[(dy * newwidth) + dx] = (0xFF00 | (*(UINT8 *)input)); + if (dx < minx) + minx = dx; + if (dy < miny) + miny = dy; + if (dx > maxx) + maxx = dx; + if (dy > maxy) + maxy = dy; + } } } } + ox = (newwidth / 2) + (leftoffset - xpivot); + oy = (newheight / 2) + (patch->topoffset - ypivot); + width = (maxx - minx); + height = (maxy - miny); + + if ((unsigned)(width * height) != size) + { + UINT16 *src, *dest; + + size = (width * height); + rawconv = Z_Calloc(size * sizeof(UINT16), PU_STATIC, NULL); + + src = &rawdst[(miny * newwidth) + minx]; + dest = rawconv; + dy = height; + + while (dy--) + { + M_Memcpy(dest, src, width * sizeof(UINT16)); + dest += width; + src += newwidth; + } + + ox -= minx; + oy -= miny; + + Z_Free(rawdst); + } + else + { + rawconv = rawdst; + width = newwidth; + height = newheight; + } + // make patch - rotated = (patch_t *)Picture_Convert(PICFMT_FLAT16, rawdst, PICFMT_PATCH, 0, &size, newwidth, newheight, 0, 0, 0); + rotated = (patch_t *)Picture_Convert(PICFMT_FLAT16, rawconv, PICFMT_PATCH, 0, NULL, width, height, 0, 0, 0); Z_ChangeTag(rotated, PU_PATCH_ROTATED); Z_SetUser(rotated, (void **)(&rotsprite->patches[idx])); + Z_Free(rawconv); - rotated->leftoffset = (rotated->width / 2) + (leftoffset - xpivot); - rotated->topoffset = (rotated->height / 2) + (patch->topoffset - ypivot); - - //BP: we cannot use special tric in hardware mode because feet in ground caused by z-buffer - rotated->topoffset += FEETADJUST>>FRACBITS; - - // free rotated image data - Z_Free(rawdst); - -#undef ROTSPRITE_XCENTER -#undef ROTSPRITE_YCENTER + rotated->leftoffset = ox; + rotated->topoffset = oy; } #endif From cc97e22e2f7c184d5beb2027fa0d70940b5f4d5c Mon Sep 17 00:00:00 2001 From: Jaime Passos Date: Mon, 12 Oct 2020 00:13:22 -0300 Subject: [PATCH 0157/1080] Changes to sprite rendering: - Added render flags (see r_defs.h) - Implemented floor splats - Drop shadow sprite rendering through render flags --- src/d_clisrv.c | 6 + src/d_clisrv.h | 3 + src/d_netcmd.c | 4 - src/d_netcmd.h | 3 - src/dehacked.c | 17 + src/doomdef.h | 3 + src/hardware/hw_main.c | 114 +---- src/lua_hudlib.c | 4 +- src/lua_mobjlib.c | 24 ++ src/p_mobj.c | 35 +- src/p_mobj.h | 3 + src/p_saveg.c | 23 +- src/p_setup.c | 13 +- src/p_user.c | 6 - src/r_bsp.c | 5 - src/r_defs.h | 31 +- src/r_draw.c | 1 + src/r_draw.h | 5 + src/r_draw8.c | 224 ++++++++++ src/r_draw8_npo2.c | 98 +++++ src/r_main.c | 6 - src/r_patch.c | 19 +- src/r_patch.h | 10 +- src/r_patchrotation.c | 16 +- src/r_plane.c | 31 +- src/r_segs.c | 179 +------- src/r_splats.c | 797 ++++++++++++---------------------- src/r_splats.h | 67 +-- src/r_things.c | 948 ++++++++++++++++++++++++++++------------- src/r_things.h | 44 +- src/screen.c | 4 + src/screen.h | 2 + src/tmap.nas | 4 +- 33 files changed, 1489 insertions(+), 1260 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index c9490410b..3db5a6207 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -648,12 +648,15 @@ static inline void resynch_write_player(resynch_pak *rsp, const size_t i) rsp->eflags = (UINT16)SHORT(players[i].mo->eflags); rsp->flags = LONG(players[i].mo->flags); rsp->flags2 = LONG(players[i].mo->flags2); + rsp->renderflags = LONG(players[i].mo->renderflags); rsp->radius = LONG(players[i].mo->radius); rsp->height = LONG(players[i].mo->height); rsp->scale = LONG(players[i].mo->scale); rsp->destscale = LONG(players[i].mo->destscale); rsp->scalespeed = LONG(players[i].mo->scalespeed); + rsp->spritexscale = LONG(players[i].mo->spritexscale); + rsp->spriteyscale = LONG(players[i].mo->spriteyscale); } static void resynch_read_player(resynch_pak *rsp) @@ -787,6 +790,7 @@ static void resynch_read_player(resynch_pak *rsp) players[i].mo->eflags = (UINT16)SHORT(rsp->eflags); players[i].mo->flags = LONG(rsp->flags); players[i].mo->flags2 = LONG(rsp->flags2); + players[i].mo->renderflags = LONG(rsp->renderflags); players[i].mo->friction = LONG(rsp->friction); players[i].mo->health = LONG(rsp->health); players[i].mo->momx = LONG(rsp->momx); @@ -813,6 +817,8 @@ static void resynch_read_player(resynch_pak *rsp) players[i].mo->scale = LONG(rsp->scale); players[i].mo->destscale = LONG(rsp->destscale); players[i].mo->scalespeed = LONG(rsp->scalespeed); + players[i].mo->spritexscale = LONG(rsp->spritexscale); + players[i].mo->spriteyscale = LONG(rsp->spriteyscale); // And finally, SET THE MOBJ SKIN damn it. if ((players[i].powers[pw_carry] == CR_NIGHTSMODE) && (skins[players[i].skin].sprites[SPR2_NFLY].numframes == 0)) diff --git a/src/d_clisrv.h b/src/d_clisrv.h index adc8a7cc9..0ed0b10f5 100644 --- a/src/d_clisrv.h +++ b/src/d_clisrv.h @@ -293,12 +293,15 @@ typedef struct UINT32 flags; UINT32 flags2; UINT16 eflags; + UINT32 renderflags; fixed_t radius; fixed_t height; fixed_t scale; fixed_t destscale; fixed_t scalespeed; + fixed_t spritexscale; + fixed_t spriteyscale; } ATTRPACK resynch_pak; typedef struct diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 6f4bcdb1d..7e0c84584 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -671,10 +671,6 @@ void D_RegisterClientCommands(void) CV_RegisterVar(&cv_gif_dynamicdelay); CV_RegisterVar(&cv_gif_localcolortable); -#ifdef WALLSPLATS - CV_RegisterVar(&cv_splats); -#endif - // register these so it is saved to config CV_RegisterVar(&cv_playername); CV_RegisterVar(&cv_playercolor); diff --git a/src/d_netcmd.h b/src/d_netcmd.h index 897c28968..3cd4b33c5 100644 --- a/src/d_netcmd.h +++ b/src/d_netcmd.h @@ -75,9 +75,6 @@ extern consvar_t cv_teamscramble; extern consvar_t cv_scrambleonchange; extern consvar_t cv_netstat; -#ifdef WALLSPLATS -extern consvar_t cv_splats; -#endif extern consvar_t cv_countdowntime; extern consvar_t cv_runscripts; diff --git a/src/dehacked.c b/src/dehacked.c index 80a0ad0ff..92a8ffe4e 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -9035,6 +9035,7 @@ static const char *const MOBJFLAG2_LIST[] = { "AMBUSH", // Alternate behaviour typically set by MTF_AMBUSH "LINKDRAW", // Draw vissprite of mobj immediately before/after tracer's vissprite (dependent on dispoffset and position) "SHIELD", // Thinker calls P_AddShield/P_ShieldLook (must be partnered with MF_SCENERY to use) + "SPLAT", // Object is a splat NULL }; @@ -9579,6 +9580,22 @@ struct { {"tr_trans90",tr_trans90}, {"NUMTRANSMAPS",NUMTRANSMAPS}, + // Render flags + {"RF_HORIZONTALFLIP",RF_HORIZONTALFLIP}, + {"RF_VERTICALFLIP",RF_VERTICALFLIP}, + {"RF_ONESIDED",RF_ONESIDED}, + {"RF_NOSPLATBILLBOARD",RF_NOSPLATBILLBOARD}, + {"RF_NOSPLATROLLANGLE",RF_NOSPLATROLLANGLE}, + {"RF_FULLBRIGHT",RF_FULLBRIGHT}, + {"RF_FULLDARK",RF_FULLDARK}, + {"RF_SPRITETYPEMASK",RF_SPRITETYPEMASK}, + {"RF_PAPERSPRITE",RF_PAPERSPRITE}, + {"RF_FLOORSPRITE",RF_FLOORSPRITE}, + {"RF_VOXELSPRITE",RF_VOXELSPRITE}, + {"RF_SHADOWDRAW",RF_SHADOWDRAW}, + {"RF_SHADOWEFFECTS",RF_SHADOWEFFECTS}, + {"RF_DROPSHADOW",RF_DROPSHADOW}, + // Level flags {"LF_SCRIPTISFILE",LF_SCRIPTISFILE}, {"LF_SPEEDMUSIC",LF_SPEEDMUSIC}, diff --git a/src/doomdef.h b/src/doomdef.h index d0b7ea0c2..98a22e5ab 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -641,6 +641,9 @@ extern const char *compdate, *comptime, *comprevision, *compbranch; /// Render flats on walls #define WALLFLATS +/// Floor splats +#define FLOORSPLATS + /// Maintain compatibility with older 2.2 demos #define OLD22DEMOCOMPAT diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index fe0aa2f35..cfcad29d0 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -700,79 +700,6 @@ static void HWR_RenderSkyPlane(extrasubsector_t *xsub, fixed_t fixedheight) #endif //doplanes -/* - wallVerts order is : - 3--2 - | /| - |/ | - 0--1 -*/ -#ifdef WALLSPLATS -static void HWR_DrawSegsSplats(FSurfaceInfo * pSurf) -{ - FOutVector wallVerts[4]; - wallsplat_t *splat; - patch_t *gpatch; - fixed_t i; - // seg bbox - fixed_t segbbox[4]; - - M_ClearBox(segbbox); - M_AddToBox(segbbox, - FLOAT_TO_FIXED(((polyvertex_t *)gl_curline->pv1)->x), - FLOAT_TO_FIXED(((polyvertex_t *)gl_curline->pv1)->y)); - M_AddToBox(segbbox, - FLOAT_TO_FIXED(((polyvertex_t *)gl_curline->pv2)->x), - FLOAT_TO_FIXED(((polyvertex_t *)gl_curline->pv2)->y)); - - splat = (wallsplat_t *)gl_curline->linedef->splats; - for (; splat; splat = splat->next) - { - //BP: don't draw splat extern to this seg - // this is quick fix best is explain in logboris.txt at 12-4-2000 - if (!M_PointInBox(segbbox,splat->v1.x,splat->v1.y) && !M_PointInBox(segbbox,splat->v2.x,splat->v2.y)) - continue; - - gpatch = W_CachePatchNum(splat->patch, PU_SPRITE); - HWR_GetPatch(gpatch); - - wallVerts[0].x = wallVerts[3].x = FIXED_TO_FLOAT(splat->v1.x); - wallVerts[0].z = wallVerts[3].z = FIXED_TO_FLOAT(splat->v1.y); - wallVerts[2].x = wallVerts[1].x = FIXED_TO_FLOAT(splat->v2.x); - wallVerts[2].z = wallVerts[1].z = FIXED_TO_FLOAT(splat->v2.y); - - i = splat->top; - if (splat->yoffset) - i += *splat->yoffset; - - wallVerts[2].y = wallVerts[3].y = FIXED_TO_FLOAT(i)+(gpatch->height>>1); - wallVerts[0].y = wallVerts[1].y = FIXED_TO_FLOAT(i)-(gpatch->height>>1); - - wallVerts[3].s = wallVerts[3].t = wallVerts[2].s = wallVerts[0].t = 0.0f; - wallVerts[1].s = wallVerts[1].t = wallVerts[2].t = wallVerts[0].s = 1.0f; - - switch (splat->flags & SPLATDRAWMODE_MASK) - { - case SPLATDRAWMODE_OPAQUE : - pSurf.PolyColor.s.alpha = 0xff; - i = PF_Translucent; - break; - case SPLATDRAWMODE_TRANS : - pSurf.PolyColor.s.alpha = 128; - i = PF_Translucent; - break; - case SPLATDRAWMODE_SHADE : - pSurf.PolyColor.s.alpha = 0xff; - i = PF_Substractive; - break; - } - - HWD.pfnSetShader(2); // wall shader - HWD.pfnDrawPolygon(&pSurf, wallVerts, 4, i|PF_Modulated|PF_Decal); - } -} -#endif - FBITFIELD HWR_TranstableToAlpha(INT32 transtablenum, FSurfaceInfo *pSurf) { switch (transtablenum) @@ -797,19 +724,21 @@ static void HWR_AddTransparentWall(FOutVector *wallVerts, FSurfaceInfo *pSurf, I // Wall generation from subsector segs // ========================================================================== +/* + wallVerts order is : + 3--2 + | /| + |/ | + 0--1 +*/ + // // HWR_ProjectWall // static void HWR_ProjectWall(FOutVector *wallVerts, FSurfaceInfo *pSurf, FBITFIELD blendmode, INT32 lightlevel, extracolormap_t *wallcolormap) { HWR_Lighting(pSurf, lightlevel, wallcolormap); - HWR_ProcessPolygon(pSurf, wallVerts, 4, blendmode|PF_Modulated|PF_Occlude, 2, false); // wall shader - -#ifdef WALLSPLATS - if (gl_curline->linedef->splats && cv_splats.value) - HWR_DrawSegsSplats(pSurf); -#endif } // ========================================================================== @@ -3977,7 +3906,7 @@ static void HWR_DrawSprite(gl_vissprite_t *spr) patch_t *gpatch; // sprite patch converted to hardware FSurfaceInfo Surf; const boolean hires = (spr->mobj && spr->mobj->skin && ((skin_t *)spr->mobj->skin)->flags & SF_HIRES); - //const boolean papersprite = (spr->mobj && (spr->mobj->frame & FF_PAPERSPRITE)); + //const boolean papersprite = R_ThingIsPaperSprite(spr->mobj); if (spr->mobj) this_scale = FIXED_TO_FLOAT(spr->mobj->scale); if (hires) @@ -4761,14 +4690,14 @@ static void HWR_ProjectSprite(mobj_t *thing) size_t lumpoff; unsigned rot; UINT16 flip; - boolean vflip = (!(thing->eflags & MFE_VERTICALFLIP) != !(thing->frame & FF_VERTICALFLIP)); + boolean vflip = (!(thing->eflags & MFE_VERTICALFLIP) != !R_ThingVerticallyFlipped(thing)); boolean mirrored = thing->mirrored; - boolean hflip = (!(thing->frame & FF_HORIZONTALFLIP) != !mirrored); + boolean hflip = (!R_ThingHorizontallyFlipped(thing) != !mirrored); INT32 dispoffset; angle_t ang; INT32 heightsec, phs; - const boolean papersprite = (thing->frame & FF_PAPERSPRITE); + const boolean papersprite = R_ThingIsPaperSprite(thing); angle_t mobjangle = (thing->player ? thing->player->drawangle : thing->angle); float z1, z2; @@ -4909,13 +4838,16 @@ static void HWR_ProjectSprite(mobj_t *thing) if (thing->rollangle) { rollangle = R_GetRollAngle(thing->rollangle); - rotsprite = Patch_GetRotatedSprite(sprframe, (thing->frame & FF_FRAMEMASK), rot, flip, sprinfo, rollangle); + rotsprite = Patch_GetRotatedSprite(sprframe, (thing->frame & FF_FRAMEMASK), rot, flip, false, sprinfo, rollangle); + if (rotsprite != NULL) { - spr_width = SHORT(rotsprite->width) << FRACBITS; - spr_height = SHORT(rotsprite->height) << FRACBITS; - spr_offset = SHORT(rotsprite->leftoffset) << FRACBITS; - spr_topoffset = SHORT(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 flip = 0; } @@ -6224,13 +6156,7 @@ void HWR_RenderWall(FOutVector *wallVerts, FSurfaceInfo *pSurf, FBITFIELD blend, } blendmode |= PF_Modulated; // No PF_Occlude means overlapping (incorrect) transparency - HWR_ProcessPolygon(pSurf, wallVerts, 4, blendmode, shader, false); - -#ifdef WALLSPLATS - if (gl_curline->linedef->splats && cv_splats.value) - HWR_DrawSegsSplats(pSurf); -#endif } INT32 HWR_GetTextureUsed(void) diff --git a/src/lua_hudlib.c b/src/lua_hudlib.c index 335e6cfbc..7b290bf3f 100644 --- a/src/lua_hudlib.c +++ b/src/lua_hudlib.c @@ -458,7 +458,7 @@ static int libd_getSpritePatch(lua_State *L) INT32 rot = R_GetRollAngle(rollangle); if (rot) { - patch_t *rotsprite = Patch_GetRotatedSprite(sprframe, frame, angle, sprframe->flip & (1<flip & (1<flip & (1<flip & (1<eflags); break; + case mobj_renderflags: + lua_pushinteger(L, mo->renderflags); + break; case mobj_skin: // skin name or nil, not struct if (!mo->skin) return 0; @@ -381,6 +390,12 @@ static int mobj_get(lua_State *L) case mobj_scalespeed: lua_pushfixed(L, mo->scalespeed); break; + case mobj_spritexscale: + lua_pushfixed(L, mo->spritexscale); + break; + case mobj_spriteyscale: + lua_pushfixed(L, mo->spriteyscale); + break; case mobj_extravalue1: lua_pushinteger(L, mo->extravalue1); break; @@ -580,6 +595,9 @@ static int mobj_set(lua_State *L) case mobj_eflags: mo->eflags = (UINT32)luaL_checkinteger(L, 3); break; + case mobj_renderflags: + mo->renderflags = (UINT32)luaL_checkinteger(L, 3); + break; case mobj_skin: // set skin by name { INT32 i; @@ -721,6 +739,12 @@ static int mobj_set(lua_State *L) case mobj_scalespeed: mo->scalespeed = luaL_checkfixed(L, 3); break; + case mobj_spritexscale: + mo->spritexscale = luaL_checkfixed(L, 3); + break; + case mobj_spriteyscale: + mo->spriteyscale = luaL_checkfixed(L, 3); + break; case mobj_extravalue1: mo->extravalue1 = luaL_checkinteger(L, 3); break; diff --git a/src/p_mobj.c b/src/p_mobj.c index de4385fa7..827650ce6 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -38,10 +38,6 @@ static CV_PossibleValue_t CV_BobSpeed[] = {{0, "MIN"}, {4*FRACUNIT, "MAX"}, {0, NULL}}; consvar_t cv_movebob = CVAR_INIT ("movebob", "1.0", CV_FLOAT|CV_SAVE, CV_BobSpeed, NULL); -#ifdef WALLSPLATS -consvar_t cv_splats = CVAR_INIT ("splats", "On", CV_SAVE, CV_OnOff, NULL); -#endif - actioncache_t actioncachehead; static mobj_t *overlaycap = NULL; @@ -1961,29 +1957,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; } @@ -9614,12 +9587,6 @@ static boolean P_MobjRegularThink(mobj_t *mobj) mobj->fuse = 1; // Return to base. break; } - case MT_CANNONBALL: -#ifdef FLOORSPLATS - R_AddFloorSplat(mobj->tracer->subsector, mobj->tracer, "TARGET", mobj->tracer->x, - mobj->tracer->y, mobj->tracer->floorz, SPLATDRAWMODE_SHADE); -#endif - break; case MT_SPINDUST: // Spindash dust mobj->momx = FixedMul(mobj->momx, (3*FRACUNIT)/4); // originally 50000 mobj->momy = FixedMul(mobj->momy, (3*FRACUNIT)/4); // same @@ -10487,6 +10454,7 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type) mobj->tics = st->tics; mobj->sprite = st->sprite; mobj->frame = st->frame; // FF_FRAMEMASK for frame, and other bits.. + mobj->renderflags = 0; P_SetupStateAnimation(mobj, st); mobj->friction = ORIG_FRICTION; @@ -10497,6 +10465,7 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type) mobj->scale = FRACUNIT; mobj->destscale = mobj->scale; mobj->scalespeed = FRACUNIT/12; + mobj->spritexscale = mobj->spriteyscale = mobj->scale; // TODO: Make this a special map header if ((maptol & TOL_ERZ3) && !(mobj->type == MT_BLACKEGGMAN)) diff --git a/src/p_mobj.h b/src/p_mobj.h index 27a6ef4f0..eb8a9ccc2 100644 --- a/src/p_mobj.h +++ b/src/p_mobj.h @@ -194,6 +194,7 @@ typedef enum MF2_AMBUSH = 1<<27, // Alternate behaviour typically set by MTF_AMBUSH MF2_LINKDRAW = 1<<28, // Draw vissprite of mobj immediately before/after tracer's vissprite (dependent on dispoffset and position) MF2_SHIELD = 1<<29, // Thinker calls P_AddShield/P_ShieldLook (must be partnered with MF_SCENERY to use) + MF2_SPLAT = 1<<30, // Renders as a splat // free: to and including 1<<31 } mobjflag2_t; @@ -308,6 +309,7 @@ typedef struct mobj_s UINT32 flags; // flags from mobjinfo tables UINT32 flags2; // MF2_ flags UINT16 eflags; // extra flags + UINT32 renderflags; // render flags void *skin; // overrides 'sprite' when non-NULL (for player bodies to 'remember' the skin) // Player and mobj sprites in multiplayer modes are modified @@ -360,6 +362,7 @@ typedef struct mobj_s fixed_t scale; fixed_t destscale; fixed_t scalespeed; + fixed_t spritexscale, spriteyscale; // Extra values are for internal use for whatever you want INT32 extravalue1; diff --git a/src/p_saveg.c b/src/p_saveg.c index 4f6f31803..d613efd70 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -1393,7 +1393,10 @@ typedef enum MD2_COLORIZED = 1<<12, MD2_MIRRORED = 1<<13, MD2_ROLLANGLE = 1<<14, - MD2_SHADOWSCALE = 1<<15, + MD2_SPRITEXSCALE = 1<<15, + MD2_SPRITEYSCALE = 1<<16, + MD2_SHADOWSCALE = 1<<17, + MD2_RENDERFLAGS = 1<<18, } mobj_diff2_t; typedef enum @@ -1604,8 +1607,14 @@ static void SaveMobjThinker(const thinker_t *th, const UINT8 type) diff2 |= MD2_MIRRORED; if (mobj->rollangle) diff2 |= MD2_ROLLANGLE; + if (mobj->spritexscale != FRACUNIT) + diff2 |= MD2_SPRITEXSCALE; + if (mobj->spriteyscale != FRACUNIT) + diff2 |= MD2_SPRITEYSCALE; if (mobj->shadowscale) diff2 |= MD2_SHADOWSCALE; + if (mobj->renderflags) + diff2 |= MD2_RENDERFLAGS; if (diff2 != 0) diff |= MD_MORE; @@ -1746,8 +1755,14 @@ static void SaveMobjThinker(const thinker_t *th, const UINT8 type) WRITEUINT8(save_p, mobj->mirrored); if (diff2 & MD2_ROLLANGLE) WRITEANGLE(save_p, mobj->rollangle); + if (diff2 & MD2_SPRITEXSCALE) + WRITEFIXED(save_p, mobj->spritexscale); + if (diff2 & MD2_SPRITEYSCALE) + WRITEFIXED(save_p, mobj->spriteyscale); if (diff2 & MD2_SHADOWSCALE) WRITEFIXED(save_p, mobj->shadowscale); + if (diff2 & MD2_RENDERFLAGS) + WRITEUINT32(save_p, mobj->renderflags); WRITEUINT32(save_p, mobj->mobjnum); } @@ -2755,8 +2770,14 @@ static thinker_t* LoadMobjThinker(actionf_p1 thinker) mobj->mirrored = READUINT8(save_p); if (diff2 & MD2_ROLLANGLE) mobj->rollangle = READANGLE(save_p); + if (diff2 & MD2_SPRITEXSCALE) + mobj->spritexscale = READFIXED(save_p); + if (diff2 & MD2_SPRITEYSCALE) + mobj->spriteyscale = READFIXED(save_p); if (diff2 & MD2_SHADOWSCALE) mobj->shadowscale = READFIXED(save_p); + if (diff2 & MD2_RENDERFLAGS) + mobj->renderflags = READUINT32(save_p); if (diff & MD_REDFLAG) { diff --git a/src/p_setup.c b/src/p_setup.c index 4dbb70e0c..349b0582d 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -1080,9 +1080,6 @@ static void P_InitializeLinedef(line_t *ld) ld->frontsector = ld->backsector = NULL; ld->validcount = 0; -#ifdef WALLSPLATS - ld->splats = NULL; -#endif ld->firsttag = ld->nexttag = -1; ld->polyobj = NULL; @@ -2081,9 +2078,6 @@ static boolean P_LoadMapData(const virtres_t *virt) static void P_InitializeSubsector(subsector_t *ss) { ss->sector = NULL; -#ifdef FLOORSPLATS - ss->splats = NULL; -#endif ss->validcount = 0; } @@ -2128,7 +2122,7 @@ static void P_LoadNodes(UINT8 *data) * \param seg Seg to compute length for. * \return Length in fracunits. */ -fixed_t P_SegLength(seg_t *seg) +static fixed_t P_SegLength(seg_t *seg) { INT64 dx = (seg->v2->x - seg->v1->x)>>1; INT64 dy = (seg->v2->y - seg->v1->y)>>1; @@ -4094,11 +4088,6 @@ boolean P_LoadLevel(boolean fromnetsave) Patch_FreeTag(PU_PATCH_ROTATED); Z_FreeTags(PU_LEVEL, PU_PURGELEVEL - 1); -#if defined (WALLSPLATS) || defined (FLOORSPLATS) - // clear the splats from previous level - R_ClearLevelSplats(); -#endif - P_InitThinkers(); P_InitCachedActions(); diff --git a/src/p_user.c b/src/p_user.c index 7bc45bfc4..0341128d5 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -8678,12 +8678,6 @@ void P_MovePlayer(player_t *player) player->fovadd = 0; #endif -#ifdef FLOORSPLATS - if (cv_shadow.value && rendermode == render_soft) - R_AddFloorSplat(player->mo->subsector, player->mo, "SHADOW", player->mo->x, - player->mo->y, player->mo->floorz, SPLATDRAWMODE_OPAQUE); -#endif - // Look for blocks to bust up // Because of FF_SHATTER, we should look for blocks constantly, // not just when spinning or playing as Knuckles diff --git a/src/r_bsp.c b/src/r_bsp.c index a430ef040..d2c8e9f86 100644 --- a/src/r_bsp.c +++ b/src/r_bsp.c @@ -1048,11 +1048,6 @@ static void R_Subsector(size_t num) } } -#ifdef FLOORSPLATS - if (sub->splats) - R_AddVisibleFloorSplats(sub); -#endif - // killough 9/18/98: Fix underwater slowdown, by passing real sector // instead of fake one. Improve sprite lighting by basing sprite // lightlevels on floor & ceiling lightlevels in the surrounding area. diff --git a/src/r_defs.h b/src/r_defs.h index 4dfba0691..d32313a46 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -409,9 +409,6 @@ typedef struct line_s sector_t *backsector; size_t validcount; // if == validcount, already checked -#if 1//#ifdef WALLSPLATS - void *splats; // wallsplat_t list -#endif INT32 firsttag, nexttag; // improves searches for tags. polyobj_t *polyobj; // Belongs to a polyobject? @@ -457,9 +454,6 @@ typedef struct subsector_s INT16 numlines; UINT16 firstline; struct polyobj_s *polyList; // haleyjd 02/19/06: list of polyobjects -#if 1//#ifdef FLOORSPLATS - void *splats; // floorsplat_t list -#endif size_t validcount; } subsector_t; @@ -674,6 +668,7 @@ typedef struct UINT8 *columns; // Software column data void *hardware; // OpenGL patch, allocated whenever necessary + void *flats[4]; // The patch as flats #ifdef ROTSPRITE rotsprite_t *rotated; // Rotated patches @@ -718,6 +713,28 @@ typedef struct #pragma pack() #endif +typedef enum +{ + RF_HORIZONTALFLIP = 0x0001, // Flip sprite horizontally + RF_VERTICALFLIP = 0x0002, // Flip sprite vertically + RF_ONESIDED = 0x0004, // Wall/floor sprite is visible from front only + RF_NOSPLATBILLBOARD = 0x0008, // Don't billboard floor sprites (faces forward from the view angle) + RF_NOSPLATROLLANGLE = 0x0010, // Don't rotate floor sprites by the object's rollangle (uses rotated patches instead) + + RF_BLENDMASK = 0x0F00, // --Blending modes + RF_FULLBRIGHT = 0x0100, // Sprite is drawn at full brightness + RF_FULLDARK = 0x0200, // Sprite is drawn completely dark + + RF_SPRITETYPEMASK = 0x7000, // ---Different sprite types, not all implemented + RF_PAPERSPRITE = 0x1000, // Paper sprite + RF_FLOORSPRITE = 0x2000, // Floor sprite + RF_VOXELSPRITE = 0x3000, // Voxel object + + RF_SHADOWDRAW = 0x10000, // Stretches and skews the sprite like a shadow. + RF_SHADOWEFFECTS = 0x20000, // Scales and becomes transparent like a shadow. + RF_DROPSHADOW = (RF_SHADOWDRAW | RF_SHADOWEFFECTS | RF_FULLDARK), +} renderflags_t; + typedef enum { SRF_SINGLE = 0, // 0-angle for all rotations @@ -759,7 +776,7 @@ typedef struct UINT16 flip; #ifdef ROTSPRITE - rotsprite_t *rotated[16]; // Rotated patches + rotsprite_t *rotated[2][16]; // Rotated patches #endif } spriteframe_t; diff --git a/src/r_draw.c b/src/r_draw.c index 2b798c3bf..e10d6e399 100644 --- a/src/r_draw.c +++ b/src/r_draw.c @@ -98,6 +98,7 @@ INT32 dc_numlights = 0, dc_maxlights, dc_texheight; INT32 ds_y, ds_x1, ds_x2; lighttable_t *ds_colormap; +lighttable_t *ds_translation; // Lactozilla: Sprite splat drawer fixed_t ds_xfrac, ds_yfrac, ds_xstep, ds_ystep; UINT16 ds_flatwidth, ds_flatheight; boolean ds_powersoftwo; diff --git a/src/r_draw.h b/src/r_draw.h index 1ca22f18a..d77bbedd3 100644 --- a/src/r_draw.h +++ b/src/r_draw.h @@ -56,6 +56,7 @@ extern INT32 dc_texheight; extern INT32 ds_y, ds_x1, ds_x2; extern lighttable_t *ds_colormap; +extern lighttable_t *ds_translation; extern fixed_t ds_xfrac, ds_yfrac, ds_xstep, ds_ystep; extern UINT16 ds_flatwidth, ds_flatheight; extern boolean ds_powersoftwo; @@ -151,8 +152,10 @@ void R_DrawColumnShadowed_8(void); void R_DrawSpan_8(void); void R_DrawSplat_8(void); +void R_DrawFloorSprite_8(void); void R_DrawTranslucentSpan_8(void); void R_DrawTranslucentSplat_8(void); +void R_DrawTranslucentFloorSprite_8(void); void R_DrawTiltedSpan_8(void); void R_DrawTiltedTranslucentSpan_8(void); #ifndef NOWATER @@ -171,8 +174,10 @@ void R_DrawFogSpan_8(void); // Lactozilla: Non-powers-of-two void R_DrawSpan_NPO2_8(void); void R_DrawTranslucentSpan_NPO2_8(void); +void R_DrawFloorSprite_NPO2_8(void); void R_DrawSplat_NPO2_8(void); void R_DrawTranslucentSplat_NPO2_8(void); +void R_DrawTranslucentFloorSprite_NPO2_8(void); void R_DrawTiltedSpan_NPO2_8(void); void R_DrawTiltedTranslucentSpan_NPO2_8(void); #ifndef NOWATER diff --git a/src/r_draw8.c b/src/r_draw8.c index 940ea724b..bc39e91a5 100644 --- a/src/r_draw8.c +++ b/src/r_draw8.c @@ -1419,6 +1419,230 @@ void R_DrawTranslucentSplat_8 (void) } } +/** \brief The R_DrawFloorSprite_8 function + Just like R_DrawSplat_8, but for floor sprites. +*/ +void R_DrawFloorSprite_8 (void) +{ + fixed_t xposition; + fixed_t yposition; + fixed_t xstep, ystep; + + UINT16 *source; + UINT8 *colormap; + UINT8 *translation; + UINT8 *dest; + const UINT8 *deststop = screens[0] + vid.rowbytes * vid.height; + + size_t count = (ds_x2 - ds_x1 + 1); + UINT32 val; + + xposition = ds_xfrac; yposition = ds_yfrac; + xstep = ds_xstep; ystep = ds_ystep; + + // SoM: we only need 6 bits for the integer part (0 thru 63) so the rest + // can be used for the fraction part. This allows calculation of the memory address in the + // texture with two shifts, an OR and one AND. (see below) + // for texture sizes > 64 the amount of precision we can allow will decrease, but only by one + // bit per power of two (obviously) + // Ok, because I was able to eliminate the variable spot below, this function is now FASTER + // than the original span renderer. Whodathunkit? + xposition <<= nflatshiftup; yposition <<= nflatshiftup; + xstep <<= nflatshiftup; ystep <<= nflatshiftup; + + source = (UINT16 *)ds_source; + colormap = ds_colormap; + translation = ds_translation; + dest = ylookup[ds_y] + columnofs[ds_x1]; + + while (count >= 8) + { + // SoM: Why didn't I see this earlier? the spot variable is a waste now because we don't + // have the uber complicated math to calculate it now, so that was a memory write we didn't + // need! + // + // 4194303 = (2048x2048)-1 (2048x2048 is maximum flat size) + val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift); + val &= 4194303; + val = source[val]; + if (val & 0xFF00) + dest[0] = colormap[translation[val & 0xFF]]; + xposition += xstep; + yposition += ystep; + + val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift); + val &= 4194303; + val = source[val]; + if (val & 0xFF00) + dest[1] = colormap[translation[val & 0xFF]]; + xposition += xstep; + yposition += ystep; + + val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift); + val &= 4194303; + val = source[val]; + if (val & 0xFF00) + dest[2] = colormap[translation[val & 0xFF]]; + xposition += xstep; + yposition += ystep; + + val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift); + val &= 4194303; + val = source[val]; + if (val & 0xFF00) + dest[3] = colormap[translation[val & 0xFF]]; + xposition += xstep; + yposition += ystep; + + val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift); + val &= 4194303; + val = source[val]; + if (val & 0xFF00) + dest[4] = colormap[translation[val & 0xFF]]; + xposition += xstep; + yposition += ystep; + + val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift); + val &= 4194303; + val = source[val]; + if (val & 0xFF00) + dest[5] = colormap[translation[val & 0xFF]]; + xposition += xstep; + yposition += ystep; + + val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift); + val &= 4194303; + val = source[val]; + if (val & 0xFF00) + dest[6] = colormap[translation[val & 0xFF]]; + xposition += xstep; + yposition += ystep; + + val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift); + val &= 4194303; + val = source[val]; + if (val & 0xFF00) + dest[7] = colormap[translation[val & 0xFF]]; + xposition += xstep; + yposition += ystep; + + dest += 8; + count -= 8; + } + while (count-- && dest <= deststop) + { + val = source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]; + if (val & 0xFF00) + *dest = colormap[translation[val & 0xFF]]; + dest++; + xposition += xstep; + yposition += ystep; + } +} + +/** \brief The R_DrawTranslucentFloorSplat_8 function + Just like R_DrawFloorSprite_8, but is translucent! +*/ +void R_DrawTranslucentFloorSprite_8 (void) +{ + fixed_t xposition; + fixed_t yposition; + fixed_t xstep, ystep; + + UINT16 *source; + UINT8 *colormap; + UINT8 *translation; + UINT8 *dest; + const UINT8 *deststop = screens[0] + vid.rowbytes * vid.height; + + size_t count = (ds_x2 - ds_x1 + 1); + UINT32 val; + + xposition = ds_xfrac; yposition = ds_yfrac; + xstep = ds_xstep; ystep = ds_ystep; + + // SoM: we only need 6 bits for the integer part (0 thru 63) so the rest + // can be used for the fraction part. This allows calculation of the memory address in the + // texture with two shifts, an OR and one AND. (see below) + // for texture sizes > 64 the amount of precision we can allow will decrease, but only by one + // bit per power of two (obviously) + // Ok, because I was able to eliminate the variable spot below, this function is now FASTER + // than the original span renderer. Whodathunkit? + xposition <<= nflatshiftup; yposition <<= nflatshiftup; + xstep <<= nflatshiftup; ystep <<= nflatshiftup; + + source = (UINT16 *)ds_source; + colormap = ds_colormap; + translation = ds_translation; + dest = ylookup[ds_y] + columnofs[ds_x1]; + + while (count >= 8) + { + // SoM: Why didn't I see this earlier? the spot variable is a waste now because we don't + // have the uber complicated math to calculate it now, so that was a memory write we didn't + // need! + val = source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]; + if (val & 0xFF00) + dest[0] = *(ds_transmap + (colormap[translation[val & 0xFF]] << 8) + dest[0]); + xposition += xstep; + yposition += ystep; + + val = source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]; + if (val & 0xFF00) + dest[1] = *(ds_transmap + (colormap[translation[val & 0xFF]] << 8) + dest[1]); + xposition += xstep; + yposition += ystep; + + val = source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]; + if (val & 0xFF00) + dest[2] = *(ds_transmap + (colormap[translation[val & 0xFF]] << 8) + dest[2]); + xposition += xstep; + yposition += ystep; + + val = source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]; + if (val & 0xFF00) + dest[3] = *(ds_transmap + (colormap[translation[val & 0xFF]] << 8) + dest[3]); + xposition += xstep; + yposition += ystep; + + val = source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]; + if (val & 0xFF00) + dest[4] = *(ds_transmap + (colormap[translation[val & 0xFF]] << 8) + dest[4]); + xposition += xstep; + yposition += ystep; + + val = source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]; + if (val & 0xFF00) + dest[5] = *(ds_transmap + (colormap[translation[val & 0xFF]] << 8) + dest[5]); + xposition += xstep; + yposition += ystep; + + val = source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]; + if (val & 0xFF00) + dest[6] = *(ds_transmap + (colormap[translation[val & 0xFF]] << 8) + dest[6]); + xposition += xstep; + yposition += ystep; + + val = source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]; + if (val & 0xFF00) + dest[7] = *(ds_transmap + (colormap[translation[val & 0xFF]] << 8) + dest[7]); + xposition += xstep; + yposition += ystep; + + dest += 8; + count -= 8; + } + while (count-- && dest <= deststop) + { + val = source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]; + if (val & 0xFF00) + *dest = *(ds_transmap + (colormap[translation[val & 0xFF]] << 8) + *dest); + dest++; + xposition += xstep; + yposition += ystep; + } +} + /** \brief The R_DrawTranslucentSpan_8 function Draws the actual span with translucency. */ diff --git a/src/r_draw8_npo2.c b/src/r_draw8_npo2.c index 020155694..087a8d30c 100644 --- a/src/r_draw8_npo2.c +++ b/src/r_draw8_npo2.c @@ -754,6 +754,104 @@ void R_DrawTranslucentSplat_NPO2_8 (void) } } +/** \brief The R_DrawFloorSprite_NPO2_8 function + Just like R_DrawSplat_NPO2_8, but for floor sprites. +*/ +void R_DrawFloorSprite_NPO2_8 (void) +{ + fixed_t xposition; + fixed_t yposition; + fixed_t xstep, ystep; + + UINT16 *source; + UINT8 *translation; + UINT8 *colormap; + UINT8 *dest; + const UINT8 *deststop = screens[0] + vid.rowbytes * vid.height; + + size_t count = (ds_x2 - ds_x1 + 1); + UINT32 val; + + xposition = ds_xfrac; yposition = ds_yfrac; + xstep = ds_xstep; ystep = ds_ystep; + + source = (UINT16 *)ds_source; + colormap = ds_colormap; + translation = ds_translation; + dest = ylookup[ds_y] + columnofs[ds_x1]; + + while (count-- && dest <= deststop) + { + fixed_t x = (xposition >> FRACBITS); + fixed_t y = (yposition >> FRACBITS); + + // Carefully align all of my Friends. + if (x < 0) + x = ds_flatwidth - ((UINT32)(ds_flatwidth - x) % ds_flatwidth); + if (y < 0) + y = ds_flatheight - ((UINT32)(ds_flatheight - y) % ds_flatheight); + + x %= ds_flatwidth; + y %= ds_flatheight; + + val = source[((y * ds_flatwidth) + x)]; + if (val & 0xFF00) + *dest = colormap[translation[val & 0xFF]]; + dest++; + xposition += xstep; + yposition += ystep; + } +} + +/** \brief The R_DrawTranslucentFloorSprite_NPO2_8 function + Just like R_DrawFloorSprite_NPO2_8, but is translucent! +*/ +void R_DrawTranslucentFloorSprite_NPO2_8 (void) +{ + fixed_t xposition; + fixed_t yposition; + fixed_t xstep, ystep; + + UINT16 *source; + UINT8 *translation; + UINT8 *colormap; + UINT8 *dest; + const UINT8 *deststop = screens[0] + vid.rowbytes * vid.height; + + size_t count = (ds_x2 - ds_x1 + 1); + UINT32 val; + + xposition = ds_xfrac; yposition = ds_yfrac; + xstep = ds_xstep; ystep = ds_ystep; + + source = (UINT16 *)ds_source; + colormap = ds_colormap; + translation = ds_translation; + dest = ylookup[ds_y] + columnofs[ds_x1]; + + while (count-- && dest <= deststop) + { + fixed_t x = (xposition >> FRACBITS); + fixed_t y = (yposition >> FRACBITS); + + // Carefully align all of my Friends. + if (x < 0) + x = ds_flatwidth - ((UINT32)(ds_flatwidth - x) % ds_flatwidth); + if (y < 0) + y = ds_flatheight - ((UINT32)(ds_flatheight - y) % ds_flatheight); + + x %= ds_flatwidth; + y %= ds_flatheight; + + val = source[((y * ds_flatwidth) + x)]; + if (val & 0xFF00) + *dest = *(ds_transmap + (colormap[translation[val & 0xFF]] << 8) + *dest); + dest++; + xposition += xstep; + yposition += ystep; + } +} + /** \brief The R_DrawTranslucentSpan_NPO2_8 function Draws the actual span with translucency. */ diff --git a/src/r_main.c b/src/r_main.c index 3568e2116..03f9c6818 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -1472,9 +1472,6 @@ void R_RenderPlayerView(player_t *player) } R_ClearDrawSegs(); R_ClearSprites(); -#ifdef FLOORSPLATS - R_ClearVisibleFloorSplats(); -#endif Portal_InitList(); // check for new console commands. @@ -1555,9 +1552,6 @@ void R_RenderPlayerView(player_t *player) rs_sw_planetime = I_GetTimeMicros(); R_DrawPlanes(); -#ifdef FLOORSPLATS - R_DrawVisibleFloorSplats(); -#endif rs_sw_planetime = I_GetTimeMicros() - rs_sw_planetime; // draw mid texture and sprite diff --git a/src/r_patch.c b/src/r_patch.c index 9ca04dd55..9b1e7d1b8 100644 --- a/src/r_patch.c +++ b/src/r_patch.c @@ -11,6 +11,7 @@ #include "doomdef.h" #include "r_patch.h" +#include "r_picformats.h" #include "r_defs.h" #include "z_zone.h" @@ -66,18 +67,25 @@ patch_t *Patch_Create(softwarepatch_t *source, size_t srcsize, void *dest) static void Patch_FreeData(patch_t *patch) { + INT32 i; + #ifdef HWRENDER if (patch->hardware) HWR_FreeTexture(patch); #endif + for (i = 0; i < 2; i++) + { + if (patch->flats[i]) + Patch_Free(patch->flats[i]); + } + #ifdef ROTSPRITE if (patch->rotated) { rotsprite_t *rotsprite = patch->rotated; - INT32 i = 0; - for (; i < rotsprite->angles; i++) + for (i = 0; i < rotsprite->angles; i++) { if (rotsprite->patches[i]) Patch_Free(rotsprite->patches[i]); @@ -116,6 +124,13 @@ void Patch_FreeTags(INT32 lowtag, INT32 hightag) Z_IterateTags(lowtag, hightag, Patch_FreeTagsCallback); } +void Patch_GenerateFlat(patch_t *patch, pictureflags_t flags) +{ + UINT8 flip = (flags & (PICFLAGS_XFLIP | PICFLAGS_YFLIP)); + if (patch->flats[flip] == NULL) + patch->flats[flip] = Picture_Convert(PICFMT_PATCH, patch, PICFMT_FLAT16, 0, NULL, 0, 0, 0, 0, flags); +} + #ifdef HWRENDER // // Allocates a hardware patch. diff --git a/src/r_patch.h b/src/r_patch.h index 6991d3637..32bcb3909 100644 --- a/src/r_patch.h +++ b/src/r_patch.h @@ -13,6 +13,7 @@ #define __R_PATCH__ #include "r_defs.h" +#include "r_picformats.h" #include "doomdef.h" // Patch functions @@ -22,6 +23,8 @@ void Patch_Free(patch_t *patch); #define Patch_FreeTag(tagnum) Patch_FreeTags(tagnum, tagnum) void Patch_FreeTags(INT32 lowtag, INT32 hightag); +void Patch_GenerateFlat(patch_t *patch, pictureflags_t flags); + #ifdef HWRENDER void *Patch_AllocateHardwarePatch(patch_t *patch); void *Patch_CreateGL(patch_t *patch); @@ -30,7 +33,12 @@ void *Patch_CreateGL(patch_t *patch); #ifdef ROTSPRITE void Patch_Rotate(patch_t *patch, INT32 angle, INT32 xpivot, INT32 ypivot, boolean flip); patch_t *Patch_GetRotated(patch_t *patch, INT32 angle, boolean flip); -patch_t *Patch_GetRotatedSprite(spriteframe_t *sprite, size_t frame, size_t spriteangle, boolean flip, void *info, INT32 rotationangle);INT32 R_GetRollAngle(angle_t rollangle); +patch_t *Patch_GetRotatedSprite( + spriteframe_t *sprite, + size_t frame, size_t spriteangle, + boolean flip, boolean adjustfeet, + void *info, INT32 rotationangle); +INT32 R_GetRollAngle(angle_t rollangle); #endif #endif // __R_PATCH__ diff --git a/src/r_patchrotation.c b/src/r_patchrotation.c index 98e3a7687..123c4eef2 100644 --- a/src/r_patchrotation.c +++ b/src/r_patchrotation.c @@ -41,19 +41,26 @@ patch_t *Patch_GetRotated(patch_t *patch, INT32 angle, boolean flip) return rotsprite->patches[angle]; } -patch_t *Patch_GetRotatedSprite(spriteframe_t *sprite, size_t frame, size_t spriteangle, boolean flip, void *info, INT32 rotationangle) +patch_t *Patch_GetRotatedSprite( + spriteframe_t *sprite, + size_t frame, size_t spriteangle, + boolean flip, boolean adjustfeet, + void *info, INT32 rotationangle) { - rotsprite_t *rotsprite = sprite->rotated[spriteangle]; + rotsprite_t *rotsprite; spriteinfo_t *sprinfo = (spriteinfo_t *)info; INT32 idx = rotationangle; + UINT8 type = (adjustfeet ? 1 : 0); if (rotationangle < 1 || rotationangle >= ROTANGLES) return NULL; + rotsprite = sprite->rotated[type][spriteangle]; + if (rotsprite == NULL) { rotsprite = RotatedPatch_Create(ROTANGLES); - sprite->rotated[spriteangle] = rotsprite; + sprite->rotated[type][spriteangle] = rotsprite; } if (flip) @@ -84,7 +91,8 @@ patch_t *Patch_GetRotatedSprite(spriteframe_t *sprite, size_t frame, size_t spri RotatedPatch_DoRotation(rotsprite, patch, rotationangle, xpivot, ypivot, flip); //BP: we cannot use special tric in hardware mode because feet in ground caused by z-buffer - ((patch_t *)rotsprite->patches[idx])->topoffset += FEETADJUST>>FRACBITS; + if (adjustfeet) + ((patch_t *)rotsprite->patches[idx])->topoffset += FEETADJUST>>FRACBITS; } return rotsprite->patches[idx]; diff --git a/src/r_plane.c b/src/r_plane.c index 6c238896c..797919a9f 100644 --- a/src/r_plane.c +++ b/src/r_plane.c @@ -745,6 +745,7 @@ void R_DrawSinglePlane(visplane_t *pl) ffloor_t *rover; int type; int spanfunctype = BASEDRAWFUNC; + angle_t viewang = viewangle; if (!(pl->minx <= pl->maxx)) return; @@ -871,20 +872,6 @@ void R_DrawSinglePlane(visplane_t *pl) light = (pl->lightlevel >> LIGHTSEGSHIFT); } - if (!pl->slope // Don't mess with angle on slopes! We'll handle this ourselves later - && viewangle != pl->viewangle+pl->plangle) - { - memset(cachedheight, 0, sizeof (cachedheight)); - angle = (pl->viewangle+pl->plangle-ANGLE_90)>>ANGLETOFINESHIFT; - basexscale = FixedDiv(FINECOSINE(angle),centerxfrac); - baseyscale = -FixedDiv(FINESINE(angle),centerxfrac); - viewangle = pl->viewangle+pl->plangle; - } - - xoffs = pl->xoffs; - yoffs = pl->yoffs; - planeheight = abs(pl->height - pl->viewz); - currentplane = pl; levelflat = &levelflats[pl->picnum]; @@ -909,6 +896,20 @@ void R_DrawSinglePlane(visplane_t *pl) R_CheckFlatLength(ds_flatwidth * ds_flatheight); } + if (!pl->slope // Don't mess with angle on slopes! We'll handle this ourselves later + && viewangle != pl->viewangle+pl->plangle) + { + memset(cachedheight, 0, sizeof (cachedheight)); + angle = (pl->viewangle+pl->plangle-ANGLE_90)>>ANGLETOFINESHIFT; + basexscale = FixedDiv(FINECOSINE(angle),centerxfrac); + baseyscale = -FixedDiv(FINESINE(angle),centerxfrac); + viewangle = pl->viewangle+pl->plangle; + } + + xoffs = pl->xoffs; + yoffs = pl->yoffs; + planeheight = abs(pl->height - pl->viewz); + if (light >= LIGHTLEVELS) light = LIGHTLEVELS-1; @@ -1121,6 +1122,8 @@ using the palette colors. } } #endif + + viewangle = viewang; } void R_PlaneBounds(visplane_t *plane) diff --git a/src/r_segs.c b/src/r_segs.c index 177827892..77425d345 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -63,170 +63,6 @@ static lighttable_t **walllights; static INT16 *maskedtexturecol; static fixed_t *maskedtextureheight = NULL; -// ========================================================================== -// R_Splats Wall Splats Drawer -// ========================================================================== - -#ifdef WALLSPLATS -static INT16 last_ceilingclip[MAXVIDWIDTH]; -static INT16 last_floorclip[MAXVIDWIDTH]; - -static void R_DrawSplatColumn(column_t *column) -{ - INT32 topscreen, bottomscreen; - fixed_t basetexturemid; - INT32 topdelta, prevdelta = -1; - - basetexturemid = dc_texturemid; - - for (; column->topdelta != 0xff ;) - { - // calculate unclipped screen coordinates for post - topdelta = column->topdelta; - if (topdelta <= prevdelta) - topdelta += prevdelta; - prevdelta = topdelta; - topscreen = sprtopscreen + spryscale*topdelta; - bottomscreen = topscreen + spryscale*column->length; - - dc_yl = (topscreen+FRACUNIT-1)>>FRACBITS; - dc_yh = (bottomscreen-1)>>FRACBITS; - - if (dc_yh >= last_floorclip[dc_x]) - dc_yh = last_floorclip[dc_x] - 1; - if (dc_yl <= last_ceilingclip[dc_x]) - dc_yl = last_ceilingclip[dc_x] + 1; - if (dc_yl <= dc_yh && dl_yh < vid.height && yh > 0) - { - dc_source = (UINT8 *)column + 3; - dc_texturemid = basetexturemid - (topdelta<length + 4); - } - - dc_texturemid = basetexturemid; -} - -static void R_DrawWallSplats(void) -{ - wallsplat_t *splat; - seg_t *seg; - angle_t angle, angle1, angle2; - INT32 x1, x2; - size_t pindex; - column_t *col; - patch_t *patch; - fixed_t texturecolumn; - - splat = (wallsplat_t *)linedef->splats; - - I_Assert(splat != NULL); - - seg = ds_p->curline; - - // draw all splats from the line that touches the range of the seg - for (; splat; splat = splat->next) - { - angle1 = R_PointToAngle(splat->v1.x, splat->v1.y); - angle2 = R_PointToAngle(splat->v2.x, splat->v2.y); - angle1 = (angle1 - viewangle + ANGLE_90)>>ANGLETOFINESHIFT; - angle2 = (angle2 - viewangle + ANGLE_90)>>ANGLETOFINESHIFT; - // out of the viewangletox lut - /// \todo clip it to the screen - if (angle1 > FINEANGLES/2 || angle2 > FINEANGLES/2) - continue; - x1 = viewangletox[angle1]; - x2 = viewangletox[angle2]; - - if (x1 >= x2) - continue; // does not cross a pixel - - // splat is not in this seg range - if (x2 < ds_p->x1 || x1 > ds_p->x2) - continue; - - if (x1 < ds_p->x1) - x1 = ds_p->x1; - if (x2 > ds_p->x2) - x2 = ds_p->x2; - if (x2 <= x1) - continue; - - // calculate incremental stepping values for texture edges - rw_scalestep = ds_p->scalestep; - spryscale = ds_p->scale1 + (x1 - ds_p->x1)*rw_scalestep; - mfloorclip = floorclip; - mceilingclip = ceilingclip; - - patch = W_CachePatchNum(splat->patch, PU_PATCH); - - dc_texturemid = splat->top + (SHORT(patch->height)<<(FRACBITS-1)) - viewz; - if (splat->yoffset) - dc_texturemid += *splat->yoffset; - - sprtopscreen = centeryfrac - FixedMul(dc_texturemid, spryscale); - - // set drawing mode - switch (splat->flags & SPLATDRAWMODE_MASK) - { - case SPLATDRAWMODE_OPAQUE: - colfunc = colfuncs[BASEDRAWFUNC]; - break; - case SPLATDRAWMODE_TRANS: - if (!cv_translucency.value) - colfunc = colfuncs[BASEDRAWFUNC]; - else - { - dc_transmap = transtables + ((tr_trans50 - 1)<>LIGHTSCALESHIFT; - if (pindex >= MAXLIGHTSCALE) - pindex = MAXLIGHTSCALE - 1; - dc_colormap = walllights[pindex]; - - if (frontsector->extra_colormap) - dc_colormap = frontsector->extra_colormap->colormap + (dc_colormap - colormaps); - - sprtopscreen = centeryfrac - FixedMul(dc_texturemid, spryscale); - dc_iscale = 0xffffffffu / (unsigned)spryscale; - - // find column of patch, from perspective - angle = (rw_centerangle + xtoviewangle[dc_x])>>ANGLETOFINESHIFT; - texturecolumn = rw_offset2 - splat->offset - - FixedMul(FINETANGENT(angle), rw_distance); - - // FIXME! - texturecolumn >>= FRACBITS; - if (texturecolumn < 0 || texturecolumn >= SHORT(patch->width)) - continue; - - // draw the texture - col = (column_t *)((UINT8 *)patch->columns + (patch->columnofs[texturecolumn])); - R_DrawSplatColumn(col); - } - } // next splat - - colfunc = colfuncs[BASEDRAWFUNC]; -} - -#endif //WALLSPLATS - // ========================================================================== // R_RenderMaskedSegRange // ========================================================================== @@ -2786,20 +2622,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) } } -#ifdef WALLSPLATS - if (linedef->splats && cv_splats.value) - { - // Isn't a bit wasteful to copy the ENTIRE array for every drawseg? - M_Memcpy(last_ceilingclip + ds_p->x1, ceilingclip + ds_p->x1, - sizeof (INT16) * (ds_p->x2 - ds_p->x1 + 1)); - M_Memcpy(last_floorclip + ds_p->x1, floorclip + ds_p->x1, - sizeof (INT16) * (ds_p->x2 - ds_p->x1 + 1)); - R_RenderSegLoop(); - R_DrawWallSplats(); - } - else -#endif - R_RenderSegLoop(); + R_RenderSegLoop(); colfunc = colfuncs[BASEDRAWFUNC]; if (portalline) // if curline is a portal, set portalrender for drawseg diff --git a/src/r_splats.c b/src/r_splats.c index dfec185a1..0b2826107 100644 --- a/src/r_splats.c +++ b/src/r_splats.c @@ -8,459 +8,253 @@ // See the 'LICENSE' file for more details. //----------------------------------------------------------------------------- /// \file r_splats.c -/// \brief floor and wall splats +/// \brief Floor splats #include "r_draw.h" #include "r_main.h" -#include "r_plane.h" #include "r_splats.h" +#include "r_bsp.h" #include "w_wad.h" #include "z_zone.h" -#include "d_netcmd.h" -#ifdef WALLSPLATS -static wallsplat_t wallsplats[MAXLEVELSPLATS]; // WALL splats -static INT32 freewallsplat; -#endif - -#ifdef USEASM -/// \brief for floorsplats \note accessed by asm code -struct rastery_s *prastertab; -#endif +struct rastery_s *prastertab; // for ASM code #ifdef FLOORSPLATS -static floorsplat_t floorsplats[1]; // FLOOR splats -static INT32 freefloorsplat; - -struct rastery_s -{ - fixed_t minx, maxx; // for each raster line starting at line 0 - fixed_t tx1, ty1; - fixed_t tx2, ty2; // start/end points in texture at this line -}; static struct rastery_s rastertab[MAXVIDHEIGHT]; - static void prepare_rastertab(void); -#endif -// -------------------------------------------------------------------------- -// setup splat cache -// -------------------------------------------------------------------------- -void R_ClearLevelSplats(void) -{ -#ifdef WALLSPLATS - freewallsplat = 0; - memset(wallsplats, 0, sizeof (wallsplats)); -#endif -#ifdef FLOORSPLATS - freefloorsplat = 0; - memset(floorsplats, 0, sizeof (floorsplats)); - - // setup to draw floorsplats - prastertab = rastertab; - prepare_rastertab(); -#endif -} - -// ========================================================================== -// WALL SPLATS -// ========================================================================== -#ifdef WALLSPLATS -// -------------------------------------------------------------------------- -// Return a pointer to a splat free for use, or NULL if no more splats are -// available -// -------------------------------------------------------------------------- -static wallsplat_t *R_AllocWallSplat(void) -{ - wallsplat_t *splat; - wallsplat_t *p_splat; - line_t *li; - - // clear the splat from the line if it was in use - splat = &wallsplats[freewallsplat]; - li = splat->line; - if (li) - { - // remove splat from line splats list - if (li->splats == splat) - li->splats = splat->next; // remove from head - else - { - I_Assert(li->splats != NULL); - for (p_splat = li->splats; p_splat->next; p_splat = p_splat->next) - if (p_splat->next == splat) - { - p_splat->next = splat->next; - break; - } - } - } - - memset(splat, 0, sizeof (wallsplat_t)); - - // for next allocation - freewallsplat++; - if (freewallsplat >= 20) - freewallsplat = 0; - - return splat; -} - -// Add a new splat to the linedef: -// top: top z coord -// wallfrac: frac along the linedef vector (0 to FRACUNIT) -// splatpatchname: name of patch to draw -void R_AddWallSplat(line_t *wallline, INT16 sectorside, const char *patchname, fixed_t top, - fixed_t wallfrac, INT32 flags) -{ - fixed_t fracsplat, linelength; - wallsplat_t *splat = NULL; - wallsplat_t *p_splat; - patch_t *patch; - sector_t *backsector = NULL; - - if (W_CheckNumForName(patchname) != LUMPERROR) - splat = R_AllocWallSplat(); - if (!splat) - return; - - // set the splat - splat->patch = W_GetNumForName(patchname); - sectorside ^= 1; - if (wallline->sidenum[sectorside] != 0xffff) - { - backsector = sides[wallline->sidenum[sectorside]].sector; - - if (top < backsector->floorheight) - { - splat->yoffset = &backsector->floorheight; - top -= backsector->floorheight; - } - else if (top > backsector->ceilingheight) - { - splat->yoffset = &backsector->ceilingheight; - top -= backsector->ceilingheight; - } - } - - splat->top = top; - splat->flags = flags; - - // bad.. but will be needed for drawing anyway.. - patch = W_CachePatchNum(splat->patch, PU_PATCH); - - // offset needed by draw code for texture mapping - linelength = P_SegLength((seg_t *)wallline); - splat->offset = FixedMul(wallfrac, linelength) - (SHORT(patch->width)<<(FRACBITS-1)); - fracsplat = FixedDiv(((SHORT(patch->width)<>1), linelength); - - wallfrac -= fracsplat; - if (wallfrac > linelength) - return; - splat->v1.x = wallline->v1->x + FixedMul(wallline->dx, wallfrac); - splat->v1.y = wallline->v1->y + FixedMul(wallline->dy, wallfrac); - wallfrac += fracsplat + fracsplat; - if (wallfrac < 0) - return; - splat->v2.x = wallline->v1->x + FixedMul(wallline->dx, wallfrac); - splat->v2.y = wallline->v1->y + FixedMul(wallline->dy, wallfrac); - - if (wallline->frontsector && wallline->frontsector == backsector) - return; - - // insert splat in the linedef splat list - // BP: why not insert in head is much more simple? - // BP: because for remove it is more simple! - splat->line = wallline; - splat->next = NULL; - if (wallline->splats) - { - p_splat = wallline->splats; - while (p_splat->next) - p_splat = p_splat->next; - p_splat->next = splat; - } - else - wallline->splats = splat; -} -#endif // WALLSPLATS +UINT8 ds_splatclip[MAXVIDWIDTH]; // ========================================================================== // FLOOR SPLATS // ========================================================================== -#ifdef FLOORSPLATS -// -------------------------------------------------------------------------- -// Return a pointer to a splat free for use, or NULL if no more splats are -// available -// -------------------------------------------------------------------------- -static floorsplat_t *R_AllocFloorSplat(void) +#ifdef USEASM +void ASMCALL rasterize_segment_tex_asm(INT32 x1, INT32 y1, INT32 x2, INT32 y2, INT32 tv1, INT32 tv2, INT32 tc, INT32 dir); +#endif + +// Lactozilla +static void rasterize_segment_tex(INT32 x1, INT32 y1, INT32 x2, INT32 y2, INT32 tv1, INT32 tv2, INT32 tc, INT32 dir) { - floorsplat_t *splat; - floorsplat_t *p_splat; - subsector_t *sub; - - // find splat to use - freefloorsplat++; - if (freefloorsplat >= 1) - freefloorsplat = 0; - - // clear the splat from the line if it was in use - splat = &floorsplats[freefloorsplat]; - sub = splat->subsector; - if (sub) +#ifdef USEASM + if (R_ASM) { - // remove splat from subsector splats list - if (sub->splats == splat) - sub->splats = splat->next; // remove from head + rasterize_segment_tex_asm(x1, y1, x2, y2, tv1, tv2, tc, dir); + return; + } + else +#endif + { + fixed_t xs, xe, count; + fixed_t dx0, dx1; + + if (y1 == y2) + return; + + if (y2 > y1) + { + count = (y2-y1)+1; + + dx0 = FixedDiv((x2-x1)<splats; - while (p_splat->next) + count = (y1-y2)+1; + + dx0 = FixedDiv((x1-x2)<next == splat) - p_splat->next = splat->next; + for (;;) + { + rastertab[y2].minx = xs; + rastertab[y2].tx1 = xe; + rastertab[y2].ty1 = tc; + + xs += dx0; + xe += dx1; + y2++; + + if (count-- < 1) break; + } + } + else + { + for (;;) + { + rastertab[y2].minx = xs; + rastertab[y2].tx1 = tc; + rastertab[y2].ty1 = xe; + + xs += dx0; + xe += dx1; + y2++; + + if (count-- < 1) break; + } } } } - - memset(splat, 0, sizeof (floorsplat_t)); - return splat; } -// -------------------------------------------------------------------------- -// Add a floor splat to the subsector -// -------------------------------------------------------------------------- -void R_AddFloorSplat(subsector_t *subsec, mobj_t *mobj, const char *picname, fixed_t x, fixed_t y, fixed_t z, - INT32 flags) -{ - floorsplat_t *splat = NULL; - floorsplat_t *p_splat; - INT32 size; - - if (W_CheckNumForName(picname) != LUMPERROR) - splat = R_AllocFloorSplat(); - if (!splat) - return; - - // set the splat - splat->pic = W_GetNumForName(picname); - splat->flags = flags; - splat->mobj = mobj; - - splat->z = z; - - size = W_LumpLength(splat->pic); - - switch (size) - { - case 4194304: // 2048x2048 lump - splat->size = 1024; - break; - case 1048576: // 1024x1024 lump - splat->size = 512; - break; - case 262144:// 512x512 lump - splat->size = 256; - break; - case 65536: // 256x256 lump - splat->size = 128; - break; - case 16384: // 128x128 lump - splat->size = 64; - break; - case 1024: // 32x32 lump - splat->size = 16; - break; - default: // 64x64 lump - splat->size = 32; - break; - } - - // 3--2 - // | | - // 0--1 - // - splat->verts[0].x = splat->verts[3].x = x - (splat->size<verts[2].x = splat->verts[1].x = x + ((splat->size-1)<verts[3].y = splat->verts[2].y = y + ((splat->size-1)<verts[0].y = splat->verts[1].y = y - (splat->size<subsector = subsec; - splat->next = NULL; - if (subsec->splats) - { - p_splat = subsec->splats; - while (p_splat->next) - p_splat = p_splat->next; - p_splat->next = splat; - } - else - subsec->splats = splat; -} - -// -------------------------------------------------------------------------- -// Before each frame being rendered, clear the visible floorsplats list -// -------------------------------------------------------------------------- -static floorsplat_t *visfloorsplats; - -void R_ClearVisibleFloorSplats(void) -{ - visfloorsplats = NULL; -} - -// -------------------------------------------------------------------------- -// Add a floorsplat to the visible floorsplats list, for the current frame -// -------------------------------------------------------------------------- -void R_AddVisibleFloorSplats(subsector_t *subsec) -{ - floorsplat_t *pSplat; - I_Assert(subsec->splats != NULL); - - pSplat = subsec->splats; - // the splat is not visible from below - // FIXME: depending on some flag in pSplat->flags, some splats may be visible from 2 sides - // (above/below) - if (pSplat->z < viewz) - { - pSplat->nextvis = visfloorsplats; - visfloorsplats = pSplat; - } - - while (pSplat->next) - { - pSplat = pSplat->next; - if (pSplat->z < viewz) - { - pSplat->nextvis = visfloorsplats; - visfloorsplats = pSplat; - } - } -} - -#ifdef USEASM -// tv1, tv2 = x/y qui varie dans la texture, tc = x/y qui est constant. -void ASMCALL rasterize_segment_tex(INT32 x1, INT32 y1, INT32 x2, INT32 y2, INT32 tv1, INT32 tv2, - INT32 tc, INT32 dir); -#endif - -// current test with floor tile -//#define FLOORSPLATSOLIDCOLOR - // -------------------------------------------------------------------------- // Rasterize the four edges of a floor splat polygon, // fill the polygon with linear interpolation, call span drawer for each // scan line // -------------------------------------------------------------------------- -static void R_RenderFloorSplat(floorsplat_t *pSplat, vertex_t *verts, UINT8 *pTex) +void R_RenderFloorSplat(floorsplat_t *pSplat, vertex_t *verts, vissprite_t *vis) { // rasterizing - INT32 miny = vid.height + 1, maxy = 0, y, x1, ry1, x2, y2; - fixed_t offsetx, offsety; + INT32 miny = viewheight + 1, maxy = 0, y, x1, ry1, x2, y2, i; + fixed_t offsetx = 0, offsety = 0; + fixed_t step; -#ifdef FLOORSPLATSOLIDCOLOR - UINT8 *pDest; - INT32 tdx, tdy, ty, tx, x; -#else - lighttable_t **planezlight; fixed_t planeheight; + fixed_t xstep, ystep; angle_t angle, planecos, planesin; fixed_t distance, span; - size_t indexr; - INT32 light; -#endif - (void)pTex; - offsetx = pSplat->verts[0].x & ((pSplat->size << FRACBITS)-1); - offsety = pSplat->verts[0].y & ((pSplat->size << FRACBITS)-1); + int spanfunctype = SPANDRAWFUNC_SPRITE; + + prepare_rastertab(); + +#define RASTERPARAMS(vnum1, vnum2, tv1, tv2, tc, dir) \ + x1 = verts[vnum1].x; \ + ry1 = verts[vnum1].y; \ + x2 = verts[vnum2].x; \ + y2 = verts[vnum2].y; \ + if (y2 > ry1) \ + step = FixedDiv(x2-x1, y2-ry1+1); \ + else if (y2 == ry1) \ + step = 0; \ + else \ + step = FixedDiv(x2-x1, ry1-y2+1); \ + if (ry1 < 0) { \ + if (step) { \ + x1 <<= FRACBITS; \ + x1 += (-ry1)*step; \ + x1 >>= FRACBITS; \ + } \ + ry1 = 0; \ + } \ + if (ry1 >= vid.height) { \ + if (step) { \ + x1 <<= FRACBITS; \ + x1 -= (vid.height-1-ry1)*step; \ + x1 >>= FRACBITS; \ + } \ + ry1 = vid.height - 1; \ + } \ + if (y2 < 0) { \ + if (step) { \ + x2 <<= FRACBITS; \ + x2 -= (-y2)*step; \ + x2 >>= FRACBITS; \ + } \ + y2 = 0; \ + } \ + if (y2 >= vid.height) { \ + if (step) { \ + x2 <<= FRACBITS; \ + x2 += (vid.height-1-y2)*step; \ + x2 >>= FRACBITS; \ + } \ + y2 = vid.height - 1; \ + } \ + rasterize_segment_tex(x1, ry1, x2, y2, tv1, tv2, tc, dir); \ + if (ry1 < miny) \ + miny = ry1; \ + if (ry1 > maxy) \ + maxy = ry1; // do segment a -> top of texture - x1 = verts[3].x; - ry1 = verts[3].y; - x2 = verts[2].x; - y2 = verts[2].y; - if (ry1 < 0) - ry1 = 0; - if (ry1 >= vid.height) - ry1 = vid.height - 1; - if (y2 < 0) - y2 = 0; - if (y2 >= vid.height) - y2 = vid.height - 1; - rasterize_segment_tex(x1, ry1, x2, y2, 0, pSplat->size - 1, 0, 0); - if (ry1 < miny) - miny = ry1; - if (ry1 > maxy) - maxy = ry1; - + RASTERPARAMS(3,2,0,pSplat->width-1,0,0); // do segment b -> right side of texture - x1 = x2; - ry1 = y2; - x2 = verts[1].x; - y2 = verts[1].y; - if (ry1 < 0) - ry1 = 0; - if (ry1 >= vid.height) - ry1 = vid.height - 1; - if (y2 < 0) - y2 = 0; - if (y2 >= vid.height) - y2 = vid.height - 1; - rasterize_segment_tex(x1, ry1, x2, y2, 0, pSplat->size - 1, pSplat->size - 1, 1); - if (ry1 < miny) - miny = ry1; - if (ry1 > maxy) - maxy = ry1; - + RASTERPARAMS(2,1,0,pSplat->width-1,pSplat->height-1,0); // do segment c -> bottom of texture - x1 = x2; - ry1 = y2; - x2 = verts[0].x; - y2 = verts[0].y; - if (ry1 < 0) - ry1 = 0; - if (ry1 >= vid.height) - ry1 = vid.height - 1; - if (y2 < 0) - y2 = 0; - if (y2 >= vid.height) - y2 = vid.height - 1; - rasterize_segment_tex(x1, ry1, x2, y2, pSplat->size - 1, 0, pSplat->size - 1, 0); - if (ry1 < miny) - miny = ry1; - if (ry1 > maxy) - maxy = ry1; - + RASTERPARAMS(1,0,pSplat->width-1,0,pSplat->height-1,0); // do segment d -> left side of texture - x1 = x2; - ry1 = y2; - x2 = verts[3].x; - y2 = verts[3].y; - if (ry1 < 0) - ry1 = 0; - if (ry1 >= vid.height) - ry1 = vid.height - 1; - if (y2 < 0) - y2 = 0; - if (y2 >= vid.height) - y2 = vid.height - 1; - rasterize_segment_tex(x1, ry1, x2, y2, pSplat->size - 1, 0, 0, 1); - if (ry1 < miny) - miny = ry1; - if (ry1 > maxy) - maxy = ry1; + RASTERPARAMS(0,3,pSplat->width-1,0,0,1); + + ds_source = pSplat->pic; + ds_flatwidth = pSplat->width; + ds_flatheight = pSplat->height; + + if (R_CheckPowersOfTwo()) + R_CheckFlatLength(ds_flatwidth * ds_flatheight); + + ds_transmap = NULL; + + if (vis->transmap) + { + ds_transmap = vis->transmap; + spanfunctype = SPANDRAWFUNC_TRANSSPRITE; + } + + if (ds_powersoftwo) + spanfunc = spanfuncs[spanfunctype]; + else + spanfunc = spanfuncs_npo2[spanfunctype]; + + if (pSplat->angle) + { + memset(cachedheight, 0, sizeof(cachedheight)); + angle = (viewangle + pSplat->angle - ANGLE_90) >> ANGLETOFINESHIFT; + basexscale = FixedDiv(FINECOSINE(angle), centerxfrac); + baseyscale = -FixedDiv(FINESINE(angle), centerxfrac); + } + else + { + angle = (viewangle - ANGLE_90) >> ANGLETOFINESHIFT; + basexscale = FixedDiv(FINECOSINE(angle), centerxfrac); + baseyscale = -FixedDiv(FINESINE(angle), centerxfrac); + } -#ifndef FLOORSPLATSOLIDCOLOR - // prepare values for all the splat - ds_source = W_CacheLumpNum(pSplat->pic, PU_CACHE); planeheight = abs(pSplat->z - viewz); - light = (pSplat->subsector->sector->lightlevel >> LIGHTSEGSHIFT); - if (light >= LIGHTLEVELS) - light = LIGHTLEVELS - 1; - if (light < 0) - light = 0; - planezlight = zlight[light]; + + if (maxy >= vid.height) + maxy = vid.height-1; for (y = miny; y <= maxy; y++) { @@ -472,7 +266,7 @@ static void R_RenderFloorSplat(floorsplat_t *pSplat, vertex_t *verts, UINT8 *pTe if (x2 >= vid.width) x2 = vid.width - 1; - angle = (currentplane->viewangle + currentplane->plangle)>>ANGLETOFINESHIFT; + angle = (viewangle + pSplat->angle)>>ANGLETOFINESHIFT; planecos = FINECOSINE(angle); planesin = FINESINE(angle); @@ -480,146 +274,115 @@ static void R_RenderFloorSplat(floorsplat_t *pSplat, vertex_t *verts, UINT8 *pTe { cachedheight[y] = planeheight; distance = cacheddistance[y] = FixedMul(planeheight, yslope[y]); - ds_xstep = cachedxstep[y] = FixedMul(distance,basexscale); - ds_ystep = cachedystep[y] = FixedMul(distance,baseyscale); - + xstep = cachedxstep[y] = FixedMul(distance, basexscale); + ystep = cachedystep[y] = FixedMul(distance, baseyscale); + // don't divide by zero if ((span = abs(centery-y))) { - ds_xstep = cachedxstep[y] = FixedMul(planesin, planeheight) / span; - ds_ystep = cachedystep[y] = FixedMul(planecos, planeheight) / span; + xstep = cachedxstep[y] = FixedMul(planesin, planeheight) / span; + ystep = cachedystep[y] = FixedMul(planecos, planeheight) / span; } } else { distance = cacheddistance[y]; - ds_xstep = cachedxstep[y]; - ds_ystep = cachedystep[y]; + xstep = cachedxstep[y]; + ystep = cachedystep[y]; } - ds_xfrac = xoffs + FixedMul(planecos, distance) + (x1 - centerx) * ds_xstep; - ds_yfrac = yoffs - FixedMul(planesin, distance) + (x1 - centerx) * ds_ystep; - ds_xfrac -= offsetx; - ds_yfrac += offsety; + ds_xstep = FixedDiv(xstep, pSplat->xscale); + ds_ystep = FixedDiv(ystep, pSplat->yscale); - indexr = distance >> LIGHTZSHIFT; - if (indexr >= MAXLIGHTZ) - indexr = MAXLIGHTZ - 1; - ds_colormap = planezlight[indexr]; + ds_colormap = vis->colormap; + ds_translation = R_GetSpriteTranslation(vis); + if (ds_translation == NULL) + ds_translation = colormaps; - ds_y = y; - if (x2 >= x1) // sanity check + if (vis->extra_colormap) { - ds_x1 = x1; - ds_x2 = x2; - ds_transmap = transtables + ((tr_trans50-1)<extra_colormap->colormap; + else + ds_colormap = &vis->extra_colormap->colormap[ds_colormap - colormaps]; } - // reset for next calls to edge rasterizer - rastertab[y].minx = INT32_MAX; - rastertab[y].maxx = INT32_MIN; - } - -#else - for (y = miny; y <= maxy; y++) - { - x1 = rastertab[y].minx>>FRACBITS; - x2 = rastertab[y].maxx>>FRACBITS; - if (x1 < 0) - x1 = 0; - if (x2 >= vid.width) - x2 = vid.width - 1; - -// pDest = ylookup[y] + columnofs[x1]; - pDest = &topleft[y*vid.width + x1]; - - x = x2 - x1 + 1; - - // starting point of the texture - tx = rastertab[y].tx1; - ty = rastertab[y].ty1; - - // HORRIBLE BUG!!! - if (x > 0) + if (pSplat->angle) { - tdx = (rastertab[y].tx2 - tx) / x; - tdy = (rastertab[y].ty2 - ty) / x; + // Add the view offset, rotated by the plane angle. + fixed_t a = -pSplat->verts[0].x + viewx; + fixed_t b = -pSplat->verts[0].y + viewy; + angle = (pSplat->angle >> ANGLETOFINESHIFT); + offsetx = FixedMul(a, FINECOSINE(angle)) - FixedMul(b,FINESINE(angle)); + offsety = -FixedMul(a, FINESINE(angle)) - FixedMul(b,FINECOSINE(angle)); + } + else + { + offsetx = viewx - pSplat->verts[0].x; + offsety = pSplat->verts[0].y - viewy; + } - while (x-- > 0) + if (vis != NULL) + { + INT32 xclip; + + mfloorclip = vis->clipbot; + mceilingclip = vis->cliptop; + + R_ClipVisSprite(vis, x1-1, x2+1, drawsegs, NULL); + memset(ds_splatclip, 0, sizeof(ds_splatclip)); + + if (x2 >= x1 && x1 < viewwidth && x1 >= 0) { - *(pDest++) = (UINT8)(y&1); - tx += tdx; - ty += tdy; + for (xclip = x1; xclip <= x2; xclip++) + { + if (y >= mfloorclip[xclip]) + ds_splatclip[xclip] = 1; + } + } + + while (ds_splatclip[x1]) + x1++; + i = x2; + while (i > x1) + { + if (ds_splatclip[i]) + x2 = i-1; + i--; } } - // reinitialise the minimum and maximum for the next approach + ds_xfrac = FixedDiv(offsetx + FixedMul(planecos, distance) + (x1 - centerx) * xstep, pSplat->xscale); + ds_yfrac = FixedDiv(offsety - FixedMul(planesin, distance) + (x1 - centerx) * ystep, pSplat->yscale); + + if (x2 >= x1) + { + ds_y = y; + ds_x1 = x1; + ds_x2 = x2; + spanfunc(); + } + rastertab[y].minx = INT32_MAX; rastertab[y].maxx = INT32_MIN; } -#endif -} -// -------------------------------------------------------------------------- -// R_DrawVisibleFloorSplats -// draw the flat floor/ceiling splats -// -------------------------------------------------------------------------- -void R_DrawVisibleFloorSplats(void) -{ - floorsplat_t *pSplat; - INT32 iCount = 0, i; - fixed_t tr_x, tr_y, rot_x, rot_y, rot_z, xscale, yscale; - vertex_t *v3d; - vertex_t v2d[4]; - - pSplat = visfloorsplats; - while (pSplat) + if (pSplat->angle) { - iCount++; - - // Draw a floor splat - // 3--2 - // | | - // 0--1 - - rot_z = pSplat->z - viewz; - for (i = 0; i < 4; i++) - { - v3d = &pSplat->verts[i]; - - // transform the origin point - tr_x = v3d->x - viewx; - tr_y = v3d->y - viewy; - - // rotation around vertical y axis - rot_x = FixedMul(tr_x, viewsin) - FixedMul(tr_y, viewcos); - rot_y = FixedMul(tr_x, viewcos) + FixedMul(tr_y, viewsin); - - if (rot_y < 4*FRACUNIT) - goto skipit; - - // note: y from view above of map, is distance far away - xscale = FixedDiv(projection, rot_y); - yscale = -FixedDiv(projectiony, rot_y); - - // projection - v2d[i].x = (centerxfrac + FixedMul (rot_x, xscale))>>FRACBITS; - v2d[i].y = (centeryfrac + FixedMul (rot_z, yscale))>>FRACBITS; - } - - R_RenderFloorSplat(pSplat, v2d, NULL); -skipit: - pSplat = pSplat->nextvis; + memset(cachedheight, 0, sizeof(cachedheight)); + angle = (viewangle - ANGLE_90) >> ANGLETOFINESHIFT; + basexscale = FixedDiv(FINECOSINE(angle), centerxfrac); + baseyscale = -FixedDiv(FINESINE(angle), centerxfrac); } } static void prepare_rastertab(void) { - INT32 iLine; - for (iLine = 0; iLine < vid.height; iLine++) + INT32 i; + prastertab = rastertab; + for (i = 0; i < vid.height; i++) { - rastertab[iLine].minx = INT32_MAX; - rastertab[iLine].maxx = INT32_MIN; + rastertab[i].minx = INT32_MAX; + rastertab[i].maxx = INT32_MIN; } } diff --git a/src/r_splats.h b/src/r_splats.h index 4ad893abb..9c01084cf 100644 --- a/src/r_splats.h +++ b/src/r_splats.h @@ -14,68 +14,35 @@ #define __R_SPLATS_H__ #include "r_defs.h" - -//#define WALLSPLATS // comment this out to compile without splat effects -/*#ifdef USEASM -#define FLOORSPLATS -#endif*/ - -#define MAXLEVELSPLATS 1024 - -// splat flags -#define SPLATDRAWMODE_MASK 0x03 // mask to get drawmode from flags -#define SPLATDRAWMODE_OPAQUE 0x00 -#define SPLATDRAWMODE_SHADE 0x01 -#define SPLATDRAWMODE_TRANS 0x02 +#include "r_things.h" // ========================================================================== // DEFINITIONS // ========================================================================== -// WALL SPLATS are patches drawn on top of wall segs -typedef struct wallsplat_s +struct rastery_s { - lumpnum_t patch; // lump id. - vertex_t v1, v2; // vertices along the linedef - fixed_t top; - fixed_t offset; // offset in columns<cut & SC_PRECIP) + && (vis->mobj->flags & (MF_ENEMY|MF_BOSS)) + && (vis->mobj->flags2 & MF2_FRET) + && !(vis->mobj->flags & MF_GRENADEBOUNCE) + && (leveltime & 1)); +} + +UINT8 *R_GetSpriteTranslation(vissprite_t *vis) +{ + if (R_SpriteIsFlashing(vis)) // Bosses "flash" + { + if (vis->mobj->type == MT_CYBRAKDEMON || vis->mobj->colorized) + return R_GetTranslationColormap(TC_ALLWHITE, 0, GTC_CACHE); + else if (vis->mobj->type == MT_METALSONIC_BATTLE) + return R_GetTranslationColormap(TC_METALSONIC, 0, GTC_CACHE); + else + return R_GetTranslationColormap(TC_BOSS, 0, GTC_CACHE); + } + else if (vis->mobj->color && vis->transmap) // Color mapping + { + if (!(vis->cut & SC_PRECIP) && vis->mobj->colorized) + return R_GetTranslationColormap(TC_RAINBOW, vis->mobj->color, GTC_CACHE); + else if (!(vis->cut & SC_PRECIP) + && vis->mobj->player && vis->mobj->player->dashmode >= DASHMODE_THRESHOLD + && (vis->mobj->player->charflags & SF_DASHMODE) + && ((leveltime/2) & 1)) + { + if (vis->mobj->player->charflags & SF_MACHINE) + return R_GetTranslationColormap(TC_DASHMODE, 0, GTC_CACHE); + else + return R_GetTranslationColormap(TC_RAINBOW, vis->mobj->color, GTC_CACHE); + } + else if (!(vis->cut & SC_PRECIP) && vis->mobj->skin && vis->mobj->sprite == SPR_PLAY) // MT_GHOST LOOKS LIKE A PLAYER SO USE THE PLAYER TRANSLATION TABLES. >_> + { + size_t skinnum = (skin_t*)vis->mobj->skin-skins; + return R_GetTranslationColormap((INT32)skinnum, vis->mobj->color, GTC_CACHE); + } + else // Use the defaults + return R_GetTranslationColormap(TC_DEFAULT, vis->mobj->color, GTC_CACHE); + } + else if (vis->mobj->color) + { + // New colormap stuff for skins Tails 06-07-2002 + if (!(vis->cut & SC_PRECIP) && vis->mobj->colorized) + return R_GetTranslationColormap(TC_RAINBOW, vis->mobj->color, GTC_CACHE); + else if (!(vis->cut & SC_PRECIP) + && vis->mobj->player && vis->mobj->player->dashmode >= DASHMODE_THRESHOLD + && (vis->mobj->player->charflags & SF_DASHMODE) + && ((leveltime/2) & 1)) + { + if (vis->mobj->player->charflags & SF_MACHINE) + return R_GetTranslationColormap(TC_DASHMODE, 0, GTC_CACHE); + else + return R_GetTranslationColormap(TC_RAINBOW, vis->mobj->color, GTC_CACHE); + } + else if (!(vis->cut & SC_PRECIP) && vis->mobj->skin && vis->mobj->sprite == SPR_PLAY) // This thing is a player! + { + size_t skinnum = (skin_t*)vis->mobj->skin-skins; + return R_GetTranslationColormap((INT32)skinnum, vis->mobj->color, GTC_CACHE); + } + else // Use the defaults + return R_GetTranslationColormap(TC_DEFAULT, vis->mobj->color, GTC_CACHE); + } + else if (vis->mobj->sprite == SPR_PLAY) // Looks like a player, but doesn't have a color? Get rid of green sonic syndrome. + return R_GetTranslationColormap(TC_DEFAULT, SKINCOLOR_BLUE, GTC_CACHE); + + return NULL; +} + // // R_DrawVisSprite // mfloorclip and mceilingclip should also be set. @@ -770,77 +845,24 @@ static void R_DrawVisSprite(vissprite_t *vis) colfunc = colfuncs[BASEDRAWFUNC]; // hack: this isn't resetting properly somewhere. dc_colormap = vis->colormap; - if (!(vis->cut & SC_PRECIP) && (vis->mobj->flags & (MF_ENEMY|MF_BOSS)) && (vis->mobj->flags2 & MF2_FRET) && !(vis->mobj->flags & MF_GRENADEBOUNCE) && (leveltime & 1)) // Bosses "flash" - { - // translate certain pixels to white - colfunc = colfuncs[COLDRAWFUNC_TRANS]; - if (vis->mobj->type == MT_CYBRAKDEMON || vis->mobj->colorized) - dc_translation = R_GetTranslationColormap(TC_ALLWHITE, 0, GTC_CACHE); - else if (vis->mobj->type == MT_METALSONIC_BATTLE) - dc_translation = R_GetTranslationColormap(TC_METALSONIC, 0, GTC_CACHE); - else - dc_translation = R_GetTranslationColormap(TC_BOSS, 0, GTC_CACHE); - } + dc_translation = R_GetSpriteTranslation(vis); + + if (R_SpriteIsFlashing(vis)) // Bosses "flash" + colfunc = colfuncs[COLDRAWFUNC_TRANS]; // translate certain pixels to white else if (vis->mobj->color && vis->transmap) // Color mapping { colfunc = colfuncs[COLDRAWFUNC_TRANSTRANS]; dc_transmap = vis->transmap; - if (!(vis->cut & SC_PRECIP) && vis->mobj->colorized) - dc_translation = R_GetTranslationColormap(TC_RAINBOW, vis->mobj->color, GTC_CACHE); - else if (!(vis->cut & SC_PRECIP) - && vis->mobj->player && vis->mobj->player->dashmode >= DASHMODE_THRESHOLD - && (vis->mobj->player->charflags & SF_DASHMODE) - && ((leveltime/2) & 1)) - { - if (vis->mobj->player->charflags & SF_MACHINE) - dc_translation = R_GetTranslationColormap(TC_DASHMODE, 0, GTC_CACHE); - else - dc_translation = R_GetTranslationColormap(TC_RAINBOW, vis->mobj->color, GTC_CACHE); - } - else if (!(vis->cut & SC_PRECIP) && vis->mobj->skin && vis->mobj->sprite == SPR_PLAY) // MT_GHOST LOOKS LIKE A PLAYER SO USE THE PLAYER TRANSLATION TABLES. >_> - { - size_t skinnum = (skin_t*)vis->mobj->skin-skins; - dc_translation = R_GetTranslationColormap((INT32)skinnum, vis->mobj->color, GTC_CACHE); - } - else // Use the defaults - dc_translation = R_GetTranslationColormap(TC_DEFAULT, vis->mobj->color, GTC_CACHE); } else if (vis->transmap) { colfunc = colfuncs[COLDRAWFUNC_FUZZY]; dc_transmap = vis->transmap; //Fab : 29-04-98: translucency table } - else if (vis->mobj->color) - { - // translate green skin to another color + else if (vis->mobj->color) // translate green skin to another color colfunc = colfuncs[COLDRAWFUNC_TRANS]; - - // New colormap stuff for skins Tails 06-07-2002 - if (!(vis->cut & SC_PRECIP) && vis->mobj->colorized) - dc_translation = R_GetTranslationColormap(TC_RAINBOW, vis->mobj->color, GTC_CACHE); - else if (!(vis->cut & SC_PRECIP) - && vis->mobj->player && vis->mobj->player->dashmode >= DASHMODE_THRESHOLD - && (vis->mobj->player->charflags & SF_DASHMODE) - && ((leveltime/2) & 1)) - { - if (vis->mobj->player->charflags & SF_MACHINE) - dc_translation = R_GetTranslationColormap(TC_DASHMODE, 0, GTC_CACHE); - else - dc_translation = R_GetTranslationColormap(TC_RAINBOW, vis->mobj->color, GTC_CACHE); - } - else if (!(vis->cut & SC_PRECIP) && vis->mobj->skin && vis->mobj->sprite == SPR_PLAY) // This thing is a player! - { - size_t skinnum = (skin_t*)vis->mobj->skin-skins; - dc_translation = R_GetTranslationColormap((INT32)skinnum, vis->mobj->color, GTC_CACHE); - } - else // Use the defaults - dc_translation = R_GetTranslationColormap(TC_DEFAULT, vis->mobj->color, GTC_CACHE); - } else if (vis->mobj->sprite == SPR_PLAY) // Looks like a player, but doesn't have a color? Get rid of green sonic syndrome. - { colfunc = colfuncs[COLDRAWFUNC_TRANS]; - dc_translation = R_GetTranslationColormap(TC_DEFAULT, SKINCOLOR_BLUE, GTC_CACHE); - } if (vis->extra_colormap) { @@ -923,6 +945,28 @@ static void R_DrawVisSprite(vissprite_t *vis) localcolfunc (column); } } + else if (vis->cut & SC_SHEAR) + { +#ifdef RANGECHECK + pwidth = SHORT(patch->width); +#endif + + // Vertically sheared sprite + for (dc_x = vis->x1; dc_x <= vis->x2; dc_x++, frac += vis->xiscale, dc_texturemid -= vis->shear.tan) + { +#ifdef RANGECHECK + texturecolumn = frac>>FRACBITS; + if (texturecolumn < 0 || texturecolumn >= pwidth) + I_Error("R_DrawSpriteRange: bad texturecolumn at %d from end", vis->x2 - dc_x); + column = (column_t *)((UINT8 *)patch->columns + (patch->columnofs[texturecolumn])); +#else + column = (column_t *)((UINT8 *)patch->columns + (patch->columnofs[frac>>FRACBITS])); +#endif + + sprtopscreen = (centeryfrac - FixedMul(dc_texturemid, spryscale)); + localcolfunc (column); + } + } else { #ifdef RANGECHECK @@ -1217,6 +1261,29 @@ fixed_t R_GetShadowZ(mobj_t *thing, pslope_t **shadowslope) #undef CHECKZ } +static void R_SkewShadowSprite( + mobj_t *thing, pslope_t *groundslope, + fixed_t groundz, INT32 spriteheight, fixed_t scalemul, + fixed_t *shadowyscale, fixed_t *shadowskew) +{ + // haha let's try some dumb stuff + fixed_t xslope, zslope; + angle_t sloperelang = (R_PointToAngle(thing->x, thing->y) - groundslope->xydirection) >> ANGLETOFINESHIFT; + + xslope = FixedMul(FINESINE(sloperelang), groundslope->zdelta); + zslope = FixedMul(FINECOSINE(sloperelang), groundslope->zdelta); + + //CONS_Printf("Shadow is sloped by %d %d\n", xslope, zslope); + + if (viewz < groundz) + *shadowyscale += FixedMul(FixedMul(thing->radius*2 / spriteheight, scalemul), zslope); + else + *shadowyscale -= FixedMul(FixedMul(thing->radius*2 / spriteheight, scalemul), zslope); + + *shadowyscale = abs((*shadowyscale)); + *shadowskew = xslope; +} + static void R_ProjectDropShadow(mobj_t *thing, vissprite_t *vis, fixed_t scale, fixed_t tx, fixed_t tz) { vissprite_t *shadow; @@ -1245,40 +1312,22 @@ static void R_ProjectDropShadow(mobj_t *thing, vissprite_t *vis, fixed_t scale, yscale = FixedDiv(projectiony, tz); shadowxscale = FixedMul(thing->radius*2, scalemul); shadowyscale = FixedMul(FixedMul(thing->radius*2, scalemul), FixedDiv(abs(groundz - viewz), tz)); - shadowyscale = min(shadowyscale, shadowxscale) / SHORT(patch->height); - shadowxscale /= SHORT(patch->width); + shadowyscale = min(shadowyscale, shadowxscale) / patch->height; + shadowxscale /= patch->width; shadowskew = 0; if (groundslope) - { - // haha let's try some dumb stuff - fixed_t xslope, zslope; - angle_t sloperelang = (R_PointToAngle(thing->x, thing->y) - groundslope->xydirection) >> ANGLETOFINESHIFT; + R_SkewShadowSprite(thing, groundslope, groundz, patch->height, scalemul, &shadowyscale, &shadowskew); - xslope = FixedMul(FINESINE(sloperelang), groundslope->zdelta); - zslope = FixedMul(FINECOSINE(sloperelang), groundslope->zdelta); - - //CONS_Printf("Shadow is sloped by %d %d\n", xslope, zslope); - - if (viewz < groundz) - shadowyscale += FixedMul(FixedMul(thing->radius*2 / SHORT(patch->height), scalemul), zslope); - else - shadowyscale -= FixedMul(FixedMul(thing->radius*2 / SHORT(patch->height), scalemul), zslope); - - shadowyscale = abs(shadowyscale); - - shadowskew = xslope; - } - - tx -= SHORT(patch->width) * shadowxscale/2; + tx -= patch->width * shadowxscale/2; x1 = (centerxfrac + FixedMul(tx,xscale))>>FRACBITS; if (x1 >= viewwidth) return; - tx += SHORT(patch->width) * shadowxscale; + tx += patch->width * shadowxscale; x2 = ((centerxfrac + FixedMul(tx,xscale))>>FRACBITS); x2--; if (x2 < 0 || x2 <= x1) return; - if (shadowyscale < FRACUNIT/SHORT(patch->height)) return; // fix some crashes? + if (shadowyscale < FRACUNIT/patch->height) return; // fix some crashes? shadow = R_NewVisSprite(); shadow->patch = patch; @@ -1293,8 +1342,8 @@ static void R_ProjectDropShadow(mobj_t *thing, vissprite_t *vis, fixed_t scale, shadow->dispoffset = vis->dispoffset - 5; shadow->gx = thing->x; shadow->gy = thing->y; - shadow->gzt = (isflipped ? shadow->pzt : shadow->pz) + SHORT(patch->height) * shadowyscale / 2; - shadow->gz = shadow->gzt - SHORT(patch->height) * shadowyscale; + shadow->gzt = (isflipped ? shadow->pzt : shadow->pz) + patch->height * shadowyscale / 2; + shadow->gz = shadow->gzt - patch->height * shadowyscale; shadow->texturemid = FixedMul(thing->scale, FixedDiv(shadow->gzt - viewz, shadowyscale)); if (thing->skin && ((skin_t *)thing->skin)->flags & SF_HIRES) shadow->texturemid = FixedMul(shadow->texturemid, ((skin_t *)thing->skin)->highresscale); @@ -1315,7 +1364,7 @@ static void R_ProjectDropShadow(mobj_t *thing, vissprite_t *vis, fixed_t scale, shadow->startfrac = 0; //shadow->xiscale = 0x7ffffff0 / (shadow->xscale/2); - shadow->xiscale = (SHORT(patch->width)<xiscale = (patch->width<x1 > x1) shadow->startfrac += shadow->xiscale*(shadow->x1-x1); @@ -1374,13 +1423,15 @@ static void R_ProjectSprite(mobj_t *thing) size_t frame, rot; UINT16 flip; - boolean vflip = (!(thing->eflags & MFE_VERTICALFLIP) != !(thing->frame & FF_VERTICALFLIP)); + boolean vflip = (!(thing->eflags & MFE_VERTICALFLIP) != !R_ThingVerticallyFlipped(thing)); boolean mirrored = thing->mirrored; - boolean hflip = (!(thing->frame & FF_HORIZONTALFLIP) != !mirrored); + boolean hflip = (!R_ThingHorizontallyFlipped(thing) != !mirrored); INT32 lindex; + INT32 trans; vissprite_t *vis; + patch_t *patch; spritecut_e cut = SC_NONE; @@ -1389,10 +1440,15 @@ static void R_ProjectSprite(mobj_t *thing) fixed_t scalestep; fixed_t offset, offset2; + fixed_t sheartan = 0; + fixed_t shadowscale = FRACUNIT; fixed_t basetx; // drop shadows - boolean papersprite = !!(thing->frame & FF_PAPERSPRITE); - fixed_t paperoffset = 0, paperdistance = 0; angle_t centerangle = 0; + boolean shadowdraw, shadoweffects, shadowskew; + boolean splat = R_ThingIsFloorSprite(thing); + boolean papersprite = (R_ThingIsPaperSprite(thing) && !splat); + fixed_t paperoffset = 0, paperdistance = 0; + angle_t centerangle = 0; INT32 dispoffset = thing->info->dispoffset; @@ -1401,10 +1457,12 @@ static void R_ProjectSprite(mobj_t *thing) INT32 heightsec, phs; INT32 light = 0; fixed_t this_scale = thing->scale; + fixed_t spritexscale, spriteyscale; // rotsprite fixed_t spr_width, spr_height; fixed_t spr_offset, spr_topoffset; + #ifdef ROTSPRITE patch_t *rotsprite = NULL; INT32 rollangle = 0; @@ -1533,17 +1591,28 @@ static void R_ProjectSprite(mobj_t *thing) spr_offset = spritecachedinfo[lump].offset; spr_topoffset = spritecachedinfo[lump].topoffset; + //Fab: lumppat is the lump number of the patch to use, this is different + // than lumpid for sprites-in-pwad : the graphics are patched + patch = W_CachePatchNum(sprframe->lumppat[rot], PU_SPRITE); + #ifdef ROTSPRITE - if (thing->rollangle) + if (thing->rollangle + && !(splat && !(thing->renderflags & RF_NOSPLATROLLANGLE))) { rollangle = R_GetRollAngle(thing->rollangle); - rotsprite = Patch_GetRotatedSprite(sprframe, (thing->frame & FF_FRAMEMASK), rot, flip, sprinfo, rollangle); + rotsprite = Patch_GetRotatedSprite(sprframe, (thing->frame & FF_FRAMEMASK), rot, flip, false, sprinfo, rollangle); + if (rotsprite != NULL) { - spr_width = SHORT(rotsprite->width) << FRACBITS; - spr_height = SHORT(rotsprite->height) << FRACBITS; - spr_offset = SHORT(rotsprite->leftoffset) << FRACBITS; - spr_topoffset = SHORT(rotsprite->topoffset) << FRACBITS; + patch = rotsprite; + cut |= SC_ISROTATED; + + 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 flip = 0; } @@ -1553,12 +1622,18 @@ static void R_ProjectSprite(mobj_t *thing) flip = !flip != !hflip; // calculate edges of the shape + spritexscale = thing->spritexscale; + spriteyscale = thing->spriteyscale; + if (spritexscale < 1 || spriteyscale < 1) + return; + if (flip) offset = spr_offset - spr_width; else offset = -spr_offset; - offset = FixedMul(offset, this_scale); - offset2 = FixedMul(spr_width, this_scale); + + offset = FixedMul(offset, FixedMul(spritexscale, this_scale)); + offset2 = FixedMul(spr_width, FixedMul(spritexscale, this_scale)); if (papersprite) { @@ -1686,7 +1761,7 @@ static void R_ProjectSprite(mobj_t *thing) dispoffset *= -1; // if it's physically behind, make sure it's ordered behind (if dispoffset > 0) sortscale = linkscale; // now make sure it's linked - cut = SC_LINKDRAW; + cut |= SC_LINKDRAW; } // PORTAL SPRITE CLIPPING @@ -1699,19 +1774,87 @@ static void R_ProjectSprite(mobj_t *thing) return; } - //SoM: 3/17/2000: Disregard sprites that are out of view.. - if (vflip) - { - // When vertical flipped, draw sprites from the top down, at least as far as offsets are concerned. - // sprite height - sprite topoffset is the proper inverse of the vertical offset, of course. - // remember gz and gzt should be seperated by sprite height, not thing height - thing height can be shorter than the sprite itself sometimes! - gz = oldthing->z + oldthing->height - FixedMul(spr_topoffset, this_scale); - gzt = gz + FixedMul(spr_height, this_scale); - } + // Determine the translucency value. + if (oldthing->flags2 & MF2_SHADOW || 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 (oldthing->frame & FF_TRANSMASK) + trans = (oldthing->frame & FF_TRANSMASK) >> FF_TRANSSHIFT; else + trans = 0; + + // Check if this sprite needs to be rendered like a shadow + shadowdraw = (!!(thing->renderflags & RF_SHADOWDRAW) && !(papersprite || splat)); + shadoweffects = (thing->renderflags & RF_SHADOWEFFECTS); + shadowskew = (shadowdraw && thing->standingslope); + + if (shadowdraw || shadoweffects) { - gzt = oldthing->z + FixedMul(spr_topoffset, this_scale); - gz = gzt - FixedMul(spr_height, this_scale); + fixed_t groundz = R_GetShadowZ(thing, NULL); + boolean isflipped = (thing->eflags & MFE_VERTICALFLIP); + + if (shadoweffects) + { + mobj_t *caster = thing->target; + + if (caster && !P_MobjWasRemoved(caster)) + { + fixed_t floordiff; + + if (abs(groundz-viewz)/tz > 4) + return; // Prevent stretchy shadows and possible crashes + + floordiff = abs((isflipped ? caster->height : 0) + caster->z - groundz); + trans += ((floordiff / (100*FRACUNIT)) + 3); + shadowscale = FixedMul(FRACUNIT - floordiff/640, caster->scale); + } + else + trans += 3; + + if (trans >= 9) + return; + + trans--; + } + + if (shadowdraw) + { + spritexscale = FixedMul(thing->radius * 2, shadowscale); + spriteyscale = FixedMul(thing->radius * 2, shadowscale); + spriteyscale = FixedMul(spriteyscale, FixedDiv(abs(groundz - viewz), tz)); + spriteyscale = min(spriteyscale, spritexscale) / patch->height; + } + else + spritexscale = spriteyscale = shadowscale; + + spritexscale /= patch->width; + + if (shadowskew) + { + R_SkewShadowSprite(thing, thing->standingslope, groundz, patch->height, shadowscale, &spriteyscale, &sheartan); + + gzt = (isflipped ? (thing->z + thing->height) : thing->z) + patch->height * spriteyscale / 2; + gz = gzt - patch->height * spriteyscale; + + cut |= SC_SHEAR; + } + } + + if (!shadowskew) + { + //SoM: 3/17/2000: Disregard sprites that are out of view.. + if (vflip) + { + // When vertical flipped, draw sprites from the top down, at least as far as offsets are concerned. + // sprite height - sprite topoffset is the proper inverse of the vertical offset, of course. + // remember gz and gzt should be seperated by sprite height, not thing height - thing height can be shorter than the sprite itself sometimes! + gz = oldthing->z + oldthing->height - FixedMul(spr_topoffset, FixedMul(spriteyscale, this_scale)); + gzt = gz + FixedMul(spr_height, FixedMul(spriteyscale, this_scale)); + } + else + { + gzt = oldthing->z + FixedMul(spr_topoffset, FixedMul(spriteyscale, this_scale)); + gz = gzt - FixedMul(spr_height, FixedMul(spriteyscale, this_scale)); + } } if (thing->subsector->sector->cullheight) @@ -1764,9 +1907,10 @@ static void R_ProjectSprite(mobj_t *thing) // store information in a vissprite vis = R_NewVisSprite(); + vis->renderflags = thing->renderflags; + vis->rotateflags = sprframe->rotate; vis->heightsec = heightsec; //SoM: 3/17/2000 vis->mobjflags = thing->flags; - vis->scale = yscale; //<sortscale = sortscale; vis->dispoffset = dispoffset; // Monster Iestyn: 23/11/15 vis->gx = thing->x; @@ -1776,12 +1920,12 @@ static void R_ProjectSprite(mobj_t *thing) vis->thingheight = thing->height; vis->pz = thing->z; vis->pzt = vis->pz + vis->thingheight; - vis->texturemid = vis->gzt - viewz; + vis->texturemid = FixedDiv(gzt - viewz, spriteyscale); vis->scalestep = scalestep; vis->paperoffset = paperoffset; vis->paperdistance = paperdistance; vis->centerangle = centerangle; - vis->shear.tan = 0; + vis->shear.tan = sheartan; vis->shear.offset = 0; vis->mobj = thing; // Easy access! Tails 06-07-2002 @@ -1789,17 +1933,28 @@ static void R_ProjectSprite(mobj_t *thing) vis->x1 = x1 < portalclipstart ? portalclipstart : x1; vis->x2 = x2 >= portalclipend ? portalclipend-1 : x2; - vis->xscale = xscale; //SoM: 4/17/2000 vis->sector = thing->subsector->sector; vis->szt = (INT16)((centeryfrac - FixedMul(vis->gzt - viewz, sortscale))>>FRACBITS); vis->sz = (INT16)((centeryfrac - FixedMul(vis->gz - viewz, sortscale))>>FRACBITS); vis->cut = cut; + if (thing->subsector->sector->numlights) vis->extra_colormap = *thing->subsector->sector->lightlist[light].extra_colormap; else vis->extra_colormap = thing->subsector->sector->extra_colormap; - iscale = FixedDiv(FRACUNIT, xscale); + vis->xscale = FixedMul(spritexscale, xscale); //SoM: 4/17/2000 + vis->scale = FixedMul(spriteyscale, yscale); //<width<shear.offset = vis->x1-x1; + vis->shadowscale = shadowscale; + } + else + iscale = FixedDiv(FRACUNIT, vis->xscale); if (flip) { @@ -1818,14 +1973,7 @@ static void R_ProjectSprite(mobj_t *thing) vis->scale += scalestep*(vis->x1 - x1); } - //Fab: lumppat is the lump number of the patch to use, this is different - // than lumpid for sprites-in-pwad : the graphics are patched -#ifdef ROTSPRITE - if (rotsprite != NULL) - vis->patch = rotsprite; - else -#endif - vis->patch = W_CachePatchNum(sprframe->lumppat[rot], PU_SPRITE); + vis->patch = patch; // // determine the colormap (lightlevel & special effects) @@ -1835,13 +1983,13 @@ static void R_ProjectSprite(mobj_t *thing) // specific translucency if (!cv_translucency.value) ; // no translucency - else if (oldthing->flags2 & MF2_SHADOW || thing->flags2 & MF2_SHADOW) // actually only the player should use this (temporary invisibility) - vis->transmap = transtables + ((tr_trans80-1)<frame & FF_TRANSMASK) - vis->transmap = transtables + (oldthing->frame & FF_TRANSMASK) - 0x10000; + else if (trans) + vis->transmap = transtables + ((trans-1)<frame & FF_FULLBRIGHT || oldthing->flags2 & MF2_SHADOW || thing->flags2 & MF2_SHADOW) + if (R_ThingIsFullBright(oldthing) || oldthing->flags2 & MF2_SHADOW || thing->flags2 & MF2_SHADOW) vis->cut |= SC_FULLBRIGHT; + else if (R_ThingIsFullDark(oldthing)) + vis->cut |= SC_FULLDARK; if (vis->cut & SC_FULLBRIGHT && (!vis->extra_colormap || !(vis->extra_colormap->flags & CMF_FADEFULLBRIGHTSPRITES))) @@ -1849,6 +1997,8 @@ static void R_ProjectSprite(mobj_t *thing) // full bright: goggles vis->colormap = colormaps; } + else if (vis->cut & SC_FULLDARK) + vis->colormap = scalelight[0][0]; else { // diminished light @@ -1862,8 +2012,10 @@ static void R_ProjectSprite(mobj_t *thing) if (vflip) vis->cut |= SC_VFLIP; + if (splat) + vis->cut |= SC_SPLAT; // I like ya cut g - if (thing->subsector->sector->numlights) + if (thing->subsector->sector->numlights && !(shadowdraw || splat)) R_SplitSprite(vis); if (oldthing->shadowscale && cv_shadow.value) @@ -2470,10 +2622,13 @@ static void R_CreateDrawNodes(maskcount_t* mask, drawnode_t* head, boolean temps } else if (r2->sprite) { - if (r2->sprite->x1 > rover->x2 || r2->sprite->x2 < rover->x1) - continue; - if (r2->sprite->szt > rover->sz || r2->sprite->sz < rover->szt) - continue; + if (!(r2->sprite->cut & SC_SPLAT || rover->cut & SC_SPLAT)) + { + if (r2->sprite->x1 > rover->x2 || r2->sprite->x2 < rover->x1) + continue; + if (r2->sprite->szt > rover->sz || r2->sprite->sz < rover->szt) + continue; + } if (r2->sprite->sortscale > rover->sortscale || (r2->sprite->sortscale == rover->sortscale && r2->sprite->dispoffset > rover->dispoffset)) @@ -2552,6 +2707,146 @@ void R_InitDrawNodes(void) nodebankhead.next = nodebankhead.prev = &nodebankhead; } +static void R_DrawVisSplat(vissprite_t *spr) +{ +#ifdef FLOORSPLATS + floorsplat_t splat; + fixed_t tr_x, tr_y, rot_x, rot_y, rot_z; + vertex_t *v3d; + vertex_t v2d[4]; + fixed_t x, y; + fixed_t w, h; + angle_t splatangle, angle; + fixed_t ca, sa; + fixed_t xscale, yscale; + fixed_t xoffset, yoffset; + fixed_t leftoffset, topoffset; + boolean hflip = (spr->xiscale < 0); + boolean vflip = (spr->cut & SC_VFLIP); + UINT8 flipflags = 0; + vector2_t rotated[4]; + INT32 i; + + if (hflip) + flipflags |= PICFLAGS_XFLIP; + if (vflip) + flipflags |= PICFLAGS_YFLIP; + + Patch_GenerateFlat(spr->patch, flipflags); + splat.pic = spr->patch->flats[flipflags]; + if (splat.pic == NULL) + return; + + splat.mobj = spr->mobj; + splat.width = spr->patch->width; + splat.height = spr->patch->height; + splat.scale = spr->mobj->scale; + + if (spr->renderflags & RF_SHADOWEFFECTS) + splat.scale = FixedMul(splat.scale, spr->shadowscale); + + if (spr->rotateflags & SRF_3D || spr->renderflags & RF_NOSPLATBILLBOARD) + splatangle = spr->mobj->angle; + else + splatangle = viewangle; + + if (!(spr->cut & SC_ISROTATED)) + splatangle += spr->mobj->rollangle; + + splat.angle = -splatangle; + splat.angle += ANGLE_90; + + topoffset = (spr->patch->topoffset * FRACUNIT); + leftoffset = (spr->patch->leftoffset * FRACUNIT); + if (hflip) + leftoffset = ((splat.width * FRACUNIT) - leftoffset); + + xscale = spr->mobj->spritexscale; + yscale = spr->mobj->spriteyscale; + + splat.xscale = FixedMul(splat.scale, xscale); + splat.yscale = FixedMul(splat.scale, yscale); + + xoffset = FixedMul(leftoffset, splat.xscale); + yoffset = FixedMul(topoffset, splat.yscale); + + x = spr->mobj->x; + y = spr->mobj->y; + w = (splat.width * splat.xscale); + h = (splat.height * splat.yscale); + + splat.x = x; + splat.y = y; + splat.z = spr->mobj->z; + + // Set positions + + // 3--2 + // | | + // 0--1 + + splat.verts[0].x = w - xoffset; + splat.verts[0].y = yoffset; + + splat.verts[1].x = -xoffset; + splat.verts[1].y = yoffset; + + splat.verts[2].x = -xoffset; + splat.verts[2].y = -h + yoffset; + + splat.verts[3].x = w - xoffset; + splat.verts[3].y = -h + yoffset; + + angle = -splat.angle; + ca = FINECOSINE(angle>>ANGLETOFINESHIFT); + sa = FINESINE(angle>>ANGLETOFINESHIFT); + + // Rotate + for (i = 0; i < 4; i++) + { + rotated[i].x = FixedMul(splat.verts[i].x, ca) - FixedMul(splat.verts[i].y, sa); + rotated[i].y = FixedMul(splat.verts[i].x, sa) + FixedMul(splat.verts[i].y, ca); + } + + // Translate + for (i = 0; i < 4; i++) + { + splat.verts[i].x = rotated[i].x + x; + splat.verts[i].y = rotated[i].y + y; + } + + rot_z = splat.z - viewz; + + for (i = 0; i < 4; i++) + { + v3d = &splat.verts[i]; + + // transform the origin point + tr_x = v3d->x - viewx; + tr_y = v3d->y - viewy; + + // rotation around vertical y axis + rot_x = FixedMul(tr_x, viewsin) - FixedMul(tr_y, viewcos); + rot_y = FixedMul(tr_x, viewcos) + FixedMul(tr_y, viewsin); + + if (!rot_y || rot_y < FixedDiv(4*FRACUNIT, splat.scale)) + return; + + // note: y from view above of map, is distance far away + xscale = FixedDiv(projection, rot_y); + yscale = -FixedDiv(projectiony, rot_y); + + // projection + v2d[i].x = (centerxfrac + FixedMul(rot_x, xscale))>>FRACBITS; + v2d[i].y = (centeryfrac + FixedMul(rot_z, yscale))>>FRACBITS; + } + + R_RenderFloorSplat(&splat, v2d, spr); +#else + (void)spr; +#endif +} + // // R_DrawSprite // @@ -2562,7 +2857,11 @@ static void R_DrawSprite(vissprite_t *spr) { mfloorclip = spr->clipbot; mceilingclip = spr->cliptop; - R_DrawVisSprite(spr); + + if (spr->cut & SC_SPLAT) + R_DrawVisSplat(spr); + else + R_DrawVisSprite(spr); } // Special drawer for precipitation sprites Tails 08-18-2002 @@ -2573,205 +2872,208 @@ static void R_DrawPrecipitationSprite(vissprite_t *spr) R_DrawPrecipitationVisSprite(spr); } -// R_ClipSprites +// R_ClipVisSprite // Clips vissprites without drawing, so that portals can work. -Red -void R_ClipSprites(drawseg_t* dsstart, portal_t* portal) +void R_ClipVisSprite(vissprite_t *spr, INT32 x1, INT32 x2, drawseg_t* dsstart, portal_t* portal) { - vissprite_t *spr; - for (; clippedvissprites < visspritecount; clippedvissprites++) + drawseg_t *ds; + INT32 x; + INT32 r1; + INT32 r2; + fixed_t scale; + fixed_t lowscale; + INT32 silhouette; + + for (x = x1; x <= x2; x++) + spr->clipbot[x] = spr->cliptop[x] = -2; + + // Scan drawsegs from end to start for obscuring segs. + // The first drawseg that has a greater scale + // is the clip seg. + //SoM: 4/8/2000: + // Pointer check was originally nonportable + // and buggy, by going past LEFT end of array: + + // for (ds = ds_p-1; ds >= drawsegs; ds--) old buggy code + for (ds = ds_p; ds-- > dsstart;) { - drawseg_t *ds; - INT32 x; - INT32 r1; - INT32 r2; - fixed_t scale; - fixed_t lowscale; - INT32 silhouette; - - spr = R_GetVisSprite(clippedvissprites); - - for (x = spr->x1; x <= spr->x2; x++) - spr->clipbot[x] = spr->cliptop[x] = -2; - - // Scan drawsegs from end to start for obscuring segs. - // The first drawseg that has a greater scale - // is the clip seg. - //SoM: 4/8/2000: - // Pointer check was originally nonportable - // and buggy, by going past LEFT end of array: - - // for (ds = ds_p-1; ds >= drawsegs; ds--) old buggy code - for (ds = ds_p; ds-- > dsstart;) + // determine if the drawseg obscures the sprite + if (ds->x1 > x2 || + ds->x2 < x1 || + (!ds->silhouette + && !ds->maskedtexturecol)) { - // determine if the drawseg obscures the sprite - if (ds->x1 > spr->x2 || - ds->x2 < spr->x1 || - (!ds->silhouette - && !ds->maskedtexturecol)) + // does not cover sprite + continue; + } + + if (ds->portalpass != 66) + { + if (ds->portalpass > 0 && ds->portalpass <= portalrender) + continue; // is a portal + + if (ds->scale1 > ds->scale2) { - // does not cover sprite + 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))) + { + // masked mid texture? + /*if (ds->maskedtexturecol) + R_RenderMaskedSegRange (ds, r1, r2);*/ + // seg is behind sprite continue; } - - if (ds->portalpass != 66) - { - if (ds->portalpass > 0 && ds->portalpass <= portalrender) - continue; // is a portal - - 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))) - { - // masked mid texture? - /*if (ds->maskedtexturecol) - R_RenderMaskedSegRange (ds, r1, r2);*/ - // seg is behind sprite - continue; - } - } - - r1 = ds->x1 < spr->x1 ? spr->x1 : ds->x1; - r2 = ds->x2 > spr->x2 ? spr->x2 : ds->x2; - - // clip this piece of the sprite - silhouette = ds->silhouette; - - if (spr->gz >= ds->bsilheight) - silhouette &= ~SIL_BOTTOM; - - if (spr->gzt <= ds->tsilheight) - silhouette &= ~SIL_TOP; - - if (silhouette == SIL_BOTTOM) - { - // bottom sil - for (x = r1; x <= r2; x++) - if (spr->clipbot[x] == -2) - spr->clipbot[x] = ds->sprbottomclip[x]; - } - else if (silhouette == SIL_TOP) - { - // top sil - for (x = r1; x <= r2; x++) - if (spr->cliptop[x] == -2) - spr->cliptop[x] = ds->sprtopclip[x]; - } - else if (silhouette == (SIL_TOP|SIL_BOTTOM)) - { - // both - for (x = r1; x <= r2; x++) - { - if (spr->clipbot[x] == -2) - spr->clipbot[x] = ds->sprbottomclip[x]; - if (spr->cliptop[x] == -2) - spr->cliptop[x] = ds->sprtopclip[x]; - } - } } - //SoM: 3/17/2000: Clip sprites in water. - if (spr->heightsec != -1) // only things in specially marked sectors + + r1 = ds->x1 < x1 ? x1 : ds->x1; + r2 = ds->x2 > x2 ? x2 : ds->x2; + + // clip this piece of the sprite + silhouette = ds->silhouette; + + if (spr->gz >= ds->bsilheight) + silhouette &= ~SIL_BOTTOM; + + if (spr->gzt <= ds->tsilheight) + silhouette &= ~SIL_TOP; + + if (silhouette == SIL_BOTTOM) { - fixed_t mh, h; - INT32 phs = viewplayer->mo->subsector->sector->heightsec; - if ((mh = sectors[spr->heightsec].floorheight) > spr->gz && - (h = centeryfrac - FixedMul(mh -= viewz, spr->sortscale)) >= 0 && - (h >>= FRACBITS) < viewheight) - { - if (mh <= 0 || (phs != -1 && viewz > sectors[phs].floorheight)) - { // clip bottom - for (x = spr->x1; x <= spr->x2; x++) - if (spr->clipbot[x] == -2 || h < spr->clipbot[x]) - spr->clipbot[x] = (INT16)h; - } - else // clip top - { - for (x = spr->x1; x <= spr->x2; x++) - if (spr->cliptop[x] == -2 || h > spr->cliptop[x]) - spr->cliptop[x] = (INT16)h; - } - } - - if ((mh = sectors[spr->heightsec].ceilingheight) < spr->gzt && - (h = centeryfrac - FixedMul(mh-viewz, spr->sortscale)) >= 0 && - (h >>= FRACBITS) < viewheight) - { - if (phs != -1 && viewz >= sectors[phs].ceilingheight) - { // clip bottom - for (x = spr->x1; x <= spr->x2; x++) - if (spr->clipbot[x] == -2 || h < spr->clipbot[x]) - spr->clipbot[x] = (INT16)h; - } - else // clip top - { - for (x = spr->x1; x <= spr->x2; x++) - if (spr->cliptop[x] == -2 || h > spr->cliptop[x]) - spr->cliptop[x] = (INT16)h; - } - } + // bottom sil + for (x = r1; x <= r2; x++) + if (spr->clipbot[x] == -2) + spr->clipbot[x] = ds->sprbottomclip[x]; } - if (spr->cut & SC_TOP && spr->cut & SC_BOTTOM) + else if (silhouette == SIL_TOP) { - for (x = spr->x1; x <= spr->x2; x++) + // top sil + for (x = r1; x <= r2; x++) + if (spr->cliptop[x] == -2) + spr->cliptop[x] = ds->sprtopclip[x]; + } + else if (silhouette == (SIL_TOP|SIL_BOTTOM)) + { + // both + for (x = r1; x <= r2; x++) { - if (spr->cliptop[x] == -2 || spr->szt > spr->cliptop[x]) - spr->cliptop[x] = spr->szt; - - if (spr->clipbot[x] == -2 || spr->sz < spr->clipbot[x]) - spr->clipbot[x] = spr->sz; + if (spr->clipbot[x] == -2) + spr->clipbot[x] = ds->sprbottomclip[x]; + if (spr->cliptop[x] == -2) + spr->cliptop[x] = ds->sprtopclip[x]; } } - else if (spr->cut & SC_TOP) + } + //SoM: 3/17/2000: Clip sprites in water. + if (spr->heightsec != -1) // only things in specially marked sectors + { + fixed_t mh, h; + INT32 phs = viewplayer->mo->subsector->sector->heightsec; + if ((mh = sectors[spr->heightsec].floorheight) > spr->gz && + (h = centeryfrac - FixedMul(mh -= viewz, spr->sortscale)) >= 0 && + (h >>= FRACBITS) < viewheight) { - for (x = spr->x1; x <= spr->x2; x++) - { - if (spr->cliptop[x] == -2 || spr->szt > spr->cliptop[x]) - spr->cliptop[x] = spr->szt; + 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]) + spr->clipbot[x] = (INT16)h; } - } - else if (spr->cut & SC_BOTTOM) - { - for (x = spr->x1; x <= spr->x2; x++) + else // clip top { - if (spr->clipbot[x] == -2 || spr->sz < spr->clipbot[x]) - spr->clipbot[x] = spr->sz; + for (x = x1; x <= x2; x++) + if (spr->cliptop[x] == -2 || h > spr->cliptop[x]) + spr->cliptop[x] = (INT16)h; } } - // all clipping has been performed, so store the values - what, did you think we were drawing them NOW? - - // check for unclipped columns - for (x = spr->x1; x <= spr->x2; x++) + if ((mh = sectors[spr->heightsec].ceilingheight) < spr->gzt && + (h = centeryfrac - FixedMul(mh-viewz, spr->sortscale)) >= 0 && + (h >>= FRACBITS) < viewheight) { - if (spr->clipbot[x] == -2) - spr->clipbot[x] = (INT16)viewheight; - - if (spr->cliptop[x] == -2) - //Fab : 26-04-98: was -1, now clips against console bottom - spr->cliptop[x] = (INT16)con_clipviewtop; - } - - if (portal) - { - for (x = spr->x1; x <= spr->x2; x++) + if (phs != -1 && viewz >= sectors[phs].ceilingheight) + { // clip bottom + for (x = x1; x <= x2; x++) + if (spr->clipbot[x] == -2 || h < spr->clipbot[x]) + spr->clipbot[x] = (INT16)h; + } + else // clip top { - if (spr->clipbot[x] > portal->floorclip[x - portal->start]) - spr->clipbot[x] = portal->floorclip[x - portal->start]; - if (spr->cliptop[x] < portal->ceilingclip[x - portal->start]) - spr->cliptop[x] = portal->ceilingclip[x - portal->start]; + for (x = x1; x <= x2; x++) + if (spr->cliptop[x] == -2 || h > spr->cliptop[x]) + spr->cliptop[x] = (INT16)h; } } } + if (spr->cut & SC_TOP && spr->cut & SC_BOTTOM) + { + for (x = x1; x <= x2; x++) + { + if (spr->cliptop[x] == -2 || spr->szt > spr->cliptop[x]) + spr->cliptop[x] = spr->szt; + + if (spr->clipbot[x] == -2 || spr->sz < spr->clipbot[x]) + spr->clipbot[x] = spr->sz; + } + } + else if (spr->cut & SC_TOP) + { + for (x = x1; x <= x2; x++) + { + if (spr->cliptop[x] == -2 || spr->szt > spr->cliptop[x]) + spr->cliptop[x] = spr->szt; + } + } + else if (spr->cut & SC_BOTTOM) + { + for (x = x1; x <= x2; x++) + { + if (spr->clipbot[x] == -2 || spr->sz < spr->clipbot[x]) + spr->clipbot[x] = spr->sz; + } + } + + // all clipping has been performed, so store the values - what, did you think we were drawing them NOW? + + // check for unclipped columns + for (x = x1; x <= x2; x++) + { + if (spr->clipbot[x] == -2) + spr->clipbot[x] = (INT16)viewheight; + + if (spr->cliptop[x] == -2) + //Fab : 26-04-98: was -1, now clips against console bottom + spr->cliptop[x] = (INT16)con_clipviewtop; + } + + if (portal) + { + for (x = x1; x <= x2; x++) + { + if (spr->clipbot[x] > portal->floorclip[x - portal->start]) + spr->clipbot[x] = portal->floorclip[x - portal->start]; + if (spr->cliptop[x] < portal->ceilingclip[x - portal->start]) + spr->cliptop[x] = portal->ceilingclip[x - portal->start]; + } + } +} + +void R_ClipSprites(drawseg_t* dsstart, portal_t* portal) +{ + for (; clippedvissprites < visspritecount; clippedvissprites++) + { + vissprite_t *spr = R_GetVisSprite(clippedvissprites); + R_ClipVisSprite(spr, spr->x1, spr->x2, dsstart, portal); + } } /* Check if thing may be drawn from our current view. */ @@ -2823,6 +3125,36 @@ boolean R_PrecipThingVisible (precipmobj_t *precipthing, return ( approx_dist <= limit_dist ); } +boolean R_ThingHorizontallyFlipped(mobj_t *thing) +{ + return (thing->frame & FF_HORIZONTALFLIP || thing->renderflags & RF_HORIZONTALFLIP); +} + +boolean R_ThingVerticallyFlipped(mobj_t *thing) +{ + return (thing->frame & FF_VERTICALFLIP || thing->renderflags & RF_VERTICALFLIP); +} + +boolean R_ThingIsPaperSprite(mobj_t *thing) +{ + return (thing->frame & FF_PAPERSPRITE || thing->renderflags & RF_PAPERSPRITE); +} + +boolean R_ThingIsFloorSprite(mobj_t *thing) +{ + return (thing->flags2 & MF2_SPLAT || thing->renderflags & RF_FLOORSPRITE); +} + +boolean R_ThingIsFullBright (mobj_t *thing) +{ + return (thing->frame & FF_FULLBRIGHT || thing->renderflags & RF_FULLBRIGHT); +} + +boolean R_ThingIsFullDark (mobj_t *thing) +{ + return (thing->renderflags & RF_FULLDARK); +} + // // R_DrawMasked // diff --git a/src/r_things.h b/src/r_things.h index f241a78ba..2addcb7ca 100644 --- a/src/r_things.h +++ b/src/r_things.h @@ -65,7 +65,6 @@ fixed_t R_GetShadowZ(mobj_t *thing, pslope_t **shadowslope); void R_AddSprites(sector_t *sec, INT32 lightlevel); void R_InitSprites(void); void R_ClearSprites(void); -void R_ClipSprites(drawseg_t* dsstart, portal_t* portal); boolean R_ThingVisible (mobj_t *thing); @@ -76,6 +75,15 @@ boolean R_ThingVisibleWithinDist (mobj_t *thing, boolean R_PrecipThingVisible (precipmobj_t *precipthing, fixed_t precip_draw_dist); +boolean R_ThingHorizontallyFlipped (mobj_t *thing); +boolean R_ThingVerticallyFlipped (mobj_t *thing); + +boolean R_ThingIsPaperSprite (mobj_t *thing); +boolean R_ThingIsFloorSprite (mobj_t *thing); + +boolean R_ThingIsFullBright (mobj_t *thing); +boolean R_ThingIsFullDark (mobj_t *thing); + // -------------- // MASKED DRAWING // -------------- @@ -108,19 +116,23 @@ void R_DrawMasked(maskcount_t* masks, UINT8 nummasks); typedef enum { // actual cuts - SC_NONE = 0, - SC_TOP = 1, - SC_BOTTOM = 1<<1, + SC_NONE = 0, + SC_TOP = 1, + SC_BOTTOM = 1<<1, // other flags - SC_PRECIP = 1<<2, - SC_LINKDRAW = 1<<3, + SC_PRECIP = 1<<2, + SC_LINKDRAW = 1<<3, SC_FULLBRIGHT = 1<<4, - SC_VFLIP = 1<<5, - SC_ISSCALED = 1<<6, - SC_SHADOW = 1<<7, + SC_FULLDARK = 1<<5, + SC_VFLIP = 1<<6, + SC_ISSCALED = 1<<7, + SC_ISROTATED = 1<<8, + SC_SHADOW = 1<<9, + SC_SHEAR = 1<<10, + SC_SPLAT = 1<<11, // masks - SC_CUTMASK = SC_TOP|SC_BOTTOM, - SC_FLAGMASK = ~SC_CUTMASK + SC_CUTMASK = SC_TOP|SC_BOTTOM, + SC_FLAGMASK = ~SC_CUTMASK } spritecut_e; // A vissprite_t is a thing that will be drawn during a refresh, @@ -177,6 +189,10 @@ typedef struct vissprite_s INT16 sz, szt; spritecut_e cut; + UINT32 renderflags; + UINT8 rotateflags; + + fixed_t shadowscale; INT16 clipbot[MAXVIDWIDTH], cliptop[MAXVIDWIDTH]; @@ -185,6 +201,12 @@ typedef struct vissprite_s extern UINT32 visspritecount; +void R_ClipSprites(drawseg_t* dsstart, portal_t* portal); +void R_ClipVisSprite(vissprite_t *spr, INT32 x1, INT32 x2, drawseg_t* dsstart, portal_t* portal); + +boolean R_SpriteIsFlashing(vissprite_t *vis); +UINT8 *R_GetSpriteTranslation(vissprite_t *vis); + // ---------- // DRAW NODES // ---------- diff --git a/src/screen.c b/src/screen.c index adda4ba2f..f5d182f34 100644 --- a/src/screen.c +++ b/src/screen.c @@ -124,6 +124,8 @@ void SCR_SetDrawFuncs(void) spanfuncs[SPANDRAWFUNC_TRANS] = R_DrawTranslucentSpan_8; spanfuncs[SPANDRAWFUNC_SPLAT] = R_DrawSplat_8; spanfuncs[SPANDRAWFUNC_TRANSSPLAT] = R_DrawTranslucentSplat_8; + spanfuncs[SPANDRAWFUNC_SPRITE] = R_DrawFloorSprite_8; + spanfuncs[SPANDRAWFUNC_TRANSSPRITE] = R_DrawTranslucentFloorSprite_8; spanfuncs[SPANDRAWFUNC_FOG] = R_DrawFogSpan_8; #ifndef NOWATER spanfuncs[SPANDRAWFUNC_WATER] = R_DrawTranslucentWaterSpan_8; @@ -140,6 +142,8 @@ void SCR_SetDrawFuncs(void) spanfuncs_npo2[SPANDRAWFUNC_TRANS] = R_DrawTranslucentSpan_NPO2_8; spanfuncs_npo2[SPANDRAWFUNC_SPLAT] = R_DrawSplat_NPO2_8; spanfuncs_npo2[SPANDRAWFUNC_TRANSSPLAT] = R_DrawTranslucentSplat_NPO2_8; + spanfuncs_npo2[SPANDRAWFUNC_SPRITE] = R_DrawFloorSprite_NPO2_8; + spanfuncs_npo2[SPANDRAWFUNC_TRANSSPRITE] = R_DrawTranslucentFloorSprite_NPO2_8; spanfuncs_npo2[SPANDRAWFUNC_FOG] = NULL; // Not needed #ifndef NOWATER spanfuncs_npo2[SPANDRAWFUNC_WATER] = R_DrawTranslucentWaterSpan_NPO2_8; diff --git a/src/screen.h b/src/screen.h index acc08f001..021c644ba 100644 --- a/src/screen.h +++ b/src/screen.h @@ -142,6 +142,8 @@ enum SPANDRAWFUNC_TRANS, SPANDRAWFUNC_SPLAT, SPANDRAWFUNC_TRANSSPLAT, + SPANDRAWFUNC_SPRITE, + SPANDRAWFUNC_TRANSSPRITE, SPANDRAWFUNC_FOG, #ifndef NOWATER SPANDRAWFUNC_WATER, diff --git a/src/tmap.nas b/src/tmap.nas index 106f38e96..69282d0b4 100644 --- a/src/tmap.nas +++ b/src/tmap.nas @@ -763,8 +763,8 @@ TX2 EQU 16 TY2 EQU 20 RASTERY_SIZEOF EQU 24 -cglobal rasterize_segment_tex -rasterize_segment_tex: +cglobal rasterize_segment_tex_asm +rasterize_segment_tex_asm: push ebp mov ebp,esp From da27f720dadd429f748aaefabf062d3979058d10 Mon Sep 17 00:00:00 2001 From: Zippy_Zolton Date: Sun, 11 Oct 2020 23:22:16 -0500 Subject: [PATCH 0158/1080] Whitelist the "X" shown in the HUD --- src/w_wad.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/w_wad.c b/src/w_wad.c index 11679b8f4..5d10cbd10 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -2079,6 +2079,7 @@ int W_VerifyNMUSlumps(const char *filename) {"STCFN", 5}, // Console font changes {"TNYFN", 5}, // Tiny console font changes {"STT", 3}, // Acceptable HUD changes (Score Time Rings) + {"STLIVEX", 7}, // "X" that shows under skin's HUDNAME {"YB_", 3}, // Intermission graphics, goes with the above {"M_", 2}, // As does menu stuff {"MUSICDEF", 8}, // Song definitions (thanks kart) From b620f4835ae46b1e122eed1e0f206e654c7b2bc5 Mon Sep 17 00:00:00 2001 From: Jaime Passos Date: Mon, 12 Oct 2020 17:25:18 -0300 Subject: [PATCH 0159/1080] Support spritexscale and spriteyscale in OpenGL Fix papersprite scaling with spritexscale and spriteyscale in Software --- src/hardware/hw_glob.h | 3 +- src/hardware/hw_main.c | 88 +++++++++++++++++++++--------------------- src/r_things.c | 14 +++++-- src/r_things.h | 1 + 4 files changed, 56 insertions(+), 50 deletions(-) diff --git a/src/hardware/hw_glob.h b/src/hardware/hw_glob.h index b16a0f231..0d33d185a 100644 --- a/src/hardware/hw_glob.h +++ b/src/hardware/hw_glob.h @@ -62,7 +62,8 @@ typedef struct typedef struct gl_vissprite_s { float x1, x2; - float tz, ty; + float gz, gzt; + float tz; float tracertz; // for MF2_LINKDRAW sprites, this contains tracer's tz for use in sorting patch_t *gpatch; boolean flip; diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index cfcad29d0..35611c9f3 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -3605,17 +3605,17 @@ static void HWR_RotateSpritePolyToAim(gl_vissprite_t *spr, FOutVector *wallVerts // X, Y, AND Z need to be manipulated for the polys to rotate around the // origin, because of how the origin setting works I believe that should // be mobj->z or mobj->z + mobj->height - wallVerts[2].y = wallVerts[3].y = (spr->ty - basey) * gl_viewludsin + basey; + wallVerts[2].y = wallVerts[3].y = (spr->gzt - basey) * gl_viewludsin + basey; wallVerts[0].y = wallVerts[1].y = (lowy - basey) * gl_viewludsin + basey; // translate back to be around 0 before translating back - wallVerts[3].x += ((spr->ty - basey) * gl_viewludcos) * gl_viewcos; - wallVerts[2].x += ((spr->ty - basey) * gl_viewludcos) * gl_viewcos; + wallVerts[3].x += ((spr->gzt - basey) * gl_viewludcos) * gl_viewcos; + wallVerts[2].x += ((spr->gzt - basey) * gl_viewludcos) * gl_viewcos; wallVerts[0].x += ((lowy - basey) * gl_viewludcos) * gl_viewcos; wallVerts[1].x += ((lowy - basey) * gl_viewludcos) * gl_viewcos; - wallVerts[3].z += ((spr->ty - basey) * gl_viewludcos) * gl_viewsin; - wallVerts[2].z += ((spr->ty - basey) * gl_viewludcos) * gl_viewsin; + wallVerts[3].z += ((spr->gzt - basey) * gl_viewludcos) * gl_viewsin; + wallVerts[2].z += ((spr->gzt - basey) * gl_viewludcos) * gl_viewsin; wallVerts[0].z += ((lowy - basey) * gl_viewludcos) * gl_viewsin; wallVerts[1].z += ((lowy - basey) * gl_viewludcos) * gl_viewsin; @@ -3624,14 +3624,13 @@ static void HWR_RotateSpritePolyToAim(gl_vissprite_t *spr, FOutVector *wallVerts static void HWR_SplitSprite(gl_vissprite_t *spr) { - float this_scale = 1.0f; FOutVector wallVerts[4]; FOutVector baseWallVerts[4]; // This is what the verts should end up as patch_t *gpatch; FSurfaceInfo Surf; - const boolean hires = (spr->mobj && spr->mobj->skin && ((skin_t *)spr->mobj->skin)->flags & SF_HIRES); extracolormap_t *colormap; FUINT lightlevel; + boolean lightset = true; FBITFIELD blend = 0; FBITFIELD occlusion; boolean use_linkdraw_hack = false; @@ -3650,11 +3649,6 @@ static void HWR_SplitSprite(gl_vissprite_t *spr) fixed_t temp; fixed_t v1x, v1y, v2x, v2y; - this_scale = FIXED_TO_FLOAT(spr->mobj->scale); - - if (hires) - this_scale = this_scale * FIXED_TO_FLOAT(((skin_t *)spr->mobj->skin)->highresscale); - gpatch = spr->gpatch; // cache the patch in the graphics card memory @@ -3667,11 +3661,8 @@ static void HWR_SplitSprite(gl_vissprite_t *spr) baseWallVerts[0].z = baseWallVerts[3].z = spr->z1; baseWallVerts[1].z = baseWallVerts[2].z = spr->z2; - baseWallVerts[2].y = baseWallVerts[3].y = spr->ty; - if (spr->mobj && fabsf(this_scale - 1.0f) > 1.0E-36f) - baseWallVerts[0].y = baseWallVerts[1].y = spr->ty - gpatch->height * this_scale; - else - baseWallVerts[0].y = baseWallVerts[1].y = spr->ty - gpatch->height; + baseWallVerts[2].y = baseWallVerts[3].y = spr->gzt; + baseWallVerts[0].y = baseWallVerts[1].y = spr->gz; v1x = FLOAT_TO_FIXED(spr->x1); v1y = FLOAT_TO_FIXED(spr->z1); @@ -3767,15 +3758,19 @@ static void HWR_SplitSprite(gl_vissprite_t *spr) i = 0; temp = FLOAT_TO_FIXED(realtop); - if (spr->mobj->frame & FF_FULLBRIGHT) + if (R_ThingIsFullBright(spr->mobj)) lightlevel = 255; + else if (R_ThingIsFullDark(spr->mobj)) + lightlevel = 0; + else + lightset = false; for (i = 1; i < sector->numlights; i++) { fixed_t h = P_GetLightZAt(§or->lightlist[i], spr->mobj->x, spr->mobj->y); if (h <= temp) { - if (!(spr->mobj->frame & FF_FULLBRIGHT)) + if (!lightset) lightlevel = *list[i-1].lightlevel > 255 ? 255 : *list[i-1].lightlevel; colormap = *list[i-1].extra_colormap; break; @@ -3790,7 +3785,7 @@ static void HWR_SplitSprite(gl_vissprite_t *spr) // even if we aren't changing colormap or lightlevel, we still need to continue drawing down the sprite if (!(list[i].flags & FF_NOSHADE) && (list[i].flags & FF_CUTSPRITES)) { - if (!(spr->mobj->frame & FF_FULLBRIGHT)) + if (!lightset) lightlevel = *list[i].lightlevel > 255 ? 255 : *list[i].lightlevel; colormap = *list[i].extra_colormap; } @@ -3901,16 +3896,10 @@ static void HWR_SplitSprite(gl_vissprite_t *spr) // -----------------+ static void HWR_DrawSprite(gl_vissprite_t *spr) { - float this_scale = 1.0f; FOutVector wallVerts[4]; patch_t *gpatch; // sprite patch converted to hardware FSurfaceInfo Surf; - const boolean hires = (spr->mobj && spr->mobj->skin && ((skin_t *)spr->mobj->skin)->flags & SF_HIRES); //const boolean papersprite = R_ThingIsPaperSprite(spr->mobj); - if (spr->mobj) - this_scale = FIXED_TO_FLOAT(spr->mobj->scale); - if (hires) - this_scale = this_scale * FIXED_TO_FLOAT(((skin_t *)spr->mobj->skin)->highresscale); if (!spr->mobj) return; @@ -3948,11 +3937,8 @@ static void HWR_DrawSprite(gl_vissprite_t *spr) // these were already scaled in HWR_ProjectSprite wallVerts[0].x = wallVerts[3].x = spr->x1; wallVerts[2].x = wallVerts[1].x = spr->x2; - wallVerts[2].y = wallVerts[3].y = spr->ty; - if (spr->mobj && fabsf(this_scale - 1.0f) > 1.0E-36f) - wallVerts[0].y = wallVerts[1].y = spr->ty - gpatch->height * this_scale; - else - wallVerts[0].y = wallVerts[1].y = spr->ty - gpatch->height; + wallVerts[2].y = wallVerts[3].y = spr->gzt; + wallVerts[0].y = wallVerts[1].y = spr->gz; // make a wall polygon (with 2 triangles), using the floor/ceiling heights, // and the 2d map coords of start/end vertices @@ -4003,10 +3989,14 @@ static void HWR_DrawSprite(gl_vissprite_t *spr) // colormap test { sector_t *sector = spr->mobj->subsector->sector; - UINT8 lightlevel = 255; + UINT8 lightlevel; extracolormap_t *colormap = sector->extra_colormap; - if (!(spr->mobj->frame & FF_FULLBRIGHT)) + if (R_ThingIsFullBright(spr->mobj)) + lightlevel = 255; + else if (R_ThingIsFullDark(spr->mobj)) + lightlevel = 0; + else lightlevel = sector->lightlevel > 255 ? 255 : sector->lightlevel; HWR_Lighting(&Surf, lightlevel, colormap); @@ -4081,8 +4071,8 @@ static inline void HWR_DrawPrecipitationSprite(gl_vissprite_t *spr) // 0--1 wallVerts[0].x = wallVerts[3].x = spr->x1; wallVerts[2].x = wallVerts[1].x = spr->x2; - wallVerts[2].y = wallVerts[3].y = spr->ty; - wallVerts[0].y = wallVerts[1].y = spr->ty - gpatch->height; + wallVerts[2].y = wallVerts[3].y = spr->gzt; + wallVerts[0].y = wallVerts[1].y = spr->gz; // make a wall polygon (with 2 triangles), using the floor/ceiling heights, // and the 2d map coords of start/end vertices @@ -4680,6 +4670,7 @@ static void HWR_ProjectSprite(mobj_t *thing) float x1, x2; float rightsin, rightcos; float this_scale; + float spritexscale, spriteyscale; float gz, gzt; spritedef_t *sprdef; spriteframe_t *sprframe; @@ -4714,6 +4705,8 @@ static void HWR_ProjectSprite(mobj_t *thing) dispoffset = thing->info->dispoffset; this_scale = FIXED_TO_FLOAT(thing->scale); + spritexscale = FIXED_TO_FLOAT(thing->spritexscale); + spriteyscale = FIXED_TO_FLOAT(thing->spriteyscale); // transform the origin point tr_x = FIXED_TO_FLOAT(thing->x) - gl_viewx; @@ -4867,15 +4860,18 @@ static void HWR_ProjectSprite(mobj_t *thing) flip = !flip != !hflip; + spritexscale *= this_scale; + spriteyscale *= this_scale; + if (flip) { - x1 = (FIXED_TO_FLOAT(spr_width - spr_offset) * this_scale); - x2 = (FIXED_TO_FLOAT(spr_offset) * this_scale); + x1 = (FIXED_TO_FLOAT(spr_width - spr_offset) * spritexscale); + x2 = (FIXED_TO_FLOAT(spr_offset) * spritexscale); } else { - x1 = (FIXED_TO_FLOAT(spr_offset) * this_scale); - x2 = (FIXED_TO_FLOAT(spr_width - spr_offset) * this_scale); + x1 = (FIXED_TO_FLOAT(spr_offset) * spritexscale); + x2 = (FIXED_TO_FLOAT(spr_width - spr_offset) * spritexscale); } // test if too close @@ -4897,13 +4893,13 @@ static void HWR_ProjectSprite(mobj_t *thing) if (vflip) { - gz = FIXED_TO_FLOAT(thing->z+thing->height) - FIXED_TO_FLOAT(spr_topoffset) * this_scale; - gzt = gz + FIXED_TO_FLOAT(spr_height) * this_scale; + gz = FIXED_TO_FLOAT(thing->z+thing->height) - (FIXED_TO_FLOAT(spr_topoffset) * spriteyscale); + gzt = gz + (FIXED_TO_FLOAT(spr_height) * spriteyscale); } else { - gzt = FIXED_TO_FLOAT(thing->z) + FIXED_TO_FLOAT(spr_topoffset) * this_scale; - gz = gzt - FIXED_TO_FLOAT(spr_height) * this_scale; + gzt = FIXED_TO_FLOAT(thing->z) + (FIXED_TO_FLOAT(spr_topoffset) * spriteyscale); + gz = gzt - (FIXED_TO_FLOAT(spr_height) * spriteyscale); } if (thing->subsector->sector->cullheight) @@ -5010,7 +5006,8 @@ static void HWR_ProjectSprite(mobj_t *thing) vis->colormap = colormaps; // set top/bottom coords - vis->ty = gzt; + vis->gzt = gzt; + vis->gz = gz; //CONS_Debug(DBG_RENDER, "------------------\nH: sprite : %d\nH: frame : %x\nH: type : %d\nH: sname : %s\n\n", // thing->sprite, thing->frame, thing->type, sprnames[thing->sprite]); @@ -5110,7 +5107,8 @@ static void HWR_ProjectPrecipitationSprite(precipmobj_t *thing) vis->colormap = colormaps; // set top/bottom coords - vis->ty = FIXED_TO_FLOAT(thing->z + spritecachedinfo[lumpoff].topoffset); + vis->gzt = FIXED_TO_FLOAT(thing->z + spritecachedinfo[lumpoff].topoffset); + vis->gz = vis->gzt - FIXED_TO_FLOAT(spritecachedinfo[lumpoff].height); vis->precip = true; diff --git a/src/r_things.c b/src/r_things.c index ac9c357a4..00bb0b32a 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -923,13 +923,16 @@ static void R_DrawVisSprite(vissprite_t *vis) // Split drawing loops for paper and non-paper to reduce conditional checks per sprite if (vis->scalestep) { + fixed_t horzscale = FixedMul(vis->spritexscale, this_scale); + fixed_t scalestep = FixedMul(vis->scalestep, vis->spriteyscale); + pwidth = SHORT(patch->width); // Papersprite drawing loop - for (dc_x = vis->x1; dc_x <= vis->x2; dc_x++, spryscale += vis->scalestep) + for (dc_x = vis->x1; dc_x <= vis->x2; dc_x++, spryscale += scalestep) { angle_t angle = ((vis->centerangle + xtoviewangle[dc_x]) >> ANGLETOFINESHIFT) & 0xFFF; - texturecolumn = (vis->paperoffset - FixedMul(FINETANGENT(angle), vis->paperdistance)) / this_scale; + texturecolumn = (vis->paperoffset - FixedMul(FINETANGENT(angle), vis->paperdistance)) / horzscale; if (texturecolumn < 0 || texturecolumn >= pwidth) continue; @@ -1946,6 +1949,9 @@ static void R_ProjectSprite(mobj_t *thing) vis->xscale = FixedMul(spritexscale, xscale); //SoM: 4/17/2000 vis->scale = FixedMul(spriteyscale, yscale); //<spritexscale = spritexscale; + vis->spriteyscale = spriteyscale; + if (shadowdraw || shadoweffects) { iscale = (patch->width<x1 > x1) { - vis->startfrac += FixedDiv(vis->xiscale, this_scale)*(vis->x1-x1); - vis->scale += scalestep*(vis->x1 - x1); + vis->startfrac += FixedDiv(vis->xiscale, this_scale) * (vis->x1 - x1); + vis->scale += FixedMul(scalestep, spriteyscale) * (vis->x1 - x1); } vis->patch = patch; diff --git a/src/r_things.h b/src/r_things.h index 2addcb7ca..16cf5088f 100644 --- a/src/r_things.h +++ b/src/r_things.h @@ -192,6 +192,7 @@ typedef struct vissprite_s UINT32 renderflags; UINT8 rotateflags; + fixed_t spritexscale, spriteyscale; fixed_t shadowscale; INT16 clipbot[MAXVIDWIDTH], cliptop[MAXVIDWIDTH]; From 87a5e1d30c6e5113afbc2fe6dd8cd4f59fd9dcfc Mon Sep 17 00:00:00 2001 From: GoldenTails Date: Mon, 12 Oct 2020 17:14:32 -0500 Subject: [PATCH 0160/1080] Futureproof against strict buildbots. --- src/d_netcmd.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index a96ea1a90..22eaeb0d2 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -3267,13 +3267,14 @@ static void Command_Addfile(void) char buf[256]; char *buf_p = buf; INT32 i; + size_t ii; int musiconly; // W_VerifyNMUSlumps isn't boolean boolean fileadded = false; fn = COM_Argv(curarg); // For the amount of filenames previously processed... - for (size_t ii = 0; ii < numfilesadded; ii++) + for (ii = 0; ii < numfilesadded; ii++) { // If this is one of them, don't try to add it. if (!strcmp(fn, addedfiles[ii])) From 831ccccdd68e3a3a7355c8a76d3c352b7f081910 Mon Sep 17 00:00:00 2001 From: Jaime Passos Date: Mon, 12 Oct 2020 19:53:21 -0300 Subject: [PATCH 0161/1080] OpenGL support for splats, fix some shadow draw bugs in Software --- src/dehacked.c | 1 + src/hardware/hw_glob.h | 25 ++-- src/hardware/hw_main.c | 268 +++++++++++++++++++++++++++++++++-------- src/r_defs.h | 5 +- src/r_things.c | 21 ++-- 5 files changed, 250 insertions(+), 70 deletions(-) diff --git a/src/dehacked.c b/src/dehacked.c index 92a8ffe4e..aa4a04be4 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -9584,6 +9584,7 @@ struct { {"RF_HORIZONTALFLIP",RF_HORIZONTALFLIP}, {"RF_VERTICALFLIP",RF_VERTICALFLIP}, {"RF_ONESIDED",RF_ONESIDED}, + {"RF_SLOPESPLAT",RF_SLOPESPLAT}, {"RF_NOSPLATBILLBOARD",RF_NOSPLATBILLBOARD}, {"RF_NOSPLATROLLANGLE",RF_NOSPLATROLLANGLE}, {"RF_FULLBRIGHT",RF_FULLBRIGHT}, diff --git a/src/hardware/hw_glob.h b/src/hardware/hw_glob.h index 0d33d185a..cb517b611 100644 --- a/src/hardware/hw_glob.h +++ b/src/hardware/hw_glob.h @@ -62,19 +62,30 @@ typedef struct typedef struct gl_vissprite_s { float x1, x2; + float z1, z2; float gz, gzt; + float tz; float tracertz; // for MF2_LINKDRAW sprites, this contains tracer's tz for use in sorting - patch_t *gpatch; - boolean flip; - UINT8 translucency; //alpha level 0-255 - mobj_t *mobj; // NOTE: This is a precipmobj_t if precip is true !!! Watch out. + + float scale; + float spritexscale, spriteyscale; + float shadowheight, shadowscale; + + UINT32 renderflags; + UINT8 rotateflags; + + boolean flip, vflip; boolean precip; // Tails 08-25-2002 - boolean vflip; - //Hurdler: 25/04/2000: now support colormap in hardware mode + boolean rotated; + UINT8 translucency; //alpha level 0-255 + + //Hurdler: 25/04/2000: now support colormap in hardware mode UINT8 *colormap; INT32 dispoffset; // copy of info->dispoffset, affects ordering but not drawing - float z1, z2; + + patch_t *gpatch; + mobj_t *mobj; // NOTE: This is a precipmobj_t if precip is true !!! Watch out. } gl_vissprite_t; // -------- diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 35611c9f3..98f3d69da 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -3634,6 +3634,7 @@ static void HWR_SplitSprite(gl_vissprite_t *spr) FBITFIELD blend = 0; FBITFIELD occlusion; boolean use_linkdraw_hack = false; + boolean splat = R_ThingIsFloorSprite(spr->mobj); UINT8 alpha; INT32 i; @@ -3692,18 +3693,21 @@ static void HWR_SplitSprite(gl_vissprite_t *spr) baseWallVerts[0].t = baseWallVerts[1].t = ((GLPatch_t *)gpatch->hardware)->max_t; } - // if it has a dispoffset, push it a little towards the camera - if (spr->dispoffset) { - float co = -gl_viewcos*(0.05f*spr->dispoffset); - float si = -gl_viewsin*(0.05f*spr->dispoffset); - baseWallVerts[0].z = baseWallVerts[3].z = baseWallVerts[0].z+si; - baseWallVerts[1].z = baseWallVerts[2].z = baseWallVerts[1].z+si; - baseWallVerts[0].x = baseWallVerts[3].x = baseWallVerts[0].x+co; - baseWallVerts[1].x = baseWallVerts[2].x = baseWallVerts[1].x+co; - } + if (!splat) + { + // if it has a dispoffset, push it a little towards the camera + if (spr->dispoffset) { + float co = -gl_viewcos*(0.05f*spr->dispoffset); + float si = -gl_viewsin*(0.05f*spr->dispoffset); + baseWallVerts[0].z = baseWallVerts[3].z = baseWallVerts[0].z+si; + baseWallVerts[1].z = baseWallVerts[2].z = baseWallVerts[1].z+si; + baseWallVerts[0].x = baseWallVerts[3].x = baseWallVerts[0].x+co; + baseWallVerts[1].x = baseWallVerts[2].x = baseWallVerts[1].x+co; + } - // Let dispoffset work first since this adjust each vertex - HWR_RotateSpritePolyToAim(spr, baseWallVerts, false); + // Let dispoffset work first since this adjust each vertex + HWR_RotateSpritePolyToAim(spr, baseWallVerts, false); + } realtop = top = baseWallVerts[3].y; realbot = bot = baseWallVerts[0].y; @@ -3899,7 +3903,7 @@ static void HWR_DrawSprite(gl_vissprite_t *spr) FOutVector wallVerts[4]; patch_t *gpatch; // sprite patch converted to hardware FSurfaceInfo Surf; - //const boolean papersprite = R_ThingIsPaperSprite(spr->mobj); + const boolean splat = R_ThingIsFloorSprite(spr->mobj); if (!spr->mobj) return; @@ -3907,7 +3911,7 @@ static void HWR_DrawSprite(gl_vissprite_t *spr) if (!spr->mobj->subsector) return; - if (spr->mobj->subsector->sector->numlights) + if (spr->mobj->subsector->sector->numlights && !splat) { HWR_SplitSprite(spr); return; @@ -3934,16 +3938,112 @@ static void HWR_DrawSprite(gl_vissprite_t *spr) // |/ | // 0--1 - // these were already scaled in HWR_ProjectSprite - wallVerts[0].x = wallVerts[3].x = spr->x1; - wallVerts[2].x = wallVerts[1].x = spr->x2; - wallVerts[2].y = wallVerts[3].y = spr->gzt; - wallVerts[0].y = wallVerts[1].y = spr->gz; + if (splat) + { + F2DCoord verts[4]; + F2DCoord rotated[4]; + angle_t angle; + float ca, sa; + float w, h; + float xscale, yscale; + float xoffset, yoffset; + float leftoffset, topoffset; + float scale = spr->scale; + float zoffset = (P_MobjFlip(spr->mobj) * 0.05f); + INT32 i; - // make a wall polygon (with 2 triangles), using the floor/ceiling heights, - // and the 2d map coords of start/end vertices - wallVerts[0].z = wallVerts[3].z = spr->z1; - wallVerts[1].z = wallVerts[2].z = spr->z2; + if (spr->renderflags & RF_SHADOWEFFECTS) + scale *= spr->shadowscale; + + if (spr->rotateflags & SRF_3D || spr->renderflags & RF_NOSPLATBILLBOARD) + angle = spr->mobj->angle; + else + angle = viewangle; + + if (!spr->rotated) + angle += spr->mobj->rollangle; + + angle = -angle; + angle += ANGLE_90; + + topoffset = (float)gpatch->topoffset; + leftoffset = (float)gpatch->leftoffset; + if (spr->flip) + leftoffset = ((float)gpatch->width - leftoffset); + + xscale = spr->scale * spr->spritexscale; + yscale = spr->scale * spr->spriteyscale; + + xoffset = leftoffset * xscale; + yoffset = topoffset * yscale; + + w = (float)gpatch->width * xscale; + h = (float)gpatch->height * yscale; + + // Set positions + + // 3--2 + // | | + // 0--1 + + verts[3].x = -xoffset; + verts[3].y = yoffset; + + verts[2].x = w - xoffset; + verts[2].y = yoffset; + + verts[1].x = w - xoffset; + verts[1].y = -h + yoffset; + + verts[0].x = -xoffset; + verts[0].y = -h + yoffset; + + ca = FIXED_TO_FLOAT(FINECOSINE((-angle)>>ANGLETOFINESHIFT)); + sa = FIXED_TO_FLOAT(FINESINE((-angle)>>ANGLETOFINESHIFT)); + + // Rotate + for (i = 0; i < 4; i++) + { + rotated[i].x = (verts[i].x * ca) - (verts[i].y * sa); + rotated[i].y = (verts[i].x * sa) + (verts[i].y * ca); + } + + // Translate + for (i = 0; i < 4; i++) + { + wallVerts[i].x = rotated[i].x + FIXED_TO_FLOAT(spr->mobj->x); + wallVerts[i].z = rotated[i].y + FIXED_TO_FLOAT(spr->mobj->y); + } + + if (spr->renderflags & RF_SLOPESPLAT && spr->mobj->standingslope) + { + pslope_t *slope = spr->mobj->standingslope; + + for (i = 0; i < 4; i++) + { + fixed_t slopez = P_GetSlopeZAt(slope, FLOAT_TO_FIXED(wallVerts[i].x), FLOAT_TO_FIXED(wallVerts[i].z)); + wallVerts[i].y = FIXED_TO_FLOAT(slopez) + zoffset; + } + } + else + { + for (i = 0; i < 4; i++) + wallVerts[i].y = FIXED_TO_FLOAT(spr->mobj->z) + zoffset; + } + } + else + { + // these were already scaled in HWR_ProjectSprite + wallVerts[0].x = wallVerts[3].x = spr->x1; + wallVerts[2].x = wallVerts[1].x = spr->x2; + wallVerts[2].y = wallVerts[3].y = spr->gzt; + wallVerts[0].y = wallVerts[1].y = spr->gz; + + // make a wall polygon (with 2 triangles), using the floor/ceiling heights, + // and the 2d map coords of start/end vertices + wallVerts[0].z = wallVerts[3].z = spr->z1; + wallVerts[1].z = wallVerts[2].z = spr->z2; + } if (spr->flip) { @@ -3969,18 +4069,21 @@ static void HWR_DrawSprite(gl_vissprite_t *spr) //Hurdler: 25/04/2000: now support colormap in hardware mode HWR_GetMappedPatch(gpatch, spr->colormap); - // if it has a dispoffset, push it a little towards the camera - if (spr->dispoffset) { - float co = -gl_viewcos*(0.05f*spr->dispoffset); - float si = -gl_viewsin*(0.05f*spr->dispoffset); - wallVerts[0].z = wallVerts[3].z = wallVerts[0].z+si; - wallVerts[1].z = wallVerts[2].z = wallVerts[1].z+si; - wallVerts[0].x = wallVerts[3].x = wallVerts[0].x+co; - wallVerts[1].x = wallVerts[2].x = wallVerts[1].x+co; - } + if (!splat) + { + // if it has a dispoffset, push it a little towards the camera + if (spr->dispoffset) { + float co = -gl_viewcos*(0.05f*spr->dispoffset); + float si = -gl_viewsin*(0.05f*spr->dispoffset); + wallVerts[0].z = wallVerts[3].z = wallVerts[0].z+si; + wallVerts[1].z = wallVerts[2].z = wallVerts[1].z+si; + wallVerts[0].x = wallVerts[3].x = wallVerts[0].x+co; + wallVerts[1].x = wallVerts[2].x = wallVerts[1].x+co; + } - // Let dispoffset work first since this adjust each vertex - HWR_RotateSpritePolyToAim(spr, wallVerts, false); + // Let dispoffset work first since this adjust each vertex + HWR_RotateSpritePolyToAim(spr, wallVerts, false); + } // This needs to be AFTER the shadows so that the regular sprites aren't drawn completely black. // sprite lighting by modulating the RGB components @@ -3990,6 +4093,7 @@ static void HWR_DrawSprite(gl_vissprite_t *spr) { sector_t *sector = spr->mobj->subsector->sector; UINT8 lightlevel; + boolean lightset = true; extracolormap_t *colormap = sector->extra_colormap; if (R_ThingIsFullBright(spr->mobj)) @@ -3997,6 +4101,19 @@ static void HWR_DrawSprite(gl_vissprite_t *spr) else if (R_ThingIsFullDark(spr->mobj)) lightlevel = 0; else + lightset = false; + + if (splat && sector->numlights) + { + INT32 light = R_GetPlaneLight(sector, spr->mobj->z, false); + + if (!lightset) + lightlevel = *sector->lightlist[light].lightlevel > 255 ? 255 : *sector->lightlist[light].lightlevel; + + if (*sector->lightlist[light].extra_colormap) + colormap = *sector->lightlist[light].extra_colormap; + } + else if (!lightset) lightlevel = sector->lightlevel > 255 ? 255 : sector->lightlevel; HWR_Lighting(&Surf, lightlevel, colormap); @@ -4038,6 +4155,18 @@ static void HWR_DrawSprite(gl_vissprite_t *spr) if (!occlusion) use_linkdraw_hack = true; } + if (spr->renderflags & RF_SHADOWEFFECTS) + { + INT32 alpha = Surf.PolyColor.s.alpha; + alpha -= ((INT32)(spr->shadowheight / 4.0f)) + 75; + if (alpha < 1) + return; + + Surf.PolyColor.s.alpha = (UINT8)(alpha); + blend = PF_Translucent|occlusion; + if (!occlusion) use_linkdraw_hack = true; + } + HWR_ProcessPolygon(&Surf, wallVerts, 4, blend|PF_Modulated|PF_Clip, 3, false); // sprite shader if (use_linkdraw_hack) @@ -4669,8 +4798,9 @@ static void HWR_ProjectSprite(mobj_t *thing) float tracertz = 0.0f; float x1, x2; float rightsin, rightcos; - float this_scale; + float this_scale, this_xscale, this_yscale; float spritexscale, spriteyscale; + float shadowheight = 1.0f, shadowscale = 1.0f; float gz, gzt; spritedef_t *sprdef; spriteframe_t *sprframe; @@ -4689,6 +4819,7 @@ static void HWR_ProjectSprite(mobj_t *thing) angle_t ang; INT32 heightsec, phs; const boolean papersprite = R_ThingIsPaperSprite(thing); + const boolean splat = R_ThingIsFloorSprite(thing); angle_t mobjangle = (thing->player ? thing->player->drawangle : thing->angle); float z1, z2; @@ -4716,7 +4847,7 @@ static void HWR_ProjectSprite(mobj_t *thing) tz = (tr_x * gl_viewcos) + (tr_y * gl_viewsin); // thing is behind view plane? - if (tz < ZCLIP_PLANE && !papersprite) + if (tz < ZCLIP_PLANE && !(papersprite || splat)) { if (cv_glmodels.value) //Yellow: Only MD2's dont disappear { @@ -4820,7 +4951,7 @@ static void HWR_ProjectSprite(mobj_t *thing) } if (thing->skin && ((skin_t *)thing->skin)->flags & SF_HIRES) - this_scale = this_scale * FIXED_TO_FLOAT(((skin_t *)thing->skin)->highresscale); + this_scale *= FIXED_TO_FLOAT(((skin_t *)thing->skin)->highresscale); spr_width = spritecachedinfo[lumpoff].width; spr_height = spritecachedinfo[lumpoff].height; @@ -4828,7 +4959,8 @@ static void HWR_ProjectSprite(mobj_t *thing) spr_topoffset = spritecachedinfo[lumpoff].topoffset; #ifdef ROTSPRITE - if (thing->rollangle) + if (thing->rollangle + && !(splat && !(thing->renderflags & RF_NOSPLATROLLANGLE))) { rollangle = R_GetRollAngle(thing->rollangle); rotsprite = Patch_GetRotatedSprite(sprframe, (thing->frame & FF_FRAMEMASK), rot, flip, false, sprinfo, rollangle); @@ -4860,18 +4992,36 @@ static void HWR_ProjectSprite(mobj_t *thing) flip = !flip != !hflip; - spritexscale *= this_scale; - spriteyscale *= this_scale; + if (thing->renderflags & RF_SHADOWEFFECTS) + { + mobj_t *caster = thing->target; + + if (caster && !P_MobjWasRemoved(caster)) + { + fixed_t groundz = R_GetShadowZ(thing, NULL); + fixed_t floordiff = abs(((thing->eflags & MFE_VERTICALFLIP) ? caster->height : 0) + caster->z - groundz); + + shadowheight = FIXED_TO_FLOAT(floordiff); + shadowscale = FIXED_TO_FLOAT(FixedMul(FRACUNIT - floordiff/640, caster->scale)); + + if (splat) + spritexscale *= shadowscale; + spriteyscale *= shadowscale; + } + } + + this_xscale = spritexscale * this_scale; + this_yscale = spriteyscale * this_scale; if (flip) { - x1 = (FIXED_TO_FLOAT(spr_width - spr_offset) * spritexscale); - x2 = (FIXED_TO_FLOAT(spr_offset) * spritexscale); + x1 = (FIXED_TO_FLOAT(spr_width - spr_offset) * this_xscale); + x2 = (FIXED_TO_FLOAT(spr_offset) * this_xscale); } else { - x1 = (FIXED_TO_FLOAT(spr_offset) * spritexscale); - x2 = (FIXED_TO_FLOAT(spr_width - spr_offset) * spritexscale); + x1 = (FIXED_TO_FLOAT(spr_offset) * this_xscale); + x2 = (FIXED_TO_FLOAT(spr_width - spr_offset) * this_xscale); } // test if too close @@ -4893,13 +5043,13 @@ static void HWR_ProjectSprite(mobj_t *thing) if (vflip) { - gz = FIXED_TO_FLOAT(thing->z+thing->height) - (FIXED_TO_FLOAT(spr_topoffset) * spriteyscale); - gzt = gz + (FIXED_TO_FLOAT(spr_height) * spriteyscale); + gz = FIXED_TO_FLOAT(thing->z + thing->height) - (FIXED_TO_FLOAT(spr_topoffset) * this_yscale); + gzt = gz + (FIXED_TO_FLOAT(spr_height) * this_yscale); } else { - gzt = FIXED_TO_FLOAT(thing->z) + (FIXED_TO_FLOAT(spr_topoffset) * spriteyscale); - gz = gzt - (FIXED_TO_FLOAT(spr_height) * spriteyscale); + gzt = FIXED_TO_FLOAT(thing->z) + (FIXED_TO_FLOAT(spr_topoffset) * this_yscale); + gz = gzt - (FIXED_TO_FLOAT(spr_height) * this_yscale); } if (thing->subsector->sector->cullheight) @@ -4956,19 +5106,37 @@ static void HWR_ProjectSprite(mobj_t *thing) vis = HWR_NewVisSprite(); vis->x1 = x1; vis->x2 = x2; + vis->z1 = z1; + vis->z2 = z2; + vis->tz = tz; // Keep tz for the simple sprite sorting that happens vis->tracertz = tracertz; + + vis->renderflags = thing->renderflags; + vis->rotateflags = sprframe->rotate; + + vis->shadowheight = shadowheight; + vis->shadowscale = shadowscale; vis->dispoffset = dispoffset; // Monster Iestyn: 23/11/15: HARDWARE SUPPORT AT LAST + vis->flip = flip; + + vis->scale = this_scale; + vis->spritexscale = spritexscale; + vis->spriteyscale = spriteyscale; + + vis->rotated = false; + #ifdef ROTSPRITE if (rotsprite) + { vis->gpatch = (patch_t *)rotsprite; + vis->rotated = true; + } else #endif vis->gpatch = (patch_t *)W_CachePatchNum(sprframe->lumppat[rot], PU_SPRITE); - vis->flip = flip; + vis->mobj = thing; - vis->z1 = z1; - vis->z2 = z2; //Hurdler: 25/04/2000: now support colormap in hardware mode if ((vis->mobj->flags & (MF_ENEMY|MF_BOSS)) && (vis->mobj->flags2 & MF2_FRET) && !(vis->mobj->flags & MF_GRENADEBOUNCE) && (leveltime & 1)) // Bosses "flash" diff --git a/src/r_defs.h b/src/r_defs.h index d32313a46..749638db3 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -718,8 +718,9 @@ typedef enum RF_HORIZONTALFLIP = 0x0001, // Flip sprite horizontally RF_VERTICALFLIP = 0x0002, // Flip sprite vertically RF_ONESIDED = 0x0004, // Wall/floor sprite is visible from front only - RF_NOSPLATBILLBOARD = 0x0008, // Don't billboard floor sprites (faces forward from the view angle) - RF_NOSPLATROLLANGLE = 0x0010, // Don't rotate floor sprites by the object's rollangle (uses rotated patches instead) + RF_SLOPESPLAT = 0x0008, // Rotate floor sprites by the object's standing slope + RF_NOSPLATBILLBOARD = 0x0010, // Don't billboard floor sprites (faces forward from the view angle) + RF_NOSPLATROLLANGLE = 0x0020, // Don't rotate floor sprites by the object's rollangle (uses rotated patches instead) RF_BLENDMASK = 0x0F00, // --Blending modes RF_FULLBRIGHT = 0x0100, // Sprite is drawn at full brightness diff --git a/src/r_things.c b/src/r_things.c index 00bb0b32a..79be4c5bd 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -1821,15 +1821,17 @@ static void R_ProjectSprite(mobj_t *thing) if (shadowdraw) { - spritexscale = FixedMul(thing->radius * 2, shadowscale); - spriteyscale = FixedMul(thing->radius * 2, shadowscale); + spritexscale = FixedMul(thing->radius * 2, FixedMul(shadowscale, spritexscale)); + spriteyscale = FixedMul(thing->radius * 2, FixedMul(shadowscale, spriteyscale)); spriteyscale = FixedMul(spriteyscale, FixedDiv(abs(groundz - viewz), tz)); spriteyscale = min(spriteyscale, spritexscale) / patch->height; + spritexscale /= patch->width; } else - spritexscale = spriteyscale = shadowscale; - - spritexscale /= patch->width; + { + spritexscale = FixedMul(shadowscale, spritexscale); + spriteyscale = FixedMul(shadowscale, spriteyscale); + } if (shadowskew) { @@ -1951,13 +1953,13 @@ static void R_ProjectSprite(mobj_t *thing) vis->spritexscale = spritexscale; vis->spriteyscale = spriteyscale; + vis->shadowscale = shadowscale; if (shadowdraw || shadoweffects) { iscale = (patch->width<shear.offset = vis->x1-x1; - vis->shadowscale = shadowscale; } else iscale = FixedDiv(FRACUNIT, vis->xscale); @@ -2748,9 +2750,6 @@ static void R_DrawVisSplat(vissprite_t *spr) splat.height = spr->patch->height; splat.scale = spr->mobj->scale; - if (spr->renderflags & RF_SHADOWEFFECTS) - splat.scale = FixedMul(splat.scale, spr->shadowscale); - if (spr->rotateflags & SRF_3D || spr->renderflags & RF_NOSPLATBILLBOARD) splatangle = spr->mobj->angle; else @@ -2767,8 +2766,8 @@ static void R_DrawVisSplat(vissprite_t *spr) if (hflip) leftoffset = ((splat.width * FRACUNIT) - leftoffset); - xscale = spr->mobj->spritexscale; - yscale = spr->mobj->spriteyscale; + xscale = spr->spritexscale; + yscale = spr->spriteyscale; splat.xscale = FixedMul(splat.scale, xscale); splat.yscale = FixedMul(splat.scale, yscale); From 453f49cb779d08dd17eac401ebed8cb71e954875 Mon Sep 17 00:00:00 2001 From: Jaime Passos Date: Mon, 12 Oct 2020 22:07:11 -0300 Subject: [PATCH 0162/1080] Fix floorsprites not being rendered when viewed from the bottom --- src/r_splats.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/r_splats.c b/src/r_splats.c index 0b2826107..cddbbf85f 100644 --- a/src/r_splats.c +++ b/src/r_splats.c @@ -261,6 +261,13 @@ void R_RenderFloorSplat(floorsplat_t *pSplat, vertex_t *verts, vissprite_t *vis) x1 = rastertab[y].minx>>FRACBITS; x2 = rastertab[y].maxx>>FRACBITS; + if (x1 > x2) + { + INT32 swap = x1; + x1 = x2; + x2 = swap; + } + if (x1 < 0) x1 = 0; if (x2 >= vid.width) From 1ea3bd8fff1807d6093ed3e8b37db7b1f667fe8d Mon Sep 17 00:00:00 2001 From: Jaime Passos Date: Mon, 12 Oct 2020 22:08:45 -0300 Subject: [PATCH 0163/1080] Fix uninitialized variable warning --- src/hardware/hw_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 98f3d69da..5c450e9d2 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -4092,7 +4092,7 @@ static void HWR_DrawSprite(gl_vissprite_t *spr) // colormap test { sector_t *sector = spr->mobj->subsector->sector; - UINT8 lightlevel; + UINT8 lightlevel = 0; boolean lightset = true; extracolormap_t *colormap = sector->extra_colormap; From f2aca01e2b441d0f44cdf363231c37ebd545aa21 Mon Sep 17 00:00:00 2001 From: Jaime Passos Date: Tue, 13 Oct 2020 00:14:27 -0300 Subject: [PATCH 0164/1080] Fix other uninitialized variable warnings --- src/r_things.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/r_things.c b/src/r_things.c index 79be4c5bd..f1d564362 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -1456,7 +1456,7 @@ static void R_ProjectSprite(mobj_t *thing) INT32 dispoffset = thing->info->dispoffset; //SoM: 3/17/2000 - fixed_t gz, gzt; + fixed_t gz = 0, gzt = 0; INT32 heightsec, phs; INT32 light = 0; fixed_t this_scale = thing->scale; From 7dbd34345c717d76735a8e06daab92f8af7cdcae Mon Sep 17 00:00:00 2001 From: Jaime Passos Date: Tue, 13 Oct 2020 01:09:17 -0300 Subject: [PATCH 0165/1080] Fix splat sorting --- src/r_things.c | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/src/r_things.c b/src/r_things.c index f1d564362..d873b806b 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -2630,7 +2630,32 @@ static void R_CreateDrawNodes(maskcount_t* mask, drawnode_t* head, boolean temps } else if (r2->sprite) { - if (!(r2->sprite->cut & SC_SPLAT || rover->cut & SC_SPLAT)) + boolean infront = (r2->sprite->sortscale > rover->sortscale + || (r2->sprite->sortscale == rover->sortscale && r2->sprite->dispoffset > rover->dispoffset)); + + if (rover->cut & SC_SPLAT + && r2->sprite->cut & SC_SPLAT) + { + fixed_t z1 = 0, z2 = 0; + + if (rover->mobj->z - viewz > 0) + { + z1 = rover->pz; + z2 = r2->sprite->pz; + } + else + { + z1 = r2->sprite->pz; + z2 = rover->pz; + } + + z1 -= viewz; + z2 -= viewz; + + if (z1 >= z2) + infront = true; + } + else { if (r2->sprite->x1 > rover->x2 || r2->sprite->x2 < rover->x1) continue; @@ -2638,8 +2663,7 @@ static void R_CreateDrawNodes(maskcount_t* mask, drawnode_t* head, boolean temps continue; } - if (r2->sprite->sortscale > rover->sortscale - || (r2->sprite->sortscale == rover->sortscale && r2->sprite->dispoffset > rover->dispoffset)) + if (infront) { entry = R_CreateDrawNode(NULL); (entry->prev = r2->prev)->next = entry; From 95d0097df6afb89d13886088b7ac7a9d6f450a15 Mon Sep 17 00:00:00 2001 From: Jaime Passos Date: Tue, 13 Oct 2020 01:45:18 -0300 Subject: [PATCH 0166/1080] Improve splat sorting: Adjust the sort scale of splats Do splat sorting in R_CreateDrawNodes if either vissprite is a splat, instead of if both are --- src/r_things.c | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/src/r_things.c b/src/r_things.c index d873b806b..56b645bf9 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -1743,6 +1743,18 @@ static void R_ProjectSprite(mobj_t *thing) return; } + // Adjust sort scale + tr_x = tr_y = 0; + + if (splat) + { + tz = (patch->height - patch->topoffset) * FRACUNIT; + ang = (viewangle >> ANGLETOFINESHIFT); + + tr_x = FixedMul(FixedMul(FixedMul(spritexscale, this_scale), tz), FINECOSINE(ang)); + tr_y = FixedMul(FixedMul(FixedMul(spriteyscale, this_scale), tz), FINESINE(ang)); + } + if ((thing->flags2 & MF2_LINKDRAW) && thing->tracer) // toast 16/09/16 (SYMMETRY) { fixed_t linkscale; @@ -1752,8 +1764,8 @@ static void R_ProjectSprite(mobj_t *thing) if (! R_ThingVisible(thing)) return; - tr_x = thing->x - viewx; - tr_y = thing->y - viewy; + tr_x = (thing->x + tr_x) - viewx; + tr_y = (thing->y + tr_y) - viewy; tz = FixedMul(tr_x, viewcos) + FixedMul(tr_y, viewsin); linkscale = FixedDiv(projectiony, tz); @@ -1766,6 +1778,13 @@ static void R_ProjectSprite(mobj_t *thing) sortscale = linkscale; // now make sure it's linked cut |= SC_LINKDRAW; } + else if (splat) + { + tr_x = (thing->x + tr_x) - viewx; + tr_y = (thing->y + tr_y) - viewy; + tz = FixedMul(tr_x, viewcos) + FixedMul(tr_y, viewsin); + sortscale = FixedDiv(projectiony, tz); + } // PORTAL SPRITE CLIPPING if (portalrender && portalclipline) @@ -2634,7 +2653,7 @@ static void R_CreateDrawNodes(maskcount_t* mask, drawnode_t* head, boolean temps || (r2->sprite->sortscale == rover->sortscale && r2->sprite->dispoffset > rover->dispoffset)); if (rover->cut & SC_SPLAT - && r2->sprite->cut & SC_SPLAT) + || r2->sprite->cut & SC_SPLAT) { fixed_t z1 = 0, z2 = 0; @@ -2652,8 +2671,7 @@ static void R_CreateDrawNodes(maskcount_t* mask, drawnode_t* head, boolean temps z1 -= viewz; z2 -= viewz; - if (z1 >= z2) - infront = true; + infront = (z1 >= z2); } else { From 87e5d63723c4962c493efa33575ac7122ce66cde Mon Sep 17 00:00:00 2001 From: Jaime Passos Date: Tue, 13 Oct 2020 02:24:18 -0300 Subject: [PATCH 0167/1080] Improve sorting between sprites and floor sprites --- src/r_things.c | 67 ++++++++++++++++++++++++++++++-------------------- src/r_things.h | 4 ++- 2 files changed, 44 insertions(+), 27 deletions(-) diff --git a/src/r_things.c b/src/r_things.c index 56b645bf9..e23c08eb1 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -1413,7 +1413,9 @@ static void R_ProjectSprite(mobj_t *thing) mobj_t *oldthing = thing; fixed_t tr_x, tr_y; fixed_t tx, tz; - fixed_t xscale, yscale, sortscale; //added : 02-02-98 : aaargll..if I were a math-guy!!! + fixed_t xscale, yscale; //added : 02-02-98 : aaargll..if I were a math-guy!!! + fixed_t sortscale, sortsplat = 0; + fixed_t sort_x = 0, sort_y = 0; INT32 x1, x2; @@ -1743,16 +1745,13 @@ static void R_ProjectSprite(mobj_t *thing) return; } - // Adjust sort scale - tr_x = tr_y = 0; - + // Adjust the sort scale if needed if (splat) { tz = (patch->height - patch->topoffset) * FRACUNIT; ang = (viewangle >> ANGLETOFINESHIFT); - - tr_x = FixedMul(FixedMul(FixedMul(spritexscale, this_scale), tz), FINECOSINE(ang)); - tr_y = FixedMul(FixedMul(FixedMul(spriteyscale, this_scale), tz), FINESINE(ang)); + sort_x = FixedMul(FixedMul(FixedMul(spritexscale, this_scale), tz), FINECOSINE(ang)); + sort_y = FixedMul(FixedMul(FixedMul(spriteyscale, this_scale), tz), FINESINE(ang)); } if ((thing->flags2 & MF2_LINKDRAW) && thing->tracer) // toast 16/09/16 (SYMMETRY) @@ -1764,8 +1763,8 @@ static void R_ProjectSprite(mobj_t *thing) if (! R_ThingVisible(thing)) return; - tr_x = (thing->x + tr_x) - viewx; - tr_y = (thing->y + tr_y) - viewy; + tr_x = (thing->x + sort_x) - viewx; + tr_y = (thing->y + sort_y) - viewy; tz = FixedMul(tr_x, viewcos) + FixedMul(tr_y, viewsin); linkscale = FixedDiv(projectiony, tz); @@ -1780,12 +1779,21 @@ static void R_ProjectSprite(mobj_t *thing) } else if (splat) { - tr_x = (thing->x + tr_x) - viewx; - tr_y = (thing->y + tr_y) - viewy; + tr_x = (thing->x + sort_x) - viewx; + tr_y = (thing->y + sort_y) - viewy; tz = FixedMul(tr_x, viewcos) + FixedMul(tr_y, viewsin); sortscale = FixedDiv(projectiony, tz); } + // Calculate the splat's sortscale + if (splat) + { + tr_x = (thing->x - sort_x) - viewx; + tr_y = (thing->y - sort_y) - viewy; + tz = FixedMul(tr_x, viewcos) + FixedMul(tr_y, viewsin); + sortsplat = FixedDiv(projectiony, tz); + } + // PORTAL SPRITE CLIPPING if (portalrender && portalclipline) { @@ -1936,6 +1944,7 @@ static void R_ProjectSprite(mobj_t *thing) vis->heightsec = heightsec; //SoM: 3/17/2000 vis->mobjflags = thing->flags; vis->sortscale = sortscale; + vis->sortsplat = sortsplat; vis->dispoffset = dispoffset; // Monster Iestyn: 23/11/15 vis->gx = thing->x; vis->gy = thing->y; @@ -2652,26 +2661,32 @@ static void R_CreateDrawNodes(maskcount_t* mask, drawnode_t* head, boolean temps boolean infront = (r2->sprite->sortscale > rover->sortscale || (r2->sprite->sortscale == rover->sortscale && r2->sprite->dispoffset > rover->dispoffset)); - if (rover->cut & SC_SPLAT - || r2->sprite->cut & SC_SPLAT) + if (rover->cut & SC_SPLAT || r2->sprite->cut & SC_SPLAT) { - fixed_t z1 = 0, z2 = 0; + fixed_t scale1 = (rover->cut & SC_SPLAT ? rover->sortsplat : rover->sortscale); + fixed_t scale2 = (r2->sprite->cut & SC_SPLAT ? r2->sprite->sortsplat : r2->sprite->sortscale); + boolean behind = (scale2 > scale1 || (scale2 == scale1 && r2->sprite->dispoffset > rover->dispoffset)); - if (rover->mobj->z - viewz > 0) + if (!behind) { - z1 = rover->pz; - z2 = r2->sprite->pz; - } - else - { - z1 = r2->sprite->pz; - z2 = rover->pz; - } + fixed_t z1 = 0, z2 = 0; - z1 -= viewz; - z2 -= viewz; + if (rover->mobj->z - viewz > 0) + { + z1 = rover->pz; + z2 = r2->sprite->pz; + } + else + { + z1 = r2->sprite->pz; + z2 = rover->pz; + } - infront = (z1 >= z2); + z1 -= viewz; + z2 -= viewz; + + infront = (z1 >= z2); + } } else { diff --git a/src/r_things.h b/src/r_things.h index 16cf5088f..643b2ca9e 100644 --- a/src/r_things.h +++ b/src/r_things.h @@ -155,7 +155,9 @@ typedef struct vissprite_s fixed_t pz, pzt; // physical bottom/top for sorting with 3D floors fixed_t startfrac; // horizontal position of x1 - fixed_t scale, sortscale; // sortscale only differs from scale for paper sprites and MF2_LINKDRAW + fixed_t scale; + fixed_t sortscale; // sortscale only differs from scale for paper sprites, floor sprites, and MF2_LINKDRAW + fixed_t sortsplat; // the sortscale from behind the floor sprite fixed_t scalestep; // only for paper sprites, 0 otherwise fixed_t paperoffset, paperdistance; // for paper sprites, offset/dist relative to the angle fixed_t xiscale; // negative if flipped From 2ba1017dab3caaef938450f9af41f6db2af513c1 Mon Sep 17 00:00:00 2001 From: Zippy_Zolton Date: Tue, 13 Oct 2020 02:13:35 -0500 Subject: [PATCH 0168/1080] More whitelists :D --- src/w_wad.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/src/w_wad.c b/src/w_wad.c index 5d10cbd10..dd5018cf1 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -2074,14 +2074,40 @@ int W_VerifyNMUSlumps(const char *filename) {"CLM", 3}, // Colormap changes {"TRANS", 5}, // Translucency map changes + {"CONSBACK", 8}, // Console Background graphic + {"SAVE", 4}, // Save Select graphics + {"ULTIMATE", 8}, // Ultimate no-save {"LTFNT", 5}, // Level title font changes {"TTL", 3}, // Act number changes {"STCFN", 5}, // Console font changes {"TNYFN", 5}, // Tiny console font changes - {"STT", 3}, // Acceptable HUD changes (Score Time Rings) {"STLIVEX", 7}, // "X" that shows under skin's HUDNAME + {"STT", 3}, // Acceptable HUD changes (Score Time Rings) {"YB_", 3}, // Intermission graphics, goes with the above + {"RESULT", 6}, // Used in intermission for competitive modes, above too :3 + {"RACE", 4}, // Race mode graphics, 321go {"M_", 2}, // As does menu stuff + + {"MINICAPS", 8}, // NiGHTS graphics here and below + {"BLUESTAT", 8}, // Sphere status + {"BYELSTAT", 8}, + {"ORNGSTAT", 8}, + {"REDSTAT", 7}, + {"YELSTAT", 7}, + {"NBRACKET", 8}, + {"NGHTLINK", 8}, + {"NGT", 3}, // Link numbers + {"NARROW", 6}, + {"NREDAR", 6}, + {"NSS", 3}, + {"NBON", 4}, + {"NRNG", 4}, + {"NHUD", 4}, + {"CAPS", 4}, + {"DRILL", 5}, + {"GRADE", 5}, + {"MINUS5", 6}, + {"MUSICDEF", 8}, // Song definitions (thanks kart) {NULL, 0}, From 45b52e372965d8e2eb116e1da7da5ce6be0b50b9 Mon Sep 17 00:00:00 2001 From: Zippy_Zolton Date: Tue, 13 Oct 2020 02:19:20 -0500 Subject: [PATCH 0169/1080] good night --- src/w_wad.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/w_wad.c b/src/w_wad.c index dd5018cf1..0f0ad97f0 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -2075,8 +2075,12 @@ int W_VerifyNMUSlumps(const char *filename) {"TRANS", 5}, // Translucency map changes {"CONSBACK", 8}, // Console Background graphic + {"GAMEQUIT", 8}, {"SAVE", 4}, // Save Select graphics {"ULTIMATE", 8}, // Ultimate no-save + {"CRFNT", 5}, // Sonic 1 font changes + {"NTFNT", 5}, // Character Select font changes + {"NTFNO", 5}, // Character Select font (outline) {"LTFNT", 5}, // Level title font changes {"TTL", 3}, // Act number changes {"STCFN", 5}, // Console font changes From 4273896311a3bead49867683e234ab7793d79a21 Mon Sep 17 00:00:00 2001 From: Jaime Passos Date: Tue, 13 Oct 2020 12:57:36 -0300 Subject: [PATCH 0170/1080] Implement relative and absolute sprite offsets for objects (mobjs) Added RF_ABSOLUTEOFFSETS and RF_FLIPOFFSETS --- src/d_clisrv.c | 16 ++++++++++---- src/d_clisrv.h | 8 +++++-- src/dehacked.c | 4 +++- src/hardware/hw_glob.h | 4 +++- src/hardware/hw_main.c | 22 +++++++++++++++++-- src/lua_mobjlib.c | 48 ++++++++++++++++++++++++++++-------------- src/p_mobj.c | 5 ++++- src/p_mobj.h | 10 +++++++-- src/p_saveg.c | 18 ++++++++++++++-- src/r_defs.h | 10 +++++---- src/r_things.c | 25 +++++++++++++++++++--- src/r_things.h | 2 ++ 12 files changed, 134 insertions(+), 38 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 3db5a6207..636e2bfa8 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -643,6 +643,12 @@ static inline void resynch_write_player(resynch_pak *rsp, const size_t i) rsp->frame = LONG(players[i].mo->frame); rsp->sprite2 = players[i].mo->sprite2; rsp->anim_duration = SHORT(players[i].mo->anim_duration); + + rsp->spritexscale = LONG(players[i].mo->spritexscale); + rsp->spriteyscale = LONG(players[i].mo->spriteyscale); + rsp->spritexoffset = LONG(players[i].mo->spritexoffset); + rsp->spriteyoffset = LONG(players[i].mo->spriteyoffset); + rsp->tics = LONG(players[i].mo->tics); rsp->statenum = (statenum_t)LONG(players[i].mo->state-states); // :( rsp->eflags = (UINT16)SHORT(players[i].mo->eflags); @@ -655,8 +661,6 @@ static inline void resynch_write_player(resynch_pak *rsp, const size_t i) rsp->scale = LONG(players[i].mo->scale); rsp->destscale = LONG(players[i].mo->destscale); rsp->scalespeed = LONG(players[i].mo->scalespeed); - rsp->spritexscale = LONG(players[i].mo->spritexscale); - rsp->spriteyscale = LONG(players[i].mo->spriteyscale); } static void resynch_read_player(resynch_pak *rsp) @@ -805,6 +809,12 @@ static void resynch_read_player(resynch_pak *rsp) players[i].mo->frame = LONG(rsp->frame); players[i].mo->sprite2 = rsp->sprite2; players[i].mo->anim_duration = SHORT(rsp->anim_duration); + + players[i].mo->spritexscale = LONG(rsp->spritexscale); + players[i].mo->spriteyscale = LONG(rsp->spriteyscale); + players[i].mo->spritexoffset = LONG(rsp->spritexoffset); + players[i].mo->spriteyoffset = LONG(rsp->spriteyoffset); + players[i].mo->tics = LONG(rsp->tics); players[i].mo->state = &states[LONG(rsp->statenum)]; @@ -817,8 +827,6 @@ static void resynch_read_player(resynch_pak *rsp) players[i].mo->scale = LONG(rsp->scale); players[i].mo->destscale = LONG(rsp->destscale); players[i].mo->scalespeed = LONG(rsp->scalespeed); - players[i].mo->spritexscale = LONG(rsp->spritexscale); - players[i].mo->spriteyscale = LONG(rsp->spriteyscale); // And finally, SET THE MOBJ SKIN damn it. if ((players[i].powers[pw_carry] == CR_NIGHTSMODE) && (skins[players[i].skin].sprites[SPR2_NFLY].numframes == 0)) diff --git a/src/d_clisrv.h b/src/d_clisrv.h index 0ed0b10f5..94cec3ff7 100644 --- a/src/d_clisrv.h +++ b/src/d_clisrv.h @@ -288,6 +288,12 @@ typedef struct UINT32 frame; UINT8 sprite2; UINT16 anim_duration; + + fixed_t spritexscale; + fixed_t spriteyscale; + fixed_t spritexoffset; + fixed_t spriteyoffset; + INT32 tics; statenum_t statenum; UINT32 flags; @@ -300,8 +306,6 @@ typedef struct fixed_t scale; fixed_t destscale; fixed_t scalespeed; - fixed_t spritexscale; - fixed_t spriteyscale; } ATTRPACK resynch_pak; typedef struct diff --git a/src/dehacked.c b/src/dehacked.c index aa4a04be4..0662074ba 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -9583,10 +9583,12 @@ struct { // Render flags {"RF_HORIZONTALFLIP",RF_HORIZONTALFLIP}, {"RF_VERTICALFLIP",RF_VERTICALFLIP}, - {"RF_ONESIDED",RF_ONESIDED}, + {"RF_ABSOLUTEOFFSETS",RF_ABSOLUTEOFFSETS}, + {"RF_FLIPOFFSETS",RF_FLIPOFFSETS}, {"RF_SLOPESPLAT",RF_SLOPESPLAT}, {"RF_NOSPLATBILLBOARD",RF_NOSPLATBILLBOARD}, {"RF_NOSPLATROLLANGLE",RF_NOSPLATROLLANGLE}, + {"RF_BLENDMASK",RF_BLENDMASK}, {"RF_FULLBRIGHT",RF_FULLBRIGHT}, {"RF_FULLDARK",RF_FULLDARK}, {"RF_SPRITETYPEMASK",RF_SPRITETYPEMASK}, diff --git a/src/hardware/hw_glob.h b/src/hardware/hw_glob.h index cb517b611..6a9bb257c 100644 --- a/src/hardware/hw_glob.h +++ b/src/hardware/hw_glob.h @@ -69,9 +69,11 @@ typedef struct gl_vissprite_s float tracertz; // for MF2_LINKDRAW sprites, this contains tracer's tz for use in sorting float scale; - float spritexscale, spriteyscale; float shadowheight, shadowscale; + float spritexscale, spriteyscale; + float spritexoffset, spriteyoffset; + UINT32 renderflags; UINT8 rotateflags; diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 5c450e9d2..315737108 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -3966,8 +3966,8 @@ static void HWR_DrawSprite(gl_vissprite_t *spr) angle = -angle; angle += ANGLE_90; - topoffset = (float)gpatch->topoffset; - leftoffset = (float)gpatch->leftoffset; + topoffset = spr->spriteyoffset; + leftoffset = spr->spritexoffset; if (spr->flip) leftoffset = ((float)gpatch->width - leftoffset); @@ -4979,6 +4979,22 @@ static void HWR_ProjectSprite(mobj_t *thing) } #endif + if (thing->renderflags & RF_ABSOLUTEOFFSETS) + { + spr_offset = thing->spritexoffset; + spr_topoffset = thing->spriteyoffset; + } + else + { + SINT8 flipoffset = 1; + + if ((thing->renderflags & RF_FLIPOFFSETS) && flip) + flipoffset = -1; + + spr_offset += thing->spritexoffset * flipoffset; + spr_topoffset += thing->spriteyoffset * flipoffset; + } + if (papersprite) { rightsin = FIXED_TO_FLOAT(FINESINE((mobjangle)>>ANGLETOFINESHIFT)); @@ -5123,6 +5139,8 @@ static void HWR_ProjectSprite(mobj_t *thing) vis->scale = this_scale; vis->spritexscale = spritexscale; vis->spriteyscale = spriteyscale; + vis->spritexoffset = FIXED_TO_FLOAT(spr_offset); + vis->spriteyoffset = FIXED_TO_FLOAT(spr_topoffset); vis->rotated = false; diff --git a/src/lua_mobjlib.c b/src/lua_mobjlib.c index c390eb064..a544f151c 100644 --- a/src/lua_mobjlib.c +++ b/src/lua_mobjlib.c @@ -39,6 +39,10 @@ enum mobj_e { mobj_frame, mobj_sprite2, mobj_anim_duration, + mobj_spritexscale, + mobj_spriteyscale, + mobj_spritexoffset, + mobj_spriteyoffset, mobj_touching_sectorlist, mobj_subsector, mobj_floorz, @@ -84,8 +88,6 @@ enum mobj_e { mobj_scale, mobj_destscale, mobj_scalespeed, - mobj_spritexscale, - mobj_spriteyscale, mobj_extravalue1, mobj_extravalue2, mobj_cusval, @@ -111,6 +113,10 @@ static const char *const mobj_opt[] = { "frame", "sprite2", "anim_duration", + "spritexscale", + "spriteyscale", + "spritexoffset", + "spriteyoffset", "touching_sectorlist", "subsector", "floorz", @@ -156,8 +162,6 @@ static const char *const mobj_opt[] = { "scale", "destscale", "scalespeed", - "spritexscale", - "spriteyscale", "extravalue1", "extravalue2", "cusval", @@ -233,6 +237,18 @@ static int mobj_get(lua_State *L) case mobj_anim_duration: lua_pushinteger(L, mo->anim_duration); break; + case mobj_spritexscale: + lua_pushfixed(L, mo->spritexscale); + break; + case mobj_spriteyscale: + lua_pushfixed(L, mo->spriteyscale); + break; + case mobj_spritexoffset: + lua_pushfixed(L, mo->spritexoffset); + break; + case mobj_spriteyoffset: + lua_pushfixed(L, mo->spriteyoffset); + break; case mobj_touching_sectorlist: return UNIMPLEMENTED; case mobj_subsector: @@ -390,12 +406,6 @@ static int mobj_get(lua_State *L) case mobj_scalespeed: lua_pushfixed(L, mo->scalespeed); break; - case mobj_spritexscale: - lua_pushfixed(L, mo->spritexscale); - break; - case mobj_spriteyscale: - lua_pushfixed(L, mo->spriteyscale); - break; case mobj_extravalue1: lua_pushinteger(L, mo->extravalue1); break; @@ -507,6 +517,18 @@ static int mobj_set(lua_State *L) case mobj_anim_duration: mo->anim_duration = (UINT16)luaL_checkinteger(L, 3); break; + case mobj_spritexscale: + mo->spritexscale = luaL_checkfixed(L, 3); + break; + case mobj_spriteyscale: + mo->spriteyscale = luaL_checkfixed(L, 3); + break; + case mobj_spritexoffset: + mo->spritexoffset = luaL_checkfixed(L, 3); + break; + case mobj_spriteyoffset: + mo->spriteyoffset = luaL_checkfixed(L, 3); + break; case mobj_touching_sectorlist: return UNIMPLEMENTED; case mobj_subsector: @@ -739,12 +761,6 @@ static int mobj_set(lua_State *L) case mobj_scalespeed: mo->scalespeed = luaL_checkfixed(L, 3); break; - case mobj_spritexscale: - mo->spritexscale = luaL_checkfixed(L, 3); - break; - case mobj_spriteyscale: - mo->spriteyscale = luaL_checkfixed(L, 3); - break; case mobj_extravalue1: mo->extravalue1 = luaL_checkinteger(L, 3); break; diff --git a/src/p_mobj.c b/src/p_mobj.c index 827650ce6..2260ace51 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -10465,12 +10465,15 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type) mobj->scale = FRACUNIT; mobj->destscale = mobj->scale; mobj->scalespeed = FRACUNIT/12; - mobj->spritexscale = mobj->spriteyscale = mobj->scale; // TODO: Make this a special map header if ((maptol & TOL_ERZ3) && !(mobj->type == MT_BLACKEGGMAN)) mobj->destscale = FRACUNIT/2; + // Sprite rendering + mobj->spritexscale = mobj->spriteyscale = mobj->scale; + mobj->spritexoffset = mobj->spriteyoffset = 0; + // set subsector and/or block links P_SetThingPosition(mobj); I_Assert(mobj->subsector != NULL); diff --git a/src/p_mobj.h b/src/p_mobj.h index eb8a9ccc2..0b688a9ad 100644 --- a/src/p_mobj.h +++ b/src/p_mobj.h @@ -286,6 +286,10 @@ typedef struct mobj_s UINT8 sprite2; // player sprites UINT16 anim_duration; // for FF_ANIMATE states + UINT32 renderflags; // render flags + fixed_t spritexscale, spriteyscale; + fixed_t spritexoffset, spriteyoffset; + struct msecnode_s *touching_sectorlist; // a linked list of sectors where this object appears struct subsector_s *subsector; // Subsector the mobj resides in. @@ -309,7 +313,6 @@ typedef struct mobj_s UINT32 flags; // flags from mobjinfo tables UINT32 flags2; // MF2_ flags UINT16 eflags; // extra flags - UINT32 renderflags; // render flags void *skin; // overrides 'sprite' when non-NULL (for player bodies to 'remember' the skin) // Player and mobj sprites in multiplayer modes are modified @@ -362,7 +365,6 @@ typedef struct mobj_s fixed_t scale; fixed_t destscale; fixed_t scalespeed; - fixed_t spritexscale, spriteyscale; // Extra values are for internal use for whatever you want INT32 extravalue1; @@ -409,6 +411,10 @@ typedef struct precipmobj_s UINT8 sprite2; // player sprites UINT16 anim_duration; // for FF_ANIMATE states + UINT32 renderflags; // render flags + fixed_t spritexscale, spriteyscale; + fixed_t spritexoffset, spriteyoffset; + struct mprecipsecnode_s *touching_sectorlist; // a linked list of sectors where this object appears struct subsector_s *subsector; // Subsector the mobj resides in. diff --git a/src/p_saveg.c b/src/p_saveg.c index d613efd70..3a9663326 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -1395,8 +1395,10 @@ typedef enum MD2_ROLLANGLE = 1<<14, MD2_SPRITEXSCALE = 1<<15, MD2_SPRITEYSCALE = 1<<16, - MD2_SHADOWSCALE = 1<<17, - MD2_RENDERFLAGS = 1<<18, + MD2_SPRITEXOFFSET = 1<<17, + MD2_SPRITEYOFFSET = 1<<18, + MD2_SHADOWSCALE = 1<<19, + MD2_RENDERFLAGS = 1<<20, } mobj_diff2_t; typedef enum @@ -1611,6 +1613,10 @@ static void SaveMobjThinker(const thinker_t *th, const UINT8 type) diff2 |= MD2_SPRITEXSCALE; if (mobj->spriteyscale != FRACUNIT) diff2 |= MD2_SPRITEYSCALE; + if (mobj->spritexoffset) + diff2 |= MD2_SPRITEXOFFSET; + if (mobj->spriteyoffset) + diff2 |= MD2_SPRITEYOFFSET; if (mobj->shadowscale) diff2 |= MD2_SHADOWSCALE; if (mobj->renderflags) @@ -1759,6 +1765,10 @@ static void SaveMobjThinker(const thinker_t *th, const UINT8 type) WRITEFIXED(save_p, mobj->spritexscale); if (diff2 & MD2_SPRITEYSCALE) WRITEFIXED(save_p, mobj->spriteyscale); + if (diff2 & MD2_SPRITEXOFFSET) + WRITEFIXED(save_p, mobj->spritexoffset); + if (diff2 & MD2_SPRITEYOFFSET) + WRITEFIXED(save_p, mobj->spriteyoffset); if (diff2 & MD2_SHADOWSCALE) WRITEFIXED(save_p, mobj->shadowscale); if (diff2 & MD2_RENDERFLAGS) @@ -2774,6 +2784,10 @@ static thinker_t* LoadMobjThinker(actionf_p1 thinker) mobj->spritexscale = READFIXED(save_p); if (diff2 & MD2_SPRITEYSCALE) mobj->spriteyscale = READFIXED(save_p); + if (diff2 & MD2_SPRITEXOFFSET) + mobj->spritexoffset = READFIXED(save_p); + if (diff2 & MD2_SPRITEYOFFSET) + mobj->spriteyoffset = READFIXED(save_p); if (diff2 & MD2_SHADOWSCALE) mobj->shadowscale = READFIXED(save_p); if (diff2 & MD2_RENDERFLAGS) diff --git a/src/r_defs.h b/src/r_defs.h index 749638db3..7b7c5d7f0 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -717,10 +717,12 @@ typedef enum { RF_HORIZONTALFLIP = 0x0001, // Flip sprite horizontally RF_VERTICALFLIP = 0x0002, // Flip sprite vertically - RF_ONESIDED = 0x0004, // Wall/floor sprite is visible from front only - RF_SLOPESPLAT = 0x0008, // Rotate floor sprites by the object's standing slope - RF_NOSPLATBILLBOARD = 0x0010, // Don't billboard floor sprites (faces forward from the view angle) - RF_NOSPLATROLLANGLE = 0x0020, // Don't rotate floor sprites by the object's rollangle (uses rotated patches instead) + RF_ABSOLUTEOFFSETS = 0x0004, // Sprite uses the object's offsets absolutely, instead of relatively + RF_FLIPOFFSETS = 0x0008, // Relative object offsets are flipped with the sprite + + RF_SLOPESPLAT = 0x0010, // Rotate floor sprites by the object's standing slope + RF_NOSPLATBILLBOARD = 0x0020, // Don't billboard floor sprites (faces forward from the view angle) + RF_NOSPLATROLLANGLE = 0x0040, // Don't rotate floor sprites by the object's rollangle (uses rotated patches instead) RF_BLENDMASK = 0x0F00, // --Blending modes RF_FULLBRIGHT = 0x0100, // Sprite is drawn at full brightness diff --git a/src/r_things.c b/src/r_things.c index e23c08eb1..d60228e36 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -1632,6 +1632,22 @@ static void R_ProjectSprite(mobj_t *thing) if (spritexscale < 1 || spriteyscale < 1) return; + if (thing->renderflags & RF_ABSOLUTEOFFSETS) + { + spr_offset = thing->spritexoffset; + spr_topoffset = thing->spriteyoffset; + } + else + { + SINT8 flipoffset = 1; + + if ((thing->renderflags & RF_FLIPOFFSETS) && flip) + flipoffset = -1; + + spr_offset += thing->spritexoffset * flipoffset; + spr_topoffset += thing->spriteyoffset * flipoffset; + } + if (flip) offset = spr_offset - spr_width; else @@ -1981,7 +1997,8 @@ static void R_ProjectSprite(mobj_t *thing) vis->spritexscale = spritexscale; vis->spriteyscale = spriteyscale; - vis->shadowscale = shadowscale; + vis->spritexoffset = spr_offset; + vis->spriteyoffset = spr_topoffset; if (shadowdraw || shadoweffects) { @@ -1992,6 +2009,8 @@ static void R_ProjectSprite(mobj_t *thing) else iscale = FixedDiv(FRACUNIT, vis->xscale); + vis->shadowscale = shadowscale; + if (flip) { vis->startfrac = spr_width-1; @@ -2818,8 +2837,8 @@ static void R_DrawVisSplat(vissprite_t *spr) splat.angle = -splatangle; splat.angle += ANGLE_90; - topoffset = (spr->patch->topoffset * FRACUNIT); - leftoffset = (spr->patch->leftoffset * FRACUNIT); + topoffset = spr->spriteyoffset; + leftoffset = spr->spritexoffset; if (hflip) leftoffset = ((splat.width * FRACUNIT) - leftoffset); diff --git a/src/r_things.h b/src/r_things.h index 643b2ca9e..f960089a1 100644 --- a/src/r_things.h +++ b/src/r_things.h @@ -195,6 +195,8 @@ typedef struct vissprite_s UINT8 rotateflags; fixed_t spritexscale, spriteyscale; + fixed_t spritexoffset, spriteyoffset; + fixed_t shadowscale; INT16 clipbot[MAXVIDWIDTH], cliptop[MAXVIDWIDTH]; From 5d699591c772fea85dba9ef7e1fa3394793bf73f Mon Sep 17 00:00:00 2001 From: Zippy_Zolton Date: Tue, 13 Oct 2020 14:23:56 -0500 Subject: [PATCH 0171/1080] more!!!!! :3 --- src/w_wad.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/w_wad.c b/src/w_wad.c index 0f0ad97f0..db87bba94 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -2076,8 +2076,14 @@ int W_VerifyNMUSlumps(const char *filename) {"CONSBACK", 8}, // Console Background graphic {"GAMEQUIT", 8}, - {"SAVE", 4}, // Save Select graphics + + {"SAVE", 4}, // Save Select graphics here and below + {"BLACXLVL", 8}, + {"GAMEDONE", 8}, + {"CONT", 4}, // Continue icons on saves (probably not used anymore) + {"STNONEX", 7}, // "X" graphic {"ULTIMATE", 8}, // Ultimate no-save + {"CRFNT", 5}, // Sonic 1 font changes {"NTFNT", 5}, // Character Select font changes {"NTFNO", 5}, // Character Select font (outline) @@ -2085,12 +2091,15 @@ int W_VerifyNMUSlumps(const char *filename) {"TTL", 3}, // Act number changes {"STCFN", 5}, // Console font changes {"TNYFN", 5}, // Tiny console font changes - {"STLIVEX", 7}, // "X" that shows under skin's HUDNAME + + {"STLIVE", 6}, // Life graphics, background and the "X" that shows under skin's HUDNAME + {"CROSSHAI", 8}, // First person crosshairs + {"INTERSC", 7}, // Default intermission backgrounds (co-op) {"STT", 3}, // Acceptable HUD changes (Score Time Rings) {"YB_", 3}, // Intermission graphics, goes with the above {"RESULT", 6}, // Used in intermission for competitive modes, above too :3 {"RACE", 4}, // Race mode graphics, 321go - {"M_", 2}, // As does menu stuff + {"M_", 2}, // Menu stuff {"MINICAPS", 8}, // NiGHTS graphics here and below {"BLUESTAT", 8}, // Sphere status From 0e62cb2adaa465b148f55c1f0707201c7c92d369 Mon Sep 17 00:00:00 2001 From: Jaime Passos Date: Tue, 13 Oct 2020 17:03:50 -0300 Subject: [PATCH 0172/1080] Fix infinitely long splat spans --- src/r_splats.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/r_splats.c b/src/r_splats.c index cddbbf85f..fa4d9eef8 100644 --- a/src/r_splats.c +++ b/src/r_splats.c @@ -268,6 +268,9 @@ void R_RenderFloorSplat(floorsplat_t *pSplat, vertex_t *verts, vissprite_t *vis) x2 = swap; } + if (x1 == INT16_MIN || x2 == INT16_MAX) + continue; + if (x1 < 0) x1 = 0; if (x2 >= vid.width) From 6fd226eb29ec32d7e7de7fad14818f4c70b32c53 Mon Sep 17 00:00:00 2001 From: Zippy_Zolton Date: Tue, 13 Oct 2020 16:41:39 -0500 Subject: [PATCH 0173/1080] Crosshair fix, no GAMEQUIT --- src/w_wad.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/w_wad.c b/src/w_wad.c index db87bba94..9d8adaabd 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -2075,7 +2075,6 @@ int W_VerifyNMUSlumps(const char *filename) {"TRANS", 5}, // Translucency map changes {"CONSBACK", 8}, // Console Background graphic - {"GAMEQUIT", 8}, {"SAVE", 4}, // Save Select graphics here and below {"BLACXLVL", 8}, @@ -2093,7 +2092,7 @@ int W_VerifyNMUSlumps(const char *filename) {"TNYFN", 5}, // Tiny console font changes {"STLIVE", 6}, // Life graphics, background and the "X" that shows under skin's HUDNAME - {"CROSSHAI", 8}, // First person crosshairs + {"CROSHAI", 7}, // First person crosshairs {"INTERSC", 7}, // Default intermission backgrounds (co-op) {"STT", 3}, // Acceptable HUD changes (Score Time Rings) {"YB_", 3}, // Intermission graphics, goes with the above From 63e471d902763e2899c5dccd64c4f9c67284d6a1 Mon Sep 17 00:00:00 2001 From: Jaime Passos Date: Tue, 13 Oct 2020 19:16:25 -0300 Subject: [PATCH 0174/1080] Correctly return the output patch's size in Picture_PatchConvert --- src/r_picformats.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/r_picformats.c b/src/r_picformats.c index 8ec78663e..ffef4c2f2 100644 --- a/src/r_picformats.c +++ b/src/r_picformats.c @@ -352,20 +352,26 @@ void *Picture_PatchConvert( img = Z_Malloc(size, PU_STATIC, NULL); memcpy(img, imgbuf, size); - if (outsize != NULL) - *outsize = size; - if (Picture_IsInternalPatchFormat(outformat)) { patch_t *converted = Patch_Create((softwarepatch_t *)img, size, NULL); + #ifdef HWRENDER Patch_CreateGL(converted); #endif + Z_Free(img); + + if (outsize != NULL) + *outsize = sizeof(patch_t); return converted; } else + { + if (outsize != NULL) + *outsize = size; return img; + } } /** Converts a picture to a flat. From fccbc00cac58a4722345f7da952213e212d5b961 Mon Sep 17 00:00:00 2001 From: Jaime Passos Date: Tue, 13 Oct 2020 19:18:01 -0300 Subject: [PATCH 0175/1080] Fix the wrong freeing function call being used in Patch_FreeData --- src/r_patch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/r_patch.c b/src/r_patch.c index 9b1e7d1b8..c78ffdd67 100644 --- a/src/r_patch.c +++ b/src/r_patch.c @@ -77,7 +77,7 @@ static void Patch_FreeData(patch_t *patch) for (i = 0; i < 2; i++) { if (patch->flats[i]) - Patch_Free(patch->flats[i]); + Z_Free(patch->flats[i]); } #ifdef ROTSPRITE From 4b7bfce95ebabf971793a1bca99741dd7fdc1d20 Mon Sep 17 00:00:00 2001 From: Jaime Passos Date: Tue, 13 Oct 2020 22:42:07 -0300 Subject: [PATCH 0176/1080] Implement sloped floor sprites --- src/r_draw.h | 39 ++++-- src/r_draw8.c | 235 +++++++++++++++++++++++++++++++-- src/r_draw8_npo2.c | 317 +++++++++++++++++++++++++++++++++++++++++++-- src/r_plane.c | 90 +++++++------ src/r_plane.h | 8 +- src/r_splats.c | 155 +++++++++++----------- src/r_splats.h | 8 +- src/r_things.c | 73 +++++++++-- src/screen.c | 4 + src/screen.h | 2 + 10 files changed, 757 insertions(+), 174 deletions(-) diff --git a/src/r_draw.h b/src/r_draw.h index d77bbedd3..5011d29d9 100644 --- a/src/r_draw.h +++ b/src/r_draw.h @@ -150,42 +150,53 @@ void R_Draw2sMultiPatchTranslucentColumn_8(void); void R_DrawFogColumn_8(void); void R_DrawColumnShadowed_8(void); +#define PLANELIGHTFLOAT (BASEVIDWIDTH * BASEVIDWIDTH / vid.width / (zeroheight - FIXED_TO_FLOAT(viewz)) / 21.0f * FIXED_TO_FLOAT(fovtan)) + void R_DrawSpan_8(void); -void R_DrawSplat_8(void); -void R_DrawFloorSprite_8(void); void R_DrawTranslucentSpan_8(void); -void R_DrawTranslucentSplat_8(void); -void R_DrawTranslucentFloorSprite_8(void); void R_DrawTiltedSpan_8(void); void R_DrawTiltedTranslucentSpan_8(void); -#ifndef NOWATER -void R_DrawTiltedTranslucentWaterSpan_8(void); -#endif + +void R_DrawSplat_8(void); +void R_DrawTranslucentSplat_8(void); void R_DrawTiltedSplat_8(void); + +void R_DrawFloorSprite_8(void); +void R_DrawTranslucentFloorSprite_8(void); +void R_DrawTiltedFloorSprite_8(void); +void R_DrawTiltedTranslucentFloorSprite_8(void); + void R_CalcTiltedLighting(fixed_t start, fixed_t end); extern INT32 tiltlighting[MAXVIDWIDTH]; + #ifndef NOWATER void R_DrawTranslucentWaterSpan_8(void); +void R_DrawTiltedTranslucentWaterSpan_8(void); + extern INT32 ds_bgofs; extern INT32 ds_waterofs; #endif + void R_DrawFogSpan_8(void); // Lactozilla: Non-powers-of-two void R_DrawSpan_NPO2_8(void); void R_DrawTranslucentSpan_NPO2_8(void); -void R_DrawFloorSprite_NPO2_8(void); -void R_DrawSplat_NPO2_8(void); -void R_DrawTranslucentSplat_NPO2_8(void); -void R_DrawTranslucentFloorSprite_NPO2_8(void); void R_DrawTiltedSpan_NPO2_8(void); void R_DrawTiltedTranslucentSpan_NPO2_8(void); -#ifndef NOWATER -void R_DrawTiltedTranslucentWaterSpan_NPO2_8(void); -#endif + +void R_DrawSplat_NPO2_8(void); +void R_DrawTranslucentSplat_NPO2_8(void); void R_DrawTiltedSplat_NPO2_8(void); + +void R_DrawFloorSprite_NPO2_8(void); +void R_DrawTranslucentFloorSprite_NPO2_8(void); +void R_DrawTiltedFloorSprite_NPO2_8(void); +void R_DrawTiltedTranslucentFloorSprite_NPO2_8(void); + #ifndef NOWATER void R_DrawTranslucentWaterSpan_NPO2_8(void); +void R_DrawTiltedTranslucentWaterSpan_NPO2_8(void); #endif #ifdef USEASM diff --git a/src/r_draw8.c b/src/r_draw8.c index bc39e91a5..c28a25cbc 100644 --- a/src/r_draw8.c +++ b/src/r_draw8.c @@ -536,6 +536,9 @@ void R_DrawTranslatedColumn_8(void) // SPANS // ========================================================================== +#define SPANSIZE 16 +#define INVSPAN 0.0625f + /** \brief The R_DrawSpan_8 function Draws the actual span. */ @@ -643,8 +646,6 @@ void R_CalcTiltedLighting(fixed_t start, fixed_t end) } } -#define PLANELIGHTFLOAT (BASEVIDWIDTH * BASEVIDWIDTH / vid.width / (zeroheight - FIXED_TO_FLOAT(viewz)) / 21.0f * FIXED_TO_FLOAT(fovtan)) - /** \brief The R_DrawTiltedSpan_8 function Draw slopes! Holy sheit! */ @@ -704,9 +705,6 @@ void R_DrawTiltedSpan_8(void) vz += ds_svp->x; } while (--width >= 0); #else -#define SPANSIZE 16 -#define INVSPAN 0.0625f - startz = 1.f/iz; startu = uz*startz; startv = vz*startz; @@ -839,9 +837,6 @@ void R_DrawTiltedTranslucentSpan_8(void) vz += ds_svp->x; } while (--width >= 0); #else -#define SPANSIZE 16 -#define INVSPAN 0.0625f - startz = 1.f/iz; startu = uz*startz; startv = vz*startz; @@ -977,9 +972,6 @@ void R_DrawTiltedTranslucentWaterSpan_8(void) vz += ds_svp->x; } while (--width >= 0); #else -#define SPANSIZE 16 -#define INVSPAN 0.0625f - startz = 1.f/iz; startu = uz*startz; startv = vz*startz; @@ -1116,9 +1108,6 @@ void R_DrawTiltedSplat_8(void) vz += ds_svp->x; } while (--width >= 0); #else -#define SPANSIZE 16 -#define INVSPAN 0.0625f - startz = 1.f/iz; startu = uz*startz; startv = vz*startz; @@ -1643,6 +1632,224 @@ void R_DrawTranslucentFloorSprite_8 (void) } } +/** \brief The R_DrawTiltedFloorSprite_8 function + Draws a tilted floor sprite. +*/ +void R_DrawTiltedFloorSprite_8(void) +{ + // x1, x2 = ds_x1, ds_x2 + int width = ds_x2 - ds_x1; + double iz, uz, vz; + UINT32 u, v; + int i; + + UINT16 *source; + UINT8 *colormap; + UINT8 *translation; + UINT8 *dest; + UINT16 val; + + double startz, startu, startv; + double izstep, uzstep, vzstep; + double endz, endu, endv; + UINT32 stepu, stepv; + + iz = ds_szp->z + ds_szp->y*(centery-ds_y) + ds_szp->x*(ds_x1-centerx); + uz = ds_sup->z + ds_sup->y*(centery-ds_y) + ds_sup->x*(ds_x1-centerx); + vz = ds_svp->z + ds_svp->y*(centery-ds_y) + ds_svp->x*(ds_x1-centerx); + + dest = ylookup[ds_y] + columnofs[ds_x1]; + source = (UINT16 *)ds_source; + colormap = ds_colormap; + translation = ds_translation; + + startz = 1.f/iz; + startu = uz*startz; + startv = vz*startz; + + izstep = ds_szp->x * SPANSIZE; + uzstep = ds_sup->x * SPANSIZE; + vzstep = ds_svp->x * SPANSIZE; + //x1 = 0; + width++; + + while (width >= SPANSIZE) + { + iz += izstep; + uz += uzstep; + vz += vzstep; + + endz = 1.f/iz; + endu = uz*endz; + endv = vz*endz; + stepu = (INT64)((endu - startu) * INVSPAN); + stepv = (INT64)((endv - startv) * INVSPAN); + u = (INT64)(startu) + viewx; + v = (INT64)(startv) + viewy; + + for (i = SPANSIZE-1; i >= 0; i--) + { + val = source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)]; + if (val & 0xFF00) + *dest = colormap[translation[val & 0xFF]]; + dest++; + + u += stepu; + v += stepv; + } + startu = endu; + startv = endv; + width -= SPANSIZE; + } + if (width > 0) + { + if (width == 1) + { + u = (INT64)(startu); + v = (INT64)(startv); + val = source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)]; + if (val & 0xFF00) + *dest = colormap[translation[val & 0xFF]]; + } + else + { + double left = width; + iz += ds_szp->x * left; + uz += ds_sup->x * left; + vz += ds_svp->x * left; + + endz = 1.f/iz; + endu = uz*endz; + endv = vz*endz; + left = 1.f/left; + stepu = (INT64)((endu - startu) * left); + stepv = (INT64)((endv - startv) * left); + u = (INT64)(startu) + viewx; + v = (INT64)(startv) + viewy; + + for (; width != 0; width--) + { + val = source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)]; + if (val & 0xFF00) + *dest = colormap[translation[val & 0xFF]]; + dest++; + + u += stepu; + v += stepv; + } + } + } +} + +/** \brief The R_DrawTiltedTranslucentFloorSprite_8 function + Draws a tilted, translucent, floor sprite. +*/ +void R_DrawTiltedTranslucentFloorSprite_8(void) +{ + // x1, x2 = ds_x1, ds_x2 + int width = ds_x2 - ds_x1; + double iz, uz, vz; + UINT32 u, v; + int i; + + UINT16 *source; + UINT8 *colormap; + UINT8 *translation; + UINT8 *dest; + UINT16 val; + + double startz, startu, startv; + double izstep, uzstep, vzstep; + double endz, endu, endv; + UINT32 stepu, stepv; + + iz = ds_szp->z + ds_szp->y*(centery-ds_y) + ds_szp->x*(ds_x1-centerx); + uz = ds_sup->z + ds_sup->y*(centery-ds_y) + ds_sup->x*(ds_x1-centerx); + vz = ds_svp->z + ds_svp->y*(centery-ds_y) + ds_svp->x*(ds_x1-centerx); + + dest = ylookup[ds_y] + columnofs[ds_x1]; + source = (UINT16 *)ds_source; + colormap = ds_colormap; + translation = ds_translation; + + startz = 1.f/iz; + startu = uz*startz; + startv = vz*startz; + + izstep = ds_szp->x * SPANSIZE; + uzstep = ds_sup->x * SPANSIZE; + vzstep = ds_svp->x * SPANSIZE; + //x1 = 0; + width++; + + while (width >= SPANSIZE) + { + iz += izstep; + uz += uzstep; + vz += vzstep; + + endz = 1.f/iz; + endu = uz*endz; + endv = vz*endz; + stepu = (INT64)((endu - startu) * INVSPAN); + stepv = (INT64)((endv - startv) * INVSPAN); + u = (INT64)(startu) + viewx; + v = (INT64)(startv) + viewy; + + for (i = SPANSIZE-1; i >= 0; i--) + { + val = source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)]; + if (val & 0xFF00) + *dest = *(ds_transmap + (colormap[translation[val & 0xFF]] << 8) + *dest); + dest++; + + u += stepu; + v += stepv; + } + startu = endu; + startv = endv; + width -= SPANSIZE; + } + if (width > 0) + { + if (width == 1) + { + u = (INT64)(startu); + v = (INT64)(startv); + val = source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)]; + if (val & 0xFF00) + *dest = *(ds_transmap + (colormap[translation[val & 0xFF]] << 8) + *dest); + } + else + { + double left = width; + iz += ds_szp->x * left; + uz += ds_sup->x * left; + vz += ds_svp->x * left; + + endz = 1.f/iz; + endu = uz*endz; + endv = vz*endz; + left = 1.f/left; + stepu = (INT64)((endu - startu) * left); + stepv = (INT64)((endv - startv) * left); + u = (INT64)(startu) + viewx; + v = (INT64)(startv) + viewy; + + for (; width != 0; width--) + { + val = source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)]; + if (val & 0xFF00) + *dest = *(ds_transmap + (colormap[translation[val & 0xFF]] << 8) + *dest); + dest++; + + u += stepu; + v += stepv; + } + } + } +} + /** \brief The R_DrawTranslucentSpan_8 function Draws the actual span with translucency. */ diff --git a/src/r_draw8_npo2.c b/src/r_draw8_npo2.c index 087a8d30c..895869e2d 100644 --- a/src/r_draw8_npo2.c +++ b/src/r_draw8_npo2.c @@ -15,6 +15,9 @@ // SPANS // ========================================================================== +#define SPANSIZE 16 +#define INVSPAN 0.0625f + /** \brief The R_DrawSpan_NPO2_8 function Draws the actual span. */ @@ -61,8 +64,6 @@ void R_DrawSpan_NPO2_8 (void) } } -#define PLANELIGHTFLOAT (BASEVIDWIDTH * BASEVIDWIDTH / vid.width / (zeroheight - FIXED_TO_FLOAT(viewz)) / 21.0f * FIXED_TO_FLOAT(fovtan)) - /** \brief The R_DrawTiltedSpan_NPO2_8 function Draw slopes! Holy sheit! */ @@ -137,9 +138,6 @@ void R_DrawTiltedSpan_NPO2_8(void) vz += ds_svp->x; } while (--width >= 0); #else -#define SPANSIZE 16 -#define INVSPAN 0.0625f - startz = 1.f/iz; startu = uz*startz; startv = vz*startz; @@ -332,9 +330,6 @@ void R_DrawTiltedTranslucentSpan_NPO2_8(void) vz += ds_svp->x; } while (--width >= 0); #else -#define SPANSIZE 16 -#define INVSPAN 0.0625f - startz = 1.f/iz; startu = uz*startz; startv = vz*startz; @@ -531,9 +526,6 @@ void R_DrawTiltedSplat_NPO2_8(void) vz += ds_svp->x; } while (--width >= 0); #else -#define SPANSIZE 16 -#define INVSPAN 0.0625f - startz = 1.f/iz; startu = uz*startz; startv = vz*startz; @@ -852,6 +844,306 @@ void R_DrawTranslucentFloorSprite_NPO2_8 (void) } } +/** \brief The R_DrawTiltedFloorSprite_NPO2_8 function + Draws a tilted floor sprite. +*/ +void R_DrawTiltedFloorSprite_NPO2_8(void) +{ + // x1, x2 = ds_x1, ds_x2 + int width = ds_x2 - ds_x1; + double iz, uz, vz; + UINT32 u, v; + int i; + + UINT16 *source; + UINT8 *colormap; + UINT8 *translation; + UINT8 *dest; + UINT16 val; + + double startz, startu, startv; + double izstep, uzstep, vzstep; + double endz, endu, endv; + UINT32 stepu, stepv; + + iz = ds_szp->z + ds_szp->y*(centery-ds_y) + ds_szp->x*(ds_x1-centerx); + uz = ds_sup->z + ds_sup->y*(centery-ds_y) + ds_sup->x*(ds_x1-centerx); + vz = ds_svp->z + ds_svp->y*(centery-ds_y) + ds_svp->x*(ds_x1-centerx); + + dest = ylookup[ds_y] + columnofs[ds_x1]; + source = (UINT16 *)ds_source; + colormap = ds_colormap; + translation = ds_translation; + + startz = 1.f/iz; + startu = uz*startz; + startv = vz*startz; + + izstep = ds_szp->x * SPANSIZE; + uzstep = ds_sup->x * SPANSIZE; + vzstep = ds_svp->x * SPANSIZE; + //x1 = 0; + width++; + + while (width >= SPANSIZE) + { + iz += izstep; + uz += uzstep; + vz += vzstep; + + endz = 1.f/iz; + endu = uz*endz; + endv = vz*endz; + stepu = (INT64)((endu - startu) * INVSPAN); + stepv = (INT64)((endv - startv) * INVSPAN); + u = (INT64)(startu) + viewx; + v = (INT64)(startv) + viewy; + + for (i = SPANSIZE-1; i >= 0; i--) + { + // Lactozilla: Non-powers-of-two + fixed_t x = (((fixed_t)u-viewx) >> FRACBITS); + fixed_t y = (((fixed_t)v-viewy) >> FRACBITS); + + // Carefully align all of my Friends. + if (x < 0) + x = ds_flatwidth - ((UINT32)(ds_flatwidth - x) % ds_flatwidth); + if (y < 0) + y = ds_flatheight - ((UINT32)(ds_flatheight - y) % ds_flatheight); + + x %= ds_flatwidth; + y %= ds_flatheight; + + val = source[((y * ds_flatwidth) + x)]; + if (val & 0xFF00) + *dest = colormap[translation[val & 0xFF]]; + dest++; + + u += stepu; + v += stepv; + } + startu = endu; + startv = endv; + width -= SPANSIZE; + } + if (width > 0) + { + if (width == 1) + { + u = (INT64)(startu); + v = (INT64)(startv); + // Lactozilla: Non-powers-of-two + { + fixed_t x = (((fixed_t)u-viewx) >> FRACBITS); + fixed_t y = (((fixed_t)v-viewy) >> FRACBITS); + + // Carefully align all of my Friends. + if (x < 0) + x = ds_flatwidth - ((UINT32)(ds_flatwidth - x) % ds_flatwidth); + if (y < 0) + y = ds_flatheight - ((UINT32)(ds_flatheight - y) % ds_flatheight); + + x %= ds_flatwidth; + y %= ds_flatheight; + + val = source[((y * ds_flatwidth) + x)]; + if (val & 0xFF00) + *dest = colormap[translation[val & 0xFF]]; + } + } + else + { + double left = width; + iz += ds_szp->x * left; + uz += ds_sup->x * left; + vz += ds_svp->x * left; + + endz = 1.f/iz; + endu = uz*endz; + endv = vz*endz; + left = 1.f/left; + stepu = (INT64)((endu - startu) * left); + stepv = (INT64)((endv - startv) * left); + u = (INT64)(startu) + viewx; + v = (INT64)(startv) + viewy; + + for (; width != 0; width--) + { + // Lactozilla: Non-powers-of-two + fixed_t x = (((fixed_t)u-viewx) >> FRACBITS); + fixed_t y = (((fixed_t)v-viewy) >> FRACBITS); + + // Carefully align all of my Friends. + if (x < 0) + x = ds_flatwidth - ((UINT32)(ds_flatwidth - x) % ds_flatwidth); + if (y < 0) + y = ds_flatheight - ((UINT32)(ds_flatheight - y) % ds_flatheight); + + x %= ds_flatwidth; + y %= ds_flatheight; + + val = source[((y * ds_flatwidth) + x)]; + if (val & 0xFF00) + *dest = colormap[translation[val & 0xFF]]; + dest++; + + u += stepu; + v += stepv; + } + } + } +} + +/** \brief The R_DrawTiltedTranslucentFloorSprite_NPO2_8 function + Draws a tilted, translucent, floor sprite. +*/ +void R_DrawTiltedTranslucentFloorSprite_NPO2_8(void) +{ + // x1, x2 = ds_x1, ds_x2 + int width = ds_x2 - ds_x1; + double iz, uz, vz; + UINT32 u, v; + int i; + + UINT16 *source; + UINT8 *colormap; + UINT8 *translation; + UINT8 *dest; + UINT16 val; + + double startz, startu, startv; + double izstep, uzstep, vzstep; + double endz, endu, endv; + UINT32 stepu, stepv; + + iz = ds_szp->z + ds_szp->y*(centery-ds_y) + ds_szp->x*(ds_x1-centerx); + uz = ds_sup->z + ds_sup->y*(centery-ds_y) + ds_sup->x*(ds_x1-centerx); + vz = ds_svp->z + ds_svp->y*(centery-ds_y) + ds_svp->x*(ds_x1-centerx); + + dest = ylookup[ds_y] + columnofs[ds_x1]; + source = (UINT16 *)ds_source; + colormap = ds_colormap; + translation = ds_translation; + + startz = 1.f/iz; + startu = uz*startz; + startv = vz*startz; + + izstep = ds_szp->x * SPANSIZE; + uzstep = ds_sup->x * SPANSIZE; + vzstep = ds_svp->x * SPANSIZE; + //x1 = 0; + width++; + + while (width >= SPANSIZE) + { + iz += izstep; + uz += uzstep; + vz += vzstep; + + endz = 1.f/iz; + endu = uz*endz; + endv = vz*endz; + stepu = (INT64)((endu - startu) * INVSPAN); + stepv = (INT64)((endv - startv) * INVSPAN); + u = (INT64)(startu) + viewx; + v = (INT64)(startv) + viewy; + + for (i = SPANSIZE-1; i >= 0; i--) + { + // Lactozilla: Non-powers-of-two + fixed_t x = (((fixed_t)u-viewx) >> FRACBITS); + fixed_t y = (((fixed_t)v-viewy) >> FRACBITS); + + // Carefully align all of my Friends. + if (x < 0) + x = ds_flatwidth - ((UINT32)(ds_flatwidth - x) % ds_flatwidth); + if (y < 0) + y = ds_flatheight - ((UINT32)(ds_flatheight - y) % ds_flatheight); + + x %= ds_flatwidth; + y %= ds_flatheight; + + val = source[((y * ds_flatwidth) + x)]; + if (val & 0xFF00) + *dest = *(ds_transmap + (colormap[translation[val & 0xFF]] << 8) + *dest); + dest++; + + u += stepu; + v += stepv; + } + startu = endu; + startv = endv; + width -= SPANSIZE; + } + if (width > 0) + { + if (width == 1) + { + u = (INT64)(startu); + v = (INT64)(startv); + // Lactozilla: Non-powers-of-two + { + fixed_t x = (((fixed_t)u-viewx) >> FRACBITS); + fixed_t y = (((fixed_t)v-viewy) >> FRACBITS); + + // Carefully align all of my Friends. + if (x < 0) + x = ds_flatwidth - ((UINT32)(ds_flatwidth - x) % ds_flatwidth); + if (y < 0) + y = ds_flatheight - ((UINT32)(ds_flatheight - y) % ds_flatheight); + + x %= ds_flatwidth; + y %= ds_flatheight; + + val = source[((y * ds_flatwidth) + x)]; + if (val & 0xFF00) + *dest = *(ds_transmap + (colormap[translation[val & 0xFF]] << 8) + *dest); + } + } + else + { + double left = width; + iz += ds_szp->x * left; + uz += ds_sup->x * left; + vz += ds_svp->x * left; + + endz = 1.f/iz; + endu = uz*endz; + endv = vz*endz; + left = 1.f/left; + stepu = (INT64)((endu - startu) * left); + stepv = (INT64)((endv - startv) * left); + u = (INT64)(startu) + viewx; + v = (INT64)(startv) + viewy; + + for (; width != 0; width--) + { + // Lactozilla: Non-powers-of-two + fixed_t x = (((fixed_t)u-viewx) >> FRACBITS); + fixed_t y = (((fixed_t)v-viewy) >> FRACBITS); + + // Carefully align all of my Friends. + if (x < 0) + x = ds_flatwidth - ((UINT32)(ds_flatwidth - x) % ds_flatwidth); + if (y < 0) + y = ds_flatheight - ((UINT32)(ds_flatheight - y) % ds_flatheight); + + x %= ds_flatwidth; + y %= ds_flatheight; + + val = source[((y * ds_flatwidth) + x)]; + if (val & 0xFF00) + *dest = *(ds_transmap + (colormap[translation[val & 0xFF]] << 8) + *dest); + dest++; + + u += stepu; + v += stepv; + } + } + } +} + /** \brief The R_DrawTranslucentSpan_NPO2_8 function Draws the actual span with translucency. */ @@ -1016,9 +1308,6 @@ void R_DrawTiltedTranslucentWaterSpan_NPO2_8(void) vz += ds_svp->x; } while (--width >= 0); #else -#define SPANSIZE 16 -#define INVSPAN 0.0625f - startz = 1.f/iz; startu = uz*startz; startv = vz*startz; diff --git a/src/r_plane.c b/src/r_plane.c index 797919a9f..096d1dbd6 100644 --- a/src/r_plane.c +++ b/src/r_plane.c @@ -645,46 +645,48 @@ static void R_DrawSkyPlane(visplane_t *pl) } } -static void R_SlopeVectors(visplane_t *pl, INT32 i, float fudge) +// Potentially override other stuff for now cus we're mean. :< But draw a slope plane! +// I copied ZDoom's code and adapted it to SRB2... -Red +void R_CalculateSlopeVectors(pslope_t *slope, fixed_t planeviewx, fixed_t planeviewy, fixed_t planeviewz, fixed_t planexscale, fixed_t planeyscale, fixed_t planexoffset, fixed_t planeyoffset, angle_t planeviewangle, angle_t planeangle, float fudge) { - // Potentially override other stuff for now cus we're mean. :< But draw a slope plane! - // I copied ZDoom's code and adapted it to SRB2... -Red floatv3_t p, m, n; float ang; float vx, vy, vz; + float xscale = FIXED_TO_FLOAT(planexscale); + float yscale = FIXED_TO_FLOAT(planeyscale); // compiler complains when P_GetSlopeZAt is used in FLOAT_TO_FIXED directly // use this as a temp var to store P_GetSlopeZAt's return value each time fixed_t temp; - vx = FIXED_TO_FLOAT(pl->viewx+xoffs); - vy = FIXED_TO_FLOAT(pl->viewy-yoffs); - vz = FIXED_TO_FLOAT(pl->viewz); + vx = FIXED_TO_FLOAT(planeviewx+planexoffset); + vy = FIXED_TO_FLOAT(planeviewy-planeyoffset); + vz = FIXED_TO_FLOAT(planeviewz); - temp = P_GetSlopeZAt(pl->slope, pl->viewx, pl->viewy); + temp = P_GetSlopeZAt(slope, planeviewx, planeviewy); zeroheight = FIXED_TO_FLOAT(temp); // p is the texture origin in view space // Don't add in the offsets at this stage, because doing so can result in // errors if the flat is rotated. - ang = ANG2RAD(ANGLE_270 - pl->viewangle); + ang = ANG2RAD(ANGLE_270 - planeviewangle); p.x = vx * cos(ang) - vy * sin(ang); p.z = vx * sin(ang) + vy * cos(ang); - temp = P_GetSlopeZAt(pl->slope, -xoffs, yoffs); + temp = P_GetSlopeZAt(slope, -planexoffset, planeyoffset); p.y = FIXED_TO_FLOAT(temp) - vz; // m is the v direction vector in view space - ang = ANG2RAD(ANGLE_180 - (pl->viewangle + pl->plangle)); - m.x = cos(ang); - m.z = sin(ang); + ang = ANG2RAD(ANGLE_180 - (planeviewangle + planeangle)); + m.x = yscale * cos(ang); + m.z = yscale * sin(ang); // n is the u direction vector in view space - n.x = sin(ang); - n.z = -cos(ang); + n.x = xscale * sin(ang); + n.z = -xscale * cos(ang); - ang = ANG2RAD(pl->plangle); - temp = P_GetSlopeZAt(pl->slope, pl->viewx + FLOAT_TO_FIXED(sin(ang)), pl->viewy + FLOAT_TO_FIXED(cos(ang))); + ang = ANG2RAD(planeangle); + temp = P_GetSlopeZAt(slope, planeviewx + yscale * FLOAT_TO_FIXED(sin(ang)), planeviewy + yscale * FLOAT_TO_FIXED(cos(ang))); m.y = FIXED_TO_FLOAT(temp) - zeroheight; - temp = P_GetSlopeZAt(pl->slope, pl->viewx + FLOAT_TO_FIXED(cos(ang)), pl->viewy - FLOAT_TO_FIXED(sin(ang))); + temp = P_GetSlopeZAt(slope, planeviewx + xscale * FLOAT_TO_FIXED(cos(ang)), planeviewy - xscale * FLOAT_TO_FIXED(sin(ang))); n.y = FIXED_TO_FLOAT(temp) - zeroheight; if (ds_powersoftwo) @@ -700,42 +702,50 @@ static void R_SlopeVectors(visplane_t *pl, INT32 i, float fudge) // Eh. I tried making this stuff fixed-point and it exploded on me. Here's a macro for the only floating-point vector function I recall using. #define CROSS(d, v1, v2) \ -d.x = (v1.y * v2.z) - (v1.z * v2.y);\ -d.y = (v1.z * v2.x) - (v1.x * v2.z);\ -d.z = (v1.x * v2.y) - (v1.y * v2.x) - CROSS(ds_su[i], p, m); - CROSS(ds_sv[i], p, n); - CROSS(ds_sz[i], m, n); +d->x = (v1.y * v2.z) - (v1.z * v2.y);\ +d->y = (v1.z * v2.x) - (v1.x * v2.z);\ +d->z = (v1.x * v2.y) - (v1.y * v2.x) + CROSS(ds_sup, p, m); + CROSS(ds_svp, p, n); + CROSS(ds_szp, m, n); #undef CROSS - ds_su[i].z *= focallengthf; - ds_sv[i].z *= focallengthf; - ds_sz[i].z *= focallengthf; + ds_sup->z *= focallengthf; + ds_svp->z *= focallengthf; + ds_szp->z *= focallengthf; // Premultiply the texture vectors with the scale factors #define SFMULT 65536.f if (ds_powersoftwo) { - ds_su[i].x *= (SFMULT * (1<x *= (SFMULT * (1<y *= (SFMULT * (1<z *= (SFMULT * (1<x *= (SFMULT * (1<y *= (SFMULT * (1<z *= (SFMULT * (1<x *= SFMULT; + ds_sup->y *= SFMULT; + ds_sup->z *= SFMULT; + ds_svp->x *= SFMULT; + ds_svp->y *= SFMULT; + ds_svp->z *= SFMULT; } #undef SFMULT } +static void R_SlopePlaneVectors(visplane_t *pl, INT32 i, float fudge) +{ + ds_sup = &ds_su[i]; + ds_svp = &ds_sv[i]; + ds_szp = &ds_sz[i]; + R_CalculateSlopeVectors(pl->slope, pl->viewx, pl->viewy, pl->viewz, FRACUNIT, FRACUNIT, xoffs, yoffs, pl->viewangle, pl->plangle, fudge); +} + void R_DrawSinglePlane(visplane_t *pl) { levelflat_t *levelflat; @@ -992,7 +1002,7 @@ void R_DrawSinglePlane(visplane_t *pl) R_PlaneRipple(pl, i, plheight); xoffs = rxoffs + ripple_xfrac; yoffs = ryoffs + ripple_yfrac; - R_SlopeVectors(pl, i, fudgecanyon); + R_SlopePlaneVectors(pl, i, fudgecanyon); } xoffs = rxoffs; @@ -1000,7 +1010,7 @@ void R_DrawSinglePlane(visplane_t *pl) } else #endif - R_SlopeVectors(pl, 0, fudgecanyon); + R_SlopePlaneVectors(pl, 0, fudgecanyon); #ifndef NOWATER if (itswater && (spanfunctype == SPANDRAWFUNC_WATER)) diff --git a/src/r_plane.h b/src/r_plane.h index 15f7f07f3..e6dffb4da 100644 --- a/src/r_plane.h +++ b/src/r_plane.h @@ -84,11 +84,15 @@ visplane_t *R_CheckPlane(visplane_t *pl, INT32 start, INT32 stop); void R_ExpandPlane(visplane_t *pl, INT32 start, INT32 stop); void R_PlaneBounds(visplane_t *plane); -// Draws a single visplane. -void R_DrawSinglePlane(visplane_t *pl); void R_CheckFlatLength(size_t size); boolean R_CheckPowersOfTwo(void); +// Draws a single visplane. +void R_DrawSinglePlane(visplane_t *pl); + +// Calculates the slope vectors needed for tilted span drawing. +void R_CalculateSlopeVectors(pslope_t *slope, fixed_t planeviewx, fixed_t planeviewy, fixed_t planeviewz, fixed_t planexscale, fixed_t planeyscale, fixed_t planexoffset, fixed_t planeyoffset, angle_t planeviewangle, angle_t planeangle, float fudge); + typedef struct planemgr_s { visplane_t *plane; diff --git a/src/r_splats.c b/src/r_splats.c index fa4d9eef8..541221841 100644 --- a/src/r_splats.c +++ b/src/r_splats.c @@ -14,6 +14,7 @@ #include "r_main.h" #include "r_splats.h" #include "r_bsp.h" +#include "p_slopes.h" #include "w_wad.h" #include "z_zone.h" @@ -143,10 +144,10 @@ static void rasterize_segment_tex(INT32 x1, INT32 y1, INT32 x2, INT32 y2, INT32 // fill the polygon with linear interpolation, call span drawer for each // scan line // -------------------------------------------------------------------------- -void R_RenderFloorSplat(floorsplat_t *pSplat, vertex_t *verts, vissprite_t *vis) +void R_RenderFloorSplat(floorsplat_t *pSplat, vector2_t *verts, vissprite_t *vis) { // rasterizing - INT32 miny = viewheight + 1, maxy = 0, y, x1, ry1, x2, y2, i; + INT32 miny = viewheight + 1, maxy = 0, y, x1, ry1, x2, y2, i, xclip; fixed_t offsetx = 0, offsety = 0; fixed_t step; @@ -217,19 +218,47 @@ void R_RenderFloorSplat(floorsplat_t *pSplat, vertex_t *verts, vissprite_t *vis) // do segment d -> left side of texture RASTERPARAMS(0,3,pSplat->width-1,0,0,1); - ds_source = pSplat->pic; + ds_source = (UINT8 *)pSplat->pic; ds_flatwidth = pSplat->width; ds_flatheight = pSplat->height; if (R_CheckPowersOfTwo()) R_CheckFlatLength(ds_flatwidth * ds_flatheight); + // Lactozilla: I don't know what I'm doing + if (pSplat->tilted) + { + R_CalculateSlopeVectors(&pSplat->slope, viewx, viewy, viewz, pSplat->xscale, pSplat->yscale, -pSplat->verts[0].x, pSplat->verts[0].y, viewangle, pSplat->angle, 1.0f); + spanfunctype = SPANDRAWFUNC_TILTEDSPRITE; + } + else + { + if (pSplat->angle) + { + // Add the view offset, rotated by the plane angle. + fixed_t a = -pSplat->verts[0].x + viewx; + fixed_t b = -pSplat->verts[0].y + viewy; + angle = (pSplat->angle >> ANGLETOFINESHIFT); + offsetx = FixedMul(a, FINECOSINE(angle)) - FixedMul(b,FINESINE(angle)); + offsety = -FixedMul(a, FINESINE(angle)) - FixedMul(b,FINECOSINE(angle)); + } + else + { + offsetx = viewx - pSplat->verts[0].x; + offsety = pSplat->verts[0].y - viewy; + } + } + ds_transmap = NULL; if (vis->transmap) { ds_transmap = vis->transmap; - spanfunctype = SPANDRAWFUNC_TRANSSPRITE; + + if (pSplat->tilted) + spanfunctype = SPANDRAWFUNC_TILTEDTRANSSPRITE; + else + spanfunctype = SPANDRAWFUNC_TRANSSPRITE; } if (ds_powersoftwo) @@ -237,7 +266,7 @@ void R_RenderFloorSplat(floorsplat_t *pSplat, vertex_t *verts, vissprite_t *vis) else spanfunc = spanfuncs_npo2[spanfunctype]; - if (pSplat->angle) + if (pSplat->angle && !pSplat->tilted) { memset(cachedheight, 0, sizeof(cachedheight)); angle = (viewangle + pSplat->angle - ANGLE_90) >> ANGLETOFINESHIFT; @@ -252,7 +281,6 @@ void R_RenderFloorSplat(floorsplat_t *pSplat, vertex_t *verts, vissprite_t *vis) } planeheight = abs(pSplat->z - viewz); - if (maxy >= vid.height) maxy = vid.height-1; @@ -276,33 +304,6 @@ void R_RenderFloorSplat(floorsplat_t *pSplat, vertex_t *verts, vissprite_t *vis) if (x2 >= vid.width) x2 = vid.width - 1; - angle = (viewangle + pSplat->angle)>>ANGLETOFINESHIFT; - planecos = FINECOSINE(angle); - planesin = FINESINE(angle); - - if (planeheight != cachedheight[y]) - { - cachedheight[y] = planeheight; - distance = cacheddistance[y] = FixedMul(planeheight, yslope[y]); - xstep = cachedxstep[y] = FixedMul(distance, basexscale); - ystep = cachedystep[y] = FixedMul(distance, baseyscale); - // don't divide by zero - if ((span = abs(centery-y))) - { - xstep = cachedxstep[y] = FixedMul(planesin, planeheight) / span; - ystep = cachedystep[y] = FixedMul(planecos, planeheight) / span; - } - } - else - { - distance = cacheddistance[y]; - xstep = cachedxstep[y]; - ystep = cachedystep[y]; - } - - ds_xstep = FixedDiv(xstep, pSplat->xscale); - ds_ystep = FixedDiv(ystep, pSplat->yscale); - ds_colormap = vis->colormap; ds_translation = R_GetSpriteTranslation(vis); if (ds_translation == NULL) @@ -316,53 +317,61 @@ void R_RenderFloorSplat(floorsplat_t *pSplat, vertex_t *verts, vissprite_t *vis) ds_colormap = &vis->extra_colormap->colormap[ds_colormap - colormaps]; } - if (pSplat->angle) + R_ClipVisSprite(vis, x1-1, x2+1, drawsegs, NULL); + memset(ds_splatclip, 0, sizeof(ds_splatclip)); + + if (x2 >= x1 && x1 < viewwidth && x1 >= 0) { - // Add the view offset, rotated by the plane angle. - fixed_t a = -pSplat->verts[0].x + viewx; - fixed_t b = -pSplat->verts[0].y + viewy; - angle = (pSplat->angle >> ANGLETOFINESHIFT); - offsetx = FixedMul(a, FINECOSINE(angle)) - FixedMul(b,FINESINE(angle)); - offsety = -FixedMul(a, FINESINE(angle)) - FixedMul(b,FINECOSINE(angle)); - } - else - { - offsetx = viewx - pSplat->verts[0].x; - offsety = pSplat->verts[0].y - viewy; - } - - if (vis != NULL) - { - INT32 xclip; - - mfloorclip = vis->clipbot; - mceilingclip = vis->cliptop; - - R_ClipVisSprite(vis, x1-1, x2+1, drawsegs, NULL); - memset(ds_splatclip, 0, sizeof(ds_splatclip)); - - if (x2 >= x1 && x1 < viewwidth && x1 >= 0) + for (xclip = x1; xclip <= x2; xclip++) { - for (xclip = x1; xclip <= x2; xclip++) + if (y >= mfloorclip[xclip]) + ds_splatclip[xclip] = 1; + } + } + + while (ds_splatclip[x1]) + x1++; + i = x2; + while (i > x1) + { + if (ds_splatclip[i]) + x2 = i-1; + i--; + } + + if (!pSplat->tilted) + { + angle = (viewangle + pSplat->angle)>>ANGLETOFINESHIFT; + planecos = FINECOSINE(angle); + planesin = FINESINE(angle); + + if (planeheight != cachedheight[y]) + { + cachedheight[y] = planeheight; + distance = cacheddistance[y] = FixedMul(planeheight, yslope[y]); + xstep = cachedxstep[y] = FixedMul(distance, basexscale); + ystep = cachedystep[y] = FixedMul(distance, baseyscale); + + // don't divide by zero + if ((span = abs(centery-y))) { - if (y >= mfloorclip[xclip]) - ds_splatclip[xclip] = 1; + xstep = cachedxstep[y] = FixedMul(planesin, planeheight) / span; + ystep = cachedystep[y] = FixedMul(planecos, planeheight) / span; } } - - while (ds_splatclip[x1]) - x1++; - i = x2; - while (i > x1) + else { - if (ds_splatclip[i]) - x2 = i-1; - i--; + distance = cacheddistance[y]; + xstep = cachedxstep[y]; + ystep = cachedystep[y]; } - } - ds_xfrac = FixedDiv(offsetx + FixedMul(planecos, distance) + (x1 - centerx) * xstep, pSplat->xscale); - ds_yfrac = FixedDiv(offsety - FixedMul(planesin, distance) + (x1 - centerx) * ystep, pSplat->yscale); + ds_xstep = FixedDiv(xstep, pSplat->xscale); + ds_ystep = FixedDiv(ystep, pSplat->yscale); + + ds_xfrac = FixedDiv(offsetx + FixedMul(planecos, distance) + (x1 - centerx) * xstep, pSplat->xscale); + ds_yfrac = FixedDiv(offsety - FixedMul(planesin, distance) + (x1 - centerx) * ystep, pSplat->yscale); + } if (x2 >= x1) { @@ -376,7 +385,7 @@ void R_RenderFloorSplat(floorsplat_t *pSplat, vertex_t *verts, vissprite_t *vis) rastertab[y].maxx = INT32_MIN; } - if (pSplat->angle) + if (pSplat->angle && !pSplat->tilted) { memset(cachedheight, 0, sizeof(cachedheight)); angle = (viewangle - ANGLE_90) >> ANGLETOFINESHIFT; diff --git a/src/r_splats.h b/src/r_splats.h index 9c01084cf..b0707e95b 100644 --- a/src/r_splats.h +++ b/src/r_splats.h @@ -31,17 +31,19 @@ extern struct rastery_s *prastertab; // for ASM code #ifdef FLOORSPLATS typedef struct floorsplat_s { - UINT8 *pic; + UINT16 *pic; INT32 width, height; fixed_t scale, xscale, yscale; angle_t angle; + boolean tilted; // Uses the tilted drawer + pslope_t slope; - vertex_t verts[4]; // (x,y) as viewed from above on map + vector3_t verts[4]; // (x,y,z) as viewed from above on map fixed_t x, y, z; // position mobj_t *mobj; // Mobj it is tied to } floorsplat_t; -void R_RenderFloorSplat(floorsplat_t *pSplat, vertex_t *verts, vissprite_t *vis); +void R_RenderFloorSplat(floorsplat_t *pSplat, vector2_t *verts, vissprite_t *vis); extern UINT8 ds_splatclip[MAXVIDWIDTH]; #endif diff --git a/src/r_things.c b/src/r_things.c index d60228e36..99fa2c7c5 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -1415,7 +1415,7 @@ static void R_ProjectSprite(mobj_t *thing) fixed_t tx, tz; fixed_t xscale, yscale; //added : 02-02-98 : aaargll..if I were a math-guy!!! fixed_t sortscale, sortsplat = 0; - fixed_t sort_x = 0, sort_y = 0; + fixed_t sort_x = 0, sort_y = 0, sort_z; INT32 x1, x2; @@ -1764,10 +1764,10 @@ static void R_ProjectSprite(mobj_t *thing) // Adjust the sort scale if needed if (splat) { - tz = (patch->height - patch->topoffset) * FRACUNIT; + sort_z = (patch->height - patch->topoffset) * FRACUNIT; ang = (viewangle >> ANGLETOFINESHIFT); - sort_x = FixedMul(FixedMul(FixedMul(spritexscale, this_scale), tz), FINECOSINE(ang)); - sort_y = FixedMul(FixedMul(FixedMul(spriteyscale, this_scale), tz), FINESINE(ang)); + sort_x = FixedMul(FixedMul(FixedMul(spritexscale, this_scale), sort_z), FINECOSINE(ang)); + sort_y = FixedMul(FixedMul(FixedMul(spriteyscale, this_scale), sort_z), FINESINE(ang)); } if ((thing->flags2 & MF2_LINKDRAW) && thing->tracer) // toast 16/09/16 (SYMMETRY) @@ -1797,8 +1797,8 @@ static void R_ProjectSprite(mobj_t *thing) { tr_x = (thing->x + sort_x) - viewx; tr_y = (thing->y + sort_y) - viewy; - tz = FixedMul(tr_x, viewcos) + FixedMul(tr_y, viewsin); - sortscale = FixedDiv(projectiony, tz); + sort_z = FixedMul(tr_x, viewcos) + FixedMul(tr_y, viewsin); + sortscale = FixedDiv(projectiony, sort_z); } // Calculate the splat's sortscale @@ -1806,8 +1806,8 @@ static void R_ProjectSprite(mobj_t *thing) { tr_x = (thing->x - sort_x) - viewx; tr_y = (thing->y - sort_y) - viewy; - tz = FixedMul(tr_x, viewcos) + FixedMul(tr_y, viewsin); - sortsplat = FixedDiv(projectiony, tz); + sort_z = FixedMul(tr_x, viewcos) + FixedMul(tr_y, viewsin); + sortsplat = FixedDiv(projectiony, sort_z); } // PORTAL SPRITE CLIPPING @@ -2796,8 +2796,8 @@ static void R_DrawVisSplat(vissprite_t *spr) #ifdef FLOORSPLATS floorsplat_t splat; fixed_t tr_x, tr_y, rot_x, rot_y, rot_z; - vertex_t *v3d; - vertex_t v2d[4]; + vector3_t *v3d; + vector2_t v2d[4]; fixed_t x, y; fixed_t w, h; angle_t splatangle, angle; @@ -2809,6 +2809,7 @@ static void R_DrawVisSplat(vissprite_t *spr) boolean vflip = (spr->cut & SC_VFLIP); UINT8 flipflags = 0; vector2_t rotated[4]; + pslope_t *slope = NULL; INT32 i; if (hflip) @@ -2826,6 +2827,9 @@ static void R_DrawVisSplat(vissprite_t *spr) splat.height = spr->patch->height; splat.scale = spr->mobj->scale; + if (spr->mobj->skin && ((skin_t *)spr->mobj->skin)->flags & SF_HIRES) + splat.scale = FixedMul(splat.scale, ((skin_t *)spr->mobj->skin)->highresscale); + if (spr->rotateflags & SRF_3D || spr->renderflags & RF_NOSPLATBILLBOARD) splatangle = spr->mobj->angle; else @@ -2859,6 +2863,7 @@ static void R_DrawVisSplat(vissprite_t *spr) splat.x = x; splat.y = y; splat.z = spr->mobj->z; + splat.tilted = false; // Set positions @@ -2889,14 +2894,53 @@ static void R_DrawVisSplat(vissprite_t *spr) rotated[i].y = FixedMul(splat.verts[i].x, sa) + FixedMul(splat.verts[i].y, ca); } + if (spr->renderflags & RF_SLOPESPLAT) + { + slope = spr->mobj->standingslope; + splat.tilted = (slope != NULL); + } + + if (splat.tilted) + { + // Lactozilla: Just copy the entire slope LMFAOOOO + pslope_t *s = &splat.slope; + + s->o.x = slope->o.x; + s->o.y = slope->o.y; + s->o.z = slope->o.z; + + s->d.x = slope->d.x; + s->d.y = slope->d.y; + + s->normal.x = slope->normal.x; + s->normal.y = slope->normal.y; + s->normal.z = slope->normal.z; + + s->zdelta = slope->zdelta; + s->zangle = slope->zangle; + s->xydirection = slope->xydirection; + + s->next = NULL; + s->flags = 0; + } + // Translate for (i = 0; i < 4; i++) { - splat.verts[i].x = rotated[i].x + x; - splat.verts[i].y = rotated[i].y + y; - } + tr_x = rotated[i].x + x; + tr_y = rotated[i].y + y; - rot_z = splat.z - viewz; + if (slope) + { + rot_z = P_GetSlopeZAt(slope, tr_x, tr_y); + splat.verts[i].z = rot_z; + } + else + splat.verts[i].z = splat.z; + + splat.verts[i].x = tr_x; + splat.verts[i].y = tr_y; + } for (i = 0; i < 4; i++) { @@ -2909,6 +2953,7 @@ static void R_DrawVisSplat(vissprite_t *spr) // rotation around vertical y axis rot_x = FixedMul(tr_x, viewsin) - FixedMul(tr_y, viewcos); rot_y = FixedMul(tr_x, viewcos) + FixedMul(tr_y, viewsin); + rot_z = v3d->z - viewz; if (!rot_y || rot_y < FixedDiv(4*FRACUNIT, splat.scale)) return; diff --git a/src/screen.c b/src/screen.c index f5d182f34..8b6c05b6a 100644 --- a/src/screen.c +++ b/src/screen.c @@ -126,6 +126,8 @@ void SCR_SetDrawFuncs(void) spanfuncs[SPANDRAWFUNC_TRANSSPLAT] = R_DrawTranslucentSplat_8; spanfuncs[SPANDRAWFUNC_SPRITE] = R_DrawFloorSprite_8; spanfuncs[SPANDRAWFUNC_TRANSSPRITE] = R_DrawTranslucentFloorSprite_8; + spanfuncs[SPANDRAWFUNC_TILTEDSPRITE] = R_DrawTiltedFloorSprite_8; + spanfuncs[SPANDRAWFUNC_TILTEDTRANSSPRITE] = R_DrawTiltedTranslucentFloorSprite_8; spanfuncs[SPANDRAWFUNC_FOG] = R_DrawFogSpan_8; #ifndef NOWATER spanfuncs[SPANDRAWFUNC_WATER] = R_DrawTranslucentWaterSpan_8; @@ -144,6 +146,8 @@ void SCR_SetDrawFuncs(void) spanfuncs_npo2[SPANDRAWFUNC_TRANSSPLAT] = R_DrawTranslucentSplat_NPO2_8; spanfuncs_npo2[SPANDRAWFUNC_SPRITE] = R_DrawFloorSprite_NPO2_8; spanfuncs_npo2[SPANDRAWFUNC_TRANSSPRITE] = R_DrawTranslucentFloorSprite_NPO2_8; + spanfuncs_npo2[SPANDRAWFUNC_TILTEDSPRITE] = R_DrawTiltedFloorSprite_NPO2_8; + spanfuncs_npo2[SPANDRAWFUNC_TILTEDTRANSSPRITE] = R_DrawTiltedTranslucentFloorSprite_NPO2_8; spanfuncs_npo2[SPANDRAWFUNC_FOG] = NULL; // Not needed #ifndef NOWATER spanfuncs_npo2[SPANDRAWFUNC_WATER] = R_DrawTranslucentWaterSpan_NPO2_8; diff --git a/src/screen.h b/src/screen.h index 021c644ba..b139bd3b4 100644 --- a/src/screen.h +++ b/src/screen.h @@ -144,6 +144,8 @@ enum SPANDRAWFUNC_TRANSSPLAT, SPANDRAWFUNC_SPRITE, SPANDRAWFUNC_TRANSSPRITE, + SPANDRAWFUNC_TILTEDSPRITE, + SPANDRAWFUNC_TILTEDTRANSSPRITE, SPANDRAWFUNC_FOG, #ifndef NOWATER SPANDRAWFUNC_WATER, From 5fca04c3dda5e84c230526057b36f278cbc54246 Mon Sep 17 00:00:00 2001 From: James R Date: Tue, 13 Oct 2020 19:04:52 -0700 Subject: [PATCH 0177/1080] Apply step up/down to opposite plane too --- src/p_map.c | 85 +++++++++++++++++++++++------------------------------ 1 file changed, 37 insertions(+), 48 deletions(-) diff --git a/src/p_map.c b/src/p_map.c index cb06f7d77..e9543e710 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -2661,7 +2661,7 @@ 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; fixed_t startingonground = P_IsObjectOnGround(thing); floatok = false; @@ -2702,6 +2702,11 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff) || GETSECSPECIAL(R_PointInSubsector(x, y)->sector->special, 1) == 13) maxstep <<= 1; + // If using type Section1:14, no maxstep. + if (P_PlayerTouchingSectorSpecial(thing->player, 1, 14) + || GETSECSPECIAL(R_PointInSubsector(x, y)->sector->special, 1) == 14) + maxstep = 0; + // Don't 'step up' while springing, // Only step up "if needed". if (thing->player->panim == PA_SPRING @@ -2721,39 +2726,45 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff) floatok = true; - if (thing->eflags & MFE_VERTICALFLIP) + thingtop = thing->z + thing->height; + + // Step up + if (thing->z < tmfloorz) { - if (thing->z < tmfloorz) + if (tmfloorz - thing->z <= maxstep) + { + thing->z = thing->floorz = tmfloorz; + thing->floorrover = tmfloorrover; + thing->eflags |= MFE_JUSTSTEPPEDDOWN; + } + else + { return false; // mobj must raise itself to fit + } } else if (tmceilingz < thingtop) - return false; // mobj must lower itself to fit - - // Ramp test - if (maxstep > 0 && !( - thing->player && ( - P_PlayerTouchingSectorSpecial(thing->player, 1, 14) - || GETSECSPECIAL(R_PointInSubsector(x, y)->sector->special, 1) == 14) - ) - ) + { + if (tmceilingz - thingtop <= maxstep) + { + thing->z = ( thing->ceilingz = tmceilingz ) - thing->height; + thing->ceilingrover = tmceilingrover; + thing->eflags |= MFE_JUSTSTEPPEDDOWN; + } + else + { + return false; // mobj must lower itself to fit + } + } + else if (maxstep > 0) // 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. - if (thing->eflags & MFE_VERTICALFLIP) + if (thingtop == thing->ceilingz && tmceilingz > thingtop && tmceilingz - thingtop <= maxstep) { - if (thingtop == thing->ceilingz && tmceilingz > thingtop && tmceilingz - thingtop <= maxstep) - { - thing->z = (thing->ceilingz = thingtop = tmceilingz) - thing->height; - thing->ceilingrover = tmceilingrover; - thing->eflags |= MFE_JUSTSTEPPEDDOWN; - } - else if (tmceilingz < thingtop && thingtop - tmceilingz <= maxstep) - { - thing->z = (thing->ceilingz = thingtop = tmceilingz) - thing->height; - thing->ceilingrover = tmceilingrover; - thing->eflags |= MFE_JUSTSTEPPEDDOWN; - } + thing->z = (thing->ceilingz = thingtop = tmceilingz) - thing->height; + thing->ceilingrover = tmceilingrover; + thing->eflags |= MFE_JUSTSTEPPEDDOWN; } else if (thing->z == thing->floorz && tmfloorz < thing->z && thing->z - tmfloorz <= maxstep) { @@ -2761,28 +2772,6 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff) thing->floorrover = tmfloorrover; thing->eflags |= MFE_JUSTSTEPPEDDOWN; } - else if (tmfloorz > thing->z && tmfloorz - thing->z <= maxstep) - { - thing->z = thing->floorz = tmfloorz; - thing->floorrover = tmfloorrover; - thing->eflags |= MFE_JUSTSTEPPEDDOWN; - } - } - - if (thing->eflags & MFE_VERTICALFLIP) - { - if (thingtop - tmceilingz > maxstep) - { - if (tmfloorthing) - tmhitthing = tmfloorthing; - return false; // too big a step up - } - } - else if (tmfloorz - thing->z > maxstep) - { - if (tmfloorthing) - tmhitthing = tmfloorthing; - return false; // too big a step up } if (!allowdropoff && !(thing->flags & MF_FLOAT) && thing->type != MT_SKIM && !tmfloorthing) @@ -5050,4 +5039,4 @@ fixed_t P_CeilingzAtPos(fixed_t x, fixed_t y, fixed_t z, fixed_t height) } return ceilingz; -} \ No newline at end of file +} From bc23f582fe69c5a3c9a0c2e08d649d5d6dfdc11d Mon Sep 17 00:00:00 2001 From: James R Date: Tue, 13 Oct 2020 19:11:18 -0700 Subject: [PATCH 0178/1080] Don't need to set this actually --- 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 e9543e710..2a7b51abd 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -2762,7 +2762,7 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff) if (thingtop == thing->ceilingz && tmceilingz > thingtop && tmceilingz - thingtop <= maxstep) { - thing->z = (thing->ceilingz = thingtop = tmceilingz) - thing->height; + thing->z = (thing->ceilingz = tmceilingz) - thing->height; thing->ceilingrover = tmceilingrover; thing->eflags |= MFE_JUSTSTEPPEDDOWN; } From a8a66f698a47eb824c604c90835f85b470fb482a Mon Sep 17 00:00:00 2001 From: Jaime Passos Date: Tue, 13 Oct 2020 23:12:44 -0300 Subject: [PATCH 0179/1080] [Software] Use the light at the bottom of the object for splats --- src/r_things.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/r_things.c b/src/r_things.c index 99fa2c7c5..a0b6239a7 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -1914,12 +1914,13 @@ static void R_ProjectSprite(mobj_t *thing) if (thing->subsector->sector->numlights) { INT32 lightnum; + fixed_t top = (splat) ? gz : gzt; light = thing->subsector->sector->numlights - 1; // R_GetPlaneLight won't work on sloped lights! for (lightnum = 1; lightnum < thing->subsector->sector->numlights; lightnum++) { fixed_t h = P_GetLightZAt(&thing->subsector->sector->lightlist[lightnum], thing->x, thing->y); - if (h <= gzt) { + if (h <= top) { light = lightnum - 1; break; } From ab526e47cc3837892c61d1ec23be8e6ea0dc44c6 Mon Sep 17 00:00:00 2001 From: Jaime Passos Date: Wed, 14 Oct 2020 00:57:13 -0300 Subject: [PATCH 0180/1080] Implement object-defined floor sprite slopes. --- src/dehacked.c | 2 + src/hardware/hw_main.c | 24 +++++++++--- src/lua_mobjlib.c | 7 ++++ src/p_mobj.c | 6 +++ src/p_mobj.h | 1 + src/p_saveg.c | 88 ++++++++++++++++++++++++++++++++---------- src/r_defs.h | 8 ++-- src/r_things.c | 28 ++++++++++---- 8 files changed, 129 insertions(+), 35 deletions(-) diff --git a/src/dehacked.c b/src/dehacked.c index 0662074ba..df692391c 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -9585,7 +9585,9 @@ struct { {"RF_VERTICALFLIP",RF_VERTICALFLIP}, {"RF_ABSOLUTEOFFSETS",RF_ABSOLUTEOFFSETS}, {"RF_FLIPOFFSETS",RF_FLIPOFFSETS}, + {"RF_SPLATMASK",RF_SLOPESPLAT}, {"RF_SLOPESPLAT",RF_SLOPESPLAT}, + {"RF_OBJECTSLOPESPLAT",RF_OBJECTSLOPESPLAT}, {"RF_NOSPLATBILLBOARD",RF_NOSPLATBILLBOARD}, {"RF_NOSPLATROLLANGLE",RF_NOSPLATROLLANGLE}, {"RF_BLENDMASK",RF_BLENDMASK}, diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 315737108..948045df3 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -3942,6 +3942,7 @@ static void HWR_DrawSprite(gl_vissprite_t *spr) { F2DCoord verts[4]; F2DCoord rotated[4]; + angle_t angle; float ca, sa; float w, h; @@ -3950,12 +3951,14 @@ static void HWR_DrawSprite(gl_vissprite_t *spr) float leftoffset, topoffset; float scale = spr->scale; float zoffset = (P_MobjFlip(spr->mobj) * 0.05f); + pslope_t *splatslope = NULL; INT32 i; - if (spr->renderflags & RF_SHADOWEFFECTS) + renderflags_t renderflags = spr->renderflags; + if (renderflags & RF_SHADOWEFFECTS) scale *= spr->shadowscale; - if (spr->rotateflags & SRF_3D || spr->renderflags & RF_NOSPLATBILLBOARD) + if (spr->rotateflags & SRF_3D || renderflags & RF_NOSPLATBILLBOARD) angle = spr->mobj->angle; else angle = viewangle; @@ -4015,13 +4018,24 @@ static void HWR_DrawSprite(gl_vissprite_t *spr) wallVerts[i].z = rotated[i].y + FIXED_TO_FLOAT(spr->mobj->y); } - if (spr->renderflags & RF_SLOPESPLAT && spr->mobj->standingslope) + if (renderflags & (RF_SLOPESPLAT | RF_OBJECTSLOPESPLAT)) { - pslope_t *slope = spr->mobj->standingslope; + pslope_t *standingslope = spr->mobj->standingslope; // The slope that the object is standing on. + // The slope that was defined for the sprite. + if (renderflags & RF_SLOPESPLAT) + splatslope = spr->mobj->floorspriteslope; + + if (standingslope && (renderflags & RF_OBJECTSLOPESPLAT)) + splatslope = standingslope; + } + + // Set vertical position + if (splatslope) + { for (i = 0; i < 4; i++) { - fixed_t slopez = P_GetSlopeZAt(slope, FLOAT_TO_FIXED(wallVerts[i].x), FLOAT_TO_FIXED(wallVerts[i].z)); + fixed_t slopez = P_GetSlopeZAt(splatslope, FLOAT_TO_FIXED(wallVerts[i].x), FLOAT_TO_FIXED(wallVerts[i].z)); wallVerts[i].y = FIXED_TO_FLOAT(slopez) + zoffset; } } diff --git a/src/lua_mobjlib.c b/src/lua_mobjlib.c index a544f151c..75b0c2f89 100644 --- a/src/lua_mobjlib.c +++ b/src/lua_mobjlib.c @@ -43,6 +43,7 @@ enum mobj_e { mobj_spriteyscale, mobj_spritexoffset, mobj_spriteyoffset, + mobj_floorspriteslope, mobj_touching_sectorlist, mobj_subsector, mobj_floorz, @@ -117,6 +118,7 @@ static const char *const mobj_opt[] = { "spriteyscale", "spritexoffset", "spriteyoffset", + "floorspriteslope", "touching_sectorlist", "subsector", "floorz", @@ -249,6 +251,9 @@ static int mobj_get(lua_State *L) case mobj_spriteyoffset: lua_pushfixed(L, mo->spriteyoffset); break; + case mobj_floorspriteslope: + LUA_PushUserdata(L, mo->floorspriteslope, META_SLOPE); + break; case mobj_touching_sectorlist: return UNIMPLEMENTED; case mobj_subsector: @@ -529,6 +534,8 @@ static int mobj_set(lua_State *L) case mobj_spriteyoffset: mo->spriteyoffset = luaL_checkfixed(L, 3); break; + case mobj_floorspriteslope: + return NOSET; case mobj_touching_sectorlist: return UNIMPLEMENTED; case mobj_subsector: diff --git a/src/p_mobj.c b/src/p_mobj.c index 2260ace51..6d36ee303 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -10473,6 +10473,8 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type) // Sprite rendering mobj->spritexscale = mobj->spriteyscale = mobj->scale; mobj->spritexoffset = mobj->spriteyoffset = 0; + mobj->floorspriteslope = Z_Calloc(sizeof(pslope_t), PU_LEVEL, NULL); + mobj->floorspriteslope->normal.z = FRACUNIT; // set subsector and/or block links P_SetThingPosition(mobj); @@ -10935,6 +10937,10 @@ void P_RemoveMobj(mobj_t *mobj) mobj->state = NULL; mobj->player = NULL; + if (mobj->floorspriteslope) + Z_Free(mobj->floorspriteslope); + mobj->floorspriteslope = NULL; + // stop any playing sound S_StopSound(mobj); diff --git a/src/p_mobj.h b/src/p_mobj.h index 0b688a9ad..d26a38897 100644 --- a/src/p_mobj.h +++ b/src/p_mobj.h @@ -289,6 +289,7 @@ typedef struct mobj_s UINT32 renderflags; // render flags fixed_t spritexscale, spriteyscale; fixed_t spritexoffset, spriteyoffset; + struct pslope_s *floorspriteslope; // The slope that the floorsprite is rotated by struct msecnode_s *touching_sectorlist; // a linked list of sectors where this object appears diff --git a/src/p_saveg.c b/src/p_saveg.c index 3a9663326..ae8181693 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -1393,12 +1393,13 @@ typedef enum MD2_COLORIZED = 1<<12, MD2_MIRRORED = 1<<13, MD2_ROLLANGLE = 1<<14, - MD2_SPRITEXSCALE = 1<<15, - MD2_SPRITEYSCALE = 1<<16, - MD2_SPRITEXOFFSET = 1<<17, - MD2_SPRITEYOFFSET = 1<<18, - MD2_SHADOWSCALE = 1<<19, - MD2_RENDERFLAGS = 1<<20, + MD2_SHADOWSCALE = 1<<15, + MD2_RENDERFLAGS = 1<<16, + MD2_SPRITEXSCALE = 1<<17, + MD2_SPRITEYSCALE = 1<<18, + MD2_SPRITEXOFFSET = 1<<19, + MD2_SPRITEYOFFSET = 1<<20, + MD2_FLOORSPRITESLOPE = 1<<21, } mobj_diff2_t; typedef enum @@ -1609,18 +1610,27 @@ static void SaveMobjThinker(const thinker_t *th, const UINT8 type) diff2 |= MD2_MIRRORED; if (mobj->rollangle) diff2 |= MD2_ROLLANGLE; + if (mobj->shadowscale) + diff2 |= MD2_SHADOWSCALE; + if (mobj->renderflags) + diff2 |= MD2_RENDERFLAGS; if (mobj->spritexscale != FRACUNIT) diff2 |= MD2_SPRITEXSCALE; if (mobj->spriteyscale != FRACUNIT) diff2 |= MD2_SPRITEYSCALE; if (mobj->spritexoffset) diff2 |= MD2_SPRITEXOFFSET; - if (mobj->spriteyoffset) - diff2 |= MD2_SPRITEYOFFSET; - if (mobj->shadowscale) - diff2 |= MD2_SHADOWSCALE; - if (mobj->renderflags) - diff2 |= MD2_RENDERFLAGS; + + { + pslope_t *slope = mobj->floorspriteslope; + if (slope->zangle || slope->zdelta || slope->xydirection + || slope->o.x || slope->o.y || slope->o.z + || slope->d.x || slope->d.y + || slope->normal.x || slope->normal.y + || (slope->normal.z != FRACUNIT)) + diff2 |= MD2_FLOORSPRITESLOPE; + } + if (diff2 != 0) diff |= MD_MORE; @@ -1761,6 +1771,10 @@ static void SaveMobjThinker(const thinker_t *th, const UINT8 type) WRITEUINT8(save_p, mobj->mirrored); if (diff2 & MD2_ROLLANGLE) WRITEANGLE(save_p, mobj->rollangle); + if (diff2 & MD2_SHADOWSCALE) + WRITEFIXED(save_p, mobj->shadowscale); + if (diff2 & MD2_RENDERFLAGS) + WRITEUINT32(save_p, mobj->renderflags); if (diff2 & MD2_SPRITEXSCALE) WRITEFIXED(save_p, mobj->spritexscale); if (diff2 & MD2_SPRITEYSCALE) @@ -1769,10 +1783,25 @@ static void SaveMobjThinker(const thinker_t *th, const UINT8 type) WRITEFIXED(save_p, mobj->spritexoffset); if (diff2 & MD2_SPRITEYOFFSET) WRITEFIXED(save_p, mobj->spriteyoffset); - if (diff2 & MD2_SHADOWSCALE) - WRITEFIXED(save_p, mobj->shadowscale); - if (diff2 & MD2_RENDERFLAGS) - WRITEUINT32(save_p, mobj->renderflags); + if (diff2 & MD2_FLOORSPRITESLOPE) + { + pslope_t *slope = mobj->floorspriteslope; + + WRITEFIXED(save_p, slope->zdelta); + WRITEANGLE(save_p, slope->zangle); + WRITEANGLE(save_p, slope->xydirection); + + WRITEFIXED(save_p, slope->o.x); + WRITEFIXED(save_p, slope->o.y); + WRITEFIXED(save_p, slope->o.z); + + WRITEFIXED(save_p, slope->d.x); + WRITEFIXED(save_p, slope->d.y); + + WRITEFIXED(save_p, slope->normal.x); + WRITEFIXED(save_p, slope->normal.y); + WRITEFIXED(save_p, slope->normal.z); + } WRITEUINT32(save_p, mobj->mobjnum); } @@ -2780,6 +2809,10 @@ static thinker_t* LoadMobjThinker(actionf_p1 thinker) mobj->mirrored = READUINT8(save_p); if (diff2 & MD2_ROLLANGLE) mobj->rollangle = READANGLE(save_p); + if (diff2 & MD2_SHADOWSCALE) + mobj->shadowscale = READFIXED(save_p); + if (diff2 & MD2_RENDERFLAGS) + mobj->renderflags = READUINT32(save_p); if (diff2 & MD2_SPRITEXSCALE) mobj->spritexscale = READFIXED(save_p); if (diff2 & MD2_SPRITEYSCALE) @@ -2788,10 +2821,25 @@ static thinker_t* LoadMobjThinker(actionf_p1 thinker) mobj->spritexoffset = READFIXED(save_p); if (diff2 & MD2_SPRITEYOFFSET) mobj->spriteyoffset = READFIXED(save_p); - if (diff2 & MD2_SHADOWSCALE) - mobj->shadowscale = READFIXED(save_p); - if (diff2 & MD2_RENDERFLAGS) - mobj->renderflags = READUINT32(save_p); + if (diff2 & MD2_FLOORSPRITESLOPE) + { + pslope_t *slope = mobj->floorspriteslope; + + slope->zdelta = READFIXED(save_p); + slope->zangle = READANGLE(save_p); + slope->xydirection = READANGLE(save_p); + + slope->o.x = READFIXED(save_p); + slope->o.y = READFIXED(save_p); + slope->o.z = READFIXED(save_p); + + slope->d.x = READFIXED(save_p); + slope->d.y = READFIXED(save_p); + + slope->normal.x = READFIXED(save_p); + slope->normal.y = READFIXED(save_p); + slope->normal.z = READFIXED(save_p); + } if (diff & MD_REDFLAG) { diff --git a/src/r_defs.h b/src/r_defs.h index 7b7c5d7f0..4423a4266 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -720,9 +720,11 @@ typedef enum RF_ABSOLUTEOFFSETS = 0x0004, // Sprite uses the object's offsets absolutely, instead of relatively RF_FLIPOFFSETS = 0x0008, // Relative object offsets are flipped with the sprite - RF_SLOPESPLAT = 0x0010, // Rotate floor sprites by the object's standing slope - RF_NOSPLATBILLBOARD = 0x0020, // Don't billboard floor sprites (faces forward from the view angle) - RF_NOSPLATROLLANGLE = 0x0040, // Don't rotate floor sprites by the object's rollangle (uses rotated patches instead) + RF_SPLATMASK = 0x00F0, // --Floor sprite flags + RF_SLOPESPLAT = 0x0010, // Rotate floor sprites by a slope + RF_OBJECTSLOPESPLAT = 0x0020, // Rotate floor sprites by the object's standing slope + RF_NOSPLATBILLBOARD = 0x0040, // Don't billboard floor sprites (faces forward from the view angle) + RF_NOSPLATROLLANGLE = 0x0080, // Don't rotate floor sprites by the object's rollangle (uses rotated patches instead) RF_BLENDMASK = 0x0F00, // --Blending modes RF_FULLBRIGHT = 0x0100, // Sprite is drawn at full brightness diff --git a/src/r_things.c b/src/r_things.c index a0b6239a7..e8c00b86b 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -2797,21 +2797,26 @@ static void R_DrawVisSplat(vissprite_t *spr) #ifdef FLOORSPLATS floorsplat_t splat; fixed_t tr_x, tr_y, rot_x, rot_y, rot_z; + vector3_t *v3d; vector2_t v2d[4]; + vector2_t rotated[4]; + fixed_t x, y; fixed_t w, h; - angle_t splatangle, angle; + angle_t angle, splatangle; fixed_t ca, sa; fixed_t xscale, yscale; fixed_t xoffset, yoffset; fixed_t leftoffset, topoffset; + pslope_t *slope = NULL; + INT32 i; + boolean hflip = (spr->xiscale < 0); boolean vflip = (spr->cut & SC_VFLIP); UINT8 flipflags = 0; - vector2_t rotated[4]; - pslope_t *slope = NULL; - INT32 i; + + renderflags_t renderflags = spr->renderflags; if (hflip) flipflags |= PICFLAGS_XFLIP; @@ -2831,7 +2836,7 @@ static void R_DrawVisSplat(vissprite_t *spr) if (spr->mobj->skin && ((skin_t *)spr->mobj->skin)->flags & SF_HIRES) splat.scale = FixedMul(splat.scale, ((skin_t *)spr->mobj->skin)->highresscale); - if (spr->rotateflags & SRF_3D || spr->renderflags & RF_NOSPLATBILLBOARD) + if (spr->rotateflags & SRF_3D || renderflags & RF_NOSPLATBILLBOARD) splatangle = spr->mobj->angle; else splatangle = viewangle; @@ -2895,9 +2900,18 @@ static void R_DrawVisSplat(vissprite_t *spr) rotated[i].y = FixedMul(splat.verts[i].x, sa) + FixedMul(splat.verts[i].y, ca); } - if (spr->renderflags & RF_SLOPESPLAT) + if (renderflags & (RF_SLOPESPLAT | RF_OBJECTSLOPESPLAT)) { - slope = spr->mobj->standingslope; + pslope_t *standingslope = spr->mobj->standingslope; // The slope that the object is standing on. + + // The slope that was defined for the sprite. + if (renderflags & RF_SLOPESPLAT) + slope = spr->mobj->floorspriteslope; + + if (standingslope && (renderflags & RF_OBJECTSLOPESPLAT)) + slope = standingslope; + + // Set splat as tilted splat.tilted = (slope != NULL); } From b35633bb61385c45f660657d2bbb989b4ce45083 Mon Sep 17 00:00:00 2001 From: James R Date: Wed, 14 Oct 2020 01:19:43 -0700 Subject: [PATCH 0181/1080] brug --- 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 2a7b51abd..f2faf29b6 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -2744,7 +2744,7 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff) } else if (tmceilingz < thingtop) { - if (tmceilingz - thingtop <= maxstep) + if (thingtop - tmceilingz <= maxstep) { thing->z = ( thing->ceilingz = tmceilingz ) - thing->height; thing->ceilingrover = tmceilingrover; From a2ff89f0077dcccfe516d8ce42bebde790b31268 Mon Sep 17 00:00:00 2001 From: sphere Date: Wed, 14 Oct 2020 17:39:23 +0200 Subject: [PATCH 0182/1080] Make record attack's quick retry more consistent. --- src/p_setup.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index 55840a0f2..7747f6462 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -4011,23 +4011,23 @@ boolean P_LoadLevel(boolean fromnetsave) wipegamestate = FORCEWIPEOFF; wipestyleflags = 0; - // Special stage fade to white + // Special stage & record attack retry fade to white // This is handled BEFORE sounds are stopped. - if (modeattacking && !demoplayback && (pausedelay == INT32_MIN)) - ranspecialwipe = 2; + if (G_GetModeAttackRetryFlag()) + { + if (modeattacking && !demoplayback) + { + ranspecialwipe = 2; + wipestyleflags |= (WSF_FADEOUT|WSF_TOWHITE); + } + G_ClearModeAttackRetryFlag(); + } else if (rendermode != render_none && G_IsSpecialStage(gamemap)) { P_RunSpecialStageWipe(); ranspecialwipe = 1; } - if (G_GetModeAttackRetryFlag()) - { - if (modeattacking) - wipestyleflags |= (WSF_FADEOUT|WSF_TOWHITE); - G_ClearModeAttackRetryFlag(); - } - // Make sure all sounds are stopped before Z_FreeTags. S_StopSounds(); S_ClearSfx(); From e63efdac136dff1a74a49e5e4d16a01c1274f9ef Mon Sep 17 00:00:00 2001 From: Jaime Passos Date: Wed, 14 Oct 2020 13:07:02 -0300 Subject: [PATCH 0183/1080] Only create floor sprite slopes when needed, instead of always allocating them. Has to be done manually in Lua. Use P_CreateFloorSpriteSlope, and P_DeleteFloorSpriteSlope when done with it. --- src/lua_baselib.c | 24 ++++++++++++++++++++++++ src/p_mobj.c | 19 +++++++++++++++++-- src/p_mobj.h | 2 ++ src/p_saveg.c | 4 ++-- 4 files changed, 45 insertions(+), 4 deletions(-) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index d74af4214..f320cfdce 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -910,6 +910,28 @@ static int lib_pMaceRotate(lua_State *L) return 0; } +static int lib_pCreateFloorSpriteSlope(lua_State *L) +{ + mobj_t *mobj = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); + NOHUD + INLEVEL + if (!mobj) + return LUA_ErrInvalid(L, "mobj_t"); + LUA_PushUserdata(L, (pslope_t *)P_CreateFloorSpriteSlope(mobj), META_SLOPE); + return 1; +} + +static int lib_pDeleteFloorSpriteSlope(lua_State *L) +{ + mobj_t *mobj = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); + NOHUD + INLEVEL + if (!mobj) + return LUA_ErrInvalid(L, "mobj_t"); + P_DeleteFloorSpriteSlope(mobj); + return 1; +} + static int lib_pRailThinker(lua_State *L) { mobj_t *mobj = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); @@ -3536,6 +3558,8 @@ static luaL_Reg lib[] = { {"P_CheckSolidLava",lib_pCheckSolidLava}, {"P_CanRunOnWater",lib_pCanRunOnWater}, {"P_MaceRotate",lib_pMaceRotate}, + {"P_CreateFloorSpriteSlope",lib_pCreateFloorSpriteSlope}, + {"P_DeleteFloorSpriteSlope",lib_pDeleteFloorSpriteSlope}, {"P_RailThinker",lib_pRailThinker}, {"P_XYMovement",lib_pXYMovement}, {"P_RingXYMovement",lib_pRingXYMovement}, diff --git a/src/p_mobj.c b/src/p_mobj.c index 6d36ee303..389dddecd 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -10473,8 +10473,7 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type) // Sprite rendering mobj->spritexscale = mobj->spriteyscale = mobj->scale; mobj->spritexoffset = mobj->spriteyoffset = 0; - mobj->floorspriteslope = Z_Calloc(sizeof(pslope_t), PU_LEVEL, NULL); - mobj->floorspriteslope->normal.z = FRACUNIT; + mobj->floorspriteslope = NULL; // set subsector and/or block links P_SetThingPosition(mobj); @@ -10876,6 +10875,22 @@ static inline precipmobj_t *P_SpawnSnowMobj(fixed_t x, fixed_t y, fixed_t z, mob return mo; } +void *P_CreateFloorSpriteSlope(mobj_t *mobj) +{ + if (mobj->floorspriteslope) + Z_Free(mobj->floorspriteslope); + mobj->floorspriteslope = Z_Calloc(sizeof(pslope_t), PU_LEVEL, NULL); + mobj->floorspriteslope->normal.z = FRACUNIT; + return (void *)mobj->floorspriteslope; +} + +void P_DeleteFloorSpriteSlope(mobj_t *mobj) +{ + if (mobj->floorspriteslope) + Z_Free(mobj->floorspriteslope); + mobj->floorspriteslope = NULL; +} + // // P_RemoveMobj // diff --git a/src/p_mobj.h b/src/p_mobj.h index d26a38897..7eb47112c 100644 --- a/src/p_mobj.h +++ b/src/p_mobj.h @@ -472,6 +472,8 @@ void P_SpawnItemPattern(mapthing_t *mthing, boolean bonustime); void P_SpawnHoopOfSomething(fixed_t x, fixed_t y, fixed_t z, fixed_t radius, INT32 number, mobjtype_t type, angle_t rotangle); 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); +void *P_CreateFloorSpriteSlope(mobj_t *mobj); +void P_DeleteFloorSpriteSlope(mobj_t *mobj); boolean P_BossTargetPlayer(mobj_t *actor, boolean closest); boolean P_SupermanLook4Players(mobj_t *actor); void P_DestroyRobots(void); diff --git a/src/p_saveg.c b/src/p_saveg.c index ae8181693..6bd24214d 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -1620,7 +1620,7 @@ static void SaveMobjThinker(const thinker_t *th, const UINT8 type) diff2 |= MD2_SPRITEYSCALE; if (mobj->spritexoffset) diff2 |= MD2_SPRITEXOFFSET; - + if (mobj->floorspriteslope) { pslope_t *slope = mobj->floorspriteslope; if (slope->zangle || slope->zdelta || slope->xydirection @@ -2823,7 +2823,7 @@ static thinker_t* LoadMobjThinker(actionf_p1 thinker) mobj->spriteyoffset = READFIXED(save_p); if (diff2 & MD2_FLOORSPRITESLOPE) { - pslope_t *slope = mobj->floorspriteslope; + pslope_t *slope = (pslope_t *)P_CreateFloorSpriteSlope(mobj); slope->zdelta = READFIXED(save_p); slope->zangle = READANGLE(save_p); From b4294220e5113efb45869efdbfe416572142ed8e Mon Sep 17 00:00:00 2001 From: Jaime Passos Date: Wed, 14 Oct 2020 14:08:25 -0300 Subject: [PATCH 0184/1080] Fix a crash in R_CalculateSlopeVectors called from R_RenderFloorSplat --- src/r_splats.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/r_splats.c b/src/r_splats.c index 541221841..ce45446d0 100644 --- a/src/r_splats.c +++ b/src/r_splats.c @@ -228,6 +228,9 @@ void R_RenderFloorSplat(floorsplat_t *pSplat, vector2_t *verts, vissprite_t *vis // Lactozilla: I don't know what I'm doing if (pSplat->tilted) { + ds_sup = &ds_su[0]; + ds_svp = &ds_sv[0]; + ds_szp = &ds_sz[0]; R_CalculateSlopeVectors(&pSplat->slope, viewx, viewy, viewz, pSplat->xscale, pSplat->yscale, -pSplat->verts[0].x, pSplat->verts[0].y, viewangle, pSplat->angle, 1.0f); spanfunctype = SPANDRAWFUNC_TILTEDSPRITE; } From bf8bb383ab1a39240c0a3e34ec8caa7c1a5bbdac Mon Sep 17 00:00:00 2001 From: Jaime Passos Date: Wed, 14 Oct 2020 21:20:37 -0300 Subject: [PATCH 0185/1080] Simplify the floor splat clipping code a bit --- src/r_splats.c | 59 +++++++++++++++++++++++++++----------------------- src/r_splats.h | 1 - src/r_things.c | 4 +++- 3 files changed, 35 insertions(+), 29 deletions(-) diff --git a/src/r_splats.c b/src/r_splats.c index ce45446d0..efcd6ea98 100644 --- a/src/r_splats.c +++ b/src/r_splats.c @@ -24,8 +24,6 @@ struct rastery_s *prastertab; // for ASM code static struct rastery_s rastertab[MAXVIDHEIGHT]; static void prepare_rastertab(void); -UINT8 ds_splatclip[MAXVIDWIDTH]; - // ========================================================================== // FLOOR SPLATS // ========================================================================== @@ -147,7 +145,8 @@ static void rasterize_segment_tex(INT32 x1, INT32 y1, INT32 x2, INT32 y2, INT32 void R_RenderFloorSplat(floorsplat_t *pSplat, vector2_t *verts, vissprite_t *vis) { // rasterizing - INT32 miny = viewheight + 1, maxy = 0, y, x1, ry1, x2, y2, i, xclip; + INT32 miny = viewheight + 1, maxy = 0; + INT32 y, x1, ry1, x2, y2, i; fixed_t offsetx = 0, offsety = 0; fixed_t step; @@ -289,6 +288,8 @@ void R_RenderFloorSplat(floorsplat_t *pSplat, vector2_t *verts, vissprite_t *vis for (y = miny; y <= maxy; y++) { + boolean cliptab[MAXVIDWIDTH+1]; + x1 = rastertab[y].minx>>FRACBITS; x2 = rastertab[y].maxx>>FRACBITS; @@ -304,8 +305,34 @@ void R_RenderFloorSplat(floorsplat_t *pSplat, vector2_t *verts, vissprite_t *vis if (x1 < 0) x1 = 0; - if (x2 >= vid.width) - x2 = vid.width - 1; + if (x2 >= viewwidth) + x2 = viewwidth - 1; + + if (x1 >= viewwidth || x2 < 0) + continue; + + for (i = x1; i <= x2; i++) + cliptab[i] = (y >= mfloorclip[i]); + + // clip left + while (cliptab[x1]) + { + x1++; + if (x1 >= viewwidth) + break; + } + + // clip right + i = x2; + + while (i > x1) + { + if (cliptab[i]) + x2 = i-1; + i--; + if (i < 0) + break; + } ds_colormap = vis->colormap; ds_translation = R_GetSpriteTranslation(vis); @@ -320,28 +347,6 @@ void R_RenderFloorSplat(floorsplat_t *pSplat, vector2_t *verts, vissprite_t *vis ds_colormap = &vis->extra_colormap->colormap[ds_colormap - colormaps]; } - R_ClipVisSprite(vis, x1-1, x2+1, drawsegs, NULL); - memset(ds_splatclip, 0, sizeof(ds_splatclip)); - - if (x2 >= x1 && x1 < viewwidth && x1 >= 0) - { - for (xclip = x1; xclip <= x2; xclip++) - { - if (y >= mfloorclip[xclip]) - ds_splatclip[xclip] = 1; - } - } - - while (ds_splatclip[x1]) - x1++; - i = x2; - while (i > x1) - { - if (ds_splatclip[i]) - x2 = i-1; - i--; - } - if (!pSplat->tilted) { angle = (viewangle + pSplat->angle)>>ANGLETOFINESHIFT; diff --git a/src/r_splats.h b/src/r_splats.h index b0707e95b..ba5052fc9 100644 --- a/src/r_splats.h +++ b/src/r_splats.h @@ -44,7 +44,6 @@ typedef struct floorsplat_s } floorsplat_t; void R_RenderFloorSplat(floorsplat_t *pSplat, vector2_t *verts, vissprite_t *vis); -extern UINT8 ds_splatclip[MAXVIDWIDTH]; #endif #endif /*__R_SPLATS_H__*/ diff --git a/src/r_things.c b/src/r_things.c index e8c00b86b..6c1d8a879 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -3213,7 +3213,9 @@ void R_ClipSprites(drawseg_t* dsstart, portal_t* portal) for (; clippedvissprites < visspritecount; clippedvissprites++) { vissprite_t *spr = R_GetVisSprite(clippedvissprites); - R_ClipVisSprite(spr, spr->x1, spr->x2, dsstart, portal); + INT32 x1 = (spr->cut & SC_SPLAT) ? 0 : spr->x1; + INT32 x2 = (spr->cut & SC_SPLAT) ? viewwidth : spr->x2; + R_ClipVisSprite(spr, x1, x2, dsstart, portal); } } From 3bace37a25b881a173e49716c11f59eeccd67693 Mon Sep 17 00:00:00 2001 From: Jaime Passos Date: Wed, 14 Oct 2020 21:26:23 -0300 Subject: [PATCH 0186/1080] Don't project if rot_y is less than a single fracunit --- src/r_things.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/r_things.c b/src/r_things.c index 6c1d8a879..5fd4e27ad 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -2970,7 +2970,7 @@ static void R_DrawVisSplat(vissprite_t *spr) rot_y = FixedMul(tr_x, viewcos) + FixedMul(tr_y, viewsin); rot_z = v3d->z - viewz; - if (!rot_y || rot_y < FixedDiv(4*FRACUNIT, splat.scale)) + if (rot_y < FRACUNIT) return; // note: y from view above of map, is distance far away From 50bd8abc78d4cf1dfe69c17bf54dc0d301a8d22a Mon Sep 17 00:00:00 2001 From: Jaime Passos Date: Thu, 15 Oct 2020 00:03:32 -0300 Subject: [PATCH 0187/1080] Fix precipitation --- src/p_mobj.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/p_mobj.h b/src/p_mobj.h index 7eb47112c..3f03e6ada 100644 --- a/src/p_mobj.h +++ b/src/p_mobj.h @@ -415,6 +415,7 @@ typedef struct precipmobj_s UINT32 renderflags; // render flags fixed_t spritexscale, spriteyscale; fixed_t spritexoffset, spriteyoffset; + struct pslope_s *floorspriteslope; // The slope that the floorsprite is rotated by struct mprecipsecnode_s *touching_sectorlist; // a linked list of sectors where this object appears From 4c59f8c615334d6b5a01801949d3c2d57a983568 Mon Sep 17 00:00:00 2001 From: Jaime Passos Date: Thu, 15 Oct 2020 01:14:16 -0300 Subject: [PATCH 0188/1080] Fix OpenGL GIF recording crashing with gif_localcolortable disabled --- src/m_anigif.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/m_anigif.c b/src/m_anigif.c index f30effb9b..85118790b 100644 --- a/src/m_anigif.c +++ b/src/m_anigif.c @@ -507,7 +507,7 @@ static void GIF_rgbconvert(UINT8 *linear, UINT8 *scr) size_t src = 0, dest = 0; size_t size = (vid.width * vid.height * 3); - InitColorLUT(&gif_colorlookup, gif_framepalette, true); + InitColorLUT(&gif_colorlookup, (gif_localcolortable) ? gif_framepalette : gif_headerpalette, true); while (src < size) { From bc3ac7615f6c62a98fe44139b45efa652f8e8505 Mon Sep 17 00:00:00 2001 From: Jaime Passos Date: Thu, 15 Oct 2020 11:32:21 -0300 Subject: [PATCH 0189/1080] Remove unnecessarily duplicated code in R_GetSpriteTranslation --- src/r_things.c | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/src/r_things.c b/src/r_things.c index 5fd4e27ad..266fc28ef 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -761,28 +761,6 @@ UINT8 *R_GetSpriteTranslation(vissprite_t *vis) else return R_GetTranslationColormap(TC_BOSS, 0, GTC_CACHE); } - else if (vis->mobj->color && vis->transmap) // Color mapping - { - if (!(vis->cut & SC_PRECIP) && vis->mobj->colorized) - return R_GetTranslationColormap(TC_RAINBOW, vis->mobj->color, GTC_CACHE); - else if (!(vis->cut & SC_PRECIP) - && vis->mobj->player && vis->mobj->player->dashmode >= DASHMODE_THRESHOLD - && (vis->mobj->player->charflags & SF_DASHMODE) - && ((leveltime/2) & 1)) - { - if (vis->mobj->player->charflags & SF_MACHINE) - return R_GetTranslationColormap(TC_DASHMODE, 0, GTC_CACHE); - else - return R_GetTranslationColormap(TC_RAINBOW, vis->mobj->color, GTC_CACHE); - } - else if (!(vis->cut & SC_PRECIP) && vis->mobj->skin && vis->mobj->sprite == SPR_PLAY) // MT_GHOST LOOKS LIKE A PLAYER SO USE THE PLAYER TRANSLATION TABLES. >_> - { - size_t skinnum = (skin_t*)vis->mobj->skin-skins; - return R_GetTranslationColormap((INT32)skinnum, vis->mobj->color, GTC_CACHE); - } - else // Use the defaults - return R_GetTranslationColormap(TC_DEFAULT, vis->mobj->color, GTC_CACHE); - } else if (vis->mobj->color) { // New colormap stuff for skins Tails 06-07-2002 From bf9ed39ec3ba4d236551a38ea9f00505dc4eb55f Mon Sep 17 00:00:00 2001 From: Jaime Passos Date: Thu, 15 Oct 2020 14:05:18 -0300 Subject: [PATCH 0190/1080] Change vis->transmap statement --- src/r_things.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/r_things.c b/src/r_things.c index 266fc28ef..444b671d2 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -2007,24 +2007,19 @@ static void R_ProjectSprite(mobj_t *thing) vis->scale += FixedMul(scalestep, spriteyscale) * (vis->x1 - x1); } - vis->patch = patch; - -// -// determine the colormap (lightlevel & special effects) -// - vis->transmap = NULL; - - // specific translucency - if (!cv_translucency.value) - ; // no translucency - else if (trans) + if (cv_translucency.value && trans) vis->transmap = transtables + ((trans-1)<transmap = NULL; if (R_ThingIsFullBright(oldthing) || oldthing->flags2 & MF2_SHADOW || thing->flags2 & MF2_SHADOW) vis->cut |= SC_FULLBRIGHT; else if (R_ThingIsFullDark(oldthing)) vis->cut |= SC_FULLDARK; + // + // determine the colormap (lightlevel & special effects) + // if (vis->cut & SC_FULLBRIGHT && (!vis->extra_colormap || !(vis->extra_colormap->flags & CMF_FADEFULLBRIGHTSPRITES))) { @@ -2049,6 +2044,8 @@ static void R_ProjectSprite(mobj_t *thing) if (splat) vis->cut |= SC_SPLAT; // I like ya cut g + vis->patch = patch; + if (thing->subsector->sector->numlights && !(shadowdraw || splat)) R_SplitSprite(vis); From 060c25c14d730590590cd378dcebea1ceda55e1b Mon Sep 17 00:00:00 2001 From: Jaime Passos Date: Thu, 15 Oct 2020 14:12:19 -0300 Subject: [PATCH 0191/1080] [Software floor sprites] Set the colormap and translation outside of the loop --- src/r_splats.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/r_splats.c b/src/r_splats.c index efcd6ea98..10cf1127c 100644 --- a/src/r_splats.c +++ b/src/r_splats.c @@ -251,7 +251,18 @@ void R_RenderFloorSplat(floorsplat_t *pSplat, vector2_t *verts, vissprite_t *vis } } - ds_transmap = NULL; + ds_colormap = vis->colormap; + ds_translation = R_GetSpriteTranslation(vis); + if (ds_translation == NULL) + ds_translation = colormaps; + + if (vis->extra_colormap) + { + if (!ds_colormap) + ds_colormap = vis->extra_colormap->colormap; + else + ds_colormap = &vis->extra_colormap->colormap[ds_colormap - colormaps]; + } if (vis->transmap) { @@ -262,6 +273,8 @@ void R_RenderFloorSplat(floorsplat_t *pSplat, vector2_t *verts, vissprite_t *vis else spanfunctype = SPANDRAWFUNC_TRANSSPRITE; } + else + ds_transmap = NULL; if (ds_powersoftwo) spanfunc = spanfuncs[spanfunctype]; @@ -334,19 +347,6 @@ void R_RenderFloorSplat(floorsplat_t *pSplat, vector2_t *verts, vissprite_t *vis break; } - ds_colormap = vis->colormap; - ds_translation = R_GetSpriteTranslation(vis); - if (ds_translation == NULL) - ds_translation = colormaps; - - if (vis->extra_colormap) - { - if (!ds_colormap) - ds_colormap = vis->extra_colormap->colormap; - else - ds_colormap = &vis->extra_colormap->colormap[ds_colormap - colormaps]; - } - if (!pSplat->tilted) { angle = (viewangle + pSplat->angle)>>ANGLETOFINESHIFT; From 70ada935ec3e58111c1e0635912eb2d826d1d716 Mon Sep 17 00:00:00 2001 From: Jaime Passos Date: Thu, 15 Oct 2020 14:31:16 -0300 Subject: [PATCH 0192/1080] Don't free PU_HWRCACHE and PU_HWRCACHE_UNLOCKED memory tags in HWR_ClearAllTextures. Probably fixes a random annoying crash around that function. (I was also suspecting renderer switching was doing other slightly weird stuff.) --- src/hardware/hw_cache.c | 5 ----- src/hardware/hw_glob.h | 2 -- src/hardware/hw_main.c | 50 ++++++++++++++++++++++++++++++----------- src/hardware/hw_main.h | 4 ++++ src/p_setup.c | 29 ++---------------------- 5 files changed, 43 insertions(+), 47 deletions(-) diff --git a/src/hardware/hw_cache.c b/src/hardware/hw_cache.c index 39c06fa0c..85dabbcec 100644 --- a/src/hardware/hw_cache.c +++ b/src/hardware/hw_cache.c @@ -674,11 +674,6 @@ void HWR_ClearAllTextures(void) // free references to the textures HWD.pfnClearMipMapCache(); - // free all hardware-converted graphics cached in the heap - // our gool is only the textures since user of the texture is the texture cache - Z_FreeTag(PU_HWRCACHE); - Z_FreeTag(PU_HWRCACHE_UNLOCKED); - // Alam: free the Z_Blocks before freeing it's users HWR_FreePatchCache(true); } diff --git a/src/hardware/hw_glob.h b/src/hardware/hw_glob.h index 6a9bb257c..112b241ef 100644 --- a/src/hardware/hw_glob.h +++ b/src/hardware/hw_glob.h @@ -108,8 +108,6 @@ void HWR_InitMapTextures(void); void HWR_LoadMapTextures(size_t pnumtextures); void HWR_FreeMapTextures(void); -extern boolean gl_maptexturesloaded; - patch_t *HWR_GetCachedGLPatchPwad(UINT16 wad, UINT16 lump); patch_t *HWR_GetCachedGLPatch(lumpnum_t lumpnum); diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 948045df3..89610a8d7 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -163,9 +163,11 @@ int rs_hw_numcolors = 0; int rs_hw_batchsorttime = 0; int rs_hw_batchdrawtime = 0; +boolean gl_init = false; +boolean gl_maploaded = false; +boolean gl_sessioncommandsadded = false; boolean gl_shadersavailable = true; - // ========================================================================== // Lighting // ========================================================================== @@ -6113,6 +6115,33 @@ void HWR_RenderPlayerView(INT32 viewnumber, player_t *player) HWD.pfnGClipRect(0, 0, vid.width, vid.height, NZCLIP_PLANE); } +void HWR_LoadLevel(void) +{ + // Lactozilla (December 8, 2019) + // Level setup used to free EVERY mipmap from memory. + // Even mipmaps that aren't related to level textures. + // Presumably, the hardware render code used to store textures as level data. + // Meaning, they had memory allocated and marked with the PU_LEVEL tag. + // Level textures are only reloaded after R_LoadTextures, which is + // when the texture list is loaded. + + // Sal: Unfortunately, NOT freeing them causes the dreaded Color Bug. + HWR_FreeColormapCache(); + +#ifdef ALAM_LIGHTING + // BP: reset light between levels (we draw preview frame lights on current frame) + HWR_ResetLights(); +#endif + + HWR_CreatePlanePolygons((INT32)numnodes - 1); + + // Build the sky dome + HWR_ClearSkyDome(); + HWR_BuildSkyDome(); + + gl_maploaded = true; +} + // ========================================================================== // 3D ENGINE COMMANDS // ========================================================================== @@ -6206,13 +6235,10 @@ void HWR_AddCommands(void) void HWR_AddSessionCommands(void) { - static boolean alreadycalled = false; - if (alreadycalled) + if (gl_sessioncommandsadded) return; - CV_RegisterVar(&cv_glanisotropicmode); - - alreadycalled = true; + gl_sessioncommandsadded = true; } // -------------------------------------------------------------------------- @@ -6220,10 +6246,7 @@ void HWR_AddSessionCommands(void) // -------------------------------------------------------------------------- void HWR_Startup(void) { - static boolean startupdone = false; - - // do this once - if (!startupdone) + if (!gl_init) { INT32 i; CONS_Printf("HWR_Startup()...\n"); @@ -6246,7 +6269,7 @@ void HWR_Startup(void) if (rendermode == render_opengl) textureformat = patchformat = GL_TEXFMT_RGBA; - startupdone = true; + gl_init = true; } // -------------------------------------------------------------------------- @@ -6255,7 +6278,8 @@ void HWR_Startup(void) void HWR_Switch(void) { // Add session commands - HWR_AddSessionCommands(); + if (!gl_sessioncommandsadded) + HWR_AddSessionCommands(); // Set special states from CVARs HWD.pfnSetSpecialState(HWD_SET_TEXTUREFILTERMODE, cv_glfiltermode.value); @@ -6266,7 +6290,7 @@ void HWR_Switch(void) HWR_LoadMapTextures(numtextures); // Create plane polygons - if (gamestate == GS_LEVEL || (gamestate == GS_TITLESCREEN && titlemapinaction)) + if (!gl_maploaded && (gamestate == GS_LEVEL || (gamestate == GS_TITLESCREEN && titlemapinaction))) HWR_LoadLevel(); } diff --git a/src/hardware/hw_main.h b/src/hardware/hw_main.h index e3c795b22..381d7b0d7 100644 --- a/src/hardware/hw_main.h +++ b/src/hardware/hw_main.h @@ -123,6 +123,10 @@ extern int rs_hw_numcolors; extern int rs_hw_batchsorttime; extern int rs_hw_batchdrawtime; +extern boolean gl_init; +extern boolean gl_maploaded; +extern boolean gl_maptexturesloaded; +extern boolean gl_sessioncommandsadded; extern boolean gl_shadersavailable; #endif diff --git a/src/p_setup.c b/src/p_setup.c index 349b0582d..e96177dd9 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -4144,6 +4144,8 @@ boolean P_LoadLevel(boolean fromnetsave) P_SpawnPrecipitation(); #ifdef HWRENDER // not win32 only 19990829 by Kin + gl_maploaded = false; + // Lactozilla: Free extrasubsectors regardless of renderer. HWR_FreeExtraSubsectors(); @@ -4231,33 +4233,6 @@ boolean P_LoadLevel(boolean fromnetsave) return true; } -#ifdef HWRENDER -void HWR_LoadLevel(void) -{ - // Lactozilla (December 8, 2019) - // Level setup used to free EVERY mipmap from memory. - // Even mipmaps that aren't related to level textures. - // Presumably, the hardware render code used to store textures as level data. - // Meaning, they had memory allocated and marked with the PU_LEVEL tag. - // Level textures are only reloaded after R_LoadTextures, which is - // when the texture list is loaded. - - // Sal: Unfortunately, NOT freeing them causes the dreaded Color Bug. - HWR_FreeColormapCache(); - -#ifdef ALAM_LIGHTING - // BP: reset light between levels (we draw preview frame lights on current frame) - HWR_ResetLights(); -#endif - - HWR_CreatePlanePolygons((INT32)numnodes - 1); - - // Build the sky dome - HWR_ClearSkyDome(); - HWR_BuildSkyDome(); -} -#endif - // // P_RunSOC // From 4b0725f36f2f94af90206672638e6dd008de3502 Mon Sep 17 00:00:00 2001 From: James R Date: Thu, 15 Oct 2020 16:17:51 -0700 Subject: [PATCH 0193/1080] Use FIELDFROM in lua polyobject code --- src/lua_polyobjlib.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lua_polyobjlib.c b/src/lua_polyobjlib.c index c4dfa8ae4..365d97056 100644 --- a/src/lua_polyobjlib.c +++ b/src/lua_polyobjlib.c @@ -99,7 +99,7 @@ static int polyobjvertices_get(lua_State *L) } } - numofverts = (size_t)(*(size_t *)(((size_t)polyverts) - (offsetof(polyobj_t, vertices) - offsetof(polyobj_t, numVertices)))); + numofverts = *(size_t *)FIELDFROM (polyobj_t, polyverts, vertices,/* -> */numVertices); if (!numofverts) return luaL_error(L, "no vertices found!"); @@ -120,7 +120,7 @@ static int polyobjvertices_num(lua_State *L) if (!polyverts || !(*polyverts)) return luaL_error(L, "accessed polyobj_t.vertices doesn't exist anymore."); - numofverts = (size_t)(*(size_t *)(((size_t)polyverts) - (offsetof(polyobj_t, vertices) - offsetof(polyobj_t, numVertices)))); + numofverts = *(size_t *)FIELDFROM (polyobj_t, polyverts, vertices,/* -> */numVertices); lua_pushinteger(L, numofverts); return 1; } @@ -156,7 +156,7 @@ static int polyobjlines_get(lua_State *L) } } - numoflines = (size_t)(*(size_t *)(((size_t)polylines) - (offsetof(polyobj_t, lines) - offsetof(polyobj_t, numLines)))); + numoflines = *(size_t *)FIELDFROM (polyobj_t, polylines, lines,/* -> */numLines); if (!numoflines) return luaL_error(L, "no lines found!"); @@ -177,7 +177,7 @@ static int polyobjlines_num(lua_State *L) if (!polylines || !(*polylines)) return luaL_error(L, "accessed polyobj_t.lines doesn't exist anymore."); - numoflines = (size_t)(*(size_t *)(((size_t)polylines) - (offsetof(polyobj_t, lines) - offsetof(polyobj_t, numLines)))); + numoflines = *(size_t *)FIELDFROM (polyobj_t, polylines, lines,/* -> */numLines); lua_pushinteger(L, numoflines); return 1; } From 00f38d41e5ea67717d8cfcceba52a8ffe6bc8c27 Mon Sep 17 00:00:00 2001 From: GoldenTails Date: Fri, 16 Oct 2020 17:06:13 -0500 Subject: [PATCH 0194/1080] Give the GIF dynamic delay memory to base future delays off of, instead of calculating for the current frame and being jank --- src/m_anigif.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/m_anigif.c b/src/m_anigif.c index 85118790b..0d3206d11 100644 --- a/src/m_anigif.c +++ b/src/m_anigif.c @@ -47,7 +47,8 @@ static RGBA_t *gif_framepalette = NULL; static FILE *gif_out = NULL; static INT32 gif_frames = 0; -static UINT32 gif_prevframems = 0; +static UINT32 gif_prevframeus = 0; // "us" is microseconds +static UINT32 gif_delayus = 0; static UINT8 gif_writeover = 0; @@ -594,16 +595,20 @@ static void GIF_framewrite(void) // screen regions are handled in GIF_lzw { - UINT16 delay; + UINT16 delay = 0; INT32 startline; if (gif_dynamicdelay) { // golden's attempt at creating a "dynamic delay" - float delayf = ceil(100.0f/NEWTICRATE); + UINT16 mingifdelay = 10; // minimum gif delay in milliseconds (keep at 10 because gifs can't get more precise). + gif_delayus += (I_GetTimeMicros() - gif_prevframeus); // increase delay by how much time was spent between last measurement - delay = (UINT16)((I_GetTimeMicros() - gif_prevframems)/10/1000); - if (delay < (int)(delayf)) - delay = (int)(delayf); + if (gif_delayus/1000 >= mingifdelay) // delay is big enough to be able to effect gif frame delay? + { + int frames = (gif_delayus/1000) / mingifdelay; // get amount of frames to delay. + delay = frames; // set the delay to delay that amount of frames. + gif_delayus -= frames*(mingifdelay*1000); // remove frames by the amount of milliseconds they take. don't reset to 0, the microseconds help consistency. + } } else { @@ -690,7 +695,7 @@ static void GIF_framewrite(void) } fwrite(gifframe_data, 1, (p - gifframe_data), gif_out); ++gif_frames; - gif_prevframems = I_GetTimeMicros(); + gif_prevframeus = I_GetTimeMicros(); } @@ -718,7 +723,8 @@ INT32 GIF_open(const char *filename) GIF_headwrite(); gif_frames = 0; - gif_prevframems = I_GetTimeMicros(); + gif_prevframeus = I_GetTimeMicros(); + gif_delayus = 0; return 1; } From f602944efd7b789ccb94d5eccaeae287a7e80493 Mon Sep 17 00:00:00 2001 From: Zippy_Zolton Date: Sat, 17 Oct 2020 15:51:22 -0500 Subject: [PATCH 0195/1080] titlecard --- src/w_wad.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/w_wad.c b/src/w_wad.c index 9d8adaabd..37dcf5847 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -2099,6 +2099,7 @@ int W_VerifyNMUSlumps(const char *filename) {"RESULT", 6}, // Used in intermission for competitive modes, above too :3 {"RACE", 4}, // Race mode graphics, 321go {"M_", 2}, // Menu stuff + {"LT", 2}, // Titlecard changes {"MINICAPS", 8}, // NiGHTS graphics here and below {"BLUESTAT", 8}, // Sphere status From 7941a5fb6319e5a330eb958b768d6830d975dd20 Mon Sep 17 00:00:00 2001 From: Hannu Hanhi Date: Sat, 17 Oct 2020 14:35:28 +0300 Subject: [PATCH 0196/1080] R_FindPlane optimization --- src/r_plane.c | 54 ++++++++++++++++++++++++++++++--------------------- src/r_plane.h | 5 ++++- 2 files changed, 36 insertions(+), 23 deletions(-) diff --git a/src/r_plane.c b/src/r_plane.c index 6c238896c..9d36c07dc 100644 --- a/src/r_plane.c +++ b/src/r_plane.c @@ -60,7 +60,7 @@ INT32 numffloors; //SoM: 3/23/2000: Boom visplane hashing routine. #define visplane_hash(picnum,lightlevel,height) \ - ((unsigned)((picnum)*3+(lightlevel)+(height)*7) & (MAXVISPLANES-1)) + ((unsigned)((picnum)*3+(lightlevel)+(height)*7) & VISPLANEHASHMASK) //SoM: 3/23/2000: Use boom opening limit removal size_t maxopenings; @@ -380,28 +380,30 @@ visplane_t *R_FindPlane(fixed_t height, INT32 picnum, INT32 lightlevel, lightlevel = 0; } - // New visplane algorithm uses hash table - hash = visplane_hash(picnum, lightlevel, height); - - for (check = visplanes[hash]; check; check = check->next) + if (!pfloor) { - if (check->polyobj && pfloor) - continue; - if (polyobj != check->polyobj) - continue; - if (height == check->height && picnum == check->picnum - && lightlevel == check->lightlevel - && xoff == check->xoffs && yoff == check->yoffs - && planecolormap == check->extra_colormap - && !pfloor && !check->ffloor - && check->viewx == viewx && check->viewy == viewy && check->viewz == viewz - && check->viewangle == viewangle - && check->plangle == plangle - && check->slope == slope) + hash = visplane_hash(picnum, lightlevel, height); + for (check = visplanes[hash]; check; check = check->next) { - return check; + if (polyobj != check->polyobj) + continue; + if (height == check->height && picnum == check->picnum + && lightlevel == check->lightlevel + && xoff == check->xoffs && yoff == check->yoffs + && planecolormap == check->extra_colormap + && check->viewx == viewx && check->viewy == viewy && check->viewz == viewz + && check->viewangle == viewangle + && check->plangle == plangle + && check->slope == slope) + { + return check; + } } } + else + { + hash = MAXVISPLANES - 1; + } check = new_visplane(hash); @@ -471,9 +473,17 @@ visplane_t *R_CheckPlane(visplane_t *pl, INT32 start, INT32 stop) } else /* Cannot use existing plane; create a new one */ { - unsigned hash = - visplane_hash(pl->picnum, pl->lightlevel, pl->height); - visplane_t *new_pl = new_visplane(hash); + visplane_t *new_pl; + if (pl->ffloor) + { + new_pl = new_visplane(MAXVISPLANES - 1); + } + else + { + unsigned hash = + visplane_hash(pl->picnum, pl->lightlevel, pl->height); + new_pl = new_visplane(hash); + } new_pl->height = pl->height; new_pl->picnum = pl->picnum; diff --git a/src/r_plane.h b/src/r_plane.h index 15f7f07f3..8d5ce9ee4 100644 --- a/src/r_plane.h +++ b/src/r_plane.h @@ -19,7 +19,10 @@ #include "r_textures.h" #include "p_polyobj.h" -#define MAXVISPLANES 512 +#define VISPLANEHASHBITS 9 +#define VISPLANEHASHMASK ((1< Date: Sat, 17 Oct 2020 20:13:29 -0500 Subject: [PATCH 0197/1080] Credits Changes --- src/f_finale.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/f_finale.c b/src/f_finale.c index 57f8a8712..1c5168396 100644 --- a/src/f_finale.c +++ b/src/f_finale.c @@ -1119,6 +1119,7 @@ static const char *credits[] = { "\"Arrietty\"", "Ryan \"Blaze Hedgehog\" Bloom", "Graeme P. \"SuperPhanto\" Caldwell", // for the new brak render + "\"Fighter_Builder\"", // for the CEZ3 button debris "\"ChrispyPixels\"", "Paul \"Boinciel\" Clempson", "Sally \"TehRealSalt\" Cochenour", @@ -1207,7 +1208,7 @@ static const char *credits[] = { "\1Testing", "Discord Community Testers", "Hank \"FuriousFox\" Brannock", - "Cody \"SRB2 Playah\" Koester", + "Cody \"Playah\" Koester", "Skye \"OmegaVelocity\" Meredith", "Stephen \"HEDGESMFG\" Moellering", "Rosalie \"ST218\" Molina", From 3ac175660ce2bfb438d8b38267fd8fe3ca76812e Mon Sep 17 00:00:00 2001 From: Jaime Passos Date: Sat, 17 Oct 2020 22:40:49 -0300 Subject: [PATCH 0198/1080] Don't render sprites with negative xscale or yscale in OpenGL --- src/hardware/hw_main.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 89610a8d7..bd4bcf66d 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -4849,6 +4849,9 @@ static void HWR_ProjectSprite(mobj_t *thing) if (!thing) return; + if (thing->spritexscale < 1 || thing->spriteyscale < 1) + return; + dispoffset = thing->info->dispoffset; this_scale = FIXED_TO_FLOAT(thing->scale); From 23e02d17c0709ad96fa87104a410738627b299b5 Mon Sep 17 00:00:00 2001 From: Hannu Hanhi Date: Sun, 18 Oct 2020 21:27:22 +0300 Subject: [PATCH 0199/1080] NPO2 span function optimization --- src/r_draw8_npo2.c | 184 ++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 174 insertions(+), 10 deletions(-) diff --git a/src/r_draw8_npo2.c b/src/r_draw8_npo2.c index 020155694..f82292ea2 100644 --- a/src/r_draw8_npo2.c +++ b/src/r_draw8_npo2.c @@ -23,6 +23,8 @@ void R_DrawSpan_NPO2_8 (void) fixed_t xposition; fixed_t yposition; fixed_t xstep, ystep; + fixed_t x, y; + fixed_t fixedwidth, fixedheight; UINT8 *source; UINT8 *colormap; @@ -41,9 +43,22 @@ void R_DrawSpan_NPO2_8 (void) if (dest+8 > deststop) return; + fixedwidth = ds_flatwidth << FRACBITS; + fixedheight = ds_flatheight << FRACBITS; + + // Fix xposition and yposition if they are out of bounds. + if (xposition < 0) + xposition = fixedwidth - ((UINT32)(fixedwidth - xposition) % fixedwidth); + else if (xposition >= fixedwidth) + xposition %= fixedwidth; + if (yposition < 0) + yposition = fixedheight - ((UINT32)(fixedheight - yposition) % fixedheight); + else if (yposition >= fixedheight) + yposition %= fixedheight; + while (count-- && dest <= deststop) { - fixed_t x = (xposition >> FRACBITS); +/* fixed_t x = (xposition >> FRACBITS); fixed_t y = (yposition >> FRACBITS); // Carefully align all of my Friends. @@ -53,7 +68,26 @@ void R_DrawSpan_NPO2_8 (void) y = ds_flatheight - ((UINT32)(ds_flatheight - y) % ds_flatheight); x %= ds_flatwidth; - y %= ds_flatheight; + y %= ds_flatheight;*/ + + // The loops here keep the texture coordinates within the texture. + // They will rarely iterate multiple times, and are cheaper than a modulo operation, + // even if using libdivide. + if (xstep < 0) // These if statements are hopefully hoisted by the compiler to above this loop + while (xposition < 0) + xposition += fixedwidth; + else + while (xposition >= fixedwidth) + xposition -= fixedwidth; + if (ystep < 0) + while (yposition < 0) + yposition += fixedheight; + else + while (yposition >= fixedheight) + yposition -= fixedheight; + + x = (xposition >> FRACBITS); + y = (yposition >> FRACBITS); *dest++ = colormap[source[((y * ds_flatwidth) + x)]]; xposition += xstep; @@ -668,6 +702,8 @@ void R_DrawSplat_NPO2_8 (void) fixed_t xposition; fixed_t yposition; fixed_t xstep, ystep; + fixed_t x, y; + fixed_t fixedwidth, fixedheight; UINT8 *source; UINT8 *colormap; @@ -684,9 +720,22 @@ void R_DrawSplat_NPO2_8 (void) colormap = ds_colormap; dest = ylookup[ds_y] + columnofs[ds_x1]; + fixedwidth = ds_flatwidth << FRACBITS; + fixedheight = ds_flatheight << FRACBITS; + + // Fix xposition and yposition if they are out of bounds. + if (xposition < 0) + xposition = fixedwidth - ((UINT32)(fixedwidth - xposition) % fixedwidth); + else if (xposition >= fixedwidth) + xposition %= fixedwidth; + if (yposition < 0) + yposition = fixedheight - ((UINT32)(fixedheight - yposition) % fixedheight); + else if (yposition >= fixedheight) + yposition %= fixedheight; + while (count-- && dest <= deststop) { - fixed_t x = (xposition >> FRACBITS); +/* fixed_t x = (xposition >> FRACBITS); fixed_t y = (yposition >> FRACBITS); // Carefully align all of my Friends. @@ -696,8 +745,25 @@ void R_DrawSplat_NPO2_8 (void) y = ds_flatheight - ((UINT32)(ds_flatheight - y) % ds_flatheight); x %= ds_flatwidth; - y %= ds_flatheight; + y %= ds_flatheight;*/ + // The loops here keep the texture coordinates within the texture. + // They will rarely iterate multiple times, and are cheaper than a modulo operation, + // even if using libdivide. + if (xstep < 0) // These if statements are hopefully hoisted by the compiler to above this loop + while (xposition < 0) + xposition += fixedwidth; + else + while (xposition >= fixedwidth) + xposition -= fixedwidth; + if (ystep < 0) + while (yposition < 0) + yposition += fixedheight; + else + while (yposition >= fixedheight) + yposition -= fixedheight; + x = (xposition >> FRACBITS); + y = (yposition >> FRACBITS); val = source[((y * ds_flatwidth) + x)]; if (val != TRANSPARENTPIXEL) *dest = colormap[val]; @@ -715,6 +781,8 @@ void R_DrawTranslucentSplat_NPO2_8 (void) fixed_t xposition; fixed_t yposition; fixed_t xstep, ystep; + fixed_t x, y; + fixed_t fixedwidth, fixedheight; UINT8 *source; UINT8 *colormap; @@ -731,9 +799,22 @@ void R_DrawTranslucentSplat_NPO2_8 (void) colormap = ds_colormap; dest = ylookup[ds_y] + columnofs[ds_x1]; + fixedwidth = ds_flatwidth << FRACBITS; + fixedheight = ds_flatheight << FRACBITS; + + // Fix xposition and yposition if they are out of bounds. + if (xposition < 0) + xposition = fixedwidth - ((UINT32)(fixedwidth - xposition) % fixedwidth); + else if (xposition >= fixedwidth) + xposition %= fixedwidth; + if (yposition < 0) + yposition = fixedheight - ((UINT32)(fixedheight - yposition) % fixedheight); + else if (yposition >= fixedheight) + yposition %= fixedheight; + while (count-- && dest <= deststop) { - fixed_t x = (xposition >> FRACBITS); + /*fixed_t x = (xposition >> FRACBITS); fixed_t y = (yposition >> FRACBITS); // Carefully align all of my Friends. @@ -743,8 +824,26 @@ void R_DrawTranslucentSplat_NPO2_8 (void) y = ds_flatheight - ((UINT32)(ds_flatheight - y) % ds_flatheight); x %= ds_flatwidth; - y %= ds_flatheight; + y %= ds_flatheight;*/ + // The loops here keep the texture coordinates within the texture. + // They will rarely iterate multiple times, and are cheaper than a modulo operation, + // even if using libdivide. + if (xstep < 0) // These if statements are hopefully hoisted by the compiler to above this loop + while (xposition < 0) + xposition += fixedwidth; + else + while (xposition >= fixedwidth) + xposition -= fixedwidth; + if (ystep < 0) + while (yposition < 0) + yposition += fixedheight; + else + while (yposition >= fixedheight) + yposition -= fixedheight; + + x = (xposition >> FRACBITS); + y = (yposition >> FRACBITS); val = source[((y * ds_flatwidth) + x)]; if (val != TRANSPARENTPIXEL) *dest = *(ds_transmap + (colormap[val] << 8) + *dest); @@ -762,6 +861,8 @@ void R_DrawTranslucentSpan_NPO2_8 (void) fixed_t xposition; fixed_t yposition; fixed_t xstep, ystep; + fixed_t x, y; + fixed_t fixedwidth, fixedheight; UINT8 *source; UINT8 *colormap; @@ -778,9 +879,22 @@ void R_DrawTranslucentSpan_NPO2_8 (void) colormap = ds_colormap; dest = ylookup[ds_y] + columnofs[ds_x1]; + fixedwidth = ds_flatwidth << FRACBITS; + fixedheight = ds_flatheight << FRACBITS; + + // Fix xposition and yposition if they are out of bounds. + if (xposition < 0) + xposition = fixedwidth - ((UINT32)(fixedwidth - xposition) % fixedwidth); + else if (xposition >= fixedwidth) + xposition %= fixedwidth; + if (yposition < 0) + yposition = fixedheight - ((UINT32)(fixedheight - yposition) % fixedheight); + else if (yposition >= fixedheight) + yposition %= fixedheight; + while (count-- && dest <= deststop) { - fixed_t x = (xposition >> FRACBITS); + /*fixed_t x = (xposition >> FRACBITS); fixed_t y = (yposition >> FRACBITS); // Carefully align all of my Friends. @@ -790,8 +904,26 @@ void R_DrawTranslucentSpan_NPO2_8 (void) y = ds_flatheight - ((UINT32)(ds_flatheight - y) % ds_flatheight); x %= ds_flatwidth; - y %= ds_flatheight; + y %= ds_flatheight;*/ + // The loops here keep the texture coordinates within the texture. + // They will rarely iterate multiple times, and are cheaper than a modulo operation, + // even if using libdivide. + if (xstep < 0) // These if statements are hopefully hoisted by the compiler to above this loop + while (xposition < 0) + xposition += fixedwidth; + else + while (xposition >= fixedwidth) + xposition -= fixedwidth; + if (ystep < 0) + while (yposition < 0) + yposition += fixedheight; + else + while (yposition >= fixedheight) + yposition -= fixedheight; + + x = (xposition >> FRACBITS); + y = (yposition >> FRACBITS); val = ((y * ds_flatwidth) + x); *dest = *(ds_transmap + (colormap[source[val]] << 8) + *dest); dest++; @@ -806,6 +938,8 @@ void R_DrawTranslucentWaterSpan_NPO2_8(void) fixed_t xposition; fixed_t yposition; fixed_t xstep, ystep; + fixed_t x, y; + fixed_t fixedwidth, fixedheight; UINT8 *source; UINT8 *colormap; @@ -823,9 +957,22 @@ void R_DrawTranslucentWaterSpan_NPO2_8(void) dest = ylookup[ds_y] + columnofs[ds_x1]; dsrc = screens[1] + (ds_y+ds_bgofs)*vid.width + ds_x1; + fixedwidth = ds_flatwidth << FRACBITS; + fixedheight = ds_flatheight << FRACBITS; + + // Fix xposition and yposition if they are out of bounds. + if (xposition < 0) + xposition = fixedwidth - ((UINT32)(fixedwidth - xposition) % fixedwidth); + else if (xposition >= fixedwidth) + xposition %= fixedwidth; + if (yposition < 0) + yposition = fixedheight - ((UINT32)(fixedheight - yposition) % fixedheight); + else if (yposition >= fixedheight) + yposition %= fixedheight; + while (count-- && dest <= deststop) { - fixed_t x = (xposition >> FRACBITS); + /*fixed_t x = (xposition >> FRACBITS); fixed_t y = (yposition >> FRACBITS); // Carefully align all of my Friends. @@ -835,8 +982,25 @@ void R_DrawTranslucentWaterSpan_NPO2_8(void) y = ds_flatheight - ((UINT32)(ds_flatheight - y) % ds_flatheight); x %= ds_flatwidth; - y %= ds_flatheight; + y %= ds_flatheight;*/ + // The loops here keep the texture coordinates within the texture. + // They will rarely iterate multiple times, and are cheaper than a modulo operation, + // even if using libdivide. + if (xstep < 0) // These if statements are hopefully hoisted by the compiler to above this loop + while (xposition < 0) + xposition += fixedwidth; + else + while (xposition >= fixedwidth) + xposition -= fixedwidth; + if (ystep < 0) + while (yposition < 0) + yposition += fixedheight; + else + while (yposition >= fixedheight) + yposition -= fixedheight; + x = (xposition >> FRACBITS); + y = (yposition >> FRACBITS); *dest++ = colormap[*(ds_transmap + (source[((y * ds_flatwidth) + x)] << 8) + *dsrc++)]; xposition += xstep; yposition += ystep; From 382ed1c31e0be865c3f4ca75bb70768b4a3777be Mon Sep 17 00:00:00 2001 From: Hannu Hanhi Date: Sun, 18 Oct 2020 23:04:01 +0300 Subject: [PATCH 0200/1080] Remove leftover commented code from previous commit --- src/r_draw8_npo2.c | 58 ---------------------------------------------- 1 file changed, 58 deletions(-) diff --git a/src/r_draw8_npo2.c b/src/r_draw8_npo2.c index f82292ea2..630b36e6f 100644 --- a/src/r_draw8_npo2.c +++ b/src/r_draw8_npo2.c @@ -58,18 +58,6 @@ void R_DrawSpan_NPO2_8 (void) while (count-- && dest <= deststop) { -/* fixed_t x = (xposition >> FRACBITS); - fixed_t y = (yposition >> FRACBITS); - - // Carefully align all of my Friends. - if (x < 0) - x = ds_flatwidth - ((UINT32)(ds_flatwidth - x) % ds_flatwidth); - if (y < 0) - y = ds_flatheight - ((UINT32)(ds_flatheight - y) % ds_flatheight); - - x %= ds_flatwidth; - y %= ds_flatheight;*/ - // The loops here keep the texture coordinates within the texture. // They will rarely iterate multiple times, and are cheaper than a modulo operation, // even if using libdivide. @@ -735,17 +723,6 @@ void R_DrawSplat_NPO2_8 (void) while (count-- && dest <= deststop) { -/* fixed_t x = (xposition >> FRACBITS); - fixed_t y = (yposition >> FRACBITS); - - // Carefully align all of my Friends. - if (x < 0) - x = ds_flatwidth - ((UINT32)(ds_flatwidth - x) % ds_flatwidth); - if (y < 0) - y = ds_flatheight - ((UINT32)(ds_flatheight - y) % ds_flatheight); - - x %= ds_flatwidth; - y %= ds_flatheight;*/ // The loops here keep the texture coordinates within the texture. // They will rarely iterate multiple times, and are cheaper than a modulo operation, // even if using libdivide. @@ -814,18 +791,6 @@ void R_DrawTranslucentSplat_NPO2_8 (void) while (count-- && dest <= deststop) { - /*fixed_t x = (xposition >> FRACBITS); - fixed_t y = (yposition >> FRACBITS); - - // Carefully align all of my Friends. - if (x < 0) - x = ds_flatwidth - ((UINT32)(ds_flatwidth - x) % ds_flatwidth); - if (y < 0) - y = ds_flatheight - ((UINT32)(ds_flatheight - y) % ds_flatheight); - - x %= ds_flatwidth; - y %= ds_flatheight;*/ - // The loops here keep the texture coordinates within the texture. // They will rarely iterate multiple times, and are cheaper than a modulo operation, // even if using libdivide. @@ -894,18 +859,6 @@ void R_DrawTranslucentSpan_NPO2_8 (void) while (count-- && dest <= deststop) { - /*fixed_t x = (xposition >> FRACBITS); - fixed_t y = (yposition >> FRACBITS); - - // Carefully align all of my Friends. - if (x < 0) - x = ds_flatwidth - ((UINT32)(ds_flatwidth - x) % ds_flatwidth); - if (y < 0) - y = ds_flatheight - ((UINT32)(ds_flatheight - y) % ds_flatheight); - - x %= ds_flatwidth; - y %= ds_flatheight;*/ - // The loops here keep the texture coordinates within the texture. // They will rarely iterate multiple times, and are cheaper than a modulo operation, // even if using libdivide. @@ -972,17 +925,6 @@ void R_DrawTranslucentWaterSpan_NPO2_8(void) while (count-- && dest <= deststop) { - /*fixed_t x = (xposition >> FRACBITS); - fixed_t y = (yposition >> FRACBITS); - - // Carefully align all of my Friends. - if (x < 0) - x = ds_flatwidth - ((UINT32)(ds_flatwidth - x) % ds_flatwidth); - if (y < 0) - y = ds_flatheight - ((UINT32)(ds_flatheight - y) % ds_flatheight); - - x %= ds_flatwidth; - y %= ds_flatheight;*/ // The loops here keep the texture coordinates within the texture. // They will rarely iterate multiple times, and are cheaper than a modulo operation, // even if using libdivide. From 3b79ca4fae6fce10d9a45bbc3fa81e0d66cc9600 Mon Sep 17 00:00:00 2001 From: Zippy_Zolton Date: Sun, 18 Oct 2020 16:00:01 -0500 Subject: [PATCH 0201/1080] Improved text colormaps --- src/console.c | 40 ++++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/src/console.c b/src/console.c index 3eee67bb8..76c46538c 100644 --- a/src/console.c +++ b/src/console.c @@ -359,27 +359,31 @@ static void CON_SetupColormaps(void) for (i = 0; i < (256*15); i++, ++memorysrc) *memorysrc = (UINT8)(i & 0xFF); // remap each color to itself... -#define colset(map, a, b, c) \ +#define colset(map, a, b, c, d, e) \ map[1] = (UINT8)a;\ - map[3] = (UINT8)b;\ - map[9] = (UINT8)c + map[2] = (UINT8)b;\ + map[3] = (UINT8)c;\ + map[8] = (UINT8)d;\ + map[9] = (UINT8)e - colset(magentamap, 177, 178, 184); - colset(yellowmap, 82, 73, 66); - colset(lgreenmap, 97, 98, 106); - colset(bluemap, 146, 147, 155); - colset(redmap, 210, 32, 39); - colset(graymap, 6, 8, 14); - colset(orangemap, 51, 52, 57); - colset(skymap, 129, 130, 133); - colset(purplemap, 160, 161, 163); - colset(aquamap, 120, 121, 123); - colset(peridotmap, 88, 188, 190); - colset(azuremap, 144, 145, 170); - colset(brownmap, 219, 221, 224); - colset(rosymap, 200, 201, 203); - colset(invertmap, 27, 26, 22); + colset(magentamap, 177, 178, 180, 181, 183); + colset(yellowmap, 82, 73, 74, 75, 76); + colset(lgreenmap, 96, 112, 113, 114, 115); + colset(bluemap, 148, 149, 150, 151, 152); + colset(redmap, 33, 34, 35, 37, 39); + colset(graymap, 9, 11, 13, 15, 17); + colset(orangemap, 50, 52, 54, 56, 58); + colset(skymap, 129, 130, 132, 134, 135); + colset(purplemap, 161, 162, 163, 164, 166); + colset(aquamap, 121, 122, 123, 124, 125); + colset(peridotmap, 73, 188, 189, 190, 191); + colset(azuremap, 144, 145, 170, 171, 172); + colset(brownmap, 224, 226, 228, 230, 232); + colset(rosymap, 200, 201, 202, 203, 204); + colset(invertmap, 30, 29, 27, 25, 23); invertmap[26] = (UINT8)3; + invertmap[30] = (UINT8)1; + invertmap[31] = (UINT8)0; #undef colset From 14aec09d1317ef6cdec97352e383a7418dcba976 Mon Sep 17 00:00:00 2001 From: Zippy_Zolton Date: Sun, 18 Oct 2020 16:21:06 -0500 Subject: [PATCH 0202/1080] possibly fixed --- src/console.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/console.c b/src/console.c index 76c46538c..66e04c198 100644 --- a/src/console.c +++ b/src/console.c @@ -360,11 +360,11 @@ static void CON_SetupColormaps(void) *memorysrc = (UINT8)(i & 0xFF); // remap each color to itself... #define colset(map, a, b, c, d, e) \ - map[1] = (UINT8)a;\ + map[0] = (UINT8)a;\ map[2] = (UINT8)b;\ - map[3] = (UINT8)c;\ - map[8] = (UINT8)d;\ - map[9] = (UINT8)e + map[4] = (UINT8)c;\ + map[6] = (UINT8)d;\ + map[8] = (UINT8)e colset(magentamap, 177, 178, 180, 181, 183); colset(yellowmap, 82, 73, 74, 75, 76); From 94cee68d4141ae09453c55fdf4eca4623c286707 Mon Sep 17 00:00:00 2001 From: Zippy_Zolton Date: Sun, 18 Oct 2020 16:41:14 -0500 Subject: [PATCH 0203/1080] Calloc --- src/console.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/console.c b/src/console.c index 66e04c198..b0eb2ce0f 100644 --- a/src/console.c +++ b/src/console.c @@ -333,7 +333,7 @@ static void CONS_backcolor_Change(void) static void CON_SetupColormaps(void) { INT32 i; - UINT8 *memorysrc = (UINT8 *)Z_Malloc((256*15), PU_STATIC, NULL); + UINT8 *memorysrc = (UINT8 *)Z_Calloc((256*15), PU_STATIC, NULL); magentamap = memorysrc; yellowmap = (magentamap+256); From 2403cbd57ba725c92e028d99467ac8828f1f51c5 Mon Sep 17 00:00:00 2001 From: Zippy_Zolton Date: Sun, 18 Oct 2020 17:01:31 -0500 Subject: [PATCH 0204/1080] possibly final --- src/console.c | 49 ++++++++++++++++++++++++++----------------------- 1 file changed, 26 insertions(+), 23 deletions(-) diff --git a/src/console.c b/src/console.c index b0eb2ce0f..8780bf5d2 100644 --- a/src/console.c +++ b/src/console.c @@ -360,30 +360,33 @@ static void CON_SetupColormaps(void) *memorysrc = (UINT8)(i & 0xFF); // remap each color to itself... #define colset(map, a, b, c, d, e) \ - map[0] = (UINT8)a;\ - map[2] = (UINT8)b;\ - map[4] = (UINT8)c;\ - map[6] = (UINT8)d;\ - map[8] = (UINT8)e + map[1] = (UINT8)a;\ + map[3] = (UINT8)b;\ + map[5] = (UINT8)c;\ + map[7] = (UINT8)d;\ + map[9] = (UINT8)e - colset(magentamap, 177, 178, 180, 181, 183); - colset(yellowmap, 82, 73, 74, 75, 76); - colset(lgreenmap, 96, 112, 113, 114, 115); - colset(bluemap, 148, 149, 150, 151, 152); - colset(redmap, 33, 34, 35, 37, 39); - colset(graymap, 9, 11, 13, 15, 17); - colset(orangemap, 50, 52, 54, 56, 58); - colset(skymap, 129, 130, 132, 134, 135); - colset(purplemap, 161, 162, 163, 164, 166); - colset(aquamap, 121, 122, 123, 124, 125); - colset(peridotmap, 73, 188, 189, 190, 191); - colset(azuremap, 144, 145, 170, 171, 172); - colset(brownmap, 224, 226, 228, 230, 232); - colset(rosymap, 200, 201, 202, 203, 204); - colset(invertmap, 30, 29, 27, 25, 23); - invertmap[26] = (UINT8)3; - invertmap[30] = (UINT8)1; - invertmap[31] = (UINT8)0; + colset(magentamap, 178, 179, 181, 182, 184); + colset(yellowmap, 83, 74, 75, 76, 77); + colset(lgreenmap, 97, 113, 114, 115, 116); + colset(bluemap, 149, 150, 151, 152, 153); + colset(redmap, 34, 35, 36, 38, 40); + colset(graymap, 10, 12, 14, 16, 18); + colset(orangemap, 51, 53, 55, 57, 59); + colset(skymap, 130, 131, 133, 135, 136); + colset(purplemap, 162, 163, 164, 165, 167); + colset(aquamap, 122, 123, 124, 125, 126); + colset(peridotmap, 74, 189, 190, 191, 192); + colset(azuremap, 145, 146, 171, 172, 173); + colset(brownmap, 225, 227, 229, 231, 233); + colset(rosymap, 201, 202, 203, 204, 205); + colset(invertmap, 31, 30, 28, 26, 24); + invertmap[27] = (UINT8)6; + invertmap[28] = (UINT8)5; + invertmap[29] = (UINT8)4; + invertmap[30] = (UINT8)3; + invertmap[31] = (UINT8)2; + invertmap[32] = (UINT8)1; #undef colset From e2d686ba42b42f4b1ab902672b5c10ad0f4a5dd2 Mon Sep 17 00:00:00 2001 From: Zippy_Zolton Date: Sun, 18 Oct 2020 17:45:46 -0500 Subject: [PATCH 0205/1080] update --- src/console.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/console.c b/src/console.c index 8780bf5d2..bffa6d18c 100644 --- a/src/console.c +++ b/src/console.c @@ -360,11 +360,11 @@ static void CON_SetupColormaps(void) *memorysrc = (UINT8)(i & 0xFF); // remap each color to itself... #define colset(map, a, b, c, d, e) \ - map[1] = (UINT8)a;\ - map[3] = (UINT8)b;\ - map[5] = (UINT8)c;\ - map[7] = (UINT8)d;\ - map[9] = (UINT8)e + map[1] = (UINT8)a;\ + map[3] = (UINT8)b;\ + map[5] = (UINT8)c;\ + map[9] = (UINT8)d;\ + map[15] = (UINT8)e colset(magentamap, 178, 179, 181, 182, 184); colset(yellowmap, 83, 74, 75, 76, 77); @@ -381,6 +381,7 @@ static void CON_SetupColormaps(void) colset(brownmap, 225, 227, 229, 231, 233); colset(rosymap, 201, 202, 203, 204, 205); colset(invertmap, 31, 30, 28, 26, 24); + invertmap[26] = (UINT8)7; invertmap[27] = (UINT8)6; invertmap[28] = (UINT8)5; invertmap[29] = (UINT8)4; From 5dc90289dc7ced8b21386b78d15dae012ca5d53b Mon Sep 17 00:00:00 2001 From: Zippy_Zolton Date: Sun, 18 Oct 2020 21:59:34 -0500 Subject: [PATCH 0206/1080] thanks goldie --- src/console.c | 68 +++++++++++++++++++++++++++++---------------------- 1 file changed, 39 insertions(+), 29 deletions(-) diff --git a/src/console.c b/src/console.c index bffa6d18c..7927ea925 100644 --- a/src/console.c +++ b/src/console.c @@ -333,7 +333,7 @@ static void CONS_backcolor_Change(void) static void CON_SetupColormaps(void) { INT32 i; - UINT8 *memorysrc = (UINT8 *)Z_Calloc((256*15), PU_STATIC, NULL); + UINT8 *memorysrc = (UINT8 *)Z_Malloc((256*15), PU_STATIC, NULL); magentamap = memorysrc; yellowmap = (magentamap+256); @@ -359,38 +359,48 @@ static void CON_SetupColormaps(void) for (i = 0; i < (256*15); i++, ++memorysrc) *memorysrc = (UINT8)(i & 0xFF); // remap each color to itself... -#define colset(map, a, b, c, d, e) \ - map[1] = (UINT8)a;\ - map[3] = (UINT8)b;\ - map[5] = (UINT8)c;\ - map[9] = (UINT8)d;\ - map[15] = (UINT8)e +#define colset(map, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) \ + map[0x0] = (UINT8)a;\ + map[0x1] = (UINT8)b;\ + map[0x2] = (UINT8)c;\ + map[0x3] = (UINT8)d;\ + map[0x4] = (UINT8)e;\ + map[0x5] = (UINT8)f;\ + map[0x6] = (UINT8)g;\ + map[0x7] = (UINT8)h;\ + map[0x8] = (UINT8)i;\ + map[0x9] = (UINT8)j;\ + map[0xA] = (UINT8)k;\ + map[0xB] = (UINT8)l;\ + map[0xC] = (UINT8)m;\ + map[0xD] = (UINT8)n;\ + map[0xE] = (UINT8)o;\ + map[0xF] = (UINT8)p; - colset(magentamap, 178, 179, 181, 182, 184); - colset(yellowmap, 83, 74, 75, 76, 77); - colset(lgreenmap, 97, 113, 114, 115, 116); - colset(bluemap, 149, 150, 151, 152, 153); - colset(redmap, 34, 35, 36, 38, 40); - colset(graymap, 10, 12, 14, 16, 18); - colset(orangemap, 51, 53, 55, 57, 59); - colset(skymap, 130, 131, 133, 135, 136); - colset(purplemap, 162, 163, 164, 165, 167); - colset(aquamap, 122, 123, 124, 125, 126); - colset(peridotmap, 74, 189, 190, 191, 192); - colset(azuremap, 145, 146, 171, 172, 173); - colset(brownmap, 225, 227, 229, 231, 233); - colset(rosymap, 201, 202, 203, 204, 205); - colset(invertmap, 31, 30, 28, 26, 24); - invertmap[26] = (UINT8)7; - invertmap[27] = (UINT8)6; - invertmap[28] = (UINT8)5; - invertmap[29] = (UINT8)4; - invertmap[30] = (UINT8)3; - invertmap[31] = (UINT8)2; - invertmap[32] = (UINT8)1; + // I tried to make them kinda close to the originals, tell me how I did! ~Golden + + // 0x1 0x3 0x9 0xF + colset(magentamap, 177, 177, 178, 178, 179, 179, 180, 180, 181, 181, 182, 182, 183, 183, 184, 184); + colset(yellowmap, 82, 82, 72, 73, 74, 74, 64, 64, 65, 65, 65, 66, 66, 66, 67, 67); + colset(lgreenmap, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111); + colset(bluemap, 147, 147, 148, 148, 149, 149, 149, 150, 150, 150, 151, 151, 151, 152, 152, 152); + colset(redmap, 210, 210, 211, 211, 32, 32, 33, 33, 34, 34, 35, 35, 37, 37, 38, 38); + colset(graymap, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20); + colset(orangemap, 51, 51, 52, 52, 53, 53, 54, 54, 55, 55, 56, 56, 57, 57, 58, 58); + colset(skymap, 129, 129, 130, 130, 131, 131, 132, 132, 133, 133, 134, 134, 135, 135, 136, 136); + colset(purplemap, 160, 160, 161, 161, 162, 162, 162, 163, 163, 163, 164, 164, 164, 165, 165, 165); + colset(aquamap, 128, 120, 121, 121, 122, 122, 123, 123, 123, 123, 124, 124, 124, 125, 125, 125); + colset(peridotmap, 72, 72, 188, 188, 188, 189, 189, 189, 189, 190, 190, 191, 191, 104, 105, 106); + colset(azuremap, 144, 144, 145, 145, 146, 146, 146, 170, 170, 170, 171, 171, 171, 172, 172, 172); + colset(brownmap, 218, 219, 220, 221, 221, 222, 223, 223, 224, 224, 225, 226, 227, 228, 229, 230); + colset(rosymap, 200, 200, 201, 201, 201, 202, 202, 203, 203, 203, 204, 204, 205, 205, 206, 206); #undef colset + // Yeah just straight up invert it like a normal person + for (i = 0x00; i <= 0x1F; i++) + invertmap[0x1F - i] = i; + // Init back colormap CON_SetupBackColormap(); } From fed2fffaa1debb65e26acab4bddf91fd22d3cb22 Mon Sep 17 00:00:00 2001 From: Zippy_Zolton Date: Sun, 18 Oct 2020 22:52:40 -0500 Subject: [PATCH 0207/1080] better colors --- src/console.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/console.c b/src/console.c index 7927ea925..feffdd338 100644 --- a/src/console.c +++ b/src/console.c @@ -378,22 +378,23 @@ static void CON_SetupColormaps(void) map[0xF] = (UINT8)p; // I tried to make them kinda close to the originals, tell me how I did! ~Golden + // decent but i made most of the colors better thanks for th help :3 // 0x1 0x3 0x9 0xF - colset(magentamap, 177, 177, 178, 178, 179, 179, 180, 180, 181, 181, 182, 182, 183, 183, 184, 184); + colset(magentamap, 176, 176, 177, 177, 178, 178, 179, 179, 180, 180, 181, 181, 182, 182, 183, 183); colset(yellowmap, 82, 82, 72, 73, 74, 74, 64, 64, 65, 65, 65, 66, 66, 66, 67, 67); - colset(lgreenmap, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111); - colset(bluemap, 147, 147, 148, 148, 149, 149, 149, 150, 150, 150, 151, 151, 151, 152, 152, 152); - colset(redmap, 210, 210, 211, 211, 32, 32, 33, 33, 34, 34, 35, 35, 37, 37, 38, 38); + colset(lgreenmap, 96, 96, 97, 97, 98, 98, 99, 99, 100, 100, 101, 101, 102, 102, 103, 103); + colset(bluemap, 144, 144, 145, 145, 146, 146, 146, 147, 147, 147, 148, 148, 148, 149, 149, 149); + colset(redmap, 210, 210, 210, 32, 32, 32, 33, 33, 33, 34, 34, 34, 35, 35, 35, 35); colset(graymap, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20); colset(orangemap, 51, 51, 52, 52, 53, 53, 54, 54, 55, 55, 56, 56, 57, 57, 58, 58); - colset(skymap, 129, 129, 130, 130, 131, 131, 132, 132, 133, 133, 134, 134, 135, 135, 136, 136); - colset(purplemap, 160, 160, 161, 161, 162, 162, 162, 163, 163, 163, 164, 164, 164, 165, 165, 165); - colset(aquamap, 128, 120, 121, 121, 122, 122, 123, 123, 123, 123, 124, 124, 124, 125, 125, 125); - colset(peridotmap, 72, 72, 188, 188, 188, 189, 189, 189, 189, 190, 190, 191, 191, 104, 105, 106); - colset(azuremap, 144, 144, 145, 145, 146, 146, 146, 170, 170, 170, 171, 171, 171, 172, 172, 172); + colset(skymap, 128, 128, 129, 129, 130, 130, 131, 131, 132, 132, 133, 133, 134, 134, 135, 135); + colset(purplemap, 144, 144, 160, 160, 160, 161, 161, 161, 162, 162, 162, 162, 163, 163, 163, 163); + colset(aquamap, 128, 128, 120, 120, 121, 121, 122, 122, 123, 123, 124, 124, 124, 125, 125, 125); + colset(peridotmap, 72, 72, 188, 188, 188, 189, 189, 189, 189, 190, 190, 191, 191, 104, 104, 104); + colset(azuremap, 144, 144, 145, 145, 146, 146, 146, 147, 147, 147, 170, 170, 170, 171, 171, 171); colset(brownmap, 218, 219, 220, 221, 221, 222, 223, 223, 224, 224, 225, 226, 227, 228, 229, 230); - colset(rosymap, 200, 200, 201, 201, 201, 202, 202, 203, 203, 203, 204, 204, 205, 205, 206, 206); + colset(rosymap, 200, 200, 201, 201, 201, 202, 202, 203, 203, 203, 204, 204, 204, 205, 205, 205); #undef colset From e5c891932aaff1ac8c8f285dd57648079c4d878b Mon Sep 17 00:00:00 2001 From: Zippy_Zolton Date: Sun, 18 Oct 2020 23:47:14 -0500 Subject: [PATCH 0208/1080] improvement --- src/console.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/console.c b/src/console.c index feffdd338..0d32eae85 100644 --- a/src/console.c +++ b/src/console.c @@ -381,13 +381,13 @@ static void CON_SetupColormaps(void) // decent but i made most of the colors better thanks for th help :3 // 0x1 0x3 0x9 0xF - colset(magentamap, 176, 176, 177, 177, 178, 178, 179, 179, 180, 180, 181, 181, 182, 182, 183, 183); + colset(magentamap, 177, 177, 178, 178, 179, 179, 180, 180, 181, 181, 182, 182, 183, 183, 184, 184); colset(yellowmap, 82, 82, 72, 73, 74, 74, 64, 64, 65, 65, 65, 66, 66, 66, 67, 67); - colset(lgreenmap, 96, 96, 97, 97, 98, 98, 99, 99, 100, 100, 101, 101, 102, 102, 103, 103); - colset(bluemap, 144, 144, 145, 145, 146, 146, 146, 147, 147, 147, 148, 148, 148, 149, 149, 149); - colset(redmap, 210, 210, 210, 32, 32, 32, 33, 33, 33, 34, 34, 34, 35, 35, 35, 35); + colset(lgreenmap, 97, 97, 98, 98, 99, 99, 100, 100, 101, 101, 102, 102, 103, 103, 104, 104); + colset(bluemap, 147, 147, 147, 148, 148, 148, 149, 149, 149, 150, 150, 151, 151, 151, 152, 152); + colset(redmap, 33, 33, 33, 34, 34, 34, 35, 35, 35, 36, 36, 36, 37, 37, 37, 37); colset(graymap, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20); - colset(orangemap, 51, 51, 52, 52, 53, 53, 54, 54, 55, 55, 56, 56, 57, 57, 58, 58); + colset(orangemap, 52, 52, 53, 53, 54, 54, 55, 55, 56, 56, 57, 57, 58, 58, 59, 59); colset(skymap, 128, 128, 129, 129, 130, 130, 131, 131, 132, 132, 133, 133, 134, 134, 135, 135); colset(purplemap, 144, 144, 160, 160, 160, 161, 161, 161, 162, 162, 162, 162, 163, 163, 163, 163); colset(aquamap, 128, 128, 120, 120, 121, 121, 122, 122, 123, 123, 124, 124, 124, 125, 125, 125); From d633f2495aeb95f40dce30a7be337621f7f79bee Mon Sep 17 00:00:00 2001 From: Zippy_Zolton Date: Mon, 19 Oct 2020 14:12:28 -0500 Subject: [PATCH 0209/1080] red abd bkyue sikbucx --- src/console.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/console.c b/src/console.c index 0d32eae85..7b32889ea 100644 --- a/src/console.c +++ b/src/console.c @@ -384,8 +384,8 @@ static void CON_SetupColormaps(void) colset(magentamap, 177, 177, 178, 178, 179, 179, 180, 180, 181, 181, 182, 182, 183, 183, 184, 184); colset(yellowmap, 82, 82, 72, 73, 74, 74, 64, 64, 65, 65, 65, 66, 66, 66, 67, 67); colset(lgreenmap, 97, 97, 98, 98, 99, 99, 100, 100, 101, 101, 102, 102, 103, 103, 104, 104); - colset(bluemap, 147, 147, 147, 148, 148, 148, 149, 149, 149, 150, 150, 151, 151, 151, 152, 152); - colset(redmap, 33, 33, 33, 34, 34, 34, 35, 35, 35, 36, 36, 36, 37, 37, 37, 37); + colset(bluemap, 147, 147, 147, 148, 148, 148, 149, 149, 150, 150, 151, 151, 152, 152, 153, 153); + colset(redmap, 33, 33, 33, 34, 34, 34, 35, 35, 37, 37, 39, 39, 41, 41, 43, 43); colset(graymap, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20); colset(orangemap, 52, 52, 53, 53, 54, 54, 55, 55, 56, 56, 57, 57, 58, 58, 59, 59); colset(skymap, 128, 128, 129, 129, 130, 130, 131, 131, 132, 132, 133, 133, 134, 134, 135, 135); From dbc149f85a340d9eeff6ce9550505779a008f360 Mon Sep 17 00:00:00 2001 From: Jaime Passos Date: Mon, 19 Oct 2020 17:33:16 -0300 Subject: [PATCH 0210/1080] Remove FLOORSPLATS define --- src/doomdef.h | 3 --- src/r_splats.c | 3 --- src/r_splats.h | 2 -- src/r_things.c | 4 ---- 4 files changed, 12 deletions(-) diff --git a/src/doomdef.h b/src/doomdef.h index 98a22e5ab..d0b7ea0c2 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -641,9 +641,6 @@ extern const char *compdate, *comptime, *comprevision, *compbranch; /// Render flats on walls #define WALLFLATS -/// Floor splats -#define FLOORSPLATS - /// Maintain compatibility with older 2.2 demos #define OLD22DEMOCOMPAT diff --git a/src/r_splats.c b/src/r_splats.c index 10cf1127c..c4074f3d1 100644 --- a/src/r_splats.c +++ b/src/r_splats.c @@ -20,7 +20,6 @@ struct rastery_s *prastertab; // for ASM code -#ifdef FLOORSPLATS static struct rastery_s rastertab[MAXVIDHEIGHT]; static void prepare_rastertab(void); @@ -412,5 +411,3 @@ static void prepare_rastertab(void) rastertab[i].maxx = INT32_MIN; } } - -#endif // FLOORSPLATS diff --git a/src/r_splats.h b/src/r_splats.h index ba5052fc9..6ee8d5c6f 100644 --- a/src/r_splats.h +++ b/src/r_splats.h @@ -28,7 +28,6 @@ struct rastery_s }; extern struct rastery_s *prastertab; // for ASM code -#ifdef FLOORSPLATS typedef struct floorsplat_s { UINT16 *pic; @@ -44,6 +43,5 @@ typedef struct floorsplat_s } floorsplat_t; void R_RenderFloorSplat(floorsplat_t *pSplat, vector2_t *verts, vissprite_t *vis); -#endif #endif /*__R_SPLATS_H__*/ diff --git a/src/r_things.c b/src/r_things.c index 444b671d2..1a2061cec 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -2769,7 +2769,6 @@ void R_InitDrawNodes(void) static void R_DrawVisSplat(vissprite_t *spr) { -#ifdef FLOORSPLATS floorsplat_t splat; fixed_t tr_x, tr_y, rot_x, rot_y, rot_z; @@ -2958,9 +2957,6 @@ static void R_DrawVisSplat(vissprite_t *spr) } R_RenderFloorSplat(&splat, v2d, spr); -#else - (void)spr; -#endif } // From a21685812fb641ad23d731f9495f20b6a7aef4af Mon Sep 17 00:00:00 2001 From: Jaime Passos Date: Mon, 19 Oct 2020 17:35:49 -0300 Subject: [PATCH 0211/1080] Rename R_DrawVisSplat to R_DrawSplatSprite, move into r_splats.c --- src/r_splats.c | 196 +++++++++++++++++++++++++++++++++++++++++++++++++ src/r_splats.h | 1 + src/r_things.c | 194 +----------------------------------------------- 3 files changed, 198 insertions(+), 193 deletions(-) diff --git a/src/r_splats.c b/src/r_splats.c index c4074f3d1..ddc73e090 100644 --- a/src/r_splats.c +++ b/src/r_splats.c @@ -136,6 +136,202 @@ static void rasterize_segment_tex(INT32 x1, INT32 y1, INT32 x2, INT32 y2, INT32 } } +void R_DrawSplatSprite(vissprite_t *spr) +{ + floorsplat_t splat; + mobj_t *mobj = spr->mobj; + fixed_t tr_x, tr_y, rot_x, rot_y, rot_z; + + vector3_t *v3d; + vector2_t v2d[4]; + vector2_t rotated[4]; + + fixed_t x, y; + fixed_t w, h; + angle_t angle, splatangle; + fixed_t ca, sa; + fixed_t xscale, yscale; + fixed_t xoffset, yoffset; + fixed_t leftoffset, topoffset; + pslope_t *slope = NULL; + INT32 i; + + boolean hflip = (spr->xiscale < 0); + boolean vflip = (spr->cut & SC_VFLIP); + UINT8 flipflags = 0; + + renderflags_t renderflags = spr->renderflags; + + if (hflip) + flipflags |= PICFLAGS_XFLIP; + if (vflip) + flipflags |= PICFLAGS_YFLIP; + + if (!mobj || P_MobjWasRemoved(mobj)) + return; + + Patch_GenerateFlat(spr->patch, flipflags); + splat.pic = spr->patch->flats[flipflags]; + if (splat.pic == NULL) + return; + + splat.mobj = mobj; + splat.width = spr->patch->width; + splat.height = spr->patch->height; + splat.scale = mobj->scale; + + if (mobj->skin && ((skin_t *)mobj->skin)->flags & SF_HIRES) + splat.scale = FixedMul(splat.scale, ((skin_t *)mobj->skin)->highresscale); + + if (spr->rotateflags & SRF_3D || renderflags & RF_NOSPLATBILLBOARD) + splatangle = mobj->angle; + else + splatangle = viewangle; + + if (!(spr->cut & SC_ISROTATED)) + splatangle += mobj->rollangle; + + splat.angle = -splatangle; + splat.angle += ANGLE_90; + + topoffset = spr->spriteyoffset; + leftoffset = spr->spritexoffset; + if (hflip) + leftoffset = ((splat.width * FRACUNIT) - leftoffset); + + xscale = spr->spritexscale; + yscale = spr->spriteyscale; + + splat.xscale = FixedMul(splat.scale, xscale); + splat.yscale = FixedMul(splat.scale, yscale); + + xoffset = FixedMul(leftoffset, splat.xscale); + yoffset = FixedMul(topoffset, splat.yscale); + + x = mobj->x; + y = mobj->y; + w = (splat.width * splat.xscale); + h = (splat.height * splat.yscale); + + splat.x = x; + splat.y = y; + splat.z = mobj->z; + splat.tilted = false; + + // Set positions + + // 3--2 + // | | + // 0--1 + + splat.verts[0].x = w - xoffset; + splat.verts[0].y = yoffset; + + splat.verts[1].x = -xoffset; + splat.verts[1].y = yoffset; + + splat.verts[2].x = -xoffset; + splat.verts[2].y = -h + yoffset; + + splat.verts[3].x = w - xoffset; + splat.verts[3].y = -h + yoffset; + + angle = -splat.angle; + ca = FINECOSINE(angle>>ANGLETOFINESHIFT); + sa = FINESINE(angle>>ANGLETOFINESHIFT); + + // Rotate + for (i = 0; i < 4; i++) + { + rotated[i].x = FixedMul(splat.verts[i].x, ca) - FixedMul(splat.verts[i].y, sa); + rotated[i].y = FixedMul(splat.verts[i].x, sa) + FixedMul(splat.verts[i].y, ca); + } + + if (renderflags & (RF_SLOPESPLAT | RF_OBJECTSLOPESPLAT)) + { + pslope_t *standingslope = mobj->standingslope; // The slope that the object is standing on. + + // The slope that was defined for the sprite. + if (renderflags & RF_SLOPESPLAT) + slope = mobj->floorspriteslope; + + if (standingslope && (renderflags & RF_OBJECTSLOPESPLAT)) + slope = standingslope; + + // Set splat as tilted + splat.tilted = (slope != NULL); + } + + if (splat.tilted) + { + // Lactozilla: Just copy the entire slope LMFAOOOO + pslope_t *s = &splat.slope; + + s->o.x = slope->o.x; + s->o.y = slope->o.y; + s->o.z = slope->o.z; + + s->d.x = slope->d.x; + s->d.y = slope->d.y; + + s->normal.x = slope->normal.x; + s->normal.y = slope->normal.y; + s->normal.z = slope->normal.z; + + s->zdelta = slope->zdelta; + s->zangle = slope->zangle; + s->xydirection = slope->xydirection; + + s->next = NULL; + s->flags = 0; + } + + // Translate + for (i = 0; i < 4; i++) + { + tr_x = rotated[i].x + x; + tr_y = rotated[i].y + y; + + if (slope) + { + rot_z = P_GetSlopeZAt(slope, tr_x, tr_y); + splat.verts[i].z = rot_z; + } + else + splat.verts[i].z = splat.z; + + splat.verts[i].x = tr_x; + splat.verts[i].y = tr_y; + } + + for (i = 0; i < 4; i++) + { + v3d = &splat.verts[i]; + + // transform the origin point + tr_x = v3d->x - viewx; + tr_y = v3d->y - viewy; + + // rotation around vertical y axis + rot_x = FixedMul(tr_x, viewsin) - FixedMul(tr_y, viewcos); + rot_y = FixedMul(tr_x, viewcos) + FixedMul(tr_y, viewsin); + rot_z = v3d->z - viewz; + + if (rot_y < FRACUNIT) + return; + + // note: y from view above of map, is distance far away + xscale = FixedDiv(projection, rot_y); + yscale = -FixedDiv(projectiony, rot_y); + + // projection + v2d[i].x = (centerxfrac + FixedMul(rot_x, xscale))>>FRACBITS; + v2d[i].y = (centeryfrac + FixedMul(rot_z, yscale))>>FRACBITS; + } + + R_RenderFloorSplat(&splat, v2d, spr); +} + // -------------------------------------------------------------------------- // Rasterize the four edges of a floor splat polygon, // fill the polygon with linear interpolation, call span drawer for each diff --git a/src/r_splats.h b/src/r_splats.h index 6ee8d5c6f..737a2c703 100644 --- a/src/r_splats.h +++ b/src/r_splats.h @@ -42,6 +42,7 @@ typedef struct floorsplat_s mobj_t *mobj; // Mobj it is tied to } floorsplat_t; +void R_DrawSplatSprite(vissprite_t *spr); void R_RenderFloorSplat(floorsplat_t *pSplat, vector2_t *verts, vissprite_t *vis); #endif /*__R_SPLATS_H__*/ diff --git a/src/r_things.c b/src/r_things.c index 1a2061cec..6562a3ca8 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -2767,198 +2767,6 @@ void R_InitDrawNodes(void) nodebankhead.next = nodebankhead.prev = &nodebankhead; } -static void R_DrawVisSplat(vissprite_t *spr) -{ - floorsplat_t splat; - fixed_t tr_x, tr_y, rot_x, rot_y, rot_z; - - vector3_t *v3d; - vector2_t v2d[4]; - vector2_t rotated[4]; - - fixed_t x, y; - fixed_t w, h; - angle_t angle, splatangle; - fixed_t ca, sa; - fixed_t xscale, yscale; - fixed_t xoffset, yoffset; - fixed_t leftoffset, topoffset; - pslope_t *slope = NULL; - INT32 i; - - boolean hflip = (spr->xiscale < 0); - boolean vflip = (spr->cut & SC_VFLIP); - UINT8 flipflags = 0; - - renderflags_t renderflags = spr->renderflags; - - if (hflip) - flipflags |= PICFLAGS_XFLIP; - if (vflip) - flipflags |= PICFLAGS_YFLIP; - - Patch_GenerateFlat(spr->patch, flipflags); - splat.pic = spr->patch->flats[flipflags]; - if (splat.pic == NULL) - return; - - splat.mobj = spr->mobj; - splat.width = spr->patch->width; - splat.height = spr->patch->height; - splat.scale = spr->mobj->scale; - - if (spr->mobj->skin && ((skin_t *)spr->mobj->skin)->flags & SF_HIRES) - splat.scale = FixedMul(splat.scale, ((skin_t *)spr->mobj->skin)->highresscale); - - if (spr->rotateflags & SRF_3D || renderflags & RF_NOSPLATBILLBOARD) - splatangle = spr->mobj->angle; - else - splatangle = viewangle; - - if (!(spr->cut & SC_ISROTATED)) - splatangle += spr->mobj->rollangle; - - splat.angle = -splatangle; - splat.angle += ANGLE_90; - - topoffset = spr->spriteyoffset; - leftoffset = spr->spritexoffset; - if (hflip) - leftoffset = ((splat.width * FRACUNIT) - leftoffset); - - xscale = spr->spritexscale; - yscale = spr->spriteyscale; - - splat.xscale = FixedMul(splat.scale, xscale); - splat.yscale = FixedMul(splat.scale, yscale); - - xoffset = FixedMul(leftoffset, splat.xscale); - yoffset = FixedMul(topoffset, splat.yscale); - - x = spr->mobj->x; - y = spr->mobj->y; - w = (splat.width * splat.xscale); - h = (splat.height * splat.yscale); - - splat.x = x; - splat.y = y; - splat.z = spr->mobj->z; - splat.tilted = false; - - // Set positions - - // 3--2 - // | | - // 0--1 - - splat.verts[0].x = w - xoffset; - splat.verts[0].y = yoffset; - - splat.verts[1].x = -xoffset; - splat.verts[1].y = yoffset; - - splat.verts[2].x = -xoffset; - splat.verts[2].y = -h + yoffset; - - splat.verts[3].x = w - xoffset; - splat.verts[3].y = -h + yoffset; - - angle = -splat.angle; - ca = FINECOSINE(angle>>ANGLETOFINESHIFT); - sa = FINESINE(angle>>ANGLETOFINESHIFT); - - // Rotate - for (i = 0; i < 4; i++) - { - rotated[i].x = FixedMul(splat.verts[i].x, ca) - FixedMul(splat.verts[i].y, sa); - rotated[i].y = FixedMul(splat.verts[i].x, sa) + FixedMul(splat.verts[i].y, ca); - } - - if (renderflags & (RF_SLOPESPLAT | RF_OBJECTSLOPESPLAT)) - { - pslope_t *standingslope = spr->mobj->standingslope; // The slope that the object is standing on. - - // The slope that was defined for the sprite. - if (renderflags & RF_SLOPESPLAT) - slope = spr->mobj->floorspriteslope; - - if (standingslope && (renderflags & RF_OBJECTSLOPESPLAT)) - slope = standingslope; - - // Set splat as tilted - splat.tilted = (slope != NULL); - } - - if (splat.tilted) - { - // Lactozilla: Just copy the entire slope LMFAOOOO - pslope_t *s = &splat.slope; - - s->o.x = slope->o.x; - s->o.y = slope->o.y; - s->o.z = slope->o.z; - - s->d.x = slope->d.x; - s->d.y = slope->d.y; - - s->normal.x = slope->normal.x; - s->normal.y = slope->normal.y; - s->normal.z = slope->normal.z; - - s->zdelta = slope->zdelta; - s->zangle = slope->zangle; - s->xydirection = slope->xydirection; - - s->next = NULL; - s->flags = 0; - } - - // Translate - for (i = 0; i < 4; i++) - { - tr_x = rotated[i].x + x; - tr_y = rotated[i].y + y; - - if (slope) - { - rot_z = P_GetSlopeZAt(slope, tr_x, tr_y); - splat.verts[i].z = rot_z; - } - else - splat.verts[i].z = splat.z; - - splat.verts[i].x = tr_x; - splat.verts[i].y = tr_y; - } - - for (i = 0; i < 4; i++) - { - v3d = &splat.verts[i]; - - // transform the origin point - tr_x = v3d->x - viewx; - tr_y = v3d->y - viewy; - - // rotation around vertical y axis - rot_x = FixedMul(tr_x, viewsin) - FixedMul(tr_y, viewcos); - rot_y = FixedMul(tr_x, viewcos) + FixedMul(tr_y, viewsin); - rot_z = v3d->z - viewz; - - if (rot_y < FRACUNIT) - return; - - // note: y from view above of map, is distance far away - xscale = FixedDiv(projection, rot_y); - yscale = -FixedDiv(projectiony, rot_y); - - // projection - v2d[i].x = (centerxfrac + FixedMul(rot_x, xscale))>>FRACBITS; - v2d[i].y = (centeryfrac + FixedMul(rot_z, yscale))>>FRACBITS; - } - - R_RenderFloorSplat(&splat, v2d, spr); -} - // // R_DrawSprite // @@ -2971,7 +2779,7 @@ static void R_DrawSprite(vissprite_t *spr) mceilingclip = spr->cliptop; if (spr->cut & SC_SPLAT) - R_DrawVisSplat(spr); + R_DrawSplatSprite(spr); else R_DrawVisSprite(spr); } From dfc85ec21aa7fd7082f73a0f29ae6f27893d5b3c Mon Sep 17 00:00:00 2001 From: Jaime Passos Date: Mon, 19 Oct 2020 17:38:02 -0300 Subject: [PATCH 0212/1080] Include p_local.h --- src/r_splats.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/r_splats.c b/src/r_splats.c index ddc73e090..6de0a7917 100644 --- a/src/r_splats.c +++ b/src/r_splats.c @@ -14,6 +14,7 @@ #include "r_main.h" #include "r_splats.h" #include "r_bsp.h" +#include "p_local.h" #include "p_slopes.h" #include "w_wad.h" #include "z_zone.h" From 81c9d2eae9576b6497e9b53749d36ae15739a3db Mon Sep 17 00:00:00 2001 From: Zippy_Zolton Date: Mon, 19 Oct 2020 18:41:23 -0500 Subject: [PATCH 0213/1080] forgot to send this like 3 hours ago --- src/console.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/console.c b/src/console.c index 7b32889ea..81d3abaac 100644 --- a/src/console.c +++ b/src/console.c @@ -384,8 +384,8 @@ static void CON_SetupColormaps(void) colset(magentamap, 177, 177, 178, 178, 179, 179, 180, 180, 181, 181, 182, 182, 183, 183, 184, 184); colset(yellowmap, 82, 82, 72, 73, 74, 74, 64, 64, 65, 65, 65, 66, 66, 66, 67, 67); colset(lgreenmap, 97, 97, 98, 98, 99, 99, 100, 100, 101, 101, 102, 102, 103, 103, 104, 104); - colset(bluemap, 147, 147, 147, 148, 148, 148, 149, 149, 150, 150, 151, 151, 152, 152, 153, 153); - colset(redmap, 33, 33, 33, 34, 34, 34, 35, 35, 37, 37, 39, 39, 41, 41, 43, 43); + colset(bluemap, 146, 146, 147, 147, 148, 148, 149, 149, 150, 150, 151, 151, 152, 152, 153, 153); + colset(redmap, 32, 32, 33, 33, 34, 34, 35, 35, 37, 37, 39, 39, 41, 41, 43, 43); colset(graymap, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20); colset(orangemap, 52, 52, 53, 53, 54, 54, 55, 55, 56, 56, 57, 57, 58, 58, 59, 59); colset(skymap, 128, 128, 129, 129, 130, 130, 131, 131, 132, 132, 133, 133, 134, 134, 135, 135); From d6c0e0cf30d59f954871c957da9c14671c881970 Mon Sep 17 00:00:00 2001 From: Steel Titanium Date: Mon, 19 Oct 2020 20:20:08 -0400 Subject: [PATCH 0214/1080] Fix G_GhostTicker crashing trying to read netvars as ghost data Also fixed possible issue with incorrectly reading the demo pointer due to the wrong type being passed to sizeof in G_ConsGhostTic --- 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 e45f23b62..0f72ad109 100644 --- a/src/g_demo.c +++ b/src/g_demo.c @@ -625,7 +625,7 @@ void G_ConsGhostTic(void) if (followtic & FZT_SCALE) demo_p += sizeof(fixed_t); // momx, momy and momz - demo_p += (demoversion < 0x000e) ? sizeof(UINT16) * 3 : sizeof(fixed_t) * 3; + demo_p += (demoversion < 0x000e) ? sizeof(INT16) * 3 : sizeof(fixed_t) * 3; if (followtic & FZT_SKIN) demo_p++; demo_p += sizeof(UINT16); @@ -2163,7 +2163,7 @@ void G_AddGhost(char *defdemoname) count = READUINT16(p); while (count--) { - p += 2; + SKIPSTRING(p); SKIPSTRING(p); p++; } From 04eae86d0a4bfbe0abe762bf705f5c1bddff5579 Mon Sep 17 00:00:00 2001 From: Zippy_Zolton Date: Mon, 19 Oct 2020 19:58:50 -0500 Subject: [PATCH 0215/1080] t --- src/console.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/console.c b/src/console.c index 81d3abaac..239706679 100644 --- a/src/console.c +++ b/src/console.c @@ -384,8 +384,8 @@ static void CON_SetupColormaps(void) colset(magentamap, 177, 177, 178, 178, 179, 179, 180, 180, 181, 181, 182, 182, 183, 183, 184, 184); colset(yellowmap, 82, 82, 72, 73, 74, 74, 64, 64, 65, 65, 65, 66, 66, 66, 67, 67); colset(lgreenmap, 97, 97, 98, 98, 99, 99, 100, 100, 101, 101, 102, 102, 103, 103, 104, 104); - colset(bluemap, 146, 146, 147, 147, 148, 148, 149, 149, 150, 150, 151, 151, 152, 152, 153, 153); - colset(redmap, 32, 32, 33, 33, 34, 34, 35, 35, 37, 37, 39, 39, 41, 41, 43, 43); + colset(bluemap, 146, 146, 147, 147, 148, 148, 149, 149, 150, 150, 151, 151, 151, 152, 152, 152); + colset(redmap, 32, 32, 33, 33, 34, 34, 35, 35, 37, 37, 39, 39, 39, 41, 41, 41); colset(graymap, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20); colset(orangemap, 52, 52, 53, 53, 54, 54, 55, 55, 56, 56, 57, 57, 58, 58, 59, 59); colset(skymap, 128, 128, 129, 129, 130, 130, 131, 131, 132, 132, 133, 133, 134, 134, 135, 135); From 4e985d71457fde8f342e4069ac5a251b4ed611f6 Mon Sep 17 00:00:00 2001 From: Zippy_Zolton Date: Mon, 19 Oct 2020 20:36:59 -0500 Subject: [PATCH 0216/1080] blue & red really seem like a hassle don't they --- src/console.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/console.c b/src/console.c index 239706679..b66c73bd4 100644 --- a/src/console.c +++ b/src/console.c @@ -384,8 +384,8 @@ static void CON_SetupColormaps(void) colset(magentamap, 177, 177, 178, 178, 179, 179, 180, 180, 181, 181, 182, 182, 183, 183, 184, 184); colset(yellowmap, 82, 82, 72, 73, 74, 74, 64, 64, 65, 65, 65, 66, 66, 66, 67, 67); colset(lgreenmap, 97, 97, 98, 98, 99, 99, 100, 100, 101, 101, 102, 102, 103, 103, 104, 104); - colset(bluemap, 146, 146, 147, 147, 148, 148, 149, 149, 150, 150, 151, 151, 151, 152, 152, 152); - colset(redmap, 32, 32, 33, 33, 34, 34, 35, 35, 37, 37, 39, 39, 39, 41, 41, 41); + colset(bluemap, 146, 146, 147, 147, 148, 148, 148, 149, 149, 149, 150, 150, 150, 151, 151, 151); + colset(redmap, 32, 32, 33, 33, 34, 34, 34, 35, 35, 35, 37, 37, 37, 39, 39, 39); colset(graymap, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20); colset(orangemap, 52, 52, 53, 53, 54, 54, 55, 55, 56, 56, 57, 57, 58, 58, 59, 59); colset(skymap, 128, 128, 129, 129, 130, 130, 131, 131, 132, 132, 133, 133, 134, 134, 135, 135); From 0b48f1052a1941b5f2fcf7ef790aca319c5ea4bd Mon Sep 17 00:00:00 2001 From: Zippy_Zolton Date: Tue, 20 Oct 2020 14:03:27 -0500 Subject: [PATCH 0217/1080] pencilvoid aqua --- src/console.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/console.c b/src/console.c index b66c73bd4..ed15e583e 100644 --- a/src/console.c +++ b/src/console.c @@ -390,7 +390,7 @@ static void CON_SetupColormaps(void) colset(orangemap, 52, 52, 53, 53, 54, 54, 55, 55, 56, 56, 57, 57, 58, 58, 59, 59); colset(skymap, 128, 128, 129, 129, 130, 130, 131, 131, 132, 132, 133, 133, 134, 134, 135, 135); colset(purplemap, 144, 144, 160, 160, 160, 161, 161, 161, 162, 162, 162, 162, 163, 163, 163, 163); - colset(aquamap, 128, 128, 120, 120, 121, 121, 122, 122, 123, 123, 124, 124, 124, 125, 125, 125); + colset(aquamap, 128, 120, 120, 121, 121, 122, 123, 123, 123, 124, 124, 124, 125, 125, 126, 126); colset(peridotmap, 72, 72, 188, 188, 188, 189, 189, 189, 189, 190, 190, 191, 191, 104, 104, 104); colset(azuremap, 144, 144, 145, 145, 146, 146, 146, 147, 147, 147, 170, 170, 170, 171, 171, 171); colset(brownmap, 218, 219, 220, 221, 221, 222, 223, 223, 224, 224, 225, 226, 227, 228, 229, 230); From b65ac1df30ad11101ff30e4199181d743478e1f3 Mon Sep 17 00:00:00 2001 From: Zippy_Zolton Date: Tue, 20 Oct 2020 14:40:10 -0500 Subject: [PATCH 0218/1080] sonicx azure --- src/console.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/console.c b/src/console.c index ed15e583e..c181f670c 100644 --- a/src/console.c +++ b/src/console.c @@ -392,7 +392,7 @@ static void CON_SetupColormaps(void) colset(purplemap, 144, 144, 160, 160, 160, 161, 161, 161, 162, 162, 162, 162, 163, 163, 163, 163); colset(aquamap, 128, 120, 120, 121, 121, 122, 123, 123, 123, 124, 124, 124, 125, 125, 126, 126); colset(peridotmap, 72, 72, 188, 188, 188, 189, 189, 189, 189, 190, 190, 191, 191, 104, 104, 104); - colset(azuremap, 144, 144, 145, 145, 146, 146, 146, 147, 147, 147, 170, 170, 170, 171, 171, 171); + colset(azuremap, 144, 144, 145, 145, 146, 146, 146, 170, 170, 170, 171, 171, 171, 172, 172, 172); colset(brownmap, 218, 219, 220, 221, 221, 222, 223, 223, 224, 224, 225, 226, 227, 228, 229, 230); colset(rosymap, 200, 200, 201, 201, 201, 202, 202, 203, 203, 203, 204, 204, 204, 205, 205, 205); From 45dd26476a7d20a8f3ffd041a96e4de9103471bc Mon Sep 17 00:00:00 2001 From: Zippy_Zolton Date: Tue, 20 Oct 2020 14:52:25 -0500 Subject: [PATCH 0219/1080] SonicX8000 purple, peridot, rosy --- src/console.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/console.c b/src/console.c index c181f670c..64c07f619 100644 --- a/src/console.c +++ b/src/console.c @@ -389,12 +389,12 @@ static void CON_SetupColormaps(void) colset(graymap, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20); colset(orangemap, 52, 52, 53, 53, 54, 54, 55, 55, 56, 56, 57, 57, 58, 58, 59, 59); colset(skymap, 128, 128, 129, 129, 130, 130, 131, 131, 132, 132, 133, 133, 134, 134, 135, 135); - colset(purplemap, 144, 144, 160, 160, 160, 161, 161, 161, 162, 162, 162, 162, 163, 163, 163, 163); + colset(purplemap, 144, 144, 160, 160, 161, 161, 161, 162, 162, 162, 163, 163, 163, 164, 164, 164); colset(aquamap, 128, 120, 120, 121, 121, 122, 123, 123, 123, 124, 124, 124, 125, 125, 126, 126); - colset(peridotmap, 72, 72, 188, 188, 188, 189, 189, 189, 189, 190, 190, 191, 191, 104, 104, 104); + colset(peridotmap, 72, 72, 188, 188, 189, 189, 189, 190, 190, 190, 191, 191, 191, 104, 104, 104); colset(azuremap, 144, 144, 145, 145, 146, 146, 146, 170, 170, 170, 171, 171, 171, 172, 172, 172); colset(brownmap, 218, 219, 220, 221, 221, 222, 223, 223, 224, 224, 225, 226, 227, 228, 229, 230); - colset(rosymap, 200, 200, 201, 201, 201, 202, 202, 203, 203, 203, 204, 204, 204, 205, 205, 205); + colset(rosymap, 200, 200, 201, 201, 202, 202, 202, 203, 203, 203, 204, 204, 204, 205, 205, 205); #undef colset From d1f16e0f778216b287888401072aa1ae586b1030 Mon Sep 17 00:00:00 2001 From: Zolton Auburn Date: Tue, 20 Oct 2020 15:56:41 -0400 Subject: [PATCH 0220/1080] Continue --- src/w_wad.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/w_wad.c b/src/w_wad.c index 37dcf5847..6306f998f 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -2101,6 +2101,9 @@ int W_VerifyNMUSlumps(const char *filename) {"M_", 2}, // Menu stuff {"LT", 2}, // Titlecard changes + {"SLID", 4}, // Continue + {"CONT", 4}, + {"MINICAPS", 8}, // NiGHTS graphics here and below {"BLUESTAT", 8}, // Sphere status {"BYELSTAT", 8}, From 03198ab31dd9a5e9eb791b1134d55677a2f0c782 Mon Sep 17 00:00:00 2001 From: Zippy_Zolton Date: Tue, 20 Oct 2020 14:59:30 -0500 Subject: [PATCH 0221/1080] SonicX aqua --- src/console.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/console.c b/src/console.c index 64c07f619..daa5f7f1b 100644 --- a/src/console.c +++ b/src/console.c @@ -390,7 +390,7 @@ static void CON_SetupColormaps(void) colset(orangemap, 52, 52, 53, 53, 54, 54, 55, 55, 56, 56, 57, 57, 58, 58, 59, 59); colset(skymap, 128, 128, 129, 129, 130, 130, 131, 131, 132, 132, 133, 133, 134, 134, 135, 135); colset(purplemap, 144, 144, 160, 160, 161, 161, 161, 162, 162, 162, 163, 163, 163, 164, 164, 164); - colset(aquamap, 128, 120, 120, 121, 121, 122, 123, 123, 123, 124, 124, 124, 125, 125, 126, 126); + colset(aquamap, 120, 120, 121, 121, 122, 122, 122, 123, 123, 123, 124, 124, 124, 125, 125, 125); colset(peridotmap, 72, 72, 188, 188, 189, 189, 189, 190, 190, 190, 191, 191, 191, 104, 104, 104); colset(azuremap, 144, 144, 145, 145, 146, 146, 146, 170, 170, 170, 171, 171, 171, 172, 172, 172); colset(brownmap, 218, 219, 220, 221, 221, 222, 223, 223, 224, 224, 225, 226, 227, 228, 229, 230); From 0f771edfd527f5c96d00d8da9d5065ac02f8b9f2 Mon Sep 17 00:00:00 2001 From: Zippy_Zolton Date: Tue, 20 Oct 2020 15:11:00 -0500 Subject: [PATCH 0222/1080] SonicX orange --- src/console.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/console.c b/src/console.c index daa5f7f1b..5d85ca663 100644 --- a/src/console.c +++ b/src/console.c @@ -387,7 +387,7 @@ static void CON_SetupColormaps(void) colset(bluemap, 146, 146, 147, 147, 148, 148, 148, 149, 149, 149, 150, 150, 150, 151, 151, 151); colset(redmap, 32, 32, 33, 33, 34, 34, 34, 35, 35, 35, 37, 37, 37, 39, 39, 39); colset(graymap, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20); - colset(orangemap, 52, 52, 53, 53, 54, 54, 55, 55, 56, 56, 57, 57, 58, 58, 59, 59); + colset(orangemap, 51, 51, 52, 52, 53, 53, 54, 54, 55, 55, 56, 56, 57, 57, 58, 58); colset(skymap, 128, 128, 129, 129, 130, 130, 131, 131, 132, 132, 133, 133, 134, 134, 135, 135); colset(purplemap, 144, 144, 160, 160, 161, 161, 161, 162, 162, 162, 163, 163, 163, 164, 164, 164); colset(aquamap, 120, 120, 121, 121, 122, 122, 122, 123, 123, 123, 124, 124, 124, 125, 125, 125); From 39ccd12f04c07a777fb598689d04facb6cbf0436 Mon Sep 17 00:00:00 2001 From: James R Date: Tue, 20 Oct 2020 16:08:34 -0700 Subject: [PATCH 0223/1080] Add CV_Set, CV_SetValue, CV_StealthSet, CV_StealthSetValue and CV_AddValue to Lua CV_SetValue merged with CV_Set (same with CV_StealthSetValue and CV_StealthSet). --- src/lua_consolelib.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/src/lua_consolelib.c b/src/lua_consolelib.c index fae4f2d14..c6b082930 100644 --- a/src/lua_consolelib.c +++ b/src/lua_consolelib.c @@ -432,6 +432,46 @@ static int lib_cvFindVar(lua_State *L) return 1; } +static int CVarSetFunction +( + lua_State *L, + void (*Set)(consvar_t *, const char *), + void (*SetValue)(consvar_t *, INT32) +){ + consvar_t *cvar = (consvar_t *)luaL_checkudata(L, 1, META_CVAR); + + switch (lua_type(L, 2)) + { + case LUA_TSTRING: + (*Set)(cvar, lua_tostring(L, 2)); + break; + case LUA_TNUMBER: + (*SetValue)(cvar, (INT32)lua_tonumber(L, 2)); + break; + default: + return luaL_typerror(L, 1, "string or number"); + } + + return 0; +} + +static int lib_cvSet(lua_State *L) +{ + return CVarSetFunction(L, CV_Set, CV_SetValue); +} + +static int lib_cvStealthSet(lua_State *L) +{ + return CVarSetFunction(L, CV_StealthSet, CV_StealthSetValue); +} + +static int lib_cvAddValue(lua_State *L) +{ + consvar_t *cvar = (consvar_t *)luaL_checkudata(L, 1, META_CVAR); + CV_AddValue(cvar, (INT32)luaL_checknumber(L, 2)); + return 0; +} + // CONS_Printf for a single player // Use 'print' in baselib for a global message. static int lib_consPrintf(lua_State *L) @@ -472,6 +512,9 @@ static luaL_Reg lib[] = { {"COM_BufInsertText", lib_comBufInsertText}, {"CV_RegisterVar", lib_cvRegisterVar}, {"CV_FindVar", lib_cvFindVar}, + {"CV_Set", lib_cvSet}, + {"CV_StealthSet", lib_cvStealthSet}, + {"CV_AddValue", lib_cvAddValue}, {"CONS_Printf", lib_consPrintf}, {NULL, NULL} }; From 88c882fa9cf9845a0331a7f43011c1a8befe2499 Mon Sep 17 00:00:00 2001 From: Zippy_Zolton Date: Tue, 20 Oct 2020 19:59:33 -0500 Subject: [PATCH 0224/1080] 81 --- src/console.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/console.c b/src/console.c index 5d85ca663..24ec6443c 100644 --- a/src/console.c +++ b/src/console.c @@ -382,7 +382,7 @@ static void CON_SetupColormaps(void) // 0x1 0x3 0x9 0xF colset(magentamap, 177, 177, 178, 178, 179, 179, 180, 180, 181, 181, 182, 182, 183, 183, 184, 184); - colset(yellowmap, 82, 82, 72, 73, 74, 74, 64, 64, 65, 65, 65, 66, 66, 66, 67, 67); + colset(yellowmap, 81, 81, 73, 73, 74, 74, 74, 65, 65, 65, 66, 66, 66, 67, 67, 67); colset(lgreenmap, 97, 97, 98, 98, 99, 99, 100, 100, 101, 101, 102, 102, 103, 103, 104, 104); colset(bluemap, 146, 146, 147, 147, 148, 148, 148, 149, 149, 149, 150, 150, 150, 151, 151, 151); colset(redmap, 32, 32, 33, 33, 34, 34, 34, 35, 35, 35, 37, 37, 37, 39, 39, 39); From 5091c19abf74a7e91d22ca00259a11f6901f4cbe Mon Sep 17 00:00:00 2001 From: Louis-Antoine Date: Wed, 21 Oct 2020 20:25:29 +0200 Subject: [PATCH 0225/1080] Kick clients that fail to catch up with server gamelogic --- src/d_clisrv.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 51a3bb24b..e314d419f 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -5611,8 +5611,13 @@ void NetUpdate(void) firstticstosend = gametic; for (i = 0; i < MAXNETNODES; i++) if (nodeingame[i] && nettics[i] < firstticstosend) + { firstticstosend = nettics[i]; + if (maketic + 1 >= nettics[i] + BACKUPTICS) + Net_ConnectionTimeout(i); + } + // Don't erase tics not acknowledged counts = realtics; From ba4b6ec4007922f7d6dd355a377781e18e80043f Mon Sep 17 00:00:00 2001 From: James R Date: Wed, 21 Oct 2020 12:34:26 -0700 Subject: [PATCH 0226/1080] 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 f84500785..58434ef89 100644 --- a/src/command.c +++ b/src/command.c @@ -165,6 +165,8 @@ void COM_BufAddTextEx(const char *ptext, int flags) */ void COM_BufInsertTextEx(const char *ptext, int flags) { + const INT32 old_wait = com_wait; + char *temp = NULL; size_t templen; @@ -176,10 +178,14 @@ void COM_BufInsertTextEx(const char *ptext, int flags) VS_Clear(&com_text); } + com_wait = 0; + // add the entire text of the file (or alias) COM_BufAddTextEx(ptext, flags); COM_BufExecute(); // do it right away + com_wait += old_wait; + // add the copied off data if (templen) { From d349e9bf839f5d1b4e41ce43b8281744d755548c Mon Sep 17 00:00:00 2001 From: Louis-Antoine Date: Wed, 21 Oct 2020 22:48:00 +0200 Subject: [PATCH 0227/1080] Only invoke the Lua API for mobj hooks that need it --- src/lua_hooklib.c | 36 +++++++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/src/lua_hooklib.c b/src/lua_hooklib.c index a5d4af412..e349dbea8 100644 --- a/src/lua_hooklib.c +++ b/src/lua_hooklib.c @@ -264,6 +264,9 @@ boolean LUAh_MobjHook(mobj_t *mo, enum hook which) I_Assert(mo->type < NUMMOBJTYPES); + if (!(mobjhooks[MT_NULL] || mobjhooks[mo->type])) + return false; + lua_settop(gL, 0); lua_pushcfunction(gL, LUA_GetErrorMessage); @@ -536,6 +539,9 @@ UINT8 LUAh_MobjCollideHook(mobj_t *thing1, mobj_t *thing2, enum hook which) I_Assert(thing1->type < NUMMOBJTYPES); + if (!(mobjhooks[MT_NULL] || mobjhooks[thing1->type])) + return 0; + lua_settop(gL, 0); lua_pushcfunction(gL, LUA_GetErrorMessage); @@ -615,6 +621,9 @@ UINT8 LUAh_MobjLineCollideHook(mobj_t *thing, line_t *line, enum hook which) I_Assert(thing->type < NUMMOBJTYPES); + if (!(mobjhooks[MT_NULL] || mobjhooks[thing->type])) + return 0; + lua_settop(gL, 0); lua_pushcfunction(gL, LUA_GetErrorMessage); @@ -695,6 +704,9 @@ boolean LUAh_MobjThinker(mobj_t *mo) I_Assert(mo->type < NUMMOBJTYPES); + if (!(mobjhooks[MT_NULL] || mobjhooks[mo->type])) + return false; + lua_settop(gL, 0); lua_pushcfunction(gL, LUA_GetErrorMessage); @@ -747,10 +759,13 @@ boolean LUAh_TouchSpecial(mobj_t *special, mobj_t *toucher) hook_p hookp; boolean hooked = false; if (!gL || !(hooksAvailable[hook_TouchSpecial/8] & (1<<(hook_TouchSpecial%8)))) - return 0; + return false; I_Assert(special->type < NUMMOBJTYPES); + if (!(mobjhooks[MT_NULL] || mobjhooks[special->type])) + return false; + lua_settop(gL, 0); lua_pushcfunction(gL, LUA_GetErrorMessage); @@ -821,6 +836,9 @@ UINT8 LUAh_ShouldDamage(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 I_Assert(target->type < NUMMOBJTYPES); + if (!(mobjhooks[MT_NULL] || mobjhooks[target->type])) + return 0; + lua_settop(gL, 0); lua_pushcfunction(gL, LUA_GetErrorMessage); @@ -908,10 +926,13 @@ boolean LUAh_MobjDamage(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 hook_p hookp; boolean hooked = false; if (!gL || !(hooksAvailable[hook_MobjDamage/8] & (1<<(hook_MobjDamage%8)))) - return 0; + return false; I_Assert(target->type < NUMMOBJTYPES); + if (!(mobjhooks[MT_NULL] || mobjhooks[target->type])) + return false; + lua_settop(gL, 0); lua_pushcfunction(gL, LUA_GetErrorMessage); @@ -990,10 +1011,13 @@ boolean LUAh_MobjDeath(mobj_t *target, mobj_t *inflictor, mobj_t *source, UINT8 hook_p hookp; boolean hooked = false; if (!gL || !(hooksAvailable[hook_MobjDeath/8] & (1<<(hook_MobjDeath%8)))) - return 0; + return false; I_Assert(target->type < NUMMOBJTYPES); + if (!(mobjhooks[MT_NULL] || mobjhooks[target->type])) + return false; + lua_settop(gL, 0); lua_pushcfunction(gL, LUA_GetErrorMessage); @@ -1392,6 +1416,9 @@ boolean LUAh_MapThingSpawn(mobj_t *mo, mapthing_t *mthing) if (!gL || !(hooksAvailable[hook_MapThingSpawn/8] & (1<<(hook_MapThingSpawn%8)))) return false; + if (!(mobjhooks[MT_NULL] || mobjhooks[mo->type])) + return false; + lua_settop(gL, 0); lua_pushcfunction(gL, LUA_GetErrorMessage); @@ -1460,6 +1487,9 @@ boolean LUAh_FollowMobj(player_t *player, mobj_t *mobj) if (!gL || !(hooksAvailable[hook_FollowMobj/8] & (1<<(hook_FollowMobj%8)))) return 0; + if (!(mobjhooks[MT_NULL] || mobjhooks[mobj->type])) + return 0; + lua_settop(gL, 0); lua_pushcfunction(gL, LUA_GetErrorMessage); From 37c11e0f2e6b48176b0f15b6bd912d09affe09a5 Mon Sep 17 00:00:00 2001 From: Louis-Antoine Date: Thu, 22 Oct 2020 00:08:06 +0200 Subject: [PATCH 0228/1080] Fix unfortunate typos --- src/lua_hooklib.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lua_hooklib.c b/src/lua_hooklib.c index e349dbea8..65d483dc1 100644 --- a/src/lua_hooklib.c +++ b/src/lua_hooklib.c @@ -539,7 +539,7 @@ UINT8 LUAh_MobjCollideHook(mobj_t *thing1, mobj_t *thing2, enum hook which) I_Assert(thing1->type < NUMMOBJTYPES); - if (!(mobjhooks[MT_NULL] || mobjhooks[thing1->type])) + if (!(mobjcollidehooks[MT_NULL] || mobjcollidehooks[thing1->type])) return 0; lua_settop(gL, 0); @@ -621,7 +621,7 @@ UINT8 LUAh_MobjLineCollideHook(mobj_t *thing, line_t *line, enum hook which) I_Assert(thing->type < NUMMOBJTYPES); - if (!(mobjhooks[MT_NULL] || mobjhooks[thing->type])) + if (!(mobjcollidehooks[MT_NULL] || mobjcollidehooks[thing->type])) return 0; lua_settop(gL, 0); @@ -704,7 +704,7 @@ boolean LUAh_MobjThinker(mobj_t *mo) I_Assert(mo->type < NUMMOBJTYPES); - if (!(mobjhooks[MT_NULL] || mobjhooks[mo->type])) + if (!(mobjthinkerhooks[MT_NULL] || mobjthinkerhooks[mo->type])) return false; lua_settop(gL, 0); From a4459b6693b969088ae307020d664910ae2aee95 Mon Sep 17 00:00:00 2001 From: Zippy_Zolton Date: Fri, 23 Oct 2020 00:47:47 -0500 Subject: [PATCH 0229/1080] Dash state for Tails overlay --- src/dehacked.c | 1 + src/info.c | 3 +++ src/info.h | 1 + src/p_user.c | 2 ++ 4 files changed, 7 insertions(+) diff --git a/src/dehacked.c b/src/dehacked.c index ca013a25d..34fe58362 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -5178,6 +5178,7 @@ static const char *const STATE_LIST[] = { // array length left dynamic for sanit "S_TAILSOVERLAY_PAIN", "S_TAILSOVERLAY_GASP", "S_TAILSOVERLAY_EDGE", + "S_TAILSOVERLAY_DASH", // [: "S_JETFUMEFLASH", diff --git a/src/info.c b/src/info.c index cb5fb0889..8cdfaa8a0 100644 --- a/src/info.c +++ b/src/info.c @@ -584,6 +584,7 @@ char spr2names[NUMPLAYERSPRITES][5] = "TAL9", "TALA", "TALB", + "TALC", "CNT1", "CNT2", @@ -661,6 +662,7 @@ playersprite_t spr2defaults[NUMPLAYERSPRITES] = { SPR2_TAL0, // SPR2_TAL9, SPR2_TAL9, // SPR2_TALA, SPR2_TAL0, // SPR2_TALB, + SPR2_TAL0, // SPR2_TALC, SPR2_WAIT, // SPR2_CNT1, SPR2_FALL, // SPR2_CNT2, @@ -801,6 +803,7 @@ state_t states[NUMSTATES] = {SPR_PLAY, SPR2_TAL9|FF_SPR2MIDSTART, 35, {NULL}, 0, 0, S_TAILSOVERLAY_PAIN}, // S_TAILSOVERLAY_PAIN {SPR_PLAY, SPR2_TALA|FF_SPR2MIDSTART, 35, {NULL}, 0, 0, S_TAILSOVERLAY_GASP}, // S_TAILSOVERLAY_GASP {SPR_PLAY, SPR2_TALB , 35, {NULL}, 0, 0, S_TAILSOVERLAY_EDGE}, // S_TAILSOVERLAY_EDGE + {SPR_PLAY, SPR2_TALC|FF_SPR2MIDSTART, 35, {NULL}, 0, 0, S_TAILSOVERLAY_DASH}, // S_TAILSOVERLAY_DASH // [: {SPR_JETF, 3|FF_ANIMATE|FF_FULLBRIGHT, 2, {NULL}, 1, 1, S_JETFUME1}, // S_JETFUMEFLASH diff --git a/src/info.h b/src/info.h index 721ebf7f2..8130cf948 100644 --- a/src/info.h +++ b/src/info.h @@ -997,6 +997,7 @@ typedef enum state S_TAILSOVERLAY_PAIN, S_TAILSOVERLAY_GASP, S_TAILSOVERLAY_EDGE, + S_TAILSOVERLAY_DASH, // [: S_JETFUMEFLASH, diff --git a/src/p_user.c b/src/p_user.c index 0d7331293..da33f1dbb 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -11208,6 +11208,8 @@ static void P_DoTailsOverlay(player_t *player, mobj_t *tails) chosenstate = S_TAILSOVERLAY_EDGE; else if (player->panim == PA_RUN) chosenstate = S_TAILSOVERLAY_RUN; + else if (player->panim == PA_DASH) + chosenstate = S_TAILSOVERLAY_DASH; else if (player->panim == PA_WALK) { if (!smilesonground || player->mo->state-states == S_PLAY_SKID) From c0571b5fbf41918842f8b6fecf5854572ed7635b Mon Sep 17 00:00:00 2001 From: Zippy_Zolton Date: Fri, 23 Oct 2020 01:09:12 -0500 Subject: [PATCH 0230/1080] g --- src/info.h | 1 + src/p_user.c | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/info.h b/src/info.h index 8130cf948..d84461617 100644 --- a/src/info.h +++ b/src/info.h @@ -856,6 +856,7 @@ typedef enum playersprite SPR2_TAL9, SPR2_TALA, SPR2_TALB, + SPR2_TALC, SPR2_CNT1, // continue disappointment SPR2_CNT2, // continue lift diff --git a/src/p_user.c b/src/p_user.c index da33f1dbb..051965eb5 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -11206,10 +11206,10 @@ static void P_DoTailsOverlay(player_t *player, mobj_t *tails) chosenstate = S_TAILSOVERLAY_GASP; else if (player->mo->state-states == S_PLAY_EDGE) chosenstate = S_TAILSOVERLAY_EDGE; - else if (player->panim == PA_RUN) - chosenstate = S_TAILSOVERLAY_RUN; else if (player->panim == PA_DASH) chosenstate = S_TAILSOVERLAY_DASH; + else if (player->panim == PA_RUN) + chosenstate = S_TAILSOVERLAY_RUN; else if (player->panim == PA_WALK) { if (!smilesonground || player->mo->state-states == S_PLAY_SKID) From 85692ac4090c68dc4bc519f230b7d69226b47263 Mon Sep 17 00:00:00 2001 From: Zolton Auburn Date: Fri, 23 Oct 2020 14:04:02 -0400 Subject: [PATCH 0231/1080] Update info.c --- src/info.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/info.c b/src/info.c index 8cdfaa8a0..29a79b1d6 100644 --- a/src/info.c +++ b/src/info.c @@ -662,7 +662,7 @@ playersprite_t spr2defaults[NUMPLAYERSPRITES] = { SPR2_TAL0, // SPR2_TAL9, SPR2_TAL9, // SPR2_TALA, SPR2_TAL0, // SPR2_TALB, - SPR2_TAL0, // SPR2_TALC, + SPR2_TAL6, // SPR2_TALC, SPR2_WAIT, // SPR2_CNT1, SPR2_FALL, // SPR2_CNT2, From 5d4032fd0067426a6cb7caf1bbeaf4b8ec2ac093 Mon Sep 17 00:00:00 2001 From: Zippy_Zolton Date: Sat, 24 Oct 2020 12:38:30 -0500 Subject: [PATCH 0232/1080] Ghost mobj matches rollangle --- src/p_user.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/p_user.c b/src/p_user.c index 0d7331293..02b807bf2 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -2029,6 +2029,7 @@ mobj_t *P_SpawnGhostMobj(mobj_t *mobj) ghost->colorized = mobj->colorized; // alternatively, "true" for sonic advance style colourisation ghost->angle = (mobj->player ? mobj->player->drawangle : mobj->angle); + ghost->rollangle = mobj->rollangle; ghost->sprite = mobj->sprite; ghost->sprite2 = mobj->sprite2; ghost->frame = mobj->frame; From 305f58077d13b39ba9e9fca91b69f6aecf6cb8ed Mon Sep 17 00:00:00 2001 From: James R Date: Sat, 24 Oct 2020 15:29:31 -0700 Subject: [PATCH 0233/1080] Fix objectplace -silent --- src/m_cheat.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/m_cheat.c b/src/m_cheat.c index 349f00c48..88f6aaf4a 100644 --- a/src/m_cheat.c +++ b/src/m_cheat.c @@ -1440,14 +1440,21 @@ void Command_Writethings_f(void) void Command_ObjectPlace_f(void) { + size_t thingarg; + size_t silent; + REQUIRE_INLEVEL; REQUIRE_SINGLEPLAYER; REQUIRE_NOULTIMATE; G_SetGameModified(multiplayer); + silent = COM_CheckParm("-silent"); + + thingarg = 2 - ( silent > 1 ); + // Entering objectplace? - if (!objectplacing || COM_Argc() > 1) + if (!objectplacing || thingarg < COM_Argc()) { if (!objectplacing) { @@ -1456,7 +1463,7 @@ void Command_ObjectPlace_f(void) if (players[0].powers[pw_carry] == CR_NIGHTSMODE) return; - if (!COM_CheckParm("-silent")) + if (! silent) { HU_SetCEchoFlags(V_RETURN8|V_MONOSPACE|V_AUTOFADEOUT); HU_SetCEchoDuration(10); @@ -1507,9 +1514,9 @@ void Command_ObjectPlace_f(void) op_oldstate = (statenum_t)(players[0].mo->state-states); } - if (COM_Argc() > 1) + if (thingarg < COM_Argc()) { - UINT16 mapthingnum = atoi(COM_Argv(1)); + UINT16 mapthingnum = atoi(COM_Argv(thingarg)); mobjtype_t type = P_GetMobjtype(mapthingnum); if (type == MT_UNKNOWN) CONS_Printf(M_GetText("No mobj type delegated to thing type %d.\n"), mapthingnum); From 288ffebea7d79454e455cb6eb2fc44ff25b94db1 Mon Sep 17 00:00:00 2001 From: James R Date: Sat, 24 Oct 2020 15:52:02 -0700 Subject: [PATCH 0234/1080] Do not save cleared ban list when reloading bans --- src/d_clisrv.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index e314d419f..43ac12c93 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -2918,16 +2918,14 @@ static void Ban_Add(const char *reason) reasontail = reasonlist; } -static void Command_ClearBans(void) +static void Ban_Clear(void) { banreason_t *temp; - if (!I_ClearBans) - return; - I_ClearBans(); - D_SaveBan(); + reasontail = NULL; + while (reasonhead) { temp = reasonhead->next; @@ -2937,6 +2935,15 @@ static void Command_ClearBans(void) } } +static void Command_ClearBans(void) +{ + if (!I_ClearBans) + return; + + Ban_Clear(); + D_SaveBan(); +} + static void Ban_Load_File(boolean warning) { FILE *f; @@ -2944,6 +2951,9 @@ static void Ban_Load_File(boolean warning) const char *address, *mask; char buffer[MAX_WADPATH]; + if (!I_ClearBans) + return; + f = fopen(va("%s"PATHSEP"%s", srb2home, "ban.txt"), "r"); if (!f) @@ -2953,13 +2963,7 @@ static void Ban_Load_File(boolean warning) return; } - if (I_ClearBans) - Command_ClearBans(); - else - { - fclose(f); - return; - } + Ban_Clear(); for (i=0; fgets(buffer, (int)sizeof(buffer), f); i++) { From 9278f04fbfa6083f10f980c1fe2914c64aae4dfa Mon Sep 17 00:00:00 2001 From: James R Date: Sat, 24 Oct 2020 15:59:11 -0700 Subject: [PATCH 0235/1080] Delete ban.txt if no bans to save --- src/d_clisrv.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 43ac12c93..12145c5c8 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -2870,11 +2870,15 @@ void D_SaveBan(void) size_t i; banreason_t *reasonlist = reasonhead; const char *address, *mask; + const char *path = va("%s"PATHSEP"%s", srb2home, "ban.txt"); if (!reasonhead) + { + remove(path); return; + } - f = fopen(va("%s"PATHSEP"%s", srb2home, "ban.txt"), "w"); + f = fopen(path, "w"); if (!f) { From 24596bd8d5f205da3c12b8ee0238db2ebb6a9d57 Mon Sep 17 00:00:00 2001 From: Zolton Auburn Date: Sat, 24 Oct 2020 20:16:21 -0400 Subject: [PATCH 0236/1080] Update f_finale.c --- src/f_finale.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/f_finale.c b/src/f_finale.c index 1c5168396..64dc707ba 100644 --- a/src/f_finale.c +++ b/src/f_finale.c @@ -1119,7 +1119,6 @@ static const char *credits[] = { "\"Arrietty\"", "Ryan \"Blaze Hedgehog\" Bloom", "Graeme P. \"SuperPhanto\" Caldwell", // for the new brak render - "\"Fighter_Builder\"", // for the CEZ3 button debris "\"ChrispyPixels\"", "Paul \"Boinciel\" Clempson", "Sally \"TehRealSalt\" Cochenour", @@ -1128,6 +1127,7 @@ static const char *credits[] = { "Sherman \"CoatRack\" DesJardins", "\"DirkTheHusky\"", "Jesse \"Jeck Jims\" Emerick", + "\"Fighter_Builder\"", // for the CEZ3 button debris "Buddy \"KinkaJoy\" Fischer", "Vivian \"toaster\" Grannell", "James \"SwitchKaze\" Hale", From 9a0d65a0f10c41aaa499331f06779e449572c46c Mon Sep 17 00:00:00 2001 From: Zolton Auburn Date: Sat, 24 Oct 2020 20:17:20 -0400 Subject: [PATCH 0237/1080] Update f_finale.c --- src/f_finale.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/f_finale.c b/src/f_finale.c index 64dc707ba..d7f81b9df 100644 --- a/src/f_finale.c +++ b/src/f_finale.c @@ -1127,7 +1127,7 @@ static const char *credits[] = { "Sherman \"CoatRack\" DesJardins", "\"DirkTheHusky\"", "Jesse \"Jeck Jims\" Emerick", - "\"Fighter_Builder\"", // for the CEZ3 button debris + "\"Fighter_Builder\"", // for the CEZ3 button debris "Buddy \"KinkaJoy\" Fischer", "Vivian \"toaster\" Grannell", "James \"SwitchKaze\" Hale", From afb8e6e1815c75c089a4bd1c684fc4c6bcc7f2d5 Mon Sep 17 00:00:00 2001 From: James R Date: Sat, 24 Oct 2020 20:44:42 -0700 Subject: [PATCH 0238/1080] Whoops --- src/m_cheat.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/m_cheat.c b/src/m_cheat.c index 88f6aaf4a..8e9cd9f51 100644 --- a/src/m_cheat.c +++ b/src/m_cheat.c @@ -1451,7 +1451,7 @@ void Command_ObjectPlace_f(void) silent = COM_CheckParm("-silent"); - thingarg = 2 - ( silent > 1 ); + thingarg = 2 - ( silent != 1 ); // Entering objectplace? if (!objectplacing || thingarg < COM_Argc()) From 86ad187f05adef9a74290e3d29aff0efa2552aba Mon Sep 17 00:00:00 2001 From: Hannu Hanhi Date: Thu, 22 Oct 2020 00:31:28 +0300 Subject: [PATCH 0239/1080] NPO2 slope span optimization --- src/CMakeLists.txt | 1 + src/libdivide.h | 2082 ++++++++++++++++++++++++++ src/r_draw.c | 1 + src/r_draw8_npo2.c | 188 ++- src/sdl/Srb2SDL-vc10.vcxproj | 1 + src/sdl/Srb2SDL-vc10.vcxproj.filters | 3 + 6 files changed, 2196 insertions(+), 80 deletions(-) create mode 100644 src/libdivide.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 6c0e20e8e..416000ac7 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -87,6 +87,7 @@ set(SRB2_CORE_HEADERS i_video.h info.h keys.h + libdivide.h lzf.h m_aatree.h m_anigif.h diff --git a/src/libdivide.h b/src/libdivide.h new file mode 100644 index 000000000..51f9a633b --- /dev/null +++ b/src/libdivide.h @@ -0,0 +1,2082 @@ +// libdivide.h - Optimized integer division +// https://libdivide.com +// +// Copyright (C) 2010 - 2019 ridiculous_fish, +// Copyright (C) 2016 - 2019 Kim Walisch, +// +// libdivide is dual-licensed under the Boost or zlib licenses. +// You may use libdivide under the terms of either of these. +// See LICENSE.txt for more details. + +// NOTICE: This version of libdivide has been modified for use with SRB2. +// Changes made: +// - unused parts commented out (to avoid the need to fix C90 compilation issues with them) +// - C90 compilation issues fixed with used parts +// - use I_Error for errors + +#ifndef LIBDIVIDE_H +#define LIBDIVIDE_H + +#define LIBDIVIDE_VERSION "3.0" +#define LIBDIVIDE_VERSION_MAJOR 3 +#define LIBDIVIDE_VERSION_MINOR 0 + +#include + +#if defined(__cplusplus) + #include + #include + #include +#else + #include + #include +#endif + +#if defined(LIBDIVIDE_AVX512) + #include +#elif defined(LIBDIVIDE_AVX2) + #include +#elif defined(LIBDIVIDE_SSE2) + #include +#endif + +#if defined(_MSC_VER) + #include + // disable warning C4146: unary minus operator applied + // to unsigned type, result still unsigned + #pragma warning(disable: 4146) + #define LIBDIVIDE_VC +#endif + +#if !defined(__has_builtin) + #define __has_builtin(x) 0 +#endif + +#if defined(__SIZEOF_INT128__) + #define HAS_INT128_T + // clang-cl on Windows does not yet support 128-bit division + #if !(defined(__clang__) && defined(LIBDIVIDE_VC)) + #define HAS_INT128_DIV + #endif +#endif + +#if defined(__x86_64__) || defined(_M_X64) + #define LIBDIVIDE_X86_64 +#endif + +#if defined(__i386__) + #define LIBDIVIDE_i386 +#endif + +#if defined(__GNUC__) || defined(__clang__) + #define LIBDIVIDE_GCC_STYLE_ASM +#endif + +#if defined(__cplusplus) || defined(LIBDIVIDE_VC) + #define LIBDIVIDE_FUNCTION __FUNCTION__ +#else + #define LIBDIVIDE_FUNCTION __func__ +#endif + +#define LIBDIVIDE_ERROR(msg) \ + I_Error("libdivide.h:%d: %s(): Error: %s\n", \ + __LINE__, LIBDIVIDE_FUNCTION, msg); + +#if defined(LIBDIVIDE_ASSERTIONS_ON) + #define LIBDIVIDE_ASSERT(x) \ + if (!(x)) { \ + I_Error("libdivide.h:%d: %s(): Assertion failed: %s\n", \ + __LINE__, LIBDIVIDE_FUNCTION, #x); \ + } +#else + #define LIBDIVIDE_ASSERT(x) +#endif + +#ifdef __cplusplus +namespace libdivide { +#endif + +// pack divider structs to prevent compilers from padding. +// This reduces memory usage by up to 43% when using a large +// array of libdivide dividers and improves performance +// by up to 10% because of reduced memory bandwidth. +#pragma pack(push, 1) + +struct libdivide_u32_t { + uint32_t magic; + uint8_t more; +}; + +struct libdivide_s32_t { + int32_t magic; + uint8_t more; +}; + +struct libdivide_u64_t { + uint64_t magic; + uint8_t more; +}; + +struct libdivide_s64_t { + int64_t magic; + uint8_t more; +}; + +struct libdivide_u32_branchfree_t { + uint32_t magic; + uint8_t more; +}; + +struct libdivide_s32_branchfree_t { + int32_t magic; + uint8_t more; +}; + +struct libdivide_u64_branchfree_t { + uint64_t magic; + uint8_t more; +}; + +struct libdivide_s64_branchfree_t { + int64_t magic; + uint8_t more; +}; + +#pragma pack(pop) + +// Explanation of the "more" field: +// +// * Bits 0-5 is the shift value (for shift path or mult path). +// * Bit 6 is the add indicator for mult path. +// * Bit 7 is set if the divisor is negative. We use bit 7 as the negative +// divisor indicator so that we can efficiently use sign extension to +// create a bitmask with all bits set to 1 (if the divisor is negative) +// or 0 (if the divisor is positive). +// +// u32: [0-4] shift value +// [5] ignored +// [6] add indicator +// magic number of 0 indicates shift path +// +// s32: [0-4] shift value +// [5] ignored +// [6] add indicator +// [7] indicates negative divisor +// magic number of 0 indicates shift path +// +// u64: [0-5] shift value +// [6] add indicator +// magic number of 0 indicates shift path +// +// s64: [0-5] shift value +// [6] add indicator +// [7] indicates negative divisor +// magic number of 0 indicates shift path +// +// In s32 and s64 branchfree modes, the magic number is negated according to +// whether the divisor is negated. In branchfree strategy, it is not negated. + +enum { + LIBDIVIDE_32_SHIFT_MASK = 0x1F, + LIBDIVIDE_64_SHIFT_MASK = 0x3F, + LIBDIVIDE_ADD_MARKER = 0x40, + LIBDIVIDE_NEGATIVE_DIVISOR = 0x80 +}; + +//static inline struct libdivide_s32_t libdivide_s32_gen(int32_t d); +static inline struct libdivide_u32_t libdivide_u32_gen(uint32_t d); +//static inline struct libdivide_s64_t libdivide_s64_gen(int64_t d); +//static inline struct libdivide_u64_t libdivide_u64_gen(uint64_t d); + +/*static inline struct libdivide_s32_branchfree_t libdivide_s32_branchfree_gen(int32_t d); +static inline struct libdivide_u32_branchfree_t libdivide_u32_branchfree_gen(uint32_t d); +static inline struct libdivide_s64_branchfree_t libdivide_s64_branchfree_gen(int64_t d); +static inline struct libdivide_u64_branchfree_t libdivide_u64_branchfree_gen(uint64_t d);*/ + +//static inline int32_t libdivide_s32_do(int32_t numer, const struct libdivide_s32_t *denom); +static inline uint32_t libdivide_u32_do(uint32_t numer, const struct libdivide_u32_t *denom); +//static inline int64_t libdivide_s64_do(int64_t numer, const struct libdivide_s64_t *denom); +//static inline uint64_t libdivide_u64_do(uint64_t numer, const struct libdivide_u64_t *denom); + +/*static inline int32_t libdivide_s32_branchfree_do(int32_t numer, const struct libdivide_s32_branchfree_t *denom); +static inline uint32_t libdivide_u32_branchfree_do(uint32_t numer, const struct libdivide_u32_branchfree_t *denom); +static inline int64_t libdivide_s64_branchfree_do(int64_t numer, const struct libdivide_s64_branchfree_t *denom); +static inline uint64_t libdivide_u64_branchfree_do(uint64_t numer, const struct libdivide_u64_branchfree_t *denom);*/ + +/*static inline int32_t libdivide_s32_recover(const struct libdivide_s32_t *denom); +static inline uint32_t libdivide_u32_recover(const struct libdivide_u32_t *denom); +static inline int64_t libdivide_s64_recover(const struct libdivide_s64_t *denom); +static inline uint64_t libdivide_u64_recover(const struct libdivide_u64_t *denom);*/ + +/*static inline int32_t libdivide_s32_branchfree_recover(const struct libdivide_s32_branchfree_t *denom); +static inline uint32_t libdivide_u32_branchfree_recover(const struct libdivide_u32_branchfree_t *denom); +static inline int64_t libdivide_s64_branchfree_recover(const struct libdivide_s64_branchfree_t *denom); +static inline uint64_t libdivide_u64_branchfree_recover(const struct libdivide_u64_branchfree_t *denom);*/ + +//////// Internal Utility Functions + +static inline uint32_t libdivide_mullhi_u32(uint32_t x, uint32_t y) { + uint64_t xl = x, yl = y; + uint64_t rl = xl * yl; + return (uint32_t)(rl >> 32); +} + +static inline int32_t libdivide_mullhi_s32(int32_t x, int32_t y) { + int64_t xl = x, yl = y; + int64_t rl = xl * yl; + // needs to be arithmetic shift + return (int32_t)(rl >> 32); +} + +static inline uint64_t libdivide_mullhi_u64(uint64_t x, uint64_t y) { +#if defined(LIBDIVIDE_VC) && \ + defined(LIBDIVIDE_X86_64) + return __umulh(x, y); +#elif defined(HAS_INT128_T) + __uint128_t xl = x, yl = y; + __uint128_t rl = xl * yl; + return (uint64_t)(rl >> 64); +#else + // full 128 bits are x0 * y0 + (x0 * y1 << 32) + (x1 * y0 << 32) + (x1 * y1 << 64) + uint32_t mask = 0xFFFFFFFF; + uint32_t x0 = (uint32_t)(x & mask); + uint32_t x1 = (uint32_t)(x >> 32); + uint32_t y0 = (uint32_t)(y & mask); + uint32_t y1 = (uint32_t)(y >> 32); + uint32_t x0y0_hi = libdivide_mullhi_u32(x0, y0); + uint64_t x0y1 = x0 * (uint64_t)y1; + uint64_t x1y0 = x1 * (uint64_t)y0; + uint64_t x1y1 = x1 * (uint64_t)y1; + uint64_t temp = x1y0 + x0y0_hi; + uint64_t temp_lo = temp & mask; + uint64_t temp_hi = temp >> 32; + + return x1y1 + temp_hi + ((temp_lo + x0y1) >> 32); +#endif +} + +static inline int64_t libdivide_mullhi_s64(int64_t x, int64_t y) { +#if defined(LIBDIVIDE_VC) && \ + defined(LIBDIVIDE_X86_64) + return __mulh(x, y); +#elif defined(HAS_INT128_T) + __int128_t xl = x, yl = y; + __int128_t rl = xl * yl; + return (int64_t)(rl >> 64); +#else + // full 128 bits are x0 * y0 + (x0 * y1 << 32) + (x1 * y0 << 32) + (x1 * y1 << 64) + uint32_t mask = 0xFFFFFFFF; + uint32_t x0 = (uint32_t)(x & mask); + uint32_t y0 = (uint32_t)(y & mask); + int32_t x1 = (int32_t)(x >> 32); + int32_t y1 = (int32_t)(y >> 32); + uint32_t x0y0_hi = libdivide_mullhi_u32(x0, y0); + int64_t t = x1 * (int64_t)y0 + x0y0_hi; + int64_t w1 = x0 * (int64_t)y1 + (t & mask); + + return x1 * (int64_t)y1 + (t >> 32) + (w1 >> 32); +#endif +} + +static inline int32_t libdivide_count_leading_zeros32(uint32_t val) { +#if defined(__GNUC__) || \ + __has_builtin(__builtin_clz) + // Fast way to count leading zeros + return __builtin_clz(val); +#elif defined(LIBDIVIDE_VC) + unsigned long result; + if (_BitScanReverse(&result, val)) { + return 31 - result; + } + return 0; +#else + if (val == 0) + return 32; + int32_t result = 8; + uint32_t hi = 0xFFU << 24; + while ((val & hi) == 0) { + hi >>= 8; + result += 8; + } + while (val & hi) { + result -= 1; + hi <<= 1; + } + return result; +#endif +} + +static inline int32_t libdivide_count_leading_zeros64(uint64_t val) { +#if defined(__GNUC__) || \ + __has_builtin(__builtin_clzll) + // Fast way to count leading zeros + return __builtin_clzll(val); +#elif defined(LIBDIVIDE_VC) && defined(_WIN64) + unsigned long result; + if (_BitScanReverse64(&result, val)) { + return 63 - result; + } + return 0; +#else + uint32_t hi = val >> 32; + uint32_t lo = val & 0xFFFFFFFF; + if (hi != 0) return libdivide_count_leading_zeros32(hi); + return 32 + libdivide_count_leading_zeros32(lo); +#endif +} + +// libdivide_64_div_32_to_32: divides a 64-bit uint {u1, u0} by a 32-bit +// uint {v}. The result must fit in 32 bits. +// Returns the quotient directly and the remainder in *r +static inline uint32_t libdivide_64_div_32_to_32(uint32_t u1, uint32_t u0, uint32_t v, uint32_t *r) { +#if (defined(LIBDIVIDE_i386) || defined(LIBDIVIDE_X86_64)) && \ + defined(LIBDIVIDE_GCC_STYLE_ASM) + uint32_t result; + __asm__("divl %[v]" + : "=a"(result), "=d"(*r) + : [v] "r"(v), "a"(u0), "d"(u1) + ); + return result; +#else + uint64_t n = ((uint64_t)u1 << 32) | u0; + uint32_t result = (uint32_t)(n / v); + *r = (uint32_t)(n - result * (uint64_t)v); + return result; +#endif +} + +// libdivide_128_div_64_to_64: divides a 128-bit uint {u1, u0} by a 64-bit +// uint {v}. The result must fit in 64 bits. +// Returns the quotient directly and the remainder in *r +/*static uint64_t libdivide_128_div_64_to_64(uint64_t u1, uint64_t u0, uint64_t v, uint64_t *r) { +#if defined(LIBDIVIDE_X86_64) && \ + defined(LIBDIVIDE_GCC_STYLE_ASM) + uint64_t result; + __asm__("divq %[v]" + : "=a"(result), "=d"(*r) + : [v] "r"(v), "a"(u0), "d"(u1) + ); + return result; +#elif defined(HAS_INT128_T) && \ + defined(HAS_INT128_DIV) + __uint128_t n = ((__uint128_t)u1 << 64) | u0; + uint64_t result = (uint64_t)(n / v); + *r = (uint64_t)(n - result * (__uint128_t)v); + return result; +#else + // Code taken from Hacker's Delight: + // http://www.hackersdelight.org/HDcode/divlu.c. + // License permits inclusion here per: + // http://www.hackersdelight.org/permissions.htm + + const uint64_t b = (1ULL << 32); // Number base (32 bits) + uint64_t un1, un0; // Norm. dividend LSD's + uint64_t vn1, vn0; // Norm. divisor digits + uint64_t q1, q0; // Quotient digits + uint64_t un64, un21, un10; // Dividend digit pairs + uint64_t rhat; // A remainder + int32_t s; // Shift amount for norm + + // If overflow, set rem. to an impossible value, + // and return the largest possible quotient + if (u1 >= v) { + *r = (uint64_t) -1; + return (uint64_t) -1; + } + + // count leading zeros + s = libdivide_count_leading_zeros64(v); + if (s > 0) { + // Normalize divisor + v = v << s; + un64 = (u1 << s) | (u0 >> (64 - s)); + un10 = u0 << s; // Shift dividend left + } else { + // Avoid undefined behavior of (u0 >> 64). + // The behavior is undefined if the right operand is + // negative, or greater than or equal to the length + // in bits of the promoted left operand. + un64 = u1; + un10 = u0; + } + + // Break divisor up into two 32-bit digits + vn1 = v >> 32; + vn0 = v & 0xFFFFFFFF; + + // Break right half of dividend into two digits + un1 = un10 >> 32; + un0 = un10 & 0xFFFFFFFF; + + // Compute the first quotient digit, q1 + q1 = un64 / vn1; + rhat = un64 - q1 * vn1; + + while (q1 >= b || q1 * vn0 > b * rhat + un1) { + q1 = q1 - 1; + rhat = rhat + vn1; + if (rhat >= b) + break; + } + + // Multiply and subtract + un21 = un64 * b + un1 - q1 * v; + + // Compute the second quotient digit + q0 = un21 / vn1; + rhat = un21 - q0 * vn1; + + while (q0 >= b || q0 * vn0 > b * rhat + un0) { + q0 = q0 - 1; + rhat = rhat + vn1; + if (rhat >= b) + break; + } + + *r = (un21 * b + un0 - q0 * v) >> s; + return q1 * b + q0; +#endif +}*/ + +// Bitshift a u128 in place, left (signed_shift > 0) or right (signed_shift < 0) +static inline void libdivide_u128_shift(uint64_t *u1, uint64_t *u0, int32_t signed_shift) { + if (signed_shift > 0) { + uint32_t shift = signed_shift; + *u1 <<= shift; + *u1 |= *u0 >> (64 - shift); + *u0 <<= shift; + } + else if (signed_shift < 0) { + uint32_t shift = -signed_shift; + *u0 >>= shift; + *u0 |= *u1 << (64 - shift); + *u1 >>= shift; + } +} + +// Computes a 128 / 128 -> 64 bit division, with a 128 bit remainder. +/*static uint64_t libdivide_128_div_128_to_64(uint64_t u_hi, uint64_t u_lo, uint64_t v_hi, uint64_t v_lo, uint64_t *r_hi, uint64_t *r_lo) { +#if defined(HAS_INT128_T) && \ + defined(HAS_INT128_DIV) + __uint128_t ufull = u_hi; + __uint128_t vfull = v_hi; + ufull = (ufull << 64) | u_lo; + vfull = (vfull << 64) | v_lo; + uint64_t res = (uint64_t)(ufull / vfull); + __uint128_t remainder = ufull - (vfull * res); + *r_lo = (uint64_t)remainder; + *r_hi = (uint64_t)(remainder >> 64); + return res; +#else + // Adapted from "Unsigned Doubleword Division" in Hacker's Delight + // We want to compute u / v + typedef struct { uint64_t hi; uint64_t lo; } u128_t; + u128_t u = {u_hi, u_lo}; + u128_t v = {v_hi, v_lo}; + + if (v.hi == 0) { + // divisor v is a 64 bit value, so we just need one 128/64 division + // Note that we are simpler than Hacker's Delight here, because we know + // the quotient fits in 64 bits whereas Hacker's Delight demands a full + // 128 bit quotient + *r_hi = 0; + return libdivide_128_div_64_to_64(u.hi, u.lo, v.lo, r_lo); + } + // Here v >= 2**64 + // We know that v.hi != 0, so count leading zeros is OK + // We have 0 <= n <= 63 + uint32_t n = libdivide_count_leading_zeros64(v.hi); + + // Normalize the divisor so its MSB is 1 + u128_t v1t = v; + libdivide_u128_shift(&v1t.hi, &v1t.lo, n); + uint64_t v1 = v1t.hi; // i.e. v1 = v1t >> 64 + + // To ensure no overflow + u128_t u1 = u; + libdivide_u128_shift(&u1.hi, &u1.lo, -1); + + // Get quotient from divide unsigned insn. + uint64_t rem_ignored; + uint64_t q1 = libdivide_128_div_64_to_64(u1.hi, u1.lo, v1, &rem_ignored); + + // Undo normalization and division of u by 2. + u128_t q0 = {0, q1}; + libdivide_u128_shift(&q0.hi, &q0.lo, n); + libdivide_u128_shift(&q0.hi, &q0.lo, -63); + + // Make q0 correct or too small by 1 + // Equivalent to `if (q0 != 0) q0 = q0 - 1;` + if (q0.hi != 0 || q0.lo != 0) { + q0.hi -= (q0.lo == 0); // borrow + q0.lo -= 1; + } + + // Now q0 is correct. + // Compute q0 * v as q0v + // = (q0.hi << 64 + q0.lo) * (v.hi << 64 + v.lo) + // = (q0.hi * v.hi << 128) + (q0.hi * v.lo << 64) + + // (q0.lo * v.hi << 64) + q0.lo * v.lo) + // Each term is 128 bit + // High half of full product (upper 128 bits!) are dropped + u128_t q0v = {0, 0}; + q0v.hi = q0.hi*v.lo + q0.lo*v.hi + libdivide_mullhi_u64(q0.lo, v.lo); + q0v.lo = q0.lo*v.lo; + + // Compute u - q0v as u_q0v + // This is the remainder + u128_t u_q0v = u; + u_q0v.hi -= q0v.hi + (u.lo < q0v.lo); // second term is borrow + u_q0v.lo -= q0v.lo; + + // Check if u_q0v >= v + // This checks if our remainder is larger than the divisor + if ((u_q0v.hi > v.hi) || + (u_q0v.hi == v.hi && u_q0v.lo >= v.lo)) { + // Increment q0 + q0.lo += 1; + q0.hi += (q0.lo == 0); // carry + + // Subtract v from remainder + u_q0v.hi -= v.hi + (u_q0v.lo < v.lo); + u_q0v.lo -= v.lo; + } + + *r_hi = u_q0v.hi; + *r_lo = u_q0v.lo; + + LIBDIVIDE_ASSERT(q0.hi == 0); + return q0.lo; +#endif +}*/ + +////////// UINT32 + +static inline struct libdivide_u32_t libdivide_internal_u32_gen(uint32_t d, int branchfree) { + struct libdivide_u32_t result; + uint32_t floor_log_2_d; + + if (d == 0) { + LIBDIVIDE_ERROR("divider must be != 0"); + } + + floor_log_2_d = 31 - libdivide_count_leading_zeros32(d); + + // Power of 2 + if ((d & (d - 1)) == 0) { + // We need to subtract 1 from the shift value in case of an unsigned + // branchfree divider because there is a hardcoded right shift by 1 + // in its division algorithm. Because of this we also need to add back + // 1 in its recovery algorithm. + result.magic = 0; + result.more = (uint8_t)(floor_log_2_d - (branchfree != 0)); + } else { + uint8_t more; + uint32_t rem, proposed_m; + uint32_t e; + proposed_m = libdivide_64_div_32_to_32(1U << floor_log_2_d, 0, d, &rem); + + LIBDIVIDE_ASSERT(rem > 0 && rem < d); + e = d - rem; + + // This power works if e < 2**floor_log_2_d. + if (!branchfree && (e < (1U << floor_log_2_d))) { + // This power works + more = floor_log_2_d; + } else { + // We have to use the general 33-bit algorithm. We need to compute + // (2**power) / d. However, we already have (2**(power-1))/d and + // its remainder. By doubling both, and then correcting the + // remainder, we can compute the larger division. + // don't care about overflow here - in fact, we expect it + const uint32_t twice_rem = rem + rem; + proposed_m += proposed_m; + if (twice_rem >= d || twice_rem < rem) proposed_m += 1; + more = floor_log_2_d | LIBDIVIDE_ADD_MARKER; + } + result.magic = 1 + proposed_m; + result.more = more; + // result.more's shift should in general be ceil_log_2_d. But if we + // used the smaller power, we subtract one from the shift because we're + // using the smaller power. If we're using the larger power, we + // subtract one from the shift because it's taken care of by the add + // indicator. So floor_log_2_d happens to be correct in both cases. + } + return result; +} + +struct libdivide_u32_t libdivide_u32_gen(uint32_t d) { + return libdivide_internal_u32_gen(d, 0); +} + +/*struct libdivide_u32_branchfree_t libdivide_u32_branchfree_gen(uint32_t d) { + if (d == 1) { + LIBDIVIDE_ERROR("branchfree divider must be != 1"); + } + struct libdivide_u32_t tmp = libdivide_internal_u32_gen(d, 1); + struct libdivide_u32_branchfree_t ret = {tmp.magic, (uint8_t)(tmp.more & LIBDIVIDE_32_SHIFT_MASK)}; + return ret; +}*/ + +uint32_t libdivide_u32_do(uint32_t numer, const struct libdivide_u32_t *denom) { + uint8_t more = denom->more; + if (!denom->magic) { + return numer >> more; + } + else { + uint32_t q = libdivide_mullhi_u32(denom->magic, numer); + if (more & LIBDIVIDE_ADD_MARKER) { + uint32_t t = ((numer - q) >> 1) + q; + return t >> (more & LIBDIVIDE_32_SHIFT_MASK); + } + else { + // All upper bits are 0, + // don't need to mask them off. + return q >> more; + } + } +} + +/*uint32_t libdivide_u32_branchfree_do(uint32_t numer, const struct libdivide_u32_branchfree_t *denom) { + uint32_t q = libdivide_mullhi_u32(denom->magic, numer); + uint32_t t = ((numer - q) >> 1) + q; + return t >> denom->more; +} + +uint32_t libdivide_u32_recover(const struct libdivide_u32_t *denom) { + uint8_t more = denom->more; + uint8_t shift = more & LIBDIVIDE_32_SHIFT_MASK; + + if (!denom->magic) { + return 1U << shift; + } else if (!(more & LIBDIVIDE_ADD_MARKER)) { + // We compute q = n/d = n*m / 2^(32 + shift) + // Therefore we have d = 2^(32 + shift) / m + // We need to ceil it. + // We know d is not a power of 2, so m is not a power of 2, + // so we can just add 1 to the floor + uint32_t hi_dividend = 1U << shift; + uint32_t rem_ignored; + return 1 + libdivide_64_div_32_to_32(hi_dividend, 0, denom->magic, &rem_ignored); + } else { + // Here we wish to compute d = 2^(32+shift+1)/(m+2^32). + // Notice (m + 2^32) is a 33 bit number. Use 64 bit division for now + // Also note that shift may be as high as 31, so shift + 1 will + // overflow. So we have to compute it as 2^(32+shift)/(m+2^32), and + // then double the quotient and remainder. + uint64_t half_n = 1ULL << (32 + shift); + uint64_t d = (1ULL << 32) | denom->magic; + // Note that the quotient is guaranteed <= 32 bits, but the remainder + // may need 33! + uint32_t half_q = (uint32_t)(half_n / d); + uint64_t rem = half_n % d; + // We computed 2^(32+shift)/(m+2^32) + // Need to double it, and then add 1 to the quotient if doubling th + // remainder would increase the quotient. + // Note that rem<<1 cannot overflow, since rem < d and d is 33 bits + uint32_t full_q = half_q + half_q + ((rem<<1) >= d); + + // We rounded down in gen (hence +1) + return full_q + 1; + } +} + +uint32_t libdivide_u32_branchfree_recover(const struct libdivide_u32_branchfree_t *denom) { + uint8_t more = denom->more; + uint8_t shift = more & LIBDIVIDE_32_SHIFT_MASK; + + if (!denom->magic) { + return 1U << (shift + 1); + } else { + // Here we wish to compute d = 2^(32+shift+1)/(m+2^32). + // Notice (m + 2^32) is a 33 bit number. Use 64 bit division for now + // Also note that shift may be as high as 31, so shift + 1 will + // overflow. So we have to compute it as 2^(32+shift)/(m+2^32), and + // then double the quotient and remainder. + uint64_t half_n = 1ULL << (32 + shift); + uint64_t d = (1ULL << 32) | denom->magic; + // Note that the quotient is guaranteed <= 32 bits, but the remainder + // may need 33! + uint32_t half_q = (uint32_t)(half_n / d); + uint64_t rem = half_n % d; + // We computed 2^(32+shift)/(m+2^32) + // Need to double it, and then add 1 to the quotient if doubling th + // remainder would increase the quotient. + // Note that rem<<1 cannot overflow, since rem < d and d is 33 bits + uint32_t full_q = half_q + half_q + ((rem<<1) >= d); + + // We rounded down in gen (hence +1) + return full_q + 1; + } +}*/ + +/////////// UINT64 + +/*static inline struct libdivide_u64_t libdivide_internal_u64_gen(uint64_t d, int branchfree) { + if (d == 0) { + LIBDIVIDE_ERROR("divider must be != 0"); + } + + struct libdivide_u64_t result; + uint32_t floor_log_2_d = 63 - libdivide_count_leading_zeros64(d); + + // Power of 2 + if ((d & (d - 1)) == 0) { + // We need to subtract 1 from the shift value in case of an unsigned + // branchfree divider because there is a hardcoded right shift by 1 + // in its division algorithm. Because of this we also need to add back + // 1 in its recovery algorithm. + result.magic = 0; + result.more = (uint8_t)(floor_log_2_d - (branchfree != 0)); + } else { + uint64_t proposed_m, rem; + uint8_t more; + // (1 << (64 + floor_log_2_d)) / d + proposed_m = libdivide_128_div_64_to_64(1ULL << floor_log_2_d, 0, d, &rem); + + LIBDIVIDE_ASSERT(rem > 0 && rem < d); + const uint64_t e = d - rem; + + // This power works if e < 2**floor_log_2_d. + if (!branchfree && e < (1ULL << floor_log_2_d)) { + // This power works + more = floor_log_2_d; + } else { + // We have to use the general 65-bit algorithm. We need to compute + // (2**power) / d. However, we already have (2**(power-1))/d and + // its remainder. By doubling both, and then correcting the + // remainder, we can compute the larger division. + // don't care about overflow here - in fact, we expect it + proposed_m += proposed_m; + const uint64_t twice_rem = rem + rem; + if (twice_rem >= d || twice_rem < rem) proposed_m += 1; + more = floor_log_2_d | LIBDIVIDE_ADD_MARKER; + } + result.magic = 1 + proposed_m; + result.more = more; + // result.more's shift should in general be ceil_log_2_d. But if we + // used the smaller power, we subtract one from the shift because we're + // using the smaller power. If we're using the larger power, we + // subtract one from the shift because it's taken care of by the add + // indicator. So floor_log_2_d happens to be correct in both cases, + // which is why we do it outside of the if statement. + } + return result; +} + +struct libdivide_u64_t libdivide_u64_gen(uint64_t d) { + return libdivide_internal_u64_gen(d, 0); +} + +struct libdivide_u64_branchfree_t libdivide_u64_branchfree_gen(uint64_t d) { + if (d == 1) { + LIBDIVIDE_ERROR("branchfree divider must be != 1"); + } + struct libdivide_u64_t tmp = libdivide_internal_u64_gen(d, 1); + struct libdivide_u64_branchfree_t ret = {tmp.magic, (uint8_t)(tmp.more & LIBDIVIDE_64_SHIFT_MASK)}; + return ret; +} + +uint64_t libdivide_u64_do(uint64_t numer, const struct libdivide_u64_t *denom) { + uint8_t more = denom->more; + if (!denom->magic) { + return numer >> more; + } + else { + uint64_t q = libdivide_mullhi_u64(denom->magic, numer); + if (more & LIBDIVIDE_ADD_MARKER) { + uint64_t t = ((numer - q) >> 1) + q; + return t >> (more & LIBDIVIDE_64_SHIFT_MASK); + } + else { + // All upper bits are 0, + // don't need to mask them off. + return q >> more; + } + } +} + +uint64_t libdivide_u64_branchfree_do(uint64_t numer, const struct libdivide_u64_branchfree_t *denom) { + uint64_t q = libdivide_mullhi_u64(denom->magic, numer); + uint64_t t = ((numer - q) >> 1) + q; + return t >> denom->more; +} + +uint64_t libdivide_u64_recover(const struct libdivide_u64_t *denom) { + uint8_t more = denom->more; + uint8_t shift = more & LIBDIVIDE_64_SHIFT_MASK; + + if (!denom->magic) { + return 1ULL << shift; + } else if (!(more & LIBDIVIDE_ADD_MARKER)) { + // We compute q = n/d = n*m / 2^(64 + shift) + // Therefore we have d = 2^(64 + shift) / m + // We need to ceil it. + // We know d is not a power of 2, so m is not a power of 2, + // so we can just add 1 to the floor + uint64_t hi_dividend = 1ULL << shift; + uint64_t rem_ignored; + return 1 + libdivide_128_div_64_to_64(hi_dividend, 0, denom->magic, &rem_ignored); + } else { + // Here we wish to compute d = 2^(64+shift+1)/(m+2^64). + // Notice (m + 2^64) is a 65 bit number. This gets hairy. See + // libdivide_u32_recover for more on what we do here. + // TODO: do something better than 128 bit math + + // Full n is a (potentially) 129 bit value + // half_n is a 128 bit value + // Compute the hi half of half_n. Low half is 0. + uint64_t half_n_hi = 1ULL << shift, half_n_lo = 0; + // d is a 65 bit value. The high bit is always set to 1. + const uint64_t d_hi = 1, d_lo = denom->magic; + // Note that the quotient is guaranteed <= 64 bits, + // but the remainder may need 65! + uint64_t r_hi, r_lo; + uint64_t half_q = libdivide_128_div_128_to_64(half_n_hi, half_n_lo, d_hi, d_lo, &r_hi, &r_lo); + // We computed 2^(64+shift)/(m+2^64) + // Double the remainder ('dr') and check if that is larger than d + // Note that d is a 65 bit value, so r1 is small and so r1 + r1 + // cannot overflow + uint64_t dr_lo = r_lo + r_lo; + uint64_t dr_hi = r_hi + r_hi + (dr_lo < r_lo); // last term is carry + int dr_exceeds_d = (dr_hi > d_hi) || (dr_hi == d_hi && dr_lo >= d_lo); + uint64_t full_q = half_q + half_q + (dr_exceeds_d ? 1 : 0); + return full_q + 1; + } +} + +uint64_t libdivide_u64_branchfree_recover(const struct libdivide_u64_branchfree_t *denom) { + uint8_t more = denom->more; + uint8_t shift = more & LIBDIVIDE_64_SHIFT_MASK; + + if (!denom->magic) { + return 1ULL << (shift + 1); + } else { + // Here we wish to compute d = 2^(64+shift+1)/(m+2^64). + // Notice (m + 2^64) is a 65 bit number. This gets hairy. See + // libdivide_u32_recover for more on what we do here. + // TODO: do something better than 128 bit math + + // Full n is a (potentially) 129 bit value + // half_n is a 128 bit value + // Compute the hi half of half_n. Low half is 0. + uint64_t half_n_hi = 1ULL << shift, half_n_lo = 0; + // d is a 65 bit value. The high bit is always set to 1. + const uint64_t d_hi = 1, d_lo = denom->magic; + // Note that the quotient is guaranteed <= 64 bits, + // but the remainder may need 65! + uint64_t r_hi, r_lo; + uint64_t half_q = libdivide_128_div_128_to_64(half_n_hi, half_n_lo, d_hi, d_lo, &r_hi, &r_lo); + // We computed 2^(64+shift)/(m+2^64) + // Double the remainder ('dr') and check if that is larger than d + // Note that d is a 65 bit value, so r1 is small and so r1 + r1 + // cannot overflow + uint64_t dr_lo = r_lo + r_lo; + uint64_t dr_hi = r_hi + r_hi + (dr_lo < r_lo); // last term is carry + int dr_exceeds_d = (dr_hi > d_hi) || (dr_hi == d_hi && dr_lo >= d_lo); + uint64_t full_q = half_q + half_q + (dr_exceeds_d ? 1 : 0); + return full_q + 1; + } +}*/ + +/////////// SINT32 + +/*static inline struct libdivide_s32_t libdivide_internal_s32_gen(int32_t d, int branchfree) { + if (d == 0) { + LIBDIVIDE_ERROR("divider must be != 0"); + } + + struct libdivide_s32_t result; + + // If d is a power of 2, or negative a power of 2, we have to use a shift. + // This is especially important because the magic algorithm fails for -1. + // To check if d is a power of 2 or its inverse, it suffices to check + // whether its absolute value has exactly one bit set. This works even for + // INT_MIN, because abs(INT_MIN) == INT_MIN, and INT_MIN has one bit set + // and is a power of 2. + uint32_t ud = (uint32_t)d; + uint32_t absD = (d < 0) ? -ud : ud; + uint32_t floor_log_2_d = 31 - libdivide_count_leading_zeros32(absD); + // check if exactly one bit is set, + // don't care if absD is 0 since that's divide by zero + if ((absD & (absD - 1)) == 0) { + // Branchfree and normal paths are exactly the same + result.magic = 0; + result.more = floor_log_2_d | (d < 0 ? LIBDIVIDE_NEGATIVE_DIVISOR : 0); + } else { + LIBDIVIDE_ASSERT(floor_log_2_d >= 1); + + uint8_t more; + // the dividend here is 2**(floor_log_2_d + 31), so the low 32 bit word + // is 0 and the high word is floor_log_2_d - 1 + uint32_t rem, proposed_m; + proposed_m = libdivide_64_div_32_to_32(1U << (floor_log_2_d - 1), 0, absD, &rem); + const uint32_t e = absD - rem; + + // We are going to start with a power of floor_log_2_d - 1. + // This works if works if e < 2**floor_log_2_d. + if (!branchfree && e < (1U << floor_log_2_d)) { + // This power works + more = floor_log_2_d - 1; + } else { + // We need to go one higher. This should not make proposed_m + // overflow, but it will make it negative when interpreted as an + // int32_t. + proposed_m += proposed_m; + const uint32_t twice_rem = rem + rem; + if (twice_rem >= absD || twice_rem < rem) proposed_m += 1; + more = floor_log_2_d | LIBDIVIDE_ADD_MARKER; + } + + proposed_m += 1; + int32_t magic = (int32_t)proposed_m; + + // Mark if we are negative. Note we only negate the magic number in the + // branchfull case. + if (d < 0) { + more |= LIBDIVIDE_NEGATIVE_DIVISOR; + if (!branchfree) { + magic = -magic; + } + } + + result.more = more; + result.magic = magic; + } + return result; +} + +struct libdivide_s32_t libdivide_s32_gen(int32_t d) { + return libdivide_internal_s32_gen(d, 0); +} + +struct libdivide_s32_branchfree_t libdivide_s32_branchfree_gen(int32_t d) { + struct libdivide_s32_t tmp = libdivide_internal_s32_gen(d, 1); + struct libdivide_s32_branchfree_t result = {tmp.magic, tmp.more}; + return result; +} + +int32_t libdivide_s32_do(int32_t numer, const struct libdivide_s32_t *denom) { + uint8_t more = denom->more; + uint8_t shift = more & LIBDIVIDE_32_SHIFT_MASK; + + if (!denom->magic) { + uint32_t sign = (int8_t)more >> 7; + uint32_t mask = (1U << shift) - 1; + uint32_t uq = numer + ((numer >> 31) & mask); + int32_t q = (int32_t)uq; + q >>= shift; + q = (q ^ sign) - sign; + return q; + } else { + uint32_t uq = (uint32_t)libdivide_mullhi_s32(denom->magic, numer); + if (more & LIBDIVIDE_ADD_MARKER) { + // must be arithmetic shift and then sign extend + int32_t sign = (int8_t)more >> 7; + // q += (more < 0 ? -numer : numer) + // cast required to avoid UB + uq += ((uint32_t)numer ^ sign) - sign; + } + int32_t q = (int32_t)uq; + q >>= shift; + q += (q < 0); + return q; + } +} + +int32_t libdivide_s32_branchfree_do(int32_t numer, const struct libdivide_s32_branchfree_t *denom) { + uint8_t more = denom->more; + uint8_t shift = more & LIBDIVIDE_32_SHIFT_MASK; + // must be arithmetic shift and then sign extend + int32_t sign = (int8_t)more >> 7; + int32_t magic = denom->magic; + int32_t q = libdivide_mullhi_s32(magic, numer); + q += numer; + + // If q is non-negative, we have nothing to do + // If q is negative, we want to add either (2**shift)-1 if d is a power of + // 2, or (2**shift) if it is not a power of 2 + uint32_t is_power_of_2 = (magic == 0); + uint32_t q_sign = (uint32_t)(q >> 31); + q += q_sign & ((1U << shift) - is_power_of_2); + + // Now arithmetic right shift + q >>= shift; + // Negate if needed + q = (q ^ sign) - sign; + + return q; +} + +int32_t libdivide_s32_recover(const struct libdivide_s32_t *denom) { + uint8_t more = denom->more; + uint8_t shift = more & LIBDIVIDE_32_SHIFT_MASK; + if (!denom->magic) { + uint32_t absD = 1U << shift; + if (more & LIBDIVIDE_NEGATIVE_DIVISOR) { + absD = -absD; + } + return (int32_t)absD; + } else { + // Unsigned math is much easier + // We negate the magic number only in the branchfull case, and we don't + // know which case we're in. However we have enough information to + // determine the correct sign of the magic number. The divisor was + // negative if LIBDIVIDE_NEGATIVE_DIVISOR is set. If ADD_MARKER is set, + // the magic number's sign is opposite that of the divisor. + // We want to compute the positive magic number. + int negative_divisor = (more & LIBDIVIDE_NEGATIVE_DIVISOR); + int magic_was_negated = (more & LIBDIVIDE_ADD_MARKER) + ? denom->magic > 0 : denom->magic < 0; + + // Handle the power of 2 case (including branchfree) + if (denom->magic == 0) { + int32_t result = 1U << shift; + return negative_divisor ? -result : result; + } + + uint32_t d = (uint32_t)(magic_was_negated ? -denom->magic : denom->magic); + uint64_t n = 1ULL << (32 + shift); // this shift cannot exceed 30 + uint32_t q = (uint32_t)(n / d); + int32_t result = (int32_t)q; + result += 1; + return negative_divisor ? -result : result; + } +} + +int32_t libdivide_s32_branchfree_recover(const struct libdivide_s32_branchfree_t *denom) { + return libdivide_s32_recover((const struct libdivide_s32_t *)denom); +}*/ + +///////////// SINT64 + +/*static inline struct libdivide_s64_t libdivide_internal_s64_gen(int64_t d, int branchfree) { + if (d == 0) { + LIBDIVIDE_ERROR("divider must be != 0"); + } + + struct libdivide_s64_t result; + + // If d is a power of 2, or negative a power of 2, we have to use a shift. + // This is especially important because the magic algorithm fails for -1. + // To check if d is a power of 2 or its inverse, it suffices to check + // whether its absolute value has exactly one bit set. This works even for + // INT_MIN, because abs(INT_MIN) == INT_MIN, and INT_MIN has one bit set + // and is a power of 2. + uint64_t ud = (uint64_t)d; + uint64_t absD = (d < 0) ? -ud : ud; + uint32_t floor_log_2_d = 63 - libdivide_count_leading_zeros64(absD); + // check if exactly one bit is set, + // don't care if absD is 0 since that's divide by zero + if ((absD & (absD - 1)) == 0) { + // Branchfree and non-branchfree cases are the same + result.magic = 0; + result.more = floor_log_2_d | (d < 0 ? LIBDIVIDE_NEGATIVE_DIVISOR : 0); + } else { + // the dividend here is 2**(floor_log_2_d + 63), so the low 64 bit word + // is 0 and the high word is floor_log_2_d - 1 + uint8_t more; + uint64_t rem, proposed_m; + proposed_m = libdivide_128_div_64_to_64(1ULL << (floor_log_2_d - 1), 0, absD, &rem); + const uint64_t e = absD - rem; + + // We are going to start with a power of floor_log_2_d - 1. + // This works if works if e < 2**floor_log_2_d. + if (!branchfree && e < (1ULL << floor_log_2_d)) { + // This power works + more = floor_log_2_d - 1; + } else { + // We need to go one higher. This should not make proposed_m + // overflow, but it will make it negative when interpreted as an + // int32_t. + proposed_m += proposed_m; + const uint64_t twice_rem = rem + rem; + if (twice_rem >= absD || twice_rem < rem) proposed_m += 1; + // note that we only set the LIBDIVIDE_NEGATIVE_DIVISOR bit if we + // also set ADD_MARKER this is an annoying optimization that + // enables algorithm #4 to avoid the mask. However we always set it + // in the branchfree case + more = floor_log_2_d | LIBDIVIDE_ADD_MARKER; + } + proposed_m += 1; + int64_t magic = (int64_t)proposed_m; + + // Mark if we are negative + if (d < 0) { + more |= LIBDIVIDE_NEGATIVE_DIVISOR; + if (!branchfree) { + magic = -magic; + } + } + + result.more = more; + result.magic = magic; + } + return result; +} + +struct libdivide_s64_t libdivide_s64_gen(int64_t d) { + return libdivide_internal_s64_gen(d, 0); +} + +struct libdivide_s64_branchfree_t libdivide_s64_branchfree_gen(int64_t d) { + struct libdivide_s64_t tmp = libdivide_internal_s64_gen(d, 1); + struct libdivide_s64_branchfree_t ret = {tmp.magic, tmp.more}; + return ret; +} + +int64_t libdivide_s64_do(int64_t numer, const struct libdivide_s64_t *denom) { + uint8_t more = denom->more; + uint8_t shift = more & LIBDIVIDE_64_SHIFT_MASK; + + if (!denom->magic) { // shift path + uint64_t mask = (1ULL << shift) - 1; + uint64_t uq = numer + ((numer >> 63) & mask); + int64_t q = (int64_t)uq; + q >>= shift; + // must be arithmetic shift and then sign-extend + int64_t sign = (int8_t)more >> 7; + q = (q ^ sign) - sign; + return q; + } else { + uint64_t uq = (uint64_t)libdivide_mullhi_s64(denom->magic, numer); + if (more & LIBDIVIDE_ADD_MARKER) { + // must be arithmetic shift and then sign extend + int64_t sign = (int8_t)more >> 7; + // q += (more < 0 ? -numer : numer) + // cast required to avoid UB + uq += ((uint64_t)numer ^ sign) - sign; + } + int64_t q = (int64_t)uq; + q >>= shift; + q += (q < 0); + return q; + } +} + +int64_t libdivide_s64_branchfree_do(int64_t numer, const struct libdivide_s64_branchfree_t *denom) { + uint8_t more = denom->more; + uint8_t shift = more & LIBDIVIDE_64_SHIFT_MASK; + // must be arithmetic shift and then sign extend + int64_t sign = (int8_t)more >> 7; + int64_t magic = denom->magic; + int64_t q = libdivide_mullhi_s64(magic, numer); + q += numer; + + // If q is non-negative, we have nothing to do. + // If q is negative, we want to add either (2**shift)-1 if d is a power of + // 2, or (2**shift) if it is not a power of 2. + uint64_t is_power_of_2 = (magic == 0); + uint64_t q_sign = (uint64_t)(q >> 63); + q += q_sign & ((1ULL << shift) - is_power_of_2); + + // Arithmetic right shift + q >>= shift; + // Negate if needed + q = (q ^ sign) - sign; + + return q; +} + +int64_t libdivide_s64_recover(const struct libdivide_s64_t *denom) { + uint8_t more = denom->more; + uint8_t shift = more & LIBDIVIDE_64_SHIFT_MASK; + if (denom->magic == 0) { // shift path + uint64_t absD = 1ULL << shift; + if (more & LIBDIVIDE_NEGATIVE_DIVISOR) { + absD = -absD; + } + return (int64_t)absD; + } else { + // Unsigned math is much easier + int negative_divisor = (more & LIBDIVIDE_NEGATIVE_DIVISOR); + int magic_was_negated = (more & LIBDIVIDE_ADD_MARKER) + ? denom->magic > 0 : denom->magic < 0; + + uint64_t d = (uint64_t)(magic_was_negated ? -denom->magic : denom->magic); + uint64_t n_hi = 1ULL << shift, n_lo = 0; + uint64_t rem_ignored; + uint64_t q = libdivide_128_div_64_to_64(n_hi, n_lo, d, &rem_ignored); + int64_t result = (int64_t)(q + 1); + if (negative_divisor) { + result = -result; + } + return result; + } +} + +int64_t libdivide_s64_branchfree_recover(const struct libdivide_s64_branchfree_t *denom) { + return libdivide_s64_recover((const struct libdivide_s64_t *)denom); +}*/ + +#if defined(LIBDIVIDE_AVX512) + +static inline __m512i libdivide_u32_do_vector(__m512i numers, const struct libdivide_u32_t *denom); +static inline __m512i libdivide_s32_do_vector(__m512i numers, const struct libdivide_s32_t *denom); +static inline __m512i libdivide_u64_do_vector(__m512i numers, const struct libdivide_u64_t *denom); +static inline __m512i libdivide_s64_do_vector(__m512i numers, const struct libdivide_s64_t *denom); + +static inline __m512i libdivide_u32_branchfree_do_vector(__m512i numers, const struct libdivide_u32_branchfree_t *denom); +static inline __m512i libdivide_s32_branchfree_do_vector(__m512i numers, const struct libdivide_s32_branchfree_t *denom); +static inline __m512i libdivide_u64_branchfree_do_vector(__m512i numers, const struct libdivide_u64_branchfree_t *denom); +static inline __m512i libdivide_s64_branchfree_do_vector(__m512i numers, const struct libdivide_s64_branchfree_t *denom); + +//////// Internal Utility Functions + +static inline __m512i libdivide_s64_signbits(__m512i v) {; + return _mm512_srai_epi64(v, 63); +} + +static inline __m512i libdivide_s64_shift_right_vector(__m512i v, int amt) { + return _mm512_srai_epi64(v, amt); +} + +// Here, b is assumed to contain one 32-bit value repeated. +static inline __m512i libdivide_mullhi_u32_vector(__m512i a, __m512i b) { + __m512i hi_product_0Z2Z = _mm512_srli_epi64(_mm512_mul_epu32(a, b), 32); + __m512i a1X3X = _mm512_srli_epi64(a, 32); + __m512i mask = _mm512_set_epi32(-1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0); + __m512i hi_product_Z1Z3 = _mm512_and_si512(_mm512_mul_epu32(a1X3X, b), mask); + return _mm512_or_si512(hi_product_0Z2Z, hi_product_Z1Z3); +} + +// b is one 32-bit value repeated. +static inline __m512i libdivide_mullhi_s32_vector(__m512i a, __m512i b) { + __m512i hi_product_0Z2Z = _mm512_srli_epi64(_mm512_mul_epi32(a, b), 32); + __m512i a1X3X = _mm512_srli_epi64(a, 32); + __m512i mask = _mm512_set_epi32(-1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0); + __m512i hi_product_Z1Z3 = _mm512_and_si512(_mm512_mul_epi32(a1X3X, b), mask); + return _mm512_or_si512(hi_product_0Z2Z, hi_product_Z1Z3); +} + +// Here, y is assumed to contain one 64-bit value repeated. +// https://stackoverflow.com/a/28827013 +static inline __m512i libdivide_mullhi_u64_vector(__m512i x, __m512i y) { + __m512i lomask = _mm512_set1_epi64(0xffffffff); + __m512i xh = _mm512_shuffle_epi32(x, (_MM_PERM_ENUM) 0xB1); + __m512i yh = _mm512_shuffle_epi32(y, (_MM_PERM_ENUM) 0xB1); + __m512i w0 = _mm512_mul_epu32(x, y); + __m512i w1 = _mm512_mul_epu32(x, yh); + __m512i w2 = _mm512_mul_epu32(xh, y); + __m512i w3 = _mm512_mul_epu32(xh, yh); + __m512i w0h = _mm512_srli_epi64(w0, 32); + __m512i s1 = _mm512_add_epi64(w1, w0h); + __m512i s1l = _mm512_and_si512(s1, lomask); + __m512i s1h = _mm512_srli_epi64(s1, 32); + __m512i s2 = _mm512_add_epi64(w2, s1l); + __m512i s2h = _mm512_srli_epi64(s2, 32); + __m512i hi = _mm512_add_epi64(w3, s1h); + hi = _mm512_add_epi64(hi, s2h); + + return hi; +} + +// y is one 64-bit value repeated. +static inline __m512i libdivide_mullhi_s64_vector(__m512i x, __m512i y) { + __m512i p = libdivide_mullhi_u64_vector(x, y); + __m512i t1 = _mm512_and_si512(libdivide_s64_signbits(x), y); + __m512i t2 = _mm512_and_si512(libdivide_s64_signbits(y), x); + p = _mm512_sub_epi64(p, t1); + p = _mm512_sub_epi64(p, t2); + return p; +} + +////////// UINT32 + +__m512i libdivide_u32_do_vector(__m512i numers, const struct libdivide_u32_t *denom) { + uint8_t more = denom->more; + if (!denom->magic) { + return _mm512_srli_epi32(numers, more); + } + else { + __m512i q = libdivide_mullhi_u32_vector(numers, _mm512_set1_epi32(denom->magic)); + if (more & LIBDIVIDE_ADD_MARKER) { + // uint32_t t = ((numer - q) >> 1) + q; + // return t >> denom->shift; + uint32_t shift = more & LIBDIVIDE_32_SHIFT_MASK; + __m512i t = _mm512_add_epi32(_mm512_srli_epi32(_mm512_sub_epi32(numers, q), 1), q); + return _mm512_srli_epi32(t, shift); + } + else { + return _mm512_srli_epi32(q, more); + } + } +} + +__m512i libdivide_u32_branchfree_do_vector(__m512i numers, const struct libdivide_u32_branchfree_t *denom) { + __m512i q = libdivide_mullhi_u32_vector(numers, _mm512_set1_epi32(denom->magic)); + __m512i t = _mm512_add_epi32(_mm512_srli_epi32(_mm512_sub_epi32(numers, q), 1), q); + return _mm512_srli_epi32(t, denom->more); +} + +////////// UINT64 + +__m512i libdivide_u64_do_vector(__m512i numers, const struct libdivide_u64_t *denom) { + uint8_t more = denom->more; + if (!denom->magic) { + return _mm512_srli_epi64(numers, more); + } + else { + __m512i q = libdivide_mullhi_u64_vector(numers, _mm512_set1_epi64(denom->magic)); + if (more & LIBDIVIDE_ADD_MARKER) { + // uint32_t t = ((numer - q) >> 1) + q; + // return t >> denom->shift; + uint32_t shift = more & LIBDIVIDE_64_SHIFT_MASK; + __m512i t = _mm512_add_epi64(_mm512_srli_epi64(_mm512_sub_epi64(numers, q), 1), q); + return _mm512_srli_epi64(t, shift); + } + else { + return _mm512_srli_epi64(q, more); + } + } +} + +__m512i libdivide_u64_branchfree_do_vector(__m512i numers, const struct libdivide_u64_branchfree_t *denom) { + __m512i q = libdivide_mullhi_u64_vector(numers, _mm512_set1_epi64(denom->magic)); + __m512i t = _mm512_add_epi64(_mm512_srli_epi64(_mm512_sub_epi64(numers, q), 1), q); + return _mm512_srli_epi64(t, denom->more); +} + +////////// SINT32 + +__m512i libdivide_s32_do_vector(__m512i numers, const struct libdivide_s32_t *denom) { + uint8_t more = denom->more; + if (!denom->magic) { + uint32_t shift = more & LIBDIVIDE_32_SHIFT_MASK; + uint32_t mask = (1U << shift) - 1; + __m512i roundToZeroTweak = _mm512_set1_epi32(mask); + // q = numer + ((numer >> 31) & roundToZeroTweak); + __m512i q = _mm512_add_epi32(numers, _mm512_and_si512(_mm512_srai_epi32(numers, 31), roundToZeroTweak)); + q = _mm512_srai_epi32(q, shift); + __m512i sign = _mm512_set1_epi32((int8_t)more >> 7); + // q = (q ^ sign) - sign; + q = _mm512_sub_epi32(_mm512_xor_si512(q, sign), sign); + return q; + } + else { + __m512i q = libdivide_mullhi_s32_vector(numers, _mm512_set1_epi32(denom->magic)); + if (more & LIBDIVIDE_ADD_MARKER) { + // must be arithmetic shift + __m512i sign = _mm512_set1_epi32((int8_t)more >> 7); + // q += ((numer ^ sign) - sign); + q = _mm512_add_epi32(q, _mm512_sub_epi32(_mm512_xor_si512(numers, sign), sign)); + } + // q >>= shift + q = _mm512_srai_epi32(q, more & LIBDIVIDE_32_SHIFT_MASK); + q = _mm512_add_epi32(q, _mm512_srli_epi32(q, 31)); // q += (q < 0) + return q; + } +} + +__m512i libdivide_s32_branchfree_do_vector(__m512i numers, const struct libdivide_s32_branchfree_t *denom) { + int32_t magic = denom->magic; + uint8_t more = denom->more; + uint8_t shift = more & LIBDIVIDE_32_SHIFT_MASK; + // must be arithmetic shift + __m512i sign = _mm512_set1_epi32((int8_t)more >> 7); + __m512i q = libdivide_mullhi_s32_vector(numers, _mm512_set1_epi32(magic)); + q = _mm512_add_epi32(q, numers); // q += numers + + // If q is non-negative, we have nothing to do + // If q is negative, we want to add either (2**shift)-1 if d is + // a power of 2, or (2**shift) if it is not a power of 2 + uint32_t is_power_of_2 = (magic == 0); + __m512i q_sign = _mm512_srai_epi32(q, 31); // q_sign = q >> 31 + __m512i mask = _mm512_set1_epi32((1U << shift) - is_power_of_2); + q = _mm512_add_epi32(q, _mm512_and_si512(q_sign, mask)); // q = q + (q_sign & mask) + q = _mm512_srai_epi32(q, shift); // q >>= shift + q = _mm512_sub_epi32(_mm512_xor_si512(q, sign), sign); // q = (q ^ sign) - sign + return q; +} + +////////// SINT64 + +__m512i libdivide_s64_do_vector(__m512i numers, const struct libdivide_s64_t *denom) { + uint8_t more = denom->more; + int64_t magic = denom->magic; + if (magic == 0) { // shift path + uint32_t shift = more & LIBDIVIDE_64_SHIFT_MASK; + uint64_t mask = (1ULL << shift) - 1; + __m512i roundToZeroTweak = _mm512_set1_epi64(mask); + // q = numer + ((numer >> 63) & roundToZeroTweak); + __m512i q = _mm512_add_epi64(numers, _mm512_and_si512(libdivide_s64_signbits(numers), roundToZeroTweak)); + q = libdivide_s64_shift_right_vector(q, shift); + __m512i sign = _mm512_set1_epi32((int8_t)more >> 7); + // q = (q ^ sign) - sign; + q = _mm512_sub_epi64(_mm512_xor_si512(q, sign), sign); + return q; + } + else { + __m512i q = libdivide_mullhi_s64_vector(numers, _mm512_set1_epi64(magic)); + if (more & LIBDIVIDE_ADD_MARKER) { + // must be arithmetic shift + __m512i sign = _mm512_set1_epi32((int8_t)more >> 7); + // q += ((numer ^ sign) - sign); + q = _mm512_add_epi64(q, _mm512_sub_epi64(_mm512_xor_si512(numers, sign), sign)); + } + // q >>= denom->mult_path.shift + q = libdivide_s64_shift_right_vector(q, more & LIBDIVIDE_64_SHIFT_MASK); + q = _mm512_add_epi64(q, _mm512_srli_epi64(q, 63)); // q += (q < 0) + return q; + } +} + +__m512i libdivide_s64_branchfree_do_vector(__m512i numers, const struct libdivide_s64_branchfree_t *denom) { + int64_t magic = denom->magic; + uint8_t more = denom->more; + uint8_t shift = more & LIBDIVIDE_64_SHIFT_MASK; + // must be arithmetic shift + __m512i sign = _mm512_set1_epi32((int8_t)more >> 7); + + // libdivide_mullhi_s64(numers, magic); + __m512i q = libdivide_mullhi_s64_vector(numers, _mm512_set1_epi64(magic)); + q = _mm512_add_epi64(q, numers); // q += numers + + // If q is non-negative, we have nothing to do. + // If q is negative, we want to add either (2**shift)-1 if d is + // a power of 2, or (2**shift) if it is not a power of 2. + uint32_t is_power_of_2 = (magic == 0); + __m512i q_sign = libdivide_s64_signbits(q); // q_sign = q >> 63 + __m512i mask = _mm512_set1_epi64((1ULL << shift) - is_power_of_2); + q = _mm512_add_epi64(q, _mm512_and_si512(q_sign, mask)); // q = q + (q_sign & mask) + q = libdivide_s64_shift_right_vector(q, shift); // q >>= shift + q = _mm512_sub_epi64(_mm512_xor_si512(q, sign), sign); // q = (q ^ sign) - sign + return q; +} + +#elif defined(LIBDIVIDE_AVX2) + +static inline __m256i libdivide_u32_do_vector(__m256i numers, const struct libdivide_u32_t *denom); +static inline __m256i libdivide_s32_do_vector(__m256i numers, const struct libdivide_s32_t *denom); +static inline __m256i libdivide_u64_do_vector(__m256i numers, const struct libdivide_u64_t *denom); +static inline __m256i libdivide_s64_do_vector(__m256i numers, const struct libdivide_s64_t *denom); + +static inline __m256i libdivide_u32_branchfree_do_vector(__m256i numers, const struct libdivide_u32_branchfree_t *denom); +static inline __m256i libdivide_s32_branchfree_do_vector(__m256i numers, const struct libdivide_s32_branchfree_t *denom); +static inline __m256i libdivide_u64_branchfree_do_vector(__m256i numers, const struct libdivide_u64_branchfree_t *denom); +static inline __m256i libdivide_s64_branchfree_do_vector(__m256i numers, const struct libdivide_s64_branchfree_t *denom); + +//////// Internal Utility Functions + +// Implementation of _mm256_srai_epi64(v, 63) (from AVX512). +static inline __m256i libdivide_s64_signbits(__m256i v) { + __m256i hiBitsDuped = _mm256_shuffle_epi32(v, _MM_SHUFFLE(3, 3, 1, 1)); + __m256i signBits = _mm256_srai_epi32(hiBitsDuped, 31); + return signBits; +} + +// Implementation of _mm256_srai_epi64 (from AVX512). +static inline __m256i libdivide_s64_shift_right_vector(__m256i v, int amt) { + const int b = 64 - amt; + __m256i m = _mm256_set1_epi64x(1ULL << (b - 1)); + __m256i x = _mm256_srli_epi64(v, amt); + __m256i result = _mm256_sub_epi64(_mm256_xor_si256(x, m), m); + return result; +} + +// Here, b is assumed to contain one 32-bit value repeated. +static inline __m256i libdivide_mullhi_u32_vector(__m256i a, __m256i b) { + __m256i hi_product_0Z2Z = _mm256_srli_epi64(_mm256_mul_epu32(a, b), 32); + __m256i a1X3X = _mm256_srli_epi64(a, 32); + __m256i mask = _mm256_set_epi32(-1, 0, -1, 0, -1, 0, -1, 0); + __m256i hi_product_Z1Z3 = _mm256_and_si256(_mm256_mul_epu32(a1X3X, b), mask); + return _mm256_or_si256(hi_product_0Z2Z, hi_product_Z1Z3); +} + +// b is one 32-bit value repeated. +static inline __m256i libdivide_mullhi_s32_vector(__m256i a, __m256i b) { + __m256i hi_product_0Z2Z = _mm256_srli_epi64(_mm256_mul_epi32(a, b), 32); + __m256i a1X3X = _mm256_srli_epi64(a, 32); + __m256i mask = _mm256_set_epi32(-1, 0, -1, 0, -1, 0, -1, 0); + __m256i hi_product_Z1Z3 = _mm256_and_si256(_mm256_mul_epi32(a1X3X, b), mask); + return _mm256_or_si256(hi_product_0Z2Z, hi_product_Z1Z3); +} + +// Here, y is assumed to contain one 64-bit value repeated. +// https://stackoverflow.com/a/28827013 +static inline __m256i libdivide_mullhi_u64_vector(__m256i x, __m256i y) { + __m256i lomask = _mm256_set1_epi64x(0xffffffff); + __m256i xh = _mm256_shuffle_epi32(x, 0xB1); // x0l, x0h, x1l, x1h + __m256i yh = _mm256_shuffle_epi32(y, 0xB1); // y0l, y0h, y1l, y1h + __m256i w0 = _mm256_mul_epu32(x, y); // x0l*y0l, x1l*y1l + __m256i w1 = _mm256_mul_epu32(x, yh); // x0l*y0h, x1l*y1h + __m256i w2 = _mm256_mul_epu32(xh, y); // x0h*y0l, x1h*y0l + __m256i w3 = _mm256_mul_epu32(xh, yh); // x0h*y0h, x1h*y1h + __m256i w0h = _mm256_srli_epi64(w0, 32); + __m256i s1 = _mm256_add_epi64(w1, w0h); + __m256i s1l = _mm256_and_si256(s1, lomask); + __m256i s1h = _mm256_srli_epi64(s1, 32); + __m256i s2 = _mm256_add_epi64(w2, s1l); + __m256i s2h = _mm256_srli_epi64(s2, 32); + __m256i hi = _mm256_add_epi64(w3, s1h); + hi = _mm256_add_epi64(hi, s2h); + + return hi; +} + +// y is one 64-bit value repeated. +static inline __m256i libdivide_mullhi_s64_vector(__m256i x, __m256i y) { + __m256i p = libdivide_mullhi_u64_vector(x, y); + __m256i t1 = _mm256_and_si256(libdivide_s64_signbits(x), y); + __m256i t2 = _mm256_and_si256(libdivide_s64_signbits(y), x); + p = _mm256_sub_epi64(p, t1); + p = _mm256_sub_epi64(p, t2); + return p; +} + +////////// UINT32 + +__m256i libdivide_u32_do_vector(__m256i numers, const struct libdivide_u32_t *denom) { + uint8_t more = denom->more; + if (!denom->magic) { + return _mm256_srli_epi32(numers, more); + } + else { + __m256i q = libdivide_mullhi_u32_vector(numers, _mm256_set1_epi32(denom->magic)); + if (more & LIBDIVIDE_ADD_MARKER) { + // uint32_t t = ((numer - q) >> 1) + q; + // return t >> denom->shift; + uint32_t shift = more & LIBDIVIDE_32_SHIFT_MASK; + __m256i t = _mm256_add_epi32(_mm256_srli_epi32(_mm256_sub_epi32(numers, q), 1), q); + return _mm256_srli_epi32(t, shift); + } + else { + return _mm256_srli_epi32(q, more); + } + } +} + +__m256i libdivide_u32_branchfree_do_vector(__m256i numers, const struct libdivide_u32_branchfree_t *denom) { + __m256i q = libdivide_mullhi_u32_vector(numers, _mm256_set1_epi32(denom->magic)); + __m256i t = _mm256_add_epi32(_mm256_srli_epi32(_mm256_sub_epi32(numers, q), 1), q); + return _mm256_srli_epi32(t, denom->more); +} + +////////// UINT64 + +__m256i libdivide_u64_do_vector(__m256i numers, const struct libdivide_u64_t *denom) { + uint8_t more = denom->more; + if (!denom->magic) { + return _mm256_srli_epi64(numers, more); + } + else { + __m256i q = libdivide_mullhi_u64_vector(numers, _mm256_set1_epi64x(denom->magic)); + if (more & LIBDIVIDE_ADD_MARKER) { + // uint32_t t = ((numer - q) >> 1) + q; + // return t >> denom->shift; + uint32_t shift = more & LIBDIVIDE_64_SHIFT_MASK; + __m256i t = _mm256_add_epi64(_mm256_srli_epi64(_mm256_sub_epi64(numers, q), 1), q); + return _mm256_srli_epi64(t, shift); + } + else { + return _mm256_srli_epi64(q, more); + } + } +} + +__m256i libdivide_u64_branchfree_do_vector(__m256i numers, const struct libdivide_u64_branchfree_t *denom) { + __m256i q = libdivide_mullhi_u64_vector(numers, _mm256_set1_epi64x(denom->magic)); + __m256i t = _mm256_add_epi64(_mm256_srli_epi64(_mm256_sub_epi64(numers, q), 1), q); + return _mm256_srli_epi64(t, denom->more); +} + +////////// SINT32 + +__m256i libdivide_s32_do_vector(__m256i numers, const struct libdivide_s32_t *denom) { + uint8_t more = denom->more; + if (!denom->magic) { + uint32_t shift = more & LIBDIVIDE_32_SHIFT_MASK; + uint32_t mask = (1U << shift) - 1; + __m256i roundToZeroTweak = _mm256_set1_epi32(mask); + // q = numer + ((numer >> 31) & roundToZeroTweak); + __m256i q = _mm256_add_epi32(numers, _mm256_and_si256(_mm256_srai_epi32(numers, 31), roundToZeroTweak)); + q = _mm256_srai_epi32(q, shift); + __m256i sign = _mm256_set1_epi32((int8_t)more >> 7); + // q = (q ^ sign) - sign; + q = _mm256_sub_epi32(_mm256_xor_si256(q, sign), sign); + return q; + } + else { + __m256i q = libdivide_mullhi_s32_vector(numers, _mm256_set1_epi32(denom->magic)); + if (more & LIBDIVIDE_ADD_MARKER) { + // must be arithmetic shift + __m256i sign = _mm256_set1_epi32((int8_t)more >> 7); + // q += ((numer ^ sign) - sign); + q = _mm256_add_epi32(q, _mm256_sub_epi32(_mm256_xor_si256(numers, sign), sign)); + } + // q >>= shift + q = _mm256_srai_epi32(q, more & LIBDIVIDE_32_SHIFT_MASK); + q = _mm256_add_epi32(q, _mm256_srli_epi32(q, 31)); // q += (q < 0) + return q; + } +} + +__m256i libdivide_s32_branchfree_do_vector(__m256i numers, const struct libdivide_s32_branchfree_t *denom) { + int32_t magic = denom->magic; + uint8_t more = denom->more; + uint8_t shift = more & LIBDIVIDE_32_SHIFT_MASK; + // must be arithmetic shift + __m256i sign = _mm256_set1_epi32((int8_t)more >> 7); + __m256i q = libdivide_mullhi_s32_vector(numers, _mm256_set1_epi32(magic)); + q = _mm256_add_epi32(q, numers); // q += numers + + // If q is non-negative, we have nothing to do + // If q is negative, we want to add either (2**shift)-1 if d is + // a power of 2, or (2**shift) if it is not a power of 2 + uint32_t is_power_of_2 = (magic == 0); + __m256i q_sign = _mm256_srai_epi32(q, 31); // q_sign = q >> 31 + __m256i mask = _mm256_set1_epi32((1U << shift) - is_power_of_2); + q = _mm256_add_epi32(q, _mm256_and_si256(q_sign, mask)); // q = q + (q_sign & mask) + q = _mm256_srai_epi32(q, shift); // q >>= shift + q = _mm256_sub_epi32(_mm256_xor_si256(q, sign), sign); // q = (q ^ sign) - sign + return q; +} + +////////// SINT64 + +__m256i libdivide_s64_do_vector(__m256i numers, const struct libdivide_s64_t *denom) { + uint8_t more = denom->more; + int64_t magic = denom->magic; + if (magic == 0) { // shift path + uint32_t shift = more & LIBDIVIDE_64_SHIFT_MASK; + uint64_t mask = (1ULL << shift) - 1; + __m256i roundToZeroTweak = _mm256_set1_epi64x(mask); + // q = numer + ((numer >> 63) & roundToZeroTweak); + __m256i q = _mm256_add_epi64(numers, _mm256_and_si256(libdivide_s64_signbits(numers), roundToZeroTweak)); + q = libdivide_s64_shift_right_vector(q, shift); + __m256i sign = _mm256_set1_epi32((int8_t)more >> 7); + // q = (q ^ sign) - sign; + q = _mm256_sub_epi64(_mm256_xor_si256(q, sign), sign); + return q; + } + else { + __m256i q = libdivide_mullhi_s64_vector(numers, _mm256_set1_epi64x(magic)); + if (more & LIBDIVIDE_ADD_MARKER) { + // must be arithmetic shift + __m256i sign = _mm256_set1_epi32((int8_t)more >> 7); + // q += ((numer ^ sign) - sign); + q = _mm256_add_epi64(q, _mm256_sub_epi64(_mm256_xor_si256(numers, sign), sign)); + } + // q >>= denom->mult_path.shift + q = libdivide_s64_shift_right_vector(q, more & LIBDIVIDE_64_SHIFT_MASK); + q = _mm256_add_epi64(q, _mm256_srli_epi64(q, 63)); // q += (q < 0) + return q; + } +} + +__m256i libdivide_s64_branchfree_do_vector(__m256i numers, const struct libdivide_s64_branchfree_t *denom) { + int64_t magic = denom->magic; + uint8_t more = denom->more; + uint8_t shift = more & LIBDIVIDE_64_SHIFT_MASK; + // must be arithmetic shift + __m256i sign = _mm256_set1_epi32((int8_t)more >> 7); + + // libdivide_mullhi_s64(numers, magic); + __m256i q = libdivide_mullhi_s64_vector(numers, _mm256_set1_epi64x(magic)); + q = _mm256_add_epi64(q, numers); // q += numers + + // If q is non-negative, we have nothing to do. + // If q is negative, we want to add either (2**shift)-1 if d is + // a power of 2, or (2**shift) if it is not a power of 2. + uint32_t is_power_of_2 = (magic == 0); + __m256i q_sign = libdivide_s64_signbits(q); // q_sign = q >> 63 + __m256i mask = _mm256_set1_epi64x((1ULL << shift) - is_power_of_2); + q = _mm256_add_epi64(q, _mm256_and_si256(q_sign, mask)); // q = q + (q_sign & mask) + q = libdivide_s64_shift_right_vector(q, shift); // q >>= shift + q = _mm256_sub_epi64(_mm256_xor_si256(q, sign), sign); // q = (q ^ sign) - sign + return q; +} + +#elif defined(LIBDIVIDE_SSE2) + +static inline __m128i libdivide_u32_do_vector(__m128i numers, const struct libdivide_u32_t *denom); +static inline __m128i libdivide_s32_do_vector(__m128i numers, const struct libdivide_s32_t *denom); +static inline __m128i libdivide_u64_do_vector(__m128i numers, const struct libdivide_u64_t *denom); +static inline __m128i libdivide_s64_do_vector(__m128i numers, const struct libdivide_s64_t *denom); + +static inline __m128i libdivide_u32_branchfree_do_vector(__m128i numers, const struct libdivide_u32_branchfree_t *denom); +static inline __m128i libdivide_s32_branchfree_do_vector(__m128i numers, const struct libdivide_s32_branchfree_t *denom); +static inline __m128i libdivide_u64_branchfree_do_vector(__m128i numers, const struct libdivide_u64_branchfree_t *denom); +static inline __m128i libdivide_s64_branchfree_do_vector(__m128i numers, const struct libdivide_s64_branchfree_t *denom); + +//////// Internal Utility Functions + +// Implementation of _mm_srai_epi64(v, 63) (from AVX512). +static inline __m128i libdivide_s64_signbits(__m128i v) { + __m128i hiBitsDuped = _mm_shuffle_epi32(v, _MM_SHUFFLE(3, 3, 1, 1)); + __m128i signBits = _mm_srai_epi32(hiBitsDuped, 31); + return signBits; +} + +// Implementation of _mm_srai_epi64 (from AVX512). +static inline __m128i libdivide_s64_shift_right_vector(__m128i v, int amt) { + const int b = 64 - amt; + __m128i m = _mm_set1_epi64x(1ULL << (b - 1)); + __m128i x = _mm_srli_epi64(v, amt); + __m128i result = _mm_sub_epi64(_mm_xor_si128(x, m), m); + return result; +} + +// Here, b is assumed to contain one 32-bit value repeated. +static inline __m128i libdivide_mullhi_u32_vector(__m128i a, __m128i b) { + __m128i hi_product_0Z2Z = _mm_srli_epi64(_mm_mul_epu32(a, b), 32); + __m128i a1X3X = _mm_srli_epi64(a, 32); + __m128i mask = _mm_set_epi32(-1, 0, -1, 0); + __m128i hi_product_Z1Z3 = _mm_and_si128(_mm_mul_epu32(a1X3X, b), mask); + return _mm_or_si128(hi_product_0Z2Z, hi_product_Z1Z3); +} + +// SSE2 does not have a signed multiplication instruction, but we can convert +// unsigned to signed pretty efficiently. Again, b is just a 32 bit value +// repeated four times. +static inline __m128i libdivide_mullhi_s32_vector(__m128i a, __m128i b) { + __m128i p = libdivide_mullhi_u32_vector(a, b); + // t1 = (a >> 31) & y, arithmetic shift + __m128i t1 = _mm_and_si128(_mm_srai_epi32(a, 31), b); + __m128i t2 = _mm_and_si128(_mm_srai_epi32(b, 31), a); + p = _mm_sub_epi32(p, t1); + p = _mm_sub_epi32(p, t2); + return p; +} + +// Here, y is assumed to contain one 64-bit value repeated. +// https://stackoverflow.com/a/28827013 +static inline __m128i libdivide_mullhi_u64_vector(__m128i x, __m128i y) { + __m128i lomask = _mm_set1_epi64x(0xffffffff); + __m128i xh = _mm_shuffle_epi32(x, 0xB1); // x0l, x0h, x1l, x1h + __m128i yh = _mm_shuffle_epi32(y, 0xB1); // y0l, y0h, y1l, y1h + __m128i w0 = _mm_mul_epu32(x, y); // x0l*y0l, x1l*y1l + __m128i w1 = _mm_mul_epu32(x, yh); // x0l*y0h, x1l*y1h + __m128i w2 = _mm_mul_epu32(xh, y); // x0h*y0l, x1h*y0l + __m128i w3 = _mm_mul_epu32(xh, yh); // x0h*y0h, x1h*y1h + __m128i w0h = _mm_srli_epi64(w0, 32); + __m128i s1 = _mm_add_epi64(w1, w0h); + __m128i s1l = _mm_and_si128(s1, lomask); + __m128i s1h = _mm_srli_epi64(s1, 32); + __m128i s2 = _mm_add_epi64(w2, s1l); + __m128i s2h = _mm_srli_epi64(s2, 32); + __m128i hi = _mm_add_epi64(w3, s1h); + hi = _mm_add_epi64(hi, s2h); + + return hi; +} + +// y is one 64-bit value repeated. +static inline __m128i libdivide_mullhi_s64_vector(__m128i x, __m128i y) { + __m128i p = libdivide_mullhi_u64_vector(x, y); + __m128i t1 = _mm_and_si128(libdivide_s64_signbits(x), y); + __m128i t2 = _mm_and_si128(libdivide_s64_signbits(y), x); + p = _mm_sub_epi64(p, t1); + p = _mm_sub_epi64(p, t2); + return p; +} + +////////// UINT32 + +__m128i libdivide_u32_do_vector(__m128i numers, const struct libdivide_u32_t *denom) { + uint8_t more = denom->more; + if (!denom->magic) { + return _mm_srli_epi32(numers, more); + } + else { + __m128i q = libdivide_mullhi_u32_vector(numers, _mm_set1_epi32(denom->magic)); + if (more & LIBDIVIDE_ADD_MARKER) { + // uint32_t t = ((numer - q) >> 1) + q; + // return t >> denom->shift; + uint32_t shift = more & LIBDIVIDE_32_SHIFT_MASK; + __m128i t = _mm_add_epi32(_mm_srli_epi32(_mm_sub_epi32(numers, q), 1), q); + return _mm_srli_epi32(t, shift); + } + else { + return _mm_srli_epi32(q, more); + } + } +} + +__m128i libdivide_u32_branchfree_do_vector(__m128i numers, const struct libdivide_u32_branchfree_t *denom) { + __m128i q = libdivide_mullhi_u32_vector(numers, _mm_set1_epi32(denom->magic)); + __m128i t = _mm_add_epi32(_mm_srli_epi32(_mm_sub_epi32(numers, q), 1), q); + return _mm_srli_epi32(t, denom->more); +} + +////////// UINT64 + +__m128i libdivide_u64_do_vector(__m128i numers, const struct libdivide_u64_t *denom) { + uint8_t more = denom->more; + if (!denom->magic) { + return _mm_srli_epi64(numers, more); + } + else { + __m128i q = libdivide_mullhi_u64_vector(numers, _mm_set1_epi64x(denom->magic)); + if (more & LIBDIVIDE_ADD_MARKER) { + // uint32_t t = ((numer - q) >> 1) + q; + // return t >> denom->shift; + uint32_t shift = more & LIBDIVIDE_64_SHIFT_MASK; + __m128i t = _mm_add_epi64(_mm_srli_epi64(_mm_sub_epi64(numers, q), 1), q); + return _mm_srli_epi64(t, shift); + } + else { + return _mm_srli_epi64(q, more); + } + } +} + +__m128i libdivide_u64_branchfree_do_vector(__m128i numers, const struct libdivide_u64_branchfree_t *denom) { + __m128i q = libdivide_mullhi_u64_vector(numers, _mm_set1_epi64x(denom->magic)); + __m128i t = _mm_add_epi64(_mm_srli_epi64(_mm_sub_epi64(numers, q), 1), q); + return _mm_srli_epi64(t, denom->more); +} + +////////// SINT32 + +__m128i libdivide_s32_do_vector(__m128i numers, const struct libdivide_s32_t *denom) { + uint8_t more = denom->more; + if (!denom->magic) { + uint32_t shift = more & LIBDIVIDE_32_SHIFT_MASK; + uint32_t mask = (1U << shift) - 1; + __m128i roundToZeroTweak = _mm_set1_epi32(mask); + // q = numer + ((numer >> 31) & roundToZeroTweak); + __m128i q = _mm_add_epi32(numers, _mm_and_si128(_mm_srai_epi32(numers, 31), roundToZeroTweak)); + q = _mm_srai_epi32(q, shift); + __m128i sign = _mm_set1_epi32((int8_t)more >> 7); + // q = (q ^ sign) - sign; + q = _mm_sub_epi32(_mm_xor_si128(q, sign), sign); + return q; + } + else { + __m128i q = libdivide_mullhi_s32_vector(numers, _mm_set1_epi32(denom->magic)); + if (more & LIBDIVIDE_ADD_MARKER) { + // must be arithmetic shift + __m128i sign = _mm_set1_epi32((int8_t)more >> 7); + // q += ((numer ^ sign) - sign); + q = _mm_add_epi32(q, _mm_sub_epi32(_mm_xor_si128(numers, sign), sign)); + } + // q >>= shift + q = _mm_srai_epi32(q, more & LIBDIVIDE_32_SHIFT_MASK); + q = _mm_add_epi32(q, _mm_srli_epi32(q, 31)); // q += (q < 0) + return q; + } +} + +__m128i libdivide_s32_branchfree_do_vector(__m128i numers, const struct libdivide_s32_branchfree_t *denom) { + int32_t magic = denom->magic; + uint8_t more = denom->more; + uint8_t shift = more & LIBDIVIDE_32_SHIFT_MASK; + // must be arithmetic shift + __m128i sign = _mm_set1_epi32((int8_t)more >> 7); + __m128i q = libdivide_mullhi_s32_vector(numers, _mm_set1_epi32(magic)); + q = _mm_add_epi32(q, numers); // q += numers + + // If q is non-negative, we have nothing to do + // If q is negative, we want to add either (2**shift)-1 if d is + // a power of 2, or (2**shift) if it is not a power of 2 + uint32_t is_power_of_2 = (magic == 0); + __m128i q_sign = _mm_srai_epi32(q, 31); // q_sign = q >> 31 + __m128i mask = _mm_set1_epi32((1U << shift) - is_power_of_2); + q = _mm_add_epi32(q, _mm_and_si128(q_sign, mask)); // q = q + (q_sign & mask) + q = _mm_srai_epi32(q, shift); // q >>= shift + q = _mm_sub_epi32(_mm_xor_si128(q, sign), sign); // q = (q ^ sign) - sign + return q; +} + +////////// SINT64 + +__m128i libdivide_s64_do_vector(__m128i numers, const struct libdivide_s64_t *denom) { + uint8_t more = denom->more; + int64_t magic = denom->magic; + if (magic == 0) { // shift path + uint32_t shift = more & LIBDIVIDE_64_SHIFT_MASK; + uint64_t mask = (1ULL << shift) - 1; + __m128i roundToZeroTweak = _mm_set1_epi64x(mask); + // q = numer + ((numer >> 63) & roundToZeroTweak); + __m128i q = _mm_add_epi64(numers, _mm_and_si128(libdivide_s64_signbits(numers), roundToZeroTweak)); + q = libdivide_s64_shift_right_vector(q, shift); + __m128i sign = _mm_set1_epi32((int8_t)more >> 7); + // q = (q ^ sign) - sign; + q = _mm_sub_epi64(_mm_xor_si128(q, sign), sign); + return q; + } + else { + __m128i q = libdivide_mullhi_s64_vector(numers, _mm_set1_epi64x(magic)); + if (more & LIBDIVIDE_ADD_MARKER) { + // must be arithmetic shift + __m128i sign = _mm_set1_epi32((int8_t)more >> 7); + // q += ((numer ^ sign) - sign); + q = _mm_add_epi64(q, _mm_sub_epi64(_mm_xor_si128(numers, sign), sign)); + } + // q >>= denom->mult_path.shift + q = libdivide_s64_shift_right_vector(q, more & LIBDIVIDE_64_SHIFT_MASK); + q = _mm_add_epi64(q, _mm_srli_epi64(q, 63)); // q += (q < 0) + return q; + } +} + +__m128i libdivide_s64_branchfree_do_vector(__m128i numers, const struct libdivide_s64_branchfree_t *denom) { + int64_t magic = denom->magic; + uint8_t more = denom->more; + uint8_t shift = more & LIBDIVIDE_64_SHIFT_MASK; + // must be arithmetic shift + __m128i sign = _mm_set1_epi32((int8_t)more >> 7); + + // libdivide_mullhi_s64(numers, magic); + __m128i q = libdivide_mullhi_s64_vector(numers, _mm_set1_epi64x(magic)); + q = _mm_add_epi64(q, numers); // q += numers + + // If q is non-negative, we have nothing to do. + // If q is negative, we want to add either (2**shift)-1 if d is + // a power of 2, or (2**shift) if it is not a power of 2. + uint32_t is_power_of_2 = (magic == 0); + __m128i q_sign = libdivide_s64_signbits(q); // q_sign = q >> 63 + __m128i mask = _mm_set1_epi64x((1ULL << shift) - is_power_of_2); + q = _mm_add_epi64(q, _mm_and_si128(q_sign, mask)); // q = q + (q_sign & mask) + q = libdivide_s64_shift_right_vector(q, shift); // q >>= shift + q = _mm_sub_epi64(_mm_xor_si128(q, sign), sign); // q = (q ^ sign) - sign + return q; +} + +#endif + +/////////// C++ stuff + +#ifdef __cplusplus + +// The C++ divider class is templated on both an integer type +// (like uint64_t) and an algorithm type. +// * BRANCHFULL is the default algorithm type. +// * BRANCHFREE is the branchfree algorithm type. +enum { + BRANCHFULL, + BRANCHFREE +}; + +#if defined(LIBDIVIDE_AVX512) + #define LIBDIVIDE_VECTOR_TYPE __m512i +#elif defined(LIBDIVIDE_AVX2) + #define LIBDIVIDE_VECTOR_TYPE __m256i +#elif defined(LIBDIVIDE_SSE2) + #define LIBDIVIDE_VECTOR_TYPE __m128i +#endif + +#if !defined(LIBDIVIDE_VECTOR_TYPE) + #define LIBDIVIDE_DIVIDE_VECTOR(ALGO) +#else + #define LIBDIVIDE_DIVIDE_VECTOR(ALGO) \ + LIBDIVIDE_VECTOR_TYPE divide(LIBDIVIDE_VECTOR_TYPE n) const { \ + return libdivide_##ALGO##_do_vector(n, &denom); \ + } +#endif + +// The DISPATCHER_GEN() macro generates C++ methods (for the given integer +// and algorithm types) that redirect to libdivide's C API. +#define DISPATCHER_GEN(T, ALGO) \ + libdivide_##ALGO##_t denom; \ + dispatcher() { } \ + dispatcher(T d) \ + : denom(libdivide_##ALGO##_gen(d)) \ + { } \ + T divide(T n) const { \ + return libdivide_##ALGO##_do(n, &denom); \ + } \ + LIBDIVIDE_DIVIDE_VECTOR(ALGO) \ + T recover() const { \ + return libdivide_##ALGO##_recover(&denom); \ + } + +// The dispatcher selects a specific division algorithm for a given +// type and ALGO using partial template specialization. +template struct dispatcher { }; + +template<> struct dispatcher { DISPATCHER_GEN(int32_t, s32) }; +template<> struct dispatcher { DISPATCHER_GEN(int32_t, s32_branchfree) }; +template<> struct dispatcher { DISPATCHER_GEN(uint32_t, u32) }; +template<> struct dispatcher { DISPATCHER_GEN(uint32_t, u32_branchfree) }; +template<> struct dispatcher { DISPATCHER_GEN(int64_t, s64) }; +template<> struct dispatcher { DISPATCHER_GEN(int64_t, s64_branchfree) }; +template<> struct dispatcher { DISPATCHER_GEN(uint64_t, u64) }; +template<> struct dispatcher { DISPATCHER_GEN(uint64_t, u64_branchfree) }; + +// This is the main divider class for use by the user (C++ API). +// The actual division algorithm is selected using the dispatcher struct +// based on the integer and algorithm template parameters. +template +class divider { +public: + // We leave the default constructor empty so that creating + // an array of dividers and then initializing them + // later doesn't slow us down. + divider() { } + + // Constructor that takes the divisor as a parameter + divider(T d) : div(d) { } + + // Divides n by the divisor + T divide(T n) const { + return div.divide(n); + } + + // Recovers the divisor, returns the value that was + // used to initialize this divider object. + T recover() const { + return div.recover(); + } + + bool operator==(const divider& other) const { + return div.denom.magic == other.denom.magic && + div.denom.more == other.denom.more; + } + + bool operator!=(const divider& other) const { + return !(*this == other); + } + +#if defined(LIBDIVIDE_VECTOR_TYPE) + // Treats the vector as packed integer values with the same type as + // the divider (e.g. s32, u32, s64, u64) and divides each of + // them by the divider, returning the packed quotients. + LIBDIVIDE_VECTOR_TYPE divide(LIBDIVIDE_VECTOR_TYPE n) const { + return div.divide(n); + } +#endif + +private: + // Storage for the actual divisor + dispatcher::value, + std::is_signed::value, sizeof(T), ALGO> div; +}; + +// Overload of operator / for scalar division +template +T operator/(T n, const divider& div) { + return div.divide(n); +} + +// Overload of operator /= for scalar division +template +T& operator/=(T& n, const divider& div) { + n = div.divide(n); + return n; +} + +#if defined(LIBDIVIDE_VECTOR_TYPE) + // Overload of operator / for vector division + template + LIBDIVIDE_VECTOR_TYPE operator/(LIBDIVIDE_VECTOR_TYPE n, const divider& div) { + return div.divide(n); + } + // Overload of operator /= for vector division + template + LIBDIVIDE_VECTOR_TYPE& operator/=(LIBDIVIDE_VECTOR_TYPE& n, const divider& div) { + n = div.divide(n); + return n; + } +#endif + +// libdivdie::branchfree_divider +template +using branchfree_divider = divider; + +} // namespace libdivide + +#endif // __cplusplus + +#endif // LIBDIVIDE_H diff --git a/src/r_draw.c b/src/r_draw.c index 2b798c3bf..cb8187521 100644 --- a/src/r_draw.c +++ b/src/r_draw.c @@ -25,6 +25,7 @@ #include "w_wad.h" #include "z_zone.h" #include "console.h" // Until buffering gets finished +#include "libdivide.h" // used by NPO2 tilted span functions #ifdef HWRENDER #include "hardware/hw_main.h" diff --git a/src/r_draw8_npo2.c b/src/r_draw8_npo2.c index 020155694..b280cbd49 100644 --- a/src/r_draw8_npo2.c +++ b/src/r_draw8_npo2.c @@ -83,6 +83,9 @@ void R_DrawTiltedSpan_NPO2_8(void) double endz, endu, endv; UINT32 stepu, stepv; + struct libdivide_u32_t x_divider = libdivide_u32_gen(ds_flatwidth); + struct libdivide_u32_t y_divider = libdivide_u32_gen(ds_flatheight); + iz = ds_szp->z + ds_szp->y*(centery-ds_y) + ds_szp->x*(ds_x1-centerx); // Lighting is simple. It's just linear interpolation from start to end @@ -122,12 +125,13 @@ void R_DrawTiltedSpan_NPO2_8(void) // Carefully align all of my Friends. if (x < 0) - x = ds_flatwidth - ((UINT32)(ds_flatwidth - x) % ds_flatwidth); + x += (libdivide_u32_do((UINT32)(-x-1), &x_divider) + 1) * ds_flatwidth; + else + x -= libdivide_u32_do((UINT32)x, &x_divider) * ds_flatwidth; if (y < 0) - y = ds_flatheight - ((UINT32)(ds_flatheight - y) % ds_flatheight); - - x %= ds_flatwidth; - y %= ds_flatheight; + y += (libdivide_u32_do((UINT32)(-y-1), &y_divider) + 1) * ds_flatheight; + else + y -= libdivide_u32_do((UINT32)y, &y_divider) * ds_flatheight; *dest = colormap[source[((y * ds_flatwidth) + x)]]; } @@ -174,12 +178,13 @@ void R_DrawTiltedSpan_NPO2_8(void) // Carefully align all of my Friends. if (x < 0) - x = ds_flatwidth - ((UINT32)(ds_flatwidth - x) % ds_flatwidth); + x += (libdivide_u32_do((UINT32)(-x-1), &x_divider) + 1) * ds_flatwidth; + else + x -= libdivide_u32_do((UINT32)x, &x_divider) * ds_flatwidth; if (y < 0) - y = ds_flatheight - ((UINT32)(ds_flatheight - y) % ds_flatheight); - - x %= ds_flatwidth; - y %= ds_flatheight; + y += (libdivide_u32_do((UINT32)(-y-1), &y_divider) + 1) * ds_flatheight; + else + y -= libdivide_u32_do((UINT32)y, &y_divider) * ds_flatheight; *dest = colormap[source[((y * ds_flatwidth) + x)]]; } @@ -205,12 +210,13 @@ void R_DrawTiltedSpan_NPO2_8(void) // Carefully align all of my Friends. if (x < 0) - x = ds_flatwidth - ((UINT32)(ds_flatwidth - x) % ds_flatwidth); + x += (libdivide_u32_do((UINT32)(-x-1), &x_divider) + 1) * ds_flatwidth; + else + x -= libdivide_u32_do((UINT32)x, &x_divider) * ds_flatwidth; if (y < 0) - y = ds_flatheight - ((UINT32)(ds_flatheight - y) % ds_flatheight); - - x %= ds_flatwidth; - y %= ds_flatheight; + y += (libdivide_u32_do((UINT32)(-y-1), &y_divider) + 1) * ds_flatheight; + else + y -= libdivide_u32_do((UINT32)y, &y_divider) * ds_flatheight; *dest = colormap[source[((y * ds_flatwidth) + x)]]; } @@ -241,12 +247,13 @@ void R_DrawTiltedSpan_NPO2_8(void) // Carefully align all of my Friends. if (x < 0) - x = ds_flatwidth - ((UINT32)(ds_flatwidth - x) % ds_flatwidth); + x += (libdivide_u32_do((UINT32)(-x-1), &x_divider) + 1) * ds_flatwidth; + else + x -= libdivide_u32_do((UINT32)x, &x_divider) * ds_flatwidth; if (y < 0) - y = ds_flatheight - ((UINT32)(ds_flatheight - y) % ds_flatheight); - - x %= ds_flatwidth; - y %= ds_flatheight; + y += (libdivide_u32_do((UINT32)(-y-1), &y_divider) + 1) * ds_flatheight; + else + y -= libdivide_u32_do((UINT32)y, &y_divider) * ds_flatheight; *dest = colormap[source[((y * ds_flatwidth) + x)]]; } @@ -279,6 +286,9 @@ void R_DrawTiltedTranslucentSpan_NPO2_8(void) double endz, endu, endv; UINT32 stepu, stepv; + struct libdivide_u32_t x_divider = libdivide_u32_gen(ds_flatwidth); + struct libdivide_u32_t y_divider = libdivide_u32_gen(ds_flatheight); + iz = ds_szp->z + ds_szp->y*(centery-ds_y) + ds_szp->x*(ds_x1-centerx); // Lighting is simple. It's just linear interpolation from start to end @@ -317,12 +327,13 @@ void R_DrawTiltedTranslucentSpan_NPO2_8(void) // Carefully align all of my Friends. if (x < 0) - x = ds_flatwidth - ((UINT32)(ds_flatwidth - x) % ds_flatwidth); + x += (libdivide_u32_do((UINT32)(-x-1), &x_divider) + 1) * ds_flatwidth; + else + x -= libdivide_u32_do((UINT32)x, &x_divider) * ds_flatwidth; if (y < 0) - y = ds_flatheight - ((UINT32)(ds_flatheight - y) % ds_flatheight); - - x %= ds_flatwidth; - y %= ds_flatheight; + y += (libdivide_u32_do((UINT32)(-y-1), &y_divider) + 1) * ds_flatheight; + else + y -= libdivide_u32_do((UINT32)y, &y_divider) * ds_flatheight; *dest = *(ds_transmap + (colormap[source[((y * ds_flatwidth) + x)]] << 8) + *dest); } @@ -369,12 +380,13 @@ void R_DrawTiltedTranslucentSpan_NPO2_8(void) // Carefully align all of my Friends. if (x < 0) - x = ds_flatwidth - ((UINT32)(ds_flatwidth - x) % ds_flatwidth); + x += (libdivide_u32_do((UINT32)(-x-1), &x_divider) + 1) * ds_flatwidth; + else + x -= libdivide_u32_do((UINT32)x, &x_divider) * ds_flatwidth; if (y < 0) - y = ds_flatheight - ((UINT32)(ds_flatheight - y) % ds_flatheight); - - x %= ds_flatwidth; - y %= ds_flatheight; + y += (libdivide_u32_do((UINT32)(-y-1), &y_divider) + 1) * ds_flatheight; + else + y -= libdivide_u32_do((UINT32)y, &y_divider) * ds_flatheight; *dest = *(ds_transmap + (colormap[source[((y * ds_flatwidth) + x)]] << 8) + *dest); } @@ -400,12 +412,13 @@ void R_DrawTiltedTranslucentSpan_NPO2_8(void) // Carefully align all of my Friends. if (x < 0) - x = ds_flatwidth - ((UINT32)(ds_flatwidth - x) % ds_flatwidth); + x += (libdivide_u32_do((UINT32)(-x-1), &x_divider) + 1) * ds_flatwidth; + else + x -= libdivide_u32_do((UINT32)x, &x_divider) * ds_flatwidth; if (y < 0) - y = ds_flatheight - ((UINT32)(ds_flatheight - y) % ds_flatheight); - - x %= ds_flatwidth; - y %= ds_flatheight; + y += (libdivide_u32_do((UINT32)(-y-1), &y_divider) + 1) * ds_flatheight; + else + y -= libdivide_u32_do((UINT32)y, &y_divider) * ds_flatheight; *dest = *(ds_transmap + (colormap[source[((y * ds_flatwidth) + x)]] << 8) + *dest); } @@ -436,12 +449,13 @@ void R_DrawTiltedTranslucentSpan_NPO2_8(void) // Carefully align all of my Friends. if (x < 0) - x = ds_flatwidth - ((UINT32)(ds_flatwidth - x) % ds_flatwidth); + x += (libdivide_u32_do((UINT32)(-x-1), &x_divider) + 1) * ds_flatwidth; + else + x -= libdivide_u32_do((UINT32)x, &x_divider) * ds_flatwidth; if (y < 0) - y = ds_flatheight - ((UINT32)(ds_flatheight - y) % ds_flatheight); - - x %= ds_flatwidth; - y %= ds_flatheight; + y += (libdivide_u32_do((UINT32)(-y-1), &y_divider) + 1) * ds_flatheight; + else + y -= libdivide_u32_do((UINT32)y, &y_divider) * ds_flatheight; *dest = *(ds_transmap + (colormap[source[((y * ds_flatwidth) + x)]] << 8) + *dest); } @@ -473,6 +487,9 @@ void R_DrawTiltedSplat_NPO2_8(void) double endz, endu, endv; UINT32 stepu, stepv; + struct libdivide_u32_t x_divider = libdivide_u32_gen(ds_flatwidth); + struct libdivide_u32_t y_divider = libdivide_u32_gen(ds_flatheight); + iz = ds_szp->z + ds_szp->y*(centery-ds_y) + ds_szp->x*(ds_x1-centerx); // Lighting is simple. It's just linear interpolation from start to end @@ -512,12 +529,13 @@ void R_DrawTiltedSplat_NPO2_8(void) // Carefully align all of my Friends. if (x < 0) - x = ds_flatwidth - ((UINT32)(ds_flatwidth - x) % ds_flatwidth); + x += (libdivide_u32_do((UINT32)(-x-1), &x_divider) + 1) * ds_flatwidth; + else + x -= libdivide_u32_do((UINT32)x, &x_divider) * ds_flatwidth; if (y < 0) - y = ds_flatheight - ((UINT32)(ds_flatheight - y) % ds_flatheight); - - x %= ds_flatwidth; - y %= ds_flatheight; + y += (libdivide_u32_do((UINT32)(-y-1), &y_divider) + 1) * ds_flatheight; + else + y -= libdivide_u32_do((UINT32)y, &y_divider) * ds_flatheight; val = source[((y * ds_flatwidth) + x)]; } @@ -568,12 +586,13 @@ void R_DrawTiltedSplat_NPO2_8(void) // Carefully align all of my Friends. if (x < 0) - x = ds_flatwidth - ((UINT32)(ds_flatwidth - x) % ds_flatwidth); + x += (libdivide_u32_do((UINT32)(-x-1), &x_divider) + 1) * ds_flatwidth; + else + x -= libdivide_u32_do((UINT32)x, &x_divider) * ds_flatwidth; if (y < 0) - y = ds_flatheight - ((UINT32)(ds_flatheight - y) % ds_flatheight); - - x %= ds_flatwidth; - y %= ds_flatheight; + y += (libdivide_u32_do((UINT32)(-y-1), &y_divider) + 1) * ds_flatheight; + else + y -= libdivide_u32_do((UINT32)y, &y_divider) * ds_flatheight; val = source[((y * ds_flatwidth) + x)]; } @@ -601,12 +620,13 @@ void R_DrawTiltedSplat_NPO2_8(void) // Carefully align all of my Friends. if (x < 0) - x = ds_flatwidth - ((UINT32)(ds_flatwidth - x) % ds_flatwidth); + x += (libdivide_u32_do((UINT32)(-x-1), &x_divider) + 1) * ds_flatwidth; + else + x -= libdivide_u32_do((UINT32)x, &x_divider) * ds_flatwidth; if (y < 0) - y = ds_flatheight - ((UINT32)(ds_flatheight - y) % ds_flatheight); - - x %= ds_flatwidth; - y %= ds_flatheight; + y += (libdivide_u32_do((UINT32)(-y-1), &y_divider) + 1) * ds_flatheight; + else + y -= libdivide_u32_do((UINT32)y, &y_divider) * ds_flatheight; val = source[((y * ds_flatwidth) + x)]; } @@ -640,12 +660,13 @@ void R_DrawTiltedSplat_NPO2_8(void) // Carefully align all of my Friends. if (x < 0) - x = ds_flatwidth - ((UINT32)(ds_flatwidth - x) % ds_flatwidth); + x += (libdivide_u32_do((UINT32)(-x-1), &x_divider) + 1) * ds_flatwidth; + else + x -= libdivide_u32_do((UINT32)x, &x_divider) * ds_flatwidth; if (y < 0) - y = ds_flatheight - ((UINT32)(ds_flatheight - y) % ds_flatheight); - - x %= ds_flatwidth; - y %= ds_flatheight; + y += (libdivide_u32_do((UINT32)(-y-1), &y_divider) + 1) * ds_flatheight; + else + y -= libdivide_u32_do((UINT32)y, &y_divider) * ds_flatheight; val = source[((y * ds_flatwidth) + x)]; } @@ -864,6 +885,9 @@ void R_DrawTiltedTranslucentWaterSpan_NPO2_8(void) double endz, endu, endv; UINT32 stepu, stepv; + struct libdivide_u32_t x_divider = libdivide_u32_gen(ds_flatwidth); + struct libdivide_u32_t y_divider = libdivide_u32_gen(ds_flatheight); + iz = ds_szp->z + ds_szp->y*(centery-ds_y) + ds_szp->x*(ds_x1-centerx); // Lighting is simple. It's just linear interpolation from start to end @@ -903,12 +927,13 @@ void R_DrawTiltedTranslucentWaterSpan_NPO2_8(void) // Carefully align all of my Friends. if (x < 0) - x = ds_flatwidth - ((UINT32)(ds_flatwidth - x) % ds_flatwidth); + x += (libdivide_u32_do((UINT32)(-x-1), &x_divider) + 1) * ds_flatwidth; + else + x -= libdivide_u32_do((UINT32)x, &x_divider) * ds_flatwidth; if (y < 0) - y = ds_flatheight - ((UINT32)(ds_flatheight - y) % ds_flatheight); - - x %= ds_flatwidth; - y %= ds_flatheight; + y += (libdivide_u32_do((UINT32)(-y-1), &y_divider) + 1) * ds_flatheight; + else + y -= libdivide_u32_do((UINT32)y, &y_divider) * ds_flatheight; *dest = *(ds_transmap + (colormap[source[((y * ds_flatwidth) + x)]] << 8) + *dsrc++); } @@ -955,12 +980,13 @@ void R_DrawTiltedTranslucentWaterSpan_NPO2_8(void) // Carefully align all of my Friends. if (x < 0) - x = ds_flatwidth - ((UINT32)(ds_flatwidth - x) % ds_flatwidth); + x += (libdivide_u32_do((UINT32)(-x-1), &x_divider) + 1) * ds_flatwidth; + else + x -= libdivide_u32_do((UINT32)x, &x_divider) * ds_flatwidth; if (y < 0) - y = ds_flatheight - ((UINT32)(ds_flatheight - y) % ds_flatheight); - - x %= ds_flatwidth; - y %= ds_flatheight; + y += (libdivide_u32_do((UINT32)(-y-1), &y_divider) + 1) * ds_flatheight; + else + y -= libdivide_u32_do((UINT32)y, &y_divider) * ds_flatheight; *dest = *(ds_transmap + (colormap[source[((y * ds_flatwidth) + x)]] << 8) + *dsrc++); } @@ -986,12 +1012,13 @@ void R_DrawTiltedTranslucentWaterSpan_NPO2_8(void) // Carefully align all of my Friends. if (x < 0) - x = ds_flatwidth - ((UINT32)(ds_flatwidth - x) % ds_flatwidth); + x += (libdivide_u32_do((UINT32)(-x-1), &x_divider) + 1) * ds_flatwidth; + else + x -= libdivide_u32_do((UINT32)x, &x_divider) * ds_flatwidth; if (y < 0) - y = ds_flatheight - ((UINT32)(ds_flatheight - y) % ds_flatheight); - - x %= ds_flatwidth; - y %= ds_flatheight; + y += (libdivide_u32_do((UINT32)(-y-1), &y_divider) + 1) * ds_flatheight; + else + y -= libdivide_u32_do((UINT32)y, &y_divider) * ds_flatheight; *dest = *(ds_transmap + (colormap[source[((y * ds_flatwidth) + x)]] << 8) + *dsrc++); } @@ -1022,12 +1049,13 @@ void R_DrawTiltedTranslucentWaterSpan_NPO2_8(void) // Carefully align all of my Friends. if (x < 0) - x = ds_flatwidth - ((UINT32)(ds_flatwidth - x) % ds_flatwidth); + x += (libdivide_u32_do((UINT32)(-x-1), &x_divider) + 1) * ds_flatwidth; + else + x -= libdivide_u32_do((UINT32)x, &x_divider) * ds_flatwidth; if (y < 0) - y = ds_flatheight - ((UINT32)(ds_flatheight - y) % ds_flatheight); - - x %= ds_flatwidth; - y %= ds_flatheight; + y += (libdivide_u32_do((UINT32)(-y-1), &y_divider) + 1) * ds_flatheight; + else + y -= libdivide_u32_do((UINT32)y, &y_divider) * ds_flatheight; *dest = *(ds_transmap + (colormap[source[((y * ds_flatwidth) + x)]] << 8) + *dsrc++); } diff --git a/src/sdl/Srb2SDL-vc10.vcxproj b/src/sdl/Srb2SDL-vc10.vcxproj index c2d6456e4..9b3214067 100644 --- a/src/sdl/Srb2SDL-vc10.vcxproj +++ b/src/sdl/Srb2SDL-vc10.vcxproj @@ -244,6 +244,7 @@ + diff --git a/src/sdl/Srb2SDL-vc10.vcxproj.filters b/src/sdl/Srb2SDL-vc10.vcxproj.filters index 438746ac7..425bbfcc0 100644 --- a/src/sdl/Srb2SDL-vc10.vcxproj.filters +++ b/src/sdl/Srb2SDL-vc10.vcxproj.filters @@ -402,6 +402,9 @@ P_Play + + R_Rend + R_Rend From 18a2e87093542c95c98ea95b5414f136fce93aee Mon Sep 17 00:00:00 2001 From: James R Date: Mon, 26 Oct 2020 14:00:54 -0700 Subject: [PATCH 0240/1080] Check maxstep is not disabled before stepping up Fixes infinite step up when it should be no step up. --- src/p_map.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/p_map.c b/src/p_map.c index 0a9107ee5..2715d2377 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -2735,7 +2735,7 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff) // Step up if (thing->z < tmfloorz) { - if (tmfloorz - thing->z <= maxstep) + if (maxstep > 0 && tmfloorz - thing->z <= maxstep) { thing->z = thing->floorz = tmfloorz; thing->floorrover = tmfloorrover; @@ -2748,7 +2748,7 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff) } else if (tmceilingz < thingtop) { - if (thingtop - tmceilingz <= maxstep) + if (maxstep > 0 && thingtop - tmceilingz <= maxstep) { thing->z = ( thing->ceilingz = tmceilingz ) - thing->height; thing->ceilingrover = tmceilingrover; From 9f5686ef48956cd64ef92f737e59cbbaa27d8cf9 Mon Sep 17 00:00:00 2001 From: Louis-Antoine Date: Mon, 26 Oct 2020 23:15:22 +0100 Subject: [PATCH 0241/1080] Fix underflow in consistancy checking code --- 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 cc2715cb1..e671bced6 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -4067,7 +4067,7 @@ static void HandlePacketFromPlayer(SINT8 node) &netbuffer->u.client2pak.cmd2, 1); // Check player consistancy during the level - if (realstart <= gametic && realstart > gametic - BACKUPTICS+1 && gamestate == GS_LEVEL + if (realstart <= gametic && realstart + BACKUPTICS - 1 > gametic && gamestate == GS_LEVEL && consistancy[realstart%BACKUPTICS] != SHORT(netbuffer->u.clientpak.consistancy) && !resendingsavegame[node]) { From 7ae53364f2ea73f54bccf317339ac83499049a95 Mon Sep 17 00:00:00 2001 From: Louis-Antoine Date: Tue, 27 Oct 2020 01:20:05 +0100 Subject: [PATCH 0242/1080] Add a 15 seconds cooldown between successive gamestate resends --- src/d_clisrv.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index e671bced6..0823f3c8a 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -85,6 +85,7 @@ char playeraddress[MAXPLAYERS][64]; tic_t jointimeout = (10*TICRATE); static boolean sendingsavegame[MAXNETNODES]; // Are we sending the savegame? static boolean resendingsavegame[MAXNETNODES]; // Are we resending the savegame? +static tic_t savegameresendcooldown[MAXNETNODES]; // How long before we can resend again? static tic_t freezetimeout[MAXNETNODES]; // Until when can this node freeze the server before getting a timeout? // Incremented by cv_joindelay when a client joins, decremented each tic. @@ -3149,14 +3150,18 @@ void D_ClientServerInit(void) static void ResetNode(INT32 node) { nodeingame[node] = false; - nodetoplayer[node] = -1; - nodetoplayer2[node] = -1; + nodewaiting[node] = 0; + nettics[node] = gametic; supposedtics[node] = gametic; - nodewaiting[node] = 0; + + nodetoplayer[node] = -1; + nodetoplayer2[node] = -1; playerpernode[node] = 0; + sendingsavegame[node] = false; resendingsavegame[node] = false; + savegameresendcooldown[node] = 0; } void SV_ResetServer(void) @@ -4069,7 +4074,7 @@ static void HandlePacketFromPlayer(SINT8 node) // Check player consistancy during the level if (realstart <= gametic && realstart + BACKUPTICS - 1 > gametic && gamestate == GS_LEVEL && consistancy[realstart%BACKUPTICS] != SHORT(netbuffer->u.clientpak.consistancy) - && !resendingsavegame[node]) + && !resendingsavegame[node] && savegameresendcooldown[node] <= I_GetTime()) { if (cv_resynchattempts.value) { @@ -4237,6 +4242,7 @@ static void HandlePacketFromPlayer(SINT8 node) case PT_RECEIVEDGAMESTATE: sendingsavegame[node] = false; resendingsavegame[node] = false; + savegameresendcooldown[node] = I_GetTime() + 15 * TICRATE; break; // -------------------------------------------- CLIENT RECEIVE ---------- case PT_SERVERTICS: From 499bb56436c7571d3247a5a813af2a84a58c5913 Mon Sep 17 00:00:00 2001 From: Louis-Antoine Date: Tue, 27 Oct 2020 01:22:31 +0100 Subject: [PATCH 0243/1080] Only resend the gamestate to one client at a time --- src/d_clisrv.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 0823f3c8a..af7907e67 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -1391,6 +1391,16 @@ static boolean SV_SendServerConfig(INT32 node) #ifndef NONET #define SAVEGAMESIZE (768*1024) +static boolean SV_ResendingSavegameToAnyone(void) +{ + INT32 i; + + for (i = 0; i < MAXNETNODES; i++) + if (resendingsavegame[i]) + return true; + return false; +} + static void SV_SendSaveGame(INT32 node, boolean resending) { size_t length, compressedlen; @@ -4074,7 +4084,8 @@ static void HandlePacketFromPlayer(SINT8 node) // Check player consistancy during the level if (realstart <= gametic && realstart + BACKUPTICS - 1 > gametic && gamestate == GS_LEVEL && consistancy[realstart%BACKUPTICS] != SHORT(netbuffer->u.clientpak.consistancy) - && !resendingsavegame[node] && savegameresendcooldown[node] <= I_GetTime()) + && !resendingsavegame[node] && savegameresendcooldown[node] <= I_GetTime() + && !SV_ResendingSavegameToAnyone()) { if (cv_resynchattempts.value) { From b872222b50c65496dee72f5e4d3b6c7ed2820da9 Mon Sep 17 00:00:00 2001 From: Jaime Passos Date: Tue, 27 Oct 2020 00:03:41 -0300 Subject: [PATCH 0244/1080] Implement blend modes --- src/d_clisrv.c | 4 +- src/d_clisrv.h | 1 + src/dehacked.c | 9 ++ src/f_wipe.c | 2 +- src/hardware/hw_defs.h | 47 +++++---- src/hardware/hw_draw.c | 2 +- src/hardware/hw_light.c | 7 +- src/hardware/hw_main.c | 107 ++++++++++++++------ src/hardware/hw_main.h | 8 +- src/hardware/hw_md2.c | 8 +- src/hardware/r_opengl/r_opengl.c | 164 ++++++++++++++++++++----------- src/lua_mobjlib.c | 8 ++ src/p_mobj.c | 2 +- src/p_mobj.h | 5 +- src/p_saveg.c | 17 +++- src/r_data.c | 4 +- src/r_draw.c | 108 +++++++++++++++++--- src/r_draw.h | 24 ++++- src/r_main.c | 4 +- src/r_plane.c | 22 ++--- src/r_segs.c | 22 ++--- src/r_things.c | 6 +- src/v_video.c | 14 +-- 23 files changed, 415 insertions(+), 180 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 636e2bfa8..dba783f4c 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -655,6 +655,7 @@ static inline void resynch_write_player(resynch_pak *rsp, const size_t i) rsp->flags = LONG(players[i].mo->flags); rsp->flags2 = LONG(players[i].mo->flags2); rsp->renderflags = LONG(players[i].mo->renderflags); + rsp->blendmode = LONG(players[i].mo->blendmode); rsp->radius = LONG(players[i].mo->radius); rsp->height = LONG(players[i].mo->height); @@ -794,7 +795,6 @@ static void resynch_read_player(resynch_pak *rsp) players[i].mo->eflags = (UINT16)SHORT(rsp->eflags); players[i].mo->flags = LONG(rsp->flags); players[i].mo->flags2 = LONG(rsp->flags2); - players[i].mo->renderflags = LONG(rsp->renderflags); players[i].mo->friction = LONG(rsp->friction); players[i].mo->health = LONG(rsp->health); players[i].mo->momx = LONG(rsp->momx); @@ -809,6 +809,8 @@ static void resynch_read_player(resynch_pak *rsp) players[i].mo->frame = LONG(rsp->frame); players[i].mo->sprite2 = rsp->sprite2; players[i].mo->anim_duration = SHORT(rsp->anim_duration); + players[i].mo->renderflags = LONG(rsp->renderflags); + players[i].mo->blendmode = LONG(rsp->blendmode); players[i].mo->spritexscale = LONG(rsp->spritexscale); players[i].mo->spriteyscale = LONG(rsp->spriteyscale); diff --git a/src/d_clisrv.h b/src/d_clisrv.h index 94cec3ff7..747cf6842 100644 --- a/src/d_clisrv.h +++ b/src/d_clisrv.h @@ -300,6 +300,7 @@ typedef struct UINT32 flags2; UINT16 eflags; UINT32 renderflags; + INT32 blendmode; fixed_t radius; fixed_t height; diff --git a/src/dehacked.c b/src/dehacked.c index df692391c..3562a2aec 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -9580,6 +9580,15 @@ struct { {"tr_trans90",tr_trans90}, {"NUMTRANSMAPS",NUMTRANSMAPS}, + // Alpha styles (blend modes) + {"AST_COPY",AST_COPY}, + {"AST_TRANSLUCENT",AST_TRANSLUCENT}, + {"AST_ADD",AST_ADD}, + {"AST_SUBTRACT",AST_SUBTRACT}, + {"AST_REVERSESUBTRACT",AST_REVERSESUBTRACT}, + {"AST_MODULATE",AST_MODULATE}, + {"AST_OVERLAY",AST_OVERLAY}, + // Render flags {"RF_HORIZONTALFLIP",RF_HORIZONTALFLIP}, {"RF_VERTICALFLIP",RF_VERTICALFLIP}, diff --git a/src/f_wipe.c b/src/f_wipe.c index f5b9bd722..6afb8a6a7 100644 --- a/src/f_wipe.c +++ b/src/f_wipe.c @@ -293,7 +293,7 @@ static void F_DoWipe(fademask_t *fademask) else { // pointer to transtable that this mask would use - transtbl = transtables + ((9 - *mask)< PolyColor - PF_NoTexture = 0x00002000, // Use the small white texture - PF_Corona = 0x00004000, // Tell the rendrer we are drawing a corona - PF_Ripple = 0x00008000, // Water shader effect - PF_RemoveYWrap = 0x00010000, // Force clamp texture on Y - PF_ForceWrapX = 0x00020000, // Force repeat texture on X - PF_ForceWrapY = 0x00040000, // Force repeat texture on Y - PF_Clip = 0x40000000, // clip to frustum and nearz plane (glide only, automatic in opengl) - PF_NoZClip = 0x20000000, // in conjonction with PF_Clip - PF_Debug = 0x80000000 // print debug message in driver :) + PF_NoTexture = 0x00002000, // Disables texturing + PF_Corona = 0x00004000, // Tells the renderer we are drawing a corona + PF_Ripple = 0x00008000, // Water effect shader + PF_RemoveYWrap = 0x00010000, // Forces clamp texture on Y + PF_ForceWrapX = 0x00020000, // Forces repeat texture on X + PF_ForceWrapY = 0x00040000 // Forces repeat texture on Y }; diff --git a/src/hardware/hw_draw.c b/src/hardware/hw_draw.c index a4e1df496..faf7a9f8c 100644 --- a/src/hardware/hw_draw.c +++ b/src/hardware/hw_draw.c @@ -571,7 +571,7 @@ void HWR_DrawPic(INT32 x, INT32 y, lumpnum_t lumpnum) // But then, the question is: why not 0 instead of PF_Masked ? // or maybe PF_Environment ??? (like what I said above) // BP: PF_Environment don't change anything ! and 0 is undifined - HWD.pfnDrawPolygon(NULL, v, 4, PF_Translucent | PF_NoDepthTest | PF_Clip | PF_NoZClip); + HWD.pfnDrawPolygon(NULL, v, 4, PF_Translucent | PF_NoDepthTest); } // ========================================================================== diff --git a/src/hardware/hw_light.c b/src/hardware/hw_light.c index 32c2d550d..987d70c69 100644 --- a/src/hardware/hw_light.c +++ b/src/hardware/hw_light.c @@ -35,8 +35,7 @@ #define DL_HIGH_QUALITY //#define STATICLIGHT //Hurdler: TODO! -//#define LIGHTMAPFLAGS (PF_Masked|PF_Clip|PF_NoAlphaTest) // debug see overdraw -#define LIGHTMAPFLAGS (PF_Modulated|PF_Additive|PF_Clip) +#define LIGHTMAPFLAGS (PF_Modulated|PF_AdditiveSource) #ifdef ALAM_LIGHTING static dynlights_t view_dynlights[2]; // 2 players in splitscreen mode @@ -1056,7 +1055,7 @@ void HWR_DoCoronasLighting(FOutVector *outVerts, gl_vissprite_t *spr) HWR_GetPic(coronalumpnum); /// \todo use different coronas - HWD.pfnDrawPolygon (&Surf, light, 4, PF_Modulated | PF_Additive | PF_Clip | PF_Corona | PF_NoDepthTest); + HWD.pfnDrawPolygon (&Surf, light, 4, PF_Modulated | PF_AdditiveSource | PF_Corona | PF_NoDepthTest); } } #endif @@ -1144,7 +1143,7 @@ void HWR_DrawCoronas(void) light[3].y = cy+size*1.33f; light[3].s = 0.0f; light[3].t = 1.0f; - HWD.pfnDrawPolygon (&Surf, light, 4, PF_Modulated | PF_Additive | PF_Clip | PF_NoDepthTest | PF_Corona); + HWD.pfnDrawPolygon (&Surf, light, 4, PF_Modulated | PF_AdditiveSource | PF_NoDepthTest | PF_Corona); } } #endif diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index bd4bcf66d..fb8318e09 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -695,28 +695,71 @@ static void HWR_RenderSkyPlane(extrasubsector_t *xsub, fixed_t fixedheight) v3d->z = pv->y; } - HWD.pfnDrawPolygon(NULL, planeVerts, nrPlaneVerts, - PF_Clip|PF_Invisible|PF_NoTexture|PF_Occlude); + HWD.pfnDrawPolygon(NULL, planeVerts, nrPlaneVerts, PF_Invisible|PF_NoTexture|PF_Occlude); } #endif //polysky #endif //doplanes -FBITFIELD HWR_TranstableToAlpha(INT32 transtablenum, FSurfaceInfo *pSurf) +FBITFIELD HWR_GetBlendModeFlag(INT32 ast) +{ + switch (ast) + { + case AST_ADD: + return PF_Additive; + case AST_SUBTRACT: + return PF_Subtractive; + case AST_REVERSESUBTRACT: + return PF_ReverseSubtract; + case AST_MODULATE: + return PF_Multiplicative; + default: + return PF_Translucent; + } + + return 0; +} + +UINT8 HWR_GetTranstableAlpha(INT32 transtablenum) { switch (transtablenum) { - case 0 : pSurf->PolyColor.s.alpha = 0x00;return PF_Masked; - case tr_trans10 : pSurf->PolyColor.s.alpha = 0xe6;return PF_Translucent; - case tr_trans20 : pSurf->PolyColor.s.alpha = 0xcc;return PF_Translucent; - case tr_trans30 : pSurf->PolyColor.s.alpha = 0xb3;return PF_Translucent; - case tr_trans40 : pSurf->PolyColor.s.alpha = 0x99;return PF_Translucent; - case tr_trans50 : pSurf->PolyColor.s.alpha = 0x80;return PF_Translucent; - case tr_trans60 : pSurf->PolyColor.s.alpha = 0x66;return PF_Translucent; - case tr_trans70 : pSurf->PolyColor.s.alpha = 0x4c;return PF_Translucent; - case tr_trans80 : pSurf->PolyColor.s.alpha = 0x33;return PF_Translucent; - case tr_trans90 : pSurf->PolyColor.s.alpha = 0x19;return PF_Translucent; + case 0 : return 0xff; + case tr_trans10 : return 0xe6; + case tr_trans20 : return 0xcc; + case tr_trans30 : return 0xb3; + case tr_trans40 : return 0x99; + case tr_trans50 : return 0x80; + case tr_trans60 : return 0x66; + case tr_trans70 : return 0x4c; + case tr_trans80 : return 0x33; + case tr_trans90 : return 0x19; } + + return 0xff; +} + +FBITFIELD HWR_SurfaceBlend(INT32 style, INT32 transtablenum, FSurfaceInfo *pSurf) +{ + if (!transtablenum) + { + pSurf->PolyColor.s.alpha = 0xff; + return PF_Masked; + } + + pSurf->PolyColor.s.alpha = HWR_GetTranstableAlpha(transtablenum); + return HWR_GetBlendModeFlag(style); +} + +FBITFIELD HWR_TranstableToAlpha(INT32 transtablenum, FSurfaceInfo *pSurf) +{ + if (!transtablenum) + { + pSurf->PolyColor.s.alpha = 0x00; + return PF_Masked; + } + + pSurf->PolyColor.s.alpha = HWR_GetTranstableAlpha(transtablenum); return PF_Translucent; } @@ -2770,10 +2813,10 @@ static void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling, if (blendmode & PF_Translucent) { Surf.PolyColor.s.alpha = (UINT8)alpha; - blendmode |= PF_Modulated|PF_Occlude|PF_Clip; + blendmode |= PF_Modulated|PF_Occlude; } else - blendmode |= PF_Masked|PF_Modulated|PF_Clip; + blendmode |= PF_Masked|PF_Modulated; HWR_ProcessPolygon(&Surf, planeVerts, nrPlaneVerts, blendmode, 1, false); // floor shader } @@ -3443,7 +3486,7 @@ static void HWR_LinkDrawHackFinish(void) { // draw sprite shape, only to z-buffer HWR_GetPatch(linkdrawlist[i].spr->gpatch); - HWR_ProcessPolygon(&surf, linkdrawlist[i].verts, 4, PF_Translucent|PF_Occlude|PF_Invisible|PF_Clip, 0, false); + HWR_ProcessPolygon(&surf, linkdrawlist[i].verts, 4, PF_Translucent|PF_Occlude|PF_Invisible, 0, false); } // reset list linkdrawcount = 0; @@ -3587,7 +3630,7 @@ static void HWR_DrawDropShadow(mobj_t *thing, fixed_t scale) HWR_Lighting(&sSurf, 0, colormap); sSurf.PolyColor.s.alpha = alpha; - HWR_ProcessPolygon(&sSurf, shadowVerts, 4, PF_Translucent|PF_Modulated|PF_Clip, 3, false); // sprite shader + HWR_ProcessPolygon(&sSurf, shadowVerts, 4, PF_Translucent|PF_Modulated, 3, false); // sprite shader } // This is expecting a pointer to an array containing 4 wallVerts for a sprite @@ -3741,10 +3784,10 @@ static void HWR_SplitSprite(gl_vissprite_t *spr) else if (spr->mobj->flags2 & MF2_SHADOW) { Surf.PolyColor.s.alpha = 0x40; - blend = PF_Translucent; + blend = HWR_GetBlendModeFlag(spr->mobj->blendmode); } else if (spr->mobj->frame & FF_TRANSMASK) - blend = HWR_TranstableToAlpha((spr->mobj->frame & FF_TRANSMASK)>>FF_TRANSSHIFT, &Surf); + blend = HWR_SurfaceBlend(spr->mobj->blendmode, (spr->mobj->frame & FF_TRANSMASK)>>FF_TRANSSHIFT, &Surf); else { // BP: i agree that is little better in environement but it don't @@ -3752,7 +3795,7 @@ static void HWR_SplitSprite(gl_vissprite_t *spr) // Hurdler: PF_Environement would be cool, but we need to fix // the issue with the fog before Surf.PolyColor.s.alpha = 0xFF; - blend = PF_Translucent|occlusion; + blend = HWR_GetBlendModeFlag(spr->mobj->blendmode)|occlusion; if (!occlusion) use_linkdraw_hack = true; } @@ -3860,7 +3903,7 @@ static void HWR_SplitSprite(gl_vissprite_t *spr) Surf.PolyColor.s.alpha = alpha; - HWR_ProcessPolygon(&Surf, wallVerts, 4, blend|PF_Modulated|PF_Clip, 3, false); // sprite shader + HWR_ProcessPolygon(&Surf, wallVerts, 4, blend|PF_Modulated, 3, false); // sprite shader if (use_linkdraw_hack) HWR_LinkDrawHackAdd(wallVerts, spr); @@ -3889,7 +3932,7 @@ static void HWR_SplitSprite(gl_vissprite_t *spr) Surf.PolyColor.s.alpha = alpha; - HWR_ProcessPolygon(&Surf, wallVerts, 4, blend|PF_Modulated|PF_Clip, 3, false); // sprite shader + HWR_ProcessPolygon(&Surf, wallVerts, 4, blend|PF_Modulated, 3, false); // sprite shader if (use_linkdraw_hack) HWR_LinkDrawHackAdd(wallVerts, spr); @@ -4156,10 +4199,10 @@ static void HWR_DrawSprite(gl_vissprite_t *spr) else if (spr->mobj->flags2 & MF2_SHADOW) { Surf.PolyColor.s.alpha = 0x40; - blend = PF_Translucent; + blend = HWR_GetBlendModeFlag(spr->mobj->blendmode); } else if (spr->mobj->frame & FF_TRANSMASK) - blend = HWR_TranstableToAlpha((spr->mobj->frame & FF_TRANSMASK)>>FF_TRANSSHIFT, &Surf); + blend = HWR_SurfaceBlend(spr->mobj->blendmode, (spr->mobj->frame & FF_TRANSMASK)>>FF_TRANSSHIFT, &Surf); else { // BP: i agree that is little better in environement but it don't @@ -4167,7 +4210,7 @@ static void HWR_DrawSprite(gl_vissprite_t *spr) // Hurdler: PF_Environement would be cool, but we need to fix // the issue with the fog before Surf.PolyColor.s.alpha = 0xFF; - blend = PF_Translucent|occlusion; + blend = HWR_GetBlendModeFlag(spr->mobj->blendmode)|occlusion; if (!occlusion) use_linkdraw_hack = true; } @@ -4183,7 +4226,7 @@ static void HWR_DrawSprite(gl_vissprite_t *spr) if (!occlusion) use_linkdraw_hack = true; } - HWR_ProcessPolygon(&Surf, wallVerts, 4, blend|PF_Modulated|PF_Clip, 3, false); // sprite shader + HWR_ProcessPolygon(&Surf, wallVerts, 4, blend|PF_Modulated, 3, false); // sprite shader if (use_linkdraw_hack) HWR_LinkDrawHackAdd(wallVerts, spr); @@ -4271,10 +4314,10 @@ static inline void HWR_DrawPrecipitationSprite(gl_vissprite_t *spr) if (spr->mobj->flags2 & MF2_SHADOW) { Surf.PolyColor.s.alpha = 0x40; - blend = PF_Translucent; + blend = HWR_GetBlendModeFlag(spr->mobj->blendmode); } else if (spr->mobj->frame & FF_TRANSMASK) - blend = HWR_TranstableToAlpha((spr->mobj->frame & FF_TRANSMASK)>>FF_TRANSSHIFT, &Surf); + blend = HWR_SurfaceBlend(spr->mobj->blendmode, (spr->mobj->frame & FF_TRANSMASK)>>FF_TRANSSHIFT, &Surf); else { // BP: i agree that is little better in environement but it don't @@ -4282,10 +4325,10 @@ static inline void HWR_DrawPrecipitationSprite(gl_vissprite_t *spr) // Hurdler: PF_Environement would be cool, but we need to fix // the issue with the fog before Surf.PolyColor.s.alpha = 0xFF; - blend = PF_Translucent|PF_Occlude; + blend = HWR_GetBlendModeFlag(spr->mobj->blendmode)|PF_Occlude; } - HWR_ProcessPolygon(&Surf, wallVerts, 4, blend|PF_Modulated|PF_Clip, 3, false); // sprite shader + HWR_ProcessPolygon(&Surf, wallVerts, 4, blend|PF_Modulated, 3, false); // sprite shader } #endif @@ -4749,7 +4792,7 @@ static void HWR_DrawSprites(void) // (Other states probably don't matter. Here I left them same as in LinkDrawHackFinish) // Without this workaround the rest of the draw calls in this frame (including UI, screen texture) // can get drawn using an incorrect glBlendFunc, resulting in a occasional black screen. - HWD.pfnSetBlend(PF_Translucent|PF_Occlude|PF_Clip|PF_Masked); + HWD.pfnSetBlend(PF_Translucent|PF_Occlude|PF_Masked); } // -------------------------------------------------------------------------- @@ -6422,7 +6465,7 @@ void HWR_DoPostProcessor(player_t *player) Surf.PolyColor.s.alpha = 0xc0; // match software mode - HWD.pfnDrawPolygon(&Surf, v, 4, PF_Modulated|PF_Additive|PF_NoTexture|PF_NoDepthTest|PF_Clip|PF_NoZClip); + HWD.pfnDrawPolygon(&Surf, v, 4, PF_Modulated|PF_AdditiveSource|PF_NoTexture|PF_NoDepthTest); } // Capture the screen for intermission and screen waving diff --git a/src/hardware/hw_main.h b/src/hardware/hw_main.h index 381d7b0d7..bd4151826 100644 --- a/src/hardware/hw_main.h +++ b/src/hardware/hw_main.h @@ -54,7 +54,6 @@ boolean HWR_Screenshot(const char *pathname); void HWR_AddCommands(void); void HWR_AddSessionCommands(void); void transform(float *cx, float *cy, float *cz); -FBITFIELD HWR_TranstableToAlpha(INT32 transtablenum, FSurfaceInfo *pSurf); INT32 HWR_GetTextureUsed(void); void HWR_DoPostProcessor(player_t *player); void HWR_StartScreenWipe(void); @@ -65,10 +64,15 @@ void HWR_DoTintedWipe(UINT8 wipenum, UINT8 scrnnum); void HWR_MakeScreenFinalTexture(void); void HWR_DrawScreenFinalTexture(int width, int height); -// This stuff is put here so MD2's can use them +// This stuff is put here so models can use them void HWR_Lighting(FSurfaceInfo *Surface, INT32 light_level, extracolormap_t *colormap); UINT8 HWR_FogBlockAlpha(INT32 light, extracolormap_t *colormap); // Let's see if this can work +UINT8 HWR_GetTranstableAlpha(INT32 transtablenum); +FBITFIELD HWR_GetBlendModeFlag(INT32 ast); +FBITFIELD HWR_SurfaceBlend(INT32 style, INT32 transtablenum, FSurfaceInfo *pSurf); +FBITFIELD HWR_TranstableToAlpha(INT32 transtablenum, FSurfaceInfo *pSurf); + void HWR_ReadShaders(UINT16 wadnum, boolean PK3); boolean HWR_LoadShaders(void); diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index d5c9cedaf..4358c5024 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -1317,11 +1317,17 @@ boolean HWR_DrawModel(gl_vissprite_t *spr) //durs = tics; if (spr->mobj->flags2 & MF2_SHADOW) + { Surf.PolyColor.s.alpha = 0x40; + Surf.PolyFlags = HWR_GetBlendModeFlag(spr->mobj->blendmode); + } else if (spr->mobj->frame & FF_TRANSMASK) - HWR_TranstableToAlpha((spr->mobj->frame & FF_TRANSMASK)>>FF_TRANSSHIFT, &Surf); + Surf.PolyFlags = HWR_SurfaceBlend(spr->mobj->blendmode, (spr->mobj->frame & FF_TRANSMASK)>>FF_TRANSSHIFT, &Surf); else + { Surf.PolyColor.s.alpha = 0xFF; + Surf.PolyFlags = 0; + } // dont forget to enabled the depth test because we can't do this like // before: polygons models are not sorted diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index 8b0e746b2..e3f7e714b 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -425,6 +425,10 @@ static PFNglBufferData pglBufferData; typedef void (APIENTRY * PFNglDeleteBuffers) (GLsizei n, const GLuint *buffers); static PFNglDeleteBuffers pglDeleteBuffers; +/* 2.0 functions */ +typedef void (APIENTRY * PFNglBlendEquation) (GLenum mode); +static PFNglBlendEquation pglBlendEquation; + /* 1.2 Parms */ /* GL_CLAMP_TO_EDGE_EXT */ @@ -892,6 +896,9 @@ void SetupGLFunc4(void) pglBufferData = GetGLFunc("glBufferData"); pglDeleteBuffers = GetGLFunc("glDeleteBuffers"); + /* 2.0 funcs */ + pglBlendEquation = GetGLFunc("glBlendEquation"); + #ifdef GL_SHADERS pglCreateShader = GetGLFunc("glCreateShader"); pglShaderSource = GetGLFunc("glShaderSource"); @@ -1286,6 +1293,7 @@ void SetStates(void) pglTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + pglEnable(GL_ALPHA_TEST); pglAlphaFunc(GL_NOTEQUAL, 0.0f); //pglBlendFunc(GL_ONE, GL_ZERO); // copy pixel to frame buffer (opaque) @@ -1554,64 +1562,110 @@ EXPORT void HWRAPI(Draw2DLine) (F2DCoord * v1, pglEnable(GL_TEXTURE_2D); } -static void Clamp2D(GLenum pname) -{ - pglTexParameteri(GL_TEXTURE_2D, pname, GL_CLAMP); // fallback clamp - pglTexParameteri(GL_TEXTURE_2D, pname, GL_CLAMP_TO_EDGE); -} - // -----------------+ // SetBlend : Set render mode // -----------------+ // PF_Masked - we could use an ALPHA_TEST of GL_EQUAL, and alpha ref of 0, // is it faster when pixels are discarded ? + +static void Clamp2D(GLenum pname) +{ + pglTexParameteri(GL_TEXTURE_2D, pname, GL_CLAMP); // fallback clamp + pglTexParameteri(GL_TEXTURE_2D, pname, GL_CLAMP_TO_EDGE); +} + +static void SetBlendEquation(GLenum mode) +{ + if (pglBlendEquation) + pglBlendEquation(mode); +} + +static void SetBlendMode(FBITFIELD flags) +{ + // Set blending function + switch (flags) + { + case PF_Translucent & PF_Blending: + pglBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // alpha = level of transparency + break; + case PF_Masked & PF_Blending: + // Hurdler: does that mean lighting is only made by alpha src? + // it sounds ok, but not for polygonsmooth + pglBlendFunc(GL_SRC_ALPHA, GL_ZERO); // 0 alpha = holes in texture + break; + case PF_Additive & PF_Blending: + case PF_Subtractive & PF_Blending: + case PF_ReverseSubtract & PF_Blending: + case PF_Environment & PF_Blending: + pglBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); + break; + case PF_AdditiveSource & PF_Blending: + pglBlendFunc(GL_SRC_ALPHA, GL_ONE); // src * alpha + dest + break; + case PF_Multiplicative & PF_Blending: + pglBlendFunc(GL_DST_COLOR, GL_ZERO); + break; + case PF_Fog & PF_Fog: + // Sryder: Fog + // multiplies input colour by input alpha, and destination colour by input colour, then adds them + pglBlendFunc(GL_SRC_ALPHA, GL_SRC_COLOR); + break; + default: // must be 0, otherwise it's an error + // No blending + pglBlendFunc(GL_ONE, GL_ZERO); // the same as no blending + break; + } + + // Set blending equation + switch (flags) + { + case PF_Subtractive & PF_Blending: + SetBlendEquation(GL_FUNC_SUBTRACT); + break; + case PF_ReverseSubtract & PF_Blending: + // good for shadow + // not really but what else ? + SetBlendEquation(GL_FUNC_REVERSE_SUBTRACT); + break; + default: + SetBlendEquation(GL_FUNC_ADD); + break; + } + + // Alpha test + switch (flags) + { + case PF_Masked & PF_Blending: + pglAlphaFunc(GL_GREATER, 0.5f); + break; + case PF_Translucent & PF_Blending: + case PF_Additive & PF_Blending: + case PF_AdditiveSource & PF_Blending: + case PF_Subtractive & PF_Blending: + case PF_ReverseSubtract & PF_Blending: + case PF_Environment & PF_Blending: + case PF_Multiplicative & PF_Blending: + pglAlphaFunc(GL_NOTEQUAL, 0.0f); + break; + case PF_Fog & PF_Fog: + pglAlphaFunc(GL_ALWAYS, 0.0f); // Don't discard zero alpha fragments + break; + default: + pglAlphaFunc(GL_GREATER, 0.5f); + break; + } +} + EXPORT void HWRAPI(SetBlend) (FBITFIELD PolyFlags) { FBITFIELD Xor; Xor = CurrentPolyFlags^PolyFlags; - if (Xor & (PF_Blending|PF_RemoveYWrap|PF_ForceWrapX|PF_ForceWrapY|PF_Occlude|PF_NoTexture|PF_Modulated|PF_NoDepthTest|PF_Decal|PF_Invisible|PF_NoAlphaTest)) + if (Xor & (PF_Blending|PF_RemoveYWrap|PF_ForceWrapX|PF_ForceWrapY|PF_Occlude|PF_NoTexture|PF_Modulated|PF_NoDepthTest|PF_Decal|PF_Invisible)) { - if (Xor&(PF_Blending)) // if blending mode must be changed - { - switch (PolyFlags & PF_Blending) { - case PF_Translucent & PF_Blending: - pglBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // alpha = level of transparency - pglAlphaFunc(GL_NOTEQUAL, 0.0f); - break; - case PF_Masked & PF_Blending: - // Hurdler: does that mean lighting is only made by alpha src? - // it sounds ok, but not for polygonsmooth - pglBlendFunc(GL_SRC_ALPHA, GL_ZERO); // 0 alpha = holes in texture - pglAlphaFunc(GL_GREATER, 0.5f); - break; - case PF_Additive & PF_Blending: - pglBlendFunc(GL_SRC_ALPHA, GL_ONE); // src * alpha + dest - pglAlphaFunc(GL_NOTEQUAL, 0.0f); - break; - case PF_Environment & PF_Blending: - pglBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); - pglAlphaFunc(GL_NOTEQUAL, 0.0f); - break; - case PF_Substractive & PF_Blending: - // good for shadow - // not really but what else ? - pglBlendFunc(GL_ZERO, GL_ONE_MINUS_SRC_COLOR); - pglAlphaFunc(GL_NOTEQUAL, 0.0f); - break; - case PF_Fog & PF_Fog: - // Sryder: Fog - // multiplies input colour by input alpha, and destination colour by input colour, then adds them - pglBlendFunc(GL_SRC_ALPHA, GL_SRC_COLOR); - pglAlphaFunc(GL_ALWAYS, 0.0f); // Don't discard zero alpha fragments - break; - default : // must be 0, otherwise it's an error - // No blending - pglBlendFunc(GL_ONE, GL_ZERO); // the same as no blending - pglAlphaFunc(GL_GREATER, 0.5f); - break; - } - } + if (Xor & PF_Blending) // if blending mode must be changed + SetBlendMode(PolyFlags & PF_Blending); + if (Xor & PF_NoAlphaTest) { if (PolyFlags & PF_NoAlphaTest) @@ -1628,7 +1682,7 @@ EXPORT void HWRAPI(SetBlend) (FBITFIELD PolyFlags) pglDisable(GL_POLYGON_OFFSET_FILL); } - if (Xor&PF_NoDepthTest) + if (Xor & PF_NoDepthTest) { if (PolyFlags & PF_NoDepthTest) pglDepthFunc(GL_ALWAYS); //pglDisable(GL_DEPTH_TEST); @@ -1636,25 +1690,25 @@ EXPORT void HWRAPI(SetBlend) (FBITFIELD PolyFlags) pglDepthFunc(GL_LEQUAL); //pglEnable(GL_DEPTH_TEST); } - if (Xor&PF_RemoveYWrap) + if (Xor & PF_RemoveYWrap) { if (PolyFlags & PF_RemoveYWrap) Clamp2D(GL_TEXTURE_WRAP_T); } - if (Xor&PF_ForceWrapX) + if (Xor & PF_ForceWrapX) { if (PolyFlags & PF_ForceWrapX) pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); } - if (Xor&PF_ForceWrapY) + if (Xor & PF_ForceWrapY) { if (PolyFlags & PF_ForceWrapY) pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); } - if (Xor&PF_Modulated) + if (Xor & PF_Modulated) { #if defined (__unix__) || defined (UNIXCOMMON) if (oglflags & GLF_NOTEXENV) @@ -2613,7 +2667,7 @@ static void DrawModelEx(model_t *model, INT32 frameIndex, INT32 duration, INT32 else pglColor4ubv((GLubyte*)&Surface->PolyColor.s); - SetBlend((poly.alpha < 1 ? PF_Translucent : (PF_Masked|PF_Occlude))|PF_Modulated); + SetBlend((poly.alpha < 1 ? Surface->PolyFlags : (PF_Masked|PF_Occlude))|PF_Modulated); tint.red = byte2float[Surface->TintColor.s.red]; tint.green = byte2float[Surface->TintColor.s.green]; @@ -3194,7 +3248,7 @@ EXPORT void HWRAPI(DoScreenWipe)(void) pglClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); - SetBlend(PF_Modulated|PF_NoDepthTest|PF_Clip|PF_NoZClip); + SetBlend(PF_Modulated|PF_NoDepthTest); pglEnable(GL_TEXTURE_2D); // Draw the original screen @@ -3204,7 +3258,7 @@ EXPORT void HWRAPI(DoScreenWipe)(void) pglVertexPointer(3, GL_FLOAT, 0, screenVerts); pglDrawArrays(GL_TRIANGLE_FAN, 0, 4); - SetBlend(PF_Modulated|PF_Translucent|PF_NoDepthTest|PF_Clip|PF_NoZClip); + SetBlend(PF_Modulated|PF_Translucent|PF_NoDepthTest); // Draw the end screen that fades in pglActiveTexture(GL_TEXTURE0); diff --git a/src/lua_mobjlib.c b/src/lua_mobjlib.c index 75b0c2f89..75e8dba99 100644 --- a/src/lua_mobjlib.c +++ b/src/lua_mobjlib.c @@ -64,6 +64,7 @@ enum mobj_e { mobj_renderflags, mobj_skin, mobj_color, + mobj_blendmode, mobj_bnext, mobj_bprev, mobj_hnext, @@ -139,6 +140,7 @@ static const char *const mobj_opt[] = { "renderflags", "skin", "color", + "blendmode", "bnext", "bprev", "hnext", @@ -315,6 +317,9 @@ static int mobj_get(lua_State *L) case mobj_color: lua_pushinteger(L, mo->color); break; + case mobj_blendmode: + lua_pushinteger(L, mo->blendmode); + break; case mobj_bnext: LUA_PushUserdata(L, mo->bnext, META_MOBJ); break; @@ -650,6 +655,9 @@ static int mobj_set(lua_State *L) mo->color = newcolor; break; } + case mobj_blendmode: + mo->blendmode = (INT32)luaL_checkinteger(L, 3); + break; case mobj_bnext: return NOSETPOS; case mobj_bprev: diff --git a/src/p_mobj.c b/src/p_mobj.c index 389dddecd..7529b196a 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -10454,7 +10454,6 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type) mobj->tics = st->tics; mobj->sprite = st->sprite; mobj->frame = st->frame; // FF_FRAMEMASK for frame, and other bits.. - mobj->renderflags = 0; P_SetupStateAnimation(mobj, st); mobj->friction = ORIG_FRICTION; @@ -10471,6 +10470,7 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type) mobj->destscale = FRACUNIT/2; // Sprite rendering + mobj->blendmode = AST_TRANSLUCENT; mobj->spritexscale = mobj->spriteyscale = mobj->scale; mobj->spritexoffset = mobj->spriteyoffset = 0; mobj->floorspriteslope = NULL; diff --git a/src/p_mobj.h b/src/p_mobj.h index 3f03e6ada..a60da67d3 100644 --- a/src/p_mobj.h +++ b/src/p_mobj.h @@ -265,6 +265,7 @@ typedef enum { // Ran the thinker this tic. PCF_THUNK = 32, } precipflag_t; + // Map Object definition. typedef struct mobj_s { @@ -287,6 +288,7 @@ typedef struct mobj_s UINT16 anim_duration; // for FF_ANIMATE states UINT32 renderflags; // render flags + INT32 blendmode; // blend mode fixed_t spritexscale, spriteyscale; fixed_t spritexoffset, spriteyoffset; struct pslope_s *floorspriteslope; // The slope that the floorsprite is rotated by @@ -405,7 +407,7 @@ typedef struct precipmobj_s struct precipmobj_s **sprev; // killough 8/11/98: change to ptr-to-ptr // More drawing info: to determine current sprite. - angle_t angle, pitch, roll; // orientation + angle_t angle, pitch, roll; // orientation angle_t rollangle; spritenum_t sprite; // used to find patch_t and flip value UINT32 frame; // frame number, plus bits see p_pspr.h @@ -413,6 +415,7 @@ typedef struct precipmobj_s UINT16 anim_duration; // for FF_ANIMATE states UINT32 renderflags; // render flags + INT32 blendmode; // blend mode fixed_t spritexscale, spriteyscale; fixed_t spritexoffset, spriteyoffset; struct pslope_s *floorspriteslope; // The slope that the floorsprite is rotated by diff --git a/src/p_saveg.c b/src/p_saveg.c index 6bd24214d..8dc019b95 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -1395,11 +1395,12 @@ typedef enum MD2_ROLLANGLE = 1<<14, MD2_SHADOWSCALE = 1<<15, MD2_RENDERFLAGS = 1<<16, - MD2_SPRITEXSCALE = 1<<17, - MD2_SPRITEYSCALE = 1<<18, - MD2_SPRITEXOFFSET = 1<<19, - MD2_SPRITEYOFFSET = 1<<20, - MD2_FLOORSPRITESLOPE = 1<<21, + MD2_BLENDMODE = 1<<17, + MD2_SPRITEXSCALE = 1<<18, + MD2_SPRITEYSCALE = 1<<19, + MD2_SPRITEXOFFSET = 1<<20, + MD2_SPRITEYOFFSET = 1<<21, + MD2_FLOORSPRITESLOPE = 1<<22, } mobj_diff2_t; typedef enum @@ -1614,6 +1615,8 @@ static void SaveMobjThinker(const thinker_t *th, const UINT8 type) diff2 |= MD2_SHADOWSCALE; if (mobj->renderflags) diff2 |= MD2_RENDERFLAGS; + if (mobj->renderflags) + diff2 |= MD2_BLENDMODE; if (mobj->spritexscale != FRACUNIT) diff2 |= MD2_SPRITEXSCALE; if (mobj->spriteyscale != FRACUNIT) @@ -1775,6 +1778,8 @@ static void SaveMobjThinker(const thinker_t *th, const UINT8 type) WRITEFIXED(save_p, mobj->shadowscale); if (diff2 & MD2_RENDERFLAGS) WRITEUINT32(save_p, mobj->renderflags); + if (diff2 & MD2_BLENDMODE) + WRITEINT32(save_p, mobj->blendmode); if (diff2 & MD2_SPRITEXSCALE) WRITEFIXED(save_p, mobj->spritexscale); if (diff2 & MD2_SPRITEYSCALE) @@ -2813,6 +2818,8 @@ static thinker_t* LoadMobjThinker(actionf_p1 thinker) mobj->shadowscale = READFIXED(save_p); if (diff2 & MD2_RENDERFLAGS) mobj->renderflags = READUINT32(save_p); + if (diff2 & MD2_BLENDMODE) + mobj->blendmode = READINT32(save_p); if (diff2 & MD2_SPRITEXSCALE) mobj->spritexscale = READFIXED(save_p); if (diff2 & MD2_SPRITEYSCALE) diff --git a/src/r_data.c b/src/r_data.c index 3c7d76d21..af672f6dc 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -175,13 +175,15 @@ UINT8 ASTBlendPaletteIndexes(UINT8 background, UINT8 foreground, int style, UINT if (alpha <= ASTTextureBlendingThreshold[1]) { UINT8 *mytransmap; + INT32 trans; // Is the patch way too translucent? Don't blend then. if (alpha < ASTTextureBlendingThreshold[0]) return background; // The equation's not exact but it works as intended. I'll call it a day for now. - mytransmap = transtables + ((8*(alpha) + 255/8)/(255 - 255/11) << FF_TRANSSHIFT); + trans = (8*(alpha) + 255/8)/(255 - 255/11); + mytransmap = R_GetTranslucencyTable(trans + 1); if (background != 0xFF) return *(mytransmap + (background<<8) + foreground); } diff --git a/src/r_draw.c b/src/r_draw.c index e10d6e399..ac9b7a2cd 100644 --- a/src/r_draw.c +++ b/src/r_draw.c @@ -75,6 +75,7 @@ UINT8 *dc_source; #define NUMTRANSTABLES 9 // how many translucency tables are used UINT8 *transtables; // translucency tables +UINT8 *blendtables[NUMBLENDMAPS]; /** \brief R_DrawTransColumn uses this */ @@ -116,10 +117,6 @@ float focallengthf, zeroheight; UINT32 nflatxshift, nflatyshift, nflatshiftup, nflatmask; -// ========================================================================== -// OLD DOOM FUZZY EFFECT -// ========================================================================== - // ========================================================================= // TRANSLATION COLORMAP CODE // ========================================================================= @@ -139,11 +136,11 @@ UINT8 skincolor_modified[MAXSKINCOLORS]; CV_PossibleValue_t Color_cons_t[MAXSKINCOLORS+1]; -/** \brief The R_InitTranslationTables +#define TRANSTAB_AMTMUL10 (256.0f / 10.0f) - load in color translation tables +/** \brief Initializes the translucency tables used by the Software renderer. */ -void R_InitTranslationTables(void) +void R_InitTranslucencyTables(void) { // Load here the transparency lookup tables 'TINTTAB' // NOTE: the TINTTAB resource MUST BE aligned on 64k for the asm @@ -160,17 +157,94 @@ void R_InitTranslationTables(void) W_ReadLump(W_GetNumForName("TRANS70"), transtables+0x60000); W_ReadLump(W_GetNumForName("TRANS80"), transtables+0x70000); W_ReadLump(W_GetNumForName("TRANS90"), transtables+0x80000); + + R_GenerateBlendTables(); } +void R_GenerateBlendTables(void) +{ + INT32 i; -/** \brief Generates a translation colormap. + for (i = 0; i < NUMBLENDMAPS; i++) + { + if (i == blendtab_modulate) + continue; + blendtables[i] = Z_MallocAlign((NUMTRANSTABLES + 1) * 0x10000, PU_STATIC, NULL, 16); + } - \param dest_colormap colormap to populate - \param skinnum number of skin, TC_DEFAULT or TC_BOSS - \param color translation color + for (i = 0; i <= 9; i++) + { + const size_t offs = (0x10000 * i); + const UINT8 alpha = TRANSTAB_AMTMUL10 * i; - \return void -*/ + R_GenerateTranslucencyTable(blendtables[blendtab_add] + offs, AST_ADD, alpha); + R_GenerateTranslucencyTable(blendtables[blendtab_subtract] + offs, AST_SUBTRACT, alpha); + R_GenerateTranslucencyTable(blendtables[blendtab_reversesubtract] + offs, AST_REVERSESUBTRACT, alpha); + } + + // Modulation blending only requires a single table + blendtables[blendtab_modulate] = Z_MallocAlign(0x10000, PU_STATIC, NULL, 16); + R_GenerateTranslucencyTable(blendtables[blendtab_modulate], AST_MODULATE, 0); +} + +static colorlookup_t transtab_lut; + +void R_GenerateTranslucencyTable(UINT8 *table, int style, UINT8 blendamt) +{ + INT16 bg, fg; + + if (table == NULL) + I_Error("R_GenerateTranslucencyTable: input table was NULL!"); + + InitColorLUT(&transtab_lut, pMasterPalette, false); + + for (bg = 0; bg < 0xFF; bg++) + { + for (fg = 0; fg < 0xFF; fg++) + { + RGBA_t backrgba = V_GetMasterColor(bg); + RGBA_t frontrgba = V_GetMasterColor(fg); + RGBA_t result; + + result.rgba = ASTBlendPixel(backrgba, frontrgba, style, blendamt); + table[((bg * 0x100) + fg)] = GetColorLUT(&transtab_lut, result.s.red, result.s.green, result.s.blue); + } + } +} + +#define ClipTransLevel(trans) max(min((trans), NUMTRANSMAPS-2), 0) + +UINT8 *R_GetTranslucencyTable(INT32 alphalevel) +{ + return transtables + (ClipTransLevel(alphalevel-1) << FF_TRANSSHIFT); +} + +UINT8 *R_GetBlendTable(int style, INT32 alphalevel) +{ + size_t offs = (ClipTransLevel(alphalevel) << FF_TRANSSHIFT); + + // Lactozilla: Returns the equivalent to AST_TRANSLUCENT + // if no alpha style matches any of the blend tables. + switch (style) + { + case AST_ADD: + return blendtables[blendtab_add] + offs; + case AST_SUBTRACT: + return blendtables[blendtab_subtract] + offs; + case AST_REVERSESUBTRACT: + return blendtables[blendtab_reversesubtract] + offs; + case AST_MODULATE: + return blendtables[blendtab_modulate]; + default: + break; + } + + // Return a normal translucency table + if (--alphalevel >= 0) + return transtables + (ClipTransLevel(alphalevel) << FF_TRANSSHIFT); + else + return NULL; +} // Define for getting accurate color brightness readings according to how the human eye sees them. // https://en.wikipedia.org/wiki/Relative_luminance @@ -228,6 +302,14 @@ static void R_RainbowColormap(UINT8 *dest_colormap, UINT16 skincolor) #undef SETBRIGHTNESS +/** \brief Generates a translation colormap. + + \param dest_colormap colormap to populate + \param skinnum number of skin, TC_DEFAULT or TC_BOSS + \param color translation color + + \return void +*/ static void R_GenerateTranslationColormap(UINT8 *dest_colormap, INT32 skinnum, UINT16 color) { INT32 i, starttranscolor, skinramplength; diff --git a/src/r_draw.h b/src/r_draw.h index 5011d29d9..8ee028892 100644 --- a/src/r_draw.h +++ b/src/r_draw.h @@ -37,7 +37,6 @@ extern UINT8 dc_hires; extern UINT8 *dc_source; // first pixel in a column // translucency stuff here -extern UINT8 *transtables; // translucency tables, should be (*transtables)[5][256][256] extern UINT8 *dc_transmap; // translation stuff here @@ -111,17 +110,36 @@ extern lumpnum_t viewborderlump[8]; #define TC_BLINK -6 // For item blinking, according to kart #define TC_DASHMODE -7 // For Metal Sonic's dashmode +// Custom player skin translation // Initialize color translation tables, for player rendering etc. -void R_InitTranslationTables(void); UINT8* R_GetTranslationColormap(INT32 skinnum, skincolornum_t color, UINT8 flags); void R_FlushTranslationColormapCache(void); UINT16 R_GetColorByName(const char *name); UINT16 R_GetSuperColorByName(const char *name); +extern UINT8 *transtables; // translucency tables, should be (*transtables)[5][256][256] + +enum +{ + blendtab_add, + blendtab_subtract, + blendtab_reversesubtract, + blendtab_modulate, + NUMBLENDMAPS +}; + +extern UINT8 *blendtables[NUMBLENDMAPS]; + +void R_InitTranslucencyTables(void); +void R_GenerateBlendTables(void); +void R_GenerateTranslucencyTable(UINT8 *table, int style, UINT8 blendamt); + +UINT8 *R_GetTranslucencyTable(INT32 alphalevel); +UINT8 *R_GetBlendTable(int style, INT32 alphalevel); + // Color ramp modification should force a recache extern UINT8 skincolor_modified[]; -// Custom player skin translation void R_InitViewBuffer(INT32 width, INT32 height); void R_InitViewBorder(void); void R_VideoErase(size_t ofs, INT32 count); diff --git a/src/r_main.c b/src/r_main.c index 03f9c6818..2706522f5 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -1010,8 +1010,8 @@ void R_Init(void) //I_OutputMsg("\nR_InitLightTables"); R_InitLightTables(); - //I_OutputMsg("\nR_InitTranslationTables\n"); - R_InitTranslationTables(); + //I_OutputMsg("\nR_InitTranslucencyTables\n"); + R_InitTranslucencyTables(); R_InitDrawNodes(); diff --git a/src/r_plane.c b/src/r_plane.c index 096d1dbd6..5cd6a8c1f 100644 --- a/src/r_plane.c +++ b/src/r_plane.c @@ -780,7 +780,7 @@ void R_DrawSinglePlane(visplane_t *pl) else if (pl->polyobj->translucency > 0) { spanfunctype = (pl->polyobj->flags & POF_SPLAT) ? SPANDRAWFUNC_TRANSSPLAT : SPANDRAWFUNC_TRANS; - ds_transmap = transtables + ((pl->polyobj->translucency-1)<polyobj->translucency); } else if (pl->polyobj->flags & POF_SPLAT) // Opaque, but allow transparent flat pixels spanfunctype = SPANDRAWFUNC_SPLAT; @@ -819,23 +819,23 @@ void R_DrawSinglePlane(visplane_t *pl) if (pl->ffloor->alpha < 12) return; // Don't even draw it else if (pl->ffloor->alpha < 38) - ds_transmap = transtables + ((tr_trans90-1)<ffloor->alpha < 64) - ds_transmap = transtables + ((tr_trans80-1)<ffloor->alpha < 89) - ds_transmap = transtables + ((tr_trans70-1)<ffloor->alpha < 115) - ds_transmap = transtables + ((tr_trans60-1)<ffloor->alpha < 140) - ds_transmap = transtables + ((tr_trans50-1)<ffloor->alpha < 166) - ds_transmap = transtables + ((tr_trans40-1)<ffloor->alpha < 192) - ds_transmap = transtables + ((tr_trans30-1)<ffloor->alpha < 217) - ds_transmap = transtables + ((tr_trans20-1)<ffloor->alpha < 243) - ds_transmap = transtables + ((tr_trans10-1)<alpha > 0 && ldef->alpha < FRACUNIT) { - dc_transmap = transtables + ((R_GetLinedefTransTable(ldef->alpha) - 1) << FF_TRANSSHIFT); + dc_transmap = R_GetTranslucencyTable(R_GetLinedefTransTable(ldef->alpha)); colfunc = colfuncs[COLDRAWFUNC_FUZZY]; } @@ -165,7 +165,7 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2) if (curline->polyseg->translucency >= NUMTRANSMAPS) return; - dc_transmap = transtables + ((curline->polyseg->translucency-1)<polyseg->translucency); colfunc = colfuncs[COLDRAWFUNC_FUZZY]; } @@ -580,23 +580,23 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) if (pfloor->alpha < 12) return; // Don't even draw it else if (pfloor->alpha < 38) - dc_transmap = transtables + ((tr_trans90-1)<alpha < 64) - dc_transmap = transtables + ((tr_trans80-1)<alpha < 89) - dc_transmap = transtables + ((tr_trans70-1)<alpha < 115) - dc_transmap = transtables + ((tr_trans60-1)<alpha < 140) - dc_transmap = transtables + ((tr_trans50-1)<alpha < 166) - dc_transmap = transtables + ((tr_trans40-1)<alpha < 192) - dc_transmap = transtables + ((tr_trans30-1)<alpha < 217) - dc_transmap = transtables + ((tr_trans20-1)<alpha < 243) - dc_transmap = transtables + ((tr_trans10-1)<extra_colormap = thing->subsector->sector->extra_colormap; - shadow->transmap = transtables + (trans<transmap = R_GetTranslucencyTable(trans + 1); shadow->colormap = scalelight[0][0]; // full dark! objectsdrawn++; @@ -2007,8 +2007,8 @@ static void R_ProjectSprite(mobj_t *thing) vis->scale += FixedMul(scalestep, spriteyscale) * (vis->x1 - x1); } - if (cv_translucency.value && trans) - vis->transmap = transtables + ((trans-1)<blendmode != AST_COPY) && cv_translucency.value) + vis->transmap = R_GetBlendTable(thing->blendmode, trans); else vis->transmap = NULL; diff --git a/src/v_video.c b/src/v_video.c index 9aeded617..522883475 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -551,7 +551,7 @@ void V_DrawStretchyFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, fixed_t vsca if (alphalevel) { - v_translevel = transtables + ((alphalevel-1)<= 0) && dest < deststop; dest += vid.width) { u = 0; @@ -1683,7 +1683,7 @@ void V_DrawFadeFill(INT32 x, INT32 y, INT32 w, INT32 h, INT32 c, UINT16 color, U fadetable = ((color & 0xFF00) // Color is not palette index? ? ((UINT8 *)colormaps + strength*256) // Do COLORMAP fade. - : ((UINT8 *)transtables + ((9-strength)<= 0) && dest < deststop; dest += vid.width) { u = 0; @@ -1829,7 +1829,7 @@ void V_DrawFadeScreen(UINT16 color, UINT8 strength) ? ((UINT8 *)(((color & 0x0F00) == 0x0A00) ? fadecolormap // Do fadecolormap fade. : (((color & 0x0F00) == 0x0B00) ? fadecolormap + (256 * FADECOLORMAPROWS) // Do white fadecolormap fade. : colormaps)) + strength*256) // Do COLORMAP fade. - : ((UINT8 *)transtables + ((9-strength)< Date: Tue, 27 Oct 2020 20:21:56 +0100 Subject: [PATCH 0245/1080] Fix camera going wild after reloading the gamestate --- src/d_clisrv.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index af7907e67..30c558f2f 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -1607,6 +1607,14 @@ static void CL_ReloadReceivedSavegame(void) neededtic = gametic; maketic = neededtic; + ticcmd_oldangleturn[0] = players[consoleplayer].oldrelangleturn; + P_ForceLocalAngle(&players[consoleplayer], (angle_t)(players[consoleplayer].angleturn << 16)); + if (splitscreen) + { + ticcmd_oldangleturn[1] = players[secondarydisplayplayer].oldrelangleturn; + P_ForceLocalAngle(&players[secondarydisplayplayer], (angle_t)(players[secondarydisplayplayer].angleturn << 16)); + } + camera.subsector = R_PointInSubsector(camera.x, camera.y); camera2.subsector = R_PointInSubsector(camera2.x, camera2.y); From 804ad44e89324eb501db9a1278a73af9ae850862 Mon Sep 17 00:00:00 2001 From: Louis-Antoine Date: Tue, 27 Oct 2020 20:22:15 +0100 Subject: [PATCH 0246/1080] Fix music resetting after reloading the gamestate --- src/p_setup.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index d36401ac3..ea4a24f35 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -4038,18 +4038,20 @@ boolean P_LoadLevel(boolean fromnetsave, boolean reloadinggamestate) // Fade out music here. Deduct 2 tics so the fade volume actually reaches 0. // But don't halt the music! S_Start will take care of that. This dodges a MIDI crash bug. - if (!titlemapinaction && (RESETMUSIC || + if (!(reloadinggamestate || titlemapinaction) && (RESETMUSIC || strnicmp(S_MusicName(), (mapmusflags & MUSIC_RELOADRESET) ? mapheaderinfo[gamemap-1]->musname : mapmusname, 7))) + { S_FadeMusic(0, FixedMul( FixedDiv((F_GetWipeLength(wipedefs[wipe_level_toblack])-2)*NEWTICRATERATIO, NEWTICRATE), MUSICRATE)); + } // Let's fade to black here // But only if we didn't do the special stage wipe if (rendermode != render_none && !(ranspecialwipe || reloadinggamestate)) P_RunLevelWipe(); - if (!titlemapinaction) + if (!(reloadinggamestate || titlemapinaction)) { if (ranspecialwipe == 2) { From 395d1f1b8f38e0dc8c00cf29318cceffc1b9862b Mon Sep 17 00:00:00 2001 From: Louis-Antoine Date: Tue, 27 Oct 2020 20:23:32 +0100 Subject: [PATCH 0247/1080] Do not pause the client while redownloading the gamestate --- src/d_clisrv.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 30c558f2f..aa18ee380 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -4274,9 +4274,6 @@ static void HandlePacketFromPlayer(SINT8 node) break; } - if (cl_redownloadinggamestate) - break; - realstart = netbuffer->u.serverpak.starttic; realend = realstart + netbuffer->u.serverpak.numtics; @@ -5001,8 +4998,7 @@ void NetUpdate(void) if (cl_redownloadinggamestate && fileneeded[0].status == FS_FOUND) CL_ReloadReceivedSavegame(); - if (!cl_redownloadinggamestate) - CL_SendClientCmd(); // Send tic cmd + CL_SendClientCmd(); // Send tic cmd hu_redownloadinggamestate = cl_redownloadinggamestate; } else From e1789663671ca2318f732d3d0b475d9a8778730e Mon Sep 17 00:00:00 2001 From: Louis-Antoine Date: Tue, 27 Oct 2020 20:28:54 +0100 Subject: [PATCH 0248/1080] Remove useless condition --- src/d_clisrv.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index aa18ee380..a3fbe88d9 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -5022,24 +5022,18 @@ void NetUpdate(void) // Don't erase tics not acknowledged counts = realtics; - // Do not make tics while resynching - if (counts != -666) - { - if (maketic + counts >= firstticstosend + BACKUPTICS) - counts = firstticstosend+BACKUPTICS-maketic-1; + if (maketic + counts >= firstticstosend + BACKUPTICS) + counts = firstticstosend+BACKUPTICS-maketic-1; - for (i = 0; i < counts; i++) - SV_Maketic(); // Create missed tics and increment maketic + for (i = 0; i < counts; i++) + SV_Maketic(); // Create missed tics and increment maketic - for (; tictoclear < firstticstosend; tictoclear++) // Clear only when acknowledged - D_Clearticcmd(tictoclear); // Clear the maketic the new tic + for (; tictoclear < firstticstosend; tictoclear++) // Clear only when acknowledged + D_Clearticcmd(tictoclear); // Clear the maketic the new tic - SV_SendTics(); + SV_SendTics(); - neededtic = maketic; // The server is a client too - } - else - hu_redownloadinggamestate = true; + neededtic = maketic; // The server is a client too } } From b03d95c5c6ba63e15fe7aed7d3b5608e9dbfedc8 Mon Sep 17 00:00:00 2001 From: Jaime Passos Date: Tue, 27 Oct 2020 17:02:35 -0300 Subject: [PATCH 0249/1080] Bug fixes --- src/hardware/hw_main.c | 23 ++++++++++++++++++++--- src/hardware/hw_md2.c | 15 +++++---------- src/hardware/r_opengl/r_opengl.c | 10 ++++++++-- src/r_things.c | 10 +++++++--- 4 files changed, 40 insertions(+), 18 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index fb8318e09..8a4274d68 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -722,6 +722,8 @@ FBITFIELD HWR_GetBlendModeFlag(INT32 ast) UINT8 HWR_GetTranstableAlpha(INT32 transtablenum) { + transtablenum = max(min(transtablenum, tr_trans90), 0); + switch (transtablenum) { case 0 : return 0xff; @@ -3787,7 +3789,12 @@ static void HWR_SplitSprite(gl_vissprite_t *spr) blend = HWR_GetBlendModeFlag(spr->mobj->blendmode); } else if (spr->mobj->frame & FF_TRANSMASK) - blend = HWR_SurfaceBlend(spr->mobj->blendmode, (spr->mobj->frame & FF_TRANSMASK)>>FF_TRANSSHIFT, &Surf); + { + INT32 trans = (spr->mobj->frame & FF_TRANSMASK)>>FF_TRANSSHIFT; + if (spr->mobj->blendmode == AST_TRANSLUCENT && trans >= NUMTRANSMAPS) + return; + blend = HWR_SurfaceBlend(spr->mobj->blendmode, trans, &Surf); + } else { // BP: i agree that is little better in environement but it don't @@ -4202,7 +4209,12 @@ static void HWR_DrawSprite(gl_vissprite_t *spr) blend = HWR_GetBlendModeFlag(spr->mobj->blendmode); } else if (spr->mobj->frame & FF_TRANSMASK) - blend = HWR_SurfaceBlend(spr->mobj->blendmode, (spr->mobj->frame & FF_TRANSMASK)>>FF_TRANSSHIFT, &Surf); + { + INT32 trans = (spr->mobj->frame & FF_TRANSMASK)>>FF_TRANSSHIFT; + if (spr->mobj->blendmode == AST_TRANSLUCENT && trans >= NUMTRANSMAPS) + return; + blend = HWR_SurfaceBlend(spr->mobj->blendmode, trans, &Surf); + } else { // BP: i agree that is little better in environement but it don't @@ -4317,7 +4329,12 @@ static inline void HWR_DrawPrecipitationSprite(gl_vissprite_t *spr) blend = HWR_GetBlendModeFlag(spr->mobj->blendmode); } else if (spr->mobj->frame & FF_TRANSMASK) - blend = HWR_SurfaceBlend(spr->mobj->blendmode, (spr->mobj->frame & FF_TRANSMASK)>>FF_TRANSSHIFT, &Surf); + { + INT32 trans = (spr->mobj->frame & FF_TRANSMASK)>>FF_TRANSSHIFT; + if (spr->mobj->blendmode == AST_TRANSLUCENT && trans >= NUMTRANSMAPS) + return; + blend = HWR_SurfaceBlend(spr->mobj->blendmode, trans, &Surf); + } else { // BP: i agree that is little better in environement but it don't diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index 4358c5024..8ca38296a 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -1316,21 +1316,16 @@ boolean HWR_DrawModel(gl_vissprite_t *spr) //if (tics > durs) //durs = tics; - if (spr->mobj->flags2 & MF2_SHADOW) - { - Surf.PolyColor.s.alpha = 0x40; - Surf.PolyFlags = HWR_GetBlendModeFlag(spr->mobj->blendmode); - } - else if (spr->mobj->frame & FF_TRANSMASK) + if (spr->mobj->frame & FF_TRANSMASK) Surf.PolyFlags = HWR_SurfaceBlend(spr->mobj->blendmode, (spr->mobj->frame & FF_TRANSMASK)>>FF_TRANSSHIFT, &Surf); else { - Surf.PolyColor.s.alpha = 0xFF; - Surf.PolyFlags = 0; + Surf.PolyColor.s.alpha = (spr->mobj->flags2 & MF2_SHADOW) ? 0x40 : 0xff; + Surf.PolyFlags = HWR_GetBlendModeFlag(spr->mobj->blendmode); } - // dont forget to enabled the depth test because we can't do this like - // before: polygons models are not sorted + // don't forget to enable the depth test because we can't do this + // like before: model polygons are not sorted // 1. load model+texture if not already loaded // 2. draw model with correct position, rotation,... diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index e3f7e714b..728c59f64 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -2600,6 +2600,7 @@ static void DrawModelEx(model_t *model, INT32 frameIndex, INT32 duration, INT32 boolean useVBO = true; + FBITFIELD flags; int i; // Because otherwise, scaling the screen negatively vertically breaks the lighting @@ -2667,8 +2668,6 @@ static void DrawModelEx(model_t *model, INT32 frameIndex, INT32 duration, INT32 else pglColor4ubv((GLubyte*)&Surface->PolyColor.s); - SetBlend((poly.alpha < 1 ? Surface->PolyFlags : (PF_Masked|PF_Occlude))|PF_Modulated); - tint.red = byte2float[Surface->TintColor.s.red]; tint.green = byte2float[Surface->TintColor.s.green]; tint.blue = byte2float[Surface->TintColor.s.blue]; @@ -2679,6 +2678,13 @@ static void DrawModelEx(model_t *model, INT32 frameIndex, INT32 duration, INT32 fade.blue = byte2float[Surface->FadeColor.s.blue]; fade.alpha = byte2float[Surface->FadeColor.s.alpha]; + flags = (Surface->PolyFlags | PF_Modulated); + if (Surface->PolyFlags & (PF_Additive|PF_AdditiveSource|PF_Subtractive|PF_ReverseSubtract|PF_Multiplicative)) + flags |= PF_Occlude; + else if (Surface->PolyColor.s.alpha == 0xFF) + flags |= (PF_Occlude | PF_Masked); + + SetBlend(flags); Shader_Load(Surface, &poly, &tint, &fade); pglEnable(GL_CULL_FACE); diff --git a/src/r_things.c b/src/r_things.c index b85e4dfdc..916d2e891 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -1802,7 +1802,11 @@ static void R_ProjectSprite(mobj_t *thing) if (oldthing->flags2 & MF2_SHADOW || 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 (oldthing->frame & FF_TRANSMASK) + { trans = (oldthing->frame & FF_TRANSMASK) >> FF_TRANSSHIFT; + if (oldthing->blendmode == AST_TRANSLUCENT && trans >= NUMTRANSMAPS) + return; + } else trans = 0; @@ -1834,7 +1838,7 @@ static void R_ProjectSprite(mobj_t *thing) else trans += 3; - if (trans >= 9) + if (trans >= NUMTRANSMAPS) return; trans--; @@ -2007,8 +2011,8 @@ static void R_ProjectSprite(mobj_t *thing) vis->scale += FixedMul(scalestep, spriteyscale) * (vis->x1 - x1); } - if ((thing->blendmode != AST_COPY) && cv_translucency.value) - vis->transmap = R_GetBlendTable(thing->blendmode, trans); + if ((oldthing->blendmode != AST_COPY) && cv_translucency.value) + vis->transmap = R_GetBlendTable(oldthing->blendmode, trans); else vis->transmap = NULL; From 0f9d85694d7b941df14b485e60328d2ed4180695 Mon Sep 17 00:00:00 2001 From: Jaime Passos Date: Tue, 27 Oct 2020 19:54:10 -0300 Subject: [PATCH 0250/1080] Implement an "ignore colormaps" sprite rendering flag --- src/dehacked.c | 1 + src/hardware/hw_main.c | 41 ++++++++++++++++++++++++----------------- src/r_defs.h | 1 + src/r_things.c | 36 ++++++++++++++++++++---------------- 4 files changed, 46 insertions(+), 33 deletions(-) diff --git a/src/dehacked.c b/src/dehacked.c index 3562a2aec..67e83e4d5 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -9602,6 +9602,7 @@ struct { {"RF_BLENDMASK",RF_BLENDMASK}, {"RF_FULLBRIGHT",RF_FULLBRIGHT}, {"RF_FULLDARK",RF_FULLDARK}, + {"RF_NOCOLORMAPS",RF_NOCOLORMAPS}, {"RF_SPRITETYPEMASK",RF_SPRITETYPEMASK}, {"RF_PAPERSPRITE",RF_PAPERSPRITE}, {"RF_FLOORSPRITE",RF_FLOORSPRITE}, diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 8a4274d68..590fac520 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -3616,16 +3616,17 @@ static void HWR_DrawDropShadow(mobj_t *thing, fixed_t scale) shadowVerts[3].t = shadowVerts[2].t = 0; shadowVerts[0].t = shadowVerts[1].t = ((GLPatch_t *)gpatch->hardware)->max_t; - if (thing->subsector->sector->numlights) + if (!(thing->renderflags & RF_NOCOLORMAPS)) { - light = R_GetPlaneLight(thing->subsector->sector, groundz, false); // Always use the light at the top instead of whatever I was doing before + if (thing->subsector->sector->numlights) + { + // Always use the light at the top instead of whatever I was doing before + light = R_GetPlaneLight(thing->subsector->sector, groundz, false); - if (*thing->subsector->sector->lightlist[light].extra_colormap) - colormap = *thing->subsector->sector->lightlist[light].extra_colormap; - } - else - { - if (thing->subsector->sector->extra_colormap) + if (*thing->subsector->sector->lightlist[light].extra_colormap) + colormap = *thing->subsector->sector->lightlist[light].extra_colormap; + } + else if (thing->subsector->sector->extra_colormap) colormap = thing->subsector->sector->extra_colormap; } @@ -3675,7 +3676,7 @@ static void HWR_SplitSprite(gl_vissprite_t *spr) FOutVector baseWallVerts[4]; // This is what the verts should end up as patch_t *gpatch; FSurfaceInfo Surf; - extracolormap_t *colormap; + extracolormap_t *colormap = NULL; FUINT lightlevel; boolean lightset = true; FBITFIELD blend = 0; @@ -3810,7 +3811,9 @@ static void HWR_SplitSprite(gl_vissprite_t *spr) // Start with the lightlevel and colormap from the top of the sprite lightlevel = *list[sector->numlights - 1].lightlevel; - colormap = *list[sector->numlights - 1].extra_colormap; + if (!(spr->mobj->renderflags & RF_NOCOLORMAPS)) + colormap = *list[sector->numlights - 1].extra_colormap; + i = 0; temp = FLOAT_TO_FIXED(realtop); @@ -3828,7 +3831,8 @@ static void HWR_SplitSprite(gl_vissprite_t *spr) { if (!lightset) lightlevel = *list[i-1].lightlevel > 255 ? 255 : *list[i-1].lightlevel; - colormap = *list[i-1].extra_colormap; + if (!(spr->mobj->renderflags & RF_NOCOLORMAPS)) + colormap = *list[i-1].extra_colormap; break; } } @@ -3843,7 +3847,8 @@ static void HWR_SplitSprite(gl_vissprite_t *spr) { if (!lightset) lightlevel = *list[i].lightlevel > 255 ? 255 : *list[i].lightlevel; - colormap = *list[i].extra_colormap; + if (!(spr->mobj->renderflags & RF_NOCOLORMAPS)) + colormap = *list[i].extra_colormap; } if (i + 1 < sector->numlights) @@ -4160,7 +4165,7 @@ static void HWR_DrawSprite(gl_vissprite_t *spr) sector_t *sector = spr->mobj->subsector->sector; UINT8 lightlevel = 0; boolean lightset = true; - extracolormap_t *colormap = sector->extra_colormap; + extracolormap_t *colormap = NULL; if (R_ThingIsFullBright(spr->mobj)) lightlevel = 255; @@ -4169,6 +4174,9 @@ static void HWR_DrawSprite(gl_vissprite_t *spr) else lightset = false; + if (!(spr->mobj->renderflags & RF_NOCOLORMAPS)) + colormap = sector->extra_colormap; + if (splat && sector->numlights) { INT32 light = R_GetPlaneLight(sector, spr->mobj->z, false); @@ -4176,7 +4184,7 @@ static void HWR_DrawSprite(gl_vissprite_t *spr) if (!lightset) lightlevel = *sector->lightlist[light].lightlevel > 255 ? 255 : *sector->lightlist[light].lightlevel; - if (*sector->lightlist[light].extra_colormap) + if (*sector->lightlist[light].extra_colormap && !(spr->mobj->renderflags & RF_NOCOLORMAPS)) colormap = *sector->lightlist[light].extra_colormap; } else if (!lightset) @@ -4301,9 +4309,8 @@ static inline void HWR_DrawPrecipitationSprite(gl_vissprite_t *spr) if (sector->numlights) { - INT32 light; - - light = R_GetPlaneLight(sector, spr->mobj->z + spr->mobj->height, false); // Always use the light at the top instead of whatever I was doing before + // Always use the light at the top instead of whatever I was doing before + INT32 light = R_GetPlaneLight(sector, spr->mobj->z + spr->mobj->height, false); if (!(spr->mobj->frame & FF_FULLBRIGHT)) lightlevel = *sector->lightlist[light].lightlevel > 255 ? 255 : *sector->lightlist[light].lightlevel; diff --git a/src/r_defs.h b/src/r_defs.h index 4423a4266..9d0f4247c 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -729,6 +729,7 @@ typedef enum RF_BLENDMASK = 0x0F00, // --Blending modes RF_FULLBRIGHT = 0x0100, // Sprite is drawn at full brightness RF_FULLDARK = 0x0200, // Sprite is drawn completely dark + RF_NOCOLORMAPS = 0x0400, // Sprite is not drawn with colormaps RF_SPRITETYPEMASK = 0x7000, // ---Different sprite types, not all implemented RF_PAPERSPRITE = 0x1000, // Paper sprite diff --git a/src/r_things.c b/src/r_things.c index 916d2e891..5db78b346 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -842,7 +842,7 @@ static void R_DrawVisSprite(vissprite_t *vis) else if (vis->mobj->sprite == SPR_PLAY) // Looks like a player, but doesn't have a color? Get rid of green sonic syndrome. colfunc = colfuncs[COLDRAWFUNC_TRANS]; - if (vis->extra_colormap) + if (vis->extra_colormap && !(vis->renderflags & RF_NOCOLORMAPS)) { if (!dc_colormap) dc_colormap = vis->extra_colormap->colormap; @@ -1354,26 +1354,30 @@ static void R_ProjectDropShadow(mobj_t *thing, vissprite_t *vis, fixed_t scale, x1 += (x2-x1)/2; shadow->shear.offset = shadow->x1-x1; - if (thing->subsector->sector->numlights) + if (thing->renderflags & RF_NOCOLORMAPS) + shadow->extra_colormap = NULL; + else { - INT32 lightnum; - light = thing->subsector->sector->numlights - 1; + if (thing->subsector->sector->numlights) + { + INT32 lightnum; + light = thing->subsector->sector->numlights - 1; - // R_GetPlaneLight won't work on sloped lights! - for (lightnum = 1; lightnum < thing->subsector->sector->numlights; lightnum++) { - fixed_t h = P_GetLightZAt(&thing->subsector->sector->lightlist[lightnum], thing->x, thing->y); - if (h <= shadow->gzt) { - light = lightnum - 1; - break; + // R_GetPlaneLight won't work on sloped lights! + for (lightnum = 1; lightnum < thing->subsector->sector->numlights; lightnum++) { + fixed_t h = P_GetLightZAt(&thing->subsector->sector->lightlist[lightnum], thing->x, thing->y); + if (h <= shadow->gzt) { + light = lightnum - 1; + break; + } } } - //light = R_GetPlaneLight(thing->subsector->sector, shadow->gzt, false); - } - if (thing->subsector->sector->numlights) - shadow->extra_colormap = *thing->subsector->sector->lightlist[light].extra_colormap; - else - shadow->extra_colormap = thing->subsector->sector->extra_colormap; + if (thing->subsector->sector->numlights) + shadow->extra_colormap = *thing->subsector->sector->lightlist[light].extra_colormap; + else + shadow->extra_colormap = thing->subsector->sector->extra_colormap; + } shadow->transmap = R_GetTranslucencyTable(trans + 1); shadow->colormap = scalelight[0][0]; // full dark! From 4e56caa196d2580bf9ee0cfa20dddea9753ef1c2 Mon Sep 17 00:00:00 2001 From: Zippy_Zolton Date: Wed, 28 Oct 2020 01:23:05 -0500 Subject: [PATCH 0251/1080] Flame Shield Changes --- src/p_user.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/p_user.c b/src/p_user.c index 0d7331293..0cf5321ad 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -5107,6 +5107,8 @@ static boolean P_PlayerShieldThink(player_t *player, ticcmd_t *cmd, mobj_t *lock player->pflags |= PF_THOKKED|PF_SHIELDABILITY; P_Thrust(player->mo, player->mo->angle, FixedMul(30*FRACUNIT - FixedSqrt(FixedDiv(player->speed, player->mo->scale)), player->mo->scale)); player->drawangle = player->mo->angle; + player->pflags &= ~PF_NOJUMPDAMAGE; + P_SetPlayerMobjState(player->mo, S_PLAY_ROLL); S_StartSound(player->mo, sfx_s3k43); default: break; From 5241b83f979da3525c6b6929b0253eceea6fa7ce Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Wed, 28 Oct 2020 19:36:03 +0000 Subject: [PATCH 0252/1080] Fix seg->length and flength not being set at all for UDMF maps --- src/p_setup.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/p_setup.c b/src/p_setup.c index 7747f6462..8e09c34df 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2401,6 +2401,10 @@ static boolean P_LoadExtendedSubsectorsAndSegs(UINT8 **data, nodetype_t nodetype seg->angle = R_PointToAngle2(v1->x, v1->y, v2->x, v2->y); if (seg->linedef) segs[i].offset = FixedHypot(v1->x - seg->linedef->v1->x, v1->y - seg->linedef->v1->y); + seg->length = P_SegLength(seg); +#ifdef HWRENDER + seg->flength = (rendermode == render_opengl) ? P_SegLengthFloat(seg) : 0; +#endif } return true; From c44120eb8756b5acfb6e8b9feb25be89dab3ef43 Mon Sep 17 00:00:00 2001 From: Hannu Hanhi Date: Thu, 29 Oct 2020 16:04:25 +0200 Subject: [PATCH 0253/1080] Fix some copyright statements in new files --- src/hardware/hw_batching.c | 3 +-- src/hardware/hw_batching.h | 3 +-- src/m_perfstats.c | 3 +-- src/m_perfstats.h | 3 +-- 4 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/hardware/hw_batching.c b/src/hardware/hw_batching.c index a63be3a72..5ea9f55d4 100644 --- a/src/hardware/hw_batching.c +++ b/src/hardware/hw_batching.c @@ -1,7 +1,6 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- -// Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/hardware/hw_batching.h b/src/hardware/hw_batching.h index 7c108a4bd..3d22324ac 100644 --- a/src/hardware/hw_batching.h +++ b/src/hardware/hw_batching.h @@ -1,7 +1,6 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- -// Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/m_perfstats.c b/src/m_perfstats.c index df1e31b5e..085adda80 100644 --- a/src/m_perfstats.c +++ b/src/m_perfstats.c @@ -1,7 +1,6 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- -// Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/m_perfstats.h b/src/m_perfstats.h index 1db46025e..01a818c1c 100644 --- a/src/m_perfstats.h +++ b/src/m_perfstats.h @@ -1,7 +1,6 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- -// Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. From 6c00a96755ea9f3cdd4d77cc2e6cd810b341455f Mon Sep 17 00:00:00 2001 From: Zippy_Zolton Date: Thu, 29 Oct 2020 12:32:42 -0500 Subject: [PATCH 0254/1080] thunder shield :D --- src/p_user.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/p_user.c b/src/p_user.c index 0cf5321ad..e886e1331 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -4835,6 +4835,8 @@ void P_DoJumpShield(player_t *player) } #undef limitangle #undef numangles + player->pflags &= ~PF_NOJUMPDAMAGE; + P_SetPlayerMobjState(player->mo, S_PLAY_ROLL); S_StartSound(player->mo, sfx_s3k45); } else From 1155d875d50d6cd79c8aaf9228cd652cbda0cf73 Mon Sep 17 00:00:00 2001 From: Louis-Antoine Date: Fri, 30 Oct 2020 15:00:13 +0100 Subject: [PATCH 0255/1080] Use the same names as userdataType() for userdataMetatable() --- src/lua_baselib.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index e60b20095..468af0aa1 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -278,8 +278,18 @@ static int lib_registerMetatable(lua_State *L) // Returns nil if the string does not refer to a valid userdata type static int lib_userdataMetatable(lua_State *L) { + UINT32 i; const char *udname = luaL_checkstring(L, 1); - luaL_getmetatable(L, udname); + + // Find internal metatable name + for (i = 0; meta2utype[i].meta; i++) + if (!strcmp(udname, meta2utype[i].utype)) + { + luaL_getmetatable(L, meta2utype[i].meta); + return 1; + } + + lua_pushnil(L); return 1; } From bfbcc6910847166b90a8e9f5cc61ec28aee03540 Mon Sep 17 00:00:00 2001 From: lachwright Date: Sat, 31 Oct 2020 18:21:14 +1100 Subject: [PATCH 0256/1080] Draw save files from outwards in --- 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 6e0d520ae..5860f00ca 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -8246,7 +8246,7 @@ static void M_CacheLoadGameData(void) static void M_DrawLoadGameData(void) { - INT32 i, savetodraw, x, y, hsep = 90; + INT32 i, prev_i = 1, savetodraw, x, y, hsep = 90; skin_t *charskin = NULL; if (vid.width != BASEVIDWIDTH*vid.dupx) @@ -8255,8 +8255,9 @@ static void M_DrawLoadGameData(void) if (needpatchrecache) M_CacheLoadGameData(); - for (i = -2; i <= 2; i++) + for (i = 2; prev_i; i = -(i + ((UINT32)i >> 31))) // draws from outwards in; 2, -2, 1, -1, 0 { + prev_i = i; savetodraw = (saveSlotSelected + i + numsaves)%numsaves; x = (BASEVIDWIDTH/2 - 42 + loadgamescroll) + (i*hsep); y = 33 + 9; From 724d126015db83170329f606572491f1f191b9c9 Mon Sep 17 00:00:00 2001 From: Hannu Hanhi Date: Sat, 31 Oct 2020 16:39:05 +0200 Subject: [PATCH 0257/1080] Clarify licensing-related text in libdivide.h --- src/libdivide.h | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/src/libdivide.h b/src/libdivide.h index 51f9a633b..915da0070 100644 --- a/src/libdivide.h +++ b/src/libdivide.h @@ -8,8 +8,37 @@ // You may use libdivide under the terms of either of these. // See LICENSE.txt for more details. -// NOTICE: This version of libdivide has been modified for use with SRB2. -// Changes made: + +// NOTICE: This is an altered source version of libdivide. +// Libdivide is used here under the terms of the zlib license. +// Here is the zlib license text from https://github.com/ridiculousfish/libdivide/blob/master/LICENSE.txt +/* + zlib License + ------------ + + Copyright (C) 2010 - 2019 ridiculous_fish, + Copyright (C) 2016 - 2019 Kim Walisch, + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + + +// This version of libdivide has been modified for use with SRB2. +// Changes made include: // - unused parts commented out (to avoid the need to fix C90 compilation issues with them) // - C90 compilation issues fixed with used parts // - use I_Error for errors From 41d8210fd5ff71db25741fc2e481d4a70dd5dcec Mon Sep 17 00:00:00 2001 From: Steel Titanium Date: Sat, 31 Oct 2020 16:36:15 -0400 Subject: [PATCH 0258/1080] Expose gamestate to Lua --- src/dehacked.c | 17 +++++++++++++++++ src/lua_script.c | 4 ++++ 2 files changed, 21 insertions(+) diff --git a/src/dehacked.c b/src/dehacked.c index ca013a25d..a3f78edd4 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -38,6 +38,7 @@ #include "lua_script.h" #include "lua_hook.h" #include "d_clisrv.h" +#include "g_state.h" // gamestate_t (for lua) #include "m_cond.h" @@ -10106,6 +10107,22 @@ struct { {"MA_NOCUTSCENES",MA_NOCUTSCENES}, {"MA_INGAME",MA_INGAME}, + // gamestates + {"GS_NULL",GS_NULL}, + {"GS_LEVEL",GS_LEVEL}, + {"GS_INTERMISSION",GS_INTERMISSION}, + {"GS_CONTINUING",GS_CONTINUING}, + {"GS_TITLESCREEN",GS_TITLESCREEN}, + {"GS_TIMEATTACK",GS_TIMEATTACK}, + {"GS_CREDITS",GS_CREDITS}, + {"GS_EVALUATION",GS_EVALUATION}, + {"GS_GAMEEND",GS_GAMEEND}, + {"GS_INTRO",GS_INTRO}, + {"GS_ENDING",GS_ENDING}, + {"GS_CUTSCENE",GS_CUTSCENE}, + {"GS_DEDICATEDSERVER",GS_DEDICATEDSERVER}, + {"GS_WAITINGPLAYERS",GS_WAITINGPLAYERS}, + {NULL,0} }; diff --git a/src/lua_script.c b/src/lua_script.c index ae7f479f6..6e40cb785 100644 --- a/src/lua_script.c +++ b/src/lua_script.c @@ -34,6 +34,7 @@ #include "lua_hook.h" #include "doomstat.h" +#include "g_state.h" lua_State *gL = NULL; @@ -361,6 +362,9 @@ int LUA_PushGlobals(lua_State *L, const char *word) } else if (fastcmp(word, "token")) { lua_pushinteger(L, token); return 1; + } else if (fastcmp(word, "gamestate")) { + lua_pushinteger(L, gamestate); + return 1; } return 0; } From ac7781a3b3ac1b96132b5c5ef44652f00330b604 Mon Sep 17 00:00:00 2001 From: Steel Titanium Date: Sat, 31 Oct 2020 20:15:41 -0500 Subject: [PATCH 0259/1080] Expose more music functions to Lua --- src/dehacked.c | 16 ++++ src/lua_baselib.c | 188 ++++++++++++++++++++++++++++++++++++++++++++++ src/lua_hook.h | 2 + src/lua_hooklib.c | 60 +++++++++++++++ src/s_sound.c | 7 +- 5 files changed, 267 insertions(+), 6 deletions(-) diff --git a/src/dehacked.c b/src/dehacked.c index ca013a25d..ae22e19d5 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -26,6 +26,7 @@ #include "dehacked.h" #include "st_stuff.h" #include "i_system.h" +#include "i_sound.h" // musictype_t (for lua) #include "p_local.h" // for var1 and var2, and some constants #include "p_setup.h" #include "r_data.h" @@ -10106,6 +10107,21 @@ struct { {"MA_NOCUTSCENES",MA_NOCUTSCENES}, {"MA_INGAME",MA_INGAME}, + // music types + {"MU_NONE", MU_NONE}, + {"MU_CMD", MU_CMD}, + {"MU_WAV", MU_WAV}, + {"MU_MOD", MU_MOD}, + {"MU_MID", MU_MID}, + {"MU_OGG", MU_OGG}, + {"MU_MP3", MU_MP3}, + {"MU_MP3_MAD_UNUSED", MU_MP3_MAD_UNUSED}, + {"MU_FLAC", MU_FLAC}, + {"MU_MODPLUG_UNUSED", MU_MODPLUG_UNUSED}, + {"MU_GME", MU_GME}, + {"MU_MOD_EX", MU_MOD_EX}, + {"MU_MID_EX", MU_MID_EX}, + {NULL,0} }; diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 132ebc1a8..6cb3a0719 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -3006,6 +3006,185 @@ static int lib_sStartMusicCaption(lua_State *L) return 0; } +static int lib_sMusicType(lua_State *L) +{ + player_t *player = NULL; + NOHUD + if (!lua_isnone(L, 1) && lua_isuserdata(L, 1)) + { + player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); + if (!player) + return LUA_ErrInvalid(L, "player_t"); + } + if (!player || P_IsLocalPlayer(player)) + lua_pushinteger(L, S_MusicType()); + else + lua_pushnil(L); + return 1; +} + +static int lib_sMusicPlaying(lua_State *L) +{ + player_t *player = NULL; + NOHUD + if (!lua_isnone(L, 1) && lua_isuserdata(L, 1)) + { + player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); + if (!player) + return LUA_ErrInvalid(L, "player_t"); + } + if (!player || P_IsLocalPlayer(player)) + lua_pushboolean(L, S_MusicPlaying()); + else + lua_pushnil(L); + return 1; +} + +static int lib_sMusicPaused(lua_State *L) +{ + player_t *player = NULL; + NOHUD + if (!lua_isnone(L, 1) && lua_isuserdata(L, 1)) + { + player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); + if (!player) + return LUA_ErrInvalid(L, "player_t"); + } + if (!player || P_IsLocalPlayer(player)) + lua_pushboolean(L, S_MusicPaused()); + else + lua_pushnil(L); + return 1; +} + +static int lib_sMusicName(lua_State *L) +{ + player_t *player = NULL; + NOHUD + if (!lua_isnone(L, 1) && lua_isuserdata(L, 1)) + { + player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); + if (!player) + return LUA_ErrInvalid(L, "player_t"); + } + if (!player || P_IsLocalPlayer(player)) + lua_pushstring(L, S_MusicName()); + else + lua_pushnil(L); + return 1; +} + +static int lib_sMusicExists(lua_State *L) +{ + boolean checkMIDI = lua_opttrueboolean(L, 2); + boolean checkDigi = lua_opttrueboolean(L, 3); +#ifdef MUSICSLOT_COMPATIBILITY + const char *music_name; + UINT32 music_num; + char music_compat_name[7]; + UINT16 music_flags = 0; + NOHUD + if (lua_isnumber(L, 1)) + { + music_num = (UINT32)luaL_checkinteger(L, 1); + music_flags = (UINT16)(music_num & 0x0000FFFF); + if (music_flags && music_flags <= 1035) + snprintf(music_compat_name, 7, "%sM", G_BuildMapName((INT32)music_flags)); + else if (music_flags && music_flags <= 1050) + strncpy(music_compat_name, compat_special_music_slots[music_flags - 1036], 7); + else + music_compat_name[0] = 0; // becomes empty string + music_compat_name[6] = 0; + music_name = (const char *)&music_compat_name; + } + else + { + music_num = 0; + music_name = luaL_checkstring(L, 1); + } +#else + const char *music_name = luaL_checkstring(L, 1); +#endif + NOHUD + lua_pushboolean(L, S_MusicExists(music_name, checkMIDI, checkDigi)); + return 1; +} + +static int lib_sSetMusicLoopPoint(lua_State *L) +{ + UINT32 looppoint = (UINT32)luaL_checkinteger(L, 1); + player_t *player = NULL; + NOHUD + if (!lua_isnone(L, 2) && lua_isuserdata(L, 2)) + { + player = *((player_t **)luaL_checkudata(L, 2, META_PLAYER)); + if (!player) + return LUA_ErrInvalid(L, "player_t"); + } + if (!player || P_IsLocalPlayer(player)) + lua_pushboolean(L, S_SetMusicLoopPoint(looppoint)); + else + lua_pushnil(L); + return 1; +} + +static int lib_sGetMusicLoopPoint(lua_State *L) +{ + player_t *player = NULL; + NOHUD + if (!lua_isnone(L, 1) && lua_isuserdata(L, 1)) + { + player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); + if (!player) + return LUA_ErrInvalid(L, "player_t"); + } + if (!player || P_IsLocalPlayer(player)) + lua_pushinteger(L, (int)S_GetMusicLoopPoint()); + else + lua_pushnil(L); + return 1; +} + +static int lib_sPauseMusic(lua_State *L) +{ + player_t *player = NULL; + NOHUD + if (!lua_isnone(L, 1) && lua_isuserdata(L, 1)) + { + player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); + if (!player) + return LUA_ErrInvalid(L, "player_t"); + } + if (!player || P_IsLocalPlayer(player)) + { + S_PauseAudio(); + lua_pushboolean(L, true); + } + else + lua_pushnil(L); + return 1; +} + +static int lib_sResumeMusic(lua_State *L) +{ + player_t *player = NULL; + NOHUD + if (!lua_isnone(L, 1) && lua_isuserdata(L, 1)) + { + player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); + if (!player) + return LUA_ErrInvalid(L, "player_t"); + } + if (!player || P_IsLocalPlayer(player)) + { + S_ResumeAudio(); + lua_pushboolean(L, true); + } + else + lua_pushnil(L); + return 1; +} + // G_GAME //////////// @@ -3712,6 +3891,15 @@ static luaL_Reg lib[] = { {"S_IdPlaying",lib_sIdPlaying}, {"S_SoundPlaying",lib_sSoundPlaying}, {"S_StartMusicCaption", lib_sStartMusicCaption}, + {"S_MusicType",lib_sMusicType}, + {"S_MusicPlaying",lib_sMusicPlaying}, + {"S_MusicPaused",lib_sMusicPaused}, + {"S_MusicName",lib_sMusicName}, + {"S_MusicExists",lib_sMusicExists}, + {"S_SetMusicLoopPoint",lib_sSetMusicLoopPoint}, + {"S_GetMusicLoopPoint",lib_sGetMusicLoopPoint}, + {"S_PauseMusic",lib_sPauseMusic}, + {"S_ResumeMusic", lib_sResumeMusic}, // g_game {"G_AddGametype", lib_gAddGametype}, diff --git a/src/lua_hook.h b/src/lua_hook.h index 47850812f..796f3a9d2 100644 --- a/src/lua_hook.h +++ b/src/lua_hook.h @@ -60,6 +60,7 @@ enum hook { hook_ShouldJingleContinue, hook_GameQuit, hook_PlayerCmd, + hook_MusicChange, hook_MAX // last hook }; @@ -118,3 +119,4 @@ boolean LUAh_SeenPlayer(player_t *player, player_t *seenfriend); // Hook for MT_ boolean LUAh_ShouldJingleContinue(player_t *player, const char *musname); // Hook for whether a jingle of the given music should continue playing void LUAh_GameQuit(void); // Hook for game quitting boolean LUAh_PlayerCmd(player_t *player, ticcmd_t *cmd); // Hook for building player's ticcmd struct (Ported from SRB2Kart) +boolean LUAh_MusicChange(const char *oldname, char *newname, UINT16 *mflags, boolean *looping, UINT32 *position, UINT32 *prefadems, UINT32 *fadeinms); // Hook for music changes \ No newline at end of file diff --git a/src/lua_hooklib.c b/src/lua_hooklib.c index 65d483dc1..117aa48a3 100644 --- a/src/lua_hooklib.c +++ b/src/lua_hooklib.c @@ -76,6 +76,7 @@ const char *const hookNames[hook_MAX+1] = { "ShouldJingleContinue", "GameQuit", "PlayerCmd", + "MusicChange", NULL }; @@ -1912,3 +1913,62 @@ boolean LUAh_PlayerCmd(player_t *player, ticcmd_t *cmd) hook_cmd_running = false; return hooked; } + +// Hook for music changes +boolean LUAh_MusicChange(const char *oldname, char *newname, UINT16 *mflags, boolean *looping, + UINT32 *position, UINT32 *prefadems, UINT32 *fadeinms) +{ + hook_p hookp; + boolean hooked = false; + + if (!gL || !(hooksAvailable[hook_MusicChange/8] & (1<<(hook_MusicChange%8)))) + return false; + + lua_settop(gL, 0); + lua_pushcfunction(gL, LUA_GetErrorMessage); + + for (hookp = roothook; hookp; hookp = hookp->next) + if (hookp->type == hook_MusicChange) + { + PushHook(gL, hookp); + lua_pushstring(gL, oldname); + lua_pushstring(gL, newname); + lua_pushinteger(gL, *mflags); + lua_pushboolean(gL, *looping); + lua_pushinteger(gL, *position); + lua_pushinteger(gL, *prefadems); + lua_pushinteger(gL, *fadeinms); + if (lua_pcall(gL, 7, 6, 1)) { + CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL,-1)); + lua_pop(gL, 1); + continue; + } + + // output 1: true, false, or string musicname override + if (lua_isboolean(gL, -6) && lua_toboolean(gL, -6)) + hooked = true; + else if (lua_isstring(gL, -6)) + strncpy(newname, lua_tostring(gL, -6), 7); + // output 2: mflags override + if (lua_isnumber(gL, -5)) + *mflags = lua_tonumber(gL, -5); + // output 3: looping override + if (lua_isboolean(gL, -4)) + *looping = lua_toboolean(gL, -4); + // output 4: position override + if (lua_isboolean(gL, -3)) + *position = lua_tonumber(gL, -3); + // output 5: prefadems override + if (lua_isboolean(gL, -2)) + *prefadems = lua_tonumber(gL, -2); + // output 6: fadeinms override + if (lua_isboolean(gL, -1)) + *fadeinms = lua_tonumber(gL, -1); + + lua_pop(gL, 7); // Pop returned values and error handler + } + + lua_settop(gL, 0); + newname[6] = 0; + return hooked; +} \ No newline at end of file diff --git a/src/s_sound.c b/src/s_sound.c index 793794aa7..36bd454c1 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -29,10 +29,7 @@ #include "fastcmp.h" #include "m_misc.h" // for tunes command #include "m_cond.h" // for conditionsets - -#ifdef HAVE_LUA_MUSICPLUS #include "lua_hook.h" // MusicChange hook -#endif #ifdef HW3SOUND // 3D Sound Interface @@ -2272,10 +2269,8 @@ void S_ChangeMusicEx(const char *mmusic, UINT16 mflags, boolean looping, UINT32 return; strncpy(newmusic, mmusic, 7); -#ifdef HAVE_LUA_MUSICPLUS - if(LUAh_MusicChange(music_name, newmusic, &mflags, &looping, &position, &prefadems, &fadeinms)) + if (LUAh_MusicChange(music_name, newmusic, &mflags, &looping, &position, &prefadems, &fadeinms)) return; -#endif newmusic[6] = 0; // No Music (empty string) From 37931fc2531a83a42366fb219eb98bff8c800249 Mon Sep 17 00:00:00 2001 From: James R Date: Sun, 1 Nov 2020 19:31:10 -0800 Subject: [PATCH 0260/1080] The lump is not needed for P_WriteThings --- src/m_cheat.c | 2 +- src/p_setup.c | 7 +------ src/p_setup.h | 2 +- 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/src/m_cheat.c b/src/m_cheat.c index 349f00c48..b28524fd3 100644 --- a/src/m_cheat.c +++ b/src/m_cheat.c @@ -1435,7 +1435,7 @@ void Command_Writethings_f(void) REQUIRE_SINGLEPLAYER; REQUIRE_OBJECTPLACE; - P_WriteThings(W_GetNumForName(G_BuildMapName(gamemap)) + ML_THINGS); + P_WriteThings(); } void Command_ObjectPlace_f(void) diff --git a/src/p_setup.c b/src/p_setup.c index 7747f6462..578fb6d53 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -904,16 +904,13 @@ static void P_SpawnMapThings(boolean spawnemblems) } // Experimental groovy write function! -void P_WriteThings(lumpnum_t lumpnum) +void P_WriteThings(void) { size_t i, length; mapthing_t *mt; - UINT8 *data; UINT8 *savebuffer, *savebuf_p; INT16 temp; - data = W_CacheLumpNum(lumpnum, PU_LEVEL); - savebuf_p = savebuffer = (UINT8 *)malloc(nummapthings * sizeof (mapthing_t)); if (!savebuf_p) @@ -935,8 +932,6 @@ void P_WriteThings(lumpnum_t lumpnum) WRITEUINT16(savebuf_p, mt->options); } - Z_Free(data); - length = savebuf_p - savebuffer; FIL_WriteFile(va("newthings%d.lmp", gamemap), savebuffer, length); diff --git a/src/p_setup.h b/src/p_setup.h index ef903e103..f8ff11706 100644 --- a/src/p_setup.h +++ b/src/p_setup.h @@ -105,7 +105,7 @@ boolean P_AddWadFile(const char *wadfilename); boolean P_RunSOC(const char *socfilename); void P_LoadSoundsRange(UINT16 wadnum, UINT16 first, UINT16 num); void P_LoadMusicsRange(UINT16 wadnum, UINT16 first, UINT16 num); -void P_WriteThings(lumpnum_t lump); +void P_WriteThings(void); size_t P_PrecacheLevelFlats(void); void P_AllocMapHeader(INT16 i); From 1f7df8a79098c8cc1e2c8f4dfb9e34ae977b2f3e Mon Sep 17 00:00:00 2001 From: GoldenTails Date: Tue, 3 Nov 2020 20:11:39 -0600 Subject: [PATCH 0261/1080] Fix hyperwalls --- 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 0a9107ee5..2380a6d52 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -3107,7 +3107,7 @@ static void P_HitSlideLine(line_t *ld) lineangle >>= ANGLETOFINESHIFT; deltaangle >>= ANGLETOFINESHIFT; - movelen = P_AproxDistance(tmxmove, tmymove); + movelen = R_PointToDist2(0, 0, tmxmove, tmymove); newlen = FixedMul(movelen, FINECOSINE(deltaangle)); tmxmove = FixedMul(newlen, FINECOSINE(lineangle)); From 805818d48ef98468859c64a537cc1151bf3c3549 Mon Sep 17 00:00:00 2001 From: Jaime Passos Date: Wed, 4 Nov 2020 21:43:16 -0300 Subject: [PATCH 0262/1080] R_DrawSplatSprite -> R_DrawFloorSprite --- src/r_splats.c | 2 +- src/r_splats.h | 2 +- src/r_things.c | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/r_splats.c b/src/r_splats.c index 6de0a7917..7d091d9ff 100644 --- a/src/r_splats.c +++ b/src/r_splats.c @@ -137,7 +137,7 @@ static void rasterize_segment_tex(INT32 x1, INT32 y1, INT32 x2, INT32 y2, INT32 } } -void R_DrawSplatSprite(vissprite_t *spr) +void R_DrawFloorSprite(vissprite_t *spr) { floorsplat_t splat; mobj_t *mobj = spr->mobj; diff --git a/src/r_splats.h b/src/r_splats.h index 737a2c703..e1f836f48 100644 --- a/src/r_splats.h +++ b/src/r_splats.h @@ -42,7 +42,7 @@ typedef struct floorsplat_s mobj_t *mobj; // Mobj it is tied to } floorsplat_t; -void R_DrawSplatSprite(vissprite_t *spr); +void R_DrawFloorSprite(vissprite_t *spr); void R_RenderFloorSplat(floorsplat_t *pSplat, vector2_t *verts, vissprite_t *vis); #endif /*__R_SPLATS_H__*/ diff --git a/src/r_things.c b/src/r_things.c index 5db78b346..1ca0349e9 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -2787,7 +2787,7 @@ static void R_DrawSprite(vissprite_t *spr) mceilingclip = spr->cliptop; if (spr->cut & SC_SPLAT) - R_DrawSplatSprite(spr); + R_DrawFloorSprite(spr); else R_DrawVisSprite(spr); } @@ -3075,12 +3075,12 @@ boolean R_ThingIsFloorSprite(mobj_t *thing) return (thing->flags2 & MF2_SPLAT || thing->renderflags & RF_FLOORSPRITE); } -boolean R_ThingIsFullBright (mobj_t *thing) +boolean R_ThingIsFullBright(mobj_t *thing) { return (thing->frame & FF_FULLBRIGHT || thing->renderflags & RF_FULLBRIGHT); } -boolean R_ThingIsFullDark (mobj_t *thing) +boolean R_ThingIsFullDark(mobj_t *thing) { return (thing->renderflags & RF_FULLDARK); } From c07c80fd9e626f15b4d84d1766f8963e089d295a Mon Sep 17 00:00:00 2001 From: Jaime Passos Date: Wed, 4 Nov 2020 23:46:34 -0300 Subject: [PATCH 0263/1080] Plane optimization and cleanup --- src/r_draw.c | 6 +- src/r_draw.h | 5 +- src/r_main.c | 10 +++ src/r_plane.c | 193 ++++++++++++++++++++++++++++--------------------- src/r_splats.c | 73 ++++++++----------- 5 files changed, 157 insertions(+), 130 deletions(-) diff --git a/src/r_draw.c b/src/r_draw.c index ac9b7a2cd..eb4dc412f 100644 --- a/src/r_draw.c +++ b/src/r_draw.c @@ -104,11 +104,11 @@ fixed_t ds_xfrac, ds_yfrac, ds_xstep, ds_ystep; UINT16 ds_flatwidth, ds_flatheight; boolean ds_powersoftwo; -UINT8 *ds_source; // start of a 64*64 tile image +UINT8 *ds_source; // points to the start of a flat UINT8 *ds_transmap; // one of the translucency tables -pslope_t *ds_slope; // Current slope being used -floatv3_t ds_su[MAXVIDHEIGHT], ds_sv[MAXVIDHEIGHT], ds_sz[MAXVIDHEIGHT]; // Vectors for... stuff? +// Vectors for Software's tilted slope drawers +floatv3_t *ds_su, *ds_sv, *ds_sz; floatv3_t *ds_sup, *ds_svp, *ds_szp; float focallengthf, zeroheight; diff --git a/src/r_draw.h b/src/r_draw.h index 8ee028892..fd40c76ce 100644 --- a/src/r_draw.h +++ b/src/r_draw.h @@ -59,6 +59,7 @@ extern lighttable_t *ds_translation; extern fixed_t ds_xfrac, ds_yfrac, ds_xstep, ds_ystep; extern UINT16 ds_flatwidth, ds_flatheight; extern boolean ds_powersoftwo; + extern UINT8 *ds_source; extern UINT8 *ds_transmap; @@ -66,8 +67,8 @@ typedef struct { float x, y, z; } floatv3_t; -extern pslope_t *ds_slope; // Current slope being used -extern floatv3_t ds_su[MAXVIDHEIGHT], ds_sv[MAXVIDHEIGHT], ds_sz[MAXVIDHEIGHT]; // Vectors for... stuff? +// Vectors for Software's tilted slope drawers +extern floatv3_t *ds_su, *ds_sv, *ds_sz; extern floatv3_t *ds_sup, *ds_svp, *ds_szp; extern float focallengthf, zeroheight; diff --git a/src/r_main.c b/src/r_main.c index 2706522f5..4f8990b21 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -958,6 +958,16 @@ void R_ExecuteSetViewSize(void) dy = FixedMul(abs(dy), fovtan); yslopetab[i] = FixedDiv(centerx*FRACUNIT, dy); } + + if (ds_su) + Z_Free(ds_su); + if (ds_sv) + Z_Free(ds_sv); + if (ds_sz) + Z_Free(ds_sz); + + ds_su = ds_sv = ds_sz = NULL; + ds_sup = ds_svp = ds_szp = NULL; } memset(scalelight, 0xFF, sizeof(scalelight)); diff --git a/src/r_plane.c b/src/r_plane.c index 5cd6a8c1f..789134534 100644 --- a/src/r_plane.c +++ b/src/r_plane.c @@ -117,29 +117,41 @@ void R_InitPlanes(void) // // Water ripple effect!! // Needs the height of the plane, and the vertical position of the span. -// Sets ripple_xfrac and ripple_yfrac, added to ds_xfrac and ds_yfrac, if the span is not tilted. +// Sets planeripple.xfrac and planeripple.yfrac, added to ds_xfrac and ds_yfrac, if the span is not tilted. // #ifndef NOWATER INT32 ds_bgofs; INT32 ds_waterofs; -static INT32 wtofs=0; -static boolean itswater; -static fixed_t ripple_xfrac; -static fixed_t ripple_yfrac; +struct +{ + INT32 offset; + fixed_t xfrac, yfrac; + boolean active; +} planeripple; -static void R_PlaneRipple(visplane_t *plane, INT32 y, fixed_t plheight) +static void R_CalculatePlaneRipple(visplane_t *plane, INT32 y, fixed_t plheight, boolean calcfrac) { fixed_t distance = FixedMul(plheight, yslope[y]); - const INT32 yay = (wtofs + (distance>>9) ) & 8191; + const INT32 yay = (planeripple.offset + (distance>>9)) & 8191; + // ripples da water texture - angle_t angle = (plane->viewangle + plane->plangle)>>ANGLETOFINESHIFT; ds_bgofs = FixedDiv(FINESINE(yay), (1<<12) + (distance>>11))>>FRACBITS; - angle = (angle + 2048) & 8191; // 90 degrees - ripple_xfrac = FixedMul(FINECOSINE(angle), (ds_bgofs<viewangle + plane->plangle)>>ANGLETOFINESHIFT; + angle = (angle + 2048) & 8191; // 90 degrees + planeripple.xfrac = FixedMul(FINECOSINE(angle), (ds_bgofs<= vid.width) x1 = vid.width - 1; + if (x1 >= vid.width) + x1 = vid.width - 1; - angle = (currentplane->viewangle + currentplane->plangle)>>ANGLETOFINESHIFT; - planecos = FINECOSINE(angle); - planesin = FINESINE(angle); - - if (planeheight != cachedheight[y]) + if (!currentplane->slope) { - cachedheight[y] = planeheight; - distance = cacheddistance[y] = FixedMul(planeheight, yslope[y]); - ds_xstep = cachedxstep[y] = FixedMul(distance, basexscale); - ds_ystep = cachedystep[y] = FixedMul(distance, baseyscale); + angle = (currentplane->viewangle + currentplane->plangle)>>ANGLETOFINESHIFT; + planecos = FINECOSINE(angle); + planesin = FINESINE(angle); - if ((span = abs(centery-y))) + if (planeheight != cachedheight[y]) { - ds_xstep = cachedxstep[y] = FixedMul(planesin, planeheight) / span; - ds_ystep = cachedystep[y] = FixedMul(planecos, planeheight) / span; - } - } - else - { - distance = cacheddistance[y]; - ds_xstep = cachedxstep[y]; - ds_ystep = cachedystep[y]; - } + cachedheight[y] = planeheight; + cacheddistance[y] = distance = FixedMul(planeheight, yslope[y]); + span = abs(centery - y); - ds_xfrac = xoffs + FixedMul(planecos, distance) + (x1 - centerx) * ds_xstep; - ds_yfrac = yoffs - FixedMul(planesin, distance) + (x1 - centerx) * ds_ystep; + if (span) // don't divide by zero + { + ds_xstep = FixedMul(planesin, planeheight) / span; + ds_ystep = FixedMul(planecos, planeheight) / span; + } + else + { + ds_xstep = FixedMul(distance, basexscale); + ds_ystep = FixedMul(distance, baseyscale); + } + + cachedxstep[y] = ds_xstep; + cachedystep[y] = ds_ystep; + } + else + { + distance = cacheddistance[y]; + ds_xstep = cachedxstep[y]; + ds_ystep = cachedystep[y]; + } + + ds_xfrac = xoffs + FixedMul(planecos, distance) + (x1 - centerx) * ds_xstep; + ds_yfrac = yoffs - FixedMul(planesin, distance) + (x1 - centerx) * ds_ystep; + } #ifndef NOWATER - if (itswater) + if (planeripple.active) { // Needed for ds_bgofs - R_PlaneRipple(currentplane, y, planeheight); + R_CalculatePlaneRipple(currentplane, y, planeheight, (!currentplane->slope)); if (currentplane->slope) { @@ -211,25 +233,26 @@ void R_MapPlane(INT32 y, INT32 x1, INT32 x2) } else { - ds_xfrac += ripple_xfrac; - ds_yfrac += ripple_yfrac; + ds_xfrac += planeripple.xfrac; + ds_yfrac += planeripple.yfrac; } - if (y+ds_bgofs>=viewheight) + if ((y + ds_bgofs) >= viewheight) ds_bgofs = viewheight-y-1; - if (y+ds_bgofs<0) + if ((y + ds_bgofs) < 0) ds_bgofs = -y; } #endif - pindex = distance >> LIGHTZSHIFT; - if (pindex >= MAXLIGHTZ) - pindex = MAXLIGHTZ - 1; - if (currentplane->slope) ds_colormap = colormaps; else + { + pindex = distance >> LIGHTZSHIFT; + if (pindex >= MAXLIGHTZ) + pindex = MAXLIGHTZ - 1; ds_colormap = planezlight[pindex]; + } if (currentplane->extra_colormap) ds_colormap = currentplane->extra_colormap->colormap + (ds_colormap - colormaps); @@ -596,9 +619,9 @@ void R_DrawPlanes(void) R_DrawSinglePlane(pl); } } + #ifndef NOWATER - ds_waterofs = (leveltime & 1)*16384; - wtofs = leveltime * 140; + R_UpdatePlaneRipple(); #endif } @@ -738,12 +761,20 @@ d->z = (v1.x * v2.y) - (v1.y * v2.x) #undef SFMULT } -static void R_SlopePlaneVectors(visplane_t *pl, INT32 i, float fudge) +static void R_SetSlopePlaneVectors(visplane_t *pl, INT32 y, fixed_t xoff, fixed_t yoff, float fudge) { - ds_sup = &ds_su[i]; - ds_svp = &ds_sv[i]; - ds_szp = &ds_sz[i]; - R_CalculateSlopeVectors(pl->slope, pl->viewx, pl->viewy, pl->viewz, FRACUNIT, FRACUNIT, xoffs, yoffs, pl->viewangle, pl->plangle, fudge); + if (ds_su == NULL) + ds_su = Z_Malloc(sizeof(*ds_su) * vid.height, PU_STATIC, NULL); + if (ds_sv == NULL) + ds_sv = Z_Malloc(sizeof(*ds_sv) * vid.height, PU_STATIC, NULL); + if (ds_sz == NULL) + ds_sz = Z_Malloc(sizeof(*ds_sz) * vid.height, PU_STATIC, NULL); + + ds_sup = &ds_su[y]; + ds_svp = &ds_sv[y]; + ds_szp = &ds_sz[y]; + + R_CalculateSlopeVectors(pl->slope, pl->viewx, pl->viewy, pl->viewz, FRACUNIT, FRACUNIT, xoff, yoff, pl->viewangle, pl->plangle, fudge); } void R_DrawSinglePlane(visplane_t *pl) @@ -768,7 +799,7 @@ void R_DrawSinglePlane(visplane_t *pl) } #ifndef NOWATER - itswater = false; + planeripple.active = false; #endif spanfunc = spanfuncs[BASEDRAWFUNC]; @@ -851,12 +882,13 @@ void R_DrawSinglePlane(visplane_t *pl) } else light = (pl->lightlevel >> LIGHTSEGSHIFT); - #ifndef NOWATER +#ifndef NOWATER if (pl->ffloor->flags & FF_RIPPLE) { INT32 top, bottom; - itswater = true; + planeripple.active = true; + if (spanfunctype == SPANDRAWFUNC_TRANS) { spanfunctype = SPANDRAWFUNC_WATER; @@ -876,7 +908,7 @@ void R_DrawSinglePlane(visplane_t *pl) vid.width, vid.width); } } - #endif +#endif } else light = (pl->lightlevel >> LIGHTSEGSHIFT); @@ -979,50 +1011,45 @@ void R_DrawSinglePlane(visplane_t *pl) xoffs -= (pl->slope->o.x + (1 << (31-nflatshiftup))) & ~((1 << (32-nflatshiftup))-1); yoffs += (pl->slope->o.y + (1 << (31-nflatshiftup))) & ~((1 << (32-nflatshiftup))-1); } + xoffs = (fixed_t)(xoffs*fudgecanyon); yoffs = (fixed_t)(yoffs/fudgecanyon); } - ds_sup = &ds_su[0]; - ds_svp = &ds_sv[0]; - ds_szp = &ds_sz[0]; - #ifndef NOWATER - if (itswater) + if (planeripple.active) { - INT32 i; fixed_t plheight = abs(P_GetSlopeZAt(pl->slope, pl->viewx, pl->viewy) - pl->viewz); - fixed_t rxoffs = xoffs; - fixed_t ryoffs = yoffs; R_PlaneBounds(pl); - for (i = pl->high; i < pl->low; i++) + for (x = pl->high; x < pl->low; x++) { - R_PlaneRipple(pl, i, plheight); - xoffs = rxoffs + ripple_xfrac; - yoffs = ryoffs + ripple_yfrac; - R_SlopePlaneVectors(pl, i, fudgecanyon); + R_CalculatePlaneRipple(pl, x, plheight, true); + R_SetSlopePlaneVectors(pl, x, (xoffs + planeripple.xfrac), (yoffs + planeripple.yfrac), fudgecanyon); } - - xoffs = rxoffs; - yoffs = ryoffs; } else #endif - R_SlopePlaneVectors(pl, 0, fudgecanyon); + R_SetSlopePlaneVectors(pl, 0, xoffs, yoffs, fudgecanyon); + switch (spanfunctype) + { #ifndef NOWATER - if (itswater && (spanfunctype == SPANDRAWFUNC_WATER)) - spanfunctype = SPANDRAWFUNC_TILTEDWATER; - else + case SPANDRAWFUNC_WATER: + spanfunctype = SPANDRAWFUNC_TILTEDWATER; + break; #endif - if (spanfunctype == SPANDRAWFUNC_TRANS) - spanfunctype = SPANDRAWFUNC_TILTEDTRANS; - else if (spanfunctype == SPANDRAWFUNC_SPLAT) - spanfunctype = SPANDRAWFUNC_TILTEDSPLAT; - else - spanfunctype = SPANDRAWFUNC_TILTED; + case SPANDRAWFUNC_TRANS: + spanfunctype = SPANDRAWFUNC_TILTEDTRANS; + break; + case SPANDRAWFUNC_SPLAT: + spanfunctype = SPANDRAWFUNC_TILTEDSPLAT; + break; + default: + spanfunctype = SPANDRAWFUNC_TILTED; + break; + } planezlight = scalelight[light]; } diff --git a/src/r_splats.c b/src/r_splats.c index 7d091d9ff..636aa30ed 100644 --- a/src/r_splats.c +++ b/src/r_splats.c @@ -344,13 +344,9 @@ void R_RenderFloorSplat(floorsplat_t *pSplat, vector2_t *verts, vissprite_t *vis INT32 miny = viewheight + 1, maxy = 0; INT32 y, x1, ry1, x2, y2, i; fixed_t offsetx = 0, offsety = 0; + fixed_t planeheight = 0; fixed_t step; - fixed_t planeheight; - fixed_t xstep, ystep; - angle_t angle, planecos, planesin; - fixed_t distance, span; - int spanfunctype = SPANDRAWFUNC_SPRITE; prepare_rastertab(); @@ -431,14 +427,17 @@ void R_RenderFloorSplat(floorsplat_t *pSplat, vector2_t *verts, vissprite_t *vis } else { + planeheight = abs(pSplat->z - viewz); + if (pSplat->angle) { // Add the view offset, rotated by the plane angle. fixed_t a = -pSplat->verts[0].x + viewx; fixed_t b = -pSplat->verts[0].y + viewy; - angle = (pSplat->angle >> ANGLETOFINESHIFT); + angle_t angle = (pSplat->angle >> ANGLETOFINESHIFT); offsetx = FixedMul(a, FINECOSINE(angle)) - FixedMul(b,FINESINE(angle)); offsety = -FixedMul(a, FINESINE(angle)) - FixedMul(b,FINECOSINE(angle)); + memset(cachedheight, 0, sizeof(cachedheight)); } else { @@ -477,21 +476,6 @@ void R_RenderFloorSplat(floorsplat_t *pSplat, vector2_t *verts, vissprite_t *vis else spanfunc = spanfuncs_npo2[spanfunctype]; - if (pSplat->angle && !pSplat->tilted) - { - memset(cachedheight, 0, sizeof(cachedheight)); - angle = (viewangle + pSplat->angle - ANGLE_90) >> ANGLETOFINESHIFT; - basexscale = FixedDiv(FINECOSINE(angle), centerxfrac); - baseyscale = -FixedDiv(FINESINE(angle), centerxfrac); - } - else - { - angle = (viewangle - ANGLE_90) >> ANGLETOFINESHIFT; - basexscale = FixedDiv(FINECOSINE(angle), centerxfrac); - baseyscale = -FixedDiv(FINESINE(angle), centerxfrac); - } - - planeheight = abs(pSplat->z - viewz); if (maxy >= vid.height) maxy = vid.height-1; @@ -543,25 +527,38 @@ void R_RenderFloorSplat(floorsplat_t *pSplat, vector2_t *verts, vissprite_t *vis break; } + if (x2 < x1) + continue; + if (!pSplat->tilted) { - angle = (viewangle + pSplat->angle)>>ANGLETOFINESHIFT; - planecos = FINECOSINE(angle); - planesin = FINESINE(angle); + fixed_t xstep, ystep; + fixed_t distance, span; + + angle_t angle = (viewangle + pSplat->angle)>>ANGLETOFINESHIFT; + angle_t planecos = FINECOSINE(angle); + angle_t planesin = FINESINE(angle); if (planeheight != cachedheight[y]) { cachedheight[y] = planeheight; distance = cacheddistance[y] = FixedMul(planeheight, yslope[y]); - xstep = cachedxstep[y] = FixedMul(distance, basexscale); - ystep = cachedystep[y] = FixedMul(distance, baseyscale); + span = abs(centery - y); - // don't divide by zero - if ((span = abs(centery-y))) + if (span) // don't divide by zero { - xstep = cachedxstep[y] = FixedMul(planesin, planeheight) / span; - ystep = cachedystep[y] = FixedMul(planecos, planeheight) / span; + xstep = FixedMul(planesin, planeheight) / span; + ystep = FixedMul(planecos, planeheight) / span; } + else + { + // ah + xstep = FRACUNIT; + ystep = FRACUNIT; + } + + cachedxstep[y] = xstep; + cachedystep[y] = ystep; } else { @@ -577,25 +574,17 @@ void R_RenderFloorSplat(floorsplat_t *pSplat, vector2_t *verts, vissprite_t *vis ds_yfrac = FixedDiv(offsety - FixedMul(planesin, distance) + (x1 - centerx) * ystep, pSplat->yscale); } - if (x2 >= x1) - { - ds_y = y; - ds_x1 = x1; - ds_x2 = x2; - spanfunc(); - } + ds_y = y; + ds_x1 = x1; + ds_x2 = x2; + spanfunc(); rastertab[y].minx = INT32_MAX; rastertab[y].maxx = INT32_MIN; } if (pSplat->angle && !pSplat->tilted) - { memset(cachedheight, 0, sizeof(cachedheight)); - angle = (viewangle - ANGLE_90) >> ANGLETOFINESHIFT; - basexscale = FixedDiv(FINECOSINE(angle), centerxfrac); - baseyscale = -FixedDiv(FINESINE(angle), centerxfrac); - } } static void prepare_rastertab(void) From 8f65b98c241cf55395e6774232ae5f6c217f597e Mon Sep 17 00:00:00 2001 From: Jaime Passos Date: Thu, 5 Nov 2020 00:00:08 -0300 Subject: [PATCH 0264/1080] Remove NOWATER define --- src/r_draw.c | 3 +++ src/r_draw.h | 10 +++------- src/r_draw8.c | 4 ---- src/r_draw8_npo2.c | 2 -- src/r_plane.c | 26 +++----------------------- src/screen.c | 24 ++++++++---------------- src/screen.h | 16 ++++++++-------- 7 files changed, 25 insertions(+), 60 deletions(-) diff --git a/src/r_draw.c b/src/r_draw.c index eb4dc412f..d9ea942a2 100644 --- a/src/r_draw.c +++ b/src/r_draw.c @@ -100,7 +100,10 @@ INT32 dc_numlights = 0, dc_maxlights, dc_texheight; INT32 ds_y, ds_x1, ds_x2; lighttable_t *ds_colormap; lighttable_t *ds_translation; // Lactozilla: Sprite splat drawer + fixed_t ds_xfrac, ds_yfrac, ds_xstep, ds_ystep; +INT32 ds_waterofs, ds_bgofs; + UINT16 ds_flatwidth, ds_flatheight; boolean ds_powersoftwo; diff --git a/src/r_draw.h b/src/r_draw.h index fd40c76ce..9957541ca 100644 --- a/src/r_draw.h +++ b/src/r_draw.h @@ -56,7 +56,10 @@ extern INT32 dc_texheight; extern INT32 ds_y, ds_x1, ds_x2; extern lighttable_t *ds_colormap; extern lighttable_t *ds_translation; + extern fixed_t ds_xfrac, ds_yfrac, ds_xstep, ds_ystep; +extern INT32 ds_waterofs, ds_bgofs; + extern UINT16 ds_flatwidth, ds_flatheight; extern boolean ds_powersoftwo; @@ -188,14 +191,9 @@ void R_DrawTiltedTranslucentFloorSprite_8(void); void R_CalcTiltedLighting(fixed_t start, fixed_t end); extern INT32 tiltlighting[MAXVIDWIDTH]; -#ifndef NOWATER void R_DrawTranslucentWaterSpan_8(void); void R_DrawTiltedTranslucentWaterSpan_8(void); -extern INT32 ds_bgofs; -extern INT32 ds_waterofs; -#endif - void R_DrawFogSpan_8(void); // Lactozilla: Non-powers-of-two @@ -213,10 +211,8 @@ void R_DrawTranslucentFloorSprite_NPO2_8(void); void R_DrawTiltedFloorSprite_NPO2_8(void); void R_DrawTiltedTranslucentFloorSprite_NPO2_8(void); -#ifndef NOWATER void R_DrawTranslucentWaterSpan_NPO2_8(void); void R_DrawTiltedTranslucentWaterSpan_NPO2_8(void); -#endif #ifdef USEASM void ASMCALL R_DrawColumn_8_ASM(void); diff --git a/src/r_draw8.c b/src/r_draw8.c index c28a25cbc..e78ba8a6c 100644 --- a/src/r_draw8.c +++ b/src/r_draw8.c @@ -911,7 +911,6 @@ void R_DrawTiltedTranslucentSpan_8(void) #endif } -#ifndef NOWATER /** \brief The R_DrawTiltedTranslucentWaterSpan_8 function Like DrawTiltedTranslucentSpan, but for water */ @@ -1045,7 +1044,6 @@ void R_DrawTiltedTranslucentWaterSpan_8(void) } #endif } -#endif // NOWATER void R_DrawTiltedSplat_8(void) { @@ -1934,7 +1932,6 @@ void R_DrawTranslucentSpan_8 (void) } } -#ifndef NOWATER void R_DrawTranslucentWaterSpan_8(void) { UINT32 xposition; @@ -2011,7 +2008,6 @@ void R_DrawTranslucentWaterSpan_8(void) yposition += ystep; } } -#endif /** \brief The R_DrawFogSpan_8 function Draws the actual span with fogging. diff --git a/src/r_draw8_npo2.c b/src/r_draw8_npo2.c index 895869e2d..d55e40302 100644 --- a/src/r_draw8_npo2.c +++ b/src/r_draw8_npo2.c @@ -1190,7 +1190,6 @@ void R_DrawTranslucentSpan_NPO2_8 (void) } } -#ifndef NOWATER void R_DrawTranslucentWaterSpan_NPO2_8(void) { fixed_t xposition; @@ -1426,4 +1425,3 @@ void R_DrawTiltedTranslucentWaterSpan_NPO2_8(void) } #endif } -#endif // NOWATER diff --git a/src/r_plane.c b/src/r_plane.c index 789134534..c3bec9a9e 100644 --- a/src/r_plane.c +++ b/src/r_plane.c @@ -115,15 +115,11 @@ void R_InitPlanes(void) } // -// Water ripple effect!! +// Water ripple effect // Needs the height of the plane, and the vertical position of the span. // Sets planeripple.xfrac and planeripple.yfrac, added to ds_xfrac and ds_yfrac, if the span is not tilted. // -#ifndef NOWATER -INT32 ds_bgofs; -INT32 ds_waterofs; - struct { INT32 offset; @@ -153,7 +149,6 @@ static void R_UpdatePlaneRipple(void) ds_waterofs = (leveltime & 1)*16384; planeripple.offset = (leveltime * 140); } -#endif // // R_MapPlane @@ -219,7 +214,7 @@ void R_MapPlane(INT32 y, INT32 x1, INT32 x2) ds_yfrac = yoffs - FixedMul(planesin, distance) + (x1 - centerx) * ds_ystep; } -#ifndef NOWATER + // Water ripple effect if (planeripple.active) { // Needed for ds_bgofs @@ -242,7 +237,6 @@ void R_MapPlane(INT32 y, INT32 x1, INT32 x2) if ((y + ds_bgofs) < 0) ds_bgofs = -y; } -#endif if (currentplane->slope) ds_colormap = colormaps; @@ -605,9 +599,7 @@ void R_DrawPlanes(void) visplane_t *pl; INT32 i; - // Note: are these two lines really needed? - // R_DrawSinglePlane and R_DrawSkyPlane do span/column drawer resets themselves anyway - spanfunc = spanfuncs[BASEDRAWFUNC]; + R_UpdatePlaneRipple(); for (i = 0; i < MAXVISPLANES; i++, pl++) { @@ -619,10 +611,6 @@ void R_DrawPlanes(void) R_DrawSinglePlane(pl); } } - -#ifndef NOWATER - R_UpdatePlaneRipple(); -#endif } // R_DrawSkyPlane @@ -798,9 +786,7 @@ void R_DrawSinglePlane(visplane_t *pl) return; } -#ifndef NOWATER planeripple.active = false; -#endif spanfunc = spanfuncs[BASEDRAWFUNC]; if (pl->polyobj) @@ -882,7 +868,6 @@ void R_DrawSinglePlane(visplane_t *pl) } else light = (pl->lightlevel >> LIGHTSEGSHIFT); -#ifndef NOWATER if (pl->ffloor->flags & FF_RIPPLE) { INT32 top, bottom; @@ -908,7 +893,6 @@ void R_DrawSinglePlane(visplane_t *pl) vid.width, vid.width); } } -#endif } else light = (pl->lightlevel >> LIGHTSEGSHIFT); @@ -1016,7 +1000,6 @@ void R_DrawSinglePlane(visplane_t *pl) yoffs = (fixed_t)(yoffs/fudgecanyon); } -#ifndef NOWATER if (planeripple.active) { fixed_t plheight = abs(P_GetSlopeZAt(pl->slope, pl->viewx, pl->viewy) - pl->viewz); @@ -1030,16 +1013,13 @@ void R_DrawSinglePlane(visplane_t *pl) } } else -#endif R_SetSlopePlaneVectors(pl, 0, xoffs, yoffs, fudgecanyon); switch (spanfunctype) { -#ifndef NOWATER case SPANDRAWFUNC_WATER: spanfunctype = SPANDRAWFUNC_TILTEDWATER; break; -#endif case SPANDRAWFUNC_TRANS: spanfunctype = SPANDRAWFUNC_TILTEDTRANS; break; diff --git a/src/screen.c b/src/screen.c index 8b6c05b6a..f14cf4bf6 100644 --- a/src/screen.c +++ b/src/screen.c @@ -122,42 +122,34 @@ void SCR_SetDrawFuncs(void) colfuncs[COLDRAWFUNC_FOG] = R_DrawFogColumn_8; spanfuncs[SPANDRAWFUNC_TRANS] = R_DrawTranslucentSpan_8; + spanfuncs[SPANDRAWFUNC_TILTED] = R_DrawTiltedSpan_8; + spanfuncs[SPANDRAWFUNC_TILTEDTRANS] = R_DrawTiltedTranslucentSpan_8; spanfuncs[SPANDRAWFUNC_SPLAT] = R_DrawSplat_8; spanfuncs[SPANDRAWFUNC_TRANSSPLAT] = R_DrawTranslucentSplat_8; + spanfuncs[SPANDRAWFUNC_TILTEDSPLAT] = R_DrawTiltedSplat_8; spanfuncs[SPANDRAWFUNC_SPRITE] = R_DrawFloorSprite_8; spanfuncs[SPANDRAWFUNC_TRANSSPRITE] = R_DrawTranslucentFloorSprite_8; spanfuncs[SPANDRAWFUNC_TILTEDSPRITE] = R_DrawTiltedFloorSprite_8; spanfuncs[SPANDRAWFUNC_TILTEDTRANSSPRITE] = R_DrawTiltedTranslucentFloorSprite_8; - spanfuncs[SPANDRAWFUNC_FOG] = R_DrawFogSpan_8; -#ifndef NOWATER spanfuncs[SPANDRAWFUNC_WATER] = R_DrawTranslucentWaterSpan_8; -#endif - spanfuncs[SPANDRAWFUNC_TILTED] = R_DrawTiltedSpan_8; - spanfuncs[SPANDRAWFUNC_TILTEDTRANS] = R_DrawTiltedTranslucentSpan_8; -#ifndef NOWATER spanfuncs[SPANDRAWFUNC_TILTEDWATER] = R_DrawTiltedTranslucentWaterSpan_8; -#endif - spanfuncs[SPANDRAWFUNC_TILTEDSPLAT] = R_DrawTiltedSplat_8; + spanfuncs[SPANDRAWFUNC_FOG] = R_DrawFogSpan_8; // Lactozilla: Non-powers-of-two spanfuncs_npo2[BASEDRAWFUNC] = R_DrawSpan_NPO2_8; spanfuncs_npo2[SPANDRAWFUNC_TRANS] = R_DrawTranslucentSpan_NPO2_8; + spanfuncs_npo2[SPANDRAWFUNC_TILTED] = R_DrawTiltedSpan_NPO2_8; + spanfuncs_npo2[SPANDRAWFUNC_TILTEDTRANS] = R_DrawTiltedTranslucentSpan_NPO2_8; spanfuncs_npo2[SPANDRAWFUNC_SPLAT] = R_DrawSplat_NPO2_8; spanfuncs_npo2[SPANDRAWFUNC_TRANSSPLAT] = R_DrawTranslucentSplat_NPO2_8; + spanfuncs_npo2[SPANDRAWFUNC_TILTEDSPLAT] = R_DrawTiltedSplat_NPO2_8; spanfuncs_npo2[SPANDRAWFUNC_SPRITE] = R_DrawFloorSprite_NPO2_8; spanfuncs_npo2[SPANDRAWFUNC_TRANSSPRITE] = R_DrawTranslucentFloorSprite_NPO2_8; spanfuncs_npo2[SPANDRAWFUNC_TILTEDSPRITE] = R_DrawTiltedFloorSprite_NPO2_8; spanfuncs_npo2[SPANDRAWFUNC_TILTEDTRANSSPRITE] = R_DrawTiltedTranslucentFloorSprite_NPO2_8; - spanfuncs_npo2[SPANDRAWFUNC_FOG] = NULL; // Not needed -#ifndef NOWATER spanfuncs_npo2[SPANDRAWFUNC_WATER] = R_DrawTranslucentWaterSpan_NPO2_8; -#endif - spanfuncs_npo2[SPANDRAWFUNC_TILTED] = R_DrawTiltedSpan_NPO2_8; - spanfuncs_npo2[SPANDRAWFUNC_TILTEDTRANS] = R_DrawTiltedTranslucentSpan_NPO2_8; -#ifndef NOWATER spanfuncs_npo2[SPANDRAWFUNC_TILTEDWATER] = R_DrawTiltedTranslucentWaterSpan_NPO2_8; -#endif - spanfuncs_npo2[SPANDRAWFUNC_TILTEDSPLAT] = R_DrawTiltedSplat_NPO2_8; + spanfuncs_npo2[SPANDRAWFUNC_FOG] = NULL; // Not needed #ifdef RUSEASM if (R_ASM) diff --git a/src/screen.h b/src/screen.h index b139bd3b4..66452289c 100644 --- a/src/screen.h +++ b/src/screen.h @@ -140,22 +140,22 @@ enum { SPANDRAWFUNC_BASE = BASEDRAWFUNC, SPANDRAWFUNC_TRANS, + SPANDRAWFUNC_TILTED, + SPANDRAWFUNC_TILTEDTRANS, + SPANDRAWFUNC_SPLAT, SPANDRAWFUNC_TRANSSPLAT, + SPANDRAWFUNC_TILTEDSPLAT, + SPANDRAWFUNC_SPRITE, SPANDRAWFUNC_TRANSSPRITE, SPANDRAWFUNC_TILTEDSPRITE, SPANDRAWFUNC_TILTEDTRANSSPRITE, - SPANDRAWFUNC_FOG, -#ifndef NOWATER + SPANDRAWFUNC_WATER, -#endif - SPANDRAWFUNC_TILTED, - SPANDRAWFUNC_TILTEDTRANS, - SPANDRAWFUNC_TILTEDSPLAT, -#ifndef NOWATER SPANDRAWFUNC_TILTEDWATER, -#endif + + SPANDRAWFUNC_FOG, SPANDRAWFUNC_MAX }; From 36550725f3cff456f42b547d7ae7116a7a367c36 Mon Sep 17 00:00:00 2001 From: Jaime Passos Date: Thu, 5 Nov 2020 00:42:14 -0300 Subject: [PATCH 0265/1080] P_DeleteFloorSpriteSlope -> P_RemoveFloorSpriteSlope --- src/lua_baselib.c | 6 +++--- src/p_mobj.c | 7 +++---- src/p_mobj.h | 2 +- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index f320cfdce..b3f826532 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -921,14 +921,14 @@ static int lib_pCreateFloorSpriteSlope(lua_State *L) return 1; } -static int lib_pDeleteFloorSpriteSlope(lua_State *L) +static int lib_pRemoveFloorSpriteSlope(lua_State *L) { mobj_t *mobj = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); NOHUD INLEVEL if (!mobj) return LUA_ErrInvalid(L, "mobj_t"); - P_DeleteFloorSpriteSlope(mobj); + P_RemoveFloorSpriteSlope(mobj); return 1; } @@ -3559,7 +3559,7 @@ static luaL_Reg lib[] = { {"P_CanRunOnWater",lib_pCanRunOnWater}, {"P_MaceRotate",lib_pMaceRotate}, {"P_CreateFloorSpriteSlope",lib_pCreateFloorSpriteSlope}, - {"P_DeleteFloorSpriteSlope",lib_pDeleteFloorSpriteSlope}, + {"P_RemoveFloorSpriteSlope",lib_pRemoveFloorSpriteSlope}, {"P_RailThinker",lib_pRailThinker}, {"P_XYMovement",lib_pXYMovement}, {"P_RingXYMovement",lib_pRingXYMovement}, diff --git a/src/p_mobj.c b/src/p_mobj.c index 7529b196a..84d9a70b6 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -10884,7 +10884,7 @@ void *P_CreateFloorSpriteSlope(mobj_t *mobj) return (void *)mobj->floorspriteslope; } -void P_DeleteFloorSpriteSlope(mobj_t *mobj) +void P_RemoveFloorSpriteSlope(mobj_t *mobj) { if (mobj->floorspriteslope) Z_Free(mobj->floorspriteslope); @@ -10947,14 +10947,13 @@ void P_RemoveMobj(mobj_t *mobj) P_DelSeclist(sector_list); sector_list = NULL; } + mobj->flags |= MF_NOSECTOR|MF_NOBLOCKMAP; mobj->subsector = NULL; mobj->state = NULL; mobj->player = NULL; - if (mobj->floorspriteslope) - Z_Free(mobj->floorspriteslope); - mobj->floorspriteslope = NULL; + P_RemoveFloorSpriteSlope(mobj); // stop any playing sound S_StopSound(mobj); diff --git a/src/p_mobj.h b/src/p_mobj.h index a60da67d3..5bb7c908e 100644 --- a/src/p_mobj.h +++ b/src/p_mobj.h @@ -477,7 +477,7 @@ void P_SpawnHoopOfSomething(fixed_t x, fixed_t y, fixed_t z, fixed_t radius, INT 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); void *P_CreateFloorSpriteSlope(mobj_t *mobj); -void P_DeleteFloorSpriteSlope(mobj_t *mobj); +void P_RemoveFloorSpriteSlope(mobj_t *mobj); boolean P_BossTargetPlayer(mobj_t *actor, boolean closest); boolean P_SupermanLook4Players(mobj_t *actor); void P_DestroyRobots(void); From a655257f4b118b13d63b2e1f61b5dfc756d84160 Mon Sep 17 00:00:00 2001 From: Jaime Passos Date: Thu, 5 Nov 2020 00:44:10 -0300 Subject: [PATCH 0266/1080] Remove RF_VOXELSPRITE --- src/dehacked.c | 1 - src/r_defs.h | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/dehacked.c b/src/dehacked.c index 67e83e4d5..820350f20 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -9606,7 +9606,6 @@ struct { {"RF_SPRITETYPEMASK",RF_SPRITETYPEMASK}, {"RF_PAPERSPRITE",RF_PAPERSPRITE}, {"RF_FLOORSPRITE",RF_FLOORSPRITE}, - {"RF_VOXELSPRITE",RF_VOXELSPRITE}, {"RF_SHADOWDRAW",RF_SHADOWDRAW}, {"RF_SHADOWEFFECTS",RF_SHADOWEFFECTS}, {"RF_DROPSHADOW",RF_DROPSHADOW}, diff --git a/src/r_defs.h b/src/r_defs.h index 9d0f4247c..664ed5e86 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -731,10 +731,9 @@ typedef enum RF_FULLDARK = 0x0200, // Sprite is drawn completely dark RF_NOCOLORMAPS = 0x0400, // Sprite is not drawn with colormaps - RF_SPRITETYPEMASK = 0x7000, // ---Different sprite types, not all implemented + RF_SPRITETYPEMASK = 0x7000, // ---Different sprite types RF_PAPERSPRITE = 0x1000, // Paper sprite RF_FLOORSPRITE = 0x2000, // Floor sprite - RF_VOXELSPRITE = 0x3000, // Voxel object RF_SHADOWDRAW = 0x10000, // Stretches and skews the sprite like a shadow. RF_SHADOWEFFECTS = 0x20000, // Scales and becomes transparent like a shadow. From a502b09929713b7292e37a7b67193d6420e5a998 Mon Sep 17 00:00:00 2001 From: GoldenTails Date: Thu, 5 Nov 2020 12:37:49 -0600 Subject: [PATCH 0267/1080] Make `emeralds` writable. --- src/lua_script.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/lua_script.c b/src/lua_script.c index 6e40cb785..98336c9bf 100644 --- a/src/lua_script.c +++ b/src/lua_script.c @@ -376,6 +376,8 @@ int LUA_CheckGlobals(lua_State *L, const char *word) redscore = (UINT32)luaL_checkinteger(L, 2); else if (fastcmp(word, "bluescore")) bluescore = (UINT32)luaL_checkinteger(L, 2); + else if (fastcmp(word, "emeralds")) + emeralds = (UINT16)luaL_checkinteger(L, 2); else return 0; From 113e6b658589bddafde5fcf74a7659397e1cd42d Mon Sep 17 00:00:00 2001 From: GoldenTails Date: Thu, 5 Nov 2020 12:38:47 -0600 Subject: [PATCH 0268/1080] Make `token` writable. --- src/lua_script.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/lua_script.c b/src/lua_script.c index 98336c9bf..da348d458 100644 --- a/src/lua_script.c +++ b/src/lua_script.c @@ -378,6 +378,8 @@ int LUA_CheckGlobals(lua_State *L, const char *word) bluescore = (UINT32)luaL_checkinteger(L, 2); else if (fastcmp(word, "emeralds")) emeralds = (UINT16)luaL_checkinteger(L, 2); + else if (fastcmp(word, "token")) + token = (UINT32)luaL_checkinteger(L, 2); else return 0; From 8a0f55e4ad4db40df3464c914467f4e01579247a Mon Sep 17 00:00:00 2001 From: GoldenTails Date: Thu, 5 Nov 2020 12:39:03 -0600 Subject: [PATCH 0269/1080] Make `gravity` writable. --- src/lua_script.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/lua_script.c b/src/lua_script.c index da348d458..3e749b31b 100644 --- a/src/lua_script.c +++ b/src/lua_script.c @@ -380,6 +380,8 @@ int LUA_CheckGlobals(lua_State *L, const char *word) emeralds = (UINT16)luaL_checkinteger(L, 2); else if (fastcmp(word, "token")) token = (UINT32)luaL_checkinteger(L, 2); + else if (fastcmp(word, "gravity")) + gravity = (fixed_t)luaL_checkinteger(L, 2); else return 0; From f42dee18712113a3aeaa921d9c7d7e629915b85b Mon Sep 17 00:00:00 2001 From: GoldenTails Date: Thu, 5 Nov 2020 13:43:33 -0600 Subject: [PATCH 0270/1080] Make `displayplayer` writable. --- src/lua_script.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/lua_script.c b/src/lua_script.c index 3e749b31b..be33cd35b 100644 --- a/src/lua_script.c +++ b/src/lua_script.c @@ -382,6 +382,13 @@ int LUA_CheckGlobals(lua_State *L, const char *word) token = (UINT32)luaL_checkinteger(L, 2); else if (fastcmp(word, "gravity")) gravity = (fixed_t)luaL_checkinteger(L, 2); + else if (fastcmp(word, "displayplayer")) + { + player_t *player = *((player_t **)luaL_checkudata(L, 2, META_PLAYER)); + + if (player) + displayplayer = player - players; + } else return 0; From 2b39a971ac1e08d8a0f0b54d7ce0177eb1b1b913 Mon Sep 17 00:00:00 2001 From: GoldenTails Date: Thu, 5 Nov 2020 15:22:45 -0600 Subject: [PATCH 0271/1080] Make `stoppedclock` writable. --- src/lua_script.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/lua_script.c b/src/lua_script.c index be33cd35b..2805a969b 100644 --- a/src/lua_script.c +++ b/src/lua_script.c @@ -382,6 +382,8 @@ int LUA_CheckGlobals(lua_State *L, const char *word) token = (UINT32)luaL_checkinteger(L, 2); else if (fastcmp(word, "gravity")) gravity = (fixed_t)luaL_checkinteger(L, 2); + else if (fastcmp(word, "stoppedclock")) + stoppedclock = luaL_checkboolean(L, 2); else if (fastcmp(word, "displayplayer")) { player_t *player = *((player_t **)luaL_checkudata(L, 2, META_PLAYER)); From 365e02bb324eba5d8c34ce41c50c12e6c12cbd01 Mon Sep 17 00:00:00 2001 From: GoldenTails Date: Thu, 5 Nov 2020 17:38:32 -0600 Subject: [PATCH 0272/1080] Make `skincolor_*` CTF color variables writable. --- src/lua_script.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/lua_script.c b/src/lua_script.c index 2805a969b..29ee094d9 100644 --- a/src/lua_script.c +++ b/src/lua_script.c @@ -376,6 +376,14 @@ int LUA_CheckGlobals(lua_State *L, const char *word) redscore = (UINT32)luaL_checkinteger(L, 2); else if (fastcmp(word, "bluescore")) bluescore = (UINT32)luaL_checkinteger(L, 2); + else if (fastcmp(word, "skincolor_redteam")) + skincolor_redteam = (UINT16)luaL_checkinteger(L, 2); + else if (fastcmp(word, "skincolor_blueteam")) + skincolor_blueteam = (UINT16)luaL_checkinteger(L, 2); + else if (fastcmp(word, "skincolor_redring")) + skincolor_redring = (UINT16)luaL_checkinteger(L, 2); + else if (fastcmp(word, "skincolor_bluering")) + skincolor_bluering = (UINT16)luaL_checkinteger(L, 2); else if (fastcmp(word, "emeralds")) emeralds = (UINT16)luaL_checkinteger(L, 2); else if (fastcmp(word, "token")) From c70d5a9773a927b46793ea6ad6f0ff87a485259f Mon Sep 17 00:00:00 2001 From: GoldenTails Date: Thu, 5 Nov 2020 18:12:35 -0600 Subject: [PATCH 0273/1080] Make `mapmusflags` and `mapmusname` writable. --- src/lua_script.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/lua_script.c b/src/lua_script.c index 29ee094d9..c0e31557e 100644 --- a/src/lua_script.c +++ b/src/lua_script.c @@ -399,6 +399,21 @@ int LUA_CheckGlobals(lua_State *L, const char *word) if (player) displayplayer = player - players; } + else if (fastcmp(word, "mapmusname")) + { + size_t strlength; + const char *str = luaL_checkstring(L, 2, &strlength); + + if (strlength > 6) + return luaL_error(L, "string length out of range (maximum 6 characters)"); + + if (strlen(str) < strlength) + return luaL_error(L, "string must not contain embedded zeros!"); + + strncpy(mapmusname, str, strlength); + } + else if (fastcmp(word, "mapmusflags")) + mapmusflags = (UINT16)luaL_checkinteger(L, 2); else return 0; From 81cbf35560a541b6116f28c4b59c681c825932c7 Mon Sep 17 00:00:00 2001 From: James R Date: Mon, 2 Nov 2020 02:33:49 -0800 Subject: [PATCH 0274/1080] Check that top of sprite is above plane or bottom is below This fixes slightly raised fofs drawing on top of sprites that should be in front of them. Previously would check that the bottom of the object was above the plane. Now also uses sprite offsets like the fof seg sorting does. --- src/r_things.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/r_things.c b/src/r_things.c index cc205f9ea..52ee6617f 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -2387,19 +2387,15 @@ static void R_CreateDrawNodes(maskcount_t* mask, drawnode_t* head, boolean temps planeobjectz = P_GetZAt(r2->plane->slope, rover->gx, rover->gy, r2->plane->height); planecameraz = P_GetZAt(r2->plane->slope, viewx, viewy, r2->plane->height); - if (rover->mobjflags & MF_NOCLIPHEIGHT) + // bird: if any part of the sprite peeks in front the plane + if (planecameraz < viewz) { - //Objects with NOCLIPHEIGHT can appear halfway in. - if (planecameraz < viewz && rover->pz+(rover->thingheight/2) >= planeobjectz) - continue; - if (planecameraz > viewz && rover->pzt-(rover->thingheight/2) <= planeobjectz) + if (rover->gzt >= planeobjectz) continue; } - else + else if (planecameraz > viewz) { - if (planecameraz < viewz && rover->pz >= planeobjectz) - continue; - if (planecameraz > viewz && rover->pzt <= planeobjectz) + if (rover->gz <= planeobjectz) continue; } From 8d63a994f01a750f5eda1481e62fca04abf7679c Mon Sep 17 00:00:00 2001 From: James R Date: Mon, 2 Nov 2020 03:37:16 -0800 Subject: [PATCH 0275/1080] Remove unused stuff --- src/r_things.c | 20 +------------------- src/r_things.h | 4 +--- 2 files changed, 2 insertions(+), 22 deletions(-) diff --git a/src/r_things.c b/src/r_things.c index 52ee6617f..da9887108 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -1068,14 +1068,6 @@ static void R_SplitSprite(vissprite_t *sprite) sprite->sz = cutfrac; newsprite->szt = (INT16)(sprite->sz - 1); - if (testheight < sprite->pzt && testheight > sprite->pz) - sprite->pz = newsprite->pzt = testheight; - else - { - newsprite->pz = newsprite->gz; - newsprite->pzt = newsprite->gzt; - } - newsprite->szt -= 8; newsprite->cut |= SC_TOP; @@ -1293,16 +1285,12 @@ static void R_ProjectDropShadow(mobj_t *thing, vissprite_t *vis, fixed_t scale, shadow->patch = patch; shadow->heightsec = vis->heightsec; - shadow->thingheight = FRACUNIT; - shadow->pz = groundz + (isflipped ? -shadow->thingheight : 0); - shadow->pzt = shadow->pz + shadow->thingheight; - shadow->mobjflags = 0; shadow->sortscale = vis->sortscale; shadow->dispoffset = vis->dispoffset - 5; shadow->gx = thing->x; shadow->gy = thing->y; - shadow->gzt = (isflipped ? shadow->pzt : shadow->pz) + SHORT(patch->height) * shadowyscale / 2; + shadow->gzt = groundz + SHORT(patch->height) * shadowyscale / 2; shadow->gz = shadow->gzt - SHORT(patch->height) * shadowyscale; shadow->texturemid = FixedMul(thing->scale, FixedDiv(shadow->gzt - viewz, shadowyscale)); if (thing->skin && ((skin_t *)thing->skin)->flags & SF_HIRES) @@ -1783,9 +1771,6 @@ static void R_ProjectSprite(mobj_t *thing) vis->gy = thing->y; vis->gz = gz; vis->gzt = gzt; - vis->thingheight = thing->height; - vis->pz = thing->z; - vis->pzt = vis->pz + vis->thingheight; vis->texturemid = vis->gzt - viewz; vis->scalestep = scalestep; vis->paperoffset = paperoffset; @@ -1991,9 +1976,6 @@ static void R_ProjectPrecipitationSprite(precipmobj_t *thing) vis->gy = thing->y; vis->gz = gz; vis->gzt = gzt; - vis->thingheight = 4*FRACUNIT; - vis->pz = thing->z; - vis->pzt = vis->pz + vis->thingheight; vis->texturemid = vis->gzt - viewz; vis->scalestep = 0; vis->paperdistance = 0; diff --git a/src/r_things.h b/src/r_things.h index b13c5dc55..c9a48dd28 100644 --- a/src/r_things.h +++ b/src/r_things.h @@ -138,8 +138,7 @@ typedef struct vissprite_s INT32 x1, x2; fixed_t gx, gy; // for line side calculation - fixed_t gz, gzt; // global bottom/top for silhouette clipping - fixed_t pz, pzt; // physical bottom/top for sorting with 3D floors + fixed_t gz, gzt; // global bottom/top for silhouette clipping and sorting with 3D floors fixed_t startfrac; // horizontal position of x1 fixed_t scale, sortscale; // sortscale only differs from scale for paper sprites and MF2_LINKDRAW @@ -171,7 +170,6 @@ typedef struct vissprite_s fixed_t xscale; // Precalculated top and bottom screen coords for the sprite. - fixed_t thingheight; // The actual height of the thing (for 3D floors) sector_t *sector; // The sector containing the thing. INT16 sz, szt; From 0d97903573ae498b9596113174d06f76dd074828 Mon Sep 17 00:00:00 2001 From: James R Date: Thu, 5 Nov 2020 04:55:01 -0800 Subject: [PATCH 0276/1080] Do not factor height into sprite thickseg sorting --- src/r_things.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/r_things.c b/src/r_things.c index da9887108..7d3f2be3d 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -2410,7 +2410,7 @@ static void R_CreateDrawNodes(maskcount_t* mask, drawnode_t* head, boolean temps } else if (r2->thickseg) { - fixed_t topplaneobjectz, topplanecameraz, botplaneobjectz, botplanecameraz; + //fixed_t topplaneobjectz, topplanecameraz, botplaneobjectz, botplanecameraz; if (rover->x1 > r2->thickseg->x2 || rover->x2 < r2->thickseg->x1) continue; @@ -2421,6 +2421,11 @@ static void R_CreateDrawNodes(maskcount_t* mask, drawnode_t* head, boolean temps if (scale <= rover->sortscale) continue; + // bird: Always sort sprites behind segs. This helps the plane + // sorting above too. Basically if the sprite gets sorted behind + // the seg here, it will be behind the plane too, since planes + // are added after segs in the list. +#if 0 topplaneobjectz = P_GetFFloorTopZAt (r2->ffloor, rover->gx, rover->gy); topplanecameraz = P_GetFFloorTopZAt (r2->ffloor, viewx, viewy); botplaneobjectz = P_GetFFloorBottomZAt(r2->ffloor, rover->gx, rover->gy); @@ -2429,6 +2434,7 @@ static void R_CreateDrawNodes(maskcount_t* mask, drawnode_t* head, boolean temps if ((topplanecameraz > viewz && botplanecameraz < viewz) || (topplanecameraz < viewz && rover->gzt < topplaneobjectz) || (botplanecameraz > viewz && rover->gz > botplaneobjectz)) +#endif { entry = R_CreateDrawNode(NULL); (entry->prev = r2->prev)->next = entry; From 425b56c2889c9342fb4c4e007be24371816c4e5e Mon Sep 17 00:00:00 2001 From: James R Date: Fri, 6 Nov 2020 13:34:21 -0800 Subject: [PATCH 0277/1080] Remove win32 specific timer --- src/sdl/i_system.c | 98 ---------------------------------------------- 1 file changed, 98 deletions(-) diff --git a/src/sdl/i_system.c b/src/sdl/i_system.c index 10c0747bf..70ae938e9 100644 --- a/src/sdl/i_system.c +++ b/src/sdl/i_system.c @@ -54,11 +54,7 @@ typedef LPVOID (WINAPI *p_MapViewOfFile) (HANDLE, DWORD, DWORD, DWORD, SIZE_T); #include #endif -#if defined (_WIN32) -DWORD TimeFunction(int requested_frequency); -#else int TimeFunction(int requested_frequency); -#endif #include #ifdef _WIN32 @@ -2044,80 +2040,6 @@ ticcmd_t *I_BaseTiccmd2(void) return &emptycmd2; } -#if defined (_WIN32) -static HMODULE winmm = NULL; -static DWORD starttickcount = 0; // hack for win2k time bug -static p_timeGetTime pfntimeGetTime = NULL; - -// --------- -// I_GetTime -// Use the High Resolution Timer if available, -// else use the multimedia timer which has 1 millisecond precision on Windowz 95, -// but lower precision on Windows NT -// --------- - -DWORD TimeFunction(int requested_frequency) -{ - DWORD newtics = 0; - // this var acts as a multiplier if sub-millisecond precision is asked but is not available - int excess_frequency = requested_frequency / 1000; - - if (!starttickcount) // high precision timer - { - LARGE_INTEGER currtime; // use only LowPart if high resolution counter is not available - static LARGE_INTEGER basetime = {{0, 0}}; - - // use this if High Resolution timer is found - static LARGE_INTEGER frequency; - - if (!basetime.LowPart) - { - if (!QueryPerformanceFrequency(&frequency)) - frequency.QuadPart = 0; - else - QueryPerformanceCounter(&basetime); - } - - if (frequency.LowPart && QueryPerformanceCounter(&currtime)) - { - newtics = (INT32)((currtime.QuadPart - basetime.QuadPart) * requested_frequency - / frequency.QuadPart); - } - else if (pfntimeGetTime) - { - currtime.LowPart = pfntimeGetTime(); - if (!basetime.LowPart) - basetime.LowPart = currtime.LowPart; - if (requested_frequency > 1000) - newtics = currtime.LowPart - basetime.LowPart * excess_frequency; - else - newtics = (currtime.LowPart - basetime.LowPart)/(1000/requested_frequency); - } - } - else - { - if (requested_frequency > 1000) - newtics = (GetTickCount() - starttickcount) * excess_frequency; - else - newtics = (GetTickCount() - starttickcount)/(1000/requested_frequency); - } - - return newtics; -} - -static void I_ShutdownTimer(void) -{ - pfntimeGetTime = NULL; - if (winmm) - { - p_timeEndPeriod pfntimeEndPeriod = (p_timeEndPeriod)(LPVOID)GetProcAddress(winmm, "timeEndPeriod"); - if (pfntimeEndPeriod) - pfntimeEndPeriod(1); - FreeLibrary(winmm); - winmm = NULL; - } -} -#else // // I_GetTime // returns time in 1/TICRATE second tics @@ -2140,7 +2062,6 @@ int TimeFunction(int requested_frequency) return ticks; } -#endif tic_t I_GetTime(void) { @@ -2157,27 +2078,8 @@ int I_GetTimeMicros(void) // void I_StartupTimer(void) { -#ifdef _WIN32 - // for win2k time bug - if (M_CheckParm("-gettickcount")) - { - starttickcount = GetTickCount(); - CONS_Printf("%s", M_GetText("Using GetTickCount()\n")); - } - winmm = LoadLibraryA("winmm.dll"); - if (winmm) - { - p_timeEndPeriod pfntimeBeginPeriod = (p_timeEndPeriod)(LPVOID)GetProcAddress(winmm, "timeBeginPeriod"); - if (pfntimeBeginPeriod) - pfntimeBeginPeriod(1); - pfntimeGetTime = (p_timeGetTime)(LPVOID)GetProcAddress(winmm, "timeGetTime"); - } - I_AddExitFunc(I_ShutdownTimer); -#endif } - - void I_Sleep(void) { if (cv_sleep.value != -1) From cc8bd7ef5928b01729dfe6b20bc94b0e43dad16f Mon Sep 17 00:00:00 2001 From: Hannu Hanhi Date: Sat, 7 Nov 2020 00:19:43 +0200 Subject: [PATCH 0278/1080] Clarify license file mention in libdivide.h --- src/libdivide.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libdivide.h b/src/libdivide.h index 915da0070..1a589c7e5 100644 --- a/src/libdivide.h +++ b/src/libdivide.h @@ -6,7 +6,7 @@ // // libdivide is dual-licensed under the Boost or zlib licenses. // You may use libdivide under the terms of either of these. -// See LICENSE.txt for more details. +// See LICENSE.txt in the libdivide source code repository for more details. // NOTICE: This is an altered source version of libdivide. From e473bfd4cdefd1f109989113bad752d26e2a58e9 Mon Sep 17 00:00:00 2001 From: GoldenTails Date: Sat, 7 Nov 2020 03:01:15 -0600 Subject: [PATCH 0279/1080] By default use the old gif_dynamicdelay v1 behavior, but keep v2 as an option. --- src/m_anigif.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/src/m_anigif.c b/src/m_anigif.c index 0d3206d11..372781a97 100644 --- a/src/m_anigif.c +++ b/src/m_anigif.c @@ -29,15 +29,21 @@ // GIFs are always little-endian #include "byteptr.h" +CV_PossibleValue_t gif_dynamicdelay_cons_t[] = { + {0, "Off"}, + {1, "On"}, + {2, "Accurate, experimental"}, +{0, NULL}}; + consvar_t cv_gif_optimize = CVAR_INIT ("gif_optimize", "On", CV_SAVE, CV_OnOff, NULL); consvar_t cv_gif_downscale = CVAR_INIT ("gif_downscale", "On", CV_SAVE, CV_OnOff, NULL); -consvar_t cv_gif_dynamicdelay = CVAR_INIT ("gif_dynamicdelay", "On", CV_SAVE, CV_OnOff, NULL); +consvar_t cv_gif_dynamicdelay = CVAR_INIT ("gif_dynamicdelay", "On", CV_SAVE, gif_dynamicdelay_cons_t, NULL); consvar_t cv_gif_localcolortable = CVAR_INIT ("gif_localcolortable", "On", CV_SAVE, CV_OnOff, NULL); #ifdef HAVE_ANIGIF static boolean gif_optimize = false; // So nobody can do something dumb static boolean gif_downscale = false; // like changing cvars mid output -static boolean gif_dynamicdelay = false; // and messing something up +static INT32 gif_dynamicdelay = 0; // and messing something up // Palette handling static boolean gif_localcolortable = false; @@ -598,7 +604,8 @@ static void GIF_framewrite(void) UINT16 delay = 0; INT32 startline; - if (gif_dynamicdelay) { + if (gif_dynamicdelay == 2) + { // golden's attempt at creating a "dynamic delay" UINT16 mingifdelay = 10; // minimum gif delay in milliseconds (keep at 10 because gifs can't get more precise). gif_delayus += (I_GetTimeMicros() - gif_prevframeus); // increase delay by how much time was spent between last measurement @@ -610,6 +617,15 @@ static void GIF_framewrite(void) gif_delayus -= frames*(mingifdelay*1000); // remove frames by the amount of milliseconds they take. don't reset to 0, the microseconds help consistency. } } + else if (gif_dynamicdelay == 1) + { + float delayf = ceil(100.0f/NEWTICRATE); + + delay = (UINT16)((I_GetTimeMicros() - gif_prevframeus)/10/1000); + + if (delay < (UINT16)(delayf)) + delay = (UINT16)(delayf); + } else { // the original code @@ -716,7 +732,7 @@ INT32 GIF_open(const char *filename) gif_optimize = (!!cv_gif_optimize.value); gif_downscale = (!!cv_gif_downscale.value); - gif_dynamicdelay = (!!cv_gif_dynamicdelay.value); + memcpy(&gif_dynamicdelay, &cv_gif_dynamicdelay.value, sizeof(gif_dynamicdelay)); //gif_dynamicdelay = (!!cv_gif_dynamicdelay.value); gif_localcolortable = (!!cv_gif_localcolortable.value); gif_colorprofile = (!!cv_screenshot_colorprofile.value); gif_headerpalette = GIF_getpalette(0); From 84ce53db60bce109fe87a895d5341ac3f7cd0673 Mon Sep 17 00:00:00 2001 From: James R Date: Sat, 7 Nov 2020 01:31:24 -0800 Subject: [PATCH 0280/1080] Use high precision timer, replace I_GetTimeMicros with I_GetPreciseTime and I_PreciseToMicros --- src/doomtype.h | 4 ++++ src/i_system.h | 8 +++++++- src/sdl/i_system.c | 35 +++++++++++++---------------------- 3 files changed, 24 insertions(+), 23 deletions(-) diff --git a/src/doomtype.h b/src/doomtype.h index 4e13ba96d..c239c7b8e 100644 --- a/src/doomtype.h +++ b/src/doomtype.h @@ -379,4 +379,8 @@ Needed for some lua shenanigans. #define FIELDFROM( type, field, have, want ) \ (void *)((intptr_t)(field) - offsetof (type, have) + offsetof (type, want)) +#ifdef HAVE_SDL +typedef UINT64 precise_t; +#endif + #endif //__DOOMTYPE__ diff --git a/src/i_system.h b/src/i_system.h index dd0b65f6d..12f0d751d 100644 --- a/src/i_system.h +++ b/src/i_system.h @@ -46,7 +46,13 @@ UINT32 I_GetFreeMem(UINT32 *total); */ tic_t I_GetTime(void); -int I_GetTimeMicros(void);// provides microsecond counter for render stats +/** \brief Returns precise time value for performance measurement. + */ +precise_t I_GetPreciseTime(void); + +/** \brief Returns the difference between precise times as microseconds. + */ +int I_PreciseToMicros(precise_t); /** \brief The I_Sleep function diff --git a/src/sdl/i_system.c b/src/sdl/i_system.c index 70ae938e9..8a70847e1 100644 --- a/src/sdl/i_system.c +++ b/src/sdl/i_system.c @@ -54,8 +54,6 @@ typedef LPVOID (WINAPI *p_MapViewOfFile) (HANDLE, DWORD, DWORD, DWORD, SIZE_T); #include #endif -int TimeFunction(int requested_frequency); - #include #ifdef _WIN32 #include @@ -2045,32 +2043,23 @@ ticcmd_t *I_BaseTiccmd2(void) // returns time in 1/TICRATE second tics // -// millisecond precision only -int TimeFunction(int requested_frequency) -{ - static Uint64 basetime = 0; - Uint64 ticks = SDL_GetTicks(); - - if (!basetime) - basetime = ticks; - - ticks -= basetime; - - ticks = (ticks*requested_frequency); - - ticks = (ticks/1000); - - return ticks; -} +static Uint64 timer_frequency; +static Uint64 tic_epoch; tic_t I_GetTime(void) { - return TimeFunction(NEWTICRATE); + const Uint64 now = SDL_GetPerformanceCounter(); + return (now - tic_epoch) * NEWTICRATE / timer_frequency; } -int I_GetTimeMicros(void) +precise_t I_GetPreciseTime(void) { - return TimeFunction(1000000); + return SDL_GetPerformanceCounter(); +} + +int I_PreciseToMicros(precise_t d) +{ + return d / (timer_frequency / 1000000); } // @@ -2078,6 +2067,8 @@ int I_GetTimeMicros(void) // void I_StartupTimer(void) { + timer_frequency = SDL_GetPerformanceFrequency(); + tic_epoch = SDL_GetPerformanceCounter(); } void I_Sleep(void) From e5f37523b846665f3812d75741a590ea132ff681 Mon Sep 17 00:00:00 2001 From: James R Date: Sat, 7 Nov 2020 01:32:25 -0800 Subject: [PATCH 0281/1080] Use precise time for gif timing --- src/m_anigif.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/m_anigif.c b/src/m_anigif.c index 0d3206d11..4e28c3e72 100644 --- a/src/m_anigif.c +++ b/src/m_anigif.c @@ -18,7 +18,7 @@ #include "z_zone.h" #include "v_video.h" #include "i_video.h" -#include "i_system.h" // I_GetTimeMicros +#include "i_system.h" // I_GetPreciseTime #include "m_misc.h" #include "st_stuff.h" // st_palette @@ -47,8 +47,8 @@ static RGBA_t *gif_framepalette = NULL; static FILE *gif_out = NULL; static INT32 gif_frames = 0; -static UINT32 gif_prevframeus = 0; // "us" is microseconds -static UINT32 gif_delayus = 0; +static precise_t gif_prevframetime = 0; +static UINT32 gif_delayus = 0; // "us" is microseconds static UINT8 gif_writeover = 0; @@ -601,7 +601,7 @@ static void GIF_framewrite(void) if (gif_dynamicdelay) { // golden's attempt at creating a "dynamic delay" UINT16 mingifdelay = 10; // minimum gif delay in milliseconds (keep at 10 because gifs can't get more precise). - gif_delayus += (I_GetTimeMicros() - gif_prevframeus); // increase delay by how much time was spent between last measurement + gif_delayus += I_PreciseToMicros(I_GetPreciseTime() - gif_prevframetime); // increase delay by how much time was spent between last measurement if (gif_delayus/1000 >= mingifdelay) // delay is big enough to be able to effect gif frame delay? { @@ -695,7 +695,7 @@ static void GIF_framewrite(void) } fwrite(gifframe_data, 1, (p - gifframe_data), gif_out); ++gif_frames; - gif_prevframeus = I_GetTimeMicros(); + gif_prevframetime = I_GetPreciseTime(); } @@ -723,7 +723,7 @@ INT32 GIF_open(const char *filename) GIF_headwrite(); gif_frames = 0; - gif_prevframeus = I_GetTimeMicros(); + gif_prevframetime = I_GetPreciseTime(); gif_delayus = 0; return 1; } From b72789b0c90045a6c500663854c73ff17ee067cd Mon Sep 17 00:00:00 2001 From: James R Date: Sat, 7 Nov 2020 01:32:59 -0800 Subject: [PATCH 0282/1080] Huge perfstats refactor I needed to update it to make it functional with the precise timer. But I also got sick of looking at the mess of sprintf followed by draw call. --- src/d_clisrv.c | 4 +- src/d_main.c | 14 +- src/hardware/hw_batching.c | 8 +- src/hardware/hw_main.c | 38 +- src/hardware/hw_main.h | 14 +- src/lua_hooklib.c | 6 +- src/m_perfstats.c | 807 +++++++++++++++++++------------------ src/m_perfstats.h | 14 +- src/p_tick.c | 18 +- src/r_main.c | 40 +- src/r_main.h | 18 +- 11 files changed, 511 insertions(+), 470 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index e314d419f..d9a7ce62c 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -5445,14 +5445,14 @@ void TryRunTics(tic_t realtics) { DEBFILE(va("============ Running tic %d (local %d)\n", gametic, localgametic)); - ps_tictime = I_GetTimeMicros(); + ps_tictime = I_GetPreciseTime(); G_Ticker((gametic % NEWTICRATERATIO) == 0); ExtraDataTicker(); gametic++; consistancy[gametic%BACKUPTICS] = Consistancy(); - ps_tictime = I_GetTimeMicros() - ps_tictime; + ps_tictime = I_GetPreciseTime() - ps_tictime; // Leave a certain amount of tics present in the net buffer as long as we've ran at least one tic this frame. if (client && gamestate == GS_LEVEL && leveltime > 3 && neededtic <= gametic + cv_netticbuffer.value) diff --git a/src/d_main.c b/src/d_main.c index ce1331fe3..caf6f0c22 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -436,7 +436,7 @@ static void D_Display(void) if (!automapactive && !dedicated && cv_renderview.value) { - ps_rendercalltime = I_GetTimeMicros(); + ps_rendercalltime = I_GetPreciseTime(); if (players[displayplayer].mo || players[displayplayer].playerstate == PST_DEAD) { topleft = screens[0] + viewwindowy*vid.width + viewwindowx; @@ -483,7 +483,7 @@ static void D_Display(void) if (postimgtype2) V_DoPostProcessor(1, postimgtype2, postimgparam2); } - ps_rendercalltime = I_GetTimeMicros() - ps_rendercalltime; + ps_rendercalltime = I_GetPreciseTime() - ps_rendercalltime; } if (lastdraw) @@ -497,7 +497,7 @@ static void D_Display(void) lastdraw = false; } - ps_uitime = I_GetTimeMicros(); + ps_uitime = I_GetPreciseTime(); if (gamestate == GS_LEVEL) { @@ -510,7 +510,7 @@ static void D_Display(void) } else { - ps_uitime = I_GetTimeMicros(); + ps_uitime = I_GetPreciseTime(); } } @@ -552,7 +552,7 @@ static void D_Display(void) CON_Drawer(); - ps_uitime = I_GetTimeMicros() - ps_uitime; + ps_uitime = I_GetPreciseTime() - ps_uitime; // // wipe update @@ -638,9 +638,9 @@ static void D_Display(void) M_DrawPerfStats(); } - ps_swaptime = I_GetTimeMicros(); + ps_swaptime = I_GetPreciseTime(); I_FinishUpdate(); // page flip or blit buffer - ps_swaptime = I_GetTimeMicros() - ps_swaptime; + ps_swaptime = I_GetPreciseTime() - ps_swaptime; } needpatchflush = false; diff --git a/src/hardware/hw_batching.c b/src/hardware/hw_batching.c index 5ea9f55d4..fb3417158 100644 --- a/src/hardware/hw_batching.c +++ b/src/hardware/hw_batching.c @@ -248,12 +248,12 @@ void HWR_RenderBatches(void) } // sort polygons - ps_hw_batchsorttime = I_GetTimeMicros(); + ps_hw_batchsorttime = I_GetPreciseTime(); if (cv_glshaders.value && gl_shadersavailable) qsort(polygonIndexArray, polygonArraySize, sizeof(unsigned int), comparePolygons); else qsort(polygonIndexArray, polygonArraySize, sizeof(unsigned int), comparePolygonsNoShaders); - ps_hw_batchsorttime = I_GetTimeMicros() - ps_hw_batchsorttime; + ps_hw_batchsorttime = I_GetPreciseTime() - ps_hw_batchsorttime; // sort order // 1. shader // 2. texture @@ -261,7 +261,7 @@ void HWR_RenderBatches(void) // 4. colors + light level // not sure about what order of the last 2 should be, or if it even matters - ps_hw_batchdrawtime = I_GetTimeMicros(); + ps_hw_batchdrawtime = I_GetPreciseTime(); currentShader = polygonArray[polygonIndexArray[0]].shader; currentTexture = polygonArray[polygonIndexArray[0]].texture; @@ -446,7 +446,7 @@ void HWR_RenderBatches(void) polygonArraySize = 0; unsortedVertexArraySize = 0; - ps_hw_batchdrawtime = I_GetTimeMicros() - ps_hw_batchdrawtime; + ps_hw_batchdrawtime = I_GetPreciseTime() - ps_hw_batchdrawtime; } diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 4268556e3..3df494272 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -146,11 +146,11 @@ static angle_t gl_aimingangle; static void HWR_SetTransformAiming(FTransform *trans, player_t *player, boolean skybox); // Render stats -int ps_hw_skyboxtime = 0; -int ps_hw_nodesorttime = 0; -int ps_hw_nodedrawtime = 0; -int ps_hw_spritesorttime = 0; -int ps_hw_spritedrawtime = 0; +precise_t ps_hw_skyboxtime = 0; +precise_t ps_hw_nodesorttime = 0; +precise_t ps_hw_nodedrawtime = 0; +precise_t ps_hw_spritesorttime = 0; +precise_t ps_hw_spritedrawtime = 0; // Render stats for batching int ps_hw_numpolys = 0; @@ -160,8 +160,8 @@ int ps_hw_numshaders = 0; int ps_hw_numtextures = 0; int ps_hw_numpolyflags = 0; int ps_hw_numcolors = 0; -int ps_hw_batchsorttime = 0; -int ps_hw_batchdrawtime = 0; +precise_t ps_hw_batchsorttime = 0; +precise_t ps_hw_batchdrawtime = 0; boolean gl_shadersavailable = true; @@ -4503,7 +4503,7 @@ static void HWR_CreateDrawNodes(void) // that is already lying around. This should all be in some sort of linked list or lists. sortindex = Z_Calloc(sizeof(size_t) * (numplanes + numpolyplanes + numwalls), PU_STATIC, NULL); - ps_hw_nodesorttime = I_GetTimeMicros(); + ps_hw_nodesorttime = I_GetPreciseTime(); for (i = 0; i < numplanes; i++, p++) { @@ -4558,9 +4558,9 @@ static void HWR_CreateDrawNodes(void) } } - ps_hw_nodesorttime = I_GetTimeMicros() - ps_hw_nodesorttime; + ps_hw_nodesorttime = I_GetPreciseTime() - ps_hw_nodesorttime; - ps_hw_nodedrawtime = I_GetTimeMicros(); + ps_hw_nodedrawtime = I_GetPreciseTime(); // Okay! Let's draw it all! Woo! HWD.pfnSetTransform(&atransform); @@ -4597,7 +4597,7 @@ static void HWR_CreateDrawNodes(void) } } - ps_hw_nodedrawtime = I_GetTimeMicros() - ps_hw_nodedrawtime; + ps_hw_nodedrawtime = I_GetPreciseTime() - ps_hw_nodedrawtime; numwalls = 0; numplanes = 0; @@ -5778,10 +5778,10 @@ void HWR_RenderPlayerView(INT32 viewnumber, player_t *player) if (viewnumber == 0) // Only do it if it's the first screen being rendered HWD.pfnClearBuffer(true, false, &ClearColor); // Clear the Color Buffer, stops HOMs. Also seems to fix the skybox issue on Intel GPUs. - ps_hw_skyboxtime = I_GetTimeMicros(); + ps_hw_skyboxtime = I_GetPreciseTime(); if (skybox && drawsky) // If there's a skybox and we should be drawing the sky, draw the skybox HWR_RenderSkyboxView(viewnumber, player); // This is drawn before everything else so it is placed behind - ps_hw_skyboxtime = I_GetTimeMicros() - ps_hw_skyboxtime; + ps_hw_skyboxtime = I_GetPreciseTime() - ps_hw_skyboxtime; { // do we really need to save player (is it not the same)? @@ -5894,7 +5894,7 @@ void HWR_RenderPlayerView(INT32 viewnumber, player_t *player) ps_numbspcalls = 0; ps_numpolyobjects = 0; - ps_bsptime = I_GetTimeMicros(); + ps_bsptime = I_GetPreciseTime(); validcount++; @@ -5932,7 +5932,7 @@ void HWR_RenderPlayerView(INT32 viewnumber, player_t *player) } #endif - ps_bsptime = I_GetTimeMicros() - ps_bsptime; + ps_bsptime = I_GetPreciseTime() - ps_bsptime; if (cv_glbatching.value) HWR_RenderBatches(); @@ -5948,12 +5948,12 @@ void HWR_RenderPlayerView(INT32 viewnumber, player_t *player) // Draw MD2 and sprites ps_numsprites = gl_visspritecount; - ps_hw_spritesorttime = I_GetTimeMicros(); + ps_hw_spritesorttime = I_GetPreciseTime(); HWR_SortVisSprites(); - ps_hw_spritesorttime = I_GetTimeMicros() - ps_hw_spritesorttime; - ps_hw_spritedrawtime = I_GetTimeMicros(); + ps_hw_spritesorttime = I_GetPreciseTime() - ps_hw_spritesorttime; + ps_hw_spritedrawtime = I_GetPreciseTime(); HWR_DrawSprites(); - ps_hw_spritedrawtime = I_GetTimeMicros() - ps_hw_spritedrawtime; + ps_hw_spritedrawtime = I_GetPreciseTime() - ps_hw_spritedrawtime; #ifdef NEWCORONAS //Hurdler: they must be drawn before translucent planes, what about gl fog? diff --git a/src/hardware/hw_main.h b/src/hardware/hw_main.h index 85072dfd9..4db0a9231 100644 --- a/src/hardware/hw_main.h +++ b/src/hardware/hw_main.h @@ -113,11 +113,11 @@ extern FTransform atransform; // Render stats -extern int ps_hw_skyboxtime; -extern int ps_hw_nodesorttime; -extern int ps_hw_nodedrawtime; -extern int ps_hw_spritesorttime; -extern int ps_hw_spritedrawtime; +extern precise_t ps_hw_skyboxtime; +extern precise_t ps_hw_nodesorttime; +extern precise_t ps_hw_nodedrawtime; +extern precise_t ps_hw_spritesorttime; +extern precise_t ps_hw_spritedrawtime; // Render stats for batching extern int ps_hw_numpolys; @@ -127,8 +127,8 @@ extern int ps_hw_numshaders; extern int ps_hw_numtextures; extern int ps_hw_numpolyflags; extern int ps_hw_numcolors; -extern int ps_hw_batchsorttime; -extern int ps_hw_batchdrawtime; +extern precise_t ps_hw_batchsorttime; +extern precise_t ps_hw_batchdrawtime; extern boolean gl_shadersavailable; diff --git a/src/lua_hooklib.c b/src/lua_hooklib.c index 65d483dc1..602dbf0ec 100644 --- a/src/lua_hooklib.c +++ b/src/lua_hooklib.c @@ -25,7 +25,7 @@ #include "m_perfstats.h" #include "d_netcmd.h" // for cv_perfstats -#include "i_system.h" // I_GetTimeMicros +#include "i_system.h" // I_GetPreciseTime static UINT8 hooksAvailable[(hook_MAX/8)+1]; @@ -480,7 +480,7 @@ void LUAh_ThinkFrame(void) continue; if (cv_perfstats.value == 3) - time_taken = I_GetTimeMicros(); + time_taken = I_GetPreciseTime(); PushHook(gL, hookp); if (lua_pcall(gL, 0, 0, 1)) { if (!hookp->error || cv_debug & DBG_LUA) @@ -491,7 +491,7 @@ void LUAh_ThinkFrame(void) if (cv_perfstats.value == 3) { lua_Debug ar; - time_taken = I_GetTimeMicros() - time_taken; + time_taken = I_GetPreciseTime() - time_taken; // we need the function, let's just retrieve it again PushHook(gL, hookp); lua_getinfo(gL, ">S", &ar); diff --git a/src/m_perfstats.c b/src/m_perfstats.c index 085adda80..1596a87e5 100644 --- a/src/m_perfstats.c +++ b/src/m_perfstats.c @@ -22,32 +22,37 @@ #include "hardware/hw_main.h" #endif -int ps_tictime = 0; +struct perfstatcol; +struct perfstatrow; -int ps_playerthink_time = 0; -int ps_thinkertime = 0; +typedef struct perfstatcol perfstatcol_t; +typedef struct perfstatrow perfstatrow_t; -int ps_thlist_times[NUM_THINKERLISTS]; -static const char* thlist_names[] = { - "Polyobjects: %d", - "Main: %d", - "Mobjs: %d", - "Dynamic slopes: %d", - "Precipitation: %d", - NULL +struct perfstatcol { + INT32 lores_x; + INT32 hires_x; + INT32 color; + perfstatrow_t * rows; }; -static const char* thlist_shortnames[] = { - "plyobjs %d", - "main %d", - "mobjs %d", - "dynslop %d", - "precip %d", - NULL + +struct perfstatrow { + const char * lores_label; + const char * hires_label; + void * value; }; +static precise_t ps_frametime = 0; + +precise_t ps_tictime = 0; + +precise_t ps_playerthink_time = 0; +precise_t ps_thinkertime = 0; + +precise_t ps_thlist_times[NUM_THINKERLISTS]; + int ps_checkposition_calls = 0; -int ps_lua_thinkframe_time = 0; +precise_t ps_lua_thinkframe_time = 0; int ps_lua_mobjhooks = 0; // dynamically allocated resizeable array for thinkframe hook stats @@ -55,6 +60,8 @@ ps_hookinfo_t *thinkframe_hooks = NULL; int thinkframe_hooks_length = 0; int thinkframe_hooks_capacity = 16; +static INT32 draw_row; + void PS_SetThinkFrameHookInfo(int index, UINT32 time_taken, char* short_src) { if (!thinkframe_hooks) @@ -76,379 +83,413 @@ void PS_SetThinkFrameHookInfo(int index, UINT32 time_taken, char* short_src) thinkframe_hooks_length = index + 1; } +static void PS_SetFrameTime(void) +{ + precise_t currenttime = I_GetPreciseTime(); + ps_frametime = currenttime - ps_prevframetime; + ps_prevframetime = currenttime; +} + +static boolean M_HighResolution(void) +{ + return (vid.width >= 640 && vid.height >= 400); +} + +enum { + PERF_TIME, + PERF_COUNT, +}; + +static void M_DrawPerfString(perfstatcol_t *col, int type) +{ + const boolean hires = M_HighResolution(); + + INT32 draw_flags = V_MONOSPACE | col->color; + + perfstatrow_t * row; + + int value; + + if (hires) + draw_flags |= V_ALLOWLOWERCASE; + + for (row = col->rows; row->lores_label; ++row) + { + if (type == PERF_TIME) + value = I_PreciseToMicros(*(precise_t *)row->value); + else + value = *(int *)row->value; + + if (hires) + { + V_DrawSmallString(col->hires_x, draw_row, draw_flags, + va("%s %d", row->hires_label, value)); + + draw_row += 5; + } + else + { + V_DrawThinString(col->lores_x, draw_row, draw_flags, + va("%s %d", row->lores_label, value)); + + draw_row += 8; + } + } +} + +static void M_DrawPerfTiming(perfstatcol_t *col) +{ + M_DrawPerfString(col, PERF_TIME); +} + +static void M_DrawPerfCount(perfstatcol_t *col) +{ + M_DrawPerfString(col, PERF_COUNT); +} + +static void M_DrawRenderStats(void) +{ + const boolean hires = M_HighResolution(); + + const int half_row = hires ? 5 : 4; + + precise_t extrarendertime; + + perfstatrow_t frametime_row[] = { + {"frmtime", "Frame time: ", &ps_frametime}, + {0} + }; + + perfstatrow_t rendercalltime_row[] = { + {"drwtime", "3d rendering: ", &ps_rendercalltime}, + {0} + }; + + perfstatrow_t opengltime_row[] = { + {"skybox ", "Skybox render: ", &ps_hw_skyboxtime}, + {"bsptime", "RenderBSPNode: ", &ps_bsptime}, + {"nodesrt", "Drwnode sort: ", &ps_hw_nodesorttime}, + {"nodedrw", "Drwnode render:", &ps_hw_nodedrawtime}, + {"sprsort", "Sprite sort: ", &ps_hw_spritesorttime}, + {"sprdraw", "Sprite render: ", &ps_hw_spritedrawtime}, + {"other ", "Other: ", &extrarendertime}, + {0} + }; + + perfstatrow_t softwaretime_row[] = { + {"bsptime", "RenderBSPNode: ", &ps_bsptime}, + {"sprclip", "R_ClipSprites: ", &ps_sw_spritecliptime}, + {"portals", "Portals+Skybox:", &ps_sw_portaltime}, + {"planes ", "R_DrawPlanes: ", &ps_sw_planetime}, + {"masked ", "R_DrawMasked: ", &ps_sw_maskedtime}, + {"other ", "Other: ", &extrarendertime}, + {0} + }; + + perfstatrow_t uiswaptime_row[] = { + {"ui ", "UI render: ", &ps_uitime}, + {"finupdt", "I_FinishUpdate:", &ps_swaptime}, + {0} + }; + + perfstatrow_t tictime_row[] = { + {"logic ", "Game logic: ", &ps_tictime}, + {0} + }; + + perfstatrow_t rendercalls_row[] = { + {"bspcall", "BSP calls: ", &ps_numbspcalls}, + {"sprites", "Sprites: ", &ps_numsprites}, + {"drwnode", "Drawnodes: ", &ps_numdrawnodes}, + {"plyobjs", "Polyobjects: ", &ps_numpolyobjects}, + {0} + }; + + perfstatrow_t batchtime_row[] = { + {"batsort", "Batch sort: ", &ps_hw_batchsorttime}, + {"batdraw", "Batch render:", &ps_hw_batchdrawtime}, + {0} + }; + + perfstatrow_t batchcount_row[] = { + {"polygon", "Polygons: ", &ps_hw_numpolys}, + {"vertex ", "Vertices: ", &ps_hw_numverts}, + {0} + }; + + perfstatrow_t batchcalls_row[] = { + {"drwcall", "Draw calls:", &ps_hw_numcalls}, + {"shaders", "Shaders: ", &ps_hw_numshaders}, + {"texture", "Textures: ", &ps_hw_numtextures}, + {"polyflg", "Polyflags: ", &ps_hw_numpolyflags}, + {"colors ", "Colors: ", &ps_hw_numcolors}, + {0} + }; + + perfstatcol_t frametime_col = {20, 20, V_YELLOWMAP, frametime_row}; + perfstatcol_t rendercalltime_col = {20, 20, V_YELLOWMAP, rendercalltime_row}; + + perfstatcol_t opengltime_col = {24, 24, V_YELLOWMAP, opengltime_row}; + perfstatcol_t softwaretime_col = {24, 24, V_YELLOWMAP, softwaretime_row}; + + perfstatcol_t uiswaptime_col = {20, 20, V_YELLOWMAP, uiswaptime_row}; + perfstatcol_t tictime_col = {20, 20, V_GRAYMAP, tictime_row}; + + perfstatcol_t rendercalls_col = {90, 115, V_BLUEMAP, rendercalls_row}; + + perfstatcol_t batchtime_col = {90, 115, V_REDMAP, batchtime_row}; + + perfstatcol_t batchcount_col = {155, 200, V_PURPLEMAP, batchcount_row}; + perfstatcol_t batchcalls_col = {220, 200, V_PURPLEMAP, batchcalls_row}; + + + boolean rendering = ( + gamestate == GS_LEVEL || + (gamestate == GS_TITLESCREEN && titlemapinaction) + ); + + draw_row = 10; + M_DrawPerfTiming(&frametime_col); + + if (rendering) + { + M_DrawPerfTiming(&rendercalltime_col); + + // Remember to update this calculation when adding more 3d rendering stats! + extrarendertime = ps_rendercalltime - ps_bsptime; + +#ifdef HWRENDER + if (rendermode == render_opengl) + { + extrarendertime -= + ps_hw_skyboxtime + + ps_hw_nodesorttime + + ps_hw_nodedrawtime + + ps_hw_spritesorttime + + ps_hw_spritedrawtime; + + if (cv_glbatching.value) + { + extrarendertime -= + ps_hw_batchsorttime + + ps_hw_batchdrawtime; + } + + M_DrawPerfTiming(&opengltime_col); + } + else +#endif + { + extrarendertime -= + ps_sw_spritecliptime + + ps_sw_portaltime + + ps_sw_planetime + + ps_sw_maskedtime; + + M_DrawPerfTiming(&softwaretime_col); + } + } + + M_DrawPerfTiming(&uiswaptime_col); + + draw_row += half_row; + M_DrawPerfTiming(&tictime_col); + + if (rendering) + { + draw_row = 10; + M_DrawPerfCount(&rendercalls_col); + +#ifdef HWRENDER + if (rendermode == render_opengl && cv_glbatching.value) + { + draw_row += half_row; + M_DrawPerfTiming(&batchtime_col); + + draw_row = 10; + M_DrawPerfCount(&batchcount_col); + + if (hires) + draw_row += half_row; + else + draw_row = 10; + + M_DrawPerfCount(&batchcalls_col); + } +#endif + } +} + +static void M_DrawTickStats(void) +{ + int i = 0; + thinker_t *thinker; + int thinkercount = 0; + int polythcount = 0; + int mainthcount = 0; + int mobjcount = 0; + int nothinkcount = 0; + int scenerycount = 0; + int regularcount = 0; + int dynslopethcount = 0; + int precipcount = 0; + int removecount = 0; + + precise_t extratime = + ps_tictime - + ps_playerthink_time - + ps_thinkertime - + ps_lua_thinkframe_time; + + perfstatrow_t tictime_row[] = { + {"logic ", "Game logic: ", &ps_tictime}, + {0} + }; + + perfstatrow_t thinker_time_row[] = { + {"plrthnk", "P_PlayerThink: ", &ps_playerthink_time}, + {"thnkers", "P_RunThinkers: ", &ps_thinkertime}, + {0} + }; + + perfstatrow_t detailed_thinker_time_row[] = { + {"plyobjs", "Polyobjects: ", &ps_thlist_times[THINK_POLYOBJ]}, + {"main ", "Main: ", &ps_thlist_times[THINK_MAIN]}, + {"mobjs ", "Mobjs: ", &ps_thlist_times[THINK_MOBJ]}, + {"dynslop", "Dynamic slopes: ", &ps_thlist_times[THINK_DYNSLOPE]}, + {"precip ", "Precipitation: ", &ps_thlist_times[THINK_PRECIP]}, + {0} + }; + + perfstatrow_t extra_thinker_time_row[] = { + {"lthinkf", "LUAh_ThinkFrame:", &ps_lua_thinkframe_time}, + {"other ", "Other: ", &extratime}, + {0} + }; + + perfstatrow_t thinkercount_row[] = { + {"thnkers", "Thinkers: ", &thinkercount}, + {0} + }; + + perfstatrow_t detailed_thinkercount_row[] = { + {"plyobjs", "Polyobjects: ", &polythcount}, + {"main ", "Main: ", &mainthcount}, + {"mobjs ", "Mobjs: ", &mobjcount}, + {0} + }; + + perfstatrow_t mobjthinkercount_row[] = { + {"regular", "Regular: ", ®ularcount}, + {"scenery", "Scenery: ", &scenerycount}, + {0} + }; + + perfstatrow_t nothinkcount_row[] = { + {"nothink", "Nothink: ", ¬hinkcount}, + {0} + }; + + perfstatrow_t detailed_thinkercount_row2[] = { + {"dynslop", "Dynamic slopes: ", &dynslopethcount}, + {"precip ", "Precipitation: ", &precipcount}, + {"remove ", "Pending removal:", &removecount}, + {0} + }; + + perfstatrow_t misc_calls_row[] = { + {"lmhook", "Lua mobj hooks: ", &ps_lua_mobjhooks}, + {"chkpos", "P_CheckPosition:", &ps_checkposition_calls}, + {0} + }; + + perfstatcol_t tictime_col = {20, 20, V_YELLOWMAP, tictime_row}; + perfstatcol_t thinker_time_col = {24, 24, V_YELLOWMAP, thinker_time_row}; + perfstatcol_t detailed_thinker_time_col = {28, 28, V_YELLOWMAP, detailed_thinker_time_row}; + perfstatcol_t extra_thinker_time_col = {24, 24, V_YELLOWMAP, extra_thinker_time_row}; + + perfstatcol_t thinkercount_col = {90, 115, V_BLUEMAP, thinkercount_row}; + perfstatcol_t detailed_thinkercount_col = {94, 119, V_BLUEMAP, detailed_thinkercount_row}; + perfstatcol_t mobjthinkercount_col = {98, 123, V_BLUEMAP, mobjthinkercount_row}; + perfstatcol_t nothinkcount_col = {98, 123, V_BLUEMAP, nothinkcount_row}; + perfstatcol_t detailed_thinkercount_col2 = {94, 119, V_BLUEMAP, detailed_thinkercount_row2}; + perfstatcol_t misc_calls_col = {170, 216, V_PURPLEMAP, misc_calls_row}; + + for (i = 0; i < NUM_THINKERLISTS; i++) + { + for (thinker = thlist[i].next; thinker != &thlist[i]; thinker = thinker->next) + { + thinkercount++; + if (thinker->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) + removecount++; + else if (i == THINK_POLYOBJ) + polythcount++; + else if (i == THINK_MAIN) + mainthcount++; + else if (i == THINK_MOBJ) + { + if (thinker->function.acp1 == (actionf_p1)P_MobjThinker) + { + mobj_t *mobj = (mobj_t*)thinker; + mobjcount++; + if (mobj->flags & MF_NOTHINK) + nothinkcount++; + else if (mobj->flags & MF_SCENERY) + scenerycount++; + else + regularcount++; + } + } + else if (i == THINK_DYNSLOPE) + dynslopethcount++; + else if (i == THINK_PRECIP) + precipcount++; + } + } + + draw_row = 10; + M_DrawPerfTiming(&tictime_col); + M_DrawPerfTiming(&thinker_time_col); + M_DrawPerfTiming(&detailed_thinker_time_col); + M_DrawPerfTiming(&extra_thinker_time_col); + + draw_row = 10; + M_DrawPerfCount(&thinkercount_col); + M_DrawPerfCount(&detailed_thinkercount_col); + M_DrawPerfCount(&mobjthinkercount_col); + + if (nothinkcount) + M_DrawPerfCount(¬hinkcount_col); + + M_DrawPerfCount(&detailed_thinkercount_col2); + + if (M_HighResolution()) + { + V_DrawSmallString(212, 10, V_MONOSPACE | V_ALLOWLOWERCASE | V_PURPLEMAP, "Calls:"); + + draw_row = 15; + } + else + { + draw_row = 10; + } + + M_DrawPerfCount(&misc_calls_col); +} + void M_DrawPerfStats(void) { char s[100]; - int currenttime = I_GetTimeMicros(); - int frametime = currenttime - ps_prevframetime; - ps_prevframetime = currenttime; + + PS_SetFrameTime(); if (cv_perfstats.value == 1) // rendering { - if (vid.width < 640 || vid.height < 400) // low resolution - { - snprintf(s, sizeof s - 1, "frmtime %d", frametime); - V_DrawThinString(20, 10, V_MONOSPACE | V_YELLOWMAP, s); - if (!(gamestate == GS_LEVEL || (gamestate == GS_TITLESCREEN && titlemapinaction))) - { - snprintf(s, sizeof s - 1, "ui %d", ps_uitime); - V_DrawThinString(20, 18, V_MONOSPACE | V_YELLOWMAP, s); - snprintf(s, sizeof s - 1, "finupdt %d", ps_swaptime); - V_DrawThinString(20, 26, V_MONOSPACE | V_YELLOWMAP, s); - snprintf(s, sizeof s - 1, "logic %d", ps_tictime); - V_DrawThinString(20, 38, V_MONOSPACE | V_GRAYMAP, s); - return; - } - snprintf(s, sizeof s - 1, "drwtime %d", ps_rendercalltime); - V_DrawThinString(20, 18, V_MONOSPACE | V_YELLOWMAP, s); - snprintf(s, sizeof s - 1, "bspcall %d", ps_numbspcalls); - V_DrawThinString(90, 10, V_MONOSPACE | V_BLUEMAP, s); - snprintf(s, sizeof s - 1, "sprites %d", ps_numsprites); - V_DrawThinString(90, 18, V_MONOSPACE | V_BLUEMAP, s); - snprintf(s, sizeof s - 1, "drwnode %d", ps_numdrawnodes); - V_DrawThinString(90, 26, V_MONOSPACE | V_BLUEMAP, s); - snprintf(s, sizeof s - 1, "plyobjs %d", ps_numpolyobjects); - V_DrawThinString(90, 34, V_MONOSPACE | V_BLUEMAP, s); -#ifdef HWRENDER - if (rendermode == render_opengl) // OpenGL specific stats - { - snprintf(s, sizeof s - 1, "skybox %d", ps_hw_skyboxtime); - V_DrawThinString(24, 26, V_MONOSPACE | V_YELLOWMAP, s); - snprintf(s, sizeof s - 1, "bsptime %d", ps_bsptime); - V_DrawThinString(24, 34, V_MONOSPACE | V_YELLOWMAP, s); - snprintf(s, sizeof s - 1, "nodesrt %d", ps_hw_nodesorttime); - V_DrawThinString(24, 42, V_MONOSPACE | V_YELLOWMAP, s); - snprintf(s, sizeof s - 1, "nodedrw %d", ps_hw_nodedrawtime); - V_DrawThinString(24, 50, V_MONOSPACE | V_YELLOWMAP, s); - snprintf(s, sizeof s - 1, "sprsort %d", ps_hw_spritesorttime); - V_DrawThinString(24, 58, V_MONOSPACE | V_YELLOWMAP, s); - snprintf(s, sizeof s - 1, "sprdraw %d", ps_hw_spritedrawtime); - V_DrawThinString(24, 66, V_MONOSPACE | V_YELLOWMAP, s); - snprintf(s, sizeof s - 1, "other %d", - ps_rendercalltime - ps_hw_skyboxtime - ps_bsptime - ps_hw_nodesorttime - - ps_hw_nodedrawtime - ps_hw_spritesorttime - ps_hw_spritedrawtime - - ps_hw_batchsorttime - ps_hw_batchdrawtime); - V_DrawThinString(24, 74, V_MONOSPACE | V_YELLOWMAP, s); - snprintf(s, sizeof s - 1, "ui %d", ps_uitime); - V_DrawThinString(20, 82, V_MONOSPACE | V_YELLOWMAP, s); - snprintf(s, sizeof s - 1, "finupdt %d", ps_swaptime); - V_DrawThinString(20, 90, V_MONOSPACE | V_YELLOWMAP, s); - snprintf(s, sizeof s - 1, "logic %d", ps_tictime); - V_DrawThinString(20, 102, V_MONOSPACE | V_GRAYMAP, s); - if (cv_glbatching.value) - { - snprintf(s, sizeof s - 1, "batsort %d", ps_hw_batchsorttime); - V_DrawThinString(90, 46, V_MONOSPACE | V_REDMAP, s); - snprintf(s, sizeof s - 1, "batdraw %d", ps_hw_batchdrawtime); - V_DrawThinString(90, 54, V_MONOSPACE | V_REDMAP, s); - - snprintf(s, sizeof s - 1, "polygon %d", ps_hw_numpolys); - V_DrawThinString(155, 10, V_MONOSPACE | V_PURPLEMAP, s); - snprintf(s, sizeof s - 1, "drwcall %d", ps_hw_numcalls); - V_DrawThinString(155, 18, V_MONOSPACE | V_PURPLEMAP, s); - snprintf(s, sizeof s - 1, "shaders %d", ps_hw_numshaders); - V_DrawThinString(155, 26, V_MONOSPACE | V_PURPLEMAP, s); - snprintf(s, sizeof s - 1, "vertex %d", ps_hw_numverts); - V_DrawThinString(155, 34, V_MONOSPACE | V_PURPLEMAP, s); - snprintf(s, sizeof s - 1, "texture %d", ps_hw_numtextures); - V_DrawThinString(220, 10, V_MONOSPACE | V_PURPLEMAP, s); - snprintf(s, sizeof s - 1, "polyflg %d", ps_hw_numpolyflags); - V_DrawThinString(220, 18, V_MONOSPACE | V_PURPLEMAP, s); - snprintf(s, sizeof s - 1, "colors %d", ps_hw_numcolors); - V_DrawThinString(220, 26, V_MONOSPACE | V_PURPLEMAP, s); - } - else - { - // reset these vars so the "other" measurement isn't off - ps_hw_batchsorttime = 0; - ps_hw_batchdrawtime = 0; - } - } - else // software specific stats -#endif - { - snprintf(s, sizeof s - 1, "bsptime %d", ps_bsptime); - V_DrawThinString(24, 26, V_MONOSPACE | V_YELLOWMAP, s); - snprintf(s, sizeof s - 1, "sprclip %d", ps_sw_spritecliptime); - V_DrawThinString(24, 34, V_MONOSPACE | V_YELLOWMAP, s); - snprintf(s, sizeof s - 1, "portals %d", ps_sw_portaltime); - V_DrawThinString(24, 42, V_MONOSPACE | V_YELLOWMAP, s); - snprintf(s, sizeof s - 1, "planes %d", ps_sw_planetime); - V_DrawThinString(24, 50, V_MONOSPACE | V_YELLOWMAP, s); - snprintf(s, sizeof s - 1, "masked %d", ps_sw_maskedtime); - V_DrawThinString(24, 58, V_MONOSPACE | V_YELLOWMAP, s); - snprintf(s, sizeof s - 1, "other %d", - ps_rendercalltime - ps_bsptime - ps_sw_spritecliptime - - ps_sw_portaltime - ps_sw_planetime - ps_sw_maskedtime); - V_DrawThinString(24, 66, V_MONOSPACE | V_YELLOWMAP, s); - snprintf(s, sizeof s - 1, "ui %d", ps_uitime); - V_DrawThinString(20, 74, V_MONOSPACE | V_YELLOWMAP, s); - snprintf(s, sizeof s - 1, "finupdt %d", ps_swaptime); - V_DrawThinString(20, 82, V_MONOSPACE | V_YELLOWMAP, s); - snprintf(s, sizeof s - 1, "logic %d", ps_tictime); - V_DrawThinString(20, 94, V_MONOSPACE | V_GRAYMAP, s); - } - } - else // high resolution - { - snprintf(s, sizeof s - 1, "Frame time: %d", frametime); - V_DrawSmallString(20, 10, V_MONOSPACE | V_ALLOWLOWERCASE | V_YELLOWMAP, s); - if (!(gamestate == GS_LEVEL || (gamestate == GS_TITLESCREEN && titlemapinaction))) - { - snprintf(s, sizeof s - 1, "UI render: %d", ps_uitime); - V_DrawSmallString(20, 15, V_MONOSPACE | V_ALLOWLOWERCASE | V_YELLOWMAP, s); - snprintf(s, sizeof s - 1, "I_FinishUpdate: %d", ps_swaptime); - V_DrawSmallString(20, 20, V_MONOSPACE | V_ALLOWLOWERCASE | V_YELLOWMAP, s); - snprintf(s, sizeof s - 1, "Game logic: %d", ps_tictime); - V_DrawSmallString(20, 30, V_MONOSPACE | V_ALLOWLOWERCASE | V_GRAYMAP, s); - return; - } - snprintf(s, sizeof s - 1, "3d rendering: %d", ps_rendercalltime); - V_DrawSmallString(20, 15, V_MONOSPACE | V_ALLOWLOWERCASE | V_YELLOWMAP, s); - snprintf(s, sizeof s - 1, "BSP calls: %d", ps_numbspcalls); - V_DrawSmallString(115, 10, V_MONOSPACE | V_ALLOWLOWERCASE | V_BLUEMAP, s); - snprintf(s, sizeof s - 1, "Sprites: %d", ps_numsprites); - V_DrawSmallString(115, 15, V_MONOSPACE | V_ALLOWLOWERCASE | V_BLUEMAP, s); - snprintf(s, sizeof s - 1, "Drawnodes: %d", ps_numdrawnodes); - V_DrawSmallString(115, 20, V_MONOSPACE | V_ALLOWLOWERCASE | V_BLUEMAP, s); - snprintf(s, sizeof s - 1, "Polyobjects: %d", ps_numpolyobjects); - V_DrawSmallString(115, 25, V_MONOSPACE | V_ALLOWLOWERCASE | V_BLUEMAP, s); -#ifdef HWRENDER - if (rendermode == render_opengl) // OpenGL specific stats - { - snprintf(s, sizeof s - 1, "Skybox render: %d", ps_hw_skyboxtime); - V_DrawSmallString(24, 20, V_MONOSPACE | V_ALLOWLOWERCASE | V_YELLOWMAP, s); - snprintf(s, sizeof s - 1, "RenderBSPNode: %d", ps_bsptime); - V_DrawSmallString(24, 25, V_MONOSPACE | V_ALLOWLOWERCASE | V_YELLOWMAP, s); - snprintf(s, sizeof s - 1, "Drwnode sort: %d", ps_hw_nodesorttime); - V_DrawSmallString(24, 30, V_MONOSPACE | V_ALLOWLOWERCASE | V_YELLOWMAP, s); - snprintf(s, sizeof s - 1, "Drwnode render: %d", ps_hw_nodedrawtime); - V_DrawSmallString(24, 35, V_MONOSPACE | V_ALLOWLOWERCASE | V_YELLOWMAP, s); - snprintf(s, sizeof s - 1, "Sprite sort: %d", ps_hw_spritesorttime); - V_DrawSmallString(24, 40, V_MONOSPACE | V_ALLOWLOWERCASE | V_YELLOWMAP, s); - snprintf(s, sizeof s - 1, "Sprite render: %d", ps_hw_spritedrawtime); - V_DrawSmallString(24, 45, V_MONOSPACE | V_ALLOWLOWERCASE | V_YELLOWMAP, s); - // Remember to update this calculation when adding more 3d rendering stats! - snprintf(s, sizeof s - 1, "Other: %d", - ps_rendercalltime - ps_hw_skyboxtime - ps_bsptime - ps_hw_nodesorttime - - ps_hw_nodedrawtime - ps_hw_spritesorttime - ps_hw_spritedrawtime - - ps_hw_batchsorttime - ps_hw_batchdrawtime); - V_DrawSmallString(24, 50, V_MONOSPACE | V_ALLOWLOWERCASE | V_YELLOWMAP, s); - snprintf(s, sizeof s - 1, "UI render: %d", ps_uitime); - V_DrawSmallString(20, 55, V_MONOSPACE | V_ALLOWLOWERCASE | V_YELLOWMAP, s); - snprintf(s, sizeof s - 1, "I_FinishUpdate: %d", ps_swaptime); - V_DrawSmallString(20, 60, V_MONOSPACE | V_ALLOWLOWERCASE | V_YELLOWMAP, s); - snprintf(s, sizeof s - 1, "Game logic: %d", ps_tictime); - V_DrawSmallString(20, 70, V_MONOSPACE | V_ALLOWLOWERCASE | V_GRAYMAP, s); - if (cv_glbatching.value) - { - snprintf(s, sizeof s - 1, "Batch sort: %d", ps_hw_batchsorttime); - V_DrawSmallString(115, 35, V_MONOSPACE | V_ALLOWLOWERCASE | V_REDMAP, s); - snprintf(s, sizeof s - 1, "Batch render: %d", ps_hw_batchdrawtime); - V_DrawSmallString(115, 40, V_MONOSPACE | V_ALLOWLOWERCASE | V_REDMAP, s); - - snprintf(s, sizeof s - 1, "Polygons: %d", ps_hw_numpolys); - V_DrawSmallString(200, 10, V_MONOSPACE | V_ALLOWLOWERCASE | V_PURPLEMAP, s); - snprintf(s, sizeof s - 1, "Vertices: %d", ps_hw_numverts); - V_DrawSmallString(200, 15, V_MONOSPACE | V_ALLOWLOWERCASE | V_PURPLEMAP, s); - snprintf(s, sizeof s - 1, "Draw calls: %d", ps_hw_numcalls); - V_DrawSmallString(200, 25, V_MONOSPACE | V_ALLOWLOWERCASE | V_PURPLEMAP, s); - snprintf(s, sizeof s - 1, "Shaders: %d", ps_hw_numshaders); - V_DrawSmallString(200, 30, V_MONOSPACE | V_ALLOWLOWERCASE | V_PURPLEMAP, s); - snprintf(s, sizeof s - 1, "Textures: %d", ps_hw_numtextures); - V_DrawSmallString(200, 35, V_MONOSPACE | V_ALLOWLOWERCASE | V_PURPLEMAP, s); - snprintf(s, sizeof s - 1, "Polyflags: %d", ps_hw_numpolyflags); - V_DrawSmallString(200, 40, V_MONOSPACE | V_ALLOWLOWERCASE | V_PURPLEMAP, s); - snprintf(s, sizeof s - 1, "Colors: %d", ps_hw_numcolors); - V_DrawSmallString(200, 45, V_MONOSPACE | V_ALLOWLOWERCASE | V_PURPLEMAP, s); - } - else - { - // reset these vars so the "other" measurement isn't off - ps_hw_batchsorttime = 0; - ps_hw_batchdrawtime = 0; - } - } - else // software specific stats -#endif - { - snprintf(s, sizeof s - 1, "RenderBSPNode: %d", ps_bsptime); - V_DrawSmallString(24, 20, V_MONOSPACE | V_ALLOWLOWERCASE | V_YELLOWMAP, s); - snprintf(s, sizeof s - 1, "R_ClipSprites: %d", ps_sw_spritecliptime); - V_DrawSmallString(24, 25, V_MONOSPACE | V_ALLOWLOWERCASE | V_YELLOWMAP, s); - snprintf(s, sizeof s - 1, "Portals+Skybox: %d", ps_sw_portaltime); - V_DrawSmallString(24, 30, V_MONOSPACE | V_ALLOWLOWERCASE | V_YELLOWMAP, s); - snprintf(s, sizeof s - 1, "R_DrawPlanes: %d", ps_sw_planetime); - V_DrawSmallString(24, 35, V_MONOSPACE | V_ALLOWLOWERCASE | V_YELLOWMAP, s); - snprintf(s, sizeof s - 1, "R_DrawMasked: %d", ps_sw_maskedtime); - V_DrawSmallString(24, 40, V_MONOSPACE | V_ALLOWLOWERCASE | V_YELLOWMAP, s); - // Remember to update this calculation when adding more 3d rendering stats! - snprintf(s, sizeof s - 1, "Other: %d", - ps_rendercalltime - ps_bsptime - ps_sw_spritecliptime - - ps_sw_portaltime - ps_sw_planetime - ps_sw_maskedtime); - V_DrawSmallString(24, 45, V_MONOSPACE | V_ALLOWLOWERCASE | V_YELLOWMAP, s); - snprintf(s, sizeof s - 1, "UI render: %d", ps_uitime); - V_DrawSmallString(20, 50, V_MONOSPACE | V_ALLOWLOWERCASE | V_YELLOWMAP, s); - snprintf(s, sizeof s - 1, "I_FinishUpdate: %d", ps_swaptime); - V_DrawSmallString(20, 55, V_MONOSPACE | V_ALLOWLOWERCASE | V_YELLOWMAP, s); - snprintf(s, sizeof s - 1, "Game logic: %d", ps_tictime); - V_DrawSmallString(20, 65, V_MONOSPACE | V_ALLOWLOWERCASE | V_GRAYMAP, s); - } - } + M_DrawRenderStats(); } else if (cv_perfstats.value == 2) // logic { - int i = 0; - thinker_t *thinker; - int thinkercount = 0; - int polythcount = 0; - int mainthcount = 0; - int mobjcount = 0; - int nothinkcount = 0; - int scenerycount = 0; - int dynslopethcount = 0; - int precipcount = 0; - int removecount = 0; - // y offset for drawing columns - int yoffset1 = 0; - int yoffset2 = 0; - - for (i = 0; i < NUM_THINKERLISTS; i++) - { - for (thinker = thlist[i].next; thinker != &thlist[i]; thinker = thinker->next) - { - thinkercount++; - if (thinker->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) - removecount++; - else if (i == THINK_POLYOBJ) - polythcount++; - else if (i == THINK_MAIN) - mainthcount++; - else if (i == THINK_MOBJ) - { - if (thinker->function.acp1 == (actionf_p1)P_MobjThinker) - { - mobj_t *mobj = (mobj_t*)thinker; - mobjcount++; - if (mobj->flags & MF_NOTHINK) - nothinkcount++; - else if (mobj->flags & MF_SCENERY) - scenerycount++; - } - } - else if (i == THINK_DYNSLOPE) - dynslopethcount++; - else if (i == THINK_PRECIP) - precipcount++; - } - } - - if (vid.width < 640 || vid.height < 400) // low resolution - { - snprintf(s, sizeof s - 1, "logic %d", ps_tictime); - V_DrawThinString(20, 10, V_MONOSPACE | V_YELLOWMAP, s); - if (!(gamestate == GS_LEVEL || (gamestate == GS_TITLESCREEN && titlemapinaction))) - return; - snprintf(s, sizeof s - 1, "plrthnk %d", ps_playerthink_time); - V_DrawThinString(24, 18, V_MONOSPACE | V_YELLOWMAP, s); - snprintf(s, sizeof s - 1, "thnkers %d", ps_thinkertime); - V_DrawThinString(24, 26, V_MONOSPACE | V_YELLOWMAP, s); - for (i = 0; i < NUM_THINKERLISTS; i++) - { - yoffset1 += 8; - snprintf(s, sizeof s - 1, thlist_shortnames[i], ps_thlist_times[i]); - V_DrawThinString(28, 26+yoffset1, V_MONOSPACE | V_YELLOWMAP, s); - } - snprintf(s, sizeof s - 1, "lthinkf %d", ps_lua_thinkframe_time); - V_DrawThinString(24, 34+yoffset1, V_MONOSPACE | V_YELLOWMAP, s); - snprintf(s, sizeof s - 1, "other %d", - ps_tictime - ps_playerthink_time - ps_thinkertime - ps_lua_thinkframe_time); - V_DrawThinString(24, 42+yoffset1, V_MONOSPACE | V_YELLOWMAP, s); - - snprintf(s, sizeof s - 1, "thnkers %d", thinkercount); - V_DrawThinString(90, 10, V_MONOSPACE | V_BLUEMAP, s); - snprintf(s, sizeof s - 1, "plyobjs %d", polythcount); - V_DrawThinString(94, 18, V_MONOSPACE | V_BLUEMAP, s); - snprintf(s, sizeof s - 1, "main %d", mainthcount); - V_DrawThinString(94, 26, V_MONOSPACE | V_BLUEMAP, s); - snprintf(s, sizeof s - 1, "mobjs %d", mobjcount); - V_DrawThinString(94, 34, V_MONOSPACE | V_BLUEMAP, s); - snprintf(s, sizeof s - 1, "regular %d", mobjcount - scenerycount - nothinkcount); - V_DrawThinString(98, 42, V_MONOSPACE | V_BLUEMAP, s); - snprintf(s, sizeof s - 1, "scenery %d", scenerycount); - V_DrawThinString(98, 50, V_MONOSPACE | V_BLUEMAP, s); - if (nothinkcount) - { - snprintf(s, sizeof s - 1, "nothink %d", nothinkcount); - V_DrawThinString(98, 58, V_MONOSPACE | V_BLUEMAP, s); - yoffset2 += 8; - } - snprintf(s, sizeof s - 1, "dynslop %d", dynslopethcount); - V_DrawThinString(94, 58+yoffset2, V_MONOSPACE | V_BLUEMAP, s); - snprintf(s, sizeof s - 1, "precip %d", precipcount); - V_DrawThinString(94, 66+yoffset2, V_MONOSPACE | V_BLUEMAP, s); - snprintf(s, sizeof s - 1, "remove %d", removecount); - V_DrawThinString(94, 74+yoffset2, V_MONOSPACE | V_BLUEMAP, s); - - snprintf(s, sizeof s - 1, "lmhooks %d", ps_lua_mobjhooks); - V_DrawThinString(170, 10, V_MONOSPACE | V_PURPLEMAP, s); - snprintf(s, sizeof s - 1, "chkpos %d", ps_checkposition_calls); - V_DrawThinString(170, 18, V_MONOSPACE | V_PURPLEMAP, s); - } - else // high resolution - { - snprintf(s, sizeof s - 1, "Game logic: %d", ps_tictime); - V_DrawSmallString(20, 10, V_MONOSPACE | V_ALLOWLOWERCASE | V_YELLOWMAP, s); - if (!(gamestate == GS_LEVEL || (gamestate == GS_TITLESCREEN && titlemapinaction))) - return; - snprintf(s, sizeof s - 1, "P_PlayerThink: %d", ps_playerthink_time); - V_DrawSmallString(24, 15, V_MONOSPACE | V_ALLOWLOWERCASE | V_YELLOWMAP, s); - snprintf(s, sizeof s - 1, "P_RunThinkers: %d", ps_thinkertime); - V_DrawSmallString(24, 20, V_MONOSPACE | V_ALLOWLOWERCASE | V_YELLOWMAP, s); - for (i = 0; i < NUM_THINKERLISTS; i++) - { - yoffset1 += 5; - snprintf(s, sizeof s - 1, thlist_names[i], ps_thlist_times[i]); - V_DrawSmallString(28, 20+yoffset1, V_MONOSPACE | V_ALLOWLOWERCASE | V_YELLOWMAP, s); - } - snprintf(s, sizeof s - 1, "LUAh_ThinkFrame: %d", ps_lua_thinkframe_time); - V_DrawSmallString(24, 25+yoffset1, V_MONOSPACE | V_ALLOWLOWERCASE | V_YELLOWMAP, s); - snprintf(s, sizeof s - 1, "Other: %d", - ps_tictime - ps_playerthink_time - ps_thinkertime - ps_lua_thinkframe_time); - V_DrawSmallString(24, 30+yoffset1, V_MONOSPACE | V_ALLOWLOWERCASE | V_YELLOWMAP, s); - - snprintf(s, sizeof s - 1, "Thinkers: %d", thinkercount); - V_DrawSmallString(115, 10+yoffset2, V_MONOSPACE | V_ALLOWLOWERCASE | V_BLUEMAP, s); - snprintf(s, sizeof s - 1, "Polyobjects: %d", polythcount); - V_DrawSmallString(119, 15+yoffset2, V_MONOSPACE | V_ALLOWLOWERCASE | V_BLUEMAP, s); - snprintf(s, sizeof s - 1, "Main: %d", mainthcount); - V_DrawSmallString(119, 20+yoffset2, V_MONOSPACE | V_ALLOWLOWERCASE | V_BLUEMAP, s); - snprintf(s, sizeof s - 1, "Mobjs: %d", mobjcount); - V_DrawSmallString(119, 25+yoffset2, V_MONOSPACE | V_ALLOWLOWERCASE | V_BLUEMAP, s); - snprintf(s, sizeof s - 1, "Regular: %d", mobjcount - scenerycount - nothinkcount); - V_DrawSmallString(123, 30+yoffset2, V_MONOSPACE | V_ALLOWLOWERCASE | V_BLUEMAP, s); - snprintf(s, sizeof s - 1, "Scenery: %d", scenerycount); - V_DrawSmallString(123, 35+yoffset2, V_MONOSPACE | V_ALLOWLOWERCASE | V_BLUEMAP, s); - if (nothinkcount) - { - snprintf(s, sizeof s - 1, "Nothink: %d", nothinkcount); - V_DrawSmallString(123, 40+yoffset2, V_MONOSPACE | V_ALLOWLOWERCASE | V_BLUEMAP, s); - yoffset2 += 5; - } - snprintf(s, sizeof s - 1, "Dynamic slopes: %d", dynslopethcount); - V_DrawSmallString(119, 40+yoffset2, V_MONOSPACE | V_ALLOWLOWERCASE | V_BLUEMAP, s); - snprintf(s, sizeof s - 1, "Precipitation: %d", precipcount); - V_DrawSmallString(119, 45+yoffset2, V_MONOSPACE | V_ALLOWLOWERCASE | V_BLUEMAP, s); - snprintf(s, sizeof s - 1, "Pending removal: %d", removecount); - V_DrawSmallString(119, 50+yoffset2, V_MONOSPACE | V_ALLOWLOWERCASE | V_BLUEMAP, s); - - snprintf(s, sizeof s - 1, "Calls:"); - V_DrawSmallString(212, 10, V_MONOSPACE | V_ALLOWLOWERCASE | V_PURPLEMAP, s); - snprintf(s, sizeof s - 1, "Lua mobj hooks: %d", ps_lua_mobjhooks); - V_DrawSmallString(216, 15, V_MONOSPACE | V_ALLOWLOWERCASE | V_PURPLEMAP, s); - snprintf(s, sizeof s - 1, "P_CheckPosition: %d", ps_checkposition_calls); - V_DrawSmallString(216, 20, V_MONOSPACE | V_ALLOWLOWERCASE | V_PURPLEMAP, s); - } + M_DrawTickStats(); } else if (cv_perfstats.value == 3) // lua thinkframe { diff --git a/src/m_perfstats.h b/src/m_perfstats.h index 01a818c1c..132bea38c 100644 --- a/src/m_perfstats.h +++ b/src/m_perfstats.h @@ -16,17 +16,17 @@ #include "lua_script.h" #include "p_local.h" -extern int ps_tictime; +extern precise_t ps_tictime; -extern int ps_playerthink_time; -extern int ps_thinkertime; +extern precise_t ps_playerthink_time; +extern precise_t ps_thinkertime; -extern int ps_thlist_times[]; +extern precise_t ps_thlist_times[]; -extern int ps_checkposition_calls; +extern int ps_checkposition_calls; -extern int ps_lua_thinkframe_time; -extern int ps_lua_mobjhooks; +extern precise_t ps_lua_thinkframe_time; +extern int ps_lua_mobjhooks; typedef struct { diff --git a/src/p_tick.c b/src/p_tick.c index 451e5e626..19fdc221b 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -22,7 +22,7 @@ #include "lua_script.h" #include "lua_hook.h" #include "m_perfstats.h" -#include "i_system.h" // I_GetTimeMicros +#include "i_system.h" // I_GetPreciseTime // Object place #include "m_cheat.h" @@ -323,7 +323,7 @@ static inline void P_RunThinkers(void) size_t i; for (i = 0; i < NUM_THINKERLISTS; i++) { - ps_thlist_times[i] = I_GetTimeMicros(); + ps_thlist_times[i] = I_GetPreciseTime(); for (currentthinker = thlist[i].next; currentthinker != &thlist[i]; currentthinker = currentthinker->next) { #ifdef PARANOIA @@ -331,7 +331,7 @@ static inline void P_RunThinkers(void) #endif currentthinker->function.acp1(currentthinker); } - ps_thlist_times[i] = I_GetTimeMicros() - ps_thlist_times[i]; + ps_thlist_times[i] = I_GetPreciseTime() - ps_thlist_times[i]; } } @@ -650,11 +650,11 @@ void P_Ticker(boolean run) LUAh_PreThinkFrame(); - ps_playerthink_time = I_GetTimeMicros(); + ps_playerthink_time = I_GetPreciseTime(); for (i = 0; i < MAXPLAYERS; i++) if (playeringame[i] && players[i].mo && !P_MobjWasRemoved(players[i].mo)) P_PlayerThink(&players[i]); - ps_playerthink_time = I_GetTimeMicros() - ps_playerthink_time; + ps_playerthink_time = I_GetPreciseTime() - ps_playerthink_time; } // Keep track of how long they've been playing! @@ -669,18 +669,18 @@ void P_Ticker(boolean run) if (run) { - ps_thinkertime = I_GetTimeMicros(); + ps_thinkertime = I_GetPreciseTime(); P_RunThinkers(); - ps_thinkertime = I_GetTimeMicros() - ps_thinkertime; + ps_thinkertime = I_GetPreciseTime() - ps_thinkertime; // Run any "after all the other thinkers" stuff for (i = 0; i < MAXPLAYERS; i++) if (playeringame[i] && players[i].mo && !P_MobjWasRemoved(players[i].mo)) P_PlayerAfterThink(&players[i]); - ps_lua_thinkframe_time = I_GetTimeMicros(); + ps_lua_thinkframe_time = I_GetPreciseTime(); LUAh_ThinkFrame(); - ps_lua_thinkframe_time = I_GetTimeMicros() - ps_lua_thinkframe_time; + ps_lua_thinkframe_time = I_GetPreciseTime() - ps_lua_thinkframe_time; } // Run shield positioning diff --git a/src/r_main.c b/src/r_main.c index 5165b3c87..7f2dd6729 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -34,7 +34,7 @@ #include "m_random.h" // quake camera shake #include "r_portal.h" #include "r_main.h" -#include "i_system.h" // I_GetTimeMicros +#include "i_system.h" // I_GetPreciseTime #ifdef HWRENDER #include "hardware/hw_main.h" @@ -100,17 +100,17 @@ lighttable_t *zlight[LIGHTLEVELS][MAXLIGHTZ]; extracolormap_t *extra_colormaps = NULL; // Render stats -int ps_prevframetime = 0; -int ps_rendercalltime = 0; -int ps_uitime = 0; -int ps_swaptime = 0; +precise_t ps_prevframetime = 0; +precise_t ps_rendercalltime = 0; +precise_t ps_uitime = 0; +precise_t ps_swaptime = 0; -int ps_bsptime = 0; +precise_t ps_bsptime = 0; -int ps_sw_spritecliptime = 0; -int ps_sw_portaltime = 0; -int ps_sw_planetime = 0; -int ps_sw_maskedtime = 0; +precise_t ps_sw_spritecliptime = 0; +precise_t ps_sw_portaltime = 0; +precise_t ps_sw_planetime = 0; +precise_t ps_sw_maskedtime = 0; int ps_numbspcalls = 0; int ps_numsprites = 0; @@ -1491,9 +1491,9 @@ void R_RenderPlayerView(player_t *player) ProfZeroTimer(); #endif ps_numbspcalls = ps_numpolyobjects = ps_numdrawnodes = 0; - ps_bsptime = I_GetTimeMicros(); + ps_bsptime = I_GetPreciseTime(); R_RenderBSPNode((INT32)numnodes - 1); - ps_bsptime = I_GetTimeMicros() - ps_bsptime; + ps_bsptime = I_GetPreciseTime() - ps_bsptime; ps_numsprites = visspritecount; #ifdef TIMING RDMSR(0x10, &mycount); @@ -1504,9 +1504,9 @@ void R_RenderPlayerView(player_t *player) //profile stuff --------------------------------------------------------- Mask_Post(&masks[nummasks - 1]); - ps_sw_spritecliptime = I_GetTimeMicros(); + ps_sw_spritecliptime = I_GetPreciseTime(); R_ClipSprites(drawsegs, NULL); - ps_sw_spritecliptime = I_GetTimeMicros() - ps_sw_spritecliptime; + ps_sw_spritecliptime = I_GetPreciseTime() - ps_sw_spritecliptime; // Add skybox portals caused by sky visplanes. @@ -1514,7 +1514,7 @@ void R_RenderPlayerView(player_t *player) Portal_AddSkyboxPortals(); // Portal rendering. Hijacks the BSP traversal. - ps_sw_portaltime = I_GetTimeMicros(); + ps_sw_portaltime = I_GetPreciseTime(); if (portal_base) { portal_t *portal; @@ -1554,20 +1554,20 @@ void R_RenderPlayerView(player_t *player) Portal_Remove(portal); } } - ps_sw_portaltime = I_GetTimeMicros() - ps_sw_portaltime; + ps_sw_portaltime = I_GetPreciseTime() - ps_sw_portaltime; - ps_sw_planetime = I_GetTimeMicros(); + ps_sw_planetime = I_GetPreciseTime(); R_DrawPlanes(); #ifdef FLOORSPLATS R_DrawVisibleFloorSplats(); #endif - ps_sw_planetime = I_GetTimeMicros() - ps_sw_planetime; + ps_sw_planetime = I_GetPreciseTime() - ps_sw_planetime; // draw mid texture and sprite // And now 3D floors/sides! - ps_sw_maskedtime = I_GetTimeMicros(); + ps_sw_maskedtime = I_GetPreciseTime(); R_DrawMasked(masks, nummasks); - ps_sw_maskedtime = I_GetTimeMicros() - ps_sw_maskedtime; + ps_sw_maskedtime = I_GetPreciseTime() - ps_sw_maskedtime; free(masks); } diff --git a/src/r_main.h b/src/r_main.h index 379b5b8df..eb3d0eedd 100644 --- a/src/r_main.h +++ b/src/r_main.h @@ -78,17 +78,17 @@ boolean R_DoCulling(line_t *cullheight, line_t *viewcullheight, fixed_t vz, fixe // Render stats -extern int ps_prevframetime;// time when previous frame was rendered -extern int ps_rendercalltime; -extern int ps_uitime; -extern int ps_swaptime; +extern precise_t ps_prevframetime;// time when previous frame was rendered +extern precise_t ps_rendercalltime; +extern precise_t ps_uitime; +extern precise_t ps_swaptime; -extern int ps_bsptime; +extern precise_t ps_bsptime; -extern int ps_sw_spritecliptime; -extern int ps_sw_portaltime; -extern int ps_sw_planetime; -extern int ps_sw_maskedtime; +extern precise_t ps_sw_spritecliptime; +extern precise_t ps_sw_portaltime; +extern precise_t ps_sw_planetime; +extern precise_t ps_sw_maskedtime; extern int ps_numbspcalls; extern int ps_numsprites; From d031bb5357cdfddcdf1dbd01c094fa4761ed7292 Mon Sep 17 00:00:00 2001 From: GoldenTails Date: Sat, 7 Nov 2020 03:43:55 -0600 Subject: [PATCH 0283/1080] fix dumb memcpy --- src/m_anigif.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/m_anigif.c b/src/m_anigif.c index 372781a97..566f48d50 100644 --- a/src/m_anigif.c +++ b/src/m_anigif.c @@ -732,7 +732,7 @@ INT32 GIF_open(const char *filename) gif_optimize = (!!cv_gif_optimize.value); gif_downscale = (!!cv_gif_downscale.value); - memcpy(&gif_dynamicdelay, &cv_gif_dynamicdelay.value, sizeof(gif_dynamicdelay)); //gif_dynamicdelay = (!!cv_gif_dynamicdelay.value); + gif_dynamicdelay = cv_gif_dynamicdelay.value; gif_localcolortable = (!!cv_gif_localcolortable.value); gif_colorprofile = (!!cv_screenshot_colorprofile.value); gif_headerpalette = GIF_getpalette(0); From 9d11d8eec952c6cdff67423e3bd0b7ad40f79a8e Mon Sep 17 00:00:00 2001 From: GoldenTails Date: Sat, 7 Nov 2020 03:49:21 -0600 Subject: [PATCH 0284/1080] Remove 3 wasteful bytes of guaranteed blank memory from some place where it's not gonna matter that much --- src/m_anigif.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/m_anigif.c b/src/m_anigif.c index 566f48d50..dbc8d3422 100644 --- a/src/m_anigif.c +++ b/src/m_anigif.c @@ -43,7 +43,7 @@ consvar_t cv_gif_localcolortable = CVAR_INIT ("gif_localcolortable", "On", CV_S #ifdef HAVE_ANIGIF static boolean gif_optimize = false; // So nobody can do something dumb static boolean gif_downscale = false; // like changing cvars mid output -static INT32 gif_dynamicdelay = 0; // and messing something up +static UINT8 gif_dynamicdelay = (UINT8)0; // and messing something up // Palette handling static boolean gif_localcolortable = false; @@ -604,7 +604,7 @@ static void GIF_framewrite(void) UINT16 delay = 0; INT32 startline; - if (gif_dynamicdelay == 2) + if (gif_dynamicdelay ==(UINT8) 2) { // golden's attempt at creating a "dynamic delay" UINT16 mingifdelay = 10; // minimum gif delay in milliseconds (keep at 10 because gifs can't get more precise). @@ -617,7 +617,7 @@ static void GIF_framewrite(void) gif_delayus -= frames*(mingifdelay*1000); // remove frames by the amount of milliseconds they take. don't reset to 0, the microseconds help consistency. } } - else if (gif_dynamicdelay == 1) + else if (gif_dynamicdelay ==(UINT8) 1) { float delayf = ceil(100.0f/NEWTICRATE); @@ -732,7 +732,7 @@ INT32 GIF_open(const char *filename) gif_optimize = (!!cv_gif_optimize.value); gif_downscale = (!!cv_gif_downscale.value); - gif_dynamicdelay = cv_gif_dynamicdelay.value; + gif_dynamicdelay = (UINT8)cv_gif_dynamicdelay.value; gif_localcolortable = (!!cv_gif_localcolortable.value); gif_colorprofile = (!!cv_screenshot_colorprofile.value); gif_headerpalette = GIF_getpalette(0); From 515d7eeb9ea6cd84afffc6e0b93e63bbf3d7635f Mon Sep 17 00:00:00 2001 From: James R Date: Sat, 7 Nov 2020 01:54:54 -0800 Subject: [PATCH 0285/1080] Let's try an experiment: move the epoch forward as I_GetTime is called This will make it even longer until time wraps around. Have you ever run a srb2 server for 4 years straight? --- src/sdl/i_system.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/sdl/i_system.c b/src/sdl/i_system.c index 8a70847e1..d4ef86c5a 100644 --- a/src/sdl/i_system.c +++ b/src/sdl/i_system.c @@ -2044,12 +2044,20 @@ ticcmd_t *I_BaseTiccmd2(void) // static Uint64 timer_frequency; + +static double tic_frequency; static Uint64 tic_epoch; tic_t I_GetTime(void) { + static double elapsed; + const Uint64 now = SDL_GetPerformanceCounter(); - return (now - tic_epoch) * NEWTICRATE / timer_frequency; + + elapsed += (now - tic_epoch) / tic_frequency; + tic_epoch = now; // moving epoch + + return (tic_t)elapsed; } precise_t I_GetPreciseTime(void) @@ -2069,6 +2077,8 @@ void I_StartupTimer(void) { timer_frequency = SDL_GetPerformanceFrequency(); tic_epoch = SDL_GetPerformanceCounter(); + + tic_frequency = timer_frequency / NEWTICRATE; } void I_Sleep(void) From c0dbc562bb186069558bc44dd619d85f41323c4c Mon Sep 17 00:00:00 2001 From: James R Date: Sat, 7 Nov 2020 13:48:37 -0800 Subject: [PATCH 0286/1080] Fix floating point math --- src/sdl/i_system.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sdl/i_system.c b/src/sdl/i_system.c index d4ef86c5a..d2c819c37 100644 --- a/src/sdl/i_system.c +++ b/src/sdl/i_system.c @@ -2067,7 +2067,7 @@ precise_t I_GetPreciseTime(void) int I_PreciseToMicros(precise_t d) { - return d / (timer_frequency / 1000000); + return (int)(d / (timer_frequency / 1000000.0)); } // @@ -2078,7 +2078,7 @@ void I_StartupTimer(void) timer_frequency = SDL_GetPerformanceFrequency(); tic_epoch = SDL_GetPerformanceCounter(); - tic_frequency = timer_frequency / NEWTICRATE; + tic_frequency = timer_frequency / (double)NEWTICRATE; } void I_Sleep(void) From 1320f10839cb28d3fe5363a4feeee1cdd6fbb149 Mon Sep 17 00:00:00 2001 From: Steel Titanium Date: Sat, 7 Nov 2020 23:53:46 -0500 Subject: [PATCH 0287/1080] Allow access to skin.sprites[] Only numframes so far though, as there's already a function for what spriteframe provides. --- src/lua_baselib.c | 2 ++ src/lua_libs.h | 2 ++ src/lua_skinlib.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 66 insertions(+), 1 deletion(-) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 132ebc1a8..ab074c8ad 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -162,6 +162,8 @@ static const struct { {META_SKIN, "skin_t"}, {META_POWERS, "player_t.powers"}, {META_SOUNDSID, "skin_t.soundsid"}, + {META_SKINSPRITES, "skin_t.sprites"}, + {META_SKINSPRITESLIST, "skin_t.sprites[]"}, {META_VERTEX, "vertex_t"}, {META_LINE, "line_t"}, diff --git a/src/lua_libs.h b/src/lua_libs.h index 03bd99cd2..82fdccf10 100644 --- a/src/lua_libs.h +++ b/src/lua_libs.h @@ -34,6 +34,8 @@ extern lua_State *gL; #define META_SKIN "SKIN_T*" #define META_POWERS "PLAYER_T*POWERS" #define META_SOUNDSID "SKIN_T*SOUNDSID" +#define META_SKINSPRITES "SKIN_T*SPRITES" +#define META_SKINSPRITESLIST "SKIN_T*SPRITES[]" #define META_VERTEX "VERTEX_T*" #define META_LINE "LINE_T*" diff --git a/src/lua_skinlib.c b/src/lua_skinlib.c index 3e4ddb9f0..1cd9df631 100644 --- a/src/lua_skinlib.c +++ b/src/lua_skinlib.c @@ -54,7 +54,8 @@ enum skin { skin_contspeed, skin_contangle, skin_soundsid, - skin_availability + skin_availability, + skin_sprites }; static const char *const skin_opt[] = { "valid", @@ -93,6 +94,7 @@ static const char *const skin_opt[] = { "contangle", "soundsid", "availability", + "sprites", NULL}; #define UNIMPLEMENTED luaL_error(L, LUA_QL("skin_t") " field " LUA_QS " is not implemented for Lua and cannot be accessed.", skin_opt[field]) @@ -214,6 +216,9 @@ static int skin_get(lua_State *L) case skin_availability: lua_pushinteger(L, skin->availability); break; + case skin_sprites: + LUA_PushUserdata(L, skin->sprites, META_SKINSPRITES); + break; } return 1; } @@ -324,6 +329,49 @@ static int soundsid_num(lua_State *L) return 1; } +enum spritesopt { + numframes = 0 +}; + +static const char *const sprites_opt[] = { + "numframes", + NULL}; + +// skin.sprites[i] -> sprites[i] +static int lib_getSkinSprite(lua_State *L) +{ + spritedef_t *sprites = *((spritedef_t **)luaL_checkudata(L, 1, META_SKINSPRITES)); + playersprite_t i = luaL_checkinteger(L, 2); + + if (i < 0 || i >= NUMPLAYERSPRITES*2) + return luaL_error(L, "skin.sprites[] index %d out of range (0 - %d)", i, (NUMPLAYERSPRITES*2)-1); + + LUA_PushLightUserdata(L, &sprites[i], META_SKINSPRITESLIST); + return 1; +} + +// #skin.sprites -> NUMPLAYERSPRITES*2 +static int lib_numSkinsSprites(lua_State *L) +{ + lua_pushinteger(L, NUMPLAYERSPRITES*2); + return 1; +} + +static int sprite_get(lua_State *L) +{ + spritedef_t *sprite = (spritedef_t *)luaL_checkudata(L, 1, META_SKINSPRITESLIST); + enum spritesopt field = luaL_checkoption(L, 2, NULL, sprites_opt); + + switch (field) + { + case numframes: + lua_pushinteger(L, sprite->numframes); + break; + } + return 1; +} + + int LUA_SkinLib(lua_State *L) { luaL_newmetatable(L, META_SKIN); @@ -345,6 +393,19 @@ int LUA_SkinLib(lua_State *L) lua_setfield(L, -2, "__len"); lua_pop(L,1); + luaL_newmetatable(L, META_SKINSPRITES); + lua_pushcfunction(L, lib_getSkinSprite); + lua_setfield(L, -2, "__index"); + + lua_pushcfunction(L, lib_numSkinsSprites); + lua_setfield(L, -2, "__len"); + lua_pop(L,1); + + luaL_newmetatable(L, META_SKINSPRITESLIST); + lua_pushcfunction(L, sprite_get); + lua_setfield(L, -2, "__index"); + lua_pop(L,1); + lua_newuserdata(L, 0); lua_createtable(L, 0, 2); lua_pushcfunction(L, lib_getSkin); From e52cb7f6fa1dae752c7d30fd8a7240df64985273 Mon Sep 17 00:00:00 2001 From: Louis-Antoine Date: Sun, 8 Nov 2020 17:20:25 +0100 Subject: [PATCH 0288/1080] Throw an error if too many metatables are registered --- src/lua_baselib.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 468af0aa1..ac9b6053d 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -250,12 +250,15 @@ static int lib_userdataType(lua_State *L) // Only callable during script loading static int lib_registerMetatable(lua_State *L) { - static UINT32 nextid = 1; + static UINT16 nextid = 1; if (!lua_lumploading) return luaL_error(L, "This function cannot be called from within a hook or coroutine!"); luaL_checktype(L, 1, LUA_TTABLE); + if (nextid == 0) + luaL_error(L, "Too many metatables registered?! Please consider rewriting your script once you are sober again.\n"); + lua_getfield(L, LUA_REGISTRYINDEX, LREG_METATABLES); // 2 // registry.metatables[metatable] = nextid lua_pushvalue(L, 1); // 3 From 87206a8c2163236fe7da42ab77b230ba5d6d5f1c Mon Sep 17 00:00:00 2001 From: Louis-Antoine Date: Sun, 8 Nov 2020 17:33:49 +0100 Subject: [PATCH 0289/1080] Show a console error if the gamestate contains too many tables --- src/lua_script.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/lua_script.c b/src/lua_script.c index 6bd1a81c5..c504cc6f3 100644 --- a/src/lua_script.c +++ b/src/lua_script.c @@ -980,8 +980,17 @@ static UINT8 ArchiveValue(int TABLESINDEX, int myindex) lua_pop(gL, 1); } if (!found) + { t++; + if (t == 0) + { + CONS_Alert(CONS_ERROR, "Too many tables to archive!\n"); + WRITEUINT8(save_p, ARCH_NULL); + return 0; + } + } + WRITEUINT8(save_p, ARCH_TABLE); WRITEUINT16(save_p, t); From 83a87042f1e76c8b378b188e9389830e50de0e3d Mon Sep 17 00:00:00 2001 From: Steel Titanium Date: Sun, 8 Nov 2020 13:25:56 -0500 Subject: [PATCH 0290/1080] Push skin->sprites as light userdata --- src/lua_skinlib.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lua_skinlib.c b/src/lua_skinlib.c index 1cd9df631..d4d7bae12 100644 --- a/src/lua_skinlib.c +++ b/src/lua_skinlib.c @@ -217,7 +217,7 @@ static int skin_get(lua_State *L) lua_pushinteger(L, skin->availability); break; case skin_sprites: - LUA_PushUserdata(L, skin->sprites, META_SKINSPRITES); + LUA_PushLightUserdata(L, skin->sprites, META_SKINSPRITES); break; } return 1; @@ -340,7 +340,7 @@ static const char *const sprites_opt[] = { // skin.sprites[i] -> sprites[i] static int lib_getSkinSprite(lua_State *L) { - spritedef_t *sprites = *((spritedef_t **)luaL_checkudata(L, 1, META_SKINSPRITES)); + spritedef_t *sprites = (spritedef_t *)luaL_checkudata(L, 1, META_SKINSPRITES); playersprite_t i = luaL_checkinteger(L, 2); if (i < 0 || i >= NUMPLAYERSPRITES*2) From d26172661d6fac5720950c93365609dcf009cc68 Mon Sep 17 00:00:00 2001 From: Steel Titanium Date: Sun, 8 Nov 2020 13:31:59 -0500 Subject: [PATCH 0291/1080] Remove spritedef field --- src/lua_skinlib.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/lua_skinlib.c b/src/lua_skinlib.c index d4d7bae12..e2f16756a 100644 --- a/src/lua_skinlib.c +++ b/src/lua_skinlib.c @@ -21,7 +21,6 @@ enum skin { skin_valid = 0, skin_name, - skin_spritedef, skin_wadnum, skin_flags, skin_realname, @@ -60,7 +59,6 @@ enum skin { static const char *const skin_opt[] = { "valid", "name", - "spritedef", "wadnum", "flags", "realname", @@ -115,8 +113,6 @@ static int skin_get(lua_State *L) case skin_name: lua_pushstring(L, skin->name); break; - case skin_spritedef: - return UNIMPLEMENTED; case skin_wadnum: // !!WARNING!! May differ between clients due to music wads, therefore NOT NETWORK SAFE return UNIMPLEMENTED; From 9f851dc28594ee9a5ef929e32b520bcbfa8a486f Mon Sep 17 00:00:00 2001 From: Louis-Antoine Date: Mon, 9 Nov 2020 00:16:40 +0100 Subject: [PATCH 0292/1080] Return explicitly when failing to register a metatable --- src/lua_baselib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index ac9b6053d..3acbd3d0f 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -257,7 +257,7 @@ static int lib_registerMetatable(lua_State *L) luaL_checktype(L, 1, LUA_TTABLE); if (nextid == 0) - luaL_error(L, "Too many metatables registered?! Please consider rewriting your script once you are sober again.\n"); + return luaL_error(L, "Too many metatables registered?! Please consider rewriting your script once you are sober again.\n"); lua_getfield(L, LUA_REGISTRYINDEX, LREG_METATABLES); // 2 // registry.metatables[metatable] = nextid From b8f668b2e0765801f4027d451a86faa4890ada5e Mon Sep 17 00:00:00 2001 From: Jaime Passos Date: Sun, 8 Nov 2020 23:02:05 -0300 Subject: [PATCH 0293/1080] rename --- src/hardware/hw_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index f3c313d8d..7667b5f4f 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -6011,7 +6011,7 @@ static CV_PossibleValue_t glfiltermode_cons_t[]= {{HWD_SET_TEXTUREFILTER_POINTSA CV_PossibleValue_t glanisotropicmode_cons_t[] = {{1, "MIN"}, {16, "MAX"}, {0, NULL}}; consvar_t cv_glshaders = CVAR_INIT ("gr_shaders", "On", CV_SAVE, glshaders_cons_t, NULL); -consvar_t cv_glallowshaders = CVAR_INIT ("gr_allowshaders", "On", CV_NETVAR, CV_OnOff, NULL); +consvar_t cv_glallowshaders = CVAR_INIT ("gr_allowclientshaders", "On", CV_NETVAR, CV_OnOff, NULL); consvar_t cv_fovchange = CVAR_INIT ("gr_fovchange", "Off", CV_SAVE, CV_OnOff, NULL); #ifdef ALAM_LIGHTING From bcaed4b95b77c82c9d27969ef3754b840432caea Mon Sep 17 00:00:00 2001 From: Steel Titanium Date: Sun, 8 Nov 2020 21:33:12 -0500 Subject: [PATCH 0294/1080] Remove unused music types --- src/dehacked.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/dehacked.c b/src/dehacked.c index df0fe6f50..3ef3a9572 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -10117,9 +10117,7 @@ struct { {"MU_MID", MU_MID}, {"MU_OGG", MU_OGG}, {"MU_MP3", MU_MP3}, - {"MU_MP3_MAD_UNUSED", MU_MP3_MAD_UNUSED}, {"MU_FLAC", MU_FLAC}, - {"MU_MODPLUG_UNUSED", MU_MODPLUG_UNUSED}, {"MU_GME", MU_GME}, {"MU_MOD_EX", MU_MOD_EX}, {"MU_MID_EX", MU_MID_EX}, From 9e6c0c31be6409f1aebcbe88583928bab34ddef7 Mon Sep 17 00:00:00 2001 From: GoldenTails Date: Sun, 8 Nov 2020 20:43:16 -0600 Subject: [PATCH 0295/1080] Add skincolor vars to the NetSave --- src/p_saveg.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/p_saveg.c b/src/p_saveg.c index 4f6f31803..9dbe5445b 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -3990,6 +3990,12 @@ static void P_NetArchiveMisc(void) WRITEINT32(save_p, sstimer); WRITEUINT32(save_p, bluescore); WRITEUINT32(save_p, redscore); + + WRITEUINT16(save_p, skincolor_redteam); + WRITEUINT16(save_p, skincolor_blueteam); + WRITEUINT16(save_p, skincolor_redring); + WRITEUINT16(save_p, skincolor_bluering); + WRITEINT32(save_p, modulothing); WRITEINT16(save_p, autobalance); @@ -4074,6 +4080,12 @@ static inline boolean P_NetUnArchiveMisc(void) sstimer = READINT32(save_p); bluescore = READUINT32(save_p); redscore = READUINT32(save_p); + + skincolor_redteam = READUINT16(save_p); + skincolor_blueteam = READUINT16(save_p); + skincolor_redring = READUINT16(save_p); + skincolor_bluering = READUINT16(save_p); + modulothing = READINT32(save_p); autobalance = READINT16(save_p); From fae4709f4b56cc881c6f106239c1060ce7f521ff Mon Sep 17 00:00:00 2001 From: GoldenTails Date: Sun, 8 Nov 2020 23:28:20 -0600 Subject: [PATCH 0296/1080] Fix stupid divide-by-zero error --- src/d_clisrv.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index a3fbe88d9..b198011a0 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -2501,10 +2501,14 @@ static void CL_RemovePlayer(INT32 playernum, kickreason_t reason) } count--; - spheres = players[playernum].spheres; - rings = players[playernum].rings; - sincrement = spheres/count; - rincrement = rings/count; + sincrement = spheres = players[playernum].spheres; + rincrement = rings = players[playernum].rings; + + if (count) + { + sincrement /= count; + rincrement /= count; + } for (i = 0; i < MAXPLAYERS; i++) { From 3daee0ebf882d795ec0aef7fb54d48b74f940c59 Mon Sep 17 00:00:00 2001 From: Riku Salminen <38985578+Riku-S@users.noreply.github.com> Date: Mon, 9 Nov 2020 17:01:20 +0200 Subject: [PATCH 0297/1080] Made height/spinheight and height change values in replays more accurate --- src/g_demo.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/src/g_demo.c b/src/g_demo.c index 0f72ad109..9d3b86015 100644 --- a/src/g_demo.c +++ b/src/g_demo.c @@ -453,8 +453,7 @@ void G_WriteGhostTic(mobj_t *ghost) WRITEUINT16(demo_p,oldghost.sprite); if (ghostext.flags & EZT_HEIGHT) { - height >>= FRACBITS; - WRITEINT16(demo_p, height); + WRITEFIXED(demo_p, height); } ghostext.flags = 0; } @@ -610,7 +609,7 @@ void G_ConsGhostTic(void) if (xziptic & EZT_SPRITE) demo_p += sizeof(UINT16); if (xziptic & EZT_HEIGHT) - demo_p += sizeof(INT16); + demo_p += (demoversion < 0x000e) ? sizeof(INT16) : sizeof(fixed_t); } if (ziptic & GZT_FOLLOW) @@ -842,7 +841,7 @@ void G_GhostTicker(void) g->mo->sprite = READUINT16(g->p); if (xziptic & EZT_HEIGHT) { - fixed_t temp = READINT16(g->p)<version < 0x000e) ? READINT16(g->p)<p); g->mo->height = FixedMul(temp, g->mo->scale); } } @@ -1106,7 +1105,7 @@ void G_ReadMetalTic(mobj_t *metal) metal->sprite = READUINT16(metal_p); if (xziptic & EZT_HEIGHT) { - fixed_t temp = READINT16(metal_p)<height = FixedMul(temp, metal->scale); } } @@ -1293,8 +1292,7 @@ void G_WriteMetalTic(mobj_t *metal) WRITEUINT16(demo_p,oldmetal.sprite); if (ghostext.flags & EZT_HEIGHT) { - height >>= FRACBITS; - WRITEINT16(demo_p, height); + WRITEFIXED(demo_p, height); } ghostext.flags = 0; } @@ -1474,8 +1472,8 @@ void G_BeginRecording(void) WRITEUINT8(demo_p,player->thrustfactor); WRITEUINT8(demo_p,player->accelstart); WRITEUINT8(demo_p,player->acceleration); - WRITEUINT8(demo_p,player->height>>FRACBITS); - WRITEUINT8(demo_p,player->spinheight>>FRACBITS); + WRITEFIXED(demo_p,player->height); + WRITEFIXED(demo_p,player->spinheight); WRITEUINT8(demo_p,player->camerascale>>FRACBITS); WRITEUINT8(demo_p,player->shieldscale>>FRACBITS); @@ -1901,8 +1899,8 @@ void G_DoPlayDemo(char *defdemoname) thrustfactor = READUINT8(demo_p); accelstart = READUINT8(demo_p); acceleration = READUINT8(demo_p); - height = (fixed_t)READUINT8(demo_p)< Date: Mon, 9 Nov 2020 18:55:00 -0500 Subject: [PATCH 0298/1080] Make the replay camera follow the player --- src/p_tick.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/p_tick.c b/src/p_tick.c index f84ae96c0..4fd08f987 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -639,7 +639,12 @@ void P_Ticker(boolean run) if (demorecording) G_WriteDemoTiccmd(&players[consoleplayer].cmd, 0); if (demoplayback) + { G_ReadDemoTiccmd(&players[consoleplayer].cmd, 0); + P_SetPlayerAngle(&players[consoleplayer], players[consoleplayer].mo->angle); + P_ForceLocalAngle(&players[consoleplayer], players[consoleplayer].mo->angle); + localaiming = players[consoleplayer].aiming; + } LUAh_PreThinkFrame(); From b62a3b623a851fe4af3fb64cc3724156a12e2738 Mon Sep 17 00:00:00 2001 From: James R Date: Mon, 9 Nov 2020 18:54:00 -0800 Subject: [PATCH 0299/1080] Don't let Lua cvar setting functions work on CV_NOLUA vars --- src/lua_consolelib.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/lua_consolelib.c b/src/lua_consolelib.c index c6b082930..32d64b5b5 100644 --- a/src/lua_consolelib.c +++ b/src/lua_consolelib.c @@ -440,6 +440,9 @@ static int CVarSetFunction ){ consvar_t *cvar = (consvar_t *)luaL_checkudata(L, 1, META_CVAR); + if (cvar->flags & CV_NOLUA) + return luaL_error(L, "Variable %s cannot be set from Lua.", cvar->name); + switch (lua_type(L, 2)) { case LUA_TSTRING: @@ -468,7 +471,12 @@ static int lib_cvStealthSet(lua_State *L) static int lib_cvAddValue(lua_State *L) { consvar_t *cvar = (consvar_t *)luaL_checkudata(L, 1, META_CVAR); + + if (cvar->flags & CV_NOLUA) + return luaL_error(L, "Variable %s cannot be set from Lua.", cvar->name); + CV_AddValue(cvar, (INT32)luaL_checknumber(L, 2)); + return 0; } From 7c79f702340662c6d8f370b9ef709181c690f49b Mon Sep 17 00:00:00 2001 From: Riku Salminen Date: Tue, 10 Nov 2020 04:17:25 -0500 Subject: [PATCH 0300/1080] Update p_tick.c, got rid of an useless angle change function --- src/p_tick.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/p_tick.c b/src/p_tick.c index 4fd08f987..b49b27cc8 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -640,10 +640,10 @@ void P_Ticker(boolean run) G_WriteDemoTiccmd(&players[consoleplayer].cmd, 0); if (demoplayback) { - G_ReadDemoTiccmd(&players[consoleplayer].cmd, 0); - P_SetPlayerAngle(&players[consoleplayer], players[consoleplayer].mo->angle); - P_ForceLocalAngle(&players[consoleplayer], players[consoleplayer].mo->angle); - localaiming = players[consoleplayer].aiming; + player_t* p = &players[consoleplayer]; + G_ReadDemoTiccmd(&p->cmd, 0); + P_ForceLocalAngle(p, p->mo->angle); + localaiming = p->aiming; } LUAh_PreThinkFrame(); From 241453056b41837c4918a81f06a9f35894f670ce Mon Sep 17 00:00:00 2001 From: Riku Salminen Date: Tue, 10 Nov 2020 04:31:26 -0500 Subject: [PATCH 0301/1080] Update p_tick.c, Replacing mobj angle with cmd angleturn --- src/p_tick.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_tick.c b/src/p_tick.c index b49b27cc8..15ec57054 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -642,7 +642,7 @@ void P_Ticker(boolean run) { player_t* p = &players[consoleplayer]; G_ReadDemoTiccmd(&p->cmd, 0); - P_ForceLocalAngle(p, p->mo->angle); + P_ForceLocalAngle(p, p->cmd.angleturn << 16); localaiming = p->aiming; } From 7eeb75260be9d3a5b068ec377e186d22498f4de9 Mon Sep 17 00:00:00 2001 From: Riku Salminen <38985578+Riku-S@users.noreply.github.com> Date: Tue, 10 Nov 2020 13:06:47 +0200 Subject: [PATCH 0302/1080] Try to add cvars for old camera --- src/d_netcmd.c | 2 ++ src/p_tick.c | 8 ++++++-- src/p_tick.h | 1 + 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 68b8ecfc1..ac1c0da1e 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -884,6 +884,8 @@ void D_RegisterClientCommands(void) // CV_RegisterVar(&cv_grid); // CV_RegisterVar(&cv_snapto); + CV_RegisterVar(&cv_freedemocamera); + // add cheat commands COM_AddCommand("noclip", Command_CheatNoClip_f); COM_AddCommand("god", Command_CheatGod_f); diff --git a/src/p_tick.c b/src/p_tick.c index 15ec57054..05ffefa7a 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -37,6 +37,7 @@ tic_t leveltime; // The entries will behave like both the head and tail of the lists. thinker_t thlist[NUM_THINKERLISTS]; +consvar_t cv_freedemocamera = {"freedemocamera", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; void Command_Numthinkers_f(void) { @@ -642,8 +643,11 @@ void P_Ticker(boolean run) { player_t* p = &players[consoleplayer]; G_ReadDemoTiccmd(&p->cmd, 0); - P_ForceLocalAngle(p, p->cmd.angleturn << 16); - localaiming = p->aiming; + if (!cv_freedemocamera.value) + { + P_ForceLocalAngle(p, p->cmd.angleturn << 16); + localaiming = p->aiming; + } } LUAh_PreThinkFrame(); diff --git a/src/p_tick.h b/src/p_tick.h index 1fb88f3f2..3b04a427a 100644 --- a/src/p_tick.h +++ b/src/p_tick.h @@ -19,6 +19,7 @@ #endif extern tic_t leveltime; +extern consvar_t cv_freedemocamera; // Called by G_Ticker. Carries out all thinking of enemies and players. void Command_Numthinkers_f(void); From 1d542d3676a583118a2345603ef3c79b78285160 Mon Sep 17 00:00:00 2001 From: Nev3r Date: Tue, 10 Nov 2020 12:12:16 +0100 Subject: [PATCH 0303/1080] Add copyright notices. --- src/taglist.c | 13 +++++++++++++ src/taglist.h | 13 +++++++++++++ 2 files changed, 26 insertions(+) diff --git a/src/taglist.c b/src/taglist.c index bc5a166fd..3c75f293f 100644 --- a/src/taglist.c +++ b/src/taglist.c @@ -1,3 +1,16 @@ +// SONIC ROBO BLAST 2 +//----------------------------------------------------------------------------- +// Copyright (C) 1998-2000 by DooM Legacy Team. +// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 2020 by Nev3r. +// +// This program is free software distributed under the +// terms of the GNU General Public License, version 2. +// See the 'LICENSE' file for more details. +//----------------------------------------------------------------------------- +/// \file taglist.c +/// \brief Ingame sector/line/mapthing tagging. + #include "taglist.h" #include "z_zone.h" #include "r_data.h" diff --git a/src/taglist.h b/src/taglist.h index 896344c13..ab69787dd 100644 --- a/src/taglist.h +++ b/src/taglist.h @@ -1,3 +1,16 @@ +// SONIC ROBO BLAST 2 +//----------------------------------------------------------------------------- +// Copyright (C) 1998-2000 by DooM Legacy Team. +// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 2020 by Nev3r. +// +// This program is free software distributed under the +// terms of the GNU General Public License, version 2. +// See the 'LICENSE' file for more details. +//----------------------------------------------------------------------------- +/// \file taglist.h +/// \brief Tag iteration and reading functions and macros' declarations. + #ifndef __R_TAGLIST__ #define __R_TAGLIST__ From 2832586274b0d285200faa4cb0c752c7b0232380 Mon Sep 17 00:00:00 2001 From: Riku Salminen Date: Mon, 9 Nov 2020 18:55:00 -0500 Subject: [PATCH 0304/1080] Make the replay camera follow the player --- src/p_tick.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/p_tick.c b/src/p_tick.c index 451e5e626..a2ea2ff0f 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -643,7 +643,12 @@ void P_Ticker(boolean run) if (demorecording) G_WriteDemoTiccmd(&players[consoleplayer].cmd, 0); if (demoplayback) + { G_ReadDemoTiccmd(&players[consoleplayer].cmd, 0); + P_SetPlayerAngle(&players[consoleplayer], players[consoleplayer].mo->angle); + P_ForceLocalAngle(&players[consoleplayer], players[consoleplayer].mo->angle); + localaiming = players[consoleplayer].aiming; + } ps_lua_mobjhooks = 0; ps_checkposition_calls = 0; From aea35171c2bf00b31190e299d68fe034c7f77d6c Mon Sep 17 00:00:00 2001 From: Riku Salminen Date: Tue, 10 Nov 2020 04:17:25 -0500 Subject: [PATCH 0305/1080] Update p_tick.c, got rid of an useless angle change function --- src/p_tick.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/p_tick.c b/src/p_tick.c index a2ea2ff0f..c03884eeb 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -644,10 +644,10 @@ void P_Ticker(boolean run) G_WriteDemoTiccmd(&players[consoleplayer].cmd, 0); if (demoplayback) { - G_ReadDemoTiccmd(&players[consoleplayer].cmd, 0); - P_SetPlayerAngle(&players[consoleplayer], players[consoleplayer].mo->angle); - P_ForceLocalAngle(&players[consoleplayer], players[consoleplayer].mo->angle); - localaiming = players[consoleplayer].aiming; + player_t* p = &players[consoleplayer]; + G_ReadDemoTiccmd(&p->cmd, 0); + P_ForceLocalAngle(p, p->mo->angle); + localaiming = p->aiming; } ps_lua_mobjhooks = 0; From 33725a58b43add93068d8bd3e9fe22897c6eaac2 Mon Sep 17 00:00:00 2001 From: Riku Salminen Date: Tue, 10 Nov 2020 04:31:26 -0500 Subject: [PATCH 0306/1080] Update p_tick.c, Replacing mobj angle with cmd angleturn --- src/p_tick.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_tick.c b/src/p_tick.c index c03884eeb..90f410f9d 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -646,7 +646,7 @@ void P_Ticker(boolean run) { player_t* p = &players[consoleplayer]; G_ReadDemoTiccmd(&p->cmd, 0); - P_ForceLocalAngle(p, p->mo->angle); + P_ForceLocalAngle(p, p->cmd.angleturn << 16); localaiming = p->aiming; } From 3dff612f3c2901bb0e5c4bc833cff3fb8851e919 Mon Sep 17 00:00:00 2001 From: Riku Salminen <38985578+Riku-S@users.noreply.github.com> Date: Tue, 10 Nov 2020 13:06:47 +0200 Subject: [PATCH 0307/1080] Try to add cvars for old camera --- src/d_netcmd.c | 2 ++ src/p_tick.c | 8 ++++++-- src/p_tick.h | 1 + 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 87abd596a..a113460f5 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -880,6 +880,8 @@ void D_RegisterClientCommands(void) // CV_RegisterVar(&cv_grid); // CV_RegisterVar(&cv_snapto); + CV_RegisterVar(&cv_freedemocamera); + // add cheat commands COM_AddCommand("noclip", Command_CheatNoClip_f); COM_AddCommand("god", Command_CheatGod_f); diff --git a/src/p_tick.c b/src/p_tick.c index 90f410f9d..24d5005e1 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -39,6 +39,7 @@ tic_t leveltime; // The entries will behave like both the head and tail of the lists. thinker_t thlist[NUM_THINKERLISTS]; +consvar_t cv_freedemocamera = {"freedemocamera", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; void Command_Numthinkers_f(void) { @@ -646,8 +647,11 @@ void P_Ticker(boolean run) { player_t* p = &players[consoleplayer]; G_ReadDemoTiccmd(&p->cmd, 0); - P_ForceLocalAngle(p, p->cmd.angleturn << 16); - localaiming = p->aiming; + if (!cv_freedemocamera.value) + { + P_ForceLocalAngle(p, p->cmd.angleturn << 16); + localaiming = p->aiming; + } } ps_lua_mobjhooks = 0; diff --git a/src/p_tick.h b/src/p_tick.h index 1fb88f3f2..3b04a427a 100644 --- a/src/p_tick.h +++ b/src/p_tick.h @@ -19,6 +19,7 @@ #endif extern tic_t leveltime; +extern consvar_t cv_freedemocamera; // Called by G_Ticker. Carries out all thinking of enemies and players. void Command_Numthinkers_f(void); From 95a61a226be02dac53b1b8938fba486e64979327 Mon Sep 17 00:00:00 2001 From: Nev3r Date: Tue, 10 Nov 2020 12:22:55 +0100 Subject: [PATCH 0308/1080] rename TAG_ITER_C to TAG_ITER_DECLARECOUNTER and remove the semicolon from the macro. --- src/p_ceilng.c | 4 ++-- src/p_floor.c | 22 +++++++++++----------- src/p_lights.c | 2 +- src/p_mobj.c | 4 ++-- src/p_setup.c | 4 ++-- src/p_slopes.c | 2 +- src/p_spec.c | 20 ++++++++++---------- src/taglist.h | 2 +- 8 files changed, 30 insertions(+), 30 deletions(-) diff --git a/src/p_ceilng.c b/src/p_ceilng.c index f355ee011..0cea8c52f 100644 --- a/src/p_ceilng.c +++ b/src/p_ceilng.c @@ -395,7 +395,7 @@ INT32 EV_DoCeiling(line_t *line, ceiling_e type) sector_t *sec; ceiling_t *ceiling; mtag_t tag = Tag_FGet(&line->tags); - TAG_ITER_C + TAG_ITER_DECLARECOUNTER; TAG_ITER_SECTORS(tag, secnum) { @@ -617,7 +617,7 @@ INT32 EV_DoCrush(line_t *line, ceiling_e type) sector_t *sec; ceiling_t *ceiling; mtag_t tag = Tag_FGet(&line->tags); - TAG_ITER_C + TAG_ITER_DECLARECOUNTER; TAG_ITER_SECTORS(tag, secnum) { diff --git a/src/p_floor.c b/src/p_floor.c index 198148549..98a26039a 100644 --- a/src/p_floor.c +++ b/src/p_floor.c @@ -635,7 +635,7 @@ void T_BounceCheese(bouncecheese_t *bouncer) boolean remove; INT32 i; mtag_t tag = Tag_FGet(&bouncer->sourceline->tags); - TAG_ITER_C + TAG_ITER_DECLARECOUNTER; if (bouncer->sector->crumblestate == CRUMBLE_RESTORE || bouncer->sector->crumblestate == CRUMBLE_WAIT || bouncer->sector->crumblestate == CRUMBLE_ACTIVATED) // Oops! Crumbler says to remove yourself! @@ -775,7 +775,7 @@ void T_StartCrumble(crumble_t *crumble) sector_t *sector; INT32 i; mtag_t tag = Tag_FGet(&crumble->sourceline->tags); - TAG_ITER_C + TAG_ITER_DECLARECOUNTER; // Once done, the no-return thinker just sits there, // constantly 'returning'... kind of an oxymoron, isn't it? @@ -948,7 +948,7 @@ void T_StartCrumble(crumble_t *crumble) void T_MarioBlock(mariothink_t *block) { INT32 i; - TAG_ITER_C + TAG_ITER_DECLARECOUNTER; T_MovePlane ( @@ -1295,7 +1295,7 @@ void T_NoEnemiesSector(noenemies_t *nobaddies) INT32 secnum = -1; boolean FOFsector = false; mtag_t tag = Tag_FGet(&nobaddies->sourceline->tags); - TAG_ITER_C + TAG_ITER_DECLARECOUNTER; TAG_ITER_SECTORS(tag, secnum) { @@ -1308,7 +1308,7 @@ void T_NoEnemiesSector(noenemies_t *nobaddies) { INT32 targetsecnum = -1; mtag_t tag2 = Tag_FGet(&sec->lines[i]->tags); - TAG_ITER_C + TAG_ITER_DECLARECOUNTER; if (sec->lines[i]->special < 100 || sec->lines[i]->special >= 300) continue; @@ -1402,7 +1402,7 @@ void T_EachTimeThinker(eachtime_t *eachtime) fixed_t bottomheight, topheight; ffloor_t *rover; mtag_t tag = Tag_FGet(&eachtime->sourceline->tags); - TAG_ITER_C + TAG_ITER_DECLARECOUNTER; for (i = 0; i < MAXPLAYERS; i++) { @@ -1430,7 +1430,7 @@ void T_EachTimeThinker(eachtime_t *eachtime) { INT32 targetsecnum = -1; mtag_t tag2 = Tag_FGet(&sec->lines[i]->tags); - TAG_ITER_C + TAG_ITER_DECLARECOUNTER; if (sec->lines[i]->special < 100 || sec->lines[i]->special >= 300) continue; @@ -1572,7 +1572,7 @@ void T_RaiseSector(raise_t *raise) INT32 direction; result_e res = 0; mtag_t tag = raise->tag; - TAG_ITER_C + TAG_ITER_DECLARECOUNTER; if (raise->sector->crumblestate >= CRUMBLE_FALL || raise->sector->ceilingdata) return; @@ -1822,7 +1822,7 @@ void EV_DoFloor(line_t *line, floor_e floortype) sector_t *sec; floormove_t *dofloor; mtag_t tag = Tag_FGet(&line->tags); - TAG_ITER_C + TAG_ITER_DECLARECOUNTER; TAG_ITER_SECTORS(tag, secnum) { @@ -2039,7 +2039,7 @@ void EV_DoElevator(line_t *line, elevator_e elevtype, boolean customspeed) sector_t *sec; elevator_t *elevator; mtag_t tag = Tag_FGet(&line->tags); - TAG_ITER_C + TAG_ITER_DECLARECOUNTER; // act on all sectors with the same tag as the triggering linedef TAG_ITER_SECTORS(tag, secnum) @@ -2339,7 +2339,7 @@ INT32 EV_StartCrumble(sector_t *sec, ffloor_t *rover, boolean floating, sector_t *foundsec; INT32 i; mtag_t tag = Tag_FGet(&rover->master->tags); - TAG_ITER_C + TAG_ITER_DECLARECOUNTER; // If floor is already activated, skip it if (sec->floordata) diff --git a/src/p_lights.c b/src/p_lights.c index bb8ef6989..326549477 100644 --- a/src/p_lights.c +++ b/src/p_lights.c @@ -374,7 +374,7 @@ void P_FadeLightBySector(sector_t *sector, INT32 destvalue, INT32 speed, boolean void P_FadeLight(INT16 tag, INT32 destvalue, INT32 speed, boolean ticbased, boolean force) { INT32 i; - TAG_ITER_C + TAG_ITER_DECLARECOUNTER; // search all sectors for ones with tag TAG_ITER_SECTORS(tag, i) diff --git a/src/p_mobj.c b/src/p_mobj.c index 61a376729..2ae24b402 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -4631,7 +4631,7 @@ static boolean P_Boss4MoveCage(mobj_t *mobj, fixed_t delta) INT32 snum; sector_t *sector; boolean gotcage = false; - TAG_ITER_C + TAG_ITER_DECLARECOUNTER; TAG_ITER_SECTORS(tag, snum) { @@ -4717,7 +4717,7 @@ static void P_Boss4DestroyCage(mobj_t *mobj) size_t a; sector_t *sector, *rsec; ffloor_t *rover; - TAG_ITER_C + TAG_ITER_DECLARECOUNTER; TAG_ITER_SECTORS(tag, snum) { diff --git a/src/p_setup.c b/src/p_setup.c index 87fb2ac0d..dd49ae0be 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2971,7 +2971,7 @@ static void P_ConvertBinaryMap(void) INT32 check = -1; INT32 paramline = -1; - TAG_ITER_C + TAG_ITER_DECLARECOUNTER; TAG_ITER_LINES(tag, check) { @@ -3188,7 +3188,7 @@ static void P_ConvertBinaryMap(void) INT32 firstline = -1; mtag_t tag = mapthings[i].angle; - TAG_ITER_C + TAG_ITER_DECLARECOUNTER; Tag_FSet(&mapthings[i].tags, tag); diff --git a/src/p_slopes.c b/src/p_slopes.c index 412d13dd2..80278451a 100644 --- a/src/p_slopes.c +++ b/src/p_slopes.c @@ -546,7 +546,7 @@ static boolean P_SetSlopeFromTag(sector_t *sec, INT32 tag, boolean ceiling) { INT32 i; pslope_t **secslope = ceiling ? &sec->c_slope : &sec->f_slope; - TAG_ITER_C + TAG_ITER_DECLARECOUNTER; if (!tag || *secslope) return false; diff --git a/src/p_spec.c b/src/p_spec.c index 39d7e9223..0746c65b0 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -2223,7 +2223,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) INT32 secnum = -1; mobj_t *bot = NULL; mtag_t tag = Tag_FGet(&line->tags); - TAG_ITER_C + TAG_ITER_DECLARECOUNTER; I_Assert(!mo || !P_MobjWasRemoved(mo)); // If mo is there, mo must be valid! @@ -3887,7 +3887,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) case 465: // Set linedef executor delay { INT32 linenum; - TAG_ITER_C + TAG_ITER_DECLARECOUNTER; if (!udmf) break; @@ -5922,7 +5922,7 @@ void T_LaserFlash(laserthink_t *flash) sector_t *sector; sector_t *sourcesec = flash->sourceline->frontsector; fixed_t top, bottom; - TAG_ITER_C + TAG_ITER_DECLARECOUNTER; TAG_ITER_SECTORS(flash->tag, s) { @@ -6204,7 +6204,7 @@ void P_SpawnSpecials(boolean fromnetsave) INT32 s; size_t sec; ffloortype_e ffloorflags; - TAG_ITER_C + TAG_ITER_DECLARECOUNTER; case 1: // Definable gravity per sector sec = sides[*lines[i].sidenum].sector - sectors; @@ -7098,7 +7098,7 @@ void P_SpawnSpecials(boolean fromnetsave) */ static void P_AddFakeFloorsByLine(size_t line, ffloortype_e ffloorflags, thinkerlist_t *secthinkers) { - TAG_ITER_C + TAG_ITER_DECLARECOUNTER; INT32 s; mtag_t tag = Tag_FGet(&lines[line].tags); size_t sec = sides[*lines[line].sidenum].sector-sectors; @@ -7214,7 +7214,7 @@ void T_Scroll(scroll_t *s) size_t i; INT32 sect; ffloor_t *rover; - TAG_ITER_C + TAG_ITER_DECLARECOUNTER; case sc_side: // scroll wall texture side = sides + s->affectee; @@ -7466,7 +7466,7 @@ static void P_SpawnScrollers(void) switch (special) { register INT32 s; - TAG_ITER_C + TAG_ITER_DECLARECOUNTER; case 513: // scroll effect ceiling case 533: // scroll and carry objects on ceiling @@ -7604,7 +7604,7 @@ void T_Disappear(disappear_t *d) ffloor_t *rover; register INT32 s; mtag_t afftag = Tag_FGet(&lines[d->affectee].tags); - TAG_ITER_C + TAG_ITER_DECLARECOUNTER; TAG_ITER_SECTORS(afftag, s) { @@ -8337,7 +8337,7 @@ static void P_SpawnFriction(void) fixed_t strength; // frontside texture offset controls magnitude fixed_t friction; // friction value to be applied during movement INT32 movefactor; // applied to each player move to simulate inertia - TAG_ITER_C + TAG_ITER_DECLARECOUNTER; for (i = 0; i < numlines; i++, l++) if (l->special == 540) @@ -8882,7 +8882,7 @@ static void P_SpawnPushers(void) mtag_t tag; register INT32 s; mobj_t *thing; - TAG_ITER_C + TAG_ITER_DECLARECOUNTER; for (i = 0; i < numlines; i++, l++) { diff --git a/src/taglist.h b/src/taglist.h index ab69787dd..caf99b807 100644 --- a/src/taglist.h +++ b/src/taglist.h @@ -61,7 +61,7 @@ INT32 Tag_FindLineSpecial(const INT16 special, const mtag_t tag); INT32 P_FindSpecialLineFromTag(INT16 special, INT16 tag, INT32 start); // Use this macro to declare the iterator position variable. -#define TAG_ITER_C size_t tag_iterator_pos; +#define TAG_ITER_DECLARECOUNTER size_t tag_iterator_pos #define TAG_ITER(fn, tag, id) for(tag_iterator_pos = 0; (id = fn(tag, tag_iterator_pos)) >= 0; tag_iterator_pos++) From d5355a11b004c797f08c51e030bcb74e2292bd82 Mon Sep 17 00:00:00 2001 From: Nev3r Date: Tue, 10 Nov 2020 12:23:30 +0100 Subject: [PATCH 0309/1080] Indent --- src/taglist.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/taglist.c b/src/taglist.c index 3c75f293f..b85d5d616 100644 --- a/src/taglist.c +++ b/src/taglist.c @@ -70,8 +70,8 @@ boolean Tag_Compare (const taglist_t* list1, const taglist_t* list2) return false; for (i = 0; i < list1->count; i++) - if (list1->tags[i] != list2->tags[i]) - return false; + if (list1->tags[i] != list2->tags[i]) + return false; return true; } From b65211d1481b1813d02276e3e007c28bec7b2d3e Mon Sep 17 00:00:00 2001 From: Nev3r Date: Tue, 10 Nov 2020 12:34:08 +0100 Subject: [PATCH 0310/1080] Use sizeu1() --- src/p_spec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_spec.c b/src/p_spec.c index 0746c65b0..417c94c99 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -5510,7 +5510,7 @@ static ffloor_t *P_AddFakeFloor(sector_t *sec, sector_t *sec2, line_t *master, f { fixed_t tempceiling = sec2->ceilingheight; //flip the sector around and print an error instead of crashing 12.1.08 -Inuyasha - CONS_Alert(CONS_ERROR, M_GetText("FOF (line %d) has a top height below its bottom.\n"), master - lines); + CONS_Alert(CONS_ERROR, M_GetText("FOF (line %d) has a top height below its bottom.\n"), sizeu1(master - lines)); sec2->ceilingheight = sec2->floorheight; sec2->floorheight = tempceiling; } From 676f7f5dbfe27ccd1be14f558ebdfc14baf53554 Mon Sep 17 00:00:00 2001 From: Nev3r Date: Tue, 10 Nov 2020 12:45:30 +0100 Subject: [PATCH 0311/1080] Use memmove() --- src/taglist.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/taglist.c b/src/taglist.c index b85d5d616..90608518b 100644 --- a/src/taglist.c +++ b/src/taglist.c @@ -123,14 +123,7 @@ void Taggroup_Add (taggroup_t *garray[], const mtag_t tag, size_t id) // Offset existing elements to make room for the new one. if (i < group->count) - { - // Temporary memory block for copying. - size_t size = group->count - i; - size_t *temp = malloc(size); - memcpy(temp, &group->elements[i], size); - memcpy(&group->elements[i + 1], temp, size); - free(temp); - } + memmove(&group->elements[i + 1], &group->elements[i], group->count - i); } group->count++; From 91a34575a7df1a3e5ee02dd87ca758483e009591 Mon Sep 17 00:00:00 2001 From: Riku Salminen <38985578+Riku-S@users.noreply.github.com> Date: Tue, 10 Nov 2020 13:53:31 +0200 Subject: [PATCH 0312/1080] Declared the cvar in netcmd to get rid of warnings --- src/d_netcmd.c | 1 + src/d_netcmd.h | 2 ++ src/p_tick.c | 1 - src/p_tick.h | 1 - 4 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index a113460f5..6f4675e4a 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -374,6 +374,7 @@ consvar_t cv_sleep = CVAR_INIT ("cpusleep", "1", CV_SAVE, sleeping_cons_t, NULL) static CV_PossibleValue_t perfstats_cons_t[] = { {0, "Off"}, {1, "Rendering"}, {2, "Logic"}, {3, "ThinkFrame"}, {0, NULL}}; consvar_t cv_perfstats = CVAR_INIT ("perfstats", "Off", 0, perfstats_cons_t, NULL); +consvar_t cv_freedemocamera = CVAR_INIT("freedemocamera", "Off", CV_SAVE, CV_OnOff, NULL); char timedemo_name[256]; boolean timedemo_csv; diff --git a/src/d_netcmd.h b/src/d_netcmd.h index 841f71acd..7ecdd4e12 100644 --- a/src/d_netcmd.h +++ b/src/d_netcmd.h @@ -121,6 +121,8 @@ extern boolean timedemo_csv; extern char timedemo_csv_id[256]; extern boolean timedemo_quit; +extern consvar_t cv_freedemocamera; + typedef enum { XD_NAMEANDCOLOR = 1, diff --git a/src/p_tick.c b/src/p_tick.c index 24d5005e1..da2a980c4 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -39,7 +39,6 @@ tic_t leveltime; // The entries will behave like both the head and tail of the lists. thinker_t thlist[NUM_THINKERLISTS]; -consvar_t cv_freedemocamera = {"freedemocamera", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; void Command_Numthinkers_f(void) { diff --git a/src/p_tick.h b/src/p_tick.h index 3b04a427a..1fb88f3f2 100644 --- a/src/p_tick.h +++ b/src/p_tick.h @@ -19,7 +19,6 @@ #endif extern tic_t leveltime; -extern consvar_t cv_freedemocamera; // Called by G_Ticker. Carries out all thinking of enemies and players. void Command_Numthinkers_f(void); From a405f17d0b5492c63030496d2ffb86763ecdaac2 Mon Sep 17 00:00:00 2001 From: Nev3r Date: Tue, 10 Nov 2020 13:09:30 +0100 Subject: [PATCH 0313/1080] Missing prototype. --- src/taglist.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/taglist.h b/src/taglist.h index caf99b807..52979b55f 100644 --- a/src/taglist.h +++ b/src/taglist.h @@ -50,6 +50,7 @@ taggroup_t* tags_mapthings[MAXTAGS + 1]; void Taggroup_Add (taggroup_t *garray[], const mtag_t tag, size_t id); void Taggroup_Remove (taggroup_t *garray[], const mtag_t tag, size_t id); +size_t Taggroup_Find (const taggroup_t *group, const size_t id); void Taglist_InitGlobalTables(void); From 56c3e93d3a6a825007130979b760489e44e8ecbb Mon Sep 17 00:00:00 2001 From: Nev3r Date: Tue, 10 Nov 2020 13:10:01 +0100 Subject: [PATCH 0314/1080] Remove unused tag parameter. --- src/p_spec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/p_spec.c b/src/p_spec.c index 417c94c99..f512e4583 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -5806,7 +5806,7 @@ static void P_AddAirbob(sector_t *sec, INT16 tag, fixed_t dist, boolean raise, b * \sa P_SpawnSpecials, T_ThwompSector * \author SSNTails */ -static inline void P_AddThwompThinker(sector_t *sec, INT16 tag, line_t *sourceline, fixed_t crushspeed, fixed_t retractspeed, UINT16 sound) +static inline void P_AddThwompThinker(sector_t *sec, line_t *sourceline, fixed_t crushspeed, fixed_t retractspeed, UINT16 sound) { thwomp_t *thwomp; @@ -6753,7 +6753,7 @@ void P_SpawnSpecials(boolean fromnetsave) fixed_t crushspeed = (lines[i].flags & ML_EFFECT5) ? lines[i].dy >> 3 : 10*FRACUNIT; fixed_t retractspeed = (lines[i].flags & ML_EFFECT5) ? lines[i].dx >> 3 : 2*FRACUNIT; UINT16 sound = (lines[i].flags & ML_EFFECT4) ? sides[lines[i].sidenum[0]].textureoffset >> FRACBITS : sfx_thwomp; - P_AddThwompThinker(lines[i].frontsector, tag, &lines[i], crushspeed, retractspeed, sound); + P_AddThwompThinker(lines[i].frontsector, &lines[i], crushspeed, retractspeed, sound); P_AddFakeFloorsByLine(i, FF_EXISTS|FF_SOLID|FF_RENDERALL|FF_CUTLEVEL, secthinkers); break; } From a931d09e7d67d48f5877ba592734f15293cdfbc3 Mon Sep 17 00:00:00 2001 From: Nev3r Date: Tue, 10 Nov 2020 13:11:42 +0100 Subject: [PATCH 0315/1080] Forgot to change %d to %s for sizeu1(). --- src/p_spec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_spec.c b/src/p_spec.c index f512e4583..c0b9983d1 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -5510,7 +5510,7 @@ static ffloor_t *P_AddFakeFloor(sector_t *sec, sector_t *sec2, line_t *master, f { fixed_t tempceiling = sec2->ceilingheight; //flip the sector around and print an error instead of crashing 12.1.08 -Inuyasha - CONS_Alert(CONS_ERROR, M_GetText("FOF (line %d) has a top height below its bottom.\n"), sizeu1(master - lines)); + CONS_Alert(CONS_ERROR, M_GetText("FOF (line %s) has a top height below its bottom.\n"), sizeu1(master - lines)); sec2->ceilingheight = sec2->floorheight; sec2->floorheight = tempceiling; } From a8f554075f784239e3df7ea2a80fa64a76a58deb Mon Sep 17 00:00:00 2001 From: Nev3r Date: Thu, 12 Nov 2020 12:25:02 +0100 Subject: [PATCH 0316/1080] Extern the global tag groups properly. --- src/taglist.c | 4 ++++ src/taglist.h | 6 +++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/taglist.c b/src/taglist.c index 90608518b..a9879e495 100644 --- a/src/taglist.c +++ b/src/taglist.c @@ -15,6 +15,10 @@ #include "z_zone.h" #include "r_data.h" +taggroup_t* tags_sectors[MAXTAGS + 1]; +taggroup_t* tags_lines[MAXTAGS + 1]; +taggroup_t* tags_mapthings[MAXTAGS + 1]; + void Tag_Add (taglist_t* list, const mtag_t tag) { list->tags = Z_Realloc(list->tags, (list->count + 1) * sizeof(list->tags), PU_LEVEL, NULL); diff --git a/src/taglist.h b/src/taglist.h index 52979b55f..f3895eabb 100644 --- a/src/taglist.h +++ b/src/taglist.h @@ -44,9 +44,9 @@ typedef struct size_t count; } taggroup_t; -taggroup_t* tags_sectors[MAXTAGS + 1]; -taggroup_t* tags_lines[MAXTAGS + 1]; -taggroup_t* tags_mapthings[MAXTAGS + 1]; +extern taggroup_t* tags_sectors[]; +extern taggroup_t* tags_lines[]; +extern taggroup_t* tags_mapthings[]; void Taggroup_Add (taggroup_t *garray[], const mtag_t tag, size_t id); void Taggroup_Remove (taggroup_t *garray[], const mtag_t tag, size_t id); From 2c8a99f25ac0ba76ca24894e4f86608a66f920a3 Mon Sep 17 00:00:00 2001 From: Nev3r Date: Thu, 12 Nov 2020 13:48:14 +0100 Subject: [PATCH 0317/1080] Add a level parameter to the iterators to account for nesting, and thus avoid variable shadowing. --- src/p_ceilng.c | 8 +-- src/p_floor.c | 50 +++++++++---------- src/p_lights.c | 4 +- src/p_mobj.c | 8 +-- src/p_setup.c | 8 +-- src/p_slopes.c | 4 +- src/p_spec.c | 132 ++++++++++++++++++++++++------------------------- src/taglist.h | 10 ++-- 8 files changed, 112 insertions(+), 112 deletions(-) diff --git a/src/p_ceilng.c b/src/p_ceilng.c index 0cea8c52f..f12499d5c 100644 --- a/src/p_ceilng.c +++ b/src/p_ceilng.c @@ -395,9 +395,9 @@ INT32 EV_DoCeiling(line_t *line, ceiling_e type) sector_t *sec; ceiling_t *ceiling; mtag_t tag = Tag_FGet(&line->tags); - TAG_ITER_DECLARECOUNTER; + TAG_ITER_DECLARECOUNTER(0); - TAG_ITER_SECTORS(tag, secnum) + TAG_ITER_SECTORS(0, tag, secnum) { sec = §ors[secnum]; @@ -617,9 +617,9 @@ INT32 EV_DoCrush(line_t *line, ceiling_e type) sector_t *sec; ceiling_t *ceiling; mtag_t tag = Tag_FGet(&line->tags); - TAG_ITER_DECLARECOUNTER; + TAG_ITER_DECLARECOUNTER(0); - TAG_ITER_SECTORS(tag, secnum) + TAG_ITER_SECTORS(0, tag, secnum) { sec = §ors[secnum]; diff --git a/src/p_floor.c b/src/p_floor.c index 98a26039a..ed49b03a3 100644 --- a/src/p_floor.c +++ b/src/p_floor.c @@ -635,7 +635,7 @@ void T_BounceCheese(bouncecheese_t *bouncer) boolean remove; INT32 i; mtag_t tag = Tag_FGet(&bouncer->sourceline->tags); - TAG_ITER_DECLARECOUNTER; + TAG_ITER_DECLARECOUNTER(0); if (bouncer->sector->crumblestate == CRUMBLE_RESTORE || bouncer->sector->crumblestate == CRUMBLE_WAIT || bouncer->sector->crumblestate == CRUMBLE_ACTIVATED) // Oops! Crumbler says to remove yourself! @@ -650,7 +650,7 @@ void T_BounceCheese(bouncecheese_t *bouncer) } // You can use multiple target sectors, but at your own risk!!! - TAG_ITER_SECTORS(tag, i) + TAG_ITER_SECTORS(0, tag, i) { actionsector = §ors[i]; actionsector->moved = true; @@ -775,7 +775,7 @@ void T_StartCrumble(crumble_t *crumble) sector_t *sector; INT32 i; mtag_t tag = Tag_FGet(&crumble->sourceline->tags); - TAG_ITER_DECLARECOUNTER; + TAG_ITER_DECLARECOUNTER(0); // Once done, the no-return thinker just sits there, // constantly 'returning'... kind of an oxymoron, isn't it? @@ -804,7 +804,7 @@ void T_StartCrumble(crumble_t *crumble) } else if (++crumble->timer == 0) // Reposition back to original spot { - TAG_ITER_SECTORS(tag, i) + TAG_ITER_SECTORS(0, tag, i) { sector = §ors[i]; @@ -840,7 +840,7 @@ void T_StartCrumble(crumble_t *crumble) // Flash to indicate that the platform is about to return. if (crumble->timer > -224 && (leveltime % ((abs(crumble->timer)/8) + 1) == 0)) { - TAG_ITER_SECTORS(tag, i) + TAG_ITER_SECTORS(0, tag, i) { sector = §ors[i]; @@ -932,7 +932,7 @@ void T_StartCrumble(crumble_t *crumble) P_RemoveThinker(&crumble->thinker); } - TAG_ITER_SECTORS(tag, i) + TAG_ITER_SECTORS(0, tag, i) { sector = §ors[i]; sector->moved = true; @@ -948,7 +948,7 @@ void T_StartCrumble(crumble_t *crumble) void T_MarioBlock(mariothink_t *block) { INT32 i; - TAG_ITER_DECLARECOUNTER; + TAG_ITER_DECLARECOUNTER(0); T_MovePlane ( @@ -983,7 +983,7 @@ void T_MarioBlock(mariothink_t *block) block->sector->ceilspeed = 0; block->direction = 0; } - TAG_ITER_SECTORS((INT16)block->tag, i) + TAG_ITER_SECTORS(0, (INT16)block->tag, i) P_RecalcPrecipInSector(§ors[i]); } @@ -1295,9 +1295,9 @@ void T_NoEnemiesSector(noenemies_t *nobaddies) INT32 secnum = -1; boolean FOFsector = false; mtag_t tag = Tag_FGet(&nobaddies->sourceline->tags); - TAG_ITER_DECLARECOUNTER; + TAG_ITER_DECLARECOUNTER(0); - TAG_ITER_SECTORS(tag, secnum) + TAG_ITER_SECTORS(0, tag, secnum) { sec = §ors[secnum]; @@ -1308,14 +1308,14 @@ void T_NoEnemiesSector(noenemies_t *nobaddies) { INT32 targetsecnum = -1; mtag_t tag2 = Tag_FGet(&sec->lines[i]->tags); - TAG_ITER_DECLARECOUNTER; + TAG_ITER_DECLARECOUNTER(1); if (sec->lines[i]->special < 100 || sec->lines[i]->special >= 300) continue; FOFsector = true; - TAG_ITER_SECTORS(tag2, targetsecnum) + TAG_ITER_SECTORS(1, tag2, targetsecnum) { if (T_SectorHasEnemies(§ors[targetsecnum])) return; @@ -1402,7 +1402,7 @@ void T_EachTimeThinker(eachtime_t *eachtime) fixed_t bottomheight, topheight; ffloor_t *rover; mtag_t tag = Tag_FGet(&eachtime->sourceline->tags); - TAG_ITER_DECLARECOUNTER; + TAG_ITER_DECLARECOUNTER(0); for (i = 0; i < MAXPLAYERS; i++) { @@ -1412,7 +1412,7 @@ void T_EachTimeThinker(eachtime_t *eachtime) eachtime->playersOnArea[i] = false; } - TAG_ITER_SECTORS(tag, secnum) + TAG_ITER_SECTORS(0, tag, secnum) { sec = §ors[secnum]; @@ -1430,14 +1430,14 @@ void T_EachTimeThinker(eachtime_t *eachtime) { INT32 targetsecnum = -1; mtag_t tag2 = Tag_FGet(&sec->lines[i]->tags); - TAG_ITER_DECLARECOUNTER; + TAG_ITER_DECLARECOUNTER(1); if (sec->lines[i]->special < 100 || sec->lines[i]->special >= 300) continue; FOFsector = true; - TAG_ITER_SECTORS(tag2, targetsecnum) + TAG_ITER_SECTORS(1, tag2, targetsecnum) { targetsec = §ors[targetsecnum]; @@ -1572,12 +1572,12 @@ void T_RaiseSector(raise_t *raise) INT32 direction; result_e res = 0; mtag_t tag = raise->tag; - TAG_ITER_DECLARECOUNTER; + TAG_ITER_DECLARECOUNTER(0); if (raise->sector->crumblestate >= CRUMBLE_FALL || raise->sector->ceilingdata) return; - TAG_ITER_SECTORS(tag, i) + TAG_ITER_SECTORS(0, tag, i) { sector = §ors[i]; @@ -1704,7 +1704,7 @@ void T_RaiseSector(raise_t *raise) raise->sector->ceilspeed = 42; raise->sector->floorspeed = speed*direction; - TAG_ITER_SECTORS(tag, i) + TAG_ITER_SECTORS(0, tag, i) P_RecalcPrecipInSector(§ors[i]); } @@ -1822,9 +1822,9 @@ void EV_DoFloor(line_t *line, floor_e floortype) sector_t *sec; floormove_t *dofloor; mtag_t tag = Tag_FGet(&line->tags); - TAG_ITER_DECLARECOUNTER; + TAG_ITER_DECLARECOUNTER(0); - TAG_ITER_SECTORS(tag, secnum) + TAG_ITER_SECTORS(0, tag, secnum) { sec = §ors[secnum]; @@ -2039,10 +2039,10 @@ void EV_DoElevator(line_t *line, elevator_e elevtype, boolean customspeed) sector_t *sec; elevator_t *elevator; mtag_t tag = Tag_FGet(&line->tags); - TAG_ITER_DECLARECOUNTER; + TAG_ITER_DECLARECOUNTER(0); // act on all sectors with the same tag as the triggering linedef - TAG_ITER_SECTORS(tag, secnum) + TAG_ITER_SECTORS(0, tag, secnum) { sec = §ors[secnum]; @@ -2339,7 +2339,7 @@ INT32 EV_StartCrumble(sector_t *sec, ffloor_t *rover, boolean floating, sector_t *foundsec; INT32 i; mtag_t tag = Tag_FGet(&rover->master->tags); - TAG_ITER_DECLARECOUNTER; + TAG_ITER_DECLARECOUNTER(0); // If floor is already activated, skip it if (sec->floordata) @@ -2382,7 +2382,7 @@ INT32 EV_StartCrumble(sector_t *sec, ffloor_t *rover, boolean floating, crumble->sector->crumblestate = CRUMBLE_ACTIVATED; - TAG_ITER_SECTORS(tag, i) + TAG_ITER_SECTORS(0, tag, i) { foundsec = §ors[i]; diff --git a/src/p_lights.c b/src/p_lights.c index 326549477..d396e92d3 100644 --- a/src/p_lights.c +++ b/src/p_lights.c @@ -374,10 +374,10 @@ void P_FadeLightBySector(sector_t *sector, INT32 destvalue, INT32 speed, boolean void P_FadeLight(INT16 tag, INT32 destvalue, INT32 speed, boolean ticbased, boolean force) { INT32 i; - TAG_ITER_DECLARECOUNTER; + TAG_ITER_DECLARECOUNTER(0); // search all sectors for ones with tag - TAG_ITER_SECTORS(tag, i) + TAG_ITER_SECTORS(0, tag, i) { if (!force && ticbased // always let speed fader execute && sectors[i].lightingdata diff --git a/src/p_mobj.c b/src/p_mobj.c index 2ae24b402..989f60c98 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -4631,9 +4631,9 @@ static boolean P_Boss4MoveCage(mobj_t *mobj, fixed_t delta) INT32 snum; sector_t *sector; boolean gotcage = false; - TAG_ITER_DECLARECOUNTER; + TAG_ITER_DECLARECOUNTER(0); - TAG_ITER_SECTORS(tag, snum) + TAG_ITER_SECTORS(0, tag, snum) { sector = §ors[snum]; sector->floorheight += delta; @@ -4717,9 +4717,9 @@ static void P_Boss4DestroyCage(mobj_t *mobj) size_t a; sector_t *sector, *rsec; ffloor_t *rover; - TAG_ITER_DECLARECOUNTER; + TAG_ITER_DECLARECOUNTER(0); - TAG_ITER_SECTORS(tag, snum) + TAG_ITER_SECTORS(0, tag, snum) { sector = §ors[snum]; diff --git a/src/p_setup.c b/src/p_setup.c index dd49ae0be..102c9b9a7 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2971,9 +2971,9 @@ static void P_ConvertBinaryMap(void) INT32 check = -1; INT32 paramline = -1; - TAG_ITER_DECLARECOUNTER; + TAG_ITER_DECLARECOUNTER(0); - TAG_ITER_LINES(tag, check) + TAG_ITER_LINES(0, tag, check) { if (lines[check].special == 22) { @@ -3188,11 +3188,11 @@ static void P_ConvertBinaryMap(void) INT32 firstline = -1; mtag_t tag = mapthings[i].angle; - TAG_ITER_DECLARECOUNTER; + TAG_ITER_DECLARECOUNTER(0); Tag_FSet(&mapthings[i].tags, tag); - TAG_ITER_LINES(tag, check) + TAG_ITER_LINES(0, tag, check) { if (lines[check].special == 20) { diff --git a/src/p_slopes.c b/src/p_slopes.c index 80278451a..aa46a8402 100644 --- a/src/p_slopes.c +++ b/src/p_slopes.c @@ -546,11 +546,11 @@ static boolean P_SetSlopeFromTag(sector_t *sec, INT32 tag, boolean ceiling) { INT32 i; pslope_t **secslope = ceiling ? &sec->c_slope : &sec->f_slope; - TAG_ITER_DECLARECOUNTER; + TAG_ITER_DECLARECOUNTER(0); if (!tag || *secslope) return false; - TAG_ITER_SECTORS(tag, i) + TAG_ITER_SECTORS(0, tag, i) { pslope_t *srcslope = ceiling ? sectors[i].c_slope : sectors[i].f_slope; if (srcslope) diff --git a/src/p_spec.c b/src/p_spec.c index c0b9983d1..a1afdd00d 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -2223,7 +2223,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) INT32 secnum = -1; mobj_t *bot = NULL; mtag_t tag = Tag_FGet(&line->tags); - TAG_ITER_DECLARECOUNTER; + TAG_ITER_DECLARECOUNTER(0); I_Assert(!mo || !P_MobjWasRemoved(mo)); // If mo is there, mo must be valid! @@ -2251,7 +2251,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) newceilinglightsec = line->frontsector->ceilinglightsec; // act on all sectors with the same tag as the triggering linedef - TAG_ITER_SECTORS(tag, secnum) + TAG_ITER_SECTORS(0, tag, secnum) { if (sectors[secnum].lightingdata) { @@ -2306,7 +2306,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) case 409: // Change tagged sectors' tag // (formerly "Change calling sectors' tag", but behavior was changed) { - TAG_ITER_SECTORS(tag, secnum) + TAG_ITER_SECTORS(0, tag, secnum) Tag_SectorFSet(secnum,(INT16)(sides[line->sidenum[0]].textureoffset>>FRACBITS)); break; } @@ -2316,7 +2316,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) break; case 411: // Stop floor/ceiling movement in tagged sector(s) - TAG_ITER_SECTORS(tag, secnum) + TAG_ITER_SECTORS(0, tag, secnum) { if (sectors[secnum].floordata) { @@ -2501,7 +2501,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) // Additionally play the sound from tagged sectors' soundorgs sector_t *sec; - TAG_ITER_SECTORS(tag, secnum) + TAG_ITER_SECTORS(0, tag, secnum) { sec = §ors[secnum]; S_StartSound(&sec->soundorg, sfxnum); @@ -2616,7 +2616,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) break; case 416: // Spawn adjustable fire flicker - TAG_ITER_SECTORS(tag, secnum) + TAG_ITER_SECTORS(0, tag, secnum) { if (line->flags & ML_NOCLIMB && line->backsector) { @@ -2650,7 +2650,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) break; case 417: // Spawn adjustable glowing light - TAG_ITER_SECTORS(tag, secnum) + TAG_ITER_SECTORS(0, tag, secnum) { if (line->flags & ML_NOCLIMB && line->backsector) { @@ -2684,7 +2684,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) break; case 418: // Spawn adjustable strobe flash (unsynchronized) - TAG_ITER_SECTORS(tag, secnum) + TAG_ITER_SECTORS(0, tag, secnum) { if (line->flags & ML_NOCLIMB && line->backsector) { @@ -2718,7 +2718,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) break; case 419: // Spawn adjustable strobe flash (synchronized) - TAG_ITER_SECTORS(tag, secnum) + TAG_ITER_SECTORS(0, tag, secnum) { if (line->flags & ML_NOCLIMB && line->backsector) { @@ -2766,7 +2766,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) break; case 421: // Stop lighting effect in tagged sectors - TAG_ITER_SECTORS(tag, secnum) + TAG_ITER_SECTORS(0, tag, secnum) if (sectors[secnum].lightingdata) { P_RemoveThinker(&((elevator_t *)sectors[secnum].lightingdata)->thinker); @@ -2980,7 +2980,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) ffloor_t *rover; // FOF that we are going to crumble boolean foundrover = false; // for debug, "Can't find a FOF" message - TAG_ITER_SECTORS(sectag, secnum) + TAG_ITER_SECTORS(0, sectag, secnum) { sec = sectors + secnum; @@ -3105,7 +3105,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) if (line->sidenum[1] != 0xffff) state = (statenum_t)sides[line->sidenum[1]].toptexture; - TAG_ITER_SECTORS(tag, secnum) + TAG_ITER_SECTORS(0, tag, secnum) { boolean tryagain; sec = sectors + secnum; @@ -3165,7 +3165,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) boolean foundrover = false; // for debug, "Can't find a FOF" message ffloortype_e oldflags; // store FOF's old flags - TAG_ITER_SECTORS(sectag, secnum) + TAG_ITER_SECTORS(0, sectag, secnum) { sec = sectors + secnum; @@ -3223,7 +3223,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) if (line->flags & ML_NOCLIMB) // don't respawn! respawn = false; - TAG_ITER_SECTORS(sectag, secnum) + TAG_ITER_SECTORS(0, sectag, secnum) { sec = sectors + secnum; @@ -3279,7 +3279,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) source = sectors[sourcesec].extra_colormap; } } - TAG_ITER_SECTORS(line->args[0], secnum) + TAG_ITER_SECTORS(0, line->args[0], secnum) { if (sectors[secnum].colormap_protected) continue; @@ -3414,7 +3414,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) ffloor_t *rover; // FOF that we are going to operate boolean foundrover = false; // for debug, "Can't find a FOF" message - TAG_ITER_SECTORS(sectag, secnum) + TAG_ITER_SECTORS(0, sectag, secnum) { sec = sectors + secnum; @@ -3478,7 +3478,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) boolean foundrover = false; // for debug, "Can't find a FOF" message size_t j = 0; // sec->ffloors is saved as ffloor #0, ss->ffloors->next is #1, etc - TAG_ITER_SECTORS(sectag, secnum) + TAG_ITER_SECTORS(0, sectag, secnum) { sec = sectors + secnum; @@ -3563,7 +3563,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) ffloor_t *rover; // FOF that we are going to operate boolean foundrover = false; // for debug, "Can't find a FOF" message - TAG_ITER_SECTORS(sectag, secnum) + TAG_ITER_SECTORS(0, sectag, secnum) { sec = sectors + secnum; @@ -3614,7 +3614,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) } } - TAG_ITER_SECTORS(line->args[0], secnum) + TAG_ITER_SECTORS(0, line->args[0], secnum) { extracolormap_t *source_exc, *dest_exc, *exc; @@ -3694,7 +3694,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) break; } case 456: // Stop fade colormap - TAG_ITER_SECTORS(line->args[0], secnum) + TAG_ITER_SECTORS(0, line->args[0], secnum) P_ResetColormapFader(§ors[secnum]); break; @@ -3887,12 +3887,12 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) case 465: // Set linedef executor delay { INT32 linenum; - TAG_ITER_DECLARECOUNTER; + TAG_ITER_DECLARECOUNTER(1); if (!udmf) break; - TAG_ITER_LINES(line->args[0], linenum) + TAG_ITER_LINES(1, line->args[0], linenum) { if (line->args[2]) lines[linenum].executordelay += line->args[1]; @@ -5922,9 +5922,9 @@ void T_LaserFlash(laserthink_t *flash) sector_t *sector; sector_t *sourcesec = flash->sourceline->frontsector; fixed_t top, bottom; - TAG_ITER_DECLARECOUNTER; + TAG_ITER_DECLARECOUNTER(0); - TAG_ITER_SECTORS(flash->tag, s) + TAG_ITER_SECTORS(0, flash->tag, s) { sector = §ors[s]; for (fflr = sector->ffloors; fflr; fflr = fflr->next) @@ -6204,11 +6204,11 @@ void P_SpawnSpecials(boolean fromnetsave) INT32 s; size_t sec; ffloortype_e ffloorflags; - TAG_ITER_DECLARECOUNTER; + TAG_ITER_DECLARECOUNTER(0); case 1: // Definable gravity per sector sec = sides[*lines[i].sidenum].sector - sectors; - TAG_ITER_SECTORS(tag, s) + TAG_ITER_SECTORS(0, tag, s) { sectors[s].gravity = §ors[sec].floorheight; // This allows it to change in realtime! @@ -6232,7 +6232,7 @@ void P_SpawnSpecials(boolean fromnetsave) case 5: // Change camera info sec = sides[*lines[i].sidenum].sector - sectors; - TAG_ITER_SECTORS(tag, s) + TAG_ITER_SECTORS(0, tag, s) P_AddCameraScanner(§ors[sec], §ors[s], R_PointToAngle2(lines[i].v2->x, lines[i].v2->y, lines[i].v1->x, lines[i].v1->y)); break; @@ -6259,7 +6259,7 @@ void P_SpawnSpecials(boolean fromnetsave) P_ApplyFlatAlignment(lines + i, lines[i].frontsector, flatangle, xoffs, yoffs); else { - TAG_ITER_SECTORS(tag, s) + TAG_ITER_SECTORS(0, tag, s) P_ApplyFlatAlignment(lines + i, sectors + s, flatangle, xoffs, yoffs); } } @@ -6270,7 +6270,7 @@ void P_SpawnSpecials(boolean fromnetsave) break; case 8: // Sector Parameters - TAG_ITER_SECTORS(tag, s) + TAG_ITER_SECTORS(0, tag, s) { if (lines[i].flags & ML_NOCLIMB) { @@ -6297,7 +6297,7 @@ void P_SpawnSpecials(boolean fromnetsave) break; case 10: // Vertical culling plane for sprites and FOFs - TAG_ITER_SECTORS(tag, s) + TAG_ITER_SECTORS(0, tag, s) sectors[s].cullheight = &lines[i]; // This allows it to change in realtime! break; @@ -6358,19 +6358,19 @@ void P_SpawnSpecials(boolean fromnetsave) case 63: // support for drawn heights coming from different sector sec = sides[*lines[i].sidenum].sector-sectors; - TAG_ITER_SECTORS(tag, s) + TAG_ITER_SECTORS(0, tag, s) sectors[s].heightsec = (INT32)sec; break; case 64: // Appearing/Disappearing FOF option if (lines[i].flags & ML_BLOCKMONSTERS) { // Find FOFs by control sector tag - TAG_ITER_SECTORS(tag, s) + TAG_ITER_SECTORS(0, tag, s) for (j = 0; (unsigned)j < sectors[s].linecount; j++) if (sectors[s].lines[j]->special >= 100 && sectors[s].lines[j]->special < 300) Add_MasterDisappearer(abs(lines[i].dx>>FRACBITS), abs(lines[i].dy>>FRACBITS), abs(sides[lines[i].sidenum[0]].sector->floorheight>>FRACBITS), (INT32)(sectors[s].lines[j]-lines), (INT32)i); } else // Find FOFs by effect sector tag { - TAG_ITER_LINES(tag, s) + TAG_ITER_LINES(0, tag, s) { if ((size_t)s == i) continue; @@ -6381,15 +6381,15 @@ void P_SpawnSpecials(boolean fromnetsave) break; case 66: // Displace floor by front sector - TAG_ITER_SECTORS(tag, s) + TAG_ITER_SECTORS(0, tag, s) P_AddPlaneDisplaceThinker(pd_floor, P_AproxDistance(lines[i].dx, lines[i].dy)>>8, sides[lines[i].sidenum[0]].sector-sectors, s, !!(lines[i].flags & ML_NOCLIMB)); break; case 67: // Displace ceiling by front sector - TAG_ITER_SECTORS(tag, s) + TAG_ITER_SECTORS(0, tag, s) P_AddPlaneDisplaceThinker(pd_ceiling, P_AproxDistance(lines[i].dx, lines[i].dy)>>8, sides[lines[i].sidenum[0]].sector-sectors, s, !!(lines[i].flags & ML_NOCLIMB)); break; case 68: // Displace both floor AND ceiling by front sector - TAG_ITER_SECTORS(tag, s) + TAG_ITER_SECTORS(0, tag, s) P_AddPlaneDisplaceThinker(pd_both, P_AproxDistance(lines[i].dx, lines[i].dy)>>8, sides[lines[i].sidenum[0]].sector-sectors, s, !!(lines[i].flags & ML_NOCLIMB)); break; @@ -6985,46 +6985,46 @@ void P_SpawnSpecials(boolean fromnetsave) case 600: // floor lighting independently (e.g. lava) sec = sides[*lines[i].sidenum].sector-sectors; - TAG_ITER_SECTORS(tag, s) + TAG_ITER_SECTORS(0, tag, s) sectors[s].floorlightsec = (INT32)sec; break; case 601: // ceiling lighting independently sec = sides[*lines[i].sidenum].sector-sectors; - TAG_ITER_SECTORS(tag, s) + TAG_ITER_SECTORS(0, tag, s) sectors[s].ceilinglightsec = (INT32)sec; break; case 602: // Adjustable pulsating light sec = sides[*lines[i].sidenum].sector - sectors; - TAG_ITER_SECTORS(tag, s) + TAG_ITER_SECTORS(0, tag, s) P_SpawnAdjustableGlowingLight(§ors[sec], §ors[s], P_AproxDistance(lines[i].dx, lines[i].dy)>>FRACBITS); break; case 603: // Adjustable flickering light sec = sides[*lines[i].sidenum].sector - sectors; - TAG_ITER_SECTORS(tag, s) + TAG_ITER_SECTORS(0, tag, s) P_SpawnAdjustableFireFlicker(§ors[sec], §ors[s], P_AproxDistance(lines[i].dx, lines[i].dy)>>FRACBITS); break; case 604: // Adjustable Blinking Light (unsynchronized) sec = sides[*lines[i].sidenum].sector - sectors; - TAG_ITER_SECTORS(tag, s) + TAG_ITER_SECTORS(0, tag, s) P_SpawnAdjustableStrobeFlash(§ors[sec], §ors[s], abs(lines[i].dx)>>FRACBITS, abs(lines[i].dy)>>FRACBITS, false); break; case 605: // Adjustable Blinking Light (synchronized) sec = sides[*lines[i].sidenum].sector - sectors; - TAG_ITER_SECTORS(tag, s) + TAG_ITER_SECTORS(0, tag, s) P_SpawnAdjustableStrobeFlash(§ors[sec], §ors[s], abs(lines[i].dx)>>FRACBITS, abs(lines[i].dy)>>FRACBITS, true); break; case 606: // HACK! Copy colormaps. Just plain colormaps. - TAG_ITER_SECTORS(lines[i].args[0], s) + TAG_ITER_SECTORS(0, lines[i].args[0], s) { extracolormap_t *exc; @@ -7098,13 +7098,13 @@ void P_SpawnSpecials(boolean fromnetsave) */ static void P_AddFakeFloorsByLine(size_t line, ffloortype_e ffloorflags, thinkerlist_t *secthinkers) { - TAG_ITER_DECLARECOUNTER; + TAG_ITER_DECLARECOUNTER(0); INT32 s; mtag_t tag = Tag_FGet(&lines[line].tags); size_t sec = sides[*lines[line].sidenum].sector-sectors; line_t* li = lines + line; - TAG_ITER_SECTORS(tag, s) + TAG_ITER_SECTORS(0, tag, s) P_AddFakeFloor(§ors[s], §ors[sec], li, ffloorflags, secthinkers); } @@ -7214,7 +7214,7 @@ void T_Scroll(scroll_t *s) size_t i; INT32 sect; ffloor_t *rover; - TAG_ITER_DECLARECOUNTER; + TAG_ITER_DECLARECOUNTER(0); case sc_side: // scroll wall texture side = sides + s->affectee; @@ -7251,7 +7251,7 @@ void T_Scroll(scroll_t *s) if (!is3dblock) continue; - TAG_ITER_SECTORS(Tag_FGet(&line->tags), sect) + TAG_ITER_SECTORS(0, Tag_FGet(&line->tags), sect) { sector_t *psec; psec = sectors + sect; @@ -7326,7 +7326,7 @@ void T_Scroll(scroll_t *s) if (!is3dblock) continue; - TAG_ITER_SECTORS(Tag_FGet(&line->tags), sect) + TAG_ITER_SECTORS(0, Tag_FGet(&line->tags), sect) { sector_t *psec; psec = sectors + sect; @@ -7466,11 +7466,11 @@ static void P_SpawnScrollers(void) switch (special) { register INT32 s; - TAG_ITER_DECLARECOUNTER; + TAG_ITER_DECLARECOUNTER(0); case 513: // scroll effect ceiling case 533: // scroll and carry objects on ceiling - TAG_ITER_SECTORS(tag, s) + TAG_ITER_SECTORS(0, tag, s) Add_Scroller(sc_ceiling, -dx, dy, control, s, accel, l->flags & ML_NOCLIMB); if (special != 533) break; @@ -7479,13 +7479,13 @@ static void P_SpawnScrollers(void) case 523: // carry objects on ceiling dx = FixedMul(dx, CARRYFACTOR); dy = FixedMul(dy, CARRYFACTOR); - TAG_ITER_SECTORS(tag, s) + TAG_ITER_SECTORS(0, tag, s) Add_Scroller(sc_carry_ceiling, dx, dy, control, s, accel, l->flags & ML_NOCLIMB); break; case 510: // scroll effect floor case 530: // scroll and carry objects on floor - TAG_ITER_SECTORS(tag, s) + TAG_ITER_SECTORS(0, tag, s) Add_Scroller(sc_floor, -dx, dy, control, s, accel, l->flags & ML_NOCLIMB); if (special != 530) break; @@ -7494,7 +7494,7 @@ static void P_SpawnScrollers(void) case 520: // carry objects on floor dx = FixedMul(dx, CARRYFACTOR); dy = FixedMul(dy, CARRYFACTOR); - TAG_ITER_SECTORS(tag, s) + TAG_ITER_SECTORS(0, tag, s) Add_Scroller(sc_carry, dx, dy, control, s, accel, l->flags & ML_NOCLIMB); break; @@ -7502,7 +7502,7 @@ static void P_SpawnScrollers(void) // (same direction and speed as scrolling floors) case 502: { - TAG_ITER_LINES(tag, s) + TAG_ITER_LINES(0, tag, s) if (s != (INT32)i) { if (l->flags & ML_EFFECT2) // use texture offsets instead @@ -7604,9 +7604,9 @@ void T_Disappear(disappear_t *d) ffloor_t *rover; register INT32 s; mtag_t afftag = Tag_FGet(&lines[d->affectee].tags); - TAG_ITER_DECLARECOUNTER; + TAG_ITER_DECLARECOUNTER(0); - TAG_ITER_SECTORS(afftag, s) + TAG_ITER_SECTORS(0, afftag, s) { for (rover = sectors[s].ffloors; rover; rover = rover->next) { @@ -8337,7 +8337,7 @@ static void P_SpawnFriction(void) fixed_t strength; // frontside texture offset controls magnitude fixed_t friction; // friction value to be applied during movement INT32 movefactor; // applied to each player move to simulate inertia - TAG_ITER_DECLARECOUNTER; + TAG_ITER_DECLARECOUNTER(0); for (i = 0; i < numlines; i++, l++) if (l->special == 540) @@ -8363,7 +8363,7 @@ static void P_SpawnFriction(void) else movefactor = FRACUNIT; - TAG_ITER_SECTORS(tag, s) + TAG_ITER_SECTORS(0, tag, s) Add_Friction(friction, movefactor, s, -1); } } @@ -8882,7 +8882,7 @@ static void P_SpawnPushers(void) mtag_t tag; register INT32 s; mobj_t *thing; - TAG_ITER_DECLARECOUNTER; + TAG_ITER_DECLARECOUNTER(0); for (i = 0; i < numlines; i++, l++) { @@ -8890,15 +8890,15 @@ static void P_SpawnPushers(void) switch (l->special) { case 541: // wind - TAG_ITER_SECTORS(tag, s) + TAG_ITER_SECTORS(0, tag, s) Add_Pusher(p_wind, l->dx, l->dy, NULL, s, -1, l->flags & ML_NOCLIMB, l->flags & ML_EFFECT4); break; case 544: // current - TAG_ITER_SECTORS(tag, s) + TAG_ITER_SECTORS(0, tag, s) Add_Pusher(p_current, l->dx, l->dy, NULL, s, -1, l->flags & ML_NOCLIMB, l->flags & ML_EFFECT4); break; case 547: // push/pull - TAG_ITER_SECTORS(tag, s) + TAG_ITER_SECTORS(0, tag, s) { thing = P_GetPushThing(s); if (thing) // No MT_P* means no effect @@ -8906,19 +8906,19 @@ static void P_SpawnPushers(void) } break; case 545: // current up - TAG_ITER_SECTORS(tag, s) + TAG_ITER_SECTORS(0, tag, s) Add_Pusher(p_upcurrent, l->dx, l->dy, NULL, s, -1, l->flags & ML_NOCLIMB, l->flags & ML_EFFECT4); break; case 546: // current down - TAG_ITER_SECTORS(tag, s) + TAG_ITER_SECTORS(0, tag, s) Add_Pusher(p_downcurrent, l->dx, l->dy, NULL, s, -1, l->flags & ML_NOCLIMB, l->flags & ML_EFFECT4); break; case 542: // wind up - TAG_ITER_SECTORS(tag, s) + TAG_ITER_SECTORS(0, tag, s) Add_Pusher(p_upwind, l->dx, l->dy, NULL, s, -1, l->flags & ML_NOCLIMB, l->flags & ML_EFFECT4); break; case 543: // wind down - TAG_ITER_SECTORS(tag, s) + TAG_ITER_SECTORS(0, tag, s) Add_Pusher(p_downwind, l->dx, l->dy, NULL, s, -1, l->flags & ML_NOCLIMB, l->flags & ML_EFFECT4); break; } diff --git a/src/taglist.h b/src/taglist.h index f3895eabb..3a724aef3 100644 --- a/src/taglist.h +++ b/src/taglist.h @@ -62,13 +62,13 @@ INT32 Tag_FindLineSpecial(const INT16 special, const mtag_t tag); INT32 P_FindSpecialLineFromTag(INT16 special, INT16 tag, INT32 start); // Use this macro to declare the iterator position variable. -#define TAG_ITER_DECLARECOUNTER size_t tag_iterator_pos +#define TAG_ITER_DECLARECOUNTER(level) size_t ICNT_##level -#define TAG_ITER(fn, tag, id) for(tag_iterator_pos = 0; (id = fn(tag, tag_iterator_pos)) >= 0; tag_iterator_pos++) +#define TAG_ITER(level, fn, tag, id) for(ICNT_##level = 0; (id = fn(tag, ICNT_##level)) >= 0; ICNT_##level++) // Use these macros as wrappers for the taglist iterations. -#define TAG_ITER_SECTORS(tag, id) TAG_ITER(Tag_Iterate_Sectors, tag, id) -#define TAG_ITER_LINES(tag, id) TAG_ITER(Tag_Iterate_Lines, tag, id) -#define TAG_ITER_THINGS(tag, id) TAG_ITER(Tag_Iterate_Things, tag, id) +#define TAG_ITER_SECTORS(level, tag, id) TAG_ITER(level, Tag_Iterate_Sectors, tag, id) +#define TAG_ITER_LINES(level, tag, id) TAG_ITER(level, Tag_Iterate_Lines, tag, id) +#define TAG_ITER_THINGS(level, tag, id) TAG_ITER(level, Tag_Iterate_Things, tag, id) #endif //__R_TAGLIST__ From 072e1889e2959d79c316b48126a4ea4b06f12f45 Mon Sep 17 00:00:00 2001 From: Nev3r Date: Thu, 12 Nov 2020 13:59:21 +0100 Subject: [PATCH 0318/1080] Fix size_t/INT32 compare. --- src/taglist.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/taglist.c b/src/taglist.c index a9879e495..e0bb86c97 100644 --- a/src/taglist.c +++ b/src/taglist.c @@ -276,7 +276,7 @@ INT32 Tag_Iterate_Things (const mtag_t tag, const size_t p) INT32 Tag_FindLineSpecial(const INT16 special, const mtag_t tag) { - INT32 i; + size_t i; if (tag == MTAG_GLOBAL) { From 365255990d7454dac7d345bdc719a9c64573c0f3 Mon Sep 17 00:00:00 2001 From: Louis-Antoine Date: Thu, 12 Nov 2020 21:25:31 +0100 Subject: [PATCH 0319/1080] Add shorthand aliases for fixed-point functions --- src/lua_mathlib.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/lua_mathlib.c b/src/lua_mathlib.c index 7cbe7a6cc..10ba42ee0 100644 --- a/src/lua_mathlib.c +++ b/src/lua_mathlib.c @@ -192,18 +192,30 @@ static luaL_Reg lib[] = { {"cos", lib_finecosine}, {"tan", lib_finetangent}, {"FixedAngle", lib_fixedangle}, + {"fixangle" , lib_fixedangle}, {"AngleFixed", lib_anglefixed}, + {"anglefix" , lib_anglefixed}, {"InvAngle", lib_invangle}, {"FixedMul", lib_fixedmul}, + {"fixmul" , lib_fixedmul}, {"FixedInt", lib_fixedint}, + {"fixint" , lib_fixedint}, {"FixedDiv", lib_fixeddiv}, + {"fixdiv" , lib_fixeddiv}, {"FixedRem", lib_fixedrem}, + {"fixrem" , lib_fixedrem}, {"FixedSqrt", lib_fixedsqrt}, + {"fixsqrt" , lib_fixedsqrt}, {"FixedHypot", lib_fixedhypot}, + {"fixhypot" , lib_fixedhypot}, {"FixedFloor", lib_fixedfloor}, + {"fixfloor" , lib_fixedfloor}, {"FixedTrunc", lib_fixedtrunc}, + {"fixtrunc" , lib_fixedtrunc}, {"FixedCeil", lib_fixedceil}, + {"fixceil" , lib_fixedceil}, {"FixedRound", lib_fixedround}, + {"fixround" , lib_fixedround}, {"GetSecSpecial", lib_getsecspecial}, {"All7Emeralds", lib_all7emeralds}, {"ColorOpposite", lib_coloropposite}, From 3d1677bade6b46e2973b3df9e90cb962994d09f7 Mon Sep 17 00:00:00 2001 From: Louis-Antoine Date: Thu, 12 Nov 2020 21:33:47 +0100 Subject: [PATCH 0320/1080] Add a shorthand alias for FRACUNIT --- src/dehacked.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/dehacked.c b/src/dehacked.c index 0380cc30e..86c09d03a 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -9511,6 +9511,7 @@ struct { // fixed_t constants, from m_fixed.h {"FRACUNIT",FRACUNIT}, + {"FU" ,FRACUNIT}, {"FRACBITS",FRACBITS}, // doomdef.h constants From e3c84156279772b5dbae4c049b4274b9134eaabf Mon Sep 17 00:00:00 2001 From: James R Date: Fri, 13 Nov 2020 00:46:03 -0800 Subject: [PATCH 0321/1080] OpenGL: don't access field that doesn't exist in precipmobj_t --- src/hardware/hw_main.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 2169ba889..bd977ed15 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -4204,12 +4204,7 @@ static inline void HWR_DrawPrecipitationSprite(gl_vissprite_t *spr) HWR_Lighting(&Surf, lightlevel, colormap); } - if (spr->mobj->flags2 & MF2_SHADOW) - { - Surf.PolyColor.s.alpha = 0x40; - blend = PF_Translucent; - } - else if (spr->mobj->frame & FF_TRANSMASK) + if (spr->mobj->frame & FF_TRANSMASK) blend = HWR_TranstableToAlpha((spr->mobj->frame & FF_TRANSMASK)>>FF_TRANSSHIFT, &Surf); else { From 04826d261528487a05a31bf06d60e6c415fd193b Mon Sep 17 00:00:00 2001 From: Louis-Antoine Date: Fri, 13 Nov 2020 15:31:11 +0100 Subject: [PATCH 0322/1080] Replace lua_pop(-1) with lua_settop(0) --- src/lua_hudlib.c | 20 ++++++++++---------- src/lua_script.c | 4 ++-- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/lua_hudlib.c b/src/lua_hudlib.c index 6b87dc930..5db5169d5 100644 --- a/src/lua_hudlib.c +++ b/src/lua_hudlib.c @@ -1343,7 +1343,7 @@ void LUAh_GameHUD(player_t *stplayr) return; hud_running = true; - lua_pop(gL, -1); + lua_settop(gL, 0); lua_getfield(gL, LUA_REGISTRYINDEX, "HUD"); I_Assert(lua_istable(gL, -1)); @@ -1367,7 +1367,7 @@ void LUAh_GameHUD(player_t *stplayr) lua_pushvalue(gL, -5); // camera LUA_Call(gL, 3); } - lua_pop(gL, -1); + lua_settop(gL, 0); hud_running = false; } @@ -1377,7 +1377,7 @@ void LUAh_ScoresHUD(void) return; hud_running = true; - lua_pop(gL, -1); + lua_settop(gL, 0); lua_getfield(gL, LUA_REGISTRYINDEX, "HUD"); I_Assert(lua_istable(gL, -1)); @@ -1392,7 +1392,7 @@ void LUAh_ScoresHUD(void) lua_pushvalue(gL, -3); // graphics library (HUD[1]) LUA_Call(gL, 1); } - lua_pop(gL, -1); + lua_settop(gL, 0); hud_running = false; } @@ -1402,7 +1402,7 @@ void LUAh_TitleHUD(void) return; hud_running = true; - lua_pop(gL, -1); + lua_settop(gL, 0); lua_getfield(gL, LUA_REGISTRYINDEX, "HUD"); I_Assert(lua_istable(gL, -1)); @@ -1417,7 +1417,7 @@ void LUAh_TitleHUD(void) lua_pushvalue(gL, -3); // graphics library (HUD[1]) LUA_Call(gL, 1); } - lua_pop(gL, -1); + lua_settop(gL, 0); hud_running = false; } @@ -1427,7 +1427,7 @@ void LUAh_TitleCardHUD(player_t *stplayr) return; hud_running = true; - lua_pop(gL, -1); + lua_settop(gL, 0); lua_getfield(gL, LUA_REGISTRYINDEX, "HUD"); I_Assert(lua_istable(gL, -1)); @@ -1451,7 +1451,7 @@ void LUAh_TitleCardHUD(player_t *stplayr) LUA_Call(gL, 4); } - lua_pop(gL, -1); + lua_settop(gL, 0); hud_running = false; } @@ -1461,7 +1461,7 @@ void LUAh_IntermissionHUD(void) return; hud_running = true; - lua_pop(gL, -1); + lua_settop(gL, 0); lua_getfield(gL, LUA_REGISTRYINDEX, "HUD"); I_Assert(lua_istable(gL, -1)); @@ -1476,6 +1476,6 @@ void LUAh_IntermissionHUD(void) lua_pushvalue(gL, -3); // graphics library (HUD[1]) LUA_Call(gL, 1); } - lua_pop(gL, -1); + lua_settop(gL, 0); hud_running = false; } diff --git a/src/lua_script.c b/src/lua_script.c index bb022f9ce..59e2fe7be 100644 --- a/src/lua_script.c +++ b/src/lua_script.c @@ -437,7 +437,7 @@ static void LUA_ClearState(void) // open base libraries luaL_openlibs(L); - lua_pop(L, -1); + lua_settop(L, 0); // make LREG_VALID table for all pushed userdata cache. lua_newtable(L); @@ -640,7 +640,7 @@ fixed_t LUA_EvalMath(const char *word) *b = '\0'; // eval string. - lua_pop(L, -1); + lua_settop(L, 0); if (luaL_dostring(L, buf)) { p = lua_tostring(L, -1); From de709345524134d150d546ecc70e6ceffe89e474 Mon Sep 17 00:00:00 2001 From: Louis-Antoine Date: Fri, 13 Nov 2020 18:19:13 +0100 Subject: [PATCH 0323/1080] Add missing lua_pop call --- src/lua_infolib.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/lua_infolib.c b/src/lua_infolib.c index 5e5a1dbc4..f36cb825b 100644 --- a/src/lua_infolib.c +++ b/src/lua_infolib.c @@ -843,6 +843,7 @@ boolean LUA_CallAction(const char *csaction, mobj_t *actor) if (superstack == MAXRECURSION) { CONS_Alert(CONS_WARNING, "Max Lua Action recursion reached! Cool it on the calling A_Action functions from inside A_Action functions!\n"); + lua_pop(gL, 1); // pop function return true; } From 01124f207616a6ed22e728fa6083723a1f28052b Mon Sep 17 00:00:00 2001 From: Louis-Antoine Date: Fri, 13 Nov 2020 18:35:22 +0100 Subject: [PATCH 0324/1080] Fix Lua stacktrace not showing in various situations --- src/blua/liolib.c | 6 +++++- src/lua_consolelib.c | 17 ++++++++++++++--- src/lua_hudlib.c | 20 +++++++++++++++----- src/lua_infolib.c | 14 ++++++++++---- src/lua_script.c | 13 +++++++++++++ src/lua_script.h | 9 +-------- 6 files changed, 58 insertions(+), 21 deletions(-) diff --git a/src/blua/liolib.c b/src/blua/liolib.c index a055aad3f..5eec97fb4 100644 --- a/src/blua/liolib.c +++ b/src/blua/liolib.c @@ -277,6 +277,9 @@ void Got_LuaFile(UINT8 **cp, INT32 playernum) if (!luafiletransfers) I_Error("No Lua file transfer\n"); + lua_settop(gL, 0); // Just in case... + lua_pushcfunction(gL, LUA_GetErrorMessage); + // Retrieve the callback and push it on the stack lua_pushfstring(gL, FMT_FILECALLBACKID, luafiletransfers->id); lua_gettable(gL, LUA_REGISTRYINDEX); @@ -304,7 +307,8 @@ void Got_LuaFile(UINT8 **cp, INT32 playernum) lua_pushstring(gL, luafiletransfers->filename); // Call the callback - LUA_Call(gL, 2); + LUA_Call(gL, 2, 0, 1); + lua_settop(gL, 0); if (success) { diff --git a/src/lua_consolelib.c b/src/lua_consolelib.c index c6b082930..7373401e5 100644 --- a/src/lua_consolelib.c +++ b/src/lua_consolelib.c @@ -40,6 +40,10 @@ void Got_Luacmd(UINT8 **cp, INT32 playernum) // like sending random junk lua commands to crash the server if (!gL) goto deny; + + lua_settop(gL, 0); // Just in case... + lua_pushcfunction(gL, LUA_GetErrorMessage); + lua_getfield(gL, LUA_REGISTRYINDEX, "COM_Command"); // push COM_Command if (!lua_istable(gL, -1)) goto deny; @@ -76,7 +80,7 @@ void Got_Luacmd(UINT8 **cp, INT32 playernum) READSTRINGN(*cp, buf, 255); lua_pushstring(gL, buf); } - LUA_Call(gL, (int)argc); // argc is 1-based, so this will cover the player we passed too. + LUA_Call(gL, (int)argc, 0, 1); // argc is 1-based, so this will cover the player we passed too. return; deny: @@ -98,6 +102,10 @@ void COM_Lua_f(void) INT32 playernum = consoleplayer; I_Assert(gL != NULL); + + lua_settop(gL, 0); // Just in case... + lua_pushcfunction(gL, LUA_GetErrorMessage); + lua_getfield(gL, LUA_REGISTRYINDEX, "COM_Command"); // push COM_Command I_Assert(lua_istable(gL, -1)); @@ -167,7 +175,7 @@ void COM_Lua_f(void) LUA_PushUserdata(gL, &players[playernum], META_PLAYER); for (i = 1; i < COM_Argc(); i++) lua_pushstring(gL, COM_Argv(i)); - LUA_Call(gL, (int)COM_Argc()); // COM_Argc is 1-based, so this will cover the player we passed too. + LUA_Call(gL, (int)COM_Argc(), 0, 1); // COM_Argc is 1-based, so this will cover the player we passed too. } // Wrapper for COM_AddCommand @@ -277,6 +285,9 @@ static void Lua_OnChange(void) /// \todo Network this! XD_LUAVAR + lua_settop(gL, 0); // Just in case... + lua_pushcfunction(gL, LUA_GetErrorMessage); + // From CV_OnChange registry field, get the function for this cvar by name. lua_getfield(gL, LUA_REGISTRYINDEX, "CV_OnChange"); I_Assert(lua_istable(gL, -1)); @@ -288,7 +299,7 @@ static void Lua_OnChange(void) lua_getfield(gL, -1, cvname); // get consvar_t* userdata. lua_remove(gL, -2); // pop the CV_Vars table. - LUA_Call(gL, 1); // call function(cvar) + LUA_Call(gL, 1, 0, 1); // call function(cvar) lua_pop(gL, 1); // pop CV_OnChange table } diff --git a/src/lua_hudlib.c b/src/lua_hudlib.c index 5db5169d5..b079cfe1b 100644 --- a/src/lua_hudlib.c +++ b/src/lua_hudlib.c @@ -1345,6 +1345,8 @@ void LUAh_GameHUD(player_t *stplayr) hud_running = true; lua_settop(gL, 0); + lua_pushcfunction(gL, LUA_GetErrorMessage); + lua_getfield(gL, LUA_REGISTRYINDEX, "HUD"); I_Assert(lua_istable(gL, -1)); lua_rawgeti(gL, -1, 2+hudhook_game); // HUD[2] = rendering funcs @@ -1365,7 +1367,7 @@ void LUAh_GameHUD(player_t *stplayr) lua_pushvalue(gL, -5); // graphics library (HUD[1]) lua_pushvalue(gL, -5); // stplayr lua_pushvalue(gL, -5); // camera - LUA_Call(gL, 3); + LUA_Call(gL, 3, 0, 1); } lua_settop(gL, 0); hud_running = false; @@ -1379,6 +1381,8 @@ void LUAh_ScoresHUD(void) hud_running = true; lua_settop(gL, 0); + lua_pushcfunction(gL, LUA_GetErrorMessage); + lua_getfield(gL, LUA_REGISTRYINDEX, "HUD"); I_Assert(lua_istable(gL, -1)); lua_rawgeti(gL, -1, 2+hudhook_scores); // HUD[3] = rendering funcs @@ -1390,7 +1394,7 @@ void LUAh_ScoresHUD(void) lua_pushnil(gL); while (lua_next(gL, -3) != 0) { lua_pushvalue(gL, -3); // graphics library (HUD[1]) - LUA_Call(gL, 1); + LUA_Call(gL, 1, 0, 1); } lua_settop(gL, 0); hud_running = false; @@ -1404,6 +1408,8 @@ void LUAh_TitleHUD(void) hud_running = true; lua_settop(gL, 0); + lua_pushcfunction(gL, LUA_GetErrorMessage); + lua_getfield(gL, LUA_REGISTRYINDEX, "HUD"); I_Assert(lua_istable(gL, -1)); lua_rawgeti(gL, -1, 2+hudhook_title); // HUD[5] = rendering funcs @@ -1415,7 +1421,7 @@ void LUAh_TitleHUD(void) lua_pushnil(gL); while (lua_next(gL, -3) != 0) { lua_pushvalue(gL, -3); // graphics library (HUD[1]) - LUA_Call(gL, 1); + LUA_Call(gL, 1, 0, 1); } lua_settop(gL, 0); hud_running = false; @@ -1429,6 +1435,8 @@ void LUAh_TitleCardHUD(player_t *stplayr) hud_running = true; lua_settop(gL, 0); + lua_pushcfunction(gL, LUA_GetErrorMessage); + lua_getfield(gL, LUA_REGISTRYINDEX, "HUD"); I_Assert(lua_istable(gL, -1)); lua_rawgeti(gL, -1, 2+hudhook_titlecard); // HUD[6] = rendering funcs @@ -1448,7 +1456,7 @@ void LUAh_TitleCardHUD(player_t *stplayr) lua_pushvalue(gL, -6); // stplayr lua_pushvalue(gL, -6); // lt_ticker lua_pushvalue(gL, -6); // lt_endtime - LUA_Call(gL, 4); + LUA_Call(gL, 4, 0, 1); } lua_settop(gL, 0); @@ -1463,6 +1471,8 @@ void LUAh_IntermissionHUD(void) hud_running = true; lua_settop(gL, 0); + lua_pushcfunction(gL, LUA_GetErrorMessage); + lua_getfield(gL, LUA_REGISTRYINDEX, "HUD"); I_Assert(lua_istable(gL, -1)); lua_rawgeti(gL, -1, 2+hudhook_intermission); // HUD[4] = rendering funcs @@ -1474,7 +1484,7 @@ void LUAh_IntermissionHUD(void) lua_pushnil(gL); while (lua_next(gL, -3) != 0) { lua_pushvalue(gL, -3); // graphics library (HUD[1]) - LUA_Call(gL, 1); + LUA_Call(gL, 1, 0, 1); } lua_settop(gL, 0); hud_running = false; diff --git a/src/lua_infolib.c b/src/lua_infolib.c index f36cb825b..566aaa6a0 100644 --- a/src/lua_infolib.c +++ b/src/lua_infolib.c @@ -630,6 +630,9 @@ static void A_Lua(mobj_t *actor) boolean found = false; I_Assert(actor != NULL); + lua_settop(gL, 0); // Just in case... + lua_pushcfunction(gL, LUA_GetErrorMessage); + // get the action for this state lua_getfield(gL, LUA_REGISTRYINDEX, LREG_STATEACTION); I_Assert(lua_istable(gL, -1)); @@ -658,7 +661,7 @@ static void A_Lua(mobj_t *actor) LUA_PushUserdata(gL, actor, META_MOBJ); lua_pushinteger(gL, var1); lua_pushinteger(gL, var2); - LUA_Call(gL, 3); + LUA_Call(gL, 3, 0, 1); if (found) { @@ -824,6 +827,8 @@ boolean LUA_CallAction(const char *csaction, mobj_t *actor) if (superstack && fasticmp(csaction, superactions[superstack-1])) // the action is calling itself, return false; // let it call the hardcoded function instead. + lua_pushcfunction(gL, LUA_GetErrorMessage); + // grab function by uppercase name. lua_getfield(gL, LUA_REGISTRYINDEX, LREG_ACTIONS); { @@ -836,14 +841,14 @@ boolean LUA_CallAction(const char *csaction, mobj_t *actor) if (lua_isnil(gL, -1)) // no match { - lua_pop(gL, 1); // pop nil + lua_pop(gL, 2); // pop nil and error handler return false; // action not called. } if (superstack == MAXRECURSION) { CONS_Alert(CONS_WARNING, "Max Lua Action recursion reached! Cool it on the calling A_Action functions from inside A_Action functions!\n"); - lua_pop(gL, 1); // pop function + lua_pop(gL, 2); // pop function and error handler return true; } @@ -857,7 +862,8 @@ boolean LUA_CallAction(const char *csaction, mobj_t *actor) superactions[superstack] = csaction; ++superstack; - LUA_Call(gL, 3); + LUA_Call(gL, 3, 0, -(2 + 3)); + lua_pop(gL, -1); // Error handler --superstack; superactions[superstack] = NULL; diff --git a/src/lua_script.c b/src/lua_script.c index 59e2fe7be..be6bf602f 100644 --- a/src/lua_script.c +++ b/src/lua_script.c @@ -133,6 +133,19 @@ int LUA_GetErrorMessage(lua_State *L) return 1; } +int LUA_Call(lua_State *L, int nargs, int nresults, int errorhandlerindex) +{ + int err = lua_pcall(L, nargs, nresults, errorhandlerindex); + + if (err) + { + CONS_Alert(CONS_WARNING, "%s\n", lua_tostring(L, -1)); + lua_pop(L, 1); + } + + return err; +} + // Moved here from lib_getenum. int LUA_PushGlobals(lua_State *L, const char *word) { diff --git a/src/lua_script.h b/src/lua_script.h index 5a3520d11..79ba0bb38 100644 --- a/src/lua_script.h +++ b/src/lua_script.h @@ -40,6 +40,7 @@ void LUA_ClearExtVars(void); extern INT32 lua_lumploading; // is LUA_LoadLump being called? int LUA_GetErrorMessage(lua_State *L); +int LUA_Call(lua_State *L, int nargs, int nresults, int errorhandlerindex); void LUA_LoadLump(UINT16 wad, UINT16 lump, boolean noresults); #ifdef LUA_ALLOW_BYTECODE void LUA_DumpFile(const char *filename); @@ -65,14 +66,6 @@ void LUAh_NetArchiveHook(lua_CFunction archFunc); // Console wrapper void COM_Lua_f(void); -#define LUA_Call(L,a)\ -{\ - if (lua_pcall(L, a, 0, 0)) {\ - CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(L,-1));\ - lua_pop(L, 1);\ - }\ -} - #define LUA_ErrInvalid(L, type) luaL_error(L, "accessed " type " doesn't exist anymore, please check 'valid' before using " type "."); // Deprecation warnings From a38a6a9dc0463ba255e2d014e2e81a1fb8cfa137 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Fri, 13 Nov 2020 20:49:18 +0000 Subject: [PATCH 0325/1080] Split off actual skin-setting code from SetPlayerSkinByNum so that both SetPlayerSkin and SetPlayerSkinByNum can call it, rather than to each other --- src/r_skins.c | 160 ++++++++++++++++++++++++++------------------------ 1 file changed, 84 insertions(+), 76 deletions(-) diff --git a/src/r_skins.c b/src/r_skins.c index 25904e95e..dab282d26 100644 --- a/src/r_skins.c +++ b/src/r_skins.c @@ -216,6 +216,85 @@ INT32 R_SkinAvailable(const char *name) return -1; } +// Auxillary function that actually sets the skin +static void SetSkin(player_t *player, INT32 skinnum) +{ + skin_t *skin = &skins[skinnum]; + UINT16 newcolor = 0; + + player->skin = skinnum; + + player->camerascale = skin->camerascale; + player->shieldscale = skin->shieldscale; + + player->charability = (UINT8)skin->ability; + player->charability2 = (UINT8)skin->ability2; + + player->charflags = (UINT32)skin->flags; + + player->thokitem = skin->thokitem < 0 ? (UINT32)mobjinfo[MT_PLAYER].painchance : (UINT32)skin->thokitem; + player->spinitem = skin->spinitem < 0 ? (UINT32)mobjinfo[MT_PLAYER].damage : (UINT32)skin->spinitem; + player->revitem = skin->revitem < 0 ? (mobjtype_t)mobjinfo[MT_PLAYER].raisestate : (UINT32)skin->revitem; + player->followitem = skin->followitem; + + if (((player->powers[pw_shield] & SH_NOSTACK) == SH_PINK) && (player->revitem == MT_LHRT || player->spinitem == MT_LHRT || player->thokitem == MT_LHRT)) // Healers can't keep their buff. + player->powers[pw_shield] &= SH_STACK; + + player->actionspd = skin->actionspd; + player->mindash = skin->mindash; + player->maxdash = skin->maxdash; + + player->normalspeed = skin->normalspeed; + player->runspeed = skin->runspeed; + player->thrustfactor = skin->thrustfactor; + player->accelstart = skin->accelstart; + player->acceleration = skin->acceleration; + + player->jumpfactor = skin->jumpfactor; + + player->height = skin->height; + player->spinheight = skin->spinheight; + + if (!(cv_debug || devparm) && !(netgame || multiplayer || demoplayback)) + { + if (player == &players[consoleplayer]) + CV_StealthSetValue(&cv_playercolor, skin->prefcolor); + else if (player == &players[secondarydisplayplayer]) + CV_StealthSetValue(&cv_playercolor2, skin->prefcolor); + player->skincolor = newcolor = skin->prefcolor; + if (player->bot && botingame) + { + botskin = (UINT8)(skinnum + 1); + botcolor = skin->prefcolor; + } + } + + if (player->followmobj) + { + P_RemoveMobj(player->followmobj); + P_SetTarget(&player->followmobj, NULL); + } + + if (player->mo) + { + fixed_t radius = FixedMul(skin->radius, player->mo->scale); + if ((player->powers[pw_carry] == CR_NIGHTSMODE) && (skin->sprites[SPR2_NFLY].numframes == 0)) // If you don't have a sprite for flying horizontally, use the default NiGHTS skin. + { + skin = &skins[DEFAULTNIGHTSSKIN]; + player->followitem = skin->followitem; + if (!(cv_debug || devparm) && !(netgame || multiplayer || demoplayback)) + newcolor = skin->prefcolor; // will be updated in thinker to flashing + } + player->mo->skin = skin; + if (newcolor) + player->mo->color = newcolor; + P_SetScale(player->mo, player->mo->scale); + player->mo->radius = radius; + + P_SetPlayerMobjState(player->mo, player->mo->state-states); // Prevent visual errors when switching between skins with differing number of frames + } +} + // network code calls this when a 'skin change' is received void SetPlayerSkin(INT32 playernum, const char *skinname) { @@ -224,7 +303,7 @@ void SetPlayerSkin(INT32 playernum, const char *skinname) if ((i != -1) && R_SkinUsable(playernum, i)) { - SetPlayerSkinByNum(playernum, i); + SetSkin(playernum, i); return; } @@ -233,7 +312,7 @@ void SetPlayerSkin(INT32 playernum, const char *skinname) else if(server || IsPlayerAdmin(consoleplayer)) CONS_Alert(CONS_WARNING, M_GetText("Player %d (%s) skin '%s' not found\n"), playernum, player_names[playernum], skinname); - SetPlayerSkinByNum(playernum, 0); + SetSkin(player, 0); } // Same as SetPlayerSkin, but uses the skin #. @@ -241,82 +320,10 @@ void SetPlayerSkin(INT32 playernum, const char *skinname) void SetPlayerSkinByNum(INT32 playernum, INT32 skinnum) { player_t *player = &players[playernum]; - skin_t *skin = &skins[skinnum]; - UINT16 newcolor = 0; if (skinnum >= 0 && skinnum < numskins && R_SkinUsable(playernum, skinnum)) // Make sure it exists! { - player->skin = skinnum; - - player->camerascale = skin->camerascale; - player->shieldscale = skin->shieldscale; - - player->charability = (UINT8)skin->ability; - player->charability2 = (UINT8)skin->ability2; - - player->charflags = (UINT32)skin->flags; - - player->thokitem = skin->thokitem < 0 ? (UINT32)mobjinfo[MT_PLAYER].painchance : (UINT32)skin->thokitem; - player->spinitem = skin->spinitem < 0 ? (UINT32)mobjinfo[MT_PLAYER].damage : (UINT32)skin->spinitem; - player->revitem = skin->revitem < 0 ? (mobjtype_t)mobjinfo[MT_PLAYER].raisestate : (UINT32)skin->revitem; - player->followitem = skin->followitem; - - if (((player->powers[pw_shield] & SH_NOSTACK) == SH_PINK) && (player->revitem == MT_LHRT || player->spinitem == MT_LHRT || player->thokitem == MT_LHRT)) // Healers can't keep their buff. - player->powers[pw_shield] &= SH_STACK; - - player->actionspd = skin->actionspd; - player->mindash = skin->mindash; - player->maxdash = skin->maxdash; - - player->normalspeed = skin->normalspeed; - player->runspeed = skin->runspeed; - player->thrustfactor = skin->thrustfactor; - player->accelstart = skin->accelstart; - player->acceleration = skin->acceleration; - - player->jumpfactor = skin->jumpfactor; - - player->height = skin->height; - player->spinheight = skin->spinheight; - - if (!(cv_debug || devparm) && !(netgame || multiplayer || demoplayback)) - { - if (playernum == consoleplayer) - CV_StealthSetValue(&cv_playercolor, skin->prefcolor); - else if (playernum == secondarydisplayplayer) - CV_StealthSetValue(&cv_playercolor2, skin->prefcolor); - player->skincolor = newcolor = skin->prefcolor; - if (player->bot && botingame) - { - botskin = (UINT8)(skinnum + 1); - botcolor = skin->prefcolor; - } - } - - if (player->followmobj) - { - P_RemoveMobj(player->followmobj); - P_SetTarget(&player->followmobj, NULL); - } - - if (player->mo) - { - fixed_t radius = FixedMul(skin->radius, player->mo->scale); - if ((player->powers[pw_carry] == CR_NIGHTSMODE) && (skin->sprites[SPR2_NFLY].numframes == 0)) // If you don't have a sprite for flying horizontally, use the default NiGHTS skin. - { - skin = &skins[DEFAULTNIGHTSSKIN]; - player->followitem = skin->followitem; - if (!(cv_debug || devparm) && !(netgame || multiplayer || demoplayback)) - newcolor = skin->prefcolor; // will be updated in thinker to flashing - } - player->mo->skin = skin; - if (newcolor) - player->mo->color = newcolor; - P_SetScale(player->mo, player->mo->scale); - player->mo->radius = radius; - - P_SetPlayerMobjState(player->mo, player->mo->state-states); // Prevent visual errors when switching between skins with differing number of frames - } + SetSkin(player, skinnum); return; } @@ -324,7 +331,8 @@ void SetPlayerSkinByNum(INT32 playernum, INT32 skinnum) CONS_Alert(CONS_WARNING, M_GetText("Requested skin %d not found\n"), skinnum); else if(server || IsPlayerAdmin(consoleplayer)) CONS_Alert(CONS_WARNING, "Player %d (%s) skin %d not found\n", playernum, player_names[playernum], skinnum); - SetPlayerSkinByNum(playernum, 0); // not found put the sonic skin + + SetSkin(player, 0); // not found put the sonic skin } // From 8f570eaa97f948bf60794bc1dc80b9c04667d936 Mon Sep 17 00:00:00 2001 From: lachwright Date: Sun, 15 Nov 2020 01:13:41 +1100 Subject: [PATCH 0326/1080] Use SDL version of executable icon at runtime on macOS --- src/sdl/i_video.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index c8f67da77..413ba0b4e 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -42,7 +42,7 @@ #ifdef HAVE_IMAGE #include "SDL_image.h" -#elif defined (__unix__) || defined(__APPLE__) || defined (UNIXCOMMON) // Windows doesn't need this, as SDL will do it for us. +#elif defined (__unix__) || !defined(__APPLE__) && defined (UNIXCOMMON) // Windows & Mac don't need this, as SDL will do it for us. #define LOAD_XPM //I want XPM! #include "IMG_xpm.c" //Alam: I don't want to add SDL_Image.dll/so #define HAVE_IMAGE //I have SDL_Image, sortof From a65fc9f6221cbf87f81fb7bdb3ccbf004ba0d934 Mon Sep 17 00:00:00 2001 From: lachwright Date: Sun, 15 Nov 2020 02:53:10 +1100 Subject: [PATCH 0327/1080] Reallow P_MobjSpawn to change the scale of objects spawned from mapthings --- src/p_mobj.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index 414d0435c..8b6b66849 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -13077,8 +13077,8 @@ static mobj_t *P_SpawnMobjFromMapThing(mapthing_t *mthing, fixed_t x, fixed_t y, mobj = P_SpawnMobj(x, y, z, i); mobj->spawnpoint = mthing; - P_SetScale(mobj, mthing->scale); - mobj->destscale = mthing->scale; + P_SetScale(mobj, FixedMul(mobj->scale, mthing->scale)); + mobj->destscale = FixedMul(mobj->destscale, mthing->scale); if (!P_SetupSpawnedMapThing(mthing, mobj, &doangle)) return mobj; From 8814980a06acfcc1493b20828a5671594f9bc2e4 Mon Sep 17 00:00:00 2001 From: Riku Salminen <38985578+Riku-S@users.noreply.github.com> Date: Sat, 14 Nov 2020 19:18:36 +0200 Subject: [PATCH 0328/1080] Emeralds and tokens now reset when restarting marathon mode in first level --- src/g_game.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/g_game.c b/src/g_game.c index 228295b62..528721e2f 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -2218,6 +2218,10 @@ void G_Ticker(boolean run) { marathonmode |= MA_INIT; marathontime = 0; + + tokenlist = 0; + token = 0; + emeralds = 0; } else if (G_GametypeUsesLives() && players[consoleplayer].playerstate == PST_LIVE && players[consoleplayer].lives != INFLIVES) players[consoleplayer].lives -= 1; From 0a1beab8c80591a90107017b0d0712f74ecba720 Mon Sep 17 00:00:00 2001 From: Riku Salminen <38985578+Riku-S@users.noreply.github.com> Date: Sat, 14 Nov 2020 20:17:35 +0200 Subject: [PATCH 0329/1080] Reset a couple of other variables while we're at it --- src/g_game.c | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index 528721e2f..d6861b252 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -2216,12 +2216,32 @@ void G_Ticker(boolean run) // Costs a life to retry ... unless the player in question is dead already, or you haven't even touched the first starpost in marathon run. if (marathonmode && gamemap == spmarathon_start && !players[consoleplayer].starposttime) { + player_t *p = &players[consoleplayer]; marathonmode |= MA_INIT; marathontime = 0; - tokenlist = 0; - token = 0; - emeralds = 0; + numgameovers = tokenlist = token = 0; + countdown = countdown2 = exitfadestarted = 0; + + p->playerstate = PST_REBORN; + p->starpostx = p->starposty = p->starpostz = 0; + + p->lives = startinglivesbalance[0]; + p->continues = 1; + + p->score = 0; + + // The latter two should clear by themselves, but just in case + p->pflags &= ~(PF_TAGIT|PF_GAMETYPEOVER|PF_FULLSTASIS); + + // Clear cheatcodes too, just in case. + p->pflags &= ~(PF_GODMODE|PF_NOCLIP|PF_INVIS); + + p->xtralife = 0; + + // Reset unlockable triggers + unlocktriggers = 0; + } else if (G_GametypeUsesLives() && players[consoleplayer].playerstate == PST_LIVE && players[consoleplayer].lives != INFLIVES) players[consoleplayer].lives -= 1; From cc98be4d232323ccb989a9792f3382df366535fe Mon Sep 17 00:00:00 2001 From: Nev3r Date: Sat, 14 Nov 2020 20:25:00 +0100 Subject: [PATCH 0330/1080] Add documentation for the iterator macros. --- src/taglist.h | 66 ++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 60 insertions(+), 6 deletions(-) diff --git a/src/taglist.h b/src/taglist.h index 3a724aef3..a1dfe479e 100644 --- a/src/taglist.h +++ b/src/taglist.h @@ -61,14 +61,68 @@ INT32 Tag_Iterate_Things (const mtag_t tag, const size_t p); INT32 Tag_FindLineSpecial(const INT16 special, const mtag_t tag); INT32 P_FindSpecialLineFromTag(INT16 special, INT16 tag, INT32 start); -// Use this macro to declare the iterator position variable. +// Use this macro to declare an iterator position variable. #define TAG_ITER_DECLARECOUNTER(level) size_t ICNT_##level -#define TAG_ITER(level, fn, tag, id) for(ICNT_##level = 0; (id = fn(tag, ICNT_##level)) >= 0; ICNT_##level++) +#define TAG_ITER(level, fn, tag, return_varname) for(ICNT_##level = 0; (return_varname = fn(tag, ICNT_##level)) >= 0; ICNT_##level++) -// Use these macros as wrappers for the taglist iterations. -#define TAG_ITER_SECTORS(level, tag, id) TAG_ITER(level, Tag_Iterate_Sectors, tag, id) -#define TAG_ITER_LINES(level, tag, id) TAG_ITER(level, Tag_Iterate_Lines, tag, id) -#define TAG_ITER_THINGS(level, tag, id) TAG_ITER(level, Tag_Iterate_Things, tag, id) +// Use these macros as wrappers for a taglist iteration. +#define TAG_ITER_SECTORS(level, tag, return_varname) TAG_ITER(level, Tag_Iterate_Sectors, tag, return_varname) +#define TAG_ITER_LINES(level, tag, return_varname) TAG_ITER(level, Tag_Iterate_Lines, tag, return_varname) +#define TAG_ITER_THINGS(level, tag, return_varname) TAG_ITER(level, Tag_Iterate_Things, tag, return_varname) + +/* ITERATION MACROS +TAG_ITER_DECLARECOUNTER must be used before using the iterators. + +'level': +For each nested iteration, an additional TAG_ITER_DECLARECOUNTER +must be used with a different level number to avoid conflict with +the outer iterations. +Most cases don't have nested iterations and thus the level is just 0. + +'tag': +Pretty much the elements' tag to iterate through. + +'return_varname': +Target variable's name to return the iteration results to. + + +EXAMPLE: +{ + TAG_ITER_DECLARECOUNTER(0); + TAG_ITER_DECLARECOUNTER(1); // For the nested iteration. + + size_t li; + size_t sec; + + INT32 tag1 = 4; + + ... + + TAG_ITER_LINES(0, tag1, li) + { + line_t *line = lines + li; + + ... + + if (something) + { + mtag_t tag2 = 8; + + // Nested iteration; just make sure the level is higher + // and that it has its own counter declared in scope. + TAG_ITER_SECTORS(1, tag2, sec) + { + sector_t *sector = sectors + sec; + + ... + } + } + } +} + +Notes: +If no elements are found for a given tag, the loop inside won't be executed. +*/ #endif //__R_TAGLIST__ From 3a8b2a6fb779b8b1fbc94acad5950b59987b20e4 Mon Sep 17 00:00:00 2001 From: Nev3r Date: Sat, 14 Nov 2020 20:50:34 +0100 Subject: [PATCH 0331/1080] Better documentation. --- src/taglist.c | 17 ++++++++++++++++- src/taglist.h | 5 ++--- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/taglist.c b/src/taglist.c index e0bb86c97..b11216b6c 100644 --- a/src/taglist.c +++ b/src/taglist.c @@ -15,10 +15,15 @@ #include "z_zone.h" #include "r_data.h" +// Taggroups are used to list elements of the same tag, for iteration. +// Since elements can now have multiple tags, it means an element may appear +// in several taggroups at the same time. These are built on level load. taggroup_t* tags_sectors[MAXTAGS + 1]; taggroup_t* tags_lines[MAXTAGS + 1]; taggroup_t* tags_mapthings[MAXTAGS + 1]; +/// Adds a tag to a given element's taglist. +/// \warning This does not rebuild the global taggroups, which are used for iteration. void Tag_Add (taglist_t* list, const mtag_t tag) { list->tags = Z_Realloc(list->tags, (list->count + 1) * sizeof(list->tags), PU_LEVEL, NULL); @@ -26,6 +31,7 @@ void Tag_Add (taglist_t* list, const mtag_t tag) } /// Sets the first tag entry in a taglist. +/// Replicates the old way of accessing element->tag. void Tag_FSet (taglist_t* list, const mtag_t tag) { if (!list->count) @@ -38,6 +44,7 @@ void Tag_FSet (taglist_t* list, const mtag_t tag) } /// Gets the first tag entry in a taglist. +/// Replicates the old way of accessing element->tag. mtag_t Tag_FGet (const taglist_t* list) { if (list->count) @@ -46,6 +53,7 @@ mtag_t Tag_FGet (const taglist_t* list) return 0; } +/// Returns true if the given tag exist inside the list. boolean Tag_Find (const taglist_t* list, const mtag_t tag) { size_t i; @@ -56,6 +64,7 @@ boolean Tag_Find (const taglist_t* list, const mtag_t tag) return false; } +/// Returns true if at least one tag is shared between two given lists. boolean Tag_Share (const taglist_t* list1, const taglist_t* list2) { size_t i; @@ -66,6 +75,7 @@ boolean Tag_Share (const taglist_t* list1, const taglist_t* list2) return false; } +/// Returns true if both lists are identical. boolean Tag_Compare (const taglist_t* list1, const taglist_t* list2) { size_t i; @@ -80,7 +90,7 @@ boolean Tag_Compare (const taglist_t* list1, const taglist_t* list2) return true; } - +/// Search for an element inside a global taggroup. size_t Taggroup_Find (const taggroup_t *group, const size_t id) { size_t i; @@ -95,6 +105,7 @@ size_t Taggroup_Find (const taggroup_t *group, const size_t id) return -1; } +/// Add an element to a global taggroup. void Taggroup_Add (taggroup_t *garray[], const mtag_t tag, size_t id) { taggroup_t *group; @@ -135,6 +146,7 @@ void Taggroup_Add (taggroup_t *garray[], const mtag_t tag, size_t id) group->elements[i] = id; } +/// Remove an element from a global taggroup. void Taggroup_Remove (taggroup_t *garray[], const mtag_t tag, size_t id) { taggroup_t *group; @@ -191,6 +203,8 @@ static void Taglist_AddToMapthings (const mtag_t tag, const size_t itemid) Taggroup_Add(tags_mapthings, tag, itemid); } +/// After all taglists have been built for each element (sectors, lines, things), +/// the global taggroups, made for iteration, are built here. void Taglist_InitGlobalTables(void) { size_t i, j; @@ -338,6 +352,7 @@ INT32 P_FindSpecialLineFromTag(INT16 special, INT16 tag, INT32 start) // Ingame list manipulation. +/// Changes the first tag for a given sector, and updates the global taggroups. void Tag_SectorFSet (const size_t id, const mtag_t tag) { sector_t* sec = §ors[id]; diff --git a/src/taglist.h b/src/taglist.h index a1dfe479e..0e6d9f842 100644 --- a/src/taglist.h +++ b/src/taglist.h @@ -20,7 +20,7 @@ typedef INT16 mtag_t; #define MAXTAGS UINT16_MAX #define MTAG_GLOBAL -1 -/// Multitag list. +/// Multitag list. Each taggable element will have its own taglist. typedef struct { mtag_t* tags; @@ -28,16 +28,15 @@ typedef struct } taglist_t; void Tag_Add (taglist_t* list, const mtag_t tag); - void Tag_FSet (taglist_t* list, const mtag_t tag); mtag_t Tag_FGet (const taglist_t* list); boolean Tag_Find (const taglist_t* list, const mtag_t tag); boolean Tag_Share (const taglist_t* list1, const taglist_t* list2); - boolean Tag_Compare (const taglist_t* list1, const taglist_t* list2); void Tag_SectorFSet (const size_t id, const mtag_t tag); +/// Taggroup list. It is essentially just an element id list. typedef struct { size_t *elements; From f0fdcfb92bdebb6a118abd8815b6de37152dabb9 Mon Sep 17 00:00:00 2001 From: Louis-Antoine Date: Sun, 15 Nov 2020 00:52:51 +0100 Subject: [PATCH 0332/1080] Delete outdated comment --- src/dehacked.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/dehacked.c b/src/dehacked.c index 0380cc30e..edc789158 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -2897,13 +2897,6 @@ static void readhuditem(MYFILE *f, INT32 num) Z_Free(s); } -/* -Sprite number = 10 -Sprite subnumber = 32968 -Duration = 200 -Next frame = 200 -*/ - /** Action pointer for reading actions from Dehacked lumps. */ typedef struct From 7e7de16e6b42a52fc1fd9f2739464c5adf69a00a Mon Sep 17 00:00:00 2001 From: Louis-Antoine Date: Sun, 15 Nov 2020 00:53:46 +0100 Subject: [PATCH 0333/1080] Fix typo --- src/dehacked.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dehacked.c b/src/dehacked.c index edc789158..5463b7bb0 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -3167,7 +3167,7 @@ static actionpointer_t actionpointers[] = {{A_PterabyteHover}, "A_PTERABYTEHOVER"}, {{A_RolloutSpawn}, "A_ROLLOUTSPAWN"}, {{A_RolloutRock}, "A_ROLLOUTROCK"}, - {{A_DragonbomberSpawn}, "A_DRAGONBOMERSPAWN"}, + {{A_DragonbomberSpawn}, "A_DRAGONBOMBERSPAWN"}, {{A_DragonWing}, "A_DRAGONWING"}, {{A_DragonSegment}, "A_DRAGONSEGMENT"}, {{A_ChangeHeight}, "A_CHANGEHEIGHT"}, From 33193db146957e3090a66cfa7879f0aa8f66bf09 Mon Sep 17 00:00:00 2001 From: James R Date: Sat, 14 Nov 2020 15:56:40 -0800 Subject: [PATCH 0334/1080] Remove unused music type enums --- src/dehacked.c | 1 - src/i_sound.h | 3 --- 2 files changed, 4 deletions(-) diff --git a/src/dehacked.c b/src/dehacked.c index 3ef3a9572..532c5c2c8 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -10111,7 +10111,6 @@ struct { // music types {"MU_NONE", MU_NONE}, - {"MU_CMD", MU_CMD}, {"MU_WAV", MU_WAV}, {"MU_MOD", MU_MOD}, {"MU_MID", MU_MID}, diff --git a/src/i_sound.h b/src/i_sound.h index a2249a102..d45c0b323 100644 --- a/src/i_sound.h +++ b/src/i_sound.h @@ -21,15 +21,12 @@ // copied from SDL mixer, plus GME typedef enum { MU_NONE, - MU_CMD, MU_WAV, MU_MOD, MU_MID, MU_OGG, MU_MP3, - MU_MP3_MAD_UNUSED, // use MU_MP3 instead MU_FLAC, - MU_MODPLUG_UNUSED, // use MU_MOD instead MU_GME, MU_MOD_EX, // libopenmpt MU_MID_EX // Non-native MIDI From 13ba25f4fe57df59b748621940a4594f1282a680 Mon Sep 17 00:00:00 2001 From: Louis-Antoine Date: Sun, 15 Nov 2020 01:15:58 +0100 Subject: [PATCH 0335/1080] Only call the Lua API for overridden actions --- src/dehacked.c | 24 +-- src/dehacked.h | 1 + src/info.h | 283 +++++++++++++++++++++++++ src/lua_infolib.c | 20 +- src/lua_script.c | 5 + src/p_enemy.c | 522 +++++++++++++++++++++++----------------------- 6 files changed, 570 insertions(+), 285 deletions(-) diff --git a/src/dehacked.c b/src/dehacked.c index 5463b7bb0..fc2b32cab 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -2897,18 +2897,9 @@ static void readhuditem(MYFILE *f, INT32 num) Z_Free(s); } -/** Action pointer for reading actions from Dehacked lumps. - */ -typedef struct -{ - actionf_t action; ///< Function pointer corresponding to the actual action. - const char *name; ///< Name of the action in ALL CAPS. -} actionpointer_t; - -/** Array mapping action names to action functions. - * Names must be in ALL CAPS for case insensitive comparisons. - */ -static actionpointer_t actionpointers[] = +// IMPORTANT! +// DO NOT FORGET TO SYNC THIS LIST WITH THE ACTIONNUM ENUM IN INFO.H +actionpointer_t actionpointers[] = { {{A_Explode}, "A_EXPLODE"}, {{A_Pain}, "A_PAIN"}, @@ -11272,3 +11263,12 @@ void LUA_SetActionByName(void *state, const char *actiontocompare) } } } + +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; +} diff --git a/src/dehacked.h b/src/dehacked.h index 54225f36e..7f4fea446 100644 --- a/src/dehacked.h +++ b/src/dehacked.h @@ -37,6 +37,7 @@ fixed_t get_number(const char *word); boolean LUA_SetLuaAction(void *state, const char *actiontocompare); const char *LUA_GetActionName(void *action); void LUA_SetActionByName(void *state, const char *actiontocompare); +enum actionnum LUA_GetActionNumByName(const char *actiontocompare); extern boolean deh_loaded; diff --git a/src/info.h b/src/info.h index d84461617..f2f60d21d 100644 --- a/src/info.h +++ b/src/info.h @@ -22,6 +22,287 @@ // dehacked.c now has lists for the more named enums! PLEASE keep them up to date! // For great modding!! +/** Action pointer for reading actions from Dehacked lumps. + */ +typedef struct +{ + actionf_t action; ///< Function pointer corresponding to the actual action. + const char *name; ///< Name of the action in ALL CAPS. +} actionpointer_t; + +/** Array mapping action names to action functions. + * Names must be in ALL CAPS for case insensitive comparisons. + */ +extern actionpointer_t actionpointers[]; + +// IMPORTANT! +// DO NOT FORGET TO SYNC THIS LIST WITH THE ACTIONPOINTERS ARRAY IN DEHACKED.C +enum actionnum +{ + A_EXPLODE = 0, + A_PAIN, + A_FALL, + A_MONITORPOP, + A_GOLDMONITORPOP, + A_GOLDMONITORRESTORE, + A_GOLDMONITORSPARKLE, + A_LOOK, + A_CHASE, + A_FACESTABCHASE, + A_FACESTABREV, + A_FACESTABHURL, + A_FACESTABMISS, + A_STATUEBURST, + A_FACETARGET, + A_FACETRACER, + A_SCREAM, + A_BOSSDEATH, + A_CUSTOMPOWER, + A_GIVEWEAPON, + A_RINGBOX, + A_INVINCIBILITY, + A_SUPERSNEAKERS, + A_BUNNYHOP, + A_BUBBLESPAWN, + A_FANBUBBLESPAWN, + A_BUBBLERISE, + A_BUBBLECHECK, + A_AWARDSCORE, + A_EXTRALIFE, + A_GIVESHIELD, + A_GRAVITYBOX, + A_SCORERISE, + A_ATTRACTCHASE, + A_DROPMINE, + A_FISHJUMP, + A_THROWNRING, + A_SETSOLIDSTEAM, + A_UNSETSOLIDSTEAM, + A_SIGNSPIN, + A_SIGNPLAYER, + A_OVERLAYTHINK, + A_JETCHASE, + A_JETBTHINK, + A_JETGTHINK, + A_JETGSHOOT, + A_SHOOTBULLET, + A_MINUSDIGGING, + A_MINUSPOPUP, + A_MINUSCHECK, + A_CHICKENCHECK, + A_MOUSETHINK, + A_DETONCHASE, + A_CAPECHASE, + A_ROTATESPIKEBALL, + A_SLINGAPPEAR, + A_UNIDUSBALL, + A_ROCKSPAWN, + A_SETFUSE, + A_CRAWLACOMMANDERTHINK, + A_SMOKETRAILER, + A_RINGEXPLODE, + A_OLDRINGEXPLODE, + A_MIXUP, + A_RECYCLEPOWERS, + A_BOSS1CHASE, + A_FOCUSTARGET, + A_BOSS2CHASE, + A_BOSS2POGO, + A_BOSSZOOM, + A_BOSSSCREAM, + A_BOSS2TAKEDAMAGE, + A_BOSS7CHASE, + A_GOOPSPLAT, + A_BOSS2POGOSFX, + A_BOSS2POGOTARGET, + A_BOSSJETFUME, + A_EGGMANBOX, + A_TURRETFIRE, + A_SUPERTURRETFIRE, + A_TURRETSTOP, + A_JETJAWROAM, + A_JETJAWCHOMP, + A_POINTYTHINK, + A_CHECKBUDDY, + A_HOODFIRE, + A_HOODTHINK, + A_HOODFALL, + A_ARROWBONKS, + A_SNAILERTHINK, + A_SHARPCHASE, + A_SHARPSPIN, + A_SHARPDECEL, + A_CRUSHSTACEANWALK, + A_CRUSHSTACEANPUNCH, + A_CRUSHCLAWAIM, + A_CRUSHCLAWLAUNCH, + A_VULTUREVTOL, + A_VULTURECHECK, + A_VULTUREHOVER, + A_VULTUREBLAST, + A_VULTUREFLY, + A_SKIMCHASE, + A_1UPTHINKER, + A_SKULLATTACK, + A_LOBSHOT, + A_FIRESHOT, + A_SUPERFIRESHOT, + A_BOSSFIRESHOT, + A_BOSS7FIREMISSILES, + A_BOSS1LASER, + A_BOSS4REVERSE, + A_BOSS4SPEEDUP, + A_BOSS4RAISE, + A_SPARKFOLLOW, + A_BUZZFLY, + A_GUARDCHASE, + A_EGGSHIELD, + A_SETREACTIONTIME, + A_BOSS1SPIKEBALLS, + A_BOSS3TAKEDAMAGE, + A_BOSS3PATH, + A_BOSS3SHOCKTHINK, + A_LINEDEFEXECUTE, + A_PLAYSEESOUND, + A_PLAYATTACKSOUND, + A_PLAYACTIVESOUND, + A_SPAWNOBJECTABSOLUTE, + A_SPAWNOBJECTRELATIVE, + A_CHANGEANGLERELATIVE, + A_CHANGEANGLEABSOLUTE, + A_ROLLANGLE, + A_CHANGEROLLANGLERELATIVE, + A_CHANGEROLLANGLEABSOLUTE, + A_PLAYSOUND, + A_FINDTARGET, + A_FINDTRACER, + A_SETTICS, + A_SETRANDOMTICS, + A_CHANGECOLORRELATIVE, + A_CHANGECOLORABSOLUTE, + A_DYE, + A_MOVERELATIVE, + A_MOVEABSOLUTE, + A_THRUST, + A_ZTHRUST, + A_SETTARGETSTARGET, + A_SETOBJECTFLAGS, + A_SETOBJECTFLAGS2, + A_RANDOMSTATE, + A_RANDOMSTATERANGE, + A_DUALACTION, + A_REMOTEACTION, + A_TOGGLEFLAMEJET, + A_ORBITNIGHTS, + A_GHOSTME, + A_SETOBJECTSTATE, + A_SETOBJECTTYPESTATE, + A_KNOCKBACK, + A_PUSHAWAY, + A_RINGDRAIN, + A_SPLITSHOT, + A_MISSILESPLIT, + A_MULTISHOT, + A_INSTALOOP, + A_CUSTOM3DROTATE, + A_SEARCHFORPLAYERS, + A_CHECKRANDOM, + A_CHECKTARGETRINGS, + A_CHECKRINGS, + A_CHECKTOTALRINGS, + A_CHECKHEALTH, + A_CHECKRANGE, + A_CHECKHEIGHT, + A_CHECKTRUERANGE, + A_CHECKTHINGCOUNT, + A_CHECKAMBUSH, + A_CHECKCUSTOMVALUE, + A_CHECKCUSVALMEMO, + A_SETCUSTOMVALUE, + A_USECUSVALMEMO, + A_RELAYCUSTOMVALUE, + A_CUSVALACTION, + A_FORCESTOP, + A_FORCEWIN, + A_SPIKERETRACT, + A_INFOSTATE, + A_REPEAT, + A_SETSCALE, + A_REMOTEDAMAGE, + A_HOMINGCHASE, + A_TRAPSHOT, + A_VILETARGET, + A_VILEATTACK, + A_VILEFIRE, + A_BRAKCHASE, + A_BRAKFIRESHOT, + A_BRAKLOBSHOT, + A_NAPALMSCATTER, + A_SPAWNFRESHCOPY, + A_FLICKYSPAWN, + A_FLICKYCENTER, + A_FLICKYAIM, + A_FLICKYFLY, + A_FLICKYSOAR, + A_FLICKYCOAST, + A_FLICKYHOP, + A_FLICKYFLOUNDER, + A_FLICKYCHECK, + A_FLICKYHEIGHTCHECK, + A_FLICKYFLUTTER, + A_FLAMEPARTICLE, + A_FADEOVERLAY, + A_BOSS5JUMP, + A_LIGHTBEAMRESET, + A_MINEEXPLODE, + A_MINERANGE, + A_CONNECTTOGROUND, + A_SPAWNPARTICLERELATIVE, + A_MULTISHOTDIST, + A_WHOCARESIFYOURSONISABEE, + A_PARENTTRIESTOSLEEP, + A_CRYINGTOMOMMA, + A_CHECKFLAGS2, + A_BOSS5FINDWAYPOINT, + A_DONPCSKID, + A_DONPCPAIN, + A_PREPAREREPEAT, + A_BOSS5EXTRAREPEAT, + A_BOSS5CALM, + A_BOSS5CHECKONGROUND, + A_BOSS5CHECKFALLING, + A_BOSS5PINCHSHOT, + A_BOSS5MAKEITRAIN, + A_BOSS5MAKEJUNK, + A_LOOKFORBETTER, + A_BOSS5BOMBEXPLODE, + A_DUSTDEVILTHINK, + A_TNTEXPLODE, + A_DEBRISRANDOM, + A_TRAINCAMEO, + A_TRAINCAMEO2, + A_CANARIVOREGAS, + A_KILLSEGMENTS, + A_SNAPPERSPAWN, + A_SNAPPERTHINKER, + A_SALOONDOORSPAWN, + A_MINECARTSPARKTHINK, + A_MODULOTOSTATE, + A_LAVAFALLROCKS, + A_LAVAFALLLAVA, + A_FALLINGLAVACHECK, + A_FIRESHRINK, + A_SPAWNPTERABYTES, + A_PTERABYTEHOVER, + A_ROLLOUTSPAWN, + A_ROLLOUTROCK, + A_DRAGONBOMBERSPAWN, + A_DRAGONWING, + A_DRAGONSEGMENT, + A_CHANGEHEIGHT, + NUMACTIONS +}; + // IMPORTANT NOTE: If you add/remove from this list of action // functions, don't forget to update them in dehacked.c! void A_Explode(); @@ -286,6 +567,8 @@ void A_DragonWing(); void A_DragonSegment(); void A_ChangeHeight(); +extern boolean actionsoverridden[NUMACTIONS]; + // ratio of states to sprites to mobj types is roughly 6 : 1 : 1 #define NUMMOBJFREESLOTS 512 #define NUMSPRITEFREESLOTS NUMMOBJFREESLOTS diff --git a/src/lua_infolib.c b/src/lua_infolib.c index 566aaa6a0..e17994974 100644 --- a/src/lua_infolib.c +++ b/src/lua_infolib.c @@ -30,7 +30,7 @@ extern CV_PossibleValue_t Color_cons_t[]; extern UINT8 skincolor_modified[]; -boolean LUA_CallAction(const char *action, mobj_t *actor); +boolean LUA_CallAction(enum actionnum actionnum, mobj_t *actor); state_t *astate; enum sfxinfo_read { @@ -63,6 +63,8 @@ const char *const sfxinfo_wopt[] = { "caption", NULL}; +boolean actionsoverridden[NUMACTIONS] = {false}; + // // Sprite Names // @@ -816,27 +818,21 @@ boolean LUA_SetLuaAction(void *stv, const char *action) return true; // action successfully set. } -boolean LUA_CallAction(const char *csaction, mobj_t *actor) +boolean LUA_CallAction(enum actionnum actionnum, mobj_t *actor) { - I_Assert(csaction != NULL); I_Assert(actor != NULL); - if (!gL) // Lua isn't loaded, + if (!(gL && actionsoverridden[actionnum])) // Lua isn't loaded, or the action is not overriden, return false; // action not called. - if (superstack && fasticmp(csaction, superactions[superstack-1])) // the action is calling itself, + if (superstack && fasticmp(actionpointers[actionnum].name, superactions[superstack-1])) // the action is calling itself, return false; // let it call the hardcoded function instead. lua_pushcfunction(gL, LUA_GetErrorMessage); // grab function by uppercase name. lua_getfield(gL, LUA_REGISTRYINDEX, LREG_ACTIONS); - { - char *action = Z_StrDup(csaction); - strupr(action); - lua_getfield(gL, -1, action); - Z_Free(action); - } + lua_getfield(gL, -1, actionpointers[actionnum].name); lua_remove(gL, -2); // pop LREG_ACTIONS if (lua_isnil(gL, -1)) // no match @@ -859,7 +855,7 @@ boolean LUA_CallAction(const char *csaction, mobj_t *actor) lua_pushinteger(gL, var1); lua_pushinteger(gL, var2); - superactions[superstack] = csaction; + superactions[superstack] = actionpointers[actionnum].name; ++superstack; LUA_Call(gL, 3, 0, -(2 + 3)); diff --git a/src/lua_script.c b/src/lua_script.c index be6bf602f..b44dd7105 100644 --- a/src/lua_script.c +++ b/src/lua_script.c @@ -401,6 +401,7 @@ static int setglobals(lua_State *L) { const char *csname; char *name; + enum actionnum actionnum; lua_remove(L, 1); // we're not gonna be using _G csname = lua_tostring(L, 1); @@ -419,6 +420,10 @@ static int setglobals(lua_State *L) lua_rawset(L, -3); // rawset doesn't trigger this metatable again. // otherwise we would've used setfield, obviously. + actionnum = LUA_GetActionNumByName(name); + if (actionnum < NUMACTIONS) + actionsoverridden[actionnum] = true; + Z_Free(name); return 0; } diff --git a/src/p_enemy.c b/src/p_enemy.c index ddb01b63b..74ab1d49c 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -30,7 +30,7 @@ #include "hardware/hw3sound.h" #endif -boolean LUA_CallAction(const char *action, mobj_t *actor); +boolean LUA_CallAction(enum actionnum actionnum, mobj_t *actor); player_t *stplyr; INT32 var1; @@ -981,7 +981,7 @@ void A_Look(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; - if (LUA_CallAction("A_Look", actor)) + if (LUA_CallAction(A_LOOK, actor)) return; if (!P_LookForPlayers(actor, locvar1 & 65535, false , FixedMul((locvar1 >> 16)*FRACUNIT, actor->scale))) @@ -1014,7 +1014,7 @@ void A_Chase(mobj_t *actor) INT32 delta; INT32 locvar1 = var1; - if (LUA_CallAction("A_Chase", actor)) + if (LUA_CallAction(A_CHASE, actor)) return; I_Assert(actor != NULL); @@ -1105,7 +1105,7 @@ void A_FaceStabChase(mobj_t *actor) { INT32 delta; - if (LUA_CallAction("A_FaceStabChase", actor)) + if (LUA_CallAction(A_FACESTABCHASE, actor)) return; if (actor->reactiontime) @@ -1227,7 +1227,7 @@ void A_FaceStabRev(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; - if (LUA_CallAction("A_FaceStabRev", actor)) + if (LUA_CallAction(A_FACESTABREV, actor)) return; if (!actor->target) @@ -1270,7 +1270,7 @@ void A_FaceStabHurl(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; - if (LUA_CallAction("A_FaceStabHurl", actor)) + if (LUA_CallAction(A_FACESTABHURL, actor)) return; if (actor->target) @@ -1360,7 +1360,7 @@ void A_FaceStabMiss(mobj_t *actor) { INT32 locvar2 = var2; - if (LUA_CallAction("A_FaceStabMiss", actor)) + if (LUA_CallAction(A_FACESTABMISS, actor)) return; if (++actor->extravalue1 >= 3) @@ -1395,7 +1395,7 @@ void A_StatueBurst(mobj_t *actor) mobjtype_t chunktype = (mobjtype_t)actor->info->raisestate; mobj_t *new; - if (LUA_CallAction("A_StatueBurst", actor)) + if (LUA_CallAction(A_STATUEBURST, actor)) return; if (!locvar1 || !(new = P_SpawnMobjFromMobj(actor, 0, 0, 0, locvar1))) @@ -1445,7 +1445,7 @@ void A_StatueBurst(mobj_t *actor) // void A_JetJawRoam(mobj_t *actor) { - if (LUA_CallAction("A_JetJawRoam", actor)) + if (LUA_CallAction(A_JETJAWROAM, actor)) return; if (actor->reactiontime) @@ -1474,7 +1474,7 @@ void A_JetJawChomp(mobj_t *actor) { INT32 delta; - if (LUA_CallAction("A_JetJawChomp", actor)) + if (LUA_CallAction(A_JETJAWCHOMP, actor)) return; // turn towards movement direction if not there yet @@ -1521,7 +1521,7 @@ void A_PointyThink(mobj_t *actor) boolean firsttime = true; INT32 sign; - if (LUA_CallAction("A_PointyThink", actor)) + if (LUA_CallAction(A_POINTYTHINK, actor)) return; actor->momx = actor->momy = actor->momz = 0; @@ -1619,7 +1619,7 @@ void A_CheckBuddy(mobj_t *actor) { INT32 locvar1 = var1; - if (LUA_CallAction("A_CheckBuddy", actor)) + if (LUA_CallAction(A_CHECKBUDDY, actor)) return; if (locvar1 && (!actor->tracer || actor->tracer->health <= 0)) @@ -1662,7 +1662,7 @@ void A_HoodFire(mobj_t *actor) mobj_t *arrow; INT32 locvar1 = var1; - if (LUA_CallAction("A_HoodFire", actor)) + if (LUA_CallAction(A_HOODFIRE, actor)) return; // Check target first. @@ -1694,7 +1694,7 @@ void A_HoodThink(mobj_t *actor) fixed_t dx, dy, dz, dm; boolean checksight; - if (LUA_CallAction("A_HoodThink", actor)) + if (LUA_CallAction(A_HOODTHINK, actor)) return; // Check target first. @@ -1761,7 +1761,7 @@ void A_HoodThink(mobj_t *actor) // void A_HoodFall(mobj_t *actor) { - if (LUA_CallAction("A_HoodFall", actor)) + if (LUA_CallAction(A_HOODFALL, actor)) return; if (!P_IsObjectOnGround(actor)) @@ -1781,7 +1781,7 @@ void A_HoodFall(mobj_t *actor) // void A_ArrowBonks(mobj_t *actor) { - if (LUA_CallAction("A_ArrowBonks", actor)) + if (LUA_CallAction(A_ARROWBONKS, actor)) return; if (((actor->eflags & MFE_VERTICALFLIP) && actor->z + actor->height >= actor->ceilingz) @@ -1804,7 +1804,7 @@ void A_ArrowBonks(mobj_t *actor) // void A_SnailerThink(mobj_t *actor) { - if (LUA_CallAction("A_SnailerThink", actor)) + if (LUA_CallAction(A_SNAILERTHINK, actor)) return; if (!actor->target || !(actor->target->flags & MF_SHOOTABLE)) @@ -1877,7 +1877,7 @@ void A_SnailerThink(mobj_t *actor) // void A_SharpChase(mobj_t *actor) { - if (LUA_CallAction("A_SharpChase", actor)) + if (LUA_CallAction(A_SHARPCHASE, actor)) return; if (actor->reactiontime) @@ -1933,7 +1933,7 @@ void A_SharpSpin(mobj_t *actor) INT32 locvar2 = var2; angle_t oldang = actor->angle; - if (LUA_CallAction("A_SharpSpin", actor)) + if (LUA_CallAction(A_SHARPSPIN, actor)) return; if (actor->threshold && actor->target) @@ -1966,7 +1966,7 @@ void A_SharpSpin(mobj_t *actor) // void A_SharpDecel(mobj_t *actor) { - if (LUA_CallAction("A_SharpDecel", actor)) + if (LUA_CallAction(A_SHARPDECEL, actor)) return; if (actor->momx > 2 || actor->momy > 2) @@ -1991,7 +1991,7 @@ void A_CrushstaceanWalk(mobj_t *actor) INT32 locvar2 = (var2 ? var2 : (INT32)actor->info->spawnstate); angle_t ang = actor->angle + ((actor->flags2 & MF2_AMBUSH) ? ANGLE_90 : ANGLE_270); - if (LUA_CallAction("A_CrushstaceanWalk", actor)) + if (LUA_CallAction(A_CRUSHSTACEANWALK, actor)) return; actor->reactiontime--; @@ -2020,7 +2020,7 @@ void A_CrushstaceanPunch(mobj_t *actor) { INT32 locvar2 = (var2 ? var2 : (INT32)actor->info->spawnstate); - if (LUA_CallAction("A_CrushstaceanPunch", actor)) + if (LUA_CallAction(A_CRUSHSTACEANPUNCH, actor)) return; if (!actor->tracer) @@ -2052,7 +2052,7 @@ void A_CrushclawAim(mobj_t *actor) mobj_t *crab = actor->tracer; angle_t ang; - if (LUA_CallAction("A_CrushclawAim", actor)) + if (LUA_CallAction(A_CRUSHCLAWAIM, actor)) return; if (!crab) @@ -2113,7 +2113,7 @@ void A_CrushclawLaunch(mobj_t *actor) INT32 locvar2 = var2; mobj_t *crab = actor->tracer; - if (LUA_CallAction("A_CrushclawLaunch", actor)) + if (LUA_CallAction(A_CRUSHCLAWLAUNCH, actor)) return; if (!crab) @@ -2244,7 +2244,7 @@ void A_CrushclawLaunch(mobj_t *actor) // void A_VultureVtol(mobj_t *actor) { - if (LUA_CallAction("A_VultureVtol", actor)) + if (LUA_CallAction(A_VULTUREVTOL, actor)) return; if (!actor->target) @@ -2279,7 +2279,7 @@ void A_VultureVtol(mobj_t *actor) // void A_VultureCheck(mobj_t *actor) { - if (LUA_CallAction("A_VultureCheck", actor)) + if (LUA_CallAction(A_VULTURECHECK, actor)) return; if (actor->momx || actor->momy) @@ -2335,7 +2335,7 @@ void A_VultureHover(mobj_t *actor) fixed_t memz = actor->z; SINT8 i; - if (LUA_CallAction("A_VultureHover", actor)) + if (LUA_CallAction(A_VULTUREHOVER, actor)) return; if (!actor->target || P_MobjWasRemoved(actor->target)) @@ -2397,7 +2397,7 @@ void A_VultureBlast(mobj_t *actor) angle_t faa; fixed_t faacos, faasin; - if (LUA_CallAction("A_VultureBlast", actor)) + if (LUA_CallAction(A_VULTUREBLAST, actor)) return; S_StartSound(actor, actor->info->attacksound); @@ -2436,7 +2436,7 @@ void A_VultureFly(mobj_t *actor) mobj_t *dust; fixed_t momm; - if (LUA_CallAction("A_VultureFly", actor)) + if (LUA_CallAction(A_VULTUREFLY, actor)) return; if (!actor->target || P_MobjWasRemoved(actor->target)) @@ -2528,7 +2528,7 @@ void A_SkimChase(mobj_t *actor) { INT32 delta; - if (LUA_CallAction("A_SkimChase", actor)) + if (LUA_CallAction(A_SKIMCHASE, actor)) return; if (actor->reactiontime) @@ -2614,7 +2614,7 @@ nomissile: // void A_FaceTarget(mobj_t *actor) { - if (LUA_CallAction("A_FaceTarget", actor)) + if (LUA_CallAction(A_FACETARGET, actor)) return; if (!actor->target) @@ -2632,7 +2632,7 @@ void A_FaceTarget(mobj_t *actor) // void A_FaceTracer(mobj_t *actor) { - if (LUA_CallAction("A_FaceTracer", actor)) + if (LUA_CallAction(A_FACETRACER, actor)) return; if (!actor->tracer) @@ -2661,7 +2661,7 @@ void A_LobShot(mobj_t *actor) fixed_t vertical, horizontal; fixed_t airtime = var2 & 65535; - if (LUA_CallAction("A_LobShot", actor)) + if (LUA_CallAction(A_LOBSHOT, actor)) return; if (!actor->target) @@ -2761,7 +2761,7 @@ void A_FireShot(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; - if (LUA_CallAction("A_FireShot", actor)) + if (LUA_CallAction(A_FIRESHOT, actor)) return; if (!actor->target) @@ -2799,7 +2799,7 @@ void A_SuperFireShot(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; - if (LUA_CallAction("A_SuperFireShot", actor)) + if (LUA_CallAction(A_SUPERFIRESHOT, actor)) return; if (!actor->target) @@ -2846,7 +2846,7 @@ void A_BossFireShot(mobj_t *actor) INT32 locvar2 = var2; mobj_t *missile; - if (LUA_CallAction("A_BossFireShot", actor)) + if (LUA_CallAction(A_BOSSFIRESHOT, actor)) return; if (!actor->target) @@ -2930,7 +2930,7 @@ void A_Boss7FireMissiles(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; - if (LUA_CallAction("A_Boss7FireMissiles", actor)) + if (LUA_CallAction(A_BOSS7FIREMISSILES, actor)) return; if (!actor->target) @@ -3005,7 +3005,7 @@ void A_Boss1Laser(mobj_t *actor) SKINCOLOR_SUPERRED3, }; - if (LUA_CallAction("A_Boss1Laser", actor)) + if (LUA_CallAction(A_BOSS1LASER, actor)) return; if (!actor->target) @@ -3176,7 +3176,7 @@ void A_FocusTarget(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; - if (LUA_CallAction("A_FocusTarget", actor)) + if (LUA_CallAction(A_FOCUSTARGET, actor)) return; if (actor->target) @@ -3227,7 +3227,7 @@ void A_Boss4Reverse(mobj_t *actor) sfxenum_t locvar1 = (sfxenum_t)var1; sfxenum_t locvar2 = (sfxenum_t)var2; - if (LUA_CallAction("A_Boss4Reverse", actor)) + if (LUA_CallAction(A_BOSS4REVERSE, actor)) return; actor->reactiontime = 0; @@ -3262,7 +3262,7 @@ void A_Boss4SpeedUp(mobj_t *actor) { sfxenum_t locvar1 = (sfxenum_t)var1; - if (LUA_CallAction("A_Boss4SpeedUp", actor)) + if (LUA_CallAction(A_BOSS4SPEEDUP, actor)) return; S_StartSound(NULL, locvar1); @@ -3280,7 +3280,7 @@ void A_Boss4Raise(mobj_t *actor) { sfxenum_t locvar1 = (sfxenum_t)var1; - if (LUA_CallAction("A_Boss4Raise", actor)) + if (LUA_CallAction(A_BOSS4RAISE, actor)) return; S_StartSound(NULL, locvar1); @@ -3311,7 +3311,7 @@ void A_SkullAttack(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; - if (LUA_CallAction("A_SkullAttack", actor)) + if (LUA_CallAction(A_SKULLATTACK, actor)) return; if (!actor->target) @@ -3429,7 +3429,7 @@ void A_BossZoom(mobj_t *actor) angle_t an; INT32 dist; - if (LUA_CallAction("A_BossZoom", actor)) + if (LUA_CallAction(A_BOSSZOOM, actor)) return; if (!actor->target) @@ -3469,7 +3469,7 @@ void A_BossScream(mobj_t *actor) INT32 locvar2 = var2; mobjtype_t explodetype; - if (LUA_CallAction("A_BossScream", actor)) + if (LUA_CallAction(A_BOSSSCREAM, actor)) return; if (locvar1 & 1) @@ -3514,7 +3514,7 @@ void A_BossScream(mobj_t *actor) // void A_Scream(mobj_t *actor) { - if (LUA_CallAction("A_Scream", actor)) + if (LUA_CallAction(A_SCREAM, actor)) return; if (actor->tracer && (actor->tracer->type == MT_SHELL || actor->tracer->type == MT_FIREBALL)) @@ -3532,7 +3532,7 @@ void A_Scream(mobj_t *actor) // void A_Pain(mobj_t *actor) { - if (LUA_CallAction("A_Pain", actor)) + if (LUA_CallAction(A_PAIN, actor)) return; if (actor->info->painsound) @@ -3553,7 +3553,7 @@ void A_Fall(mobj_t *actor) { INT32 locvar1 = var1; - if (LUA_CallAction("A_Fall", actor)) + if (LUA_CallAction(A_FALL, actor)) return; // actor is on ground, it can be walked over @@ -3585,7 +3585,7 @@ void A_1upThinker(mobj_t *actor) fixed_t temp; INT32 closestplayer = -1; - if (LUA_CallAction("A_1upThinker", actor)) + if (LUA_CallAction(A_1UPTHINKER, actor)) return; for (i = 0; i < MAXPLAYERS; i++) @@ -3651,7 +3651,7 @@ void A_MonitorPop(mobj_t *actor) mobjtype_t item = 0; mobj_t *newmobj; - if (LUA_CallAction("A_MonitorPop", actor)) + if (LUA_CallAction(A_MONITORPOP, actor)) return; // Spawn the "pop" explosion. @@ -3732,7 +3732,7 @@ void A_GoldMonitorPop(mobj_t *actor) mobjtype_t item = 0; mobj_t *newmobj; - if (LUA_CallAction("A_GoldMonitorPop", actor)) + if (LUA_CallAction(A_GOLDMONITORPOP, actor)) return; // Don't spawn the "pop" explosion, because the monitor isn't broken. @@ -3815,7 +3815,7 @@ void A_GoldMonitorPop(mobj_t *actor) // void A_GoldMonitorRestore(mobj_t *actor) { - if (LUA_CallAction("A_GoldMonitorRestore", actor)) + if (LUA_CallAction(A_GOLDMONITORRESTORE, actor)) return; actor->flags |= MF_MONITOR|MF_SHOOTABLE; @@ -3833,7 +3833,7 @@ void A_GoldMonitorSparkle(mobj_t *actor) { fixed_t i, ngangle, xofs, yofs; - if (LUA_CallAction("A_GoldMonitorSparkle", actor)) + if (LUA_CallAction(A_GOLDMONITORSPARKLE, actor)) return; ngangle = FixedAngle(((leveltime * 21) % 360) << FRACBITS); @@ -3855,7 +3855,7 @@ void A_Explode(mobj_t *actor) { INT32 locvar1 = var1; - if (LUA_CallAction("A_Explode", actor)) + if (LUA_CallAction(A_EXPLODE, actor)) return; P_RadiusAttack(actor, actor->target, actor->info->damage, locvar1, true); @@ -3875,7 +3875,7 @@ void A_BossDeath(mobj_t *mo) line_t junk; INT32 i; - if (LUA_CallAction("A_BossDeath", mo)) + if (LUA_CallAction(A_BOSSDEATH, mo)) return; if (mo->spawnpoint && mo->spawnpoint->extrainfo) @@ -4183,7 +4183,7 @@ void A_CustomPower(mobj_t *actor) INT32 locvar2 = var2; boolean spawnshield = false; - if (LUA_CallAction("A_CustomPower", actor)) + if (LUA_CallAction(A_CUSTOMPOWER, actor)) return; if (!actor->target || !actor->target->player) @@ -4223,7 +4223,7 @@ void A_GiveWeapon(mobj_t *actor) player_t *player; INT32 locvar1 = var1; - if (LUA_CallAction("A_GiveWeapon", actor)) + if (LUA_CallAction(A_GIVEWEAPON, actor)) return; if (!actor->target || !actor->target->player) @@ -4256,7 +4256,7 @@ void A_RingBox(mobj_t *actor) { player_t *player; - if (LUA_CallAction("A_RingBox", actor)) + if (LUA_CallAction(A_RINGBOX, actor)) return; if (!actor->target || !actor->target->player) @@ -4283,7 +4283,7 @@ void A_Invincibility(mobj_t *actor) { player_t *player; - if (LUA_CallAction("A_Invincibility", actor)) + if (LUA_CallAction(A_INVINCIBILITY, actor)) return; if (!actor->target || !actor->target->player) @@ -4316,7 +4316,7 @@ void A_SuperSneakers(mobj_t *actor) { player_t *player; - if (LUA_CallAction("A_SuperSneakers", actor)) + if (LUA_CallAction(A_SUPERSNEAKERS, actor)) return; if (!actor->target || !actor->target->player) @@ -4351,7 +4351,7 @@ void A_AwardScore(mobj_t *actor) { player_t *player; - if (LUA_CallAction("A_AwardScore", actor)) + if (LUA_CallAction(A_AWARDSCORE, actor)) return; if (!actor->target || !actor->target->player) @@ -4378,7 +4378,7 @@ void A_ExtraLife(mobj_t *actor) { player_t *player; - if (LUA_CallAction("A_ExtraLife", actor)) + if (LUA_CallAction(A_EXTRALIFE, actor)) return; if (!actor->target || !actor->target->player) @@ -4416,7 +4416,7 @@ void A_GiveShield(mobj_t *actor) player_t *player; UINT16 locvar1 = var1; - if (LUA_CallAction("A_GiveShield", actor)) + if (LUA_CallAction(A_GIVESHIELD, actor)) return; if (!actor->target || !actor->target->player) @@ -4442,7 +4442,7 @@ void A_GravityBox(mobj_t *actor) { player_t *player; - if (LUA_CallAction("A_GravityBox", actor)) + if (LUA_CallAction(A_GRAVITYBOX, actor)) return; if (!actor->target || !actor->target->player) @@ -4467,7 +4467,7 @@ void A_GravityBox(mobj_t *actor) // void A_ScoreRise(mobj_t *actor) { - if (LUA_CallAction("A_ScoreRise", actor)) + if (LUA_CallAction(A_SCORERISE, actor)) return; // make logo rise! @@ -4486,7 +4486,7 @@ void A_BunnyHop(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; - if (LUA_CallAction("A_BunnyHop", actor)) + if (LUA_CallAction(A_BUNNYHOP, actor)) return; if (((actor->eflags & MFE_VERTICALFLIP) && actor->z + actor->height >= actor->ceilingz) @@ -4510,7 +4510,7 @@ void A_BubbleSpawn(mobj_t *actor) UINT8 prandom; mobj_t *bubble = NULL; - if (LUA_CallAction("A_BubbleSpawn", actor)) + if (LUA_CallAction(A_BUBBLESPAWN, actor)) return; if (!(actor->eflags & MFE_UNDERWATER)) @@ -4563,7 +4563,7 @@ void A_FanBubbleSpawn(mobj_t *actor) mobj_t *bubble = NULL; fixed_t hz = actor->z + (4*actor->height)/5; - if (LUA_CallAction("A_FanBubbleSpawn", actor)) + if (LUA_CallAction(A_FANBUBBLESPAWN, actor)) return; if (!(actor->eflags & MFE_UNDERWATER)) @@ -4609,7 +4609,7 @@ void A_BubbleRise(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; - if (LUA_CallAction("A_BubbleRise", actor)) + if (LUA_CallAction(A_BUBBLERISE, actor)) return; if (actor->type == MT_EXTRALARGEBUBBLE) @@ -4645,7 +4645,7 @@ void A_BubbleRise(mobj_t *actor) // void A_BubbleCheck(mobj_t *actor) { - if (LUA_CallAction("A_BubbleCheck", actor)) + if (LUA_CallAction(A_BUBBLECHECK, actor)) return; if (actor->eflags & MFE_UNDERWATER) @@ -4663,7 +4663,7 @@ void A_BubbleCheck(mobj_t *actor) // void A_AttractChase(mobj_t *actor) { - if (LUA_CallAction("A_AttractChase", actor)) + if (LUA_CallAction(A_ATTRACTCHASE, actor)) return; if (actor->flags2 & MF2_NIGHTSPULL || !actor->health) @@ -4734,7 +4734,7 @@ void A_DropMine(mobj_t *actor) fixed_t z; mobj_t *mine; - if (LUA_CallAction("A_DropMine", actor)) + if (LUA_CallAction(A_DROPMINE, actor)) return; if (locvar2 & 65535) @@ -4782,7 +4782,7 @@ void A_FishJump(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; - if (LUA_CallAction("A_FishJump", actor)) + if (LUA_CallAction(A_FISHJUMP, actor)) return; if (locvar2) @@ -4833,7 +4833,7 @@ void A_ThrownRing(mobj_t *actor) player_t *player; fixed_t dist; - if (LUA_CallAction("A_ThrownRing", actor)) + if (LUA_CallAction(A_THROWNRING, actor)) return; if (leveltime % (TICRATE/7) == 0) @@ -4989,7 +4989,7 @@ void A_ThrownRing(mobj_t *actor) // void A_SetSolidSteam(mobj_t *actor) { - if (LUA_CallAction("A_SetSolidSteam", actor)) + if (LUA_CallAction(A_SETSOLIDSTEAM, actor)) return; actor->flags &= ~MF_NOCLIP; @@ -5020,7 +5020,7 @@ void A_SetSolidSteam(mobj_t *actor) // void A_UnsetSolidSteam(mobj_t *actor) { - if (LUA_CallAction("A_UnsetSolidSteam", actor)) + if (LUA_CallAction(A_UNSETSOLIDSTEAM, actor)) return; actor->flags &= ~MF_SOLID; @@ -5040,7 +5040,7 @@ void A_SignSpin(mobj_t *actor) INT16 i; angle_t rotateangle = FixedAngle(locvar1 << FRACBITS); - if (LUA_CallAction("A_SignSpin", actor)) + if (LUA_CallAction(A_SIGNSPIN, actor)) return; if (P_IsObjectOnGround(actor) && P_MobjFlip(actor) * actor->momz <= 0) @@ -5111,7 +5111,7 @@ void A_SignPlayer(mobj_t *actor) facecolor = signcolor = (UINT16)locvar2; - if (LUA_CallAction("A_SignPlayer", actor)) + if (LUA_CallAction(A_SIGNPLAYER, actor)) return; if (actor->tracer == NULL || locvar1 < -3 || locvar1 >= numskins || signcolor >= numskincolors) @@ -5229,7 +5229,7 @@ void A_OverlayThink(mobj_t *actor) { fixed_t destx, desty; - if (LUA_CallAction("A_OverlayThink", actor)) + if (LUA_CallAction(A_OVERLAYTHINK, actor)) return; if (!actor->target) @@ -5281,7 +5281,7 @@ void A_JetChase(mobj_t *actor) { fixed_t thefloor; - if (LUA_CallAction("A_JetChase", actor)) + if (LUA_CallAction(A_JETCHASE, actor)) return; if (actor->flags2 & MF2_AMBUSH) @@ -5377,7 +5377,7 @@ void A_JetbThink(mobj_t *actor) sector_t *nextsector; fixed_t thefloor; - if (LUA_CallAction("A_JetbThink", actor)) + if (LUA_CallAction(A_JETBTHINK, actor)) return; if (actor->z >= actor->waterbottom && actor->watertop > actor->floorz @@ -5442,7 +5442,7 @@ void A_JetgShoot(mobj_t *actor) { fixed_t dist; - if (LUA_CallAction("A_JetgShoot", actor)) + if (LUA_CallAction(A_JETGSHOOT, actor)) return; if (!actor->target) @@ -5482,7 +5482,7 @@ void A_ShootBullet(mobj_t *actor) { fixed_t dist; - if (LUA_CallAction("A_ShootBullet", actor)) + if (LUA_CallAction(A_SHOOTBULLET, actor)) return; if (!actor->target) @@ -5542,7 +5542,7 @@ void A_MinusDigging(mobj_t *actor) fixed_t mz = (actor->eflags & MFE_VERTICALFLIP) ? actor->ceilingz : actor->floorz; mobj_t *par; - if (LUA_CallAction("A_MinusDigging", actor)) + if (LUA_CallAction(A_MINUSDIGGING, actor)) return; if (!actor->target) @@ -5623,7 +5623,7 @@ void A_MinusPopup(mobj_t *actor) angle_t ani = FixedAngle(FRACUNIT*360/num); INT32 i; - if (LUA_CallAction("A_MinusPopup", actor)) + if (LUA_CallAction(A_MINUSPOPUP, actor)) return; if (actor->eflags & MFE_VERTICALFLIP) @@ -5658,7 +5658,7 @@ void A_MinusCheck(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; - if (LUA_CallAction("A_MinusCheck", actor)) + if (LUA_CallAction(A_MINUSCHECK, actor)) return; if (((actor->eflags & MFE_VERTICALFLIP) && actor->z + actor->height >= actor->ceilingz) || (!(actor->eflags & MFE_VERTICALFLIP) && actor->z <= actor->floorz)) @@ -5689,7 +5689,7 @@ void A_MinusCheck(mobj_t *actor) // void A_ChickenCheck(mobj_t *actor) { - if (LUA_CallAction("A_ChickenCheck", actor)) + if (LUA_CallAction(A_CHICKENCHECK, actor)) return; if ((!(actor->eflags & MFE_VERTICALFLIP) && actor->z <= actor->floorz) @@ -5720,7 +5720,7 @@ void A_JetgThink(mobj_t *actor) fixed_t thefloor; - if (LUA_CallAction("A_JetgThink", actor)) + if (LUA_CallAction(A_JETGTHINK, actor)) return; if (actor->z >= actor->waterbottom && actor->watertop > actor->floorz @@ -5770,7 +5770,7 @@ void A_JetgThink(mobj_t *actor) // void A_MouseThink(mobj_t *actor) { - if (LUA_CallAction("A_MouseThink", actor)) + if (LUA_CallAction(A_MOUSETHINK, actor)) return; if (actor->reactiontime) @@ -5807,7 +5807,7 @@ void A_DetonChase(mobj_t *actor) angle_t exact; fixed_t xydist, dist; - if (LUA_CallAction("A_DetonChase", actor)) + if (LUA_CallAction(A_DETONCHASE, actor)) return; // modify tracer threshold @@ -5954,7 +5954,7 @@ void A_CapeChase(mobj_t *actor) INT32 locvar2 = var2; angle_t angle; - if (LUA_CallAction("A_CapeChase", actor)) + if (LUA_CallAction(A_CAPECHASE, actor)) return; CONS_Debug(DBG_GAMELOGIC, "A_CapeChase called from object type %d, var1: %d, var2: %d\n", actor->type, locvar1, locvar2); @@ -6014,7 +6014,7 @@ void A_RotateSpikeBall(mobj_t *actor) INT32 locvar1 = var1; const fixed_t radius = FixedMul(12*actor->info->speed, actor->scale); - if (LUA_CallAction("A_RotateSpikeBall", actor)) + if (LUA_CallAction(A_ROTATESPIKEBALL, actor)) return; if (!((!locvar1 && (actor->target)) || (locvar1 && (actor->tracer))))// This should NEVER happen. @@ -6065,7 +6065,7 @@ void A_UnidusBall(mobj_t *actor) INT32 locvar1 = var1; boolean canthrow = false; - if (LUA_CallAction("A_UnidusBall", actor)) + if (LUA_CallAction(A_UNIDUSBALL, actor)) return; actor->angle += ANGLE_11hh; @@ -6162,7 +6162,7 @@ void A_RockSpawn(mobj_t *actor) fixed_t dist; fixed_t randomoomph; - if (LUA_CallAction("A_RockSpawn", actor)) + if (LUA_CallAction(A_ROCKSPAWN, actor)) return; if (i == -1) @@ -6215,7 +6215,7 @@ void A_SlingAppear(mobj_t *actor) UINT8 mlength = 4; mobj_t *spawnee, *hprev; - if (LUA_CallAction("A_SlingAppear", actor)) + if (LUA_CallAction(A_SLINGAPPEAR, actor)) return; P_UnsetThingPosition(actor); @@ -6265,7 +6265,7 @@ void A_SetFuse(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; - if (LUA_CallAction("A_SetFuse", actor)) + if (LUA_CallAction(A_SETFUSE, actor)) return; if ((!actor->fuse || (locvar2 >> 16)) && (locvar2 >> 16) != 2) // set the actor's fuse value @@ -6294,7 +6294,7 @@ void A_CrawlaCommanderThink(mobj_t *actor) INT32 locvar2 = var2; boolean hovermode = (actor->health > 1 || actor->fuse); - if (LUA_CallAction("A_CrawlaCommanderThink", actor)) + if (LUA_CallAction(A_CRAWLACOMMANDERTHINK, actor)) return; if (actor->z >= actor->waterbottom && actor->watertop > actor->floorz @@ -6452,7 +6452,7 @@ void A_RingExplode(mobj_t *actor) thinker_t *th; angle_t d; - if (LUA_CallAction("A_RingExplode", actor)) + if (LUA_CallAction(A_RINGEXPLODE, actor)) return; for (d = 0; d < 16; d++) @@ -6497,7 +6497,7 @@ void A_OldRingExplode(mobj_t *actor) { INT32 locvar1 = var1; boolean changecolor = (actor->target && actor->target->player); - if (LUA_CallAction("A_OldRingExplode", actor)) + if (LUA_CallAction(A_OLDRINGEXPLODE, actor)) return; for (i = 0; i < 32; i++) @@ -6573,7 +6573,7 @@ void A_MixUp(mobj_t *actor) boolean teleported[MAXPLAYERS]; INT32 i, numplayers = 0, prandom = 0; - if (LUA_CallAction("A_MixUp", actor)) + if (LUA_CallAction(A_MIXUP, actor)) return; if (!multiplayer) @@ -6848,7 +6848,7 @@ void A_RecyclePowers(mobj_t *actor) INT32 weapons[MAXPLAYERS]; INT32 weaponheld[MAXPLAYERS]; - if (LUA_CallAction("A_RecyclePowers", actor)) + if (LUA_CallAction(A_RECYCLEPOWERS, actor)) return; if (!multiplayer) @@ -6979,7 +6979,7 @@ void A_Boss1Chase(mobj_t *actor) { INT32 delta; - if (LUA_CallAction("A_Boss1Chase", actor)) + if (LUA_CallAction(A_BOSS1CHASE, actor)) return; if (!actor->target || !(actor->target->flags & MF_SHOOTABLE)) @@ -7102,7 +7102,7 @@ void A_Boss2Chase(mobj_t *actor) boolean reverse = false; INT32 speedvar; - if (LUA_CallAction("A_Boss2Chase", actor)) + if (LUA_CallAction(A_BOSS2CHASE, actor)) return; if (actor->health <= 0) @@ -7228,7 +7228,7 @@ void A_Boss2Chase(mobj_t *actor) // void A_Boss2Pogo(mobj_t *actor) { - if (LUA_CallAction("A_Boss2Pogo", actor)) + if (LUA_CallAction(A_BOSS2POGO, actor)) return; if (actor->z <= actor->floorz + FixedMul(8*FRACUNIT, actor->scale) && actor->momz <= 0) @@ -7276,7 +7276,7 @@ void A_Boss2TakeDamage(mobj_t *actor) { INT32 locvar1 = var1; - if (LUA_CallAction("A_Boss2TakeDamage", actor)) + if (LUA_CallAction(A_BOSS2TAKEDAMAGE, actor)) return; A_Pain(actor); @@ -7299,7 +7299,7 @@ void A_Boss7Chase(mobj_t *actor) INT32 delta; INT32 i; - if (LUA_CallAction("A_Boss7Chase", actor)) + if (LUA_CallAction(A_BOSS7CHASE, actor)) return; if (actor->z != actor->floorz) @@ -7429,7 +7429,7 @@ void A_Boss7Chase(mobj_t *actor) // void A_GoopSplat(mobj_t *actor) { - if (LUA_CallAction("A_GoopSplat", actor)) + if (LUA_CallAction(A_GOOPSPLAT, actor)) return; P_UnsetThingPosition(actor); @@ -7454,7 +7454,7 @@ void A_Boss2PogoSFX(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; - if (LUA_CallAction("A_Boss2PogoSFX", actor)) + if (LUA_CallAction(A_BOSS2POGOSFX, actor)) return; if (!actor->target || !(actor->target->flags & MF_SHOOTABLE)) @@ -7496,7 +7496,7 @@ void A_Boss2PogoTarget(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; - if (LUA_CallAction("A_Boss2PogoTarget", actor)) + if (LUA_CallAction(A_BOSS2POGOTARGET, actor)) return; if (!actor->target || !(actor->target->flags & MF_SHOOTABLE) || (actor->target->player && actor->target->player->powers[pw_flashing]) @@ -7581,7 +7581,7 @@ void A_Boss2PogoTarget(mobj_t *actor) // void A_EggmanBox(mobj_t *actor) { - if (LUA_CallAction("A_EggmanBox", actor)) + if (LUA_CallAction(A_EGGMANBOX, actor)) return; if (!actor->target || !actor->target->player) @@ -7607,7 +7607,7 @@ void A_TurretFire(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; - if (LUA_CallAction("A_TurretFire", actor)) + if (LUA_CallAction(A_TURRETFIRE, actor)) return; if (locvar2) @@ -7645,7 +7645,7 @@ void A_SuperTurretFire(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; - if (LUA_CallAction("A_SuperTurretFire", actor)) + if (LUA_CallAction(A_SUPERTURRETFIRE, actor)) return; if (locvar2) @@ -7681,7 +7681,7 @@ void A_TurretStop(mobj_t *actor) { INT32 locvar1 = var1; - if (LUA_CallAction("A_TurretStop", actor)) + if (LUA_CallAction(A_TURRETSTOP, actor)) return; actor->flags2 &= ~MF2_FIRING; @@ -7700,7 +7700,7 @@ void A_TurretStop(mobj_t *actor) // void A_SparkFollow(mobj_t *actor) { - if (LUA_CallAction("A_SparkFollow", actor)) + if (LUA_CallAction(A_SPARKFOLLOW, actor)) return; if ((!actor->target || (actor->target->health <= 0)) @@ -7736,7 +7736,7 @@ void A_BuzzFly(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; - if (LUA_CallAction("A_BuzzFly", actor)) + if (LUA_CallAction(A_BUZZFLY, actor)) return; if (actor->flags2 & MF2_AMBUSH) @@ -7835,7 +7835,7 @@ void A_GuardChase(mobj_t *actor) { INT32 delta; - if (LUA_CallAction("A_GuardChase", actor)) + if (LUA_CallAction(A_GUARDCHASE, actor)) return; if (actor->reactiontime) @@ -7940,7 +7940,7 @@ void A_EggShield(mobj_t *actor) fixed_t movex, movey; angle_t angle; - if (LUA_CallAction("A_EggShield", actor)) + if (LUA_CallAction(A_EGGSHIELD, actor)) return; if (!actor->target || !actor->target->health) @@ -8022,7 +8022,7 @@ void A_EggShield(mobj_t *actor) // void A_SetReactionTime(mobj_t *actor) { - if (LUA_CallAction("A_SetReactionTime", actor)) + if (LUA_CallAction(A_SETREACTIONTIME, actor)) return; if (var1) @@ -8044,7 +8044,7 @@ void A_Boss1Spikeballs(mobj_t *actor) INT32 locvar2 = var2; mobj_t *ball; - if (LUA_CallAction("A_Boss1Spikeballs", actor)) + if (LUA_CallAction(A_BOSS1SPIKEBALLS, actor)) return; ball = P_SpawnMobj(actor->x, actor->y, actor->z, MT_EGGMOBILE_BALL); @@ -8066,7 +8066,7 @@ void A_Boss1Spikeballs(mobj_t *actor) // void A_Boss3TakeDamage(mobj_t *actor) { - if (LUA_CallAction("A_Boss3TakeDamage", actor)) + if (LUA_CallAction(A_BOSS3TAKEDAMAGE, actor)) return; actor->movecount = var1; @@ -8086,7 +8086,7 @@ void A_Boss3TakeDamage(mobj_t *actor) // void A_Boss3Path(mobj_t *actor) { - if (LUA_CallAction("A_Boss3Path", actor)) + if (LUA_CallAction(A_BOSS3PATH, actor)) return; if (actor->tracer && actor->tracer->health && actor->tracer->movecount) @@ -8213,7 +8213,7 @@ void A_Boss3Path(mobj_t *actor) // void A_Boss3ShockThink(mobj_t *actor) { - if (LUA_CallAction("A_Boss3ShockThink", actor)) + if (LUA_CallAction(A_BOSS3SHOCKTHINK, actor)) return; if (actor->momx || actor->momy) @@ -8266,7 +8266,7 @@ void A_LinedefExecute(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; - if (LUA_CallAction("A_LinedefExecute", actor)) + if (LUA_CallAction(A_LINEDEFEXECUTE, actor)) return; tagnum = locvar1; @@ -8292,7 +8292,7 @@ void A_LinedefExecute(mobj_t *actor) // void A_PlaySeeSound(mobj_t *actor) { - if (LUA_CallAction("A_PlaySeeSound", actor)) + if (LUA_CallAction(A_PLAYSEESOUND, actor)) return; if (actor->info->seesound) @@ -8308,7 +8308,7 @@ void A_PlaySeeSound(mobj_t *actor) // void A_PlayAttackSound(mobj_t *actor) { - if (LUA_CallAction("A_PlayAttackSound", actor)) + if (LUA_CallAction(A_PLAYATTACKSOUND, actor)) return; if (actor->info->attacksound) @@ -8324,7 +8324,7 @@ void A_PlayAttackSound(mobj_t *actor) // void A_PlayActiveSound(mobj_t *actor) { - if (LUA_CallAction("A_PlayActiveSound", actor)) + if (LUA_CallAction(A_PLAYACTIVESOUND, actor)) return; if (actor->info->activesound) @@ -8343,7 +8343,7 @@ void A_SmokeTrailer(mobj_t *actor) mobj_t *th; INT32 locvar1 = var1; - if (LUA_CallAction("A_SmokeTrailer", actor)) + if (LUA_CallAction(A_SMOKETRAILER, actor)) return; if (leveltime % 4) @@ -8384,7 +8384,7 @@ void A_SpawnObjectAbsolute(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; - if (LUA_CallAction("A_SpawnObjectAbsolute", actor)) + if (LUA_CallAction(A_SPAWNOBJECTABSOLUTE, actor)) return; x = (INT16)(locvar1>>16); @@ -8420,7 +8420,7 @@ void A_SpawnObjectRelative(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; - if (LUA_CallAction("A_SpawnObjectRelative", actor)) + if (LUA_CallAction(A_SPAWNOBJECTRELATIVE, actor)) return; CONS_Debug(DBG_GAMELOGIC, "A_SpawnObjectRelative called from object type %d, var1: %d, var2: %d\n", actor->type, locvar1, locvar2); @@ -8464,7 +8464,7 @@ void A_ChangeAngleRelative(mobj_t *actor) //const angle_t amin = FixedAngle(locvar1*FRACUNIT); //const angle_t amax = FixedAngle(locvar2*FRACUNIT); - if (LUA_CallAction("A_ChangeAngleRelative", actor)) + if (LUA_CallAction(A_CHANGEANGLERELATIVE, actor)) return; #ifdef PARANOIA @@ -8497,7 +8497,7 @@ void A_ChangeAngleAbsolute(mobj_t *actor) //const angle_t amin = FixedAngle(locvar1*FRACUNIT); //const angle_t amax = FixedAngle(locvar2*FRACUNIT); - if (LUA_CallAction("A_ChangeAngleAbsolute", actor)) + if (LUA_CallAction(A_CHANGEANGLEABSOLUTE, actor)) return; #ifdef PARANOIA @@ -8526,7 +8526,7 @@ void A_RollAngle(mobj_t *actor) INT32 locvar2 = var2; const angle_t angle = FixedAngle(locvar1*FRACUNIT); - if (LUA_CallAction("A_RollAngle", actor)) + if (LUA_CallAction(A_ROLLANGLE, actor)) return; // relative (default) @@ -8551,7 +8551,7 @@ void A_ChangeRollAngleRelative(mobj_t *actor) const fixed_t amin = locvar1*FRACUNIT; const fixed_t amax = locvar2*FRACUNIT; - if (LUA_CallAction("A_ChangeRollAngleRelative", actor)) + if (LUA_CallAction(A_CHANGEROLLANGLERELATIVE, actor)) return; #ifdef PARANOIA @@ -8576,7 +8576,7 @@ void A_ChangeRollAngleAbsolute(mobj_t *actor) const fixed_t amin = locvar1*FRACUNIT; const fixed_t amax = locvar2*FRACUNIT; - if (LUA_CallAction("A_ChangeRollAngleAbsolute", actor)) + if (LUA_CallAction(A_CHANGEROLLANGLEABSOLUTE, actor)) return; #ifdef PARANOIA @@ -8601,7 +8601,7 @@ void A_PlaySound(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; - if (LUA_CallAction("A_PlaySound", actor)) + if (LUA_CallAction(A_PLAYSOUND, actor)) return; if (leveltime < 2 && (locvar2 >> 16)) @@ -8626,7 +8626,7 @@ void A_FindTarget(mobj_t *actor) mobj_t *mo2; fixed_t dist1 = 0, dist2 = 0; - if (LUA_CallAction("A_FindTarget", actor)) + if (LUA_CallAction(A_FINDTARGET, actor)) return; CONS_Debug(DBG_GAMELOGIC, "A_FindTarget called from object type %d, var1: %d, var2: %d\n", actor->type, locvar1, locvar2); @@ -8690,7 +8690,7 @@ void A_FindTracer(mobj_t *actor) mobj_t *mo2; fixed_t dist1 = 0, dist2 = 0; - if (LUA_CallAction("A_FindTracer", actor)) + if (LUA_CallAction(A_FINDTRACER, actor)) return; CONS_Debug(DBG_GAMELOGIC, "A_FindTracer called from object type %d, var1: %d, var2: %d\n", actor->type, locvar1, locvar2); @@ -8750,7 +8750,7 @@ void A_SetTics(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; - if (LUA_CallAction("A_SetTics", actor)) + if (LUA_CallAction(A_SETTICS, actor)) return; if (locvar1) @@ -8771,7 +8771,7 @@ void A_SetRandomTics(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; - if (LUA_CallAction("A_SetRandomTics", actor)) + if (LUA_CallAction(A_SETRANDOMTICS, actor)) return; actor->tics = P_RandomRange(locvar1, locvar2); @@ -8789,7 +8789,7 @@ void A_ChangeColorRelative(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; - if (LUA_CallAction("A_ChangeColorRelative", actor)) + if (LUA_CallAction(A_CHANGECOLORRELATIVE, actor)) return; if (locvar1) @@ -8814,7 +8814,7 @@ void A_ChangeColorAbsolute(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; - if (LUA_CallAction("A_ChangeColorAbsolute", actor)) + if (LUA_CallAction(A_CHANGECOLORABSOLUTE, actor)) return; if (locvar1) @@ -8840,7 +8840,7 @@ void A_Dye(mobj_t *actor) mobj_t *target = ((locvar1 && actor->target) ? actor->target : actor); UINT16 color = (UINT16)locvar2; - if (LUA_CallAction("A_Dye", actor)) + if (LUA_CallAction(A_DYE, actor)) return; if (color >= numskincolors) return; @@ -8873,7 +8873,7 @@ void A_MoveRelative(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; - if (LUA_CallAction("A_MoveRelative", actor)) + if (LUA_CallAction(A_MOVERELATIVE, actor)) return; P_Thrust(actor, actor->angle+FixedAngle(locvar1*FRACUNIT), FixedMul(locvar2*FRACUNIT, actor->scale)); @@ -8891,7 +8891,7 @@ void A_MoveAbsolute(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; - if (LUA_CallAction("A_MoveAbsolute", actor)) + if (LUA_CallAction(A_MOVEABSOLUTE, actor)) return; P_InstaThrust(actor, FixedAngle(locvar1*FRACUNIT), FixedMul(locvar2*FRACUNIT, actor->scale)); @@ -8909,7 +8909,7 @@ void A_Thrust(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; - if (LUA_CallAction("A_Thrust", actor)) + if (LUA_CallAction(A_THRUST, actor)) return; if (!locvar1) @@ -8935,7 +8935,7 @@ void A_ZThrust(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; - if (LUA_CallAction("A_ZThrust", actor)) + if (LUA_CallAction(A_ZTHRUST, actor)) return; if (!locvar1) @@ -8969,7 +8969,7 @@ void A_SetTargetsTarget(mobj_t *actor) INT32 locvar2 = var2; mobj_t *oldtarg = NULL, *newtarg = NULL; - if (LUA_CallAction("A_SetTargetsTarget", actor)) + if (LUA_CallAction(A_SETTARGETSTARGET, actor)) return; // actor's target @@ -9013,7 +9013,7 @@ void A_SetObjectFlags(mobj_t *actor) INT32 locvar2 = var2; boolean unlinkthings = false; - if (LUA_CallAction("A_SetObjectFlags", actor)) + if (LUA_CallAction(A_SETOBJECTFLAGS, actor)) return; if (locvar2 == 2) @@ -9054,7 +9054,7 @@ void A_SetObjectFlags2(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; - if (LUA_CallAction("A_SetObjectFlags2", actor)) + if (LUA_CallAction(A_SETOBJECTFLAGS2, actor)) return; if (locvar2 == 2) @@ -9081,7 +9081,7 @@ void A_BossJetFume(mobj_t *actor) mobj_t *filler; INT32 locvar1 = var1; - if (LUA_CallAction("A_BossJetFume", actor)) + if (LUA_CallAction(A_BOSSJETFUME, actor)) return; if (locvar1 == 0) // Boss1 jet fumes @@ -9216,7 +9216,7 @@ void A_RandomState(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; - if (LUA_CallAction("A_RandomState", actor)) + if (LUA_CallAction(A_RANDOMSTATE, actor)) return; P_SetMobjState(actor, P_RandomChance(FRACUNIT/2) ? locvar1 : locvar2); @@ -9234,7 +9234,7 @@ void A_RandomStateRange(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; - if (LUA_CallAction("A_RandomStateRange", actor)) + if (LUA_CallAction(A_RANDOMSTATERANGE, actor)) return; P_SetMobjState(actor, P_RandomRange(locvar1, locvar2)); @@ -9252,7 +9252,7 @@ void A_DualAction(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; - if (LUA_CallAction("A_DualAction", actor)) + if (LUA_CallAction(A_DUALACTION, actor)) return; CONS_Debug(DBG_GAMELOGIC, "A_DualAction called from object type %d, var1: %d, var2: %d\n", actor->type, locvar1, locvar2); @@ -9285,7 +9285,7 @@ void A_RemoteAction(mobj_t *actor) INT32 locvar2 = var2; mobj_t *originaltarget = actor->target; // Hold on to the target for later. - if (LUA_CallAction("A_RemoteAction", actor)) + if (LUA_CallAction(A_REMOTEACTION, actor)) return; // If >=0, find the closest target. @@ -9367,7 +9367,7 @@ void A_RemoteAction(mobj_t *actor) // void A_ToggleFlameJet(mobj_t* actor) { - if (LUA_CallAction("A_ToggleFlameJet", actor)) + if (LUA_CallAction(A_TOGGLEFLAMEJET, actor)) return; // threshold - off delay @@ -9414,7 +9414,7 @@ void A_OrbitNights(mobj_t* actor) boolean donotrescale = (var2 & 0x40000); INT32 xfactor = 32, yfactor = 32, zfactor = 20; - if (LUA_CallAction("A_OrbitNights", actor)) + if (LUA_CallAction(A_ORBITNIGHTS, actor)) return; if (actor->flags & MF_GRENADEBOUNCE) @@ -9487,7 +9487,7 @@ void A_GhostMe(mobj_t *actor) INT32 locvar1 = var1; mobj_t *ghost; - if (LUA_CallAction("A_GhostMe", actor)) + if (LUA_CallAction(A_GHOSTME, actor)) return; ghost = P_SpawnGhostMobj(actor); @@ -9510,7 +9510,7 @@ void A_SetObjectState(mobj_t *actor) INT32 locvar2 = var2; mobj_t *target; - if (LUA_CallAction("A_SetObjectState", actor)) + if (LUA_CallAction(A_SETOBJECTSTATE, actor)) return; if ((!locvar2 && !actor->target) || (locvar2 && !actor->tracer)) @@ -9554,7 +9554,7 @@ void A_SetObjectTypeState(mobj_t *actor) mobj_t *mo2; fixed_t dist = 0; - if (LUA_CallAction("A_SetObjectTypeState", actor)) + if (LUA_CallAction(A_SETOBJECTTYPESTATE, actor)) return; for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next) @@ -9596,7 +9596,7 @@ void A_KnockBack(mobj_t *actor) INT32 locvar1 = var1; mobj_t *target; - if (LUA_CallAction("A_KnockBack", actor)) + if (LUA_CallAction(A_KNOCKBACK, actor)) return; if (!locvar1) @@ -9631,7 +9631,7 @@ void A_PushAway(mobj_t *actor) mobj_t *target; // target angle_t an; // actor to target angle - if (LUA_CallAction("A_PushAway", actor)) + if (LUA_CallAction(A_PUSHAWAY, actor)) return; if ((!(locvar2 >> 16) && !actor->target) || ((locvar2 >> 16) && !actor->tracer)) @@ -9665,7 +9665,7 @@ void A_RingDrain(mobj_t *actor) INT32 locvar1 = var1; player_t *player; - if (LUA_CallAction("A_RingDrain", actor)) + if (LUA_CallAction(A_RINGDRAIN, actor)) return; if (!actor->target || !actor->target->player) @@ -9697,7 +9697,7 @@ void A_SplitShot(mobj_t *actor) const fixed_t offs = (fixed_t)(locvar1*FRACUNIT); const fixed_t hoffs = (fixed_t)(loc2up*FRACUNIT); - if (LUA_CallAction("A_SplitShot", actor)) + if (LUA_CallAction(A_SPLITSHOT, actor)) return; if (!actor->target) @@ -9734,7 +9734,7 @@ void A_MissileSplit(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; - if (LUA_CallAction("A_MissileSplit", actor)) + if (LUA_CallAction(A_MISSILESPLIT, actor)) return; if (actor->eflags & MFE_VERTICALFLIP) @@ -9762,7 +9762,7 @@ void A_MultiShot(mobj_t *actor) INT32 count = 0; fixed_t ad; - if (LUA_CallAction("A_MultiShot", actor)) + if (LUA_CallAction(A_MULTISHOT, actor)) return; if (actor->target) @@ -9823,7 +9823,7 @@ void A_InstaLoop(mobj_t *actor) const fixed_t ac = FINECOSINE(fa); const fixed_t as = FINESINE(fa); - if (LUA_CallAction("A_InstaLoop", actor)) + if (LUA_CallAction(A_INSTALOOP, actor)) return; P_InstaThrust(actor, actor->angle, FixedMul(ac, FixedMul(force, actor->scale))); @@ -9856,7 +9856,7 @@ void A_Custom3DRotate(mobj_t *actor) const fixed_t hspeed = FixedMul(loc2up*FRACUNIT/10, actor->scale); const fixed_t vspeed = FixedMul(loc2lw*FRACUNIT/10, actor->scale); - if (LUA_CallAction("A_Custom3DRotate", actor)) + if (LUA_CallAction(A_CUSTOM3DROTATE, actor)) return; if (actor->target->health == 0) @@ -9915,7 +9915,7 @@ void A_SearchForPlayers(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; - if (LUA_CallAction("A_SearchForPlayers", actor)) + if (LUA_CallAction(A_SEARCHFORPLAYERS, actor)) return; if (!actor->target || !(actor->target->flags & MF_SHOOTABLE)) @@ -9947,7 +9947,7 @@ void A_CheckRandom(mobj_t *actor) INT32 locvar2 = var2; fixed_t chance = FRACUNIT; - if (LUA_CallAction("A_CheckRandom", actor)) + if (LUA_CallAction(A_CHECKRANDOM, actor)) return; if ((locvar1 & 0xFFFF) == 0) @@ -9974,7 +9974,7 @@ void A_CheckTargetRings(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; - if (LUA_CallAction("A_CheckTargetRings", actor)) + if (LUA_CallAction(A_CHECKTARGETRINGS, actor)) return; if (!(actor->target) || !(actor->target->player)) @@ -9997,7 +9997,7 @@ void A_CheckRings(mobj_t *actor) INT32 locvar2 = var2; INT32 i, cntr = 0; - if (LUA_CallAction("A_CheckRings", actor)) + if (LUA_CallAction(A_CHECKRINGS, actor)) return; for (i = 0; i < MAXPLAYERS; i++) @@ -10021,7 +10021,7 @@ void A_CheckTotalRings(mobj_t *actor) INT32 i, cntr = 0; - if (LUA_CallAction("A_CheckTotalRings", actor)) + if (LUA_CallAction(A_CHECKTOTALRINGS, actor)) return; for (i = 0; i < MAXPLAYERS; i++) @@ -10043,7 +10043,7 @@ void A_CheckHealth(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; - if (LUA_CallAction("A_CheckHealth", actor)) + if (LUA_CallAction(A_CHECKHEALTH, actor)) return; if (actor->health <= locvar1) @@ -10065,7 +10065,7 @@ void A_CheckRange(mobj_t *actor) INT32 locvar2 = var2; fixed_t dist; - if (LUA_CallAction("A_CheckRange", actor)) + if (LUA_CallAction(A_CHECKRANGE, actor)) return; if ((!(locvar1 >> 16) && !actor->target) || ((locvar1 >> 16) && !actor->tracer)) @@ -10095,7 +10095,7 @@ void A_CheckHeight(mobj_t *actor) INT32 locvar2 = var2; fixed_t height; - if (LUA_CallAction("A_CheckHeight", actor)) + if (LUA_CallAction(A_CHECKHEIGHT, actor)) return; if ((!(locvar1 >> 16) && !actor->target) || ((locvar1 >> 16) && !actor->tracer)) @@ -10127,7 +10127,7 @@ void A_CheckTrueRange(mobj_t *actor) fixed_t dist; // horizontal range fixed_t l; // true range - if (LUA_CallAction("A_CheckTrueRange", actor)) + if (LUA_CallAction(A_CHECKTRUERANGE, actor)) return; if ((!(locvar1 >> 16) && !actor->target) || ((locvar1 >> 16) && !actor->tracer)) @@ -10178,7 +10178,7 @@ void A_CheckThingCount(mobj_t *actor) mobj_t *mo2; fixed_t dist = 0; - if (LUA_CallAction("A_CheckThingCount", actor)) + if (LUA_CallAction(A_CHECKTHINGCOUNT, actor)) return; for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next) @@ -10223,7 +10223,7 @@ void A_CheckAmbush(mobj_t *actor) angle_t atp; // actor to target angle angle_t an; // angle between at and atp - if (LUA_CallAction("A_CheckAmbush", actor)) + if (LUA_CallAction(A_CHECKAMBUSH, actor)) return; if ((!locvar1 && !actor->target) || (locvar1 && !actor->tracer)) @@ -10261,7 +10261,7 @@ void A_CheckCustomValue(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; - if (LUA_CallAction("A_CheckCustomValue", actor)) + if (LUA_CallAction(A_CHECKCUSTOMVALUE, actor)) return; if (actor->cusval >= locvar1) @@ -10280,7 +10280,7 @@ void A_CheckCusValMemo(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; - if (LUA_CallAction("A_CheckCusValMemo", actor)) + if (LUA_CallAction(A_CHECKCUSVALMEMO, actor)) return; if (actor->cvmem >= locvar1) @@ -10305,7 +10305,7 @@ void A_SetCustomValue(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; - if (LUA_CallAction("A_SetCustomValue", actor)) + if (LUA_CallAction(A_SETCUSTOMVALUE, actor)) return; if (cv_debug) @@ -10355,7 +10355,7 @@ void A_UseCusValMemo(mobj_t *actor) INT32 temp = actor->cusval; // value being manipulated INT32 tempM = actor->cvmem; // value used to manipulate temp with - if (LUA_CallAction("A_UseCusValMemo", actor)) + if (LUA_CallAction(A_USECUSVALMEMO, actor)) return; if (locvar1 == 1) // cvmem being changed using cusval @@ -10418,7 +10418,7 @@ void A_RelayCustomValue(mobj_t *actor) INT32 temp; // reference value - var1 lower 16 bits changes this INT32 tempT; // target's value - changed to tracer if var1 upper 16 bits set, then modified to become final value - if (LUA_CallAction("A_RelayCustomValue", actor)) + if (LUA_CallAction(A_RELAYCUSTOMVALUE, actor)) return; if ((!(locvar1 >> 16) && !actor->target) || ((locvar1 >> 16) && !actor->tracer)) @@ -10477,7 +10477,7 @@ void A_CusValAction(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; - if (LUA_CallAction("A_CusValAction", actor)) + if (LUA_CallAction(A_CUSVALACTION, actor)) return; if (locvar2 == 5) @@ -10528,7 +10528,7 @@ void A_ForceStop(mobj_t *actor) { INT32 locvar1 = var1; - if (LUA_CallAction("A_ForceStop", actor)) + if (LUA_CallAction(A_FORCESTOP, actor)) return; actor->momx = actor->momy = 0; @@ -10547,7 +10547,7 @@ void A_ForceWin(mobj_t *actor) { INT32 i; - if (LUA_CallAction("A_ForceWin", actor)) + if (LUA_CallAction(A_FORCEWIN, actor)) return; for (i = 0; i < MAXPLAYERS; i++) @@ -10581,7 +10581,7 @@ void A_SpikeRetract(mobj_t *actor) { INT32 locvar1 = var1; - if (LUA_CallAction("A_SpikeRetract", actor)) + if (LUA_CallAction(A_SPIKERETRACT, actor)) return; if (actor->flags & MF_NOBLOCKMAP) @@ -10665,7 +10665,7 @@ void A_Repeat(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; - if (LUA_CallAction("A_Repeat", actor)) + if (LUA_CallAction(A_REPEAT, actor)) return; if (locvar1 && (!actor->extravalue2 || actor->extravalue2 > locvar1)) @@ -10690,7 +10690,7 @@ void A_SetScale(mobj_t *actor) INT32 locvar2 = var2; mobj_t *target; - if (LUA_CallAction("A_SetScale", actor)) + if (LUA_CallAction(A_SETSCALE, actor)) return; if (locvar1 <= 0) @@ -10733,7 +10733,7 @@ void A_RemoteDamage(mobj_t *actor) mobj_t *target; // we MUST have a target mobj_t *source = NULL; // on the other hand we don't necessarily need a source - if (LUA_CallAction("A_RemoteDamage", actor)) + if (LUA_CallAction(A_REMOTEDAMAGE, actor)) return; if (locvar1 == 1) @@ -10786,7 +10786,7 @@ void A_HomingChase(mobj_t *actor) fixed_t dist; fixed_t speedmul; - if (LUA_CallAction("A_HomingChase", actor)) + if (LUA_CallAction(A_HOMINGCHASE, actor)) return; if (locvar2 == 1) @@ -10839,7 +10839,7 @@ void A_TrapShot(mobj_t *actor) fixed_t x, y, z; fixed_t speed; - if (LUA_CallAction("A_TrapShot", actor)) + if (LUA_CallAction(A_TRAPSHOT, actor)) return; x = actor->x + P_ReturnThrustX(actor, actor->angle, FixedMul(frontoff*FRACUNIT, actor->scale)); @@ -10904,7 +10904,7 @@ void A_VileTarget(mobj_t *actor) mobjtype_t fogtype; INT32 i; - if (LUA_CallAction("A_VileTarget", actor)) + if (LUA_CallAction(A_VILETARGET, actor)) return; if (!actor->target) @@ -10991,7 +10991,7 @@ void A_VileAttack(mobj_t *actor) mobj_t *fire; INT32 i; - if (LUA_CallAction("A_VileAttack", actor)) + if (LUA_CallAction(A_VILEATTACK, actor)) return; if (!actor->target) @@ -11103,7 +11103,7 @@ void A_VileFire(mobj_t *actor) INT32 locvar2 = var2; mobj_t *dest; - if (LUA_CallAction("A_VileFire", actor)) + if (LUA_CallAction(A_VILEFIRE, actor)) return; dest = actor->tracer; @@ -11189,7 +11189,7 @@ void A_BrakChase(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; - if (LUA_CallAction("A_BrakChase", actor)) + if (LUA_CallAction(A_BRAKCHASE, actor)) return; // Set new tics NOW, in case the state changes while we're doing this and we try applying this to the painstate or something silly @@ -11309,7 +11309,7 @@ void A_BrakFireShot(mobj_t *actor) fixed_t x, y, z; INT32 locvar1 = var1; - if (LUA_CallAction("A_BrakFireShot", actor)) + if (LUA_CallAction(A_BRAKFIRESHOT, actor)) return; if (!actor->target) @@ -11372,7 +11372,7 @@ void A_BrakLobShot(mobj_t *actor) INT32 locvar2 = var2 & 0x0000FFFF; INT32 aimDirect = var2 & 0xFFFF0000; - if (LUA_CallAction("A_BrakLobShot", actor)) + if (LUA_CallAction(A_BRAKLOBSHOT, actor)) return; if (!actor->target) @@ -11478,7 +11478,7 @@ void A_NapalmScatter(mobj_t *actor) INT32 i; // for-loop cursor mobj_t *mo; // each and every spawned napalm burst - if (LUA_CallAction("A_NapalmScatter", actor)) + if (LUA_CallAction(A_NAPALMSCATTER, actor)) return; // Some quick sanity-checking @@ -11530,7 +11530,7 @@ void A_SpawnFreshCopy(mobj_t *actor) { mobj_t *newObject; - if (LUA_CallAction("A_SpawnFreshCopy", actor)) + if (LUA_CallAction(A_SPAWNFRESHCOPY, actor)) return; newObject = P_SpawnMobjFromMobj(actor, 0, 0, 0, actor->type); @@ -11606,7 +11606,7 @@ void A_FlickySpawn(mobj_t *actor) INT32 test = (var1 >> 16); SINT8 moveforward = 0; - if (LUA_CallAction("A_FlickySpawn", actor)) + if (LUA_CallAction(A_FLICKYSPAWN, actor)) return; if (test & 1) @@ -11674,7 +11674,7 @@ void A_FlickyCenter(mobj_t *actor) UINT8 flickycolor = ((locvar1 >> 16) & 0xFF); UINT8 flickyflags = ((locvar1 >> 20) & 0xF); - if (LUA_CallAction("A_FlickyCenter", actor)) + if (LUA_CallAction(A_FLICKYCENTER, actor)) return; if (!actor->tracer) @@ -11794,7 +11794,7 @@ void A_FlickyAim(mobj_t *actor) INT32 locvar2 = var2; boolean flickyhitwall = false; - if (LUA_CallAction("A_FlickyAim", actor)) + if (LUA_CallAction(A_FLICKYAIM, actor)) return; if ((actor->momx == actor->momy && actor->momy == 0) @@ -11894,7 +11894,7 @@ void A_FlickyFly(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; - if (LUA_CallAction("A_FlickyFly", actor)) + if (LUA_CallAction(A_FLICKYFLY, actor)) return; P_InternalFlickyFly(actor, locvar1, locvar2, @@ -11914,7 +11914,7 @@ void A_FlickySoar(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; - if (LUA_CallAction("A_FlickySoar", actor)) + if (LUA_CallAction(A_FLICKYSOAR, actor)) return; P_InternalFlickyFly(actor, locvar1, locvar2, @@ -11938,7 +11938,7 @@ void A_FlickyCoast(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; - if (LUA_CallAction("A_FlickyCoast", actor)) + if (LUA_CallAction(A_FLICKYCOAST, actor)) return; if (actor->eflags & MFE_UNDERWATER) @@ -11985,7 +11985,7 @@ void A_FlickyHop(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; - if (LUA_CallAction("A_FlickyHop", actor)) + if (LUA_CallAction(A_FLICKYHOP, actor)) return; P_InternalFlickyHop(actor, locvar1, locvar2, actor->angle); @@ -12004,7 +12004,7 @@ void A_FlickyFlounder(mobj_t *actor) INT32 locvar2 = var2; angle_t hopangle; - if (LUA_CallAction("A_FlickyFlounder", actor)) + if (LUA_CallAction(A_FLICKYFLOUNDER, actor)) return; locvar1 *= (P_RandomKey(2) + 1); @@ -12026,7 +12026,7 @@ void A_FlickyCheck(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; - if (LUA_CallAction("A_FlickyCheck", actor)) + if (LUA_CallAction(A_FLICKYCHECK, actor)) return; if (actor->target @@ -12063,7 +12063,7 @@ void A_FlickyHeightCheck(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; - if (LUA_CallAction("A_FlickyHeightCheck", actor)) + if (LUA_CallAction(A_FLICKYHEIGHTCHECK, actor)) return; if (actor->target @@ -12098,7 +12098,7 @@ void A_FlickyFlutter(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; - if (LUA_CallAction("A_FlickyFlutter", actor)) + if (LUA_CallAction(A_FLICKYFLUTTER, actor)) return; var1 = locvar1; @@ -12129,7 +12129,7 @@ void A_FlameParticle(mobj_t *actor) fixed_t rad, hei; mobj_t *particle; - if (LUA_CallAction("A_FlameParticle", actor)) + if (LUA_CallAction(A_FLAMEPARTICLE, actor)) return; if (!type) @@ -12157,7 +12157,7 @@ void A_FadeOverlay(mobj_t *actor) mobj_t *fade; INT32 locvar1 = var1; - if (LUA_CallAction("A_FadeOverlay", actor)) + if (LUA_CallAction(A_FADEOVERLAY, actor)) return; fade = P_SpawnGhostMobj(actor); @@ -12198,7 +12198,7 @@ void A_Boss5Jump(mobj_t *actor) // INT32 locvar1 = var1; // INT32 locvar2 = var2; - if (LUA_CallAction("A_Boss5Jump", actor)) + if (LUA_CallAction(A_BOSS5JUMP, actor)) return; if (!actor->tracer) @@ -12275,7 +12275,7 @@ void A_LightBeamReset(mobj_t *actor) // INT32 locvar1 = var1; // INT32 locvar2 = var2; - if (LUA_CallAction("A_LightBeamReset", actor)) + if (LUA_CallAction(A_LIGHTBEAMRESET, actor)) return; actor->destscale = FRACUNIT + P_SignedRandom()*FRACUNIT/256; @@ -12305,7 +12305,7 @@ void A_MineExplode(mobj_t *actor) // INT32 locvar1 = var1; // INT32 locvar2 = var2; - if (LUA_CallAction("A_MineExplode", actor)) + if (LUA_CallAction(A_MINEEXPLODE, actor)) return; A_Scream(actor); @@ -12358,7 +12358,7 @@ void A_MineRange(mobj_t *actor) INT32 locvar1 = var1; // INT32 locvar2 = var2; - if (LUA_CallAction("A_MineRange", actor)) + if (LUA_CallAction(A_MINERANGE, actor)) return; if (!actor->target) @@ -12384,7 +12384,7 @@ void A_ConnectToGround(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; - if (LUA_CallAction("A_ConnectToGround", actor)) + if (LUA_CallAction(A_CONNECTTOGROUND, actor)) return; if (actor->subsector->sector->ffloors) @@ -12443,7 +12443,7 @@ void A_SpawnParticleRelative(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; - if (LUA_CallAction("A_SpawnParticleRelative", actor)) + if (LUA_CallAction(A_SPAWNPARTICLERELATIVE, actor)) return; @@ -12481,7 +12481,7 @@ void A_MultiShotDist(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; - if (LUA_CallAction("A_MultiShotDist", actor)) + if (LUA_CallAction(A_MULTISHOTDIST, actor)) return; { @@ -12520,7 +12520,7 @@ void A_WhoCaresIfYourSonIsABee(mobj_t *actor) fixed_t foffsety; mobj_t *son; - if (LUA_CallAction("A_WhoCaresIfYourSonIsABee", actor)) + if (LUA_CallAction(A_WHOCARESIFYOURSONISABEE, actor)) return; A_FaceTarget(actor); @@ -12554,7 +12554,7 @@ void A_ParentTriesToSleep(mobj_t *actor) { INT32 locvar1 = var1; - if (LUA_CallAction("A_ParentTriesToSleep", actor)) + if (LUA_CallAction(A_PARENTTRIESTOSLEEP, actor)) return; if (actor->extravalue1) @@ -12582,7 +12582,7 @@ void A_ParentTriesToSleep(mobj_t *actor) // void A_CryingToMomma(mobj_t *actor) { - if (LUA_CallAction("A_CryingToMomma", actor)) + if (LUA_CallAction(A_CRYINGTOMOMMA, actor)) return; if (actor->tracer) @@ -12612,7 +12612,7 @@ void A_CheckFlags2(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; - if (LUA_CallAction("A_CheckFlags2", actor)) + if (LUA_CallAction(A_CHECKFLAGS2, actor)) return; if (actor->flags2 & locvar1) @@ -12633,7 +12633,7 @@ void A_Boss5FindWaypoint(mobj_t *actor) UINT32 i; UINT8 extrainfo = (actor->spawnpoint ? actor->spawnpoint->extrainfo : 0); - if (LUA_CallAction("A_Boss5FindWaypoint", actor)) + if (LUA_CallAction(A_BOSS5FINDWAYPOINT, actor)) return; avoidcenter = !actor->tracer || (actor->health == actor->info->damage+1); @@ -12850,7 +12850,7 @@ void A_DoNPCSkid(mobj_t *actor) INT32 locvar2 = var2; fixed_t x, y, z; - if (LUA_CallAction("A_DoNPCSkid", actor)) + if (LUA_CallAction(A_DONPCSKID, actor)) return; x = actor->x; @@ -12906,7 +12906,7 @@ void A_DoNPCPain(mobj_t *actor) fixed_t vspeed = 0; fixed_t hspeed = FixedMul(4*FRACUNIT, actor->scale); - if (LUA_CallAction("A_DoNPCPain", actor)) + if (LUA_CallAction(A_DONPCPAIN, actor)) return; actor->flags &= ~(MF_NOGRAVITY|MF_NOCLIP|MF_NOCLIPHEIGHT); @@ -12954,7 +12954,7 @@ void A_PrepareRepeat(mobj_t *actor) { INT32 locvar1 = var1; - if (LUA_CallAction("A_PrepareRepeat", actor)) + if (LUA_CallAction(A_PREPAREREPEAT, actor)) return; actor->extravalue2 = locvar1; @@ -12975,7 +12975,7 @@ void A_Boss5ExtraRepeat(mobj_t *actor) INT32 locspawn; INT32 lochealth; - if (LUA_CallAction("A_Boss5ExtraRepeat", actor)) + if (LUA_CallAction(A_BOSS5EXTRAREPEAT, actor)) return; if (actor->extravalue2 > 0 && !(actor->flags2 & MF2_FRET)) @@ -13007,7 +13007,7 @@ void A_Boss5ExtraRepeat(mobj_t *actor) // void A_Boss5Calm(mobj_t *actor) { - if (LUA_CallAction("A_Boss5Calm", actor)) + if (LUA_CallAction(A_BOSS5CALM, actor)) return; actor->flags |= MF_SHOOTABLE; @@ -13026,7 +13026,7 @@ void A_Boss5CheckOnGround(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; - if (LUA_CallAction("A_Boss5CheckOnGround", actor)) + if (LUA_CallAction(A_BOSS5CHECKONGROUND, actor)) return; if ((!(actor->eflags & MFE_VERTICALFLIP) && actor->z <= actor->floorz) @@ -13057,7 +13057,7 @@ void A_Boss5CheckFalling(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; - if (LUA_CallAction("A_Boss5CheckFalling", actor)) + if (LUA_CallAction(A_BOSS5CHECKFALLING, actor)) return; if (actor->health && actor->extravalue2 > 1) @@ -13086,7 +13086,7 @@ void A_Boss5PinchShot(mobj_t *actor) fixed_t zoffset; mobj_t *missile; - if (LUA_CallAction("A_Boss5PinchShot", actor)) + if (LUA_CallAction(A_BOSS5PINCHSHOT, actor)) return; if (actor->health > actor->info->damage) @@ -13121,7 +13121,7 @@ void A_Boss5MakeItRain(mobj_t *actor) INT32 offset = (48 + locvar2)<<16; // upper 16 bits, not fixed_t! INT32 i; - if (LUA_CallAction("A_Boss5MakeItRain", actor)) + if (LUA_CallAction(A_BOSS5MAKEITRAIN, actor)) return; actor->flags2 |= MF2_STRONGBOX; @@ -13157,7 +13157,7 @@ void A_Boss5MakeJunk(mobj_t *actor) angle_t ang; INT32 i = ((locvar2 & 1) ? 8 : 1); - if (LUA_CallAction("A_Boss5MakeJunk", actor)) + if (LUA_CallAction(A_BOSS5MAKEJUNK, actor)) return; if (locvar1 < 0 && (actor->flags2 & MF2_SLIDEPUSH)) // this entire action is a hack, don't judge me @@ -13247,7 +13247,7 @@ void A_LookForBetter(mobj_t *actor) { INT32 locvar1 = var1; - if (LUA_CallAction("A_LookForBetter", actor)) + if (LUA_CallAction(A_LOOKFORBETTER, actor)) return; P_LookForPlayers(actor, (locvar1 & 65535), false, FixedMul((locvar1 >> 16)*FRACUNIT, actor->scale)); @@ -13307,7 +13307,7 @@ void A_Boss5BombExplode(mobj_t *actor) { INT32 locvar1 = var1; - if (LUA_CallAction("A_Boss5BombExplode", actor)) + if (LUA_CallAction(A_BOSS5BOMBEXPLODE, actor)) return; // The original Lua script did not use |= to add flags but just set these flags exactly apparently? @@ -13417,7 +13417,7 @@ void A_DustDevilThink(mobj_t *actor) INT32 bx, by, xl, xh, yl, yh; fixed_t radius = actor->radius; - if (LUA_CallAction("A_DustDevilThink", actor)) + if (LUA_CallAction(A_DUSTDEVILTHINK, actor)) return; //Chained thinker for the spiralling dust column. @@ -13559,7 +13559,7 @@ void A_TNTExplode(mobj_t *actor) INT32 xl, xh, yl, yh; static mappoint_t epicenter = {0,0,0}; - if (LUA_CallAction("A_TNTExplode", actor)) + if (LUA_CallAction(A_TNTEXPLODE, actor)) return; if (actor->tracer) @@ -13625,7 +13625,7 @@ void A_DebrisRandom(mobj_t *actor) { INT32 locvar1 = var1; - if (LUA_CallAction("A_DebrisRandom", actor)) + if (LUA_CallAction(A_DEBRISRANDOM, actor)) return; actor->frame |= P_RandomRange(0, locvar1); @@ -13666,7 +13666,7 @@ void A_TrainCameo(mobj_t *actor) fixed_t span = locvar1*FRACUNIT; fixed_t len = locvar2*FRACUNIT; - if (LUA_CallAction("A_TrainCameo", actor)) + if (LUA_CallAction(A_TRAINCAMEO, actor)) return; //Spawn sides. @@ -13704,7 +13704,7 @@ void A_TrainCameo2(mobj_t *actor) fixed_t span = locvar1*FRACUNIT; fixed_t len = locvar2*FRACUNIT; - if (LUA_CallAction("A_TrainCameo2", actor)) + if (LUA_CallAction(A_TRAINCAMEO2, actor)) return; //Spawn sides. @@ -13730,7 +13730,7 @@ void A_CanarivoreGas(mobj_t *actor) { INT32 locvar1 = var1; - if (LUA_CallAction("A_CanarivoreGas", actor)) + if (LUA_CallAction(A_CANARIVOREGAS, actor)) return; P_DustRing(locvar1, 4, actor->x, actor->y, actor->z + actor->height / 5, 18, 0, FRACUNIT/10, actor->scale); @@ -13751,7 +13751,7 @@ void A_KillSegments(mobj_t *actor) mobj_t *seg = actor->tracer; INT32 fuse = locvar1 ? locvar1 : TICRATE/2; - if (LUA_CallAction("A_KillSegments", actor)) + if (LUA_CallAction(A_KILLSEGMENTS, actor)) return; while (seg) @@ -13834,7 +13834,7 @@ void A_SnapperSpawn(mobj_t *actor) INT32 i; mobj_t *seg; - if (LUA_CallAction("A_SnapperSpawn", actor)) + if (LUA_CallAction(A_SNAPPERSPAWN, actor)) return; // It spawns 1 head. @@ -13884,7 +13884,7 @@ void A_SnapperThinker(mobj_t *actor) fixed_t dist; boolean chasing; - if (LUA_CallAction("A_SnapperThinker", actor)) + if (LUA_CallAction(A_SNAPPERTHINKER, actor)) return; // We make a check just in case there's no spawnpoint. @@ -14005,7 +14005,7 @@ void A_SaloonDoorSpawn(mobj_t *actor) mobj_t *door; mobjflag2_t ambush = (actor->flags2 & MF2_AMBUSH); - if (LUA_CallAction("A_SaloonDoorSpawn", actor)) + if (LUA_CallAction(A_SALOONDOORSPAWN, actor)) return; if (!locvar1) @@ -14042,7 +14042,7 @@ void A_MinecartSparkThink(mobj_t *actor) fixed_t dz, dm; UINT8 i; - if (LUA_CallAction("A_MinecartSparkThink", actor)) + if (LUA_CallAction(A_MINECARTSPARKTHINK, actor)) return; if (actor->momz == 0 && P_IsObjectOnGround(actor)) @@ -14076,7 +14076,7 @@ void A_ModuloToState(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; - if (LUA_CallAction("A_ModuloToState", actor)) + if (LUA_CallAction(A_MODULOTOSTATE, actor)) return; if ((modulothing % locvar1 == 0)) @@ -14095,7 +14095,7 @@ void A_LavafallRocks(mobj_t *actor) { UINT8 i; - if (LUA_CallAction("A_LavafallRocks", actor)) + if (LUA_CallAction(A_LAVAFALLROCKS, actor)) return; // Don't spawn rocks unless a player is relatively close by. @@ -14126,7 +14126,7 @@ void A_LavafallLava(mobj_t *actor) mobj_t *lavafall; UINT8 i; - if (LUA_CallAction("A_LavafallLava", actor)) + if (LUA_CallAction(A_LAVAFALLLAVA, actor)) return; if ((40 - actor->fuse) % (2*(actor->scale >> FRACBITS))) @@ -14154,7 +14154,7 @@ void A_LavafallLava(mobj_t *actor) // void A_FallingLavaCheck(mobj_t *actor) { - if (LUA_CallAction("A_FallingLavaCheck", actor)) + if (LUA_CallAction(A_FALLINGLAVACHECK, actor)) return; if (actor->eflags & MFE_TOUCHWATER || P_IsObjectOnGround(actor)) @@ -14179,7 +14179,7 @@ void A_FireShrink(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; - if (LUA_CallAction("A_FireShrink", actor)) + if (LUA_CallAction(A_FIRESHRINK, actor)) return; actor->destscale = locvar1; @@ -14203,7 +14203,7 @@ void A_SpawnPterabytes(mobj_t *actor) UINT8 amount = 1; UINT8 i; - if (LUA_CallAction("A_SpawnPterabytes", actor)) + if (LUA_CallAction(A_SPAWNPTERABYTES, actor)) return; if (actor->spawnpoint) @@ -14238,7 +14238,7 @@ void A_PterabyteHover(mobj_t *actor) { angle_t ang, fa; - if (LUA_CallAction("A_PterabyteHover", actor)) + if (LUA_CallAction(A_PTERABYTEHOVER, actor)) return; P_InstaThrust(actor, actor->angle, actor->info->speed); @@ -14260,7 +14260,7 @@ void A_RolloutSpawn(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; - if (LUA_CallAction("A_RolloutSpawn", actor)) + if (LUA_CallAction(A_ROLLOUTSPAWN, actor)) return; if (!(actor->target) @@ -14296,7 +14296,7 @@ void A_RolloutRock(mobj_t *actor) fixed_t speed = P_AproxDistance(actor->momx, actor->momy), topspeed = FixedMul(actor->info->speed, actor->scale); boolean inwater = actor->eflags & (MFE_TOUCHWATER|MFE_UNDERWATER); - if (LUA_CallAction("A_RolloutRock", actor)) + if (LUA_CallAction(A_ROLLOUTROCK, actor)) return; actor->friction = FRACUNIT; // turns out riding on solids sucks, so let's just make it easier on ourselves @@ -14379,7 +14379,7 @@ void A_DragonbomberSpawn(mobj_t *actor) UINT8 i; mobj_t *mo = actor; - if (LUA_CallAction("A_DragonbomberSpawn", actor)) + if (LUA_CallAction(A_DRAGONBOMBERSPAWN, actor)) return; for (i = 0; i < var1; i++) // spawn tail segments @@ -14415,7 +14415,7 @@ void A_DragonWing(mobj_t *actor) mobj_t *target = actor->target; fixed_t x, y; - if (LUA_CallAction("A_DragonWing", actor)) + if (LUA_CallAction(A_DRAGONWING, actor)) return; if (target == NULL || !target->health) @@ -14448,7 +14448,7 @@ void A_DragonSegment(mobj_t *actor) fixed_t ydist; fixed_t zdist; - if (LUA_CallAction("A_DragonSegment", actor)) + if (LUA_CallAction(A_DRAGONSEGMENT, actor)) return; if (target == NULL || !target->health) @@ -14486,7 +14486,7 @@ void A_ChangeHeight(mobj_t *actor) fixed_t height = locvar1; boolean reverse; - if (LUA_CallAction("A_ChangeHeight", actor)) + if (LUA_CallAction(A_CHANGEHEIGHT, actor)) return; reverse = (actor->eflags & MFE_VERTICALFLIP) || (actor->flags2 & MF2_OBJECTFLIP); From d3199ac779cce0f05651b117324d6cf87432236d Mon Sep 17 00:00:00 2001 From: James R Date: Sat, 14 Nov 2020 16:18:54 -0800 Subject: [PATCH 0336/1080] Fix one last instance of printing address diff --- 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 102c9b9a7..d3e91d71a 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -1341,7 +1341,7 @@ static void P_LoadSidedefs(UINT8 *data) || (msd->toptexture[0] >= 'A' && msd->toptexture[0] <= 'F')) sd->toptexture = axtoi(msd->toptexture); else - I_Error("Custom FOF (line id %d) needs a value in the linedef's back side upper texture field.", sd->line - lines); + I_Error("Custom FOF (line id %s) needs a value in the linedef's back side upper texture field.", sizeu1(sd->line - lines)); sd->midtexture = R_TextureNumForName(msd->midtexture); sd->bottomtexture = R_TextureNumForName(msd->bottomtexture); From b03d2b16edbe3d351c0f93e7d299fff70a9fe699 Mon Sep 17 00:00:00 2001 From: Louis-Antoine Date: Sun, 15 Nov 2020 01:23:50 +0100 Subject: [PATCH 0337/1080] Delete unneeded check --- src/lua_infolib.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lua_infolib.c b/src/lua_infolib.c index e17994974..cf23eff62 100644 --- a/src/lua_infolib.c +++ b/src/lua_infolib.c @@ -377,7 +377,7 @@ static int lib_setSpriteInfo(lua_State *L) if (hud_running) return luaL_error(L, "Do not alter spriteinfo_t in HUD rendering code!"); if (hook_cmd_running) - return luaL_error(L, "Do not alter spriteinfo_t in CMD building code!"); + return luaL_error(L, "Do not alter spriteinfo_t in CMD building code!"); lua_remove(L, 1); { @@ -822,7 +822,7 @@ boolean LUA_CallAction(enum actionnum actionnum, mobj_t *actor) { I_Assert(actor != NULL); - if (!(gL && actionsoverridden[actionnum])) // Lua isn't loaded, or the action is not overriden, + if (!actionsoverridden[actionnum]) // The action is not overriden, return false; // action not called. if (superstack && fasticmp(actionpointers[actionnum].name, superactions[superstack-1])) // the action is calling itself, From 26b6b33220309c70dfb6475bc1296911cd4dfc36 Mon Sep 17 00:00:00 2001 From: lachwright Date: Sun, 15 Nov 2020 15:52:55 +1100 Subject: [PATCH 0338/1080] Add parentheses --- src/sdl/i_video.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index 413ba0b4e..972d208d4 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -42,7 +42,7 @@ #ifdef HAVE_IMAGE #include "SDL_image.h" -#elif defined (__unix__) || !defined(__APPLE__) && defined (UNIXCOMMON) // Windows & Mac don't need this, as SDL will do it for us. +#elif defined (__unix__) || (!defined(__APPLE__) && defined (UNIXCOMMON)) // Windows & Mac don't need this, as SDL will do it for us. #define LOAD_XPM //I want XPM! #include "IMG_xpm.c" //Alam: I don't want to add SDL_Image.dll/so #define HAVE_IMAGE //I have SDL_Image, sortof From 5454068843860d41ba2ae294f8638684b8cb54ef Mon Sep 17 00:00:00 2001 From: lachwright Date: Mon, 16 Nov 2020 17:37:12 +1100 Subject: [PATCH 0339/1080] Uncap palette lump palettes & allow flashpal palettes to display during pause --- src/st_stuff.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/st_stuff.c b/src/st_stuff.c index 86e0b3754..246272c3a 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -203,9 +203,7 @@ void ST_doPaletteStuff(void) { INT32 palette; - if (paused || P_AutoPause()) - palette = 0; - else if (stplyr && stplyr->flashcount) + if (stplyr && stplyr->flashcount) palette = stplyr->flashpal; else palette = 0; @@ -215,8 +213,6 @@ void ST_doPaletteStuff(void) palette = 0; // No flashpals here in OpenGL #endif - palette = min(max(palette, 0), 13); - if (palette != st_palette) { st_palette = palette; From fb40a2836597f3aa751f0ac68aab2a87b93ecf02 Mon Sep 17 00:00:00 2001 From: SMS Alfredo <65426124+SMS-Alfredo@users.noreply.github.com> Date: Tue, 17 Nov 2020 11:47:33 -0600 Subject: [PATCH 0340/1080] Do deh thing --- src/p_user.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/p_user.c b/src/p_user.c index 10b7e970e..a9194fbb2 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -4524,6 +4524,7 @@ void P_DoJump(player_t *player, boolean soundandstate) player->mo->eflags &= ~MFE_APPLYPMOMZ; player->pflags |= P_GetJumpFlags(player);; + player->pflags &= ~PF_SPINNING; if (soundandstate) { From ad9bf6085f0845c9fde5348c7299136735a83d84 Mon Sep 17 00:00:00 2001 From: SMS Alfredo <65426124+SMS-Alfredo@users.noreply.github.com> Date: Wed, 18 Nov 2020 11:28:31 -0600 Subject: [PATCH 0341/1080] Fix no spin characters being able to damage enemies with their jump out of a spin without removing PF_SPINNING --- src/p_user.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index a9194fbb2..c1b11965b 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -1135,7 +1135,8 @@ boolean P_PlayerCanDamage(player_t *player, mobj_t *thing) return true; // Spinning. - if (player->pflags & PF_SPINNING) + if ((player->pflags & PF_SPINNING) + && !((player->pflags & PF_JUMPED) && (player->pflags & PF_NOJUMPDAMAGE))) return true; if (player->dashmode >= DASHMODE_THRESHOLD && (player->charflags & (SF_DASHMODE|SF_MACHINE)) == (SF_DASHMODE|SF_MACHINE)) @@ -4524,7 +4525,6 @@ void P_DoJump(player_t *player, boolean soundandstate) player->mo->eflags &= ~MFE_APPLYPMOMZ; player->pflags |= P_GetJumpFlags(player);; - player->pflags &= ~PF_SPINNING; if (soundandstate) { From 16fd754a398901eb403faff323adbe646451fa36 Mon Sep 17 00:00:00 2001 From: SMS Alfredo <65426124+SMS-Alfredo@users.noreply.github.com> Date: Wed, 18 Nov 2020 11:49:17 -0600 Subject: [PATCH 0342/1080] Allow forcespin sectors to work on no spin characters --- src/p_spec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/p_spec.c b/src/p_spec.c index a1afdd00d..99a0a0994 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -4503,7 +4503,7 @@ DoneSection2: P_InstaThrust(player->mo, player->mo->angle, linespeed); - if ((lines[i].flags & ML_EFFECT5) && (player->charability2 == CA2_SPINDASH)) // Roll! + if (lines[i].flags & ML_EFFECT5) // Roll! { if (!(player->pflags & PF_SPINNING)) player->pflags |= PF_SPINNING; @@ -4669,7 +4669,7 @@ DoneSection2: break; case 7: // Make player spin - if (!(player->pflags & PF_SPINNING) && P_IsObjectOnGround(player->mo) && (player->charability2 == CA2_SPINDASH)) + if (!(player->pflags & PF_SPINNING) && P_IsObjectOnGround(player->mo)) { player->pflags |= PF_SPINNING; P_SetPlayerMobjState(player->mo, S_PLAY_ROLL); From 09644d69c084484762995f27ef3598ef383aa297 Mon Sep 17 00:00:00 2001 From: SMS Alfredo <65426124+SMS-Alfredo@users.noreply.github.com> Date: Wed, 18 Nov 2020 12:01:06 -0600 Subject: [PATCH 0343/1080] Don't force S_PLAY_SPIN when landing with PF_SPINNING if you have certain PA flags --- src/p_user.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/p_user.c b/src/p_user.c index c1b11965b..9f5484105 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -2330,7 +2330,8 @@ boolean P_PlayerHitFloor(player_t *player, boolean dorollstuff) P_MobjCheckWater(player->mo); if (player->pflags & PF_SPINNING) { - if (player->mo->state-states != S_PLAY_ROLL && !(player->pflags & PF_STARTDASH)) + if (player->mo->state-states != S_PLAY_ROLL && !(player->pflags & PF_STARTDASH) && player->panim != PA_ROLL + && player->panim != PA_ETC && player->panim != PA_ABILITY && player->panim != PA_ABILITY2) { P_SetPlayerMobjState(player->mo, S_PLAY_ROLL); S_StartSound(player->mo, sfx_spin); From 01a03a4daa330958ef4633691e4d150379e0d803 Mon Sep 17 00:00:00 2001 From: SMS Alfredo <65426124+SMS-Alfredo@users.noreply.github.com> Date: Wed, 18 Nov 2020 12:03:48 -0600 Subject: [PATCH 0344/1080] lmao formatting --- src/p_user.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index 9f5484105..004ff71d1 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -2330,8 +2330,9 @@ boolean P_PlayerHitFloor(player_t *player, boolean dorollstuff) P_MobjCheckWater(player->mo); if (player->pflags & PF_SPINNING) { - if (player->mo->state-states != S_PLAY_ROLL && !(player->pflags & PF_STARTDASH) && player->panim != PA_ROLL - && player->panim != PA_ETC && player->panim != PA_ABILITY && player->panim != PA_ABILITY2) + if (player->mo->state-states != S_PLAY_ROLL && !(player->pflags & PF_STARTDASH) + && player->panim != PA_ROLL && player->panim != PA_ETC + && player->panim != PA_ABILITY && player->panim != PA_ABILITY2) { P_SetPlayerMobjState(player->mo, S_PLAY_ROLL); S_StartSound(player->mo, sfx_spin); From 7ad8aa14770d923ac3501e44af4eff4ea7cd802e Mon Sep 17 00:00:00 2001 From: SMS Alfredo <65426124+SMS-Alfredo@users.noreply.github.com> Date: Wed, 18 Nov 2020 12:27:09 -0600 Subject: [PATCH 0345/1080] Allow the Forcespin sector type to be used with intangible fofs Didn't think simply removing the P_IsObjectOnGround was gonna work, but apparently it does. --- src/p_spec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_spec.c b/src/p_spec.c index 99a0a0994..9e0203619 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -4669,7 +4669,7 @@ DoneSection2: break; case 7: // Make player spin - if (!(player->pflags & PF_SPINNING) && P_IsObjectOnGround(player->mo)) + if (!(player->pflags & PF_SPINNING)) { player->pflags |= PF_SPINNING; P_SetPlayerMobjState(player->mo, S_PLAY_ROLL); From 9163e7309227965894719d1bd08d1f68a1c9c08c Mon Sep 17 00:00:00 2001 From: SMS Alfredo <65426124+SMS-Alfredo@users.noreply.github.com> Date: Wed, 18 Nov 2020 12:35:40 -0600 Subject: [PATCH 0346/1080] Allow no spin characters to water skip while spinning --- 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 4fc561b20..004207a07 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -3393,7 +3393,7 @@ void P_MobjCheckWater(mobj_t *mobj) } // skipping stone! - if (p && (p->charability2 == CA2_SPINDASH) && p->speed/2 > abs(mobj->momz) + if (p && p->speed/2 > abs(mobj->momz) && ((p->pflags & (PF_SPINNING|PF_JUMPED)) == PF_SPINNING) && ((!(mobj->eflags & MFE_VERTICALFLIP) && thingtop - mobj->momz > mobj->watertop) || ((mobj->eflags & MFE_VERTICALFLIP) && mobj->z - mobj->momz < mobj->waterbottom))) From 389763a550a7c399c0d44d16aa8b0d81c5d91dc2 Mon Sep 17 00:00:00 2001 From: Jaime Ita Passos Date: Thu, 19 Nov 2020 00:59:37 -0300 Subject: [PATCH 0347/1080] Update R_DrawFloorSprite_NPO2_8 and R_DrawTranslucentFloorSprite_NPO2_8 to have the lastest NPO2 optimizations --- src/r_draw8_npo2.c | 86 ++++++++++++++++++++++++++++++++++------------ 1 file changed, 64 insertions(+), 22 deletions(-) diff --git a/src/r_draw8_npo2.c b/src/r_draw8_npo2.c index ea5691e7c..a34a20e9a 100644 --- a/src/r_draw8_npo2.c +++ b/src/r_draw8_npo2.c @@ -818,6 +818,8 @@ void R_DrawFloorSprite_NPO2_8 (void) fixed_t xposition; fixed_t yposition; fixed_t xstep, ystep; + fixed_t x, y; + fixed_t fixedwidth, fixedheight; UINT16 *source; UINT8 *translation; @@ -836,20 +838,39 @@ void R_DrawFloorSprite_NPO2_8 (void) translation = ds_translation; dest = ylookup[ds_y] + columnofs[ds_x1]; + fixedwidth = ds_flatwidth << FRACBITS; + fixedheight = ds_flatheight << FRACBITS; + + // Fix xposition and yposition if they are out of bounds. + if (xposition < 0) + xposition = fixedwidth - ((UINT32)(fixedwidth - xposition) % fixedwidth); + else if (xposition >= fixedwidth) + xposition %= fixedwidth; + if (yposition < 0) + yposition = fixedheight - ((UINT32)(fixedheight - yposition) % fixedheight); + else if (yposition >= fixedheight) + yposition %= fixedheight; + while (count-- && dest <= deststop) { - fixed_t x = (xposition >> FRACBITS); - fixed_t y = (yposition >> FRACBITS); - - // Carefully align all of my Friends. - if (x < 0) - x = ds_flatwidth - ((UINT32)(ds_flatwidth - x) % ds_flatwidth); - if (y < 0) - y = ds_flatheight - ((UINT32)(ds_flatheight - y) % ds_flatheight); - - x %= ds_flatwidth; - y %= ds_flatheight; + // The loops here keep the texture coordinates within the texture. + // They will rarely iterate multiple times, and are cheaper than a modulo operation, + // even if using libdivide. + if (xstep < 0) // These if statements are hopefully hoisted by the compiler to above this loop + while (xposition < 0) + xposition += fixedwidth; + else + while (xposition >= fixedwidth) + xposition -= fixedwidth; + if (ystep < 0) + while (yposition < 0) + yposition += fixedheight; + else + while (yposition >= fixedheight) + yposition -= fixedheight; + x = (xposition >> FRACBITS); + y = (yposition >> FRACBITS); val = source[((y * ds_flatwidth) + x)]; if (val & 0xFF00) *dest = colormap[translation[val & 0xFF]]; @@ -867,6 +888,8 @@ void R_DrawTranslucentFloorSprite_NPO2_8 (void) fixed_t xposition; fixed_t yposition; fixed_t xstep, ystep; + fixed_t x, y; + fixed_t fixedwidth, fixedheight; UINT16 *source; UINT8 *translation; @@ -885,20 +908,39 @@ void R_DrawTranslucentFloorSprite_NPO2_8 (void) translation = ds_translation; dest = ylookup[ds_y] + columnofs[ds_x1]; + fixedwidth = ds_flatwidth << FRACBITS; + fixedheight = ds_flatheight << FRACBITS; + + // Fix xposition and yposition if they are out of bounds. + if (xposition < 0) + xposition = fixedwidth - ((UINT32)(fixedwidth - xposition) % fixedwidth); + else if (xposition >= fixedwidth) + xposition %= fixedwidth; + if (yposition < 0) + yposition = fixedheight - ((UINT32)(fixedheight - yposition) % fixedheight); + else if (yposition >= fixedheight) + yposition %= fixedheight; + while (count-- && dest <= deststop) { - fixed_t x = (xposition >> FRACBITS); - fixed_t y = (yposition >> FRACBITS); - - // Carefully align all of my Friends. - if (x < 0) - x = ds_flatwidth - ((UINT32)(ds_flatwidth - x) % ds_flatwidth); - if (y < 0) - y = ds_flatheight - ((UINT32)(ds_flatheight - y) % ds_flatheight); - - x %= ds_flatwidth; - y %= ds_flatheight; + // The loops here keep the texture coordinates within the texture. + // They will rarely iterate multiple times, and are cheaper than a modulo operation, + // even if using libdivide. + if (xstep < 0) // These if statements are hopefully hoisted by the compiler to above this loop + while (xposition < 0) + xposition += fixedwidth; + else + while (xposition >= fixedwidth) + xposition -= fixedwidth; + if (ystep < 0) + while (yposition < 0) + yposition += fixedheight; + else + while (yposition >= fixedheight) + yposition -= fixedheight; + x = (xposition >> FRACBITS); + y = (yposition >> FRACBITS); val = source[((y * ds_flatwidth) + x)]; if (val & 0xFF00) *dest = *(ds_transmap + (colormap[translation[val & 0xFF]] << 8) + *dest); From 949c0c181d49cdead1ab094f1635caf10715c41e Mon Sep 17 00:00:00 2001 From: GoldenTails Date: Thu, 15 Oct 2020 10:54:18 -0500 Subject: [PATCH 0348/1080] Add aPNG downscaling, and its associated consvar. --- src/d_netcmd.c | 1 + src/m_misc.c | 36 +++++++++++++++++++++++++++++------- src/m_misc.h | 2 +- 3 files changed, 31 insertions(+), 8 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 87abd596a..0fc5c78c1 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -669,6 +669,7 @@ void D_RegisterClientCommands(void) CV_RegisterVar(&cv_zlib_strategya); CV_RegisterVar(&cv_zlib_window_bitsa); CV_RegisterVar(&cv_apng_delay); + CV_RegisterVar(&cv_apng_downscale); // GIF variables CV_RegisterVar(&cv_gif_optimize); CV_RegisterVar(&cv_gif_downscale); diff --git a/src/m_misc.c b/src/m_misc.c index d97d8f94b..ad2d133ab 100644 --- a/src/m_misc.c +++ b/src/m_misc.c @@ -163,6 +163,9 @@ consvar_t cv_zlib_levela = CVAR_INIT ("apng_compress_level", "4", CV_SAVE, zlib_ consvar_t cv_zlib_strategya = CVAR_INIT ("apng_strategy", "RLE", CV_SAVE, zlib_strategy_t, NULL); consvar_t cv_zlib_window_bitsa = CVAR_INIT ("apng_window_size", "32k", CV_SAVE, zlib_window_bits_t, NULL); consvar_t cv_apng_delay = CVAR_INIT ("apng_speed", "1x", CV_SAVE, apng_delay_t, NULL); +consvar_t cv_apng_downscale = CVAR_INIT ("apng_downscale", "On", CV_SAVE, CV_OnOff, NULL); + +static boolean apng_downscale = false; // So nobody can do something dumb like changing cvars mid output boolean takescreenshot = false; // Take a screenshot this tic @@ -981,25 +984,38 @@ static inline boolean M_PNGLib(void) static void M_PNGFrame(png_structp png_ptr, png_infop png_info_ptr, png_bytep png_buf) { + png_uint_16 downscale = apng_downscale ? vid.dupx : 1; + png_uint_32 pitch = png_get_rowbytes(png_ptr, png_info_ptr); - PNG_CONST png_uint_32 height = vid.height; - png_bytepp row_pointers = png_malloc(png_ptr, height* sizeof (png_bytep)); - png_uint_32 y; + PNG_CONST png_uint_32 width = vid.width / downscale; + PNG_CONST png_uint_32 height = vid.height / downscale; + png_bytepp row_pointers = png_malloc(png_ptr, height * sizeof (png_bytep)); + png_uint_32 x, y; png_uint_16 framedelay = (png_uint_16)cv_apng_delay.value; apng_frames++; for (y = 0; y < height; y++) { - row_pointers[y] = png_buf; - png_buf += pitch; + row_pointers[y] = malloc(pitch * sizeof(png_byte)); + for (x = 0; x < width; x++) + row_pointers[y][x] = png_buf[x * downscale]; + png_buf += pitch * (downscale * downscale); } + //for (x = 0; x < width; x++) + //{ + // printf("%d", x); + // row_pointers[y][x] = 0; + //} + /* row_pointers[y] = calloc(1, sizeof(png_bytep)); + png_buf += pitch * 2; + }*/ #ifndef PNG_STATIC if (aPNG_write_frame_head) #endif aPNG_write_frame_head(apng_ptr, apng_info_ptr, row_pointers, - vid.width, /* width */ + width, /* width */ height, /* height */ 0, /* x offset */ 0, /* y offset */ @@ -1030,6 +1046,12 @@ static void M_PNGfix_acTL(png_structp png_ptr, png_infop png_info_ptr, static boolean M_SetupaPNG(png_const_charp filename, png_bytep pal) { + png_uint_16 downscale; + + apng_downscale = (!!cv_apng_downscale.value); + + downscale = apng_downscale ? vid.dupx : 1; + apng_FILE = fopen(filename,"wb+"); // + mode for reading if (!apng_FILE) { @@ -1080,7 +1102,7 @@ static boolean M_SetupaPNG(png_const_charp filename, png_bytep pal) png_set_compression_strategy(apng_ptr, cv_zlib_strategya.value); png_set_compression_window_bits(apng_ptr, cv_zlib_window_bitsa.value); - M_PNGhdr(apng_ptr, apng_info_ptr, vid.width, vid.height, pal); + M_PNGhdr(apng_ptr, apng_info_ptr, vid.width / downscale, vid.height / downscale, pal); M_PNGText(apng_ptr, apng_info_ptr, true); diff --git a/src/m_misc.h b/src/m_misc.h index dbded37d0..c5ef9f9f2 100644 --- a/src/m_misc.h +++ b/src/m_misc.h @@ -33,7 +33,7 @@ extern consvar_t cv_screenshot_option, cv_screenshot_folder, cv_screenshot_color extern consvar_t cv_moviemode, cv_movie_folder, cv_movie_option; extern consvar_t cv_zlib_memory, cv_zlib_level, cv_zlib_strategy, cv_zlib_window_bits; extern consvar_t cv_zlib_memorya, cv_zlib_levela, cv_zlib_strategya, cv_zlib_window_bitsa; -extern consvar_t cv_apng_delay; +extern consvar_t cv_apng_delay, cv_apng_downscale; void M_StartMovie(void); void M_SaveFrame(void); From 12ac096a950d953cb3cb115061662b4f5461d06f Mon Sep 17 00:00:00 2001 From: GoldenTails Date: Thu, 15 Oct 2020 11:00:34 -0500 Subject: [PATCH 0349/1080] Add a menu option for aPNG downscaling. --- src/m_menu.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index 5860f00ca..ffd5c6510 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1551,18 +1551,19 @@ static menuitem_t OP_ScreenshotOptionsMenu[] = {IT_STRING|IT_CVAR, NULL, "Window Size", &cv_zlib_window_bits, 57}, {IT_HEADER, NULL, "Movie Mode (F9)", NULL, 64}, - {IT_STRING|IT_CVAR, NULL, "Storage Location", &cv_movie_option, 70}, - {IT_STRING|IT_CVAR|IT_CV_STRING, NULL, "Custom Folder", &cv_movie_folder, 75}, - {IT_STRING|IT_CVAR, NULL, "Capture Mode", &cv_moviemode, 90}, + {IT_STRING|IT_CVAR, NULL, "Storage Location", &cv_movie_option, 70}, + {IT_STRING|IT_CVAR|IT_CV_STRING, NULL, "Custom Folder", &cv_movie_folder, 75}, + {IT_STRING|IT_CVAR, NULL, "Capture Mode", &cv_moviemode, 90}, - {IT_STRING|IT_CVAR, NULL, "Region Optimizing", &cv_gif_optimize, 95}, + {IT_STRING|IT_CVAR, NULL, "Region Optimizing", &cv_gif_optimize, 95}, {IT_STRING|IT_CVAR, NULL, "Downscaling", &cv_gif_downscale, 100}, {IT_STRING|IT_CVAR, NULL, "Local Color Table", &cv_gif_localcolortable, 105}, - {IT_STRING|IT_CVAR, NULL, "Memory Level", &cv_zlib_memorya, 95}, - {IT_STRING|IT_CVAR, NULL, "Compression Level", &cv_zlib_levela, 100}, - {IT_STRING|IT_CVAR, NULL, "Strategy", &cv_zlib_strategya, 105}, - {IT_STRING|IT_CVAR, NULL, "Window Size", &cv_zlib_window_bitsa, 110}, + {IT_STRING|IT_CVAR, NULL, "Downscaling", &cv_apng_downscale, 95}, + {IT_STRING|IT_CVAR, NULL, "Memory Level", &cv_zlib_memorya, 100}, + {IT_STRING|IT_CVAR, NULL, "Compression Level", &cv_zlib_levela, 105}, + {IT_STRING|IT_CVAR, NULL, "Strategy", &cv_zlib_strategya, 110}, + {IT_STRING|IT_CVAR, NULL, "Window Size", &cv_zlib_window_bitsa, 115}, }; enum @@ -1575,7 +1576,7 @@ enum op_screenshot_gif_start = 13, op_screenshot_gif_end = 15, op_screenshot_apng_start = 16, - op_screenshot_apng_end = 19, + op_screenshot_apng_end = 20, }; static menuitem_t OP_EraseDataMenu[] = From 55f169f3c96152ac259a8e48a71ccf4ee43cea79 Mon Sep 17 00:00:00 2001 From: GoldenTails Date: Thu, 15 Oct 2020 11:04:52 -0500 Subject: [PATCH 0350/1080] Move the GIF downscaling menu option up one to create some parity. --- 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 ffd5c6510..ff9842f66 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1555,8 +1555,8 @@ static menuitem_t OP_ScreenshotOptionsMenu[] = {IT_STRING|IT_CVAR|IT_CV_STRING, NULL, "Custom Folder", &cv_movie_folder, 75}, {IT_STRING|IT_CVAR, NULL, "Capture Mode", &cv_moviemode, 90}, - {IT_STRING|IT_CVAR, NULL, "Region Optimizing", &cv_gif_optimize, 95}, - {IT_STRING|IT_CVAR, NULL, "Downscaling", &cv_gif_downscale, 100}, + {IT_STRING|IT_CVAR, NULL, "Downscaling", &cv_gif_downscale, 95}, + {IT_STRING|IT_CVAR, NULL, "Region Optimizing", &cv_gif_optimize, 100}, {IT_STRING|IT_CVAR, NULL, "Local Color Table", &cv_gif_localcolortable, 105}, {IT_STRING|IT_CVAR, NULL, "Downscaling", &cv_apng_downscale, 95}, From 377a9c10f09cd829dab666419a771cc63b411a67 Mon Sep 17 00:00:00 2001 From: James R Date: Sat, 21 Nov 2020 13:37:12 -0800 Subject: [PATCH 0351/1080] Lua: disallow bitwise not on anything but number values This fixes a crash. --- src/blua/lcode.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/blua/lcode.c b/src/blua/lcode.c index 5c7fed454..efb20e96b 100644 --- a/src/blua/lcode.c +++ b/src/blua/lcode.c @@ -686,6 +686,15 @@ static void codearith (FuncState *fs, OpCode op, expdesc *e1, expdesc *e2) { } +static void codeunaryarith (FuncState *fs, OpCode op, expdesc *e) { + expdesc e2; + e2.t = e2.f = NO_JUMP; e2.k = VKNUM; e2.u.nval = 0; + if (!isnumeral(e)) + luaK_exp2anyreg(fs, e); /* cannot operate on non-numeric constants */ + codearith(fs, op, e, &e2); +} + + static void codecomp (FuncState *fs, OpCode op, int cond, expdesc *e1, expdesc *e2) { int o1 = luaK_exp2RK(fs, e1); @@ -706,18 +715,8 @@ void luaK_prefix (FuncState *fs, UnOpr op, expdesc *e) { expdesc e2; e2.t = e2.f = NO_JUMP; e2.k = VKNUM; e2.u.nval = 0; switch (op) { - case OPR_MINUS: { - if (!isnumeral(e)) - luaK_exp2anyreg(fs, e); /* cannot operate on non-numeric constants */ - codearith(fs, OP_UNM, e, &e2); - break; - } - case OPR_BNOT: { - if (e->k == VK) - luaK_exp2anyreg(fs, e); /* cannot operate on non-numeric constants */ - codearith(fs, OP_BNOT, e, &e2); - break; - } + case OPR_MINUS: codeunaryarith(fs, OP_UNM, e); break; + case OPR_BNOT: codeunaryarith(fs, OP_BNOT, e); break; case OPR_NOT: codenot(fs, e); break; case OPR_LEN: { luaK_exp2anyreg(fs, e); /* cannot operate on constants */ From 5a8e653cd5c6c33a129c40e3f5fa3fb17896b909 Mon Sep 17 00:00:00 2001 From: James R Date: Sat, 21 Nov 2020 13:43:32 -0800 Subject: [PATCH 0352/1080] More concise --- src/blua/lcode.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/blua/lcode.c b/src/blua/lcode.c index efb20e96b..fd4aaff24 100644 --- a/src/blua/lcode.c +++ b/src/blua/lcode.c @@ -689,7 +689,7 @@ static void codearith (FuncState *fs, OpCode op, expdesc *e1, expdesc *e2) { static void codeunaryarith (FuncState *fs, OpCode op, expdesc *e) { expdesc e2; e2.t = e2.f = NO_JUMP; e2.k = VKNUM; e2.u.nval = 0; - if (!isnumeral(e)) + if (op == OP_LEN || !isnumeral(e)) luaK_exp2anyreg(fs, e); /* cannot operate on non-numeric constants */ codearith(fs, op, e, &e2); } @@ -712,17 +712,11 @@ static void codecomp (FuncState *fs, OpCode op, int cond, expdesc *e1, void luaK_prefix (FuncState *fs, UnOpr op, expdesc *e) { - expdesc e2; - e2.t = e2.f = NO_JUMP; e2.k = VKNUM; e2.u.nval = 0; switch (op) { case OPR_MINUS: codeunaryarith(fs, OP_UNM, e); break; case OPR_BNOT: codeunaryarith(fs, OP_BNOT, e); break; case OPR_NOT: codenot(fs, e); break; - case OPR_LEN: { - luaK_exp2anyreg(fs, e); /* cannot operate on constants */ - codearith(fs, OP_LEN, e, &e2); - break; - } + case OPR_LEN: codeunaryarith(fs, OP_LEN, e); break; default: lua_assert(0); } } From 071ec7338972277dd01b03d479ac2bc3fd78e2b2 Mon Sep 17 00:00:00 2001 From: Jaime Ita Passos Date: Sun, 22 Nov 2020 03:47:15 -0300 Subject: [PATCH 0353/1080] Some fixes for spritestuff2 --- src/r_patch.c | 2 +- src/r_things.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/r_patch.c b/src/r_patch.c index c78ffdd67..d6db44ea5 100644 --- a/src/r_patch.c +++ b/src/r_patch.c @@ -74,7 +74,7 @@ static void Patch_FreeData(patch_t *patch) HWR_FreeTexture(patch); #endif - for (i = 0; i < 2; i++) + for (i = 0; i < 4; i++) { if (patch->flats[i]) Z_Free(patch->flats[i]); diff --git a/src/r_things.c b/src/r_things.c index cdcc1877c..9032cd246 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -296,7 +296,7 @@ boolean R_AddSingleSpriteDef(const char *sprname, spritedef_t *spritedef, UINT16 if (!isPNG) #endif { - W_ReadLumpHeaderPwad(wadnum, l, &patch, sizeof (patch_t), 0); + W_ReadLumpHeaderPwad(wadnum, l, &patch, sizeof(INT16) * 4, 0); width = SHORT(patch.width); height = SHORT(patch.height); topoffset = SHORT(patch.topoffset); From 9ab3acae2dcac621e0e58a903d31e271d3b65ceb Mon Sep 17 00:00:00 2001 From: Jaime Ita Passos Date: Sun, 22 Nov 2020 17:03:04 -0300 Subject: [PATCH 0354/1080] Change how texture deletion works in OpenGL --- src/hardware/hw_cache.c | 19 ++++++++++--------- src/hardware/hw_data.h | 3 +-- src/hardware/hw_drv.h | 2 ++ src/hardware/r_opengl/r_opengl.c | 23 ++++++++++++++++++++--- src/sdl/hwsym_sdl.c | 1 + src/sdl/i_video.c | 1 + src/win32/win_dll.c | 2 ++ 7 files changed, 37 insertions(+), 14 deletions(-) diff --git a/src/hardware/hw_cache.c b/src/hardware/hw_cache.c index 85dabbcec..d133840ac 100644 --- a/src/hardware/hw_cache.c +++ b/src/hardware/hw_cache.c @@ -642,6 +642,9 @@ void HWR_FreeTextureColormaps(patch_t *patch) // Set the first colormap to the one that comes after it. next = pat->mipmap->nextcolormap; + if (!next) + break; + pat->mipmap->nextcolormap = next->nextcolormap; // Free image data from memory. @@ -671,14 +674,14 @@ void HWR_ClearAllTextures(void) { HWR_FreeMapTextures(); - // free references to the textures - HWD.pfnClearMipMapCache(); - // Alam: free the Z_Blocks before freeing it's users HWR_FreePatchCache(true); + + // free references to the textures + HWD.pfnClearCacheList(); } -// free all patch colormaps after each level: must be done after ClearMipMapCache! +// free all patch colormaps after each level void HWR_FreeColormapCache(void) { HWR_FreePatchCache(false); @@ -696,6 +699,7 @@ static void FreeMapTexture(GLMapTexture_t *tex) HWD.pfnDeleteTexture(&tex->mipmap); if (tex->mipmap.data) Z_Free(tex->mipmap.data); + tex->mipmap.data = NULL; } void HWR_FreeMapTextures(void) @@ -722,18 +726,15 @@ void HWR_FreeMapTextures(void) void HWR_LoadMapTextures(size_t pnumtextures) { - // we must free it since numtextures changed + // we must free it since numtextures may have changed HWR_FreeMapTextures(); - // Why not Z_Malloc? gl_numtextures = pnumtextures; gl_textures = calloc(gl_numtextures, sizeof(*gl_textures)); gl_flats = calloc(gl_numtextures, sizeof(*gl_flats)); - // Doesn't tell you which it _is_, but hopefully - // should never ever happen (right?!) if ((gl_textures == NULL) || (gl_flats == NULL)) - I_Error("HWR_LoadMapTextures: ran out of memory for OpenGL textures. Sad!"); + I_Error("HWR_LoadMapTextures: ran out of memory for OpenGL textures"); gl_maptexturesloaded = true; } diff --git a/src/hardware/hw_data.h b/src/hardware/hw_data.h index 6a872d258..32fb96e17 100644 --- a/src/hardware/hw_data.h +++ b/src/hardware/hw_data.h @@ -55,8 +55,7 @@ struct GLMipmap_s struct GLMipmap_s *nextcolormap; const UINT8 *colormap; - // opengl - struct GLMipmap_s *nextmipmap; // opengl : liste of all texture in opengl driver + struct GLMipmap_s *prevmipmap, *nextmipmap; // Linked list of all textures }; typedef struct GLMipmap_s GLMipmap_t; diff --git a/src/hardware/hw_drv.h b/src/hardware/hw_drv.h index de17f97d2..5a2e0e44e 100644 --- a/src/hardware/hw_drv.h +++ b/src/hardware/hw_drv.h @@ -46,6 +46,7 @@ EXPORT void HWRAPI(DeleteTexture) (FTextureInfo *TexInfo); EXPORT void HWRAPI(ReadRect) (INT32 x, INT32 y, INT32 width, INT32 height, INT32 dst_stride, UINT16 *dst_data); EXPORT void HWRAPI(GClipRect) (INT32 minx, INT32 miny, INT32 maxx, INT32 maxy, float nearclip); EXPORT void HWRAPI(ClearMipMapCache) (void); +EXPORT void HWRAPI(ClearCacheList) (void); //Hurdler: added for backward compatibility EXPORT void HWRAPI(SetSpecialState) (hwdspecialstate_t IdState, INT32 Value); @@ -100,6 +101,7 @@ struct hwdriver_s ReadRect pfnReadRect; GClipRect pfnGClipRect; ClearMipMapCache pfnClearMipMapCache; + ClearCacheList pfnClearCacheList; SetSpecialState pfnSetSpecialState;//Hurdler: added for backward compatibility DrawModel pfnDrawModel; CreateModelVBOs pfnCreateModelVBOs; diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index 39552dc1c..4c29dd2e4 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -1292,6 +1292,9 @@ EXPORT void HWRAPI(DeleteTexture) (FTextureInfo *pTexInfo) if (pTexInfo->downloaded) pglDeleteTextures(1, (GLuint *)&pTexInfo->downloaded); pTexInfo->downloaded = 0; + + if (pTexInfo->prevmipmap) + pTexInfo->prevmipmap->nextmipmap = pTexInfo->nextmipmap; } @@ -1308,12 +1311,21 @@ void Flush(void) DeleteTexture(gl_cachehead); gl_cachehead = gl_cachehead->nextmipmap; } - gl_cachetail = gl_cachehead = NULL; //Hurdler: well, gl_cachehead is already NULL + ClearCacheList(); //Hurdler: well, gl_cachehead is already NULL tex_downloaded = 0; } +// -----------------+ +// ClearCacheList : Clears the texture cache tail and head +// -----------------+ +EXPORT void HWRAPI(ClearCacheList) (void) +{ + gl_cachetail = gl_cachehead = NULL; +} + + // -----------------+ // isExtAvailable : Look if an OpenGL extension is available // Returns : true if extension available @@ -1929,14 +1941,19 @@ EXPORT void HWRAPI(SetTexture) (FTextureInfo *pTexInfo) else { UpdateTexture(pTexInfo); + + pTexInfo->prevmipmap = NULL; pTexInfo->nextmipmap = NULL; + + // insertion at the tail if (gl_cachetail) - { // insertion at the tail + { gl_cachetail->nextmipmap = pTexInfo; + pTexInfo->prevmipmap = gl_cachetail; gl_cachetail = pTexInfo; } else // initialization of the linked list - gl_cachetail = gl_cachehead = pTexInfo; + gl_cachetail = gl_cachehead = pTexInfo; } } diff --git a/src/sdl/hwsym_sdl.c b/src/sdl/hwsym_sdl.c index 96e3d7d69..398508662 100644 --- a/src/sdl/hwsym_sdl.c +++ b/src/sdl/hwsym_sdl.c @@ -90,6 +90,7 @@ void *hwSym(const char *funcName,void *handle) GETFUNC(ReadRect); GETFUNC(GClipRect); GETFUNC(ClearMipMapCache); + GETFUNC(ClearCacheList); GETFUNC(SetSpecialState); GETFUNC(GetTextureUsed); GETFUNC(DrawModel); diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index b9423ac21..f83f57576 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -1868,6 +1868,7 @@ void VID_StartupOpenGL(void) HWD.pfnReadRect = hwSym("ReadRect",NULL); HWD.pfnGClipRect = hwSym("GClipRect",NULL); HWD.pfnClearMipMapCache = hwSym("ClearMipMapCache",NULL); + HWD.pfnClearCacheList = hwSym("ClearCacheList",NULL); HWD.pfnSetSpecialState = hwSym("SetSpecialState",NULL); HWD.pfnSetPalette = hwSym("SetPalette",NULL); HWD.pfnGetTextureUsed = hwSym("GetTextureUsed",NULL); diff --git a/src/win32/win_dll.c b/src/win32/win_dll.c index 4743cec34..d942d8cd4 100644 --- a/src/win32/win_dll.c +++ b/src/win32/win_dll.c @@ -111,6 +111,7 @@ static loadfunc_t hwdFuncTable[] = { {"ReadRect@24", &hwdriver.pfnReadRect}, {"GClipRect@20", &hwdriver.pfnGClipRect}, {"ClearMipMapCache@0", &hwdriver.pfnClearMipMapCache}, + {"ClearCacheList@0", &hwdriver.pfnClearCacheList}, {"SetSpecialState@8", &hwdriver.pfnSetSpecialState}, {"DrawModel@16", &hwdriver.pfnDrawModel}, {"SetTransform@4", &hwdriver.pfnSetTransform}, @@ -144,6 +145,7 @@ static loadfunc_t hwdFuncTable[] = { {"ReadRect", &hwdriver.pfnReadRect}, {"GClipRect", &hwdriver.pfnGClipRect}, {"ClearMipMapCache", &hwdriver.pfnClearMipMapCache}, + {"ClearCacheList", &hwdriver.pfnClearCacheList}, {"SetSpecialState", &hwdriver.pfnSetSpecialState}, {"DrawModel", &hwdriver.pfnDrawModel}, {"SetTransform", &hwdriver.pfnSetTransform}, From 152c540c1e08ab9e05102875656dbae7f2bd0f6c Mon Sep 17 00:00:00 2001 From: Jaime Ita Passos Date: Sun, 22 Nov 2020 17:10:10 -0300 Subject: [PATCH 0355/1080] Fix sprite textures in models --- 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 670a405a1..9c786e67e 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -527,7 +527,7 @@ void HWR_InitModels(void) return; } } - + // length of the player model prefix prefixlen = strlen(PLAYERMODELPREFIX); @@ -1470,7 +1470,7 @@ boolean HWR_DrawModel(gl_vissprite_t *spr) // Instead of the != operator, memcmp is used to avoid a compiler warning. if (memcmp(&(hwrPatch->max_s), &(md2->model->max_s), sizeof(md2->model->max_s)) != 0 || memcmp(&(hwrPatch->max_t), &(md2->model->max_t), sizeof(md2->model->max_t)) != 0) - adjustTextureCoords(md2->model, gpatch); + adjustTextureCoords(md2->model, spr->gpatch); HWR_GetMappedPatch(spr->gpatch, spr->colormap); } From abe35fd00885282026d1e7e60bfac3646d294fc6 Mon Sep 17 00:00:00 2001 From: Jaime Ita Passos Date: Sun, 22 Nov 2020 17:22:18 -0300 Subject: [PATCH 0356/1080] Some interface fixes --- src/d_main.c | 15 ++------------- src/lua_hudlib.c | 8 ++++---- src/screen.c | 18 ++++++++---------- src/screen.h | 1 - src/sdl/i_video.c | 2 +- 5 files changed, 15 insertions(+), 29 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index 53798d446..81797947d 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -652,6 +652,8 @@ void D_SRB2Loop(void) SCR_SetMode(); // change video mode SCR_Recalc(); + chosenrendermode = render_none; + // Check and print which version is executed. // Use this as the border between setup and the main game loop being entered. CONS_Printf( @@ -1296,19 +1298,6 @@ void D_SRB2Main(void) // set user default mode or mode set at cmdline SCR_CheckDefaultMode(); - // Lactozilla: Check if the render mode needs to change. - if (setrenderneeded) - { - CONS_Printf(M_GetText("Switching the renderer...\n")); - - // Switch the renderer in the interface - if (VID_CheckRenderer()) - con_refresh = true; // Allow explicit screen refresh again - - // Set cv_renderer to the new render mode - CV_StealthSetValue(&cv_renderer, rendermode); - } - wipegamestate = gamestate; savedata.lives = 0; // flag this as not-used diff --git a/src/lua_hudlib.c b/src/lua_hudlib.c index 7b290bf3f..f4e5d5ccf 100644 --- a/src/lua_hudlib.c +++ b/src/lua_hudlib.c @@ -305,16 +305,16 @@ static int patch_get(lua_State *L) lua_pushboolean(L, patch != NULL); break; case patch_width: - lua_pushinteger(L, SHORT(patch->width)); + lua_pushinteger(L, patch->width); break; case patch_height: - lua_pushinteger(L, SHORT(patch->height)); + lua_pushinteger(L, patch->height); break; case patch_leftoffset: - lua_pushinteger(L, SHORT(patch->leftoffset)); + lua_pushinteger(L, patch->leftoffset); break; case patch_topoffset: - lua_pushinteger(L, SHORT(patch->topoffset)); + lua_pushinteger(L, patch->topoffset); break; } return 1; diff --git a/src/screen.c b/src/screen.c index f14cf4bf6..9d36eee39 100644 --- a/src/screen.c +++ b/src/screen.c @@ -72,7 +72,7 @@ CV_PossibleValue_t cv_renderer_t[] = { {0, NULL} }; -consvar_t cv_renderer = CVAR_INIT ("renderer", "Software", CV_SAVE|CV_NOLUA|CV_CALL, cv_renderer_t, SCR_SetTargetRenderer); +consvar_t cv_renderer = CVAR_INIT ("renderer", "Software", CV_SAVE|CV_NOLUA|CV_CALL, cv_renderer_t, SCR_ChangeRenderer); static void SCR_ChangeFullscreen(void); @@ -207,7 +207,11 @@ void SCR_SetMode(void) if (setrenderneeded && (moviemode == MM_APNG)) M_StopMovie(); - VID_CheckRenderer(); + // VID_SetMode will call VID_CheckRenderer itself, + // so no need to do this in here. + if (!setmodeneeded) + VID_CheckRenderer(); + vid.recalc = 1; } @@ -402,15 +406,10 @@ void SCR_ChangeFullscreen(void) #endif } -void SCR_SetTargetRenderer(void) -{ - if (!con_refresh) - SCR_ChangeRenderer(); -} - void SCR_ChangeRenderer(void) { - if ((signed)rendermode == cv_renderer.value) + if (chosenrendermode != render_none + || (signed)rendermode == cv_renderer.value) return; #ifdef HWRENDER @@ -428,7 +427,6 @@ void SCR_ChangeRenderer(void) // Set the new render mode setrenderneeded = cv_renderer.value; - con_refresh = false; } boolean SCR_IsAspectCorrect(INT32 width, INT32 height) diff --git a/src/screen.h b/src/screen.h index 66452289c..e4944775d 100644 --- a/src/screen.h +++ b/src/screen.h @@ -183,7 +183,6 @@ extern INT32 setmodeneeded; // mode number to set if needed, or 0 extern UINT8 setrenderneeded; void SCR_ChangeRenderer(void); -void SCR_SetTargetRenderer(void); extern CV_PossibleValue_t cv_renderer_t[]; diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index f83f57576..fb25362af 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -1557,7 +1557,7 @@ boolean VID_CheckRenderer(void) setrenderneeded = 0; } - SDLSetMode(vid.width, vid.height, USE_FULLSCREEN, (rendererchanged ? SDL_FALSE : SDL_TRUE)); + SDLSetMode(vid.width, vid.height, USE_FULLSCREEN, (setmodeneeded ? SDL_TRUE : SDL_FALSE)); Impl_VideoSetupBuffer(); if (rendermode == render_soft) From 0645c642d2c0f92bdaade58e3897b4c003c682c4 Mon Sep 17 00:00:00 2001 From: Jaime Ita Passos Date: Sun, 22 Nov 2020 18:18:26 -0300 Subject: [PATCH 0357/1080] Improve GPU texture management. --- src/hardware/hw_cache.c | 34 ++++++++++++++++++-------------- src/hardware/hw_data.h | 16 +++++++-------- src/hardware/hw_glob.h | 1 + src/hardware/hw_main.c | 14 +++---------- src/hardware/r_opengl/r_opengl.c | 6 ------ src/p_setup.c | 6 ++++++ src/sdl/i_video.c | 5 ----- 7 files changed, 37 insertions(+), 45 deletions(-) diff --git a/src/hardware/hw_cache.c b/src/hardware/hw_cache.c index d133840ac..5c4702fda 100644 --- a/src/hardware/hw_cache.c +++ b/src/hardware/hw_cache.c @@ -585,6 +585,21 @@ static GLMapTexture_t *gl_textures; // For all textures static GLMapTexture_t *gl_flats; // For all (texture) flats, as normal flats don't need to be cached boolean gl_maptexturesloaded = false; +void HWR_FreeTextureData(patch_t *patch) +{ + GLPatch_t *grPatch; + + if (!patch || !patch->hardware) + return; + + grPatch = patch->hardware; + + if (vid.glstate == VID_GL_LIBRARY_LOADED) + HWD.pfnDeleteTexture(grPatch->mipmap); + if (grPatch->mipmap->data) + Z_Free(grPatch->mipmap->data); +} + void HWR_FreeTexture(patch_t *patch) { if (!patch) @@ -598,10 +613,7 @@ void HWR_FreeTexture(patch_t *patch) if (grPatch->mipmap) { - if (vid.glstate == VID_GL_LIBRARY_LOADED) - HWD.pfnDeleteTexture(grPatch->mipmap); - if (grPatch->mipmap->data) - Z_Free(grPatch->mipmap->data); + HWR_FreeTextureData(patch); Z_Free(grPatch->mipmap); } @@ -636,15 +648,12 @@ void HWR_FreeTextureColormaps(patch_t *patch) if (!pat->mipmap) break; - // No colormap mipmap either. + // No colormap mipmaps either. if (!pat->mipmap->nextcolormap) break; // Set the first colormap to the one that comes after it. next = pat->mipmap->nextcolormap; - if (!next) - break; - pat->mipmap->nextcolormap = next->nextcolormap; // Free image data from memory. @@ -670,18 +679,13 @@ static void HWR_FreePatchCache(boolean freeall) } } +// free all textures after each level void HWR_ClearAllTextures(void) { - HWR_FreeMapTextures(); - - // Alam: free the Z_Blocks before freeing it's users + HWD.pfnClearMipMapCache(); // free references to the textures HWR_FreePatchCache(true); - - // free references to the textures - HWD.pfnClearCacheList(); } -// free all patch colormaps after each level void HWR_FreeColormapCache(void) { HWR_FreePatchCache(false); diff --git a/src/hardware/hw_data.h b/src/hardware/hw_data.h index 32fb96e17..3ae4ef8bc 100644 --- a/src/hardware/hw_data.h +++ b/src/hardware/hw_data.h @@ -43,19 +43,19 @@ typedef enum GLTextureFormat_e // NULL if the texture is not in Doom heap cache. struct GLMipmap_s { - //for TexDownloadMipMap - GLTextureFormat_t format; - void *data; + // for TexDownloadMipMap + GLTextureFormat_t format; + void *data; - UINT32 flags; - UINT16 height; - UINT16 width; - UINT32 downloaded; // the dll driver have it in there cache ? + UINT32 flags; + UINT16 height; + UINT16 width; + UINT32 downloaded; // The GPU has this texture. struct GLMipmap_s *nextcolormap; const UINT8 *colormap; - struct GLMipmap_s *prevmipmap, *nextmipmap; // Linked list of all textures + struct GLMipmap_s *nextmipmap; // Linked list of all textures }; typedef struct GLMipmap_s GLMipmap_t; diff --git a/src/hardware/hw_glob.h b/src/hardware/hw_glob.h index 112b241ef..87405d3d4 100644 --- a/src/hardware/hw_glob.h +++ b/src/hardware/hw_glob.h @@ -121,6 +121,7 @@ void HWR_GetLevelFlat(levelflat_t *levelflat); void HWR_LiterallyGetFlat(lumpnum_t flatlumpnum); void HWR_FreeTexture(patch_t *patch); +void HWR_FreeTextureData(patch_t *patch); void HWR_FreeTextureColormaps(patch_t *patch); void HWR_ClearAllTextures(void); void HWR_FreeColormapCache(void); diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 2a694b95f..1dda7a423 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -6221,17 +6221,6 @@ void HWR_RenderPlayerView(INT32 viewnumber, player_t *player) void HWR_LoadLevel(void) { - // Lactozilla (December 8, 2019) - // Level setup used to free EVERY mipmap from memory. - // Even mipmaps that aren't related to level textures. - // Presumably, the hardware render code used to store textures as level data. - // Meaning, they had memory allocated and marked with the PU_LEVEL tag. - // Level textures are only reloaded after R_LoadTextures, which is - // when the texture list is loaded. - - // Sal: Unfortunately, NOT freeing them causes the dreaded Color Bug. - HWR_FreeColormapCache(); - #ifdef ALAM_LIGHTING // BP: reset light between levels (we draw preview frame lights on current frame) HWR_ResetLights(); @@ -6394,7 +6383,10 @@ void HWR_Switch(void) // Create plane polygons if (!gl_maploaded && (gamestate == GS_LEVEL || (gamestate == GS_TITLESCREEN && titlemapinaction))) + { + HWR_ClearAllTextures(); HWR_LoadLevel(); + } } // -------------------------------------------------------------------------- diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index 4c29dd2e4..8cd948eea 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -1292,9 +1292,6 @@ EXPORT void HWRAPI(DeleteTexture) (FTextureInfo *pTexInfo) if (pTexInfo->downloaded) pglDeleteTextures(1, (GLuint *)&pTexInfo->downloaded); pTexInfo->downloaded = 0; - - if (pTexInfo->prevmipmap) - pTexInfo->prevmipmap->nextmipmap = pTexInfo->nextmipmap; } @@ -1941,15 +1938,12 @@ EXPORT void HWRAPI(SetTexture) (FTextureInfo *pTexInfo) else { UpdateTexture(pTexInfo); - - pTexInfo->prevmipmap = NULL; pTexInfo->nextmipmap = NULL; // insertion at the tail if (gl_cachetail) { gl_cachetail->nextmipmap = pTexInfo; - pTexInfo->prevmipmap = gl_cachetail; gl_cachetail = pTexInfo; } else // initialization of the linked list diff --git a/src/p_setup.c b/src/p_setup.c index cfee05009..1d2519218 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -4133,6 +4133,12 @@ boolean P_LoadLevel(boolean fromnetsave, boolean reloadinggamestate) // Clear pointers that would be left dangling by the purge R_FlushTranslationColormapCache(); +#ifdef HWRENDER + // Free GPU textures before freeing patches. + if (vid.glstate == VID_GL_LIBRARY_LOADED) + HWR_ClearAllTextures(); +#endif + Patch_FreeTag(PU_PATCH_LOWPRIORITY); Patch_FreeTag(PU_PATCH_ROTATED); Z_FreeTags(PU_LEVEL, PU_PURGELEVEL - 1); diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index fb25362af..b8b3b9d34 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -1568,11 +1568,6 @@ boolean VID_CheckRenderer(void) bufSurface = NULL; } -#ifdef HWRENDER - if (rendererchanged && vid.glstate == VID_GL_LIBRARY_LOADED) // Only if OpenGL ever loaded! - HWR_ClearAllTextures(); -#endif - SCR_SetDrawFuncs(); } #ifdef HWRENDER From f51be77aa21e125c4abd16da2f660c4da03daa84 Mon Sep 17 00:00:00 2001 From: Riku Salminen <38985578+Riku-S@users.noreply.github.com> Date: Sun, 22 Nov 2020 23:19:24 +0200 Subject: [PATCH 0358/1080] Now the fix actually does what the MR says... +lua banks --- src/g_game.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/g_game.c b/src/g_game.c index d6861b252..1afaf8956 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -2242,6 +2242,12 @@ void G_Ticker(boolean run) // Reset unlockable triggers unlocktriggers = 0; + emeralds = 0; + tokenbits = 0; + tokenlist = 0; + token = 0; + + memset(&luabanks, 0, sizeof(luabanks)); } else if (G_GametypeUsesLives() && players[consoleplayer].playerstate == PST_LIVE && players[consoleplayer].lives != INFLIVES) players[consoleplayer].lives -= 1; From b9fa50f7ef00000bc1f79e5d47582aeae971b37f Mon Sep 17 00:00:00 2001 From: Riku Salminen <38985578+Riku-S@users.noreply.github.com> Date: Sun, 22 Nov 2020 23:23:32 +0200 Subject: [PATCH 0359/1080] No need to reset tokens twice --- src/g_game.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index 1afaf8956..b91087b2b 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -2243,9 +2243,6 @@ void G_Ticker(boolean run) unlocktriggers = 0; emeralds = 0; - tokenbits = 0; - tokenlist = 0; - token = 0; memset(&luabanks, 0, sizeof(luabanks)); } From 2e21168395df7fa4f51b47b37ddca38f00efd335 Mon Sep 17 00:00:00 2001 From: Jaime Ita Passos Date: Sun, 22 Nov 2020 18:23:35 -0300 Subject: [PATCH 0360/1080] Free GPU textures when adding a file --- src/p_setup.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/p_setup.c b/src/p_setup.c index 1d2519218..918ffbd4e 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -4498,6 +4498,11 @@ boolean P_AddWadFile(const char *wadfilename) if (!devparm && digmreplaces) CONS_Printf(M_GetText("%s digital musics replaced\n"), sizeu1(digmreplaces)); +#ifdef HWRENDER + // Free GPU textures before freeing patches. + if (vid.glstate == VID_GL_LIBRARY_LOADED) + HWR_ClearAllTextures(); +#endif // // search for sprite replacements From 5293c52bcabf790b5839c91d09b5ae2fb381de40 Mon Sep 17 00:00:00 2001 From: Jaime Ita Passos Date: Sun, 22 Nov 2020 20:02:47 -0300 Subject: [PATCH 0361/1080] Remove SHORT macros for referencing patch width/height/offsets --- src/console.c | 2 +- src/d_main.c | 2 +- src/f_finale.c | 4 +- src/hardware/hw_cache.c | 4 +- src/hardware/hw_draw.c | 8 ++-- src/hardware/hw_main.c | 4 +- src/hu_stuff.c | 14 +++---- src/m_menu.c | 68 +++++++++++++++++----------------- src/r_patch.c | 10 ++--- src/r_things.c | 28 ++++++-------- src/st_stuff.c | 18 ++++----- src/v_video.c | 82 ++++++++++++++++++++--------------------- src/y_inter.c | 12 +++--- 13 files changed, 125 insertions(+), 131 deletions(-) diff --git a/src/console.c b/src/console.c index 29794d017..b19b8818d 100644 --- a/src/console.c +++ b/src/console.c @@ -1682,7 +1682,7 @@ static void CON_DrawHudlines(void) ;//charwidth = 4 * con_scalefactor; else { - //charwidth = SHORT(hu_font['A'-HU_FONTSTART]->width) * con_scalefactor; + //charwidth = (hu_font['A'-HU_FONTSTART]->width) * con_scalefactor; V_DrawCharacter(x, y, (INT32)(*p) | charflags | cv_constextsize.value | V_NOSCALESTART, true); } } diff --git a/src/d_main.c b/src/d_main.c index 81797947d..1045d4d99 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -507,7 +507,7 @@ static void D_Display(void) else py = viewwindowy + 4; patch = W_CachePatchName("M_PAUSE", PU_PATCH); - V_DrawScaledPatch(viewwindowx + (BASEVIDWIDTH - SHORT(patch->width))/2, py, 0, patch); + V_DrawScaledPatch(viewwindowx + (BASEVIDWIDTH - patch->width)/2, py, 0, patch); #else INT32 y = ((automapactive) ? (32) : (BASEVIDHEIGHT/2)); M_DrawTextBox((BASEVIDWIDTH/2) - (60), y - (16), 13, 2); diff --git a/src/f_finale.c b/src/f_finale.c index 268bc79f5..688cd4fc7 100644 --- a/src/f_finale.c +++ b/src/f_finale.c @@ -2336,8 +2336,8 @@ void F_SkyScroll(INT32 scrollxspeed, INT32 scrollyspeed, const char *patchname) pat = W_CachePatchName(patchname, PU_PATCH_LOWPRIORITY); - patwidth = SHORT(pat->width); - patheight = SHORT(pat->height); + patwidth = pat->width; + patheight = pat->height; pw = patwidth * dupz; ph = patheight * dupz; diff --git a/src/hardware/hw_cache.c b/src/hardware/hw_cache.c index 5c4702fda..b4fa7ec6c 100644 --- a/src/hardware/hw_cache.c +++ b/src/hardware/hw_cache.c @@ -1206,8 +1206,8 @@ static void HWR_DrawFadeMaskInCache(GLMipmap_t *mipmap, INT32 pblockwidth, INT32 W_ReadLump(fademasklumpnum, Z_Malloc(W_LumpLength(fademasklumpnum), PU_HWRCACHE, &flat)); - stepy = ((INT32)SHORT(fmheight)<= -0.1f && cx <= 0.1f && (gpatch->width) == BASEVIDWIDTH && cy >= -0.1f && cy <= 0.1f && SHORT(gpatch->height) == BASEVIDHEIGHT) + if (cx >= -0.1f && cx <= 0.1f && gpatch->width == BASEVIDWIDTH && cy >= -0.1f && cy <= 0.1f && gpatch->height == BASEVIDHEIGHT) { const column_t *column = (const column_t *)((const UINT8 *)(gpatch->columns) + (gpatch->columnofs[0])); if (!column->topdelta) @@ -427,8 +427,8 @@ void HWR_DrawCroppedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale, // fuck it, no GL support for croppedpatch v_perplayer right now. it's not like it's accessible to Lua or anything, and we only use it for menus... - cy -= (float)SHORT(gpatch->topoffset) * fscale; - cx -= (float)SHORT(gpatch->leftoffset) * fscale; + cy -= (float)(gpatch->topoffset) * fscale; + cx -= (float)(gpatch->leftoffset) * fscale; if (!(option & V_NOSCALESTART)) { @@ -440,7 +440,7 @@ void HWR_DrawCroppedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale, // if it's meant to cover the whole screen, black out the rest (ONLY IF TOP LEFT ISN'T TRANSPARENT) // cx and cy are possibly *slightly* off from float maths // This is done before here compared to software because we directly alter cx and cy to centre - if (cx >= -0.1f && cx <= 0.1f && SHORT(gpatch->width) == BASEVIDWIDTH && cy >= -0.1f && cy <= 0.1f && SHORT(gpatch->height) == BASEVIDHEIGHT) + if (cx >= -0.1f && cx <= 0.1f && gpatch->width == BASEVIDWIDTH && cy >= -0.1f && cy <= 0.1f && gpatch->height == BASEVIDHEIGHT) { const column_t *column = (const column_t *)((const UINT8 *)(gpatch->columns) + (gpatch->columnofs[0])); if (!column->topdelta) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 1dda7a423..5dd2727bc 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -1145,7 +1145,7 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom texturevpegtop += gl_sidedef->rowoffset; // This is so that it doesn't overflow and screw up the wall, it doesn't need to go higher than the texture's height anyway - texturevpegtop %= SHORT(textures[gl_toptexture]->height)<height)<scaleY; wallVerts[0].t = wallVerts[1].t = (texturevpegtop + gl_frontsector->ceilingheight - gl_backsector->ceilingheight) * grTex->scaleY; @@ -1211,7 +1211,7 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom texturevpegbottom += gl_sidedef->rowoffset; // This is so that it doesn't overflow and screw up the wall, it doesn't need to go higher than the texture's height anyway - texturevpegbottom %= SHORT(textures[gl_bottomtexture]->height)<height)<scaleY; wallVerts[0].t = wallVerts[1].t = (texturevpegbottom + gl_backsector->floorheight - gl_frontsector->floorheight) * grTex->scaleY; diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 604a509e0..7e9144f98 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -1794,8 +1794,8 @@ static void HU_DrawChat_Old(void) size_t i = 0; const char *ntalk = "Say: ", *ttalk = "Say-Team: "; const char *talk = ntalk; - INT32 charwidth = 8 * con_scalefactor; //SHORT(hu_font['A'-HU_FONTSTART]->width) * con_scalefactor; - INT32 charheight = 8 * con_scalefactor; //SHORT(hu_font['A'-HU_FONTSTART]->height) * con_scalefactor; + INT32 charwidth = 8 * con_scalefactor; //(hu_font['A'-HU_FONTSTART]->width) * con_scalefactor; + INT32 charheight = 8 * con_scalefactor; //(hu_font['A'-HU_FONTSTART]->height) * con_scalefactor; if (teamtalk) { talk = ttalk; @@ -1816,7 +1816,7 @@ static void HU_DrawChat_Old(void) } else { - //charwidth = SHORT(hu_font[talk[i]-HU_FONTSTART]->width) * con_scalefactor; + //charwidth = (hu_font[talk[i]-HU_FONTSTART]->width) * con_scalefactor; V_DrawCharacter(HU_INPUTX + c, y, talk[i++] | cv_constextsize.value | V_NOSCALESTART, true); } c += charwidth; @@ -1844,7 +1844,7 @@ static void HU_DrawChat_Old(void) } else { - //charwidth = SHORT(hu_font[w_chat[i]-HU_FONTSTART]->width) * con_scalefactor; + //charwidth = (hu_font[w_chat[i]-HU_FONTSTART]->width) * con_scalefactor; V_DrawCharacter(HU_INPUTX + c, y, w_chat[i++] | cv_constextsize.value | V_NOSCALESTART | t, true); } @@ -2364,7 +2364,7 @@ void HU_DrawTabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scorelines, I } if (players[tab[i].num].exiting || (players[tab[i].num].pflags & PF_FINISHED)) - V_DrawSmallScaledPatch(x - SHORT(exiticon->width)/2 - 1, y-3, 0, exiticon); + V_DrawSmallScaledPatch(x - exiticon->width/2 - 1, y-3, 0, exiticon); if (gametyperankings[gametype] == GT_RACE) { @@ -2668,7 +2668,7 @@ void HU_DrawDualTabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scoreline V_DrawSmallScaledPatch(x-28, y-4, 0, tagico); if (players[tab[i].num].exiting || (players[tab[i].num].pflags & PF_FINISHED)) - V_DrawSmallScaledPatch(x - SHORT(exiticon->width)/2 - 1, y-3, 0, exiticon); + V_DrawSmallScaledPatch(x - exiticon->width/2 - 1, y-3, 0, exiticon); // Draw emeralds if (players[tab[i].num].powers[pw_invulnerability] && (players[tab[i].num].powers[pw_invulnerability] == players[tab[i].num].powers[pw_sneakers]) && ((leveltime/7) & 1)) @@ -3094,7 +3094,7 @@ static void HU_DrawCoopOverlay(void) if (LUA_HudEnabled(hud_tabemblems) && (!modifiedgame || savemoddata)) { V_DrawString(160, 144, 0, va("- %d/%d", M_CountEmblems(), numemblems+numextraemblems)); - V_DrawScaledPatch(128, 144 - SHORT(emblemicon->height)/4, 0, emblemicon); + V_DrawScaledPatch(128, 144 - emblemicon->height/4, 0, emblemicon); } if (!LUA_HudEnabled(hud_coopemeralds)) diff --git a/src/m_menu.c b/src/m_menu.c index d31e2154c..b09025fe0 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -4031,7 +4031,7 @@ static void M_DrawThermo(INT32 x, INT32 y, consvar_t *cv) cursorlump = W_GetNumForName("M_THERMO"); V_DrawScaledPatch(xx, y, 0, p = W_CachePatchNum(leftlump,PU_PATCH)); - xx += SHORT(p->width) - SHORT(p->leftoffset); + xx += p->width - p->leftoffset; for (i = 0; i < 16; i++) { V_DrawScaledPatch(xx, y, V_WRAPX, W_CachePatchNum(centerlump[i & 1], PU_PATCH)); @@ -4170,7 +4170,7 @@ static void M_DrawStaticBox(fixed_t x, fixed_t y, INT32 flags, fixed_t w, fixed_ fixed_t sw, pw; patch = W_CachePatchName("LSSTATIC", PU_PATCH); - pw = SHORT(patch->width) - (sw = w*2); //FixedDiv(w, scale); -- for scale FRACUNIT/2 + pw = patch->width - (sw = w*2); //FixedDiv(w, scale); -- for scale FRACUNIT/2 /*if (pw > 0) -- model code for modders providing weird LSSTATIC { @@ -4267,8 +4267,8 @@ static void M_DrawMenuTitle(void) if (p->height > 24) // title is larger than normal { - INT32 xtitle = (BASEVIDWIDTH - (SHORT(p->width)/2))/2; - INT32 ytitle = (30 - (SHORT(p->height)/2))/2; + INT32 xtitle = (BASEVIDWIDTH - (p->width/2))/2; + INT32 ytitle = (30 - (p->height/2))/2; if (xtitle < 0) xtitle = 0; @@ -4279,8 +4279,8 @@ static void M_DrawMenuTitle(void) } else { - INT32 xtitle = (BASEVIDWIDTH - SHORT(p->width))/2; - INT32 ytitle = (30 - SHORT(p->height))/2; + INT32 xtitle = (BASEVIDWIDTH - p->width)/2; + INT32 ytitle = (30 - p->height)/2; if (xtitle < 0) xtitle = 0; @@ -4316,7 +4316,7 @@ static void M_DrawGenericMenu(void) { patch_t *p; p = W_CachePatchName(currentMenu->menuitems[i].patch, PU_PATCH); - V_DrawScaledPatch((BASEVIDWIDTH - SHORT(p->width))/2, y, 0, p); + V_DrawScaledPatch((BASEVIDWIDTH - p->width)/2, y, 0, p); } else { @@ -4847,7 +4847,7 @@ static void M_DrawCenteredMenu(void) { patch_t *p; p = W_CachePatchName(currentMenu->menuitems[i].patch, PU_PATCH); - V_DrawScaledPatch((BASEVIDWIDTH - SHORT(p->width))/2, y, 0, p); + V_DrawScaledPatch((BASEVIDWIDTH - p->width)/2, y, 0, p); } else { @@ -5695,7 +5695,7 @@ static void M_DrawRecordAttackForeground(void) angle_t fa; INT32 i; - INT32 height = (SHORT(fg->height)/2); + INT32 height = (fg->height / 2); INT32 dupz = (vid.dupx < vid.dupy ? vid.dupx : vid.dupy); for (i = -12; i < (BASEVIDHEIGHT/height) + 12; i++) @@ -5730,9 +5730,9 @@ static void M_DrawNightsAttackMountains(void) static INT32 bgscrollx; INT32 dupz = (vid.dupx < vid.dupy ? vid.dupx : vid.dupy); patch_t *background = W_CachePatchName(curbgname, PU_PATCH); - INT16 w = SHORT(background->width); + INT16 w = background->width; INT32 x = FixedInt(-bgscrollx) % w; - INT32 y = BASEVIDHEIGHT - SHORT(background->height)*2; + INT32 y = BASEVIDHEIGHT - (background->height * 2); if (vid.height != BASEVIDHEIGHT * dupz) V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 158); @@ -5757,18 +5757,18 @@ static void M_DrawNightsAttackBackground(void) // top patch_t *backtopfg = W_CachePatchName("NTSATKT1", PU_PATCH); patch_t *fronttopfg = W_CachePatchName("NTSATKT2", PU_PATCH); - INT32 backtopwidth = SHORT(backtopfg->width); - //INT32 backtopheight = SHORT(backtopfg->height); - INT32 fronttopwidth = SHORT(fronttopfg->width); - //INT32 fronttopheight = SHORT(fronttopfg->height); + INT32 backtopwidth = backtopfg->width; + //INT32 backtopheight = backtopfg->height; + INT32 fronttopwidth = fronttopfg->width; + //INT32 fronttopheight = fronttopfg->height; // bottom patch_t *backbottomfg = W_CachePatchName("NTSATKB1", PU_PATCH); patch_t *frontbottomfg = W_CachePatchName("NTSATKB2", PU_PATCH); - INT32 backbottomwidth = SHORT(backbottomfg->width); - INT32 backbottomheight = SHORT(backbottomfg->height); - INT32 frontbottomwidth = SHORT(frontbottomfg->width); - INT32 frontbottomheight = SHORT(frontbottomfg->height); + INT32 backbottomwidth = backbottomfg->width; + INT32 backbottomheight = backbottomfg->height; + INT32 frontbottomwidth = frontbottomfg->width; + INT32 frontbottomheight = frontbottomfg->height; // background M_DrawNightsAttackMountains(); @@ -6151,7 +6151,7 @@ static void M_DrawMessageMenu(void) } V_DrawString((BASEVIDWIDTH - V_StringWidth(string, 0))/2,y,V_ALLOWLOWERCASE,string); - y += 8; //SHORT(hu_font[0]->height); + y += 8; //hu_font[0]->height; } } @@ -9165,10 +9165,10 @@ static void M_DrawSetupChoosePlayerMenu(void) patch_t *charbg = W_CachePatchName("CHARBG", PU_PATCH); patch_t *charfg = W_CachePatchName("CHARFG", PU_PATCH); - INT16 bgheight = SHORT(charbg->height); - INT16 fgheight = SHORT(charfg->height); - INT16 bgwidth = SHORT(charbg->width); - INT16 fgwidth = SHORT(charfg->width); + INT16 bgheight = charbg->height; + INT16 fgheight = charfg->height; + INT16 bgwidth = charbg->width; + INT16 fgwidth = charfg->width; INT32 x, y; INT32 w = (vid.width/vid.dupx); @@ -9260,14 +9260,14 @@ static void M_DrawSetupChoosePlayerMenu(void) curoutlinecolor = col = skincolors[charskin->prefcolor].invcolor; txsh = oxsh; - ox = 8 + SHORT((description[char_on].charpic)->width)/2; + ox = 8 + ((description[char_on].charpic)->width)/2; y = my + 144; // cur { x = ox - txsh; if (curpatch) - x -= (SHORT(curpatch->width)/2); + x -= curpatch->width / 2; if (curtext[0] != '\0') { @@ -9300,7 +9300,7 @@ static void M_DrawSetupChoosePlayerMenu(void) x = (ox - txsh) - w; if (prevpatch) - x -= (SHORT(prevpatch->width)/2); + x -= prevpatch->width / 2; if (prevtext[0] != '\0') { @@ -9330,7 +9330,7 @@ static void M_DrawSetupChoosePlayerMenu(void) x = (ox - txsh) + w; if (nextpatch) - x -= (SHORT(nextpatch->width)/2); + x -= nextpatch->width / 2; if (nexttext[0] != '\0') { @@ -9352,7 +9352,7 @@ static void M_DrawSetupChoosePlayerMenu(void) { patch_t *header = W_CachePatchName("M_PICKP", PU_PATCH); INT32 xtitle = 146; - INT32 ytitle = (35 - SHORT(header->height))/2; + INT32 ytitle = (35 - header->height) / 2; V_DrawFixedPatch(xtitle<leftoffset)/2; - empaty = SHORT(empatch->topoffset)/2; + empatx = empatch->leftoffset / 2; + empaty = empatch->topoffset / 2; if (em->collected) V_DrawSmallMappedPatch(104+76+empatx, yHeight+lsheadingheight/2+empaty, 0, empatch, @@ -10055,7 +10055,7 @@ void M_DrawNightsAttackMenu(void) // Super Sonic M_DrawNightsAttackSuperSonic(); //if (P_HasGrades(cv_nextmap.value, 0)) - // V_DrawScaledPatch(235 - (SHORT((ngradeletters[bestoverall])->width)*3)/2, 135, 0, ngradeletters[bestoverall]); + // V_DrawScaledPatch(235 - (((ngradeletters[bestoverall])->width)*3)/2, 135, 0, ngradeletters[bestoverall]); if (P_HasGrades(cv_nextmap.value, cv_dummymares.value)) {//make bigger again @@ -10612,7 +10612,7 @@ void M_DrawMarathon(void) { patch_t *fg = W_CachePatchName("RECATKFG", PU_PATCH); INT32 trans = V_60TRANS+((cnt&~3)<<(V_ALPHASHIFT-2)); - INT32 height = (SHORT(fg->height)/2); + INT32 height = fg->height / 2; char patchname[7] = "CEMGx0"; dupz = (w*7)/6; //(w*42*120)/(360*6); -- I don't know why this works but I'm not going to complain. @@ -11382,7 +11382,7 @@ static void M_DrawServerMenu(void) else PictureOfLevel = W_CachePatchName("BLANKLVL", PU_PATCH); - V_DrawSmallScaledPatch(319 - (currentMenu->x + (SHORT(PictureOfLevel->width)/2)), currentMenu->y + imgheight, 0, PictureOfLevel); + V_DrawSmallScaledPatch(319 - (currentMenu->x + (PictureOfLevel->width / 2)), currentMenu->y + imgheight, 0, PictureOfLevel); } } diff --git a/src/r_patch.c b/src/r_patch.c index d6db44ea5..1a08d1892 100644 --- a/src/r_patch.c +++ b/src/r_patch.c @@ -31,13 +31,13 @@ patch_t *Patch_Create(softwarepatch_t *source, size_t srcsize, void *dest) if (source) { INT32 col, colsize; - size_t size = sizeof(INT32) * source->width; + size_t size = sizeof(INT32) * SHORT(source->width); size_t offs = (sizeof(INT16) * 4) + size; - patch->width = source->width; - patch->height = source->height; - patch->leftoffset = source->leftoffset; - patch->topoffset = source->topoffset; + patch->width = SHORT(source->width); + patch->height = SHORT(source->height); + patch->leftoffset = SHORT(source->leftoffset); + patch->topoffset = SHORT(source->topoffset); patch->columnofs = Z_Calloc(size, PU_PATCH_DATA, NULL); for (col = 0; col < source->width; col++) diff --git a/src/r_things.c b/src/r_things.c index 9032cd246..30bf15f85 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -297,10 +297,10 @@ boolean R_AddSingleSpriteDef(const char *sprname, spritedef_t *spritedef, UINT16 #endif { W_ReadLumpHeaderPwad(wadnum, l, &patch, sizeof(INT16) * 4, 0); - width = SHORT(patch.width); - height = SHORT(patch.height); - topoffset = SHORT(patch.topoffset); - leftoffset = SHORT(patch.leftoffset); + width = (INT32)(SHORT(patch.width)); + height = (INT32)(SHORT(patch.height)); + topoffset = (INT16)(SHORT(patch.topoffset)); + leftoffset = (INT16)(SHORT(patch.leftoffset)); } spritecachedinfo[numspritelumps].width = width<0 && SHORT(patch.topoffset)>FRACBITS),SHORT(patch.height))<x2 = vid.width-1; localcolfunc = (vis->cut & SC_VFLIP) ? R_DrawFlippedMaskedColumn : R_DrawMaskedColumn; - lengthcol = SHORT(patch->height); + lengthcol = patch->height; // Split drawing loops for paper and non-paper to reduce conditional checks per sprite if (vis->scalestep) @@ -904,7 +898,7 @@ static void R_DrawVisSprite(vissprite_t *vis) fixed_t horzscale = FixedMul(vis->spritexscale, this_scale); fixed_t scalestep = FixedMul(vis->scalestep, vis->spriteyscale); - pwidth = SHORT(patch->width); + pwidth = patch->width; // Papersprite drawing loop for (dc_x = vis->x1; dc_x <= vis->x2; dc_x++, spryscale += scalestep) @@ -929,7 +923,7 @@ static void R_DrawVisSprite(vissprite_t *vis) else if (vis->cut & SC_SHEAR) { #ifdef RANGECHECK - pwidth = SHORT(patch->width); + pwidth = patch->width; #endif // Vertically sheared sprite @@ -951,7 +945,7 @@ static void R_DrawVisSprite(vissprite_t *vis) else { #ifdef RANGECHECK - pwidth = SHORT(patch->width); + pwidth = patch->width; #endif // Non-paper drawing loop @@ -1025,7 +1019,7 @@ static void R_DrawPrecipitationVisSprite(vissprite_t *vis) #ifdef RANGECHECK texturecolumn = frac>>FRACBITS; - if (texturecolumn < 0 || texturecolumn >= SHORT(patch->width)) + if (texturecolumn < 0 || texturecolumn >= patch->width) I_Error("R_DrawPrecipitationSpriteRange: bad texturecolumn"); column = (column_t *)((UINT8 *)patch->columns + (patch->columnofs[texturecolumn])); diff --git a/src/st_stuff.c b/src/st_stuff.c index 45e498323..8ecf4368f 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -458,7 +458,7 @@ boolean st_overlay; static void ST_DrawNightsOverlayNum(fixed_t x /* right border */, fixed_t y, fixed_t s, INT32 a, UINT32 num, patch_t **numpat, skincolornum_t colornum) { - fixed_t w = SHORT(numpat[0]->width)*s; + fixed_t w = numpat[0]->width * s; const UINT8 *colormap; // I want my V_SNAPTOx flags. :< -Red @@ -676,7 +676,7 @@ static void ST_drawRaceNum(INT32 time) if (!(P_AutoPause() || paused) && !bounce) S_StartSound(0, ((racenum == racego) ? sfx_s3kad : sfx_s3ka7)); } - V_DrawScaledPatch(((BASEVIDWIDTH - SHORT(racenum->width))/2), height, V_PERPLAYER, racenum); + V_DrawScaledPatch(((BASEVIDWIDTH - racenum->width)/2), height, V_PERPLAYER, racenum); } static void ST_drawTime(void) @@ -1625,8 +1625,8 @@ static void ST_drawFirstPersonHUD(void) p = W_CachePatchNum(sprframe->lumppat[0], PU_CACHE); // Display the countdown drown numbers! - if (p && !F_GetPromptHideHud(60 - SHORT(p->topoffset))) - V_DrawScaledPatch((BASEVIDWIDTH/2) - (SHORT(p->width)/2) + SHORT(p->leftoffset), 60 - SHORT(p->topoffset), + if (p && !F_GetPromptHideHud(60 - p->topoffset)) + V_DrawScaledPatch((BASEVIDWIDTH/2) - (p->width / 2) + SHORT(p->leftoffset), 60 - SHORT(p->topoffset), V_PERPLAYER|V_PERPLAYER|V_TRANSLUCENT, p); } @@ -2379,7 +2379,7 @@ static void ST_drawTeamHUD(void) p = bmatcico; if (LUA_HudEnabled(hud_teamscores)) - V_DrawSmallScaledPatch(BASEVIDWIDTH/2 - SEP - SHORT(p->width)/4, 4, V_HUDTRANS|V_PERPLAYER|V_SNAPTOTOP, p); + V_DrawSmallScaledPatch(BASEVIDWIDTH/2 - SEP - (p->width / 4), 4, V_HUDTRANS|V_PERPLAYER|V_SNAPTOTOP, p); if (gametyperules & GTR_TEAMFLAGS) p = rflagico; @@ -2387,7 +2387,7 @@ static void ST_drawTeamHUD(void) p = rmatcico; if (LUA_HudEnabled(hud_teamscores)) - V_DrawSmallScaledPatch(BASEVIDWIDTH/2 + SEP - SHORT(p->width)/4, 4, V_HUDTRANS|V_PERPLAYER|V_SNAPTOTOP, p); + V_DrawSmallScaledPatch(BASEVIDWIDTH/2 + SEP - (p->width / 4), 4, V_HUDTRANS|V_PERPLAYER|V_SNAPTOTOP, p); if (!(gametyperules & GTR_TEAMFLAGS)) goto num; @@ -2400,11 +2400,11 @@ static void ST_drawTeamHUD(void) { // Blue flag isn't at base if (players[i].gotflag & GF_BLUEFLAG && LUA_HudEnabled(hud_teamscores)) - V_DrawScaledPatch(BASEVIDWIDTH/2 - SEP - SHORT(nonicon->width)/2, 0, V_HUDTRANS|V_PERPLAYER|V_SNAPTOTOP, nonicon); + V_DrawScaledPatch(BASEVIDWIDTH/2 - SEP - (nonicon->width / 2), 0, V_HUDTRANS|V_PERPLAYER|V_SNAPTOTOP, nonicon); // Red flag isn't at base if (players[i].gotflag & GF_REDFLAG && LUA_HudEnabled(hud_teamscores)) - V_DrawScaledPatch(BASEVIDWIDTH/2 + SEP - SHORT(nonicon2->width)/2, 0, V_HUDTRANS|V_PERPLAYER|V_SNAPTOTOP, nonicon2); + V_DrawScaledPatch(BASEVIDWIDTH/2 + SEP - (nonicon2->width / 2), 0, V_HUDTRANS|V_PERPLAYER|V_SNAPTOTOP, nonicon2); whichflag |= players[i].gotflag; @@ -2677,7 +2677,7 @@ static void ST_overlayDrawer(void) else { tic_t num = time; - INT32 sz = SHORT(tallnum[0]->width)/2, width = 0; + INT32 sz = tallnum[0]->width / 2, width = 0; do { width += sz; diff --git a/src/v_video.c b/src/v_video.c index 522883475..4713db0d8 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -599,13 +599,13 @@ void V_DrawStretchyFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, fixed_t vsca // left offset if (scrn & V_FLIP) - offsetx = FixedMul((SHORT(patch->width) - SHORT(patch->leftoffset))<width - patch->leftoffset)<leftoffset)<leftoffset<topoffset)<topoffset<width) == BASEVIDWIDTH && y == 0 && SHORT(patch->height) == BASEVIDHEIGHT) + if (x == 0 && patch->width == BASEVIDWIDTH && y == 0 && patch->height == BASEVIDHEIGHT) { column = (const column_t *)((const UINT8 *)(patch->columns) + (patch->columnofs[0])); if (!column->topdelta) @@ -754,18 +754,18 @@ void V_DrawStretchyFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, fixed_t vsca if (pscale != FRACUNIT) // scale width properly { - pwidth = SHORT(patch->width)<width<>= FRACBITS; } else - pwidth = SHORT(patch->width) * dupx; + pwidth = patch->width * dupx; deststart = desttop; destend = desttop + pwidth; - for (col = 0; (col>>FRACBITS) < SHORT(patch->width); col += colfrac, ++offx, desttop++) + for (col = 0; (col>>FRACBITS) < patch->width; col += colfrac, ++offx, desttop++) { INT32 topdelta, prevdelta = -1; if (scrn & V_FLIP) // offx is measured from right edge instead of left @@ -862,8 +862,8 @@ void V_DrawCroppedPatch(fixed_t x, fixed_t y, fixed_t pscale, INT32 scrn, patch_ colfrac = FixedDiv(FRACUNIT, fdup); rowfrac = FixedDiv(FRACUNIT, fdup); - y -= FixedMul(SHORT(patch->topoffset)<leftoffset)<topoffset<leftoffset<>FRACBITS) < SHORT(patch->width) && ((col>>FRACBITS) - sx) < w; col += colfrac, ++x, desttop++) + for (col = sx<>FRACBITS) < patch->width && ((col>>FRACBITS) - sx) < w; col += colfrac, ++x, desttop++) { INT32 topdelta, prevdelta = -1; if (x < 0) // don't draw off the left of the screen (WRAP PREVENTION) @@ -1796,7 +1796,7 @@ void V_DrawFlatFill(INT32 x, INT32 y, INT32 w, INT32 h, lumpnum_t flatnum) void V_DrawPatchFill(patch_t *pat) { INT32 dupz = (vid.dupx < vid.dupy ? vid.dupx : vid.dupy); - INT32 x, y, pw = SHORT(pat->width) * dupz, ph = SHORT(pat->height) * dupz; + INT32 x, y, pw = pat->width * dupz, ph = pat->height * dupz; for (x = 0; x < vid.width; x += pw) { @@ -1984,7 +1984,7 @@ void V_DrawCharacter(INT32 x, INT32 y, INT32 c, boolean lowercaseallowed) if (c < 0 || c >= HU_FONTSIZE || !hu_font[c]) return; - w = SHORT(hu_font[c]->width); + w = hu_font[c]->width; if (x + w > vid.width) return; @@ -2011,7 +2011,7 @@ void V_DrawChatCharacter(INT32 x, INT32 y, INT32 c, boolean lowercaseallowed, UI if (c < 0 || c >= HU_FONTSIZE || !hu_font[c]) return; - w = (vid.width < 640 ) ? (SHORT(hu_font[c]->width)/2) : (SHORT(hu_font[c]->width)); // use normal sized characters if we're using a terribly low resolution. + w = (vid.width < 640 ) ? ((hu_font[c]->width / 2)) : (hu_font[c]->width); // use normal sized characters if we're using a terribly low resolution. if (x + w > vid.width) return; @@ -2173,10 +2173,10 @@ void V_DrawString(INT32 x, INT32 y, INT32 option, const char *string) if (charwidth) { w = charwidth * dupx; - center = w/2 - SHORT(hu_font[c]->width)*dupx/2; + center = w/2 - hu_font[c]->width*dupx/2; } else - w = SHORT(hu_font[c]->width) * dupx; + w = hu_font[c]->width * dupx; if (cx > scrwidth) continue; @@ -2290,10 +2290,10 @@ void V_DrawSmallString(INT32 x, INT32 y, INT32 option, const char *string) if (charwidth) { w = charwidth * dupx; - center = w/2 - SHORT(hu_font[c]->width)*dupx/4; + center = w/2 - hu_font[c]->width*dupx/4; } else - w = SHORT(hu_font[c]->width) * dupx / 2; + w = hu_font[c]->width * dupx / 2; if (cx > scrwidth) continue; @@ -2408,7 +2408,7 @@ void V_DrawThinString(INT32 x, INT32 y, INT32 option, const char *string) if (charwidth) w = charwidth * dupx; else - w = (SHORT(tny_font[c]->width) * dupx); + w = tny_font[c]->width * dupx; if (cx > scrwidth) continue; @@ -2547,10 +2547,10 @@ void V_DrawStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string) if (charwidth) { w = charwidth * dupx; - center = w/2 - SHORT(hu_font[c]->width)*(dupx/2); + center = w/2 - hu_font[c]->width*(dupx/2); } else - w = SHORT(hu_font[c]->width) * dupx; + w = hu_font[c]->width * dupx; if ((cx>>FRACBITS) > scrwidth) continue; @@ -2663,10 +2663,10 @@ void V_DrawSmallStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *st if (charwidth) { w = charwidth * dupx; - center = w/2 - SHORT(hu_font[c]->width)*(dupx/4); + center = w/2 - hu_font[c]->width*(dupx/4); } else - w = SHORT(hu_font[c]->width) * dupx / 2; + w = hu_font[c]->width * dupx / 2; if ((cx>>FRACBITS) > scrwidth) break; @@ -2780,10 +2780,10 @@ void V_DrawThinStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *str if (charwidth) { w = charwidth * dupx; - center = w/2 - SHORT(tny_font[c]->width)*(dupx/2); + center = w/2 - tny_font[c]->width*(dupx/2); } else - w = SHORT(tny_font[c]->width) * dupx; + w = tny_font[c]->width * dupx; if ((cx>>FRACBITS) > scrwidth) break; @@ -2897,10 +2897,10 @@ void V_DrawSmallThinStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char if (charwidth) { w = FixedMul(charwidth, dupx); - center = w/2 - SHORT(tny_font[c]->width)*(dupx/4); + center = w/2 - tny_font[c]->width*(dupx/4); } else - w = SHORT(tny_font[c]->width) * dupx / 2; + w = tny_font[c]->width * dupx / 2; if (cx > scrwidth) break; @@ -2933,7 +2933,7 @@ void V_DrawRightAlignedSmallThinStringAtFixed(fixed_t x, fixed_t y, INT32 option // Draws a tallnum. Replaces two functions in y_inter and st_stuff void V_DrawTallNum(INT32 x, INT32 y, INT32 flags, INT32 num) { - INT32 w = SHORT(tallnum[0]->width); + INT32 w = tallnum[0]->width; boolean neg; if (flags & (V_NOSCALESTART|V_NOSCALEPATCH)) @@ -2959,7 +2959,7 @@ void V_DrawTallNum(INT32 x, INT32 y, INT32 flags, INT32 num) // Does not handle negative numbers in a special way, don't try to feed it any. void V_DrawPaddedTallNum(INT32 x, INT32 y, INT32 flags, INT32 num, INT32 digits) { - INT32 w = SHORT(tallnum[0]->width); + INT32 w = tallnum[0]->width; if (flags & (V_NOSCALESTART|V_NOSCALEPATCH)) w *= vid.dupx; @@ -3036,7 +3036,7 @@ void V_DrawCreditString(fixed_t x, fixed_t y, INT32 option, const char *string) continue; } - w = SHORT(cred_font[c]->width) * dupx; + w = cred_font[c]->width * dupx; if ((cx>>FRACBITS) > scrwidth) continue; @@ -3098,7 +3098,7 @@ static void V_DrawNameTagLine(INT32 x, INT32 y, INT32 option, fixed_t scale, UIN continue; } - w = FixedMul((SHORT(ntb_font[c]->width)+2 * dupx) * FRACUNIT, scale); + w = FixedMul(((ntb_font[c]->width)+2 * dupx) * FRACUNIT, scale); if (FixedInt(cx) > scrwidth) continue; @@ -3239,7 +3239,7 @@ INT32 V_NameTagWidth(const char *string) if (c < 0 || c >= NT_FONTSIZE || !ntb_font[c] || !nto_font[c]) w += 4; else - w += SHORT(ntb_font[c]->width)+2; + w += (ntb_font[c]->width)+2; } return w; @@ -3262,7 +3262,7 @@ INT32 V_CreditStringWidth(const char *string) if (c < 0 || c >= CRED_FONTSIZE) w += 16; else - w += SHORT(cred_font[c]->width); + w += cred_font[c]->width; } return w; @@ -3320,7 +3320,7 @@ void V_DrawLevelTitle(INT32 x, INT32 y, INT32 option, const char *string) continue; } - w = SHORT(lt_font[c]->width) * dupx; + w = lt_font[c]->width * dupx; if (cx > scrwidth) continue; @@ -3352,7 +3352,7 @@ INT32 V_LevelNameWidth(const char *string) if (c < 0 || c >= LT_FONTSIZE || !lt_font[c]) w += 16; else - w += SHORT(lt_font[c]->width); + w += lt_font[c]->width; } return w; @@ -3371,8 +3371,8 @@ INT32 V_LevelNameHeight(const char *string) if (c < 0 || c >= LT_FONTSIZE || !lt_font[c]) continue; - if (SHORT(lt_font[c]->height) > w) - w = SHORT(lt_font[c]->height); + if (lt_font[c]->height > w) + w = lt_font[c]->height; } return w; @@ -3385,11 +3385,11 @@ INT16 V_LevelActNumWidth(UINT8 num) INT16 result = 0; if (num == 0) - result = SHORT(ttlnum[num]->width); + result = ttlnum[num]->width; while (num > 0 && num <= 99) { - result = result + SHORT(ttlnum[num%10]->width); + result = result + ttlnum[num%10]->width; num = num/10; } @@ -3427,7 +3427,7 @@ INT32 V_StringWidth(const char *string, INT32 option) if (c < 0 || c >= HU_FONTSIZE || !hu_font[c]) w += spacewidth; else - w += (charwidth ? charwidth : SHORT(hu_font[c]->width)); + w += (charwidth ? charwidth : hu_font[c]->width); } if (option & (V_NOSCALESTART|V_NOSCALEPATCH)) @@ -3467,7 +3467,7 @@ INT32 V_SmallStringWidth(const char *string, INT32 option) if (c < 0 || c >= HU_FONTSIZE || !hu_font[c]) w += spacewidth; else - w += (charwidth ? charwidth : SHORT(hu_font[c]->width)/2); + w += (charwidth ? charwidth : (hu_font[c]->width / 2)); } return w; @@ -3504,7 +3504,7 @@ INT32 V_ThinStringWidth(const char *string, INT32 option) if (c < 0 || c >= HU_FONTSIZE || !tny_font[c]) w += spacewidth; else - w += (charwidth ? charwidth : SHORT(tny_font[c]->width)); + w += (charwidth ? charwidth : tny_font[c]->width); } return w; diff --git a/src/y_inter.c b/src/y_inter.c index acdf5f8d7..061cbb5e1 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -183,7 +183,7 @@ static void Y_IntermissionTokenDrawer(void) offs = 0; lowy = BASEVIDHEIGHT - 32 - 8; - temp = SHORT(tokenicon->height)/2; + temp = tokenicon->height / 2; em = 0; while (emeralds & (1 << em)) @@ -212,7 +212,7 @@ static void Y_IntermissionTokenDrawer(void) calc = (lowy - y)*2; if (calc > 0) - V_DrawCroppedPatch(32<width), calc); + V_DrawCroppedPatch(32<width, calc); } // @@ -402,7 +402,7 @@ void Y_IntermissionDrawer(void) // Total V_DrawScaledPatch(152, bonusy, 0, data.coop.ptotal); V_DrawTallNum(BASEVIDWIDTH - 68, bonusy + 1, 0, data.coop.total); - bonusy -= (3*SHORT(tallnum[0]->height)/2) + 1; + bonusy -= (3*(tallnum[0]->height)/2) + 1; // Draw bonuses for (i = 3; i >= 0; --i) @@ -412,7 +412,7 @@ void Y_IntermissionDrawer(void) V_DrawScaledPatch(152, bonusy, 0, data.coop.bonuspatches[i]); V_DrawTallNum(BASEVIDWIDTH - 68, bonusy + 1, 0, data.coop.bonuses[i].points); } - bonusy -= (3*SHORT(tallnum[0]->height)/2) + 1; + bonusy -= (3*(tallnum[0]->height)/2) + 1; } } else if (intertype == int_spec) @@ -749,10 +749,10 @@ void Y_IntermissionDrawer(void) char name[MAXPLAYERNAME+1]; // Show the team flags and the team score at the top instead of "RESULTS" - V_DrawSmallScaledPatch(128 - SHORT(data.match.blueflag->width)/4, 2, 0, data.match.blueflag); + V_DrawSmallScaledPatch(128 - (data.match.blueflag->width / 4), 2, 0, data.match.blueflag); V_DrawCenteredString(128, 16, 0, va("%u", bluescore)); - V_DrawSmallScaledPatch(192 - SHORT(data.match.redflag->width)/4, 2, 0, data.match.redflag); + V_DrawSmallScaledPatch(192 - (data.match.redflag->width / 4), 2, 0, data.match.redflag); V_DrawCenteredString(192, 16, 0, va("%u", redscore)); // draw the level name From 40e954779e900643564e07766962bc07ac5f9d7d Mon Sep 17 00:00:00 2001 From: James R Date: Sun, 22 Nov 2020 15:12:34 -0800 Subject: [PATCH 0362/1080] Resolve one last conflict in splat sorting Can't use gz/gzt because there is no transformation to make those work differently for splats. --- src/r_things.c | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/src/r_things.c b/src/r_things.c index 2daa6984d..01c02aec4 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -2656,23 +2656,11 @@ static void R_CreateDrawNodes(maskcount_t* mask, drawnode_t* head, boolean temps if (!behind) { - fixed_t z1 = 0, z2 = 0; - - if (rover->mobj->z - viewz > 0) - { - z1 = rover->pz; - z2 = r2->sprite->pz; - } + // FIXME: calculate gz and gzt for splats properly and use that + if (rover->mobj->z < viewz) + infront = (r2->sprite->mobj->z >= rover->mobj->z); else - { - z1 = r2->sprite->pz; - z2 = rover->pz; - } - - z1 -= viewz; - z2 -= viewz; - - infront = (z1 >= z2); + infront = (r2->sprite->mobj->z <= rover->mobj->z); } } else From 7ff64436592af42a64fb729f11b81fffaf707c4e Mon Sep 17 00:00:00 2001 From: LJ Sonic Date: Mon, 23 Nov 2020 01:23:34 +0100 Subject: [PATCH 0363/1080] Fix PlayerCmd not handling angle and aiming correctly --- src/g_game.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/g_game.c b/src/g_game.c index 228295b62..283113bbe 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1677,10 +1677,26 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) } } - // Note: Lat originally made the PlayerCmd hook for SRB2 Kart so credit goes to him. + // At this point, cmd doesn't contain the final angle yet, + // So we need to temporarily transform it so Lua scripters + // don't need to handle it differently than in other hooks. if (gamestate == GS_LEVEL) + { + INT16 extra = ticcmd_oldangleturn[forplayer] - player->oldrelangleturn; + INT16 origangle = cmd->angleturn; + INT16 orighookangle = (INT16)(origangle + player->angleturn + extra); + INT16 origaiming = cmd->aiming; + + cmd->angleturn = orighookangle; + LUAh_PlayerCmd(player, cmd); + extra = cmd->angleturn - orighookangle; + cmd->angleturn = origangle + extra; + *myangle += extra << 16; + *myaiming += (cmd->aiming - origaiming) << 16; + } + //Reset away view if a command is given. if (ssplayer == 1 && (cmd->forwardmove || cmd->sidemove || cmd->buttons) && displayplayer != consoleplayer) From 7bbd563b73dc44ba1373bb3d038f5230a2d6329a Mon Sep 17 00:00:00 2001 From: SMS Alfredo <65426124+SMS-Alfredo@users.noreply.github.com> Date: Sun, 22 Nov 2020 23:23:35 -0600 Subject: [PATCH 0364/1080] Remove unneeded S_PLAY_ROLL check --- src/p_user.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index 004ff71d1..0ffa5e1af 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -2330,8 +2330,7 @@ boolean P_PlayerHitFloor(player_t *player, boolean dorollstuff) P_MobjCheckWater(player->mo); if (player->pflags & PF_SPINNING) { - if (player->mo->state-states != S_PLAY_ROLL && !(player->pflags & PF_STARTDASH) - && player->panim != PA_ROLL && player->panim != PA_ETC + if (!(player->pflags & PF_STARTDASH) && player->panim != PA_ROLL && player->panim != PA_ETC && player->panim != PA_ABILITY && player->panim != PA_ABILITY2) { P_SetPlayerMobjState(player->mo, S_PLAY_ROLL); From 7b05ffd92d101d58aaaf8f5234413ff4ab8a0dd1 Mon Sep 17 00:00:00 2001 From: SMS Alfredo <65426124+SMS-Alfredo@users.noreply.github.com> Date: Mon, 23 Nov 2020 09:18:05 -0600 Subject: [PATCH 0365/1080] Revert "Fix no spin characters being able to damage enemies with their jump out of a spin without removing PF_SPINNING" This reverts commit ad9bf6085f0845c9fde5348c7299136735a83d84. --- src/p_user.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index 0ffa5e1af..2ec8f5995 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -1135,8 +1135,7 @@ boolean P_PlayerCanDamage(player_t *player, mobj_t *thing) return true; // Spinning. - if ((player->pflags & PF_SPINNING) - && !((player->pflags & PF_JUMPED) && (player->pflags & PF_NOJUMPDAMAGE))) + if (player->pflags & PF_SPINNING) return true; if (player->dashmode >= DASHMODE_THRESHOLD && (player->charflags & (SF_DASHMODE|SF_MACHINE)) == (SF_DASHMODE|SF_MACHINE)) @@ -4526,6 +4525,7 @@ void P_DoJump(player_t *player, boolean soundandstate) player->mo->eflags &= ~MFE_APPLYPMOMZ; player->pflags |= P_GetJumpFlags(player);; + player->pflags &= ~PF_SPINNING; if (soundandstate) { From ea7e06a61635860ff266da3864ec0b4ecd8dd295 Mon Sep 17 00:00:00 2001 From: SMS Alfredo <65426124+SMS-Alfredo@users.noreply.github.com> Date: Mon, 23 Nov 2020 09:21:00 -0600 Subject: [PATCH 0366/1080] Remove PF_SPINNING when jumping if you have SF_NOJUMPDAMAGE --- src/p_user.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/p_user.c b/src/p_user.c index 2ec8f5995..da7ad4cb9 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -4525,7 +4525,9 @@ void P_DoJump(player_t *player, boolean soundandstate) player->mo->eflags &= ~MFE_APPLYPMOMZ; player->pflags |= P_GetJumpFlags(player);; - player->pflags &= ~PF_SPINNING; + + if (!(player->charflags & SF_NOJUMPDAMAGE)) + player->pflags &= ~PF_SPINNING; if (soundandstate) { From fe066b3ef28a6b5f3bb91ca10a5ed319469e41d8 Mon Sep 17 00:00:00 2001 From: SMS Alfredo <65426124+SMS-Alfredo@users.noreply.github.com> Date: Mon, 23 Nov 2020 09:23:02 -0600 Subject: [PATCH 0367/1080] ...snickerdoodles --- 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 da7ad4cb9..6c3c6f136 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -4526,7 +4526,7 @@ void P_DoJump(player_t *player, boolean soundandstate) player->pflags |= P_GetJumpFlags(player);; - if (!(player->charflags & SF_NOJUMPDAMAGE)) + if (player->charflags & SF_NOJUMPDAMAGE) player->pflags &= ~PF_SPINNING; if (soundandstate) From 5bdee63117a4dde28cb63b179387d8e2ac9964f7 Mon Sep 17 00:00:00 2001 From: Jaime Ita Passos Date: Mon, 23 Nov 2020 12:53:59 -0300 Subject: [PATCH 0368/1080] Fix a crash --- src/r_plane.c | 12 ++++++++---- src/r_plane.h | 3 +++ src/r_splats.c | 4 +--- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/r_plane.c b/src/r_plane.c index f4fd9c397..c54b32382 100644 --- a/src/r_plane.c +++ b/src/r_plane.c @@ -759,7 +759,7 @@ d->z = (v1.x * v2.y) - (v1.y * v2.x) #undef SFMULT } -static void R_SetSlopePlaneVectors(visplane_t *pl, INT32 y, fixed_t xoff, fixed_t yoff, float fudge) +void R_SetTiltedSpan(INT32 span) { if (ds_su == NULL) ds_su = Z_Malloc(sizeof(*ds_su) * vid.height, PU_STATIC, NULL); @@ -768,10 +768,14 @@ static void R_SetSlopePlaneVectors(visplane_t *pl, INT32 y, fixed_t xoff, fixed_ if (ds_sz == NULL) ds_sz = Z_Malloc(sizeof(*ds_sz) * vid.height, PU_STATIC, NULL); - ds_sup = &ds_su[y]; - ds_svp = &ds_sv[y]; - ds_szp = &ds_sz[y]; + ds_sup = &ds_su[span]; + ds_svp = &ds_sv[span]; + ds_szp = &ds_sz[span]; +} +static void R_SetSlopePlaneVectors(visplane_t *pl, INT32 y, fixed_t xoff, fixed_t yoff, float fudge) +{ + R_SetTiltedSpan(y); R_CalculateSlopeVectors(pl->slope, pl->viewx, pl->viewy, pl->viewz, FRACUNIT, FRACUNIT, xoff, yoff, pl->viewangle, pl->plangle, fudge); } diff --git a/src/r_plane.h b/src/r_plane.h index 7664858c9..0d11c5b72 100644 --- a/src/r_plane.h +++ b/src/r_plane.h @@ -96,6 +96,9 @@ void R_DrawSinglePlane(visplane_t *pl); // Calculates the slope vectors needed for tilted span drawing. void R_CalculateSlopeVectors(pslope_t *slope, fixed_t planeviewx, fixed_t planeviewy, fixed_t planeviewz, fixed_t planexscale, fixed_t planeyscale, fixed_t planexoffset, fixed_t planeyoffset, angle_t planeviewangle, angle_t planeangle, float fudge); +// Sets the slope vector pointers for the current tilted span. +void R_SetTiltedSpan(INT32 span); + typedef struct planemgr_s { visplane_t *plane; diff --git a/src/r_splats.c b/src/r_splats.c index 636aa30ed..a3fad82d8 100644 --- a/src/r_splats.c +++ b/src/r_splats.c @@ -419,9 +419,7 @@ void R_RenderFloorSplat(floorsplat_t *pSplat, vector2_t *verts, vissprite_t *vis // Lactozilla: I don't know what I'm doing if (pSplat->tilted) { - ds_sup = &ds_su[0]; - ds_svp = &ds_sv[0]; - ds_szp = &ds_sz[0]; + R_SetTiltedSpan(0); R_CalculateSlopeVectors(&pSplat->slope, viewx, viewy, viewz, pSplat->xscale, pSplat->yscale, -pSplat->verts[0].x, pSplat->verts[0].y, viewangle, pSplat->angle, 1.0f); spanfunctype = SPANDRAWFUNC_TILTEDSPRITE; } From d8066557693e6446da1d31a11aed921ddd2d1afe Mon Sep 17 00:00:00 2001 From: GoldenTails Date: Mon, 23 Nov 2020 21:20:17 -0600 Subject: [PATCH 0369/1080] Fix a dumb typo of luaL_checklstring i made whoops --- src/lua_script.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lua_script.c b/src/lua_script.c index 160746e9e..14619a220 100644 --- a/src/lua_script.c +++ b/src/lua_script.c @@ -402,7 +402,7 @@ int LUA_CheckGlobals(lua_State *L, const char *word) else if (fastcmp(word, "mapmusname")) { size_t strlength; - const char *str = luaL_checkstring(L, 2, &strlength); + const char *str = luaL_checklstring(L, 2, &strlength); if (strlength > 6) return luaL_error(L, "string length out of range (maximum 6 characters)"); From 8fef61aa29f9a69b18cf48529f760427023a180b Mon Sep 17 00:00:00 2001 From: GoldenTails Date: Thu, 29 Oct 2020 00:48:29 -0500 Subject: [PATCH 0370/1080] Split dehacked.c into multiple files. --- src/CMakeLists.txt | 6 + src/Makefile | 3 + src/deh_lua.c | 688 +++ src/deh_lua.h | 19 + src/deh_soc.c | 4527 ++++++++++++++ src/deh_soc.h | 89 + src/deh_tables.c | 5418 +++++++++++++++++ src/deh_tables.h | 73 + src/dehacked.c | 10727 +-------------------------------- src/dehacked.h | 11 +- src/doomstat.h | 2 +- src/info.h | 4 +- src/lua_infolib.c | 1 + src/lua_script.c | 1 + src/m_menu.c | 2 +- src/sdl/Srb2SDL-vc10.vcxproj | 6 + src/sdl/Srb2SDL-vc9.vcproj | 132 + 17 files changed, 11010 insertions(+), 10699 deletions(-) create mode 100644 src/deh_lua.c create mode 100644 src/deh_lua.h create mode 100644 src/deh_soc.c create mode 100644 src/deh_soc.h create mode 100644 src/deh_tables.c create mode 100644 src/deh_tables.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index fa09c8324..d35e774e9 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -13,6 +13,9 @@ set(SRB2_CORE_SOURCES d_netcmd.c d_netfil.c dehacked.c + deh_soc.c + deh_lua.c + deh_tables.c f_finale.c f_wipe.c filesrch.c @@ -66,6 +69,9 @@ set(SRB2_CORE_HEADERS d_think.h d_ticcmd.h dehacked.h + deh_soc.h + deh_lua.h + deh_tables.h doomdata.h doomdef.h doomstat.h diff --git a/src/Makefile b/src/Makefile index 4a2f3688a..0c1626fc9 100644 --- a/src/Makefile +++ b/src/Makefile @@ -465,6 +465,9 @@ OBJS:=$(i_main_o) \ $(OBJDIR)/d_netfil.o \ $(OBJDIR)/d_netcmd.o \ $(OBJDIR)/dehacked.o \ + $(OBJDIR)/deh_soc.o \ + $(OBJDIR)/deh_lua.o \ + $(OBJDIR)/deh_tables.o \ $(OBJDIR)/z_zone.o \ $(OBJDIR)/f_finale.o \ $(OBJDIR)/f_wipe.o \ diff --git a/src/deh_lua.c b/src/deh_lua.c new file mode 100644 index 000000000..c4b839031 --- /dev/null +++ b/src/deh_lua.c @@ -0,0 +1,688 @@ +// SONIC ROBO BLAST 2 +//----------------------------------------------------------------------------- +// Copyright (C) 1998-2000 by DooM Legacy Team. +// Copyright (C) 1999-2020 by Sonic Team Junior. +// +// This program is free software distributed under the +// terms of the GNU General Public License, version 2. +// See the 'LICENSE' file for more details. +//----------------------------------------------------------------------------- +/// \file deh_lua.c +/// \brief Lua SOC library + +#include "g_game.h" +#include "s_sound.h" +#include "z_zone.h" +#include "m_menu.h" +#include "m_misc.h" +#include "p_local.h" +#include "st_stuff.h" +#include "fastcmp.h" +#include "lua_script.h" +#include "lua_libs.h" + +#include "dehacked.h" +#include "deh_lua.h" +#include "deh_tables.h" + +#ifdef MUSICSLOT_COMPATIBILITY +#include "deh_soc.h" // for get_mus +#endif + +// freeslot takes a name (string only!) +// and allocates it to the appropriate free slot. +// Returns the slot number allocated for it or nil if failed. +// ex. freeslot("MT_MYTHING","S_MYSTATE1","S_MYSTATE2") +// TODO: Error checking! @.@; There's currently no way to know which ones failed and why! +// +static inline int lib_freeslot(lua_State *L) +{ + int n = lua_gettop(L); + int r = 0; // args returned + char *s, *type,*word; + + if (!lua_lumploading) + return luaL_error(L, "This function cannot be called from within a hook or coroutine!"); + + while (n-- > 0) + { + s = Z_StrDup(luaL_checkstring(L,1)); + type = strtok(s, "_"); + if (type) + strupr(type); + else { + Z_Free(s); + return luaL_error(L, "Unknown enum type in '%s'\n", luaL_checkstring(L, 1)); + } + + word = strtok(NULL, "\n"); + if (word) + strupr(word); + else { + Z_Free(s); + return luaL_error(L, "Missing enum name in '%s'\n", luaL_checkstring(L, 1)); + } + 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) { + lua_pushinteger(L, sfx); + r++; + } else + CONS_Alert(CONS_WARNING, "Ran out of free SFX slots!\n"); + } + else if (fastcmp(type, "SPR")) + { + char wad; + spritenum_t j; + lua_getfield(L, LUA_REGISTRYINDEX, "WAD"); + wad = (char)lua_tointeger(L, -1); + lua_pop(L, 1); + for (j = SPR_FIRSTFREESLOT; j <= SPR_LASTFREESLOT; j++) + { + if (used_spr[(j-SPR_FIRSTFREESLOT)/8] & (1<<(j%8))) + { + 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); + 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); + r++; + break; + } + if (j > SPR_LASTFREESLOT) + CONS_Alert(CONS_WARNING, "Ran out of free sprite slots!\n"); + } + else if (fastcmp(type, "S")) + { + statenum_t i; + for (i = 0; i < NUMSTATEFREESLOTS; i++) + if (!FREE_STATES[i]) { + CONS_Printf("State S_%s allocated.\n",word); + FREE_STATES[i] = Z_Malloc(strlen(word)+1, PU_STATIC, NULL); + strcpy(FREE_STATES[i],word); + lua_pushinteger(L, S_FIRSTFREESLOT + i); + r++; + break; + } + if (i == NUMSTATEFREESLOTS) + CONS_Alert(CONS_WARNING, "Ran out of free State slots!\n"); + } + else if (fastcmp(type, "MT")) + { + mobjtype_t i; + for (i = 0; i < NUMMOBJFREESLOTS; i++) + if (!FREE_MOBJS[i]) { + CONS_Printf("MobjType MT_%s allocated.\n",word); + FREE_MOBJS[i] = Z_Malloc(strlen(word)+1, PU_STATIC, NULL); + strcpy(FREE_MOBJS[i],word); + lua_pushinteger(L, MT_FIRSTFREESLOT + i); + r++; + break; + } + if (i == NUMMOBJFREESLOTS) + CONS_Alert(CONS_WARNING, "Ran out of free MobjType slots!\n"); + } + else if (fastcmp(type, "SKINCOLOR")) + { + skincolornum_t i; + for (i = 0; i < NUMCOLORFREESLOTS; i++) + if (!FREE_SKINCOLORS[i]) { + CONS_Printf("Skincolor SKINCOLOR_%s allocated.\n",word); + FREE_SKINCOLORS[i] = Z_Malloc(strlen(word)+1, PU_STATIC, NULL); + strcpy(FREE_SKINCOLORS[i],word); + M_AddMenuColor(numskincolors++); + lua_pushinteger(L, SKINCOLOR_FIRSTFREESLOT + i); + r++; + break; + } + if (i == NUMCOLORFREESLOTS) + CONS_Alert(CONS_WARNING, "Ran out of free skincolor slots!\n"); + } + else if (fastcmp(type, "SPR2")) + { + // Search if we already have an SPR2 by that name... + playersprite_t i; + for (i = SPR2_FIRSTFREESLOT; i < free_spr2; i++) + if (memcmp(spr2names[i],word,4) == 0) + break; + // We don't, so allocate a new one. + if (i >= free_spr2) { + if (free_spr2 < NUMPLAYERSPRITES) + { + CONS_Printf("Sprite SPR2_%s allocated.\n",word); + strncpy(spr2names[free_spr2],word,4); + spr2defaults[free_spr2] = 0; + lua_pushinteger(L, free_spr2); + r++; + spr2names[free_spr2++][4] = 0; + } else + CONS_Alert(CONS_WARNING, "Ran out of free SPR2 slots!\n"); + } + } + else if (fastcmp(type, "TOL")) + { + // Search if we already have a typeoflevel by that name... + int i; + for (i = 0; TYPEOFLEVEL[i].name; i++) + if (fastcmp(word, TYPEOFLEVEL[i].name)) + break; + + // We don't, so allocate a new one. + if (TYPEOFLEVEL[i].name == NULL) { + if (lastcustomtol == (UINT32)MAXTOL) // Unless you have way too many, since they're flags. + CONS_Alert(CONS_WARNING, "Ran out of free typeoflevel slots!\n"); + else { + CONS_Printf("TypeOfLevel TOL_%s allocated.\n",word); + G_AddTOL(lastcustomtol, word); + lua_pushinteger(L, lastcustomtol); + lastcustomtol <<= 1; + r++; + } + } + } + Z_Free(s); + lua_remove(L, 1); + continue; + } + return r; +} + +// Wrapper for ALL A_Action functions. +// Arguments: mobj_t actor, int var1, int var2 +static int action_call(lua_State *L) +{ + //actionf_t *action = lua_touserdata(L,lua_upvalueindex(1)); + actionf_t *action = *((actionf_t **)luaL_checkudata(L, 1, META_ACTION)); + mobj_t *actor = *((mobj_t **)luaL_checkudata(L, 2, META_MOBJ)); + var1 = (INT32)luaL_optinteger(L, 3, 0); + var2 = (INT32)luaL_optinteger(L, 4, 0); + if (!actor) + return LUA_ErrInvalid(L, "mobj_t"); + action->acp1(actor); + return 0; +} + +// Hardcoded A_Action name to call for super() or NULL if super() would be invalid. +// Set in lua_infolib. +const char *superactions[MAXRECURSION]; +UINT8 superstack = 0; + +static int lib_dummysuper(lua_State *L) +{ + return luaL_error(L, "Can't call super() outside of hardcode-replacing A_Action functions being called by state changes!"); // convoluted, I know. @_@;; +} + +static inline int lib_getenum(lua_State *L) +{ + const char *word, *p; + fixed_t i; + boolean mathlib = lua_toboolean(L, lua_upvalueindex(1)); + if (lua_type(L,2) != LUA_TSTRING) + return 0; + word = lua_tostring(L,2); + if (strlen(word) == 1) { // Assume sprite frame if length 1. + if (*word >= 'A' && *word <= '~') + { + lua_pushinteger(L, *word-'A'); + return 1; + } + if (mathlib) return luaL_error(L, "constant '%s' could not be parsed.\n", word); + return 0; + } + else if (fastncmp("MF_", word, 3)) { + p = word+3; + for (i = 0; MOBJFLAG_LIST[i]; i++) + if (fastcmp(p, MOBJFLAG_LIST[i])) { + lua_pushinteger(L, ((lua_Integer)1< return action's string name +static int lib_getActionName(lua_State *L) +{ + if (lua_isuserdata(L, 1)) // arg 1 is built-in action, expect action userdata + { + actionf_t *action = *((actionf_t **)luaL_checkudata(L, 1, META_ACTION)); + const char *name = NULL; + if (!action) + return luaL_error(L, "not a valid action?"); + name = LUA_GetActionName(action); + if (!name) // that can't be right? + return luaL_error(L, "no name string could be found for this action"); + lua_pushstring(L, name); + return 1; + } + else if (lua_isfunction(L, 1)) // arg 1 is a function (either C or Lua) + { + lua_settop(L, 1); // set top of stack to 1 (removing any extra args, which there shouldn't be) + // get the name for this action, if possible. + lua_getfield(L, LUA_REGISTRYINDEX, LREG_ACTIONS); + lua_pushnil(L); + // Lua stack at this point: + // 1 ... -2 -1 + // arg ... LREG_ACTIONS nil + while (lua_next(L, -2)) + { + // Lua stack at this point: + // 1 ... -3 -2 -1 + // arg ... LREG_ACTIONS "A_ACTION" function + if (lua_rawequal(L, -1, 1)) // is this the same as the arg? + { + // make sure the key (i.e. "A_ACTION") is a string first + // (note: we don't use lua_isstring because it also returns true for numbers) + if (lua_type(L, -2) == LUA_TSTRING) + { + lua_pushvalue(L, -2); // push "A_ACTION" string to top of stack + return 1; + } + lua_pop(L, 2); // pop the name and function + break; // probably should have succeeded but we didn't, so end the loop + } + lua_pop(L, 1); + } + lua_pop(L, 1); // pop LREG_ACTIONS + return 0; // return nothing (don't error) + } + + return luaL_typerror(L, 1, "action userdata or Lua function"); +} + + + +int LUA_SOCLib(lua_State *L) +{ + lua_register(L,"freeslot",lib_freeslot); + lua_register(L,"getActionName",lib_getActionName); + + luaL_newmetatable(L, META_ACTION); + lua_pushcfunction(L, action_call); + lua_setfield(L, -2, "__call"); + lua_pop(L, 1); + + return 0; +} + +const char *LUA_GetActionName(void *action) +{ + actionf_t *act = (actionf_t *)action; + size_t z; + for (z = 0; actionpointers[z].name; z++) + { + if (actionpointers[z].action.acv == act->acv) + return actionpointers[z].name; + } + return NULL; +} + +void LUA_SetActionByName(void *state, const char *actiontocompare) +{ + state_t *st = (state_t *)state; + size_t z; + for (z = 0; actionpointers[z].name; z++) + { + if (fasticmp(actiontocompare, actionpointers[z].name)) + { + st->action = actionpointers[z].action; + st->action.acv = actionpointers[z].action.acv; // assign + st->action.acp1 = actionpointers[z].action.acp1; + return; + } + } +} diff --git a/src/deh_lua.h b/src/deh_lua.h new file mode 100644 index 000000000..b464481e4 --- /dev/null +++ b/src/deh_lua.h @@ -0,0 +1,19 @@ +// SONIC ROBO BLAST 2 +//----------------------------------------------------------------------------- +// Copyright (C) 1998-2000 by DooM Legacy Team. +// Copyright (C) 1999-2020 by Sonic Team Junior. +// +// This program is free software distributed under the +// terms of the GNU General Public License, version 2. +// See the 'LICENSE' file for more details. +//----------------------------------------------------------------------------- +/// \file deh_lua.h +/// \brief Lua SOC library + +#ifndef __DEH_LUA_H__ +#define __DEH_LUA_H__ + +boolean LUA_SetLuaAction(void *state, const char *actiontocompare); +const char *LUA_GetActionName(void *action); +void LUA_SetActionByName(void *state, const char *actiontocompare); +#endif diff --git a/src/deh_soc.c b/src/deh_soc.c new file mode 100644 index 000000000..5b12ea1b0 --- /dev/null +++ b/src/deh_soc.c @@ -0,0 +1,4527 @@ +// SONIC ROBO BLAST 2 +//----------------------------------------------------------------------------- +// Copyright (C) 1998-2000 by DooM Legacy Team. +// Copyright (C) 1999-2020 by Sonic Team Junior. +// +// This program is free software distributed under the +// terms of the GNU General Public License, version 2. +// See the 'LICENSE' file for more details. +//----------------------------------------------------------------------------- +/// \file deh_soc.c +/// \brief Load SOC file and change tables and text + +#include "doomdef.h" +#include "d_main.h" // for srb2home +#include "g_game.h" +#include "sounds.h" +#include "info.h" +#include "d_think.h" +#include "m_argv.h" +#include "z_zone.h" +#include "w_wad.h" +#include "y_inter.h" +#include "m_menu.h" +#include "m_misc.h" +#include "f_finale.h" +#include "st_stuff.h" +#include "i_system.h" +#include "p_setup.h" +#include "r_data.h" +#include "r_textures.h" +#include "r_draw.h" +#include "r_picformats.h" +#include "r_things.h" // R_Char2Frame +#include "r_sky.h" +#include "fastcmp.h" +#include "lua_script.h" // Reluctantly included for LUA_EvalMath +#include "d_clisrv.h" + +#ifdef HWRENDER +#include "hardware/hw_light.h" +#endif + +#include "m_cond.h" + +#include "dehacked.h" +#include "deh_soc.h" +#include "deh_lua.h" // included due to some LUA_SetLuaAction hack smh +#include "deh_tables.h" + +// Loops through every constant and operation in word and performs its calculations, returning the final value. +fixed_t get_number(const char *word) +{ + return LUA_EvalMath(word); + + /*// DESPERATELY NEEDED: Order of operations support! :x + fixed_t i = find_const(&word); + INT32 o; + while(*word) { + o = operation_pad(&word); + if (o != -1) + i = OPERATIONS[o].v(i,find_const(&word)); + else + break; + } + return i;*/ +} + +#define PARAMCHECK(n) do { if (!params[n]) { deh_warning("Too few parameters, need %d", n); return; }} while (0) + +/* ======================================================================== */ +// Load a dehacked file format +/* ======================================================================== */ +/* a sample to see + Thing 1 (Player) { // MT_PLAYER +INT32 doomednum; ID # = 3232 -1, // doomednum +INT32 spawnstate; Initial frame = 32 "PLAY", // spawnstate +INT32 spawnhealth; Hit points = 3232 100, // spawnhealth +INT32 seestate; First moving frame = 32 "PLAY_RUN1", // seestate +INT32 seesound; Alert sound = 32 sfx_None, // seesound +INT32 reactiontime; Reaction time = 3232 0, // reactiontime +INT32 attacksound; Attack sound = 32 sfx_None, // attacksound +INT32 painstate; Injury frame = 32 "PLAY_PAIN", // painstate +INT32 painchance; Pain chance = 3232 255, // painchance +INT32 painsound; Pain sound = 32 sfx_plpain, // painsound +INT32 meleestate; Close attack frame = 32 "NULL", // meleestate +INT32 missilestate; Far attack frame = 32 "PLAY_ATK1", // missilestate +INT32 deathstate; Death frame = 32 "PLAY_DIE1", // deathstate +INT32 xdeathstate; Exploding frame = 32 "PLAY_XDIE1", // xdeathstate +INT32 deathsound; Death sound = 32 sfx_pldeth, // deathsound +INT32 speed; Speed = 3232 0, // speed +INT32 radius; Width = 211812352 16*FRACUNIT, // radius +INT32 height; Height = 211812352 56*FRACUNIT, // height +INT32 dispoffset; DispOffset = 0 0, // dispoffset +INT32 mass; Mass = 3232 100, // mass +INT32 damage; Missile damage = 3232 0, // damage +INT32 activesound; Action sound = 32 sfx_None, // activesound +INT32 flags; Bits = 3232 MF_SOLID|MF_SHOOTABLE|MF_DROPOFF|MF_PICKUP|MF_NOTDMATCH, +INT32 raisestate; Respawn frame = 32 S_NULL // raisestate + }, */ + +#ifdef HWRENDER +static INT32 searchvalue(const char *s) +{ + while (s[0] != '=' && s[0]) + s++; + if (s[0] == '=') + return atoi(&s[1]); + else + { + deh_warning("No value found"); + return 0; + } +} + +static float searchfvalue(const char *s) +{ + while (s[0] != '=' && s[0]) + s++; + if (s[0] == '=') + return (float)atof(&s[1]); + else + { + deh_warning("No value found"); + return 0; + } +} +#endif + +// These are for clearing all of various things +void clear_conditionsets(void) +{ + UINT8 i; + for (i = 0; i < MAXCONDITIONSETS; ++i) + M_ClearConditionSet(i+1); +} + +void clear_levels(void) +{ + INT16 i; + + // This is potentially dangerous but if we're resetting these headers, + // we may as well try to save some memory, right? + for (i = 0; i < NUMMAPS; ++i) + { + if (!mapheaderinfo[i] || i == (tutorialmap-1)) + continue; + + // Custom map header info + // (no need to set num to 0, we're freeing the entire header shortly) + Z_Free(mapheaderinfo[i]->customopts); + + P_DeleteFlickies(i); + P_DeleteGrades(i); + + Z_Free(mapheaderinfo[i]); + mapheaderinfo[i] = NULL; + } + + // Realloc the one for the current gamemap as a safeguard + P_AllocMapHeader(gamemap-1); +} + +static boolean findFreeSlot(INT32 *num) +{ + // Send the character select entry to a free slot. + while (*num < MAXSKINS && (description[*num].used)) + *num = *num+1; + + // No more free slots. :( + if (*num >= MAXSKINS) + return false; + + // Redesign your logo. (See M_DrawSetupChoosePlayerMenu in m_menu.c...) + description[*num].picname[0] = '\0'; + description[*num].nametag[0] = '\0'; + description[*num].displayname[0] = '\0'; + description[*num].oppositecolor = SKINCOLOR_NONE; + description[*num].tagtextcolor = SKINCOLOR_NONE; + description[*num].tagoutlinecolor = SKINCOLOR_NONE; + + // Found one! ^_^ + return (description[*num].used = true); +} + +// Reads a player. +// For modifying the character select screen +void readPlayer(MYFILE *f, INT32 num) +{ + char *s = Z_Malloc(MAXLINELEN, PU_STATIC, NULL); + char *word; + char *word2; + char *displayname = ZZ_Alloc(MAXLINELEN+1); + INT32 i; + boolean slotfound = false; + + #define SLOTFOUND \ + if (!slotfound && (slotfound = findFreeSlot(&num)) == false) \ + goto done; + + displayname[MAXLINELEN] = '\0'; + + do + { + if (myfgets(s, MAXLINELEN, f)) + { + if (s[0] == '\n') + break; + + for (i = 0; i < MAXLINELEN-3; i++) + { + char *tmp; + if (s[i] == '=') + { + tmp = &s[i+2]; + strncpy(displayname, tmp, SKINNAMESIZE); + break; + } + } + + word = strtok(s, " "); + if (word) + strupr(word); + else + break; + + if (fastcmp(word, "PLAYERTEXT")) + { + char *playertext = NULL; + + SLOTFOUND + + for (i = 0; i < MAXLINELEN-3; i++) + { + if (s[i] == '=') + { + playertext = &s[i+2]; + break; + } + } + if (playertext) + { + strcpy(description[num].notes, playertext); + strcat(description[num].notes, myhashfgets(playertext, sizeof (description[num].notes), f)); + } + 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 < sizeof(description[num].notes)-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")) + { + SLOTFOUND + strncpy(description[num].picname, word2, 8); + } + // new character select + else if (fastcmp(word, "DISPLAYNAME")) + { + SLOTFOUND + // replace '#' with line breaks + // (also remove any '\n') + { + char *cur = NULL; + + // remove '\n' + cur = strchr(displayname, '\n'); + if (cur) + *cur = '\0'; + + // turn '#' into '\n' + cur = strchr(displayname, '#'); + while (cur) + { + *cur = '\n'; + cur = strchr(cur, '#'); + } + } + // copy final string + strncpy(description[num].displayname, displayname, SKINNAMESIZE); + } + else if (fastcmp(word, "OPPOSITECOLOR") || fastcmp(word, "OPPOSITECOLOUR")) + { + SLOTFOUND + description[num].oppositecolor = (UINT16)get_number(word2); + } + else if (fastcmp(word, "NAMETAG") || fastcmp(word, "TAGNAME")) + { + SLOTFOUND + strncpy(description[num].nametag, word2, 8); + } + else if (fastcmp(word, "TAGTEXTCOLOR") || fastcmp(word, "TAGTEXTCOLOUR")) + { + SLOTFOUND + description[num].tagtextcolor = (UINT16)get_number(word2); + } + else if (fastcmp(word, "TAGOUTLINECOLOR") || fastcmp(word, "TAGOUTLINECOLOUR")) + { + SLOTFOUND + description[num].tagoutlinecolor = (UINT16)get_number(word2); + } + else if (fastcmp(word, "STATUS")) + { + /* + 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 entries you like, but only if you + signal that you are purposely doing so by disabling and then reenabling the slot. + */ + if (i && !slotfound && (slotfound = findFreeSlot(&num)) == false) + goto done; + + description[num].used = (!!i); + } + else if (fastcmp(word, "SKINNAME")) + { + // Send to free slot. + SLOTFOUND + 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 + #undef SLOTFOUND +done: + Z_Free(displayname); + Z_Free(s); +} + +// TODO: Figure out how to do undolines for this.... +// TODO: Warnings for running out of freeslots +void readfreeslots(MYFILE *f) +{ + char *s = Z_Malloc(MAXLINELEN, PU_STATIC, NULL); + char *word,*type; + char *tmp; + int i; + + do + { + if (myfgets(s, MAXLINELEN, f)) + { + if (s[0] == '\n') + break; + + tmp = strchr(s, '#'); + if (tmp) + *tmp = '\0'; + if (s == tmp) + continue; // Skip comment lines, but don't break. + + type = strtok(s, "_"); + if (type) + strupr(type); + else + break; + + word = strtok(NULL, "\n"); + if (word) + strupr(word); + else + break; + + // TODO: Check for existing freeslot mobjs/states/etc. and make errors. + // TODO: Out-of-slots warnings/errors. + // TODO: Name too long (truncated) warnings. + if (fastcmp(type, "SFX")) + S_AddSoundFx(word, false, 0, false); + else if (fastcmp(type, "SPR")) + { + for (i = SPR_FIRSTFREESLOT; i <= SPR_LASTFREESLOT; i++) + { + if (used_spr[(i-SPR_FIRSTFREESLOT)/8] & (1<<(i%8))) + { + 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); + //sprnames[i][4] = 0; + used_spr[(i-SPR_FIRSTFREESLOT)/8] |= 1<<(i%8); // Okay, this sprite slot has been named now. + break; + } + } + else if (fastcmp(type, "S")) + { + for (i = 0; i < NUMSTATEFREESLOTS; i++) + if (!FREE_STATES[i]) { + FREE_STATES[i] = Z_Malloc(strlen(word)+1, PU_STATIC, NULL); + strcpy(FREE_STATES[i],word); + break; + } + } + else if (fastcmp(type, "MT")) + { + for (i = 0; i < NUMMOBJFREESLOTS; i++) + if (!FREE_MOBJS[i]) { + FREE_MOBJS[i] = Z_Malloc(strlen(word)+1, PU_STATIC, NULL); + strcpy(FREE_MOBJS[i],word); + break; + } + } + else if (fastcmp(type, "SKINCOLOR")) + { + for (i = 0; i < NUMCOLORFREESLOTS; i++) + if (!FREE_SKINCOLORS[i]) { + FREE_SKINCOLORS[i] = Z_Malloc(strlen(word)+1, PU_STATIC, NULL); + strcpy(FREE_SKINCOLORS[i],word); + M_AddMenuColor(numskincolors++); + break; + } + } + else if (fastcmp(type, "SPR2")) + { + // Search if we already have an SPR2 by that name... + for (i = SPR2_FIRSTFREESLOT; i < (int)free_spr2; i++) + if (memcmp(spr2names[i],word,4) == 0) + break; + // We found it? (Two mods using the same SPR2 name?) Then don't allocate another one. + if (i < (int)free_spr2) + continue; + // Copy in the spr2 name and increment free_spr2. + if (free_spr2 < NUMPLAYERSPRITES) { + strncpy(spr2names[free_spr2],word,4); + spr2defaults[free_spr2] = 0; + spr2names[free_spr2++][4] = 0; + } else + deh_warning("Ran out of free SPR2 slots!\n"); + } + else if (fastcmp(type, "TOL")) + { + // Search if we already have a typeoflevel by that name... + for (i = 0; TYPEOFLEVEL[i].name; i++) + if (fastcmp(word, TYPEOFLEVEL[i].name)) + break; + + // We found it? Then don't allocate another one. + if (TYPEOFLEVEL[i].name) + continue; + + // We don't, so freeslot it. + if (lastcustomtol == (UINT32)MAXTOL) // Unless you have way too many, since they're flags. + deh_warning("Ran out of free typeoflevel slots!\n"); + else + { + G_AddTOL(lastcustomtol, word); + lastcustomtol <<= 1; + } + } + else + deh_warning("Freeslots: unknown enum class '%s' for '%s_%s'", type, type, word); + } + } while (!myfeof(f)); // finish when the line is empty + + Z_Free(s); +} + +void readthing(MYFILE *f, INT32 num) +{ + char *s = Z_Malloc(MAXLINELEN, PU_STATIC, NULL); + char *word, *word2; + char *tmp; + + do + { + if (myfgets(s, MAXLINELEN, f)) + { + if (s[0] == '\n') + break; + + tmp = strchr(s, '#'); + if (tmp) + *tmp = '\0'; + if (s == tmp) + continue; // Skip comment lines, but don't break. + + word = strtok(s, " "); + if (word) + strupr(word); + else + break; + + word2 = strtok(NULL, " = "); + if (word2) + strupr(word2); + else + break; + if (word2[strlen(word2)-1] == '\n') + word2[strlen(word2)-1] = '\0'; + + if (fastcmp(word, "MAPTHINGNUM") || fastcmp(word, "DOOMEDNUM")) + { + mobjinfo[num].doomednum = (INT32)atoi(word2); + } + else if (fastcmp(word, "SPAWNSTATE")) + { + mobjinfo[num].spawnstate = get_number(word2); + } + else if (fastcmp(word, "SPAWNHEALTH")) + { + mobjinfo[num].spawnhealth = (INT32)get_number(word2); + } + else if (fastcmp(word, "SEESTATE")) + { + mobjinfo[num].seestate = get_number(word2); + } + else if (fastcmp(word, "SEESOUND")) + { + mobjinfo[num].seesound = get_number(word2); + } + else if (fastcmp(word, "REACTIONTIME")) + { + mobjinfo[num].reactiontime = (INT32)get_number(word2); + } + else if (fastcmp(word, "ATTACKSOUND")) + { + mobjinfo[num].attacksound = get_number(word2); + } + else if (fastcmp(word, "PAINSTATE")) + { + mobjinfo[num].painstate = get_number(word2); + } + else if (fastcmp(word, "PAINCHANCE")) + { + mobjinfo[num].painchance = (INT32)get_number(word2); + } + else if (fastcmp(word, "PAINSOUND")) + { + mobjinfo[num].painsound = get_number(word2); + } + else if (fastcmp(word, "MELEESTATE")) + { + mobjinfo[num].meleestate = get_number(word2); + } + else if (fastcmp(word, "MISSILESTATE")) + { + mobjinfo[num].missilestate = get_number(word2); + } + else if (fastcmp(word, "DEATHSTATE")) + { + mobjinfo[num].deathstate = get_number(word2); + } + else if (fastcmp(word, "DEATHSOUND")) + { + mobjinfo[num].deathsound = get_number(word2); + } + else if (fastcmp(word, "XDEATHSTATE")) + { + mobjinfo[num].xdeathstate = get_number(word2); + } + else if (fastcmp(word, "SPEED")) + { + mobjinfo[num].speed = get_number(word2); + } + else if (fastcmp(word, "RADIUS")) + { + mobjinfo[num].radius = get_number(word2); + } + else if (fastcmp(word, "HEIGHT")) + { + mobjinfo[num].height = get_number(word2); + } + else if (fastcmp(word, "DISPOFFSET")) + { + mobjinfo[num].dispoffset = get_number(word2); + } + else if (fastcmp(word, "MASS")) + { + mobjinfo[num].mass = (INT32)get_number(word2); + } + else if (fastcmp(word, "DAMAGE")) + { + mobjinfo[num].damage = (INT32)get_number(word2); + } + else if (fastcmp(word, "ACTIVESOUND")) + { + mobjinfo[num].activesound = get_number(word2); + } + else if (fastcmp(word, "FLAGS")) + { + mobjinfo[num].flags = (INT32)get_number(word2); + } + else if (fastcmp(word, "RAISESTATE")) + { + mobjinfo[num].raisestate = get_number(word2); + } + else + deh_warning("Thing %d: unknown word '%s'", num, word); + } + } while (!myfeof(f)); // finish when the line is empty + + Z_Free(s); +} + +void readskincolor(MYFILE *f, INT32 num) +{ + char *s = Z_Malloc(MAXLINELEN, PU_STATIC, NULL); + char *word = s; + char *word2; + char *tmp; + + Color_cons_t[num].value = num; + + do + { + if (myfgets(s, MAXLINELEN, f)) + { + if (s[0] == '\n') + break; + + // First remove trailing newline, if there is one + tmp = strchr(s, '\n'); + if (tmp) + *tmp = '\0'; + + tmp = strchr(s, '#'); + if (tmp) + *tmp = '\0'; + if (s == tmp) + continue; // Skip comment lines, but don't break. + + // Get the part before the " = " + tmp = strchr(s, '='); + if (tmp) + *(tmp-1) = '\0'; + else + break; + strupr(word); + + // Now get the part after + word2 = tmp += 2; + + if (fastcmp(word, "NAME")) + { + size_t namesize = sizeof(skincolors[num].name); + char truncword[namesize]; + UINT16 dupecheck; + + deh_strlcpy(truncword, word2, namesize, va("Skincolor %d: name", num)); // truncate here to check for dupes + dupecheck = R_GetColorByName(truncword); + if (truncword[0] != '\0' && (!stricmp(truncword, skincolors[SKINCOLOR_NONE].name) || (dupecheck && dupecheck != num))) + { + size_t lastchar = strlen(truncword); + char oldword[lastchar+1]; + char dupenum = '1'; + + strlcpy(oldword, truncword, lastchar+1); + lastchar--; + if (lastchar == namesize-2) // exactly max length, replace last character with 0 + truncword[lastchar] = '0'; + else // append 0 + { + strcat(truncword, "0"); + lastchar++; + } + + while (R_GetColorByName(truncword)) + { + truncword[lastchar] = dupenum; + if (dupenum == '9') + dupenum = 'A'; + else if (dupenum == 'Z') // give up :? + break; + else + dupenum++; + } + + deh_warning("Skincolor %d: name %s is a duplicate of another skincolor's name - renamed to %s", num, oldword, truncword); + } + + strlcpy(skincolors[num].name, truncword, namesize); // already truncated + } + else if (fastcmp(word, "RAMP")) + { + UINT8 i; + tmp = strtok(word2,","); + for (i = 0; i < COLORRAMPSIZE; i++) { + skincolors[num].ramp[i] = (UINT8)get_number(tmp); + if ((tmp = strtok(NULL,",")) == NULL) + break; + } + skincolor_modified[num] = true; + } + else if (fastcmp(word, "INVCOLOR")) + { + UINT16 v = (UINT16)get_number(word2); + if (v < numskincolors) + skincolors[num].invcolor = v; + else + skincolors[num].invcolor = SKINCOLOR_GREEN; + } + else if (fastcmp(word, "INVSHADE")) + { + skincolors[num].invshade = get_number(word2)%COLORRAMPSIZE; + } + else if (fastcmp(word, "CHATCOLOR")) + { + skincolors[num].chatcolor = get_number(word2); + } + else if (fastcmp(word, "ACCESSIBLE")) + { + if (num > FIRSTSUPERCOLOR) + skincolors[num].accessible = (boolean)(atoi(word2) || word2[0] == 'T' || word2[0] == 'Y'); + } + else + deh_warning("Skincolor %d: unknown word '%s'", num, word); + } + } while (!myfeof(f)); // finish when the line is empty + + Z_Free(s); +} + +#ifdef HWRENDER +void readlight(MYFILE *f, INT32 num) +{ + char *s = Z_Malloc(MAXLINELEN, PU_STATIC, NULL); + char *word; + char *tmp; + INT32 value; + float fvalue; + + do + { + if (myfgets(s, MAXLINELEN, f)) + { + if (s[0] == '\n') + break; + + tmp = strchr(s, '#'); + if (tmp) + *tmp = '\0'; + if (s == tmp) + continue; // Skip comment lines, but don't break. + + fvalue = searchfvalue(s); + value = searchvalue(s); + + word = strtok(s, " "); + if (word) + strupr(word); + else + break; + + if (fastcmp(word, "TYPE")) + { + lspr[num].type = (UINT16)value; + } + else if (fastcmp(word, "OFFSETX")) + { + lspr[num].light_xoffset = fvalue; + } + else if (fastcmp(word, "OFFSETY")) + { + lspr[num].light_yoffset = fvalue; + } + else if (fastcmp(word, "CORONACOLOR")) + { + lspr[num].corona_color = value; + } + else if (fastcmp(word, "CORONARADIUS")) + { + lspr[num].corona_radius = fvalue; + } + else if (fastcmp(word, "DYNAMICCOLOR")) + { + lspr[num].dynamic_color = value; + } + else if (fastcmp(word, "DYNAMICRADIUS")) + { + lspr[num].dynamic_radius = fvalue; + + /// \note Update the sqrradius! unnecessary? + lspr[num].dynamic_sqrradius = fvalue * fvalue; + } + else + deh_warning("Light %d: unknown word '%s'", num, word); + } + } while (!myfeof(f)); // finish when the line is empty + + Z_Free(s); +} +#endif // HWRENDER + +static void readspriteframe(MYFILE *f, spriteinfo_t *sprinfo, UINT8 frame) +{ + char *s = Z_Malloc(MAXLINELEN, PU_STATIC, NULL); + char *word, *word2; + char *tmp; + INT32 value; + char *lastline; + + do + { + lastline = f->curpos; + if (myfgets(s, MAXLINELEN, f)) + { + if (s[0] == '\n') + break; + + // First remove trailing newline, if there is one + tmp = strchr(s, '\n'); + if (tmp) + *tmp = '\0'; + + tmp = strchr(s, '#'); + if (tmp) + *tmp = '\0'; + if (s == tmp) + continue; // Skip comment lines, but don't break. + + // Set / reset word + word = s; + while ((*word == '\t') || (*word == ' ')) + word++; + + // Get the part before the " = " + tmp = strchr(s, '='); + if (tmp) + { + *(tmp-1) = '\0'; + // Now get the part after + word2 = tmp += 2; + } + else + { + // Get the part before the " " + tmp = strchr(s, ' '); + if (tmp) + { + *tmp = '\0'; + // Now get the part after + tmp++; + word2 = tmp; + } + else + break; + } + strupr(word); + value = atoi(word2); // used for numerical settings + + if (fastcmp(word, "XPIVOT")) + sprinfo->pivot[frame].x = value; + else if (fastcmp(word, "YPIVOT")) + sprinfo->pivot[frame].y = value; + else if (fastcmp(word, "ROTAXIS")) + sprinfo->pivot[frame].rotaxis = value; + else + { + f->curpos = lastline; + break; + } + } + } while (!myfeof(f)); // finish when the line is empty + Z_Free(s); +} + +void readspriteinfo(MYFILE *f, INT32 num, boolean sprite2) +{ + char *s = Z_Malloc(MAXLINELEN, PU_STATIC, NULL); + char *word, *word2; + char *tmp; +#ifdef HWRENDER + INT32 value; +#endif + char *lastline; + INT32 skinnumbers[MAXSKINS]; + INT32 foundskins = 0; + + // allocate a spriteinfo + spriteinfo_t *info = Z_Calloc(sizeof(spriteinfo_t), PU_STATIC, NULL); + info->available = true; + + do + { + lastline = f->curpos; + if (myfgets(s, MAXLINELEN, f)) + { + if (s[0] == '\n') + break; + + // First remove trailing newline, if there is one + tmp = strchr(s, '\n'); + if (tmp) + *tmp = '\0'; + + tmp = strchr(s, '#'); + if (tmp) + *tmp = '\0'; + if (s == tmp) + continue; // Skip comment lines, but don't break. + + // Set / reset word + word = s; + while ((*word == '\t') || (*word == ' ')) + word++; + + // Get the part before the " = " + tmp = strchr(s, '='); + if (tmp) + { + *(tmp-1) = '\0'; + // Now get the part after + word2 = tmp += 2; + } + else + { + // Get the part before the " " + tmp = strchr(s, ' '); + if (tmp) + { + *tmp = '\0'; + // Now get the part after + tmp++; + word2 = tmp; + } + else + break; + } + strupr(word); +#ifdef HWRENDER + value = atoi(word2); // used for numerical settings + + if (fastcmp(word, "LIGHTTYPE")) + { + if (sprite2) + deh_warning("Sprite2 %s: invalid word '%s'", spr2names[num], word); + else + { + INT32 oldvar; + for (oldvar = 0; t_lspr[num] != &lspr[oldvar]; oldvar++) + ; + t_lspr[num] = &lspr[value]; + } + } + else +#endif + if (fastcmp(word, "SKIN")) + { + INT32 skinnum = -1; + if (!sprite2) + { + deh_warning("Sprite %s: %s keyword found outside of SPRITE2INFO block, ignoring", spr2names[num], word); + continue; + } + + // make lowercase + strlwr(word2); + skinnum = R_SkinAvailable(word2); + if (skinnum == -1) + { + deh_warning("Sprite2 %s: unknown skin %s", spr2names[num], word2); + break; + } + + skinnumbers[foundskins] = skinnum; + foundskins++; + } + else if (fastcmp(word, "DEFAULT")) + { + if (!sprite2) + { + deh_warning("Sprite %s: %s keyword found outside of SPRITE2INFO block, ignoring", spr2names[num], word); + continue; + } + if (num < (INT32)free_spr2 && num >= (INT32)SPR2_FIRSTFREESLOT) + spr2defaults[num] = get_number(word2); + else + { + deh_warning("Sprite2 %s: out of range (%d - %d), ignoring", spr2names[num], SPR2_FIRSTFREESLOT, free_spr2-1); + continue; + } + } + else if (fastcmp(word, "FRAME")) + { + UINT8 frame = R_Char2Frame(word2[0]); + // frame number too high + if (frame >= 64) + { + if (sprite2) + deh_warning("Sprite2 %s: invalid frame %s", spr2names[num], word2); + else + deh_warning("Sprite %s: invalid frame %s", sprnames[num], word2); + break; + } + + // read sprite frame and store it in the spriteinfo_t struct + readspriteframe(f, info, frame); + if (sprite2) + { + INT32 i; + if (!foundskins) + { + deh_warning("Sprite2 %s: no skins specified", spr2names[num]); + break; + } + for (i = 0; i < foundskins; i++) + { + size_t skinnum = skinnumbers[i]; + skin_t *skin = &skins[skinnum]; + spriteinfo_t *sprinfo = skin->sprinfo; + M_Memcpy(&sprinfo[num], info, sizeof(spriteinfo_t)); + } + } + else + M_Memcpy(&spriteinfo[num], info, sizeof(spriteinfo_t)); + } + else + { + //deh_warning("Sprite %s: unknown word '%s'", sprnames[num], word); + f->curpos = lastline; + break; + } + } + } while (!myfeof(f)); // finish when the line is empty + + Z_Free(s); + Z_Free(info); +} + +void readsprite2(MYFILE *f, INT32 num) +{ + char *s = Z_Malloc(MAXLINELEN, PU_STATIC, NULL); + char *word, *word2; + char *tmp; + + do + { + if (myfgets(s, MAXLINELEN, f)) + { + if (s[0] == '\n') + break; + + tmp = strchr(s, '#'); + if (tmp) + *tmp = '\0'; + if (s == tmp) + continue; // Skip comment lines, but don't break. + + word = strtok(s, " "); + if (word) + strupr(word); + else + break; + + word2 = strtok(NULL, " = "); + if (word2) + strupr(word2); + else + break; + if (word2[strlen(word2)-1] == '\n') + word2[strlen(word2)-1] = '\0'; + + if (fastcmp(word, "DEFAULT")) + spr2defaults[num] = get_number(word2); + else + deh_warning("Sprite2 %s: unknown word '%s'", spr2names[num], word); + } + } while (!myfeof(f)); // finish when the line is empty + + Z_Free(s); +} + +// copypasted from readPlayer :] +void readgametype(MYFILE *f, char *gtname) +{ + char *s = Z_Malloc(MAXLINELEN, PU_STATIC, NULL); + char *word; + char *word2, *word2lwr = NULL; + char *tmp; + INT32 i, j; + + INT16 newgtidx = 0; + UINT32 newgtrules = 0; + UINT32 newgttol = 0; + INT32 newgtpointlimit = 0; + INT32 newgttimelimit = 0; + UINT8 newgtleftcolor = 0; + UINT8 newgtrightcolor = 0; + INT16 newgtrankingstype = -1; + int newgtinttype = 0; + char gtdescription[441]; + char gtconst[MAXLINELEN]; + + // Empty strings. + gtdescription[0] = '\0'; + gtconst[0] = '\0'; + + do + { + if (myfgets(s, MAXLINELEN, f)) + { + if (s[0] == '\n') + break; + + word = strtok(s, " "); + if (word) + strupr(word); + else + break; + + if (fastcmp(word, "DESCRIPTION")) + { + char *descr = NULL; + + for (i = 0; i < MAXLINELEN-3; i++) + { + if (s[i] == '=') + { + descr = &s[i+2]; + break; + } + } + if (descr) + { + strcpy(gtdescription, descr); + strcat(gtdescription, myhashfgets(descr, sizeof (gtdescription), f)); + } + else + strcpy(gtdescription, ""); + + // 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 < sizeof(gtdescription)-1; i++) + { + if (numline < 20 && gtdescription[i] == '\n') + numline++; + + if (numline >= 20 || gtdescription[i] == '\0' || gtdescription[i] == '#') + break; + } + } + gtdescription[strlen(gtdescription)-1] = '\0'; + gtdescription[i] = '\0'; + continue; + } + + word2 = strtok(NULL, " = "); + if (word2) + { + if (!word2lwr) + word2lwr = Z_Malloc(MAXLINELEN, PU_STATIC, NULL); + strcpy(word2lwr, word2); + strupr(word2); + } + else + break; + + if (word2[strlen(word2)-1] == '\n') + word2[strlen(word2)-1] = '\0'; + i = atoi(word2); + + // Game type rules + if (fastcmp(word, "RULES")) + { + // GTR_ + newgtrules = (UINT32)get_number(word2); + } + // Identifier + else if (fastcmp(word, "IDENTIFIER")) + { + // GT_ + strncpy(gtconst, word2, MAXLINELEN); + } + // Point and time limits + else if (fastcmp(word, "DEFAULTPOINTLIMIT")) + newgtpointlimit = (INT32)i; + else if (fastcmp(word, "DEFAULTTIMELIMIT")) + newgttimelimit = (INT32)i; + // Level platter + else if (fastcmp(word, "HEADERCOLOR") || fastcmp(word, "HEADERCOLOUR")) + newgtleftcolor = newgtrightcolor = (UINT8)get_number(word2); + else if (fastcmp(word, "HEADERLEFTCOLOR") || fastcmp(word, "HEADERLEFTCOLOUR")) + newgtleftcolor = (UINT8)get_number(word2); + else if (fastcmp(word, "HEADERRIGHTCOLOR") || fastcmp(word, "HEADERRIGHTCOLOUR")) + newgtrightcolor = (UINT8)get_number(word2); + // Rankings type + else if (fastcmp(word, "RANKINGTYPE")) + { + // Case insensitive + newgtrankingstype = (int)get_number(word2); + } + // Intermission type + else if (fastcmp(word, "INTERMISSIONTYPE")) + { + // Case sensitive + newgtinttype = (int)get_number(word2lwr); + } + // Type of level + else if (fastcmp(word, "TYPEOFLEVEL")) + { + if (i) // it's just a number + newgttol = (UINT32)i; + else + { + UINT32 tol = 0; + tmp = strtok(word2,","); + do { + for (i = 0; TYPEOFLEVEL[i].name; i++) + if (fasticmp(tmp, TYPEOFLEVEL[i].name)) + break; + if (!TYPEOFLEVEL[i].name) + deh_warning("readgametype %s: unknown typeoflevel flag %s\n", gtname, tmp); + tol |= TYPEOFLEVEL[i].flag; + } while((tmp = strtok(NULL,",")) != NULL); + newgttol = tol; + } + } + // The SOC probably provided gametype rules as words, + // instead of using the RULES keyword. + // Like for example "NOSPECTATORSPAWN = TRUE". + // This is completely valid, and looks better anyway. + else + { + UINT32 wordgt = 0; + for (j = 0; GAMETYPERULE_LIST[j]; j++) + if (fastcmp(word, GAMETYPERULE_LIST[j])) { + wordgt |= (1<lvlttl, word2, + sizeof(mapheaderinfo[num-1]->lvlttl), va("Level header %d: levelname", num)); + strlcpy(mapheaderinfo[num-1]->selectheading, word2, sizeof(mapheaderinfo[num-1]->selectheading)); // not deh_ so only complains once + continue; + } + // CHEAP HACK: move this over here for lowercase subtitles + if (fastcmp(word, "SUBTITLE")) + { + deh_strlcpy(mapheaderinfo[num-1]->subttl, word2, + sizeof(mapheaderinfo[num-1]->subttl), va("Level header %d: subtitle", num)); + continue; + } + + // Lua custom options also go above, contents may be case sensitive. + if (fastncmp(word, "LUA.", 4)) + { + UINT8 j; + customoption_t *modoption; + + // Note: we actualy strlwr word here, so things are made a little easier for Lua + strlwr(word); + word += 4; // move past "lua." + + // ... and do a simple name sanity check; the name must start with a letter + if (*word < 'a' || *word > 'z') + { + deh_warning("Level header %d: invalid custom option name \"%s\"", num, word); + continue; + } + + // Sanity limit of 128 params + if (mapheaderinfo[num-1]->numCustomOptions == 128) + { + deh_warning("Level header %d: too many custom parameters", num); + continue; + } + j = mapheaderinfo[num-1]->numCustomOptions++; + + mapheaderinfo[num-1]->customopts = + Z_Realloc(mapheaderinfo[num-1]->customopts, + sizeof(customoption_t) * mapheaderinfo[num-1]->numCustomOptions, PU_STATIC, NULL); + + // Newly allocated + modoption = &mapheaderinfo[num-1]->customopts[j]; + + strncpy(modoption->option, word, 31); + modoption->option[31] = '\0'; + strncpy(modoption->value, word2, 255); + modoption->value[255] = '\0'; + continue; + } + + // Now go to uppercase + strupr(word2); + + // List of flickies that are be freed in this map + if (fastcmp(word, "FLICKYLIST") || fastcmp(word, "ANIMALLIST")) + { + if (fastcmp(word2, "NONE")) + P_DeleteFlickies(num-1); + else if (fastcmp(word2, "DEMO")) + P_SetDemoFlickies(num-1); + else if (fastcmp(word2, "ALL")) + { + mobjtype_t tmpflickies[MAXFLICKIES]; + + for (mapheaderinfo[num-1]->numFlickies = 0; + ((mapheaderinfo[num-1]->numFlickies < MAXFLICKIES) && FLICKYTYPES[mapheaderinfo[num-1]->numFlickies].type); + mapheaderinfo[num-1]->numFlickies++) + tmpflickies[mapheaderinfo[num-1]->numFlickies] = FLICKYTYPES[mapheaderinfo[num-1]->numFlickies].type; + + if (mapheaderinfo[num-1]->numFlickies) // just in case... + { + size_t newsize = sizeof(mobjtype_t) * mapheaderinfo[num-1]->numFlickies; + mapheaderinfo[num-1]->flickies = Z_Realloc(mapheaderinfo[num-1]->flickies, newsize, PU_STATIC, NULL); + M_Memcpy(mapheaderinfo[num-1]->flickies, tmpflickies, newsize); + } + } + else + { + mobjtype_t tmpflickies[MAXFLICKIES]; + mapheaderinfo[num-1]->numFlickies = 0; + tmp = strtok(word2,","); + // get up to the first MAXFLICKIES flickies + do { + if (mapheaderinfo[num-1]->numFlickies == MAXFLICKIES) // never going to get above that number + { + deh_warning("Level header %d: too many flickies\n", num); + break; + } + + if (fastncmp(tmp, "MT_", 3)) // support for specified mobjtypes... + { + i = get_mobjtype(tmp); + if (!i) + { + //deh_warning("Level header %d: unknown flicky mobj type %s\n", num, tmp); -- no need for this line as get_mobjtype complains too + continue; + } + tmpflickies[mapheaderinfo[num-1]->numFlickies] = i; + } + else // ...or a quick, limited selection of default flickies! + { + for (i = 0; FLICKYTYPES[i].name; i++) + if (fastcmp(tmp, FLICKYTYPES[i].name)) + break; + + if (!FLICKYTYPES[i].name) + { + deh_warning("Level header %d: unknown flicky selection %s\n", num, tmp); + continue; + } + tmpflickies[mapheaderinfo[num-1]->numFlickies] = FLICKYTYPES[i].type; + } + mapheaderinfo[num-1]->numFlickies++; + } while ((tmp = strtok(NULL,",")) != NULL); + + if (mapheaderinfo[num-1]->numFlickies) + { + size_t newsize = sizeof(mobjtype_t) * mapheaderinfo[num-1]->numFlickies; + mapheaderinfo[num-1]->flickies = Z_Realloc(mapheaderinfo[num-1]->flickies, newsize, PU_STATIC, NULL); + // now we add them to the list! + M_Memcpy(mapheaderinfo[num-1]->flickies, tmpflickies, newsize); + } + else + deh_warning("Level header %d: no valid flicky types found\n", num); + } + } + + // NiGHTS grades + else 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, "SELECTHEADING")) + { + deh_strlcpy(mapheaderinfo[num-1]->selectheading, word2, + sizeof(mapheaderinfo[num-1]->selectheading), va("Level header %d: selectheading", num)); + } + else if (fastcmp(word, "SCRIPTNAME")) + { + deh_strlcpy(mapheaderinfo[num-1]->scriptname, word2, + sizeof(mapheaderinfo[num-1]->scriptname), va("Level header %d: scriptname", num)); + } + else if (fastcmp(word, "RUNSOC")) + { + deh_strlcpy(mapheaderinfo[num-1]->runsoc, word2, + sizeof(mapheaderinfo[num-1]->runsoc), va("Level header %d: runsoc", num)); + } + else if (fastcmp(word, "ACT")) + { + if (i >= 0 && i <= 99) // 0 for no act number + mapheaderinfo[num-1]->actnum = (UINT8)i; + else + deh_warning("Level header %d: invalid act number %d", num, i); + } + else if (fastcmp(word, "NEXTLEVEL")) + { + if (fastcmp(word2, "TITLE")) i = 1100; + else if (fastcmp(word2, "EVALUATION")) i = 1101; + else if (fastcmp(word2, "CREDITS")) i = 1102; + else if (fastcmp(word2, "ENDING")) i = 1103; + else + // Support using the actual map name, + // i.e., Nextlevel = AB, Nextlevel = FZ, etc. + + // Convert to map number + if (word2[0] >= 'A' && word2[0] <= 'Z' && word2[2] == '\0') + i = M_MapNumber(word2[0], word2[1]); + + mapheaderinfo[num-1]->nextlevel = (INT16)i; + } + else if (fastcmp(word, "MARATHONNEXT")) + { + if (fastcmp(word2, "TITLE")) i = 1100; + else if (fastcmp(word2, "EVALUATION")) i = 1101; + else if (fastcmp(word2, "CREDITS")) i = 1102; + else if (fastcmp(word2, "ENDING")) i = 1103; + else + // Support using the actual map name, + // i.e., MarathonNext = AB, MarathonNext = FZ, etc. + + // Convert to map number + if (word2[0] >= 'A' && word2[0] <= 'Z' && word2[2] == '\0') + i = M_MapNumber(word2[0], word2[1]); + + mapheaderinfo[num-1]->marathonnext = (INT16)i; + } + else if (fastcmp(word, "TYPEOFLEVEL")) + { + if (i) // it's just a number + mapheaderinfo[num-1]->typeoflevel = (UINT32)i; + else + { + UINT32 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; + } + } + else if (fastcmp(word, "KEYWORDS")) + { + deh_strlcpy(mapheaderinfo[num-1]->keywords, word2, + sizeof(mapheaderinfo[num-1]->keywords), va("Level header %d: keywords", num)); + } + else if (fastcmp(word, "MUSIC")) + { + if (fastcmp(word2, "NONE")) + mapheaderinfo[num-1]->musname[0] = 0; // becomes empty string + else + { + deh_strlcpy(mapheaderinfo[num-1]->musname, word2, + sizeof(mapheaderinfo[num-1]->musname), va("Level header %d: music", num)); + } + } +#ifdef MUSICSLOT_COMPATIBILITY + else if (fastcmp(word, "MUSICSLOT")) + { + i = get_mus(word2, true); + if (i && i <= 1035) + snprintf(mapheaderinfo[num-1]->musname, 7, "%sM", G_BuildMapName(i)); + else if (i && i <= 1050) + strncpy(mapheaderinfo[num-1]->musname, compat_special_music_slots[i - 1036], 7); + else + mapheaderinfo[num-1]->musname[0] = 0; // becomes empty string + mapheaderinfo[num-1]->musname[6] = 0; + } +#endif + else if (fastcmp(word, "MUSICTRACK")) + 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, "MUSICPOSTBOSS")) + deh_strlcpy(mapheaderinfo[num-1]->muspostbossname, word2, + sizeof(mapheaderinfo[num-1]->muspostbossname), va("Level header %d: post-boss music", num)); + else if (fastcmp(word, "MUSICPOSTBOSSTRACK")) + mapheaderinfo[num-1]->muspostbosstrack = ((UINT16)i - 1); + else if (fastcmp(word, "MUSICPOSTBOSSPOS")) + mapheaderinfo[num-1]->muspostbosspos = (UINT32)get_number(word2); + else if (fastcmp(word, "MUSICPOSTBOSSFADEIN")) + mapheaderinfo[num-1]->muspostbossfadein = (UINT32)get_number(word2); + else if (fastcmp(word, "FORCERESETMUSIC")) + { + // This is a weird one because "FALSE"/"NO" could either apply to "leave to default preference" (cv_resetmusic) + // or "force off". Let's assume it means "force off", and let an unspecified value mean "default preference" + if (fastcmp(word2, "OFF") || word2[0] == 'F' || word2[0] == 'N') i = 0; + else if (fastcmp(word2, "ON") || word2[0] == 'T' || word2[0] == 'Y') i = 1; + else i = -1; // (fastcmp(word2, "DEFAULT")) + + if (i >= -1 && i <= 1) // -1 to force off, 1 to force on, 0 to honor default. + // This behavior can be disabled with cv_resetmusicbyheader + mapheaderinfo[num-1]->musforcereset = (SINT8)i; + else + deh_warning("Level header %d: invalid forceresetmusic option %d", num, i); + } + else if (fastcmp(word, "FORCECHARACTER")) + { + strlcpy(mapheaderinfo[num-1]->forcecharacter, word2, SKINNAMESIZE+1); + strlwr(mapheaderinfo[num-1]->forcecharacter); // skin names are lowercase + } + else if (fastcmp(word, "WEATHER")) + mapheaderinfo[num-1]->weather = (UINT8)get_number(word2); + else if (fastcmp(word, "SKYNUM")) + mapheaderinfo[num-1]->skynum = (INT16)i; + else if (fastcmp(word, "INTERSCREEN")) + strncpy(mapheaderinfo[num-1]->interscreen, word2, 8); + else if (fastcmp(word, "PRECUTSCENENUM")) + mapheaderinfo[num-1]->precutscenenum = (UINT8)i; + else if (fastcmp(word, "CUTSCENENUM")) + mapheaderinfo[num-1]->cutscenenum = (UINT8)i; + else if (fastcmp(word, "COUNTDOWN")) + mapheaderinfo[num-1]->countdown = (INT16)i; + else if (fastcmp(word, "PALETTE")) + mapheaderinfo[num-1]->palette = (UINT16)i; + else if (fastcmp(word, "NUMLAPS")) + mapheaderinfo[num-1]->numlaps = (UINT8)i; + else if (fastcmp(word, "UNLOCKABLE")) + { + if (i >= 0 && i <= MAXUNLOCKABLES) // 0 for no unlock required, anything else requires something + mapheaderinfo[num-1]->unlockrequired = (SINT8)i - 1; + else + deh_warning("Level header %d: invalid unlockable number %d", num, i); + } + else if (fastcmp(word, "LEVELSELECT")) + mapheaderinfo[num-1]->levelselect = (UINT8)i; + else if (fastcmp(word, "SKYBOXSCALE")) + mapheaderinfo[num-1]->skybox_scalex = mapheaderinfo[num-1]->skybox_scaley = mapheaderinfo[num-1]->skybox_scalez = (INT16)i; + else if (fastcmp(word, "SKYBOXSCALEX")) + mapheaderinfo[num-1]->skybox_scalex = (INT16)i; + else if (fastcmp(word, "SKYBOXSCALEY")) + mapheaderinfo[num-1]->skybox_scaley = (INT16)i; + 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; + else if (fastcmp(word2, "NIGHTS")) i = 3; + else if (fastcmp(word2, "NIGHTSLINK")) i = 4; + + if (i >= -1 && i <= 4) // -1 for no bonus. Max is 4. + mapheaderinfo[num-1]->bonustype = (SINT8)i; + else + deh_warning("Level header %d: invalid bonus type number %d", num, i); + } + + // Title card + else if (fastcmp(word, "TITLECARDZIGZAG")) + { + deh_strlcpy(mapheaderinfo[num-1]->ltzzpatch, word2, + sizeof(mapheaderinfo[num-1]->ltzzpatch), va("Level header %d: title card zigzag patch name", num)); + } + else if (fastcmp(word, "TITLECARDZIGZAGTEXT")) + { + deh_strlcpy(mapheaderinfo[num-1]->ltzztext, word2, + sizeof(mapheaderinfo[num-1]->ltzztext), va("Level header %d: title card zigzag text patch name", num)); + } + else if (fastcmp(word, "TITLECARDACTDIAMOND")) + { + deh_strlcpy(mapheaderinfo[num-1]->ltactdiamond, word2, + sizeof(mapheaderinfo[num-1]->ltactdiamond), va("Level header %d: title card act diamond patch name", num)); + } + + else if (fastcmp(word, "MAXBONUSLIVES")) + mapheaderinfo[num-1]->maxbonuslives = (SINT8)i; + else if (fastcmp(word, "LEVELFLAGS")) + mapheaderinfo[num-1]->levelflags = (UINT16)i; + else if (fastcmp(word, "MENUFLAGS")) + mapheaderinfo[num-1]->menuflags = (UINT8)i; + + // Individual triggers for level flags, for ease of use (and 2.0 compatibility) + else if (fastcmp(word, "SCRIPTISFILE")) + { + if (i || word2[0] == 'T' || word2[0] == 'Y') + mapheaderinfo[num-1]->levelflags |= LF_SCRIPTISFILE; + else + mapheaderinfo[num-1]->levelflags &= ~LF_SCRIPTISFILE; + } + else if (fastcmp(word, "SPEEDMUSIC")) + { + if (i || word2[0] == 'T' || word2[0] == 'Y') + mapheaderinfo[num-1]->levelflags |= LF_SPEEDMUSIC; + else + mapheaderinfo[num-1]->levelflags &= ~LF_SPEEDMUSIC; + } + else if (fastcmp(word, "NOSSMUSIC")) + { + if (i || word2[0] == 'T' || word2[0] == 'Y') + mapheaderinfo[num-1]->levelflags |= LF_NOSSMUSIC; + else + mapheaderinfo[num-1]->levelflags &= ~LF_NOSSMUSIC; + } + else if (fastcmp(word, "NORELOAD")) + { + if (i || word2[0] == 'T' || word2[0] == 'Y') + mapheaderinfo[num-1]->levelflags |= LF_NORELOAD; + else + mapheaderinfo[num-1]->levelflags &= ~LF_NORELOAD; + } + else if (fastcmp(word, "NOZONE")) + { + if (i || word2[0] == 'T' || word2[0] == 'Y') + mapheaderinfo[num-1]->levelflags |= LF_NOZONE; + else + mapheaderinfo[num-1]->levelflags &= ~LF_NOZONE; + } + else if (fastcmp(word, "SAVEGAME")) + { + if (i || word2[0] == 'T' || word2[0] == 'Y') + mapheaderinfo[num-1]->levelflags |= LF_SAVEGAME; + else + mapheaderinfo[num-1]->levelflags &= ~LF_SAVEGAME; + } + else if (fastcmp(word, "MIXNIGHTSCOUNTDOWN")) + { + if (i || word2[0] == 'T' || word2[0] == 'Y') + mapheaderinfo[num-1]->levelflags |= LF_MIXNIGHTSCOUNTDOWN; + else + mapheaderinfo[num-1]->levelflags &= ~LF_MIXNIGHTSCOUNTDOWN; + } + else if (fastcmp(word, "WARNINGTITLE")) + { + if (i || word2[0] == 'T' || word2[0] == 'Y') + mapheaderinfo[num-1]->levelflags |= LF_WARNINGTITLE; + else + mapheaderinfo[num-1]->levelflags &= ~LF_WARNINGTITLE; + } + else if (fastcmp(word, "NOTITLECARD")) + { + if (i || word2[0] == 'T' || word2[0] == 'Y') + mapheaderinfo[num-1]->levelflags |= LF_NOTITLECARD; + else + mapheaderinfo[num-1]->levelflags &= ~LF_NOTITLECARD; + } + else if (fastcmp(word, "SHOWTITLECARDFOR")) + { + mapheaderinfo[num-1]->levelflags |= LF_NOTITLECARD; + tmp = strtok(word2,","); + do { + if (fastcmp(tmp, "FIRST")) + mapheaderinfo[num-1]->levelflags &= ~LF_NOTITLECARDFIRST; + else if (fastcmp(tmp, "RESPAWN")) + mapheaderinfo[num-1]->levelflags &= ~LF_NOTITLECARDRESPAWN; + else if (fastcmp(tmp, "RECORDATTACK")) + mapheaderinfo[num-1]->levelflags &= ~LF_NOTITLECARDRECORDATTACK; + else if (fastcmp(tmp, "ALL")) + mapheaderinfo[num-1]->levelflags &= ~LF_NOTITLECARD; + else if (!fastcmp(tmp, "NONE")) + deh_warning("Level header %d: unknown titlecard show option %s\n", num, tmp); + + } while((tmp = strtok(NULL,",")) != NULL); + } + + // Individual triggers for menu flags + else if (fastcmp(word, "HIDDEN")) + { + if (i || word2[0] == 'T' || word2[0] == 'Y') + mapheaderinfo[num-1]->menuflags |= LF2_HIDEINMENU; + else + mapheaderinfo[num-1]->menuflags &= ~LF2_HIDEINMENU; + } + else if (fastcmp(word, "HIDEINSTATS")) + { + if (i || word2[0] == 'T' || word2[0] == 'Y') + mapheaderinfo[num-1]->menuflags |= LF2_HIDEINSTATS; + else + mapheaderinfo[num-1]->menuflags &= ~LF2_HIDEINSTATS; + } + else if (fastcmp(word, "RECORDATTACK") || fastcmp(word, "TIMEATTACK")) + { // TIMEATTACK is an accepted alias + if (i || word2[0] == 'T' || word2[0] == 'Y') + mapheaderinfo[num-1]->menuflags |= LF2_RECORDATTACK; + else + mapheaderinfo[num-1]->menuflags &= ~LF2_RECORDATTACK; + } + else if (fastcmp(word, "NIGHTSATTACK")) + { + if (i || word2[0] == 'T' || word2[0] == 'Y') + mapheaderinfo[num-1]->menuflags |= LF2_NIGHTSATTACK; + else + mapheaderinfo[num-1]->menuflags &= LF2_NIGHTSATTACK; + } + else if (fastcmp(word, "NOVISITNEEDED")) + { + if (i || word2[0] == 'T' || word2[0] == 'Y') + mapheaderinfo[num-1]->menuflags |= LF2_NOVISITNEEDED; + else + mapheaderinfo[num-1]->menuflags &= ~LF2_NOVISITNEEDED; + } + else if (fastcmp(word, "WIDEICON")) + { + if (i || word2[0] == 'T' || word2[0] == 'Y') + mapheaderinfo[num-1]->menuflags |= LF2_WIDEICON; + else + mapheaderinfo[num-1]->menuflags &= ~LF2_WIDEICON; + } + else if (fastcmp(word, "STARTRINGS")) + mapheaderinfo[num-1]->startrings = (UINT16)i; + else if (fastcmp(word, "SPECIALSTAGETIME")) + mapheaderinfo[num-1]->sstimer = i; + else if (fastcmp(word, "SPECIALSTAGESPHERES")) + mapheaderinfo[num-1]->ssspheres = i; + else if (fastcmp(word, "GRAVITY")) + mapheaderinfo[num-1]->gravity = FLOAT_TO_FIXED(atof(word2)); + else + deh_warning("Level header %d: unknown word '%s'", num, word); + } + } while (!myfeof(f)); // finish when the line is empty + + Z_Free(s); +} + +static void readcutscenescene(MYFILE *f, INT32 num, INT32 scenenum) +{ + char *s = Z_Calloc(MAXLINELEN, PU_STATIC, NULL); + char *word; + char *word2; + INT32 i; + UINT16 usi; + UINT8 picid; + + do + { + if (myfgets(s, MAXLINELEN, f)) + { + if (s[0] == '\n') + break; + + word = strtok(s, " "); + if (word) + strupr(word); + else + break; + + if (fastcmp(word, "SCENETEXT")) + { + char *scenetext = NULL; + char *buffer; + const int bufferlen = 4096; + + for (i = 0; i < MAXLINELEN; i++) + { + if (s[i] == '=') + { + scenetext = &s[i+2]; + break; + } + } + + if (!scenetext) + { + Z_Free(cutscenes[num]->scene[scenenum].text); + cutscenes[num]->scene[scenenum].text = NULL; + continue; + } + + for (i = 0; i < MAXLINELEN; i++) + { + if (s[i] == '\0') + { + s[i] = '\n'; + s[i+1] = '\0'; + break; + } + } + + buffer = Z_Malloc(4096, PU_STATIC, NULL); + strcpy(buffer, scenetext); + + strcat(buffer, + myhashfgets(scenetext, bufferlen + - strlen(buffer) - 1, f)); + + // A cutscene overwriting another one... + Z_Free(cutscenes[num]->scene[scenenum].text); + + cutscenes[num]->scene[scenenum].text = Z_StrDup(buffer); + + Z_Free(buffer); + + continue; + } + + word2 = strtok(NULL, " = "); + if (word2) + strupr(word2); + else + break; + + if (word2[strlen(word2)-1] == '\n') + word2[strlen(word2)-1] = '\0'; + i = atoi(word2); + usi = (UINT16)i; + + + if (fastcmp(word, "NUMBEROFPICS")) + { + cutscenes[num]->scene[scenenum].numpics = (UINT8)i; + } + else if (fastncmp(word, "PIC", 3)) + { + picid = (UINT8)atoi(word + 3); + if (picid > 8 || picid == 0) + { + deh_warning("CutSceneScene %d: unknown word '%s'", num, word); + continue; + } + --picid; + + if (fastcmp(word+4, "NAME")) + { + strncpy(cutscenes[num]->scene[scenenum].picname[picid], word2, 8); + } + else if (fastcmp(word+4, "HIRES")) + { + cutscenes[num]->scene[scenenum].pichires[picid] = (UINT8)(i || word2[0] == 'T' || word2[0] == 'Y'); + } + else if (fastcmp(word+4, "DURATION")) + { + cutscenes[num]->scene[scenenum].picduration[picid] = usi; + } + else if (fastcmp(word+4, "XCOORD")) + { + cutscenes[num]->scene[scenenum].xcoord[picid] = usi; + } + else if (fastcmp(word+4, "YCOORD")) + { + cutscenes[num]->scene[scenenum].ycoord[picid] = usi; + } + else + deh_warning("CutSceneScene %d: unknown word '%s'", num, word); + } + else if (fastcmp(word, "MUSIC")) + { + strncpy(cutscenes[num]->scene[scenenum].musswitch, word2, 7); + cutscenes[num]->scene[scenenum].musswitch[6] = 0; + } +#ifdef MUSICSLOT_COMPATIBILITY + 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 + else if (fastcmp(word, "MUSICTRACK")) + { + cutscenes[num]->scene[scenenum].musswitchflags = ((UINT16)i) & MUSIC_TRACKMASK; + } + else if (fastcmp(word, "MUSICPOS")) + { + cutscenes[num]->scene[scenenum].musswitchposition = (UINT32)get_number(word2); + } + else if (fastcmp(word, "MUSICLOOP")) + { + cutscenes[num]->scene[scenenum].musicloop = (UINT8)(i || word2[0] == 'T' || word2[0] == 'Y'); + } + else if (fastcmp(word, "TEXTXPOS")) + { + cutscenes[num]->scene[scenenum].textxpos = usi; + } + else if (fastcmp(word, "TEXTYPOS")) + { + cutscenes[num]->scene[scenenum].textypos = usi; + } + else if (fastcmp(word, "FADEINID")) + { + cutscenes[num]->scene[scenenum].fadeinid = (UINT8)i; + } + else if (fastcmp(word, "FADEOUTID")) + { + cutscenes[num]->scene[scenenum].fadeoutid = (UINT8)i; + } + else if (fastcmp(word, "FADECOLOR")) + { + cutscenes[num]->scene[scenenum].fadecolor = (UINT8)i; + } + else + deh_warning("CutSceneScene %d: unknown word '%s'", num, word); + } + } while (!myfeof(f)); // finish when the line is empty + + Z_Free(s); +} + +void readcutscene(MYFILE *f, INT32 num) +{ + char *s = Z_Malloc(MAXLINELEN, PU_STATIC, NULL); + char *word; + char *word2; + char *tmp; + INT32 value; + + // Allocate memory for this cutscene if we don't yet have any + if (!cutscenes[num]) + cutscenes[num] = Z_Calloc(sizeof (cutscene_t), PU_STATIC, NULL); + + do + { + if (myfgets(s, MAXLINELEN, f)) + { + if (s[0] == '\n') + break; + + tmp = strchr(s, '#'); + if (tmp) + *tmp = '\0'; + if (s == tmp) + continue; // Skip comment lines, but don't break. + + word = strtok(s, " "); + if (word) + strupr(word); + else + break; + + word2 = strtok(NULL, " "); + if (word2) + value = atoi(word2); + else + { + deh_warning("No value for token %s", word); + continue; + } + + if (fastcmp(word, "NUMSCENES")) + { + cutscenes[num]->numscenes = value; + } + else if (fastcmp(word, "SCENE")) + { + if (1 <= value && value <= 128) + { + readcutscenescene(f, num, value - 1); + } + else + deh_warning("Scene number %d out of range (1 - 128)", value); + + } + else + deh_warning("Cutscene %d: unknown word '%s', Scene expected.", num, word); + } + } while (!myfeof(f)); // finish when the line is empty + + Z_Free(s); +} + +static void readtextpromptpage(MYFILE *f, INT32 num, INT32 pagenum) +{ + char *s = Z_Calloc(MAXLINELEN, PU_STATIC, NULL); + char *word; + char *word2; + INT32 i; + UINT16 usi; + UINT8 picid; + + do + { + if (myfgets(s, MAXLINELEN, f)) + { + if (s[0] == '\n') + break; + + word = strtok(s, " "); + if (word) + strupr(word); + else + break; + + if (fastcmp(word, "PAGETEXT")) + { + char *pagetext = NULL; + char *buffer; + const int bufferlen = 4096; + + for (i = 0; i < MAXLINELEN; i++) + { + if (s[i] == '=') + { + pagetext = &s[i+2]; + break; + } + } + + if (!pagetext) + { + Z_Free(textprompts[num]->page[pagenum].text); + textprompts[num]->page[pagenum].text = NULL; + continue; + } + + for (i = 0; i < MAXLINELEN; i++) + { + if (s[i] == '\0') + { + s[i] = '\n'; + s[i+1] = '\0'; + break; + } + } + + buffer = Z_Malloc(4096, PU_STATIC, NULL); + strcpy(buffer, pagetext); + + // \todo trim trailing whitespace before the # + // and also support # at the end of a PAGETEXT with no line break + + strcat(buffer, + myhashfgets(pagetext, bufferlen + - strlen(buffer) - 1, f)); + + // A text prompt overwriting another one... + Z_Free(textprompts[num]->page[pagenum].text); + + textprompts[num]->page[pagenum].text = Z_StrDup(buffer); + + Z_Free(buffer); + + continue; + } + + word2 = strtok(NULL, " = "); + if (word2) + strupr(word2); + else + break; + + if (word2[strlen(word2)-1] == '\n') + word2[strlen(word2)-1] = '\0'; + i = atoi(word2); + usi = (UINT16)i; + + // copypasta from readcutscenescene + if (fastcmp(word, "NUMBEROFPICS")) + { + textprompts[num]->page[pagenum].numpics = (UINT8)i; + } + else if (fastcmp(word, "PICMODE")) + { + UINT8 picmode = 0; // PROMPT_PIC_PERSIST + if (usi == 1 || word2[0] == 'L') picmode = PROMPT_PIC_LOOP; + else if (usi == 2 || word2[0] == 'D' || word2[0] == 'H') picmode = PROMPT_PIC_DESTROY; + textprompts[num]->page[pagenum].picmode = picmode; + } + else if (fastcmp(word, "PICTOLOOP")) + textprompts[num]->page[pagenum].pictoloop = (UINT8)i; + else if (fastcmp(word, "PICTOSTART")) + textprompts[num]->page[pagenum].pictostart = (UINT8)i; + else if (fastcmp(word, "PICSMETAPAGE")) + { + if (usi && usi <= textprompts[num]->numpages) + { + UINT8 metapagenum = usi - 1; + + textprompts[num]->page[pagenum].numpics = textprompts[num]->page[metapagenum].numpics; + textprompts[num]->page[pagenum].picmode = textprompts[num]->page[metapagenum].picmode; + textprompts[num]->page[pagenum].pictoloop = textprompts[num]->page[metapagenum].pictoloop; + textprompts[num]->page[pagenum].pictostart = textprompts[num]->page[metapagenum].pictostart; + + for (picid = 0; picid < MAX_PROMPT_PICS; picid++) + { + strncpy(textprompts[num]->page[pagenum].picname[picid], textprompts[num]->page[metapagenum].picname[picid], 8); + textprompts[num]->page[pagenum].pichires[picid] = textprompts[num]->page[metapagenum].pichires[picid]; + textprompts[num]->page[pagenum].picduration[picid] = textprompts[num]->page[metapagenum].picduration[picid]; + textprompts[num]->page[pagenum].xcoord[picid] = textprompts[num]->page[metapagenum].xcoord[picid]; + textprompts[num]->page[pagenum].ycoord[picid] = textprompts[num]->page[metapagenum].ycoord[picid]; + } + } + } + else if (fastncmp(word, "PIC", 3)) + { + picid = (UINT8)atoi(word + 3); + if (picid > MAX_PROMPT_PICS || picid == 0) + { + deh_warning("textpromptscene %d: unknown word '%s'", num, word); + continue; + } + --picid; + + if (fastcmp(word+4, "NAME")) + { + strncpy(textprompts[num]->page[pagenum].picname[picid], word2, 8); + } + else if (fastcmp(word+4, "HIRES")) + { + textprompts[num]->page[pagenum].pichires[picid] = (UINT8)(i || word2[0] == 'T' || word2[0] == 'Y'); + } + else if (fastcmp(word+4, "DURATION")) + { + textprompts[num]->page[pagenum].picduration[picid] = usi; + } + else if (fastcmp(word+4, "XCOORD")) + { + textprompts[num]->page[pagenum].xcoord[picid] = usi; + } + else if (fastcmp(word+4, "YCOORD")) + { + textprompts[num]->page[pagenum].ycoord[picid] = usi; + } + else + deh_warning("textpromptscene %d: unknown word '%s'", num, word); + } + else if (fastcmp(word, "MUSIC")) + { + strncpy(textprompts[num]->page[pagenum].musswitch, word2, 7); + textprompts[num]->page[pagenum].musswitch[6] = 0; + } +#ifdef MUSICSLOT_COMPATIBILITY + else if (fastcmp(word, "MUSICSLOT")) + { + i = get_mus(word2, true); + if (i && i <= 1035) + snprintf(textprompts[num]->page[pagenum].musswitch, 7, "%sM", G_BuildMapName(i)); + else if (i && i <= 1050) + strncpy(textprompts[num]->page[pagenum].musswitch, compat_special_music_slots[i - 1036], 7); + else + textprompts[num]->page[pagenum].musswitch[0] = 0; // becomes empty string + textprompts[num]->page[pagenum].musswitch[6] = 0; + } +#endif + else if (fastcmp(word, "MUSICTRACK")) + { + textprompts[num]->page[pagenum].musswitchflags = ((UINT16)i) & MUSIC_TRACKMASK; + } + else if (fastcmp(word, "MUSICLOOP")) + { + textprompts[num]->page[pagenum].musicloop = (UINT8)(i || word2[0] == 'T' || word2[0] == 'Y'); + } + // end copypasta from readcutscenescene + else if (fastcmp(word, "NAME")) + { + if (*word2 != '\0') + { + INT32 j; + + // HACK: Add yellow control char now + // so the drawing function doesn't call it repeatedly + char name[34]; + name[0] = '\x82'; // color yellow + name[1] = 0; + strncat(name, word2, 33); + name[33] = 0; + + // Replace _ with ' ' + for (j = 0; j < 32 && name[j]; j++) + { + if (name[j] == '_') + name[j] = ' '; + } + + strncpy(textprompts[num]->page[pagenum].name, name, 32); + } + else + *textprompts[num]->page[pagenum].name = '\0'; + } + else if (fastcmp(word, "ICON")) + strncpy(textprompts[num]->page[pagenum].iconname, word2, 8); + else if (fastcmp(word, "ICONALIGN")) + textprompts[num]->page[pagenum].rightside = (i || word2[0] == 'R'); + else if (fastcmp(word, "ICONFLIP")) + textprompts[num]->page[pagenum].iconflip = (i || word2[0] == 'T' || word2[0] == 'Y'); + else if (fastcmp(word, "LINES")) + textprompts[num]->page[pagenum].lines = usi; + else if (fastcmp(word, "BACKCOLOR")) + { + INT32 backcolor; + if (i == 0 || fastcmp(word2, "WHITE")) backcolor = 0; + else if (i == 1 || fastcmp(word2, "GRAY") || fastcmp(word2, "GREY") || + fastcmp(word2, "BLACK")) backcolor = 1; + else if (i == 2 || fastcmp(word2, "SEPIA")) backcolor = 2; + else if (i == 3 || fastcmp(word2, "BROWN")) backcolor = 3; + else if (i == 4 || fastcmp(word2, "PINK")) backcolor = 4; + else if (i == 5 || fastcmp(word2, "RASPBERRY")) backcolor = 5; + else if (i == 6 || fastcmp(word2, "RED")) backcolor = 6; + else if (i == 7 || fastcmp(word2, "CREAMSICLE")) backcolor = 7; + else if (i == 8 || fastcmp(word2, "ORANGE")) backcolor = 8; + else if (i == 9 || fastcmp(word2, "GOLD")) backcolor = 9; + else if (i == 10 || fastcmp(word2, "YELLOW")) backcolor = 10; + else if (i == 11 || fastcmp(word2, "EMERALD")) backcolor = 11; + else if (i == 12 || fastcmp(word2, "GREEN")) backcolor = 12; + else if (i == 13 || fastcmp(word2, "CYAN") || fastcmp(word2, "AQUA")) backcolor = 13; + else if (i == 14 || fastcmp(word2, "STEEL")) backcolor = 14; + else if (i == 15 || fastcmp(word2, "PERIWINKLE")) backcolor = 15; + else if (i == 16 || fastcmp(word2, "BLUE")) backcolor = 16; + else if (i == 17 || fastcmp(word2, "PURPLE")) backcolor = 17; + else if (i == 18 || fastcmp(word2, "LAVENDER")) backcolor = 18; + else if (i >= 256 && i < 512) backcolor = i; // non-transparent palette index + else if (i < 0) backcolor = INT32_MAX; // CONS_BACKCOLOR user-configured + else backcolor = 1; // default gray + textprompts[num]->page[pagenum].backcolor = backcolor; + } + else if (fastcmp(word, "ALIGN")) + { + UINT8 align = 0; // left + if (usi == 1 || word2[0] == 'R') align = 1; + else if (usi == 2 || word2[0] == 'C' || word2[0] == 'M') align = 2; + textprompts[num]->page[pagenum].align = align; + } + else if (fastcmp(word, "VERTICALALIGN")) + { + UINT8 align = 0; // top + if (usi == 1 || word2[0] == 'B') align = 1; + else if (usi == 2 || word2[0] == 'C' || word2[0] == 'M') align = 2; + textprompts[num]->page[pagenum].verticalalign = align; + } + else if (fastcmp(word, "TEXTSPEED")) + textprompts[num]->page[pagenum].textspeed = get_number(word2); + else if (fastcmp(word, "TEXTSFX")) + textprompts[num]->page[pagenum].textsfx = get_number(word2); + else if (fastcmp(word, "HIDEHUD")) + { + UINT8 hidehud = 0; + if ((word2[0] == 'F' && (word2[1] == 'A' || !word2[1])) || word2[0] == 'N') hidehud = 0; // false + else if (usi == 1 || word2[0] == 'T' || word2[0] == 'Y') hidehud = 1; // true (hide appropriate HUD elements) + else if (usi == 2 || word2[0] == 'A' || (word2[0] == 'F' && word2[1] == 'O')) hidehud = 2; // force (hide all HUD elements) + textprompts[num]->page[pagenum].hidehud = hidehud; + } + else if (fastcmp(word, "METAPAGE")) + { + if (usi && usi <= textprompts[num]->numpages) + { + UINT8 metapagenum = usi - 1; + + strncpy(textprompts[num]->page[pagenum].name, textprompts[num]->page[metapagenum].name, 32); + strncpy(textprompts[num]->page[pagenum].iconname, textprompts[num]->page[metapagenum].iconname, 8); + textprompts[num]->page[pagenum].rightside = textprompts[num]->page[metapagenum].rightside; + textprompts[num]->page[pagenum].iconflip = textprompts[num]->page[metapagenum].iconflip; + textprompts[num]->page[pagenum].lines = textprompts[num]->page[metapagenum].lines; + textprompts[num]->page[pagenum].backcolor = textprompts[num]->page[metapagenum].backcolor; + textprompts[num]->page[pagenum].align = textprompts[num]->page[metapagenum].align; + textprompts[num]->page[pagenum].verticalalign = textprompts[num]->page[metapagenum].verticalalign; + textprompts[num]->page[pagenum].textspeed = textprompts[num]->page[metapagenum].textspeed; + textprompts[num]->page[pagenum].textsfx = textprompts[num]->page[metapagenum].textsfx; + textprompts[num]->page[pagenum].hidehud = textprompts[num]->page[metapagenum].hidehud; + + // music: don't copy, else each page change may reset the music + } + } + else if (fastcmp(word, "TAG")) + strncpy(textprompts[num]->page[pagenum].tag, word2, 33); + else if (fastcmp(word, "NEXTPROMPT")) + textprompts[num]->page[pagenum].nextprompt = usi; + else if (fastcmp(word, "NEXTPAGE")) + textprompts[num]->page[pagenum].nextpage = usi; + else if (fastcmp(word, "NEXTTAG")) + strncpy(textprompts[num]->page[pagenum].nexttag, word2, 33); + else if (fastcmp(word, "TIMETONEXT")) + textprompts[num]->page[pagenum].timetonext = get_number(word2); + else + deh_warning("PromptPage %d: unknown word '%s'", num, word); + } + } while (!myfeof(f)); // finish when the line is empty + + Z_Free(s); +} + +void readtextprompt(MYFILE *f, INT32 num) +{ + char *s = Z_Malloc(MAXLINELEN, PU_STATIC, NULL); + char *word; + char *word2; + char *tmp; + INT32 value; + + // Allocate memory for this prompt if we don't yet have any + if (!textprompts[num]) + textprompts[num] = Z_Calloc(sizeof (textprompt_t), PU_STATIC, NULL); + + do + { + if (myfgets(s, MAXLINELEN, f)) + { + if (s[0] == '\n') + break; + + tmp = strchr(s, '#'); + if (tmp) + *tmp = '\0'; + if (s == tmp) + continue; // Skip comment lines, but don't break. + + word = strtok(s, " "); + if (word) + strupr(word); + else + break; + + word2 = strtok(NULL, " "); + if (word2) + value = atoi(word2); + else + { + deh_warning("No value for token %s", word); + continue; + } + + if (fastcmp(word, "NUMPAGES")) + { + textprompts[num]->numpages = min(max(value, 0), MAX_PAGES); + } + else if (fastcmp(word, "PAGE")) + { + if (1 <= value && value <= MAX_PAGES) + { + textprompts[num]->page[value - 1].backcolor = 1; // default to gray + textprompts[num]->page[value - 1].hidehud = 1; // hide appropriate HUD elements + readtextpromptpage(f, num, value - 1); + } + else + deh_warning("Page number %d out of range (1 - %d)", value, MAX_PAGES); + + } + else + deh_warning("Prompt %d: unknown word '%s', Page expected.", num, word); + } + } while (!myfeof(f)); // finish when the line is empty + + Z_Free(s); +} + +void readmenu(MYFILE *f, INT32 num) +{ + char *s = Z_Malloc(MAXLINELEN, PU_STATIC, NULL); + char *word = s; + char *word2; + char *tmp; + INT32 value; + + do + { + if (myfgets(s, MAXLINELEN, f)) + { + if (s[0] == '\n') + break; + + // First remove trailing newline, if there is one + tmp = strchr(s, '\n'); + if (tmp) + *tmp = '\0'; + + tmp = strchr(s, '#'); + if (tmp) + *tmp = '\0'; + if (s == tmp) + continue; // Skip comment lines, but don't break. + + // Get the part before the " = " + tmp = strchr(s, '='); + if (tmp) + *(tmp-1) = '\0'; + else + break; + strupr(word); + + // Now get the part after + word2 = (tmp += 2); + strupr(word2); + + value = atoi(word2); // used for numerical settings + + if (fastcmp(word, "BACKGROUNDNAME")) + { + strncpy(menupres[num].bgname, word2, 8); + titlechanged = true; + } + else if (fastcmp(word, "HIDEBACKGROUND")) + { + menupres[num].bghide = (boolean)(value || word2[0] == 'T' || word2[0] == 'Y'); + titlechanged = true; + } + else if (fastcmp(word, "BACKGROUNDCOLOR")) + { + menupres[num].bgcolor = get_number(word2); + titlechanged = true; + } + else if (fastcmp(word, "HIDETITLEPICS") || fastcmp(word, "HIDEPICS") || fastcmp(word, "TITLEPICSHIDE")) + { + // true by default, except MM_MAIN + menupres[num].hidetitlepics = (boolean)(value || word2[0] == 'T' || word2[0] == 'Y'); + titlechanged = true; + } + else if (fastcmp(word, "TITLEPICSMODE")) + { + if (fastcmp(word2, "USER")) + menupres[num].ttmode = TTMODE_USER; + else if (fastcmp(word2, "ALACROIX")) + menupres[num].ttmode = TTMODE_ALACROIX; + else if (fastcmp(word2, "HIDE") || fastcmp(word2, "HIDDEN") || fastcmp(word2, "NONE")) + { + menupres[num].ttmode = TTMODE_USER; + menupres[num].ttname[0] = 0; + menupres[num].hidetitlepics = true; + } + else // if (fastcmp(word2, "OLD") || fastcmp(word2, "SSNTAILS")) + menupres[num].ttmode = TTMODE_OLD; + titlechanged = true; + } + else if (fastcmp(word, "TITLEPICSSCALE")) + { + // Don't handle Alacroix special case here; see Maincfg section. + menupres[num].ttscale = max(1, min(8, (UINT8)get_number(word2))); + titlechanged = true; + } + else if (fastcmp(word, "TITLEPICSNAME")) + { + strncpy(menupres[num].ttname, word2, 9); + titlechanged = true; + } + else if (fastcmp(word, "TITLEPICSX")) + { + menupres[num].ttx = (INT16)get_number(word2); + titlechanged = true; + } + else if (fastcmp(word, "TITLEPICSY")) + { + menupres[num].tty = (INT16)get_number(word2); + titlechanged = true; + } + else if (fastcmp(word, "TITLEPICSLOOP")) + { + menupres[num].ttloop = (INT16)get_number(word2); + titlechanged = true; + } + else if (fastcmp(word, "TITLEPICSTICS")) + { + menupres[num].tttics = (UINT16)get_number(word2); + titlechanged = true; + } + else if (fastcmp(word, "TITLESCROLLSPEED") || fastcmp(word, "TITLESCROLLXSPEED") + || fastcmp(word, "SCROLLSPEED") || fastcmp(word, "SCROLLXSPEED")) + { + menupres[num].titlescrollxspeed = get_number(word2); + titlechanged = true; + } + else if (fastcmp(word, "TITLESCROLLYSPEED") || fastcmp(word, "SCROLLYSPEED")) + { + menupres[num].titlescrollyspeed = get_number(word2); + titlechanged = true; + } + else if (fastcmp(word, "MUSIC")) + { + strncpy(menupres[num].musname, word2, 7); + menupres[num].musname[6] = 0; + titlechanged = true; + } +#ifdef MUSICSLOT_COMPATIBILITY + else if (fastcmp(word, "MUSICSLOT")) + { + value = get_mus(word2, true); + if (value && value <= 1035) + snprintf(menupres[num].musname, 7, "%sM", G_BuildMapName(value)); + else if (value && value <= 1050) + strncpy(menupres[num].musname, compat_special_music_slots[value - 1036], 7); + else + menupres[num].musname[0] = 0; // becomes empty string + menupres[num].musname[6] = 0; + titlechanged = true; + } +#endif + else if (fastcmp(word, "MUSICTRACK")) + { + menupres[num].mustrack = ((UINT16)value - 1); + titlechanged = true; + } + else if (fastcmp(word, "MUSICLOOP")) + { + // true by default except MM_MAIN + menupres[num].muslooping = (value || word2[0] == 'T' || word2[0] == 'Y'); + titlechanged = true; + } + else if (fastcmp(word, "NOMUSIC")) + { + menupres[num].musstop = (value || word2[0] == 'T' || word2[0] == 'Y'); + titlechanged = true; + } + else if (fastcmp(word, "IGNOREMUSIC")) + { + menupres[num].musignore = (value || word2[0] == 'T' || word2[0] == 'Y'); + titlechanged = true; + } + else if (fastcmp(word, "FADESTRENGTH")) + { + // one-based, <= 0 means use default value. 1-32 + menupres[num].fadestrength = get_number(word2)-1; + titlechanged = true; + } + else if (fastcmp(word, "NOENTERBUBBLE")) + { + menupres[num].enterbubble = !(value || word2[0] == 'T' || word2[0] == 'Y'); + titlechanged = true; + } + else if (fastcmp(word, "NOEXITBUBBLE")) + { + menupres[num].exitbubble = !(value || word2[0] == 'T' || word2[0] == 'Y'); + titlechanged = true; + } + else if (fastcmp(word, "ENTERTAG")) + { + menupres[num].entertag = get_number(word2); + titlechanged = true; + } + else if (fastcmp(word, "EXITTAG")) + { + menupres[num].exittag = get_number(word2); + titlechanged = true; + } + else if (fastcmp(word, "ENTERWIPE")) + { + menupres[num].enterwipe = get_number(word2); + titlechanged = true; + } + else if (fastcmp(word, "EXITWIPE")) + { + menupres[num].exitwipe = get_number(word2); + titlechanged = true; + } + } + } while (!myfeof(f)); // finish when the line is empty + + Z_Free(s); +} + +void readhuditem(MYFILE *f, INT32 num) +{ + char *s = Z_Malloc(MAXLINELEN, PU_STATIC, NULL); + char *word = s; + char *word2; + char *tmp; + INT32 i; + + do + { + if (myfgets(s, MAXLINELEN, f)) + { + if (s[0] == '\n') + break; + + // First remove trailing newline, if there is one + tmp = strchr(s, '\n'); + if (tmp) + *tmp = '\0'; + + tmp = strchr(s, '#'); + if (tmp) + *tmp = '\0'; + if (s == tmp) + continue; // Skip comment lines, but don't break. + + // Get the part before the " = " + tmp = strchr(s, '='); + if (tmp) + *(tmp-1) = '\0'; + else + break; + strupr(word); + + // Now get the part after + word2 = tmp += 2; + strupr(word2); + + i = atoi(word2); // used for numerical settings + + if (fastcmp(word, "X")) + { + hudinfo[num].x = i; + } + else if (fastcmp(word, "Y")) + { + hudinfo[num].y = i; + } + else if (fastcmp(word, "F")) + { + hudinfo[num].f = i; + } + else + deh_warning("Level header %d: unknown word '%s'", num, word); + } + } while (!myfeof(f)); // finish when the line is empty + + Z_Free(s); +} + +void readframe(MYFILE *f, INT32 num) +{ + char *s = Z_Malloc(MAXLINELEN, PU_STATIC, NULL); + char *word1; + char *word2 = NULL; + char *tmp; + + do + { + if (myfgets(s, MAXLINELEN, f)) + { + if (s[0] == '\n') + break; + + tmp = strchr(s, '#'); + if (tmp) + *tmp = '\0'; + if (s == tmp) + continue; // Skip comment lines, but don't break. + + word1 = strtok(s, " "); + if (word1) + strupr(word1); + else + break; + + word2 = strtok(NULL, " = "); + if (word2) + strupr(word2); + else + break; + if (word2[strlen(word2)-1] == '\n') + word2[strlen(word2)-1] = '\0'; + + if (fastcmp(word1, "SPRITENUMBER") || fastcmp(word1, "SPRITENAME")) + { + states[num].sprite = get_sprite(word2); + } + else if (fastcmp(word1, "SPRITESUBNUMBER") || fastcmp(word1, "SPRITEFRAME")) + { + states[num].frame = (INT32)get_number(word2); // So the FF_ flags get calculated + } + else if (fastcmp(word1, "DURATION")) + { + states[num].tics = (INT32)get_number(word2); // So TICRATE can be used + } + else if (fastcmp(word1, "NEXT")) + { + states[num].nextstate = get_state(word2); + } + else if (fastcmp(word1, "VAR1")) + { + states[num].var1 = (INT32)get_number(word2); + } + else if (fastcmp(word1, "VAR2")) + { + states[num].var2 = (INT32)get_number(word2); + } + else if (fastcmp(word1, "ACTION")) + { + size_t z; + boolean found = false; + char actiontocompare[32]; + + memset(actiontocompare, 0x00, sizeof(actiontocompare)); + strlcpy(actiontocompare, word2, sizeof (actiontocompare)); + strupr(actiontocompare); + + for (z = 0; z < 32; z++) + { + if (actiontocompare[z] == '\n' || actiontocompare[z] == '\r') + { + actiontocompare[z] = '\0'; + break; + } + } + + for (z = 0; actionpointers[z].name; z++) + { + if (actionpointers[z].action.acv == states[num].action.acv) + break; + } + + z = 0; + found = LUA_SetLuaAction(&states[num], actiontocompare); + if (!found) + while (actionpointers[z].name) + { + if (fastcmp(actiontocompare, actionpointers[z].name)) + { + states[num].action = actionpointers[z].action; + states[num].action.acv = actionpointers[z].action.acv; // assign + states[num].action.acp1 = actionpointers[z].action.acp1; + found = true; + break; + } + z++; + } + + if (!found) + deh_warning("Unknown action %s", actiontocompare); + } + else + deh_warning("Frame %d: unknown word '%s'", num, word1); + } + } while (!myfeof(f)); + + Z_Free(s); +} + +void readsound(MYFILE *f, INT32 num) +{ + char *s = Z_Malloc(MAXLINELEN, PU_STATIC, NULL); + char *word; + char *word2; + char *tmp; + INT32 value; + + do + { + if (myfgets(s, MAXLINELEN, f)) + { + if (s[0] == '\n') + break; + + tmp = strchr(s, '#'); + if (tmp) + *tmp = '\0'; + if (s == tmp) + continue; // Skip comment lines, but don't break. + + word = strtok(s, " "); + if (word) + strupr(word); + else + break; + + word2 = strtok(NULL, " "); + if (word2) + value = atoi(word2); + else + { + deh_warning("No value for token %s", word); + continue; + } + + if (fastcmp(word, "SINGULAR")) + { + S_sfx[num].singularity = value; + } + else if (fastcmp(word, "PRIORITY")) + { + S_sfx[num].priority = value; + } + else if (fastcmp(word, "FLAGS")) + { + S_sfx[num].pitch = value; + } + else if (fastcmp(word, "CAPTION") || fastcmp(word, "DESCRIPTION")) + { + deh_strlcpy(S_sfx[num].caption, word2, + sizeof(S_sfx[num].caption), va("Sound effect %d: caption", num)); + } + else + deh_warning("Sound %d : unknown word '%s'",num,word); + } + } while (!myfeof(f)); + + Z_Free(s); +} + +/** Checks if a game data file name for a mod is good. + * "Good" means that it contains only alphanumerics, _, and -; + * ends in ".dat"; has at least one character before the ".dat"; + * and is not "gamedata.dat" (tested case-insensitively). + * + * Assumption: that gamedata.dat is the only .dat file that will + * ever be treated specially by the game. + * + * Note: Check for the tail ".dat" case-insensitively since at + * present, we get passed the filename in all uppercase. + * + * \param s Filename string to check. + * \return True if the filename is good. + * \sa readmaincfg() + * \author Graue + */ +static boolean GoodDataFileName(const char *s) +{ + const char *p; + const char *tail = ".dat"; + + for (p = s; *p != '\0'; p++) + if (!isalnum(*p) && *p != '_' && *p != '-' && *p != '.') + return false; + + p = s + strlen(s) - strlen(tail); + if (p <= s) return false; // too short + if (!fasticmp(p, tail)) return false; // doesn't end in .dat + if (fasticmp(s, "gamedata.dat")) return false; + + return true; +} + +void reademblemdata(MYFILE *f, INT32 num) +{ + char *s = Z_Malloc(MAXLINELEN, PU_STATIC, NULL); + char *word = s; + char *word2; + char *tmp; + INT32 value; + + memset(&emblemlocations[num-1], 0, sizeof(emblem_t)); + + do + { + if (myfgets(s, MAXLINELEN, f)) + { + if (s[0] == '\n') + break; + + // First remove trailing newline, if there is one + tmp = strchr(s, '\n'); + if (tmp) + *tmp = '\0'; + + tmp = strchr(s, '#'); + if (tmp) + *tmp = '\0'; + if (s == tmp) + continue; // Skip comment lines, but don't break. + + // Get the part before the " = " + tmp = strchr(s, '='); + if (tmp) + *(tmp-1) = '\0'; + else + break; + strupr(word); + + // Now get the part after + word2 = tmp += 2; + value = atoi(word2); // used for numerical settings + + // Up here to allow lowercase in hints + if (fastcmp(word, "HINT")) + { + while ((tmp = strchr(word2, '\\'))) + *tmp = '\n'; + deh_strlcpy(emblemlocations[num-1].hint, word2, sizeof (emblemlocations[num-1].hint), va("Emblem %d: hint", num)); + continue; + } + strupr(word2); + + if (fastcmp(word, "TYPE")) + { + if (fastcmp(word2, "GLOBAL")) + 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, "MAP")) + emblemlocations[num-1].type = ET_MAP; + 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; + } + else if (fastcmp(word, "TAG")) + emblemlocations[num-1].tag = (INT16)value; + else if (fastcmp(word, "MAPNUM")) + { + // Support using the actual map name, + // i.e., Level AB, Level FZ, etc. + + // Convert to map number + if (word2[0] >= 'A' && word2[0] <= 'Z') + value = M_MapNumber(word2[0], word2[1]); + + emblemlocations[num-1].level = (INT16)value; + } + else if (fastcmp(word, "SPRITE")) + { + if (word2[0] >= 'A' && word2[0] <= 'Z') + value = word2[0]; + else + value += 'A'-1; + + if (value < 'A' || value > 'Z') + deh_warning("Emblem %d: sprite must be from A - Z (1 - 26)", num); + else + emblemlocations[num-1].sprite = (UINT8)value; + } + else if (fastcmp(word, "COLOR")) + emblemlocations[num-1].color = get_number(word2); + else if (fastcmp(word, "VAR")) + emblemlocations[num-1].var = get_number(word2); + else + deh_warning("Emblem %d: unknown word '%s'", num, word); + } + } while (!myfeof(f)); + + // Default sprite and color definitions for lazy people like me + if (!emblemlocations[num-1].sprite) switch (emblemlocations[num-1].type) + { + case ET_RINGS: + emblemlocations[num-1].sprite = 'R'; break; + case ET_SCORE: case ET_NGRADE: + emblemlocations[num-1].sprite = 'S'; break; + case ET_TIME: case ET_NTIME: + emblemlocations[num-1].sprite = 'T'; break; + default: + emblemlocations[num-1].sprite = 'A'; break; + } + if (!emblemlocations[num-1].color) switch (emblemlocations[num-1].type) + { + case ET_RINGS: + emblemlocations[num-1].color = SKINCOLOR_GOLD; break; + case ET_SCORE: + emblemlocations[num-1].color = SKINCOLOR_BROWN; break; + case ET_NGRADE: + emblemlocations[num-1].color = SKINCOLOR_TEAL; break; + case ET_TIME: case ET_NTIME: + emblemlocations[num-1].color = SKINCOLOR_GREY; break; + default: + emblemlocations[num-1].color = SKINCOLOR_BLUE; break; + } + + Z_Free(s); +} + +void readextraemblemdata(MYFILE *f, INT32 num) +{ + char *s = Z_Malloc(MAXLINELEN, PU_STATIC, NULL); + char *word = s; + char *word2; + char *tmp; + INT32 value; + + memset(&extraemblems[num-1], 0, sizeof(extraemblem_t)); + + do + { + if (myfgets(s, MAXLINELEN, f)) + { + if (s[0] == '\n') + break; + + // First remove trailing newline, if there is one + tmp = strchr(s, '\n'); + if (tmp) + *tmp = '\0'; + + tmp = strchr(s, '#'); + if (tmp) + *tmp = '\0'; + if (s == tmp) + continue; // Skip comment lines, but don't break. + + // Get the part before the " = " + tmp = strchr(s, '='); + if (tmp) + *(tmp-1) = '\0'; + else + break; + strupr(word); + + // Now get the part after + word2 = tmp += 2; + + 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)); + else if (fastcmp(word, "OBJECTIVE")) + deh_strlcpy(extraemblems[num-1].description, word2, + 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, "SHOWCONDITIONSET")) + extraemblems[num-1].showconditionset = (UINT8)value; + else + { + strupr(word2); + if (fastcmp(word, "SPRITE")) + { + if (word2[0] >= 'A' && word2[0] <= 'Z') + value = word2[0]; + else + value += 'A'-1; + + if (value < 'A' || value > 'Z') + deh_warning("Emblem %d: sprite must be from A - Z (1 - 26)", num); + else + extraemblems[num-1].sprite = (UINT8)value; + } + else if (fastcmp(word, "COLOR")) + extraemblems[num-1].color = get_number(word2); + else + deh_warning("Extra emblem %d: unknown word '%s'", num, word); + } + } + } while (!myfeof(f)); + + if (!extraemblems[num-1].sprite) + extraemblems[num-1].sprite = 'X'; + if (!extraemblems[num-1].color) + extraemblems[num-1].color = SKINCOLOR_BLUE; + + Z_Free(s); +} + +void readunlockable(MYFILE *f, INT32 num) +{ + char *s = Z_Malloc(MAXLINELEN, PU_STATIC, NULL); + char *word = s; + char *word2; + char *tmp; + INT32 i; + + memset(&unlockables[num], 0, sizeof(unlockable_t)); + unlockables[num].objective[0] = '/'; + + do + { + if (myfgets(s, MAXLINELEN, f)) + { + if (s[0] == '\n') + break; + + // First remove trailing newline, if there is one + tmp = strchr(s, '\n'); + if (tmp) + *tmp = '\0'; + + tmp = strchr(s, '#'); + if (tmp) + *tmp = '\0'; + if (s == tmp) + continue; // Skip comment lines, but don't break. + + // Get the part before the " = " + tmp = strchr(s, '='); + if (tmp) + *(tmp-1) = '\0'; + else + break; + strupr(word); + + // Now get the part after + word2 = tmp += 2; + + 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)); + else if (fastcmp(word, "OBJECTIVE")) + deh_strlcpy(unlockables[num].objective, word2, + sizeof (unlockables[num].objective), va("Unlockable %d: objective", num)); + else + { + strupr(word2); + if (fastcmp(word, "HEIGHT")) + unlockables[num].height = (UINT16)i; + else if (fastcmp(word, "CONDITIONSET")) + unlockables[num].conditionset = (UINT8)i; + else if (fastcmp(word, "SHOWCONDITIONSET")) + unlockables[num].showconditionset = (UINT8)i; + else if (fastcmp(word, "NOCECHO")) + unlockables[num].nocecho = (UINT8)(i || word2[0] == 'T' || word2[0] == 'Y'); + else if (fastcmp(word, "NOCHECKLIST")) + unlockables[num].nochecklist = (UINT8)(i || word2[0] == 'T' || word2[0] == 'Y'); + else if (fastcmp(word, "TYPE")) + { + if (fastcmp(word2, "NONE")) + unlockables[num].type = SECRET_NONE; + else if (fastcmp(word2, "ITEMFINDER")) + unlockables[num].type = SECRET_ITEMFINDER; + else if (fastcmp(word2, "EMBLEMHINTS")) + unlockables[num].type = SECRET_EMBLEMHINTS; + else if (fastcmp(word2, "PANDORA")) + unlockables[num].type = SECRET_PANDORA; + else if (fastcmp(word2, "CREDITS")) + unlockables[num].type = SECRET_CREDITS; + else if (fastcmp(word2, "RECORDATTACK")) + unlockables[num].type = SECRET_RECORDATTACK; + else if (fastcmp(word2, "NIGHTSMODE")) + unlockables[num].type = SECRET_NIGHTSMODE; + else if (fastcmp(word2, "HEADER")) + unlockables[num].type = SECRET_HEADER; + else if (fastcmp(word2, "LEVELSELECT")) + unlockables[num].type = SECRET_LEVELSELECT; + else if (fastcmp(word2, "WARP")) + unlockables[num].type = SECRET_WARP; + else if (fastcmp(word2, "SOUNDTEST")) + unlockables[num].type = SECRET_SOUNDTEST; + else + unlockables[num].type = (INT16)i; + } + else if (fastcmp(word, "VAR")) + { + // Support using the actual map name, + // i.e., Level AB, Level FZ, etc. + + // Convert to map number + if (word2[0] >= 'A' && word2[0] <= 'Z') + i = M_MapNumber(word2[0], word2[1]); + + unlockables[num].variable = (INT16)i; + } + else + deh_warning("Unlockable %d: unknown word '%s'", num+1, word); + } + } + } while (!myfeof(f)); // finish when the line is empty + + Z_Free(s); +} + +static void readcondition(UINT8 set, UINT32 id, char *word2) +{ + INT32 i; + char *params[4]; // condition, requirement, extra info, extra info + char *spos; + + conditiontype_t ty; + INT32 re; + INT16 x1 = 0, x2 = 0; + + INT32 offset = 0; + + spos = strtok(word2, " "); + + for (i = 0; i < 4; ++i) + { + if (spos != NULL) + { + params[i] = spos; + spos = strtok(NULL, " "); + } + else + params[i] = NULL; + } + + if (!params[0]) + { + deh_warning("condition line is empty"); + return; + } + + if (fastcmp(params[0], "PLAYTIME")) + { + PARAMCHECK(1); + ty = UC_PLAYTIME; + re = atoi(params[1]); + } + else if (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], "OVERALLSCORE") + || (++offset && fastcmp(params[0], "OVERALLTIME")) + || (++offset && fastcmp(params[0], "OVERALLRINGS"))) + { + PARAMCHECK(1); + ty = UC_OVERALLSCORE + offset; + re = atoi(params[1]); + } + 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; + + // Convert to map number if it appears to be one + if (params[1][0] >= 'A' && params[1][0] <= 'Z') + re = M_MapNumber(params[1][0], params[1][1]); + else + re = atoi(params[1]); + + if (re < 0 || re >= NUMMAPS) + { + deh_warning("Level number %d out of range (1 - %d)", re, NUMMAPS); + return; + } + } + else if ((offset=0) || fastcmp(params[0], "MAPSCORE") + || (++offset && fastcmp(params[0], "MAPTIME")) + || (++offset && fastcmp(params[0], "MAPRINGS"))) + { + PARAMCHECK(2); + ty = UC_MAPSCORE + offset; + re = atoi(params[2]); + + // Convert to map number if it appears to be one + if (params[1][0] >= 'A' && params[1][0] <= 'Z') + x1 = (INT16)M_MapNumber(params[1][0], params[1][1]); + else + x1 = (INT16)atoi(params[1]); + + if (x1 < 0 || x1 >= NUMMAPS) + { + deh_warning("Level number %d out of range (1 - %d)", re, NUMMAPS); + return; + } + } + else if ((offset=0) || fastcmp(params[0], "NIGHTSSCORE") + || (++offset && fastcmp(params[0], "NIGHTSTIME")) + || (++offset && fastcmp(params[0], "NIGHTSGRADE"))) + { + PARAMCHECK(2); // one optional one + + ty = UC_NIGHTSSCORE + offset; + i = (params[3] ? 3 : 2); + if (fastncmp("GRADE_",params[i],6)) + { + char *p = params[i]+6; + for (re = 0; NIGHTSGRADE_LIST[re]; re++) + if (*p == NIGHTSGRADE_LIST[re]) + break; + if (!NIGHTSGRADE_LIST[re]) + { + deh_warning("Invalid NiGHTS grade %s\n", params[i]); + return; + } + } + else + re = atoi(params[i]); + + // Convert to map number if it appears to be one + if (params[1][0] >= 'A' && params[1][0] <= 'Z') + x1 = (INT16)M_MapNumber(params[1][0], params[1][1]); + else + x1 = (INT16)atoi(params[1]); + + if (x1 < 0 || x1 >= NUMMAPS) + { + deh_warning("Level number %d out of range (1 - %d)", re, NUMMAPS); + return; + } + + // Mare number (0 for overall) + if (params[3]) // Only if we actually got 3 params (so the second one == mare and not requirement) + x2 = (INT16)atoi(params[2]); + else + x2 = 0; + + } + else if (fastcmp(params[0], "TRIGGER")) + { + PARAMCHECK(1); + ty = UC_TRIGGER; + re = atoi(params[1]); + + // constrained by 32 bits + if (re < 0 || re > 31) + { + deh_warning("Trigger ID %d out of range (0 - 31)", re); + return; + } + } + else if (fastcmp(params[0], "TOTALEMBLEMS")) + { + PARAMCHECK(1); + ty = UC_TOTALEMBLEMS; + re = atoi(params[1]); + } + else if (fastcmp(params[0], "EMBLEM")) + { + PARAMCHECK(1); + ty = UC_EMBLEM; + re = atoi(params[1]); + + if (re <= 0 || re > MAXEMBLEMS) + { + deh_warning("Emblem %d out of range (1 - %d)", re, MAXEMBLEMS); + return; + } + } + else if (fastcmp(params[0], "EXTRAEMBLEM")) + { + PARAMCHECK(1); + ty = UC_EXTRAEMBLEM; + re = atoi(params[1]); + + if (re <= 0 || re > MAXEXTRAEMBLEMS) + { + deh_warning("Extra emblem %d out of range (1 - %d)", re, MAXEXTRAEMBLEMS); + return; + } + } + else if (fastcmp(params[0], "CONDITIONSET")) + { + PARAMCHECK(1); + ty = UC_CONDITIONSET; + re = atoi(params[1]); + + if (re <= 0 || re > MAXCONDITIONSETS) + { + deh_warning("Condition set %d out of range (1 - %d)", re, MAXCONDITIONSETS); + return; + } + } + else + { + deh_warning("Invalid condition name %s", params[0]); + return; + } + + M_AddRawCondition(set, (UINT8)id, ty, re, x1, x2); +} + +void readconditionset(MYFILE *f, UINT8 setnum) +{ + char *s = Z_Malloc(MAXLINELEN, PU_STATIC, NULL); + char *word = s; + char *word2; + char *tmp; + UINT8 id; + UINT8 previd = 0; + + M_ClearConditionSet(setnum); + + do + { + if (myfgets(s, MAXLINELEN, f)) + { + if (s[0] == '\n') + break; + + // First remove trailing newline, if there is one + tmp = strchr(s, '\n'); + if (tmp) + *tmp = '\0'; + + tmp = strchr(s, '#'); + if (tmp) + *tmp = '\0'; + if (s == tmp) + continue; // Skip comment lines, but don't break. + + // Get the part before the " = " + tmp = strchr(s, '='); + if (tmp) + *(tmp-1) = '\0'; + else + break; + strupr(word); + + // Now get the part after + word2 = tmp += 2; + strupr(word2); + + if (fastncmp(word, "CONDITION", 9)) + { + id = (UINT8)atoi(word + 9); + if (id == 0) + { + deh_warning("Condition set %d: unknown word '%s'", setnum, word); + continue; + } + else if (previd > id) + { + // out of order conditions can cause problems, so enforce proper order + deh_warning("Condition set %d: conditions are out of order, ignoring this line", setnum); + continue; + } + previd = id; + + readcondition(setnum, id, word2); + } + else + deh_warning("Condition set %d: unknown word '%s'", setnum, word); + } + } while (!myfeof(f)); // finish when the line is empty + + Z_Free(s); +} + +void readmaincfg(MYFILE *f) +{ + char *s = Z_Malloc(MAXLINELEN, PU_STATIC, NULL); + char *word = s; + char *word2; + char *tmp; + INT32 value; + + do + { + if (myfgets(s, MAXLINELEN, f)) + { + if (s[0] == '\n') + break; + + // First remove trailing newline, if there is one + tmp = strchr(s, '\n'); + if (tmp) + *tmp = '\0'; + + tmp = strchr(s, '#'); + if (tmp) + *tmp = '\0'; + if (s == tmp) + continue; // Skip comment lines, but don't break. + + // Get the part before the " = " + tmp = strchr(s, '='); + if (tmp) + *(tmp-1) = '\0'; + else + break; + strupr(word); + + // Now get the part after + word2 = tmp += 2; + strupr(word2); + + value = atoi(word2); // used for numerical settings + + if (fastcmp(word, "EXECCFG")) + { + if (strchr(word2, '.')) + COM_BufAddText(va("exec %s\n", word2)); + else + { + lumpnum_t lumpnum; + char newname[9]; + + strncpy(newname, word2, 8); + + newname[8] = '\0'; + + lumpnum = W_CheckNumForName(newname); + + if (lumpnum == LUMPERROR || W_LumpLength(lumpnum) == 0) + CONS_Debug(DBG_SETUP, "SOC Error: script lump %s not found/not valid.\n", newname); + else + COM_BufInsertText(W_CacheLumpNum(lumpnum, PU_CACHE)); + } + } + + else if (fastcmp(word, "SPSTAGE_START")) + { + // Support using the actual map name, + // i.e., Level AB, Level FZ, etc. + + // Convert to map number + if (word2[0] >= 'A' && word2[0] <= 'Z') + value = M_MapNumber(word2[0], word2[1]); + else + value = get_number(word2); + + spstage_start = spmarathon_start = (INT16)value; + } + else if (fastcmp(word, "SPMARATHON_START")) + { + // Support using the actual map name, + // i.e., Level AB, Level FZ, etc. + + // Convert to map number + if (word2[0] >= 'A' && word2[0] <= 'Z') + value = M_MapNumber(word2[0], word2[1]); + else + value = get_number(word2); + + spmarathon_start = (INT16)value; + } + else if (fastcmp(word, "SSTAGE_START")) + { + // Support using the actual map name, + // i.e., Level AB, Level FZ, etc. + + // Convert to map number + if (word2[0] >= 'A' && word2[0] <= 'Z') + value = M_MapNumber(word2[0], word2[1]); + else + value = get_number(word2); + + sstage_start = (INT16)value; + sstage_end = (INT16)(sstage_start+7); // 7 special stages total plus one weirdo + } + else if (fastcmp(word, "SMPSTAGE_START")) + { + // Support using the actual map name, + // i.e., Level AB, Level FZ, etc. + + // Convert to map number + if (word2[0] >= 'A' && word2[0] <= 'Z') + value = M_MapNumber(word2[0], word2[1]); + else + value = get_number(word2); + + smpstage_start = (INT16)value; + smpstage_end = (INT16)(smpstage_start+6); // 7 special stages total + } + else if (fastcmp(word, "REDTEAM")) + { + skincolor_redteam = (UINT16)get_number(word2); + } + else if (fastcmp(word, "BLUETEAM")) + { + skincolor_blueteam = (UINT16)get_number(word2); + } + else if (fastcmp(word, "REDRING")) + { + skincolor_redring = (UINT16)get_number(word2); + } + else if (fastcmp(word, "BLUERING")) + { + skincolor_bluering = (UINT16)get_number(word2); + } + else if (fastcmp(word, "INVULNTICS")) + { + invulntics = (UINT16)get_number(word2); + } + else if (fastcmp(word, "SNEAKERTICS")) + { + sneakertics = (UINT16)get_number(word2); + } + else if (fastcmp(word, "FLASHINGTICS")) + { + 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")) + { + extralifetics = (UINT16)get_number(word2); + } + else if (fastcmp(word, "NIGHTSLINKTICS")) + { + nightslinktics = (UINT16)get_number(word2); + } + else if (fastcmp(word, "GAMEOVERTICS")) + { + gameovertics = get_number(word2); + } + else if (fastcmp(word, "AMMOREMOVALTICS")) + { + ammoremovaltics = get_number(word2); + } + else if (fastcmp(word, "INTROTOPLAY")) + { + introtoplay = (UINT8)get_number(word2); + // range check, you morons. + if (introtoplay > 128) + introtoplay = 128; + introchanged = true; + } + else if (fastcmp(word, "CREDITSCUTSCENE")) + { + creditscutscene = (UINT8)get_number(word2); + // range check, you morons. + if (creditscutscene > 128) + creditscutscene = 128; + } + else if (fastcmp(word, "USEBLACKROCK")) + { + useBlackRock = (UINT8)(value || word2[0] == 'T' || word2[0] == 'Y'); + } + else if (fastcmp(word, "LOOPTITLE")) + { + looptitle = (value || word2[0] == 'T' || word2[0] == 'Y'); + titlechanged = true; + } + else if (fastcmp(word, "TITLEMAP")) + { + // Support using the actual map name, + // i.e., Level AB, Level FZ, etc. + + // Convert to map number + if (word2[0] >= 'A' && word2[0] <= 'Z') + value = M_MapNumber(word2[0], word2[1]); + else + value = get_number(word2); + + titlemap = (INT16)value; + titlechanged = true; + } + else if (fastcmp(word, "HIDETITLEPICS") || fastcmp(word, "TITLEPICSHIDE")) + { + hidetitlepics = (boolean)(value || word2[0] == 'T' || word2[0] == 'Y'); + titlechanged = true; + } + else if (fastcmp(word, "TITLEPICSMODE")) + { + if (fastcmp(word2, "USER")) + ttmode = TTMODE_USER; + else if (fastcmp(word2, "ALACROIX")) + ttmode = TTMODE_ALACROIX; + else if (fastcmp(word2, "HIDE") || fastcmp(word2, "HIDDEN") || fastcmp(word2, "NONE")) + { + ttmode = TTMODE_USER; + ttname[0] = 0; + hidetitlepics = true; + } + else // if (fastcmp(word2, "OLD") || fastcmp(word2, "SSNTAILS")) + ttmode = TTMODE_OLD; + titlechanged = true; + } + else if (fastcmp(word, "TITLEPICSSCALE")) + { + ttscale = max(1, min(8, (UINT8)get_number(word2))); + titlechanged = true; + } + else if (fastcmp(word, "TITLEPICSSCALESAVAILABLE")) + { + // SPECIAL CASE for Alacroix: Comma-separated list of resolutions that are available + // for gfx loading. + ttavailable[0] = ttavailable[1] = ttavailable[2] = ttavailable[3] =\ + ttavailable[4] = ttavailable[5] = false; + + if (strstr(word2, "1") != NULL) + ttavailable[0] = true; + if (strstr(word2, "2") != NULL) + ttavailable[1] = true; + if (strstr(word2, "3") != NULL) + ttavailable[2] = true; + if (strstr(word2, "4") != NULL) + ttavailable[3] = true; + if (strstr(word2, "5") != NULL) + ttavailable[4] = true; + if (strstr(word2, "6") != NULL) + ttavailable[5] = true; + titlechanged = true; + } + else if (fastcmp(word, "TITLEPICSNAME")) + { + strncpy(ttname, word2, 9); + titlechanged = true; + } + else if (fastcmp(word, "TITLEPICSX")) + { + ttx = (INT16)get_number(word2); + titlechanged = true; + } + else if (fastcmp(word, "TITLEPICSY")) + { + tty = (INT16)get_number(word2); + titlechanged = true; + } + else if (fastcmp(word, "TITLEPICSLOOP")) + { + ttloop = (INT16)get_number(word2); + titlechanged = true; + } + else if (fastcmp(word, "TITLEPICSTICS")) + { + tttics = (UINT16)get_number(word2); + titlechanged = true; + } + else if (fastcmp(word, "TITLESCROLLSPEED") || fastcmp(word, "TITLESCROLLXSPEED")) + { + titlescrollxspeed = get_number(word2); + titlechanged = true; + } + else if (fastcmp(word, "TITLESCROLLYSPEED")) + { + titlescrollyspeed = get_number(word2); + titlechanged = true; + } + else if (fastcmp(word, "DISABLESPEEDADJUST")) + { + disableSpeedAdjust = (value || word2[0] == 'T' || word2[0] == 'Y'); + } + else if (fastcmp(word, "NUMDEMOS")) + { + numDemos = (UINT8)get_number(word2); + titlechanged = true; + } + else if (fastcmp(word, "DEMODELAYTIME")) + { + demoDelayTime = get_number(word2); + titlechanged = true; + } + else if (fastcmp(word, "DEMOIDLETIME")) + { + demoIdleTime = get_number(word2); + titlechanged = true; + } + else if (fastcmp(word, "USE1UPSOUND")) + { + use1upSound = (UINT8)(value || word2[0] == 'T' || word2[0] == 'Y'); + } + else if (fastcmp(word, "MAXXTRALIFE")) + { + maxXtraLife = (UINT8)get_number(word2); + } + else if (fastcmp(word, "USECONTINUES")) + { + useContinues = (UINT8)(value || word2[0] == 'T' || word2[0] == 'Y'); + } + + else if (fastcmp(word, "GAMEDATA")) + { + size_t filenamelen; + + // Check the data filename so that mods + // can't write arbitrary files. + if (!GoodDataFileName(word2)) + I_Error("Maincfg: bad data file name '%s'\n", word2); + + G_SaveGameData(); + strlcpy(gamedatafilename, word2, sizeof (gamedatafilename)); + strlwr(gamedatafilename); + savemoddata = true; + + // Also save a time attack folder + filenamelen = strlen(gamedatafilename)-4; // Strip off the extension + strncpy(timeattackfolder, gamedatafilename, min(filenamelen, sizeof (timeattackfolder))); + timeattackfolder[min(filenamelen, sizeof (timeattackfolder) - 1)] = '\0'; + + strcpy(savegamename, timeattackfolder); + strlcat(savegamename, "%u.ssg", sizeof(savegamename)); + // can't use sprintf since there is %u in savegamename + strcatbf(savegamename, srb2home, PATHSEP); + + strcpy(liveeventbackup, va("live%s.bkp", timeattackfolder)); + strcatbf(liveeventbackup, srb2home, PATHSEP); + + gamedataadded = true; + titlechanged = true; + } + else if (fastcmp(word, "RESETDATA")) + { + P_ResetData(value); + titlechanged = true; + } + else if (fastcmp(word, "CUSTOMVERSION")) + { + strlcpy(customversionstring, word2, sizeof (customversionstring)); + //titlechanged = true; + } + else if (fastcmp(word, "BOOTMAP")) + { + // Support using the actual map name, + // i.e., Level AB, Level FZ, etc. + + // Convert to map number + if (word2[0] >= 'A' && word2[0] <= 'Z') + value = M_MapNumber(word2[0], word2[1]); + else + value = get_number(word2); + + bootmap = (INT16)value; + //titlechanged = true; + } + else if (fastcmp(word, "STARTCHAR")) + { + startchar = (INT16)value; + char_on = -1; + } + else if (fastcmp(word, "TUTORIALMAP")) + { + // Support using the actual map name, + // i.e., Level AB, Level FZ, etc. + + // Convert to map number + if (word2[0] >= 'A' && word2[0] <= 'Z') + value = M_MapNumber(word2[0], word2[1]); + else + value = get_number(word2); + + tutorialmap = (INT16)value; + } + else + deh_warning("Maincfg: unknown word '%s'", word); + } + } while (!myfeof(f)); + + Z_Free(s); +} + +void readwipes(MYFILE *f) +{ + char *s = Z_Malloc(MAXLINELEN, PU_STATIC, NULL); + char *word = s; + char *pword = word; + char *word2; + char *tmp; + INT32 value; + INT32 wipeoffset; + + do + { + if (myfgets(s, MAXLINELEN, f)) + { + if (s[0] == '\n') + break; + + // First remove trailing newline, if there is one + tmp = strchr(s, '\n'); + if (tmp) + *tmp = '\0'; + + tmp = strchr(s, '#'); + if (tmp) + *tmp = '\0'; + if (s == tmp) + continue; // Skip comment lines, but don't break. + + // Get the part before the " = " + tmp = strchr(s, '='); + if (tmp) + *(tmp-1) = '\0'; + else + break; + strupr(word); + + // Now get the part after + word2 = tmp += 2; + value = atoi(word2); // used for numerical settings + + if (value < -1 || value > 99) + { + deh_warning("Wipes: bad value '%s'", word2); + continue; + } + else if (value == -1) + value = UINT8_MAX; + + // error catching + wipeoffset = -1; + + if (fastncmp(word, "LEVEL_", 6)) + { + pword = word + 6; + if (fastcmp(pword, "TOBLACK")) + wipeoffset = wipe_level_toblack; + else if (fastcmp(pword, "FINAL")) + wipeoffset = wipe_level_final; + } + else if (fastncmp(word, "INTERMISSION_", 13)) + { + pword = word + 13; + if (fastcmp(pword, "TOBLACK")) + wipeoffset = wipe_intermission_toblack; + else if (fastcmp(pword, "FINAL")) + wipeoffset = wipe_intermission_final; + } + else if (fastncmp(word, "SPECINTER_", 10)) + { + pword = word + 10; + if (fastcmp(pword, "TOBLACK")) + wipeoffset = wipe_specinter_toblack; + else if (fastcmp(pword, "FINAL")) + wipeoffset = wipe_specinter_final; + } + else if (fastncmp(word, "MULTINTER_", 10)) + { + pword = word + 10; + if (fastcmp(pword, "TOBLACK")) + wipeoffset = wipe_multinter_toblack; + else if (fastcmp(pword, "FINAL")) + wipeoffset = wipe_multinter_final; + } + else if (fastncmp(word, "CONTINUING_", 11)) + { + pword = word + 11; + if (fastcmp(pword, "TOBLACK")) + wipeoffset = wipe_continuing_toblack; + else if (fastcmp(pword, "FINAL")) + wipeoffset = wipe_continuing_final; + } + else if (fastncmp(word, "TITLESCREEN_", 12)) + { + pword = word + 12; + if (fastcmp(pword, "TOBLACK")) + wipeoffset = wipe_titlescreen_toblack; + else if (fastcmp(pword, "FINAL")) + wipeoffset = wipe_titlescreen_final; + } + else if (fastncmp(word, "TIMEATTACK_", 11)) + { + pword = word + 11; + if (fastcmp(pword, "TOBLACK")) + wipeoffset = wipe_timeattack_toblack; + else if (fastcmp(pword, "FINAL")) + wipeoffset = wipe_timeattack_final; + } + else if (fastncmp(word, "CREDITS_", 8)) + { + pword = word + 8; + if (fastcmp(pword, "TOBLACK")) + wipeoffset = wipe_credits_toblack; + else if (fastcmp(pword, "FINAL")) + wipeoffset = wipe_credits_final; + else if (fastcmp(pword, "INTERMEDIATE")) + wipeoffset = wipe_credits_intermediate; + } + else if (fastncmp(word, "EVALUATION_", 11)) + { + pword = word + 11; + if (fastcmp(pword, "TOBLACK")) + wipeoffset = wipe_evaluation_toblack; + else if (fastcmp(pword, "FINAL")) + wipeoffset = wipe_evaluation_final; + } + else if (fastncmp(word, "GAMEEND_", 8)) + { + pword = word + 8; + if (fastcmp(pword, "TOBLACK")) + wipeoffset = wipe_gameend_toblack; + else if (fastcmp(pword, "FINAL")) + wipeoffset = wipe_gameend_final; + } + else if (fastncmp(word, "SPECLEVEL_", 10)) + { + pword = word + 10; + if (fastcmp(pword, "TOWHITE")) + wipeoffset = wipe_speclevel_towhite; + } + + if (wipeoffset < 0) + { + deh_warning("Wipes: unknown word '%s'", word); + continue; + } + + if (value == UINT8_MAX + && (wipeoffset <= wipe_level_toblack || wipeoffset >= wipe_speclevel_towhite)) + { + // Cannot disable non-toblack wipes + // (or the level toblack wipe, or the special towhite wipe) + deh_warning("Wipes: can't disable wipe of type '%s'", word); + continue; + } + + wipedefs[wipeoffset] = (UINT8)value; + } + } while (!myfeof(f)); + + Z_Free(s); +} + +mobjtype_t get_mobjtype(const char *word) +{ // Returns the value 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++) { + 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_NULL; +} + +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++) { + 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; +} + +skincolornum_t get_skincolor(const char *word) +{ // Returns the value of SKINCOLOR_ enumerations + skincolornum_t i; + if (*word >= '0' && *word <= '9') + return atoi(word); + if (fastncmp("SKINCOLOR_",word,10)) + word += 10; // take off the SKINCOLOR_ + for (i = 0; i < NUMCOLORFREESLOTS; i++) { + if (!FREE_SKINCOLORS[i]) + break; + if (fastcmp(word, FREE_SKINCOLORS[i])) + return SKINCOLOR_FIRSTFREESLOT+i; + } + for (i = 0; i < SKINCOLOR_FIRSTFREESLOT; i++) + if (fastcmp(word, COLOR_ENUMS[i])) + return i; + deh_warning("Couldn't find skincolor named 'SKINCOLOR_%s'",word); + return SKINCOLOR_GREEN; +} + +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) + return i; + deh_warning("Couldn't find sprite named 'SPR_%s'",word); + return SPR_NULL; +} + +playersprite_t get_sprite2(const char *word) +{ // Returns the value of SPR2_ enumerations + playersprite_t i; + if (*word >= '0' && *word <= '9') + return atoi(word); + if (fastncmp("SPR2_",word,5)) + word += 5; // take off the SPR2_ + for (i = 0; i < NUMPLAYERSPRITES; i++) + if (!spr2names[i][4] && memcmp(word,spr2names[i],4)==0) + return i; + deh_warning("Couldn't find sprite named 'SPR2_%s'",word); + return SPR2_STND; +} + +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 +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]); + + if (fastncmp("MUS_",word,4)) + word += 4; // take off the MUS_ + 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)) + { + word += 3; + if (toupper(word[0]) >= 'A' && toupper(word[0]) <= 'Z') + return (UINT16)M_MapNumber(word[0], word[1]); + else if ((i = atoi(word))) + return i; + + word -= 3; + if (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 + +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_LIVES; +} + +menutype_t get_menutype(const char *word) +{ // Returns the value of MN_ enumerations + menutype_t i; + if (*word >= '0' && *word <= '9') + return atoi(word); + if (fastncmp("MN_",word,3)) + word += 3; // take off the MN_ + for (i = 0; i < NUMMENUTYPES; i++) + if (fastcmp(word, MENUTYPES_LIST[i])) + return i; + deh_warning("Couldn't find menutype named 'MN_%s'",word); + return MN_NONE; +} + +/*static INT16 get_gametype(const char *word) +{ // Returns the value of GT_ enumerations + INT16 i; + if (*word >= '0' && *word <= '9') + return atoi(word); + if (fastncmp("GT_",word,3)) + word += 3; // take off the GT_ + for (i = 0; i < NUMGAMETYPES; i++) + if (fastcmp(word, Gametype_ConstantNames[i]+3)) + return i; + deh_warning("Couldn't find gametype named 'GT_%s'",word); + return GT_COOP; +} + +static powertype_t get_power(const char *word) +{ // Returns the value of pw_ enumerations + powertype_t i; + if (*word >= '0' && *word <= '9') + return atoi(word); + if (fastncmp("PW_",word,3)) + word += 3; // take off the pw_ + for (i = 0; i < NUMPOWERS; i++) + if (fastcmp(word, POWERS_LIST[i])) + return i; + deh_warning("Couldn't find power named 'pw_%s'",word); + return pw_invulnerability; +}*/ + +/// \todo Make ANY of this completely over-the-top math craziness obey the order of operations. +static fixed_t op_mul(fixed_t a, fixed_t b) { return a*b; } +static fixed_t op_div(fixed_t a, fixed_t b) { return a/b; } +static fixed_t op_add(fixed_t a, fixed_t b) { return a+b; } +static fixed_t op_sub(fixed_t a, fixed_t b) { return a-b; } +static fixed_t op_or(fixed_t a, fixed_t b) { return a|b; } +static fixed_t op_and(fixed_t a, fixed_t b) { return a&b; } +static fixed_t op_lshift(fixed_t a, fixed_t b) { return a<>b; } + +struct { + const char c; + fixed_t (*v)(fixed_t,fixed_t); +} OPERATIONS[] = { + {'*',op_mul}, + {'/',op_div}, + {'+',op_add}, + {'-',op_sub}, + {'|',op_or}, + {'&',op_and}, + {'<',op_lshift}, + {'>',op_rshift}, + {0,NULL} +}; + +// Returns the full word, cut at the first symbol or whitespace +/*static char *read_word(const char *line) +{ + // Part 1: You got the start of the word, now find the end. + const char *p; + INT32 i; + for (p = line+1; *p; p++) { + if (*p == ' ' || *p == '\t') + break; + for (i = 0; OPERATIONS[i].c; i++) + if (*p == OPERATIONS[i].c) { + i = -1; + break; + } + if (i == -1) + break; + } + + // Part 2: Make a copy of the word and return it. + { + size_t len = (p-line); + char *word = malloc(len+1); + M_Memcpy(word,line,len); + word[len] = '\0'; + return word; + } +} + +static INT32 operation_pad(const char **word) +{ // Brings word the next operation and returns the operation number. + INT32 i; + for (; **word; (*word)++) { + if (**word == ' ' || **word == '\t') + continue; + for (i = 0; OPERATIONS[i].c; i++) + if (**word == OPERATIONS[i].c) + { + if ((**word == '<' && *(*word+1) == '<') || (**word == '>' && *(*word+1) == '>')) (*word)++; // These operations are two characters long. + else if (**word == '<' || **word == '>') continue; // ... do not accept one character long. + (*word)++; + return i; + } + deh_warning("Unknown operation '%c'",**word); + return -1; + } + return -1; +} + +static void const_warning(const char *type, const char *word) +{ + deh_warning("Couldn't find %s named '%s'",type,word); +} + +static fixed_t find_const(const char **rword) +{ // Finds the value of constants and returns it, bringing word to the next operation. + INT32 i; + fixed_t r; + char *word = read_word(*rword); + *rword += strlen(word); + if ((*word >= '0' && *word <= '9') || *word == '-') { // Parse a number + r = atoi(word); + free(word); + return r; + } + if (!*(word+1) && // Turn a single A-z symbol into numbers, like sprite frames. + ((*word >= 'A' && *word <= 'Z') || (*word >= 'a' && *word <= 'z'))) { + r = R_Char2Frame(*word); + free(word); + return r; + } + if (fastncmp("MF_", word, 3)) { + char *p = word+3; + for (i = 0; MOBJFLAG_LIST[i]; i++) + if (fastcmp(p, MOBJFLAG_LIST[i])) { + free(word); + return (1< \t"S_\1", +// I am leaving the prefixes solely for clarity to programmers, +// because sadly no one remembers this place while searching for full state names. +const char *const STATE_LIST[] = { // array length left dynamic for sanity testing later. + "S_NULL", + "S_UNKNOWN", + "S_INVISIBLE", // state for invisible sprite + + "S_SPAWNSTATE", + "S_SEESTATE", + "S_MELEESTATE", + "S_MISSILESTATE", + "S_DEATHSTATE", + "S_XDEATHSTATE", + "S_RAISESTATE", + + // Thok + "S_THOK", + + // Player + "S_PLAY_STND", + "S_PLAY_WAIT", + "S_PLAY_WALK", + "S_PLAY_SKID", + "S_PLAY_RUN", + "S_PLAY_DASH", + "S_PLAY_PAIN", + "S_PLAY_STUN", + "S_PLAY_DEAD", + "S_PLAY_DRWN", + "S_PLAY_ROLL", + "S_PLAY_GASP", + "S_PLAY_JUMP", + "S_PLAY_SPRING", + "S_PLAY_FALL", + "S_PLAY_EDGE", + "S_PLAY_RIDE", + + // CA2_SPINDASH + "S_PLAY_SPINDASH", + + // CA_FLY/SWIM + "S_PLAY_FLY", + "S_PLAY_SWIM", + "S_PLAY_FLY_TIRED", + + // CA_GLIDEANDCLIMB + "S_PLAY_GLIDE", + "S_PLAY_GLIDE_LANDING", + "S_PLAY_CLING", + "S_PLAY_CLIMB", + + // CA_FLOAT/CA_SLOWFALL + "S_PLAY_FLOAT", + "S_PLAY_FLOAT_RUN", + + // CA_BOUNCE + "S_PLAY_BOUNCE", + "S_PLAY_BOUNCE_LANDING", + + // CA2_GUNSLINGER + "S_PLAY_FIRE", + "S_PLAY_FIRE_FINISH", + + // CA_TWINSPIN + "S_PLAY_TWINSPIN", + + // CA2_MELEE + "S_PLAY_MELEE", + "S_PLAY_MELEE_FINISH", + "S_PLAY_MELEE_LANDING", + + // SF_SUPER + "S_PLAY_SUPER_TRANS1", + "S_PLAY_SUPER_TRANS2", + "S_PLAY_SUPER_TRANS3", + "S_PLAY_SUPER_TRANS4", + "S_PLAY_SUPER_TRANS5", + "S_PLAY_SUPER_TRANS6", + + // technically the player goes here but it's an infinite tic state + "S_OBJPLACE_DUMMY", + + // 1-Up Box Sprites overlay (uses player sprite) + "S_PLAY_BOX1", + "S_PLAY_BOX2", + "S_PLAY_ICON1", + "S_PLAY_ICON2", + "S_PLAY_ICON3", + + // Level end sign overlay (uses player sprite) + "S_PLAY_SIGN", + + // NiGHTS character (uses player sprite) + "S_PLAY_NIGHTS_TRANS1", + "S_PLAY_NIGHTS_TRANS2", + "S_PLAY_NIGHTS_TRANS3", + "S_PLAY_NIGHTS_TRANS4", + "S_PLAY_NIGHTS_TRANS5", + "S_PLAY_NIGHTS_TRANS6", + "S_PLAY_NIGHTS_STAND", + "S_PLAY_NIGHTS_FLOAT", + "S_PLAY_NIGHTS_FLY", + "S_PLAY_NIGHTS_DRILL", + "S_PLAY_NIGHTS_STUN", + "S_PLAY_NIGHTS_PULL", + "S_PLAY_NIGHTS_ATTACK", + + // c: + "S_TAILSOVERLAY_STAND", + "S_TAILSOVERLAY_0DEGREES", + "S_TAILSOVERLAY_PLUS30DEGREES", + "S_TAILSOVERLAY_PLUS60DEGREES", + "S_TAILSOVERLAY_MINUS30DEGREES", + "S_TAILSOVERLAY_MINUS60DEGREES", + "S_TAILSOVERLAY_RUN", + "S_TAILSOVERLAY_FLY", + "S_TAILSOVERLAY_TIRE", + "S_TAILSOVERLAY_PAIN", + "S_TAILSOVERLAY_GASP", + "S_TAILSOVERLAY_EDGE", + "S_TAILSOVERLAY_DASH", + + // [: + "S_JETFUMEFLASH", + + // Blue Crawla + "S_POSS_STND", + "S_POSS_RUN1", + "S_POSS_RUN2", + "S_POSS_RUN3", + "S_POSS_RUN4", + "S_POSS_RUN5", + "S_POSS_RUN6", + + // Red Crawla + "S_SPOS_STND", + "S_SPOS_RUN1", + "S_SPOS_RUN2", + "S_SPOS_RUN3", + "S_SPOS_RUN4", + "S_SPOS_RUN5", + "S_SPOS_RUN6", + + // Greenflower Fish + "S_FISH1", + "S_FISH2", + "S_FISH3", + "S_FISH4", + + // Buzz (Gold) + "S_BUZZLOOK1", + "S_BUZZLOOK2", + "S_BUZZFLY1", + "S_BUZZFLY2", + + // Buzz (Red) + "S_RBUZZLOOK1", + "S_RBUZZLOOK2", + "S_RBUZZFLY1", + "S_RBUZZFLY2", + + // Jetty-Syn Bomber + "S_JETBLOOK1", + "S_JETBLOOK2", + "S_JETBZOOM1", + "S_JETBZOOM2", + + // Jetty-Syn Gunner + "S_JETGLOOK1", + "S_JETGLOOK2", + "S_JETGZOOM1", + "S_JETGZOOM2", + "S_JETGSHOOT1", + "S_JETGSHOOT2", + + // Crawla Commander + "S_CCOMMAND1", + "S_CCOMMAND2", + "S_CCOMMAND3", + "S_CCOMMAND4", + + // Deton + "S_DETON1", + "S_DETON2", + "S_DETON3", + "S_DETON4", + "S_DETON5", + "S_DETON6", + "S_DETON7", + "S_DETON8", + "S_DETON9", + "S_DETON10", + "S_DETON11", + "S_DETON12", + "S_DETON13", + "S_DETON14", + "S_DETON15", + + // Skim Mine Dropper + "S_SKIM1", + "S_SKIM2", + "S_SKIM3", + "S_SKIM4", + + // THZ Turret + "S_TURRET", + "S_TURRETFIRE", + "S_TURRETSHOCK1", + "S_TURRETSHOCK2", + "S_TURRETSHOCK3", + "S_TURRETSHOCK4", + "S_TURRETSHOCK5", + "S_TURRETSHOCK6", + "S_TURRETSHOCK7", + "S_TURRETSHOCK8", + "S_TURRETSHOCK9", + + // Popup Turret + "S_TURRETLOOK", + "S_TURRETSEE", + "S_TURRETPOPUP1", + "S_TURRETPOPUP2", + "S_TURRETPOPUP3", + "S_TURRETPOPUP4", + "S_TURRETPOPUP5", + "S_TURRETPOPUP6", + "S_TURRETPOPUP7", + "S_TURRETPOPUP8", + "S_TURRETSHOOT", + "S_TURRETPOPDOWN1", + "S_TURRETPOPDOWN2", + "S_TURRETPOPDOWN3", + "S_TURRETPOPDOWN4", + "S_TURRETPOPDOWN5", + "S_TURRETPOPDOWN6", + "S_TURRETPOPDOWN7", + "S_TURRETPOPDOWN8", + + // Spincushion + "S_SPINCUSHION_LOOK", + "S_SPINCUSHION_CHASE1", + "S_SPINCUSHION_CHASE2", + "S_SPINCUSHION_CHASE3", + "S_SPINCUSHION_CHASE4", + "S_SPINCUSHION_AIM1", + "S_SPINCUSHION_AIM2", + "S_SPINCUSHION_AIM3", + "S_SPINCUSHION_AIM4", + "S_SPINCUSHION_AIM5", + "S_SPINCUSHION_SPIN1", + "S_SPINCUSHION_SPIN2", + "S_SPINCUSHION_SPIN3", + "S_SPINCUSHION_SPIN4", + "S_SPINCUSHION_STOP1", + "S_SPINCUSHION_STOP2", + "S_SPINCUSHION_STOP3", + "S_SPINCUSHION_STOP4", + + // Crushstacean + "S_CRUSHSTACEAN_ROAM1", + "S_CRUSHSTACEAN_ROAM2", + "S_CRUSHSTACEAN_ROAM3", + "S_CRUSHSTACEAN_ROAM4", + "S_CRUSHSTACEAN_ROAMPAUSE", + "S_CRUSHSTACEAN_PUNCH1", + "S_CRUSHSTACEAN_PUNCH2", + "S_CRUSHCLAW_AIM", + "S_CRUSHCLAW_OUT", + "S_CRUSHCLAW_STAY", + "S_CRUSHCLAW_IN", + "S_CRUSHCLAW_WAIT", + "S_CRUSHCHAIN", + + // Banpyura + "S_BANPYURA_ROAM1", + "S_BANPYURA_ROAM2", + "S_BANPYURA_ROAM3", + "S_BANPYURA_ROAM4", + "S_BANPYURA_ROAMPAUSE", + "S_CDIAG1", + "S_CDIAG2", + "S_CDIAG3", + "S_CDIAG4", + "S_CDIAG5", + "S_CDIAG6", + "S_CDIAG7", + "S_CDIAG8", + + // Jet Jaw + "S_JETJAW_ROAM1", + "S_JETJAW_ROAM2", + "S_JETJAW_ROAM3", + "S_JETJAW_ROAM4", + "S_JETJAW_ROAM5", + "S_JETJAW_ROAM6", + "S_JETJAW_ROAM7", + "S_JETJAW_ROAM8", + "S_JETJAW_CHOMP1", + "S_JETJAW_CHOMP2", + "S_JETJAW_CHOMP3", + "S_JETJAW_CHOMP4", + "S_JETJAW_CHOMP5", + "S_JETJAW_CHOMP6", + "S_JETJAW_CHOMP7", + "S_JETJAW_CHOMP8", + "S_JETJAW_CHOMP9", + "S_JETJAW_CHOMP10", + "S_JETJAW_CHOMP11", + "S_JETJAW_CHOMP12", + "S_JETJAW_CHOMP13", + "S_JETJAW_CHOMP14", + "S_JETJAW_CHOMP15", + "S_JETJAW_CHOMP16", + "S_JETJAW_SOUND", + + // Snailer + "S_SNAILER1", + "S_SNAILER_FLICKY", + + // Vulture + "S_VULTURE_STND", + "S_VULTURE_DRIFT", + "S_VULTURE_ZOOM1", + "S_VULTURE_ZOOM2", + "S_VULTURE_STUNNED", + + // Pointy + "S_POINTY1", + "S_POINTYBALL1", + + // Robo-Hood + "S_ROBOHOOD_LOOK", + "S_ROBOHOOD_STAND", + "S_ROBOHOOD_FIRE1", + "S_ROBOHOOD_FIRE2", + "S_ROBOHOOD_JUMP1", + "S_ROBOHOOD_JUMP2", + "S_ROBOHOOD_JUMP3", + + // Castlebot Facestabber + "S_FACESTABBER_STND1", + "S_FACESTABBER_STND2", + "S_FACESTABBER_STND3", + "S_FACESTABBER_STND4", + "S_FACESTABBER_STND5", + "S_FACESTABBER_STND6", + "S_FACESTABBER_CHARGE1", + "S_FACESTABBER_CHARGE2", + "S_FACESTABBER_CHARGE3", + "S_FACESTABBER_CHARGE4", + "S_FACESTABBER_PAIN", + "S_FACESTABBER_DIE1", + "S_FACESTABBER_DIE2", + "S_FACESTABBER_DIE3", + "S_FACESTABBERSPEAR", + + // Egg Guard + "S_EGGGUARD_STND", + "S_EGGGUARD_WALK1", + "S_EGGGUARD_WALK2", + "S_EGGGUARD_WALK3", + "S_EGGGUARD_WALK4", + "S_EGGGUARD_MAD1", + "S_EGGGUARD_MAD2", + "S_EGGGUARD_MAD3", + "S_EGGGUARD_RUN1", + "S_EGGGUARD_RUN2", + "S_EGGGUARD_RUN3", + "S_EGGGUARD_RUN4", + + // Egg Shield for Egg Guard + "S_EGGSHIELD", + "S_EGGSHIELDBREAK", + + // Green Snapper + "S_SNAPPER_SPAWN", + "S_SNAPPER_SPAWN2", + "S_GSNAPPER_STND", + "S_GSNAPPER1", + "S_GSNAPPER2", + "S_GSNAPPER3", + "S_GSNAPPER4", + "S_SNAPPER_XPLD", + "S_SNAPPER_LEG", + "S_SNAPPER_LEGRAISE", + "S_SNAPPER_HEAD", + + // Minus + "S_MINUS_INIT", + "S_MINUS_STND", + "S_MINUS_DIGGING1", + "S_MINUS_DIGGING2", + "S_MINUS_DIGGING3", + "S_MINUS_DIGGING4", + "S_MINUS_BURST0", + "S_MINUS_BURST1", + "S_MINUS_BURST2", + "S_MINUS_BURST3", + "S_MINUS_BURST4", + "S_MINUS_BURST5", + "S_MINUS_POPUP", + "S_MINUS_AERIAL1", + "S_MINUS_AERIAL2", + "S_MINUS_AERIAL3", + "S_MINUS_AERIAL4", + + // Minus dirt + "S_MINUSDIRT1", + "S_MINUSDIRT2", + "S_MINUSDIRT3", + "S_MINUSDIRT4", + "S_MINUSDIRT5", + "S_MINUSDIRT6", + "S_MINUSDIRT7", + + // Spring Shell + "S_SSHELL_STND", + "S_SSHELL_RUN1", + "S_SSHELL_RUN2", + "S_SSHELL_RUN3", + "S_SSHELL_RUN4", + "S_SSHELL_SPRING1", + "S_SSHELL_SPRING2", + "S_SSHELL_SPRING3", + "S_SSHELL_SPRING4", + + // Spring Shell (yellow) + "S_YSHELL_STND", + "S_YSHELL_RUN1", + "S_YSHELL_RUN2", + "S_YSHELL_RUN3", + "S_YSHELL_RUN4", + "S_YSHELL_SPRING1", + "S_YSHELL_SPRING2", + "S_YSHELL_SPRING3", + "S_YSHELL_SPRING4", + + // Unidus + "S_UNIDUS_STND", + "S_UNIDUS_RUN", + "S_UNIDUS_BALL", + + // Canarivore + "S_CANARIVORE_LOOK", + "S_CANARIVORE_AWAKEN1", + "S_CANARIVORE_AWAKEN2", + "S_CANARIVORE_AWAKEN3", + "S_CANARIVORE_GAS1", + "S_CANARIVORE_GAS2", + "S_CANARIVORE_GAS3", + "S_CANARIVORE_GAS4", + "S_CANARIVORE_GAS5", + "S_CANARIVORE_GASREPEAT", + "S_CANARIVORE_CLOSE1", + "S_CANARIVORE_CLOSE2", + "S_CANARIVOREGAS_1", + "S_CANARIVOREGAS_2", + "S_CANARIVOREGAS_3", + "S_CANARIVOREGAS_4", + "S_CANARIVOREGAS_5", + "S_CANARIVOREGAS_6", + "S_CANARIVOREGAS_7", + "S_CANARIVOREGAS_8", + + // Pyre Fly + "S_PYREFLY_FLY", + "S_PYREFLY_BURN", + "S_PYREFIRE1", + "S_PYREFIRE2", + + // Pterabyte + "S_PTERABYTESPAWNER", + "S_PTERABYTEWAYPOINT", + "S_PTERABYTE_FLY1", + "S_PTERABYTE_FLY2", + "S_PTERABYTE_FLY3", + "S_PTERABYTE_FLY4", + "S_PTERABYTE_SWOOPDOWN", + "S_PTERABYTE_SWOOPUP", + + // Dragonbomber + "S_DRAGONBOMBER", + "S_DRAGONWING1", + "S_DRAGONWING2", + "S_DRAGONWING3", + "S_DRAGONWING4", + "S_DRAGONTAIL_LOADED", + "S_DRAGONTAIL_EMPTY", + "S_DRAGONTAIL_EMPTYLOOP", + "S_DRAGONTAIL_RELOAD", + "S_DRAGONMINE", + "S_DRAGONMINE_LAND1", + "S_DRAGONMINE_LAND2", + "S_DRAGONMINE_SLOWFLASH1", + "S_DRAGONMINE_SLOWFLASH2", + "S_DRAGONMINE_SLOWLOOP", + "S_DRAGONMINE_FASTFLASH1", + "S_DRAGONMINE_FASTFLASH2", + "S_DRAGONMINE_FASTLOOP", + + // Boss Explosion + "S_BOSSEXPLODE", + + // S3&K Boss Explosion + "S_SONIC3KBOSSEXPLOSION1", + "S_SONIC3KBOSSEXPLOSION2", + "S_SONIC3KBOSSEXPLOSION3", + "S_SONIC3KBOSSEXPLOSION4", + "S_SONIC3KBOSSEXPLOSION5", + "S_SONIC3KBOSSEXPLOSION6", + + "S_JETFUME1", + + // Boss 1 + "S_EGGMOBILE_STND", + "S_EGGMOBILE_ROFL", + "S_EGGMOBILE_LATK1", + "S_EGGMOBILE_LATK2", + "S_EGGMOBILE_LATK3", + "S_EGGMOBILE_LATK4", + "S_EGGMOBILE_LATK5", + "S_EGGMOBILE_LATK6", + "S_EGGMOBILE_LATK7", + "S_EGGMOBILE_LATK8", + "S_EGGMOBILE_LATK9", + "S_EGGMOBILE_RATK1", + "S_EGGMOBILE_RATK2", + "S_EGGMOBILE_RATK3", + "S_EGGMOBILE_RATK4", + "S_EGGMOBILE_RATK5", + "S_EGGMOBILE_RATK6", + "S_EGGMOBILE_RATK7", + "S_EGGMOBILE_RATK8", + "S_EGGMOBILE_RATK9", + "S_EGGMOBILE_PANIC1", + "S_EGGMOBILE_PANIC2", + "S_EGGMOBILE_PANIC3", + "S_EGGMOBILE_PANIC4", + "S_EGGMOBILE_PANIC5", + "S_EGGMOBILE_PANIC6", + "S_EGGMOBILE_PANIC7", + "S_EGGMOBILE_PANIC8", + "S_EGGMOBILE_PANIC9", + "S_EGGMOBILE_PANIC10", + "S_EGGMOBILE_PANIC11", + "S_EGGMOBILE_PANIC12", + "S_EGGMOBILE_PANIC13", + "S_EGGMOBILE_PANIC14", + "S_EGGMOBILE_PANIC15", + "S_EGGMOBILE_PAIN", + "S_EGGMOBILE_PAIN2", + "S_EGGMOBILE_DIE1", + "S_EGGMOBILE_DIE2", + "S_EGGMOBILE_DIE3", + "S_EGGMOBILE_DIE4", + "S_EGGMOBILE_FLEE1", + "S_EGGMOBILE_FLEE2", + "S_EGGMOBILE_BALL", + "S_EGGMOBILE_TARGET", + + "S_BOSSEGLZ1", + "S_BOSSEGLZ2", + + // Boss 2 + "S_EGGMOBILE2_STND", + "S_EGGMOBILE2_POGO1", + "S_EGGMOBILE2_POGO2", + "S_EGGMOBILE2_POGO3", + "S_EGGMOBILE2_POGO4", + "S_EGGMOBILE2_POGO5", + "S_EGGMOBILE2_POGO6", + "S_EGGMOBILE2_POGO7", + "S_EGGMOBILE2_PAIN", + "S_EGGMOBILE2_PAIN2", + "S_EGGMOBILE2_DIE1", + "S_EGGMOBILE2_DIE2", + "S_EGGMOBILE2_DIE3", + "S_EGGMOBILE2_DIE4", + "S_EGGMOBILE2_FLEE1", + "S_EGGMOBILE2_FLEE2", + + "S_BOSSTANK1", + "S_BOSSTANK2", + "S_BOSSSPIGOT", + + // Boss 2 Goop + "S_GOOP1", + "S_GOOP2", + "S_GOOP3", + "S_GOOPTRAIL", + + // Boss 3 + "S_EGGMOBILE3_STND", + "S_EGGMOBILE3_SHOCK", + "S_EGGMOBILE3_ATK1", + "S_EGGMOBILE3_ATK2", + "S_EGGMOBILE3_ATK3A", + "S_EGGMOBILE3_ATK3B", + "S_EGGMOBILE3_ATK3C", + "S_EGGMOBILE3_ATK3D", + "S_EGGMOBILE3_ATK4", + "S_EGGMOBILE3_ATK5", + "S_EGGMOBILE3_ROFL", + "S_EGGMOBILE3_PAIN", + "S_EGGMOBILE3_PAIN2", + "S_EGGMOBILE3_DIE1", + "S_EGGMOBILE3_DIE2", + "S_EGGMOBILE3_DIE3", + "S_EGGMOBILE3_DIE4", + "S_EGGMOBILE3_FLEE1", + "S_EGGMOBILE3_FLEE2", + + // Boss 3 Pinch + "S_FAKEMOBILE_INIT", + "S_FAKEMOBILE", + "S_FAKEMOBILE_ATK1", + "S_FAKEMOBILE_ATK2", + "S_FAKEMOBILE_ATK3A", + "S_FAKEMOBILE_ATK3B", + "S_FAKEMOBILE_ATK3C", + "S_FAKEMOBILE_ATK3D", + "S_FAKEMOBILE_DIE1", + "S_FAKEMOBILE_DIE2", + + "S_BOSSSEBH1", + "S_BOSSSEBH2", + + // Boss 3 Shockwave + "S_SHOCKWAVE1", + "S_SHOCKWAVE2", + + // Boss 4 + "S_EGGMOBILE4_STND", + "S_EGGMOBILE4_LATK1", + "S_EGGMOBILE4_LATK2", + "S_EGGMOBILE4_LATK3", + "S_EGGMOBILE4_LATK4", + "S_EGGMOBILE4_LATK5", + "S_EGGMOBILE4_LATK6", + "S_EGGMOBILE4_RATK1", + "S_EGGMOBILE4_RATK2", + "S_EGGMOBILE4_RATK3", + "S_EGGMOBILE4_RATK4", + "S_EGGMOBILE4_RATK5", + "S_EGGMOBILE4_RATK6", + "S_EGGMOBILE4_RAISE1", + "S_EGGMOBILE4_RAISE2", + "S_EGGMOBILE4_PAIN1", + "S_EGGMOBILE4_PAIN2", + "S_EGGMOBILE4_DIE1", + "S_EGGMOBILE4_DIE2", + "S_EGGMOBILE4_DIE3", + "S_EGGMOBILE4_DIE4", + "S_EGGMOBILE4_FLEE1", + "S_EGGMOBILE4_FLEE2", + "S_EGGMOBILE4_MACE", + "S_EGGMOBILE4_MACE_DIE1", + "S_EGGMOBILE4_MACE_DIE2", + "S_EGGMOBILE4_MACE_DIE3", + + // Boss 4 jet flame + "S_JETFLAME", + + // Boss 4 Spectator Eggrobo + "S_EGGROBO1_STND", + "S_EGGROBO1_BSLAP1", + "S_EGGROBO1_BSLAP2", + "S_EGGROBO1_PISSED", + + // Boss 4 Spectator Eggrobo jet flame + "S_EGGROBOJET", + + // Boss 5 + "S_FANG_SETUP", + "S_FANG_INTRO0", + "S_FANG_INTRO1", + "S_FANG_INTRO2", + "S_FANG_INTRO3", + "S_FANG_INTRO4", + "S_FANG_INTRO5", + "S_FANG_INTRO6", + "S_FANG_INTRO7", + "S_FANG_INTRO8", + "S_FANG_INTRO9", + "S_FANG_INTRO10", + "S_FANG_INTRO11", + "S_FANG_INTRO12", + "S_FANG_CLONE1", + "S_FANG_CLONE2", + "S_FANG_CLONE3", + "S_FANG_CLONE4", + "S_FANG_IDLE0", + "S_FANG_IDLE1", + "S_FANG_IDLE2", + "S_FANG_IDLE3", + "S_FANG_IDLE4", + "S_FANG_IDLE5", + "S_FANG_IDLE6", + "S_FANG_IDLE7", + "S_FANG_IDLE8", + "S_FANG_PAIN1", + "S_FANG_PAIN2", + "S_FANG_PATHINGSTART1", + "S_FANG_PATHINGSTART2", + "S_FANG_PATHING", + "S_FANG_BOUNCE1", + "S_FANG_BOUNCE2", + "S_FANG_BOUNCE3", + "S_FANG_BOUNCE4", + "S_FANG_FALL1", + "S_FANG_FALL2", + "S_FANG_CHECKPATH1", + "S_FANG_CHECKPATH2", + "S_FANG_PATHINGCONT1", + "S_FANG_PATHINGCONT2", + "S_FANG_PATHINGCONT3", + "S_FANG_SKID1", + "S_FANG_SKID2", + "S_FANG_SKID3", + "S_FANG_CHOOSEATTACK", + "S_FANG_FIRESTART1", + "S_FANG_FIRESTART2", + "S_FANG_FIRE1", + "S_FANG_FIRE2", + "S_FANG_FIRE3", + "S_FANG_FIRE4", + "S_FANG_FIREREPEAT", + "S_FANG_LOBSHOT0", + "S_FANG_LOBSHOT1", + "S_FANG_LOBSHOT2", + "S_FANG_WAIT1", + "S_FANG_WAIT2", + "S_FANG_WALLHIT", + "S_FANG_PINCHPATHINGSTART1", + "S_FANG_PINCHPATHINGSTART2", + "S_FANG_PINCHPATHING", + "S_FANG_PINCHBOUNCE0", + "S_FANG_PINCHBOUNCE1", + "S_FANG_PINCHBOUNCE2", + "S_FANG_PINCHBOUNCE3", + "S_FANG_PINCHBOUNCE4", + "S_FANG_PINCHFALL0", + "S_FANG_PINCHFALL1", + "S_FANG_PINCHFALL2", + "S_FANG_PINCHSKID1", + "S_FANG_PINCHSKID2", + "S_FANG_PINCHLOBSHOT0", + "S_FANG_PINCHLOBSHOT1", + "S_FANG_PINCHLOBSHOT2", + "S_FANG_PINCHLOBSHOT3", + "S_FANG_PINCHLOBSHOT4", + "S_FANG_DIE1", + "S_FANG_DIE2", + "S_FANG_DIE3", + "S_FANG_DIE4", + "S_FANG_DIE5", + "S_FANG_DIE6", + "S_FANG_DIE7", + "S_FANG_DIE8", + "S_FANG_FLEEPATHING1", + "S_FANG_FLEEPATHING2", + "S_FANG_FLEEBOUNCE1", + "S_FANG_FLEEBOUNCE2", + "S_FANG_KO", + + "S_BROKENROBOTRANDOM", + "S_BROKENROBOTA", + "S_BROKENROBOTB", + "S_BROKENROBOTC", + "S_BROKENROBOTD", + "S_BROKENROBOTE", + "S_BROKENROBOTF", + + "S_ALART1", + "S_ALART2", + + "S_VWREF", + "S_VWREB", + + "S_PROJECTORLIGHT1", + "S_PROJECTORLIGHT2", + "S_PROJECTORLIGHT3", + "S_PROJECTORLIGHT4", + "S_PROJECTORLIGHT5", + + "S_FBOMB1", + "S_FBOMB2", + "S_FBOMB_EXPL1", + "S_FBOMB_EXPL2", + "S_FBOMB_EXPL3", + "S_FBOMB_EXPL4", + "S_FBOMB_EXPL5", + "S_FBOMB_EXPL6", + "S_TNTDUST_1", + "S_TNTDUST_2", + "S_TNTDUST_3", + "S_TNTDUST_4", + "S_TNTDUST_5", + "S_TNTDUST_6", + "S_TNTDUST_7", + "S_TNTDUST_8", + "S_FSGNA", + "S_FSGNB", + "S_FSGNC", + "S_FSGND", + + // Black Eggman (Boss 7) + "S_BLACKEGG_STND", + "S_BLACKEGG_STND2", + "S_BLACKEGG_WALK1", + "S_BLACKEGG_WALK2", + "S_BLACKEGG_WALK3", + "S_BLACKEGG_WALK4", + "S_BLACKEGG_WALK5", + "S_BLACKEGG_WALK6", + "S_BLACKEGG_SHOOT1", + "S_BLACKEGG_SHOOT2", + "S_BLACKEGG_PAIN1", + "S_BLACKEGG_PAIN2", + "S_BLACKEGG_PAIN3", + "S_BLACKEGG_PAIN4", + "S_BLACKEGG_PAIN5", + "S_BLACKEGG_PAIN6", + "S_BLACKEGG_PAIN7", + "S_BLACKEGG_PAIN8", + "S_BLACKEGG_PAIN9", + "S_BLACKEGG_PAIN10", + "S_BLACKEGG_PAIN11", + "S_BLACKEGG_PAIN12", + "S_BLACKEGG_PAIN13", + "S_BLACKEGG_PAIN14", + "S_BLACKEGG_PAIN15", + "S_BLACKEGG_PAIN16", + "S_BLACKEGG_PAIN17", + "S_BLACKEGG_PAIN18", + "S_BLACKEGG_PAIN19", + "S_BLACKEGG_PAIN20", + "S_BLACKEGG_PAIN21", + "S_BLACKEGG_PAIN22", + "S_BLACKEGG_PAIN23", + "S_BLACKEGG_PAIN24", + "S_BLACKEGG_PAIN25", + "S_BLACKEGG_PAIN26", + "S_BLACKEGG_PAIN27", + "S_BLACKEGG_PAIN28", + "S_BLACKEGG_PAIN29", + "S_BLACKEGG_PAIN30", + "S_BLACKEGG_PAIN31", + "S_BLACKEGG_PAIN32", + "S_BLACKEGG_PAIN33", + "S_BLACKEGG_PAIN34", + "S_BLACKEGG_PAIN35", + "S_BLACKEGG_HITFACE1", + "S_BLACKEGG_HITFACE2", + "S_BLACKEGG_HITFACE3", + "S_BLACKEGG_HITFACE4", + "S_BLACKEGG_DIE1", + "S_BLACKEGG_DIE2", + "S_BLACKEGG_DIE3", + "S_BLACKEGG_DIE4", + "S_BLACKEGG_DIE5", + "S_BLACKEGG_MISSILE1", + "S_BLACKEGG_MISSILE2", + "S_BLACKEGG_MISSILE3", + "S_BLACKEGG_GOOP", + "S_BLACKEGG_JUMP1", + "S_BLACKEGG_JUMP2", + "S_BLACKEGG_DESTROYPLAT1", + "S_BLACKEGG_DESTROYPLAT2", + "S_BLACKEGG_DESTROYPLAT3", + + "S_BLACKEGG_HELPER", // Collision helper + + "S_BLACKEGG_GOOP1", + "S_BLACKEGG_GOOP2", + "S_BLACKEGG_GOOP3", + "S_BLACKEGG_GOOP4", + "S_BLACKEGG_GOOP5", + "S_BLACKEGG_GOOP6", + "S_BLACKEGG_GOOP7", + + "S_BLACKEGG_MISSILE", + + // New Very-Last-Minute 2.1 Brak Eggman (Cy-Brak-demon) + "S_CYBRAKDEMON_IDLE", + "S_CYBRAKDEMON_WALK1", + "S_CYBRAKDEMON_WALK2", + "S_CYBRAKDEMON_WALK3", + "S_CYBRAKDEMON_WALK4", + "S_CYBRAKDEMON_WALK5", + "S_CYBRAKDEMON_WALK6", + "S_CYBRAKDEMON_CHOOSE_ATTACK1", + "S_CYBRAKDEMON_MISSILE_ATTACK1", // Aim + "S_CYBRAKDEMON_MISSILE_ATTACK2", // Fire + "S_CYBRAKDEMON_MISSILE_ATTACK3", // Aim + "S_CYBRAKDEMON_MISSILE_ATTACK4", // Fire + "S_CYBRAKDEMON_MISSILE_ATTACK5", // Aim + "S_CYBRAKDEMON_MISSILE_ATTACK6", // Fire + "S_CYBRAKDEMON_FLAME_ATTACK1", // Reset + "S_CYBRAKDEMON_FLAME_ATTACK2", // Aim + "S_CYBRAKDEMON_FLAME_ATTACK3", // Fire + "S_CYBRAKDEMON_FLAME_ATTACK4", // Loop + "S_CYBRAKDEMON_CHOOSE_ATTACK2", + "S_CYBRAKDEMON_VILE_ATTACK1", + "S_CYBRAKDEMON_VILE_ATTACK2", + "S_CYBRAKDEMON_VILE_ATTACK3", + "S_CYBRAKDEMON_VILE_ATTACK4", + "S_CYBRAKDEMON_VILE_ATTACK5", + "S_CYBRAKDEMON_VILE_ATTACK6", + "S_CYBRAKDEMON_NAPALM_ATTACK1", + "S_CYBRAKDEMON_NAPALM_ATTACK2", + "S_CYBRAKDEMON_NAPALM_ATTACK3", + "S_CYBRAKDEMON_FINISH_ATTACK1", // If just attacked, remove MF2_FRET w/out going back to spawnstate + "S_CYBRAKDEMON_FINISH_ATTACK2", // Force a delay between attacks so you don't get bombarded with them back-to-back + "S_CYBRAKDEMON_PAIN1", + "S_CYBRAKDEMON_PAIN2", + "S_CYBRAKDEMON_PAIN3", + "S_CYBRAKDEMON_DIE1", + "S_CYBRAKDEMON_DIE2", + "S_CYBRAKDEMON_DIE3", + "S_CYBRAKDEMON_DIE4", + "S_CYBRAKDEMON_DIE5", + "S_CYBRAKDEMON_DIE6", + "S_CYBRAKDEMON_DIE7", + "S_CYBRAKDEMON_DIE8", + "S_CYBRAKDEMON_DEINVINCIBLERIZE", + "S_CYBRAKDEMON_INVINCIBLERIZE", + + "S_CYBRAKDEMONMISSILE", + "S_CYBRAKDEMONMISSILE_EXPLODE1", + "S_CYBRAKDEMONMISSILE_EXPLODE2", + "S_CYBRAKDEMONMISSILE_EXPLODE3", + + "S_CYBRAKDEMONFLAMESHOT_FLY1", + "S_CYBRAKDEMONFLAMESHOT_FLY2", + "S_CYBRAKDEMONFLAMESHOT_FLY3", + "S_CYBRAKDEMONFLAMESHOT_DIE", + + "S_CYBRAKDEMONFLAMEREST", + + "S_CYBRAKDEMONELECTRICBARRIER_INIT1", + "S_CYBRAKDEMONELECTRICBARRIER_INIT2", + "S_CYBRAKDEMONELECTRICBARRIER_PLAYSOUND", + "S_CYBRAKDEMONELECTRICBARRIER1", + "S_CYBRAKDEMONELECTRICBARRIER2", + "S_CYBRAKDEMONELECTRICBARRIER3", + "S_CYBRAKDEMONELECTRICBARRIER4", + "S_CYBRAKDEMONELECTRICBARRIER5", + "S_CYBRAKDEMONELECTRICBARRIER6", + "S_CYBRAKDEMONELECTRICBARRIER7", + "S_CYBRAKDEMONELECTRICBARRIER8", + "S_CYBRAKDEMONELECTRICBARRIER9", + "S_CYBRAKDEMONELECTRICBARRIER10", + "S_CYBRAKDEMONELECTRICBARRIER11", + "S_CYBRAKDEMONELECTRICBARRIER12", + "S_CYBRAKDEMONELECTRICBARRIER13", + "S_CYBRAKDEMONELECTRICBARRIER14", + "S_CYBRAKDEMONELECTRICBARRIER15", + "S_CYBRAKDEMONELECTRICBARRIER16", + "S_CYBRAKDEMONELECTRICBARRIER17", + "S_CYBRAKDEMONELECTRICBARRIER18", + "S_CYBRAKDEMONELECTRICBARRIER19", + "S_CYBRAKDEMONELECTRICBARRIER20", + "S_CYBRAKDEMONELECTRICBARRIER21", + "S_CYBRAKDEMONELECTRICBARRIER22", + "S_CYBRAKDEMONELECTRICBARRIER23", + "S_CYBRAKDEMONELECTRICBARRIER24", + "S_CYBRAKDEMONELECTRICBARRIER_DIE1", + "S_CYBRAKDEMONELECTRICBARRIER_DIE2", + "S_CYBRAKDEMONELECTRICBARRIER_DIE3", + "S_CYBRAKDEMONELECTRICBARRIER_SPARK_RANDOMCHECK", + "S_CYBRAKDEMONELECTRICBARRIER_SPARK_RANDOMSUCCESS", + "S_CYBRAKDEMONELECTRICBARRIER_SPARK_RANDOMCHOOSE", + "S_CYBRAKDEMONELECTRICBARRIER_SPARK_RANDOM1", + "S_CYBRAKDEMONELECTRICBARRIER_SPARK_RANDOM2", + "S_CYBRAKDEMONELECTRICBARRIER_SPARK_RANDOM3", + "S_CYBRAKDEMONELECTRICBARRIER_SPARK_RANDOM4", + "S_CYBRAKDEMONELECTRICBARRIER_SPARK_RANDOM5", + "S_CYBRAKDEMONELECTRICBARRIER_SPARK_RANDOM6", + "S_CYBRAKDEMONELECTRICBARRIER_SPARK_RANDOM7", + "S_CYBRAKDEMONELECTRICBARRIER_SPARK_RANDOM8", + "S_CYBRAKDEMONELECTRICBARRIER_SPARK_RANDOM9", + "S_CYBRAKDEMONELECTRICBARRIER_SPARK_RANDOM10", + "S_CYBRAKDEMONELECTRICBARRIER_SPARK_RANDOM11", + "S_CYBRAKDEMONELECTRICBARRIER_SPARK_RANDOM12", + "S_CYBRAKDEMONELECTRICBARRIER_SPARK_RANDOMFAIL", + "S_CYBRAKDEMONELECTRICBARRIER_SPARK_RANDOMLOOP", + "S_CYBRAKDEMONELECTRICBARRIER_REVIVE1", + "S_CYBRAKDEMONELECTRICBARRIER_REVIVE2", + "S_CYBRAKDEMONELECTRICBARRIER_REVIVE3", + + "S_CYBRAKDEMONTARGETRETICULE1", + "S_CYBRAKDEMONTARGETRETICULE2", + "S_CYBRAKDEMONTARGETRETICULE3", + "S_CYBRAKDEMONTARGETRETICULE4", + "S_CYBRAKDEMONTARGETRETICULE5", + "S_CYBRAKDEMONTARGETRETICULE6", + "S_CYBRAKDEMONTARGETRETICULE7", + "S_CYBRAKDEMONTARGETRETICULE8", + "S_CYBRAKDEMONTARGETRETICULE9", + "S_CYBRAKDEMONTARGETRETICULE10", + "S_CYBRAKDEMONTARGETRETICULE11", + "S_CYBRAKDEMONTARGETRETICULE12", + "S_CYBRAKDEMONTARGETRETICULE13", + "S_CYBRAKDEMONTARGETRETICULE14", + + "S_CYBRAKDEMONTARGETDOT", + + "S_CYBRAKDEMONNAPALMBOMBLARGE_FLY1", + "S_CYBRAKDEMONNAPALMBOMBLARGE_FLY2", + "S_CYBRAKDEMONNAPALMBOMBLARGE_FLY3", + "S_CYBRAKDEMONNAPALMBOMBLARGE_FLY4", + "S_CYBRAKDEMONNAPALMBOMBLARGE_DIE1", // Explode + "S_CYBRAKDEMONNAPALMBOMBLARGE_DIE2", // Outer ring + "S_CYBRAKDEMONNAPALMBOMBLARGE_DIE3", // Center + "S_CYBRAKDEMONNAPALMBOMBLARGE_DIE4", // Sound + + "S_CYBRAKDEMONNAPALMBOMBSMALL", + "S_CYBRAKDEMONNAPALMBOMBSMALL_DIE1", // Explode + "S_CYBRAKDEMONNAPALMBOMBSMALL_DIE2", // Outer ring + "S_CYBRAKDEMONNAPALMBOMBSMALL_DIE3", // Inner ring + "S_CYBRAKDEMONNAPALMBOMBSMALL_DIE4", // Center + "S_CYBRAKDEMONNAPALMBOMBSMALL_DIE5", // Sound + + "S_CYBRAKDEMONNAPALMFLAME_FLY1", + "S_CYBRAKDEMONNAPALMFLAME_FLY2", + "S_CYBRAKDEMONNAPALMFLAME_FLY3", + "S_CYBRAKDEMONNAPALMFLAME_FLY4", + "S_CYBRAKDEMONNAPALMFLAME_FLY5", + "S_CYBRAKDEMONNAPALMFLAME_FLY6", + "S_CYBRAKDEMONNAPALMFLAME_DIE", + + "S_CYBRAKDEMONVILEEXPLOSION1", + "S_CYBRAKDEMONVILEEXPLOSION2", + "S_CYBRAKDEMONVILEEXPLOSION3", + + // Metal Sonic (Race) + "S_METALSONIC_RACE", + // Metal Sonic (Battle) + "S_METALSONIC_FLOAT", + "S_METALSONIC_VECTOR", + "S_METALSONIC_STUN", + "S_METALSONIC_RAISE", + "S_METALSONIC_GATHER", + "S_METALSONIC_DASH", + "S_METALSONIC_BOUNCE", + "S_METALSONIC_BADBOUNCE", + "S_METALSONIC_SHOOT", + "S_METALSONIC_PAIN", + "S_METALSONIC_DEATH1", + "S_METALSONIC_DEATH2", + "S_METALSONIC_DEATH3", + "S_METALSONIC_DEATH4", + "S_METALSONIC_FLEE1", + "S_METALSONIC_FLEE2", + + "S_MSSHIELD_F1", + "S_MSSHIELD_F2", + + // Ring + "S_RING", + + // Blue Sphere for special stages + "S_BLUESPHERE", + "S_BLUESPHEREBONUS", + "S_BLUESPHERESPARK", + + // Bomb Sphere + "S_BOMBSPHERE1", + "S_BOMBSPHERE2", + "S_BOMBSPHERE3", + "S_BOMBSPHERE4", + + // NiGHTS Chip + "S_NIGHTSCHIP", + "S_NIGHTSCHIPBONUS", + + // NiGHTS Star + "S_NIGHTSSTAR", + "S_NIGHTSSTARXMAS", + + // Gravity Wells for special stages + "S_GRAVWELLGREEN", + "S_GRAVWELLRED", + + // Individual Team Rings + "S_TEAMRING", + + // Special Stage Token + "S_TOKEN", + + // CTF Flags + "S_REDFLAG", + "S_BLUEFLAG", + + // Emblem + "S_EMBLEM1", + "S_EMBLEM2", + "S_EMBLEM3", + "S_EMBLEM4", + "S_EMBLEM5", + "S_EMBLEM6", + "S_EMBLEM7", + "S_EMBLEM8", + "S_EMBLEM9", + "S_EMBLEM10", + "S_EMBLEM11", + "S_EMBLEM12", + "S_EMBLEM13", + "S_EMBLEM14", + "S_EMBLEM15", + "S_EMBLEM16", + "S_EMBLEM17", + "S_EMBLEM18", + "S_EMBLEM19", + "S_EMBLEM20", + "S_EMBLEM21", + "S_EMBLEM22", + "S_EMBLEM23", + "S_EMBLEM24", + "S_EMBLEM25", + "S_EMBLEM26", + + // Chaos Emeralds + "S_CEMG1", + "S_CEMG2", + "S_CEMG3", + "S_CEMG4", + "S_CEMG5", + "S_CEMG6", + "S_CEMG7", + + // Emerald hunt shards + "S_SHRD1", + "S_SHRD2", + "S_SHRD3", + + // Bubble Source + "S_BUBBLES1", + "S_BUBBLES2", + "S_BUBBLES3", + "S_BUBBLES4", + + // Level End Sign + "S_SIGN", + "S_SIGNSPIN1", + "S_SIGNSPIN2", + "S_SIGNSPIN3", + "S_SIGNSPIN4", + "S_SIGNSPIN5", + "S_SIGNSPIN6", + "S_SIGNPLAYER", + "S_SIGNSLOW", + "S_SIGNSTOP", + "S_SIGNBOARD", + "S_EGGMANSIGN", + "S_CLEARSIGN", + + // Spike Ball + "S_SPIKEBALL1", + "S_SPIKEBALL2", + "S_SPIKEBALL3", + "S_SPIKEBALL4", + "S_SPIKEBALL5", + "S_SPIKEBALL6", + "S_SPIKEBALL7", + "S_SPIKEBALL8", + + // Elemental Shield's Spawn + "S_SPINFIRE1", + "S_SPINFIRE2", + "S_SPINFIRE3", + "S_SPINFIRE4", + "S_SPINFIRE5", + "S_SPINFIRE6", + + // Spikes + "S_SPIKE1", + "S_SPIKE2", + "S_SPIKE3", + "S_SPIKE4", + "S_SPIKE5", + "S_SPIKE6", + "S_SPIKED1", + "S_SPIKED2", + + // Wall spikes + "S_WALLSPIKE1", + "S_WALLSPIKE2", + "S_WALLSPIKE3", + "S_WALLSPIKE4", + "S_WALLSPIKE5", + "S_WALLSPIKE6", + "S_WALLSPIKEBASE", + "S_WALLSPIKED1", + "S_WALLSPIKED2", + + // Starpost + "S_STARPOST_IDLE", + "S_STARPOST_FLASH", + "S_STARPOST_STARTSPIN", + "S_STARPOST_SPIN", + "S_STARPOST_ENDSPIN", + + // Big floating mine + "S_BIGMINE_IDLE", + "S_BIGMINE_ALERT1", + "S_BIGMINE_ALERT2", + "S_BIGMINE_ALERT3", + "S_BIGMINE_SET1", + "S_BIGMINE_SET2", + "S_BIGMINE_SET3", + "S_BIGMINE_BLAST1", + "S_BIGMINE_BLAST2", + "S_BIGMINE_BLAST3", + "S_BIGMINE_BLAST4", + "S_BIGMINE_BLAST5", + + // Cannon Launcher + "S_CANNONLAUNCHER1", + "S_CANNONLAUNCHER2", + "S_CANNONLAUNCHER3", + + // Monitor Miscellany + "S_BOXSPARKLE1", + "S_BOXSPARKLE2", + "S_BOXSPARKLE3", + "S_BOXSPARKLE4", + + "S_BOX_FLICKER", + "S_BOX_POP1", + "S_BOX_POP2", + + "S_GOLDBOX_FLICKER", + "S_GOLDBOX_OFF1", + "S_GOLDBOX_OFF2", + "S_GOLDBOX_OFF3", + "S_GOLDBOX_OFF4", + "S_GOLDBOX_OFF5", + "S_GOLDBOX_OFF6", + "S_GOLDBOX_OFF7", + + // Monitor States (one per box) + "S_MYSTERY_BOX", + "S_RING_BOX", + "S_PITY_BOX", + "S_ATTRACT_BOX", + "S_FORCE_BOX", + "S_ARMAGEDDON_BOX", + "S_WHIRLWIND_BOX", + "S_ELEMENTAL_BOX", + "S_SNEAKERS_BOX", + "S_INVULN_BOX", + "S_1UP_BOX", + "S_EGGMAN_BOX", + "S_MIXUP_BOX", + "S_GRAVITY_BOX", + "S_RECYCLER_BOX", + "S_SCORE1K_BOX", + "S_SCORE10K_BOX", + "S_FLAMEAURA_BOX", + "S_BUBBLEWRAP_BOX", + "S_THUNDERCOIN_BOX", + + // Gold Repeat Monitor States (one per box) + "S_PITY_GOLDBOX", + "S_ATTRACT_GOLDBOX", + "S_FORCE_GOLDBOX", + "S_ARMAGEDDON_GOLDBOX", + "S_WHIRLWIND_GOLDBOX", + "S_ELEMENTAL_GOLDBOX", + "S_SNEAKERS_GOLDBOX", + "S_INVULN_GOLDBOX", + "S_EGGMAN_GOLDBOX", + "S_GRAVITY_GOLDBOX", + "S_FLAMEAURA_GOLDBOX", + "S_BUBBLEWRAP_GOLDBOX", + "S_THUNDERCOIN_GOLDBOX", + + // Team Ring Boxes (these are special) + "S_RING_REDBOX1", + "S_RING_REDBOX2", + "S_REDBOX_POP1", + "S_REDBOX_POP2", + + "S_RING_BLUEBOX1", + "S_RING_BLUEBOX2", + "S_BLUEBOX_POP1", + "S_BLUEBOX_POP2", + + // Box Icons -- 2 states each, animation and action + "S_RING_ICON1", + "S_RING_ICON2", + + "S_PITY_ICON1", + "S_PITY_ICON2", + + "S_ATTRACT_ICON1", + "S_ATTRACT_ICON2", + + "S_FORCE_ICON1", + "S_FORCE_ICON2", + + "S_ARMAGEDDON_ICON1", + "S_ARMAGEDDON_ICON2", + + "S_WHIRLWIND_ICON1", + "S_WHIRLWIND_ICON2", + + "S_ELEMENTAL_ICON1", + "S_ELEMENTAL_ICON2", + + "S_SNEAKERS_ICON1", + "S_SNEAKERS_ICON2", + + "S_INVULN_ICON1", + "S_INVULN_ICON2", + + "S_1UP_ICON1", + "S_1UP_ICON2", + + "S_EGGMAN_ICON1", + "S_EGGMAN_ICON2", + + "S_MIXUP_ICON1", + "S_MIXUP_ICON2", + + "S_GRAVITY_ICON1", + "S_GRAVITY_ICON2", + + "S_RECYCLER_ICON1", + "S_RECYCLER_ICON2", + + "S_SCORE1K_ICON1", + "S_SCORE1K_ICON2", + + "S_SCORE10K_ICON1", + "S_SCORE10K_ICON2", + + "S_FLAMEAURA_ICON1", + "S_FLAMEAURA_ICON2", + + "S_BUBBLEWRAP_ICON1", + "S_BUBBLEWRAP_ICON2", + + "S_THUNDERCOIN_ICON1", + "S_THUNDERCOIN_ICON2", + + // --- + + "S_ROCKET", + + "S_LASER", + "S_LASER2", + "S_LASERFLASH", + + "S_LASERFLAME1", + "S_LASERFLAME2", + "S_LASERFLAME3", + "S_LASERFLAME4", + "S_LASERFLAME5", + + "S_TORPEDO", + + "S_ENERGYBALL1", + "S_ENERGYBALL2", + + // Skim Mine, also used by Jetty-Syn bomber + "S_MINE1", + "S_MINE_BOOM1", + "S_MINE_BOOM2", + "S_MINE_BOOM3", + "S_MINE_BOOM4", + + // Jetty-Syn Bullet + "S_JETBULLET1", + "S_JETBULLET2", + + "S_TURRETLASER", + "S_TURRETLASEREXPLODE1", + "S_TURRETLASEREXPLODE2", + + // Cannonball + "S_CANNONBALL1", + + // Arrow + "S_ARROW", + "S_ARROWBONK", + + // Glaregoyle Demon fire + "S_DEMONFIRE", + + // The letter + "S_LETTER", + + // GFZ flowers + "S_GFZFLOWERA", + "S_GFZFLOWERB", + "S_GFZFLOWERC", + + "S_BLUEBERRYBUSH", + "S_BERRYBUSH", + "S_BUSH", + + // Trees (both GFZ and misc) + "S_GFZTREE", + "S_GFZBERRYTREE", + "S_GFZCHERRYTREE", + "S_CHECKERTREE", + "S_CHECKERSUNSETTREE", + "S_FHZTREE", // Frozen Hillside + "S_FHZPINKTREE", + "S_POLYGONTREE", + "S_BUSHTREE", + "S_BUSHREDTREE", + "S_SPRINGTREE", + + // THZ flowers + "S_THZFLOWERA", // THZ1 Steam flower + "S_THZFLOWERB", // THZ1 Spin flower (red) + "S_THZFLOWERC", // THZ1 Spin flower (yellow) + + // THZ Steam Whistle tree/bush + "S_THZTREE", + "S_THZTREEBRANCH1", + "S_THZTREEBRANCH2", + "S_THZTREEBRANCH3", + "S_THZTREEBRANCH4", + "S_THZTREEBRANCH5", + "S_THZTREEBRANCH6", + "S_THZTREEBRANCH7", + "S_THZTREEBRANCH8", + "S_THZTREEBRANCH9", + "S_THZTREEBRANCH10", + "S_THZTREEBRANCH11", + "S_THZTREEBRANCH12", + "S_THZTREEBRANCH13", + + // THZ Alarm + "S_ALARM1", + + // Deep Sea Gargoyle + "S_GARGOYLE", + "S_BIGGARGOYLE", + + // DSZ Seaweed + "S_SEAWEED1", + "S_SEAWEED2", + "S_SEAWEED3", + "S_SEAWEED4", + "S_SEAWEED5", + "S_SEAWEED6", + + // Dripping Water + "S_DRIPA1", + "S_DRIPA2", + "S_DRIPA3", + "S_DRIPA4", + "S_DRIPB1", + "S_DRIPC1", + "S_DRIPC2", + + // Coral + "S_CORAL1", + "S_CORAL2", + "S_CORAL3", + "S_CORAL4", + "S_CORAL5", + + // Blue Crystal + "S_BLUECRYSTAL1", + + // Kelp, + "S_KELP", + + // Animated algae + "S_ANIMALGAETOP1", + "S_ANIMALGAETOP2", + "S_ANIMALGAESEG", + + // DSZ Stalagmites + "S_DSZSTALAGMITE", + "S_DSZ2STALAGMITE", + + // DSZ Light beam + "S_LIGHTBEAM1", + "S_LIGHTBEAM2", + "S_LIGHTBEAM3", + "S_LIGHTBEAM4", + "S_LIGHTBEAM5", + "S_LIGHTBEAM6", + "S_LIGHTBEAM7", + "S_LIGHTBEAM8", + "S_LIGHTBEAM9", + "S_LIGHTBEAM10", + "S_LIGHTBEAM11", + "S_LIGHTBEAM12", + + // CEZ Chain + "S_CEZCHAIN", + + // Flame + "S_FLAME", + "S_FLAMEPARTICLE", + "S_FLAMEREST", + + // Eggman Statue + "S_EGGSTATUE1", + + // CEZ hidden sling + "S_SLING1", + "S_SLING2", + + // CEZ maces and chains + "S_SMALLMACECHAIN", + "S_BIGMACECHAIN", + "S_SMALLMACE", + "S_BIGMACE", + "S_SMALLGRABCHAIN", + "S_BIGGRABCHAIN", + + // Yellow spring on a ball + "S_YELLOWSPRINGBALL", + "S_YELLOWSPRINGBALL2", + "S_YELLOWSPRINGBALL3", + "S_YELLOWSPRINGBALL4", + "S_YELLOWSPRINGBALL5", + + // Red spring on a ball + "S_REDSPRINGBALL", + "S_REDSPRINGBALL2", + "S_REDSPRINGBALL3", + "S_REDSPRINGBALL4", + "S_REDSPRINGBALL5", + + // Small Firebar + "S_SMALLFIREBAR1", + "S_SMALLFIREBAR2", + "S_SMALLFIREBAR3", + "S_SMALLFIREBAR4", + "S_SMALLFIREBAR5", + "S_SMALLFIREBAR6", + "S_SMALLFIREBAR7", + "S_SMALLFIREBAR8", + "S_SMALLFIREBAR9", + "S_SMALLFIREBAR10", + "S_SMALLFIREBAR11", + "S_SMALLFIREBAR12", + "S_SMALLFIREBAR13", + "S_SMALLFIREBAR14", + "S_SMALLFIREBAR15", + "S_SMALLFIREBAR16", + + // Big Firebar + "S_BIGFIREBAR1", + "S_BIGFIREBAR2", + "S_BIGFIREBAR3", + "S_BIGFIREBAR4", + "S_BIGFIREBAR5", + "S_BIGFIREBAR6", + "S_BIGFIREBAR7", + "S_BIGFIREBAR8", + "S_BIGFIREBAR9", + "S_BIGFIREBAR10", + "S_BIGFIREBAR11", + "S_BIGFIREBAR12", + "S_BIGFIREBAR13", + "S_BIGFIREBAR14", + "S_BIGFIREBAR15", + "S_BIGFIREBAR16", + + "S_CEZFLOWER", + "S_CEZPOLE", + "S_CEZBANNER1", + "S_CEZBANNER2", + "S_PINETREE", + "S_CEZBUSH1", + "S_CEZBUSH2", + "S_CANDLE", + "S_CANDLEPRICKET", + "S_FLAMEHOLDER", + "S_FIRETORCH", + "S_WAVINGFLAG", + "S_WAVINGFLAGSEG1", + "S_WAVINGFLAGSEG2", + "S_CRAWLASTATUE", + "S_FACESTABBERSTATUE", + "S_SUSPICIOUSFACESTABBERSTATUE_WAIT", + "S_SUSPICIOUSFACESTABBERSTATUE_BURST1", + "S_SUSPICIOUSFACESTABBERSTATUE_BURST2", + "S_BRAMBLES", + + // Big Tumbleweed + "S_BIGTUMBLEWEED", + "S_BIGTUMBLEWEED_ROLL1", + "S_BIGTUMBLEWEED_ROLL2", + "S_BIGTUMBLEWEED_ROLL3", + "S_BIGTUMBLEWEED_ROLL4", + "S_BIGTUMBLEWEED_ROLL5", + "S_BIGTUMBLEWEED_ROLL6", + "S_BIGTUMBLEWEED_ROLL7", + "S_BIGTUMBLEWEED_ROLL8", + + // Little Tumbleweed + "S_LITTLETUMBLEWEED", + "S_LITTLETUMBLEWEED_ROLL1", + "S_LITTLETUMBLEWEED_ROLL2", + "S_LITTLETUMBLEWEED_ROLL3", + "S_LITTLETUMBLEWEED_ROLL4", + "S_LITTLETUMBLEWEED_ROLL5", + "S_LITTLETUMBLEWEED_ROLL6", + "S_LITTLETUMBLEWEED_ROLL7", + "S_LITTLETUMBLEWEED_ROLL8", + + // Cacti + "S_CACTI1", + "S_CACTI2", + "S_CACTI3", + "S_CACTI4", + "S_CACTI5", + "S_CACTI6", + "S_CACTI7", + "S_CACTI8", + "S_CACTI9", + "S_CACTI10", + "S_CACTI11", + "S_CACTITINYSEG", + "S_CACTISMALLSEG", + + // Warning signs + "S_ARIDSIGN_CAUTION", + "S_ARIDSIGN_CACTI", + "S_ARIDSIGN_SHARPTURN", + + // Oil lamp + "S_OILLAMP", + "S_OILLAMPFLARE", + + // TNT barrel + "S_TNTBARREL_STND1", + "S_TNTBARREL_EXPL1", + "S_TNTBARREL_EXPL2", + "S_TNTBARREL_EXPL3", + "S_TNTBARREL_EXPL4", + "S_TNTBARREL_EXPL5", + "S_TNTBARREL_EXPL6", + "S_TNTBARREL_EXPL7", + "S_TNTBARREL_FLYING", + + // TNT proximity shell + "S_PROXIMITY_TNT", + "S_PROXIMITY_TNT_TRIGGER1", + "S_PROXIMITY_TNT_TRIGGER2", + "S_PROXIMITY_TNT_TRIGGER3", + "S_PROXIMITY_TNT_TRIGGER4", + "S_PROXIMITY_TNT_TRIGGER5", + "S_PROXIMITY_TNT_TRIGGER6", + "S_PROXIMITY_TNT_TRIGGER7", + "S_PROXIMITY_TNT_TRIGGER8", + "S_PROXIMITY_TNT_TRIGGER9", + "S_PROXIMITY_TNT_TRIGGER10", + "S_PROXIMITY_TNT_TRIGGER11", + "S_PROXIMITY_TNT_TRIGGER12", + "S_PROXIMITY_TNT_TRIGGER13", + "S_PROXIMITY_TNT_TRIGGER14", + "S_PROXIMITY_TNT_TRIGGER15", + "S_PROXIMITY_TNT_TRIGGER16", + "S_PROXIMITY_TNT_TRIGGER17", + "S_PROXIMITY_TNT_TRIGGER18", + "S_PROXIMITY_TNT_TRIGGER19", + "S_PROXIMITY_TNT_TRIGGER20", + "S_PROXIMITY_TNT_TRIGGER21", + "S_PROXIMITY_TNT_TRIGGER22", + "S_PROXIMITY_TNT_TRIGGER23", + + // Dust devil + "S_DUSTDEVIL", + "S_DUSTLAYER1", + "S_DUSTLAYER2", + "S_DUSTLAYER3", + "S_DUSTLAYER4", + "S_DUSTLAYER5", + "S_ARIDDUST1", + "S_ARIDDUST2", + "S_ARIDDUST3", + + // Minecart + "S_MINECART_IDLE", + "S_MINECART_DTH1", + "S_MINECARTEND", + "S_MINECARTSEG_FRONT", + "S_MINECARTSEG_BACK", + "S_MINECARTSEG_LEFT", + "S_MINECARTSEG_RIGHT", + "S_MINECARTSIDEMARK1", + "S_MINECARTSIDEMARK2", + "S_MINECARTSPARK", + + // Saloon door + "S_SALOONDOOR", + "S_SALOONDOORCENTER", + + // Train cameo + "S_TRAINCAMEOSPAWNER_1", + "S_TRAINCAMEOSPAWNER_2", + "S_TRAINCAMEOSPAWNER_3", + "S_TRAINCAMEOSPAWNER_4", + "S_TRAINCAMEOSPAWNER_5", + "S_TRAINPUFFMAKER", + + // Train + "S_TRAINDUST", + "S_TRAINSTEAM", + + // Flame jet + "S_FLAMEJETSTND", + "S_FLAMEJETSTART", + "S_FLAMEJETSTOP", + "S_FLAMEJETFLAME1", + "S_FLAMEJETFLAME2", + "S_FLAMEJETFLAME3", + "S_FLAMEJETFLAME4", + "S_FLAMEJETFLAME5", + "S_FLAMEJETFLAME6", + "S_FLAMEJETFLAME7", + "S_FLAMEJETFLAME8", + "S_FLAMEJETFLAME9", + + // Spinning flame jets + "S_FJSPINAXISA1", // Counter-clockwise + "S_FJSPINAXISA2", + "S_FJSPINAXISB1", // Clockwise + "S_FJSPINAXISB2", + + // Blade's flame + "S_FLAMEJETFLAMEB1", + "S_FLAMEJETFLAMEB2", + "S_FLAMEJETFLAMEB3", + + // Lavafall + "S_LAVAFALL_DORMANT", + "S_LAVAFALL_TELL", + "S_LAVAFALL_SHOOT", + "S_LAVAFALL_LAVA1", + "S_LAVAFALL_LAVA2", + "S_LAVAFALL_LAVA3", + "S_LAVAFALLROCK", + + // Rollout Rock + "S_ROLLOUTSPAWN", + "S_ROLLOUTROCK", + + // RVZ scenery + "S_BIGFERNLEAF", + "S_BIGFERN1", + "S_BIGFERN2", + "S_JUNGLEPALM", + "S_TORCHFLOWER", + "S_WALLVINE_LONG", + "S_WALLVINE_SHORT", + + // Glaregoyles + "S_GLAREGOYLE", + "S_GLAREGOYLE_CHARGE", + "S_GLAREGOYLE_BLINK", + "S_GLAREGOYLE_HOLD", + "S_GLAREGOYLE_FIRE", + "S_GLAREGOYLE_LOOP", + "S_GLAREGOYLE_COOLDOWN", + "S_GLAREGOYLEUP", + "S_GLAREGOYLEUP_CHARGE", + "S_GLAREGOYLEUP_BLINK", + "S_GLAREGOYLEUP_HOLD", + "S_GLAREGOYLEUP_FIRE", + "S_GLAREGOYLEUP_LOOP", + "S_GLAREGOYLEUP_COOLDOWN", + "S_GLAREGOYLEDOWN", + "S_GLAREGOYLEDOWN_CHARGE", + "S_GLAREGOYLEDOWN_BLINK", + "S_GLAREGOYLEDOWN_HOLD", + "S_GLAREGOYLEDOWN_FIRE", + "S_GLAREGOYLEDOWN_LOOP", + "S_GLAREGOYLEDOWN_COOLDOWN", + "S_GLAREGOYLELONG", + "S_GLAREGOYLELONG_CHARGE", + "S_GLAREGOYLELONG_BLINK", + "S_GLAREGOYLELONG_HOLD", + "S_GLAREGOYLELONG_FIRE", + "S_GLAREGOYLELONG_LOOP", + "S_GLAREGOYLELONG_COOLDOWN", + + // ATZ's Red Crystal/Target + "S_TARGET_IDLE", + "S_TARGET_HIT1", + "S_TARGET_HIT2", + "S_TARGET_RESPAWN", + "S_TARGET_ALLDONE", + + // ATZ's green flame + "S_GREENFLAME", + + // ATZ Blue Gargoyle + "S_BLUEGARGOYLE", + + // Stalagmites + "S_STG0", + "S_STG1", + "S_STG2", + "S_STG3", + "S_STG4", + "S_STG5", + "S_STG6", + "S_STG7", + "S_STG8", + "S_STG9", + + // Xmas-specific stuff + "S_XMASPOLE", + "S_CANDYCANE", + "S_SNOWMAN", // normal + "S_SNOWMANHAT", // with hat + scarf + "S_LAMPPOST1", // normal + "S_LAMPPOST2", // with snow + "S_HANGSTAR", + "S_MISTLETOE", + // Xmas GFZ bushes + "S_XMASBLUEBERRYBUSH", + "S_XMASBERRYBUSH", + "S_XMASBUSH", + // FHZ + "S_FHZICE1", + "S_FHZICE2", + "S_ROSY_IDLE1", + "S_ROSY_IDLE2", + "S_ROSY_IDLE3", + "S_ROSY_IDLE4", + "S_ROSY_JUMP", + "S_ROSY_WALK", + "S_ROSY_HUG", + "S_ROSY_PAIN", + "S_ROSY_STND", + "S_ROSY_UNHAPPY", + + // Halloween Scenery + // Pumpkins + "S_JACKO1", + "S_JACKO1OVERLAY_1", + "S_JACKO1OVERLAY_2", + "S_JACKO1OVERLAY_3", + "S_JACKO1OVERLAY_4", + "S_JACKO2", + "S_JACKO2OVERLAY_1", + "S_JACKO2OVERLAY_2", + "S_JACKO2OVERLAY_3", + "S_JACKO2OVERLAY_4", + "S_JACKO3", + "S_JACKO3OVERLAY_1", + "S_JACKO3OVERLAY_2", + "S_JACKO3OVERLAY_3", + "S_JACKO3OVERLAY_4", + // Dr Seuss Trees + "S_HHZTREE_TOP", + "S_HHZTREE_TRUNK", + "S_HHZTREE_LEAF", + // Mushroom + "S_HHZSHROOM_1", + "S_HHZSHROOM_2", + "S_HHZSHROOM_3", + "S_HHZSHROOM_4", + "S_HHZSHROOM_5", + "S_HHZSHROOM_6", + "S_HHZSHROOM_7", + "S_HHZSHROOM_8", + "S_HHZSHROOM_9", + "S_HHZSHROOM_10", + "S_HHZSHROOM_11", + "S_HHZSHROOM_12", + "S_HHZSHROOM_13", + "S_HHZSHROOM_14", + "S_HHZSHROOM_15", + "S_HHZSHROOM_16", + // Misc + "S_HHZGRASS", + "S_HHZTENT1", + "S_HHZTENT2", + "S_HHZSTALAGMITE_TALL", + "S_HHZSTALAGMITE_SHORT", + + // Botanic Serenity's loads of scenery states + "S_BSZTALLFLOWER_RED", + "S_BSZTALLFLOWER_PURPLE", + "S_BSZTALLFLOWER_BLUE", + "S_BSZTALLFLOWER_CYAN", + "S_BSZTALLFLOWER_YELLOW", + "S_BSZTALLFLOWER_ORANGE", + "S_BSZFLOWER_RED", + "S_BSZFLOWER_PURPLE", + "S_BSZFLOWER_BLUE", + "S_BSZFLOWER_CYAN", + "S_BSZFLOWER_YELLOW", + "S_BSZFLOWER_ORANGE", + "S_BSZSHORTFLOWER_RED", + "S_BSZSHORTFLOWER_PURPLE", + "S_BSZSHORTFLOWER_BLUE", + "S_BSZSHORTFLOWER_CYAN", + "S_BSZSHORTFLOWER_YELLOW", + "S_BSZSHORTFLOWER_ORANGE", + "S_BSZTULIP_RED", + "S_BSZTULIP_PURPLE", + "S_BSZTULIP_BLUE", + "S_BSZTULIP_CYAN", + "S_BSZTULIP_YELLOW", + "S_BSZTULIP_ORANGE", + "S_BSZCLUSTER_RED", + "S_BSZCLUSTER_PURPLE", + "S_BSZCLUSTER_BLUE", + "S_BSZCLUSTER_CYAN", + "S_BSZCLUSTER_YELLOW", + "S_BSZCLUSTER_ORANGE", + "S_BSZBUSH_RED", + "S_BSZBUSH_PURPLE", + "S_BSZBUSH_BLUE", + "S_BSZBUSH_CYAN", + "S_BSZBUSH_YELLOW", + "S_BSZBUSH_ORANGE", + "S_BSZVINE_RED", + "S_BSZVINE_PURPLE", + "S_BSZVINE_BLUE", + "S_BSZVINE_CYAN", + "S_BSZVINE_YELLOW", + "S_BSZVINE_ORANGE", + "S_BSZSHRUB", + "S_BSZCLOVER", + "S_BIG_PALMTREE_TRUNK", + "S_BIG_PALMTREE_TOP", + "S_PALMTREE_TRUNK", + "S_PALMTREE_TOP", + + "S_DBALL1", + "S_DBALL2", + "S_DBALL3", + "S_DBALL4", + "S_DBALL5", + "S_DBALL6", + "S_EGGSTATUE2", + + // Shield Orb + "S_ARMA1", + "S_ARMA2", + "S_ARMA3", + "S_ARMA4", + "S_ARMA5", + "S_ARMA6", + "S_ARMA7", + "S_ARMA8", + "S_ARMA9", + "S_ARMA10", + "S_ARMA11", + "S_ARMA12", + "S_ARMA13", + "S_ARMA14", + "S_ARMA15", + "S_ARMA16", + + "S_ARMF1", + "S_ARMF2", + "S_ARMF3", + "S_ARMF4", + "S_ARMF5", + "S_ARMF6", + "S_ARMF7", + "S_ARMF8", + "S_ARMF9", + "S_ARMF10", + "S_ARMF11", + "S_ARMF12", + "S_ARMF13", + "S_ARMF14", + "S_ARMF15", + "S_ARMF16", + "S_ARMF17", + "S_ARMF18", + "S_ARMF19", + "S_ARMF20", + "S_ARMF21", + "S_ARMF22", + "S_ARMF23", + "S_ARMF24", + "S_ARMF25", + "S_ARMF26", + "S_ARMF27", + "S_ARMF28", + "S_ARMF29", + "S_ARMF30", + "S_ARMF31", + "S_ARMF32", + + "S_ARMB1", + "S_ARMB2", + "S_ARMB3", + "S_ARMB4", + "S_ARMB5", + "S_ARMB6", + "S_ARMB7", + "S_ARMB8", + "S_ARMB9", + "S_ARMB10", + "S_ARMB11", + "S_ARMB12", + "S_ARMB13", + "S_ARMB14", + "S_ARMB15", + "S_ARMB16", + "S_ARMB17", + "S_ARMB18", + "S_ARMB19", + "S_ARMB20", + "S_ARMB21", + "S_ARMB22", + "S_ARMB23", + "S_ARMB24", + "S_ARMB25", + "S_ARMB26", + "S_ARMB27", + "S_ARMB28", + "S_ARMB29", + "S_ARMB30", + "S_ARMB31", + "S_ARMB32", + + "S_WIND1", + "S_WIND2", + "S_WIND3", + "S_WIND4", + "S_WIND5", + "S_WIND6", + "S_WIND7", + "S_WIND8", + + "S_MAGN1", + "S_MAGN2", + "S_MAGN3", + "S_MAGN4", + "S_MAGN5", + "S_MAGN6", + "S_MAGN7", + "S_MAGN8", + "S_MAGN9", + "S_MAGN10", + "S_MAGN11", + "S_MAGN12", + "S_MAGN13", + + "S_FORC1", + "S_FORC2", + "S_FORC3", + "S_FORC4", + "S_FORC5", + "S_FORC6", + "S_FORC7", + "S_FORC8", + "S_FORC9", + "S_FORC10", + + "S_FORC11", + "S_FORC12", + "S_FORC13", + "S_FORC14", + "S_FORC15", + "S_FORC16", + "S_FORC17", + "S_FORC18", + "S_FORC19", + "S_FORC20", + + "S_FORC21", + + "S_ELEM1", + "S_ELEM2", + "S_ELEM3", + "S_ELEM4", + "S_ELEM5", + "S_ELEM6", + "S_ELEM7", + "S_ELEM8", + "S_ELEM9", + "S_ELEM10", + "S_ELEM11", + "S_ELEM12", + + "S_ELEM13", + "S_ELEM14", + + "S_ELEMF1", + "S_ELEMF2", + "S_ELEMF3", + "S_ELEMF4", + "S_ELEMF5", + "S_ELEMF6", + "S_ELEMF7", + "S_ELEMF8", + "S_ELEMF9", + "S_ELEMF10", + + "S_PITY1", + "S_PITY2", + "S_PITY3", + "S_PITY4", + "S_PITY5", + "S_PITY6", + "S_PITY7", + "S_PITY8", + "S_PITY9", + "S_PITY10", + "S_PITY11", + "S_PITY12", + + "S_FIRS1", + "S_FIRS2", + "S_FIRS3", + "S_FIRS4", + "S_FIRS5", + "S_FIRS6", + "S_FIRS7", + "S_FIRS8", + "S_FIRS9", + + "S_FIRS10", + "S_FIRS11", + + "S_FIRSB1", + "S_FIRSB2", + "S_FIRSB3", + "S_FIRSB4", + "S_FIRSB5", + "S_FIRSB6", + "S_FIRSB7", + "S_FIRSB8", + "S_FIRSB9", + + "S_FIRSB10", + + "S_BUBS1", + "S_BUBS2", + "S_BUBS3", + "S_BUBS4", + "S_BUBS5", + "S_BUBS6", + "S_BUBS7", + "S_BUBS8", + "S_BUBS9", + + "S_BUBS10", + "S_BUBS11", + + "S_BUBSB1", + "S_BUBSB2", + "S_BUBSB3", + "S_BUBSB4", + + "S_BUBSB5", + "S_BUBSB6", + + "S_ZAPS1", + "S_ZAPS2", + "S_ZAPS3", + "S_ZAPS4", + "S_ZAPS5", + "S_ZAPS6", + "S_ZAPS7", + "S_ZAPS8", + "S_ZAPS9", + "S_ZAPS10", + "S_ZAPS11", + "S_ZAPS12", + "S_ZAPS13", // blank frame + "S_ZAPS14", + "S_ZAPS15", + "S_ZAPS16", + + "S_ZAPSB1", // blank frame + "S_ZAPSB2", + "S_ZAPSB3", + "S_ZAPSB4", + "S_ZAPSB5", + "S_ZAPSB6", + "S_ZAPSB7", + "S_ZAPSB8", + "S_ZAPSB9", + "S_ZAPSB10", + "S_ZAPSB11", // blank frame + + //Thunder spark + "S_THUNDERCOIN_SPARK", + + // Invincibility Sparkles + "S_IVSP", + + // Super Sonic Spark + "S_SSPK1", + "S_SSPK2", + "S_SSPK3", + "S_SSPK4", + "S_SSPK5", + + // Flicky-sized bubble + "S_FLICKY_BUBBLE", + + // Bluebird + "S_FLICKY_01_OUT", + "S_FLICKY_01_FLAP1", + "S_FLICKY_01_FLAP2", + "S_FLICKY_01_FLAP3", + "S_FLICKY_01_STAND", + "S_FLICKY_01_CENTER", + + // Rabbit + "S_FLICKY_02_OUT", + "S_FLICKY_02_AIM", + "S_FLICKY_02_HOP", + "S_FLICKY_02_UP", + "S_FLICKY_02_DOWN", + "S_FLICKY_02_STAND", + "S_FLICKY_02_CENTER", + + // Chicken + "S_FLICKY_03_OUT", + "S_FLICKY_03_AIM", + "S_FLICKY_03_HOP", + "S_FLICKY_03_UP", + "S_FLICKY_03_FLAP1", + "S_FLICKY_03_FLAP2", + "S_FLICKY_03_STAND", + "S_FLICKY_03_CENTER", + + // Seal + "S_FLICKY_04_OUT", + "S_FLICKY_04_AIM", + "S_FLICKY_04_HOP", + "S_FLICKY_04_UP", + "S_FLICKY_04_DOWN", + "S_FLICKY_04_SWIM1", + "S_FLICKY_04_SWIM2", + "S_FLICKY_04_SWIM3", + "S_FLICKY_04_SWIM4", + "S_FLICKY_04_STAND", + "S_FLICKY_04_CENTER", + + // Pig + "S_FLICKY_05_OUT", + "S_FLICKY_05_AIM", + "S_FLICKY_05_HOP", + "S_FLICKY_05_UP", + "S_FLICKY_05_DOWN", + "S_FLICKY_05_STAND", + "S_FLICKY_05_CENTER", + + // Chipmunk + "S_FLICKY_06_OUT", + "S_FLICKY_06_AIM", + "S_FLICKY_06_HOP", + "S_FLICKY_06_UP", + "S_FLICKY_06_DOWN", + "S_FLICKY_06_STAND", + "S_FLICKY_06_CENTER", + + // Penguin + "S_FLICKY_07_OUT", + "S_FLICKY_07_AIML", + "S_FLICKY_07_HOPL", + "S_FLICKY_07_UPL", + "S_FLICKY_07_DOWNL", + "S_FLICKY_07_AIMR", + "S_FLICKY_07_HOPR", + "S_FLICKY_07_UPR", + "S_FLICKY_07_DOWNR", + "S_FLICKY_07_SWIM1", + "S_FLICKY_07_SWIM2", + "S_FLICKY_07_SWIM3", + "S_FLICKY_07_STAND", + "S_FLICKY_07_CENTER", + + // Fish + "S_FLICKY_08_OUT", + "S_FLICKY_08_AIM", + "S_FLICKY_08_HOP", + "S_FLICKY_08_FLAP1", + "S_FLICKY_08_FLAP2", + "S_FLICKY_08_FLAP3", + "S_FLICKY_08_FLAP4", + "S_FLICKY_08_SWIM1", + "S_FLICKY_08_SWIM2", + "S_FLICKY_08_SWIM3", + "S_FLICKY_08_SWIM4", + "S_FLICKY_08_STAND", + "S_FLICKY_08_CENTER", + + // Ram + "S_FLICKY_09_OUT", + "S_FLICKY_09_AIM", + "S_FLICKY_09_HOP", + "S_FLICKY_09_UP", + "S_FLICKY_09_DOWN", + "S_FLICKY_09_STAND", + "S_FLICKY_09_CENTER", + + // Puffin + "S_FLICKY_10_OUT", + "S_FLICKY_10_FLAP1", + "S_FLICKY_10_FLAP2", + "S_FLICKY_10_STAND", + "S_FLICKY_10_CENTER", + + // Cow + "S_FLICKY_11_OUT", + "S_FLICKY_11_AIM", + "S_FLICKY_11_RUN1", + "S_FLICKY_11_RUN2", + "S_FLICKY_11_RUN3", + "S_FLICKY_11_STAND", + "S_FLICKY_11_CENTER", + + // Rat + "S_FLICKY_12_OUT", + "S_FLICKY_12_AIM", + "S_FLICKY_12_RUN1", + "S_FLICKY_12_RUN2", + "S_FLICKY_12_RUN3", + "S_FLICKY_12_STAND", + "S_FLICKY_12_CENTER", + + // Bear + "S_FLICKY_13_OUT", + "S_FLICKY_13_AIM", + "S_FLICKY_13_HOP", + "S_FLICKY_13_UP", + "S_FLICKY_13_DOWN", + "S_FLICKY_13_STAND", + "S_FLICKY_13_CENTER", + + // Dove + "S_FLICKY_14_OUT", + "S_FLICKY_14_FLAP1", + "S_FLICKY_14_FLAP2", + "S_FLICKY_14_FLAP3", + "S_FLICKY_14_STAND", + "S_FLICKY_14_CENTER", + + // Cat + "S_FLICKY_15_OUT", + "S_FLICKY_15_AIM", + "S_FLICKY_15_HOP", + "S_FLICKY_15_UP", + "S_FLICKY_15_DOWN", + "S_FLICKY_15_STAND", + "S_FLICKY_15_CENTER", + + // Canary + "S_FLICKY_16_OUT", + "S_FLICKY_16_FLAP1", + "S_FLICKY_16_FLAP2", + "S_FLICKY_16_FLAP3", + "S_FLICKY_16_STAND", + "S_FLICKY_16_CENTER", + + // Spider + "S_SECRETFLICKY_01_OUT", + "S_SECRETFLICKY_01_AIM", + "S_SECRETFLICKY_01_HOP", + "S_SECRETFLICKY_01_UP", + "S_SECRETFLICKY_01_DOWN", + "S_SECRETFLICKY_01_STAND", + "S_SECRETFLICKY_01_CENTER", + + // Bat + "S_SECRETFLICKY_02_OUT", + "S_SECRETFLICKY_02_FLAP1", + "S_SECRETFLICKY_02_FLAP2", + "S_SECRETFLICKY_02_FLAP3", + "S_SECRETFLICKY_02_STAND", + "S_SECRETFLICKY_02_CENTER", + + // Fan + "S_FAN", + "S_FAN2", + "S_FAN3", + "S_FAN4", + "S_FAN5", + + // Steam Riser + "S_STEAM1", + "S_STEAM2", + "S_STEAM3", + "S_STEAM4", + "S_STEAM5", + "S_STEAM6", + "S_STEAM7", + "S_STEAM8", + + // Bumpers + "S_BUMPER", + "S_BUMPERHIT", + + // Balloons + "S_BALLOON", + "S_BALLOONPOP1", + "S_BALLOONPOP2", + "S_BALLOONPOP3", + "S_BALLOONPOP4", + "S_BALLOONPOP5", + "S_BALLOONPOP6", + + // Yellow Spring + "S_YELLOWSPRING", + "S_YELLOWSPRING2", + "S_YELLOWSPRING3", + "S_YELLOWSPRING4", + "S_YELLOWSPRING5", + + // Red Spring + "S_REDSPRING", + "S_REDSPRING2", + "S_REDSPRING3", + "S_REDSPRING4", + "S_REDSPRING5", + + // Blue Spring + "S_BLUESPRING", + "S_BLUESPRING2", + "S_BLUESPRING3", + "S_BLUESPRING4", + "S_BLUESPRING5", + + // Yellow Diagonal Spring + "S_YDIAG1", + "S_YDIAG2", + "S_YDIAG3", + "S_YDIAG4", + "S_YDIAG5", + "S_YDIAG6", + "S_YDIAG7", + "S_YDIAG8", + + // Red Diagonal Spring + "S_RDIAG1", + "S_RDIAG2", + "S_RDIAG3", + "S_RDIAG4", + "S_RDIAG5", + "S_RDIAG6", + "S_RDIAG7", + "S_RDIAG8", + + // Blue Diagonal Spring + "S_BDIAG1", + "S_BDIAG2", + "S_BDIAG3", + "S_BDIAG4", + "S_BDIAG5", + "S_BDIAG6", + "S_BDIAG7", + "S_BDIAG8", + + // Yellow Side Spring + "S_YHORIZ1", + "S_YHORIZ2", + "S_YHORIZ3", + "S_YHORIZ4", + "S_YHORIZ5", + "S_YHORIZ6", + "S_YHORIZ7", + "S_YHORIZ8", + + // Red Side Spring + "S_RHORIZ1", + "S_RHORIZ2", + "S_RHORIZ3", + "S_RHORIZ4", + "S_RHORIZ5", + "S_RHORIZ6", + "S_RHORIZ7", + "S_RHORIZ8", + + // Blue Side Spring + "S_BHORIZ1", + "S_BHORIZ2", + "S_BHORIZ3", + "S_BHORIZ4", + "S_BHORIZ5", + "S_BHORIZ6", + "S_BHORIZ7", + "S_BHORIZ8", + + // Booster + "S_BOOSTERSOUND", + "S_YELLOWBOOSTERROLLER", + "S_YELLOWBOOSTERSEG_LEFT", + "S_YELLOWBOOSTERSEG_RIGHT", + "S_YELLOWBOOSTERSEG_FACE", + "S_REDBOOSTERROLLER", + "S_REDBOOSTERSEG_LEFT", + "S_REDBOOSTERSEG_RIGHT", + "S_REDBOOSTERSEG_FACE", + + // Rain + "S_RAIN1", + "S_RAINRETURN", + + // Snowflake + "S_SNOW1", + "S_SNOW2", + "S_SNOW3", + + // Water Splish + "S_SPLISH1", + "S_SPLISH2", + "S_SPLISH3", + "S_SPLISH4", + "S_SPLISH5", + "S_SPLISH6", + "S_SPLISH7", + "S_SPLISH8", + "S_SPLISH9", + + // Lava Splish + "S_LAVASPLISH", + + // added water splash + "S_SPLASH1", + "S_SPLASH2", + "S_SPLASH3", + + // lava/slime damage burn smoke + "S_SMOKE1", + "S_SMOKE2", + "S_SMOKE3", + "S_SMOKE4", + "S_SMOKE5", + + // Bubbles + "S_SMALLBUBBLE", + "S_MEDIUMBUBBLE", + "S_LARGEBUBBLE1", + "S_LARGEBUBBLE2", + "S_EXTRALARGEBUBBLE", // breathable + + "S_POP1", // Extra Large bubble goes POP! + + "S_WATERZAP", + + // Spindash dust + "S_SPINDUST1", + "S_SPINDUST2", + "S_SPINDUST3", + "S_SPINDUST4", + "S_SPINDUST_BUBBLE1", + "S_SPINDUST_BUBBLE2", + "S_SPINDUST_BUBBLE3", + "S_SPINDUST_BUBBLE4", + "S_SPINDUST_FIRE1", + "S_SPINDUST_FIRE2", + "S_SPINDUST_FIRE3", + "S_SPINDUST_FIRE4", + + "S_FOG1", + "S_FOG2", + "S_FOG3", + "S_FOG4", + "S_FOG5", + "S_FOG6", + "S_FOG7", + "S_FOG8", + "S_FOG9", + "S_FOG10", + "S_FOG11", + "S_FOG12", + "S_FOG13", + "S_FOG14", + + "S_SEED", + + "S_PARTICLE", + + // Score Logos + "S_SCRA", // 100 + "S_SCRB", // 200 + "S_SCRC", // 500 + "S_SCRD", // 1000 + "S_SCRE", // 10000 + "S_SCRF", // 400 (mario) + "S_SCRG", // 800 (mario) + "S_SCRH", // 2000 (mario) + "S_SCRI", // 4000 (mario) + "S_SCRJ", // 8000 (mario) + "S_SCRK", // 1UP (mario) + "S_SCRL", // 10 + + // Drowning Timer Numbers + "S_ZERO1", + "S_ONE1", + "S_TWO1", + "S_THREE1", + "S_FOUR1", + "S_FIVE1", + + "S_ZERO2", + "S_ONE2", + "S_TWO2", + "S_THREE2", + "S_FOUR2", + "S_FIVE2", + + "S_FLIGHTINDICATOR", + + "S_LOCKON1", + "S_LOCKON2", + "S_LOCKON3", + "S_LOCKON4", + "S_LOCKONINF1", + "S_LOCKONINF2", + "S_LOCKONINF3", + "S_LOCKONINF4", + + // Tag Sign + "S_TTAG", + + // Got Flag Sign + "S_GOTFLAG", + + // Finish flag + "S_FINISHFLAG", + + "S_CORK", + "S_LHRT", + + // Red Ring + "S_RRNG1", + "S_RRNG2", + "S_RRNG3", + "S_RRNG4", + "S_RRNG5", + "S_RRNG6", + "S_RRNG7", + + // Weapon Ring Ammo + "S_BOUNCERINGAMMO", + "S_RAILRINGAMMO", + "S_INFINITYRINGAMMO", + "S_AUTOMATICRINGAMMO", + "S_EXPLOSIONRINGAMMO", + "S_SCATTERRINGAMMO", + "S_GRENADERINGAMMO", + + // Weapon pickup + "S_BOUNCEPICKUP", + "S_BOUNCEPICKUPFADE1", + "S_BOUNCEPICKUPFADE2", + "S_BOUNCEPICKUPFADE3", + "S_BOUNCEPICKUPFADE4", + "S_BOUNCEPICKUPFADE5", + "S_BOUNCEPICKUPFADE6", + "S_BOUNCEPICKUPFADE7", + "S_BOUNCEPICKUPFADE8", + + "S_RAILPICKUP", + "S_RAILPICKUPFADE1", + "S_RAILPICKUPFADE2", + "S_RAILPICKUPFADE3", + "S_RAILPICKUPFADE4", + "S_RAILPICKUPFADE5", + "S_RAILPICKUPFADE6", + "S_RAILPICKUPFADE7", + "S_RAILPICKUPFADE8", + + "S_AUTOPICKUP", + "S_AUTOPICKUPFADE1", + "S_AUTOPICKUPFADE2", + "S_AUTOPICKUPFADE3", + "S_AUTOPICKUPFADE4", + "S_AUTOPICKUPFADE5", + "S_AUTOPICKUPFADE6", + "S_AUTOPICKUPFADE7", + "S_AUTOPICKUPFADE8", + + "S_EXPLODEPICKUP", + "S_EXPLODEPICKUPFADE1", + "S_EXPLODEPICKUPFADE2", + "S_EXPLODEPICKUPFADE3", + "S_EXPLODEPICKUPFADE4", + "S_EXPLODEPICKUPFADE5", + "S_EXPLODEPICKUPFADE6", + "S_EXPLODEPICKUPFADE7", + "S_EXPLODEPICKUPFADE8", + + "S_SCATTERPICKUP", + "S_SCATTERPICKUPFADE1", + "S_SCATTERPICKUPFADE2", + "S_SCATTERPICKUPFADE3", + "S_SCATTERPICKUPFADE4", + "S_SCATTERPICKUPFADE5", + "S_SCATTERPICKUPFADE6", + "S_SCATTERPICKUPFADE7", + "S_SCATTERPICKUPFADE8", + + "S_GRENADEPICKUP", + "S_GRENADEPICKUPFADE1", + "S_GRENADEPICKUPFADE2", + "S_GRENADEPICKUPFADE3", + "S_GRENADEPICKUPFADE4", + "S_GRENADEPICKUPFADE5", + "S_GRENADEPICKUPFADE6", + "S_GRENADEPICKUPFADE7", + "S_GRENADEPICKUPFADE8", + + // Thrown Weapon Rings + "S_THROWNBOUNCE1", + "S_THROWNBOUNCE2", + "S_THROWNBOUNCE3", + "S_THROWNBOUNCE4", + "S_THROWNBOUNCE5", + "S_THROWNBOUNCE6", + "S_THROWNBOUNCE7", + "S_THROWNINFINITY1", + "S_THROWNINFINITY2", + "S_THROWNINFINITY3", + "S_THROWNINFINITY4", + "S_THROWNINFINITY5", + "S_THROWNINFINITY6", + "S_THROWNINFINITY7", + "S_THROWNAUTOMATIC1", + "S_THROWNAUTOMATIC2", + "S_THROWNAUTOMATIC3", + "S_THROWNAUTOMATIC4", + "S_THROWNAUTOMATIC5", + "S_THROWNAUTOMATIC6", + "S_THROWNAUTOMATIC7", + "S_THROWNEXPLOSION1", + "S_THROWNEXPLOSION2", + "S_THROWNEXPLOSION3", + "S_THROWNEXPLOSION4", + "S_THROWNEXPLOSION5", + "S_THROWNEXPLOSION6", + "S_THROWNEXPLOSION7", + "S_THROWNGRENADE1", + "S_THROWNGRENADE2", + "S_THROWNGRENADE3", + "S_THROWNGRENADE4", + "S_THROWNGRENADE5", + "S_THROWNGRENADE6", + "S_THROWNGRENADE7", + "S_THROWNGRENADE8", + "S_THROWNGRENADE9", + "S_THROWNGRENADE10", + "S_THROWNGRENADE11", + "S_THROWNGRENADE12", + "S_THROWNGRENADE13", + "S_THROWNGRENADE14", + "S_THROWNGRENADE15", + "S_THROWNGRENADE16", + "S_THROWNGRENADE17", + "S_THROWNGRENADE18", + "S_THROWNSCATTER", + + "S_RINGEXPLODE", + + "S_COIN1", + "S_COIN2", + "S_COIN3", + "S_COINSPARKLE1", + "S_COINSPARKLE2", + "S_COINSPARKLE3", + "S_COINSPARKLE4", + "S_GOOMBA1", + "S_GOOMBA1B", + "S_GOOMBA2", + "S_GOOMBA3", + "S_GOOMBA4", + "S_GOOMBA5", + "S_GOOMBA6", + "S_GOOMBA7", + "S_GOOMBA8", + "S_GOOMBA9", + "S_GOOMBA_DEAD", + "S_BLUEGOOMBA1", + "S_BLUEGOOMBA1B", + "S_BLUEGOOMBA2", + "S_BLUEGOOMBA3", + "S_BLUEGOOMBA4", + "S_BLUEGOOMBA5", + "S_BLUEGOOMBA6", + "S_BLUEGOOMBA7", + "S_BLUEGOOMBA8", + "S_BLUEGOOMBA9", + "S_BLUEGOOMBA_DEAD", + + // Mario-specific stuff + "S_FIREFLOWER1", + "S_FIREFLOWER2", + "S_FIREFLOWER3", + "S_FIREFLOWER4", + "S_FIREBALL", + "S_FIREBALLTRAIL1", + "S_FIREBALLTRAIL2", + "S_SHELL", + "S_PUMA_START1", + "S_PUMA_START2", + "S_PUMA_UP1", + "S_PUMA_UP2", + "S_PUMA_UP3", + "S_PUMA_DOWN1", + "S_PUMA_DOWN2", + "S_PUMA_DOWN3", + "S_PUMATRAIL1", + "S_PUMATRAIL2", + "S_PUMATRAIL3", + "S_PUMATRAIL4", + "S_HAMMER", + "S_KOOPA1", + "S_KOOPA2", + "S_KOOPAFLAME1", + "S_KOOPAFLAME2", + "S_KOOPAFLAME3", + "S_AXE1", + "S_AXE2", + "S_AXE3", + "S_MARIOBUSH1", + "S_MARIOBUSH2", + "S_TOAD", + + // Nights-specific stuff + "S_NIGHTSDRONE_MAN1", + "S_NIGHTSDRONE_MAN2", + "S_NIGHTSDRONE_SPARKLING1", + "S_NIGHTSDRONE_SPARKLING2", + "S_NIGHTSDRONE_SPARKLING3", + "S_NIGHTSDRONE_SPARKLING4", + "S_NIGHTSDRONE_SPARKLING5", + "S_NIGHTSDRONE_SPARKLING6", + "S_NIGHTSDRONE_SPARKLING7", + "S_NIGHTSDRONE_SPARKLING8", + "S_NIGHTSDRONE_SPARKLING9", + "S_NIGHTSDRONE_SPARKLING10", + "S_NIGHTSDRONE_SPARKLING11", + "S_NIGHTSDRONE_SPARKLING12", + "S_NIGHTSDRONE_SPARKLING13", + "S_NIGHTSDRONE_SPARKLING14", + "S_NIGHTSDRONE_SPARKLING15", + "S_NIGHTSDRONE_SPARKLING16", + "S_NIGHTSDRONE_GOAL1", + "S_NIGHTSDRONE_GOAL2", + "S_NIGHTSDRONE_GOAL3", + "S_NIGHTSDRONE_GOAL4", + + "S_NIGHTSPARKLE1", + "S_NIGHTSPARKLE2", + "S_NIGHTSPARKLE3", + "S_NIGHTSPARKLE4", + "S_NIGHTSPARKLESUPER1", + "S_NIGHTSPARKLESUPER2", + "S_NIGHTSPARKLESUPER3", + "S_NIGHTSPARKLESUPER4", + "S_NIGHTSLOOPHELPER", + + // NiGHTS bumper + "S_NIGHTSBUMPER1", + "S_NIGHTSBUMPER2", + "S_NIGHTSBUMPER3", + "S_NIGHTSBUMPER4", + "S_NIGHTSBUMPER5", + "S_NIGHTSBUMPER6", + "S_NIGHTSBUMPER7", + "S_NIGHTSBUMPER8", + "S_NIGHTSBUMPER9", + "S_NIGHTSBUMPER10", + "S_NIGHTSBUMPER11", + "S_NIGHTSBUMPER12", + + "S_HOOP", + "S_HOOP_XMASA", + "S_HOOP_XMASB", + + "S_NIGHTSCORE10", + "S_NIGHTSCORE20", + "S_NIGHTSCORE30", + "S_NIGHTSCORE40", + "S_NIGHTSCORE50", + "S_NIGHTSCORE60", + "S_NIGHTSCORE70", + "S_NIGHTSCORE80", + "S_NIGHTSCORE90", + "S_NIGHTSCORE100", + "S_NIGHTSCORE10_2", + "S_NIGHTSCORE20_2", + "S_NIGHTSCORE30_2", + "S_NIGHTSCORE40_2", + "S_NIGHTSCORE50_2", + "S_NIGHTSCORE60_2", + "S_NIGHTSCORE70_2", + "S_NIGHTSCORE80_2", + "S_NIGHTSCORE90_2", + "S_NIGHTSCORE100_2", + + // NiGHTS Paraloop Powerups + "S_NIGHTSSUPERLOOP", + "S_NIGHTSDRILLREFILL", + "S_NIGHTSHELPER", + "S_NIGHTSEXTRATIME", + "S_NIGHTSLINKFREEZE", + "S_EGGCAPSULE", + + // Orbiting Chaos Emeralds + "S_ORBITEM1", + "S_ORBITEM2", + "S_ORBITEM3", + "S_ORBITEM4", + "S_ORBITEM5", + "S_ORBITEM6", + "S_ORBITEM7", + "S_ORBITEM8", + "S_ORBIDYA1", + "S_ORBIDYA2", + "S_ORBIDYA3", + "S_ORBIDYA4", + "S_ORBIDYA5", + + // "Flicky" helper + "S_NIGHTOPIANHELPER1", + "S_NIGHTOPIANHELPER2", + "S_NIGHTOPIANHELPER3", + "S_NIGHTOPIANHELPER4", + "S_NIGHTOPIANHELPER5", + "S_NIGHTOPIANHELPER6", + "S_NIGHTOPIANHELPER7", + "S_NIGHTOPIANHELPER8", + "S_NIGHTOPIANHELPER9", + + // Nightopian + "S_PIAN0", + "S_PIAN1", + "S_PIAN2", + "S_PIAN3", + "S_PIAN4", + "S_PIAN5", + "S_PIAN6", + "S_PIANSING", + + // Shleep + "S_SHLEEP1", + "S_SHLEEP2", + "S_SHLEEP3", + "S_SHLEEP4", + "S_SHLEEPBOUNCE1", + "S_SHLEEPBOUNCE2", + "S_SHLEEPBOUNCE3", + + // Secret badniks and hazards, shhhh + "S_PENGUINATOR_LOOK", + "S_PENGUINATOR_WADDLE1", + "S_PENGUINATOR_WADDLE2", + "S_PENGUINATOR_WADDLE3", + "S_PENGUINATOR_WADDLE4", + "S_PENGUINATOR_SLIDE1", + "S_PENGUINATOR_SLIDE2", + "S_PENGUINATOR_SLIDE3", + "S_PENGUINATOR_SLIDE4", + "S_PENGUINATOR_SLIDE5", + + "S_POPHAT_LOOK", + "S_POPHAT_SHOOT1", + "S_POPHAT_SHOOT2", + "S_POPHAT_SHOOT3", + "S_POPHAT_SHOOT4", + "S_POPSHOT", + "S_POPSHOT_TRAIL", + + "S_HIVEELEMENTAL_LOOK", + "S_HIVEELEMENTAL_PREPARE1", + "S_HIVEELEMENTAL_PREPARE2", + "S_HIVEELEMENTAL_SHOOT1", + "S_HIVEELEMENTAL_SHOOT2", + "S_HIVEELEMENTAL_DORMANT", + "S_HIVEELEMENTAL_PAIN", + "S_HIVEELEMENTAL_DIE1", + "S_HIVEELEMENTAL_DIE2", + "S_HIVEELEMENTAL_DIE3", + + "S_BUMBLEBORE_SPAWN", + "S_BUMBLEBORE_LOOK1", + "S_BUMBLEBORE_LOOK2", + "S_BUMBLEBORE_FLY1", + "S_BUMBLEBORE_FLY2", + "S_BUMBLEBORE_RAISE", + "S_BUMBLEBORE_FALL1", + "S_BUMBLEBORE_FALL2", + "S_BUMBLEBORE_STUCK1", + "S_BUMBLEBORE_STUCK2", + "S_BUMBLEBORE_DIE", + + "S_BUGGLEIDLE", + "S_BUGGLEFLY", + + "S_SMASHSPIKE_FLOAT", + "S_SMASHSPIKE_EASE1", + "S_SMASHSPIKE_EASE2", + "S_SMASHSPIKE_FALL", + "S_SMASHSPIKE_STOMP1", + "S_SMASHSPIKE_STOMP2", + "S_SMASHSPIKE_RISE1", + "S_SMASHSPIKE_RISE2", + + "S_CACO_LOOK", + "S_CACO_WAKE1", + "S_CACO_WAKE2", + "S_CACO_WAKE3", + "S_CACO_WAKE4", + "S_CACO_ROAR", + "S_CACO_CHASE", + "S_CACO_CHASE_REPEAT", + "S_CACO_RANDOM", + "S_CACO_PREPARE_SOUND", + "S_CACO_PREPARE1", + "S_CACO_PREPARE2", + "S_CACO_PREPARE3", + "S_CACO_SHOOT_SOUND", + "S_CACO_SHOOT1", + "S_CACO_SHOOT2", + "S_CACO_CLOSE", + "S_CACO_DIE_FLAGS", + "S_CACO_DIE_GIB1", + "S_CACO_DIE_GIB2", + "S_CACO_DIE_SCREAM", + "S_CACO_DIE_SHATTER", + "S_CACO_DIE_FALL", + "S_CACOSHARD_RANDOMIZE", + "S_CACOSHARD1_1", + "S_CACOSHARD1_2", + "S_CACOSHARD2_1", + "S_CACOSHARD2_2", + "S_CACOFIRE1", + "S_CACOFIRE2", + "S_CACOFIRE3", + "S_CACOFIRE_EXPLODE1", + "S_CACOFIRE_EXPLODE2", + "S_CACOFIRE_EXPLODE3", + "S_CACOFIRE_EXPLODE4", + + "S_SPINBOBERT_MOVE_FLIPUP", + "S_SPINBOBERT_MOVE_UP", + "S_SPINBOBERT_MOVE_FLIPDOWN", + "S_SPINBOBERT_MOVE_DOWN", + "S_SPINBOBERT_FIRE_MOVE", + "S_SPINBOBERT_FIRE_GHOST", + "S_SPINBOBERT_FIRE_TRAIL1", + "S_SPINBOBERT_FIRE_TRAIL2", + "S_SPINBOBERT_FIRE_TRAIL3", + + "S_HANGSTER_LOOK", + "S_HANGSTER_SWOOP1", + "S_HANGSTER_SWOOP2", + "S_HANGSTER_ARC1", + "S_HANGSTER_ARC2", + "S_HANGSTER_ARC3", + "S_HANGSTER_FLY1", + "S_HANGSTER_FLY2", + "S_HANGSTER_FLY3", + "S_HANGSTER_FLY4", + "S_HANGSTER_FLYREPEAT", + "S_HANGSTER_ARCUP1", + "S_HANGSTER_ARCUP2", + "S_HANGSTER_ARCUP3", + "S_HANGSTER_RETURN1", + "S_HANGSTER_RETURN2", + "S_HANGSTER_RETURN3", + + "S_CRUMBLE1", + "S_CRUMBLE2", + + // Spark + "S_SPRK1", + "S_SPRK2", + "S_SPRK3", + + // Robot Explosion + "S_XPLD_FLICKY", + "S_XPLD1", + "S_XPLD2", + "S_XPLD3", + "S_XPLD4", + "S_XPLD5", + "S_XPLD6", + "S_XPLD_EGGTRAP", + + // Underwater Explosion + "S_WPLD1", + "S_WPLD2", + "S_WPLD3", + "S_WPLD4", + "S_WPLD5", + "S_WPLD6", + + "S_DUST1", + "S_DUST2", + "S_DUST3", + "S_DUST4", + + "S_ROCKSPAWN", + + "S_ROCKCRUMBLEA", + "S_ROCKCRUMBLEB", + "S_ROCKCRUMBLEC", + "S_ROCKCRUMBLED", + "S_ROCKCRUMBLEE", + "S_ROCKCRUMBLEF", + "S_ROCKCRUMBLEG", + "S_ROCKCRUMBLEH", + "S_ROCKCRUMBLEI", + "S_ROCKCRUMBLEJ", + "S_ROCKCRUMBLEK", + "S_ROCKCRUMBLEL", + "S_ROCKCRUMBLEM", + "S_ROCKCRUMBLEN", + "S_ROCKCRUMBLEO", + "S_ROCKCRUMBLEP", + + // Level debris + "S_GFZDEBRIS", + "S_BRICKDEBRIS", + "S_WOODDEBRIS", + "S_REDBRICKDEBRIS", + "S_BLUEBRICKDEBRIS", + "S_YELLOWBRICKDEBRIS", + +#ifdef SEENAMES + "S_NAMECHECK", +#endif +}; + +// RegEx to generate this from info.h: ^\tMT_([^,]+), --> \t"MT_\1", +// I am leaving the prefixes solely for clarity to programmers, +// because sadly no one remembers this place while searching for full state names. +const char *const MOBJTYPE_LIST[] = { // array length left dynamic for sanity testing later. + "MT_NULL", + "MT_UNKNOWN", + + "MT_THOK", // Thok! mobj + "MT_PLAYER", + "MT_TAILSOVERLAY", // c: + "MT_METALJETFUME", + + // Enemies + "MT_BLUECRAWLA", // Crawla (Blue) + "MT_REDCRAWLA", // Crawla (Red) + "MT_GFZFISH", // SDURF + "MT_GOLDBUZZ", // Buzz (Gold) + "MT_REDBUZZ", // Buzz (Red) + "MT_JETTBOMBER", // Jetty-Syn Bomber + "MT_JETTGUNNER", // Jetty-Syn Gunner + "MT_CRAWLACOMMANDER", // Crawla Commander + "MT_DETON", // Deton + "MT_SKIM", // Skim mine dropper + "MT_TURRET", // Industrial Turret + "MT_POPUPTURRET", // Pop-Up Turret + "MT_SPINCUSHION", // Spincushion + "MT_CRUSHSTACEAN", // Crushstacean + "MT_CRUSHCLAW", // Big meaty claw + "MT_CRUSHCHAIN", // Chain + "MT_BANPYURA", // Banpyura + "MT_BANPSPRING", // Banpyura spring + "MT_JETJAW", // Jet Jaw + "MT_SNAILER", // Snailer + "MT_VULTURE", // BASH + "MT_POINTY", // Pointy + "MT_POINTYBALL", // Pointy Ball + "MT_ROBOHOOD", // Robo-Hood + "MT_FACESTABBER", // Castlebot Facestabber + "MT_FACESTABBERSPEAR", // Castlebot Facestabber spear aura + "MT_EGGGUARD", // Egg Guard + "MT_EGGSHIELD", // Egg Guard's shield + "MT_GSNAPPER", // Green Snapper + "MT_SNAPPER_LEG", // Green Snapper leg + "MT_SNAPPER_HEAD", // Green Snapper head + "MT_MINUS", // Minus + "MT_MINUSDIRT", // Minus dirt + "MT_SPRINGSHELL", // Spring Shell + "MT_YELLOWSHELL", // Spring Shell (yellow) + "MT_UNIDUS", // Unidus + "MT_UNIBALL", // Unidus Ball + "MT_CANARIVORE", // Canarivore + "MT_CANARIVORE_GAS", // Canarivore gas + "MT_PYREFLY", // Pyre Fly + "MT_PYREFLY_FIRE", // Pyre Fly fire + "MT_PTERABYTESPAWNER", // Pterabyte spawner + "MT_PTERABYTEWAYPOINT", // Pterabyte waypoint + "MT_PTERABYTE", // Pterabyte + "MT_DRAGONBOMBER", // Dragonbomber + "MT_DRAGONWING", // Dragonbomber wing + "MT_DRAGONTAIL", // Dragonbomber tail segment + "MT_DRAGONMINE", // Dragonbomber mine + + // Generic Boss Items + "MT_BOSSEXPLODE", + "MT_SONIC3KBOSSEXPLODE", + "MT_BOSSFLYPOINT", + "MT_EGGTRAP", + "MT_BOSS3WAYPOINT", + "MT_BOSS9GATHERPOINT", + "MT_BOSSJUNK", + + // Boss 1 + "MT_EGGMOBILE", + "MT_JETFUME1", + "MT_EGGMOBILE_BALL", + "MT_EGGMOBILE_TARGET", + "MT_EGGMOBILE_FIRE", + + // Boss 2 + "MT_EGGMOBILE2", + "MT_EGGMOBILE2_POGO", + "MT_GOOP", + "MT_GOOPTRAIL", + + // Boss 3 + "MT_EGGMOBILE3", + "MT_FAKEMOBILE", + "MT_SHOCKWAVE", + + // Boss 4 + "MT_EGGMOBILE4", + "MT_EGGMOBILE4_MACE", + "MT_JETFLAME", + "MT_EGGROBO1", + "MT_EGGROBO1JET", + + // Boss 5 + "MT_FANG", + "MT_BROKENROBOT", + "MT_VWREF", + "MT_VWREB", + "MT_PROJECTORLIGHT", + "MT_FBOMB", + "MT_TNTDUST", // also used by barrel + "MT_FSGNA", + "MT_FSGNB", + "MT_FANGWAYPOINT", + + // Black Eggman (Boss 7) + "MT_BLACKEGGMAN", + "MT_BLACKEGGMAN_HELPER", + "MT_BLACKEGGMAN_GOOPFIRE", + "MT_BLACKEGGMAN_MISSILE", + + // New Very-Last-Minute 2.1 Brak Eggman (Cy-Brak-demon) + "MT_CYBRAKDEMON", + "MT_CYBRAKDEMON_ELECTRIC_BARRIER", + "MT_CYBRAKDEMON_MISSILE", + "MT_CYBRAKDEMON_FLAMESHOT", + "MT_CYBRAKDEMON_FLAMEREST", + "MT_CYBRAKDEMON_TARGET_RETICULE", + "MT_CYBRAKDEMON_TARGET_DOT", + "MT_CYBRAKDEMON_NAPALM_BOMB_LARGE", + "MT_CYBRAKDEMON_NAPALM_BOMB_SMALL", + "MT_CYBRAKDEMON_NAPALM_FLAMES", + "MT_CYBRAKDEMON_VILE_EXPLOSION", + + // Metal Sonic (Boss 9) + "MT_METALSONIC_RACE", + "MT_METALSONIC_BATTLE", + "MT_MSSHIELD_FRONT", + "MT_MSGATHER", + + // Collectible Items + "MT_RING", + "MT_FLINGRING", // Lost ring + "MT_BLUESPHERE", // Blue sphere for special stages + "MT_FLINGBLUESPHERE", // Lost blue sphere + "MT_BOMBSPHERE", + "MT_REDTEAMRING", //Rings collectable by red team. + "MT_BLUETEAMRING", //Rings collectable by blue team. + "MT_TOKEN", // Special Stage token for special stage + "MT_REDFLAG", // Red CTF Flag + "MT_BLUEFLAG", // Blue CTF Flag + "MT_EMBLEM", + "MT_EMERALD1", + "MT_EMERALD2", + "MT_EMERALD3", + "MT_EMERALD4", + "MT_EMERALD5", + "MT_EMERALD6", + "MT_EMERALD7", + "MT_EMERHUNT", // Emerald Hunt + "MT_EMERALDSPAWN", // Emerald spawner w/ delay + "MT_FLINGEMERALD", // Lost emerald + + // Springs and others + "MT_FAN", + "MT_STEAM", + "MT_BUMPER", + "MT_BALLOON", + + "MT_YELLOWSPRING", + "MT_REDSPRING", + "MT_BLUESPRING", + "MT_YELLOWDIAG", + "MT_REDDIAG", + "MT_BLUEDIAG", + "MT_YELLOWHORIZ", + "MT_REDHORIZ", + "MT_BLUEHORIZ", + + "MT_BOOSTERSEG", + "MT_BOOSTERROLLER", + "MT_YELLOWBOOSTER", + "MT_REDBOOSTER", + + // Interactive Objects + "MT_BUBBLES", // Bubble source + "MT_SIGN", // Level end sign + "MT_SPIKEBALL", // Spike Ball + "MT_SPINFIRE", + "MT_SPIKE", + "MT_WALLSPIKE", + "MT_WALLSPIKEBASE", + "MT_STARPOST", + "MT_BIGMINE", + "MT_BLASTEXECUTOR", + "MT_CANNONLAUNCHER", + + // Monitor miscellany + "MT_BOXSPARKLE", + + // Monitor boxes -- regular + "MT_RING_BOX", + "MT_PITY_BOX", + "MT_ATTRACT_BOX", + "MT_FORCE_BOX", + "MT_ARMAGEDDON_BOX", + "MT_WHIRLWIND_BOX", + "MT_ELEMENTAL_BOX", + "MT_SNEAKERS_BOX", + "MT_INVULN_BOX", + "MT_1UP_BOX", + "MT_EGGMAN_BOX", + "MT_MIXUP_BOX", + "MT_MYSTERY_BOX", + "MT_GRAVITY_BOX", + "MT_RECYCLER_BOX", + "MT_SCORE1K_BOX", + "MT_SCORE10K_BOX", + "MT_FLAMEAURA_BOX", + "MT_BUBBLEWRAP_BOX", + "MT_THUNDERCOIN_BOX", + + // Monitor boxes -- repeating (big) boxes + "MT_PITY_GOLDBOX", + "MT_ATTRACT_GOLDBOX", + "MT_FORCE_GOLDBOX", + "MT_ARMAGEDDON_GOLDBOX", + "MT_WHIRLWIND_GOLDBOX", + "MT_ELEMENTAL_GOLDBOX", + "MT_SNEAKERS_GOLDBOX", + "MT_INVULN_GOLDBOX", + "MT_EGGMAN_GOLDBOX", + "MT_GRAVITY_GOLDBOX", + "MT_FLAMEAURA_GOLDBOX", + "MT_BUBBLEWRAP_GOLDBOX", + "MT_THUNDERCOIN_GOLDBOX", + + // Monitor boxes -- special + "MT_RING_REDBOX", + "MT_RING_BLUEBOX", + + // Monitor icons + "MT_RING_ICON", + "MT_PITY_ICON", + "MT_ATTRACT_ICON", + "MT_FORCE_ICON", + "MT_ARMAGEDDON_ICON", + "MT_WHIRLWIND_ICON", + "MT_ELEMENTAL_ICON", + "MT_SNEAKERS_ICON", + "MT_INVULN_ICON", + "MT_1UP_ICON", + "MT_EGGMAN_ICON", + "MT_MIXUP_ICON", + "MT_GRAVITY_ICON", + "MT_RECYCLER_ICON", + "MT_SCORE1K_ICON", + "MT_SCORE10K_ICON", + "MT_FLAMEAURA_ICON", + "MT_BUBBLEWRAP_ICON", + "MT_THUNDERCOIN_ICON", + + // Projectiles + "MT_ROCKET", + "MT_LASER", + "MT_TORPEDO", + "MT_TORPEDO2", // silent + "MT_ENERGYBALL", + "MT_MINE", // Skim/Jetty-Syn mine + "MT_JETTBULLET", // Jetty-Syn Bullet + "MT_TURRETLASER", + "MT_CANNONBALL", // Cannonball + "MT_CANNONBALLDECOR", // Decorative/still cannonball + "MT_ARROW", // Arrow + "MT_DEMONFIRE", // Glaregoyle fire + + // The letter + "MT_LETTER", + + // Greenflower Scenery + "MT_GFZFLOWER1", + "MT_GFZFLOWER2", + "MT_GFZFLOWER3", + + "MT_BLUEBERRYBUSH", + "MT_BERRYBUSH", + "MT_BUSH", + + // Trees (both GFZ and misc) + "MT_GFZTREE", + "MT_GFZBERRYTREE", + "MT_GFZCHERRYTREE", + "MT_CHECKERTREE", + "MT_CHECKERSUNSETTREE", + "MT_FHZTREE", // Frozen Hillside + "MT_FHZPINKTREE", + "MT_POLYGONTREE", + "MT_BUSHTREE", + "MT_BUSHREDTREE", + "MT_SPRINGTREE", + + // Techno Hill Scenery + "MT_THZFLOWER1", + "MT_THZFLOWER2", + "MT_THZFLOWER3", + "MT_THZTREE", // Steam whistle tree/bush + "MT_THZTREEBRANCH", // branch of said tree + "MT_ALARM", + + // Deep Sea Scenery + "MT_GARGOYLE", // Deep Sea Gargoyle + "MT_BIGGARGOYLE", // Deep Sea Gargoyle (Big) + "MT_SEAWEED", // DSZ Seaweed + "MT_WATERDRIP", // Dripping Water source + "MT_WATERDROP", // Water drop from dripping water + "MT_CORAL1", // Coral + "MT_CORAL2", + "MT_CORAL3", + "MT_CORAL4", + "MT_CORAL5", + "MT_BLUECRYSTAL", // Blue Crystal + "MT_KELP", // Kelp + "MT_ANIMALGAETOP", // Animated algae top + "MT_ANIMALGAESEG", // Animated algae segment + "MT_DSZSTALAGMITE", // Deep Sea 1 Stalagmite + "MT_DSZ2STALAGMITE", // Deep Sea 2 Stalagmite + "MT_LIGHTBEAM", // DSZ Light beam + + // Castle Eggman Scenery + "MT_CHAIN", // CEZ Chain + "MT_FLAME", // Flame (has corona) + "MT_FLAMEPARTICLE", + "MT_EGGSTATUE", // Eggman Statue + "MT_MACEPOINT", // Mace rotation point + "MT_CHAINMACEPOINT", // Combination of chains and maces point + "MT_SPRINGBALLPOINT", // Spring ball point + "MT_CHAINPOINT", // Mace chain + "MT_HIDDEN_SLING", // Spin mace chain (activatable) + "MT_FIREBARPOINT", // Firebar + "MT_CUSTOMMACEPOINT", // Custom mace + "MT_SMALLMACECHAIN", // Small Mace Chain + "MT_BIGMACECHAIN", // Big Mace Chain + "MT_SMALLMACE", // Small Mace + "MT_BIGMACE", // Big Mace + "MT_SMALLGRABCHAIN", // Small Grab Chain + "MT_BIGGRABCHAIN", // Big Grab Chain + "MT_YELLOWSPRINGBALL", // Yellow spring on a ball + "MT_REDSPRINGBALL", // Red spring on a ball + "MT_SMALLFIREBAR", // Small Firebar + "MT_BIGFIREBAR", // Big Firebar + "MT_CEZFLOWER", // Flower + "MT_CEZPOLE1", // Pole (with red banner) + "MT_CEZPOLE2", // Pole (with blue banner) + "MT_CEZBANNER1", // Banner (red) + "MT_CEZBANNER2", // Banner (blue) + "MT_PINETREE", // Pine Tree + "MT_CEZBUSH1", // Bush 1 + "MT_CEZBUSH2", // Bush 2 + "MT_CANDLE", // Candle + "MT_CANDLEPRICKET", // Candle pricket + "MT_FLAMEHOLDER", // Flame holder + "MT_FIRETORCH", // Fire torch + "MT_WAVINGFLAG1", // Waving flag (red) + "MT_WAVINGFLAG2", // Waving flag (blue) + "MT_WAVINGFLAGSEG1", // Waving flag segment (red) + "MT_WAVINGFLAGSEG2", // Waving flag segment (blue) + "MT_CRAWLASTATUE", // Crawla statue + "MT_FACESTABBERSTATUE", // Facestabber statue + "MT_SUSPICIOUSFACESTABBERSTATUE", // :eggthinking: + "MT_BRAMBLES", // Brambles + + // Arid Canyon Scenery + "MT_BIGTUMBLEWEED", + "MT_LITTLETUMBLEWEED", + "MT_CACTI1", // Tiny Red Flower Cactus + "MT_CACTI2", // Small Red Flower Cactus + "MT_CACTI3", // Tiny Blue Flower Cactus + "MT_CACTI4", // Small Blue Flower Cactus + "MT_CACTI5", // Prickly Pear + "MT_CACTI6", // Barrel Cactus + "MT_CACTI7", // Tall Barrel Cactus + "MT_CACTI8", // Armed Cactus + "MT_CACTI9", // Ball Cactus + "MT_CACTI10", // Tiny Cactus + "MT_CACTI11", // Small Cactus + "MT_CACTITINYSEG", // Tiny Cactus Segment + "MT_CACTISMALLSEG", // Small Cactus Segment + "MT_ARIDSIGN_CAUTION", // Caution Sign + "MT_ARIDSIGN_CACTI", // Cacti Sign + "MT_ARIDSIGN_SHARPTURN", // Sharp Turn Sign + "MT_OILLAMP", + "MT_TNTBARREL", + "MT_PROXIMITYTNT", + "MT_DUSTDEVIL", + "MT_DUSTLAYER", + "MT_ARIDDUST", + "MT_MINECART", + "MT_MINECARTSEG", + "MT_MINECARTSPAWNER", + "MT_MINECARTEND", + "MT_MINECARTENDSOLID", + "MT_MINECARTSIDEMARK", + "MT_MINECARTSPARK", + "MT_SALOONDOOR", + "MT_SALOONDOORCENTER", + "MT_TRAINCAMEOSPAWNER", + "MT_TRAINSEG", + "MT_TRAINDUSTSPAWNER", + "MT_TRAINSTEAMSPAWNER", + "MT_MINECARTSWITCHPOINT", + + // Red Volcano Scenery + "MT_FLAMEJET", + "MT_VERTICALFLAMEJET", + "MT_FLAMEJETFLAME", + + "MT_FJSPINAXISA", // Counter-clockwise + "MT_FJSPINAXISB", // Clockwise + + "MT_FLAMEJETFLAMEB", // Blade's flame + + "MT_LAVAFALL", + "MT_LAVAFALL_LAVA", + "MT_LAVAFALLROCK", + + "MT_ROLLOUTSPAWN", + "MT_ROLLOUTROCK", + + "MT_BIGFERNLEAF", + "MT_BIGFERN", + "MT_JUNGLEPALM", + "MT_TORCHFLOWER", + "MT_WALLVINE_LONG", + "MT_WALLVINE_SHORT", + + // Dark City Scenery + + // Egg Rock Scenery + + // Azure Temple Scenery + "MT_GLAREGOYLE", + "MT_GLAREGOYLEUP", + "MT_GLAREGOYLEDOWN", + "MT_GLAREGOYLELONG", + "MT_TARGET", // AKA Red Crystal + "MT_GREENFLAME", + "MT_BLUEGARGOYLE", + + // Stalagmites + "MT_STALAGMITE0", + "MT_STALAGMITE1", + "MT_STALAGMITE2", + "MT_STALAGMITE3", + "MT_STALAGMITE4", + "MT_STALAGMITE5", + "MT_STALAGMITE6", + "MT_STALAGMITE7", + "MT_STALAGMITE8", + "MT_STALAGMITE9", + + // Christmas Scenery + "MT_XMASPOLE", + "MT_CANDYCANE", + "MT_SNOWMAN", // normal + "MT_SNOWMANHAT", // with hat + scarf + "MT_LAMPPOST1", // normal + "MT_LAMPPOST2", // with snow + "MT_HANGSTAR", + "MT_MISTLETOE", + // Xmas GFZ bushes + "MT_XMASBLUEBERRYBUSH", + "MT_XMASBERRYBUSH", + "MT_XMASBUSH", + // FHZ + "MT_FHZICE1", + "MT_FHZICE2", + "MT_ROSY", + "MT_CDLHRT", + + // Halloween Scenery + // Pumpkins + "MT_JACKO1", + "MT_JACKO2", + "MT_JACKO3", + // Dr Seuss Trees + "MT_HHZTREE_TOP", + "MT_HHZTREE_PART", + // Misc + "MT_HHZSHROOM", + "MT_HHZGRASS", + "MT_HHZTENTACLE1", + "MT_HHZTENTACLE2", + "MT_HHZSTALAGMITE_TALL", + "MT_HHZSTALAGMITE_SHORT", + + // Botanic Serenity scenery + "MT_BSZTALLFLOWER_RED", + "MT_BSZTALLFLOWER_PURPLE", + "MT_BSZTALLFLOWER_BLUE", + "MT_BSZTALLFLOWER_CYAN", + "MT_BSZTALLFLOWER_YELLOW", + "MT_BSZTALLFLOWER_ORANGE", + "MT_BSZFLOWER_RED", + "MT_BSZFLOWER_PURPLE", + "MT_BSZFLOWER_BLUE", + "MT_BSZFLOWER_CYAN", + "MT_BSZFLOWER_YELLOW", + "MT_BSZFLOWER_ORANGE", + "MT_BSZSHORTFLOWER_RED", + "MT_BSZSHORTFLOWER_PURPLE", + "MT_BSZSHORTFLOWER_BLUE", + "MT_BSZSHORTFLOWER_CYAN", + "MT_BSZSHORTFLOWER_YELLOW", + "MT_BSZSHORTFLOWER_ORANGE", + "MT_BSZTULIP_RED", + "MT_BSZTULIP_PURPLE", + "MT_BSZTULIP_BLUE", + "MT_BSZTULIP_CYAN", + "MT_BSZTULIP_YELLOW", + "MT_BSZTULIP_ORANGE", + "MT_BSZCLUSTER_RED", + "MT_BSZCLUSTER_PURPLE", + "MT_BSZCLUSTER_BLUE", + "MT_BSZCLUSTER_CYAN", + "MT_BSZCLUSTER_YELLOW", + "MT_BSZCLUSTER_ORANGE", + "MT_BSZBUSH_RED", + "MT_BSZBUSH_PURPLE", + "MT_BSZBUSH_BLUE", + "MT_BSZBUSH_CYAN", + "MT_BSZBUSH_YELLOW", + "MT_BSZBUSH_ORANGE", + "MT_BSZVINE_RED", + "MT_BSZVINE_PURPLE", + "MT_BSZVINE_BLUE", + "MT_BSZVINE_CYAN", + "MT_BSZVINE_YELLOW", + "MT_BSZVINE_ORANGE", + "MT_BSZSHRUB", + "MT_BSZCLOVER", + "MT_BIG_PALMTREE_TRUNK", + "MT_BIG_PALMTREE_TOP", + "MT_PALMTREE_TRUNK", + "MT_PALMTREE_TOP", + + // Misc scenery + "MT_DBALL", + "MT_EGGSTATUE2", + + // Powerup Indicators + "MT_ELEMENTAL_ORB", // Elemental shield mobj + "MT_ATTRACT_ORB", // Attract shield mobj + "MT_FORCE_ORB", // Force shield mobj + "MT_ARMAGEDDON_ORB", // Armageddon shield mobj + "MT_WHIRLWIND_ORB", // Whirlwind shield mobj + "MT_PITY_ORB", // Pity shield mobj + "MT_FLAMEAURA_ORB", // Flame shield mobj + "MT_BUBBLEWRAP_ORB", // Bubble shield mobj + "MT_THUNDERCOIN_ORB", // Thunder shield mobj + "MT_THUNDERCOIN_SPARK", // Thunder spark + "MT_IVSP", // Invincibility sparkles + "MT_SUPERSPARK", // Super Sonic Spark + + // Flickies + "MT_FLICKY_01", // Bluebird + "MT_FLICKY_01_CENTER", + "MT_FLICKY_02", // Rabbit + "MT_FLICKY_02_CENTER", + "MT_FLICKY_03", // Chicken + "MT_FLICKY_03_CENTER", + "MT_FLICKY_04", // Seal + "MT_FLICKY_04_CENTER", + "MT_FLICKY_05", // Pig + "MT_FLICKY_05_CENTER", + "MT_FLICKY_06", // Chipmunk + "MT_FLICKY_06_CENTER", + "MT_FLICKY_07", // Penguin + "MT_FLICKY_07_CENTER", + "MT_FLICKY_08", // Fish + "MT_FLICKY_08_CENTER", + "MT_FLICKY_09", // Ram + "MT_FLICKY_09_CENTER", + "MT_FLICKY_10", // Puffin + "MT_FLICKY_10_CENTER", + "MT_FLICKY_11", // Cow + "MT_FLICKY_11_CENTER", + "MT_FLICKY_12", // Rat + "MT_FLICKY_12_CENTER", + "MT_FLICKY_13", // Bear + "MT_FLICKY_13_CENTER", + "MT_FLICKY_14", // Dove + "MT_FLICKY_14_CENTER", + "MT_FLICKY_15", // Cat + "MT_FLICKY_15_CENTER", + "MT_FLICKY_16", // Canary + "MT_FLICKY_16_CENTER", + "MT_SECRETFLICKY_01", // Spider + "MT_SECRETFLICKY_01_CENTER", + "MT_SECRETFLICKY_02", // Bat + "MT_SECRETFLICKY_02_CENTER", + "MT_SEED", + + // Environmental Effects + "MT_RAIN", // Rain + "MT_SNOWFLAKE", // Snowflake + "MT_SPLISH", // Water splish! + "MT_LAVASPLISH", // Lava splish! + "MT_SMOKE", + "MT_SMALLBUBBLE", // small bubble + "MT_MEDIUMBUBBLE", // medium bubble + "MT_EXTRALARGEBUBBLE", // extra large bubble + "MT_WATERZAP", + "MT_SPINDUST", // Spindash dust + "MT_TFOG", + "MT_PARTICLE", + "MT_PARTICLEGEN", // For fans, etc. + + // Game Indicators + "MT_SCORE", // score logo + "MT_DROWNNUMBERS", // Drowning Timer + "MT_GOTEMERALD", // Chaos Emerald (intangible) + "MT_LOCKON", // Target + "MT_LOCKONINF", // In-level Target + "MT_TAG", // Tag Sign + "MT_GOTFLAG", // Got Flag sign + "MT_FINISHFLAG", // Finish flag + + // Ambient Sounds + "MT_AWATERA", // Ambient Water Sound 1 + "MT_AWATERB", // Ambient Water Sound 2 + "MT_AWATERC", // Ambient Water Sound 3 + "MT_AWATERD", // Ambient Water Sound 4 + "MT_AWATERE", // Ambient Water Sound 5 + "MT_AWATERF", // Ambient Water Sound 6 + "MT_AWATERG", // Ambient Water Sound 7 + "MT_AWATERH", // Ambient Water Sound 8 + "MT_RANDOMAMBIENT", + "MT_RANDOMAMBIENT2", + "MT_MACHINEAMBIENCE", + + "MT_CORK", + "MT_LHRT", + + // Ring Weapons + "MT_REDRING", + "MT_BOUNCERING", + "MT_RAILRING", + "MT_INFINITYRING", + "MT_AUTOMATICRING", + "MT_EXPLOSIONRING", + "MT_SCATTERRING", + "MT_GRENADERING", + + "MT_BOUNCEPICKUP", + "MT_RAILPICKUP", + "MT_AUTOPICKUP", + "MT_EXPLODEPICKUP", + "MT_SCATTERPICKUP", + "MT_GRENADEPICKUP", + + "MT_THROWNBOUNCE", + "MT_THROWNINFINITY", + "MT_THROWNAUTOMATIC", + "MT_THROWNSCATTER", + "MT_THROWNEXPLOSION", + "MT_THROWNGRENADE", + + // Mario-specific stuff + "MT_COIN", + "MT_FLINGCOIN", + "MT_GOOMBA", + "MT_BLUEGOOMBA", + "MT_FIREFLOWER", + "MT_FIREBALL", + "MT_FIREBALLTRAIL", + "MT_SHELL", + "MT_PUMA", + "MT_PUMATRAIL", + "MT_HAMMER", + "MT_KOOPA", + "MT_KOOPAFLAME", + "MT_AXE", + "MT_MARIOBUSH1", + "MT_MARIOBUSH2", + "MT_TOAD", + + // NiGHTS Stuff + "MT_AXIS", + "MT_AXISTRANSFER", + "MT_AXISTRANSFERLINE", + "MT_NIGHTSDRONE", + "MT_NIGHTSDRONE_MAN", + "MT_NIGHTSDRONE_SPARKLING", + "MT_NIGHTSDRONE_GOAL", + "MT_NIGHTSPARKLE", + "MT_NIGHTSLOOPHELPER", + "MT_NIGHTSBUMPER", // NiGHTS Bumper + "MT_HOOP", + "MT_HOOPCOLLIDE", // Collision detection for NiGHTS hoops + "MT_HOOPCENTER", // Center of a hoop + "MT_NIGHTSCORE", + "MT_NIGHTSCHIP", // NiGHTS Chip + "MT_FLINGNIGHTSCHIP", // Lost NiGHTS Chip + "MT_NIGHTSSTAR", // NiGHTS Star + "MT_FLINGNIGHTSSTAR", // Lost NiGHTS Star + "MT_NIGHTSSUPERLOOP", + "MT_NIGHTSDRILLREFILL", + "MT_NIGHTSHELPER", + "MT_NIGHTSEXTRATIME", + "MT_NIGHTSLINKFREEZE", + "MT_EGGCAPSULE", + "MT_IDEYAANCHOR", + "MT_NIGHTOPIANHELPER", // the actual helper object that orbits you + "MT_PIAN", // decorative singing friend + "MT_SHLEEP", // almost-decorative sleeping enemy + + // Secret badniks and hazards, shhhh + "MT_PENGUINATOR", + "MT_POPHAT", + "MT_POPSHOT", + "MT_POPSHOT_TRAIL", + + "MT_HIVEELEMENTAL", + "MT_BUMBLEBORE", + + "MT_BUGGLE", + + "MT_SMASHINGSPIKEBALL", + "MT_CACOLANTERN", + "MT_CACOSHARD", + "MT_CACOFIRE", + "MT_SPINBOBERT", + "MT_SPINBOBERT_FIRE1", + "MT_SPINBOBERT_FIRE2", + "MT_HANGSTER", + + // Utility Objects + "MT_TELEPORTMAN", + "MT_ALTVIEWMAN", + "MT_CRUMBLEOBJ", // Sound generator for crumbling platform + "MT_TUBEWAYPOINT", + "MT_PUSH", + "MT_PULL", + "MT_GHOST", + "MT_OVERLAY", + "MT_ANGLEMAN", + "MT_POLYANCHOR", + "MT_POLYSPAWN", + + // Skybox objects + "MT_SKYBOX", + + // Debris + "MT_SPARK", //spark + "MT_EXPLODE", // Robot Explosion + "MT_UWEXPLODE", // Underwater Explosion + "MT_DUST", + "MT_ROCKSPAWNER", + "MT_FALLINGROCK", + "MT_ROCKCRUMBLE1", + "MT_ROCKCRUMBLE2", + "MT_ROCKCRUMBLE3", + "MT_ROCKCRUMBLE4", + "MT_ROCKCRUMBLE5", + "MT_ROCKCRUMBLE6", + "MT_ROCKCRUMBLE7", + "MT_ROCKCRUMBLE8", + "MT_ROCKCRUMBLE9", + "MT_ROCKCRUMBLE10", + "MT_ROCKCRUMBLE11", + "MT_ROCKCRUMBLE12", + "MT_ROCKCRUMBLE13", + "MT_ROCKCRUMBLE14", + "MT_ROCKCRUMBLE15", + "MT_ROCKCRUMBLE16", + + // Level debris + "MT_GFZDEBRIS", + "MT_BRICKDEBRIS", + "MT_WOODDEBRIS", + "MT_REDBRICKDEBRIS", + "MT_BLUEBRICKDEBRIS", + "MT_YELLOWBRICKDEBRIS", + +#ifdef SEENAMES + "MT_NAMECHECK", +#endif +}; + +const char *const MOBJFLAG_LIST[] = { + "SPECIAL", + "SOLID", + "SHOOTABLE", + "NOSECTOR", + "NOBLOCKMAP", + "PAPERCOLLISION", + "PUSHABLE", + "BOSS", + "SPAWNCEILING", + "NOGRAVITY", + "AMBIENT", + "SLIDEME", + "NOCLIP", + "FLOAT", + "BOXICON", + "MISSILE", + "SPRING", + "BOUNCE", + "MONITOR", + "NOTHINK", + "FIRE", + "NOCLIPHEIGHT", + "ENEMY", + "SCENERY", + "PAIN", + "STICKY", + "NIGHTSITEM", + "NOCLIPTHING", + "GRENADEBOUNCE", + "RUNSPAWNFUNC", + NULL +}; + +// \tMF2_(\S+).*// (.+) --> \t"\1", // \2 +const char *const MOBJFLAG2_LIST[] = { + "AXIS", // It's a NiGHTS axis! (For faster checking) + "TWOD", // Moves like it's in a 2D level + "DONTRESPAWN", // Don't respawn this object! + "DONTDRAW", // Don't generate a vissprite + "AUTOMATIC", // Thrown ring has automatic properties + "RAILRING", // Thrown ring has rail properties + "BOUNCERING", // Thrown ring has bounce properties + "EXPLOSION", // Thrown ring has explosive properties + "SCATTER", // Thrown ring has scatter properties + "BEYONDTHEGRAVE", // Source of this missile has died and has since respawned. + "SLIDEPUSH", // MF_PUSHABLE that pushes continuously. + "CLASSICPUSH", // Drops straight down when object has negative momz. + "INVERTAIMABLE", // Flips whether it's targetable by A_LookForEnemies (enemies no, decoys yes) + "INFLOAT", // Floating to a height for a move, don't auto float to target's height. + "DEBRIS", // Splash ring from explosion ring + "NIGHTSPULL", // Attracted from a paraloop + "JUSTATTACKED", // can be pushed by other moving mobjs + "FIRING", // turret fire + "SUPERFIRE", // Firing something with Super Sonic-stopping properties. Or, if mobj has MF_MISSILE, this is the actual fire from it. + "SHADOW", // Fuzzy draw, makes targeting harder. + "STRONGBOX", // Flag used for "strong" random monitors. + "OBJECTFLIP", // Flag for objects that always have flipped gravity. + "SKULLFLY", // Special handling: skull in flight. + "FRET", // Flashing from a previous hit + "BOSSNOTRAP", // No Egg Trap after boss + "BOSSFLEE", // Boss is fleeing! + "BOSSDEAD", // Boss is dead! (Not necessarily fleeing, if a fleeing point doesn't exist.) + "AMBUSH", // Alternate behaviour typically set by MTF_AMBUSH + "LINKDRAW", // Draw vissprite of mobj immediately before/after tracer's vissprite (dependent on dispoffset and position) + "SHIELD", // Thinker calls P_AddShield/P_ShieldLook (must be partnered with MF_SCENERY to use) + NULL +}; + +const char *const MOBJEFLAG_LIST[] = { + "ONGROUND", // The mobj stands on solid floor (not on another mobj or in air) + "JUSTHITFLOOR", // The mobj just hit the floor while falling, this is cleared on next frame + "TOUCHWATER", // The mobj stands in a sector with water, and touches the surface + "UNDERWATER", // The mobj stands in a sector with water, and his waist is BELOW the water surface + "JUSTSTEPPEDDOWN", // used for ramp sectors + "VERTICALFLIP", // Vertically flip sprite/allow upside-down physics + "GOOWATER", // Goo water + "TOUCHLAVA", // The mobj is touching a lava block + "PUSHED", // Mobj was already pushed this tic + "SPRUNG", // Mobj was already sprung this tic + "APPLYPMOMZ", // Platform movement + "TRACERANGLE", // Compute and trigger on mobj angle relative to tracer + NULL +}; + +const char *const MAPTHINGFLAG_LIST[4] = { + "EXTRA", // Extra flag for objects. + "OBJECTFLIP", // Reverse gravity flag for objects. + "OBJECTSPECIAL", // Special flag used with certain objects. + "AMBUSH" // Deaf monsters/do not react to sound. +}; + +const char *const PLAYERFLAG_LIST[] = { + + // Cvars + "FLIPCAM", // Flip camera angle with gravity flip prefrence. + "ANALOGMODE", // Analog mode? + "DIRECTIONCHAR", // Directional character sprites? + "AUTOBRAKE", // Autobrake? + + // Cheats + "GODMODE", + "NOCLIP", + "INVIS", + + // True if button down last tic. + "ATTACKDOWN", + "SPINDOWN", + "JUMPDOWN", + "WPNDOWN", + + // Unmoving states + "STASIS", // Player is not allowed to move + "JUMPSTASIS", // and that includes jumping. + // (we don't include FULLSTASIS here I guess because it's just those two together...?) + + // Applying autobrake? + "APPLYAUTOBRAKE", + + // Character action status + "STARTJUMP", + "JUMPED", + "NOJUMPDAMAGE", + + "SPINNING", + "STARTDASH", + + "THOKKED", + "SHIELDABILITY", + "GLIDING", + "BOUNCING", + + // Sliding (usually in water) like Labyrinth/Oil Ocean + "SLIDING", + + // NiGHTS stuff + "TRANSFERTOCLOSEST", + "DRILLING", + + // Gametype-specific stuff + "GAMETYPEOVER", // Race time over, or H&S out-of-game + "TAGIT", // The player is it! For Tag Mode + + /*** misc ***/ + "FORCESTRAFE", // Translate turn inputs into strafe inputs + "CANCARRY", // Can carry? + "FINISHED", + + NULL // stop loop here. +}; + +const char *const GAMETYPERULE_LIST[] = { + "CAMPAIGN", + "RINGSLINGER", + "SPECTATORS", + "LIVES", + "TEAMS", + "FIRSTPERSON", + "POWERSTONES", + "TEAMFLAGS", + "FRIENDLY", + "SPECIALSTAGES", + "EMERALDTOKENS", + "EMERALDHUNT", + "RACE", + "TAG", + "POINTLIMIT", + "TIMELIMIT", + "OVERTIME", + "HURTMESSAGES", + "FRIENDLYFIRE", + "STARTCOUNTDOWN", + "HIDEFROZEN", + "BLINDFOLDED", + "RESPAWNDELAY", + "PITYSHIELD", + "DEATHPENALTY", + "NOSPECTATORSPAWN", + "DEATHMATCHSTARTS", + "SPAWNINVUL", + "SPAWNENEMIES", + "ALLOWEXIT", + "NOTITLECARD", + "CUTSCENES", + NULL +}; + +// Linedef flags +const char *const ML_LIST[16] = { + "IMPASSIBLE", + "BLOCKMONSTERS", + "TWOSIDED", + "DONTPEGTOP", + "DONTPEGBOTTOM", + "EFFECT1", + "NOCLIMB", + "EFFECT2", + "EFFECT3", + "EFFECT4", + "EFFECT5", + "NOSONIC", + "NOTAILS", + "NOKNUX", + "BOUNCY", + "TFERLINE" +}; + +const char *COLOR_ENUMS[] = { + "NONE", // SKINCOLOR_NONE, + + // Greyscale ranges + "WHITE", // SKINCOLOR_WHITE, + "BONE", // SKINCOLOR_BONE, + "CLOUDY", // SKINCOLOR_CLOUDY, + "GREY", // SKINCOLOR_GREY, + "SILVER", // SKINCOLOR_SILVER, + "CARBON", // SKINCOLOR_CARBON, + "JET", // SKINCOLOR_JET, + "BLACK", // SKINCOLOR_BLACK, + + // Desaturated + "AETHER", // SKINCOLOR_AETHER, + "SLATE", // SKINCOLOR_SLATE, + "BLUEBELL", // SKINCOLOR_BLUEBELL, + "PINK", // SKINCOLOR_PINK, + "YOGURT", // SKINCOLOR_YOGURT, + "BROWN", // SKINCOLOR_BROWN, + "BRONZE", // SKINCOLOR_BRONZE, + "TAN", // SKINCOLOR_TAN, + "BEIGE", // SKINCOLOR_BEIGE, + "MOSS", // SKINCOLOR_MOSS, + "AZURE", // SKINCOLOR_AZURE, + "LAVENDER", // SKINCOLOR_LAVENDER, + + // Viv's vivid colours (toast 21/07/17) + "RUBY", // SKINCOLOR_RUBY, + "SALMON", // SKINCOLOR_SALMON, + "RED", // SKINCOLOR_RED, + "CRIMSON", // SKINCOLOR_CRIMSON, + "FLAME", // SKINCOLOR_FLAME, + "KETCHUP", // SKINCOLOR_KETCHUP, + "PEACHY", // SKINCOLOR_PEACHY, + "QUAIL", // SKINCOLOR_QUAIL, + "SUNSET", // SKINCOLOR_SUNSET, + "COPPER", // SKINCOLOR_COPPER, + "APRICOT", // SKINCOLOR_APRICOT, + "ORANGE", // SKINCOLOR_ORANGE, + "RUST", // SKINCOLOR_RUST, + "GOLD", // SKINCOLOR_GOLD, + "SANDY", // SKINCOLOR_SANDY, + "YELLOW", // SKINCOLOR_YELLOW, + "OLIVE", // SKINCOLOR_OLIVE, + "LIME", // SKINCOLOR_LIME, + "PERIDOT", // SKINCOLOR_PERIDOT, + "APPLE", // SKINCOLOR_APPLE, + "GREEN", // SKINCOLOR_GREEN, + "FOREST", // SKINCOLOR_FOREST, + "EMERALD", // SKINCOLOR_EMERALD, + "MINT", // SKINCOLOR_MINT, + "SEAFOAM", // SKINCOLOR_SEAFOAM, + "AQUA", // SKINCOLOR_AQUA, + "TEAL", // SKINCOLOR_TEAL, + "WAVE", // SKINCOLOR_WAVE, + "CYAN", // SKINCOLOR_CYAN, + "SKY", // SKINCOLOR_SKY, + "CERULEAN", // SKINCOLOR_CERULEAN, + "ICY", // SKINCOLOR_ICY, + "SAPPHIRE", // SKINCOLOR_SAPPHIRE, + "CORNFLOWER", // SKINCOLOR_CORNFLOWER, + "BLUE", // SKINCOLOR_BLUE, + "COBALT", // SKINCOLOR_COBALT, + "VAPOR", // SKINCOLOR_VAPOR, + "DUSK", // SKINCOLOR_DUSK, + "PASTEL", // SKINCOLOR_PASTEL, + "PURPLE", // SKINCOLOR_PURPLE, + "BUBBLEGUM", // SKINCOLOR_BUBBLEGUM, + "MAGENTA", // SKINCOLOR_MAGENTA, + "NEON", // SKINCOLOR_NEON, + "VIOLET", // SKINCOLOR_VIOLET, + "LILAC", // SKINCOLOR_LILAC, + "PLUM", // SKINCOLOR_PLUM, + "RASPBERRY", // SKINCOLOR_RASPBERRY, + "ROSY", // SKINCOLOR_ROSY, + + // Super special awesome Super flashing colors! + "SUPERSILVER1", // SKINCOLOR_SUPERSILVER1 + "SUPERSILVER2", // SKINCOLOR_SUPERSILVER2, + "SUPERSILVER3", // SKINCOLOR_SUPERSILVER3, + "SUPERSILVER4", // SKINCOLOR_SUPERSILVER4, + "SUPERSILVER5", // SKINCOLOR_SUPERSILVER5, + + "SUPERRED1", // SKINCOLOR_SUPERRED1 + "SUPERRED2", // SKINCOLOR_SUPERRED2, + "SUPERRED3", // SKINCOLOR_SUPERRED3, + "SUPERRED4", // SKINCOLOR_SUPERRED4, + "SUPERRED5", // SKINCOLOR_SUPERRED5, + + "SUPERORANGE1", // SKINCOLOR_SUPERORANGE1 + "SUPERORANGE2", // SKINCOLOR_SUPERORANGE2, + "SUPERORANGE3", // SKINCOLOR_SUPERORANGE3, + "SUPERORANGE4", // SKINCOLOR_SUPERORANGE4, + "SUPERORANGE5", // SKINCOLOR_SUPERORANGE5, + + "SUPERGOLD1", // SKINCOLOR_SUPERGOLD1 + "SUPERGOLD2", // SKINCOLOR_SUPERGOLD2, + "SUPERGOLD3", // SKINCOLOR_SUPERGOLD3, + "SUPERGOLD4", // SKINCOLOR_SUPERGOLD4, + "SUPERGOLD5", // SKINCOLOR_SUPERGOLD5, + + "SUPERPERIDOT1", // SKINCOLOR_SUPERPERIDOT1 + "SUPERPERIDOT2", // SKINCOLOR_SUPERPERIDOT2, + "SUPERPERIDOT3", // SKINCOLOR_SUPERPERIDOT3, + "SUPERPERIDOT4", // SKINCOLOR_SUPERPERIDOT4, + "SUPERPERIDOT5", // SKINCOLOR_SUPERPERIDOT5, + + "SUPERSKY1", // SKINCOLOR_SUPERSKY1 + "SUPERSKY2", // SKINCOLOR_SUPERSKY2, + "SUPERSKY3", // SKINCOLOR_SUPERSKY3, + "SUPERSKY4", // SKINCOLOR_SUPERSKY4, + "SUPERSKY5", // SKINCOLOR_SUPERSKY5, + + "SUPERPURPLE1", // SKINCOLOR_SUPERPURPLE1, + "SUPERPURPLE2", // SKINCOLOR_SUPERPURPLE2, + "SUPERPURPLE3", // SKINCOLOR_SUPERPURPLE3, + "SUPERPURPLE4", // SKINCOLOR_SUPERPURPLE4, + "SUPERPURPLE5", // SKINCOLOR_SUPERPURPLE5, + + "SUPERRUST1", // SKINCOLOR_SUPERRUST1 + "SUPERRUST2", // SKINCOLOR_SUPERRUST2, + "SUPERRUST3", // SKINCOLOR_SUPERRUST3, + "SUPERRUST4", // SKINCOLOR_SUPERRUST4, + "SUPERRUST5", // SKINCOLOR_SUPERRUST5, + + "SUPERTAN1", // SKINCOLOR_SUPERTAN1 + "SUPERTAN2", // SKINCOLOR_SUPERTAN2, + "SUPERTAN3", // SKINCOLOR_SUPERTAN3, + "SUPERTAN4", // SKINCOLOR_SUPERTAN4, + "SUPERTAN5" // SKINCOLOR_SUPERTAN5, +}; + +const char *const POWERS_LIST[] = { + "INVULNERABILITY", + "SNEAKERS", + "FLASHING", + "SHIELD", + "CARRY", + "TAILSFLY", // tails flying + "UNDERWATER", // underwater timer + "SPACETIME", // In space, no one can hear you spin! + "EXTRALIFE", // Extra Life timer + "PUSHING", + "JUSTSPRUNG", + "NOAUTOBRAKE", + + "SUPER", // Are you super? + "GRAVITYBOOTS", // gravity boots + + // Weapon ammunition + "INFINITYRING", + "AUTOMATICRING", + "BOUNCERING", + "SCATTERRING", + "GRENADERING", + "EXPLOSIONRING", + "RAILRING", + + // Power Stones + "EMERALDS", // stored like global 'emeralds' variable + + // NiGHTS powerups + "NIGHTS_SUPERLOOP", + "NIGHTS_HELPER", + "NIGHTS_LINKFREEZE", + + //for linedef exec 427 + "NOCONTROL", + + //for dyes + "DYE", + + "JUSTLAUNCHED", + + "IGNORELATCH" +}; + +const char *const HUDITEMS_LIST[] = { + "LIVES", + + "RINGS", + "RINGSNUM", + "RINGSNUMTICS", + + "SCORE", + "SCORENUM", + + "TIME", + "MINUTES", + "TIMECOLON", + "SECONDS", + "TIMETICCOLON", + "TICS", + + "SS_TOTALRINGS", + + "GETRINGS", + "GETRINGSNUM", + "TIMELEFT", + "TIMELEFTNUM", + "TIMEUP", + "HUNTPICS", + "POWERUPS" +}; + +const char *const MENUTYPES_LIST[] = { + "NONE", + + "MAIN", + + // Single Player + "SP_MAIN", + + "SP_LOAD", + "SP_PLAYER", + + "SP_LEVELSELECT", + "SP_LEVELSTATS", + + "SP_TIMEATTACK", + "SP_TIMEATTACK_LEVELSELECT", + "SP_GUESTREPLAY", + "SP_REPLAY", + "SP_GHOST", + + "SP_NIGHTSATTACK", + "SP_NIGHTS_LEVELSELECT", + "SP_NIGHTS_GUESTREPLAY", + "SP_NIGHTS_REPLAY", + "SP_NIGHTS_GHOST", + + // Multiplayer + "MP_MAIN", + "MP_SPLITSCREEN", // SplitServer + "MP_SERVER", + "MP_CONNECT", + "MP_ROOM", + "MP_PLAYERSETUP", // MP_PlayerSetupDef shared with SPLITSCREEN if #defined NONET + "MP_SERVER_OPTIONS", + + // Options + "OP_MAIN", + + "OP_P1CONTROLS", + "OP_CHANGECONTROLS", // OP_ChangeControlsDef shared with P2 + "OP_P1MOUSE", + "OP_P1JOYSTICK", + "OP_JOYSTICKSET", // OP_JoystickSetDef shared with P2 + "OP_P1CAMERA", + + "OP_P2CONTROLS", + "OP_P2MOUSE", + "OP_P2JOYSTICK", + "OP_P2CAMERA", + + "OP_PLAYSTYLE", + + "OP_VIDEO", + "OP_VIDEOMODE", + "OP_COLOR", + "OP_OPENGL", + "OP_OPENGL_LIGHTING", + + "OP_SOUND", + + "OP_SERVER", + "OP_MONITORTOGGLE", + + "OP_DATA", + "OP_ADDONS", + "OP_SCREENSHOTS", + "OP_ERASEDATA", + + // Extras + "SR_MAIN", + "SR_PANDORA", + "SR_LEVELSELECT", + "SR_UNLOCKCHECKLIST", + "SR_EMBLEMHINT", + "SR_PLAYER", + "SR_SOUNDTEST", + + // Addons (Part of MISC, but let's make it our own) + "AD_MAIN", + + // MISC + // "MESSAGE", + // "SPAUSE", + + // "MPAUSE", + // "SCRAMBLETEAM", + // "CHANGETEAM", + // "CHANGELEVEL", + + // "MAPAUSE", + // "HELP", + + "SPECIAL" +}; + +struct int_const_s const INT_CONST[] = { + // If a mod removes some variables here, + // please leave the names in-tact and just set + // the value to 0 or something. + + // integer type limits, from doomtype.h + // INT64 and UINT64 limits not included, they're too big for most purposes anyway + // signed + {"INT8_MIN",INT8_MIN}, + {"INT16_MIN",INT16_MIN}, + {"INT32_MIN",INT32_MIN}, + {"INT8_MAX",INT8_MAX}, + {"INT16_MAX",INT16_MAX}, + {"INT32_MAX",INT32_MAX}, + // unsigned + {"UINT8_MAX",UINT8_MAX}, + {"UINT16_MAX",UINT16_MAX}, + {"UINT32_MAX",UINT32_MAX}, + + // fixed_t constants, from m_fixed.h + {"FRACUNIT",FRACUNIT}, + {"FRACBITS",FRACBITS}, + + // doomdef.h constants + {"TICRATE",TICRATE}, + {"MUSICRATE",MUSICRATE}, + {"RING_DIST",RING_DIST}, + {"PUSHACCEL",PUSHACCEL}, + {"MODID",MODID}, // I don't know, I just thought it would be cool for a wad to potentially know what mod it was loaded into. + {"MODVERSION",MODVERSION}, // or what version of the mod this is. + {"CODEBASE",CODEBASE}, // or what release of SRB2 this is. + {"NEWTICRATE",NEWTICRATE}, // TICRATE*NEWTICRATERATIO + {"NEWTICRATERATIO",NEWTICRATERATIO}, + + // Special linedef executor tag numbers! + {"LE_PINCHPHASE",LE_PINCHPHASE}, // A boss entered pinch phase (and, in most cases, is preparing their pinch phase attack!) + {"LE_ALLBOSSESDEAD",LE_ALLBOSSESDEAD}, // All bosses in the map are dead (Egg capsule raise) + {"LE_BOSSDEAD",LE_BOSSDEAD}, // A boss in the map died (Chaos mode boss tally) + {"LE_BOSS4DROP",LE_BOSS4DROP}, // CEZ boss dropped its cage + {"LE_BRAKVILEATACK",LE_BRAKVILEATACK}, // Brak's doing his LOS attack, oh noes + {"LE_TURRET",LE_TURRET}, // THZ turret + {"LE_BRAKPLATFORM",LE_BRAKPLATFORM}, // v2.0 Black Eggman destroys platform + {"LE_CAPSULE2",LE_CAPSULE2}, // Egg Capsule + {"LE_CAPSULE1",LE_CAPSULE1}, // Egg Capsule + {"LE_CAPSULE0",LE_CAPSULE0}, // Egg Capsule + {"LE_KOOPA",LE_KOOPA}, // Distant cousin to Gay Bowser + {"LE_AXE",LE_AXE}, // MKB Axe object + {"LE_PARAMWIDTH",LE_PARAMWIDTH}, // If an object that calls LinedefExecute has a nonzero parameter value, this times the parameter will be subtracted. (Mostly for the purpose of coexisting bosses...) + + /// \todo Get all this stuff into its own sections, maybe. Maybe. + + // Frame settings + {"FF_FRAMEMASK",FF_FRAMEMASK}, + {"FF_SPR2SUPER",FF_SPR2SUPER}, + {"FF_SPR2ENDSTATE",FF_SPR2ENDSTATE}, + {"FF_SPR2MIDSTART",FF_SPR2MIDSTART}, + {"FF_ANIMATE",FF_ANIMATE}, + {"FF_RANDOMANIM",FF_RANDOMANIM}, + {"FF_GLOBALANIM",FF_GLOBALANIM}, + {"FF_FULLBRIGHT",FF_FULLBRIGHT}, + {"FF_VERTICALFLIP",FF_VERTICALFLIP}, + {"FF_HORIZONTALFLIP",FF_HORIZONTALFLIP}, + {"FF_PAPERSPRITE",FF_PAPERSPRITE}, + {"FF_TRANSMASK",FF_TRANSMASK}, + {"FF_TRANSSHIFT",FF_TRANSSHIFT}, + // new preshifted translucency (used in source) + {"FF_TRANS10",FF_TRANS10}, + {"FF_TRANS20",FF_TRANS20}, + {"FF_TRANS30",FF_TRANS30}, + {"FF_TRANS40",FF_TRANS40}, + {"FF_TRANS50",FF_TRANS50}, + {"FF_TRANS60",FF_TRANS60}, + {"FF_TRANS70",FF_TRANS70}, + {"FF_TRANS80",FF_TRANS80}, + {"FF_TRANS90",FF_TRANS90}, + // compatibility + // Transparency for SOCs is pre-shifted + {"TR_TRANS10",tr_trans10<gotflag! + // Used to be MF_ for some stupid reason, now they're GF_ to stop them looking like mobjflags + {"GF_REDFLAG",GF_REDFLAG}, + {"GF_BLUEFLAG",GF_BLUEFLAG}, + + // Customisable sounds for Skins, from sounds.h + {"SKSSPIN",SKSSPIN}, + {"SKSPUTPUT",SKSPUTPUT}, + {"SKSPUDPUD",SKSPUDPUD}, + {"SKSPLPAN1",SKSPLPAN1}, // Ouchies + {"SKSPLPAN2",SKSPLPAN2}, + {"SKSPLPAN3",SKSPLPAN3}, + {"SKSPLPAN4",SKSPLPAN4}, + {"SKSPLDET1",SKSPLDET1}, // Deaths + {"SKSPLDET2",SKSPLDET2}, + {"SKSPLDET3",SKSPLDET3}, + {"SKSPLDET4",SKSPLDET4}, + {"SKSPLVCT1",SKSPLVCT1}, // Victories + {"SKSPLVCT2",SKSPLVCT2}, + {"SKSPLVCT3",SKSPLVCT3}, + {"SKSPLVCT4",SKSPLVCT4}, + {"SKSTHOK",SKSTHOK}, + {"SKSSPNDSH",SKSSPNDSH}, + {"SKSZOOM",SKSZOOM}, + {"SKSSKID",SKSSKID}, + {"SKSGASP",SKSGASP}, + {"SKSJUMP",SKSJUMP}, + + // 3D Floor/Fake Floor/FOF/whatever flags + {"FF_EXISTS",FF_EXISTS}, ///< Always set, to check for validity. + {"FF_BLOCKPLAYER",FF_BLOCKPLAYER}, ///< Solid to player, but nothing else + {"FF_BLOCKOTHERS",FF_BLOCKOTHERS}, ///< Solid to everything but player + {"FF_SOLID",FF_SOLID}, ///< Clips things. + {"FF_RENDERSIDES",FF_RENDERSIDES}, ///< Renders the sides. + {"FF_RENDERPLANES",FF_RENDERPLANES}, ///< Renders the floor/ceiling. + {"FF_RENDERALL",FF_RENDERALL}, ///< Renders everything. + {"FF_SWIMMABLE",FF_SWIMMABLE}, ///< Is a water block. + {"FF_NOSHADE",FF_NOSHADE}, ///< Messes with the lighting? + {"FF_CUTSOLIDS",FF_CUTSOLIDS}, ///< Cuts out hidden solid pixels. + {"FF_CUTEXTRA",FF_CUTEXTRA}, ///< Cuts out hidden translucent pixels. + {"FF_CUTLEVEL",FF_CUTLEVEL}, ///< Cuts out all hidden pixels. + {"FF_CUTSPRITES",FF_CUTSPRITES}, ///< Final step in making 3D water. + {"FF_BOTHPLANES",FF_BOTHPLANES}, ///< Render inside and outside planes. + {"FF_EXTRA",FF_EXTRA}, ///< Gets cut by ::FF_CUTEXTRA. + {"FF_TRANSLUCENT",FF_TRANSLUCENT}, ///< See through! + {"FF_FOG",FF_FOG}, ///< Fog "brush." + {"FF_INVERTPLANES",FF_INVERTPLANES}, ///< Only render inside planes. + {"FF_ALLSIDES",FF_ALLSIDES}, ///< Render inside and outside sides. + {"FF_INVERTSIDES",FF_INVERTSIDES}, ///< Only render inside sides. + {"FF_DOUBLESHADOW",FF_DOUBLESHADOW}, ///< Make two lightlist entries to reset light? + {"FF_FLOATBOB",FF_FLOATBOB}, ///< Floats on water and bobs if you step on it. + {"FF_NORETURN",FF_NORETURN}, ///< Used with ::FF_CRUMBLE. Will not return to its original position after falling. + {"FF_CRUMBLE",FF_CRUMBLE}, ///< Falls 2 seconds after being stepped on, and randomly brings all touching crumbling 3dfloors down with it, providing their master sectors share the same tag (allows crumble platforms above or below, to also exist). + {"FF_SHATTERBOTTOM",FF_SHATTERBOTTOM}, ///< Used with ::FF_BUSTUP. Like FF_SHATTER, but only breaks from the bottom. Good for springing up through rubble. + {"FF_MARIO",FF_MARIO}, ///< Acts like a question block when hit from underneath. Goodie spawned at top is determined by master sector. + {"FF_BUSTUP",FF_BUSTUP}, ///< You can spin through/punch this block and it will crumble! + {"FF_QUICKSAND",FF_QUICKSAND}, ///< Quicksand! + {"FF_PLATFORM",FF_PLATFORM}, ///< You can jump up through this to the top. + {"FF_REVERSEPLATFORM",FF_REVERSEPLATFORM}, ///< A fall-through floor in normal gravity, a platform in reverse gravity. + {"FF_INTANGIBLEFLATS",FF_INTANGIBLEFLATS}, ///< Both flats are intangible, but the sides are still solid. + {"FF_INTANGABLEFLATS",FF_INTANGIBLEFLATS}, ///< Both flats are intangable, but the sides are still solid. + {"FF_SHATTER",FF_SHATTER}, ///< Used with ::FF_BUSTUP. Bustable on mere touch. + {"FF_SPINBUST",FF_SPINBUST}, ///< Used with ::FF_BUSTUP. Also bustable if you're in your spinning frames. + {"FF_STRONGBUST",FF_STRONGBUST}, ///< Used with ::FF_BUSTUP. Only bustable by "strong" characters (Knuckles) and abilities (bouncing, twinspin, melee). + {"FF_RIPPLE",FF_RIPPLE}, ///< Ripple the flats + {"FF_COLORMAPONLY",FF_COLORMAPONLY}, ///< Only copy the colormap, not the lightlevel + {"FF_GOOWATER",FF_GOOWATER}, ///< Used with ::FF_SWIMMABLE. Makes thick bouncey goop. + + // PolyObject flags + {"POF_CLIPLINES",POF_CLIPLINES}, ///< Test against lines for collision + {"POF_CLIPPLANES",POF_CLIPPLANES}, ///< Test against tops and bottoms for collision + {"POF_SOLID",POF_SOLID}, ///< Clips things. + {"POF_TESTHEIGHT",POF_TESTHEIGHT}, ///< Test line collision with heights + {"POF_RENDERSIDES",POF_RENDERSIDES}, ///< Renders the sides. + {"POF_RENDERTOP",POF_RENDERTOP}, ///< Renders the top. + {"POF_RENDERBOTTOM",POF_RENDERBOTTOM}, ///< Renders the bottom. + {"POF_RENDERPLANES",POF_RENDERPLANES}, ///< Renders top and bottom. + {"POF_RENDERALL",POF_RENDERALL}, ///< Renders everything. + {"POF_INVERT",POF_INVERT}, ///< Inverts collision (like a cage). + {"POF_INVERTPLANES",POF_INVERTPLANES}, ///< Render inside planes. + {"POF_INVERTPLANESONLY",POF_INVERTPLANESONLY}, ///< Only render inside planes. + {"POF_PUSHABLESTOP",POF_PUSHABLESTOP}, ///< Pushables will stop movement. + {"POF_LDEXEC",POF_LDEXEC}, ///< This PO triggers a linedef executor. + {"POF_ONESIDE",POF_ONESIDE}, ///< Only use the first side of the linedef. + {"POF_NOSPECIALS",POF_NOSPECIALS}, ///< Don't apply sector specials. + {"POF_SPLAT",POF_SPLAT}, ///< Use splat flat renderer (treat cyan pixels as invisible). + +#ifdef HAVE_LUA_SEGS + // Node flags + {"NF_SUBSECTOR",NF_SUBSECTOR}, // Indicate a leaf. +#endif + + // Slope flags + {"SL_NOPHYSICS",SL_NOPHYSICS}, + {"SL_DYNAMIC",SL_DYNAMIC}, + + // Angles + {"ANG1",ANG1}, + {"ANG2",ANG2}, + {"ANG10",ANG10}, + {"ANG15",ANG15}, + {"ANG20",ANG20}, + {"ANG30",ANG30}, + {"ANG60",ANG60}, + {"ANG64h",ANG64h}, + {"ANG105",ANG105}, + {"ANG210",ANG210}, + {"ANG255",ANG255}, + {"ANG340",ANG340}, + {"ANG350",ANG350}, + {"ANGLE_11hh",ANGLE_11hh}, + {"ANGLE_22h",ANGLE_22h}, + {"ANGLE_45",ANGLE_45}, + {"ANGLE_67h",ANGLE_67h}, + {"ANGLE_90",ANGLE_90}, + {"ANGLE_112h",ANGLE_112h}, + {"ANGLE_135",ANGLE_135}, + {"ANGLE_157h",ANGLE_157h}, + {"ANGLE_180",ANGLE_180}, + {"ANGLE_202h",ANGLE_202h}, + {"ANGLE_225",ANGLE_225}, + {"ANGLE_247h",ANGLE_247h}, + {"ANGLE_270",ANGLE_270}, + {"ANGLE_292h",ANGLE_292h}, + {"ANGLE_315",ANGLE_315}, + {"ANGLE_337h",ANGLE_337h}, + {"ANGLE_MAX",ANGLE_MAX}, + + // P_Chase directions (dirtype_t) + {"DI_NODIR",DI_NODIR}, + {"DI_EAST",DI_EAST}, + {"DI_NORTHEAST",DI_NORTHEAST}, + {"DI_NORTH",DI_NORTH}, + {"DI_NORTHWEST",DI_NORTHWEST}, + {"DI_WEST",DI_WEST}, + {"DI_SOUTHWEST",DI_SOUTHWEST}, + {"DI_SOUTH",DI_SOUTH}, + {"DI_SOUTHEAST",DI_SOUTHEAST}, + {"NUMDIRS",NUMDIRS}, + + // Sprite rotation axis (rotaxis_t) + {"ROTAXIS_X",ROTAXIS_X}, + {"ROTAXIS_Y",ROTAXIS_Y}, + {"ROTAXIS_Z",ROTAXIS_Z}, + + // Buttons (ticcmd_t) + {"BT_WEAPONMASK",BT_WEAPONMASK}, //our first four bits. + {"BT_WEAPONNEXT",BT_WEAPONNEXT}, + {"BT_WEAPONPREV",BT_WEAPONPREV}, + {"BT_ATTACK",BT_ATTACK}, // shoot rings + {"BT_SPIN",BT_SPIN}, + {"BT_CAMLEFT",BT_CAMLEFT}, // turn camera left + {"BT_CAMRIGHT",BT_CAMRIGHT}, // turn camera right + {"BT_TOSSFLAG",BT_TOSSFLAG}, + {"BT_JUMP",BT_JUMP}, + {"BT_FIRENORMAL",BT_FIRENORMAL}, // Fire a normal ring no matter what + {"BT_CUSTOM1",BT_CUSTOM1}, // Lua customizable + {"BT_CUSTOM2",BT_CUSTOM2}, // Lua customizable + {"BT_CUSTOM3",BT_CUSTOM3}, // Lua customizable + + // Lua command registration flags + {"COM_ADMIN",COM_ADMIN}, + {"COM_SPLITSCREEN",COM_SPLITSCREEN}, + {"COM_LOCAL",COM_LOCAL}, + + // cvflags_t + {"CV_SAVE",CV_SAVE}, + {"CV_CALL",CV_CALL}, + {"CV_NETVAR",CV_NETVAR}, + {"CV_NOINIT",CV_NOINIT}, + {"CV_FLOAT",CV_FLOAT}, + {"CV_NOTINNET",CV_NOTINNET}, + {"CV_MODIFIED",CV_MODIFIED}, + {"CV_SHOWMODIF",CV_SHOWMODIF}, + {"CV_SHOWMODIFONETIME",CV_SHOWMODIFONETIME}, + {"CV_NOSHOWHELP",CV_NOSHOWHELP}, + {"CV_HIDEN",CV_HIDEN}, + {"CV_HIDDEN",CV_HIDEN}, + {"CV_CHEAT",CV_CHEAT}, + {"CV_NOLUA",CV_NOLUA}, + + // v_video flags + {"V_NOSCALEPATCH",V_NOSCALEPATCH}, + {"V_SMALLSCALEPATCH",V_SMALLSCALEPATCH}, + {"V_MEDSCALEPATCH",V_MEDSCALEPATCH}, + {"V_6WIDTHSPACE",V_6WIDTHSPACE}, + {"V_OLDSPACING",V_OLDSPACING}, + {"V_MONOSPACE",V_MONOSPACE}, + + {"V_MAGENTAMAP",V_MAGENTAMAP}, + {"V_YELLOWMAP",V_YELLOWMAP}, + {"V_GREENMAP",V_GREENMAP}, + {"V_BLUEMAP",V_BLUEMAP}, + {"V_REDMAP",V_REDMAP}, + {"V_GRAYMAP",V_GRAYMAP}, + {"V_ORANGEMAP",V_ORANGEMAP}, + {"V_SKYMAP",V_SKYMAP}, + {"V_PURPLEMAP",V_PURPLEMAP}, + {"V_AQUAMAP",V_AQUAMAP}, + {"V_PERIDOTMAP",V_PERIDOTMAP}, + {"V_AZUREMAP",V_AZUREMAP}, + {"V_BROWNMAP",V_BROWNMAP}, + {"V_ROSYMAP",V_ROSYMAP}, + {"V_INVERTMAP",V_INVERTMAP}, + + {"V_TRANSLUCENT",V_TRANSLUCENT}, + {"V_10TRANS",V_10TRANS}, + {"V_20TRANS",V_20TRANS}, + {"V_30TRANS",V_30TRANS}, + {"V_40TRANS",V_40TRANS}, + {"V_50TRANS",V_TRANSLUCENT}, // alias + {"V_60TRANS",V_60TRANS}, + {"V_70TRANS",V_70TRANS}, + {"V_80TRANS",V_80TRANS}, + {"V_90TRANS",V_90TRANS}, + {"V_HUDTRANSHALF",V_HUDTRANSHALF}, + {"V_HUDTRANS",V_HUDTRANS}, + {"V_HUDTRANSDOUBLE",V_HUDTRANSDOUBLE}, + {"V_AUTOFADEOUT",V_AUTOFADEOUT}, + {"V_RETURN8",V_RETURN8}, + {"V_OFFSET",V_OFFSET}, + {"V_ALLOWLOWERCASE",V_ALLOWLOWERCASE}, + {"V_FLIP",V_FLIP}, + {"V_CENTERNAMETAG",V_CENTERNAMETAG}, + {"V_SNAPTOTOP",V_SNAPTOTOP}, + {"V_SNAPTOBOTTOM",V_SNAPTOBOTTOM}, + {"V_SNAPTOLEFT",V_SNAPTOLEFT}, + {"V_SNAPTORIGHT",V_SNAPTORIGHT}, + {"V_WRAPX",V_WRAPX}, + {"V_WRAPY",V_WRAPY}, + {"V_NOSCALESTART",V_NOSCALESTART}, + {"V_PERPLAYER",V_PERPLAYER}, + + {"V_PARAMMASK",V_PARAMMASK}, + {"V_SCALEPATCHMASK",V_SCALEPATCHMASK}, + {"V_SPACINGMASK",V_SPACINGMASK}, + {"V_CHARCOLORMASK",V_CHARCOLORMASK}, + {"V_ALPHAMASK",V_ALPHAMASK}, + + {"V_CHARCOLORSHIFT",V_CHARCOLORSHIFT}, + {"V_ALPHASHIFT",V_ALPHASHIFT}, + + //Kick Reasons + {"KR_KICK",KR_KICK}, + {"KR_PINGLIMIT",KR_PINGLIMIT}, + {"KR_SYNCH",KR_SYNCH}, + {"KR_TIMEOUT",KR_TIMEOUT}, + {"KR_BAN",KR_BAN}, + {"KR_LEAVE",KR_LEAVE}, + + // translation colormaps + {"TC_DEFAULT",TC_DEFAULT}, + {"TC_BOSS",TC_BOSS}, + {"TC_METALSONIC",TC_METALSONIC}, + {"TC_ALLWHITE",TC_ALLWHITE}, + {"TC_RAINBOW",TC_RAINBOW}, + {"TC_BLINK",TC_BLINK}, + {"TC_DASHMODE",TC_DASHMODE}, + + // marathonmode flags + {"MA_INIT",MA_INIT}, + {"MA_RUNNING",MA_RUNNING}, + {"MA_NOCUTSCENES",MA_NOCUTSCENES}, + {"MA_INGAME",MA_INGAME}, + + // music types + {"MU_NONE", MU_NONE}, + {"MU_WAV", MU_WAV}, + {"MU_MOD", MU_MOD}, + {"MU_MID", MU_MID}, + {"MU_OGG", MU_OGG}, + {"MU_MP3", MU_MP3}, + {"MU_FLAC", MU_FLAC}, + {"MU_GME", MU_GME}, + {"MU_MOD_EX", MU_MOD_EX}, + {"MU_MID_EX", MU_MID_EX}, + + // gamestates + {"GS_NULL",GS_NULL}, + {"GS_LEVEL",GS_LEVEL}, + {"GS_INTERMISSION",GS_INTERMISSION}, + {"GS_CONTINUING",GS_CONTINUING}, + {"GS_TITLESCREEN",GS_TITLESCREEN}, + {"GS_TIMEATTACK",GS_TIMEATTACK}, + {"GS_CREDITS",GS_CREDITS}, + {"GS_EVALUATION",GS_EVALUATION}, + {"GS_GAMEEND",GS_GAMEEND}, + {"GS_INTRO",GS_INTRO}, + {"GS_ENDING",GS_ENDING}, + {"GS_CUTSCENE",GS_CUTSCENE}, + {"GS_DEDICATEDSERVER",GS_DEDICATEDSERVER}, + {"GS_WAITINGPLAYERS",GS_WAITINGPLAYERS}, + + {NULL,0} +}; diff --git a/src/deh_tables.h b/src/deh_tables.h new file mode 100644 index 000000000..3e1f3d933 --- /dev/null +++ b/src/deh_tables.h @@ -0,0 +1,73 @@ +// SONIC ROBO BLAST 2 +//----------------------------------------------------------------------------- +// Copyright (C) 2020 by Golden. +// +// This program is free software distributed under the +// terms of the GNU General Public License, version 2. +// See the 'LICENSE' file for more details. +//----------------------------------------------------------------------------- +/// \file deh_tables.h +/// \brief Define DeHackEd tables. + +#ifndef __DEH_TABLES_H__ +#define __DEH_TABLES_H__ + +#include "doomdef.h" // Constants +#include "d_think.h" // actionf_t +#include "info.h" // Mobj, state, sprite, etc constants + +// Free slot names +// The crazy word-reading stuff uses these. +char *FREE_STATES[NUMSTATEFREESLOTS]; +char *FREE_MOBJS[NUMMOBJFREESLOTS]; +char *FREE_SKINCOLORS[NUMCOLORFREESLOTS]; +UINT8 used_spr[(NUMSPRITEFREESLOTS / 8) + 1]; // Bitwise flag for sprite freeslot in use! I would use ceil() here if I could, but it only saves 1 byte of memory anyway. + +#define initfreeslots() {\ + memset(FREE_STATES,0,sizeof(char *) * NUMSTATEFREESLOTS);\ + memset(FREE_MOBJS,0,sizeof(char *) * NUMMOBJFREESLOTS);\ + memset(FREE_SKINCOLORS,0,sizeof(char *) * NUMCOLORFREESLOTS);\ + memset(used_spr,0,sizeof(UINT8) * ((NUMSPRITEFREESLOTS / 8) + 1));\ +} + +struct flickytypes_s { + const char *name; + const mobjtype_t type; +}; + +#define MAXFLICKIES 64 + +/** Action pointer for reading actions from Dehacked lumps. + */ +typedef struct +{ + actionf_t action; ///< Function pointer corresponding to the actual action. + const char *name; ///< Name of the action in ALL CAPS. +} actionpointer_t; + +struct int_const_s { + const char *n; + // has to be able to hold both fixed_t and angle_t, so drastic measure!! + lua_Integer v; +}; + +extern const char NIGHTSGRADE_LIST[]; +extern struct flickytypes_s FLICKYTYPES[]; +extern actionpointer_t actionpointers[]; // Array mapping action names to action functions. +extern const char *const STATE_LIST[]; +extern const char *const MOBJTYPE_LIST[]; +extern const char *const MOBJFLAG_LIST[]; +extern const char *const MOBJFLAG2_LIST[]; // \tMF2_(\S+).*// (.+) --> \t"\1", // \2 +extern const char *const MOBJEFLAG_LIST[]; +extern const char *const MAPTHINGFLAG_LIST[4]; +extern const char *const PLAYERFLAG_LIST[]; +extern const char *const GAMETYPERULE_LIST[]; +extern const char *const ML_LIST[16]; // Linedef flags +extern const char *COLOR_ENUMS[]; +extern const char *const POWERS_LIST[]; +extern const char *const HUDITEMS_LIST[]; +extern const char *const MENUTYPES_LIST[]; + +extern struct int_const_s const INT_CONST[]; + +#endif diff --git a/src/dehacked.c b/src/dehacked.c index eb8951569..e98ff71cf 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -11,80 +11,45 @@ /// \brief Load dehacked file and change tables and text #include "doomdef.h" -#include "d_main.h" // for srb2home -#include "g_game.h" -#include "sounds.h" -#include "info.h" -#include "d_think.h" -#include "m_argv.h" -#include "z_zone.h" -#include "w_wad.h" -#include "m_menu.h" -#include "m_misc.h" -#include "f_finale.h" -#include "y_inter.h" -#include "dehacked.h" -#include "st_stuff.h" -#include "i_system.h" -#include "i_sound.h" // musictype_t (for lua) -#include "p_local.h" // for var1 and var2, and some constants -#include "p_setup.h" -#include "r_data.h" -#include "r_textures.h" -#include "r_draw.h" -#include "r_patch.h" -#include "r_picformats.h" -#include "r_things.h" // R_Char2Frame -#include "r_sky.h" -#include "fastcmp.h" -#include "lua_script.h" -#include "lua_hook.h" -#include "d_clisrv.h" -#include "g_state.h" // gamestate_t (for lua) - #include "m_cond.h" - -#include "v_video.h" // video flags (for lua) - -#ifdef HWRENDER -#include "hardware/hw_light.h" -#endif - -// Free slot names -// The crazy word-reading stuff uses these. -static char *FREE_STATES[NUMSTATEFREESLOTS]; -static char *FREE_MOBJS[NUMMOBJFREESLOTS]; -static char *FREE_SKINCOLORS[NUMCOLORFREESLOTS]; -static UINT8 used_spr[(NUMSPRITEFREESLOTS / 8) + 1]; // Bitwise flag for sprite freeslot in use! I would use ceil() here if I could, but it only saves 1 byte of memory anyway. -#define initfreeslots() {\ -memset(FREE_STATES,0,sizeof(char *) * NUMSTATEFREESLOTS);\ -memset(FREE_MOBJS,0,sizeof(char *) * NUMMOBJFREESLOTS);\ -memset(FREE_SKINCOLORS,0,sizeof(char *) * NUMCOLORFREESLOTS);\ -memset(used_spr,0,sizeof(UINT8) * ((NUMSPRITEFREESLOTS / 8) + 1));\ -} - -// Crazy word-reading stuff -/// \todo Put these in a seperate file or something. -static mobjtype_t get_mobjtype(const char *word); -static statenum_t get_state(const char *word); -static spritenum_t get_sprite(const char *word); -static playersprite_t get_sprite2(const char *word); -static sfxenum_t get_sfx(const char *word); -#ifdef MUSICSLOT_COMPATIBILITY -static UINT16 get_mus(const char *word, UINT8 dehacked_mode); -#endif -static hudnum_t get_huditem(const char *word); -static menutype_t get_menutype(const char *word); -//static INT16 get_gametype(const char *word); -//static powertype_t get_power(const char *word); -skincolornum_t get_skincolor(const char *word); +#include "deh_soc.h" +#include "deh_tables.h" boolean deh_loaded = false; -static int dbg_line; -static boolean gamedataadded = false; -static boolean titlechanged = false; -static boolean introchanged = false; +boolean gamedataadded = false; +boolean titlechanged = false; +boolean introchanged = false; + +static int dbg_line; +static INT32 deh_num_warning = 0; + +FUNCPRINTF void deh_warning(const char *first, ...) +{ + va_list argptr; + char *buf = Z_Malloc(1000, PU_STATIC, NULL); + + va_start(argptr, 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. + CONS_Alert(CONS_WARNING, "%s\n", buf); + else + CONS_Alert(CONS_WARNING, "Line %u: %s\n", dbg_line, buf); + + deh_num_warning++; + + Z_Free(buf); +} + +void deh_strlcpy(char *dst, const char *src, size_t size, const char *warntext) +{ + size_t len = strlen(src)+1; // Used to determine if truncation has been done + if (len > size) + deh_warning("%s exceeds max length of %s", warntext, sizeu1(size-1)); + strlcpy(dst, src, size); +} ATTRINLINE static FUNCINLINE char myfget_color(MYFILE *f) { @@ -150,7 +115,7 @@ char *myfgets(char *buf, size_t bufsize, MYFILE *f) return buf; } -static char *myhashfgets(char *buf, size_t bufsize, MYFILE *f) +char *myhashfgets(char *buf, size_t bufsize, MYFILE *f) { size_t i = 0; if (myfeof(f)) @@ -182,4375 +147,6 @@ static char *myhashfgets(char *buf, size_t bufsize, MYFILE *f) return buf; } -static INT32 deh_num_warning = 0; - -FUNCPRINTF static void deh_warning(const char *first, ...) -{ - va_list argptr; - char *buf = Z_Malloc(1000, PU_STATIC, NULL); - - va_start(argptr, 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. - CONS_Alert(CONS_WARNING, "%s\n", buf); - else - CONS_Alert(CONS_WARNING, "Line %u: %s\n", dbg_line, buf); - - deh_num_warning++; - - Z_Free(buf); -} - -static void deh_strlcpy(char *dst, const char *src, size_t size, const char *warntext) -{ - size_t len = strlen(src)+1; // Used to determine if truncation has been done - if (len > size) - deh_warning("%s exceeds max length of %s", warntext, sizeu1(size-1)); - strlcpy(dst, src, size); -} - -/* ======================================================================== */ -// Load a dehacked file format -/* ======================================================================== */ -/* a sample to see - Thing 1 (Player) { // MT_PLAYER -INT32 doomednum; ID # = 3232 -1, // doomednum -INT32 spawnstate; Initial frame = 32 "PLAY", // spawnstate -INT32 spawnhealth; Hit points = 3232 100, // spawnhealth -INT32 seestate; First moving frame = 32 "PLAY_RUN1", // seestate -INT32 seesound; Alert sound = 32 sfx_None, // seesound -INT32 reactiontime; Reaction time = 3232 0, // reactiontime -INT32 attacksound; Attack sound = 32 sfx_None, // attacksound -INT32 painstate; Injury frame = 32 "PLAY_PAIN", // painstate -INT32 painchance; Pain chance = 3232 255, // painchance -INT32 painsound; Pain sound = 32 sfx_plpain, // painsound -INT32 meleestate; Close attack frame = 32 "NULL", // meleestate -INT32 missilestate; Far attack frame = 32 "PLAY_ATK1", // missilestate -INT32 deathstate; Death frame = 32 "PLAY_DIE1", // deathstate -INT32 xdeathstate; Exploding frame = 32 "PLAY_XDIE1", // xdeathstate -INT32 deathsound; Death sound = 32 sfx_pldeth, // deathsound -INT32 speed; Speed = 3232 0, // speed -INT32 radius; Width = 211812352 16*FRACUNIT, // radius -INT32 height; Height = 211812352 56*FRACUNIT, // height -INT32 dispoffset; DispOffset = 0 0, // dispoffset -INT32 mass; Mass = 3232 100, // mass -INT32 damage; Missile damage = 3232 0, // damage -INT32 activesound; Action sound = 32 sfx_None, // activesound -INT32 flags; Bits = 3232 MF_SOLID|MF_SHOOTABLE|MF_DROPOFF|MF_PICKUP|MF_NOTDMATCH, -INT32 raisestate; Respawn frame = 32 S_NULL // raisestate - }, */ - -#ifdef HWRENDER -static INT32 searchvalue(const char *s) -{ - while (s[0] != '=' && s[0]) - s++; - if (s[0] == '=') - return atoi(&s[1]); - else - { - deh_warning("No value found"); - return 0; - } -} - -static float searchfvalue(const char *s) -{ - while (s[0] != '=' && s[0]) - s++; - if (s[0] == '=') - return (float)atof(&s[1]); - else - { - deh_warning("No value found"); - return 0; - } -} -#endif - -// These are for clearing all of various things -static void clear_conditionsets(void) -{ - UINT8 i; - for (i = 0; i < MAXCONDITIONSETS; ++i) - M_ClearConditionSet(i+1); -} - -static void clear_levels(void) -{ - INT16 i; - - // This is potentially dangerous but if we're resetting these headers, - // we may as well try to save some memory, right? - for (i = 0; i < NUMMAPS; ++i) - { - if (!mapheaderinfo[i] || i == (tutorialmap-1)) - continue; - - // Custom map header info - // (no need to set num to 0, we're freeing the entire header shortly) - Z_Free(mapheaderinfo[i]->customopts); - - P_DeleteFlickies(i); - P_DeleteGrades(i); - - Z_Free(mapheaderinfo[i]); - mapheaderinfo[i] = NULL; - } - - // Realloc the one for the current gamemap as a safeguard - P_AllocMapHeader(gamemap-1); -} - -static boolean findFreeSlot(INT32 *num) -{ - // Send the character select entry to a free slot. - while (*num < MAXSKINS && (description[*num].used)) - *num = *num+1; - - // No more free slots. :( - if (*num >= MAXSKINS) - return false; - - // Redesign your logo. (See M_DrawSetupChoosePlayerMenu in m_menu.c...) - description[*num].picname[0] = '\0'; - description[*num].nametag[0] = '\0'; - description[*num].displayname[0] = '\0'; - description[*num].oppositecolor = SKINCOLOR_NONE; - description[*num].tagtextcolor = SKINCOLOR_NONE; - description[*num].tagoutlinecolor = SKINCOLOR_NONE; - - // Found one! ^_^ - return (description[*num].used = 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; - char *displayname = ZZ_Alloc(MAXLINELEN+1); - INT32 i; - boolean slotfound = false; - - #define SLOTFOUND \ - if (!slotfound && (slotfound = findFreeSlot(&num)) == false) \ - goto done; - - displayname[MAXLINELEN] = '\0'; - - do - { - if (myfgets(s, MAXLINELEN, f)) - { - if (s[0] == '\n') - break; - - for (i = 0; i < MAXLINELEN-3; i++) - { - char *tmp; - if (s[i] == '=') - { - tmp = &s[i+2]; - strncpy(displayname, tmp, SKINNAMESIZE); - break; - } - } - - word = strtok(s, " "); - if (word) - strupr(word); - else - break; - - if (fastcmp(word, "PLAYERTEXT")) - { - char *playertext = NULL; - - SLOTFOUND - - for (i = 0; i < MAXLINELEN-3; i++) - { - if (s[i] == '=') - { - playertext = &s[i+2]; - break; - } - } - if (playertext) - { - strcpy(description[num].notes, playertext); - strcat(description[num].notes, myhashfgets(playertext, sizeof (description[num].notes), f)); - } - 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 < sizeof(description[num].notes)-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")) - { - SLOTFOUND - strncpy(description[num].picname, word2, 8); - } - // new character select - else if (fastcmp(word, "DISPLAYNAME")) - { - SLOTFOUND - // replace '#' with line breaks - // (also remove any '\n') - { - char *cur = NULL; - - // remove '\n' - cur = strchr(displayname, '\n'); - if (cur) - *cur = '\0'; - - // turn '#' into '\n' - cur = strchr(displayname, '#'); - while (cur) - { - *cur = '\n'; - cur = strchr(cur, '#'); - } - } - // copy final string - strncpy(description[num].displayname, displayname, SKINNAMESIZE); - } - else if (fastcmp(word, "OPPOSITECOLOR") || fastcmp(word, "OPPOSITECOLOUR")) - { - SLOTFOUND - description[num].oppositecolor = (UINT16)get_number(word2); - } - else if (fastcmp(word, "NAMETAG") || fastcmp(word, "TAGNAME")) - { - SLOTFOUND - strncpy(description[num].nametag, word2, 8); - } - else if (fastcmp(word, "TAGTEXTCOLOR") || fastcmp(word, "TAGTEXTCOLOUR")) - { - SLOTFOUND - description[num].tagtextcolor = (UINT16)get_number(word2); - } - else if (fastcmp(word, "TAGOUTLINECOLOR") || fastcmp(word, "TAGOUTLINECOLOUR")) - { - SLOTFOUND - description[num].tagoutlinecolor = (UINT16)get_number(word2); - } - else if (fastcmp(word, "STATUS")) - { - /* - 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 entries you like, but only if you - signal that you are purposely doing so by disabling and then reenabling the slot. - */ - if (i && !slotfound && (slotfound = findFreeSlot(&num)) == false) - goto done; - - description[num].used = (!!i); - } - else if (fastcmp(word, "SKINNAME")) - { - // Send to free slot. - SLOTFOUND - 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 - #undef SLOTFOUND -done: - Z_Free(displayname); - Z_Free(s); -} - -// TODO: Figure out how to do undolines for this.... -// TODO: Warnings for running out of freeslots -static void readfreeslots(MYFILE *f) -{ - char *s = Z_Malloc(MAXLINELEN, PU_STATIC, NULL); - char *word,*type; - char *tmp; - int i; - - do - { - if (myfgets(s, MAXLINELEN, f)) - { - if (s[0] == '\n') - break; - - tmp = strchr(s, '#'); - if (tmp) - *tmp = '\0'; - if (s == tmp) - continue; // Skip comment lines, but don't break. - - type = strtok(s, "_"); - if (type) - strupr(type); - else - break; - - word = strtok(NULL, "\n"); - if (word) - strupr(word); - else - break; - - // TODO: Check for existing freeslot mobjs/states/etc. and make errors. - // TODO: Out-of-slots warnings/errors. - // TODO: Name too long (truncated) warnings. - if (fastcmp(type, "SFX")) - S_AddSoundFx(word, false, 0, false); - else if (fastcmp(type, "SPR")) - { - for (i = SPR_FIRSTFREESLOT; i <= SPR_LASTFREESLOT; i++) - { - if (used_spr[(i-SPR_FIRSTFREESLOT)/8] & (1<<(i%8))) - { - 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); - //sprnames[i][4] = 0; - used_spr[(i-SPR_FIRSTFREESLOT)/8] |= 1<<(i%8); // Okay, this sprite slot has been named now. - break; - } - } - else if (fastcmp(type, "S")) - { - for (i = 0; i < NUMSTATEFREESLOTS; i++) - if (!FREE_STATES[i]) { - FREE_STATES[i] = Z_Malloc(strlen(word)+1, PU_STATIC, NULL); - strcpy(FREE_STATES[i],word); - break; - } - } - else if (fastcmp(type, "MT")) - { - for (i = 0; i < NUMMOBJFREESLOTS; i++) - if (!FREE_MOBJS[i]) { - FREE_MOBJS[i] = Z_Malloc(strlen(word)+1, PU_STATIC, NULL); - strcpy(FREE_MOBJS[i],word); - break; - } - } - else if (fastcmp(type, "SKINCOLOR")) - { - for (i = 0; i < NUMCOLORFREESLOTS; i++) - if (!FREE_SKINCOLORS[i]) { - FREE_SKINCOLORS[i] = Z_Malloc(strlen(word)+1, PU_STATIC, NULL); - strcpy(FREE_SKINCOLORS[i],word); - M_AddMenuColor(numskincolors++); - break; - } - } - else if (fastcmp(type, "SPR2")) - { - // Search if we already have an SPR2 by that name... - for (i = SPR2_FIRSTFREESLOT; i < (int)free_spr2; i++) - if (memcmp(spr2names[i],word,4) == 0) - break; - // We found it? (Two mods using the same SPR2 name?) Then don't allocate another one. - if (i < (int)free_spr2) - continue; - // Copy in the spr2 name and increment free_spr2. - if (free_spr2 < NUMPLAYERSPRITES) { - strncpy(spr2names[free_spr2],word,4); - spr2defaults[free_spr2] = 0; - spr2names[free_spr2++][4] = 0; - } else - deh_warning("Ran out of free SPR2 slots!\n"); - } - else if (fastcmp(type, "TOL")) - { - // Search if we already have a typeoflevel by that name... - for (i = 0; TYPEOFLEVEL[i].name; i++) - if (fastcmp(word, TYPEOFLEVEL[i].name)) - break; - - // We found it? Then don't allocate another one. - if (TYPEOFLEVEL[i].name) - continue; - - // We don't, so freeslot it. - if (lastcustomtol == (UINT32)MAXTOL) // Unless you have way too many, since they're flags. - deh_warning("Ran out of free typeoflevel slots!\n"); - else - { - G_AddTOL(lastcustomtol, word); - lastcustomtol <<= 1; - } - } - else - deh_warning("Freeslots: unknown enum class '%s' for '%s_%s'", type, type, word); - } - } while (!myfeof(f)); // finish when the line is empty - - Z_Free(s); -} - -static void readthing(MYFILE *f, INT32 num) -{ - char *s = Z_Malloc(MAXLINELEN, PU_STATIC, NULL); - char *word, *word2; - char *tmp; - - do - { - if (myfgets(s, MAXLINELEN, f)) - { - if (s[0] == '\n') - break; - - tmp = strchr(s, '#'); - if (tmp) - *tmp = '\0'; - if (s == tmp) - continue; // Skip comment lines, but don't break. - - word = strtok(s, " "); - if (word) - strupr(word); - else - break; - - word2 = strtok(NULL, " = "); - if (word2) - strupr(word2); - else - break; - if (word2[strlen(word2)-1] == '\n') - word2[strlen(word2)-1] = '\0'; - - if (fastcmp(word, "MAPTHINGNUM") || fastcmp(word, "DOOMEDNUM")) - { - mobjinfo[num].doomednum = (INT32)atoi(word2); - } - else if (fastcmp(word, "SPAWNSTATE")) - { - mobjinfo[num].spawnstate = get_number(word2); - } - else if (fastcmp(word, "SPAWNHEALTH")) - { - mobjinfo[num].spawnhealth = (INT32)get_number(word2); - } - else if (fastcmp(word, "SEESTATE")) - { - mobjinfo[num].seestate = get_number(word2); - } - else if (fastcmp(word, "SEESOUND")) - { - mobjinfo[num].seesound = get_number(word2); - } - else if (fastcmp(word, "REACTIONTIME")) - { - mobjinfo[num].reactiontime = (INT32)get_number(word2); - } - else if (fastcmp(word, "ATTACKSOUND")) - { - mobjinfo[num].attacksound = get_number(word2); - } - else if (fastcmp(word, "PAINSTATE")) - { - mobjinfo[num].painstate = get_number(word2); - } - else if (fastcmp(word, "PAINCHANCE")) - { - mobjinfo[num].painchance = (INT32)get_number(word2); - } - else if (fastcmp(word, "PAINSOUND")) - { - mobjinfo[num].painsound = get_number(word2); - } - else if (fastcmp(word, "MELEESTATE")) - { - mobjinfo[num].meleestate = get_number(word2); - } - else if (fastcmp(word, "MISSILESTATE")) - { - mobjinfo[num].missilestate = get_number(word2); - } - else if (fastcmp(word, "DEATHSTATE")) - { - mobjinfo[num].deathstate = get_number(word2); - } - else if (fastcmp(word, "DEATHSOUND")) - { - mobjinfo[num].deathsound = get_number(word2); - } - else if (fastcmp(word, "XDEATHSTATE")) - { - mobjinfo[num].xdeathstate = get_number(word2); - } - else if (fastcmp(word, "SPEED")) - { - mobjinfo[num].speed = get_number(word2); - } - else if (fastcmp(word, "RADIUS")) - { - mobjinfo[num].radius = get_number(word2); - } - else if (fastcmp(word, "HEIGHT")) - { - mobjinfo[num].height = get_number(word2); - } - else if (fastcmp(word, "DISPOFFSET")) - { - mobjinfo[num].dispoffset = get_number(word2); - } - else if (fastcmp(word, "MASS")) - { - mobjinfo[num].mass = (INT32)get_number(word2); - } - else if (fastcmp(word, "DAMAGE")) - { - mobjinfo[num].damage = (INT32)get_number(word2); - } - else if (fastcmp(word, "ACTIVESOUND")) - { - mobjinfo[num].activesound = get_number(word2); - } - else if (fastcmp(word, "FLAGS")) - { - mobjinfo[num].flags = (INT32)get_number(word2); - } - else if (fastcmp(word, "RAISESTATE")) - { - mobjinfo[num].raisestate = get_number(word2); - } - else - deh_warning("Thing %d: unknown word '%s'", num, word); - } - } while (!myfeof(f)); // finish when the line is empty - - Z_Free(s); -} - -static void readskincolor(MYFILE *f, INT32 num) -{ - char *s = Z_Malloc(MAXLINELEN, PU_STATIC, NULL); - char *word = s; - char *word2; - char *tmp; - - Color_cons_t[num].value = num; - - do - { - if (myfgets(s, MAXLINELEN, f)) - { - if (s[0] == '\n') - break; - - // First remove trailing newline, if there is one - tmp = strchr(s, '\n'); - if (tmp) - *tmp = '\0'; - - tmp = strchr(s, '#'); - if (tmp) - *tmp = '\0'; - if (s == tmp) - continue; // Skip comment lines, but don't break. - - // Get the part before the " = " - tmp = strchr(s, '='); - if (tmp) - *(tmp-1) = '\0'; - else - break; - strupr(word); - - // Now get the part after - word2 = tmp += 2; - - if (fastcmp(word, "NAME")) - { - size_t namesize = sizeof(skincolors[num].name); - char truncword[namesize]; - UINT16 dupecheck; - - deh_strlcpy(truncword, word2, namesize, va("Skincolor %d: name", num)); // truncate here to check for dupes - dupecheck = R_GetColorByName(truncword); - if (truncword[0] != '\0' && (!stricmp(truncword, skincolors[SKINCOLOR_NONE].name) || (dupecheck && dupecheck != num))) - { - size_t lastchar = strlen(truncword); - char oldword[lastchar+1]; - char dupenum = '1'; - - strlcpy(oldword, truncword, lastchar+1); - lastchar--; - if (lastchar == namesize-2) // exactly max length, replace last character with 0 - truncword[lastchar] = '0'; - else // append 0 - { - strcat(truncword, "0"); - lastchar++; - } - - while (R_GetColorByName(truncword)) - { - truncword[lastchar] = dupenum; - if (dupenum == '9') - dupenum = 'A'; - else if (dupenum == 'Z') // give up :? - break; - else - dupenum++; - } - - deh_warning("Skincolor %d: name %s is a duplicate of another skincolor's name - renamed to %s", num, oldword, truncword); - } - - strlcpy(skincolors[num].name, truncword, namesize); // already truncated - } - else if (fastcmp(word, "RAMP")) - { - UINT8 i; - tmp = strtok(word2,","); - for (i = 0; i < COLORRAMPSIZE; i++) { - skincolors[num].ramp[i] = (UINT8)get_number(tmp); - if ((tmp = strtok(NULL,",")) == NULL) - break; - } - skincolor_modified[num] = true; - } - else if (fastcmp(word, "INVCOLOR")) - { - UINT16 v = (UINT16)get_number(word2); - if (v < numskincolors) - skincolors[num].invcolor = v; - else - skincolors[num].invcolor = SKINCOLOR_GREEN; - } - else if (fastcmp(word, "INVSHADE")) - { - skincolors[num].invshade = get_number(word2)%COLORRAMPSIZE; - } - else if (fastcmp(word, "CHATCOLOR")) - { - skincolors[num].chatcolor = get_number(word2); - } - else if (fastcmp(word, "ACCESSIBLE")) - { - if (num > FIRSTSUPERCOLOR) - skincolors[num].accessible = (boolean)(atoi(word2) || word2[0] == 'T' || word2[0] == 'Y'); - } - else - deh_warning("Skincolor %d: unknown word '%s'", num, word); - } - } while (!myfeof(f)); // finish when the line is empty - - Z_Free(s); -} - -#ifdef HWRENDER -static void readlight(MYFILE *f, INT32 num) -{ - char *s = Z_Malloc(MAXLINELEN, PU_STATIC, NULL); - char *word; - char *tmp; - INT32 value; - float fvalue; - - do - { - if (myfgets(s, MAXLINELEN, f)) - { - if (s[0] == '\n') - break; - - tmp = strchr(s, '#'); - if (tmp) - *tmp = '\0'; - if (s == tmp) - continue; // Skip comment lines, but don't break. - - fvalue = searchfvalue(s); - value = searchvalue(s); - - word = strtok(s, " "); - if (word) - strupr(word); - else - break; - - if (fastcmp(word, "TYPE")) - { - lspr[num].type = (UINT16)value; - } - else if (fastcmp(word, "OFFSETX")) - { - lspr[num].light_xoffset = fvalue; - } - else if (fastcmp(word, "OFFSETY")) - { - lspr[num].light_yoffset = fvalue; - } - else if (fastcmp(word, "CORONACOLOR")) - { - lspr[num].corona_color = value; - } - else if (fastcmp(word, "CORONARADIUS")) - { - lspr[num].corona_radius = fvalue; - } - else if (fastcmp(word, "DYNAMICCOLOR")) - { - lspr[num].dynamic_color = value; - } - else if (fastcmp(word, "DYNAMICRADIUS")) - { - lspr[num].dynamic_radius = fvalue; - - /// \note Update the sqrradius! unnecessary? - lspr[num].dynamic_sqrradius = fvalue * fvalue; - } - else - deh_warning("Light %d: unknown word '%s'", num, word); - } - } while (!myfeof(f)); // finish when the line is empty - - Z_Free(s); -} -#endif // HWRENDER - -static void readspriteframe(MYFILE *f, spriteinfo_t *sprinfo, UINT8 frame) -{ - char *s = Z_Malloc(MAXLINELEN, PU_STATIC, NULL); - char *word, *word2; - char *tmp; - INT32 value; - char *lastline; - - do - { - lastline = f->curpos; - if (myfgets(s, MAXLINELEN, f)) - { - if (s[0] == '\n') - break; - - // First remove trailing newline, if there is one - tmp = strchr(s, '\n'); - if (tmp) - *tmp = '\0'; - - tmp = strchr(s, '#'); - if (tmp) - *tmp = '\0'; - if (s == tmp) - continue; // Skip comment lines, but don't break. - - // Set / reset word - word = s; - while ((*word == '\t') || (*word == ' ')) - word++; - - // Get the part before the " = " - tmp = strchr(s, '='); - if (tmp) - { - *(tmp-1) = '\0'; - // Now get the part after - word2 = tmp += 2; - } - else - { - // Get the part before the " " - tmp = strchr(s, ' '); - if (tmp) - { - *tmp = '\0'; - // Now get the part after - tmp++; - word2 = tmp; - } - else - break; - } - strupr(word); - value = atoi(word2); // used for numerical settings - - if (fastcmp(word, "XPIVOT")) - sprinfo->pivot[frame].x = value; - else if (fastcmp(word, "YPIVOT")) - sprinfo->pivot[frame].y = value; - else if (fastcmp(word, "ROTAXIS")) - sprinfo->pivot[frame].rotaxis = value; - else - { - f->curpos = lastline; - break; - } - } - } while (!myfeof(f)); // finish when the line is empty - Z_Free(s); -} - -static void readspriteinfo(MYFILE *f, INT32 num, boolean sprite2) -{ - char *s = Z_Malloc(MAXLINELEN, PU_STATIC, NULL); - char *word, *word2; - char *tmp; -#ifdef HWRENDER - INT32 value; -#endif - char *lastline; - INT32 skinnumbers[MAXSKINS]; - INT32 foundskins = 0; - - // allocate a spriteinfo - spriteinfo_t *info = Z_Calloc(sizeof(spriteinfo_t), PU_STATIC, NULL); - info->available = true; - - do - { - lastline = f->curpos; - if (myfgets(s, MAXLINELEN, f)) - { - if (s[0] == '\n') - break; - - // First remove trailing newline, if there is one - tmp = strchr(s, '\n'); - if (tmp) - *tmp = '\0'; - - tmp = strchr(s, '#'); - if (tmp) - *tmp = '\0'; - if (s == tmp) - continue; // Skip comment lines, but don't break. - - // Set / reset word - word = s; - while ((*word == '\t') || (*word == ' ')) - word++; - - // Get the part before the " = " - tmp = strchr(s, '='); - if (tmp) - { - *(tmp-1) = '\0'; - // Now get the part after - word2 = tmp += 2; - } - else - { - // Get the part before the " " - tmp = strchr(s, ' '); - if (tmp) - { - *tmp = '\0'; - // Now get the part after - tmp++; - word2 = tmp; - } - else - break; - } - strupr(word); -#ifdef HWRENDER - value = atoi(word2); // used for numerical settings - - if (fastcmp(word, "LIGHTTYPE")) - { - if (sprite2) - deh_warning("Sprite2 %s: invalid word '%s'", spr2names[num], word); - else - { - INT32 oldvar; - for (oldvar = 0; t_lspr[num] != &lspr[oldvar]; oldvar++) - ; - t_lspr[num] = &lspr[value]; - } - } - else -#endif - if (fastcmp(word, "SKIN")) - { - INT32 skinnum = -1; - if (!sprite2) - { - deh_warning("Sprite %s: %s keyword found outside of SPRITE2INFO block, ignoring", spr2names[num], word); - continue; - } - - // make lowercase - strlwr(word2); - skinnum = R_SkinAvailable(word2); - if (skinnum == -1) - { - deh_warning("Sprite2 %s: unknown skin %s", spr2names[num], word2); - break; - } - - skinnumbers[foundskins] = skinnum; - foundskins++; - } - else if (fastcmp(word, "DEFAULT")) - { - if (!sprite2) - { - deh_warning("Sprite %s: %s keyword found outside of SPRITE2INFO block, ignoring", spr2names[num], word); - continue; - } - if (num < (INT32)free_spr2 && num >= (INT32)SPR2_FIRSTFREESLOT) - spr2defaults[num] = get_number(word2); - else - { - deh_warning("Sprite2 %s: out of range (%d - %d), ignoring", spr2names[num], SPR2_FIRSTFREESLOT, free_spr2-1); - continue; - } - } - else if (fastcmp(word, "FRAME")) - { - UINT8 frame = R_Char2Frame(word2[0]); - // frame number too high - if (frame >= 64) - { - if (sprite2) - deh_warning("Sprite2 %s: invalid frame %s", spr2names[num], word2); - else - deh_warning("Sprite %s: invalid frame %s", sprnames[num], word2); - break; - } - - // read sprite frame and store it in the spriteinfo_t struct - readspriteframe(f, info, frame); - if (sprite2) - { - INT32 i; - if (!foundskins) - { - deh_warning("Sprite2 %s: no skins specified", spr2names[num]); - break; - } - for (i = 0; i < foundskins; i++) - { - size_t skinnum = skinnumbers[i]; - skin_t *skin = &skins[skinnum]; - spriteinfo_t *sprinfo = skin->sprinfo; - M_Memcpy(&sprinfo[num], info, sizeof(spriteinfo_t)); - } - } - else - M_Memcpy(&spriteinfo[num], info, sizeof(spriteinfo_t)); - } - else - { - //deh_warning("Sprite %s: unknown word '%s'", sprnames[num], word); - f->curpos = lastline; - break; - } - } - } while (!myfeof(f)); // finish when the line is empty - - Z_Free(s); - Z_Free(info); -} - -static void readsprite2(MYFILE *f, INT32 num) -{ - char *s = Z_Malloc(MAXLINELEN, PU_STATIC, NULL); - char *word, *word2; - char *tmp; - - do - { - if (myfgets(s, MAXLINELEN, f)) - { - if (s[0] == '\n') - break; - - tmp = strchr(s, '#'); - if (tmp) - *tmp = '\0'; - if (s == tmp) - continue; // Skip comment lines, but don't break. - - word = strtok(s, " "); - if (word) - strupr(word); - else - break; - - word2 = strtok(NULL, " = "); - if (word2) - strupr(word2); - else - break; - if (word2[strlen(word2)-1] == '\n') - word2[strlen(word2)-1] = '\0'; - - if (fastcmp(word, "DEFAULT")) - spr2defaults[num] = get_number(word2); - else - deh_warning("Sprite2 %s: unknown word '%s'", spr2names[num], word); - } - } while (!myfeof(f)); // finish when the line is empty - - Z_Free(s); -} - -// copypasted from readPlayer :] -static const char *const GAMETYPERULE_LIST[]; -static void readgametype(MYFILE *f, char *gtname) -{ - char *s = Z_Malloc(MAXLINELEN, PU_STATIC, NULL); - char *word; - char *word2, *word2lwr = NULL; - char *tmp; - INT32 i, j; - - INT16 newgtidx = 0; - UINT32 newgtrules = 0; - UINT32 newgttol = 0; - INT32 newgtpointlimit = 0; - INT32 newgttimelimit = 0; - UINT8 newgtleftcolor = 0; - UINT8 newgtrightcolor = 0; - INT16 newgtrankingstype = -1; - int newgtinttype = 0; - char gtdescription[441]; - char gtconst[MAXLINELEN]; - - // Empty strings. - gtdescription[0] = '\0'; - gtconst[0] = '\0'; - - do - { - if (myfgets(s, MAXLINELEN, f)) - { - if (s[0] == '\n') - break; - - word = strtok(s, " "); - if (word) - strupr(word); - else - break; - - if (fastcmp(word, "DESCRIPTION")) - { - char *descr = NULL; - - for (i = 0; i < MAXLINELEN-3; i++) - { - if (s[i] == '=') - { - descr = &s[i+2]; - break; - } - } - if (descr) - { - strcpy(gtdescription, descr); - strcat(gtdescription, myhashfgets(descr, sizeof (gtdescription), f)); - } - else - strcpy(gtdescription, ""); - - // 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 < sizeof(gtdescription)-1; i++) - { - if (numline < 20 && gtdescription[i] == '\n') - numline++; - - if (numline >= 20 || gtdescription[i] == '\0' || gtdescription[i] == '#') - break; - } - } - gtdescription[strlen(gtdescription)-1] = '\0'; - gtdescription[i] = '\0'; - continue; - } - - word2 = strtok(NULL, " = "); - if (word2) - { - if (!word2lwr) - word2lwr = Z_Malloc(MAXLINELEN, PU_STATIC, NULL); - strcpy(word2lwr, word2); - strupr(word2); - } - else - break; - - if (word2[strlen(word2)-1] == '\n') - word2[strlen(word2)-1] = '\0'; - i = atoi(word2); - - // Game type rules - if (fastcmp(word, "RULES")) - { - // GTR_ - newgtrules = (UINT32)get_number(word2); - } - // Identifier - else if (fastcmp(word, "IDENTIFIER")) - { - // GT_ - strncpy(gtconst, word2, MAXLINELEN); - } - // Point and time limits - else if (fastcmp(word, "DEFAULTPOINTLIMIT")) - newgtpointlimit = (INT32)i; - else if (fastcmp(word, "DEFAULTTIMELIMIT")) - newgttimelimit = (INT32)i; - // Level platter - else if (fastcmp(word, "HEADERCOLOR") || fastcmp(word, "HEADERCOLOUR")) - newgtleftcolor = newgtrightcolor = (UINT8)get_number(word2); - else if (fastcmp(word, "HEADERLEFTCOLOR") || fastcmp(word, "HEADERLEFTCOLOUR")) - newgtleftcolor = (UINT8)get_number(word2); - else if (fastcmp(word, "HEADERRIGHTCOLOR") || fastcmp(word, "HEADERRIGHTCOLOUR")) - newgtrightcolor = (UINT8)get_number(word2); - // Rankings type - else if (fastcmp(word, "RANKINGTYPE")) - { - // Case insensitive - newgtrankingstype = (int)get_number(word2); - } - // Intermission type - else if (fastcmp(word, "INTERMISSIONTYPE")) - { - // Case sensitive - newgtinttype = (int)get_number(word2lwr); - } - // Type of level - else if (fastcmp(word, "TYPEOFLEVEL")) - { - if (i) // it's just a number - newgttol = (UINT32)i; - else - { - UINT32 tol = 0; - tmp = strtok(word2,","); - do { - for (i = 0; TYPEOFLEVEL[i].name; i++) - if (fasticmp(tmp, TYPEOFLEVEL[i].name)) - break; - if (!TYPEOFLEVEL[i].name) - deh_warning("readgametype %s: unknown typeoflevel flag %s\n", gtname, tmp); - tol |= TYPEOFLEVEL[i].flag; - } while((tmp = strtok(NULL,",")) != NULL); - newgttol = tol; - } - } - // The SOC probably provided gametype rules as words, - // instead of using the RULES keyword. - // Like for example "NOSPECTATORSPAWN = TRUE". - // This is completely valid, and looks better anyway. - else - { - UINT32 wordgt = 0; - for (j = 0; GAMETYPERULE_LIST[j]; j++) - if (fastcmp(word, GAMETYPERULE_LIST[j])) { - wordgt |= (1<lvlttl, word2, - sizeof(mapheaderinfo[num-1]->lvlttl), va("Level header %d: levelname", num)); - strlcpy(mapheaderinfo[num-1]->selectheading, word2, sizeof(mapheaderinfo[num-1]->selectheading)); // not deh_ so only complains once - continue; - } - // CHEAP HACK: move this over here for lowercase subtitles - if (fastcmp(word, "SUBTITLE")) - { - deh_strlcpy(mapheaderinfo[num-1]->subttl, word2, - sizeof(mapheaderinfo[num-1]->subttl), va("Level header %d: subtitle", num)); - continue; - } - - // Lua custom options also go above, contents may be case sensitive. - if (fastncmp(word, "LUA.", 4)) - { - UINT8 j; - customoption_t *modoption; - - // Note: we actualy strlwr word here, so things are made a little easier for Lua - strlwr(word); - word += 4; // move past "lua." - - // ... and do a simple name sanity check; the name must start with a letter - if (*word < 'a' || *word > 'z') - { - deh_warning("Level header %d: invalid custom option name \"%s\"", num, word); - continue; - } - - // Sanity limit of 128 params - if (mapheaderinfo[num-1]->numCustomOptions == 128) - { - deh_warning("Level header %d: too many custom parameters", num); - continue; - } - j = mapheaderinfo[num-1]->numCustomOptions++; - - mapheaderinfo[num-1]->customopts = - Z_Realloc(mapheaderinfo[num-1]->customopts, - sizeof(customoption_t) * mapheaderinfo[num-1]->numCustomOptions, PU_STATIC, NULL); - - // Newly allocated - modoption = &mapheaderinfo[num-1]->customopts[j]; - - strncpy(modoption->option, word, 31); - modoption->option[31] = '\0'; - strncpy(modoption->value, word2, 255); - modoption->value[255] = '\0'; - continue; - } - - // Now go to uppercase - strupr(word2); - - // List of flickies that are be freed in this map - if (fastcmp(word, "FLICKYLIST") || fastcmp(word, "ANIMALLIST")) - { - if (fastcmp(word2, "NONE")) - P_DeleteFlickies(num-1); - else if (fastcmp(word2, "DEMO")) - P_SetDemoFlickies(num-1); - else if (fastcmp(word2, "ALL")) - { - mobjtype_t tmpflickies[MAXFLICKIES]; - - for (mapheaderinfo[num-1]->numFlickies = 0; - ((mapheaderinfo[num-1]->numFlickies < MAXFLICKIES) && FLICKYTYPES[mapheaderinfo[num-1]->numFlickies].type); - mapheaderinfo[num-1]->numFlickies++) - tmpflickies[mapheaderinfo[num-1]->numFlickies] = FLICKYTYPES[mapheaderinfo[num-1]->numFlickies].type; - - if (mapheaderinfo[num-1]->numFlickies) // just in case... - { - size_t newsize = sizeof(mobjtype_t) * mapheaderinfo[num-1]->numFlickies; - mapheaderinfo[num-1]->flickies = Z_Realloc(mapheaderinfo[num-1]->flickies, newsize, PU_STATIC, NULL); - M_Memcpy(mapheaderinfo[num-1]->flickies, tmpflickies, newsize); - } - } - else - { - mobjtype_t tmpflickies[MAXFLICKIES]; - mapheaderinfo[num-1]->numFlickies = 0; - tmp = strtok(word2,","); - // get up to the first MAXFLICKIES flickies - do { - if (mapheaderinfo[num-1]->numFlickies == MAXFLICKIES) // never going to get above that number - { - deh_warning("Level header %d: too many flickies\n", num); - break; - } - - if (fastncmp(tmp, "MT_", 3)) // support for specified mobjtypes... - { - i = get_mobjtype(tmp); - if (!i) - { - //deh_warning("Level header %d: unknown flicky mobj type %s\n", num, tmp); -- no need for this line as get_mobjtype complains too - continue; - } - tmpflickies[mapheaderinfo[num-1]->numFlickies] = i; - } - else // ...or a quick, limited selection of default flickies! - { - for (i = 0; FLICKYTYPES[i].name; i++) - if (fastcmp(tmp, FLICKYTYPES[i].name)) - break; - - if (!FLICKYTYPES[i].name) - { - deh_warning("Level header %d: unknown flicky selection %s\n", num, tmp); - continue; - } - tmpflickies[mapheaderinfo[num-1]->numFlickies] = FLICKYTYPES[i].type; - } - mapheaderinfo[num-1]->numFlickies++; - } while ((tmp = strtok(NULL,",")) != NULL); - - if (mapheaderinfo[num-1]->numFlickies) - { - size_t newsize = sizeof(mobjtype_t) * mapheaderinfo[num-1]->numFlickies; - mapheaderinfo[num-1]->flickies = Z_Realloc(mapheaderinfo[num-1]->flickies, newsize, PU_STATIC, NULL); - // now we add them to the list! - M_Memcpy(mapheaderinfo[num-1]->flickies, tmpflickies, newsize); - } - else - deh_warning("Level header %d: no valid flicky types found\n", num); - } - } - - // NiGHTS grades - else 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, "SELECTHEADING")) - { - deh_strlcpy(mapheaderinfo[num-1]->selectheading, word2, - sizeof(mapheaderinfo[num-1]->selectheading), va("Level header %d: selectheading", num)); - } - else if (fastcmp(word, "SCRIPTNAME")) - { - deh_strlcpy(mapheaderinfo[num-1]->scriptname, word2, - sizeof(mapheaderinfo[num-1]->scriptname), va("Level header %d: scriptname", num)); - } - else if (fastcmp(word, "RUNSOC")) - { - deh_strlcpy(mapheaderinfo[num-1]->runsoc, word2, - sizeof(mapheaderinfo[num-1]->runsoc), va("Level header %d: runsoc", num)); - } - else if (fastcmp(word, "ACT")) - { - if (i >= 0 && i <= 99) // 0 for no act number - mapheaderinfo[num-1]->actnum = (UINT8)i; - else - deh_warning("Level header %d: invalid act number %d", num, i); - } - else if (fastcmp(word, "NEXTLEVEL")) - { - if (fastcmp(word2, "TITLE")) i = 1100; - else if (fastcmp(word2, "EVALUATION")) i = 1101; - else if (fastcmp(word2, "CREDITS")) i = 1102; - else if (fastcmp(word2, "ENDING")) i = 1103; - else - // Support using the actual map name, - // i.e., Nextlevel = AB, Nextlevel = FZ, etc. - - // Convert to map number - if (word2[0] >= 'A' && word2[0] <= 'Z' && word2[2] == '\0') - i = M_MapNumber(word2[0], word2[1]); - - mapheaderinfo[num-1]->nextlevel = (INT16)i; - } - else if (fastcmp(word, "MARATHONNEXT")) - { - if (fastcmp(word2, "TITLE")) i = 1100; - else if (fastcmp(word2, "EVALUATION")) i = 1101; - else if (fastcmp(word2, "CREDITS")) i = 1102; - else if (fastcmp(word2, "ENDING")) i = 1103; - else - // Support using the actual map name, - // i.e., MarathonNext = AB, MarathonNext = FZ, etc. - - // Convert to map number - if (word2[0] >= 'A' && word2[0] <= 'Z' && word2[2] == '\0') - i = M_MapNumber(word2[0], word2[1]); - - mapheaderinfo[num-1]->marathonnext = (INT16)i; - } - else if (fastcmp(word, "TYPEOFLEVEL")) - { - if (i) // it's just a number - mapheaderinfo[num-1]->typeoflevel = (UINT32)i; - else - { - UINT32 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; - } - } - else if (fastcmp(word, "KEYWORDS")) - { - deh_strlcpy(mapheaderinfo[num-1]->keywords, word2, - sizeof(mapheaderinfo[num-1]->keywords), va("Level header %d: keywords", num)); - } - else if (fastcmp(word, "MUSIC")) - { - if (fastcmp(word2, "NONE")) - mapheaderinfo[num-1]->musname[0] = 0; // becomes empty string - else - { - deh_strlcpy(mapheaderinfo[num-1]->musname, word2, - sizeof(mapheaderinfo[num-1]->musname), va("Level header %d: music", num)); - } - } -#ifdef MUSICSLOT_COMPATIBILITY - else if (fastcmp(word, "MUSICSLOT")) - { - i = get_mus(word2, true); - if (i && i <= 1035) - snprintf(mapheaderinfo[num-1]->musname, 7, "%sM", G_BuildMapName(i)); - else if (i && i <= 1050) - strncpy(mapheaderinfo[num-1]->musname, compat_special_music_slots[i - 1036], 7); - else - mapheaderinfo[num-1]->musname[0] = 0; // becomes empty string - mapheaderinfo[num-1]->musname[6] = 0; - } -#endif - else if (fastcmp(word, "MUSICTRACK")) - 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, "MUSICPOSTBOSS")) - deh_strlcpy(mapheaderinfo[num-1]->muspostbossname, word2, - sizeof(mapheaderinfo[num-1]->muspostbossname), va("Level header %d: post-boss music", num)); - else if (fastcmp(word, "MUSICPOSTBOSSTRACK")) - mapheaderinfo[num-1]->muspostbosstrack = ((UINT16)i - 1); - else if (fastcmp(word, "MUSICPOSTBOSSPOS")) - mapheaderinfo[num-1]->muspostbosspos = (UINT32)get_number(word2); - else if (fastcmp(word, "MUSICPOSTBOSSFADEIN")) - mapheaderinfo[num-1]->muspostbossfadein = (UINT32)get_number(word2); - else if (fastcmp(word, "FORCERESETMUSIC")) - { - // This is a weird one because "FALSE"/"NO" could either apply to "leave to default preference" (cv_resetmusic) - // or "force off". Let's assume it means "force off", and let an unspecified value mean "default preference" - if (fastcmp(word2, "OFF") || word2[0] == 'F' || word2[0] == 'N') i = 0; - else if (fastcmp(word2, "ON") || word2[0] == 'T' || word2[0] == 'Y') i = 1; - else i = -1; // (fastcmp(word2, "DEFAULT")) - - if (i >= -1 && i <= 1) // -1 to force off, 1 to force on, 0 to honor default. - // This behavior can be disabled with cv_resetmusicbyheader - mapheaderinfo[num-1]->musforcereset = (SINT8)i; - else - deh_warning("Level header %d: invalid forceresetmusic option %d", num, i); - } - else if (fastcmp(word, "FORCECHARACTER")) - { - strlcpy(mapheaderinfo[num-1]->forcecharacter, word2, SKINNAMESIZE+1); - strlwr(mapheaderinfo[num-1]->forcecharacter); // skin names are lowercase - } - else if (fastcmp(word, "WEATHER")) - mapheaderinfo[num-1]->weather = (UINT8)get_number(word2); - else if (fastcmp(word, "SKYNUM")) - mapheaderinfo[num-1]->skynum = (INT16)i; - else if (fastcmp(word, "INTERSCREEN")) - strncpy(mapheaderinfo[num-1]->interscreen, word2, 8); - else if (fastcmp(word, "PRECUTSCENENUM")) - mapheaderinfo[num-1]->precutscenenum = (UINT8)i; - else if (fastcmp(word, "CUTSCENENUM")) - mapheaderinfo[num-1]->cutscenenum = (UINT8)i; - else if (fastcmp(word, "COUNTDOWN")) - mapheaderinfo[num-1]->countdown = (INT16)i; - else if (fastcmp(word, "PALETTE")) - mapheaderinfo[num-1]->palette = (UINT16)i; - else if (fastcmp(word, "NUMLAPS")) - mapheaderinfo[num-1]->numlaps = (UINT8)i; - else if (fastcmp(word, "UNLOCKABLE")) - { - if (i >= 0 && i <= MAXUNLOCKABLES) // 0 for no unlock required, anything else requires something - mapheaderinfo[num-1]->unlockrequired = (SINT8)i - 1; - else - deh_warning("Level header %d: invalid unlockable number %d", num, i); - } - else if (fastcmp(word, "LEVELSELECT")) - mapheaderinfo[num-1]->levelselect = (UINT8)i; - else if (fastcmp(word, "SKYBOXSCALE")) - mapheaderinfo[num-1]->skybox_scalex = mapheaderinfo[num-1]->skybox_scaley = mapheaderinfo[num-1]->skybox_scalez = (INT16)i; - else if (fastcmp(word, "SKYBOXSCALEX")) - mapheaderinfo[num-1]->skybox_scalex = (INT16)i; - else if (fastcmp(word, "SKYBOXSCALEY")) - mapheaderinfo[num-1]->skybox_scaley = (INT16)i; - 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; - else if (fastcmp(word2, "NIGHTS")) i = 3; - else if (fastcmp(word2, "NIGHTSLINK")) i = 4; - - if (i >= -1 && i <= 4) // -1 for no bonus. Max is 4. - mapheaderinfo[num-1]->bonustype = (SINT8)i; - else - deh_warning("Level header %d: invalid bonus type number %d", num, i); - } - - // Title card - else if (fastcmp(word, "TITLECARDZIGZAG")) - { - deh_strlcpy(mapheaderinfo[num-1]->ltzzpatch, word2, - sizeof(mapheaderinfo[num-1]->ltzzpatch), va("Level header %d: title card zigzag patch name", num)); - } - else if (fastcmp(word, "TITLECARDZIGZAGTEXT")) - { - deh_strlcpy(mapheaderinfo[num-1]->ltzztext, word2, - sizeof(mapheaderinfo[num-1]->ltzztext), va("Level header %d: title card zigzag text patch name", num)); - } - else if (fastcmp(word, "TITLECARDACTDIAMOND")) - { - deh_strlcpy(mapheaderinfo[num-1]->ltactdiamond, word2, - sizeof(mapheaderinfo[num-1]->ltactdiamond), va("Level header %d: title card act diamond patch name", num)); - } - - else if (fastcmp(word, "MAXBONUSLIVES")) - mapheaderinfo[num-1]->maxbonuslives = (SINT8)i; - else if (fastcmp(word, "LEVELFLAGS")) - mapheaderinfo[num-1]->levelflags = (UINT16)i; - else if (fastcmp(word, "MENUFLAGS")) - mapheaderinfo[num-1]->menuflags = (UINT8)i; - - // Individual triggers for level flags, for ease of use (and 2.0 compatibility) - else if (fastcmp(word, "SCRIPTISFILE")) - { - if (i || word2[0] == 'T' || word2[0] == 'Y') - mapheaderinfo[num-1]->levelflags |= LF_SCRIPTISFILE; - else - mapheaderinfo[num-1]->levelflags &= ~LF_SCRIPTISFILE; - } - else if (fastcmp(word, "SPEEDMUSIC")) - { - if (i || word2[0] == 'T' || word2[0] == 'Y') - mapheaderinfo[num-1]->levelflags |= LF_SPEEDMUSIC; - else - mapheaderinfo[num-1]->levelflags &= ~LF_SPEEDMUSIC; - } - else if (fastcmp(word, "NOSSMUSIC")) - { - if (i || word2[0] == 'T' || word2[0] == 'Y') - mapheaderinfo[num-1]->levelflags |= LF_NOSSMUSIC; - else - mapheaderinfo[num-1]->levelflags &= ~LF_NOSSMUSIC; - } - else if (fastcmp(word, "NORELOAD")) - { - if (i || word2[0] == 'T' || word2[0] == 'Y') - mapheaderinfo[num-1]->levelflags |= LF_NORELOAD; - else - mapheaderinfo[num-1]->levelflags &= ~LF_NORELOAD; - } - else if (fastcmp(word, "NOZONE")) - { - if (i || word2[0] == 'T' || word2[0] == 'Y') - mapheaderinfo[num-1]->levelflags |= LF_NOZONE; - else - mapheaderinfo[num-1]->levelflags &= ~LF_NOZONE; - } - else if (fastcmp(word, "SAVEGAME")) - { - if (i || word2[0] == 'T' || word2[0] == 'Y') - mapheaderinfo[num-1]->levelflags |= LF_SAVEGAME; - else - mapheaderinfo[num-1]->levelflags &= ~LF_SAVEGAME; - } - else if (fastcmp(word, "MIXNIGHTSCOUNTDOWN")) - { - if (i || word2[0] == 'T' || word2[0] == 'Y') - mapheaderinfo[num-1]->levelflags |= LF_MIXNIGHTSCOUNTDOWN; - else - mapheaderinfo[num-1]->levelflags &= ~LF_MIXNIGHTSCOUNTDOWN; - } - else if (fastcmp(word, "WARNINGTITLE")) - { - if (i || word2[0] == 'T' || word2[0] == 'Y') - mapheaderinfo[num-1]->levelflags |= LF_WARNINGTITLE; - else - mapheaderinfo[num-1]->levelflags &= ~LF_WARNINGTITLE; - } - else if (fastcmp(word, "NOTITLECARD")) - { - if (i || word2[0] == 'T' || word2[0] == 'Y') - mapheaderinfo[num-1]->levelflags |= LF_NOTITLECARD; - else - mapheaderinfo[num-1]->levelflags &= ~LF_NOTITLECARD; - } - else if (fastcmp(word, "SHOWTITLECARDFOR")) - { - mapheaderinfo[num-1]->levelflags |= LF_NOTITLECARD; - tmp = strtok(word2,","); - do { - if (fastcmp(tmp, "FIRST")) - mapheaderinfo[num-1]->levelflags &= ~LF_NOTITLECARDFIRST; - else if (fastcmp(tmp, "RESPAWN")) - mapheaderinfo[num-1]->levelflags &= ~LF_NOTITLECARDRESPAWN; - else if (fastcmp(tmp, "RECORDATTACK")) - mapheaderinfo[num-1]->levelflags &= ~LF_NOTITLECARDRECORDATTACK; - else if (fastcmp(tmp, "ALL")) - mapheaderinfo[num-1]->levelflags &= ~LF_NOTITLECARD; - else if (!fastcmp(tmp, "NONE")) - deh_warning("Level header %d: unknown titlecard show option %s\n", num, tmp); - - } while((tmp = strtok(NULL,",")) != NULL); - } - - // Individual triggers for menu flags - else if (fastcmp(word, "HIDDEN")) - { - if (i || word2[0] == 'T' || word2[0] == 'Y') - mapheaderinfo[num-1]->menuflags |= LF2_HIDEINMENU; - else - mapheaderinfo[num-1]->menuflags &= ~LF2_HIDEINMENU; - } - else if (fastcmp(word, "HIDEINSTATS")) - { - if (i || word2[0] == 'T' || word2[0] == 'Y') - mapheaderinfo[num-1]->menuflags |= LF2_HIDEINSTATS; - else - mapheaderinfo[num-1]->menuflags &= ~LF2_HIDEINSTATS; - } - else if (fastcmp(word, "RECORDATTACK") || fastcmp(word, "TIMEATTACK")) - { // TIMEATTACK is an accepted alias - if (i || word2[0] == 'T' || word2[0] == 'Y') - mapheaderinfo[num-1]->menuflags |= LF2_RECORDATTACK; - else - mapheaderinfo[num-1]->menuflags &= ~LF2_RECORDATTACK; - } - else if (fastcmp(word, "NIGHTSATTACK")) - { - if (i || word2[0] == 'T' || word2[0] == 'Y') - mapheaderinfo[num-1]->menuflags |= LF2_NIGHTSATTACK; - else - mapheaderinfo[num-1]->menuflags &= LF2_NIGHTSATTACK; - } - else if (fastcmp(word, "NOVISITNEEDED")) - { - if (i || word2[0] == 'T' || word2[0] == 'Y') - mapheaderinfo[num-1]->menuflags |= LF2_NOVISITNEEDED; - else - mapheaderinfo[num-1]->menuflags &= ~LF2_NOVISITNEEDED; - } - else if (fastcmp(word, "WIDEICON")) - { - if (i || word2[0] == 'T' || word2[0] == 'Y') - mapheaderinfo[num-1]->menuflags |= LF2_WIDEICON; - else - mapheaderinfo[num-1]->menuflags &= ~LF2_WIDEICON; - } - else if (fastcmp(word, "STARTRINGS")) - mapheaderinfo[num-1]->startrings = (UINT16)i; - else if (fastcmp(word, "SPECIALSTAGETIME")) - mapheaderinfo[num-1]->sstimer = i; - else if (fastcmp(word, "SPECIALSTAGESPHERES")) - mapheaderinfo[num-1]->ssspheres = i; - else if (fastcmp(word, "GRAVITY")) - mapheaderinfo[num-1]->gravity = FLOAT_TO_FIXED(atof(word2)); - else - deh_warning("Level header %d: unknown word '%s'", num, word); - } - } while (!myfeof(f)); // finish when the line is empty - - Z_Free(s); -} - -#undef MAXFLICKIES - -static void readcutscenescene(MYFILE *f, INT32 num, INT32 scenenum) -{ - char *s = Z_Calloc(MAXLINELEN, PU_STATIC, NULL); - char *word; - char *word2; - INT32 i; - UINT16 usi; - UINT8 picid; - - do - { - if (myfgets(s, MAXLINELEN, f)) - { - if (s[0] == '\n') - break; - - word = strtok(s, " "); - if (word) - strupr(word); - else - break; - - if (fastcmp(word, "SCENETEXT")) - { - char *scenetext = NULL; - char *buffer; - const int bufferlen = 4096; - - for (i = 0; i < MAXLINELEN; i++) - { - if (s[i] == '=') - { - scenetext = &s[i+2]; - break; - } - } - - if (!scenetext) - { - Z_Free(cutscenes[num]->scene[scenenum].text); - cutscenes[num]->scene[scenenum].text = NULL; - continue; - } - - for (i = 0; i < MAXLINELEN; i++) - { - if (s[i] == '\0') - { - s[i] = '\n'; - s[i+1] = '\0'; - break; - } - } - - buffer = Z_Malloc(4096, PU_STATIC, NULL); - strcpy(buffer, scenetext); - - strcat(buffer, - myhashfgets(scenetext, bufferlen - - strlen(buffer) - 1, f)); - - // A cutscene overwriting another one... - Z_Free(cutscenes[num]->scene[scenenum].text); - - cutscenes[num]->scene[scenenum].text = Z_StrDup(buffer); - - Z_Free(buffer); - - continue; - } - - word2 = strtok(NULL, " = "); - if (word2) - strupr(word2); - else - break; - - if (word2[strlen(word2)-1] == '\n') - word2[strlen(word2)-1] = '\0'; - i = atoi(word2); - usi = (UINT16)i; - - - if (fastcmp(word, "NUMBEROFPICS")) - { - cutscenes[num]->scene[scenenum].numpics = (UINT8)i; - } - else if (fastncmp(word, "PIC", 3)) - { - picid = (UINT8)atoi(word + 3); - if (picid > 8 || picid == 0) - { - deh_warning("CutSceneScene %d: unknown word '%s'", num, word); - continue; - } - --picid; - - if (fastcmp(word+4, "NAME")) - { - strncpy(cutscenes[num]->scene[scenenum].picname[picid], word2, 8); - } - else if (fastcmp(word+4, "HIRES")) - { - cutscenes[num]->scene[scenenum].pichires[picid] = (UINT8)(i || word2[0] == 'T' || word2[0] == 'Y'); - } - else if (fastcmp(word+4, "DURATION")) - { - cutscenes[num]->scene[scenenum].picduration[picid] = usi; - } - else if (fastcmp(word+4, "XCOORD")) - { - cutscenes[num]->scene[scenenum].xcoord[picid] = usi; - } - else if (fastcmp(word+4, "YCOORD")) - { - cutscenes[num]->scene[scenenum].ycoord[picid] = usi; - } - else - deh_warning("CutSceneScene %d: unknown word '%s'", num, word); - } - else if (fastcmp(word, "MUSIC")) - { - strncpy(cutscenes[num]->scene[scenenum].musswitch, word2, 7); - cutscenes[num]->scene[scenenum].musswitch[6] = 0; - } -#ifdef MUSICSLOT_COMPATIBILITY - 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 - else if (fastcmp(word, "MUSICTRACK")) - { - cutscenes[num]->scene[scenenum].musswitchflags = ((UINT16)i) & MUSIC_TRACKMASK; - } - else if (fastcmp(word, "MUSICPOS")) - { - cutscenes[num]->scene[scenenum].musswitchposition = (UINT32)get_number(word2); - } - else if (fastcmp(word, "MUSICLOOP")) - { - cutscenes[num]->scene[scenenum].musicloop = (UINT8)(i || word2[0] == 'T' || word2[0] == 'Y'); - } - else if (fastcmp(word, "TEXTXPOS")) - { - cutscenes[num]->scene[scenenum].textxpos = usi; - } - else if (fastcmp(word, "TEXTYPOS")) - { - cutscenes[num]->scene[scenenum].textypos = usi; - } - else if (fastcmp(word, "FADEINID")) - { - cutscenes[num]->scene[scenenum].fadeinid = (UINT8)i; - } - else if (fastcmp(word, "FADEOUTID")) - { - cutscenes[num]->scene[scenenum].fadeoutid = (UINT8)i; - } - else if (fastcmp(word, "FADECOLOR")) - { - cutscenes[num]->scene[scenenum].fadecolor = (UINT8)i; - } - else - deh_warning("CutSceneScene %d: unknown word '%s'", num, word); - } - } while (!myfeof(f)); // finish when the line is empty - - Z_Free(s); -} - -static void readcutscene(MYFILE *f, INT32 num) -{ - char *s = Z_Malloc(MAXLINELEN, PU_STATIC, NULL); - char *word; - char *word2; - char *tmp; - INT32 value; - - // Allocate memory for this cutscene if we don't yet have any - if (!cutscenes[num]) - cutscenes[num] = Z_Calloc(sizeof (cutscene_t), PU_STATIC, NULL); - - do - { - if (myfgets(s, MAXLINELEN, f)) - { - if (s[0] == '\n') - break; - - tmp = strchr(s, '#'); - if (tmp) - *tmp = '\0'; - if (s == tmp) - continue; // Skip comment lines, but don't break. - - word = strtok(s, " "); - if (word) - strupr(word); - else - break; - - word2 = strtok(NULL, " "); - if (word2) - value = atoi(word2); - else - { - deh_warning("No value for token %s", word); - continue; - } - - if (fastcmp(word, "NUMSCENES")) - { - cutscenes[num]->numscenes = value; - } - else if (fastcmp(word, "SCENE")) - { - if (1 <= value && value <= 128) - { - readcutscenescene(f, num, value - 1); - } - else - deh_warning("Scene number %d out of range (1 - 128)", value); - - } - else - deh_warning("Cutscene %d: unknown word '%s', Scene expected.", num, word); - } - } while (!myfeof(f)); // finish when the line is empty - - Z_Free(s); -} - -static void readtextpromptpage(MYFILE *f, INT32 num, INT32 pagenum) -{ - char *s = Z_Calloc(MAXLINELEN, PU_STATIC, NULL); - char *word; - char *word2; - INT32 i; - UINT16 usi; - UINT8 picid; - - do - { - if (myfgets(s, MAXLINELEN, f)) - { - if (s[0] == '\n') - break; - - word = strtok(s, " "); - if (word) - strupr(word); - else - break; - - if (fastcmp(word, "PAGETEXT")) - { - char *pagetext = NULL; - char *buffer; - const int bufferlen = 4096; - - for (i = 0; i < MAXLINELEN; i++) - { - if (s[i] == '=') - { - pagetext = &s[i+2]; - break; - } - } - - if (!pagetext) - { - Z_Free(textprompts[num]->page[pagenum].text); - textprompts[num]->page[pagenum].text = NULL; - continue; - } - - for (i = 0; i < MAXLINELEN; i++) - { - if (s[i] == '\0') - { - s[i] = '\n'; - s[i+1] = '\0'; - break; - } - } - - buffer = Z_Malloc(4096, PU_STATIC, NULL); - strcpy(buffer, pagetext); - - // \todo trim trailing whitespace before the # - // and also support # at the end of a PAGETEXT with no line break - - strcat(buffer, - myhashfgets(pagetext, bufferlen - - strlen(buffer) - 1, f)); - - // A text prompt overwriting another one... - Z_Free(textprompts[num]->page[pagenum].text); - - textprompts[num]->page[pagenum].text = Z_StrDup(buffer); - - Z_Free(buffer); - - continue; - } - - word2 = strtok(NULL, " = "); - if (word2) - strupr(word2); - else - break; - - if (word2[strlen(word2)-1] == '\n') - word2[strlen(word2)-1] = '\0'; - i = atoi(word2); - usi = (UINT16)i; - - // copypasta from readcutscenescene - if (fastcmp(word, "NUMBEROFPICS")) - { - textprompts[num]->page[pagenum].numpics = (UINT8)i; - } - else if (fastcmp(word, "PICMODE")) - { - UINT8 picmode = 0; // PROMPT_PIC_PERSIST - if (usi == 1 || word2[0] == 'L') picmode = PROMPT_PIC_LOOP; - else if (usi == 2 || word2[0] == 'D' || word2[0] == 'H') picmode = PROMPT_PIC_DESTROY; - textprompts[num]->page[pagenum].picmode = picmode; - } - else if (fastcmp(word, "PICTOLOOP")) - textprompts[num]->page[pagenum].pictoloop = (UINT8)i; - else if (fastcmp(word, "PICTOSTART")) - textprompts[num]->page[pagenum].pictostart = (UINT8)i; - else if (fastcmp(word, "PICSMETAPAGE")) - { - if (usi && usi <= textprompts[num]->numpages) - { - UINT8 metapagenum = usi - 1; - - textprompts[num]->page[pagenum].numpics = textprompts[num]->page[metapagenum].numpics; - textprompts[num]->page[pagenum].picmode = textprompts[num]->page[metapagenum].picmode; - textprompts[num]->page[pagenum].pictoloop = textprompts[num]->page[metapagenum].pictoloop; - textprompts[num]->page[pagenum].pictostart = textprompts[num]->page[metapagenum].pictostart; - - for (picid = 0; picid < MAX_PROMPT_PICS; picid++) - { - strncpy(textprompts[num]->page[pagenum].picname[picid], textprompts[num]->page[metapagenum].picname[picid], 8); - textprompts[num]->page[pagenum].pichires[picid] = textprompts[num]->page[metapagenum].pichires[picid]; - textprompts[num]->page[pagenum].picduration[picid] = textprompts[num]->page[metapagenum].picduration[picid]; - textprompts[num]->page[pagenum].xcoord[picid] = textprompts[num]->page[metapagenum].xcoord[picid]; - textprompts[num]->page[pagenum].ycoord[picid] = textprompts[num]->page[metapagenum].ycoord[picid]; - } - } - } - else if (fastncmp(word, "PIC", 3)) - { - picid = (UINT8)atoi(word + 3); - if (picid > MAX_PROMPT_PICS || picid == 0) - { - deh_warning("textpromptscene %d: unknown word '%s'", num, word); - continue; - } - --picid; - - if (fastcmp(word+4, "NAME")) - { - strncpy(textprompts[num]->page[pagenum].picname[picid], word2, 8); - } - else if (fastcmp(word+4, "HIRES")) - { - textprompts[num]->page[pagenum].pichires[picid] = (UINT8)(i || word2[0] == 'T' || word2[0] == 'Y'); - } - else if (fastcmp(word+4, "DURATION")) - { - textprompts[num]->page[pagenum].picduration[picid] = usi; - } - else if (fastcmp(word+4, "XCOORD")) - { - textprompts[num]->page[pagenum].xcoord[picid] = usi; - } - else if (fastcmp(word+4, "YCOORD")) - { - textprompts[num]->page[pagenum].ycoord[picid] = usi; - } - else - deh_warning("textpromptscene %d: unknown word '%s'", num, word); - } - else if (fastcmp(word, "MUSIC")) - { - strncpy(textprompts[num]->page[pagenum].musswitch, word2, 7); - textprompts[num]->page[pagenum].musswitch[6] = 0; - } -#ifdef MUSICSLOT_COMPATIBILITY - else if (fastcmp(word, "MUSICSLOT")) - { - i = get_mus(word2, true); - if (i && i <= 1035) - snprintf(textprompts[num]->page[pagenum].musswitch, 7, "%sM", G_BuildMapName(i)); - else if (i && i <= 1050) - strncpy(textprompts[num]->page[pagenum].musswitch, compat_special_music_slots[i - 1036], 7); - else - textprompts[num]->page[pagenum].musswitch[0] = 0; // becomes empty string - textprompts[num]->page[pagenum].musswitch[6] = 0; - } -#endif - else if (fastcmp(word, "MUSICTRACK")) - { - textprompts[num]->page[pagenum].musswitchflags = ((UINT16)i) & MUSIC_TRACKMASK; - } - else if (fastcmp(word, "MUSICLOOP")) - { - textprompts[num]->page[pagenum].musicloop = (UINT8)(i || word2[0] == 'T' || word2[0] == 'Y'); - } - // end copypasta from readcutscenescene - else if (fastcmp(word, "NAME")) - { - if (*word2 != '\0') - { - INT32 j; - - // HACK: Add yellow control char now - // so the drawing function doesn't call it repeatedly - char name[34]; - name[0] = '\x82'; // color yellow - name[1] = 0; - strncat(name, word2, 33); - name[33] = 0; - - // Replace _ with ' ' - for (j = 0; j < 32 && name[j]; j++) - { - if (name[j] == '_') - name[j] = ' '; - } - - strncpy(textprompts[num]->page[pagenum].name, name, 32); - } - else - *textprompts[num]->page[pagenum].name = '\0'; - } - else if (fastcmp(word, "ICON")) - strncpy(textprompts[num]->page[pagenum].iconname, word2, 8); - else if (fastcmp(word, "ICONALIGN")) - textprompts[num]->page[pagenum].rightside = (i || word2[0] == 'R'); - else if (fastcmp(word, "ICONFLIP")) - textprompts[num]->page[pagenum].iconflip = (i || word2[0] == 'T' || word2[0] == 'Y'); - else if (fastcmp(word, "LINES")) - textprompts[num]->page[pagenum].lines = usi; - else if (fastcmp(word, "BACKCOLOR")) - { - INT32 backcolor; - if (i == 0 || fastcmp(word2, "WHITE")) backcolor = 0; - else if (i == 1 || fastcmp(word2, "GRAY") || fastcmp(word2, "GREY") || - fastcmp(word2, "BLACK")) backcolor = 1; - else if (i == 2 || fastcmp(word2, "SEPIA")) backcolor = 2; - else if (i == 3 || fastcmp(word2, "BROWN")) backcolor = 3; - else if (i == 4 || fastcmp(word2, "PINK")) backcolor = 4; - else if (i == 5 || fastcmp(word2, "RASPBERRY")) backcolor = 5; - else if (i == 6 || fastcmp(word2, "RED")) backcolor = 6; - else if (i == 7 || fastcmp(word2, "CREAMSICLE")) backcolor = 7; - else if (i == 8 || fastcmp(word2, "ORANGE")) backcolor = 8; - else if (i == 9 || fastcmp(word2, "GOLD")) backcolor = 9; - else if (i == 10 || fastcmp(word2, "YELLOW")) backcolor = 10; - else if (i == 11 || fastcmp(word2, "EMERALD")) backcolor = 11; - else if (i == 12 || fastcmp(word2, "GREEN")) backcolor = 12; - else if (i == 13 || fastcmp(word2, "CYAN") || fastcmp(word2, "AQUA")) backcolor = 13; - else if (i == 14 || fastcmp(word2, "STEEL")) backcolor = 14; - else if (i == 15 || fastcmp(word2, "PERIWINKLE")) backcolor = 15; - else if (i == 16 || fastcmp(word2, "BLUE")) backcolor = 16; - else if (i == 17 || fastcmp(word2, "PURPLE")) backcolor = 17; - else if (i == 18 || fastcmp(word2, "LAVENDER")) backcolor = 18; - else if (i >= 256 && i < 512) backcolor = i; // non-transparent palette index - else if (i < 0) backcolor = INT32_MAX; // CONS_BACKCOLOR user-configured - else backcolor = 1; // default gray - textprompts[num]->page[pagenum].backcolor = backcolor; - } - else if (fastcmp(word, "ALIGN")) - { - UINT8 align = 0; // left - if (usi == 1 || word2[0] == 'R') align = 1; - else if (usi == 2 || word2[0] == 'C' || word2[0] == 'M') align = 2; - textprompts[num]->page[pagenum].align = align; - } - else if (fastcmp(word, "VERTICALALIGN")) - { - UINT8 align = 0; // top - if (usi == 1 || word2[0] == 'B') align = 1; - else if (usi == 2 || word2[0] == 'C' || word2[0] == 'M') align = 2; - textprompts[num]->page[pagenum].verticalalign = align; - } - else if (fastcmp(word, "TEXTSPEED")) - textprompts[num]->page[pagenum].textspeed = get_number(word2); - else if (fastcmp(word, "TEXTSFX")) - textprompts[num]->page[pagenum].textsfx = get_number(word2); - else if (fastcmp(word, "HIDEHUD")) - { - UINT8 hidehud = 0; - if ((word2[0] == 'F' && (word2[1] == 'A' || !word2[1])) || word2[0] == 'N') hidehud = 0; // false - else if (usi == 1 || word2[0] == 'T' || word2[0] == 'Y') hidehud = 1; // true (hide appropriate HUD elements) - else if (usi == 2 || word2[0] == 'A' || (word2[0] == 'F' && word2[1] == 'O')) hidehud = 2; // force (hide all HUD elements) - textprompts[num]->page[pagenum].hidehud = hidehud; - } - else if (fastcmp(word, "METAPAGE")) - { - if (usi && usi <= textprompts[num]->numpages) - { - UINT8 metapagenum = usi - 1; - - strncpy(textprompts[num]->page[pagenum].name, textprompts[num]->page[metapagenum].name, 32); - strncpy(textprompts[num]->page[pagenum].iconname, textprompts[num]->page[metapagenum].iconname, 8); - textprompts[num]->page[pagenum].rightside = textprompts[num]->page[metapagenum].rightside; - textprompts[num]->page[pagenum].iconflip = textprompts[num]->page[metapagenum].iconflip; - textprompts[num]->page[pagenum].lines = textprompts[num]->page[metapagenum].lines; - textprompts[num]->page[pagenum].backcolor = textprompts[num]->page[metapagenum].backcolor; - textprompts[num]->page[pagenum].align = textprompts[num]->page[metapagenum].align; - textprompts[num]->page[pagenum].verticalalign = textprompts[num]->page[metapagenum].verticalalign; - textprompts[num]->page[pagenum].textspeed = textprompts[num]->page[metapagenum].textspeed; - textprompts[num]->page[pagenum].textsfx = textprompts[num]->page[metapagenum].textsfx; - textprompts[num]->page[pagenum].hidehud = textprompts[num]->page[metapagenum].hidehud; - - // music: don't copy, else each page change may reset the music - } - } - else if (fastcmp(word, "TAG")) - strncpy(textprompts[num]->page[pagenum].tag, word2, 33); - else if (fastcmp(word, "NEXTPROMPT")) - textprompts[num]->page[pagenum].nextprompt = usi; - else if (fastcmp(word, "NEXTPAGE")) - textprompts[num]->page[pagenum].nextpage = usi; - else if (fastcmp(word, "NEXTTAG")) - strncpy(textprompts[num]->page[pagenum].nexttag, word2, 33); - else if (fastcmp(word, "TIMETONEXT")) - textprompts[num]->page[pagenum].timetonext = get_number(word2); - else - deh_warning("PromptPage %d: unknown word '%s'", num, word); - } - } while (!myfeof(f)); // finish when the line is empty - - Z_Free(s); -} - -static void readtextprompt(MYFILE *f, INT32 num) -{ - char *s = Z_Malloc(MAXLINELEN, PU_STATIC, NULL); - char *word; - char *word2; - char *tmp; - INT32 value; - - // Allocate memory for this prompt if we don't yet have any - if (!textprompts[num]) - textprompts[num] = Z_Calloc(sizeof (textprompt_t), PU_STATIC, NULL); - - do - { - if (myfgets(s, MAXLINELEN, f)) - { - if (s[0] == '\n') - break; - - tmp = strchr(s, '#'); - if (tmp) - *tmp = '\0'; - if (s == tmp) - continue; // Skip comment lines, but don't break. - - word = strtok(s, " "); - if (word) - strupr(word); - else - break; - - word2 = strtok(NULL, " "); - if (word2) - value = atoi(word2); - else - { - deh_warning("No value for token %s", word); - continue; - } - - if (fastcmp(word, "NUMPAGES")) - { - textprompts[num]->numpages = min(max(value, 0), MAX_PAGES); - } - else if (fastcmp(word, "PAGE")) - { - if (1 <= value && value <= MAX_PAGES) - { - textprompts[num]->page[value - 1].backcolor = 1; // default to gray - textprompts[num]->page[value - 1].hidehud = 1; // hide appropriate HUD elements - readtextpromptpage(f, num, value - 1); - } - else - deh_warning("Page number %d out of range (1 - %d)", value, MAX_PAGES); - - } - else - deh_warning("Prompt %d: unknown word '%s', Page expected.", num, word); - } - } while (!myfeof(f)); // finish when the line is empty - - Z_Free(s); -} - -static void readmenu(MYFILE *f, INT32 num) -{ - char *s = Z_Malloc(MAXLINELEN, PU_STATIC, NULL); - char *word = s; - char *word2; - char *tmp; - INT32 value; - - do - { - if (myfgets(s, MAXLINELEN, f)) - { - if (s[0] == '\n') - break; - - // First remove trailing newline, if there is one - tmp = strchr(s, '\n'); - if (tmp) - *tmp = '\0'; - - tmp = strchr(s, '#'); - if (tmp) - *tmp = '\0'; - if (s == tmp) - continue; // Skip comment lines, but don't break. - - // Get the part before the " = " - tmp = strchr(s, '='); - if (tmp) - *(tmp-1) = '\0'; - else - break; - strupr(word); - - // Now get the part after - word2 = (tmp += 2); - strupr(word2); - - value = atoi(word2); // used for numerical settings - - if (fastcmp(word, "BACKGROUNDNAME")) - { - strncpy(menupres[num].bgname, word2, 8); - titlechanged = true; - } - else if (fastcmp(word, "HIDEBACKGROUND")) - { - menupres[num].bghide = (boolean)(value || word2[0] == 'T' || word2[0] == 'Y'); - titlechanged = true; - } - else if (fastcmp(word, "BACKGROUNDCOLOR")) - { - menupres[num].bgcolor = get_number(word2); - titlechanged = true; - } - else if (fastcmp(word, "HIDETITLEPICS") || fastcmp(word, "HIDEPICS") || fastcmp(word, "TITLEPICSHIDE")) - { - // true by default, except MM_MAIN - menupres[num].hidetitlepics = (boolean)(value || word2[0] == 'T' || word2[0] == 'Y'); - titlechanged = true; - } - else if (fastcmp(word, "TITLEPICSMODE")) - { - if (fastcmp(word2, "USER")) - menupres[num].ttmode = TTMODE_USER; - else if (fastcmp(word2, "ALACROIX")) - menupres[num].ttmode = TTMODE_ALACROIX; - else if (fastcmp(word2, "HIDE") || fastcmp(word2, "HIDDEN") || fastcmp(word2, "NONE")) - { - menupres[num].ttmode = TTMODE_USER; - menupres[num].ttname[0] = 0; - menupres[num].hidetitlepics = true; - } - else // if (fastcmp(word2, "OLD") || fastcmp(word2, "SSNTAILS")) - menupres[num].ttmode = TTMODE_OLD; - titlechanged = true; - } - else if (fastcmp(word, "TITLEPICSSCALE")) - { - // Don't handle Alacroix special case here; see Maincfg section. - menupres[num].ttscale = max(1, min(8, (UINT8)get_number(word2))); - titlechanged = true; - } - else if (fastcmp(word, "TITLEPICSNAME")) - { - strncpy(menupres[num].ttname, word2, 9); - titlechanged = true; - } - else if (fastcmp(word, "TITLEPICSX")) - { - menupres[num].ttx = (INT16)get_number(word2); - titlechanged = true; - } - else if (fastcmp(word, "TITLEPICSY")) - { - menupres[num].tty = (INT16)get_number(word2); - titlechanged = true; - } - else if (fastcmp(word, "TITLEPICSLOOP")) - { - menupres[num].ttloop = (INT16)get_number(word2); - titlechanged = true; - } - else if (fastcmp(word, "TITLEPICSTICS")) - { - menupres[num].tttics = (UINT16)get_number(word2); - titlechanged = true; - } - else if (fastcmp(word, "TITLESCROLLSPEED") || fastcmp(word, "TITLESCROLLXSPEED") - || fastcmp(word, "SCROLLSPEED") || fastcmp(word, "SCROLLXSPEED")) - { - menupres[num].titlescrollxspeed = get_number(word2); - titlechanged = true; - } - else if (fastcmp(word, "TITLESCROLLYSPEED") || fastcmp(word, "SCROLLYSPEED")) - { - menupres[num].titlescrollyspeed = get_number(word2); - titlechanged = true; - } - else if (fastcmp(word, "MUSIC")) - { - strncpy(menupres[num].musname, word2, 7); - menupres[num].musname[6] = 0; - titlechanged = true; - } -#ifdef MUSICSLOT_COMPATIBILITY - else if (fastcmp(word, "MUSICSLOT")) - { - value = get_mus(word2, true); - if (value && value <= 1035) - snprintf(menupres[num].musname, 7, "%sM", G_BuildMapName(value)); - else if (value && value <= 1050) - strncpy(menupres[num].musname, compat_special_music_slots[value - 1036], 7); - else - menupres[num].musname[0] = 0; // becomes empty string - menupres[num].musname[6] = 0; - titlechanged = true; - } -#endif - else if (fastcmp(word, "MUSICTRACK")) - { - menupres[num].mustrack = ((UINT16)value - 1); - titlechanged = true; - } - else if (fastcmp(word, "MUSICLOOP")) - { - // true by default except MM_MAIN - menupres[num].muslooping = (value || word2[0] == 'T' || word2[0] == 'Y'); - titlechanged = true; - } - else if (fastcmp(word, "NOMUSIC")) - { - menupres[num].musstop = (value || word2[0] == 'T' || word2[0] == 'Y'); - titlechanged = true; - } - else if (fastcmp(word, "IGNOREMUSIC")) - { - menupres[num].musignore = (value || word2[0] == 'T' || word2[0] == 'Y'); - titlechanged = true; - } - else if (fastcmp(word, "FADESTRENGTH")) - { - // one-based, <= 0 means use default value. 1-32 - menupres[num].fadestrength = get_number(word2)-1; - titlechanged = true; - } - else if (fastcmp(word, "NOENTERBUBBLE")) - { - menupres[num].enterbubble = !(value || word2[0] == 'T' || word2[0] == 'Y'); - titlechanged = true; - } - else if (fastcmp(word, "NOEXITBUBBLE")) - { - menupres[num].exitbubble = !(value || word2[0] == 'T' || word2[0] == 'Y'); - titlechanged = true; - } - else if (fastcmp(word, "ENTERTAG")) - { - menupres[num].entertag = get_number(word2); - titlechanged = true; - } - else if (fastcmp(word, "EXITTAG")) - { - menupres[num].exittag = get_number(word2); - titlechanged = true; - } - else if (fastcmp(word, "ENTERWIPE")) - { - menupres[num].enterwipe = get_number(word2); - titlechanged = true; - } - else if (fastcmp(word, "EXITWIPE")) - { - menupres[num].exitwipe = get_number(word2); - titlechanged = true; - } - } - } while (!myfeof(f)); // finish when the line is empty - - Z_Free(s); -} - -static void readhuditem(MYFILE *f, INT32 num) -{ - char *s = Z_Malloc(MAXLINELEN, PU_STATIC, NULL); - char *word = s; - char *word2; - char *tmp; - INT32 i; - - do - { - if (myfgets(s, MAXLINELEN, f)) - { - if (s[0] == '\n') - break; - - // First remove trailing newline, if there is one - tmp = strchr(s, '\n'); - if (tmp) - *tmp = '\0'; - - tmp = strchr(s, '#'); - if (tmp) - *tmp = '\0'; - if (s == tmp) - continue; // Skip comment lines, but don't break. - - // Get the part before the " = " - tmp = strchr(s, '='); - if (tmp) - *(tmp-1) = '\0'; - else - break; - strupr(word); - - // Now get the part after - word2 = tmp += 2; - strupr(word2); - - i = atoi(word2); // used for numerical settings - - if (fastcmp(word, "X")) - { - hudinfo[num].x = i; - } - else if (fastcmp(word, "Y")) - { - hudinfo[num].y = i; - } - else if (fastcmp(word, "F")) - { - hudinfo[num].f = i; - } - else - deh_warning("Level header %d: unknown word '%s'", num, word); - } - } while (!myfeof(f)); // finish when the line is empty - - Z_Free(s); -} - -/* -Sprite number = 10 -Sprite subnumber = 32968 -Duration = 200 -Next frame = 200 -*/ - -/** Action pointer for reading actions from Dehacked lumps. - */ -typedef struct -{ - actionf_t action; ///< Function pointer corresponding to the actual action. - const char *name; ///< Name of the action in ALL CAPS. -} actionpointer_t; - -/** Array mapping action names to action functions. - * Names must be in ALL CAPS for case insensitive comparisons. - */ -static actionpointer_t actionpointers[] = -{ - {{A_Explode}, "A_EXPLODE"}, - {{A_Pain}, "A_PAIN"}, - {{A_Fall}, "A_FALL"}, - {{A_MonitorPop}, "A_MONITORPOP"}, - {{A_GoldMonitorPop}, "A_GOLDMONITORPOP"}, - {{A_GoldMonitorRestore}, "A_GOLDMONITORRESTORE"}, - {{A_GoldMonitorSparkle}, "A_GOLDMONITORSPARKLE"}, - {{A_Look}, "A_LOOK"}, - {{A_Chase}, "A_CHASE"}, - {{A_FaceStabChase}, "A_FACESTABCHASE"}, - {{A_FaceStabRev}, "A_FACESTABREV"}, - {{A_FaceStabHurl}, "A_FACESTABHURL"}, - {{A_FaceStabMiss}, "A_FACESTABMISS"}, - {{A_StatueBurst}, "A_STATUEBURST"}, - {{A_FaceTarget}, "A_FACETARGET"}, - {{A_FaceTracer}, "A_FACETRACER"}, - {{A_Scream}, "A_SCREAM"}, - {{A_BossDeath}, "A_BOSSDEATH"}, - {{A_CustomPower}, "A_CUSTOMPOWER"}, - {{A_GiveWeapon}, "A_GIVEWEAPON"}, - {{A_RingBox}, "A_RINGBOX"}, - {{A_Invincibility}, "A_INVINCIBILITY"}, - {{A_SuperSneakers}, "A_SUPERSNEAKERS"}, - {{A_BunnyHop}, "A_BUNNYHOP"}, - {{A_BubbleSpawn}, "A_BUBBLESPAWN"}, - {{A_FanBubbleSpawn}, "A_FANBUBBLESPAWN"}, - {{A_BubbleRise}, "A_BUBBLERISE"}, - {{A_BubbleCheck}, "A_BUBBLECHECK"}, - {{A_AwardScore}, "A_AWARDSCORE"}, - {{A_ExtraLife}, "A_EXTRALIFE"}, - {{A_GiveShield}, "A_GIVESHIELD"}, - {{A_GravityBox}, "A_GRAVITYBOX"}, - {{A_ScoreRise}, "A_SCORERISE"}, - {{A_AttractChase}, "A_ATTRACTCHASE"}, - {{A_DropMine}, "A_DROPMINE"}, - {{A_FishJump}, "A_FISHJUMP"}, - {{A_ThrownRing}, "A_THROWNRING"}, - {{A_SetSolidSteam}, "A_SETSOLIDSTEAM"}, - {{A_UnsetSolidSteam}, "A_UNSETSOLIDSTEAM"}, - {{A_SignSpin}, "A_SIGNSPIN"}, - {{A_SignPlayer}, "A_SIGNPLAYER"}, - {{A_OverlayThink}, "A_OVERLAYTHINK"}, - {{A_JetChase}, "A_JETCHASE"}, - {{A_JetbThink}, "A_JETBTHINK"}, - {{A_JetgThink}, "A_JETGTHINK"}, - {{A_JetgShoot}, "A_JETGSHOOT"}, - {{A_ShootBullet}, "A_SHOOTBULLET"}, - {{A_MinusDigging}, "A_MINUSDIGGING"}, - {{A_MinusPopup}, "A_MINUSPOPUP"}, - {{A_MinusCheck}, "A_MINUSCHECK"}, - {{A_ChickenCheck}, "A_CHICKENCHECK"}, - {{A_MouseThink}, "A_MOUSETHINK"}, - {{A_DetonChase}, "A_DETONCHASE"}, - {{A_CapeChase}, "A_CAPECHASE"}, - {{A_RotateSpikeBall}, "A_ROTATESPIKEBALL"}, - {{A_SlingAppear}, "A_SLINGAPPEAR"}, - {{A_UnidusBall}, "A_UNIDUSBALL"}, - {{A_RockSpawn}, "A_ROCKSPAWN"}, - {{A_SetFuse}, "A_SETFUSE"}, - {{A_CrawlaCommanderThink}, "A_CRAWLACOMMANDERTHINK"}, - {{A_SmokeTrailer}, "A_SMOKETRAILER"}, - {{A_RingExplode}, "A_RINGEXPLODE"}, - {{A_OldRingExplode}, "A_OLDRINGEXPLODE"}, - {{A_MixUp}, "A_MIXUP"}, - {{A_RecyclePowers}, "A_RECYCLEPOWERS"}, - {{A_Boss1Chase}, "A_BOSS1CHASE"}, - {{A_FocusTarget}, "A_FOCUSTARGET"}, - {{A_Boss2Chase}, "A_BOSS2CHASE"}, - {{A_Boss2Pogo}, "A_BOSS2POGO"}, - {{A_BossZoom}, "A_BOSSZOOM"}, - {{A_BossScream}, "A_BOSSSCREAM"}, - {{A_Boss2TakeDamage}, "A_BOSS2TAKEDAMAGE"}, - {{A_Boss7Chase}, "A_BOSS7CHASE"}, - {{A_GoopSplat}, "A_GOOPSPLAT"}, - {{A_Boss2PogoSFX}, "A_BOSS2POGOSFX"}, - {{A_Boss2PogoTarget}, "A_BOSS2POGOTARGET"}, - {{A_BossJetFume}, "A_BOSSJETFUME"}, - {{A_EggmanBox}, "A_EGGMANBOX"}, - {{A_TurretFire}, "A_TURRETFIRE"}, - {{A_SuperTurretFire}, "A_SUPERTURRETFIRE"}, - {{A_TurretStop}, "A_TURRETSTOP"}, - {{A_JetJawRoam}, "A_JETJAWROAM"}, - {{A_JetJawChomp}, "A_JETJAWCHOMP"}, - {{A_PointyThink}, "A_POINTYTHINK"}, - {{A_CheckBuddy}, "A_CHECKBUDDY"}, - {{A_HoodFire}, "A_HOODFIRE"}, - {{A_HoodThink}, "A_HOODTHINK"}, - {{A_HoodFall}, "A_HOODFALL"}, - {{A_ArrowBonks}, "A_ARROWBONKS"}, - {{A_SnailerThink}, "A_SNAILERTHINK"}, - {{A_SharpChase}, "A_SHARPCHASE"}, - {{A_SharpSpin}, "A_SHARPSPIN"}, - {{A_SharpDecel}, "A_SHARPDECEL"}, - {{A_CrushstaceanWalk}, "A_CRUSHSTACEANWALK"}, - {{A_CrushstaceanPunch}, "A_CRUSHSTACEANPUNCH"}, - {{A_CrushclawAim}, "A_CRUSHCLAWAIM"}, - {{A_CrushclawLaunch}, "A_CRUSHCLAWLAUNCH"}, - {{A_VultureVtol}, "A_VULTUREVTOL"}, - {{A_VultureCheck}, "A_VULTURECHECK"}, - {{A_VultureHover}, "A_VULTUREHOVER"}, - {{A_VultureBlast}, "A_VULTUREBLAST"}, - {{A_VultureFly}, "A_VULTUREFLY"}, - {{A_SkimChase}, "A_SKIMCHASE"}, - {{A_1upThinker}, "A_1UPTHINKER"}, - {{A_SkullAttack}, "A_SKULLATTACK"}, - {{A_LobShot}, "A_LOBSHOT"}, - {{A_FireShot}, "A_FIRESHOT"}, - {{A_SuperFireShot}, "A_SUPERFIRESHOT"}, - {{A_BossFireShot}, "A_BOSSFIRESHOT"}, - {{A_Boss7FireMissiles}, "A_BOSS7FIREMISSILES"}, - {{A_Boss1Laser}, "A_BOSS1LASER"}, - {{A_Boss4Reverse}, "A_BOSS4REVERSE"}, - {{A_Boss4SpeedUp}, "A_BOSS4SPEEDUP"}, - {{A_Boss4Raise}, "A_BOSS4RAISE"}, - {{A_SparkFollow}, "A_SPARKFOLLOW"}, - {{A_BuzzFly}, "A_BUZZFLY"}, - {{A_GuardChase}, "A_GUARDCHASE"}, - {{A_EggShield}, "A_EGGSHIELD"}, - {{A_SetReactionTime}, "A_SETREACTIONTIME"}, - {{A_Boss1Spikeballs}, "A_BOSS1SPIKEBALLS"}, - {{A_Boss3TakeDamage}, "A_BOSS3TAKEDAMAGE"}, - {{A_Boss3Path}, "A_BOSS3PATH"}, - {{A_Boss3ShockThink}, "A_BOSS3SHOCKTHINK"}, - {{A_LinedefExecute}, "A_LINEDEFEXECUTE"}, - {{A_PlaySeeSound}, "A_PLAYSEESOUND"}, - {{A_PlayAttackSound}, "A_PLAYATTACKSOUND"}, - {{A_PlayActiveSound}, "A_PLAYACTIVESOUND"}, - {{A_SpawnObjectAbsolute}, "A_SPAWNOBJECTABSOLUTE"}, - {{A_SpawnObjectRelative}, "A_SPAWNOBJECTRELATIVE"}, - {{A_ChangeAngleRelative}, "A_CHANGEANGLERELATIVE"}, - {{A_ChangeAngleAbsolute}, "A_CHANGEANGLEABSOLUTE"}, - {{A_RollAngle}, "A_ROLLANGLE"}, - {{A_ChangeRollAngleRelative},"A_CHANGEROLLANGLERELATIVE"}, - {{A_ChangeRollAngleAbsolute},"A_CHANGEROLLANGLEABSOLUTE"}, - {{A_PlaySound}, "A_PLAYSOUND"}, - {{A_FindTarget}, "A_FINDTARGET"}, - {{A_FindTracer}, "A_FINDTRACER"}, - {{A_SetTics}, "A_SETTICS"}, - {{A_SetRandomTics}, "A_SETRANDOMTICS"}, - {{A_ChangeColorRelative}, "A_CHANGECOLORRELATIVE"}, - {{A_ChangeColorAbsolute}, "A_CHANGECOLORABSOLUTE"}, - {{A_Dye}, "A_DYE"}, - {{A_MoveRelative}, "A_MOVERELATIVE"}, - {{A_MoveAbsolute}, "A_MOVEABSOLUTE"}, - {{A_Thrust}, "A_THRUST"}, - {{A_ZThrust}, "A_ZTHRUST"}, - {{A_SetTargetsTarget}, "A_SETTARGETSTARGET"}, - {{A_SetObjectFlags}, "A_SETOBJECTFLAGS"}, - {{A_SetObjectFlags2}, "A_SETOBJECTFLAGS2"}, - {{A_RandomState}, "A_RANDOMSTATE"}, - {{A_RandomStateRange}, "A_RANDOMSTATERANGE"}, - {{A_DualAction}, "A_DUALACTION"}, - {{A_RemoteAction}, "A_REMOTEACTION"}, - {{A_ToggleFlameJet}, "A_TOGGLEFLAMEJET"}, - {{A_OrbitNights}, "A_ORBITNIGHTS"}, - {{A_GhostMe}, "A_GHOSTME"}, - {{A_SetObjectState}, "A_SETOBJECTSTATE"}, - {{A_SetObjectTypeState}, "A_SETOBJECTTYPESTATE"}, - {{A_KnockBack}, "A_KNOCKBACK"}, - {{A_PushAway}, "A_PUSHAWAY"}, - {{A_RingDrain}, "A_RINGDRAIN"}, - {{A_SplitShot}, "A_SPLITSHOT"}, - {{A_MissileSplit}, "A_MISSILESPLIT"}, - {{A_MultiShot}, "A_MULTISHOT"}, - {{A_InstaLoop}, "A_INSTALOOP"}, - {{A_Custom3DRotate}, "A_CUSTOM3DROTATE"}, - {{A_SearchForPlayers}, "A_SEARCHFORPLAYERS"}, - {{A_CheckRandom}, "A_CHECKRANDOM"}, - {{A_CheckTargetRings}, "A_CHECKTARGETRINGS"}, - {{A_CheckRings}, "A_CHECKRINGS"}, - {{A_CheckTotalRings}, "A_CHECKTOTALRINGS"}, - {{A_CheckHealth}, "A_CHECKHEALTH"}, - {{A_CheckRange}, "A_CHECKRANGE"}, - {{A_CheckHeight}, "A_CHECKHEIGHT"}, - {{A_CheckTrueRange}, "A_CHECKTRUERANGE"}, - {{A_CheckThingCount}, "A_CHECKTHINGCOUNT"}, - {{A_CheckAmbush}, "A_CHECKAMBUSH"}, - {{A_CheckCustomValue}, "A_CHECKCUSTOMVALUE"}, - {{A_CheckCusValMemo}, "A_CHECKCUSVALMEMO"}, - {{A_SetCustomValue}, "A_SETCUSTOMVALUE"}, - {{A_UseCusValMemo}, "A_USECUSVALMEMO"}, - {{A_RelayCustomValue}, "A_RELAYCUSTOMVALUE"}, - {{A_CusValAction}, "A_CUSVALACTION"}, - {{A_ForceStop}, "A_FORCESTOP"}, - {{A_ForceWin}, "A_FORCEWIN"}, - {{A_SpikeRetract}, "A_SPIKERETRACT"}, - {{A_InfoState}, "A_INFOSTATE"}, - {{A_Repeat}, "A_REPEAT"}, - {{A_SetScale}, "A_SETSCALE"}, - {{A_RemoteDamage}, "A_REMOTEDAMAGE"}, - {{A_HomingChase}, "A_HOMINGCHASE"}, - {{A_TrapShot}, "A_TRAPSHOT"}, - {{A_VileTarget}, "A_VILETARGET"}, - {{A_VileAttack}, "A_VILEATTACK"}, - {{A_VileFire}, "A_VILEFIRE"}, - {{A_BrakChase}, "A_BRAKCHASE"}, - {{A_BrakFireShot}, "A_BRAKFIRESHOT"}, - {{A_BrakLobShot}, "A_BRAKLOBSHOT"}, - {{A_NapalmScatter}, "A_NAPALMSCATTER"}, - {{A_SpawnFreshCopy}, "A_SPAWNFRESHCOPY"}, - {{A_FlickySpawn}, "A_FLICKYSPAWN"}, - {{A_FlickyCenter}, "A_FLICKYCENTER"}, - {{A_FlickyAim}, "A_FLICKYAIM"}, - {{A_FlickyFly}, "A_FLICKYFLY"}, - {{A_FlickySoar}, "A_FLICKYSOAR"}, - {{A_FlickyCoast}, "A_FLICKYCOAST"}, - {{A_FlickyHop}, "A_FLICKYHOP"}, - {{A_FlickyFlounder}, "A_FLICKYFLOUNDER"}, - {{A_FlickyCheck}, "A_FLICKYCHECK"}, - {{A_FlickyHeightCheck}, "A_FLICKYHEIGHTCHECK"}, - {{A_FlickyFlutter}, "A_FLICKYFLUTTER"}, - {{A_FlameParticle}, "A_FLAMEPARTICLE"}, - {{A_FadeOverlay}, "A_FADEOVERLAY"}, - {{A_Boss5Jump}, "A_BOSS5JUMP"}, - {{A_LightBeamReset}, "A_LIGHTBEAMRESET"}, - {{A_MineExplode}, "A_MINEEXPLODE"}, - {{A_MineRange}, "A_MINERANGE"}, - {{A_ConnectToGround}, "A_CONNECTTOGROUND"}, - {{A_SpawnParticleRelative}, "A_SPAWNPARTICLERELATIVE"}, - {{A_MultiShotDist}, "A_MULTISHOTDIST"}, - {{A_WhoCaresIfYourSonIsABee},"A_WHOCARESIFYOURSONISABEE"}, - {{A_ParentTriesToSleep}, "A_PARENTTRIESTOSLEEP"}, - {{A_CryingToMomma}, "A_CRYINGTOMOMMA"}, - {{A_CheckFlags2}, "A_CHECKFLAGS2"}, - {{A_Boss5FindWaypoint}, "A_BOSS5FINDWAYPOINT"}, - {{A_DoNPCSkid}, "A_DONPCSKID"}, - {{A_DoNPCPain}, "A_DONPCPAIN"}, - {{A_PrepareRepeat}, "A_PREPAREREPEAT"}, - {{A_Boss5ExtraRepeat}, "A_BOSS5EXTRAREPEAT"}, - {{A_Boss5Calm}, "A_BOSS5CALM"}, - {{A_Boss5CheckOnGround}, "A_BOSS5CHECKONGROUND"}, - {{A_Boss5CheckFalling}, "A_BOSS5CHECKFALLING"}, - {{A_Boss5PinchShot}, "A_BOSS5PINCHSHOT"}, - {{A_Boss5MakeItRain}, "A_BOSS5MAKEITRAIN"}, - {{A_Boss5MakeJunk}, "A_BOSS5MAKEJUNK"}, - {{A_LookForBetter}, "A_LOOKFORBETTER"}, - {{A_Boss5BombExplode}, "A_BOSS5BOMBEXPLODE"}, - {{A_DustDevilThink}, "A_DUSTDEVILTHINK"}, - {{A_TNTExplode}, "A_TNTEXPLODE"}, - {{A_DebrisRandom}, "A_DEBRISRANDOM"}, - {{A_TrainCameo}, "A_TRAINCAMEO"}, - {{A_TrainCameo2}, "A_TRAINCAMEO2"}, - {{A_CanarivoreGas}, "A_CANARIVOREGAS"}, - {{A_KillSegments}, "A_KILLSEGMENTS"}, - {{A_SnapperSpawn}, "A_SNAPPERSPAWN"}, - {{A_SnapperThinker}, "A_SNAPPERTHINKER"}, - {{A_SaloonDoorSpawn}, "A_SALOONDOORSPAWN"}, - {{A_MinecartSparkThink}, "A_MINECARTSPARKTHINK"}, - {{A_ModuloToState}, "A_MODULOTOSTATE"}, - {{A_LavafallRocks}, "A_LAVAFALLROCKS"}, - {{A_LavafallLava}, "A_LAVAFALLLAVA"}, - {{A_FallingLavaCheck}, "A_FALLINGLAVACHECK"}, - {{A_FireShrink}, "A_FIRESHRINK"}, - {{A_SpawnPterabytes}, "A_SPAWNPTERABYTES"}, - {{A_PterabyteHover}, "A_PTERABYTEHOVER"}, - {{A_RolloutSpawn}, "A_ROLLOUTSPAWN"}, - {{A_RolloutRock}, "A_ROLLOUTROCK"}, - {{A_DragonbomberSpawn}, "A_DRAGONBOMERSPAWN"}, - {{A_DragonWing}, "A_DRAGONWING"}, - {{A_DragonSegment}, "A_DRAGONSEGMENT"}, - {{A_ChangeHeight}, "A_CHANGEHEIGHT"}, - {{NULL}, "NONE"}, - - // This NULL entry must be the last in the list - {{NULL}, NULL}, -}; - -static void readframe(MYFILE *f, INT32 num) -{ - char *s = Z_Malloc(MAXLINELEN, PU_STATIC, NULL); - char *word1; - char *word2 = NULL; - char *tmp; - - do - { - if (myfgets(s, MAXLINELEN, f)) - { - if (s[0] == '\n') - break; - - tmp = strchr(s, '#'); - if (tmp) - *tmp = '\0'; - if (s == tmp) - continue; // Skip comment lines, but don't break. - - word1 = strtok(s, " "); - if (word1) - strupr(word1); - else - break; - - word2 = strtok(NULL, " = "); - if (word2) - strupr(word2); - else - break; - if (word2[strlen(word2)-1] == '\n') - word2[strlen(word2)-1] = '\0'; - - if (fastcmp(word1, "SPRITENUMBER") || fastcmp(word1, "SPRITENAME")) - { - states[num].sprite = get_sprite(word2); - } - else if (fastcmp(word1, "SPRITESUBNUMBER") || fastcmp(word1, "SPRITEFRAME")) - { - states[num].frame = (INT32)get_number(word2); // So the FF_ flags get calculated - } - else if (fastcmp(word1, "DURATION")) - { - states[num].tics = (INT32)get_number(word2); // So TICRATE can be used - } - else if (fastcmp(word1, "NEXT")) - { - states[num].nextstate = get_state(word2); - } - else if (fastcmp(word1, "VAR1")) - { - states[num].var1 = (INT32)get_number(word2); - } - else if (fastcmp(word1, "VAR2")) - { - states[num].var2 = (INT32)get_number(word2); - } - else if (fastcmp(word1, "ACTION")) - { - size_t z; - boolean found = false; - char actiontocompare[32]; - - memset(actiontocompare, 0x00, sizeof(actiontocompare)); - strlcpy(actiontocompare, word2, sizeof (actiontocompare)); - strupr(actiontocompare); - - for (z = 0; z < 32; z++) - { - if (actiontocompare[z] == '\n' || actiontocompare[z] == '\r') - { - actiontocompare[z] = '\0'; - break; - } - } - - for (z = 0; actionpointers[z].name; z++) - { - if (actionpointers[z].action.acv == states[num].action.acv) - break; - } - - z = 0; - found = LUA_SetLuaAction(&states[num], actiontocompare); - if (!found) - while (actionpointers[z].name) - { - if (fastcmp(actiontocompare, actionpointers[z].name)) - { - states[num].action = actionpointers[z].action; - states[num].action.acv = actionpointers[z].action.acv; // assign - states[num].action.acp1 = actionpointers[z].action.acp1; - found = true; - break; - } - z++; - } - - if (!found) - deh_warning("Unknown action %s", actiontocompare); - } - else - deh_warning("Frame %d: unknown word '%s'", num, word1); - } - } while (!myfeof(f)); - - Z_Free(s); -} - -static void readsound(MYFILE *f, INT32 num) -{ - char *s = Z_Malloc(MAXLINELEN, PU_STATIC, NULL); - char *word; - char *word2; - char *tmp; - INT32 value; - - do - { - if (myfgets(s, MAXLINELEN, f)) - { - if (s[0] == '\n') - break; - - tmp = strchr(s, '#'); - if (tmp) - *tmp = '\0'; - if (s == tmp) - continue; // Skip comment lines, but don't break. - - word = strtok(s, " "); - if (word) - strupr(word); - else - break; - - word2 = strtok(NULL, " "); - if (word2) - value = atoi(word2); - else - { - deh_warning("No value for token %s", word); - continue; - } - - if (fastcmp(word, "SINGULAR")) - { - S_sfx[num].singularity = value; - } - else if (fastcmp(word, "PRIORITY")) - { - S_sfx[num].priority = value; - } - else if (fastcmp(word, "FLAGS")) - { - S_sfx[num].pitch = value; - } - else if (fastcmp(word, "CAPTION") || fastcmp(word, "DESCRIPTION")) - { - deh_strlcpy(S_sfx[num].caption, word2, - sizeof(S_sfx[num].caption), va("Sound effect %d: caption", num)); - } - else - deh_warning("Sound %d : unknown word '%s'",num,word); - } - } while (!myfeof(f)); - - Z_Free(s); -} - -/** Checks if a game data file name for a mod is good. - * "Good" means that it contains only alphanumerics, _, and -; - * ends in ".dat"; has at least one character before the ".dat"; - * and is not "gamedata.dat" (tested case-insensitively). - * - * Assumption: that gamedata.dat is the only .dat file that will - * ever be treated specially by the game. - * - * Note: Check for the tail ".dat" case-insensitively since at - * present, we get passed the filename in all uppercase. - * - * \param s Filename string to check. - * \return True if the filename is good. - * \sa readmaincfg() - * \author Graue - */ -static boolean GoodDataFileName(const char *s) -{ - const char *p; - const char *tail = ".dat"; - - for (p = s; *p != '\0'; p++) - if (!isalnum(*p) && *p != '_' && *p != '-' && *p != '.') - return false; - - p = s + strlen(s) - strlen(tail); - if (p <= s) return false; // too short - if (!fasticmp(p, tail)) return false; // doesn't end in .dat - if (fasticmp(s, "gamedata.dat")) return false; - - return true; -} - -static void reademblemdata(MYFILE *f, INT32 num) -{ - char *s = Z_Malloc(MAXLINELEN, PU_STATIC, NULL); - char *word = s; - char *word2; - char *tmp; - INT32 value; - - memset(&emblemlocations[num-1], 0, sizeof(emblem_t)); - - do - { - if (myfgets(s, MAXLINELEN, f)) - { - if (s[0] == '\n') - break; - - // First remove trailing newline, if there is one - tmp = strchr(s, '\n'); - if (tmp) - *tmp = '\0'; - - tmp = strchr(s, '#'); - if (tmp) - *tmp = '\0'; - if (s == tmp) - continue; // Skip comment lines, but don't break. - - // Get the part before the " = " - tmp = strchr(s, '='); - if (tmp) - *(tmp-1) = '\0'; - else - break; - strupr(word); - - // Now get the part after - word2 = tmp += 2; - value = atoi(word2); // used for numerical settings - - // Up here to allow lowercase in hints - if (fastcmp(word, "HINT")) - { - while ((tmp = strchr(word2, '\\'))) - *tmp = '\n'; - deh_strlcpy(emblemlocations[num-1].hint, word2, sizeof (emblemlocations[num-1].hint), va("Emblem %d: hint", num)); - continue; - } - strupr(word2); - - if (fastcmp(word, "TYPE")) - { - if (fastcmp(word2, "GLOBAL")) - 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, "MAP")) - emblemlocations[num-1].type = ET_MAP; - 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; - } - else if (fastcmp(word, "TAG")) - emblemlocations[num-1].tag = (INT16)value; - else if (fastcmp(word, "MAPNUM")) - { - // Support using the actual map name, - // i.e., Level AB, Level FZ, etc. - - // Convert to map number - if (word2[0] >= 'A' && word2[0] <= 'Z') - value = M_MapNumber(word2[0], word2[1]); - - emblemlocations[num-1].level = (INT16)value; - } - else if (fastcmp(word, "SPRITE")) - { - if (word2[0] >= 'A' && word2[0] <= 'Z') - value = word2[0]; - else - value += 'A'-1; - - if (value < 'A' || value > 'Z') - deh_warning("Emblem %d: sprite must be from A - Z (1 - 26)", num); - else - emblemlocations[num-1].sprite = (UINT8)value; - } - else if (fastcmp(word, "COLOR")) - emblemlocations[num-1].color = get_number(word2); - else if (fastcmp(word, "VAR")) - emblemlocations[num-1].var = get_number(word2); - else - deh_warning("Emblem %d: unknown word '%s'", num, word); - } - } while (!myfeof(f)); - - // Default sprite and color definitions for lazy people like me - if (!emblemlocations[num-1].sprite) switch (emblemlocations[num-1].type) - { - case ET_RINGS: - emblemlocations[num-1].sprite = 'R'; break; - case ET_SCORE: case ET_NGRADE: - emblemlocations[num-1].sprite = 'S'; break; - case ET_TIME: case ET_NTIME: - emblemlocations[num-1].sprite = 'T'; break; - default: - emblemlocations[num-1].sprite = 'A'; break; - } - if (!emblemlocations[num-1].color) switch (emblemlocations[num-1].type) - { - case ET_RINGS: - emblemlocations[num-1].color = SKINCOLOR_GOLD; break; - case ET_SCORE: - emblemlocations[num-1].color = SKINCOLOR_BROWN; break; - case ET_NGRADE: - emblemlocations[num-1].color = SKINCOLOR_TEAL; break; - case ET_TIME: case ET_NTIME: - emblemlocations[num-1].color = SKINCOLOR_GREY; break; - default: - emblemlocations[num-1].color = SKINCOLOR_BLUE; break; - } - - Z_Free(s); -} - -static void readextraemblemdata(MYFILE *f, INT32 num) -{ - char *s = Z_Malloc(MAXLINELEN, PU_STATIC, NULL); - char *word = s; - char *word2; - char *tmp; - INT32 value; - - memset(&extraemblems[num-1], 0, sizeof(extraemblem_t)); - - do - { - if (myfgets(s, MAXLINELEN, f)) - { - if (s[0] == '\n') - break; - - // First remove trailing newline, if there is one - tmp = strchr(s, '\n'); - if (tmp) - *tmp = '\0'; - - tmp = strchr(s, '#'); - if (tmp) - *tmp = '\0'; - if (s == tmp) - continue; // Skip comment lines, but don't break. - - // Get the part before the " = " - tmp = strchr(s, '='); - if (tmp) - *(tmp-1) = '\0'; - else - break; - strupr(word); - - // Now get the part after - word2 = tmp += 2; - - 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)); - else if (fastcmp(word, "OBJECTIVE")) - deh_strlcpy(extraemblems[num-1].description, word2, - 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, "SHOWCONDITIONSET")) - extraemblems[num-1].showconditionset = (UINT8)value; - else - { - strupr(word2); - if (fastcmp(word, "SPRITE")) - { - if (word2[0] >= 'A' && word2[0] <= 'Z') - value = word2[0]; - else - value += 'A'-1; - - if (value < 'A' || value > 'Z') - deh_warning("Emblem %d: sprite must be from A - Z (1 - 26)", num); - else - extraemblems[num-1].sprite = (UINT8)value; - } - else if (fastcmp(word, "COLOR")) - extraemblems[num-1].color = get_number(word2); - else - deh_warning("Extra emblem %d: unknown word '%s'", num, word); - } - } - } while (!myfeof(f)); - - if (!extraemblems[num-1].sprite) - extraemblems[num-1].sprite = 'X'; - if (!extraemblems[num-1].color) - extraemblems[num-1].color = SKINCOLOR_BLUE; - - Z_Free(s); -} - -static void readunlockable(MYFILE *f, INT32 num) -{ - char *s = Z_Malloc(MAXLINELEN, PU_STATIC, NULL); - char *word = s; - char *word2; - char *tmp; - INT32 i; - - memset(&unlockables[num], 0, sizeof(unlockable_t)); - unlockables[num].objective[0] = '/'; - - do - { - if (myfgets(s, MAXLINELEN, f)) - { - if (s[0] == '\n') - break; - - // First remove trailing newline, if there is one - tmp = strchr(s, '\n'); - if (tmp) - *tmp = '\0'; - - tmp = strchr(s, '#'); - if (tmp) - *tmp = '\0'; - if (s == tmp) - continue; // Skip comment lines, but don't break. - - // Get the part before the " = " - tmp = strchr(s, '='); - if (tmp) - *(tmp-1) = '\0'; - else - break; - strupr(word); - - // Now get the part after - word2 = tmp += 2; - - 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)); - else if (fastcmp(word, "OBJECTIVE")) - deh_strlcpy(unlockables[num].objective, word2, - sizeof (unlockables[num].objective), va("Unlockable %d: objective", num)); - else - { - strupr(word2); - if (fastcmp(word, "HEIGHT")) - unlockables[num].height = (UINT16)i; - else if (fastcmp(word, "CONDITIONSET")) - unlockables[num].conditionset = (UINT8)i; - else if (fastcmp(word, "SHOWCONDITIONSET")) - unlockables[num].showconditionset = (UINT8)i; - else if (fastcmp(word, "NOCECHO")) - unlockables[num].nocecho = (UINT8)(i || word2[0] == 'T' || word2[0] == 'Y'); - else if (fastcmp(word, "NOCHECKLIST")) - unlockables[num].nochecklist = (UINT8)(i || word2[0] == 'T' || word2[0] == 'Y'); - else if (fastcmp(word, "TYPE")) - { - if (fastcmp(word2, "NONE")) - unlockables[num].type = SECRET_NONE; - else if (fastcmp(word2, "ITEMFINDER")) - unlockables[num].type = SECRET_ITEMFINDER; - else if (fastcmp(word2, "EMBLEMHINTS")) - unlockables[num].type = SECRET_EMBLEMHINTS; - else if (fastcmp(word2, "PANDORA")) - unlockables[num].type = SECRET_PANDORA; - else if (fastcmp(word2, "CREDITS")) - unlockables[num].type = SECRET_CREDITS; - else if (fastcmp(word2, "RECORDATTACK")) - unlockables[num].type = SECRET_RECORDATTACK; - else if (fastcmp(word2, "NIGHTSMODE")) - unlockables[num].type = SECRET_NIGHTSMODE; - else if (fastcmp(word2, "HEADER")) - unlockables[num].type = SECRET_HEADER; - else if (fastcmp(word2, "LEVELSELECT")) - unlockables[num].type = SECRET_LEVELSELECT; - else if (fastcmp(word2, "WARP")) - unlockables[num].type = SECRET_WARP; - else if (fastcmp(word2, "SOUNDTEST")) - unlockables[num].type = SECRET_SOUNDTEST; - else - unlockables[num].type = (INT16)i; - } - else if (fastcmp(word, "VAR")) - { - // Support using the actual map name, - // i.e., Level AB, Level FZ, etc. - - // Convert to map number - if (word2[0] >= 'A' && word2[0] <= 'Z') - i = M_MapNumber(word2[0], word2[1]); - - unlockables[num].variable = (INT16)i; - } - else - deh_warning("Unlockable %d: unknown word '%s'", num+1, word); - } - } - } while (!myfeof(f)); // finish when the line is empty - - Z_Free(s); -} - -static const char NIGHTSGRADE_LIST[] = { - 'F', // GRADE_F - 'E', // GRADE_E - 'D', // GRADE_D - 'C', // GRADE_C - 'B', // GRADE_B - 'A', // GRADE_A - 'S', // GRADE_S - '\0' -}; - -#define PARAMCHECK(n) do { if (!params[n]) { deh_warning("Too few parameters, need %d", n); return; }} while (0) -static void readcondition(UINT8 set, UINT32 id, char *word2) -{ - INT32 i; - char *params[4]; // condition, requirement, extra info, extra info - char *spos; - - conditiontype_t ty; - INT32 re; - INT16 x1 = 0, x2 = 0; - - INT32 offset = 0; - - spos = strtok(word2, " "); - - for (i = 0; i < 4; ++i) - { - if (spos != NULL) - { - params[i] = spos; - spos = strtok(NULL, " "); - } - else - params[i] = NULL; - } - - if (!params[0]) - { - deh_warning("condition line is empty"); - return; - } - - if (fastcmp(params[0], "PLAYTIME")) - { - PARAMCHECK(1); - ty = UC_PLAYTIME; - re = atoi(params[1]); - } - else if (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], "OVERALLSCORE") - || (++offset && fastcmp(params[0], "OVERALLTIME")) - || (++offset && fastcmp(params[0], "OVERALLRINGS"))) - { - PARAMCHECK(1); - ty = UC_OVERALLSCORE + offset; - re = atoi(params[1]); - } - 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; - - // Convert to map number if it appears to be one - if (params[1][0] >= 'A' && params[1][0] <= 'Z') - re = M_MapNumber(params[1][0], params[1][1]); - else - re = atoi(params[1]); - - if (re < 0 || re >= NUMMAPS) - { - deh_warning("Level number %d out of range (1 - %d)", re, NUMMAPS); - return; - } - } - else if ((offset=0) || fastcmp(params[0], "MAPSCORE") - || (++offset && fastcmp(params[0], "MAPTIME")) - || (++offset && fastcmp(params[0], "MAPRINGS"))) - { - PARAMCHECK(2); - ty = UC_MAPSCORE + offset; - re = atoi(params[2]); - - // Convert to map number if it appears to be one - if (params[1][0] >= 'A' && params[1][0] <= 'Z') - x1 = (INT16)M_MapNumber(params[1][0], params[1][1]); - else - x1 = (INT16)atoi(params[1]); - - if (x1 < 0 || x1 >= NUMMAPS) - { - deh_warning("Level number %d out of range (1 - %d)", re, NUMMAPS); - return; - } - } - else if ((offset=0) || fastcmp(params[0], "NIGHTSSCORE") - || (++offset && fastcmp(params[0], "NIGHTSTIME")) - || (++offset && fastcmp(params[0], "NIGHTSGRADE"))) - { - PARAMCHECK(2); // one optional one - - ty = UC_NIGHTSSCORE + offset; - i = (params[3] ? 3 : 2); - if (fastncmp("GRADE_",params[i],6)) - { - char *p = params[i]+6; - for (re = 0; NIGHTSGRADE_LIST[re]; re++) - if (*p == NIGHTSGRADE_LIST[re]) - break; - if (!NIGHTSGRADE_LIST[re]) - { - deh_warning("Invalid NiGHTS grade %s\n", params[i]); - return; - } - } - else - re = atoi(params[i]); - - // Convert to map number if it appears to be one - if (params[1][0] >= 'A' && params[1][0] <= 'Z') - x1 = (INT16)M_MapNumber(params[1][0], params[1][1]); - else - x1 = (INT16)atoi(params[1]); - - if (x1 < 0 || x1 >= NUMMAPS) - { - deh_warning("Level number %d out of range (1 - %d)", re, NUMMAPS); - return; - } - - // Mare number (0 for overall) - if (params[3]) // Only if we actually got 3 params (so the second one == mare and not requirement) - x2 = (INT16)atoi(params[2]); - else - x2 = 0; - - } - else if (fastcmp(params[0], "TRIGGER")) - { - PARAMCHECK(1); - ty = UC_TRIGGER; - re = atoi(params[1]); - - // constrained by 32 bits - if (re < 0 || re > 31) - { - deh_warning("Trigger ID %d out of range (0 - 31)", re); - return; - } - } - else if (fastcmp(params[0], "TOTALEMBLEMS")) - { - PARAMCHECK(1); - ty = UC_TOTALEMBLEMS; - re = atoi(params[1]); - } - else if (fastcmp(params[0], "EMBLEM")) - { - PARAMCHECK(1); - ty = UC_EMBLEM; - re = atoi(params[1]); - - if (re <= 0 || re > MAXEMBLEMS) - { - deh_warning("Emblem %d out of range (1 - %d)", re, MAXEMBLEMS); - return; - } - } - else if (fastcmp(params[0], "EXTRAEMBLEM")) - { - PARAMCHECK(1); - ty = UC_EXTRAEMBLEM; - re = atoi(params[1]); - - if (re <= 0 || re > MAXEXTRAEMBLEMS) - { - deh_warning("Extra emblem %d out of range (1 - %d)", re, MAXEXTRAEMBLEMS); - return; - } - } - else if (fastcmp(params[0], "CONDITIONSET")) - { - PARAMCHECK(1); - ty = UC_CONDITIONSET; - re = atoi(params[1]); - - if (re <= 0 || re > MAXCONDITIONSETS) - { - deh_warning("Condition set %d out of range (1 - %d)", re, MAXCONDITIONSETS); - return; - } - } - else - { - deh_warning("Invalid condition name %s", params[0]); - return; - } - - M_AddRawCondition(set, (UINT8)id, ty, re, x1, x2); -} -#undef PARAMCHECK - -static void readconditionset(MYFILE *f, UINT8 setnum) -{ - char *s = Z_Malloc(MAXLINELEN, PU_STATIC, NULL); - char *word = s; - char *word2; - char *tmp; - UINT8 id; - UINT8 previd = 0; - - M_ClearConditionSet(setnum); - - do - { - if (myfgets(s, MAXLINELEN, f)) - { - if (s[0] == '\n') - break; - - // First remove trailing newline, if there is one - tmp = strchr(s, '\n'); - if (tmp) - *tmp = '\0'; - - tmp = strchr(s, '#'); - if (tmp) - *tmp = '\0'; - if (s == tmp) - continue; // Skip comment lines, but don't break. - - // Get the part before the " = " - tmp = strchr(s, '='); - if (tmp) - *(tmp-1) = '\0'; - else - break; - strupr(word); - - // Now get the part after - word2 = tmp += 2; - strupr(word2); - - if (fastncmp(word, "CONDITION", 9)) - { - id = (UINT8)atoi(word + 9); - if (id == 0) - { - deh_warning("Condition set %d: unknown word '%s'", setnum, word); - continue; - } - else if (previd > id) - { - // out of order conditions can cause problems, so enforce proper order - deh_warning("Condition set %d: conditions are out of order, ignoring this line", setnum); - continue; - } - previd = id; - - readcondition(setnum, id, word2); - } - else - deh_warning("Condition set %d: unknown word '%s'", setnum, word); - } - } while (!myfeof(f)); // finish when the line is empty - - Z_Free(s); -} - -static void readmaincfg(MYFILE *f) -{ - char *s = Z_Malloc(MAXLINELEN, PU_STATIC, NULL); - char *word = s; - char *word2; - char *tmp; - INT32 value; - - do - { - if (myfgets(s, MAXLINELEN, f)) - { - if (s[0] == '\n') - break; - - // First remove trailing newline, if there is one - tmp = strchr(s, '\n'); - if (tmp) - *tmp = '\0'; - - tmp = strchr(s, '#'); - if (tmp) - *tmp = '\0'; - if (s == tmp) - continue; // Skip comment lines, but don't break. - - // Get the part before the " = " - tmp = strchr(s, '='); - if (tmp) - *(tmp-1) = '\0'; - else - break; - strupr(word); - - // Now get the part after - word2 = tmp += 2; - strupr(word2); - - value = atoi(word2); // used for numerical settings - - if (fastcmp(word, "EXECCFG")) - { - if (strchr(word2, '.')) - COM_BufAddText(va("exec %s\n", word2)); - else - { - lumpnum_t lumpnum; - char newname[9]; - - strncpy(newname, word2, 8); - - newname[8] = '\0'; - - lumpnum = W_CheckNumForName(newname); - - if (lumpnum == LUMPERROR || W_LumpLength(lumpnum) == 0) - CONS_Debug(DBG_SETUP, "SOC Error: script lump %s not found/not valid.\n", newname); - else - COM_BufInsertText(W_CacheLumpNum(lumpnum, PU_CACHE)); - } - } - - else if (fastcmp(word, "SPSTAGE_START")) - { - // Support using the actual map name, - // i.e., Level AB, Level FZ, etc. - - // Convert to map number - if (word2[0] >= 'A' && word2[0] <= 'Z') - value = M_MapNumber(word2[0], word2[1]); - else - value = get_number(word2); - - spstage_start = spmarathon_start = (INT16)value; - } - else if (fastcmp(word, "SPMARATHON_START")) - { - // Support using the actual map name, - // i.e., Level AB, Level FZ, etc. - - // Convert to map number - if (word2[0] >= 'A' && word2[0] <= 'Z') - value = M_MapNumber(word2[0], word2[1]); - else - value = get_number(word2); - - spmarathon_start = (INT16)value; - } - else if (fastcmp(word, "SSTAGE_START")) - { - // Support using the actual map name, - // i.e., Level AB, Level FZ, etc. - - // Convert to map number - if (word2[0] >= 'A' && word2[0] <= 'Z') - value = M_MapNumber(word2[0], word2[1]); - else - value = get_number(word2); - - sstage_start = (INT16)value; - sstage_end = (INT16)(sstage_start+7); // 7 special stages total plus one weirdo - } - else if (fastcmp(word, "SMPSTAGE_START")) - { - // Support using the actual map name, - // i.e., Level AB, Level FZ, etc. - - // Convert to map number - if (word2[0] >= 'A' && word2[0] <= 'Z') - value = M_MapNumber(word2[0], word2[1]); - else - value = get_number(word2); - - smpstage_start = (INT16)value; - smpstage_end = (INT16)(smpstage_start+6); // 7 special stages total - } - else if (fastcmp(word, "REDTEAM")) - { - skincolor_redteam = (UINT16)get_number(word2); - } - else if (fastcmp(word, "BLUETEAM")) - { - skincolor_blueteam = (UINT16)get_number(word2); - } - else if (fastcmp(word, "REDRING")) - { - skincolor_redring = (UINT16)get_number(word2); - } - else if (fastcmp(word, "BLUERING")) - { - skincolor_bluering = (UINT16)get_number(word2); - } - else if (fastcmp(word, "INVULNTICS")) - { - invulntics = (UINT16)get_number(word2); - } - else if (fastcmp(word, "SNEAKERTICS")) - { - sneakertics = (UINT16)get_number(word2); - } - else if (fastcmp(word, "FLASHINGTICS")) - { - 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")) - { - extralifetics = (UINT16)get_number(word2); - } - else if (fastcmp(word, "NIGHTSLINKTICS")) - { - nightslinktics = (UINT16)get_number(word2); - } - else if (fastcmp(word, "GAMEOVERTICS")) - { - gameovertics = get_number(word2); - } - else if (fastcmp(word, "AMMOREMOVALTICS")) - { - ammoremovaltics = get_number(word2); - } - else if (fastcmp(word, "INTROTOPLAY")) - { - introtoplay = (UINT8)get_number(word2); - // range check, you morons. - if (introtoplay > 128) - introtoplay = 128; - introchanged = true; - } - else if (fastcmp(word, "CREDITSCUTSCENE")) - { - creditscutscene = (UINT8)get_number(word2); - // range check, you morons. - if (creditscutscene > 128) - creditscutscene = 128; - } - else if (fastcmp(word, "USEBLACKROCK")) - { - useBlackRock = (UINT8)(value || word2[0] == 'T' || word2[0] == 'Y'); - } - else if (fastcmp(word, "LOOPTITLE")) - { - looptitle = (value || word2[0] == 'T' || word2[0] == 'Y'); - titlechanged = true; - } - else if (fastcmp(word, "TITLEMAP")) - { - // Support using the actual map name, - // i.e., Level AB, Level FZ, etc. - - // Convert to map number - if (word2[0] >= 'A' && word2[0] <= 'Z') - value = M_MapNumber(word2[0], word2[1]); - else - value = get_number(word2); - - titlemap = (INT16)value; - titlechanged = true; - } - else if (fastcmp(word, "HIDETITLEPICS") || fastcmp(word, "TITLEPICSHIDE")) - { - hidetitlepics = (boolean)(value || word2[0] == 'T' || word2[0] == 'Y'); - titlechanged = true; - } - else if (fastcmp(word, "TITLEPICSMODE")) - { - if (fastcmp(word2, "USER")) - ttmode = TTMODE_USER; - else if (fastcmp(word2, "ALACROIX")) - ttmode = TTMODE_ALACROIX; - else if (fastcmp(word2, "HIDE") || fastcmp(word2, "HIDDEN") || fastcmp(word2, "NONE")) - { - ttmode = TTMODE_USER; - ttname[0] = 0; - hidetitlepics = true; - } - else // if (fastcmp(word2, "OLD") || fastcmp(word2, "SSNTAILS")) - ttmode = TTMODE_OLD; - titlechanged = true; - } - else if (fastcmp(word, "TITLEPICSSCALE")) - { - ttscale = max(1, min(8, (UINT8)get_number(word2))); - titlechanged = true; - } - else if (fastcmp(word, "TITLEPICSSCALESAVAILABLE")) - { - // SPECIAL CASE for Alacroix: Comma-separated list of resolutions that are available - // for gfx loading. - ttavailable[0] = ttavailable[1] = ttavailable[2] = ttavailable[3] =\ - ttavailable[4] = ttavailable[5] = false; - - if (strstr(word2, "1") != NULL) - ttavailable[0] = true; - if (strstr(word2, "2") != NULL) - ttavailable[1] = true; - if (strstr(word2, "3") != NULL) - ttavailable[2] = true; - if (strstr(word2, "4") != NULL) - ttavailable[3] = true; - if (strstr(word2, "5") != NULL) - ttavailable[4] = true; - if (strstr(word2, "6") != NULL) - ttavailable[5] = true; - titlechanged = true; - } - else if (fastcmp(word, "TITLEPICSNAME")) - { - strncpy(ttname, word2, 9); - titlechanged = true; - } - else if (fastcmp(word, "TITLEPICSX")) - { - ttx = (INT16)get_number(word2); - titlechanged = true; - } - else if (fastcmp(word, "TITLEPICSY")) - { - tty = (INT16)get_number(word2); - titlechanged = true; - } - else if (fastcmp(word, "TITLEPICSLOOP")) - { - ttloop = (INT16)get_number(word2); - titlechanged = true; - } - else if (fastcmp(word, "TITLEPICSTICS")) - { - tttics = (UINT16)get_number(word2); - titlechanged = true; - } - else if (fastcmp(word, "TITLESCROLLSPEED") || fastcmp(word, "TITLESCROLLXSPEED")) - { - titlescrollxspeed = get_number(word2); - titlechanged = true; - } - else if (fastcmp(word, "TITLESCROLLYSPEED")) - { - titlescrollyspeed = get_number(word2); - titlechanged = true; - } - else if (fastcmp(word, "DISABLESPEEDADJUST")) - { - disableSpeedAdjust = (value || word2[0] == 'T' || word2[0] == 'Y'); - } - else if (fastcmp(word, "NUMDEMOS")) - { - numDemos = (UINT8)get_number(word2); - titlechanged = true; - } - else if (fastcmp(word, "DEMODELAYTIME")) - { - demoDelayTime = get_number(word2); - titlechanged = true; - } - else if (fastcmp(word, "DEMOIDLETIME")) - { - demoIdleTime = get_number(word2); - titlechanged = true; - } - else if (fastcmp(word, "USE1UPSOUND")) - { - use1upSound = (UINT8)(value || word2[0] == 'T' || word2[0] == 'Y'); - } - else if (fastcmp(word, "MAXXTRALIFE")) - { - maxXtraLife = (UINT8)get_number(word2); - } - else if (fastcmp(word, "USECONTINUES")) - { - useContinues = (UINT8)(value || word2[0] == 'T' || word2[0] == 'Y'); - } - - else if (fastcmp(word, "GAMEDATA")) - { - size_t filenamelen; - - // Check the data filename so that mods - // can't write arbitrary files. - if (!GoodDataFileName(word2)) - I_Error("Maincfg: bad data file name '%s'\n", word2); - - G_SaveGameData(); - strlcpy(gamedatafilename, word2, sizeof (gamedatafilename)); - strlwr(gamedatafilename); - savemoddata = true; - - // Also save a time attack folder - filenamelen = strlen(gamedatafilename)-4; // Strip off the extension - strncpy(timeattackfolder, gamedatafilename, min(filenamelen, sizeof (timeattackfolder))); - timeattackfolder[min(filenamelen, sizeof (timeattackfolder) - 1)] = '\0'; - - strcpy(savegamename, timeattackfolder); - strlcat(savegamename, "%u.ssg", sizeof(savegamename)); - // can't use sprintf since there is %u in savegamename - strcatbf(savegamename, srb2home, PATHSEP); - - strcpy(liveeventbackup, va("live%s.bkp", timeattackfolder)); - strcatbf(liveeventbackup, srb2home, PATHSEP); - - gamedataadded = true; - titlechanged = true; - } - else if (fastcmp(word, "RESETDATA")) - { - P_ResetData(value); - titlechanged = true; - } - else if (fastcmp(word, "CUSTOMVERSION")) - { - strlcpy(customversionstring, word2, sizeof (customversionstring)); - //titlechanged = true; - } - else if (fastcmp(word, "BOOTMAP")) - { - // Support using the actual map name, - // i.e., Level AB, Level FZ, etc. - - // Convert to map number - if (word2[0] >= 'A' && word2[0] <= 'Z') - value = M_MapNumber(word2[0], word2[1]); - else - value = get_number(word2); - - bootmap = (INT16)value; - //titlechanged = true; - } - else if (fastcmp(word, "STARTCHAR")) - { - startchar = (INT16)value; - char_on = -1; - } - else if (fastcmp(word, "TUTORIALMAP")) - { - // Support using the actual map name, - // i.e., Level AB, Level FZ, etc. - - // Convert to map number - if (word2[0] >= 'A' && word2[0] <= 'Z') - value = M_MapNumber(word2[0], word2[1]); - else - value = get_number(word2); - - tutorialmap = (INT16)value; - } - else - deh_warning("Maincfg: unknown word '%s'", word); - } - } while (!myfeof(f)); - - Z_Free(s); -} - -static void readwipes(MYFILE *f) -{ - char *s = Z_Malloc(MAXLINELEN, PU_STATIC, NULL); - char *word = s; - char *pword = word; - char *word2; - char *tmp; - INT32 value; - INT32 wipeoffset; - - do - { - if (myfgets(s, MAXLINELEN, f)) - { - if (s[0] == '\n') - break; - - // First remove trailing newline, if there is one - tmp = strchr(s, '\n'); - if (tmp) - *tmp = '\0'; - - tmp = strchr(s, '#'); - if (tmp) - *tmp = '\0'; - if (s == tmp) - continue; // Skip comment lines, but don't break. - - // Get the part before the " = " - tmp = strchr(s, '='); - if (tmp) - *(tmp-1) = '\0'; - else - break; - strupr(word); - - // Now get the part after - word2 = tmp += 2; - value = atoi(word2); // used for numerical settings - - if (value < -1 || value > 99) - { - deh_warning("Wipes: bad value '%s'", word2); - continue; - } - else if (value == -1) - value = UINT8_MAX; - - // error catching - wipeoffset = -1; - - if (fastncmp(word, "LEVEL_", 6)) - { - pword = word + 6; - if (fastcmp(pword, "TOBLACK")) - wipeoffset = wipe_level_toblack; - else if (fastcmp(pword, "FINAL")) - wipeoffset = wipe_level_final; - } - else if (fastncmp(word, "INTERMISSION_", 13)) - { - pword = word + 13; - if (fastcmp(pword, "TOBLACK")) - wipeoffset = wipe_intermission_toblack; - else if (fastcmp(pword, "FINAL")) - wipeoffset = wipe_intermission_final; - } - else if (fastncmp(word, "SPECINTER_", 10)) - { - pword = word + 10; - if (fastcmp(pword, "TOBLACK")) - wipeoffset = wipe_specinter_toblack; - else if (fastcmp(pword, "FINAL")) - wipeoffset = wipe_specinter_final; - } - else if (fastncmp(word, "MULTINTER_", 10)) - { - pword = word + 10; - if (fastcmp(pword, "TOBLACK")) - wipeoffset = wipe_multinter_toblack; - else if (fastcmp(pword, "FINAL")) - wipeoffset = wipe_multinter_final; - } - else if (fastncmp(word, "CONTINUING_", 11)) - { - pword = word + 11; - if (fastcmp(pword, "TOBLACK")) - wipeoffset = wipe_continuing_toblack; - else if (fastcmp(pword, "FINAL")) - wipeoffset = wipe_continuing_final; - } - else if (fastncmp(word, "TITLESCREEN_", 12)) - { - pword = word + 12; - if (fastcmp(pword, "TOBLACK")) - wipeoffset = wipe_titlescreen_toblack; - else if (fastcmp(pword, "FINAL")) - wipeoffset = wipe_titlescreen_final; - } - else if (fastncmp(word, "TIMEATTACK_", 11)) - { - pword = word + 11; - if (fastcmp(pword, "TOBLACK")) - wipeoffset = wipe_timeattack_toblack; - else if (fastcmp(pword, "FINAL")) - wipeoffset = wipe_timeattack_final; - } - else if (fastncmp(word, "CREDITS_", 8)) - { - pword = word + 8; - if (fastcmp(pword, "TOBLACK")) - wipeoffset = wipe_credits_toblack; - else if (fastcmp(pword, "FINAL")) - wipeoffset = wipe_credits_final; - else if (fastcmp(pword, "INTERMEDIATE")) - wipeoffset = wipe_credits_intermediate; - } - else if (fastncmp(word, "EVALUATION_", 11)) - { - pword = word + 11; - if (fastcmp(pword, "TOBLACK")) - wipeoffset = wipe_evaluation_toblack; - else if (fastcmp(pword, "FINAL")) - wipeoffset = wipe_evaluation_final; - } - else if (fastncmp(word, "GAMEEND_", 8)) - { - pword = word + 8; - if (fastcmp(pword, "TOBLACK")) - wipeoffset = wipe_gameend_toblack; - else if (fastcmp(pword, "FINAL")) - wipeoffset = wipe_gameend_final; - } - else if (fastncmp(word, "SPECLEVEL_", 10)) - { - pword = word + 10; - if (fastcmp(pword, "TOWHITE")) - wipeoffset = wipe_speclevel_towhite; - } - - if (wipeoffset < 0) - { - deh_warning("Wipes: unknown word '%s'", word); - continue; - } - - if (value == UINT8_MAX - && (wipeoffset <= wipe_level_toblack || wipeoffset >= wipe_speclevel_towhite)) - { - // Cannot disable non-toblack wipes - // (or the level toblack wipe, or the special towhite wipe) - deh_warning("Wipes: can't disable wipe of type '%s'", word); - continue; - } - - wipedefs[wipeoffset] = (UINT8)value; - } - } while (!myfeof(f)); - - Z_Free(s); -} - // Used when you do something invalid like read a bad item number // to prevent extra unnecessary errors static void ignorelines(MYFILE *f) @@ -5044,5596 +640,6 @@ void DEH_LoadDehackedLump(lumpnum_t lumpnum) DEH_LoadDehackedLumpPwad(WADFILENUM(lumpnum),LUMPNUM(lumpnum), false); } -//////////////////////////////////////////////////////////////////////////////// -// CRAZY LIST OF STATE NAMES AND ALL FROM HERE DOWN -// TODO: Make this all a seperate file or something, like part of info.c?? -// TODO: Read the list from a text lump in a WAD as necessary instead -// or something, don't just keep it all in memory like this. -// TODO: Make the lists public so we can start using actual mobj -// and state names in warning and error messages! :D - -// RegEx to generate this from info.h: ^\tS_([^,]+), --> \t"S_\1", -// I am leaving the prefixes solely for clarity to programmers, -// because sadly no one remembers this place while searching for full state names. -static const char *const STATE_LIST[] = { // array length left dynamic for sanity testing later. - "S_NULL", - "S_UNKNOWN", - "S_INVISIBLE", // state for invisible sprite - - "S_SPAWNSTATE", - "S_SEESTATE", - "S_MELEESTATE", - "S_MISSILESTATE", - "S_DEATHSTATE", - "S_XDEATHSTATE", - "S_RAISESTATE", - - // Thok - "S_THOK", - - // Player - "S_PLAY_STND", - "S_PLAY_WAIT", - "S_PLAY_WALK", - "S_PLAY_SKID", - "S_PLAY_RUN", - "S_PLAY_DASH", - "S_PLAY_PAIN", - "S_PLAY_STUN", - "S_PLAY_DEAD", - "S_PLAY_DRWN", - "S_PLAY_ROLL", - "S_PLAY_GASP", - "S_PLAY_JUMP", - "S_PLAY_SPRING", - "S_PLAY_FALL", - "S_PLAY_EDGE", - "S_PLAY_RIDE", - - // CA2_SPINDASH - "S_PLAY_SPINDASH", - - // CA_FLY/SWIM - "S_PLAY_FLY", - "S_PLAY_SWIM", - "S_PLAY_FLY_TIRED", - - // CA_GLIDEANDCLIMB - "S_PLAY_GLIDE", - "S_PLAY_GLIDE_LANDING", - "S_PLAY_CLING", - "S_PLAY_CLIMB", - - // CA_FLOAT/CA_SLOWFALL - "S_PLAY_FLOAT", - "S_PLAY_FLOAT_RUN", - - // CA_BOUNCE - "S_PLAY_BOUNCE", - "S_PLAY_BOUNCE_LANDING", - - // CA2_GUNSLINGER - "S_PLAY_FIRE", - "S_PLAY_FIRE_FINISH", - - // CA_TWINSPIN - "S_PLAY_TWINSPIN", - - // CA2_MELEE - "S_PLAY_MELEE", - "S_PLAY_MELEE_FINISH", - "S_PLAY_MELEE_LANDING", - - // SF_SUPER - "S_PLAY_SUPER_TRANS1", - "S_PLAY_SUPER_TRANS2", - "S_PLAY_SUPER_TRANS3", - "S_PLAY_SUPER_TRANS4", - "S_PLAY_SUPER_TRANS5", - "S_PLAY_SUPER_TRANS6", - - // technically the player goes here but it's an infinite tic state - "S_OBJPLACE_DUMMY", - - // 1-Up Box Sprites overlay (uses player sprite) - "S_PLAY_BOX1", - "S_PLAY_BOX2", - "S_PLAY_ICON1", - "S_PLAY_ICON2", - "S_PLAY_ICON3", - - // Level end sign overlay (uses player sprite) - "S_PLAY_SIGN", - - // NiGHTS character (uses player sprite) - "S_PLAY_NIGHTS_TRANS1", - "S_PLAY_NIGHTS_TRANS2", - "S_PLAY_NIGHTS_TRANS3", - "S_PLAY_NIGHTS_TRANS4", - "S_PLAY_NIGHTS_TRANS5", - "S_PLAY_NIGHTS_TRANS6", - "S_PLAY_NIGHTS_STAND", - "S_PLAY_NIGHTS_FLOAT", - "S_PLAY_NIGHTS_FLY", - "S_PLAY_NIGHTS_DRILL", - "S_PLAY_NIGHTS_STUN", - "S_PLAY_NIGHTS_PULL", - "S_PLAY_NIGHTS_ATTACK", - - // c: - "S_TAILSOVERLAY_STAND", - "S_TAILSOVERLAY_0DEGREES", - "S_TAILSOVERLAY_PLUS30DEGREES", - "S_TAILSOVERLAY_PLUS60DEGREES", - "S_TAILSOVERLAY_MINUS30DEGREES", - "S_TAILSOVERLAY_MINUS60DEGREES", - "S_TAILSOVERLAY_RUN", - "S_TAILSOVERLAY_FLY", - "S_TAILSOVERLAY_TIRE", - "S_TAILSOVERLAY_PAIN", - "S_TAILSOVERLAY_GASP", - "S_TAILSOVERLAY_EDGE", - "S_TAILSOVERLAY_DASH", - - // [: - "S_JETFUMEFLASH", - - // Blue Crawla - "S_POSS_STND", - "S_POSS_RUN1", - "S_POSS_RUN2", - "S_POSS_RUN3", - "S_POSS_RUN4", - "S_POSS_RUN5", - "S_POSS_RUN6", - - // Red Crawla - "S_SPOS_STND", - "S_SPOS_RUN1", - "S_SPOS_RUN2", - "S_SPOS_RUN3", - "S_SPOS_RUN4", - "S_SPOS_RUN5", - "S_SPOS_RUN6", - - // Greenflower Fish - "S_FISH1", - "S_FISH2", - "S_FISH3", - "S_FISH4", - - // Buzz (Gold) - "S_BUZZLOOK1", - "S_BUZZLOOK2", - "S_BUZZFLY1", - "S_BUZZFLY2", - - // Buzz (Red) - "S_RBUZZLOOK1", - "S_RBUZZLOOK2", - "S_RBUZZFLY1", - "S_RBUZZFLY2", - - // Jetty-Syn Bomber - "S_JETBLOOK1", - "S_JETBLOOK2", - "S_JETBZOOM1", - "S_JETBZOOM2", - - // Jetty-Syn Gunner - "S_JETGLOOK1", - "S_JETGLOOK2", - "S_JETGZOOM1", - "S_JETGZOOM2", - "S_JETGSHOOT1", - "S_JETGSHOOT2", - - // Crawla Commander - "S_CCOMMAND1", - "S_CCOMMAND2", - "S_CCOMMAND3", - "S_CCOMMAND4", - - // Deton - "S_DETON1", - "S_DETON2", - "S_DETON3", - "S_DETON4", - "S_DETON5", - "S_DETON6", - "S_DETON7", - "S_DETON8", - "S_DETON9", - "S_DETON10", - "S_DETON11", - "S_DETON12", - "S_DETON13", - "S_DETON14", - "S_DETON15", - - // Skim Mine Dropper - "S_SKIM1", - "S_SKIM2", - "S_SKIM3", - "S_SKIM4", - - // THZ Turret - "S_TURRET", - "S_TURRETFIRE", - "S_TURRETSHOCK1", - "S_TURRETSHOCK2", - "S_TURRETSHOCK3", - "S_TURRETSHOCK4", - "S_TURRETSHOCK5", - "S_TURRETSHOCK6", - "S_TURRETSHOCK7", - "S_TURRETSHOCK8", - "S_TURRETSHOCK9", - - // Popup Turret - "S_TURRETLOOK", - "S_TURRETSEE", - "S_TURRETPOPUP1", - "S_TURRETPOPUP2", - "S_TURRETPOPUP3", - "S_TURRETPOPUP4", - "S_TURRETPOPUP5", - "S_TURRETPOPUP6", - "S_TURRETPOPUP7", - "S_TURRETPOPUP8", - "S_TURRETSHOOT", - "S_TURRETPOPDOWN1", - "S_TURRETPOPDOWN2", - "S_TURRETPOPDOWN3", - "S_TURRETPOPDOWN4", - "S_TURRETPOPDOWN5", - "S_TURRETPOPDOWN6", - "S_TURRETPOPDOWN7", - "S_TURRETPOPDOWN8", - - // Spincushion - "S_SPINCUSHION_LOOK", - "S_SPINCUSHION_CHASE1", - "S_SPINCUSHION_CHASE2", - "S_SPINCUSHION_CHASE3", - "S_SPINCUSHION_CHASE4", - "S_SPINCUSHION_AIM1", - "S_SPINCUSHION_AIM2", - "S_SPINCUSHION_AIM3", - "S_SPINCUSHION_AIM4", - "S_SPINCUSHION_AIM5", - "S_SPINCUSHION_SPIN1", - "S_SPINCUSHION_SPIN2", - "S_SPINCUSHION_SPIN3", - "S_SPINCUSHION_SPIN4", - "S_SPINCUSHION_STOP1", - "S_SPINCUSHION_STOP2", - "S_SPINCUSHION_STOP3", - "S_SPINCUSHION_STOP4", - - // Crushstacean - "S_CRUSHSTACEAN_ROAM1", - "S_CRUSHSTACEAN_ROAM2", - "S_CRUSHSTACEAN_ROAM3", - "S_CRUSHSTACEAN_ROAM4", - "S_CRUSHSTACEAN_ROAMPAUSE", - "S_CRUSHSTACEAN_PUNCH1", - "S_CRUSHSTACEAN_PUNCH2", - "S_CRUSHCLAW_AIM", - "S_CRUSHCLAW_OUT", - "S_CRUSHCLAW_STAY", - "S_CRUSHCLAW_IN", - "S_CRUSHCLAW_WAIT", - "S_CRUSHCHAIN", - - // Banpyura - "S_BANPYURA_ROAM1", - "S_BANPYURA_ROAM2", - "S_BANPYURA_ROAM3", - "S_BANPYURA_ROAM4", - "S_BANPYURA_ROAMPAUSE", - "S_CDIAG1", - "S_CDIAG2", - "S_CDIAG3", - "S_CDIAG4", - "S_CDIAG5", - "S_CDIAG6", - "S_CDIAG7", - "S_CDIAG8", - - // Jet Jaw - "S_JETJAW_ROAM1", - "S_JETJAW_ROAM2", - "S_JETJAW_ROAM3", - "S_JETJAW_ROAM4", - "S_JETJAW_ROAM5", - "S_JETJAW_ROAM6", - "S_JETJAW_ROAM7", - "S_JETJAW_ROAM8", - "S_JETJAW_CHOMP1", - "S_JETJAW_CHOMP2", - "S_JETJAW_CHOMP3", - "S_JETJAW_CHOMP4", - "S_JETJAW_CHOMP5", - "S_JETJAW_CHOMP6", - "S_JETJAW_CHOMP7", - "S_JETJAW_CHOMP8", - "S_JETJAW_CHOMP9", - "S_JETJAW_CHOMP10", - "S_JETJAW_CHOMP11", - "S_JETJAW_CHOMP12", - "S_JETJAW_CHOMP13", - "S_JETJAW_CHOMP14", - "S_JETJAW_CHOMP15", - "S_JETJAW_CHOMP16", - "S_JETJAW_SOUND", - - // Snailer - "S_SNAILER1", - "S_SNAILER_FLICKY", - - // Vulture - "S_VULTURE_STND", - "S_VULTURE_DRIFT", - "S_VULTURE_ZOOM1", - "S_VULTURE_ZOOM2", - "S_VULTURE_STUNNED", - - // Pointy - "S_POINTY1", - "S_POINTYBALL1", - - // Robo-Hood - "S_ROBOHOOD_LOOK", - "S_ROBOHOOD_STAND", - "S_ROBOHOOD_FIRE1", - "S_ROBOHOOD_FIRE2", - "S_ROBOHOOD_JUMP1", - "S_ROBOHOOD_JUMP2", - "S_ROBOHOOD_JUMP3", - - // Castlebot Facestabber - "S_FACESTABBER_STND1", - "S_FACESTABBER_STND2", - "S_FACESTABBER_STND3", - "S_FACESTABBER_STND4", - "S_FACESTABBER_STND5", - "S_FACESTABBER_STND6", - "S_FACESTABBER_CHARGE1", - "S_FACESTABBER_CHARGE2", - "S_FACESTABBER_CHARGE3", - "S_FACESTABBER_CHARGE4", - "S_FACESTABBER_PAIN", - "S_FACESTABBER_DIE1", - "S_FACESTABBER_DIE2", - "S_FACESTABBER_DIE3", - "S_FACESTABBERSPEAR", - - // Egg Guard - "S_EGGGUARD_STND", - "S_EGGGUARD_WALK1", - "S_EGGGUARD_WALK2", - "S_EGGGUARD_WALK3", - "S_EGGGUARD_WALK4", - "S_EGGGUARD_MAD1", - "S_EGGGUARD_MAD2", - "S_EGGGUARD_MAD3", - "S_EGGGUARD_RUN1", - "S_EGGGUARD_RUN2", - "S_EGGGUARD_RUN3", - "S_EGGGUARD_RUN4", - - // Egg Shield for Egg Guard - "S_EGGSHIELD", - "S_EGGSHIELDBREAK", - - // Green Snapper - "S_SNAPPER_SPAWN", - "S_SNAPPER_SPAWN2", - "S_GSNAPPER_STND", - "S_GSNAPPER1", - "S_GSNAPPER2", - "S_GSNAPPER3", - "S_GSNAPPER4", - "S_SNAPPER_XPLD", - "S_SNAPPER_LEG", - "S_SNAPPER_LEGRAISE", - "S_SNAPPER_HEAD", - - // Minus - "S_MINUS_INIT", - "S_MINUS_STND", - "S_MINUS_DIGGING1", - "S_MINUS_DIGGING2", - "S_MINUS_DIGGING3", - "S_MINUS_DIGGING4", - "S_MINUS_BURST0", - "S_MINUS_BURST1", - "S_MINUS_BURST2", - "S_MINUS_BURST3", - "S_MINUS_BURST4", - "S_MINUS_BURST5", - "S_MINUS_POPUP", - "S_MINUS_AERIAL1", - "S_MINUS_AERIAL2", - "S_MINUS_AERIAL3", - "S_MINUS_AERIAL4", - - // Minus dirt - "S_MINUSDIRT1", - "S_MINUSDIRT2", - "S_MINUSDIRT3", - "S_MINUSDIRT4", - "S_MINUSDIRT5", - "S_MINUSDIRT6", - "S_MINUSDIRT7", - - // Spring Shell - "S_SSHELL_STND", - "S_SSHELL_RUN1", - "S_SSHELL_RUN2", - "S_SSHELL_RUN3", - "S_SSHELL_RUN4", - "S_SSHELL_SPRING1", - "S_SSHELL_SPRING2", - "S_SSHELL_SPRING3", - "S_SSHELL_SPRING4", - - // Spring Shell (yellow) - "S_YSHELL_STND", - "S_YSHELL_RUN1", - "S_YSHELL_RUN2", - "S_YSHELL_RUN3", - "S_YSHELL_RUN4", - "S_YSHELL_SPRING1", - "S_YSHELL_SPRING2", - "S_YSHELL_SPRING3", - "S_YSHELL_SPRING4", - - // Unidus - "S_UNIDUS_STND", - "S_UNIDUS_RUN", - "S_UNIDUS_BALL", - - // Canarivore - "S_CANARIVORE_LOOK", - "S_CANARIVORE_AWAKEN1", - "S_CANARIVORE_AWAKEN2", - "S_CANARIVORE_AWAKEN3", - "S_CANARIVORE_GAS1", - "S_CANARIVORE_GAS2", - "S_CANARIVORE_GAS3", - "S_CANARIVORE_GAS4", - "S_CANARIVORE_GAS5", - "S_CANARIVORE_GASREPEAT", - "S_CANARIVORE_CLOSE1", - "S_CANARIVORE_CLOSE2", - "S_CANARIVOREGAS_1", - "S_CANARIVOREGAS_2", - "S_CANARIVOREGAS_3", - "S_CANARIVOREGAS_4", - "S_CANARIVOREGAS_5", - "S_CANARIVOREGAS_6", - "S_CANARIVOREGAS_7", - "S_CANARIVOREGAS_8", - - // Pyre Fly - "S_PYREFLY_FLY", - "S_PYREFLY_BURN", - "S_PYREFIRE1", - "S_PYREFIRE2", - - // Pterabyte - "S_PTERABYTESPAWNER", - "S_PTERABYTEWAYPOINT", - "S_PTERABYTE_FLY1", - "S_PTERABYTE_FLY2", - "S_PTERABYTE_FLY3", - "S_PTERABYTE_FLY4", - "S_PTERABYTE_SWOOPDOWN", - "S_PTERABYTE_SWOOPUP", - - // Dragonbomber - "S_DRAGONBOMBER", - "S_DRAGONWING1", - "S_DRAGONWING2", - "S_DRAGONWING3", - "S_DRAGONWING4", - "S_DRAGONTAIL_LOADED", - "S_DRAGONTAIL_EMPTY", - "S_DRAGONTAIL_EMPTYLOOP", - "S_DRAGONTAIL_RELOAD", - "S_DRAGONMINE", - "S_DRAGONMINE_LAND1", - "S_DRAGONMINE_LAND2", - "S_DRAGONMINE_SLOWFLASH1", - "S_DRAGONMINE_SLOWFLASH2", - "S_DRAGONMINE_SLOWLOOP", - "S_DRAGONMINE_FASTFLASH1", - "S_DRAGONMINE_FASTFLASH2", - "S_DRAGONMINE_FASTLOOP", - - // Boss Explosion - "S_BOSSEXPLODE", - - // S3&K Boss Explosion - "S_SONIC3KBOSSEXPLOSION1", - "S_SONIC3KBOSSEXPLOSION2", - "S_SONIC3KBOSSEXPLOSION3", - "S_SONIC3KBOSSEXPLOSION4", - "S_SONIC3KBOSSEXPLOSION5", - "S_SONIC3KBOSSEXPLOSION6", - - "S_JETFUME1", - - // Boss 1 - "S_EGGMOBILE_STND", - "S_EGGMOBILE_ROFL", - "S_EGGMOBILE_LATK1", - "S_EGGMOBILE_LATK2", - "S_EGGMOBILE_LATK3", - "S_EGGMOBILE_LATK4", - "S_EGGMOBILE_LATK5", - "S_EGGMOBILE_LATK6", - "S_EGGMOBILE_LATK7", - "S_EGGMOBILE_LATK8", - "S_EGGMOBILE_LATK9", - "S_EGGMOBILE_RATK1", - "S_EGGMOBILE_RATK2", - "S_EGGMOBILE_RATK3", - "S_EGGMOBILE_RATK4", - "S_EGGMOBILE_RATK5", - "S_EGGMOBILE_RATK6", - "S_EGGMOBILE_RATK7", - "S_EGGMOBILE_RATK8", - "S_EGGMOBILE_RATK9", - "S_EGGMOBILE_PANIC1", - "S_EGGMOBILE_PANIC2", - "S_EGGMOBILE_PANIC3", - "S_EGGMOBILE_PANIC4", - "S_EGGMOBILE_PANIC5", - "S_EGGMOBILE_PANIC6", - "S_EGGMOBILE_PANIC7", - "S_EGGMOBILE_PANIC8", - "S_EGGMOBILE_PANIC9", - "S_EGGMOBILE_PANIC10", - "S_EGGMOBILE_PANIC11", - "S_EGGMOBILE_PANIC12", - "S_EGGMOBILE_PANIC13", - "S_EGGMOBILE_PANIC14", - "S_EGGMOBILE_PANIC15", - "S_EGGMOBILE_PAIN", - "S_EGGMOBILE_PAIN2", - "S_EGGMOBILE_DIE1", - "S_EGGMOBILE_DIE2", - "S_EGGMOBILE_DIE3", - "S_EGGMOBILE_DIE4", - "S_EGGMOBILE_FLEE1", - "S_EGGMOBILE_FLEE2", - "S_EGGMOBILE_BALL", - "S_EGGMOBILE_TARGET", - - "S_BOSSEGLZ1", - "S_BOSSEGLZ2", - - // Boss 2 - "S_EGGMOBILE2_STND", - "S_EGGMOBILE2_POGO1", - "S_EGGMOBILE2_POGO2", - "S_EGGMOBILE2_POGO3", - "S_EGGMOBILE2_POGO4", - "S_EGGMOBILE2_POGO5", - "S_EGGMOBILE2_POGO6", - "S_EGGMOBILE2_POGO7", - "S_EGGMOBILE2_PAIN", - "S_EGGMOBILE2_PAIN2", - "S_EGGMOBILE2_DIE1", - "S_EGGMOBILE2_DIE2", - "S_EGGMOBILE2_DIE3", - "S_EGGMOBILE2_DIE4", - "S_EGGMOBILE2_FLEE1", - "S_EGGMOBILE2_FLEE2", - - "S_BOSSTANK1", - "S_BOSSTANK2", - "S_BOSSSPIGOT", - - // Boss 2 Goop - "S_GOOP1", - "S_GOOP2", - "S_GOOP3", - "S_GOOPTRAIL", - - // Boss 3 - "S_EGGMOBILE3_STND", - "S_EGGMOBILE3_SHOCK", - "S_EGGMOBILE3_ATK1", - "S_EGGMOBILE3_ATK2", - "S_EGGMOBILE3_ATK3A", - "S_EGGMOBILE3_ATK3B", - "S_EGGMOBILE3_ATK3C", - "S_EGGMOBILE3_ATK3D", - "S_EGGMOBILE3_ATK4", - "S_EGGMOBILE3_ATK5", - "S_EGGMOBILE3_ROFL", - "S_EGGMOBILE3_PAIN", - "S_EGGMOBILE3_PAIN2", - "S_EGGMOBILE3_DIE1", - "S_EGGMOBILE3_DIE2", - "S_EGGMOBILE3_DIE3", - "S_EGGMOBILE3_DIE4", - "S_EGGMOBILE3_FLEE1", - "S_EGGMOBILE3_FLEE2", - - // Boss 3 Pinch - "S_FAKEMOBILE_INIT", - "S_FAKEMOBILE", - "S_FAKEMOBILE_ATK1", - "S_FAKEMOBILE_ATK2", - "S_FAKEMOBILE_ATK3A", - "S_FAKEMOBILE_ATK3B", - "S_FAKEMOBILE_ATK3C", - "S_FAKEMOBILE_ATK3D", - "S_FAKEMOBILE_DIE1", - "S_FAKEMOBILE_DIE2", - - "S_BOSSSEBH1", - "S_BOSSSEBH2", - - // Boss 3 Shockwave - "S_SHOCKWAVE1", - "S_SHOCKWAVE2", - - // Boss 4 - "S_EGGMOBILE4_STND", - "S_EGGMOBILE4_LATK1", - "S_EGGMOBILE4_LATK2", - "S_EGGMOBILE4_LATK3", - "S_EGGMOBILE4_LATK4", - "S_EGGMOBILE4_LATK5", - "S_EGGMOBILE4_LATK6", - "S_EGGMOBILE4_RATK1", - "S_EGGMOBILE4_RATK2", - "S_EGGMOBILE4_RATK3", - "S_EGGMOBILE4_RATK4", - "S_EGGMOBILE4_RATK5", - "S_EGGMOBILE4_RATK6", - "S_EGGMOBILE4_RAISE1", - "S_EGGMOBILE4_RAISE2", - "S_EGGMOBILE4_PAIN1", - "S_EGGMOBILE4_PAIN2", - "S_EGGMOBILE4_DIE1", - "S_EGGMOBILE4_DIE2", - "S_EGGMOBILE4_DIE3", - "S_EGGMOBILE4_DIE4", - "S_EGGMOBILE4_FLEE1", - "S_EGGMOBILE4_FLEE2", - "S_EGGMOBILE4_MACE", - "S_EGGMOBILE4_MACE_DIE1", - "S_EGGMOBILE4_MACE_DIE2", - "S_EGGMOBILE4_MACE_DIE3", - - // Boss 4 jet flame - "S_JETFLAME", - - // Boss 4 Spectator Eggrobo - "S_EGGROBO1_STND", - "S_EGGROBO1_BSLAP1", - "S_EGGROBO1_BSLAP2", - "S_EGGROBO1_PISSED", - - // Boss 4 Spectator Eggrobo jet flame - "S_EGGROBOJET", - - // Boss 5 - "S_FANG_SETUP", - "S_FANG_INTRO0", - "S_FANG_INTRO1", - "S_FANG_INTRO2", - "S_FANG_INTRO3", - "S_FANG_INTRO4", - "S_FANG_INTRO5", - "S_FANG_INTRO6", - "S_FANG_INTRO7", - "S_FANG_INTRO8", - "S_FANG_INTRO9", - "S_FANG_INTRO10", - "S_FANG_INTRO11", - "S_FANG_INTRO12", - "S_FANG_CLONE1", - "S_FANG_CLONE2", - "S_FANG_CLONE3", - "S_FANG_CLONE4", - "S_FANG_IDLE0", - "S_FANG_IDLE1", - "S_FANG_IDLE2", - "S_FANG_IDLE3", - "S_FANG_IDLE4", - "S_FANG_IDLE5", - "S_FANG_IDLE6", - "S_FANG_IDLE7", - "S_FANG_IDLE8", - "S_FANG_PAIN1", - "S_FANG_PAIN2", - "S_FANG_PATHINGSTART1", - "S_FANG_PATHINGSTART2", - "S_FANG_PATHING", - "S_FANG_BOUNCE1", - "S_FANG_BOUNCE2", - "S_FANG_BOUNCE3", - "S_FANG_BOUNCE4", - "S_FANG_FALL1", - "S_FANG_FALL2", - "S_FANG_CHECKPATH1", - "S_FANG_CHECKPATH2", - "S_FANG_PATHINGCONT1", - "S_FANG_PATHINGCONT2", - "S_FANG_PATHINGCONT3", - "S_FANG_SKID1", - "S_FANG_SKID2", - "S_FANG_SKID3", - "S_FANG_CHOOSEATTACK", - "S_FANG_FIRESTART1", - "S_FANG_FIRESTART2", - "S_FANG_FIRE1", - "S_FANG_FIRE2", - "S_FANG_FIRE3", - "S_FANG_FIRE4", - "S_FANG_FIREREPEAT", - "S_FANG_LOBSHOT0", - "S_FANG_LOBSHOT1", - "S_FANG_LOBSHOT2", - "S_FANG_WAIT1", - "S_FANG_WAIT2", - "S_FANG_WALLHIT", - "S_FANG_PINCHPATHINGSTART1", - "S_FANG_PINCHPATHINGSTART2", - "S_FANG_PINCHPATHING", - "S_FANG_PINCHBOUNCE0", - "S_FANG_PINCHBOUNCE1", - "S_FANG_PINCHBOUNCE2", - "S_FANG_PINCHBOUNCE3", - "S_FANG_PINCHBOUNCE4", - "S_FANG_PINCHFALL0", - "S_FANG_PINCHFALL1", - "S_FANG_PINCHFALL2", - "S_FANG_PINCHSKID1", - "S_FANG_PINCHSKID2", - "S_FANG_PINCHLOBSHOT0", - "S_FANG_PINCHLOBSHOT1", - "S_FANG_PINCHLOBSHOT2", - "S_FANG_PINCHLOBSHOT3", - "S_FANG_PINCHLOBSHOT4", - "S_FANG_DIE1", - "S_FANG_DIE2", - "S_FANG_DIE3", - "S_FANG_DIE4", - "S_FANG_DIE5", - "S_FANG_DIE6", - "S_FANG_DIE7", - "S_FANG_DIE8", - "S_FANG_FLEEPATHING1", - "S_FANG_FLEEPATHING2", - "S_FANG_FLEEBOUNCE1", - "S_FANG_FLEEBOUNCE2", - "S_FANG_KO", - - "S_BROKENROBOTRANDOM", - "S_BROKENROBOTA", - "S_BROKENROBOTB", - "S_BROKENROBOTC", - "S_BROKENROBOTD", - "S_BROKENROBOTE", - "S_BROKENROBOTF", - - "S_ALART1", - "S_ALART2", - - "S_VWREF", - "S_VWREB", - - "S_PROJECTORLIGHT1", - "S_PROJECTORLIGHT2", - "S_PROJECTORLIGHT3", - "S_PROJECTORLIGHT4", - "S_PROJECTORLIGHT5", - - "S_FBOMB1", - "S_FBOMB2", - "S_FBOMB_EXPL1", - "S_FBOMB_EXPL2", - "S_FBOMB_EXPL3", - "S_FBOMB_EXPL4", - "S_FBOMB_EXPL5", - "S_FBOMB_EXPL6", - "S_TNTDUST_1", - "S_TNTDUST_2", - "S_TNTDUST_3", - "S_TNTDUST_4", - "S_TNTDUST_5", - "S_TNTDUST_6", - "S_TNTDUST_7", - "S_TNTDUST_8", - "S_FSGNA", - "S_FSGNB", - "S_FSGNC", - "S_FSGND", - - // Black Eggman (Boss 7) - "S_BLACKEGG_STND", - "S_BLACKEGG_STND2", - "S_BLACKEGG_WALK1", - "S_BLACKEGG_WALK2", - "S_BLACKEGG_WALK3", - "S_BLACKEGG_WALK4", - "S_BLACKEGG_WALK5", - "S_BLACKEGG_WALK6", - "S_BLACKEGG_SHOOT1", - "S_BLACKEGG_SHOOT2", - "S_BLACKEGG_PAIN1", - "S_BLACKEGG_PAIN2", - "S_BLACKEGG_PAIN3", - "S_BLACKEGG_PAIN4", - "S_BLACKEGG_PAIN5", - "S_BLACKEGG_PAIN6", - "S_BLACKEGG_PAIN7", - "S_BLACKEGG_PAIN8", - "S_BLACKEGG_PAIN9", - "S_BLACKEGG_PAIN10", - "S_BLACKEGG_PAIN11", - "S_BLACKEGG_PAIN12", - "S_BLACKEGG_PAIN13", - "S_BLACKEGG_PAIN14", - "S_BLACKEGG_PAIN15", - "S_BLACKEGG_PAIN16", - "S_BLACKEGG_PAIN17", - "S_BLACKEGG_PAIN18", - "S_BLACKEGG_PAIN19", - "S_BLACKEGG_PAIN20", - "S_BLACKEGG_PAIN21", - "S_BLACKEGG_PAIN22", - "S_BLACKEGG_PAIN23", - "S_BLACKEGG_PAIN24", - "S_BLACKEGG_PAIN25", - "S_BLACKEGG_PAIN26", - "S_BLACKEGG_PAIN27", - "S_BLACKEGG_PAIN28", - "S_BLACKEGG_PAIN29", - "S_BLACKEGG_PAIN30", - "S_BLACKEGG_PAIN31", - "S_BLACKEGG_PAIN32", - "S_BLACKEGG_PAIN33", - "S_BLACKEGG_PAIN34", - "S_BLACKEGG_PAIN35", - "S_BLACKEGG_HITFACE1", - "S_BLACKEGG_HITFACE2", - "S_BLACKEGG_HITFACE3", - "S_BLACKEGG_HITFACE4", - "S_BLACKEGG_DIE1", - "S_BLACKEGG_DIE2", - "S_BLACKEGG_DIE3", - "S_BLACKEGG_DIE4", - "S_BLACKEGG_DIE5", - "S_BLACKEGG_MISSILE1", - "S_BLACKEGG_MISSILE2", - "S_BLACKEGG_MISSILE3", - "S_BLACKEGG_GOOP", - "S_BLACKEGG_JUMP1", - "S_BLACKEGG_JUMP2", - "S_BLACKEGG_DESTROYPLAT1", - "S_BLACKEGG_DESTROYPLAT2", - "S_BLACKEGG_DESTROYPLAT3", - - "S_BLACKEGG_HELPER", // Collision helper - - "S_BLACKEGG_GOOP1", - "S_BLACKEGG_GOOP2", - "S_BLACKEGG_GOOP3", - "S_BLACKEGG_GOOP4", - "S_BLACKEGG_GOOP5", - "S_BLACKEGG_GOOP6", - "S_BLACKEGG_GOOP7", - - "S_BLACKEGG_MISSILE", - - // New Very-Last-Minute 2.1 Brak Eggman (Cy-Brak-demon) - "S_CYBRAKDEMON_IDLE", - "S_CYBRAKDEMON_WALK1", - "S_CYBRAKDEMON_WALK2", - "S_CYBRAKDEMON_WALK3", - "S_CYBRAKDEMON_WALK4", - "S_CYBRAKDEMON_WALK5", - "S_CYBRAKDEMON_WALK6", - "S_CYBRAKDEMON_CHOOSE_ATTACK1", - "S_CYBRAKDEMON_MISSILE_ATTACK1", // Aim - "S_CYBRAKDEMON_MISSILE_ATTACK2", // Fire - "S_CYBRAKDEMON_MISSILE_ATTACK3", // Aim - "S_CYBRAKDEMON_MISSILE_ATTACK4", // Fire - "S_CYBRAKDEMON_MISSILE_ATTACK5", // Aim - "S_CYBRAKDEMON_MISSILE_ATTACK6", // Fire - "S_CYBRAKDEMON_FLAME_ATTACK1", // Reset - "S_CYBRAKDEMON_FLAME_ATTACK2", // Aim - "S_CYBRAKDEMON_FLAME_ATTACK3", // Fire - "S_CYBRAKDEMON_FLAME_ATTACK4", // Loop - "S_CYBRAKDEMON_CHOOSE_ATTACK2", - "S_CYBRAKDEMON_VILE_ATTACK1", - "S_CYBRAKDEMON_VILE_ATTACK2", - "S_CYBRAKDEMON_VILE_ATTACK3", - "S_CYBRAKDEMON_VILE_ATTACK4", - "S_CYBRAKDEMON_VILE_ATTACK5", - "S_CYBRAKDEMON_VILE_ATTACK6", - "S_CYBRAKDEMON_NAPALM_ATTACK1", - "S_CYBRAKDEMON_NAPALM_ATTACK2", - "S_CYBRAKDEMON_NAPALM_ATTACK3", - "S_CYBRAKDEMON_FINISH_ATTACK1", // If just attacked, remove MF2_FRET w/out going back to spawnstate - "S_CYBRAKDEMON_FINISH_ATTACK2", // Force a delay between attacks so you don't get bombarded with them back-to-back - "S_CYBRAKDEMON_PAIN1", - "S_CYBRAKDEMON_PAIN2", - "S_CYBRAKDEMON_PAIN3", - "S_CYBRAKDEMON_DIE1", - "S_CYBRAKDEMON_DIE2", - "S_CYBRAKDEMON_DIE3", - "S_CYBRAKDEMON_DIE4", - "S_CYBRAKDEMON_DIE5", - "S_CYBRAKDEMON_DIE6", - "S_CYBRAKDEMON_DIE7", - "S_CYBRAKDEMON_DIE8", - "S_CYBRAKDEMON_DEINVINCIBLERIZE", - "S_CYBRAKDEMON_INVINCIBLERIZE", - - "S_CYBRAKDEMONMISSILE", - "S_CYBRAKDEMONMISSILE_EXPLODE1", - "S_CYBRAKDEMONMISSILE_EXPLODE2", - "S_CYBRAKDEMONMISSILE_EXPLODE3", - - "S_CYBRAKDEMONFLAMESHOT_FLY1", - "S_CYBRAKDEMONFLAMESHOT_FLY2", - "S_CYBRAKDEMONFLAMESHOT_FLY3", - "S_CYBRAKDEMONFLAMESHOT_DIE", - - "S_CYBRAKDEMONFLAMEREST", - - "S_CYBRAKDEMONELECTRICBARRIER_INIT1", - "S_CYBRAKDEMONELECTRICBARRIER_INIT2", - "S_CYBRAKDEMONELECTRICBARRIER_PLAYSOUND", - "S_CYBRAKDEMONELECTRICBARRIER1", - "S_CYBRAKDEMONELECTRICBARRIER2", - "S_CYBRAKDEMONELECTRICBARRIER3", - "S_CYBRAKDEMONELECTRICBARRIER4", - "S_CYBRAKDEMONELECTRICBARRIER5", - "S_CYBRAKDEMONELECTRICBARRIER6", - "S_CYBRAKDEMONELECTRICBARRIER7", - "S_CYBRAKDEMONELECTRICBARRIER8", - "S_CYBRAKDEMONELECTRICBARRIER9", - "S_CYBRAKDEMONELECTRICBARRIER10", - "S_CYBRAKDEMONELECTRICBARRIER11", - "S_CYBRAKDEMONELECTRICBARRIER12", - "S_CYBRAKDEMONELECTRICBARRIER13", - "S_CYBRAKDEMONELECTRICBARRIER14", - "S_CYBRAKDEMONELECTRICBARRIER15", - "S_CYBRAKDEMONELECTRICBARRIER16", - "S_CYBRAKDEMONELECTRICBARRIER17", - "S_CYBRAKDEMONELECTRICBARRIER18", - "S_CYBRAKDEMONELECTRICBARRIER19", - "S_CYBRAKDEMONELECTRICBARRIER20", - "S_CYBRAKDEMONELECTRICBARRIER21", - "S_CYBRAKDEMONELECTRICBARRIER22", - "S_CYBRAKDEMONELECTRICBARRIER23", - "S_CYBRAKDEMONELECTRICBARRIER24", - "S_CYBRAKDEMONELECTRICBARRIER_DIE1", - "S_CYBRAKDEMONELECTRICBARRIER_DIE2", - "S_CYBRAKDEMONELECTRICBARRIER_DIE3", - "S_CYBRAKDEMONELECTRICBARRIER_SPARK_RANDOMCHECK", - "S_CYBRAKDEMONELECTRICBARRIER_SPARK_RANDOMSUCCESS", - "S_CYBRAKDEMONELECTRICBARRIER_SPARK_RANDOMCHOOSE", - "S_CYBRAKDEMONELECTRICBARRIER_SPARK_RANDOM1", - "S_CYBRAKDEMONELECTRICBARRIER_SPARK_RANDOM2", - "S_CYBRAKDEMONELECTRICBARRIER_SPARK_RANDOM3", - "S_CYBRAKDEMONELECTRICBARRIER_SPARK_RANDOM4", - "S_CYBRAKDEMONELECTRICBARRIER_SPARK_RANDOM5", - "S_CYBRAKDEMONELECTRICBARRIER_SPARK_RANDOM6", - "S_CYBRAKDEMONELECTRICBARRIER_SPARK_RANDOM7", - "S_CYBRAKDEMONELECTRICBARRIER_SPARK_RANDOM8", - "S_CYBRAKDEMONELECTRICBARRIER_SPARK_RANDOM9", - "S_CYBRAKDEMONELECTRICBARRIER_SPARK_RANDOM10", - "S_CYBRAKDEMONELECTRICBARRIER_SPARK_RANDOM11", - "S_CYBRAKDEMONELECTRICBARRIER_SPARK_RANDOM12", - "S_CYBRAKDEMONELECTRICBARRIER_SPARK_RANDOMFAIL", - "S_CYBRAKDEMONELECTRICBARRIER_SPARK_RANDOMLOOP", - "S_CYBRAKDEMONELECTRICBARRIER_REVIVE1", - "S_CYBRAKDEMONELECTRICBARRIER_REVIVE2", - "S_CYBRAKDEMONELECTRICBARRIER_REVIVE3", - - "S_CYBRAKDEMONTARGETRETICULE1", - "S_CYBRAKDEMONTARGETRETICULE2", - "S_CYBRAKDEMONTARGETRETICULE3", - "S_CYBRAKDEMONTARGETRETICULE4", - "S_CYBRAKDEMONTARGETRETICULE5", - "S_CYBRAKDEMONTARGETRETICULE6", - "S_CYBRAKDEMONTARGETRETICULE7", - "S_CYBRAKDEMONTARGETRETICULE8", - "S_CYBRAKDEMONTARGETRETICULE9", - "S_CYBRAKDEMONTARGETRETICULE10", - "S_CYBRAKDEMONTARGETRETICULE11", - "S_CYBRAKDEMONTARGETRETICULE12", - "S_CYBRAKDEMONTARGETRETICULE13", - "S_CYBRAKDEMONTARGETRETICULE14", - - "S_CYBRAKDEMONTARGETDOT", - - "S_CYBRAKDEMONNAPALMBOMBLARGE_FLY1", - "S_CYBRAKDEMONNAPALMBOMBLARGE_FLY2", - "S_CYBRAKDEMONNAPALMBOMBLARGE_FLY3", - "S_CYBRAKDEMONNAPALMBOMBLARGE_FLY4", - "S_CYBRAKDEMONNAPALMBOMBLARGE_DIE1", // Explode - "S_CYBRAKDEMONNAPALMBOMBLARGE_DIE2", // Outer ring - "S_CYBRAKDEMONNAPALMBOMBLARGE_DIE3", // Center - "S_CYBRAKDEMONNAPALMBOMBLARGE_DIE4", // Sound - - "S_CYBRAKDEMONNAPALMBOMBSMALL", - "S_CYBRAKDEMONNAPALMBOMBSMALL_DIE1", // Explode - "S_CYBRAKDEMONNAPALMBOMBSMALL_DIE2", // Outer ring - "S_CYBRAKDEMONNAPALMBOMBSMALL_DIE3", // Inner ring - "S_CYBRAKDEMONNAPALMBOMBSMALL_DIE4", // Center - "S_CYBRAKDEMONNAPALMBOMBSMALL_DIE5", // Sound - - "S_CYBRAKDEMONNAPALMFLAME_FLY1", - "S_CYBRAKDEMONNAPALMFLAME_FLY2", - "S_CYBRAKDEMONNAPALMFLAME_FLY3", - "S_CYBRAKDEMONNAPALMFLAME_FLY4", - "S_CYBRAKDEMONNAPALMFLAME_FLY5", - "S_CYBRAKDEMONNAPALMFLAME_FLY6", - "S_CYBRAKDEMONNAPALMFLAME_DIE", - - "S_CYBRAKDEMONVILEEXPLOSION1", - "S_CYBRAKDEMONVILEEXPLOSION2", - "S_CYBRAKDEMONVILEEXPLOSION3", - - // Metal Sonic (Race) - "S_METALSONIC_RACE", - // Metal Sonic (Battle) - "S_METALSONIC_FLOAT", - "S_METALSONIC_VECTOR", - "S_METALSONIC_STUN", - "S_METALSONIC_RAISE", - "S_METALSONIC_GATHER", - "S_METALSONIC_DASH", - "S_METALSONIC_BOUNCE", - "S_METALSONIC_BADBOUNCE", - "S_METALSONIC_SHOOT", - "S_METALSONIC_PAIN", - "S_METALSONIC_DEATH1", - "S_METALSONIC_DEATH2", - "S_METALSONIC_DEATH3", - "S_METALSONIC_DEATH4", - "S_METALSONIC_FLEE1", - "S_METALSONIC_FLEE2", - - "S_MSSHIELD_F1", - "S_MSSHIELD_F2", - - // Ring - "S_RING", - - // Blue Sphere for special stages - "S_BLUESPHERE", - "S_BLUESPHEREBONUS", - "S_BLUESPHERESPARK", - - // Bomb Sphere - "S_BOMBSPHERE1", - "S_BOMBSPHERE2", - "S_BOMBSPHERE3", - "S_BOMBSPHERE4", - - // NiGHTS Chip - "S_NIGHTSCHIP", - "S_NIGHTSCHIPBONUS", - - // NiGHTS Star - "S_NIGHTSSTAR", - "S_NIGHTSSTARXMAS", - - // Gravity Wells for special stages - "S_GRAVWELLGREEN", - "S_GRAVWELLRED", - - // Individual Team Rings - "S_TEAMRING", - - // Special Stage Token - "S_TOKEN", - - // CTF Flags - "S_REDFLAG", - "S_BLUEFLAG", - - // Emblem - "S_EMBLEM1", - "S_EMBLEM2", - "S_EMBLEM3", - "S_EMBLEM4", - "S_EMBLEM5", - "S_EMBLEM6", - "S_EMBLEM7", - "S_EMBLEM8", - "S_EMBLEM9", - "S_EMBLEM10", - "S_EMBLEM11", - "S_EMBLEM12", - "S_EMBLEM13", - "S_EMBLEM14", - "S_EMBLEM15", - "S_EMBLEM16", - "S_EMBLEM17", - "S_EMBLEM18", - "S_EMBLEM19", - "S_EMBLEM20", - "S_EMBLEM21", - "S_EMBLEM22", - "S_EMBLEM23", - "S_EMBLEM24", - "S_EMBLEM25", - "S_EMBLEM26", - - // Chaos Emeralds - "S_CEMG1", - "S_CEMG2", - "S_CEMG3", - "S_CEMG4", - "S_CEMG5", - "S_CEMG6", - "S_CEMG7", - - // Emerald hunt shards - "S_SHRD1", - "S_SHRD2", - "S_SHRD3", - - // Bubble Source - "S_BUBBLES1", - "S_BUBBLES2", - "S_BUBBLES3", - "S_BUBBLES4", - - // Level End Sign - "S_SIGN", - "S_SIGNSPIN1", - "S_SIGNSPIN2", - "S_SIGNSPIN3", - "S_SIGNSPIN4", - "S_SIGNSPIN5", - "S_SIGNSPIN6", - "S_SIGNPLAYER", - "S_SIGNSLOW", - "S_SIGNSTOP", - "S_SIGNBOARD", - "S_EGGMANSIGN", - "S_CLEARSIGN", - - // Spike Ball - "S_SPIKEBALL1", - "S_SPIKEBALL2", - "S_SPIKEBALL3", - "S_SPIKEBALL4", - "S_SPIKEBALL5", - "S_SPIKEBALL6", - "S_SPIKEBALL7", - "S_SPIKEBALL8", - - // Elemental Shield's Spawn - "S_SPINFIRE1", - "S_SPINFIRE2", - "S_SPINFIRE3", - "S_SPINFIRE4", - "S_SPINFIRE5", - "S_SPINFIRE6", - - // Spikes - "S_SPIKE1", - "S_SPIKE2", - "S_SPIKE3", - "S_SPIKE4", - "S_SPIKE5", - "S_SPIKE6", - "S_SPIKED1", - "S_SPIKED2", - - // Wall spikes - "S_WALLSPIKE1", - "S_WALLSPIKE2", - "S_WALLSPIKE3", - "S_WALLSPIKE4", - "S_WALLSPIKE5", - "S_WALLSPIKE6", - "S_WALLSPIKEBASE", - "S_WALLSPIKED1", - "S_WALLSPIKED2", - - // Starpost - "S_STARPOST_IDLE", - "S_STARPOST_FLASH", - "S_STARPOST_STARTSPIN", - "S_STARPOST_SPIN", - "S_STARPOST_ENDSPIN", - - // Big floating mine - "S_BIGMINE_IDLE", - "S_BIGMINE_ALERT1", - "S_BIGMINE_ALERT2", - "S_BIGMINE_ALERT3", - "S_BIGMINE_SET1", - "S_BIGMINE_SET2", - "S_BIGMINE_SET3", - "S_BIGMINE_BLAST1", - "S_BIGMINE_BLAST2", - "S_BIGMINE_BLAST3", - "S_BIGMINE_BLAST4", - "S_BIGMINE_BLAST5", - - // Cannon Launcher - "S_CANNONLAUNCHER1", - "S_CANNONLAUNCHER2", - "S_CANNONLAUNCHER3", - - // Monitor Miscellany - "S_BOXSPARKLE1", - "S_BOXSPARKLE2", - "S_BOXSPARKLE3", - "S_BOXSPARKLE4", - - "S_BOX_FLICKER", - "S_BOX_POP1", - "S_BOX_POP2", - - "S_GOLDBOX_FLICKER", - "S_GOLDBOX_OFF1", - "S_GOLDBOX_OFF2", - "S_GOLDBOX_OFF3", - "S_GOLDBOX_OFF4", - "S_GOLDBOX_OFF5", - "S_GOLDBOX_OFF6", - "S_GOLDBOX_OFF7", - - // Monitor States (one per box) - "S_MYSTERY_BOX", - "S_RING_BOX", - "S_PITY_BOX", - "S_ATTRACT_BOX", - "S_FORCE_BOX", - "S_ARMAGEDDON_BOX", - "S_WHIRLWIND_BOX", - "S_ELEMENTAL_BOX", - "S_SNEAKERS_BOX", - "S_INVULN_BOX", - "S_1UP_BOX", - "S_EGGMAN_BOX", - "S_MIXUP_BOX", - "S_GRAVITY_BOX", - "S_RECYCLER_BOX", - "S_SCORE1K_BOX", - "S_SCORE10K_BOX", - "S_FLAMEAURA_BOX", - "S_BUBBLEWRAP_BOX", - "S_THUNDERCOIN_BOX", - - // Gold Repeat Monitor States (one per box) - "S_PITY_GOLDBOX", - "S_ATTRACT_GOLDBOX", - "S_FORCE_GOLDBOX", - "S_ARMAGEDDON_GOLDBOX", - "S_WHIRLWIND_GOLDBOX", - "S_ELEMENTAL_GOLDBOX", - "S_SNEAKERS_GOLDBOX", - "S_INVULN_GOLDBOX", - "S_EGGMAN_GOLDBOX", - "S_GRAVITY_GOLDBOX", - "S_FLAMEAURA_GOLDBOX", - "S_BUBBLEWRAP_GOLDBOX", - "S_THUNDERCOIN_GOLDBOX", - - // Team Ring Boxes (these are special) - "S_RING_REDBOX1", - "S_RING_REDBOX2", - "S_REDBOX_POP1", - "S_REDBOX_POP2", - - "S_RING_BLUEBOX1", - "S_RING_BLUEBOX2", - "S_BLUEBOX_POP1", - "S_BLUEBOX_POP2", - - // Box Icons -- 2 states each, animation and action - "S_RING_ICON1", - "S_RING_ICON2", - - "S_PITY_ICON1", - "S_PITY_ICON2", - - "S_ATTRACT_ICON1", - "S_ATTRACT_ICON2", - - "S_FORCE_ICON1", - "S_FORCE_ICON2", - - "S_ARMAGEDDON_ICON1", - "S_ARMAGEDDON_ICON2", - - "S_WHIRLWIND_ICON1", - "S_WHIRLWIND_ICON2", - - "S_ELEMENTAL_ICON1", - "S_ELEMENTAL_ICON2", - - "S_SNEAKERS_ICON1", - "S_SNEAKERS_ICON2", - - "S_INVULN_ICON1", - "S_INVULN_ICON2", - - "S_1UP_ICON1", - "S_1UP_ICON2", - - "S_EGGMAN_ICON1", - "S_EGGMAN_ICON2", - - "S_MIXUP_ICON1", - "S_MIXUP_ICON2", - - "S_GRAVITY_ICON1", - "S_GRAVITY_ICON2", - - "S_RECYCLER_ICON1", - "S_RECYCLER_ICON2", - - "S_SCORE1K_ICON1", - "S_SCORE1K_ICON2", - - "S_SCORE10K_ICON1", - "S_SCORE10K_ICON2", - - "S_FLAMEAURA_ICON1", - "S_FLAMEAURA_ICON2", - - "S_BUBBLEWRAP_ICON1", - "S_BUBBLEWRAP_ICON2", - - "S_THUNDERCOIN_ICON1", - "S_THUNDERCOIN_ICON2", - - // --- - - "S_ROCKET", - - "S_LASER", - "S_LASER2", - "S_LASERFLASH", - - "S_LASERFLAME1", - "S_LASERFLAME2", - "S_LASERFLAME3", - "S_LASERFLAME4", - "S_LASERFLAME5", - - "S_TORPEDO", - - "S_ENERGYBALL1", - "S_ENERGYBALL2", - - // Skim Mine, also used by Jetty-Syn bomber - "S_MINE1", - "S_MINE_BOOM1", - "S_MINE_BOOM2", - "S_MINE_BOOM3", - "S_MINE_BOOM4", - - // Jetty-Syn Bullet - "S_JETBULLET1", - "S_JETBULLET2", - - "S_TURRETLASER", - "S_TURRETLASEREXPLODE1", - "S_TURRETLASEREXPLODE2", - - // Cannonball - "S_CANNONBALL1", - - // Arrow - "S_ARROW", - "S_ARROWBONK", - - // Glaregoyle Demon fire - "S_DEMONFIRE", - - // The letter - "S_LETTER", - - // GFZ flowers - "S_GFZFLOWERA", - "S_GFZFLOWERB", - "S_GFZFLOWERC", - - "S_BLUEBERRYBUSH", - "S_BERRYBUSH", - "S_BUSH", - - // Trees (both GFZ and misc) - "S_GFZTREE", - "S_GFZBERRYTREE", - "S_GFZCHERRYTREE", - "S_CHECKERTREE", - "S_CHECKERSUNSETTREE", - "S_FHZTREE", // Frozen Hillside - "S_FHZPINKTREE", - "S_POLYGONTREE", - "S_BUSHTREE", - "S_BUSHREDTREE", - "S_SPRINGTREE", - - // THZ flowers - "S_THZFLOWERA", // THZ1 Steam flower - "S_THZFLOWERB", // THZ1 Spin flower (red) - "S_THZFLOWERC", // THZ1 Spin flower (yellow) - - // THZ Steam Whistle tree/bush - "S_THZTREE", - "S_THZTREEBRANCH1", - "S_THZTREEBRANCH2", - "S_THZTREEBRANCH3", - "S_THZTREEBRANCH4", - "S_THZTREEBRANCH5", - "S_THZTREEBRANCH6", - "S_THZTREEBRANCH7", - "S_THZTREEBRANCH8", - "S_THZTREEBRANCH9", - "S_THZTREEBRANCH10", - "S_THZTREEBRANCH11", - "S_THZTREEBRANCH12", - "S_THZTREEBRANCH13", - - // THZ Alarm - "S_ALARM1", - - // Deep Sea Gargoyle - "S_GARGOYLE", - "S_BIGGARGOYLE", - - // DSZ Seaweed - "S_SEAWEED1", - "S_SEAWEED2", - "S_SEAWEED3", - "S_SEAWEED4", - "S_SEAWEED5", - "S_SEAWEED6", - - // Dripping Water - "S_DRIPA1", - "S_DRIPA2", - "S_DRIPA3", - "S_DRIPA4", - "S_DRIPB1", - "S_DRIPC1", - "S_DRIPC2", - - // Coral - "S_CORAL1", - "S_CORAL2", - "S_CORAL3", - "S_CORAL4", - "S_CORAL5", - - // Blue Crystal - "S_BLUECRYSTAL1", - - // Kelp, - "S_KELP", - - // Animated algae - "S_ANIMALGAETOP1", - "S_ANIMALGAETOP2", - "S_ANIMALGAESEG", - - // DSZ Stalagmites - "S_DSZSTALAGMITE", - "S_DSZ2STALAGMITE", - - // DSZ Light beam - "S_LIGHTBEAM1", - "S_LIGHTBEAM2", - "S_LIGHTBEAM3", - "S_LIGHTBEAM4", - "S_LIGHTBEAM5", - "S_LIGHTBEAM6", - "S_LIGHTBEAM7", - "S_LIGHTBEAM8", - "S_LIGHTBEAM9", - "S_LIGHTBEAM10", - "S_LIGHTBEAM11", - "S_LIGHTBEAM12", - - // CEZ Chain - "S_CEZCHAIN", - - // Flame - "S_FLAME", - "S_FLAMEPARTICLE", - "S_FLAMEREST", - - // Eggman Statue - "S_EGGSTATUE1", - - // CEZ hidden sling - "S_SLING1", - "S_SLING2", - - // CEZ maces and chains - "S_SMALLMACECHAIN", - "S_BIGMACECHAIN", - "S_SMALLMACE", - "S_BIGMACE", - "S_SMALLGRABCHAIN", - "S_BIGGRABCHAIN", - - // Yellow spring on a ball - "S_YELLOWSPRINGBALL", - "S_YELLOWSPRINGBALL2", - "S_YELLOWSPRINGBALL3", - "S_YELLOWSPRINGBALL4", - "S_YELLOWSPRINGBALL5", - - // Red spring on a ball - "S_REDSPRINGBALL", - "S_REDSPRINGBALL2", - "S_REDSPRINGBALL3", - "S_REDSPRINGBALL4", - "S_REDSPRINGBALL5", - - // Small Firebar - "S_SMALLFIREBAR1", - "S_SMALLFIREBAR2", - "S_SMALLFIREBAR3", - "S_SMALLFIREBAR4", - "S_SMALLFIREBAR5", - "S_SMALLFIREBAR6", - "S_SMALLFIREBAR7", - "S_SMALLFIREBAR8", - "S_SMALLFIREBAR9", - "S_SMALLFIREBAR10", - "S_SMALLFIREBAR11", - "S_SMALLFIREBAR12", - "S_SMALLFIREBAR13", - "S_SMALLFIREBAR14", - "S_SMALLFIREBAR15", - "S_SMALLFIREBAR16", - - // Big Firebar - "S_BIGFIREBAR1", - "S_BIGFIREBAR2", - "S_BIGFIREBAR3", - "S_BIGFIREBAR4", - "S_BIGFIREBAR5", - "S_BIGFIREBAR6", - "S_BIGFIREBAR7", - "S_BIGFIREBAR8", - "S_BIGFIREBAR9", - "S_BIGFIREBAR10", - "S_BIGFIREBAR11", - "S_BIGFIREBAR12", - "S_BIGFIREBAR13", - "S_BIGFIREBAR14", - "S_BIGFIREBAR15", - "S_BIGFIREBAR16", - - "S_CEZFLOWER", - "S_CEZPOLE", - "S_CEZBANNER1", - "S_CEZBANNER2", - "S_PINETREE", - "S_CEZBUSH1", - "S_CEZBUSH2", - "S_CANDLE", - "S_CANDLEPRICKET", - "S_FLAMEHOLDER", - "S_FIRETORCH", - "S_WAVINGFLAG", - "S_WAVINGFLAGSEG1", - "S_WAVINGFLAGSEG2", - "S_CRAWLASTATUE", - "S_FACESTABBERSTATUE", - "S_SUSPICIOUSFACESTABBERSTATUE_WAIT", - "S_SUSPICIOUSFACESTABBERSTATUE_BURST1", - "S_SUSPICIOUSFACESTABBERSTATUE_BURST2", - "S_BRAMBLES", - - // Big Tumbleweed - "S_BIGTUMBLEWEED", - "S_BIGTUMBLEWEED_ROLL1", - "S_BIGTUMBLEWEED_ROLL2", - "S_BIGTUMBLEWEED_ROLL3", - "S_BIGTUMBLEWEED_ROLL4", - "S_BIGTUMBLEWEED_ROLL5", - "S_BIGTUMBLEWEED_ROLL6", - "S_BIGTUMBLEWEED_ROLL7", - "S_BIGTUMBLEWEED_ROLL8", - - // Little Tumbleweed - "S_LITTLETUMBLEWEED", - "S_LITTLETUMBLEWEED_ROLL1", - "S_LITTLETUMBLEWEED_ROLL2", - "S_LITTLETUMBLEWEED_ROLL3", - "S_LITTLETUMBLEWEED_ROLL4", - "S_LITTLETUMBLEWEED_ROLL5", - "S_LITTLETUMBLEWEED_ROLL6", - "S_LITTLETUMBLEWEED_ROLL7", - "S_LITTLETUMBLEWEED_ROLL8", - - // Cacti - "S_CACTI1", - "S_CACTI2", - "S_CACTI3", - "S_CACTI4", - "S_CACTI5", - "S_CACTI6", - "S_CACTI7", - "S_CACTI8", - "S_CACTI9", - "S_CACTI10", - "S_CACTI11", - "S_CACTITINYSEG", - "S_CACTISMALLSEG", - - // Warning signs - "S_ARIDSIGN_CAUTION", - "S_ARIDSIGN_CACTI", - "S_ARIDSIGN_SHARPTURN", - - // Oil lamp - "S_OILLAMP", - "S_OILLAMPFLARE", - - // TNT barrel - "S_TNTBARREL_STND1", - "S_TNTBARREL_EXPL1", - "S_TNTBARREL_EXPL2", - "S_TNTBARREL_EXPL3", - "S_TNTBARREL_EXPL4", - "S_TNTBARREL_EXPL5", - "S_TNTBARREL_EXPL6", - "S_TNTBARREL_EXPL7", - "S_TNTBARREL_FLYING", - - // TNT proximity shell - "S_PROXIMITY_TNT", - "S_PROXIMITY_TNT_TRIGGER1", - "S_PROXIMITY_TNT_TRIGGER2", - "S_PROXIMITY_TNT_TRIGGER3", - "S_PROXIMITY_TNT_TRIGGER4", - "S_PROXIMITY_TNT_TRIGGER5", - "S_PROXIMITY_TNT_TRIGGER6", - "S_PROXIMITY_TNT_TRIGGER7", - "S_PROXIMITY_TNT_TRIGGER8", - "S_PROXIMITY_TNT_TRIGGER9", - "S_PROXIMITY_TNT_TRIGGER10", - "S_PROXIMITY_TNT_TRIGGER11", - "S_PROXIMITY_TNT_TRIGGER12", - "S_PROXIMITY_TNT_TRIGGER13", - "S_PROXIMITY_TNT_TRIGGER14", - "S_PROXIMITY_TNT_TRIGGER15", - "S_PROXIMITY_TNT_TRIGGER16", - "S_PROXIMITY_TNT_TRIGGER17", - "S_PROXIMITY_TNT_TRIGGER18", - "S_PROXIMITY_TNT_TRIGGER19", - "S_PROXIMITY_TNT_TRIGGER20", - "S_PROXIMITY_TNT_TRIGGER21", - "S_PROXIMITY_TNT_TRIGGER22", - "S_PROXIMITY_TNT_TRIGGER23", - - // Dust devil - "S_DUSTDEVIL", - "S_DUSTLAYER1", - "S_DUSTLAYER2", - "S_DUSTLAYER3", - "S_DUSTLAYER4", - "S_DUSTLAYER5", - "S_ARIDDUST1", - "S_ARIDDUST2", - "S_ARIDDUST3", - - // Minecart - "S_MINECART_IDLE", - "S_MINECART_DTH1", - "S_MINECARTEND", - "S_MINECARTSEG_FRONT", - "S_MINECARTSEG_BACK", - "S_MINECARTSEG_LEFT", - "S_MINECARTSEG_RIGHT", - "S_MINECARTSIDEMARK1", - "S_MINECARTSIDEMARK2", - "S_MINECARTSPARK", - - // Saloon door - "S_SALOONDOOR", - "S_SALOONDOORCENTER", - - // Train cameo - "S_TRAINCAMEOSPAWNER_1", - "S_TRAINCAMEOSPAWNER_2", - "S_TRAINCAMEOSPAWNER_3", - "S_TRAINCAMEOSPAWNER_4", - "S_TRAINCAMEOSPAWNER_5", - "S_TRAINPUFFMAKER", - - // Train - "S_TRAINDUST", - "S_TRAINSTEAM", - - // Flame jet - "S_FLAMEJETSTND", - "S_FLAMEJETSTART", - "S_FLAMEJETSTOP", - "S_FLAMEJETFLAME1", - "S_FLAMEJETFLAME2", - "S_FLAMEJETFLAME3", - "S_FLAMEJETFLAME4", - "S_FLAMEJETFLAME5", - "S_FLAMEJETFLAME6", - "S_FLAMEJETFLAME7", - "S_FLAMEJETFLAME8", - "S_FLAMEJETFLAME9", - - // Spinning flame jets - "S_FJSPINAXISA1", // Counter-clockwise - "S_FJSPINAXISA2", - "S_FJSPINAXISB1", // Clockwise - "S_FJSPINAXISB2", - - // Blade's flame - "S_FLAMEJETFLAMEB1", - "S_FLAMEJETFLAMEB2", - "S_FLAMEJETFLAMEB3", - - // Lavafall - "S_LAVAFALL_DORMANT", - "S_LAVAFALL_TELL", - "S_LAVAFALL_SHOOT", - "S_LAVAFALL_LAVA1", - "S_LAVAFALL_LAVA2", - "S_LAVAFALL_LAVA3", - "S_LAVAFALLROCK", - - // Rollout Rock - "S_ROLLOUTSPAWN", - "S_ROLLOUTROCK", - - // RVZ scenery - "S_BIGFERNLEAF", - "S_BIGFERN1", - "S_BIGFERN2", - "S_JUNGLEPALM", - "S_TORCHFLOWER", - "S_WALLVINE_LONG", - "S_WALLVINE_SHORT", - - // Glaregoyles - "S_GLAREGOYLE", - "S_GLAREGOYLE_CHARGE", - "S_GLAREGOYLE_BLINK", - "S_GLAREGOYLE_HOLD", - "S_GLAREGOYLE_FIRE", - "S_GLAREGOYLE_LOOP", - "S_GLAREGOYLE_COOLDOWN", - "S_GLAREGOYLEUP", - "S_GLAREGOYLEUP_CHARGE", - "S_GLAREGOYLEUP_BLINK", - "S_GLAREGOYLEUP_HOLD", - "S_GLAREGOYLEUP_FIRE", - "S_GLAREGOYLEUP_LOOP", - "S_GLAREGOYLEUP_COOLDOWN", - "S_GLAREGOYLEDOWN", - "S_GLAREGOYLEDOWN_CHARGE", - "S_GLAREGOYLEDOWN_BLINK", - "S_GLAREGOYLEDOWN_HOLD", - "S_GLAREGOYLEDOWN_FIRE", - "S_GLAREGOYLEDOWN_LOOP", - "S_GLAREGOYLEDOWN_COOLDOWN", - "S_GLAREGOYLELONG", - "S_GLAREGOYLELONG_CHARGE", - "S_GLAREGOYLELONG_BLINK", - "S_GLAREGOYLELONG_HOLD", - "S_GLAREGOYLELONG_FIRE", - "S_GLAREGOYLELONG_LOOP", - "S_GLAREGOYLELONG_COOLDOWN", - - // ATZ's Red Crystal/Target - "S_TARGET_IDLE", - "S_TARGET_HIT1", - "S_TARGET_HIT2", - "S_TARGET_RESPAWN", - "S_TARGET_ALLDONE", - - // ATZ's green flame - "S_GREENFLAME", - - // ATZ Blue Gargoyle - "S_BLUEGARGOYLE", - - // Stalagmites - "S_STG0", - "S_STG1", - "S_STG2", - "S_STG3", - "S_STG4", - "S_STG5", - "S_STG6", - "S_STG7", - "S_STG8", - "S_STG9", - - // Xmas-specific stuff - "S_XMASPOLE", - "S_CANDYCANE", - "S_SNOWMAN", // normal - "S_SNOWMANHAT", // with hat + scarf - "S_LAMPPOST1", // normal - "S_LAMPPOST2", // with snow - "S_HANGSTAR", - "S_MISTLETOE", - // Xmas GFZ bushes - "S_XMASBLUEBERRYBUSH", - "S_XMASBERRYBUSH", - "S_XMASBUSH", - // FHZ - "S_FHZICE1", - "S_FHZICE2", - "S_ROSY_IDLE1", - "S_ROSY_IDLE2", - "S_ROSY_IDLE3", - "S_ROSY_IDLE4", - "S_ROSY_JUMP", - "S_ROSY_WALK", - "S_ROSY_HUG", - "S_ROSY_PAIN", - "S_ROSY_STND", - "S_ROSY_UNHAPPY", - - // Halloween Scenery - // Pumpkins - "S_JACKO1", - "S_JACKO1OVERLAY_1", - "S_JACKO1OVERLAY_2", - "S_JACKO1OVERLAY_3", - "S_JACKO1OVERLAY_4", - "S_JACKO2", - "S_JACKO2OVERLAY_1", - "S_JACKO2OVERLAY_2", - "S_JACKO2OVERLAY_3", - "S_JACKO2OVERLAY_4", - "S_JACKO3", - "S_JACKO3OVERLAY_1", - "S_JACKO3OVERLAY_2", - "S_JACKO3OVERLAY_3", - "S_JACKO3OVERLAY_4", - // Dr Seuss Trees - "S_HHZTREE_TOP", - "S_HHZTREE_TRUNK", - "S_HHZTREE_LEAF", - // Mushroom - "S_HHZSHROOM_1", - "S_HHZSHROOM_2", - "S_HHZSHROOM_3", - "S_HHZSHROOM_4", - "S_HHZSHROOM_5", - "S_HHZSHROOM_6", - "S_HHZSHROOM_7", - "S_HHZSHROOM_8", - "S_HHZSHROOM_9", - "S_HHZSHROOM_10", - "S_HHZSHROOM_11", - "S_HHZSHROOM_12", - "S_HHZSHROOM_13", - "S_HHZSHROOM_14", - "S_HHZSHROOM_15", - "S_HHZSHROOM_16", - // Misc - "S_HHZGRASS", - "S_HHZTENT1", - "S_HHZTENT2", - "S_HHZSTALAGMITE_TALL", - "S_HHZSTALAGMITE_SHORT", - - // Botanic Serenity's loads of scenery states - "S_BSZTALLFLOWER_RED", - "S_BSZTALLFLOWER_PURPLE", - "S_BSZTALLFLOWER_BLUE", - "S_BSZTALLFLOWER_CYAN", - "S_BSZTALLFLOWER_YELLOW", - "S_BSZTALLFLOWER_ORANGE", - "S_BSZFLOWER_RED", - "S_BSZFLOWER_PURPLE", - "S_BSZFLOWER_BLUE", - "S_BSZFLOWER_CYAN", - "S_BSZFLOWER_YELLOW", - "S_BSZFLOWER_ORANGE", - "S_BSZSHORTFLOWER_RED", - "S_BSZSHORTFLOWER_PURPLE", - "S_BSZSHORTFLOWER_BLUE", - "S_BSZSHORTFLOWER_CYAN", - "S_BSZSHORTFLOWER_YELLOW", - "S_BSZSHORTFLOWER_ORANGE", - "S_BSZTULIP_RED", - "S_BSZTULIP_PURPLE", - "S_BSZTULIP_BLUE", - "S_BSZTULIP_CYAN", - "S_BSZTULIP_YELLOW", - "S_BSZTULIP_ORANGE", - "S_BSZCLUSTER_RED", - "S_BSZCLUSTER_PURPLE", - "S_BSZCLUSTER_BLUE", - "S_BSZCLUSTER_CYAN", - "S_BSZCLUSTER_YELLOW", - "S_BSZCLUSTER_ORANGE", - "S_BSZBUSH_RED", - "S_BSZBUSH_PURPLE", - "S_BSZBUSH_BLUE", - "S_BSZBUSH_CYAN", - "S_BSZBUSH_YELLOW", - "S_BSZBUSH_ORANGE", - "S_BSZVINE_RED", - "S_BSZVINE_PURPLE", - "S_BSZVINE_BLUE", - "S_BSZVINE_CYAN", - "S_BSZVINE_YELLOW", - "S_BSZVINE_ORANGE", - "S_BSZSHRUB", - "S_BSZCLOVER", - "S_BIG_PALMTREE_TRUNK", - "S_BIG_PALMTREE_TOP", - "S_PALMTREE_TRUNK", - "S_PALMTREE_TOP", - - "S_DBALL1", - "S_DBALL2", - "S_DBALL3", - "S_DBALL4", - "S_DBALL5", - "S_DBALL6", - "S_EGGSTATUE2", - - // Shield Orb - "S_ARMA1", - "S_ARMA2", - "S_ARMA3", - "S_ARMA4", - "S_ARMA5", - "S_ARMA6", - "S_ARMA7", - "S_ARMA8", - "S_ARMA9", - "S_ARMA10", - "S_ARMA11", - "S_ARMA12", - "S_ARMA13", - "S_ARMA14", - "S_ARMA15", - "S_ARMA16", - - "S_ARMF1", - "S_ARMF2", - "S_ARMF3", - "S_ARMF4", - "S_ARMF5", - "S_ARMF6", - "S_ARMF7", - "S_ARMF8", - "S_ARMF9", - "S_ARMF10", - "S_ARMF11", - "S_ARMF12", - "S_ARMF13", - "S_ARMF14", - "S_ARMF15", - "S_ARMF16", - "S_ARMF17", - "S_ARMF18", - "S_ARMF19", - "S_ARMF20", - "S_ARMF21", - "S_ARMF22", - "S_ARMF23", - "S_ARMF24", - "S_ARMF25", - "S_ARMF26", - "S_ARMF27", - "S_ARMF28", - "S_ARMF29", - "S_ARMF30", - "S_ARMF31", - "S_ARMF32", - - "S_ARMB1", - "S_ARMB2", - "S_ARMB3", - "S_ARMB4", - "S_ARMB5", - "S_ARMB6", - "S_ARMB7", - "S_ARMB8", - "S_ARMB9", - "S_ARMB10", - "S_ARMB11", - "S_ARMB12", - "S_ARMB13", - "S_ARMB14", - "S_ARMB15", - "S_ARMB16", - "S_ARMB17", - "S_ARMB18", - "S_ARMB19", - "S_ARMB20", - "S_ARMB21", - "S_ARMB22", - "S_ARMB23", - "S_ARMB24", - "S_ARMB25", - "S_ARMB26", - "S_ARMB27", - "S_ARMB28", - "S_ARMB29", - "S_ARMB30", - "S_ARMB31", - "S_ARMB32", - - "S_WIND1", - "S_WIND2", - "S_WIND3", - "S_WIND4", - "S_WIND5", - "S_WIND6", - "S_WIND7", - "S_WIND8", - - "S_MAGN1", - "S_MAGN2", - "S_MAGN3", - "S_MAGN4", - "S_MAGN5", - "S_MAGN6", - "S_MAGN7", - "S_MAGN8", - "S_MAGN9", - "S_MAGN10", - "S_MAGN11", - "S_MAGN12", - "S_MAGN13", - - "S_FORC1", - "S_FORC2", - "S_FORC3", - "S_FORC4", - "S_FORC5", - "S_FORC6", - "S_FORC7", - "S_FORC8", - "S_FORC9", - "S_FORC10", - - "S_FORC11", - "S_FORC12", - "S_FORC13", - "S_FORC14", - "S_FORC15", - "S_FORC16", - "S_FORC17", - "S_FORC18", - "S_FORC19", - "S_FORC20", - - "S_FORC21", - - "S_ELEM1", - "S_ELEM2", - "S_ELEM3", - "S_ELEM4", - "S_ELEM5", - "S_ELEM6", - "S_ELEM7", - "S_ELEM8", - "S_ELEM9", - "S_ELEM10", - "S_ELEM11", - "S_ELEM12", - - "S_ELEM13", - "S_ELEM14", - - "S_ELEMF1", - "S_ELEMF2", - "S_ELEMF3", - "S_ELEMF4", - "S_ELEMF5", - "S_ELEMF6", - "S_ELEMF7", - "S_ELEMF8", - "S_ELEMF9", - "S_ELEMF10", - - "S_PITY1", - "S_PITY2", - "S_PITY3", - "S_PITY4", - "S_PITY5", - "S_PITY6", - "S_PITY7", - "S_PITY8", - "S_PITY9", - "S_PITY10", - "S_PITY11", - "S_PITY12", - - "S_FIRS1", - "S_FIRS2", - "S_FIRS3", - "S_FIRS4", - "S_FIRS5", - "S_FIRS6", - "S_FIRS7", - "S_FIRS8", - "S_FIRS9", - - "S_FIRS10", - "S_FIRS11", - - "S_FIRSB1", - "S_FIRSB2", - "S_FIRSB3", - "S_FIRSB4", - "S_FIRSB5", - "S_FIRSB6", - "S_FIRSB7", - "S_FIRSB8", - "S_FIRSB9", - - "S_FIRSB10", - - "S_BUBS1", - "S_BUBS2", - "S_BUBS3", - "S_BUBS4", - "S_BUBS5", - "S_BUBS6", - "S_BUBS7", - "S_BUBS8", - "S_BUBS9", - - "S_BUBS10", - "S_BUBS11", - - "S_BUBSB1", - "S_BUBSB2", - "S_BUBSB3", - "S_BUBSB4", - - "S_BUBSB5", - "S_BUBSB6", - - "S_ZAPS1", - "S_ZAPS2", - "S_ZAPS3", - "S_ZAPS4", - "S_ZAPS5", - "S_ZAPS6", - "S_ZAPS7", - "S_ZAPS8", - "S_ZAPS9", - "S_ZAPS10", - "S_ZAPS11", - "S_ZAPS12", - "S_ZAPS13", // blank frame - "S_ZAPS14", - "S_ZAPS15", - "S_ZAPS16", - - "S_ZAPSB1", // blank frame - "S_ZAPSB2", - "S_ZAPSB3", - "S_ZAPSB4", - "S_ZAPSB5", - "S_ZAPSB6", - "S_ZAPSB7", - "S_ZAPSB8", - "S_ZAPSB9", - "S_ZAPSB10", - "S_ZAPSB11", // blank frame - - //Thunder spark - "S_THUNDERCOIN_SPARK", - - // Invincibility Sparkles - "S_IVSP", - - // Super Sonic Spark - "S_SSPK1", - "S_SSPK2", - "S_SSPK3", - "S_SSPK4", - "S_SSPK5", - - // Flicky-sized bubble - "S_FLICKY_BUBBLE", - - // Bluebird - "S_FLICKY_01_OUT", - "S_FLICKY_01_FLAP1", - "S_FLICKY_01_FLAP2", - "S_FLICKY_01_FLAP3", - "S_FLICKY_01_STAND", - "S_FLICKY_01_CENTER", - - // Rabbit - "S_FLICKY_02_OUT", - "S_FLICKY_02_AIM", - "S_FLICKY_02_HOP", - "S_FLICKY_02_UP", - "S_FLICKY_02_DOWN", - "S_FLICKY_02_STAND", - "S_FLICKY_02_CENTER", - - // Chicken - "S_FLICKY_03_OUT", - "S_FLICKY_03_AIM", - "S_FLICKY_03_HOP", - "S_FLICKY_03_UP", - "S_FLICKY_03_FLAP1", - "S_FLICKY_03_FLAP2", - "S_FLICKY_03_STAND", - "S_FLICKY_03_CENTER", - - // Seal - "S_FLICKY_04_OUT", - "S_FLICKY_04_AIM", - "S_FLICKY_04_HOP", - "S_FLICKY_04_UP", - "S_FLICKY_04_DOWN", - "S_FLICKY_04_SWIM1", - "S_FLICKY_04_SWIM2", - "S_FLICKY_04_SWIM3", - "S_FLICKY_04_SWIM4", - "S_FLICKY_04_STAND", - "S_FLICKY_04_CENTER", - - // Pig - "S_FLICKY_05_OUT", - "S_FLICKY_05_AIM", - "S_FLICKY_05_HOP", - "S_FLICKY_05_UP", - "S_FLICKY_05_DOWN", - "S_FLICKY_05_STAND", - "S_FLICKY_05_CENTER", - - // Chipmunk - "S_FLICKY_06_OUT", - "S_FLICKY_06_AIM", - "S_FLICKY_06_HOP", - "S_FLICKY_06_UP", - "S_FLICKY_06_DOWN", - "S_FLICKY_06_STAND", - "S_FLICKY_06_CENTER", - - // Penguin - "S_FLICKY_07_OUT", - "S_FLICKY_07_AIML", - "S_FLICKY_07_HOPL", - "S_FLICKY_07_UPL", - "S_FLICKY_07_DOWNL", - "S_FLICKY_07_AIMR", - "S_FLICKY_07_HOPR", - "S_FLICKY_07_UPR", - "S_FLICKY_07_DOWNR", - "S_FLICKY_07_SWIM1", - "S_FLICKY_07_SWIM2", - "S_FLICKY_07_SWIM3", - "S_FLICKY_07_STAND", - "S_FLICKY_07_CENTER", - - // Fish - "S_FLICKY_08_OUT", - "S_FLICKY_08_AIM", - "S_FLICKY_08_HOP", - "S_FLICKY_08_FLAP1", - "S_FLICKY_08_FLAP2", - "S_FLICKY_08_FLAP3", - "S_FLICKY_08_FLAP4", - "S_FLICKY_08_SWIM1", - "S_FLICKY_08_SWIM2", - "S_FLICKY_08_SWIM3", - "S_FLICKY_08_SWIM4", - "S_FLICKY_08_STAND", - "S_FLICKY_08_CENTER", - - // Ram - "S_FLICKY_09_OUT", - "S_FLICKY_09_AIM", - "S_FLICKY_09_HOP", - "S_FLICKY_09_UP", - "S_FLICKY_09_DOWN", - "S_FLICKY_09_STAND", - "S_FLICKY_09_CENTER", - - // Puffin - "S_FLICKY_10_OUT", - "S_FLICKY_10_FLAP1", - "S_FLICKY_10_FLAP2", - "S_FLICKY_10_STAND", - "S_FLICKY_10_CENTER", - - // Cow - "S_FLICKY_11_OUT", - "S_FLICKY_11_AIM", - "S_FLICKY_11_RUN1", - "S_FLICKY_11_RUN2", - "S_FLICKY_11_RUN3", - "S_FLICKY_11_STAND", - "S_FLICKY_11_CENTER", - - // Rat - "S_FLICKY_12_OUT", - "S_FLICKY_12_AIM", - "S_FLICKY_12_RUN1", - "S_FLICKY_12_RUN2", - "S_FLICKY_12_RUN3", - "S_FLICKY_12_STAND", - "S_FLICKY_12_CENTER", - - // Bear - "S_FLICKY_13_OUT", - "S_FLICKY_13_AIM", - "S_FLICKY_13_HOP", - "S_FLICKY_13_UP", - "S_FLICKY_13_DOWN", - "S_FLICKY_13_STAND", - "S_FLICKY_13_CENTER", - - // Dove - "S_FLICKY_14_OUT", - "S_FLICKY_14_FLAP1", - "S_FLICKY_14_FLAP2", - "S_FLICKY_14_FLAP3", - "S_FLICKY_14_STAND", - "S_FLICKY_14_CENTER", - - // Cat - "S_FLICKY_15_OUT", - "S_FLICKY_15_AIM", - "S_FLICKY_15_HOP", - "S_FLICKY_15_UP", - "S_FLICKY_15_DOWN", - "S_FLICKY_15_STAND", - "S_FLICKY_15_CENTER", - - // Canary - "S_FLICKY_16_OUT", - "S_FLICKY_16_FLAP1", - "S_FLICKY_16_FLAP2", - "S_FLICKY_16_FLAP3", - "S_FLICKY_16_STAND", - "S_FLICKY_16_CENTER", - - // Spider - "S_SECRETFLICKY_01_OUT", - "S_SECRETFLICKY_01_AIM", - "S_SECRETFLICKY_01_HOP", - "S_SECRETFLICKY_01_UP", - "S_SECRETFLICKY_01_DOWN", - "S_SECRETFLICKY_01_STAND", - "S_SECRETFLICKY_01_CENTER", - - // Bat - "S_SECRETFLICKY_02_OUT", - "S_SECRETFLICKY_02_FLAP1", - "S_SECRETFLICKY_02_FLAP2", - "S_SECRETFLICKY_02_FLAP3", - "S_SECRETFLICKY_02_STAND", - "S_SECRETFLICKY_02_CENTER", - - // Fan - "S_FAN", - "S_FAN2", - "S_FAN3", - "S_FAN4", - "S_FAN5", - - // Steam Riser - "S_STEAM1", - "S_STEAM2", - "S_STEAM3", - "S_STEAM4", - "S_STEAM5", - "S_STEAM6", - "S_STEAM7", - "S_STEAM8", - - // Bumpers - "S_BUMPER", - "S_BUMPERHIT", - - // Balloons - "S_BALLOON", - "S_BALLOONPOP1", - "S_BALLOONPOP2", - "S_BALLOONPOP3", - "S_BALLOONPOP4", - "S_BALLOONPOP5", - "S_BALLOONPOP6", - - // Yellow Spring - "S_YELLOWSPRING", - "S_YELLOWSPRING2", - "S_YELLOWSPRING3", - "S_YELLOWSPRING4", - "S_YELLOWSPRING5", - - // Red Spring - "S_REDSPRING", - "S_REDSPRING2", - "S_REDSPRING3", - "S_REDSPRING4", - "S_REDSPRING5", - - // Blue Spring - "S_BLUESPRING", - "S_BLUESPRING2", - "S_BLUESPRING3", - "S_BLUESPRING4", - "S_BLUESPRING5", - - // Yellow Diagonal Spring - "S_YDIAG1", - "S_YDIAG2", - "S_YDIAG3", - "S_YDIAG4", - "S_YDIAG5", - "S_YDIAG6", - "S_YDIAG7", - "S_YDIAG8", - - // Red Diagonal Spring - "S_RDIAG1", - "S_RDIAG2", - "S_RDIAG3", - "S_RDIAG4", - "S_RDIAG5", - "S_RDIAG6", - "S_RDIAG7", - "S_RDIAG8", - - // Blue Diagonal Spring - "S_BDIAG1", - "S_BDIAG2", - "S_BDIAG3", - "S_BDIAG4", - "S_BDIAG5", - "S_BDIAG6", - "S_BDIAG7", - "S_BDIAG8", - - // Yellow Side Spring - "S_YHORIZ1", - "S_YHORIZ2", - "S_YHORIZ3", - "S_YHORIZ4", - "S_YHORIZ5", - "S_YHORIZ6", - "S_YHORIZ7", - "S_YHORIZ8", - - // Red Side Spring - "S_RHORIZ1", - "S_RHORIZ2", - "S_RHORIZ3", - "S_RHORIZ4", - "S_RHORIZ5", - "S_RHORIZ6", - "S_RHORIZ7", - "S_RHORIZ8", - - // Blue Side Spring - "S_BHORIZ1", - "S_BHORIZ2", - "S_BHORIZ3", - "S_BHORIZ4", - "S_BHORIZ5", - "S_BHORIZ6", - "S_BHORIZ7", - "S_BHORIZ8", - - // Booster - "S_BOOSTERSOUND", - "S_YELLOWBOOSTERROLLER", - "S_YELLOWBOOSTERSEG_LEFT", - "S_YELLOWBOOSTERSEG_RIGHT", - "S_YELLOWBOOSTERSEG_FACE", - "S_REDBOOSTERROLLER", - "S_REDBOOSTERSEG_LEFT", - "S_REDBOOSTERSEG_RIGHT", - "S_REDBOOSTERSEG_FACE", - - // Rain - "S_RAIN1", - "S_RAINRETURN", - - // Snowflake - "S_SNOW1", - "S_SNOW2", - "S_SNOW3", - - // Water Splish - "S_SPLISH1", - "S_SPLISH2", - "S_SPLISH3", - "S_SPLISH4", - "S_SPLISH5", - "S_SPLISH6", - "S_SPLISH7", - "S_SPLISH8", - "S_SPLISH9", - - // Lava Splish - "S_LAVASPLISH", - - // added water splash - "S_SPLASH1", - "S_SPLASH2", - "S_SPLASH3", - - // lava/slime damage burn smoke - "S_SMOKE1", - "S_SMOKE2", - "S_SMOKE3", - "S_SMOKE4", - "S_SMOKE5", - - // Bubbles - "S_SMALLBUBBLE", - "S_MEDIUMBUBBLE", - "S_LARGEBUBBLE1", - "S_LARGEBUBBLE2", - "S_EXTRALARGEBUBBLE", // breathable - - "S_POP1", // Extra Large bubble goes POP! - - "S_WATERZAP", - - // Spindash dust - "S_SPINDUST1", - "S_SPINDUST2", - "S_SPINDUST3", - "S_SPINDUST4", - "S_SPINDUST_BUBBLE1", - "S_SPINDUST_BUBBLE2", - "S_SPINDUST_BUBBLE3", - "S_SPINDUST_BUBBLE4", - "S_SPINDUST_FIRE1", - "S_SPINDUST_FIRE2", - "S_SPINDUST_FIRE3", - "S_SPINDUST_FIRE4", - - "S_FOG1", - "S_FOG2", - "S_FOG3", - "S_FOG4", - "S_FOG5", - "S_FOG6", - "S_FOG7", - "S_FOG8", - "S_FOG9", - "S_FOG10", - "S_FOG11", - "S_FOG12", - "S_FOG13", - "S_FOG14", - - "S_SEED", - - "S_PARTICLE", - - // Score Logos - "S_SCRA", // 100 - "S_SCRB", // 200 - "S_SCRC", // 500 - "S_SCRD", // 1000 - "S_SCRE", // 10000 - "S_SCRF", // 400 (mario) - "S_SCRG", // 800 (mario) - "S_SCRH", // 2000 (mario) - "S_SCRI", // 4000 (mario) - "S_SCRJ", // 8000 (mario) - "S_SCRK", // 1UP (mario) - "S_SCRL", // 10 - - // Drowning Timer Numbers - "S_ZERO1", - "S_ONE1", - "S_TWO1", - "S_THREE1", - "S_FOUR1", - "S_FIVE1", - - "S_ZERO2", - "S_ONE2", - "S_TWO2", - "S_THREE2", - "S_FOUR2", - "S_FIVE2", - - "S_FLIGHTINDICATOR", - - "S_LOCKON1", - "S_LOCKON2", - "S_LOCKON3", - "S_LOCKON4", - "S_LOCKONINF1", - "S_LOCKONINF2", - "S_LOCKONINF3", - "S_LOCKONINF4", - - // Tag Sign - "S_TTAG", - - // Got Flag Sign - "S_GOTFLAG", - - // Finish flag - "S_FINISHFLAG", - - "S_CORK", - "S_LHRT", - - // Red Ring - "S_RRNG1", - "S_RRNG2", - "S_RRNG3", - "S_RRNG4", - "S_RRNG5", - "S_RRNG6", - "S_RRNG7", - - // Weapon Ring Ammo - "S_BOUNCERINGAMMO", - "S_RAILRINGAMMO", - "S_INFINITYRINGAMMO", - "S_AUTOMATICRINGAMMO", - "S_EXPLOSIONRINGAMMO", - "S_SCATTERRINGAMMO", - "S_GRENADERINGAMMO", - - // Weapon pickup - "S_BOUNCEPICKUP", - "S_BOUNCEPICKUPFADE1", - "S_BOUNCEPICKUPFADE2", - "S_BOUNCEPICKUPFADE3", - "S_BOUNCEPICKUPFADE4", - "S_BOUNCEPICKUPFADE5", - "S_BOUNCEPICKUPFADE6", - "S_BOUNCEPICKUPFADE7", - "S_BOUNCEPICKUPFADE8", - - "S_RAILPICKUP", - "S_RAILPICKUPFADE1", - "S_RAILPICKUPFADE2", - "S_RAILPICKUPFADE3", - "S_RAILPICKUPFADE4", - "S_RAILPICKUPFADE5", - "S_RAILPICKUPFADE6", - "S_RAILPICKUPFADE7", - "S_RAILPICKUPFADE8", - - "S_AUTOPICKUP", - "S_AUTOPICKUPFADE1", - "S_AUTOPICKUPFADE2", - "S_AUTOPICKUPFADE3", - "S_AUTOPICKUPFADE4", - "S_AUTOPICKUPFADE5", - "S_AUTOPICKUPFADE6", - "S_AUTOPICKUPFADE7", - "S_AUTOPICKUPFADE8", - - "S_EXPLODEPICKUP", - "S_EXPLODEPICKUPFADE1", - "S_EXPLODEPICKUPFADE2", - "S_EXPLODEPICKUPFADE3", - "S_EXPLODEPICKUPFADE4", - "S_EXPLODEPICKUPFADE5", - "S_EXPLODEPICKUPFADE6", - "S_EXPLODEPICKUPFADE7", - "S_EXPLODEPICKUPFADE8", - - "S_SCATTERPICKUP", - "S_SCATTERPICKUPFADE1", - "S_SCATTERPICKUPFADE2", - "S_SCATTERPICKUPFADE3", - "S_SCATTERPICKUPFADE4", - "S_SCATTERPICKUPFADE5", - "S_SCATTERPICKUPFADE6", - "S_SCATTERPICKUPFADE7", - "S_SCATTERPICKUPFADE8", - - "S_GRENADEPICKUP", - "S_GRENADEPICKUPFADE1", - "S_GRENADEPICKUPFADE2", - "S_GRENADEPICKUPFADE3", - "S_GRENADEPICKUPFADE4", - "S_GRENADEPICKUPFADE5", - "S_GRENADEPICKUPFADE6", - "S_GRENADEPICKUPFADE7", - "S_GRENADEPICKUPFADE8", - - // Thrown Weapon Rings - "S_THROWNBOUNCE1", - "S_THROWNBOUNCE2", - "S_THROWNBOUNCE3", - "S_THROWNBOUNCE4", - "S_THROWNBOUNCE5", - "S_THROWNBOUNCE6", - "S_THROWNBOUNCE7", - "S_THROWNINFINITY1", - "S_THROWNINFINITY2", - "S_THROWNINFINITY3", - "S_THROWNINFINITY4", - "S_THROWNINFINITY5", - "S_THROWNINFINITY6", - "S_THROWNINFINITY7", - "S_THROWNAUTOMATIC1", - "S_THROWNAUTOMATIC2", - "S_THROWNAUTOMATIC3", - "S_THROWNAUTOMATIC4", - "S_THROWNAUTOMATIC5", - "S_THROWNAUTOMATIC6", - "S_THROWNAUTOMATIC7", - "S_THROWNEXPLOSION1", - "S_THROWNEXPLOSION2", - "S_THROWNEXPLOSION3", - "S_THROWNEXPLOSION4", - "S_THROWNEXPLOSION5", - "S_THROWNEXPLOSION6", - "S_THROWNEXPLOSION7", - "S_THROWNGRENADE1", - "S_THROWNGRENADE2", - "S_THROWNGRENADE3", - "S_THROWNGRENADE4", - "S_THROWNGRENADE5", - "S_THROWNGRENADE6", - "S_THROWNGRENADE7", - "S_THROWNGRENADE8", - "S_THROWNGRENADE9", - "S_THROWNGRENADE10", - "S_THROWNGRENADE11", - "S_THROWNGRENADE12", - "S_THROWNGRENADE13", - "S_THROWNGRENADE14", - "S_THROWNGRENADE15", - "S_THROWNGRENADE16", - "S_THROWNGRENADE17", - "S_THROWNGRENADE18", - "S_THROWNSCATTER", - - "S_RINGEXPLODE", - - "S_COIN1", - "S_COIN2", - "S_COIN3", - "S_COINSPARKLE1", - "S_COINSPARKLE2", - "S_COINSPARKLE3", - "S_COINSPARKLE4", - "S_GOOMBA1", - "S_GOOMBA1B", - "S_GOOMBA2", - "S_GOOMBA3", - "S_GOOMBA4", - "S_GOOMBA5", - "S_GOOMBA6", - "S_GOOMBA7", - "S_GOOMBA8", - "S_GOOMBA9", - "S_GOOMBA_DEAD", - "S_BLUEGOOMBA1", - "S_BLUEGOOMBA1B", - "S_BLUEGOOMBA2", - "S_BLUEGOOMBA3", - "S_BLUEGOOMBA4", - "S_BLUEGOOMBA5", - "S_BLUEGOOMBA6", - "S_BLUEGOOMBA7", - "S_BLUEGOOMBA8", - "S_BLUEGOOMBA9", - "S_BLUEGOOMBA_DEAD", - - // Mario-specific stuff - "S_FIREFLOWER1", - "S_FIREFLOWER2", - "S_FIREFLOWER3", - "S_FIREFLOWER4", - "S_FIREBALL", - "S_FIREBALLTRAIL1", - "S_FIREBALLTRAIL2", - "S_SHELL", - "S_PUMA_START1", - "S_PUMA_START2", - "S_PUMA_UP1", - "S_PUMA_UP2", - "S_PUMA_UP3", - "S_PUMA_DOWN1", - "S_PUMA_DOWN2", - "S_PUMA_DOWN3", - "S_PUMATRAIL1", - "S_PUMATRAIL2", - "S_PUMATRAIL3", - "S_PUMATRAIL4", - "S_HAMMER", - "S_KOOPA1", - "S_KOOPA2", - "S_KOOPAFLAME1", - "S_KOOPAFLAME2", - "S_KOOPAFLAME3", - "S_AXE1", - "S_AXE2", - "S_AXE3", - "S_MARIOBUSH1", - "S_MARIOBUSH2", - "S_TOAD", - - // Nights-specific stuff - "S_NIGHTSDRONE_MAN1", - "S_NIGHTSDRONE_MAN2", - "S_NIGHTSDRONE_SPARKLING1", - "S_NIGHTSDRONE_SPARKLING2", - "S_NIGHTSDRONE_SPARKLING3", - "S_NIGHTSDRONE_SPARKLING4", - "S_NIGHTSDRONE_SPARKLING5", - "S_NIGHTSDRONE_SPARKLING6", - "S_NIGHTSDRONE_SPARKLING7", - "S_NIGHTSDRONE_SPARKLING8", - "S_NIGHTSDRONE_SPARKLING9", - "S_NIGHTSDRONE_SPARKLING10", - "S_NIGHTSDRONE_SPARKLING11", - "S_NIGHTSDRONE_SPARKLING12", - "S_NIGHTSDRONE_SPARKLING13", - "S_NIGHTSDRONE_SPARKLING14", - "S_NIGHTSDRONE_SPARKLING15", - "S_NIGHTSDRONE_SPARKLING16", - "S_NIGHTSDRONE_GOAL1", - "S_NIGHTSDRONE_GOAL2", - "S_NIGHTSDRONE_GOAL3", - "S_NIGHTSDRONE_GOAL4", - - "S_NIGHTSPARKLE1", - "S_NIGHTSPARKLE2", - "S_NIGHTSPARKLE3", - "S_NIGHTSPARKLE4", - "S_NIGHTSPARKLESUPER1", - "S_NIGHTSPARKLESUPER2", - "S_NIGHTSPARKLESUPER3", - "S_NIGHTSPARKLESUPER4", - "S_NIGHTSLOOPHELPER", - - // NiGHTS bumper - "S_NIGHTSBUMPER1", - "S_NIGHTSBUMPER2", - "S_NIGHTSBUMPER3", - "S_NIGHTSBUMPER4", - "S_NIGHTSBUMPER5", - "S_NIGHTSBUMPER6", - "S_NIGHTSBUMPER7", - "S_NIGHTSBUMPER8", - "S_NIGHTSBUMPER9", - "S_NIGHTSBUMPER10", - "S_NIGHTSBUMPER11", - "S_NIGHTSBUMPER12", - - "S_HOOP", - "S_HOOP_XMASA", - "S_HOOP_XMASB", - - "S_NIGHTSCORE10", - "S_NIGHTSCORE20", - "S_NIGHTSCORE30", - "S_NIGHTSCORE40", - "S_NIGHTSCORE50", - "S_NIGHTSCORE60", - "S_NIGHTSCORE70", - "S_NIGHTSCORE80", - "S_NIGHTSCORE90", - "S_NIGHTSCORE100", - "S_NIGHTSCORE10_2", - "S_NIGHTSCORE20_2", - "S_NIGHTSCORE30_2", - "S_NIGHTSCORE40_2", - "S_NIGHTSCORE50_2", - "S_NIGHTSCORE60_2", - "S_NIGHTSCORE70_2", - "S_NIGHTSCORE80_2", - "S_NIGHTSCORE90_2", - "S_NIGHTSCORE100_2", - - // NiGHTS Paraloop Powerups - "S_NIGHTSSUPERLOOP", - "S_NIGHTSDRILLREFILL", - "S_NIGHTSHELPER", - "S_NIGHTSEXTRATIME", - "S_NIGHTSLINKFREEZE", - "S_EGGCAPSULE", - - // Orbiting Chaos Emeralds - "S_ORBITEM1", - "S_ORBITEM2", - "S_ORBITEM3", - "S_ORBITEM4", - "S_ORBITEM5", - "S_ORBITEM6", - "S_ORBITEM7", - "S_ORBITEM8", - "S_ORBIDYA1", - "S_ORBIDYA2", - "S_ORBIDYA3", - "S_ORBIDYA4", - "S_ORBIDYA5", - - // "Flicky" helper - "S_NIGHTOPIANHELPER1", - "S_NIGHTOPIANHELPER2", - "S_NIGHTOPIANHELPER3", - "S_NIGHTOPIANHELPER4", - "S_NIGHTOPIANHELPER5", - "S_NIGHTOPIANHELPER6", - "S_NIGHTOPIANHELPER7", - "S_NIGHTOPIANHELPER8", - "S_NIGHTOPIANHELPER9", - - // Nightopian - "S_PIAN0", - "S_PIAN1", - "S_PIAN2", - "S_PIAN3", - "S_PIAN4", - "S_PIAN5", - "S_PIAN6", - "S_PIANSING", - - // Shleep - "S_SHLEEP1", - "S_SHLEEP2", - "S_SHLEEP3", - "S_SHLEEP4", - "S_SHLEEPBOUNCE1", - "S_SHLEEPBOUNCE2", - "S_SHLEEPBOUNCE3", - - // Secret badniks and hazards, shhhh - "S_PENGUINATOR_LOOK", - "S_PENGUINATOR_WADDLE1", - "S_PENGUINATOR_WADDLE2", - "S_PENGUINATOR_WADDLE3", - "S_PENGUINATOR_WADDLE4", - "S_PENGUINATOR_SLIDE1", - "S_PENGUINATOR_SLIDE2", - "S_PENGUINATOR_SLIDE3", - "S_PENGUINATOR_SLIDE4", - "S_PENGUINATOR_SLIDE5", - - "S_POPHAT_LOOK", - "S_POPHAT_SHOOT1", - "S_POPHAT_SHOOT2", - "S_POPHAT_SHOOT3", - "S_POPHAT_SHOOT4", - "S_POPSHOT", - "S_POPSHOT_TRAIL", - - "S_HIVEELEMENTAL_LOOK", - "S_HIVEELEMENTAL_PREPARE1", - "S_HIVEELEMENTAL_PREPARE2", - "S_HIVEELEMENTAL_SHOOT1", - "S_HIVEELEMENTAL_SHOOT2", - "S_HIVEELEMENTAL_DORMANT", - "S_HIVEELEMENTAL_PAIN", - "S_HIVEELEMENTAL_DIE1", - "S_HIVEELEMENTAL_DIE2", - "S_HIVEELEMENTAL_DIE3", - - "S_BUMBLEBORE_SPAWN", - "S_BUMBLEBORE_LOOK1", - "S_BUMBLEBORE_LOOK2", - "S_BUMBLEBORE_FLY1", - "S_BUMBLEBORE_FLY2", - "S_BUMBLEBORE_RAISE", - "S_BUMBLEBORE_FALL1", - "S_BUMBLEBORE_FALL2", - "S_BUMBLEBORE_STUCK1", - "S_BUMBLEBORE_STUCK2", - "S_BUMBLEBORE_DIE", - - "S_BUGGLEIDLE", - "S_BUGGLEFLY", - - "S_SMASHSPIKE_FLOAT", - "S_SMASHSPIKE_EASE1", - "S_SMASHSPIKE_EASE2", - "S_SMASHSPIKE_FALL", - "S_SMASHSPIKE_STOMP1", - "S_SMASHSPIKE_STOMP2", - "S_SMASHSPIKE_RISE1", - "S_SMASHSPIKE_RISE2", - - "S_CACO_LOOK", - "S_CACO_WAKE1", - "S_CACO_WAKE2", - "S_CACO_WAKE3", - "S_CACO_WAKE4", - "S_CACO_ROAR", - "S_CACO_CHASE", - "S_CACO_CHASE_REPEAT", - "S_CACO_RANDOM", - "S_CACO_PREPARE_SOUND", - "S_CACO_PREPARE1", - "S_CACO_PREPARE2", - "S_CACO_PREPARE3", - "S_CACO_SHOOT_SOUND", - "S_CACO_SHOOT1", - "S_CACO_SHOOT2", - "S_CACO_CLOSE", - "S_CACO_DIE_FLAGS", - "S_CACO_DIE_GIB1", - "S_CACO_DIE_GIB2", - "S_CACO_DIE_SCREAM", - "S_CACO_DIE_SHATTER", - "S_CACO_DIE_FALL", - "S_CACOSHARD_RANDOMIZE", - "S_CACOSHARD1_1", - "S_CACOSHARD1_2", - "S_CACOSHARD2_1", - "S_CACOSHARD2_2", - "S_CACOFIRE1", - "S_CACOFIRE2", - "S_CACOFIRE3", - "S_CACOFIRE_EXPLODE1", - "S_CACOFIRE_EXPLODE2", - "S_CACOFIRE_EXPLODE3", - "S_CACOFIRE_EXPLODE4", - - "S_SPINBOBERT_MOVE_FLIPUP", - "S_SPINBOBERT_MOVE_UP", - "S_SPINBOBERT_MOVE_FLIPDOWN", - "S_SPINBOBERT_MOVE_DOWN", - "S_SPINBOBERT_FIRE_MOVE", - "S_SPINBOBERT_FIRE_GHOST", - "S_SPINBOBERT_FIRE_TRAIL1", - "S_SPINBOBERT_FIRE_TRAIL2", - "S_SPINBOBERT_FIRE_TRAIL3", - - "S_HANGSTER_LOOK", - "S_HANGSTER_SWOOP1", - "S_HANGSTER_SWOOP2", - "S_HANGSTER_ARC1", - "S_HANGSTER_ARC2", - "S_HANGSTER_ARC3", - "S_HANGSTER_FLY1", - "S_HANGSTER_FLY2", - "S_HANGSTER_FLY3", - "S_HANGSTER_FLY4", - "S_HANGSTER_FLYREPEAT", - "S_HANGSTER_ARCUP1", - "S_HANGSTER_ARCUP2", - "S_HANGSTER_ARCUP3", - "S_HANGSTER_RETURN1", - "S_HANGSTER_RETURN2", - "S_HANGSTER_RETURN3", - - "S_CRUMBLE1", - "S_CRUMBLE2", - - // Spark - "S_SPRK1", - "S_SPRK2", - "S_SPRK3", - - // Robot Explosion - "S_XPLD_FLICKY", - "S_XPLD1", - "S_XPLD2", - "S_XPLD3", - "S_XPLD4", - "S_XPLD5", - "S_XPLD6", - "S_XPLD_EGGTRAP", - - // Underwater Explosion - "S_WPLD1", - "S_WPLD2", - "S_WPLD3", - "S_WPLD4", - "S_WPLD5", - "S_WPLD6", - - "S_DUST1", - "S_DUST2", - "S_DUST3", - "S_DUST4", - - "S_ROCKSPAWN", - - "S_ROCKCRUMBLEA", - "S_ROCKCRUMBLEB", - "S_ROCKCRUMBLEC", - "S_ROCKCRUMBLED", - "S_ROCKCRUMBLEE", - "S_ROCKCRUMBLEF", - "S_ROCKCRUMBLEG", - "S_ROCKCRUMBLEH", - "S_ROCKCRUMBLEI", - "S_ROCKCRUMBLEJ", - "S_ROCKCRUMBLEK", - "S_ROCKCRUMBLEL", - "S_ROCKCRUMBLEM", - "S_ROCKCRUMBLEN", - "S_ROCKCRUMBLEO", - "S_ROCKCRUMBLEP", - - // Level debris - "S_GFZDEBRIS", - "S_BRICKDEBRIS", - "S_WOODDEBRIS", - "S_REDBRICKDEBRIS", - "S_BLUEBRICKDEBRIS", - "S_YELLOWBRICKDEBRIS", - -#ifdef SEENAMES - "S_NAMECHECK", -#endif -}; - -// RegEx to generate this from info.h: ^\tMT_([^,]+), --> \t"MT_\1", -// I am leaving the prefixes solely for clarity to programmers, -// because sadly no one remembers this place while searching for full state names. -static const char *const MOBJTYPE_LIST[] = { // array length left dynamic for sanity testing later. - "MT_NULL", - "MT_UNKNOWN", - - "MT_THOK", // Thok! mobj - "MT_PLAYER", - "MT_TAILSOVERLAY", // c: - "MT_METALJETFUME", - - // Enemies - "MT_BLUECRAWLA", // Crawla (Blue) - "MT_REDCRAWLA", // Crawla (Red) - "MT_GFZFISH", // SDURF - "MT_GOLDBUZZ", // Buzz (Gold) - "MT_REDBUZZ", // Buzz (Red) - "MT_JETTBOMBER", // Jetty-Syn Bomber - "MT_JETTGUNNER", // Jetty-Syn Gunner - "MT_CRAWLACOMMANDER", // Crawla Commander - "MT_DETON", // Deton - "MT_SKIM", // Skim mine dropper - "MT_TURRET", // Industrial Turret - "MT_POPUPTURRET", // Pop-Up Turret - "MT_SPINCUSHION", // Spincushion - "MT_CRUSHSTACEAN", // Crushstacean - "MT_CRUSHCLAW", // Big meaty claw - "MT_CRUSHCHAIN", // Chain - "MT_BANPYURA", // Banpyura - "MT_BANPSPRING", // Banpyura spring - "MT_JETJAW", // Jet Jaw - "MT_SNAILER", // Snailer - "MT_VULTURE", // BASH - "MT_POINTY", // Pointy - "MT_POINTYBALL", // Pointy Ball - "MT_ROBOHOOD", // Robo-Hood - "MT_FACESTABBER", // Castlebot Facestabber - "MT_FACESTABBERSPEAR", // Castlebot Facestabber spear aura - "MT_EGGGUARD", // Egg Guard - "MT_EGGSHIELD", // Egg Guard's shield - "MT_GSNAPPER", // Green Snapper - "MT_SNAPPER_LEG", // Green Snapper leg - "MT_SNAPPER_HEAD", // Green Snapper head - "MT_MINUS", // Minus - "MT_MINUSDIRT", // Minus dirt - "MT_SPRINGSHELL", // Spring Shell - "MT_YELLOWSHELL", // Spring Shell (yellow) - "MT_UNIDUS", // Unidus - "MT_UNIBALL", // Unidus Ball - "MT_CANARIVORE", // Canarivore - "MT_CANARIVORE_GAS", // Canarivore gas - "MT_PYREFLY", // Pyre Fly - "MT_PYREFLY_FIRE", // Pyre Fly fire - "MT_PTERABYTESPAWNER", // Pterabyte spawner - "MT_PTERABYTEWAYPOINT", // Pterabyte waypoint - "MT_PTERABYTE", // Pterabyte - "MT_DRAGONBOMBER", // Dragonbomber - "MT_DRAGONWING", // Dragonbomber wing - "MT_DRAGONTAIL", // Dragonbomber tail segment - "MT_DRAGONMINE", // Dragonbomber mine - - // Generic Boss Items - "MT_BOSSEXPLODE", - "MT_SONIC3KBOSSEXPLODE", - "MT_BOSSFLYPOINT", - "MT_EGGTRAP", - "MT_BOSS3WAYPOINT", - "MT_BOSS9GATHERPOINT", - "MT_BOSSJUNK", - - // Boss 1 - "MT_EGGMOBILE", - "MT_JETFUME1", - "MT_EGGMOBILE_BALL", - "MT_EGGMOBILE_TARGET", - "MT_EGGMOBILE_FIRE", - - // Boss 2 - "MT_EGGMOBILE2", - "MT_EGGMOBILE2_POGO", - "MT_GOOP", - "MT_GOOPTRAIL", - - // Boss 3 - "MT_EGGMOBILE3", - "MT_FAKEMOBILE", - "MT_SHOCKWAVE", - - // Boss 4 - "MT_EGGMOBILE4", - "MT_EGGMOBILE4_MACE", - "MT_JETFLAME", - "MT_EGGROBO1", - "MT_EGGROBO1JET", - - // Boss 5 - "MT_FANG", - "MT_BROKENROBOT", - "MT_VWREF", - "MT_VWREB", - "MT_PROJECTORLIGHT", - "MT_FBOMB", - "MT_TNTDUST", // also used by barrel - "MT_FSGNA", - "MT_FSGNB", - "MT_FANGWAYPOINT", - - // Black Eggman (Boss 7) - "MT_BLACKEGGMAN", - "MT_BLACKEGGMAN_HELPER", - "MT_BLACKEGGMAN_GOOPFIRE", - "MT_BLACKEGGMAN_MISSILE", - - // New Very-Last-Minute 2.1 Brak Eggman (Cy-Brak-demon) - "MT_CYBRAKDEMON", - "MT_CYBRAKDEMON_ELECTRIC_BARRIER", - "MT_CYBRAKDEMON_MISSILE", - "MT_CYBRAKDEMON_FLAMESHOT", - "MT_CYBRAKDEMON_FLAMEREST", - "MT_CYBRAKDEMON_TARGET_RETICULE", - "MT_CYBRAKDEMON_TARGET_DOT", - "MT_CYBRAKDEMON_NAPALM_BOMB_LARGE", - "MT_CYBRAKDEMON_NAPALM_BOMB_SMALL", - "MT_CYBRAKDEMON_NAPALM_FLAMES", - "MT_CYBRAKDEMON_VILE_EXPLOSION", - - // Metal Sonic (Boss 9) - "MT_METALSONIC_RACE", - "MT_METALSONIC_BATTLE", - "MT_MSSHIELD_FRONT", - "MT_MSGATHER", - - // Collectible Items - "MT_RING", - "MT_FLINGRING", // Lost ring - "MT_BLUESPHERE", // Blue sphere for special stages - "MT_FLINGBLUESPHERE", // Lost blue sphere - "MT_BOMBSPHERE", - "MT_REDTEAMRING", //Rings collectable by red team. - "MT_BLUETEAMRING", //Rings collectable by blue team. - "MT_TOKEN", // Special Stage token for special stage - "MT_REDFLAG", // Red CTF Flag - "MT_BLUEFLAG", // Blue CTF Flag - "MT_EMBLEM", - "MT_EMERALD1", - "MT_EMERALD2", - "MT_EMERALD3", - "MT_EMERALD4", - "MT_EMERALD5", - "MT_EMERALD6", - "MT_EMERALD7", - "MT_EMERHUNT", // Emerald Hunt - "MT_EMERALDSPAWN", // Emerald spawner w/ delay - "MT_FLINGEMERALD", // Lost emerald - - // Springs and others - "MT_FAN", - "MT_STEAM", - "MT_BUMPER", - "MT_BALLOON", - - "MT_YELLOWSPRING", - "MT_REDSPRING", - "MT_BLUESPRING", - "MT_YELLOWDIAG", - "MT_REDDIAG", - "MT_BLUEDIAG", - "MT_YELLOWHORIZ", - "MT_REDHORIZ", - "MT_BLUEHORIZ", - - "MT_BOOSTERSEG", - "MT_BOOSTERROLLER", - "MT_YELLOWBOOSTER", - "MT_REDBOOSTER", - - // Interactive Objects - "MT_BUBBLES", // Bubble source - "MT_SIGN", // Level end sign - "MT_SPIKEBALL", // Spike Ball - "MT_SPINFIRE", - "MT_SPIKE", - "MT_WALLSPIKE", - "MT_WALLSPIKEBASE", - "MT_STARPOST", - "MT_BIGMINE", - "MT_BLASTEXECUTOR", - "MT_CANNONLAUNCHER", - - // Monitor miscellany - "MT_BOXSPARKLE", - - // Monitor boxes -- regular - "MT_RING_BOX", - "MT_PITY_BOX", - "MT_ATTRACT_BOX", - "MT_FORCE_BOX", - "MT_ARMAGEDDON_BOX", - "MT_WHIRLWIND_BOX", - "MT_ELEMENTAL_BOX", - "MT_SNEAKERS_BOX", - "MT_INVULN_BOX", - "MT_1UP_BOX", - "MT_EGGMAN_BOX", - "MT_MIXUP_BOX", - "MT_MYSTERY_BOX", - "MT_GRAVITY_BOX", - "MT_RECYCLER_BOX", - "MT_SCORE1K_BOX", - "MT_SCORE10K_BOX", - "MT_FLAMEAURA_BOX", - "MT_BUBBLEWRAP_BOX", - "MT_THUNDERCOIN_BOX", - - // Monitor boxes -- repeating (big) boxes - "MT_PITY_GOLDBOX", - "MT_ATTRACT_GOLDBOX", - "MT_FORCE_GOLDBOX", - "MT_ARMAGEDDON_GOLDBOX", - "MT_WHIRLWIND_GOLDBOX", - "MT_ELEMENTAL_GOLDBOX", - "MT_SNEAKERS_GOLDBOX", - "MT_INVULN_GOLDBOX", - "MT_EGGMAN_GOLDBOX", - "MT_GRAVITY_GOLDBOX", - "MT_FLAMEAURA_GOLDBOX", - "MT_BUBBLEWRAP_GOLDBOX", - "MT_THUNDERCOIN_GOLDBOX", - - // Monitor boxes -- special - "MT_RING_REDBOX", - "MT_RING_BLUEBOX", - - // Monitor icons - "MT_RING_ICON", - "MT_PITY_ICON", - "MT_ATTRACT_ICON", - "MT_FORCE_ICON", - "MT_ARMAGEDDON_ICON", - "MT_WHIRLWIND_ICON", - "MT_ELEMENTAL_ICON", - "MT_SNEAKERS_ICON", - "MT_INVULN_ICON", - "MT_1UP_ICON", - "MT_EGGMAN_ICON", - "MT_MIXUP_ICON", - "MT_GRAVITY_ICON", - "MT_RECYCLER_ICON", - "MT_SCORE1K_ICON", - "MT_SCORE10K_ICON", - "MT_FLAMEAURA_ICON", - "MT_BUBBLEWRAP_ICON", - "MT_THUNDERCOIN_ICON", - - // Projectiles - "MT_ROCKET", - "MT_LASER", - "MT_TORPEDO", - "MT_TORPEDO2", // silent - "MT_ENERGYBALL", - "MT_MINE", // Skim/Jetty-Syn mine - "MT_JETTBULLET", // Jetty-Syn Bullet - "MT_TURRETLASER", - "MT_CANNONBALL", // Cannonball - "MT_CANNONBALLDECOR", // Decorative/still cannonball - "MT_ARROW", // Arrow - "MT_DEMONFIRE", // Glaregoyle fire - - // The letter - "MT_LETTER", - - // Greenflower Scenery - "MT_GFZFLOWER1", - "MT_GFZFLOWER2", - "MT_GFZFLOWER3", - - "MT_BLUEBERRYBUSH", - "MT_BERRYBUSH", - "MT_BUSH", - - // Trees (both GFZ and misc) - "MT_GFZTREE", - "MT_GFZBERRYTREE", - "MT_GFZCHERRYTREE", - "MT_CHECKERTREE", - "MT_CHECKERSUNSETTREE", - "MT_FHZTREE", // Frozen Hillside - "MT_FHZPINKTREE", - "MT_POLYGONTREE", - "MT_BUSHTREE", - "MT_BUSHREDTREE", - "MT_SPRINGTREE", - - // Techno Hill Scenery - "MT_THZFLOWER1", - "MT_THZFLOWER2", - "MT_THZFLOWER3", - "MT_THZTREE", // Steam whistle tree/bush - "MT_THZTREEBRANCH", // branch of said tree - "MT_ALARM", - - // Deep Sea Scenery - "MT_GARGOYLE", // Deep Sea Gargoyle - "MT_BIGGARGOYLE", // Deep Sea Gargoyle (Big) - "MT_SEAWEED", // DSZ Seaweed - "MT_WATERDRIP", // Dripping Water source - "MT_WATERDROP", // Water drop from dripping water - "MT_CORAL1", // Coral - "MT_CORAL2", - "MT_CORAL3", - "MT_CORAL4", - "MT_CORAL5", - "MT_BLUECRYSTAL", // Blue Crystal - "MT_KELP", // Kelp - "MT_ANIMALGAETOP", // Animated algae top - "MT_ANIMALGAESEG", // Animated algae segment - "MT_DSZSTALAGMITE", // Deep Sea 1 Stalagmite - "MT_DSZ2STALAGMITE", // Deep Sea 2 Stalagmite - "MT_LIGHTBEAM", // DSZ Light beam - - // Castle Eggman Scenery - "MT_CHAIN", // CEZ Chain - "MT_FLAME", // Flame (has corona) - "MT_FLAMEPARTICLE", - "MT_EGGSTATUE", // Eggman Statue - "MT_MACEPOINT", // Mace rotation point - "MT_CHAINMACEPOINT", // Combination of chains and maces point - "MT_SPRINGBALLPOINT", // Spring ball point - "MT_CHAINPOINT", // Mace chain - "MT_HIDDEN_SLING", // Spin mace chain (activatable) - "MT_FIREBARPOINT", // Firebar - "MT_CUSTOMMACEPOINT", // Custom mace - "MT_SMALLMACECHAIN", // Small Mace Chain - "MT_BIGMACECHAIN", // Big Mace Chain - "MT_SMALLMACE", // Small Mace - "MT_BIGMACE", // Big Mace - "MT_SMALLGRABCHAIN", // Small Grab Chain - "MT_BIGGRABCHAIN", // Big Grab Chain - "MT_YELLOWSPRINGBALL", // Yellow spring on a ball - "MT_REDSPRINGBALL", // Red spring on a ball - "MT_SMALLFIREBAR", // Small Firebar - "MT_BIGFIREBAR", // Big Firebar - "MT_CEZFLOWER", // Flower - "MT_CEZPOLE1", // Pole (with red banner) - "MT_CEZPOLE2", // Pole (with blue banner) - "MT_CEZBANNER1", // Banner (red) - "MT_CEZBANNER2", // Banner (blue) - "MT_PINETREE", // Pine Tree - "MT_CEZBUSH1", // Bush 1 - "MT_CEZBUSH2", // Bush 2 - "MT_CANDLE", // Candle - "MT_CANDLEPRICKET", // Candle pricket - "MT_FLAMEHOLDER", // Flame holder - "MT_FIRETORCH", // Fire torch - "MT_WAVINGFLAG1", // Waving flag (red) - "MT_WAVINGFLAG2", // Waving flag (blue) - "MT_WAVINGFLAGSEG1", // Waving flag segment (red) - "MT_WAVINGFLAGSEG2", // Waving flag segment (blue) - "MT_CRAWLASTATUE", // Crawla statue - "MT_FACESTABBERSTATUE", // Facestabber statue - "MT_SUSPICIOUSFACESTABBERSTATUE", // :eggthinking: - "MT_BRAMBLES", // Brambles - - // Arid Canyon Scenery - "MT_BIGTUMBLEWEED", - "MT_LITTLETUMBLEWEED", - "MT_CACTI1", // Tiny Red Flower Cactus - "MT_CACTI2", // Small Red Flower Cactus - "MT_CACTI3", // Tiny Blue Flower Cactus - "MT_CACTI4", // Small Blue Flower Cactus - "MT_CACTI5", // Prickly Pear - "MT_CACTI6", // Barrel Cactus - "MT_CACTI7", // Tall Barrel Cactus - "MT_CACTI8", // Armed Cactus - "MT_CACTI9", // Ball Cactus - "MT_CACTI10", // Tiny Cactus - "MT_CACTI11", // Small Cactus - "MT_CACTITINYSEG", // Tiny Cactus Segment - "MT_CACTISMALLSEG", // Small Cactus Segment - "MT_ARIDSIGN_CAUTION", // Caution Sign - "MT_ARIDSIGN_CACTI", // Cacti Sign - "MT_ARIDSIGN_SHARPTURN", // Sharp Turn Sign - "MT_OILLAMP", - "MT_TNTBARREL", - "MT_PROXIMITYTNT", - "MT_DUSTDEVIL", - "MT_DUSTLAYER", - "MT_ARIDDUST", - "MT_MINECART", - "MT_MINECARTSEG", - "MT_MINECARTSPAWNER", - "MT_MINECARTEND", - "MT_MINECARTENDSOLID", - "MT_MINECARTSIDEMARK", - "MT_MINECARTSPARK", - "MT_SALOONDOOR", - "MT_SALOONDOORCENTER", - "MT_TRAINCAMEOSPAWNER", - "MT_TRAINSEG", - "MT_TRAINDUSTSPAWNER", - "MT_TRAINSTEAMSPAWNER", - "MT_MINECARTSWITCHPOINT", - - // Red Volcano Scenery - "MT_FLAMEJET", - "MT_VERTICALFLAMEJET", - "MT_FLAMEJETFLAME", - - "MT_FJSPINAXISA", // Counter-clockwise - "MT_FJSPINAXISB", // Clockwise - - "MT_FLAMEJETFLAMEB", // Blade's flame - - "MT_LAVAFALL", - "MT_LAVAFALL_LAVA", - "MT_LAVAFALLROCK", - - "MT_ROLLOUTSPAWN", - "MT_ROLLOUTROCK", - - "MT_BIGFERNLEAF", - "MT_BIGFERN", - "MT_JUNGLEPALM", - "MT_TORCHFLOWER", - "MT_WALLVINE_LONG", - "MT_WALLVINE_SHORT", - - // Dark City Scenery - - // Egg Rock Scenery - - // Azure Temple Scenery - "MT_GLAREGOYLE", - "MT_GLAREGOYLEUP", - "MT_GLAREGOYLEDOWN", - "MT_GLAREGOYLELONG", - "MT_TARGET", // AKA Red Crystal - "MT_GREENFLAME", - "MT_BLUEGARGOYLE", - - // Stalagmites - "MT_STALAGMITE0", - "MT_STALAGMITE1", - "MT_STALAGMITE2", - "MT_STALAGMITE3", - "MT_STALAGMITE4", - "MT_STALAGMITE5", - "MT_STALAGMITE6", - "MT_STALAGMITE7", - "MT_STALAGMITE8", - "MT_STALAGMITE9", - - // Christmas Scenery - "MT_XMASPOLE", - "MT_CANDYCANE", - "MT_SNOWMAN", // normal - "MT_SNOWMANHAT", // with hat + scarf - "MT_LAMPPOST1", // normal - "MT_LAMPPOST2", // with snow - "MT_HANGSTAR", - "MT_MISTLETOE", - // Xmas GFZ bushes - "MT_XMASBLUEBERRYBUSH", - "MT_XMASBERRYBUSH", - "MT_XMASBUSH", - // FHZ - "MT_FHZICE1", - "MT_FHZICE2", - "MT_ROSY", - "MT_CDLHRT", - - // Halloween Scenery - // Pumpkins - "MT_JACKO1", - "MT_JACKO2", - "MT_JACKO3", - // Dr Seuss Trees - "MT_HHZTREE_TOP", - "MT_HHZTREE_PART", - // Misc - "MT_HHZSHROOM", - "MT_HHZGRASS", - "MT_HHZTENTACLE1", - "MT_HHZTENTACLE2", - "MT_HHZSTALAGMITE_TALL", - "MT_HHZSTALAGMITE_SHORT", - - // Botanic Serenity scenery - "MT_BSZTALLFLOWER_RED", - "MT_BSZTALLFLOWER_PURPLE", - "MT_BSZTALLFLOWER_BLUE", - "MT_BSZTALLFLOWER_CYAN", - "MT_BSZTALLFLOWER_YELLOW", - "MT_BSZTALLFLOWER_ORANGE", - "MT_BSZFLOWER_RED", - "MT_BSZFLOWER_PURPLE", - "MT_BSZFLOWER_BLUE", - "MT_BSZFLOWER_CYAN", - "MT_BSZFLOWER_YELLOW", - "MT_BSZFLOWER_ORANGE", - "MT_BSZSHORTFLOWER_RED", - "MT_BSZSHORTFLOWER_PURPLE", - "MT_BSZSHORTFLOWER_BLUE", - "MT_BSZSHORTFLOWER_CYAN", - "MT_BSZSHORTFLOWER_YELLOW", - "MT_BSZSHORTFLOWER_ORANGE", - "MT_BSZTULIP_RED", - "MT_BSZTULIP_PURPLE", - "MT_BSZTULIP_BLUE", - "MT_BSZTULIP_CYAN", - "MT_BSZTULIP_YELLOW", - "MT_BSZTULIP_ORANGE", - "MT_BSZCLUSTER_RED", - "MT_BSZCLUSTER_PURPLE", - "MT_BSZCLUSTER_BLUE", - "MT_BSZCLUSTER_CYAN", - "MT_BSZCLUSTER_YELLOW", - "MT_BSZCLUSTER_ORANGE", - "MT_BSZBUSH_RED", - "MT_BSZBUSH_PURPLE", - "MT_BSZBUSH_BLUE", - "MT_BSZBUSH_CYAN", - "MT_BSZBUSH_YELLOW", - "MT_BSZBUSH_ORANGE", - "MT_BSZVINE_RED", - "MT_BSZVINE_PURPLE", - "MT_BSZVINE_BLUE", - "MT_BSZVINE_CYAN", - "MT_BSZVINE_YELLOW", - "MT_BSZVINE_ORANGE", - "MT_BSZSHRUB", - "MT_BSZCLOVER", - "MT_BIG_PALMTREE_TRUNK", - "MT_BIG_PALMTREE_TOP", - "MT_PALMTREE_TRUNK", - "MT_PALMTREE_TOP", - - // Misc scenery - "MT_DBALL", - "MT_EGGSTATUE2", - - // Powerup Indicators - "MT_ELEMENTAL_ORB", // Elemental shield mobj - "MT_ATTRACT_ORB", // Attract shield mobj - "MT_FORCE_ORB", // Force shield mobj - "MT_ARMAGEDDON_ORB", // Armageddon shield mobj - "MT_WHIRLWIND_ORB", // Whirlwind shield mobj - "MT_PITY_ORB", // Pity shield mobj - "MT_FLAMEAURA_ORB", // Flame shield mobj - "MT_BUBBLEWRAP_ORB", // Bubble shield mobj - "MT_THUNDERCOIN_ORB", // Thunder shield mobj - "MT_THUNDERCOIN_SPARK", // Thunder spark - "MT_IVSP", // Invincibility sparkles - "MT_SUPERSPARK", // Super Sonic Spark - - // Flickies - "MT_FLICKY_01", // Bluebird - "MT_FLICKY_01_CENTER", - "MT_FLICKY_02", // Rabbit - "MT_FLICKY_02_CENTER", - "MT_FLICKY_03", // Chicken - "MT_FLICKY_03_CENTER", - "MT_FLICKY_04", // Seal - "MT_FLICKY_04_CENTER", - "MT_FLICKY_05", // Pig - "MT_FLICKY_05_CENTER", - "MT_FLICKY_06", // Chipmunk - "MT_FLICKY_06_CENTER", - "MT_FLICKY_07", // Penguin - "MT_FLICKY_07_CENTER", - "MT_FLICKY_08", // Fish - "MT_FLICKY_08_CENTER", - "MT_FLICKY_09", // Ram - "MT_FLICKY_09_CENTER", - "MT_FLICKY_10", // Puffin - "MT_FLICKY_10_CENTER", - "MT_FLICKY_11", // Cow - "MT_FLICKY_11_CENTER", - "MT_FLICKY_12", // Rat - "MT_FLICKY_12_CENTER", - "MT_FLICKY_13", // Bear - "MT_FLICKY_13_CENTER", - "MT_FLICKY_14", // Dove - "MT_FLICKY_14_CENTER", - "MT_FLICKY_15", // Cat - "MT_FLICKY_15_CENTER", - "MT_FLICKY_16", // Canary - "MT_FLICKY_16_CENTER", - "MT_SECRETFLICKY_01", // Spider - "MT_SECRETFLICKY_01_CENTER", - "MT_SECRETFLICKY_02", // Bat - "MT_SECRETFLICKY_02_CENTER", - "MT_SEED", - - // Environmental Effects - "MT_RAIN", // Rain - "MT_SNOWFLAKE", // Snowflake - "MT_SPLISH", // Water splish! - "MT_LAVASPLISH", // Lava splish! - "MT_SMOKE", - "MT_SMALLBUBBLE", // small bubble - "MT_MEDIUMBUBBLE", // medium bubble - "MT_EXTRALARGEBUBBLE", // extra large bubble - "MT_WATERZAP", - "MT_SPINDUST", // Spindash dust - "MT_TFOG", - "MT_PARTICLE", - "MT_PARTICLEGEN", // For fans, etc. - - // Game Indicators - "MT_SCORE", // score logo - "MT_DROWNNUMBERS", // Drowning Timer - "MT_GOTEMERALD", // Chaos Emerald (intangible) - "MT_LOCKON", // Target - "MT_LOCKONINF", // In-level Target - "MT_TAG", // Tag Sign - "MT_GOTFLAG", // Got Flag sign - "MT_FINISHFLAG", // Finish flag - - // Ambient Sounds - "MT_AWATERA", // Ambient Water Sound 1 - "MT_AWATERB", // Ambient Water Sound 2 - "MT_AWATERC", // Ambient Water Sound 3 - "MT_AWATERD", // Ambient Water Sound 4 - "MT_AWATERE", // Ambient Water Sound 5 - "MT_AWATERF", // Ambient Water Sound 6 - "MT_AWATERG", // Ambient Water Sound 7 - "MT_AWATERH", // Ambient Water Sound 8 - "MT_RANDOMAMBIENT", - "MT_RANDOMAMBIENT2", - "MT_MACHINEAMBIENCE", - - "MT_CORK", - "MT_LHRT", - - // Ring Weapons - "MT_REDRING", - "MT_BOUNCERING", - "MT_RAILRING", - "MT_INFINITYRING", - "MT_AUTOMATICRING", - "MT_EXPLOSIONRING", - "MT_SCATTERRING", - "MT_GRENADERING", - - "MT_BOUNCEPICKUP", - "MT_RAILPICKUP", - "MT_AUTOPICKUP", - "MT_EXPLODEPICKUP", - "MT_SCATTERPICKUP", - "MT_GRENADEPICKUP", - - "MT_THROWNBOUNCE", - "MT_THROWNINFINITY", - "MT_THROWNAUTOMATIC", - "MT_THROWNSCATTER", - "MT_THROWNEXPLOSION", - "MT_THROWNGRENADE", - - // Mario-specific stuff - "MT_COIN", - "MT_FLINGCOIN", - "MT_GOOMBA", - "MT_BLUEGOOMBA", - "MT_FIREFLOWER", - "MT_FIREBALL", - "MT_FIREBALLTRAIL", - "MT_SHELL", - "MT_PUMA", - "MT_PUMATRAIL", - "MT_HAMMER", - "MT_KOOPA", - "MT_KOOPAFLAME", - "MT_AXE", - "MT_MARIOBUSH1", - "MT_MARIOBUSH2", - "MT_TOAD", - - // NiGHTS Stuff - "MT_AXIS", - "MT_AXISTRANSFER", - "MT_AXISTRANSFERLINE", - "MT_NIGHTSDRONE", - "MT_NIGHTSDRONE_MAN", - "MT_NIGHTSDRONE_SPARKLING", - "MT_NIGHTSDRONE_GOAL", - "MT_NIGHTSPARKLE", - "MT_NIGHTSLOOPHELPER", - "MT_NIGHTSBUMPER", // NiGHTS Bumper - "MT_HOOP", - "MT_HOOPCOLLIDE", // Collision detection for NiGHTS hoops - "MT_HOOPCENTER", // Center of a hoop - "MT_NIGHTSCORE", - "MT_NIGHTSCHIP", // NiGHTS Chip - "MT_FLINGNIGHTSCHIP", // Lost NiGHTS Chip - "MT_NIGHTSSTAR", // NiGHTS Star - "MT_FLINGNIGHTSSTAR", // Lost NiGHTS Star - "MT_NIGHTSSUPERLOOP", - "MT_NIGHTSDRILLREFILL", - "MT_NIGHTSHELPER", - "MT_NIGHTSEXTRATIME", - "MT_NIGHTSLINKFREEZE", - "MT_EGGCAPSULE", - "MT_IDEYAANCHOR", - "MT_NIGHTOPIANHELPER", // the actual helper object that orbits you - "MT_PIAN", // decorative singing friend - "MT_SHLEEP", // almost-decorative sleeping enemy - - // Secret badniks and hazards, shhhh - "MT_PENGUINATOR", - "MT_POPHAT", - "MT_POPSHOT", - "MT_POPSHOT_TRAIL", - - "MT_HIVEELEMENTAL", - "MT_BUMBLEBORE", - - "MT_BUGGLE", - - "MT_SMASHINGSPIKEBALL", - "MT_CACOLANTERN", - "MT_CACOSHARD", - "MT_CACOFIRE", - "MT_SPINBOBERT", - "MT_SPINBOBERT_FIRE1", - "MT_SPINBOBERT_FIRE2", - "MT_HANGSTER", - - // Utility Objects - "MT_TELEPORTMAN", - "MT_ALTVIEWMAN", - "MT_CRUMBLEOBJ", // Sound generator for crumbling platform - "MT_TUBEWAYPOINT", - "MT_PUSH", - "MT_PULL", - "MT_GHOST", - "MT_OVERLAY", - "MT_ANGLEMAN", - "MT_POLYANCHOR", - "MT_POLYSPAWN", - - // Skybox objects - "MT_SKYBOX", - - // Debris - "MT_SPARK", //spark - "MT_EXPLODE", // Robot Explosion - "MT_UWEXPLODE", // Underwater Explosion - "MT_DUST", - "MT_ROCKSPAWNER", - "MT_FALLINGROCK", - "MT_ROCKCRUMBLE1", - "MT_ROCKCRUMBLE2", - "MT_ROCKCRUMBLE3", - "MT_ROCKCRUMBLE4", - "MT_ROCKCRUMBLE5", - "MT_ROCKCRUMBLE6", - "MT_ROCKCRUMBLE7", - "MT_ROCKCRUMBLE8", - "MT_ROCKCRUMBLE9", - "MT_ROCKCRUMBLE10", - "MT_ROCKCRUMBLE11", - "MT_ROCKCRUMBLE12", - "MT_ROCKCRUMBLE13", - "MT_ROCKCRUMBLE14", - "MT_ROCKCRUMBLE15", - "MT_ROCKCRUMBLE16", - - // Level debris - "MT_GFZDEBRIS", - "MT_BRICKDEBRIS", - "MT_WOODDEBRIS", - "MT_REDBRICKDEBRIS", - "MT_BLUEBRICKDEBRIS", - "MT_YELLOWBRICKDEBRIS", - -#ifdef SEENAMES - "MT_NAMECHECK", -#endif -}; - -static const char *const MOBJFLAG_LIST[] = { - "SPECIAL", - "SOLID", - "SHOOTABLE", - "NOSECTOR", - "NOBLOCKMAP", - "PAPERCOLLISION", - "PUSHABLE", - "BOSS", - "SPAWNCEILING", - "NOGRAVITY", - "AMBIENT", - "SLIDEME", - "NOCLIP", - "FLOAT", - "BOXICON", - "MISSILE", - "SPRING", - "BOUNCE", - "MONITOR", - "NOTHINK", - "FIRE", - "NOCLIPHEIGHT", - "ENEMY", - "SCENERY", - "PAIN", - "STICKY", - "NIGHTSITEM", - "NOCLIPTHING", - "GRENADEBOUNCE", - "RUNSPAWNFUNC", - NULL -}; - -// \tMF2_(\S+).*// (.+) --> \t"\1", // \2 -static const char *const MOBJFLAG2_LIST[] = { - "AXIS", // It's a NiGHTS axis! (For faster checking) - "TWOD", // Moves like it's in a 2D level - "DONTRESPAWN", // Don't respawn this object! - "DONTDRAW", // Don't generate a vissprite - "AUTOMATIC", // Thrown ring has automatic properties - "RAILRING", // Thrown ring has rail properties - "BOUNCERING", // Thrown ring has bounce properties - "EXPLOSION", // Thrown ring has explosive properties - "SCATTER", // Thrown ring has scatter properties - "BEYONDTHEGRAVE", // Source of this missile has died and has since respawned. - "SLIDEPUSH", // MF_PUSHABLE that pushes continuously. - "CLASSICPUSH", // Drops straight down when object has negative momz. - "INVERTAIMABLE", // Flips whether it's targetable by A_LookForEnemies (enemies no, decoys yes) - "INFLOAT", // Floating to a height for a move, don't auto float to target's height. - "DEBRIS", // Splash ring from explosion ring - "NIGHTSPULL", // Attracted from a paraloop - "JUSTATTACKED", // can be pushed by other moving mobjs - "FIRING", // turret fire - "SUPERFIRE", // Firing something with Super Sonic-stopping properties. Or, if mobj has MF_MISSILE, this is the actual fire from it. - "SHADOW", // Fuzzy draw, makes targeting harder. - "STRONGBOX", // Flag used for "strong" random monitors. - "OBJECTFLIP", // Flag for objects that always have flipped gravity. - "SKULLFLY", // Special handling: skull in flight. - "FRET", // Flashing from a previous hit - "BOSSNOTRAP", // No Egg Trap after boss - "BOSSFLEE", // Boss is fleeing! - "BOSSDEAD", // Boss is dead! (Not necessarily fleeing, if a fleeing point doesn't exist.) - "AMBUSH", // Alternate behaviour typically set by MTF_AMBUSH - "LINKDRAW", // Draw vissprite of mobj immediately before/after tracer's vissprite (dependent on dispoffset and position) - "SHIELD", // Thinker calls P_AddShield/P_ShieldLook (must be partnered with MF_SCENERY to use) - "SPLAT", // Object is a splat - NULL -}; - -static const char *const MOBJEFLAG_LIST[] = { - "ONGROUND", // The mobj stands on solid floor (not on another mobj or in air) - "JUSTHITFLOOR", // The mobj just hit the floor while falling, this is cleared on next frame - "TOUCHWATER", // The mobj stands in a sector with water, and touches the surface - "UNDERWATER", // The mobj stands in a sector with water, and his waist is BELOW the water surface - "JUSTSTEPPEDDOWN", // used for ramp sectors - "VERTICALFLIP", // Vertically flip sprite/allow upside-down physics - "GOOWATER", // Goo water - "TOUCHLAVA", // The mobj is touching a lava block - "PUSHED", // Mobj was already pushed this tic - "SPRUNG", // Mobj was already sprung this tic - "APPLYPMOMZ", // Platform movement - "TRACERANGLE", // Compute and trigger on mobj angle relative to tracer - NULL -}; - -static const char *const MAPTHINGFLAG_LIST[4] = { - "EXTRA", // Extra flag for objects. - "OBJECTFLIP", // Reverse gravity flag for objects. - "OBJECTSPECIAL", // Special flag used with certain objects. - "AMBUSH" // Deaf monsters/do not react to sound. -}; - -static const char *const PLAYERFLAG_LIST[] = { - - // Cvars - "FLIPCAM", // Flip camera angle with gravity flip prefrence. - "ANALOGMODE", // Analog mode? - "DIRECTIONCHAR", // Directional character sprites? - "AUTOBRAKE", // Autobrake? - - // Cheats - "GODMODE", - "NOCLIP", - "INVIS", - - // True if button down last tic. - "ATTACKDOWN", - "SPINDOWN", - "JUMPDOWN", - "WPNDOWN", - - // Unmoving states - "STASIS", // Player is not allowed to move - "JUMPSTASIS", // and that includes jumping. - // (we don't include FULLSTASIS here I guess because it's just those two together...?) - - // Applying autobrake? - "APPLYAUTOBRAKE", - - // Character action status - "STARTJUMP", - "JUMPED", - "NOJUMPDAMAGE", - - "SPINNING", - "STARTDASH", - - "THOKKED", - "SHIELDABILITY", - "GLIDING", - "BOUNCING", - - // Sliding (usually in water) like Labyrinth/Oil Ocean - "SLIDING", - - // NiGHTS stuff - "TRANSFERTOCLOSEST", - "DRILLING", - - // Gametype-specific stuff - "GAMETYPEOVER", // Race time over, or H&S out-of-game - "TAGIT", // The player is it! For Tag Mode - - /*** misc ***/ - "FORCESTRAFE", // Translate turn inputs into strafe inputs - "CANCARRY", // Can carry? - "FINISHED", - - NULL // stop loop here. -}; - -static const char *const GAMETYPERULE_LIST[] = { - "CAMPAIGN", - "RINGSLINGER", - "SPECTATORS", - "LIVES", - "TEAMS", - "FIRSTPERSON", - "POWERSTONES", - "TEAMFLAGS", - "FRIENDLY", - "SPECIALSTAGES", - "EMERALDTOKENS", - "EMERALDHUNT", - "RACE", - "TAG", - "POINTLIMIT", - "TIMELIMIT", - "OVERTIME", - "HURTMESSAGES", - "FRIENDLYFIRE", - "STARTCOUNTDOWN", - "HIDEFROZEN", - "BLINDFOLDED", - "RESPAWNDELAY", - "PITYSHIELD", - "DEATHPENALTY", - "NOSPECTATORSPAWN", - "DEATHMATCHSTARTS", - "SPAWNINVUL", - "SPAWNENEMIES", - "ALLOWEXIT", - "NOTITLECARD", - "CUTSCENES", - NULL -}; - -// Linedef flags -static const char *const ML_LIST[16] = { - "IMPASSIBLE", - "BLOCKMONSTERS", - "TWOSIDED", - "DONTPEGTOP", - "DONTPEGBOTTOM", - "EFFECT1", - "NOCLIMB", - "EFFECT2", - "EFFECT3", - "EFFECT4", - "EFFECT5", - "NOSONIC", - "NOTAILS", - "NOKNUX", - "BOUNCY", - "TFERLINE" -}; - -static const char *COLOR_ENUMS[] = { - "NONE", // SKINCOLOR_NONE, - - // Greyscale ranges - "WHITE", // SKINCOLOR_WHITE, - "BONE", // SKINCOLOR_BONE, - "CLOUDY", // SKINCOLOR_CLOUDY, - "GREY", // SKINCOLOR_GREY, - "SILVER", // SKINCOLOR_SILVER, - "CARBON", // SKINCOLOR_CARBON, - "JET", // SKINCOLOR_JET, - "BLACK", // SKINCOLOR_BLACK, - - // Desaturated - "AETHER", // SKINCOLOR_AETHER, - "SLATE", // SKINCOLOR_SLATE, - "BLUEBELL", // SKINCOLOR_BLUEBELL, - "PINK", // SKINCOLOR_PINK, - "YOGURT", // SKINCOLOR_YOGURT, - "BROWN", // SKINCOLOR_BROWN, - "BRONZE", // SKINCOLOR_BRONZE, - "TAN", // SKINCOLOR_TAN, - "BEIGE", // SKINCOLOR_BEIGE, - "MOSS", // SKINCOLOR_MOSS, - "AZURE", // SKINCOLOR_AZURE, - "LAVENDER", // SKINCOLOR_LAVENDER, - - // Viv's vivid colours (toast 21/07/17) - "RUBY", // SKINCOLOR_RUBY, - "SALMON", // SKINCOLOR_SALMON, - "RED", // SKINCOLOR_RED, - "CRIMSON", // SKINCOLOR_CRIMSON, - "FLAME", // SKINCOLOR_FLAME, - "KETCHUP", // SKINCOLOR_KETCHUP, - "PEACHY", // SKINCOLOR_PEACHY, - "QUAIL", // SKINCOLOR_QUAIL, - "SUNSET", // SKINCOLOR_SUNSET, - "COPPER", // SKINCOLOR_COPPER, - "APRICOT", // SKINCOLOR_APRICOT, - "ORANGE", // SKINCOLOR_ORANGE, - "RUST", // SKINCOLOR_RUST, - "GOLD", // SKINCOLOR_GOLD, - "SANDY", // SKINCOLOR_SANDY, - "YELLOW", // SKINCOLOR_YELLOW, - "OLIVE", // SKINCOLOR_OLIVE, - "LIME", // SKINCOLOR_LIME, - "PERIDOT", // SKINCOLOR_PERIDOT, - "APPLE", // SKINCOLOR_APPLE, - "GREEN", // SKINCOLOR_GREEN, - "FOREST", // SKINCOLOR_FOREST, - "EMERALD", // SKINCOLOR_EMERALD, - "MINT", // SKINCOLOR_MINT, - "SEAFOAM", // SKINCOLOR_SEAFOAM, - "AQUA", // SKINCOLOR_AQUA, - "TEAL", // SKINCOLOR_TEAL, - "WAVE", // SKINCOLOR_WAVE, - "CYAN", // SKINCOLOR_CYAN, - "SKY", // SKINCOLOR_SKY, - "CERULEAN", // SKINCOLOR_CERULEAN, - "ICY", // SKINCOLOR_ICY, - "SAPPHIRE", // SKINCOLOR_SAPPHIRE, - "CORNFLOWER", // SKINCOLOR_CORNFLOWER, - "BLUE", // SKINCOLOR_BLUE, - "COBALT", // SKINCOLOR_COBALT, - "VAPOR", // SKINCOLOR_VAPOR, - "DUSK", // SKINCOLOR_DUSK, - "PASTEL", // SKINCOLOR_PASTEL, - "PURPLE", // SKINCOLOR_PURPLE, - "BUBBLEGUM", // SKINCOLOR_BUBBLEGUM, - "MAGENTA", // SKINCOLOR_MAGENTA, - "NEON", // SKINCOLOR_NEON, - "VIOLET", // SKINCOLOR_VIOLET, - "LILAC", // SKINCOLOR_LILAC, - "PLUM", // SKINCOLOR_PLUM, - "RASPBERRY", // SKINCOLOR_RASPBERRY, - "ROSY", // SKINCOLOR_ROSY, - - // Super special awesome Super flashing colors! - "SUPERSILVER1", // SKINCOLOR_SUPERSILVER1 - "SUPERSILVER2", // SKINCOLOR_SUPERSILVER2, - "SUPERSILVER3", // SKINCOLOR_SUPERSILVER3, - "SUPERSILVER4", // SKINCOLOR_SUPERSILVER4, - "SUPERSILVER5", // SKINCOLOR_SUPERSILVER5, - - "SUPERRED1", // SKINCOLOR_SUPERRED1 - "SUPERRED2", // SKINCOLOR_SUPERRED2, - "SUPERRED3", // SKINCOLOR_SUPERRED3, - "SUPERRED4", // SKINCOLOR_SUPERRED4, - "SUPERRED5", // SKINCOLOR_SUPERRED5, - - "SUPERORANGE1", // SKINCOLOR_SUPERORANGE1 - "SUPERORANGE2", // SKINCOLOR_SUPERORANGE2, - "SUPERORANGE3", // SKINCOLOR_SUPERORANGE3, - "SUPERORANGE4", // SKINCOLOR_SUPERORANGE4, - "SUPERORANGE5", // SKINCOLOR_SUPERORANGE5, - - "SUPERGOLD1", // SKINCOLOR_SUPERGOLD1 - "SUPERGOLD2", // SKINCOLOR_SUPERGOLD2, - "SUPERGOLD3", // SKINCOLOR_SUPERGOLD3, - "SUPERGOLD4", // SKINCOLOR_SUPERGOLD4, - "SUPERGOLD5", // SKINCOLOR_SUPERGOLD5, - - "SUPERPERIDOT1", // SKINCOLOR_SUPERPERIDOT1 - "SUPERPERIDOT2", // SKINCOLOR_SUPERPERIDOT2, - "SUPERPERIDOT3", // SKINCOLOR_SUPERPERIDOT3, - "SUPERPERIDOT4", // SKINCOLOR_SUPERPERIDOT4, - "SUPERPERIDOT5", // SKINCOLOR_SUPERPERIDOT5, - - "SUPERSKY1", // SKINCOLOR_SUPERSKY1 - "SUPERSKY2", // SKINCOLOR_SUPERSKY2, - "SUPERSKY3", // SKINCOLOR_SUPERSKY3, - "SUPERSKY4", // SKINCOLOR_SUPERSKY4, - "SUPERSKY5", // SKINCOLOR_SUPERSKY5, - - "SUPERPURPLE1", // SKINCOLOR_SUPERPURPLE1, - "SUPERPURPLE2", // SKINCOLOR_SUPERPURPLE2, - "SUPERPURPLE3", // SKINCOLOR_SUPERPURPLE3, - "SUPERPURPLE4", // SKINCOLOR_SUPERPURPLE4, - "SUPERPURPLE5", // SKINCOLOR_SUPERPURPLE5, - - "SUPERRUST1", // SKINCOLOR_SUPERRUST1 - "SUPERRUST2", // SKINCOLOR_SUPERRUST2, - "SUPERRUST3", // SKINCOLOR_SUPERRUST3, - "SUPERRUST4", // SKINCOLOR_SUPERRUST4, - "SUPERRUST5", // SKINCOLOR_SUPERRUST5, - - "SUPERTAN1", // SKINCOLOR_SUPERTAN1 - "SUPERTAN2", // SKINCOLOR_SUPERTAN2, - "SUPERTAN3", // SKINCOLOR_SUPERTAN3, - "SUPERTAN4", // SKINCOLOR_SUPERTAN4, - "SUPERTAN5" // SKINCOLOR_SUPERTAN5, -}; - -static const char *const POWERS_LIST[] = { - "INVULNERABILITY", - "SNEAKERS", - "FLASHING", - "SHIELD", - "CARRY", - "TAILSFLY", // tails flying - "UNDERWATER", // underwater timer - "SPACETIME", // In space, no one can hear you spin! - "EXTRALIFE", // Extra Life timer - "PUSHING", - "JUSTSPRUNG", - "NOAUTOBRAKE", - - "SUPER", // Are you super? - "GRAVITYBOOTS", // gravity boots - - // Weapon ammunition - "INFINITYRING", - "AUTOMATICRING", - "BOUNCERING", - "SCATTERRING", - "GRENADERING", - "EXPLOSIONRING", - "RAILRING", - - // Power Stones - "EMERALDS", // stored like global 'emeralds' variable - - // NiGHTS powerups - "NIGHTS_SUPERLOOP", - "NIGHTS_HELPER", - "NIGHTS_LINKFREEZE", - - //for linedef exec 427 - "NOCONTROL", - - //for dyes - "DYE", - - "JUSTLAUNCHED", - - "IGNORELATCH" -}; - -static const char *const HUDITEMS_LIST[] = { - "LIVES", - - "RINGS", - "RINGSNUM", - "RINGSNUMTICS", - - "SCORE", - "SCORENUM", - - "TIME", - "MINUTES", - "TIMECOLON", - "SECONDS", - "TIMETICCOLON", - "TICS", - - "SS_TOTALRINGS", - - "GETRINGS", - "GETRINGSNUM", - "TIMELEFT", - "TIMELEFTNUM", - "TIMEUP", - "HUNTPICS", - "POWERUPS" -}; - -static const char *const MENUTYPES_LIST[] = { - "NONE", - - "MAIN", - - // Single Player - "SP_MAIN", - - "SP_LOAD", - "SP_PLAYER", - - "SP_LEVELSELECT", - "SP_LEVELSTATS", - - "SP_TIMEATTACK", - "SP_TIMEATTACK_LEVELSELECT", - "SP_GUESTREPLAY", - "SP_REPLAY", - "SP_GHOST", - - "SP_NIGHTSATTACK", - "SP_NIGHTS_LEVELSELECT", - "SP_NIGHTS_GUESTREPLAY", - "SP_NIGHTS_REPLAY", - "SP_NIGHTS_GHOST", - - // Multiplayer - "MP_MAIN", - "MP_SPLITSCREEN", // SplitServer - "MP_SERVER", - "MP_CONNECT", - "MP_ROOM", - "MP_PLAYERSETUP", // MP_PlayerSetupDef shared with SPLITSCREEN if #defined NONET - "MP_SERVER_OPTIONS", - - // Options - "OP_MAIN", - - "OP_P1CONTROLS", - "OP_CHANGECONTROLS", // OP_ChangeControlsDef shared with P2 - "OP_P1MOUSE", - "OP_P1JOYSTICK", - "OP_JOYSTICKSET", // OP_JoystickSetDef shared with P2 - "OP_P1CAMERA", - - "OP_P2CONTROLS", - "OP_P2MOUSE", - "OP_P2JOYSTICK", - "OP_P2CAMERA", - - "OP_PLAYSTYLE", - - "OP_VIDEO", - "OP_VIDEOMODE", - "OP_COLOR", - "OP_OPENGL", - "OP_OPENGL_LIGHTING", - - "OP_SOUND", - - "OP_SERVER", - "OP_MONITORTOGGLE", - - "OP_DATA", - "OP_ADDONS", - "OP_SCREENSHOTS", - "OP_ERASEDATA", - - // Extras - "SR_MAIN", - "SR_PANDORA", - "SR_LEVELSELECT", - "SR_UNLOCKCHECKLIST", - "SR_EMBLEMHINT", - "SR_PLAYER", - "SR_SOUNDTEST", - - // Addons (Part of MISC, but let's make it our own) - "AD_MAIN", - - // MISC - // "MESSAGE", - // "SPAUSE", - - // "MPAUSE", - // "SCRAMBLETEAM", - // "CHANGETEAM", - // "CHANGELEVEL", - - // "MAPAUSE", - // "HELP", - - "SPECIAL" -}; - -struct { - const char *n; - // has to be able to hold both fixed_t and angle_t, so drastic measure!! - lua_Integer v; -} const INT_CONST[] = { - // If a mod removes some variables here, - // please leave the names in-tact and just set - // the value to 0 or something. - - // integer type limits, from doomtype.h - // INT64 and UINT64 limits not included, they're too big for most purposes anyway - // signed - {"INT8_MIN",INT8_MIN}, - {"INT16_MIN",INT16_MIN}, - {"INT32_MIN",INT32_MIN}, - {"INT8_MAX",INT8_MAX}, - {"INT16_MAX",INT16_MAX}, - {"INT32_MAX",INT32_MAX}, - // unsigned - {"UINT8_MAX",UINT8_MAX}, - {"UINT16_MAX",UINT16_MAX}, - {"UINT32_MAX",UINT32_MAX}, - - // fixed_t constants, from m_fixed.h - {"FRACUNIT",FRACUNIT}, - {"FRACBITS",FRACBITS}, - - // doomdef.h constants - {"TICRATE",TICRATE}, - {"MUSICRATE",MUSICRATE}, - {"RING_DIST",RING_DIST}, - {"PUSHACCEL",PUSHACCEL}, - {"MODID",MODID}, // I don't know, I just thought it would be cool for a wad to potentially know what mod it was loaded into. - {"MODVERSION",MODVERSION}, // or what version of the mod this is. - {"CODEBASE",CODEBASE}, // or what release of SRB2 this is. - {"NEWTICRATE",NEWTICRATE}, // TICRATE*NEWTICRATERATIO - {"NEWTICRATERATIO",NEWTICRATERATIO}, - - // Special linedef executor tag numbers! - {"LE_PINCHPHASE",LE_PINCHPHASE}, // A boss entered pinch phase (and, in most cases, is preparing their pinch phase attack!) - {"LE_ALLBOSSESDEAD",LE_ALLBOSSESDEAD}, // All bosses in the map are dead (Egg capsule raise) - {"LE_BOSSDEAD",LE_BOSSDEAD}, // A boss in the map died (Chaos mode boss tally) - {"LE_BOSS4DROP",LE_BOSS4DROP}, // CEZ boss dropped its cage - {"LE_BRAKVILEATACK",LE_BRAKVILEATACK}, // Brak's doing his LOS attack, oh noes - {"LE_TURRET",LE_TURRET}, // THZ turret - {"LE_BRAKPLATFORM",LE_BRAKPLATFORM}, // v2.0 Black Eggman destroys platform - {"LE_CAPSULE2",LE_CAPSULE2}, // Egg Capsule - {"LE_CAPSULE1",LE_CAPSULE1}, // Egg Capsule - {"LE_CAPSULE0",LE_CAPSULE0}, // Egg Capsule - {"LE_KOOPA",LE_KOOPA}, // Distant cousin to Gay Bowser - {"LE_AXE",LE_AXE}, // MKB Axe object - {"LE_PARAMWIDTH",LE_PARAMWIDTH}, // If an object that calls LinedefExecute has a nonzero parameter value, this times the parameter will be subtracted. (Mostly for the purpose of coexisting bosses...) - - /// \todo Get all this stuff into its own sections, maybe. Maybe. - - // Frame settings - {"FF_FRAMEMASK",FF_FRAMEMASK}, - {"FF_SPR2SUPER",FF_SPR2SUPER}, - {"FF_SPR2ENDSTATE",FF_SPR2ENDSTATE}, - {"FF_SPR2MIDSTART",FF_SPR2MIDSTART}, - {"FF_ANIMATE",FF_ANIMATE}, - {"FF_RANDOMANIM",FF_RANDOMANIM}, - {"FF_GLOBALANIM",FF_GLOBALANIM}, - {"FF_FULLBRIGHT",FF_FULLBRIGHT}, - {"FF_VERTICALFLIP",FF_VERTICALFLIP}, - {"FF_HORIZONTALFLIP",FF_HORIZONTALFLIP}, - {"FF_PAPERSPRITE",FF_PAPERSPRITE}, - {"FF_TRANSMASK",FF_TRANSMASK}, - {"FF_TRANSSHIFT",FF_TRANSSHIFT}, - // new preshifted translucency (used in source) - {"FF_TRANS10",FF_TRANS10}, - {"FF_TRANS20",FF_TRANS20}, - {"FF_TRANS30",FF_TRANS30}, - {"FF_TRANS40",FF_TRANS40}, - {"FF_TRANS50",FF_TRANS50}, - {"FF_TRANS60",FF_TRANS60}, - {"FF_TRANS70",FF_TRANS70}, - {"FF_TRANS80",FF_TRANS80}, - {"FF_TRANS90",FF_TRANS90}, - // compatibility - // Transparency for SOCs is pre-shifted - {"TR_TRANS10",tr_trans10<gotflag! - // Used to be MF_ for some stupid reason, now they're GF_ to stop them looking like mobjflags - {"GF_REDFLAG",GF_REDFLAG}, - {"GF_BLUEFLAG",GF_BLUEFLAG}, - - // Customisable sounds for Skins, from sounds.h - {"SKSSPIN",SKSSPIN}, - {"SKSPUTPUT",SKSPUTPUT}, - {"SKSPUDPUD",SKSPUDPUD}, - {"SKSPLPAN1",SKSPLPAN1}, // Ouchies - {"SKSPLPAN2",SKSPLPAN2}, - {"SKSPLPAN3",SKSPLPAN3}, - {"SKSPLPAN4",SKSPLPAN4}, - {"SKSPLDET1",SKSPLDET1}, // Deaths - {"SKSPLDET2",SKSPLDET2}, - {"SKSPLDET3",SKSPLDET3}, - {"SKSPLDET4",SKSPLDET4}, - {"SKSPLVCT1",SKSPLVCT1}, // Victories - {"SKSPLVCT2",SKSPLVCT2}, - {"SKSPLVCT3",SKSPLVCT3}, - {"SKSPLVCT4",SKSPLVCT4}, - {"SKSTHOK",SKSTHOK}, - {"SKSSPNDSH",SKSSPNDSH}, - {"SKSZOOM",SKSZOOM}, - {"SKSSKID",SKSSKID}, - {"SKSGASP",SKSGASP}, - {"SKSJUMP",SKSJUMP}, - - // 3D Floor/Fake Floor/FOF/whatever flags - {"FF_EXISTS",FF_EXISTS}, ///< Always set, to check for validity. - {"FF_BLOCKPLAYER",FF_BLOCKPLAYER}, ///< Solid to player, but nothing else - {"FF_BLOCKOTHERS",FF_BLOCKOTHERS}, ///< Solid to everything but player - {"FF_SOLID",FF_SOLID}, ///< Clips things. - {"FF_RENDERSIDES",FF_RENDERSIDES}, ///< Renders the sides. - {"FF_RENDERPLANES",FF_RENDERPLANES}, ///< Renders the floor/ceiling. - {"FF_RENDERALL",FF_RENDERALL}, ///< Renders everything. - {"FF_SWIMMABLE",FF_SWIMMABLE}, ///< Is a water block. - {"FF_NOSHADE",FF_NOSHADE}, ///< Messes with the lighting? - {"FF_CUTSOLIDS",FF_CUTSOLIDS}, ///< Cuts out hidden solid pixels. - {"FF_CUTEXTRA",FF_CUTEXTRA}, ///< Cuts out hidden translucent pixels. - {"FF_CUTLEVEL",FF_CUTLEVEL}, ///< Cuts out all hidden pixels. - {"FF_CUTSPRITES",FF_CUTSPRITES}, ///< Final step in making 3D water. - {"FF_BOTHPLANES",FF_BOTHPLANES}, ///< Render inside and outside planes. - {"FF_EXTRA",FF_EXTRA}, ///< Gets cut by ::FF_CUTEXTRA. - {"FF_TRANSLUCENT",FF_TRANSLUCENT}, ///< See through! - {"FF_FOG",FF_FOG}, ///< Fog "brush." - {"FF_INVERTPLANES",FF_INVERTPLANES}, ///< Only render inside planes. - {"FF_ALLSIDES",FF_ALLSIDES}, ///< Render inside and outside sides. - {"FF_INVERTSIDES",FF_INVERTSIDES}, ///< Only render inside sides. - {"FF_DOUBLESHADOW",FF_DOUBLESHADOW}, ///< Make two lightlist entries to reset light? - {"FF_FLOATBOB",FF_FLOATBOB}, ///< Floats on water and bobs if you step on it. - {"FF_NORETURN",FF_NORETURN}, ///< Used with ::FF_CRUMBLE. Will not return to its original position after falling. - {"FF_CRUMBLE",FF_CRUMBLE}, ///< Falls 2 seconds after being stepped on, and randomly brings all touching crumbling 3dfloors down with it, providing their master sectors share the same tag (allows crumble platforms above or below, to also exist). - {"FF_SHATTERBOTTOM",FF_SHATTERBOTTOM}, ///< Used with ::FF_BUSTUP. Like FF_SHATTER, but only breaks from the bottom. Good for springing up through rubble. - {"FF_MARIO",FF_MARIO}, ///< Acts like a question block when hit from underneath. Goodie spawned at top is determined by master sector. - {"FF_BUSTUP",FF_BUSTUP}, ///< You can spin through/punch this block and it will crumble! - {"FF_QUICKSAND",FF_QUICKSAND}, ///< Quicksand! - {"FF_PLATFORM",FF_PLATFORM}, ///< You can jump up through this to the top. - {"FF_REVERSEPLATFORM",FF_REVERSEPLATFORM}, ///< A fall-through floor in normal gravity, a platform in reverse gravity. - {"FF_INTANGIBLEFLATS",FF_INTANGIBLEFLATS}, ///< Both flats are intangible, but the sides are still solid. - {"FF_INTANGABLEFLATS",FF_INTANGIBLEFLATS}, ///< Both flats are intangable, but the sides are still solid. - {"FF_SHATTER",FF_SHATTER}, ///< Used with ::FF_BUSTUP. Bustable on mere touch. - {"FF_SPINBUST",FF_SPINBUST}, ///< Used with ::FF_BUSTUP. Also bustable if you're in your spinning frames. - {"FF_STRONGBUST",FF_STRONGBUST}, ///< Used with ::FF_BUSTUP. Only bustable by "strong" characters (Knuckles) and abilities (bouncing, twinspin, melee). - {"FF_RIPPLE",FF_RIPPLE}, ///< Ripple the flats - {"FF_COLORMAPONLY",FF_COLORMAPONLY}, ///< Only copy the colormap, not the lightlevel - {"FF_GOOWATER",FF_GOOWATER}, ///< Used with ::FF_SWIMMABLE. Makes thick bouncey goop. - - // PolyObject flags - {"POF_CLIPLINES",POF_CLIPLINES}, ///< Test against lines for collision - {"POF_CLIPPLANES",POF_CLIPPLANES}, ///< Test against tops and bottoms for collision - {"POF_SOLID",POF_SOLID}, ///< Clips things. - {"POF_TESTHEIGHT",POF_TESTHEIGHT}, ///< Test line collision with heights - {"POF_RENDERSIDES",POF_RENDERSIDES}, ///< Renders the sides. - {"POF_RENDERTOP",POF_RENDERTOP}, ///< Renders the top. - {"POF_RENDERBOTTOM",POF_RENDERBOTTOM}, ///< Renders the bottom. - {"POF_RENDERPLANES",POF_RENDERPLANES}, ///< Renders top and bottom. - {"POF_RENDERALL",POF_RENDERALL}, ///< Renders everything. - {"POF_INVERT",POF_INVERT}, ///< Inverts collision (like a cage). - {"POF_INVERTPLANES",POF_INVERTPLANES}, ///< Render inside planes. - {"POF_INVERTPLANESONLY",POF_INVERTPLANESONLY}, ///< Only render inside planes. - {"POF_PUSHABLESTOP",POF_PUSHABLESTOP}, ///< Pushables will stop movement. - {"POF_LDEXEC",POF_LDEXEC}, ///< This PO triggers a linedef executor. - {"POF_ONESIDE",POF_ONESIDE}, ///< Only use the first side of the linedef. - {"POF_NOSPECIALS",POF_NOSPECIALS}, ///< Don't apply sector specials. - {"POF_SPLAT",POF_SPLAT}, ///< Use splat flat renderer (treat cyan pixels as invisible). - -#ifdef HAVE_LUA_SEGS - // Node flags - {"NF_SUBSECTOR",NF_SUBSECTOR}, // Indicate a leaf. -#endif - - // Slope flags - {"SL_NOPHYSICS",SL_NOPHYSICS}, - {"SL_DYNAMIC",SL_DYNAMIC}, - - // Angles - {"ANG1",ANG1}, - {"ANG2",ANG2}, - {"ANG10",ANG10}, - {"ANG15",ANG15}, - {"ANG20",ANG20}, - {"ANG30",ANG30}, - {"ANG60",ANG60}, - {"ANG64h",ANG64h}, - {"ANG105",ANG105}, - {"ANG210",ANG210}, - {"ANG255",ANG255}, - {"ANG340",ANG340}, - {"ANG350",ANG350}, - {"ANGLE_11hh",ANGLE_11hh}, - {"ANGLE_22h",ANGLE_22h}, - {"ANGLE_45",ANGLE_45}, - {"ANGLE_67h",ANGLE_67h}, - {"ANGLE_90",ANGLE_90}, - {"ANGLE_112h",ANGLE_112h}, - {"ANGLE_135",ANGLE_135}, - {"ANGLE_157h",ANGLE_157h}, - {"ANGLE_180",ANGLE_180}, - {"ANGLE_202h",ANGLE_202h}, - {"ANGLE_225",ANGLE_225}, - {"ANGLE_247h",ANGLE_247h}, - {"ANGLE_270",ANGLE_270}, - {"ANGLE_292h",ANGLE_292h}, - {"ANGLE_315",ANGLE_315}, - {"ANGLE_337h",ANGLE_337h}, - {"ANGLE_MAX",ANGLE_MAX}, - - // P_Chase directions (dirtype_t) - {"DI_NODIR",DI_NODIR}, - {"DI_EAST",DI_EAST}, - {"DI_NORTHEAST",DI_NORTHEAST}, - {"DI_NORTH",DI_NORTH}, - {"DI_NORTHWEST",DI_NORTHWEST}, - {"DI_WEST",DI_WEST}, - {"DI_SOUTHWEST",DI_SOUTHWEST}, - {"DI_SOUTH",DI_SOUTH}, - {"DI_SOUTHEAST",DI_SOUTHEAST}, - {"NUMDIRS",NUMDIRS}, - - // Sprite rotation axis (rotaxis_t) - {"ROTAXIS_X",ROTAXIS_X}, - {"ROTAXIS_Y",ROTAXIS_Y}, - {"ROTAXIS_Z",ROTAXIS_Z}, - - // Buttons (ticcmd_t) - {"BT_WEAPONMASK",BT_WEAPONMASK}, //our first four bits. - {"BT_WEAPONNEXT",BT_WEAPONNEXT}, - {"BT_WEAPONPREV",BT_WEAPONPREV}, - {"BT_ATTACK",BT_ATTACK}, // shoot rings - {"BT_SPIN",BT_SPIN}, - {"BT_CAMLEFT",BT_CAMLEFT}, // turn camera left - {"BT_CAMRIGHT",BT_CAMRIGHT}, // turn camera right - {"BT_TOSSFLAG",BT_TOSSFLAG}, - {"BT_JUMP",BT_JUMP}, - {"BT_FIRENORMAL",BT_FIRENORMAL}, // Fire a normal ring no matter what - {"BT_CUSTOM1",BT_CUSTOM1}, // Lua customizable - {"BT_CUSTOM2",BT_CUSTOM2}, // Lua customizable - {"BT_CUSTOM3",BT_CUSTOM3}, // Lua customizable - - // Lua command registration flags - {"COM_ADMIN",COM_ADMIN}, - {"COM_SPLITSCREEN",COM_SPLITSCREEN}, - {"COM_LOCAL",COM_LOCAL}, - - // cvflags_t - {"CV_SAVE",CV_SAVE}, - {"CV_CALL",CV_CALL}, - {"CV_NETVAR",CV_NETVAR}, - {"CV_NOINIT",CV_NOINIT}, - {"CV_FLOAT",CV_FLOAT}, - {"CV_NOTINNET",CV_NOTINNET}, - {"CV_MODIFIED",CV_MODIFIED}, - {"CV_SHOWMODIF",CV_SHOWMODIF}, - {"CV_SHOWMODIFONETIME",CV_SHOWMODIFONETIME}, - {"CV_NOSHOWHELP",CV_NOSHOWHELP}, - {"CV_HIDEN",CV_HIDEN}, - {"CV_HIDDEN",CV_HIDEN}, - {"CV_CHEAT",CV_CHEAT}, - {"CV_NOLUA",CV_NOLUA}, - - // v_video flags - {"V_NOSCALEPATCH",V_NOSCALEPATCH}, - {"V_SMALLSCALEPATCH",V_SMALLSCALEPATCH}, - {"V_MEDSCALEPATCH",V_MEDSCALEPATCH}, - {"V_6WIDTHSPACE",V_6WIDTHSPACE}, - {"V_OLDSPACING",V_OLDSPACING}, - {"V_MONOSPACE",V_MONOSPACE}, - - {"V_MAGENTAMAP",V_MAGENTAMAP}, - {"V_YELLOWMAP",V_YELLOWMAP}, - {"V_GREENMAP",V_GREENMAP}, - {"V_BLUEMAP",V_BLUEMAP}, - {"V_REDMAP",V_REDMAP}, - {"V_GRAYMAP",V_GRAYMAP}, - {"V_ORANGEMAP",V_ORANGEMAP}, - {"V_SKYMAP",V_SKYMAP}, - {"V_PURPLEMAP",V_PURPLEMAP}, - {"V_AQUAMAP",V_AQUAMAP}, - {"V_PERIDOTMAP",V_PERIDOTMAP}, - {"V_AZUREMAP",V_AZUREMAP}, - {"V_BROWNMAP",V_BROWNMAP}, - {"V_ROSYMAP",V_ROSYMAP}, - {"V_INVERTMAP",V_INVERTMAP}, - - {"V_TRANSLUCENT",V_TRANSLUCENT}, - {"V_10TRANS",V_10TRANS}, - {"V_20TRANS",V_20TRANS}, - {"V_30TRANS",V_30TRANS}, - {"V_40TRANS",V_40TRANS}, - {"V_50TRANS",V_TRANSLUCENT}, // alias - {"V_60TRANS",V_60TRANS}, - {"V_70TRANS",V_70TRANS}, - {"V_80TRANS",V_80TRANS}, - {"V_90TRANS",V_90TRANS}, - {"V_HUDTRANSHALF",V_HUDTRANSHALF}, - {"V_HUDTRANS",V_HUDTRANS}, - {"V_HUDTRANSDOUBLE",V_HUDTRANSDOUBLE}, - {"V_AUTOFADEOUT",V_AUTOFADEOUT}, - {"V_RETURN8",V_RETURN8}, - {"V_OFFSET",V_OFFSET}, - {"V_ALLOWLOWERCASE",V_ALLOWLOWERCASE}, - {"V_FLIP",V_FLIP}, - {"V_CENTERNAMETAG",V_CENTERNAMETAG}, - {"V_SNAPTOTOP",V_SNAPTOTOP}, - {"V_SNAPTOBOTTOM",V_SNAPTOBOTTOM}, - {"V_SNAPTOLEFT",V_SNAPTOLEFT}, - {"V_SNAPTORIGHT",V_SNAPTORIGHT}, - {"V_WRAPX",V_WRAPX}, - {"V_WRAPY",V_WRAPY}, - {"V_NOSCALESTART",V_NOSCALESTART}, - {"V_PERPLAYER",V_PERPLAYER}, - - {"V_PARAMMASK",V_PARAMMASK}, - {"V_SCALEPATCHMASK",V_SCALEPATCHMASK}, - {"V_SPACINGMASK",V_SPACINGMASK}, - {"V_CHARCOLORMASK",V_CHARCOLORMASK}, - {"V_ALPHAMASK",V_ALPHAMASK}, - - {"V_CHARCOLORSHIFT",V_CHARCOLORSHIFT}, - {"V_ALPHASHIFT",V_ALPHASHIFT}, - - //Kick Reasons - {"KR_KICK",KR_KICK}, - {"KR_PINGLIMIT",KR_PINGLIMIT}, - {"KR_SYNCH",KR_SYNCH}, - {"KR_TIMEOUT",KR_TIMEOUT}, - {"KR_BAN",KR_BAN}, - {"KR_LEAVE",KR_LEAVE}, - - // translation colormaps - {"TC_DEFAULT",TC_DEFAULT}, - {"TC_BOSS",TC_BOSS}, - {"TC_METALSONIC",TC_METALSONIC}, - {"TC_ALLWHITE",TC_ALLWHITE}, - {"TC_RAINBOW",TC_RAINBOW}, - {"TC_BLINK",TC_BLINK}, - {"TC_DASHMODE",TC_DASHMODE}, - - // marathonmode flags - {"MA_INIT",MA_INIT}, - {"MA_RUNNING",MA_RUNNING}, - {"MA_NOCUTSCENES",MA_NOCUTSCENES}, - {"MA_INGAME",MA_INGAME}, - - // music types - {"MU_NONE", MU_NONE}, - {"MU_WAV", MU_WAV}, - {"MU_MOD", MU_MOD}, - {"MU_MID", MU_MID}, - {"MU_OGG", MU_OGG}, - {"MU_MP3", MU_MP3}, - {"MU_FLAC", MU_FLAC}, - {"MU_GME", MU_GME}, - {"MU_MOD_EX", MU_MOD_EX}, - {"MU_MID_EX", MU_MID_EX}, - - // gamestates - {"GS_NULL",GS_NULL}, - {"GS_LEVEL",GS_LEVEL}, - {"GS_INTERMISSION",GS_INTERMISSION}, - {"GS_CONTINUING",GS_CONTINUING}, - {"GS_TITLESCREEN",GS_TITLESCREEN}, - {"GS_TIMEATTACK",GS_TIMEATTACK}, - {"GS_CREDITS",GS_CREDITS}, - {"GS_EVALUATION",GS_EVALUATION}, - {"GS_GAMEEND",GS_GAMEEND}, - {"GS_INTRO",GS_INTRO}, - {"GS_ENDING",GS_ENDING}, - {"GS_CUTSCENE",GS_CUTSCENE}, - {"GS_DEDICATEDSERVER",GS_DEDICATEDSERVER}, - {"GS_WAITINGPLAYERS",GS_WAITINGPLAYERS}, - - {NULL,0} -}; - -static mobjtype_t get_mobjtype(const char *word) -{ // Returns the value 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++) { - 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_NULL; -} - -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++) { - 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; -} - -skincolornum_t get_skincolor(const char *word) -{ // Returns the value of SKINCOLOR_ enumerations - skincolornum_t i; - if (*word >= '0' && *word <= '9') - return atoi(word); - if (fastncmp("SKINCOLOR_",word,10)) - word += 10; // take off the SKINCOLOR_ - for (i = 0; i < NUMCOLORFREESLOTS; i++) { - if (!FREE_SKINCOLORS[i]) - break; - if (fastcmp(word, FREE_SKINCOLORS[i])) - return SKINCOLOR_FIRSTFREESLOT+i; - } - for (i = 0; i < SKINCOLOR_FIRSTFREESLOT; i++) - if (fastcmp(word, COLOR_ENUMS[i])) - return i; - deh_warning("Couldn't find skincolor named 'SKINCOLOR_%s'",word); - return SKINCOLOR_GREEN; -} - -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) - return i; - deh_warning("Couldn't find sprite named 'SPR_%s'",word); - return SPR_NULL; -} - -static playersprite_t get_sprite2(const char *word) -{ // Returns the value of SPR2_ enumerations - playersprite_t i; - if (*word >= '0' && *word <= '9') - return atoi(word); - if (fastncmp("SPR2_",word,5)) - word += 5; // take off the SPR2_ - for (i = 0; i < NUMPLAYERSPRITES; i++) - if (!spr2names[i][4] && memcmp(word,spr2names[i],4)==0) - return i; - deh_warning("Couldn't find sprite named 'SPR2_%s'",word); - return SPR2_STND; -} - -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 -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]); - - if (fastncmp("MUS_",word,4)) - word += 4; // take off the MUS_ - 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)) - { - word += 3; - if (toupper(word[0]) >= 'A' && toupper(word[0]) <= 'Z') - return (UINT16)M_MapNumber(word[0], word[1]); - else if ((i = atoi(word))) - return i; - - word -= 3; - if (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 - -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_LIVES; -} - -static menutype_t get_menutype(const char *word) -{ // Returns the value of MN_ enumerations - menutype_t i; - if (*word >= '0' && *word <= '9') - return atoi(word); - if (fastncmp("MN_",word,3)) - word += 3; // take off the MN_ - for (i = 0; i < NUMMENUTYPES; i++) - if (fastcmp(word, MENUTYPES_LIST[i])) - return i; - deh_warning("Couldn't find menutype named 'MN_%s'",word); - return MN_NONE; -} - -/*static INT16 get_gametype(const char *word) -{ // Returns the value of GT_ enumerations - INT16 i; - if (*word >= '0' && *word <= '9') - return atoi(word); - if (fastncmp("GT_",word,3)) - word += 3; // take off the GT_ - for (i = 0; i < NUMGAMETYPES; i++) - if (fastcmp(word, Gametype_ConstantNames[i]+3)) - return i; - deh_warning("Couldn't find gametype named 'GT_%s'",word); - return GT_COOP; -} - -static powertype_t get_power(const char *word) -{ // Returns the value of pw_ enumerations - powertype_t i; - if (*word >= '0' && *word <= '9') - return atoi(word); - if (fastncmp("PW_",word,3)) - word += 3; // take off the pw_ - for (i = 0; i < NUMPOWERS; i++) - if (fastcmp(word, POWERS_LIST[i])) - return i; - deh_warning("Couldn't find power named 'pw_%s'",word); - return pw_invulnerability; -}*/ - -/// \todo Make ANY of this completely over-the-top math craziness obey the order of operations. -static fixed_t op_mul(fixed_t a, fixed_t b) { return a*b; } -static fixed_t op_div(fixed_t a, fixed_t b) { return a/b; } -static fixed_t op_add(fixed_t a, fixed_t b) { return a+b; } -static fixed_t op_sub(fixed_t a, fixed_t b) { return a-b; } -static fixed_t op_or(fixed_t a, fixed_t b) { return a|b; } -static fixed_t op_and(fixed_t a, fixed_t b) { return a&b; } -static fixed_t op_lshift(fixed_t a, fixed_t b) { return a<>b; } - -struct { - const char c; - fixed_t (*v)(fixed_t,fixed_t); -} OPERATIONS[] = { - {'*',op_mul}, - {'/',op_div}, - {'+',op_add}, - {'-',op_sub}, - {'|',op_or}, - {'&',op_and}, - {'<',op_lshift}, - {'>',op_rshift}, - {0,NULL} -}; - -// Returns the full word, cut at the first symbol or whitespace -/*static char *read_word(const char *line) -{ - // Part 1: You got the start of the word, now find the end. - const char *p; - INT32 i; - for (p = line+1; *p; p++) { - if (*p == ' ' || *p == '\t') - break; - for (i = 0; OPERATIONS[i].c; i++) - if (*p == OPERATIONS[i].c) { - i = -1; - break; - } - if (i == -1) - break; - } - - // Part 2: Make a copy of the word and return it. - { - size_t len = (p-line); - char *word = malloc(len+1); - M_Memcpy(word,line,len); - word[len] = '\0'; - return word; - } -} - -static INT32 operation_pad(const char **word) -{ // Brings word the next operation and returns the operation number. - INT32 i; - for (; **word; (*word)++) { - if (**word == ' ' || **word == '\t') - continue; - for (i = 0; OPERATIONS[i].c; i++) - if (**word == OPERATIONS[i].c) - { - if ((**word == '<' && *(*word+1) == '<') || (**word == '>' && *(*word+1) == '>')) (*word)++; // These operations are two characters long. - else if (**word == '<' || **word == '>') continue; // ... do not accept one character long. - (*word)++; - return i; - } - deh_warning("Unknown operation '%c'",**word); - return -1; - } - return -1; -} - -static void const_warning(const char *type, const char *word) -{ - deh_warning("Couldn't find %s named '%s'",type,word); -} - -static fixed_t find_const(const char **rword) -{ // Finds the value of constants and returns it, bringing word to the next operation. - INT32 i; - fixed_t r; - char *word = read_word(*rword); - *rword += strlen(word); - if ((*word >= '0' && *word <= '9') || *word == '-') { // Parse a number - r = atoi(word); - free(word); - return r; - } - if (!*(word+1) && // Turn a single A-z symbol into numbers, like sprite frames. - ((*word >= 'A' && *word <= 'Z') || (*word >= 'a' && *word <= 'z'))) { - r = R_Char2Frame(*word); - free(word); - return r; - } - if (fastncmp("MF_", word, 3)) { - char *p = word+3; - for (i = 0; MOBJFLAG_LIST[i]; i++) - if (fastcmp(p, MOBJFLAG_LIST[i])) { - free(word); - return (1< 0) - { - s = Z_StrDup(luaL_checkstring(L,1)); - type = strtok(s, "_"); - if (type) - strupr(type); - else { - Z_Free(s); - return luaL_error(L, "Unknown enum type in '%s'\n", luaL_checkstring(L, 1)); - } - - word = strtok(NULL, "\n"); - if (word) - strupr(word); - else { - Z_Free(s); - return luaL_error(L, "Missing enum name in '%s'\n", luaL_checkstring(L, 1)); - } - 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) { - lua_pushinteger(L, sfx); - r++; - } else - CONS_Alert(CONS_WARNING, "Ran out of free SFX slots!\n"); - } - else if (fastcmp(type, "SPR")) - { - char wad; - spritenum_t j; - lua_getfield(L, LUA_REGISTRYINDEX, "WAD"); - wad = (char)lua_tointeger(L, -1); - lua_pop(L, 1); - for (j = SPR_FIRSTFREESLOT; j <= SPR_LASTFREESLOT; j++) - { - if (used_spr[(j-SPR_FIRSTFREESLOT)/8] & (1<<(j%8))) - { - 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); - 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); - r++; - break; - } - if (j > SPR_LASTFREESLOT) - CONS_Alert(CONS_WARNING, "Ran out of free sprite slots!\n"); - } - else if (fastcmp(type, "S")) - { - statenum_t i; - for (i = 0; i < NUMSTATEFREESLOTS; i++) - if (!FREE_STATES[i]) { - CONS_Printf("State S_%s allocated.\n",word); - FREE_STATES[i] = Z_Malloc(strlen(word)+1, PU_STATIC, NULL); - strcpy(FREE_STATES[i],word); - lua_pushinteger(L, S_FIRSTFREESLOT + i); - r++; - break; - } - if (i == NUMSTATEFREESLOTS) - CONS_Alert(CONS_WARNING, "Ran out of free State slots!\n"); - } - else if (fastcmp(type, "MT")) - { - mobjtype_t i; - for (i = 0; i < NUMMOBJFREESLOTS; i++) - if (!FREE_MOBJS[i]) { - CONS_Printf("MobjType MT_%s allocated.\n",word); - FREE_MOBJS[i] = Z_Malloc(strlen(word)+1, PU_STATIC, NULL); - strcpy(FREE_MOBJS[i],word); - lua_pushinteger(L, MT_FIRSTFREESLOT + i); - r++; - break; - } - if (i == NUMMOBJFREESLOTS) - CONS_Alert(CONS_WARNING, "Ran out of free MobjType slots!\n"); - } - else if (fastcmp(type, "SKINCOLOR")) - { - skincolornum_t i; - for (i = 0; i < NUMCOLORFREESLOTS; i++) - if (!FREE_SKINCOLORS[i]) { - CONS_Printf("Skincolor SKINCOLOR_%s allocated.\n",word); - FREE_SKINCOLORS[i] = Z_Malloc(strlen(word)+1, PU_STATIC, NULL); - strcpy(FREE_SKINCOLORS[i],word); - M_AddMenuColor(numskincolors++); - lua_pushinteger(L, SKINCOLOR_FIRSTFREESLOT + i); - r++; - break; - } - if (i == NUMCOLORFREESLOTS) - CONS_Alert(CONS_WARNING, "Ran out of free skincolor slots!\n"); - } - else if (fastcmp(type, "SPR2")) - { - // Search if we already have an SPR2 by that name... - playersprite_t i; - for (i = SPR2_FIRSTFREESLOT; i < free_spr2; i++) - if (memcmp(spr2names[i],word,4) == 0) - break; - // We don't, so allocate a new one. - if (i >= free_spr2) { - if (free_spr2 < NUMPLAYERSPRITES) - { - CONS_Printf("Sprite SPR2_%s allocated.\n",word); - strncpy(spr2names[free_spr2],word,4); - spr2defaults[free_spr2] = 0; - lua_pushinteger(L, free_spr2); - r++; - spr2names[free_spr2++][4] = 0; - } else - CONS_Alert(CONS_WARNING, "Ran out of free SPR2 slots!\n"); - } - } - else if (fastcmp(type, "TOL")) - { - // Search if we already have a typeoflevel by that name... - int i; - for (i = 0; TYPEOFLEVEL[i].name; i++) - if (fastcmp(word, TYPEOFLEVEL[i].name)) - break; - - // We don't, so allocate a new one. - if (TYPEOFLEVEL[i].name == NULL) { - if (lastcustomtol == (UINT32)MAXTOL) // Unless you have way too many, since they're flags. - CONS_Alert(CONS_WARNING, "Ran out of free typeoflevel slots!\n"); - else { - CONS_Printf("TypeOfLevel TOL_%s allocated.\n",word); - G_AddTOL(lastcustomtol, word); - lua_pushinteger(L, lastcustomtol); - lastcustomtol <<= 1; - r++; - } - } - } - Z_Free(s); - lua_remove(L, 1); - continue; - } - return r; -} - -// Wrapper for ALL A_Action functions. -// Arguments: mobj_t actor, int var1, int var2 -static int action_call(lua_State *L) -{ - //actionf_t *action = lua_touserdata(L,lua_upvalueindex(1)); - actionf_t *action = *((actionf_t **)luaL_checkudata(L, 1, META_ACTION)); - mobj_t *actor = *((mobj_t **)luaL_checkudata(L, 2, META_MOBJ)); - var1 = (INT32)luaL_optinteger(L, 3, 0); - var2 = (INT32)luaL_optinteger(L, 4, 0); - if (!actor) - return LUA_ErrInvalid(L, "mobj_t"); - action->acp1(actor); - return 0; -} - -// Hardcoded A_Action name to call for super() or NULL if super() would be invalid. -// Set in lua_infolib. -const char *superactions[MAXRECURSION]; -UINT8 superstack = 0; - -static int lib_dummysuper(lua_State *L) -{ - return luaL_error(L, "Can't call super() outside of hardcode-replacing A_Action functions being called by state changes!"); // convoluted, I know. @_@;; -} - -static inline int lib_getenum(lua_State *L) -{ - const char *word, *p; - fixed_t i; - boolean mathlib = lua_toboolean(L, lua_upvalueindex(1)); - if (lua_type(L,2) != LUA_TSTRING) - return 0; - word = lua_tostring(L,2); - if (strlen(word) == 1) { // Assume sprite frame if length 1. - if (*word >= 'A' && *word <= '~') - { - lua_pushinteger(L, *word-'A'); - return 1; - } - if (mathlib) return luaL_error(L, "constant '%s' could not be parsed.\n", word); - return 0; - } - else if (fastncmp("MF_", word, 3)) { - p = word+3; - for (i = 0; MOBJFLAG_LIST[i]; i++) - if (fastcmp(p, MOBJFLAG_LIST[i])) { - lua_pushinteger(L, ((lua_Integer)1< return action's string name -static int lib_getActionName(lua_State *L) -{ - if (lua_isuserdata(L, 1)) // arg 1 is built-in action, expect action userdata - { - actionf_t *action = *((actionf_t **)luaL_checkudata(L, 1, META_ACTION)); - const char *name = NULL; - if (!action) - return luaL_error(L, "not a valid action?"); - name = LUA_GetActionName(action); - if (!name) // that can't be right? - return luaL_error(L, "no name string could be found for this action"); - lua_pushstring(L, name); - return 1; - } - else if (lua_isfunction(L, 1)) // arg 1 is a function (either C or Lua) - { - lua_settop(L, 1); // set top of stack to 1 (removing any extra args, which there shouldn't be) - // get the name for this action, if possible. - lua_getfield(L, LUA_REGISTRYINDEX, LREG_ACTIONS); - lua_pushnil(L); - // Lua stack at this point: - // 1 ... -2 -1 - // arg ... LREG_ACTIONS nil - while (lua_next(L, -2)) - { - // Lua stack at this point: - // 1 ... -3 -2 -1 - // arg ... LREG_ACTIONS "A_ACTION" function - if (lua_rawequal(L, -1, 1)) // is this the same as the arg? - { - // make sure the key (i.e. "A_ACTION") is a string first - // (note: we don't use lua_isstring because it also returns true for numbers) - if (lua_type(L, -2) == LUA_TSTRING) - { - lua_pushvalue(L, -2); // push "A_ACTION" string to top of stack - return 1; - } - lua_pop(L, 2); // pop the name and function - break; // probably should have succeeded but we didn't, so end the loop - } - lua_pop(L, 1); - } - lua_pop(L, 1); // pop LREG_ACTIONS - return 0; // return nothing (don't error) - } - - return luaL_typerror(L, 1, "action userdata or Lua function"); -} - - - -int LUA_SOCLib(lua_State *L) -{ - lua_register(L,"freeslot",lib_freeslot); - lua_register(L,"getActionName",lib_getActionName); - - luaL_newmetatable(L, META_ACTION); - lua_pushcfunction(L, action_call); - lua_setfield(L, -2, "__call"); - lua_pop(L, 1); - - return 0; -} - -const char *LUA_GetActionName(void *action) -{ - actionf_t *act = (actionf_t *)action; - size_t z; - for (z = 0; actionpointers[z].name; z++) - { - if (actionpointers[z].action.acv == act->acv) - return actionpointers[z].name; - } - return NULL; -} - -void LUA_SetActionByName(void *state, const char *actiontocompare) -{ - state_t *st = (state_t *)state; - size_t z; - for (z = 0; actionpointers[z].name; z++) - { - if (fasticmp(actiontocompare, actionpointers[z].name)) - { - st->action = actionpointers[z].action; - st->action.acv = actionpointers[z].action.acv; // assign - st->action.acp1 = actionpointers[z].action.acp1; - return; - } - } -} diff --git a/src/dehacked.h b/src/dehacked.h index 54225f36e..d5256be23 100644 --- a/src/dehacked.h +++ b/src/dehacked.h @@ -33,13 +33,15 @@ void DEH_LoadDehackedLumpPwad(UINT16 wad, UINT16 lump, boolean mainfile); void DEH_Check(void); fixed_t get_number(const char *word); - -boolean LUA_SetLuaAction(void *state, const char *actiontocompare); -const char *LUA_GetActionName(void *action); -void LUA_SetActionByName(void *state, const char *actiontocompare); +FUNCPRINTF void deh_warning(const char *first, ...); +void deh_strlcpy(char *dst, const char *src, size_t size, const char *warntext); extern boolean deh_loaded; +extern boolean gamedataadded; +extern boolean titlechanged; +extern boolean introchanged; + #define MAXRECURSION 30 extern const char *superactions[MAXRECURSION]; extern UINT8 superstack; @@ -60,4 +62,5 @@ typedef struct } MYFILE; #define myfeof(a) (a->data + a->size <= a->curpos) char *myfgets(char *buf, size_t bufsize, MYFILE *f); +char *myhashfgets(char *buf, size_t bufsize, MYFILE *f); #endif diff --git a/src/doomstat.h b/src/doomstat.h index 3abaf2988..2d28b81af 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -410,7 +410,7 @@ enum GameType GT_LASTFREESLOT = GT_FIRSTFREESLOT + NUMGAMETYPEFREESLOTS - 1, NUMGAMETYPES }; -// If you alter this list, update dehacked.c, MISC_ChangeGameTypeMenu in m_menu.c, and Gametype_Names in g_game.c +// If you alter this list, update deh_tables.c, MISC_ChangeGameTypeMenu in m_menu.c, and Gametype_Names in g_game.c // Gametype rules enum GameTypeRules diff --git a/src/info.h b/src/info.h index d84461617..65c871416 100644 --- a/src/info.h +++ b/src/info.h @@ -19,11 +19,11 @@ #include "sounds.h" #include "m_fixed.h" -// dehacked.c now has lists for the more named enums! PLEASE keep them up to date! +// deh_tables.c now has lists for the more named enums! PLEASE keep them up to date! // For great modding!! // IMPORTANT NOTE: If you add/remove from this list of action -// functions, don't forget to update them in dehacked.c! +// functions, don't forget to update them in deh_tables.c! void A_Explode(); void A_Pain(); void A_Fall(); diff --git a/src/lua_infolib.c b/src/lua_infolib.c index 18e519951..d70fbe5b7 100644 --- a/src/lua_infolib.c +++ b/src/lua_infolib.c @@ -14,6 +14,7 @@ #include "fastcmp.h" #include "info.h" #include "dehacked.h" +#include "deh_lua.h" #include "p_mobj.h" #include "p_local.h" #include "z_zone.h" diff --git a/src/lua_script.c b/src/lua_script.c index 160746e9e..1045a8b1d 100644 --- a/src/lua_script.c +++ b/src/lua_script.c @@ -13,6 +13,7 @@ #include "doomdef.h" #include "fastcmp.h" #include "dehacked.h" +#include "deh_lua.h" #include "z_zone.h" #include "w_wad.h" #include "p_setup.h" diff --git a/src/m_menu.c b/src/m_menu.c index d31e2154c..d6aa9dcab 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -425,7 +425,7 @@ static CV_PossibleValue_t skins_cons_t[MAXSKINS+1] = {{1, DEFAULTSKIN}}; consvar_t cv_chooseskin = CVAR_INIT ("chooseskin", DEFAULTSKIN, CV_HIDEN|CV_CALL, skins_cons_t, Nextmap_OnChange); // This gametype list is integral for many different reasons. -// When you add gametypes here, don't forget to update them in dehacked.c and doomstat.h! +// When you add gametypes here, don't forget to update them in deh_tables.c and doomstat.h! CV_PossibleValue_t gametype_cons_t[NUMGAMETYPES+1]; consvar_t cv_newgametype = CVAR_INIT ("newgametype", "Co-op", CV_HIDEN|CV_CALL, gametype_cons_t, Newgametype_OnChange); diff --git a/src/sdl/Srb2SDL-vc10.vcxproj b/src/sdl/Srb2SDL-vc10.vcxproj index 22ac9fb8f..d46a4af2b 100644 --- a/src/sdl/Srb2SDL-vc10.vcxproj +++ b/src/sdl/Srb2SDL-vc10.vcxproj @@ -196,6 +196,9 @@ + + + @@ -363,6 +366,9 @@ + + + diff --git a/src/sdl/Srb2SDL-vc9.vcproj b/src/sdl/Srb2SDL-vc9.vcproj index 3c430b2b4..95f035267 100644 --- a/src/sdl/Srb2SDL-vc9.vcproj +++ b/src/sdl/Srb2SDL-vc9.vcproj @@ -1710,6 +1710,138 @@ RelativePath="..\dehacked.h" > + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 930b5ea44264ce0937a719147362b83b82b7a785 Mon Sep 17 00:00:00 2001 From: GoldenTails Date: Thu, 29 Oct 2020 15:32:31 -0500 Subject: [PATCH 0371/1080] Replace credits with original authors --- src/deh_tables.c | 3 ++- src/deh_tables.h | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/deh_tables.c b/src/deh_tables.c index 3c86a584a..6ff0b14cd 100644 --- a/src/deh_tables.c +++ b/src/deh_tables.c @@ -1,6 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- -// Copyright (C) 2020 by Golden. +// Copyright (C) 1998-2000 by DooM Legacy Team. +// Copyright (C) 1999-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/deh_tables.h b/src/deh_tables.h index 3e1f3d933..c2be7a12d 100644 --- a/src/deh_tables.h +++ b/src/deh_tables.h @@ -1,6 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- -// Copyright (C) 2020 by Golden. +// Copyright (C) 1998-2000 by DooM Legacy Team. +// Copyright (C) 1999-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. From 87968c946beb499c66f20c226f00067f8c0c1fd3 Mon Sep 17 00:00:00 2001 From: lachwright Date: Tue, 24 Nov 2020 14:56:22 +1100 Subject: [PATCH 0372/1080] Prevent non-CA2_SPINDASH characters from getting crushed by roll-jumping into a crevice --- src/p_user.c | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index b8e7d1746..7dfa9d83a 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -8614,6 +8614,7 @@ void P_MovePlayer(player_t *player) P_DoFiring(player, cmd); { + boolean atspinheight = false; fixed_t oldheight = player->mo->height; // Less height while spinning. Good for spinning under things...? @@ -8623,32 +8624,35 @@ void P_MovePlayer(player_t *player) || player->powers[pw_tailsfly] || player->pflags & PF_GLIDING || (player->charability == CA_GLIDEANDCLIMB && player->mo->state-states == S_PLAY_GLIDE_LANDING) || (player->charability == CA_FLY && player->mo->state-states == S_PLAY_FLY_TIRED)) + { player->mo->height = P_GetPlayerSpinHeight(player); + atspinheight = true; + } else player->mo->height = P_GetPlayerHeight(player); if (player->mo->eflags & MFE_VERTICALFLIP && player->mo->height != oldheight) // adjust z height for reverse gravity, similar to how it's done for scaling player->mo->z -= player->mo->height - oldheight; - } - // Crush test... - if ((player->mo->ceilingz - player->mo->floorz < player->mo->height) - && !(player->mo->flags & MF_NOCLIP)) - { - if ((player->charability2 == CA2_SPINDASH) && !(player->pflags & PF_SPINNING)) + // Crush test... + if ((player->mo->ceilingz - player->mo->floorz < player->mo->height) + && !(player->mo->flags & MF_NOCLIP)) { - player->pflags |= PF_SPINNING; - P_SetPlayerMobjState(player->mo, S_PLAY_ROLL); - } - else if (player->mo->ceilingz - player->mo->floorz < player->mo->height) - { - if ((netgame || multiplayer) && player->spectator) - P_DamageMobj(player->mo, NULL, NULL, 1, DMG_SPECTATOR); // Respawn crushed spectators - else - P_DamageMobj(player->mo, NULL, NULL, 1, DMG_CRUSHED); + if (!atspinheight) + { + player->pflags |= PF_SPINNING; + P_SetPlayerMobjState(player->mo, S_PLAY_ROLL); + } + else if (player->mo->ceilingz - player->mo->floorz < player->mo->height) + { + if ((netgame || multiplayer) && player->spectator) + P_DamageMobj(player->mo, NULL, NULL, 1, DMG_SPECTATOR); // Respawn crushed spectators + else + P_DamageMobj(player->mo, NULL, NULL, 1, DMG_CRUSHED); - if (player->playerstate == PST_DEAD) - return; + if (player->playerstate == PST_DEAD) + return; + } } } From 76822cef2bdab3fd0d43f607b29682e060dd03a1 Mon Sep 17 00:00:00 2001 From: Zachary McAlpin Date: Tue, 24 Nov 2020 20:41:11 -0600 Subject: [PATCH 0373/1080] Expose the selectheading option from mapheader_t in Lua --- src/lua_maplib.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/lua_maplib.c b/src/lua_maplib.c index 95cc8c101..83744c74d 100644 --- a/src/lua_maplib.c +++ b/src/lua_maplib.c @@ -2189,6 +2189,8 @@ static int mapheaderinfo_get(lua_State *L) lua_pushinteger(L, header->levelflags); else if (fastcmp(field,"menuflags")) lua_pushinteger(L, header->menuflags); + else if (fastcmp(field,"selectheading")) + lua_pushstring(L, header->selectheading); else if (fastcmp(field,"startrings")) lua_pushinteger(L, header->startrings); else if (fastcmp(field, "sstimer")) From b2d6d4f83fb07ddc8f3dfb850f9de8fc43152109 Mon Sep 17 00:00:00 2001 From: SMS Alfredo <65426124+SMS-Alfredo@users.noreply.github.com> Date: Wed, 25 Nov 2020 12:35:36 -0600 Subject: [PATCH 0374/1080] Expose `player.skin` and `player.availabilities` to Lua as Read-only --- src/lua_playerlib.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/lua_playerlib.c b/src/lua_playerlib.c index 412dc3eff..0eb54808f 100644 --- a/src/lua_playerlib.c +++ b/src/lua_playerlib.c @@ -158,6 +158,10 @@ static int player_get(lua_State *L) lua_pushinteger(L, plr->flashpal); else if (fastcmp(field,"skincolor")) lua_pushinteger(L, plr->skincolor); + else if (fastcmp(field,"skin")) + lua_pushinteger(L, plr->skin); + else if (fastcmp(field,"availabilities")) + lua_pushinteger(L, plr->availabilities); else if (fastcmp(field,"score")) lua_pushinteger(L, plr->score); else if (fastcmp(field,"dashspeed")) @@ -469,6 +473,10 @@ static int player_set(lua_State *L) return luaL_error(L, "player.skincolor %d out of range (0 - %d).", newcolor, numskincolors-1); plr->skincolor = newcolor; } + else if (fastcmp(field,"skin")) + return NOSET; + else if (fastcmp(field,"availabilities")) + return NOSET; else if (fastcmp(field,"score")) plr->score = (UINT32)luaL_checkinteger(L, 3); else if (fastcmp(field,"dashspeed")) From 5c71fe07103e7f3febbb94bc0d9a6a7bd9426fc0 Mon Sep 17 00:00:00 2001 From: SMS Alfredo <65426124+SMS-Alfredo@users.noreply.github.com> Date: Wed, 25 Nov 2020 14:31:24 -0600 Subject: [PATCH 0375/1080] Allow player.lastlinehit and player.lastsidehit to be used outside of Knuckles' climbing ability --- src/p_map.c | 14 +++++++++++--- src/p_mobj.c | 4 ++++ src/p_user.c | 6 ------ 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/p_map.c b/src/p_map.c index 922c0d9ec..4f344a9b0 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -3443,9 +3443,17 @@ static boolean PTR_SlideTraverse(intercept_t *in) P_ProcessSpecialSector(slidemo->player, slidemo->subsector->sector, li->polyobj->lines[0]->backsector); } - if (slidemo->player && slidemo->player->charability == CA_GLIDEANDCLIMB - && (slidemo->player->pflags & PF_GLIDING || slidemo->player->climbing)) - PTR_GlideClimbTraverse(li); + if (slidemo->player) + { + if (slidemo->player->charability == CA_GLIDEANDCLIMB + && (slidemo->player->pflags & PF_GLIDING || slidemo->player->climbing)) + PTR_GlideClimbTraverse(li); + else + { + slidemo->player->lastsidehit = li->sidenum[P_PointOnLineSide(slidemo->x, slidemo->y, li)]; + slidemo->player->lastlinehit = (INT16)(li - lines); + } + } if (in->frac < bestslidefrac && (!slidemo->player || !slidemo->player->climbing)) { diff --git a/src/p_mobj.c b/src/p_mobj.c index 4fc561b20..8dab1b2cf 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -11404,6 +11404,10 @@ void P_SpawnPlayer(INT32 playernum) p->normalspeed = skins[p->skin].normalspeed; p->jumpfactor = skins[p->skin].jumpfactor; } + + // Clear lastlinehit and lastsidehit + p->lastsidehit = -1; + p->lastlinehit = -1; //awayview stuff p->awayviewmobj = NULL; diff --git a/src/p_user.c b/src/p_user.c index 10b7e970e..73f6339a9 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -8601,12 +8601,6 @@ void P_MovePlayer(player_t *player) player->climbing--; } - if (!player->climbing) - { - player->lastsidehit = -1; - player->lastlinehit = -1; - } - // Make sure you're not teetering when you shouldn't be. if (player->panim == PA_EDGE && (player->mo->momx || player->mo->momy || player->mo->momz)) From db6b0c6aa0f305cfbf2bd98885b83c0a098237f1 Mon Sep 17 00:00:00 2001 From: Zippy_Zolton Date: Wed, 25 Nov 2020 21:46:45 -0600 Subject: [PATCH 0376/1080] Fix normal one-up sound playing in Mario mode --- src/p_user.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index c5f919c78..57eb1e072 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -1491,10 +1491,10 @@ void P_PlayLivesJingle(player_t *player) if (player && !P_IsLocalPlayer(player)) return; - if (use1upSound || cv_1upsound.value) - S_StartSound(NULL, sfx_oneup); - else if (mariomode) + if (mariomode) S_StartSound(NULL, sfx_marioa); + else if (use1upSound || cv_1upsound.value) + S_StartSound(NULL, sfx_oneup); else { P_PlayJingle(player, JT_1UP); From b9f6069cd07b14d15b2bd26da2f49db3ae96e608 Mon Sep 17 00:00:00 2001 From: James R Date: Sat, 28 Nov 2020 02:19:52 -0800 Subject: [PATCH 0377/1080] Replace TC macros with an enum that automatically counts up Also fixes TC_DASHMODE not being accessible to Lua. --- src/lua_hudlib.c | 6 ++++-- src/r_draw.h | 18 +++++++++++------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/lua_hudlib.c b/src/lua_hudlib.c index f4e5d5ccf..04fbf41a0 100644 --- a/src/lua_hudlib.c +++ b/src/lua_hudlib.c @@ -896,8 +896,10 @@ static int libd_getColormap(lua_State *L) else if (lua_type(L, 1) == LUA_TNUMBER) // skin number { skinnum = (INT32)luaL_checkinteger(L, 1); - if (skinnum < TC_BLINK || skinnum >= MAXSKINS) - return luaL_error(L, "skin number %d is out of range (%d - %d)", skinnum, TC_BLINK, MAXSKINS-1); + if (skinnum >= MAXSKINS) + return luaL_error(L, "skin number %d is out of range (>%d)", skinnum, MAXSKINS-1); + else if (skinnum < 0 && skinnum > TC_DEFAULT) + return luaL_error(L, "translation colormap index is out of range"); } else // skin name { diff --git a/src/r_draw.h b/src/r_draw.h index 9957541ca..d1eb83033 100644 --- a/src/r_draw.h +++ b/src/r_draw.h @@ -106,13 +106,17 @@ extern lumpnum_t viewborderlump[8]; #define GTC_CACHE 1 -#define TC_DEFAULT -1 -#define TC_BOSS -2 -#define TC_METALSONIC -3 // For Metal Sonic battle -#define TC_ALLWHITE -4 // For Cy-Brak-demon -#define TC_RAINBOW -5 // For single colour -#define TC_BLINK -6 // For item blinking, according to kart -#define TC_DASHMODE -7 // For Metal Sonic's dashmode +enum +{ + TC_BOSS = INT8_MIN, + TC_METALSONIC, // For Metal Sonic battle + TC_ALLWHITE, // For Cy-Brak-demon + TC_RAINBOW, // For single colour + TC_BLINK, // For item blinking, according to kart + TC_DASHMODE, // For Metal Sonic's dashmode + + TC_DEFAULT +}; // Custom player skin translation // Initialize color translation tables, for player rendering etc. From 75c5c8ba6a0ffc54ff609fe1ae644b70c53edb68 Mon Sep 17 00:00:00 2001 From: James R Date: Sat, 28 Nov 2020 02:22:08 -0800 Subject: [PATCH 0378/1080] Add missing *individual* skin flags --- src/d_player.h | 2 +- src/r_skins.c | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/d_player.h b/src/d_player.h index eb0372832..79f2a3b92 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -51,7 +51,7 @@ typedef enum SF_NONIGHTSSUPER = 1<<15, // Disable super colors for NiGHTS (if you have SF_SUPER) SF_NOSUPERSPRITES = 1<<16, // Don't use super sprites while super SF_NOSUPERJUMPBOOST = 1<<17, // Disable the jump boost given while super (i.e. Knuckles) - SF_CANBUSTWALLS = 1<<18, // Can naturally bust walls on contact? (i.e. Knuckles) + SF_CANBUSTWALLS = 1<<18, // Can naturally bust walls on contact? (i.e. Knuckles) // free up to and including 1<<31 } skinflags_t; diff --git a/src/r_skins.c b/src/r_skins.c index 25904e95e..522d9236a 100644 --- a/src/r_skins.c +++ b/src/r_skins.c @@ -511,6 +511,9 @@ static boolean R_ProcessPatchableFields(skin_t *skin, char *stoken, char *value) GETFLAG(MULTIABILITY) GETFLAG(NONIGHTSROTATION) GETFLAG(NONIGHTSSUPER) + GETFLAG(NOSUPERSPRITES) + GETFLAG(NOSUPERJUMPBOOST) + GETFLAG(CANBUSTWALLS) #undef GETFLAG else // let's check if it's a sound, otherwise error out From 6b4d4226649eebb200f1f00e0f863f39a28ea57d Mon Sep 17 00:00:00 2001 From: James R Date: Sat, 28 Nov 2020 20:00:01 -0800 Subject: [PATCH 0379/1080] Don't add pk3 if there are holes ZIP tools often read the final central directory, but SRB2 may not if there are multiple central directories. It's just easier to not allow "holes", or unaccounted for bytes in the file. --- src/w_wad.c | 111 ++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 85 insertions(+), 26 deletions(-) diff --git a/src/w_wad.c b/src/w_wad.c index aca530fa5..19432e937 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -716,7 +716,7 @@ UINT16 W_InitFile(const char *filename, boolean mainfile, boolean startup) #endif size_t packetsize; UINT8 md5sum[16]; - boolean important; + int important; if (!(refreshdirmenu & REFRESHDIR_ADDFILE)) refreshdirmenu = REFRESHDIR_NORMAL|REFRESHDIR_ADDFILE; // clean out cons_alerts that happened earlier @@ -746,10 +746,18 @@ UINT16 W_InitFile(const char *filename, boolean mainfile, boolean startup) if ((handle = W_OpenWadFile(&filename, true)) == NULL) return W_InitFileError(filename, startup); + important = W_VerifyNMUSlumps(filename); + + if (important == -1) + { + fclose(handle); + return W_InitFileError(filename, startup); + } + // Check if wad files will overflow fileneededbuffer. Only the filename part // is send in the packet; cf. // see PutFileNeeded in d_netfil.c - if ((important = !W_VerifyNMUSlumps(filename))) + if ((important = !important)) { packetsize = packetsizetally + nameonlylength(filename) + 22; @@ -1919,8 +1927,16 @@ static lumpchecklist_t folderblacklist[] = static int W_VerifyPK3 (FILE *fp, lumpchecklist_t *checklist, boolean status) { + int verified = true; + zend_t zend; zentry_t zentry; + zlentry_t zlentry; + + long file_size;/* size of zip file */ + long data_size;/* size of data inside zip file */ + + long old_position; UINT16 numlumps; size_t i; @@ -1936,6 +1952,8 @@ W_VerifyPK3 (FILE *fp, lumpchecklist_t *checklist, boolean status) // Central directory bullshit fseek(fp, 0, SEEK_END); + file_size = ftell(fp); + if (!ResFindSignature(fp, pat_end, max(0, ftell(fp) - (22 + 65536)))) return true; @@ -1943,6 +1961,8 @@ W_VerifyPK3 (FILE *fp, lumpchecklist_t *checklist, boolean status) if (fread(&zend, 1, sizeof zend, fp) < sizeof zend) return true; + data_size = sizeof zend; + numlumps = zend.entries; fseek(fp, zend.cdiroffset, SEEK_SET); @@ -1957,40 +1977,79 @@ W_VerifyPK3 (FILE *fp, lumpchecklist_t *checklist, boolean status) if (memcmp(zentry.signature, pat_central, 4)) return true; - fullname = malloc(zentry.namelen + 1); - if (fgets(fullname, zentry.namelen + 1, fp) != fullname) - return true; - - // Strip away file address and extension for the 8char name. - if ((trimname = strrchr(fullname, '/')) != 0) - trimname++; - else - trimname = fullname; // Care taken for root files. - - if (*trimname) // Ignore directories, well kinda + if (verified == true) { - if ((dotpos = strrchr(trimname, '.')) == 0) - dotpos = fullname + strlen(fullname); // Watch for files without extension. + fullname = malloc(zentry.namelen + 1); + if (fgets(fullname, zentry.namelen + 1, fp) != fullname) + return true; - memset(lumpname, '\0', 9); // Making sure they're initialized to 0. Is it necessary? - strncpy(lumpname, trimname, min(8, dotpos - trimname)); + // Strip away file address and extension for the 8char name. + if ((trimname = strrchr(fullname, '/')) != 0) + trimname++; + else + trimname = fullname; // Care taken for root files. - if (! W_VerifyName(lumpname, checklist, status)) - return false; + if (*trimname) // Ignore directories, well kinda + { + if ((dotpos = strrchr(trimname, '.')) == 0) + dotpos = fullname + strlen(fullname); // Watch for files without extension. - // Check for directories next, if it's blacklisted it will return false - if (W_VerifyName(fullname, folderblacklist, status)) - return false; + memset(lumpname, '\0', 9); // Making sure they're initialized to 0. Is it necessary? + strncpy(lumpname, trimname, min(8, dotpos - trimname)); + + if (! W_VerifyName(lumpname, checklist, status)) + verified = false; + + // Check for directories next, if it's blacklisted it will return false + else if (W_VerifyName(fullname, folderblacklist, status)) + verified = false; + } + + free(fullname); + + // skip and ignore comments/extra fields + if (fseek(fp, zentry.xtralen + zentry.commlen, SEEK_CUR) != 0) + return true; + } + else + { + if (fseek(fp, zentry.namelen + zentry.xtralen + zentry.commlen, SEEK_CUR) != 0) + return true; } - free(fullname); + data_size += + sizeof zentry + zentry.namelen + zentry.xtralen + zentry.commlen; - // skip and ignore comments/extra fields - if (fseek(fp, zentry.xtralen + zentry.commlen, SEEK_CUR) != 0) + old_position = ftell(fp); + + if (fseek(fp, zentry.offset, SEEK_SET) != 0) return true; + + if (fread(&zlentry, 1, sizeof(zlentry_t), fp) < sizeof (zlentry_t)) + return true; + + data_size += + sizeof zlentry + zlentry.namelen + zlentry.xtralen + zlentry.compsize; + + fseek(fp, old_position, SEEK_SET); } - return true; + if (data_size < file_size) + { + const char * error = "ZIP file has holes (%ld extra bytes)\n"; + CONS_Alert(CONS_ERROR, error, (file_size - data_size)); + return -1; + } + else if (data_size > file_size) + { + const char * error = "Reported size of ZIP file contents exceeds file size (%ld extra bytes)\n"; + CONS_Alert(CONS_ERROR, error, (data_size - file_size)); + return -1; + } + else + { + return verified; + } } // Note: This never opens lumps themselves and therefore doesn't have to From 95dfb93a117a76f60e9a7cd0e316a7e9d81ca87a Mon Sep 17 00:00:00 2001 From: SMS Alfredo <65426124+SMS-Alfredo@users.noreply.github.com> Date: Sat, 28 Nov 2020 22:03:02 -0600 Subject: [PATCH 0380/1080] Allow non-player objects to apply the CR_PLAYER carry type without crashing the game --- src/p_user.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index 10b7e970e..6205a40dd 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -12580,13 +12580,16 @@ void P_PlayerAfterThink(player_t *player) player->powers[pw_carry] = CR_NONE; else { - P_TryMove(player->mo, tails->x + P_ReturnThrustX(tails, tails->player->drawangle, 4*FRACUNIT), tails->y + P_ReturnThrustY(tails, tails->player->drawangle, 4*FRACUNIT), true); + if (tails->player) + P_TryMove(player->mo, tails->x + P_ReturnThrustX(tails, tails->player->drawangle, 4*FRACUNIT), tails->y + P_ReturnThrustY(tails, tails->player->drawangle, 4*FRACUNIT), true); + else + P_TryMove(player->mo, tails->x + P_ReturnThrustX(tails, tails->angle, 4*FRACUNIT), tails->y + P_ReturnThrustY(tails, tails->angle, 4*FRACUNIT), true); player->mo->momx = tails->momx; player->mo->momy = tails->momy; player->mo->momz = tails->momz; } - if (G_CoopGametype() && (!tails->player || tails->player->bot != 1)) + if (G_CoopGametype() && tails->player && tails->player->bot != 1) { player->mo->angle = tails->angle; @@ -12601,7 +12604,7 @@ void P_PlayerAfterThink(player_t *player) { if (player->mo->state-states != S_PLAY_RIDE) P_SetPlayerMobjState(player->mo, S_PLAY_RIDE); - if ((tails->skin && ((skin_t *)(tails->skin))->sprites[SPR2_SWIM].numframes) && (tails->eflags & MFE_UNDERWATER)) + if (tails->player && (tails->skin && ((skin_t *)(tails->skin))->sprites[SPR2_SWIM].numframes) && (tails->eflags & MFE_UNDERWATER)) tails->player->powers[pw_tailsfly] = 0; } else From 445d0407959ae36f93f7d7265ec5e36093782e8f Mon Sep 17 00:00:00 2001 From: James R Date: Sat, 28 Nov 2020 20:51:21 -0800 Subject: [PATCH 0381/1080] Don't print W_VerifyFile errors more than once --- src/d_main.c | 6 +----- src/d_netcmd.c | 8 +++++++- src/w_wad.c | 23 +++++++++++++++++------ src/w_wad.h | 2 +- 4 files changed, 26 insertions(+), 13 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index 1045d4d99..ace1b5ed4 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -998,7 +998,7 @@ static void IdentifyVersion(void) #define MUSICTEST(str) \ {\ const char *musicpath = va(pandf,srb2waddir,str);\ - int ms = W_VerifyNMUSlumps(musicpath); \ + int ms = W_VerifyNMUSlumps(musicpath, false); \ if (ms == 1) \ D_AddFile(startupwadfiles, musicpath); \ else if (ms == 0) \ @@ -1187,11 +1187,7 @@ void D_SRB2Main(void) const char *s = M_GetNextParm(); if (s) // Check for NULL? - { - if (!W_VerifyNMUSlumps(s)) - G_SetGameModified(true); D_AddFile(startuppwads, s); - } } } } diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 31c10f58a..49a465ce7 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -3294,7 +3294,13 @@ static void Command_Addfile(void) if (!isprint(fn[i]) || fn[i] == ';') return; - musiconly = W_VerifyNMUSlumps(fn); + musiconly = W_VerifyNMUSlumps(fn, false); + + if (musiconly == -1) + { + addedfiles[numfilesadded++] = fn; + continue; + } if (!musiconly) { diff --git a/src/w_wad.c b/src/w_wad.c index 19432e937..2429eaf92 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -66,6 +66,7 @@ #include "p_setup.h" // P_ScanThings #endif #include "m_misc.h" // M_MapNumber +#include "g_game.h" // G_SetGameModified #ifdef HWRENDER #include "hardware/hw_main.h" @@ -683,9 +684,9 @@ static UINT16 W_InitFileError (const char *filename, boolean exitworthy) if (exitworthy) { #ifdef _DEBUG - CONS_Error("A WAD file was not found or not valid.\nCheck the log to see which ones.\n"); + CONS_Error(va("%s was not found or not valid.\nCheck the log for more details.\n", filename)); #else - I_Error("A WAD file was not found or not valid.\nCheck the log to see which ones.\n"); + I_Error("%s was not found or not valid.\nCheck the log for more details.\n", filename); #endif } else @@ -746,12 +747,12 @@ UINT16 W_InitFile(const char *filename, boolean mainfile, boolean startup) if ((handle = W_OpenWadFile(&filename, true)) == NULL) return W_InitFileError(filename, startup); - important = W_VerifyNMUSlumps(filename); + important = W_VerifyNMUSlumps(filename, startup); if (important == -1) { fclose(handle); - return W_InitFileError(filename, startup); + return INT16_MAX; } // Check if wad files will overflow fileneededbuffer. Only the filename part @@ -819,6 +820,9 @@ UINT16 W_InitFile(const char *filename, boolean mainfile, boolean startup) return W_InitFileError(filename, startup); } + if (important && !mainfile) + G_SetGameModified(true); + // // link wad file to search files // @@ -2088,12 +2092,13 @@ static int W_VerifyFile(const char *filename, lumpchecklist_t *checklist, * be sent. * * \param filename Filename of the wad to check. + * \param exit_on_error Whether to exit upon file error. * \return 1 if file contains only music/sound lumps, 0 if it contains other * stuff (maps, sprites, dehacked lumps, and so on). -1 if there no * file exists with that filename * \author Alam Arias */ -int W_VerifyNMUSlumps(const char *filename) +int W_VerifyNMUSlumps(const char *filename, boolean exit_on_error) { // MIDI, MOD/S3M/IT/XM/OGG/MP3/WAV, WAVE SFX // ENDOOM text and palette lumps @@ -2167,7 +2172,13 @@ int W_VerifyNMUSlumps(const char *filename) {NULL, 0}, }; - return W_VerifyFile(filename, NMUSlist, false); + + int status = W_VerifyFile(filename, NMUSlist, false); + + if (status == -1) + W_InitFileError(filename, exit_on_error); + + return status; } /** \brief Generates a virtual resource used for level data loading. diff --git a/src/w_wad.h b/src/w_wad.h index 1e86eea5a..d0a86bcb4 100644 --- a/src/w_wad.h +++ b/src/w_wad.h @@ -206,6 +206,6 @@ void W_UnlockCachedPatch(void *patch); void W_VerifyFileMD5(UINT16 wadfilenum, const char *matchmd5); -int W_VerifyNMUSlumps(const char *filename); +int W_VerifyNMUSlumps(const char *filename, boolean exit_on_error); #endif // __W_WAD__ From 59d26465939ea9941f7d29e67a5b270c9362a21d Mon Sep 17 00:00:00 2001 From: GoldenTails Date: Sun, 29 Nov 2020 08:30:50 -0600 Subject: [PATCH 0382/1080] Send a `quitting` argument to the GameQuit Lua hook --- src/d_clisrv.c | 6 +++--- src/d_netcmd.c | 4 ++-- src/lua_hook.h | 2 +- src/lua_hooklib.c | 5 +++-- src/m_menu.c | 4 ++-- src/sdl/i_video.c | 2 +- 6 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index b198011a0..8951fe204 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -3027,7 +3027,7 @@ static void Got_KickCmd(UINT8 **p, INT32 playernum) if (pnum == consoleplayer) { if (Playing()) - LUAh_GameQuit(); + LUAh_GameQuit(false); #ifdef DUMPCONSISTENCY if (msg == KICK_MSG_CON_FAIL) SV_SavedGame(); #endif @@ -3728,7 +3728,7 @@ static void HandleShutdown(SINT8 node) { (void)node; if (Playing()) - LUAh_GameQuit(); + LUAh_GameQuit(false); D_QuitNetGame(); CL_Reset(); D_StartTitle(); @@ -3744,7 +3744,7 @@ static void HandleTimeout(SINT8 node) { (void)node; if (Playing()) - LUAh_GameQuit(); + LUAh_GameQuit(false); D_QuitNetGame(); CL_Reset(); D_StartTitle(); diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 31c10f58a..ec46aa4c3 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -3607,7 +3607,7 @@ static void Command_Playintro_f(void) FUNCNORETURN static ATTRNORETURN void Command_Quit_f(void) { if (Playing()) - LUAh_GameQuit(); + LUAh_GameQuit(true); I_Quit(); } @@ -4270,7 +4270,7 @@ void Command_ExitGame_f(void) INT32 i; if (Playing()) - LUAh_GameQuit(); + LUAh_GameQuit(false); D_QuitNetGame(); CL_Reset(); diff --git a/src/lua_hook.h b/src/lua_hook.h index 796f3a9d2..dd41814b5 100644 --- a/src/lua_hook.h +++ b/src/lua_hook.h @@ -117,6 +117,6 @@ boolean LUAh_SeenPlayer(player_t *player, player_t *seenfriend); // Hook for MT_ #endif #define LUAh_PlayerThink(player) LUAh_PlayerHook(player, hook_PlayerThink) // Hook for P_PlayerThink boolean LUAh_ShouldJingleContinue(player_t *player, const char *musname); // Hook for whether a jingle of the given music should continue playing -void LUAh_GameQuit(void); // Hook for game quitting +void LUAh_GameQuit(boolean quitting); // Hook for game quitting boolean LUAh_PlayerCmd(player_t *player, ticcmd_t *cmd); // Hook for building player's ticcmd struct (Ported from SRB2Kart) boolean LUAh_MusicChange(const char *oldname, char *newname, UINT16 *mflags, boolean *looping, UINT32 *position, UINT32 *prefadems, UINT32 *fadeinms); // Hook for music changes \ No newline at end of file diff --git a/src/lua_hooklib.c b/src/lua_hooklib.c index 117aa48a3..a206f80db 100644 --- a/src/lua_hooklib.c +++ b/src/lua_hooklib.c @@ -1846,7 +1846,7 @@ boolean LUAh_ShouldJingleContinue(player_t *player, const char *musname) } // Hook for game quitting -void LUAh_GameQuit(void) +void LUAh_GameQuit(boolean quitting) { hook_p hookp; if (!gL || !(hooksAvailable[hook_GameQuit/8] & (1<<(hook_GameQuit%8)))) @@ -1860,7 +1860,8 @@ void LUAh_GameQuit(void) continue; PushHook(gL, hookp); - if (lua_pcall(gL, 0, 0, 1)) { + lua_pushboolean(gL, quitting); + if (lua_pcall(gL, 1, 0, 1)) { if (!hookp->error || cv_debug & DBG_LUA) CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); lua_pop(gL, 1); diff --git a/src/m_menu.c b/src/m_menu.c index 77648f877..135137c12 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -6938,7 +6938,7 @@ static void M_UltimateCheat(INT32 choice) { (void)choice; if (Playing()) - LUAh_GameQuit(); + LUAh_GameQuit(true); I_Quit(); } @@ -13373,7 +13373,7 @@ void M_QuitResponse(INT32 ch) if (ch != 'y' && ch != KEY_ENTER) return; if (Playing()) - LUAh_GameQuit(); + LUAh_GameQuit(true); if (!(netgame || cv_debug)) { S_ResetCaptions(); diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index b8b3b9d34..310275d55 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -1058,7 +1058,7 @@ void I_GetEvent(void) break; case SDL_QUIT: if (Playing()) - LUAh_GameQuit(); + LUAh_GameQuit(true); I_Quit(); break; } From b389700de3a9523b946ecdb5cc8450ea70d422a4 Mon Sep 17 00:00:00 2001 From: GoldenTails Date: Sun, 29 Nov 2020 08:32:04 -0600 Subject: [PATCH 0383/1080] Always call GameQuit when quitting via the Quit menu option on the title screen. --- src/m_menu.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index 135137c12..258b01318 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -13372,8 +13372,7 @@ void M_QuitResponse(INT32 ch) if (ch != 'y' && ch != KEY_ENTER) return; - if (Playing()) - LUAh_GameQuit(true); + LUAh_GameQuit(true); if (!(netgame || cv_debug)) { S_ResetCaptions(); From 119d2e9e37ec60c5a729e4dd255a96f37be8d7b2 Mon Sep 17 00:00:00 2001 From: GoldenTails Date: Sun, 29 Nov 2020 16:53:29 -0600 Subject: [PATCH 0384/1080] Remove the rest of the Playing() checks for GameQuit hook --- src/d_clisrv.c | 9 +++------ src/d_netcmd.c | 6 ++---- src/m_menu.c | 3 +-- src/sdl/i_video.c | 3 +-- 4 files changed, 7 insertions(+), 14 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 8951fe204..52f091fee 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -3026,8 +3026,7 @@ static void Got_KickCmd(UINT8 **p, INT32 playernum) if (pnum == consoleplayer) { - if (Playing()) - LUAh_GameQuit(false); + LUAh_GameQuit(false); #ifdef DUMPCONSISTENCY if (msg == KICK_MSG_CON_FAIL) SV_SavedGame(); #endif @@ -3727,8 +3726,7 @@ static void HandleConnect(SINT8 node) static void HandleShutdown(SINT8 node) { (void)node; - if (Playing()) - LUAh_GameQuit(false); + LUAh_GameQuit(false); D_QuitNetGame(); CL_Reset(); D_StartTitle(); @@ -3743,8 +3741,7 @@ static void HandleShutdown(SINT8 node) static void HandleTimeout(SINT8 node) { (void)node; - if (Playing()) - LUAh_GameQuit(false); + LUAh_GameQuit(false); D_QuitNetGame(); CL_Reset(); D_StartTitle(); diff --git a/src/d_netcmd.c b/src/d_netcmd.c index ec46aa4c3..7d5a598db 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -3606,8 +3606,7 @@ static void Command_Playintro_f(void) */ FUNCNORETURN static ATTRNORETURN void Command_Quit_f(void) { - if (Playing()) - LUAh_GameQuit(true); + LUAh_GameQuit(true); I_Quit(); } @@ -4269,8 +4268,7 @@ void Command_ExitGame_f(void) { INT32 i; - if (Playing()) - LUAh_GameQuit(false); + LUAh_GameQuit(false); D_QuitNetGame(); CL_Reset(); diff --git a/src/m_menu.c b/src/m_menu.c index 258b01318..5ec9132f7 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -6937,8 +6937,7 @@ static void M_SelectableClearMenus(INT32 choice) static void M_UltimateCheat(INT32 choice) { (void)choice; - if (Playing()) - LUAh_GameQuit(true); + LUAh_GameQuit(true); I_Quit(); } diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index 310275d55..5ebff8700 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -1057,8 +1057,7 @@ void I_GetEvent(void) M_SetupJoystickMenu(0); break; case SDL_QUIT: - if (Playing()) - LUAh_GameQuit(true); + LUAh_GameQuit(true); I_Quit(); break; } From f913d60a9faab27ddf9182051b8d1190af87ac17 Mon Sep 17 00:00:00 2001 From: Zippy_Zolton Date: Sun, 29 Nov 2020 17:16:57 -0600 Subject: [PATCH 0385/1080] Make P_DoSuperTransformation (with giverings) add 50 rings instead of setting it --- 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 c5f919c78..04c5e1387 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -1342,7 +1342,7 @@ void P_DoSuperTransformation(player_t *player, boolean giverings) P_SetPlayerMobjState(player->mo, S_PLAY_SUPER_TRANS1); if (giverings) - player->rings = 50; + player->rings += 50; // Just in case. if (!(mapheaderinfo[gamemap-1]->levelflags & LF_NOSSMUSIC)) From 412f3fc42b4c8b57ca0bd0eee0fd67c2f8abae71 Mon Sep 17 00:00:00 2001 From: Zippy_Zolton Date: Sun, 29 Nov 2020 17:39:54 -0600 Subject: [PATCH 0386/1080] P_GivePlayerRings --- 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 04c5e1387..166027c8d 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -1342,7 +1342,7 @@ void P_DoSuperTransformation(player_t *player, boolean giverings) P_SetPlayerMobjState(player->mo, S_PLAY_SUPER_TRANS1); if (giverings) - player->rings += 50; + P_GivePlayerRings(player, 50) // Just in case. if (!(mapheaderinfo[gamemap-1]->levelflags & LF_NOSSMUSIC)) From da1a3029a90a43475afd0a8f7a356c94697366ea Mon Sep 17 00:00:00 2001 From: Zippy_Zolton Date: Mon, 30 Nov 2020 12:04:35 -0600 Subject: [PATCH 0387/1080] overhaul --- src/p_user.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index 166027c8d..66cce3082 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -1341,8 +1341,8 @@ void P_DoSuperTransformation(player_t *player, boolean giverings) // Transformation animation P_SetPlayerMobjState(player->mo, S_PLAY_SUPER_TRANS1); - if (giverings) - P_GivePlayerRings(player, 50) + if (giverings) && player->rings > 50 + player->rings = 50 // Just in case. if (!(mapheaderinfo[gamemap-1]->levelflags & LF_NOSSMUSIC)) From 20d181198374a092d5639f149f635ae3f69885c3 Mon Sep 17 00:00:00 2001 From: Zippy_Zolton Date: Mon, 30 Nov 2020 12:05:45 -0600 Subject: [PATCH 0388/1080] oops --- 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 66cce3082..e357c8b5c 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -1342,7 +1342,7 @@ void P_DoSuperTransformation(player_t *player, boolean giverings) P_SetPlayerMobjState(player->mo, S_PLAY_SUPER_TRANS1); if (giverings) && player->rings > 50 - player->rings = 50 + player->rings = 50; // Just in case. if (!(mapheaderinfo[gamemap-1]->levelflags & LF_NOSSMUSIC)) From 9770368ee9b2e60fb375b60da71e66f130c44e06 Mon Sep 17 00:00:00 2001 From: Tatsuru <44866610+Ikkarin@users.noreply.github.com> Date: Mon, 30 Nov 2020 18:21:06 -0300 Subject: [PATCH 0389/1080] Initialize junk line tag lists --- src/p_enemy.c | 8 ++++++++ src/p_inter.c | 4 ++++ 2 files changed, 12 insertions(+) diff --git a/src/p_enemy.c b/src/p_enemy.c index 22de9bc67..63a14636d 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -3924,6 +3924,10 @@ void A_BossDeath(mobj_t *mo) } else { + // Initialize my junk + junk.tags.tags = NULL; + junk.tags.count = 0; + // Bring the egg trap up to the surface // Incredibly shitty code ahead Tag_FSet(&junk.tags, LE_CAPSULE0); @@ -4053,6 +4057,10 @@ bossjustdie: } case MT_KOOPA: { + // Initialize my junk + junk.tags.tags = NULL; + junk.tags.count = 0; + Tag_FSet(&junk.tags, LE_KOOPA); EV_DoCeiling(&junk, raiseToHighest); return; diff --git a/src/p_inter.c b/src/p_inter.c index 415c679e4..9bfe54e54 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -1388,6 +1388,10 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) if (player->bot) return; + // Initialize my junk + junk.tags.tags = NULL; + junk.tags.count = 0; + Tag_FSet(&junk.tags, LE_AXE); EV_DoElevator(&junk, bridgeFall, false); From 69248cc684541678162920b5573b125ec3f6bc73 Mon Sep 17 00:00:00 2001 From: Zippy_Zolton Date: Mon, 30 Nov 2020 16:39:24 -0600 Subject: [PATCH 0390/1080] thanks zap --- 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 e357c8b5c..31aadffa6 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -1341,7 +1341,7 @@ void P_DoSuperTransformation(player_t *player, boolean giverings) // Transformation animation P_SetPlayerMobjState(player->mo, S_PLAY_SUPER_TRANS1); - if (giverings) && player->rings > 50 + if (giverings && player->rings < 50) player->rings = 50; // Just in case. From d004515d6a57059bbd136625856e548c839727ae Mon Sep 17 00:00:00 2001 From: James R Date: Mon, 30 Nov 2020 19:04:23 -0800 Subject: [PATCH 0391/1080] Fix double define --- src/deh_tables.c | 5 +++++ src/deh_tables.h | 8 ++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/deh_tables.c b/src/deh_tables.c index 1ed385e7b..5733d9b0e 100644 --- a/src/deh_tables.c +++ b/src/deh_tables.c @@ -25,6 +25,11 @@ #include "deh_tables.h" +char *FREE_STATES[NUMSTATEFREESLOTS]; +char *FREE_MOBJS[NUMMOBJFREESLOTS]; +char *FREE_SKINCOLORS[NUMCOLORFREESLOTS]; +UINT8 used_spr[(NUMSPRITEFREESLOTS / 8) + 1]; // Bitwise flag for sprite freeslot in use! I would use ceil() here if I could, but it only saves 1 byte of memory anyway. + const char NIGHTSGRADE_LIST[] = { 'F', // GRADE_F 'E', // GRADE_E diff --git a/src/deh_tables.h b/src/deh_tables.h index 28e0ad927..2c6b3e204 100644 --- a/src/deh_tables.h +++ b/src/deh_tables.h @@ -20,10 +20,10 @@ // Free slot names // The crazy word-reading stuff uses these. -char *FREE_STATES[NUMSTATEFREESLOTS]; -char *FREE_MOBJS[NUMMOBJFREESLOTS]; -char *FREE_SKINCOLORS[NUMCOLORFREESLOTS]; -UINT8 used_spr[(NUMSPRITEFREESLOTS / 8) + 1]; // Bitwise flag for sprite freeslot in use! I would use ceil() here if I could, but it only saves 1 byte of memory anyway. +extern char *FREE_STATES[NUMSTATEFREESLOTS]; +extern char *FREE_MOBJS[NUMMOBJFREESLOTS]; +extern char *FREE_SKINCOLORS[NUMCOLORFREESLOTS]; +extern UINT8 used_spr[(NUMSPRITEFREESLOTS / 8) + 1]; // Bitwise flag for sprite freeslot in use! I would use ceil() here if I could, but it only saves 1 byte of memory anyway. #define initfreeslots() {\ memset(FREE_STATES,0,sizeof(char *) * NUMSTATEFREESLOTS);\ From c8ae28bbaf3a16ca445647da47968573078507e9 Mon Sep 17 00:00:00 2001 From: Nev3r Date: Tue, 1 Dec 2020 18:35:24 +0100 Subject: [PATCH 0392/1080] Follow GZDoom's convention for stringargs. --- 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 918ffbd4e..e02cb34aa 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -1628,9 +1628,9 @@ static void ParseTextmapLinedefParameter(UINT32 i, char *param, char *val) return; lines[i].args[argnum] = atol(val); } - else if (fastncmp(param, "stringarg", 9) && strlen(param) > 9) + else if (strlen(param) == 7 && fastncmp(param, "arg", 3) && fastncmp(param + 4, "str", 3)) { - size_t argnum = param[9] - '0'; + size_t argnum = param[3] - '0'; if (argnum >= NUMLINESTRINGARGS) return; lines[i].stringargs[argnum] = Z_Malloc(strlen(val) + 1, PU_LEVEL, NULL); @@ -1727,9 +1727,9 @@ static void ParseTextmapThingParameter(UINT32 i, char *param, char *val) return; mapthings[i].args[argnum] = atol(val); } - else if (fastncmp(param, "stringarg", 9) && strlen(param) > 9) + else if (strlen(param) == 7 && fastncmp(param, "arg", 3) && fastncmp(param + 4, "str", 3)) { - size_t argnum = param[9] - '0'; + size_t argnum = param[3] - '0'; if (argnum >= NUMMAPTHINGSTRINGARGS) return; mapthings[i].stringargs[argnum] = Z_Malloc(strlen(val) + 1, PU_LEVEL, NULL); From 4d716cb1707b3822dd333f57214faf8e8875aac1 Mon Sep 17 00:00:00 2001 From: Nev3r Date: Tue, 1 Dec 2020 19:44:58 +0100 Subject: [PATCH 0393/1080] Move the numerical arg check below so that the string gets checked first (who decided to give them such similar names anyway). --- src/p_setup.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index e02cb34aa..41d8822e2 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -1621,13 +1621,6 @@ static void ParseTextmapLinedefParameter(UINT32 i, char *param, char *val) P_SetLinedefV1(i, atol(val)); else if (fastcmp(param, "v2")) P_SetLinedefV2(i, atol(val)); - else if (fastncmp(param, "arg", 3) && strlen(param) > 3) - { - size_t argnum = atol(param + 3); - if (argnum >= NUMLINEARGS) - return; - lines[i].args[argnum] = atol(val); - } else if (strlen(param) == 7 && fastncmp(param, "arg", 3) && fastncmp(param + 4, "str", 3)) { size_t argnum = param[3] - '0'; @@ -1636,6 +1629,13 @@ static void ParseTextmapLinedefParameter(UINT32 i, char *param, char *val) lines[i].stringargs[argnum] = Z_Malloc(strlen(val) + 1, PU_LEVEL, NULL); M_Memcpy(lines[i].stringargs[argnum], val, strlen(val) + 1); } + else if (fastncmp(param, "arg", 3) && strlen(param) > 3) + { + size_t argnum = atol(param + 3); + if (argnum >= NUMLINEARGS) + return; + lines[i].args[argnum] = atol(val); + } else if (fastcmp(param, "sidefront")) lines[i].sidenum[0] = atol(val); else if (fastcmp(param, "sideback")) @@ -1720,13 +1720,6 @@ static void ParseTextmapThingParameter(UINT32 i, char *param, char *val) else if (fastcmp(param, "ambush") && fastcmp("true", val)) mapthings[i].options |= MTF_AMBUSH; - else if (fastncmp(param, "arg", 3) && strlen(param) > 3) - { - size_t argnum = atol(param + 3); - if (argnum >= NUMMAPTHINGARGS) - return; - mapthings[i].args[argnum] = atol(val); - } else if (strlen(param) == 7 && fastncmp(param, "arg", 3) && fastncmp(param + 4, "str", 3)) { size_t argnum = param[3] - '0'; @@ -1735,6 +1728,13 @@ static void ParseTextmapThingParameter(UINT32 i, char *param, char *val) mapthings[i].stringargs[argnum] = Z_Malloc(strlen(val) + 1, PU_LEVEL, NULL); M_Memcpy(mapthings[i].stringargs[argnum], val, strlen(val) + 1); } + else if (fastncmp(param, "arg", 3) && strlen(param) > 3) + { + size_t argnum = atol(param + 3); + if (argnum >= NUMMAPTHINGARGS) + return; + mapthings[i].args[argnum] = atol(val); + } } /** From a given position table, run a specified parser function through a {}-encapsuled text. From b2544395926ed4c5f7ec02a91e486feb6ba5b78d Mon Sep 17 00:00:00 2001 From: Radicalicious Date: Wed, 2 Dec 2020 00:17:57 -0500 Subject: [PATCH 0394/1080] Update hw_light.c --- src/hardware/hw_light.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/hardware/hw_light.c b/src/hardware/hw_light.c index 987d70c69..76fecd7aa 100644 --- a/src/hardware/hw_light.c +++ b/src/hardware/hw_light.c @@ -340,6 +340,7 @@ light_t *t_lspr[NUMSPRITES] = &lspr[NOLIGHT], // SPR_BMCH &lspr[NOLIGHT], // SPR_SMCE &lspr[NOLIGHT], // SPR_BMCE + &lspr[NOLIGHT], // SPR_BSPB &lspr[NOLIGHT], // SPR_YSPB &lspr[NOLIGHT], // SPR_RSPB &lspr[REDBALL_L], // SPR_SFBR From a67862665a054538788fdb7b01575198bc37a35d Mon Sep 17 00:00:00 2001 From: Tatsuru <44866610+Ikkarin@users.noreply.github.com> Date: Wed, 2 Dec 2020 12:05:40 -0300 Subject: [PATCH 0395/1080] Don't spawn the projectile if you're just gonna delete it --- src/p_mobj.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index 7ba6d1fad..a259847ea 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -5654,14 +5654,10 @@ static void P_Boss9Thinker(mobj_t *mobj) if (P_RandomRange(1,(dist>>FRACBITS)/16) == 1) break; } - if (spawner) + if (spawner && dist) { mobj_t *missile = P_SpawnMissile(spawner, mobj, MT_MSGATHER); - - if (dist == 0) - missile->fuse = 0; - else - missile->fuse = (dist/P_AproxDistance(missile->momx, missile->momy)); + missile->fuse = (dist/P_AproxDistance(missile->momx, missile->momy)); if (missile->fuse > mobj->fuse) P_RemoveMobj(missile); From 0ffb241c0a1705273c0c93790b67d2ce3474ad0e Mon Sep 17 00:00:00 2001 From: Jaime Ita Passos Date: Wed, 2 Dec 2020 15:31:11 -0300 Subject: [PATCH 0396/1080] Fix 3D floor culling with polyobject segs --- src/r_segs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/r_segs.c b/src/r_segs.c index 1ed1f0285..3bc0d011c 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -1191,7 +1191,7 @@ static void R_RenderSegLoop (void) // Lactozilla: Cull part of the column by the 3D floor if it can't be seen // "bottom" is the top pixel of the floor column - if (ffbottom >= bottom-1 && R_FFloorCanClip(&ffloor[i])) + if (ffbottom >= bottom-1 && R_FFloorCanClip(&ffloor[i]) && !curline->polyseg) { rw_floormarked = true; floorclip[rw_x] = fftop; @@ -1239,7 +1239,7 @@ static void R_RenderSegLoop (void) // Lactozilla: Cull part of the column by the 3D floor if it can't be seen // "top" is the height of the ceiling column - if (fftop <= top+1 && R_FFloorCanClip(&ffloor[i])) + if (fftop <= top+1 && R_FFloorCanClip(&ffloor[i]) && !curline->polyseg) { rw_ceilingmarked = true; ceilingclip[rw_x] = ffbottom; From 47b8c0648b2b87fdf7ec388e1f0c3b48239c8cff Mon Sep 17 00:00:00 2001 From: Jaime Ita Passos Date: Wed, 2 Dec 2020 15:34:11 -0300 Subject: [PATCH 0397/1080] Don't clip if the 3D floor is fog --- src/r_segs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/r_segs.c b/src/r_segs.c index 3bc0d011c..c79071e9b 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -540,7 +540,7 @@ static boolean R_IsFFloorTranslucent(visffloor_t *pfloor) // Polyobjects have no ffloors, and they're handled in the conditional above. if (pfloor->ffloor != NULL) - return (pfloor->ffloor->flags & FF_TRANSLUCENT); + return (pfloor->ffloor->flags & (FF_TRANSLUCENT|FF_FOG)); return false; } From c98108df2764e1cdcd8537655d3b479be1b3b4ea Mon Sep 17 00:00:00 2001 From: Radicalicious Date: Thu, 3 Dec 2020 00:46:28 +0000 Subject: [PATCH 0398/1080] Revert "Update hw_light.c" This reverts commit b2544395926ed4c5f7ec02a91e486feb6ba5b78d --- src/hardware/hw_light.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/hardware/hw_light.c b/src/hardware/hw_light.c index 76fecd7aa..987d70c69 100644 --- a/src/hardware/hw_light.c +++ b/src/hardware/hw_light.c @@ -340,7 +340,6 @@ light_t *t_lspr[NUMSPRITES] = &lspr[NOLIGHT], // SPR_BMCH &lspr[NOLIGHT], // SPR_SMCE &lspr[NOLIGHT], // SPR_BMCE - &lspr[NOLIGHT], // SPR_BSPB &lspr[NOLIGHT], // SPR_YSPB &lspr[NOLIGHT], // SPR_RSPB &lspr[REDBALL_L], // SPR_SFBR From b5526312e7fb36ae58a27f44b3e6e979246ac42e Mon Sep 17 00:00:00 2001 From: GoldenTails Date: Wed, 2 Dec 2020 19:47:00 -0600 Subject: [PATCH 0399/1080] Fix missing stuff --- src/deh_tables.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/deh_tables.c b/src/deh_tables.c index 5733d9b0e..3240aee14 100644 --- a/src/deh_tables.c +++ b/src/deh_tables.c @@ -4331,6 +4331,7 @@ const char *const MOBJFLAG2_LIST[] = { "AMBUSH", // Alternate behaviour typically set by MTF_AMBUSH "LINKDRAW", // Draw vissprite of mobj immediately before/after tracer's vissprite (dependent on dispoffset and position) "SHIELD", // Thinker calls P_AddShield/P_ShieldLook (must be partnered with MF_SCENERY to use) + "SPLAT", // Object is a splat NULL }; @@ -4871,6 +4872,36 @@ struct int_const_s const INT_CONST[] = { {"tr_trans90",tr_trans90}, {"NUMTRANSMAPS",NUMTRANSMAPS}, + // Alpha styles (blend modes) + {"AST_COPY",AST_COPY}, + {"AST_TRANSLUCENT",AST_TRANSLUCENT}, + {"AST_ADD",AST_ADD}, + {"AST_SUBTRACT",AST_SUBTRACT}, + {"AST_REVERSESUBTRACT",AST_REVERSESUBTRACT}, + {"AST_MODULATE",AST_MODULATE}, + {"AST_OVERLAY",AST_OVERLAY}, + + // Render flags + {"RF_HORIZONTALFLIP",RF_HORIZONTALFLIP}, + {"RF_VERTICALFLIP",RF_VERTICALFLIP}, + {"RF_ABSOLUTEOFFSETS",RF_ABSOLUTEOFFSETS}, + {"RF_FLIPOFFSETS",RF_FLIPOFFSETS}, + {"RF_SPLATMASK",RF_SLOPESPLAT}, + {"RF_SLOPESPLAT",RF_SLOPESPLAT}, + {"RF_OBJECTSLOPESPLAT",RF_OBJECTSLOPESPLAT}, + {"RF_NOSPLATBILLBOARD",RF_NOSPLATBILLBOARD}, + {"RF_NOSPLATROLLANGLE",RF_NOSPLATROLLANGLE}, + {"RF_BLENDMASK",RF_BLENDMASK}, + {"RF_FULLBRIGHT",RF_FULLBRIGHT}, + {"RF_FULLDARK",RF_FULLDARK}, + {"RF_NOCOLORMAPS",RF_NOCOLORMAPS}, + {"RF_SPRITETYPEMASK",RF_SPRITETYPEMASK}, + {"RF_PAPERSPRITE",RF_PAPERSPRITE}, + {"RF_FLOORSPRITE",RF_FLOORSPRITE}, + {"RF_SHADOWDRAW",RF_SHADOWDRAW}, + {"RF_SHADOWEFFECTS",RF_SHADOWEFFECTS}, + {"RF_DROPSHADOW",RF_DROPSHADOW}, + // Level flags {"LF_SCRIPTISFILE",LF_SCRIPTISFILE}, {"LF_SPEEDMUSIC",LF_SPEEDMUSIC}, From c28bd8005eea0cf8ab83326ddb1b0d35deca0e9d Mon Sep 17 00:00:00 2001 From: Zippy_Zolton Date: Thu, 3 Dec 2020 01:28:54 -0600 Subject: [PATCH 0400/1080] Fix fire objects disappearing in lava --- src/p_mobj.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index 7ba6d1fad..d06e57d66 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -7937,7 +7937,7 @@ static boolean P_MobjPushableThink(mobj_t *mobj) P_PushableThinker(mobj); // Extinguish fire objects in water. (Yes, it's extraordinarily rare to have a pushable flame object, but Brak uses such a case.) - if (mobj->flags & MF_FIRE && mobj->type != MT_PUMA && mobj->type != MT_FIREBALL + if (mobj->flags & MF_FIRE && mobj->eflags ! MFE_TOUCHLAVA && (mobj->eflags & (MFE_UNDERWATER | MFE_TOUCHWATER))) { P_KillMobj(mobj, NULL, NULL, 0); @@ -9705,7 +9705,7 @@ static boolean P_MobjRegularThink(mobj_t *mobj) P_MobjCheckWater(mobj); // Extinguish fire objects in water - if (mobj->flags & MF_FIRE && mobj->type != MT_PUMA && mobj->type != MT_FIREBALL + if (mobj->flags & MF_FIRE && mobj->eflags ! MFE_TOUCHLAVA && (mobj->eflags & (MFE_UNDERWATER|MFE_TOUCHWATER))) { P_KillMobj(mobj, NULL, NULL, 0); From 29f56fb2d8c3dc7d2010023278433aad10481960 Mon Sep 17 00:00:00 2001 From: Zippy_Zolton Date: Thu, 3 Dec 2020 02:05:10 -0600 Subject: [PATCH 0401/1080] g --- src/p_mobj.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index d06e57d66..4494c72b7 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -7937,7 +7937,7 @@ static boolean P_MobjPushableThink(mobj_t *mobj) P_PushableThinker(mobj); // Extinguish fire objects in water. (Yes, it's extraordinarily rare to have a pushable flame object, but Brak uses such a case.) - if (mobj->flags & MF_FIRE && mobj->eflags ! MFE_TOUCHLAVA + if ((mobj->flags & MF_FIRE) && !(mobj->eflags & MFE_TOUCHLAVA) && (mobj->eflags & (MFE_UNDERWATER | MFE_TOUCHWATER))) { P_KillMobj(mobj, NULL, NULL, 0); @@ -9705,7 +9705,7 @@ static boolean P_MobjRegularThink(mobj_t *mobj) P_MobjCheckWater(mobj); // Extinguish fire objects in water - if (mobj->flags & MF_FIRE && mobj->eflags ! MFE_TOUCHLAVA + if ((mobj->flags & MF_FIRE) && !(mobj->eflags & MFE_TOUCHLAVA) && (mobj->eflags & (MFE_UNDERWATER|MFE_TOUCHWATER))) { P_KillMobj(mobj, NULL, NULL, 0); From fae845f935db2973da75e5f74197ada426bcd9a8 Mon Sep 17 00:00:00 2001 From: Tatsuru <44866610+Ikkarin@users.noreply.github.com> Date: Thu, 3 Dec 2020 17:50:10 -0300 Subject: [PATCH 0402/1080] Initialize in p_spec.c too + magic number replacement --- src/p_spec.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/p_spec.c b/src/p_spec.c index a1afdd00d..4996573a9 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -4420,15 +4420,19 @@ void P_ProcessSpecialSector(player_t *player, sector_t *sector, sector_t *rovers // clear the special so you can't push the button twice. sector->special = 0; + // Initialize my junk + junk.tags.tags = NULL; + junk.tags.count = 0; + // Move the button down - Tag_FSet(&junk.tags, 680); + Tag_FSet(&junk.tags, LE_CAPSULE0); EV_DoElevator(&junk, elevateDown, false); // Open the top FOF - Tag_FSet(&junk.tags, 681); + Tag_FSet(&junk.tags, LE_CAPSULE1); EV_DoFloor(&junk, raiseFloorToNearestFast); // Open the bottom FOF - Tag_FSet(&junk.tags, 682); + Tag_FSet(&junk.tags, LE_CAPSULE2); EV_DoCeiling(&junk, lowerToLowestFast); // Mark all players with the time to exit thingy! From 4c53eabc59c8d2d60d90d9019cf5b1939b627647 Mon Sep 17 00:00:00 2001 From: Steel Titanium Date: Thu, 3 Dec 2020 21:14:27 -0500 Subject: [PATCH 0403/1080] Reword the error to be more consistent with other errors --- src/lua_skinlib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lua_skinlib.c b/src/lua_skinlib.c index e2f16756a..ea368a9cd 100644 --- a/src/lua_skinlib.c +++ b/src/lua_skinlib.c @@ -340,7 +340,7 @@ static int lib_getSkinSprite(lua_State *L) playersprite_t i = luaL_checkinteger(L, 2); if (i < 0 || i >= NUMPLAYERSPRITES*2) - return luaL_error(L, "skin.sprites[] index %d out of range (0 - %d)", i, (NUMPLAYERSPRITES*2)-1); + return luaL_error(L, LUA_QL("skin_t") " field 'sprites' index %d out of range (0 - %d)", i, (NUMPLAYERSPRITES*2)-1); LUA_PushLightUserdata(L, &sprites[i], META_SKINSPRITESLIST); return 1; From 2017eb4d9ed67f880c9c418561073c358762c679 Mon Sep 17 00:00:00 2001 From: Jaime Ita Passos Date: Wed, 2 Dec 2020 16:57:08 -0300 Subject: [PATCH 0404/1080] Fix polyobject segs messing with 3D floors they shouldn't be --- src/r_segs.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/r_segs.c b/src/r_segs.c index 1ed1f0285..7c913e023 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -1477,10 +1477,18 @@ static void R_RenderSegLoop (void) } for (i = 0; i < numffloors; i++) + { + if (curline->polyseg && (ffloor[i].polyobj != curline->polyseg)) + continue; + ffloor[i].f_frac += ffloor[i].f_step; + } for (i = 0; i < numbackffloors; i++) { + if (curline->polyseg && (ffloor[i].polyobj != curline->polyseg)) + continue; + ffloor[i].f_clip[rw_x] = ffloor[i].c_clip[rw_x] = (INT16)((ffloor[i].b_frac >> HEIGHTBITS) & 0xFFFF); ffloor[i].b_frac += ffloor[i].b_step; } From 621efbfa158e49a33f6ba8a55c267cb10f85b602 Mon Sep 17 00:00:00 2001 From: James R Date: Fri, 4 Dec 2020 00:30:08 -0800 Subject: [PATCH 0405/1080] Lua taglib for accessing taggroups The global "tags" can be iterated upon for every unique tag which is set in the level. If a tag is set on a sector/line/thing, it will be included. Taking the length of "tags" will give you the number of these unique tags. (If a tag is set on multiple sectors/lines/things, it will only be counted once though.) For sectors, lines and mapthings, call the field "tagged". This function takes one argument, which is the tag. The return value can be iterated over for all the sectors/lines/things with that tag. The length can also be taken for the number of such objects. If no argument is given, the global tag is default. --- src/CMakeLists.txt | 1 + src/blua/Makefile.cfg | 1 + src/doomtype.h | 22 +++++++++++ src/lua_libs.h | 1 + src/lua_maplib.c | 60 +++++++++-------------------- src/lua_mobjlib.c | 31 +++++---------- src/lua_script.c | 59 ++++++++++++++++++++++++++-- src/lua_script.h | 48 ++++++++++++++++++++--- src/taglist.c | 90 +++++++++++++++++++++++-------------------- src/taglist.h | 10 +++++ 10 files changed, 208 insertions(+), 115 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d35e774e9..87a0499b6 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -276,6 +276,7 @@ set(SRB2_LUA_SOURCES lua_hudlib.c lua_infolib.c lua_maplib.c + lua_taglib.c lua_mathlib.c lua_mobjlib.c lua_playerlib.c diff --git a/src/blua/Makefile.cfg b/src/blua/Makefile.cfg index eae95ba3a..3a2962e65 100644 --- a/src/blua/Makefile.cfg +++ b/src/blua/Makefile.cfg @@ -47,6 +47,7 @@ OBJS:=$(OBJS) \ $(OBJDIR)/lua_skinlib.o \ $(OBJDIR)/lua_thinkerlib.o \ $(OBJDIR)/lua_maplib.o \ + $(OBJDIR)/lua_taglib.o \ $(OBJDIR)/lua_polyobjlib.o \ $(OBJDIR)/lua_blockmaplib.o \ $(OBJDIR)/lua_hudlib.o diff --git a/src/doomtype.h b/src/doomtype.h index 4e13ba96d..08317c65a 100644 --- a/src/doomtype.h +++ b/src/doomtype.h @@ -379,4 +379,26 @@ Needed for some lua shenanigans. #define FIELDFROM( type, field, have, want ) \ (void *)((intptr_t)(field) - offsetof (type, have) + offsetof (type, want)) +typedef UINT8 bitarray_t; + +#define BIT_ARRAY_SIZE(n) (((n) + 7) >> 3) + +static inline int +in_bit_array (const bitarray_t * const array, const int value) +{ + return (array[value >> 3] & (1<<(value & 7))); +} + +static inline void +set_bit_array (bitarray_t * const array, const int value) +{ + array[value >> 3] |= (1<<(value & 7)); +} + +static inline void +unset_bit_array (bitarray_t * const array, const int value) +{ + array[value >> 3] &= ~(1<<(value & 7)); +} + #endif //__DOOMTYPE__ diff --git a/src/lua_libs.h b/src/lua_libs.h index 062a3fe50..aa0638683 100644 --- a/src/lua_libs.h +++ b/src/lua_libs.h @@ -93,6 +93,7 @@ int LUA_PlayerLib(lua_State *L); int LUA_SkinLib(lua_State *L); int LUA_ThinkerLib(lua_State *L); int LUA_MapLib(lua_State *L); +int LUA_TagLib(lua_State *L); int LUA_PolyObjLib(lua_State *L); int LUA_BlockmapLib(lua_State *L); int LUA_HudLib(lua_State *L); diff --git a/src/lua_maplib.c b/src/lua_maplib.c index 95cc8c101..a3df28cca 100644 --- a/src/lua_maplib.c +++ b/src/lua_maplib.c @@ -1385,25 +1385,15 @@ static int lib_iterateSectors(lua_State *L) static int lib_getSector(lua_State *L) { - int field; INLEVEL - lua_settop(L, 2); - lua_remove(L, 1); // dummy userdata table is unused. - if (lua_isnumber(L, 1)) + if (lua_isnumber(L, 2)) { - size_t i = lua_tointeger(L, 1); + size_t i = lua_tointeger(L, 2); if (i >= numsectors) return 0; LUA_PushUserdata(L, §ors[i], META_SECTOR); return 1; } - field = luaL_checkoption(L, 1, NULL, array_opt); - switch(field) - { - case 0: // iterate - lua_pushcfunction(L, lib_iterateSectors); - return 1; - } return 0; } @@ -1489,25 +1479,15 @@ static int lib_iterateLines(lua_State *L) static int lib_getLine(lua_State *L) { - int field; INLEVEL - lua_settop(L, 2); - lua_remove(L, 1); // dummy userdata table is unused. - if (lua_isnumber(L, 1)) + if (lua_isnumber(L, 2)) { - size_t i = lua_tointeger(L, 1); + size_t i = lua_tointeger(L, 2); if (i >= numlines) return 0; LUA_PushUserdata(L, &lines[i], META_LINE); return 1; } - field = luaL_checkoption(L, 1, NULL, array_opt); - switch(field) - { - case 0: // iterate - lua_pushcfunction(L, lib_iterateLines); - return 1; - } return 0; } @@ -2358,15 +2338,13 @@ int LUA_MapLib(lua_State *L) //lua_setfield(L, -2, "__len"); lua_pop(L, 1); - lua_newuserdata(L, 0); - lua_createtable(L, 0, 2); - lua_pushcfunction(L, lib_getSector); - lua_setfield(L, -2, "__index"); - - lua_pushcfunction(L, lib_numsectors); - lua_setfield(L, -2, "__len"); - lua_setmetatable(L, -2); - lua_setglobal(L, "sectors"); + LUA_PushTaggableObjectArray(L, "sectors", + lib_iterateSectors, + lib_getSector, + lib_numsectors, + tags_sectors, + &numsectors, §ors, + sizeof (sector_t), META_SECTOR); lua_newuserdata(L, 0); lua_createtable(L, 0, 2); @@ -2378,15 +2356,13 @@ int LUA_MapLib(lua_State *L) lua_setmetatable(L, -2); lua_setglobal(L, "subsectors"); - lua_newuserdata(L, 0); - lua_createtable(L, 0, 2); - lua_pushcfunction(L, lib_getLine); - lua_setfield(L, -2, "__index"); - - lua_pushcfunction(L, lib_numlines); - lua_setfield(L, -2, "__len"); - lua_setmetatable(L, -2); - lua_setglobal(L, "lines"); + LUA_PushTaggableObjectArray(L, "lines", + lib_iterateLines, + lib_getLine, + lib_numlines, + tags_lines, + &numlines, &lines, + sizeof (line_t), META_LINE); lua_newuserdata(L, 0); lua_createtable(L, 0, 2); diff --git a/src/lua_mobjlib.c b/src/lua_mobjlib.c index 7aae18c90..134f104ee 100644 --- a/src/lua_mobjlib.c +++ b/src/lua_mobjlib.c @@ -22,8 +22,6 @@ #include "lua_hud.h" // hud_running errors #include "lua_hook.h" // hook_cmd_running errors -static const char *const array_opt[] ={"iterate",NULL}; - enum mobj_e { mobj_valid = 0, mobj_x, @@ -1003,25 +1001,15 @@ static int lib_iterateMapthings(lua_State *L) static int lib_getMapthing(lua_State *L) { - int field; INLEVEL - lua_settop(L, 2); - lua_remove(L, 1); // dummy userdata table is unused. - if (lua_isnumber(L, 1)) + if (lua_isnumber(L, 2)) { - size_t i = lua_tointeger(L, 1); + size_t i = lua_tointeger(L, 2); if (i >= nummapthings) return 0; LUA_PushUserdata(L, &mapthings[i], META_MAPTHING); return 1; } - field = luaL_checkoption(L, 1, NULL, array_opt); - switch(field) - { - case 0: // iterate - lua_pushcfunction(L, lib_iterateMapthings); - return 1; - } return 0; } @@ -1068,14 +1056,13 @@ int LUA_MobjLib(lua_State *L) lua_setfield(L, -2, "__len"); lua_pop(L,1); - lua_newuserdata(L, 0); - lua_createtable(L, 0, 2); - lua_pushcfunction(L, lib_getMapthing); - lua_setfield(L, -2, "__index"); + LUA_PushTaggableObjectArray(L, "mapthings", + lib_iterateMapthings, + lib_getMapthing, + lib_nummapthings, + tags_mapthings, + &nummapthings, &mapthings, + sizeof (mapthing_t), META_MAPTHING); - lua_pushcfunction(L, lib_nummapthings); - lua_setfield(L, -2, "__len"); - lua_setmetatable(L, -2); - lua_setglobal(L, "mapthings"); return 0; } diff --git a/src/lua_script.c b/src/lua_script.c index eb4737f76..ee60a41c6 100644 --- a/src/lua_script.c +++ b/src/lua_script.c @@ -53,6 +53,7 @@ static lua_CFunction liblist[] = { LUA_SkinLib, // skin_t, skins[] LUA_ThinkerLib, // thinker_t LUA_MapLib, // line_t, side_t, sector_t, subsector_t + LUA_TagLib, // tags LUA_PolyObjLib, // polyobj_t LUA_BlockmapLib, // blockmap stuff LUA_HudLib, // HUD stuff @@ -739,25 +740,37 @@ void LUA_PushLightUserdata (lua_State *L, void *data, const char *meta) // Pushes it to the stack and stores it in the registry. void LUA_PushUserdata(lua_State *L, void *data, const char *meta) { + if (LUA_RawPushUserdata(L, data) == LPUSHED_NEW) + { + luaL_getmetatable(L, meta); + lua_setmetatable(L, -2); + } +} + +// Same as LUA_PushUserdata but don't set a metatable yet. +lpushed_t LUA_RawPushUserdata(lua_State *L, void *data) +{ + lpushed_t status = LPUSHED_NIL; + void **userdata; if (!data) { // push a NULL lua_pushnil(L); - return; + return status; } lua_getfield(L, LUA_REGISTRYINDEX, LREG_VALID); I_Assert(lua_istable(L, -1)); + lua_pushlightuserdata(L, data); lua_rawget(L, -2); + if (lua_isnil(L, -1)) { // no userdata? deary me, we'll have to make one. lua_pop(L, 1); // pop the nil // create the userdata userdata = lua_newuserdata(L, sizeof(void *)); *userdata = data; - luaL_getmetatable(L, meta); - lua_setmetatable(L, -2); // Set it in the registry so we can find it again lua_pushlightuserdata(L, data); // k (store the userdata via the data's pointer) @@ -765,8 +778,15 @@ void LUA_PushUserdata(lua_State *L, void *data, const char *meta) lua_rawset(L, -4); // stack is left with the userdata on top, as if getting it had originally succeeded. + + status = LPUSHED_NEW; } + else + status = LPUSHED_EXISTING; + lua_remove(L, -2); // remove LREG_VALID + + return status; } // When userdata is freed, use this function to remove it from Lua. @@ -1681,3 +1701,36 @@ int Lua_optoption(lua_State *L, int narg, return i; return -1; } + +void LUA_PushTaggableObjectArray +( lua_State *L, + const char *field, + lua_CFunction iterator, + lua_CFunction indexer, + lua_CFunction counter, + taggroup_t *garray[], + size_t * max_elements, + void * element_array, + size_t sizeof_element, + const char *meta) +{ + lua_newuserdata(L, 0); + lua_createtable(L, 0, 2); + lua_createtable(L, 0, 2); + lua_pushcfunction(L, iterator); + lua_setfield(L, -2, "iterate"); + + LUA_InsertTaggroupIterator(L, garray, + max_elements, element_array, sizeof_element, meta); + + lua_createtable(L, 0, 1); + lua_pushcfunction(L, indexer); + lua_setfield(L, -2, "__index"); + lua_setmetatable(L, -2); + lua_setfield(L, -2, "__index"); + + lua_pushcfunction(L, counter); + lua_setfield(L, -2, "__len"); + lua_setmetatable(L, -2); + lua_setglobal(L, field); +} diff --git a/src/lua_script.h b/src/lua_script.h index 79ba0bb38..2dc34446a 100644 --- a/src/lua_script.h +++ b/src/lua_script.h @@ -10,10 +10,14 @@ /// \file lua_script.h /// \brief Lua scripting basics +#ifndef LUA_SCRIPT_H +#define LUA_SCRIPT_H + #include "m_fixed.h" #include "doomtype.h" #include "d_player.h" #include "g_state.h" +#include "taglist.h" #include "blua/lua.h" #include "blua/lualib.h" @@ -46,12 +50,6 @@ void LUA_LoadLump(UINT16 wad, UINT16 lump, boolean noresults); void LUA_DumpFile(const char *filename); #endif fixed_t LUA_EvalMath(const char *word); -void LUA_PushLightUserdata(lua_State *L, void *data, const char *meta); -void LUA_PushUserdata(lua_State *L, void *data, const char *meta); -void LUA_InvalidateUserdata(void *data); -void LUA_InvalidateLevel(void); -void LUA_InvalidateMapthings(void); -void LUA_InvalidatePlayer(player_t *player); void LUA_Step(void); void LUA_Archive(void); void LUA_UnArchive(void); @@ -63,6 +61,42 @@ int Lua_optoption(lua_State *L, int narg, const char *def, const char *const lst[]); void LUAh_NetArchiveHook(lua_CFunction archFunc); +void LUA_PushTaggableObjectArray +( lua_State *L, + const char *field, + lua_CFunction iterator, + lua_CFunction indexer, + lua_CFunction counter, + taggroup_t *garray[], + size_t * max_elements, + void * element_array, + size_t sizeof_element, + const char *meta); + +void LUA_InsertTaggroupIterator +( lua_State *L, + taggroup_t *garray[], + size_t * max_elements, + void * element_array, + size_t sizeof_element, + const char * meta); + +typedef enum { + LPUSHED_NIL, + LPUSHED_NEW, + LPUSHED_EXISTING, +} lpushed_t; + +void LUA_PushLightUserdata(lua_State *L, void *data, const char *meta); +void LUA_PushUserdata(lua_State *L, void *data, const char *meta); +lpushed_t LUA_RawPushUserdata(lua_State *L, void *data); + +void LUA_InvalidateUserdata(void *data); + +void LUA_InvalidateLevel(void); +void LUA_InvalidateMapthings(void); +void LUA_InvalidatePlayer(player_t *player); + // Console wrapper void COM_Lua_f(void); @@ -98,3 +132,5 @@ void COM_Lua_f(void); #define INLEVEL if (! ISINLEVEL)\ return luaL_error(L, "This can only be used in a level!"); + +#endif/*LUA_SCRIPT_H*/ diff --git a/src/taglist.c b/src/taglist.c index b11216b6c..658605734 100644 --- a/src/taglist.c +++ b/src/taglist.c @@ -15,6 +15,11 @@ #include "z_zone.h" #include "r_data.h" +// Bit array of whether a tag exists for sectors/lines/things. +bitarray_t tags_available[BIT_ARRAY_SIZE (MAXTAGS)]; + +size_t num_tags; + // Taggroups are used to list elements of the same tag, for iteration. // Since elements can now have multiple tags, it means an element may appear // in several taggroups at the same time. These are built on level load. @@ -105,6 +110,33 @@ size_t Taggroup_Find (const taggroup_t *group, const size_t id) return -1; } +/// Iterate thru elements in a global taggroup. +INT32 Taggroup_Iterate +( taggroup_t *garray[], + const size_t max_elements, + const mtag_t tag, + const size_t p) +{ + const taggroup_t *group; + + if (tag == MTAG_GLOBAL) + { + if (p < max_elements) + return p; + return -1; + } + + group = garray[(UINT16)tag]; + + if (group) + { + if (p < group->count) + return group->elements[p]; + return -1; + } + return -1; +} + /// Add an element to a global taggroup. void Taggroup_Add (taggroup_t *garray[], const mtag_t tag, size_t id) { @@ -120,6 +152,11 @@ void Taggroup_Add (taggroup_t *garray[], const mtag_t tag, size_t id) if (Taggroup_Find(group, id) != (size_t)-1) return; + if (! in_bit_array(tags_available, tag)) + num_tags++; + + set_bit_array(tags_available, tag); + // Create group if empty. if (!group) { @@ -161,6 +198,11 @@ void Taggroup_Remove (taggroup_t *garray[], const mtag_t tag, size_t id) if ((rempos = Taggroup_Find(group, id)) == (size_t)-1) return; + if (in_bit_array(tags_available, tag)) + num_tags--; + + unset_bit_array(tags_available, tag); + // Strip away taggroup if no elements left. if (!(newcount = --group->count)) { @@ -209,6 +251,9 @@ void Taglist_InitGlobalTables(void) { size_t i, j; + memset(tags_available, 0, sizeof tags_available); + num_tags = 0; + for (i = 0; i < MAXTAGS; i++) { tags_sectors[i] = NULL; @@ -236,56 +281,17 @@ void Taglist_InitGlobalTables(void) INT32 Tag_Iterate_Sectors (const mtag_t tag, const size_t p) { - if (tag == MTAG_GLOBAL) - { - if (p < numsectors) - return p; - return -1; - } - - if (tags_sectors[(UINT16)tag]) - { - if (p < tags_sectors[(UINT16)tag]->count) - return tags_sectors[(UINT16)tag]->elements[p]; - return -1; - } - return -1; + return Taggroup_Iterate(tags_sectors, numsectors, tag, p); } INT32 Tag_Iterate_Lines (const mtag_t tag, const size_t p) { - if (tag == MTAG_GLOBAL) - { - if (p < numlines) - return p; - return -1; - } - - if (tags_lines[(UINT16)tag]) - { - if (p < tags_lines[(UINT16)tag]->count) - return tags_lines[(UINT16)tag]->elements[p]; - return -1; - } - return -1; + return Taggroup_Iterate(tags_lines, numlines, tag, p); } INT32 Tag_Iterate_Things (const mtag_t tag, const size_t p) { - if (tag == MTAG_GLOBAL) - { - if (p < nummapthings) - return p; - return -1; - } - - if (tags_mapthings[(UINT16)tag]) - { - if (p < tags_mapthings[(UINT16)tag]->count) - return tags_mapthings[(UINT16)tag]->elements[p]; - return -1; - } - return -1; + return Taggroup_Iterate(tags_mapthings, nummapthings, tag, p); } INT32 Tag_FindLineSpecial(const INT16 special, const mtag_t tag) diff --git a/src/taglist.h b/src/taglist.h index 0e6d9f842..e5db08806 100644 --- a/src/taglist.h +++ b/src/taglist.h @@ -43,6 +43,10 @@ typedef struct size_t count; } taggroup_t; +extern bitarray_t tags_available[]; + +extern size_t num_tags; + extern taggroup_t* tags_sectors[]; extern taggroup_t* tags_lines[]; extern taggroup_t* tags_mapthings[]; @@ -51,6 +55,12 @@ void Taggroup_Add (taggroup_t *garray[], const mtag_t tag, size_t id); void Taggroup_Remove (taggroup_t *garray[], const mtag_t tag, size_t id); size_t Taggroup_Find (const taggroup_t *group, const size_t id); +INT32 Taggroup_Iterate +( taggroup_t *garray[], + const size_t max_elements, + const mtag_t tag, + const size_t p); + void Taglist_InitGlobalTables(void); INT32 Tag_Iterate_Sectors (const mtag_t tag, const size_t p); From 96851e52a10bb87c02fcc579a8407a003d9f7be5 Mon Sep 17 00:00:00 2001 From: James R Date: Fri, 4 Dec 2020 02:27:14 -0800 Subject: [PATCH 0406/1080] hehehehehe what if I forgot to git add? --- src/lua_taglib.c | 186 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 186 insertions(+) create mode 100644 src/lua_taglib.c diff --git a/src/lua_taglib.c b/src/lua_taglib.c new file mode 100644 index 000000000..e6c82fea3 --- /dev/null +++ b/src/lua_taglib.c @@ -0,0 +1,186 @@ +// SONIC ROBO BLAST 2 +//----------------------------------------------------------------------------- +// Copyright (C) 2020 by James R. +// Copyright (C) 2020 by Sonic Team Junior. +// +// This program is free software distributed under the +// terms of the GNU General Public License, version 2. +// See the 'LICENSE' file for more details. +//----------------------------------------------------------------------------- +/// \file lua_taglib.c +/// \brief tag list iterator for Lua scripting + +#include "doomdef.h" +#include "taglist.h" +#include "r_state.h" + +#include "lua_script.h" +#include "lua_libs.h" + +static int tag_iterator(lua_State *L) +{ + INT32 tag = lua_isnil(L, 2) ? -1 : lua_tonumber(L, 2); + do + { + if (++tag >= MAXTAGS) + return 0; + } + while (! in_bit_array(tags_available, tag)) ; + lua_pushnumber(L, tag); + return 1; +} + +enum { +#define UPVALUE lua_upvalueindex + up_garray = UPVALUE(1), + up_max_elements = UPVALUE(2), + up_element_array = UPVALUE(3), + up_sizeof_element = UPVALUE(4), + up_meta = UPVALUE(5), +#undef UPVALUE +}; + +static INT32 next_element(lua_State *L, const mtag_t tag, const size_t p) +{ + taggroup_t ** garray = lua_touserdata(L, up_garray); + const size_t * max_elements = lua_touserdata(L, up_max_elements); + return Taggroup_Iterate(garray, *max_elements, tag, p); +} + +static void push_element(lua_State *L, void *element) +{ + if (LUA_RawPushUserdata(L, element) == LPUSHED_NEW) + { + lua_pushvalue(L, up_meta); + lua_setmetatable(L, -2); + } +} + +static void push_next_element(lua_State *L, const INT32 element) +{ + char * element_array = *(char **)lua_touserdata(L, up_element_array); + const size_t sizeof_element = lua_tonumber(L, up_sizeof_element); + push_element(L, &element_array[element * sizeof_element]); +} + +struct element_iterator_state { + mtag_t tag; + size_t p; +}; + +static int element_iterator(lua_State *L) +{ + struct element_iterator_state * state = lua_touserdata(L, 1); + const INT32 element = next_element(L, state->tag, state->p); + + if (element == -1) + return 0; + else + { + push_next_element(L, element); + state->p++; + return 1; + } +} + +static int lib_iterateTags(lua_State *L) +{ + if (lua_gettop(L) < 2) + { + lua_pushcfunction(L, tag_iterator); + return 1; + } + else + return tag_iterator(L); +} + +static int lib_numTags(lua_State *L) +{ + lua_pushnumber(L, num_tags); + return 1; +} + +static int lib_getTaggroup(lua_State *L) +{ + struct element_iterator_state *state; + + mtag_t tag; + + if (lua_gettop(L) > 1) + return luaL_error(L, "too many arguments"); + + if (lua_isnoneornil(L, 1)) + { + tag = MTAG_GLOBAL; + } + else + { + tag = lua_tonumber(L, 1); + luaL_argcheck(L, tag >= -1, 1, "tag out of range"); + } + + state = lua_newuserdata(L, sizeof *state); + state->tag = tag; + state->p = 0; + + lua_pushvalue(L, lua_upvalueindex(1)); + lua_setmetatable(L, -2); + + return 1; +} + +static int lib_numTaggroupElements(lua_State *L) +{ + const mtag_t tag = *(mtag_t *)lua_touserdata(L, 1); + if (tag == MTAG_GLOBAL) + lua_pushnumber(L, *(size_t *)lua_touserdata(L, up_max_elements)); + else + { + const taggroup_t ** garray = lua_touserdata(L, up_garray); + lua_pushnumber(L, garray[tag] ? garray[tag]->count : 0); + } + return 1; +} + +void LUA_InsertTaggroupIterator +( lua_State *L, + taggroup_t *garray[], + size_t * max_elements, + void * element_array, + size_t sizeof_element, + const char * meta) +{ + lua_createtable(L, 0, 2); + lua_pushlightuserdata(L, garray); + lua_pushlightuserdata(L, max_elements); + + lua_pushvalue(L, -2); + lua_pushvalue(L, -2); + lua_pushlightuserdata(L, element_array); + lua_pushnumber(L, sizeof_element); + luaL_getmetatable(L, meta); + lua_pushcclosure(L, element_iterator, 5); + lua_setfield(L, -4, "__call"); + + lua_pushcclosure(L, lib_numTaggroupElements, 2); + lua_setfield(L, -2, "__len"); + lua_pushcclosure(L, lib_getTaggroup, 1); + lua_setfield(L, -2, "tagged"); +} + +int LUA_TagLib(lua_State *L) +{ + lua_newuserdata(L, 0); + lua_createtable(L, 0, 2); + lua_createtable(L, 0, 1); + lua_pushcfunction(L, lib_iterateTags); + lua_setfield(L, -2, "iterate"); + lua_setfield(L, -2, "__index"); + + lua_pushcfunction(L, lib_numTags); + lua_setfield(L, -2, "__len"); + lua_setmetatable(L, -2); + lua_setglobal(L, "tags"); + + return 0; +} From c2217bb42689502a9511a752b6e6aae3fc60aa07 Mon Sep 17 00:00:00 2001 From: James R Date: Fri, 4 Dec 2020 04:54:12 -0800 Subject: [PATCH 0407/1080] Mkae Lua taggroups indexable They are 1-indexed. --- src/lua_taglib.c | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/src/lua_taglib.c b/src/lua_taglib.c index e6c82fea3..2e2a0d277 100644 --- a/src/lua_taglib.c +++ b/src/lua_taglib.c @@ -71,16 +71,9 @@ struct element_iterator_state { static int element_iterator(lua_State *L) { struct element_iterator_state * state = lua_touserdata(L, 1); - const INT32 element = next_element(L, state->tag, state->p); - - if (element == -1) - return 0; - else - { - push_next_element(L, element); - state->p++; - return 1; - } + lua_pushnumber(L, ++state->p); + lua_gettable(L, 1); + return 1; } static int lib_iterateTags(lua_State *L) @@ -129,6 +122,21 @@ static int lib_getTaggroup(lua_State *L) return 1; } +static int lib_getTaggroupElement(lua_State *L) +{ + const size_t p = luaL_checknumber(L, 2) - 1; + const mtag_t tag = *(mtag_t *)lua_touserdata(L, 1); + const INT32 element = next_element(L, tag, p); + + if (element == -1) + return 0; + else + { + push_next_element(L, element); + return 1; + } +} + static int lib_numTaggroupElements(lua_State *L) { const mtag_t tag = *(mtag_t *)lua_touserdata(L, 1); @@ -150,7 +158,7 @@ void LUA_InsertTaggroupIterator size_t sizeof_element, const char * meta) { - lua_createtable(L, 0, 2); + lua_createtable(L, 0, 3); lua_pushlightuserdata(L, garray); lua_pushlightuserdata(L, max_elements); @@ -159,11 +167,14 @@ void LUA_InsertTaggroupIterator lua_pushlightuserdata(L, element_array); lua_pushnumber(L, sizeof_element); luaL_getmetatable(L, meta); - lua_pushcclosure(L, element_iterator, 5); - lua_setfield(L, -4, "__call"); + lua_pushcclosure(L, lib_getTaggroupElement, 5); + lua_setfield(L, -4, "__index"); lua_pushcclosure(L, lib_numTaggroupElements, 2); lua_setfield(L, -2, "__len"); + + lua_pushcfunction(L, element_iterator); + lua_setfield(L, -2, "__call"); lua_pushcclosure(L, lib_getTaggroup, 1); lua_setfield(L, -2, "tagged"); } From 314fd2783a2b22c2803b9063994a2dd48ddd98a7 Mon Sep 17 00:00:00 2001 From: James R Date: Fri, 4 Dec 2020 13:47:22 -0800 Subject: [PATCH 0408/1080] Lua tag lists Index and take length of tag lists like a table, 1-indexed. There are three methods which may be used on tag lists: list:iterate() - returns an iterator over the tags in the list list:has(tag) - returns a boolean whether the tag is in the list list.shares(list2) - returns whether two lists share a tag "find" is also an alias to "has". Each method may be accessed from the global taglist library too, e.g. taglist.iterate(list) Tag lists may be compared with an equality operator too. This will tell you if the two lists are composed of identical tags. Accessible from sector.taglist, line.taglist and mapthing.taglist. --- src/lua_baselib.c | 3 + src/lua_libs.h | 3 + src/lua_maplib.c | 12 ++++ src/lua_mobjlib.c | 7 +++ src/lua_script.h | 2 + src/lua_taglib.c | 156 ++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 183 insertions(+) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 4667fdbf4..1324322a2 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -184,12 +184,15 @@ static const struct { {META_CVAR, "consvar_t"}, {META_SECTORLINES, "sector_t.lines"}, + {META_SECTORTAGLIST, "sector_t.taglist"}, {META_SIDENUM, "line_t.sidenum"}, {META_LINEARGS, "line_t.args"}, {META_LINESTRINGARGS, "line_t.stringargs"}, + {META_LINETAGLIST, "line_t.taglist"}, {META_THINGARGS, "mapthing.args"}, {META_THINGSTRINGARGS, "mapthing.stringargs"}, + {META_THINGTAGLIST, "mapthing_t.taglist"}, #ifdef HAVE_LUA_SEGS {META_NODEBBOX, "node_t.bbox"}, {META_NODECHILDREN, "node_t.children"}, diff --git a/src/lua_libs.h b/src/lua_libs.h index aa0638683..991fae3fd 100644 --- a/src/lua_libs.h +++ b/src/lua_libs.h @@ -56,11 +56,14 @@ extern lua_State *gL; #define META_CVAR "CONSVAR_T*" #define META_SECTORLINES "SECTOR_T*LINES" +#define META_SECTORTAGLIST "SECTOR_T*TAGLIST" #define META_SIDENUM "LINE_T*SIDENUM" #define META_LINEARGS "LINE_T*ARGS" #define META_LINESTRINGARGS "LINE_T*STRINGARGS" +#define META_LINETAGLIST "LINE_T*TAGLIST" #define META_THINGARGS "MAPTHING_T*ARGS" #define META_THINGSTRINGARGS "MAPTHING_T*STRINGARGS" +#define META_THINGTAGLIST "THING_T*TAGLIST" #define META_POLYOBJVERTICES "POLYOBJ_T*VERTICES" #define META_POLYOBJLINES "POLYOBJ_T*LINES" #ifdef HAVE_LUA_SEGS diff --git a/src/lua_maplib.c b/src/lua_maplib.c index a3df28cca..25edf83d8 100644 --- a/src/lua_maplib.c +++ b/src/lua_maplib.c @@ -37,6 +37,7 @@ enum sector_e { sector_lightlevel, sector_special, sector_tag, + sector_taglist, sector_thinglist, sector_heightsec, sector_camsec, @@ -55,6 +56,7 @@ static const char *const sector_opt[] = { "lightlevel", "special", "tag", + "taglist", "thinglist", "heightsec", "camsec", @@ -89,6 +91,7 @@ enum line_e { line_flags, line_special, line_tag, + line_taglist, line_args, line_stringargs, line_sidenum, @@ -113,6 +116,7 @@ static const char *const line_opt[] = { "flags", "special", "tag", + "taglist", "args", "stringargs", "sidenum", @@ -581,6 +585,9 @@ static int sector_get(lua_State *L) case sector_tag: lua_pushinteger(L, Tag_FGet(§or->tags)); return 1; + case sector_taglist: + LUA_PushUserdata(L, §or->tags, META_SECTORTAGLIST); + return 1; case sector_thinglist: // thinglist lua_pushcfunction(L, lib_iterateSectorThinglist); LUA_PushUserdata(L, sector->thinglist, META_MOBJ); @@ -682,6 +689,8 @@ static int sector_set(lua_State *L) case sector_tag: Tag_SectorFSet((UINT32)(sector - sectors), (INT16)luaL_checkinteger(L, 3)); break; + case sector_taglist: + return LUA_ErrSetDirectly(L, "sector_t", "taglist"); } return 0; } @@ -821,6 +830,9 @@ static int line_get(lua_State *L) case line_tag: lua_pushinteger(L, Tag_FGet(&line->tags)); return 1; + case line_taglist: + LUA_PushUserdata(L, &line->tags, META_LINETAGLIST); + return 1; case line_args: LUA_PushUserdata(L, line->args, META_LINEARGS); return 1; diff --git a/src/lua_mobjlib.c b/src/lua_mobjlib.c index 134f104ee..8d205780d 100644 --- a/src/lua_mobjlib.c +++ b/src/lua_mobjlib.c @@ -902,6 +902,11 @@ static int mapthing_get(lua_State *L) number = mt->extrainfo; else if(fastcmp(field,"tag")) number = Tag_FGet(&mt->tags); + else if(fastcmp(field,"taglist")) + { + LUA_PushUserdata(L, &mt->tags, META_THINGTAGLIST); + return 1; + } else if(fastcmp(field,"args")) { LUA_PushUserdata(L, mt->args, META_THINGARGS); @@ -964,6 +969,8 @@ static int mapthing_set(lua_State *L) } else if (fastcmp(field,"tag")) Tag_FSet(&mt->tags, (INT16)luaL_checkinteger(L, 3)); + else if (fastcmp(field,"taglist")) + return LUA_ErrSetDirectly(L, "mapthing_t", "taglist"); else if(fastcmp(field,"mobj")) mt->mobj = *((mobj_t **)luaL_checkudata(L, 3, META_MOBJ)); else diff --git a/src/lua_script.h b/src/lua_script.h index 2dc34446a..77fbb7c1d 100644 --- a/src/lua_script.h +++ b/src/lua_script.h @@ -102,6 +102,8 @@ void COM_Lua_f(void); #define LUA_ErrInvalid(L, type) luaL_error(L, "accessed " type " doesn't exist anymore, please check 'valid' before using " type "."); +#define LUA_ErrSetDirectly(L, type, field) luaL_error(L, type " field " LUA_QL(field) " cannot be set directly.") + // Deprecation warnings // Shows once upon use. Then doesn't show again. #define LUA_Deprecated(L,this_func,use_instead)\ diff --git a/src/lua_taglib.c b/src/lua_taglib.c index 2e2a0d277..73f033312 100644 --- a/src/lua_taglib.c +++ b/src/lua_taglib.c @@ -150,6 +150,137 @@ static int lib_numTaggroupElements(lua_State *L) return 1; } +static void push_taglist(lua_State *L, int idx) +{ + lua_getmetatable(L, idx); + lua_pushliteral(L, "taglist"); + lua_rawget(L, -2); + lua_remove(L, -2); +} + +static int has_valid_field(lua_State *L) +{ + int equal; + lua_pushliteral(L, "valid"); + equal = lua_rawequal(L, 2, -1); + lua_pop(L, 1); + return equal; +} + +static taglist_t * valid_taglist(lua_State *L, int idx, boolean getting) +{ + taglist_t *list = *(taglist_t **)lua_touserdata(L, idx); + + if (list == NULL) + { + if (getting && has_valid_field(L)) + lua_pushboolean(L, 0); + else + LUA_ErrInvalid(L, "taglist_t");/* doesn't actually return */ + return NULL; + } + else + return list; +} + +static taglist_t * check_taglist(lua_State *L, int idx) +{ + luaL_checktype(L, idx, LUA_TUSERDATA); + push_taglist(L, idx); + luaL_argcheck(L, lua_toboolean(L, -1), idx, "must be a tag list"); + return valid_taglist(L, idx, false); +} + +static int taglist_get(lua_State *L) +{ + const taglist_t *list = valid_taglist(L, 1, true); + + if (list == NULL)/* valid check */ + return 1; + + if (lua_isnumber(L, 2)) + { + const size_t i = lua_tonumber(L, 2); + + if (list && i <= list->count) + { + lua_pushnumber(L, list->tags[i - 1]); + return 1; + } + else + return 0; + } + else if (has_valid_field(L)) + { + lua_pushboolean(L, 1); + return 1; + } + else + { + push_taglist(L, 1); + lua_replace(L, 1); + lua_rawget(L, 1); + return 1; + } +} + +static int taglist_len(lua_State *L) +{ + const taglist_t *list = valid_taglist(L, 1, false); + lua_pushnumber(L, list->count); + return 1; +} + +static int taglist_equal(lua_State *L) +{ + const taglist_t *lhs = check_taglist(L, 1); + const taglist_t *rhs = check_taglist(L, 2); + lua_pushboolean(L, Tag_Compare(lhs, rhs)); + return 1; +} + +static int taglist_iterator(lua_State *L) +{ + const taglist_t *list = valid_taglist(L, 1, false); + const size_t i = 1 + lua_tonumber(L, lua_upvalueindex(1)); + if (i <= list->count) + { + lua_pushnumber(L, list->tags[i - 1]); + /* watch me exploit an upvalue as a control because + I want to use the control as the value */ + lua_pushnumber(L, i); + lua_replace(L, lua_upvalueindex(1)); + return 1; + } + else + return 0; +} + +static int taglist_iterate(lua_State *L) +{ + check_taglist(L, 1); + lua_pushnumber(L, 0); + lua_pushcclosure(L, taglist_iterator, 1); + lua_pushvalue(L, 1); + return 2; +} + +static int taglist_find(lua_State *L) +{ + const taglist_t *list = check_taglist(L, 1); + const mtag_t tag = luaL_checknumber(L, 2); + lua_pushboolean(L, Tag_Find(list, tag)); + return 1; +} + +static int taglist_shares(lua_State *L) +{ + const taglist_t *lhs = check_taglist(L, 1); + const taglist_t *rhs = check_taglist(L, 2); + lua_pushboolean(L, Tag_Share(lhs, rhs)); + return 1; +} + void LUA_InsertTaggroupIterator ( lua_State *L, taggroup_t *garray[], @@ -179,6 +310,13 @@ void LUA_InsertTaggroupIterator lua_setfield(L, -2, "tagged"); } +static luaL_Reg taglist_lib[] = { + {"iterate", taglist_iterate}, + {"find", taglist_find}, + {"shares", taglist_shares}, + {0} +}; + int LUA_TagLib(lua_State *L) { lua_newuserdata(L, 0); @@ -193,5 +331,23 @@ int LUA_TagLib(lua_State *L) lua_setmetatable(L, -2); lua_setglobal(L, "tags"); + luaL_newmetatable(L, META_THINGTAGLIST); + luaL_register(L, "taglist", taglist_lib); + lua_getfield(L, -1, "find"); + lua_setfield(L, -2, "has"); + lua_setfield(L, -2, "taglist"); + + lua_pushcfunction(L, taglist_get); + lua_setfield(L, -2, "__index"); + + lua_pushcfunction(L, taglist_len); + lua_setfield(L, -2, "__len"); + + lua_pushcfunction(L, taglist_equal); + lua_setfield(L, -2, "__eq"); + lua_pushvalue(L, -1); + lua_setfield(L, LUA_REGISTRYINDEX, META_LINETAGLIST); + lua_setfield(L, LUA_REGISTRYINDEX, META_SECTORTAGLIST); + return 0; } From 828d7e71ce62d1dae4ddcd7fe9319229005eac75 Mon Sep 17 00:00:00 2001 From: James R Date: Sat, 5 Dec 2020 00:36:54 -0800 Subject: [PATCH 0409/1080] Fix uninitialized last element when using Taggroup_Remove --- src/taglist.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/taglist.c b/src/taglist.c index 658605734..7dbad65c4 100644 --- a/src/taglist.c +++ b/src/taglist.c @@ -188,7 +188,7 @@ void Taggroup_Remove (taggroup_t *garray[], const mtag_t tag, size_t id) { taggroup_t *group; size_t rempos; - size_t newcount; + size_t oldcount; if (tag == MTAG_GLOBAL) return; @@ -204,7 +204,7 @@ void Taggroup_Remove (taggroup_t *garray[], const mtag_t tag, size_t id) unset_bit_array(tags_available, tag); // Strip away taggroup if no elements left. - if (!(newcount = --group->count)) + if (!(oldcount = group->count--)) { Z_Free(group->elements); Z_Free(group); @@ -212,19 +212,18 @@ void Taggroup_Remove (taggroup_t *garray[], const mtag_t tag, size_t id) } else { - size_t *newelements = Z_Malloc(newcount * sizeof(size_t), PU_LEVEL, NULL); + size_t *newelements = Z_Malloc(group->count * sizeof(size_t), PU_LEVEL, NULL); size_t i; // Copy the previous entries save for the one to remove. for (i = 0; i < rempos; i++) newelements[i] = group->elements[i]; - for (i = rempos + 1; i < group->count; i++) + for (i = rempos + 1; i < oldcount; i++) newelements[i - 1] = group->elements[i]; Z_Free(group->elements); group->elements = newelements; - group->count = newcount; } } From ae663e724774007e0242fc509c87402a3ff7b7c4 Mon Sep 17 00:00:00 2001 From: James R Date: Sat, 5 Dec 2020 00:46:51 -0800 Subject: [PATCH 0410/1080] Don't realloc twice when adding to the taggroup --- src/taglist.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/taglist.c b/src/taglist.c index 7dbad65c4..cfd9cbb9c 100644 --- a/src/taglist.c +++ b/src/taglist.c @@ -170,16 +170,15 @@ void Taggroup_Add (taggroup_t *garray[], const mtag_t tag, size_t id) for (i = 0; i < group->count; i++) if (group->elements[i] > id) break; - - group->elements = Z_Realloc(group->elements, (group->count + 1) * sizeof(size_t), PU_LEVEL, NULL); - - // Offset existing elements to make room for the new one. - if (i < group->count) - memmove(&group->elements[i + 1], &group->elements[i], group->count - i); } + group->elements = Z_Realloc(group->elements, (group->count + 1) * sizeof(size_t), PU_LEVEL, NULL); + + // Offset existing elements to make room for the new one. + if (i < group->count) + memmove(&group->elements[i + 1], &group->elements[i], group->count - i); + group->count++; - group->elements = Z_Realloc(group->elements, group->count * sizeof(size_t), PU_LEVEL, NULL); group->elements[i] = id; } From e5a3e6a845e105566dd6def263cd2d7326155d42 Mon Sep 17 00:00:00 2001 From: James R Date: Sat, 5 Dec 2020 01:14:52 -0800 Subject: [PATCH 0411/1080] Fix removing a tag unsetting the bit array even if more elements with that tag exist --- src/lua_taglib.c | 2 +- src/taglist.c | 28 +++++++++++++++++++++++----- src/taglist.h | 1 + 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/src/lua_taglib.c b/src/lua_taglib.c index 73f033312..07646af87 100644 --- a/src/lua_taglib.c +++ b/src/lua_taglib.c @@ -145,7 +145,7 @@ static int lib_numTaggroupElements(lua_State *L) else { const taggroup_t ** garray = lua_touserdata(L, up_garray); - lua_pushnumber(L, garray[tag] ? garray[tag]->count : 0); + lua_pushnumber(L, Taggroup_Count(garray[tag])); } return 1; } diff --git a/src/taglist.c b/src/taglist.c index cfd9cbb9c..a759f4d02 100644 --- a/src/taglist.c +++ b/src/taglist.c @@ -110,6 +110,12 @@ size_t Taggroup_Find (const taggroup_t *group, const size_t id) return -1; } +/// group->count, but also checks for NULL +size_t Taggroup_Count (const taggroup_t *group) +{ + return group ? group->count : 0; +} + /// Iterate thru elements in a global taggroup. INT32 Taggroup_Iterate ( taggroup_t *garray[], @@ -153,9 +159,10 @@ void Taggroup_Add (taggroup_t *garray[], const mtag_t tag, size_t id) return; if (! in_bit_array(tags_available, tag)) + { num_tags++; - - set_bit_array(tags_available, tag); + set_bit_array(tags_available, tag); + } // Create group if empty. if (!group) @@ -182,6 +189,16 @@ void Taggroup_Add (taggroup_t *garray[], const mtag_t tag, size_t id) group->elements[i] = id; } +static size_t total_elements_with_tag (const mtag_t tag) +{ + return + ( + Taggroup_Count(tags_sectors[tag]) + + Taggroup_Count(tags_lines[tag]) + + Taggroup_Count(tags_mapthings[tag]) + ); +} + /// Remove an element from a global taggroup. void Taggroup_Remove (taggroup_t *garray[], const mtag_t tag, size_t id) { @@ -197,10 +214,11 @@ void Taggroup_Remove (taggroup_t *garray[], const mtag_t tag, size_t id) if ((rempos = Taggroup_Find(group, id)) == (size_t)-1) return; - if (in_bit_array(tags_available, tag)) + if (group->count == 1 && total_elements_with_tag(tag) == 1) + { num_tags--; - - unset_bit_array(tags_available, tag); + unset_bit_array(tags_available, tag); + } // Strip away taggroup if no elements left. if (!(oldcount = group->count--)) diff --git a/src/taglist.h b/src/taglist.h index e5db08806..a0529ab6b 100644 --- a/src/taglist.h +++ b/src/taglist.h @@ -54,6 +54,7 @@ extern taggroup_t* tags_mapthings[]; void Taggroup_Add (taggroup_t *garray[], const mtag_t tag, size_t id); void Taggroup_Remove (taggroup_t *garray[], const mtag_t tag, size_t id); size_t Taggroup_Find (const taggroup_t *group, const size_t id); +size_t Taggroup_Count (const taggroup_t *group); INT32 Taggroup_Iterate ( taggroup_t *garray[], From 8dd964e3a726a30ad50e7cfc3a5d0356351f24bf Mon Sep 17 00:00:00 2001 From: James R Date: Sat, 5 Dec 2020 02:02:06 -0800 Subject: [PATCH 0412/1080] Lua: taglist.add and taglist.remove for sector tag lists --- src/lua_baselib.c | 6 ++- src/lua_libs.h | 10 +++-- src/lua_maplib.c | 2 +- src/lua_mobjlib.c | 2 +- src/lua_taglib.c | 110 +++++++++++++++++++++++++++++++++++++++------- 5 files changed, 108 insertions(+), 22 deletions(-) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 1324322a2..59c1d411b 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -155,6 +155,8 @@ static const struct { {META_PIVOTLIST, "spriteframepivot_t[]"}, {META_FRAMEPIVOT, "spriteframepivot_t"}, + {META_TAGLIST, "taglist"}, + {META_MOBJ, "mobj_t"}, {META_MAPTHING, "mapthing_t"}, @@ -184,15 +186,15 @@ static const struct { {META_CVAR, "consvar_t"}, {META_SECTORLINES, "sector_t.lines"}, +#ifdef MUTABLE_TAGS {META_SECTORTAGLIST, "sector_t.taglist"}, +#endif {META_SIDENUM, "line_t.sidenum"}, {META_LINEARGS, "line_t.args"}, {META_LINESTRINGARGS, "line_t.stringargs"}, - {META_LINETAGLIST, "line_t.taglist"}, {META_THINGARGS, "mapthing.args"}, {META_THINGSTRINGARGS, "mapthing.stringargs"}, - {META_THINGTAGLIST, "mapthing_t.taglist"}, #ifdef HAVE_LUA_SEGS {META_NODEBBOX, "node_t.bbox"}, {META_NODECHILDREN, "node_t.children"}, diff --git a/src/lua_libs.h b/src/lua_libs.h index 991fae3fd..e7f4ae253 100644 --- a/src/lua_libs.h +++ b/src/lua_libs.h @@ -12,6 +12,8 @@ extern lua_State *gL; +#define MUTABLE_TAGS + #define LREG_VALID "VALID_USERDATA" #define LREG_EXTVARS "LUA_VARS" #define LREG_STATEACTION "STATE_ACTION" @@ -27,6 +29,8 @@ extern lua_State *gL; #define META_PIVOTLIST "SPRITEFRAMEPIVOT_T[]" #define META_FRAMEPIVOT "SPRITEFRAMEPIVOT_T*" +#define META_TAGLIST "TAGLIST" + #define META_MOBJ "MOBJ_T*" #define META_MAPTHING "MAPTHING_T*" @@ -56,14 +60,14 @@ extern lua_State *gL; #define META_CVAR "CONSVAR_T*" #define META_SECTORLINES "SECTOR_T*LINES" -#define META_SECTORTAGLIST "SECTOR_T*TAGLIST" +#ifdef MUTABLE_TAGS +#define META_SECTORTAGLIST "sector_t.taglist" +#endif #define META_SIDENUM "LINE_T*SIDENUM" #define META_LINEARGS "LINE_T*ARGS" #define META_LINESTRINGARGS "LINE_T*STRINGARGS" -#define META_LINETAGLIST "LINE_T*TAGLIST" #define META_THINGARGS "MAPTHING_T*ARGS" #define META_THINGSTRINGARGS "MAPTHING_T*STRINGARGS" -#define META_THINGTAGLIST "THING_T*TAGLIST" #define META_POLYOBJVERTICES "POLYOBJ_T*VERTICES" #define META_POLYOBJLINES "POLYOBJ_T*LINES" #ifdef HAVE_LUA_SEGS diff --git a/src/lua_maplib.c b/src/lua_maplib.c index 25edf83d8..3520cdbda 100644 --- a/src/lua_maplib.c +++ b/src/lua_maplib.c @@ -831,7 +831,7 @@ static int line_get(lua_State *L) lua_pushinteger(L, Tag_FGet(&line->tags)); return 1; case line_taglist: - LUA_PushUserdata(L, &line->tags, META_LINETAGLIST); + LUA_PushUserdata(L, &line->tags, META_TAGLIST); return 1; case line_args: LUA_PushUserdata(L, line->args, META_LINEARGS); diff --git a/src/lua_mobjlib.c b/src/lua_mobjlib.c index 8d205780d..65adceb15 100644 --- a/src/lua_mobjlib.c +++ b/src/lua_mobjlib.c @@ -904,7 +904,7 @@ static int mapthing_get(lua_State *L) number = Tag_FGet(&mt->tags); else if(fastcmp(field,"taglist")) { - LUA_PushUserdata(L, &mt->tags, META_THINGTAGLIST); + LUA_PushUserdata(L, &mt->tags, META_TAGLIST); return 1; } else if(fastcmp(field,"args")) diff --git a/src/lua_taglib.c b/src/lua_taglib.c index 07646af87..7994b6625 100644 --- a/src/lua_taglib.c +++ b/src/lua_taglib.c @@ -17,6 +17,10 @@ #include "lua_script.h" #include "lua_libs.h" +#ifdef MUTABLE_TAGS +#include "z_zone.h" +#endif + static int tag_iterator(lua_State *L) { INT32 tag = lua_isnil(L, 2) ? -1 : lua_tonumber(L, 2); @@ -281,6 +285,63 @@ static int taglist_shares(lua_State *L) return 1; } +/* only sector tags are mutable... */ + +#ifdef MUTABLE_TAGS +static size_t sector_of_taglist(taglist_t *list) +{ + return (sector_t *)((char *)list - offsetof (sector_t, tags)) - sectors; +} + +static int this_taglist(lua_State *L) +{ + lua_settop(L, 1); + return 1; +} + +static int taglist_add(lua_State *L) +{ + taglist_t *list = *(taglist_t **)luaL_checkudata(L, 1, META_SECTORTAGLIST); + const mtag_t tag = luaL_checknumber(L, 2); + + if (! Tag_Find(list, tag)) + { + Taggroup_Add(tags_sectors, tag, sector_of_taglist(list)); + Tag_Add(list, tag); + } + + return this_taglist(L); +} + +static int taglist_remove(lua_State *L) +{ + taglist_t *list = *(taglist_t **)luaL_checkudata(L, 1, META_SECTORTAGLIST); + const mtag_t tag = luaL_checknumber(L, 2); + + size_t i; + + for (i = 0; i < list->count; ++i) + { + if (list->tags[i] == tag) + { + if (list->count > 1) + { + memmove(&list->tags[i], &list->tags[i + 1], + (list->count - 1 - i) * sizeof (mtag_t)); + list->tags = Z_Realloc(list->tags, + (--list->count) * sizeof (mtag_t), PU_LEVEL, NULL); + Taggroup_Remove(tags_sectors, tag, sector_of_taglist(list)); + } + else/* reset to default tag */ + Tag_SectorFSet(sector_of_taglist(list), 0); + break; + } + } + + return this_taglist(L); +} +#endif/*MUTABLE_TAGS*/ + void LUA_InsertTaggroupIterator ( lua_State *L, taggroup_t *garray[], @@ -314,9 +375,38 @@ static luaL_Reg taglist_lib[] = { {"iterate", taglist_iterate}, {"find", taglist_find}, {"shares", taglist_shares}, +#ifdef MUTABLE_TAGS + {"add", taglist_add}, + {"remove", taglist_remove}, +#endif {0} }; +static void open_taglist(lua_State *L) +{ + luaL_register(L, "taglist", taglist_lib); + + lua_getfield(L, -1, "find"); + lua_setfield(L, -2, "has"); +} + +static void set_taglist_metatable(lua_State *L, const char *meta) +{ + lua_createtable(L, 0, 4); + lua_getglobal(L, "taglist"); + lua_setfield(L, -2, "taglist"); + + lua_pushcfunction(L, taglist_get); + lua_setfield(L, -2, "__index"); + + lua_pushcfunction(L, taglist_len); + lua_setfield(L, -2, "__len"); + + lua_pushcfunction(L, taglist_equal); + lua_setfield(L, -2, "__eq"); + lua_setfield(L, LUA_REGISTRYINDEX, meta); +} + int LUA_TagLib(lua_State *L) { lua_newuserdata(L, 0); @@ -331,23 +421,13 @@ int LUA_TagLib(lua_State *L) lua_setmetatable(L, -2); lua_setglobal(L, "tags"); - luaL_newmetatable(L, META_THINGTAGLIST); - luaL_register(L, "taglist", taglist_lib); - lua_getfield(L, -1, "find"); - lua_setfield(L, -2, "has"); - lua_setfield(L, -2, "taglist"); + open_taglist(L); - lua_pushcfunction(L, taglist_get); - lua_setfield(L, -2, "__index"); + set_taglist_metatable(L, META_TAGLIST); - lua_pushcfunction(L, taglist_len); - lua_setfield(L, -2, "__len"); - - lua_pushcfunction(L, taglist_equal); - lua_setfield(L, -2, "__eq"); - lua_pushvalue(L, -1); - lua_setfield(L, LUA_REGISTRYINDEX, META_LINETAGLIST); - lua_setfield(L, LUA_REGISTRYINDEX, META_SECTORTAGLIST); +#ifdef MUTABLE_TAGS + set_taglist_metatable(L, META_SECTORTAGLIST); +#endif return 0; } From 5d1040c92441a2634410caf2da673eea335e92be Mon Sep 17 00:00:00 2001 From: James R Date: Sat, 5 Dec 2020 02:08:00 -0800 Subject: [PATCH 0413/1080] Reset taggroup iterator on successive calls --- src/lua_taglib.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/lua_taglib.c b/src/lua_taglib.c index 7994b6625..cfaf84872 100644 --- a/src/lua_taglib.c +++ b/src/lua_taglib.c @@ -75,6 +75,8 @@ struct element_iterator_state { static int element_iterator(lua_State *L) { struct element_iterator_state * state = lua_touserdata(L, 1); + if (lua_isnoneornil(L, 3)) + state->p = 0; lua_pushnumber(L, ++state->p); lua_gettable(L, 1); return 1; From 0b0f2e1e35aa822566986bcd6dc1526f3828f25e Mon Sep 17 00:00:00 2001 From: James R Date: Sat, 5 Dec 2020 02:26:00 -0800 Subject: [PATCH 0414/1080] Invalidate taglist userdata --- src/lua_script.c | 5 +++++ src/lua_taglib.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/lua_script.c b/src/lua_script.c index ee60a41c6..bc88928f3 100644 --- a/src/lua_script.c +++ b/src/lua_script.c @@ -846,6 +846,7 @@ void LUA_InvalidateLevel(void) { LUA_InvalidateUserdata(§ors[i]); LUA_InvalidateUserdata(§ors[i].lines); + LUA_InvalidateUserdata(§ors[i].tags); if (sectors[i].ffloors) { for (rover = sectors[i].ffloors; rover; rover = rover->next) @@ -855,6 +856,7 @@ void LUA_InvalidateLevel(void) for (i = 0; i < numlines; i++) { LUA_InvalidateUserdata(&lines[i]); + LUA_InvalidateUserdata(&lines[i].tags); LUA_InvalidateUserdata(lines[i].sidenum); } for (i = 0; i < numsides; i++) @@ -886,7 +888,10 @@ void LUA_InvalidateMapthings(void) return; for (i = 0; i < nummapthings; i++) + { LUA_InvalidateUserdata(&mapthings[i]); + LUA_InvalidateUserdata(&mapthings[i].tags); + } } void LUA_InvalidatePlayer(player_t *player) diff --git a/src/lua_taglib.c b/src/lua_taglib.c index cfaf84872..284b171a3 100644 --- a/src/lua_taglib.c +++ b/src/lua_taglib.c @@ -182,7 +182,7 @@ static taglist_t * valid_taglist(lua_State *L, int idx, boolean getting) if (getting && has_valid_field(L)) lua_pushboolean(L, 0); else - LUA_ErrInvalid(L, "taglist_t");/* doesn't actually return */ + LUA_ErrInvalid(L, "taglist");/* doesn't actually return */ return NULL; } else From f6af04ecbb45b34488c5c2160b44f6dcda1770cb Mon Sep 17 00:00:00 2001 From: GoldenTails Date: Sat, 5 Dec 2020 05:00:59 -0600 Subject: [PATCH 0415/1080] Fix weird spelling mistake --- src/deh_tables.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/deh_tables.c b/src/deh_tables.c index 3240aee14..ff596deea 100644 --- a/src/deh_tables.c +++ b/src/deh_tables.c @@ -4886,7 +4886,7 @@ struct int_const_s const INT_CONST[] = { {"RF_VERTICALFLIP",RF_VERTICALFLIP}, {"RF_ABSOLUTEOFFSETS",RF_ABSOLUTEOFFSETS}, {"RF_FLIPOFFSETS",RF_FLIPOFFSETS}, - {"RF_SPLATMASK",RF_SLOPESPLAT}, + {"RF_SPLATMASK",RF_SPLATMASK}, {"RF_SLOPESPLAT",RF_SLOPESPLAT}, {"RF_OBJECTSLOPESPLAT",RF_OBJECTSLOPESPLAT}, {"RF_NOSPLATBILLBOARD",RF_NOSPLATBILLBOARD}, From 854140932940517a5800b9c93939081f189f2b08 Mon Sep 17 00:00:00 2001 From: katsy Date: Sat, 5 Dec 2020 23:13:47 -0500 Subject: [PATCH 0416/1080] add noclipheight on chaingrab --- src/p_inter.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/p_inter.c b/src/p_inter.c index 415c679e4..189cbcea7 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -1641,6 +1641,9 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) // Can't jump first frame player->pflags |= PF_JUMPSTASIS; + // Disable interaction with ground + player->mo->flags |= MF_NOCLIPHEIGHT; + return; } case MT_EGGMOBILE2_POGO: From 3dbb44e7b1afa8d42cf9b83ffcdc02525871f1af Mon Sep 17 00:00:00 2001 From: katsy Date: Sat, 5 Dec 2020 23:17:01 -0500 Subject: [PATCH 0417/1080] ensure the new flag is cleared properly --- src/p_user.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/p_user.c b/src/p_user.c index c5f919c78..65397c287 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -1085,6 +1085,9 @@ void P_ResetPlayer(player_t *player) player->powers[pw_carry] = CR_NONE; } + if (player->powers[pw_carry] == CR_MACESPIN || player->powers[pw_carry] == CR_GENERIC) + player->mo->flags &= ~MF_NOCLIPHEIGHT; + if (!(player->powers[pw_carry] == CR_NIGHTSMODE || player->powers[pw_carry] == CR_NIGHTSFALL || player->powers[pw_carry] == CR_BRAKGOOP || player->powers[pw_carry] == CR_MINECART)) player->powers[pw_carry] = CR_NONE; @@ -4426,6 +4429,8 @@ void P_DoJump(player_t *player, boolean soundandstate) if (!(player->mo->tracer->flags & MF_MISSILE)) // Missiles remember their owner! P_SetTarget(&player->mo->tracer->target, NULL); P_SetTarget(&player->mo->tracer, NULL); + player->mo->flags &= ~MF_NOCLIPHEIGHT; + } else if (player->powers[pw_carry] == CR_ROPEHANG) { @@ -5257,6 +5262,7 @@ static void P_DoJumpStuff(player_t *player, ticcmd_t *cmd) player->powers[pw_carry] = CR_NONE; P_SetTarget(&player->mo->tracer, NULL); player->powers[pw_flashing] = TICRATE/4; + player->mo->flags &= ~MF_NOCLIPHEIGHT; } // can't jump while in air, can't jump while jumping else if (onground || player->climbing || player->powers[pw_carry]) From a7fa2b2e490268da0d75c82e91e825c21bf521a9 Mon Sep 17 00:00:00 2001 From: katsy Date: Sun, 6 Dec 2020 00:09:40 -0500 Subject: [PATCH 0418/1080] Replace p_mobj.c From 768ee5705743d8f42a4b72cac52da7dc910e1ecb Mon Sep 17 00:00:00 2001 From: katsy Date: Sun, 6 Dec 2020 00:10:28 -0500 Subject: [PATCH 0419/1080] Replace p_user.c --- src/p_user.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index 65397c287..c5f919c78 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -1085,9 +1085,6 @@ void P_ResetPlayer(player_t *player) player->powers[pw_carry] = CR_NONE; } - if (player->powers[pw_carry] == CR_MACESPIN || player->powers[pw_carry] == CR_GENERIC) - player->mo->flags &= ~MF_NOCLIPHEIGHT; - if (!(player->powers[pw_carry] == CR_NIGHTSMODE || player->powers[pw_carry] == CR_NIGHTSFALL || player->powers[pw_carry] == CR_BRAKGOOP || player->powers[pw_carry] == CR_MINECART)) player->powers[pw_carry] = CR_NONE; @@ -4429,8 +4426,6 @@ void P_DoJump(player_t *player, boolean soundandstate) if (!(player->mo->tracer->flags & MF_MISSILE)) // Missiles remember their owner! P_SetTarget(&player->mo->tracer->target, NULL); P_SetTarget(&player->mo->tracer, NULL); - player->mo->flags &= ~MF_NOCLIPHEIGHT; - } else if (player->powers[pw_carry] == CR_ROPEHANG) { @@ -5262,7 +5257,6 @@ static void P_DoJumpStuff(player_t *player, ticcmd_t *cmd) player->powers[pw_carry] = CR_NONE; P_SetTarget(&player->mo->tracer, NULL); player->powers[pw_flashing] = TICRATE/4; - player->mo->flags &= ~MF_NOCLIPHEIGHT; } // can't jump while in air, can't jump while jumping else if (onground || player->climbing || player->powers[pw_carry]) From fd4674971a3a2ca7dac8203d801420aa76b06dec Mon Sep 17 00:00:00 2001 From: katsy Date: Sun, 6 Dec 2020 00:10:45 -0500 Subject: [PATCH 0420/1080] Replace p_inter.c --- src/p_inter.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/p_inter.c b/src/p_inter.c index 189cbcea7..415c679e4 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -1641,9 +1641,6 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) // Can't jump first frame player->pflags |= PF_JUMPSTASIS; - // Disable interaction with ground - player->mo->flags |= MF_NOCLIPHEIGHT; - return; } case MT_EGGMOBILE2_POGO: From 2fcf613a3114803c90e3a7db51035265b5ab066b Mon Sep 17 00:00:00 2001 From: katsy Date: Sun, 6 Dec 2020 00:13:10 -0500 Subject: [PATCH 0421/1080] brak barrier is scaled up by 2x in gameplay, the actual object's parameters should be halved --- src/info.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/info.c b/src/info.c index 29a79b1d6..d2f53c55c 100644 --- a/src/info.c +++ b/src/info.c @@ -6458,8 +6458,8 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = S_NULL, // xdeathstate sfx_fizzle, // deathsound 10*FRACUNIT, // speed - 48*FRACUNIT, // radius - 160*FRACUNIT, // height + 24*FRACUNIT, // radius + 80*FRACUNIT, // height 0, // display offset DMG_ELECTRIC, // mass 1, // damage From ffd20ee7538609d2e8dbc841ff43ab3685badabe Mon Sep 17 00:00:00 2001 From: katsy Date: Sun, 6 Dec 2020 07:44:49 +0000 Subject: [PATCH 0422/1080] Revert "ensure the new flag is cleared properly" This reverts commit 3dbb44e7b1afa8d42cf9b83ffcdc02525871f1af --- src/p_user.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index 65397c287..c5f919c78 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -1085,9 +1085,6 @@ void P_ResetPlayer(player_t *player) player->powers[pw_carry] = CR_NONE; } - if (player->powers[pw_carry] == CR_MACESPIN || player->powers[pw_carry] == CR_GENERIC) - player->mo->flags &= ~MF_NOCLIPHEIGHT; - if (!(player->powers[pw_carry] == CR_NIGHTSMODE || player->powers[pw_carry] == CR_NIGHTSFALL || player->powers[pw_carry] == CR_BRAKGOOP || player->powers[pw_carry] == CR_MINECART)) player->powers[pw_carry] = CR_NONE; @@ -4429,8 +4426,6 @@ void P_DoJump(player_t *player, boolean soundandstate) if (!(player->mo->tracer->flags & MF_MISSILE)) // Missiles remember their owner! P_SetTarget(&player->mo->tracer->target, NULL); P_SetTarget(&player->mo->tracer, NULL); - player->mo->flags &= ~MF_NOCLIPHEIGHT; - } else if (player->powers[pw_carry] == CR_ROPEHANG) { @@ -5262,7 +5257,6 @@ static void P_DoJumpStuff(player_t *player, ticcmd_t *cmd) player->powers[pw_carry] = CR_NONE; P_SetTarget(&player->mo->tracer, NULL); player->powers[pw_flashing] = TICRATE/4; - player->mo->flags &= ~MF_NOCLIPHEIGHT; } // can't jump while in air, can't jump while jumping else if (onground || player->climbing || player->powers[pw_carry]) From 5853a0b4d837fbb83c092c2a91ef4566ab906e64 Mon Sep 17 00:00:00 2001 From: katsy Date: Sun, 6 Dec 2020 07:44:59 +0000 Subject: [PATCH 0423/1080] Revert "add noclipheight on chaingrab" This reverts commit 854140932940517a5800b9c93939081f189f2b08 --- src/p_inter.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/p_inter.c b/src/p_inter.c index 189cbcea7..415c679e4 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -1641,9 +1641,6 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) // Can't jump first frame player->pflags |= PF_JUMPSTASIS; - // Disable interaction with ground - player->mo->flags |= MF_NOCLIPHEIGHT; - return; } case MT_EGGMOBILE2_POGO: From 8f4d23197c299d59778eede6a8c8424058f851d6 Mon Sep 17 00:00:00 2001 From: katsy Date: Sun, 6 Dec 2020 04:32:30 -0500 Subject: [PATCH 0424/1080] space --- src/info.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/info.c b/src/info.c index d2f53c55c..56e764b5d 100644 --- a/src/info.c +++ b/src/info.c @@ -6459,7 +6459,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = sfx_fizzle, // deathsound 10*FRACUNIT, // speed 24*FRACUNIT, // radius - 80*FRACUNIT, // height + 80*FRACUNIT, // height 0, // display offset DMG_ELECTRIC, // mass 1, // damage From 233990099db1380560bfa64bb89c95340ed01124 Mon Sep 17 00:00:00 2001 From: GoldenTails Date: Sun, 6 Dec 2020 04:28:12 -0600 Subject: [PATCH 0425/1080] Make caret coloring support letters. --- src/dehacked.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/dehacked.c b/src/dehacked.c index e98ff71cf..b42663267 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -59,6 +59,12 @@ ATTRINLINE static FUNCINLINE char myfget_color(MYFILE *f) if (c >= '0' && c <= '9') return 0x80+(c-'0'); + + c = tolower(c); + + if (c >= 'a' && c <= 'f') + return 0x80+10+(c-'a'); + return 0x80; // Unhandled -- default to no color } From 3b85abdee7e557818486ef06f6714cb374360c11 Mon Sep 17 00:00:00 2001 From: Tatsuru <44866610+Ikkarin@users.noreply.github.com> Date: Sun, 6 Dec 2020 14:11:08 -0300 Subject: [PATCH 0426/1080] Kill saloon doors without a tracer, add height check for non-blocking doors --- src/p_map.c | 6 ++++-- src/p_mobj.c | 6 ++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/p_map.c b/src/p_map.c index 922c0d9ec..24311c35a 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -982,7 +982,8 @@ static boolean PIT_CheckThing(mobj_t *thing) if (thing->type == MT_SALOONDOOR && tmthing->player) { mobj_t *ref = (tmthing->player->powers[pw_carry] == CR_MINECART && tmthing->tracer && !P_MobjWasRemoved(tmthing->tracer)) ? tmthing->tracer : tmthing; - if ((thing->flags2 & MF2_AMBUSH) || ref != tmthing) + if (((thing->flags2 & MF2_AMBUSH) && (tmthing->z <= thing->z + thing->height) && (tmthing->z + tmthing->height >= thing->z)) + || ref != tmthing) { fixed_t dm = min(FixedHypot(ref->momx, ref->momy), 16*FRACUNIT); angle_t ang = R_PointToAngle2(0, 0, ref->momx, ref->momy) - thing->angle; @@ -995,7 +996,8 @@ static boolean PIT_CheckThing(mobj_t *thing) if (thing->type == MT_SALOONDOORCENTER && tmthing->player) { - if ((thing->flags2 & MF2_AMBUSH) || (tmthing->player->powers[pw_carry] == CR_MINECART && tmthing->tracer && !P_MobjWasRemoved(tmthing->tracer))) + if (((thing->flags2 & MF2_AMBUSH) && (tmthing->z <= thing->z + thing->height) && (tmthing->z + tmthing->height >= thing->z)) + || (tmthing->player->powers[pw_carry] == CR_MINECART && tmthing->tracer && !P_MobjWasRemoved(tmthing->tracer))) return true; } diff --git a/src/p_mobj.c b/src/p_mobj.c index 7ba6d1fad..65113a840 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -9651,6 +9651,12 @@ static boolean P_MobjRegularThink(mobj_t *mobj) break; } case MT_SALOONDOOR: + if (!mobj->tracer) // Door center is gone or not spawned? + { + P_RemoveMobj(mobj); // Die + return false; + } + P_SaloonDoorThink(mobj); break; case MT_MINECARTSPAWNER: From 6546fc8ce775298d7818061166434992c598be38 Mon Sep 17 00:00:00 2001 From: GoldenTails Date: Sun, 6 Dec 2020 12:01:31 -0600 Subject: [PATCH 0427/1080] Fix HWR_DrawCroppedPatch scaling a patch when cropping the top and left sides. --- src/hardware/hw_draw.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hardware/hw_draw.c b/src/hardware/hw_draw.c index b9cb288e9..c5d362520 100644 --- a/src/hardware/hw_draw.c +++ b/src/hardware/hw_draw.c @@ -506,13 +506,13 @@ void HWR_DrawCroppedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale, v[0].s = v[3].s = ((sx)/(float)(gpatch->width))*hwrPatch->max_s; if (sx + w > gpatch->width) - v[2].s = v[1].s = hwrPatch->max_s; + v[2].s = v[1].s = hwrPatch->max_s - ((sx+w)/(float)(gpatch->width))*hwrPatch->max_s; else v[2].s = v[1].s = ((sx+w)/(float)(gpatch->width))*hwrPatch->max_s; v[0].t = v[1].t = ((sy)/(float)(gpatch->height))*hwrPatch->max_t; if (sy + h > gpatch->height) - v[2].t = v[3].t = hwrPatch->max_t; + v[2].t = v[3].t = hwrPatch->max_t - ((sy+h)/(float)(gpatch->height))*hwrPatch->max_t; else v[2].t = v[3].t = ((sy+h)/(float)(gpatch->height))*hwrPatch->max_t; From 24ba78214421ff6fe4aafc5480a9d5e6e66c49db Mon Sep 17 00:00:00 2001 From: Jaime Ita Passos Date: Sun, 6 Dec 2020 17:29:20 -0300 Subject: [PATCH 0428/1080] Fix archived mobjs having no default blend mode and sprite scales --- src/p_saveg.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index adedea049..03229e740 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -1506,7 +1506,7 @@ static void SaveMobjThinker(const thinker_t *th, const UINT8 type) { const mobj_t *mobj = (const mobj_t *)th; UINT32 diff; - UINT16 diff2; + UINT32 diff2; // Ignore stationary hoops - these will be respawned from mapthings. if (mobj->type == MT_HOOP) @@ -1638,7 +1638,7 @@ static void SaveMobjThinker(const thinker_t *th, const UINT8 type) diff2 |= MD2_SHADOWSCALE; if (mobj->renderflags) diff2 |= MD2_RENDERFLAGS; - if (mobj->renderflags) + if (mobj->blendmode != AST_TRANSLUCENT) diff2 |= MD2_BLENDMODE; if (mobj->spritexscale != FRACUNIT) diff2 |= MD2_SPRITEXSCALE; @@ -1646,6 +1646,8 @@ static void SaveMobjThinker(const thinker_t *th, const UINT8 type) diff2 |= MD2_SPRITEYSCALE; if (mobj->spritexoffset) diff2 |= MD2_SPRITEXOFFSET; + if (mobj->spriteyoffset) + diff2 |= MD2_SPRITEYOFFSET; if (mobj->floorspriteslope) { pslope_t *slope = mobj->floorspriteslope; @@ -1667,7 +1669,7 @@ static void SaveMobjThinker(const thinker_t *th, const UINT8 type) WRITEUINT8(save_p, type); WRITEUINT32(save_p, diff); if (diff & MD_MORE) - WRITEUINT16(save_p, diff2); + WRITEUINT32(save_p, diff2); // save pointer, at load time we will search this pointer to reinitilize pointers WRITEUINT32(save_p, (size_t)mobj); @@ -2615,14 +2617,14 @@ static thinker_t* LoadMobjThinker(actionf_p1 thinker) thinker_t *next; mobj_t *mobj; UINT32 diff; - UINT16 diff2; + UINT32 diff2; INT32 i; fixed_t z, floorz, ceilingz; ffloor_t *floorrover = NULL, *ceilingrover = NULL; diff = READUINT32(save_p); if (diff & MD_MORE) - diff2 = READUINT16(save_p); + diff2 = READUINT32(save_p); else diff2 = 0; @@ -2843,10 +2845,16 @@ static thinker_t* LoadMobjThinker(actionf_p1 thinker) mobj->renderflags = READUINT32(save_p); if (diff2 & MD2_BLENDMODE) mobj->blendmode = READINT32(save_p); + else + mobj->blendmode = AST_TRANSLUCENT; if (diff2 & MD2_SPRITEXSCALE) mobj->spritexscale = READFIXED(save_p); + else + mobj->spritexscale = FRACUNIT; if (diff2 & MD2_SPRITEYSCALE) mobj->spriteyscale = READFIXED(save_p); + else + mobj->spriteyscale = FRACUNIT; if (diff2 & MD2_SPRITEXOFFSET) mobj->spritexoffset = READFIXED(save_p); if (diff2 & MD2_SPRITEYOFFSET) From 6f9c48a30560b0f2d89f7202371dfc164015b9ba Mon Sep 17 00:00:00 2001 From: Jaime Ita Passos Date: Sun, 6 Dec 2020 17:46:35 -0300 Subject: [PATCH 0429/1080] Move a few mobj spawn defaults to its own function --- src/p_local.h | 1 + src/p_mobj.c | 76 ++++++++++++++++++++++++++++----------------------- src/p_saveg.c | 40 ++------------------------- 3 files changed, 46 insertions(+), 71 deletions(-) diff --git a/src/p_local.h b/src/p_local.h index 8a5084962..96401bb75 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -279,6 +279,7 @@ mobjtype_t P_GetMobjtype(UINT16 mthingtype); void P_RespawnSpecials(void); mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type); +void P_SetMobjSpawnDefaults(mobj_t *mobj); void P_RecalcPrecipInSector(sector_t *sector); void P_PrecipitationEffects(void); diff --git a/src/p_mobj.c b/src/p_mobj.c index 7ba6d1fad..e664d85be 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -10438,44 +10438,11 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type) mobj->x = x; mobj->y = y; - mobj->radius = info->radius; - mobj->height = info->height; - mobj->flags = info->flags; - - mobj->health = (info->spawnhealth ? info->spawnhealth : 1); - - mobj->reactiontime = info->reactiontime; - - mobj->lastlook = -1; // stuff moved in P_enemy.P_LookForPlayer - - // do not set the state with P_SetMobjState, - // because action routines can not be called yet - st = &states[info->spawnstate]; - - mobj->state = st; - mobj->tics = st->tics; - mobj->sprite = st->sprite; - mobj->frame = st->frame; // FF_FRAMEMASK for frame, and other bits.. - P_SetupStateAnimation(mobj, st); - - mobj->friction = ORIG_FRICTION; - - mobj->movefactor = FRACUNIT; - - // All mobjs are created at 100% scale. - mobj->scale = FRACUNIT; - mobj->destscale = mobj->scale; - mobj->scalespeed = FRACUNIT/12; - // TODO: Make this a special map header if ((maptol & TOL_ERZ3) && !(mobj->type == MT_BLACKEGGMAN)) mobj->destscale = FRACUNIT/2; - // Sprite rendering - mobj->blendmode = AST_TRANSLUCENT; - mobj->spritexscale = mobj->spriteyscale = mobj->scale; - mobj->spritexoffset = mobj->spriteyoffset = 0; - mobj->floorspriteslope = NULL; + P_SetMobjSpawnDefaults(mobj); // set subsector and/or block links P_SetThingPosition(mobj); @@ -10785,6 +10752,8 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type) mobj->frame &= ~FF_FRAMEMASK; } + st = &states[info->spawnstate]; + // Call action functions when the state is set if (st->action.acp1 && (mobj->flags & MF_RUNSPAWNFUNC)) { @@ -10815,6 +10784,45 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type) return mobj; } +void P_SetMobjSpawnDefaults(mobj_t *mobj) +{ + const mobjinfo_t *info = mobj->info; + state_t *st = &states[info->spawnstate]; + + mobj->radius = info->radius; + mobj->height = info->height; + mobj->flags = info->flags; + + mobj->health = (info->spawnhealth ? info->spawnhealth : 1); + + mobj->reactiontime = info->reactiontime; + + mobj->lastlook = -1; // stuff moved in P_enemy.P_LookForPlayer + + // do not set the state with P_SetMobjState, + // because action routines can not be called yet + mobj->state = st; + mobj->tics = st->tics; + mobj->sprite = st->sprite; + mobj->frame = st->frame; // FF_FRAMEMASK for frame, and other bits.. + P_SetupStateAnimation(mobj, st); + + mobj->friction = ORIG_FRICTION; + + mobj->movefactor = FRACUNIT; + + // All mobjs are created at 100% scale. + mobj->scale = FRACUNIT; + mobj->destscale = mobj->scale; + mobj->scalespeed = FRACUNIT/12; + + // Sprite rendering + mobj->blendmode = AST_TRANSLUCENT; + mobj->spritexscale = mobj->spriteyscale = mobj->scale; + mobj->spritexoffset = mobj->spriteyoffset = 0; + mobj->floorspriteslope = NULL; +} + static precipmobj_t *P_SpawnPrecipMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type) { state_t *st; diff --git a/src/p_saveg.c b/src/p_saveg.c index 03229e740..c1364e08f 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -2692,7 +2692,10 @@ static thinker_t* LoadMobjThinker(actionf_p1 thinker) } mobj->type = i; } + mobj->info = &mobjinfo[mobj->type]; + P_SetMobjSpawnDefaults(mobj); + if (diff & MD_POS) { mobj->x = READFIXED(save_p); @@ -2718,35 +2721,21 @@ static thinker_t* LoadMobjThinker(actionf_p1 thinker) if (diff & MD_RADIUS) mobj->radius = READFIXED(save_p); - else - mobj->radius = mobj->info->radius; if (diff & MD_HEIGHT) mobj->height = READFIXED(save_p); - else - mobj->height = mobj->info->height; if (diff & MD_FLAGS) mobj->flags = READUINT32(save_p); - else - mobj->flags = mobj->info->flags; if (diff & MD_FLAGS2) mobj->flags2 = READUINT32(save_p); if (diff & MD_HEALTH) mobj->health = READINT32(save_p); - else - mobj->health = mobj->info->spawnhealth; if (diff & MD_RTIME) mobj->reactiontime = READINT32(save_p); - else - mobj->reactiontime = mobj->info->reactiontime; if (diff & MD_STATE) mobj->state = &states[READUINT16(save_p)]; - else - mobj->state = &states[mobj->info->spawnstate]; if (diff & MD_TICS) mobj->tics = READINT32(save_p); - else - mobj->tics = mobj->state->tics; if (diff & MD_SPRITE) { mobj->sprite = READUINT16(save_p); if (mobj->sprite == SPR_PLAY) @@ -2762,11 +2751,6 @@ static thinker_t* LoadMobjThinker(actionf_p1 thinker) mobj->frame = READUINT32(save_p); mobj->anim_duration = READUINT16(save_p); } - else - { - mobj->frame = mobj->state->frame; - mobj->anim_duration = (UINT16)mobj->state->var2; - } if (diff & MD_EFLAGS) mobj->eflags = READUINT16(save_p); if (diff & MD_PLAYER) @@ -2783,20 +2767,14 @@ static thinker_t* LoadMobjThinker(actionf_p1 thinker) mobj->threshold = READINT32(save_p); if (diff & MD_LASTLOOK) mobj->lastlook = READINT32(save_p); - else - mobj->lastlook = -1; if (diff & MD_TARGET) mobj->target = (mobj_t *)(size_t)READUINT32(save_p); if (diff & MD_TRACER) mobj->tracer = (mobj_t *)(size_t)READUINT32(save_p); if (diff & MD_FRICTION) mobj->friction = READFIXED(save_p); - else - mobj->friction = ORIG_FRICTION; if (diff & MD_MOVEFACTOR) mobj->movefactor = READFIXED(save_p); - else - mobj->movefactor = FRACUNIT; if (diff & MD_FUSE) mobj->fuse = READINT32(save_p); if (diff & MD_WATERTOP) @@ -2805,16 +2783,10 @@ static thinker_t* LoadMobjThinker(actionf_p1 thinker) mobj->waterbottom = READFIXED(save_p); if (diff & MD_SCALE) mobj->scale = READFIXED(save_p); - else - mobj->scale = FRACUNIT; if (diff & MD_DSCALE) mobj->destscale = READFIXED(save_p); - else - mobj->destscale = mobj->scale; if (diff2 & MD2_SCALESPEED) mobj->scalespeed = READFIXED(save_p); - else - mobj->scalespeed = FRACUNIT/12; if (diff2 & MD2_CUSVAL) mobj->cusval = READINT32(save_p); if (diff2 & MD2_CVMEM) @@ -2845,16 +2817,10 @@ static thinker_t* LoadMobjThinker(actionf_p1 thinker) mobj->renderflags = READUINT32(save_p); if (diff2 & MD2_BLENDMODE) mobj->blendmode = READINT32(save_p); - else - mobj->blendmode = AST_TRANSLUCENT; if (diff2 & MD2_SPRITEXSCALE) mobj->spritexscale = READFIXED(save_p); - else - mobj->spritexscale = FRACUNIT; if (diff2 & MD2_SPRITEYSCALE) mobj->spriteyscale = READFIXED(save_p); - else - mobj->spriteyscale = FRACUNIT; if (diff2 & MD2_SPRITEXOFFSET) mobj->spritexoffset = READFIXED(save_p); if (diff2 & MD2_SPRITEYOFFSET) From 18ee97c583117e7d10e4914e473e47adbfaa13d4 Mon Sep 17 00:00:00 2001 From: Jaime Ita Passos Date: Sun, 6 Dec 2020 20:17:14 -0300 Subject: [PATCH 0430/1080] Fix animated skincolors in OpenGL --- src/hardware/hw_cache.c | 73 +++++++++++++++++++++++++++++++++-------- src/hardware/hw_data.h | 13 ++++++-- src/hardware/hw_main.c | 4 +-- src/hardware/hw_md2.c | 17 ++++++++-- src/m_menu.c | 11 ++----- src/z_zone.c | 12 +++---- 6 files changed, 95 insertions(+), 35 deletions(-) diff --git a/src/hardware/hw_cache.c b/src/hardware/hw_cache.c index b4fa7ec6c..43fdc89f0 100644 --- a/src/hardware/hw_cache.c +++ b/src/hardware/hw_cache.c @@ -108,7 +108,7 @@ static void HWR_DrawColumnInCache(const column_t *patchcol, UINT8 *block, GLMipm //Hurdler: 25/04/2000: now support colormap in hardware mode if (mipmap->colormap) - texel = mipmap->colormap[texel]; + texel = mipmap->colormap->data[texel]; // hope compiler will get this switch out of the loops (dreams...) // gcc do it ! but vcc not ! (why don't use cygwin gcc for win32 ?) @@ -218,7 +218,7 @@ static void HWR_DrawFlippedColumnInCache(const column_t *patchcol, UINT8 *block, //Hurdler: 25/04/2000: now support colormap in hardware mode if (mipmap->colormap) - texel = mipmap->colormap[texel]; + texel = mipmap->colormap->data[texel]; // hope compiler will get this switch out of the loops (dreams...) // gcc do it ! but vcc not ! (why don't use cygwin gcc for win32 ?) @@ -659,7 +659,10 @@ void HWR_FreeTextureColormaps(patch_t *patch) // Free image data from memory. if (next->data) Z_Free(next->data); + if (next->colormap) + Z_Free(next->colormap); next->data = NULL; + next->colormap = NULL; HWD.pfnDeleteTexture(next); // Free the old colormap mipmap from memory. @@ -667,16 +670,29 @@ void HWR_FreeTextureColormaps(patch_t *patch) } } +static boolean FreeTextureCallback(void *mem) +{ + patch_t *patch = (patch_t *)mem; + HWR_FreeTexture(patch); + return false; +} + +static boolean FreeColormapsCallback(void *mem) +{ + patch_t *patch = (patch_t *)mem; + HWR_FreeTextureColormaps(patch); + return false; +} + static void HWR_FreePatchCache(boolean freeall) { - INT32 i; + boolean (*callback)(void *mem) = FreeTextureCallback; - for (i = 0; i < numwadfiles; i++) - { - INT32 j = 0; - for (; j < wadfiles[i]->numlumps; j++) - (freeall ? HWR_FreeTexture : HWR_FreeTextureColormaps)(wadfiles[i]->patchcache[j]); - } + if (!freeall) + callback = FreeColormapsCallback; + + Z_IterateTags(PU_PATCH, PU_PATCH_ROTATED, callback); + Z_IterateTags(PU_SPRITE, PU_HUDGFX, callback); } // free all textures after each level @@ -977,8 +993,28 @@ static void HWR_LoadPatchMipmap(patch_t *patch, GLMipmap_t *grMipmap) Z_ChangeTag(grMipmap->data, PU_HWRCACHE_UNLOCKED); } +// ----------------------+ +// HWR_UpdatePatchMipmap : Updates a mipmap. +// ----------------------+ +static void HWR_UpdatePatchMipmap(patch_t *patch, GLMipmap_t *grMipmap) +{ + GLPatch_t *grPatch = patch->hardware; + HWR_MakePatch(patch, grPatch, grMipmap, true); + + // If hardware does not have the texture, then call pfnSetTexture to upload it + // If it does have the texture, then call pfnUpdateTexture to update it + if (!grMipmap->downloaded) + HWD.pfnSetTexture(grMipmap); + else + HWD.pfnUpdateTexture(grMipmap); + HWR_SetCurrentTexture(grMipmap); + + // The system-memory data can be purged now. + Z_ChangeTag(grMipmap->data, PU_HWRCACHE_UNLOCKED); +} + // -----------------+ -// HWR_GetPatch : Download a patch to the hardware cache and make it ready for use +// HWR_GetPatch : Downloads a patch to the hardware cache and make it ready for use // -----------------+ void HWR_GetPatch(patch_t *patch) { @@ -1006,14 +1042,20 @@ void HWR_GetMappedPatch(patch_t *patch, const UINT8 *colormap) return; } - // search for the mimmap + // search for the mipmap // skip the first (no colormap translated) for (grMipmap = grPatch->mipmap; grMipmap->nextcolormap; ) { grMipmap = grMipmap->nextcolormap; - if (grMipmap->colormap == colormap) + if (grMipmap->colormap && grMipmap->colormap->source == colormap) { - HWR_LoadPatchMipmap(patch, grMipmap); + if (memcmp(grMipmap->colormap->data, colormap, 256 * sizeof(UINT8))) + { + M_Memcpy(grMipmap->colormap->data, colormap, 256 * sizeof(UINT8)); + HWR_UpdatePatchMipmap(patch, grMipmap); + } + else + HWR_LoadPatchMipmap(patch, grMipmap); return; } } @@ -1029,7 +1071,10 @@ void HWR_GetMappedPatch(patch_t *patch, const UINT8 *colormap) I_Error("%s: Out of memory", "HWR_GetMappedPatch"); grMipmap->nextcolormap = newMipmap; - newMipmap->colormap = colormap; + newMipmap->colormap = Z_Calloc(sizeof(*newMipmap->colormap), PU_HWRPATCHCOLMIPMAP, NULL); + newMipmap->colormap->source = colormap; + M_Memcpy(newMipmap->colormap->data, colormap, 256 * sizeof(UINT8)); + HWR_LoadPatchMipmap(patch, newMipmap); } diff --git a/src/hardware/hw_data.h b/src/hardware/hw_data.h index 3ae4ef8bc..11e41b18a 100644 --- a/src/hardware/hw_data.h +++ b/src/hardware/hw_data.h @@ -39,6 +39,15 @@ typedef enum GLTextureFormat_e GL_TEXFMT_ALPHA_INTENSITY_88 = 0x22, } GLTextureFormat_t; +// Colormap structure for mipmaps. +struct GLColormap_s +{ + const UINT8 *source; + UINT8 data[256]; +}; +typedef struct GLColormap_s GLColormap_t; + + // data holds the address of the graphics data cached in heap memory // NULL if the texture is not in Doom heap cache. struct GLMipmap_s @@ -53,7 +62,7 @@ struct GLMipmap_s UINT32 downloaded; // The GPU has this texture. struct GLMipmap_s *nextcolormap; - const UINT8 *colormap; + struct GLColormap_s *colormap; struct GLMipmap_s *nextmipmap; // Linked list of all textures }; @@ -77,7 +86,7 @@ struct GLPatch_s { float max_s,max_t; GLMipmap_t *mipmap; -} ATTRPACK; +}; typedef struct GLPatch_s GLPatch_t; #endif //_HWR_DATA_ diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 5dd2727bc..902ce55bd 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -5295,7 +5295,7 @@ static void HWR_ProjectSprite(mobj_t *thing) vis->colormap = R_GetTranslationColormap(TC_DEFAULT, vis->mobj->color ? vis->mobj->color : SKINCOLOR_CYAN, GTC_CACHE); } else - vis->colormap = colormaps; + vis->colormap = NULL; // set top/bottom coords vis->gzt = gzt; @@ -5396,7 +5396,7 @@ static void HWR_ProjectPrecipitationSprite(precipmobj_t *thing) vis->flip = flip; vis->mobj = (mobj_t *)thing; - vis->colormap = colormaps; + vis->colormap = NULL; // set top/bottom coords vis->gzt = FIXED_TO_FLOAT(thing->z + spritecachedinfo[lumpoff].topoffset); diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index 9c786e67e..2e944d3e6 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -1106,11 +1106,19 @@ static void HWR_GetBlendedTexture(patch_t *patch, patch_t *blendpatch, INT32 ski for (grMipmap = grPatch->mipmap; grMipmap->nextcolormap; ) { grMipmap = grMipmap->nextcolormap; - if (grMipmap->colormap == colormap) + if (grMipmap->colormap && grMipmap->colormap->source == colormap) { if (grMipmap->downloaded && grMipmap->data) { - HWD.pfnSetTexture(grMipmap); // found the colormap, set it to the correct texture + if (memcmp(grMipmap->colormap->data, colormap, 256 * sizeof(UINT8))) + { + M_Memcpy(grMipmap->colormap->data, colormap, 256 * sizeof(UINT8)); + HWR_CreateBlendedTexture(patch, blendpatch, grMipmap, skinnum, color); + HWD.pfnUpdateTexture(grMipmap); + } + else + HWD.pfnSetTexture(grMipmap); // found the colormap, set it to the correct texture + Z_ChangeTag(grMipmap->data, PU_HWRMODELTEXTURE_UNLOCKED); return; } @@ -1128,7 +1136,10 @@ static void HWR_GetBlendedTexture(patch_t *patch, patch_t *blendpatch, INT32 ski if (newMipmap == NULL) I_Error("%s: Out of memory", "HWR_GetBlendedTexture"); grMipmap->nextcolormap = newMipmap; - newMipmap->colormap = colormap; + + newMipmap->colormap = Z_Calloc(sizeof(*newMipmap->colormap), PU_HWRPATCHCOLMIPMAP, NULL); + newMipmap->colormap->source = colormap; + M_Memcpy(newMipmap->colormap->data, colormap, 256 * sizeof(UINT8)); HWR_CreateBlendedTexture(patch, blendpatch, newMipmap, skinnum, color); diff --git a/src/m_menu.c b/src/m_menu.c index 77648f877..3a6b5ce22 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -8423,7 +8423,7 @@ static void M_DrawLoadGameData(void) sprdef = &charbotskin->sprites[SPR2_SIGN]; if (!sprdef->numframes) goto skipbot; - colormap = R_GetTranslationColormap(savegameinfo[savetodraw].botskin-1, charbotskin->prefcolor, 0); + colormap = R_GetTranslationColormap(savegameinfo[savetodraw].botskin-1, charbotskin->prefcolor, GTC_CACHE); sprframe = &sprdef->spriteframes[0]; patch = W_CachePatchNum(sprframe->lumppat[0], PU_PATCH); @@ -8433,8 +8433,6 @@ static void M_DrawLoadGameData(void) charbotskin->highresscale, 0, patch, colormap); - Z_Free(colormap); - tempx -= (20<sprites[SPR2_SIGN]; - colormap = R_GetTranslationColormap(savegameinfo[savetodraw].skinnum, charskin->prefcolor, 0); + colormap = R_GetTranslationColormap(savegameinfo[savetodraw].skinnum, charskin->prefcolor, GTC_CACHE); if (!sprdef->numframes) goto skipsign; sprframe = &sprdef->spriteframes[0]; @@ -8483,8 +8481,6 @@ skipsign: charskin->highresscale/2, 0, patch, colormap); skiplife: - if (colormap) - Z_Free(colormap); patch = W_CachePatchName("STLIVEX", PU_PATCH); @@ -11755,7 +11751,7 @@ static void M_DrawSetupMultiPlayerMenu(void) goto faildraw; // ok, draw player sprite for sure now - colormap = R_GetTranslationColormap(setupm_fakeskin, setupm_fakecolor->color, 0); + colormap = R_GetTranslationColormap(setupm_fakeskin, setupm_fakecolor->color, GTC_CACHE); if (multi_frame >= sprdef->numframes) multi_frame = 0; @@ -11773,7 +11769,6 @@ static void M_DrawSetupMultiPlayerMenu(void) FixedDiv(skins[setupm_fakeskin].highresscale, skins[setupm_fakeskin].shieldscale), flags, patch, colormap); - Z_Free(colormap); goto colordraw; faildraw: diff --git a/src/z_zone.c b/src/z_zone.c index ad64a3a07..d7da17e51 100644 --- a/src/z_zone.c +++ b/src/z_zone.c @@ -813,12 +813,12 @@ static void Command_Memfree_f(void) #ifdef HWRENDER if (rendermode == render_opengl) { - CONS_Printf(M_GetText("Patch info headers: %7s KB\n"), sizeu1(Z_TagUsage(PU_HWRPATCHINFO)>>10)); - CONS_Printf(M_GetText("Mipmap patches : %7s KB\n"), sizeu1(Z_TagUsage(PU_HWRPATCHCOLMIPMAP)>>10)); - CONS_Printf(M_GetText("HW Texture cache : %7s KB\n"), sizeu1(Z_TagUsage(PU_HWRCACHE)>>10)); - CONS_Printf(M_GetText("Plane polygons : %7s KB\n"), sizeu1(Z_TagUsage(PU_HWRPLANE)>>10)); - CONS_Printf(M_GetText("HW model textures : %7s KB\n"), sizeu1(Z_TagUsage(PU_HWRMODELTEXTURE)>>10)); - CONS_Printf(M_GetText("HW Texture used : %7d KB\n"), HWR_GetTextureUsed()>>10); + CONS_Printf(M_GetText("Patch info headers : %7s KB\n"), sizeu1(Z_TagUsage(PU_HWRPATCHINFO)>>10)); + CONS_Printf(M_GetText("Cached textures : %7s KB\n"), sizeu1(Z_TagUsage(PU_HWRCACHE)>>10)); + CONS_Printf(M_GetText("Texture colormaps : %7s KB\n"), sizeu1(Z_TagUsage(PU_HWRPATCHCOLMIPMAP)>>10)); + CONS_Printf(M_GetText("Model textures : %7s KB\n"), sizeu1(Z_TagUsage(PU_HWRMODELTEXTURE)>>10)); + CONS_Printf(M_GetText("Plane polygons : %7s KB\n"), sizeu1(Z_TagUsage(PU_HWRPLANE)>>10)); + CONS_Printf(M_GetText("All GPU textures : %7d KB\n"), HWR_GetTextureUsed()>>10); } #endif From 284205baacdd2ffb923ef222a3469178f9ddd12f Mon Sep 17 00:00:00 2001 From: Steel Titanium Date: Sun, 6 Dec 2020 22:20:06 -0500 Subject: [PATCH 0431/1080] Fix SPC looping on libgme versions >= 0.6.3 --- src/sdl/mixer_sound.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index c64164caa..d67536b04 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -1298,6 +1298,9 @@ boolean I_PlaySong(boolean looping) if (gme) { gme_equalizer_t eq = {GME_TREBLE, GME_BASS, 0,0,0,0,0,0,0,0}; +#if GME_VERSION >= 0x000603 + gme_set_autoload_playback_limit(gme, 0); +#endif gme_set_equalizer(gme, &eq); gme_start_track(gme, 0); current_track = 0; From c3a560f51d274b039bc3441bb8f4f2994350ea86 Mon Sep 17 00:00:00 2001 From: Steel Titanium Date: Sun, 6 Dec 2020 22:30:50 -0500 Subject: [PATCH 0432/1080] Let's check for looping first --- src/sdl/mixer_sound.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index d67536b04..490ebb5ba 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -1299,7 +1299,8 @@ boolean I_PlaySong(boolean looping) { gme_equalizer_t eq = {GME_TREBLE, GME_BASS, 0,0,0,0,0,0,0,0}; #if GME_VERSION >= 0x000603 - gme_set_autoload_playback_limit(gme, 0); + if (looping) + gme_set_autoload_playback_limit(gme, 0); #endif gme_set_equalizer(gme, &eq); gme_start_track(gme, 0); From 11bbad9be8231c0403c1fb41d7c65c4a62a3fec3 Mon Sep 17 00:00:00 2001 From: Steel Titanium Date: Sun, 6 Dec 2020 22:58:17 -0500 Subject: [PATCH 0433/1080] Tab fix --- src/sdl/mixer_sound.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index 490ebb5ba..5cae48077 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -1299,8 +1299,8 @@ boolean I_PlaySong(boolean looping) { gme_equalizer_t eq = {GME_TREBLE, GME_BASS, 0,0,0,0,0,0,0,0}; #if GME_VERSION >= 0x000603 - if (looping) - gme_set_autoload_playback_limit(gme, 0); + if (looping) + gme_set_autoload_playback_limit(gme, 0); #endif gme_set_equalizer(gme, &eq); gme_start_track(gme, 0); From 27217259624c287b131d92e2f762057fa791bd12 Mon Sep 17 00:00:00 2001 From: Zippy_Zolton Date: Mon, 7 Dec 2020 16:46:05 -0600 Subject: [PATCH 0434/1080] Final lap text for circuit --- src/p_spec.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/p_spec.c b/src/p_spec.c index a1afdd00d..cdab17c97 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -4823,6 +4823,8 @@ DoneSection2: if (player->laps >= (UINT8)cv_numlaps.value) CONS_Printf(M_GetText("%s has finished the race.\n"), player_names[player-players]); + else if (player->laps == (UINT8)cv_numlaps.value-1) + CONS_Printf(M_GetText("%s started the %c%s%c!\n"), player_names[player-players], 0x85, M_GetText("final lap"), 0x80); else CONS_Printf(M_GetText("%s started lap %u\n"), player_names[player-players], (UINT32)player->laps+1); From c2de684150262cca19402bcace64c14da3362767 Mon Sep 17 00:00:00 2001 From: Steel Titanium Date: Mon, 7 Dec 2020 17:52:43 -0500 Subject: [PATCH 0435/1080] Fix double free occuring when unloading the intermission patches due to the same patch being cached twice --- src/y_inter.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/y_inter.c b/src/y_inter.c index 061cbb5e1..bd3b557d7 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -1229,7 +1229,10 @@ void Y_StartIntermission(void) data.coop.tics = players[consoleplayer].realtime; for (i = 0; i < 4; ++i) - data.coop.bonuspatches[i] = W_CachePatchName(data.coop.bonuses[i].patch, PU_PATCH); + { + if (strlen(data.coop.bonuses[i].patch)) + data.coop.bonuspatches[i] = W_CachePatchName(data.coop.bonuses[i].patch, PU_PATCH); + } data.coop.ptotal = W_CachePatchName("YB_TOTAL", PU_PATCH); // get act number @@ -1733,7 +1736,6 @@ static void Y_SetNullBonus(player_t *player, y_bonus_t *bstruct) { (void)player; memset(bstruct, 0, sizeof(y_bonus_t)); - strncpy(bstruct->patch, "MISSING", sizeof(bstruct->patch)); } // From 45a4b728b354fd867641e6c7c372c052ad827d32 Mon Sep 17 00:00:00 2001 From: Zippy_Zolton Date: Tue, 8 Dec 2020 12:05:06 -0600 Subject: [PATCH 0436/1080] zwip suggestion --- src/p_spec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_spec.c b/src/p_spec.c index cdab17c97..06eee3b12 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -4824,7 +4824,7 @@ DoneSection2: if (player->laps >= (UINT8)cv_numlaps.value) CONS_Printf(M_GetText("%s has finished the race.\n"), player_names[player-players]); else if (player->laps == (UINT8)cv_numlaps.value-1) - CONS_Printf(M_GetText("%s started the %c%s%c!\n"), player_names[player-players], 0x85, M_GetText("final lap"), 0x80); + CONS_Printf(M_GetText("%s started the \205final lap\200!\n"), player_names[player-players]); else CONS_Printf(M_GetText("%s started lap %u\n"), player_names[player-players], (UINT32)player->laps+1); From 1b888c689cb2a5a24e13f7fcf34f0b2235dad86c Mon Sep 17 00:00:00 2001 From: Zippy_Zolton Date: Tue, 8 Dec 2020 15:56:45 -0600 Subject: [PATCH 0437/1080] CTF text 1 --- src/p_spec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/p_spec.c b/src/p_spec.c index 06eee3b12..e79e02812 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -4600,7 +4600,7 @@ DoneSection2: HU_SetCEchoFlags(V_AUTOFADEOUT|V_ALLOWLOWERCASE); HU_SetCEchoDuration(5); - HU_DoCEcho(va(M_GetText("%s%s%s\\CAPTURED THE %sBLUE FLAG%s.\\\\\\\\"), "\x85", player_names[player-players], "\x80", "\x84", "\x80")); + HU_DoCEcho(va(M_GetText("\205%s\200\\CAPTURED THE \204BLUE FLAG\200.\\\\\\\\"), player_names[player-players])); if (splitscreen || players[consoleplayer].ctfteam == 1) S_StartSound(NULL, sfx_flgcap); @@ -4633,7 +4633,7 @@ DoneSection2: HU_SetCEchoFlags(V_AUTOFADEOUT|V_ALLOWLOWERCASE); HU_SetCEchoDuration(5); - HU_DoCEcho(va(M_GetText("%s%s%s\\CAPTURED THE %sRED FLAG%s.\\\\\\\\"), "\x84", player_names[player-players], "\x80", "\x85", "\x80")); + HU_DoCEcho(va(M_GetText("\204%s\200\\CAPTURED THE \205RED FLAG\200.\\\\\\\\"), player_names[player-players])); if (splitscreen || players[consoleplayer].ctfteam == 2) S_StartSound(NULL, sfx_flgcap); From 7082db485b754bd0a007d44b3e71edcdd9e40c96 Mon Sep 17 00:00:00 2001 From: Zippy_Zolton Date: Tue, 8 Dec 2020 16:09:51 -0600 Subject: [PATCH 0438/1080] CTF text 2, branch is finished --- src/p_mobj.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index 7ba6d1fad..0e80496b5 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -9835,7 +9835,7 @@ static void P_FlagFuseThink(mobj_t *mobj) if (mobj->type == MT_REDFLAG) { if (!(mobj->flags2 & MF2_JUSTATTACKED)) - CONS_Printf(M_GetText("The %c%s%c has returned to base.\n"), 0x85, M_GetText("Red flag"), 0x80); + CONS_Printf(M_GetText("The \205Red flag\200 has returned to base.\n")); // Assumedly in splitscreen players will be on opposing teams if (players[consoleplayer].ctfteam == 1 || splitscreen) @@ -9848,7 +9848,7 @@ static void P_FlagFuseThink(mobj_t *mobj) else // MT_BLUEFLAG { if (!(mobj->flags2 & MF2_JUSTATTACKED)) - CONS_Printf(M_GetText("The %c%s%c has returned to base.\n"), 0x84, M_GetText("Blue flag"), 0x80); + CONS_Printf(M_GetText("The \204Blue flag\200 has returned to base.\n")); // Assumedly in splitscreen players will be on opposing teams if (players[consoleplayer].ctfteam == 2 || splitscreen) From e7883f3f8e5514433f0e73d9118a7d51e483b135 Mon Sep 17 00:00:00 2001 From: James R Date: Tue, 17 Nov 2020 02:51:11 -0800 Subject: [PATCH 0439/1080] That moment when you see HAVE_BLUA crawl back from the grave This would mean MapChange hasn't been firing for demos ...since 2.2.5. --- src/d_clisrv.c | 2 -- src/g_demo.c | 2 -- 2 files changed, 4 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index b198011a0..14fc1aea5 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -1595,9 +1595,7 @@ static void CL_ReloadReceivedSavegame(void) for (i = 0; i < MAXPLAYERS; i++) { -#ifdef HAVE_BLUA LUA_InvalidatePlayer(&players[i]); -#endif sprintf(player_names[i], "Player %d", i + 1); } diff --git a/src/g_demo.c b/src/g_demo.c index 9d3b86015..593fd7723 100644 --- a/src/g_demo.c +++ b/src/g_demo.c @@ -1956,9 +1956,7 @@ void G_DoPlayDemo(char *defdemoname) // Set skin SetPlayerSkin(0, skin); -#ifdef HAVE_BLUA LUAh_MapChange(gamemap); -#endif displayplayer = consoleplayer = 0; memset(playeringame,0,sizeof(playeringame)); playeringame[0] = true; From 8d382e49fb3411cad1a3ef5ee1e546030c3a9d93 Mon Sep 17 00:00:00 2001 From: James R Date: Tue, 17 Nov 2020 04:14:45 -0800 Subject: [PATCH 0440/1080] Big Large Lua Hooklib Refactor * Hooks are no longer a mess of lua boiler plate. Helper functions reduce hooks to, at the most basic level, only two calls. * Lua tables (the array part) are used to index hooks. Such tables contain only hooks of the same type. * Hook types are defined in one place so you no longer need to sync up the enum and name array. --- src/b_bot.c | 6 +- src/d_clisrv.c | 12 +- src/d_netcmd.c | 10 +- src/doomtype.h | 2 + src/g_demo.c | 2 +- src/g_game.c | 10 +- src/hu_stuff.c | 2 +- src/lua_hook.h | 191 ++-- src/lua_hooklib.c | 2630 +++++++++++++++------------------------------ src/lua_script.c | 4 +- src/lua_script.h | 2 +- src/m_menu.c | 4 +- src/p_enemy.c | 2 +- src/p_inter.c | 16 +- src/p_map.c | 8 +- src/p_mobj.c | 22 +- src/p_setup.c | 4 +- src/p_spec.c | 4 +- src/p_tick.c | 12 +- src/p_user.c | 40 +- src/s_sound.c | 12 +- src/s_sound.h | 10 + src/sdl/i_video.c | 2 +- src/y_inter.c | 2 +- 24 files changed, 1055 insertions(+), 1954 deletions(-) diff --git a/src/b_bot.c b/src/b_bot.c index d3635f32c..93a853dee 100644 --- a/src/b_bot.c +++ b/src/b_bot.c @@ -75,7 +75,7 @@ static void B_BuildTailsTiccmd(mobj_t *sonic, mobj_t *tails, ticcmd_t *cmd) return; // Lua can handle it! - if (LUAh_BotAI(sonic, tails, cmd)) + if (LUA_HookBotAI(sonic, tails, cmd)) return; if (tails->player->powers[pw_carry] == CR_MACESPIN || tails->player->powers[pw_carry] == CR_GENERIC) @@ -363,7 +363,7 @@ void B_BuildTiccmd(player_t *player, ticcmd_t *cmd) CV_SetValue(&cv_analog[1], false); // Let Lua scripts build ticcmds - if (LUAh_BotTiccmd(player, cmd)) + if (LUA_HookTiccmd(player, cmd, Hook(BotTiccmd))) return; // We don't have any main character AI, sorry. D: @@ -461,7 +461,7 @@ boolean B_CheckRespawn(player_t *player) // B_RespawnBot doesn't do anything if the condition above this isn't met { - UINT8 shouldForce = LUAh_BotRespawn(sonic, tails); + UINT8 shouldForce = LUA_Hook2Mobj(sonic, tails, Mobj_Hook(BotRespawn)); if (P_MobjWasRemoved(sonic) || P_MobjWasRemoved(tails)) return (shouldForce == 1); // mobj was removed diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 14fc1aea5..91918ed35 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -2537,14 +2537,14 @@ static void CL_RemovePlayer(INT32 playernum, kickreason_t reason) } } - LUAh_PlayerQuit(&players[playernum], reason); // Lua hook for player quitting + LUA_HookPlayerQuit(&players[playernum], reason); // Lua hook for player quitting // don't look through someone's view who isn't there if (playernum == displayplayer) { // Call ViewpointSwitch hooks here. // The viewpoint was forcibly changed. - LUAh_ViewpointSwitch(&players[consoleplayer], &players[consoleplayer], true); + LUA_HookViewpointSwitch(&players[consoleplayer], &players[consoleplayer], true); displayplayer = consoleplayer; } @@ -3025,7 +3025,7 @@ static void Got_KickCmd(UINT8 **p, INT32 playernum) if (pnum == consoleplayer) { if (Playing()) - LUAh_GameQuit(); + LUA_Hook(GameQuit); #ifdef DUMPCONSISTENCY if (msg == KICK_MSG_CON_FAIL) SV_SavedGame(); #endif @@ -3445,7 +3445,7 @@ static void Got_AddPlayer(UINT8 **p, INT32 playernum) COM_BufAddText(va("sayto %d %s\n", newplayernum, motd)); if (!rejoined) - LUAh_PlayerJoin(newplayernum); + LUA_HookInt(newplayernum, Hook(PlayerJoin)); } static boolean SV_AddWaitingPlayers(const char *name, const char *name2) @@ -3726,7 +3726,7 @@ static void HandleShutdown(SINT8 node) { (void)node; if (Playing()) - LUAh_GameQuit(); + LUA_Hook(GameQuit); D_QuitNetGame(); CL_Reset(); D_StartTitle(); @@ -3742,7 +3742,7 @@ static void HandleTimeout(SINT8 node) { (void)node; if (Playing()) - LUAh_GameQuit(); + LUA_Hook(GameQuit); D_QuitNetGame(); CL_Reset(); D_StartTitle(); diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 31c10f58a..baad9bcdf 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -2103,7 +2103,7 @@ static void Got_Mapcmd(UINT8 **cp, INT32 playernum) } mapnumber = M_MapNumber(mapname[3], mapname[4]); - LUAh_MapChange(mapnumber); + LUA_HookInt(mapnumber, Hook(MapChange)); G_InitNew(ultimatemode, mapname, resetplayer, skipprecutscene, FLS); if (demoplayback && !timingdemo) @@ -2688,7 +2688,7 @@ static void Got_Teamchange(UINT8 **cp, INT32 playernum) } // Don't switch team, just go away, please, go awaayyyy, aaauuauugghhhghgh - if (!LUAh_TeamSwitch(&players[playernum], NetPacket.packet.newteam, players[playernum].spectator, NetPacket.packet.autobalance, NetPacket.packet.scrambled)) + if (!LUA_HookTeamSwitch(&players[playernum], NetPacket.packet.newteam, players[playernum].spectator, NetPacket.packet.autobalance, NetPacket.packet.scrambled)) return; //no status changes after hidetime @@ -2849,7 +2849,7 @@ static void Got_Teamchange(UINT8 **cp, INT32 playernum) // Call ViewpointSwitch hooks here. // The viewpoint was forcibly changed. if (displayplayer != consoleplayer) // You're already viewing yourself. No big deal. - LUAh_ViewpointSwitch(&players[consoleplayer], &players[consoleplayer], true); + LUA_HookViewpointSwitch(&players[consoleplayer], &players[consoleplayer], true); displayplayer = consoleplayer; } @@ -3607,7 +3607,7 @@ static void Command_Playintro_f(void) FUNCNORETURN static ATTRNORETURN void Command_Quit_f(void) { if (Playing()) - LUAh_GameQuit(); + LUA_Hook(GameQuit); I_Quit(); } @@ -4270,7 +4270,7 @@ void Command_ExitGame_f(void) INT32 i; if (Playing()) - LUAh_GameQuit(); + LUA_Hook(GameQuit); D_QuitNetGame(); CL_Reset(); diff --git a/src/doomtype.h b/src/doomtype.h index 4e13ba96d..8bfedbe92 100644 --- a/src/doomtype.h +++ b/src/doomtype.h @@ -367,6 +367,8 @@ typedef UINT32 tic_t; #define UINT2RGBA(a) (UINT32)((a&0xff)<<24)|((a&0xff00)<<8)|((a&0xff0000)>>8)|(((UINT32)a&0xff000000)>>24) #endif +#define TOSTR(x) #x + /* preprocessor dumb and needs second macro to expand input */ #define WSTRING2(s) L ## s #define WSTRING(s) WSTRING2 (s) diff --git a/src/g_demo.c b/src/g_demo.c index 593fd7723..e4af7086c 100644 --- a/src/g_demo.c +++ b/src/g_demo.c @@ -1956,7 +1956,7 @@ void G_DoPlayDemo(char *defdemoname) // Set skin SetPlayerSkin(0, skin); - LUAh_MapChange(gamemap); + LUA_HookInt(gamemap, Hook(MapChange)); displayplayer = consoleplayer = 0; memset(playeringame,0,sizeof(playeringame)); playeringame[0] = true; diff --git a/src/g_game.c b/src/g_game.c index 283113bbe..c0aaf6af7 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1689,7 +1689,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) cmd->angleturn = orighookangle; - LUAh_PlayerCmd(player, cmd); + LUA_HookTiccmd(player, cmd, Hook(PlayerCmd)); extra = cmd->angleturn - orighookangle; cmd->angleturn = origangle + extra; @@ -1703,7 +1703,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) { // Call ViewpointSwitch hooks here. // The viewpoint was forcibly changed. - LUAh_ViewpointSwitch(player, &players[consoleplayer], true); + LUA_HookViewpointSwitch(player, &players[consoleplayer], true); displayplayer = consoleplayer; } @@ -2076,7 +2076,7 @@ boolean G_Responder(event_t *ev) continue; // Call ViewpointSwitch hooks here. - canSwitchView = LUAh_ViewpointSwitch(&players[consoleplayer], &players[displayplayer], false); + canSwitchView = LUA_HookViewpointSwitch(&players[consoleplayer], &players[displayplayer], false); if (canSwitchView == 1) // Set viewpoint to this player break; else if (canSwitchView == 2) // Skip this player @@ -2713,7 +2713,7 @@ void G_SpawnPlayer(INT32 playernum) P_SpawnPlayer(playernum); G_MovePlayerToSpawnOrStarpost(playernum); - LUAh_PlayerSpawn(&players[playernum]); // Lua hook for player spawning :) + LUA_HookPlayer(&players[playernum], Hook(PlayerSpawn)); // Lua hook for player spawning :) } void G_MovePlayerToSpawnOrStarpost(INT32 playernum) @@ -3092,7 +3092,7 @@ void G_DoReborn(INT32 playernum) } else { - LUAh_MapChange(gamemap); + LUA_HookInt(gamemap, Hook(MapChange)); titlecardforreload = true; G_DoLoadLevel(true); titlecardforreload = false; diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 7e9144f98..9516b466b 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -684,7 +684,7 @@ static void Got_Saycmd(UINT8 **p, INT32 playernum) // run the lua hook even if we were supposed to eat the msg, netgame consistency goes first. - if (LUAh_PlayerMsg(playernum, target, flags, msg)) + if (LUA_HookPlayerMsg(playernum, target, flags, msg)) return; if (spam_eatmsg) diff --git a/src/lua_hook.h b/src/lua_hook.h index 796f3a9d2..f44a2e305 100644 --- a/src/lua_hook.h +++ b/src/lua_hook.h @@ -12,111 +12,100 @@ #include "r_defs.h" #include "d_player.h" +#include "s_sound.h" -enum hook { - hook_NetVars=0, - hook_MapChange, - hook_MapLoad, - hook_PlayerJoin, - hook_PreThinkFrame, - hook_ThinkFrame, - hook_PostThinkFrame, - hook_MobjSpawn, - hook_MobjCollide, - hook_MobjLineCollide, - hook_MobjMoveCollide, - hook_TouchSpecial, - hook_MobjFuse, - hook_MobjThinker, - hook_BossThinker, - hook_ShouldDamage, - hook_MobjDamage, - hook_MobjDeath, - hook_BossDeath, - hook_MobjRemoved, - hook_JumpSpecial, - hook_AbilitySpecial, - hook_SpinSpecial, - hook_JumpSpinSpecial, - hook_BotTiccmd, - hook_BotAI, - hook_BotRespawn, - hook_LinedefExecute, - hook_PlayerMsg, - hook_HurtMsg, - hook_PlayerSpawn, - hook_ShieldSpawn, - hook_ShieldSpecial, - hook_MobjMoveBlocked, - hook_MapThingSpawn, - hook_FollowMobj, - hook_PlayerCanDamage, - hook_PlayerQuit, - hook_IntermissionThinker, - hook_TeamSwitch, - hook_ViewpointSwitch, - hook_SeenPlayer, - hook_PlayerThink, - hook_ShouldJingleContinue, - hook_GameQuit, - hook_PlayerCmd, - hook_MusicChange, +#define Mobj_Hook_List(X) \ + X (MobjSpawn),/* P_SpawnMobj */\ + X (MobjCollide),/* PIT_CheckThing */\ + X (MobjLineCollide),/* ditto */\ + X (MobjMoveCollide),/* tritto */\ + X (TouchSpecial),/* P_TouchSpecialThing */\ + X (MobjFuse),/* when mobj->fuse runs out */\ + X (MobjThinker),/* P_MobjThinker, P_SceneryThinker */\ + X (BossThinker),/* P_GenericBossThinker */\ + X (ShouldDamage),/* P_DamageMobj (Should mobj take damage?) */\ + X (MobjDamage),/* P_DamageMobj (Mobj actually takes damage!) */\ + X (MobjDeath),/* P_KillMobj */\ + X (BossDeath),/* A_BossDeath */\ + X (MobjRemoved),/* P_RemoveMobj */\ + X (BotRespawn),/* B_CheckRespawn */\ + X (MobjMoveBlocked),/* P_XYMovement (when movement is blocked) */\ + X (MapThingSpawn),/* P_SpawnMapThing */\ + X (FollowMobj),/* P_PlayerAfterThink Smiles mobj-following */\ - hook_MAX // last hook -}; -extern const char *const hookNames[]; +#define Hook_List(X) \ + X (NetVars),/* add to archive table (netsave) */\ + X (MapChange),/* (before map load) */\ + X (MapLoad),\ + X (PlayerJoin),/* Got_AddPlayer */\ + X (PreThinkFrame)/* frame (before mobj and player thinkers) */,\ + X (ThinkFrame),/* frame (after mobj and player thinkers) */\ + X (PostThinkFrame),/* frame (at end of tick, ie after overlays, precipitation, specials) */\ + X (JumpSpecial),/* P_DoJumpStuff (Any-jumping) */\ + X (AbilitySpecial),/* P_DoJumpStuff (Double-jumping) */\ + X (SpinSpecial),/* P_DoSpinAbility (Spin button effect) */\ + X (JumpSpinSpecial),/* P_DoJumpStuff (Spin button effect (mid-air)) */\ + X (BotTiccmd),/* B_BuildTiccmd */\ + X (PlayerMsg),/* chat messages */\ + X (HurtMsg),/* imhurttin */\ + X (PlayerSpawn),/* G_SpawnPlayer */\ + X (ShieldSpawn),/* P_SpawnShieldOrb */\ + X (ShieldSpecial),/* shield abilities */\ + X (PlayerCanDamage),/* P_PlayerCanDamage */\ + X (PlayerQuit),\ + X (IntermissionThinker),/* Y_Ticker */\ + X (TeamSwitch),/* team switching in... uh... *what* speak, spit it the fuck out */\ + X (ViewpointSwitch),/* spy mode (no trickstabs) */\ + X (SeenPlayer),/* MT_NAMECHECK */\ + X (PlayerThink),/* P_PlayerThink */\ + X (GameQuit),\ + X (PlayerCmd),/* building the player's ticcmd struct (Ported from SRB2Kart) */\ + X (MusicChange),\ + +#define String_Hook_List(X) \ + X (BotAI),/* B_BuildTailsTiccmd by skin name */\ + X (LinedefExecute),\ + X (ShouldJingleContinue),/* should jingle of the given music continue playing */\ + +#define Mobj_Hook(name) mobjhook_ ## name +#define Hook(name) hook_ ## name +#define String_Hook(name) stringhook_ ## name + +enum { Mobj_Hook_List (Mobj_Hook) Mobj_Hook(MAX) }; +enum { Hook_List (Hook) Hook(MAX) }; +enum { String_Hook_List (String_Hook) String_Hook(MAX) }; extern boolean hook_cmd_running; -void LUAh_MapChange(INT16 mapnumber); // Hook for map change (before load) -void LUAh_MapLoad(void); // Hook for map load -void LUAh_PlayerJoin(int playernum); // Hook for Got_AddPlayer -void LUAh_PreThinkFrame(void); // Hook for frame (before mobj and player thinkers) -void LUAh_ThinkFrame(void); // Hook for frame (after mobj and player thinkers) -void LUAh_PostThinkFrame(void); // Hook for frame (at end of tick, ie after overlays, precipitation, specials) -boolean LUAh_MobjHook(mobj_t *mo, enum hook which); -boolean LUAh_PlayerHook(player_t *plr, enum hook which); -#define LUAh_MobjSpawn(mo) LUAh_MobjHook(mo, hook_MobjSpawn) // Hook for P_SpawnMobj by mobj type -UINT8 LUAh_MobjCollideHook(mobj_t *thing1, mobj_t *thing2, enum hook which); -UINT8 LUAh_MobjLineCollideHook(mobj_t *thing, line_t *line, enum hook which); -#define LUAh_MobjCollide(thing1, thing2) LUAh_MobjCollideHook(thing1, thing2, hook_MobjCollide) // Hook for PIT_CheckThing by (thing) mobj type -#define LUAh_MobjLineCollide(thing, line) LUAh_MobjLineCollideHook(thing, line, hook_MobjLineCollide) // Hook for PIT_CheckThing by (thing) mobj type -#define LUAh_MobjMoveCollide(thing1, thing2) LUAh_MobjCollideHook(thing1, thing2, hook_MobjMoveCollide) // Hook for PIT_CheckThing by (tmthing) mobj type -boolean LUAh_TouchSpecial(mobj_t *special, mobj_t *toucher); // Hook for P_TouchSpecialThing by mobj type -#define LUAh_MobjFuse(mo) LUAh_MobjHook(mo, hook_MobjFuse) // Hook for mobj->fuse == 0 by mobj type -boolean LUAh_MobjThinker(mobj_t *mo); // Hook for P_MobjThinker or P_SceneryThinker by mobj type -#define LUAh_BossThinker(mo) LUAh_MobjHook(mo, hook_BossThinker) // Hook for P_GenericBossThinker by mobj type -UINT8 LUAh_ShouldDamage(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 damage, UINT8 damagetype); // Hook for P_DamageMobj by mobj type (Should mobj take damage?) -boolean LUAh_MobjDamage(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 damage, UINT8 damagetype); // Hook for P_DamageMobj by mobj type (Mobj actually takes damage!) -boolean LUAh_MobjDeath(mobj_t *target, mobj_t *inflictor, mobj_t *source, UINT8 damagetype); // Hook for P_KillMobj by mobj type -#define LUAh_BossDeath(mo) LUAh_MobjHook(mo, hook_BossDeath) // Hook for A_BossDeath by mobj type -#define LUAh_MobjRemoved(mo) LUAh_MobjHook(mo, hook_MobjRemoved) // Hook for P_RemoveMobj by mobj type -#define LUAh_JumpSpecial(player) LUAh_PlayerHook(player, hook_JumpSpecial) // Hook for P_DoJumpStuff (Any-jumping) -#define LUAh_AbilitySpecial(player) LUAh_PlayerHook(player, hook_AbilitySpecial) // Hook for P_DoJumpStuff (Double-jumping) -#define LUAh_SpinSpecial(player) LUAh_PlayerHook(player, hook_SpinSpecial) // Hook for P_DoSpinAbility (Spin button effect) -#define LUAh_JumpSpinSpecial(player) LUAh_PlayerHook(player, hook_JumpSpinSpecial) // Hook for P_DoJumpStuff (Spin button effect (mid-air)) -boolean LUAh_BotTiccmd(player_t *bot, ticcmd_t *cmd); // Hook for B_BuildTiccmd -boolean LUAh_BotAI(mobj_t *sonic, mobj_t *tails, ticcmd_t *cmd); // Hook for B_BuildTailsTiccmd by skin name -boolean LUAh_BotRespawn(mobj_t *sonic, mobj_t *tails); // Hook for B_CheckRespawn -boolean LUAh_LinedefExecute(line_t *line, mobj_t *mo, sector_t *sector); // Hook for linedef executors -boolean LUAh_PlayerMsg(int source, int target, int flags, char *msg); // Hook for chat messages -boolean LUAh_HurtMsg(player_t *player, mobj_t *inflictor, mobj_t *source, UINT8 damagetype); // Hook for hurt messages -#define LUAh_PlayerSpawn(player) LUAh_PlayerHook(player, hook_PlayerSpawn) // Hook for G_SpawnPlayer -#define LUAh_ShieldSpawn(player) LUAh_PlayerHook(player, hook_ShieldSpawn) // Hook for P_SpawnShieldOrb -#define LUAh_ShieldSpecial(player) LUAh_PlayerHook(player, hook_ShieldSpecial) // Hook for shield abilities -#define LUAh_MobjMoveBlocked(mo) LUAh_MobjHook(mo, hook_MobjMoveBlocked) // Hook for P_XYMovement (when movement is blocked) -boolean LUAh_MapThingSpawn(mobj_t *mo, mapthing_t *mthing); // Hook for P_SpawnMapThing by mobj type -boolean LUAh_FollowMobj(player_t *player, mobj_t *mobj); // Hook for P_PlayerAfterThink Smiles mobj-following -UINT8 LUAh_PlayerCanDamage(player_t *player, mobj_t *mobj); // Hook for P_PlayerCanDamage -void LUAh_PlayerQuit(player_t *plr, kickreason_t reason); // Hook for player quitting -void LUAh_IntermissionThinker(void); // Hook for Y_Ticker -boolean LUAh_TeamSwitch(player_t *player, int newteam, boolean fromspectators, boolean tryingautobalance, boolean tryingscramble); // Hook for team switching in... uh.... -UINT8 LUAh_ViewpointSwitch(player_t *player, player_t *newdisplayplayer, boolean forced); // Hook for spy mode +/* dead simple, LUA_Hook(GameQuit) */ +void LUA_Hook(int hook); +#define LUA_Hook(type) LUA_Hook(Hook(type)) + +int LUA_HookMobj(mobj_t *, int hook); +int LUA_Hook2Mobj(mobj_t *, mobj_t *, int hook); +void LUA_HookInt(INT32 integer, int hook); +int LUA_HookPlayer(player_t *, int hook); +int LUA_HookTiccmd(player_t *, ticcmd_t *, int hook); + +void LUA_HookThinkFrame(void); +int LUA_HookMobjLineCollide(mobj_t *, line_t *); +int LUA_HookTouchSpecial(mobj_t *special, mobj_t *toucher); +int LUA_HookShouldDamage(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 damage, UINT8 damagetype); +int LUA_HookMobjDamage(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 damage, UINT8 damagetype); +int LUA_HookMobjDeath(mobj_t *target, mobj_t *inflictor, mobj_t *source, UINT8 damagetype); +int LUA_HookBotAI(mobj_t *sonic, mobj_t *tails, ticcmd_t *cmd); +void LUA_HookLinedefExecute(line_t *, mobj_t *, sector_t *); +int LUA_HookPlayerMsg(int source, int target, int flags, char *msg); +int LUA_HookHurtMsg(player_t *, mobj_t *inflictor, mobj_t *source, UINT8 damagetype); +int LUA_HookMapThingSpawn(mobj_t *, mapthing_t *); +int LUA_HookFollowMobj(player_t *, mobj_t *); +int LUA_HookPlayerCanDamage(player_t *, mobj_t *); +void LUA_HookPlayerQuit(player_t *, kickreason_t); +int LUA_HookTeamSwitch(player_t *, int newteam, boolean fromspectators, boolean tryingautobalance, boolean tryingscramble); +int LUA_HookViewpointSwitch(player_t *player, player_t *newdisplayplayer, boolean forced); #ifdef SEENAMES -boolean LUAh_SeenPlayer(player_t *player, player_t *seenfriend); // Hook for MT_NAMECHECK +int LUA_HookSeenPlayer(player_t *player, player_t *seenfriend); #endif -#define LUAh_PlayerThink(player) LUAh_PlayerHook(player, hook_PlayerThink) // Hook for P_PlayerThink -boolean LUAh_ShouldJingleContinue(player_t *player, const char *musname); // Hook for whether a jingle of the given music should continue playing -void LUAh_GameQuit(void); // Hook for game quitting -boolean LUAh_PlayerCmd(player_t *player, ticcmd_t *cmd); // Hook for building player's ticcmd struct (Ported from SRB2Kart) -boolean LUAh_MusicChange(const char *oldname, char *newname, UINT16 *mflags, boolean *looping, UINT32 *position, UINT32 *prefadems, UINT32 *fadeinms); // Hook for music changes \ No newline at end of file +int LUA_HookShouldJingleContinue(player_t *, const char *musname); +int LUA_HookPlayerCmd(player_t *, ticcmd_t *); +int LUA_HookMusicChange(const char *oldname, struct MusicChange *); diff --git a/src/lua_hooklib.c b/src/lua_hooklib.c index 117aa48a3..dce67cef7 100644 --- a/src/lua_hooklib.c +++ b/src/lua_hooklib.c @@ -27,1948 +27,1038 @@ #include "d_netcmd.h" // for cv_perfstats #include "i_system.h" // I_GetTimeMicros -static UINT8 hooksAvailable[(hook_MAX/8)+1]; +#undef LUA_Hook -const char *const hookNames[hook_MAX+1] = { - "NetVars", - "MapChange", - "MapLoad", - "PlayerJoin", - "PreThinkFrame", - "ThinkFrame", - "PostThinkFrame", - "MobjSpawn", - "MobjCollide", - "MobjLineCollide", - "MobjMoveCollide", - "TouchSpecial", - "MobjFuse", - "MobjThinker", - "BossThinker", - "ShouldDamage", - "MobjDamage", - "MobjDeath", - "BossDeath", - "MobjRemoved", - "JumpSpecial", - "AbilitySpecial", - "SpinSpecial", - "JumpSpinSpecial", - "BotTiccmd", - "BotAI", - "BotRespawn", - "LinedefExecute", - "PlayerMsg", - "HurtMsg", - "PlayerSpawn", - "ShieldSpawn", - "ShieldSpecial", - "MobjMoveBlocked", - "MapThingSpawn", - "FollowMobj", - "PlayerCanDamage", - "PlayerQuit", - "IntermissionThinker", - "TeamSwitch", - "ViewpointSwitch", - "SeenPlayer", - "PlayerThink", - "ShouldJingleContinue", - "GameQuit", - "PlayerCmd", - "MusicChange", - NULL +/* ========================================================================= + ABSTRACTION + ========================================================================= */ + +static const char * const mobjHookNames[] = { Mobj_Hook_List (TOSTR) NULL }; +static const char * const hookNames[] = { Hook_List (TOSTR) NULL }; + +static const char * const stringHookNames[] = { + String_Hook_List (TOSTR) NULL }; -// Hook metadata -struct hook_s +/* TODO: remove when doomtype version is merged */ + +#define BIT_ARRAY_LENGTH(n) (((n) + 7) >> 3) + +static inline void set_bit_array (UINT8 *array, const int n) { + array[n >> 3] |= 1 << (n & 7); +} + +static inline int in_bit_array (const UINT8 *array, const int n) { + return array[n >> 3] & (1 << (n & 7)); +} + +typedef struct { + int numGeneric; + int ref; +} stringhook_t; + +static int hookRefs[Hook(MAX)]; +static int mobjHookRefs[NUMMOBJTYPES][Mobj_Hook(MAX)]; + +static stringhook_t stringHooks[String_Hook(MAX)]; + +static int hookReg; + +// After a hook errors once, don't print the error again. +static UINT8 * hooksErrored; + +static boolean mobj_hook_available(int hook_type, mobjtype_t mobj_type) { - struct hook_s *next; - enum hook type; - UINT16 id; - union { - mobjtype_t mt; - char *str; - } s; - boolean error; -}; -typedef struct hook_s* hook_p; + return + ( + mobjHookRefs [MT_NULL] [hook_type] > 0 || + mobjHookRefs[mobj_type][hook_type] > 0 + ); +} -#define FMT_HOOKID "hook_%d" +static int hook_in_list +( + const char * const name, + const char * const * const list +){ + int type; -// For each mobj type, a linked list to its thinker and collision hooks. -// That way, we don't have to iterate through all the hooks. -// We could do that with all other mobj hooks, but it would probably just be -// a waste of memory since they are only called occasionally. Probably... -static hook_p mobjthinkerhooks[NUMMOBJTYPES]; -static hook_p mobjcollidehooks[NUMMOBJTYPES]; + for (type = 0; list[type] != NULL; ++type) + { + if (strcmp(name, list[type]) == 0) + break; + } -// For each mobj type, a linked list for other mobj hooks -static hook_p mobjhooks[NUMMOBJTYPES]; + return type; +} -// A linked list for player hooks -static hook_p playerhooks; - -// A linked list for linedef executor hooks -static hook_p linedefexecutorhooks; - -// For other hooks, a unique linked list -hook_p roothook; - -static void PushHook(lua_State *L, hook_p hookp) +static void get_table(lua_State *L) { - lua_pushfstring(L, FMT_HOOKID, hookp->id); - lua_gettable(L, LUA_REGISTRYINDEX); + lua_pushvalue(L, -1); + lua_rawget(L, -3); + + if (lua_isnil(L, -1)) + { + lua_pop(L, 1); + lua_createtable(L, 1, 0); + lua_pushvalue(L, -2); + lua_pushvalue(L, -2); + lua_rawset(L, -5); + } + + lua_remove(L, -2); +} + +static void new_hook_table(lua_State *L, int *ref) +{ + if (*ref > 0) + lua_getref(L, *ref); + else + { + lua_newtable(L); + lua_pushvalue(L, -1); + *ref = luaL_ref(L, LUA_REGISTRYINDEX); + } +} + +static void add_hook(lua_State *L, int id) +{ + lua_pushnumber(L, 1 + id); + lua_rawseti(L, -2, 1 + lua_objlen(L, -2)); +} + +static void add_mobj_hook(lua_State *L, int hook_type, int id) +{ + mobjtype_t mobj_type = luaL_optnumber(L, 3, MT_NULL); + + luaL_argcheck(L, mobj_type < NUMMOBJTYPES, 3, "invalid mobjtype_t"); + + new_hook_table(L, &mobjHookRefs[mobj_type][hook_type]); + add_hook(L, id); +} + +static void add_string_hook(lua_State *L, int type, int id) +{ + stringhook_t * hook = &stringHooks[type]; + + char * string = NULL; + + switch (type) + { + case String_Hook(BotAI): + case String_Hook(ShouldJingleContinue): + if (lua_isstring(L, 3)) + { // lowercase copy + string = Z_StrDup(lua_tostring(L, 3)); + strlwr(string); + } + break; + + case String_Hook(LinedefExecute): + string = Z_StrDup(luaL_checkstring(L, 3)); + strupr(string); + break; + } + + new_hook_table(L, &hook->ref); + + if (string) + { + lua_pushstring(L, string); + get_table(L); + add_hook(L, id); + } + else + { + lua_pushnumber(L, 1 + id); + lua_rawseti(L, -2, ++hook->numGeneric); + } } // Takes hook, function, and additional arguments (mobj type to act on, etc.) static int lib_addHook(lua_State *L) { - static struct hook_s hook = {NULL, 0, 0, {0}, false}; - static UINT32 nextid; - hook_p hookp, *lastp; + static int nextid; - hook.type = luaL_checkoption(L, 1, NULL, hookNames); - lua_remove(L, 1); - - luaL_checktype(L, 1, LUA_TFUNCTION); + const char * name; + int type; if (!lua_lumploading) return luaL_error(L, "This function cannot be called from within a hook or coroutine!"); - switch(hook.type) + name = luaL_checkstring(L, 1); + luaL_checktype(L, 2, LUA_TFUNCTION); + + /* this is a very special case */ + if (( type = hook_in_list(name, stringHookNames) ) < String_Hook(MAX)) { - // Take a mobjtype enum which this hook is specifically for. - case hook_MobjSpawn: - case hook_MobjCollide: - case hook_MobjLineCollide: - case hook_MobjMoveCollide: - case hook_TouchSpecial: - case hook_MobjFuse: - case hook_MobjThinker: - case hook_BossThinker: - case hook_ShouldDamage: - case hook_MobjDamage: - case hook_MobjDeath: - case hook_BossDeath: - case hook_MobjRemoved: - case hook_HurtMsg: - case hook_MobjMoveBlocked: - case hook_MapThingSpawn: - case hook_FollowMobj: - hook.s.mt = MT_NULL; - if (lua_isnumber(L, 2)) - hook.s.mt = lua_tonumber(L, 2); - luaL_argcheck(L, hook.s.mt < NUMMOBJTYPES, 2, "invalid mobjtype_t"); - break; - case hook_BotAI: - case hook_ShouldJingleContinue: - hook.s.str = NULL; - if (lua_isstring(L, 2)) - { // lowercase copy - hook.s.str = Z_StrDup(lua_tostring(L, 2)); - strlwr(hook.s.str); - } - break; - case hook_LinedefExecute: // Linedef executor functions - hook.s.str = Z_StrDup(luaL_checkstring(L, 2)); - strupr(hook.s.str); - break; - default: - break; + add_string_hook(L, type, nextid); } - lua_settop(L, 1); // lua stack contains only the function now. - - hooksAvailable[hook.type/8] |= 1<<(hook.type%8); - - // set hook.id to the highest id + 1 - hook.id = nextid++; - - // Special cases for some hook types (see the comments above mobjthinkerhooks declaration) - switch(hook.type) + else if (( type = hook_in_list(name, mobjHookNames) ) < Mobj_Hook(MAX)) { - case hook_MobjThinker: - lastp = &mobjthinkerhooks[hook.s.mt]; - break; - case hook_MobjCollide: - case hook_MobjLineCollide: - case hook_MobjMoveCollide: - lastp = &mobjcollidehooks[hook.s.mt]; - break; - case hook_MobjSpawn: - case hook_TouchSpecial: - case hook_MobjFuse: - case hook_BossThinker: - case hook_ShouldDamage: - case hook_MobjDamage: - case hook_MobjDeath: - case hook_BossDeath: - case hook_MobjRemoved: - case hook_MobjMoveBlocked: - case hook_MapThingSpawn: - case hook_FollowMobj: - lastp = &mobjhooks[hook.s.mt]; - break; - case hook_JumpSpecial: - case hook_AbilitySpecial: - case hook_SpinSpecial: - case hook_JumpSpinSpecial: - case hook_PlayerSpawn: - case hook_PlayerCanDamage: - case hook_TeamSwitch: - case hook_ViewpointSwitch: - case hook_SeenPlayer: - case hook_ShieldSpawn: - case hook_ShieldSpecial: - case hook_PlayerThink: - lastp = &playerhooks; - break; - case hook_LinedefExecute: - lastp = &linedefexecutorhooks; - break; - default: - lastp = &roothook; - break; + add_mobj_hook(L, type, nextid); + } + else if (( type = hook_in_list(name, hookNames) ) < Hook(MAX)) + { + new_hook_table(L, &hookRefs[type]); + add_hook(L, nextid); + } + else + { + return luaL_argerror(L, 1, lua_pushfstring(L, "invalid hook " LUA_QS, name)); } - // iterate the hook metadata structs - // set lastp to the last hook struct's "next" pointer. - for (hookp = *lastp; hookp; hookp = hookp->next) - lastp = &hookp->next; - // allocate a permanent memory struct to stuff hook. - hookp = ZZ_Alloc(sizeof(struct hook_s)); - memcpy(hookp, &hook, sizeof(struct hook_s)); - // tack it onto the end of the linked list. - *lastp = hookp; + if (!(nextid & 7)) + { + Z_Realloc(hooksErrored, + BIT_ARRAY_LENGTH (nextid + 1) * sizeof *hooksErrored, + PU_STATIC, &hooksErrored); + hooksErrored[nextid >> 3] = 0; + } // set the hook function in the registry. - lua_pushfstring(L, FMT_HOOKID, hook.id); - lua_pushvalue(L, 1); - lua_settable(L, LUA_REGISTRYINDEX); + lua_getref(L, hookReg); + lua_pushvalue(L, 2);/* the function */ + lua_rawseti(L, -2, ++nextid); + return 0; } int LUA_HookLib(lua_State *L) { - memset(hooksAvailable,0,sizeof(UINT8[(hook_MAX/8)+1])); - roothook = NULL; + new_hook_table(L, &hookReg); lua_register(L, "addHook", lib_addHook); return 0; } -boolean LUAh_MobjHook(mobj_t *mo, enum hook which) +typedef struct Hook_State Hook_State; +typedef void (*Hook_Callback)(Hook_State *); + +struct Hook_State { + int status;/* return status to calling function */ + void * userdata; + int ref;/* ref for primary hook table */ + int hook_type;/* Hook or Hook(MAX) + Mobj_Hook */ + mobjtype_t mobj_type; + 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 function from registry */ + int values;/* num arguments passed to hook */ + int results;/* num values returned by hook */ + Hook_Callback results_handler;/* callback when hook successfully returns */ +}; + +enum { + HINDEX = 1,/* hook registry */ + EINDEX = 2,/* error handler */ + SINDEX = 3,/* string itself is pushed in case of string hook */ +}; + +static void push_error_handler(void) { - hook_p hookp; - boolean hooked = false; - if (!gL || !(hooksAvailable[which/8] & (1<<(which%8)))) - return false; - - I_Assert(mo->type < NUMMOBJTYPES); - - if (!(mobjhooks[MT_NULL] || mobjhooks[mo->type])) - return false; - - lua_settop(gL, 0); lua_pushcfunction(gL, LUA_GetErrorMessage); +} - // Look for all generic mobj hooks - for (hookp = mobjhooks[MT_NULL]; hookp; hookp = hookp->next) +/* repush hook string */ +static void push_string(void) +{ + lua_pushvalue(gL, SINDEX); +} + +static boolean start_hook_stack(void) +{ + lua_settop(gL, 0); + lua_getref(gL, hookReg); + push_error_handler(); + return true; +} + +static boolean init_hook_type +( + Hook_State * hook, + int status, + int hook_type, + mobjtype_t mobj_type, + const char * string, + int ref +){ + boolean ready; + + hook->status = status; + + if (mobj_type > 0) + ready = mobj_hook_available(hook_type, mobj_type); + else + ready = ref > 0; + + if (ready) { - if (hookp->type != which) - continue; + hook->ref = ref; + hook->hook_type = hook_type; + hook->mobj_type = mobj_type; + hook->string = string; + return start_hook_stack(); + } + else + return false; +} - ps_lua_mobjhooks++; - if (lua_gettop(gL) == 1) - LUA_PushUserdata(gL, mo, META_MOBJ); - PushHook(gL, hookp); - lua_pushvalue(gL, -2); - if (lua_pcall(gL, 1, 1, 1)) { - if (!hookp->error || cv_debug & DBG_LUA) - CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); - lua_pop(gL, 1); - hookp->error = true; - continue; +static boolean prepare_hook +( + Hook_State * hook, + int default_status, + int hook_type +){ + return init_hook_type(hook, default_status, + hook_type, 0, NULL, + hookRefs[hook_type]); +} + +static boolean prepare_mobj_hook +( + Hook_State * hook, + int default_status, + int hook_type, + mobjtype_t mobj_type +){ + return init_hook_type(hook, default_status, + hook_type, mobj_type, NULL, + mobjHookRefs[mobj_type][hook_type]); +} + +static boolean prepare_string_hook +( + Hook_State * hook, + int default_status, + int hook_type, + const char * string +){ + if (init_hook_type(hook, default_status, + hook_type, 0, string, + stringHooks[hook_type].ref)) + { + lua_pushstring(gL, string); + return true; + } + else + return false; +} + +static void init_hook_call +( + Hook_State * hook, + int values, + int results, + Hook_Callback results_handler +){ + hook->top = lua_gettop(gL); + hook->values = values; + hook->results = results; + hook->results_handler = results_handler; +} + +static void get_hook_table(Hook_State *hook) +{ + lua_getref(gL, hook->ref); +} + +static void get_hook(Hook_State *hook, int n) +{ + lua_rawgeti(gL, -1, n); + hook->id = lua_tonumber(gL, -1) - 1; + lua_rawget(gL, HINDEX); +} + +static int call_single_hook_no_copy(Hook_State *hook) +{ + if (lua_pcall(gL, hook->values, hook->results, EINDEX) == 0) + { + if (hook->results > 0) + { + (*hook->results_handler)(hook); + lua_pop(gL, hook->results); + } + } + else + { + /* print the error message once */ + if (cv_debug & DBG_LUA || !in_bit_array(hooksErrored, hook->id)) + { + CONS_Alert(CONS_WARNING, "%s\n", lua_tostring(gL, -1)); + set_bit_array(hooksErrored, hook->id); } - if (lua_toboolean(gL, -1)) - hooked = true; lua_pop(gL, 1); } - for (hookp = mobjhooks[mo->type]; hookp; hookp = hookp->next) - { - if (hookp->type != which) - continue; + return 1; +} - ps_lua_mobjhooks++; - if (lua_gettop(gL) == 1) - LUA_PushUserdata(gL, mo, META_MOBJ); - PushHook(gL, hookp); - lua_pushvalue(gL, -2); - if (lua_pcall(gL, 1, 1, 1)) { - if (!hookp->error || cv_debug & DBG_LUA) - CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); - lua_pop(gL, 1); - hookp->error = true; - continue; - } +static int call_single_hook(Hook_State *hook) +{ + int i; + + for (i = -(hook->values) + 1; i <= 0; ++i) + lua_pushvalue(gL, hook->top + i); + + return call_single_hook_no_copy(hook); +} + +static int call_hook_table_for(Hook_State *hook, int n) +{ + int k; + + for (k = 1; k <= n; ++k) + { + get_hook(hook, k); + call_single_hook(hook); + } + + return n; +} + +static int call_hook_table(Hook_State *hook) +{ + return call_hook_table_for(hook, lua_objlen(gL, -1)); +} + +static int call_ref(Hook_State *hook, int ref) +{ + int calls; + + if (ref > 0) + { + lua_getref(gL, ref); + calls = call_hook_table(hook); + + return calls; + } + else + return 0; +} + +static int call_string_hooks(Hook_State *hook) +{ + const int numGeneric = stringHooks[hook->hook_type].numGeneric; + + int calls = 0; + + get_hook_table(hook); + + /* call generic string hooks first */ + calls += call_hook_table_for(hook, numGeneric); + + push_string(); + lua_rawget(gL, -2); + calls += call_hook_table(hook); + + return calls; +} + +static int call_generic_mobj_hooks(Hook_State *hook) +{ + const int ref = mobjHookRefs[MT_NULL][hook->hook_type]; + return call_ref(hook, ref); +} + +static int call_hooks +( + Hook_State * hook, + int values, + int results, + Hook_Callback results_handler +){ + int calls = 0; + + init_hook_call(hook, values, results, results_handler); + + if (hook->string) + { + calls += call_string_hooks(hook); + } + else + { + if (hook->mobj_type > 0) + calls += call_generic_mobj_hooks(hook); + + calls += call_ref(hook, hook->ref); + + if (hook->mobj_type > 0) + ps_lua_mobjhooks += calls; + } + + lua_settop(gL, 0); + + return calls; +} + +/* ========================================================================= + COMMON RESULT HANDLERS + ========================================================================= */ + +#define res_none NULL + +static void res_true(Hook_State *hook) +{ + if (lua_toboolean(gL, -1)) + hook->status = true; +} + +static void res_false(Hook_State *hook) +{ + if (!lua_isnil(gL, -1) && !lua_toboolean(gL, -1)) + hook->status = false; +} + +static void res_force(Hook_State *hook) +{ + if (!lua_isnil(gL, -1)) + { if (lua_toboolean(gL, -1)) - hooked = true; - lua_pop(gL, 1); + hook->status = 1; // Force yes + else + hook->status = 2; // Force no } - - lua_settop(gL, 0); - return hooked; } -boolean LUAh_PlayerHook(player_t *plr, enum hook which) +/* ========================================================================= + GENERALISED HOOKS + ========================================================================= */ + +int LUA_HookMobj(mobj_t *mobj, int hook_type) { - hook_p hookp; - boolean hooked = false; - if (!gL || !(hooksAvailable[which/8] & (1<<(which%8)))) - return false; - - lua_settop(gL, 0); - lua_pushcfunction(gL, LUA_GetErrorMessage); - - for (hookp = playerhooks; hookp; hookp = hookp->next) + Hook_State hook; + if (prepare_mobj_hook(&hook, false, hook_type, mobj->type)) { - if (hookp->type != which) - continue; - - ps_lua_mobjhooks++; - if (lua_gettop(gL) == 1) - LUA_PushUserdata(gL, plr, META_PLAYER); - PushHook(gL, hookp); - lua_pushvalue(gL, -2); - if (lua_pcall(gL, 1, 1, 1)) { - if (!hookp->error || cv_debug & DBG_LUA) - CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); - lua_pop(gL, 1); - hookp->error = true; - continue; - } - if (lua_toboolean(gL, -1)) - hooked = true; - lua_pop(gL, 1); + LUA_PushUserdata(gL, mobj, META_MOBJ); + call_hooks(&hook, 1, 1, res_true); } - - lua_settop(gL, 0); - return hooked; + return hook.status; } -// Hook for map change (before load) -void LUAh_MapChange(INT16 mapnumber) +int LUA_Hook2Mobj(mobj_t *t1, mobj_t *t2, int hook_type) { - hook_p hookp; - if (!gL || !(hooksAvailable[hook_MapChange/8] & (1<<(hook_MapChange%8)))) - return; - - lua_settop(gL, 0); - lua_pushcfunction(gL, LUA_GetErrorMessage); - lua_pushinteger(gL, mapnumber); - - for (hookp = roothook; hookp; hookp = hookp->next) + Hook_State hook; + if (prepare_mobj_hook(&hook, 0, hook_type, t1->type)) { - if (hookp->type != hook_MapChange) - continue; - - PushHook(gL, hookp); - lua_pushvalue(gL, -2); - if (lua_pcall(gL, 1, 0, 1)) { - CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); - lua_pop(gL, 1); - } + LUA_PushUserdata(gL, t1, META_MOBJ); + LUA_PushUserdata(gL, t2, META_MOBJ); + call_hooks(&hook, 2, 1, res_force); } - - lua_settop(gL, 0); + return hook.status; } -// Hook for map load -void LUAh_MapLoad(void) +void LUA_Hook(int type) { - hook_p hookp; - if (!gL || !(hooksAvailable[hook_MapLoad/8] & (1<<(hook_MapLoad%8)))) - return; + Hook_State hook; + if (prepare_hook(&hook, 0, type)) + call_hooks(&hook, 0, 0, res_none); +} - lua_settop(gL, 0); - lua_pushcfunction(gL, LUA_GetErrorMessage); - lua_pushinteger(gL, gamemap); - - for (hookp = roothook; hookp; hookp = hookp->next) +void LUA_HookInt(INT32 number, int hook_type) +{ + Hook_State hook; + if (prepare_hook(&hook, 0, hook_type)) { - if (hookp->type != hook_MapLoad) - continue; - - PushHook(gL, hookp); - lua_pushvalue(gL, -2); - if (lua_pcall(gL, 1, 0, 1)) { - CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); - lua_pop(gL, 1); - } + lua_pushinteger(gL, number); + call_hooks(&hook, 1, 0, res_none); } - - lua_settop(gL, 0); } -// Hook for Got_AddPlayer -void LUAh_PlayerJoin(int playernum) +int LUA_HookPlayer(player_t *player, int hook_type) { - hook_p hookp; - if (!gL || !(hooksAvailable[hook_PlayerJoin/8] & (1<<(hook_PlayerJoin%8)))) - return; - - lua_settop(gL, 0); - lua_pushcfunction(gL, LUA_GetErrorMessage); - lua_pushinteger(gL, playernum); - - for (hookp = roothook; hookp; hookp = hookp->next) + Hook_State hook; + if (prepare_hook(&hook, false, hook_type)) { - if (hookp->type != hook_PlayerJoin) - continue; - - PushHook(gL, hookp); - lua_pushvalue(gL, -2); - if (lua_pcall(gL, 1, 0, 1)) { - CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); - lua_pop(gL, 1); - } + LUA_PushUserdata(gL, player, META_PLAYER); + call_hooks(&hook, 1, 1, res_true); } - - lua_settop(gL, 0); + return hook.status; } -// Hook for frame (before mobj and player thinkers) -void LUAh_PreThinkFrame(void) +int LUA_HookTiccmd(player_t *player, ticcmd_t *cmd, int hook_type) { - hook_p hookp; - if (!gL || !(hooksAvailable[hook_PreThinkFrame/8] & (1<<(hook_PreThinkFrame%8)))) - return; - - lua_pushcfunction(gL, LUA_GetErrorMessage); - - for (hookp = roothook; hookp; hookp = hookp->next) + Hook_State hook; + if (prepare_hook(&hook, false, hook_type)) { - if (hookp->type != hook_PreThinkFrame) - continue; + LUA_PushUserdata(gL, player, META_PLAYER); + LUA_PushUserdata(gL, cmd, META_TICCMD); - PushHook(gL, hookp); - if (lua_pcall(gL, 0, 0, 1)) { - if (!hookp->error || cv_debug & DBG_LUA) - CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); - lua_pop(gL, 1); - hookp->error = true; - } + if (hook_type == Hook(PlayerCmd)) + hook_cmd_running = true; + + call_hooks(&hook, 2, 1, res_true); + + if (hook_type == Hook(PlayerCmd)) + hook_cmd_running = false; } - - lua_pop(gL, 1); // Pop error handler + return hook.status; } -// Hook for frame (after mobj and player thinkers) -void LUAh_ThinkFrame(void) +/* ========================================================================= + SPECIALIZED HOOKS + ========================================================================= */ + +void LUA_HookThinkFrame(void) { - hook_p hookp; // variables used by perf stats int hook_index = 0; int time_taken = 0; - if (!gL || !(hooksAvailable[hook_ThinkFrame/8] & (1<<(hook_ThinkFrame%8)))) - return; - lua_pushcfunction(gL, LUA_GetErrorMessage); + Hook_State hook; - for (hookp = roothook; hookp; hookp = hookp->next) + int n; + int k; + + if (prepare_hook(&hook, 0, Hook(ThinkFrame))) { - if (hookp->type != hook_ThinkFrame) - continue; + init_hook_call(&hook, 0, 0, res_none); - if (cv_perfstats.value == 3) - time_taken = I_GetTimeMicros(); - PushHook(gL, hookp); - if (lua_pcall(gL, 0, 0, 1)) { - if (!hookp->error || cv_debug & DBG_LUA) - CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); - lua_pop(gL, 1); - hookp->error = true; - } - if (cv_perfstats.value == 3) + get_hook_table(&hook); + n = lua_objlen(gL, -1); + + for (k = 1; k <= n; ++k) { - lua_Debug ar; - time_taken = I_GetTimeMicros() - time_taken; - // we need the function, let's just retrieve it again - PushHook(gL, hookp); - lua_getinfo(gL, ">S", &ar); - PS_SetThinkFrameHookInfo(hook_index, time_taken, ar.short_src); - hook_index++; - } - } + get_hook(&hook, k); - lua_pop(gL, 1); // Pop error handler -} - -// Hook for frame (at end of tick, ie after overlays, precipitation, specials) -void LUAh_PostThinkFrame(void) -{ - hook_p hookp; - if (!gL || !(hooksAvailable[hook_PostThinkFrame/8] & (1<<(hook_PostThinkFrame%8)))) - return; - - lua_pushcfunction(gL, LUA_GetErrorMessage); - - for (hookp = roothook; hookp; hookp = hookp->next) - { - if (hookp->type != hook_PostThinkFrame) - continue; - - PushHook(gL, hookp); - if (lua_pcall(gL, 0, 0, 1)) { - if (!hookp->error || cv_debug & DBG_LUA) - CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); - lua_pop(gL, 1); - hookp->error = true; - } - } - - lua_pop(gL, 1); // Pop error handler -} - -// Hook for mobj collisions -UINT8 LUAh_MobjCollideHook(mobj_t *thing1, mobj_t *thing2, enum hook which) -{ - hook_p hookp; - UINT8 shouldCollide = 0; // 0 = default, 1 = force yes, 2 = force no. - if (!gL || !(hooksAvailable[which/8] & (1<<(which%8)))) - return 0; - - I_Assert(thing1->type < NUMMOBJTYPES); - - if (!(mobjcollidehooks[MT_NULL] || mobjcollidehooks[thing1->type])) - return 0; - - lua_settop(gL, 0); - lua_pushcfunction(gL, LUA_GetErrorMessage); - - // Look for all generic mobj collision hooks - for (hookp = mobjcollidehooks[MT_NULL]; hookp; hookp = hookp->next) - { - if (hookp->type != which) - continue; - - ps_lua_mobjhooks++; - if (lua_gettop(gL) == 1) - { - LUA_PushUserdata(gL, thing1, META_MOBJ); - LUA_PushUserdata(gL, thing2, META_MOBJ); - } - PushHook(gL, hookp); - lua_pushvalue(gL, -3); - lua_pushvalue(gL, -3); - if (lua_pcall(gL, 2, 1, 1)) { - if (!hookp->error || cv_debug & DBG_LUA) - CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); - lua_pop(gL, 1); - hookp->error = true; - continue; - } - if (!lua_isnil(gL, -1)) - { // if nil, leave shouldCollide = 0. - if (lua_toboolean(gL, -1)) - shouldCollide = 1; // Force yes - else - shouldCollide = 2; // Force no - } - lua_pop(gL, 1); - } - - for (hookp = mobjcollidehooks[thing1->type]; hookp; hookp = hookp->next) - { - if (hookp->type != which) - continue; - - ps_lua_mobjhooks++; - if (lua_gettop(gL) == 1) - { - LUA_PushUserdata(gL, thing1, META_MOBJ); - LUA_PushUserdata(gL, thing2, META_MOBJ); - } - PushHook(gL, hookp); - lua_pushvalue(gL, -3); - lua_pushvalue(gL, -3); - if (lua_pcall(gL, 2, 1, 1)) { - if (!hookp->error || cv_debug & DBG_LUA) - CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); - lua_pop(gL, 1); - hookp->error = true; - continue; - } - if (!lua_isnil(gL, -1)) - { // if nil, leave shouldCollide = 0. - if (lua_toboolean(gL, -1)) - shouldCollide = 1; // Force yes - else - shouldCollide = 2; // Force no - } - lua_pop(gL, 1); - } - - lua_settop(gL, 0); - return shouldCollide; -} - -UINT8 LUAh_MobjLineCollideHook(mobj_t *thing, line_t *line, enum hook which) -{ - hook_p hookp; - UINT8 shouldCollide = 0; // 0 = default, 1 = force yes, 2 = force no. - if (!gL || !(hooksAvailable[which/8] & (1<<(which%8)))) - return 0; - - I_Assert(thing->type < NUMMOBJTYPES); - - if (!(mobjcollidehooks[MT_NULL] || mobjcollidehooks[thing->type])) - return 0; - - lua_settop(gL, 0); - lua_pushcfunction(gL, LUA_GetErrorMessage); - - // Look for all generic mobj collision hooks - for (hookp = mobjcollidehooks[MT_NULL]; hookp; hookp = hookp->next) - { - if (hookp->type != which) - continue; - - ps_lua_mobjhooks++; - if (lua_gettop(gL) == 1) - { - LUA_PushUserdata(gL, thing, META_MOBJ); - LUA_PushUserdata(gL, line, META_LINE); - } - PushHook(gL, hookp); - lua_pushvalue(gL, -3); - lua_pushvalue(gL, -3); - if (lua_pcall(gL, 2, 1, 1)) { - if (!hookp->error || cv_debug & DBG_LUA) - CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); - lua_pop(gL, 1); - hookp->error = true; - continue; - } - if (!lua_isnil(gL, -1)) - { // if nil, leave shouldCollide = 0. - if (lua_toboolean(gL, -1)) - shouldCollide = 1; // Force yes - else - shouldCollide = 2; // Force no - } - lua_pop(gL, 1); - } - - for (hookp = mobjcollidehooks[thing->type]; hookp; hookp = hookp->next) - { - if (hookp->type != which) - continue; - - ps_lua_mobjhooks++; - if (lua_gettop(gL) == 1) - { - LUA_PushUserdata(gL, thing, META_MOBJ); - LUA_PushUserdata(gL, line, META_LINE); - } - PushHook(gL, hookp); - lua_pushvalue(gL, -3); - lua_pushvalue(gL, -3); - if (lua_pcall(gL, 2, 1, 1)) { - if (!hookp->error || cv_debug & DBG_LUA) - CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); - lua_pop(gL, 1); - hookp->error = true; - continue; - } - if (!lua_isnil(gL, -1)) - { // if nil, leave shouldCollide = 0. - if (lua_toboolean(gL, -1)) - shouldCollide = 1; // Force yes - else - shouldCollide = 2; // Force no - } - lua_pop(gL, 1); - } - - lua_settop(gL, 0); - return shouldCollide; -} - -// Hook for mobj thinkers -boolean LUAh_MobjThinker(mobj_t *mo) -{ - hook_p hookp; - boolean hooked = false; - if (!gL || !(hooksAvailable[hook_MobjThinker/8] & (1<<(hook_MobjThinker%8)))) - return false; - - I_Assert(mo->type < NUMMOBJTYPES); - - if (!(mobjthinkerhooks[MT_NULL] || mobjthinkerhooks[mo->type])) - return false; - - lua_settop(gL, 0); - lua_pushcfunction(gL, LUA_GetErrorMessage); - - // Look for all generic mobj thinker hooks - for (hookp = mobjthinkerhooks[MT_NULL]; hookp; hookp = hookp->next) - { - ps_lua_mobjhooks++; - if (lua_gettop(gL) == 1) - LUA_PushUserdata(gL, mo, META_MOBJ); - PushHook(gL, hookp); - lua_pushvalue(gL, -2); - if (lua_pcall(gL, 1, 1, 1)) { - if (!hookp->error || cv_debug & DBG_LUA) - CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); - lua_pop(gL, 1); - hookp->error = true; - continue; - } - if (lua_toboolean(gL, -1)) - hooked = true; - lua_pop(gL, 1); - } - - for (hookp = mobjthinkerhooks[mo->type]; hookp; hookp = hookp->next) - { - ps_lua_mobjhooks++; - if (lua_gettop(gL) == 1) - LUA_PushUserdata(gL, mo, META_MOBJ); - PushHook(gL, hookp); - lua_pushvalue(gL, -2); - if (lua_pcall(gL, 1, 1, 1)) { - if (!hookp->error || cv_debug & DBG_LUA) - CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); - lua_pop(gL, 1); - hookp->error = true; - continue; - } - if (lua_toboolean(gL, -1)) - hooked = true; - lua_pop(gL, 1); - } - - lua_settop(gL, 0); - return hooked; -} - -// Hook for P_TouchSpecialThing by mobj type -boolean LUAh_TouchSpecial(mobj_t *special, mobj_t *toucher) -{ - hook_p hookp; - boolean hooked = false; - if (!gL || !(hooksAvailable[hook_TouchSpecial/8] & (1<<(hook_TouchSpecial%8)))) - return false; - - I_Assert(special->type < NUMMOBJTYPES); - - if (!(mobjhooks[MT_NULL] || mobjhooks[special->type])) - return false; - - lua_settop(gL, 0); - lua_pushcfunction(gL, LUA_GetErrorMessage); - - // Look for all generic touch special hooks - for (hookp = mobjhooks[MT_NULL]; hookp; hookp = hookp->next) - { - if (hookp->type != hook_TouchSpecial) - continue; - - ps_lua_mobjhooks++; - if (lua_gettop(gL) == 1) - { - LUA_PushUserdata(gL, special, META_MOBJ); - LUA_PushUserdata(gL, toucher, META_MOBJ); - } - PushHook(gL, hookp); - lua_pushvalue(gL, -3); - lua_pushvalue(gL, -3); - if (lua_pcall(gL, 2, 1, 1)) { - if (!hookp->error || cv_debug & DBG_LUA) - CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); - lua_pop(gL, 1); - hookp->error = true; - continue; - } - if (lua_toboolean(gL, -1)) - hooked = true; - lua_pop(gL, 1); - } - - for (hookp = mobjhooks[special->type]; hookp; hookp = hookp->next) - { - if (hookp->type != hook_TouchSpecial) - continue; - - ps_lua_mobjhooks++; - if (lua_gettop(gL) == 1) - { - LUA_PushUserdata(gL, special, META_MOBJ); - LUA_PushUserdata(gL, toucher, META_MOBJ); - } - PushHook(gL, hookp); - lua_pushvalue(gL, -3); - lua_pushvalue(gL, -3); - if (lua_pcall(gL, 2, 1, 1)) { - if (!hookp->error || cv_debug & DBG_LUA) - CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); - lua_pop(gL, 1); - hookp->error = true; - continue; - } - if (lua_toboolean(gL, -1)) - hooked = true; - lua_pop(gL, 1); - } - - lua_settop(gL, 0); - return hooked; -} - -// Hook for P_DamageMobj by mobj type (Should mobj take damage?) -UINT8 LUAh_ShouldDamage(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 damage, UINT8 damagetype) -{ - hook_p hookp; - UINT8 shouldDamage = 0; // 0 = default, 1 = force yes, 2 = force no. - if (!gL || !(hooksAvailable[hook_ShouldDamage/8] & (1<<(hook_ShouldDamage%8)))) - return 0; - - I_Assert(target->type < NUMMOBJTYPES); - - if (!(mobjhooks[MT_NULL] || mobjhooks[target->type])) - return 0; - - lua_settop(gL, 0); - lua_pushcfunction(gL, LUA_GetErrorMessage); - - // Look for all generic should damage hooks - for (hookp = mobjhooks[MT_NULL]; hookp; hookp = hookp->next) - { - if (hookp->type != hook_ShouldDamage) - continue; - - ps_lua_mobjhooks++; - if (lua_gettop(gL) == 1) - { - LUA_PushUserdata(gL, target, META_MOBJ); - LUA_PushUserdata(gL, inflictor, META_MOBJ); - LUA_PushUserdata(gL, source, META_MOBJ); - lua_pushinteger(gL, damage); - lua_pushinteger(gL, damagetype); - } - PushHook(gL, hookp); - lua_pushvalue(gL, -6); - lua_pushvalue(gL, -6); - lua_pushvalue(gL, -6); - lua_pushvalue(gL, -6); - lua_pushvalue(gL, -6); - if (lua_pcall(gL, 5, 1, 1)) { - if (!hookp->error || cv_debug & DBG_LUA) - CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); - lua_pop(gL, 1); - hookp->error = true; - continue; - } - if (!lua_isnil(gL, -1)) - { - if (lua_toboolean(gL, -1)) - shouldDamage = 1; // Force yes - else - shouldDamage = 2; // Force no - } - lua_pop(gL, 1); - } - - for (hookp = mobjhooks[target->type]; hookp; hookp = hookp->next) - { - if (hookp->type != hook_ShouldDamage) - continue; - ps_lua_mobjhooks++; - if (lua_gettop(gL) == 1) - { - LUA_PushUserdata(gL, target, META_MOBJ); - LUA_PushUserdata(gL, inflictor, META_MOBJ); - LUA_PushUserdata(gL, source, META_MOBJ); - lua_pushinteger(gL, damage); - lua_pushinteger(gL, damagetype); - } - PushHook(gL, hookp); - lua_pushvalue(gL, -6); - lua_pushvalue(gL, -6); - lua_pushvalue(gL, -6); - lua_pushvalue(gL, -6); - lua_pushvalue(gL, -6); - if (lua_pcall(gL, 5, 1, 1)) { - if (!hookp->error || cv_debug & DBG_LUA) - CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); - lua_pop(gL, 1); - hookp->error = true; - continue; - } - if (!lua_isnil(gL, -1)) - { - if (lua_toboolean(gL, -1)) - shouldDamage = 1; // Force yes - else - shouldDamage = 2; // Force no - } - lua_pop(gL, 1); - } - - lua_settop(gL, 0); - return shouldDamage; -} - -// Hook for P_DamageMobj by mobj type (Mobj actually takes damage!) -boolean LUAh_MobjDamage(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 damage, UINT8 damagetype) -{ - hook_p hookp; - boolean hooked = false; - if (!gL || !(hooksAvailable[hook_MobjDamage/8] & (1<<(hook_MobjDamage%8)))) - return false; - - I_Assert(target->type < NUMMOBJTYPES); - - if (!(mobjhooks[MT_NULL] || mobjhooks[target->type])) - return false; - - lua_settop(gL, 0); - lua_pushcfunction(gL, LUA_GetErrorMessage); - - // Look for all generic mobj damage hooks - for (hookp = mobjhooks[MT_NULL]; hookp; hookp = hookp->next) - { - if (hookp->type != hook_MobjDamage) - continue; - - ps_lua_mobjhooks++; - if (lua_gettop(gL) == 1) - { - LUA_PushUserdata(gL, target, META_MOBJ); - LUA_PushUserdata(gL, inflictor, META_MOBJ); - LUA_PushUserdata(gL, source, META_MOBJ); - lua_pushinteger(gL, damage); - lua_pushinteger(gL, damagetype); - } - PushHook(gL, hookp); - lua_pushvalue(gL, -6); - lua_pushvalue(gL, -6); - lua_pushvalue(gL, -6); - lua_pushvalue(gL, -6); - lua_pushvalue(gL, -6); - if (lua_pcall(gL, 5, 1, 1)) { - if (!hookp->error || cv_debug & DBG_LUA) - CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); - lua_pop(gL, 1); - hookp->error = true; - continue; - } - if (lua_toboolean(gL, -1)) - hooked = true; - lua_pop(gL, 1); - } - - for (hookp = mobjhooks[target->type]; hookp; hookp = hookp->next) - { - if (hookp->type != hook_MobjDamage) - continue; - - ps_lua_mobjhooks++; - if (lua_gettop(gL) == 1) - { - LUA_PushUserdata(gL, target, META_MOBJ); - LUA_PushUserdata(gL, inflictor, META_MOBJ); - LUA_PushUserdata(gL, source, META_MOBJ); - lua_pushinteger(gL, damage); - lua_pushinteger(gL, damagetype); - } - PushHook(gL, hookp); - lua_pushvalue(gL, -6); - lua_pushvalue(gL, -6); - lua_pushvalue(gL, -6); - lua_pushvalue(gL, -6); - lua_pushvalue(gL, -6); - if (lua_pcall(gL, 5, 1, 1)) { - if (!hookp->error || cv_debug & DBG_LUA) - CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); - lua_pop(gL, 1); - hookp->error = true; - continue; - } - if (lua_toboolean(gL, -1)) - hooked = true; - lua_pop(gL, 1); - } - - lua_settop(gL, 0); - return hooked; -} - -// Hook for P_KillMobj by mobj type -boolean LUAh_MobjDeath(mobj_t *target, mobj_t *inflictor, mobj_t *source, UINT8 damagetype) -{ - hook_p hookp; - boolean hooked = false; - if (!gL || !(hooksAvailable[hook_MobjDeath/8] & (1<<(hook_MobjDeath%8)))) - return false; - - I_Assert(target->type < NUMMOBJTYPES); - - if (!(mobjhooks[MT_NULL] || mobjhooks[target->type])) - return false; - - lua_settop(gL, 0); - lua_pushcfunction(gL, LUA_GetErrorMessage); - - // Look for all generic mobj death hooks - for (hookp = mobjhooks[MT_NULL]; hookp; hookp = hookp->next) - { - if (hookp->type != hook_MobjDeath) - continue; - - ps_lua_mobjhooks++; - if (lua_gettop(gL) == 1) - { - LUA_PushUserdata(gL, target, META_MOBJ); - LUA_PushUserdata(gL, inflictor, META_MOBJ); - LUA_PushUserdata(gL, source, META_MOBJ); - lua_pushinteger(gL, damagetype); - } - PushHook(gL, hookp); - lua_pushvalue(gL, -5); - lua_pushvalue(gL, -5); - lua_pushvalue(gL, -5); - lua_pushvalue(gL, -5); - if (lua_pcall(gL, 4, 1, 1)) { - if (!hookp->error || cv_debug & DBG_LUA) - CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); - lua_pop(gL, 1); - hookp->error = true; - continue; - } - if (lua_toboolean(gL, -1)) - hooked = true; - lua_pop(gL, 1); - } - - for (hookp = mobjhooks[target->type]; hookp; hookp = hookp->next) - { - if (hookp->type != hook_MobjDeath) - continue; - - ps_lua_mobjhooks++; - if (lua_gettop(gL) == 1) - { - LUA_PushUserdata(gL, target, META_MOBJ); - LUA_PushUserdata(gL, inflictor, META_MOBJ); - LUA_PushUserdata(gL, source, META_MOBJ); - lua_pushinteger(gL, damagetype); - } - PushHook(gL, hookp); - lua_pushvalue(gL, -5); - lua_pushvalue(gL, -5); - lua_pushvalue(gL, -5); - lua_pushvalue(gL, -5); - if (lua_pcall(gL, 4, 1, 1)) { - if (!hookp->error || cv_debug & DBG_LUA) - CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); - lua_pop(gL, 1); - hookp->error = true; - continue; - } - if (lua_toboolean(gL, -1)) - hooked = true; - lua_pop(gL, 1); - } - - lua_settop(gL, 0); - return hooked; -} - -// Hook for B_BuildTiccmd -boolean LUAh_BotTiccmd(player_t *bot, ticcmd_t *cmd) -{ - hook_p hookp; - boolean hooked = false; - if (!gL || !(hooksAvailable[hook_BotTiccmd/8] & (1<<(hook_BotTiccmd%8)))) - return false; - - lua_settop(gL, 0); - lua_pushcfunction(gL, LUA_GetErrorMessage); - - for (hookp = roothook; hookp; hookp = hookp->next) - { - if (hookp->type != hook_BotTiccmd) - continue; - - if (lua_gettop(gL) == 1) - { - LUA_PushUserdata(gL, bot, META_PLAYER); - LUA_PushUserdata(gL, cmd, META_TICCMD); - } - PushHook(gL, hookp); - lua_pushvalue(gL, -3); - lua_pushvalue(gL, -3); - if (lua_pcall(gL, 2, 1, 1)) { - if (!hookp->error || cv_debug & DBG_LUA) - CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); - lua_pop(gL, 1); - hookp->error = true; - continue; - } - if (lua_toboolean(gL, -1)) - hooked = true; - lua_pop(gL, 1); - } - - lua_settop(gL, 0); - return hooked; -} - -// Hook for B_BuildTailsTiccmd by skin name -boolean LUAh_BotAI(mobj_t *sonic, mobj_t *tails, ticcmd_t *cmd) -{ - hook_p hookp; - boolean hooked = false; - if (!gL || !(hooksAvailable[hook_BotAI/8] & (1<<(hook_BotAI%8)))) - return false; - - lua_settop(gL, 0); - lua_pushcfunction(gL, LUA_GetErrorMessage); - - for (hookp = roothook; hookp; hookp = hookp->next) - { - if (hookp->type != hook_BotAI - || (hookp->s.str && strcmp(hookp->s.str, ((skin_t*)tails->skin)->name))) - continue; - - if (lua_gettop(gL) == 1) - { - LUA_PushUserdata(gL, sonic, META_MOBJ); - LUA_PushUserdata(gL, tails, META_MOBJ); - } - PushHook(gL, hookp); - lua_pushvalue(gL, -3); - lua_pushvalue(gL, -3); - if (lua_pcall(gL, 2, 8, 1)) { - if (!hookp->error || cv_debug & DBG_LUA) - CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); - lua_pop(gL, 1); - hookp->error = true; - continue; - } - - // This turns forward, backward, left, right, jump, and spin into a proper ticcmd for tails. - if (lua_istable(gL, 2+1)) { - boolean forward=false, backward=false, left=false, right=false, strafeleft=false, straferight=false, jump=false, spin=false; -#define CHECKFIELD(field) \ - lua_getfield(gL, 2+1, #field);\ - if (lua_toboolean(gL, -1))\ - field = true;\ - lua_pop(gL, 1); - - CHECKFIELD(forward) - CHECKFIELD(backward) - CHECKFIELD(left) - CHECKFIELD(right) - CHECKFIELD(strafeleft) - CHECKFIELD(straferight) - CHECKFIELD(jump) - CHECKFIELD(spin) -#undef CHECKFIELD - B_KeysToTiccmd(tails, cmd, forward, backward, left, right, strafeleft, straferight, jump, spin); - } else - B_KeysToTiccmd(tails, cmd, lua_toboolean(gL, 2+1), lua_toboolean(gL, 2+2), lua_toboolean(gL, 2+3), lua_toboolean(gL, 2+4), lua_toboolean(gL, 2+5), lua_toboolean(gL, 2+6), lua_toboolean(gL, 2+7), lua_toboolean(gL, 2+8)); - - lua_pop(gL, 8); - hooked = true; - } - - lua_settop(gL, 0); - return hooked; -} - -// Hook for B_CheckRespawn -boolean LUAh_BotRespawn(mobj_t *sonic, mobj_t *tails) -{ - hook_p hookp; - UINT8 shouldRespawn = 0; // 0 = default, 1 = force yes, 2 = force no. - if (!gL || !(hooksAvailable[hook_BotRespawn/8] & (1<<(hook_BotRespawn%8)))) - return false; - - lua_settop(gL, 0); - lua_pushcfunction(gL, LUA_GetErrorMessage); - - for (hookp = roothook; hookp; hookp = hookp->next) - { - if (hookp->type != hook_BotRespawn) - continue; - - if (lua_gettop(gL) == 1) - { - LUA_PushUserdata(gL, sonic, META_MOBJ); - LUA_PushUserdata(gL, tails, META_MOBJ); - } - PushHook(gL, hookp); - lua_pushvalue(gL, -3); - lua_pushvalue(gL, -3); - if (lua_pcall(gL, 2, 1, 1)) { - if (!hookp->error || cv_debug & DBG_LUA) - CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); - lua_pop(gL, 1); - hookp->error = true; - continue; - } - if (!lua_isnil(gL, -1)) - { - if (lua_toboolean(gL, -1)) - shouldRespawn = 1; // Force yes - else - shouldRespawn = 2; // Force no - } - lua_pop(gL, 1); - } - - lua_settop(gL, 0); - return shouldRespawn; -} - -// Hook for linedef executors -boolean LUAh_LinedefExecute(line_t *line, mobj_t *mo, sector_t *sector) -{ - hook_p hookp; - boolean hooked = false; - if (!gL || !(hooksAvailable[hook_LinedefExecute/8] & (1<<(hook_LinedefExecute%8)))) - return 0; - - lua_settop(gL, 0); - lua_pushcfunction(gL, LUA_GetErrorMessage); - - for (hookp = linedefexecutorhooks; hookp; hookp = hookp->next) - { - if (strcmp(hookp->s.str, line->stringargs[0])) - continue; - - ps_lua_mobjhooks++; - if (lua_gettop(gL) == 1) - { - LUA_PushUserdata(gL, line, META_LINE); - LUA_PushUserdata(gL, mo, META_MOBJ); - LUA_PushUserdata(gL, sector, META_SECTOR); - } - PushHook(gL, hookp); - lua_pushvalue(gL, -4); - lua_pushvalue(gL, -4); - lua_pushvalue(gL, -4); - if (lua_pcall(gL, 3, 0, 1)) { - CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); - lua_pop(gL, 1); - } - hooked = true; - } - - lua_settop(gL, 0); - return hooked; -} - - -boolean LUAh_PlayerMsg(int source, int target, int flags, char *msg) -{ - hook_p hookp; - boolean hooked = false; - if (!gL || !(hooksAvailable[hook_PlayerMsg/8] & (1<<(hook_PlayerMsg%8)))) - return false; - - lua_settop(gL, 0); - lua_pushcfunction(gL, LUA_GetErrorMessage); - - for (hookp = roothook; hookp; hookp = hookp->next) - { - if (hookp->type != hook_PlayerMsg) - continue; - - if (lua_gettop(gL) == 1) - { - LUA_PushUserdata(gL, &players[source], META_PLAYER); // Source player - if (flags & 2 /*HU_CSAY*/) { // csay TODO: make HU_CSAY accessible outside hu_stuff.c - lua_pushinteger(gL, 3); // type - lua_pushnil(gL); // target - } else if (target == -1) { // sayteam - lua_pushinteger(gL, 1); // type - lua_pushnil(gL); // target - } else if (target == 0) { // say - lua_pushinteger(gL, 0); // type - lua_pushnil(gL); // target - } else { // sayto - lua_pushinteger(gL, 2); // type - LUA_PushUserdata(gL, &players[target-1], META_PLAYER); // target + if (cv_perfstats.value == 3) + { + lua_pushvalue(gL, -1);/* need the function again */ + time_taken = I_GetTimeMicros(); } - lua_pushstring(gL, msg); // msg - } - PushHook(gL, hookp); - lua_pushvalue(gL, -5); - lua_pushvalue(gL, -5); - lua_pushvalue(gL, -5); - lua_pushvalue(gL, -5); - if (lua_pcall(gL, 4, 1, 1)) { - if (!hookp->error || cv_debug & DBG_LUA) - CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); - lua_pop(gL, 1); - hookp->error = true; - continue; - } - if (lua_toboolean(gL, -1)) - hooked = true; - lua_pop(gL, 1); - } - lua_settop(gL, 0); - return hooked; + call_single_hook(&hook); + + if (cv_perfstats.value == 3) + { + lua_Debug ar; + time_taken = I_GetTimeMicros() - time_taken; + lua_getinfo(gL, ">S", &ar); + PS_SetThinkFrameHookInfo(hook_index, time_taken, ar.short_src); + hook_index++; + } + } + + lua_settop(gL, 0); + } } - -// Hook for hurt messages -boolean LUAh_HurtMsg(player_t *player, mobj_t *inflictor, mobj_t *source, UINT8 damagetype) +int LUA_HookMobjLineCollide(mobj_t *mobj, line_t *line) { - hook_p hookp; - boolean hooked = false; - if (!gL || !(hooksAvailable[hook_HurtMsg/8] & (1<<(hook_HurtMsg%8)))) - return false; - - lua_settop(gL, 0); - lua_pushcfunction(gL, LUA_GetErrorMessage); - - for (hookp = roothook; hookp; hookp = hookp->next) + Hook_State hook; + if (prepare_mobj_hook(&hook, 0, Mobj_Hook(MobjLineCollide), mobj->type)) { - if (hookp->type != hook_HurtMsg - || (hookp->s.mt && !(inflictor && hookp->s.mt == inflictor->type))) - continue; + LUA_PushUserdata(gL, mobj, META_MOBJ); + LUA_PushUserdata(gL, line, META_LINE); + call_hooks(&hook, 2, 1, res_force); + } + return hook.status; +} - if (lua_gettop(gL) == 1) +int LUA_HookTouchSpecial(mobj_t *special, mobj_t *toucher) +{ + Hook_State hook; + if (prepare_mobj_hook(&hook, false, Mobj_Hook(TouchSpecial), special->type)) + { + LUA_PushUserdata(gL, special, META_MOBJ); + LUA_PushUserdata(gL, toucher, META_MOBJ); + call_hooks(&hook, 2, 1, res_true); + } + return hook.status; +} + +static int damage_hook +( + mobj_t *target, + mobj_t *inflictor, + mobj_t *source, + INT32 damage, + UINT8 damagetype, + int hook_type, + int values, + Hook_Callback results_handler +){ + Hook_State hook; + if (prepare_mobj_hook(&hook, 0, hook_type, target->type)) + { + LUA_PushUserdata(gL, target, META_MOBJ); + LUA_PushUserdata(gL, inflictor, META_MOBJ); + LUA_PushUserdata(gL, source, META_MOBJ); + if (values == 5) + lua_pushinteger(gL, damage); + lua_pushinteger(gL, damagetype); + call_hooks(&hook, values, 1, results_handler); + } + return hook.status; +} + +int LUA_HookShouldDamage(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 damage, UINT8 damagetype) +{ + return damage_hook(target, inflictor, source, damage, damagetype, + Mobj_Hook(ShouldDamage), 5, res_force); +} + +int LUA_HookMobjDamage(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 damage, UINT8 damagetype) +{ + return damage_hook(target, inflictor, source, damage, damagetype, + Mobj_Hook(MobjDamage), 5, res_true); +} + +int LUA_HookMobjDeath(mobj_t *target, mobj_t *inflictor, mobj_t *source, UINT8 damagetype) +{ + return damage_hook(target, inflictor, source, 0, damagetype, + Mobj_Hook(MobjDeath), 4, res_true); +} + +typedef struct { + mobj_t * tails; + ticcmd_t * cmd; +} BotAI_State; + +static boolean checkbotkey(const char *field) +{ + return lua_toboolean(gL, -1) && strcmp(lua_tostring(gL, -2), field) == 0; +} + +static void res_botai(Hook_State *hook) +{ + BotAI_State *botai = hook->userdata; + + int k[8]; + + int fields = 0; + + // This turns forward, backward, left, right, jump, and spin into a proper ticcmd for tails. + if (lua_istable(gL, -8)) { + lua_pushnil(gL); // key + while (lua_next(gL, -9)) { +#define check(n, f) (checkbotkey(f) ? (k[(n)-1] = 1) : 0) + if ( + check(1, "forward") || check(2, "backward") || + check(3, "left") || check(4, "right") || + check(5, "strafeleft") || check(6, "straferight") || + check(7, "jump") || check(8, "spin") + ){ + if (8 <= ++fields) + { + lua_pop(gL, 2); // pop key and value + break; + } + } + + lua_pop(gL, 1); // pop value +#undef check + } + } else { + while (fields < 8) { - LUA_PushUserdata(gL, player, META_PLAYER); - LUA_PushUserdata(gL, inflictor, META_MOBJ); - LUA_PushUserdata(gL, source, META_MOBJ); - lua_pushinteger(gL, damagetype); + k[fields] = lua_toboolean(gL, -8 + fields); + fields++; } - PushHook(gL, hookp); - lua_pushvalue(gL, -5); - lua_pushvalue(gL, -5); - lua_pushvalue(gL, -5); - lua_pushvalue(gL, -5); - if (lua_pcall(gL, 4, 1, 1)) { - if (!hookp->error || cv_debug & DBG_LUA) - CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); - lua_pop(gL, 1); - hookp->error = true; - continue; - } - if (lua_toboolean(gL, -1)) - hooked = true; - lua_pop(gL, 1); } - lua_settop(gL, 0); - return hooked; + B_KeysToTiccmd(botai->tails, botai->cmd, + k[0],k[1],k[2],k[3],k[4],k[5],k[6],k[7]); + + hook->status = true; } -void LUAh_NetArchiveHook(lua_CFunction archFunc) +int LUA_HookBotAI(mobj_t *sonic, mobj_t *tails, ticcmd_t *cmd) { - hook_p hookp; - int errorhandlerindex; - if (!gL || !(hooksAvailable[hook_NetVars/8] & (1<<(hook_NetVars%8)))) - return; + const char *skin = ((skin_t *)tails->skin)->name; - // stack: tables - I_Assert(lua_gettop(gL) > 0); - I_Assert(lua_istable(gL, -1)); + Hook_State hook; + BotAI_State botai; - lua_pushcfunction(gL, LUA_GetErrorMessage); - errorhandlerindex = lua_gettop(gL); - - // tables becomes an upvalue of archFunc - lua_pushvalue(gL, -2); - lua_pushcclosure(gL, archFunc, 1); - // stack: tables, archFunc - - for (hookp = roothook; hookp; hookp = hookp->next) + if (prepare_string_hook(&hook, false, String_Hook(BotAI), skin)) { - if (hookp->type != hook_NetVars) - continue; + LUA_PushUserdata(gL, sonic, META_MOBJ); + LUA_PushUserdata(gL, tails, META_MOBJ); - PushHook(gL, hookp); - lua_pushvalue(gL, -2); // archFunc - if (lua_pcall(gL, 1, 0, errorhandlerindex)) { - CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); - lua_pop(gL, 1); - } + botai.tails = tails; + botai.cmd = cmd; + + hook.userdata = &botai; + + call_hooks(&hook, 2, 8, res_botai); } - lua_pop(gL, 2); // Pop archFunc and error handler - // stack: tables + return hook.status; } -boolean LUAh_MapThingSpawn(mobj_t *mo, mapthing_t *mthing) +void LUA_HookLinedefExecute(line_t *line, mobj_t *mo, sector_t *sector) { - hook_p hookp; - boolean hooked = false; - if (!gL || !(hooksAvailable[hook_MapThingSpawn/8] & (1<<(hook_MapThingSpawn%8)))) - return false; - - if (!(mobjhooks[MT_NULL] || mobjhooks[mo->type])) - return false; - - lua_settop(gL, 0); - lua_pushcfunction(gL, LUA_GetErrorMessage); - - // Look for all generic mobj map thing spawn hooks - for (hookp = mobjhooks[MT_NULL]; hookp; hookp = hookp->next) + Hook_State hook; + if (prepare_string_hook + (&hook, 0, String_Hook(LinedefExecute), line->stringargs[0])) { - if (hookp->type != hook_MapThingSpawn) - continue; - - ps_lua_mobjhooks++; - if (lua_gettop(gL) == 1) - { - LUA_PushUserdata(gL, mo, META_MOBJ); - LUA_PushUserdata(gL, mthing, META_MAPTHING); - } - PushHook(gL, hookp); - lua_pushvalue(gL, -3); - lua_pushvalue(gL, -3); - if (lua_pcall(gL, 2, 1, 1)) { - if (!hookp->error || cv_debug & DBG_LUA) - CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); - lua_pop(gL, 1); - hookp->error = true; - continue; - } - if (lua_toboolean(gL, -1)) - hooked = true; - lua_pop(gL, 1); + LUA_PushUserdata(gL, line, META_LINE); + LUA_PushUserdata(gL, mo, META_MOBJ); + LUA_PushUserdata(gL, sector, META_SECTOR); + ps_lua_mobjhooks += call_hooks(&hook, 3, 0, res_none); } - - for (hookp = mobjhooks[mo->type]; hookp; hookp = hookp->next) - { - if (hookp->type != hook_MapThingSpawn) - continue; - - ps_lua_mobjhooks++; - if (lua_gettop(gL) == 1) - { - LUA_PushUserdata(gL, mo, META_MOBJ); - LUA_PushUserdata(gL, mthing, META_MAPTHING); - } - PushHook(gL, hookp); - lua_pushvalue(gL, -3); - lua_pushvalue(gL, -3); - if (lua_pcall(gL, 2, 1, 1)) { - if (!hookp->error || cv_debug & DBG_LUA) - CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); - lua_pop(gL, 1); - hookp->error = true; - continue; - } - if (lua_toboolean(gL, -1)) - hooked = true; - lua_pop(gL, 1); - } - - lua_settop(gL, 0); - return hooked; } -// Hook for P_PlayerAfterThink Smiles mobj-following -boolean LUAh_FollowMobj(player_t *player, mobj_t *mobj) +int LUA_HookPlayerMsg(int source, int target, int flags, char *msg) { - hook_p hookp; - boolean hooked = false; - if (!gL || !(hooksAvailable[hook_FollowMobj/8] & (1<<(hook_FollowMobj%8)))) - return 0; - - if (!(mobjhooks[MT_NULL] || mobjhooks[mobj->type])) - return 0; - - lua_settop(gL, 0); - lua_pushcfunction(gL, LUA_GetErrorMessage); - - // Look for all generic mobj follow item hooks - for (hookp = mobjhooks[MT_NULL]; hookp; hookp = hookp->next) + Hook_State hook; + if (prepare_hook(&hook, false, Hook(PlayerMsg))) { - if (hookp->type != hook_FollowMobj) - continue; - - ps_lua_mobjhooks++; - if (lua_gettop(gL) == 1) - { - LUA_PushUserdata(gL, player, META_PLAYER); - LUA_PushUserdata(gL, mobj, META_MOBJ); + LUA_PushUserdata(gL, &players[source], META_PLAYER); // Source player + if (flags & 2 /*HU_CSAY*/) { // csay TODO: make HU_CSAY accessible outside hu_stuff.c + lua_pushinteger(gL, 3); // type + lua_pushnil(gL); // target + } else if (target == -1) { // sayteam + lua_pushinteger(gL, 1); // type + lua_pushnil(gL); // target + } else if (target == 0) { // say + lua_pushinteger(gL, 0); // type + lua_pushnil(gL); // target + } else { // sayto + lua_pushinteger(gL, 2); // type + LUA_PushUserdata(gL, &players[target-1], META_PLAYER); // target } - PushHook(gL, hookp); - lua_pushvalue(gL, -3); - lua_pushvalue(gL, -3); - if (lua_pcall(gL, 2, 1, 1)) { - if (!hookp->error || cv_debug & DBG_LUA) - CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); - lua_pop(gL, 1); - hookp->error = true; - continue; - } - if (lua_toboolean(gL, -1)) - hooked = true; - lua_pop(gL, 1); + lua_pushstring(gL, msg); // msg + call_hooks(&hook, 4, 1, res_true); } - - for (hookp = mobjhooks[mobj->type]; hookp; hookp = hookp->next) - { - if (hookp->type != hook_FollowMobj) - continue; - - ps_lua_mobjhooks++; - if (lua_gettop(gL) == 1) - { - LUA_PushUserdata(gL, player, META_PLAYER); - LUA_PushUserdata(gL, mobj, META_MOBJ); - } - PushHook(gL, hookp); - lua_pushvalue(gL, -3); - lua_pushvalue(gL, -3); - if (lua_pcall(gL, 2, 1, 1)) { - if (!hookp->error || cv_debug & DBG_LUA) - CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); - lua_pop(gL, 1); - hookp->error = true; - continue; - } - if (lua_toboolean(gL, -1)) - hooked = true; - lua_pop(gL, 1); - } - - lua_settop(gL, 0); - return hooked; + return hook.status; } -// Hook for P_PlayerCanDamage -UINT8 LUAh_PlayerCanDamage(player_t *player, mobj_t *mobj) +int LUA_HookHurtMsg(player_t *player, mobj_t *inflictor, mobj_t *source, UINT8 damagetype) { - hook_p hookp; - UINT8 shouldCollide = 0; // 0 = default, 1 = force yes, 2 = force no. - if (!gL || !(hooksAvailable[hook_PlayerCanDamage/8] & (1<<(hook_PlayerCanDamage%8)))) - return 0; - - lua_settop(gL, 0); - lua_pushcfunction(gL, LUA_GetErrorMessage); - - for (hookp = playerhooks; hookp; hookp = hookp->next) + Hook_State hook; + if (prepare_hook(&hook, false, Hook(HurtMsg))) { - if (hookp->type != hook_PlayerCanDamage) - continue; - - ps_lua_mobjhooks++; - if (lua_gettop(gL) == 1) - { - LUA_PushUserdata(gL, player, META_PLAYER); - LUA_PushUserdata(gL, mobj, META_MOBJ); - } - PushHook(gL, hookp); - lua_pushvalue(gL, -3); - lua_pushvalue(gL, -3); - if (lua_pcall(gL, 2, 1, 1)) { - if (!hookp->error || cv_debug & DBG_LUA) - CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); - lua_pop(gL, 1); - hookp->error = true; - continue; - } - if (!lua_isnil(gL, -1)) - { // if nil, leave shouldCollide = 0. - if (lua_toboolean(gL, -1)) - shouldCollide = 1; // Force yes - else - shouldCollide = 2; // Force no - } - lua_pop(gL, 1); + LUA_PushUserdata(gL, player, META_PLAYER); + LUA_PushUserdata(gL, inflictor, META_MOBJ); + LUA_PushUserdata(gL, source, META_MOBJ); + lua_pushinteger(gL, damagetype); + call_hooks(&hook, 4, 1, res_true); } - - lua_settop(gL, 0); - return shouldCollide; + return hook.status; } -void LUAh_PlayerQuit(player_t *plr, kickreason_t reason) +void LUA_HookNetArchive(lua_CFunction archFunc) { - hook_p hookp; - if (!gL || !(hooksAvailable[hook_PlayerQuit/8] & (1<<(hook_PlayerQuit%8)))) - return; - - lua_settop(gL, 0); - lua_pushcfunction(gL, LUA_GetErrorMessage); - - for (hookp = roothook; hookp; hookp = hookp->next) + const int ref = hookRefs[Hook(NetVars)]; + Hook_State hook; + /* this is a remarkable case where the stack isn't reset */ + if (ref > 0) { - if (hookp->type != hook_PlayerQuit) - continue; + // stack: tables + I_Assert(lua_gettop(gL) > 0); + I_Assert(lua_istable(gL, -1)); - if (lua_gettop(gL) == 1) - { - LUA_PushUserdata(gL, plr, META_PLAYER); // Player that quit - lua_pushinteger(gL, reason); // Reason for quitting - } - PushHook(gL, hookp); - lua_pushvalue(gL, -3); - lua_pushvalue(gL, -3); - if (lua_pcall(gL, 2, 0, 1)) { - CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); - lua_pop(gL, 1); - } + push_error_handler(); + lua_getref(gL, hookReg); + + lua_insert(gL, HINDEX); + lua_insert(gL, EINDEX); + + // tables becomes an upvalue of archFunc + lua_pushvalue(gL, -1); + lua_pushcclosure(gL, archFunc, 1); + // stack: tables, archFunc + + init_hook_call(&hook, 1, 0, res_none); + call_ref(&hook, ref); + + lua_pop(gL, 2); // pop hook table and archFunc + lua_remove(gL, EINDEX); // pop error handler + lua_remove(gL, HINDEX); // pop hook registry + // stack: tables } - - lua_settop(gL, 0); } -// Hook for Y_Ticker -void LUAh_IntermissionThinker(void) +int LUA_HookMapThingSpawn(mobj_t *mobj, mapthing_t *mthing) { - hook_p hookp; - if (!gL || !(hooksAvailable[hook_IntermissionThinker/8] & (1<<(hook_IntermissionThinker%8)))) - return; - - lua_pushcfunction(gL, LUA_GetErrorMessage); - - for (hookp = roothook; hookp; hookp = hookp->next) + Hook_State hook; + if (prepare_mobj_hook(&hook, false, Mobj_Hook(MapThingSpawn), mobj->type)) { - if (hookp->type != hook_IntermissionThinker) - continue; - - PushHook(gL, hookp); - if (lua_pcall(gL, 0, 0, 1)) { - if (!hookp->error || cv_debug & DBG_LUA) - CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); - lua_pop(gL, 1); - hookp->error = true; - } + LUA_PushUserdata(gL, mobj, META_MOBJ); + LUA_PushUserdata(gL, mthing, META_MAPTHING); + call_hooks(&hook, 2, 1, res_true); } - - lua_pop(gL, 1); // Pop error handler + return hook.status; } -// Hook for team switching -// It's just an edit of LUAh_ViewpointSwitch. -boolean LUAh_TeamSwitch(player_t *player, int newteam, boolean fromspectators, boolean tryingautobalance, boolean tryingscramble) +int LUA_HookFollowMobj(player_t *player, mobj_t *mobj) { - hook_p hookp; - boolean canSwitchTeam = true; - if (!gL || !(hooksAvailable[hook_TeamSwitch/8] & (1<<(hook_TeamSwitch%8)))) - return true; - - lua_settop(gL, 0); - lua_pushcfunction(gL, LUA_GetErrorMessage); - - for (hookp = playerhooks; hookp; hookp = hookp->next) + Hook_State hook; + if (prepare_mobj_hook(&hook, false, Mobj_Hook(FollowMobj), mobj->type)) { - if (hookp->type != hook_TeamSwitch) - continue; - - if (lua_gettop(gL) == 1) - { - LUA_PushUserdata(gL, player, META_PLAYER); - lua_pushinteger(gL, newteam); - lua_pushboolean(gL, fromspectators); - lua_pushboolean(gL, tryingautobalance); - lua_pushboolean(gL, tryingscramble); - } - PushHook(gL, hookp); - lua_pushvalue(gL, -6); - lua_pushvalue(gL, -6); - lua_pushvalue(gL, -6); - lua_pushvalue(gL, -6); - lua_pushvalue(gL, -6); - if (lua_pcall(gL, 5, 1, 1)) { - if (!hookp->error || cv_debug & DBG_LUA) - CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); - lua_pop(gL, 1); - hookp->error = true; - continue; - } - if (!lua_isnil(gL, -1) && !lua_toboolean(gL, -1)) - canSwitchTeam = false; // Can't switch team - lua_pop(gL, 1); + LUA_PushUserdata(gL, player, META_PLAYER); + LUA_PushUserdata(gL, mobj, META_MOBJ); + call_hooks(&hook, 2, 1, res_true); } - - lua_settop(gL, 0); - return canSwitchTeam; + return hook.status; } -// Hook for spy mode -UINT8 LUAh_ViewpointSwitch(player_t *player, player_t *newdisplayplayer, boolean forced) +int LUA_HookPlayerCanDamage(player_t *player, mobj_t *mobj) { - hook_p hookp; - UINT8 canSwitchView = 0; // 0 = default, 1 = force yes, 2 = force no. - if (!gL || !(hooksAvailable[hook_ViewpointSwitch/8] & (1<<(hook_ViewpointSwitch%8)))) - return 0; - - lua_settop(gL, 0); - lua_pushcfunction(gL, LUA_GetErrorMessage); - - hud_running = true; // local hook - - for (hookp = playerhooks; hookp; hookp = hookp->next) + Hook_State hook; + if (prepare_hook(&hook, 0, Hook(PlayerCanDamage))) { - if (hookp->type != hook_ViewpointSwitch) - continue; - - if (lua_gettop(gL) == 1) - { - LUA_PushUserdata(gL, player, META_PLAYER); - LUA_PushUserdata(gL, newdisplayplayer, META_PLAYER); - lua_pushboolean(gL, forced); - } - PushHook(gL, hookp); - lua_pushvalue(gL, -4); - lua_pushvalue(gL, -4); - lua_pushvalue(gL, -4); - if (lua_pcall(gL, 3, 1, 1)) { - if (!hookp->error || cv_debug & DBG_LUA) - CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); - lua_pop(gL, 1); - hookp->error = true; - continue; - } - if (!lua_isnil(gL, -1)) - { // if nil, leave canSwitchView = 0. - if (lua_toboolean(gL, -1)) - canSwitchView = 1; // Force viewpoint switch - else - canSwitchView = 2; // Skip viewpoint switch - } - lua_pop(gL, 1); + LUA_PushUserdata(gL, player, META_PLAYER); + LUA_PushUserdata(gL, mobj, META_MOBJ); + call_hooks(&hook, 2, 1, res_force); } - - lua_settop(gL, 0); - - hud_running = false; - - return canSwitchView; + return hook.status; +} + +void LUA_HookPlayerQuit(player_t *plr, kickreason_t reason) +{ + Hook_State hook; + if (prepare_hook(&hook, 0, Hook(PlayerQuit))) + { + LUA_PushUserdata(gL, plr, META_PLAYER); // Player that quit + lua_pushinteger(gL, reason); // Reason for quitting + call_hooks(&hook, 2, 0, res_none); + } +} + +int LUA_HookTeamSwitch(player_t *player, int newteam, boolean fromspectators, boolean tryingautobalance, boolean tryingscramble) +{ + Hook_State hook; + if (prepare_hook(&hook, true, Hook(TeamSwitch))) + { + LUA_PushUserdata(gL, player, META_PLAYER); + lua_pushinteger(gL, newteam); + lua_pushboolean(gL, fromspectators); + lua_pushboolean(gL, tryingautobalance); + lua_pushboolean(gL, tryingscramble); + call_hooks(&hook, 5, 1, res_false); + } + return hook.status; +} + +int LUA_HookViewpointSwitch(player_t *player, player_t *newdisplayplayer, boolean forced) +{ + Hook_State hook; + if (prepare_hook(&hook, 0, Hook(ViewpointSwitch))) + { + LUA_PushUserdata(gL, player, META_PLAYER); + LUA_PushUserdata(gL, newdisplayplayer, META_PLAYER); + lua_pushboolean(gL, forced); + + hud_running = true; // local hook + call_hooks(&hook, 3, 1, res_force); + hud_running = false; + } + return hook.status; } -// Hook for MT_NAMECHECK #ifdef SEENAMES -boolean LUAh_SeenPlayer(player_t *player, player_t *seenfriend) +int LUA_HookSeenPlayer(player_t *player, player_t *seenfriend) { - hook_p hookp; - boolean hasSeenPlayer = true; - if (!gL || !(hooksAvailable[hook_SeenPlayer/8] & (1<<(hook_SeenPlayer%8)))) - return true; - - lua_settop(gL, 0); - lua_pushcfunction(gL, LUA_GetErrorMessage); - - hud_running = true; // local hook - - for (hookp = playerhooks; hookp; hookp = hookp->next) + Hook_State hook; + if (prepare_hook(&hook, true, Hook(SeenPlayer))) { - if (hookp->type != hook_SeenPlayer) - continue; + LUA_PushUserdata(gL, player, META_PLAYER); + LUA_PushUserdata(gL, seenfriend, META_PLAYER); - if (lua_gettop(gL) == 1) - { - LUA_PushUserdata(gL, player, META_PLAYER); - LUA_PushUserdata(gL, seenfriend, META_PLAYER); - } - PushHook(gL, hookp); - lua_pushvalue(gL, -3); - lua_pushvalue(gL, -3); - if (lua_pcall(gL, 2, 1, 1)) { - if (!hookp->error || cv_debug & DBG_LUA) - CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); - lua_pop(gL, 1); - hookp->error = true; - continue; - } - if (!lua_isnil(gL, -1) && !lua_toboolean(gL, -1)) - hasSeenPlayer = false; // Hasn't seen player - lua_pop(gL, 1); + hud_running = true; // local hook + call_hooks(&hook, 2, 1, res_false); + hud_running = false; } - - lua_settop(gL, 0); - - hud_running = false; - - return hasSeenPlayer; + return hook.status; } #endif // SEENAMES -boolean LUAh_ShouldJingleContinue(player_t *player, const char *musname) +int LUA_HookShouldJingleContinue(player_t *player, const char *musname) { - hook_p hookp; - boolean keepplaying = false; - if (!gL || !(hooksAvailable[hook_ShouldJingleContinue/8] & (1<<(hook_ShouldJingleContinue%8)))) - return true; - - lua_settop(gL, 0); - lua_pushcfunction(gL, LUA_GetErrorMessage); - - hud_running = true; // local hook - - for (hookp = roothook; hookp; hookp = hookp->next) + Hook_State hook; + if (prepare_string_hook + (&hook, false, String_Hook(ShouldJingleContinue), musname)) { - if (hookp->type != hook_ShouldJingleContinue - || (hookp->s.str && strcmp(hookp->s.str, musname))) - continue; + LUA_PushUserdata(gL, player, META_PLAYER); + push_string(); - if (lua_gettop(gL) == 1) - { - LUA_PushUserdata(gL, player, META_PLAYER); - lua_pushstring(gL, musname); - } - PushHook(gL, hookp); - lua_pushvalue(gL, -3); - lua_pushvalue(gL, -3); - if (lua_pcall(gL, 2, 1, 1)) { - if (!hookp->error || cv_debug & DBG_LUA) - CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); - lua_pop(gL, 1); - hookp->error = true; - continue; - } - if (!lua_isnil(gL, -1) && lua_toboolean(gL, -1)) - keepplaying = true; // Keep playing this boolean - lua_pop(gL, 1); + hud_running = true; // local hook + call_hooks(&hook, 2, 1, res_true); + hud_running = false; } - - lua_settop(gL, 0); - - hud_running = false; - - return keepplaying; + return hook.status; } -// Hook for game quitting -void LUAh_GameQuit(void) -{ - hook_p hookp; - if (!gL || !(hooksAvailable[hook_GameQuit/8] & (1<<(hook_GameQuit%8)))) - return; - - lua_pushcfunction(gL, LUA_GetErrorMessage); - - for (hookp = roothook; hookp; hookp = hookp->next) - { - if (hookp->type != hook_GameQuit) - continue; - - PushHook(gL, hookp); - if (lua_pcall(gL, 0, 0, 1)) { - if (!hookp->error || cv_debug & DBG_LUA) - CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); - lua_pop(gL, 1); - hookp->error = true; - } - } - - lua_pop(gL, 1); // Pop error handler -} - -// Hook for building player's ticcmd struct (Ported from SRB2Kart) boolean hook_cmd_running = false; -boolean LUAh_PlayerCmd(player_t *player, ticcmd_t *cmd) + +static void update_music_name(struct MusicChange *musicchange) { - hook_p hookp; - boolean hooked = false; - if (!gL || !(hooksAvailable[hook_PlayerCmd/8] & (1<<(hook_PlayerCmd%8)))) - return false; + size_t length; + const char * new = lua_tolstring(gL, -6, &length); - lua_settop(gL, 0); - lua_pushcfunction(gL, LUA_GetErrorMessage); - - hook_cmd_running = true; - for (hookp = roothook; hookp; hookp = hookp->next) + if (length < 7) { - if (hookp->type != hook_PlayerCmd) - continue; - - if (lua_gettop(gL) == 1) - { - LUA_PushUserdata(gL, player, META_PLAYER); - LUA_PushUserdata(gL, cmd, META_TICCMD); - } - PushHook(gL, hookp); - lua_pushvalue(gL, -3); - lua_pushvalue(gL, -3); - if (lua_pcall(gL, 2, 1, 1)) { - if (!hookp->error || cv_debug & DBG_LUA) - CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); - lua_pop(gL, 1); - hookp->error = true; - continue; - } - if (lua_toboolean(gL, -1)) - hooked = true; - lua_pop(gL, 1); + strcpy(musicchange->newname, new); + lua_pushvalue(gL, -6);/* may as well keep it for next call */ + } + else + { + memcpy(musicchange->newname, new, 6); + musicchange->newname[6] = '\0'; + lua_pushlstring(gL, new, 6); } - lua_settop(gL, 0); - hook_cmd_running = false; - return hooked; + lua_replace(gL, -7); } -// Hook for music changes -boolean LUAh_MusicChange(const char *oldname, char *newname, UINT16 *mflags, boolean *looping, - UINT32 *position, UINT32 *prefadems, UINT32 *fadeinms) +static void res_musicchange(Hook_State *hook) { - hook_p hookp; - boolean hooked = false; + struct MusicChange *musicchange = hook->userdata; - if (!gL || !(hooksAvailable[hook_MusicChange/8] & (1<<(hook_MusicChange%8)))) - return false; + // output 1: true, false, or string musicname override + if (lua_isstring(gL, -6)) + update_music_name(musicchange); + else if (lua_isboolean(gL, -6) && lua_toboolean(gL, -6)) + hook->status = true; - lua_settop(gL, 0); - lua_pushcfunction(gL, LUA_GetErrorMessage); + // output 2: mflags override + if (lua_isnumber(gL, -5)) + *musicchange->mflags = lua_tonumber(gL, -5); + // output 3: looping override + if (lua_isboolean(gL, -4)) + *musicchange->looping = lua_toboolean(gL, -4); + // output 4: position override + if (lua_isboolean(gL, -3)) + *musicchange->position = lua_tonumber(gL, -3); + // output 5: prefadems override + if (lua_isboolean(gL, -2)) + *musicchange->prefadems = lua_tonumber(gL, -2); + // output 6: fadeinms override + if (lua_isboolean(gL, -1)) + *musicchange->fadeinms = lua_tonumber(gL, -1); +} - for (hookp = roothook; hookp; hookp = hookp->next) - if (hookp->type == hook_MusicChange) - { - PushHook(gL, hookp); - lua_pushstring(gL, oldname); - lua_pushstring(gL, newname); - lua_pushinteger(gL, *mflags); - lua_pushboolean(gL, *looping); - lua_pushinteger(gL, *position); - lua_pushinteger(gL, *prefadems); - lua_pushinteger(gL, *fadeinms); - if (lua_pcall(gL, 7, 6, 1)) { - CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL,-1)); - lua_pop(gL, 1); - continue; - } +int LUA_HookMusicChange(const char *oldname, struct MusicChange *param) +{ + Hook_State hook; + if (prepare_hook(&hook, false, Hook(MusicChange))) + { + int n; + int k; - // output 1: true, false, or string musicname override - if (lua_isboolean(gL, -6) && lua_toboolean(gL, -6)) - hooked = true; - else if (lua_isstring(gL, -6)) - strncpy(newname, lua_tostring(gL, -6), 7); - // output 2: mflags override - if (lua_isnumber(gL, -5)) - *mflags = lua_tonumber(gL, -5); - // output 3: looping override - if (lua_isboolean(gL, -4)) - *looping = lua_toboolean(gL, -4); - // output 4: position override - if (lua_isboolean(gL, -3)) - *position = lua_tonumber(gL, -3); - // output 5: prefadems override - if (lua_isboolean(gL, -2)) - *prefadems = lua_tonumber(gL, -2); - // output 6: fadeinms override - if (lua_isboolean(gL, -1)) - *fadeinms = lua_tonumber(gL, -1); + init_hook_call(&hook, 7, 6, res_musicchange); + hook.userdata = param; - lua_pop(gL, 7); // Pop returned values and error handler + lua_pushstring(gL, oldname);/* the only constant value */ + lua_pushstring(gL, param->newname);/* semi constant */ + + get_hook_table(&hook); + n = lua_objlen(gL, -1); + + for (k = 1; k <= n; ++k) { + lua_pushvalue(gL, -3); + lua_pushvalue(gL, -3); + lua_pushinteger(gL, *param->mflags); + lua_pushboolean(gL, *param->looping); + lua_pushinteger(gL, *param->position); + lua_pushinteger(gL, *param->prefadems); + lua_pushinteger(gL, *param->fadeinms); + + call_single_hook_no_copy(&hook); } - lua_settop(gL, 0); - newname[6] = 0; - return hooked; -} \ No newline at end of file + lua_settop(gL, 0); + } + return hook.status; +} diff --git a/src/lua_script.c b/src/lua_script.c index eb4737f76..a649942b8 100644 --- a/src/lua_script.c +++ b/src/lua_script.c @@ -1628,7 +1628,7 @@ void LUA_Archive(void) WRITEUINT32(save_p, UINT32_MAX); // end of mobjs marker, replaces mobjnum. - LUAh_NetArchiveHook(NetArchive); // call the NetArchive hook in archive mode + LUA_HookNetArchive(NetArchive); // call the NetArchive hook in archive mode ArchiveTables(); if (gL) @@ -1663,7 +1663,7 @@ void LUA_UnArchive(void) } } while(mobjnum != UINT32_MAX); // repeat until end of mobjs marker. - LUAh_NetArchiveHook(NetUnArchive); // call the NetArchive hook in unarchive mode + LUA_HookNetArchive(NetUnArchive); // call the NetArchive hook in unarchive mode UnArchiveTables(); if (gL) diff --git a/src/lua_script.h b/src/lua_script.h index 79ba0bb38..e9104f3d5 100644 --- a/src/lua_script.h +++ b/src/lua_script.h @@ -61,7 +61,7 @@ void Got_Luacmd(UINT8 **cp, INT32 playernum); // lua_consolelib.c void LUA_CVarChanged(const char *name); // lua_consolelib.c int Lua_optoption(lua_State *L, int narg, const char *def, const char *const lst[]); -void LUAh_NetArchiveHook(lua_CFunction archFunc); +void LUA_HookNetArchive(lua_CFunction archFunc); // Console wrapper void COM_Lua_f(void); diff --git a/src/m_menu.c b/src/m_menu.c index 77648f877..a9333e36e 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -6938,7 +6938,7 @@ static void M_UltimateCheat(INT32 choice) { (void)choice; if (Playing()) - LUAh_GameQuit(); + LUA_Hook(GameQuit); I_Quit(); } @@ -13373,7 +13373,7 @@ void M_QuitResponse(INT32 ch) if (ch != 'y' && ch != KEY_ENTER) return; if (Playing()) - LUAh_GameQuit(); + LUA_Hook(GameQuit); if (!(netgame || cv_debug)) { S_ResetCaptions(); diff --git a/src/p_enemy.c b/src/p_enemy.c index 22de9bc67..103441701 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -3957,7 +3957,7 @@ void A_BossDeath(mobj_t *mo) } bossjustdie: - if (LUAh_BossDeath(mo)) + if (LUA_HookMobj(mo, Mobj_Hook(BossDeath))) return; else if (P_MobjWasRemoved(mo)) return; diff --git a/src/p_inter.c b/src/p_inter.c index 415c679e4..2d5f2736a 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -365,7 +365,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) if (special->flags & (MF_ENEMY|MF_BOSS) && special->flags2 & MF2_FRET) return; - if (LUAh_TouchSpecial(special, toucher) || P_MobjWasRemoved(special)) + if (LUA_HookTouchSpecial(special, toucher) || P_MobjWasRemoved(special)) return; // 0 = none, 1 = elemental pierce, 2 = bubble bounce @@ -1935,7 +1935,7 @@ static void P_HitDeathMessages(player_t *player, mobj_t *inflictor, mobj_t *sour if (!netgame) return; // Presumably it's obvious what's happening in splitscreen. - if (LUAh_HurtMsg(player, inflictor, source, damagetype)) + if (LUA_HookHurtMsg(player, inflictor, source, damagetype)) return; deadtarget = (player->mo->health <= 0); @@ -2409,7 +2409,7 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, UINT8 damaget target->flags2 &= ~(MF2_SKULLFLY|MF2_NIGHTSPULL); target->health = 0; // This makes it easy to check if something's dead elsewhere. - if (LUAh_MobjDeath(target, inflictor, source, damagetype) || P_MobjWasRemoved(target)) + if (LUA_HookMobjDeath(target, inflictor, source, damagetype) || P_MobjWasRemoved(target)) return; // Let EVERYONE know what happened to a player! 01-29-2002 Tails @@ -3544,7 +3544,7 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da // Everything above here can't be forced. if (!metalrecording) { - UINT8 shouldForce = LUAh_ShouldDamage(target, inflictor, source, damage, damagetype); + UINT8 shouldForce = LUA_HookShouldDamage(target, inflictor, source, damage, damagetype); if (P_MobjWasRemoved(target)) return (shouldForce == 1); // mobj was removed if (shouldForce == 1) @@ -3585,7 +3585,7 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da if (!force && target->flags2 & MF2_FRET) // Currently flashing from being hit return false; - if (LUAh_MobjDamage(target, inflictor, source, damage, damagetype) || P_MobjWasRemoved(target)) + if (LUA_HookMobjDamage(target, inflictor, source, damage, damagetype) || P_MobjWasRemoved(target)) return true; if (target->health > 1) @@ -3635,7 +3635,7 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da || (G_GametypeHasTeams() && player->ctfteam == source->player->ctfteam))) return false; // Don't run eachother over in special stages and team games and such } - if (LUAh_MobjDamage(target, inflictor, source, damage, damagetype)) + if (LUA_HookMobjDamage(target, inflictor, source, damage, damagetype)) return true; P_NiGHTSDamage(target, source); // -5s :( return true; @@ -3689,13 +3689,13 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da if (force || (inflictor && inflictor->flags & MF_MISSILE && inflictor->flags2 & MF2_SUPERFIRE)) // Super Sonic is stunned! { - if (!LUAh_MobjDamage(target, inflictor, source, damage, damagetype)) + if (!LUA_HookMobjDamage(target, inflictor, source, damage, damagetype)) P_SuperDamage(player, inflictor, source, damage); return true; } return false; } - else if (LUAh_MobjDamage(target, inflictor, source, damage, damagetype)) + else if (LUA_HookMobjDamage(target, inflictor, source, damage, damagetype)) return true; else if (player->powers[pw_shield] || (player->bot && !ultimatemode)) //If One-Hit Shield { diff --git a/src/p_map.c b/src/p_map.c index 922c0d9ec..8c548ed3c 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -747,7 +747,7 @@ static boolean PIT_CheckThing(mobj_t *thing) return true; // underneath // REX HAS SEEN YOU - if (!LUAh_SeenPlayer(tmthing->target->player, thing->player)) + if (!LUA_HookSeenPlayer(tmthing->target->player, thing->player)) return false; seenplayer = thing->player; @@ -937,7 +937,7 @@ static boolean PIT_CheckThing(mobj_t *thing) } { - UINT8 shouldCollide = LUAh_MobjCollide(thing, tmthing); // checks hook for thing's type + UINT8 shouldCollide = LUA_Hook2Mobj(thing, tmthing, Mobj_Hook(MobjCollide)); // checks hook for thing's type if (P_MobjWasRemoved(tmthing) || P_MobjWasRemoved(thing)) return true; // one of them was removed??? if (shouldCollide == 1) @@ -945,7 +945,7 @@ static boolean PIT_CheckThing(mobj_t *thing) else if (shouldCollide == 2) return true; // force no collide - shouldCollide = LUAh_MobjMoveCollide(tmthing, thing); // checks hook for tmthing's type + shouldCollide = LUA_Hook2Mobj(tmthing, thing, Mobj_Hook(MobjMoveCollide)); // checks hook for tmthing's type if (P_MobjWasRemoved(tmthing) || P_MobjWasRemoved(thing)) return true; // one of them was removed??? if (shouldCollide == 1) @@ -1927,7 +1927,7 @@ static boolean PIT_CheckLine(line_t *ld) blockingline = ld; { - UINT8 shouldCollide = LUAh_MobjLineCollide(tmthing, blockingline); // checks hook for thing's type + UINT8 shouldCollide = LUA_HookMobjLineCollide(tmthing, blockingline); // checks hook for thing's type if (P_MobjWasRemoved(tmthing)) return true; // one of them was removed??? if (shouldCollide == 1) diff --git a/src/p_mobj.c b/src/p_mobj.c index 7ba6d1fad..5523fa273 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -1844,7 +1844,7 @@ void P_XYMovement(mobj_t *mo) B_MoveBlocked(player); } - if (LUAh_MobjMoveBlocked(mo)) + if (LUA_HookMobj(mo, Mobj_Hook(MobjMoveBlocked))) { if (P_MobjWasRemoved(mo)) return; @@ -7513,7 +7513,7 @@ static void P_RosySceneryThink(mobj_t *mobj) static void P_MobjSceneryThink(mobj_t *mobj) { - if (LUAh_MobjThinker(mobj)) + if (LUA_HookMobj(mobj, Mobj_Hook(MobjThinker))) return; if (P_MobjWasRemoved(mobj)) return; @@ -7861,7 +7861,7 @@ static void P_MobjSceneryThink(mobj_t *mobj) if (!mobj->fuse) { - if (!LUAh_MobjFuse(mobj)) + if (!LUA_HookMobj(mobj, Mobj_Hook(MobjFuse))) P_RemoveMobj(mobj); return; } @@ -7920,7 +7920,7 @@ static void P_MobjSceneryThink(mobj_t *mobj) mobj->fuse--; if (!mobj->fuse) { - if (!LUAh_MobjFuse(mobj)) + if (!LUA_HookMobj(mobj, Mobj_Hook(MobjFuse))) P_RemoveMobj(mobj); return; } @@ -7949,7 +7949,7 @@ static boolean P_MobjPushableThink(mobj_t *mobj) static boolean P_MobjBossThink(mobj_t *mobj) { - if (LUAh_BossThinker(mobj)) + if (LUA_HookMobj(mobj, Mobj_Hook(BossThinker))) { if (P_MobjWasRemoved(mobj)) return false; @@ -9870,7 +9870,7 @@ static boolean P_FuseThink(mobj_t *mobj) if (mobj->fuse) return true; - if (LUAh_MobjFuse(mobj) || P_MobjWasRemoved(mobj)) + if (LUA_HookMobj(mobj, Mobj_Hook(MobjFuse)) || P_MobjWasRemoved(mobj)) ; else if (mobj->info->flags & MF_MONITOR) { @@ -10046,13 +10046,13 @@ void P_MobjThinker(mobj_t *mobj) // Check for a Lua thinker first if (!mobj->player) { - if (LUAh_MobjThinker(mobj) || P_MobjWasRemoved(mobj)) + if (LUA_HookMobj(mobj, Mobj_Hook(MobjThinker)) || P_MobjWasRemoved(mobj)) return; } else if (!mobj->player->spectator) { // You cannot short-circuit the player thinker like you can other thinkers. - LUAh_MobjThinker(mobj); + LUA_HookMobj(mobj, Mobj_Hook(MobjThinker)); if (P_MobjWasRemoved(mobj)) return; } @@ -10523,7 +10523,7 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type) // DANGER! This can cause P_SpawnMobj to return NULL! // Avoid using P_RemoveMobj on the newly created mobj in "MobjSpawn" Lua hooks! - if (LUAh_MobjSpawn(mobj)) + if (LUA_HookMobj(mobj, Mobj_Hook(MobjSpawn))) { if (P_MobjWasRemoved(mobj)) return NULL; @@ -10910,7 +10910,7 @@ void P_RemoveMobj(mobj_t *mobj) return; // something already removing this mobj. mobj->thinker.function.acp1 = (actionf_p1)P_RemoveThinkerDelayed; // shh. no recursing. - LUAh_MobjRemoved(mobj); + LUA_HookMobj(mobj, Mobj_Hook(MobjRemoved)); mobj->thinker.function.acp1 = (actionf_p1)P_MobjThinker; // needed for P_UnsetThingPosition, etc. to work. // Rings only, please! @@ -12556,7 +12556,7 @@ static boolean P_SetupBooster(mapthing_t* mthing, mobj_t* mobj, boolean strong) static boolean P_SetupSpawnedMapThing(mapthing_t *mthing, mobj_t *mobj, boolean *doangle) { - boolean override = LUAh_MapThingSpawn(mobj, mthing); + boolean override = LUA_HookMapThingSpawn(mobj, mthing); if (P_MobjWasRemoved(mobj)) return false; diff --git a/src/p_setup.c b/src/p_setup.c index 918ffbd4e..01d43bd88 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -65,7 +65,7 @@ #include "md5.h" // map MD5 -// for LUAh_MapLoad +// for MapLoad hook #include "lua_script.h" #include "lua_hook.h" @@ -4271,7 +4271,7 @@ boolean P_LoadLevel(boolean fromnetsave, boolean reloadinggamestate) G_CopyTiccmd(&players[i].cmd, &netcmds[buf][i], 1); } P_PreTicker(2); - LUAh_MapLoad(); + LUA_HookInt(gamemap, Hook(MapLoad)); } // No render mode or reloading gamestate, stop here. diff --git a/src/p_spec.c b/src/p_spec.c index a1afdd00d..59b9a0648 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -35,7 +35,7 @@ #include "v_video.h" // V_AUTOFADEOUT|V_ALLOWLOWERCASE #include "m_misc.h" #include "m_cond.h" //unlock triggers -#include "lua_hook.h" // LUAh_LinedefExecute +#include "lua_hook.h" // LUA_HookLinedefExecute #include "f_finale.h" // control text prompt #include "r_skins.h" // skins @@ -3135,7 +3135,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) case 443: // Calls a named Lua function if (line->stringargs[0]) - LUAh_LinedefExecute(line, mo, callsec); + LUA_HookLinedefExecute(line, mo, callsec); else CONS_Alert(CONS_WARNING, "Linedef %s is missing the hook name of the Lua function to call! (This should be given in arg0str)\n", sizeu1(line-lines)); break; diff --git a/src/p_tick.c b/src/p_tick.c index da2a980c4..930223ab9 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -656,7 +656,7 @@ void P_Ticker(boolean run) ps_lua_mobjhooks = 0; ps_checkposition_calls = 0; - LUAh_PreThinkFrame(); + LUA_Hook(PreThinkFrame); ps_playerthink_time = I_GetTimeMicros(); for (i = 0; i < MAXPLAYERS; i++) @@ -687,7 +687,7 @@ void P_Ticker(boolean run) P_PlayerAfterThink(&players[i]); ps_lua_thinkframe_time = I_GetTimeMicros(); - LUAh_ThinkFrame(); + LUA_HookThinkFrame(); ps_lua_thinkframe_time = I_GetTimeMicros() - ps_lua_thinkframe_time; } @@ -760,7 +760,7 @@ void P_Ticker(boolean run) if (modeattacking) G_GhostTicker(); - LUAh_PostThinkFrame(); + LUA_Hook(PostThinkFrame); } P_MapEnd(); @@ -783,7 +783,7 @@ void P_PreTicker(INT32 frames) { P_MapStart(); - LUAh_PreThinkFrame(); + LUA_Hook(PreThinkFrame); for (i = 0; i < MAXPLAYERS; i++) if (playeringame[i] && players[i].mo && !P_MobjWasRemoved(players[i].mo)) @@ -810,7 +810,7 @@ void P_PreTicker(INT32 frames) if (playeringame[i] && players[i].mo && !P_MobjWasRemoved(players[i].mo)) P_PlayerAfterThink(&players[i]); - LUAh_ThinkFrame(); + LUA_HookThinkFrame(); // Run shield positioning P_RunShields(); @@ -819,7 +819,7 @@ void P_PreTicker(INT32 frames) P_UpdateSpecials(); P_RespawnSpecials(); - LUAh_PostThinkFrame(); + LUA_Hook(PostThinkFrame); P_MapEnd(); } diff --git a/src/p_user.c b/src/p_user.c index c5f919c78..178a26126 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -1111,7 +1111,7 @@ boolean P_PlayerCanDamage(player_t *player, mobj_t *thing) return false; { - UINT8 shouldCollide = LUAh_PlayerCanDamage(player, thing); + UINT8 shouldCollide = LUA_HookPlayerCanDamage(player, thing); if (P_MobjWasRemoved(thing)) return false; // removed??? if (shouldCollide == 1) @@ -1594,7 +1594,7 @@ boolean P_EvaluateMusicStatus(UINT16 status, const char *musname) break; case JT_OTHER: // Other state - result = LUAh_ShouldJingleContinue(&players[i], musname); + result = LUA_HookShouldJingleContinue(&players[i], musname); break; case JT_NONE: // Null state @@ -1860,7 +1860,7 @@ void P_SpawnShieldOrb(player_t *player) I_Error("P_SpawnShieldOrb: player->mo is NULL!\n"); #endif - if (LUAh_ShieldSpawn(player)) + if (LUA_HookPlayer(player, Hook(ShieldSpawn))) return; if (player->powers[pw_shield] & SH_FORCE) @@ -4577,7 +4577,7 @@ static void P_DoSpinAbility(player_t *player, ticcmd_t *cmd) if (cmd->buttons & BT_SPIN) { - if (LUAh_SpinSpecial(player)) + if (LUA_HookPlayer(player, Hook(SpinSpecial))) return; } @@ -5043,7 +5043,7 @@ static boolean P_PlayerShieldThink(player_t *player, ticcmd_t *cmd, mobj_t *lock } } } - if (cmd->buttons & BT_SPIN && !LUAh_ShieldSpecial(player)) // Spin button effects + if (cmd->buttons & BT_SPIN && !LUA_HookPlayer(player, Hook(ShieldSpecial))) // Spin button effects { // Force stop if ((player->powers[pw_shield] & ~(SH_FORCEHP|SH_STACK)) == SH_FORCE) @@ -5167,7 +5167,7 @@ static void P_DoJumpStuff(player_t *player, ticcmd_t *cmd) // and you don't have a shield, do it! P_DoSuperTransformation(player, false); } - else if (!LUAh_JumpSpinSpecial(player)) + else if (!LUA_HookPlayer(player, Hook(JumpSpinSpecial))) switch (player->charability) { case CA_THOK: @@ -5240,7 +5240,7 @@ static void P_DoJumpStuff(player_t *player, ticcmd_t *cmd) if (cmd->buttons & BT_JUMP && !player->exiting && !P_PlayerInPain(player)) { - if (LUAh_JumpSpecial(player)) + if (LUA_HookPlayer(player, Hook(JumpSpecial))) ; // all situations below this require jump button not to be pressed already else if (player->pflags & PF_JUMPDOWN) @@ -5275,7 +5275,7 @@ static void P_DoJumpStuff(player_t *player, ticcmd_t *cmd) }*/ else if (player->pflags & PF_JUMPED) { - if (!LUAh_AbilitySpecial(player)) + if (!LUA_HookPlayer(player, Hook(AbilitySpecial))) switch (player->charability) { case CA_THOK: @@ -5468,7 +5468,7 @@ static void P_DoJumpStuff(player_t *player, ticcmd_t *cmd) } else if (player->pflags & PF_THOKKED) { - if (!LUAh_AbilitySpecial(player)) + if (!LUA_HookPlayer(player, Hook(AbilitySpecial))) switch (player->charability) { case CA_FLY: @@ -10490,7 +10490,7 @@ boolean P_SpectatorJoinGame(player_t *player) else changeto = (P_RandomFixed() & 1) + 1; - if (!LUAh_TeamSwitch(player, changeto, true, false, false)) + if (!LUA_HookTeamSwitch(player, changeto, true, false, false)) return false; if (player->mo) @@ -10507,7 +10507,7 @@ boolean P_SpectatorJoinGame(player_t *player) { // Call ViewpointSwitch hooks here. // The viewpoint was forcibly changed. - LUAh_ViewpointSwitch(player, &players[consoleplayer], true); + LUA_HookViewpointSwitch(player, &players[consoleplayer], true); displayplayer = consoleplayer; } @@ -10525,7 +10525,7 @@ boolean P_SpectatorJoinGame(player_t *player) // respawn in place and sit there for the rest of the round. if (!((gametyperules & GTR_HIDEFROZEN) && leveltime > (hidetime * TICRATE))) { - if (!LUAh_TeamSwitch(player, 3, true, false, false)) + if (!LUA_HookTeamSwitch(player, 3, true, false, false)) return false; if (player->mo) { @@ -10552,7 +10552,7 @@ boolean P_SpectatorJoinGame(player_t *player) { // Call ViewpointSwitch hooks here. // The viewpoint was forcibly changed. - LUAh_ViewpointSwitch(player, &players[consoleplayer], true); + LUA_HookViewpointSwitch(player, &players[consoleplayer], true); displayplayer = consoleplayer; } @@ -11477,7 +11477,7 @@ void P_PlayerThink(player_t *player) } if (player->playerstate == PST_REBORN) { - LUAh_PlayerThink(player); + LUA_HookPlayer(player, Hook(PlayerThink)); return; } } @@ -11581,7 +11581,7 @@ void P_PlayerThink(player_t *player) if (player->playerstate == PST_DEAD) { - LUAh_PlayerThink(player); + LUA_HookPlayer(player, Hook(PlayerThink)); return; } } @@ -11702,7 +11702,7 @@ void P_PlayerThink(player_t *player) { player->mo->flags2 &= ~MF2_SHADOW; P_DeathThink(player); - LUAh_PlayerThink(player); + LUA_HookPlayer(player, Hook(PlayerThink)); return; } @@ -11744,7 +11744,7 @@ void P_PlayerThink(player_t *player) { if (P_SpectatorJoinGame(player)) { - LUAh_PlayerThink(player); + LUA_HookPlayer(player, Hook(PlayerThink)); return; // player->mo was removed. } } @@ -11849,7 +11849,7 @@ void P_PlayerThink(player_t *player) if (!player->mo) { - LUAh_PlayerThink(player); + LUA_HookPlayer(player, Hook(PlayerThink)); return; // P_MovePlayer removed player->mo. } @@ -12303,7 +12303,7 @@ void P_PlayerThink(player_t *player) } #undef dashmode - LUAh_PlayerThink(player); + LUA_HookPlayer(player, Hook(PlayerThink)); /* // Colormap verification @@ -12863,7 +12863,7 @@ void P_PlayerAfterThink(player_t *player) if (player->followmobj) { - if (LUAh_FollowMobj(player, player->followmobj) || P_MobjWasRemoved(player->followmobj)) + if (LUA_HookFollowMobj(player, player->followmobj) || P_MobjWasRemoved(player->followmobj)) {;} else { diff --git a/src/s_sound.c b/src/s_sound.c index 36bd454c1..106a5bd23 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -2262,6 +2262,16 @@ static void S_ChangeMusicToQueue(void) void S_ChangeMusicEx(const char *mmusic, UINT16 mflags, boolean looping, UINT32 position, UINT32 prefadems, UINT32 fadeinms) { char newmusic[7]; + + struct MusicChange hook_param = { + newmusic, + &mflags, + &looping, + &position, + &prefadems, + &fadeinms + }; + boolean currentmidi = (I_SongType() == MU_MID || I_SongType() == MU_MID_EX); boolean midipref = cv_musicpref.value; @@ -2269,7 +2279,7 @@ void S_ChangeMusicEx(const char *mmusic, UINT16 mflags, boolean looping, UINT32 return; strncpy(newmusic, mmusic, 7); - if (LUAh_MusicChange(music_name, newmusic, &mflags, &looping, &position, &prefadems, &fadeinms)) + if (LUA_HookMusicChange(music_name, &hook_param)) return; newmusic[6] = 0; diff --git a/src/s_sound.h b/src/s_sound.h index 4ac3c70bf..c872c2224 100644 --- a/src/s_sound.h +++ b/src/s_sound.h @@ -265,6 +265,16 @@ boolean S_RecallMusic(UINT16 status, boolean fromfirst); // Music Playback // +/* this is for the sake of the hook */ +struct MusicChange { + char * newname; + UINT16 * mflags; + boolean * looping; + UINT32 * position; + UINT32 * prefadems; + UINT32 * fadeinms; +}; + // Start music track, arbitrary, given its name, and set whether looping // note: music flags 12 bits for tracknum (gme, other formats with more than one track) // 13-15 aren't used yet diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index b8b3b9d34..8ca4f758a 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -1058,7 +1058,7 @@ void I_GetEvent(void) break; case SDL_QUIT: if (Playing()) - LUAh_GameQuit(); + LUA_Hook(GameQuit); I_Quit(); break; } diff --git a/src/y_inter.c b/src/y_inter.c index 061cbb5e1..ae4dcdaf0 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -927,7 +927,7 @@ void Y_Ticker(void) if (paused || P_AutoPause()) return; - LUAh_IntermissionThinker(); + LUA_Hook(IntermissionThinker); intertic++; From 0df5d8ff58da2fcb6e20db31257308d8724c651e Mon Sep 17 00:00:00 2001 From: James R Date: Thu, 10 Dec 2020 03:06:41 -0800 Subject: [PATCH 0441/1080] Oops! --- src/m_anigif.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/m_anigif.c b/src/m_anigif.c index 5c42fc605..41f99254e 100644 --- a/src/m_anigif.c +++ b/src/m_anigif.c @@ -621,7 +621,7 @@ static void GIF_framewrite(void) { float delayf = ceil(100.0f/NEWTICRATE); - delay = (UINT16)((I_GetTimeMicros() - gif_prevframeus)/10/1000); + delay = (UINT16)I_PreciseToMicros((I_GetPreciseTime() - gif_prevframetime))/10/1000; if (delay < (UINT16)(delayf)) delay = (UINT16)(delayf); From 3f7c2ae0b0c450cb8993ffe7664ead05fd9f5000 Mon Sep 17 00:00:00 2001 From: James R Date: Thu, 10 Dec 2020 05:39:53 -0800 Subject: [PATCH 0442/1080] Avoid using multiple tables to fetch hook String hooks still use a table to fetch the id, but the id indexes a C array. Also I fixed a missing call in the MusicChange hook. --- src/lua_hooklib.c | 212 ++++++++++++++++++++++------------------------ 1 file changed, 101 insertions(+), 111 deletions(-) diff --git a/src/lua_hooklib.c b/src/lua_hooklib.c index 2d5ee44e4..02c427979 100644 --- a/src/lua_hooklib.c +++ b/src/lua_hooklib.c @@ -52,17 +52,24 @@ static inline int in_bit_array (const UINT8 *array, const int n) { return array[n >> 3] & (1 << (n & 7)); } +typedef struct { + int numHooks; + int *ids; +} hook_t; + typedef struct { int numGeneric; int ref; } stringhook_t; -static int hookRefs[Hook(MAX)]; -static int mobjHookRefs[NUMMOBJTYPES][Mobj_Hook(MAX)]; +static hook_t hookIds[Hook(MAX)]; +static hook_t mobjHookIds[NUMMOBJTYPES][Mobj_Hook(MAX)]; +// Lua tables are used to lookup string hook ids. static stringhook_t stringHooks[String_Hook(MAX)]; -static int hookReg; +// This will be indexed by hook id, the value of which fetches the registry. +static int * hookRefs; // After a hook errors once, don't print the error again. static UINT8 * hooksErrored; @@ -71,8 +78,8 @@ static boolean mobj_hook_available(int hook_type, mobjtype_t mobj_type) { return ( - mobjHookRefs [MT_NULL] [hook_type] > 0 || - mobjHookRefs[mobj_type][hook_type] > 0 + mobjHookIds [MT_NULL] [hook_type].numHooks > 0 || + mobjHookIds[mobj_type][hook_type].numHooks > 0 ); } @@ -109,32 +116,10 @@ static void get_table(lua_State *L) lua_remove(L, -2); } -static void new_hook_table(lua_State *L, int *ref) +static void add_hook_to_table(lua_State *L, int id, int n) { - if (*ref > 0) - lua_getref(L, *ref); - else - { - lua_newtable(L); - lua_pushvalue(L, -1); - *ref = luaL_ref(L, LUA_REGISTRYINDEX); - } -} - -static void add_hook(lua_State *L, int id) -{ - lua_pushnumber(L, 1 + id); - lua_rawseti(L, -2, 1 + lua_objlen(L, -2)); -} - -static void add_mobj_hook(lua_State *L, int hook_type, int id) -{ - mobjtype_t mobj_type = luaL_optnumber(L, 3, MT_NULL); - - luaL_argcheck(L, mobj_type < NUMMOBJTYPES, 3, "invalid mobjtype_t"); - - new_hook_table(L, &mobjHookRefs[mobj_type][hook_type]); - add_hook(L, id); + lua_pushnumber(L, id); + lua_rawseti(L, -2, n); } static void add_string_hook(lua_State *L, int type, int id) @@ -160,19 +145,39 @@ static void add_string_hook(lua_State *L, int type, int id) break; } - new_hook_table(L, &hook->ref); + if (hook->ref > 0) + lua_getref(L, hook->ref); + else + { + lua_newtable(L); + lua_pushvalue(L, -1); + hook->ref = luaL_ref(L, LUA_REGISTRYINDEX); + } if (string) { lua_pushstring(L, string); get_table(L); - add_hook(L, id); + add_hook_to_table(L, id, 1 + lua_objlen(L, -1)); } else - { - lua_pushnumber(L, 1 + id); - lua_rawseti(L, -2, ++hook->numGeneric); - } + add_hook_to_table(L, id, ++hook->numGeneric); +} + +static void add_hook(hook_t *map, int id) +{ + Z_Realloc(map->ids, (map->numHooks + 1) * sizeof *map->ids, + PU_STATIC, &map->ids); + map->ids[map->numHooks++] = id; +} + +static void add_mobj_hook(lua_State *L, int hook_type, int id) +{ + mobjtype_t mobj_type = luaL_optnumber(L, 3, MT_NULL); + + luaL_argcheck(L, mobj_type < NUMMOBJTYPES, 3, "invalid mobjtype_t"); + + add_hook(&mobjHookIds[mobj_type][hook_type], id); } // Takes hook, function, and additional arguments (mobj type to act on, etc.) @@ -200,8 +205,7 @@ static int lib_addHook(lua_State *L) } else if (( type = hook_in_list(name, hookNames) ) < Hook(MAX)) { - new_hook_table(L, &hookRefs[type]); - add_hook(L, nextid); + add_hook(&hookIds[type], nextid); } else { @@ -216,17 +220,17 @@ static int lib_addHook(lua_State *L) hooksErrored[nextid >> 3] = 0; } + Z_Realloc(hookRefs, (nextid + 1) * sizeof *hookRefs, PU_STATIC, &hookRefs); + // set the hook function in the registry. - lua_getref(L, hookReg); lua_pushvalue(L, 2);/* the function */ - lua_rawseti(L, -2, ++nextid); + hookRefs[nextid++] = luaL_ref(L, LUA_REGISTRYINDEX); return 0; } int LUA_HookLib(lua_State *L) { - new_hook_table(L, &hookReg); lua_register(L, "addHook", lib_addHook); return 0; } @@ -237,21 +241,19 @@ typedef void (*Hook_Callback)(Hook_State *); struct Hook_State { int status;/* return status to calling function */ void * userdata; - int ref;/* ref for primary hook table */ - int hook_type;/* Hook or Hook(MAX) + Mobj_Hook */ - mobjtype_t mobj_type; + int hook_type; + mobjtype_t mobj_type;/* >0 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 function from registry */ + int id;/* id to fetch ref */ int values;/* num arguments passed to hook */ int results;/* num values returned by hook */ Hook_Callback results_handler;/* callback when hook successfully returns */ }; enum { - HINDEX = 1,/* hook registry */ - EINDEX = 2,/* error handler */ - SINDEX = 3,/* string itself is pushed in case of string hook */ + EINDEX = 1,/* error handler */ + SINDEX = 2,/* string itself is pushed in case of string hook */ }; static void push_error_handler(void) @@ -268,7 +270,6 @@ static void push_string(void) static boolean start_hook_stack(void) { lua_settop(gL, 0); - lua_getref(gL, hookReg); push_error_handler(); return true; } @@ -280,20 +281,12 @@ static boolean init_hook_type int hook_type, mobjtype_t mobj_type, const char * string, - int ref + int nonzero ){ - boolean ready; - hook->status = status; - if (mobj_type > 0) - ready = mobj_hook_available(hook_type, mobj_type); - else - ready = ref > 0; - - if (ready) + if (nonzero) { - hook->ref = ref; hook->hook_type = hook_type; hook->mobj_type = mobj_type; hook->string = string; @@ -311,7 +304,7 @@ static boolean prepare_hook ){ return init_hook_type(hook, default_status, hook_type, 0, NULL, - hookRefs[hook_type]); + hookIds[hook_type].numHooks); } static boolean prepare_mobj_hook @@ -323,7 +316,7 @@ static boolean prepare_mobj_hook ){ return init_hook_type(hook, default_status, hook_type, mobj_type, NULL, - mobjHookRefs[mobj_type][hook_type]); + mobj_hook_available(hook_type, mobj_type)); } static boolean prepare_string_hook @@ -357,16 +350,17 @@ static void init_hook_call hook->results_handler = results_handler; } -static void get_hook_table(Hook_State *hook) +static void get_hook(Hook_State *hook, const int *ids, int n) { - lua_getref(gL, hook->ref); + hook->id = ids[n]; + lua_getref(gL, hookRefs[hook->id]); } -static void get_hook(Hook_State *hook, int n) +static void get_hook_from_table(Hook_State *hook, int n) { lua_rawgeti(gL, -1, n); - hook->id = lua_tonumber(gL, -1) - 1; - lua_rawget(gL, HINDEX); + hook->id = lua_tonumber(gL, -1); + lua_getref(gL, hookRefs[hook->id]); } static int call_single_hook_no_copy(Hook_State *hook) @@ -409,7 +403,7 @@ static int call_hook_table_for(Hook_State *hook, int n) for (k = 1; k <= n; ++k) { - get_hook(hook, k); + get_hook_from_table(hook, k); call_single_hook(hook); } @@ -421,31 +415,29 @@ static int call_hook_table(Hook_State *hook) return call_hook_table_for(hook, lua_objlen(gL, -1)); } -static int call_ref(Hook_State *hook, int ref) +static int call_mapped(Hook_State *hook, const hook_t *map) { - int calls; + int k; - if (ref > 0) + for (k = 0; k < map->numHooks; ++k) { - lua_getref(gL, ref); - calls = call_hook_table(hook); - - return calls; + get_hook(hook, map->ids, k); + call_single_hook(hook); } - else - return 0; + + return map->numHooks; } static int call_string_hooks(Hook_State *hook) { - const int numGeneric = stringHooks[hook->hook_type].numGeneric; + const stringhook_t *map = &stringHooks[hook->hook_type]; int calls = 0; - get_hook_table(hook); + lua_getref(gL, map->ref); /* call generic string hooks first */ - calls += call_hook_table_for(hook, numGeneric); + calls += call_hook_table_for(hook, map->numGeneric); push_string(); lua_rawget(gL, -2); @@ -454,10 +446,9 @@ static int call_string_hooks(Hook_State *hook) return calls; } -static int call_generic_mobj_hooks(Hook_State *hook) +static int call_mobj_type_hooks(Hook_State *hook, mobjtype_t mobj_type) { - const int ref = mobjHookRefs[MT_NULL][hook->hook_type]; - return call_ref(hook, ref); + return call_mapped(hook, &mobjHookIds[mobj_type][hook->hook_type]); } static int call_hooks @@ -475,16 +466,16 @@ static int call_hooks { calls += call_string_hooks(hook); } - else + else if (hook->mobj_type > 0) { - if (hook->mobj_type > 0) - calls += call_generic_mobj_hooks(hook); + /* call generic mobj hooks first */ + calls += call_mobj_type_hooks(hook, MT_NULL); + calls += call_mobj_type_hooks(hook, hook->mobj_type); - calls += call_ref(hook, hook->ref); - - if (hook->mobj_type > 0) - ps_lua_mobjhooks += calls; + ps_lua_mobjhooks += calls; } + else + calls += call_mapped(hook, &hookIds[hook->hook_type]); lua_settop(gL, 0); @@ -600,25 +591,24 @@ int LUA_HookTiccmd(player_t *player, ticcmd_t *cmd, int hook_type) void LUA_HookThinkFrame(void) { + const int type = Hook(ThinkFrame); + // variables used by perf stats int hook_index = 0; precise_t time_taken = 0; Hook_State hook; - int n; + const hook_t * map = &hookIds[type]; int k; - if (prepare_hook(&hook, 0, Hook(ThinkFrame))) + if (prepare_hook(&hook, 0, type)) { init_hook_call(&hook, 0, 0, res_none); - get_hook_table(&hook); - n = lua_objlen(gL, -1); - - for (k = 1; k <= n; ++k) + for (k = 0; k < map->numHooks; ++k) { - get_hook(&hook, k); + get_hook(&hook, map->ids, k); if (cv_perfstats.value == 3) { @@ -839,19 +829,16 @@ int LUA_HookHurtMsg(player_t *player, mobj_t *inflictor, mobj_t *source, UINT8 d void LUA_HookNetArchive(lua_CFunction archFunc) { - const int ref = hookRefs[Hook(NetVars)]; + const hook_t * map = &hookIds[Hook(NetVars)]; Hook_State hook; /* this is a remarkable case where the stack isn't reset */ - if (ref > 0) + if (map->numHooks > 0) { // stack: tables I_Assert(lua_gettop(gL) > 0); I_Assert(lua_istable(gL, -1)); push_error_handler(); - lua_getref(gL, hookReg); - - lua_insert(gL, HINDEX); lua_insert(gL, EINDEX); // tables becomes an upvalue of archFunc @@ -860,11 +847,10 @@ void LUA_HookNetArchive(lua_CFunction archFunc) // stack: tables, archFunc init_hook_call(&hook, 1, 0, res_none); - call_ref(&hook, ref); + call_mapped(&hook, map); lua_pop(gL, 2); // pop hook table and archFunc lua_remove(gL, EINDEX); // pop error handler - lua_remove(gL, HINDEX); // pop hook registry // stack: tables } } @@ -1031,22 +1017,25 @@ static void res_musicchange(Hook_State *hook) int LUA_HookMusicChange(const char *oldname, struct MusicChange *param) { - Hook_State hook; - if (prepare_hook(&hook, false, Hook(MusicChange))) - { - int n; - int k; + const int type = Hook(MusicChange); + const hook_t * map = &hookIds[type]; + Hook_State hook; + + int k; + + if (prepare_hook(&hook, false, type)) + { init_hook_call(&hook, 7, 6, res_musicchange); hook.userdata = param; lua_pushstring(gL, oldname);/* the only constant value */ lua_pushstring(gL, param->newname);/* semi constant */ - get_hook_table(&hook); - n = lua_objlen(gL, -1); + for (k = 0; k <= map->numHooks; ++k) + { + get_hook(&hook, map->ids, k); - for (k = 1; k <= n; ++k) { lua_pushvalue(gL, -3); lua_pushvalue(gL, -3); lua_pushinteger(gL, *param->mflags); @@ -1060,5 +1049,6 @@ int LUA_HookMusicChange(const char *oldname, struct MusicChange *param) lua_settop(gL, 0); } + return hook.status; } From dbd8903a538e7b87061795ce27ec5c72c26743af Mon Sep 17 00:00:00 2001 From: James R Date: Thu, 10 Dec 2020 08:50:23 -0800 Subject: [PATCH 0443/1080] Use ref for pushing error handler --- src/lua_hooklib.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/lua_hooklib.c b/src/lua_hooklib.c index 02c427979..1ac9a6952 100644 --- a/src/lua_hooklib.c +++ b/src/lua_hooklib.c @@ -74,6 +74,8 @@ static int * hookRefs; // After a hook errors once, don't print the error again. static UINT8 * hooksErrored; +static int errorRef; + static boolean mobj_hook_available(int hook_type, mobjtype_t mobj_type) { return @@ -231,7 +233,11 @@ static int lib_addHook(lua_State *L) int LUA_HookLib(lua_State *L) { + lua_pushcfunction(L, LUA_GetErrorMessage); + errorRef = luaL_ref(L, LUA_REGISTRYINDEX); + lua_register(L, "addHook", lib_addHook); + return 0; } @@ -258,7 +264,7 @@ enum { static void push_error_handler(void) { - lua_pushcfunction(gL, LUA_GetErrorMessage); + lua_getref(gL, errorRef); } /* repush hook string */ From 39a320734dcb53243aaff5228c63870e1295ef44 Mon Sep 17 00:00:00 2001 From: Louis-Antoine Date: Thu, 12 Nov 2020 21:25:31 +0100 Subject: [PATCH 0444/1080] Add shorthand aliases for fixed-point functions --- src/lua_mathlib.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/lua_mathlib.c b/src/lua_mathlib.c index 7cbe7a6cc..10ba42ee0 100644 --- a/src/lua_mathlib.c +++ b/src/lua_mathlib.c @@ -192,18 +192,30 @@ static luaL_Reg lib[] = { {"cos", lib_finecosine}, {"tan", lib_finetangent}, {"FixedAngle", lib_fixedangle}, + {"fixangle" , lib_fixedangle}, {"AngleFixed", lib_anglefixed}, + {"anglefix" , lib_anglefixed}, {"InvAngle", lib_invangle}, {"FixedMul", lib_fixedmul}, + {"fixmul" , lib_fixedmul}, {"FixedInt", lib_fixedint}, + {"fixint" , lib_fixedint}, {"FixedDiv", lib_fixeddiv}, + {"fixdiv" , lib_fixeddiv}, {"FixedRem", lib_fixedrem}, + {"fixrem" , lib_fixedrem}, {"FixedSqrt", lib_fixedsqrt}, + {"fixsqrt" , lib_fixedsqrt}, {"FixedHypot", lib_fixedhypot}, + {"fixhypot" , lib_fixedhypot}, {"FixedFloor", lib_fixedfloor}, + {"fixfloor" , lib_fixedfloor}, {"FixedTrunc", lib_fixedtrunc}, + {"fixtrunc" , lib_fixedtrunc}, {"FixedCeil", lib_fixedceil}, + {"fixceil" , lib_fixedceil}, {"FixedRound", lib_fixedround}, + {"fixround" , lib_fixedround}, {"GetSecSpecial", lib_getsecspecial}, {"All7Emeralds", lib_all7emeralds}, {"ColorOpposite", lib_coloropposite}, From 3aecc2276430ab55851a89f012a9663fec48f30f Mon Sep 17 00:00:00 2001 From: Louis-Antoine Date: Thu, 12 Nov 2020 21:33:47 +0100 Subject: [PATCH 0445/1080] Add a shorthand alias for FRACUNIT --- src/deh_tables.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/deh_tables.c b/src/deh_tables.c index 5733d9b0e..926ca805c 100644 --- a/src/deh_tables.c +++ b/src/deh_tables.c @@ -4794,6 +4794,7 @@ struct int_const_s const INT_CONST[] = { // fixed_t constants, from m_fixed.h {"FRACUNIT",FRACUNIT}, + {"FU" ,FRACUNIT}, {"FRACBITS",FRACBITS}, // doomdef.h constants From 69d98b22ad19b49072143d98ce4333a474f65826 Mon Sep 17 00:00:00 2001 From: James R Date: Thu, 10 Dec 2020 13:40:47 -0800 Subject: [PATCH 0446/1080] Credits: add Zolton and Ors to the programming section --- src/f_finale.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/f_finale.c b/src/f_finale.c index 688cd4fc7..b23ab4f7a 100644 --- a/src/f_finale.c +++ b/src/f_finale.c @@ -1074,6 +1074,7 @@ static const char *credits[] = { "\1Programming", "Alam \"GBC\" Arias", "Logan \"GBA\" Arias", + "Zolton \"Zippy_Zolton\" Auburn", "Colette \"fickleheart\" Bordelon", "Andrew \"orospakr\" Clunis", "Sally \"TehRealSalt\" Cochenour", @@ -1104,6 +1105,7 @@ static const char *credits[] = { "Sean \"Sryder13\" Ryder", "Ehab \"Wolfy\" Saeed", "Tasos \"tatokis\" Sahanidis", // Corrected C FixedMul, making 64-bit builds netplay compatible + "Riku \"Ors\" Salminen", // Demo consistency improvements "Jonas \"MascaraSnake\" Sauer", "Wessel \"sphere\" Smit", "\"SSNTails\"", From 317c107064a1ed88da40b342e07fc4f86d1d6197 Mon Sep 17 00:00:00 2001 From: Zippy_Zolton Date: Thu, 10 Dec 2020 16:09:43 -0600 Subject: [PATCH 0447/1080] Make player->speed use R_PointToDist2 --- 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 892f4b678..292e452d7 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -5924,7 +5924,7 @@ static void P_3dMovement(player_t *player) player->rmomy = player->mo->momy - player->cmomy; // Calculates player's speed based on distance-of-a-line formula - player->speed = P_AproxDistance(player->rmomx, player->rmomy); + 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! From 3472b3ece38bc6d62ff248bfdf34950ec4709105 Mon Sep 17 00:00:00 2001 From: Jaime Ita Passos Date: Thu, 10 Dec 2020 21:55:22 -0300 Subject: [PATCH 0448/1080] Fix ERZ3 mode --- 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 e664d85be..2393013de 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -10438,19 +10438,12 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type) mobj->x = x; mobj->y = y; - // TODO: Make this a special map header - if ((maptol & TOL_ERZ3) && !(mobj->type == MT_BLACKEGGMAN)) - mobj->destscale = FRACUNIT/2; - P_SetMobjSpawnDefaults(mobj); // set subsector and/or block links P_SetThingPosition(mobj); I_Assert(mobj->subsector != NULL); - // Make sure scale matches destscale immediately when spawned - P_SetScale(mobj, mobj->destscale); - mobj->floorz = P_GetSectorFloorZAt (mobj->subsector->sector, x, y); mobj->ceilingz = P_GetSectorCeilingZAt(mobj->subsector->sector, x, y); @@ -10816,9 +10809,16 @@ void P_SetMobjSpawnDefaults(mobj_t *mobj) mobj->destscale = mobj->scale; mobj->scalespeed = FRACUNIT/12; + // TODO: Make this a special map header + if ((maptol & TOL_ERZ3) && !(mobj->type == MT_BLACKEGGMAN)) + mobj->destscale = FRACUNIT/2; + + // Make sure scale matches destscale immediately when spawned + P_SetScale(mobj, mobj->destscale); + // Sprite rendering mobj->blendmode = AST_TRANSLUCENT; - mobj->spritexscale = mobj->spriteyscale = mobj->scale; + mobj->spritexscale = mobj->spriteyscale = FRACUNIT; mobj->spritexoffset = mobj->spriteyoffset = 0; mobj->floorspriteslope = NULL; } From 916cacb38f6e7072a1869bd1b964297f05210acb Mon Sep 17 00:00:00 2001 From: Zippy_Zolton Date: Thu, 10 Dec 2020 19:01:09 -0600 Subject: [PATCH 0449/1080] snailer --- src/p_enemy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_enemy.c b/src/p_enemy.c index 63a14636d..5feae4188 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -1834,7 +1834,7 @@ void A_SnailerThink(mobj_t *actor) fixed_t dist; fixed_t dx, dy; - dist = P_AproxDistance(actor->x - actor->target->x, actor->y - actor->target->y); + dist = R_PointToDist2(0, 0, actor->x - actor->target->x, actor->y - actor->target->y); if (an > ANGLE_45 && an <= ANGLE_90) // fire at 45 degrees to the left { From 440f46144a75d9048c24eef9fcaf34b0cad8181b Mon Sep 17 00:00:00 2001 From: Jaime Ita Passos Date: Thu, 10 Dec 2020 22:01:53 -0300 Subject: [PATCH 0450/1080] Fix intro crash --- src/w_wad.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/w_wad.c b/src/w_wad.c index 2429eaf92..6566800c0 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -1747,6 +1747,9 @@ void *W_CachePatchNum(lumpnum_t lumpnum, INT32 tag) void W_UnlockCachedPatch(void *patch) { + if (!patch) + return; + // The hardware code does its own memory management, as its patches // have different lifetimes from software's. #ifdef HWRENDER @@ -2144,7 +2147,7 @@ int W_VerifyNMUSlumps(const char *filename, boolean exit_on_error) {"LT", 2}, // Titlecard changes {"SLID", 4}, // Continue - {"CONT", 4}, + {"CONT", 4}, {"MINICAPS", 8}, // NiGHTS graphics here and below {"BLUESTAT", 8}, // Sphere status From f79ded7c0b86a6d8e9c23f8fb0ec2c417c03752a Mon Sep 17 00:00:00 2001 From: katsy Date: Thu, 10 Dec 2020 20:52:06 -0500 Subject: [PATCH 0451/1080] scale minimum dashmode thok on actionspd, not normalspeed --- 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 c5f919c78..c760d52ec 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -5289,7 +5289,7 @@ static void P_DoJumpStuff(player_t *player, ticcmd_t *cmd) fixed_t actionspd = player->actionspd; if (player->charflags & SF_DASHMODE) - actionspd = max(player->normalspeed, FixedDiv(player->speed, player->mo->scale)); + actionspd = max(player->actionspd, FixedDiv(player->speed, player->mo->scale)); if (player->mo->eflags & MFE_UNDERWATER) actionspd >>= 1; From f2095b57fd042dfbe58a1e696308d6b8c24083c3 Mon Sep 17 00:00:00 2001 From: Zippy_Zolton Date: Thu, 10 Dec 2020 20:37:50 -0600 Subject: [PATCH 0452/1080] Player-Colored Elemental Fire for competitive gametypes --- src/deh_tables.c | 7 +++++++ src/hardware/hw_light.c | 1 + src/info.c | 8 ++++++++ src/info.h | 8 ++++++++ src/p_user.c | 10 ++++++++++ 5 files changed, 34 insertions(+) diff --git a/src/deh_tables.c b/src/deh_tables.c index 7877903c5..67d876069 100644 --- a/src/deh_tables.c +++ b/src/deh_tables.c @@ -1522,6 +1522,13 @@ const char *const STATE_LIST[] = { // array length left dynamic for sanity testi "S_SPINFIRE5", "S_SPINFIRE6", + "S_TEAM_SPINFIRE1", + "S_TEAM_SPINFIRE2", + "S_TEAM_SPINFIRE3", + "S_TEAM_SPINFIRE4", + "S_TEAM_SPINFIRE5", + "S_TEAM_SPINFIRE6", + // Spikes "S_SPIKE1", "S_SPIKE2", diff --git a/src/hardware/hw_light.c b/src/hardware/hw_light.c index 987d70c69..93c61f4e7 100644 --- a/src/hardware/hw_light.c +++ b/src/hardware/hw_light.c @@ -253,6 +253,7 @@ light_t *t_lspr[NUMSPRITES] = &lspr[NOLIGHT], // SPR_SIGN &lspr[NOLIGHT], // SPR_SPIK &lspr[NOLIGHT], // SPR_SFLM + &lspr[NOLIGHT], // SPR_TFLM &lspr[NOLIGHT], // SPR_USPK &lspr[NOLIGHT], // SPR_WSPK &lspr[NOLIGHT], // SPR_WSPB diff --git a/src/info.c b/src/info.c index 56e764b5d..3ae9aeeb4 100644 --- a/src/info.c +++ b/src/info.c @@ -150,6 +150,7 @@ char sprnames[NUMSPRITES + 1][5] = "SIGN", // Level end sign "SPIK", // Spike Ball "SFLM", // Spin fire + "TFLM", // Spin fire (team) "USPK", // Floor spike "WSPK", // Wall spike "WSPB", // Wall spike base @@ -1894,6 +1895,13 @@ state_t states[NUMSTATES] = {SPR_SFLM, FF_FULLBRIGHT|4, 2, {NULL}, 0, 0, S_SPINFIRE6}, // S_SPINFIRE5 {SPR_SFLM, FF_FULLBRIGHT|5, 2, {NULL}, 0, 0, S_SPINFIRE1}, // S_SPINFIRE6 + {SPR_TFLM, FF_FULLBRIGHT, 2, {NULL}, 0, 0, S_TEAM_SPINFIRE2}, // S_TEAM_SPINFIRE1 + {SPR_TFLM, FF_FULLBRIGHT|1, 2, {NULL}, 0, 0, S_TEAM_SPINFIRE3}, // S_TEAM_SPINFIRE2 + {SPR_TFLM, FF_FULLBRIGHT|2, 2, {NULL}, 0, 0, S_TEAM_SPINFIRE4}, // S_TEAM_SPINFIRE3 + {SPR_TFLM, FF_FULLBRIGHT|3, 2, {NULL}, 0, 0, S_TEAM_SPINFIRE5}, // S_TEAM_SPINFIRE4 + {SPR_TFLM, FF_FULLBRIGHT|4, 2, {NULL}, 0, 0, S_TEAM_SPINFIRE6}, // S_TEAM_SPINFIRE5 + {SPR_TFLM, FF_FULLBRIGHT|5, 2, {NULL}, 0, 0, S_TEAM_SPINFIRE1}, // S_TEAM_SPINFIRE6 + // Floor Spike {SPR_USPK, 0,-1, {A_SpikeRetract}, 1, 0, S_SPIKE2}, // S_SPIKE1 -- Fully extended {SPR_USPK, 1, 2, {A_Pain}, 0, 0, S_SPIKE3}, // S_SPIKE2 diff --git a/src/info.h b/src/info.h index 604922beb..461afd180 100644 --- a/src/info.h +++ b/src/info.h @@ -684,6 +684,7 @@ typedef enum sprite SPR_SIGN, // Level end sign SPR_SPIK, // Spike Ball SPR_SFLM, // Spin fire + SPR_TFLM, // Spin fire (team) SPR_USPK, // Floor spike SPR_WSPK, // Wall spike SPR_WSPB, // Wall spike base @@ -2324,6 +2325,13 @@ typedef enum state S_SPINFIRE5, S_SPINFIRE6, + S_TEAM_SPINFIRE1, + S_TEAM_SPINFIRE2, + S_TEAM_SPINFIRE3, + S_TEAM_SPINFIRE4, + S_TEAM_SPINFIRE5, + S_TEAM_SPINFIRE6, + // Spikes S_SPIKE1, S_SPIKE2, diff --git a/src/p_user.c b/src/p_user.c index 892f4b678..09d148f41 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -7756,6 +7756,11 @@ void P_ElementalFire(player_t *player, boolean cropcircle) flame->eflags = (flame->eflags & ~MFE_VERTICALFLIP)|(player->mo->eflags & MFE_VERTICALFLIP); P_InstaThrust(flame, flame->angle, FixedMul(3*FRACUNIT, flame->scale)); P_SetObjectMomZ(flame, 3*FRACUNIT, false); + if (!(gametyperules & GTR_FRIENDLY)) + { + P_SetMobjState(flame, S_TEAM_SPINFIRE1); + flame->color = player->mo->color; + } } #undef limitangle #undef numangles @@ -7783,6 +7788,11 @@ void P_ElementalFire(player_t *player, boolean cropcircle) flame->destscale = player->mo->scale; P_SetScale(flame, player->mo->scale); flame->eflags = (flame->eflags & ~MFE_VERTICALFLIP)|(player->mo->eflags & MFE_VERTICALFLIP); + if (!(gametyperules & GTR_FRIENDLY)) + { + P_SetMobjState(flame, S_TEAM_SPINFIRE1); + flame->color = player->mo->color; + } flame->momx = 8; // this is a hack which is used to ensure it still behaves as a missile and can damage others P_XYMovement(flame); From 68de9f4bbe132bd57fbf072bc3dc861dd9f3be81 Mon Sep 17 00:00:00 2001 From: Zippy_Zolton Date: Fri, 11 Dec 2020 12:34:30 -0600 Subject: [PATCH 0453/1080] Make Ring Drain sectors play the depletion sound instead of the ring sound --- src/p_spec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_spec.c b/src/p_spec.c index 5b9e05c61..8843824ce 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -4304,7 +4304,7 @@ void P_ProcessSpecialSector(player_t *player, sector_t *sector, sector_t *rovers if (leveltime % (TICRATE/2) == 0 && player->rings > 0) { player->rings--; - S_StartSound(player->mo, sfx_itemup); + S_StartSound(player->mo, sfx_antiri); } break; case 11: // Special Stage Damage From 029e79024ba33f5b9ebfb08bba2be328df64fe14 Mon Sep 17 00:00:00 2001 From: Zwip-Zwap Zapony Date: Fri, 11 Dec 2020 23:43:38 +0100 Subject: [PATCH 0454/1080] V_DrawCroppedPatch Lua exposure and improvements Separated X and Y scale, and added colormap argument Added V_*SCALEPATCH and V_PERPLAYER flags support Made sx,sy,w,h into fixed-point values Exposed to Lua as "v.drawCropped(...)" (Also fix HWR_DrawStretchyFixedPatch ignoring vscale without pscale) --- src/console.c | 4 +- src/hardware/hw_draw.c | 147 ++++++++++++++++++++++++++++++----------- src/hardware/hw_main.h | 2 +- src/lua_hudlib.c | 40 +++++++++++ src/m_menu.c | 2 +- src/v_video.c | 71 +++++++++++++------- src/v_video.h | 2 +- src/y_inter.c | 2 +- 8 files changed, 202 insertions(+), 68 deletions(-) diff --git a/src/console.c b/src/console.c index b19b8818d..bcf01c989 100644 --- a/src/console.c +++ b/src/console.c @@ -1736,8 +1736,8 @@ static void CON_DrawBackpic(void) } // Draw the patch. - V_DrawCroppedPatch(x << FRACBITS, 0, FRACUNIT, V_NOSCALESTART, con_backpic, - 0, ( BASEVIDHEIGHT - h ), BASEVIDWIDTH, h); + V_DrawCroppedPatch(x << FRACBITS, 0, FRACUNIT, FRACUNIT, V_NOSCALESTART, con_backpic, NULL, + 0, (BASEVIDHEIGHT - h) << FRACBITS, BASEVIDWIDTH << FRACBITS, h << FRACBITS); // Unlock the cached patch. W_UnlockCachedPatch(con_backpic); diff --git a/src/hardware/hw_draw.c b/src/hardware/hw_draw.c index c5d362520..0322e9d27 100644 --- a/src/hardware/hw_draw.c +++ b/src/hardware/hw_draw.c @@ -317,7 +317,7 @@ void HWR_DrawStretchyFixedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t p } } - if (pscale != FRACUNIT || (splitscreen && option & V_PERPLAYER)) + if (pscale != FRACUNIT || vscale != FRACUNIT || (splitscreen && option & V_PERPLAYER)) { fwidth = (float)(gpatch->width) * fscalew * dupx; fheight = (float)(gpatch->height) * fscaleh * dupy; @@ -382,7 +382,7 @@ void HWR_DrawStretchyFixedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t p HWD.pfnDrawPolygon(NULL, v, 4, flags); } -void HWR_DrawCroppedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale, INT32 option, fixed_t sx, fixed_t sy, fixed_t w, fixed_t h) +void HWR_DrawCroppedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale, fixed_t vscale, INT32 option, const UINT8 *colormap, fixed_t sx, fixed_t sy, fixed_t w, fixed_t h) { FOutVector v[4]; FBITFIELD flags; @@ -395,13 +395,19 @@ void HWR_DrawCroppedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale, // | /| // |/ | // 0--1 - float dupx, dupy, fscale, fwidth, fheight; + float dupx, dupy, fscalew, fscaleh, fwidth, fheight; + + UINT8 perplayershuffle = 0; if (alphalevel >= 10 && alphalevel < 13) return; // make patch ready in hardware cache - HWR_GetPatch(gpatch); + if (!colormap) + HWR_GetPatch(gpatch); + else + HWR_GetMappedPatch(gpatch, colormap); + hwrPatch = ((GLPatch_t *)gpatch->hardware); dupx = (float)vid.dupx; @@ -423,12 +429,80 @@ void HWR_DrawCroppedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale, } dupx = dupy = (dupx < dupy ? dupx : dupy); - fscale = FIXED_TO_FLOAT(pscale); + fscalew = fscaleh = FIXED_TO_FLOAT(pscale); + if (vscale != pscale) + fscaleh = FIXED_TO_FLOAT(vscale); - // fuck it, no GL support for croppedpatch v_perplayer right now. it's not like it's accessible to Lua or anything, and we only use it for menus... + cx -= (float)(gpatch->leftoffset) * fscalew; + cy -= (float)(gpatch->topoffset) * fscaleh; - cy -= (float)(gpatch->topoffset) * fscale; - cx -= (float)(gpatch->leftoffset) * fscale; + if (splitscreen && (option & V_PERPLAYER)) + { + float adjusty = ((option & V_NOSCALESTART) ? vid.height : BASEVIDHEIGHT)/2.0f; + fscaleh /= 2; + cy /= 2; +#ifdef QUADS + if (splitscreen > 1) // 3 or 4 players + { + float adjustx = ((option & V_NOSCALESTART) ? vid.width : BASEVIDWIDTH)/2.0f; + fscalew /= 2; + cx /= 2; + if (stplyr == &players[displayplayer]) + { + if (!(option & (V_SNAPTOTOP|V_SNAPTOBOTTOM))) + perplayershuffle |= 1; + if (!(option & (V_SNAPTOLEFT|V_SNAPTORIGHT))) + perplayershuffle |= 4; + option &= ~V_SNAPTOBOTTOM|V_SNAPTORIGHT; + } + else if (stplyr == &players[secondarydisplayplayer]) + { + if (!(option & (V_SNAPTOTOP|V_SNAPTOBOTTOM))) + perplayershuffle |= 1; + if (!(option & (V_SNAPTOLEFT|V_SNAPTORIGHT))) + perplayershuffle |= 8; + cx += adjustx; + option &= ~V_SNAPTOBOTTOM|V_SNAPTOLEFT; + } + else if (stplyr == &players[thirddisplayplayer]) + { + if (!(option & (V_SNAPTOTOP|V_SNAPTOBOTTOM))) + perplayershuffle |= 2; + if (!(option & (V_SNAPTOLEFT|V_SNAPTORIGHT))) + perplayershuffle |= 4; + cy += adjusty; + option &= ~V_SNAPTOTOP|V_SNAPTORIGHT; + } + else if (stplyr == &players[fourthdisplayplayer]) + { + if (!(option & (V_SNAPTOTOP|V_SNAPTOBOTTOM))) + perplayershuffle |= 2; + if (!(option & (V_SNAPTOLEFT|V_SNAPTORIGHT))) + perplayershuffle |= 8; + cx += adjustx; + cy += adjusty; + option &= ~V_SNAPTOTOP|V_SNAPTOLEFT; + } + } + else +#endif + // 2 players + { + if (stplyr == &players[displayplayer]) + { + if (!(option & (V_SNAPTOTOP|V_SNAPTOBOTTOM))) + perplayershuffle = 1; + option &= ~V_SNAPTOBOTTOM; + } + else //if (stplyr == &players[secondarydisplayplayer]) + { + if (!(option & (V_SNAPTOTOP|V_SNAPTOBOTTOM))) + perplayershuffle = 2; + cy += adjusty; + option &= ~V_SNAPTOTOP; + } + } + } if (!(option & V_NOSCALESTART)) { @@ -437,18 +511,9 @@ void HWR_DrawCroppedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale, if (!(option & V_SCALEPATCHMASK)) { - // if it's meant to cover the whole screen, black out the rest (ONLY IF TOP LEFT ISN'T TRANSPARENT) - // cx and cy are possibly *slightly* off from float maths - // This is done before here compared to software because we directly alter cx and cy to centre - if (cx >= -0.1f && cx <= 0.1f && gpatch->width == BASEVIDWIDTH && cy >= -0.1f && cy <= 0.1f && gpatch->height == BASEVIDHEIGHT) - { - const column_t *column = (const column_t *)((const UINT8 *)(gpatch->columns) + (gpatch->columnofs[0])); - if (!column->topdelta) - { - const UINT8 *source = (const UINT8 *)(column) + 3; - HWR_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, (column->topdelta == 0xff ? 31 : source[0])); - } - } + // if it's meant to cover the whole screen, black out the rest + // no the patch is cropped do not do this ever + // centre screen if (fabsf((float)vid.width - (float)BASEVIDWIDTH * dupx) > 1.0E-36f) { @@ -456,6 +521,10 @@ void HWR_DrawCroppedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale, cx += ((float)vid.width - ((float)BASEVIDWIDTH * dupx)); else if (!(option & V_SNAPTOLEFT)) cx += ((float)vid.width - ((float)BASEVIDWIDTH * dupx))/2; + if (perplayershuffle & 4) + cx -= ((float)vid.width - ((float)BASEVIDWIDTH * dupx))/4; + else if (perplayershuffle & 8) + cx += ((float)vid.width - ((float)BASEVIDWIDTH * dupx))/4; } if (fabsf((float)vid.height - (float)BASEVIDHEIGHT * dupy) > 1.0E-36f) { @@ -463,23 +532,27 @@ void HWR_DrawCroppedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale, cy += ((float)vid.height - ((float)BASEVIDHEIGHT * dupy)); else if (!(option & V_SNAPTOTOP)) cy += ((float)vid.height - ((float)BASEVIDHEIGHT * dupy))/2; + if (perplayershuffle & 1) + cy -= ((float)vid.height - ((float)BASEVIDHEIGHT * dupy))/4; + else if (perplayershuffle & 2) + cy += ((float)vid.height - ((float)BASEVIDHEIGHT * dupy))/4; } } } - fwidth = w; - fheight = h; + fwidth = FIXED_TO_FLOAT(w); + fheight = FIXED_TO_FLOAT(h); - if (fwidth > gpatch->width) - fwidth = gpatch->width; + if (sx + w > gpatch->width<width< gpatch->height) - fheight = gpatch->height; + if (sy + h > gpatch->height<height<width))*hwrPatch->max_s; - if (sx + w > gpatch->width) - v[2].s = v[1].s = hwrPatch->max_s - ((sx+w)/(float)(gpatch->width))*hwrPatch->max_s; + v[0].s = v[3].s = (FIXED_TO_FLOAT(sx)/(float)(gpatch->width))*hwrPatch->max_s; + if (sx + w > gpatch->width<max_s; else - v[2].s = v[1].s = ((sx+w)/(float)(gpatch->width))*hwrPatch->max_s; + v[2].s = v[1].s = (FIXED_TO_FLOAT(sx+w)/(float)(gpatch->width))*hwrPatch->max_s; - v[0].t = v[1].t = ((sy)/(float)(gpatch->height))*hwrPatch->max_t; - if (sy + h > gpatch->height) - v[2].t = v[3].t = hwrPatch->max_t - ((sy+h)/(float)(gpatch->height))*hwrPatch->max_t; + v[0].t = v[1].t = (FIXED_TO_FLOAT(sy)/(float)(gpatch->height))*hwrPatch->max_t; + if (sy + h > gpatch->height<max_t; else - v[2].t = v[3].t = ((sy+h)/(float)(gpatch->height))*hwrPatch->max_t; + v[2].t = v[3].t = (FIXED_TO_FLOAT(sy+h)/(float)(gpatch->height))*hwrPatch->max_t; flags = PF_Translucent|PF_NoDepthTest; diff --git a/src/hardware/hw_main.h b/src/hardware/hw_main.h index 4ad09aa3d..708227585 100644 --- a/src/hardware/hw_main.h +++ b/src/hardware/hw_main.h @@ -39,7 +39,7 @@ void HWR_InitTextureMapping(void); void HWR_SetViewSize(void); void HWR_DrawPatch(patch_t *gpatch, INT32 x, INT32 y, INT32 option); void HWR_DrawStretchyFixedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale, fixed_t vscale, INT32 option, const UINT8 *colormap); -void HWR_DrawCroppedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t scale, INT32 option, fixed_t sx, fixed_t sy, fixed_t w, fixed_t h); +void HWR_DrawCroppedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale, fixed_t vscale, INT32 option, const UINT8 *colormap, fixed_t sx, fixed_t sy, fixed_t w, fixed_t h); void HWR_MakePatch(const patch_t *patch, GLPatch_t *grPatch, GLMipmap_t *grMipmap, boolean makebitmap); void HWR_CreatePlanePolygons(INT32 bspnum); void HWR_CreateStaticLightmaps(INT32 bspnum); diff --git a/src/lua_hudlib.c b/src/lua_hudlib.c index e58cd4a58..20eb33f37 100644 --- a/src/lua_hudlib.c +++ b/src/lua_hudlib.c @@ -660,6 +660,45 @@ static int libd_drawStretched(lua_State *L) return 0; } +static int libd_drawCropped(lua_State *L) +{ + fixed_t x, y, hscale, vscale, sx, sy, w, h; + INT32 flags; + patch_t *patch; + const UINT8 *colormap = NULL; + + HUDONLY + x = luaL_checkinteger(L, 1); + y = luaL_checkinteger(L, 2); + hscale = luaL_checkinteger(L, 3); + if (hscale < 0) + return luaL_error(L, "negative horizontal scale"); + vscale = luaL_checkinteger(L, 4); + if (vscale < 0) + return luaL_error(L, "negative vertical scale"); + patch = *((patch_t **)luaL_checkudata(L, 5, META_PATCH)); + flags = luaL_checkinteger(L, 6); + if (!lua_isnoneornil(L, 7)) + colormap = *((UINT8 **)luaL_checkudata(L, 7, META_COLORMAP)); + sx = luaL_checkinteger(L, 8); + if (sx < 0) // Don't crash. Now, we could do "x-=sx*FRACUNIT; sx=0;" here... + return luaL_error(L, "negative crop sx"); + sy = luaL_checkinteger(L, 9); + if (sy < 0) // ...but it's more truthful to just deny it, as negative values would crash + return luaL_error(L, "negative crop sy"); + w = luaL_checkinteger(L, 10); + if (w < 0) // Again, don't crash + return luaL_error(L, "negative crop w"); + h = luaL_checkinteger(L, 11); + if (h < 0) + return luaL_error(L, "negative crop h"); + + flags &= ~V_PARAMMASK; // Don't let crashes happen. + + V_DrawCroppedPatch(x, y, hscale, vscale, flags, patch, colormap, sx, sy, w, h); + return 0; +} + static int libd_drawNum(lua_State *L) { INT32 x, y, flags, num; @@ -1084,6 +1123,7 @@ static luaL_Reg lib_draw[] = { {"draw", libd_draw}, {"drawScaled", libd_drawScaled}, {"drawStretched", libd_drawStretched}, + {"drawCropped", libd_drawCropped}, {"drawNum", libd_drawNum}, {"drawPaddedNum", libd_drawPaddedNum}, {"drawFill", libd_drawFill}, diff --git a/src/m_menu.c b/src/m_menu.c index 5ec9132f7..003e308b0 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -4183,7 +4183,7 @@ static void M_DrawStaticBox(fixed_t x, fixed_t y, INT32 flags, fixed_t w, fixed_ if (staticalong > pw) // simplified for base LSSTATIC staticalong -= pw; - V_DrawCroppedPatch(x<> V_SCALEPATCHSHIFT) + { + case 1: // V_NOSCALEPATCH + dupx = dupy = 1; + break; + case 2: // V_SMALLSCALEPATCH + dupx = vid.smalldupx; + dupy = vid.smalldupy; + break; + case 3: // V_MEDSCALEPATCH + dupx = vid.meddupx; + dupy = vid.meddupy; + break; + default: + break; + } + + // only use one dup, to avoid stretching (har har) + dupx = dupy = (dupx < dupy ? dupx : dupy); + fdup = vdup = FixedMul(dupx<topoffset<leftoffset<topoffset<>= 1; + vdup >>= 1; rowfrac <<= 1; y >>= 1; - sy >>= 1; - h >>= 1; #ifdef QUADS if (splitscreen > 1) // 3 or 4 players { fixed_t adjustx = ((scrn & V_NOSCALESTART) ? vid.height : BASEVIDHEIGHT)<<(FRACBITS-1)); + fdup >>= 1; colfrac <<= 1; x >>= 1; - sx >>= 1; - w >>= 1; if (stplyr == &players[displayplayer]) { if (!(scrn & (V_SNAPTOTOP|V_SNAPTOBOTTOM))) @@ -896,7 +921,6 @@ void V_DrawCroppedPatch(fixed_t x, fixed_t y, fixed_t pscale, INT32 scrn, patch_ if (!(scrn & (V_SNAPTOLEFT|V_SNAPTORIGHT))) perplayershuffle |= 8; x += adjustx; - sx += adjustx; scrn &= ~V_SNAPTOBOTTOM|V_SNAPTOLEFT; } else if (stplyr == &players[thirddisplayplayer]) @@ -906,7 +930,6 @@ void V_DrawCroppedPatch(fixed_t x, fixed_t y, fixed_t pscale, INT32 scrn, patch_ if (!(scrn & (V_SNAPTOLEFT|V_SNAPTORIGHT))) perplayershuffle |= 4; y += adjusty; - sy += adjusty; scrn &= ~V_SNAPTOTOP|V_SNAPTORIGHT; } else //if (stplyr == &players[fourthdisplayplayer]) @@ -916,9 +939,7 @@ void V_DrawCroppedPatch(fixed_t x, fixed_t y, fixed_t pscale, INT32 scrn, patch_ if (!(scrn & (V_SNAPTOLEFT|V_SNAPTORIGHT))) perplayershuffle |= 8; x += adjustx; - sx += adjustx; y += adjusty; - sy += adjusty; scrn &= ~V_SNAPTOTOP|V_SNAPTOLEFT; } } @@ -937,7 +958,6 @@ void V_DrawCroppedPatch(fixed_t x, fixed_t y, fixed_t pscale, INT32 scrn, patch_ if (!(scrn & (V_SNAPTOTOP|V_SNAPTOBOTTOM))) perplayershuffle |= 2; y += adjusty; - sy += adjusty; scrn &= ~V_SNAPTOTOP; } } @@ -950,7 +970,8 @@ void V_DrawCroppedPatch(fixed_t x, fixed_t y, fixed_t pscale, INT32 scrn, patch_ deststop = desttop + vid.rowbytes * vid.height; - if (scrn & V_NOSCALESTART) { + if (scrn & V_NOSCALESTART) + { x >>= FRACBITS; y >>= FRACBITS; desttop += (y*vid.width) + x; @@ -998,7 +1019,7 @@ void V_DrawCroppedPatch(fixed_t x, fixed_t y, fixed_t pscale, INT32 scrn, patch_ desttop += (y*vid.width) + x; } - for (col = sx<>FRACBITS) < patch->width && ((col>>FRACBITS) - sx) < w; col += colfrac, ++x, desttop++) + for (col = sx; (col>>FRACBITS) < patch->width && (col - sx) < w; col += colfrac, ++x, desttop++) { INT32 topdelta, prevdelta = -1; if (x < 0) // don't draw off the left of the screen (WRAP PREVENTION) @@ -1015,15 +1036,15 @@ void V_DrawCroppedPatch(fixed_t x, fixed_t y, fixed_t pscale, INT32 scrn, patch_ prevdelta = topdelta; source = (const UINT8 *)(column) + 3; dest = desttop; - if (topdelta-sy > 0) + if ((topdelta< 0) { - dest += FixedInt(FixedMul((topdelta-sy)<>FRACBITS) < column->length && (((ofs>>FRACBITS) - sy) + topdelta) < h; ofs += rowfrac) + for (; dest < deststop && (ofs>>FRACBITS) < column->length && ((ofs - sy) + (topdelta<= screens[scrn&V_PARAMMASK]) // don't draw off the top of the screen (CRASH PREVENTION) *dest = patchdrawfunc(dest, source, ofs); diff --git a/src/v_video.h b/src/v_video.h index 8a18f82ad..f3f169079 100644 --- a/src/v_video.h +++ b/src/v_video.h @@ -165,7 +165,7 @@ void V_CubeApply(UINT8 *red, UINT8 *green, UINT8 *blue); #define V_DrawSciencePatch(x,y,s,p,sc) V_DrawFixedPatch(x,y,sc,s,p,NULL) #define V_DrawFixedPatch(x,y,sc,s,p,c) V_DrawStretchyFixedPatch(x,y,sc,sc,s,p,c) void V_DrawStretchyFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, fixed_t vscale, INT32 scrn, patch_t *patch, const UINT8 *colormap); -void V_DrawCroppedPatch(fixed_t x, fixed_t y, fixed_t pscale, INT32 scrn, patch_t *patch, fixed_t sx, fixed_t sy, fixed_t w, fixed_t h); +void V_DrawCroppedPatch(fixed_t x, fixed_t y, fixed_t pscale, fixed_t vscale, INT32 scrn, patch_t *patch, const UINT8 *colormap, fixed_t sx, fixed_t sy, fixed_t w, fixed_t h); void V_DrawContinueIcon(INT32 x, INT32 y, INT32 flags, INT32 skinnum, UINT16 skincolor); diff --git a/src/y_inter.c b/src/y_inter.c index 061cbb5e1..f2f676919 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -212,7 +212,7 @@ static void Y_IntermissionTokenDrawer(void) calc = (lowy - y)*2; if (calc > 0) - V_DrawCroppedPatch(32<width, calc); + V_DrawCroppedPatch(32<width< Date: Fri, 11 Dec 2020 20:59:14 -0500 Subject: [PATCH 0455/1080] make fire spindust dust fullbright --- src/info.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/info.c b/src/info.c index 29a79b1d6..8684c68f5 100644 --- a/src/info.c +++ b/src/info.c @@ -3299,10 +3299,10 @@ state_t states[NUMSTATES] = {SPR_BUBL, 0, 6, {NULL}, 0, 0, S_SPINDUST_BUBBLE3}, // S_SPINDUST_BUBBLE2 {SPR_BUBL, FF_TRANS30|0, 4, {NULL}, 0, 0, S_SPINDUST_BUBBLE4}, // S_SPINDUST_BUBBLE3 {SPR_BUBL, FF_TRANS60|0, 3, {NULL}, 0, 0, S_NULL}, // S_SPINDUST_BUBBLE4 - {SPR_FPRT, 0, 7, {NULL}, 0, 0, S_SPINDUST_FIRE2}, // S_SPINDUST_FIRE1 - {SPR_FPRT, 0, 6, {NULL}, 0, 0, S_SPINDUST_FIRE3}, // S_SPINDUST_FIRE2 - {SPR_FPRT, FF_TRANS30|0, 4, {NULL}, 0, 0, S_SPINDUST_FIRE4}, // S_SPINDUST_FIRE3 - {SPR_FPRT, FF_TRANS60|0, 3, {NULL}, 0, 0, S_NULL}, // S_SPINDUST_FIRE4 + {SPR_FPRT, FF_FULLBRIGHT|0, 7, {NULL}, 0, 0, S_SPINDUST_FIRE2}, // S_SPINDUST_FIRE1 + {SPR_FPRT, FF_FULLBRIGHT|0, 6, {NULL}, 0, 0, S_SPINDUST_FIRE3}, // S_SPINDUST_FIRE2 + {SPR_FPRT, FF_FULLBRIGHT|FF_TRANS30|0, 4, {NULL}, 0, 0, S_SPINDUST_FIRE4}, // S_SPINDUST_FIRE3 + {SPR_FPRT, FF_FULLBRIGHT|FF_TRANS60|0, 3, {NULL}, 0, 0, S_NULL}, // S_SPINDUST_FIRE4 {SPR_TFOG, FF_FULLBRIGHT|FF_TRANS50, 2, {NULL}, 0, 0, S_FOG2}, // S_FOG1 From ab156e17091479257fd6fc6287c7973a73d7329b Mon Sep 17 00:00:00 2001 From: Steel Titanium Date: Fri, 11 Dec 2020 23:11:15 -0500 Subject: [PATCH 0456/1080] Remove music slot compatibility --- src/deh_lua.c | 27 ------------- src/deh_soc.c | 100 ---------------------------------------------- src/deh_soc.h | 5 +-- src/doomdef.h | 4 -- src/lua_baselib.c | 67 +------------------------------ src/s_sound.c | 39 ++---------------- src/s_sound.h | 6 --- 7 files changed, 5 insertions(+), 243 deletions(-) diff --git a/src/deh_lua.c b/src/deh_lua.c index e6a436421..51632079b 100644 --- a/src/deh_lua.c +++ b/src/deh_lua.c @@ -25,10 +25,6 @@ #include "deh_lua.h" #include "deh_tables.h" -#ifdef MUSICSLOT_COMPATIBILITY -#include "deh_soc.h" // for get_mus -#endif - // freeslot takes a name (string only!) // and allocates it to the appropriate free slot. // Returns the slot number allocated for it or nil if failed. @@ -430,29 +426,6 @@ static inline int lib_getenum(lua_State *L) if (mathlib) return luaL_error(L, "sfx '%s' could not be found.\n", word); return 0; } -#ifdef MUSICSLOT_COMPATIBILITY - else if (!mathlib && fastncmp("mus_",word,4)) { - p = word+4; - if ((i = get_mus(p, false)) == 0) - return 0; - lua_pushinteger(L, i); - return 1; - } - else if (mathlib && fastncmp("MUS_",word,4)) { // SOCs are ALL CAPS! - p = word+4; - if ((i = get_mus(p, false)) == 0) - return luaL_error(L, "music '%s' could not be found.\n", word); - lua_pushinteger(L, i); - return 1; - } - else if (mathlib && (fastncmp("O_",word,2) || fastncmp("D_",word,2))) { - p = word+2; - if ((i = get_mus(p, false)) == 0) - return luaL_error(L, "music '%s' could not be found.\n", word); - lua_pushinteger(L, i); - return 1; - } -#endif else if (!mathlib && fastncmp("pw_",word,3)) { p = word+3; for (i = 0; i < NUMPOWERS; i++) diff --git a/src/deh_soc.c b/src/deh_soc.c index 5b12ea1b0..2cd872378 100644 --- a/src/deh_soc.c +++ b/src/deh_soc.c @@ -1574,19 +1574,6 @@ void readlevelheader(MYFILE *f, INT32 num) sizeof(mapheaderinfo[num-1]->musname), va("Level header %d: music", num)); } } -#ifdef MUSICSLOT_COMPATIBILITY - else if (fastcmp(word, "MUSICSLOT")) - { - i = get_mus(word2, true); - if (i && i <= 1035) - snprintf(mapheaderinfo[num-1]->musname, 7, "%sM", G_BuildMapName(i)); - else if (i && i <= 1050) - strncpy(mapheaderinfo[num-1]->musname, compat_special_music_slots[i - 1036], 7); - else - mapheaderinfo[num-1]->musname[0] = 0; // becomes empty string - mapheaderinfo[num-1]->musname[6] = 0; - } -#endif else if (fastcmp(word, "MUSICTRACK")) mapheaderinfo[num-1]->mustrack = ((UINT16)i - 1); else if (fastcmp(word, "MUSICPOS")) @@ -1964,19 +1951,6 @@ static void readcutscenescene(MYFILE *f, INT32 num, INT32 scenenum) strncpy(cutscenes[num]->scene[scenenum].musswitch, word2, 7); cutscenes[num]->scene[scenenum].musswitch[6] = 0; } -#ifdef MUSICSLOT_COMPATIBILITY - 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 else if (fastcmp(word, "MUSICTRACK")) { cutscenes[num]->scene[scenenum].musswitchflags = ((UINT16)i) & MUSIC_TRACKMASK; @@ -2239,19 +2213,6 @@ static void readtextpromptpage(MYFILE *f, INT32 num, INT32 pagenum) strncpy(textprompts[num]->page[pagenum].musswitch, word2, 7); textprompts[num]->page[pagenum].musswitch[6] = 0; } -#ifdef MUSICSLOT_COMPATIBILITY - else if (fastcmp(word, "MUSICSLOT")) - { - i = get_mus(word2, true); - if (i && i <= 1035) - snprintf(textprompts[num]->page[pagenum].musswitch, 7, "%sM", G_BuildMapName(i)); - else if (i && i <= 1050) - strncpy(textprompts[num]->page[pagenum].musswitch, compat_special_music_slots[i - 1036], 7); - else - textprompts[num]->page[pagenum].musswitch[0] = 0; // becomes empty string - textprompts[num]->page[pagenum].musswitch[6] = 0; - } -#endif else if (fastcmp(word, "MUSICTRACK")) { textprompts[num]->page[pagenum].musswitchflags = ((UINT16)i) & MUSIC_TRACKMASK; @@ -2577,20 +2538,6 @@ void readmenu(MYFILE *f, INT32 num) menupres[num].musname[6] = 0; titlechanged = true; } -#ifdef MUSICSLOT_COMPATIBILITY - else if (fastcmp(word, "MUSICSLOT")) - { - value = get_mus(word2, true); - if (value && value <= 1035) - snprintf(menupres[num].musname, 7, "%sM", G_BuildMapName(value)); - else if (value && value <= 1050) - strncpy(menupres[num].musname, compat_special_music_slots[value - 1036], 7); - else - menupres[num].musname[0] = 0; // becomes empty string - menupres[num].musname[6] = 0; - titlechanged = true; - } -#endif else if (fastcmp(word, "MUSICTRACK")) { menupres[num].mustrack = ((UINT16)value - 1); @@ -4178,46 +4125,6 @@ sfxenum_t get_sfx(const char *word) return sfx_None; } -#ifdef MUSICSLOT_COMPATIBILITY -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]); - - if (fastncmp("MUS_",word,4)) - word += 4; // take off the MUS_ - 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)) - { - word += 3; - if (toupper(word[0]) >= 'A' && toupper(word[0]) <= 'Z') - return (UINT16)M_MapNumber(word[0], word[1]); - else if ((i = atoi(word))) - return i; - - word -= 3; - if (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 - hudnum_t get_huditem(const char *word) { // Returns the value of HUD_ enumerations hudnum_t i; @@ -4448,13 +4355,6 @@ static fixed_t find_const(const char **rword) free(word); return r; } -#ifdef MUSICSLOT_COMPATIBILITY - else if (fastncmp("MUS_",word,4) || fastncmp("O_",word,2)) { - r = get_mus(word, true); - free(word); - return r; - } -#endif else if (fastncmp("PW_",word,3)) { r = get_power(word); free(word); diff --git a/src/deh_soc.h b/src/deh_soc.h index 2bcb52e70..0082e0e70 100644 --- a/src/deh_soc.h +++ b/src/deh_soc.h @@ -43,7 +43,7 @@ #include "info.h" #include "dehacked.h" -#include "doomdef.h" // MUSICSLOT_COMPATIBILITY, HWRENDER +#include "doomdef.h" // HWRENDER // Crazy word-reading stuff /// \todo Put these in a seperate file or something. @@ -52,9 +52,6 @@ statenum_t get_state(const char *word); spritenum_t get_sprite(const char *word); playersprite_t get_sprite2(const char *word); sfxenum_t get_sfx(const char *word); -#ifdef MUSICSLOT_COMPATIBILITY -UINT16 get_mus(const char *word, UINT8 dehacked_mode); -#endif hudnum_t get_huditem(const char *word); menutype_t get_menutype(const char *word); //INT16 get_gametype(const char *word); diff --git a/src/doomdef.h b/src/doomdef.h index d0b7ea0c2..3958d85d0 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -607,10 +607,6 @@ extern const char *compdate, *comptime, *comprevision, *compbranch; /// Experimental tweaks to analog mode. (Needs a lot of work before it's ready for primetime.) //#define REDSANALOG -/// Backwards compatibility with musicslots. -/// \note You should leave this enabled unless you're working with a future SRB2 version. -#define MUSICSLOT_COMPATIBILITY - /// Experimental attempts at preventing MF_PAPERCOLLISION objects from getting stuck in walls. //#define PAPER_COLLISIONCORRECTION diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 515f6f0ba..3836fffb8 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -2803,46 +2803,13 @@ static int lib_sStopSoundByID(lua_State *L) static int lib_sChangeMusic(lua_State *L) { -#ifdef MUSICSLOT_COMPATIBILITY - const char *music_name; - UINT32 music_num, position, prefadems, fadeinms; - char music_compat_name[7]; + UINT32 position, prefadems, fadeinms; - boolean looping; - player_t *player = NULL; - UINT16 music_flags = 0; - //NOHUD - - if (lua_isnumber(L, 1)) - { - music_num = (UINT32)luaL_checkinteger(L, 1); - music_flags = (UINT16)(music_num & 0x0000FFFF); - if (music_flags && music_flags <= 1035) - snprintf(music_compat_name, 7, "%sM", G_BuildMapName((INT32)music_flags)); - else if (music_flags && music_flags <= 1050) - strncpy(music_compat_name, compat_special_music_slots[music_flags - 1036], 7); - else - music_compat_name[0] = 0; // becomes empty string - music_compat_name[6] = 0; - music_name = (const char *)&music_compat_name; - music_flags = 0; - } - else - { - music_num = 0; - music_name = luaL_checkstring(L, 1); - } - - looping = (boolean)lua_opttrueboolean(L, 2); - -#else const char *music_name = luaL_checkstring(L, 1); boolean looping = (boolean)lua_opttrueboolean(L, 2); player_t *player = NULL; UINT16 music_flags = 0; - //NOHUD -#endif if (!lua_isnone(L, 3) && lua_isuserdata(L, 3)) { player = *((player_t **)luaL_checkudata(L, 3, META_PLAYER)); @@ -2850,13 +2817,7 @@ static int lib_sChangeMusic(lua_State *L) return LUA_ErrInvalid(L, "player_t"); } -#ifdef MUSICSLOT_COMPATIBILITY - if (music_num) - music_flags = (UINT16)((music_num & 0x7FFF0000) >> 16); - else -#endif music_flags = (UINT16)luaL_optinteger(L, 4, 0); - position = (UINT32)luaL_optinteger(L, 5, 0); prefadems = (UINT32)luaL_optinteger(L, 6, 0); fadeinms = (UINT32)luaL_optinteger(L, 7, 0); @@ -3153,33 +3114,7 @@ static int lib_sMusicExists(lua_State *L) { boolean checkMIDI = lua_opttrueboolean(L, 2); boolean checkDigi = lua_opttrueboolean(L, 3); -#ifdef MUSICSLOT_COMPATIBILITY - const char *music_name; - UINT32 music_num; - char music_compat_name[7]; - UINT16 music_flags = 0; - NOHUD - if (lua_isnumber(L, 1)) - { - music_num = (UINT32)luaL_checkinteger(L, 1); - music_flags = (UINT16)(music_num & 0x0000FFFF); - if (music_flags && music_flags <= 1035) - snprintf(music_compat_name, 7, "%sM", G_BuildMapName((INT32)music_flags)); - else if (music_flags && music_flags <= 1050) - strncpy(music_compat_name, compat_special_music_slots[music_flags - 1036], 7); - else - music_compat_name[0] = 0; // becomes empty string - music_compat_name[6] = 0; - music_name = (const char *)&music_compat_name; - } - else - { - music_num = 0; - music_name = luaL_checkstring(L, 1); - } -#else const char *music_name = luaL_checkstring(L, 1); -#endif NOHUD lua_pushboolean(L, S_MusicExists(music_name, checkMIDI, checkDigi)); return 1; diff --git a/src/s_sound.c b/src/s_sound.c index 36bd454c1..ecce7e9c4 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -1354,28 +1354,6 @@ void S_InitSfxChannels(INT32 sfxVolume) /// Music /// ------------------------ -#ifdef MUSICSLOT_COMPATIBILITY -const char *compat_special_music_slots[16] = -{ - "_title", // 1036 title screen - "_intro", // 1037 intro - "_clear", // 1038 level clear - "_inv", // 1039 invincibility - "_shoes", // 1040 super sneakers - "_minv", // 1041 Mario invincibility - "_drown", // 1042 drowning - "_gover", // 1043 game over - "_1up", // 1044 extra life - "_conti", // 1045 continue screen - "_super", // 1046 Super Sonic - "_chsel", // 1047 character select - "_creds", // 1048 credits - "_inter", // 1049 Race Results - "_stjr", // 1050 Sonic Team Jr. Presents - "" -}; -#endif - static char music_name[7]; // up to 6-character name static void *music_data; static UINT16 music_flags; @@ -2465,7 +2443,7 @@ void S_StartEx(boolean reset) static void Command_Tunes_f(void) { const char *tunearg; - UINT16 tunenum, track = 0; + UINT16 track = 0; UINT32 position = 0; const size_t argc = COM_Argc(); @@ -2481,7 +2459,6 @@ static void Command_Tunes_f(void) } tunearg = COM_Argv(1); - tunenum = (UINT16)atoi(tunearg); track = 0; if (!strcasecmp(tunearg, "-show")) @@ -2500,24 +2477,14 @@ static void Command_Tunes_f(void) tunearg = mapheaderinfo[gamemap-1]->musname; track = mapheaderinfo[gamemap-1]->mustrack; } - else if (!tunearg[2] && toupper(tunearg[0]) >= 'A' && toupper(tunearg[0]) <= 'Z') - tunenum = (UINT16)M_MapNumber(tunearg[0], tunearg[1]); - if (tunenum && tunenum >= 1036) - { - CONS_Alert(CONS_NOTICE, M_GetText("Valid music slots are 1 to 1035.\n")); - return; - } - if (!tunenum && strlen(tunearg) > 6) // This is automatic -- just show the error just in case + if (strlen(tunearg) > 6) // This is automatic -- just show the error just in case CONS_Alert(CONS_NOTICE, M_GetText("Music name too long - truncated to six characters.\n")); if (argc > 2) track = (UINT16)atoi(COM_Argv(2))-1; - if (tunenum) - snprintf(mapmusname, 7, "%sM", G_BuildMapName(tunenum)); - else - strncpy(mapmusname, tunearg, 7); + strncpy(mapmusname, tunearg, 7); if (argc > 4) position = (UINT32)atoi(COM_Argv(4)); diff --git a/src/s_sound.h b/src/s_sound.h index 4ac3c70bf..ab2c411c0 100644 --- a/src/s_sound.h +++ b/src/s_sound.h @@ -319,10 +319,4 @@ void S_StopSoundByNum(sfxenum_t sfxnum); #define S_StartScreamSound S_StartSound #endif -#ifdef MUSICSLOT_COMPATIBILITY -// For compatibility with code/scripts relying on older versions -// This is a list of all the "special" slot names and their associated numbers -extern const char *compat_special_music_slots[16]; -#endif - #endif From 2971156ba7c4699979218a4a8470d93d8faf63aa Mon Sep 17 00:00:00 2001 From: katsy Date: Fri, 11 Dec 2020 23:39:42 -0500 Subject: [PATCH 0457/1080] Update info.c --- src/info.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/info.c b/src/info.c index 8684c68f5..192e592af 100644 --- a/src/info.c +++ b/src/info.c @@ -3291,16 +3291,16 @@ state_t states[NUMSTATES] = {SPR_WZAP, FF_TRANS10|FF_ANIMATE|FF_RANDOMANIM, 4, {NULL}, 3, 2, S_NULL}, // S_WATERZAP // Spindash dust - {SPR_DUST, 0, 7, {NULL}, 0, 0, S_SPINDUST2}, // S_SPINDUST1 - {SPR_DUST, 1, 6, {NULL}, 0, 0, S_SPINDUST3}, // S_SPINDUST2 - {SPR_DUST, FF_TRANS30|2, 4, {NULL}, 0, 0, S_SPINDUST4}, // S_SPINDUST3 - {SPR_DUST, FF_TRANS60|3, 3, {NULL}, 0, 0, S_NULL}, // S_SPINDUST4 - {SPR_BUBL, 0, 7, {NULL}, 0, 0, S_SPINDUST_BUBBLE2}, // S_SPINDUST_BUBBLE1 - {SPR_BUBL, 0, 6, {NULL}, 0, 0, S_SPINDUST_BUBBLE3}, // S_SPINDUST_BUBBLE2 - {SPR_BUBL, FF_TRANS30|0, 4, {NULL}, 0, 0, S_SPINDUST_BUBBLE4}, // S_SPINDUST_BUBBLE3 - {SPR_BUBL, FF_TRANS60|0, 3, {NULL}, 0, 0, S_NULL}, // S_SPINDUST_BUBBLE4 - {SPR_FPRT, FF_FULLBRIGHT|0, 7, {NULL}, 0, 0, S_SPINDUST_FIRE2}, // S_SPINDUST_FIRE1 - {SPR_FPRT, FF_FULLBRIGHT|0, 6, {NULL}, 0, 0, S_SPINDUST_FIRE3}, // S_SPINDUST_FIRE2 + {SPR_DUST, 0, 7, {NULL}, 0, 0, S_SPINDUST2}, // S_SPINDUST1 + {SPR_DUST, 1, 6, {NULL}, 0, 0, S_SPINDUST3}, // S_SPINDUST2 + {SPR_DUST, FF_TRANS30|2, 4, {NULL}, 0, 0, S_SPINDUST4}, // S_SPINDUST3 + {SPR_DUST, FF_TRANS60|3, 3, {NULL}, 0, 0, S_NULL}, // S_SPINDUST4 + {SPR_BUBL, 0, 7, {NULL}, 0, 0, S_SPINDUST_BUBBLE2}, // S_SPINDUST_BUBBLE1 + {SPR_BUBL, 0, 6, {NULL}, 0, 0, S_SPINDUST_BUBBLE3}, // S_SPINDUST_BUBBLE2 + {SPR_BUBL, FF_TRANS30|0, 4, {NULL}, 0, 0, S_SPINDUST_BUBBLE4}, // S_SPINDUST_BUBBLE3 + {SPR_BUBL, FF_TRANS60|0, 3, {NULL}, 0, 0, S_NULL}, // S_SPINDUST_BUBBLE4 + {SPR_FPRT, FF_FULLBRIGHT|0, 7, {NULL}, 0, 0, S_SPINDUST_FIRE2}, // S_SPINDUST_FIRE1 + {SPR_FPRT, FF_FULLBRIGHT|0, 6, {NULL}, 0, 0, S_SPINDUST_FIRE3}, // S_SPINDUST_FIRE2 {SPR_FPRT, FF_FULLBRIGHT|FF_TRANS30|0, 4, {NULL}, 0, 0, S_SPINDUST_FIRE4}, // S_SPINDUST_FIRE3 {SPR_FPRT, FF_FULLBRIGHT|FF_TRANS60|0, 3, {NULL}, 0, 0, S_NULL}, // S_SPINDUST_FIRE4 From 9ddeb5f5896de0407b2b6fce8c949295a9e6d5e4 Mon Sep 17 00:00:00 2001 From: James R Date: Sat, 12 Dec 2020 02:05:21 -0800 Subject: [PATCH 0458/1080] Resolve GameQuit hook conflicts --- src/d_clisrv.c | 6 +++--- src/d_netcmd.c | 4 ++-- src/lua_hook.h | 1 + src/lua_hooklib.c | 10 ++++++++++ src/m_menu.c | 4 ++-- src/sdl/i_video.c | 2 +- 6 files changed, 19 insertions(+), 8 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 8ecafcc1b..9a24546ea 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -3032,7 +3032,7 @@ static void Got_KickCmd(UINT8 **p, INT32 playernum) if (pnum == consoleplayer) { - LUAh_GameQuit(false); + LUA_HookBool(false, Hook(GameQuit)); #ifdef DUMPCONSISTENCY if (msg == KICK_MSG_CON_FAIL) SV_SavedGame(); #endif @@ -3732,7 +3732,7 @@ static void HandleConnect(SINT8 node) static void HandleShutdown(SINT8 node) { (void)node; - LUAh_GameQuit(false); + LUA_HookBool(false, Hook(GameQuit)); D_QuitNetGame(); CL_Reset(); D_StartTitle(); @@ -3747,7 +3747,7 @@ static void HandleShutdown(SINT8 node) static void HandleTimeout(SINT8 node) { (void)node; - LUAh_GameQuit(false); + LUA_HookBool(false, Hook(GameQuit)); D_QuitNetGame(); CL_Reset(); D_StartTitle(); diff --git a/src/d_netcmd.c b/src/d_netcmd.c index d2f6add0c..25b4b0aa1 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -3612,7 +3612,7 @@ static void Command_Playintro_f(void) */ FUNCNORETURN static ATTRNORETURN void Command_Quit_f(void) { - LUAh_GameQuit(true); + LUA_HookBool(true, Hook(GameQuit)); I_Quit(); } @@ -4274,7 +4274,7 @@ void Command_ExitGame_f(void) { INT32 i; - LUAh_GameQuit(false); + LUA_HookBool(false, Hook(GameQuit)); D_QuitNetGame(); CL_Reset(); diff --git a/src/lua_hook.h b/src/lua_hook.h index f44a2e305..873c14643 100644 --- a/src/lua_hook.h +++ b/src/lua_hook.h @@ -84,6 +84,7 @@ void LUA_Hook(int hook); int LUA_HookMobj(mobj_t *, int hook); int LUA_Hook2Mobj(mobj_t *, mobj_t *, int hook); void LUA_HookInt(INT32 integer, int hook); +void LUA_HookBool(boolean value, int hook); int LUA_HookPlayer(player_t *, int hook); int LUA_HookTiccmd(player_t *, ticcmd_t *, int hook); diff --git a/src/lua_hooklib.c b/src/lua_hooklib.c index 1ac9a6952..5492c7921 100644 --- a/src/lua_hooklib.c +++ b/src/lua_hooklib.c @@ -561,6 +561,16 @@ void LUA_HookInt(INT32 number, int hook_type) } } +void LUA_HookBool(boolean value, int hook_type) +{ + Hook_State hook; + if (prepare_hook(&hook, 0, hook_type)) + { + lua_pushboolean(gL, value); + call_hooks(&hook, 1, 0, res_none); + } +} + int LUA_HookPlayer(player_t *player, int hook_type) { Hook_State hook; diff --git a/src/m_menu.c b/src/m_menu.c index 5ec9132f7..c6b1b2b8a 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -6937,7 +6937,7 @@ static void M_SelectableClearMenus(INT32 choice) static void M_UltimateCheat(INT32 choice) { (void)choice; - LUAh_GameQuit(true); + LUA_HookBool(true, Hook(GameQuit)); I_Quit(); } @@ -13371,7 +13371,7 @@ void M_QuitResponse(INT32 ch) if (ch != 'y' && ch != KEY_ENTER) return; - LUAh_GameQuit(true); + LUA_HookBool(true, Hook(GameQuit)); if (!(netgame || cv_debug)) { S_ResetCaptions(); diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index 5ebff8700..f3da446d8 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -1057,7 +1057,7 @@ void I_GetEvent(void) M_SetupJoystickMenu(0); break; case SDL_QUIT: - LUAh_GameQuit(true); + LUA_HookBool(true, Hook(GameQuit)); I_Quit(); break; } From e55d842d7f4647719fb197621aa368677ae114a4 Mon Sep 17 00:00:00 2001 From: James R Date: Sat, 12 Dec 2020 02:11:23 -0800 Subject: [PATCH 0459/1080] Kill SEENAMES --- src/d_netcmd.c | 8 +------- src/d_netcmd.h | 2 -- src/deh_tables.c | 4 ---- src/doomdef.h | 3 --- src/g_game.c | 2 -- src/g_game.h | 2 -- src/info.c | 4 ---- src/info.h | 4 ---- src/lua_hook.h | 4 +--- src/lua_hooklib.c | 4 +--- src/m_menu.c | 2 -- src/p_floor.c | 2 -- src/p_local.h | 2 -- src/p_map.c | 6 ++---- src/p_user.c | 2 -- src/st_stuff.c | 2 -- 16 files changed, 5 insertions(+), 48 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 31c10f58a..bea1ab33e 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -214,11 +214,9 @@ consvar_t cv_respawntime = CVAR_INIT ("respawndelay", "3", CV_SAVE|CV_NETVAR|CV_ consvar_t cv_competitionboxes = CVAR_INIT ("competitionboxes", "Mystery", CV_SAVE|CV_NETVAR|CV_CHEAT, competitionboxes_cons_t, NULL); -#ifdef SEENAMES static CV_PossibleValue_t seenames_cons_t[] = {{0, "Off"}, {1, "Colorless"}, {2, "Team"}, {3, "Ally/Foe"}, {0, NULL}}; consvar_t cv_seenames = CVAR_INIT ("seenames", "Ally/Foe", CV_SAVE, seenames_cons_t, 0); consvar_t cv_allowseenames = CVAR_INIT ("allowseenames", "Yes", CV_SAVE|CV_NETVAR, CV_YesNo, NULL); -#endif // names consvar_t cv_playername = CVAR_INIT ("name", "Sonic", CV_SAVE|CV_CALL|CV_NOINIT, NULL, Name_OnChange); @@ -597,9 +595,7 @@ void D_RegisterServerCommands(void) CV_RegisterVar(&cv_pingtimeout); CV_RegisterVar(&cv_showping); -#ifdef SEENAMES - CV_RegisterVar(&cv_allowseenames); -#endif + CV_RegisterVar(&cv_allowseenames); CV_RegisterVar(&cv_dummyconsvar); } @@ -690,9 +686,7 @@ void D_RegisterClientCommands(void) CV_RegisterVar(&cv_defaultplayercolor2); CV_RegisterVar(&cv_defaultskin2); -#ifdef SEENAMES CV_RegisterVar(&cv_seenames); -#endif CV_RegisterVar(&cv_rollingdemos); CV_RegisterVar(&cv_netstat); CV_RegisterVar(&cv_netticbuffer); diff --git a/src/d_netcmd.h b/src/d_netcmd.h index 98d8f1425..ac39626a4 100644 --- a/src/d_netcmd.h +++ b/src/d_netcmd.h @@ -31,9 +31,7 @@ extern consvar_t cv_defaultskin; extern consvar_t cv_defaultplayercolor2; extern consvar_t cv_defaultskin2; -#ifdef SEENAMES extern consvar_t cv_seenames, cv_allowseenames; -#endif extern consvar_t cv_usemouse; extern consvar_t cv_usejoystick; extern consvar_t cv_usejoystick2; diff --git a/src/deh_tables.c b/src/deh_tables.c index 5733d9b0e..95e326823 100644 --- a/src/deh_tables.c +++ b/src/deh_tables.c @@ -3478,9 +3478,7 @@ const char *const STATE_LIST[] = { // array length left dynamic for sanity testi "S_BLUEBRICKDEBRIS", "S_YELLOWBRICKDEBRIS", -#ifdef SEENAMES "S_NAMECHECK", -#endif }; // RegEx to generate this from info.h: ^\tMT_([^,]+), --> \t"MT_\1", @@ -4260,9 +4258,7 @@ const char *const MOBJTYPE_LIST[] = { // array length left dynamic for sanity t "MT_BLUEBRICKDEBRIS", "MT_YELLOWBRICKDEBRIS", -#ifdef SEENAMES "MT_NAMECHECK", -#endif }; const char *const MOBJFLAG_LIST[] = { diff --git a/src/doomdef.h b/src/doomdef.h index d0b7ea0c2..52abc9597 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -582,9 +582,6 @@ extern const char *compdate, *comptime, *comprevision, *compbranch; /// Dumps the contents of a network save game upon consistency failure for debugging. //#define DUMPCONSISTENCY -/// See name of player in your crosshair -#define SEENAMES - /// Who put weights on my recycler? ... Inuyasha did. /// \note XMOD port. //#define WEIGHTEDRECYCLER diff --git a/src/g_game.c b/src/g_game.c index 283113bbe..844acea74 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -444,9 +444,7 @@ consvar_t cv_firenaxis2 = CVAR_INIT ("joyaxis2_firenormal", "Z-Axis", CV_SAVE, j consvar_t cv_deadzone2 = CVAR_INIT ("joy_deadzone2", "0.125", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL); consvar_t cv_digitaldeadzone2 = CVAR_INIT ("joy_digdeadzone2", "0.25", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL); -#ifdef SEENAMES player_t *seenplayer; // player we're aiming at right now -#endif // now automatically allocated in D_RegisterClientCommands // so that it doesn't have to be updated depending on the value of MAXPLAYERS diff --git a/src/g_game.h b/src/g_game.h index 2bcf444c2..744d6755a 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -25,9 +25,7 @@ extern char timeattackfolder[64]; extern char customversionstring[32]; #define GAMEDATASIZE (4*8192) -#ifdef SEENAMES extern player_t *seenplayer; -#endif extern char player_names[MAXPLAYERS][MAXPLAYERNAME+1]; extern INT32 player_name_changes[MAXPLAYERS]; diff --git a/src/info.c b/src/info.c index 29a79b1d6..152a74927 100644 --- a/src/info.c +++ b/src/info.c @@ -3924,9 +3924,7 @@ state_t states[NUMSTATES] = {SPR_BRIB, FF_ANIMATE|FF_RANDOMANIM, -1, {NULL}, 31, 1, S_NULL}, // S_BLUEBRICKDEBRIS {SPR_BRIY, FF_ANIMATE|FF_RANDOMANIM, -1, {NULL}, 31, 1, S_NULL}, // S_YELLOWBRICKDEBRIS -#ifdef SEENAMES {SPR_NULL, 0, 1, {NULL}, 0, 0, S_NULL}, // S_NAMECHECK -#endif }; mobjinfo_t mobjinfo[NUMMOBJTYPES] = @@ -21653,7 +21651,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = S_NULL // raisestate }, -#ifdef SEENAMES { // MT_NAMECHECK -1, // doomednum S_NAMECHECK, // spawnstate @@ -21680,7 +21677,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = MF_NOBLOCKMAP|MF_MISSILE|MF_NOGRAVITY|MF_NOSECTOR, // flags S_NULL // raisestate }, -#endif }; skincolor_t skincolors[MAXSKINCOLORS] = { diff --git a/src/info.h b/src/info.h index 604922beb..c6a2a2c44 100644 --- a/src/info.h +++ b/src/info.h @@ -4280,9 +4280,7 @@ typedef enum state S_BLUEBRICKDEBRIS, // for CEZ3 S_YELLOWBRICKDEBRIS, // for CEZ3 -#ifdef SEENAMES S_NAMECHECK, -#endif S_FIRSTFREESLOT, S_LASTFREESLOT = S_FIRSTFREESLOT + NUMSTATEFREESLOTS - 1, @@ -5082,9 +5080,7 @@ typedef enum mobj_type MT_BLUEBRICKDEBRIS, // for CEZ3 MT_YELLOWBRICKDEBRIS, // for CEZ3 -#ifdef SEENAMES MT_NAMECHECK, -#endif MT_FIRSTFREESLOT, MT_LASTFREESLOT = MT_FIRSTFREESLOT + NUMMOBJFREESLOTS - 1, diff --git a/src/lua_hook.h b/src/lua_hook.h index 796f3a9d2..260df0bee 100644 --- a/src/lua_hook.h +++ b/src/lua_hook.h @@ -112,11 +112,9 @@ void LUAh_PlayerQuit(player_t *plr, kickreason_t reason); // Hook for player qui void LUAh_IntermissionThinker(void); // Hook for Y_Ticker boolean LUAh_TeamSwitch(player_t *player, int newteam, boolean fromspectators, boolean tryingautobalance, boolean tryingscramble); // Hook for team switching in... uh.... UINT8 LUAh_ViewpointSwitch(player_t *player, player_t *newdisplayplayer, boolean forced); // Hook for spy mode -#ifdef SEENAMES boolean LUAh_SeenPlayer(player_t *player, player_t *seenfriend); // Hook for MT_NAMECHECK -#endif #define LUAh_PlayerThink(player) LUAh_PlayerHook(player, hook_PlayerThink) // Hook for P_PlayerThink boolean LUAh_ShouldJingleContinue(player_t *player, const char *musname); // Hook for whether a jingle of the given music should continue playing void LUAh_GameQuit(void); // Hook for game quitting boolean LUAh_PlayerCmd(player_t *player, ticcmd_t *cmd); // Hook for building player's ticcmd struct (Ported from SRB2Kart) -boolean LUAh_MusicChange(const char *oldname, char *newname, UINT16 *mflags, boolean *looping, UINT32 *position, UINT32 *prefadems, UINT32 *fadeinms); // Hook for music changes \ No newline at end of file +boolean LUAh_MusicChange(const char *oldname, char *newname, UINT16 *mflags, boolean *looping, UINT32 *position, UINT32 *prefadems, UINT32 *fadeinms); // Hook for music changes diff --git a/src/lua_hooklib.c b/src/lua_hooklib.c index 117aa48a3..7bfe00fb5 100644 --- a/src/lua_hooklib.c +++ b/src/lua_hooklib.c @@ -1754,7 +1754,6 @@ UINT8 LUAh_ViewpointSwitch(player_t *player, player_t *newdisplayplayer, boolean } // Hook for MT_NAMECHECK -#ifdef SEENAMES boolean LUAh_SeenPlayer(player_t *player, player_t *seenfriend) { hook_p hookp; @@ -1798,7 +1797,6 @@ boolean LUAh_SeenPlayer(player_t *player, player_t *seenfriend) return hasSeenPlayer; } -#endif // SEENAMES boolean LUAh_ShouldJingleContinue(player_t *player, const char *musname) { @@ -1971,4 +1969,4 @@ boolean LUAh_MusicChange(const char *oldname, char *newname, UINT16 *mflags, boo lua_settop(gL, 0); newname[6] = 0; return hooked; -} \ No newline at end of file +} diff --git a/src/m_menu.c b/src/m_menu.c index 77648f877..8c2131dc8 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1356,9 +1356,7 @@ static menuitem_t OP_VideoOptionsMenu[] = {IT_STRING | IT_CVAR, NULL, "Score/Time/Rings", &cv_timetic, 71}, {IT_STRING | IT_CVAR, NULL, "Show Powerups", &cv_powerupdisplay, 76}, {IT_STRING | IT_CVAR, NULL, "Local ping display", &cv_showping, 81}, // shows ping next to framerate if we want to. -#ifdef SEENAMES {IT_STRING | IT_CVAR, NULL, "Show player names", &cv_seenames, 86}, -#endif {IT_HEADER, NULL, "Console", NULL, 95}, {IT_STRING | IT_CVAR, NULL, "Background color", &cons_backcolor, 101}, diff --git a/src/p_floor.c b/src/p_floor.c index ed49b03a3..7c26065b5 100644 --- a/src/p_floor.c +++ b/src/p_floor.c @@ -1064,9 +1064,7 @@ static mobj_t *SearchMarioNode(msecnode_t *node) case MT_HOOP: case MT_HOOPCOLLIDE: case MT_NIGHTSCORE: -#ifdef SEENAMES case MT_NAMECHECK: // DEFINITELY not this, because it is client-side. -#endif continue; default: break; diff --git a/src/p_local.h b/src/p_local.h index 8a5084962..8caab0d27 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -326,9 +326,7 @@ mobj_t *P_SpawnPointMissile(mobj_t *source, fixed_t xa, fixed_t ya, fixed_t za, mobj_t *P_SpawnAlteredDirectionMissile(mobj_t *source, mobjtype_t type, fixed_t x, fixed_t y, fixed_t z, INT32 shiftingAngle); mobj_t *P_SPMAngle(mobj_t *source, mobjtype_t type, angle_t angle, UINT8 aimtype, UINT32 flags2); #define P_SpawnPlayerMissile(s,t,f) P_SPMAngle(s,t,s->angle,true,f) -#ifdef SEENAMES #define P_SpawnNameFinder(s,t) P_SPMAngle(s,t,s->angle,true,0) -#endif void P_ColorTeamMissile(mobj_t *missile, player_t *source); SINT8 P_MobjFlip(mobj_t *mobj); fixed_t P_GetMobjGravity(mobj_t *mo); diff --git a/src/p_map.c b/src/p_map.c index 922c0d9ec..1b46f9686 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -727,9 +727,8 @@ static boolean PIT_CheckThing(mobj_t *thing) || (thing->player && thing->player->spectator)) return true; -#ifdef SEENAMES - // Do name checks all the way up here - // So that NOTHING ELSE can see MT_NAMECHECK because it is client-side. + // Do name checks all the way up here + // So that NOTHING ELSE can see MT_NAMECHECK because it is client-side. if (tmthing->type == MT_NAMECHECK) { // Ignore things that aren't players, ignore spectators, ignore yourself. @@ -753,7 +752,6 @@ static boolean PIT_CheckThing(mobj_t *thing) seenplayer = thing->player; return false; } -#endif // Metal Sonic destroys tiny baby objects. if (tmthing->type == MT_METALSONIC_RACE diff --git a/src/p_user.c b/src/p_user.c index c5f919c78..dc9604110 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -11482,7 +11482,6 @@ void P_PlayerThink(player_t *player) } } -#ifdef SEENAMES if (netgame && player == &players[displayplayer] && !(leveltime % (TICRATE/5))) { seenplayer = NULL; @@ -11507,7 +11506,6 @@ void P_PlayerThink(player_t *player) } } } -#endif if (player->awayviewmobj && P_MobjWasRemoved(player->awayviewmobj)) { diff --git a/src/st_stuff.c b/src/st_stuff.c index b25538d88..649644620 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -2751,7 +2751,6 @@ static void ST_overlayDrawer(void) void ST_Drawer(void) { -#ifdef SEENAMES if (cv_seenames.value && cv_allowseenames.value && displayplayer == consoleplayer && seenplayer && seenplayer->mo) { INT32 c = 0; @@ -2775,7 +2774,6 @@ void ST_Drawer(void) V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT/2 + 15, V_HUDTRANSHALF|c, player_names[seenplayer-players]); } -#endif // Doom's status bar only updated if necessary. // However, ours updates every frame regardless, so the "refresh" param was removed From c8cc9c7a6f449505b9a809d106e29dc19e3f7a9c Mon Sep 17 00:00:00 2001 From: James R Date: Sat, 12 Dec 2020 02:40:46 -0800 Subject: [PATCH 0460/1080] Remove trailing whitespace --- src/d_netcmd.c | 2 +- src/hardware/hw_batching.h | 2 +- src/lua_skinlib.c | 2 +- src/p_enemy.c | 2 +- src/p_mobj.c | 2 +- src/p_user.c | 8 ++++---- src/w_wad.c | 2 +- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 6080b2fd0..f2e168616 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -878,7 +878,7 @@ void D_RegisterClientCommands(void) // CV_RegisterVar(&cv_snapto); CV_RegisterVar(&cv_freedemocamera); - + // add cheat commands COM_AddCommand("noclip", Command_CheatNoClip_f); COM_AddCommand("god", Command_CheatGod_f); diff --git a/src/hardware/hw_batching.h b/src/hardware/hw_batching.h index 3d22324ac..42291a0df 100644 --- a/src/hardware/hw_batching.h +++ b/src/hardware/hw_batching.h @@ -16,7 +16,7 @@ #include "hw_data.h" #include "hw_drv.h" -typedef struct +typedef struct { FSurfaceInfo surf;// surf also has its own polyflags for some reason, but it seems unused unsigned int vertsIndex;// location of verts in unsortedVertexArray diff --git a/src/lua_skinlib.c b/src/lua_skinlib.c index ea368a9cd..56be6bf4f 100644 --- a/src/lua_skinlib.c +++ b/src/lua_skinlib.c @@ -214,7 +214,7 @@ static int skin_get(lua_State *L) break; case skin_sprites: LUA_PushLightUserdata(L, skin->sprites, META_SKINSPRITES); - break; + break; } return 1; } diff --git a/src/p_enemy.c b/src/p_enemy.c index 63a14636d..7f322567e 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -4060,7 +4060,7 @@ bossjustdie: // Initialize my junk junk.tags.tags = NULL; junk.tags.count = 0; - + Tag_FSet(&junk.tags, LE_KOOPA); EV_DoCeiling(&junk, raiseToHighest); return; diff --git a/src/p_mobj.c b/src/p_mobj.c index 1f87762bc..a1edcfe77 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -11398,7 +11398,7 @@ void P_SpawnPlayer(INT32 playernum) p->normalspeed = skins[p->skin].normalspeed; p->jumpfactor = skins[p->skin].jumpfactor; } - + // Clear lastlinehit and lastsidehit p->lastsidehit = -1; p->lastlinehit = -1; diff --git a/src/p_user.c b/src/p_user.c index 892f4b678..2377134cc 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -2613,10 +2613,10 @@ static void P_CheckBustableBlocks(player_t *player) if ((netgame || multiplayer) && player->spectator) return; - + oldx = player->mo->x; oldy = player->mo->y; - + if (!(player->pflags & PF_BOUNCING)) // Bouncers only get to break downwards, not sideways { P_UnsetThingPosition(player->mo); @@ -2635,7 +2635,7 @@ static void P_CheckBustableBlocks(player_t *player) if (!node->m_sector->ffloors) continue; - + for (rover = node->m_sector->ffloors; rover; rover = rover->next) { if (!P_PlayerCanBust(player, rover)) @@ -4525,7 +4525,7 @@ void P_DoJump(player_t *player, boolean soundandstate) player->mo->eflags &= ~MFE_APPLYPMOMZ; player->pflags |= P_GetJumpFlags(player);; - + if (player->charflags & SF_NOJUMPDAMAGE) player->pflags &= ~PF_SPINNING; diff --git a/src/w_wad.c b/src/w_wad.c index 2429eaf92..4aae2ee46 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -2144,7 +2144,7 @@ int W_VerifyNMUSlumps(const char *filename, boolean exit_on_error) {"LT", 2}, // Titlecard changes {"SLID", 4}, // Continue - {"CONT", 4}, + {"CONT", 4}, {"MINICAPS", 8}, // NiGHTS graphics here and below {"BLUESTAT", 8}, // Sphere status From 93e4f43e4b3a24fc2d8032e8730cbf427e75b297 Mon Sep 17 00:00:00 2001 From: James R Date: Sat, 12 Dec 2020 03:06:57 -0800 Subject: [PATCH 0461/1080] Hooklib macros names -> uppercase + documentation --- src/b_bot.c | 4 +-- src/d_clisrv.c | 8 ++--- src/d_netcmd.c | 6 ++-- src/g_demo.c | 2 +- src/g_game.c | 6 ++-- src/lua_hook.h | 40 +++++++++++++++------- src/lua_hooklib.c | 84 +++++++++++++++++++++++------------------------ src/m_menu.c | 4 +-- src/p_enemy.c | 2 +- src/p_map.c | 4 +-- src/p_mobj.c | 20 +++++------ src/p_setup.c | 2 +- src/p_tick.c | 8 ++--- src/p_user.c | 26 +++++++-------- src/sdl/i_video.c | 2 +- src/y_inter.c | 2 +- 16 files changed, 117 insertions(+), 103 deletions(-) diff --git a/src/b_bot.c b/src/b_bot.c index 93a853dee..ba5aa3ccf 100644 --- a/src/b_bot.c +++ b/src/b_bot.c @@ -363,7 +363,7 @@ void B_BuildTiccmd(player_t *player, ticcmd_t *cmd) CV_SetValue(&cv_analog[1], false); // Let Lua scripts build ticcmds - if (LUA_HookTiccmd(player, cmd, Hook(BotTiccmd))) + if (LUA_HookTiccmd(player, cmd, HOOK(BotTiccmd))) return; // We don't have any main character AI, sorry. D: @@ -461,7 +461,7 @@ boolean B_CheckRespawn(player_t *player) // B_RespawnBot doesn't do anything if the condition above this isn't met { - UINT8 shouldForce = LUA_Hook2Mobj(sonic, tails, Mobj_Hook(BotRespawn)); + UINT8 shouldForce = LUA_Hook2Mobj(sonic, tails, MOBJ_HOOK(BotRespawn)); if (P_MobjWasRemoved(sonic) || P_MobjWasRemoved(tails)) return (shouldForce == 1); // mobj was removed diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 9a24546ea..2a461be34 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -3032,7 +3032,7 @@ static void Got_KickCmd(UINT8 **p, INT32 playernum) if (pnum == consoleplayer) { - LUA_HookBool(false, Hook(GameQuit)); + LUA_HookBool(false, HOOK(GameQuit)); #ifdef DUMPCONSISTENCY if (msg == KICK_MSG_CON_FAIL) SV_SavedGame(); #endif @@ -3452,7 +3452,7 @@ static void Got_AddPlayer(UINT8 **p, INT32 playernum) COM_BufAddText(va("sayto %d %s\n", newplayernum, motd)); if (!rejoined) - LUA_HookInt(newplayernum, Hook(PlayerJoin)); + LUA_HookInt(newplayernum, HOOK(PlayerJoin)); } static boolean SV_AddWaitingPlayers(const char *name, const char *name2) @@ -3732,7 +3732,7 @@ static void HandleConnect(SINT8 node) static void HandleShutdown(SINT8 node) { (void)node; - LUA_HookBool(false, Hook(GameQuit)); + LUA_HookBool(false, HOOK(GameQuit)); D_QuitNetGame(); CL_Reset(); D_StartTitle(); @@ -3747,7 +3747,7 @@ static void HandleShutdown(SINT8 node) static void HandleTimeout(SINT8 node) { (void)node; - LUA_HookBool(false, Hook(GameQuit)); + LUA_HookBool(false, HOOK(GameQuit)); D_QuitNetGame(); CL_Reset(); D_StartTitle(); diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 25b4b0aa1..ee75b059d 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -2103,7 +2103,7 @@ static void Got_Mapcmd(UINT8 **cp, INT32 playernum) } mapnumber = M_MapNumber(mapname[3], mapname[4]); - LUA_HookInt(mapnumber, Hook(MapChange)); + LUA_HookInt(mapnumber, HOOK(MapChange)); G_InitNew(ultimatemode, mapname, resetplayer, skipprecutscene, FLS); if (demoplayback && !timingdemo) @@ -3612,7 +3612,7 @@ static void Command_Playintro_f(void) */ FUNCNORETURN static ATTRNORETURN void Command_Quit_f(void) { - LUA_HookBool(true, Hook(GameQuit)); + LUA_HookBool(true, HOOK(GameQuit)); I_Quit(); } @@ -4274,7 +4274,7 @@ void Command_ExitGame_f(void) { INT32 i; - LUA_HookBool(false, Hook(GameQuit)); + LUA_HookBool(false, HOOK(GameQuit)); D_QuitNetGame(); CL_Reset(); diff --git a/src/g_demo.c b/src/g_demo.c index e4af7086c..5bfe2684c 100644 --- a/src/g_demo.c +++ b/src/g_demo.c @@ -1956,7 +1956,7 @@ void G_DoPlayDemo(char *defdemoname) // Set skin SetPlayerSkin(0, skin); - LUA_HookInt(gamemap, Hook(MapChange)); + LUA_HookInt(gamemap, HOOK(MapChange)); displayplayer = consoleplayer = 0; memset(playeringame,0,sizeof(playeringame)); playeringame[0] = true; diff --git a/src/g_game.c b/src/g_game.c index e889c7113..209ca0580 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1689,7 +1689,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) cmd->angleturn = orighookangle; - LUA_HookTiccmd(player, cmd, Hook(PlayerCmd)); + LUA_HookTiccmd(player, cmd, HOOK(PlayerCmd)); extra = cmd->angleturn - orighookangle; cmd->angleturn = origangle + extra; @@ -2740,7 +2740,7 @@ void G_SpawnPlayer(INT32 playernum) P_SpawnPlayer(playernum); G_MovePlayerToSpawnOrStarpost(playernum); - LUA_HookPlayer(&players[playernum], Hook(PlayerSpawn)); // Lua hook for player spawning :) + LUA_HookPlayer(&players[playernum], HOOK(PlayerSpawn)); // Lua hook for player spawning :) } void G_MovePlayerToSpawnOrStarpost(INT32 playernum) @@ -3119,7 +3119,7 @@ void G_DoReborn(INT32 playernum) } else { - LUA_HookInt(gamemap, Hook(MapChange)); + LUA_HookInt(gamemap, HOOK(MapChange)); titlecardforreload = true; G_DoLoadLevel(true); titlecardforreload = false; diff --git a/src/lua_hook.h b/src/lua_hook.h index 873c14643..4274f1f3c 100644 --- a/src/lua_hook.h +++ b/src/lua_hook.h @@ -14,7 +14,14 @@ #include "d_player.h" #include "s_sound.h" -#define Mobj_Hook_List(X) \ +/* +Do you know what an 'X Macro' is? Such a macro is called over each element of +a list and expands the input. I use it for the hook lists because both an enum +and array of hook names need to be kept in order. The X Macro handles this +automatically. +*/ + +#define MOBJ_HOOK_LIST(X) \ X (MobjSpawn),/* P_SpawnMobj */\ X (MobjCollide),/* PIT_CheckThing */\ X (MobjLineCollide),/* ditto */\ @@ -33,7 +40,7 @@ X (MapThingSpawn),/* P_SpawnMapThing */\ X (FollowMobj),/* P_PlayerAfterThink Smiles mobj-following */\ -#define Hook_List(X) \ +#define HOOK_LIST(X) \ X (NetVars),/* add to archive table (netsave) */\ X (MapChange),/* (before map load) */\ X (MapLoad),\ @@ -62,24 +69,33 @@ X (PlayerCmd),/* building the player's ticcmd struct (Ported from SRB2Kart) */\ X (MusicChange),\ -#define String_Hook_List(X) \ +#define STRING_HOOK_LIST(X) \ X (BotAI),/* B_BuildTailsTiccmd by skin name */\ X (LinedefExecute),\ X (ShouldJingleContinue),/* should jingle of the given music continue playing */\ -#define Mobj_Hook(name) mobjhook_ ## name -#define Hook(name) hook_ ## name -#define String_Hook(name) stringhook_ ## name +/* +I chose to access the hook enums through a macro as well. This could provide +a hint to lookup the macro's definition instead of the enum's definition. +(Since each enumeration is not defined in the source code, but by the list +macros above, it is not greppable.) The name passed to the macro can also be +grepped and found in the lists above. +*/ -enum { Mobj_Hook_List (Mobj_Hook) Mobj_Hook(MAX) }; -enum { Hook_List (Hook) Hook(MAX) }; -enum { String_Hook_List (String_Hook) String_Hook(MAX) }; +#define MOBJ_HOOK(name) mobjhook_ ## name +#define HOOK(name) hook_ ## name +#define STRING_HOOK(name) stringhook_ ## name + +enum { MOBJ_HOOK_LIST (MOBJ_HOOK) MOBJ_HOOK(MAX) }; +enum { HOOK_LIST (HOOK) HOOK(MAX) }; +enum { STRING_HOOK_LIST (STRING_HOOK) STRING_HOOK(MAX) }; + +/* dead simple, LUA_HOOK(GameQuit) */ +#define LUA_HOOK(type) LUA_HookVoid(HOOK(type)) extern boolean hook_cmd_running; -/* dead simple, LUA_Hook(GameQuit) */ -void LUA_Hook(int hook); -#define LUA_Hook(type) LUA_Hook(Hook(type)) +void LUA_HookVoid(int hook); int LUA_HookMobj(mobj_t *, int hook); int LUA_Hook2Mobj(mobj_t *, mobj_t *, int hook); diff --git a/src/lua_hooklib.c b/src/lua_hooklib.c index 5492c7921..4143fbd8e 100644 --- a/src/lua_hooklib.c +++ b/src/lua_hooklib.c @@ -27,17 +27,15 @@ #include "d_netcmd.h" // for cv_perfstats #include "i_system.h" // I_GetPreciseTime -#undef LUA_Hook - /* ========================================================================= ABSTRACTION ========================================================================= */ -static const char * const mobjHookNames[] = { Mobj_Hook_List (TOSTR) NULL }; -static const char * const hookNames[] = { Hook_List (TOSTR) NULL }; +static const char * const mobjHookNames[] = { MOBJ_HOOK_LIST (TOSTR) NULL }; +static const char * const hookNames[] = { HOOK_LIST (TOSTR) NULL }; static const char * const stringHookNames[] = { - String_Hook_List (TOSTR) NULL + STRING_HOOK_LIST (TOSTR) NULL }; /* TODO: remove when doomtype version is merged */ @@ -62,11 +60,11 @@ typedef struct { int ref; } stringhook_t; -static hook_t hookIds[Hook(MAX)]; -static hook_t mobjHookIds[NUMMOBJTYPES][Mobj_Hook(MAX)]; +static hook_t hookIds[HOOK(MAX)]; +static hook_t mobjHookIds[NUMMOBJTYPES][MOBJ_HOOK(MAX)]; // Lua tables are used to lookup string hook ids. -static stringhook_t stringHooks[String_Hook(MAX)]; +static stringhook_t stringHooks[STRING_HOOK(MAX)]; // This will be indexed by hook id, the value of which fetches the registry. static int * hookRefs; @@ -132,8 +130,8 @@ static void add_string_hook(lua_State *L, int type, int id) switch (type) { - case String_Hook(BotAI): - case String_Hook(ShouldJingleContinue): + case STRING_HOOK(BotAI): + case STRING_HOOK(ShouldJingleContinue): if (lua_isstring(L, 3)) { // lowercase copy string = Z_StrDup(lua_tostring(L, 3)); @@ -141,7 +139,7 @@ static void add_string_hook(lua_State *L, int type, int id) } break; - case String_Hook(LinedefExecute): + case STRING_HOOK(LinedefExecute): string = Z_StrDup(luaL_checkstring(L, 3)); strupr(string); break; @@ -197,15 +195,15 @@ static int lib_addHook(lua_State *L) luaL_checktype(L, 2, LUA_TFUNCTION); /* this is a very special case */ - if (( type = hook_in_list(name, stringHookNames) ) < String_Hook(MAX)) + if (( type = hook_in_list(name, stringHookNames) ) < STRING_HOOK(MAX)) { add_string_hook(L, type, nextid); } - else if (( type = hook_in_list(name, mobjHookNames) ) < Mobj_Hook(MAX)) + else if (( type = hook_in_list(name, mobjHookNames) ) < MOBJ_HOOK(MAX)) { add_mobj_hook(L, type, nextid); } - else if (( type = hook_in_list(name, hookNames) ) < Hook(MAX)) + else if (( type = hook_in_list(name, hookNames) ) < HOOK(MAX)) { add_hook(&hookIds[type], nextid); } @@ -544,7 +542,7 @@ int LUA_Hook2Mobj(mobj_t *t1, mobj_t *t2, int hook_type) return hook.status; } -void LUA_Hook(int type) +void LUA_HookVoid(int type) { Hook_State hook; if (prepare_hook(&hook, 0, type)) @@ -590,12 +588,12 @@ int LUA_HookTiccmd(player_t *player, ticcmd_t *cmd, int hook_type) LUA_PushUserdata(gL, player, META_PLAYER); LUA_PushUserdata(gL, cmd, META_TICCMD); - if (hook_type == Hook(PlayerCmd)) + if (hook_type == HOOK(PlayerCmd)) hook_cmd_running = true; call_hooks(&hook, 2, 1, res_true); - if (hook_type == Hook(PlayerCmd)) + if (hook_type == HOOK(PlayerCmd)) hook_cmd_running = false; } return hook.status; @@ -607,7 +605,7 @@ int LUA_HookTiccmd(player_t *player, ticcmd_t *cmd, int hook_type) void LUA_HookThinkFrame(void) { - const int type = Hook(ThinkFrame); + const int type = HOOK(ThinkFrame); // variables used by perf stats int hook_index = 0; @@ -651,7 +649,7 @@ void LUA_HookThinkFrame(void) int LUA_HookMobjLineCollide(mobj_t *mobj, line_t *line) { Hook_State hook; - if (prepare_mobj_hook(&hook, 0, Mobj_Hook(MobjLineCollide), mobj->type)) + if (prepare_mobj_hook(&hook, 0, MOBJ_HOOK(MobjLineCollide), mobj->type)) { LUA_PushUserdata(gL, mobj, META_MOBJ); LUA_PushUserdata(gL, line, META_LINE); @@ -663,7 +661,7 @@ int LUA_HookMobjLineCollide(mobj_t *mobj, line_t *line) int LUA_HookTouchSpecial(mobj_t *special, mobj_t *toucher) { Hook_State hook; - if (prepare_mobj_hook(&hook, false, Mobj_Hook(TouchSpecial), special->type)) + if (prepare_mobj_hook(&hook, false, MOBJ_HOOK(TouchSpecial), special->type)) { LUA_PushUserdata(gL, special, META_MOBJ); LUA_PushUserdata(gL, toucher, META_MOBJ); @@ -700,19 +698,19 @@ static int damage_hook int LUA_HookShouldDamage(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 damage, UINT8 damagetype) { return damage_hook(target, inflictor, source, damage, damagetype, - Mobj_Hook(ShouldDamage), 5, res_force); + MOBJ_HOOK(ShouldDamage), 5, res_force); } int LUA_HookMobjDamage(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 damage, UINT8 damagetype) { return damage_hook(target, inflictor, source, damage, damagetype, - Mobj_Hook(MobjDamage), 5, res_true); + MOBJ_HOOK(MobjDamage), 5, res_true); } int LUA_HookMobjDeath(mobj_t *target, mobj_t *inflictor, mobj_t *source, UINT8 damagetype) { return damage_hook(target, inflictor, source, 0, damagetype, - Mobj_Hook(MobjDeath), 4, res_true); + MOBJ_HOOK(MobjDeath), 4, res_true); } typedef struct { @@ -737,12 +735,12 @@ static void res_botai(Hook_State *hook) if (lua_istable(gL, -8)) { lua_pushnil(gL); // key while (lua_next(gL, -9)) { -#define check(n, f) (checkbotkey(f) ? (k[(n)-1] = 1) : 0) +#define CHECK(n, f) (checkbotkey(f) ? (k[(n)-1] = 1) : 0) if ( - check(1, "forward") || check(2, "backward") || - check(3, "left") || check(4, "right") || - check(5, "strafeleft") || check(6, "straferight") || - check(7, "jump") || check(8, "spin") + CHECK(1, "forward") || CHECK(2, "backward") || + CHECK(3, "left") || CHECK(4, "right") || + CHECK(5, "strafeleft") || CHECK(6, "straferight") || + CHECK(7, "jump") || CHECK(8, "spin") ){ if (8 <= ++fields) { @@ -752,7 +750,7 @@ static void res_botai(Hook_State *hook) } lua_pop(gL, 1); // pop value -#undef check +#undef CHECK } } else { while (fields < 8) @@ -775,7 +773,7 @@ int LUA_HookBotAI(mobj_t *sonic, mobj_t *tails, ticcmd_t *cmd) Hook_State hook; BotAI_State botai; - if (prepare_string_hook(&hook, false, String_Hook(BotAI), skin)) + if (prepare_string_hook(&hook, false, STRING_HOOK(BotAI), skin)) { LUA_PushUserdata(gL, sonic, META_MOBJ); LUA_PushUserdata(gL, tails, META_MOBJ); @@ -795,7 +793,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->stringargs[0])) + (&hook, 0, STRING_HOOK(LinedefExecute), line->stringargs[0])) { LUA_PushUserdata(gL, line, META_LINE); LUA_PushUserdata(gL, mo, META_MOBJ); @@ -807,7 +805,7 @@ void LUA_HookLinedefExecute(line_t *line, mobj_t *mo, sector_t *sector) int LUA_HookPlayerMsg(int source, int target, int flags, char *msg) { Hook_State hook; - if (prepare_hook(&hook, false, Hook(PlayerMsg))) + if (prepare_hook(&hook, false, HOOK(PlayerMsg))) { LUA_PushUserdata(gL, &players[source], META_PLAYER); // Source player if (flags & 2 /*HU_CSAY*/) { // csay TODO: make HU_CSAY accessible outside hu_stuff.c @@ -832,7 +830,7 @@ int LUA_HookPlayerMsg(int source, int target, int flags, char *msg) int LUA_HookHurtMsg(player_t *player, mobj_t *inflictor, mobj_t *source, UINT8 damagetype) { Hook_State hook; - if (prepare_hook(&hook, false, Hook(HurtMsg))) + if (prepare_hook(&hook, false, HOOK(HurtMsg))) { LUA_PushUserdata(gL, player, META_PLAYER); LUA_PushUserdata(gL, inflictor, META_MOBJ); @@ -845,7 +843,7 @@ int LUA_HookHurtMsg(player_t *player, mobj_t *inflictor, mobj_t *source, UINT8 d void LUA_HookNetArchive(lua_CFunction archFunc) { - const hook_t * map = &hookIds[Hook(NetVars)]; + const hook_t * map = &hookIds[HOOK(NetVars)]; Hook_State hook; /* this is a remarkable case where the stack isn't reset */ if (map->numHooks > 0) @@ -874,7 +872,7 @@ void LUA_HookNetArchive(lua_CFunction archFunc) int LUA_HookMapThingSpawn(mobj_t *mobj, mapthing_t *mthing) { Hook_State hook; - if (prepare_mobj_hook(&hook, false, Mobj_Hook(MapThingSpawn), mobj->type)) + if (prepare_mobj_hook(&hook, false, MOBJ_HOOK(MapThingSpawn), mobj->type)) { LUA_PushUserdata(gL, mobj, META_MOBJ); LUA_PushUserdata(gL, mthing, META_MAPTHING); @@ -886,7 +884,7 @@ int LUA_HookMapThingSpawn(mobj_t *mobj, mapthing_t *mthing) int LUA_HookFollowMobj(player_t *player, mobj_t *mobj) { Hook_State hook; - if (prepare_mobj_hook(&hook, false, Mobj_Hook(FollowMobj), mobj->type)) + if (prepare_mobj_hook(&hook, false, MOBJ_HOOK(FollowMobj), mobj->type)) { LUA_PushUserdata(gL, player, META_PLAYER); LUA_PushUserdata(gL, mobj, META_MOBJ); @@ -898,7 +896,7 @@ int LUA_HookFollowMobj(player_t *player, mobj_t *mobj) int LUA_HookPlayerCanDamage(player_t *player, mobj_t *mobj) { Hook_State hook; - if (prepare_hook(&hook, 0, Hook(PlayerCanDamage))) + if (prepare_hook(&hook, 0, HOOK(PlayerCanDamage))) { LUA_PushUserdata(gL, player, META_PLAYER); LUA_PushUserdata(gL, mobj, META_MOBJ); @@ -910,7 +908,7 @@ int LUA_HookPlayerCanDamage(player_t *player, mobj_t *mobj) void LUA_HookPlayerQuit(player_t *plr, kickreason_t reason) { Hook_State hook; - if (prepare_hook(&hook, 0, Hook(PlayerQuit))) + if (prepare_hook(&hook, 0, HOOK(PlayerQuit))) { LUA_PushUserdata(gL, plr, META_PLAYER); // Player that quit lua_pushinteger(gL, reason); // Reason for quitting @@ -921,7 +919,7 @@ void LUA_HookPlayerQuit(player_t *plr, kickreason_t reason) int LUA_HookTeamSwitch(player_t *player, int newteam, boolean fromspectators, boolean tryingautobalance, boolean tryingscramble) { Hook_State hook; - if (prepare_hook(&hook, true, Hook(TeamSwitch))) + if (prepare_hook(&hook, true, HOOK(TeamSwitch))) { LUA_PushUserdata(gL, player, META_PLAYER); lua_pushinteger(gL, newteam); @@ -936,7 +934,7 @@ int LUA_HookTeamSwitch(player_t *player, int newteam, boolean fromspectators, bo int LUA_HookViewpointSwitch(player_t *player, player_t *newdisplayplayer, boolean forced) { Hook_State hook; - if (prepare_hook(&hook, 0, Hook(ViewpointSwitch))) + if (prepare_hook(&hook, 0, HOOK(ViewpointSwitch))) { LUA_PushUserdata(gL, player, META_PLAYER); LUA_PushUserdata(gL, newdisplayplayer, META_PLAYER); @@ -953,7 +951,7 @@ int LUA_HookViewpointSwitch(player_t *player, player_t *newdisplayplayer, boolea int LUA_HookSeenPlayer(player_t *player, player_t *seenfriend) { Hook_State hook; - if (prepare_hook(&hook, true, Hook(SeenPlayer))) + if (prepare_hook(&hook, true, HOOK(SeenPlayer))) { LUA_PushUserdata(gL, player, META_PLAYER); LUA_PushUserdata(gL, seenfriend, META_PLAYER); @@ -970,7 +968,7 @@ int LUA_HookShouldJingleContinue(player_t *player, const char *musname) { Hook_State hook; if (prepare_string_hook - (&hook, false, String_Hook(ShouldJingleContinue), musname)) + (&hook, false, STRING_HOOK(ShouldJingleContinue), musname)) { LUA_PushUserdata(gL, player, META_PLAYER); push_string(); @@ -1033,7 +1031,7 @@ static void res_musicchange(Hook_State *hook) int LUA_HookMusicChange(const char *oldname, struct MusicChange *param) { - const int type = Hook(MusicChange); + const int type = HOOK(MusicChange); const hook_t * map = &hookIds[type]; Hook_State hook; diff --git a/src/m_menu.c b/src/m_menu.c index c6b1b2b8a..2a44bb2a4 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -6937,7 +6937,7 @@ static void M_SelectableClearMenus(INT32 choice) static void M_UltimateCheat(INT32 choice) { (void)choice; - LUA_HookBool(true, Hook(GameQuit)); + LUA_HookBool(true, HOOK(GameQuit)); I_Quit(); } @@ -13371,7 +13371,7 @@ void M_QuitResponse(INT32 ch) if (ch != 'y' && ch != KEY_ENTER) return; - LUA_HookBool(true, Hook(GameQuit)); + LUA_HookBool(true, HOOK(GameQuit)); if (!(netgame || cv_debug)) { S_ResetCaptions(); diff --git a/src/p_enemy.c b/src/p_enemy.c index 276fc999d..2aec5c989 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -3961,7 +3961,7 @@ void A_BossDeath(mobj_t *mo) } bossjustdie: - if (LUA_HookMobj(mo, Mobj_Hook(BossDeath))) + if (LUA_HookMobj(mo, MOBJ_HOOK(BossDeath))) return; else if (P_MobjWasRemoved(mo)) return; diff --git a/src/p_map.c b/src/p_map.c index e55238ffa..14eac1147 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -937,7 +937,7 @@ static boolean PIT_CheckThing(mobj_t *thing) } { - UINT8 shouldCollide = LUA_Hook2Mobj(thing, tmthing, Mobj_Hook(MobjCollide)); // checks hook for thing's type + UINT8 shouldCollide = LUA_Hook2Mobj(thing, tmthing, MOBJ_HOOK(MobjCollide)); // checks hook for thing's type if (P_MobjWasRemoved(tmthing) || P_MobjWasRemoved(thing)) return true; // one of them was removed??? if (shouldCollide == 1) @@ -945,7 +945,7 @@ static boolean PIT_CheckThing(mobj_t *thing) else if (shouldCollide == 2) return true; // force no collide - shouldCollide = LUA_Hook2Mobj(tmthing, thing, Mobj_Hook(MobjMoveCollide)); // checks hook for tmthing's type + shouldCollide = LUA_Hook2Mobj(tmthing, thing, MOBJ_HOOK(MobjMoveCollide)); // checks hook for tmthing's type if (P_MobjWasRemoved(tmthing) || P_MobjWasRemoved(thing)) return true; // one of them was removed??? if (shouldCollide == 1) diff --git a/src/p_mobj.c b/src/p_mobj.c index c2de01fa7..9d8a7bd7d 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -1844,7 +1844,7 @@ void P_XYMovement(mobj_t *mo) B_MoveBlocked(player); } - if (LUA_HookMobj(mo, Mobj_Hook(MobjMoveBlocked))) + if (LUA_HookMobj(mo, MOBJ_HOOK(MobjMoveBlocked))) { if (P_MobjWasRemoved(mo)) return; @@ -7509,7 +7509,7 @@ static void P_RosySceneryThink(mobj_t *mobj) static void P_MobjSceneryThink(mobj_t *mobj) { - if (LUA_HookMobj(mobj, Mobj_Hook(MobjThinker))) + if (LUA_HookMobj(mobj, MOBJ_HOOK(MobjThinker))) return; if (P_MobjWasRemoved(mobj)) return; @@ -7857,7 +7857,7 @@ static void P_MobjSceneryThink(mobj_t *mobj) if (!mobj->fuse) { - if (!LUA_HookMobj(mobj, Mobj_Hook(MobjFuse))) + if (!LUA_HookMobj(mobj, MOBJ_HOOK(MobjFuse))) P_RemoveMobj(mobj); return; } @@ -7916,7 +7916,7 @@ static void P_MobjSceneryThink(mobj_t *mobj) mobj->fuse--; if (!mobj->fuse) { - if (!LUA_HookMobj(mobj, Mobj_Hook(MobjFuse))) + if (!LUA_HookMobj(mobj, MOBJ_HOOK(MobjFuse))) P_RemoveMobj(mobj); return; } @@ -7945,7 +7945,7 @@ static boolean P_MobjPushableThink(mobj_t *mobj) static boolean P_MobjBossThink(mobj_t *mobj) { - if (LUA_HookMobj(mobj, Mobj_Hook(BossThinker))) + if (LUA_HookMobj(mobj, MOBJ_HOOK(BossThinker))) { if (P_MobjWasRemoved(mobj)) return false; @@ -9872,7 +9872,7 @@ static boolean P_FuseThink(mobj_t *mobj) if (mobj->fuse) return true; - if (LUA_HookMobj(mobj, Mobj_Hook(MobjFuse)) || P_MobjWasRemoved(mobj)) + if (LUA_HookMobj(mobj, MOBJ_HOOK(MobjFuse)) || P_MobjWasRemoved(mobj)) ; else if (mobj->info->flags & MF_MONITOR) { @@ -10048,13 +10048,13 @@ void P_MobjThinker(mobj_t *mobj) // Check for a Lua thinker first if (!mobj->player) { - if (LUA_HookMobj(mobj, Mobj_Hook(MobjThinker)) || P_MobjWasRemoved(mobj)) + if (LUA_HookMobj(mobj, MOBJ_HOOK(MobjThinker)) || P_MobjWasRemoved(mobj)) return; } else if (!mobj->player->spectator) { // You cannot short-circuit the player thinker like you can other thinkers. - LUA_HookMobj(mobj, Mobj_Hook(MobjThinker)); + LUA_HookMobj(mobj, MOBJ_HOOK(MobjThinker)); if (P_MobjWasRemoved(mobj)) return; } @@ -10525,7 +10525,7 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type) // DANGER! This can cause P_SpawnMobj to return NULL! // Avoid using P_RemoveMobj on the newly created mobj in "MobjSpawn" Lua hooks! - if (LUA_HookMobj(mobj, Mobj_Hook(MobjSpawn))) + if (LUA_HookMobj(mobj, MOBJ_HOOK(MobjSpawn))) { if (P_MobjWasRemoved(mobj)) return NULL; @@ -10912,7 +10912,7 @@ void P_RemoveMobj(mobj_t *mobj) return; // something already removing this mobj. mobj->thinker.function.acp1 = (actionf_p1)P_RemoveThinkerDelayed; // shh. no recursing. - LUA_HookMobj(mobj, Mobj_Hook(MobjRemoved)); + LUA_HookMobj(mobj, MOBJ_HOOK(MobjRemoved)); mobj->thinker.function.acp1 = (actionf_p1)P_MobjThinker; // needed for P_UnsetThingPosition, etc. to work. // Rings only, please! diff --git a/src/p_setup.c b/src/p_setup.c index 09addd73d..0ab43a8bc 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -4271,7 +4271,7 @@ boolean P_LoadLevel(boolean fromnetsave, boolean reloadinggamestate) G_CopyTiccmd(&players[i].cmd, &netcmds[buf][i], 1); } P_PreTicker(2); - LUA_HookInt(gamemap, Hook(MapLoad)); + LUA_HookInt(gamemap, HOOK(MapLoad)); } // No render mode or reloading gamestate, stop here. diff --git a/src/p_tick.c b/src/p_tick.c index 5857100a3..0f342daf1 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -656,7 +656,7 @@ void P_Ticker(boolean run) ps_lua_mobjhooks = 0; ps_checkposition_calls = 0; - LUA_Hook(PreThinkFrame); + LUA_HOOK(PreThinkFrame); ps_playerthink_time = I_GetPreciseTime(); for (i = 0; i < MAXPLAYERS; i++) @@ -760,7 +760,7 @@ void P_Ticker(boolean run) if (modeattacking) G_GhostTicker(); - LUA_Hook(PostThinkFrame); + LUA_HOOK(PostThinkFrame); } P_MapEnd(); @@ -783,7 +783,7 @@ void P_PreTicker(INT32 frames) { P_MapStart(); - LUA_Hook(PreThinkFrame); + LUA_HOOK(PreThinkFrame); for (i = 0; i < MAXPLAYERS; i++) if (playeringame[i] && players[i].mo && !P_MobjWasRemoved(players[i].mo)) @@ -819,7 +819,7 @@ void P_PreTicker(INT32 frames) P_UpdateSpecials(); P_RespawnSpecials(); - LUA_Hook(PostThinkFrame); + LUA_HOOK(PostThinkFrame); P_MapEnd(); } diff --git a/src/p_user.c b/src/p_user.c index 370a0c1f1..e6bd8e5ec 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -1860,7 +1860,7 @@ void P_SpawnShieldOrb(player_t *player) I_Error("P_SpawnShieldOrb: player->mo is NULL!\n"); #endif - if (LUA_HookPlayer(player, Hook(ShieldSpawn))) + if (LUA_HookPlayer(player, HOOK(ShieldSpawn))) return; if (player->powers[pw_shield] & SH_FORCE) @@ -4581,7 +4581,7 @@ static void P_DoSpinAbility(player_t *player, ticcmd_t *cmd) if (cmd->buttons & BT_SPIN) { - if (LUA_HookPlayer(player, Hook(SpinSpecial))) + if (LUA_HookPlayer(player, HOOK(SpinSpecial))) return; } @@ -5047,7 +5047,7 @@ static boolean P_PlayerShieldThink(player_t *player, ticcmd_t *cmd, mobj_t *lock } } } - if (cmd->buttons & BT_SPIN && !LUA_HookPlayer(player, Hook(ShieldSpecial))) // Spin button effects + if (cmd->buttons & BT_SPIN && !LUA_HookPlayer(player, HOOK(ShieldSpecial))) // Spin button effects { // Force stop if ((player->powers[pw_shield] & ~(SH_FORCEHP|SH_STACK)) == SH_FORCE) @@ -5171,7 +5171,7 @@ static void P_DoJumpStuff(player_t *player, ticcmd_t *cmd) // and you don't have a shield, do it! P_DoSuperTransformation(player, false); } - else if (!LUA_HookPlayer(player, Hook(JumpSpinSpecial))) + else if (!LUA_HookPlayer(player, HOOK(JumpSpinSpecial))) switch (player->charability) { case CA_THOK: @@ -5244,7 +5244,7 @@ static void P_DoJumpStuff(player_t *player, ticcmd_t *cmd) if (cmd->buttons & BT_JUMP && !player->exiting && !P_PlayerInPain(player)) { - if (LUA_HookPlayer(player, Hook(JumpSpecial))) + if (LUA_HookPlayer(player, HOOK(JumpSpecial))) ; // all situations below this require jump button not to be pressed already else if (player->pflags & PF_JUMPDOWN) @@ -5279,7 +5279,7 @@ static void P_DoJumpStuff(player_t *player, ticcmd_t *cmd) }*/ else if (player->pflags & PF_JUMPED) { - if (!LUA_HookPlayer(player, Hook(AbilitySpecial))) + if (!LUA_HookPlayer(player, HOOK(AbilitySpecial))) switch (player->charability) { case CA_THOK: @@ -5472,7 +5472,7 @@ static void P_DoJumpStuff(player_t *player, ticcmd_t *cmd) } else if (player->pflags & PF_THOKKED) { - if (!LUA_HookPlayer(player, Hook(AbilitySpecial))) + if (!LUA_HookPlayer(player, HOOK(AbilitySpecial))) switch (player->charability) { case CA_FLY: @@ -11479,7 +11479,7 @@ void P_PlayerThink(player_t *player) } if (player->playerstate == PST_REBORN) { - LUA_HookPlayer(player, Hook(PlayerThink)); + LUA_HookPlayer(player, HOOK(PlayerThink)); return; } } @@ -11583,7 +11583,7 @@ void P_PlayerThink(player_t *player) if (player->playerstate == PST_DEAD) { - LUA_HookPlayer(player, Hook(PlayerThink)); + LUA_HookPlayer(player, HOOK(PlayerThink)); return; } } @@ -11704,7 +11704,7 @@ void P_PlayerThink(player_t *player) { player->mo->flags2 &= ~MF2_SHADOW; P_DeathThink(player); - LUA_HookPlayer(player, Hook(PlayerThink)); + LUA_HookPlayer(player, HOOK(PlayerThink)); return; } @@ -11746,7 +11746,7 @@ void P_PlayerThink(player_t *player) { if (P_SpectatorJoinGame(player)) { - LUA_HookPlayer(player, Hook(PlayerThink)); + LUA_HookPlayer(player, HOOK(PlayerThink)); return; // player->mo was removed. } } @@ -11851,7 +11851,7 @@ void P_PlayerThink(player_t *player) if (!player->mo) { - LUA_HookPlayer(player, Hook(PlayerThink)); + LUA_HookPlayer(player, HOOK(PlayerThink)); return; // P_MovePlayer removed player->mo. } @@ -12305,7 +12305,7 @@ void P_PlayerThink(player_t *player) } #undef dashmode - LUA_HookPlayer(player, Hook(PlayerThink)); + LUA_HookPlayer(player, HOOK(PlayerThink)); /* // Colormap verification diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index f3da446d8..0bdb70d1f 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -1057,7 +1057,7 @@ void I_GetEvent(void) M_SetupJoystickMenu(0); break; case SDL_QUIT: - LUA_HookBool(true, Hook(GameQuit)); + LUA_HookBool(true, HOOK(GameQuit)); I_Quit(); break; } diff --git a/src/y_inter.c b/src/y_inter.c index ae4dcdaf0..5930d35ec 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -927,7 +927,7 @@ void Y_Ticker(void) if (paused || P_AutoPause()) return; - LUA_Hook(IntermissionThinker); + LUA_HOOK(IntermissionThinker); intertic++; From c5474436af67408342e8dce0ec996d62c9a4c21c Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Sat, 7 Nov 2020 19:47:50 -0500 Subject: [PATCH 0462/1080] Use FixedHypot over P_AproxDistance Not convinced that the small speed benefit from P_AproxDistance is worth the "aproximate"[sic] results it gives. Let's instead try a define to replace it with FixedHypot. In Lua, the function gives a deprecated warning. Inspired by the hyperwall fix for vanilla, except for everything. From little testing, actively improves waypoint checks, bumping, speed checks, wall collisions, Jawz targetting, Lightning Shield attacks, so on. The only way I see this as a potential downgrade is A_Look (and related functions) getting slower, which are barely used in Kart. --- src/lua_baselib.c | 3 ++- src/p_maputl.c | 13 ------------- src/p_maputl.h | 2 +- 3 files changed, 3 insertions(+), 15 deletions(-) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 515f6f0ba..7b2e42bd5 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -427,7 +427,8 @@ static int lib_pAproxDistance(lua_State *L) fixed_t dx = luaL_checkfixed(L, 1); fixed_t dy = luaL_checkfixed(L, 2); //HUDSAFE - lua_pushfixed(L, P_AproxDistance(dx, dy)); + LUA_Deprecated(L, "P_AproxDistance", "FixedHypot"); + lua_pushfixed(L, FixedHypot(dx, dy)); return 1; } diff --git a/src/p_maputl.c b/src/p_maputl.c index 90718a41c..83905a418 100644 --- a/src/p_maputl.c +++ b/src/p_maputl.c @@ -24,19 +24,6 @@ #include "p_slopes.h" #include "z_zone.h" -// -// P_AproxDistance -// Gives an estimation of distance (not exact) -// -fixed_t P_AproxDistance(fixed_t dx, fixed_t dy) -{ - dx = abs(dx); - dy = abs(dy); - if (dx < dy) - return dx + dy - (dx>>1); - return dx + dy - (dy>>1); -} - // // P_ClosestPointOnLine // Finds the closest point on a given line to the supplied point diff --git a/src/p_maputl.h b/src/p_maputl.h index 08b606833..df90ab4b4 100644 --- a/src/p_maputl.h +++ b/src/p_maputl.h @@ -41,7 +41,7 @@ typedef boolean (*traverser_t)(intercept_t *in); boolean P_PathTraverse(fixed_t px1, fixed_t py1, fixed_t px2, fixed_t py2, INT32 pflags, traverser_t ptrav); -FUNCMATH fixed_t P_AproxDistance(fixed_t dx, fixed_t dy); +#define P_AproxDistance(dx, dy) FixedHypot(dx, dy) void P_ClosestPointOnLine(fixed_t x, fixed_t y, line_t *line, vertex_t *result); void P_ClosestPointOnLine3D(const vector3_t *p, const vector3_t *line, vector3_t *result); INT32 P_PointOnLineSide(fixed_t x, fixed_t y, line_t *line); From e19196a86e5347edf7f25b335214cede978b91b8 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Sat, 7 Nov 2020 23:56:46 -0500 Subject: [PATCH 0463/1080] Use R_PointToDist2 instead Apparently overflows less often Actually, lets just fix FixedHypot instead. Now FixedHypot uses the code from R_PointToDist2, and R_PointToDist2 just calls FixedHypot. Ultimately, this branch was intended to get rid of a redundant way to retrieve distance and replace it with the one that was actually good at its job. So consolidating FixedHypot and R_PointToDist2 together is just an extension of that. --- src/m_fixed.c | 40 ++++++++++++++++++++++++++++------------ src/r_main.c | 24 +----------------------- 2 files changed, 29 insertions(+), 35 deletions(-) diff --git a/src/m_fixed.c b/src/m_fixed.c index eb10fd5f8..09d6936f2 100644 --- a/src/m_fixed.c +++ b/src/m_fixed.c @@ -18,8 +18,10 @@ #define HAVE_SQRTF #endif #endif + #include "doomdef.h" #include "m_fixed.h" +#include "tables.h" // ANGLETOFINESHIFT #ifdef __USE_C_FIXEDMUL__ @@ -105,20 +107,34 @@ fixed_t FixedSqrt(fixed_t x) fixed_t FixedHypot(fixed_t x, fixed_t y) { - fixed_t ax, yx, yx2, yx1; - if (abs(y) > abs(x)) // |y|>|x| + // Moved the code from R_PointToDist2 to here, + // since R_PointToDist2 did the same thing, + // except less prone to overflowing. + + angle_t angle; + fixed_t dist; + + x = abs(x); + y = abs(y); + + if (y > x) { - ax = abs(y); // |y| => ax - yx = FixedDiv(x, y); // (x/y) + fixed_t temp; + + temp = x; + x = y; + y = temp; } - else // |x|>|y| - { - ax = abs(x); // |x| => ax - yx = FixedDiv(y, x); // (x/y) - } - yx2 = FixedMul(yx, yx); // (x/y)^2 - yx1 = FixedSqrt(1 * FRACUNIT + yx2); // (1 + (x/y)^2)^1/2 - return FixedMul(ax, yx1); // |x|*((1 + (x/y)^2)^1/2) + + if (!y) + return x; + + angle = (tantoangle[FixedDiv(y, x)>>DBITS] + ANGLE_90) >> ANGLETOFINESHIFT; + + // use as cosine + dist = FixedDiv(x, FINESINE(angle)); + + return dist; } vector2_t *FV2_Load(vector2_t *vec, fixed_t x, fixed_t y) diff --git a/src/r_main.c b/src/r_main.c index f82fb589e..f6c05e312 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -357,29 +357,7 @@ angle_t R_PointToAngle2(fixed_t pviewx, fixed_t pviewy, fixed_t x, fixed_t y) fixed_t R_PointToDist2(fixed_t px2, fixed_t py2, fixed_t px1, fixed_t py1) { - angle_t angle; - fixed_t dx, dy, dist; - - dx = abs(px1 - px2); - dy = abs(py1 - py2); - - if (dy > dx) - { - fixed_t temp; - - temp = dx; - dx = dy; - dy = temp; - } - if (!dy) - return dx; - - angle = (tantoangle[FixedDiv(dy, dx)>>DBITS] + ANGLE_90) >> ANGLETOFINESHIFT; - - // use as cosine - dist = FixedDiv(dx, FINESINE(angle)); - - return dist; + return FixedHypot(px1 - px2, py1 - py2); } // Little extra utility. Works in the same way as R_PointToAngle2 From 75633bde5039106c5f916ca2b4d1bde11d274be9 Mon Sep 17 00:00:00 2001 From: James R Date: Sat, 12 Dec 2020 14:53:54 -0800 Subject: [PATCH 0464/1080] Replace all instances of P_AproxDistance with FixedHypot --- src/b_bot.c | 10 +-- src/g_game.c | 2 +- src/p_ceilng.c | 4 +- src/p_enemy.c | 172 ++++++++++++++++++++++++------------------------ src/p_floor.c | 10 +-- src/p_inter.c | 20 +++--- src/p_map.c | 10 +-- src/p_maputl.h | 1 - src/p_mobj.c | 78 +++++++++++----------- src/p_polyobj.c | 2 +- src/p_setup.c | 2 +- src/p_slopes.c | 2 +- src/p_spec.c | 58 ++++++++-------- src/p_user.c | 56 ++++++++-------- src/r_things.c | 4 +- src/s_sound.c | 4 +- src/st_stuff.c | 2 +- 17 files changed, 218 insertions(+), 219 deletions(-) diff --git a/src/b_bot.c b/src/b_bot.c index d3635f32c..abe69caeb 100644 --- a/src/b_bot.c +++ b/src/b_bot.c @@ -54,11 +54,11 @@ static void B_BuildTailsTiccmd(mobj_t *sonic, mobj_t *tails, ticcmd_t *cmd) boolean _2d = (tails->flags2 & MF2_TWOD) || twodlevel; fixed_t scale = tails->scale; - fixed_t dist = P_AproxDistance(sonic->x - tails->x, sonic->y - tails->y); + fixed_t dist = FixedHypot(sonic->x - tails->x, sonic->y - tails->y); fixed_t zdist = flip * (sonic->z - tails->z); angle_t ang = sonic->angle; - fixed_t pmom = P_AproxDistance(sonic->momx, sonic->momy); - fixed_t bmom = P_AproxDistance(tails->momx, tails->momy); + fixed_t pmom = FixedHypot(sonic->momx, sonic->momy); + fixed_t bmom = FixedHypot(tails->momx, tails->momy); fixed_t followmax = 128 * 8 * scale; // Max follow distance before AI begins to enter "panic" state fixed_t followthres = 92 * scale; // Distance that AI will try to reach fixed_t followmin = 32 * scale; @@ -81,7 +81,7 @@ static void B_BuildTailsTiccmd(mobj_t *sonic, mobj_t *tails, ticcmd_t *cmd) if (tails->player->powers[pw_carry] == CR_MACESPIN || tails->player->powers[pw_carry] == CR_GENERIC) { boolean isrelevant = (sonic->player->powers[pw_carry] == CR_MACESPIN || sonic->player->powers[pw_carry] == CR_GENERIC); - dist = P_AproxDistance(tails->x-sonic->x, tails->y-sonic->y); + dist = FixedHypot(tails->x-sonic->x, tails->y-sonic->y); if (sonic->player->cmd.buttons & BT_JUMP && (sonic->player->pflags & PF_JUMPED) && isrelevant) cmd->buttons |= BT_JUMP; if (isrelevant) @@ -496,7 +496,7 @@ boolean B_CheckRespawn(player_t *player) } // If you can't see Sonic, I guess we should? - if (!P_CheckSight(sonic, tails) && P_AproxDistance(P_AproxDistance(tails->x-sonic->x, tails->y-sonic->y), tails->z-sonic->z) > FixedMul(1024*FRACUNIT, tails->scale)) + if (!P_CheckSight(sonic, tails) && FixedHypot(FixedHypot(tails->x-sonic->x, tails->y-sonic->y), tails->z-sonic->z) > FixedMul(1024*FRACUNIT, tails->scale)) return true; return false; } diff --git a/src/g_game.c b/src/g_game.c index 6171c7b72..3f8d573c8 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1423,7 +1423,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) newtarget = P_SpawnMobj(ticcmd_ztargetfocus[forplayer]->x, ticcmd_ztargetfocus[forplayer]->y, ticcmd_ztargetfocus[forplayer]->z, MT_LOCKON); // positioning, flip handled in P_SceneryThinker P_SetTarget(&newtarget->target, ticcmd_ztargetfocus[forplayer]); - if (P_AproxDistance( + if (FixedHypot( player->mo->x - ticcmd_ztargetfocus[forplayer]->x, player->mo->y - ticcmd_ztargetfocus[forplayer]->y ) > 50*player->mo->scale) diff --git a/src/p_ceilng.c b/src/p_ceilng.c index f12499d5c..2168d1d78 100644 --- a/src/p_ceilng.c +++ b/src/p_ceilng.c @@ -468,7 +468,7 @@ INT32 EV_DoCeiling(line_t *line, ceiling_e type) // Linedef executor excellence case moveCeilingByFrontSector: - ceiling->speed = P_AproxDistance(line->dx, line->dy); + ceiling->speed = FixedHypot(line->dx, line->dy); ceiling->speed = FixedDiv(ceiling->speed,8*FRACUNIT); if (line->frontsector->ceilingheight >= sec->ceilingheight) // Move up { @@ -547,7 +547,7 @@ INT32 EV_DoCeiling(line_t *line, ceiling_e type) */ case bounceCeiling: - ceiling->speed = P_AproxDistance(line->dx, line->dy); // same speed as elevateContinuous + ceiling->speed = FixedHypot(line->dx, line->dy); // same speed as elevateContinuous ceiling->speed = FixedDiv(ceiling->speed,4*FRACUNIT); ceiling->origspeed = ceiling->speed; if (line->frontsector->ceilingheight >= sec->ceilingheight) // Move up diff --git a/src/p_enemy.c b/src/p_enemy.c index 203e04af1..0d94f2a7e 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -334,7 +334,7 @@ boolean P_CheckMeleeRange(mobj_t *actor) return false; pl = actor->target; - dist = P_AproxDistance(pl->x-actor->x, pl->y-actor->y); + dist = FixedHypot(pl->x-actor->x, pl->y-actor->y); if (dist >= FixedMul(MELEERANGE - 20*FRACUNIT, actor->scale) + pl->radius) return false; @@ -360,7 +360,7 @@ boolean P_JetbCheckMeleeRange(mobj_t *actor) return false; pl = actor->target; - dist = P_AproxDistance(pl->x-actor->x, pl->y-actor->y); + dist = FixedHypot(pl->x-actor->x, pl->y-actor->y); if (dist >= (actor->radius + pl->radius)*2) return false; @@ -389,7 +389,7 @@ boolean P_FaceStabCheckMeleeRange(mobj_t *actor) return false; pl = actor->target; - dist = P_AproxDistance(pl->x-actor->x, pl->y-actor->y); + dist = FixedHypot(pl->x-actor->x, pl->y-actor->y); if (dist >= (actor->radius + pl->radius)*4) return false; @@ -413,7 +413,7 @@ boolean P_SkimCheckMeleeRange(mobj_t *actor) return false; pl = actor->target; - dist = P_AproxDistance(pl->x-actor->x, pl->y-actor->y); + dist = FixedHypot(pl->x-actor->x, pl->y-actor->y); if (dist >= FixedMul(MELEERANGE - 20*FRACUNIT, actor->scale) + pl->radius) return false; @@ -449,7 +449,7 @@ boolean P_CheckMissileRange(mobj_t *actor) return false; // OPTIMIZE: get this from a global checksight - dist = P_AproxDistance(actor->x-actor->target->x, actor->y-actor->target->y) - FixedMul(64*FRACUNIT, actor->scale); + dist = FixedHypot(actor->x-actor->target->x, actor->y-actor->target->y) - FixedMul(64*FRACUNIT, actor->scale); if (!actor->info->meleestate) dist -= FixedMul(128*FRACUNIT, actor->scale); // no melee attack, so fire more @@ -750,7 +750,7 @@ boolean P_LookForPlayers(mobj_t *actor, boolean allaround, boolean tracer, fixed continue; // Ignore uncontrolled bodies if (dist > 0 - && P_AproxDistance(P_AproxDistance(player->mo->x - actor->x, player->mo->y - actor->y), player->mo->z - actor->z) > dist) + && FixedHypot(FixedHypot(player->mo->x - actor->x, player->mo->y - actor->y), player->mo->z - actor->z) > dist) continue; // Too far away if (!allaround) @@ -758,7 +758,7 @@ boolean P_LookForPlayers(mobj_t *actor, boolean allaround, boolean tracer, fixed an = R_PointToAngle2(actor->x, actor->y, player->mo->x, player->mo->y) - actor->angle; if (an > ANGLE_90 && an < ANGLE_270) { - dist = P_AproxDistance(player->mo->x - actor->x, player->mo->y - actor->y); + dist = FixedHypot(player->mo->x - actor->x, player->mo->y - actor->y); // if real close, react anyway if (dist > FixedMul(MELEERANGE, actor->scale)) continue; // behind back @@ -821,7 +821,7 @@ static boolean P_LookForShield(mobj_t *actor) continue; if ((player->powers[pw_shield] & SH_PROTECTELECTRIC) - && (P_AproxDistance(P_AproxDistance(actor->x-player->mo->x, actor->y-player->mo->y), actor->z-player->mo->z) < FixedMul(RING_DIST, player->mo->scale))) + && (FixedHypot(FixedHypot(actor->x-player->mo->x, actor->y-player->mo->y), actor->z-player->mo->z) < FixedMul(RING_DIST, player->mo->scale))) { P_SetTarget(&actor->tracer, player->mo); @@ -1548,8 +1548,8 @@ void A_PointyThink(mobj_t *actor) } else { - if (P_AproxDistance(players[i].mo->x - actor->x, players[i].mo->y - actor->y) < - P_AproxDistance(player->mo->x - actor->x, player->mo->y - actor->y)) + if (FixedHypot(players[i].mo->x - actor->x, players[i].mo->y - actor->y) < + FixedHypot(player->mo->x - actor->x, player->mo->y - actor->y)) player = &players[i]; } } @@ -1561,7 +1561,7 @@ void A_PointyThink(mobj_t *actor) P_SetTarget(&actor->target, player->mo); A_FaceTarget(actor); - if (P_AproxDistance(player->mo->x - actor->x, player->mo->y - actor->y) < P_AproxDistance(player->mo->x + player->mo->momx - actor->x, player->mo->y + player->mo->momy - actor->y)) + if (FixedHypot(player->mo->x - actor->x, player->mo->y - actor->y) < FixedHypot(player->mo->x + player->mo->momx - actor->x, player->mo->y + player->mo->momy - actor->y)) sign = -1; // Player is moving away else sign = 1; // Player is moving closer @@ -1638,7 +1638,7 @@ static void P_ParabolicMove(mobj_t *actor, fixed_t x, fixed_t y, fixed_t z, fixe y -= actor->y; z -= actor->z; - dh = P_AproxDistance(x, y); + dh = FixedHypot(x, y); actor->momx = FixedMul(FixedDiv(x, dh), speed); actor->momy = FixedMul(FixedDiv(y, dh), speed); @@ -1706,7 +1706,7 @@ void A_HoodThink(mobj_t *actor) } dx = (actor->target->x - actor->x), dy = (actor->target->y - actor->y), dz = (actor->target->z - actor->z); - dm = P_AproxDistance(dx, dy); + dm = FixedHypot(dx, dy); // Target dangerously close to robohood, retreat then. if ((dm < 256<target || !crab->info->missilestate || (statenum_t)(crab->state-states) == crab->info->missilestate) return; - if (((ang + ANG1) < ANG2) || P_AproxDistance(crab->x - crab->target->x, crab->y - crab->target->y) < 333*crab->scale) + if (((ang + ANG1) < ANG2) || FixedHypot(crab->x - crab->target->x, crab->y - crab->target->y) < 333*crab->scale) P_SetMobjState(crab, crab->info->missilestate); } @@ -2703,7 +2703,7 @@ void A_LobShot(mobj_t *actor) shot->angle = an = actor->angle; an >>= ANGLETOFINESHIFT; - dist = P_AproxDistance(actor->target->x - shot->x, actor->target->y - shot->y); + dist = FixedHypot(actor->target->x - shot->x, actor->target->y - shot->y); horizontal = dist / airtime; vertical = FixedMul((gravity*airtime)/2, shot->scale); @@ -2721,7 +2721,7 @@ void A_LobShot(mobj_t *actor) diff = actor->z - actor->target->z; { - launchhyp = P_AproxDistance(horizontal, vertical); + launchhyp = FixedHypot(horizontal, vertical); orig = FixedMul(FixedDiv(vertical, horizontal), diff); @@ -3325,7 +3325,7 @@ void A_SkullAttack(mobj_t *actor) S_StartSound(actor, actor->info->activesound); A_FaceTarget(actor); - dist = P_AproxDistance(dest->x - actor->x, dest->y - actor->y); + dist = FixedHypot(dest->x - actor->x, dest->y - actor->y); if (locvar1 == 1) actor->angle += ANGLE_180; @@ -3443,7 +3443,7 @@ void A_BossZoom(mobj_t *actor) an = actor->angle >> ANGLETOFINESHIFT; actor->momx = FixedMul(FixedMul(actor->info->speed*5*FRACUNIT, actor->scale), FINECOSINE(an)); actor->momy = FixedMul(FixedMul(actor->info->speed*5*FRACUNIT, actor->scale), FINESINE(an)); - dist = P_AproxDistance(dest->x - actor->x, dest->y - actor->y); + dist = FixedHypot(dest->x - actor->x, dest->y - actor->y); dist = dist / FixedMul(actor->info->speed*5*FRACUNIT, actor->scale); if (dist < 1) @@ -3599,7 +3599,7 @@ void A_1upThinker(mobj_t *actor) if ((netgame || multiplayer) && players[i].playerstate != PST_LIVE) continue; - temp = P_AproxDistance(players[i].mo->x-actor->x, players[i].mo->y-actor->y); + temp = FixedHypot(players[i].mo->x-actor->x, players[i].mo->y-actor->y); if (temp < dist) { @@ -4144,8 +4144,8 @@ bossjustdie: // If this one's further then the last one, don't go for it. if (mo->target && - P_AproxDistance(P_AproxDistance(mo->x - mo2->x, mo->y - mo2->y), mo->z - mo2->z) > - P_AproxDistance(P_AproxDistance(mo->x - mo->target->x, mo->y - mo->target->y), mo->z - mo->target->z)) + FixedHypot(FixedHypot(mo->x - mo2->x, mo->y - mo2->y), mo->z - mo2->z) > + FixedHypot(FixedHypot(mo->x - mo->target->x, mo->y - mo->target->y), mo->z - mo->target->z)) continue; // Otherwise... Do! @@ -4536,7 +4536,7 @@ void A_BubbleSpawn(mobj_t *actor) // Don't spawn bubbles unless a player is relatively close by (var1). for (i = 0; i < MAXPLAYERS; ++i) if (playeringame[i] && players[i].mo - && P_AproxDistance(actor->x - players[i].mo->x, actor->y - players[i].mo->y) < (locvar1<x - players[i].mo->x, actor->y - players[i].mo->y) < (locvar1<x - players[i].mo->x, actor->y - players[i].mo->y) < (locvar1<x - players[i].mo->x, actor->y - players[i].mo->y) < (locvar1<x-target->x, actor->y-target->y)>>FRACBITS; + dist = FixedHypot(actor->x-target->x, actor->y-target->y)>>FRACBITS; if (dist > FixedMul((locvar2 & 65535), actor->scale)) return; @@ -4800,7 +4800,7 @@ void A_FishJump(mobj_t *actor) // Don't spawn trail unless a player is nearby. for (i = 0; i < MAXPLAYERS; ++i) if (playeringame[i] && players[i].mo - && P_AproxDistance(actor->x - players[i].mo->x, actor->y - players[i].mo->y) < (actor->info->speed)) + && FixedHypot(actor->x - players[i].mo->x, actor->y - players[i].mo->y) < (actor->info->speed)) break; // Stop looking. if (i < MAXPLAYERS) { @@ -4905,7 +4905,7 @@ void A_ThrownRing(mobj_t *actor) // magnetic player. If he gets too far away, make // sure to stop the attraction! if ((!actor->tracer->health) || (actor->tracer->player && (actor->tracer->player->powers[pw_shield] & SH_PROTECTELECTRIC) - && P_AproxDistance(P_AproxDistance(actor->tracer->x-actor->x, + && FixedHypot(FixedHypot(actor->tracer->x-actor->x, actor->tracer->y-actor->y), actor->tracer->z-actor->z) > FixedMul(RING_DIST/4, actor->tracer->scale))) { P_SetTarget(&actor->tracer, NULL); @@ -4964,7 +4964,7 @@ void A_ThrownRing(mobj_t *actor) continue; } - dist = P_AproxDistance(P_AproxDistance(player->mo->x-actor->x, + dist = FixedHypot(FixedHypot(player->mo->x-actor->x, player->mo->y-actor->y), player->mo->z-actor->z); // check distance @@ -5345,7 +5345,7 @@ void A_JetChase(mobj_t *actor) return; // got a new target // If the player is over 3072 fracunits away, then look for another player - if (P_AproxDistance(P_AproxDistance(actor->target->x - actor->x, actor->target->y - actor->y), + if (FixedHypot(FixedHypot(actor->target->x - actor->x, actor->target->y - actor->y), actor->target->z - actor->z) > FixedMul(3072*FRACUNIT, actor->scale) && P_LookForPlayers(actor, true, false, FixedMul(3072*FRACUNIT, actor->scale))) { return; // got a new target @@ -5460,7 +5460,7 @@ void A_JetgShoot(mobj_t *actor) if (actor->reactiontime) return; - dist = P_AproxDistance(actor->target->x - actor->x, actor->target->y - actor->y); + dist = FixedHypot(actor->target->x - actor->x, actor->target->y - actor->y); if (dist > FixedMul(actor->info->painchance*FRACUNIT, actor->scale)) return; @@ -5497,7 +5497,7 @@ void A_ShootBullet(mobj_t *actor) if (!actor->target) return; - dist = P_AproxDistance(P_AproxDistance(actor->target->x - actor->x, actor->target->y - actor->y), actor->target->z - actor->z); + dist = FixedHypot(FixedHypot(actor->target->x - actor->x, actor->target->y - actor->y), actor->target->z - actor->z); if (dist > FixedMul(actor->info->painchance*FRACUNIT, actor->scale)) return; @@ -5522,7 +5522,7 @@ static boolean PIT_MinusCarry(mobj_t *thing) if (!(thing->flags & (MF_PUSHABLE|MF_ENEMY))) return true; - if (P_AproxDistance(minus->x - thing->x, minus->y - thing->y) >= minus->radius*3) + if (FixedHypot(minus->x - thing->x, minus->y - thing->y) >= minus->radius*3) return true; if (abs(thing->z - minus->z) > minus->height) @@ -5566,7 +5566,7 @@ void A_MinusDigging(mobj_t *actor) P_TryMove(par, x, y, false); // If close enough, prepare to attack - if (P_AproxDistance(actor->x - actor->target->x, actor->y - actor->target->y) < actor->radius*2) + if (FixedHypot(actor->x - actor->target->x, actor->y - actor->target->y) < actor->radius*2) { P_SetMobjState(actor, actor->info->meleestate); P_TryMove(actor, actor->target->x, actor->target->y, false); @@ -5858,7 +5858,7 @@ void A_DetonChase(mobj_t *actor) } }*/ // movedir is up/down angle: how much it has to go up as it goes over to the player - xydist = P_AproxDistance(actor->tracer->x - actor->x, actor->tracer->y - actor->y); + xydist = FixedHypot(actor->tracer->x - actor->x, actor->tracer->y - actor->y); exact = R_PointToAngle2(0, 0, xydist, actor->tracer->z - actor->z); actor->movedir = exact; /*if (exact != actor->movedir) @@ -5880,7 +5880,7 @@ void A_DetonChase(mobj_t *actor) // check for melee attack if (actor->tracer) { - if (P_AproxDistance(actor->tracer->x-actor->x, actor->tracer->y-actor->y) < actor->radius+actor->tracer->radius) + if (FixedHypot(actor->tracer->x-actor->x, actor->tracer->y-actor->y) < actor->radius+actor->tracer->radius) { if (!((actor->tracer->z > actor->z + actor->height) || (actor->z > actor->tracer->z + actor->tracer->height))) { @@ -5891,7 +5891,7 @@ void A_DetonChase(mobj_t *actor) } // chase towards player - if ((dist = P_AproxDistance(xydist, actor->tracer->z-actor->z)) + if ((dist = FixedHypot(xydist, actor->tracer->z-actor->z)) > FixedMul((actor->info->painchance << FRACBITS), actor->scale)) { P_SetTarget(&actor->tracer, NULL); // Too far away @@ -5933,7 +5933,7 @@ void A_DetonChase(mobj_t *actor) actor->momy = FixedMul(xyspeed, FINESINE(exact)); // Variable re-use - xyspeed = (P_AproxDistance(actor->tracer->x - actor->x, P_AproxDistance(actor->tracer->y - actor->y, actor->tracer->z - actor->z))>>(FRACBITS+6)); + xyspeed = (FixedHypot(actor->tracer->x - actor->x, FixedHypot(actor->tracer->y - actor->y, actor->tracer->z - actor->z))>>(FRACBITS+6)); if (xyspeed < 1) xyspeed = 1; @@ -6081,7 +6081,7 @@ void A_UnidusBall(mobj_t *actor) if (actor->movecount) { - if (P_AproxDistance(actor->momx, actor->momy) < FixedMul(actor->info->damage/2, actor->scale)) + if (FixedHypot(actor->momx, actor->momy) < FixedMul(actor->info->damage/2, actor->scale)) P_ExplodeMissile(actor); return; } @@ -6113,7 +6113,7 @@ void A_UnidusBall(mobj_t *actor) if (locvar1 == 1 && canthrow) { - if (P_AproxDistance(actor->target->target->x - actor->target->x, actor->target->target->y - actor->target->y) > FixedMul(MISSILERANGE>>1, actor->scale) + if (FixedHypot(actor->target->target->x - actor->target->x, actor->target->target->y - actor->target->y) > FixedMul(MISSILERANGE>>1, actor->scale) || !P_CheckSight(actor, actor->target->target)) return; @@ -6188,7 +6188,7 @@ void A_RockSpawn(mobj_t *actor) return; } - dist = P_AproxDistance(line->dx, line->dy)/16; + dist = FixedHypot(line->dx, line->dy)/16; if (dist < 1) dist = 1; @@ -6354,7 +6354,7 @@ void A_CrawlaCommanderThink(mobj_t *actor) return; } - dist = P_AproxDistance(actor->x - actor->target->x, actor->y - actor->target->y); + dist = FixedHypot(actor->x - actor->target->x, actor->y - actor->target->y); if (actor->target->player && (!hovermode || actor->reactiontime <= 2*TICRATE)) { @@ -6391,7 +6391,7 @@ void A_CrawlaCommanderThink(mobj_t *actor) { fixed_t mom; P_Thrust(actor, actor->angle, 2*actor->scale); - mom = P_AproxDistance(actor->momx, actor->momy); + mom = FixedHypot(actor->momx, actor->momy); if (mom > 20*actor->scale) { mom += 20*actor->scale; @@ -6479,7 +6479,7 @@ void A_RingExplode(mobj_t *actor) if (mo2 == actor) // Don't explode yourself! Endless loop! continue; - if (P_AproxDistance(P_AproxDistance(mo2->x - actor->x, mo2->y - actor->y), mo2->z - actor->z) > FixedMul(actor->info->painchance, actor->scale)) + if (FixedHypot(FixedHypot(mo2->x - actor->x, mo2->y - actor->y), mo2->z - actor->z) > FixedMul(actor->info->painchance, actor->scale)) continue; if (mo2->flags & MF_SHOOTABLE) @@ -7078,7 +7078,7 @@ nomissile: } // chase towards player - if (P_AproxDistance(actor->target->x-actor->x, actor->target->y-actor->y) > actor->radius+actor->target->radius) + if (FixedHypot(actor->target->x-actor->x, actor->target->y-actor->y) > actor->radius+actor->target->radius) { if (--actor->movecount < 0 || !P_Move(actor, actor->info->speed)) P_NewChaseDir(actor); @@ -7317,7 +7317,7 @@ void A_Boss7Chase(mobj_t *actor) // Self-adjust if stuck on the edge if (actor->tracer) { - if (P_AproxDistance(actor->x - actor->tracer->x, actor->y - actor->tracer->y) > 128*FRACUNIT - actor->radius) + if (FixedHypot(actor->x - actor->tracer->x, actor->y - actor->tracer->y) > 128*FRACUNIT - actor->radius) P_InstaThrust(actor, R_PointToAngle2(actor->x, actor->y, actor->tracer->x, actor->tracer->y), FRACUNIT); } @@ -7353,7 +7353,7 @@ void A_Boss7Chase(mobj_t *actor) if (players[i].mo->health <= 0) continue; - if (P_AproxDistance(players[i].mo->x - actor->x, players[i].mo->y - actor->y) > actor->radius) + if (FixedHypot(players[i].mo->x - actor->x, players[i].mo->y - actor->y) > actor->radius) continue; if (players[i].mo->z > actor->z + actor->height - 2*FRACUNIT @@ -7476,7 +7476,7 @@ void A_Boss2PogoSFX(mobj_t *actor) } // Boing! - if (P_AproxDistance(actor->x-actor->target->x, actor->y-actor->target->y) < FixedMul(256*FRACUNIT, actor->scale)) + if (FixedHypot(actor->x-actor->target->x, actor->y-actor->target->y) < FixedMul(256*FRACUNIT, actor->scale)) { actor->angle = R_PointToAngle2(actor->x, actor->y, actor->target->x, actor->target->y); P_InstaThrust(actor, actor->angle, FixedMul(actor->info->speed, actor->scale)); @@ -7509,7 +7509,7 @@ void A_Boss2PogoTarget(mobj_t *actor) return; if (!actor->target || !(actor->target->flags & MF_SHOOTABLE) || (actor->target->player && actor->target->player->powers[pw_flashing]) - || P_AproxDistance(actor->x-actor->target->x, actor->y-actor->target->y) >= FixedMul(512*FRACUNIT, actor->scale)) + || FixedHypot(actor->x-actor->target->x, actor->y-actor->target->y) >= FixedMul(512*FRACUNIT, actor->scale)) { // look for a new target if (P_LookForPlayers(actor, true, false, 512*FRACUNIT)) @@ -7530,7 +7530,7 @@ void A_Boss2PogoTarget(mobj_t *actor) P_InstaThrust(actor, actor->angle+ANGLE_180, FixedMul(FixedMul(actor->info->speed,(locvar2)), actor->scale)); // Move at wandering speed } // Try to land on top of the player. - else if (P_AproxDistance(actor->x-actor->target->x, actor->y-actor->target->y) < FixedMul(512*FRACUNIT, actor->scale)) + else if (FixedHypot(actor->x-actor->target->x, actor->y-actor->target->y) < FixedMul(512*FRACUNIT, actor->scale)) { fixed_t airtime, gravityadd, zoffs; @@ -7558,7 +7558,7 @@ void A_Boss2PogoTarget(mobj_t *actor) airtime = FixedDiv((-actor->momz - FixedSqrt(FixedMul(actor->momz,actor->momz)+zoffs)), gravityadd)<<1; // to try and land on their head rather than on their feet actor->angle = R_PointToAngle2(actor->x, actor->y, actor->target->x, actor->target->y); - P_InstaThrust(actor, actor->angle, FixedDiv(P_AproxDistance(actor->x - actor->target->x, actor->y - actor->target->y), airtime)); + P_InstaThrust(actor, actor->angle, FixedDiv(FixedHypot(actor->x - actor->target->x, actor->y - actor->target->y), airtime)); } // Wander semi-randomly towards the player to get closer. else @@ -7629,7 +7629,7 @@ void A_TurretFire(mobj_t *actor) while (P_SupermanLook4Players(actor) && count < MAXPLAYERS) { - if (P_AproxDistance(actor->x - actor->target->x, actor->y - actor->target->y) < dist) + if (FixedHypot(actor->x - actor->target->x, actor->y - actor->target->y) < dist) { actor->flags2 |= MF2_FIRING; actor->extravalue1 = locvar1; @@ -7667,7 +7667,7 @@ void A_SuperTurretFire(mobj_t *actor) while (P_SupermanLook4Players(actor) && count < MAXPLAYERS) { - if (P_AproxDistance(actor->x - actor->target->x, actor->y - actor->target->y) < dist) + if (FixedHypot(actor->x - actor->target->x, actor->y - actor->target->y) < dist) { actor->flags2 |= MF2_FIRING; actor->flags2 |= MF2_SUPERFIRE; @@ -7788,7 +7788,7 @@ void A_BuzzFly(mobj_t *actor) } // If the player is over 3072 fracunits away, then look for another player - if (P_AproxDistance(P_AproxDistance(actor->target->x - actor->x, actor->target->y - actor->y), + if (FixedHypot(FixedHypot(actor->target->x - actor->x, actor->target->y - actor->y), actor->target->z - actor->z) > FixedMul(3072*FRACUNIT, actor->scale)) { if (multiplayer || netgame) @@ -7807,7 +7807,7 @@ void A_BuzzFly(mobj_t *actor) else realspeed = FixedMul(actor->info->speed, actor->scale); - dist = P_AproxDistance(P_AproxDistance(actor->target->x - actor->x, + dist = FixedHypot(FixedHypot(actor->target->x - actor->x, actor->target->y - actor->y), actor->target->z - actor->z); if (dist < 1) @@ -8165,7 +8165,7 @@ void A_Boss3Path(mobj_t *actor) if (actor->target->x == actor->x && actor->target->y == actor->y) { - dist = P_AproxDistance(P_AproxDistance(actor->target->x - actor->x, actor->target->y - actor->y), actor->target->z + actor->movefactor - actor->z); + dist = FixedHypot(FixedHypot(actor->target->x - actor->x, actor->target->y - actor->y), actor->target->z + actor->movefactor - actor->z); if (dist < 1) dist = 1; @@ -9575,7 +9575,7 @@ void A_SetObjectTypeState(mobj_t *actor) if (mo2->type == (mobjtype_t)loc2lw) { - dist = P_AproxDistance(mo2->x - actor->x, mo2->y - actor->y); + dist = FixedHypot(mo2->x - actor->x, mo2->y - actor->y); if (mo2->health > 0) { @@ -10081,9 +10081,9 @@ void A_CheckRange(mobj_t *actor) return; if (!(locvar1 >> 16)) //target - dist = P_AproxDistance(actor->target->x - actor->x, actor->target->y - actor->y); + dist = FixedHypot(actor->target->x - actor->x, actor->target->y - actor->y); else //tracer - dist = P_AproxDistance(actor->tracer->x - actor->x, actor->tracer->y - actor->y); + dist = FixedHypot(actor->tracer->x - actor->x, actor->tracer->y - actor->y); if (dist <= FixedMul((locvar1 & 65535)*FRACUNIT, actor->scale)) P_SetMobjState(actor, locvar2); @@ -10145,16 +10145,16 @@ void A_CheckTrueRange(mobj_t *actor) if (!(locvar1 >> 16)) // target { height = actor->target->z - actor->z; - dist = P_AproxDistance(actor->target->x - actor->x, actor->target->y - actor->y); + dist = FixedHypot(actor->target->x - actor->x, actor->target->y - actor->y); } else // tracer { height = actor->tracer->z - actor->z; - dist = P_AproxDistance(actor->tracer->x - actor->x, actor->tracer->y - actor->y); + dist = FixedHypot(actor->tracer->x - actor->x, actor->tracer->y - actor->y); } - l = P_AproxDistance(dist, height); + l = FixedHypot(dist, height); if (l <= FixedMul((locvar1 & 65535)*FRACUNIT, actor->scale)) P_SetMobjState(actor, locvar2); @@ -10199,7 +10199,7 @@ void A_CheckThingCount(mobj_t *actor) if (mo2->type == (mobjtype_t)loc1up) { - dist = P_AproxDistance(mo2->x - actor->x, mo2->y - actor->y); + dist = FixedHypot(mo2->x - actor->x, mo2->y - actor->y); if (loc2up == 0) count++; @@ -10808,7 +10808,7 @@ void A_HomingChase(mobj_t *actor) actor->angle = R_PointToAngle2(actor->x, actor->y, dest->x, dest->y); - dist = P_AproxDistance(P_AproxDistance(dest->x - actor->x, dest->y - actor->y), dest->z - actor->z); + dist = FixedHypot(FixedHypot(dest->x - actor->x, dest->y - actor->y), dest->z - actor->z); if (dist < 1) dist = 1; @@ -11394,14 +11394,14 @@ void A_BrakLobShot(mobj_t *actor) g = gravity; // Look up distance between actor and its target - x = P_AproxDistance(actor->target->x - actor->x, actor->target->y - actor->y); + x = FixedHypot(actor->target->x - actor->x, actor->target->y - actor->y); if (!aimDirect) { // Distance should actually be a third of the way over x = FixedDiv(x, 3<x + P_ReturnThrustX(actor, actor->angle, x); newTargetY = actor->y + P_ReturnThrustY(actor, actor->angle, x); - x = P_AproxDistance(newTargetX - actor->x, newTargetY - actor->y); + x = FixedHypot(newTargetX - actor->x, newTargetY - actor->y); // Look up height difference between actor and the ground 1/3 of the way to its target y = P_FloorzAtPos(newTargetX, newTargetY, actor->target->z, actor->target->height) - (actor->z + FixedMul(locvar2*FRACUNIT, actor->scale)); } @@ -11753,7 +11753,7 @@ void A_FlickyCenter(mobj_t *actor) P_LookForPlayers(actor, true, false, actor->extravalue1); - if (actor->target && P_AproxDistance(actor->target->x - originx, actor->target->y - originy) < actor->extravalue1) + if (actor->target && FixedHypot(actor->target->x - originx, actor->target->y - originy) < actor->extravalue1) { actor->extravalue2 = 1; P_TeleportMove(actor, actor->target->x, actor->target->y, actor->target->z); @@ -11809,7 +11809,7 @@ void A_FlickyAim(mobj_t *actor) if ((actor->momx == actor->momy && actor->momy == 0) || (actor->target && P_IsFlickyCenter(actor->target->type) && actor->target->extravalue1 && (actor->target->flags & MF_SLIDEME) - && P_AproxDistance(actor->x - actor->target->x, actor->y - actor->target->y) >= actor->target->extravalue1)) + && FixedHypot(actor->x - actor->target->x, actor->y - actor->target->y) >= actor->target->extravalue1)) flickyhitwall = true; P_InternalFlickyBubble(actor); @@ -11831,12 +11831,12 @@ void A_FlickyAim(mobj_t *actor) actor->movedir *= -1; posvar = ((R_PointToAngle2(actor->target->x, actor->target->y, actor->x, actor->y) + actor->movedir*locvar1) >> ANGLETOFINESHIFT) & FINEMASK; - chasevar = FixedSqrt(max(FRACUNIT, P_AproxDistance(actor->target->x - actor->x, actor->target->y - actor->y) - locvar2)) + locvar2; + chasevar = FixedSqrt(max(FRACUNIT, FixedHypot(actor->target->x - actor->x, actor->target->y - actor->y) - locvar2)) + locvar2; chasex = actor->target->x + FixedMul(FINECOSINE(posvar), chasevar); chasey = actor->target->y + FixedMul(FINESINE(posvar), chasevar); - if (P_AproxDistance(chasex - actor->x, chasey - actor->y)) + if (FixedHypot(chasex - actor->x, chasey - actor->y)) actor->angle = R_PointToAngle2(actor->x, actor->y, chasex, chasey); } else if (flickyhitwall) @@ -11878,7 +11878,7 @@ void P_InternalFlickyFly(mobj_t *actor, fixed_t flyspeed, fixed_t targetdist, fi targetdist = 16*FRACUNIT; //Default! if (actor->target && abs(chasez - actor->z) > targetdist) - targetdist = P_AproxDistance(actor->target->x - actor->x, actor->target->y - actor->y); + targetdist = FixedHypot(actor->target->x - actor->x, actor->target->y - actor->y); if (actor->target && P_IsFlickyCenter(actor->target->type) @@ -11956,7 +11956,7 @@ void A_FlickyCoast(mobj_t *actor) actor->momy = (11*actor->momy)/12; actor->momz = (11*actor->momz)/12; - if (P_AproxDistance(P_AproxDistance(actor->momx, actor->momy), actor->momz) < locvar1) + if (FixedHypot(FixedHypot(actor->momx, actor->momy), actor->momz) < locvar1) P_SetMobjState(actor, locvar2); return; @@ -12220,7 +12220,7 @@ void A_Boss5Jump(mobj_t *actor) g = gravity; // Look up distance between actor and its tracer - x = P_AproxDistance(actor->tracer->x - actor->x, actor->tracer->y - actor->y); + x = FixedHypot(actor->tracer->x - actor->x, actor->tracer->y - actor->y); // Look up height difference between actor and its tracer y = actor->tracer->z - actor->z; @@ -12341,7 +12341,7 @@ void A_MineExplode(mobj_t *actor) actor->z+P_RandomRange(((actor->eflags & MFE_UNDERWATER) ? -dist : 0), dist)*FRACUNIT, type); fixed_t dx = b->x - actor->x, dy = b->y - actor->y, dz = b->z - actor->z; - fixed_t dm = P_AproxDistance(dz, P_AproxDistance(dy, dx)); + fixed_t dm = FixedHypot(dz, FixedHypot(dy, dx)); b->momx = FixedDiv(dx, dm)*3; b->momy = FixedDiv(dy, dm)*3; b->momz = FixedDiv(dz, dm)*3; @@ -12373,7 +12373,7 @@ void A_MineRange(mobj_t *actor) if (!actor->target) return; - dm = P_AproxDistance(actor->z - actor->target->z, P_AproxDistance(actor->y - actor->target->y, actor->x - actor->target->x)); + dm = FixedHypot(actor->z - actor->target->z, FixedHypot(actor->y - actor->target->y, actor->x - actor->target->x)); if ((dm>>FRACBITS) < locvar1) P_SetMobjState(actor, actor->info->meleestate); } @@ -12499,7 +12499,7 @@ void A_MultiShotDist(mobj_t *actor) // Don't spawn dust unless a player is relatively close by (var1). for (i = 0; i < MAXPLAYERS; ++i) if (playeringame[i] && players[i].mo - && P_AproxDistance(actor->x - players[i].mo->x, actor->y - players[i].mo->y) < (1600<x - players[i].mo->x, actor->y - players[i].mo->y) < (1600<tracer && - P_AproxDistance(P_AproxDistance(actor->x - mo2->x, actor->y - mo2->y), actor->z - mo2->z) > - P_AproxDistance(P_AproxDistance(actor->x - actor->tracer->x, actor->y - actor->tracer->y), actor->z - actor->tracer->z)) + FixedHypot(FixedHypot(actor->x - mo2->x, actor->y - mo2->y), actor->z - mo2->z) > + FixedHypot(FixedHypot(actor->x - actor->tracer->x, actor->y - actor->tracer->y), actor->z - actor->tracer->z)) continue; // Otherwise... Do! @@ -13047,7 +13047,7 @@ void A_Boss5CheckOnGround(mobj_t *actor) P_SetMobjState(actor, locvar1); } - if (actor->tracer && P_AproxDistance(actor->tracer->x - actor->x, actor->tracer->y - actor->y) < 2*actor->radius) + if (actor->tracer && FixedHypot(actor->tracer->x - actor->x, actor->tracer->y - actor->y) < 2*actor->radius) { actor->momx = (4*actor->momx)/5; actor->momy = (4*actor->momy)/5; @@ -13507,7 +13507,7 @@ static boolean PIT_TNTExplode(mobj_t *nearby) dx = nearby->x - barrel->x; dy = nearby->y - barrel->y; dz = nearby->z - barrel->z + (nearby->height - barrel->height/2)/2; - dm = P_AproxDistance(P_AproxDistance(dx, dy), dz); + dm = FixedHypot(FixedHypot(dx, dy), dz); if (dm >= exploderadius || !P_CheckSight(barrel, nearby)) // out of range or not visible return true; @@ -13910,7 +13910,7 @@ void A_SnapperThinker(mobj_t *actor) // Look for nearby, valid players to chase angrily at. if ((actor->target || P_LookForPlayers(actor, true, false, 1024*FRACUNIT)) - && P_AproxDistance(actor->target->x - xs, actor->target->y - ys) < 2048*FRACUNIT + && FixedHypot(actor->target->x - xs, actor->target->y - ys) < 2048*FRACUNIT && abs(actor->target->z - actor->z) < 80*FRACUNIT && P_CheckSight(actor, actor->target)) { @@ -13925,7 +13925,7 @@ void A_SnapperThinker(mobj_t *actor) y1 = ys; } - dist = P_AproxDistance(x1 - x0, y1 - y0); + dist = FixedHypot(x1 - x0, y1 - y0); // The snapper either chases what it considers to be a nearby player, or instead decides to go back to its spawnpoint. if (chasing || dist > 32*FRACUNIT) @@ -14110,7 +14110,7 @@ void A_LavafallRocks(mobj_t *actor) // Don't spawn rocks unless a player is relatively close by. for (i = 0; i < MAXPLAYERS; ++i) if (playeringame[i] && players[i].mo - && P_AproxDistance(actor->x - players[i].mo->x, actor->y - players[i].mo->y) < (actor->info->speed >> 1)) + && FixedHypot(actor->x - players[i].mo->x, actor->y - players[i].mo->y) < (actor->info->speed >> 1)) break; // Stop looking. if (i < MAXPLAYERS) @@ -14144,7 +14144,7 @@ void A_LavafallLava(mobj_t *actor) // Don't spawn lava unless a player is nearby. for (i = 0; i < MAXPLAYERS; ++i) if (playeringame[i] && players[i].mo - && P_AproxDistance(actor->x - players[i].mo->x, actor->y - players[i].mo->y) < (actor->info->speed)) + && FixedHypot(actor->x - players[i].mo->x, actor->y - players[i].mo->y) < (actor->info->speed)) break; // Stop looking. if (i >= MAXPLAYERS) @@ -14274,7 +14274,7 @@ void A_RolloutSpawn(mobj_t *actor) if (!(actor->target) || P_MobjWasRemoved(actor->target) - || P_AproxDistance(actor->x - actor->target->x, actor->y - actor->target->y) > locvar1) + || FixedHypot(actor->x - actor->target->x, actor->y - actor->target->y) > locvar1) { actor->target = P_SpawnMobj(actor->x, actor->y, actor->z, locvar2); actor->target->flags2 |= (actor->flags2 & (MF2_AMBUSH | MF2_OBJECTFLIP)) | MF2_SLIDEPUSH; @@ -14302,7 +14302,7 @@ void A_RolloutRock(mobj_t *actor) UINT8 maxframes = actor->info->reactiontime; // number of frames the mobj cycles through fixed_t pi = (22*FRACUNIT/7); fixed_t circumference = FixedMul(2 * pi, actor->radius); // used to calculate when to change frame - fixed_t speed = P_AproxDistance(actor->momx, actor->momy), topspeed = FixedMul(actor->info->speed, actor->scale); + fixed_t speed = FixedHypot(actor->momx, actor->momy), topspeed = FixedMul(actor->info->speed, actor->scale); boolean inwater = actor->eflags & (MFE_TOUCHWATER|MFE_UNDERWATER); if (LUA_CallAction(A_ROLLOUTROCK, actor)) @@ -14344,7 +14344,7 @@ void A_RolloutRock(mobj_t *actor) actor->momy = FixedMul(actor->momy, locvar1); } - speed = P_AproxDistance(actor->momx, actor->momy); // recalculate speed for visual rolling + speed = FixedHypot(actor->momx, actor->momy); // recalculate speed for visual rolling if (speed < actor->scale >> 1) // stop moving if speed is insignificant { @@ -14466,7 +14466,7 @@ void A_DragonSegment(mobj_t *actor) return; } - dist = P_AproxDistance(P_AproxDistance(actor->x - target->x, actor->y - target->y), actor->z - target->z); + dist = FixedHypot(FixedHypot(actor->x - target->x, actor->y - target->y), actor->z - target->z); radius = actor->radius + target->radius; hangle = R_PointToAngle2(target->x, target->y, actor->x, actor->y); zangle = R_PointToAngle2(0, target->z, dist, actor->z); diff --git a/src/p_floor.c b/src/p_floor.c index 7c26065b5..de8f5d4e8 100644 --- a/src/p_floor.c +++ b/src/p_floor.c @@ -1164,7 +1164,7 @@ void T_ThwompSector(thwomp_t *thwomp) if (players[i].mo->z > thwomp->sector->ceilingheight) continue; - if (P_AproxDistance(thwompx - players[i].mo->x, thwompy - players[i].mo->y) > 96*FRACUNIT) + if (FixedHypot(thwompx - players[i].mo->x, thwompy - players[i].mo->y) > 96*FRACUNIT) continue; thwomp->direction = -1; @@ -1892,7 +1892,7 @@ void EV_DoFloor(line_t *line, floor_e floortype) // Linedef executor command, linetype 106. // Line length = speed, front sector floor = destination height. case moveFloorByFrontSector: - dofloor->speed = P_AproxDistance(line->dx, line->dy); + dofloor->speed = FixedHypot(line->dx, line->dy); dofloor->speed = FixedDiv(dofloor->speed,8*FRACUNIT); dofloor->floordestheight = line->frontsector->floorheight; @@ -1958,7 +1958,7 @@ void EV_DoFloor(line_t *line, floor_e floortype) // Linetypes 2/3. // Move floor up and down indefinitely like the old elevators. case bounceFloor: - dofloor->speed = P_AproxDistance(line->dx, line->dy); // same speed as elevateContinuous + dofloor->speed = FixedHypot(line->dx, line->dy); // same speed as elevateContinuous dofloor->speed = FixedDiv(dofloor->speed,4*FRACUNIT); dofloor->origspeed = dofloor->speed; // it gets slowed down at the top and bottom dofloor->floordestheight = line->frontsector->floorheight; @@ -2104,7 +2104,7 @@ void EV_DoElevator(line_t *line, elevator_e elevtype, boolean customspeed) case elevateContinuous: if (customspeed) { - elevator->origspeed = P_AproxDistance(line->dx, line->dy); + elevator->origspeed = FixedHypot(line->dx, line->dy); elevator->origspeed = FixedDiv(elevator->origspeed,4*FRACUNIT); elevator->speed = elevator->origspeed; } @@ -2266,7 +2266,7 @@ void EV_CrumbleChain(sector_t *sec, ffloor_t *rover) if (flags & ML_EFFECT1) { - P_InstaThrust(spawned, R_PointToAngle2(sec->soundorg.x, sec->soundorg.y, a, b), FixedDiv(P_AproxDistance(a - sec->soundorg.x, b - sec->soundorg.y), widthfactor)); + P_InstaThrust(spawned, R_PointToAngle2(sec->soundorg.x, sec->soundorg.y, a, b), FixedDiv(FixedHypot(a - sec->soundorg.x, b - sec->soundorg.y), widthfactor)); P_SetObjectMomZ(spawned, FixedDiv((c - bottomz), heightfactor), false); } diff --git a/src/p_inter.c b/src/p_inter.c index e9a16a3dd..be4133af5 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -1002,7 +1002,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) x = (x/count)<x - x, special->y - y), special->z - z); + gatherradius = FixedHypot(FixedHypot(special->x - x, special->y - y), special->z - z); P_RemoveMobj(special); if (player->powers[pw_nights_superloop]) @@ -1028,7 +1028,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) mo2 = (mobj_t *)th; - if (P_AproxDistance(P_AproxDistance(mo2->x - x, mo2->y - y), mo2->z - z) > gatherradius) + if (FixedHypot(FixedHypot(mo2->x - x, mo2->y - y), mo2->z - z) > gatherradius) continue; if (mo2->flags & MF_SHOOTABLE) @@ -1450,8 +1450,8 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) fixed_t touchx, touchy, touchspeed; angle_t angle; - if (P_AproxDistance(toucher->x-special->x, toucher->y-special->y) > - P_AproxDistance((toucher->x-toucher->momx)-special->x, (toucher->y-toucher->momy)-special->y)) + if (FixedHypot(toucher->x-special->x, toucher->y-special->y) > + FixedHypot((toucher->x-toucher->momx)-special->x, (toucher->y-toucher->momy)-special->y)) { touchx = toucher->x + toucher->momx; touchy = toucher->y + toucher->momy; @@ -1463,7 +1463,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) } angle = R_PointToAngle2(special->x, special->y, touchx, touchy); - touchspeed = P_AproxDistance(toucher->momx, toucher->momy); + touchspeed = FixedHypot(toucher->momx, toucher->momy); toucher->momx = P_ReturnThrustX(special, angle, touchspeed); toucher->momy = P_ReturnThrustY(special, angle, touchspeed); @@ -1509,7 +1509,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) case MT_EGGSHIELD: { angle_t angle = R_PointToAngle2(special->x, special->y, toucher->x, toucher->y) - special->angle; - fixed_t touchspeed = P_AproxDistance(toucher->momx, toucher->momy); + fixed_t touchspeed = FixedHypot(toucher->momx, toucher->momy); if (touchspeed < special->scale) touchspeed = special->scale; @@ -1590,7 +1590,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) { special->momx = toucher->momx; special->momy = toucher->momy; - special->momz = P_AproxDistance(toucher->momx, toucher->momy)/4; + special->momz = FixedHypot(toucher->momx, toucher->momy)/4; if (toucher->momz > 0) special->momz += toucher->momz/8; @@ -1762,7 +1762,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) toucher->momx = toucher->tracer->momx/2; toucher->momy = toucher->tracer->momy/2; - toucher->momz = toucher->tracer->momz + P_AproxDistance(toucher->tracer->momx, toucher->tracer->momy)/2; + toucher->momz = toucher->tracer->momz + FixedHypot(toucher->tracer->momx, toucher->tracer->momy)/2; P_ResetPlayer(player); player->pflags &= ~PF_APPLYAUTOBRAKE; P_SetPlayerMobjState(toucher, S_PLAY_FALL); @@ -2666,7 +2666,7 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, UINT8 damaget case MT_BUGGLE: if (inflictor && inflictor->player // did a player kill you? Spawn relative to the player so they're bound to get it - && P_AproxDistance(inflictor->x - target->x, inflictor->y - target->y) <= inflictor->radius + target->radius + FixedMul(8*FRACUNIT, inflictor->scale) // close enough? + && FixedHypot(inflictor->x - target->x, inflictor->y - target->y) <= inflictor->radius + target->radius + FixedMul(8*FRACUNIT, inflictor->scale) // close enough? && inflictor->z <= target->z + target->height + FixedMul(8*FRACUNIT, inflictor->scale) && inflictor->z + inflictor->height >= target->z - FixedMul(8*FRACUNIT, inflictor->scale)) mo = P_SpawnMobj(inflictor->x + inflictor->momx, inflictor->y + inflictor->momy, inflictor->z + (inflictor->height / 2) + inflictor->momz, MT_EXTRALARGEBUBBLE); @@ -3305,7 +3305,7 @@ static void P_SuperDamage(player_t *player, mobj_t *inflictor, mobj_t *source, I // to recover if (inflictor->flags2 & MF2_SCATTER && source) { - fixed_t dist = P_AproxDistance(P_AproxDistance(source->x-player->mo->x, source->y-player->mo->y), source->z-player->mo->z); + fixed_t dist = FixedHypot(FixedHypot(source->x-player->mo->x, source->y-player->mo->y), source->z-player->mo->z); dist = FixedMul(128*FRACUNIT, inflictor->scale) - dist/4; diff --git a/src/p_map.c b/src/p_map.c index b934e3255..63fdebbbd 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -776,7 +776,7 @@ static boolean PIT_CheckThing(mobj_t *thing) if (thing->flags & MF_SOLID) S_StartSound(tmthing, thing->info->deathsound); for (iter = thing->subsector->sector->thinglist; iter; iter = iter->snext) - if (iter->type == thing->type && iter->health > 0 && iter->flags & MF_SOLID && (iter == thing || P_AproxDistance(P_AproxDistance(thing->x - iter->x, thing->y - iter->y), thing->z - iter->z) < 56*thing->scale))//FixedMul(56*FRACUNIT, thing->scale)) + if (iter->type == thing->type && iter->health > 0 && iter->flags & MF_SOLID && (iter == thing || FixedHypot(FixedHypot(thing->x - iter->x, thing->y - iter->y), thing->z - iter->z) < 56*thing->scale))//FixedMul(56*FRACUNIT, thing->scale)) P_KillMobj(iter, tmthing, tmthing, 0); } else @@ -815,7 +815,7 @@ static boolean PIT_CheckThing(mobj_t *thing) if (thing->flags & MF_SOLID) S_StartSound(tmthing, thing->info->deathsound); for (iter = thing->subsector->sector->thinglist; iter; iter = iter->snext) - if (iter->type == thing->type && iter->health > 0 && iter->flags & MF_SOLID && (iter == thing || P_AproxDistance(P_AproxDistance(thing->x - iter->x, thing->y - iter->y), thing->z - iter->z) < 56*thing->scale))//FixedMul(56*FRACUNIT, thing->scale)) + if (iter->type == thing->type && iter->health > 0 && iter->flags & MF_SOLID && (iter == thing || FixedHypot(FixedHypot(thing->x - iter->x, thing->y - iter->y), thing->z - iter->z) < 56*thing->scale))//FixedMul(56*FRACUNIT, thing->scale)) P_KillMobj(iter, tmthing, tmthing, 0); return true; } @@ -3061,7 +3061,7 @@ static void P_HitCameraSlideLine(line_t *ld, camera_t *thiscam) lineangle >>= ANGLETOFINESHIFT; deltaangle >>= ANGLETOFINESHIFT; - movelen = P_AproxDistance(tmxmove, tmymove); + movelen = FixedHypot(tmxmove, tmymove); newlen = FixedMul(movelen, FINECOSINE(deltaangle)); tmxmove = FixedMul(newlen, FINECOSINE(lineangle)); @@ -3147,7 +3147,7 @@ static void P_HitBounceLine(line_t *ld) lineangle >>= ANGLETOFINESHIFT; deltaangle >>= ANGLETOFINESHIFT; - movelen = P_AproxDistance(tmxmove, tmymove); + movelen = FixedHypot(tmxmove, tmymove); tmxmove = FixedMul(movelen, FINECOSINE(deltaangle)); tmymove = FixedMul(movelen, FINESINE(deltaangle)); @@ -4074,7 +4074,7 @@ static boolean PIT_RadiusAttack(mobj_t *thing) dy = abs(thing->y - bombspot->y); dz = abs(thing->z + (thing->height>>1) - bombspot->z); - dist = P_AproxDistance(P_AproxDistance(dx, dy), dz); + dist = FixedHypot(FixedHypot(dx, dy), dz); dist -= thing->radius; if (dist < 0) diff --git a/src/p_maputl.h b/src/p_maputl.h index df90ab4b4..9bc00fa17 100644 --- a/src/p_maputl.h +++ b/src/p_maputl.h @@ -41,7 +41,6 @@ typedef boolean (*traverser_t)(intercept_t *in); boolean P_PathTraverse(fixed_t px1, fixed_t py1, fixed_t px2, fixed_t py2, INT32 pflags, traverser_t ptrav); -#define P_AproxDistance(dx, dy) FixedHypot(dx, dy) void P_ClosestPointOnLine(fixed_t x, fixed_t y, line_t *line, vertex_t *result); void P_ClosestPointOnLine3D(const vector3_t *p, const vector3_t *line, vector3_t *result); INT32 P_PointOnLineSide(fixed_t x, fixed_t y, line_t *line); diff --git a/src/p_mobj.c b/src/p_mobj.c index a1edcfe77..c539db6d2 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -1736,7 +1736,7 @@ static void P_PushableCheckBustables(mobj_t *mo) // Run a linedef executor?? if (rover->master->flags & ML_EFFECT5) - P_LinedefExecute((INT16)(P_AproxDistance(rover->master->dx, rover->master->dy)>>FRACBITS), mo, node->m_sector); + P_LinedefExecute((INT16)(FixedHypot(rover->master->dx, rover->master->dy)>>FRACBITS), mo, node->m_sector); goto bustupdone; } @@ -2512,7 +2512,7 @@ boolean P_ZMovement(mobj_t *mo) // float down towards target if too close if (!(mo->flags2 & MF2_SKULLFLY) && !(mo->flags2 & MF2_INFLOAT)) { - dist = P_AproxDistance(mo->x - mo->target->x, mo->y - mo->target->y); + dist = FixedHypot(mo->x - mo->target->x, mo->y - mo->target->y); delta = (mo->target->z + (mo->height>>1)) - mo->z; @@ -3662,11 +3662,11 @@ boolean P_CameraThinker(player_t *player, camera_t *thiscam, boolean resetcalled P_ResetCamera(player, thiscam); else { - fixed_t camspeed = P_AproxDistance(thiscam->momx, thiscam->momy); + fixed_t camspeed = FixedHypot(thiscam->momx, thiscam->momy); P_SlideCameraMove(thiscam); - if (!resetcalled && P_AproxDistance(thiscam->momx, thiscam->momy) == camspeed) + if (!resetcalled && FixedHypot(thiscam->momx, thiscam->momy) == camspeed) { P_ResetCamera(player, thiscam); resetcalled = true; @@ -4149,7 +4149,7 @@ boolean P_BossTargetPlayer(mobj_t *actor, boolean closest) if (closest) { - dist = P_AproxDistance(actor->x - player->mo->x, actor->y - player->mo->y); + dist = FixedHypot(actor->x - player->mo->x, actor->y - player->mo->y); if (!lastdist || dist < lastdist) { lastdist = dist+1; @@ -4518,7 +4518,7 @@ static void P_Boss3Thinker(mobj_t *mobj) if (mobj->tracer->x == mobj->x && mobj->tracer->y == mobj->y) { // apply ambush for old routing, otherwise whack a mole only - dist = P_AproxDistance(P_AproxDistance(mobj->tracer->x - mobj->x, mobj->tracer->y - mobj->y), mobj->tracer->z + mobj->movefactor - mobj->z); + dist = FixedHypot(FixedHypot(mobj->tracer->x - mobj->x, mobj->tracer->y - mobj->y), mobj->tracer->z + mobj->movefactor - mobj->z); if (dist < 1) dist = 1; @@ -5042,7 +5042,7 @@ static void P_Boss5Thinker(mobj_t *mobj) } if (mobj->state == &states[mobj->info->xdeathstate]) mobj->momz -= (2*FRACUNIT)/3; - else if (mobj->tracer && P_AproxDistance(mobj->tracer->x - mobj->x, mobj->tracer->y - mobj->y) < 2*mobj->radius) + else if (mobj->tracer && FixedHypot(mobj->tracer->x - mobj->x, mobj->tracer->y - mobj->y) < 2*mobj->radius) mobj->flags &= ~MF_NOCLIP; } else @@ -5168,7 +5168,7 @@ static void P_Boss7Thinker(mobj_t *mobj) if (players[i].mo->health <= 0) continue; - if (P_AproxDistance(players[i].mo->x - mobj->x, players[i].mo->y - mobj->y) > (mobj->radius + players[i].mo->radius)) + if (FixedHypot(players[i].mo->x - mobj->x, players[i].mo->y - mobj->y) > (mobj->radius + players[i].mo->radius)) continue; if (players[i].mo->z > mobj->z + mobj->height - FRACUNIT @@ -5272,7 +5272,7 @@ static void P_Boss7Thinker(mobj_t *mobj) if (mobj->health <= mobj->info->damage && !(mo2->spawnpoint->options & 7)) continue; // don't jump to center - dist = P_AproxDistance(players[i].mo->x - mo2->x, players[i].mo->y - mo2->y); + dist = FixedHypot(players[i].mo->x - mo2->x, players[i].mo->y - mo2->y); if (!(closestNum == -1 || dist < closestdist)) continue; @@ -5345,7 +5345,7 @@ static void P_Boss7Thinker(mobj_t *mobj) an = mobj->angle; an >>= ANGLETOFINESHIFT; - dist = P_AproxDistance(hitspot->x - mobj->x, hitspot->y - mobj->y); + dist = FixedHypot(hitspot->x - mobj->x, hitspot->y - mobj->y); horizontal = dist / airtime; vertical = (gravity*airtime)/2; @@ -5396,7 +5396,7 @@ static void P_Boss7Thinker(mobj_t *mobj) if (players[i].mo->health <= 0) continue; - if (P_AproxDistance(players[i].mo->x - mobj->x, players[i].mo->y - mobj->y) > mobj->radius*4) + if (FixedHypot(players[i].mo->x - mobj->x, players[i].mo->y - mobj->y) > mobj->radius*4) continue; if (players[i].mo->z > mobj->z + 128*FRACUNIT) @@ -5650,14 +5650,14 @@ static void P_Boss9Thinker(mobj_t *mobj) // Spawn energy particles for (spawner = mobj->hnext; spawner; spawner = spawner->hnext) { - dist = P_AproxDistance(spawner->x - mobj->x, spawner->y - mobj->y); + dist = FixedHypot(spawner->x - mobj->x, spawner->y - mobj->y); if (P_RandomRange(1,(dist>>FRACBITS)/16) == 1) break; } if (spawner && dist) { mobj_t *missile = P_SpawnMissile(spawner, mobj, MT_MSGATHER); - missile->fuse = (dist/P_AproxDistance(missile->momx, missile->momy)); + missile->fuse = (dist/FixedHypot(missile->momx, missile->momy)); if (missile->fuse > mobj->fuse) P_RemoveMobj(missile); @@ -6089,7 +6089,7 @@ nodanger: mobj->flags2 |= MF2_INVERTAIMABLE; // Move normally: Approach the player using normal thrust and simulated friction. - dist = P_AproxDistance(mobj->x-mobj->target->x, mobj->y-mobj->target->y); + dist = FixedHypot(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 && !(mobj->target->player && mobj->target->player->homing)) P_Thrust(mobj, mobj->angle, -4*FRACUNIT); @@ -6097,7 +6097,7 @@ nodanger: P_Thrust(mobj, mobj->angle, FRACUNIT); else P_Thrust(mobj, mobj->angle + ANGLE_90, FINECOSINE((((angle_t)(leveltime*ANG1))>>ANGLETOFINESHIFT) & FINEMASK)>>1); - mobj->momz += P_AproxDistance(mobj->momx, mobj->momy)/12; // Move up higher the faster you're going. + mobj->momz += FixedHypot(mobj->momx, mobj->momy)/12; // Move up higher the faster you're going. } } } @@ -6303,7 +6303,7 @@ void P_SpawnParaloop(fixed_t x, fixed_t y, fixed_t z, fixed_t radius, INT32 numb mobj->angle = R_PointToAngle2(mobj->x, mobj->y, x, y); // change slope - dist = P_AproxDistance(P_AproxDistance(x - mobj->x, y - mobj->y), z - mobj->z); + dist = FixedHypot(FixedHypot(x - mobj->x, y - mobj->y), z - mobj->z); if (dist < 1) dist = 1; @@ -6377,7 +6377,7 @@ void P_Attract(mobj_t *source, mobj_t *dest, boolean nightsgrab) // Home in on y fixed_t tx = dest->x; fixed_t ty = dest->y; fixed_t tz = dest->z + (dest->height/2); // Aim for center - fixed_t xydist = P_AproxDistance(tx - source->x, ty - source->y); + fixed_t xydist = FixedHypot(tx - source->x, ty - source->y); if (!dest || dest->health <= 0 || !dest->player || !source->tracer) return; @@ -6386,7 +6386,7 @@ void P_Attract(mobj_t *source, mobj_t *dest, boolean nightsgrab) // Home in on y source->angle = R_PointToAngle2(source->x, source->y, tx, ty); // change slope - dist = P_AproxDistance(xydist, tz - source->z); + dist = FixedHypot(xydist, tz - source->z); if (dist < 1) dist = 1; @@ -6412,9 +6412,9 @@ void P_Attract(mobj_t *source, mobj_t *dest, boolean nightsgrab) // Home in on y else { if (nightsgrab) - speedmul = P_AproxDistance(dest->momx, dest->momy) + FixedMul(8*FRACUNIT, source->scale); + speedmul = FixedHypot(dest->momx, dest->momy) + FixedMul(8*FRACUNIT, source->scale); else - speedmul = P_AproxDistance(dest->momx, dest->momy) + FixedMul(source->info->speed, source->scale); + speedmul = FixedHypot(dest->momx, dest->momy) + FixedMul(source->info->speed, source->scale); source->momx = FixedMul(FixedDiv(tx - source->x, dist), speedmul); source->momy = FixedMul(FixedDiv(ty - source->y, dist), speedmul); @@ -6422,7 +6422,7 @@ void P_Attract(mobj_t *source, mobj_t *dest, boolean nightsgrab) // Home in on y } // Instead of just unsetting NOCLIP like an idiot, let's check the distance to our target. - ndist = P_AproxDistance(P_AproxDistance(tx - (source->x+source->momx), + ndist = FixedHypot(FixedHypot(tx - (source->x+source->momx), ty - (source->y+source->momy)), tz - (source->z+source->momz)); @@ -7073,7 +7073,7 @@ static void P_MaceSceneryThink(mobj_t *mobj) // The below is selected based on CEZ2's first room. I promise you it is a coincidence that it looks like the weed number. for (i = 0; i < MAXPLAYERS; ++i) if (playeringame[i] && players[i].mo - && P_AproxDistance(P_AproxDistance(mobj->x - players[i].mo->x, mobj->y - players[i].mo->y), mobj->z - players[i].mo->z) < (4200 << FRACBITS)) + && FixedHypot(FixedHypot(mobj->x - players[i].mo->x, mobj->y - players[i].mo->y), mobj->z - players[i].mo->z) < (4200 << FRACBITS)) break; // Stop looking. if (i == MAXPLAYERS) { @@ -8049,7 +8049,7 @@ static boolean P_MobjBossThink(mobj_t *mobj) { if (mobj->target) { - mobj->momz = FixedMul(FixedDiv(mobj->target->z - mobj->z, P_AproxDistance(mobj->x - mobj->target->x, mobj->y - mobj->target->y)), mobj->scale << 1); + mobj->momz = FixedMul(FixedDiv(mobj->target->z - mobj->z, FixedHypot(mobj->x - mobj->target->x, mobj->y - mobj->target->y)), mobj->scale << 1); mobj->angle = R_PointToAngle2(mobj->x, mobj->y, mobj->target->x, mobj->target->y); } else @@ -8293,7 +8293,7 @@ static void P_ArrowThink(mobj_t *mobj) 0------dist(momx,momy) */ - fixed_t dist = P_AproxDistance(mobj->momx, mobj->momy); + fixed_t dist = FixedHypot(mobj->momx, mobj->momy); angle_t angle = R_PointToAngle2(0, 0, dist, mobj->momz); if (angle > ANG20 && angle <= ANGLE_180) @@ -8575,7 +8575,7 @@ static boolean P_EggRobo1Think(mobj_t *mobj) continue; if (players[i].mo->z + players[i].mo->height < mobj->z - 8*mobj->scale) continue; - compdist = P_AproxDistance( + compdist = FixedHypot( players[i].mo->x + players[i].mo->momx - basex, players[i].mo->y + players[i].mo->momy - basey); if (compdist >= dist) @@ -8590,7 +8590,7 @@ static boolean P_EggRobo1Think(mobj_t *mobj) mobj->frame = 3 + ((leveltime & 2) >> 1); mobj->angle = R_PointToAngle2(mobj->x, mobj->y, mobj->target->x, mobj->target->y); - if (P_AproxDistance( + if (FixedHypot( mobj->x - basex, mobj->y - basey) < mobj->scale) @@ -8621,7 +8621,7 @@ static boolean P_EggRobo1Think(mobj_t *mobj) if (!didmove) { - if (P_AproxDistance(mobj->x - basex, mobj->y - basey) < mobj->scale) + if (FixedHypot(mobj->x - basex, mobj->y - basey) < mobj->scale) P_TeleportMove(mobj, basex, basey, mobj->z); else P_TeleportMove(mobj, @@ -9011,7 +9011,7 @@ static void P_PyreFlyThink(mobj_t *mobj) { //Aim for player z position. If too close to floor/ceiling, aim just above/below them. fixed_t destz = min(max(mobj->target->z, mobj->target->floorz + 70*FRACUNIT), mobj->target->ceilingz - 80*FRACUNIT - mobj->height); - fixed_t dist = P_AproxDistance(hdist, destz - mobj->z); + fixed_t dist = FixedHypot(hdist, destz - mobj->z); P_InstaThrust(mobj, R_PointToAngle2(mobj->x, mobj->y, mobj->target->x, mobj->target->y), 2*FRACUNIT); mobj->momz = FixedMul(FixedDiv(destz - mobj->z, dist), 2*FRACUNIT); } @@ -9113,7 +9113,7 @@ static void P_PterabyteThink(mobj_t *mobj) var1 = 2*mobj->info->speed; var2 = 1; A_HomingChase(mobj); - if (P_AproxDistance(mobj->x - mobj->tracer->x, mobj->y - mobj->tracer->y) <= mobj->info->speed) + if (FixedHypot(mobj->x - mobj->tracer->x, mobj->y - mobj->tracer->y) <= mobj->info->speed) { mobj->extravalue1 -= 2; mobj->momx = mobj->momy = mobj->momz = 0; @@ -9138,7 +9138,7 @@ static void P_DragonbomberThink(mobj_t *mobj) { mobj_t *mine = P_SpawnMobjFromMobj(segment, 0, 0, 0, segment->info->painchance); mine->angle = segment->angle; - P_InstaThrust(mine, mobj->angle, P_AproxDistance(mobj->momx, mobj->momy) >> 1); + P_InstaThrust(mine, mobj->angle, FixedHypot(mobj->momx, mobj->momy) >> 1); P_SetObjectMomZ(mine, -2*FRACUNIT, true); S_StartSound(mine, mine->info->seesound); P_SetMobjState(segment, segment->info->raisestate); @@ -9148,7 +9148,7 @@ static void P_DragonbomberThink(mobj_t *mobj) } if (mobj->target) // Are we chasing a player? { - fixed_t dist = P_AproxDistance(mobj->x - mobj->target->x, mobj->y - mobj->target->y); + fixed_t dist = FixedHypot(mobj->x - mobj->target->x, mobj->y - mobj->target->y); if (dist > 2000*mobj->scale) // Not anymore! P_SetTarget(&mobj->target, NULL); else @@ -9256,7 +9256,7 @@ static boolean P_MobjRegularThink(mobj_t *mobj) mobj->eflags |= MFE_UNDERWATER; //P_MobjCheckWater(mobj); // solely for MFE_UNDERWATER for A_FlickySpawn { if (mobj->tracer && mobj->tracer->player && mobj->tracer->health > 0 - && P_AproxDistance(P_AproxDistance(mobj->tracer->x - mobj->x, mobj->tracer->y - mobj->y), mobj->tracer->z - mobj->z) <= mobj->radius*16) + && FixedHypot(FixedHypot(mobj->tracer->x - mobj->x, mobj->tracer->y - mobj->y), mobj->tracer->z - mobj->z) <= mobj->radius*16) { var1 = mobj->info->speed; var2 = 1; @@ -9391,7 +9391,7 @@ static boolean P_MobjRegularThink(mobj_t *mobj) if (playeringame[i] && players[i].mo && players[i].mare == mobj->threshold && players[i].spheres > 0) { - fixed_t dist = P_AproxDistance(players[i].mo->x - mobj->x, players[i].mo->y - mobj->y); + fixed_t dist = FixedHypot(players[i].mo->x - mobj->x, players[i].mo->y - mobj->y); if (dist < shortest) { P_SetTarget(&mobj->target, players[i].mo); @@ -9422,7 +9422,7 @@ static boolean P_MobjRegularThink(mobj_t *mobj) P_KoopaThinker(mobj); break; case MT_FIREBALL: - if (P_AproxDistance(mobj->momx, mobj->momy) <= 16*FRACUNIT) // Once fireballs lose enough speed, kill them + if (FixedHypot(mobj->momx, mobj->momy) <= 16*FRACUNIT) // Once fireballs lose enough speed, kill them { P_KillMobj(mobj, NULL, NULL, 0); return false; @@ -13530,7 +13530,7 @@ mobj_t *P_SpawnXYZMissile(mobj_t *source, mobj_t *dest, mobjtype_t type, th->momx = FixedMul(speed, FINECOSINE(an)); th->momy = FixedMul(speed, FINESINE(an)); - dist = P_AproxDistance(dest->x - x, dest->y - y); + dist = FixedHypot(dest->x - x, dest->y - y); dist = dist / speed; if (dist < 1) @@ -13592,7 +13592,7 @@ mobj_t *P_SpawnAlteredDirectionMissile(mobj_t *source, mobjtype_t type, fixed_t th->momx = FixedMul(speed, FINECOSINE(an)); th->momy = FixedMul(speed, FINESINE(an)); - dist = P_AproxDistance(source->momx*800, source->momy*800); + dist = FixedHypot(source->momx*800, source->momy*800); dist = dist / speed; if (dist < 1) @@ -13657,7 +13657,7 @@ mobj_t *P_SpawnPointMissile(mobj_t *source, fixed_t xa, fixed_t ya, fixed_t za, th->momx = FixedMul(speed, FINECOSINE(an)); th->momy = FixedMul(speed, FINESINE(an)); - dist = P_AproxDistance(xa - x, ya - y); + dist = FixedHypot(xa - x, ya - y); dist = dist / speed; if (dist < 1) @@ -13737,9 +13737,9 @@ mobj_t *P_SpawnMissile(mobj_t *source, mobj_t *dest, mobjtype_t type) th->momy = FixedMul(speed, FINESINE(an)); if (type == MT_TURRETLASER || type == MT_ENERGYBALL) // More accurate! - dist = P_AproxDistance(dest->x+(dest->momx*gsf) - source->x, dest->y+(dest->momy*gsf) - source->y); + dist = FixedHypot(dest->x+(dest->momx*gsf) - source->x, dest->y+(dest->momy*gsf) - source->y); else - dist = P_AproxDistance(dest->x - source->x, dest->y - source->y); + dist = FixedHypot(dest->x - source->x, dest->y - source->y); dist = dist / speed; diff --git a/src/p_polyobj.c b/src/p_polyobj.c index 874edbd50..95734ff86 100644 --- a/src/p_polyobj.c +++ b/src/p_polyobj.c @@ -1636,7 +1636,7 @@ void T_PolyObjWaypoint(polywaypoint_t *th) distx = target->x - pox; disty = target->y - poy; distz = target->z - poz; - dist = P_AproxDistance(P_AproxDistance(distx, disty), distz); + dist = FixedHypot(FixedHypot(distx, disty), distz); if (dist < 1) dist = 1; diff --git a/src/p_setup.c b/src/p_setup.c index 41d8822e2..2ee588fbb 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -232,7 +232,7 @@ mobj_t *P_GetClosestWaypoint(UINT8 sequence, mobj_t *mo) if (!mo2) continue; - curdist = P_AproxDistance(P_AproxDistance(mo->x - mo2->x, mo->y - mo2->y), mo->z - mo2->z); + curdist = FixedHypot(FixedHypot(mo->x - mo2->x, mo->y - mo2->y), mo->z - mo2->z); if (result && curdist > bestdist) continue; diff --git a/src/p_slopes.c b/src/p_slopes.c index aa46a8402..d77d0805f 100644 --- a/src/p_slopes.c +++ b/src/p_slopes.c @@ -885,7 +885,7 @@ void P_ButteredSlope(mobj_t *mo) } if (mo->momx || mo->momy) // Slightly increase thrust based on the object's speed - thrust = FixedMul(thrust, FRACUNIT+P_AproxDistance(mo->momx, mo->momy)/16); + thrust = FixedMul(thrust, FRACUNIT+FixedHypot(mo->momx, mo->momy)/16); // This makes it harder to zigzag up steep slopes, as well as allows greater top speed when rolling down // Let's get the gravity strength for the object... diff --git a/src/p_spec.c b/src/p_spec.c index 5b9e05c61..e696ad5d1 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -1240,7 +1240,7 @@ static boolean PolyFlag(line_t *line) polyflagdata_t pfd; pfd.polyObjNum = Tag_FGet(&line->tags); - pfd.speed = P_AproxDistance(line->dx, line->dy) >> FRACBITS; + pfd.speed = FixedHypot(line->dx, line->dy) >> FRACBITS; pfd.angle = R_PointToAngle2(line->v1->x, line->v1->y, line->v2->x, line->v2->y) >> ANGLETOFINESHIFT; pfd.momx = sides[line->sidenum[0]].textureoffset >> FRACBITS; @@ -1567,7 +1567,7 @@ static boolean P_CheckNightsTriggerLine(line_t *triggerline, mobj_t *actor) 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; + fixed_t dist = FixedHypot(triggerline->dx, triggerline->dy)>>FRACBITS; size_t i, linecnt, sectori; INT16 specialtype = triggerline->special; @@ -2629,7 +2629,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) sectors[secnum].lightlevel = line->backsector->lightlevel; flick = P_SpawnAdjustableFireFlicker(line->frontsector, §ors[secnum], - P_AproxDistance(line->dx, line->dy)>>FRACBITS); + FixedHypot(line->dx, line->dy)>>FRACBITS); // Make sure the starting light level is in range. if (reallightlevel < flick->minlight) @@ -2644,7 +2644,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) // Use front sector for min, target sector for max, // the same way linetype 61 does it. P_SpawnAdjustableFireFlicker(line->frontsector, §ors[secnum], - P_AproxDistance(line->dx, line->dy)>>FRACBITS); + FixedHypot(line->dx, line->dy)>>FRACBITS); } } break; @@ -2663,7 +2663,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) sectors[secnum].lightlevel = line->backsector->lightlevel; glow = P_SpawnAdjustableGlowingLight(line->frontsector, §ors[secnum], - P_AproxDistance(line->dx, line->dy)>>FRACBITS); + FixedHypot(line->dx, line->dy)>>FRACBITS); // Make sure the starting light level is in range. if (reallightlevel < glow->minlight) @@ -2678,7 +2678,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) // Use front sector for min, target sector for max, // the same way linetype 602 does it. P_SpawnAdjustableGlowingLight(line->frontsector, §ors[secnum], - P_AproxDistance(line->dx, line->dy)>>FRACBITS); + FixedHypot(line->dx, line->dy)>>FRACBITS); } } break; @@ -2760,7 +2760,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) ((line->sidenum[1] != 0xFFFF && !(sides[line->sidenum[0]].rowoffset>>FRACBITS)) ? max(min(sides[line->sidenum[1]].rowoffset>>FRACBITS, 255), 0) : max(min(sides[line->sidenum[0]].rowoffset>>FRACBITS, 255), 0)) - : abs(P_AproxDistance(line->dx, line->dy))>>FRACBITS, + : abs(FixedHypot(line->dx, line->dy))>>FRACBITS, (line->flags & ML_EFFECT4), (line->flags & ML_EFFECT5)); break; @@ -2795,7 +2795,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) else { P_SetTarget(&mo->player->awayviewmobj, altview); - mo->player->awayviewtics = P_AproxDistance(line->dx, line->dy)>>FRACBITS; + mo->player->awayviewtics = FixedHypot(line->dx, line->dy)>>FRACBITS; } @@ -2840,7 +2840,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) case 425: // Calls P_SetMobjState on calling mobj if (mo && !mo->player) - P_SetMobjState(mo, sides[line->sidenum[0]].toptexture); //P_AproxDistance(line->dx, line->dy)>>FRACBITS); + P_SetMobjState(mo, sides[line->sidenum[0]].toptexture); //FixedHypot(line->dx, line->dy)>>FRACBITS); break; case 426: // Moves the mobj to its sector's soundorg and on the floor, and stops it @@ -3026,7 +3026,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) case 438: // Set player scale if (mo) { - mo->destscale = FixedDiv(P_AproxDistance(line->dx, line->dy), 100<destscale = FixedDiv(FixedHypot(line->dx, line->dy), 100<destscale < FRACUNIT/100) mo->destscale = FRACUNIT/100; if (mo->player && bot) @@ -3144,7 +3144,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) { quake.intensity = sides[line->sidenum[0]].textureoffset; quake.radius = sides[line->sidenum[0]].rowoffset; - quake.time = P_AproxDistance(line->dx, line->dy)>>FRACBITS; + quake.time = FixedHypot(line->dx, line->dy)>>FRACBITS; quake.epicenter = NULL; /// \todo @@ -3407,7 +3407,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) case 452: // Set FOF alpha { INT16 destvalue = line->sidenum[1] != 0xffff ? - (INT16)(sides[line->sidenum[1]].textureoffset>>FRACBITS) : (INT16)(P_AproxDistance(line->dx, line->dy)>>FRACBITS); + (INT16)(sides[line->sidenum[1]].textureoffset>>FRACBITS) : (INT16)(FixedHypot(line->dx, line->dy)>>FRACBITS); INT16 sectag = (INT16)(sides[line->sidenum[0]].textureoffset>>FRACBITS); INT16 foftag = (INT16)(sides[line->sidenum[0]].rowoffset>>FRACBITS); sector_t *sec; // Sector that the FOF is visible in @@ -4995,8 +4995,8 @@ DoneSection2: } else { - if (P_AproxDistance(P_AproxDistance(player->mo->x-resultlow.x, player->mo->y-resultlow.y), - player->mo->z-resultlow.z) < P_AproxDistance(P_AproxDistance(player->mo->x-resulthigh.x, + if (FixedHypot(FixedHypot(player->mo->x-resultlow.x, player->mo->y-resultlow.y), + player->mo->z-resultlow.z) < FixedHypot(FixedHypot(player->mo->x-resulthigh.x, player->mo->y-resulthigh.y), player->mo->z-resulthigh.z)) { // Line between Mid and Low is closer @@ -6314,7 +6314,7 @@ void P_SpawnSpecials(boolean fromnetsave) break; case 52: // Continuously Falling sector - EV_DoContinuousFall(lines[i].frontsector, lines[i].backsector, P_AproxDistance(lines[i].dx, lines[i].dy), (lines[i].flags & ML_NOCLIMB)); + EV_DoContinuousFall(lines[i].frontsector, lines[i].backsector, FixedHypot(lines[i].dx, lines[i].dy), (lines[i].flags & ML_NOCLIMB)); break; case 53: // New super cool and awesome moving floor and ceiling type @@ -6386,15 +6386,15 @@ void P_SpawnSpecials(boolean fromnetsave) case 66: // Displace floor by front sector TAG_ITER_SECTORS(0, tag, s) - P_AddPlaneDisplaceThinker(pd_floor, P_AproxDistance(lines[i].dx, lines[i].dy)>>8, sides[lines[i].sidenum[0]].sector-sectors, s, !!(lines[i].flags & ML_NOCLIMB)); + P_AddPlaneDisplaceThinker(pd_floor, FixedHypot(lines[i].dx, lines[i].dy)>>8, sides[lines[i].sidenum[0]].sector-sectors, s, !!(lines[i].flags & ML_NOCLIMB)); break; case 67: // Displace ceiling by front sector TAG_ITER_SECTORS(0, tag, s) - P_AddPlaneDisplaceThinker(pd_ceiling, P_AproxDistance(lines[i].dx, lines[i].dy)>>8, sides[lines[i].sidenum[0]].sector-sectors, s, !!(lines[i].flags & ML_NOCLIMB)); + P_AddPlaneDisplaceThinker(pd_ceiling, FixedHypot(lines[i].dx, lines[i].dy)>>8, sides[lines[i].sidenum[0]].sector-sectors, s, !!(lines[i].flags & ML_NOCLIMB)); break; case 68: // Displace both floor AND ceiling by front sector TAG_ITER_SECTORS(0, tag, s) - P_AddPlaneDisplaceThinker(pd_both, P_AproxDistance(lines[i].dx, lines[i].dy)>>8, sides[lines[i].sidenum[0]].sector-sectors, s, !!(lines[i].flags & ML_NOCLIMB)); + P_AddPlaneDisplaceThinker(pd_both, FixedHypot(lines[i].dx, lines[i].dy)>>8, sides[lines[i].sidenum[0]].sector-sectors, s, !!(lines[i].flags & ML_NOCLIMB)); break; case 100: // FOF (solid, opaque, shadows) @@ -6588,18 +6588,18 @@ void P_SpawnSpecials(boolean fromnetsave) case 150: // Air bobbing platform case 151: // Adjustable air bobbing platform { - fixed_t dist = (lines[i].special == 150) ? 16*FRACUNIT : P_AproxDistance(lines[i].dx, lines[i].dy); + fixed_t dist = (lines[i].special == 150) ? 16*FRACUNIT : FixedHypot(lines[i].dx, lines[i].dy); P_AddFakeFloorsByLine(i, FF_EXISTS|FF_SOLID|FF_RENDERALL|FF_CUTLEVEL, secthinkers); P_AddAirbob(lines[i].frontsector, tag, dist, false, !!(lines[i].flags & ML_NOCLIMB), false); break; } case 152: // Adjustable air bobbing platform in reverse P_AddFakeFloorsByLine(i, FF_EXISTS|FF_SOLID|FF_RENDERALL|FF_CUTLEVEL, secthinkers); - P_AddAirbob(lines[i].frontsector, tag, P_AproxDistance(lines[i].dx, lines[i].dy), true, !!(lines[i].flags & ML_NOCLIMB), false); + P_AddAirbob(lines[i].frontsector, tag, FixedHypot(lines[i].dx, lines[i].dy), true, !!(lines[i].flags & ML_NOCLIMB), false); break; case 153: // Dynamic Sinking Platform P_AddFakeFloorsByLine(i, FF_EXISTS|FF_SOLID|FF_RENDERALL|FF_CUTLEVEL, secthinkers); - P_AddAirbob(lines[i].frontsector, tag, P_AproxDistance(lines[i].dx, lines[i].dy), false, !!(lines[i].flags & ML_NOCLIMB), true); + P_AddAirbob(lines[i].frontsector, tag, FixedHypot(lines[i].dx, lines[i].dy), false, !!(lines[i].flags & ML_NOCLIMB), true); break; case 160: // Float/bob platform @@ -6678,7 +6678,7 @@ void P_SpawnSpecials(boolean fromnetsave) case 194: // Rising Platform 'Platform' - You can jump up through it case 195: // Rising Platform Translucent "platform" { - fixed_t speed = FixedDiv(P_AproxDistance(lines[i].dx, lines[i].dy), 4*FRACUNIT); + fixed_t speed = FixedDiv(FixedHypot(lines[i].dx, lines[i].dy), 4*FRACUNIT); fixed_t ceilingtop = P_FindHighestCeilingSurrounding(lines[i].frontsector); fixed_t ceilingbottom = P_FindLowestCeilingSurrounding(lines[i].frontsector); @@ -7003,14 +7003,14 @@ void P_SpawnSpecials(boolean fromnetsave) sec = sides[*lines[i].sidenum].sector - sectors; TAG_ITER_SECTORS(0, tag, s) P_SpawnAdjustableGlowingLight(§ors[sec], §ors[s], - P_AproxDistance(lines[i].dx, lines[i].dy)>>FRACBITS); + FixedHypot(lines[i].dx, lines[i].dy)>>FRACBITS); break; case 603: // Adjustable flickering light sec = sides[*lines[i].sidenum].sector - sectors; TAG_ITER_SECTORS(0, tag, s) P_SpawnAdjustableFireFlicker(§ors[sec], §ors[s], - P_AproxDistance(lines[i].dx, lines[i].dy)>>FRACBITS); + FixedHypot(lines[i].dx, lines[i].dy)>>FRACBITS); break; case 604: // Adjustable Blinking Light (unsynchronized) @@ -8416,9 +8416,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 = FixedHypot(p->x_mag,p->y_mag)<<(FRACBITS-PUSH_FACTOR); else - p->magnitude = P_AproxDistance(p->x_mag,p->y_mag); + p->magnitude = FixedHypot(p->x_mag,p->y_mag); if (source) // point source exist? { // where force goes to zero @@ -8469,14 +8469,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 = FixedHypot(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), + dist = FixedHypot(FixedHypot(thing->x - sx, thing->y - sy), thing->z - sz); } @@ -8811,7 +8811,7 @@ void T_Pusher(pusher_t *p) // Tumbleweeds bounce a bit... if (thing->type == MT_LITTLETUMBLEWEED || thing->type == MT_BIGTUMBLEWEED) - thing->momz += P_AproxDistance(xspeed<<(FRACBITS-PUSH_FACTOR), yspeed<<(FRACBITS-PUSH_FACTOR)) >> 2; + thing->momz += FixedHypot(xspeed<<(FRACBITS-PUSH_FACTOR), yspeed<<(FRACBITS-PUSH_FACTOR)) >> 2; } if (moved) diff --git a/src/p_user.c b/src/p_user.c index 2dcc21009..84fc3e521 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -1018,7 +1018,7 @@ void P_DoPlayerPain(player_t *player, mobj_t *source, mobj_t *inflictor) // to recover if ((inflictor->flags2 & MF2_SCATTER) && source) { - fixed_t dist = P_AproxDistance(P_AproxDistance(source->x-player->mo->x, source->y-player->mo->y), source->z-player->mo->z); + fixed_t dist = FixedHypot(FixedHypot(source->x-player->mo->x, source->y-player->mo->y), source->z-player->mo->z); dist = FixedMul(128*FRACUNIT, inflictor->scale) - dist/4; @@ -2701,7 +2701,7 @@ static void P_CheckBustableBlocks(player_t *player) // Run a linedef executor?? if (rover->master->flags & ML_EFFECT5) - P_LinedefExecute((INT16)(P_AproxDistance(rover->master->dx, rover->master->dy)>>FRACBITS), player->mo, node->m_sector); + P_LinedefExecute((INT16)(FixedHypot(rover->master->dx, rover->master->dy)>>FRACBITS), player->mo, node->m_sector); goto bustupdone; } @@ -2764,7 +2764,7 @@ static void P_CheckBouncySectors(player_t *player) if (player->mo->z + player->mo->height < bottomheight) continue; - bouncestrength = P_AproxDistance(rover->master->dx, rover->master->dy)/100; + bouncestrength = FixedHypot(rover->master->dx, rover->master->dy)/100; if (oldz < P_GetFOFTopZ(player->mo, node->m_sector, rover, oldx, oldy, NULL) && oldz + player->mo->height > P_GetFOFBottomZ(player->mo, node->m_sector, rover, oldx, oldy, NULL)) @@ -4981,7 +4981,7 @@ 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; - dist = P_AproxDistance(P_AproxDistance(player->mo->x-mo2->x, player->mo->y-mo2->y), player->mo->z-mo2->z); + dist = FixedHypot(FixedHypot(player->mo->x-mo2->x, player->mo->y-mo2->y), player->mo->z-mo2->z); if (range < dist) continue; @@ -6464,12 +6464,12 @@ static void P_NightsTransferPoints(player_t *player, fixed_t xspeed, fixed_t rad //CONS_Debug(DBG_NIGHTS, "T1 is at %d, %d\n", transfer1->x>>FRACBITS, transfer1->y>>FRACBITS); //CONS_Debug(DBG_NIGHTS, "T2 is at %d, %d\n", transfer2->x>>FRACBITS, transfer2->y>>FRACBITS); - //CONS_Debug(DBG_NIGHTS, "Distance from T1: %d\n", P_AproxDistance(transfer1->x - player->mo->x, transfer1->y - player->mo->y)>>FRACBITS); - //CONS_Debug(DBG_NIGHTS, "Distance from T2: %d\n", P_AproxDistance(transfer2->x - player->mo->x, transfer2->y - player->mo->y)>>FRACBITS); + //CONS_Debug(DBG_NIGHTS, "Distance from T1: %d\n", FixedHypot(transfer1->x - player->mo->x, transfer1->y - player->mo->y)>>FRACBITS); + //CONS_Debug(DBG_NIGHTS, "Distance from T2: %d\n", FixedHypot(transfer2->x - player->mo->x, transfer2->y - player->mo->y)>>FRACBITS); // Transfer1 is closer to the player than transfer2 - if (P_AproxDistance(transfer1->x - player->mo->x, transfer1->y - player->mo->y)>>FRACBITS - < P_AproxDistance(transfer2->x - player->mo->x, transfer2->y - player->mo->y)>>FRACBITS) + if (FixedHypot(transfer1->x - player->mo->x, transfer1->y - player->mo->y)>>FRACBITS + < FixedHypot(transfer2->x - player->mo->x, transfer2->y - player->mo->y)>>FRACBITS) { //CONS_Debug(DBG_NIGHTS, " must be < 0 to transfer\n"); @@ -7709,7 +7709,7 @@ void P_BlackOw(player_t *player) S_StartSound (player->mo, sfx_bkpoof); // Sound the BANG! for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i] && P_AproxDistance(player->mo->x - players[i].mo->x, + if (playeringame[i] && FixedHypot(player->mo->x - players[i].mo->x, player->mo->y - players[i].mo->y) < 1536*FRACUNIT) P_FlashPal(&players[i], PAL_NUKE, 10); @@ -7883,7 +7883,7 @@ static void P_SkidStuff(player_t *player) P_SpawnSkidDust(player, 0, false); } } - else if (P_AproxDistance(pmx, pmy) >= FixedMul(player->runspeed/2, player->mo->scale) // if you were moving faster than half your run speed last frame + else if (FixedHypot(pmx, pmy) >= FixedMul(player->runspeed/2, player->mo->scale) // if you were moving faster than half your run speed last frame && (player->mo->momx != pmx || player->mo->momy != pmy) // and you are moving differently this frame && P_GetPlayerControlDirection(player) == 2) // and your controls are pointing in the opposite direction to your movement { // check for skidding @@ -8514,7 +8514,7 @@ void P_MovePlayer(player_t *player) P_ResetScore(player); // Show the "THOK!" graphic when spinning quickly across the ground. (even applies to non-spinners, in the case of zoom tubes) - if (player->pflags & PF_SPINNING && P_AproxDistance(player->speed, player->mo->momz) > FixedMul(15<mo->scale) && !(player->pflags & PF_JUMPED)) + if (player->pflags & PF_SPINNING && FixedHypot(player->speed, player->mo->momz) > FixedMul(15<mo->scale) && !(player->pflags & PF_JUMPED)) { P_SpawnSpinMobj(player, player->spinitem); G_GhostAddSpin(); @@ -8735,7 +8735,7 @@ static void P_DoZoomTube(player_t *player) speed = abs(player->speed); // change slope - dist = P_AproxDistance(P_AproxDistance(player->mo->tracer->x - player->mo->x, player->mo->tracer->y - player->mo->y), player->mo->tracer->z - player->mo->z); + dist = FixedHypot(FixedHypot(player->mo->tracer->x - player->mo->x, player->mo->tracer->y - player->mo->y), player->mo->tracer->z - player->mo->z); if (dist < 1) dist = 1; @@ -8776,7 +8776,7 @@ static void P_DoZoomTube(player_t *player) // calculate MOMX/MOMY/MOMZ for next waypoint // change slope - dist = P_AproxDistance(P_AproxDistance(player->mo->tracer->x - player->mo->x, player->mo->tracer->y - player->mo->y), player->mo->tracer->z - player->mo->z); + dist = FixedHypot(FixedHypot(player->mo->tracer->x - player->mo->x, player->mo->tracer->y - player->mo->y), player->mo->tracer->z - player->mo->z); if (dist < 1) dist = 1; @@ -8829,7 +8829,7 @@ static void P_DoRopeHang(player_t *player) sequence = player->mo->tracer->threshold; // change slope - dist = P_AproxDistance(P_AproxDistance(player->mo->tracer->x - player->mo->x, player->mo->tracer->y - player->mo->y), player->mo->tracer->z - playerz); + dist = FixedHypot(FixedHypot(player->mo->tracer->x - player->mo->x, player->mo->tracer->y - player->mo->y), player->mo->tracer->z - playerz); if (dist < 1) dist = 1; @@ -8892,7 +8892,7 @@ static void P_DoRopeHang(player_t *player) // calculate MOMX/MOMY/MOMZ for next waypoint // change slope - dist = P_AproxDistance(P_AproxDistance(player->mo->tracer->x - player->mo->x, player->mo->tracer->y - player->mo->y), player->mo->tracer->z - playerz); + dist = FixedHypot(FixedHypot(player->mo->tracer->x - player->mo->x, player->mo->tracer->y - player->mo->y), player->mo->tracer->z - playerz); if (dist < 1) dist = 1; @@ -8993,7 +8993,7 @@ void P_NukeEnemies(mobj_t *inflictor, mobj_t *source, fixed_t radius) if (abs(inflictor->x - mo->x) > radius || abs(inflictor->y - mo->y) > radius || abs(inflictor->z - mo->z) > radius) continue; // Workaround for possible integer overflow in the below -Red - if (P_AproxDistance(P_AproxDistance(inflictor->x - mo->x, inflictor->y - mo->y), inflictor->z - mo->z) > radius) + if (FixedHypot(FixedHypot(inflictor->x - mo->x, inflictor->y - mo->y), inflictor->z - mo->z) > radius) continue; if (mo->type == MT_MINUS && !(mo->flags & (MF_SPECIAL|MF_SHOOTABLE))) @@ -9129,12 +9129,12 @@ mobj_t *P_LookForFocusTarget(player_t *player, mobj_t *exclude, SINT8 direction, { fixed_t zdist = (player->mo->z + player->mo->height/2) - (mo->z + mo->height/2); - dist = P_AproxDistance(player->mo->x-mo->x, player->mo->y-mo->y); + dist = FixedHypot(player->mo->x-mo->x, player->mo->y-mo->y); if (abs(zdist) > dist) continue; // Don't home outside of desired angle! - dist = P_AproxDistance(dist, zdist); + dist = FixedHypot(dist, zdist); if (dist > maxdist) continue; // out of range } @@ -9226,7 +9226,7 @@ mobj_t *P_LookForEnemies(player_t *player, boolean nonenemies, boolean bullet) { fixed_t zdist = (player->mo->z + player->mo->height/2) - (mo->z + mo->height/2); - dist = P_AproxDistance(player->mo->x-mo->x, player->mo->y-mo->y); + dist = FixedHypot(player->mo->x-mo->x, player->mo->y-mo->y); if (bullet) { if ((R_PointToAngle2(0, 0, dist, zdist) + span) > span*2) @@ -9243,7 +9243,7 @@ mobj_t *P_LookForEnemies(player_t *player, boolean nonenemies, boolean bullet) continue; } - dist = P_AproxDistance(dist, zdist); + dist = FixedHypot(dist, zdist); if (dist > maxdist) continue; // out of range } @@ -9303,7 +9303,7 @@ boolean P_HomingAttack(mobj_t *source, mobj_t *enemy) // Home in on your target // change slope zdist = ((P_MobjFlip(source) == -1) ? (enemy->z + enemy->height) - (source->z + source->height) : (enemy->z - source->z)); - dist = P_AproxDistance(P_AproxDistance(enemy->x - source->x, enemy->y - source->y), zdist); + dist = FixedHypot(FixedHypot(enemy->x - source->x, enemy->y - source->y), zdist); if (dist < 1) dist = 1; @@ -10352,7 +10352,7 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall // follow the player /*if (player->playerstate != PST_DEAD && (camspeed) != 0) { - if (P_AproxDistance(mo->x - thiscam->x, mo->y - thiscam->y) > (checkdist + P_AproxDistance(mo->momx, mo->momy)) * 4 + if (FixedHypot(mo->x - thiscam->x, mo->y - thiscam->y) > (checkdist + FixedHypot(mo->momx, mo->momy)) * 4 || abs(mo->z - thiscam->z) > checkdist * 3) { if (!resetcalled) @@ -10417,7 +10417,7 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall } /* check z distance too for orbital camera */ - if (P_AproxDistance(P_AproxDistance(vx - mo->x, vy - mo->y), + if (FixedHypot(FixedHypot(vx - mo->x, vy - mo->y), vz - ( mo->z + mo->height / 2 )) < FixedMul(48*FRACUNIT, mo->scale)) mo->flags2 |= MF2_SHADOW; else @@ -10902,7 +10902,7 @@ static void P_ParabolicMove(mobj_t *mo, fixed_t x, fixed_t y, fixed_t z, fixed_t fixed_t dx = x - mo->x; fixed_t dy = y - mo->y; fixed_t dz = z - mo->z; - fixed_t dh = P_AproxDistance(dx, dy); + fixed_t dh = FixedHypot(dx, dy); fixed_t c = FixedDiv(dx, dh); fixed_t s = FixedDiv(dy, dh); fixed_t fixConst = FixedDiv(speed, g); @@ -11774,7 +11774,7 @@ void P_PlayerThink(player_t *player) if (mo2->flags2 & MF2_NIGHTSPULL) continue; - if (P_AproxDistance(P_AproxDistance(mo2->x - x, mo2->y - y), mo2->z - z) > FixedMul(128*FRACUNIT, player->mo->scale)) + if (FixedHypot(FixedHypot(mo2->x - x, mo2->y - y), mo2->z - z) > FixedMul(128*FRACUNIT, player->mo->scale)) continue; // Yay! The thing's in reach! Pull it in! @@ -12010,7 +12010,7 @@ void P_PlayerThink(player_t *player) if (!currentlyonground) acceleration /= 2; // fake skidding! see P_SkidStuff for reference on conditionals - else if (!player->skidtime && !(player->mo->eflags & MFE_GOOWATER) && !(player->pflags & (PF_JUMPED|PF_SPINNING|PF_SLIDING)) && !(player->charflags & SF_NOSKID) && P_AproxDistance(player->mo->momx, player->mo->momy) >= FixedMul(player->runspeed, player->mo->scale)) // modified from player->runspeed/2 'cuz the skid was just TOO frequent ngl + else if (!player->skidtime && !(player->mo->eflags & MFE_GOOWATER) && !(player->pflags & (PF_JUMPED|PF_SPINNING|PF_SLIDING)) && !(player->charflags & SF_NOSKID) && FixedHypot(player->mo->momx, player->mo->momy) >= FixedMul(player->runspeed, player->mo->scale)) // modified from player->runspeed/2 'cuz the skid was just TOO frequent ngl { if (player->mo->state-states != S_PLAY_SKID) P_SetPlayerMobjState(player->mo, S_PLAY_SKID); @@ -12595,7 +12595,7 @@ void P_PlayerAfterThink(player_t *player) P_SetPlayerAngle(player, player->mo->angle); } - if (P_AproxDistance(player->mo->x - tails->x, player->mo->y - tails->y) > player->mo->radius) + if (FixedHypot(player->mo->x - tails->x, player->mo->y - tails->y) > player->mo->radius) player->powers[pw_carry] = CR_NONE; if (player->powers[pw_carry] != CR_NONE) @@ -12784,7 +12784,7 @@ void P_PlayerAfterThink(player_t *player) player->mo->momy = ptera->momy; player->mo->momz = ptera->momz; - if (P_AproxDistance(player->mo->x - ptera->x - ptera->watertop, player->mo->y - ptera->y - ptera->waterbottom) > player->mo->radius) + if (FixedHypot(player->mo->x - ptera->x - ptera->watertop, player->mo->y - ptera->y - ptera->waterbottom) > player->mo->radius) goto dropoff; ptera->watertop >>= 1; diff --git a/src/r_things.c b/src/r_things.c index 083373927..4e296bb1a 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -2991,7 +2991,7 @@ boolean R_ThingVisibleWithinDist (mobj_t *thing, if (! R_ThingVisible(thing)) return false; - approx_dist = P_AproxDistance(viewx-thing->x, viewy-thing->y); + approx_dist = FixedHypot(viewx-thing->x, viewy-thing->y); if (thing->sprite == SPR_HOOP) { @@ -3016,7 +3016,7 @@ boolean R_PrecipThingVisible (precipmobj_t *precipthing, if (( precipthing->precipflags & PCF_INVISIBLE )) return false; - approx_dist = P_AproxDistance(viewx-precipthing->x, viewy-precipthing->y); + approx_dist = FixedHypot(viewx-precipthing->x, viewy-precipthing->y); return ( approx_dist <= limit_dist ); } diff --git a/src/s_sound.c b/src/s_sound.c index 392a5b453..0085dc342 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -943,8 +943,8 @@ void S_UpdateSounds(void) const mobj_t *soundmobj = c->origin; fixed_t dist1, dist2; - dist1 = P_AproxDistance(listener.x-soundmobj->x, listener.y-soundmobj->y); - dist2 = P_AproxDistance(listener2.x-soundmobj->x, listener2.y-soundmobj->y); + dist1 = FixedHypot(listener.x-soundmobj->x, listener.y-soundmobj->y); + dist2 = FixedHypot(listener2.x-soundmobj->x, listener2.y-soundmobj->y); if (dist1 <= dist2) { diff --git a/src/st_stuff.c b/src/st_stuff.c index 649644620..15d1af396 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -2458,7 +2458,7 @@ num: static INT32 ST_drawEmeraldHuntIcon(mobj_t *hunt, patch_t **patches, INT32 offset) { INT32 interval, i; - UINT32 dist = ((UINT32)P_AproxDistance(P_AproxDistance(stplyr->mo->x - hunt->x, stplyr->mo->y - hunt->y), stplyr->mo->z - hunt->z))>>FRACBITS; + UINT32 dist = ((UINT32)FixedHypot(FixedHypot(stplyr->mo->x - hunt->x, stplyr->mo->y - hunt->y), stplyr->mo->z - hunt->z))>>FRACBITS; if (dist < 128) { From 5bb221b3bfb501c940e96871cbb068abc8f4a8d4 Mon Sep 17 00:00:00 2001 From: James R Date: Sat, 12 Dec 2020 15:39:13 -0800 Subject: [PATCH 0465/1080] Yeah Fuck You SEENAMES --- src/lua_hook.h | 2 -- src/lua_hooklib.c | 2 -- 2 files changed, 4 deletions(-) diff --git a/src/lua_hook.h b/src/lua_hook.h index 4274f1f3c..0f8482794 100644 --- a/src/lua_hook.h +++ b/src/lua_hook.h @@ -120,9 +120,7 @@ int LUA_HookPlayerCanDamage(player_t *, mobj_t *); void LUA_HookPlayerQuit(player_t *, kickreason_t); int LUA_HookTeamSwitch(player_t *, int newteam, boolean fromspectators, boolean tryingautobalance, boolean tryingscramble); int LUA_HookViewpointSwitch(player_t *player, player_t *newdisplayplayer, boolean forced); -#ifdef SEENAMES int LUA_HookSeenPlayer(player_t *player, player_t *seenfriend); -#endif int LUA_HookShouldJingleContinue(player_t *, const char *musname); int LUA_HookPlayerCmd(player_t *, ticcmd_t *); int LUA_HookMusicChange(const char *oldname, struct MusicChange *); diff --git a/src/lua_hooklib.c b/src/lua_hooklib.c index 4143fbd8e..3a63e446e 100644 --- a/src/lua_hooklib.c +++ b/src/lua_hooklib.c @@ -947,7 +947,6 @@ int LUA_HookViewpointSwitch(player_t *player, player_t *newdisplayplayer, boolea return hook.status; } -#ifdef SEENAMES int LUA_HookSeenPlayer(player_t *player, player_t *seenfriend) { Hook_State hook; @@ -962,7 +961,6 @@ int LUA_HookSeenPlayer(player_t *player, player_t *seenfriend) } return hook.status; } -#endif // SEENAMES int LUA_HookShouldJingleContinue(player_t *player, const char *musname) { From 83e80eef9ba1e60a71970807962ed49c9669eceb Mon Sep 17 00:00:00 2001 From: Steel Titanium Date: Sat, 12 Dec 2020 18:54:47 -0500 Subject: [PATCH 0466/1080] Add deprecation warning when using the level header parameter --- src/deh_soc.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/deh_soc.c b/src/deh_soc.c index 2cd872378..2075d6484 100644 --- a/src/deh_soc.c +++ b/src/deh_soc.c @@ -1574,6 +1574,8 @@ void readlevelheader(MYFILE *f, INT32 num) sizeof(mapheaderinfo[num-1]->musname), va("Level header %d: music", num)); } } + else if (fastcmp(word, "MUSICSLOT")) + deh_warning("Level header %d: MusicSlot parameter is deprecated and will be removed.\nUse \"Music\" instead.", num); else if (fastcmp(word, "MUSICTRACK")) mapheaderinfo[num-1]->mustrack = ((UINT16)i - 1); else if (fastcmp(word, "MUSICPOS")) From 7e0a1709de58ea290a6edef7d7f2b4ec28427ac8 Mon Sep 17 00:00:00 2001 From: Jaime Ita Passos Date: Mon, 14 Dec 2020 00:53:42 -0300 Subject: [PATCH 0467/1080] Fix a crash in Picture_GetPatchPixel with PICFMT_DOOMPATCH formats --- src/r_picformats.c | 9 +++++---- src/r_textures.c | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/r_picformats.c b/src/r_picformats.c index 02f1de4ab..f87362c76 100644 --- a/src/r_picformats.c +++ b/src/r_picformats.c @@ -544,21 +544,22 @@ void *Picture_GetPatchPixel( UINT16 *s16 = NULL; UINT32 *s32 = NULL; softwarepatch_t *doompatch = (softwarepatch_t *)patch; + boolean isdoompatch = Picture_IsDoomPatchFormat(informat); INT16 width; if (patch == NULL) I_Error("Picture_GetPatchPixel: patch == NULL"); - width = (Picture_IsDoomPatchFormat(informat) ? patch->width : SHORT(patch->width)); + width = (isdoompatch ? SHORT(doompatch->width) : patch->width); if (x >= 0 && x < width) { INT32 colx = (flags & PICFLAGS_XFLIP) ? (width-1)-x : x; INT32 topdelta, prevdelta = -1; - INT32 colofs = (Picture_IsDoomPatchFormat(informat) ? LONG(patch->columnofs[colx]) : patch->columnofs[colx]); + INT32 colofs = (isdoompatch ? LONG(doompatch->columnofs[colx]) : patch->columnofs[colx]); - // Column offsets are pointers so no casting required - if (Picture_IsDoomPatchFormat(informat)) + // Column offsets are pointers, so no casting is required. + if (isdoompatch) column = (column_t *)((UINT8 *)doompatch + colofs); else column = (column_t *)((UINT8 *)patch->columns + colofs); diff --git a/src/r_textures.c b/src/r_textures.c index 9de9649e2..a006d739f 100644 --- a/src/r_textures.c +++ b/src/r_textures.c @@ -604,7 +604,7 @@ void *R_GetLevelFlat(levelflat_t *levelflat) levelflat->height = ds_flatheight = SHORT(patch->height); levelflat->picture = Z_Malloc(levelflat->width * levelflat->height, PU_LEVEL, NULL); - converted = Picture_FlatConvert(PICFMT_DOOMPATCH, patch, PICFMT_FLAT, 0, &size, levelflat->width, levelflat->height, patch->topoffset, patch->leftoffset, 0); + converted = Picture_FlatConvert(PICFMT_DOOMPATCH, patch, PICFMT_FLAT, 0, &size, levelflat->width, levelflat->height, SHORT(patch->topoffset), SHORT(patch->leftoffset), 0); M_Memcpy(levelflat->picture, converted, size); Z_Free(converted); } From ca78fc69cad750a5a915cd5519c2cc45c5ff5848 Mon Sep 17 00:00:00 2001 From: Jaime Ita Passos Date: Mon, 14 Dec 2020 01:14:55 -0300 Subject: [PATCH 0468/1080] Restore the viewpoint's angle in R_DrawPlanes instead --- src/r_plane.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/r_plane.c b/src/r_plane.c index c54b32382..b5ac7252f 100644 --- a/src/r_plane.c +++ b/src/r_plane.c @@ -607,6 +607,7 @@ void R_MakeSpans(INT32 x, INT32 t1, INT32 b1, INT32 t2, INT32 b2) void R_DrawPlanes(void) { visplane_t *pl; + angle_t va = viewangle; INT32 i; R_UpdatePlaneRipple(); @@ -621,6 +622,8 @@ void R_DrawPlanes(void) R_DrawSinglePlane(pl); } } + + viewangle = va; } // R_DrawSkyPlane @@ -788,7 +791,6 @@ void R_DrawSinglePlane(visplane_t *pl) ffloor_t *rover; int type; int spanfunctype = BASEDRAWFUNC; - angle_t viewang = viewangle; if (!(pl->minx <= pl->maxx)) return; @@ -1153,8 +1155,6 @@ using the palette colors. } } #endif - - viewangle = viewang; } void R_PlaneBounds(visplane_t *plane) From 6160a2d0fe6a09990a0fca6b0c9e5c4f75191e0e Mon Sep 17 00:00:00 2001 From: Jaime Ita Passos Date: Mon, 14 Dec 2020 02:07:12 -0300 Subject: [PATCH 0469/1080] Fix a misuse of levelflat_t.picture in OpenGL (Kitchen Sink SRB2 port) --- src/hardware/hw_cache.c | 31 +++++++++++++++++++------------ src/hardware/hw_draw.c | 2 +- src/hardware/hw_glob.h | 2 +- src/p_setup.h | 1 + 4 files changed, 22 insertions(+), 14 deletions(-) diff --git a/src/hardware/hw_cache.c b/src/hardware/hw_cache.c index b4fa7ec6c..6048affe0 100644 --- a/src/hardware/hw_cache.c +++ b/src/hardware/hw_cache.c @@ -850,7 +850,7 @@ static void HWR_CacheTextureAsFlat(GLMipmap_t *grMipmap, INT32 texturenum) } // Download a Doom 'flat' to the hardware cache and make it ready for use -void HWR_LiterallyGetFlat(lumpnum_t flatlumpnum) +void HWR_GetRawFlat(lumpnum_t flatlumpnum) { GLMipmap_t *grmip; patch_t *patch; @@ -879,7 +879,7 @@ void HWR_GetLevelFlat(levelflat_t *levelflat) return; if (levelflat->type == LEVELFLAT_FLAT) - HWR_LiterallyGetFlat(levelflat->u.flat.lumpnum); + HWR_GetRawFlat(levelflat->u.flat.lumpnum); else if (levelflat->type == LEVELFLAT_TEXTURE) { GLMapTexture_t *grtex; @@ -918,15 +918,17 @@ void HWR_GetLevelFlat(levelflat_t *levelflat) #ifndef NO_PNG_LUMPS else if (levelflat->type == LEVELFLAT_PNG) { - INT32 pngwidth = 0, pngheight = 0; GLMipmap_t *mipmap = levelflat->mipmap; - UINT8 *flat; - size_t size; // Cache the picture. - if (!levelflat->picture) + if (!levelflat->mippic) { - levelflat->picture = Picture_PNGConvert(W_CacheLumpNum(levelflat->u.flat.lumpnum, PU_CACHE), PICFMT_FLAT, &pngwidth, &pngheight, NULL, NULL, W_LumpLength(levelflat->u.flat.lumpnum), NULL, 0); + INT32 pngwidth = 0, pngheight = 0; + void *pic = Picture_PNGConvert(W_CacheLumpNum(levelflat->u.flat.lumpnum, PU_CACHE), PICFMT_FLAT, &pngwidth, &pngheight, NULL, NULL, W_LumpLength(levelflat->u.flat.lumpnum), NULL, 0); + + Z_ChangeTag(pic, PU_LEVEL); + Z_SetUser(pic, &levelflat->mippic); + levelflat->width = (UINT16)pngwidth; levelflat->height = (UINT16)pngheight; } @@ -934,7 +936,7 @@ void HWR_GetLevelFlat(levelflat_t *levelflat) // Make the mipmap. if (mipmap == NULL) { - mipmap = Z_Calloc(sizeof(GLMipmap_t), PU_LEVEL, NULL); + mipmap = Z_Calloc(sizeof(GLMipmap_t), PU_STATIC, NULL); mipmap->format = GL_TEXFMT_P_8; mipmap->flags = TF_WRAPXY|TF_CHROMAKEYED; levelflat->mipmap = mipmap; @@ -942,17 +944,22 @@ void HWR_GetLevelFlat(levelflat_t *levelflat) if (!mipmap->data && !mipmap->downloaded) { + UINT8 *flat; + size_t size; + + if (levelflat->mippic == NULL) + I_Error("HWR_GetLevelFlat: levelflat->mippic == NULL"); + mipmap->width = levelflat->width; mipmap->height = levelflat->height; + size = (mipmap->width * mipmap->height); flat = Z_Malloc(size, PU_LEVEL, &mipmap->data); - if (levelflat->picture == NULL) - I_Error("HWR_GetLevelFlat: levelflat->picture == NULL"); - M_Memcpy(flat, levelflat->picture, size); + M_Memcpy(flat, levelflat->mippic, size); } // Tell the hardware driver to bind the current texture to the flat's mipmap - HWD.pfnSetTexture(mipmap); + HWR_SetCurrentTexture(mipmap); } #endif else // set no texture diff --git a/src/hardware/hw_draw.c b/src/hardware/hw_draw.c index c5d362520..8c92c6709 100644 --- a/src/hardware/hw_draw.c +++ b/src/hardware/hw_draw.c @@ -639,7 +639,7 @@ void HWR_DrawFlatFill (INT32 x, INT32 y, INT32 w, INT32 h, lumpnum_t flatlumpnum v[0].t = v[1].t = (float)((y & flatflag)/dflatsize); v[2].t = v[3].t = (float)(v[0].t + h/dflatsize); - HWR_LiterallyGetFlat(flatlumpnum); + HWR_GetRawFlat(flatlumpnum); //Hurdler: Boris, the same comment as above... but maybe for pics // it not a problem since they don't have any transparent pixel diff --git a/src/hardware/hw_glob.h b/src/hardware/hw_glob.h index 87405d3d4..2aba62248 100644 --- a/src/hardware/hw_glob.h +++ b/src/hardware/hw_glob.h @@ -118,7 +118,7 @@ patch_t *HWR_GetPic(lumpnum_t lumpnum); GLMapTexture_t *HWR_GetTexture(INT32 tex); void HWR_GetLevelFlat(levelflat_t *levelflat); -void HWR_LiterallyGetFlat(lumpnum_t flatlumpnum); +void HWR_GetRawFlat(lumpnum_t flatlumpnum); void HWR_FreeTexture(patch_t *patch); void HWR_FreeTextureData(patch_t *patch); diff --git a/src/p_setup.h b/src/p_setup.h index 34de9c93d..5d13ae7d4 100644 --- a/src/p_setup.h +++ b/src/p_setup.h @@ -80,6 +80,7 @@ typedef struct UINT8 *picture; #ifdef HWRENDER void *mipmap; + void *mippic; #endif } levelflat_t; From 2b2346835920ca359891c1212e8210a3543a4c27 Mon Sep 17 00:00:00 2001 From: katsy Date: Mon, 14 Dec 2020 02:36:00 -0500 Subject: [PATCH 0470/1080] remove amy --- 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 badf19372..b116b756c 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -11798,7 +11798,7 @@ static boolean P_AllowMobjSpawn(mapthing_t* mthing, mobjtype_t i) if (!(G_CoopGametype() || (mthing->options & MTF_EXTRA))) return false; // she doesn't hang out here - if (!mariomode && !(netgame || multiplayer) && players[consoleplayer].skin == 3) + if (!(netgame || multiplayer) && players[consoleplayer].skin == 3) return false; // no doubles break; From 0ce9d9127a7707aceb94c2f263508725438ef9dc Mon Sep 17 00:00:00 2001 From: katsy Date: Mon, 14 Dec 2020 04:01:50 -0500 Subject: [PATCH 0471/1080] add SF_NOSHIELDABILITY --- src/d_player.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/d_player.h b/src/d_player.h index eb0372832..0e0f623d3 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -51,7 +51,8 @@ typedef enum SF_NONIGHTSSUPER = 1<<15, // Disable super colors for NiGHTS (if you have SF_SUPER) SF_NOSUPERSPRITES = 1<<16, // Don't use super sprites while super SF_NOSUPERJUMPBOOST = 1<<17, // Disable the jump boost given while super (i.e. Knuckles) - SF_CANBUSTWALLS = 1<<18, // Can naturally bust walls on contact? (i.e. Knuckles) + SF_CANBUSTWALLS = 1<<18, // Can naturally bust walls on contact? (i.e. Knuckles) + SF_NOSHIELDABILITY = 1<<19, // Disable shield abilities // free up to and including 1<<31 } skinflags_t; From dfbb1825f460fcc3db33880450fea4c93bd2e648 Mon Sep 17 00:00:00 2001 From: katsy Date: Mon, 14 Dec 2020 04:02:17 -0500 Subject: [PATCH 0472/1080] ditto --- src/deh_tables.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/deh_tables.c b/src/deh_tables.c index 5733d9b0e..2a0f179d4 100644 --- a/src/deh_tables.c +++ b/src/deh_tables.c @@ -4987,6 +4987,8 @@ struct int_const_s const INT_CONST[] = { {"SF_NOSUPERSPRITES",SF_NOSUPERSPRITES}, {"SF_NOSUPERJUMPBOOST",SF_NOSUPERJUMPBOOST}, {"SF_CANBUSTWALLS",SF_CANBUSTWALLS}, + {"SF_NOSHIELDABILITY",SF_NOSHIELDABILITY}, + // Dashmode constants {"DASHMODE_THRESHOLD",DASHMODE_THRESHOLD}, From 2bebaf12d0f19e97a84577af8c75fa1e1523172a Mon Sep 17 00:00:00 2001 From: katsy Date: Mon, 14 Dec 2020 04:03:14 -0500 Subject: [PATCH 0473/1080] add checks for new flag, make emergency jump call shieldspecial --- src/p_user.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index c5f919c78..f06ad998d 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -2491,6 +2491,7 @@ boolean P_PlayerHitFloor(player_t *player, boolean dorollstuff) player->mo->momx = player->mo->momy = 0; clipmomz = false; } + else if ((player->powers[pw_shield] & SH_NOSTACK) == SH_BUBBLEWRAP) // Bubble shield's bounce attack. { P_DoBubbleBounce(player); @@ -5020,7 +5021,7 @@ static boolean P_PlayerShieldThink(player_t *player, ticcmd_t *cmd, mobj_t *lock if ((player->powers[pw_shield] & SH_NOSTACK) && !player->powers[pw_super] && !(player->pflags & PF_SPINDOWN) && ((!(player->pflags & PF_THOKKED) || (((player->powers[pw_shield] & SH_NOSTACK) == SH_BUBBLEWRAP || (player->powers[pw_shield] & SH_NOSTACK) == SH_ATTRACT) && player->secondjump == UINT8_MAX) ))) // thokked is optional if you're bubblewrapped / 3dblasted { - if ((player->powers[pw_shield] & SH_NOSTACK) == SH_ATTRACT) + if ((player->powers[pw_shield] & SH_NOSTACK) == SH_ATTRACT && !(player->charflags & SF_NOSHIELDABILITY)) { if ((lockonshield = P_LookForEnemies(player, false, false))) { @@ -5043,7 +5044,7 @@ static boolean P_PlayerShieldThink(player_t *player, ticcmd_t *cmd, mobj_t *lock } } } - if (cmd->buttons & BT_SPIN && !LUAh_ShieldSpecial(player)) // Spin button effects + if ((!(player->charflags & SF_NOSHIELDABILITY)) && (cmd->buttons & BT_SPIN && !LUAh_ShieldSpecial(player))) // Spin button effects { // Force stop if ((player->powers[pw_shield] & ~(SH_FORCEHP|SH_STACK)) == SH_FORCE) @@ -5491,7 +5492,7 @@ static void P_DoJumpStuff(player_t *player, ticcmd_t *cmd) break; } } - else if ((player->powers[pw_shield] & SH_NOSTACK) == SH_WHIRLWIND && !player->powers[pw_super]) + else if ((!(player->charflags & SF_NOSHIELDABILITY)) && ((player->powers[pw_shield] & SH_NOSTACK) == SH_WHIRLWIND && !player->powers[pw_super] && !LUAh_ShieldSpecial(player))) P_DoJumpShield(player); } From 200e444016f61556fb080d956903364fee304abe Mon Sep 17 00:00:00 2001 From: katsy Date: Mon, 14 Dec 2020 04:05:14 -0500 Subject: [PATCH 0474/1080] go away whitespace --- src/deh_tables.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/deh_tables.c b/src/deh_tables.c index 2a0f179d4..e92a4f60c 100644 --- a/src/deh_tables.c +++ b/src/deh_tables.c @@ -4989,7 +4989,6 @@ struct int_const_s const INT_CONST[] = { {"SF_CANBUSTWALLS",SF_CANBUSTWALLS}, {"SF_NOSHIELDABILITY",SF_NOSHIELDABILITY}, - // Dashmode constants {"DASHMODE_THRESHOLD",DASHMODE_THRESHOLD}, {"DASHMODE_MAX",DASHMODE_MAX}, From 4521827e2c2b101db0ba3c8ddd114fd8a1b18bc7 Mon Sep 17 00:00:00 2001 From: katsy Date: Mon, 14 Dec 2020 04:06:28 -0500 Subject: [PATCH 0475/1080] you too --- src/p_user.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/p_user.c b/src/p_user.c index f06ad998d..917c7ddf6 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -2491,7 +2491,6 @@ boolean P_PlayerHitFloor(player_t *player, boolean dorollstuff) player->mo->momx = player->mo->momy = 0; clipmomz = false; } - else if ((player->powers[pw_shield] & SH_NOSTACK) == SH_BUBBLEWRAP) // Bubble shield's bounce attack. { P_DoBubbleBounce(player); From 00dff6d2836890bf51803530626047bf40f7b2fa Mon Sep 17 00:00:00 2001 From: James R Date: Mon, 14 Dec 2020 05:53:57 -0800 Subject: [PATCH 0476/1080] Push "valid" only once --- src/lua_taglib.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/lua_taglib.c b/src/lua_taglib.c index 284b171a3..12d1a3c05 100644 --- a/src/lua_taglib.c +++ b/src/lua_taglib.c @@ -167,7 +167,7 @@ static void push_taglist(lua_State *L, int idx) static int has_valid_field(lua_State *L) { int equal; - lua_pushliteral(L, "valid"); + lua_rawgeti(L, LUA_ENVIRONINDEX, 1); equal = lua_rawequal(L, 2, -1); lua_pop(L, 1); return equal; @@ -392,6 +392,9 @@ static void open_taglist(lua_State *L) lua_setfield(L, -2, "has"); } +#define new_literal(L, s) \ + (lua_pushliteral(L, s), luaL_ref(L, -2)) + static void set_taglist_metatable(lua_State *L, const char *meta) { lua_createtable(L, 0, 4); @@ -399,6 +402,9 @@ static void set_taglist_metatable(lua_State *L, const char *meta) lua_setfield(L, -2, "taglist"); lua_pushcfunction(L, taglist_get); + lua_createtable(L, 0, 1); + new_literal(L, "valid"); + lua_setfenv(L, -2); lua_setfield(L, -2, "__index"); lua_pushcfunction(L, taglist_len); From d0f3a6d737137d2e68c4fb1506f8d7809f8801ae Mon Sep 17 00:00:00 2001 From: James R Date: Mon, 14 Dec 2020 08:08:01 -0800 Subject: [PATCH 0477/1080] Better check for tag list userdata --- src/lua_taglib.c | 52 +++++++++++++++++++++++++++++------------------- 1 file changed, 31 insertions(+), 21 deletions(-) diff --git a/src/lua_taglib.c b/src/lua_taglib.c index 12d1a3c05..c9f320fe8 100644 --- a/src/lua_taglib.c +++ b/src/lua_taglib.c @@ -156,13 +156,9 @@ static int lib_numTaggroupElements(lua_State *L) return 1; } -static void push_taglist(lua_State *L, int idx) -{ - lua_getmetatable(L, idx); - lua_pushliteral(L, "taglist"); - lua_rawget(L, -2); - lua_remove(L, -2); -} +#ifdef MUTABLE_TAGS +static int meta_ref[2]; +#endif static int has_valid_field(lua_State *L) { @@ -191,10 +187,19 @@ static taglist_t * valid_taglist(lua_State *L, int idx, boolean getting) static taglist_t * check_taglist(lua_State *L, int idx) { - luaL_checktype(L, idx, LUA_TUSERDATA); - push_taglist(L, idx); - luaL_argcheck(L, lua_toboolean(L, -1), idx, "must be a tag list"); - return valid_taglist(L, idx, false); + if (lua_isuserdata(L, idx) && lua_getmetatable(L, idx)) + { + lua_getref(L, meta_ref[0]); + lua_getref(L, meta_ref[1]); + + if (lua_rawequal(L, -3, -2) || lua_rawequal(L, -3, -1)) + { + lua_pop(L, 3); + return valid_taglist(L, idx, false); + } + } + + return luaL_argerror(L, idx, "must be a tag list"), NULL; } static int taglist_get(lua_State *L) @@ -223,7 +228,7 @@ static int taglist_get(lua_State *L) } else { - push_taglist(L, 1); + lua_getmetatable(L, 1); lua_replace(L, 1); lua_rawget(L, 1); return 1; @@ -395,12 +400,14 @@ static void open_taglist(lua_State *L) #define new_literal(L, s) \ (lua_pushliteral(L, s), luaL_ref(L, -2)) -static void set_taglist_metatable(lua_State *L, const char *meta) +#ifdef MUTABLE_TAGS +static int +#else +static void +#endif +set_taglist_metatable(lua_State *L, const char *meta) { - lua_createtable(L, 0, 4); - lua_getglobal(L, "taglist"); - lua_setfield(L, -2, "taglist"); - + luaL_newmetatable(L, meta); lua_pushcfunction(L, taglist_get); lua_createtable(L, 0, 1); new_literal(L, "valid"); @@ -412,7 +419,9 @@ static void set_taglist_metatable(lua_State *L, const char *meta) lua_pushcfunction(L, taglist_equal); lua_setfield(L, -2, "__eq"); - lua_setfield(L, LUA_REGISTRYINDEX, meta); +#ifdef MUTABLE_TAGS + return luaL_ref(L, LUA_REGISTRYINDEX); +#endif } int LUA_TagLib(lua_State *L) @@ -431,10 +440,11 @@ int LUA_TagLib(lua_State *L) open_taglist(L); - set_taglist_metatable(L, META_TAGLIST); - #ifdef MUTABLE_TAGS - set_taglist_metatable(L, META_SECTORTAGLIST); + meta_ref[0] = set_taglist_metatable(L, META_TAGLIST); + meta_ref[1] = set_taglist_metatable(L, META_SECTORTAGLIST); +#else + set_taglist_metatable(L, META_TAGLIST); #endif return 0; From 3b36005ceb1fa04f8c2875e5d614aeb8c419cef9 Mon Sep 17 00:00:00 2001 From: Jaime Ita Passos Date: Mon, 14 Dec 2020 14:13:24 -0300 Subject: [PATCH 0478/1080] Replace the first entry in the taglist, instead of adding into it --- 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 41d8822e2..66243fb0e 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -3171,7 +3171,7 @@ static void P_ConvertBinaryMap(void) switch (mapthings[i].type) { case 750: - Tag_Add(&mapthings[i].tags, mapthings[i].angle); + Tag_FSet(&mapthings[i].tags, mapthings[i].angle); break; case 760: case 761: From 9b8bacd08886375c1090d46d8d964f6c1c2b1be6 Mon Sep 17 00:00:00 2001 From: Zippy_Zolton Date: Mon, 14 Dec 2020 12:52:24 -0600 Subject: [PATCH 0479/1080] Redone colormaps by SonicX8000 --- src/console.c | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/src/console.c b/src/console.c index 982b0d550..3c19c5e18 100644 --- a/src/console.c +++ b/src/console.c @@ -378,24 +378,23 @@ static void CON_SetupColormaps(void) map[0xE] = (UINT8)o;\ map[0xF] = (UINT8)p; - // I tried to make them kinda close to the originals, tell me how I did! ~Golden - // decent but i made most of the colors better thanks for th help :3 + // Tried to keep the colors vanilla while adding some shades in between them ~SonicX8000 - // 0x1 0x3 0x9 0xF - colset(magentamap, 177, 177, 178, 178, 179, 179, 180, 180, 181, 181, 182, 182, 183, 183, 184, 184); - colset(yellowmap, 81, 81, 73, 73, 74, 74, 74, 65, 65, 65, 66, 66, 66, 67, 67, 67); - colset(lgreenmap, 97, 97, 98, 98, 99, 99, 100, 100, 101, 101, 102, 102, 103, 103, 104, 104); - colset(bluemap, 146, 146, 147, 147, 148, 148, 148, 149, 149, 149, 150, 150, 150, 151, 151, 151); - colset(redmap, 32, 32, 33, 33, 34, 34, 34, 35, 35, 35, 37, 37, 37, 39, 39, 39); - colset(graymap, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20); - colset(orangemap, 51, 51, 52, 52, 53, 53, 54, 54, 55, 55, 56, 56, 57, 57, 58, 58); - colset(skymap, 128, 128, 129, 129, 130, 130, 131, 131, 132, 132, 133, 133, 134, 134, 135, 135); - colset(purplemap, 144, 144, 160, 160, 161, 161, 161, 162, 162, 162, 163, 163, 163, 164, 164, 164); - colset(aquamap, 120, 120, 121, 121, 122, 122, 122, 123, 123, 123, 124, 124, 124, 125, 125, 125); - colset(peridotmap, 72, 72, 188, 188, 189, 189, 189, 190, 190, 190, 191, 191, 191, 104, 104, 104); - colset(azuremap, 144, 144, 145, 145, 146, 146, 146, 170, 170, 170, 171, 171, 171, 172, 172, 172); - colset(brownmap, 218, 219, 220, 221, 221, 222, 223, 223, 224, 224, 225, 226, 227, 228, 229, 230); - colset(rosymap, 200, 200, 201, 201, 202, 202, 202, 203, 203, 203, 204, 204, 204, 205, 205, 205); + // 0x1 0x3 0x9 0xF + colset(magentamap, 177, 177, 178, 178, 178, 181, 181, 181, 183, 183, 183, 183, 185, 185, 185, 186); + colset(yellowmap, 82, 82, 73, 73, 73, 64, 64, 64, 66, 66, 66, 66, 67, 67, 67, 68); + colset(lgreenmap, 96, 96, 98, 98, 98, 101, 101, 101, 105, 105, 105, 105, 107, 107, 107, 108); + colset(bluemap, 146, 146, 147, 147, 147, 149, 149, 149, 152, 152, 152, 152, 155, 155, 155, 157); + colset(redmap, 32, 32, 33, 33, 33, 35, 35, 35, 39, 39, 39, 39, 42, 42, 42, 44); + colset(graymap, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23); + colset(orangemap, 50, 50, 52, 52, 52, 54, 54, 54, 56, 56, 56, 56, 59, 59, 59, 60); + colset(skymap, 129, 129, 130, 130, 130, 131, 131, 131, 133, 133, 133, 133, 135, 135, 135, 136); + colset(purplemap, 160, 160, 161, 161, 161, 162, 162, 162, 163, 163, 163, 163, 164, 164, 164, 165); + colset(aquamap, 120, 120, 121, 121, 121, 122, 122, 122, 123, 123, 123, 123, 124, 124, 124, 125); + colset(peridotmap, 72, 72, 188, 188, 189, 189, 189, 189, 190, 190, 190, 190, 191, 191, 191, 94); + colset(azuremap, 144, 144, 145, 145, 145, 146, 146, 146, 170, 170, 170, 170, 171, 171, 171, 172); + colset(brownmap, 219, 219, 221, 221, 221, 222, 222, 222, 224, 224, 224, 224, 227, 227, 227, 229); + colset(rosymap, 200, 200, 201, 201, 201, 202, 202, 202, 203, 203, 203, 203, 204, 204, 204, 205); #undef colset From 07034cf44116b54bf769c80b42c39586b90338b6 Mon Sep 17 00:00:00 2001 From: Zippy_Zolton Date: Mon, 14 Dec 2020 16:14:20 -0600 Subject: [PATCH 0480/1080] fixes spaces --- src/console.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/console.c b/src/console.c index 3c19c5e18..478f93fc8 100644 --- a/src/console.c +++ b/src/console.c @@ -378,23 +378,23 @@ static void CON_SetupColormaps(void) map[0xE] = (UINT8)o;\ map[0xF] = (UINT8)p; - // Tried to keep the colors vanilla while adding some shades in between them ~SonicX8000 + // Tried to keep the colors vanilla while adding some shades in between them ~SonicX8000 - // 0x1 0x3 0x9 0xF - colset(magentamap, 177, 177, 178, 178, 178, 181, 181, 181, 183, 183, 183, 183, 185, 185, 185, 186); - colset(yellowmap, 82, 82, 73, 73, 73, 64, 64, 64, 66, 66, 66, 66, 67, 67, 67, 68); - colset(lgreenmap, 96, 96, 98, 98, 98, 101, 101, 101, 105, 105, 105, 105, 107, 107, 107, 108); - colset(bluemap, 146, 146, 147, 147, 147, 149, 149, 149, 152, 152, 152, 152, 155, 155, 155, 157); - colset(redmap, 32, 32, 33, 33, 33, 35, 35, 35, 39, 39, 39, 39, 42, 42, 42, 44); - colset(graymap, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23); - colset(orangemap, 50, 50, 52, 52, 52, 54, 54, 54, 56, 56, 56, 56, 59, 59, 59, 60); - colset(skymap, 129, 129, 130, 130, 130, 131, 131, 131, 133, 133, 133, 133, 135, 135, 135, 136); - colset(purplemap, 160, 160, 161, 161, 161, 162, 162, 162, 163, 163, 163, 163, 164, 164, 164, 165); - colset(aquamap, 120, 120, 121, 121, 121, 122, 122, 122, 123, 123, 123, 123, 124, 124, 124, 125); + // 0x1 0x3 0x9 0xF + colset(magentamap, 177, 177, 178, 178, 178, 181, 181, 181, 183, 183, 183, 183, 185, 185, 185, 186); + colset(yellowmap, 82, 82, 73, 73, 73, 64, 64, 64, 66, 66, 66, 66, 67, 67, 67, 68); + colset(lgreenmap, 96, 96, 98, 98, 98, 101, 101, 101, 105, 105, 105, 105, 107, 107, 107, 108); + colset(bluemap, 146, 146, 147, 147, 147, 149, 149, 149, 152, 152, 152, 152, 155, 155, 155, 157); + colset(redmap, 32, 32, 33, 33, 33, 35, 35, 35, 39, 39, 39, 39, 42, 42, 42, 44); + colset(graymap, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23); + colset(orangemap, 50, 50, 52, 52, 52, 54, 54, 54, 56, 56, 56, 56, 59, 59, 59, 60); + colset(skymap, 129, 129, 130, 130, 130, 131, 131, 131, 133, 133, 133, 133, 135, 135, 135, 136); + colset(purplemap, 160, 160, 161, 161, 161, 162, 162, 162, 163, 163, 163, 163, 164, 164, 164, 165); + colset(aquamap, 120, 120, 121, 121, 121, 122, 122, 122, 123, 123, 123, 123, 124, 124, 124, 125); colset(peridotmap, 72, 72, 188, 188, 189, 189, 189, 189, 190, 190, 190, 190, 191, 191, 191, 94); - colset(azuremap, 144, 144, 145, 145, 145, 146, 146, 146, 170, 170, 170, 170, 171, 171, 171, 172); - colset(brownmap, 219, 219, 221, 221, 221, 222, 222, 222, 224, 224, 224, 224, 227, 227, 227, 229); - colset(rosymap, 200, 200, 201, 201, 201, 202, 202, 202, 203, 203, 203, 203, 204, 204, 204, 205); + colset(azuremap, 144, 144, 145, 145, 145, 146, 146, 146, 170, 170, 170, 170, 171, 171, 171, 172); + colset(brownmap, 219, 219, 221, 221, 221, 222, 222, 222, 224, 224, 224, 224, 227, 227, 227, 229); + colset(rosymap, 200, 200, 201, 201, 201, 202, 202, 202, 203, 203, 203, 203, 204, 204, 204, 205); #undef colset From d999e436f1883dead04b1b603a67e3f9efa9e547 Mon Sep 17 00:00:00 2001 From: katsy Date: Mon, 14 Dec 2020 20:23:24 -0500 Subject: [PATCH 0481/1080] GETFLAG --- src/r_skins.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/r_skins.c b/src/r_skins.c index 522d9236a..6f150f234 100644 --- a/src/r_skins.c +++ b/src/r_skins.c @@ -514,6 +514,7 @@ static boolean R_ProcessPatchableFields(skin_t *skin, char *stoken, char *value) GETFLAG(NOSUPERSPRITES) GETFLAG(NOSUPERJUMPBOOST) GETFLAG(CANBUSTWALLS) + GETFLAG(NOSHIELDABILITY) #undef GETFLAG else // let's check if it's a sound, otherwise error out From fa9db2d64424bb6bfd98b350f43e44a63dfe8095 Mon Sep 17 00:00:00 2001 From: Jaime Ita Passos Date: Wed, 16 Dec 2020 00:26:08 -0300 Subject: [PATCH 0482/1080] Fix vibing slope planes I messed up the multiplication order for texture scaling: it multiplied a floating point number with a fixed point number, instead of multiplying two floats and then converting the result into a fixed point number. --- src/r_plane.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/r_plane.c b/src/r_plane.c index c54b32382..194f85c4a 100644 --- a/src/r_plane.c +++ b/src/r_plane.c @@ -705,9 +705,9 @@ void R_CalculateSlopeVectors(pslope_t *slope, fixed_t planeviewx, fixed_t planev n.z = -xscale * cos(ang); ang = ANG2RAD(planeangle); - temp = P_GetSlopeZAt(slope, planeviewx + yscale * FLOAT_TO_FIXED(sin(ang)), planeviewy + yscale * FLOAT_TO_FIXED(cos(ang))); + temp = P_GetSlopeZAt(slope, planeviewx + FLOAT_TO_FIXED(yscale * sin(ang)), planeviewy + FLOAT_TO_FIXED(yscale * cos(ang))); m.y = FIXED_TO_FLOAT(temp) - zeroheight; - temp = P_GetSlopeZAt(slope, planeviewx + xscale * FLOAT_TO_FIXED(cos(ang)), planeviewy - xscale * FLOAT_TO_FIXED(sin(ang))); + temp = P_GetSlopeZAt(slope, planeviewx + FLOAT_TO_FIXED(xscale * cos(ang)), planeviewy - FLOAT_TO_FIXED(xscale * sin(ang))); n.y = FIXED_TO_FLOAT(temp) - zeroheight; if (ds_powersoftwo) From 45976d230454f37f62ca0c5cef5d1506c73dbccd Mon Sep 17 00:00:00 2001 From: Zippy_Zolton Date: Tue, 15 Dec 2020 22:19:57 -0600 Subject: [PATCH 0483/1080] magenta and green sonicx --- src/console.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/console.c b/src/console.c index 478f93fc8..c7bfe0fe1 100644 --- a/src/console.c +++ b/src/console.c @@ -381,9 +381,9 @@ static void CON_SetupColormaps(void) // Tried to keep the colors vanilla while adding some shades in between them ~SonicX8000 // 0x1 0x3 0x9 0xF - colset(magentamap, 177, 177, 178, 178, 178, 181, 181, 181, 183, 183, 183, 183, 185, 185, 185, 186); + colset(magentamap, 177, 177, 178, 178, 178, 180, 180, 180, 182, 182, 182, 182, 184, 184, 184, 185); colset(yellowmap, 82, 82, 73, 73, 73, 64, 64, 64, 66, 66, 66, 66, 67, 67, 67, 68); - colset(lgreenmap, 96, 96, 98, 98, 98, 101, 101, 101, 105, 105, 105, 105, 107, 107, 107, 108); + colset(lgreenmap, 96, 96, 98, 98, 98, 101, 101, 101, 104, 104, 104, 104, 106, 106, 106, 107); colset(bluemap, 146, 146, 147, 147, 147, 149, 149, 149, 152, 152, 152, 152, 155, 155, 155, 157); colset(redmap, 32, 32, 33, 33, 33, 35, 35, 35, 39, 39, 39, 39, 42, 42, 42, 44); colset(graymap, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23); From b82cee780a80fd502b99eb20ba0ae4b1bd1e287a Mon Sep 17 00:00:00 2001 From: LJ Sonic Date: Wed, 16 Dec 2020 17:35:39 +0100 Subject: [PATCH 0484/1080] Fix TICCMD_RECEIVED being overridden by gamelogic --- src/g_game.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/g_game.c b/src/g_game.c index 283113bbe..8813afaf1 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -2266,14 +2266,21 @@ void G_Ticker(boolean run) { if (playeringame[i]) { + INT16 received; + G_CopyTiccmd(&players[i].cmd, &netcmds[buf][i], 1); + received = (players[i].cmd.angleturn & TICCMD_RECEIVED); + players[i].angleturn += players[i].cmd.angleturn - players[i].oldrelangleturn; players[i].oldrelangleturn = players[i].cmd.angleturn; if (P_ControlStyle(&players[i]) == CS_LMAOGALOG) P_ForceLocalAngle(&players[i], players[i].angleturn << 16); else players[i].cmd.angleturn = players[i].angleturn; + + players[i].cmd.angleturn &= ~TICCMD_RECEIVED; + players[i].cmd.angleturn |= received; } } From 4713b258376da8120a27aa7422e3ab9cbcfa7f3c Mon Sep 17 00:00:00 2001 From: James R Date: Wed, 16 Dec 2020 08:41:58 -0800 Subject: [PATCH 0485/1080] Bit array conflicts --- src/lua_hooklib.c | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/src/lua_hooklib.c b/src/lua_hooklib.c index 3a63e446e..7f5e3dc96 100644 --- a/src/lua_hooklib.c +++ b/src/lua_hooklib.c @@ -38,18 +38,6 @@ static const char * const stringHookNames[] = { STRING_HOOK_LIST (TOSTR) NULL }; -/* TODO: remove when doomtype version is merged */ - -#define BIT_ARRAY_LENGTH(n) (((n) + 7) >> 3) - -static inline void set_bit_array (UINT8 *array, const int n) { - array[n >> 3] |= 1 << (n & 7); -} - -static inline int in_bit_array (const UINT8 *array, const int n) { - return array[n >> 3] & (1 << (n & 7)); -} - typedef struct { int numHooks; int *ids; @@ -215,7 +203,7 @@ static int lib_addHook(lua_State *L) if (!(nextid & 7)) { Z_Realloc(hooksErrored, - BIT_ARRAY_LENGTH (nextid + 1) * sizeof *hooksErrored, + BIT_ARRAY_SIZE (nextid + 1) * sizeof *hooksErrored, PU_STATIC, &hooksErrored); hooksErrored[nextid >> 3] = 0; } From f91489bcb68b409a8349ed8b901be448ee4ca4ce Mon Sep 17 00:00:00 2001 From: GoldenTails Date: Sat, 23 May 2020 17:06:10 -0500 Subject: [PATCH 0486/1080] Make the colormap returned by v.getColormap() writable. I mean it was already readable anyway... --- src/lua_hudlib.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/lua_hudlib.c b/src/lua_hudlib.c index e58cd4a58..0da0cb662 100644 --- a/src/lua_hudlib.c +++ b/src/lua_hudlib.c @@ -277,7 +277,7 @@ static int hudinfo_num(lua_State *L) static int colormap_get(lua_State *L) { - const UINT8 *colormap = *((UINT8 **)luaL_checkudata(L, 1, META_COLORMAP)); + UINT8 *colormap = *((UINT8 **)luaL_checkudata(L, 1, META_COLORMAP)); UINT32 i = luaL_checkinteger(L, 2); if (i >= 256) return luaL_error(L, "colormap index %d out of range (0 - %d)", i, 255); @@ -285,6 +285,16 @@ static int colormap_get(lua_State *L) return 1; } +static int colormap_set(lua_State *L) +{ + UINT8 *colormap = *((UINT8 **)luaL_checkudata(L, 1, META_COLORMAP)); + UINT32 i = luaL_checkinteger(L, 2); + if (i >= 256) + return luaL_error(L, "colormap index %d out of range (0 - %d)", i, 255); + colormap[i] = (UINT8)luaL_checkinteger(L, 3); + return 0; +} + static int patch_get(lua_State *L) { patch_t *patch = *((patch_t **)luaL_checkudata(L, 1, META_PATCH)); @@ -1230,6 +1240,9 @@ int LUA_HudLib(lua_State *L) luaL_newmetatable(L, META_COLORMAP); lua_pushcfunction(L, colormap_get); lua_setfield(L, -2, "__index"); + + lua_pushcfunction(L, colormap_set); + lua_setfield(L, -2, "__newindex"); lua_pop(L,1); luaL_newmetatable(L, META_PATCH); From 81ee4a75e3186a4936941c33a06f97b74f863f22 Mon Sep 17 00:00:00 2001 From: GoldenTails Date: Sat, 28 Nov 2020 00:09:12 -0600 Subject: [PATCH 0487/1080] Copy colormaps so Lua cannot modify cached colormaps! (And Z_Free them on garbage collection.) --- src/lua_hudlib.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/lua_hudlib.c b/src/lua_hudlib.c index 0da0cb662..ab091eb2f 100644 --- a/src/lua_hudlib.c +++ b/src/lua_hudlib.c @@ -295,6 +295,13 @@ static int colormap_set(lua_State *L) return 0; } +static int colormap_free(lua_State *L) +{ + UINT8 *colormap = *((UINT8 **)luaL_checkudata(L, 1, META_COLORMAP)); + Z_Free(colormap); + return 0; +} + static int patch_get(lua_State *L) { patch_t *patch = *((patch_t **)luaL_checkudata(L, 1, META_PATCH)); @@ -921,7 +928,7 @@ static int libd_getColormap(lua_State *L) // all was successful above, now we generate the colormap at last! - colormap = R_GetTranslationColormap(skinnum, color, GTC_CACHE); + colormap = R_GetTranslationColormap(skinnum, color, 0); LUA_PushUserdata(L, colormap, META_COLORMAP); // push as META_COLORMAP userdata, specifically for patches to use! return 1; } @@ -930,10 +937,14 @@ static int libd_getStringColormap(lua_State *L) { INT32 flags = luaL_checkinteger(L, 1); UINT8* colormap = NULL; + UINT8* lua_colormap = NULL; HUDONLY colormap = V_GetStringColormap(flags & V_CHARCOLORMASK); if (colormap) { - LUA_PushUserdata(L, colormap, META_COLORMAP); // push as META_COLORMAP userdata, specifically for patches to use! + lua_colormap = Z_Malloc(256 * sizeof(UINT8), PU_LUA, NULL); + memcpy(lua_colormap, colormap, 256 * sizeof(UINT8)); + + LUA_PushUserdata(L, lua_colormap, META_COLORMAP); // push as META_COLORMAP userdata, specifically for patches to use! return 1; } return 0; @@ -1243,6 +1254,9 @@ int LUA_HudLib(lua_State *L) lua_pushcfunction(L, colormap_set); lua_setfield(L, -2, "__newindex"); + + lua_pushcfunction(L, colormap_free); + lua_setfield(L, -2, "__gc"); lua_pop(L,1); luaL_newmetatable(L, META_PATCH); From 4717261459efb5861943cb46a65b0038b5b9eb3c Mon Sep 17 00:00:00 2001 From: Jaime Ita Passos Date: Sat, 19 Dec 2020 17:32:45 -0300 Subject: [PATCH 0488/1080] Optimize Picture_GetPatchPixel --- src/r_picformats.c | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/src/r_picformats.c b/src/r_picformats.c index f87362c76..eeebb94fd 100644 --- a/src/r_picformats.c +++ b/src/r_picformats.c @@ -540,9 +540,7 @@ void *Picture_GetPatchPixel( { fixed_t ofs; column_t *column; - UINT8 *s8 = NULL; - UINT16 *s16 = NULL; - UINT32 *s32 = NULL; + INT32 inbpp = Picture_FormatBPP(informat); softwarepatch_t *doompatch = (softwarepatch_t *)patch; boolean isdoompatch = Picture_IsDoomPatchFormat(informat); INT16 width; @@ -566,30 +564,36 @@ void *Picture_GetPatchPixel( while (column->topdelta != 0xff) { + UINT8 *s8 = NULL; + UINT16 *s16 = NULL; + UINT32 *s32 = NULL; + topdelta = column->topdelta; if (topdelta <= prevdelta) topdelta += prevdelta; prevdelta = topdelta; - s8 = (UINT8 *)(column) + 3; - if (Picture_FormatBPP(informat) == PICDEPTH_32BPP) - s32 = (UINT32 *)s8; - else if (Picture_FormatBPP(informat) == PICDEPTH_16BPP) - s16 = (UINT16 *)s8; - for (ofs = 0; ofs < column->length; ofs++) + + ofs = (y - topdelta); + + if (y >= topdelta && ofs < column->length) { - if ((topdelta + ofs) == y) + s8 = (UINT8 *)(column) + 3; + switch (inbpp) { - if (Picture_FormatBPP(informat) == PICDEPTH_32BPP) + case PICDEPTH_32BPP: + s32 = (UINT32 *)s8; return &s32[ofs]; - else if (Picture_FormatBPP(informat) == PICDEPTH_16BPP) + case PICDEPTH_16BPP: + s16 = (UINT16 *)s8; return &s16[ofs]; - else // PICDEPTH_8BPP + default: // PICDEPTH_8BPP return &s8[ofs]; } } - if (Picture_FormatBPP(informat) == PICDEPTH_32BPP) + + if (inbpp == PICDEPTH_32BPP) column = (column_t *)((UINT32 *)column + column->length); - else if (Picture_FormatBPP(informat) == PICDEPTH_16BPP) + else if (inbpp == PICDEPTH_16BPP) column = (column_t *)((UINT16 *)column + column->length); else column = (column_t *)((UINT8 *)column + column->length); From 1254f691ee6d7262865c71d7c554c6300ffc7849 Mon Sep 17 00:00:00 2001 From: Jaime Ita Passos Date: Sat, 19 Dec 2020 17:40:18 -0300 Subject: [PATCH 0489/1080] Fix unused variable warning when USE_APNG is not defined --- src/m_misc.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/m_misc.c b/src/m_misc.c index ad2d133ab..17a398b83 100644 --- a/src/m_misc.c +++ b/src/m_misc.c @@ -165,7 +165,9 @@ consvar_t cv_zlib_window_bitsa = CVAR_INIT ("apng_window_size", "32k", CV_SAVE, consvar_t cv_apng_delay = CVAR_INIT ("apng_speed", "1x", CV_SAVE, apng_delay_t, NULL); consvar_t cv_apng_downscale = CVAR_INIT ("apng_downscale", "On", CV_SAVE, CV_OnOff, NULL); +#ifdef USE_APNG static boolean apng_downscale = false; // So nobody can do something dumb like changing cvars mid output +#endif boolean takescreenshot = false; // Take a screenshot this tic From f9e5681a6b29cc87e220cd7c224f605cd2e843a6 Mon Sep 17 00:00:00 2001 From: GoldenTails Date: Sat, 19 Dec 2020 20:33:29 -0600 Subject: [PATCH 0490/1080] Actually check for a player smh --- src/p_enemy.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/p_enemy.c b/src/p_enemy.c index 203e04af1..1cc1686b1 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -7521,7 +7521,7 @@ void A_Boss2PogoTarget(mobj_t *actor) } // Target hit, retreat! - if (actor->target->player->powers[pw_flashing] > TICRATE || actor->flags2 & MF2_FRET) + if ((actor->target->player && actor->target->player->powers[pw_flashing] > TICRATE) || actor->flags2 & MF2_FRET) { UINT8 prandom = P_RandomByte(); actor->z++; // unstick from the floor @@ -7532,7 +7532,7 @@ void A_Boss2PogoTarget(mobj_t *actor) // Try to land on top of the player. else if (P_AproxDistance(actor->x-actor->target->x, actor->y-actor->target->y) < FixedMul(512*FRACUNIT, actor->scale)) { - fixed_t airtime, gravityadd, zoffs; + fixed_t airtime, gravityadd, zoffs, height; // check gravity in the sector (for later math) P_CheckGravity(actor, true); @@ -7554,7 +7554,13 @@ void A_Boss2PogoTarget(mobj_t *actor) // Remember, kids! // Reduced down Calculus lets you avoid bad 'logic math' loops! //airtime = FixedDiv(-actor->momz<<1, gravityadd)<<1; // going from 0 to 0 is much simpler - zoffs = (P_GetPlayerHeight(actor->target->player)>>1) + (actor->target->floorz - actor->floorz); // offset by the difference in floor height plus half the player height, + + if (actor->target->player) + height = P_GetPlayerHeight(actor->target->player) >> 1; + else + height = actor->target->height >> 1; + + zoffs = height + (actor->target->floorz - actor->floorz); // offset by the difference in floor height plus half the player height, airtime = FixedDiv((-actor->momz - FixedSqrt(FixedMul(actor->momz,actor->momz)+zoffs)), gravityadd)<<1; // to try and land on their head rather than on their feet actor->angle = R_PointToAngle2(actor->x, actor->y, actor->target->x, actor->target->y); From 60564197afa4629a5f71bba673381e52874320e3 Mon Sep 17 00:00:00 2001 From: GoldenTails Date: Sat, 19 Dec 2020 21:12:09 -0600 Subject: [PATCH 0491/1080] Have A_DetonChase check for a player too --- src/p_enemy.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/p_enemy.c b/src/p_enemy.c index 1cc1686b1..898dcd3cc 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -5920,13 +5920,18 @@ void A_DetonChase(mobj_t *actor) if (actor->reactiontime == -42) { - fixed_t xyspeed; + fixed_t xyspeed, speed; + + if (actor->target->player) + speed = actor->target->player->normalspeed; + else + speed = actor->target->info->speed; actor->reactiontime = -42; exact = actor->movedir>>ANGLETOFINESHIFT; - xyspeed = FixedMul(FixedMul(actor->tracer->player->normalspeed,3*FRACUNIT/4), FINECOSINE(exact)); - actor->momz = FixedMul(FixedMul(actor->tracer->player->normalspeed,3*FRACUNIT/4), FINESINE(exact)); + xyspeed = FixedMul(FixedMul(speed,3*FRACUNIT/4), FINECOSINE(exact)); + actor->momz = FixedMul(FixedMul(speed,3*FRACUNIT/4), FINESINE(exact)); exact = actor->angle>>ANGLETOFINESHIFT; actor->momx = FixedMul(xyspeed, FINECOSINE(exact)); From 08146c9cad42f8a30a6b54386194ed22825d024a Mon Sep 17 00:00:00 2001 From: GoldenTails Date: Sat, 19 Dec 2020 21:30:13 -0600 Subject: [PATCH 0492/1080] Have A_ThrownRing check for a player too --- src/p_enemy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_enemy.c b/src/p_enemy.c index 898dcd3cc..3e7f52a3f 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -4912,7 +4912,7 @@ void A_ThrownRing(mobj_t *actor) } if (actor->tracer && (actor->tracer->health) - && (actor->tracer->player->powers[pw_shield] & SH_PROTECTELECTRIC))// Already found someone to follow. + && (actor->tracer->player && actor->tracer->player->powers[pw_shield] & SH_PROTECTELECTRIC))// Already found someone to follow. { const INT32 temp = actor->threshold; actor->threshold = 32000; From 6c330bbf16a6dba4919d538d418b6b60f94b8244 Mon Sep 17 00:00:00 2001 From: Hannu Hanhi Date: Mon, 21 Dec 2020 00:03:20 +0200 Subject: [PATCH 0493/1080] Fix video mode 0 not getting centered --- src/screen.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/screen.c b/src/screen.c index 9d36eee39..744523dab 100644 --- a/src/screen.c +++ b/src/screen.c @@ -217,7 +217,7 @@ void SCR_SetMode(void) // Set the video mode in the video interface. if (setmodeneeded) - VID_SetMode(--setmodeneeded); + VID_SetMode(setmodeneeded - 1); V_SetPalette(0); From 971518d22e2c7dcde18d44568bb256581db72370 Mon Sep 17 00:00:00 2001 From: GoldenTails Date: Sun, 20 Dec 2020 21:43:14 -0600 Subject: [PATCH 0494/1080] Have Lua_OnChange restore the stack to what it was before it was called. So we don't get Luas with access to LUA_GetErrorMessage. --- src/lua_consolelib.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lua_consolelib.c b/src/lua_consolelib.c index 84bfeaee2..5344fee76 100644 --- a/src/lua_consolelib.c +++ b/src/lua_consolelib.c @@ -285,8 +285,8 @@ static void Lua_OnChange(void) /// \todo Network this! XD_LUAVAR - lua_settop(gL, 0); // Just in case... lua_pushcfunction(gL, LUA_GetErrorMessage); + lua_insert(gL, 1); // Because LUA_Call wants it at index 1. // From CV_OnChange registry field, get the function for this cvar by name. lua_getfield(gL, LUA_REGISTRYINDEX, "CV_OnChange"); @@ -301,6 +301,7 @@ static void Lua_OnChange(void) LUA_Call(gL, 1, 0, 1); // call function(cvar) lua_pop(gL, 1); // pop CV_OnChange table + lua_remove(gL, 1); // remove LUA_GetErrorMessage } static int lib_cvRegisterVar(lua_State *L) From 147c38c5ce489e2760f922ec98214005cfa9f99b Mon Sep 17 00:00:00 2001 From: GoldenTails Date: Mon, 21 Dec 2020 02:03:44 -0600 Subject: [PATCH 0495/1080] Make sliding against objects actually work --- src/p_map.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/p_map.c b/src/p_map.c index b934e3255..a1cad524e 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -2257,6 +2257,8 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) { if (!P_BlockThingsIterator(bx, by, PIT_CheckThing)) blockval = false; + else + tmhitthing = tmfloorthing; if (P_MobjWasRemoved(tmthing)) return false; } From abf0ca6690a3cb66b89030fda85ad24ccfa7b9b1 Mon Sep 17 00:00:00 2001 From: Jaime Ita Passos Date: Mon, 21 Dec 2020 17:19:07 -0300 Subject: [PATCH 0496/1080] Fix "missing initializer" warnings/errors in CVAR_INIT macros --- src/command.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/command.h b/src/command.h index ea5593395..d4033e6ef 100644 --- a/src/command.h +++ b/src/command.h @@ -158,7 +158,7 @@ typedef struct consvar_s //NULL, NULL, 0, NULL, NULL |, 0, NULL, NULL, 0, 0, NUL /* name, defaultvalue, flags, PossibleValue, func */ #define CVAR_INIT( ... ) \ -{ __VA_ARGS__, 0, NULL, NULL, {0}, 0U, (char)0, NULL } +{ __VA_ARGS__, 0, NULL, NULL, {0, {NULL}}, 0U, (char)0, NULL } #ifdef OLD22DEMOCOMPAT typedef struct old_demo_var old_demo_var_t; From ad8abcef0942d8deb055908cbd9d145314e78eca Mon Sep 17 00:00:00 2001 From: SwitchKaze Date: Mon, 21 Dec 2020 15:48:49 -0600 Subject: [PATCH 0497/1080] Return nil on skincolor invalid field access --- src/lua_infolib.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/lua_infolib.c b/src/lua_infolib.c index 4c6ef3528..6e86f47b7 100644 --- a/src/lua_infolib.c +++ b/src/lua_infolib.c @@ -1635,8 +1635,10 @@ static int skincolor_get(lua_State *L) lua_pushinteger(L, info->chatcolor); else if (fastcmp(field,"accessible")) lua_pushboolean(L, info->accessible); - else + else { CONS_Debug(DBG_LUA, M_GetText("'%s' has no field named '%s'; returning nil.\n"), "skincolor_t", field); + return 0; + } return 1; } From 4d6b677765d48b84addbf107caa7bb5e19f4715f Mon Sep 17 00:00:00 2001 From: James R Date: Wed, 23 Dec 2020 03:02:31 +0000 Subject: [PATCH 0498/1080] Revert "Merge branch 'plane-sorting-fix-part-3' into 'next'" This reverts merge request !1235 --- src/r_things.c | 62 ++++++++++++++++++++++++++++++++++++-------------- src/r_things.h | 4 +++- 2 files changed, 48 insertions(+), 18 deletions(-) diff --git a/src/r_things.c b/src/r_things.c index 083373927..30bf15f85 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -1078,6 +1078,14 @@ static void R_SplitSprite(vissprite_t *sprite) sprite->sz = cutfrac; newsprite->szt = (INT16)(sprite->sz - 1); + if (testheight < sprite->pzt && testheight > sprite->pz) + sprite->pz = newsprite->pzt = testheight; + else + { + newsprite->pz = newsprite->gz; + newsprite->pzt = newsprite->gzt; + } + newsprite->szt -= 8; newsprite->cut |= SC_TOP; @@ -1300,12 +1308,16 @@ static void R_ProjectDropShadow(mobj_t *thing, vissprite_t *vis, fixed_t scale, shadow->patch = patch; shadow->heightsec = vis->heightsec; + shadow->thingheight = FRACUNIT; + shadow->pz = groundz + (isflipped ? -shadow->thingheight : 0); + shadow->pzt = shadow->pz + shadow->thingheight; + shadow->mobjflags = 0; shadow->sortscale = vis->sortscale; shadow->dispoffset = vis->dispoffset - 5; shadow->gx = thing->x; shadow->gy = thing->y; - shadow->gzt = groundz + patch->height * shadowyscale / 2; + shadow->gzt = (isflipped ? shadow->pzt : shadow->pz) + patch->height * shadowyscale / 2; shadow->gz = shadow->gzt - patch->height * shadowyscale; shadow->texturemid = FixedMul(thing->scale, FixedDiv(shadow->gzt - viewz, shadowyscale)); if (thing->skin && ((skin_t *)thing->skin)->flags & SF_HIRES) @@ -1935,6 +1947,9 @@ static void R_ProjectSprite(mobj_t *thing) vis->gy = thing->y; vis->gz = gz; vis->gzt = gzt; + vis->thingheight = thing->height; + vis->pz = thing->z; + vis->pzt = vis->pz + vis->thingheight; vis->texturemid = FixedDiv(gzt - viewz, spriteyscale); vis->scalestep = scalestep; vis->paperoffset = paperoffset; @@ -2151,6 +2166,9 @@ static void R_ProjectPrecipitationSprite(precipmobj_t *thing) vis->gy = thing->y; vis->gz = gz; vis->gzt = gzt; + vis->thingheight = 4*FRACUNIT; + vis->pz = thing->z; + vis->pzt = vis->pz + vis->thingheight; vis->texturemid = vis->gzt - viewz; vis->scalestep = 0; vis->paperdistance = 0; @@ -2544,15 +2562,19 @@ static void R_CreateDrawNodes(maskcount_t* mask, drawnode_t* head, boolean temps planeobjectz = P_GetZAt(r2->plane->slope, rover->gx, rover->gy, r2->plane->height); planecameraz = P_GetZAt(r2->plane->slope, viewx, viewy, r2->plane->height); - // bird: if any part of the sprite peeks in front the plane - if (planecameraz < viewz) + if (rover->mobjflags & MF_NOCLIPHEIGHT) { - if (rover->gzt >= planeobjectz) + //Objects with NOCLIPHEIGHT can appear halfway in. + if (planecameraz < viewz && rover->pz+(rover->thingheight/2) >= planeobjectz) + continue; + if (planecameraz > viewz && rover->pzt-(rover->thingheight/2) <= planeobjectz) continue; } - else if (planecameraz > viewz) + else { - if (rover->gz <= planeobjectz) + if (planecameraz < viewz && rover->pz >= planeobjectz) + continue; + if (planecameraz > viewz && rover->pzt <= planeobjectz) continue; } @@ -2585,7 +2607,7 @@ static void R_CreateDrawNodes(maskcount_t* mask, drawnode_t* head, boolean temps } else if (r2->thickseg) { - //fixed_t topplaneobjectz, topplanecameraz, botplaneobjectz, botplanecameraz; + fixed_t topplaneobjectz, topplanecameraz, botplaneobjectz, botplanecameraz; if (rover->x1 > r2->thickseg->x2 || rover->x2 < r2->thickseg->x1) continue; @@ -2596,11 +2618,6 @@ static void R_CreateDrawNodes(maskcount_t* mask, drawnode_t* head, boolean temps if (scale <= rover->sortscale) continue; - // bird: Always sort sprites behind segs. This helps the plane - // sorting above too. Basically if the sprite gets sorted behind - // the seg here, it will be behind the plane too, since planes - // are added after segs in the list. -#if 0 topplaneobjectz = P_GetFFloorTopZAt (r2->ffloor, rover->gx, rover->gy); topplanecameraz = P_GetFFloorTopZAt (r2->ffloor, viewx, viewy); botplaneobjectz = P_GetFFloorBottomZAt(r2->ffloor, rover->gx, rover->gy); @@ -2609,7 +2626,6 @@ static void R_CreateDrawNodes(maskcount_t* mask, drawnode_t* head, boolean temps if ((topplanecameraz > viewz && botplanecameraz < viewz) || (topplanecameraz < viewz && rover->gzt < topplaneobjectz) || (botplanecameraz > viewz && rover->gz > botplaneobjectz)) -#endif { entry = R_CreateDrawNode(NULL); (entry->prev = r2->prev)->next = entry; @@ -2650,11 +2666,23 @@ static void R_CreateDrawNodes(maskcount_t* mask, drawnode_t* head, boolean temps if (!behind) { - // FIXME: calculate gz and gzt for splats properly and use that - if (rover->mobj->z < viewz) - infront = (r2->sprite->mobj->z >= rover->mobj->z); + fixed_t z1 = 0, z2 = 0; + + if (rover->mobj->z - viewz > 0) + { + z1 = rover->pz; + z2 = r2->sprite->pz; + } else - infront = (r2->sprite->mobj->z <= rover->mobj->z); + { + z1 = r2->sprite->pz; + z2 = rover->pz; + } + + z1 -= viewz; + z2 -= viewz; + + infront = (z1 >= z2); } } else diff --git a/src/r_things.h b/src/r_things.h index d15ae818c..f960089a1 100644 --- a/src/r_things.h +++ b/src/r_things.h @@ -151,7 +151,8 @@ typedef struct vissprite_s INT32 x1, x2; fixed_t gx, gy; // for line side calculation - fixed_t gz, gzt; // global bottom/top for silhouette clipping and sorting with 3D floors + fixed_t gz, gzt; // global bottom/top for silhouette clipping + fixed_t pz, pzt; // physical bottom/top for sorting with 3D floors fixed_t startfrac; // horizontal position of x1 fixed_t scale; @@ -185,6 +186,7 @@ typedef struct vissprite_s fixed_t xscale; // Precalculated top and bottom screen coords for the sprite. + fixed_t thingheight; // The actual height of the thing (for 3D floors) sector_t *sector; // The sector containing the thing. INT16 sz, szt; From 0d1973075deafd5272f0cb9801f273d16e1736d9 Mon Sep 17 00:00:00 2001 From: GoldenTails Date: Thu, 24 Dec 2020 03:22:08 -0600 Subject: [PATCH 0499/1080] Nice UDB config there, SRB2. --- extras/conf/udb/Includes/SRB222_things.cfg | 1 + 1 file changed, 1 insertion(+) diff --git a/extras/conf/udb/Includes/SRB222_things.cfg b/extras/conf/udb/Includes/SRB222_things.cfg index 0ea452155..113c1a4c2 100644 --- a/extras/conf/udb/Includes/SRB222_things.cfg +++ b/extras/conf/udb/Includes/SRB222_things.cfg @@ -1247,6 +1247,7 @@ patterns sprite = "SPHRA0"; width = 96; height = 192; + } 609 { title = "Circle of Rings and Spheres (Big)"; From 9327e96e4d4f4d15421b71bbba8a9c44c4244951 Mon Sep 17 00:00:00 2001 From: GoldenTails Date: Sat, 26 Dec 2020 17:19:14 -0600 Subject: [PATCH 0500/1080] Pause the console refresh while startup wads are loading. --- src/console.c | 13 +++++++++++++ src/console.h | 3 +++ src/d_main.c | 4 ++++ 3 files changed, 20 insertions(+) diff --git a/src/console.c b/src/console.c index c7bfe0fe1..3785136af 100644 --- a/src/console.c +++ b/src/console.c @@ -484,6 +484,19 @@ void CON_Init(void) Unlock_state(); } } + +void CON_StartRefresh(void) +{ + if (con_startup) + con_refresh = true; +} + +void CON_StopRefresh(void) +{ + if (con_startup) + con_refresh = false; +} + // Console input initialization // static void CON_InputInit(void) diff --git a/src/console.h b/src/console.h index 0296f4f6e..db27d9358 100644 --- a/src/console.h +++ b/src/console.h @@ -16,6 +16,9 @@ void CON_Init(void); +void CON_StartRefresh(void); +void CON_StopRefresh(void); + boolean CON_Responder(event_t *ev); #ifdef HAVE_THREADS diff --git a/src/d_main.c b/src/d_main.c index a89f4ed2d..7d25208e7 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -1275,10 +1275,14 @@ void D_SRB2Main(void) I_RegisterSysCommands(); + CON_StopRefresh(); // Temporarily stop refreshing the screen for wad loading + CONS_Printf("W_InitMultipleFiles(): Adding extra PWADs.\n"); W_InitMultipleFiles(startuppwads); D_CleanFile(startuppwads); + CON_StartRefresh(); // Restart the refresh! + CONS_Printf("HU_LoadGraphics()...\n"); HU_LoadGraphics(); From 50d46e1fa634abd6672ca6a8bf43daaec528fa80 Mon Sep 17 00:00:00 2001 From: GoldenTails Date: Sun, 27 Dec 2020 00:21:09 -0600 Subject: [PATCH 0501/1080] Set the target of a spawned ghost to where it came from. --- src/p_user.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/p_user.c b/src/p_user.c index a70dceb8b..8361004d6 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -2016,6 +2016,8 @@ mobj_t *P_SpawnGhostMobj(mobj_t *mobj) { mobj_t *ghost = P_SpawnMobj(mobj->x, mobj->y, mobj->z, MT_GHOST); + P_SetTarget(&ghost->target, mobj); + P_SetScale(ghost, mobj->scale); ghost->destscale = mobj->scale; From 0de3a64b59e6647a97efef630450f3565d06e4bd Mon Sep 17 00:00:00 2001 From: LJ Sonic Date: Tue, 29 Dec 2020 21:36:15 +0100 Subject: [PATCH 0502/1080] Let Lua toggle the crosshair --- src/hu_stuff.c | 19 +++++++++++-------- src/lua_hud.h | 1 + src/lua_hudlib.c | 1 + 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 7e9144f98..0b24d0690 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -2109,15 +2109,18 @@ void HU_Drawer(void) return; // draw the crosshair, not when viewing demos nor with chasecam - if (!automapactive && cv_crosshair.value && !demoplayback && - (!camera.chase || ticcmd_ztargetfocus[0]) - && !players[displayplayer].spectator) - HU_DrawCrosshair(); + if (LUA_HudEnabled(hud_crosshair)) + { + if (!automapactive && cv_crosshair.value && !demoplayback && + (!camera.chase || ticcmd_ztargetfocus[0]) + && !players[displayplayer].spectator) + HU_DrawCrosshair(); - if (!automapactive && cv_crosshair2.value && !demoplayback && - (!camera2.chase || ticcmd_ztargetfocus[1]) - && !players[secondarydisplayplayer].spectator) - HU_DrawCrosshair2(); + if (!automapactive && cv_crosshair2.value && !demoplayback && + (!camera2.chase || ticcmd_ztargetfocus[1]) + && !players[secondarydisplayplayer].spectator) + HU_DrawCrosshair2(); + } // draw desynch text if (hu_redownloadinggamestate) diff --git a/src/lua_hud.h b/src/lua_hud.h index 4a7c596c8..1e9dca00b 100644 --- a/src/lua_hud.h +++ b/src/lua_hud.h @@ -13,6 +13,7 @@ enum hud { hud_stagetitle = 0, hud_textspectator, + hud_crosshair, // Singleplayer / Co-op hud_score, hud_time, diff --git a/src/lua_hudlib.c b/src/lua_hudlib.c index e58cd4a58..8d451e99c 100644 --- a/src/lua_hudlib.c +++ b/src/lua_hudlib.c @@ -39,6 +39,7 @@ static UINT8 hudAvailable; // hud hooks field static const char *const hud_disable_options[] = { "stagetitle", "textspectator", + "crosshair", "score", "time", From ed82b94e64139a12d21376800cb123585f1ebc40 Mon Sep 17 00:00:00 2001 From: Hannu Hanhi Date: Tue, 29 Dec 2020 23:29:00 +0200 Subject: [PATCH 0503/1080] Take slopes into account in FOF wall cutoff in HWR_ProcessSeg --- src/hardware/hw_main.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index a7e37d231..5de6f8e11 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -1104,7 +1104,6 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom SLOPEPARAMS(gl_backsector->c_slope, worldhigh, worldhighslope, gl_backsector->ceilingheight) SLOPEPARAMS(gl_backsector->f_slope, worldlow, worldlowslope, gl_backsector->floorheight) -#undef SLOPEPARAMS // hack to allow height changes in outdoor areas // This is what gets rid of the upper textures if there should be sky @@ -1589,14 +1588,18 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom { ffloor_t * rover; fixed_t highcut = 0, lowcut = 0; + fixed_t lowcutslope, highcutslope; + + // Used for height comparisons and etc across FOFs and slopes + fixed_t high1, highslope1, low1, lowslope1; INT32 texnum; line_t * newline = NULL; // Multi-Property FOF - ///TODO add slope support (fixing cutoffs, proper wall clipping) - maybe just disable highcut/lowcut if either sector or FOF has a slope - /// to allow fun plane intersecting in OGL? But then people would abuse that and make software look bad. :C - highcut = gl_frontsector->ceilingheight < gl_backsector->ceilingheight ? gl_frontsector->ceilingheight : gl_backsector->ceilingheight; - lowcut = gl_frontsector->floorheight > gl_backsector->floorheight ? gl_frontsector->floorheight : gl_backsector->floorheight; + lowcut = max(worldbottom, worldlow); + highcut = min(worldtop, worldhigh); + lowcutslope = max(worldbottomslope, worldlowslope); + highcutslope = min(worldtopslope, worldhighslope); if (gl_backsector->ffloors) { @@ -1618,7 +1621,11 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom continue; if (!(rover->flags & FF_ALLSIDES) && rover->flags & FF_INVERTSIDES) continue; - if (*rover->topheight < lowcut || *rover->bottomheight > highcut) + + 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; texnum = R_GetTextureNum(sides[rover->master->sidenum[0]].midtexture); @@ -1764,7 +1771,11 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom continue; if (!(rover->flags & FF_ALLSIDES || rover->flags & FF_INVERTSIDES)) continue; - if (*rover->topheight < lowcut || *rover->bottomheight > highcut) + + 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; texnum = R_GetTextureNum(sides[rover->master->sidenum[0]].midtexture); @@ -1856,6 +1867,7 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom } } } +#undef SLOPEPARAMS //Hurdler: end of 3d-floors test } From c19539248aa02b64a4cb1c8ecebfde1d4c648eed Mon Sep 17 00:00:00 2001 From: katsy Date: Thu, 31 Dec 2020 04:38:26 -0600 Subject: [PATCH 0504/1080] add sprung flag to steam --- src/p_map.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/p_map.c b/src/p_map.c index b934e3255..7ca6d653a 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -511,6 +511,7 @@ static void P_DoFanAndGasJet(mobj_t *spring, mobj_t *object) if (spring->state != &states[S_STEAM1]) // Only when it bursts break; + object->eflags |= MFE_SPRUNG; object->momz = flipval*FixedMul(speed, FixedSqrt(FixedMul(spring->scale, object->scale))); // scale the speed with both objects' scales, just like with springs! if (p) From 3b4a52b8b85a7c17127f92423d90b273710ca04f Mon Sep 17 00:00:00 2001 From: GoldenTails Date: Mon, 4 Jan 2021 00:03:18 -0600 Subject: [PATCH 0505/1080] Allows Lua to transport you to a different map in place of a Special Stage. --- src/g_game.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index 6171c7b72..e204cdb2c 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -3920,12 +3920,13 @@ static void G_DoCompleted(void) { token--; - for (i = 0; i < 7; i++) - if (!(emeralds & (1< Date: Mon, 4 Jan 2021 18:10:41 -0300 Subject: [PATCH 0506/1080] Allow water running in reverse gravity --- src/p_mobj.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index 58124fb9b..5cde1639c 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -3188,13 +3188,16 @@ boolean P_SceneryZMovement(mobj_t *mo) // boolean P_CanRunOnWater(player_t *player, ffloor_t *rover) { - fixed_t topheight = P_GetFFloorTopZAt(rover, player->mo->x, player->mo->y); + boolean flip = player->mo->eflags & MFE_VERTICALFLIP; + fixed_t surfaceheight = flip ? P_GetFFloorBottomZAt(rover, player->mo->x, player->mo->y) : P_GetFFloorTopZAt(rover, player->mo->x, player->mo->y); + fixed_t playerbottom = flip ? (player->mo->z + player->mo->height) : player->mo->z; + boolean doifit = flip ? (surfaceheight - player->mo->floorz >= player->mo->height) : (player->mo->ceilingz - surfaceheight >= player->mo->height); if (!player->powers[pw_carry] && !player->homing - && ((player->powers[pw_super] || player->charflags & SF_RUNONWATER || player->dashmode >= DASHMODE_THRESHOLD) && player->mo->ceilingz-topheight >= player->mo->height) + && ((player->powers[pw_super] || player->charflags & SF_RUNONWATER || player->dashmode >= DASHMODE_THRESHOLD) && doifit) && (rover->flags & FF_SWIMMABLE) && !(player->pflags & PF_SPINNING) && player->speed > FixedMul(player->runspeed, player->mo->scale) && !(player->pflags & PF_SLIDING) - && abs(player->mo->z - topheight) < FixedMul(30*FRACUNIT, player->mo->scale)) + && abs(playerbottom - surfaceheight) < FixedMul(30*FRACUNIT, player->mo->scale)) return true; return false; From 70eb3228f8af551ef6fcec91a5481c311bd4ad6b Mon Sep 17 00:00:00 2001 From: GoldenTails Date: Tue, 5 Jan 2021 13:20:02 -0600 Subject: [PATCH 0507/1080] Pressing A Key Combination In The Console Crashes SRB2 get stryder7x in on this --- src/console.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/console.c b/src/console.c index c7bfe0fe1..121605b10 100644 --- a/src/console.c +++ b/src/console.c @@ -826,6 +826,12 @@ static void CON_InputDelSelection(void) Lock_state(); + if (!input_cur) + { + Unlock_state(); + return; + } + if (input_cur > input_sel) { start = input_sel; From c8627464c9ace0d5939edf76a610dff458f3a95c Mon Sep 17 00:00:00 2001 From: Steel Titanium Date: Wed, 6 Jan 2021 19:40:30 -0500 Subject: [PATCH 0508/1080] Check if GME_VERSION is defined. I made the assumption it would always be defined, which won't always be the case. --- src/sdl/mixer_sound.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index 5cae48077..412a21ea0 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -1298,7 +1298,7 @@ boolean I_PlaySong(boolean looping) if (gme) { gme_equalizer_t eq = {GME_TREBLE, GME_BASS, 0,0,0,0,0,0,0,0}; -#if GME_VERSION >= 0x000603 +#if defined (GME_VERSION) && GME_VERSION >= 0x000603 if (looping) gme_set_autoload_playback_limit(gme, 0); #endif From 679bf5f999b8574a36a99b62b99824bb1239a635 Mon Sep 17 00:00:00 2001 From: Zwip-Zwap Zapony Date: Fri, 8 Jan 2021 16:25:10 +0100 Subject: [PATCH 0509/1080] Fix CA_BOUNCE when flipped Fix P_DoAbilityBounce() always using "max", instead of "min" while upside-down and "max" while not --- src/p_user.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index a70dceb8b..5352a969c 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -4880,22 +4880,28 @@ void P_DoBubbleBounce(player_t *player) // void P_DoAbilityBounce(player_t *player, boolean changemomz) { - fixed_t prevmomz; if (player->mo->state-states == S_PLAY_BOUNCE_LANDING) return; + if (changemomz) { - fixed_t minmomz; - prevmomz = player->mo->momz; + fixed_t prevmomz = player->mo->momz, minmomz; + if (P_MobjFlip(player->mo)*prevmomz < 0) prevmomz = 0; else if (player->mo->eflags & MFE_UNDERWATER) prevmomz /= 2; + P_DoJump(player, false); player->pflags &= ~(PF_STARTJUMP|PF_JUMPED); minmomz = FixedMul(player->mo->momz, 3*FRACUNIT/2); - player->mo->momz = max(minmomz, (minmomz + prevmomz)/2); + + if (player->mo->eflags & MFE_VERTICALFLIP) // Use "min" or "max" depending on if the player is flipped + player->mo->momz = min(minmomz, (minmomz + prevmomz)/2); + else + player->mo->momz = max(minmomz, (minmomz + prevmomz)/2); } + S_StartSound(player->mo, sfx_boingf); P_SetPlayerMobjState(player->mo, S_PLAY_BOUNCE_LANDING); player->pflags |= PF_BOUNCING|PF_THOKKED; From 59bc197f3252bdfff838614bba7cd771d4f7440c Mon Sep 17 00:00:00 2001 From: GoldenTails Date: Sun, 10 Jan 2021 10:01:31 -0600 Subject: [PATCH 0510/1080] Fix a divby0 when you have SF_MULTIABILITY, CA_DOUBLEJUMP, and actionspd -FRACUNIT. --- 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 a70dceb8b..a9e1fe9a2 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -4499,7 +4499,7 @@ void P_DoJump(player_t *player, boolean soundandstate) if (twodlevel || (player->mo->flags2 & MF2_TWOD)) factor += player->jumpfactor / 10; - if (player->charflags & SF_MULTIABILITY && player->charability == CA_DOUBLEJUMP) + if (player->charflags & SF_MULTIABILITY && player->charability == CA_DOUBLEJUMP && (player->actionspd >> FRACBITS) != -1) factor -= max(0, player->secondjump * player->jumpfactor / ((player->actionspd >> FRACBITS) + 1)); // Reduce the jump height each time //if (maptol & TOL_NIGHTS) From eb1e7eff8f2d2a73e833e557f807a810e6ef946a Mon Sep 17 00:00:00 2001 From: Hannu Hanhi Date: Sun, 10 Jan 2021 20:52:03 +0200 Subject: [PATCH 0511/1080] Take slopes into account even more in FOF wall cutoff in HWR_ProcessSeg --- src/hardware/hw_main.c | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 5de6f8e11..671a21017 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -1641,10 +1641,17 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom hS = P_GetFFloorTopZAt (rover, v2x, v2y); l = P_GetFFloorBottomZAt(rover, v1x, v1y); lS = P_GetFFloorBottomZAt(rover, v2x, v2y); - if (!(*rover->t_slope) && !gl_frontsector->c_slope && !gl_backsector->c_slope && h > highcut) - h = hS = highcut; - if (!(*rover->b_slope) && !gl_frontsector->f_slope && !gl_backsector->f_slope && l < lowcut) - l = lS = lowcut; + // 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 @@ -1790,10 +1797,17 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom hS = P_GetFFloorTopZAt (rover, v2x, v2y); l = P_GetFFloorBottomZAt(rover, v1x, v1y); lS = P_GetFFloorBottomZAt(rover, v2x, v2y); - if (!(*rover->t_slope) && !gl_frontsector->c_slope && !gl_backsector->c_slope && h > highcut) - h = hS = highcut; - if (!(*rover->b_slope) && !gl_frontsector->f_slope && !gl_backsector->f_slope && l < lowcut) - l = lS = lowcut; + // 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 From d252f074b7cd28bea837552b8ff01314141058d0 Mon Sep 17 00:00:00 2001 From: Hannu Hanhi Date: Sun, 10 Jan 2021 21:33:54 +0200 Subject: [PATCH 0512/1080] Render midtextures on two-sided lines with a z-buffer offset This will fix z-fighting issues when they overlap with FOFs. --- src/hardware/hw_main.c | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index a7e37d231..ca4d3e258 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -831,7 +831,7 @@ static float HWR_ClipViewSegment(INT32 x, polyvertex_t *v1, polyvertex_t *v2) // // HWR_SplitWall // -static void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, FSurfaceInfo* Surf, INT32 cutflag, ffloor_t *pfloor) +static void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, FSurfaceInfo* Surf, INT32 cutflag, ffloor_t *pfloor, FBITFIELD polyflags) { /* SoM: split up and light walls according to the lightlist. This may also include leaving out parts @@ -969,11 +969,11 @@ static void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, wallVerts[1].y = endbot; if (cutflag & FF_FOG) - HWR_AddTransparentWall(wallVerts, Surf, texnum, PF_Fog|PF_NoTexture, true, lightnum, colormap); + HWR_AddTransparentWall(wallVerts, Surf, texnum, PF_Fog|PF_NoTexture|polyflags, true, lightnum, colormap); else if (cutflag & FF_TRANSLUCENT) - HWR_AddTransparentWall(wallVerts, Surf, texnum, PF_Translucent, false, lightnum, colormap); + HWR_AddTransparentWall(wallVerts, Surf, texnum, PF_Translucent|polyflags, false, lightnum, colormap); else - HWR_ProjectWall(wallVerts, Surf, PF_Masked, lightnum, colormap); + HWR_ProjectWall(wallVerts, Surf, PF_Masked|polyflags, lightnum, colormap); top = bot; endtop = endbot; @@ -998,11 +998,11 @@ static void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, wallVerts[1].y = endbot; if (cutflag & FF_FOG) - HWR_AddTransparentWall(wallVerts, Surf, texnum, PF_Fog|PF_NoTexture, true, lightnum, colormap); + HWR_AddTransparentWall(wallVerts, Surf, texnum, PF_Fog|PF_NoTexture|polyflags, true, lightnum, colormap); else if (cutflag & FF_TRANSLUCENT) - HWR_AddTransparentWall(wallVerts, Surf, texnum, PF_Translucent, false, lightnum, colormap); + HWR_AddTransparentWall(wallVerts, Surf, texnum, PF_Translucent|polyflags, false, lightnum, colormap); else - HWR_ProjectWall(wallVerts, Surf, PF_Masked, lightnum, colormap); + HWR_ProjectWall(wallVerts, Surf, PF_Masked|polyflags, lightnum, colormap); } // HWR_DrawSkyWall @@ -1183,7 +1183,7 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom wallVerts[1].y = FIXED_TO_FLOAT(worldhighslope); if (gl_frontsector->numlights) - HWR_SplitWall(gl_frontsector, wallVerts, gl_toptexture, &Surf, FF_CUTLEVEL, NULL); + HWR_SplitWall(gl_frontsector, wallVerts, gl_toptexture, &Surf, FF_CUTLEVEL, NULL, 0); else if (grTex->mipmap.flags & TF_TRANSPARENT) HWR_AddTransparentWall(wallVerts, &Surf, gl_toptexture, PF_Environment, false, lightnum, colormap); else @@ -1249,7 +1249,7 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom wallVerts[1].y = FIXED_TO_FLOAT(worldbottomslope); if (gl_frontsector->numlights) - HWR_SplitWall(gl_frontsector, wallVerts, gl_bottomtexture, &Surf, FF_CUTLEVEL, NULL); + HWR_SplitWall(gl_frontsector, wallVerts, gl_bottomtexture, &Surf, FF_CUTLEVEL, NULL, 0); else if (grTex->mipmap.flags & TF_TRANSPARENT) HWR_AddTransparentWall(wallVerts, &Surf, gl_bottomtexture, PF_Environment, false, lightnum, colormap); else @@ -1465,13 +1465,17 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom blendmode = HWR_TranstableToAlpha(gl_curline->polyseg->translucency, &Surf); } + // Render midtextures on two-sided lines with a z-buffer offset. + // This will cause the midtexture appear on top, if a FOF overlaps with it. + blendmode |= PF_Decal; + if (gl_frontsector->numlights) { if (!(blendmode & PF_Masked)) - HWR_SplitWall(gl_frontsector, wallVerts, gl_midtexture, &Surf, FF_TRANSLUCENT, NULL); + HWR_SplitWall(gl_frontsector, wallVerts, gl_midtexture, &Surf, FF_TRANSLUCENT, NULL, PF_Decal); else { - HWR_SplitWall(gl_frontsector, wallVerts, gl_midtexture, &Surf, FF_CUTLEVEL, NULL); + HWR_SplitWall(gl_frontsector, wallVerts, gl_midtexture, &Surf, FF_CUTLEVEL, NULL, PF_Decal); } } else if (!(blendmode & PF_Masked)) @@ -1554,7 +1558,7 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom // I don't think that solid walls can use translucent linedef types... if (gl_frontsector->numlights) - HWR_SplitWall(gl_frontsector, wallVerts, gl_midtexture, &Surf, FF_CUTLEVEL, NULL); + HWR_SplitWall(gl_frontsector, wallVerts, gl_midtexture, &Surf, FF_CUTLEVEL, NULL, 0); else { if (grTex->mipmap.flags & TF_TRANSPARENT) @@ -1717,7 +1721,7 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom Surf.PolyColor.s.alpha = HWR_FogBlockAlpha(rover->master->frontsector->lightlevel, rover->master->frontsector->extra_colormap); if (gl_frontsector->numlights) - HWR_SplitWall(gl_frontsector, wallVerts, 0, &Surf, rover->flags, rover); + HWR_SplitWall(gl_frontsector, wallVerts, 0, &Surf, rover->flags, rover, 0); else HWR_AddTransparentWall(wallVerts, &Surf, 0, blendmode, true, lightnum, colormap); } @@ -1732,7 +1736,7 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom } if (gl_frontsector->numlights) - HWR_SplitWall(gl_frontsector, wallVerts, texnum, &Surf, rover->flags, rover); + HWR_SplitWall(gl_frontsector, wallVerts, texnum, &Surf, rover->flags, rover, 0); else { if (blendmode != PF_Masked) @@ -1829,7 +1833,7 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom Surf.PolyColor.s.alpha = HWR_FogBlockAlpha(rover->master->frontsector->lightlevel, rover->master->frontsector->extra_colormap); if (gl_backsector->numlights) - HWR_SplitWall(gl_backsector, wallVerts, 0, &Surf, rover->flags, rover); + HWR_SplitWall(gl_backsector, wallVerts, 0, &Surf, rover->flags, rover, 0); else HWR_AddTransparentWall(wallVerts, &Surf, 0, blendmode, true, lightnum, colormap); } @@ -1844,7 +1848,7 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom } if (gl_backsector->numlights) - HWR_SplitWall(gl_backsector, wallVerts, texnum, &Surf, rover->flags, rover); + HWR_SplitWall(gl_backsector, wallVerts, texnum, &Surf, rover->flags, rover, 0); else { if (blendmode != PF_Masked) From 8aac7454b8a90dafe57e454ab98bdce5ddec67b5 Mon Sep 17 00:00:00 2001 From: Zippy_Zolton Date: Sun, 10 Jan 2021 17:20:07 -0600 Subject: [PATCH 0513/1080] Make Armageddon Shield instantly kill Egg Guards --- src/p_user.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/p_user.c b/src/p_user.c index a70dceb8b..e2aa258e1 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -9009,8 +9009,11 @@ void P_NukeEnemies(mobj_t *inflictor, mobj_t *source, fixed_t radius) if (mo->type == MT_MINUS && !(mo->flags & (MF_SPECIAL|MF_SHOOTABLE))) mo->flags = (mo->flags & ~MF_NOCLIPTHING)|MF_SPECIAL|MF_SHOOTABLE; - if (mo->type == MT_EGGGUARD && mo->tracer) //nuke Egg Guard's shield! + if (mo->type == MT_EGGGUARD && mo->tracer) // Egg Guard's shield needs to be removed if it has one! + { P_KillMobj(mo->tracer, inflictor, source, DMG_NUKE); + P_KillMobj(mo, inflictor, source, DMG_NUKE); + } if (mo->flags & MF_BOSS || mo->type == MT_PLAYER) //don't OHKO bosses nor players! P_DamageMobj(mo, inflictor, source, 1, DMG_NUKE); From fbcc0c25b3198453d0f96bebdbd5e71724780b5c Mon Sep 17 00:00:00 2001 From: Tatsuru <44866610+Ikkarin@users.noreply.github.com> Date: Sun, 10 Jan 2021 23:17:40 -0300 Subject: [PATCH 0514/1080] Add Logan to the art credits --- src/f_finale.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/f_finale.c b/src/f_finale.c index b23ab4f7a..bd5f16f43 100644 --- a/src/f_finale.c +++ b/src/f_finale.c @@ -1149,6 +1149,7 @@ static const char *credits[] = { "Daniel \"Inazuma\" Trinh", "\"VelocitOni\"", "Jarrett \"JEV3\" Voight", + "Logan \"Hyperchaotix\" McCloud", "", "\1Music and Sound", "\1Production", From 8e9073f11f96868baf173dbf6be07d00193fd202 Mon Sep 17 00:00:00 2001 From: Zippy_Zolton Date: Sun, 10 Jan 2021 21:55:25 -0600 Subject: [PATCH 0515/1080] CR_PTERABYTE tweaks --- src/p_user.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index a70dceb8b..27e1498da 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -12774,13 +12774,13 @@ void P_PlayerAfterThink(player_t *player) if (!ptera->movefactor) goto dropoff; - if (ptera->cusval >= 50) + if (ptera->cusval >= 30) { player->powers[pw_carry] = CR_NONE; P_SetTarget(&player->mo->tracer, NULL); P_KillMobj(ptera, player->mo, player->mo, 0); player->mo->momz = 9*FRACUNIT; - player->pflags |= PF_APPLYAUTOBRAKE|PF_JUMPED|PF_THOKKED; + player->pflags |= PF_APPLYAUTOBRAKE|PF_JUMPED; P_SetMobjState(player->mo, S_PLAY_ROLL); break; } From 058b681660cc002e470a087f37a74fa8ca20cd93 Mon Sep 17 00:00:00 2001 From: Zippy_Zolton Date: Sun, 10 Jan 2021 22:01:41 -0600 Subject: [PATCH 0516/1080] P_SetObjectMomz --- 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 27e1498da..be16a03cc 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -12779,7 +12779,7 @@ void P_PlayerAfterThink(player_t *player) player->powers[pw_carry] = CR_NONE; P_SetTarget(&player->mo->tracer, NULL); P_KillMobj(ptera, player->mo, player->mo, 0); - player->mo->momz = 9*FRACUNIT; + P_SetObjectMomZ(player->mo, 9*FRACUNIT, false); player->pflags |= PF_APPLYAUTOBRAKE|PF_JUMPED; P_SetMobjState(player->mo, S_PLAY_ROLL); break; From 1917155adf2a70f867d51e650a7be9bb53d68fb5 Mon Sep 17 00:00:00 2001 From: Zippy_Zolton Date: Mon, 11 Jan 2021 00:19:56 -0600 Subject: [PATCH 0517/1080] PF_THOKKED --- 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 be16a03cc..f5b44d494 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -12780,7 +12780,7 @@ void P_PlayerAfterThink(player_t *player) P_SetTarget(&player->mo->tracer, NULL); P_KillMobj(ptera, player->mo, player->mo, 0); P_SetObjectMomZ(player->mo, 9*FRACUNIT, false); - player->pflags |= PF_APPLYAUTOBRAKE|PF_JUMPED; + player->pflags |= PF_APPLYAUTOBRAKE|PF_JUMPED|PF_THOKKED; P_SetMobjState(player->mo, S_PLAY_ROLL); break; } From 129ac4633c61752d3107f04cd6ae40001cb78377 Mon Sep 17 00:00:00 2001 From: Zippy_Zolton Date: Mon, 11 Jan 2021 13:25:42 -0600 Subject: [PATCH 0518/1080] Increased launch height --- 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 f5b44d494..7e61c91fa 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -12779,7 +12779,7 @@ void P_PlayerAfterThink(player_t *player) player->powers[pw_carry] = CR_NONE; P_SetTarget(&player->mo->tracer, NULL); P_KillMobj(ptera, player->mo, player->mo, 0); - P_SetObjectMomZ(player->mo, 9*FRACUNIT, false); + P_SetObjectMomZ(player->mo, 16*FRACUNIT, false); player->pflags |= PF_APPLYAUTOBRAKE|PF_JUMPED|PF_THOKKED; P_SetMobjState(player->mo, S_PLAY_ROLL); break; From 90b0242802151bced2c3355757e6670b60066e01 Mon Sep 17 00:00:00 2001 From: Tatsuru <44866610+Ikkarin@users.noreply.github.com> Date: Mon, 11 Jan 2021 21:49:31 -0300 Subject: [PATCH 0519/1080] Put his name at the right order --- src/f_finale.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/f_finale.c b/src/f_finale.c index bd5f16f43..2232b669f 100644 --- a/src/f_finale.c +++ b/src/f_finale.c @@ -1138,6 +1138,7 @@ static const char *credits[] = { "Iestyn \"Monster Iestyn\" Jealous", "William \"GuyWithThePie\" Kloppenberg", "Alice \"Alacroix\" de Lemos", + "Logan \"Hyperchaotix\" McCloud", "Alexander \"DrTapeworm\" Moench-Ford", "Andrew \"Senku Niola\" Moran", "\"MotorRoach\"", @@ -1149,7 +1150,6 @@ static const char *credits[] = { "Daniel \"Inazuma\" Trinh", "\"VelocitOni\"", "Jarrett \"JEV3\" Voight", - "Logan \"Hyperchaotix\" McCloud", "", "\1Music and Sound", "\1Production", From d2be3110bda87db82ca9fe74fbb5c375af2c8f88 Mon Sep 17 00:00:00 2001 From: lachwright Date: Wed, 13 Jan 2021 22:28:38 +1100 Subject: [PATCH 0520/1080] Have Metal Sonic use spinheight while dashing --- src/p_user.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/p_user.c b/src/p_user.c index a70dceb8b..a1bbe8d57 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -8652,7 +8652,9 @@ void P_MovePlayer(player_t *player) || (player->pflags & PF_SPINNING) || player->powers[pw_tailsfly] || player->pflags & PF_GLIDING || (player->charability == CA_GLIDEANDCLIMB && player->mo->state-states == S_PLAY_GLIDE_LANDING) - || (player->charability == CA_FLY && player->mo->state-states == S_PLAY_FLY_TIRED)) + || (player->charability == CA_FLY && player->mo->state-states == S_PLAY_FLY_TIRED) + || (player->dashmode >= DASHMODE_THRESHOLD && (player->charflags & SF_MACHINE) + && player->mo->state-states == S_PLAY_DASH && (player->mo->sprite2 & ~FF_SPR2SUPER) == player->mo->state->frame)) { player->mo->height = P_GetPlayerSpinHeight(player); atspinheight = true; From 149535634e757bb6bb833e18d866dc1005b63c0d Mon Sep 17 00:00:00 2001 From: lachwright Date: Thu, 14 Jan 2021 04:24:48 +1100 Subject: [PATCH 0521/1080] Keep Metal's jet fume at a consistent height during dashmode --- src/p_user.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index a1bbe8d57..47d73ec2a 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -11357,6 +11357,7 @@ static void P_DoMetalJetFume(player_t *player, mobj_t *fume) mobj_t *mo = player->mo; angle_t angle = player->drawangle; fixed_t dist; + fixed_t playerheight = P_GetPlayerHeight(player); panim_t panim = player->panim; tic_t dashmode = player->dashmode; boolean underwater = mo->eflags & MFE_UNDERWATER; @@ -11390,7 +11391,7 @@ static void P_DoMetalJetFume(player_t *player, mobj_t *fume) offsetV = i*P_ReturnThrustY(fume, fume->movedir, radiusV); x = mo->x + radiusX + FixedMul(offsetH, factorX); y = mo->y + radiusY + FixedMul(offsetH, factorY); - z = mo->z + (mo->height >> 1) + offsetV; + z = mo->z + (playerheight >> 1) + offsetV; P_SpawnMobj(x, y, z, MT_SMALLBUBBLE)->scale = mo->scale >> 1; } @@ -11453,7 +11454,7 @@ static void P_DoMetalJetFume(player_t *player, mobj_t *fume) P_UnsetThingPosition(fume); fume->x = mo->x + P_ReturnThrustX(fume, angle, dist); fume->y = mo->y + P_ReturnThrustY(fume, angle, dist); - fume->z = mo->z + ((mo->height - fume->height) >> 1); + fume->z = mo->z + ((playerheight - fume->height) >> 1); P_SetThingPosition(fume); // If dashmode is high enough, spawn a trail From a117ec98599f65b4836b05a33f63f281ef3a434f Mon Sep 17 00:00:00 2001 From: lachwright Date: Thu, 14 Jan 2021 04:34:43 +1100 Subject: [PATCH 0522/1080] oops that doesn't work in reverse gravity --- src/p_user.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index 47d73ec2a..f2b7759fa 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -11357,7 +11357,7 @@ static void P_DoMetalJetFume(player_t *player, mobj_t *fume) mobj_t *mo = player->mo; angle_t angle = player->drawangle; fixed_t dist; - fixed_t playerheight = P_GetPlayerHeight(player); + fixed_t heightoffset = ((mo->eflags & MFE_VERTICALFLIP) ? mo->height - (P_GetPlayerHeight(player) >> 1) : (P_GetPlayerHeight(player) >> 1)); panim_t panim = player->panim; tic_t dashmode = player->dashmode; boolean underwater = mo->eflags & MFE_UNDERWATER; @@ -11391,7 +11391,7 @@ static void P_DoMetalJetFume(player_t *player, mobj_t *fume) offsetV = i*P_ReturnThrustY(fume, fume->movedir, radiusV); x = mo->x + radiusX + FixedMul(offsetH, factorX); y = mo->y + radiusY + FixedMul(offsetH, factorY); - z = mo->z + (playerheight >> 1) + offsetV; + z = mo->z + heightoffset + offsetV; P_SpawnMobj(x, y, z, MT_SMALLBUBBLE)->scale = mo->scale >> 1; } @@ -11454,7 +11454,7 @@ static void P_DoMetalJetFume(player_t *player, mobj_t *fume) P_UnsetThingPosition(fume); fume->x = mo->x + P_ReturnThrustX(fume, angle, dist); fume->y = mo->y + P_ReturnThrustY(fume, angle, dist); - fume->z = mo->z + ((playerheight - fume->height) >> 1); + fume->z = mo->z + heightoffset - (fume->height >> 1); P_SetThingPosition(fume); // If dashmode is high enough, spawn a trail From 216f227539b0b9456eae1a55c8f9f89e19cd533d Mon Sep 17 00:00:00 2001 From: Zippy_Zolton Date: Wed, 13 Jan 2021 12:03:02 -0600 Subject: [PATCH 0523/1080] 12 --- 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 7e61c91fa..3fdbe4d8f 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -12779,7 +12779,7 @@ void P_PlayerAfterThink(player_t *player) player->powers[pw_carry] = CR_NONE; P_SetTarget(&player->mo->tracer, NULL); P_KillMobj(ptera, player->mo, player->mo, 0); - P_SetObjectMomZ(player->mo, 16*FRACUNIT, false); + P_SetObjectMomZ(player->mo, 12*FRACUNIT, false); player->pflags |= PF_APPLYAUTOBRAKE|PF_JUMPED|PF_THOKKED; P_SetMobjState(player->mo, S_PLAY_ROLL); break; From 794d92767032f718e6c31aa62f3125cd21b2511f Mon Sep 17 00:00:00 2001 From: Shane Ellis Date: Fri, 15 Jan 2021 16:44:26 -0500 Subject: [PATCH 0524/1080] Add conditions for new player bot type --- src/p_inter.c | 64 ++++++++++++++++++++++++--------------------------- 1 file changed, 30 insertions(+), 34 deletions(-) diff --git a/src/p_inter.c b/src/p_inter.c index e9a16a3dd..778ec703b 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -151,7 +151,7 @@ boolean P_CanPickupItem(player_t *player, boolean weapon) if (!player->mo || player->mo->health <= 0) return false; - if (player->bot) + if (player->bot && player->bot != 3) { if (weapon) return false; @@ -178,7 +178,7 @@ void P_DoNightsScore(player_t *player) return; // Don't do any fancy shit for failures. dummymo = P_SpawnMobj(player->mo->x, player->mo->y, player->mo->z+player->mo->height/2, MT_NIGHTSCORE); - if (player->bot) + if (player->bot && player->bot != 3) player = &players[consoleplayer]; if (G_IsSpecialStage(gamemap)) // Global link count? Maybe not a good idea... @@ -470,14 +470,14 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) if (!(player->charability2 == CA2_MELEE && player->panim == PA_ABILITY2)) { fixed_t setmomz = -toucher->momz; // Store this, momz get changed by P_DoJump within P_DoBubbleBounce - + if (elementalpierce == 2) // Reset bubblewrap, part 1 P_DoBubbleBounce(player); toucher->momz = setmomz; if (elementalpierce == 2) // Reset bubblewrap, part 2 { boolean underwater = toucher->eflags & MFE_UNDERWATER; - + if (underwater) toucher->momz /= 2; toucher->momz -= (toucher->momz/(underwater ? 8 : 4)); // Cap the height! @@ -630,7 +630,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) // ***************************** // // Special Stage Token case MT_TOKEN: - if (player->bot) + if (player->bot && player->bot != 3) return; P_AddPlayerScore(player, 1000); @@ -670,7 +670,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) // Emerald Hunt case MT_EMERHUNT: - if (player->bot) + if (player->bot && player->bot != 3) return; if (hunt1 == special) @@ -701,7 +701,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) case MT_EMERALD5: case MT_EMERALD6: case MT_EMERALD7: - if (player->bot) + if (player->bot && player->bot != 3) return; if (special->threshold) @@ -738,7 +738,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) // Secret emblem thingy case MT_EMBLEM: { - if (demoplayback || player->bot) + if (demoplayback || (player->bot && player->bot != 3)) return; emblemlocations[special->health-1].collected = true; @@ -751,7 +751,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) // CTF Flags case MT_REDFLAG: case MT_BLUEFLAG: - if (player->bot) + if (player->bot && player->bot != 3) return; if (player->powers[pw_flashing] || player->tossdelay) return; @@ -826,7 +826,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) { boolean spec = G_IsSpecialStage(gamemap); boolean cangiveemmy = false; - if (player->bot) + if (player->bot && player->bot != 3) return; if (player->exiting) return; @@ -1072,7 +1072,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) } return; case MT_EGGCAPSULE: - if (player->bot) + if (player->bot && player->bot != 3) return; // make sure everything is as it should be, THEN take rings from players in special stages @@ -1164,7 +1164,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) } return; case MT_NIGHTSSUPERLOOP: - if (player->bot || !(player->powers[pw_carry] == CR_NIGHTSMODE)) + if ((player->bot && player->bot != 3) || !(player->powers[pw_carry] == CR_NIGHTSMODE)) return; if (!G_IsSpecialStage(gamemap)) player->powers[pw_nights_superloop] = (UINT16)special->info->speed; @@ -1186,7 +1186,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) } break; case MT_NIGHTSDRILLREFILL: - if (player->bot || !(player->powers[pw_carry] == CR_NIGHTSMODE)) + if ((player->bot && player->bot != 3) || !(player->powers[pw_carry] == CR_NIGHTSMODE)) return; if (!G_IsSpecialStage(gamemap)) player->drillmeter = special->info->speed; @@ -1208,7 +1208,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) } break; case MT_NIGHTSHELPER: - if (player->bot || !(player->powers[pw_carry] == CR_NIGHTSMODE)) + if ((player->bot && player->bot != 3) || !(player->powers[pw_carry] == CR_NIGHTSMODE)) return; if (!G_IsSpecialStage(gamemap)) { @@ -1240,7 +1240,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) } break; case MT_NIGHTSEXTRATIME: - if (player->bot || !(player->powers[pw_carry] == CR_NIGHTSMODE)) + if ((player->bot && player->bot != 3) || !(player->powers[pw_carry] == CR_NIGHTSMODE)) return; if (!G_IsSpecialStage(gamemap)) { @@ -1272,7 +1272,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) } break; case MT_NIGHTSLINKFREEZE: - if (player->bot || !(player->powers[pw_carry] == CR_NIGHTSMODE)) + if ((player->bot && player->bot != 3) || !(player->powers[pw_carry] == CR_NIGHTSMODE)) return; if (!G_IsSpecialStage(gamemap)) { @@ -1332,7 +1332,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) if (playeringame[i] && players[i].powers[pw_carry] == CR_NIGHTSMODE) players[i].drillmeter += TICRATE/2; } - else if (player->bot) + else if (player->bot && player->bot != 3) players[consoleplayer].drillmeter += TICRATE/2; else player->drillmeter += TICRATE/2; @@ -1385,13 +1385,9 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) thinker_t *th; mobj_t *mo2; - if (player->bot) + if (player->bot && player->bot != 3) return; - // Initialize my junk - junk.tags.tags = NULL; - junk.tags.count = 0; - Tag_FSet(&junk.tags, LE_AXE); EV_DoElevator(&junk, bridgeFall, false); @@ -1423,7 +1419,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) return; } case MT_FIREFLOWER: - if (player->bot) + if (player->bot && player->bot != 3) return; S_StartSound(toucher, sfx_mario3); @@ -1617,7 +1613,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) if (special->tracer && !(special->tracer->flags2 & MF2_STRONGBOX)) macespin = true; - + if (macespin ? (player->powers[pw_ignorelatch] & (1<<15)) : (player->powers[pw_ignorelatch])) return; @@ -1685,7 +1681,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) return; // Only go in the mouth // Eaten by player! - if ((!player->bot) && (player->powers[pw_underwater] && player->powers[pw_underwater] <= 12*TICRATE + 1)) + if ((!player->bot || player->bot == 3) && (player->powers[pw_underwater] && player->powers[pw_underwater] <= 12*TICRATE + 1)) { player->powers[pw_underwater] = underwatertics + 1; P_RestoreMusic(player); @@ -1696,7 +1692,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) if (!player->climbing) { - if (player->bot && toucher->state-states != S_PLAY_GASP) + if (player->bot && player->bot != 3 && toucher->state-states != S_PLAY_GASP) S_StartSound(toucher, special->info->deathsound); // Force it to play a sound for bots P_SetPlayerMobjState(toucher, S_PLAY_GASP); P_ResetPlayer(player); @@ -1704,7 +1700,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) toucher->momx = toucher->momy = toucher->momz = 0; - if (player->bot) + if (player->bot && player->bot != 3) return; else break; @@ -1736,7 +1732,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) return; case MT_MINECARTSPAWNER: - if (!player->bot && special->fuse <= TICRATE && player->powers[pw_carry] != CR_MINECART && !(player->powers[pw_ignorelatch] & (1<<15))) + if (!player->bot && player->bot != 3 && special->fuse <= TICRATE && player->powers[pw_carry] != CR_MINECART && !(player->powers[pw_ignorelatch] & (1<<15))) { mobj_t *mcart = P_SpawnMobj(special->x, special->y, special->z, MT_MINECART); P_SetTarget(&mcart->target, toucher); @@ -1789,7 +1785,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) } return; default: // SOC or script pickup - if (player->bot) + if (player->bot && player->bot != 3) return; P_SetTarget(&special->target, toucher); break; @@ -1813,7 +1809,7 @@ void P_TouchStarPost(mobj_t *post, player_t *player, boolean snaptopost) mobj_t *toucher = player->mo; mobj_t *checkbase = snaptopost ? post : toucher; - if (player->bot) + if (player->bot && player->bot != 3) return; // In circuit, player must have touched all previous starposts if (circuitmap @@ -2555,7 +2551,7 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, UINT8 damaget if ((target->player->lives <= 1) && (netgame || multiplayer) && G_GametypeUsesCoopLives() && (cv_cooplives.value == 0)) ; - else if (!target->player->bot && !target->player->spectator && (target->player->lives != INFLIVES) + else if ((!target->player->bot || target->player->bot == 3) && !target->player->spectator && (target->player->lives != INFLIVES) && G_GametypeUsesLives()) { if (!(target->player->pflags & PF_FINISHED)) @@ -3475,7 +3471,7 @@ void P_SpecialStageDamage(player_t *player, mobj_t *inflictor, mobj_t *source) if (inflictor && inflictor->type == MT_LHRT) return; - if (player->powers[pw_shield] || player->bot) //If One-Hit Shield + if (player->powers[pw_shield] || (player->bot && player->bot != 3)) //If One-Hit Shield { P_RemoveShield(player); S_StartSound(player->mo, sfx_shldls); // Ba-Dum! Shield loss. @@ -3566,7 +3562,7 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da return false; // Make sure that boxes cannot be popped by enemies, red rings, etc. - if (target->flags & MF_MONITOR && ((!source || !source->player || source->player->bot) + if (target->flags & MF_MONITOR && ((!source || !source->player || (source->player->bot && source->player->bot != 3)) || (inflictor && (inflictor->type == MT_REDRING || (inflictor->type >= MT_THROWNBOUNCE && inflictor->type <= MT_THROWNGRENADE))))) return false; } @@ -3701,7 +3697,7 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da } else if (LUAh_MobjDamage(target, inflictor, source, damage, damagetype)) return true; - else if (player->powers[pw_shield] || (player->bot && !ultimatemode)) //If One-Hit Shield + else if (player->powers[pw_shield] || (player->bot && player->bot != 3 && !ultimatemode)) //If One-Hit Shield { P_ShieldDamage(player, inflictor, source, damage, damagetype); damage = 0; From 4b9a95a53837166a080b200b34982ce867a31ffd Mon Sep 17 00:00:00 2001 From: Shane Ellis Date: Fri, 15 Jan 2021 16:46:15 -0500 Subject: [PATCH 0525/1080] Add conditions for new player bot type --- src/p_enemy.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/p_enemy.c b/src/p_enemy.c index 203e04af1..38df59855 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -743,7 +743,7 @@ boolean P_LookForPlayers(mobj_t *actor, boolean allaround, boolean tracer, fixed if (player->mo->health <= 0) continue; // dead - if (player->bot) + if (player->bot && player->bot != 3) continue; // ignore bots if (player->quittime) @@ -1834,7 +1834,7 @@ void A_SnailerThink(mobj_t *actor) fixed_t dist; fixed_t dx, dy; - dist = R_PointToDist2(0, 0, actor->x - actor->target->x, actor->y - actor->target->y); + dist = P_AproxDistance(actor->x - actor->target->x, actor->y - actor->target->y); if (an > ANGLE_45 && an <= ANGLE_90) // fire at 45 degrees to the left { @@ -3924,10 +3924,6 @@ void A_BossDeath(mobj_t *mo) } else { - // Initialize my junk - junk.tags.tags = NULL; - junk.tags.count = 0; - // Bring the egg trap up to the surface // Incredibly shitty code ahead Tag_FSet(&junk.tags, LE_CAPSULE0); @@ -4057,10 +4053,6 @@ bossjustdie: } case MT_KOOPA: { - // Initialize my junk - junk.tags.tags = NULL; - junk.tags.count = 0; - Tag_FSet(&junk.tags, LE_KOOPA); EV_DoCeiling(&junk, raiseToHighest); return; From b995e3cb75b67116d51583c1ae85debf25013621 Mon Sep 17 00:00:00 2001 From: Shane Ellis Date: Fri, 15 Jan 2021 16:48:19 -0500 Subject: [PATCH 0526/1080] Add conditions for new player bot type --- src/p_user.c | 125 ++++++++++++++++++++------------------------------- 1 file changed, 48 insertions(+), 77 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index a70dceb8b..2466310bb 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -1189,7 +1189,7 @@ void P_GivePlayerRings(player_t *player, INT32 num_rings) if (!player) return; - if (player->bot) + if (player->bot && player->bot != 3) player = &players[consoleplayer]; if (!player->mo) @@ -1234,7 +1234,7 @@ void P_GivePlayerSpheres(player_t *player, INT32 num_spheres) if (!player) return; - if (player->bot) + if (player->bot && player->bot != 3) player = &players[consoleplayer]; if (!player->mo) @@ -1261,7 +1261,7 @@ void P_GivePlayerLives(player_t *player, INT32 numlives) if (!player) return; - if (player->bot) + if (player->bot && player->bot != 3) player = &players[consoleplayer]; if (gamestate == GS_LEVEL) @@ -1341,7 +1341,7 @@ void P_DoSuperTransformation(player_t *player, boolean giverings) // Transformation animation P_SetPlayerMobjState(player->mo, S_PLAY_SUPER_TRANS1); - if (giverings && player->rings < 50) + if (giverings) player->rings = 50; // Just in case. @@ -1367,7 +1367,7 @@ void P_AddPlayerScore(player_t *player, UINT32 amount) { UINT32 oldscore; - if (player->bot) + if (player->bot && player->bot != 3) player = &players[consoleplayer]; // NiGHTS does it different! @@ -1491,10 +1491,10 @@ void P_PlayLivesJingle(player_t *player) if (player && !P_IsLocalPlayer(player)) return; - if (mariomode) - S_StartSound(NULL, sfx_marioa); - else if (use1upSound || cv_1upsound.value) + if (use1upSound || cv_1upsound.value) S_StartSound(NULL, sfx_oneup); + else if (mariomode) + S_StartSound(NULL, sfx_marioa); else { P_PlayJingle(player, JT_1UP); @@ -2329,8 +2329,7 @@ boolean P_PlayerHitFloor(player_t *player, boolean dorollstuff) P_MobjCheckWater(player->mo); if (player->pflags & PF_SPINNING) { - if (!(player->pflags & PF_STARTDASH) && player->panim != PA_ROLL && player->panim != PA_ETC - && player->panim != PA_ABILITY && player->panim != PA_ABILITY2) + if (player->mo->state-states != S_PLAY_ROLL && !(player->pflags & PF_STARTDASH)) { P_SetPlayerMobjState(player->mo, S_PLAY_ROLL); S_StartSound(player->mo, sfx_spin); @@ -2613,10 +2612,10 @@ static void P_CheckBustableBlocks(player_t *player) if ((netgame || multiplayer) && player->spectator) return; - + oldx = player->mo->x; oldy = player->mo->y; - + if (!(player->pflags & PF_BOUNCING)) // Bouncers only get to break downwards, not sideways { P_UnsetThingPosition(player->mo); @@ -2635,7 +2634,7 @@ static void P_CheckBustableBlocks(player_t *player) if (!node->m_sector->ffloors) continue; - + for (rover = node->m_sector->ffloors; rover; rover = rover->next) { if (!P_PlayerCanBust(player, rover)) @@ -2993,7 +2992,7 @@ static void P_CheckUnderwaterAndSpaceTimer(player_t *player) player->powers[pw_spacetime] = 0; // Underwater audio cues - if (P_IsLocalPlayer(player) && !player->bot) + if (P_IsLocalPlayer(player) && !player->bot && player->bot != 3) { if ((player->powers[pw_underwater] == 25*TICRATE + 1) || (player->powers[pw_underwater] == 20*TICRATE + 1) @@ -4526,9 +4525,6 @@ void P_DoJump(player_t *player, boolean soundandstate) player->pflags |= P_GetJumpFlags(player);; - if (player->charflags & SF_NOJUMPDAMAGE) - player->pflags &= ~PF_SPINNING; - if (soundandstate) { if (!player->spectator) @@ -5024,7 +5020,7 @@ static boolean P_PlayerShieldThink(player_t *player, ticcmd_t *cmd, mobj_t *lock if ((player->powers[pw_shield] & SH_NOSTACK) && !player->powers[pw_super] && !(player->pflags & PF_SPINDOWN) && ((!(player->pflags & PF_THOKKED) || (((player->powers[pw_shield] & SH_NOSTACK) == SH_BUBBLEWRAP || (player->powers[pw_shield] & SH_NOSTACK) == SH_ATTRACT) && player->secondjump == UINT8_MAX) ))) // thokked is optional if you're bubblewrapped / 3dblasted { - if ((player->powers[pw_shield] & SH_NOSTACK) == SH_ATTRACT && !(player->charflags & SF_NOSHIELDABILITY)) + if ((player->powers[pw_shield] & SH_NOSTACK) == SH_ATTRACT) { if ((lockonshield = P_LookForEnemies(player, false, false))) { @@ -5047,7 +5043,7 @@ static boolean P_PlayerShieldThink(player_t *player, ticcmd_t *cmd, mobj_t *lock } } } - if ((!(player->charflags & SF_NOSHIELDABILITY)) && (cmd->buttons & BT_SPIN && !LUAh_ShieldSpecial(player))) // Spin button effects + if (cmd->buttons & BT_SPIN && !LUAh_ShieldSpecial(player)) // Spin button effects { // Force stop if ((player->powers[pw_shield] & ~(SH_FORCEHP|SH_STACK)) == SH_FORCE) @@ -5495,7 +5491,7 @@ static void P_DoJumpStuff(player_t *player, ticcmd_t *cmd) break; } } - else if ((!(player->charflags & SF_NOSHIELDABILITY)) && ((player->powers[pw_shield] & SH_NOSTACK) == SH_WHIRLWIND && !player->powers[pw_super] && !LUAh_ShieldSpecial(player))) + else if ((player->powers[pw_shield] & SH_NOSTACK) == SH_WHIRLWIND && !player->powers[pw_super]) P_DoJumpShield(player); } @@ -5924,7 +5920,7 @@ static void P_3dMovement(player_t *player) player->rmomy = player->mo->momy - player->cmomy; // Calculates player's speed based on distance-of-a-line formula - player->speed = R_PointToDist2(0, 0, player->rmomx, player->rmomy); + player->speed = P_AproxDistance(player->rmomx, player->rmomy); // Monster Iestyn - 04-11-13 // Quadrants are stupid, excessive and broken, let's do this a much simpler way! @@ -5957,22 +5953,6 @@ static void P_3dMovement(player_t *player) acceleration = 96 + (FixedDiv(player->speed, player->mo->scale)>>FRACBITS) * 40; topspeed = normalspd; } - else if (player->bot) - { // Bot steals player 1's stats - normalspd = FixedMul(players[consoleplayer].normalspeed, player->mo->scale); - thrustfactor = players[consoleplayer].thrustfactor; - acceleration = players[consoleplayer].accelstart + (FixedDiv(player->speed, player->mo->scale)>>FRACBITS) * players[consoleplayer].acceleration; - - if (player->powers[pw_tailsfly]) - topspeed = normalspd/2; - else if (player->mo->eflags & (MFE_UNDERWATER|MFE_GOOWATER)) - { - topspeed = normalspd/2; - acceleration = 2*acceleration/3; - } - else - topspeed = normalspd; - } else { if (player->powers[pw_super] || player->powers[pw_sneakers]) @@ -7756,11 +7736,6 @@ void P_ElementalFire(player_t *player, boolean cropcircle) flame->eflags = (flame->eflags & ~MFE_VERTICALFLIP)|(player->mo->eflags & MFE_VERTICALFLIP); P_InstaThrust(flame, flame->angle, FixedMul(3*FRACUNIT, flame->scale)); P_SetObjectMomZ(flame, 3*FRACUNIT, false); - if (!(gametyperules & GTR_FRIENDLY)) - { - P_SetMobjState(flame, S_TEAM_SPINFIRE1); - flame->color = player->mo->color; - } } #undef limitangle #undef numangles @@ -7788,11 +7763,6 @@ void P_ElementalFire(player_t *player, boolean cropcircle) flame->destscale = player->mo->scale; P_SetScale(flame, player->mo->scale); flame->eflags = (flame->eflags & ~MFE_VERTICALFLIP)|(player->mo->eflags & MFE_VERTICALFLIP); - if (!(gametyperules & GTR_FRIENDLY)) - { - P_SetMobjState(flame, S_TEAM_SPINFIRE1); - flame->color = player->mo->color; - } flame->momx = 8; // this is a hack which is used to ensure it still behaves as a missile and can damage others P_XYMovement(flame); @@ -8619,6 +8589,12 @@ void P_MovePlayer(player_t *player) player->climbing--; } + if (!player->climbing) + { + player->lastsidehit = -1; + player->lastlinehit = -1; + } + // Make sure you're not teetering when you shouldn't be. if (player->panim == PA_EDGE && (player->mo->momx || player->mo->momy || player->mo->momz)) @@ -8643,7 +8619,6 @@ void P_MovePlayer(player_t *player) P_DoFiring(player, cmd); { - boolean atspinheight = false; fixed_t oldheight = player->mo->height; // Less height while spinning. Good for spinning under things...? @@ -8653,35 +8628,32 @@ void P_MovePlayer(player_t *player) || player->powers[pw_tailsfly] || player->pflags & PF_GLIDING || (player->charability == CA_GLIDEANDCLIMB && player->mo->state-states == S_PLAY_GLIDE_LANDING) || (player->charability == CA_FLY && player->mo->state-states == S_PLAY_FLY_TIRED)) - { player->mo->height = P_GetPlayerSpinHeight(player); - atspinheight = true; - } else player->mo->height = P_GetPlayerHeight(player); if (player->mo->eflags & MFE_VERTICALFLIP && player->mo->height != oldheight) // adjust z height for reverse gravity, similar to how it's done for scaling player->mo->z -= player->mo->height - oldheight; + } - // Crush test... - if ((player->mo->ceilingz - player->mo->floorz < player->mo->height) - && !(player->mo->flags & MF_NOCLIP)) + // Crush test... + if ((player->mo->ceilingz - player->mo->floorz < player->mo->height) + && !(player->mo->flags & MF_NOCLIP)) + { + if ((player->charability2 == CA2_SPINDASH) && !(player->pflags & PF_SPINNING)) { - if (!atspinheight) - { - player->pflags |= PF_SPINNING; - P_SetPlayerMobjState(player->mo, S_PLAY_ROLL); - } - else if (player->mo->ceilingz - player->mo->floorz < player->mo->height) - { - if ((netgame || multiplayer) && player->spectator) - P_DamageMobj(player->mo, NULL, NULL, 1, DMG_SPECTATOR); // Respawn crushed spectators - else - P_DamageMobj(player->mo, NULL, NULL, 1, DMG_CRUSHED); + player->pflags |= PF_SPINNING; + P_SetPlayerMobjState(player->mo, S_PLAY_ROLL); + } + else if (player->mo->ceilingz - player->mo->floorz < player->mo->height) + { + if ((netgame || multiplayer) && player->spectator) + P_DamageMobj(player->mo, NULL, NULL, 1, DMG_SPECTATOR); // Respawn crushed spectators + else + P_DamageMobj(player->mo, NULL, NULL, 1, DMG_CRUSHED); - if (player->playerstate == PST_DEAD) - return; - } + if (player->playerstate == PST_DEAD) + return; } } @@ -9497,11 +9469,11 @@ static void P_DeathThink(player_t *player) if (player->deadtimer < INT32_MAX) player->deadtimer++; - if (player->bot) // don't allow bots to do any of the below, B_CheckRespawn does all they need for respawning already + if (player->bot && player->bot != 3) // don't allow bots to do any of the below, B_CheckRespawn does all they need for respawning already goto notrealplayer; // continue logic - if (!(netgame || multiplayer) && player->lives <= 0) + if (!(netgame || multiplayer) && player->lives <= 0 && player ==&players[consoleplayer]) //Extra players in SP can't be allowed to continue or end game { if (player->deadtimer > (3*TICRATE) && (cmd->buttons & BT_SPIN || cmd->buttons & BT_JUMP) && (!continuesInSession || player->continues > 0)) G_UseContinue(); @@ -11480,7 +11452,7 @@ void P_PlayerThink(player_t *player) player->playerstate = PST_DEAD; } - if (player->bot) + if (player->bot && player->bot != 3) { if (player->playerstate == PST_LIVE || player->playerstate == PST_DEAD) { @@ -11494,6 +11466,7 @@ void P_PlayerThink(player_t *player) } } +#ifdef SEENAMES if (netgame && player == &players[displayplayer] && !(leveltime % (TICRATE/5))) { seenplayer = NULL; @@ -11518,6 +11491,7 @@ void P_PlayerThink(player_t *player) } } } +#endif if (player->awayviewmobj && P_MobjWasRemoved(player->awayviewmobj)) { @@ -12588,16 +12562,13 @@ void P_PlayerAfterThink(player_t *player) player->powers[pw_carry] = CR_NONE; else { - if (tails->player) - P_TryMove(player->mo, tails->x + P_ReturnThrustX(tails, tails->player->drawangle, 4*FRACUNIT), tails->y + P_ReturnThrustY(tails, tails->player->drawangle, 4*FRACUNIT), true); - else - P_TryMove(player->mo, tails->x + P_ReturnThrustX(tails, tails->angle, 4*FRACUNIT), tails->y + P_ReturnThrustY(tails, tails->angle, 4*FRACUNIT), true); + P_TryMove(player->mo, tails->x + P_ReturnThrustX(tails, tails->player->drawangle, 4*FRACUNIT), tails->y + P_ReturnThrustY(tails, tails->player->drawangle, 4*FRACUNIT), true); player->mo->momx = tails->momx; player->mo->momy = tails->momy; player->mo->momz = tails->momz; } - if (G_CoopGametype() && tails->player && tails->player->bot != 1) + if (G_CoopGametype() && (!tails->player || tails->player->bot != 1)) { player->mo->angle = tails->angle; @@ -12612,7 +12583,7 @@ void P_PlayerAfterThink(player_t *player) { if (player->mo->state-states != S_PLAY_RIDE) P_SetPlayerMobjState(player->mo, S_PLAY_RIDE); - if (tails->player && (tails->skin && ((skin_t *)(tails->skin))->sprites[SPR2_SWIM].numframes) && (tails->eflags & MFE_UNDERWATER)) + if ((tails->skin && ((skin_t *)(tails->skin))->sprites[SPR2_SWIM].numframes) && (tails->eflags & MFE_UNDERWATER)) tails->player->powers[pw_tailsfly] = 0; } else From 5e8313e157ab0bef4f2e2a346906aa1a6efdd58b Mon Sep 17 00:00:00 2001 From: Shane Ellis Date: Fri, 15 Jan 2021 16:50:01 -0500 Subject: [PATCH 0527/1080] Implementation of lua function P_AddPlayer() --- src/lua_baselib.c | 89 ++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 81 insertions(+), 8 deletions(-) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index c5f847be6..9bc8813a2 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -155,8 +155,6 @@ static const struct { {META_PIVOTLIST, "spriteframepivot_t[]"}, {META_FRAMEPIVOT, "spriteframepivot_t"}, - {META_TAGLIST, "taglist"}, - {META_MOBJ, "mobj_t"}, {META_MAPTHING, "mapthing_t"}, @@ -165,8 +163,6 @@ static const struct { {META_SKIN, "skin_t"}, {META_POWERS, "player_t.powers"}, {META_SOUNDSID, "skin_t.soundsid"}, - {META_SKINSPRITES, "skin_t.sprites"}, - {META_SKINSPRITESLIST, "skin_t.sprites[]"}, {META_VERTEX, "vertex_t"}, {META_LINE, "line_t"}, @@ -188,9 +184,6 @@ static const struct { {META_CVAR, "consvar_t"}, {META_SECTORLINES, "sector_t.lines"}, -#ifdef MUTABLE_TAGS - {META_SECTORTAGLIST, "sector_t.taglist"}, -#endif {META_SIDENUM, "line_t.sidenum"}, {META_LINEARGS, "line_t.args"}, {META_LINESTRINGARGS, "line_t.stringargs"}, @@ -2639,7 +2632,7 @@ static int lib_rSkinUsable(lua_State *L) else // skin name { const char *skinname = luaL_checkstring(L, 2); - i = R_SkinAvailable(skinname); + if (R_SkinAvailable(skinname) >= 0) if (i == -1) return luaL_error(L, "skin %s (argument 2) is not loaded", skinname); } @@ -3407,6 +3400,85 @@ static int lib_gAddGametype(lua_State *L) return 0; } +// Bot adding function! +// Partly lifted from Got_AddPlayer +static int lib_gAddPlayer(lua_State *L) +{ + INT16 i, newplayernum, botcount = 1; + player_t *newplayer; + INT8 skinnum = 0, bot; + + for (i = 0; i < MAXPLAYERS; i++) + { + if (!playeringame[i]) + break; + + if (players[i].bot) + botcount++; // How many of us are there already? + } + if (i >= MAXPLAYERS) + { + lua_pushnil(L); + return 1; + } + + + newplayernum = i; + + //if (!splitscreen && !botingame) + CL_ClearPlayer(newplayernum); + + playeringame[newplayernum] = true; + G_AddPlayer(newplayernum); + newplayer = &players[newplayernum]; + + newplayer->jointime = 0; + newplayer->quittime = 0; + + // I hereby name you Bot X + strcpy(player_names[newplayernum], va("Bot %d", botcount)); + + // Read the skin string! + if (!lua_isnoneornil(L, 1)) + { + skinnum = R_SkinAvailable(luaL_checkstring(L, 1)); + skinnum = skinnum < 0 ? 0 : skinnum; + + // Bots can be whatever they want + if (!R_SkinUsable(newplayernum, skinnum)) + newplayer->availabilities |= 1 << skinnum; + } + + // Read the color! + if (!lua_isnoneornil(L, 2)) + newplayer->skincolor = R_GetColorByName(luaL_checkstring(L, 2)); + else + newplayer->skincolor = skins[newplayer->skin].prefcolor; + + // Read the bot name, if given! + if (!lua_isnoneornil(L, 3)) + strcpy(player_names[newplayernum], luaL_checkstring(L, 3)); + + bot = luaL_optinteger(L, 4, 3); + newplayer->bot = (bot >= 0 && bot <= 3) ? bot : 3; + + // Set the skin + SetPlayerSkinByNum(newplayernum, skinnum); + + + if (netgame) + { + char joinmsg[256]; + + strcpy(joinmsg, M_GetText("\x82*Bot %s has joined the game (player %d)")); + strcpy(joinmsg, va(joinmsg, player_names[newplayernum], newplayernum)); + HU_AddChatText(joinmsg, false); + } + + LUA_PushUserdata(L, newplayer, META_PLAYER); + return 0; +} + static int Lcheckmapnumber (lua_State *L, int idx, const char *fun) { if (ISINLEVEL) @@ -3987,6 +4059,7 @@ static luaL_Reg lib[] = { // g_game {"G_AddGametype", lib_gAddGametype}, + {"G_AddPlayer", lib_gAddPlayer}, {"G_BuildMapName",lib_gBuildMapName}, {"G_BuildMapTitle",lib_gBuildMapTitle}, {"G_FindMap",lib_gFindMap}, From 9eeaef2e32c90d2c23a314c2cd99a0b72dde0f0a Mon Sep 17 00:00:00 2001 From: Shane Ellis Date: Fri, 15 Jan 2021 16:55:49 -0500 Subject: [PATCH 0528/1080] Exception made in R_SkinUsable() for player bot types --- src/r_skins.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/r_skins.c b/src/r_skins.c index 6f150f234..155a64700 100644 --- a/src/r_skins.c +++ b/src/r_skins.c @@ -198,6 +198,7 @@ boolean R_SkinUsable(INT32 playernum, INT32 skinnum) || (Playing() && (R_SkinAvailable(mapheaderinfo[gamemap-1]->forcecharacter) == skinnum)) // Force 1. || (netgame && (cv_forceskin.value == skinnum)) // Force 2. || (metalrecording && skinnum == 5) // Force 3. + || players[playernum].bot //Force (player is a bot) ); } @@ -511,10 +512,6 @@ static boolean R_ProcessPatchableFields(skin_t *skin, char *stoken, char *value) GETFLAG(MULTIABILITY) GETFLAG(NONIGHTSROTATION) GETFLAG(NONIGHTSSUPER) - GETFLAG(NOSUPERSPRITES) - GETFLAG(NOSUPERJUMPBOOST) - GETFLAG(CANBUSTWALLS) - GETFLAG(NOSHIELDABILITY) #undef GETFLAG else // let's check if it's a sound, otherwise error out From f166af4d8b7805e1ce5688cbef386f6ddc6e3ec1 Mon Sep 17 00:00:00 2001 From: Shane Ellis Date: Fri, 15 Jan 2021 17:00:21 -0500 Subject: [PATCH 0529/1080] CL_RemovePlayer() - Allow for removal of non-consoleplayer and non-secondaryviewplayer player instances (e.g. bot players) --- src/r_skins.c | 5748 ++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 5019 insertions(+), 729 deletions(-) diff --git a/src/r_skins.c b/src/r_skins.c index 155a64700..88b4d9387 100644 --- a/src/r_skins.c +++ b/src/r_skins.c @@ -1,6 +1,5 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- -// Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. // Copyright (C) 1999-2020 by Sonic Team Junior. // @@ -8,826 +7,5117 @@ // terms of the GNU General Public License, version 2. // See the 'LICENSE' file for more details. //----------------------------------------------------------------------------- -/// \file r_skins.c -/// \brief Loading skins +/// \file d_clisrv.c +/// \brief SRB2 Network game communication and protocol, all OS independent parts. -#include "doomdef.h" -#include "console.h" -#include "g_game.h" -#include "r_local.h" -#include "st_stuff.h" -#include "w_wad.h" -#include "z_zone.h" -#include "m_misc.h" -#include "info.h" // spr2names -#include "i_video.h" // rendermode +#include +#ifdef __GNUC__ +#include //for unlink +#endif + +#include "i_net.h" #include "i_system.h" -#include "r_things.h" -#include "r_skins.h" +#include "i_video.h" +#include "d_net.h" +#include "d_main.h" +#include "g_game.h" +#include "st_stuff.h" +#include "hu_stuff.h" +#include "keys.h" +#include "g_input.h" // JOY1 +#include "m_menu.h" +#include "console.h" +#include "d_netfil.h" +#include "byteptr.h" +#include "p_saveg.h" +#include "z_zone.h" #include "p_local.h" -#include "dehacked.h" // get_number (for thok) -#include "m_cond.h" -#ifdef HWRENDER -#include "hardware/hw_md2.h" -#endif +#include "m_misc.h" +#include "am_map.h" +#include "m_random.h" +#include "mserv.h" +#include "y_inter.h" +#include "r_local.h" +#include "m_argv.h" +#include "p_setup.h" +#include "lzf.h" +#include "lua_script.h" +#include "lua_hook.h" +#include "md5.h" +#include "m_perfstats.h" -INT32 numskins = 0; -skin_t skins[MAXSKINS]; - -// FIXTHIS: don't work because it must be inistilised before the config load -//#define SKINVALUES -#ifdef SKINVALUES -CV_PossibleValue_t skin_cons_t[MAXSKINS+1]; +#ifndef NONET +// cl loading screen +#include "v_video.h" +#include "f_finale.h" #endif // -// P_GetSkinSprite2 -// For non-super players, tries each sprite2's immediate predecessor until it finds one with a number of frames or ends up at standing. -// For super players, does the same as above - but tries the super equivalent for each sprite2 before the non-super version. +// NETWORKING // +// gametic is the tic about to (or currently being) run +// Server: +// maketic is the tic that hasn't had control made for it yet +// nettics is the tic for each node +// firstticstosend is the lowest value of nettics +// Client: +// neededtic is the tic needed by the client to run the game +// firstticstosend is used to optimize a condition +// Normally maketic >= gametic > 0 -UINT8 P_GetSkinSprite2(skin_t *skin, UINT8 spr2, player_t *player) +#define PREDICTIONQUEUE BACKUPTICS +#define PREDICTIONMASK (PREDICTIONQUEUE-1) +#define MAX_REASONLENGTH 30 + +boolean server = true; // true or false but !server == client +#define client (!server) +boolean nodownload = false; +boolean serverrunning = false; +INT32 serverplayer = 0; +char motd[254], server_context[8]; // Message of the Day, Unique Context (even without Mumble support) + +// Server specific vars +UINT8 playernode[MAXPLAYERS]; +char playeraddress[MAXPLAYERS][64]; + +// Minimum timeout for sending the savegame +// The actual timeout will be longer depending on the savegame length +tic_t jointimeout = (10*TICRATE); +static boolean sendingsavegame[MAXNETNODES]; // Are we sending the savegame? +static boolean resendingsavegame[MAXNETNODES]; // Are we resending the savegame? +static tic_t savegameresendcooldown[MAXNETNODES]; // How long before we can resend again? +static tic_t freezetimeout[MAXNETNODES]; // Until when can this node freeze the server before getting a timeout? + +// Incremented by cv_joindelay when a client joins, decremented each tic. +// If higher than cv_joindelay * 2 (3 joins in a short timespan), joins are temporarily disabled. +static tic_t joindelay = 0; + +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. +SINT8 nodetoplayer[MAXNETNODES]; +SINT8 nodetoplayer2[MAXNETNODES]; // say the numplayer for this node if any (splitscreen) +UINT8 playerpernode[MAXNETNODES]; // used specialy for scplitscreen +boolean nodeingame[MAXNETNODES]; // set false as nodes leave game +tic_t servermaxping = 800; // server's max ping. Defaults to 800 +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 +static tic_t maketic; + +static INT16 consistancy[BACKUPTICS]; + +static UINT8 player_joining = false; +UINT8 hu_redownloadinggamestate = 0; + +UINT8 adminpassmd5[16]; +boolean adminpasswordset = false; + +// Client specific +static ticcmd_t localcmds; +static ticcmd_t localcmds2; +static boolean cl_packetmissed; +// here it is for the secondary local player (splitscreen) +static UINT8 mynode; // my address pointofview server +static boolean cl_redownloadinggamestate = false; + +static UINT8 localtextcmd[MAXTEXTCMD]; +static UINT8 localtextcmd2[MAXTEXTCMD]; // splitscreen +static tic_t neededtic; +SINT8 servernode = 0; // the number of the server node +/// \brief do we accept new players? +/// \todo WORK! +boolean acceptnewnode = true; + +// engine + +// Must be a power of two +#define TEXTCMD_HASH_SIZE 4 + +typedef struct textcmdplayer_s { - UINT8 super = 0, i = 0; + INT32 playernum; + UINT8 cmd[MAXTEXTCMD]; + struct textcmdplayer_s *next; +} textcmdplayer_t; - if (!skin) - return 0; +typedef struct textcmdtic_s +{ + tic_t tic; + textcmdplayer_t *playercmds[TEXTCMD_HASH_SIZE]; + struct textcmdtic_s *next; +} textcmdtic_t; - if ((playersprite_t)(spr2 & ~FF_SPR2SUPER) >= free_spr2) - return 0; +ticcmd_t netcmds[BACKUPTICS][MAXPLAYERS]; +static textcmdtic_t *textcmds[TEXTCMD_HASH_SIZE] = {NULL}; - while (!skin->sprites[spr2].numframes - && spr2 != SPR2_STND - && ++i < 32) // recursion limiter - { - if (spr2 & FF_SPR2SUPER) - { - super = FF_SPR2SUPER; - spr2 &= ~FF_SPR2SUPER; - continue; - } - switch(spr2) - { - // Normal special cases. - case SPR2_JUMP: - spr2 = ((player - ? player->charflags - : skin->flags) - & SF_NOJUMPSPIN) ? SPR2_SPNG : SPR2_ROLL; - break; - case SPR2_TIRE: - spr2 = ((player - ? player->charability - : skin->ability) - == CA_SWIM) ? SPR2_SWIM : SPR2_FLY; - break; - // Use the handy list, that's what it's there for! - default: - spr2 = spr2defaults[spr2]; - break; - } +consvar_t cv_showjoinaddress = CVAR_INIT ("showjoinaddress", "Off", CV_SAVE|CV_NETVAR, CV_OnOff, NULL); - spr2 |= super; - } +static CV_PossibleValue_t playbackspeed_cons_t[] = {{1, "MIN"}, {10, "MAX"}, {0, NULL}}; +consvar_t cv_playbackspeed = CVAR_INIT ("playbackspeed", "1", 0, playbackspeed_cons_t, NULL); - if (i >= 32) // probably an infinite loop... - return 0; +static inline void *G_DcpyTiccmd(void* dest, const ticcmd_t* src, const size_t n) +{ + const size_t d = n / sizeof(ticcmd_t); + const size_t r = n % sizeof(ticcmd_t); + UINT8 *ret = dest; - return spr2; + if (r) + M_Memcpy(dest, src, n); + else if (d) + G_MoveTiccmd(dest, src, d); + return ret+n; } -static void Sk_SetDefaultValue(skin_t *skin) +static inline void *G_ScpyTiccmd(ticcmd_t* dest, void* src, const size_t n) { - INT32 i; - // - // set default skin values - // - memset(skin, 0, sizeof (skin_t)); - snprintf(skin->name, - sizeof skin->name, "skin %u", (UINT32)(skin-skins)); - skin->name[sizeof skin->name - 1] = '\0'; - skin->wadnum = INT16_MAX; + const size_t d = n / sizeof(ticcmd_t); + const size_t r = n % sizeof(ticcmd_t); + UINT8 *ret = src; - skin->flags = 0; - - strcpy(skin->realname, "Someone"); - strcpy(skin->hudname, "???"); - - skin->starttranscolor = 96; - skin->prefcolor = SKINCOLOR_GREEN; - skin->supercolor = SKINCOLOR_SUPERGOLD1; - skin->prefoppositecolor = 0; // use tables - - skin->normalspeed = 36<runspeed = 28<thrustfactor = 5; - skin->accelstart = 96; - skin->acceleration = 40; - - skin->ability = CA_NONE; - skin->ability2 = CA2_SPINDASH; - skin->jumpfactor = FRACUNIT; - skin->actionspd = 30<mindash = 15<maxdash = 70<radius = mobjinfo[MT_PLAYER].radius; - skin->height = mobjinfo[MT_PLAYER].height; - skin->spinheight = FixedMul(skin->height, 2*FRACUNIT/3); - - skin->shieldscale = FRACUNIT; - skin->camerascale = FRACUNIT; - - skin->thokitem = -1; - skin->spinitem = -1; - skin->revitem = -1; - skin->followitem = 0; - - skin->highresscale = FRACUNIT; - skin->contspeed = 17; - skin->contangle = 0; - - skin->availability = 0; - - for (i = 0; i < sfx_skinsoundslot0; i++) - if (S_sfx[i].skinsound != -1) - skin->soundsid[S_sfx[i].skinsound] = i; + if (r) + M_Memcpy(dest, src, n); + else if (d) + G_MoveTiccmd(dest, src, d); + return ret+n; } -// -// Initialize the basic skins -// -void R_InitSkins(void) -{ -#ifdef SKINVALUES - INT32 i; - for (i = 0; i <= MAXSKINS; i++) - { - skin_cons_t[i].value = 0; - skin_cons_t[i].strvalue = NULL; - } + +// Some software don't support largest packet +// (original sersetup, not exactely, but the probability of sending a packet +// of 512 bytes is like 0.1) +UINT16 software_MAXPACKETLENGTH; + +/** Guesses the full value of a tic from its lowest byte, for a specific node + * + * \param low The lowest byte of the tic value + * \param node The node to deduce the tic for + * \return The full tic value + * + */ +tic_t ExpandTics(INT32 low, INT32 node) +{ + INT32 delta; + + delta = low - (nettics[node] & UINT8_MAX); + + if (delta >= -64 && delta <= 64) + return (nettics[node] & ~UINT8_MAX) + low; + else if (delta > 64) + return (nettics[node] & ~UINT8_MAX) - 256 + low; + else //if (delta < -64) + return (nettics[node] & ~UINT8_MAX) + 256 + low; +} + +// ----------------------------------------------------------------- +// Some extra data function for handle textcmd buffer +// ----------------------------------------------------------------- + +static void (*listnetxcmd[MAXNETXCMD])(UINT8 **p, INT32 playernum); + +void RegisterNetXCmd(netxcmd_t id, void (*cmd_f)(UINT8 **p, INT32 playernum)) +{ +#ifdef PARANOIA + if (id >= MAXNETXCMD) + I_Error("Command id %d too big", id); + if (listnetxcmd[id] != 0) + I_Error("Command id %d already used", id); #endif - - // no default skin! - numskins = 0; + listnetxcmd[id] = cmd_f; } -UINT32 R_GetSkinAvailabilities(void) +void SendNetXCmd(netxcmd_t id, const void *param, size_t nparam) { - INT32 s; - UINT32 response = 0; - - for (s = 0; s < MAXSKINS; s++) + if (localtextcmd[0]+2+nparam > MAXTEXTCMD) { - if (skins[s].availability && unlockables[skins[s].availability - 1].unlocked) - response |= (1 << s); - } - return response; -} - -// returns true if available in circumstances, otherwise nope -// warning don't use with an invalid skinnum other than -1 which always returns true -boolean R_SkinUsable(INT32 playernum, INT32 skinnum) -{ - return ((skinnum == -1) // Simplifies things elsewhere, since there's already plenty of checks for less-than-0... - || (!skins[skinnum].availability) - || (((netgame || multiplayer) && playernum != -1) ? (players[playernum].availabilities & (1 << skinnum)) : (unlockables[skins[skinnum].availability - 1].unlocked)) - || (modeattacking) // If you have someone else's run you might as well take a look - || (Playing() && (R_SkinAvailable(mapheaderinfo[gamemap-1]->forcecharacter) == skinnum)) // Force 1. - || (netgame && (cv_forceskin.value == skinnum)) // Force 2. - || (metalrecording && skinnum == 5) // Force 3. - || players[playernum].bot //Force (player is a bot) - ); -} - -// returns true if the skin name is found (loaded from pwad) -// warning return -1 if not found -INT32 R_SkinAvailable(const char *name) -{ - INT32 i; - - for (i = 0; i < numskins; i++) - { - // search in the skin list - if (stricmp(skins[i].name,name)==0) - return i; - } - return -1; -} - -// network code calls this when a 'skin change' is received -void SetPlayerSkin(INT32 playernum, const char *skinname) -{ - INT32 i = R_SkinAvailable(skinname); - player_t *player = &players[playernum]; - - if ((i != -1) && R_SkinUsable(playernum, i)) - { - SetPlayerSkinByNum(playernum, i); + // for future reference: if (cv_debug) != debug disabled. + CONS_Alert(CONS_ERROR, M_GetText("NetXCmd buffer full, cannot add netcmd %d! (size: %d, needed: %s)\n"), id, localtextcmd[0], sizeu1(nparam)); return; } - - if (P_IsLocalPlayer(player)) - CONS_Alert(CONS_WARNING, M_GetText("Skin '%s' not found.\n"), skinname); - else if(server || IsPlayerAdmin(consoleplayer)) - CONS_Alert(CONS_WARNING, M_GetText("Player %d (%s) skin '%s' not found\n"), playernum, player_names[playernum], skinname); - - SetPlayerSkinByNum(playernum, 0); + localtextcmd[0]++; + localtextcmd[localtextcmd[0]] = (UINT8)id; + if (param && nparam) + { + M_Memcpy(&localtextcmd[localtextcmd[0]+1], param, nparam); + localtextcmd[0] = (UINT8)(localtextcmd[0] + (UINT8)nparam); + } } -// Same as SetPlayerSkin, but uses the skin #. -// network code calls this when a 'skin change' is received -void SetPlayerSkinByNum(INT32 playernum, INT32 skinnum) +// splitscreen player +void SendNetXCmd2(netxcmd_t id, const void *param, size_t nparam) { - player_t *player = &players[playernum]; - skin_t *skin = &skins[skinnum]; - UINT16 newcolor = 0; - - if (skinnum >= 0 && skinnum < numskins && R_SkinUsable(playernum, skinnum)) // Make sure it exists! + if (localtextcmd2[0]+2+nparam > MAXTEXTCMD) { - player->skin = skinnum; + I_Error("No more place in the buffer for netcmd %d\n",id); + return; + } + localtextcmd2[0]++; + localtextcmd2[localtextcmd2[0]] = (UINT8)id; + if (param && nparam) + { + M_Memcpy(&localtextcmd2[localtextcmd2[0]+1], param, nparam); + localtextcmd2[0] = (UINT8)(localtextcmd2[0] + (UINT8)nparam); + } +} - player->camerascale = skin->camerascale; - player->shieldscale = skin->shieldscale; +UINT8 GetFreeXCmdSize(void) +{ + // -1 for the size and another -1 for the ID. + return (UINT8)(localtextcmd[0] - 2); +} - player->charability = (UINT8)skin->ability; - player->charability2 = (UINT8)skin->ability2; +// 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; - player->charflags = (UINT32)skin->flags; + while (textcmdtic && textcmdtic->tic != tic) + { + tctprev = &textcmdtic->next; + textcmdtic = textcmdtic->next; + } - player->thokitem = skin->thokitem < 0 ? (UINT32)mobjinfo[MT_PLAYER].painchance : (UINT32)skin->thokitem; - player->spinitem = skin->spinitem < 0 ? (UINT32)mobjinfo[MT_PLAYER].damage : (UINT32)skin->spinitem; - player->revitem = skin->revitem < 0 ? (mobjtype_t)mobjinfo[MT_PLAYER].raisestate : (UINT32)skin->revitem; - player->followitem = skin->followitem; + if (textcmdtic) + { + INT32 i; - if (((player->powers[pw_shield] & SH_NOSTACK) == SH_PINK) && (player->revitem == MT_LHRT || player->spinitem == MT_LHRT || player->thokitem == MT_LHRT)) // Healers can't keep their buff. - player->powers[pw_shield] &= SH_STACK; + // Remove this tic from the list. + *tctprev = textcmdtic->next; - player->actionspd = skin->actionspd; - player->mindash = skin->mindash; - player->maxdash = skin->maxdash; - - player->normalspeed = skin->normalspeed; - player->runspeed = skin->runspeed; - player->thrustfactor = skin->thrustfactor; - player->accelstart = skin->accelstart; - player->acceleration = skin->acceleration; - - player->jumpfactor = skin->jumpfactor; - - player->height = skin->height; - player->spinheight = skin->spinheight; - - if (!(cv_debug || devparm) && !(netgame || multiplayer || demoplayback)) + // Free all players. + for (i = 0; i < TEXTCMD_HASH_SIZE; i++) { - if (playernum == consoleplayer) - CV_StealthSetValue(&cv_playercolor, skin->prefcolor); - else if (playernum == secondarydisplayplayer) - CV_StealthSetValue(&cv_playercolor2, skin->prefcolor); - player->skincolor = newcolor = skin->prefcolor; - if (player->bot && botingame) + textcmdplayer_t *textcmdplayer = textcmdtic->playercmds[i]; + + while (textcmdplayer) { - botskin = (UINT8)(skinnum + 1); - botcolor = skin->prefcolor; + textcmdplayer_t *tcpnext = textcmdplayer->next; + Z_Free(textcmdplayer); + textcmdplayer = tcpnext; } } - if (player->followmobj) - { - P_RemoveMobj(player->followmobj); - P_SetTarget(&player->followmobj, NULL); - } - - if (player->mo) - { - fixed_t radius = FixedMul(skin->radius, player->mo->scale); - if ((player->powers[pw_carry] == CR_NIGHTSMODE) && (skin->sprites[SPR2_NFLY].numframes == 0)) // If you don't have a sprite for flying horizontally, use the default NiGHTS skin. - { - skin = &skins[DEFAULTNIGHTSSKIN]; - player->followitem = skin->followitem; - if (!(cv_debug || devparm) && !(netgame || multiplayer || demoplayback)) - newcolor = skin->prefcolor; // will be updated in thinker to flashing - } - player->mo->skin = skin; - if (newcolor) - player->mo->color = newcolor; - P_SetScale(player->mo, player->mo->scale); - player->mo->radius = radius; - - P_SetPlayerMobjState(player->mo, player->mo->state-states); // Prevent visual errors when switching between skins with differing number of frames - } - return; + // Free this tic's own memory. + Z_Free(textcmdtic); } - - if (P_IsLocalPlayer(player)) - CONS_Alert(CONS_WARNING, M_GetText("Requested skin %d not found\n"), skinnum); - else if(server || IsPlayerAdmin(consoleplayer)) - CONS_Alert(CONS_WARNING, "Player %d (%s) skin %d not found\n", playernum, player_names[playernum], skinnum); - SetPlayerSkinByNum(playernum, 0); // not found put the sonic skin } -// -// Add skins from a pwad, each skin preceded by 'S_SKIN' marker -// - -// Does the same is in w_wad, but check only for -// the first 6 characters (this is so we can have S_SKIN1, S_SKIN2.. -// for wad editors that don't like multiple resources of the same name) -// -static UINT16 W_CheckForSkinMarkerInPwad(UINT16 wadid, UINT16 startlump) +// Gets the buffer for the specified ticcmd, or NULL if there isn't one +static UINT8* D_GetExistingTextcmd(tic_t tic, INT32 playernum) { - UINT16 i; - const char *S_SKIN = "S_SKIN"; - lumpinfo_t *lump_p; + textcmdtic_t *textcmdtic = textcmds[tic & (TEXTCMD_HASH_SIZE - 1)]; + while (textcmdtic && textcmdtic->tic != tic) textcmdtic = textcmdtic->next; - // scan forward, start at - if (startlump < wadfiles[wadid]->numlumps) + // Do we have an entry for the tic? If so, look for player. + if (textcmdtic) { - lump_p = wadfiles[wadid]->lumpinfo + startlump; - for (i = startlump; i < wadfiles[wadid]->numlumps; i++, lump_p++) - if (memcmp(lump_p->name,S_SKIN,6)==0) - return i; + textcmdplayer_t *textcmdplayer = textcmdtic->playercmds[playernum & (TEXTCMD_HASH_SIZE - 1)]; + while (textcmdplayer && textcmdplayer->playernum != playernum) textcmdplayer = textcmdplayer->next; + + if (textcmdplayer) return textcmdplayer->cmd; } - return INT16_MAX; // not found + + return NULL; } -#define HUDNAMEWRITE(value) STRBUFCPY(skin->hudname, value) +// 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)]; + textcmdplayer_t *textcmdplayer, **tcpprev; -// turn _ into spaces and . into katana dot -#define SYMBOLCONVERT(name) for (value = name; *value; value++)\ - {\ - if (*value == '_') *value = ' ';\ - else if (*value == '.') *value = '\x1E';\ + // Look for the tic. + while (textcmdtic && textcmdtic->tic != tic) + { + tctprev = &textcmdtic->next; + textcmdtic = textcmdtic->next; + } + + // 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->tic = tic; + } + + tcpprev = &textcmdtic->playercmds[playernum & (TEXTCMD_HASH_SIZE - 1)]; + textcmdplayer = *tcpprev; + + // Look for the player. + while (textcmdplayer && textcmdplayer->playernum != playernum) + { + tcpprev = &textcmdplayer->next; + textcmdplayer = textcmdplayer->next; + } + + // If we don't have an entry for the player, make it. + if (!textcmdplayer) + { + textcmdplayer = *tcpprev = Z_Calloc(sizeof (textcmdplayer_t), PU_STATIC, NULL); + textcmdplayer->playernum = playernum; + } + + return textcmdplayer->cmd; +} + +static void ExtraDataTicker(void) +{ + INT32 i; + + for (i = 0; i < MAXPLAYERS; i++) + if (playeringame[i] || i == 0) + { + UINT8 *bufferstart = D_GetExistingTextcmd(gametic, i); + + if (bufferstart) + { + UINT8 *curpos = bufferstart; + UINT8 *bufferend = &curpos[curpos[0]+1]; + + curpos++; + while (curpos < bufferend) + { + if (*curpos < MAXNETXCMD && listnetxcmd[*curpos]) + { + const UINT8 id = *curpos; + curpos++; + DEBFILE(va("executing x_cmd %s ply %u ", netxcmdnames[id - 1], i)); + (listnetxcmd[id])(&curpos, i); + DEBFILE("done\n"); } - -// -// Patch skins from a pwad, each skin preceded by 'P_SKIN' marker -// - -// Does the same is in w_wad, but check only for -// the first 6 characters (this is so we can have P_SKIN1, P_SKIN2.. -// for wad editors that don't like multiple resources of the same name) -// -static UINT16 W_CheckForPatchSkinMarkerInPwad(UINT16 wadid, UINT16 startlump) -{ - UINT16 i; - const char *P_SKIN = "P_SKIN"; - lumpinfo_t *lump_p; - - // scan forward, start at - if (startlump < wadfiles[wadid]->numlumps) - { - lump_p = wadfiles[wadid]->lumpinfo + startlump; - for (i = startlump; i < wadfiles[wadid]->numlumps; i++, lump_p++) - if (memcmp(lump_p->name,P_SKIN,6)==0) - return i; - } - return INT16_MAX; // not found -} - -static void R_LoadSkinSprites(UINT16 wadnum, UINT16 *lump, UINT16 *lastlump, skin_t *skin) -{ - UINT16 newlastlump; - UINT8 sprite2; - - *lump += 1; // start after S_SKIN - *lastlump = W_CheckNumForNamePwad("S_END",wadnum,*lump); // stop at S_END - - // old wadding practices die hard -- stop at S_SKIN (or P_SKIN) or S_START if they come before S_END. - newlastlump = W_CheckForSkinMarkerInPwad(wadnum,*lump); - if (newlastlump < *lastlump) *lastlump = newlastlump; - newlastlump = W_CheckForPatchSkinMarkerInPwad(wadnum,*lump); - if (newlastlump < *lastlump) *lastlump = newlastlump; - newlastlump = W_CheckNumForNamePwad("S_START",wadnum,*lump); - if (newlastlump < *lastlump) *lastlump = newlastlump; - - // ...and let's handle super, too - newlastlump = W_CheckNumForNamePwad("S_SUPER",wadnum,*lump); - if (newlastlump < *lastlump) - { - newlastlump++; - // load all sprite sets we are aware of... for super! - for (sprite2 = 0; sprite2 < free_spr2; sprite2++) - R_AddSingleSpriteDef(spr2names[sprite2], &skin->sprites[FF_SPR2SUPER|sprite2], wadnum, newlastlump, *lastlump); - - newlastlump--; - *lastlump = newlastlump; // okay, make the normal sprite set loading end there - } - - // load all sprite sets we are aware of... for normal stuff. - for (sprite2 = 0; sprite2 < free_spr2; sprite2++) - R_AddSingleSpriteDef(spr2names[sprite2], &skin->sprites[sprite2], wadnum, *lump, *lastlump); - - if (skin->sprites[0].numframes == 0) - I_Error("R_LoadSkinSprites: no frames found for sprite SPR2_%s\n", spr2names[0]); -} - -// returns whether found appropriate property -static boolean R_ProcessPatchableFields(skin_t *skin, char *stoken, char *value) -{ - // custom translation table - if (!stricmp(stoken, "startcolor")) - skin->starttranscolor = atoi(value); - -#define FULLPROCESS(field) else if (!stricmp(stoken, #field)) skin->field = get_number(value); - // character type identification - FULLPROCESS(flags) - FULLPROCESS(ability) - FULLPROCESS(ability2) - - FULLPROCESS(thokitem) - FULLPROCESS(spinitem) - FULLPROCESS(revitem) - FULLPROCESS(followitem) -#undef FULLPROCESS - -#define GETFRACBITS(field) else if (!stricmp(stoken, #field)) skin->field = atoi(value)<field = atoi(value); - GETINT(thrustfactor) - GETINT(accelstart) - GETINT(acceleration) - GETINT(contspeed) - GETINT(contangle) -#undef GETINT - -#define GETSKINCOLOR(field) else if (!stricmp(stoken, #field)) \ -{ \ - UINT16 color = R_GetColorByName(value); \ - skin->field = (color ? color : SKINCOLOR_GREEN); \ -} - GETSKINCOLOR(prefcolor) - GETSKINCOLOR(prefoppositecolor) -#undef GETSKINCOLOR - else if (!stricmp(stoken, "supercolor")) - { - UINT16 color = R_GetSuperColorByName(value); - skin->supercolor = (color ? color : SKINCOLOR_SUPERGOLD1); - } - -#define GETFLOAT(field) else if (!stricmp(stoken, #field)) skin->field = FLOAT_TO_FIXED(atof(value)); - GETFLOAT(jumpfactor) - GETFLOAT(highresscale) - GETFLOAT(shieldscale) - GETFLOAT(camerascale) -#undef GETFLOAT - -#define GETFLAG(field) else if (!stricmp(stoken, #field)) { \ - strupr(value); \ - if (atoi(value) || value[0] == 'T' || value[0] == 'Y') \ - skin->flags |= (SF_##field); \ - else \ - skin->flags &= ~(SF_##field); \ -} - // parameters for individual character flags - // these are uppercase so they can be concatenated with SF_ - // 1, true, yes are all valid values - GETFLAG(SUPER) - GETFLAG(NOSUPERSPIN) - GETFLAG(NOSPINDASHDUST) - GETFLAG(HIRES) - GETFLAG(NOSKID) - GETFLAG(NOSPEEDADJUST) - GETFLAG(RUNONWATER) - GETFLAG(NOJUMPSPIN) - GETFLAG(NOJUMPDAMAGE) - GETFLAG(STOMPDAMAGE) - GETFLAG(MARIODAMAGE) - GETFLAG(MACHINE) - GETFLAG(DASHMODE) - GETFLAG(FASTEDGE) - GETFLAG(MULTIABILITY) - GETFLAG(NONIGHTSROTATION) - GETFLAG(NONIGHTSSUPER) -#undef GETFLAG - - else // let's check if it's a sound, otherwise error out - { - boolean found = false; - sfxenum_t i; - size_t stokenadjust; - - // Remove the prefix. (We need to affect an adjusting variable so that we can print error messages if it's not actually a sound.) - if ((stoken[0] == 'D' || stoken[0] == 'd') && (stoken[1] == 'S' || stoken[1] == 's')) // DS* - stokenadjust = 2; - else // sfx_* - stokenadjust = 4; - - // Remove the prefix. (We can affect this directly since we're not going to use it again.) - if ((value[0] == 'D' || value[0] == 'd') && (value[1] == 'S' || value[1] == 's')) // DS* - value += 2; - else // sfx_* - value += 4; - - // copy name of sounds that are remapped - // for this skin - for (i = 0; i < sfx_skinsoundslot0; i++) - { - if (!S_sfx[i].name) - continue; - if (S_sfx[i].skinsound != -1 - && !stricmp(S_sfx[i].name, - stoken + stokenadjust)) - { - skin->soundsid[S_sfx[i].skinsound] = - S_AddSoundFx(value, S_sfx[i].singularity, S_sfx[i].pitch, true); - found = true; + else + { + if (server) + { + SendKick(i, KICK_MSG_CON_FAIL | KICK_MSG_KEEP_BODY); + DEBFILE(va("player %d kicked [gametic=%u] reason as follows:\n", i, gametic)); + } + CONS_Alert(CONS_WARNING, M_GetText("Got unknown net command [%s]=%d (max %d)\n"), sizeu1(curpos - bufferstart), *curpos, bufferstart[0]); + break; + } + } } } - return found; - } + + // If you are a client, you can safely forget the net commands for this tic + // If you are the server, you need to remember them until every client has been acknowledged, + // because if you need to resend a PT_SERVERTICS packet, you will need to put the commands in it + if (client) + D_FreeTextcmd(gametic); +} + +static void D_Clearticcmd(tic_t tic) +{ + INT32 i; + + D_FreeTextcmd(tic); + + for (i = 0; i < MAXPLAYERS; i++) + netcmds[tic%BACKUPTICS][i].angleturn = 0; + + DEBFILE(va("clear tic %5u (%2u)\n", tic, tic%BACKUPTICS)); +} + +void D_ResetTiccmds(void) +{ + INT32 i; + + memset(&localcmds, 0, sizeof(ticcmd_t)); + memset(&localcmds2, 0, sizeof(ticcmd_t)); + + // Reset the net command list + for (i = 0; i < TEXTCMD_HASH_SIZE; i++) + while (textcmds[i]) + D_Clearticcmd(textcmds[i]->tic); +} + +void SendKick(UINT8 playernum, UINT8 msg) +{ + UINT8 buf[2]; + + if (!(server && cv_rejointimeout.value)) + msg &= ~KICK_MSG_KEEP_BODY; + + buf[0] = playernum; + buf[1] = msg; + SendNetXCmd(XD_KICK, &buf, 2); +} + +// ----------------------------------------------------------------- +// end of extra data function +// ----------------------------------------------------------------- + +// ----------------------------------------------------------------- +// extra data function for lmps +// ----------------------------------------------------------------- + +// if extradatabit is set, after the ziped tic you find this: +// +// type | description +// ---------+-------------- +// byte | size of the extradata +// byte | the extradata (xd) bits: see XD_... +// with this byte you know what parameter folow +// if (xd & XDNAMEANDCOLOR) +// byte | color +// char[MAXPLAYERNAME] | name of the player +// endif +// if (xd & XD_WEAPON_PREF) +// byte | original weapon switch: boolean, true if use the old +// | weapon switch methode +// char[NUMWEAPONS] | the weapon switch priority +// byte | autoaim: true if use the old autoaim system +// endif +/*boolean AddLmpExtradata(UINT8 **demo_point, INT32 playernum) +{ + UINT8 *textcmd = D_GetExistingTextcmd(gametic, playernum); + + if (!textcmd) + return false; + + M_Memcpy(*demo_point, textcmd, textcmd[0]+1); + *demo_point += textcmd[0]+1; return true; } -// -// Find skin sprites, sounds & optional status bar face, & add them -// -void R_AddSkins(UINT16 wadnum) +void ReadLmpExtraData(UINT8 **demo_pointer, INT32 playernum) { - UINT16 lump, lastlump = 0; - char *buf; - char *buf2; - char *stoken; - char *value; - size_t size; - skin_t *skin; - boolean hudname, realname; + UINT8 nextra; + UINT8 *textcmd; - // - // search for all skin markers in pwad - // + if (!demo_pointer) + return; - while ((lump = W_CheckForSkinMarkerInPwad(wadnum, lastlump)) != INT16_MAX) + textcmd = D_GetTextcmd(gametic, playernum); + nextra = **demo_pointer; + M_Memcpy(textcmd, *demo_pointer, nextra + 1); + // increment demo pointer + *demo_pointer += nextra + 1; +}*/ + +// ----------------------------------------------------------------- +// end extra data function for lmps +// ----------------------------------------------------------------- + +static INT16 Consistancy(void); + +typedef enum +{ + CL_SEARCHING, + CL_DOWNLOADFILES, + CL_ASKJOIN, + CL_WAITJOINRESPONSE, + CL_DOWNLOADSAVEGAME, + CL_CONNECTED, + CL_ABORTED +} cl_mode_t; + +static void GetPackets(void); + +static cl_mode_t cl_mode = CL_SEARCHING; + +#ifndef NONET +#define SNAKE_SPEED 5 + +#define SNAKE_NUM_BLOCKS_X 20 +#define SNAKE_NUM_BLOCKS_Y 10 +#define SNAKE_BLOCK_SIZE 12 +#define SNAKE_BORDER_SIZE 12 + +#define SNAKE_MAP_WIDTH (SNAKE_NUM_BLOCKS_X * SNAKE_BLOCK_SIZE) +#define SNAKE_MAP_HEIGHT (SNAKE_NUM_BLOCKS_Y * SNAKE_BLOCK_SIZE) + +#define SNAKE_LEFT_X ((BASEVIDWIDTH - SNAKE_MAP_WIDTH) / 2 - SNAKE_BORDER_SIZE) +#define SNAKE_RIGHT_X (SNAKE_LEFT_X + SNAKE_MAP_WIDTH + SNAKE_BORDER_SIZE * 2 - 1) +#define SNAKE_BOTTOM_Y (BASEVIDHEIGHT - 48) +#define SNAKE_TOP_Y (SNAKE_BOTTOM_Y - SNAKE_MAP_HEIGHT - SNAKE_BORDER_SIZE * 2 + 1) + +enum snake_bonustype_s { + SNAKE_BONUS_NONE = 0, + SNAKE_BONUS_SLOW, + SNAKE_BONUS_FAST, + SNAKE_BONUS_GHOST, + SNAKE_BONUS_NUKE, + SNAKE_BONUS_SCISSORS, + SNAKE_BONUS_REVERSE, + SNAKE_BONUS_EGGMAN, + SNAKE_NUM_BONUSES, +}; + +static const char *snake_bonuspatches[] = { + NULL, + "DL_SLOW", + "TVSSC0", + "TVIVC0", + "TVARC0", + "DL_SCISSORS", + "TVRCC0", + "TVEGC0", +}; + +static const char *snake_backgrounds[] = { + "RVPUMICF", + "FRSTRCKF", + "TAR", + "MMFLRB4", + "RVDARKF1", + "RVZWALF1", + "RVZWALF4", + "RVZWALF5", + "RVZGRS02", + "RVZGRS04", +}; + +typedef struct snake_s +{ + boolean paused; + boolean pausepressed; + tic_t time; + tic_t nextupdate; + boolean gameover; + UINT8 background; + + UINT16 snakelength; + enum snake_bonustype_s snakebonus; + tic_t snakebonustime; + UINT8 snakex[SNAKE_NUM_BLOCKS_X * SNAKE_NUM_BLOCKS_Y]; + UINT8 snakey[SNAKE_NUM_BLOCKS_X * SNAKE_NUM_BLOCKS_Y]; + UINT8 snakedir[SNAKE_NUM_BLOCKS_X * SNAKE_NUM_BLOCKS_Y]; + + UINT8 applex; + UINT8 appley; + + enum snake_bonustype_s bonustype; + UINT8 bonusx; + UINT8 bonusy; +} snake_t; + +static snake_t *snake = NULL; + +static void Snake_Initialise(void) +{ + if (!snake) + snake = malloc(sizeof(snake_t)); + + snake->paused = false; + snake->pausepressed = false; + snake->time = 0; + snake->nextupdate = SNAKE_SPEED; + snake->gameover = false; + snake->background = M_RandomKey(sizeof(snake_backgrounds) / sizeof(*snake_backgrounds)); + + snake->snakelength = 1; + snake->snakebonus = SNAKE_BONUS_NONE; + snake->snakex[0] = M_RandomKey(SNAKE_NUM_BLOCKS_X); + snake->snakey[0] = M_RandomKey(SNAKE_NUM_BLOCKS_Y); + snake->snakedir[0] = 0; + snake->snakedir[1] = 0; + + snake->applex = M_RandomKey(SNAKE_NUM_BLOCKS_X); + snake->appley = M_RandomKey(SNAKE_NUM_BLOCKS_Y); + + snake->bonustype = SNAKE_BONUS_NONE; +} + +static UINT8 Snake_GetOppositeDir(UINT8 dir) +{ + if (dir == 1 || dir == 3) + return dir + 1; + else if (dir == 2 || dir == 4) + return dir - 1; + else + return 12 + 5 - dir; +} + +static void Snake_FindFreeSlot(UINT8 *freex, UINT8 *freey, UINT8 headx, UINT8 heady) +{ + UINT8 x, y; + UINT16 i; + + do { - // advance by default - lastlump = lump + 1; + x = M_RandomKey(SNAKE_NUM_BLOCKS_X); + y = M_RandomKey(SNAKE_NUM_BLOCKS_Y); - if (numskins >= MAXSKINS) - { - CONS_Debug(DBG_RENDER, "ignored skin (%d skins maximum)\n", MAXSKINS); - continue; // so we know how many skins couldn't be added - } - buf = W_CacheLumpNumPwad(wadnum, lump, PU_CACHE); - size = W_LumpLengthPwad(wadnum, lump); + for (i = 0; i < snake->snakelength; i++) + if (x == snake->snakex[i] && y == snake->snakey[i]) + break; + } while (i < snake->snakelength || (x == headx && y == heady) + || (x == snake->applex && y == snake->appley) + || (snake->bonustype != SNAKE_BONUS_NONE && x == snake->bonusx && y == snake->bonusy)); - // for strtok - buf2 = malloc(size+1); - if (!buf2) - I_Error("R_AddSkins: No more free memory\n"); - M_Memcpy(buf2,buf,size); - buf2[size] = '\0'; + *freex = x; + *freey = y; +} - // set defaults - skin = &skins[numskins]; - Sk_SetDefaultValue(skin); - skin->wadnum = wadnum; - hudname = realname = false; - // parse - stoken = strtok (buf2, "\r\n= "); - while (stoken) - { - if ((stoken[0] == '/' && stoken[1] == '/') - || (stoken[0] == '#'))// skip comments - { - stoken = strtok(NULL, "\r\n"); // skip end of line - goto next_token; // find the real next token - } +static void Snake_Handle(void) +{ + UINT8 x, y; + UINT8 oldx, oldy; + UINT16 i; - value = strtok(NULL, "\r\n= "); - - if (!value) - I_Error("R_AddSkins: syntax error in S_SKIN lump# %d(%s) in WAD %s\n", lump, W_CheckNameForNumPwad(wadnum,lump), wadfiles[wadnum]->filename); - - // Some of these can't go in R_ProcessPatchableFields because they have side effects for future lines. - // Others can't go in there because we don't want them to be patchable. - if (!stricmp(stoken, "name")) - { - INT32 skinnum = R_SkinAvailable(value); - strlwr(value); - if (skinnum == -1) - STRBUFCPY(skin->name, value); - // the skin name must uniquely identify a single skin - // if the name is already used I make the name 'namex' - // using the default skin name's number set above - else - { - const size_t stringspace = - strlen(value) + sizeof (numskins) + 1; - char *value2 = Z_Malloc(stringspace, PU_STATIC, NULL); - snprintf(value2, stringspace, - "%s%d", value, numskins); - value2[stringspace - 1] = '\0'; - if (R_SkinAvailable(value2) == -1) - // I'm lazy so if NEW name is already used I leave the 'skin x' - // default skin name set in Sk_SetDefaultValue - STRBUFCPY(skin->name, value2); - Z_Free(value2); - } - - // copy to hudname and fullname as a default. - if (!realname) - { - STRBUFCPY(skin->realname, skin->name); - for (value = skin->realname; *value; value++) - { - if (*value == '_') *value = ' '; // turn _ into spaces. - else if (*value == '.') *value = '\x1E'; // turn . into katana dot. - } - } - if (!hudname) - { - HUDNAMEWRITE(skin->name); - strupr(skin->hudname); - SYMBOLCONVERT(skin->hudname) - } - } - else if (!stricmp(stoken, "realname")) - { // Display name (eg. "Knuckles") - realname = true; - STRBUFCPY(skin->realname, value); - SYMBOLCONVERT(skin->realname) - if (!hudname) - HUDNAMEWRITE(skin->realname); - } - else if (!stricmp(stoken, "hudname")) - { // Life icon name (eg. "K.T.E") - hudname = true; - HUDNAMEWRITE(value); - SYMBOLCONVERT(skin->hudname) - if (!realname) - STRBUFCPY(skin->realname, skin->hudname); - } - else if (!stricmp(stoken, "availability")) - { - skin->availability = atoi(value); - if (skin->availability >= MAXUNLOCKABLES) - skin->availability = 0; - } - else if (!R_ProcessPatchableFields(skin, stoken, value)) - CONS_Debug(DBG_SETUP, "R_AddSkins: Unknown keyword '%s' in S_SKIN lump #%d (WAD %s)\n", stoken, lump, wadfiles[wadnum]->filename); - -next_token: - stoken = strtok(NULL, "\r\n= "); - } - free(buf2); - - // Add sprites - R_LoadSkinSprites(wadnum, &lump, &lastlump, skin); - //ST_LoadFaceGraphics(numskins); -- nah let's do this elsewhere - - R_FlushTranslationColormapCache(); - - if (!skin->availability) // Safe to print... - CONS_Printf(M_GetText("Added skin '%s'\n"), skin->name); -#ifdef SKINVALUES - skin_cons_t[numskins].value = numskins; - skin_cons_t[numskins].strvalue = skin->name; -#endif - -#ifdef HWRENDER - if (rendermode == render_opengl) - HWR_AddPlayerModel(numskins); -#endif - - numskins++; + // Handle retry + if (snake->gameover && (PLAYER1INPUTDOWN(gc_jump) || gamekeydown[KEY_ENTER])) + { + Snake_Initialise(); + snake->pausepressed = true; // Avoid accidental pause on respawn } - return; + + // Handle pause + if (PLAYER1INPUTDOWN(gc_pause) || gamekeydown[KEY_ENTER]) + { + if (!snake->pausepressed) + snake->paused = !snake->paused; + snake->pausepressed = true; + } + else + snake->pausepressed = false; + + if (snake->paused) + return; + + snake->time++; + + x = snake->snakex[0]; + y = snake->snakey[0]; + oldx = snake->snakex[1]; + oldy = snake->snakey[1]; + + // Update direction + if (gamekeydown[KEY_LEFTARROW]) + { + if (snake->snakelength < 2 || x <= oldx) + snake->snakedir[0] = 1; + } + else if (gamekeydown[KEY_RIGHTARROW]) + { + if (snake->snakelength < 2 || x >= oldx) + snake->snakedir[0] = 2; + } + else if (gamekeydown[KEY_UPARROW]) + { + if (snake->snakelength < 2 || y <= oldy) + snake->snakedir[0] = 3; + } + else if (gamekeydown[KEY_DOWNARROW]) + { + if (snake->snakelength < 2 || y >= oldy) + snake->snakedir[0] = 4; + } + + if (snake->snakebonustime) + { + snake->snakebonustime--; + if (!snake->snakebonustime) + snake->snakebonus = SNAKE_BONUS_NONE; + } + + snake->nextupdate--; + if (snake->nextupdate) + return; + if (snake->snakebonus == SNAKE_BONUS_SLOW) + snake->nextupdate = SNAKE_SPEED * 2; + else if (snake->snakebonus == SNAKE_BONUS_FAST) + snake->nextupdate = SNAKE_SPEED * 2 / 3; + else + snake->nextupdate = SNAKE_SPEED; + + if (snake->gameover) + return; + + // Find new position + switch (snake->snakedir[0]) + { + case 1: + if (x > 0) + x--; + else + snake->gameover = true; + break; + case 2: + if (x < SNAKE_NUM_BLOCKS_X - 1) + x++; + else + snake->gameover = true; + break; + case 3: + if (y > 0) + y--; + else + snake->gameover = true; + break; + case 4: + if (y < SNAKE_NUM_BLOCKS_Y - 1) + y++; + else + snake->gameover = true; + break; + } + + // Check collision with snake + if (snake->snakebonus != SNAKE_BONUS_GHOST) + for (i = 1; i < snake->snakelength - 1; i++) + if (x == snake->snakex[i] && y == snake->snakey[i]) + { + if (snake->snakebonus == SNAKE_BONUS_SCISSORS) + { + snake->snakebonus = SNAKE_BONUS_NONE; + snake->snakelength = i; + S_StartSound(NULL, sfx_adderr); + } + else + snake->gameover = true; + } + + if (snake->gameover) + { + S_StartSound(NULL, sfx_lose); + return; + } + + // Check collision with apple + if (x == snake->applex && y == snake->appley) + { + if (snake->snakelength + 3 < SNAKE_NUM_BLOCKS_X * SNAKE_NUM_BLOCKS_Y) + { + snake->snakelength++; + snake->snakex [snake->snakelength - 1] = snake->snakex [snake->snakelength - 2]; + snake->snakey [snake->snakelength - 1] = snake->snakey [snake->snakelength - 2]; + snake->snakedir[snake->snakelength - 1] = snake->snakedir[snake->snakelength - 2]; + } + + // Spawn new apple + Snake_FindFreeSlot(&snake->applex, &snake->appley, x, y); + + // Spawn new bonus + if (!(snake->snakelength % 5)) + { + do + { + snake->bonustype = M_RandomKey(SNAKE_NUM_BONUSES - 1) + 1; + } while (snake->snakelength > SNAKE_NUM_BLOCKS_X * SNAKE_NUM_BLOCKS_Y * 3 / 4 + && (snake->bonustype == SNAKE_BONUS_EGGMAN || snake->bonustype == SNAKE_BONUS_FAST || snake->bonustype == SNAKE_BONUS_REVERSE)); + + Snake_FindFreeSlot(&snake->bonusx, &snake->bonusy, x, y); + } + + S_StartSound(NULL, sfx_s3k6b); + } + + if (snake->snakelength > 1 && snake->snakedir[0]) + { + UINT8 dir = snake->snakedir[0]; + + oldx = snake->snakex[1]; + oldy = snake->snakey[1]; + + // Move + for (i = snake->snakelength - 1; i > 0; i--) + { + snake->snakex[i] = snake->snakex[i - 1]; + snake->snakey[i] = snake->snakey[i - 1]; + snake->snakedir[i] = snake->snakedir[i - 1]; + } + + // Handle corners + if (x < oldx && dir == 3) + dir = 5; + else if (x > oldx && dir == 3) + dir = 6; + else if (x < oldx && dir == 4) + dir = 7; + else if (x > oldx && dir == 4) + dir = 8; + else if (y < oldy && dir == 1) + dir = 9; + else if (y < oldy && dir == 2) + dir = 10; + else if (y > oldy && dir == 1) + dir = 11; + else if (y > oldy && dir == 2) + dir = 12; + snake->snakedir[1] = dir; + } + + snake->snakex[0] = x; + snake->snakey[0] = y; + + // Check collision with bonus + if (snake->bonustype != SNAKE_BONUS_NONE && x == snake->bonusx && y == snake->bonusy) + { + S_StartSound(NULL, sfx_ncchip); + + switch (snake->bonustype) + { + case SNAKE_BONUS_SLOW: + snake->snakebonus = SNAKE_BONUS_SLOW; + snake->snakebonustime = 20 * TICRATE; + break; + case SNAKE_BONUS_FAST: + snake->snakebonus = SNAKE_BONUS_FAST; + snake->snakebonustime = 20 * TICRATE; + break; + case SNAKE_BONUS_GHOST: + snake->snakebonus = SNAKE_BONUS_GHOST; + snake->snakebonustime = 10 * TICRATE; + break; + case SNAKE_BONUS_NUKE: + for (i = 0; i < snake->snakelength; i++) + { + snake->snakex [i] = snake->snakex [0]; + snake->snakey [i] = snake->snakey [0]; + snake->snakedir[i] = snake->snakedir[0]; + } + + S_StartSound(NULL, sfx_bkpoof); + break; + case SNAKE_BONUS_SCISSORS: + snake->snakebonus = SNAKE_BONUS_SCISSORS; + snake->snakebonustime = 60 * TICRATE; + break; + case SNAKE_BONUS_REVERSE: + for (i = 0; i < (snake->snakelength + 1) / 2; i++) + { + UINT16 i2 = snake->snakelength - 1 - i; + UINT8 tmpx = snake->snakex [i]; + UINT8 tmpy = snake->snakey [i]; + UINT8 tmpdir = snake->snakedir[i]; + + // Swap first segment with last segment + snake->snakex [i] = snake->snakex [i2]; + snake->snakey [i] = snake->snakey [i2]; + snake->snakedir[i] = Snake_GetOppositeDir(snake->snakedir[i2]); + snake->snakex [i2] = tmpx; + snake->snakey [i2] = tmpy; + snake->snakedir[i2] = Snake_GetOppositeDir(tmpdir); + } + + snake->snakedir[0] = 0; + + S_StartSound(NULL, sfx_gravch); + break; + default: + if (snake->snakebonus != SNAKE_BONUS_GHOST) + { + snake->gameover = true; + S_StartSound(NULL, sfx_lose); + } + } + + snake->bonustype = SNAKE_BONUS_NONE; + } +} + +static void Snake_Draw(void) +{ + INT16 i; + + // Background + V_DrawFlatFill( + SNAKE_LEFT_X + SNAKE_BORDER_SIZE, + SNAKE_TOP_Y + SNAKE_BORDER_SIZE, + SNAKE_MAP_WIDTH, + SNAKE_MAP_HEIGHT, + W_GetNumForName(snake_backgrounds[snake->background]) + ); + + // Borders + V_DrawFill(SNAKE_LEFT_X, SNAKE_TOP_Y, SNAKE_BORDER_SIZE + SNAKE_MAP_WIDTH, SNAKE_BORDER_SIZE, 242); // Top + V_DrawFill(SNAKE_LEFT_X + SNAKE_BORDER_SIZE + SNAKE_MAP_WIDTH, SNAKE_TOP_Y, SNAKE_BORDER_SIZE, SNAKE_BORDER_SIZE + SNAKE_MAP_HEIGHT, 242); // Right + V_DrawFill(SNAKE_LEFT_X + SNAKE_BORDER_SIZE, SNAKE_TOP_Y + SNAKE_BORDER_SIZE + SNAKE_MAP_HEIGHT, SNAKE_BORDER_SIZE + SNAKE_MAP_WIDTH, SNAKE_BORDER_SIZE, 242); // Bottom + V_DrawFill(SNAKE_LEFT_X, SNAKE_TOP_Y + SNAKE_BORDER_SIZE, SNAKE_BORDER_SIZE, SNAKE_BORDER_SIZE + SNAKE_MAP_HEIGHT, 242); // Left + + // Apple + V_DrawFixedPatch( + (SNAKE_LEFT_X + SNAKE_BORDER_SIZE + snake->applex * SNAKE_BLOCK_SIZE + SNAKE_BLOCK_SIZE / 2) * FRACUNIT, + (SNAKE_TOP_Y + SNAKE_BORDER_SIZE + snake->appley * SNAKE_BLOCK_SIZE + SNAKE_BLOCK_SIZE / 2) * FRACUNIT, + FRACUNIT / 4, + 0, + W_CachePatchLongName("DL_APPLE", PU_HUDGFX), + NULL + ); + + // Bonus + if (snake->bonustype != SNAKE_BONUS_NONE) + V_DrawFixedPatch( + (SNAKE_LEFT_X + SNAKE_BORDER_SIZE + snake->bonusx * SNAKE_BLOCK_SIZE + SNAKE_BLOCK_SIZE / 2 ) * FRACUNIT, + (SNAKE_TOP_Y + SNAKE_BORDER_SIZE + snake->bonusy * SNAKE_BLOCK_SIZE + SNAKE_BLOCK_SIZE / 2 + 4) * FRACUNIT, + FRACUNIT / 2, + 0, + W_CachePatchLongName(snake_bonuspatches[snake->bonustype], PU_HUDGFX), + NULL + ); + + // Snake + if (!snake->gameover || snake->time % 8 < 8 / 2) // Blink if game over + { + for (i = snake->snakelength - 1; i >= 0; i--) + { + const char *patchname; + UINT8 dir = snake->snakedir[i]; + + if (i == 0) // Head + { + switch (dir) + { + case 1: patchname = "DL_SNAKEHEAD_L"; break; + case 2: patchname = "DL_SNAKEHEAD_R"; break; + case 3: patchname = "DL_SNAKEHEAD_T"; break; + case 4: patchname = "DL_SNAKEHEAD_B"; break; + default: patchname = "DL_SNAKEHEAD_M"; + } + } + else // Body + { + switch (dir) + { + case 1: patchname = "DL_SNAKEBODY_L"; break; + case 2: patchname = "DL_SNAKEBODY_R"; break; + case 3: patchname = "DL_SNAKEBODY_T"; break; + case 4: patchname = "DL_SNAKEBODY_B"; break; + case 5: patchname = "DL_SNAKEBODY_LT"; break; + case 6: patchname = "DL_SNAKEBODY_RT"; break; + case 7: patchname = "DL_SNAKEBODY_LB"; break; + case 8: patchname = "DL_SNAKEBODY_RB"; break; + case 9: patchname = "DL_SNAKEBODY_TL"; break; + case 10: patchname = "DL_SNAKEBODY_TR"; break; + case 11: patchname = "DL_SNAKEBODY_BL"; break; + case 12: patchname = "DL_SNAKEBODY_BR"; break; + default: patchname = "DL_SNAKEBODY_B"; + } + } + + V_DrawFixedPatch( + (SNAKE_LEFT_X + SNAKE_BORDER_SIZE + snake->snakex[i] * SNAKE_BLOCK_SIZE + SNAKE_BLOCK_SIZE / 2) * FRACUNIT, + (SNAKE_TOP_Y + SNAKE_BORDER_SIZE + snake->snakey[i] * SNAKE_BLOCK_SIZE + SNAKE_BLOCK_SIZE / 2) * FRACUNIT, + i == 0 && dir == 0 ? FRACUNIT / 5 : FRACUNIT / 2, + snake->snakebonus == SNAKE_BONUS_GHOST ? V_TRANSLUCENT : 0, + W_CachePatchLongName(patchname, PU_HUDGFX), + NULL + ); + } + } + + // Length + V_DrawString(SNAKE_RIGHT_X + 4, SNAKE_TOP_Y, V_MONOSPACE, va("%u", snake->snakelength)); + + // Bonus + if (snake->snakebonus != SNAKE_BONUS_NONE + && (snake->snakebonustime >= 3 * TICRATE || snake->time % 4 < 4 / 2)) + V_DrawFixedPatch( + (SNAKE_RIGHT_X + 10) * FRACUNIT, + (SNAKE_TOP_Y + 24) * FRACUNIT, + FRACUNIT / 2, + 0, + W_CachePatchLongName(snake_bonuspatches[snake->snakebonus], PU_HUDGFX), + NULL + ); } // -// Patch skin sprites +// CL_DrawConnectionStatus // -void R_PatchSkins(UINT16 wadnum) +// Keep the local client informed of our status. +// +static inline void CL_DrawConnectionStatus(void) { - UINT16 lump, lastlump = 0; - char *buf; - char *buf2; - char *stoken; - char *value; - size_t size; - skin_t *skin; - boolean noskincomplain, realname, hudname; + INT32 ccstime = I_GetTime(); - // - // search for all skin patch markers in pwad - // + // Draw background fade + if (!menuactive) // menu already draws its own fade + V_DrawFadeScreen(0xFF00, 16); // force default - while ((lump = W_CheckForPatchSkinMarkerInPwad(wadnum, lastlump)) != INT16_MAX) + // Draw the bottom box. + M_DrawTextBox(BASEVIDWIDTH/2-128-8, BASEVIDHEIGHT-16-8, 32, 1); + V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-16-16, V_YELLOWMAP, "Press ESC to abort"); + + if (cl_mode != CL_DOWNLOADFILES) { - INT32 skinnum = 0; + INT32 i, animtime = ((ccstime / 4) & 15) + 16; + UINT8 palstart = (cl_mode == CL_SEARCHING) ? 32 : 96; + // 15 pal entries total. + const char *cltext; - // advance by default - lastlump = lump + 1; + if (!(cl_mode == CL_DOWNLOADSAVEGAME && lastfilenum != -1)) + for (i = 0; i < 16; ++i) + V_DrawFill((BASEVIDWIDTH/2-128) + (i * 16), BASEVIDHEIGHT-16, 16, 8, palstart + ((animtime - i) & 15)); - buf = W_CacheLumpNumPwad(wadnum, lump, PU_CACHE); - size = W_LumpLengthPwad(wadnum, lump); - - // for strtok - buf2 = malloc(size+1); - if (!buf2) - I_Error("R_PatchSkins: No more free memory\n"); - M_Memcpy(buf2,buf,size); - buf2[size] = '\0'; - - skin = NULL; - noskincomplain = realname = hudname = false; - - /* - Parse. Has more phases than the parser in R_AddSkins because it needs to have the patching name first (no default skin name is acceptible for patching, unlike skin creation) - */ - - stoken = strtok(buf2, "\r\n= "); - while (stoken) + switch (cl_mode) { - if ((stoken[0] == '/' && stoken[1] == '/') - || (stoken[0] == '#'))// skip comments - { - stoken = strtok(NULL, "\r\n"); // skip end of line - goto next_token; // find the real next token - } - - value = strtok(NULL, "\r\n= "); - - if (!value) - I_Error("R_PatchSkins: syntax error in P_SKIN lump# %d(%s) in WAD %s\n", lump, W_CheckNameForNumPwad(wadnum,lump), wadfiles[wadnum]->filename); - - if (!skin) // Get the name! - { - if (!stricmp(stoken, "name")) + case CL_DOWNLOADSAVEGAME: + if (lastfilenum != -1) { - strlwr(value); - skinnum = R_SkinAvailable(value); - if (skinnum != -1) - skin = &skins[skinnum]; - else - { - CONS_Debug(DBG_SETUP, "R_PatchSkins: unknown skin name in P_SKIN lump# %d(%s) in WAD %s\n", lump, W_CheckNameForNumPwad(wadnum,lump), wadfiles[wadnum]->filename); - noskincomplain = true; - } - } - } - else // Get the properties! - { - // Some of these can't go in R_ProcessPatchableFields because they have side effects for future lines. - if (!stricmp(stoken, "realname")) - { // Display name (eg. "Knuckles") - realname = true; - STRBUFCPY(skin->realname, value); - SYMBOLCONVERT(skin->realname) - if (!hudname) - HUDNAMEWRITE(skin->realname); - } - else if (!stricmp(stoken, "hudname")) - { // Life icon name (eg. "K.T.E") - hudname = true; - HUDNAMEWRITE(value); - SYMBOLCONVERT(skin->hudname) - if (!realname) - STRBUFCPY(skin->realname, skin->hudname); - } - else if (!R_ProcessPatchableFields(skin, stoken, value)) - CONS_Debug(DBG_SETUP, "R_PatchSkins: Unknown keyword '%s' in P_SKIN lump #%d (WAD %s)\n", stoken, lump, wadfiles[wadnum]->filename); - } + UINT32 currentsize = fileneeded[lastfilenum].currentsize; + UINT32 totalsize = fileneeded[lastfilenum].totalsize; + INT32 dldlength; - if (!skin) + cltext = M_GetText("Downloading game state..."); + Net_GetNetStat(); + + dldlength = (INT32)((currentsize/(double)totalsize) * 256); + if (dldlength > 256) + dldlength = 256; + V_DrawFill(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-16, 256, 8, 111); + V_DrawFill(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-16, dldlength, 8, 96); + + V_DrawString(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-16, V_20TRANS|V_MONOSPACE, + va(" %4uK/%4uK",currentsize>>10,totalsize>>10)); + + V_DrawRightAlignedString(BASEVIDWIDTH/2+128, BASEVIDHEIGHT-16, V_20TRANS|V_MONOSPACE, + va("%3.1fK/s ", ((double)getbps)/1024)); + } + else + cltext = M_GetText("Waiting to download game state..."); + break; + case CL_ASKJOIN: + case CL_WAITJOINRESPONSE: + cltext = M_GetText("Requesting to join..."); + break; + default: + cltext = M_GetText("Connecting to server..."); break; - -next_token: - stoken = strtok(NULL, "\r\n= "); } - free(buf2); - - if (!skin) // Didn't include a name parameter? What a waste. + V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-16-24, V_YELLOWMAP, cltext); + } + else + { + if (lastfilenum != -1) { - if (!noskincomplain) - CONS_Debug(DBG_SETUP, "R_PatchSkins: no skin name given in P_SKIN lump #%d (WAD %s)\n", lump, wadfiles[wadnum]->filename); + INT32 dldlength; + static char tempname[28]; + fileneeded_t *file = &fileneeded[lastfilenum]; + char *filename = file->filename; + + Snake_Draw(); + + Net_GetNetStat(); + dldlength = (INT32)((file->currentsize/(double)file->totalsize) * 256); + if (dldlength > 256) + dldlength = 256; + V_DrawFill(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-16, 256, 8, 111); + V_DrawFill(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-16, dldlength, 8, 96); + + memset(tempname, 0, sizeof(tempname)); + // offset filename to just the name only part + filename += strlen(filename) - nameonlylength(filename); + + if (strlen(filename) > sizeof(tempname)-1) // too long to display fully + { + size_t endhalfpos = strlen(filename)-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); + } + else // we can copy the whole thing in safely + { + strncpy(tempname, filename, sizeof(tempname)-1); + } + + V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-16-24, V_YELLOWMAP, + va(M_GetText("Downloading \"%s\""), tempname)); + V_DrawString(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-16, V_20TRANS|V_MONOSPACE, + va(" %4uK/%4uK",fileneeded[lastfilenum].currentsize>>10,file->totalsize>>10)); + V_DrawRightAlignedString(BASEVIDWIDTH/2+128, BASEVIDHEIGHT-16, V_20TRANS|V_MONOSPACE, + va("%3.1fK/s ", ((double)getbps)/1024)); + } + else + V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-16-24, V_YELLOWMAP, + M_GetText("Waiting to download files...")); + } +} +#endif + +/** Sends a special packet to declare how many players in local + * Used only in arbitratrenetstart() + * Sends a PT_CLIENTJOIN packet to the server + * + * \return True if the packet was successfully sent + * \todo Improve the description... + * Because to be honest, I have no idea what arbitratrenetstart is... + * Is it even used...? + * + */ +static boolean CL_SendJoin(void) +{ + UINT8 localplayers = 1; + if (netgame) + CONS_Printf(M_GetText("Sending join request...\n")); + netbuffer->packettype = PT_CLIENTJOIN; + + if (splitscreen || botingame) + localplayers++; + netbuffer->u.clientcfg.localplayers = localplayers; + netbuffer->u.clientcfg._255 = 255; + 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); + + CleanupPlayerName(consoleplayer, cv_playername.zstring); + if (splitscreen) + CleanupPlayerName(1, cv_playername2.zstring);/* 1 is a HACK? oh no */ + + strncpy(netbuffer->u.clientcfg.names[0], cv_playername.zstring, MAXPLAYERNAME); + strncpy(netbuffer->u.clientcfg.names[1], cv_playername2.zstring, MAXPLAYERNAME); + + return HSendPacket(servernode, true, 0, sizeof (clientconfig_pak)); +} + +static INT32 FindRejoinerNum(SINT8 node) +{ + char strippednodeaddress[64]; + const char *nodeaddress; + char *port; + INT32 i; + + // Make sure there is no dead dress before proceeding to the stripping + if (!I_GetNodeAddress) + return -1; + nodeaddress = I_GetNodeAddress(node); + if (!nodeaddress) + return -1; + + // Strip the address of its port + strcpy(strippednodeaddress, nodeaddress); + port = strchr(strippednodeaddress, ':'); + if (port) + *port = '\0'; + + // Check if any player matches the stripped address + for (i = 0; i < MAXPLAYERS; i++) + { + if (playeringame[i] && playeraddress[i][0] && playernode[i] == UINT8_MAX + && !strcmp(playeraddress[i], strippednodeaddress)) + return i; + } + + return -1; +} + +static void SV_SendServerInfo(INT32 node, tic_t servertime) +{ + UINT8 *p; + + 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); + // 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); + + netbuffer->u.serverinfo.numberofplayer = (UINT8)D_NumPlayers(); + netbuffer->u.serverinfo.maxplayer = (UINT8)cv_maxplayers.value; + + if (!node || FindRejoinerNum(node) != -1) + netbuffer->u.serverinfo.refusereason = 0; + else if (!cv_allownewplayer.value) + netbuffer->u.serverinfo.refusereason = 1; + else if (D_NumPlayers() >= cv_maxplayers.value) + netbuffer->u.serverinfo.refusereason = 2; + else + netbuffer->u.serverinfo.refusereason = 0; + + strncpy(netbuffer->u.serverinfo.gametypename, Gametype_Names[gametype], + sizeof netbuffer->u.serverinfo.gametypename); + netbuffer->u.serverinfo.modifiedgame = (UINT8)modifiedgame; + netbuffer->u.serverinfo.cheatsenabled = CV_CheatsEnabled(); + netbuffer->u.serverinfo.isdedicated = (UINT8)dedicated; + strncpy(netbuffer->u.serverinfo.servername, cv_servername.string, + MAXSERVERNAME); + strncpy(netbuffer->u.serverinfo.mapname, G_BuildMapName(gamemap), 7); + + M_Memcpy(netbuffer->u.serverinfo.mapmd5, mapmd5, 16); + + memset(netbuffer->u.serverinfo.maptitle, 0, sizeof netbuffer->u.serverinfo.maptitle); + + if (mapheaderinfo[gamemap-1] && *mapheaderinfo[gamemap-1]->lvlttl) + { + char *read = mapheaderinfo[gamemap-1]->lvlttl, *writ = netbuffer->u.serverinfo.maptitle; + while (writ < (netbuffer->u.serverinfo.maptitle+32) && *read != '\0') + { + if (!(*read & 0x80)) + { + *writ = toupper(*read); + writ++; + } + read++; + } + *writ = '\0'; + //strncpy(netbuffer->u.serverinfo.maptitle, (char *)mapheaderinfo[gamemap-1]->lvlttl, 33); + } + else + strncpy(netbuffer->u.serverinfo.maptitle, "UNKNOWN", 32); + + if (mapheaderinfo[gamemap-1] && !(mapheaderinfo[gamemap-1]->levelflags & LF_NOZONE)) + netbuffer->u.serverinfo.iszone = 1; + else + netbuffer->u.serverinfo.iszone = 0; + + if (mapheaderinfo[gamemap-1]) + netbuffer->u.serverinfo.actnum = mapheaderinfo[gamemap-1]->actnum; + + p = PutFileNeeded(); + + HSendPacket(node, false, 0, p - ((UINT8 *)&netbuffer->u)); +} + +static void SV_SendPlayerInfo(INT32 node) +{ + UINT8 i; + netbuffer->packettype = PT_PLAYERINFO; + + for (i = 0; i < MAXPLAYERS; i++) + { + if (!playeringame[i]) + { + netbuffer->u.playerinfo[i].num = 255; // This slot is empty. continue; } - // Patch sprites - R_LoadSkinSprites(wadnum, &lump, &lastlump, skin); - //ST_LoadFaceGraphics(skinnum); -- nah let's do this elsewhere + netbuffer->u.playerinfo[i].num = i; + strncpy(netbuffer->u.playerinfo[i].name, (const char *)&player_names[i], MAXPLAYERNAME+1); + netbuffer->u.playerinfo[i].name[MAXPLAYERNAME] = '\0'; - R_FlushTranslationColormapCache(); + //fetch IP address + //No, don't do that, you fuckface. + memset(netbuffer->u.playerinfo[i].address, 0, 4); - if (!skin->availability) // Safe to print... - CONS_Printf(M_GetText("Patched skin '%s'\n"), skin->name); + if (G_GametypeHasTeams()) + { + if (!players[i].ctfteam) + netbuffer->u.playerinfo[i].team = 255; + else + netbuffer->u.playerinfo[i].team = (UINT8)players[i].ctfteam; + } + else + { + if (players[i].spectator) + netbuffer->u.playerinfo[i].team = 255; + else + netbuffer->u.playerinfo[i].team = 0; + } + + 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 +#ifdef DEVELOP // it's safe to do this only because PLAYERINFO isn't read by the game itself + % 3 +#endif + ); + + // Extra data + netbuffer->u.playerinfo[i].data = 0; //players[i].skincolor; + + if (players[i].pflags & PF_TAGIT) + netbuffer->u.playerinfo[i].data |= 0x20; + + if (players[i].gotflag) + netbuffer->u.playerinfo[i].data |= 0x40; + + if (players[i].powers[pw_super]) + netbuffer->u.playerinfo[i].data |= 0x80; } - return; + + HSendPacket(node, false, 0, sizeof(plrinfo) * MAXPLAYERS); } -#undef HUDNAMEWRITE -#undef SYMBOLCONVERT +/** Sends a PT_SERVERCFG packet + * + * \param node The destination + * \return True if the packet was successfully sent + * + */ +static boolean SV_SendServerConfig(INT32 node) +{ + boolean waspacketsent; + + netbuffer->packettype = PT_SERVERCFG; + + netbuffer->u.servercfg.version = VERSION; + netbuffer->u.servercfg.subversion = SUBVERSION; + + netbuffer->u.servercfg.serverplayer = (UINT8)serverplayer; + netbuffer->u.servercfg.totalslotnum = (UINT8)(doomcom->numslots); + netbuffer->u.servercfg.gametic = (tic_t)LONG(gametic); + netbuffer->u.servercfg.clientnode = (UINT8)node; + netbuffer->u.servercfg.gamestate = (UINT8)gamestate; + netbuffer->u.servercfg.gametype = (UINT8)gametype; + netbuffer->u.servercfg.modifiedgame = (UINT8)modifiedgame; + + memcpy(netbuffer->u.servercfg.server_context, server_context, 8); + + { + const size_t len = sizeof (serverconfig_pak); + +#ifdef DEBUGFILE + if (debugfile) + { + fprintf(debugfile, "ServerConfig Packet about to be sent, size of packet:%s to node:%d\n", + sizeu1(len), node); + } +#endif + + waspacketsent = HSendPacket(node, true, 0, len); + } + +#ifdef DEBUGFILE + if (debugfile) + { + if (waspacketsent) + { + fprintf(debugfile, "ServerConfig Packet was sent\n"); + } + else + { + fprintf(debugfile, "ServerConfig Packet could not be sent right now\n"); + } + } +#endif + + return waspacketsent; +} + +#ifndef NONET +#define SAVEGAMESIZE (768*1024) + +static boolean SV_ResendingSavegameToAnyone(void) +{ + INT32 i; + + for (i = 0; i < MAXNETNODES; i++) + if (resendingsavegame[i]) + return true; + return false; +} + +static void SV_SendSaveGame(INT32 node, boolean resending) +{ + size_t length, compressedlen; + UINT8 *savebuffer; + UINT8 *compressedsave; + UINT8 *buffertosend; + + // first save it in a malloced buffer + savebuffer = (UINT8 *)malloc(SAVEGAMESIZE); + if (!savebuffer) + { + CONS_Alert(CONS_ERROR, M_GetText("No more free memory for savegame\n")); + return; + } + + // Leave room for the uncompressed length. + save_p = savebuffer + sizeof(UINT32); + + P_SaveNetGame(resending); + + length = save_p - savebuffer; + if (length > SAVEGAMESIZE) + { + free(savebuffer); + save_p = NULL; + I_Error("Savegame buffer overrun"); + } + + // Allocate space for compressed save: one byte fewer than for the + // uncompressed data to ensure that the compression is worthwhile. + compressedsave = malloc(length - 1); + if (!compressedsave) + { + CONS_Alert(CONS_ERROR, M_GetText("No more free memory for savegame\n")); + return; + } + + // Attempt to compress it. + if((compressedlen = lzf_compress(savebuffer + sizeof(UINT32), length - sizeof(UINT32), compressedsave + sizeof(UINT32), length - sizeof(UINT32) - 1))) + { + // Compressing succeeded; send compressed data + + free(savebuffer); + + // State that we're compressed. + buffertosend = compressedsave; + WRITEUINT32(compressedsave, length - sizeof(UINT32)); + length = compressedlen + sizeof(UINT32); + } + else + { + // Compression failed to make it smaller; send original + + free(compressedsave); + + // State that we're not compressed + buffertosend = savebuffer; + WRITEUINT32(savebuffer, 0); + } + + AddRamToSendQueue(node, buffertosend, length, SF_RAM, 0); + save_p = NULL; + + // Remember when we started sending the savegame so we can handle timeouts + sendingsavegame[node] = true; + freezetimeout[node] = I_GetTime() + jointimeout + length / 1024; // 1 extra tic for each kilobyte +} + +#ifdef DUMPCONSISTENCY +#define TMPSAVENAME "badmath.sav" +static consvar_t cv_dumpconsistency = CVAR_INIT ("dumpconsistency", "Off", CV_SAVE|CV_NETVAR, CV_OnOff, NULL); + +static void SV_SavedGame(void) +{ + size_t length; + UINT8 *savebuffer; + char tmpsave[256]; + + if (!cv_dumpconsistency.value) + return; + + sprintf(tmpsave, "%s" PATHSEP TMPSAVENAME, srb2home); + + // first save it in a malloced buffer + save_p = savebuffer = (UINT8 *)malloc(SAVEGAMESIZE); + if (!save_p) + { + CONS_Alert(CONS_ERROR, M_GetText("No more free memory for savegame\n")); + return; + } + + P_SaveNetGame(false); + + length = save_p - savebuffer; + if (length > SAVEGAMESIZE) + { + free(savebuffer); + save_p = NULL; + I_Error("Savegame buffer overrun"); + } + + // then save it! + if (!FIL_WriteFile(tmpsave, savebuffer, length)) + CONS_Printf(M_GetText("Didn't save %s for netgame"), tmpsave); + + free(savebuffer); + save_p = NULL; +} + +#undef TMPSAVENAME +#endif +#define TMPSAVENAME "$$$.sav" + + +static void CL_LoadReceivedSavegame(boolean reloading) +{ + UINT8 *savebuffer = NULL; + size_t length, decompressedlen; + char tmpsave[256]; + + sprintf(tmpsave, "%s" PATHSEP TMPSAVENAME, srb2home); + + length = FIL_ReadFile(tmpsave, &savebuffer); + + CONS_Printf(M_GetText("Loading savegame length %s\n"), sizeu1(length)); + if (!length) + { + I_Error("Can't read savegame sent"); + return; + } + + save_p = savebuffer; + + // Decompress saved game if necessary. + decompressedlen = READUINT32(save_p); + if(decompressedlen > 0) + { + UINT8 *decompressedbuffer = Z_Malloc(decompressedlen, PU_STATIC, NULL); + lzf_decompress(save_p, length - sizeof(UINT32), decompressedbuffer, decompressedlen); + Z_Free(savebuffer); + save_p = savebuffer = decompressedbuffer; + } + + paused = false; + demoplayback = false; + titlemapinaction = TITLEMAP_OFF; + titledemo = false; + automapactive = false; + + // load a base level + if (P_LoadNetGame(reloading)) + { + const UINT8 actnum = mapheaderinfo[gamemap-1]->actnum; + CONS_Printf(M_GetText("Map is now \"%s"), G_BuildMapName(gamemap)); + if (strcmp(mapheaderinfo[gamemap-1]->lvlttl, "")) + { + CONS_Printf(": %s", mapheaderinfo[gamemap-1]->lvlttl); + if (!(mapheaderinfo[gamemap-1]->levelflags & LF_NOZONE)) + CONS_Printf(M_GetText(" Zone")); + if (actnum > 0) + CONS_Printf(" %2d", actnum); + } + CONS_Printf("\"\n"); + } + else + { + CONS_Alert(CONS_ERROR, M_GetText("Can't load the level!\n")); + Z_Free(savebuffer); + save_p = NULL; + if (unlink(tmpsave) == -1) + CONS_Alert(CONS_ERROR, M_GetText("Can't delete %s\n"), tmpsave); + return; + } + + // done + Z_Free(savebuffer); + save_p = NULL; + if (unlink(tmpsave) == -1) + CONS_Alert(CONS_ERROR, M_GetText("Can't delete %s\n"), tmpsave); + consistancy[gametic%BACKUPTICS] = Consistancy(); + CON_ToggleOff(); + + // Tell the server we have received and reloaded the gamestate + // so they know they can resume the game + netbuffer->packettype = PT_RECEIVEDGAMESTATE; + HSendPacket(servernode, true, 0, 0); +} + +static void CL_ReloadReceivedSavegame(void) +{ + INT32 i; + + for (i = 0; i < MAXPLAYERS; i++) + { +#ifdef HAVE_BLUA + LUA_InvalidatePlayer(&players[i]); +#endif + sprintf(player_names[i], "Player %d", i + 1); + } + + CL_LoadReceivedSavegame(true); + + if (neededtic < gametic) + neededtic = gametic; + maketic = neededtic; + + ticcmd_oldangleturn[0] = players[consoleplayer].oldrelangleturn; + P_ForceLocalAngle(&players[consoleplayer], (angle_t)(players[consoleplayer].angleturn << 16)); + if (splitscreen) + { + ticcmd_oldangleturn[1] = players[secondarydisplayplayer].oldrelangleturn; + P_ForceLocalAngle(&players[secondarydisplayplayer], (angle_t)(players[secondarydisplayplayer].angleturn << 16)); + } + + camera.subsector = R_PointInSubsector(camera.x, camera.y); + camera2.subsector = R_PointInSubsector(camera2.x, camera2.y); + + cl_redownloadinggamestate = false; + + CONS_Printf(M_GetText("Game state reloaded\n")); +} +#endif + +#ifndef NONET +static void SendAskInfo(INT32 node) +{ + const tic_t asktime = I_GetTime(); + netbuffer->packettype = PT_ASKINFO; + netbuffer->u.askinfo.version = VERSION; + netbuffer->u.askinfo.time = (tic_t)LONG(asktime); + + // Even if this never arrives due to the host being firewalled, we've + // now allowed traffic from the host to us in, so once the MS relays + // our address to the host, it'll be able to speak to us. + HSendPacket(node, false, 0, sizeof (askinfo_pak)); +} + +serverelem_t serverlist[MAXSERVERLIST]; +UINT32 serverlistcount = 0; + +#define FORCECLOSE 0x8000 + +static void SL_ClearServerList(INT32 connectedserver) +{ + UINT32 i; + + for (i = 0; i < serverlistcount; i++) + if (connectedserver != serverlist[i].node) + { + Net_CloseConnection(serverlist[i].node|FORCECLOSE); + serverlist[i].node = 0; + } + serverlistcount = 0; +} + +static UINT32 SL_SearchServer(INT32 node) +{ + UINT32 i; + for (i = 0; i < serverlistcount; i++) + if (serverlist[i].node == node) + return i; + + return UINT32_MAX; +} + +static void SL_InsertServer(serverinfo_pak* info, SINT8 node) +{ + UINT32 i; + + // search if not already on it + i = SL_SearchServer(node); + if (i == UINT32_MAX) + { + // not found add it + if (serverlistcount >= MAXSERVERLIST) + return; // list full + + if (info->_255 != 255) + return;/* old packet format */ + + if (info->packetversion != PACKETVERSION) + return;/* old new packet format */ + + if (info->version != VERSION) + return; // Not same version. + + if (info->subversion != SUBVERSION) + return; // Close, but no cigar. + + if (strcmp(info->application, SRB2APPLICATION)) + return;/* that's a different mod */ + + i = serverlistcount++; + } + + serverlist[i].info = *info; + serverlist[i].node = node; + + // resort server list + M_SortServerList(); +} + +#if defined (MASTERSERVER) && defined (HAVE_THREADS) +struct Fetch_servers_ctx +{ + int room; + int id; +}; + +static void +Fetch_servers_thread (struct Fetch_servers_ctx *ctx) +{ + msg_server_t *server_list; + + server_list = GetShortServersList(ctx->room, ctx->id); + + if (server_list) + { + I_lock_mutex(&ms_QueryId_mutex); + { + if (ctx->id != ms_QueryId) + { + free(server_list); + server_list = NULL; + } + } + I_unlock_mutex(ms_QueryId_mutex); + + if (server_list) + { + I_lock_mutex(&m_menu_mutex); + { + if (m_waiting_mode == M_WAITING_SERVERS) + m_waiting_mode = M_NOT_WAITING; + } + I_unlock_mutex(m_menu_mutex); + + I_lock_mutex(&ms_ServerList_mutex); + { + ms_ServerList = server_list; + } + I_unlock_mutex(ms_ServerList_mutex); + } + } + + free(ctx); +} +#endif/*defined (MASTERSERVER) && defined (HAVE_THREADS)*/ + +void CL_QueryServerList (msg_server_t *server_list) +{ + INT32 i; + + for (i = 0; server_list[i].header.buffer[0]; i++) + { + // Make sure MS version matches our own, to + // thwart nefarious servers who lie to the MS. + + /* lol bruh, that version COMES from the servers */ + //if (strcmp(version, server_list[i].version) == 0) + { + INT32 node = I_NetMakeNodewPort(server_list[i].ip, server_list[i].port); + if (node == -1) + break; // no more node free + SendAskInfo(node); + // Force close the connection so that servers can't eat + // up nodes forever if we never get a reply back from them + // (usually when they've not forwarded their ports). + // + // Don't worry, we'll get in contact with the working + // servers again when they send SERVERINFO to us later! + // + // (Note: as a side effect this probably means every + // server in the list will probably be using the same node (e.g. node 1), + // not that it matters which nodes they use when + // the connections are closed afterwards anyway) + // -- Monster Iestyn 12/11/18 + Net_CloseConnection(node|FORCECLOSE); + } + } +} + +void CL_UpdateServerList(boolean internetsearch, INT32 room) +{ + (void)internetsearch; + (void)room; + + SL_ClearServerList(0); + + if (!netgame && I_NetOpenSocket) + { + if (I_NetOpenSocket()) + { + netgame = true; + multiplayer = true; + } + } + + // search for local servers + if (netgame) + SendAskInfo(BROADCASTADDR); + +#ifdef MASTERSERVER + if (internetsearch) + { +#ifdef HAVE_THREADS + struct Fetch_servers_ctx *ctx; + + ctx = malloc(sizeof *ctx); + + /* This called from M_Refresh so I don't use a mutex */ + m_waiting_mode = M_WAITING_SERVERS; + + I_lock_mutex(&ms_QueryId_mutex); + { + ctx->id = ms_QueryId; + } + I_unlock_mutex(ms_QueryId_mutex); + + ctx->room = room; + + I_spawn_thread("fetch-servers", (I_thread_fn)Fetch_servers_thread, ctx); +#else + msg_server_t *server_list; + + server_list = GetShortServersList(room, 0); + + if (server_list) + { + CL_QueryServerList(server_list); + free(server_list); + } +#endif + } +#endif/*MASTERSERVER*/ +} + +#endif // ifndef NONET + +/** Called by CL_ServerConnectionTicker + * + * \param asksent The last time we asked the server to join. We re-ask every second in case our request got lost in transmit. + * \return False if the connection was aborted + * \sa CL_ServerConnectionTicker + * \sa CL_ConnectToServer + * + */ +static boolean CL_ServerConnectionSearchTicker(tic_t *asksent) +{ +#ifndef NONET + INT32 i; + + // serverlist is updated by GetPacket function + if (serverlistcount > 0) + { + // this can be a responce to our broadcast request + if (servernode == -1 || servernode >= MAXNETNODES) + { + i = 0; + servernode = serverlist[i].node; + CONS_Printf(M_GetText("Found, ")); + } + else + { + i = SL_SearchServer(servernode); + if (i < 0) + return true; + } + + // Quit here rather than downloading files and being refused later. + if (serverlist[i].info.refusereason) + { + D_QuitNetGame(); + CL_Reset(); + D_StartTitle(); + if (serverlist[i].info.refusereason == 1) + M_StartMessage(M_GetText("The server is not accepting\njoins for the moment.\n\nPress ESC\n"), NULL, MM_NOTHING); + else if (serverlist[i].info.refusereason == 2) + M_StartMessage(va(M_GetText("Maximum players reached: %d\n\nPress ESC\n"), serverlist[i].info.maxplayer), NULL, MM_NOTHING); + else + M_StartMessage(M_GetText("You can't join.\nI don't know why,\nbut you can't join.\n\nPress ESC\n"), NULL, MM_NOTHING); + return false; + } + + if (client) + { + D_ParseFileneeded(serverlist[i].info.fileneedednum, + serverlist[i].info.fileneeded); + CONS_Printf(M_GetText("Checking files...\n")); + i = CL_CheckFiles(); + if (i == 3) // too many files + { + D_QuitNetGame(); + CL_Reset(); + D_StartTitle(); + M_StartMessage(M_GetText( + "You have too many WAD files loaded\n" + "to add ones the server is using.\n" + "Please restart SRB2 before connecting.\n\n" + "Press ESC\n" + ), NULL, MM_NOTHING); + return false; + } + else if (i == 2) // cannot join for some reason + { + D_QuitNetGame(); + CL_Reset(); + D_StartTitle(); + M_StartMessage(M_GetText( + "You have the wrong addons loaded.\n\n" + "To play on this server, restart\n" + "the game and don't load any addons.\n" + "SRB2 will automatically add\n" + "everything you need when you join.\n\n" + "Press ESC\n" + ), NULL, MM_NOTHING); + return false; + } + else if (i == 1) + cl_mode = CL_ASKJOIN; + else + { + // must download something + // can we, though? + if (!CL_CheckDownloadable()) // nope! + { + D_QuitNetGame(); + CL_Reset(); + D_StartTitle(); + M_StartMessage(M_GetText( + "You cannot connect to this server\n" + "because you cannot download the files\n" + "that you are missing from the server.\n\n" + "See the console or log file for\n" + "more details.\n\n" + "Press ESC\n" + ), NULL, MM_NOTHING); + return false; + } + // no problem if can't send packet, we will retry later + if (CL_SendFileRequest()) + { + cl_mode = CL_DOWNLOADFILES; +#ifndef NONET + Snake_Initialise(); +#endif + } + } + } + else + cl_mode = CL_ASKJOIN; // files need not be checked for the server. + + return true; + } + + // Ask the info to the server (askinfo packet) + if (*asksent + NEWTICRATE < I_GetTime()) + { + SendAskInfo(servernode); + *asksent = I_GetTime(); + } +#else + (void)asksent; + // No netgames, so we skip this state. + cl_mode = CL_ASKJOIN; +#endif // ifndef NONET/else + + return true; +} + +/** Called by CL_ConnectToServer + * + * \param tmpsave The name of the gamestate file??? + * \param oldtic Used for knowing when to poll events and redraw + * \param asksent ??? + * \return False if the connection was aborted + * \sa CL_ServerConnectionSearchTicker + * \sa CL_ConnectToServer + * + */ +static boolean CL_ServerConnectionTicker(const char *tmpsave, tic_t *oldtic, tic_t *asksent) +{ + boolean waitmore; + INT32 i; + +#ifdef NONET + (void)tmpsave; +#endif + + switch (cl_mode) + { + case CL_SEARCHING: + if (!CL_ServerConnectionSearchTicker(asksent)) + return false; + break; + + case CL_DOWNLOADFILES: + waitmore = false; + for (i = 0; i < fileneedednum; i++) + if (fileneeded[i].status == FS_DOWNLOADING + || fileneeded[i].status == FS_REQUESTED) + { + waitmore = true; + break; + } + if (waitmore) + break; // exit the case + +#ifndef NONET + if (snake) + { + free(snake); + snake = NULL; + } +#endif + + cl_mode = CL_ASKJOIN; // don't break case continue to cljoin request now + /* FALLTHRU */ + + case CL_ASKJOIN: + CL_LoadServerFiles(); +#ifndef NONET + // prepare structures to save the file + // WARNING: this can be useless in case of server not in GS_LEVEL + // but since the network layer doesn't provide ordered packets... + CL_PrepareDownloadSaveGame(tmpsave); +#endif + if (CL_SendJoin()) + cl_mode = CL_WAITJOINRESPONSE; + break; + +#ifndef NONET + case CL_DOWNLOADSAVEGAME: + // At this state, the first (and only) needed file is the gamestate + if (fileneeded[0].status == FS_FOUND) + { + // Gamestate is now handled within CL_LoadReceivedSavegame() + CL_LoadReceivedSavegame(false); + cl_mode = CL_CONNECTED; + } // don't break case continue to CL_CONNECTED + else + break; +#endif + + case CL_WAITJOINRESPONSE: + case CL_CONNECTED: + default: + break; + + // Connection closed by cancel, timeout or refusal. + case CL_ABORTED: + cl_mode = CL_SEARCHING; + return false; + + } + + GetPackets(); + Net_AckTicker(); + + // Call it only once by tic + if (*oldtic != I_GetTime()) + { + I_OsPolling(); + for (; eventtail != eventhead; eventtail = (eventtail+1) & (MAXEVENTS-1)) + G_MapEventsToControls(&events[eventtail]); + + if (gamekeydown[KEY_ESCAPE] || gamekeydown[KEY_JOY1+1]) + { + CONS_Printf(M_GetText("Network game synchronization aborted.\n")); +// M_StartMessage(M_GetText("Network game synchronization aborted.\n\nPress ESC\n"), NULL, MM_NOTHING); + +#ifndef NONET + if (snake) + { + free(snake); + snake = NULL; + } +#endif + + D_QuitNetGame(); + CL_Reset(); + D_StartTitle(); + memset(gamekeydown, 0, NUMKEYS); + return false; + } +#ifndef NONET + else if (cl_mode == CL_DOWNLOADFILES && snake) + Snake_Handle(); +#endif + + if (client && (cl_mode == CL_DOWNLOADFILES || cl_mode == CL_DOWNLOADSAVEGAME)) + FileReceiveTicker(); + + // why are these here? this is for servers, we're a client + //if (key == 's' && server) + // doomcom->numnodes = (INT16)pnumnodes; + //FileSendTicker(); + *oldtic = I_GetTime(); + +#ifndef NONET + if (client && cl_mode != CL_CONNECTED && cl_mode != CL_ABORTED) + { + if (cl_mode != CL_DOWNLOADFILES && cl_mode != CL_DOWNLOADSAVEGAME) + { + F_MenuPresTicker(true); // title sky + F_TitleScreenTicker(true); + F_TitleScreenDrawer(); + } + CL_DrawConnectionStatus(); + I_UpdateNoVsync(); // page flip or blit buffer + if (moviemode) + M_SaveFrame(); + S_UpdateSounds(); + S_UpdateClosedCaptions(); + } +#else + CON_Drawer(); + I_UpdateNoVsync(); +#endif + } + else + I_Sleep(); + + return true; +} + +/** Use adaptive send using net_bandwidth and stat.sendbytes + * + * \todo Better description... + * + */ +static void CL_ConnectToServer(void) +{ + INT32 pnumnodes, nodewaited = doomcom->numnodes, i; + tic_t oldtic; +#ifndef NONET + tic_t asksent; + char tmpsave[256]; + + sprintf(tmpsave, "%s" PATHSEP TMPSAVENAME, srb2home); + + lastfilenum = -1; +#endif + + cl_mode = CL_SEARCHING; + +#ifndef NONET + // Don't get a corrupt savegame error because tmpsave already exists + if (FIL_FileExists(tmpsave) && unlink(tmpsave) == -1) + I_Error("Can't delete %s\n", tmpsave); +#endif + + if (netgame) + { + if (servernode < 0 || servernode >= MAXNETNODES) + CONS_Printf(M_GetText("Searching for a server...\n")); + else + CONS_Printf(M_GetText("Contacting the server...\n")); + } + + if (gamestate == GS_INTERMISSION) + Y_EndIntermission(); // clean up intermission graphics etc + + DEBFILE(va("waiting %d nodes\n", doomcom->numnodes)); + G_SetGamestate(GS_WAITINGPLAYERS); + wipegamestate = GS_WAITINGPLAYERS; + + ClearAdminPlayers(); + pnumnodes = 1; + oldtic = I_GetTime() - 1; +#ifndef NONET + asksent = (tic_t) - TICRATE; + + i = SL_SearchServer(servernode); + + if (i != -1) + { + char *gametypestr = serverlist[i].info.gametypename; + CONS_Printf(M_GetText("Connecting to: %s\n"), serverlist[i].info.servername); + gametypestr[sizeof serverlist[i].info.gametypename - 1] = '\0'; + CONS_Printf(M_GetText("Gametype: %s\n"), gametypestr); + CONS_Printf(M_GetText("Version: %d.%d.%u\n"), serverlist[i].info.version/100, + serverlist[i].info.version%100, serverlist[i].info.subversion); + } + SL_ClearServerList(servernode); +#endif + + do + { + // If the connection was aborted for some reason, leave +#ifndef NONET + if (!CL_ServerConnectionTicker(tmpsave, &oldtic, &asksent)) +#else + if (!CL_ServerConnectionTicker((char*)NULL, &oldtic, (tic_t *)NULL)) +#endif + return; + + if (server) + { + pnumnodes = 0; + for (i = 0; i < MAXNETNODES; i++) + if (nodeingame[i]) + pnumnodes++; + } + } + while (!(cl_mode == CL_CONNECTED && (client || (server && nodewaited <= pnumnodes)))); + + DEBFILE(va("Synchronisation Finished\n")); + + displayplayer = consoleplayer; +} + +#ifndef NONET +typedef struct banreason_s +{ + char *reason; + struct banreason_s *prev; //-1 + struct banreason_s *next; //+1 +} banreason_t; + +static banreason_t *reasontail = NULL; //last entry, use prev +static banreason_t *reasonhead = NULL; //1st entry, use next + +static void Command_ShowBan(void) //Print out ban list +{ + size_t i; + const char *address, *mask; + banreason_t *reasonlist = reasonhead; + + if (I_GetBanAddress) + CONS_Printf(M_GetText("Ban List:\n")); + else + return; + + for (i = 0;(address = I_GetBanAddress(i)) != NULL;i++) + { + if (!I_GetBanMask || (mask = I_GetBanMask(i)) == NULL) + CONS_Printf("%s: %s ", sizeu1(i+1), address); + else + CONS_Printf("%s: %s/%s ", sizeu1(i+1), address, mask); + + if (reasonlist && reasonlist->reason) + CONS_Printf("(%s)\n", reasonlist->reason); + else + CONS_Printf("\n"); + + if (reasonlist) reasonlist = reasonlist->next; + } + + if (i == 0 && !address) + CONS_Printf(M_GetText("(empty)\n")); +} + +void D_SaveBan(void) +{ + FILE *f; + size_t i; + banreason_t *reasonlist = reasonhead; + const char *address, *mask; + + if (!reasonhead) + return; + + f = fopen(va("%s"PATHSEP"%s", srb2home, "ban.txt"), "w"); + + if (!f) + { + CONS_Alert(CONS_WARNING, M_GetText("Could not save ban list into ban.txt\n")); + return; + } + + for (i = 0;(address = I_GetBanAddress(i)) != NULL;i++) + { + if (!I_GetBanMask || (mask = I_GetBanMask(i)) == NULL) + fprintf(f, "%s 0", address); + else + fprintf(f, "%s %s", address, mask); + + if (reasonlist && reasonlist->reason) + fprintf(f, " %s\n", reasonlist->reason); + else + fprintf(f, " %s\n", "NA"); + + if (reasonlist) reasonlist = reasonlist->next; + } + + fclose(f); +} + +static void Ban_Add(const char *reason) +{ + banreason_t *reasonlist = malloc(sizeof(*reasonlist)); + + if (!reasonlist) + return; + if (!reason) + reason = "NA"; + + reasonlist->next = NULL; + reasonlist->reason = Z_StrDup(reason); + if ((reasonlist->prev = reasontail) == NULL) + reasonhead = reasonlist; + else + reasontail->next = reasonlist; + reasontail = reasonlist; +} + +static void Command_ClearBans(void) +{ + banreason_t *temp; + + if (!I_ClearBans) + return; + + I_ClearBans(); + D_SaveBan(); + reasontail = NULL; + while (reasonhead) + { + temp = reasonhead->next; + Z_Free(reasonhead->reason); + free(reasonhead); + reasonhead = temp; + } +} + +static void Ban_Load_File(boolean warning) +{ + FILE *f; + size_t i; + const char *address, *mask; + char buffer[MAX_WADPATH]; + + f = fopen(va("%s"PATHSEP"%s", srb2home, "ban.txt"), "r"); + + if (!f) + { + if (warning) + CONS_Alert(CONS_WARNING, M_GetText("Could not open ban.txt for ban list\n")); + return; + } + + if (I_ClearBans) + Command_ClearBans(); + else + { + fclose(f); + return; + } + + for (i=0; fgets(buffer, (int)sizeof(buffer), f); i++) + { + address = strtok(buffer, " \t\r\n"); + mask = strtok(NULL, " \t\r\n"); + + I_SetBanAddress(address, mask); + + Ban_Add(strtok(NULL, "\r\n")); + } + + fclose(f); +} + +static void Command_ReloadBan(void) //recheck ban.txt +{ + Ban_Load_File(true); +} + +static void Command_connect(void) +{ + if (COM_Argc() < 2 || *COM_Argv(1) == 0) + { + CONS_Printf(M_GetText( + "Connect (port): connect to a server\n" + "Connect ANY: connect to the first lan server found\n" + //"Connect SELF: connect to your own server.\n" + )); + return; + } + + if (Playing() || titledemo) + { + CONS_Printf(M_GetText("You cannot connect while in a game. End this game first.\n")); + return; + } + + // modified game check: no longer handled + // we don't request a restart unless the filelist differs + + server = false; +/* + if (!stricmp(COM_Argv(1), "self")) + { + servernode = 0; + server = true; + /// \bug should be but... + //SV_SpawnServer(); + } + else +*/ + { + // used in menu to connect to a server in the list + if (netgame && !stricmp(COM_Argv(1), "node")) + { + servernode = (SINT8)atoi(COM_Argv(2)); + } + else if (netgame) + { + CONS_Printf(M_GetText("You cannot connect while in a game. End this game first.\n")); + return; + } + else if (I_NetOpenSocket) + { + I_NetOpenSocket(); + netgame = true; + multiplayer = true; + + if (!stricmp(COM_Argv(1), "any")) + servernode = BROADCASTADDR; + else if (I_NetMakeNodewPort) + { + if (COM_Argc() >= 3) // address AND port + servernode = I_NetMakeNodewPort(COM_Argv(1), COM_Argv(2)); + else // address only, or address:port + servernode = I_NetMakeNode(COM_Argv(1)); + } + else + { + CONS_Alert(CONS_ERROR, M_GetText("There is no server identification with this network driver\n")); + D_CloseConnection(); + return; + } + } + else + CONS_Alert(CONS_ERROR, M_GetText("There is no network driver\n")); + } + + splitscreen = false; + SplitScreen_OnChange(); + botingame = false; + botskin = 0; + CL_ConnectToServer(); +} +#endif + +static void ResetNode(INT32 node); + +// +// CL_ClearPlayer +// +// Clears the player data so that a future client can use this slot +// +void CL_ClearPlayer(INT32 playernum) +{ + if (players[playernum].mo) + P_RemoveMobj(players[playernum].mo); + memset(&players[playernum], 0, sizeof (player_t)); + memset(playeraddress[playernum], 0, sizeof(*playeraddress)); +} + +// +// CL_RemovePlayer +// +// Removes a player from the current game +// +static void CL_RemovePlayer(INT32 playernum, kickreason_t reason) +{ + // Sanity check: exceptional cases (i.e. c-fails) can cause multiple + // kick commands to be issued for the same player. + if (!playeringame[playernum]) + return; + + if (server && !demoplayback && playernode[playernum] != UINT8_MAX) + { + INT32 node = playernode[playernum]; + playerpernode[node]--; + if (playerpernode[node] <= 0) + { + nodeingame[node] = false; + Net_CloseConnection(node); + ResetNode(node); + } + } + + if (gametyperules & GTR_TEAMFLAGS) + P_PlayerFlagBurst(&players[playernum], false); // Don't take the flag with you! + + // If in a special stage, redistribute the player's spheres across + // the remaining players. + if (G_IsSpecialStage(gamemap)) + { + INT32 i, count, sincrement, spheres, rincrement, rings; + + for (i = 0, count = 0; i < MAXPLAYERS; i++) + { + if (playeringame[i]) + count++; + } + + count--; + sincrement = spheres = players[playernum].spheres; + rincrement = rings = players[playernum].rings; + + if (count) + { + sincrement /= count; + rincrement /= count; + } + + for (i = 0; i < MAXPLAYERS; i++) + { + if (playeringame[i] && i != playernum) + { + if (spheres < 2*sincrement) + { + P_GivePlayerSpheres(&players[i], spheres); + spheres = 0; + } + else + { + P_GivePlayerSpheres(&players[i], sincrement); + spheres -= sincrement; + } + + if (rings < 2*rincrement) + { + P_GivePlayerRings(&players[i], rings); + rings = 0; + } + else + { + P_GivePlayerRings(&players[i], rincrement); + rings -= rincrement; + } + } + } + } + + LUAh_PlayerQuit(&players[playernum], reason); // Lua hook for player quitting + + // don't look through someone's view who isn't there + if (playernum == displayplayer) + { + // Call ViewpointSwitch hooks here. + // The viewpoint was forcibly changed. + LUAh_ViewpointSwitch(&players[consoleplayer], &players[consoleplayer], true); + displayplayer = consoleplayer; + } + + // Reset player data + CL_ClearPlayer(playernum); + + // remove avatar of player + playeringame[playernum] = false; + playernode[playernum] = UINT8_MAX; + while (!playeringame[doomcom->numslots-1] && doomcom->numslots > 1) + doomcom->numslots--; + + // Reset the name + sprintf(player_names[playernum], "Player %d", playernum+1); + + player_name_changes[playernum] = 0; + + if (IsPlayerAdmin(playernum)) + { + RemoveAdminPlayer(playernum); // don't stay admin after you're gone + } + + LUA_InvalidatePlayer(&players[playernum]); + + if (G_TagGametype()) //Check if you still have a game. Location flexible. =P + P_CheckSurvivors(); + else if (gametyperules & GTR_RACE) + P_CheckRacers(); +} + +void CL_Reset(void) +{ + if (metalrecording) + G_StopMetalRecording(false); + if (metalplayback) + G_StopMetalDemo(); + if (demorecording) + G_CheckDemoStatus(); + + // reset client/server code + DEBFILE(va("\n-=-=-=-=-=-=-= Client reset =-=-=-=-=-=-=-\n\n")); + + if (servernode > 0 && servernode < MAXNETNODES) + { + nodeingame[(UINT8)servernode] = false; + Net_CloseConnection(servernode); + } + D_CloseConnection(); // netgame = false + multiplayer = false; + servernode = 0; + server = true; + doomcom->numnodes = 1; + doomcom->numslots = 1; + SV_StopServer(); + SV_ResetServer(); + CV_RevertNetVars(); + + // make sure we don't leave any fileneeded gunk over from a failed join + fileneedednum = 0; + memset(fileneeded, 0, sizeof(fileneeded)); + + // D_StartTitle should get done now, but the calling function will handle it +} + +#ifndef NONET +static void Command_GetPlayerNum(void) +{ + INT32 i; + + for (i = 0; i < MAXPLAYERS; i++) + if (playeringame[i]) + { + if (serverplayer == i) + CONS_Printf(M_GetText("num:%2d node:%2d %s\n"), i, playernode[i], player_names[i]); + else + CONS_Printf(M_GetText("\x82num:%2d node:%2d %s\n"), i, playernode[i], player_names[i]); + } +} + +SINT8 nametonum(const char *name) +{ + INT32 playernum, i; + + if (!strcmp(name, "0")) + return 0; + + playernum = (SINT8)atoi(name); + + if (playernum < 0 || playernum >= MAXPLAYERS) + return -1; + + if (playernum) + { + if (playeringame[playernum]) + return (SINT8)playernum; + else + return -1; + } + + for (i = 0; i < MAXPLAYERS; i++) + if (playeringame[i] && !stricmp(player_names[i], name)) + return (SINT8)i; + + CONS_Printf(M_GetText("There is no player named \"%s\"\n"), name); + + return -1; +} + +/** Lists all players and their player numbers. + * + * \sa Command_GetPlayerNum + */ +static void Command_Nodes(void) +{ + INT32 i; + size_t maxlen = 0; + const char *address; + + for (i = 0; i < MAXPLAYERS; i++) + { + const size_t plen = strlen(player_names[i]); + if (playeringame[i] && plen > maxlen) + maxlen = plen; + } + + for (i = 0; i < MAXPLAYERS; i++) + { + if (playeringame[i]) + { + CONS_Printf("%.2u: %*s", i, (int)maxlen, player_names[i]); + + if (playernode[i] != UINT8_MAX) + { + CONS_Printf(" - node %.2d", playernode[i]); + if (I_GetNodeAddress && (address = I_GetNodeAddress(playernode[i])) != NULL) + CONS_Printf(" - %s", address); + } + + if (IsPlayerAdmin(i)) + CONS_Printf(M_GetText(" (verified admin)")); + + if (players[i].spectator) + CONS_Printf(M_GetText(" (spectator)")); + + CONS_Printf("\n"); + } + } +} + +static void Command_Ban(void) +{ + if (COM_Argc() < 2) + { + CONS_Printf(M_GetText("Ban : ban and kick a player\n")); + return; + } + + if (!netgame) // Don't kick Tails in splitscreen! + { + CONS_Printf(M_GetText("This only works in a netgame.\n")); + return; + } + + if (server || IsPlayerAdmin(consoleplayer)) + { + UINT8 buf[3 + MAX_REASONLENGTH]; + UINT8 *p = buf; + const SINT8 pn = nametonum(COM_Argv(1)); + const INT32 node = playernode[(INT32)pn]; + + if (pn == -1 || pn == 0) + return; + + WRITEUINT8(p, pn); + + if (server && I_Ban && !I_Ban(node)) // only the server is allowed to do this right now + { + CONS_Alert(CONS_WARNING, M_GetText("Too many bans! Geez, that's a lot of people you're excluding...\n")); + WRITEUINT8(p, KICK_MSG_GO_AWAY); + SendNetXCmd(XD_KICK, &buf, 2); + } + else + { + if (server) // only the server is allowed to do this right now + { + Ban_Add(COM_Argv(2)); + D_SaveBan(); // save the ban list + } + + if (COM_Argc() == 2) + { + WRITEUINT8(p, KICK_MSG_BANNED); + SendNetXCmd(XD_KICK, &buf, 2); + } + else + { + size_t i, j = COM_Argc(); + char message[MAX_REASONLENGTH]; + + //Steal from the motd code so you don't have to put the reason in quotes. + strlcpy(message, COM_Argv(2), sizeof message); + for (i = 3; i < j; i++) + { + strlcat(message, " ", sizeof message); + strlcat(message, COM_Argv(i), sizeof message); + } + + WRITEUINT8(p, KICK_MSG_CUSTOM_BAN); + WRITESTRINGN(p, message, MAX_REASONLENGTH); + SendNetXCmd(XD_KICK, &buf, p - buf); + } + } + } + else + CONS_Printf(M_GetText("Only the server or a remote admin can use this.\n")); + +} + +static void Command_BanIP(void) +{ + if (COM_Argc() < 2) + { + CONS_Printf(M_GetText("banip : ban an ip address\n")); + return; + } + + if (server) // Only the server can use this, otherwise does nothing. + { + const char *address = (COM_Argv(1)); + const char *reason; + + if (COM_Argc() == 2) + reason = NULL; + else + reason = COM_Argv(2); + + + if (I_SetBanAddress && I_SetBanAddress(address, NULL)) + { + if (reason) + CONS_Printf("Banned IP address %s for: %s\n", address, reason); + else + CONS_Printf("Banned IP address %s\n", address); + + Ban_Add(reason); + D_SaveBan(); + } + else + { + return; + } + } +} + +static void Command_Kick(void) +{ + if (COM_Argc() < 2) + { + CONS_Printf(M_GetText("kick : kick a player\n")); + return; + } + + //if (!netgame) // Don't kick Tails in splitscreen! + //{ + // CONS_Printf(M_GetText("This only works in a netgame.\n")); + // return; + //} + + if (server || IsPlayerAdmin(consoleplayer)) + { + UINT8 buf[3 + MAX_REASONLENGTH]; + UINT8 *p = buf; + const SINT8 pn = nametonum(COM_Argv(1)); + + if (splitscreen && (pn == 0 || pn == 1)) + { + CONS_Printf(M_GetText("Splitscreen players cannot be kicked.\n")); + return; + } + if (pn == -1 || pn == 0) + 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 + if (server && playernode[pn] != UINT8_MAX && sendingsavegame[playernode[pn]]) + { + Net_ConnectionTimeout(playernode[pn]); + return; + } + + WRITESINT8(p, pn); + + if (COM_Argc() == 2) + { + WRITEUINT8(p, KICK_MSG_GO_AWAY); + SendNetXCmd(XD_KICK, &buf, 2); + } + else + { + size_t i, j = COM_Argc(); + char message[MAX_REASONLENGTH]; + + //Steal from the motd code so you don't have to put the reason in quotes. + strlcpy(message, COM_Argv(2), sizeof message); + for (i = 3; i < j; i++) + { + strlcat(message, " ", sizeof message); + strlcat(message, COM_Argv(i), sizeof message); + } + + WRITEUINT8(p, KICK_MSG_CUSTOM_KICK); + WRITESTRINGN(p, message, MAX_REASONLENGTH); + SendNetXCmd(XD_KICK, &buf, p - buf); + } + } + else + CONS_Printf(M_GetText("Only the server or a remote admin can use this.\n")); +} +#endif + +static void Got_KickCmd(UINT8 **p, INT32 playernum) +{ + INT32 pnum, msg; + char buf[3 + MAX_REASONLENGTH]; + char *reason = buf; + kickreason_t kickreason = KR_KICK; + boolean keepbody; + + pnum = READUINT8(*p); + msg = READUINT8(*p); + keepbody = (msg & KICK_MSG_KEEP_BODY) != 0; + msg &= ~KICK_MSG_KEEP_BODY; + + if (pnum == serverplayer && IsPlayerAdmin(playernum)) + { + CONS_Printf(M_GetText("Server is being shut down remotely. Goodbye!\n")); + + if (server) + COM_BufAddText("quit\n"); + + return; + } + + // Is playernum authorized to make this kick? + if (playernum != serverplayer && !IsPlayerAdmin(playernum) + && !(playernode[playernum] != UINT8_MAX && playerpernode[playernode[playernum]] == 2 + && nodetoplayer2[playernode[playernum]] == pnum)) + { + // We received a kick command from someone who isn't the + // server or admin, and who isn't in splitscreen removing + // player 2. Thus, it must be someone with a modified + // binary, trying to kick someone but without having + // authorization. + + // We deal with this by changing the kick reason to + // "consistency failure" and kicking the offending user + // instead. + + // Note: Splitscreen in netgames is broken because of + // this. Only the server has any idea of which players + // are using splitscreen on the same computer, so + // clients cannot always determine if a kick is + // legitimate. + + CONS_Alert(CONS_WARNING, M_GetText("Illegal kick command received from %s for player %d\n"), player_names[playernum], pnum); + + // In debug, print a longer message with more details. + // TODO Callum: Should we translate this? +/* + CONS_Debug(DBG_NETPLAY, + "So, you must be asking, why is this an illegal kick?\n" + "Well, let's take a look at the facts, shall we?\n" + "\n" + "playernum (this is the guy who did it), he's %d.\n" + "pnum (the guy he's trying to kick) is %d.\n" + "playernum's node is %d.\n" + "That node has %d players.\n" + "Player 2 on that node is %d.\n" + "pnum's node is %d.\n" + "That node has %d players.\n" + "Player 2 on that node is %d.\n" + "\n" + "If you think this is a bug, please report it, including all of the details above.\n", + playernum, pnum, + playernode[playernum], playerpernode[playernode[playernum]], + nodetoplayer2[playernode[playernum]], + playernode[pnum], playerpernode[playernode[pnum]], + nodetoplayer2[playernode[pnum]]); +*/ + pnum = playernum; + msg = KICK_MSG_CON_FAIL; + keepbody = true; + } + + //CONS_Printf("\x82%s ", player_names[pnum]); + + // If a verified admin banned someone, the server needs to know about it. + // If the playernum isn't zero (the server) then the server needs to record the ban. + if (server && playernum && (msg == KICK_MSG_BANNED || msg == KICK_MSG_CUSTOM_BAN)) + { + if (I_Ban && !I_Ban(playernode[(INT32)pnum])) + CONS_Alert(CONS_WARNING, M_GetText("Too many bans! Geez, that's a lot of people you're excluding...\n")); +#ifndef NONET + else + Ban_Add(reason); +#endif + } + + switch (msg) + { + case KICK_MSG_GO_AWAY: + if (!players[pnum].quittime) + HU_AddChatText(va("\x82*%s has been kicked (Go away)", player_names[pnum]), false); + kickreason = KR_KICK; + break; + case KICK_MSG_PING_HIGH: + HU_AddChatText(va("\x82*%s left the game (Broke ping limit)", player_names[pnum]), false); + kickreason = KR_PINGLIMIT; + break; + case KICK_MSG_CON_FAIL: + HU_AddChatText(va("\x82*%s left the game (Synch Failure)", player_names[pnum]), false); + kickreason = KR_SYNCH; + + if (M_CheckParm("-consisdump")) // Helps debugging some problems + { + INT32 i; + + CONS_Printf(M_GetText("Player kicked is #%d, dumping consistency...\n"), pnum); + + for (i = 0; i < MAXPLAYERS; i++) + { + if (!playeringame[i]) + continue; + CONS_Printf("-------------------------------------\n"); + CONS_Printf("Player %d: %s\n", i, player_names[i]); + CONS_Printf("Skin: %d\n", players[i].skin); + CONS_Printf("Color: %d\n", players[i].skincolor); + CONS_Printf("Speed: %d\n",players[i].speed>>FRACBITS); + if (players[i].mo) + { + if (!players[i].mo->skin) + CONS_Printf("Mobj skin: NULL!\n"); + else + CONS_Printf("Mobj skin: %s\n", ((skin_t *)players[i].mo->skin)->name); + CONS_Printf("Position: %d, %d, %d\n", players[i].mo->x, players[i].mo->y, players[i].mo->z); + if (!players[i].mo->state) + CONS_Printf("State: S_NULL\n"); + else + CONS_Printf("State: %d\n", (statenum_t)(players[i].mo->state-states)); + } + else + CONS_Printf("Mobj: NULL\n"); + CONS_Printf("-------------------------------------\n"); + } + } + break; + case KICK_MSG_TIMEOUT: + HU_AddChatText(va("\x82*%s left the game (Connection timeout)", player_names[pnum]), false); + kickreason = KR_TIMEOUT; + break; + case KICK_MSG_PLAYER_QUIT: + if (netgame && !players[pnum].quittime) // not splitscreen/bots or soulless body + HU_AddChatText(va("\x82*%s left the game", player_names[pnum]), false); + kickreason = KR_LEAVE; + break; + case KICK_MSG_BANNED: + HU_AddChatText(va("\x82*%s has been banned (Don't come back)", player_names[pnum]), false); + kickreason = KR_BAN; + break; + case KICK_MSG_CUSTOM_KICK: + READSTRINGN(*p, reason, MAX_REASONLENGTH+1); + HU_AddChatText(va("\x82*%s has been kicked (%s)", player_names[pnum], reason), false); + kickreason = KR_KICK; + break; + case KICK_MSG_CUSTOM_BAN: + READSTRINGN(*p, reason, MAX_REASONLENGTH+1); + HU_AddChatText(va("\x82*%s has been banned (%s)", player_names[pnum], reason), false); + kickreason = KR_BAN; + break; + } + + if (pnum == consoleplayer) + { + if (Playing()) + LUAh_GameQuit(); +#ifdef DUMPCONSISTENCY + if (msg == KICK_MSG_CON_FAIL) SV_SavedGame(); +#endif + D_QuitNetGame(); + CL_Reset(); + D_StartTitle(); + if (msg == KICK_MSG_CON_FAIL) + M_StartMessage(M_GetText("Server closed connection\n(synch failure)\nPress ESC\n"), NULL, MM_NOTHING); + else if (msg == KICK_MSG_PING_HIGH) + M_StartMessage(M_GetText("Server closed connection\n(Broke ping limit)\nPress ESC\n"), NULL, MM_NOTHING); + else if (msg == KICK_MSG_BANNED) + M_StartMessage(M_GetText("You have been banned by the server\n\nPress ESC\n"), NULL, MM_NOTHING); + else if (msg == KICK_MSG_CUSTOM_KICK) + M_StartMessage(va(M_GetText("You have been kicked\n(%s)\nPress ESC\n"), reason), NULL, MM_NOTHING); + else if (msg == KICK_MSG_CUSTOM_BAN) + M_StartMessage(va(M_GetText("You have been banned\n(%s)\nPress ESC\n"), reason), NULL, MM_NOTHING); + else + M_StartMessage(M_GetText("You have been kicked by the server\n\nPress ESC\n"), NULL, MM_NOTHING); + } + else if (keepbody) + { + if (server && !demoplayback && playernode[pnum] != UINT8_MAX) + { + INT32 node = playernode[pnum]; + playerpernode[node]--; + if (playerpernode[node] <= 0) + { + nodeingame[node] = false; + Net_CloseConnection(node); + ResetNode(node); + } + } + + playernode[pnum] = UINT8_MAX; + + players[pnum].quittime = 1; + } + else + CL_RemovePlayer(pnum, kickreason); +} + +static void Command_ResendGamestate(void) +{ + SINT8 playernum; + + if (COM_Argc() == 1) + { + CONS_Printf(M_GetText("resendgamestate : resend the game state to a player\n")); + return; + } + else if (client) + { + CONS_Printf(M_GetText("Only the server can use this.\n")); + return; + } + + playernum = nametonum(COM_Argv(1)); + if (playernum == -1 || playernum == 0) + return; + + // Send a PT_WILLRESENDGAMESTATE packet to the client so they know what's going on + netbuffer->packettype = PT_WILLRESENDGAMESTATE; + if (!HSendPacket(playernode[playernum], true, 0, 0)) + { + CONS_Alert(CONS_ERROR, M_GetText("A problem occured, please try again.\n")); + return; + } +} + +static CV_PossibleValue_t netticbuffer_cons_t[] = {{0, "MIN"}, {3, "MAX"}, {0, NULL}}; +consvar_t cv_netticbuffer = CVAR_INIT ("netticbuffer", "1", CV_SAVE, netticbuffer_cons_t, NULL); + +consvar_t cv_allownewplayer = CVAR_INIT ("allowjoin", "On", CV_SAVE|CV_NETVAR, CV_OnOff, NULL); +consvar_t cv_joinnextround = CVAR_INIT ("joinnextround", "Off", CV_SAVE|CV_NETVAR, CV_OnOff, NULL); /// \todo not done +static CV_PossibleValue_t maxplayers_cons_t[] = {{2, "MIN"}, {32, "MAX"}, {0, NULL}}; +consvar_t cv_maxplayers = CVAR_INIT ("maxplayers", "8", CV_SAVE|CV_NETVAR, maxplayers_cons_t, NULL); +static CV_PossibleValue_t joindelay_cons_t[] = {{1, "MIN"}, {3600, "MAX"}, {0, "Off"}, {0, NULL}}; +consvar_t cv_joindelay = CVAR_INIT ("joindelay", "10", CV_SAVE|CV_NETVAR, joindelay_cons_t, NULL); +static CV_PossibleValue_t rejointimeout_cons_t[] = {{1, "MIN"}, {60 * FRACUNIT, "MAX"}, {0, "Off"}, {0, NULL}}; +consvar_t cv_rejointimeout = CVAR_INIT ("rejointimeout", "Off", CV_SAVE|CV_NETVAR|CV_FLOAT, rejointimeout_cons_t, NULL); + +static CV_PossibleValue_t resynchattempts_cons_t[] = {{1, "MIN"}, {20, "MAX"}, {0, "No"}, {0, NULL}}; +consvar_t cv_resynchattempts = CVAR_INIT ("resynchattempts", "10", CV_SAVE|CV_NETVAR, resynchattempts_cons_t, NULL); +consvar_t cv_blamecfail = CVAR_INIT ("blamecfail", "Off", CV_SAVE|CV_NETVAR, CV_OnOff, NULL); + +// max file size to send to a player (in kilobytes) +static CV_PossibleValue_t maxsend_cons_t[] = {{0, "MIN"}, {51200, "MAX"}, {0, NULL}}; +consvar_t cv_maxsend = CVAR_INIT ("maxsend", "4096", CV_SAVE|CV_NETVAR, maxsend_cons_t, NULL); +consvar_t cv_noticedownload = CVAR_INIT ("noticedownload", "Off", CV_SAVE|CV_NETVAR, CV_OnOff, NULL); + +// Speed of file downloading (in packets per tic) +static CV_PossibleValue_t downloadspeed_cons_t[] = {{0, "MIN"}, {32, "MAX"}, {0, NULL}}; +consvar_t cv_downloadspeed = CVAR_INIT ("downloadspeed", "16", CV_SAVE|CV_NETVAR, downloadspeed_cons_t, NULL); + +static void Got_AddPlayer(UINT8 **p, INT32 playernum); + +// called one time at init +void D_ClientServerInit(void) +{ + DEBFILE(va("- - -== SRB2 v%d.%.2d.%d "VERSIONSTRING" debugfile ==- - -\n", + VERSION/100, VERSION%100, SUBVERSION)); + +#ifndef NONET + COM_AddCommand("getplayernum", Command_GetPlayerNum); + COM_AddCommand("kick", Command_Kick); + COM_AddCommand("ban", Command_Ban); + COM_AddCommand("banip", Command_BanIP); + COM_AddCommand("clearbans", Command_ClearBans); + COM_AddCommand("showbanlist", Command_ShowBan); + COM_AddCommand("reloadbans", Command_ReloadBan); + COM_AddCommand("connect", Command_connect); + COM_AddCommand("nodes", Command_Nodes); + COM_AddCommand("resendgamestate", Command_ResendGamestate); +#ifdef PACKETDROP + COM_AddCommand("drop", Command_Drop); + COM_AddCommand("droprate", Command_Droprate); +#endif +#ifdef _DEBUG + COM_AddCommand("numnodes", Command_Numnodes); +#endif +#endif + + RegisterNetXCmd(XD_KICK, Got_KickCmd); + RegisterNetXCmd(XD_ADDPLAYER, Got_AddPlayer); +#ifndef NONET +#ifdef DUMPCONSISTENCY + CV_RegisterVar(&cv_dumpconsistency); +#endif + Ban_Load_File(false); +#endif + + gametic = 0; + localgametic = 0; + + // do not send anything before the real begin + SV_StopServer(); + SV_ResetServer(); + if (dedicated) + SV_SpawnServer(); +} + +static void ResetNode(INT32 node) +{ + nodeingame[node] = false; + nodewaiting[node] = 0; + + nettics[node] = gametic; + supposedtics[node] = gametic; + + nodetoplayer[node] = -1; + nodetoplayer2[node] = -1; + playerpernode[node] = 0; + + sendingsavegame[node] = false; + resendingsavegame[node] = false; + savegameresendcooldown[node] = 0; +} + +void SV_ResetServer(void) +{ + INT32 i; + + // +1 because this command will be executed in com_executebuffer in + // tryruntic so gametic will be incremented, anyway maketic > gametic + // is not an issue + + maketic = gametic + 1; + neededtic = maketic; + tictoclear = maketic; + + joindelay = 0; + + for (i = 0; i < MAXNETNODES; i++) + ResetNode(i); + + for (i = 0; i < MAXPLAYERS; i++) + { + LUA_InvalidatePlayer(&players[i]); + playeringame[i] = false; + playernode[i] = UINT8_MAX; + memset(playeraddress[i], 0, sizeof(*playeraddress)); + sprintf(player_names[i], "Player %d", i + 1); + adminplayers[i] = -1; // Populate the entire adminplayers array with -1. + } + + memset(player_name_changes, 0, sizeof player_name_changes); + + mynode = 0; + cl_packetmissed = false; + cl_redownloadinggamestate = false; + + if (dedicated) + { + nodeingame[0] = true; + serverplayer = 0; + } + else + serverplayer = consoleplayer; + + if (server) + servernode = 0; + + doomcom->numslots = 0; + + // clear server_context + memset(server_context, '-', 8); + + DEBFILE("\n-=-=-=-=-=-=-= Server Reset =-=-=-=-=-=-=-\n\n"); +} + +static inline void SV_GenContext(void) +{ + UINT8 i; + // generate server_context, as exactly 8 bytes of randomly mixed A-Z and a-z + // (hopefully M_Random is initialized!! if not this will be awfully silly!) + for (i = 0; i < 8; i++) + { + const char a = M_RandomKey(26*2); + if (a < 26) // uppercase + server_context[i] = 'A'+a; + else // lowercase + server_context[i] = 'a'+(a-26); + } +} + +// +// D_QuitNetGame +// Called before quitting to leave a net game +// without hanging the other players +// +void D_QuitNetGame(void) +{ + if (!netgame || !netbuffer) + return; + + DEBFILE("===========================================================================\n" + " Quitting Game, closing connection\n" + "===========================================================================\n"); + + // abort send/receive of files + CloseNetFile(); + RemoveAllLuaFileTransfers(); + waitingforluafiletransfer = false; + waitingforluafilecommand = false; + + if (server) + { + INT32 i; + + netbuffer->packettype = PT_SERVERSHUTDOWN; + for (i = 0; i < MAXNETNODES; i++) + if (nodeingame[i]) + HSendPacket(i, true, 0, 0); +#ifdef MASTERSERVER + if (serverrunning && ms_RoomId > 0) + UnregisterServer(); +#endif + } + else if (servernode > 0 && servernode < MAXNETNODES && nodeingame[(UINT8)servernode]) + { + netbuffer->packettype = PT_CLIENTQUIT; + HSendPacket(servernode, true, 0, 0); + } + + D_CloseConnection(); + ClearAdminPlayers(); + + DEBFILE("===========================================================================\n" + " Log finish\n" + "===========================================================================\n"); +#ifdef DEBUGFILE + if (debugfile) + { + fclose(debugfile); + debugfile = NULL; + } +#endif +} + +// Adds a node to the game (player will follow at map change or at savegame....) +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) + nodeingame[node] = true; +} + +// Xcmd XD_ADDPLAYER +static void Got_AddPlayer(UINT8 **p, INT32 playernum) +{ + INT16 node, newplayernum; + boolean splitscreenplayer; + boolean rejoined; + 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 | KICK_MSG_KEEP_BODY); + return; + } + + node = READUINT8(*p); + newplayernum = READUINT8(*p); + splitscreenplayer = newplayernum & 0x80; + newplayernum &= ~0x80; + + rejoined = playeringame[newplayernum]; + + if (!rejoined) + { + // Clear player before joining, lest some things get set incorrectly + // HACK: don't do this for splitscreen, it relies on preset values + if (!splitscreen && !botingame) + CL_ClearPlayer(newplayernum); + playeringame[newplayernum] = true; + G_AddPlayer(newplayernum); + if (newplayernum+1 > doomcom->numslots) + doomcom->numslots = (INT16)(newplayernum+1); + + if (server && I_GetNodeAddress) + { + const char *address = I_GetNodeAddress(node); + char *port = NULL; + if (address) // MI: fix msvcrt.dll!_mbscat crash? + { + strcpy(playeraddress[newplayernum], address); + port = strchr(playeraddress[newplayernum], ':'); + if (port) + *port = '\0'; + } + } + } + + newplayer = &players[newplayernum]; + + newplayer->jointime = 0; + newplayer->quittime = 0; + + READSTRINGN(*p, player_names[newplayernum], MAXPLAYERNAME); + + // the server is creating my player + if (node == mynode) + { + playernode[newplayernum] = 0; // for information only + if (!splitscreenplayer) + { + consoleplayer = newplayernum; + displayplayer = newplayernum; + secondarydisplayplayer = newplayernum; + DEBFILE("spawning me\n"); + ticcmd_oldangleturn[0] = newplayer->oldrelangleturn; + } + else + { + secondarydisplayplayer = newplayernum; + DEBFILE("spawning my brother\n"); + if (botingame) + newplayer->bot = 1; + ticcmd_oldangleturn[1] = newplayer->oldrelangleturn; + } + P_ForceLocalAngle(newplayer, (angle_t)(newplayer->angleturn << 16)); + D_SendPlayerConfig(); + addedtogame = true; + + if (rejoined) + { + if (newplayer->mo) + { + newplayer->viewheight = 41*newplayer->height/48; + + if (newplayer->mo->eflags & MFE_VERTICALFLIP) + newplayer->viewz = newplayer->mo->z + newplayer->mo->height - newplayer->viewheight; + else + newplayer->viewz = newplayer->mo->z + newplayer->viewheight; + } + + // wake up the status bar + ST_Start(); + // wake up the heads up text + HU_Start(); + + if (camera.chase && !splitscreenplayer) + P_ResetCamera(newplayer, &camera); + if (camera2.chase && splitscreenplayer) + P_ResetCamera(newplayer, &camera2); + } + } + + if (netgame) + { + char joinmsg[256]; + + if (rejoined) + strcpy(joinmsg, M_GetText("\x82*%s has rejoined the game (player %d)")); + else + strcpy(joinmsg, M_GetText("\x82*%s has joined the game (player %d)")); + strcpy(joinmsg, va(joinmsg, player_names[newplayernum], newplayernum)); + + // Merge join notification + IP to avoid clogging console/chat + if (server && cv_showjoinaddress.value && I_GetNodeAddress) + { + const char *address = I_GetNodeAddress(node); + if (address) + strcat(joinmsg, va(" (%s)", address)); + } + + HU_AddChatText(joinmsg, false); + } + + if (server && multiplayer && motd[0] != '\0') + COM_BufAddText(va("sayto %d %s\n", newplayernum, motd)); + + if (!rejoined) + LUAh_PlayerJoin(newplayernum); +} + +static boolean SV_AddWaitingPlayers(const char *name, const char *name2) +{ + INT32 node, n, newplayer = false; + UINT8 buf[2 + MAXPLAYERNAME]; + UINT8 *p; + INT32 newplayernum; + + for (node = 0; node < MAXNETNODES; node++) + { + // splitscreen can allow 2 player in one node + for (; nodewaiting[node] > 0; nodewaiting[node]--) + { + newplayer = true; + + newplayernum = FindRejoinerNum(node); + if (newplayernum == -1) + { + // search for a free playernum + // we can't 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) + break; + if (n == MAXNETNODES) + break; + } + } + + // should never happen since we check the playernum + // before accepting the join + I_Assert(newplayernum < MAXPLAYERS); + + playernode[newplayernum] = (UINT8)node; + + p = buf + 2; + buf[0] = (UINT8)node; + buf[1] = newplayernum; + if (playerpernode[node] < 1) + { + nodetoplayer[node] = newplayernum; + WRITESTRINGN(p, name, MAXPLAYERNAME); + } + else + { + nodetoplayer2[node] = newplayernum; + buf[1] |= 0x80; + WRITESTRINGN(p, name2, MAXPLAYERNAME); + } + playerpernode[node]++; + + SendNetXCmd(XD_ADDPLAYER, &buf, p - buf); + + DEBFILE(va("Server added player %d node %d\n", newplayernum, node)); + } + } + + return newplayer; +} + +void CL_AddSplitscreenPlayer(void) +{ + if (cl_mode == CL_CONNECTED) + CL_SendJoin(); +} + +void CL_RemoveSplitscreenPlayer(void) +{ + if (cl_mode != CL_CONNECTED) + return; + + SendKick(secondarydisplayplayer, KICK_MSG_PLAYER_QUIT); +} + +// is there a game running +boolean Playing(void) +{ + return (server && serverrunning) || (client && cl_mode == CL_CONNECTED); +} + +boolean SV_SpawnServer(void) +{ + if (demoplayback) + G_StopDemo(); // reset engine parameter + if (metalplayback) + G_StopMetalDemo(); + + if (!serverrunning) + { + CONS_Printf(M_GetText("Starting Server....\n")); + serverrunning = true; + SV_ResetServer(); + SV_GenContext(); + if (netgame && I_NetOpenSocket) + { + I_NetOpenSocket(); +#ifdef MASTERSERVER + if (ms_RoomId > 0) + RegisterServer(); +#endif + } + + // non dedicated server just connect to itself + if (!dedicated) + CL_ConnectToServer(); + else doomcom->numslots = 1; + } + + return SV_AddWaitingPlayers(cv_playername.zstring, cv_playername2.zstring); +} + +void SV_StopServer(void) +{ + tic_t i; + + if (gamestate == GS_INTERMISSION) + Y_EndIntermission(); + gamestate = wipegamestate = GS_NULL; + + localtextcmd[0] = 0; + localtextcmd2[0] = 0; + + for (i = firstticstosend; i < firstticstosend + BACKUPTICS; i++) + D_Clearticcmd(i); + + consoleplayer = 0; + cl_mode = CL_SEARCHING; + maketic = gametic+1; + neededtic = maketic; + serverrunning = false; +} + +// called at singleplayer start and stopdemo +void SV_StartSinglePlayerServer(void) +{ + server = true; + netgame = false; + multiplayer = false; + G_SetGametype(GT_COOP); + + // no more tic the game with this settings! + SV_StopServer(); + + if (splitscreen) + multiplayer = true; +} + +static void SV_SendRefuse(INT32 node, const char *reason) +{ + strcpy(netbuffer->u.serverrefuse.reason, reason); + + netbuffer->packettype = PT_SERVERREFUSE; + HSendPacket(node, true, 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) +{ + INT32 i; + size_t total = 1; // num of textcmds in the tic (ntextcmd byte) + + for (i = 0; i < MAXPLAYERS; i++) + { + UINT8 *textcmd = D_GetExistingTextcmd(tic, i); + if ((!i || playeringame[i]) && textcmd) + total += 2 + textcmd[0]; // "+2" for size and playernum + } + + return total; +} + +/** Called when a PT_CLIENTJOIN packet is received + * + * \param node The packet sender + * + */ +static void HandleConnect(SINT8 node) +{ + char names[MAXSPLITSCREENPLAYERS][MAXPLAYERNAME + 1]; + INT32 rejoinernum; + INT32 i; + + rejoinernum = FindRejoinerNum(node); + + if (bannednode && bannednode[node]) + SV_SendRefuse(node, M_GetText("You have been banned\nfrom the server.")); + else if (netbuffer->u.clientcfg._255 != 255 || + netbuffer->u.clientcfg.packetversion != PACKETVERSION) + SV_SendRefuse(node, "Incompatible packet formats."); + else if (strncmp(netbuffer->u.clientcfg.application, SRB2APPLICATION, + sizeof netbuffer->u.clientcfg.application)) + SV_SendRefuse(node, "Different SRB2 modifications\nare not compatible."); + else if (netbuffer->u.clientcfg.version != VERSION + || netbuffer->u.clientcfg.subversion != SUBVERSION) + SV_SendRefuse(node, va(M_GetText("Different SRB2 versions cannot\nplay a netgame!\n(server version %d.%d.%d)"), VERSION/100, VERSION%100, SUBVERSION)); + else if (!cv_allownewplayer.value && node && rejoinernum == -1) + SV_SendRefuse(node, M_GetText("The server is not accepting\njoins for the moment.")); + else if (D_NumPlayers() >= cv_maxplayers.value && rejoinernum == -1) + SV_SendRefuse(node, va(M_GetText("Maximum players reached: %d"), cv_maxplayers.value)); + else if (netgame && netbuffer->u.clientcfg.localplayers > 1) // Hacked client? + SV_SendRefuse(node, M_GetText("Too many players from\nthis node.")); + else if (netgame && !netbuffer->u.clientcfg.localplayers) // Stealth join? + SV_SendRefuse(node, M_GetText("No players from\nthis node.")); + else if (luafiletransfers) + SV_SendRefuse(node, M_GetText("The server is broadcasting a file\nrequested by a Lua script.\nPlease wait a bit and then\ntry rejoining.")); + else if (netgame && joindelay > 2 * (tic_t)cv_joindelay.value * TICRATE) + SV_SendRefuse(node, va(M_GetText("Too many people are connecting.\nPlease wait %d seconds and then\ntry rejoining."), + (joindelay - 2 * cv_joindelay.value * TICRATE) / TICRATE)); + else + { +#ifndef NONET + boolean newnode = false; +#endif + + for (i = 0; i < netbuffer->u.clientcfg.localplayers - playerpernode[node]; i++) + { + strlcpy(names[i], netbuffer->u.clientcfg.names[i], MAXPLAYERNAME + 1); + if (!EnsurePlayerNameIsGood(names[i], rejoinernum)) + { + SV_SendRefuse(node, "Bad player name"); + return; + } + } + + // client authorised to join + nodewaiting[node] = (UINT8)(netbuffer->u.clientcfg.localplayers - playerpernode[node]); + if (!nodeingame[node]) + { + gamestate_t backupstate = gamestate; +#ifndef NONET + newnode = true; +#endif + SV_AddNode(node); + + if (cv_joinnextround.value && gameaction == ga_nothing) + G_SetGamestate(GS_WAITINGPLAYERS); + if (!SV_SendServerConfig(node)) + { + G_SetGamestate(backupstate); + /// \note Shouldn't SV_SendRefuse be called before ResetNode? + ResetNode(node); + SV_SendRefuse(node, M_GetText("Server couldn't send info, please try again")); + /// \todo fix this !!! + return; // restart the while + } + //if (gamestate != GS_LEVEL) // GS_INTERMISSION, etc? + // SV_SendPlayerConfigs(node); // send bare minimum player info + G_SetGamestate(backupstate); + DEBFILE("new node joined\n"); + } +#ifndef NONET + if (nodewaiting[node]) + { + if ((gamestate == GS_LEVEL || gamestate == GS_INTERMISSION) && newnode) + { + SV_SendSaveGame(node, false); // send a complete game state + DEBFILE("send savegame\n"); + } + SV_AddWaitingPlayers(names[0], names[1]); + joindelay += cv_joindelay.value * TICRATE; + player_joining = true; + } +#endif + } +} + +/** Called when a PT_SERVERSHUTDOWN packet is received + * + * \param node The packet sender (should be the server) + * + */ +static void HandleShutdown(SINT8 node) +{ + (void)node; + if (Playing()) + LUAh_GameQuit(); + D_QuitNetGame(); + CL_Reset(); + D_StartTitle(); + M_StartMessage(M_GetText("Server has shutdown\n\nPress Esc\n"), NULL, MM_NOTHING); +} + +/** Called when a PT_NODETIMEOUT packet is received + * + * \param node The packet sender (should be the server) + * + */ +static void HandleTimeout(SINT8 node) +{ + (void)node; + if (Playing()) + LUAh_GameQuit(); + D_QuitNetGame(); + CL_Reset(); + D_StartTitle(); + M_StartMessage(M_GetText("Server Timeout\n\nPress Esc\n"), NULL, MM_NOTHING); +} + +#ifndef NONET +/** Called when a PT_SERVERINFO packet is received + * + * \param node The packet sender + * \note What happens if the packet comes from a client or something like that? + * + */ +static void HandleServerInfo(SINT8 node) +{ + // compute ping in ms + const tic_t ticnow = I_GetTime(); + const tic_t ticthen = (tic_t)LONG(netbuffer->u.serverinfo.time); + const tic_t ticdiff = (ticnow - ticthen)*1000/NEWTICRATE; + netbuffer->u.serverinfo.time = (tic_t)LONG(ticdiff); + netbuffer->u.serverinfo.servername[MAXSERVERNAME-1] = 0; + netbuffer->u.serverinfo.application + [sizeof netbuffer->u.serverinfo.application - 1] = '\0'; + netbuffer->u.serverinfo.gametypename + [sizeof netbuffer->u.serverinfo.gametypename - 1] = '\0'; + + SL_InsertServer(&netbuffer->u.serverinfo, node); +} +#endif + +static void PT_WillResendGamestate(void) +{ + char tmpsave[256]; + + if (server || cl_redownloadinggamestate) + return; + + // Send back a PT_CANRECEIVEGAMESTATE packet to the server + // so they know they can start sending the game state + netbuffer->packettype = PT_CANRECEIVEGAMESTATE; + if (!HSendPacket(servernode, true, 0, 0)) + return; + + CONS_Printf(M_GetText("Reloading game state...\n")); + + sprintf(tmpsave, "%s" PATHSEP TMPSAVENAME, srb2home); + + // Don't get a corrupt savegame error because tmpsave already exists + if (FIL_FileExists(tmpsave) && unlink(tmpsave) == -1) + I_Error("Can't delete %s\n", tmpsave); + + CL_PrepareDownloadSaveGame(tmpsave); + + cl_redownloadinggamestate = true; +} + +static void PT_CanReceiveGamestate(SINT8 node) +{ + if (client || sendingsavegame[node]) + return; + + CONS_Printf(M_GetText("Resending game state to %s...\n"), player_names[nodetoplayer[node]]); + + SV_SendSaveGame(node, true); // Resend a complete game state + resendingsavegame[node] = true; +} + +/** Handles a packet received from a node that isn't in game + * + * \param node The packet sender + * \todo Choose a better name, as the packet can also come from the server apparently? + * \sa HandlePacketFromPlayer + * \sa GetPackets + * + */ +static void HandlePacketFromAwayNode(SINT8 node) +{ + if (node != servernode) + DEBFILE(va("Received packet from unknown host %d\n", node)); + +// macro for packets that should only be sent by the server +// if it is NOT from the server, bail out and close the connection! +#define SERVERONLY \ + if (node != servernode) \ + { \ + Net_CloseConnection(node); \ + break; \ + } + switch (netbuffer->packettype) + { + case PT_ASKINFOVIAMS: +#if 0 + if (server && serverrunning) + { + INT32 clientnode; + if (ms_RoomId < 0) // ignore if we're not actually on the MS right now + { + Net_CloseConnection(node); // and yes, close connection + return; + } + clientnode = I_NetMakeNode(netbuffer->u.msaskinfo.clientaddr); + if (clientnode != -1) + { + SV_SendServerInfo(clientnode, (tic_t)LONG(netbuffer->u.msaskinfo.time)); + SV_SendPlayerInfo(clientnode); // Send extra info + Net_CloseConnection(clientnode); + // Don't close connection to MS... + } + else + Net_CloseConnection(node); // ...unless the IP address is not valid + } + else + Net_CloseConnection(node); // you're not supposed to get it, so ignore it +#else + Net_CloseConnection(node); +#endif + break; + + case PT_ASKINFO: + if (server && serverrunning) + { + SV_SendServerInfo(node, (tic_t)LONG(netbuffer->u.askinfo.time)); + SV_SendPlayerInfo(node); // Send extra info + } + Net_CloseConnection(node); + break; + + case PT_SERVERREFUSE: // Negative response of client join request + if (server && serverrunning) + { // But wait I thought I'm the server? + Net_CloseConnection(node); + break; + } + SERVERONLY + if (cl_mode == CL_WAITJOINRESPONSE) + { + // Save the reason so it can be displayed after quitting the netgame + char *reason = strdup(netbuffer->u.serverrefuse.reason); + if (!reason) + I_Error("Out of memory!\n"); + + D_QuitNetGame(); + CL_Reset(); + D_StartTitle(); + + M_StartMessage(va(M_GetText("Server refuses connection\n\nReason:\n%s"), + reason), NULL, MM_NOTHING); + + free(reason); + + // Will be reset by caller. Signals refusal. + cl_mode = CL_ABORTED; + } + break; + + case PT_SERVERCFG: // Positive response of client join request + { + if (server && serverrunning && node != servernode) + { // but wait I thought I'm the server? + Net_CloseConnection(node); + break; + } + SERVERONLY + /// \note how would this happen? and is it doing the right thing if it does? + if (cl_mode != CL_WAITJOINRESPONSE) + break; + + if (client) + { + maketic = gametic = neededtic = (tic_t)LONG(netbuffer->u.servercfg.gametic); + G_SetGametype(netbuffer->u.servercfg.gametype); + modifiedgame = netbuffer->u.servercfg.modifiedgame; + memcpy(server_context, netbuffer->u.servercfg.server_context, 8); + } + + nodeingame[(UINT8)servernode] = true; + serverplayer = netbuffer->u.servercfg.serverplayer; + doomcom->numslots = SHORT(netbuffer->u.servercfg.totalslotnum); + mynode = netbuffer->u.servercfg.clientnode; + if (serverplayer >= 0) + playernode[(UINT8)serverplayer] = servernode; + + if (netgame) +#ifndef NONET + CONS_Printf(M_GetText("Join accepted, waiting for complete game state...\n")); +#else + CONS_Printf(M_GetText("Join accepted, waiting for next level change...\n")); +#endif + DEBFILE(va("Server accept join gametic=%u mynode=%d\n", gametic, mynode)); + +#ifndef NONET + /// \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? + /// Also, according to HandleConnect, the server will send the savegame even during intermission... + if (netbuffer->u.servercfg.gamestate == GS_LEVEL/* || + netbuffer->u.servercfg.gamestate == GS_INTERMISSION*/) + cl_mode = CL_DOWNLOADSAVEGAME; + else +#endif + cl_mode = CL_CONNECTED; + break; + } + + // Handled in d_netfil.c + case PT_FILEFRAGMENT: + if (server) + { // But wait I thought I'm the server? + Net_CloseConnection(node); + break; + } + SERVERONLY + PT_FileFragment(); + break; + + case PT_FILEACK: + if (server) + PT_FileAck(); + break; + + case PT_FILERECEIVED: + if (server) + PT_FileReceived(); + break; + + case PT_REQUESTFILE: + if (server) + { + if (!cv_downloading.value || !PT_RequestFile(node)) + Net_CloseConnection(node); // close connection if one of the requested files could not be sent, or you disabled downloading anyway + } + else + Net_CloseConnection(node); // nope + break; + + case PT_NODETIMEOUT: + case PT_CLIENTQUIT: + if (server) + Net_CloseConnection(node); + break; + + case PT_CLIENTCMD: + break; // This is not an "unknown packet" + + 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); + break; // Ignore it + + } +#undef SERVERONLY +} + +/** Handles a packet received from a node that is in game + * + * \param node The packet sender + * \todo Choose a better name + * \sa HandlePacketFromAwayNode + * \sa GetPackets + * + */ +static void HandlePacketFromPlayer(SINT8 node) +{ + INT32 netconsole; + tic_t realend, realstart; + UINT8 *pak, *txtpak, numtxtpak; +#ifndef NOMD5 + UINT8 finalmd5[16];/* Well, it's the cool thing to do? */ +#endif + + txtpak = NULL; + + if (dedicated && node == 0) + netconsole = 0; + else + netconsole = nodetoplayer[node]; +#ifdef PARANOIA + if (netconsole >= MAXPLAYERS) + I_Error("bad table nodetoplayer: node %d player %d", doomcom->remotenode, netconsole); +#endif + + switch (netbuffer->packettype) + { +// -------------------------------------------- SERVER RECEIVE ---------- + case PT_CLIENTCMD: + case PT_CLIENT2CMD: + case PT_CLIENTMIS: + case PT_CLIENT2MIS: + case PT_NODEKEEPALIVE: + case PT_NODEKEEPALIVEMIS: + if (client) + break; + + // To save bytes, only the low byte of tic numbers are sent + // Use ExpandTics to figure out what the rest of the bytes are + realstart = ExpandTics(netbuffer->u.clientpak.client_tic, node); + realend = ExpandTics(netbuffer->u.clientpak.resendfrom, node); + + if (netbuffer->packettype == PT_CLIENTMIS || netbuffer->packettype == PT_CLIENT2MIS + || netbuffer->packettype == PT_NODEKEEPALIVEMIS + || supposedtics[node] < realend) + { + supposedtics[node] = realend; + } + // Discard out of order packet + if (nettics[node] > realend) + { + DEBFILE(va("out of order ticcmd discarded nettics = %u\n", nettics[node])); + break; + } + + // Update the nettics + nettics[node] = realend; + + // Don't do anything for packets of type NODEKEEPALIVE? + if (netconsole == -1 || netbuffer->packettype == PT_NODEKEEPALIVE + || netbuffer->packettype == PT_NODEKEEPALIVEMIS) + break; + + // As long as clients send valid ticcmds, the server can keep running, so reset the timeout + /// \todo Use a separate cvar for that kind of timeout? + freezetimeout[node] = I_GetTime() + connectiontimeout; + + // Copy ticcmd + G_MoveTiccmd(&netcmds[maketic%BACKUPTICS][netconsole], &netbuffer->u.clientpak.cmd, 1); + + // Check ticcmd for "speed hacks" + if (netcmds[maketic%BACKUPTICS][netconsole].forwardmove > MAXPLMOVE || netcmds[maketic%BACKUPTICS][netconsole].forwardmove < -MAXPLMOVE + || netcmds[maketic%BACKUPTICS][netconsole].sidemove > MAXPLMOVE || netcmds[maketic%BACKUPTICS][netconsole].sidemove < -MAXPLMOVE) + { + CONS_Alert(CONS_WARNING, M_GetText("Illegal movement value received from node %d\n"), netconsole); + //D_Clearticcmd(k); + + SendKick(netconsole, KICK_MSG_CON_FAIL); + break; + } + + // Splitscreen cmd + if ((netbuffer->packettype == PT_CLIENT2CMD || netbuffer->packettype == PT_CLIENT2MIS) + && nodetoplayer2[node] >= 0) + G_MoveTiccmd(&netcmds[maketic%BACKUPTICS][(UINT8)nodetoplayer2[node]], + &netbuffer->u.client2pak.cmd2, 1); + + // Check player consistancy during the level + if (realstart <= gametic && realstart + BACKUPTICS - 1 > gametic && gamestate == GS_LEVEL + && consistancy[realstart%BACKUPTICS] != SHORT(netbuffer->u.clientpak.consistancy) + && !resendingsavegame[node] && savegameresendcooldown[node] <= I_GetTime() + && !SV_ResendingSavegameToAnyone()) + { + if (cv_resynchattempts.value) + { + // Tell the client we are about to resend them the gamestate + netbuffer->packettype = PT_WILLRESENDGAMESTATE; + HSendPacket(node, true, 0, 0); + + resendingsavegame[node] = true; + + if (cv_blamecfail.value) + CONS_Printf(M_GetText("Synch failure for player %d (%s); expected %hd, got %hd\n"), + netconsole+1, player_names[netconsole], + consistancy[realstart%BACKUPTICS], + SHORT(netbuffer->u.clientpak.consistancy)); + DEBFILE(va("Restoring player %d (synch failure) [%update] %d!=%d\n", + netconsole, realstart, consistancy[realstart%BACKUPTICS], + SHORT(netbuffer->u.clientpak.consistancy))); + break; + } + else + { + SendKick(netconsole, KICK_MSG_CON_FAIL | KICK_MSG_KEEP_BODY); + DEBFILE(va("player %d kicked (synch failure) [%u] %d!=%d\n", + netconsole, realstart, consistancy[realstart%BACKUPTICS], + SHORT(netbuffer->u.clientpak.consistancy))); + break; + } + } + break; + case PT_TEXTCMD2: // splitscreen special + netconsole = nodetoplayer2[node]; + /* FALLTHRU */ + case PT_TEXTCMD: + if (client) + break; + + 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); + break; + } + + // 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-BASEPACKETSIZE-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-BASEPACKETSIZE-1), + node, netconsole)); + Net_UnAcknowledgePacket(node); + break; + } + + // 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); + break; + } + + // 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)); + + M_Memcpy(&textcmd[textcmd[0]+1], netbuffer->u.textcmd+1, netbuffer->u.textcmd[0]); + textcmd[0] += (UINT8)netbuffer->u.textcmd[0]; + } + break; + case PT_LOGIN: + if (client) + break; + +#ifndef NOMD5 + if (doomcom->datalength < 16)/* ignore partial sends */ + break; + + if (!adminpasswordset) + { + CONS_Printf(M_GetText("Password from %s failed (no password set).\n"), player_names[netconsole]); + break; + } + + // Do the final pass to compare with the sent md5 + D_MD5PasswordPass(adminpassmd5, 16, va("PNUM%02d", netconsole), &finalmd5); + + if (!memcmp(netbuffer->u.md5sum, finalmd5, 16)) + { + CONS_Printf(M_GetText("%s passed authentication.\n"), player_names[netconsole]); + COM_BufInsertText(va("promote %d\n", netconsole)); // do this immediately + } + else + CONS_Printf(M_GetText("Password from %s failed.\n"), player_names[netconsole]); +#endif + break; + case PT_NODETIMEOUT: + case PT_CLIENTQUIT: + if (client) + break; + + // 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]) + { + UINT8 kickmsg; + + if (netbuffer->packettype == PT_NODETIMEOUT) + kickmsg = KICK_MSG_TIMEOUT; + else + kickmsg = KICK_MSG_PLAYER_QUIT; + kickmsg |= KICK_MSG_KEEP_BODY; + + SendKick(netconsole, kickmsg); + nodetoplayer[node] = -1; + + if (nodetoplayer2[node] != -1 && nodetoplayer2[node] >= 0 + && playeringame[(UINT8)nodetoplayer2[node]]) + { + SendKick(nodetoplayer2[node], kickmsg); + nodetoplayer2[node] = -1; + } + } + Net_CloseConnection(node); + nodeingame[node] = false; + break; + case PT_CANRECEIVEGAMESTATE: + PT_CanReceiveGamestate(node); + break; + case PT_ASKLUAFILE: + if (server && luafiletransfers && luafiletransfers->nodestatus[node] == LFTNS_ASKED) + AddLuaFileToSendQueue(node, luafiletransfers->realfilename); + break; + case PT_HASLUAFILE: + if (server && luafiletransfers && luafiletransfers->nodestatus[node] == LFTNS_SENDING) + SV_HandleLuaFileSent(node); + break; + case PT_RECEIVEDGAMESTATE: + sendingsavegame[node] = false; + resendingsavegame[node] = false; + savegameresendcooldown[node] = I_GetTime() + 15 * TICRATE; + break; +// -------------------------------------------- CLIENT RECEIVE ---------- + case PT_SERVERTICS: + // Only accept PT_SERVERTICS from the server. + if (node != servernode) + { + CONS_Alert(CONS_WARNING, M_GetText("%s received from non-host %d\n"), "PT_SERVERTICS", node); + if (server) + SendKick(netconsole, KICK_MSG_CON_FAIL | KICK_MSG_KEEP_BODY); + break; + } + + realstart = netbuffer->u.serverpak.starttic; + realend = realstart + netbuffer->u.serverpak.numtics; + + if (!txtpak) + txtpak = (UINT8 *)&netbuffer->u.serverpak.cmds[netbuffer->u.serverpak.numslots + * netbuffer->u.serverpak.numtics]; + + if (realend > gametic + CLIENTBACKUPTICS) + realend = gametic + CLIENTBACKUPTICS; + cl_packetmissed = realstart > neededtic; + + if (realstart <= neededtic && realend > neededtic) + { + tic_t i, j; + pak = (UINT8 *)&netbuffer->u.serverpak.cmds; + + for (i = realstart; i < realend; i++) + { + // clear first + D_Clearticcmd(i); + + // copy the tics + pak = G_ScpyTiccmd(netcmds[i%BACKUPTICS], pak, + netbuffer->u.serverpak.numslots*sizeof (ticcmd_t)); + + // copy the textcmds + numtxtpak = *txtpak++; + for (j = 0; j < numtxtpak; j++) + { + INT32 k = *txtpak++; // playernum + const size_t txtsize = txtpak[0]+1; + + if (i >= gametic) // Don't copy old net commands + M_Memcpy(D_GetTextcmd(i, k), txtpak, txtsize); + txtpak += txtsize; + } + } + + neededtic = realend; + } + else + { + DEBFILE(va("frame not in bound: %u\n", neededtic)); + /*if (realend < neededtic - 2 * TICRATE || neededtic + 2 * TICRATE < realstart) + I_Error("Received an out of order PT_SERVERTICS packet!\n" + "Got tics %d-%d, needed tic %d\n\n" + "Please report this crash on the Master Board,\n" + "IRC or Discord so it can be fixed.\n", (INT32)realstart, (INT32)realend, (INT32)neededtic);*/ + } + break; + case PT_PING: + // Only accept PT_PING from the server. + if (node != servernode) + { + CONS_Alert(CONS_WARNING, M_GetText("%s received from non-host %d\n"), "PT_PING", node); + if (server) + SendKick(netconsole, KICK_MSG_CON_FAIL | KICK_MSG_KEEP_BODY); + break; + } + + //Update client ping table from the server. + if (client) + { + UINT8 i; + for (i = 0; i < MAXPLAYERS; i++) + if (playeringame[i]) + playerpingtable[i] = (tic_t)netbuffer->u.pingtable[i]; + + servermaxping = (tic_t)netbuffer->u.pingtable[MAXPLAYERS]; + } + + break; + case PT_SERVERCFG: + break; + case PT_FILEFRAGMENT: + // Only accept PT_FILEFRAGMENT from the server. + if (node != servernode) + { + CONS_Alert(CONS_WARNING, M_GetText("%s received from non-host %d\n"), "PT_FILEFRAGMENT", node); + if (server) + SendKick(netconsole, KICK_MSG_CON_FAIL | KICK_MSG_KEEP_BODY); + break; + } + if (client) + PT_FileFragment(); + break; + case PT_FILEACK: + if (server) + PT_FileAck(); + break; + case PT_FILERECEIVED: + if (server) + PT_FileReceived(); + break; + case PT_WILLRESENDGAMESTATE: + PT_WillResendGamestate(); + break; + case PT_SENDINGLUAFILE: + if (client) + CL_PrepareDownloadLuaFile(); + break; + default: + DEBFILE(va("UNKNOWN PACKET TYPE RECEIVED %d from host %d\n", + netbuffer->packettype, node)); + } // end switch +} + +/** Handles all received packets, if any + * + * \todo Add details to this description (lol) + * + */ +static void GetPackets(void) +{ + SINT8 node; // The packet sender + + player_joining = false; + + while (HGetPacket()) + { + node = (SINT8)doomcom->remotenode; + + if (netbuffer->packettype == PT_CLIENTJOIN && server) + { + HandleConnect(node); + continue; + } + if (node == servernode && client && cl_mode != CL_SEARCHING) + { + if (netbuffer->packettype == PT_SERVERSHUTDOWN) + { + HandleShutdown(node); + continue; + } + if (netbuffer->packettype == PT_NODETIMEOUT) + { + HandleTimeout(node); + continue; + } + } + +#ifndef NONET + if (netbuffer->packettype == PT_SERVERINFO) + { + HandleServerInfo(node); + continue; + } +#endif + + if (netbuffer->packettype == PT_PLAYERINFO) + continue; // We do nothing with PLAYERINFO, that's for the MS browser. + + // Packet received from someone already playing + if (nodeingame[node]) + HandlePacketFromPlayer(node); + // Packet received from someone not playing + else + HandlePacketFromAwayNode(node); + } +} + +// +// NetUpdate +// Builds ticcmds for console player, +// sends out a packet +// +// no more use random generator, because at very first tic isn't yet synchronized +// Note: It is called consistAncy on purpose. +// +static INT16 Consistancy(void) +{ + INT32 i; + UINT32 ret = 0; +#ifdef MOBJCONSISTANCY + thinker_t *th; + mobj_t *mo; +#endif + + DEBFILE(va("TIC %u ", gametic)); + + for (i = 0; i < MAXPLAYERS; i++) + { + if (!playeringame[i]) + ret ^= 0xCCCC; + else if (!players[i].mo); + else + { + ret += players[i].mo->x; + ret -= players[i].mo->y; + ret += players[i].powers[pw_shield]; + ret *= i+1; + } + } + // I give up + // Coop desynching enemies is painful + if (!G_PlatformGametype()) + ret += P_GetRandSeed(); + +#ifdef MOBJCONSISTANCY + for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next) + { + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) + continue; + + mo = (mobj_t *)th; + + if (mo->flags & (MF_SPECIAL | MF_SOLID | MF_PUSHABLE | MF_BOSS | MF_MISSILE | MF_SPRING | MF_MONITOR | MF_FIRE | MF_ENEMY | MF_PAIN | MF_STICKY)) + { + ret -= mo->type; + ret += mo->x; + ret -= mo->y; + ret += mo->z; + ret -= mo->momx; + ret += mo->momy; + ret -= mo->momz; + ret += mo->angle; + ret -= mo->flags; + ret += mo->flags2; + ret -= mo->eflags; + if (mo->target) + { + ret += mo->target->type; + ret -= mo->target->x; + ret += mo->target->y; + ret -= mo->target->z; + ret += mo->target->momx; + ret -= mo->target->momy; + ret += mo->target->momz; + ret -= mo->target->angle; + ret += mo->target->flags; + ret -= mo->target->flags2; + ret += mo->target->eflags; + ret -= mo->target->state - states; + ret += mo->target->tics; + ret -= mo->target->sprite; + ret += mo->target->frame; + } + else + ret ^= 0x3333; + if (mo->tracer && mo->tracer->type != MT_OVERLAY) + { + ret += mo->tracer->type; + ret -= mo->tracer->x; + ret += mo->tracer->y; + ret -= mo->tracer->z; + ret += mo->tracer->momx; + ret -= mo->tracer->momy; + ret += mo->tracer->momz; + ret -= mo->tracer->angle; + ret += mo->tracer->flags; + ret -= mo->tracer->flags2; + ret += mo->tracer->eflags; + ret -= mo->tracer->state - states; + ret += mo->tracer->tics; + ret -= mo->tracer->sprite; + ret += mo->tracer->frame; + } + else + ret ^= 0xAAAA; + ret -= mo->state - states; + ret += mo->tics; + ret -= mo->sprite; + ret += mo->frame; + } + } +#endif + + DEBFILE(va("Consistancy = %u\n", (ret & 0xFFFF))); + + return (INT16)(ret & 0xFFFF); +} + +// send the client packet to the server +static void CL_SendClientCmd(void) +{ + size_t packetsize = 0; + + netbuffer->packettype = PT_CLIENTCMD; + + if (cl_packetmissed) + netbuffer->packettype++; + 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 += 4; + packetsize = sizeof (clientcmd_pak) - sizeof (ticcmd_t) - sizeof (INT16); + HSendPacket(servernode, false, 0, packetsize); + } + else if (gamestate != GS_NULL && (addedtogame || dedicated)) + { + G_MoveTiccmd(&netbuffer->u.clientpak.cmd, &localcmds, 1); + netbuffer->u.clientpak.consistancy = SHORT(consistancy[gametic%BACKUPTICS]); + + // Send a special packet with 2 cmd for splitscreen + if (splitscreen || botingame) + { + netbuffer->packettype += 2; + G_MoveTiccmd(&netbuffer->u.client2pak.cmd2, &localcmds2, 1); + packetsize = sizeof (client2cmd_pak); + } + else + packetsize = sizeof (clientcmd_pak); + + HSendPacket(servernode, false, 0, packetsize); + } + + if (cl_mode == CL_CONNECTED || dedicated) + { + // Send extra data if needed + if (localtextcmd[0]) + { + netbuffer->packettype = PT_TEXTCMD; + M_Memcpy(netbuffer->u.textcmd,localtextcmd, localtextcmd[0]+1); + // All extra data have been sent + if (HSendPacket(servernode, true, 0, localtextcmd[0]+1)) // Send can fail... + localtextcmd[0] = 0; + } + + // Send extra data if needed for player 2 (splitscreen) + if (localtextcmd2[0]) + { + netbuffer->packettype = PT_TEXTCMD2; + M_Memcpy(netbuffer->u.textcmd, localtextcmd2, localtextcmd2[0]+1); + // All extra data have been sent + if (HSendPacket(servernode, true, 0, localtextcmd2[0]+1)) // Send can fail... + localtextcmd2[0] = 0; + } + } +} + +// send the server packet +// send tic from firstticstosend to maketic-1 +static void SV_SendTics(void) +{ + tic_t realfirsttic, lasttictosend, i; + UINT32 n; + INT32 j; + size_t packsize; + UINT8 *bufpos; + UINT8 *ntextcmd; + + // 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 + for (n = 1; n < MAXNETNODES; n++) + if (nodeingame[n]) + { + // assert supposedtics[n]>=nettics[n] + realfirsttic = supposedtics[n]; + lasttictosend = min(maketic, nettics[n] + CLIENTBACKUPTICS); + + if (realfirsttic >= lasttictosend) + { + // well we have sent all tics we will so use extrabandwidth + // 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, maketic, supposedtics[n], nettics[n])); + realfirsttic = nettics[n]; + if (realfirsttic >= lasttictosend || (I_GetTime() + n)&3) + // all tic are ok + continue; + DEBFILE(va("Sent %d anyway\n", realfirsttic)); + } + if (realfirsttic < firstticstosend) + realfirsttic = firstticstosend; + + // compute the length of the packet and cut it if too large + packsize = BASESERVERTICSSIZE; + for (i = realfirsttic; i < lasttictosend; i++) + { + packsize += sizeof (ticcmd_t) * doomcom->numslots; + packsize += TotalTextCmdPerTic(i); + + if (packsize > software_MAXPACKETLENGTH) + { + DEBFILE(va("packet too large (%s) at tic %d (should be from %d to %d)\n", + sizeu1(packsize), i, realfirsttic, lasttictosend)); + lasttictosend = i; + + // too bad: too much player have send extradata and there is too + // much data in one tic. + // To avoid it put the data on the next tic. (see getpacket + // textcmd case) but when numplayer changes the computation can be different + if (lasttictosend == realfirsttic) + { + if (packsize > MAXPACKETLENGTH) + I_Error("Too many players: can't send %s data for %d players to node %d\n" + "Well sorry nobody is perfect....\n", + sizeu1(packsize), doomcom->numslots, n); + else + { + lasttictosend++; // send it anyway! + DEBFILE("sending it anyway\n"); + } + } + break; + } + } + + // Send the tics + netbuffer->packettype = PT_SERVERTICS; + netbuffer->u.serverpak.starttic = realfirsttic; + netbuffer->u.serverpak.numtics = (UINT8)(lasttictosend - realfirsttic); + netbuffer->u.serverpak.numslots = (UINT8)SHORT(doomcom->numslots); + bufpos = (UINT8 *)&netbuffer->u.serverpak.cmds; + + for (i = realfirsttic; i < lasttictosend; i++) + { + bufpos = G_DcpyTiccmd(bufpos, netcmds[i%BACKUPTICS], doomcom->numslots * sizeof (ticcmd_t)); + } + + // add textcmds + for (i = realfirsttic; i < lasttictosend; i++) + { + ntextcmd = bufpos++; + *ntextcmd = 0; + for (j = 0; j < MAXPLAYERS; j++) + { + UINT8 *textcmd = D_GetExistingTextcmd(i, j); + INT32 size = textcmd ? textcmd[0] : 0; + + if ((!j || playeringame[j]) && size) + { + (*ntextcmd)++; + WRITEUINT8(bufpos, j); + M_Memcpy(bufpos, textcmd, size + 1); + bufpos += size + 1; + } + } + } + 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; + if (supposedtics[n] < nettics[n]) supposedtics[n] = nettics[n]; + } + // node 0 is me! + supposedtics[0] = maketic; +} + +// +// TryRunTics +// +static void Local_Maketic(INT32 realtics) +{ + I_OsPolling(); // I_Getevent + D_ProcessEvents(); // menu responder, cons responder, + // game responder calls HU_Responder, AM_Responder, + // and G_MapEventsToControls + if (!dedicated) rendergametic = gametic; + // translate inputs (keyboard/mouse/joystick) into game controls + G_BuildTiccmd(&localcmds, realtics, 1); + if (splitscreen || botingame) + G_BuildTiccmd(&localcmds2, realtics, 2); + + localcmds.angleturn |= TICCMD_RECEIVED; + localcmds2.angleturn |= TICCMD_RECEIVED; +} + +// create missed tic +static void SV_Maketic(void) +{ + INT32 i; + + for (i = 0; i < MAXPLAYERS; i++) + { + if (!playeringame[i]) + continue; + + // We didn't receive this tic + if ((netcmds[maketic % BACKUPTICS][i].angleturn & TICCMD_RECEIVED) == 0) + { + ticcmd_t * ticcmd = &netcmds[(maketic ) % BACKUPTICS][i]; + ticcmd_t *prevticcmd = &netcmds[(maketic - 1) % BACKUPTICS][i]; + + if (players[i].quittime) + { + // Copy the angle/aiming from the previous tic + // and empty the other inputs + memset(ticcmd, 0, sizeof(netcmds[0][0])); + ticcmd->angleturn = prevticcmd->angleturn | TICCMD_RECEIVED; + ticcmd->aiming = prevticcmd->aiming; + } + else + { + DEBFILE(va("MISS tic%4d for player %d\n", maketic, i)); + // Copy the input from the previous tic + *ticcmd = *prevticcmd; + ticcmd->angleturn &= ~TICCMD_RECEIVED; + } + } + } + + // all tic are now proceed make the next + maketic++; +} + +void TryRunTics(tic_t realtics) +{ + // the machine has lagged but it is not so bad + if (realtics > TICRATE/7) // FIXME: consistency failure!! + { + if (server) + realtics = 1; + else + realtics = TICRATE/7; + } + + if (singletics) + realtics = 1; + + if (realtics >= 1) + { + COM_BufTicker(); + if (mapchangepending) + D_MapChange(-1, 0, ultimatemode, false, 2, false, fromlevelselect); // finish the map change + } + + NetUpdate(); + + if (demoplayback) + { + neededtic = gametic + (realtics * cv_playbackspeed.value); + // start a game after a demo + maketic += realtics; + firstticstosend = maketic; + tictoclear = firstticstosend; + } + + GetPackets(); + +#ifdef DEBUGFILE + if (debugfile && (realtics || neededtic > gametic)) + { + //SoM: 3/30/2000: Need long INT32 in the format string for args 4 & 5. + //Shut up stupid warning! + fprintf(debugfile, "------------ Tryruntic: REAL:%d NEED:%d GAME:%d LOAD: %d\n", + realtics, neededtic, gametic, debugload); + debugload = 100000; + } +#endif + + if (player_joining) + return; + + if (neededtic > gametic) + { + if (advancedemo) + { + if (timedemo_quit) + COM_ImmedExecute("quit"); + else + D_StartTitle(); + } + else + // run the count * tics + while (neededtic > gametic) + { + DEBFILE(va("============ Running tic %d (local %d)\n", gametic, localgametic)); + + ps_tictime = I_GetTimeMicros(); + + G_Ticker((gametic % NEWTICRATERATIO) == 0); + ExtraDataTicker(); + gametic++; + consistancy[gametic%BACKUPTICS] = Consistancy(); + + ps_tictime = I_GetTimeMicros() - ps_tictime; + + // Leave a certain amount of tics present in the net buffer as long as we've ran at least one tic this frame. + if (client && gamestate == GS_LEVEL && leveltime > 3 && neededtic <= gametic + cv_netticbuffer.value) + break; + } + } +} + +/* +Ping Update except better: +We call this once per second and check for people's pings. If their ping happens to be too high, we increment some timer and kick them out. +If they're not lagging, decrement the timer by 1. Of course, reset all of this if they leave. +*/ + +static INT32 pingtimeout[MAXPLAYERS]; + +static inline void PingUpdate(void) +{ + INT32 i; + boolean laggers[MAXPLAYERS]; + UINT8 numlaggers = 0; + memset(laggers, 0, sizeof(boolean) * MAXPLAYERS); + + netbuffer->packettype = PT_PING; + + //check for ping limit breakage. + if (cv_maxping.value) + { + for (i = 1; i < MAXPLAYERS; i++) + { + if (playeringame[i] && !players[i].quittime + && (realpingtable[i] / pingmeasurecount > (unsigned)cv_maxping.value)) + { + if (players[i].jointime > 30 * TICRATE) + laggers[i] = true; + numlaggers++; + } + else + pingtimeout[i] = 0; + } + + //kick lagging players... unless everyone but the server's ping sucks. + //in that case, it is probably the server's fault. + if (numlaggers < D_NumPlayers() - 1) + { + for (i = 1; i < MAXPLAYERS; i++) + { + if (playeringame[i] && laggers[i]) + { + pingtimeout[i]++; + // ok your net has been bad for too long, you deserve to die. + if (pingtimeout[i] > cv_pingtimeout.value) + { + pingtimeout[i] = 0; + SendKick(i, KICK_MSG_PING_HIGH | KICK_MSG_KEEP_BODY); + } + } + /* + you aren't lagging, + but you aren't free yet. + In case you'll keep spiking, + we just make the timer go back down. (Very unstable net must still get kicked). + */ + else + pingtimeout[i] = (pingtimeout[i] == 0 ? 0 : pingtimeout[i]-1); + } + } + } + + //make the ping packet and clear server data for next one + for (i = 0; i < MAXPLAYERS; i++) + { + netbuffer->u.pingtable[i] = realpingtable[i] / pingmeasurecount; + //server takes a snapshot of the real ping for display. + //otherwise, pings fluctuate a lot and would be odd to look at. + playerpingtable[i] = realpingtable[i] / pingmeasurecount; + realpingtable[i] = 0; //Reset each as we go. + } + + // send the server's maxping as last element of our ping table. This is useful to let us know when we're about to get kicked. + netbuffer->u.pingtable[MAXPLAYERS] = cv_maxping.value; + + //send out our ping packets + for (i = 0; i < MAXNETNODES; i++) + if (nodeingame[i]) + HSendPacket(i, true, 0, sizeof(INT32) * (MAXPLAYERS+1)); + + pingmeasurecount = 1; //Reset count +} + +void NetUpdate(void) +{ + static tic_t gametime = 0; + static tic_t resptime = 0; + tic_t nowtime; + INT32 i; + INT32 realtics; + + nowtime = I_GetTime(); + realtics = nowtime - gametime; + + if (realtics <= 0) // nothing new to update + return; + if (realtics > 5) + { + if (server) + realtics = 1; + else + realtics = 5; + } + + gametime = nowtime; + + if (server) + { + if (netgame && !(gametime % 35)) // update once per second. + PingUpdate(); + // update node latency values so we can take an average later. + for (i = 0; i < MAXPLAYERS; i++) + if (playeringame[i] && playernode[i] != UINT8_MAX) + realpingtable[i] += G_TicsToMilliseconds(GetLag(playernode[i])); + pingmeasurecount++; + } + + if (client) + maketic = neededtic; + + Local_Maketic(realtics); // make local tic, and call menu? + + if (server) + CL_SendClientCmd(); // send it + + GetPackets(); // get packet from client or from server + + // client send the command after a receive of the server + // the server send before because in single player is beter + +#ifdef MASTERSERVER + MasterClient_Ticker(); // Acking the Master Server +#endif + + if (client) + { + // If the client just finished redownloading the game state, load it + if (cl_redownloadinggamestate && fileneeded[0].status == FS_FOUND) + CL_ReloadReceivedSavegame(); + + CL_SendClientCmd(); // Send tic cmd + hu_redownloadinggamestate = cl_redownloadinggamestate; + } + else + { + if (!demoplayback) + { + INT32 counts; + + hu_redownloadinggamestate = false; + + firstticstosend = gametic; + for (i = 0; i < MAXNETNODES; i++) + if (nodeingame[i] && nettics[i] < firstticstosend) + { + firstticstosend = nettics[i]; + + if (maketic + 1 >= nettics[i] + BACKUPTICS) + Net_ConnectionTimeout(i); + } + + // Don't erase tics not acknowledged + counts = realtics; + + if (maketic + counts >= firstticstosend + BACKUPTICS) + counts = firstticstosend+BACKUPTICS-maketic-1; + + for (i = 0; i < counts; i++) + SV_Maketic(); // Create missed tics and increment maketic + + for (; tictoclear < firstticstosend; tictoclear++) // Clear only when acknowledged + D_Clearticcmd(tictoclear); // Clear the maketic the new tic + + SV_SendTics(); + + neededtic = maketic; // The server is a client too + } + } + + Net_AckTicker(); + + // Handle timeouts to prevent definitive freezes from happenning + if (server) + { + for (i = 1; i < MAXNETNODES; i++) + if (nodeingame[i] && freezetimeout[i] < I_GetTime()) + Net_ConnectionTimeout(i); + + // In case the cvar value was lowered + if (joindelay) + joindelay = min(joindelay - 1, 3 * (tic_t)cv_joindelay.value * TICRATE); + } + + nowtime /= NEWTICRATERATIO; + if (nowtime > resptime) + { + resptime = nowtime; +#ifdef HAVE_THREADS + I_lock_mutex(&m_menu_mutex); +#endif + M_Ticker(); +#ifdef HAVE_THREADS + I_unlock_mutex(m_menu_mutex); +#endif + CON_Ticker(); + } + + FileSendTicker(); +} + +/** Returns the number of players playing. + * \return Number of players. Can be zero if we're running a ::dedicated + * server. + * \author Graue + */ +INT32 D_NumPlayers(void) +{ + INT32 num = 0, ix; + for (ix = 0; ix < MAXPLAYERS; ix++) + if (playeringame[ix]) + num++; + return num; +} + +tic_t GetLag(INT32 node) +{ + return gametic - nettics[node]; +} + +void D_MD5PasswordPass(const UINT8 *buffer, size_t len, const char *salt, void *dest) +{ +#ifdef NOMD5 + (void)buffer; + (void)len; + (void)salt; + memset(dest, 0, 16); +#else + char tmpbuf[256]; + const size_t sl = strlen(salt); + + if (len > 256-sl) + len = 256-sl; + + memcpy(tmpbuf, buffer, len); + memmove(&tmpbuf[len], salt, sl); + //strcpy(&tmpbuf[len], salt); + len += strlen(salt); + if (len < 256) + memset(&tmpbuf[len],0,256-len); + + // Yes, we intentionally md5 the ENTIRE buffer regardless of size... + md5_buffer(tmpbuf, 256, dest); +#endif +} From edc312066dbb7b3dc7c222c490d76f836c70eb6e Mon Sep 17 00:00:00 2001 From: Shane Ellis Date: Fri, 15 Jan 2021 22:01:51 +0000 Subject: [PATCH 0530/1080] =?UTF-8?q?Revert=20"CL=5FRemovePlayer()=20-=20A?= =?UTF-8?q?llow=20for=20removal=20of=20non-consoleplayer=20and=E2=80=A6"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit f166af4d8b7805e1ce5688cbef386f6ddc6e3ec1 --- src/r_skins.c | 5810 +++++++------------------------------------------ 1 file changed, 760 insertions(+), 5050 deletions(-) diff --git a/src/r_skins.c b/src/r_skins.c index 88b4d9387..155a64700 100644 --- a/src/r_skins.c +++ b/src/r_skins.c @@ -1,5 +1,6 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- +// Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. // Copyright (C) 1999-2020 by Sonic Team Junior. // @@ -7,5117 +8,826 @@ // terms of the GNU General Public License, version 2. // See the 'LICENSE' file for more details. //----------------------------------------------------------------------------- -/// \file d_clisrv.c -/// \brief SRB2 Network game communication and protocol, all OS independent parts. +/// \file r_skins.c +/// \brief Loading skins -#include -#ifdef __GNUC__ -#include //for unlink -#endif - -#include "i_net.h" -#include "i_system.h" -#include "i_video.h" -#include "d_net.h" -#include "d_main.h" -#include "g_game.h" -#include "st_stuff.h" -#include "hu_stuff.h" -#include "keys.h" -#include "g_input.h" // JOY1 -#include "m_menu.h" +#include "doomdef.h" #include "console.h" -#include "d_netfil.h" -#include "byteptr.h" -#include "p_saveg.h" -#include "z_zone.h" -#include "p_local.h" -#include "m_misc.h" -#include "am_map.h" -#include "m_random.h" -#include "mserv.h" -#include "y_inter.h" +#include "g_game.h" #include "r_local.h" -#include "m_argv.h" -#include "p_setup.h" -#include "lzf.h" -#include "lua_script.h" -#include "lua_hook.h" -#include "md5.h" -#include "m_perfstats.h" +#include "st_stuff.h" +#include "w_wad.h" +#include "z_zone.h" +#include "m_misc.h" +#include "info.h" // spr2names +#include "i_video.h" // rendermode +#include "i_system.h" +#include "r_things.h" +#include "r_skins.h" +#include "p_local.h" +#include "dehacked.h" // get_number (for thok) +#include "m_cond.h" +#ifdef HWRENDER +#include "hardware/hw_md2.h" +#endif -#ifndef NONET -// cl loading screen -#include "v_video.h" -#include "f_finale.h" +INT32 numskins = 0; +skin_t skins[MAXSKINS]; + +// FIXTHIS: don't work because it must be inistilised before the config load +//#define SKINVALUES +#ifdef SKINVALUES +CV_PossibleValue_t skin_cons_t[MAXSKINS+1]; #endif // -// NETWORKING +// P_GetSkinSprite2 +// For non-super players, tries each sprite2's immediate predecessor until it finds one with a number of frames or ends up at standing. +// For super players, does the same as above - but tries the super equivalent for each sprite2 before the non-super version. // -// gametic is the tic about to (or currently being) run -// Server: -// maketic is the tic that hasn't had control made for it yet -// nettics is the tic for each node -// firstticstosend is the lowest value of nettics -// Client: -// neededtic is the tic needed by the client to run the game -// firstticstosend is used to optimize a condition -// Normally maketic >= gametic > 0 -#define PREDICTIONQUEUE BACKUPTICS -#define PREDICTIONMASK (PREDICTIONQUEUE-1) -#define MAX_REASONLENGTH 30 - -boolean server = true; // true or false but !server == client -#define client (!server) -boolean nodownload = false; -boolean serverrunning = false; -INT32 serverplayer = 0; -char motd[254], server_context[8]; // Message of the Day, Unique Context (even without Mumble support) - -// Server specific vars -UINT8 playernode[MAXPLAYERS]; -char playeraddress[MAXPLAYERS][64]; - -// Minimum timeout for sending the savegame -// The actual timeout will be longer depending on the savegame length -tic_t jointimeout = (10*TICRATE); -static boolean sendingsavegame[MAXNETNODES]; // Are we sending the savegame? -static boolean resendingsavegame[MAXNETNODES]; // Are we resending the savegame? -static tic_t savegameresendcooldown[MAXNETNODES]; // How long before we can resend again? -static tic_t freezetimeout[MAXNETNODES]; // Until when can this node freeze the server before getting a timeout? - -// Incremented by cv_joindelay when a client joins, decremented each tic. -// If higher than cv_joindelay * 2 (3 joins in a short timespan), joins are temporarily disabled. -static tic_t joindelay = 0; - -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. -SINT8 nodetoplayer[MAXNETNODES]; -SINT8 nodetoplayer2[MAXNETNODES]; // say the numplayer for this node if any (splitscreen) -UINT8 playerpernode[MAXNETNODES]; // used specialy for scplitscreen -boolean nodeingame[MAXNETNODES]; // set false as nodes leave game -tic_t servermaxping = 800; // server's max ping. Defaults to 800 -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 -static tic_t maketic; - -static INT16 consistancy[BACKUPTICS]; - -static UINT8 player_joining = false; -UINT8 hu_redownloadinggamestate = 0; - -UINT8 adminpassmd5[16]; -boolean adminpasswordset = false; - -// Client specific -static ticcmd_t localcmds; -static ticcmd_t localcmds2; -static boolean cl_packetmissed; -// here it is for the secondary local player (splitscreen) -static UINT8 mynode; // my address pointofview server -static boolean cl_redownloadinggamestate = false; - -static UINT8 localtextcmd[MAXTEXTCMD]; -static UINT8 localtextcmd2[MAXTEXTCMD]; // splitscreen -static tic_t neededtic; -SINT8 servernode = 0; // the number of the server node -/// \brief do we accept new players? -/// \todo WORK! -boolean acceptnewnode = true; - -// engine - -// Must be a power of two -#define TEXTCMD_HASH_SIZE 4 - -typedef struct textcmdplayer_s +UINT8 P_GetSkinSprite2(skin_t *skin, UINT8 spr2, player_t *player) { - INT32 playernum; - UINT8 cmd[MAXTEXTCMD]; - struct textcmdplayer_s *next; -} textcmdplayer_t; + UINT8 super = 0, i = 0; -typedef struct textcmdtic_s -{ - tic_t tic; - textcmdplayer_t *playercmds[TEXTCMD_HASH_SIZE]; - struct textcmdtic_s *next; -} textcmdtic_t; - -ticcmd_t netcmds[BACKUPTICS][MAXPLAYERS]; -static textcmdtic_t *textcmds[TEXTCMD_HASH_SIZE] = {NULL}; - - -consvar_t cv_showjoinaddress = CVAR_INIT ("showjoinaddress", "Off", CV_SAVE|CV_NETVAR, CV_OnOff, NULL); - -static CV_PossibleValue_t playbackspeed_cons_t[] = {{1, "MIN"}, {10, "MAX"}, {0, NULL}}; -consvar_t cv_playbackspeed = CVAR_INIT ("playbackspeed", "1", 0, playbackspeed_cons_t, NULL); - -static inline void *G_DcpyTiccmd(void* dest, const ticcmd_t* src, const size_t n) -{ - const size_t d = n / sizeof(ticcmd_t); - const size_t r = n % sizeof(ticcmd_t); - UINT8 *ret = dest; - - if (r) - M_Memcpy(dest, src, n); - else if (d) - G_MoveTiccmd(dest, src, d); - return ret+n; -} - -static inline void *G_ScpyTiccmd(ticcmd_t* dest, void* src, const size_t n) -{ - const size_t d = n / sizeof(ticcmd_t); - const size_t r = n % sizeof(ticcmd_t); - UINT8 *ret = src; - - if (r) - M_Memcpy(dest, src, n); - else if (d) - G_MoveTiccmd(dest, src, d); - return ret+n; -} - - - -// Some software don't support largest packet -// (original sersetup, not exactely, but the probability of sending a packet -// of 512 bytes is like 0.1) -UINT16 software_MAXPACKETLENGTH; - -/** Guesses the full value of a tic from its lowest byte, for a specific node - * - * \param low The lowest byte of the tic value - * \param node The node to deduce the tic for - * \return The full tic value - * - */ -tic_t ExpandTics(INT32 low, INT32 node) -{ - INT32 delta; - - delta = low - (nettics[node] & UINT8_MAX); - - if (delta >= -64 && delta <= 64) - return (nettics[node] & ~UINT8_MAX) + low; - else if (delta > 64) - return (nettics[node] & ~UINT8_MAX) - 256 + low; - else //if (delta < -64) - return (nettics[node] & ~UINT8_MAX) + 256 + low; -} - -// ----------------------------------------------------------------- -// Some extra data function for handle textcmd buffer -// ----------------------------------------------------------------- - -static void (*listnetxcmd[MAXNETXCMD])(UINT8 **p, INT32 playernum); - -void RegisterNetXCmd(netxcmd_t id, void (*cmd_f)(UINT8 **p, INT32 playernum)) -{ -#ifdef PARANOIA - if (id >= MAXNETXCMD) - I_Error("Command id %d too big", id); - if (listnetxcmd[id] != 0) - I_Error("Command id %d already used", id); -#endif - listnetxcmd[id] = cmd_f; -} - -void SendNetXCmd(netxcmd_t id, const void *param, size_t nparam) -{ - if (localtextcmd[0]+2+nparam > MAXTEXTCMD) - { - // for future reference: if (cv_debug) != debug disabled. - CONS_Alert(CONS_ERROR, M_GetText("NetXCmd buffer full, cannot add netcmd %d! (size: %d, needed: %s)\n"), id, localtextcmd[0], sizeu1(nparam)); - return; - } - localtextcmd[0]++; - localtextcmd[localtextcmd[0]] = (UINT8)id; - if (param && nparam) - { - M_Memcpy(&localtextcmd[localtextcmd[0]+1], param, nparam); - localtextcmd[0] = (UINT8)(localtextcmd[0] + (UINT8)nparam); - } -} - -// splitscreen player -void SendNetXCmd2(netxcmd_t id, const void *param, size_t nparam) -{ - if (localtextcmd2[0]+2+nparam > MAXTEXTCMD) - { - I_Error("No more place in the buffer for netcmd %d\n",id); - return; - } - localtextcmd2[0]++; - localtextcmd2[localtextcmd2[0]] = (UINT8)id; - if (param && nparam) - { - M_Memcpy(&localtextcmd2[localtextcmd2[0]+1], param, nparam); - localtextcmd2[0] = (UINT8)(localtextcmd2[0] + (UINT8)nparam); - } -} - -UINT8 GetFreeXCmdSize(void) -{ - // -1 for the size and another -1 for the ID. - return (UINT8)(localtextcmd[0] - 2); -} - -// 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; - } - - if (textcmdtic) - { - INT32 i; - - // Remove this tic from the list. - *tctprev = textcmdtic->next; - - // Free all players. - for (i = 0; i < TEXTCMD_HASH_SIZE; i++) - { - textcmdplayer_t *textcmdplayer = textcmdtic->playercmds[i]; - - while (textcmdplayer) - { - textcmdplayer_t *tcpnext = textcmdplayer->next; - Z_Free(textcmdplayer); - textcmdplayer = tcpnext; - } - } - - // Free this tic's own memory. - Z_Free(textcmdtic); - } -} - -// 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; - - // Do we have an entry for the tic? If so, look for player. - if (textcmdtic) - { - textcmdplayer_t *textcmdplayer = textcmdtic->playercmds[playernum & (TEXTCMD_HASH_SIZE - 1)]; - while (textcmdplayer && textcmdplayer->playernum != playernum) textcmdplayer = textcmdplayer->next; - - if (textcmdplayer) return textcmdplayer->cmd; - } - - return NULL; -} - -// 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)]; - textcmdplayer_t *textcmdplayer, **tcpprev; - - // Look for the tic. - while (textcmdtic && textcmdtic->tic != tic) - { - tctprev = &textcmdtic->next; - textcmdtic = textcmdtic->next; - } - - // 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->tic = tic; - } - - tcpprev = &textcmdtic->playercmds[playernum & (TEXTCMD_HASH_SIZE - 1)]; - textcmdplayer = *tcpprev; - - // Look for the player. - while (textcmdplayer && textcmdplayer->playernum != playernum) - { - tcpprev = &textcmdplayer->next; - textcmdplayer = textcmdplayer->next; - } - - // If we don't have an entry for the player, make it. - if (!textcmdplayer) - { - textcmdplayer = *tcpprev = Z_Calloc(sizeof (textcmdplayer_t), PU_STATIC, NULL); - textcmdplayer->playernum = playernum; - } - - return textcmdplayer->cmd; -} - -static void ExtraDataTicker(void) -{ - INT32 i; - - for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i] || i == 0) - { - UINT8 *bufferstart = D_GetExistingTextcmd(gametic, i); - - if (bufferstart) - { - UINT8 *curpos = bufferstart; - UINT8 *bufferend = &curpos[curpos[0]+1]; - - curpos++; - while (curpos < bufferend) - { - if (*curpos < MAXNETXCMD && listnetxcmd[*curpos]) - { - const UINT8 id = *curpos; - curpos++; - DEBFILE(va("executing x_cmd %s ply %u ", netxcmdnames[id - 1], i)); - (listnetxcmd[id])(&curpos, i); - DEBFILE("done\n"); - } - else - { - if (server) - { - SendKick(i, KICK_MSG_CON_FAIL | KICK_MSG_KEEP_BODY); - DEBFILE(va("player %d kicked [gametic=%u] reason as follows:\n", i, gametic)); - } - CONS_Alert(CONS_WARNING, M_GetText("Got unknown net command [%s]=%d (max %d)\n"), sizeu1(curpos - bufferstart), *curpos, bufferstart[0]); - break; - } - } - } - } - - // If you are a client, you can safely forget the net commands for this tic - // If you are the server, you need to remember them until every client has been acknowledged, - // because if you need to resend a PT_SERVERTICS packet, you will need to put the commands in it - if (client) - D_FreeTextcmd(gametic); -} - -static void D_Clearticcmd(tic_t tic) -{ - INT32 i; - - D_FreeTextcmd(tic); - - for (i = 0; i < MAXPLAYERS; i++) - netcmds[tic%BACKUPTICS][i].angleturn = 0; - - DEBFILE(va("clear tic %5u (%2u)\n", tic, tic%BACKUPTICS)); -} - -void D_ResetTiccmds(void) -{ - INT32 i; - - memset(&localcmds, 0, sizeof(ticcmd_t)); - memset(&localcmds2, 0, sizeof(ticcmd_t)); - - // Reset the net command list - for (i = 0; i < TEXTCMD_HASH_SIZE; i++) - while (textcmds[i]) - D_Clearticcmd(textcmds[i]->tic); -} - -void SendKick(UINT8 playernum, UINT8 msg) -{ - UINT8 buf[2]; - - if (!(server && cv_rejointimeout.value)) - msg &= ~KICK_MSG_KEEP_BODY; - - buf[0] = playernum; - buf[1] = msg; - SendNetXCmd(XD_KICK, &buf, 2); -} - -// ----------------------------------------------------------------- -// end of extra data function -// ----------------------------------------------------------------- - -// ----------------------------------------------------------------- -// extra data function for lmps -// ----------------------------------------------------------------- - -// if extradatabit is set, after the ziped tic you find this: -// -// type | description -// ---------+-------------- -// byte | size of the extradata -// byte | the extradata (xd) bits: see XD_... -// with this byte you know what parameter folow -// if (xd & XDNAMEANDCOLOR) -// byte | color -// char[MAXPLAYERNAME] | name of the player -// endif -// if (xd & XD_WEAPON_PREF) -// byte | original weapon switch: boolean, true if use the old -// | weapon switch methode -// char[NUMWEAPONS] | the weapon switch priority -// byte | autoaim: true if use the old autoaim system -// endif -/*boolean AddLmpExtradata(UINT8 **demo_point, INT32 playernum) -{ - UINT8 *textcmd = D_GetExistingTextcmd(gametic, playernum); - - if (!textcmd) - return false; - - M_Memcpy(*demo_point, textcmd, textcmd[0]+1); - *demo_point += textcmd[0]+1; - return true; -} - -void ReadLmpExtraData(UINT8 **demo_pointer, INT32 playernum) -{ - UINT8 nextra; - UINT8 *textcmd; - - if (!demo_pointer) - return; - - textcmd = D_GetTextcmd(gametic, playernum); - nextra = **demo_pointer; - M_Memcpy(textcmd, *demo_pointer, nextra + 1); - // increment demo pointer - *demo_pointer += nextra + 1; -}*/ - -// ----------------------------------------------------------------- -// end extra data function for lmps -// ----------------------------------------------------------------- - -static INT16 Consistancy(void); - -typedef enum -{ - CL_SEARCHING, - CL_DOWNLOADFILES, - CL_ASKJOIN, - CL_WAITJOINRESPONSE, - CL_DOWNLOADSAVEGAME, - CL_CONNECTED, - CL_ABORTED -} cl_mode_t; - -static void GetPackets(void); - -static cl_mode_t cl_mode = CL_SEARCHING; - -#ifndef NONET -#define SNAKE_SPEED 5 - -#define SNAKE_NUM_BLOCKS_X 20 -#define SNAKE_NUM_BLOCKS_Y 10 -#define SNAKE_BLOCK_SIZE 12 -#define SNAKE_BORDER_SIZE 12 - -#define SNAKE_MAP_WIDTH (SNAKE_NUM_BLOCKS_X * SNAKE_BLOCK_SIZE) -#define SNAKE_MAP_HEIGHT (SNAKE_NUM_BLOCKS_Y * SNAKE_BLOCK_SIZE) - -#define SNAKE_LEFT_X ((BASEVIDWIDTH - SNAKE_MAP_WIDTH) / 2 - SNAKE_BORDER_SIZE) -#define SNAKE_RIGHT_X (SNAKE_LEFT_X + SNAKE_MAP_WIDTH + SNAKE_BORDER_SIZE * 2 - 1) -#define SNAKE_BOTTOM_Y (BASEVIDHEIGHT - 48) -#define SNAKE_TOP_Y (SNAKE_BOTTOM_Y - SNAKE_MAP_HEIGHT - SNAKE_BORDER_SIZE * 2 + 1) - -enum snake_bonustype_s { - SNAKE_BONUS_NONE = 0, - SNAKE_BONUS_SLOW, - SNAKE_BONUS_FAST, - SNAKE_BONUS_GHOST, - SNAKE_BONUS_NUKE, - SNAKE_BONUS_SCISSORS, - SNAKE_BONUS_REVERSE, - SNAKE_BONUS_EGGMAN, - SNAKE_NUM_BONUSES, -}; - -static const char *snake_bonuspatches[] = { - NULL, - "DL_SLOW", - "TVSSC0", - "TVIVC0", - "TVARC0", - "DL_SCISSORS", - "TVRCC0", - "TVEGC0", -}; - -static const char *snake_backgrounds[] = { - "RVPUMICF", - "FRSTRCKF", - "TAR", - "MMFLRB4", - "RVDARKF1", - "RVZWALF1", - "RVZWALF4", - "RVZWALF5", - "RVZGRS02", - "RVZGRS04", -}; - -typedef struct snake_s -{ - boolean paused; - boolean pausepressed; - tic_t time; - tic_t nextupdate; - boolean gameover; - UINT8 background; - - UINT16 snakelength; - enum snake_bonustype_s snakebonus; - tic_t snakebonustime; - UINT8 snakex[SNAKE_NUM_BLOCKS_X * SNAKE_NUM_BLOCKS_Y]; - UINT8 snakey[SNAKE_NUM_BLOCKS_X * SNAKE_NUM_BLOCKS_Y]; - UINT8 snakedir[SNAKE_NUM_BLOCKS_X * SNAKE_NUM_BLOCKS_Y]; - - UINT8 applex; - UINT8 appley; - - enum snake_bonustype_s bonustype; - UINT8 bonusx; - UINT8 bonusy; -} snake_t; - -static snake_t *snake = NULL; - -static void Snake_Initialise(void) -{ - if (!snake) - snake = malloc(sizeof(snake_t)); - - snake->paused = false; - snake->pausepressed = false; - snake->time = 0; - snake->nextupdate = SNAKE_SPEED; - snake->gameover = false; - snake->background = M_RandomKey(sizeof(snake_backgrounds) / sizeof(*snake_backgrounds)); - - snake->snakelength = 1; - snake->snakebonus = SNAKE_BONUS_NONE; - snake->snakex[0] = M_RandomKey(SNAKE_NUM_BLOCKS_X); - snake->snakey[0] = M_RandomKey(SNAKE_NUM_BLOCKS_Y); - snake->snakedir[0] = 0; - snake->snakedir[1] = 0; - - snake->applex = M_RandomKey(SNAKE_NUM_BLOCKS_X); - snake->appley = M_RandomKey(SNAKE_NUM_BLOCKS_Y); - - snake->bonustype = SNAKE_BONUS_NONE; -} - -static UINT8 Snake_GetOppositeDir(UINT8 dir) -{ - if (dir == 1 || dir == 3) - return dir + 1; - else if (dir == 2 || dir == 4) - return dir - 1; - else - return 12 + 5 - dir; -} - -static void Snake_FindFreeSlot(UINT8 *freex, UINT8 *freey, UINT8 headx, UINT8 heady) -{ - UINT8 x, y; - UINT16 i; - - do - { - x = M_RandomKey(SNAKE_NUM_BLOCKS_X); - y = M_RandomKey(SNAKE_NUM_BLOCKS_Y); - - for (i = 0; i < snake->snakelength; i++) - if (x == snake->snakex[i] && y == snake->snakey[i]) - break; - } while (i < snake->snakelength || (x == headx && y == heady) - || (x == snake->applex && y == snake->appley) - || (snake->bonustype != SNAKE_BONUS_NONE && x == snake->bonusx && y == snake->bonusy)); - - *freex = x; - *freey = y; -} - -static void Snake_Handle(void) -{ - UINT8 x, y; - UINT8 oldx, oldy; - UINT16 i; - - // Handle retry - if (snake->gameover && (PLAYER1INPUTDOWN(gc_jump) || gamekeydown[KEY_ENTER])) - { - Snake_Initialise(); - snake->pausepressed = true; // Avoid accidental pause on respawn - } - - // Handle pause - if (PLAYER1INPUTDOWN(gc_pause) || gamekeydown[KEY_ENTER]) - { - if (!snake->pausepressed) - snake->paused = !snake->paused; - snake->pausepressed = true; - } - else - snake->pausepressed = false; - - if (snake->paused) - return; - - snake->time++; - - x = snake->snakex[0]; - y = snake->snakey[0]; - oldx = snake->snakex[1]; - oldy = snake->snakey[1]; - - // Update direction - if (gamekeydown[KEY_LEFTARROW]) - { - if (snake->snakelength < 2 || x <= oldx) - snake->snakedir[0] = 1; - } - else if (gamekeydown[KEY_RIGHTARROW]) - { - if (snake->snakelength < 2 || x >= oldx) - snake->snakedir[0] = 2; - } - else if (gamekeydown[KEY_UPARROW]) - { - if (snake->snakelength < 2 || y <= oldy) - snake->snakedir[0] = 3; - } - else if (gamekeydown[KEY_DOWNARROW]) - { - if (snake->snakelength < 2 || y >= oldy) - snake->snakedir[0] = 4; - } - - if (snake->snakebonustime) - { - snake->snakebonustime--; - if (!snake->snakebonustime) - snake->snakebonus = SNAKE_BONUS_NONE; - } - - snake->nextupdate--; - if (snake->nextupdate) - return; - if (snake->snakebonus == SNAKE_BONUS_SLOW) - snake->nextupdate = SNAKE_SPEED * 2; - else if (snake->snakebonus == SNAKE_BONUS_FAST) - snake->nextupdate = SNAKE_SPEED * 2 / 3; - else - snake->nextupdate = SNAKE_SPEED; - - if (snake->gameover) - return; - - // Find new position - switch (snake->snakedir[0]) - { - case 1: - if (x > 0) - x--; - else - snake->gameover = true; - break; - case 2: - if (x < SNAKE_NUM_BLOCKS_X - 1) - x++; - else - snake->gameover = true; - break; - case 3: - if (y > 0) - y--; - else - snake->gameover = true; - break; - case 4: - if (y < SNAKE_NUM_BLOCKS_Y - 1) - y++; - else - snake->gameover = true; - break; - } - - // Check collision with snake - if (snake->snakebonus != SNAKE_BONUS_GHOST) - for (i = 1; i < snake->snakelength - 1; i++) - if (x == snake->snakex[i] && y == snake->snakey[i]) - { - if (snake->snakebonus == SNAKE_BONUS_SCISSORS) - { - snake->snakebonus = SNAKE_BONUS_NONE; - snake->snakelength = i; - S_StartSound(NULL, sfx_adderr); - } - else - snake->gameover = true; - } - - if (snake->gameover) - { - S_StartSound(NULL, sfx_lose); - return; - } - - // Check collision with apple - if (x == snake->applex && y == snake->appley) - { - if (snake->snakelength + 3 < SNAKE_NUM_BLOCKS_X * SNAKE_NUM_BLOCKS_Y) - { - snake->snakelength++; - snake->snakex [snake->snakelength - 1] = snake->snakex [snake->snakelength - 2]; - snake->snakey [snake->snakelength - 1] = snake->snakey [snake->snakelength - 2]; - snake->snakedir[snake->snakelength - 1] = snake->snakedir[snake->snakelength - 2]; - } - - // Spawn new apple - Snake_FindFreeSlot(&snake->applex, &snake->appley, x, y); - - // Spawn new bonus - if (!(snake->snakelength % 5)) - { - do - { - snake->bonustype = M_RandomKey(SNAKE_NUM_BONUSES - 1) + 1; - } while (snake->snakelength > SNAKE_NUM_BLOCKS_X * SNAKE_NUM_BLOCKS_Y * 3 / 4 - && (snake->bonustype == SNAKE_BONUS_EGGMAN || snake->bonustype == SNAKE_BONUS_FAST || snake->bonustype == SNAKE_BONUS_REVERSE)); - - Snake_FindFreeSlot(&snake->bonusx, &snake->bonusy, x, y); - } - - S_StartSound(NULL, sfx_s3k6b); - } - - if (snake->snakelength > 1 && snake->snakedir[0]) - { - UINT8 dir = snake->snakedir[0]; - - oldx = snake->snakex[1]; - oldy = snake->snakey[1]; - - // Move - for (i = snake->snakelength - 1; i > 0; i--) - { - snake->snakex[i] = snake->snakex[i - 1]; - snake->snakey[i] = snake->snakey[i - 1]; - snake->snakedir[i] = snake->snakedir[i - 1]; - } - - // Handle corners - if (x < oldx && dir == 3) - dir = 5; - else if (x > oldx && dir == 3) - dir = 6; - else if (x < oldx && dir == 4) - dir = 7; - else if (x > oldx && dir == 4) - dir = 8; - else if (y < oldy && dir == 1) - dir = 9; - else if (y < oldy && dir == 2) - dir = 10; - else if (y > oldy && dir == 1) - dir = 11; - else if (y > oldy && dir == 2) - dir = 12; - snake->snakedir[1] = dir; - } - - snake->snakex[0] = x; - snake->snakey[0] = y; - - // Check collision with bonus - if (snake->bonustype != SNAKE_BONUS_NONE && x == snake->bonusx && y == snake->bonusy) - { - S_StartSound(NULL, sfx_ncchip); - - switch (snake->bonustype) - { - case SNAKE_BONUS_SLOW: - snake->snakebonus = SNAKE_BONUS_SLOW; - snake->snakebonustime = 20 * TICRATE; - break; - case SNAKE_BONUS_FAST: - snake->snakebonus = SNAKE_BONUS_FAST; - snake->snakebonustime = 20 * TICRATE; - break; - case SNAKE_BONUS_GHOST: - snake->snakebonus = SNAKE_BONUS_GHOST; - snake->snakebonustime = 10 * TICRATE; - break; - case SNAKE_BONUS_NUKE: - for (i = 0; i < snake->snakelength; i++) - { - snake->snakex [i] = snake->snakex [0]; - snake->snakey [i] = snake->snakey [0]; - snake->snakedir[i] = snake->snakedir[0]; - } - - S_StartSound(NULL, sfx_bkpoof); - break; - case SNAKE_BONUS_SCISSORS: - snake->snakebonus = SNAKE_BONUS_SCISSORS; - snake->snakebonustime = 60 * TICRATE; - break; - case SNAKE_BONUS_REVERSE: - for (i = 0; i < (snake->snakelength + 1) / 2; i++) - { - UINT16 i2 = snake->snakelength - 1 - i; - UINT8 tmpx = snake->snakex [i]; - UINT8 tmpy = snake->snakey [i]; - UINT8 tmpdir = snake->snakedir[i]; - - // Swap first segment with last segment - snake->snakex [i] = snake->snakex [i2]; - snake->snakey [i] = snake->snakey [i2]; - snake->snakedir[i] = Snake_GetOppositeDir(snake->snakedir[i2]); - snake->snakex [i2] = tmpx; - snake->snakey [i2] = tmpy; - snake->snakedir[i2] = Snake_GetOppositeDir(tmpdir); - } - - snake->snakedir[0] = 0; - - S_StartSound(NULL, sfx_gravch); - break; - default: - if (snake->snakebonus != SNAKE_BONUS_GHOST) - { - snake->gameover = true; - S_StartSound(NULL, sfx_lose); - } - } - - snake->bonustype = SNAKE_BONUS_NONE; - } -} - -static void Snake_Draw(void) -{ - INT16 i; - - // Background - V_DrawFlatFill( - SNAKE_LEFT_X + SNAKE_BORDER_SIZE, - SNAKE_TOP_Y + SNAKE_BORDER_SIZE, - SNAKE_MAP_WIDTH, - SNAKE_MAP_HEIGHT, - W_GetNumForName(snake_backgrounds[snake->background]) - ); - - // Borders - V_DrawFill(SNAKE_LEFT_X, SNAKE_TOP_Y, SNAKE_BORDER_SIZE + SNAKE_MAP_WIDTH, SNAKE_BORDER_SIZE, 242); // Top - V_DrawFill(SNAKE_LEFT_X + SNAKE_BORDER_SIZE + SNAKE_MAP_WIDTH, SNAKE_TOP_Y, SNAKE_BORDER_SIZE, SNAKE_BORDER_SIZE + SNAKE_MAP_HEIGHT, 242); // Right - V_DrawFill(SNAKE_LEFT_X + SNAKE_BORDER_SIZE, SNAKE_TOP_Y + SNAKE_BORDER_SIZE + SNAKE_MAP_HEIGHT, SNAKE_BORDER_SIZE + SNAKE_MAP_WIDTH, SNAKE_BORDER_SIZE, 242); // Bottom - V_DrawFill(SNAKE_LEFT_X, SNAKE_TOP_Y + SNAKE_BORDER_SIZE, SNAKE_BORDER_SIZE, SNAKE_BORDER_SIZE + SNAKE_MAP_HEIGHT, 242); // Left - - // Apple - V_DrawFixedPatch( - (SNAKE_LEFT_X + SNAKE_BORDER_SIZE + snake->applex * SNAKE_BLOCK_SIZE + SNAKE_BLOCK_SIZE / 2) * FRACUNIT, - (SNAKE_TOP_Y + SNAKE_BORDER_SIZE + snake->appley * SNAKE_BLOCK_SIZE + SNAKE_BLOCK_SIZE / 2) * FRACUNIT, - FRACUNIT / 4, - 0, - W_CachePatchLongName("DL_APPLE", PU_HUDGFX), - NULL - ); - - // Bonus - if (snake->bonustype != SNAKE_BONUS_NONE) - V_DrawFixedPatch( - (SNAKE_LEFT_X + SNAKE_BORDER_SIZE + snake->bonusx * SNAKE_BLOCK_SIZE + SNAKE_BLOCK_SIZE / 2 ) * FRACUNIT, - (SNAKE_TOP_Y + SNAKE_BORDER_SIZE + snake->bonusy * SNAKE_BLOCK_SIZE + SNAKE_BLOCK_SIZE / 2 + 4) * FRACUNIT, - FRACUNIT / 2, - 0, - W_CachePatchLongName(snake_bonuspatches[snake->bonustype], PU_HUDGFX), - NULL - ); - - // Snake - if (!snake->gameover || snake->time % 8 < 8 / 2) // Blink if game over - { - for (i = snake->snakelength - 1; i >= 0; i--) - { - const char *patchname; - UINT8 dir = snake->snakedir[i]; - - if (i == 0) // Head - { - switch (dir) - { - case 1: patchname = "DL_SNAKEHEAD_L"; break; - case 2: patchname = "DL_SNAKEHEAD_R"; break; - case 3: patchname = "DL_SNAKEHEAD_T"; break; - case 4: patchname = "DL_SNAKEHEAD_B"; break; - default: patchname = "DL_SNAKEHEAD_M"; - } - } - else // Body - { - switch (dir) - { - case 1: patchname = "DL_SNAKEBODY_L"; break; - case 2: patchname = "DL_SNAKEBODY_R"; break; - case 3: patchname = "DL_SNAKEBODY_T"; break; - case 4: patchname = "DL_SNAKEBODY_B"; break; - case 5: patchname = "DL_SNAKEBODY_LT"; break; - case 6: patchname = "DL_SNAKEBODY_RT"; break; - case 7: patchname = "DL_SNAKEBODY_LB"; break; - case 8: patchname = "DL_SNAKEBODY_RB"; break; - case 9: patchname = "DL_SNAKEBODY_TL"; break; - case 10: patchname = "DL_SNAKEBODY_TR"; break; - case 11: patchname = "DL_SNAKEBODY_BL"; break; - case 12: patchname = "DL_SNAKEBODY_BR"; break; - default: patchname = "DL_SNAKEBODY_B"; - } - } - - V_DrawFixedPatch( - (SNAKE_LEFT_X + SNAKE_BORDER_SIZE + snake->snakex[i] * SNAKE_BLOCK_SIZE + SNAKE_BLOCK_SIZE / 2) * FRACUNIT, - (SNAKE_TOP_Y + SNAKE_BORDER_SIZE + snake->snakey[i] * SNAKE_BLOCK_SIZE + SNAKE_BLOCK_SIZE / 2) * FRACUNIT, - i == 0 && dir == 0 ? FRACUNIT / 5 : FRACUNIT / 2, - snake->snakebonus == SNAKE_BONUS_GHOST ? V_TRANSLUCENT : 0, - W_CachePatchLongName(patchname, PU_HUDGFX), - NULL - ); - } - } - - // Length - V_DrawString(SNAKE_RIGHT_X + 4, SNAKE_TOP_Y, V_MONOSPACE, va("%u", snake->snakelength)); - - // Bonus - if (snake->snakebonus != SNAKE_BONUS_NONE - && (snake->snakebonustime >= 3 * TICRATE || snake->time % 4 < 4 / 2)) - V_DrawFixedPatch( - (SNAKE_RIGHT_X + 10) * FRACUNIT, - (SNAKE_TOP_Y + 24) * FRACUNIT, - FRACUNIT / 2, - 0, - W_CachePatchLongName(snake_bonuspatches[snake->snakebonus], PU_HUDGFX), - NULL - ); -} - -// -// CL_DrawConnectionStatus -// -// Keep the local client informed of our status. -// -static inline void CL_DrawConnectionStatus(void) -{ - INT32 ccstime = I_GetTime(); - - // Draw background fade - if (!menuactive) // menu already draws its own fade - V_DrawFadeScreen(0xFF00, 16); // force default - - // Draw the bottom box. - M_DrawTextBox(BASEVIDWIDTH/2-128-8, BASEVIDHEIGHT-16-8, 32, 1); - V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-16-16, V_YELLOWMAP, "Press ESC to abort"); - - if (cl_mode != CL_DOWNLOADFILES) - { - INT32 i, animtime = ((ccstime / 4) & 15) + 16; - UINT8 palstart = (cl_mode == CL_SEARCHING) ? 32 : 96; - // 15 pal entries total. - const char *cltext; - - if (!(cl_mode == CL_DOWNLOADSAVEGAME && lastfilenum != -1)) - for (i = 0; i < 16; ++i) - V_DrawFill((BASEVIDWIDTH/2-128) + (i * 16), BASEVIDHEIGHT-16, 16, 8, palstart + ((animtime - i) & 15)); - - switch (cl_mode) - { - case CL_DOWNLOADSAVEGAME: - if (lastfilenum != -1) - { - UINT32 currentsize = fileneeded[lastfilenum].currentsize; - UINT32 totalsize = fileneeded[lastfilenum].totalsize; - INT32 dldlength; - - cltext = M_GetText("Downloading game state..."); - Net_GetNetStat(); - - dldlength = (INT32)((currentsize/(double)totalsize) * 256); - if (dldlength > 256) - dldlength = 256; - V_DrawFill(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-16, 256, 8, 111); - V_DrawFill(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-16, dldlength, 8, 96); - - V_DrawString(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-16, V_20TRANS|V_MONOSPACE, - va(" %4uK/%4uK",currentsize>>10,totalsize>>10)); - - V_DrawRightAlignedString(BASEVIDWIDTH/2+128, BASEVIDHEIGHT-16, V_20TRANS|V_MONOSPACE, - va("%3.1fK/s ", ((double)getbps)/1024)); - } - else - cltext = M_GetText("Waiting to download game state..."); - break; - case CL_ASKJOIN: - case CL_WAITJOINRESPONSE: - cltext = M_GetText("Requesting to join..."); - break; - default: - cltext = M_GetText("Connecting to server..."); - break; - } - V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-16-24, V_YELLOWMAP, cltext); - } - else - { - if (lastfilenum != -1) - { - INT32 dldlength; - static char tempname[28]; - fileneeded_t *file = &fileneeded[lastfilenum]; - char *filename = file->filename; - - Snake_Draw(); - - Net_GetNetStat(); - dldlength = (INT32)((file->currentsize/(double)file->totalsize) * 256); - if (dldlength > 256) - dldlength = 256; - V_DrawFill(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-16, 256, 8, 111); - V_DrawFill(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-16, dldlength, 8, 96); - - memset(tempname, 0, sizeof(tempname)); - // offset filename to just the name only part - filename += strlen(filename) - nameonlylength(filename); - - if (strlen(filename) > sizeof(tempname)-1) // too long to display fully - { - size_t endhalfpos = strlen(filename)-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); - } - else // we can copy the whole thing in safely - { - strncpy(tempname, filename, sizeof(tempname)-1); - } - - V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-16-24, V_YELLOWMAP, - va(M_GetText("Downloading \"%s\""), tempname)); - V_DrawString(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-16, V_20TRANS|V_MONOSPACE, - va(" %4uK/%4uK",fileneeded[lastfilenum].currentsize>>10,file->totalsize>>10)); - V_DrawRightAlignedString(BASEVIDWIDTH/2+128, BASEVIDHEIGHT-16, V_20TRANS|V_MONOSPACE, - va("%3.1fK/s ", ((double)getbps)/1024)); - } - else - V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-16-24, V_YELLOWMAP, - M_GetText("Waiting to download files...")); - } -} -#endif - -/** Sends a special packet to declare how many players in local - * Used only in arbitratrenetstart() - * Sends a PT_CLIENTJOIN packet to the server - * - * \return True if the packet was successfully sent - * \todo Improve the description... - * Because to be honest, I have no idea what arbitratrenetstart is... - * Is it even used...? - * - */ -static boolean CL_SendJoin(void) -{ - UINT8 localplayers = 1; - if (netgame) - CONS_Printf(M_GetText("Sending join request...\n")); - netbuffer->packettype = PT_CLIENTJOIN; - - if (splitscreen || botingame) - localplayers++; - netbuffer->u.clientcfg.localplayers = localplayers; - netbuffer->u.clientcfg._255 = 255; - 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); - - CleanupPlayerName(consoleplayer, cv_playername.zstring); - if (splitscreen) - CleanupPlayerName(1, cv_playername2.zstring);/* 1 is a HACK? oh no */ - - strncpy(netbuffer->u.clientcfg.names[0], cv_playername.zstring, MAXPLAYERNAME); - strncpy(netbuffer->u.clientcfg.names[1], cv_playername2.zstring, MAXPLAYERNAME); - - return HSendPacket(servernode, true, 0, sizeof (clientconfig_pak)); -} - -static INT32 FindRejoinerNum(SINT8 node) -{ - char strippednodeaddress[64]; - const char *nodeaddress; - char *port; - INT32 i; - - // Make sure there is no dead dress before proceeding to the stripping - if (!I_GetNodeAddress) - return -1; - nodeaddress = I_GetNodeAddress(node); - if (!nodeaddress) - return -1; - - // Strip the address of its port - strcpy(strippednodeaddress, nodeaddress); - port = strchr(strippednodeaddress, ':'); - if (port) - *port = '\0'; - - // Check if any player matches the stripped address - for (i = 0; i < MAXPLAYERS; i++) - { - if (playeringame[i] && playeraddress[i][0] && playernode[i] == UINT8_MAX - && !strcmp(playeraddress[i], strippednodeaddress)) - return i; - } - - return -1; -} - -static void SV_SendServerInfo(INT32 node, tic_t servertime) -{ - UINT8 *p; - - 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); - // 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); - - netbuffer->u.serverinfo.numberofplayer = (UINT8)D_NumPlayers(); - netbuffer->u.serverinfo.maxplayer = (UINT8)cv_maxplayers.value; - - if (!node || FindRejoinerNum(node) != -1) - netbuffer->u.serverinfo.refusereason = 0; - else if (!cv_allownewplayer.value) - netbuffer->u.serverinfo.refusereason = 1; - else if (D_NumPlayers() >= cv_maxplayers.value) - netbuffer->u.serverinfo.refusereason = 2; - else - netbuffer->u.serverinfo.refusereason = 0; - - strncpy(netbuffer->u.serverinfo.gametypename, Gametype_Names[gametype], - sizeof netbuffer->u.serverinfo.gametypename); - netbuffer->u.serverinfo.modifiedgame = (UINT8)modifiedgame; - netbuffer->u.serverinfo.cheatsenabled = CV_CheatsEnabled(); - netbuffer->u.serverinfo.isdedicated = (UINT8)dedicated; - strncpy(netbuffer->u.serverinfo.servername, cv_servername.string, - MAXSERVERNAME); - strncpy(netbuffer->u.serverinfo.mapname, G_BuildMapName(gamemap), 7); - - M_Memcpy(netbuffer->u.serverinfo.mapmd5, mapmd5, 16); - - memset(netbuffer->u.serverinfo.maptitle, 0, sizeof netbuffer->u.serverinfo.maptitle); - - if (mapheaderinfo[gamemap-1] && *mapheaderinfo[gamemap-1]->lvlttl) - { - char *read = mapheaderinfo[gamemap-1]->lvlttl, *writ = netbuffer->u.serverinfo.maptitle; - while (writ < (netbuffer->u.serverinfo.maptitle+32) && *read != '\0') - { - if (!(*read & 0x80)) - { - *writ = toupper(*read); - writ++; - } - read++; - } - *writ = '\0'; - //strncpy(netbuffer->u.serverinfo.maptitle, (char *)mapheaderinfo[gamemap-1]->lvlttl, 33); - } - else - strncpy(netbuffer->u.serverinfo.maptitle, "UNKNOWN", 32); - - if (mapheaderinfo[gamemap-1] && !(mapheaderinfo[gamemap-1]->levelflags & LF_NOZONE)) - netbuffer->u.serverinfo.iszone = 1; - else - netbuffer->u.serverinfo.iszone = 0; - - if (mapheaderinfo[gamemap-1]) - netbuffer->u.serverinfo.actnum = mapheaderinfo[gamemap-1]->actnum; - - p = PutFileNeeded(); - - HSendPacket(node, false, 0, p - ((UINT8 *)&netbuffer->u)); -} - -static void SV_SendPlayerInfo(INT32 node) -{ - UINT8 i; - netbuffer->packettype = PT_PLAYERINFO; - - for (i = 0; i < MAXPLAYERS; i++) - { - if (!playeringame[i]) - { - netbuffer->u.playerinfo[i].num = 255; // This slot is empty. - continue; - } - - netbuffer->u.playerinfo[i].num = i; - strncpy(netbuffer->u.playerinfo[i].name, (const char *)&player_names[i], MAXPLAYERNAME+1); - netbuffer->u.playerinfo[i].name[MAXPLAYERNAME] = '\0'; - - //fetch IP address - //No, don't do that, you fuckface. - memset(netbuffer->u.playerinfo[i].address, 0, 4); - - if (G_GametypeHasTeams()) - { - if (!players[i].ctfteam) - netbuffer->u.playerinfo[i].team = 255; - else - netbuffer->u.playerinfo[i].team = (UINT8)players[i].ctfteam; - } - else - { - if (players[i].spectator) - netbuffer->u.playerinfo[i].team = 255; - else - netbuffer->u.playerinfo[i].team = 0; - } - - 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 -#ifdef DEVELOP // it's safe to do this only because PLAYERINFO isn't read by the game itself - % 3 -#endif - ); - - // Extra data - netbuffer->u.playerinfo[i].data = 0; //players[i].skincolor; - - if (players[i].pflags & PF_TAGIT) - netbuffer->u.playerinfo[i].data |= 0x20; - - if (players[i].gotflag) - netbuffer->u.playerinfo[i].data |= 0x40; - - if (players[i].powers[pw_super]) - netbuffer->u.playerinfo[i].data |= 0x80; - } - - HSendPacket(node, false, 0, sizeof(plrinfo) * MAXPLAYERS); -} - -/** Sends a PT_SERVERCFG packet - * - * \param node The destination - * \return True if the packet was successfully sent - * - */ -static boolean SV_SendServerConfig(INT32 node) -{ - boolean waspacketsent; - - netbuffer->packettype = PT_SERVERCFG; - - netbuffer->u.servercfg.version = VERSION; - netbuffer->u.servercfg.subversion = SUBVERSION; - - netbuffer->u.servercfg.serverplayer = (UINT8)serverplayer; - netbuffer->u.servercfg.totalslotnum = (UINT8)(doomcom->numslots); - netbuffer->u.servercfg.gametic = (tic_t)LONG(gametic); - netbuffer->u.servercfg.clientnode = (UINT8)node; - netbuffer->u.servercfg.gamestate = (UINT8)gamestate; - netbuffer->u.servercfg.gametype = (UINT8)gametype; - netbuffer->u.servercfg.modifiedgame = (UINT8)modifiedgame; - - memcpy(netbuffer->u.servercfg.server_context, server_context, 8); - - { - const size_t len = sizeof (serverconfig_pak); - -#ifdef DEBUGFILE - if (debugfile) - { - fprintf(debugfile, "ServerConfig Packet about to be sent, size of packet:%s to node:%d\n", - sizeu1(len), node); - } -#endif - - waspacketsent = HSendPacket(node, true, 0, len); - } - -#ifdef DEBUGFILE - if (debugfile) - { - if (waspacketsent) - { - fprintf(debugfile, "ServerConfig Packet was sent\n"); - } - else - { - fprintf(debugfile, "ServerConfig Packet could not be sent right now\n"); - } - } -#endif - - return waspacketsent; -} - -#ifndef NONET -#define SAVEGAMESIZE (768*1024) - -static boolean SV_ResendingSavegameToAnyone(void) -{ - INT32 i; - - for (i = 0; i < MAXNETNODES; i++) - if (resendingsavegame[i]) - return true; - return false; -} - -static void SV_SendSaveGame(INT32 node, boolean resending) -{ - size_t length, compressedlen; - UINT8 *savebuffer; - UINT8 *compressedsave; - UINT8 *buffertosend; - - // first save it in a malloced buffer - savebuffer = (UINT8 *)malloc(SAVEGAMESIZE); - if (!savebuffer) - { - CONS_Alert(CONS_ERROR, M_GetText("No more free memory for savegame\n")); - return; - } - - // Leave room for the uncompressed length. - save_p = savebuffer + sizeof(UINT32); - - P_SaveNetGame(resending); - - length = save_p - savebuffer; - if (length > SAVEGAMESIZE) - { - free(savebuffer); - save_p = NULL; - I_Error("Savegame buffer overrun"); - } - - // Allocate space for compressed save: one byte fewer than for the - // uncompressed data to ensure that the compression is worthwhile. - compressedsave = malloc(length - 1); - if (!compressedsave) - { - CONS_Alert(CONS_ERROR, M_GetText("No more free memory for savegame\n")); - return; - } - - // Attempt to compress it. - if((compressedlen = lzf_compress(savebuffer + sizeof(UINT32), length - sizeof(UINT32), compressedsave + sizeof(UINT32), length - sizeof(UINT32) - 1))) - { - // Compressing succeeded; send compressed data - - free(savebuffer); - - // State that we're compressed. - buffertosend = compressedsave; - WRITEUINT32(compressedsave, length - sizeof(UINT32)); - length = compressedlen + sizeof(UINT32); - } - else - { - // Compression failed to make it smaller; send original - - free(compressedsave); - - // State that we're not compressed - buffertosend = savebuffer; - WRITEUINT32(savebuffer, 0); - } - - AddRamToSendQueue(node, buffertosend, length, SF_RAM, 0); - save_p = NULL; - - // Remember when we started sending the savegame so we can handle timeouts - sendingsavegame[node] = true; - freezetimeout[node] = I_GetTime() + jointimeout + length / 1024; // 1 extra tic for each kilobyte -} - -#ifdef DUMPCONSISTENCY -#define TMPSAVENAME "badmath.sav" -static consvar_t cv_dumpconsistency = CVAR_INIT ("dumpconsistency", "Off", CV_SAVE|CV_NETVAR, CV_OnOff, NULL); - -static void SV_SavedGame(void) -{ - size_t length; - UINT8 *savebuffer; - char tmpsave[256]; - - if (!cv_dumpconsistency.value) - return; - - sprintf(tmpsave, "%s" PATHSEP TMPSAVENAME, srb2home); - - // first save it in a malloced buffer - save_p = savebuffer = (UINT8 *)malloc(SAVEGAMESIZE); - if (!save_p) - { - CONS_Alert(CONS_ERROR, M_GetText("No more free memory for savegame\n")); - return; - } - - P_SaveNetGame(false); - - length = save_p - savebuffer; - if (length > SAVEGAMESIZE) - { - free(savebuffer); - save_p = NULL; - I_Error("Savegame buffer overrun"); - } - - // then save it! - if (!FIL_WriteFile(tmpsave, savebuffer, length)) - CONS_Printf(M_GetText("Didn't save %s for netgame"), tmpsave); - - free(savebuffer); - save_p = NULL; -} - -#undef TMPSAVENAME -#endif -#define TMPSAVENAME "$$$.sav" - - -static void CL_LoadReceivedSavegame(boolean reloading) -{ - UINT8 *savebuffer = NULL; - size_t length, decompressedlen; - char tmpsave[256]; - - sprintf(tmpsave, "%s" PATHSEP TMPSAVENAME, srb2home); - - length = FIL_ReadFile(tmpsave, &savebuffer); - - CONS_Printf(M_GetText("Loading savegame length %s\n"), sizeu1(length)); - if (!length) - { - I_Error("Can't read savegame sent"); - return; - } - - save_p = savebuffer; - - // Decompress saved game if necessary. - decompressedlen = READUINT32(save_p); - if(decompressedlen > 0) - { - UINT8 *decompressedbuffer = Z_Malloc(decompressedlen, PU_STATIC, NULL); - lzf_decompress(save_p, length - sizeof(UINT32), decompressedbuffer, decompressedlen); - Z_Free(savebuffer); - save_p = savebuffer = decompressedbuffer; - } - - paused = false; - demoplayback = false; - titlemapinaction = TITLEMAP_OFF; - titledemo = false; - automapactive = false; - - // load a base level - if (P_LoadNetGame(reloading)) - { - const UINT8 actnum = mapheaderinfo[gamemap-1]->actnum; - CONS_Printf(M_GetText("Map is now \"%s"), G_BuildMapName(gamemap)); - if (strcmp(mapheaderinfo[gamemap-1]->lvlttl, "")) - { - CONS_Printf(": %s", mapheaderinfo[gamemap-1]->lvlttl); - if (!(mapheaderinfo[gamemap-1]->levelflags & LF_NOZONE)) - CONS_Printf(M_GetText(" Zone")); - if (actnum > 0) - CONS_Printf(" %2d", actnum); - } - CONS_Printf("\"\n"); - } - else - { - CONS_Alert(CONS_ERROR, M_GetText("Can't load the level!\n")); - Z_Free(savebuffer); - save_p = NULL; - if (unlink(tmpsave) == -1) - CONS_Alert(CONS_ERROR, M_GetText("Can't delete %s\n"), tmpsave); - return; - } - - // done - Z_Free(savebuffer); - save_p = NULL; - if (unlink(tmpsave) == -1) - CONS_Alert(CONS_ERROR, M_GetText("Can't delete %s\n"), tmpsave); - consistancy[gametic%BACKUPTICS] = Consistancy(); - CON_ToggleOff(); - - // Tell the server we have received and reloaded the gamestate - // so they know they can resume the game - netbuffer->packettype = PT_RECEIVEDGAMESTATE; - HSendPacket(servernode, true, 0, 0); -} - -static void CL_ReloadReceivedSavegame(void) -{ - INT32 i; - - for (i = 0; i < MAXPLAYERS; i++) - { -#ifdef HAVE_BLUA - LUA_InvalidatePlayer(&players[i]); -#endif - sprintf(player_names[i], "Player %d", i + 1); - } - - CL_LoadReceivedSavegame(true); - - if (neededtic < gametic) - neededtic = gametic; - maketic = neededtic; - - ticcmd_oldangleturn[0] = players[consoleplayer].oldrelangleturn; - P_ForceLocalAngle(&players[consoleplayer], (angle_t)(players[consoleplayer].angleturn << 16)); - if (splitscreen) - { - ticcmd_oldangleturn[1] = players[secondarydisplayplayer].oldrelangleturn; - P_ForceLocalAngle(&players[secondarydisplayplayer], (angle_t)(players[secondarydisplayplayer].angleturn << 16)); - } - - camera.subsector = R_PointInSubsector(camera.x, camera.y); - camera2.subsector = R_PointInSubsector(camera2.x, camera2.y); - - cl_redownloadinggamestate = false; - - CONS_Printf(M_GetText("Game state reloaded\n")); -} -#endif - -#ifndef NONET -static void SendAskInfo(INT32 node) -{ - const tic_t asktime = I_GetTime(); - netbuffer->packettype = PT_ASKINFO; - netbuffer->u.askinfo.version = VERSION; - netbuffer->u.askinfo.time = (tic_t)LONG(asktime); - - // Even if this never arrives due to the host being firewalled, we've - // now allowed traffic from the host to us in, so once the MS relays - // our address to the host, it'll be able to speak to us. - HSendPacket(node, false, 0, sizeof (askinfo_pak)); -} - -serverelem_t serverlist[MAXSERVERLIST]; -UINT32 serverlistcount = 0; - -#define FORCECLOSE 0x8000 - -static void SL_ClearServerList(INT32 connectedserver) -{ - UINT32 i; - - for (i = 0; i < serverlistcount; i++) - if (connectedserver != serverlist[i].node) - { - Net_CloseConnection(serverlist[i].node|FORCECLOSE); - serverlist[i].node = 0; - } - serverlistcount = 0; -} - -static UINT32 SL_SearchServer(INT32 node) -{ - UINT32 i; - for (i = 0; i < serverlistcount; i++) - if (serverlist[i].node == node) - return i; - - return UINT32_MAX; -} - -static void SL_InsertServer(serverinfo_pak* info, SINT8 node) -{ - UINT32 i; - - // search if not already on it - i = SL_SearchServer(node); - if (i == UINT32_MAX) - { - // not found add it - if (serverlistcount >= MAXSERVERLIST) - return; // list full - - if (info->_255 != 255) - return;/* old packet format */ - - if (info->packetversion != PACKETVERSION) - return;/* old new packet format */ - - if (info->version != VERSION) - return; // Not same version. - - if (info->subversion != SUBVERSION) - return; // Close, but no cigar. - - if (strcmp(info->application, SRB2APPLICATION)) - return;/* that's a different mod */ - - i = serverlistcount++; - } - - serverlist[i].info = *info; - serverlist[i].node = node; - - // resort server list - M_SortServerList(); -} - -#if defined (MASTERSERVER) && defined (HAVE_THREADS) -struct Fetch_servers_ctx -{ - int room; - int id; -}; - -static void -Fetch_servers_thread (struct Fetch_servers_ctx *ctx) -{ - msg_server_t *server_list; - - server_list = GetShortServersList(ctx->room, ctx->id); - - if (server_list) - { - I_lock_mutex(&ms_QueryId_mutex); - { - if (ctx->id != ms_QueryId) - { - free(server_list); - server_list = NULL; - } - } - I_unlock_mutex(ms_QueryId_mutex); - - if (server_list) - { - I_lock_mutex(&m_menu_mutex); - { - if (m_waiting_mode == M_WAITING_SERVERS) - m_waiting_mode = M_NOT_WAITING; - } - I_unlock_mutex(m_menu_mutex); - - I_lock_mutex(&ms_ServerList_mutex); - { - ms_ServerList = server_list; - } - I_unlock_mutex(ms_ServerList_mutex); - } - } - - free(ctx); -} -#endif/*defined (MASTERSERVER) && defined (HAVE_THREADS)*/ - -void CL_QueryServerList (msg_server_t *server_list) -{ - INT32 i; - - for (i = 0; server_list[i].header.buffer[0]; i++) - { - // Make sure MS version matches our own, to - // thwart nefarious servers who lie to the MS. - - /* lol bruh, that version COMES from the servers */ - //if (strcmp(version, server_list[i].version) == 0) - { - INT32 node = I_NetMakeNodewPort(server_list[i].ip, server_list[i].port); - if (node == -1) - break; // no more node free - SendAskInfo(node); - // Force close the connection so that servers can't eat - // up nodes forever if we never get a reply back from them - // (usually when they've not forwarded their ports). - // - // Don't worry, we'll get in contact with the working - // servers again when they send SERVERINFO to us later! - // - // (Note: as a side effect this probably means every - // server in the list will probably be using the same node (e.g. node 1), - // not that it matters which nodes they use when - // the connections are closed afterwards anyway) - // -- Monster Iestyn 12/11/18 - Net_CloseConnection(node|FORCECLOSE); - } - } -} - -void CL_UpdateServerList(boolean internetsearch, INT32 room) -{ - (void)internetsearch; - (void)room; - - SL_ClearServerList(0); - - if (!netgame && I_NetOpenSocket) - { - if (I_NetOpenSocket()) - { - netgame = true; - multiplayer = true; - } - } - - // search for local servers - if (netgame) - SendAskInfo(BROADCASTADDR); - -#ifdef MASTERSERVER - if (internetsearch) - { -#ifdef HAVE_THREADS - struct Fetch_servers_ctx *ctx; - - ctx = malloc(sizeof *ctx); - - /* This called from M_Refresh so I don't use a mutex */ - m_waiting_mode = M_WAITING_SERVERS; - - I_lock_mutex(&ms_QueryId_mutex); - { - ctx->id = ms_QueryId; - } - I_unlock_mutex(ms_QueryId_mutex); - - ctx->room = room; - - I_spawn_thread("fetch-servers", (I_thread_fn)Fetch_servers_thread, ctx); -#else - msg_server_t *server_list; - - server_list = GetShortServersList(room, 0); - - if (server_list) - { - CL_QueryServerList(server_list); - free(server_list); - } -#endif - } -#endif/*MASTERSERVER*/ -} - -#endif // ifndef NONET - -/** Called by CL_ServerConnectionTicker - * - * \param asksent The last time we asked the server to join. We re-ask every second in case our request got lost in transmit. - * \return False if the connection was aborted - * \sa CL_ServerConnectionTicker - * \sa CL_ConnectToServer - * - */ -static boolean CL_ServerConnectionSearchTicker(tic_t *asksent) -{ -#ifndef NONET - INT32 i; - - // serverlist is updated by GetPacket function - if (serverlistcount > 0) - { - // this can be a responce to our broadcast request - if (servernode == -1 || servernode >= MAXNETNODES) - { - i = 0; - servernode = serverlist[i].node; - CONS_Printf(M_GetText("Found, ")); - } - else - { - i = SL_SearchServer(servernode); - if (i < 0) - return true; - } - - // Quit here rather than downloading files and being refused later. - if (serverlist[i].info.refusereason) - { - D_QuitNetGame(); - CL_Reset(); - D_StartTitle(); - if (serverlist[i].info.refusereason == 1) - M_StartMessage(M_GetText("The server is not accepting\njoins for the moment.\n\nPress ESC\n"), NULL, MM_NOTHING); - else if (serverlist[i].info.refusereason == 2) - M_StartMessage(va(M_GetText("Maximum players reached: %d\n\nPress ESC\n"), serverlist[i].info.maxplayer), NULL, MM_NOTHING); - else - M_StartMessage(M_GetText("You can't join.\nI don't know why,\nbut you can't join.\n\nPress ESC\n"), NULL, MM_NOTHING); - return false; - } - - if (client) - { - D_ParseFileneeded(serverlist[i].info.fileneedednum, - serverlist[i].info.fileneeded); - CONS_Printf(M_GetText("Checking files...\n")); - i = CL_CheckFiles(); - if (i == 3) // too many files - { - D_QuitNetGame(); - CL_Reset(); - D_StartTitle(); - M_StartMessage(M_GetText( - "You have too many WAD files loaded\n" - "to add ones the server is using.\n" - "Please restart SRB2 before connecting.\n\n" - "Press ESC\n" - ), NULL, MM_NOTHING); - return false; - } - else if (i == 2) // cannot join for some reason - { - D_QuitNetGame(); - CL_Reset(); - D_StartTitle(); - M_StartMessage(M_GetText( - "You have the wrong addons loaded.\n\n" - "To play on this server, restart\n" - "the game and don't load any addons.\n" - "SRB2 will automatically add\n" - "everything you need when you join.\n\n" - "Press ESC\n" - ), NULL, MM_NOTHING); - return false; - } - else if (i == 1) - cl_mode = CL_ASKJOIN; - else - { - // must download something - // can we, though? - if (!CL_CheckDownloadable()) // nope! - { - D_QuitNetGame(); - CL_Reset(); - D_StartTitle(); - M_StartMessage(M_GetText( - "You cannot connect to this server\n" - "because you cannot download the files\n" - "that you are missing from the server.\n\n" - "See the console or log file for\n" - "more details.\n\n" - "Press ESC\n" - ), NULL, MM_NOTHING); - return false; - } - // no problem if can't send packet, we will retry later - if (CL_SendFileRequest()) - { - cl_mode = CL_DOWNLOADFILES; -#ifndef NONET - Snake_Initialise(); -#endif - } - } - } - else - cl_mode = CL_ASKJOIN; // files need not be checked for the server. - - return true; - } - - // Ask the info to the server (askinfo packet) - if (*asksent + NEWTICRATE < I_GetTime()) - { - SendAskInfo(servernode); - *asksent = I_GetTime(); - } -#else - (void)asksent; - // No netgames, so we skip this state. - cl_mode = CL_ASKJOIN; -#endif // ifndef NONET/else - - return true; -} - -/** Called by CL_ConnectToServer - * - * \param tmpsave The name of the gamestate file??? - * \param oldtic Used for knowing when to poll events and redraw - * \param asksent ??? - * \return False if the connection was aborted - * \sa CL_ServerConnectionSearchTicker - * \sa CL_ConnectToServer - * - */ -static boolean CL_ServerConnectionTicker(const char *tmpsave, tic_t *oldtic, tic_t *asksent) -{ - boolean waitmore; - INT32 i; - -#ifdef NONET - (void)tmpsave; -#endif - - switch (cl_mode) - { - case CL_SEARCHING: - if (!CL_ServerConnectionSearchTicker(asksent)) - return false; - break; - - case CL_DOWNLOADFILES: - waitmore = false; - for (i = 0; i < fileneedednum; i++) - if (fileneeded[i].status == FS_DOWNLOADING - || fileneeded[i].status == FS_REQUESTED) - { - waitmore = true; - break; - } - if (waitmore) - break; // exit the case - -#ifndef NONET - if (snake) - { - free(snake); - snake = NULL; - } -#endif - - cl_mode = CL_ASKJOIN; // don't break case continue to cljoin request now - /* FALLTHRU */ - - case CL_ASKJOIN: - CL_LoadServerFiles(); -#ifndef NONET - // prepare structures to save the file - // WARNING: this can be useless in case of server not in GS_LEVEL - // but since the network layer doesn't provide ordered packets... - CL_PrepareDownloadSaveGame(tmpsave); -#endif - if (CL_SendJoin()) - cl_mode = CL_WAITJOINRESPONSE; - break; - -#ifndef NONET - case CL_DOWNLOADSAVEGAME: - // At this state, the first (and only) needed file is the gamestate - if (fileneeded[0].status == FS_FOUND) - { - // Gamestate is now handled within CL_LoadReceivedSavegame() - CL_LoadReceivedSavegame(false); - cl_mode = CL_CONNECTED; - } // don't break case continue to CL_CONNECTED - else - break; -#endif - - case CL_WAITJOINRESPONSE: - case CL_CONNECTED: - default: - break; - - // Connection closed by cancel, timeout or refusal. - case CL_ABORTED: - cl_mode = CL_SEARCHING; - return false; - - } - - GetPackets(); - Net_AckTicker(); - - // Call it only once by tic - if (*oldtic != I_GetTime()) - { - I_OsPolling(); - for (; eventtail != eventhead; eventtail = (eventtail+1) & (MAXEVENTS-1)) - G_MapEventsToControls(&events[eventtail]); - - if (gamekeydown[KEY_ESCAPE] || gamekeydown[KEY_JOY1+1]) - { - CONS_Printf(M_GetText("Network game synchronization aborted.\n")); -// M_StartMessage(M_GetText("Network game synchronization aborted.\n\nPress ESC\n"), NULL, MM_NOTHING); - -#ifndef NONET - if (snake) - { - free(snake); - snake = NULL; - } -#endif - - D_QuitNetGame(); - CL_Reset(); - D_StartTitle(); - memset(gamekeydown, 0, NUMKEYS); - return false; - } -#ifndef NONET - else if (cl_mode == CL_DOWNLOADFILES && snake) - Snake_Handle(); -#endif - - if (client && (cl_mode == CL_DOWNLOADFILES || cl_mode == CL_DOWNLOADSAVEGAME)) - FileReceiveTicker(); - - // why are these here? this is for servers, we're a client - //if (key == 's' && server) - // doomcom->numnodes = (INT16)pnumnodes; - //FileSendTicker(); - *oldtic = I_GetTime(); - -#ifndef NONET - if (client && cl_mode != CL_CONNECTED && cl_mode != CL_ABORTED) - { - if (cl_mode != CL_DOWNLOADFILES && cl_mode != CL_DOWNLOADSAVEGAME) - { - F_MenuPresTicker(true); // title sky - F_TitleScreenTicker(true); - F_TitleScreenDrawer(); - } - CL_DrawConnectionStatus(); - I_UpdateNoVsync(); // page flip or blit buffer - if (moviemode) - M_SaveFrame(); - S_UpdateSounds(); - S_UpdateClosedCaptions(); - } -#else - CON_Drawer(); - I_UpdateNoVsync(); -#endif - } - else - I_Sleep(); - - return true; -} - -/** Use adaptive send using net_bandwidth and stat.sendbytes - * - * \todo Better description... - * - */ -static void CL_ConnectToServer(void) -{ - INT32 pnumnodes, nodewaited = doomcom->numnodes, i; - tic_t oldtic; -#ifndef NONET - tic_t asksent; - char tmpsave[256]; - - sprintf(tmpsave, "%s" PATHSEP TMPSAVENAME, srb2home); - - lastfilenum = -1; -#endif - - cl_mode = CL_SEARCHING; - -#ifndef NONET - // Don't get a corrupt savegame error because tmpsave already exists - if (FIL_FileExists(tmpsave) && unlink(tmpsave) == -1) - I_Error("Can't delete %s\n", tmpsave); -#endif - - if (netgame) - { - if (servernode < 0 || servernode >= MAXNETNODES) - CONS_Printf(M_GetText("Searching for a server...\n")); - else - CONS_Printf(M_GetText("Contacting the server...\n")); - } - - if (gamestate == GS_INTERMISSION) - Y_EndIntermission(); // clean up intermission graphics etc - - DEBFILE(va("waiting %d nodes\n", doomcom->numnodes)); - G_SetGamestate(GS_WAITINGPLAYERS); - wipegamestate = GS_WAITINGPLAYERS; - - ClearAdminPlayers(); - pnumnodes = 1; - oldtic = I_GetTime() - 1; -#ifndef NONET - asksent = (tic_t) - TICRATE; - - i = SL_SearchServer(servernode); - - if (i != -1) - { - char *gametypestr = serverlist[i].info.gametypename; - CONS_Printf(M_GetText("Connecting to: %s\n"), serverlist[i].info.servername); - gametypestr[sizeof serverlist[i].info.gametypename - 1] = '\0'; - CONS_Printf(M_GetText("Gametype: %s\n"), gametypestr); - CONS_Printf(M_GetText("Version: %d.%d.%u\n"), serverlist[i].info.version/100, - serverlist[i].info.version%100, serverlist[i].info.subversion); - } - SL_ClearServerList(servernode); -#endif - - do - { - // If the connection was aborted for some reason, leave -#ifndef NONET - if (!CL_ServerConnectionTicker(tmpsave, &oldtic, &asksent)) -#else - if (!CL_ServerConnectionTicker((char*)NULL, &oldtic, (tic_t *)NULL)) -#endif - return; - - if (server) - { - pnumnodes = 0; - for (i = 0; i < MAXNETNODES; i++) - if (nodeingame[i]) - pnumnodes++; - } - } - while (!(cl_mode == CL_CONNECTED && (client || (server && nodewaited <= pnumnodes)))); - - DEBFILE(va("Synchronisation Finished\n")); - - displayplayer = consoleplayer; -} - -#ifndef NONET -typedef struct banreason_s -{ - char *reason; - struct banreason_s *prev; //-1 - struct banreason_s *next; //+1 -} banreason_t; - -static banreason_t *reasontail = NULL; //last entry, use prev -static banreason_t *reasonhead = NULL; //1st entry, use next - -static void Command_ShowBan(void) //Print out ban list -{ - size_t i; - const char *address, *mask; - banreason_t *reasonlist = reasonhead; - - if (I_GetBanAddress) - CONS_Printf(M_GetText("Ban List:\n")); - else - return; - - for (i = 0;(address = I_GetBanAddress(i)) != NULL;i++) - { - if (!I_GetBanMask || (mask = I_GetBanMask(i)) == NULL) - CONS_Printf("%s: %s ", sizeu1(i+1), address); - else - CONS_Printf("%s: %s/%s ", sizeu1(i+1), address, mask); - - if (reasonlist && reasonlist->reason) - CONS_Printf("(%s)\n", reasonlist->reason); - else - CONS_Printf("\n"); - - if (reasonlist) reasonlist = reasonlist->next; - } - - if (i == 0 && !address) - CONS_Printf(M_GetText("(empty)\n")); -} - -void D_SaveBan(void) -{ - FILE *f; - size_t i; - banreason_t *reasonlist = reasonhead; - const char *address, *mask; - - if (!reasonhead) - return; - - f = fopen(va("%s"PATHSEP"%s", srb2home, "ban.txt"), "w"); - - if (!f) - { - CONS_Alert(CONS_WARNING, M_GetText("Could not save ban list into ban.txt\n")); - return; - } - - for (i = 0;(address = I_GetBanAddress(i)) != NULL;i++) - { - if (!I_GetBanMask || (mask = I_GetBanMask(i)) == NULL) - fprintf(f, "%s 0", address); - else - fprintf(f, "%s %s", address, mask); - - if (reasonlist && reasonlist->reason) - fprintf(f, " %s\n", reasonlist->reason); - else - fprintf(f, " %s\n", "NA"); - - if (reasonlist) reasonlist = reasonlist->next; - } - - fclose(f); -} - -static void Ban_Add(const char *reason) -{ - banreason_t *reasonlist = malloc(sizeof(*reasonlist)); - - if (!reasonlist) - return; - if (!reason) - reason = "NA"; - - reasonlist->next = NULL; - reasonlist->reason = Z_StrDup(reason); - if ((reasonlist->prev = reasontail) == NULL) - reasonhead = reasonlist; - else - reasontail->next = reasonlist; - reasontail = reasonlist; -} - -static void Command_ClearBans(void) -{ - banreason_t *temp; - - if (!I_ClearBans) - return; - - I_ClearBans(); - D_SaveBan(); - reasontail = NULL; - while (reasonhead) - { - temp = reasonhead->next; - Z_Free(reasonhead->reason); - free(reasonhead); - reasonhead = temp; - } -} - -static void Ban_Load_File(boolean warning) -{ - FILE *f; - size_t i; - const char *address, *mask; - char buffer[MAX_WADPATH]; - - f = fopen(va("%s"PATHSEP"%s", srb2home, "ban.txt"), "r"); - - if (!f) - { - if (warning) - CONS_Alert(CONS_WARNING, M_GetText("Could not open ban.txt for ban list\n")); - return; - } - - if (I_ClearBans) - Command_ClearBans(); - else - { - fclose(f); - return; - } - - for (i=0; fgets(buffer, (int)sizeof(buffer), f); i++) - { - address = strtok(buffer, " \t\r\n"); - mask = strtok(NULL, " \t\r\n"); - - I_SetBanAddress(address, mask); - - Ban_Add(strtok(NULL, "\r\n")); - } - - fclose(f); -} - -static void Command_ReloadBan(void) //recheck ban.txt -{ - Ban_Load_File(true); -} - -static void Command_connect(void) -{ - if (COM_Argc() < 2 || *COM_Argv(1) == 0) - { - CONS_Printf(M_GetText( - "Connect (port): connect to a server\n" - "Connect ANY: connect to the first lan server found\n" - //"Connect SELF: connect to your own server.\n" - )); - return; - } - - if (Playing() || titledemo) - { - CONS_Printf(M_GetText("You cannot connect while in a game. End this game first.\n")); - return; - } - - // modified game check: no longer handled - // we don't request a restart unless the filelist differs - - server = false; -/* - if (!stricmp(COM_Argv(1), "self")) - { - servernode = 0; - server = true; - /// \bug should be but... - //SV_SpawnServer(); - } - else -*/ - { - // used in menu to connect to a server in the list - if (netgame && !stricmp(COM_Argv(1), "node")) - { - servernode = (SINT8)atoi(COM_Argv(2)); - } - else if (netgame) - { - CONS_Printf(M_GetText("You cannot connect while in a game. End this game first.\n")); - return; - } - else if (I_NetOpenSocket) - { - I_NetOpenSocket(); - netgame = true; - multiplayer = true; - - if (!stricmp(COM_Argv(1), "any")) - servernode = BROADCASTADDR; - else if (I_NetMakeNodewPort) - { - if (COM_Argc() >= 3) // address AND port - servernode = I_NetMakeNodewPort(COM_Argv(1), COM_Argv(2)); - else // address only, or address:port - servernode = I_NetMakeNode(COM_Argv(1)); - } - else - { - CONS_Alert(CONS_ERROR, M_GetText("There is no server identification with this network driver\n")); - D_CloseConnection(); - return; - } - } - else - CONS_Alert(CONS_ERROR, M_GetText("There is no network driver\n")); - } - - splitscreen = false; - SplitScreen_OnChange(); - botingame = false; - botskin = 0; - CL_ConnectToServer(); -} -#endif - -static void ResetNode(INT32 node); - -// -// CL_ClearPlayer -// -// Clears the player data so that a future client can use this slot -// -void CL_ClearPlayer(INT32 playernum) -{ - if (players[playernum].mo) - P_RemoveMobj(players[playernum].mo); - memset(&players[playernum], 0, sizeof (player_t)); - memset(playeraddress[playernum], 0, sizeof(*playeraddress)); -} - -// -// CL_RemovePlayer -// -// Removes a player from the current game -// -static void CL_RemovePlayer(INT32 playernum, kickreason_t reason) -{ - // Sanity check: exceptional cases (i.e. c-fails) can cause multiple - // kick commands to be issued for the same player. - if (!playeringame[playernum]) - return; - - if (server && !demoplayback && playernode[playernum] != UINT8_MAX) - { - INT32 node = playernode[playernum]; - playerpernode[node]--; - if (playerpernode[node] <= 0) - { - nodeingame[node] = false; - Net_CloseConnection(node); - ResetNode(node); - } - } - - if (gametyperules & GTR_TEAMFLAGS) - P_PlayerFlagBurst(&players[playernum], false); // Don't take the flag with you! - - // If in a special stage, redistribute the player's spheres across - // the remaining players. - if (G_IsSpecialStage(gamemap)) - { - INT32 i, count, sincrement, spheres, rincrement, rings; - - for (i = 0, count = 0; i < MAXPLAYERS; i++) - { - if (playeringame[i]) - count++; - } - - count--; - sincrement = spheres = players[playernum].spheres; - rincrement = rings = players[playernum].rings; - - if (count) - { - sincrement /= count; - rincrement /= count; - } - - for (i = 0; i < MAXPLAYERS; i++) - { - if (playeringame[i] && i != playernum) - { - if (spheres < 2*sincrement) - { - P_GivePlayerSpheres(&players[i], spheres); - spheres = 0; - } - else - { - P_GivePlayerSpheres(&players[i], sincrement); - spheres -= sincrement; - } - - if (rings < 2*rincrement) - { - P_GivePlayerRings(&players[i], rings); - rings = 0; - } - else - { - P_GivePlayerRings(&players[i], rincrement); - rings -= rincrement; - } - } - } - } - - LUAh_PlayerQuit(&players[playernum], reason); // Lua hook for player quitting - - // don't look through someone's view who isn't there - if (playernum == displayplayer) - { - // Call ViewpointSwitch hooks here. - // The viewpoint was forcibly changed. - LUAh_ViewpointSwitch(&players[consoleplayer], &players[consoleplayer], true); - displayplayer = consoleplayer; - } - - // Reset player data - CL_ClearPlayer(playernum); - - // remove avatar of player - playeringame[playernum] = false; - playernode[playernum] = UINT8_MAX; - while (!playeringame[doomcom->numslots-1] && doomcom->numslots > 1) - doomcom->numslots--; - - // Reset the name - sprintf(player_names[playernum], "Player %d", playernum+1); - - player_name_changes[playernum] = 0; - - if (IsPlayerAdmin(playernum)) - { - RemoveAdminPlayer(playernum); // don't stay admin after you're gone - } - - LUA_InvalidatePlayer(&players[playernum]); - - if (G_TagGametype()) //Check if you still have a game. Location flexible. =P - P_CheckSurvivors(); - else if (gametyperules & GTR_RACE) - P_CheckRacers(); -} - -void CL_Reset(void) -{ - if (metalrecording) - G_StopMetalRecording(false); - if (metalplayback) - G_StopMetalDemo(); - if (demorecording) - G_CheckDemoStatus(); - - // reset client/server code - DEBFILE(va("\n-=-=-=-=-=-=-= Client reset =-=-=-=-=-=-=-\n\n")); - - if (servernode > 0 && servernode < MAXNETNODES) - { - nodeingame[(UINT8)servernode] = false; - Net_CloseConnection(servernode); - } - D_CloseConnection(); // netgame = false - multiplayer = false; - servernode = 0; - server = true; - doomcom->numnodes = 1; - doomcom->numslots = 1; - SV_StopServer(); - SV_ResetServer(); - CV_RevertNetVars(); - - // make sure we don't leave any fileneeded gunk over from a failed join - fileneedednum = 0; - memset(fileneeded, 0, sizeof(fileneeded)); - - // D_StartTitle should get done now, but the calling function will handle it -} - -#ifndef NONET -static void Command_GetPlayerNum(void) -{ - INT32 i; - - for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i]) - { - if (serverplayer == i) - CONS_Printf(M_GetText("num:%2d node:%2d %s\n"), i, playernode[i], player_names[i]); - else - CONS_Printf(M_GetText("\x82num:%2d node:%2d %s\n"), i, playernode[i], player_names[i]); - } -} - -SINT8 nametonum(const char *name) -{ - INT32 playernum, i; - - if (!strcmp(name, "0")) + if (!skin) return 0; - playernum = (SINT8)atoi(name); + if ((playersprite_t)(spr2 & ~FF_SPR2SUPER) >= free_spr2) + return 0; - if (playernum < 0 || playernum >= MAXPLAYERS) - return -1; - - if (playernum) + while (!skin->sprites[spr2].numframes + && spr2 != SPR2_STND + && ++i < 32) // recursion limiter { - if (playeringame[playernum]) - return (SINT8)playernum; - else - return -1; + if (spr2 & FF_SPR2SUPER) + { + super = FF_SPR2SUPER; + spr2 &= ~FF_SPR2SUPER; + continue; + } + + switch(spr2) + { + // Normal special cases. + case SPR2_JUMP: + spr2 = ((player + ? player->charflags + : skin->flags) + & SF_NOJUMPSPIN) ? SPR2_SPNG : SPR2_ROLL; + break; + case SPR2_TIRE: + spr2 = ((player + ? player->charability + : skin->ability) + == CA_SWIM) ? SPR2_SWIM : SPR2_FLY; + break; + // Use the handy list, that's what it's there for! + default: + spr2 = spr2defaults[spr2]; + break; + } + + spr2 |= super; } - for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i] && !stricmp(player_names[i], name)) - return (SINT8)i; + if (i >= 32) // probably an infinite loop... + return 0; - CONS_Printf(M_GetText("There is no player named \"%s\"\n"), name); + return spr2; +} +static void Sk_SetDefaultValue(skin_t *skin) +{ + INT32 i; + // + // set default skin values + // + memset(skin, 0, sizeof (skin_t)); + snprintf(skin->name, + sizeof skin->name, "skin %u", (UINT32)(skin-skins)); + skin->name[sizeof skin->name - 1] = '\0'; + skin->wadnum = INT16_MAX; + + skin->flags = 0; + + strcpy(skin->realname, "Someone"); + strcpy(skin->hudname, "???"); + + skin->starttranscolor = 96; + skin->prefcolor = SKINCOLOR_GREEN; + skin->supercolor = SKINCOLOR_SUPERGOLD1; + skin->prefoppositecolor = 0; // use tables + + skin->normalspeed = 36<runspeed = 28<thrustfactor = 5; + skin->accelstart = 96; + skin->acceleration = 40; + + skin->ability = CA_NONE; + skin->ability2 = CA2_SPINDASH; + skin->jumpfactor = FRACUNIT; + skin->actionspd = 30<mindash = 15<maxdash = 70<radius = mobjinfo[MT_PLAYER].radius; + skin->height = mobjinfo[MT_PLAYER].height; + skin->spinheight = FixedMul(skin->height, 2*FRACUNIT/3); + + skin->shieldscale = FRACUNIT; + skin->camerascale = FRACUNIT; + + skin->thokitem = -1; + skin->spinitem = -1; + skin->revitem = -1; + skin->followitem = 0; + + skin->highresscale = FRACUNIT; + skin->contspeed = 17; + skin->contangle = 0; + + skin->availability = 0; + + for (i = 0; i < sfx_skinsoundslot0; i++) + if (S_sfx[i].skinsound != -1) + skin->soundsid[S_sfx[i].skinsound] = i; +} + +// +// Initialize the basic skins +// +void R_InitSkins(void) +{ +#ifdef SKINVALUES + INT32 i; + + for (i = 0; i <= MAXSKINS; i++) + { + skin_cons_t[i].value = 0; + skin_cons_t[i].strvalue = NULL; + } +#endif + + // no default skin! + numskins = 0; +} + +UINT32 R_GetSkinAvailabilities(void) +{ + INT32 s; + UINT32 response = 0; + + for (s = 0; s < MAXSKINS; s++) + { + if (skins[s].availability && unlockables[skins[s].availability - 1].unlocked) + response |= (1 << s); + } + return response; +} + +// returns true if available in circumstances, otherwise nope +// warning don't use with an invalid skinnum other than -1 which always returns true +boolean R_SkinUsable(INT32 playernum, INT32 skinnum) +{ + return ((skinnum == -1) // Simplifies things elsewhere, since there's already plenty of checks for less-than-0... + || (!skins[skinnum].availability) + || (((netgame || multiplayer) && playernum != -1) ? (players[playernum].availabilities & (1 << skinnum)) : (unlockables[skins[skinnum].availability - 1].unlocked)) + || (modeattacking) // If you have someone else's run you might as well take a look + || (Playing() && (R_SkinAvailable(mapheaderinfo[gamemap-1]->forcecharacter) == skinnum)) // Force 1. + || (netgame && (cv_forceskin.value == skinnum)) // Force 2. + || (metalrecording && skinnum == 5) // Force 3. + || players[playernum].bot //Force (player is a bot) + ); +} + +// returns true if the skin name is found (loaded from pwad) +// warning return -1 if not found +INT32 R_SkinAvailable(const char *name) +{ + INT32 i; + + for (i = 0; i < numskins; i++) + { + // search in the skin list + if (stricmp(skins[i].name,name)==0) + return i; + } return -1; } -/** Lists all players and their player numbers. - * - * \sa Command_GetPlayerNum - */ -static void Command_Nodes(void) +// network code calls this when a 'skin change' is received +void SetPlayerSkin(INT32 playernum, const char *skinname) { - INT32 i; - size_t maxlen = 0; - const char *address; + INT32 i = R_SkinAvailable(skinname); + player_t *player = &players[playernum]; - for (i = 0; i < MAXPLAYERS; i++) + if ((i != -1) && R_SkinUsable(playernum, i)) { - const size_t plen = strlen(player_names[i]); - if (playeringame[i] && plen > maxlen) - maxlen = plen; + SetPlayerSkinByNum(playernum, i); + return; } - for (i = 0; i < MAXPLAYERS; i++) - { - if (playeringame[i]) - { - CONS_Printf("%.2u: %*s", i, (int)maxlen, player_names[i]); + if (P_IsLocalPlayer(player)) + CONS_Alert(CONS_WARNING, M_GetText("Skin '%s' not found.\n"), skinname); + else if(server || IsPlayerAdmin(consoleplayer)) + CONS_Alert(CONS_WARNING, M_GetText("Player %d (%s) skin '%s' not found\n"), playernum, player_names[playernum], skinname); - if (playernode[i] != UINT8_MAX) - { - CONS_Printf(" - node %.2d", playernode[i]); - if (I_GetNodeAddress && (address = I_GetNodeAddress(playernode[i])) != NULL) - CONS_Printf(" - %s", address); - } - - if (IsPlayerAdmin(i)) - CONS_Printf(M_GetText(" (verified admin)")); - - if (players[i].spectator) - CONS_Printf(M_GetText(" (spectator)")); - - CONS_Printf("\n"); - } - } + SetPlayerSkinByNum(playernum, 0); } -static void Command_Ban(void) +// Same as SetPlayerSkin, but uses the skin #. +// network code calls this when a 'skin change' is received +void SetPlayerSkinByNum(INT32 playernum, INT32 skinnum) { - if (COM_Argc() < 2) + player_t *player = &players[playernum]; + skin_t *skin = &skins[skinnum]; + UINT16 newcolor = 0; + + if (skinnum >= 0 && skinnum < numskins && R_SkinUsable(playernum, skinnum)) // Make sure it exists! { - CONS_Printf(M_GetText("Ban : ban and kick a player\n")); - return; - } + player->skin = skinnum; - if (!netgame) // Don't kick Tails in splitscreen! - { - CONS_Printf(M_GetText("This only works in a netgame.\n")); - return; - } + player->camerascale = skin->camerascale; + player->shieldscale = skin->shieldscale; - if (server || IsPlayerAdmin(consoleplayer)) - { - UINT8 buf[3 + MAX_REASONLENGTH]; - UINT8 *p = buf; - const SINT8 pn = nametonum(COM_Argv(1)); - const INT32 node = playernode[(INT32)pn]; + player->charability = (UINT8)skin->ability; + player->charability2 = (UINT8)skin->ability2; - if (pn == -1 || pn == 0) - return; + player->charflags = (UINT32)skin->flags; - WRITEUINT8(p, pn); + player->thokitem = skin->thokitem < 0 ? (UINT32)mobjinfo[MT_PLAYER].painchance : (UINT32)skin->thokitem; + player->spinitem = skin->spinitem < 0 ? (UINT32)mobjinfo[MT_PLAYER].damage : (UINT32)skin->spinitem; + player->revitem = skin->revitem < 0 ? (mobjtype_t)mobjinfo[MT_PLAYER].raisestate : (UINT32)skin->revitem; + player->followitem = skin->followitem; - if (server && I_Ban && !I_Ban(node)) // only the server is allowed to do this right now + if (((player->powers[pw_shield] & SH_NOSTACK) == SH_PINK) && (player->revitem == MT_LHRT || player->spinitem == MT_LHRT || player->thokitem == MT_LHRT)) // Healers can't keep their buff. + player->powers[pw_shield] &= SH_STACK; + + player->actionspd = skin->actionspd; + player->mindash = skin->mindash; + player->maxdash = skin->maxdash; + + player->normalspeed = skin->normalspeed; + player->runspeed = skin->runspeed; + player->thrustfactor = skin->thrustfactor; + player->accelstart = skin->accelstart; + player->acceleration = skin->acceleration; + + player->jumpfactor = skin->jumpfactor; + + player->height = skin->height; + player->spinheight = skin->spinheight; + + if (!(cv_debug || devparm) && !(netgame || multiplayer || demoplayback)) { - CONS_Alert(CONS_WARNING, M_GetText("Too many bans! Geez, that's a lot of people you're excluding...\n")); - WRITEUINT8(p, KICK_MSG_GO_AWAY); - SendNetXCmd(XD_KICK, &buf, 2); + if (playernum == consoleplayer) + CV_StealthSetValue(&cv_playercolor, skin->prefcolor); + else if (playernum == secondarydisplayplayer) + CV_StealthSetValue(&cv_playercolor2, skin->prefcolor); + player->skincolor = newcolor = skin->prefcolor; + if (player->bot && botingame) + { + botskin = (UINT8)(skinnum + 1); + botcolor = skin->prefcolor; + } } - else + + if (player->followmobj) { - if (server) // only the server is allowed to do this right now + P_RemoveMobj(player->followmobj); + P_SetTarget(&player->followmobj, NULL); + } + + if (player->mo) + { + fixed_t radius = FixedMul(skin->radius, player->mo->scale); + if ((player->powers[pw_carry] == CR_NIGHTSMODE) && (skin->sprites[SPR2_NFLY].numframes == 0)) // If you don't have a sprite for flying horizontally, use the default NiGHTS skin. { - Ban_Add(COM_Argv(2)); - D_SaveBan(); // save the ban list + skin = &skins[DEFAULTNIGHTSSKIN]; + player->followitem = skin->followitem; + if (!(cv_debug || devparm) && !(netgame || multiplayer || demoplayback)) + newcolor = skin->prefcolor; // will be updated in thinker to flashing + } + player->mo->skin = skin; + if (newcolor) + player->mo->color = newcolor; + P_SetScale(player->mo, player->mo->scale); + player->mo->radius = radius; + + P_SetPlayerMobjState(player->mo, player->mo->state-states); // Prevent visual errors when switching between skins with differing number of frames + } + return; + } + + if (P_IsLocalPlayer(player)) + CONS_Alert(CONS_WARNING, M_GetText("Requested skin %d not found\n"), skinnum); + else if(server || IsPlayerAdmin(consoleplayer)) + CONS_Alert(CONS_WARNING, "Player %d (%s) skin %d not found\n", playernum, player_names[playernum], skinnum); + SetPlayerSkinByNum(playernum, 0); // not found put the sonic skin +} + +// +// Add skins from a pwad, each skin preceded by 'S_SKIN' marker +// + +// Does the same is in w_wad, but check only for +// the first 6 characters (this is so we can have S_SKIN1, S_SKIN2.. +// for wad editors that don't like multiple resources of the same name) +// +static UINT16 W_CheckForSkinMarkerInPwad(UINT16 wadid, UINT16 startlump) +{ + UINT16 i; + const char *S_SKIN = "S_SKIN"; + lumpinfo_t *lump_p; + + // scan forward, start at + if (startlump < wadfiles[wadid]->numlumps) + { + lump_p = wadfiles[wadid]->lumpinfo + startlump; + for (i = startlump; i < wadfiles[wadid]->numlumps; i++, lump_p++) + if (memcmp(lump_p->name,S_SKIN,6)==0) + return i; + } + return INT16_MAX; // not found +} + +#define HUDNAMEWRITE(value) STRBUFCPY(skin->hudname, value) + +// turn _ into spaces and . into katana dot +#define SYMBOLCONVERT(name) for (value = name; *value; value++)\ + {\ + if (*value == '_') *value = ' ';\ + else if (*value == '.') *value = '\x1E';\ + } + +// +// Patch skins from a pwad, each skin preceded by 'P_SKIN' marker +// + +// Does the same is in w_wad, but check only for +// the first 6 characters (this is so we can have P_SKIN1, P_SKIN2.. +// for wad editors that don't like multiple resources of the same name) +// +static UINT16 W_CheckForPatchSkinMarkerInPwad(UINT16 wadid, UINT16 startlump) +{ + UINT16 i; + const char *P_SKIN = "P_SKIN"; + lumpinfo_t *lump_p; + + // scan forward, start at + if (startlump < wadfiles[wadid]->numlumps) + { + lump_p = wadfiles[wadid]->lumpinfo + startlump; + for (i = startlump; i < wadfiles[wadid]->numlumps; i++, lump_p++) + if (memcmp(lump_p->name,P_SKIN,6)==0) + return i; + } + return INT16_MAX; // not found +} + +static void R_LoadSkinSprites(UINT16 wadnum, UINT16 *lump, UINT16 *lastlump, skin_t *skin) +{ + UINT16 newlastlump; + UINT8 sprite2; + + *lump += 1; // start after S_SKIN + *lastlump = W_CheckNumForNamePwad("S_END",wadnum,*lump); // stop at S_END + + // old wadding practices die hard -- stop at S_SKIN (or P_SKIN) or S_START if they come before S_END. + newlastlump = W_CheckForSkinMarkerInPwad(wadnum,*lump); + if (newlastlump < *lastlump) *lastlump = newlastlump; + newlastlump = W_CheckForPatchSkinMarkerInPwad(wadnum,*lump); + if (newlastlump < *lastlump) *lastlump = newlastlump; + newlastlump = W_CheckNumForNamePwad("S_START",wadnum,*lump); + if (newlastlump < *lastlump) *lastlump = newlastlump; + + // ...and let's handle super, too + newlastlump = W_CheckNumForNamePwad("S_SUPER",wadnum,*lump); + if (newlastlump < *lastlump) + { + newlastlump++; + // load all sprite sets we are aware of... for super! + for (sprite2 = 0; sprite2 < free_spr2; sprite2++) + R_AddSingleSpriteDef(spr2names[sprite2], &skin->sprites[FF_SPR2SUPER|sprite2], wadnum, newlastlump, *lastlump); + + newlastlump--; + *lastlump = newlastlump; // okay, make the normal sprite set loading end there + } + + // load all sprite sets we are aware of... for normal stuff. + for (sprite2 = 0; sprite2 < free_spr2; sprite2++) + R_AddSingleSpriteDef(spr2names[sprite2], &skin->sprites[sprite2], wadnum, *lump, *lastlump); + + if (skin->sprites[0].numframes == 0) + I_Error("R_LoadSkinSprites: no frames found for sprite SPR2_%s\n", spr2names[0]); +} + +// returns whether found appropriate property +static boolean R_ProcessPatchableFields(skin_t *skin, char *stoken, char *value) +{ + // custom translation table + if (!stricmp(stoken, "startcolor")) + skin->starttranscolor = atoi(value); + +#define FULLPROCESS(field) else if (!stricmp(stoken, #field)) skin->field = get_number(value); + // character type identification + FULLPROCESS(flags) + FULLPROCESS(ability) + FULLPROCESS(ability2) + + FULLPROCESS(thokitem) + FULLPROCESS(spinitem) + FULLPROCESS(revitem) + FULLPROCESS(followitem) +#undef FULLPROCESS + +#define GETFRACBITS(field) else if (!stricmp(stoken, #field)) skin->field = atoi(value)<field = atoi(value); + GETINT(thrustfactor) + GETINT(accelstart) + GETINT(acceleration) + GETINT(contspeed) + GETINT(contangle) +#undef GETINT + +#define GETSKINCOLOR(field) else if (!stricmp(stoken, #field)) \ +{ \ + UINT16 color = R_GetColorByName(value); \ + skin->field = (color ? color : SKINCOLOR_GREEN); \ +} + GETSKINCOLOR(prefcolor) + GETSKINCOLOR(prefoppositecolor) +#undef GETSKINCOLOR + else if (!stricmp(stoken, "supercolor")) + { + UINT16 color = R_GetSuperColorByName(value); + skin->supercolor = (color ? color : SKINCOLOR_SUPERGOLD1); + } + +#define GETFLOAT(field) else if (!stricmp(stoken, #field)) skin->field = FLOAT_TO_FIXED(atof(value)); + GETFLOAT(jumpfactor) + GETFLOAT(highresscale) + GETFLOAT(shieldscale) + GETFLOAT(camerascale) +#undef GETFLOAT + +#define GETFLAG(field) else if (!stricmp(stoken, #field)) { \ + strupr(value); \ + if (atoi(value) || value[0] == 'T' || value[0] == 'Y') \ + skin->flags |= (SF_##field); \ + else \ + skin->flags &= ~(SF_##field); \ +} + // parameters for individual character flags + // these are uppercase so they can be concatenated with SF_ + // 1, true, yes are all valid values + GETFLAG(SUPER) + GETFLAG(NOSUPERSPIN) + GETFLAG(NOSPINDASHDUST) + GETFLAG(HIRES) + GETFLAG(NOSKID) + GETFLAG(NOSPEEDADJUST) + GETFLAG(RUNONWATER) + GETFLAG(NOJUMPSPIN) + GETFLAG(NOJUMPDAMAGE) + GETFLAG(STOMPDAMAGE) + GETFLAG(MARIODAMAGE) + GETFLAG(MACHINE) + GETFLAG(DASHMODE) + GETFLAG(FASTEDGE) + GETFLAG(MULTIABILITY) + GETFLAG(NONIGHTSROTATION) + GETFLAG(NONIGHTSSUPER) +#undef GETFLAG + + else // let's check if it's a sound, otherwise error out + { + boolean found = false; + sfxenum_t i; + size_t stokenadjust; + + // Remove the prefix. (We need to affect an adjusting variable so that we can print error messages if it's not actually a sound.) + if ((stoken[0] == 'D' || stoken[0] == 'd') && (stoken[1] == 'S' || stoken[1] == 's')) // DS* + stokenadjust = 2; + else // sfx_* + stokenadjust = 4; + + // Remove the prefix. (We can affect this directly since we're not going to use it again.) + if ((value[0] == 'D' || value[0] == 'd') && (value[1] == 'S' || value[1] == 's')) // DS* + value += 2; + else // sfx_* + value += 4; + + // copy name of sounds that are remapped + // for this skin + for (i = 0; i < sfx_skinsoundslot0; i++) + { + if (!S_sfx[i].name) + continue; + if (S_sfx[i].skinsound != -1 + && !stricmp(S_sfx[i].name, + stoken + stokenadjust)) + { + skin->soundsid[S_sfx[i].skinsound] = + S_AddSoundFx(value, S_sfx[i].singularity, S_sfx[i].pitch, true); + found = true; + } + } + return found; + } + return true; +} + +// +// Find skin sprites, sounds & optional status bar face, & add them +// +void R_AddSkins(UINT16 wadnum) +{ + UINT16 lump, lastlump = 0; + char *buf; + char *buf2; + char *stoken; + char *value; + size_t size; + skin_t *skin; + boolean hudname, realname; + + // + // search for all skin markers in pwad + // + + while ((lump = W_CheckForSkinMarkerInPwad(wadnum, lastlump)) != INT16_MAX) + { + // advance by default + lastlump = lump + 1; + + if (numskins >= MAXSKINS) + { + CONS_Debug(DBG_RENDER, "ignored skin (%d skins maximum)\n", MAXSKINS); + continue; // so we know how many skins couldn't be added + } + buf = W_CacheLumpNumPwad(wadnum, lump, PU_CACHE); + size = W_LumpLengthPwad(wadnum, lump); + + // for strtok + buf2 = malloc(size+1); + if (!buf2) + I_Error("R_AddSkins: No more free memory\n"); + M_Memcpy(buf2,buf,size); + buf2[size] = '\0'; + + // set defaults + skin = &skins[numskins]; + Sk_SetDefaultValue(skin); + skin->wadnum = wadnum; + hudname = realname = false; + // parse + stoken = strtok (buf2, "\r\n= "); + while (stoken) + { + if ((stoken[0] == '/' && stoken[1] == '/') + || (stoken[0] == '#'))// skip comments + { + stoken = strtok(NULL, "\r\n"); // skip end of line + goto next_token; // find the real next token } - if (COM_Argc() == 2) - { - WRITEUINT8(p, KICK_MSG_BANNED); - SendNetXCmd(XD_KICK, &buf, 2); - } - else - { - size_t i, j = COM_Argc(); - char message[MAX_REASONLENGTH]; + value = strtok(NULL, "\r\n= "); - //Steal from the motd code so you don't have to put the reason in quotes. - strlcpy(message, COM_Argv(2), sizeof message); - for (i = 3; i < j; i++) + if (!value) + I_Error("R_AddSkins: syntax error in S_SKIN lump# %d(%s) in WAD %s\n", lump, W_CheckNameForNumPwad(wadnum,lump), wadfiles[wadnum]->filename); + + // Some of these can't go in R_ProcessPatchableFields because they have side effects for future lines. + // Others can't go in there because we don't want them to be patchable. + if (!stricmp(stoken, "name")) + { + INT32 skinnum = R_SkinAvailable(value); + strlwr(value); + if (skinnum == -1) + STRBUFCPY(skin->name, value); + // the skin name must uniquely identify a single skin + // if the name is already used I make the name 'namex' + // using the default skin name's number set above + else { - strlcat(message, " ", sizeof message); - strlcat(message, COM_Argv(i), sizeof message); + const size_t stringspace = + strlen(value) + sizeof (numskins) + 1; + char *value2 = Z_Malloc(stringspace, PU_STATIC, NULL); + snprintf(value2, stringspace, + "%s%d", value, numskins); + value2[stringspace - 1] = '\0'; + if (R_SkinAvailable(value2) == -1) + // I'm lazy so if NEW name is already used I leave the 'skin x' + // default skin name set in Sk_SetDefaultValue + STRBUFCPY(skin->name, value2); + Z_Free(value2); } - WRITEUINT8(p, KICK_MSG_CUSTOM_BAN); - WRITESTRINGN(p, message, MAX_REASONLENGTH); - SendNetXCmd(XD_KICK, &buf, p - buf); - } - } - } - else - CONS_Printf(M_GetText("Only the server or a remote admin can use this.\n")); - -} - -static void Command_BanIP(void) -{ - if (COM_Argc() < 2) - { - CONS_Printf(M_GetText("banip : ban an ip address\n")); - return; - } - - if (server) // Only the server can use this, otherwise does nothing. - { - const char *address = (COM_Argv(1)); - const char *reason; - - if (COM_Argc() == 2) - reason = NULL; - else - reason = COM_Argv(2); - - - if (I_SetBanAddress && I_SetBanAddress(address, NULL)) - { - if (reason) - CONS_Printf("Banned IP address %s for: %s\n", address, reason); - else - CONS_Printf("Banned IP address %s\n", address); - - Ban_Add(reason); - D_SaveBan(); - } - else - { - return; - } - } -} - -static void Command_Kick(void) -{ - if (COM_Argc() < 2) - { - CONS_Printf(M_GetText("kick : kick a player\n")); - return; - } - - //if (!netgame) // Don't kick Tails in splitscreen! - //{ - // CONS_Printf(M_GetText("This only works in a netgame.\n")); - // return; - //} - - if (server || IsPlayerAdmin(consoleplayer)) - { - UINT8 buf[3 + MAX_REASONLENGTH]; - UINT8 *p = buf; - const SINT8 pn = nametonum(COM_Argv(1)); - - if (splitscreen && (pn == 0 || pn == 1)) - { - CONS_Printf(M_GetText("Splitscreen players cannot be kicked.\n")); - return; - } - if (pn == -1 || pn == 0) - 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 - if (server && playernode[pn] != UINT8_MAX && sendingsavegame[playernode[pn]]) - { - Net_ConnectionTimeout(playernode[pn]); - return; - } - - WRITESINT8(p, pn); - - if (COM_Argc() == 2) - { - WRITEUINT8(p, KICK_MSG_GO_AWAY); - SendNetXCmd(XD_KICK, &buf, 2); - } - else - { - size_t i, j = COM_Argc(); - char message[MAX_REASONLENGTH]; - - //Steal from the motd code so you don't have to put the reason in quotes. - strlcpy(message, COM_Argv(2), sizeof message); - for (i = 3; i < j; i++) - { - strlcat(message, " ", sizeof message); - strlcat(message, COM_Argv(i), sizeof message); - } - - WRITEUINT8(p, KICK_MSG_CUSTOM_KICK); - WRITESTRINGN(p, message, MAX_REASONLENGTH); - SendNetXCmd(XD_KICK, &buf, p - buf); - } - } - else - CONS_Printf(M_GetText("Only the server or a remote admin can use this.\n")); -} -#endif - -static void Got_KickCmd(UINT8 **p, INT32 playernum) -{ - INT32 pnum, msg; - char buf[3 + MAX_REASONLENGTH]; - char *reason = buf; - kickreason_t kickreason = KR_KICK; - boolean keepbody; - - pnum = READUINT8(*p); - msg = READUINT8(*p); - keepbody = (msg & KICK_MSG_KEEP_BODY) != 0; - msg &= ~KICK_MSG_KEEP_BODY; - - if (pnum == serverplayer && IsPlayerAdmin(playernum)) - { - CONS_Printf(M_GetText("Server is being shut down remotely. Goodbye!\n")); - - if (server) - COM_BufAddText("quit\n"); - - return; - } - - // Is playernum authorized to make this kick? - if (playernum != serverplayer && !IsPlayerAdmin(playernum) - && !(playernode[playernum] != UINT8_MAX && playerpernode[playernode[playernum]] == 2 - && nodetoplayer2[playernode[playernum]] == pnum)) - { - // We received a kick command from someone who isn't the - // server or admin, and who isn't in splitscreen removing - // player 2. Thus, it must be someone with a modified - // binary, trying to kick someone but without having - // authorization. - - // We deal with this by changing the kick reason to - // "consistency failure" and kicking the offending user - // instead. - - // Note: Splitscreen in netgames is broken because of - // this. Only the server has any idea of which players - // are using splitscreen on the same computer, so - // clients cannot always determine if a kick is - // legitimate. - - CONS_Alert(CONS_WARNING, M_GetText("Illegal kick command received from %s for player %d\n"), player_names[playernum], pnum); - - // In debug, print a longer message with more details. - // TODO Callum: Should we translate this? -/* - CONS_Debug(DBG_NETPLAY, - "So, you must be asking, why is this an illegal kick?\n" - "Well, let's take a look at the facts, shall we?\n" - "\n" - "playernum (this is the guy who did it), he's %d.\n" - "pnum (the guy he's trying to kick) is %d.\n" - "playernum's node is %d.\n" - "That node has %d players.\n" - "Player 2 on that node is %d.\n" - "pnum's node is %d.\n" - "That node has %d players.\n" - "Player 2 on that node is %d.\n" - "\n" - "If you think this is a bug, please report it, including all of the details above.\n", - playernum, pnum, - playernode[playernum], playerpernode[playernode[playernum]], - nodetoplayer2[playernode[playernum]], - playernode[pnum], playerpernode[playernode[pnum]], - nodetoplayer2[playernode[pnum]]); -*/ - pnum = playernum; - msg = KICK_MSG_CON_FAIL; - keepbody = true; - } - - //CONS_Printf("\x82%s ", player_names[pnum]); - - // If a verified admin banned someone, the server needs to know about it. - // If the playernum isn't zero (the server) then the server needs to record the ban. - if (server && playernum && (msg == KICK_MSG_BANNED || msg == KICK_MSG_CUSTOM_BAN)) - { - if (I_Ban && !I_Ban(playernode[(INT32)pnum])) - CONS_Alert(CONS_WARNING, M_GetText("Too many bans! Geez, that's a lot of people you're excluding...\n")); -#ifndef NONET - else - Ban_Add(reason); -#endif - } - - switch (msg) - { - case KICK_MSG_GO_AWAY: - if (!players[pnum].quittime) - HU_AddChatText(va("\x82*%s has been kicked (Go away)", player_names[pnum]), false); - kickreason = KR_KICK; - break; - case KICK_MSG_PING_HIGH: - HU_AddChatText(va("\x82*%s left the game (Broke ping limit)", player_names[pnum]), false); - kickreason = KR_PINGLIMIT; - break; - case KICK_MSG_CON_FAIL: - HU_AddChatText(va("\x82*%s left the game (Synch Failure)", player_names[pnum]), false); - kickreason = KR_SYNCH; - - if (M_CheckParm("-consisdump")) // Helps debugging some problems - { - INT32 i; - - CONS_Printf(M_GetText("Player kicked is #%d, dumping consistency...\n"), pnum); - - for (i = 0; i < MAXPLAYERS; i++) + // copy to hudname and fullname as a default. + if (!realname) { - if (!playeringame[i]) - continue; - CONS_Printf("-------------------------------------\n"); - CONS_Printf("Player %d: %s\n", i, player_names[i]); - CONS_Printf("Skin: %d\n", players[i].skin); - CONS_Printf("Color: %d\n", players[i].skincolor); - CONS_Printf("Speed: %d\n",players[i].speed>>FRACBITS); - if (players[i].mo) + STRBUFCPY(skin->realname, skin->name); + for (value = skin->realname; *value; value++) { - if (!players[i].mo->skin) - CONS_Printf("Mobj skin: NULL!\n"); - else - CONS_Printf("Mobj skin: %s\n", ((skin_t *)players[i].mo->skin)->name); - CONS_Printf("Position: %d, %d, %d\n", players[i].mo->x, players[i].mo->y, players[i].mo->z); - if (!players[i].mo->state) - CONS_Printf("State: S_NULL\n"); - else - CONS_Printf("State: %d\n", (statenum_t)(players[i].mo->state-states)); + if (*value == '_') *value = ' '; // turn _ into spaces. + else if (*value == '.') *value = '\x1E'; // turn . into katana dot. } + } + if (!hudname) + { + HUDNAMEWRITE(skin->name); + strupr(skin->hudname); + SYMBOLCONVERT(skin->hudname) + } + } + else if (!stricmp(stoken, "realname")) + { // Display name (eg. "Knuckles") + realname = true; + STRBUFCPY(skin->realname, value); + SYMBOLCONVERT(skin->realname) + if (!hudname) + HUDNAMEWRITE(skin->realname); + } + else if (!stricmp(stoken, "hudname")) + { // Life icon name (eg. "K.T.E") + hudname = true; + HUDNAMEWRITE(value); + SYMBOLCONVERT(skin->hudname) + if (!realname) + STRBUFCPY(skin->realname, skin->hudname); + } + else if (!stricmp(stoken, "availability")) + { + skin->availability = atoi(value); + if (skin->availability >= MAXUNLOCKABLES) + skin->availability = 0; + } + else if (!R_ProcessPatchableFields(skin, stoken, value)) + CONS_Debug(DBG_SETUP, "R_AddSkins: Unknown keyword '%s' in S_SKIN lump #%d (WAD %s)\n", stoken, lump, wadfiles[wadnum]->filename); + +next_token: + stoken = strtok(NULL, "\r\n= "); + } + free(buf2); + + // Add sprites + R_LoadSkinSprites(wadnum, &lump, &lastlump, skin); + //ST_LoadFaceGraphics(numskins); -- nah let's do this elsewhere + + R_FlushTranslationColormapCache(); + + if (!skin->availability) // Safe to print... + CONS_Printf(M_GetText("Added skin '%s'\n"), skin->name); +#ifdef SKINVALUES + skin_cons_t[numskins].value = numskins; + skin_cons_t[numskins].strvalue = skin->name; +#endif + +#ifdef HWRENDER + if (rendermode == render_opengl) + HWR_AddPlayerModel(numskins); +#endif + + numskins++; + } + return; +} + +// +// Patch skin sprites +// +void R_PatchSkins(UINT16 wadnum) +{ + UINT16 lump, lastlump = 0; + char *buf; + char *buf2; + char *stoken; + char *value; + size_t size; + skin_t *skin; + boolean noskincomplain, realname, hudname; + + // + // search for all skin patch markers in pwad + // + + while ((lump = W_CheckForPatchSkinMarkerInPwad(wadnum, lastlump)) != INT16_MAX) + { + INT32 skinnum = 0; + + // advance by default + lastlump = lump + 1; + + buf = W_CacheLumpNumPwad(wadnum, lump, PU_CACHE); + size = W_LumpLengthPwad(wadnum, lump); + + // for strtok + buf2 = malloc(size+1); + if (!buf2) + I_Error("R_PatchSkins: No more free memory\n"); + M_Memcpy(buf2,buf,size); + buf2[size] = '\0'; + + skin = NULL; + noskincomplain = realname = hudname = false; + + /* + Parse. Has more phases than the parser in R_AddSkins because it needs to have the patching name first (no default skin name is acceptible for patching, unlike skin creation) + */ + + stoken = strtok(buf2, "\r\n= "); + while (stoken) + { + if ((stoken[0] == '/' && stoken[1] == '/') + || (stoken[0] == '#'))// skip comments + { + stoken = strtok(NULL, "\r\n"); // skip end of line + goto next_token; // find the real next token + } + + value = strtok(NULL, "\r\n= "); + + if (!value) + I_Error("R_PatchSkins: syntax error in P_SKIN lump# %d(%s) in WAD %s\n", lump, W_CheckNameForNumPwad(wadnum,lump), wadfiles[wadnum]->filename); + + if (!skin) // Get the name! + { + if (!stricmp(stoken, "name")) + { + strlwr(value); + skinnum = R_SkinAvailable(value); + if (skinnum != -1) + skin = &skins[skinnum]; else - CONS_Printf("Mobj: NULL\n"); - CONS_Printf("-------------------------------------\n"); - } - } - break; - case KICK_MSG_TIMEOUT: - HU_AddChatText(va("\x82*%s left the game (Connection timeout)", player_names[pnum]), false); - kickreason = KR_TIMEOUT; - break; - case KICK_MSG_PLAYER_QUIT: - if (netgame && !players[pnum].quittime) // not splitscreen/bots or soulless body - HU_AddChatText(va("\x82*%s left the game", player_names[pnum]), false); - kickreason = KR_LEAVE; - break; - case KICK_MSG_BANNED: - HU_AddChatText(va("\x82*%s has been banned (Don't come back)", player_names[pnum]), false); - kickreason = KR_BAN; - break; - case KICK_MSG_CUSTOM_KICK: - READSTRINGN(*p, reason, MAX_REASONLENGTH+1); - HU_AddChatText(va("\x82*%s has been kicked (%s)", player_names[pnum], reason), false); - kickreason = KR_KICK; - break; - case KICK_MSG_CUSTOM_BAN: - READSTRINGN(*p, reason, MAX_REASONLENGTH+1); - HU_AddChatText(va("\x82*%s has been banned (%s)", player_names[pnum], reason), false); - kickreason = KR_BAN; - break; - } - - if (pnum == consoleplayer) - { - if (Playing()) - LUAh_GameQuit(); -#ifdef DUMPCONSISTENCY - if (msg == KICK_MSG_CON_FAIL) SV_SavedGame(); -#endif - D_QuitNetGame(); - CL_Reset(); - D_StartTitle(); - if (msg == KICK_MSG_CON_FAIL) - M_StartMessage(M_GetText("Server closed connection\n(synch failure)\nPress ESC\n"), NULL, MM_NOTHING); - else if (msg == KICK_MSG_PING_HIGH) - M_StartMessage(M_GetText("Server closed connection\n(Broke ping limit)\nPress ESC\n"), NULL, MM_NOTHING); - else if (msg == KICK_MSG_BANNED) - M_StartMessage(M_GetText("You have been banned by the server\n\nPress ESC\n"), NULL, MM_NOTHING); - else if (msg == KICK_MSG_CUSTOM_KICK) - M_StartMessage(va(M_GetText("You have been kicked\n(%s)\nPress ESC\n"), reason), NULL, MM_NOTHING); - else if (msg == KICK_MSG_CUSTOM_BAN) - M_StartMessage(va(M_GetText("You have been banned\n(%s)\nPress ESC\n"), reason), NULL, MM_NOTHING); - else - M_StartMessage(M_GetText("You have been kicked by the server\n\nPress ESC\n"), NULL, MM_NOTHING); - } - else if (keepbody) - { - if (server && !demoplayback && playernode[pnum] != UINT8_MAX) - { - INT32 node = playernode[pnum]; - playerpernode[node]--; - if (playerpernode[node] <= 0) - { - nodeingame[node] = false; - Net_CloseConnection(node); - ResetNode(node); - } - } - - playernode[pnum] = UINT8_MAX; - - players[pnum].quittime = 1; - } - else - CL_RemovePlayer(pnum, kickreason); -} - -static void Command_ResendGamestate(void) -{ - SINT8 playernum; - - if (COM_Argc() == 1) - { - CONS_Printf(M_GetText("resendgamestate : resend the game state to a player\n")); - return; - } - else if (client) - { - CONS_Printf(M_GetText("Only the server can use this.\n")); - return; - } - - playernum = nametonum(COM_Argv(1)); - if (playernum == -1 || playernum == 0) - return; - - // Send a PT_WILLRESENDGAMESTATE packet to the client so they know what's going on - netbuffer->packettype = PT_WILLRESENDGAMESTATE; - if (!HSendPacket(playernode[playernum], true, 0, 0)) - { - CONS_Alert(CONS_ERROR, M_GetText("A problem occured, please try again.\n")); - return; - } -} - -static CV_PossibleValue_t netticbuffer_cons_t[] = {{0, "MIN"}, {3, "MAX"}, {0, NULL}}; -consvar_t cv_netticbuffer = CVAR_INIT ("netticbuffer", "1", CV_SAVE, netticbuffer_cons_t, NULL); - -consvar_t cv_allownewplayer = CVAR_INIT ("allowjoin", "On", CV_SAVE|CV_NETVAR, CV_OnOff, NULL); -consvar_t cv_joinnextround = CVAR_INIT ("joinnextround", "Off", CV_SAVE|CV_NETVAR, CV_OnOff, NULL); /// \todo not done -static CV_PossibleValue_t maxplayers_cons_t[] = {{2, "MIN"}, {32, "MAX"}, {0, NULL}}; -consvar_t cv_maxplayers = CVAR_INIT ("maxplayers", "8", CV_SAVE|CV_NETVAR, maxplayers_cons_t, NULL); -static CV_PossibleValue_t joindelay_cons_t[] = {{1, "MIN"}, {3600, "MAX"}, {0, "Off"}, {0, NULL}}; -consvar_t cv_joindelay = CVAR_INIT ("joindelay", "10", CV_SAVE|CV_NETVAR, joindelay_cons_t, NULL); -static CV_PossibleValue_t rejointimeout_cons_t[] = {{1, "MIN"}, {60 * FRACUNIT, "MAX"}, {0, "Off"}, {0, NULL}}; -consvar_t cv_rejointimeout = CVAR_INIT ("rejointimeout", "Off", CV_SAVE|CV_NETVAR|CV_FLOAT, rejointimeout_cons_t, NULL); - -static CV_PossibleValue_t resynchattempts_cons_t[] = {{1, "MIN"}, {20, "MAX"}, {0, "No"}, {0, NULL}}; -consvar_t cv_resynchattempts = CVAR_INIT ("resynchattempts", "10", CV_SAVE|CV_NETVAR, resynchattempts_cons_t, NULL); -consvar_t cv_blamecfail = CVAR_INIT ("blamecfail", "Off", CV_SAVE|CV_NETVAR, CV_OnOff, NULL); - -// max file size to send to a player (in kilobytes) -static CV_PossibleValue_t maxsend_cons_t[] = {{0, "MIN"}, {51200, "MAX"}, {0, NULL}}; -consvar_t cv_maxsend = CVAR_INIT ("maxsend", "4096", CV_SAVE|CV_NETVAR, maxsend_cons_t, NULL); -consvar_t cv_noticedownload = CVAR_INIT ("noticedownload", "Off", CV_SAVE|CV_NETVAR, CV_OnOff, NULL); - -// Speed of file downloading (in packets per tic) -static CV_PossibleValue_t downloadspeed_cons_t[] = {{0, "MIN"}, {32, "MAX"}, {0, NULL}}; -consvar_t cv_downloadspeed = CVAR_INIT ("downloadspeed", "16", CV_SAVE|CV_NETVAR, downloadspeed_cons_t, NULL); - -static void Got_AddPlayer(UINT8 **p, INT32 playernum); - -// called one time at init -void D_ClientServerInit(void) -{ - DEBFILE(va("- - -== SRB2 v%d.%.2d.%d "VERSIONSTRING" debugfile ==- - -\n", - VERSION/100, VERSION%100, SUBVERSION)); - -#ifndef NONET - COM_AddCommand("getplayernum", Command_GetPlayerNum); - COM_AddCommand("kick", Command_Kick); - COM_AddCommand("ban", Command_Ban); - COM_AddCommand("banip", Command_BanIP); - COM_AddCommand("clearbans", Command_ClearBans); - COM_AddCommand("showbanlist", Command_ShowBan); - COM_AddCommand("reloadbans", Command_ReloadBan); - COM_AddCommand("connect", Command_connect); - COM_AddCommand("nodes", Command_Nodes); - COM_AddCommand("resendgamestate", Command_ResendGamestate); -#ifdef PACKETDROP - COM_AddCommand("drop", Command_Drop); - COM_AddCommand("droprate", Command_Droprate); -#endif -#ifdef _DEBUG - COM_AddCommand("numnodes", Command_Numnodes); -#endif -#endif - - RegisterNetXCmd(XD_KICK, Got_KickCmd); - RegisterNetXCmd(XD_ADDPLAYER, Got_AddPlayer); -#ifndef NONET -#ifdef DUMPCONSISTENCY - CV_RegisterVar(&cv_dumpconsistency); -#endif - Ban_Load_File(false); -#endif - - gametic = 0; - localgametic = 0; - - // do not send anything before the real begin - SV_StopServer(); - SV_ResetServer(); - if (dedicated) - SV_SpawnServer(); -} - -static void ResetNode(INT32 node) -{ - nodeingame[node] = false; - nodewaiting[node] = 0; - - nettics[node] = gametic; - supposedtics[node] = gametic; - - nodetoplayer[node] = -1; - nodetoplayer2[node] = -1; - playerpernode[node] = 0; - - sendingsavegame[node] = false; - resendingsavegame[node] = false; - savegameresendcooldown[node] = 0; -} - -void SV_ResetServer(void) -{ - INT32 i; - - // +1 because this command will be executed in com_executebuffer in - // tryruntic so gametic will be incremented, anyway maketic > gametic - // is not an issue - - maketic = gametic + 1; - neededtic = maketic; - tictoclear = maketic; - - joindelay = 0; - - for (i = 0; i < MAXNETNODES; i++) - ResetNode(i); - - for (i = 0; i < MAXPLAYERS; i++) - { - LUA_InvalidatePlayer(&players[i]); - playeringame[i] = false; - playernode[i] = UINT8_MAX; - memset(playeraddress[i], 0, sizeof(*playeraddress)); - sprintf(player_names[i], "Player %d", i + 1); - adminplayers[i] = -1; // Populate the entire adminplayers array with -1. - } - - memset(player_name_changes, 0, sizeof player_name_changes); - - mynode = 0; - cl_packetmissed = false; - cl_redownloadinggamestate = false; - - if (dedicated) - { - nodeingame[0] = true; - serverplayer = 0; - } - else - serverplayer = consoleplayer; - - if (server) - servernode = 0; - - doomcom->numslots = 0; - - // clear server_context - memset(server_context, '-', 8); - - DEBFILE("\n-=-=-=-=-=-=-= Server Reset =-=-=-=-=-=-=-\n\n"); -} - -static inline void SV_GenContext(void) -{ - UINT8 i; - // generate server_context, as exactly 8 bytes of randomly mixed A-Z and a-z - // (hopefully M_Random is initialized!! if not this will be awfully silly!) - for (i = 0; i < 8; i++) - { - const char a = M_RandomKey(26*2); - if (a < 26) // uppercase - server_context[i] = 'A'+a; - else // lowercase - server_context[i] = 'a'+(a-26); - } -} - -// -// D_QuitNetGame -// Called before quitting to leave a net game -// without hanging the other players -// -void D_QuitNetGame(void) -{ - if (!netgame || !netbuffer) - return; - - DEBFILE("===========================================================================\n" - " Quitting Game, closing connection\n" - "===========================================================================\n"); - - // abort send/receive of files - CloseNetFile(); - RemoveAllLuaFileTransfers(); - waitingforluafiletransfer = false; - waitingforluafilecommand = false; - - if (server) - { - INT32 i; - - netbuffer->packettype = PT_SERVERSHUTDOWN; - for (i = 0; i < MAXNETNODES; i++) - if (nodeingame[i]) - HSendPacket(i, true, 0, 0); -#ifdef MASTERSERVER - if (serverrunning && ms_RoomId > 0) - UnregisterServer(); -#endif - } - else if (servernode > 0 && servernode < MAXNETNODES && nodeingame[(UINT8)servernode]) - { - netbuffer->packettype = PT_CLIENTQUIT; - HSendPacket(servernode, true, 0, 0); - } - - D_CloseConnection(); - ClearAdminPlayers(); - - DEBFILE("===========================================================================\n" - " Log finish\n" - "===========================================================================\n"); -#ifdef DEBUGFILE - if (debugfile) - { - fclose(debugfile); - debugfile = NULL; - } -#endif -} - -// Adds a node to the game (player will follow at map change or at savegame....) -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) - nodeingame[node] = true; -} - -// Xcmd XD_ADDPLAYER -static void Got_AddPlayer(UINT8 **p, INT32 playernum) -{ - INT16 node, newplayernum; - boolean splitscreenplayer; - boolean rejoined; - 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 | KICK_MSG_KEEP_BODY); - return; - } - - node = READUINT8(*p); - newplayernum = READUINT8(*p); - splitscreenplayer = newplayernum & 0x80; - newplayernum &= ~0x80; - - rejoined = playeringame[newplayernum]; - - if (!rejoined) - { - // Clear player before joining, lest some things get set incorrectly - // HACK: don't do this for splitscreen, it relies on preset values - if (!splitscreen && !botingame) - CL_ClearPlayer(newplayernum); - playeringame[newplayernum] = true; - G_AddPlayer(newplayernum); - if (newplayernum+1 > doomcom->numslots) - doomcom->numslots = (INT16)(newplayernum+1); - - if (server && I_GetNodeAddress) - { - const char *address = I_GetNodeAddress(node); - char *port = NULL; - if (address) // MI: fix msvcrt.dll!_mbscat crash? - { - strcpy(playeraddress[newplayernum], address); - port = strchr(playeraddress[newplayernum], ':'); - if (port) - *port = '\0'; - } - } - } - - newplayer = &players[newplayernum]; - - newplayer->jointime = 0; - newplayer->quittime = 0; - - READSTRINGN(*p, player_names[newplayernum], MAXPLAYERNAME); - - // the server is creating my player - if (node == mynode) - { - playernode[newplayernum] = 0; // for information only - if (!splitscreenplayer) - { - consoleplayer = newplayernum; - displayplayer = newplayernum; - secondarydisplayplayer = newplayernum; - DEBFILE("spawning me\n"); - ticcmd_oldangleturn[0] = newplayer->oldrelangleturn; - } - else - { - secondarydisplayplayer = newplayernum; - DEBFILE("spawning my brother\n"); - if (botingame) - newplayer->bot = 1; - ticcmd_oldangleturn[1] = newplayer->oldrelangleturn; - } - P_ForceLocalAngle(newplayer, (angle_t)(newplayer->angleturn << 16)); - D_SendPlayerConfig(); - addedtogame = true; - - if (rejoined) - { - if (newplayer->mo) - { - newplayer->viewheight = 41*newplayer->height/48; - - if (newplayer->mo->eflags & MFE_VERTICALFLIP) - newplayer->viewz = newplayer->mo->z + newplayer->mo->height - newplayer->viewheight; - else - newplayer->viewz = newplayer->mo->z + newplayer->viewheight; - } - - // wake up the status bar - ST_Start(); - // wake up the heads up text - HU_Start(); - - if (camera.chase && !splitscreenplayer) - P_ResetCamera(newplayer, &camera); - if (camera2.chase && splitscreenplayer) - P_ResetCamera(newplayer, &camera2); - } - } - - if (netgame) - { - char joinmsg[256]; - - if (rejoined) - strcpy(joinmsg, M_GetText("\x82*%s has rejoined the game (player %d)")); - else - strcpy(joinmsg, M_GetText("\x82*%s has joined the game (player %d)")); - strcpy(joinmsg, va(joinmsg, player_names[newplayernum], newplayernum)); - - // Merge join notification + IP to avoid clogging console/chat - if (server && cv_showjoinaddress.value && I_GetNodeAddress) - { - const char *address = I_GetNodeAddress(node); - if (address) - strcat(joinmsg, va(" (%s)", address)); - } - - HU_AddChatText(joinmsg, false); - } - - if (server && multiplayer && motd[0] != '\0') - COM_BufAddText(va("sayto %d %s\n", newplayernum, motd)); - - if (!rejoined) - LUAh_PlayerJoin(newplayernum); -} - -static boolean SV_AddWaitingPlayers(const char *name, const char *name2) -{ - INT32 node, n, newplayer = false; - UINT8 buf[2 + MAXPLAYERNAME]; - UINT8 *p; - INT32 newplayernum; - - for (node = 0; node < MAXNETNODES; node++) - { - // splitscreen can allow 2 player in one node - for (; nodewaiting[node] > 0; nodewaiting[node]--) - { - newplayer = true; - - newplayernum = FindRejoinerNum(node); - if (newplayernum == -1) - { - // search for a free playernum - // we can't 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) - break; - if (n == MAXNETNODES) - break; - } - } - - // should never happen since we check the playernum - // before accepting the join - I_Assert(newplayernum < MAXPLAYERS); - - playernode[newplayernum] = (UINT8)node; - - p = buf + 2; - buf[0] = (UINT8)node; - buf[1] = newplayernum; - if (playerpernode[node] < 1) - { - nodetoplayer[node] = newplayernum; - WRITESTRINGN(p, name, MAXPLAYERNAME); - } - else - { - nodetoplayer2[node] = newplayernum; - buf[1] |= 0x80; - WRITESTRINGN(p, name2, MAXPLAYERNAME); - } - playerpernode[node]++; - - SendNetXCmd(XD_ADDPLAYER, &buf, p - buf); - - DEBFILE(va("Server added player %d node %d\n", newplayernum, node)); - } - } - - return newplayer; -} - -void CL_AddSplitscreenPlayer(void) -{ - if (cl_mode == CL_CONNECTED) - CL_SendJoin(); -} - -void CL_RemoveSplitscreenPlayer(void) -{ - if (cl_mode != CL_CONNECTED) - return; - - SendKick(secondarydisplayplayer, KICK_MSG_PLAYER_QUIT); -} - -// is there a game running -boolean Playing(void) -{ - return (server && serverrunning) || (client && cl_mode == CL_CONNECTED); -} - -boolean SV_SpawnServer(void) -{ - if (demoplayback) - G_StopDemo(); // reset engine parameter - if (metalplayback) - G_StopMetalDemo(); - - if (!serverrunning) - { - CONS_Printf(M_GetText("Starting Server....\n")); - serverrunning = true; - SV_ResetServer(); - SV_GenContext(); - if (netgame && I_NetOpenSocket) - { - I_NetOpenSocket(); -#ifdef MASTERSERVER - if (ms_RoomId > 0) - RegisterServer(); -#endif - } - - // non dedicated server just connect to itself - if (!dedicated) - CL_ConnectToServer(); - else doomcom->numslots = 1; - } - - return SV_AddWaitingPlayers(cv_playername.zstring, cv_playername2.zstring); -} - -void SV_StopServer(void) -{ - tic_t i; - - if (gamestate == GS_INTERMISSION) - Y_EndIntermission(); - gamestate = wipegamestate = GS_NULL; - - localtextcmd[0] = 0; - localtextcmd2[0] = 0; - - for (i = firstticstosend; i < firstticstosend + BACKUPTICS; i++) - D_Clearticcmd(i); - - consoleplayer = 0; - cl_mode = CL_SEARCHING; - maketic = gametic+1; - neededtic = maketic; - serverrunning = false; -} - -// called at singleplayer start and stopdemo -void SV_StartSinglePlayerServer(void) -{ - server = true; - netgame = false; - multiplayer = false; - G_SetGametype(GT_COOP); - - // no more tic the game with this settings! - SV_StopServer(); - - if (splitscreen) - multiplayer = true; -} - -static void SV_SendRefuse(INT32 node, const char *reason) -{ - strcpy(netbuffer->u.serverrefuse.reason, reason); - - netbuffer->packettype = PT_SERVERREFUSE; - HSendPacket(node, true, 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) -{ - INT32 i; - size_t total = 1; // num of textcmds in the tic (ntextcmd byte) - - for (i = 0; i < MAXPLAYERS; i++) - { - UINT8 *textcmd = D_GetExistingTextcmd(tic, i); - if ((!i || playeringame[i]) && textcmd) - total += 2 + textcmd[0]; // "+2" for size and playernum - } - - return total; -} - -/** Called when a PT_CLIENTJOIN packet is received - * - * \param node The packet sender - * - */ -static void HandleConnect(SINT8 node) -{ - char names[MAXSPLITSCREENPLAYERS][MAXPLAYERNAME + 1]; - INT32 rejoinernum; - INT32 i; - - rejoinernum = FindRejoinerNum(node); - - if (bannednode && bannednode[node]) - SV_SendRefuse(node, M_GetText("You have been banned\nfrom the server.")); - else if (netbuffer->u.clientcfg._255 != 255 || - netbuffer->u.clientcfg.packetversion != PACKETVERSION) - SV_SendRefuse(node, "Incompatible packet formats."); - else if (strncmp(netbuffer->u.clientcfg.application, SRB2APPLICATION, - sizeof netbuffer->u.clientcfg.application)) - SV_SendRefuse(node, "Different SRB2 modifications\nare not compatible."); - else if (netbuffer->u.clientcfg.version != VERSION - || netbuffer->u.clientcfg.subversion != SUBVERSION) - SV_SendRefuse(node, va(M_GetText("Different SRB2 versions cannot\nplay a netgame!\n(server version %d.%d.%d)"), VERSION/100, VERSION%100, SUBVERSION)); - else if (!cv_allownewplayer.value && node && rejoinernum == -1) - SV_SendRefuse(node, M_GetText("The server is not accepting\njoins for the moment.")); - else if (D_NumPlayers() >= cv_maxplayers.value && rejoinernum == -1) - SV_SendRefuse(node, va(M_GetText("Maximum players reached: %d"), cv_maxplayers.value)); - else if (netgame && netbuffer->u.clientcfg.localplayers > 1) // Hacked client? - SV_SendRefuse(node, M_GetText("Too many players from\nthis node.")); - else if (netgame && !netbuffer->u.clientcfg.localplayers) // Stealth join? - SV_SendRefuse(node, M_GetText("No players from\nthis node.")); - else if (luafiletransfers) - SV_SendRefuse(node, M_GetText("The server is broadcasting a file\nrequested by a Lua script.\nPlease wait a bit and then\ntry rejoining.")); - else if (netgame && joindelay > 2 * (tic_t)cv_joindelay.value * TICRATE) - SV_SendRefuse(node, va(M_GetText("Too many people are connecting.\nPlease wait %d seconds and then\ntry rejoining."), - (joindelay - 2 * cv_joindelay.value * TICRATE) / TICRATE)); - else - { -#ifndef NONET - boolean newnode = false; -#endif - - for (i = 0; i < netbuffer->u.clientcfg.localplayers - playerpernode[node]; i++) - { - strlcpy(names[i], netbuffer->u.clientcfg.names[i], MAXPLAYERNAME + 1); - if (!EnsurePlayerNameIsGood(names[i], rejoinernum)) - { - SV_SendRefuse(node, "Bad player name"); - return; - } - } - - // client authorised to join - nodewaiting[node] = (UINT8)(netbuffer->u.clientcfg.localplayers - playerpernode[node]); - if (!nodeingame[node]) - { - gamestate_t backupstate = gamestate; -#ifndef NONET - newnode = true; -#endif - SV_AddNode(node); - - if (cv_joinnextround.value && gameaction == ga_nothing) - G_SetGamestate(GS_WAITINGPLAYERS); - if (!SV_SendServerConfig(node)) - { - G_SetGamestate(backupstate); - /// \note Shouldn't SV_SendRefuse be called before ResetNode? - ResetNode(node); - SV_SendRefuse(node, M_GetText("Server couldn't send info, please try again")); - /// \todo fix this !!! - return; // restart the while - } - //if (gamestate != GS_LEVEL) // GS_INTERMISSION, etc? - // SV_SendPlayerConfigs(node); // send bare minimum player info - G_SetGamestate(backupstate); - DEBFILE("new node joined\n"); - } -#ifndef NONET - if (nodewaiting[node]) - { - if ((gamestate == GS_LEVEL || gamestate == GS_INTERMISSION) && newnode) - { - SV_SendSaveGame(node, false); // send a complete game state - DEBFILE("send savegame\n"); - } - SV_AddWaitingPlayers(names[0], names[1]); - joindelay += cv_joindelay.value * TICRATE; - player_joining = true; - } -#endif - } -} - -/** Called when a PT_SERVERSHUTDOWN packet is received - * - * \param node The packet sender (should be the server) - * - */ -static void HandleShutdown(SINT8 node) -{ - (void)node; - if (Playing()) - LUAh_GameQuit(); - D_QuitNetGame(); - CL_Reset(); - D_StartTitle(); - M_StartMessage(M_GetText("Server has shutdown\n\nPress Esc\n"), NULL, MM_NOTHING); -} - -/** Called when a PT_NODETIMEOUT packet is received - * - * \param node The packet sender (should be the server) - * - */ -static void HandleTimeout(SINT8 node) -{ - (void)node; - if (Playing()) - LUAh_GameQuit(); - D_QuitNetGame(); - CL_Reset(); - D_StartTitle(); - M_StartMessage(M_GetText("Server Timeout\n\nPress Esc\n"), NULL, MM_NOTHING); -} - -#ifndef NONET -/** Called when a PT_SERVERINFO packet is received - * - * \param node The packet sender - * \note What happens if the packet comes from a client or something like that? - * - */ -static void HandleServerInfo(SINT8 node) -{ - // compute ping in ms - const tic_t ticnow = I_GetTime(); - const tic_t ticthen = (tic_t)LONG(netbuffer->u.serverinfo.time); - const tic_t ticdiff = (ticnow - ticthen)*1000/NEWTICRATE; - netbuffer->u.serverinfo.time = (tic_t)LONG(ticdiff); - netbuffer->u.serverinfo.servername[MAXSERVERNAME-1] = 0; - netbuffer->u.serverinfo.application - [sizeof netbuffer->u.serverinfo.application - 1] = '\0'; - netbuffer->u.serverinfo.gametypename - [sizeof netbuffer->u.serverinfo.gametypename - 1] = '\0'; - - SL_InsertServer(&netbuffer->u.serverinfo, node); -} -#endif - -static void PT_WillResendGamestate(void) -{ - char tmpsave[256]; - - if (server || cl_redownloadinggamestate) - return; - - // Send back a PT_CANRECEIVEGAMESTATE packet to the server - // so they know they can start sending the game state - netbuffer->packettype = PT_CANRECEIVEGAMESTATE; - if (!HSendPacket(servernode, true, 0, 0)) - return; - - CONS_Printf(M_GetText("Reloading game state...\n")); - - sprintf(tmpsave, "%s" PATHSEP TMPSAVENAME, srb2home); - - // Don't get a corrupt savegame error because tmpsave already exists - if (FIL_FileExists(tmpsave) && unlink(tmpsave) == -1) - I_Error("Can't delete %s\n", tmpsave); - - CL_PrepareDownloadSaveGame(tmpsave); - - cl_redownloadinggamestate = true; -} - -static void PT_CanReceiveGamestate(SINT8 node) -{ - if (client || sendingsavegame[node]) - return; - - CONS_Printf(M_GetText("Resending game state to %s...\n"), player_names[nodetoplayer[node]]); - - SV_SendSaveGame(node, true); // Resend a complete game state - resendingsavegame[node] = true; -} - -/** Handles a packet received from a node that isn't in game - * - * \param node The packet sender - * \todo Choose a better name, as the packet can also come from the server apparently? - * \sa HandlePacketFromPlayer - * \sa GetPackets - * - */ -static void HandlePacketFromAwayNode(SINT8 node) -{ - if (node != servernode) - DEBFILE(va("Received packet from unknown host %d\n", node)); - -// macro for packets that should only be sent by the server -// if it is NOT from the server, bail out and close the connection! -#define SERVERONLY \ - if (node != servernode) \ - { \ - Net_CloseConnection(node); \ - break; \ - } - switch (netbuffer->packettype) - { - case PT_ASKINFOVIAMS: -#if 0 - if (server && serverrunning) - { - INT32 clientnode; - if (ms_RoomId < 0) // ignore if we're not actually on the MS right now - { - Net_CloseConnection(node); // and yes, close connection - return; - } - clientnode = I_NetMakeNode(netbuffer->u.msaskinfo.clientaddr); - if (clientnode != -1) - { - SV_SendServerInfo(clientnode, (tic_t)LONG(netbuffer->u.msaskinfo.time)); - SV_SendPlayerInfo(clientnode); // Send extra info - Net_CloseConnection(clientnode); - // Don't close connection to MS... - } - else - Net_CloseConnection(node); // ...unless the IP address is not valid - } - else - Net_CloseConnection(node); // you're not supposed to get it, so ignore it -#else - Net_CloseConnection(node); -#endif - break; - - case PT_ASKINFO: - if (server && serverrunning) - { - SV_SendServerInfo(node, (tic_t)LONG(netbuffer->u.askinfo.time)); - SV_SendPlayerInfo(node); // Send extra info - } - Net_CloseConnection(node); - break; - - case PT_SERVERREFUSE: // Negative response of client join request - if (server && serverrunning) - { // But wait I thought I'm the server? - Net_CloseConnection(node); - break; - } - SERVERONLY - if (cl_mode == CL_WAITJOINRESPONSE) - { - // Save the reason so it can be displayed after quitting the netgame - char *reason = strdup(netbuffer->u.serverrefuse.reason); - if (!reason) - I_Error("Out of memory!\n"); - - D_QuitNetGame(); - CL_Reset(); - D_StartTitle(); - - M_StartMessage(va(M_GetText("Server refuses connection\n\nReason:\n%s"), - reason), NULL, MM_NOTHING); - - free(reason); - - // Will be reset by caller. Signals refusal. - cl_mode = CL_ABORTED; - } - break; - - case PT_SERVERCFG: // Positive response of client join request - { - if (server && serverrunning && node != servernode) - { // but wait I thought I'm the server? - Net_CloseConnection(node); - break; - } - SERVERONLY - /// \note how would this happen? and is it doing the right thing if it does? - if (cl_mode != CL_WAITJOINRESPONSE) - break; - - if (client) - { - maketic = gametic = neededtic = (tic_t)LONG(netbuffer->u.servercfg.gametic); - G_SetGametype(netbuffer->u.servercfg.gametype); - modifiedgame = netbuffer->u.servercfg.modifiedgame; - memcpy(server_context, netbuffer->u.servercfg.server_context, 8); - } - - nodeingame[(UINT8)servernode] = true; - serverplayer = netbuffer->u.servercfg.serverplayer; - doomcom->numslots = SHORT(netbuffer->u.servercfg.totalslotnum); - mynode = netbuffer->u.servercfg.clientnode; - if (serverplayer >= 0) - playernode[(UINT8)serverplayer] = servernode; - - if (netgame) -#ifndef NONET - CONS_Printf(M_GetText("Join accepted, waiting for complete game state...\n")); -#else - CONS_Printf(M_GetText("Join accepted, waiting for next level change...\n")); -#endif - DEBFILE(va("Server accept join gametic=%u mynode=%d\n", gametic, mynode)); - -#ifndef NONET - /// \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? - /// Also, according to HandleConnect, the server will send the savegame even during intermission... - if (netbuffer->u.servercfg.gamestate == GS_LEVEL/* || - netbuffer->u.servercfg.gamestate == GS_INTERMISSION*/) - cl_mode = CL_DOWNLOADSAVEGAME; - else -#endif - cl_mode = CL_CONNECTED; - break; - } - - // Handled in d_netfil.c - case PT_FILEFRAGMENT: - if (server) - { // But wait I thought I'm the server? - Net_CloseConnection(node); - break; - } - SERVERONLY - PT_FileFragment(); - break; - - case PT_FILEACK: - if (server) - PT_FileAck(); - break; - - case PT_FILERECEIVED: - if (server) - PT_FileReceived(); - break; - - case PT_REQUESTFILE: - if (server) - { - if (!cv_downloading.value || !PT_RequestFile(node)) - Net_CloseConnection(node); // close connection if one of the requested files could not be sent, or you disabled downloading anyway - } - else - Net_CloseConnection(node); // nope - break; - - case PT_NODETIMEOUT: - case PT_CLIENTQUIT: - if (server) - Net_CloseConnection(node); - break; - - case PT_CLIENTCMD: - break; // This is not an "unknown packet" - - 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); - break; // Ignore it - - } -#undef SERVERONLY -} - -/** Handles a packet received from a node that is in game - * - * \param node The packet sender - * \todo Choose a better name - * \sa HandlePacketFromAwayNode - * \sa GetPackets - * - */ -static void HandlePacketFromPlayer(SINT8 node) -{ - INT32 netconsole; - tic_t realend, realstart; - UINT8 *pak, *txtpak, numtxtpak; -#ifndef NOMD5 - UINT8 finalmd5[16];/* Well, it's the cool thing to do? */ -#endif - - txtpak = NULL; - - if (dedicated && node == 0) - netconsole = 0; - else - netconsole = nodetoplayer[node]; -#ifdef PARANOIA - if (netconsole >= MAXPLAYERS) - I_Error("bad table nodetoplayer: node %d player %d", doomcom->remotenode, netconsole); -#endif - - switch (netbuffer->packettype) - { -// -------------------------------------------- SERVER RECEIVE ---------- - case PT_CLIENTCMD: - case PT_CLIENT2CMD: - case PT_CLIENTMIS: - case PT_CLIENT2MIS: - case PT_NODEKEEPALIVE: - case PT_NODEKEEPALIVEMIS: - if (client) - break; - - // To save bytes, only the low byte of tic numbers are sent - // Use ExpandTics to figure out what the rest of the bytes are - realstart = ExpandTics(netbuffer->u.clientpak.client_tic, node); - realend = ExpandTics(netbuffer->u.clientpak.resendfrom, node); - - if (netbuffer->packettype == PT_CLIENTMIS || netbuffer->packettype == PT_CLIENT2MIS - || netbuffer->packettype == PT_NODEKEEPALIVEMIS - || supposedtics[node] < realend) - { - supposedtics[node] = realend; - } - // Discard out of order packet - if (nettics[node] > realend) - { - DEBFILE(va("out of order ticcmd discarded nettics = %u\n", nettics[node])); - break; - } - - // Update the nettics - nettics[node] = realend; - - // Don't do anything for packets of type NODEKEEPALIVE? - if (netconsole == -1 || netbuffer->packettype == PT_NODEKEEPALIVE - || netbuffer->packettype == PT_NODEKEEPALIVEMIS) - break; - - // As long as clients send valid ticcmds, the server can keep running, so reset the timeout - /// \todo Use a separate cvar for that kind of timeout? - freezetimeout[node] = I_GetTime() + connectiontimeout; - - // Copy ticcmd - G_MoveTiccmd(&netcmds[maketic%BACKUPTICS][netconsole], &netbuffer->u.clientpak.cmd, 1); - - // Check ticcmd for "speed hacks" - if (netcmds[maketic%BACKUPTICS][netconsole].forwardmove > MAXPLMOVE || netcmds[maketic%BACKUPTICS][netconsole].forwardmove < -MAXPLMOVE - || netcmds[maketic%BACKUPTICS][netconsole].sidemove > MAXPLMOVE || netcmds[maketic%BACKUPTICS][netconsole].sidemove < -MAXPLMOVE) - { - CONS_Alert(CONS_WARNING, M_GetText("Illegal movement value received from node %d\n"), netconsole); - //D_Clearticcmd(k); - - SendKick(netconsole, KICK_MSG_CON_FAIL); - break; - } - - // Splitscreen cmd - if ((netbuffer->packettype == PT_CLIENT2CMD || netbuffer->packettype == PT_CLIENT2MIS) - && nodetoplayer2[node] >= 0) - G_MoveTiccmd(&netcmds[maketic%BACKUPTICS][(UINT8)nodetoplayer2[node]], - &netbuffer->u.client2pak.cmd2, 1); - - // Check player consistancy during the level - if (realstart <= gametic && realstart + BACKUPTICS - 1 > gametic && gamestate == GS_LEVEL - && consistancy[realstart%BACKUPTICS] != SHORT(netbuffer->u.clientpak.consistancy) - && !resendingsavegame[node] && savegameresendcooldown[node] <= I_GetTime() - && !SV_ResendingSavegameToAnyone()) - { - if (cv_resynchattempts.value) - { - // Tell the client we are about to resend them the gamestate - netbuffer->packettype = PT_WILLRESENDGAMESTATE; - HSendPacket(node, true, 0, 0); - - resendingsavegame[node] = true; - - if (cv_blamecfail.value) - CONS_Printf(M_GetText("Synch failure for player %d (%s); expected %hd, got %hd\n"), - netconsole+1, player_names[netconsole], - consistancy[realstart%BACKUPTICS], - SHORT(netbuffer->u.clientpak.consistancy)); - DEBFILE(va("Restoring player %d (synch failure) [%update] %d!=%d\n", - netconsole, realstart, consistancy[realstart%BACKUPTICS], - SHORT(netbuffer->u.clientpak.consistancy))); - break; - } - else - { - SendKick(netconsole, KICK_MSG_CON_FAIL | KICK_MSG_KEEP_BODY); - DEBFILE(va("player %d kicked (synch failure) [%u] %d!=%d\n", - netconsole, realstart, consistancy[realstart%BACKUPTICS], - SHORT(netbuffer->u.clientpak.consistancy))); - break; - } - } - break; - case PT_TEXTCMD2: // splitscreen special - netconsole = nodetoplayer2[node]; - /* FALLTHRU */ - case PT_TEXTCMD: - if (client) - break; - - 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); - break; - } - - // 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-BASEPACKETSIZE-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-BASEPACKETSIZE-1), - node, netconsole)); - Net_UnAcknowledgePacket(node); - break; - } - - // 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); - break; - } - - // 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)); - - M_Memcpy(&textcmd[textcmd[0]+1], netbuffer->u.textcmd+1, netbuffer->u.textcmd[0]); - textcmd[0] += (UINT8)netbuffer->u.textcmd[0]; - } - break; - case PT_LOGIN: - if (client) - break; - -#ifndef NOMD5 - if (doomcom->datalength < 16)/* ignore partial sends */ - break; - - if (!adminpasswordset) - { - CONS_Printf(M_GetText("Password from %s failed (no password set).\n"), player_names[netconsole]); - break; - } - - // Do the final pass to compare with the sent md5 - D_MD5PasswordPass(adminpassmd5, 16, va("PNUM%02d", netconsole), &finalmd5); - - if (!memcmp(netbuffer->u.md5sum, finalmd5, 16)) - { - CONS_Printf(M_GetText("%s passed authentication.\n"), player_names[netconsole]); - COM_BufInsertText(va("promote %d\n", netconsole)); // do this immediately - } - else - CONS_Printf(M_GetText("Password from %s failed.\n"), player_names[netconsole]); -#endif - break; - case PT_NODETIMEOUT: - case PT_CLIENTQUIT: - if (client) - break; - - // 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]) - { - UINT8 kickmsg; - - if (netbuffer->packettype == PT_NODETIMEOUT) - kickmsg = KICK_MSG_TIMEOUT; - else - kickmsg = KICK_MSG_PLAYER_QUIT; - kickmsg |= KICK_MSG_KEEP_BODY; - - SendKick(netconsole, kickmsg); - nodetoplayer[node] = -1; - - if (nodetoplayer2[node] != -1 && nodetoplayer2[node] >= 0 - && playeringame[(UINT8)nodetoplayer2[node]]) - { - SendKick(nodetoplayer2[node], kickmsg); - nodetoplayer2[node] = -1; - } - } - Net_CloseConnection(node); - nodeingame[node] = false; - break; - case PT_CANRECEIVEGAMESTATE: - PT_CanReceiveGamestate(node); - break; - case PT_ASKLUAFILE: - if (server && luafiletransfers && luafiletransfers->nodestatus[node] == LFTNS_ASKED) - AddLuaFileToSendQueue(node, luafiletransfers->realfilename); - break; - case PT_HASLUAFILE: - if (server && luafiletransfers && luafiletransfers->nodestatus[node] == LFTNS_SENDING) - SV_HandleLuaFileSent(node); - break; - case PT_RECEIVEDGAMESTATE: - sendingsavegame[node] = false; - resendingsavegame[node] = false; - savegameresendcooldown[node] = I_GetTime() + 15 * TICRATE; - break; -// -------------------------------------------- CLIENT RECEIVE ---------- - case PT_SERVERTICS: - // Only accept PT_SERVERTICS from the server. - if (node != servernode) - { - CONS_Alert(CONS_WARNING, M_GetText("%s received from non-host %d\n"), "PT_SERVERTICS", node); - if (server) - SendKick(netconsole, KICK_MSG_CON_FAIL | KICK_MSG_KEEP_BODY); - break; - } - - realstart = netbuffer->u.serverpak.starttic; - realend = realstart + netbuffer->u.serverpak.numtics; - - if (!txtpak) - txtpak = (UINT8 *)&netbuffer->u.serverpak.cmds[netbuffer->u.serverpak.numslots - * netbuffer->u.serverpak.numtics]; - - if (realend > gametic + CLIENTBACKUPTICS) - realend = gametic + CLIENTBACKUPTICS; - cl_packetmissed = realstart > neededtic; - - if (realstart <= neededtic && realend > neededtic) - { - tic_t i, j; - pak = (UINT8 *)&netbuffer->u.serverpak.cmds; - - for (i = realstart; i < realend; i++) - { - // clear first - D_Clearticcmd(i); - - // copy the tics - pak = G_ScpyTiccmd(netcmds[i%BACKUPTICS], pak, - netbuffer->u.serverpak.numslots*sizeof (ticcmd_t)); - - // copy the textcmds - numtxtpak = *txtpak++; - for (j = 0; j < numtxtpak; j++) { - INT32 k = *txtpak++; // playernum - const size_t txtsize = txtpak[0]+1; - - if (i >= gametic) // Don't copy old net commands - M_Memcpy(D_GetTextcmd(i, k), txtpak, txtsize); - txtpak += txtsize; - } - } - - neededtic = realend; - } - else - { - DEBFILE(va("frame not in bound: %u\n", neededtic)); - /*if (realend < neededtic - 2 * TICRATE || neededtic + 2 * TICRATE < realstart) - I_Error("Received an out of order PT_SERVERTICS packet!\n" - "Got tics %d-%d, needed tic %d\n\n" - "Please report this crash on the Master Board,\n" - "IRC or Discord so it can be fixed.\n", (INT32)realstart, (INT32)realend, (INT32)neededtic);*/ - } - break; - case PT_PING: - // Only accept PT_PING from the server. - if (node != servernode) - { - CONS_Alert(CONS_WARNING, M_GetText("%s received from non-host %d\n"), "PT_PING", node); - if (server) - SendKick(netconsole, KICK_MSG_CON_FAIL | KICK_MSG_KEEP_BODY); - break; - } - - //Update client ping table from the server. - if (client) - { - UINT8 i; - for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i]) - playerpingtable[i] = (tic_t)netbuffer->u.pingtable[i]; - - servermaxping = (tic_t)netbuffer->u.pingtable[MAXPLAYERS]; - } - - break; - case PT_SERVERCFG: - break; - case PT_FILEFRAGMENT: - // Only accept PT_FILEFRAGMENT from the server. - if (node != servernode) - { - CONS_Alert(CONS_WARNING, M_GetText("%s received from non-host %d\n"), "PT_FILEFRAGMENT", node); - if (server) - SendKick(netconsole, KICK_MSG_CON_FAIL | KICK_MSG_KEEP_BODY); - break; - } - if (client) - PT_FileFragment(); - break; - case PT_FILEACK: - if (server) - PT_FileAck(); - break; - case PT_FILERECEIVED: - if (server) - PT_FileReceived(); - break; - case PT_WILLRESENDGAMESTATE: - PT_WillResendGamestate(); - break; - case PT_SENDINGLUAFILE: - if (client) - CL_PrepareDownloadLuaFile(); - break; - default: - DEBFILE(va("UNKNOWN PACKET TYPE RECEIVED %d from host %d\n", - netbuffer->packettype, node)); - } // end switch -} - -/** Handles all received packets, if any - * - * \todo Add details to this description (lol) - * - */ -static void GetPackets(void) -{ - SINT8 node; // The packet sender - - player_joining = false; - - while (HGetPacket()) - { - node = (SINT8)doomcom->remotenode; - - if (netbuffer->packettype == PT_CLIENTJOIN && server) - { - HandleConnect(node); - continue; - } - if (node == servernode && client && cl_mode != CL_SEARCHING) - { - if (netbuffer->packettype == PT_SERVERSHUTDOWN) - { - HandleShutdown(node); - continue; - } - if (netbuffer->packettype == PT_NODETIMEOUT) - { - HandleTimeout(node); - continue; - } - } - -#ifndef NONET - if (netbuffer->packettype == PT_SERVERINFO) - { - HandleServerInfo(node); - continue; - } -#endif - - if (netbuffer->packettype == PT_PLAYERINFO) - continue; // We do nothing with PLAYERINFO, that's for the MS browser. - - // Packet received from someone already playing - if (nodeingame[node]) - HandlePacketFromPlayer(node); - // Packet received from someone not playing - else - HandlePacketFromAwayNode(node); - } -} - -// -// NetUpdate -// Builds ticcmds for console player, -// sends out a packet -// -// no more use random generator, because at very first tic isn't yet synchronized -// Note: It is called consistAncy on purpose. -// -static INT16 Consistancy(void) -{ - INT32 i; - UINT32 ret = 0; -#ifdef MOBJCONSISTANCY - thinker_t *th; - mobj_t *mo; -#endif - - DEBFILE(va("TIC %u ", gametic)); - - for (i = 0; i < MAXPLAYERS; i++) - { - if (!playeringame[i]) - ret ^= 0xCCCC; - else if (!players[i].mo); - else - { - ret += players[i].mo->x; - ret -= players[i].mo->y; - ret += players[i].powers[pw_shield]; - ret *= i+1; - } - } - // I give up - // Coop desynching enemies is painful - if (!G_PlatformGametype()) - ret += P_GetRandSeed(); - -#ifdef MOBJCONSISTANCY - for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next) - { - if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) - continue; - - mo = (mobj_t *)th; - - if (mo->flags & (MF_SPECIAL | MF_SOLID | MF_PUSHABLE | MF_BOSS | MF_MISSILE | MF_SPRING | MF_MONITOR | MF_FIRE | MF_ENEMY | MF_PAIN | MF_STICKY)) - { - ret -= mo->type; - ret += mo->x; - ret -= mo->y; - ret += mo->z; - ret -= mo->momx; - ret += mo->momy; - ret -= mo->momz; - ret += mo->angle; - ret -= mo->flags; - ret += mo->flags2; - ret -= mo->eflags; - if (mo->target) - { - ret += mo->target->type; - ret -= mo->target->x; - ret += mo->target->y; - ret -= mo->target->z; - ret += mo->target->momx; - ret -= mo->target->momy; - ret += mo->target->momz; - ret -= mo->target->angle; - ret += mo->target->flags; - ret -= mo->target->flags2; - ret += mo->target->eflags; - ret -= mo->target->state - states; - ret += mo->target->tics; - ret -= mo->target->sprite; - ret += mo->target->frame; - } - else - ret ^= 0x3333; - if (mo->tracer && mo->tracer->type != MT_OVERLAY) - { - ret += mo->tracer->type; - ret -= mo->tracer->x; - ret += mo->tracer->y; - ret -= mo->tracer->z; - ret += mo->tracer->momx; - ret -= mo->tracer->momy; - ret += mo->tracer->momz; - ret -= mo->tracer->angle; - ret += mo->tracer->flags; - ret -= mo->tracer->flags2; - ret += mo->tracer->eflags; - ret -= mo->tracer->state - states; - ret += mo->tracer->tics; - ret -= mo->tracer->sprite; - ret += mo->tracer->frame; - } - else - ret ^= 0xAAAA; - ret -= mo->state - states; - ret += mo->tics; - ret -= mo->sprite; - ret += mo->frame; - } - } -#endif - - DEBFILE(va("Consistancy = %u\n", (ret & 0xFFFF))); - - return (INT16)(ret & 0xFFFF); -} - -// send the client packet to the server -static void CL_SendClientCmd(void) -{ - size_t packetsize = 0; - - netbuffer->packettype = PT_CLIENTCMD; - - if (cl_packetmissed) - netbuffer->packettype++; - 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 += 4; - packetsize = sizeof (clientcmd_pak) - sizeof (ticcmd_t) - sizeof (INT16); - HSendPacket(servernode, false, 0, packetsize); - } - else if (gamestate != GS_NULL && (addedtogame || dedicated)) - { - G_MoveTiccmd(&netbuffer->u.clientpak.cmd, &localcmds, 1); - netbuffer->u.clientpak.consistancy = SHORT(consistancy[gametic%BACKUPTICS]); - - // Send a special packet with 2 cmd for splitscreen - if (splitscreen || botingame) - { - netbuffer->packettype += 2; - G_MoveTiccmd(&netbuffer->u.client2pak.cmd2, &localcmds2, 1); - packetsize = sizeof (client2cmd_pak); - } - else - packetsize = sizeof (clientcmd_pak); - - HSendPacket(servernode, false, 0, packetsize); - } - - if (cl_mode == CL_CONNECTED || dedicated) - { - // Send extra data if needed - if (localtextcmd[0]) - { - netbuffer->packettype = PT_TEXTCMD; - M_Memcpy(netbuffer->u.textcmd,localtextcmd, localtextcmd[0]+1); - // All extra data have been sent - if (HSendPacket(servernode, true, 0, localtextcmd[0]+1)) // Send can fail... - localtextcmd[0] = 0; - } - - // Send extra data if needed for player 2 (splitscreen) - if (localtextcmd2[0]) - { - netbuffer->packettype = PT_TEXTCMD2; - M_Memcpy(netbuffer->u.textcmd, localtextcmd2, localtextcmd2[0]+1); - // All extra data have been sent - if (HSendPacket(servernode, true, 0, localtextcmd2[0]+1)) // Send can fail... - localtextcmd2[0] = 0; - } - } -} - -// send the server packet -// send tic from firstticstosend to maketic-1 -static void SV_SendTics(void) -{ - tic_t realfirsttic, lasttictosend, i; - UINT32 n; - INT32 j; - size_t packsize; - UINT8 *bufpos; - UINT8 *ntextcmd; - - // 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 - for (n = 1; n < MAXNETNODES; n++) - if (nodeingame[n]) - { - // assert supposedtics[n]>=nettics[n] - realfirsttic = supposedtics[n]; - lasttictosend = min(maketic, nettics[n] + CLIENTBACKUPTICS); - - if (realfirsttic >= lasttictosend) - { - // well we have sent all tics we will so use extrabandwidth - // 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, maketic, supposedtics[n], nettics[n])); - realfirsttic = nettics[n]; - if (realfirsttic >= lasttictosend || (I_GetTime() + n)&3) - // all tic are ok - continue; - DEBFILE(va("Sent %d anyway\n", realfirsttic)); - } - if (realfirsttic < firstticstosend) - realfirsttic = firstticstosend; - - // compute the length of the packet and cut it if too large - packsize = BASESERVERTICSSIZE; - for (i = realfirsttic; i < lasttictosend; i++) - { - packsize += sizeof (ticcmd_t) * doomcom->numslots; - packsize += TotalTextCmdPerTic(i); - - if (packsize > software_MAXPACKETLENGTH) - { - DEBFILE(va("packet too large (%s) at tic %d (should be from %d to %d)\n", - sizeu1(packsize), i, realfirsttic, lasttictosend)); - lasttictosend = i; - - // too bad: too much player have send extradata and there is too - // much data in one tic. - // To avoid it put the data on the next tic. (see getpacket - // textcmd case) but when numplayer changes the computation can be different - if (lasttictosend == realfirsttic) - { - if (packsize > MAXPACKETLENGTH) - I_Error("Too many players: can't send %s data for %d players to node %d\n" - "Well sorry nobody is perfect....\n", - sizeu1(packsize), doomcom->numslots, n); - else - { - lasttictosend++; // send it anyway! - DEBFILE("sending it anyway\n"); - } - } - break; - } - } - - // Send the tics - netbuffer->packettype = PT_SERVERTICS; - netbuffer->u.serverpak.starttic = realfirsttic; - netbuffer->u.serverpak.numtics = (UINT8)(lasttictosend - realfirsttic); - netbuffer->u.serverpak.numslots = (UINT8)SHORT(doomcom->numslots); - bufpos = (UINT8 *)&netbuffer->u.serverpak.cmds; - - for (i = realfirsttic; i < lasttictosend; i++) - { - bufpos = G_DcpyTiccmd(bufpos, netcmds[i%BACKUPTICS], doomcom->numslots * sizeof (ticcmd_t)); - } - - // add textcmds - for (i = realfirsttic; i < lasttictosend; i++) - { - ntextcmd = bufpos++; - *ntextcmd = 0; - for (j = 0; j < MAXPLAYERS; j++) - { - UINT8 *textcmd = D_GetExistingTextcmd(i, j); - INT32 size = textcmd ? textcmd[0] : 0; - - if ((!j || playeringame[j]) && size) - { - (*ntextcmd)++; - WRITEUINT8(bufpos, j); - M_Memcpy(bufpos, textcmd, size + 1); - bufpos += size + 1; + CONS_Debug(DBG_SETUP, "R_PatchSkins: unknown skin name in P_SKIN lump# %d(%s) in WAD %s\n", lump, W_CheckNameForNumPwad(wadnum,lump), wadfiles[wadnum]->filename); + noskincomplain = true; } } } - packsize = bufpos - (UINT8 *)&(netbuffer->u); + else // Get the properties! + { + // Some of these can't go in R_ProcessPatchableFields because they have side effects for future lines. + if (!stricmp(stoken, "realname")) + { // Display name (eg. "Knuckles") + realname = true; + STRBUFCPY(skin->realname, value); + SYMBOLCONVERT(skin->realname) + if (!hudname) + HUDNAMEWRITE(skin->realname); + } + else if (!stricmp(stoken, "hudname")) + { // Life icon name (eg. "K.T.E") + hudname = true; + HUDNAMEWRITE(value); + SYMBOLCONVERT(skin->hudname) + if (!realname) + STRBUFCPY(skin->realname, skin->hudname); + } + else if (!R_ProcessPatchableFields(skin, stoken, value)) + CONS_Debug(DBG_SETUP, "R_PatchSkins: Unknown keyword '%s' in P_SKIN lump #%d (WAD %s)\n", stoken, lump, wadfiles[wadnum]->filename); + } - 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; - if (supposedtics[n] < nettics[n]) supposedtics[n] = nettics[n]; + if (!skin) + break; + +next_token: + stoken = strtok(NULL, "\r\n= "); } - // node 0 is me! - supposedtics[0] = maketic; -} + free(buf2); -// -// TryRunTics -// -static void Local_Maketic(INT32 realtics) -{ - I_OsPolling(); // I_Getevent - D_ProcessEvents(); // menu responder, cons responder, - // game responder calls HU_Responder, AM_Responder, - // and G_MapEventsToControls - if (!dedicated) rendergametic = gametic; - // translate inputs (keyboard/mouse/joystick) into game controls - G_BuildTiccmd(&localcmds, realtics, 1); - if (splitscreen || botingame) - G_BuildTiccmd(&localcmds2, realtics, 2); - - localcmds.angleturn |= TICCMD_RECEIVED; - localcmds2.angleturn |= TICCMD_RECEIVED; -} - -// create missed tic -static void SV_Maketic(void) -{ - INT32 i; - - for (i = 0; i < MAXPLAYERS; i++) - { - if (!playeringame[i]) + if (!skin) // Didn't include a name parameter? What a waste. + { + if (!noskincomplain) + CONS_Debug(DBG_SETUP, "R_PatchSkins: no skin name given in P_SKIN lump #%d (WAD %s)\n", lump, wadfiles[wadnum]->filename); continue; - - // We didn't receive this tic - if ((netcmds[maketic % BACKUPTICS][i].angleturn & TICCMD_RECEIVED) == 0) - { - ticcmd_t * ticcmd = &netcmds[(maketic ) % BACKUPTICS][i]; - ticcmd_t *prevticcmd = &netcmds[(maketic - 1) % BACKUPTICS][i]; - - if (players[i].quittime) - { - // Copy the angle/aiming from the previous tic - // and empty the other inputs - memset(ticcmd, 0, sizeof(netcmds[0][0])); - ticcmd->angleturn = prevticcmd->angleturn | TICCMD_RECEIVED; - ticcmd->aiming = prevticcmd->aiming; - } - else - { - DEBFILE(va("MISS tic%4d for player %d\n", maketic, i)); - // Copy the input from the previous tic - *ticcmd = *prevticcmd; - ticcmd->angleturn &= ~TICCMD_RECEIVED; - } - } - } - - // all tic are now proceed make the next - maketic++; -} - -void TryRunTics(tic_t realtics) -{ - // the machine has lagged but it is not so bad - if (realtics > TICRATE/7) // FIXME: consistency failure!! - { - if (server) - realtics = 1; - else - realtics = TICRATE/7; - } - - if (singletics) - realtics = 1; - - if (realtics >= 1) - { - COM_BufTicker(); - if (mapchangepending) - D_MapChange(-1, 0, ultimatemode, false, 2, false, fromlevelselect); // finish the map change - } - - NetUpdate(); - - if (demoplayback) - { - neededtic = gametic + (realtics * cv_playbackspeed.value); - // start a game after a demo - maketic += realtics; - firstticstosend = maketic; - tictoclear = firstticstosend; - } - - GetPackets(); - -#ifdef DEBUGFILE - if (debugfile && (realtics || neededtic > gametic)) - { - //SoM: 3/30/2000: Need long INT32 in the format string for args 4 & 5. - //Shut up stupid warning! - fprintf(debugfile, "------------ Tryruntic: REAL:%d NEED:%d GAME:%d LOAD: %d\n", - realtics, neededtic, gametic, debugload); - debugload = 100000; - } -#endif - - if (player_joining) - return; - - if (neededtic > gametic) - { - if (advancedemo) - { - if (timedemo_quit) - COM_ImmedExecute("quit"); - else - D_StartTitle(); - } - else - // run the count * tics - while (neededtic > gametic) - { - DEBFILE(va("============ Running tic %d (local %d)\n", gametic, localgametic)); - - ps_tictime = I_GetTimeMicros(); - - G_Ticker((gametic % NEWTICRATERATIO) == 0); - ExtraDataTicker(); - gametic++; - consistancy[gametic%BACKUPTICS] = Consistancy(); - - ps_tictime = I_GetTimeMicros() - ps_tictime; - - // Leave a certain amount of tics present in the net buffer as long as we've ran at least one tic this frame. - if (client && gamestate == GS_LEVEL && leveltime > 3 && neededtic <= gametic + cv_netticbuffer.value) - break; - } - } -} - -/* -Ping Update except better: -We call this once per second and check for people's pings. If their ping happens to be too high, we increment some timer and kick them out. -If they're not lagging, decrement the timer by 1. Of course, reset all of this if they leave. -*/ - -static INT32 pingtimeout[MAXPLAYERS]; - -static inline void PingUpdate(void) -{ - INT32 i; - boolean laggers[MAXPLAYERS]; - UINT8 numlaggers = 0; - memset(laggers, 0, sizeof(boolean) * MAXPLAYERS); - - netbuffer->packettype = PT_PING; - - //check for ping limit breakage. - if (cv_maxping.value) - { - for (i = 1; i < MAXPLAYERS; i++) - { - if (playeringame[i] && !players[i].quittime - && (realpingtable[i] / pingmeasurecount > (unsigned)cv_maxping.value)) - { - if (players[i].jointime > 30 * TICRATE) - laggers[i] = true; - numlaggers++; - } - else - pingtimeout[i] = 0; } - //kick lagging players... unless everyone but the server's ping sucks. - //in that case, it is probably the server's fault. - if (numlaggers < D_NumPlayers() - 1) - { - for (i = 1; i < MAXPLAYERS; i++) - { - if (playeringame[i] && laggers[i]) - { - pingtimeout[i]++; - // ok your net has been bad for too long, you deserve to die. - if (pingtimeout[i] > cv_pingtimeout.value) - { - pingtimeout[i] = 0; - SendKick(i, KICK_MSG_PING_HIGH | KICK_MSG_KEEP_BODY); - } - } - /* - you aren't lagging, - but you aren't free yet. - In case you'll keep spiking, - we just make the timer go back down. (Very unstable net must still get kicked). - */ - else - pingtimeout[i] = (pingtimeout[i] == 0 ? 0 : pingtimeout[i]-1); - } - } + // Patch sprites + R_LoadSkinSprites(wadnum, &lump, &lastlump, skin); + //ST_LoadFaceGraphics(skinnum); -- nah let's do this elsewhere + + R_FlushTranslationColormapCache(); + + if (!skin->availability) // Safe to print... + CONS_Printf(M_GetText("Patched skin '%s'\n"), skin->name); } - - //make the ping packet and clear server data for next one - for (i = 0; i < MAXPLAYERS; i++) - { - netbuffer->u.pingtable[i] = realpingtable[i] / pingmeasurecount; - //server takes a snapshot of the real ping for display. - //otherwise, pings fluctuate a lot and would be odd to look at. - playerpingtable[i] = realpingtable[i] / pingmeasurecount; - realpingtable[i] = 0; //Reset each as we go. - } - - // send the server's maxping as last element of our ping table. This is useful to let us know when we're about to get kicked. - netbuffer->u.pingtable[MAXPLAYERS] = cv_maxping.value; - - //send out our ping packets - for (i = 0; i < MAXNETNODES; i++) - if (nodeingame[i]) - HSendPacket(i, true, 0, sizeof(INT32) * (MAXPLAYERS+1)); - - pingmeasurecount = 1; //Reset count + return; } -void NetUpdate(void) -{ - static tic_t gametime = 0; - static tic_t resptime = 0; - tic_t nowtime; - INT32 i; - INT32 realtics; - - nowtime = I_GetTime(); - realtics = nowtime - gametime; - - if (realtics <= 0) // nothing new to update - return; - if (realtics > 5) - { - if (server) - realtics = 1; - else - realtics = 5; - } - - gametime = nowtime; - - if (server) - { - if (netgame && !(gametime % 35)) // update once per second. - PingUpdate(); - // update node latency values so we can take an average later. - for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i] && playernode[i] != UINT8_MAX) - realpingtable[i] += G_TicsToMilliseconds(GetLag(playernode[i])); - pingmeasurecount++; - } - - if (client) - maketic = neededtic; - - Local_Maketic(realtics); // make local tic, and call menu? - - if (server) - CL_SendClientCmd(); // send it - - GetPackets(); // get packet from client or from server - - // client send the command after a receive of the server - // the server send before because in single player is beter - -#ifdef MASTERSERVER - MasterClient_Ticker(); // Acking the Master Server -#endif - - if (client) - { - // If the client just finished redownloading the game state, load it - if (cl_redownloadinggamestate && fileneeded[0].status == FS_FOUND) - CL_ReloadReceivedSavegame(); - - CL_SendClientCmd(); // Send tic cmd - hu_redownloadinggamestate = cl_redownloadinggamestate; - } - else - { - if (!demoplayback) - { - INT32 counts; - - hu_redownloadinggamestate = false; - - firstticstosend = gametic; - for (i = 0; i < MAXNETNODES; i++) - if (nodeingame[i] && nettics[i] < firstticstosend) - { - firstticstosend = nettics[i]; - - if (maketic + 1 >= nettics[i] + BACKUPTICS) - Net_ConnectionTimeout(i); - } - - // Don't erase tics not acknowledged - counts = realtics; - - if (maketic + counts >= firstticstosend + BACKUPTICS) - counts = firstticstosend+BACKUPTICS-maketic-1; - - for (i = 0; i < counts; i++) - SV_Maketic(); // Create missed tics and increment maketic - - for (; tictoclear < firstticstosend; tictoclear++) // Clear only when acknowledged - D_Clearticcmd(tictoclear); // Clear the maketic the new tic - - SV_SendTics(); - - neededtic = maketic; // The server is a client too - } - } - - Net_AckTicker(); - - // Handle timeouts to prevent definitive freezes from happenning - if (server) - { - for (i = 1; i < MAXNETNODES; i++) - if (nodeingame[i] && freezetimeout[i] < I_GetTime()) - Net_ConnectionTimeout(i); - - // In case the cvar value was lowered - if (joindelay) - joindelay = min(joindelay - 1, 3 * (tic_t)cv_joindelay.value * TICRATE); - } - - nowtime /= NEWTICRATERATIO; - if (nowtime > resptime) - { - resptime = nowtime; -#ifdef HAVE_THREADS - I_lock_mutex(&m_menu_mutex); -#endif - M_Ticker(); -#ifdef HAVE_THREADS - I_unlock_mutex(m_menu_mutex); -#endif - CON_Ticker(); - } - - FileSendTicker(); -} - -/** Returns the number of players playing. - * \return Number of players. Can be zero if we're running a ::dedicated - * server. - * \author Graue - */ -INT32 D_NumPlayers(void) -{ - INT32 num = 0, ix; - for (ix = 0; ix < MAXPLAYERS; ix++) - if (playeringame[ix]) - num++; - return num; -} - -tic_t GetLag(INT32 node) -{ - return gametic - nettics[node]; -} - -void D_MD5PasswordPass(const UINT8 *buffer, size_t len, const char *salt, void *dest) -{ -#ifdef NOMD5 - (void)buffer; - (void)len; - (void)salt; - memset(dest, 0, 16); -#else - char tmpbuf[256]; - const size_t sl = strlen(salt); - - if (len > 256-sl) - len = 256-sl; - - memcpy(tmpbuf, buffer, len); - memmove(&tmpbuf[len], salt, sl); - //strcpy(&tmpbuf[len], salt); - len += strlen(salt); - if (len < 256) - memset(&tmpbuf[len],0,256-len); - - // Yes, we intentionally md5 the ENTIRE buffer regardless of size... - md5_buffer(tmpbuf, 256, dest); -#endif -} +#undef HUDNAMEWRITE +#undef SYMBOLCONVERT From 079fe9ba7e488e880561318e1200e8630289d117 Mon Sep 17 00:00:00 2001 From: Shane Ellis Date: Fri, 15 Jan 2021 17:08:16 -0500 Subject: [PATCH 0531/1080] Command_Kick() - Allow removal of non-consoleplayer/secondaryviewplayer player instances (e.g. player bots) --- src/d_clisrv.c | 66 ++++++++++++++++++++++++++------------------------ 1 file changed, 34 insertions(+), 32 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 4fdc7e7ee..88b4d9387 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -1595,7 +1595,9 @@ static void CL_ReloadReceivedSavegame(void) for (i = 0; i < MAXPLAYERS; i++) { +#ifdef HAVE_BLUA LUA_InvalidatePlayer(&players[i]); +#endif sprintf(player_names[i], "Player %d", i + 1); } @@ -2258,15 +2260,11 @@ void D_SaveBan(void) size_t i; banreason_t *reasonlist = reasonhead; const char *address, *mask; - const char *path = va("%s"PATHSEP"%s", srb2home, "ban.txt"); if (!reasonhead) - { - remove(path); return; - } - f = fopen(path, "w"); + f = fopen(va("%s"PATHSEP"%s", srb2home, "ban.txt"), "w"); if (!f) { @@ -2310,14 +2308,16 @@ static void Ban_Add(const char *reason) reasontail = reasonlist; } -static void Ban_Clear(void) +static void Command_ClearBans(void) { banreason_t *temp; + if (!I_ClearBans) + return; + I_ClearBans(); - + D_SaveBan(); reasontail = NULL; - while (reasonhead) { temp = reasonhead->next; @@ -2327,15 +2327,6 @@ static void Ban_Clear(void) } } -static void Command_ClearBans(void) -{ - if (!I_ClearBans) - return; - - Ban_Clear(); - D_SaveBan(); -} - static void Ban_Load_File(boolean warning) { FILE *f; @@ -2343,9 +2334,6 @@ static void Ban_Load_File(boolean warning) const char *address, *mask; char buffer[MAX_WADPATH]; - if (!I_ClearBans) - return; - f = fopen(va("%s"PATHSEP"%s", srb2home, "ban.txt"), "r"); if (!f) @@ -2355,7 +2343,13 @@ static void Ban_Load_File(boolean warning) return; } - Ban_Clear(); + if (I_ClearBans) + Command_ClearBans(); + else + { + fclose(f); + return; + } for (i=0; fgets(buffer, (int)sizeof(buffer), f); i++) { @@ -2815,11 +2809,11 @@ static void Command_Kick(void) return; } - if (!netgame) // Don't kick Tails in splitscreen! - { - CONS_Printf(M_GetText("This only works in a netgame.\n")); - return; - } + //if (!netgame) // Don't kick Tails in splitscreen! + //{ + // CONS_Printf(M_GetText("This only works in a netgame.\n")); + // return; + //} if (server || IsPlayerAdmin(consoleplayer)) { @@ -2827,9 +2821,14 @@ static void Command_Kick(void) UINT8 *p = buf; const SINT8 pn = nametonum(COM_Argv(1)); + if (splitscreen && (pn == 0 || pn == 1)) + { + CONS_Printf(M_GetText("Splitscreen players cannot be kicked.\n")); + return; + } if (pn == -1 || pn == 0) 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 @@ -3032,7 +3031,8 @@ static void Got_KickCmd(UINT8 **p, INT32 playernum) if (pnum == consoleplayer) { - LUAh_GameQuit(false); + if (Playing()) + LUAh_GameQuit(); #ifdef DUMPCONSISTENCY if (msg == KICK_MSG_CON_FAIL) SV_SavedGame(); #endif @@ -3732,7 +3732,8 @@ static void HandleConnect(SINT8 node) static void HandleShutdown(SINT8 node) { (void)node; - LUAh_GameQuit(false); + if (Playing()) + LUAh_GameQuit(); D_QuitNetGame(); CL_Reset(); D_StartTitle(); @@ -3747,7 +3748,8 @@ static void HandleShutdown(SINT8 node) static void HandleTimeout(SINT8 node) { (void)node; - LUAh_GameQuit(false); + if (Playing()) + LUAh_GameQuit(); D_QuitNetGame(); CL_Reset(); D_StartTitle(); @@ -4850,14 +4852,14 @@ void TryRunTics(tic_t realtics) { DEBFILE(va("============ Running tic %d (local %d)\n", gametic, localgametic)); - ps_tictime = I_GetPreciseTime(); + ps_tictime = I_GetTimeMicros(); G_Ticker((gametic % NEWTICRATERATIO) == 0); ExtraDataTicker(); gametic++; consistancy[gametic%BACKUPTICS] = Consistancy(); - ps_tictime = I_GetPreciseTime() - ps_tictime; + ps_tictime = I_GetTimeMicros() - ps_tictime; // Leave a certain amount of tics present in the net buffer as long as we've ran at least one tic this frame. if (client && gamestate == GS_LEVEL && leveltime > 3 && neededtic <= gametic + cv_netticbuffer.value) From a68fee3303b0804cd35c186c4d89b858b790c385 Mon Sep 17 00:00:00 2001 From: Shane Ellis Date: Fri, 15 Jan 2021 17:22:38 -0500 Subject: [PATCH 0532/1080] oops --- src/p_inter.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/p_inter.c b/src/p_inter.c index 778ec703b..8190f5cfa 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -1387,6 +1387,10 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) if (player->bot && player->bot != 3) return; + + // Initialize my junk + junk.tags.tags = NULL; + junk.tags.count = 0; Tag_FSet(&junk.tags, LE_AXE); EV_DoElevator(&junk, bridgeFall, false); From 56e9b99f283923855efc6cf621d988700c305634 Mon Sep 17 00:00:00 2001 From: Shane Ellis Date: Fri, 15 Jan 2021 22:28:01 +0000 Subject: [PATCH 0533/1080] Revert "Add conditions for new player bot type" This reverts commit 4b9a95a53837166a080b200b34982ce867a31ffd --- src/p_enemy.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/p_enemy.c b/src/p_enemy.c index 38df59855..203e04af1 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -743,7 +743,7 @@ boolean P_LookForPlayers(mobj_t *actor, boolean allaround, boolean tracer, fixed if (player->mo->health <= 0) continue; // dead - if (player->bot && player->bot != 3) + if (player->bot) continue; // ignore bots if (player->quittime) @@ -1834,7 +1834,7 @@ void A_SnailerThink(mobj_t *actor) fixed_t dist; fixed_t dx, dy; - dist = P_AproxDistance(actor->x - actor->target->x, actor->y - actor->target->y); + dist = R_PointToDist2(0, 0, actor->x - actor->target->x, actor->y - actor->target->y); if (an > ANGLE_45 && an <= ANGLE_90) // fire at 45 degrees to the left { @@ -3924,6 +3924,10 @@ void A_BossDeath(mobj_t *mo) } else { + // Initialize my junk + junk.tags.tags = NULL; + junk.tags.count = 0; + // Bring the egg trap up to the surface // Incredibly shitty code ahead Tag_FSet(&junk.tags, LE_CAPSULE0); @@ -4053,6 +4057,10 @@ bossjustdie: } case MT_KOOPA: { + // Initialize my junk + junk.tags.tags = NULL; + junk.tags.count = 0; + Tag_FSet(&junk.tags, LE_KOOPA); EV_DoCeiling(&junk, raiseToHighest); return; From 161e1c42cb6bed9ca7af062df4f7fd091f0299b7 Mon Sep 17 00:00:00 2001 From: Shane Ellis Date: Fri, 15 Jan 2021 17:29:15 -0500 Subject: [PATCH 0534/1080] Update p_enemy.c --- src/p_enemy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_enemy.c b/src/p_enemy.c index 203e04af1..637eba83f 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -743,7 +743,7 @@ boolean P_LookForPlayers(mobj_t *actor, boolean allaround, boolean tracer, fixed if (player->mo->health <= 0) continue; // dead - if (player->bot) + if (player->bot && player->bot != 3) continue; // ignore bots if (player->quittime) From 759ff44dfd366bfd42ae252d90f78a1e85b947c2 Mon Sep 17 00:00:00 2001 From: Shane Ellis Date: Fri, 15 Jan 2021 22:32:02 +0000 Subject: [PATCH 0535/1080] Revert "Add conditions for new player bot type" This reverts commit b995e3cb75b67116d51583c1ae85debf25013621 --- src/p_user.c | 125 +++++++++++++++++++++++++++++++-------------------- 1 file changed, 77 insertions(+), 48 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index 2466310bb..a70dceb8b 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -1189,7 +1189,7 @@ void P_GivePlayerRings(player_t *player, INT32 num_rings) if (!player) return; - if (player->bot && player->bot != 3) + if (player->bot) player = &players[consoleplayer]; if (!player->mo) @@ -1234,7 +1234,7 @@ void P_GivePlayerSpheres(player_t *player, INT32 num_spheres) if (!player) return; - if (player->bot && player->bot != 3) + if (player->bot) player = &players[consoleplayer]; if (!player->mo) @@ -1261,7 +1261,7 @@ void P_GivePlayerLives(player_t *player, INT32 numlives) if (!player) return; - if (player->bot && player->bot != 3) + if (player->bot) player = &players[consoleplayer]; if (gamestate == GS_LEVEL) @@ -1341,7 +1341,7 @@ void P_DoSuperTransformation(player_t *player, boolean giverings) // Transformation animation P_SetPlayerMobjState(player->mo, S_PLAY_SUPER_TRANS1); - if (giverings) + if (giverings && player->rings < 50) player->rings = 50; // Just in case. @@ -1367,7 +1367,7 @@ void P_AddPlayerScore(player_t *player, UINT32 amount) { UINT32 oldscore; - if (player->bot && player->bot != 3) + if (player->bot) player = &players[consoleplayer]; // NiGHTS does it different! @@ -1491,10 +1491,10 @@ void P_PlayLivesJingle(player_t *player) if (player && !P_IsLocalPlayer(player)) return; - if (use1upSound || cv_1upsound.value) - S_StartSound(NULL, sfx_oneup); - else if (mariomode) + if (mariomode) S_StartSound(NULL, sfx_marioa); + else if (use1upSound || cv_1upsound.value) + S_StartSound(NULL, sfx_oneup); else { P_PlayJingle(player, JT_1UP); @@ -2329,7 +2329,8 @@ boolean P_PlayerHitFloor(player_t *player, boolean dorollstuff) P_MobjCheckWater(player->mo); if (player->pflags & PF_SPINNING) { - if (player->mo->state-states != S_PLAY_ROLL && !(player->pflags & PF_STARTDASH)) + if (!(player->pflags & PF_STARTDASH) && player->panim != PA_ROLL && player->panim != PA_ETC + && player->panim != PA_ABILITY && player->panim != PA_ABILITY2) { P_SetPlayerMobjState(player->mo, S_PLAY_ROLL); S_StartSound(player->mo, sfx_spin); @@ -2612,10 +2613,10 @@ static void P_CheckBustableBlocks(player_t *player) if ((netgame || multiplayer) && player->spectator) return; - + oldx = player->mo->x; oldy = player->mo->y; - + if (!(player->pflags & PF_BOUNCING)) // Bouncers only get to break downwards, not sideways { P_UnsetThingPosition(player->mo); @@ -2634,7 +2635,7 @@ static void P_CheckBustableBlocks(player_t *player) if (!node->m_sector->ffloors) continue; - + for (rover = node->m_sector->ffloors; rover; rover = rover->next) { if (!P_PlayerCanBust(player, rover)) @@ -2992,7 +2993,7 @@ static void P_CheckUnderwaterAndSpaceTimer(player_t *player) player->powers[pw_spacetime] = 0; // Underwater audio cues - if (P_IsLocalPlayer(player) && !player->bot && player->bot != 3) + if (P_IsLocalPlayer(player) && !player->bot) { if ((player->powers[pw_underwater] == 25*TICRATE + 1) || (player->powers[pw_underwater] == 20*TICRATE + 1) @@ -4525,6 +4526,9 @@ void P_DoJump(player_t *player, boolean soundandstate) player->pflags |= P_GetJumpFlags(player);; + if (player->charflags & SF_NOJUMPDAMAGE) + player->pflags &= ~PF_SPINNING; + if (soundandstate) { if (!player->spectator) @@ -5020,7 +5024,7 @@ static boolean P_PlayerShieldThink(player_t *player, ticcmd_t *cmd, mobj_t *lock if ((player->powers[pw_shield] & SH_NOSTACK) && !player->powers[pw_super] && !(player->pflags & PF_SPINDOWN) && ((!(player->pflags & PF_THOKKED) || (((player->powers[pw_shield] & SH_NOSTACK) == SH_BUBBLEWRAP || (player->powers[pw_shield] & SH_NOSTACK) == SH_ATTRACT) && player->secondjump == UINT8_MAX) ))) // thokked is optional if you're bubblewrapped / 3dblasted { - if ((player->powers[pw_shield] & SH_NOSTACK) == SH_ATTRACT) + if ((player->powers[pw_shield] & SH_NOSTACK) == SH_ATTRACT && !(player->charflags & SF_NOSHIELDABILITY)) { if ((lockonshield = P_LookForEnemies(player, false, false))) { @@ -5043,7 +5047,7 @@ static boolean P_PlayerShieldThink(player_t *player, ticcmd_t *cmd, mobj_t *lock } } } - if (cmd->buttons & BT_SPIN && !LUAh_ShieldSpecial(player)) // Spin button effects + if ((!(player->charflags & SF_NOSHIELDABILITY)) && (cmd->buttons & BT_SPIN && !LUAh_ShieldSpecial(player))) // Spin button effects { // Force stop if ((player->powers[pw_shield] & ~(SH_FORCEHP|SH_STACK)) == SH_FORCE) @@ -5491,7 +5495,7 @@ static void P_DoJumpStuff(player_t *player, ticcmd_t *cmd) break; } } - else if ((player->powers[pw_shield] & SH_NOSTACK) == SH_WHIRLWIND && !player->powers[pw_super]) + else if ((!(player->charflags & SF_NOSHIELDABILITY)) && ((player->powers[pw_shield] & SH_NOSTACK) == SH_WHIRLWIND && !player->powers[pw_super] && !LUAh_ShieldSpecial(player))) P_DoJumpShield(player); } @@ -5920,7 +5924,7 @@ static void P_3dMovement(player_t *player) player->rmomy = player->mo->momy - player->cmomy; // Calculates player's speed based on distance-of-a-line formula - player->speed = P_AproxDistance(player->rmomx, player->rmomy); + 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! @@ -5953,6 +5957,22 @@ static void P_3dMovement(player_t *player) acceleration = 96 + (FixedDiv(player->speed, player->mo->scale)>>FRACBITS) * 40; topspeed = normalspd; } + else if (player->bot) + { // Bot steals player 1's stats + normalspd = FixedMul(players[consoleplayer].normalspeed, player->mo->scale); + thrustfactor = players[consoleplayer].thrustfactor; + acceleration = players[consoleplayer].accelstart + (FixedDiv(player->speed, player->mo->scale)>>FRACBITS) * players[consoleplayer].acceleration; + + if (player->powers[pw_tailsfly]) + topspeed = normalspd/2; + else if (player->mo->eflags & (MFE_UNDERWATER|MFE_GOOWATER)) + { + topspeed = normalspd/2; + acceleration = 2*acceleration/3; + } + else + topspeed = normalspd; + } else { if (player->powers[pw_super] || player->powers[pw_sneakers]) @@ -7736,6 +7756,11 @@ void P_ElementalFire(player_t *player, boolean cropcircle) flame->eflags = (flame->eflags & ~MFE_VERTICALFLIP)|(player->mo->eflags & MFE_VERTICALFLIP); P_InstaThrust(flame, flame->angle, FixedMul(3*FRACUNIT, flame->scale)); P_SetObjectMomZ(flame, 3*FRACUNIT, false); + if (!(gametyperules & GTR_FRIENDLY)) + { + P_SetMobjState(flame, S_TEAM_SPINFIRE1); + flame->color = player->mo->color; + } } #undef limitangle #undef numangles @@ -7763,6 +7788,11 @@ void P_ElementalFire(player_t *player, boolean cropcircle) flame->destscale = player->mo->scale; P_SetScale(flame, player->mo->scale); flame->eflags = (flame->eflags & ~MFE_VERTICALFLIP)|(player->mo->eflags & MFE_VERTICALFLIP); + if (!(gametyperules & GTR_FRIENDLY)) + { + P_SetMobjState(flame, S_TEAM_SPINFIRE1); + flame->color = player->mo->color; + } flame->momx = 8; // this is a hack which is used to ensure it still behaves as a missile and can damage others P_XYMovement(flame); @@ -8589,12 +8619,6 @@ void P_MovePlayer(player_t *player) player->climbing--; } - if (!player->climbing) - { - player->lastsidehit = -1; - player->lastlinehit = -1; - } - // Make sure you're not teetering when you shouldn't be. if (player->panim == PA_EDGE && (player->mo->momx || player->mo->momy || player->mo->momz)) @@ -8619,6 +8643,7 @@ void P_MovePlayer(player_t *player) P_DoFiring(player, cmd); { + boolean atspinheight = false; fixed_t oldheight = player->mo->height; // Less height while spinning. Good for spinning under things...? @@ -8628,32 +8653,35 @@ void P_MovePlayer(player_t *player) || player->powers[pw_tailsfly] || player->pflags & PF_GLIDING || (player->charability == CA_GLIDEANDCLIMB && player->mo->state-states == S_PLAY_GLIDE_LANDING) || (player->charability == CA_FLY && player->mo->state-states == S_PLAY_FLY_TIRED)) + { player->mo->height = P_GetPlayerSpinHeight(player); + atspinheight = true; + } else player->mo->height = P_GetPlayerHeight(player); if (player->mo->eflags & MFE_VERTICALFLIP && player->mo->height != oldheight) // adjust z height for reverse gravity, similar to how it's done for scaling player->mo->z -= player->mo->height - oldheight; - } - // Crush test... - if ((player->mo->ceilingz - player->mo->floorz < player->mo->height) - && !(player->mo->flags & MF_NOCLIP)) - { - if ((player->charability2 == CA2_SPINDASH) && !(player->pflags & PF_SPINNING)) + // Crush test... + if ((player->mo->ceilingz - player->mo->floorz < player->mo->height) + && !(player->mo->flags & MF_NOCLIP)) { - player->pflags |= PF_SPINNING; - P_SetPlayerMobjState(player->mo, S_PLAY_ROLL); - } - else if (player->mo->ceilingz - player->mo->floorz < player->mo->height) - { - if ((netgame || multiplayer) && player->spectator) - P_DamageMobj(player->mo, NULL, NULL, 1, DMG_SPECTATOR); // Respawn crushed spectators - else - P_DamageMobj(player->mo, NULL, NULL, 1, DMG_CRUSHED); + if (!atspinheight) + { + player->pflags |= PF_SPINNING; + P_SetPlayerMobjState(player->mo, S_PLAY_ROLL); + } + else if (player->mo->ceilingz - player->mo->floorz < player->mo->height) + { + if ((netgame || multiplayer) && player->spectator) + P_DamageMobj(player->mo, NULL, NULL, 1, DMG_SPECTATOR); // Respawn crushed spectators + else + P_DamageMobj(player->mo, NULL, NULL, 1, DMG_CRUSHED); - if (player->playerstate == PST_DEAD) - return; + if (player->playerstate == PST_DEAD) + return; + } } } @@ -9469,11 +9497,11 @@ static void P_DeathThink(player_t *player) if (player->deadtimer < INT32_MAX) player->deadtimer++; - if (player->bot && player->bot != 3) // don't allow bots to do any of the below, B_CheckRespawn does all they need for respawning already + if (player->bot) // don't allow bots to do any of the below, B_CheckRespawn does all they need for respawning already goto notrealplayer; // continue logic - if (!(netgame || multiplayer) && player->lives <= 0 && player ==&players[consoleplayer]) //Extra players in SP can't be allowed to continue or end game + if (!(netgame || multiplayer) && player->lives <= 0) { if (player->deadtimer > (3*TICRATE) && (cmd->buttons & BT_SPIN || cmd->buttons & BT_JUMP) && (!continuesInSession || player->continues > 0)) G_UseContinue(); @@ -11452,7 +11480,7 @@ void P_PlayerThink(player_t *player) player->playerstate = PST_DEAD; } - if (player->bot && player->bot != 3) + if (player->bot) { if (player->playerstate == PST_LIVE || player->playerstate == PST_DEAD) { @@ -11466,7 +11494,6 @@ void P_PlayerThink(player_t *player) } } -#ifdef SEENAMES if (netgame && player == &players[displayplayer] && !(leveltime % (TICRATE/5))) { seenplayer = NULL; @@ -11491,7 +11518,6 @@ void P_PlayerThink(player_t *player) } } } -#endif if (player->awayviewmobj && P_MobjWasRemoved(player->awayviewmobj)) { @@ -12562,13 +12588,16 @@ void P_PlayerAfterThink(player_t *player) player->powers[pw_carry] = CR_NONE; else { - P_TryMove(player->mo, tails->x + P_ReturnThrustX(tails, tails->player->drawangle, 4*FRACUNIT), tails->y + P_ReturnThrustY(tails, tails->player->drawangle, 4*FRACUNIT), true); + if (tails->player) + P_TryMove(player->mo, tails->x + P_ReturnThrustX(tails, tails->player->drawangle, 4*FRACUNIT), tails->y + P_ReturnThrustY(tails, tails->player->drawangle, 4*FRACUNIT), true); + else + P_TryMove(player->mo, tails->x + P_ReturnThrustX(tails, tails->angle, 4*FRACUNIT), tails->y + P_ReturnThrustY(tails, tails->angle, 4*FRACUNIT), true); player->mo->momx = tails->momx; player->mo->momy = tails->momy; player->mo->momz = tails->momz; } - if (G_CoopGametype() && (!tails->player || tails->player->bot != 1)) + if (G_CoopGametype() && tails->player && tails->player->bot != 1) { player->mo->angle = tails->angle; @@ -12583,7 +12612,7 @@ void P_PlayerAfterThink(player_t *player) { if (player->mo->state-states != S_PLAY_RIDE) P_SetPlayerMobjState(player->mo, S_PLAY_RIDE); - if ((tails->skin && ((skin_t *)(tails->skin))->sprites[SPR2_SWIM].numframes) && (tails->eflags & MFE_UNDERWATER)) + if (tails->player && (tails->skin && ((skin_t *)(tails->skin))->sprites[SPR2_SWIM].numframes) && (tails->eflags & MFE_UNDERWATER)) tails->player->powers[pw_tailsfly] = 0; } else From 6103d7a51e2e7905d5298f5fde80be3554d1751f Mon Sep 17 00:00:00 2001 From: Shane Ellis Date: Fri, 15 Jan 2021 17:41:16 -0500 Subject: [PATCH 0536/1080] Update p_user.c --- src/p_user.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index a70dceb8b..9e86e2d73 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -777,7 +777,7 @@ void P_NightserizePlayer(player_t *player, INT32 nighttime) UINT8 oldmare, oldmarelap, oldmarebonuslap; // Bots can't be NiGHTSerized, silly!1 :P - if (player->bot) + if (player->bot && player->bot != 3) return; if (player->powers[pw_carry] != CR_NIGHTSMODE) @@ -1189,7 +1189,7 @@ void P_GivePlayerRings(player_t *player, INT32 num_rings) if (!player) return; - if (player->bot) + if (player->bot && player->bot != 3) player = &players[consoleplayer]; if (!player->mo) @@ -1234,7 +1234,7 @@ void P_GivePlayerSpheres(player_t *player, INT32 num_spheres) if (!player) return; - if (player->bot) + if (player->bot && player->bot != 3) player = &players[consoleplayer]; if (!player->mo) @@ -1261,7 +1261,7 @@ void P_GivePlayerLives(player_t *player, INT32 numlives) if (!player) return; - if (player->bot) + if (player->bot && player->bot != 3) player = &players[consoleplayer]; if (gamestate == GS_LEVEL) @@ -1367,7 +1367,7 @@ void P_AddPlayerScore(player_t *player, UINT32 amount) { UINT32 oldscore; - if (player->bot) + if (player->bot && player->bot != 3) player = &players[consoleplayer]; // NiGHTS does it different! @@ -5957,7 +5957,7 @@ static void P_3dMovement(player_t *player) acceleration = 96 + (FixedDiv(player->speed, player->mo->scale)>>FRACBITS) * 40; topspeed = normalspd; } - else if (player->bot) + else if (player->bot && player->bot != 3) { // Bot steals player 1's stats normalspd = FixedMul(players[consoleplayer].normalspeed, player->mo->scale); thrustfactor = players[consoleplayer].thrustfactor; @@ -9497,11 +9497,11 @@ static void P_DeathThink(player_t *player) if (player->deadtimer < INT32_MAX) player->deadtimer++; - if (player->bot) // don't allow bots to do any of the below, B_CheckRespawn does all they need for respawning already + if (player->bot && player->bot != 3) // don't allow bots to do any of the below, B_CheckRespawn does all they need for respawning already goto notrealplayer; // continue logic - if (!(netgame || multiplayer) && player->lives <= 0) + if (!(netgame || multiplayer) && player->lives <= 0 && player == &players[consoleplayer]) //Extra players in SP can't be allowed to continue or end game { if (player->deadtimer > (3*TICRATE) && (cmd->buttons & BT_SPIN || cmd->buttons & BT_JUMP) && (!continuesInSession || player->continues > 0)) G_UseContinue(); @@ -11480,7 +11480,7 @@ void P_PlayerThink(player_t *player) player->playerstate = PST_DEAD; } - if (player->bot) + if (player->bot && player->bot != 3) { if (player->playerstate == PST_LIVE || player->playerstate == PST_DEAD) { From 00462323c3fe6dda7ece834cfa92431525f54e85 Mon Sep 17 00:00:00 2001 From: Shane Ellis Date: Fri, 15 Jan 2021 22:42:35 +0000 Subject: [PATCH 0537/1080] Revert "Implementation of lua function P_AddPlayer()" This reverts commit 5e8313e157ab0bef4f2e2a346906aa1a6efdd58b --- src/lua_baselib.c | 89 +++++------------------------------------------ 1 file changed, 8 insertions(+), 81 deletions(-) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 9bc8813a2..c5f847be6 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -155,6 +155,8 @@ static const struct { {META_PIVOTLIST, "spriteframepivot_t[]"}, {META_FRAMEPIVOT, "spriteframepivot_t"}, + {META_TAGLIST, "taglist"}, + {META_MOBJ, "mobj_t"}, {META_MAPTHING, "mapthing_t"}, @@ -163,6 +165,8 @@ static const struct { {META_SKIN, "skin_t"}, {META_POWERS, "player_t.powers"}, {META_SOUNDSID, "skin_t.soundsid"}, + {META_SKINSPRITES, "skin_t.sprites"}, + {META_SKINSPRITESLIST, "skin_t.sprites[]"}, {META_VERTEX, "vertex_t"}, {META_LINE, "line_t"}, @@ -184,6 +188,9 @@ static const struct { {META_CVAR, "consvar_t"}, {META_SECTORLINES, "sector_t.lines"}, +#ifdef MUTABLE_TAGS + {META_SECTORTAGLIST, "sector_t.taglist"}, +#endif {META_SIDENUM, "line_t.sidenum"}, {META_LINEARGS, "line_t.args"}, {META_LINESTRINGARGS, "line_t.stringargs"}, @@ -2632,7 +2639,7 @@ static int lib_rSkinUsable(lua_State *L) else // skin name { const char *skinname = luaL_checkstring(L, 2); - if (R_SkinAvailable(skinname) >= 0) + i = R_SkinAvailable(skinname); if (i == -1) return luaL_error(L, "skin %s (argument 2) is not loaded", skinname); } @@ -3400,85 +3407,6 @@ static int lib_gAddGametype(lua_State *L) return 0; } -// Bot adding function! -// Partly lifted from Got_AddPlayer -static int lib_gAddPlayer(lua_State *L) -{ - INT16 i, newplayernum, botcount = 1; - player_t *newplayer; - INT8 skinnum = 0, bot; - - for (i = 0; i < MAXPLAYERS; i++) - { - if (!playeringame[i]) - break; - - if (players[i].bot) - botcount++; // How many of us are there already? - } - if (i >= MAXPLAYERS) - { - lua_pushnil(L); - return 1; - } - - - newplayernum = i; - - //if (!splitscreen && !botingame) - CL_ClearPlayer(newplayernum); - - playeringame[newplayernum] = true; - G_AddPlayer(newplayernum); - newplayer = &players[newplayernum]; - - newplayer->jointime = 0; - newplayer->quittime = 0; - - // I hereby name you Bot X - strcpy(player_names[newplayernum], va("Bot %d", botcount)); - - // Read the skin string! - if (!lua_isnoneornil(L, 1)) - { - skinnum = R_SkinAvailable(luaL_checkstring(L, 1)); - skinnum = skinnum < 0 ? 0 : skinnum; - - // Bots can be whatever they want - if (!R_SkinUsable(newplayernum, skinnum)) - newplayer->availabilities |= 1 << skinnum; - } - - // Read the color! - if (!lua_isnoneornil(L, 2)) - newplayer->skincolor = R_GetColorByName(luaL_checkstring(L, 2)); - else - newplayer->skincolor = skins[newplayer->skin].prefcolor; - - // Read the bot name, if given! - if (!lua_isnoneornil(L, 3)) - strcpy(player_names[newplayernum], luaL_checkstring(L, 3)); - - bot = luaL_optinteger(L, 4, 3); - newplayer->bot = (bot >= 0 && bot <= 3) ? bot : 3; - - // Set the skin - SetPlayerSkinByNum(newplayernum, skinnum); - - - if (netgame) - { - char joinmsg[256]; - - strcpy(joinmsg, M_GetText("\x82*Bot %s has joined the game (player %d)")); - strcpy(joinmsg, va(joinmsg, player_names[newplayernum], newplayernum)); - HU_AddChatText(joinmsg, false); - } - - LUA_PushUserdata(L, newplayer, META_PLAYER); - return 0; -} - static int Lcheckmapnumber (lua_State *L, int idx, const char *fun) { if (ISINLEVEL) @@ -4059,7 +3987,6 @@ static luaL_Reg lib[] = { // g_game {"G_AddGametype", lib_gAddGametype}, - {"G_AddPlayer", lib_gAddPlayer}, {"G_BuildMapName",lib_gBuildMapName}, {"G_BuildMapTitle",lib_gBuildMapTitle}, {"G_FindMap",lib_gFindMap}, From 4e029dbc67a51529d88c2e16c696da97b5f73703 Mon Sep 17 00:00:00 2001 From: Shane Ellis Date: Fri, 15 Jan 2021 17:45:41 -0500 Subject: [PATCH 0538/1080] Update lua_baselib.c --- src/lua_baselib.c | 77 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index c5f847be6..438c20b81 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -3407,6 +3407,82 @@ static int lib_gAddGametype(lua_State *L) return 0; } +// Bot adding function! +// Partly lifted from Got_AddPlayer +static int lib_gAddPlayer(lua_State *L) +{ + INT16 i, newplayernum, botcount = 1; + player_t *newplayer; + INT8 skinnum = 0, bot; + + for (i = 0; i < MAXPLAYERS; i++) + { + if (!playeringame[i]) + break; + + if (players[i].bot) + botcount++; // How many of us are there already? + } + if (i >= MAXPLAYERS) + { + lua_pushnil(L); + return 1; + } + + + newplayernum = i; + + //if (!splitscreen && !botingame) + CL_ClearPlayer(newplayernum); + + playeringame[newplayernum] = true; + G_AddPlayer(newplayernum); + newplayer = &players[newplayernum]; + + newplayer->jointime = 0; + newplayer->quittime = 0; + + // I hereby name you Bot X + strcpy(player_names[newplayernum], va("Bot %d", botcount)); + + // Read the skin string! + if (!lua_isnoneornil(L, 1)) + { + skinnum = R_SkinAvailable(luaL_checkstring(L, 1)); + skinnum = skinnum < 0 ? 0 : skinnum; + } + + // Read the color! + if (!lua_isnoneornil(L, 2)) + newplayer->skincolor = R_GetColorByName(luaL_checkstring(L, 2)); + else + newplayer->skincolor = skins[newplayer->skin].prefcolor; + + // Read the bot name, if given! + if (!lua_isnoneornil(L, 3)) + strcpy(player_names[newplayernum], luaL_checkstring(L, 3)); + + bot = luaL_optinteger(L, 4, 3); + newplayer->bot = (bot >= 0 && bot <= 3) ? bot : 3; + + // Set the skin (needed to set bot first!) + SetPlayerSkinByNum(newplayernum, skinnum); + + + if (netgame) + { + char joinmsg[256]; + + strcpy(joinmsg, M_GetText("\x82*Bot %s has joined the game (player %d)")); + strcpy(joinmsg, va(joinmsg, player_names[newplayernum], newplayernum)); + HU_AddChatText(joinmsg, false); + } + + LUA_PushUserdata(L, newplayer, META_PLAYER); + return 0; +} + + static int Lcheckmapnumber (lua_State *L, int idx, const char *fun) { if (ISINLEVEL) @@ -3987,6 +4063,7 @@ static luaL_Reg lib[] = { // g_game {"G_AddGametype", lib_gAddGametype}, + {"G_AddPlayer", lib_gAddPlayer}, {"G_BuildMapName",lib_gBuildMapName}, {"G_BuildMapTitle",lib_gBuildMapTitle}, {"G_FindMap",lib_gFindMap}, From 8fa8ca622249af77e1aad9ffe6e2800f92448380 Mon Sep 17 00:00:00 2001 From: Shane Ellis Date: Fri, 15 Jan 2021 17:47:26 -0500 Subject: [PATCH 0539/1080] Update r_skins.c --- src/r_skins.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/r_skins.c b/src/r_skins.c index 155a64700..a29209873 100644 --- a/src/r_skins.c +++ b/src/r_skins.c @@ -512,6 +512,10 @@ static boolean R_ProcessPatchableFields(skin_t *skin, char *stoken, char *value) GETFLAG(MULTIABILITY) GETFLAG(NONIGHTSROTATION) GETFLAG(NONIGHTSSUPER) + GETFLAG(NOSUPERSPRITES) + GETFLAG(NOSUPERJUMPBOOST) + GETFLAG(CANBUSTWALLS) + GETFLAG(NOSHIELDABILITY) #undef GETFLAG else // let's check if it's a sound, otherwise error out From 93562b782e9e001d82fa6d8c94860ea3170a2bc9 Mon Sep 17 00:00:00 2001 From: Shane Ellis Date: Fri, 15 Jan 2021 22:50:20 +0000 Subject: [PATCH 0540/1080] =?UTF-8?q?Revert=20"Command=5FKick()=20-=20Allo?= =?UTF-8?q?w=20removal=20of=20non-consoleplayer/secondaryviewplayer=20play?= =?UTF-8?q?er=E2=80=A6"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 079fe9ba7e488e880561318e1200e8630289d117 --- src/d_clisrv.c | 66 ++++++++++++++++++++++++-------------------------- 1 file changed, 32 insertions(+), 34 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 88b4d9387..4fdc7e7ee 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -1595,9 +1595,7 @@ static void CL_ReloadReceivedSavegame(void) for (i = 0; i < MAXPLAYERS; i++) { -#ifdef HAVE_BLUA LUA_InvalidatePlayer(&players[i]); -#endif sprintf(player_names[i], "Player %d", i + 1); } @@ -2260,11 +2258,15 @@ void D_SaveBan(void) size_t i; banreason_t *reasonlist = reasonhead; const char *address, *mask; + const char *path = va("%s"PATHSEP"%s", srb2home, "ban.txt"); if (!reasonhead) + { + remove(path); return; + } - f = fopen(va("%s"PATHSEP"%s", srb2home, "ban.txt"), "w"); + f = fopen(path, "w"); if (!f) { @@ -2308,16 +2310,14 @@ static void Ban_Add(const char *reason) reasontail = reasonlist; } -static void Command_ClearBans(void) +static void Ban_Clear(void) { banreason_t *temp; - if (!I_ClearBans) - return; - I_ClearBans(); - D_SaveBan(); + reasontail = NULL; + while (reasonhead) { temp = reasonhead->next; @@ -2327,6 +2327,15 @@ static void Command_ClearBans(void) } } +static void Command_ClearBans(void) +{ + if (!I_ClearBans) + return; + + Ban_Clear(); + D_SaveBan(); +} + static void Ban_Load_File(boolean warning) { FILE *f; @@ -2334,6 +2343,9 @@ static void Ban_Load_File(boolean warning) const char *address, *mask; char buffer[MAX_WADPATH]; + if (!I_ClearBans) + return; + f = fopen(va("%s"PATHSEP"%s", srb2home, "ban.txt"), "r"); if (!f) @@ -2343,13 +2355,7 @@ static void Ban_Load_File(boolean warning) return; } - if (I_ClearBans) - Command_ClearBans(); - else - { - fclose(f); - return; - } + Ban_Clear(); for (i=0; fgets(buffer, (int)sizeof(buffer), f); i++) { @@ -2809,11 +2815,11 @@ static void Command_Kick(void) return; } - //if (!netgame) // Don't kick Tails in splitscreen! - //{ - // CONS_Printf(M_GetText("This only works in a netgame.\n")); - // return; - //} + if (!netgame) // Don't kick Tails in splitscreen! + { + CONS_Printf(M_GetText("This only works in a netgame.\n")); + return; + } if (server || IsPlayerAdmin(consoleplayer)) { @@ -2821,14 +2827,9 @@ static void Command_Kick(void) UINT8 *p = buf; const SINT8 pn = nametonum(COM_Argv(1)); - if (splitscreen && (pn == 0 || pn == 1)) - { - CONS_Printf(M_GetText("Splitscreen players cannot be kicked.\n")); - return; - } if (pn == -1 || pn == 0) 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 @@ -3031,8 +3032,7 @@ static void Got_KickCmd(UINT8 **p, INT32 playernum) if (pnum == consoleplayer) { - if (Playing()) - LUAh_GameQuit(); + LUAh_GameQuit(false); #ifdef DUMPCONSISTENCY if (msg == KICK_MSG_CON_FAIL) SV_SavedGame(); #endif @@ -3732,8 +3732,7 @@ static void HandleConnect(SINT8 node) static void HandleShutdown(SINT8 node) { (void)node; - if (Playing()) - LUAh_GameQuit(); + LUAh_GameQuit(false); D_QuitNetGame(); CL_Reset(); D_StartTitle(); @@ -3748,8 +3747,7 @@ static void HandleShutdown(SINT8 node) static void HandleTimeout(SINT8 node) { (void)node; - if (Playing()) - LUAh_GameQuit(); + LUAh_GameQuit(false); D_QuitNetGame(); CL_Reset(); D_StartTitle(); @@ -4852,14 +4850,14 @@ void TryRunTics(tic_t realtics) { DEBFILE(va("============ Running tic %d (local %d)\n", gametic, localgametic)); - ps_tictime = I_GetTimeMicros(); + ps_tictime = I_GetPreciseTime(); G_Ticker((gametic % NEWTICRATERATIO) == 0); ExtraDataTicker(); gametic++; consistancy[gametic%BACKUPTICS] = Consistancy(); - ps_tictime = I_GetTimeMicros() - ps_tictime; + ps_tictime = I_GetPreciseTime() - ps_tictime; // Leave a certain amount of tics present in the net buffer as long as we've ran at least one tic this frame. if (client && gamestate == GS_LEVEL && leveltime > 3 && neededtic <= gametic + cv_netticbuffer.value) From 9bbebcbe9e4d6ed144bed21c0cf0b37d6918f20c Mon Sep 17 00:00:00 2001 From: Shane Ellis Date: Fri, 15 Jan 2021 17:55:14 -0500 Subject: [PATCH 0541/1080] Update d_clisrv.c --- src/d_clisrv.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 4fdc7e7ee..4574e5a1c 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -2815,18 +2815,22 @@ static void Command_Kick(void) return; } - if (!netgame) // Don't kick Tails in splitscreen! - { - CONS_Printf(M_GetText("This only works in a netgame.\n")); - return; - } - if (server || IsPlayerAdmin(consoleplayer)) { UINT8 buf[3 + MAX_REASONLENGTH]; UINT8 *p = buf; const SINT8 pn = nametonum(COM_Argv(1)); + // Unlike bans, kicks are used especially to remove bot players, so we'll + // need to run a more specific check which allows kicking offline, but + // not against splitscreen players. + if (splitscreen && (pn == 0 || pn == 1)) + { + CONS_Printf(M_GetText("Splitscreen players cannot be kicked.\n")); + return; + } + + if (pn == -1 || pn == 0) return; From 225e7c72ace052a5945454b46ba14ab623209396 Mon Sep 17 00:00:00 2001 From: Shane Ellis Date: Fri, 15 Jan 2021 18:00:00 -0500 Subject: [PATCH 0542/1080] Update p_mobj.c --- src/p_mobj.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index 58124fb9b..f27ab2914 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -1840,7 +1840,7 @@ void P_XYMovement(mobj_t *mo) moved = false; if (player) { - if (player->bot) + if (player->bot and player->bot != 3) B_MoveBlocked(player); } @@ -4135,7 +4135,7 @@ boolean P_BossTargetPlayer(mobj_t *actor, boolean closest) player = &players[actor->lastlook]; - if (player->pflags & PF_INVIS || player->bot || player->spectator) + if (player->pflags & PF_INVIS || (player->bot && player->bot != 3) || player->spectator) continue; // ignore notarget if (!player->mo || P_MobjWasRemoved(player->mo)) From 505ba1ff631c91d3f91a65bd728817fe19ea6d76 Mon Sep 17 00:00:00 2001 From: Shane Ellis Date: Fri, 15 Jan 2021 18:06:36 -0500 Subject: [PATCH 0543/1080] Update g_game.c --- src/g_game.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/g_game.c b/src/g_game.c index f1cae8cf5..43906e558 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -2974,7 +2974,8 @@ void G_DoReborn(INT32 playernum) // Make sure objectplace is OFF when you first start the level! OP_ResetObjectplace(); - if (player->bot && playernum != consoleplayer) + // Tailsbot + if (player->bot && player->bot != 3 && playernum != consoleplayer) { // Bots respawn next to their master. mobj_t *oldmo = NULL; @@ -2992,6 +2993,28 @@ void G_DoReborn(INT32 playernum) return; } + + // Additional players (e.g. independent bots) in Single Player + if (playernum != consoleplayer && !(netgame || multiplayer)) + { + mobj_t *oldmo = NULL; + // Do nothing if out of lives + if (player->lives <= 0) + return; + + // Otherwise do respawn, starting by removing the player object + if (player->mo) + { + oldmo = player->mo; + P_RemoveMobj(player->mo); + } + // Do spawning + G_SpawnPlayer(playernum); + if (oldmo) + G_ChangePlayerReferences(oldmo, players[playernum].mo); + + return; //Exit function to avoid proccing other SP related mechanics + } if (countdowntimeup || (!(netgame || multiplayer) && (gametyperules & GTR_CAMPAIGN))) resetlevel = true; From 1583bf126b3105f98d647634a4256d22bc1e7e4d Mon Sep 17 00:00:00 2001 From: Shane Ellis Date: Fri, 15 Jan 2021 18:31:09 -0500 Subject: [PATCH 0544/1080] lua habits --- 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 f27ab2914..a660a8a92 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -1840,7 +1840,7 @@ void P_XYMovement(mobj_t *mo) moved = false; if (player) { - if (player->bot and player->bot != 3) + if (player->bot && player->bot != 3) B_MoveBlocked(player); } From 0e9b4acb587491b6f5d0b9c9c898a1c37811de85 Mon Sep 17 00:00:00 2001 From: Shane Ellis Date: Fri, 15 Jan 2021 19:29:03 -0500 Subject: [PATCH 0545/1080] Update g_game.c (Account for bot type 3) --- src/g_game.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/g_game.c b/src/g_game.c index 43906e558..5e2b4e708 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -2627,8 +2627,10 @@ void G_PlayerReborn(INT32 player, boolean betweenmaps) p->totalring = totalring; p->mare = mare; - if (bot) + if (bot == 2) p->bot = 1; // reset to AI-controlled + else + p->bot = bot; p->pity = pity; p->rings = rings; p->spheres = spheres; From b73a15a0bfe628e8c1001dc97aef7d2720940ff5 Mon Sep 17 00:00:00 2001 From: Shane Ellis Date: Fri, 15 Jan 2021 22:50:15 -0500 Subject: [PATCH 0546/1080] fixed G_AddPlayer not sending return value --- src/lua_baselib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 438c20b81..f54662278 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -3479,7 +3479,7 @@ static int lib_gAddPlayer(lua_State *L) } LUA_PushUserdata(L, newplayer, META_PLAYER); - return 0; + return 1; } From e19b0856846bbdcc860c735b9da95082965f604b Mon Sep 17 00:00:00 2001 From: Shane Ellis Date: Fri, 15 Jan 2021 22:56:48 -0500 Subject: [PATCH 0547/1080] Netcode failsafe. At least until I can figure out the best way to produce bot cmds outside of player sends. --- src/b_bot.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/b_bot.c b/src/b_bot.c index d3635f32c..35b14bd78 100644 --- a/src/b_bot.c +++ b/src/b_bot.c @@ -362,6 +362,12 @@ void B_BuildTiccmd(player_t *player, ticcmd_t *cmd) // Bot AI isn't programmed in analog. CV_SetValue(&cv_analog[1], false); + // Bot cmd functions and hooks are not currently netplay compatible + // Necessary failsafe, as a bot in the P2 position in a netgame can inherit + // the last input from a hook triggered in splitscreen or SP. + if (netgame) + return; + // Let Lua scripts build ticcmds if (LUAh_BotTiccmd(player, cmd)) return; From f3ad648874a910cbd7d7dc508ed4b74de29b5373 Mon Sep 17 00:00:00 2001 From: Jaime Ita Passos Date: Sun, 6 Dec 2020 17:46:35 -0300 Subject: [PATCH 0548/1080] Revert "Move a few mobj spawn defaults to its own function" This reverts commit 6f9c48a30560b0f2d89f7202371dfc164015b9ba. # Conflicts: # src/p_mobj.c --- src/p_local.h | 1 - src/p_mobj.c | 87 ++++++++++++++++++++++----------------------------- src/p_saveg.c | 40 +++++++++++++++++++++-- 3 files changed, 75 insertions(+), 53 deletions(-) diff --git a/src/p_local.h b/src/p_local.h index 9359290fa..8caab0d27 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -279,7 +279,6 @@ mobjtype_t P_GetMobjtype(UINT16 mthingtype); void P_RespawnSpecials(void); mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type); -void P_SetMobjSpawnDefaults(mobj_t *mobj); void P_RecalcPrecipInSector(sector_t *sector); void P_PrecipitationEffects(void); diff --git a/src/p_mobj.c b/src/p_mobj.c index 58124fb9b..4945eed48 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -10440,7 +10440,44 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type) mobj->x = x; mobj->y = y; - P_SetMobjSpawnDefaults(mobj); + mobj->radius = info->radius; + mobj->height = info->height; + mobj->flags = info->flags; + + mobj->health = (info->spawnhealth ? info->spawnhealth : 1); + + mobj->reactiontime = info->reactiontime; + + mobj->lastlook = -1; // stuff moved in P_enemy.P_LookForPlayer + + // do not set the state with P_SetMobjState, + // because action routines can not be called yet + st = &states[info->spawnstate]; + + mobj->state = st; + mobj->tics = st->tics; + mobj->sprite = st->sprite; + mobj->frame = st->frame; // FF_FRAMEMASK for frame, and other bits.. + P_SetupStateAnimation(mobj, st); + + mobj->friction = ORIG_FRICTION; + + mobj->movefactor = FRACUNIT; + + // All mobjs are created at 100% scale. + mobj->scale = FRACUNIT; + mobj->destscale = mobj->scale; + mobj->scalespeed = FRACUNIT/12; + + // TODO: Make this a special map header + if ((maptol & TOL_ERZ3) && !(mobj->type == MT_BLACKEGGMAN)) + mobj->destscale = FRACUNIT/2; + + // Sprite rendering + mobj->blendmode = AST_TRANSLUCENT; + mobj->spritexscale = mobj->spriteyscale = mobj->scale; + mobj->spritexoffset = mobj->spriteyoffset = 0; + mobj->floorspriteslope = NULL; // set subsector and/or block links P_SetThingPosition(mobj); @@ -10747,8 +10784,6 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type) mobj->frame &= ~FF_FRAMEMASK; } - st = &states[info->spawnstate]; - // Call action functions when the state is set if (st->action.acp1 && (mobj->flags & MF_RUNSPAWNFUNC)) { @@ -10779,52 +10814,6 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type) return mobj; } -void P_SetMobjSpawnDefaults(mobj_t *mobj) -{ - const mobjinfo_t *info = mobj->info; - state_t *st = &states[info->spawnstate]; - - mobj->radius = info->radius; - mobj->height = info->height; - mobj->flags = info->flags; - - mobj->health = (info->spawnhealth ? info->spawnhealth : 1); - - mobj->reactiontime = info->reactiontime; - - mobj->lastlook = -1; // stuff moved in P_enemy.P_LookForPlayer - - // do not set the state with P_SetMobjState, - // because action routines can not be called yet - mobj->state = st; - mobj->tics = st->tics; - mobj->sprite = st->sprite; - mobj->frame = st->frame; // FF_FRAMEMASK for frame, and other bits.. - P_SetupStateAnimation(mobj, st); - - mobj->friction = ORIG_FRICTION; - - mobj->movefactor = FRACUNIT; - - // All mobjs are created at 100% scale. - mobj->scale = FRACUNIT; - mobj->destscale = mobj->scale; - mobj->scalespeed = FRACUNIT/12; - - // TODO: Make this a special map header - if ((maptol & TOL_ERZ3) && !(mobj->type == MT_BLACKEGGMAN)) - mobj->destscale = FRACUNIT/2; - - // Make sure scale matches destscale immediately when spawned - P_SetScale(mobj, mobj->destscale); - - // Sprite rendering - mobj->blendmode = AST_TRANSLUCENT; - mobj->spritexscale = mobj->spriteyscale = FRACUNIT; - mobj->spritexoffset = mobj->spriteyoffset = 0; - mobj->floorspriteslope = NULL; -} - static precipmobj_t *P_SpawnPrecipMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type) { state_t *st; diff --git a/src/p_saveg.c b/src/p_saveg.c index c1364e08f..03229e740 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -2692,10 +2692,7 @@ static thinker_t* LoadMobjThinker(actionf_p1 thinker) } mobj->type = i; } - mobj->info = &mobjinfo[mobj->type]; - P_SetMobjSpawnDefaults(mobj); - if (diff & MD_POS) { mobj->x = READFIXED(save_p); @@ -2721,21 +2718,35 @@ static thinker_t* LoadMobjThinker(actionf_p1 thinker) if (diff & MD_RADIUS) mobj->radius = READFIXED(save_p); + else + mobj->radius = mobj->info->radius; if (diff & MD_HEIGHT) mobj->height = READFIXED(save_p); + else + mobj->height = mobj->info->height; if (diff & MD_FLAGS) mobj->flags = READUINT32(save_p); + else + mobj->flags = mobj->info->flags; if (diff & MD_FLAGS2) mobj->flags2 = READUINT32(save_p); if (diff & MD_HEALTH) mobj->health = READINT32(save_p); + else + mobj->health = mobj->info->spawnhealth; if (diff & MD_RTIME) mobj->reactiontime = READINT32(save_p); + else + mobj->reactiontime = mobj->info->reactiontime; if (diff & MD_STATE) mobj->state = &states[READUINT16(save_p)]; + else + mobj->state = &states[mobj->info->spawnstate]; if (diff & MD_TICS) mobj->tics = READINT32(save_p); + else + mobj->tics = mobj->state->tics; if (diff & MD_SPRITE) { mobj->sprite = READUINT16(save_p); if (mobj->sprite == SPR_PLAY) @@ -2751,6 +2762,11 @@ static thinker_t* LoadMobjThinker(actionf_p1 thinker) mobj->frame = READUINT32(save_p); mobj->anim_duration = READUINT16(save_p); } + else + { + mobj->frame = mobj->state->frame; + mobj->anim_duration = (UINT16)mobj->state->var2; + } if (diff & MD_EFLAGS) mobj->eflags = READUINT16(save_p); if (diff & MD_PLAYER) @@ -2767,14 +2783,20 @@ static thinker_t* LoadMobjThinker(actionf_p1 thinker) mobj->threshold = READINT32(save_p); if (diff & MD_LASTLOOK) mobj->lastlook = READINT32(save_p); + else + mobj->lastlook = -1; if (diff & MD_TARGET) mobj->target = (mobj_t *)(size_t)READUINT32(save_p); if (diff & MD_TRACER) mobj->tracer = (mobj_t *)(size_t)READUINT32(save_p); if (diff & MD_FRICTION) mobj->friction = READFIXED(save_p); + else + mobj->friction = ORIG_FRICTION; if (diff & MD_MOVEFACTOR) mobj->movefactor = READFIXED(save_p); + else + mobj->movefactor = FRACUNIT; if (diff & MD_FUSE) mobj->fuse = READINT32(save_p); if (diff & MD_WATERTOP) @@ -2783,10 +2805,16 @@ static thinker_t* LoadMobjThinker(actionf_p1 thinker) mobj->waterbottom = READFIXED(save_p); if (diff & MD_SCALE) mobj->scale = READFIXED(save_p); + else + mobj->scale = FRACUNIT; if (diff & MD_DSCALE) mobj->destscale = READFIXED(save_p); + else + mobj->destscale = mobj->scale; if (diff2 & MD2_SCALESPEED) mobj->scalespeed = READFIXED(save_p); + else + mobj->scalespeed = FRACUNIT/12; if (diff2 & MD2_CUSVAL) mobj->cusval = READINT32(save_p); if (diff2 & MD2_CVMEM) @@ -2817,10 +2845,16 @@ static thinker_t* LoadMobjThinker(actionf_p1 thinker) mobj->renderflags = READUINT32(save_p); if (diff2 & MD2_BLENDMODE) mobj->blendmode = READINT32(save_p); + else + mobj->blendmode = AST_TRANSLUCENT; if (diff2 & MD2_SPRITEXSCALE) mobj->spritexscale = READFIXED(save_p); + else + mobj->spritexscale = FRACUNIT; if (diff2 & MD2_SPRITEYSCALE) mobj->spriteyscale = READFIXED(save_p); + else + mobj->spriteyscale = FRACUNIT; if (diff2 & MD2_SPRITEXOFFSET) mobj->spritexoffset = READFIXED(save_p); if (diff2 & MD2_SPRITEYOFFSET) From ce8e389a2d9cec8c36f43a9573f0d9a29bf50d18 Mon Sep 17 00:00:00 2001 From: Shane Ellis Date: Sat, 23 Jan 2021 09:49:57 -0500 Subject: [PATCH 0549/1080] Add lua player.botleader and player.buttons_last (read+write) --- src/lua_playerlib.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/lua_playerlib.c b/src/lua_playerlib.c index 0eb54808f..a8dc64a15 100644 --- a/src/lua_playerlib.c +++ b/src/lua_playerlib.c @@ -370,6 +370,10 @@ static int player_get(lua_State *L) lua_pushboolean(L, plr->outofcoop); else if (fastcmp(field,"bot")) lua_pushinteger(L, plr->bot); + else if (fastcmp(field,"botleader")) + LUA_PushUserdata(L, plr->botleader, META_PLAYER); + else if (fastcmp(field,"buttons_last")) + lua_pushinteger(L, plr->buttons_last); else if (fastcmp(field,"jointime")) lua_pushinteger(L, plr->jointime); else if (fastcmp(field,"quittime")) From c391d76c11331dec29f3eedddb9bcc9344eb82e7 Mon Sep 17 00:00:00 2001 From: Shane Ellis Date: Sat, 23 Jan 2021 10:06:47 -0500 Subject: [PATCH 0550/1080] buttons_last -> lastbuttons --- src/lua_playerlib.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/lua_playerlib.c b/src/lua_playerlib.c index a8dc64a15..51eb4ac0c 100644 --- a/src/lua_playerlib.c +++ b/src/lua_playerlib.c @@ -372,8 +372,8 @@ static int player_get(lua_State *L) lua_pushinteger(L, plr->bot); else if (fastcmp(field,"botleader")) LUA_PushUserdata(L, plr->botleader, META_PLAYER); - else if (fastcmp(field,"buttons_last")) - lua_pushinteger(L, plr->buttons_last); + else if (fastcmp(field,"lastbuttons")) + lua_pushinteger(L, plr->lastbuttons); else if (fastcmp(field,"jointime")) lua_pushinteger(L, plr->jointime); else if (fastcmp(field,"quittime")) @@ -723,6 +723,15 @@ static int player_set(lua_State *L) plr->outofcoop = lua_toboolean(L, 3); else if (fastcmp(field,"bot")) return NOSET; + else if (fastcmp(field,"botleader")) + { + player_t *player = NULL; + if (!lua_isnil(L, 3)) + player = *((player_t **)luaL_checkudata(L, 3, META_PLAYER)); + plr->botleader = player; + } + else if (fastcmp(field,"lastbuttons")) + plr->lastbuttons = (UINT16)luaL_checkinteger(L, 3); else if (fastcmp(field,"jointime")) plr->jointime = (tic_t)luaL_checkinteger(L, 3); else if (fastcmp(field,"quittime")) From 2abf89e8000b6dbda26d5dd59b9306c5d32624b6 Mon Sep 17 00:00:00 2001 From: Shane Ellis Date: Sat, 23 Jan 2021 10:13:16 -0500 Subject: [PATCH 0551/1080] Update G_AddPlayer() --- src/lua_baselib.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index f54662278..525ce89ec 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -3432,8 +3432,7 @@ static int lib_gAddPlayer(lua_State *L) newplayernum = i; - //if (!splitscreen && !botingame) - CL_ClearPlayer(newplayernum); + CL_ClearPlayer(newplayernum); playeringame[newplayernum] = true; G_AddPlayer(newplayernum); @@ -3442,30 +3441,34 @@ static int lib_gAddPlayer(lua_State *L) newplayer->jointime = 0; newplayer->quittime = 0; - // I hereby name you Bot X + // Set the bot name (defaults to Bot #) strcpy(player_names[newplayernum], va("Bot %d", botcount)); - // Read the skin string! + // Read the skin argument (defaults to Sonic) if (!lua_isnoneornil(L, 1)) { skinnum = R_SkinAvailable(luaL_checkstring(L, 1)); skinnum = skinnum < 0 ? 0 : skinnum; } - // Read the color! + // Read the color (defaults to skin prefcolor) if (!lua_isnoneornil(L, 2)) newplayer->skincolor = R_GetColorByName(luaL_checkstring(L, 2)); else newplayer->skincolor = skins[newplayer->skin].prefcolor; - // Read the bot name, if given! + // Read the bot name, if given if (!lua_isnoneornil(L, 3)) strcpy(player_names[newplayernum], luaL_checkstring(L, 3)); bot = luaL_optinteger(L, 4, 3); newplayer->bot = (bot >= 0 && bot <= 3) ? bot : 3; - - // Set the skin (needed to set bot first!) + + // If our bot is a 2P type, we'll need to set its leader so it can spawn + if (newplayer->bot == BOT_2PAI || newplayer->bot == BOT_2PHUMAN) + B_UpdateBotleader(newplayer); + + // Set the skin (can't do this until AFTER bot type is set!) SetPlayerSkinByNum(newplayernum, skinnum); From 2e528216ac855fbfdf9f73df3a534a237936ccbd Mon Sep 17 00:00:00 2001 From: Shane Ellis Date: Sat, 23 Jan 2021 10:15:33 -0500 Subject: [PATCH 0552/1080] Updated references to player->bot --- src/p_user.c | 48 ++++++++++++++++++++++++++---------------------- 1 file changed, 26 insertions(+), 22 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index 9e86e2d73..c631f49b2 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -776,8 +776,8 @@ void P_NightserizePlayer(player_t *player, INT32 nighttime) { UINT8 oldmare, oldmarelap, oldmarebonuslap; - // Bots can't be NiGHTSerized, silly!1 :P - if (player->bot && player->bot != 3) + //! Bots can't be NiGHTSerized, silly!1 :P + if (player->bot == BOT_2PAI || player->bot || BOT_2PHUMAN) return; if (player->powers[pw_carry] != CR_NIGHTSMODE) @@ -1188,9 +1188,9 @@ void P_GivePlayerRings(player_t *player, INT32 num_rings) { if (!player) return; - - if (player->bot && player->bot != 3) - player = &players[consoleplayer]; + //! + if ((player->bot == BOT_2PAI || player->bot == BOT_2PHUMAN) && player->botleader) + player = player->botleader; if (!player->mo) return; @@ -1234,8 +1234,8 @@ void P_GivePlayerSpheres(player_t *player, INT32 num_spheres) if (!player) return; - if (player->bot && player->bot != 3) - player = &players[consoleplayer]; + if ((player->bot == BOT_2PAI || player->bot == BOT_2PHUMAN) && player->botleader) + player = player->botleader; if (!player->mo) return; @@ -1261,8 +1261,8 @@ void P_GivePlayerLives(player_t *player, INT32 numlives) if (!player) return; - if (player->bot && player->bot != 3) - player = &players[consoleplayer]; + if ((player->bot == BOT_2PAI || player->bot == BOT_2PHUMAN) && player->botleader) + player = player->botleader; if (gamestate == GS_LEVEL) { @@ -1367,8 +1367,8 @@ void P_AddPlayerScore(player_t *player, UINT32 amount) { UINT32 oldscore; - if (player->bot && player->bot != 3) - player = &players[consoleplayer]; + if ((player->bot == BOT_2PAI || player->bot == BOT_2PHUMAN) && player->botleader) + player = player->botleader; // NiGHTS does it different! if (gamestate == GS_LEVEL && mapheaderinfo[gamemap-1]->typeoflevel & TOL_NIGHTS) @@ -5370,7 +5370,7 @@ static void P_DoJumpStuff(player_t *player, ticcmd_t *cmd) player->powers[pw_tailsfly] = tailsflytics + 1; // Set the fly timer player->pflags &= ~(PF_JUMPED|PF_NOJUMPDAMAGE|PF_SPINNING|PF_STARTDASH); - if (player->bot == 1) + if (player->bot == BOT_2PAI) player->pflags |= PF_THOKKED; else player->pflags |= (PF_THOKKED|PF_CANCARRY); @@ -5957,7 +5957,8 @@ static void P_3dMovement(player_t *player) acceleration = 96 + (FixedDiv(player->speed, player->mo->scale)>>FRACBITS) * 40; topspeed = normalspd; } - else if (player->bot && player->bot != 3) + //! Kill this! + /* else if (player->bot == BOT_2PAI || player->bot == BOT_2PHUMAN) { // Bot steals player 1's stats normalspd = FixedMul(players[consoleplayer].normalspeed, player->mo->scale); thrustfactor = players[consoleplayer].thrustfactor; @@ -5972,7 +5973,7 @@ static void P_3dMovement(player_t *player) } else topspeed = normalspd; - } + } */ else { if (player->powers[pw_super] || player->powers[pw_sneakers]) @@ -9497,7 +9498,7 @@ static void P_DeathThink(player_t *player) if (player->deadtimer < INT32_MAX) player->deadtimer++; - if (player->bot && player->bot != 3) // don't allow bots to do any of the below, B_CheckRespawn does all they need for respawning already + if (player->bot == BOT_2PAI || player->bot == BOT_2PHUMAN) // don't allow followbots to do any of the below, B_CheckRespawn does all they need for respawning already goto notrealplayer; // continue logic @@ -11473,6 +11474,9 @@ void P_PlayerThink(player_t *player) I_Error("p_playerthink: players[%s].mo == NULL", sizeu1(playeri)); #endif + //! Reset terrain blocked status for this frame + player->blocked = false; + // todo: Figure out what is actually causing these problems in the first place... if (player->mo->health <= 0 && player->playerstate == PST_LIVE) //you should be DEAD! { @@ -11480,7 +11484,7 @@ void P_PlayerThink(player_t *player) player->playerstate = PST_DEAD; } - if (player->bot && player->bot != 3) + if (player->bot == BOT_2PAI || player->bot == BOT_2PHUMAN) { if (player->playerstate == PST_LIVE || player->playerstate == PST_DEAD) { @@ -11623,8 +11627,8 @@ void P_PlayerThink(player_t *player) INT32 i; for (i = 0; i < MAXPLAYERS; i++) - { - if (!playeringame[i] || players[i].spectator || players[i].bot) + { //! + if (!playeringame[i] || players[i].spectator || players[i].bot == BOT_2PAI || players[i].bot == BOT_2PHUMAN) continue; if (players[i].lives <= 0) continue; @@ -11655,8 +11659,8 @@ void P_PlayerThink(player_t *player) INT32 i, total = 0, exiting = 0; for (i = 0; i < MAXPLAYERS; i++) - { - if (!playeringame[i] || players[i].spectator || players[i].bot) + { //! + if (!playeringame[i] || players[i].spectator || players[i].bot == BOT_2PAI || players[i].bot == BOT_2PHUMAN) continue; if (players[i].quittime > 30 * TICRATE) continue; @@ -12596,8 +12600,8 @@ void P_PlayerAfterThink(player_t *player) player->mo->momy = tails->momy; player->mo->momz = tails->momz; } - - if (G_CoopGametype() && tails->player && tails->player->bot != 1) + //! + if (G_CoopGametype() && tails->player && tails->player->bot != BOT_2PAI) { player->mo->angle = tails->angle; From 2016caa70b584286af7aff80e83eb63c32f16534 Mon Sep 17 00:00:00 2001 From: Shane Ellis Date: Sat, 23 Jan 2021 10:16:27 -0500 Subject: [PATCH 0553/1080] Update references to player->bot --- src/p_mobj.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index a660a8a92..43d81077e 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -1839,10 +1839,9 @@ void P_XYMovement(mobj_t *mo) // blocked move moved = false; - if (player) { - if (player->bot && player->bot != 3) - B_MoveBlocked(player); - } + //!!! + if (player) + B_MoveBlocked(player); if (LUAh_MobjMoveBlocked(mo)) { @@ -4135,7 +4134,7 @@ boolean P_BossTargetPlayer(mobj_t *actor, boolean closest) player = &players[actor->lastlook]; - if (player->pflags & PF_INVIS || (player->bot && player->bot != 3) || player->spectator) + if (player->pflags & PF_INVIS || player->bot == BOT_2PAI || player->bot == BOT_2PHUMAN || player->spectator) continue; // ignore notarget if (!player->mo || P_MobjWasRemoved(player->mo)) @@ -4176,7 +4175,7 @@ boolean P_SupermanLook4Players(mobj_t *actor) if (players[c].pflags & PF_INVIS) continue; // ignore notarget - if (!players[c].mo || players[c].bot) + if (!players[c].mo || players[c].bot == BOT_2PAI || players[c].bot == BOT_2PHUMAN) continue; if (players[c].mo->health <= 0) @@ -7307,7 +7306,7 @@ static void P_RosySceneryThink(mobj_t *mobj) continue; if (!players[i].mo) continue; - if (players[i].bot) + if (players[i].bot == BOT_2PAI || players[i].bot == BOT_2PHUMAN) continue; if (!players[i].mo->health) continue; From fd536e91a3bb73c44adcc13486631c18e83d9620 Mon Sep 17 00:00:00 2001 From: Shane Ellis Date: Sat, 23 Jan 2021 10:17:05 -0500 Subject: [PATCH 0554/1080] void B_UpdateBotleader(player_t *player); --- src/b_bot.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/b_bot.h b/src/b_bot.h index 2806bd68f..53114df48 100644 --- a/src/b_bot.h +++ b/src/b_bot.h @@ -10,6 +10,7 @@ /// \file b_bot.h /// \brief Basic bot handling +void B_UpdateBotleader(player_t *player); void B_BuildTiccmd(player_t *player, ticcmd_t *cmd); void B_KeysToTiccmd(mobj_t *mo, ticcmd_t *cmd, boolean forward, boolean backward, boolean left, boolean right, boolean strafeleft, boolean straferight, boolean jump, boolean spin); boolean B_CheckRespawn(player_t *player); From b8fea55f6777d3fa9891d845c6d1430f66acb363 Mon Sep 17 00:00:00 2001 From: Shane Ellis Date: Sat, 23 Jan 2021 10:25:35 -0500 Subject: [PATCH 0555/1080] Update b_bot.c --- src/b_bot.c | 251 +++++++++++++++++++++++++++++----------------------- 1 file changed, 139 insertions(+), 112 deletions(-) diff --git a/src/b_bot.c b/src/b_bot.c index 35b14bd78..151aaa633 100644 --- a/src/b_bot.c +++ b/src/b_bot.c @@ -18,29 +18,41 @@ #include "b_bot.h" #include "lua_hook.h" -// If you want multiple bots, variables like this will -// have to be stuffed in something accessible through player_t. -static boolean lastForward = false; -static boolean lastBlocked = false; -static boolean blocked = false; - -static boolean jump_last = false; -static boolean spin_last = false; -static UINT8 anxiety = 0; -static boolean panic = false; -static UINT8 flymode = 0; -static boolean spinmode = false; -static boolean thinkfly = false; - -static inline void B_ResetAI(void) +void B_UpdateBotleader(player_t *player) { - jump_last = false; - spin_last = false; - anxiety = 0; - panic = false; - flymode = 0; - spinmode = false; - thinkfly = false; + UINT32 i; + fixed_t dist; + fixed_t neardist = INT32_MAX; + player_t *nearplayer = NULL; + //Find new botleader + //if (!player->botleader) + //{ + for (i = 0; i < MAXPLAYERS; i++) + { + if (players[i].bot || players[i].playerstate != PST_LIVE || players[i].spectator || !players[i].mo) + continue; + if (!player->mo) //Can't do distance calculations if there's no player object, so we'll just take the first we find + { + player->botleader = &players[i]; + return; + } + //Update best candidate based on nearest distance + dist = R_PointToDist2(player->mo->x, player->mo->y, players[i].mo->x, players[i].mo->y); + if (neardist > dist) + { + neardist = dist; + nearplayer = &players[i]; + } + } + //Set botleader to best candidate (or null if none available) + player->botleader = nearplayer; + //} +} + +static inline void B_ResetAI(botmem_t *mem) +{ + mem->thinkstate = AI_FOLLOW; + mem->catchup_tics = 0; } static void B_BuildTailsTiccmd(mobj_t *sonic, mobj_t *tails, ticcmd_t *cmd) @@ -49,39 +61,48 @@ static void B_BuildTailsTiccmd(mobj_t *sonic, mobj_t *tails, ticcmd_t *cmd) player_t *player = sonic->player, *bot = tails->player; ticcmd_t *pcmd = &player->cmd; - boolean water = tails->eflags & MFE_UNDERWATER; + botmem_t *mem = &bot->botmem; + boolean water = (tails->eflags & MFE_UNDERWATER); SINT8 flip = P_MobjFlip(tails); boolean _2d = (tails->flags2 & MF2_TWOD) || twodlevel; fixed_t scale = tails->scale; + boolean jump_last = (bot->lastbuttons & BT_JUMP); + boolean spin_last = (bot->lastbuttons & BT_SPIN); fixed_t dist = P_AproxDistance(sonic->x - tails->x, sonic->y - tails->y); fixed_t zdist = flip * (sonic->z - tails->z); angle_t ang = sonic->angle; fixed_t pmom = P_AproxDistance(sonic->momx, sonic->momy); fixed_t bmom = P_AproxDistance(tails->momx, tails->momy); - fixed_t followmax = 128 * 8 * scale; // Max follow distance before AI begins to enter "panic" state + fixed_t followmax = 128 * 8 * scale; // Max follow distance before AI begins to enter catchup state fixed_t followthres = 92 * scale; // Distance that AI will try to reach fixed_t followmin = 32 * scale; fixed_t comfortheight = 96 * scale; fixed_t touchdist = 24 * scale; boolean stalled = (bmom < scale >> 1) && dist > followthres; // Helps to see if the AI is having trouble catching up boolean samepos = (sonic->x == tails->x && sonic->y == tails->y); - + boolean blocked = bot->blocked; + if (!samepos) ang = R_PointToAngle2(tails->x, tails->y, sonic->x, sonic->y); - // We can't follow Sonic if he's not around! - if (!sonic || sonic->health <= 0) - return; - // Lua can handle it! if (LUAh_BotAI(sonic, tails, cmd)) return; + // We can't follow Sonic if he's not around! + if (!sonic || sonic->health <= 0) + { + mem->thinkstate = AI_STANDBY; + return; + } + else if (mem->thinkstate == AI_STANDBY) + mem->thinkstate = AI_FOLLOW; + if (tails->player->powers[pw_carry] == CR_MACESPIN || tails->player->powers[pw_carry] == CR_GENERIC) { boolean isrelevant = (sonic->player->powers[pw_carry] == CR_MACESPIN || sonic->player->powers[pw_carry] == CR_GENERIC); - dist = P_AproxDistance(tails->x-sonic->x, tails->y-sonic->y); + //dist = P_AproxDistance(tails->x-sonic->x, tails->y-sonic->y); //! This is totally redundant. if (sonic->player->cmd.buttons & BT_JUMP && (sonic->player->pflags & PF_JUMPED) && isrelevant) cmd->buttons |= BT_JUMP; if (isrelevant) @@ -103,56 +124,57 @@ static void B_BuildTailsTiccmd(mobj_t *sonic, mobj_t *tails, ticcmd_t *cmd) followmin = 0; followthres = 16*scale; followmax >>= 1; - thinkfly = false; + if (mem->thinkstate == AI_THINKFLY) + mem->thinkstate = AI_FOLLOW; } - // Check anxiety - if (spinmode) + // Update catchup_tics + if (mem->thinkstate == AI_SPINFOLLOW) { - anxiety = 0; - panic = false; + mem-> catchup_tics = 0; } else if (dist > followmax || zdist > comfortheight || stalled) { - anxiety = min(anxiety + 2, 70); - if (anxiety >= 70) - panic = true; + mem-> catchup_tics = min(mem-> catchup_tics + 2, 70); + if (mem-> catchup_tics >= 70) + mem->thinkstate = AI_CATCHUP; } else { - anxiety = max(anxiety - 1, 0); - panic = false; + mem-> catchup_tics = max(mem-> catchup_tics - 1, 0); + if (mem->thinkstate == AI_CATCHUP) + mem->thinkstate = AI_FOLLOW; } // Orientation + // cmd->angleturn won't be relative to player angle, since we're not going through G_BuildTiccmd. if (bot->pflags & (PF_SPINNING|PF_STARTDASH)) { - cmd->angleturn = (sonic->angle - tails->angle) >> 16; // NOT FRACBITS DAMNIT + cmd->angleturn = (sonic->angle) >> 16; // NOT FRACBITS DAMNIT } - else if (flymode == 2) + else if (mem->thinkstate == AI_FLYCARRY) { - cmd->angleturn = sonic->player->cmd.angleturn - (tails->angle >> 16); + cmd->angleturn = sonic->player->cmd.angleturn; } else { - cmd->angleturn = (ang - tails->angle) >> 16; // NOT FRACBITS DAMNIT + cmd->angleturn = (ang) >> 16; // NOT FRACBITS DAMNIT } // ******** // FLY MODE - // spinmode check - if (spinmode || player->exiting) - thinkfly = false; + // exiting check + if (player->exiting && mem->thinkstate == AI_THINKFLY) + mem->thinkstate = AI_FOLLOW; else { // Activate co-op flight - if (thinkfly && player->pflags & PF_JUMPED) + if (mem->thinkstate == AI_THINKFLY && player->pflags & PF_JUMPED) { if (!jump_last) { jump = true; - flymode = 1; - thinkfly = false; + mem->thinkstate = AI_FLYSTANDBY; bot->pflags |= PF_CANCARRY; } } @@ -165,20 +187,19 @@ static void B_BuildTailsTiccmd(mobj_t *sonic, mobj_t *tails, ticcmd_t *cmd) && P_IsObjectOnGround(sonic) && P_IsObjectOnGround(tails) && !(player->pflags & PF_STASIS) && bot->charability == CA_FLY) - thinkfly = true; - else - thinkfly = false; + mem->thinkstate = AI_THINKFLY; + else if (mem->thinkstate == AI_THINKFLY) + mem->thinkstate = AI_FOLLOW; // Set carried state if (player->powers[pw_carry] == CR_PLAYER && sonic->tracer == tails) { - flymode = 2; + mem->thinkstate = AI_FLYCARRY; } // Ready for takeoff - if (flymode == 1) + if (mem->thinkstate == AI_FLYSTANDBY) { - thinkfly = false; if (zdist < -64*scale || (flip * tails->momz) > scale) // Make sure we're not too high up spin = true; else if (!jump_last) @@ -186,10 +207,10 @@ static void B_BuildTailsTiccmd(mobj_t *sonic, mobj_t *tails, ticcmd_t *cmd) // Abort if the player moves away or spins if (dist > followthres || player->dashspeed) - flymode = 0; + mem->thinkstate = AI_FOLLOW; } // Read player inputs while carrying - else if (flymode == 2) + else if (mem->thinkstate == AI_FLYCARRY) { cmd->forwardmove = pcmd->forwardmove; cmd->sidemove = pcmd->sidemove; @@ -203,19 +224,19 @@ static void B_BuildTailsTiccmd(mobj_t *sonic, mobj_t *tails, ticcmd_t *cmd) // End flymode if (player->powers[pw_carry] != CR_PLAYER) { - flymode = 0; + mem->thinkstate = AI_FOLLOW; } } } - if (flymode && P_IsObjectOnGround(tails) && !(pcmd->buttons & BT_JUMP)) - flymode = 0; + if (P_IsObjectOnGround(tails) && !(pcmd->buttons & BT_JUMP) && (mem->thinkstate == AI_FLYSTANDBY || mem->thinkstate == AI_FLYCARRY)) + mem->thinkstate = AI_FOLLOW; // ******** // SPINNING - if (panic || flymode || !(player->pflags & PF_SPINNING) || (player->pflags & PF_JUMPED)) - spinmode = false; - else + if (!(player->pflags & (PF_SPINNING|PF_STARTDASH)) && mem->thinkstate == AI_SPINFOLLOW) + mem->thinkstate = AI_FOLLOW; + else if (mem->thinkstate == AI_FOLLOW || mem->thinkstate == AI_SPINFOLLOW) { if (!_2d) { @@ -224,21 +245,21 @@ static void B_BuildTailsTiccmd(mobj_t *sonic, mobj_t *tails, ticcmd_t *cmd) { if (dist < followthres && dist > touchdist) // Do positioning { - cmd->angleturn = (ang - tails->angle) >> 16; // NOT FRACBITS DAMNIT + cmd->angleturn = (ang) >> 16; // NOT FRACBITS DAMNIT cmd->forwardmove = 50; - spinmode = true; + mem->thinkstate = AI_SPINFOLLOW; } else if (dist < touchdist) { if (!bmom && (!(bot->pflags & PF_SPINNING) || (bot->dashspeed && bot->pflags & PF_SPINNING))) { - cmd->angleturn = (sonic->angle - tails->angle) >> 16; // NOT FRACBITS DAMNIT + cmd->angleturn = (sonic->angle) >> 16; // NOT FRACBITS DAMNIT spin = true; } - spinmode = true; + mem->thinkstate = AI_SPINFOLLOW; } else - spinmode = false; + mem->thinkstate = AI_FOLLOW; } // Spin else if (player->dashspeed == bot->dashspeed && player->pflags & PF_SPINNING) @@ -246,12 +267,12 @@ static void B_BuildTailsTiccmd(mobj_t *sonic, mobj_t *tails, ticcmd_t *cmd) if (bot->pflags & PF_SPINNING || !spin_last) { spin = true; - cmd->angleturn = (sonic->angle - tails->angle) >> 16; // NOT FRACBITS DAMNIT + cmd->angleturn = (sonic->angle) >> 16; // NOT FRACBITS DAMNIT cmd->forwardmove = MAXPLMOVE; - spinmode = true; + mem->thinkstate = AI_SPINFOLLOW; } else - spinmode = false; + mem->thinkstate = AI_FOLLOW; } } // 2D mode @@ -261,17 +282,19 @@ static void B_BuildTailsTiccmd(mobj_t *sonic, mobj_t *tails, ticcmd_t *cmd) && ((bot->pflags & PF_SPINNING) || !spin_last)) { spin = true; - spinmode = true; + mem->thinkstate = AI_SPINFOLLOW; } + else + mem->thinkstate = AI_FOLLOW; } } // ******** // FOLLOW - if (!(flymode || spinmode)) + if (mem->thinkstate == AI_FOLLOW || mem->thinkstate == AI_CATCHUP) { // Too far - if (panic || dist > followthres) + if (mem->thinkstate == AI_CATCHUP || dist > followthres) { if (!_2d) cmd->forwardmove = MAXPLMOVE; @@ -281,7 +304,7 @@ static void B_BuildTailsTiccmd(mobj_t *sonic, mobj_t *tails, ticcmd_t *cmd) cmd->sidemove = -MAXPLMOVE; } // Within threshold - else if (!panic && dist > followmin && abs(zdist) < 192*scale) + else if (dist > followmin && abs(zdist) < 192*scale) { if (!_2d) cmd->forwardmove = FixedHypot(pcmd->forwardmove, pcmd->sidemove); @@ -292,7 +315,7 @@ static void B_BuildTailsTiccmd(mobj_t *sonic, mobj_t *tails, ticcmd_t *cmd) else if (dist < followmin) { // Copy inputs - cmd->angleturn = (sonic->angle - tails->angle) >> 16; // NOT FRACBITS DAMNIT + cmd->angleturn = (sonic->angle) >> 16; // NOT FRACBITS DAMNIT bot->drawangle = ang; cmd->forwardmove = 8 * pcmd->forwardmove / 10; cmd->sidemove = 8 * pcmd->sidemove / 10; @@ -301,7 +324,7 @@ static void B_BuildTailsTiccmd(mobj_t *sonic, mobj_t *tails, ticcmd_t *cmd) // ******** // JUMP - if (!(flymode || spinmode)) + if (mem->thinkstate == AI_FOLLOW || mem->thinkstate == AI_CATCHUP || (mem->thinkstate == AI_SPINFOLLOW && player->pflags & PF_JUMPED)) { // Flying catch-up if (bot->pflags & PF_THOKKED) @@ -319,31 +342,30 @@ static void B_BuildTailsTiccmd(mobj_t *sonic, mobj_t *tails, ticcmd_t *cmd) // Start jump else if (!jump_last && !(bot->pflags & PF_JUMPED) //&& !(player->pflags & PF_SPINNING) && ((zdist > 32*scale && player->pflags & PF_JUMPED) // Following - || (zdist > 64*scale && panic) // Vertical catch-up - || (stalled && anxiety > 20 && bot->powers[pw_carry] == CR_NONE) + || (zdist > 64*scale && mem->thinkstate == AI_CATCHUP) // Vertical catch-up + || (stalled && mem-> catchup_tics > 20 && bot->powers[pw_carry] == CR_NONE) //|| (bmom < scale>>3 && dist > followthres && !(bot->powers[pw_carry])) // Stopped & not in carry state || (bot->pflags & PF_SPINNING && !(bot->pflags & PF_JUMPED)))) // Spinning jump = true; // Hold jump - else if (bot->pflags & PF_JUMPED && jump_last && tails->momz*flip > 0 && (zdist > 0 || panic)) + else if (bot->pflags & PF_JUMPED && jump_last && tails->momz*flip > 0 && (zdist > 0 || mem->thinkstate == AI_CATCHUP)) jump = true; // Start flying - else if (bot->pflags & PF_JUMPED && panic && !jump_last && bot->charability == CA_FLY) + else if (bot->pflags & PF_JUMPED && mem->thinkstate == AI_CATCHUP && !jump_last && bot->charability == CA_FLY) jump = true; } // ******** // HISTORY - jump_last = jump; - spin_last = spin; + //jump_last = jump; + //spin_last = spin; // Turn the virtual keypresses into ticcmd_t. B_KeysToTiccmd(tails, cmd, forward, backward, left, right, false, false, jump, spin); // Update our status - lastForward = forward; - lastBlocked = blocked; - blocked = false; + mem->lastForward = forward; + mem->lastBlocked = blocked; } void B_BuildTiccmd(player_t *player, ticcmd_t *cmd) @@ -362,32 +384,31 @@ void B_BuildTiccmd(player_t *player, ticcmd_t *cmd) // Bot AI isn't programmed in analog. CV_SetValue(&cv_analog[1], false); - // Bot cmd functions and hooks are not currently netplay compatible - // Necessary failsafe, as a bot in the P2 position in a netgame can inherit - // the last input from a hook triggered in splitscreen or SP. - if (netgame) - return; - // Let Lua scripts build ticcmds if (LUAh_BotTiccmd(player, cmd)) return; - // We don't have any main character AI, sorry. D: - if (player-players == consoleplayer) + // Make sure we have a valid main character to follow + B_UpdateBotleader(player); + if (!player->botleader) return; - // Basic Tails AI - B_BuildTailsTiccmd(players[consoleplayer].mo, player->mo, cmd); + // Single Player Tails AI + //B_BuildTailsTiccmd(players[consoleplayer].mo, player->mo, cmd); + B_BuildTailsTiccmd(player->botleader->mo, player->mo, cmd); } void B_KeysToTiccmd(mobj_t *mo, ticcmd_t *cmd, boolean forward, boolean backward, boolean left, boolean right, boolean strafeleft, boolean straferight, boolean jump, boolean spin) { + player_t *player = mo->player; // don't try to do stuff if your sonic is in a minecart or something - if (players[consoleplayer].powers[pw_carry] && players[consoleplayer].powers[pw_carry] != CR_PLAYER) + //if (players[consoleplayer].powers[pw_carry] && players[consoleplayer].powers[pw_carry] != CR_PLAYER) + //!!! + if (&player->botleader && player->botleader->powers[pw_carry] && player->botleader->powers[pw_carry] != CR_PLAYER) return; // Turn the virtual keypresses into ticcmd_t. if (twodlevel || mo->flags2 & MF2_TWOD) { - if (players[consoleplayer].climbing + if (player->botleader->climbing || mo->player->pflags & PF_GLIDING) { // Don't mess with bot inputs during these unhandled movement conditions. // The normal AI doesn't use abilities, so custom AI should be sending us exactly what it wants anyway. @@ -426,10 +447,10 @@ void B_KeysToTiccmd(mobj_t *mo, ticcmd_t *cmd, boolean forward, boolean backward cmd->forwardmove += MAXPLMOVE<>16; if (backward) cmd->forwardmove -= MAXPLMOVE<>16; - if (left) + if (left) cmd->angleturn += 1280; if (right) - cmd->angleturn -= 1280; + cmd->angleturn -= 1280; if (strafeleft) cmd->sidemove -= MAXPLMOVE<>16; if (straferight) @@ -453,14 +474,19 @@ void B_KeysToTiccmd(mobj_t *mo, ticcmd_t *cmd, boolean forward, boolean backward void B_MoveBlocked(player_t *player) { (void)player; - blocked = true; + player->blocked = true; } boolean B_CheckRespawn(player_t *player) { - mobj_t *sonic = players[consoleplayer].mo; + mobj_t *sonic; mobj_t *tails = player->mo; + //We don't have a main player to spawn to! + if (!player->botleader) + return false; + + sonic = player->botleader->mo; // We can't follow Sonic if he's not around! if (!sonic || sonic->health <= 0) return false; @@ -511,15 +537,19 @@ void B_RespawnBot(INT32 playernum) { player_t *player = &players[playernum]; fixed_t x,y,z; - mobj_t *sonic = players[consoleplayer].mo; + mobj_t *sonic; mobj_t *tails; + if (!player->botleader) + return; + + sonic = player->botleader->mo; if (!sonic || sonic->health <= 0) return; - B_ResetAI(); + B_ResetAI(&player->botmem); - player->bot = 1; + player->bot = BOT_2PAI; P_SpawnPlayer(playernum); tails = player->mo; @@ -546,10 +576,7 @@ void B_RespawnBot(INT32 playernum) player->powers[pw_spacetime] = sonic->player->powers[pw_spacetime]; player->powers[pw_gravityboots] = sonic->player->powers[pw_gravityboots]; player->powers[pw_nocontrol] = sonic->player->powers[pw_nocontrol]; - player->acceleration = sonic->player->acceleration; - player->accelstart = sonic->player->accelstart; - player->thrustfactor = sonic->player->thrustfactor; - player->normalspeed = sonic->player->normalspeed; + //!!! Nuke the speed equivalencies player->pflags |= PF_AUTOBRAKE|(sonic->player->pflags & PF_DIRECTIONCHAR); P_TeleportMove(tails, x, y, z); @@ -567,11 +594,11 @@ void B_RespawnBot(INT32 playernum) void B_HandleFlightIndicator(player_t *player) { mobj_t *tails = player->mo; - + botmem_t *mem = &player->botmem; if (!tails) return; - if (thinkfly && player->bot == 1 && tails->health) + if (mem->thinkstate == AI_THINKFLY && player->bot == BOT_2PAI && tails->health) { if (!tails->hnext) { From 4e47f240adc21eab710b6c17673d6053539579eb Mon Sep 17 00:00:00 2001 From: Shane Ellis Date: Sat, 23 Jan 2021 10:30:07 -0500 Subject: [PATCH 0556/1080] Add new botstuffs --- src/d_player.h | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/src/d_player.h b/src/d_player.h index 2e7afed88..bb206c889 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -313,9 +313,43 @@ typedef enum RW_RAIL = 32 } ringweapons_t; +//Bot types +typedef enum +{ + BOT_NONE = 0, + BOT_2PAI, + BOT_2PHUMAN, + BOT_MPAI +} bottype_t; + +//AI states +typedef enum +{ + AI_STANDBY = 0, + AI_FOLLOW, + AI_CATCHUP, + AI_THINKFLY, + AI_FLYSTANDBY, + AI_FLYCARRY, + AI_SPINFOLLOW +} aistatetype_t; + + // ======================================================================== // PLAYER STRUCTURE // ======================================================================== + +//Bot memory struct +typedef struct botmem_s +{ + boolean lastForward; + boolean lastBlocked; + boolean blocked; + UINT8 catchup_tics; + UINT8 thinkstate; +} botmem_t; + +//Main struct typedef struct player_s { mobj_t *mo; @@ -526,7 +560,11 @@ typedef struct player_s boolean spectator; boolean outofcoop; UINT8 bot; - + struct player_s *botleader; + UINT16 lastbuttons; + botmem_t botmem; + boolean blocked; + tic_t jointime; // Timer when player joins game to change skin/color tic_t quittime; // Time elapsed since user disconnected, zero if connected #ifdef HWRENDER From 25bf4b54e2cccb666acb143aecaaa6f26993fc88 Mon Sep 17 00:00:00 2001 From: Shane Ellis Date: Sat, 23 Jan 2021 10:36:44 -0500 Subject: [PATCH 0557/1080] Restructured botticcmds into G_Ticker --- src/g_game.c | 88 ++++++++++++++++++++++++++++++++-------------------- 1 file changed, 54 insertions(+), 34 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index 5e2b4e708..3d6fc52b7 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1087,7 +1087,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) boolean turnleft, turnright, strafelkey, straferkey, movefkey, movebkey, mouseaiming, analogjoystickmove, gamepadjoystickmove, thisjoyaiming; boolean strafeisturn; // Simple controls only player_t *player = &players[ssplayer == 2 ? secondarydisplayplayer : consoleplayer]; - camera_t *thiscam = ((ssplayer == 1 || player->bot == 2) ? &camera : &camera2); + camera_t *thiscam = ((ssplayer == 1 || player->bot == BOT_2PHUMAN) ? &camera : &camera2); angle_t *myangle = (ssplayer == 1 ? &localangle : &localangle2); INT32 *myaiming = (ssplayer == 1 ? &localaiming : &localaiming2); @@ -1560,23 +1560,14 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) cmd->forwardmove = (SINT8)(cmd->forwardmove + forward); cmd->sidemove = (SINT8)(cmd->sidemove + side); - if (player->bot == 1) { // Tailsbot for P2 - if (!player->powers[pw_tailsfly] && (cmd->forwardmove || cmd->sidemove || cmd->buttons)) - { - player->bot = 2; // A player-controlled bot. Returns to AI when it respawns. - CV_SetValue(&cv_analog[1], true); - } - else - { - G_CopyTiccmd(cmd, I_BaseTiccmd2(), 1); // empty, or external driver - B_BuildTiccmd(player, cmd); - } - B_HandleFlightIndicator(player); - } - else if (player->bot == 2) + //Note: Majority of botstuffs are handled in G_Ticker now. + if (player->bot == BOT_2PHUMAN) //Player-controlled bot + { + G_CopyTiccmd(cmd, I_BaseTiccmd2(), 1); // empty, or external driver // Fix offset angle for P2-controlled Tailsbot when P2's controls are set to non-Legacy cmd->angleturn = (INT16)((localangle - *myangle) >> 16); - + } + *myangle += (cmd->angleturn<<16); if (controlstyle == CS_LMAOGALOG) { @@ -2290,22 +2281,51 @@ void G_Ticker(boolean run) for (i = 0; i < MAXPLAYERS; i++) { if (playeringame[i]) - { + { //!!! INT16 received; + //Save last frame's button readings + players[i].lastbuttons = players[i].cmd.buttons; G_CopyTiccmd(&players[i].cmd, &netcmds[buf][i], 1); + //Bot ticcmd handling + //Yes, ordinarily this would be handled in G_BuildTiccmd... + //...however, bot players won't have a corresponding consoleplayer or splitscreen player 2 to send that information. + //Therefore, this has to be done after ticcmd sends are received. + if (players[i].bot == BOT_2PAI) { // Tailsbot for P2 + if (!players[i].powers[pw_tailsfly] && (players[i].cmd.forwardmove || players[i].cmd.sidemove || players[i].cmd.buttons)) + { + players[i].bot = BOT_2PHUMAN; // A player-controlled bot. Returns to AI when it respawns. + CV_SetValue(&cv_analog[1], true); + } + else + { + B_BuildTiccmd(&players[i], &players[i].cmd); + } + B_HandleFlightIndicator(&players[i]); + } + else if (players[i].bot == BOT_MPAI) { + B_BuildTiccmd(&players[i], &players[i].cmd); + } + + // Do angle adjustments. + if (players[i].bot == BOT_NONE || players[i].bot == BOT_2PHUMAN) + { + received = (players[i].cmd.angleturn & TICCMD_RECEIVED); + players[i].angleturn += players[i].cmd.angleturn - players[i].oldrelangleturn; + players[i].oldrelangleturn = players[i].cmd.angleturn; + if (P_ControlStyle(&players[i]) == CS_LMAOGALOG) + P_ForceLocalAngle(&players[i], players[i].angleturn << 16); + else + players[i].cmd.angleturn = players[i].angleturn; - received = (players[i].cmd.angleturn & TICCMD_RECEIVED); - - players[i].angleturn += players[i].cmd.angleturn - players[i].oldrelangleturn; - players[i].oldrelangleturn = players[i].cmd.angleturn; - if (P_ControlStyle(&players[i]) == CS_LMAOGALOG) - P_ForceLocalAngle(&players[i], players[i].angleturn << 16); - else - players[i].cmd.angleturn = players[i].angleturn; - - players[i].cmd.angleturn &= ~TICCMD_RECEIVED; - players[i].cmd.angleturn |= received; + players[i].cmd.angleturn &= ~TICCMD_RECEIVED; + players[i].cmd.angleturn |= received; + } + else // Less work is required if we're building a bot ticcmd. + { + players[i].angleturn = players[i].cmd.angleturn; + players[i].oldrelangleturn = players[i].cmd.angleturn; + } } } @@ -2627,8 +2647,8 @@ void G_PlayerReborn(INT32 player, boolean betweenmaps) p->totalring = totalring; p->mare = mare; - if (bot == 2) - p->bot = 1; // reset to AI-controlled + if (bot == BOT_2PHUMAN) + p->bot = BOT_2PAI; // reset to AI-controlled else p->bot = bot; p->pity = pity; @@ -2976,8 +2996,8 @@ void G_DoReborn(INT32 playernum) // Make sure objectplace is OFF when you first start the level! OP_ResetObjectplace(); - // Tailsbot - if (player->bot && player->bot != 3 && playernum != consoleplayer) + //! Tailsbot + if (player->bot == BOT_2PAI || player->bot == BOT_2PHUMAN) { // Bots respawn next to their master. mobj_t *oldmo = NULL; @@ -3198,7 +3218,7 @@ void G_AddPlayer(INT32 playernum) if (!playeringame[i]) continue; - if (players[i].bot) // ignore dumb, stupid tails + if (players[i].bot == BOT_2PAI || players[i].bot == BOT_2PHUMAN) // ignore dumb, stupid tails continue; countplayers++; @@ -3239,7 +3259,7 @@ boolean G_EnoughPlayersFinished(void) for (i = 0; i < MAXPLAYERS; i++) { - if (!playeringame[i] || players[i].spectator || players[i].bot) + if (!playeringame[i] || players[i].spectator || players[i].bot == BOT_2PAI || players[i].bot == BOT_2PHUMAN) continue; if (players[i].quittime > 30 * TICRATE) continue; From 1274b4651e6decce71a8b4627bb367377a483465 Mon Sep 17 00:00:00 2001 From: Shane Ellis Date: Sat, 23 Jan 2021 10:39:59 -0500 Subject: [PATCH 0558/1080] Added botstuffs to savestate --- src/p_saveg.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/p_saveg.c b/src/p_saveg.c index c1364e08f..d80495e5b 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -158,6 +158,18 @@ static void P_NetArchivePlayers(void) WRITEUINT32(save_p, players[i].dashmode); WRITEUINT32(save_p, players[i].skidtime); + ////////// + // Bots // + ////////// + WRITEUINT8(save_p, players[i].bot); + WRITEUINT8(save_p, players[i].botmem.lastForward); + WRITEUINT8(save_p, players[i].botmem.lastBlocked); + WRITEUINT8(save_p, players[i].botmem.catchup_tics); + WRITEUINT8(save_p, players[i].botmem.thinkstate); + + WRITEUINT8(save_p, players[i].blocked); + WRITEUINT16(save_p, players[i].lastbuttons); + //////////////////////////// // Conveyor Belt Movement // //////////////////////////// @@ -372,6 +384,19 @@ static void P_NetUnArchivePlayers(void) players[i].dashmode = READUINT32(save_p); // counter for dashmode ability players[i].skidtime = READUINT32(save_p); // Skid timer + ////////// + // Bots // + ////////// + players[i].bot = READUINT8(save_p); + + players[i].botmem.lastForward = READUINT8(save_p); + players[i].botmem.lastBlocked = READUINT8(save_p); + players[i].botmem.catchup_tics = READUINT8(save_p); + players[i].botmem.thinkstate = READUINT8(save_p); + + players[i].blocked = READUINT8(save_p); + players[i].lastbuttons = READUINT16(save_p); + //////////////////////////// // Conveyor Belt Movement // //////////////////////////// From 135032c2932afa6474b15b0859717fe1771a3dc7 Mon Sep 17 00:00:00 2001 From: Shane Ellis Date: Sat, 23 Jan 2021 10:58:34 -0500 Subject: [PATCH 0559/1080] Correction to implicit declaration of B_UpdateBotleader() --- src/lua_baselib.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 525ce89ec..b6adc0ccd 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -28,6 +28,7 @@ #include "console.h" #include "d_netcmd.h" // IsPlayerAdmin #include "m_menu.h" // Player Setup menu color stuff +#include "b_bot.h" // B_UpdateBotleader #include "lua_script.h" #include "lua_libs.h" From 0a60fe0b1db198d8ed9ead70bab43a4e7711810b Mon Sep 17 00:00:00 2001 From: CobaltBW Date: Sat, 23 Jan 2021 14:05:36 -0800 Subject: [PATCH 0560/1080] Almost forgot: player.blocked --- src/lua_playerlib.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/lua_playerlib.c b/src/lua_playerlib.c index 51eb4ac0c..8156c2ac1 100644 --- a/src/lua_playerlib.c +++ b/src/lua_playerlib.c @@ -374,6 +374,8 @@ static int player_get(lua_State *L) LUA_PushUserdata(L, plr->botleader, META_PLAYER); else if (fastcmp(field,"lastbuttons")) lua_pushinteger(L, plr->lastbuttons); + else if (fastcmp(field,"blocked")) + lua_pushboolean(L, plr->blocked); else if (fastcmp(field,"jointime")) lua_pushinteger(L, plr->jointime); else if (fastcmp(field,"quittime")) @@ -732,6 +734,8 @@ static int player_set(lua_State *L) } else if (fastcmp(field,"lastbuttons")) plr->lastbuttons = (UINT16)luaL_checkinteger(L, 3); + else if (fastcmp(field,"blocked")) + plr->blocked = (UINT8)luaL_checkinteger(L, 3); else if (fastcmp(field,"jointime")) plr->jointime = (tic_t)luaL_checkinteger(L, 3); else if (fastcmp(field,"quittime")) From 93ec472c7849fecb0fe53e99e7802904a2b7c1ba Mon Sep 17 00:00:00 2001 From: CobaltBW Date: Sat, 23 Jan 2021 14:49:20 -0800 Subject: [PATCH 0561/1080] Expose BOT_ to lua --- src/deh_tables.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/deh_tables.c b/src/deh_tables.c index 3039bf7de..cd6ceb3c6 100644 --- a/src/deh_tables.c +++ b/src/deh_tables.c @@ -5167,6 +5167,12 @@ struct int_const_s const INT_CONST[] = { {"GF_REDFLAG",GF_REDFLAG}, {"GF_BLUEFLAG",GF_BLUEFLAG}, + // Bot types + {"BOT_NONE",BOT_NONE}, + {"BOT_2PAI",BOT_2PAI}, + {"BOT_2PHUMAN",BOT_2PHUMAN}, + {"BOT_MPAI",BOT_MPAI}, + // Customisable sounds for Skins, from sounds.h {"SKSSPIN",SKSSPIN}, {"SKSPUTPUT",SKSPUTPUT}, From a2fce68f14fe8002394639ce1f8facf109f3ea3c Mon Sep 17 00:00:00 2001 From: CobaltBW Date: Sat, 23 Jan 2021 17:01:48 -0800 Subject: [PATCH 0562/1080] Specialized Lua function for bot removal --- src/d_clisrv.c | 18 +++++++----------- src/d_clisrv.h | 1 + src/lua_baselib.c | 35 ++++++++++++++++++++++++++++++++++- 3 files changed, 42 insertions(+), 12 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 4574e5a1c..691408b54 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -2472,7 +2472,7 @@ void CL_ClearPlayer(INT32 playernum) // // Removes a player from the current game // -static void CL_RemovePlayer(INT32 playernum, kickreason_t reason) +void CL_RemovePlayer(INT32 playernum, kickreason_t reason) { // Sanity check: exceptional cases (i.e. c-fails) can cause multiple // kick commands to be issued for the same player. @@ -2815,22 +2815,18 @@ static void Command_Kick(void) return; } + if (!netgame) // Don't kick Tails in splitscreen! + { + CONS_Printf(M_GetText("This only works in a netgame.\n")); + return; + } + if (server || IsPlayerAdmin(consoleplayer)) { UINT8 buf[3 + MAX_REASONLENGTH]; UINT8 *p = buf; const SINT8 pn = nametonum(COM_Argv(1)); - // Unlike bans, kicks are used especially to remove bot players, so we'll - // need to run a more specific check which allows kicking offline, but - // not against splitscreen players. - if (splitscreen && (pn == 0 || pn == 1)) - { - CONS_Printf(M_GetText("Splitscreen players cannot be kicked.\n")); - return; - } - - if (pn == -1 || pn == 0) return; diff --git a/src/d_clisrv.h b/src/d_clisrv.h index 3d67525da..adb611ecf 100644 --- a/src/d_clisrv.h +++ b/src/d_clisrv.h @@ -401,6 +401,7 @@ void CL_Reset(void); void CL_ClearPlayer(INT32 playernum); void CL_QueryServerList(msg_server_t *list); void CL_UpdateServerList(boolean internetsearch, INT32 room); +void CL_RemovePlayer(INT32 playernum, kickreason_t reason); // Is there a game running boolean Playing(void); diff --git a/src/lua_baselib.c b/src/lua_baselib.c index b6adc0ccd..9aeabe1fc 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -29,6 +29,7 @@ #include "d_netcmd.h" // IsPlayerAdmin #include "m_menu.h" // Player Setup menu color stuff #include "b_bot.h" // B_UpdateBotleader +#include "d_clisrv.h" // CL_RemovePlayer #include "lua_script.h" #include "lua_libs.h" @@ -3463,7 +3464,7 @@ static int lib_gAddPlayer(lua_State *L) strcpy(player_names[newplayernum], luaL_checkstring(L, 3)); bot = luaL_optinteger(L, 4, 3); - newplayer->bot = (bot >= 0 && bot <= 3) ? bot : 3; + newplayer->bot = (bot >= BOT_NONE && bot <= BOT_MPAI) ? bot : BOT_MPAI; // If our bot is a 2P type, we'll need to set its leader so it can spawn if (newplayer->bot == BOT_2PAI || newplayer->bot == BOT_2PHUMAN) @@ -3487,6 +3488,37 @@ static int lib_gAddPlayer(lua_State *L) } +// Bot removing function +static int lib_gRemovePlayer(lua_State *L) +{ + UINT8 pnum = -1; + //const char *kickreason = luaL_checkstring(L, 2); + + if (!lua_isnoneornil(L, 1)) + pnum = luaL_checkinteger(L, 1); + if (&players[pnum]) + { + if (players[pnum].bot != BOT_NONE) + { +// CL_RemovePlayer(pnum, *kickreason); + CL_RemovePlayer(pnum, pnum); + if (netgame) + { + char kickmsg[256]; + + strcpy(kickmsg, M_GetText("\x82*Bot %s has been removed")); + strcpy(kickmsg, va(kickmsg, player_names[pnum], pnum)); + HU_AddChatText(kickmsg, false); + } + lua_pushboolean(L, true); + return 1; + } + } + lua_pushboolean(L, false); + return 1; +} + + static int Lcheckmapnumber (lua_State *L, int idx, const char *fun) { if (ISINLEVEL) @@ -4068,6 +4100,7 @@ static luaL_Reg lib[] = { // g_game {"G_AddGametype", lib_gAddGametype}, {"G_AddPlayer", lib_gAddPlayer}, + {"G_RemovePlayer", lib_gRemovePlayer}, {"G_BuildMapName",lib_gBuildMapName}, {"G_BuildMapTitle",lib_gBuildMapTitle}, {"G_FindMap",lib_gFindMap}, From ea6879b5c290811395a74c442924f2a200c491ce Mon Sep 17 00:00:00 2001 From: Shane Ellis Date: Sun, 24 Jan 2021 12:43:13 -0500 Subject: [PATCH 0563/1080] missed a couple spots --- src/p_enemy.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/p_enemy.c b/src/p_enemy.c index 637eba83f..d0e0cc9ee 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -743,8 +743,8 @@ boolean P_LookForPlayers(mobj_t *actor, boolean allaround, boolean tracer, fixed if (player->mo->health <= 0) continue; // dead - if (player->bot && player->bot != 3) - continue; // ignore bots + if (player->bot == BOT_2PAI || player->bot == BOT_2PHUMAN) + continue; // ignore followbots if (player->quittime) continue; // Ignore uncontrolled bodies @@ -3590,7 +3590,7 @@ void A_1upThinker(mobj_t *actor) for (i = 0; i < MAXPLAYERS; i++) { - if (!playeringame[i] || players[i].bot || players[i].spectator) + if (!playeringame[i] || players[i].bot == BOT_2PAI || players[i].bot == BOT_2PHUMAN || players[i].spectator) continue; if (!players[i].mo) From ca00e2d5086af7f6a5ba63a3caf82b74742680a1 Mon Sep 17 00:00:00 2001 From: Shane Ellis Date: Sun, 24 Jan 2021 12:46:03 -0500 Subject: [PATCH 0564/1080] correction to nights bot clause --- 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 c631f49b2..f0cbb6f37 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -777,7 +777,7 @@ void P_NightserizePlayer(player_t *player, INT32 nighttime) UINT8 oldmare, oldmarelap, oldmarebonuslap; //! Bots can't be NiGHTSerized, silly!1 :P - if (player->bot == BOT_2PAI || player->bot || BOT_2PHUMAN) + if (player->bot == BOT_2PAI || player->bot == BOT_2PHUMAN) return; if (player->powers[pw_carry] != CR_NIGHTSMODE) From 5501d495c72d0cb8f2d82d4424e64d67a6a6a8ea Mon Sep 17 00:00:00 2001 From: Jaime Ita Passos Date: Wed, 27 Jan 2021 17:48:57 -0300 Subject: [PATCH 0565/1080] OpenGL backend: Manage uploaded GPU textures with an internal list Indirectly fixes the game doing whatever after freeing a patch. This commit implements a FTextureInfo struct type, instead of it being a typedef to the GLMipmap_s struct type. --- src/f_finale.c | 44 ++++++++--------- src/hardware/hw_cache.c | 1 - src/hardware/hw_data.h | 19 ++++---- src/hardware/hw_defs.h | 11 ++++- src/hardware/hw_drv.h | 8 ++- src/hardware/r_opengl/r_opengl.c | 84 ++++++++++++++++++++++---------- src/sdl/hwsym_sdl.c | 1 - src/sdl/i_video.c | 1 - src/w_wad.c | 18 +------ src/win32/win_dll.c | 2 - src/z_zone.h | 3 +- 11 files changed, 106 insertions(+), 86 deletions(-) diff --git a/src/f_finale.c b/src/f_finale.c index 2232b669f..fdcfad279 100644 --- a/src/f_finale.c +++ b/src/f_finale.c @@ -2546,28 +2546,28 @@ static void F_UnloadAlacroixGraphics(SINT8 oldttscale) oldttscale--; // zero-based index for (i = 0; i < TTMAX_ALACROIX; i++) { - if(ttembl[oldttscale][i]) { Z_Free(ttembl[oldttscale][i]); ttembl[oldttscale][i] = 0; } - if(ttribb[oldttscale][i]) { Z_Free(ttribb[oldttscale][i]); ttribb[oldttscale][i] = 0; } - if(ttsont[oldttscale][i]) { Z_Free(ttsont[oldttscale][i]); ttsont[oldttscale][i] = 0; } - if(ttrobo[oldttscale][i]) { Z_Free(ttrobo[oldttscale][i]); ttrobo[oldttscale][i] = 0; } - if(tttwot[oldttscale][i]) { Z_Free(tttwot[oldttscale][i]); tttwot[oldttscale][i] = 0; } - if(ttrbtx[oldttscale][i]) { Z_Free(ttrbtx[oldttscale][i]); ttrbtx[oldttscale][i] = 0; } - if(ttsoib[oldttscale][i]) { Z_Free(ttsoib[oldttscale][i]); ttsoib[oldttscale][i] = 0; } - if(ttsoif[oldttscale][i]) { Z_Free(ttsoif[oldttscale][i]); ttsoif[oldttscale][i] = 0; } - if(ttsoba[oldttscale][i]) { Z_Free(ttsoba[oldttscale][i]); ttsoba[oldttscale][i] = 0; } - if(ttsobk[oldttscale][i]) { Z_Free(ttsobk[oldttscale][i]); ttsobk[oldttscale][i] = 0; } - if(ttsodh[oldttscale][i]) { Z_Free(ttsodh[oldttscale][i]); ttsodh[oldttscale][i] = 0; } - if(tttaib[oldttscale][i]) { Z_Free(tttaib[oldttscale][i]); tttaib[oldttscale][i] = 0; } - if(tttaif[oldttscale][i]) { Z_Free(tttaif[oldttscale][i]); tttaif[oldttscale][i] = 0; } - if(tttaba[oldttscale][i]) { Z_Free(tttaba[oldttscale][i]); tttaba[oldttscale][i] = 0; } - if(tttabk[oldttscale][i]) { Z_Free(tttabk[oldttscale][i]); tttabk[oldttscale][i] = 0; } - if(tttabt[oldttscale][i]) { Z_Free(tttabt[oldttscale][i]); tttabt[oldttscale][i] = 0; } - if(tttaft[oldttscale][i]) { Z_Free(tttaft[oldttscale][i]); tttaft[oldttscale][i] = 0; } - if(ttknib[oldttscale][i]) { Z_Free(ttknib[oldttscale][i]); ttknib[oldttscale][i] = 0; } - if(ttknif[oldttscale][i]) { Z_Free(ttknif[oldttscale][i]); ttknif[oldttscale][i] = 0; } - if(ttknba[oldttscale][i]) { Z_Free(ttknba[oldttscale][i]); ttknba[oldttscale][i] = 0; } - if(ttknbk[oldttscale][i]) { Z_Free(ttknbk[oldttscale][i]); ttknbk[oldttscale][i] = 0; } - if(ttkndh[oldttscale][i]) { Z_Free(ttkndh[oldttscale][i]); ttkndh[oldttscale][i] = 0; } + if(ttembl[oldttscale][i]) { Patch_Free(ttembl[oldttscale][i]); ttembl[oldttscale][i] = 0; } + if(ttribb[oldttscale][i]) { Patch_Free(ttribb[oldttscale][i]); ttribb[oldttscale][i] = 0; } + if(ttsont[oldttscale][i]) { Patch_Free(ttsont[oldttscale][i]); ttsont[oldttscale][i] = 0; } + if(ttrobo[oldttscale][i]) { Patch_Free(ttrobo[oldttscale][i]); ttrobo[oldttscale][i] = 0; } + if(tttwot[oldttscale][i]) { Patch_Free(tttwot[oldttscale][i]); tttwot[oldttscale][i] = 0; } + if(ttrbtx[oldttscale][i]) { Patch_Free(ttrbtx[oldttscale][i]); ttrbtx[oldttscale][i] = 0; } + if(ttsoib[oldttscale][i]) { Patch_Free(ttsoib[oldttscale][i]); ttsoib[oldttscale][i] = 0; } + if(ttsoif[oldttscale][i]) { Patch_Free(ttsoif[oldttscale][i]); ttsoif[oldttscale][i] = 0; } + if(ttsoba[oldttscale][i]) { Patch_Free(ttsoba[oldttscale][i]); ttsoba[oldttscale][i] = 0; } + if(ttsobk[oldttscale][i]) { Patch_Free(ttsobk[oldttscale][i]); ttsobk[oldttscale][i] = 0; } + if(ttsodh[oldttscale][i]) { Patch_Free(ttsodh[oldttscale][i]); ttsodh[oldttscale][i] = 0; } + if(tttaib[oldttscale][i]) { Patch_Free(tttaib[oldttscale][i]); tttaib[oldttscale][i] = 0; } + if(tttaif[oldttscale][i]) { Patch_Free(tttaif[oldttscale][i]); tttaif[oldttscale][i] = 0; } + if(tttaba[oldttscale][i]) { Patch_Free(tttaba[oldttscale][i]); tttaba[oldttscale][i] = 0; } + if(tttabk[oldttscale][i]) { Patch_Free(tttabk[oldttscale][i]); tttabk[oldttscale][i] = 0; } + if(tttabt[oldttscale][i]) { Patch_Free(tttabt[oldttscale][i]); tttabt[oldttscale][i] = 0; } + if(tttaft[oldttscale][i]) { Patch_Free(tttaft[oldttscale][i]); tttaft[oldttscale][i] = 0; } + if(ttknib[oldttscale][i]) { Patch_Free(ttknib[oldttscale][i]); ttknib[oldttscale][i] = 0; } + if(ttknif[oldttscale][i]) { Patch_Free(ttknif[oldttscale][i]); ttknif[oldttscale][i] = 0; } + if(ttknba[oldttscale][i]) { Patch_Free(ttknba[oldttscale][i]); ttknba[oldttscale][i] = 0; } + if(ttknbk[oldttscale][i]) { Patch_Free(ttknbk[oldttscale][i]); ttknbk[oldttscale][i] = 0; } + if(ttkndh[oldttscale][i]) { Patch_Free(ttkndh[oldttscale][i]); ttkndh[oldttscale][i] = 0; } } ttloaded[oldttscale] = false; } diff --git a/src/hardware/hw_cache.c b/src/hardware/hw_cache.c index 37e9f690f..83a4e2e03 100644 --- a/src/hardware/hw_cache.c +++ b/src/hardware/hw_cache.c @@ -1091,7 +1091,6 @@ void HWR_UnlockCachedPatch(GLPatch_t *gpatch) return; Z_ChangeTag(gpatch->mipmap->data, PU_HWRCACHE_UNLOCKED); - Z_ChangeTag(gpatch, PU_HWRPATCHINFO_UNLOCKED); } static const INT32 picmode2GR[] = diff --git a/src/hardware/hw_data.h b/src/hardware/hw_data.h index 11e41b18a..ce6527666 100644 --- a/src/hardware/hw_data.h +++ b/src/hardware/hw_data.h @@ -48,18 +48,19 @@ struct GLColormap_s typedef struct GLColormap_s GLColormap_t; -// data holds the address of the graphics data cached in heap memory -// NULL if the texture is not in Doom heap cache. +// Texture information (misleadingly named "mipmap" all over the code.) +// The *data pointer holds the address of the graphics data cached in heap memory. +// NULL if the texture is not in SRB2's heap cache. struct GLMipmap_s { - // for TexDownloadMipMap + // for UpdateTexture GLTextureFormat_t format; void *data; UINT32 flags; UINT16 height; UINT16 width; - UINT32 downloaded; // The GPU has this texture. + UINT32 downloaded; // The GPU has this texture. struct GLMipmap_s *nextcolormap; struct GLColormap_s *colormap; @@ -70,22 +71,22 @@ typedef struct GLMipmap_s GLMipmap_t; // -// Doom texture info, as cached for hardware rendering +// Level textures, as cached for hardware rendering. // struct GLMapTexture_s { GLMipmap_t mipmap; - float scaleX; //used for scaling textures on walls + float scaleX; // Used for scaling textures on walls float scaleY; }; typedef struct GLMapTexture_s GLMapTexture_t; -// a cached patch as converted to hardware format +// Patch information for the hardware renderer. struct GLPatch_s { - float max_s,max_t; - GLMipmap_t *mipmap; + GLMipmap_t *mipmap; // Texture data. Allocated whenever the patch is. + float max_s, max_t; }; typedef struct GLPatch_s GLPatch_t; diff --git a/src/hardware/hw_defs.h b/src/hardware/hw_defs.h index a782762a3..bd6afc74f 100644 --- a/src/hardware/hw_defs.h +++ b/src/hardware/hw_defs.h @@ -255,7 +255,16 @@ enum ETextureFlags TF_TRANSPARENT = 0x00000040, // texture with some alpha == 0 }; -typedef struct GLMipmap_s FTextureInfo; +struct FTextureInfo +{ + UINT32 width, height; + UINT32 downloaded; + UINT32 format; + + struct GLMipmap_s *texture; + struct FTextureInfo *prev, *next; +}; +typedef struct FTextureInfo FTextureInfo; // jimita 14032019 struct FLightInfo diff --git a/src/hardware/hw_drv.h b/src/hardware/hw_drv.h index 5a2e0e44e..da4ee8614 100644 --- a/src/hardware/hw_drv.h +++ b/src/hardware/hw_drv.h @@ -40,13 +40,12 @@ EXPORT void HWRAPI(DrawIndexedTriangles) (FSurfaceInfo *pSurf, FOutVector *pOutV EXPORT void HWRAPI(RenderSkyDome) (gl_sky_t *sky); EXPORT void HWRAPI(SetBlend) (FBITFIELD PolyFlags); EXPORT void HWRAPI(ClearBuffer) (FBOOLEAN ColorMask, FBOOLEAN DepthMask, FRGBAFloat *ClearColor); -EXPORT void HWRAPI(SetTexture) (FTextureInfo *TexInfo); -EXPORT void HWRAPI(UpdateTexture) (FTextureInfo *TexInfo); -EXPORT void HWRAPI(DeleteTexture) (FTextureInfo *TexInfo); +EXPORT void HWRAPI(SetTexture) (GLMipmap_t *TexInfo); +EXPORT void HWRAPI(UpdateTexture) (GLMipmap_t *TexInfo); +EXPORT void HWRAPI(DeleteTexture) (GLMipmap_t *TexInfo); EXPORT void HWRAPI(ReadRect) (INT32 x, INT32 y, INT32 width, INT32 height, INT32 dst_stride, UINT16 *dst_data); EXPORT void HWRAPI(GClipRect) (INT32 minx, INT32 miny, INT32 maxx, INT32 maxy, float nearclip); EXPORT void HWRAPI(ClearMipMapCache) (void); -EXPORT void HWRAPI(ClearCacheList) (void); //Hurdler: added for backward compatibility EXPORT void HWRAPI(SetSpecialState) (hwdspecialstate_t IdState, INT32 Value); @@ -101,7 +100,6 @@ struct hwdriver_s ReadRect pfnReadRect; GClipRect pfnGClipRect; ClearMipMapCache pfnClearMipMapCache; - ClearCacheList pfnClearCacheList; SetSpecialState pfnSetSpecialState;//Hurdler: added for backward compatibility DrawModel pfnDrawModel; CreateModelVBOs pfnCreateModelVBOs; diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index 8cd948eea..2568a7d08 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -58,8 +58,9 @@ static GLuint tex_downloaded = 0; static GLfloat fov = 90.0f; static FBITFIELD CurrentPolyFlags; -static FTextureInfo *gl_cachetail = NULL; -static FTextureInfo *gl_cachehead = NULL; +// Linked list of all textures. +static FTextureInfo *TexCacheTail = NULL; +static FTextureInfo *TexCacheHead = NULL; RGBA_t myPaletteData[256]; GLint screen_width = 0; // used by Draw2DLine() @@ -1287,10 +1288,30 @@ void SetStates(void) // -----------------+ // DeleteTexture : Deletes a texture from the GPU and frees its data // -----------------+ -EXPORT void HWRAPI(DeleteTexture) (FTextureInfo *pTexInfo) +EXPORT void HWRAPI(DeleteTexture) (GLMipmap_t *pTexInfo) { - if (pTexInfo->downloaded) + FTextureInfo *head = TexCacheHead; + + if (!pTexInfo) + return; + else if (pTexInfo->downloaded) pglDeleteTextures(1, (GLuint *)&pTexInfo->downloaded); + + while (head) + { + if (head->downloaded == pTexInfo->downloaded) + { + if (head->next) + head->next->prev = head->prev; + if (head->prev) + head->prev->next = head->next; + free(head); + break; + } + + head = head->next; + } + pTexInfo->downloaded = 0; } @@ -1303,26 +1324,29 @@ void Flush(void) { //GL_DBG_Printf ("HWR_Flush()\n"); - while (gl_cachehead) + while (TexCacheHead) { - DeleteTexture(gl_cachehead); - gl_cachehead = gl_cachehead->nextmipmap; + FTextureInfo *pTexInfo = TexCacheHead; + GLMipmap_t *texture = pTexInfo->texture; + + if (pTexInfo->downloaded) + { + pglDeleteTextures(1, (GLuint *)&pTexInfo->downloaded); + pTexInfo->downloaded = 0; + } + + if (texture) + texture->downloaded = 0; + + TexCacheHead = pTexInfo->next; + free(pTexInfo); } - ClearCacheList(); //Hurdler: well, gl_cachehead is already NULL + TexCacheTail = TexCacheHead = NULL; //Hurdler: well, TexCacheHead is already NULL tex_downloaded = 0; } -// -----------------+ -// ClearCacheList : Clears the texture cache tail and head -// -----------------+ -EXPORT void HWRAPI(ClearCacheList) (void) -{ - gl_cachetail = gl_cachehead = NULL; -} - - // -----------------+ // isExtAvailable : Look if an OpenGL extension is available // Returns : true if extension available @@ -1718,7 +1742,7 @@ EXPORT void HWRAPI(SetBlend) (FBITFIELD PolyFlags) // -----------------+ // UpdateTexture : Updates the texture data. // -----------------+ -EXPORT void HWRAPI(UpdateTexture) (FTextureInfo *pTexInfo) +EXPORT void HWRAPI(UpdateTexture) (GLMipmap_t *pTexInfo) { // Download a mipmap boolean updatemipmap = true; @@ -1920,7 +1944,7 @@ EXPORT void HWRAPI(UpdateTexture) (FTextureInfo *pTexInfo) // -----------------+ // SetTexture : The mipmap becomes the current texture source // -----------------+ -EXPORT void HWRAPI(SetTexture) (FTextureInfo *pTexInfo) +EXPORT void HWRAPI(SetTexture) (GLMipmap_t *pTexInfo) { if (!pTexInfo) { @@ -1937,17 +1961,25 @@ EXPORT void HWRAPI(SetTexture) (FTextureInfo *pTexInfo) } else { + FTextureInfo *newTex = calloc(1, sizeof (*newTex)); + UpdateTexture(pTexInfo); - pTexInfo->nextmipmap = NULL; + + newTex->texture = pTexInfo; + newTex->downloaded = (UINT32)pTexInfo->downloaded; + newTex->width = (UINT32)pTexInfo->width; + newTex->height = (UINT32)pTexInfo->height; + newTex->format = (UINT32)pTexInfo->format; // insertion at the tail - if (gl_cachetail) + if (TexCacheTail) { - gl_cachetail->nextmipmap = pTexInfo; - gl_cachetail = pTexInfo; + newTex->prev = TexCacheTail; + TexCacheTail->next = newTex; + TexCacheTail = newTex; } else // initialization of the linked list - gl_cachetail = gl_cachehead = pTexInfo; + TexCacheTail = TexCacheHead = newTex; } } @@ -3011,7 +3043,7 @@ EXPORT void HWRAPI(SetTransform) (FTransform *stransform) EXPORT INT32 HWRAPI(GetTextureUsed) (void) { - FTextureInfo *tmp = gl_cachehead; + FTextureInfo *tmp = TexCacheHead; INT32 res = 0; while (tmp) @@ -3028,7 +3060,7 @@ EXPORT INT32 HWRAPI(GetTextureUsed) (void) // Add it up! res += tmp->height*tmp->width*bpp; - tmp = tmp->nextmipmap; + tmp = tmp->next; } return res; diff --git a/src/sdl/hwsym_sdl.c b/src/sdl/hwsym_sdl.c index 398508662..96e3d7d69 100644 --- a/src/sdl/hwsym_sdl.c +++ b/src/sdl/hwsym_sdl.c @@ -90,7 +90,6 @@ void *hwSym(const char *funcName,void *handle) GETFUNC(ReadRect); GETFUNC(GClipRect); GETFUNC(ClearMipMapCache); - GETFUNC(ClearCacheList); GETFUNC(SetSpecialState); GETFUNC(GetTextureUsed); GETFUNC(DrawModel); diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index 5ebff8700..0ed10463f 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -1862,7 +1862,6 @@ void VID_StartupOpenGL(void) HWD.pfnReadRect = hwSym("ReadRect",NULL); HWD.pfnGClipRect = hwSym("GClipRect",NULL); HWD.pfnClearMipMapCache = hwSym("ClearMipMapCache",NULL); - HWD.pfnClearCacheList = hwSym("ClearCacheList",NULL); HWD.pfnSetSpecialState = hwSym("SetSpecialState",NULL); HWD.pfnSetPalette = hwSym("SetPalette",NULL); HWD.pfnGetTextureUsed = hwSym("GetTextureUsed",NULL); diff --git a/src/w_wad.c b/src/w_wad.c index 6566800c0..2cbcdecb5 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -1682,26 +1682,12 @@ void *W_CacheSoftwarePatchNumPwad(UINT16 wad, UINT16 lump, INT32 tag) // read the lump in full W_ReadLumpHeaderPwad(wad, lump, lumpdata, 0, 0); + ptr = lumpdata; #ifndef NO_PNG_LUMPS - // lump is a png so convert it if (Picture_IsLumpPNG((UINT8 *)lumpdata, len)) - { - size_t newlen; - void *converted = Picture_PNGConvert((UINT8 *)lumpdata, PICFMT_DOOMPATCH, NULL, NULL, NULL, NULL, len, &newlen, 0); - ptr = Z_Malloc(newlen, PU_STATIC, NULL); - M_Memcpy(ptr, converted, newlen); - Z_Free(converted); - len = newlen; - } - else // just copy it into the patch cache + ptr = Picture_PNGConvert((UINT8 *)lumpdata, PICFMT_DOOMPATCH, NULL, NULL, NULL, NULL, len, &len, 0); #endif - { - ptr = Z_Malloc(len, PU_STATIC, NULL); - M_Memcpy(ptr, lumpdata, len); - } - - Z_Free(lumpdata); dest = Z_Calloc(sizeof(patch_t), tag, &lumpcache[lump]); Patch_Create(ptr, len, dest); diff --git a/src/win32/win_dll.c b/src/win32/win_dll.c index d942d8cd4..4743cec34 100644 --- a/src/win32/win_dll.c +++ b/src/win32/win_dll.c @@ -111,7 +111,6 @@ static loadfunc_t hwdFuncTable[] = { {"ReadRect@24", &hwdriver.pfnReadRect}, {"GClipRect@20", &hwdriver.pfnGClipRect}, {"ClearMipMapCache@0", &hwdriver.pfnClearMipMapCache}, - {"ClearCacheList@0", &hwdriver.pfnClearCacheList}, {"SetSpecialState@8", &hwdriver.pfnSetSpecialState}, {"DrawModel@16", &hwdriver.pfnDrawModel}, {"SetTransform@4", &hwdriver.pfnSetTransform}, @@ -145,7 +144,6 @@ static loadfunc_t hwdFuncTable[] = { {"ReadRect", &hwdriver.pfnReadRect}, {"GClipRect", &hwdriver.pfnGClipRect}, {"ClearMipMapCache", &hwdriver.pfnClearMipMapCache}, - {"ClearCacheList", &hwdriver.pfnClearCacheList}, {"SetSpecialState", &hwdriver.pfnSetSpecialState}, {"DrawModel", &hwdriver.pfnDrawModel}, {"SetTransform", &hwdriver.pfnSetTransform}, diff --git a/src/z_zone.h b/src/z_zone.h index e80a45e7f..7b58be8f3 100644 --- a/src/z_zone.h +++ b/src/z_zone.h @@ -68,8 +68,7 @@ enum PU_HWRCACHE_UNLOCKED = 102, // 'unlocked' PU_HWRCACHE memory: // 'second-level' cache for graphics // stored in hardware format and downloaded as needed - PU_HWRPATCHINFO_UNLOCKED = 103, // 'unlocked' PU_HWRPATCHINFO memory - PU_HWRMODELTEXTURE_UNLOCKED = 104, // 'unlocked' PU_HWRMODELTEXTURE memory + PU_HWRMODELTEXTURE_UNLOCKED = 103, // 'unlocked' PU_HWRMODELTEXTURE memory }; // From d4044a4f82bd9862a848a1e3f49a62f35f8f8b71 Mon Sep 17 00:00:00 2001 From: Jaime Ita Passos Date: Wed, 27 Jan 2021 18:54:33 -0300 Subject: [PATCH 0566/1080] Add PF_ColorMapped Not all surfaces have tint and fade colors. Checking for a specific surface flag, that tells the backend those colors are present, avoids uninitialized reads. --- src/hardware/hw_defs.h | 10 +-- src/hardware/hw_drv.h | 1 - src/hardware/hw_main.c | 129 ++++++++++++++++++++++--------- src/hardware/r_opengl/r_opengl.c | 42 +++++----- 4 files changed, 119 insertions(+), 63 deletions(-) diff --git a/src/hardware/hw_defs.h b/src/hardware/hw_defs.h index a782762a3..eb4ddf572 100644 --- a/src/hardware/hw_defs.h +++ b/src/hardware/hw_defs.h @@ -230,14 +230,15 @@ enum EPolyFlags PF_NoDepthTest = 0x00000200, // Disables the depth test mode PF_Invisible = 0x00000400, // Disables write to color buffer PF_Decal = 0x00000800, // Enables polygon offset - PF_Modulated = 0x00001000, // Modulation (multiply output with constant ARGB) + PF_Modulated = 0x00001000, // Modulation (multiply output with constant RGBA) // When set, pass the color constant into the FSurfaceInfo -> PolyColor PF_NoTexture = 0x00002000, // Disables texturing PF_Corona = 0x00004000, // Tells the renderer we are drawing a corona - PF_Ripple = 0x00008000, // Water effect shader + PF_ColorMapped = 0x00008000, // Surface has "tint" and "fade" colors, which are sent as uniforms to a shader. PF_RemoveYWrap = 0x00010000, // Forces clamp texture on Y PF_ForceWrapX = 0x00020000, // Forces repeat texture on X - PF_ForceWrapY = 0x00040000 // Forces repeat texture on Y + PF_ForceWrapY = 0x00040000, // Forces repeat texture on Y + PF_Ripple = 0x00100000 // Water ripple effect. The current backend doesn't use it for anything. }; @@ -257,7 +258,6 @@ enum ETextureFlags typedef struct GLMipmap_s FTextureInfo; -// jimita 14032019 struct FLightInfo { FUINT light_level; @@ -273,7 +273,7 @@ struct FSurfaceInfo RGBA_t PolyColor; RGBA_t TintColor; RGBA_t FadeColor; - FLightInfo LightInfo; // jimita 14032019 + FLightInfo LightInfo; }; typedef struct FSurfaceInfo FSurfaceInfo; diff --git a/src/hardware/hw_drv.h b/src/hardware/hw_drv.h index 5a2e0e44e..03e664e42 100644 --- a/src/hardware/hw_drv.h +++ b/src/hardware/hw_drv.h @@ -69,7 +69,6 @@ EXPORT void HWRAPI(DrawScreenFinalTexture) (int width, int height); #define SCREENVERTS 10 EXPORT void HWRAPI(PostImgRedraw) (float points[SCREENVERTS][SCREENVERTS][2]); -// jimita EXPORT boolean HWRAPI(CompileShaders) (void); EXPORT void HWRAPI(CleanShaders) (void); EXPORT void HWRAPI(SetShader) (int type); diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index a7e37d231..ab5fa0229 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -173,6 +173,11 @@ boolean gl_shadersavailable = true; // Lighting // ========================================================================== +static boolean HWR_UseShader(void) +{ + return (cv_glshaders.value && gl_shadersavailable); +} + void HWR_Lighting(FSurfaceInfo *Surface, INT32 light_level, extracolormap_t *colormap) { RGBA_t poly_color, tint_color, fade_color; @@ -182,7 +187,7 @@ void HWR_Lighting(FSurfaceInfo *Surface, INT32 light_level, extracolormap_t *col fade_color.rgba = (colormap != NULL) ? (UINT32)colormap->fadergba : GL_DEFAULTFOG; // Crappy backup coloring if you can't do shaders - if (!cv_glshaders.value || !gl_shadersavailable) + if (!HWR_UseShader()) { // be careful, this may get negative for high lightlevel values. float tint_alpha, fade_alpha; @@ -371,7 +376,7 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool static FOutVector *planeVerts = NULL; static UINT16 numAllocedPlaneVerts = 0; - int shader; + INT32 shader = SHADER_DEFAULT; // no convex poly were generated for this subsector if (!xsub->planepoly) @@ -568,12 +573,17 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool else PolyFlags |= PF_Masked|PF_Modulated; - if (PolyFlags & PF_Fog) - shader = SHADER_FOG; // fog shader - else if (PolyFlags & PF_Ripple) - shader = SHADER_WATER; // water shader - else - shader = SHADER_FLOOR; // floor shader + if (HWR_UseShader()) + { + if (PolyFlags & PF_Fog) + shader = SHADER_FOG; + else if (PolyFlags & PF_Ripple) + shader = SHADER_WATER; + else + shader = SHADER_FLOOR; + + PolyFlags |= PF_ColorMapped; + } HWR_ProcessPolygon(&Surf, planeVerts, nrPlaneVerts, PolyFlags, shader, false); @@ -785,8 +795,17 @@ static void HWR_AddTransparentWall(FOutVector *wallVerts, FSurfaceInfo *pSurf, I // static void HWR_ProjectWall(FOutVector *wallVerts, FSurfaceInfo *pSurf, FBITFIELD blendmode, INT32 lightlevel, extracolormap_t *wallcolormap) { + INT32 shader = SHADER_DEFAULT; + HWR_Lighting(pSurf, lightlevel, wallcolormap); - HWR_ProcessPolygon(pSurf, wallVerts, 4, blendmode|PF_Modulated|PF_Occlude, SHADER_WALL, false); // wall shader + + if (HWR_UseShader()) + { + shader = SHADER_WALL; + blendmode |= PF_ColorMapped; + } + + HWR_ProcessPolygon(pSurf, wallVerts, 4, blendmode|PF_Modulated|PF_Occlude, shader, false); } // ========================================================================== @@ -2659,30 +2678,30 @@ static void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling, FBITFIELD blendmode, UINT8 lightlevel, levelflat_t *levelflat, sector_t *FOFsector, UINT8 alpha, extracolormap_t *planecolormap) { - float height; //constant y for all points on the convex flat polygon - FOutVector *v3d; - INT32 i; - float flatxref,flatyref; + FSurfaceInfo Surf; + FOutVector *v3d; + INT32 shader = SHADER_DEFAULT; + + size_t nrPlaneVerts = polysector->numVertices; + INT32 i; + + float height = FIXED_TO_FLOAT(fixedheight); // constant y for all points on the convex flat polygon + float flatxref, flatyref; float fflatwidth = 64.0f, fflatheight = 64.0f; INT32 flatflag = 63; + boolean texflat = false; + float scrollx = 0.0f, scrolly = 0.0f; angle_t angle = 0; - FSurfaceInfo Surf; fixed_t tempxs, tempyt; - size_t nrPlaneVerts; static FOutVector *planeVerts = NULL; static UINT16 numAllocedPlaneVerts = 0; - nrPlaneVerts = polysector->numVertices; - - height = FIXED_TO_FLOAT(fixedheight); - - if (nrPlaneVerts < 3) //not even a triangle ? + if (nrPlaneVerts < 3) // Not even a triangle? return; - - if (nrPlaneVerts > (size_t)UINT16_MAX) // FIXME: exceeds plVerts size + else if (nrPlaneVerts > (size_t)UINT16_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; @@ -2834,7 +2853,6 @@ static void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling, v3d->z = FIXED_TO_FLOAT(polysector->vertices[i]->y); } - HWR_Lighting(&Surf, lightlevel, planecolormap); if (blendmode & PF_Translucent) @@ -2845,7 +2863,13 @@ static void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling, else blendmode |= PF_Masked|PF_Modulated; - HWR_ProcessPolygon(&Surf, planeVerts, nrPlaneVerts, blendmode, SHADER_FLOOR, false); // floor shader + if (HWR_UseShader()) + { + shader = SHADER_FLOOR; + blendmode |= PF_ColorMapped; + } + + HWR_ProcessPolygon(&Surf, planeVerts, nrPlaneVerts, blendmode, shader, false); } static void HWR_AddPolyObjectPlanes(void) @@ -3566,6 +3590,8 @@ static void HWR_DrawDropShadow(mobj_t *thing, fixed_t scale) FSurfaceInfo sSurf; float fscale; float fx; float fy; float offset; extracolormap_t *colormap = NULL; + FBITFIELD blendmode = PF_Translucent|PF_Modulated; + INT32 shader = SHADER_DEFAULT; UINT8 i; SINT8 flip = P_MobjFlip(thing); @@ -3658,7 +3684,13 @@ static void HWR_DrawDropShadow(mobj_t *thing, fixed_t scale) HWR_Lighting(&sSurf, 0, colormap); sSurf.PolyColor.s.alpha = alpha; - HWR_ProcessPolygon(&sSurf, shadowVerts, 4, PF_Translucent|PF_Modulated, SHADER_SPRITE, false); // sprite shader + if (HWR_UseShader()) + { + shader = SHADER_SPRITE; + blendmode |= PF_ColorMapped; + } + + HWR_ProcessPolygon(&sSurf, shadowVerts, 4, blendmode, shader, false); } // This is expecting a pointer to an array containing 4 wallVerts for a sprite @@ -3706,6 +3738,7 @@ static void HWR_SplitSprite(gl_vissprite_t *spr) boolean lightset = true; FBITFIELD blend = 0; FBITFIELD occlusion; + INT32 shader = SHADER_DEFAULT; boolean use_linkdraw_hack = false; boolean splat = R_ThingIsFloorSprite(spr->mobj); UINT8 alpha; @@ -3832,6 +3865,12 @@ static void HWR_SplitSprite(gl_vissprite_t *spr) if (!occlusion) use_linkdraw_hack = true; } + if (HWR_UseShader()) + { + shader = SHADER_SPRITE; + blend |= PF_ColorMapped; + } + alpha = Surf.PolyColor.s.alpha; // Start with the lightlevel and colormap from the top of the sprite @@ -3940,7 +3979,7 @@ static void HWR_SplitSprite(gl_vissprite_t *spr) Surf.PolyColor.s.alpha = alpha; - HWR_ProcessPolygon(&Surf, wallVerts, 4, blend|PF_Modulated, SHADER_SPRITE, false); // sprite shader + HWR_ProcessPolygon(&Surf, wallVerts, 4, blend|PF_Modulated, shader, false); if (use_linkdraw_hack) HWR_LinkDrawHackAdd(wallVerts, spr); @@ -3969,7 +4008,7 @@ static void HWR_SplitSprite(gl_vissprite_t *spr) Surf.PolyColor.s.alpha = alpha; - HWR_ProcessPolygon(&Surf, wallVerts, 4, blend|PF_Modulated, SHADER_SPRITE, false); // sprite shader + HWR_ProcessPolygon(&Surf, wallVerts, 4, blend|PF_Modulated, shader, false); if (use_linkdraw_hack) HWR_LinkDrawHackAdd(wallVerts, spr); @@ -4219,6 +4258,7 @@ static void HWR_DrawSprite(gl_vissprite_t *spr) } { + INT32 shader = SHADER_DEFAULT; FBITFIELD blend = 0; FBITFIELD occlusion; boolean use_linkdraw_hack = false; @@ -4271,7 +4311,13 @@ static void HWR_DrawSprite(gl_vissprite_t *spr) if (!occlusion) use_linkdraw_hack = true; } - HWR_ProcessPolygon(&Surf, wallVerts, 4, blend|PF_Modulated, SHADER_SPRITE, false); // sprite shader + if (HWR_UseShader()) + { + shader = SHADER_SPRITE; + blend |= PF_ColorMapped; + } + + HWR_ProcessPolygon(&Surf, wallVerts, 4, blend|PF_Modulated, shader, false); if (use_linkdraw_hack) HWR_LinkDrawHackAdd(wallVerts, spr); @@ -4282,6 +4328,7 @@ static void HWR_DrawSprite(gl_vissprite_t *spr) // Sprite drawer for precipitation static inline void HWR_DrawPrecipitationSprite(gl_vissprite_t *spr) { + INT32 shader = SHADER_DEFAULT; FBITFIELD blend = 0; FOutVector wallVerts[4]; patch_t *gpatch; // sprite patch converted to hardware @@ -4372,7 +4419,13 @@ static inline void HWR_DrawPrecipitationSprite(gl_vissprite_t *spr) blend = HWR_GetBlendModeFlag(spr->mobj->blendmode)|PF_Occlude; } - HWR_ProcessPolygon(&Surf, wallVerts, 4, blend|PF_Modulated, SHADER_SPRITE, false); // sprite shader + if (HWR_UseShader()) + { + shader = SHADER_SPRITE; + blend |= PF_ColorMapped; + } + + HWR_ProcessPolygon(&Surf, wallVerts, 4, blend|PF_Modulated, shader, false); } #endif @@ -6454,24 +6507,29 @@ void HWR_RenderWall(FOutVector *wallVerts, FSurfaceInfo *pSurf, FBITFIELD blend, FBITFIELD blendmode = blend; UINT8 alpha = pSurf->PolyColor.s.alpha; // retain the alpha - int shader; + INT32 shader = SHADER_DEFAULT; // Lighting is done here instead so that fog isn't drawn incorrectly on transparent walls after sorting HWR_Lighting(pSurf, lightlevel, wallcolormap); pSurf->PolyColor.s.alpha = alpha; // put the alpha back after lighting - shader = SHADER_WALL; // wall shader - if (blend & PF_Environment) blendmode |= PF_Occlude; // PF_Occlude must be used for solid objects - if (fogwall) + if (HWR_UseShader()) { - blendmode |= PF_Fog; - shader = SHADER_FOG; // fog shader + if (fogwall) + shader = SHADER_FOG; + else + shader = SHADER_WALL; + + blendmode |= PF_ColorMapped; } + if (fogwall) + blendmode |= PF_Fog; + blendmode |= PF_Modulated; // No PF_Occlude means overlapping (incorrect) transparency HWR_ProcessPolygon(pSurf, wallVerts, 4, blendmode, shader, false); } @@ -6647,7 +6705,6 @@ void HWR_DrawScreenFinalTexture(int width, int height) HWD.pfnDrawScreenFinalTexture(width, height); } -// jimita 18032019 static inline UINT16 HWR_FindShaderDefs(UINT16 wadnum) { UINT16 i; diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index 8cd948eea..56e7efc4e 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -909,7 +909,6 @@ void SetupGLFunc4(void) pgluBuild2DMipmaps = GetGLFunc("gluBuild2DMipmaps"); } -// jimita EXPORT boolean HWRAPI(CompileShaders) (void) { #ifdef GL_SHADERS @@ -2144,32 +2143,34 @@ static void PreparePolygon(FSurfaceInfo *pSurf, FOutVector *pOutVerts, FBITFIELD SetBlend(PolyFlags); //TODO: inline (#pragma..) - // PolyColor if (pSurf) { - // If Modulated, mix the surface colour to the texture + // If modulated, mix the surface colour to the texture if (CurrentPolyFlags & PF_Modulated) - { - // Poly color - poly.red = byte2float[pSurf->PolyColor.s.red]; - poly.green = byte2float[pSurf->PolyColor.s.green]; - poly.blue = byte2float[pSurf->PolyColor.s.blue]; - poly.alpha = byte2float[pSurf->PolyColor.s.alpha]; - pglColor4ubv((GLubyte*)&pSurf->PolyColor.s); + + // If the surface is either modulated or colormapped, or both + if (CurrentPolyFlags & (PF_Modulated | PF_ColorMapped)) + { + poly.red = byte2float[pSurf->PolyColor.s.red]; + poly.green = byte2float[pSurf->PolyColor.s.green]; + poly.blue = byte2float[pSurf->PolyColor.s.blue]; + poly.alpha = byte2float[pSurf->PolyColor.s.alpha]; } - // Tint color - tint.red = byte2float[pSurf->TintColor.s.red]; - tint.green = byte2float[pSurf->TintColor.s.green]; - tint.blue = byte2float[pSurf->TintColor.s.blue]; - tint.alpha = byte2float[pSurf->TintColor.s.alpha]; + // Only if the surface is colormapped + if (CurrentPolyFlags & PF_ColorMapped) + { + tint.red = byte2float[pSurf->TintColor.s.red]; + tint.green = byte2float[pSurf->TintColor.s.green]; + tint.blue = byte2float[pSurf->TintColor.s.blue]; + tint.alpha = byte2float[pSurf->TintColor.s.alpha]; - // Fade color - fade.red = byte2float[pSurf->FadeColor.s.red]; - fade.green = byte2float[pSurf->FadeColor.s.green]; - fade.blue = byte2float[pSurf->FadeColor.s.blue]; - fade.alpha = byte2float[pSurf->FadeColor.s.alpha]; + fade.red = byte2float[pSurf->FadeColor.s.red]; + fade.green = byte2float[pSurf->FadeColor.s.green]; + fade.blue = byte2float[pSurf->FadeColor.s.blue]; + fade.alpha = byte2float[pSurf->FadeColor.s.alpha]; + } } // this test is added for new coronas' code (without depth buffer) @@ -2983,7 +2984,6 @@ EXPORT void HWRAPI(SetTransform) (FTransform *stransform) pglMatrixMode(GL_PROJECTION); pglLoadIdentity(); - // jimita 14042019 // Simulate Software's y-shearing // https://zdoom.org/wiki/Y-shearing if (shearing) From 4891611ab73a7ec60119bfee84d5a164b3127611 Mon Sep 17 00:00:00 2001 From: Jaime Ita Passos Date: Wed, 27 Jan 2021 19:23:04 -0300 Subject: [PATCH 0567/1080] tRNS chunk fix Fixes a faulty check not properly detecting the presence of a tRNS chunk. --- src/r_picformats.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/r_picformats.c b/src/r_picformats.c index f87362c76..ac9747426 100644 --- a/src/r_picformats.c +++ b/src/r_picformats.c @@ -979,8 +979,8 @@ static png_bytep *PNG_Read( for (i = 0; i < 256; i++) { - UINT32 rgb = R_PutRgbaRGBA(pal->red, pal->green, pal->blue, 0xFF); - if (rgb != pMasterPalette[i].rgba) + byteColor_t *curpal = &(pMasterPalette[i].s); + if (pal->red != curpal->red || pal->green != curpal->green || pal->blue != curpal->blue) { usepal = false; break; @@ -996,12 +996,12 @@ static png_bytep *PNG_Read( { png_get_tRNS(png_ptr, png_info_ptr, &trans, &trans_num, &trans_values); - if (trans && trans_num == 256) + if (trans && trans_num > 0) { INT32 i; for (i = 0; i < trans_num; i++) { - // libpng will transform this image into RGB even if + // libpng will transform this image into RGBA even if // the transparent index does not exist in the image, // and there is no way around that. if (trans[i] < 0xFF) From 8318935811aab1bfbf28cc072f302000417e6680 Mon Sep 17 00:00:00 2001 From: Jaime Ita Passos Date: Wed, 27 Jan 2021 21:23:20 -0300 Subject: [PATCH 0568/1080] Remove GLMipmap_t.nextmipmap --- src/hardware/hw_data.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/hardware/hw_data.h b/src/hardware/hw_data.h index ce6527666..7e56a14d0 100644 --- a/src/hardware/hw_data.h +++ b/src/hardware/hw_data.h @@ -64,8 +64,6 @@ struct GLMipmap_s struct GLMipmap_s *nextcolormap; struct GLColormap_s *colormap; - - struct GLMipmap_s *nextmipmap; // Linked list of all textures }; typedef struct GLMipmap_s GLMipmap_t; From 3dff1eb1b71af5c483238d63fcf5c6a5adcbecb8 Mon Sep 17 00:00:00 2001 From: LJ Sonic Date: Thu, 11 Feb 2021 00:10:15 +0100 Subject: [PATCH 0569/1080] Fix consoleplayer returning the server player during joining phase --- src/lua_script.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lua_script.c b/src/lua_script.c index bc88928f3..7fd5a98e6 100644 --- a/src/lua_script.c +++ b/src/lua_script.c @@ -333,7 +333,7 @@ int LUA_PushGlobals(lua_State *L, const char *word) return 1; // local player variables, by popular request } else if (fastcmp(word,"consoleplayer")) { // player controlling console (aka local player 1) - if (consoleplayer < 0 || !playeringame[consoleplayer]) + if (!addedtogame || consoleplayer < 0 || !playeringame[consoleplayer]) return 0; LUA_PushUserdata(L, &players[consoleplayer], META_PLAYER); return 1; From dfc1767794c140fc086bcac77c261fcdf39e2270 Mon Sep 17 00:00:00 2001 From: LJ Sonic Date: Thu, 11 Feb 2021 00:24:42 +0100 Subject: [PATCH 0570/1080] Only call PlayerCmd hooks if added to game --- 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 6b7356c52..10bec888f 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1678,7 +1678,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) // At this point, cmd doesn't contain the final angle yet, // So we need to temporarily transform it so Lua scripters // don't need to handle it differently than in other hooks. - if (gamestate == GS_LEVEL) + if (addedtogame && gamestate == GS_LEVEL) { INT16 extra = ticcmd_oldangleturn[forplayer] - player->oldrelangleturn; INT16 origangle = cmd->angleturn; From 326be012760a1f9e1dff38d3162d8120b620a489 Mon Sep 17 00:00:00 2001 From: namishere <50415197+namishere@users.noreply.github.com> Date: Thu, 11 Feb 2021 04:06:40 -0800 Subject: [PATCH 0571/1080] Expose P_ButteredSlope to lua --- src/lua_baselib.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index c5f847be6..240591506 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -2494,6 +2494,17 @@ static int lib_pGetZAt(lua_State *L) return 1; } +static int lib_pButteredSlope(lua_State *L) +{ + mobj_t *mobj = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); + NOHUD + INLEVEL + if (!mobj) + return LUA_ErrInvalid(L, "mobj_t"); + P_ButteredSlope(mobj); + return 0; +} + // R_DEFS //////////// @@ -3932,6 +3943,7 @@ static luaL_Reg lib[] = { // p_slopes {"P_GetZAt",lib_pGetZAt}, + {"P_ButteredSlope",lib_pButteredSlope}, // r_defs {"R_PointToAngle",lib_rPointToAngle}, From eda6b0ad8edb2cfda121f8e5058065975a853a1f Mon Sep 17 00:00:00 2001 From: Nev3r Date: Thu, 11 Feb 2021 13:24:20 +0100 Subject: [PATCH 0572/1080] Remove TAG_ITER_DECLARECOUNTER and the level field on the iterator macros. Declare the position counters inside the for loops instead; RIP C90. --- src/p_ceilng.c | 6 +-- src/p_floor.c | 39 ++++++---------- src/p_lights.c | 3 +- src/p_mobj.c | 6 +-- src/p_setup.c | 8 +--- src/p_slopes.c | 3 +- src/p_spec.c | 122 +++++++++++++++++++++++-------------------------- src/taglist.h | 11 ++--- 8 files changed, 82 insertions(+), 116 deletions(-) diff --git a/src/p_ceilng.c b/src/p_ceilng.c index 2168d1d78..264a6e2c8 100644 --- a/src/p_ceilng.c +++ b/src/p_ceilng.c @@ -395,9 +395,8 @@ INT32 EV_DoCeiling(line_t *line, ceiling_e type) sector_t *sec; ceiling_t *ceiling; mtag_t tag = Tag_FGet(&line->tags); - TAG_ITER_DECLARECOUNTER(0); - TAG_ITER_SECTORS(0, tag, secnum) + TAG_ITER_SECTORS(tag, secnum) { sec = §ors[secnum]; @@ -617,9 +616,8 @@ INT32 EV_DoCrush(line_t *line, ceiling_e type) sector_t *sec; ceiling_t *ceiling; mtag_t tag = Tag_FGet(&line->tags); - TAG_ITER_DECLARECOUNTER(0); - TAG_ITER_SECTORS(0, tag, secnum) + TAG_ITER_SECTORS(tag, secnum) { sec = §ors[secnum]; diff --git a/src/p_floor.c b/src/p_floor.c index de8f5d4e8..86a2a9319 100644 --- a/src/p_floor.c +++ b/src/p_floor.c @@ -635,7 +635,6 @@ void T_BounceCheese(bouncecheese_t *bouncer) boolean remove; INT32 i; mtag_t tag = Tag_FGet(&bouncer->sourceline->tags); - TAG_ITER_DECLARECOUNTER(0); if (bouncer->sector->crumblestate == CRUMBLE_RESTORE || bouncer->sector->crumblestate == CRUMBLE_WAIT || bouncer->sector->crumblestate == CRUMBLE_ACTIVATED) // Oops! Crumbler says to remove yourself! @@ -650,7 +649,7 @@ void T_BounceCheese(bouncecheese_t *bouncer) } // You can use multiple target sectors, but at your own risk!!! - TAG_ITER_SECTORS(0, tag, i) + TAG_ITER_SECTORS(tag, i) { actionsector = §ors[i]; actionsector->moved = true; @@ -775,7 +774,6 @@ void T_StartCrumble(crumble_t *crumble) sector_t *sector; INT32 i; mtag_t tag = Tag_FGet(&crumble->sourceline->tags); - TAG_ITER_DECLARECOUNTER(0); // Once done, the no-return thinker just sits there, // constantly 'returning'... kind of an oxymoron, isn't it? @@ -804,7 +802,7 @@ void T_StartCrumble(crumble_t *crumble) } else if (++crumble->timer == 0) // Reposition back to original spot { - TAG_ITER_SECTORS(0, tag, i) + TAG_ITER_SECTORS(tag, i) { sector = §ors[i]; @@ -840,7 +838,7 @@ void T_StartCrumble(crumble_t *crumble) // Flash to indicate that the platform is about to return. if (crumble->timer > -224 && (leveltime % ((abs(crumble->timer)/8) + 1) == 0)) { - TAG_ITER_SECTORS(0, tag, i) + TAG_ITER_SECTORS(tag, i) { sector = §ors[i]; @@ -932,7 +930,7 @@ void T_StartCrumble(crumble_t *crumble) P_RemoveThinker(&crumble->thinker); } - TAG_ITER_SECTORS(0, tag, i) + TAG_ITER_SECTORS(tag, i) { sector = §ors[i]; sector->moved = true; @@ -948,7 +946,6 @@ void T_StartCrumble(crumble_t *crumble) void T_MarioBlock(mariothink_t *block) { INT32 i; - TAG_ITER_DECLARECOUNTER(0); T_MovePlane ( @@ -983,7 +980,7 @@ void T_MarioBlock(mariothink_t *block) block->sector->ceilspeed = 0; block->direction = 0; } - TAG_ITER_SECTORS(0, (INT16)block->tag, i) + TAG_ITER_SECTORS((INT16)block->tag, i) P_RecalcPrecipInSector(§ors[i]); } @@ -1293,9 +1290,8 @@ void T_NoEnemiesSector(noenemies_t *nobaddies) INT32 secnum = -1; boolean FOFsector = false; mtag_t tag = Tag_FGet(&nobaddies->sourceline->tags); - TAG_ITER_DECLARECOUNTER(0); - TAG_ITER_SECTORS(0, tag, secnum) + TAG_ITER_SECTORS(tag, secnum) { sec = §ors[secnum]; @@ -1306,14 +1302,13 @@ void T_NoEnemiesSector(noenemies_t *nobaddies) { INT32 targetsecnum = -1; mtag_t tag2 = Tag_FGet(&sec->lines[i]->tags); - TAG_ITER_DECLARECOUNTER(1); if (sec->lines[i]->special < 100 || sec->lines[i]->special >= 300) continue; FOFsector = true; - TAG_ITER_SECTORS(1, tag2, targetsecnum) + TAG_ITER_SECTORS(tag2, targetsecnum) { if (T_SectorHasEnemies(§ors[targetsecnum])) return; @@ -1400,7 +1395,6 @@ void T_EachTimeThinker(eachtime_t *eachtime) fixed_t bottomheight, topheight; ffloor_t *rover; mtag_t tag = Tag_FGet(&eachtime->sourceline->tags); - TAG_ITER_DECLARECOUNTER(0); for (i = 0; i < MAXPLAYERS; i++) { @@ -1410,7 +1404,7 @@ void T_EachTimeThinker(eachtime_t *eachtime) eachtime->playersOnArea[i] = false; } - TAG_ITER_SECTORS(0, tag, secnum) + TAG_ITER_SECTORS(tag, secnum) { sec = §ors[secnum]; @@ -1428,14 +1422,13 @@ void T_EachTimeThinker(eachtime_t *eachtime) { INT32 targetsecnum = -1; mtag_t tag2 = Tag_FGet(&sec->lines[i]->tags); - TAG_ITER_DECLARECOUNTER(1); if (sec->lines[i]->special < 100 || sec->lines[i]->special >= 300) continue; FOFsector = true; - TAG_ITER_SECTORS(1, tag2, targetsecnum) + TAG_ITER_SECTORS(tag2, targetsecnum) { targetsec = §ors[targetsecnum]; @@ -1570,12 +1563,11 @@ void T_RaiseSector(raise_t *raise) INT32 direction; result_e res = 0; mtag_t tag = raise->tag; - TAG_ITER_DECLARECOUNTER(0); if (raise->sector->crumblestate >= CRUMBLE_FALL || raise->sector->ceilingdata) return; - TAG_ITER_SECTORS(0, tag, i) + TAG_ITER_SECTORS(tag, i) { sector = §ors[i]; @@ -1702,7 +1694,7 @@ void T_RaiseSector(raise_t *raise) raise->sector->ceilspeed = 42; raise->sector->floorspeed = speed*direction; - TAG_ITER_SECTORS(0, tag, i) + TAG_ITER_SECTORS(tag, i) P_RecalcPrecipInSector(§ors[i]); } @@ -1820,9 +1812,8 @@ void EV_DoFloor(line_t *line, floor_e floortype) sector_t *sec; floormove_t *dofloor; mtag_t tag = Tag_FGet(&line->tags); - TAG_ITER_DECLARECOUNTER(0); - TAG_ITER_SECTORS(0, tag, secnum) + TAG_ITER_SECTORS(tag, secnum) { sec = §ors[secnum]; @@ -2037,10 +2028,9 @@ void EV_DoElevator(line_t *line, elevator_e elevtype, boolean customspeed) sector_t *sec; elevator_t *elevator; mtag_t tag = Tag_FGet(&line->tags); - TAG_ITER_DECLARECOUNTER(0); // act on all sectors with the same tag as the triggering linedef - TAG_ITER_SECTORS(0, tag, secnum) + TAG_ITER_SECTORS(tag, secnum) { sec = §ors[secnum]; @@ -2337,7 +2327,6 @@ INT32 EV_StartCrumble(sector_t *sec, ffloor_t *rover, boolean floating, sector_t *foundsec; INT32 i; mtag_t tag = Tag_FGet(&rover->master->tags); - TAG_ITER_DECLARECOUNTER(0); // If floor is already activated, skip it if (sec->floordata) @@ -2380,7 +2369,7 @@ INT32 EV_StartCrumble(sector_t *sec, ffloor_t *rover, boolean floating, crumble->sector->crumblestate = CRUMBLE_ACTIVATED; - TAG_ITER_SECTORS(0, tag, i) + TAG_ITER_SECTORS(tag, i) { foundsec = §ors[i]; diff --git a/src/p_lights.c b/src/p_lights.c index d396e92d3..3fc8e6c10 100644 --- a/src/p_lights.c +++ b/src/p_lights.c @@ -374,10 +374,9 @@ void P_FadeLightBySector(sector_t *sector, INT32 destvalue, INT32 speed, boolean void P_FadeLight(INT16 tag, INT32 destvalue, INT32 speed, boolean ticbased, boolean force) { INT32 i; - TAG_ITER_DECLARECOUNTER(0); // search all sectors for ones with tag - TAG_ITER_SECTORS(0, tag, i) + TAG_ITER_SECTORS(tag, i) { if (!force && ticbased // always let speed fader execute && sectors[i].lightingdata diff --git a/src/p_mobj.c b/src/p_mobj.c index 69eecd26d..2b408b2fd 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -4607,9 +4607,8 @@ static boolean P_Boss4MoveCage(mobj_t *mobj, fixed_t delta) INT32 snum; sector_t *sector; boolean gotcage = false; - TAG_ITER_DECLARECOUNTER(0); - TAG_ITER_SECTORS(0, tag, snum) + TAG_ITER_SECTORS(tag, snum) { sector = §ors[snum]; sector->floorheight += delta; @@ -4693,9 +4692,8 @@ static void P_Boss4DestroyCage(mobj_t *mobj) size_t a; sector_t *sector, *rsec; ffloor_t *rover; - TAG_ITER_DECLARECOUNTER(0); - TAG_ITER_SECTORS(0, tag, snum) + TAG_ITER_SECTORS(tag, snum) { sector = §ors[snum]; diff --git a/src/p_setup.c b/src/p_setup.c index 2c0b84ba6..e93d930da 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2966,9 +2966,7 @@ static void P_ConvertBinaryMap(void) INT32 check = -1; INT32 paramline = -1; - TAG_ITER_DECLARECOUNTER(0); - - TAG_ITER_LINES(0, tag, check) + TAG_ITER_LINES(tag, check) { if (lines[check].special == 22) { @@ -3183,11 +3181,9 @@ static void P_ConvertBinaryMap(void) INT32 firstline = -1; mtag_t tag = mapthings[i].angle; - TAG_ITER_DECLARECOUNTER(0); - Tag_FSet(&mapthings[i].tags, tag); - TAG_ITER_LINES(0, tag, check) + TAG_ITER_LINES(tag, check) { if (lines[check].special == 20) { diff --git a/src/p_slopes.c b/src/p_slopes.c index d77d0805f..29fbb308f 100644 --- a/src/p_slopes.c +++ b/src/p_slopes.c @@ -546,11 +546,10 @@ static boolean P_SetSlopeFromTag(sector_t *sec, INT32 tag, boolean ceiling) { INT32 i; pslope_t **secslope = ceiling ? &sec->c_slope : &sec->f_slope; - TAG_ITER_DECLARECOUNTER(0); if (!tag || *secslope) return false; - TAG_ITER_SECTORS(0, tag, i) + TAG_ITER_SECTORS(tag, i) { pslope_t *srcslope = ceiling ? sectors[i].c_slope : sectors[i].f_slope; if (srcslope) diff --git a/src/p_spec.c b/src/p_spec.c index eb14f8dd6..998f8d9e3 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -2223,7 +2223,6 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) INT32 secnum = -1; mobj_t *bot = NULL; mtag_t tag = Tag_FGet(&line->tags); - TAG_ITER_DECLARECOUNTER(0); I_Assert(!mo || !P_MobjWasRemoved(mo)); // If mo is there, mo must be valid! @@ -2251,7 +2250,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) newceilinglightsec = line->frontsector->ceilinglightsec; // act on all sectors with the same tag as the triggering linedef - TAG_ITER_SECTORS(0, tag, secnum) + TAG_ITER_SECTORS(tag, secnum) { if (sectors[secnum].lightingdata) { @@ -2306,7 +2305,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) case 409: // Change tagged sectors' tag // (formerly "Change calling sectors' tag", but behavior was changed) { - TAG_ITER_SECTORS(0, tag, secnum) + TAG_ITER_SECTORS(tag, secnum) Tag_SectorFSet(secnum,(INT16)(sides[line->sidenum[0]].textureoffset>>FRACBITS)); break; } @@ -2316,7 +2315,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) break; case 411: // Stop floor/ceiling movement in tagged sector(s) - TAG_ITER_SECTORS(0, tag, secnum) + TAG_ITER_SECTORS(tag, secnum) { if (sectors[secnum].floordata) { @@ -2501,7 +2500,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) // Additionally play the sound from tagged sectors' soundorgs sector_t *sec; - TAG_ITER_SECTORS(0, tag, secnum) + TAG_ITER_SECTORS(tag, secnum) { sec = §ors[secnum]; S_StartSound(&sec->soundorg, sfxnum); @@ -2616,7 +2615,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) break; case 416: // Spawn adjustable fire flicker - TAG_ITER_SECTORS(0, tag, secnum) + TAG_ITER_SECTORS(tag, secnum) { if (line->flags & ML_NOCLIMB && line->backsector) { @@ -2650,7 +2649,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) break; case 417: // Spawn adjustable glowing light - TAG_ITER_SECTORS(0, tag, secnum) + TAG_ITER_SECTORS(tag, secnum) { if (line->flags & ML_NOCLIMB && line->backsector) { @@ -2684,7 +2683,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) break; case 418: // Spawn adjustable strobe flash (unsynchronized) - TAG_ITER_SECTORS(0, tag, secnum) + TAG_ITER_SECTORS(tag, secnum) { if (line->flags & ML_NOCLIMB && line->backsector) { @@ -2718,7 +2717,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) break; case 419: // Spawn adjustable strobe flash (synchronized) - TAG_ITER_SECTORS(0, tag, secnum) + TAG_ITER_SECTORS(tag, secnum) { if (line->flags & ML_NOCLIMB && line->backsector) { @@ -2766,7 +2765,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) break; case 421: // Stop lighting effect in tagged sectors - TAG_ITER_SECTORS(0, tag, secnum) + TAG_ITER_SECTORS(tag, secnum) if (sectors[secnum].lightingdata) { P_RemoveThinker(&((elevator_t *)sectors[secnum].lightingdata)->thinker); @@ -2980,7 +2979,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) ffloor_t *rover; // FOF that we are going to crumble boolean foundrover = false; // for debug, "Can't find a FOF" message - TAG_ITER_SECTORS(0, sectag, secnum) + TAG_ITER_SECTORS(sectag, secnum) { sec = sectors + secnum; @@ -3105,7 +3104,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) if (line->sidenum[1] != 0xffff) state = (statenum_t)sides[line->sidenum[1]].toptexture; - TAG_ITER_SECTORS(0, tag, secnum) + TAG_ITER_SECTORS(tag, secnum) { boolean tryagain; sec = sectors + secnum; @@ -3165,7 +3164,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) boolean foundrover = false; // for debug, "Can't find a FOF" message ffloortype_e oldflags; // store FOF's old flags - TAG_ITER_SECTORS(0, sectag, secnum) + TAG_ITER_SECTORS(sectag, secnum) { sec = sectors + secnum; @@ -3223,7 +3222,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) if (line->flags & ML_NOCLIMB) // don't respawn! respawn = false; - TAG_ITER_SECTORS(0, sectag, secnum) + TAG_ITER_SECTORS(sectag, secnum) { sec = sectors + secnum; @@ -3279,7 +3278,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) source = sectors[sourcesec].extra_colormap; } } - TAG_ITER_SECTORS(0, line->args[0], secnum) + TAG_ITER_SECTORS(line->args[0], secnum) { if (sectors[secnum].colormap_protected) continue; @@ -3414,7 +3413,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) ffloor_t *rover; // FOF that we are going to operate boolean foundrover = false; // for debug, "Can't find a FOF" message - TAG_ITER_SECTORS(0, sectag, secnum) + TAG_ITER_SECTORS(sectag, secnum) { sec = sectors + secnum; @@ -3478,7 +3477,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) boolean foundrover = false; // for debug, "Can't find a FOF" message size_t j = 0; // sec->ffloors is saved as ffloor #0, ss->ffloors->next is #1, etc - TAG_ITER_SECTORS(0, sectag, secnum) + TAG_ITER_SECTORS(sectag, secnum) { sec = sectors + secnum; @@ -3563,7 +3562,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) ffloor_t *rover; // FOF that we are going to operate boolean foundrover = false; // for debug, "Can't find a FOF" message - TAG_ITER_SECTORS(0, sectag, secnum) + TAG_ITER_SECTORS(sectag, secnum) { sec = sectors + secnum; @@ -3614,7 +3613,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) } } - TAG_ITER_SECTORS(0, line->args[0], secnum) + TAG_ITER_SECTORS(line->args[0], secnum) { extracolormap_t *source_exc, *dest_exc, *exc; @@ -3694,7 +3693,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) break; } case 456: // Stop fade colormap - TAG_ITER_SECTORS(0, line->args[0], secnum) + TAG_ITER_SECTORS(line->args[0], secnum) P_ResetColormapFader(§ors[secnum]); break; @@ -3887,12 +3886,11 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) case 465: // Set linedef executor delay { INT32 linenum; - TAG_ITER_DECLARECOUNTER(1); if (!udmf) break; - TAG_ITER_LINES(1, line->args[0], linenum) + TAG_ITER_LINES(line->args[0], linenum) { if (line->args[2]) lines[linenum].executordelay += line->args[1]; @@ -5928,9 +5926,8 @@ void T_LaserFlash(laserthink_t *flash) sector_t *sector; sector_t *sourcesec = flash->sourceline->frontsector; fixed_t top, bottom; - TAG_ITER_DECLARECOUNTER(0); - TAG_ITER_SECTORS(0, flash->tag, s) + TAG_ITER_SECTORS(flash->tag, s) { sector = §ors[s]; for (fflr = sector->ffloors; fflr; fflr = fflr->next) @@ -6210,11 +6207,10 @@ void P_SpawnSpecials(boolean fromnetsave) INT32 s; size_t sec; ffloortype_e ffloorflags; - TAG_ITER_DECLARECOUNTER(0); case 1: // Definable gravity per sector sec = sides[*lines[i].sidenum].sector - sectors; - TAG_ITER_SECTORS(0, tag, s) + TAG_ITER_SECTORS(tag, s) { sectors[s].gravity = §ors[sec].floorheight; // This allows it to change in realtime! @@ -6238,7 +6234,7 @@ void P_SpawnSpecials(boolean fromnetsave) case 5: // Change camera info sec = sides[*lines[i].sidenum].sector - sectors; - TAG_ITER_SECTORS(0, tag, s) + TAG_ITER_SECTORS(tag, s) P_AddCameraScanner(§ors[sec], §ors[s], R_PointToAngle2(lines[i].v2->x, lines[i].v2->y, lines[i].v1->x, lines[i].v1->y)); break; @@ -6265,7 +6261,7 @@ void P_SpawnSpecials(boolean fromnetsave) P_ApplyFlatAlignment(lines + i, lines[i].frontsector, flatangle, xoffs, yoffs); else { - TAG_ITER_SECTORS(0, tag, s) + TAG_ITER_SECTORS(tag, s) P_ApplyFlatAlignment(lines + i, sectors + s, flatangle, xoffs, yoffs); } } @@ -6276,7 +6272,7 @@ void P_SpawnSpecials(boolean fromnetsave) break; case 8: // Sector Parameters - TAG_ITER_SECTORS(0, tag, s) + TAG_ITER_SECTORS(tag, s) { if (lines[i].flags & ML_NOCLIMB) { @@ -6303,7 +6299,7 @@ void P_SpawnSpecials(boolean fromnetsave) break; case 10: // Vertical culling plane for sprites and FOFs - TAG_ITER_SECTORS(0, tag, s) + TAG_ITER_SECTORS(tag, s) sectors[s].cullheight = &lines[i]; // This allows it to change in realtime! break; @@ -6364,19 +6360,19 @@ void P_SpawnSpecials(boolean fromnetsave) case 63: // support for drawn heights coming from different sector sec = sides[*lines[i].sidenum].sector-sectors; - TAG_ITER_SECTORS(0, tag, s) + TAG_ITER_SECTORS(tag, s) sectors[s].heightsec = (INT32)sec; break; case 64: // Appearing/Disappearing FOF option if (lines[i].flags & ML_BLOCKMONSTERS) { // Find FOFs by control sector tag - TAG_ITER_SECTORS(0, tag, s) + TAG_ITER_SECTORS(tag, s) for (j = 0; (unsigned)j < sectors[s].linecount; j++) if (sectors[s].lines[j]->special >= 100 && sectors[s].lines[j]->special < 300) Add_MasterDisappearer(abs(lines[i].dx>>FRACBITS), abs(lines[i].dy>>FRACBITS), abs(sides[lines[i].sidenum[0]].sector->floorheight>>FRACBITS), (INT32)(sectors[s].lines[j]-lines), (INT32)i); } else // Find FOFs by effect sector tag { - TAG_ITER_LINES(0, tag, s) + TAG_ITER_LINES(tag, s) { if ((size_t)s == i) continue; @@ -6387,15 +6383,15 @@ void P_SpawnSpecials(boolean fromnetsave) break; case 66: // Displace floor by front sector - TAG_ITER_SECTORS(0, tag, s) + TAG_ITER_SECTORS(tag, s) P_AddPlaneDisplaceThinker(pd_floor, FixedHypot(lines[i].dx, lines[i].dy)>>8, sides[lines[i].sidenum[0]].sector-sectors, s, !!(lines[i].flags & ML_NOCLIMB)); break; case 67: // Displace ceiling by front sector - TAG_ITER_SECTORS(0, tag, s) + TAG_ITER_SECTORS(tag, s) P_AddPlaneDisplaceThinker(pd_ceiling, FixedHypot(lines[i].dx, lines[i].dy)>>8, sides[lines[i].sidenum[0]].sector-sectors, s, !!(lines[i].flags & ML_NOCLIMB)); break; case 68: // Displace both floor AND ceiling by front sector - TAG_ITER_SECTORS(0, tag, s) + TAG_ITER_SECTORS(tag, s) P_AddPlaneDisplaceThinker(pd_both, FixedHypot(lines[i].dx, lines[i].dy)>>8, sides[lines[i].sidenum[0]].sector-sectors, s, !!(lines[i].flags & ML_NOCLIMB)); break; @@ -6991,46 +6987,46 @@ void P_SpawnSpecials(boolean fromnetsave) case 600: // floor lighting independently (e.g. lava) sec = sides[*lines[i].sidenum].sector-sectors; - TAG_ITER_SECTORS(0, tag, s) + TAG_ITER_SECTORS(tag, s) sectors[s].floorlightsec = (INT32)sec; break; case 601: // ceiling lighting independently sec = sides[*lines[i].sidenum].sector-sectors; - TAG_ITER_SECTORS(0, tag, s) + TAG_ITER_SECTORS(tag, s) sectors[s].ceilinglightsec = (INT32)sec; break; case 602: // Adjustable pulsating light sec = sides[*lines[i].sidenum].sector - sectors; - TAG_ITER_SECTORS(0, tag, s) + TAG_ITER_SECTORS(tag, s) P_SpawnAdjustableGlowingLight(§ors[sec], §ors[s], FixedHypot(lines[i].dx, lines[i].dy)>>FRACBITS); break; case 603: // Adjustable flickering light sec = sides[*lines[i].sidenum].sector - sectors; - TAG_ITER_SECTORS(0, tag, s) + TAG_ITER_SECTORS(tag, s) P_SpawnAdjustableFireFlicker(§ors[sec], §ors[s], FixedHypot(lines[i].dx, lines[i].dy)>>FRACBITS); break; case 604: // Adjustable Blinking Light (unsynchronized) sec = sides[*lines[i].sidenum].sector - sectors; - TAG_ITER_SECTORS(0, tag, s) + TAG_ITER_SECTORS(tag, s) P_SpawnAdjustableStrobeFlash(§ors[sec], §ors[s], abs(lines[i].dx)>>FRACBITS, abs(lines[i].dy)>>FRACBITS, false); break; case 605: // Adjustable Blinking Light (synchronized) sec = sides[*lines[i].sidenum].sector - sectors; - TAG_ITER_SECTORS(0, tag, s) + TAG_ITER_SECTORS(tag, s) P_SpawnAdjustableStrobeFlash(§ors[sec], §ors[s], abs(lines[i].dx)>>FRACBITS, abs(lines[i].dy)>>FRACBITS, true); break; case 606: // HACK! Copy colormaps. Just plain colormaps. - TAG_ITER_SECTORS(0, lines[i].args[0], s) + TAG_ITER_SECTORS(lines[i].args[0], s) { extracolormap_t *exc; @@ -7104,13 +7100,12 @@ void P_SpawnSpecials(boolean fromnetsave) */ static void P_AddFakeFloorsByLine(size_t line, ffloortype_e ffloorflags, thinkerlist_t *secthinkers) { - TAG_ITER_DECLARECOUNTER(0); INT32 s; mtag_t tag = Tag_FGet(&lines[line].tags); size_t sec = sides[*lines[line].sidenum].sector-sectors; line_t* li = lines + line; - TAG_ITER_SECTORS(0, tag, s) + TAG_ITER_SECTORS(tag, s) P_AddFakeFloor(§ors[s], §ors[sec], li, ffloorflags, secthinkers); } @@ -7220,7 +7215,6 @@ void T_Scroll(scroll_t *s) size_t i; INT32 sect; ffloor_t *rover; - TAG_ITER_DECLARECOUNTER(0); case sc_side: // scroll wall texture side = sides + s->affectee; @@ -7257,7 +7251,7 @@ void T_Scroll(scroll_t *s) if (!is3dblock) continue; - TAG_ITER_SECTORS(0, Tag_FGet(&line->tags), sect) + TAG_ITER_SECTORS(Tag_FGet(&line->tags), sect) { sector_t *psec; psec = sectors + sect; @@ -7332,7 +7326,7 @@ void T_Scroll(scroll_t *s) if (!is3dblock) continue; - TAG_ITER_SECTORS(0, Tag_FGet(&line->tags), sect) + TAG_ITER_SECTORS(Tag_FGet(&line->tags), sect) { sector_t *psec; psec = sectors + sect; @@ -7472,11 +7466,10 @@ static void P_SpawnScrollers(void) switch (special) { register INT32 s; - TAG_ITER_DECLARECOUNTER(0); case 513: // scroll effect ceiling case 533: // scroll and carry objects on ceiling - TAG_ITER_SECTORS(0, tag, s) + TAG_ITER_SECTORS(tag, s) Add_Scroller(sc_ceiling, -dx, dy, control, s, accel, l->flags & ML_NOCLIMB); if (special != 533) break; @@ -7485,13 +7478,13 @@ static void P_SpawnScrollers(void) case 523: // carry objects on ceiling dx = FixedMul(dx, CARRYFACTOR); dy = FixedMul(dy, CARRYFACTOR); - TAG_ITER_SECTORS(0, tag, s) + TAG_ITER_SECTORS(tag, s) Add_Scroller(sc_carry_ceiling, dx, dy, control, s, accel, l->flags & ML_NOCLIMB); break; case 510: // scroll effect floor case 530: // scroll and carry objects on floor - TAG_ITER_SECTORS(0, tag, s) + TAG_ITER_SECTORS(tag, s) Add_Scroller(sc_floor, -dx, dy, control, s, accel, l->flags & ML_NOCLIMB); if (special != 530) break; @@ -7500,7 +7493,7 @@ static void P_SpawnScrollers(void) case 520: // carry objects on floor dx = FixedMul(dx, CARRYFACTOR); dy = FixedMul(dy, CARRYFACTOR); - TAG_ITER_SECTORS(0, tag, s) + TAG_ITER_SECTORS(tag, s) Add_Scroller(sc_carry, dx, dy, control, s, accel, l->flags & ML_NOCLIMB); break; @@ -7508,7 +7501,7 @@ static void P_SpawnScrollers(void) // (same direction and speed as scrolling floors) case 502: { - TAG_ITER_LINES(0, tag, s) + TAG_ITER_LINES(tag, s) if (s != (INT32)i) { if (l->flags & ML_EFFECT2) // use texture offsets instead @@ -7610,9 +7603,8 @@ void T_Disappear(disappear_t *d) ffloor_t *rover; register INT32 s; mtag_t afftag = Tag_FGet(&lines[d->affectee].tags); - TAG_ITER_DECLARECOUNTER(0); - TAG_ITER_SECTORS(0, afftag, s) + TAG_ITER_SECTORS(afftag, s) { for (rover = sectors[s].ffloors; rover; rover = rover->next) { @@ -8343,7 +8335,6 @@ static void P_SpawnFriction(void) fixed_t strength; // frontside texture offset controls magnitude fixed_t friction; // friction value to be applied during movement INT32 movefactor; // applied to each player move to simulate inertia - TAG_ITER_DECLARECOUNTER(0); for (i = 0; i < numlines; i++, l++) if (l->special == 540) @@ -8369,7 +8360,7 @@ static void P_SpawnFriction(void) else movefactor = FRACUNIT; - TAG_ITER_SECTORS(0, tag, s) + TAG_ITER_SECTORS(tag, s) Add_Friction(friction, movefactor, s, -1); } } @@ -8888,7 +8879,6 @@ static void P_SpawnPushers(void) mtag_t tag; register INT32 s; mobj_t *thing; - TAG_ITER_DECLARECOUNTER(0); for (i = 0; i < numlines; i++, l++) { @@ -8896,15 +8886,15 @@ static void P_SpawnPushers(void) switch (l->special) { case 541: // wind - TAG_ITER_SECTORS(0, tag, s) + TAG_ITER_SECTORS(tag, s) Add_Pusher(p_wind, l->dx, l->dy, NULL, s, -1, l->flags & ML_NOCLIMB, l->flags & ML_EFFECT4); break; case 544: // current - TAG_ITER_SECTORS(0, tag, s) + TAG_ITER_SECTORS(tag, s) Add_Pusher(p_current, l->dx, l->dy, NULL, s, -1, l->flags & ML_NOCLIMB, l->flags & ML_EFFECT4); break; case 547: // push/pull - TAG_ITER_SECTORS(0, tag, s) + TAG_ITER_SECTORS(tag, s) { thing = P_GetPushThing(s); if (thing) // No MT_P* means no effect @@ -8912,19 +8902,19 @@ static void P_SpawnPushers(void) } break; case 545: // current up - TAG_ITER_SECTORS(0, tag, s) + TAG_ITER_SECTORS(tag, s) Add_Pusher(p_upcurrent, l->dx, l->dy, NULL, s, -1, l->flags & ML_NOCLIMB, l->flags & ML_EFFECT4); break; case 546: // current down - TAG_ITER_SECTORS(0, tag, s) + TAG_ITER_SECTORS(tag, s) Add_Pusher(p_downcurrent, l->dx, l->dy, NULL, s, -1, l->flags & ML_NOCLIMB, l->flags & ML_EFFECT4); break; case 542: // wind up - TAG_ITER_SECTORS(0, tag, s) + TAG_ITER_SECTORS(tag, s) Add_Pusher(p_upwind, l->dx, l->dy, NULL, s, -1, l->flags & ML_NOCLIMB, l->flags & ML_EFFECT4); break; case 543: // wind down - TAG_ITER_SECTORS(0, tag, s) + TAG_ITER_SECTORS(tag, s) Add_Pusher(p_downwind, l->dx, l->dy, NULL, s, -1, l->flags & ML_NOCLIMB, l->flags & ML_EFFECT4); break; } diff --git a/src/taglist.h b/src/taglist.h index a0529ab6b..df0606a68 100644 --- a/src/taglist.h +++ b/src/taglist.h @@ -71,15 +71,12 @@ INT32 Tag_Iterate_Things (const mtag_t tag, const size_t p); INT32 Tag_FindLineSpecial(const INT16 special, const mtag_t tag); INT32 P_FindSpecialLineFromTag(INT16 special, INT16 tag, INT32 start); -// Use this macro to declare an iterator position variable. -#define TAG_ITER_DECLARECOUNTER(level) size_t ICNT_##level - -#define TAG_ITER(level, fn, tag, return_varname) for(ICNT_##level = 0; (return_varname = fn(tag, ICNT_##level)) >= 0; ICNT_##level++) +#define TAG_ITER(fn, tag, return_varname) for(size_t ICNT_ ## __LINE__ = 0; (return_varname = fn(tag, ICNT_ ## __LINE__)) >= 0; ICNT_ ## __LINE__++) // Use these macros as wrappers for a taglist iteration. -#define TAG_ITER_SECTORS(level, tag, return_varname) TAG_ITER(level, Tag_Iterate_Sectors, tag, return_varname) -#define TAG_ITER_LINES(level, tag, return_varname) TAG_ITER(level, Tag_Iterate_Lines, tag, return_varname) -#define TAG_ITER_THINGS(level, tag, return_varname) TAG_ITER(level, Tag_Iterate_Things, tag, return_varname) +#define TAG_ITER_SECTORS(tag, return_varname) TAG_ITER(Tag_Iterate_Sectors, tag, return_varname) +#define TAG_ITER_LINES(tag, return_varname) TAG_ITER(Tag_Iterate_Lines, tag, return_varname) +#define TAG_ITER_THINGS(tag, return_varname) TAG_ITER(Tag_Iterate_Things, tag, return_varname) /* ITERATION MACROS TAG_ITER_DECLARECOUNTER must be used before using the iterators. From fbe2a19c6037bc141dbe56304164a6a80de23316 Mon Sep 17 00:00:00 2001 From: Nev3r Date: Thu, 11 Feb 2021 14:12:50 +0100 Subject: [PATCH 0573/1080] Fix __LINE__ macro expansion via recursive macro expansion; C macros sure are something sometimes... --- src/taglist.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/taglist.h b/src/taglist.h index df0606a68..b02fc34dd 100644 --- a/src/taglist.h +++ b/src/taglist.h @@ -71,7 +71,9 @@ INT32 Tag_Iterate_Things (const mtag_t tag, const size_t p); INT32 Tag_FindLineSpecial(const INT16 special, const mtag_t tag); INT32 P_FindSpecialLineFromTag(INT16 special, INT16 tag, INT32 start); -#define TAG_ITER(fn, tag, return_varname) for(size_t ICNT_ ## __LINE__ = 0; (return_varname = fn(tag, ICNT_ ## __LINE__)) >= 0; ICNT_ ## __LINE__++) +#define ICNAME2(id) ICNT_##id +#define ICNAME(id) ICNAME2(id) +#define TAG_ITER(fn, tag, return_varname) for(size_t ICNAME(__LINE__) = 0; (return_varname = fn(tag, ICNAME(__LINE__))) >= 0; ICNAME(__LINE__)++) // Use these macros as wrappers for a taglist iteration. #define TAG_ITER_SECTORS(tag, return_varname) TAG_ITER(Tag_Iterate_Sectors, tag, return_varname) From a57c695f79de5e863e1c708c340fa30c9735e665 Mon Sep 17 00:00:00 2001 From: Nev3r Date: Thu, 11 Feb 2021 14:22:49 +0100 Subject: [PATCH 0574/1080] Update example comment. --- src/taglist.h | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/src/taglist.h b/src/taglist.h index b02fc34dd..2dd160c9a 100644 --- a/src/taglist.h +++ b/src/taglist.h @@ -81,14 +81,6 @@ INT32 P_FindSpecialLineFromTag(INT16 special, INT16 tag, INT32 start); #define TAG_ITER_THINGS(tag, return_varname) TAG_ITER(Tag_Iterate_Things, tag, return_varname) /* ITERATION MACROS -TAG_ITER_DECLARECOUNTER must be used before using the iterators. - -'level': -For each nested iteration, an additional TAG_ITER_DECLARECOUNTER -must be used with a different level number to avoid conflict with -the outer iterations. -Most cases don't have nested iterations and thus the level is just 0. - 'tag': Pretty much the elements' tag to iterate through. @@ -98,17 +90,12 @@ Target variable's name to return the iteration results to. EXAMPLE: { - TAG_ITER_DECLARECOUNTER(0); - TAG_ITER_DECLARECOUNTER(1); // For the nested iteration. - size_t li; - size_t sec; - INT32 tag1 = 4; ... - TAG_ITER_LINES(0, tag1, li) + TAG_ITER_LINES(tag1, li) { line_t *line = lines + li; @@ -116,11 +103,11 @@ EXAMPLE: if (something) { + size_t sec; mtag_t tag2 = 8; - // Nested iteration; just make sure the level is higher - // and that it has its own counter declared in scope. - TAG_ITER_SECTORS(1, tag2, sec) + // Nested iteration. + TAG_ITER_SECTORS(tag2, sec) { sector_t *sector = sectors + sec; From 09d911a5b607d889ecd7a6ae182f372badb296b7 Mon Sep 17 00:00:00 2001 From: LJ Sonic Date: Sat, 13 Feb 2021 17:45:20 +0100 Subject: [PATCH 0575/1080] Revert "Replace all instances of P_AproxDistance with FixedHypot" This reverts commit 75633bde5039106c5f916ca2b4d1bde11d274be9. --- src/b_bot.c | 10 +-- src/g_game.c | 2 +- src/p_ceilng.c | 4 +- src/p_enemy.c | 172 ++++++++++++++++++++++++------------------------ src/p_floor.c | 10 +-- src/p_inter.c | 20 +++--- src/p_map.c | 10 +-- src/p_maputl.h | 1 + src/p_mobj.c | 78 +++++++++++----------- src/p_polyobj.c | 2 +- src/p_setup.c | 2 +- src/p_slopes.c | 2 +- src/p_spec.c | 58 ++++++++-------- src/p_user.c | 56 ++++++++-------- src/r_things.c | 4 +- src/s_sound.c | 4 +- src/st_stuff.c | 2 +- 17 files changed, 219 insertions(+), 218 deletions(-) diff --git a/src/b_bot.c b/src/b_bot.c index abe69caeb..d3635f32c 100644 --- a/src/b_bot.c +++ b/src/b_bot.c @@ -54,11 +54,11 @@ static void B_BuildTailsTiccmd(mobj_t *sonic, mobj_t *tails, ticcmd_t *cmd) boolean _2d = (tails->flags2 & MF2_TWOD) || twodlevel; fixed_t scale = tails->scale; - fixed_t dist = FixedHypot(sonic->x - tails->x, sonic->y - tails->y); + fixed_t dist = P_AproxDistance(sonic->x - tails->x, sonic->y - tails->y); fixed_t zdist = flip * (sonic->z - tails->z); angle_t ang = sonic->angle; - fixed_t pmom = FixedHypot(sonic->momx, sonic->momy); - fixed_t bmom = FixedHypot(tails->momx, tails->momy); + fixed_t pmom = P_AproxDistance(sonic->momx, sonic->momy); + fixed_t bmom = P_AproxDistance(tails->momx, tails->momy); fixed_t followmax = 128 * 8 * scale; // Max follow distance before AI begins to enter "panic" state fixed_t followthres = 92 * scale; // Distance that AI will try to reach fixed_t followmin = 32 * scale; @@ -81,7 +81,7 @@ static void B_BuildTailsTiccmd(mobj_t *sonic, mobj_t *tails, ticcmd_t *cmd) if (tails->player->powers[pw_carry] == CR_MACESPIN || tails->player->powers[pw_carry] == CR_GENERIC) { boolean isrelevant = (sonic->player->powers[pw_carry] == CR_MACESPIN || sonic->player->powers[pw_carry] == CR_GENERIC); - dist = FixedHypot(tails->x-sonic->x, tails->y-sonic->y); + dist = P_AproxDistance(tails->x-sonic->x, tails->y-sonic->y); if (sonic->player->cmd.buttons & BT_JUMP && (sonic->player->pflags & PF_JUMPED) && isrelevant) cmd->buttons |= BT_JUMP; if (isrelevant) @@ -496,7 +496,7 @@ boolean B_CheckRespawn(player_t *player) } // If you can't see Sonic, I guess we should? - if (!P_CheckSight(sonic, tails) && FixedHypot(FixedHypot(tails->x-sonic->x, tails->y-sonic->y), tails->z-sonic->z) > FixedMul(1024*FRACUNIT, tails->scale)) + if (!P_CheckSight(sonic, tails) && P_AproxDistance(P_AproxDistance(tails->x-sonic->x, tails->y-sonic->y), tails->z-sonic->z) > FixedMul(1024*FRACUNIT, tails->scale)) return true; return false; } diff --git a/src/g_game.c b/src/g_game.c index 10bec888f..2b304b4fd 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1423,7 +1423,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) newtarget = P_SpawnMobj(ticcmd_ztargetfocus[forplayer]->x, ticcmd_ztargetfocus[forplayer]->y, ticcmd_ztargetfocus[forplayer]->z, MT_LOCKON); // positioning, flip handled in P_SceneryThinker P_SetTarget(&newtarget->target, ticcmd_ztargetfocus[forplayer]); - if (FixedHypot( + if (P_AproxDistance( player->mo->x - ticcmd_ztargetfocus[forplayer]->x, player->mo->y - ticcmd_ztargetfocus[forplayer]->y ) > 50*player->mo->scale) diff --git a/src/p_ceilng.c b/src/p_ceilng.c index 2168d1d78..f12499d5c 100644 --- a/src/p_ceilng.c +++ b/src/p_ceilng.c @@ -468,7 +468,7 @@ INT32 EV_DoCeiling(line_t *line, ceiling_e type) // Linedef executor excellence case moveCeilingByFrontSector: - ceiling->speed = FixedHypot(line->dx, line->dy); + ceiling->speed = P_AproxDistance(line->dx, line->dy); ceiling->speed = FixedDiv(ceiling->speed,8*FRACUNIT); if (line->frontsector->ceilingheight >= sec->ceilingheight) // Move up { @@ -547,7 +547,7 @@ INT32 EV_DoCeiling(line_t *line, ceiling_e type) */ case bounceCeiling: - ceiling->speed = FixedHypot(line->dx, line->dy); // same speed as elevateContinuous + ceiling->speed = P_AproxDistance(line->dx, line->dy); // same speed as elevateContinuous ceiling->speed = FixedDiv(ceiling->speed,4*FRACUNIT); ceiling->origspeed = ceiling->speed; if (line->frontsector->ceilingheight >= sec->ceilingheight) // Move up diff --git a/src/p_enemy.c b/src/p_enemy.c index 0e20aac10..3e7f52a3f 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -334,7 +334,7 @@ boolean P_CheckMeleeRange(mobj_t *actor) return false; pl = actor->target; - dist = FixedHypot(pl->x-actor->x, pl->y-actor->y); + dist = P_AproxDistance(pl->x-actor->x, pl->y-actor->y); if (dist >= FixedMul(MELEERANGE - 20*FRACUNIT, actor->scale) + pl->radius) return false; @@ -360,7 +360,7 @@ boolean P_JetbCheckMeleeRange(mobj_t *actor) return false; pl = actor->target; - dist = FixedHypot(pl->x-actor->x, pl->y-actor->y); + dist = P_AproxDistance(pl->x-actor->x, pl->y-actor->y); if (dist >= (actor->radius + pl->radius)*2) return false; @@ -389,7 +389,7 @@ boolean P_FaceStabCheckMeleeRange(mobj_t *actor) return false; pl = actor->target; - dist = FixedHypot(pl->x-actor->x, pl->y-actor->y); + dist = P_AproxDistance(pl->x-actor->x, pl->y-actor->y); if (dist >= (actor->radius + pl->radius)*4) return false; @@ -413,7 +413,7 @@ boolean P_SkimCheckMeleeRange(mobj_t *actor) return false; pl = actor->target; - dist = FixedHypot(pl->x-actor->x, pl->y-actor->y); + dist = P_AproxDistance(pl->x-actor->x, pl->y-actor->y); if (dist >= FixedMul(MELEERANGE - 20*FRACUNIT, actor->scale) + pl->radius) return false; @@ -449,7 +449,7 @@ boolean P_CheckMissileRange(mobj_t *actor) return false; // OPTIMIZE: get this from a global checksight - dist = FixedHypot(actor->x-actor->target->x, actor->y-actor->target->y) - FixedMul(64*FRACUNIT, actor->scale); + dist = P_AproxDistance(actor->x-actor->target->x, actor->y-actor->target->y) - FixedMul(64*FRACUNIT, actor->scale); if (!actor->info->meleestate) dist -= FixedMul(128*FRACUNIT, actor->scale); // no melee attack, so fire more @@ -750,7 +750,7 @@ boolean P_LookForPlayers(mobj_t *actor, boolean allaround, boolean tracer, fixed continue; // Ignore uncontrolled bodies if (dist > 0 - && FixedHypot(FixedHypot(player->mo->x - actor->x, player->mo->y - actor->y), player->mo->z - actor->z) > dist) + && P_AproxDistance(P_AproxDistance(player->mo->x - actor->x, player->mo->y - actor->y), player->mo->z - actor->z) > dist) continue; // Too far away if (!allaround) @@ -758,7 +758,7 @@ boolean P_LookForPlayers(mobj_t *actor, boolean allaround, boolean tracer, fixed an = R_PointToAngle2(actor->x, actor->y, player->mo->x, player->mo->y) - actor->angle; if (an > ANGLE_90 && an < ANGLE_270) { - dist = FixedHypot(player->mo->x - actor->x, player->mo->y - actor->y); + dist = P_AproxDistance(player->mo->x - actor->x, player->mo->y - actor->y); // if real close, react anyway if (dist > FixedMul(MELEERANGE, actor->scale)) continue; // behind back @@ -821,7 +821,7 @@ static boolean P_LookForShield(mobj_t *actor) continue; if ((player->powers[pw_shield] & SH_PROTECTELECTRIC) - && (FixedHypot(FixedHypot(actor->x-player->mo->x, actor->y-player->mo->y), actor->z-player->mo->z) < FixedMul(RING_DIST, player->mo->scale))) + && (P_AproxDistance(P_AproxDistance(actor->x-player->mo->x, actor->y-player->mo->y), actor->z-player->mo->z) < FixedMul(RING_DIST, player->mo->scale))) { P_SetTarget(&actor->tracer, player->mo); @@ -1548,8 +1548,8 @@ void A_PointyThink(mobj_t *actor) } else { - if (FixedHypot(players[i].mo->x - actor->x, players[i].mo->y - actor->y) < - FixedHypot(player->mo->x - actor->x, player->mo->y - actor->y)) + if (P_AproxDistance(players[i].mo->x - actor->x, players[i].mo->y - actor->y) < + P_AproxDistance(player->mo->x - actor->x, player->mo->y - actor->y)) player = &players[i]; } } @@ -1561,7 +1561,7 @@ void A_PointyThink(mobj_t *actor) P_SetTarget(&actor->target, player->mo); A_FaceTarget(actor); - if (FixedHypot(player->mo->x - actor->x, player->mo->y - actor->y) < FixedHypot(player->mo->x + player->mo->momx - actor->x, player->mo->y + player->mo->momy - actor->y)) + if (P_AproxDistance(player->mo->x - actor->x, player->mo->y - actor->y) < P_AproxDistance(player->mo->x + player->mo->momx - actor->x, player->mo->y + player->mo->momy - actor->y)) sign = -1; // Player is moving away else sign = 1; // Player is moving closer @@ -1638,7 +1638,7 @@ static void P_ParabolicMove(mobj_t *actor, fixed_t x, fixed_t y, fixed_t z, fixe y -= actor->y; z -= actor->z; - dh = FixedHypot(x, y); + dh = P_AproxDistance(x, y); actor->momx = FixedMul(FixedDiv(x, dh), speed); actor->momy = FixedMul(FixedDiv(y, dh), speed); @@ -1706,7 +1706,7 @@ void A_HoodThink(mobj_t *actor) } dx = (actor->target->x - actor->x), dy = (actor->target->y - actor->y), dz = (actor->target->z - actor->z); - dm = FixedHypot(dx, dy); + dm = P_AproxDistance(dx, dy); // Target dangerously close to robohood, retreat then. if ((dm < 256<target || !crab->info->missilestate || (statenum_t)(crab->state-states) == crab->info->missilestate) return; - if (((ang + ANG1) < ANG2) || FixedHypot(crab->x - crab->target->x, crab->y - crab->target->y) < 333*crab->scale) + if (((ang + ANG1) < ANG2) || P_AproxDistance(crab->x - crab->target->x, crab->y - crab->target->y) < 333*crab->scale) P_SetMobjState(crab, crab->info->missilestate); } @@ -2703,7 +2703,7 @@ void A_LobShot(mobj_t *actor) shot->angle = an = actor->angle; an >>= ANGLETOFINESHIFT; - dist = FixedHypot(actor->target->x - shot->x, actor->target->y - shot->y); + dist = P_AproxDistance(actor->target->x - shot->x, actor->target->y - shot->y); horizontal = dist / airtime; vertical = FixedMul((gravity*airtime)/2, shot->scale); @@ -2721,7 +2721,7 @@ void A_LobShot(mobj_t *actor) diff = actor->z - actor->target->z; { - launchhyp = FixedHypot(horizontal, vertical); + launchhyp = P_AproxDistance(horizontal, vertical); orig = FixedMul(FixedDiv(vertical, horizontal), diff); @@ -3325,7 +3325,7 @@ void A_SkullAttack(mobj_t *actor) S_StartSound(actor, actor->info->activesound); A_FaceTarget(actor); - dist = FixedHypot(dest->x - actor->x, dest->y - actor->y); + dist = P_AproxDistance(dest->x - actor->x, dest->y - actor->y); if (locvar1 == 1) actor->angle += ANGLE_180; @@ -3443,7 +3443,7 @@ void A_BossZoom(mobj_t *actor) an = actor->angle >> ANGLETOFINESHIFT; actor->momx = FixedMul(FixedMul(actor->info->speed*5*FRACUNIT, actor->scale), FINECOSINE(an)); actor->momy = FixedMul(FixedMul(actor->info->speed*5*FRACUNIT, actor->scale), FINESINE(an)); - dist = FixedHypot(dest->x - actor->x, dest->y - actor->y); + dist = P_AproxDistance(dest->x - actor->x, dest->y - actor->y); dist = dist / FixedMul(actor->info->speed*5*FRACUNIT, actor->scale); if (dist < 1) @@ -3599,7 +3599,7 @@ void A_1upThinker(mobj_t *actor) if ((netgame || multiplayer) && players[i].playerstate != PST_LIVE) continue; - temp = FixedHypot(players[i].mo->x-actor->x, players[i].mo->y-actor->y); + temp = P_AproxDistance(players[i].mo->x-actor->x, players[i].mo->y-actor->y); if (temp < dist) { @@ -4144,8 +4144,8 @@ bossjustdie: // If this one's further then the last one, don't go for it. if (mo->target && - FixedHypot(FixedHypot(mo->x - mo2->x, mo->y - mo2->y), mo->z - mo2->z) > - FixedHypot(FixedHypot(mo->x - mo->target->x, mo->y - mo->target->y), mo->z - mo->target->z)) + P_AproxDistance(P_AproxDistance(mo->x - mo2->x, mo->y - mo2->y), mo->z - mo2->z) > + P_AproxDistance(P_AproxDistance(mo->x - mo->target->x, mo->y - mo->target->y), mo->z - mo->target->z)) continue; // Otherwise... Do! @@ -4536,7 +4536,7 @@ void A_BubbleSpawn(mobj_t *actor) // Don't spawn bubbles unless a player is relatively close by (var1). for (i = 0; i < MAXPLAYERS; ++i) if (playeringame[i] && players[i].mo - && FixedHypot(actor->x - players[i].mo->x, actor->y - players[i].mo->y) < (locvar1<x - players[i].mo->x, actor->y - players[i].mo->y) < (locvar1<x - players[i].mo->x, actor->y - players[i].mo->y) < (locvar1<x - players[i].mo->x, actor->y - players[i].mo->y) < (locvar1<x-target->x, actor->y-target->y)>>FRACBITS; + dist = P_AproxDistance(actor->x-target->x, actor->y-target->y)>>FRACBITS; if (dist > FixedMul((locvar2 & 65535), actor->scale)) return; @@ -4800,7 +4800,7 @@ void A_FishJump(mobj_t *actor) // Don't spawn trail unless a player is nearby. for (i = 0; i < MAXPLAYERS; ++i) if (playeringame[i] && players[i].mo - && FixedHypot(actor->x - players[i].mo->x, actor->y - players[i].mo->y) < (actor->info->speed)) + && P_AproxDistance(actor->x - players[i].mo->x, actor->y - players[i].mo->y) < (actor->info->speed)) break; // Stop looking. if (i < MAXPLAYERS) { @@ -4905,7 +4905,7 @@ void A_ThrownRing(mobj_t *actor) // magnetic player. If he gets too far away, make // sure to stop the attraction! if ((!actor->tracer->health) || (actor->tracer->player && (actor->tracer->player->powers[pw_shield] & SH_PROTECTELECTRIC) - && FixedHypot(FixedHypot(actor->tracer->x-actor->x, + && P_AproxDistance(P_AproxDistance(actor->tracer->x-actor->x, actor->tracer->y-actor->y), actor->tracer->z-actor->z) > FixedMul(RING_DIST/4, actor->tracer->scale))) { P_SetTarget(&actor->tracer, NULL); @@ -4964,7 +4964,7 @@ void A_ThrownRing(mobj_t *actor) continue; } - dist = FixedHypot(FixedHypot(player->mo->x-actor->x, + dist = P_AproxDistance(P_AproxDistance(player->mo->x-actor->x, player->mo->y-actor->y), player->mo->z-actor->z); // check distance @@ -5345,7 +5345,7 @@ void A_JetChase(mobj_t *actor) return; // got a new target // If the player is over 3072 fracunits away, then look for another player - if (FixedHypot(FixedHypot(actor->target->x - actor->x, actor->target->y - actor->y), + if (P_AproxDistance(P_AproxDistance(actor->target->x - actor->x, actor->target->y - actor->y), actor->target->z - actor->z) > FixedMul(3072*FRACUNIT, actor->scale) && P_LookForPlayers(actor, true, false, FixedMul(3072*FRACUNIT, actor->scale))) { return; // got a new target @@ -5460,7 +5460,7 @@ void A_JetgShoot(mobj_t *actor) if (actor->reactiontime) return; - dist = FixedHypot(actor->target->x - actor->x, actor->target->y - actor->y); + dist = P_AproxDistance(actor->target->x - actor->x, actor->target->y - actor->y); if (dist > FixedMul(actor->info->painchance*FRACUNIT, actor->scale)) return; @@ -5497,7 +5497,7 @@ void A_ShootBullet(mobj_t *actor) if (!actor->target) return; - dist = FixedHypot(FixedHypot(actor->target->x - actor->x, actor->target->y - actor->y), actor->target->z - actor->z); + dist = P_AproxDistance(P_AproxDistance(actor->target->x - actor->x, actor->target->y - actor->y), actor->target->z - actor->z); if (dist > FixedMul(actor->info->painchance*FRACUNIT, actor->scale)) return; @@ -5522,7 +5522,7 @@ static boolean PIT_MinusCarry(mobj_t *thing) if (!(thing->flags & (MF_PUSHABLE|MF_ENEMY))) return true; - if (FixedHypot(minus->x - thing->x, minus->y - thing->y) >= minus->radius*3) + if (P_AproxDistance(minus->x - thing->x, minus->y - thing->y) >= minus->radius*3) return true; if (abs(thing->z - minus->z) > minus->height) @@ -5566,7 +5566,7 @@ void A_MinusDigging(mobj_t *actor) P_TryMove(par, x, y, false); // If close enough, prepare to attack - if (FixedHypot(actor->x - actor->target->x, actor->y - actor->target->y) < actor->radius*2) + if (P_AproxDistance(actor->x - actor->target->x, actor->y - actor->target->y) < actor->radius*2) { P_SetMobjState(actor, actor->info->meleestate); P_TryMove(actor, actor->target->x, actor->target->y, false); @@ -5858,7 +5858,7 @@ void A_DetonChase(mobj_t *actor) } }*/ // movedir is up/down angle: how much it has to go up as it goes over to the player - xydist = FixedHypot(actor->tracer->x - actor->x, actor->tracer->y - actor->y); + xydist = P_AproxDistance(actor->tracer->x - actor->x, actor->tracer->y - actor->y); exact = R_PointToAngle2(0, 0, xydist, actor->tracer->z - actor->z); actor->movedir = exact; /*if (exact != actor->movedir) @@ -5880,7 +5880,7 @@ void A_DetonChase(mobj_t *actor) // check for melee attack if (actor->tracer) { - if (FixedHypot(actor->tracer->x-actor->x, actor->tracer->y-actor->y) < actor->radius+actor->tracer->radius) + if (P_AproxDistance(actor->tracer->x-actor->x, actor->tracer->y-actor->y) < actor->radius+actor->tracer->radius) { if (!((actor->tracer->z > actor->z + actor->height) || (actor->z > actor->tracer->z + actor->tracer->height))) { @@ -5891,7 +5891,7 @@ void A_DetonChase(mobj_t *actor) } // chase towards player - if ((dist = FixedHypot(xydist, actor->tracer->z-actor->z)) + if ((dist = P_AproxDistance(xydist, actor->tracer->z-actor->z)) > FixedMul((actor->info->painchance << FRACBITS), actor->scale)) { P_SetTarget(&actor->tracer, NULL); // Too far away @@ -5938,7 +5938,7 @@ void A_DetonChase(mobj_t *actor) actor->momy = FixedMul(xyspeed, FINESINE(exact)); // Variable re-use - xyspeed = (FixedHypot(actor->tracer->x - actor->x, FixedHypot(actor->tracer->y - actor->y, actor->tracer->z - actor->z))>>(FRACBITS+6)); + xyspeed = (P_AproxDistance(actor->tracer->x - actor->x, P_AproxDistance(actor->tracer->y - actor->y, actor->tracer->z - actor->z))>>(FRACBITS+6)); if (xyspeed < 1) xyspeed = 1; @@ -6086,7 +6086,7 @@ void A_UnidusBall(mobj_t *actor) if (actor->movecount) { - if (FixedHypot(actor->momx, actor->momy) < FixedMul(actor->info->damage/2, actor->scale)) + if (P_AproxDistance(actor->momx, actor->momy) < FixedMul(actor->info->damage/2, actor->scale)) P_ExplodeMissile(actor); return; } @@ -6118,7 +6118,7 @@ void A_UnidusBall(mobj_t *actor) if (locvar1 == 1 && canthrow) { - if (FixedHypot(actor->target->target->x - actor->target->x, actor->target->target->y - actor->target->y) > FixedMul(MISSILERANGE>>1, actor->scale) + if (P_AproxDistance(actor->target->target->x - actor->target->x, actor->target->target->y - actor->target->y) > FixedMul(MISSILERANGE>>1, actor->scale) || !P_CheckSight(actor, actor->target->target)) return; @@ -6193,7 +6193,7 @@ void A_RockSpawn(mobj_t *actor) return; } - dist = FixedHypot(line->dx, line->dy)/16; + dist = P_AproxDistance(line->dx, line->dy)/16; if (dist < 1) dist = 1; @@ -6359,7 +6359,7 @@ void A_CrawlaCommanderThink(mobj_t *actor) return; } - dist = FixedHypot(actor->x - actor->target->x, actor->y - actor->target->y); + dist = P_AproxDistance(actor->x - actor->target->x, actor->y - actor->target->y); if (actor->target->player && (!hovermode || actor->reactiontime <= 2*TICRATE)) { @@ -6396,7 +6396,7 @@ void A_CrawlaCommanderThink(mobj_t *actor) { fixed_t mom; P_Thrust(actor, actor->angle, 2*actor->scale); - mom = FixedHypot(actor->momx, actor->momy); + mom = P_AproxDistance(actor->momx, actor->momy); if (mom > 20*actor->scale) { mom += 20*actor->scale; @@ -6484,7 +6484,7 @@ void A_RingExplode(mobj_t *actor) if (mo2 == actor) // Don't explode yourself! Endless loop! continue; - if (FixedHypot(FixedHypot(mo2->x - actor->x, mo2->y - actor->y), mo2->z - actor->z) > FixedMul(actor->info->painchance, actor->scale)) + if (P_AproxDistance(P_AproxDistance(mo2->x - actor->x, mo2->y - actor->y), mo2->z - actor->z) > FixedMul(actor->info->painchance, actor->scale)) continue; if (mo2->flags & MF_SHOOTABLE) @@ -7083,7 +7083,7 @@ nomissile: } // chase towards player - if (FixedHypot(actor->target->x-actor->x, actor->target->y-actor->y) > actor->radius+actor->target->radius) + if (P_AproxDistance(actor->target->x-actor->x, actor->target->y-actor->y) > actor->radius+actor->target->radius) { if (--actor->movecount < 0 || !P_Move(actor, actor->info->speed)) P_NewChaseDir(actor); @@ -7322,7 +7322,7 @@ void A_Boss7Chase(mobj_t *actor) // Self-adjust if stuck on the edge if (actor->tracer) { - if (FixedHypot(actor->x - actor->tracer->x, actor->y - actor->tracer->y) > 128*FRACUNIT - actor->radius) + if (P_AproxDistance(actor->x - actor->tracer->x, actor->y - actor->tracer->y) > 128*FRACUNIT - actor->radius) P_InstaThrust(actor, R_PointToAngle2(actor->x, actor->y, actor->tracer->x, actor->tracer->y), FRACUNIT); } @@ -7358,7 +7358,7 @@ void A_Boss7Chase(mobj_t *actor) if (players[i].mo->health <= 0) continue; - if (FixedHypot(players[i].mo->x - actor->x, players[i].mo->y - actor->y) > actor->radius) + if (P_AproxDistance(players[i].mo->x - actor->x, players[i].mo->y - actor->y) > actor->radius) continue; if (players[i].mo->z > actor->z + actor->height - 2*FRACUNIT @@ -7481,7 +7481,7 @@ void A_Boss2PogoSFX(mobj_t *actor) } // Boing! - if (FixedHypot(actor->x-actor->target->x, actor->y-actor->target->y) < FixedMul(256*FRACUNIT, actor->scale)) + if (P_AproxDistance(actor->x-actor->target->x, actor->y-actor->target->y) < FixedMul(256*FRACUNIT, actor->scale)) { actor->angle = R_PointToAngle2(actor->x, actor->y, actor->target->x, actor->target->y); P_InstaThrust(actor, actor->angle, FixedMul(actor->info->speed, actor->scale)); @@ -7514,7 +7514,7 @@ void A_Boss2PogoTarget(mobj_t *actor) return; if (!actor->target || !(actor->target->flags & MF_SHOOTABLE) || (actor->target->player && actor->target->player->powers[pw_flashing]) - || FixedHypot(actor->x-actor->target->x, actor->y-actor->target->y) >= FixedMul(512*FRACUNIT, actor->scale)) + || P_AproxDistance(actor->x-actor->target->x, actor->y-actor->target->y) >= FixedMul(512*FRACUNIT, actor->scale)) { // look for a new target if (P_LookForPlayers(actor, true, false, 512*FRACUNIT)) @@ -7535,7 +7535,7 @@ void A_Boss2PogoTarget(mobj_t *actor) P_InstaThrust(actor, actor->angle+ANGLE_180, FixedMul(FixedMul(actor->info->speed,(locvar2)), actor->scale)); // Move at wandering speed } // Try to land on top of the player. - else if (FixedHypot(actor->x-actor->target->x, actor->y-actor->target->y) < FixedMul(512*FRACUNIT, actor->scale)) + else if (P_AproxDistance(actor->x-actor->target->x, actor->y-actor->target->y) < FixedMul(512*FRACUNIT, actor->scale)) { fixed_t airtime, gravityadd, zoffs, height; @@ -7569,7 +7569,7 @@ void A_Boss2PogoTarget(mobj_t *actor) airtime = FixedDiv((-actor->momz - FixedSqrt(FixedMul(actor->momz,actor->momz)+zoffs)), gravityadd)<<1; // to try and land on their head rather than on their feet actor->angle = R_PointToAngle2(actor->x, actor->y, actor->target->x, actor->target->y); - P_InstaThrust(actor, actor->angle, FixedDiv(FixedHypot(actor->x - actor->target->x, actor->y - actor->target->y), airtime)); + P_InstaThrust(actor, actor->angle, FixedDiv(P_AproxDistance(actor->x - actor->target->x, actor->y - actor->target->y), airtime)); } // Wander semi-randomly towards the player to get closer. else @@ -7640,7 +7640,7 @@ void A_TurretFire(mobj_t *actor) while (P_SupermanLook4Players(actor) && count < MAXPLAYERS) { - if (FixedHypot(actor->x - actor->target->x, actor->y - actor->target->y) < dist) + if (P_AproxDistance(actor->x - actor->target->x, actor->y - actor->target->y) < dist) { actor->flags2 |= MF2_FIRING; actor->extravalue1 = locvar1; @@ -7678,7 +7678,7 @@ void A_SuperTurretFire(mobj_t *actor) while (P_SupermanLook4Players(actor) && count < MAXPLAYERS) { - if (FixedHypot(actor->x - actor->target->x, actor->y - actor->target->y) < dist) + if (P_AproxDistance(actor->x - actor->target->x, actor->y - actor->target->y) < dist) { actor->flags2 |= MF2_FIRING; actor->flags2 |= MF2_SUPERFIRE; @@ -7799,7 +7799,7 @@ void A_BuzzFly(mobj_t *actor) } // If the player is over 3072 fracunits away, then look for another player - if (FixedHypot(FixedHypot(actor->target->x - actor->x, actor->target->y - actor->y), + if (P_AproxDistance(P_AproxDistance(actor->target->x - actor->x, actor->target->y - actor->y), actor->target->z - actor->z) > FixedMul(3072*FRACUNIT, actor->scale)) { if (multiplayer || netgame) @@ -7818,7 +7818,7 @@ void A_BuzzFly(mobj_t *actor) else realspeed = FixedMul(actor->info->speed, actor->scale); - dist = FixedHypot(FixedHypot(actor->target->x - actor->x, + dist = P_AproxDistance(P_AproxDistance(actor->target->x - actor->x, actor->target->y - actor->y), actor->target->z - actor->z); if (dist < 1) @@ -8176,7 +8176,7 @@ void A_Boss3Path(mobj_t *actor) if (actor->target->x == actor->x && actor->target->y == actor->y) { - dist = FixedHypot(FixedHypot(actor->target->x - actor->x, actor->target->y - actor->y), actor->target->z + actor->movefactor - actor->z); + dist = P_AproxDistance(P_AproxDistance(actor->target->x - actor->x, actor->target->y - actor->y), actor->target->z + actor->movefactor - actor->z); if (dist < 1) dist = 1; @@ -9586,7 +9586,7 @@ void A_SetObjectTypeState(mobj_t *actor) if (mo2->type == (mobjtype_t)loc2lw) { - dist = FixedHypot(mo2->x - actor->x, mo2->y - actor->y); + dist = P_AproxDistance(mo2->x - actor->x, mo2->y - actor->y); if (mo2->health > 0) { @@ -10092,9 +10092,9 @@ void A_CheckRange(mobj_t *actor) return; if (!(locvar1 >> 16)) //target - dist = FixedHypot(actor->target->x - actor->x, actor->target->y - actor->y); + dist = P_AproxDistance(actor->target->x - actor->x, actor->target->y - actor->y); else //tracer - dist = FixedHypot(actor->tracer->x - actor->x, actor->tracer->y - actor->y); + dist = P_AproxDistance(actor->tracer->x - actor->x, actor->tracer->y - actor->y); if (dist <= FixedMul((locvar1 & 65535)*FRACUNIT, actor->scale)) P_SetMobjState(actor, locvar2); @@ -10156,16 +10156,16 @@ void A_CheckTrueRange(mobj_t *actor) if (!(locvar1 >> 16)) // target { height = actor->target->z - actor->z; - dist = FixedHypot(actor->target->x - actor->x, actor->target->y - actor->y); + dist = P_AproxDistance(actor->target->x - actor->x, actor->target->y - actor->y); } else // tracer { height = actor->tracer->z - actor->z; - dist = FixedHypot(actor->tracer->x - actor->x, actor->tracer->y - actor->y); + dist = P_AproxDistance(actor->tracer->x - actor->x, actor->tracer->y - actor->y); } - l = FixedHypot(dist, height); + l = P_AproxDistance(dist, height); if (l <= FixedMul((locvar1 & 65535)*FRACUNIT, actor->scale)) P_SetMobjState(actor, locvar2); @@ -10210,7 +10210,7 @@ void A_CheckThingCount(mobj_t *actor) if (mo2->type == (mobjtype_t)loc1up) { - dist = FixedHypot(mo2->x - actor->x, mo2->y - actor->y); + dist = P_AproxDistance(mo2->x - actor->x, mo2->y - actor->y); if (loc2up == 0) count++; @@ -10819,7 +10819,7 @@ void A_HomingChase(mobj_t *actor) actor->angle = R_PointToAngle2(actor->x, actor->y, dest->x, dest->y); - dist = FixedHypot(FixedHypot(dest->x - actor->x, dest->y - actor->y), dest->z - actor->z); + dist = P_AproxDistance(P_AproxDistance(dest->x - actor->x, dest->y - actor->y), dest->z - actor->z); if (dist < 1) dist = 1; @@ -11405,14 +11405,14 @@ void A_BrakLobShot(mobj_t *actor) g = gravity; // Look up distance between actor and its target - x = FixedHypot(actor->target->x - actor->x, actor->target->y - actor->y); + x = P_AproxDistance(actor->target->x - actor->x, actor->target->y - actor->y); if (!aimDirect) { // Distance should actually be a third of the way over x = FixedDiv(x, 3<x + P_ReturnThrustX(actor, actor->angle, x); newTargetY = actor->y + P_ReturnThrustY(actor, actor->angle, x); - x = FixedHypot(newTargetX - actor->x, newTargetY - actor->y); + x = P_AproxDistance(newTargetX - actor->x, newTargetY - actor->y); // Look up height difference between actor and the ground 1/3 of the way to its target y = P_FloorzAtPos(newTargetX, newTargetY, actor->target->z, actor->target->height) - (actor->z + FixedMul(locvar2*FRACUNIT, actor->scale)); } @@ -11764,7 +11764,7 @@ void A_FlickyCenter(mobj_t *actor) P_LookForPlayers(actor, true, false, actor->extravalue1); - if (actor->target && FixedHypot(actor->target->x - originx, actor->target->y - originy) < actor->extravalue1) + if (actor->target && P_AproxDistance(actor->target->x - originx, actor->target->y - originy) < actor->extravalue1) { actor->extravalue2 = 1; P_TeleportMove(actor, actor->target->x, actor->target->y, actor->target->z); @@ -11820,7 +11820,7 @@ void A_FlickyAim(mobj_t *actor) if ((actor->momx == actor->momy && actor->momy == 0) || (actor->target && P_IsFlickyCenter(actor->target->type) && actor->target->extravalue1 && (actor->target->flags & MF_SLIDEME) - && FixedHypot(actor->x - actor->target->x, actor->y - actor->target->y) >= actor->target->extravalue1)) + && P_AproxDistance(actor->x - actor->target->x, actor->y - actor->target->y) >= actor->target->extravalue1)) flickyhitwall = true; P_InternalFlickyBubble(actor); @@ -11842,12 +11842,12 @@ void A_FlickyAim(mobj_t *actor) actor->movedir *= -1; posvar = ((R_PointToAngle2(actor->target->x, actor->target->y, actor->x, actor->y) + actor->movedir*locvar1) >> ANGLETOFINESHIFT) & FINEMASK; - chasevar = FixedSqrt(max(FRACUNIT, FixedHypot(actor->target->x - actor->x, actor->target->y - actor->y) - locvar2)) + locvar2; + chasevar = FixedSqrt(max(FRACUNIT, P_AproxDistance(actor->target->x - actor->x, actor->target->y - actor->y) - locvar2)) + locvar2; chasex = actor->target->x + FixedMul(FINECOSINE(posvar), chasevar); chasey = actor->target->y + FixedMul(FINESINE(posvar), chasevar); - if (FixedHypot(chasex - actor->x, chasey - actor->y)) + if (P_AproxDistance(chasex - actor->x, chasey - actor->y)) actor->angle = R_PointToAngle2(actor->x, actor->y, chasex, chasey); } else if (flickyhitwall) @@ -11889,7 +11889,7 @@ void P_InternalFlickyFly(mobj_t *actor, fixed_t flyspeed, fixed_t targetdist, fi targetdist = 16*FRACUNIT; //Default! if (actor->target && abs(chasez - actor->z) > targetdist) - targetdist = FixedHypot(actor->target->x - actor->x, actor->target->y - actor->y); + targetdist = P_AproxDistance(actor->target->x - actor->x, actor->target->y - actor->y); if (actor->target && P_IsFlickyCenter(actor->target->type) @@ -11967,7 +11967,7 @@ void A_FlickyCoast(mobj_t *actor) actor->momy = (11*actor->momy)/12; actor->momz = (11*actor->momz)/12; - if (FixedHypot(FixedHypot(actor->momx, actor->momy), actor->momz) < locvar1) + if (P_AproxDistance(P_AproxDistance(actor->momx, actor->momy), actor->momz) < locvar1) P_SetMobjState(actor, locvar2); return; @@ -12231,7 +12231,7 @@ void A_Boss5Jump(mobj_t *actor) g = gravity; // Look up distance between actor and its tracer - x = FixedHypot(actor->tracer->x - actor->x, actor->tracer->y - actor->y); + x = P_AproxDistance(actor->tracer->x - actor->x, actor->tracer->y - actor->y); // Look up height difference between actor and its tracer y = actor->tracer->z - actor->z; @@ -12352,7 +12352,7 @@ void A_MineExplode(mobj_t *actor) actor->z+P_RandomRange(((actor->eflags & MFE_UNDERWATER) ? -dist : 0), dist)*FRACUNIT, type); fixed_t dx = b->x - actor->x, dy = b->y - actor->y, dz = b->z - actor->z; - fixed_t dm = FixedHypot(dz, FixedHypot(dy, dx)); + fixed_t dm = P_AproxDistance(dz, P_AproxDistance(dy, dx)); b->momx = FixedDiv(dx, dm)*3; b->momy = FixedDiv(dy, dm)*3; b->momz = FixedDiv(dz, dm)*3; @@ -12384,7 +12384,7 @@ void A_MineRange(mobj_t *actor) if (!actor->target) return; - dm = FixedHypot(actor->z - actor->target->z, FixedHypot(actor->y - actor->target->y, actor->x - actor->target->x)); + dm = P_AproxDistance(actor->z - actor->target->z, P_AproxDistance(actor->y - actor->target->y, actor->x - actor->target->x)); if ((dm>>FRACBITS) < locvar1) P_SetMobjState(actor, actor->info->meleestate); } @@ -12510,7 +12510,7 @@ void A_MultiShotDist(mobj_t *actor) // Don't spawn dust unless a player is relatively close by (var1). for (i = 0; i < MAXPLAYERS; ++i) if (playeringame[i] && players[i].mo - && FixedHypot(actor->x - players[i].mo->x, actor->y - players[i].mo->y) < (1600<x - players[i].mo->x, actor->y - players[i].mo->y) < (1600<tracer && - FixedHypot(FixedHypot(actor->x - mo2->x, actor->y - mo2->y), actor->z - mo2->z) > - FixedHypot(FixedHypot(actor->x - actor->tracer->x, actor->y - actor->tracer->y), actor->z - actor->tracer->z)) + P_AproxDistance(P_AproxDistance(actor->x - mo2->x, actor->y - mo2->y), actor->z - mo2->z) > + P_AproxDistance(P_AproxDistance(actor->x - actor->tracer->x, actor->y - actor->tracer->y), actor->z - actor->tracer->z)) continue; // Otherwise... Do! @@ -13058,7 +13058,7 @@ void A_Boss5CheckOnGround(mobj_t *actor) P_SetMobjState(actor, locvar1); } - if (actor->tracer && FixedHypot(actor->tracer->x - actor->x, actor->tracer->y - actor->y) < 2*actor->radius) + if (actor->tracer && P_AproxDistance(actor->tracer->x - actor->x, actor->tracer->y - actor->y) < 2*actor->radius) { actor->momx = (4*actor->momx)/5; actor->momy = (4*actor->momy)/5; @@ -13518,7 +13518,7 @@ static boolean PIT_TNTExplode(mobj_t *nearby) dx = nearby->x - barrel->x; dy = nearby->y - barrel->y; dz = nearby->z - barrel->z + (nearby->height - barrel->height/2)/2; - dm = FixedHypot(FixedHypot(dx, dy), dz); + dm = P_AproxDistance(P_AproxDistance(dx, dy), dz); if (dm >= exploderadius || !P_CheckSight(barrel, nearby)) // out of range or not visible return true; @@ -13921,7 +13921,7 @@ void A_SnapperThinker(mobj_t *actor) // Look for nearby, valid players to chase angrily at. if ((actor->target || P_LookForPlayers(actor, true, false, 1024*FRACUNIT)) - && FixedHypot(actor->target->x - xs, actor->target->y - ys) < 2048*FRACUNIT + && P_AproxDistance(actor->target->x - xs, actor->target->y - ys) < 2048*FRACUNIT && abs(actor->target->z - actor->z) < 80*FRACUNIT && P_CheckSight(actor, actor->target)) { @@ -13936,7 +13936,7 @@ void A_SnapperThinker(mobj_t *actor) y1 = ys; } - dist = FixedHypot(x1 - x0, y1 - y0); + dist = P_AproxDistance(x1 - x0, y1 - y0); // The snapper either chases what it considers to be a nearby player, or instead decides to go back to its spawnpoint. if (chasing || dist > 32*FRACUNIT) @@ -14121,7 +14121,7 @@ void A_LavafallRocks(mobj_t *actor) // Don't spawn rocks unless a player is relatively close by. for (i = 0; i < MAXPLAYERS; ++i) if (playeringame[i] && players[i].mo - && FixedHypot(actor->x - players[i].mo->x, actor->y - players[i].mo->y) < (actor->info->speed >> 1)) + && P_AproxDistance(actor->x - players[i].mo->x, actor->y - players[i].mo->y) < (actor->info->speed >> 1)) break; // Stop looking. if (i < MAXPLAYERS) @@ -14155,7 +14155,7 @@ void A_LavafallLava(mobj_t *actor) // Don't spawn lava unless a player is nearby. for (i = 0; i < MAXPLAYERS; ++i) if (playeringame[i] && players[i].mo - && FixedHypot(actor->x - players[i].mo->x, actor->y - players[i].mo->y) < (actor->info->speed)) + && P_AproxDistance(actor->x - players[i].mo->x, actor->y - players[i].mo->y) < (actor->info->speed)) break; // Stop looking. if (i >= MAXPLAYERS) @@ -14285,7 +14285,7 @@ void A_RolloutSpawn(mobj_t *actor) if (!(actor->target) || P_MobjWasRemoved(actor->target) - || FixedHypot(actor->x - actor->target->x, actor->y - actor->target->y) > locvar1) + || P_AproxDistance(actor->x - actor->target->x, actor->y - actor->target->y) > locvar1) { actor->target = P_SpawnMobj(actor->x, actor->y, actor->z, locvar2); actor->target->flags2 |= (actor->flags2 & (MF2_AMBUSH | MF2_OBJECTFLIP)) | MF2_SLIDEPUSH; @@ -14313,7 +14313,7 @@ void A_RolloutRock(mobj_t *actor) UINT8 maxframes = actor->info->reactiontime; // number of frames the mobj cycles through fixed_t pi = (22*FRACUNIT/7); fixed_t circumference = FixedMul(2 * pi, actor->radius); // used to calculate when to change frame - fixed_t speed = FixedHypot(actor->momx, actor->momy), topspeed = FixedMul(actor->info->speed, actor->scale); + fixed_t speed = P_AproxDistance(actor->momx, actor->momy), topspeed = FixedMul(actor->info->speed, actor->scale); boolean inwater = actor->eflags & (MFE_TOUCHWATER|MFE_UNDERWATER); if (LUA_CallAction(A_ROLLOUTROCK, actor)) @@ -14355,7 +14355,7 @@ void A_RolloutRock(mobj_t *actor) actor->momy = FixedMul(actor->momy, locvar1); } - speed = FixedHypot(actor->momx, actor->momy); // recalculate speed for visual rolling + speed = P_AproxDistance(actor->momx, actor->momy); // recalculate speed for visual rolling if (speed < actor->scale >> 1) // stop moving if speed is insignificant { @@ -14477,7 +14477,7 @@ void A_DragonSegment(mobj_t *actor) return; } - dist = FixedHypot(FixedHypot(actor->x - target->x, actor->y - target->y), actor->z - target->z); + dist = P_AproxDistance(P_AproxDistance(actor->x - target->x, actor->y - target->y), actor->z - target->z); radius = actor->radius + target->radius; hangle = R_PointToAngle2(target->x, target->y, actor->x, actor->y); zangle = R_PointToAngle2(0, target->z, dist, actor->z); diff --git a/src/p_floor.c b/src/p_floor.c index de8f5d4e8..7c26065b5 100644 --- a/src/p_floor.c +++ b/src/p_floor.c @@ -1164,7 +1164,7 @@ void T_ThwompSector(thwomp_t *thwomp) if (players[i].mo->z > thwomp->sector->ceilingheight) continue; - if (FixedHypot(thwompx - players[i].mo->x, thwompy - players[i].mo->y) > 96*FRACUNIT) + if (P_AproxDistance(thwompx - players[i].mo->x, thwompy - players[i].mo->y) > 96*FRACUNIT) continue; thwomp->direction = -1; @@ -1892,7 +1892,7 @@ void EV_DoFloor(line_t *line, floor_e floortype) // Linedef executor command, linetype 106. // Line length = speed, front sector floor = destination height. case moveFloorByFrontSector: - dofloor->speed = FixedHypot(line->dx, line->dy); + dofloor->speed = P_AproxDistance(line->dx, line->dy); dofloor->speed = FixedDiv(dofloor->speed,8*FRACUNIT); dofloor->floordestheight = line->frontsector->floorheight; @@ -1958,7 +1958,7 @@ void EV_DoFloor(line_t *line, floor_e floortype) // Linetypes 2/3. // Move floor up and down indefinitely like the old elevators. case bounceFloor: - dofloor->speed = FixedHypot(line->dx, line->dy); // same speed as elevateContinuous + dofloor->speed = P_AproxDistance(line->dx, line->dy); // same speed as elevateContinuous dofloor->speed = FixedDiv(dofloor->speed,4*FRACUNIT); dofloor->origspeed = dofloor->speed; // it gets slowed down at the top and bottom dofloor->floordestheight = line->frontsector->floorheight; @@ -2104,7 +2104,7 @@ void EV_DoElevator(line_t *line, elevator_e elevtype, boolean customspeed) case elevateContinuous: if (customspeed) { - elevator->origspeed = FixedHypot(line->dx, line->dy); + elevator->origspeed = P_AproxDistance(line->dx, line->dy); elevator->origspeed = FixedDiv(elevator->origspeed,4*FRACUNIT); elevator->speed = elevator->origspeed; } @@ -2266,7 +2266,7 @@ void EV_CrumbleChain(sector_t *sec, ffloor_t *rover) if (flags & ML_EFFECT1) { - P_InstaThrust(spawned, R_PointToAngle2(sec->soundorg.x, sec->soundorg.y, a, b), FixedDiv(FixedHypot(a - sec->soundorg.x, b - sec->soundorg.y), widthfactor)); + P_InstaThrust(spawned, R_PointToAngle2(sec->soundorg.x, sec->soundorg.y, a, b), FixedDiv(P_AproxDistance(a - sec->soundorg.x, b - sec->soundorg.y), widthfactor)); P_SetObjectMomZ(spawned, FixedDiv((c - bottomz), heightfactor), false); } diff --git a/src/p_inter.c b/src/p_inter.c index be4133af5..e9a16a3dd 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -1002,7 +1002,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) x = (x/count)<x - x, special->y - y), special->z - z); + gatherradius = P_AproxDistance(P_AproxDistance(special->x - x, special->y - y), special->z - z); P_RemoveMobj(special); if (player->powers[pw_nights_superloop]) @@ -1028,7 +1028,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) mo2 = (mobj_t *)th; - if (FixedHypot(FixedHypot(mo2->x - x, mo2->y - y), mo2->z - z) > gatherradius) + if (P_AproxDistance(P_AproxDistance(mo2->x - x, mo2->y - y), mo2->z - z) > gatherradius) continue; if (mo2->flags & MF_SHOOTABLE) @@ -1450,8 +1450,8 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) fixed_t touchx, touchy, touchspeed; angle_t angle; - if (FixedHypot(toucher->x-special->x, toucher->y-special->y) > - FixedHypot((toucher->x-toucher->momx)-special->x, (toucher->y-toucher->momy)-special->y)) + if (P_AproxDistance(toucher->x-special->x, toucher->y-special->y) > + P_AproxDistance((toucher->x-toucher->momx)-special->x, (toucher->y-toucher->momy)-special->y)) { touchx = toucher->x + toucher->momx; touchy = toucher->y + toucher->momy; @@ -1463,7 +1463,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) } angle = R_PointToAngle2(special->x, special->y, touchx, touchy); - touchspeed = FixedHypot(toucher->momx, toucher->momy); + touchspeed = P_AproxDistance(toucher->momx, toucher->momy); toucher->momx = P_ReturnThrustX(special, angle, touchspeed); toucher->momy = P_ReturnThrustY(special, angle, touchspeed); @@ -1509,7 +1509,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) case MT_EGGSHIELD: { angle_t angle = R_PointToAngle2(special->x, special->y, toucher->x, toucher->y) - special->angle; - fixed_t touchspeed = FixedHypot(toucher->momx, toucher->momy); + fixed_t touchspeed = P_AproxDistance(toucher->momx, toucher->momy); if (touchspeed < special->scale) touchspeed = special->scale; @@ -1590,7 +1590,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) { special->momx = toucher->momx; special->momy = toucher->momy; - special->momz = FixedHypot(toucher->momx, toucher->momy)/4; + special->momz = P_AproxDistance(toucher->momx, toucher->momy)/4; if (toucher->momz > 0) special->momz += toucher->momz/8; @@ -1762,7 +1762,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) toucher->momx = toucher->tracer->momx/2; toucher->momy = toucher->tracer->momy/2; - toucher->momz = toucher->tracer->momz + FixedHypot(toucher->tracer->momx, toucher->tracer->momy)/2; + toucher->momz = toucher->tracer->momz + P_AproxDistance(toucher->tracer->momx, toucher->tracer->momy)/2; P_ResetPlayer(player); player->pflags &= ~PF_APPLYAUTOBRAKE; P_SetPlayerMobjState(toucher, S_PLAY_FALL); @@ -2666,7 +2666,7 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, UINT8 damaget case MT_BUGGLE: if (inflictor && inflictor->player // did a player kill you? Spawn relative to the player so they're bound to get it - && FixedHypot(inflictor->x - target->x, inflictor->y - target->y) <= inflictor->radius + target->radius + FixedMul(8*FRACUNIT, inflictor->scale) // close enough? + && P_AproxDistance(inflictor->x - target->x, inflictor->y - target->y) <= inflictor->radius + target->radius + FixedMul(8*FRACUNIT, inflictor->scale) // close enough? && inflictor->z <= target->z + target->height + FixedMul(8*FRACUNIT, inflictor->scale) && inflictor->z + inflictor->height >= target->z - FixedMul(8*FRACUNIT, inflictor->scale)) mo = P_SpawnMobj(inflictor->x + inflictor->momx, inflictor->y + inflictor->momy, inflictor->z + (inflictor->height / 2) + inflictor->momz, MT_EXTRALARGEBUBBLE); @@ -3305,7 +3305,7 @@ static void P_SuperDamage(player_t *player, mobj_t *inflictor, mobj_t *source, I // to recover if (inflictor->flags2 & MF2_SCATTER && source) { - fixed_t dist = FixedHypot(FixedHypot(source->x-player->mo->x, source->y-player->mo->y), source->z-player->mo->z); + fixed_t dist = P_AproxDistance(P_AproxDistance(source->x-player->mo->x, source->y-player->mo->y), source->z-player->mo->z); dist = FixedMul(128*FRACUNIT, inflictor->scale) - dist/4; diff --git a/src/p_map.c b/src/p_map.c index b4fa2e9e0..a1cad524e 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -776,7 +776,7 @@ static boolean PIT_CheckThing(mobj_t *thing) if (thing->flags & MF_SOLID) S_StartSound(tmthing, thing->info->deathsound); for (iter = thing->subsector->sector->thinglist; iter; iter = iter->snext) - if (iter->type == thing->type && iter->health > 0 && iter->flags & MF_SOLID && (iter == thing || FixedHypot(FixedHypot(thing->x - iter->x, thing->y - iter->y), thing->z - iter->z) < 56*thing->scale))//FixedMul(56*FRACUNIT, thing->scale)) + if (iter->type == thing->type && iter->health > 0 && iter->flags & MF_SOLID && (iter == thing || P_AproxDistance(P_AproxDistance(thing->x - iter->x, thing->y - iter->y), thing->z - iter->z) < 56*thing->scale))//FixedMul(56*FRACUNIT, thing->scale)) P_KillMobj(iter, tmthing, tmthing, 0); } else @@ -815,7 +815,7 @@ static boolean PIT_CheckThing(mobj_t *thing) if (thing->flags & MF_SOLID) S_StartSound(tmthing, thing->info->deathsound); for (iter = thing->subsector->sector->thinglist; iter; iter = iter->snext) - if (iter->type == thing->type && iter->health > 0 && iter->flags & MF_SOLID && (iter == thing || FixedHypot(FixedHypot(thing->x - iter->x, thing->y - iter->y), thing->z - iter->z) < 56*thing->scale))//FixedMul(56*FRACUNIT, thing->scale)) + if (iter->type == thing->type && iter->health > 0 && iter->flags & MF_SOLID && (iter == thing || P_AproxDistance(P_AproxDistance(thing->x - iter->x, thing->y - iter->y), thing->z - iter->z) < 56*thing->scale))//FixedMul(56*FRACUNIT, thing->scale)) P_KillMobj(iter, tmthing, tmthing, 0); return true; } @@ -3063,7 +3063,7 @@ static void P_HitCameraSlideLine(line_t *ld, camera_t *thiscam) lineangle >>= ANGLETOFINESHIFT; deltaangle >>= ANGLETOFINESHIFT; - movelen = FixedHypot(tmxmove, tmymove); + movelen = P_AproxDistance(tmxmove, tmymove); newlen = FixedMul(movelen, FINECOSINE(deltaangle)); tmxmove = FixedMul(newlen, FINECOSINE(lineangle)); @@ -3149,7 +3149,7 @@ static void P_HitBounceLine(line_t *ld) lineangle >>= ANGLETOFINESHIFT; deltaangle >>= ANGLETOFINESHIFT; - movelen = FixedHypot(tmxmove, tmymove); + movelen = P_AproxDistance(tmxmove, tmymove); tmxmove = FixedMul(movelen, FINECOSINE(deltaangle)); tmymove = FixedMul(movelen, FINESINE(deltaangle)); @@ -4076,7 +4076,7 @@ static boolean PIT_RadiusAttack(mobj_t *thing) dy = abs(thing->y - bombspot->y); dz = abs(thing->z + (thing->height>>1) - bombspot->z); - dist = FixedHypot(FixedHypot(dx, dy), dz); + dist = P_AproxDistance(P_AproxDistance(dx, dy), dz); dist -= thing->radius; if (dist < 0) diff --git a/src/p_maputl.h b/src/p_maputl.h index 9bc00fa17..df90ab4b4 100644 --- a/src/p_maputl.h +++ b/src/p_maputl.h @@ -41,6 +41,7 @@ typedef boolean (*traverser_t)(intercept_t *in); boolean P_PathTraverse(fixed_t px1, fixed_t py1, fixed_t px2, fixed_t py2, INT32 pflags, traverser_t ptrav); +#define P_AproxDistance(dx, dy) FixedHypot(dx, dy) void P_ClosestPointOnLine(fixed_t x, fixed_t y, line_t *line, vertex_t *result); void P_ClosestPointOnLine3D(const vector3_t *p, const vector3_t *line, vector3_t *result); INT32 P_PointOnLineSide(fixed_t x, fixed_t y, line_t *line); diff --git a/src/p_mobj.c b/src/p_mobj.c index 69eecd26d..49db6daee 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -1736,7 +1736,7 @@ static void P_PushableCheckBustables(mobj_t *mo) // Run a linedef executor?? if (rover->master->flags & ML_EFFECT5) - P_LinedefExecute((INT16)(FixedHypot(rover->master->dx, rover->master->dy)>>FRACBITS), mo, node->m_sector); + P_LinedefExecute((INT16)(P_AproxDistance(rover->master->dx, rover->master->dy)>>FRACBITS), mo, node->m_sector); goto bustupdone; } @@ -2512,7 +2512,7 @@ boolean P_ZMovement(mobj_t *mo) // float down towards target if too close if (!(mo->flags2 & MF2_SKULLFLY) && !(mo->flags2 & MF2_INFLOAT)) { - dist = FixedHypot(mo->x - mo->target->x, mo->y - mo->target->y); + dist = P_AproxDistance(mo->x - mo->target->x, mo->y - mo->target->y); delta = (mo->target->z + (mo->height>>1)) - mo->z; @@ -3665,11 +3665,11 @@ boolean P_CameraThinker(player_t *player, camera_t *thiscam, boolean resetcalled P_ResetCamera(player, thiscam); else { - fixed_t camspeed = FixedHypot(thiscam->momx, thiscam->momy); + fixed_t camspeed = P_AproxDistance(thiscam->momx, thiscam->momy); P_SlideCameraMove(thiscam); - if (!resetcalled && FixedHypot(thiscam->momx, thiscam->momy) == camspeed) + if (!resetcalled && P_AproxDistance(thiscam->momx, thiscam->momy) == camspeed) { P_ResetCamera(player, thiscam); resetcalled = true; @@ -4152,7 +4152,7 @@ boolean P_BossTargetPlayer(mobj_t *actor, boolean closest) if (closest) { - dist = FixedHypot(actor->x - player->mo->x, actor->y - player->mo->y); + dist = P_AproxDistance(actor->x - player->mo->x, actor->y - player->mo->y); if (!lastdist || dist < lastdist) { lastdist = dist+1; @@ -4521,7 +4521,7 @@ static void P_Boss3Thinker(mobj_t *mobj) if (mobj->tracer->x == mobj->x && mobj->tracer->y == mobj->y) { // apply ambush for old routing, otherwise whack a mole only - dist = FixedHypot(FixedHypot(mobj->tracer->x - mobj->x, mobj->tracer->y - mobj->y), mobj->tracer->z + mobj->movefactor - mobj->z); + dist = P_AproxDistance(P_AproxDistance(mobj->tracer->x - mobj->x, mobj->tracer->y - mobj->y), mobj->tracer->z + mobj->movefactor - mobj->z); if (dist < 1) dist = 1; @@ -5045,7 +5045,7 @@ static void P_Boss5Thinker(mobj_t *mobj) } if (mobj->state == &states[mobj->info->xdeathstate]) mobj->momz -= (2*FRACUNIT)/3; - else if (mobj->tracer && FixedHypot(mobj->tracer->x - mobj->x, mobj->tracer->y - mobj->y) < 2*mobj->radius) + else if (mobj->tracer && P_AproxDistance(mobj->tracer->x - mobj->x, mobj->tracer->y - mobj->y) < 2*mobj->radius) mobj->flags &= ~MF_NOCLIP; } else @@ -5171,7 +5171,7 @@ static void P_Boss7Thinker(mobj_t *mobj) if (players[i].mo->health <= 0) continue; - if (FixedHypot(players[i].mo->x - mobj->x, players[i].mo->y - mobj->y) > (mobj->radius + players[i].mo->radius)) + if (P_AproxDistance(players[i].mo->x - mobj->x, players[i].mo->y - mobj->y) > (mobj->radius + players[i].mo->radius)) continue; if (players[i].mo->z > mobj->z + mobj->height - FRACUNIT @@ -5275,7 +5275,7 @@ static void P_Boss7Thinker(mobj_t *mobj) if (mobj->health <= mobj->info->damage && !(mo2->spawnpoint->options & 7)) continue; // don't jump to center - dist = FixedHypot(players[i].mo->x - mo2->x, players[i].mo->y - mo2->y); + dist = P_AproxDistance(players[i].mo->x - mo2->x, players[i].mo->y - mo2->y); if (!(closestNum == -1 || dist < closestdist)) continue; @@ -5348,7 +5348,7 @@ static void P_Boss7Thinker(mobj_t *mobj) an = mobj->angle; an >>= ANGLETOFINESHIFT; - dist = FixedHypot(hitspot->x - mobj->x, hitspot->y - mobj->y); + dist = P_AproxDistance(hitspot->x - mobj->x, hitspot->y - mobj->y); horizontal = dist / airtime; vertical = (gravity*airtime)/2; @@ -5399,7 +5399,7 @@ static void P_Boss7Thinker(mobj_t *mobj) if (players[i].mo->health <= 0) continue; - if (FixedHypot(players[i].mo->x - mobj->x, players[i].mo->y - mobj->y) > mobj->radius*4) + if (P_AproxDistance(players[i].mo->x - mobj->x, players[i].mo->y - mobj->y) > mobj->radius*4) continue; if (players[i].mo->z > mobj->z + 128*FRACUNIT) @@ -5653,14 +5653,14 @@ static void P_Boss9Thinker(mobj_t *mobj) // Spawn energy particles for (spawner = mobj->hnext; spawner; spawner = spawner->hnext) { - dist = FixedHypot(spawner->x - mobj->x, spawner->y - mobj->y); + dist = P_AproxDistance(spawner->x - mobj->x, spawner->y - mobj->y); if (P_RandomRange(1,(dist>>FRACBITS)/16) == 1) break; } if (spawner && dist) { mobj_t *missile = P_SpawnMissile(spawner, mobj, MT_MSGATHER); - missile->fuse = (dist/FixedHypot(missile->momx, missile->momy)); + missile->fuse = (dist/P_AproxDistance(missile->momx, missile->momy)); if (missile->fuse > mobj->fuse) P_RemoveMobj(missile); @@ -6092,7 +6092,7 @@ nodanger: mobj->flags2 |= MF2_INVERTAIMABLE; // Move normally: Approach the player using normal thrust and simulated friction. - dist = FixedHypot(mobj->x-mobj->target->x, mobj->y-mobj->target->y); + 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 && !(mobj->target->player && mobj->target->player->homing)) P_Thrust(mobj, mobj->angle, -4*FRACUNIT); @@ -6100,7 +6100,7 @@ nodanger: P_Thrust(mobj, mobj->angle, FRACUNIT); else P_Thrust(mobj, mobj->angle + ANGLE_90, FINECOSINE((((angle_t)(leveltime*ANG1))>>ANGLETOFINESHIFT) & FINEMASK)>>1); - mobj->momz += FixedHypot(mobj->momx, mobj->momy)/12; // Move up higher the faster you're going. + mobj->momz += P_AproxDistance(mobj->momx, mobj->momy)/12; // Move up higher the faster you're going. } } } @@ -6306,7 +6306,7 @@ void P_SpawnParaloop(fixed_t x, fixed_t y, fixed_t z, fixed_t radius, INT32 numb mobj->angle = R_PointToAngle2(mobj->x, mobj->y, x, y); // change slope - dist = FixedHypot(FixedHypot(x - mobj->x, y - mobj->y), z - mobj->z); + dist = P_AproxDistance(P_AproxDistance(x - mobj->x, y - mobj->y), z - mobj->z); if (dist < 1) dist = 1; @@ -6380,7 +6380,7 @@ void P_Attract(mobj_t *source, mobj_t *dest, boolean nightsgrab) // Home in on y fixed_t tx = dest->x; fixed_t ty = dest->y; fixed_t tz = dest->z + (dest->height/2); // Aim for center - fixed_t xydist = FixedHypot(tx - source->x, ty - source->y); + fixed_t xydist = P_AproxDistance(tx - source->x, ty - source->y); if (!dest || dest->health <= 0 || !dest->player || !source->tracer) return; @@ -6389,7 +6389,7 @@ void P_Attract(mobj_t *source, mobj_t *dest, boolean nightsgrab) // Home in on y source->angle = R_PointToAngle2(source->x, source->y, tx, ty); // change slope - dist = FixedHypot(xydist, tz - source->z); + dist = P_AproxDistance(xydist, tz - source->z); if (dist < 1) dist = 1; @@ -6415,9 +6415,9 @@ void P_Attract(mobj_t *source, mobj_t *dest, boolean nightsgrab) // Home in on y else { if (nightsgrab) - speedmul = FixedHypot(dest->momx, dest->momy) + FixedMul(8*FRACUNIT, source->scale); + speedmul = P_AproxDistance(dest->momx, dest->momy) + FixedMul(8*FRACUNIT, source->scale); else - speedmul = FixedHypot(dest->momx, dest->momy) + FixedMul(source->info->speed, source->scale); + speedmul = P_AproxDistance(dest->momx, dest->momy) + FixedMul(source->info->speed, source->scale); source->momx = FixedMul(FixedDiv(tx - source->x, dist), speedmul); source->momy = FixedMul(FixedDiv(ty - source->y, dist), speedmul); @@ -6425,7 +6425,7 @@ void P_Attract(mobj_t *source, mobj_t *dest, boolean nightsgrab) // Home in on y } // Instead of just unsetting NOCLIP like an idiot, let's check the distance to our target. - ndist = FixedHypot(FixedHypot(tx - (source->x+source->momx), + ndist = P_AproxDistance(P_AproxDistance(tx - (source->x+source->momx), ty - (source->y+source->momy)), tz - (source->z+source->momz)); @@ -7076,7 +7076,7 @@ static void P_MaceSceneryThink(mobj_t *mobj) // The below is selected based on CEZ2's first room. I promise you it is a coincidence that it looks like the weed number. for (i = 0; i < MAXPLAYERS; ++i) if (playeringame[i] && players[i].mo - && FixedHypot(FixedHypot(mobj->x - players[i].mo->x, mobj->y - players[i].mo->y), mobj->z - players[i].mo->z) < (4200 << FRACBITS)) + && P_AproxDistance(P_AproxDistance(mobj->x - players[i].mo->x, mobj->y - players[i].mo->y), mobj->z - players[i].mo->z) < (4200 << FRACBITS)) break; // Stop looking. if (i == MAXPLAYERS) { @@ -8052,7 +8052,7 @@ static boolean P_MobjBossThink(mobj_t *mobj) { if (mobj->target) { - mobj->momz = FixedMul(FixedDiv(mobj->target->z - mobj->z, FixedHypot(mobj->x - mobj->target->x, mobj->y - mobj->target->y)), mobj->scale << 1); + mobj->momz = FixedMul(FixedDiv(mobj->target->z - mobj->z, P_AproxDistance(mobj->x - mobj->target->x, mobj->y - mobj->target->y)), mobj->scale << 1); mobj->angle = R_PointToAngle2(mobj->x, mobj->y, mobj->target->x, mobj->target->y); } else @@ -8296,7 +8296,7 @@ static void P_ArrowThink(mobj_t *mobj) 0------dist(momx,momy) */ - fixed_t dist = FixedHypot(mobj->momx, mobj->momy); + fixed_t dist = P_AproxDistance(mobj->momx, mobj->momy); angle_t angle = R_PointToAngle2(0, 0, dist, mobj->momz); if (angle > ANG20 && angle <= ANGLE_180) @@ -8578,7 +8578,7 @@ static boolean P_EggRobo1Think(mobj_t *mobj) continue; if (players[i].mo->z + players[i].mo->height < mobj->z - 8*mobj->scale) continue; - compdist = FixedHypot( + compdist = P_AproxDistance( players[i].mo->x + players[i].mo->momx - basex, players[i].mo->y + players[i].mo->momy - basey); if (compdist >= dist) @@ -8593,7 +8593,7 @@ static boolean P_EggRobo1Think(mobj_t *mobj) mobj->frame = 3 + ((leveltime & 2) >> 1); mobj->angle = R_PointToAngle2(mobj->x, mobj->y, mobj->target->x, mobj->target->y); - if (FixedHypot( + if (P_AproxDistance( mobj->x - basex, mobj->y - basey) < mobj->scale) @@ -8624,7 +8624,7 @@ static boolean P_EggRobo1Think(mobj_t *mobj) if (!didmove) { - if (FixedHypot(mobj->x - basex, mobj->y - basey) < mobj->scale) + if (P_AproxDistance(mobj->x - basex, mobj->y - basey) < mobj->scale) P_TeleportMove(mobj, basex, basey, mobj->z); else P_TeleportMove(mobj, @@ -9014,7 +9014,7 @@ static void P_PyreFlyThink(mobj_t *mobj) { //Aim for player z position. If too close to floor/ceiling, aim just above/below them. fixed_t destz = min(max(mobj->target->z, mobj->target->floorz + 70*FRACUNIT), mobj->target->ceilingz - 80*FRACUNIT - mobj->height); - fixed_t dist = FixedHypot(hdist, destz - mobj->z); + fixed_t dist = P_AproxDistance(hdist, destz - mobj->z); P_InstaThrust(mobj, R_PointToAngle2(mobj->x, mobj->y, mobj->target->x, mobj->target->y), 2*FRACUNIT); mobj->momz = FixedMul(FixedDiv(destz - mobj->z, dist), 2*FRACUNIT); } @@ -9116,7 +9116,7 @@ static void P_PterabyteThink(mobj_t *mobj) var1 = 2*mobj->info->speed; var2 = 1; A_HomingChase(mobj); - if (FixedHypot(mobj->x - mobj->tracer->x, mobj->y - mobj->tracer->y) <= mobj->info->speed) + if (P_AproxDistance(mobj->x - mobj->tracer->x, mobj->y - mobj->tracer->y) <= mobj->info->speed) { mobj->extravalue1 -= 2; mobj->momx = mobj->momy = mobj->momz = 0; @@ -9141,7 +9141,7 @@ static void P_DragonbomberThink(mobj_t *mobj) { mobj_t *mine = P_SpawnMobjFromMobj(segment, 0, 0, 0, segment->info->painchance); mine->angle = segment->angle; - P_InstaThrust(mine, mobj->angle, FixedHypot(mobj->momx, mobj->momy) >> 1); + P_InstaThrust(mine, mobj->angle, P_AproxDistance(mobj->momx, mobj->momy) >> 1); P_SetObjectMomZ(mine, -2*FRACUNIT, true); S_StartSound(mine, mine->info->seesound); P_SetMobjState(segment, segment->info->raisestate); @@ -9151,7 +9151,7 @@ static void P_DragonbomberThink(mobj_t *mobj) } if (mobj->target) // Are we chasing a player? { - fixed_t dist = FixedHypot(mobj->x - mobj->target->x, mobj->y - mobj->target->y); + fixed_t dist = P_AproxDistance(mobj->x - mobj->target->x, mobj->y - mobj->target->y); if (dist > 2000*mobj->scale) // Not anymore! P_SetTarget(&mobj->target, NULL); else @@ -9259,7 +9259,7 @@ static boolean P_MobjRegularThink(mobj_t *mobj) mobj->eflags |= MFE_UNDERWATER; //P_MobjCheckWater(mobj); // solely for MFE_UNDERWATER for A_FlickySpawn { if (mobj->tracer && mobj->tracer->player && mobj->tracer->health > 0 - && FixedHypot(FixedHypot(mobj->tracer->x - mobj->x, mobj->tracer->y - mobj->y), mobj->tracer->z - mobj->z) <= mobj->radius*16) + && P_AproxDistance(P_AproxDistance(mobj->tracer->x - mobj->x, mobj->tracer->y - mobj->y), mobj->tracer->z - mobj->z) <= mobj->radius*16) { var1 = mobj->info->speed; var2 = 1; @@ -9394,7 +9394,7 @@ static boolean P_MobjRegularThink(mobj_t *mobj) if (playeringame[i] && players[i].mo && players[i].mare == mobj->threshold && players[i].spheres > 0) { - fixed_t dist = FixedHypot(players[i].mo->x - mobj->x, players[i].mo->y - mobj->y); + fixed_t dist = P_AproxDistance(players[i].mo->x - mobj->x, players[i].mo->y - mobj->y); if (dist < shortest) { P_SetTarget(&mobj->target, players[i].mo); @@ -9425,7 +9425,7 @@ static boolean P_MobjRegularThink(mobj_t *mobj) P_KoopaThinker(mobj); break; case MT_FIREBALL: - if (FixedHypot(mobj->momx, mobj->momy) <= 16*FRACUNIT) // Once fireballs lose enough speed, kill them + if (P_AproxDistance(mobj->momx, mobj->momy) <= 16*FRACUNIT) // Once fireballs lose enough speed, kill them { P_KillMobj(mobj, NULL, NULL, 0); return false; @@ -13530,7 +13530,7 @@ mobj_t *P_SpawnXYZMissile(mobj_t *source, mobj_t *dest, mobjtype_t type, th->momx = FixedMul(speed, FINECOSINE(an)); th->momy = FixedMul(speed, FINESINE(an)); - dist = FixedHypot(dest->x - x, dest->y - y); + dist = P_AproxDistance(dest->x - x, dest->y - y); dist = dist / speed; if (dist < 1) @@ -13592,7 +13592,7 @@ mobj_t *P_SpawnAlteredDirectionMissile(mobj_t *source, mobjtype_t type, fixed_t th->momx = FixedMul(speed, FINECOSINE(an)); th->momy = FixedMul(speed, FINESINE(an)); - dist = FixedHypot(source->momx*800, source->momy*800); + dist = P_AproxDistance(source->momx*800, source->momy*800); dist = dist / speed; if (dist < 1) @@ -13657,7 +13657,7 @@ mobj_t *P_SpawnPointMissile(mobj_t *source, fixed_t xa, fixed_t ya, fixed_t za, th->momx = FixedMul(speed, FINECOSINE(an)); th->momy = FixedMul(speed, FINESINE(an)); - dist = FixedHypot(xa - x, ya - y); + dist = P_AproxDistance(xa - x, ya - y); dist = dist / speed; if (dist < 1) @@ -13737,9 +13737,9 @@ mobj_t *P_SpawnMissile(mobj_t *source, mobj_t *dest, mobjtype_t type) th->momy = FixedMul(speed, FINESINE(an)); if (type == MT_TURRETLASER || type == MT_ENERGYBALL) // More accurate! - dist = FixedHypot(dest->x+(dest->momx*gsf) - source->x, dest->y+(dest->momy*gsf) - source->y); + dist = P_AproxDistance(dest->x+(dest->momx*gsf) - source->x, dest->y+(dest->momy*gsf) - source->y); else - dist = FixedHypot(dest->x - source->x, dest->y - source->y); + dist = P_AproxDistance(dest->x - source->x, dest->y - source->y); dist = dist / speed; diff --git a/src/p_polyobj.c b/src/p_polyobj.c index 95734ff86..874edbd50 100644 --- a/src/p_polyobj.c +++ b/src/p_polyobj.c @@ -1636,7 +1636,7 @@ void T_PolyObjWaypoint(polywaypoint_t *th) distx = target->x - pox; disty = target->y - poy; distz = target->z - poz; - dist = FixedHypot(FixedHypot(distx, disty), distz); + dist = P_AproxDistance(P_AproxDistance(distx, disty), distz); if (dist < 1) dist = 1; diff --git a/src/p_setup.c b/src/p_setup.c index 2c0b84ba6..66243fb0e 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -232,7 +232,7 @@ mobj_t *P_GetClosestWaypoint(UINT8 sequence, mobj_t *mo) if (!mo2) continue; - curdist = FixedHypot(FixedHypot(mo->x - mo2->x, mo->y - mo2->y), mo->z - mo2->z); + curdist = P_AproxDistance(P_AproxDistance(mo->x - mo2->x, mo->y - mo2->y), mo->z - mo2->z); if (result && curdist > bestdist) continue; diff --git a/src/p_slopes.c b/src/p_slopes.c index d77d0805f..aa46a8402 100644 --- a/src/p_slopes.c +++ b/src/p_slopes.c @@ -885,7 +885,7 @@ void P_ButteredSlope(mobj_t *mo) } if (mo->momx || mo->momy) // Slightly increase thrust based on the object's speed - thrust = FixedMul(thrust, FRACUNIT+FixedHypot(mo->momx, mo->momy)/16); + thrust = FixedMul(thrust, FRACUNIT+P_AproxDistance(mo->momx, mo->momy)/16); // This makes it harder to zigzag up steep slopes, as well as allows greater top speed when rolling down // Let's get the gravity strength for the object... diff --git a/src/p_spec.c b/src/p_spec.c index eb14f8dd6..226e58d15 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -1240,7 +1240,7 @@ static boolean PolyFlag(line_t *line) polyflagdata_t pfd; pfd.polyObjNum = Tag_FGet(&line->tags); - pfd.speed = FixedHypot(line->dx, line->dy) >> FRACBITS; + pfd.speed = P_AproxDistance(line->dx, line->dy) >> FRACBITS; pfd.angle = R_PointToAngle2(line->v1->x, line->v1->y, line->v2->x, line->v2->y) >> ANGLETOFINESHIFT; pfd.momx = sides[line->sidenum[0]].textureoffset >> FRACBITS; @@ -1567,7 +1567,7 @@ static boolean P_CheckNightsTriggerLine(line_t *triggerline, mobj_t *actor) boolean P_RunTriggerLinedef(line_t *triggerline, mobj_t *actor, sector_t *caller) { sector_t *ctlsector; - fixed_t dist = FixedHypot(triggerline->dx, triggerline->dy)>>FRACBITS; + fixed_t dist = P_AproxDistance(triggerline->dx, triggerline->dy)>>FRACBITS; size_t i, linecnt, sectori; INT16 specialtype = triggerline->special; @@ -2629,7 +2629,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) sectors[secnum].lightlevel = line->backsector->lightlevel; flick = P_SpawnAdjustableFireFlicker(line->frontsector, §ors[secnum], - FixedHypot(line->dx, line->dy)>>FRACBITS); + P_AproxDistance(line->dx, line->dy)>>FRACBITS); // Make sure the starting light level is in range. if (reallightlevel < flick->minlight) @@ -2644,7 +2644,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) // Use front sector for min, target sector for max, // the same way linetype 61 does it. P_SpawnAdjustableFireFlicker(line->frontsector, §ors[secnum], - FixedHypot(line->dx, line->dy)>>FRACBITS); + P_AproxDistance(line->dx, line->dy)>>FRACBITS); } } break; @@ -2663,7 +2663,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) sectors[secnum].lightlevel = line->backsector->lightlevel; glow = P_SpawnAdjustableGlowingLight(line->frontsector, §ors[secnum], - FixedHypot(line->dx, line->dy)>>FRACBITS); + P_AproxDistance(line->dx, line->dy)>>FRACBITS); // Make sure the starting light level is in range. if (reallightlevel < glow->minlight) @@ -2678,7 +2678,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) // Use front sector for min, target sector for max, // the same way linetype 602 does it. P_SpawnAdjustableGlowingLight(line->frontsector, §ors[secnum], - FixedHypot(line->dx, line->dy)>>FRACBITS); + P_AproxDistance(line->dx, line->dy)>>FRACBITS); } } break; @@ -2760,7 +2760,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) ((line->sidenum[1] != 0xFFFF && !(sides[line->sidenum[0]].rowoffset>>FRACBITS)) ? max(min(sides[line->sidenum[1]].rowoffset>>FRACBITS, 255), 0) : max(min(sides[line->sidenum[0]].rowoffset>>FRACBITS, 255), 0)) - : abs(FixedHypot(line->dx, line->dy))>>FRACBITS, + : abs(P_AproxDistance(line->dx, line->dy))>>FRACBITS, (line->flags & ML_EFFECT4), (line->flags & ML_EFFECT5)); break; @@ -2795,7 +2795,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) else { P_SetTarget(&mo->player->awayviewmobj, altview); - mo->player->awayviewtics = FixedHypot(line->dx, line->dy)>>FRACBITS; + mo->player->awayviewtics = P_AproxDistance(line->dx, line->dy)>>FRACBITS; } @@ -2840,7 +2840,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) case 425: // Calls P_SetMobjState on calling mobj if (mo && !mo->player) - P_SetMobjState(mo, sides[line->sidenum[0]].toptexture); //FixedHypot(line->dx, line->dy)>>FRACBITS); + P_SetMobjState(mo, sides[line->sidenum[0]].toptexture); //P_AproxDistance(line->dx, line->dy)>>FRACBITS); break; case 426: // Moves the mobj to its sector's soundorg and on the floor, and stops it @@ -3026,7 +3026,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) case 438: // Set player scale if (mo) { - mo->destscale = FixedDiv(FixedHypot(line->dx, line->dy), 100<destscale = FixedDiv(P_AproxDistance(line->dx, line->dy), 100<destscale < FRACUNIT/100) mo->destscale = FRACUNIT/100; if (mo->player && bot) @@ -3144,7 +3144,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) { quake.intensity = sides[line->sidenum[0]].textureoffset; quake.radius = sides[line->sidenum[0]].rowoffset; - quake.time = FixedHypot(line->dx, line->dy)>>FRACBITS; + quake.time = P_AproxDistance(line->dx, line->dy)>>FRACBITS; quake.epicenter = NULL; /// \todo @@ -3407,7 +3407,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) case 452: // Set FOF alpha { INT16 destvalue = line->sidenum[1] != 0xffff ? - (INT16)(sides[line->sidenum[1]].textureoffset>>FRACBITS) : (INT16)(FixedHypot(line->dx, line->dy)>>FRACBITS); + (INT16)(sides[line->sidenum[1]].textureoffset>>FRACBITS) : (INT16)(P_AproxDistance(line->dx, line->dy)>>FRACBITS); INT16 sectag = (INT16)(sides[line->sidenum[0]].textureoffset>>FRACBITS); INT16 foftag = (INT16)(sides[line->sidenum[0]].rowoffset>>FRACBITS); sector_t *sec; // Sector that the FOF is visible in @@ -4997,8 +4997,8 @@ DoneSection2: } else { - if (FixedHypot(FixedHypot(player->mo->x-resultlow.x, player->mo->y-resultlow.y), - player->mo->z-resultlow.z) < FixedHypot(FixedHypot(player->mo->x-resulthigh.x, + if (P_AproxDistance(P_AproxDistance(player->mo->x-resultlow.x, player->mo->y-resultlow.y), + player->mo->z-resultlow.z) < P_AproxDistance(P_AproxDistance(player->mo->x-resulthigh.x, player->mo->y-resulthigh.y), player->mo->z-resulthigh.z)) { // Line between Mid and Low is closer @@ -6316,7 +6316,7 @@ void P_SpawnSpecials(boolean fromnetsave) break; case 52: // Continuously Falling sector - EV_DoContinuousFall(lines[i].frontsector, lines[i].backsector, FixedHypot(lines[i].dx, lines[i].dy), (lines[i].flags & ML_NOCLIMB)); + EV_DoContinuousFall(lines[i].frontsector, lines[i].backsector, P_AproxDistance(lines[i].dx, lines[i].dy), (lines[i].flags & ML_NOCLIMB)); break; case 53: // New super cool and awesome moving floor and ceiling type @@ -6388,15 +6388,15 @@ void P_SpawnSpecials(boolean fromnetsave) case 66: // Displace floor by front sector TAG_ITER_SECTORS(0, tag, s) - P_AddPlaneDisplaceThinker(pd_floor, FixedHypot(lines[i].dx, lines[i].dy)>>8, sides[lines[i].sidenum[0]].sector-sectors, s, !!(lines[i].flags & ML_NOCLIMB)); + P_AddPlaneDisplaceThinker(pd_floor, P_AproxDistance(lines[i].dx, lines[i].dy)>>8, sides[lines[i].sidenum[0]].sector-sectors, s, !!(lines[i].flags & ML_NOCLIMB)); break; case 67: // Displace ceiling by front sector TAG_ITER_SECTORS(0, tag, s) - P_AddPlaneDisplaceThinker(pd_ceiling, FixedHypot(lines[i].dx, lines[i].dy)>>8, sides[lines[i].sidenum[0]].sector-sectors, s, !!(lines[i].flags & ML_NOCLIMB)); + P_AddPlaneDisplaceThinker(pd_ceiling, P_AproxDistance(lines[i].dx, lines[i].dy)>>8, sides[lines[i].sidenum[0]].sector-sectors, s, !!(lines[i].flags & ML_NOCLIMB)); break; case 68: // Displace both floor AND ceiling by front sector TAG_ITER_SECTORS(0, tag, s) - P_AddPlaneDisplaceThinker(pd_both, FixedHypot(lines[i].dx, lines[i].dy)>>8, sides[lines[i].sidenum[0]].sector-sectors, s, !!(lines[i].flags & ML_NOCLIMB)); + P_AddPlaneDisplaceThinker(pd_both, P_AproxDistance(lines[i].dx, lines[i].dy)>>8, sides[lines[i].sidenum[0]].sector-sectors, s, !!(lines[i].flags & ML_NOCLIMB)); break; case 100: // FOF (solid, opaque, shadows) @@ -6590,18 +6590,18 @@ void P_SpawnSpecials(boolean fromnetsave) case 150: // Air bobbing platform case 151: // Adjustable air bobbing platform { - fixed_t dist = (lines[i].special == 150) ? 16*FRACUNIT : FixedHypot(lines[i].dx, lines[i].dy); + fixed_t dist = (lines[i].special == 150) ? 16*FRACUNIT : P_AproxDistance(lines[i].dx, lines[i].dy); P_AddFakeFloorsByLine(i, FF_EXISTS|FF_SOLID|FF_RENDERALL|FF_CUTLEVEL, secthinkers); P_AddAirbob(lines[i].frontsector, tag, dist, false, !!(lines[i].flags & ML_NOCLIMB), false); break; } case 152: // Adjustable air bobbing platform in reverse P_AddFakeFloorsByLine(i, FF_EXISTS|FF_SOLID|FF_RENDERALL|FF_CUTLEVEL, secthinkers); - P_AddAirbob(lines[i].frontsector, tag, FixedHypot(lines[i].dx, lines[i].dy), true, !!(lines[i].flags & ML_NOCLIMB), false); + P_AddAirbob(lines[i].frontsector, tag, P_AproxDistance(lines[i].dx, lines[i].dy), true, !!(lines[i].flags & ML_NOCLIMB), false); break; case 153: // Dynamic Sinking Platform P_AddFakeFloorsByLine(i, FF_EXISTS|FF_SOLID|FF_RENDERALL|FF_CUTLEVEL, secthinkers); - P_AddAirbob(lines[i].frontsector, tag, FixedHypot(lines[i].dx, lines[i].dy), false, !!(lines[i].flags & ML_NOCLIMB), true); + P_AddAirbob(lines[i].frontsector, tag, P_AproxDistance(lines[i].dx, lines[i].dy), false, !!(lines[i].flags & ML_NOCLIMB), true); break; case 160: // Float/bob platform @@ -6680,7 +6680,7 @@ void P_SpawnSpecials(boolean fromnetsave) case 194: // Rising Platform 'Platform' - You can jump up through it case 195: // Rising Platform Translucent "platform" { - fixed_t speed = FixedDiv(FixedHypot(lines[i].dx, lines[i].dy), 4*FRACUNIT); + fixed_t speed = FixedDiv(P_AproxDistance(lines[i].dx, lines[i].dy), 4*FRACUNIT); fixed_t ceilingtop = P_FindHighestCeilingSurrounding(lines[i].frontsector); fixed_t ceilingbottom = P_FindLowestCeilingSurrounding(lines[i].frontsector); @@ -7005,14 +7005,14 @@ void P_SpawnSpecials(boolean fromnetsave) sec = sides[*lines[i].sidenum].sector - sectors; TAG_ITER_SECTORS(0, tag, s) P_SpawnAdjustableGlowingLight(§ors[sec], §ors[s], - FixedHypot(lines[i].dx, lines[i].dy)>>FRACBITS); + P_AproxDistance(lines[i].dx, lines[i].dy)>>FRACBITS); break; case 603: // Adjustable flickering light sec = sides[*lines[i].sidenum].sector - sectors; TAG_ITER_SECTORS(0, tag, s) P_SpawnAdjustableFireFlicker(§ors[sec], §ors[s], - FixedHypot(lines[i].dx, lines[i].dy)>>FRACBITS); + P_AproxDistance(lines[i].dx, lines[i].dy)>>FRACBITS); break; case 604: // Adjustable Blinking Light (unsynchronized) @@ -8418,9 +8418,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 = FixedHypot(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 = FixedHypot(p->x_mag,p->y_mag); + p->magnitude = P_AproxDistance(p->x_mag,p->y_mag); if (source) // point source exist? { // where force goes to zero @@ -8471,14 +8471,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 = FixedHypot(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 = FixedHypot(FixedHypot(thing->x - sx, thing->y - sy), + dist = P_AproxDistance(P_AproxDistance(thing->x - sx, thing->y - sy), thing->z - sz); } @@ -8813,7 +8813,7 @@ void T_Pusher(pusher_t *p) // Tumbleweeds bounce a bit... if (thing->type == MT_LITTLETUMBLEWEED || thing->type == MT_BIGTUMBLEWEED) - thing->momz += FixedHypot(xspeed<<(FRACBITS-PUSH_FACTOR), yspeed<<(FRACBITS-PUSH_FACTOR)) >> 2; + thing->momz += P_AproxDistance(xspeed<<(FRACBITS-PUSH_FACTOR), yspeed<<(FRACBITS-PUSH_FACTOR)) >> 2; } if (moved) diff --git a/src/p_user.c b/src/p_user.c index dbf13cefc..a9e1fe9a2 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -1018,7 +1018,7 @@ void P_DoPlayerPain(player_t *player, mobj_t *source, mobj_t *inflictor) // to recover if ((inflictor->flags2 & MF2_SCATTER) && source) { - fixed_t dist = FixedHypot(FixedHypot(source->x-player->mo->x, source->y-player->mo->y), source->z-player->mo->z); + fixed_t dist = P_AproxDistance(P_AproxDistance(source->x-player->mo->x, source->y-player->mo->y), source->z-player->mo->z); dist = FixedMul(128*FRACUNIT, inflictor->scale) - dist/4; @@ -2701,7 +2701,7 @@ static void P_CheckBustableBlocks(player_t *player) // Run a linedef executor?? if (rover->master->flags & ML_EFFECT5) - P_LinedefExecute((INT16)(FixedHypot(rover->master->dx, rover->master->dy)>>FRACBITS), player->mo, node->m_sector); + P_LinedefExecute((INT16)(P_AproxDistance(rover->master->dx, rover->master->dy)>>FRACBITS), player->mo, node->m_sector); goto bustupdone; } @@ -2764,7 +2764,7 @@ static void P_CheckBouncySectors(player_t *player) if (player->mo->z + player->mo->height < bottomheight) continue; - bouncestrength = FixedHypot(rover->master->dx, rover->master->dy)/100; + bouncestrength = P_AproxDistance(rover->master->dx, rover->master->dy)/100; if (oldz < P_GetFOFTopZ(player->mo, node->m_sector, rover, oldx, oldy, NULL) && oldz + player->mo->height > P_GetFOFBottomZ(player->mo, node->m_sector, rover, oldx, oldy, NULL)) @@ -4981,7 +4981,7 @@ 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; - dist = FixedHypot(FixedHypot(player->mo->x-mo2->x, player->mo->y-mo2->y), player->mo->z-mo2->z); + dist = P_AproxDistance(P_AproxDistance(player->mo->x-mo2->x, player->mo->y-mo2->y), player->mo->z-mo2->z); if (range < dist) continue; @@ -6464,12 +6464,12 @@ static void P_NightsTransferPoints(player_t *player, fixed_t xspeed, fixed_t rad //CONS_Debug(DBG_NIGHTS, "T1 is at %d, %d\n", transfer1->x>>FRACBITS, transfer1->y>>FRACBITS); //CONS_Debug(DBG_NIGHTS, "T2 is at %d, %d\n", transfer2->x>>FRACBITS, transfer2->y>>FRACBITS); - //CONS_Debug(DBG_NIGHTS, "Distance from T1: %d\n", FixedHypot(transfer1->x - player->mo->x, transfer1->y - player->mo->y)>>FRACBITS); - //CONS_Debug(DBG_NIGHTS, "Distance from T2: %d\n", FixedHypot(transfer2->x - player->mo->x, transfer2->y - player->mo->y)>>FRACBITS); + //CONS_Debug(DBG_NIGHTS, "Distance from T1: %d\n", P_AproxDistance(transfer1->x - player->mo->x, transfer1->y - player->mo->y)>>FRACBITS); + //CONS_Debug(DBG_NIGHTS, "Distance from T2: %d\n", P_AproxDistance(transfer2->x - player->mo->x, transfer2->y - player->mo->y)>>FRACBITS); // Transfer1 is closer to the player than transfer2 - if (FixedHypot(transfer1->x - player->mo->x, transfer1->y - player->mo->y)>>FRACBITS - < FixedHypot(transfer2->x - player->mo->x, transfer2->y - player->mo->y)>>FRACBITS) + if (P_AproxDistance(transfer1->x - player->mo->x, transfer1->y - player->mo->y)>>FRACBITS + < P_AproxDistance(transfer2->x - player->mo->x, transfer2->y - player->mo->y)>>FRACBITS) { //CONS_Debug(DBG_NIGHTS, " must be < 0 to transfer\n"); @@ -7709,7 +7709,7 @@ void P_BlackOw(player_t *player) S_StartSound (player->mo, sfx_bkpoof); // Sound the BANG! for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i] && FixedHypot(player->mo->x - players[i].mo->x, + if (playeringame[i] && P_AproxDistance(player->mo->x - players[i].mo->x, player->mo->y - players[i].mo->y) < 1536*FRACUNIT) P_FlashPal(&players[i], PAL_NUKE, 10); @@ -7893,7 +7893,7 @@ static void P_SkidStuff(player_t *player) P_SpawnSkidDust(player, 0, false); } } - else if (FixedHypot(pmx, pmy) >= FixedMul(player->runspeed/2, player->mo->scale) // if you were moving faster than half your run speed last frame + else if (P_AproxDistance(pmx, pmy) >= FixedMul(player->runspeed/2, player->mo->scale) // if you were moving faster than half your run speed last frame && (player->mo->momx != pmx || player->mo->momy != pmy) // and you are moving differently this frame && P_GetPlayerControlDirection(player) == 2) // and your controls are pointing in the opposite direction to your movement { // check for skidding @@ -8524,7 +8524,7 @@ void P_MovePlayer(player_t *player) P_ResetScore(player); // Show the "THOK!" graphic when spinning quickly across the ground. (even applies to non-spinners, in the case of zoom tubes) - if (player->pflags & PF_SPINNING && FixedHypot(player->speed, player->mo->momz) > FixedMul(15<mo->scale) && !(player->pflags & PF_JUMPED)) + if (player->pflags & PF_SPINNING && P_AproxDistance(player->speed, player->mo->momz) > FixedMul(15<mo->scale) && !(player->pflags & PF_JUMPED)) { P_SpawnSpinMobj(player, player->spinitem); G_GhostAddSpin(); @@ -8745,7 +8745,7 @@ static void P_DoZoomTube(player_t *player) speed = abs(player->speed); // change slope - dist = FixedHypot(FixedHypot(player->mo->tracer->x - player->mo->x, player->mo->tracer->y - player->mo->y), player->mo->tracer->z - player->mo->z); + dist = P_AproxDistance(P_AproxDistance(player->mo->tracer->x - player->mo->x, player->mo->tracer->y - player->mo->y), player->mo->tracer->z - player->mo->z); if (dist < 1) dist = 1; @@ -8786,7 +8786,7 @@ static void P_DoZoomTube(player_t *player) // calculate MOMX/MOMY/MOMZ for next waypoint // change slope - dist = FixedHypot(FixedHypot(player->mo->tracer->x - player->mo->x, player->mo->tracer->y - player->mo->y), player->mo->tracer->z - player->mo->z); + dist = P_AproxDistance(P_AproxDistance(player->mo->tracer->x - player->mo->x, player->mo->tracer->y - player->mo->y), player->mo->tracer->z - player->mo->z); if (dist < 1) dist = 1; @@ -8839,7 +8839,7 @@ static void P_DoRopeHang(player_t *player) sequence = player->mo->tracer->threshold; // change slope - dist = FixedHypot(FixedHypot(player->mo->tracer->x - player->mo->x, player->mo->tracer->y - player->mo->y), player->mo->tracer->z - playerz); + dist = P_AproxDistance(P_AproxDistance(player->mo->tracer->x - player->mo->x, player->mo->tracer->y - player->mo->y), player->mo->tracer->z - playerz); if (dist < 1) dist = 1; @@ -8902,7 +8902,7 @@ static void P_DoRopeHang(player_t *player) // calculate MOMX/MOMY/MOMZ for next waypoint // change slope - dist = FixedHypot(FixedHypot(player->mo->tracer->x - player->mo->x, player->mo->tracer->y - player->mo->y), player->mo->tracer->z - playerz); + dist = P_AproxDistance(P_AproxDistance(player->mo->tracer->x - player->mo->x, player->mo->tracer->y - player->mo->y), player->mo->tracer->z - playerz); if (dist < 1) dist = 1; @@ -9003,7 +9003,7 @@ void P_NukeEnemies(mobj_t *inflictor, mobj_t *source, fixed_t radius) if (abs(inflictor->x - mo->x) > radius || abs(inflictor->y - mo->y) > radius || abs(inflictor->z - mo->z) > radius) continue; // Workaround for possible integer overflow in the below -Red - if (FixedHypot(FixedHypot(inflictor->x - mo->x, inflictor->y - mo->y), inflictor->z - mo->z) > radius) + if (P_AproxDistance(P_AproxDistance(inflictor->x - mo->x, inflictor->y - mo->y), inflictor->z - mo->z) > radius) continue; if (mo->type == MT_MINUS && !(mo->flags & (MF_SPECIAL|MF_SHOOTABLE))) @@ -9139,12 +9139,12 @@ mobj_t *P_LookForFocusTarget(player_t *player, mobj_t *exclude, SINT8 direction, { fixed_t zdist = (player->mo->z + player->mo->height/2) - (mo->z + mo->height/2); - dist = FixedHypot(player->mo->x-mo->x, player->mo->y-mo->y); + dist = P_AproxDistance(player->mo->x-mo->x, player->mo->y-mo->y); if (abs(zdist) > dist) continue; // Don't home outside of desired angle! - dist = FixedHypot(dist, zdist); + dist = P_AproxDistance(dist, zdist); if (dist > maxdist) continue; // out of range } @@ -9236,7 +9236,7 @@ mobj_t *P_LookForEnemies(player_t *player, boolean nonenemies, boolean bullet) { fixed_t zdist = (player->mo->z + player->mo->height/2) - (mo->z + mo->height/2); - dist = FixedHypot(player->mo->x-mo->x, player->mo->y-mo->y); + dist = P_AproxDistance(player->mo->x-mo->x, player->mo->y-mo->y); if (bullet) { if ((R_PointToAngle2(0, 0, dist, zdist) + span) > span*2) @@ -9253,7 +9253,7 @@ mobj_t *P_LookForEnemies(player_t *player, boolean nonenemies, boolean bullet) continue; } - dist = FixedHypot(dist, zdist); + dist = P_AproxDistance(dist, zdist); if (dist > maxdist) continue; // out of range } @@ -9313,7 +9313,7 @@ boolean P_HomingAttack(mobj_t *source, mobj_t *enemy) // Home in on your target // change slope zdist = ((P_MobjFlip(source) == -1) ? (enemy->z + enemy->height) - (source->z + source->height) : (enemy->z - source->z)); - dist = FixedHypot(FixedHypot(enemy->x - source->x, enemy->y - source->y), zdist); + dist = P_AproxDistance(P_AproxDistance(enemy->x - source->x, enemy->y - source->y), zdist); if (dist < 1) dist = 1; @@ -10362,7 +10362,7 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall // follow the player /*if (player->playerstate != PST_DEAD && (camspeed) != 0) { - if (FixedHypot(mo->x - thiscam->x, mo->y - thiscam->y) > (checkdist + FixedHypot(mo->momx, mo->momy)) * 4 + if (P_AproxDistance(mo->x - thiscam->x, mo->y - thiscam->y) > (checkdist + P_AproxDistance(mo->momx, mo->momy)) * 4 || abs(mo->z - thiscam->z) > checkdist * 3) { if (!resetcalled) @@ -10427,7 +10427,7 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall } /* check z distance too for orbital camera */ - if (FixedHypot(FixedHypot(vx - mo->x, vy - mo->y), + if (P_AproxDistance(P_AproxDistance(vx - mo->x, vy - mo->y), vz - ( mo->z + mo->height / 2 )) < FixedMul(48*FRACUNIT, mo->scale)) mo->flags2 |= MF2_SHADOW; else @@ -10912,7 +10912,7 @@ static void P_ParabolicMove(mobj_t *mo, fixed_t x, fixed_t y, fixed_t z, fixed_t fixed_t dx = x - mo->x; fixed_t dy = y - mo->y; fixed_t dz = z - mo->z; - fixed_t dh = FixedHypot(dx, dy); + fixed_t dh = P_AproxDistance(dx, dy); fixed_t c = FixedDiv(dx, dh); fixed_t s = FixedDiv(dy, dh); fixed_t fixConst = FixedDiv(speed, g); @@ -11784,7 +11784,7 @@ void P_PlayerThink(player_t *player) if (mo2->flags2 & MF2_NIGHTSPULL) continue; - if (FixedHypot(FixedHypot(mo2->x - x, mo2->y - y), mo2->z - z) > FixedMul(128*FRACUNIT, player->mo->scale)) + if (P_AproxDistance(P_AproxDistance(mo2->x - x, mo2->y - y), mo2->z - z) > FixedMul(128*FRACUNIT, player->mo->scale)) continue; // Yay! The thing's in reach! Pull it in! @@ -12020,7 +12020,7 @@ void P_PlayerThink(player_t *player) if (!currentlyonground) acceleration /= 2; // fake skidding! see P_SkidStuff for reference on conditionals - else if (!player->skidtime && !(player->mo->eflags & MFE_GOOWATER) && !(player->pflags & (PF_JUMPED|PF_SPINNING|PF_SLIDING)) && !(player->charflags & SF_NOSKID) && FixedHypot(player->mo->momx, player->mo->momy) >= FixedMul(player->runspeed, player->mo->scale)) // modified from player->runspeed/2 'cuz the skid was just TOO frequent ngl + else if (!player->skidtime && !(player->mo->eflags & MFE_GOOWATER) && !(player->pflags & (PF_JUMPED|PF_SPINNING|PF_SLIDING)) && !(player->charflags & SF_NOSKID) && P_AproxDistance(player->mo->momx, player->mo->momy) >= FixedMul(player->runspeed, player->mo->scale)) // modified from player->runspeed/2 'cuz the skid was just TOO frequent ngl { if (player->mo->state-states != S_PLAY_SKID) P_SetPlayerMobjState(player->mo, S_PLAY_SKID); @@ -12605,7 +12605,7 @@ void P_PlayerAfterThink(player_t *player) P_SetPlayerAngle(player, player->mo->angle); } - if (FixedHypot(player->mo->x - tails->x, player->mo->y - tails->y) > player->mo->radius) + if (P_AproxDistance(player->mo->x - tails->x, player->mo->y - tails->y) > player->mo->radius) player->powers[pw_carry] = CR_NONE; if (player->powers[pw_carry] != CR_NONE) @@ -12794,7 +12794,7 @@ void P_PlayerAfterThink(player_t *player) player->mo->momy = ptera->momy; player->mo->momz = ptera->momz; - if (FixedHypot(player->mo->x - ptera->x - ptera->watertop, player->mo->y - ptera->y - ptera->waterbottom) > player->mo->radius) + if (P_AproxDistance(player->mo->x - ptera->x - ptera->watertop, player->mo->y - ptera->y - ptera->waterbottom) > player->mo->radius) goto dropoff; ptera->watertop >>= 1; diff --git a/src/r_things.c b/src/r_things.c index 66c292b07..30bf15f85 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -3019,7 +3019,7 @@ boolean R_ThingVisibleWithinDist (mobj_t *thing, if (! R_ThingVisible(thing)) return false; - approx_dist = FixedHypot(viewx-thing->x, viewy-thing->y); + approx_dist = P_AproxDistance(viewx-thing->x, viewy-thing->y); if (thing->sprite == SPR_HOOP) { @@ -3044,7 +3044,7 @@ boolean R_PrecipThingVisible (precipmobj_t *precipthing, if (( precipthing->precipflags & PCF_INVISIBLE )) return false; - approx_dist = FixedHypot(viewx-precipthing->x, viewy-precipthing->y); + approx_dist = P_AproxDistance(viewx-precipthing->x, viewy-precipthing->y); return ( approx_dist <= limit_dist ); } diff --git a/src/s_sound.c b/src/s_sound.c index 0085dc342..392a5b453 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -943,8 +943,8 @@ void S_UpdateSounds(void) const mobj_t *soundmobj = c->origin; fixed_t dist1, dist2; - dist1 = FixedHypot(listener.x-soundmobj->x, listener.y-soundmobj->y); - dist2 = FixedHypot(listener2.x-soundmobj->x, listener2.y-soundmobj->y); + dist1 = P_AproxDistance(listener.x-soundmobj->x, listener.y-soundmobj->y); + dist2 = P_AproxDistance(listener2.x-soundmobj->x, listener2.y-soundmobj->y); if (dist1 <= dist2) { diff --git a/src/st_stuff.c b/src/st_stuff.c index 15d1af396..649644620 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -2458,7 +2458,7 @@ num: static INT32 ST_drawEmeraldHuntIcon(mobj_t *hunt, patch_t **patches, INT32 offset) { INT32 interval, i; - UINT32 dist = ((UINT32)FixedHypot(FixedHypot(stplyr->mo->x - hunt->x, stplyr->mo->y - hunt->y), stplyr->mo->z - hunt->z))>>FRACBITS; + UINT32 dist = ((UINT32)P_AproxDistance(P_AproxDistance(stplyr->mo->x - hunt->x, stplyr->mo->y - hunt->y), stplyr->mo->z - hunt->z))>>FRACBITS; if (dist < 128) { From d2d1f83b62de98a9f08f5197e9bed84306f12741 Mon Sep 17 00:00:00 2001 From: LJ Sonic Date: Sat, 13 Feb 2021 17:45:54 +0100 Subject: [PATCH 0576/1080] Revert "Use R_PointToDist2 instead" This reverts commit e19196a86e5347edf7f25b335214cede978b91b8. --- src/m_fixed.c | 40 ++++++++++++---------------------------- src/r_main.c | 24 +++++++++++++++++++++++- 2 files changed, 35 insertions(+), 29 deletions(-) diff --git a/src/m_fixed.c b/src/m_fixed.c index 09d6936f2..eb10fd5f8 100644 --- a/src/m_fixed.c +++ b/src/m_fixed.c @@ -18,10 +18,8 @@ #define HAVE_SQRTF #endif #endif - #include "doomdef.h" #include "m_fixed.h" -#include "tables.h" // ANGLETOFINESHIFT #ifdef __USE_C_FIXEDMUL__ @@ -107,34 +105,20 @@ fixed_t FixedSqrt(fixed_t x) fixed_t FixedHypot(fixed_t x, fixed_t y) { - // Moved the code from R_PointToDist2 to here, - // since R_PointToDist2 did the same thing, - // except less prone to overflowing. - - angle_t angle; - fixed_t dist; - - x = abs(x); - y = abs(y); - - if (y > x) + fixed_t ax, yx, yx2, yx1; + if (abs(y) > abs(x)) // |y|>|x| { - fixed_t temp; - - temp = x; - x = y; - y = temp; + ax = abs(y); // |y| => ax + yx = FixedDiv(x, y); // (x/y) } - - if (!y) - return x; - - angle = (tantoangle[FixedDiv(y, x)>>DBITS] + ANGLE_90) >> ANGLETOFINESHIFT; - - // use as cosine - dist = FixedDiv(x, FINESINE(angle)); - - return dist; + else // |x|>|y| + { + ax = abs(x); // |x| => ax + yx = FixedDiv(y, x); // (x/y) + } + yx2 = FixedMul(yx, yx); // (x/y)^2 + yx1 = FixedSqrt(1 * FRACUNIT + yx2); // (1 + (x/y)^2)^1/2 + return FixedMul(ax, yx1); // |x|*((1 + (x/y)^2)^1/2) } vector2_t *FV2_Load(vector2_t *vec, fixed_t x, fixed_t y) diff --git a/src/r_main.c b/src/r_main.c index f6c05e312..f82fb589e 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -357,7 +357,29 @@ angle_t R_PointToAngle2(fixed_t pviewx, fixed_t pviewy, fixed_t x, fixed_t y) fixed_t R_PointToDist2(fixed_t px2, fixed_t py2, fixed_t px1, fixed_t py1) { - return FixedHypot(px1 - px2, py1 - py2); + angle_t angle; + fixed_t dx, dy, dist; + + dx = abs(px1 - px2); + dy = abs(py1 - py2); + + if (dy > dx) + { + fixed_t temp; + + temp = dx; + dx = dy; + dy = temp; + } + if (!dy) + return dx; + + angle = (tantoangle[FixedDiv(dy, dx)>>DBITS] + ANGLE_90) >> ANGLETOFINESHIFT; + + // use as cosine + dist = FixedDiv(dx, FINESINE(angle)); + + return dist; } // Little extra utility. Works in the same way as R_PointToAngle2 From a58df577fe9579bc879de895aea0ef310d8750e1 Mon Sep 17 00:00:00 2001 From: LJ Sonic Date: Sat, 13 Feb 2021 17:46:29 +0100 Subject: [PATCH 0577/1080] Revert "Use FixedHypot over P_AproxDistance" This reverts commit c5474436af67408342e8dce0ec996d62c9a4c21c. --- src/lua_baselib.c | 3 +-- src/p_maputl.c | 13 +++++++++++++ src/p_maputl.h | 2 +- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 609d9c8b8..c5f847be6 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -432,8 +432,7 @@ static int lib_pAproxDistance(lua_State *L) fixed_t dx = luaL_checkfixed(L, 1); fixed_t dy = luaL_checkfixed(L, 2); //HUDSAFE - LUA_Deprecated(L, "P_AproxDistance", "FixedHypot"); - lua_pushfixed(L, FixedHypot(dx, dy)); + lua_pushfixed(L, P_AproxDistance(dx, dy)); return 1; } diff --git a/src/p_maputl.c b/src/p_maputl.c index 83905a418..90718a41c 100644 --- a/src/p_maputl.c +++ b/src/p_maputl.c @@ -24,6 +24,19 @@ #include "p_slopes.h" #include "z_zone.h" +// +// P_AproxDistance +// Gives an estimation of distance (not exact) +// +fixed_t P_AproxDistance(fixed_t dx, fixed_t dy) +{ + dx = abs(dx); + dy = abs(dy); + if (dx < dy) + return dx + dy - (dx>>1); + return dx + dy - (dy>>1); +} + // // P_ClosestPointOnLine // Finds the closest point on a given line to the supplied point diff --git a/src/p_maputl.h b/src/p_maputl.h index df90ab4b4..08b606833 100644 --- a/src/p_maputl.h +++ b/src/p_maputl.h @@ -41,7 +41,7 @@ typedef boolean (*traverser_t)(intercept_t *in); boolean P_PathTraverse(fixed_t px1, fixed_t py1, fixed_t px2, fixed_t py2, INT32 pflags, traverser_t ptrav); -#define P_AproxDistance(dx, dy) FixedHypot(dx, dy) +FUNCMATH fixed_t P_AproxDistance(fixed_t dx, fixed_t dy); void P_ClosestPointOnLine(fixed_t x, fixed_t y, line_t *line, vertex_t *result); void P_ClosestPointOnLine3D(const vector3_t *p, const vector3_t *line, vector3_t *result); INT32 P_PointOnLineSide(fixed_t x, fixed_t y, line_t *line); From 758de501da8c458cc3b8f06a376db1b3cb818316 Mon Sep 17 00:00:00 2001 From: LJ Sonic Date: Sat, 13 Feb 2021 18:04:12 +0100 Subject: [PATCH 0578/1080] Use R_PointToDist2 for the Lua versions of P_AproxDistance and FixedHypot --- src/lua_baselib.c | 2 +- src/lua_mathlib.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index c5f847be6..916fa9254 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -432,7 +432,7 @@ static int lib_pAproxDistance(lua_State *L) fixed_t dx = luaL_checkfixed(L, 1); fixed_t dy = luaL_checkfixed(L, 2); //HUDSAFE - lua_pushfixed(L, P_AproxDistance(dx, dy)); + lua_pushfixed(L, R_PointToDist2(0, 0, dx, dy)); return 1; } diff --git a/src/lua_mathlib.c b/src/lua_mathlib.c index 10ba42ee0..b6046ab53 100644 --- a/src/lua_mathlib.c +++ b/src/lua_mathlib.c @@ -15,6 +15,7 @@ #include "tables.h" #include "p_local.h" #include "doomstat.h" // for ALL7EMERALDS +#include "r_main.h" // for R_PointToDist2 #include "lua_script.h" #include "lua_libs.h" @@ -129,7 +130,7 @@ static int lib_fixedsqrt(lua_State *L) static int lib_fixedhypot(lua_State *L) { - lua_pushfixed(L, FixedHypot(luaL_checkfixed(L, 1), luaL_checkfixed(L, 2))); + lua_pushfixed(L, R_PointToDist2(0, 0, luaL_checkfixed(L, 1), luaL_checkfixed(L, 2))); return 1; } From 70850b083632d9b590cdaaf102be7ecf081be1ca Mon Sep 17 00:00:00 2001 From: LJ Sonic Date: Sat, 13 Feb 2021 18:04:27 +0100 Subject: [PATCH 0579/1080] Deprecate P_AproxDistance for Lua scripts --- src/lua_baselib.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 916fa9254..6e0116d12 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -432,6 +432,7 @@ static int lib_pAproxDistance(lua_State *L) fixed_t dx = luaL_checkfixed(L, 1); fixed_t dy = luaL_checkfixed(L, 2); //HUDSAFE + LUA_Deprecated(L, "P_AproxDistance", "FixedHypot"); lua_pushfixed(L, R_PointToDist2(0, 0, dx, dy)); return 1; } From cf389179e85536d05fa4545004477f784181adc1 Mon Sep 17 00:00:00 2001 From: lachwright Date: Mon, 15 Feb 2021 01:11:03 +1100 Subject: [PATCH 0580/1080] Rollout rock improvements: - No longer struggles to start to accelerating at certain angles - Carrying a player onto a rollout rock no longer leaves them in their ride state - Changed dispoffset might alleviate some sorting issues - Changes the player's camera angle when sprung horizontally - Works better in reverse gravity --- src/info.c | 2 +- src/p_enemy.c | 14 ++++++++++---- src/p_map.c | 7 +++++++ src/p_user.c | 9 ++++++--- 4 files changed, 24 insertions(+), 8 deletions(-) diff --git a/src/info.c b/src/info.c index ee836a372..6fbf71432 100644 --- a/src/info.c +++ b/src/info.c @@ -13481,7 +13481,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = 32*FRACUNIT, // speed 30*FRACUNIT, // radius 60*FRACUNIT, // height - 0, // display offset + -1, // display offset 100, // mass 0, // damage sfx_None, // activesound diff --git a/src/p_enemy.c b/src/p_enemy.c index 3e7f52a3f..294615b88 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -14319,6 +14319,14 @@ void A_RolloutRock(mobj_t *actor) if (LUA_CallAction(A_ROLLOUTROCK, actor)) return; + if (!actor->tracer || P_MobjWasRemoved(actor->tracer) || !actor->tracer->health) + actor->flags |= MF_PUSHABLE; + else + { + actor->flags2 = (actor->flags2 & ~MF2_OBJECTFLIP) | (actor->tracer->flags2 & MF2_OBJECTFLIP); + actor->eflags = (actor->eflags & ~MFE_VERTICALFLIP) | (actor->tracer->eflags & MFE_VERTICALFLIP); + } + actor->friction = FRACUNIT; // turns out riding on solids sucks, so let's just make it easier on ourselves if (actor->eflags & MFE_JUSTHITFLOOR) @@ -14357,7 +14365,8 @@ void A_RolloutRock(mobj_t *actor) speed = P_AproxDistance(actor->momx, actor->momy); // recalculate speed for visual rolling - if (speed < actor->scale >> 1) // stop moving if speed is insignificant + if (((actor->flags & MF_PUSHABLE) || !(actor->flags2 & MF2_STRONGBOX)) + && speed < actor->scale) // stop moving if speed is insignificant { actor->momx = 0; actor->momy = 0; @@ -14377,9 +14386,6 @@ void A_RolloutRock(mobj_t *actor) actor->frame = actor->reactiontime % maxframes; // set frame - if (!actor->tracer || P_MobjWasRemoved(actor->tracer) || !actor->tracer->health) - actor->flags |= MF_PUSHABLE; - if (!(actor->flags & MF_PUSHABLE) || (actor->movecount != 1)) // if being ridden or haven't moved, don't disappear actor->fuse = actor->info->painchance; else if (actor->fuse < 2*TICRATE) diff --git a/src/p_map.c b/src/p_map.c index a1cad524e..630d28200 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -429,6 +429,13 @@ boolean P_DoSpring(mobj_t *spring, mobj_t *object) else P_SetPlayerMobjState(object, S_PLAY_FALL); } + else if (horizspeed + && object->tracer + && object->tracer->player + && object->tracer->player->powers[pw_carry] != CR_NONE + && object->tracer->tracer == object + && (!demoplayback || P_ControlStyle(object->tracer->player) == CS_LMAOGALOG)) + P_SetPlayerAngle(object->tracer->player, spring->angle); object->standingslope = NULL; // And again. diff --git a/src/p_user.c b/src/p_user.c index a9e1fe9a2..ca1dfd478 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -12608,14 +12608,14 @@ void P_PlayerAfterThink(player_t *player) if (P_AproxDistance(player->mo->x - tails->x, player->mo->y - tails->y) > player->mo->radius) player->powers[pw_carry] = CR_NONE; - if (player->powers[pw_carry] != CR_NONE) + if (player->powers[pw_carry] == CR_PLAYER) { if (player->mo->state-states != S_PLAY_RIDE) P_SetPlayerMobjState(player->mo, S_PLAY_RIDE); if (tails->player && (tails->skin && ((skin_t *)(tails->skin))->sprites[SPR2_SWIM].numframes) && (tails->eflags & MFE_UNDERWATER)) tails->player->powers[pw_tailsfly] = 0; } - else + else if (player->powers[pw_carry] == CR_NONE) P_SetTarget(&player->mo->tracer, NULL); if (player-players == consoleplayer && botingame) @@ -12718,9 +12718,12 @@ void P_PlayerAfterThink(player_t *player) if (player->cmd.forwardmove || player->cmd.sidemove) { + rock->flags2 |= MF2_STRONGBOX; // signifies the rock should not slow to a halt rock->movedir = (player->cmd.angleturn << FRACBITS) + R_PointToAngle2(0, 0, player->cmd.forwardmove << FRACBITS, -player->cmd.sidemove << FRACBITS); P_Thrust(rock, rock->movedir, rock->scale >> 1); } + else + rock->flags2 &= ~MF2_STRONGBOX; mo->momx = rock->momx; mo->momy = rock->momy; @@ -12736,7 +12739,7 @@ void P_PlayerAfterThink(player_t *player) mo->tics = walktics; } - P_TeleportMove(player->mo, rock->x, rock->y, rock->z + rock->height); + P_TeleportMove(player->mo, rock->x, rock->y, rock->z + ((mo->eflags & MFE_VERTICALFLIP) ? -mo->height : rock->height)); break; } case CR_PTERABYTE: // being carried by a Pterabyte From 4430835a71430c73b5ca3f014babd6ff1778abd1 Mon Sep 17 00:00:00 2001 From: SMS Alfredo <65426124+SMS-Alfredo@users.noreply.github.com> Date: Sun, 14 Feb 2021 20:49:03 -0600 Subject: [PATCH 0581/1080] This might be dumb, but whatever --- src/lua_baselib.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 6e0116d12..916fa9254 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -432,7 +432,6 @@ static int lib_pAproxDistance(lua_State *L) fixed_t dx = luaL_checkfixed(L, 1); fixed_t dy = luaL_checkfixed(L, 2); //HUDSAFE - LUA_Deprecated(L, "P_AproxDistance", "FixedHypot"); lua_pushfixed(L, R_PointToDist2(0, 0, dx, dy)); return 1; } From b369243bebf5db2d2f1cc270d2716e8a73750073 Mon Sep 17 00:00:00 2001 From: LJ Sonic Date: Mon, 15 Feb 2021 13:37:25 +0100 Subject: [PATCH 0582/1080] Use standard Lua naming scheme for polyobject list --- src/lua_polyobjlib.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lua_polyobjlib.c b/src/lua_polyobjlib.c index 365d97056..2a5bcfbf1 100644 --- a/src/lua_polyobjlib.c +++ b/src/lua_polyobjlib.c @@ -417,7 +417,7 @@ static int lib_getPolyObject(lua_State *L) { i = luaL_checkinteger(L, 2); if (i < 0 || i >= numPolyObjects) - return luaL_error(L, "PolyObjects[] index %d out of range (0 - %d)", i, numPolyObjects-1); + return luaL_error(L, "polyobjects[] index %d out of range (0 - %d)", i, numPolyObjects-1); LUA_PushUserdata(L, &PolyObjects[i], META_POLYOBJ); return 1; } @@ -481,6 +481,6 @@ int LUA_PolyObjLib(lua_State *L) lua_pushcfunction(L, lib_numPolyObjects); lua_setfield(L, -2, "__len"); lua_setmetatable(L, -2); - lua_setglobal(L, "PolyObjects"); + lua_setglobal(L, "polyobjects"); return 0; } From 0b012d5db0bd5f3d6b904bbed4f585fde61ce582 Mon Sep 17 00:00:00 2001 From: LJ Sonic Date: Mon, 15 Feb 2021 16:21:26 +0100 Subject: [PATCH 0583/1080] Make the names of disconnected players flicker in tab HUD --- src/hu_stuff.c | 45 +++++++++++++++++++++++++-------------------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 0b24d0690..1e69e6d51 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -2307,10 +2307,11 @@ void HU_DrawTabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scorelines, I // V_DrawSmallString(x+ 246, y+4, V_YELLOWMAP, "SERVER"); } - V_DrawString(x + 20, y, - ((tab[i].num == whiteplayer) ? V_YELLOWMAP : 0) - | (greycheck ? V_60TRANS : 0) - | V_ALLOWLOWERCASE, tab[i].name); + if (!players[tab[i].num].quittime || (leveltime / (TICRATE/2) & 1)) + V_DrawString(x + 20, y, + ((tab[i].num == whiteplayer) ? V_YELLOWMAP : 0) + | (greycheck ? V_60TRANS : 0) + | V_ALLOWLOWERCASE, tab[i].name); // Draw emeralds if (players[tab[i].num].powers[pw_invulnerability] && (players[tab[i].num].powers[pw_invulnerability] == players[tab[i].num].powers[pw_sneakers]) && ((leveltime/7) & 1)) @@ -2458,10 +2459,11 @@ static void HU_Draw32TeamTabRankings(playersort_t *tab, INT32 whiteplayer) supercheck = supercheckdef; strlcpy(name, tab[i].name, 8); - V_DrawString(x + 10, y, - ((tab[i].num == whiteplayer) ? V_YELLOWMAP : 0) - | (greycheck ? 0 : V_TRANSLUCENT) - | V_ALLOWLOWERCASE, name); + if (!players[tab[i].num].quittime || (leveltime / (TICRATE/2) & 1)) + V_DrawString(x + 10, y, + ((tab[i].num == whiteplayer) ? V_YELLOWMAP : 0) + | (greycheck ? 0 : V_TRANSLUCENT) + | V_ALLOWLOWERCASE, name); if (gametyperules & GTR_TEAMFLAGS) { @@ -2586,10 +2588,11 @@ void HU_DrawTeamTabRankings(playersort_t *tab, INT32 whiteplayer) supercheck = supercheckdef; strlcpy(name, tab[i].name, 7); - V_DrawString(x + 20, y, - ((tab[i].num == whiteplayer) ? V_YELLOWMAP : 0) - | (greycheck ? V_TRANSLUCENT : 0) - | V_ALLOWLOWERCASE, name); + if (!players[tab[i].num].quittime || (leveltime / (TICRATE/2) & 1)) + V_DrawString(x + 20, y, + ((tab[i].num == whiteplayer) ? V_YELLOWMAP : 0) + | (greycheck ? V_TRANSLUCENT : 0) + | V_ALLOWLOWERCASE, name); if (gametyperules & GTR_TEAMFLAGS) { @@ -2660,10 +2663,11 @@ void HU_DrawDualTabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scoreline //else // V_DrawSmallString(x+ 94, y+4, V_YELLOWMAP, "SERVER"); - V_DrawString(x + 20, y, - ((tab[i].num == whiteplayer) ? V_YELLOWMAP : 0) - | (greycheck ? V_TRANSLUCENT : 0) - | V_ALLOWLOWERCASE, name); + if (!players[tab[i].num].quittime || (leveltime / (TICRATE/2) & 1)) + V_DrawString(x + 20, y, + ((tab[i].num == whiteplayer) ? V_YELLOWMAP : 0) + | (greycheck ? V_TRANSLUCENT : 0) + | V_ALLOWLOWERCASE, name); if (G_GametypeUsesLives() && !(G_GametypeUsesCoopLives() && (cv_cooplives.value == 0 || cv_cooplives.value == 3)) && (players[tab[i].num].lives != INFLIVES)) //show lives V_DrawRightAlignedString(x, y+4, V_ALLOWLOWERCASE, va("%dx", players[tab[i].num].lives)); @@ -2769,10 +2773,11 @@ static void HU_Draw32TabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scor // V_DrawSmallString(x+ 129, y+4, V_YELLOWMAP, "HOST"); } - V_DrawString(x + 10, y, - ((tab[i].num == whiteplayer) ? V_YELLOWMAP : 0) - | (greycheck ? 0 : V_TRANSLUCENT) - | V_ALLOWLOWERCASE, name); + if (!players[tab[i].num].quittime || (leveltime / (TICRATE/2) & 1)) + V_DrawString(x + 10, y, + ((tab[i].num == whiteplayer) ? V_YELLOWMAP : 0) + | (greycheck ? 0 : V_TRANSLUCENT) + | V_ALLOWLOWERCASE, name); if (G_GametypeUsesLives()) //show lives V_DrawRightAlignedThinString(x-1, y, V_ALLOWLOWERCASE, va("%d", players[tab[i].num].lives)); From aa33d90215c058e0f19621661d4ae10391b583eb Mon Sep 17 00:00:00 2001 From: LJ Sonic Date: Mon, 15 Feb 2021 16:23:57 +0100 Subject: [PATCH 0584/1080] Add rejointimeout to the server options --- src/m_menu.c | 69 ++++++++++++++++++++++++++-------------------------- 1 file changed, 35 insertions(+), 34 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index 05c819c37..516bd34c1 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1612,53 +1612,54 @@ static menuitem_t OP_ServerOptionsMenu[] = {IT_STRING | IT_CVAR, NULL, "Max Players", &cv_maxplayers, 21}, {IT_STRING | IT_CVAR, NULL, "Allow Add-on Downloading", &cv_downloading, 26}, {IT_STRING | IT_CVAR, NULL, "Allow players to join", &cv_allownewplayer, 31}, + {IT_STRING | IT_CVAR, NULL, "Minutes for reconnecting", &cv_rejointimeout, 36}, #endif - {IT_STRING | IT_CVAR, NULL, "Map progression", &cv_advancemap, 36}, - {IT_STRING | IT_CVAR, NULL, "Intermission Timer", &cv_inttime, 41}, + {IT_STRING | IT_CVAR, NULL, "Map progression", &cv_advancemap, 41}, + {IT_STRING | IT_CVAR, NULL, "Intermission Timer", &cv_inttime, 46}, - {IT_HEADER, NULL, "Characters", NULL, 50}, - {IT_STRING | IT_CVAR, NULL, "Force a character", &cv_forceskin, 56}, - {IT_STRING | IT_CVAR, NULL, "Restrict character changes", &cv_restrictskinchange, 61}, + {IT_HEADER, NULL, "Characters", NULL, 55}, + {IT_STRING | IT_CVAR, NULL, "Force a character", &cv_forceskin, 61}, + {IT_STRING | IT_CVAR, NULL, "Restrict character changes", &cv_restrictskinchange, 66}, - {IT_HEADER, NULL, "Items", NULL, 70}, - {IT_STRING | IT_CVAR, NULL, "Item respawn delay", &cv_itemrespawntime, 76}, - {IT_STRING | IT_SUBMENU, NULL, "Mystery Item Monitor Toggles...", &OP_MonitorToggleDef, 81}, + {IT_HEADER, NULL, "Items", NULL, 75}, + {IT_STRING | IT_CVAR, NULL, "Item respawn delay", &cv_itemrespawntime, 81}, + {IT_STRING | IT_SUBMENU, NULL, "Mystery Item Monitor Toggles...", &OP_MonitorToggleDef, 86}, - {IT_HEADER, NULL, "Cooperative", NULL, 90}, - {IT_STRING | IT_CVAR, NULL, "Players required for exit", &cv_playersforexit, 96}, - {IT_STRING | IT_CVAR, NULL, "Starposts", &cv_coopstarposts, 101}, - {IT_STRING | IT_CVAR, NULL, "Life sharing", &cv_cooplives, 106}, - {IT_STRING | IT_CVAR, NULL, "Post-goal free roaming", &cv_exitmove, 111}, + {IT_HEADER, NULL, "Cooperative", NULL, 95}, + {IT_STRING | IT_CVAR, NULL, "Players required for exit", &cv_playersforexit, 101}, + {IT_STRING | IT_CVAR, NULL, "Starposts", &cv_coopstarposts, 106}, + {IT_STRING | IT_CVAR, NULL, "Life sharing", &cv_cooplives, 111}, + {IT_STRING | IT_CVAR, NULL, "Post-goal free roaming", &cv_exitmove, 116}, - {IT_HEADER, NULL, "Race, Competition", NULL, 120}, - {IT_STRING | IT_CVAR, NULL, "Level completion countdown", &cv_countdowntime, 126}, - {IT_STRING | IT_CVAR, NULL, "Item Monitors", &cv_competitionboxes, 131}, + {IT_HEADER, NULL, "Race, Competition", NULL, 125}, + {IT_STRING | IT_CVAR, NULL, "Level completion countdown", &cv_countdowntime, 131}, + {IT_STRING | IT_CVAR, NULL, "Item Monitors", &cv_competitionboxes, 136}, - {IT_HEADER, NULL, "Ringslinger (Match, CTF, Tag, H&S)", NULL, 140}, - {IT_STRING | IT_CVAR, NULL, "Time Limit", &cv_timelimit, 146}, - {IT_STRING | IT_CVAR, NULL, "Score Limit", &cv_pointlimit, 151}, - {IT_STRING | IT_CVAR, NULL, "Overtime on Tie", &cv_overtime, 156}, - {IT_STRING | IT_CVAR, NULL, "Player respawn delay", &cv_respawntime, 161}, + {IT_HEADER, NULL, "Ringslinger (Match, CTF, Tag, H&S)", NULL, 145}, + {IT_STRING | IT_CVAR, NULL, "Time Limit", &cv_timelimit, 151}, + {IT_STRING | IT_CVAR, NULL, "Score Limit", &cv_pointlimit, 156}, + {IT_STRING | IT_CVAR, NULL, "Overtime on Tie", &cv_overtime, 161}, + {IT_STRING | IT_CVAR, NULL, "Player respawn delay", &cv_respawntime, 166}, - {IT_STRING | IT_CVAR, NULL, "Item Monitors", &cv_matchboxes, 171}, - {IT_STRING | IT_CVAR, NULL, "Weapon Rings", &cv_specialrings, 176}, - {IT_STRING | IT_CVAR, NULL, "Power Stones", &cv_powerstones, 181}, + {IT_STRING | IT_CVAR, NULL, "Item Monitors", &cv_matchboxes, 176}, + {IT_STRING | IT_CVAR, NULL, "Weapon Rings", &cv_specialrings, 181}, + {IT_STRING | IT_CVAR, NULL, "Power Stones", &cv_powerstones, 186}, - {IT_STRING | IT_CVAR, NULL, "Flag respawn delay", &cv_flagtime, 191}, - {IT_STRING | IT_CVAR, NULL, "Hiding time", &cv_hidetime, 196}, + {IT_STRING | IT_CVAR, NULL, "Flag respawn delay", &cv_flagtime, 196}, + {IT_STRING | IT_CVAR, NULL, "Hiding time", &cv_hidetime, 201}, - {IT_HEADER, NULL, "Teams", NULL, 205}, - {IT_STRING | IT_CVAR, NULL, "Autobalance sizes", &cv_autobalance, 211}, - {IT_STRING | IT_CVAR, NULL, "Scramble on Map Change", &cv_scrambleonchange, 216}, + {IT_HEADER, NULL, "Teams", NULL, 210}, + {IT_STRING | IT_CVAR, NULL, "Autobalance sizes", &cv_autobalance, 216}, + {IT_STRING | IT_CVAR, NULL, "Scramble on Map Change", &cv_scrambleonchange, 221}, #ifndef NONET - {IT_HEADER, NULL, "Advanced", NULL, 225}, - {IT_STRING | IT_CVAR | IT_CV_STRING, NULL, "Master server", &cv_masterserver, 231}, + {IT_HEADER, NULL, "Advanced", NULL, 230}, + {IT_STRING | IT_CVAR | IT_CV_STRING, NULL, "Master server", &cv_masterserver, 236}, - {IT_STRING | IT_CVAR, NULL, "Join delay", &cv_joindelay, 246}, - {IT_STRING | IT_CVAR, NULL, "Attempts to resynchronise", &cv_resynchattempts, 251}, + {IT_STRING | IT_CVAR, NULL, "Join delay", &cv_joindelay, 251}, + {IT_STRING | IT_CVAR, NULL, "Attempts to resynchronise", &cv_resynchattempts, 256}, - {IT_STRING | IT_CVAR, NULL, "Show IP Address of Joiners", &cv_showjoinaddress, 256}, + {IT_STRING | IT_CVAR, NULL, "Show IP Address of Joiners", &cv_showjoinaddress, 261}, #endif }; From 97daba68d0beb57622f996c6086d15355175ae22 Mon Sep 17 00:00:00 2001 From: LJ Sonic Date: Mon, 15 Feb 2021 16:24:30 +0100 Subject: [PATCH 0585/1080] Enable rejointimeout by default --- 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 4fdc7e7ee..02577b508 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -3112,7 +3112,7 @@ consvar_t cv_maxplayers = CVAR_INIT ("maxplayers", "8", CV_SAVE|CV_NETVAR, maxpl static CV_PossibleValue_t joindelay_cons_t[] = {{1, "MIN"}, {3600, "MAX"}, {0, "Off"}, {0, NULL}}; consvar_t cv_joindelay = CVAR_INIT ("joindelay", "10", CV_SAVE|CV_NETVAR, joindelay_cons_t, NULL); static CV_PossibleValue_t rejointimeout_cons_t[] = {{1, "MIN"}, {60 * FRACUNIT, "MAX"}, {0, "Off"}, {0, NULL}}; -consvar_t cv_rejointimeout = CVAR_INIT ("rejointimeout", "Off", CV_SAVE|CV_NETVAR|CV_FLOAT, rejointimeout_cons_t, NULL); +consvar_t cv_rejointimeout = CVAR_INIT ("rejointimeout", "2", CV_SAVE|CV_NETVAR|CV_FLOAT, rejointimeout_cons_t, NULL); static CV_PossibleValue_t resynchattempts_cons_t[] = {{1, "MIN"}, {20, "MAX"}, {0, "No"}, {0, NULL}}; consvar_t cv_resynchattempts = CVAR_INIT ("resynchattempts", "10", CV_SAVE|CV_NETVAR, resynchattempts_cons_t, NULL); From 7133c703b4c6a6cada6ee47f8c8fad9ee768f099 Mon Sep 17 00:00:00 2001 From: LJ Sonic Date: Mon, 15 Feb 2021 22:19:48 +0100 Subject: [PATCH 0586/1080] Show an alternate ping icon when the player is disconnected --- src/hu_stuff.c | 50 ++++++++++++++++++++++++++++++-------------------- 1 file changed, 30 insertions(+), 20 deletions(-) diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 1e69e6d51..7c4f1acf1 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -98,6 +98,7 @@ patch_t *emeraldpics[3][8]; // 0 = normal, 1 = tiny, 2 = coinbox static patch_t *emblemicon; patch_t *tokenicon; static patch_t *exiticon; +static patch_t *nopingicon; //------------------------------------------- // misc vars @@ -286,6 +287,7 @@ void HU_LoadGraphics(void) emblemicon = W_CachePatchName("EMBLICON", PU_HUDGFX); tokenicon = W_CachePatchName("TOKNICON", PU_HUDGFX); exiticon = W_CachePatchName("EXITICON", PU_HUDGFX); + nopingicon = W_CachePatchName("NOPINGICON", PU_HUDGFX); emeraldpics[0][0] = W_CachePatchName("CHAOS1", PU_HUDGFX); emeraldpics[0][1] = W_CachePatchName("CHAOS2", PU_HUDGFX); @@ -2246,8 +2248,8 @@ void HU_Erase(void) // void HU_drawPing(INT32 x, INT32 y, UINT32 ping, boolean notext, INT32 flags) { - UINT8 numbars = 1; // how many ping bars do we draw? - UINT8 barcolor = 35; // color we use for the bars (green, yellow or red) + UINT8 numbars = 0; // how many ping bars do we draw? + UINT8 barcolor = 31; // color we use for the bars (green, yellow, red or black) SINT8 i = 0; SINT8 yoffset = 6; INT32 dx = x+1 - (V_SmallStringWidth(va("%dms", ping), @@ -2260,11 +2262,16 @@ void HU_drawPing(INT32 x, INT32 y, UINT32 ping, boolean notext, INT32 flags) } else if (ping < 256) { - numbars = 2; // Apparently ternaries w/ multiple statements don't look good in C so I decided against it. + numbars = 2; barcolor = 73; } + else if (ping < UINT32_MAX) + { + numbars = 1; + barcolor = 35; + } - if (!notext || vid.width >= 640) // how sad, we're using a shit resolution. + if (ping < UINT32_MAX && (!notext || vid.width >= 640)) // how sad, we're using a shit resolution. V_DrawSmallString(dx, y+4, V_ALLOWLOWERCASE|flags, va("%dms", ping)); for (i=0; (i<3); i++) // Draw the ping bar @@ -2275,6 +2282,9 @@ void HU_drawPing(INT32 x, INT32 y, UINT32 ping, boolean notext, INT32 flags) yoffset -= 2; } + + if (ping == UINT32_MAX) + V_DrawSmallScaledPatch(x + 4 - nopingicon->width/2, y + 9 - nopingicon->height/2, 0, nopingicon); } // @@ -2301,8 +2311,8 @@ void HU_DrawTabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scorelines, I if (!splitscreen) // don't draw it on splitscreen, { - if (!(tab[i].num == serverplayer || players[tab[i].num].quittime)) - HU_drawPing(x+ 253, y, playerpingtable[tab[i].num], false, 0); + if (tab[i].num != serverplayer) + HU_drawPing(x + 253, y, players[tab[i].num].quittime ? UINT32_MAX : playerpingtable[tab[i].num], false, 0); //else // V_DrawSmallString(x+ 246, y+4, V_YELLOWMAP, "SERVER"); } @@ -2502,10 +2512,10 @@ static void HU_Draw32TeamTabRankings(playersort_t *tab, INT32 whiteplayer) V_DrawRightAlignedThinString(x+128, y, ((players[tab[i].num].spectator || players[tab[i].num].playerstate == PST_DEAD) ? 0 : V_TRANSLUCENT), va("%u", tab[i].count)); if (!splitscreen) { - if (!(tab[i].num == serverplayer || players[tab[i].num].quittime)) - HU_drawPing(x+ 135, y+1, playerpingtable[tab[i].num], true, 0); - //else - //V_DrawSmallString(x+ 129, y+4, V_YELLOWMAP, "HOST"); + if (tab[i].num != serverplayer) + HU_drawPing(x + 135, y+1, players[tab[i].num].quittime ? UINT32_MAX : playerpingtable[tab[i].num], true, 0); + //else + //V_DrawSmallString(x+ 129, y+4, V_YELLOWMAP, "HOST"); } } } @@ -2627,10 +2637,10 @@ void HU_DrawTeamTabRankings(playersort_t *tab, INT32 whiteplayer) V_DrawRightAlignedThinString(x+100, y, (greycheck ? V_TRANSLUCENT : 0), va("%u", tab[i].count)); if (!splitscreen) { - if (!(tab[i].num == serverplayer || players[tab[i].num].quittime)) - HU_drawPing(x+ 113, y, playerpingtable[tab[i].num], false, 0); - //else - // V_DrawSmallString(x+ 94, y+4, V_YELLOWMAP, "SERVER"); + if (tab[i].num != serverplayer) + HU_drawPing(x+ 113, y, players[tab[i].num].quittime ? UINT32_MAX : playerpingtable[tab[i].num], false, 0); + //else + // V_DrawSmallString(x+ 94, y+4, V_YELLOWMAP, "SERVER"); } } } @@ -2658,8 +2668,8 @@ void HU_DrawDualTabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scoreline supercheck = supercheckdef; strlcpy(name, tab[i].name, 7); - if (!(tab[i].num == serverplayer || players[tab[i].num].quittime)) - HU_drawPing(x+ 113, y, playerpingtable[tab[i].num], false, 0); + if (tab[i].num != serverplayer) + HU_drawPing(x+ 113, y, players[tab[i].num].quittime ? UINT32_MAX : playerpingtable[tab[i].num], false, 0); //else // V_DrawSmallString(x+ 94, y+4, V_YELLOWMAP, "SERVER"); @@ -2767,10 +2777,10 @@ static void HU_Draw32TabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scor strlcpy(name, tab[i].name, 7); if (!splitscreen) // don't draw it on splitscreen, { - if (!(tab[i].num == serverplayer || players[tab[i].num].quittime)) - HU_drawPing(x+ 135, y+1, playerpingtable[tab[i].num], true, 0); - //else - // V_DrawSmallString(x+ 129, y+4, V_YELLOWMAP, "HOST"); + if (tab[i].num != serverplayer) + HU_drawPing(x+ 135, y+1, players[tab[i].num].quittime ? UINT32_MAX : playerpingtable[tab[i].num], true, 0); + //else + // V_DrawSmallString(x+ 129, y+4, V_YELLOWMAP, "HOST"); } if (!players[tab[i].num].quittime || (leveltime / (TICRATE/2) & 1)) From 205ccc2727a2c755d9e44dcd662cd8d4d1b6db68 Mon Sep 17 00:00:00 2001 From: "X.organic" Date: Tue, 16 Feb 2021 19:46:31 +0100 Subject: [PATCH 0587/1080] Move Dehacked table sanity check to deh_tables.c --- src/d_main.c | 2 +- src/deh_tables.c | 24 ++++++++++++++++++++++++ src/deh_tables.h | 3 +++ src/dehacked.c | 22 ---------------------- src/dehacked.h | 2 -- 5 files changed, 28 insertions(+), 25 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index a89f4ed2d..409a66bec 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -1072,7 +1072,7 @@ void D_SRB2Main(void) G_LoadGameSettings(); // Test Dehacked lists - DEH_Check(); + DEH_TableCheck(); // Netgame URL special case: change working dir to EXE folder. ChangeDirForUrlHandler(); diff --git a/src/deh_tables.c b/src/deh_tables.c index 3039bf7de..dd6d7d69f 100644 --- a/src/deh_tables.c +++ b/src/deh_tables.c @@ -5457,3 +5457,27 @@ struct int_const_s const INT_CONST[] = { {NULL,0} }; + +// For this to work compile-time without being in this file, +// this function would need to check sizes at runtime, without sizeof +void DEH_TableCheck(void) +{ +#if defined(_DEBUG) || defined(PARANOIA) + const size_t dehstates = sizeof(STATE_LIST)/sizeof(const char*); + const size_t dehmobjs = sizeof(MOBJTYPE_LIST)/sizeof(const char*); + const size_t dehpowers = sizeof(POWERS_LIST)/sizeof(const char*); + const size_t dehcolors = sizeof(COLOR_ENUMS)/sizeof(const char*); + + if (dehstates != S_FIRSTFREESLOT) + I_Error("You forgot to update the Dehacked states list, you dolt!\n(%d states defined, versus %s in the Dehacked list)\n", S_FIRSTFREESLOT, sizeu1(dehstates)); + + if (dehmobjs != MT_FIRSTFREESLOT) + I_Error("You forgot to update the Dehacked mobjtype list, you dolt!\n(%d mobj types defined, versus %s in the Dehacked list)\n", MT_FIRSTFREESLOT, sizeu1(dehmobjs)); + + if (dehpowers != NUMPOWERS) + I_Error("You forgot to update the Dehacked powers list, you dolt!\n(%d powers defined, versus %s in the Dehacked list)\n", NUMPOWERS, sizeu1(dehpowers)); + + if (dehcolors != SKINCOLOR_FIRSTFREESLOT) + I_Error("You forgot to update the Dehacked colors list, you dolt!\n(%d colors defined, versus %s in the Dehacked list)\n", SKINCOLOR_FIRSTFREESLOT, sizeu1(dehcolors)); +#endif +} diff --git a/src/deh_tables.h b/src/deh_tables.h index 2c6b3e204..d094bcbad 100644 --- a/src/deh_tables.h +++ b/src/deh_tables.h @@ -72,4 +72,7 @@ extern const char *const MENUTYPES_LIST[]; extern struct int_const_s const INT_CONST[]; +// Moved to this file because it can't work compile-time otherwise +void DEH_TableCheck(void); + #endif diff --git a/src/dehacked.c b/src/dehacked.c index b42663267..c2ea28d27 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -645,25 +645,3 @@ void DEH_LoadDehackedLump(lumpnum_t lumpnum) { DEH_LoadDehackedLumpPwad(WADFILENUM(lumpnum),LUMPNUM(lumpnum), false); } - -void DEH_Check(void) -{ -#if defined(_DEBUG) || defined(PARANOIA) - const size_t dehstates = sizeof(STATE_LIST)/sizeof(const char*); - const size_t dehmobjs = sizeof(MOBJTYPE_LIST)/sizeof(const char*); - const size_t dehpowers = sizeof(POWERS_LIST)/sizeof(const char*); - const size_t dehcolors = sizeof(COLOR_ENUMS)/sizeof(const char*); - - if (dehstates != S_FIRSTFREESLOT) - I_Error("You forgot to update the Dehacked states list, you dolt!\n(%d states defined, versus %s in the Dehacked list)\n", S_FIRSTFREESLOT, sizeu1(dehstates)); - - if (dehmobjs != MT_FIRSTFREESLOT) - I_Error("You forgot to update the Dehacked mobjtype list, you dolt!\n(%d mobj types defined, versus %s in the Dehacked list)\n", MT_FIRSTFREESLOT, sizeu1(dehmobjs)); - - if (dehpowers != NUMPOWERS) - I_Error("You forgot to update the Dehacked powers list, you dolt!\n(%d powers defined, versus %s in the Dehacked list)\n", NUMPOWERS, sizeu1(dehpowers)); - - if (dehcolors != SKINCOLOR_FIRSTFREESLOT) - I_Error("You forgot to update the Dehacked colors list, you dolt!\n(%d colors defined, versus %s in the Dehacked list)\n", SKINCOLOR_FIRSTFREESLOT, sizeu1(dehcolors)); -#endif -} diff --git a/src/dehacked.h b/src/dehacked.h index d5256be23..1620314ca 100644 --- a/src/dehacked.h +++ b/src/dehacked.h @@ -30,8 +30,6 @@ typedef enum void DEH_LoadDehackedLump(lumpnum_t lumpnum); void DEH_LoadDehackedLumpPwad(UINT16 wad, UINT16 lump, boolean mainfile); -void DEH_Check(void); - fixed_t get_number(const char *word); FUNCPRINTF void deh_warning(const char *first, ...); void deh_strlcpy(char *dst, const char *src, size_t size, const char *warntext); From 90611ed547044d6902ad61008a8eca2be393074e Mon Sep 17 00:00:00 2001 From: "X.organic" Date: Tue, 16 Feb 2021 21:36:28 +0100 Subject: [PATCH 0588/1080] Fix MOBJCONSISTANCY and make it optional in DEBUGMODE MOBJCONSISTANCY checks confined to gamestate GS_LEVEL. DEBUGMODE no longer implicitly enables them, making it netgame-compatible. --- src/Makefile | 2 +- src/d_clisrv.c | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Makefile b/src/Makefile index 1314161bd..67560caf6 100644 --- a/src/Makefile +++ b/src/Makefile @@ -415,7 +415,7 @@ ifdef GCC48 else CFLAGS+=-O0 endif - CFLAGS+= -Wall -DPARANOIA -DRANGECHECK -DPACKETDROP -DMOBJCONSISTANCY + CFLAGS+= -Wall -DPARANOIA -DRANGECHECK -DPACKETDROP else diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 02577b508..1b6b4cd1f 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -4480,6 +4480,7 @@ static INT16 Consistancy(void) ret += P_GetRandSeed(); #ifdef MOBJCONSISTANCY +if (gamestate == GS_LEVEL) { for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next) { if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) @@ -4546,6 +4547,7 @@ static INT16 Consistancy(void) ret += mo->frame; } } +} #endif DEBFILE(va("Consistancy = %u\n", (ret & 0xFFFF))); From 0cbf9a791b883e7a819aceaa4a0a7e330dccdb15 Mon Sep 17 00:00:00 2001 From: "X.organic" Date: Tue, 16 Feb 2021 23:27:44 +0100 Subject: [PATCH 0589/1080] Fix indentation in MOBJCONSISTANCY conditional --- src/d_clisrv.c | 125 +++++++++++++++++++++++++------------------------ 1 file changed, 63 insertions(+), 62 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 1b6b4cd1f..7c2dec6a1 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -4480,74 +4480,75 @@ static INT16 Consistancy(void) ret += P_GetRandSeed(); #ifdef MOBJCONSISTANCY -if (gamestate == GS_LEVEL) { - for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next) + if (gamestate == GS_LEVEL) { - if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) - continue; - - mo = (mobj_t *)th; - - if (mo->flags & (MF_SPECIAL | MF_SOLID | MF_PUSHABLE | MF_BOSS | MF_MISSILE | MF_SPRING | MF_MONITOR | MF_FIRE | MF_ENEMY | MF_PAIN | MF_STICKY)) + for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next) { - ret -= mo->type; - ret += mo->x; - ret -= mo->y; - ret += mo->z; - ret -= mo->momx; - ret += mo->momy; - ret -= mo->momz; - ret += mo->angle; - ret -= mo->flags; - ret += mo->flags2; - ret -= mo->eflags; - if (mo->target) + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) + continue; + + mo = (mobj_t *)th; + + if (mo->flags & (MF_SPECIAL | MF_SOLID | MF_PUSHABLE | MF_BOSS | MF_MISSILE | MF_SPRING | MF_MONITOR | MF_FIRE | MF_ENEMY | MF_PAIN | MF_STICKY)) { - ret += mo->target->type; - ret -= mo->target->x; - ret += mo->target->y; - ret -= mo->target->z; - ret += mo->target->momx; - ret -= mo->target->momy; - ret += mo->target->momz; - ret -= mo->target->angle; - ret += mo->target->flags; - ret -= mo->target->flags2; - ret += mo->target->eflags; - ret -= mo->target->state - states; - ret += mo->target->tics; - ret -= mo->target->sprite; - ret += mo->target->frame; + ret -= mo->type; + ret += mo->x; + ret -= mo->y; + ret += mo->z; + ret -= mo->momx; + ret += mo->momy; + ret -= mo->momz; + ret += mo->angle; + ret -= mo->flags; + ret += mo->flags2; + ret -= mo->eflags; + if (mo->target) + { + ret += mo->target->type; + ret -= mo->target->x; + ret += mo->target->y; + ret -= mo->target->z; + ret += mo->target->momx; + ret -= mo->target->momy; + ret += mo->target->momz; + ret -= mo->target->angle; + ret += mo->target->flags; + ret -= mo->target->flags2; + ret += mo->target->eflags; + ret -= mo->target->state - states; + ret += mo->target->tics; + ret -= mo->target->sprite; + ret += mo->target->frame; + } + else + ret ^= 0x3333; + if (mo->tracer && mo->tracer->type != MT_OVERLAY) + { + ret += mo->tracer->type; + ret -= mo->tracer->x; + ret += mo->tracer->y; + ret -= mo->tracer->z; + ret += mo->tracer->momx; + ret -= mo->tracer->momy; + ret += mo->tracer->momz; + ret -= mo->tracer->angle; + ret += mo->tracer->flags; + ret -= mo->tracer->flags2; + ret += mo->tracer->eflags; + ret -= mo->tracer->state - states; + ret += mo->tracer->tics; + ret -= mo->tracer->sprite; + ret += mo->tracer->frame; + } + else + ret ^= 0xAAAA; + ret -= mo->state - states; + ret += mo->tics; + ret -= mo->sprite; + ret += mo->frame; } - else - ret ^= 0x3333; - if (mo->tracer && mo->tracer->type != MT_OVERLAY) - { - ret += mo->tracer->type; - ret -= mo->tracer->x; - ret += mo->tracer->y; - ret -= mo->tracer->z; - ret += mo->tracer->momx; - ret -= mo->tracer->momy; - ret += mo->tracer->momz; - ret -= mo->tracer->angle; - ret += mo->tracer->flags; - ret -= mo->tracer->flags2; - ret += mo->tracer->eflags; - ret -= mo->tracer->state - states; - ret += mo->tracer->tics; - ret -= mo->tracer->sprite; - ret += mo->tracer->frame; - } - else - ret ^= 0xAAAA; - ret -= mo->state - states; - ret += mo->tics; - ret -= mo->sprite; - ret += mo->frame; } } -} #endif DEBFILE(va("Consistancy = %u\n", (ret & 0xFFFF))); From 998d06569880aa79e310484d7baa7fdd638d9083 Mon Sep 17 00:00:00 2001 From: sphere Date: Wed, 17 Feb 2021 16:06:02 +0100 Subject: [PATCH 0590/1080] Add more actions for slope copying & update the ZB config. --- extras/conf/SRB2-22.cfg | 78 +++++++++++++++++++++++++++++++++++++++++ src/p_setup.c | 28 +++++++++++++++ 2 files changed, 106 insertions(+) diff --git a/extras/conf/SRB2-22.cfg b/extras/conf/SRB2-22.cfg index a0d40cdf0..b7ba56ba7 100644 --- a/extras/conf/SRB2-22.cfg +++ b/extras/conf/SRB2-22.cfg @@ -3059,6 +3059,84 @@ linedeftypes slopeargs = 3; } + 723 + { + title = "Copy Backside Floor Slope from Line Tag"; + prefix = "(720)"; + slope = "copy"; + slopeargs = 4; + } + + 724 + { + title = "Copy Backside Ceiling Slope from Line Tag"; + prefix = "(721)"; + slope = "copy"; + slopeargs = 8; + } + + 725 + { + title = "Copy Backside Floor and Ceiling Slope from Line Tag"; + prefix = "(722)"; + slope = "copy"; + slopeargs = 12; + } + + 730 + { + title = "Copy Frontside Floor Slope to Backside"; + prefix = "(730)"; + slope = "copy"; + slopeargs = 1; + //copyslopeargs = 1; uncomment when ZB updates + } + + 731 + { + title = "Copy Frontside Ceiling Slope to Backside"; + prefix = "(731)"; + slope = "copy"; + slopeargs = 2; + //copyslopeargs = 4; uncomment when ZB updates + } + + 732 + { + title = "Copy Frontside Floor and Ceiling Slope to Backside"; + prefix = "(732)"; + slope = "copy"; + slopeargs = 3; + //copyslopeargs = 5; uncomment when ZB updates + } + + 733 + { + title = "Copy Backside Floor Slope to Frontside"; + prefix = "(730)"; + slope = "copy"; + slopeargs = 1; + //copyslopeargs = 2; uncomment when ZB updates + } + + 734 + { + title = "Copy Backside Ceiling Slope to Frontside"; + prefix = "(731)"; + slope = "copy"; + slopeargs = 2; + //copyslopeargs = 8; uncomment when ZB updates + } + + 735 + { + title = "Copy Backside Floor and Ceiling Slope to Frontside"; + prefix = "(732)"; + slope = "copy"; + slopeargs = 3; + //copyslopeargs = 10; uncomment when ZB updates + } + 799 { title = "Set Tagged Dynamic Slope Vertex to Front Sector Height"; diff --git a/src/p_setup.c b/src/p_setup.c index 66243fb0e..1c70c01e6 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -3141,6 +3141,34 @@ static void P_ConvertBinaryMap(void) lines[i].args[1] = tag; lines[i].special = 720; break; + case 723: //Copy back side floor slope + case 724: //Copy back side ceiling slope + case 725: //Copy back side floor and ceiling slope + if (lines[i].special != 724) + lines[i].args[2] = tag; + if (lines[i].special != 723) + lines[i].args[3] = tag; + lines[i].special = 720; + break; + case 730: //Copy front side floor slope to back side + case 731: //Copy front side ceiling slope to back side + case 732: //Copy front side floor and ceiling slope to back side + if (lines[i].special != 731) + lines[i].args[4] |= TMSC_FRONTTOBACKFLOOR; + if (lines[i].special != 730) + lines[i].args[4] |= TMSC_FRONTTOBACKCEILING; + lines[i].special = 720; + break; + case 733: //Copy back side floor slope to front side + case 734: //Copy back side ceiling slope to front side + case 735: //Copy back side floor and ceiling slope to front side + if (lines[i].special != 734) + lines[i].args[4] |= TMSC_BACKTOFRONTFLOOR; + if (lines[i].special != 733) + lines[i].args[4] |= TMSC_BACKTOFRONTCEILING; + lines[i].special = 720; + break; + case 900: //Translucent wall (10%) case 901: //Translucent wall (20%) case 902: //Translucent wall (30%) From 3003c252d12651111498e47eb9d372c0e8794a75 Mon Sep 17 00:00:00 2001 From: James R Date: Thu, 18 Feb 2021 05:16:15 -0800 Subject: [PATCH 0591/1080] Makfile: don't print some messages twice --- src/Makefile | 10 +++++++--- src/Makefile.cfg | 10 ++++++---- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/Makefile b/src/Makefile index 42b757940..1186fe915 100644 --- a/src/Makefile +++ b/src/Makefile @@ -2,7 +2,7 @@ # GNU Make makefile for SRB2 ############################################################################# # Copyright (C) 1998-2000 by DooM Legacy Team. -# Copyright (C) 2003-2020 by Sonic Team Junior. +# Copyright (C) 2003-2021 by Sonic Team Junior. # # This program is free software distributed under the # terms of the GNU General Public License, version 2. @@ -79,6 +79,10 @@ # ############################################################################# +ifndef MAKE_RESTARTS +print=$(info $(1)) +endif + ALL_SYSTEMS=\ PANDORA\ LINUX64\ @@ -98,7 +102,7 @@ ALL_SYSTEMS=\ ifeq (,$(filter $(ALL_SYSTEMS),$(.VARIABLES))) ifeq ($(OS),Windows_NT) # all windows are Windows_NT... - $(info Detected a Windows system, compiling for 32-bit MinGW SDL2...) + $(call print,Detected a Windows system, compiling for 32-bit MinGW SDL2...) # go for a 32-bit sdl mingw exe by default MINGW=1 @@ -123,7 +127,7 @@ else # if you on the *nix new_system:=$(new_system)64 endif - $(info Detected $(system) ($(new_system))...) + $(call print,Detected $(system) ($(new_system))...) $(new_system)=1 endif diff --git a/src/Makefile.cfg b/src/Makefile.cfg index f081eacdf..c323f4ffd 100644 --- a/src/Makefile.cfg +++ b/src/Makefile.cfg @@ -60,12 +60,14 @@ ifeq (,$(filter GCC%,$(.VARIABLES))) # If this version is not in the list, default to the latest supported ifeq (,$(filter $(v),$(SUPPORTED_GCC_VERSIONS))) - $(info\ - Your compiler version, GCC $(version), is not supported by the Makefile.\ - The Makefile will assume GCC $(LATEST_GCC_VERSION).) + define line = + Your compiler version, GCC $(version), is not supported by the Makefile. + The Makefile will assume GCC $(LATEST_GCC_VERSION).)) + endef + $(call print,$(line)) GCC$(subst .,,$(LATEST_GCC_VERSION))=1 else - $(info Detected GCC $(version) (GCC$(v))) + $(call print,Detected GCC $(version) (GCC$(v))) GCC$(v)=1 endif endif From 3d32f3145cf1bec85f77c33908a8bfc6772bd779 Mon Sep 17 00:00:00 2001 From: James R Date: Thu, 18 Feb 2021 06:15:11 -0800 Subject: [PATCH 0592/1080] Generate individual dependency files This removes Makefile.depends. Instead, '.d' files are included from the 'dep' directory. This speeds up building because dependencies for every file don't need to be regenerated if only one changes. As a bonus, dependencies also won't be generated if only clean type targets are going to be run. Also added a 'distclean' target, which cleans both objects and dependency files. --- src/Makefile | 57 ++++++++++++++++++++++++------------------------ src/Makefile.cfg | 13 +++++++++++ 2 files changed, 41 insertions(+), 29 deletions(-) diff --git a/src/Makefile b/src/Makefile index 1186fe915..3e8c33624 100644 --- a/src/Makefile +++ b/src/Makefile @@ -24,7 +24,9 @@ # clean # Remove all object files # cleandep -# Remove depend.dep +# Remove dependency files +# distclean +# Remove autogenerated files # dll # compile primary HW render DLL/SO # all_dll @@ -459,7 +461,6 @@ DBGNAME?=$(EXENAME).debug # not too sophisticated dependency OBJS:=$(i_main_o) \ - $(OBJDIR)/comptime.o \ $(OBJDIR)/string.o \ $(OBJDIR)/d_main.o \ $(OBJDIR)/d_clisrv.o \ @@ -539,6 +540,8 @@ OBJS:=$(i_main_o) \ $(i_sound_o) \ $(OBJS) +DEPS:=$(patsubst $(OBJDIR)/%.o,$(DEPDIR)/%.d,$(OBJS)) +OBJS+=$(OBJDIR)/comptime.o ifndef ECHO ifndef NOECHOFILENAMES @@ -559,12 +562,12 @@ OPTS+=-DGETTEXT endif ifdef PANDORA -all: pre-build $(BIN)/$(PNDNAME) +all: $(BIN)/$(PNDNAME) endif ifdef SDL -all: pre-build $(BIN)/$(EXENAME) +all: $(BIN)/$(EXENAME) endif ifdef DUMMY @@ -572,20 +575,15 @@ all: $(BIN)/$(EXENAME) endif cleandep: - $(REMOVE) $(OBJDIR)/depend.dep + $(REMOVE) $(DEPS) $(REMOVE) comptime.h -pre-build: -ifdef WINDOWSHELL - -..\comptime.bat . -else - -@../comptime.sh . -endif - clean: $(REMOVE) *~ *.flc $(REMOVE) $(OBJDIR)/*.o +distclean: clean cleandep + ifdef MINGW $(REMOVE) $(OBJDIR)/*.res endif @@ -667,24 +665,21 @@ endif endif #dependecy made by gcc itself ! -$(OBJS): ifndef DUMMY --include $(OBJDIR)/depend.dep +ifneq (,$(filter-out cleandep clean distclean,$(or $(MAKECMDGOALS),all))) +$(call print,Checking dependency files...) +-include $(DEPS) +endif endif -$(OBJDIR)/depend.dep: - @echo "Creating dependency file, depend.dep" - @echo > comptime.h - -$(MKDIR) $(OBJDIR) - $(CC) $(CFLAGS) -MM *.c > $(OBJDIR)/depend.ped - $(CC) $(CFLAGS) -MM $(INTERFACE)/*.c >> $(OBJDIR)/depend.ped -ifndef NOHW - $(CC) $(CFLAGS) -MM hardware/*.c >> $(OBJDIR)/depend.ped +$(DEPDIR)/%.d: %.c +# windows makes it too hard ! +ifndef WINDOWSHELL +ifndef ECHO + @printf "%-20.20s\r" $< endif - $(CC) $(CFLAGS) -MM blua/*.c >> $(OBJDIR)/depend.ped - @sed -e 's,\(.*\)\.o: ,$(subst /,\/,$(OBJDIR))\/&,g' < $(OBJDIR)/depend.ped > $(OBJDIR)/depend.dep - $(REMOVE) $(OBJDIR)/depend.ped - @echo "Created dependency file, depend.dep" +endif + $(CC) $(CFLAGS) -M -MF $@ -MT $(OBJDIR)/$< $< ifdef VALGRIND $(OBJDIR)/z_zone.o: z_zone.c @@ -692,9 +687,13 @@ $(OBJDIR)/z_zone.o: z_zone.c $(CC) $(CFLAGS) $(WFLAGS) -DHAVE_VALGRIND $(VALGRIND_CFLAGS) -c $< -o $@ endif -$(OBJDIR)/comptime.o: comptime.c pre-build - $(echoName) - $(CC) $(CFLAGS) $(WFLAGS) -c $< -o $@ +$(OBJDIR)/comptime.o:: +ifdef WINDOWSHELL + -..\comptime.bat . +else + -../comptime.sh . +endif + $(CC) $(CFLAGS) $(WFLAGS) -c comptime.c -o $@ $(BIN)/%.mo: locale/%.po -$(MKDIR) $(BIN) diff --git a/src/Makefile.cfg b/src/Makefile.cfg index c323f4ffd..ec19e9f85 100644 --- a/src/Makefile.cfg +++ b/src/Makefile.cfg @@ -363,6 +363,7 @@ i_main_o=$(OBJDIR)/i_main.o #set OBJDIR and BIN's starting place OBJDIR=../objs BIN=../bin +DEPDIR=../dep #Nasm ASM and rm ifdef YASM NASM?=yasm @@ -385,6 +386,7 @@ ifdef DUMMY INTERFACE=dummy OBJDIR:=$(OBJDIR)/dummy BIN:=$(BIN)/dummy + DEPDIR:=$(DEPDIR)/dummy else ifdef LINUX NASMFORMAT=elf -DLINUX @@ -392,9 +394,11 @@ ifdef LINUX ifdef LINUX64 OBJDIR:=$(OBJDIR)/Linux64 BIN:=$(BIN)/Linux64 + DEPDIR:=$(DEPDIR)/Linux64 else OBJDIR:=$(OBJDIR)/Linux BIN:=$(BIN)/Linux + DEPDIR:=$(DEPDIR)/Linux endif else ifdef FREEBSD @@ -404,6 +408,7 @@ ifdef FREEBSD OBJDIR:=$(OBJDIR)/FreeBSD BIN:=$(BIN)/FreeBSD + DEPDIR:=$(DEPDIR)/Linux else ifdef SOLARIS INTERFACE=sdl @@ -412,6 +417,7 @@ ifdef SOLARIS OBJDIR:=$(OBJDIR)/Solaris BIN:=$(BIN)/Solaris + DEPDIR:=$(DEPDIR)/Solaris else ifdef CYGWIN32 INTERFACE=sdl @@ -420,18 +426,21 @@ ifdef CYGWIN32 OBJDIR:=$(OBJDIR)/cygwin BIN:=$(BIN)/Cygwin + DEPDIR:=$(DEPDIR)/Cygwin else ifdef MINGW64 #NASMFORMAT=win64 SDL=1 OBJDIR:=$(OBJDIR)/Mingw64 BIN:=$(BIN)/Mingw64 + DEPDIR:=$(DEPDIR)/Mingw64 else ifdef MINGW NASMFORMAT=win32 SDL=1 OBJDIR:=$(OBJDIR)/Mingw BIN:=$(BIN)/Mingw + DEPDIR:=$(DEPDIR)/Mingw endif endif endif @@ -443,6 +452,7 @@ endif ifdef ARCHNAME OBJDIR:=$(OBJDIR)/$(ARCHNAME) BIN:=$(BIN)/$(ARCHNAME) + DEPDIR:=$(DEPDIR)/$(ARCHNAME) endif OBJDUMP_OPTS?=--wide --source --line-numbers @@ -451,14 +461,17 @@ LD=$(CC) ifdef SDL INTERFACE=sdl OBJDIR:=$(OBJDIR)/SDL + DEPDIR:=$(DEPDIR)/SDL endif ifndef DUMMY ifdef DEBUGMODE OBJDIR:=$(OBJDIR)/Debug BIN:=$(BIN)/Debug + DEPDIR:=$(DEPDIR)/Debug else OBJDIR:=$(OBJDIR)/Release BIN:=$(BIN)/Release + DEPDIR:=$(DEPDIR)/Release endif endif From 747c278bc2380d5f48c0c939de1ef3994d44b6c4 Mon Sep 17 00:00:00 2001 From: James R Date: Thu, 18 Feb 2021 07:03:25 -0800 Subject: [PATCH 0593/1080] Makefile: add a SILENT flag This makes it print nothing to stdout. Also fixed some irregularities. --- src/Makefile | 37 ++++++++++++++++++++++++++----------- src/Makefile.cfg | 3 ++- 2 files changed, 28 insertions(+), 12 deletions(-) diff --git a/src/Makefile b/src/Makefile index 3e8c33624..260175a69 100644 --- a/src/Makefile +++ b/src/Makefile @@ -81,9 +81,16 @@ # ############################################################################# +,=, + +ifeq (,$(filter-out cleandep clean distclean,$(or $(MAKECMDGOALS),all))) +CLEANONLY=1 +else ifndef SILENT +echo=@echo "$(1)" ifndef MAKE_RESTARTS print=$(info $(1)) endif +endif ALL_SYSTEMS=\ PANDORA\ @@ -104,7 +111,7 @@ ALL_SYSTEMS=\ ifeq (,$(filter $(ALL_SYSTEMS),$(.VARIABLES))) ifeq ($(OS),Windows_NT) # all windows are Windows_NT... - $(call print,Detected a Windows system, compiling for 32-bit MinGW SDL2...) + $(call print,Detected a Windows system$(,) compiling for 32-bit MinGW SDL2...) # go for a 32-bit sdl mingw exe by default MINGW=1 @@ -243,6 +250,12 @@ endif MSGFMT?=msgfmt +ifdef WINDOWSHELL + COMPTIME=-..\comptime.bat +else + COMPTIME=-../comptime.sh +endif + ifndef ECHO NASM:=@$(NASM) REMOVE:=@$(REMOVE) @@ -257,6 +270,7 @@ ifndef ECHO MSGFMT:=@$(MSGFMT) UPX:=@$(UPX) UPX_OPTS+=-q + COMPTIME:=@$(COMPTIME) endif ifdef NONET @@ -543,6 +557,7 @@ OBJS:=$(i_main_o) \ DEPS:=$(patsubst $(OBJDIR)/%.o,$(DEPDIR)/%.d,$(OBJS)) OBJS+=$(OBJDIR)/comptime.o +ifndef SILENT ifndef ECHO ifndef NOECHOFILENAMES define echoName = @@ -550,6 +565,7 @@ define echoName = endef endif endif +endif # List of languages to compile. # For reference, this is the command I use to build a srb2.pot file from the source code. @@ -603,11 +619,11 @@ asm: $(BIN)/$(EXENAME): $(POS) $(OBJS) -$(MKDIR) $(BIN) - @echo Linking $(EXENAME)... + $(call echo,Linking $(EXENAME)...) $(LD) $(LDFLAGS) $(OBJS) -o $(BIN)/$(EXENAME) $(LIBS) ifndef VALGRIND ifndef NOOBJDUMP - @echo Dumping debugging info + $(call echo,Dumping debugging info) $(OBJDUMP) $(OBJDUMP_OPTS) $(BIN)/$(EXENAME) > $(BIN)/$(DBGNAME).txt ifdef WINDOWSHELL -$(GZIP) $(GZIP_OPTS) $(BIN)/$(DBGNAME).txt @@ -626,10 +642,10 @@ ifndef NOUPX -$(UPX) $(UPX_OPTS) $(BIN)/$(EXENAME) endif endif - @echo Build is done, please look for $(EXENAME) in $(BIN), \(checking for post steps\) + $(call echo,Build is done$(,) please look for $(EXENAME) in $(BIN)$(,) (checking for post steps)) reobjdump: - @echo Redumping debugging info + $(call echo,Redumping debugging info) $(OBJDUMP) $(OBJDUMP_OPTS) $(BIN)/$(DBGNAME) > $(BIN)/$(DBGNAME).txt ifdef WINDOWSHELL -$(GZIP) $(GZIP_OPTS) $(BIN)/$(DBGNAME).txt @@ -666,7 +682,7 @@ endif #dependecy made by gcc itself ! ifndef DUMMY -ifneq (,$(filter-out cleandep clean distclean,$(or $(MAKECMDGOALS),all))) +ifndef CLEANONLY $(call print,Checking dependency files...) -include $(DEPS) endif @@ -675,7 +691,7 @@ endif $(DEPDIR)/%.d: %.c # windows makes it too hard ! ifndef WINDOWSHELL -ifndef ECHO +ifdef echoName @printf "%-20.20s\r" $< endif endif @@ -688,11 +704,10 @@ $(OBJDIR)/z_zone.o: z_zone.c endif $(OBJDIR)/comptime.o:: -ifdef WINDOWSHELL - -..\comptime.bat . -else - -../comptime.sh . +ifdef echoName + @echo -- comptime.c ... endif + $(COMPTIME) . $(CC) $(CFLAGS) $(WFLAGS) -c comptime.c -o $@ $(BIN)/%.mo: locale/%.po diff --git a/src/Makefile.cfg b/src/Makefile.cfg index ec19e9f85..075cd2d3a 100644 --- a/src/Makefile.cfg +++ b/src/Makefile.cfg @@ -47,7 +47,8 @@ ifdef MACOSX endif # Automatically set version flag, but not if one was manually set -ifeq (,$(filter GCC%,$(.VARIABLES))) +# And don't bother if this is a clean only run +ifeq (,$(filter GCC% CLEANONLY,$(.VARIABLES))) version:=$(shell $(CC) --version) # check if this is in fact GCC ifneq (,$(or $(findstring gcc,$(version)),$(findstring GCC,$(version)))) From 73758f50ff5586f537a2e414519bc4b8ae8103f4 Mon Sep 17 00:00:00 2001 From: toaster Date: Fri, 19 Feb 2021 06:45:28 -0500 Subject: [PATCH 0594/1080] Fix dropshadows of papersprites drifting depending on angle relative to camera. Discovered in Kart internal for the paper item drops and ported back, hence the branch name. --- src/r_things.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/r_things.c b/src/r_things.c index 30bf15f85..bea40c810 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -1423,7 +1423,7 @@ static void R_ProjectSprite(mobj_t *thing) fixed_t sheartan = 0; fixed_t shadowscale = FRACUNIT; - fixed_t basetx; // drop shadows + fixed_t basetx, basetz; // drop shadows boolean shadowdraw, shadoweffects, shadowskew; boolean splat = R_ThingIsFloorSprite(thing); @@ -1453,7 +1453,7 @@ static void R_ProjectSprite(mobj_t *thing) tr_x = thing->x - viewx; tr_y = thing->y - viewy; - tz = FixedMul(tr_x, viewcos) + FixedMul(tr_y, viewsin); // near/far distance + basetz = tz = FixedMul(tr_x, viewcos) + FixedMul(tr_y, viewsin); // near/far distance // thing is behind view plane? if (!papersprite && (tz < FixedMul(MINZ, this_scale))) // papersprite clipping is handled later @@ -2052,7 +2052,7 @@ static void R_ProjectSprite(mobj_t *thing) R_SplitSprite(vis); if (oldthing->shadowscale && cv_shadow.value) - R_ProjectDropShadow(oldthing, vis, oldthing->shadowscale, basetx, tz); + R_ProjectDropShadow(oldthing, vis, oldthing->shadowscale, basetx, basetz); // Debug ++objectsdrawn; From 308ab0e0791abe16fd1109c0c48e6a249592cfe9 Mon Sep 17 00:00:00 2001 From: Zwip-Zwap Zapony Date: Sun, 21 Feb 2021 22:16:38 +0100 Subject: [PATCH 0595/1080] Fix OpenGL V_DrawCroppedPatch --- src/hardware/hw_draw.c | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/src/hardware/hw_draw.c b/src/hardware/hw_draw.c index 8c92c6709..ba4923d10 100644 --- a/src/hardware/hw_draw.c +++ b/src/hardware/hw_draw.c @@ -437,18 +437,9 @@ void HWR_DrawCroppedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale, if (!(option & V_SCALEPATCHMASK)) { - // if it's meant to cover the whole screen, black out the rest (ONLY IF TOP LEFT ISN'T TRANSPARENT) - // cx and cy are possibly *slightly* off from float maths - // This is done before here compared to software because we directly alter cx and cy to centre - if (cx >= -0.1f && cx <= 0.1f && gpatch->width == BASEVIDWIDTH && cy >= -0.1f && cy <= 0.1f && gpatch->height == BASEVIDHEIGHT) - { - const column_t *column = (const column_t *)((const UINT8 *)(gpatch->columns) + (gpatch->columnofs[0])); - if (!column->topdelta) - { - const UINT8 *source = (const UINT8 *)(column) + 3; - HWR_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, (column->topdelta == 0xff ? 31 : source[0])); - } - } + // if it's meant to cover the whole screen, black out the rest + // no the patch is cropped do not do this ever + // centre screen if (fabsf((float)vid.width - (float)BASEVIDWIDTH * dupx) > 1.0E-36f) { @@ -470,11 +461,11 @@ void HWR_DrawCroppedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale, fwidth = w; fheight = h; - if (fwidth > gpatch->width) - fwidth = gpatch->width; + if (sx + w > gpatch->width) + fwidth = gpatch->width - sx; - if (fheight > gpatch->height) - fheight = gpatch->height; + if (sy + h > gpatch->height) + fheight = gpatch->height - sy; if (pscale != FRACUNIT) { @@ -506,13 +497,13 @@ void HWR_DrawCroppedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale, v[0].s = v[3].s = ((sx)/(float)(gpatch->width))*hwrPatch->max_s; if (sx + w > gpatch->width) - v[2].s = v[1].s = hwrPatch->max_s - ((sx+w)/(float)(gpatch->width))*hwrPatch->max_s; + v[2].s = v[1].s = hwrPatch->max_s; else v[2].s = v[1].s = ((sx+w)/(float)(gpatch->width))*hwrPatch->max_s; v[0].t = v[1].t = ((sy)/(float)(gpatch->height))*hwrPatch->max_t; if (sy + h > gpatch->height) - v[2].t = v[3].t = hwrPatch->max_t - ((sy+h)/(float)(gpatch->height))*hwrPatch->max_t; + v[2].t = v[3].t = hwrPatch->max_t; else v[2].t = v[3].t = ((sy+h)/(float)(gpatch->height))*hwrPatch->max_t; From 12205314bcc8e973e22e1bbbfcccb8f34c304629 Mon Sep 17 00:00:00 2001 From: GoldenTails Date: Sun, 21 Feb 2021 19:32:00 -0600 Subject: [PATCH 0596/1080] Check against null tmpusher source before attempting to push a thing. --- src/p_spec.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/p_spec.c b/src/p_spec.c index 226e58d15..9886495db 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -8458,6 +8458,9 @@ static inline boolean PIT_PushThing(mobj_t *thing) if (thing->player && thing->player->powers[pw_carry] == CR_ROPEHANG) return false; + if (!tmpusher->source) + return false; + // Allow this to affect pushable objects at some point? if (thing->player && (!(thing->flags & (MF_NOGRAVITY | MF_NOCLIP)) || thing->player->powers[pw_carry] == CR_NIGHTSMODE)) { From d305952119aff3f84eee15697c4e2af6b32a1140 Mon Sep 17 00:00:00 2001 From: sphere Date: Wed, 24 Feb 2021 10:30:48 +0100 Subject: [PATCH 0597/1080] Update ZB config: at this rate, ZB will update before this gets merged. --- extras/conf/SRB2-22.cfg | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/extras/conf/SRB2-22.cfg b/extras/conf/SRB2-22.cfg index b7ba56ba7..246ef9b64 100644 --- a/extras/conf/SRB2-22.cfg +++ b/extras/conf/SRB2-22.cfg @@ -3088,8 +3088,7 @@ linedeftypes title = "Copy Frontside Floor Slope to Backside"; prefix = "(730)"; slope = "copy"; - slopeargs = 1; - //copyslopeargs = 1; uncomment when ZB updates + copyslopeargs = 1; } 731 @@ -3097,8 +3096,7 @@ linedeftypes title = "Copy Frontside Ceiling Slope to Backside"; prefix = "(731)"; slope = "copy"; - slopeargs = 2; - //copyslopeargs = 4; uncomment when ZB updates + copyslopeargs = 4; } 732 @@ -3106,8 +3104,7 @@ linedeftypes title = "Copy Frontside Floor and Ceiling Slope to Backside"; prefix = "(732)"; slope = "copy"; - slopeargs = 3; - //copyslopeargs = 5; uncomment when ZB updates + copyslopeargs = 5; } 733 @@ -3115,8 +3112,7 @@ linedeftypes title = "Copy Backside Floor Slope to Frontside"; prefix = "(730)"; slope = "copy"; - slopeargs = 1; - //copyslopeargs = 2; uncomment when ZB updates + copyslopeargs = 2; } 734 @@ -3124,8 +3120,7 @@ linedeftypes title = "Copy Backside Ceiling Slope to Frontside"; prefix = "(731)"; slope = "copy"; - slopeargs = 2; - //copyslopeargs = 8; uncomment when ZB updates + copyslopeargs = 8; } 735 @@ -3133,8 +3128,7 @@ linedeftypes title = "Copy Backside Floor and Ceiling Slope to Frontside"; prefix = "(732)"; slope = "copy"; - slopeargs = 3; - //copyslopeargs = 10; uncomment when ZB updates + copyslopeargs = 10; } 799 From 75d0e702369e80cc93191782bc8dfd4de45fde88 Mon Sep 17 00:00:00 2001 From: LJ Sonic Date: Thu, 25 Feb 2021 23:41:43 +0100 Subject: [PATCH 0598/1080] Fix sector tags being signed in Lua --- src/lua_maplib.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/lua_maplib.c b/src/lua_maplib.c index 6a9091cc9..9598f7708 100644 --- a/src/lua_maplib.c +++ b/src/lua_maplib.c @@ -583,7 +583,18 @@ static int sector_get(lua_State *L) lua_pushinteger(L, sector->special); return 1; case sector_tag: - lua_pushinteger(L, Tag_FGet(§or->tags)); + // HELLO + // THIS IS LJ SONIC + // HOW IS YOUR DAY? + // BY THE WAY WHEN 2.3 OR 3.0 OR 4.0 OR SRB3 OR SRB4 OR WHATEVER IS OUT + // YOU SHOULD REMEMBER TO CHANGE THIS SO IT ALWAYS RETURNS A UNSIGNED VALUE + // HAVE A NICE DAY + // + // + // + // + // you are ugly + lua_pushinteger(L, (UINT16)Tag_FGet(§or->tags)); return 1; case sector_taglist: LUA_PushUserdata(L, §or->tags, META_SECTORTAGLIST); @@ -828,6 +839,17 @@ static int line_get(lua_State *L) lua_pushinteger(L, line->special); return 1; case line_tag: + // HELLO + // THIS IS LJ SONIC + // HOW IS YOUR DAY? + // BY THE WAY WHEN 2.3 OR 3.0 OR 4.0 OR SRB3 OR SRB4 OR WHATEVER IS OUT + // YOU SHOULD REMEMBER TO CHANGE THIS SO IT ALWAYS RETURNS A UNSIGNED VALUE + // HAVE A NICE DAY + // + // + // + // + // you are ugly lua_pushinteger(L, Tag_FGet(&line->tags)); return 1; case line_taglist: From 5b1dc6ba338ac1f1401d38ce1d82aeb082ad3dff Mon Sep 17 00:00:00 2001 From: Jaime Ita Passos Date: Wed, 24 Feb 2021 23:45:39 -0300 Subject: [PATCH 0599/1080] [Meta] Change branding --- src/d_netcmd.c | 4 ++-- src/m_misc.c | 6 +++--- src/sdl/i_system.c | 8 ++++---- src/sdl/i_video.c | 2 +- src/win32/Makefile.cfg | 2 +- src/win32/Srb2win.rc | 6 +++--- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 4208e4c4f..8d42ca4c2 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -3477,9 +3477,9 @@ static void Command_ListWADS_f(void) static void Command_Version_f(void) { #ifdef DEVELOP - CONS_Printf("Sonic Robo Blast 2 %s-%s (%s %s) ", compbranch, comprevision, compdate, comptime); + CONS_Printf("Kitchen Sink Faucet %s-%s (%s %s) ", compbranch, comprevision, compdate, comptime); #else - CONS_Printf("Sonic Robo Blast 2 %s (%s %s %s %s) ", VERSIONSTRING, compdate, comptime, comprevision, compbranch); + CONS_Printf("Kitchen Sink Faucet %s (%s %s %s %s) ", VERSIONSTRING, compdate, comptime, comprevision, compbranch); #endif // Base library diff --git a/src/m_misc.c b/src/m_misc.c index 42890cb08..376e7512f 100644 --- a/src/m_misc.c +++ b/src/m_misc.c @@ -783,10 +783,10 @@ static void M_PNGText(png_structp png_ptr, png_infop png_info_ptr, PNG_CONST png char keytxt[SRB2PNGTXT][12] = { "Title", "Description", "Playername", "Mapnum", "Mapname", "Location", "Interface", "Render Mode", "Revision", "Build Date", "Build Time"}; - char titletxt[] = "Sonic Robo Blast 2 " VERSIONSTRING; + char titletxt[] = "Kitchen Sink Faucet " VERSIONSTRING; png_charp playertxt = cv_playername.zstring; - char desctxt[] = "SRB2 Screenshot"; - char Movietxt[] = "SRB2 Movie"; + char desctxt[] = "Kitchen Sink Faucet Screenshot"; + char Movietxt[] = "Kitchen Sink Faucet Movie"; size_t i; char interfacetxt[] = #ifdef HAVE_SDL diff --git a/src/sdl/i_system.c b/src/sdl/i_system.c index 10c0747bf..1c47b89c9 100644 --- a/src/sdl/i_system.c +++ b/src/sdl/i_system.c @@ -629,7 +629,7 @@ static void I_StartupConsole(void) if (gotConsole) { - SetConsoleTitleA("SRB2 Console"); + SetConsoleTitleA("Kitchen Sink Faucet Console"); consolevent = SDL_TRUE; } @@ -1622,7 +1622,7 @@ void I_UpdateMumble(const mobj_t *mobj, const listener_t listener) return; if(mumble->uiVersion != 2) { - wcsncpy(mumble->name, L"SRB2 "VERSIONSTRINGW, 256); + wcsncpy(mumble->name, L"Kitchen Sink Faucet "VERSIONSTRINGW, 256); wcsncpy(mumble->description, L"Sonic Robo Blast 2 with integrated Mumble Link support.", 2048); mumble->uiVersion = 2; } @@ -2400,7 +2400,7 @@ void I_Error(const char *error, ...) // which should fail gracefully if it can't put a message box up // on the target system SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, - "SRB2 "VERSIONSTRING" Recursive Error", + "Kitchen Sink Faucet Recursive Error", buffer, NULL); W_Shutdown(); @@ -2444,7 +2444,7 @@ void I_Error(const char *error, ...) // which should fail gracefully if it can't put a message box up // on the target system SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, - "SRB2 "VERSIONSTRING" Error", + "Kitchen Sink Faucet Error", buffer, NULL); // Note that SDL_ShowSimpleMessageBox does *not* require SDL to be // initialized at the time, so calling it after SDL_Quit() is diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index c8f67da77..032521c0a 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -1631,7 +1631,7 @@ static SDL_bool Impl_CreateWindow(SDL_bool fullscreen) #endif // Create a window - window = SDL_CreateWindow("SRB2 "VERSIONSTRING, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, + window = SDL_CreateWindow("Kitchen Sink Faucet "VERSIONSTRING, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, realwidth, realheight, flags); diff --git a/src/win32/Makefile.cfg b/src/win32/Makefile.cfg index 702ae3765..0365f617d 100644 --- a/src/win32/Makefile.cfg +++ b/src/win32/Makefile.cfg @@ -68,7 +68,7 @@ endif endif # name of the exefile - EXENAME?=srb2win.exe + EXENAME?=kitchensinkfaucet.exe ifdef SDL i_system_o+=$(OBJDIR)/SRB2.res diff --git a/src/win32/Srb2win.rc b/src/win32/Srb2win.rc index 5ba366bda..98927e2a6 100644 --- a/src/win32/Srb2win.rc +++ b/src/win32/Srb2win.rc @@ -84,14 +84,14 @@ BEGIN BEGIN VALUE "Comments", "Visit our web site at www.srb2.org for news and updates!\0" VALUE "CompanyName", "Sonic Team Junior\0" - VALUE "FileDescription", "Sonic Robo Blast 2\0" + VALUE "FileDescription", "Kitchen Sink Faucet\0" VALUE "FileVersion", VERSIONSTRING_RC VALUE "InternalName", "srb2\0" VALUE "LegalCopyright", "Copyright 1998-2020 by Sonic Team Junior\0" VALUE "LegalTrademarks", "Sonic the Hedgehog and related characters are trademarks of Sega.\0" - VALUE "OriginalFilename", "srb2win.exe\0" + VALUE "OriginalFilename", "kitchensinkfaucet.exe\0" VALUE "PrivateBuild", "\0" - VALUE "ProductName", "Sonic Robo Blast 2\0" + VALUE "ProductName", "Kitchen Sink Faucet\0" VALUE "ProductVersion", VERSIONSTRING_RC VALUE "SpecialBuild", "\0" END From 70ebca2bf602dd69beb1a4c00a9aafe96b8722e0 Mon Sep 17 00:00:00 2001 From: Jaime Ita Passos Date: Thu, 25 Feb 2021 00:25:09 -0300 Subject: [PATCH 0600/1080] Update README --- README.md | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 8a5ca1a1f..98cff8fec 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,7 @@ -# Sonic Robo Blast 2 +# Kitchen Sink Faucet SRB2 -[![Build status](https://ci.appveyor.com/api/projects/status/399d4hcw9yy7hg2y?svg=true)](https://ci.appveyor.com/project/STJr/srb2) -[![Build status](https://travis-ci.org/STJr/SRB2.svg?branch=master)](https://travis-ci.org/STJr/SRB2) -[![CircleCI](https://circleci.com/gh/STJr/SRB2/tree/master.svg?style=svg)](https://circleci.com/gh/STJr/SRB2/tree/master) - -[Sonic Robo Blast 2](https://srb2.org/) is a 3D Sonic the Hedgehog fangame based on a modified version of [Doom Legacy](http://doomlegacy.sourceforge.net/). +[![Build status](https://ci.appveyor.com/api/projects/status/gv49pw5mra2sad1j?svg=true)](https://ci.appveyor.com/project/jimita/kitchensinkfaucetsrb2) +[![CircleCI](https://circleci.com/gh/Jimita/KitchenSinkFaucetSRB2/tree/master.svg?style=svg)](https://app.circleci.com/pipelines/github/Jimita/KitchenSinkFaucetSRB2) ## Dependencies - NASM (x86 builds only) From 2ca8efd7eea4b3d531ac5fca4ef09a5da9f2efd1 Mon Sep 17 00:00:00 2001 From: Jaime Ita Passos Date: Thu, 25 Feb 2021 20:17:27 -0300 Subject: [PATCH 0601/1080] Revert accidental push --- README.md | 9 ++++++--- src/d_netcmd.c | 4 ++-- src/m_misc.c | 6 +++--- src/sdl/i_system.c | 8 ++++---- src/sdl/i_video.c | 2 +- src/win32/Makefile.cfg | 2 +- src/win32/Srb2win.rc | 6 +++--- 7 files changed, 20 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 98cff8fec..8a5ca1a1f 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,10 @@ -# Kitchen Sink Faucet SRB2 +# Sonic Robo Blast 2 -[![Build status](https://ci.appveyor.com/api/projects/status/gv49pw5mra2sad1j?svg=true)](https://ci.appveyor.com/project/jimita/kitchensinkfaucetsrb2) -[![CircleCI](https://circleci.com/gh/Jimita/KitchenSinkFaucetSRB2/tree/master.svg?style=svg)](https://app.circleci.com/pipelines/github/Jimita/KitchenSinkFaucetSRB2) +[![Build status](https://ci.appveyor.com/api/projects/status/399d4hcw9yy7hg2y?svg=true)](https://ci.appveyor.com/project/STJr/srb2) +[![Build status](https://travis-ci.org/STJr/SRB2.svg?branch=master)](https://travis-ci.org/STJr/SRB2) +[![CircleCI](https://circleci.com/gh/STJr/SRB2/tree/master.svg?style=svg)](https://circleci.com/gh/STJr/SRB2/tree/master) + +[Sonic Robo Blast 2](https://srb2.org/) is a 3D Sonic the Hedgehog fangame based on a modified version of [Doom Legacy](http://doomlegacy.sourceforge.net/). ## Dependencies - NASM (x86 builds only) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 8d42ca4c2..4208e4c4f 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -3477,9 +3477,9 @@ static void Command_ListWADS_f(void) static void Command_Version_f(void) { #ifdef DEVELOP - CONS_Printf("Kitchen Sink Faucet %s-%s (%s %s) ", compbranch, comprevision, compdate, comptime); + CONS_Printf("Sonic Robo Blast 2 %s-%s (%s %s) ", compbranch, comprevision, compdate, comptime); #else - CONS_Printf("Kitchen Sink Faucet %s (%s %s %s %s) ", VERSIONSTRING, compdate, comptime, comprevision, compbranch); + CONS_Printf("Sonic Robo Blast 2 %s (%s %s %s %s) ", VERSIONSTRING, compdate, comptime, comprevision, compbranch); #endif // Base library diff --git a/src/m_misc.c b/src/m_misc.c index 376e7512f..42890cb08 100644 --- a/src/m_misc.c +++ b/src/m_misc.c @@ -783,10 +783,10 @@ static void M_PNGText(png_structp png_ptr, png_infop png_info_ptr, PNG_CONST png char keytxt[SRB2PNGTXT][12] = { "Title", "Description", "Playername", "Mapnum", "Mapname", "Location", "Interface", "Render Mode", "Revision", "Build Date", "Build Time"}; - char titletxt[] = "Kitchen Sink Faucet " VERSIONSTRING; + char titletxt[] = "Sonic Robo Blast 2 " VERSIONSTRING; png_charp playertxt = cv_playername.zstring; - char desctxt[] = "Kitchen Sink Faucet Screenshot"; - char Movietxt[] = "Kitchen Sink Faucet Movie"; + char desctxt[] = "SRB2 Screenshot"; + char Movietxt[] = "SRB2 Movie"; size_t i; char interfacetxt[] = #ifdef HAVE_SDL diff --git a/src/sdl/i_system.c b/src/sdl/i_system.c index 1c47b89c9..10c0747bf 100644 --- a/src/sdl/i_system.c +++ b/src/sdl/i_system.c @@ -629,7 +629,7 @@ static void I_StartupConsole(void) if (gotConsole) { - SetConsoleTitleA("Kitchen Sink Faucet Console"); + SetConsoleTitleA("SRB2 Console"); consolevent = SDL_TRUE; } @@ -1622,7 +1622,7 @@ void I_UpdateMumble(const mobj_t *mobj, const listener_t listener) return; if(mumble->uiVersion != 2) { - wcsncpy(mumble->name, L"Kitchen Sink Faucet "VERSIONSTRINGW, 256); + wcsncpy(mumble->name, L"SRB2 "VERSIONSTRINGW, 256); wcsncpy(mumble->description, L"Sonic Robo Blast 2 with integrated Mumble Link support.", 2048); mumble->uiVersion = 2; } @@ -2400,7 +2400,7 @@ void I_Error(const char *error, ...) // which should fail gracefully if it can't put a message box up // on the target system SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, - "Kitchen Sink Faucet Recursive Error", + "SRB2 "VERSIONSTRING" Recursive Error", buffer, NULL); W_Shutdown(); @@ -2444,7 +2444,7 @@ void I_Error(const char *error, ...) // which should fail gracefully if it can't put a message box up // on the target system SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, - "Kitchen Sink Faucet Error", + "SRB2 "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 diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index 032521c0a..c8f67da77 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -1631,7 +1631,7 @@ static SDL_bool Impl_CreateWindow(SDL_bool fullscreen) #endif // Create a window - window = SDL_CreateWindow("Kitchen Sink Faucet "VERSIONSTRING, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, + window = SDL_CreateWindow("SRB2 "VERSIONSTRING, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, realwidth, realheight, flags); diff --git a/src/win32/Makefile.cfg b/src/win32/Makefile.cfg index 0365f617d..702ae3765 100644 --- a/src/win32/Makefile.cfg +++ b/src/win32/Makefile.cfg @@ -68,7 +68,7 @@ endif endif # name of the exefile - EXENAME?=kitchensinkfaucet.exe + EXENAME?=srb2win.exe ifdef SDL i_system_o+=$(OBJDIR)/SRB2.res diff --git a/src/win32/Srb2win.rc b/src/win32/Srb2win.rc index 98927e2a6..5ba366bda 100644 --- a/src/win32/Srb2win.rc +++ b/src/win32/Srb2win.rc @@ -84,14 +84,14 @@ BEGIN BEGIN VALUE "Comments", "Visit our web site at www.srb2.org for news and updates!\0" VALUE "CompanyName", "Sonic Team Junior\0" - VALUE "FileDescription", "Kitchen Sink Faucet\0" + VALUE "FileDescription", "Sonic Robo Blast 2\0" VALUE "FileVersion", VERSIONSTRING_RC VALUE "InternalName", "srb2\0" VALUE "LegalCopyright", "Copyright 1998-2020 by Sonic Team Junior\0" VALUE "LegalTrademarks", "Sonic the Hedgehog and related characters are trademarks of Sega.\0" - VALUE "OriginalFilename", "kitchensinkfaucet.exe\0" + VALUE "OriginalFilename", "srb2win.exe\0" VALUE "PrivateBuild", "\0" - VALUE "ProductName", "Kitchen Sink Faucet\0" + VALUE "ProductName", "Sonic Robo Blast 2\0" VALUE "ProductVersion", VERSIONSTRING_RC VALUE "SpecialBuild", "\0" END From 8bcc71c6295cd65d3fbb72d9706ef072ff21d4ce Mon Sep 17 00:00:00 2001 From: Riku Salminen <38985578+Riku-S@users.noreply.github.com> Date: Fri, 26 Feb 2021 15:43:53 +0200 Subject: [PATCH 0602/1080] Disable pausing during score screens in marathon mode --- src/d_netcmd.c | 2 +- src/p_user.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 0acbec928..09f9d4651 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -2130,7 +2130,7 @@ static void Command_Pause(void) if (cv_pause.value || server || (IsPlayerAdmin(consoleplayer))) { - if (modeattacking || !(gamestate == GS_LEVEL || gamestate == GS_INTERMISSION)) + if (modeattacking || !(gamestate == GS_LEVEL || gamestate == GS_INTERMISSION) || (marathonmode && gamestate == GS_INTERMISSION)) { CONS_Printf(M_GetText("You can't pause here.\n")); return; diff --git a/src/p_user.c b/src/p_user.c index a9e1fe9a2..d7ce33177 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -190,7 +190,7 @@ fixed_t P_ReturnThrustY(mobj_t *mo, angle_t angle, fixed_t move) boolean P_AutoPause(void) { // Don't pause even on menu-up or focus-lost in netgames or record attack - if (netgame || modeattacking || gamestate == GS_TITLESCREEN) + if (netgame || modeattacking || gamestate == GS_TITLESCREEN || (marathonmode && gamestate == GS_INTERMISSION)) return false; return (menuactive || ( window_notinfocus && cv_pauseifunfocused.value )); From 77feee73c36085180db713871098f1917fdf1f3d Mon Sep 17 00:00:00 2001 From: Lachlan Wright Date: Sat, 27 Feb 2021 03:38:13 +0000 Subject: [PATCH 0603/1080] Revert "Merge branch 'player-speed' into 'next'" This reverts merge request !1309 --- src/p_enemy.c | 2 +- src/p_user.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/p_enemy.c b/src/p_enemy.c index 3e7f52a3f..12bba0b4d 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -1834,7 +1834,7 @@ void A_SnailerThink(mobj_t *actor) fixed_t dist; fixed_t dx, dy; - dist = R_PointToDist2(0, 0, actor->x - actor->target->x, actor->y - actor->target->y); + dist = P_AproxDistance(actor->x - actor->target->x, actor->y - actor->target->y); if (an > ANGLE_45 && an <= ANGLE_90) // fire at 45 degrees to the left { diff --git a/src/p_user.c b/src/p_user.c index a9e1fe9a2..b3b337572 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -5924,7 +5924,7 @@ static void P_3dMovement(player_t *player) player->rmomy = player->mo->momy - player->cmomy; // Calculates player's speed based on distance-of-a-line formula - player->speed = R_PointToDist2(0, 0, player->rmomx, player->rmomy); + player->speed = P_AproxDistance(player->rmomx, player->rmomy); // Monster Iestyn - 04-11-13 // Quadrants are stupid, excessive and broken, let's do this a much simpler way! From a1e0aa18120ad75d25b5aad4373c24e47f9dbb47 Mon Sep 17 00:00:00 2001 From: Jaime Ita Passos Date: Sat, 27 Feb 2021 12:04:48 -0300 Subject: [PATCH 0604/1080] Fix "implicit declaration of function 'DEH_TableCheck'" warning --- 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 409a66bec..23a2c0133 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -61,7 +61,7 @@ #include "p_local.h" // chasecam #include "mserv.h" // ms_RoomId #include "m_misc.h" // screenshot functionality -#include "dehacked.h" // Dehacked list test +#include "deh_tables.h" // Dehacked list test #include "m_cond.h" // condition initialization #include "fastcmp.h" #include "keys.h" From 4016a2e0622826f35948da1d357be83946450fcc Mon Sep 17 00:00:00 2001 From: GoldenTails Date: Thu, 3 Dec 2020 17:29:39 -0600 Subject: [PATCH 0605/1080] Crash backtrace logging for NEWSIGNALHANDLER. --- src/doomdef.h | 1 + src/sdl/i_main.c | 4 ++ src/sdl/i_system.c | 98 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 103 insertions(+) diff --git a/src/doomdef.h b/src/doomdef.h index 52abc9597..e1cda6f42 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -118,6 +118,7 @@ #ifdef LOGMESSAGES extern FILE *logstream; +extern FILE *crashstream; extern char logfilename[1024]; #endif diff --git a/src/sdl/i_main.c b/src/sdl/i_main.c index 1dee379c0..03783d1ef 100644 --- a/src/sdl/i_main.c +++ b/src/sdl/i_main.c @@ -52,6 +52,7 @@ extern int SDL_main(int argc, char *argv[]); #ifdef LOGMESSAGES FILE *logstream = NULL; +FILE *crashstream = NULL; char logfilename[1024]; #endif @@ -249,6 +250,9 @@ int main(int argc, char **argv) // startup SRB2 CONS_Printf("Setting up SRB2...\n"); D_SRB2Main(); + + crashstream = fopen(va("%s" PATHSEP "%s", srb2home, "crash-log.txt"), "at"); + #ifdef LOGMESSAGES if (!M_CheckParm("-nolog")) CONS_Printf("Logfile: %s\n", logfilename); diff --git a/src/sdl/i_system.c b/src/sdl/i_system.c index d2c819c37..528d495c7 100644 --- a/src/sdl/i_system.c +++ b/src/sdl/i_system.c @@ -137,6 +137,11 @@ typedef LPVOID (WINAPI *p_MapViewOfFile) (HANDLE, DWORD, DWORD, DWORD, SIZE_T); #include #endif +#if defined (__unix__) || defined(__APPLE__) || defined (UNIXCOMMON) +#include +#include +#endif + // Locations for searching the srb2.pk3 #if defined (__unix__) || defined(__APPLE__) || defined (UNIXCOMMON) #define DEFAULTWADLOCATION1 "/usr/local/share/games/SRB2" @@ -238,6 +243,75 @@ SDL_bool framebuffer = SDL_FALSE; UINT8 keyboard_started = false; +#define STDERR_WRITE(string) if (fd != -1) I_OutputMsg("%s", string) +#define CRASHLOG_WRITE(string) if (fd != -1) write(fd, string, strlen(string)) +#define CRASHLOG_STDERR_WRITE(string) \ + if (fd != -1)\ + write(fd, string, strlen(string));\ + I_OutputMsg("%s", string) + +static void write_backtrace(INT32 signal) +{ +#if defined (__unix__) || defined(__APPLE__) || defined (UNIXCOMMON) + int fd = -1; + size_t size; + time_t rawtime; + struct tm * timeinfo; + + enum { MAX_SIZE = 1024 }; + void *array[MAX_SIZE]; + + const char *error = "An error occurred within SRB2! Send this stack trace to someone who can help!\n"; + const char *error2 = "(Or find crash-log.txt in your SRB2 directory.)\n"; // Shown only to stderr. + + if (!crashstream) + crashstream = fopen(va("%s" PATHSEP "%s", srb2home, "crash-log.txt"), "at"); + + if (!crashstream) + I_OutputMsg("\nWARNING: Couldn't open crash log for writing! Make sure your permissions are correct. Please save the below report!\n"); + else + { + fd = fileno(crashstream); + + if (fd == -1) + fd = open(va("%s" PATHSEP "%s", srb2home, "crash-log.txt"), O_CREAT|O_APPEND); + } + + time(&rawtime); + timeinfo = localtime(&rawtime); + + CRASHLOG_WRITE("------------------------\n"); // Nice looking seperator + + CRASHLOG_STDERR_WRITE("\n"); // Newline to look nice for both outputs. + CRASHLOG_STDERR_WRITE(error); // "Oops, SRB2 crashed" message + STDERR_WRITE(error2); // Tell the user where the crash log is. + + // Tell the log when we crashed. + CRASHLOG_WRITE("Time of crash: "); + CRASHLOG_WRITE(asctime(timeinfo)); + + // Give the crash log the cause and a nice 'Backtrace:' thing + // The signal is given to the user when the parent process sees we crashed. + CRASHLOG_WRITE("Cause: "); + CRASHLOG_WRITE(strsignal(signal)); + CRASHLOG_WRITE("\n"); // Newline for the signal name + + CRASHLOG_STDERR_WRITE("\nBacktrace:\n"); + + // Flood the output and log with the backtrace + size = backtrace(array, MAX_SIZE); + backtrace_symbols_fd(array, size, fd); + backtrace_symbols_fd(array, size, STDERR_FILENO); + + CRASHLOG_WRITE("\n"); // Write another newline to the log so it looks nice :) + + close(fd); +#endif +} +#undef STDERR_WRITE +#undef CRASHLOG_WRITE +#undef CRASHLOG_STDERR_WRITE + static void I_ReportSignal(int num, int coredumped) { //static char msg[] = "oh no! back to reality!\r\n"; @@ -298,6 +372,9 @@ FUNCNORETURN static ATTRNORETURN void signal_handler(INT32 num) D_QuitNetGame(); // Fix server freezes CL_AbortDownloadResume(); I_ReportSignal(num, 0); + + write_backtrace(num); + I_ShutdownSystem(); signal(num, SIG_DFL); //default signal action raise(num); @@ -687,6 +764,26 @@ static void I_RegisterSignals (void) #endif } +#ifdef NEWSIGNALHANDLER +static void signal_handler_child(INT32 num) +{ + write_backtrace(num); + + signal(num, SIG_DFL); //default signal action + raise(num); +} + +static void I_RegisterChildSignals(void) +{ + // If these defines don't exist, + // then compilation would have failed above us... + signal(SIGILL , signal_handler_child); + signal(SIGSEGV , signal_handler_child); + signal(SIGABRT , signal_handler_child); + signal(SIGFPE , signal_handler_child); +} +#endif + // //I_OutputMsg // @@ -2123,6 +2220,7 @@ static void I_Fork(void) newsignalhandler_Warn("fork()"); break; case 0: + I_RegisterChildSignals(); break; default: if (logstream) From 5108f1f57b805f7517e703f8c4b973d8489c3aa7 Mon Sep 17 00:00:00 2001 From: GoldenTails Date: Thu, 3 Dec 2020 17:08:40 -0600 Subject: [PATCH 0606/1080] Use file descriptors and ditch file streams, for now. --- src/doomdef.h | 1 - src/sdl/i_main.c | 4 ---- src/sdl/i_system.c | 12 ++---------- 3 files changed, 2 insertions(+), 15 deletions(-) diff --git a/src/doomdef.h b/src/doomdef.h index e1cda6f42..52abc9597 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -118,7 +118,6 @@ #ifdef LOGMESSAGES extern FILE *logstream; -extern FILE *crashstream; extern char logfilename[1024]; #endif diff --git a/src/sdl/i_main.c b/src/sdl/i_main.c index 03783d1ef..1dee379c0 100644 --- a/src/sdl/i_main.c +++ b/src/sdl/i_main.c @@ -52,7 +52,6 @@ extern int SDL_main(int argc, char *argv[]); #ifdef LOGMESSAGES FILE *logstream = NULL; -FILE *crashstream = NULL; char logfilename[1024]; #endif @@ -250,9 +249,6 @@ int main(int argc, char **argv) // startup SRB2 CONS_Printf("Setting up SRB2...\n"); D_SRB2Main(); - - crashstream = fopen(va("%s" PATHSEP "%s", srb2home, "crash-log.txt"), "at"); - #ifdef LOGMESSAGES if (!M_CheckParm("-nolog")) CONS_Printf("Logfile: %s\n", logfilename); diff --git a/src/sdl/i_system.c b/src/sdl/i_system.c index 528d495c7..7c870c0c7 100644 --- a/src/sdl/i_system.c +++ b/src/sdl/i_system.c @@ -264,18 +264,10 @@ static void write_backtrace(INT32 signal) const char *error = "An error occurred within SRB2! Send this stack trace to someone who can help!\n"; const char *error2 = "(Or find crash-log.txt in your SRB2 directory.)\n"; // Shown only to stderr. - if (!crashstream) - crashstream = fopen(va("%s" PATHSEP "%s", srb2home, "crash-log.txt"), "at"); + fd = open(va("%s" PATHSEP "%s", srb2home, "crash-log.txt"), O_CREAT|O_APPEND|O_RDWR, S_IRUSR|S_IWUSR); - if (!crashstream) + if (fd == -1) I_OutputMsg("\nWARNING: Couldn't open crash log for writing! Make sure your permissions are correct. Please save the below report!\n"); - else - { - fd = fileno(crashstream); - - if (fd == -1) - fd = open(va("%s" PATHSEP "%s", srb2home, "crash-log.txt"), O_CREAT|O_APPEND); - } time(&rawtime); timeinfo = localtime(&rawtime); From bdb28a06f4ace02a71375a462696329786dee7e9 Mon Sep 17 00:00:00 2001 From: GoldenTails Date: Thu, 3 Dec 2020 18:23:33 -0600 Subject: [PATCH 0607/1080] Print the backtrace before showing the signal handler popup. --- src/sdl/i_system.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/sdl/i_system.c b/src/sdl/i_system.c index 7c870c0c7..1d1fc2af2 100644 --- a/src/sdl/i_system.c +++ b/src/sdl/i_system.c @@ -363,10 +363,8 @@ FUNCNORETURN static ATTRNORETURN void signal_handler(INT32 num) { D_QuitNetGame(); // Fix server freezes CL_AbortDownloadResume(); - I_ReportSignal(num, 0); - write_backtrace(num); - + I_ReportSignal(num, 0); I_ShutdownSystem(); signal(num, SIG_DFL); //default signal action raise(num); From a0396d5e437929e525805414cc83d207d7db1331 Mon Sep 17 00:00:00 2001 From: GoldenTails Date: Fri, 4 Dec 2020 12:08:50 -0600 Subject: [PATCH 0608/1080] Make it more async-signal-safe --- src/sdl/i_system.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/sdl/i_system.c b/src/sdl/i_system.c index 1d1fc2af2..e8c5d59fb 100644 --- a/src/sdl/i_system.c +++ b/src/sdl/i_system.c @@ -256,10 +256,11 @@ static void write_backtrace(INT32 signal) int fd = -1; size_t size; time_t rawtime; - struct tm * timeinfo; + struct tm timeinfo; - enum { MAX_SIZE = 1024 }; - void *array[MAX_SIZE]; + enum { BT_SIZE = 1024, STR_SIZE = 32 }; + void *array[BT_SIZE]; + char timestr[STR_SIZE]; const char *error = "An error occurred within SRB2! Send this stack trace to someone who can help!\n"; const char *error2 = "(Or find crash-log.txt in your SRB2 directory.)\n"; // Shown only to stderr. @@ -269,8 +270,10 @@ static void write_backtrace(INT32 signal) if (fd == -1) I_OutputMsg("\nWARNING: Couldn't open crash log for writing! Make sure your permissions are correct. Please save the below report!\n"); + // Get the current time as a string. time(&rawtime); - timeinfo = localtime(&rawtime); + localtime_r(&rawtime, &timeinfo); + strftime(timestr, STR_SIZE, "%a, %d %b %Y %T %z", &timeinfo); CRASHLOG_WRITE("------------------------\n"); // Nice looking seperator @@ -280,7 +283,8 @@ static void write_backtrace(INT32 signal) // Tell the log when we crashed. CRASHLOG_WRITE("Time of crash: "); - CRASHLOG_WRITE(asctime(timeinfo)); + CRASHLOG_WRITE(timestr); + CRASHLOG_WRITE("\n"); // Give the crash log the cause and a nice 'Backtrace:' thing // The signal is given to the user when the parent process sees we crashed. @@ -290,8 +294,8 @@ static void write_backtrace(INT32 signal) CRASHLOG_STDERR_WRITE("\nBacktrace:\n"); - // Flood the output and log with the backtrace - size = backtrace(array, MAX_SIZE); + // Flood the output and log with the backtrace + size = backtrace(array, BT_SIZE); backtrace_symbols_fd(array, size, fd); backtrace_symbols_fd(array, size, STDERR_FILENO); From 07ffe2599cc25d5fb46f55f9f78f4e6b0dece019 Mon Sep 17 00:00:00 2001 From: Jaime Ita Passos Date: Sun, 28 Feb 2021 16:23:40 -0300 Subject: [PATCH 0609/1080] Fix thing scale mismatch in R_DrawVisSprite --- src/r_things.c | 4 +++- src/r_things.h | 5 ++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/r_things.c b/src/r_things.c index 30bf15f85..92340cab3 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -796,7 +796,7 @@ static void R_DrawVisSprite(vissprite_t *vis) INT32 pwidth; fixed_t frac; patch_t *patch = vis->patch; - fixed_t this_scale = vis->mobj->scale; + fixed_t this_scale = vis->thingscale; INT32 x1, x2; INT64 overflow_test; @@ -1332,6 +1332,7 @@ static void R_ProjectDropShadow(mobj_t *thing, vissprite_t *vis, fixed_t scale, shadow->xscale = FixedMul(xscale, shadowxscale); //SoM: 4/17/2000 shadow->scale = FixedMul(yscale, shadowyscale); + shadow->thingscale = thing->scale; shadow->sector = vis->sector; shadow->szt = (INT16)((centeryfrac - FixedMul(shadow->gzt - viewz, yscale))>>FRACBITS); shadow->sz = (INT16)((centeryfrac - FixedMul(shadow->gz - viewz, yscale))>>FRACBITS); @@ -1975,6 +1976,7 @@ static void R_ProjectSprite(mobj_t *thing) vis->xscale = FixedMul(spritexscale, xscale); //SoM: 4/17/2000 vis->scale = FixedMul(spriteyscale, yscale); //<thingscale = oldthing->scale; vis->spritexscale = spritexscale; vis->spriteyscale = spriteyscale; diff --git a/src/r_things.h b/src/r_things.h index f960089a1..708b6c24c 100644 --- a/src/r_things.h +++ b/src/r_things.h @@ -155,7 +155,8 @@ typedef struct vissprite_s fixed_t pz, pzt; // physical bottom/top for sorting with 3D floors fixed_t startfrac; // horizontal position of x1 - fixed_t scale; + fixed_t xscale, scale; // projected horizontal and vertical scales + fixed_t thingscale; // the object's scale fixed_t sortscale; // sortscale only differs from scale for paper sprites, floor sprites, and MF2_LINKDRAW fixed_t sortsplat; // the sortscale from behind the floor sprite fixed_t scalestep; // only for paper sprites, 0 otherwise @@ -183,8 +184,6 @@ typedef struct vissprite_s extracolormap_t *extra_colormap; // global colormaps - fixed_t xscale; - // Precalculated top and bottom screen coords for the sprite. fixed_t thingheight; // The actual height of the thing (for 3D floors) sector_t *sector; // The sector containing the thing. From 401271feb7d44bc47b7a4b29aa4de31dbf34b989 Mon Sep 17 00:00:00 2001 From: Jaime Ita Passos Date: Sun, 28 Feb 2021 17:05:25 -0300 Subject: [PATCH 0610/1080] Fix translation colormap cache rebuilding using the old translation enumerations This was causing a buffer underwrite too. Lovely. --- src/r_draw.c | 60 ++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 42 insertions(+), 18 deletions(-) diff --git a/src/r_draw.c b/src/r_draw.c index d9ea942a2..96554fad3 100644 --- a/src/r_draw.c +++ b/src/r_draw.c @@ -134,9 +134,43 @@ UINT32 nflatxshift, nflatyshift, nflatshiftup, nflatmask; #define DEFAULT_STARTTRANSCOLOR 96 #define NUM_PALETTE_ENTRIES 256 -static UINT8** translationtablecache[MAXSKINS + 7] = {NULL}; +static UINT8 **translationtablecache[MAXSKINS + 7] = {NULL}; UINT8 skincolor_modified[MAXSKINCOLORS]; +static INT32 SkinToCacheIndex(INT32 skinnum) +{ + switch (skinnum) + { + case TC_DEFAULT: return DEFAULT_TT_CACHE_INDEX; + case TC_BOSS: return BOSS_TT_CACHE_INDEX; + case TC_METALSONIC: return METALSONIC_TT_CACHE_INDEX; + case TC_ALLWHITE: return ALLWHITE_TT_CACHE_INDEX; + case TC_RAINBOW: return RAINBOW_TT_CACHE_INDEX; + case TC_BLINK: return BLINK_TT_CACHE_INDEX; + case TC_DASHMODE: return DASHMODE_TT_CACHE_INDEX; + default: break; + } + + return skinnum; +} + +static INT32 CacheIndexToSkin(INT32 ttc) +{ + switch (ttc) + { + case DEFAULT_TT_CACHE_INDEX: return TC_DEFAULT; + case BOSS_TT_CACHE_INDEX: return TC_BOSS; + case METALSONIC_TT_CACHE_INDEX: return TC_METALSONIC; + case ALLWHITE_TT_CACHE_INDEX: return TC_ALLWHITE; + case RAINBOW_TT_CACHE_INDEX: return TC_RAINBOW; + case BLINK_TT_CACHE_INDEX: return TC_BLINK; + case DASHMODE_TT_CACHE_INDEX: return TC_DASHMODE; + default: break; + } + + return ttc; +} + CV_PossibleValue_t Color_cons_t[MAXSKINCOLORS+1]; #define TRANSTAB_AMTMUL10 (256.0f / 10.0f) @@ -308,7 +342,7 @@ static void R_RainbowColormap(UINT8 *dest_colormap, UINT16 skincolor) /** \brief Generates a translation colormap. \param dest_colormap colormap to populate - \param skinnum number of skin, TC_DEFAULT or TC_BOSS + \param skinnum skin number, or a translation mode \param color translation color \return void @@ -412,6 +446,9 @@ static void R_GenerateTranslationColormap(UINT8 *dest_colormap, INT32 skinnum, U if (color >= numskincolors) I_Error("Invalid skin color #%hu.", (UINT16)color); + if (skinnum < 0 && skinnum > TC_DEFAULT) + I_Error("Invalid non-translation skin number %d.", skinnum); + starttranscolor = (skinnum != TC_DEFAULT) ? skins[skinnum].starttranscolor : DEFAULT_STARTTRANSCOLOR; if (starttranscolor >= NUM_PALETTE_ENTRIES) @@ -448,25 +485,11 @@ static void R_GenerateTranslationColormap(UINT8 *dest_colormap, INT32 skinnum, U UINT8* R_GetTranslationColormap(INT32 skinnum, skincolornum_t color, UINT8 flags) { UINT8* ret; - INT32 skintableindex; + INT32 skintableindex = SkinToCacheIndex(skinnum); // Adjust if we want the default colormap INT32 i; - // Adjust if we want the default colormap - switch (skinnum) - { - case TC_DEFAULT: skintableindex = DEFAULT_TT_CACHE_INDEX; break; - case TC_BOSS: skintableindex = BOSS_TT_CACHE_INDEX; break; - case TC_METALSONIC: skintableindex = METALSONIC_TT_CACHE_INDEX; break; - 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; - case TC_DASHMODE: skintableindex = DASHMODE_TT_CACHE_INDEX; break; - default: skintableindex = skinnum; break; - } - if (flags & GTC_CACHE) { - // Allocate table for skin if necessary if (!translationtablecache[skintableindex]) translationtablecache[skintableindex] = Z_Calloc(MAXSKINCOLORS * sizeof(UINT8**), PU_STATIC, NULL); @@ -479,7 +502,8 @@ UINT8* R_GetTranslationColormap(INT32 skinnum, skincolornum_t color, UINT8 flags { for (i = 0; i < (INT32)(sizeof(translationtablecache) / sizeof(translationtablecache[0])); i++) if (translationtablecache[i] && translationtablecache[i][color]) - R_GenerateTranslationColormap(translationtablecache[i][color], i>=MAXSKINS ? MAXSKINS-i-1 : i, color); + R_GenerateTranslationColormap(translationtablecache[i][color], CacheIndexToSkin(i), color); + skincolor_modified[color] = false; } } From 94fe7a3d8c66d1417dfd0b07d8d5d59962fa8e3b Mon Sep 17 00:00:00 2001 From: Jaime Ita Passos Date: Sun, 28 Feb 2021 17:47:12 -0300 Subject: [PATCH 0611/1080] Change I_Error message --- src/r_draw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/r_draw.c b/src/r_draw.c index 96554fad3..c3d4efae3 100644 --- a/src/r_draw.c +++ b/src/r_draw.c @@ -447,7 +447,7 @@ static void R_GenerateTranslationColormap(UINT8 *dest_colormap, INT32 skinnum, U I_Error("Invalid skin color #%hu.", (UINT16)color); if (skinnum < 0 && skinnum > TC_DEFAULT) - I_Error("Invalid non-translation skin number %d.", skinnum); + I_Error("Invalid translation colormap index %d.", skinnum); starttranscolor = (skinnum != TC_DEFAULT) ? skins[skinnum].starttranscolor : DEFAULT_STARTTRANSCOLOR; From 6d539626c4f6cd2ba7434571daae3878788a50ac Mon Sep 17 00:00:00 2001 From: James R Date: Sun, 28 Feb 2021 16:12:38 -0800 Subject: [PATCH 0612/1080] I forgot to add the dep directory --- dep/.gitignore | 2 ++ dep/FreeBSD/SDL/Debug/.gitignore | 2 ++ dep/FreeBSD/SDL/Release/.gitignore | 2 ++ dep/Linux/SDL/Debug/.gitignore | 2 ++ dep/Linux/SDL/Release/.gitignore | 2 ++ dep/Linux64/SDL/Debug/.gitignore | 2 ++ dep/Linux64/SDL/Release/.gitignore | 2 ++ dep/MasterClient/.gitignore | 2 ++ dep/MasterServer/.gitignore | 2 ++ dep/Mingw/Debug/.gitignore | 2 ++ dep/Mingw/Release/.gitignore | 2 ++ dep/Mingw/SDL/Debug/.gitignore | 2 ++ dep/Mingw/SDL/Release/.gitignore | 2 ++ dep/Mingw64/Debug/.gitignore | 2 ++ dep/Mingw64/Release/.gitignore | 2 ++ dep/Mingw64/SDL/Debug/.gitignore | 2 ++ dep/Mingw64/SDL/Release/.gitignore | 2 ++ dep/SDL/Release/.gitignore | 2 ++ dep/VC/.gitignore | 2 ++ dep/VC9/.gitignore | 2 ++ dep/cygwin/Debug/.gitignore | 2 ++ dep/cygwin/Release/.gitignore | 2 ++ dep/dummy/.gitignore | 2 ++ 23 files changed, 46 insertions(+) create mode 100644 dep/.gitignore create mode 100644 dep/FreeBSD/SDL/Debug/.gitignore create mode 100644 dep/FreeBSD/SDL/Release/.gitignore create mode 100644 dep/Linux/SDL/Debug/.gitignore create mode 100644 dep/Linux/SDL/Release/.gitignore create mode 100644 dep/Linux64/SDL/Debug/.gitignore create mode 100644 dep/Linux64/SDL/Release/.gitignore create mode 100644 dep/MasterClient/.gitignore create mode 100644 dep/MasterServer/.gitignore create mode 100644 dep/Mingw/Debug/.gitignore create mode 100644 dep/Mingw/Release/.gitignore create mode 100644 dep/Mingw/SDL/Debug/.gitignore create mode 100644 dep/Mingw/SDL/Release/.gitignore create mode 100644 dep/Mingw64/Debug/.gitignore create mode 100644 dep/Mingw64/Release/.gitignore create mode 100644 dep/Mingw64/SDL/Debug/.gitignore create mode 100644 dep/Mingw64/SDL/Release/.gitignore create mode 100644 dep/SDL/Release/.gitignore create mode 100644 dep/VC/.gitignore create mode 100644 dep/VC9/.gitignore create mode 100644 dep/cygwin/Debug/.gitignore create mode 100644 dep/cygwin/Release/.gitignore create mode 100644 dep/dummy/.gitignore diff --git a/dep/.gitignore b/dep/.gitignore new file mode 100644 index 000000000..fb941664f --- /dev/null +++ b/dep/.gitignore @@ -0,0 +1,2 @@ +#All folders +*.d diff --git a/dep/FreeBSD/SDL/Debug/.gitignore b/dep/FreeBSD/SDL/Debug/.gitignore new file mode 100644 index 000000000..42c6dc2c6 --- /dev/null +++ b/dep/FreeBSD/SDL/Debug/.gitignore @@ -0,0 +1,2 @@ +# DON'T REMOVE +# This keeps the folder from disappearing diff --git a/dep/FreeBSD/SDL/Release/.gitignore b/dep/FreeBSD/SDL/Release/.gitignore new file mode 100644 index 000000000..42c6dc2c6 --- /dev/null +++ b/dep/FreeBSD/SDL/Release/.gitignore @@ -0,0 +1,2 @@ +# DON'T REMOVE +# This keeps the folder from disappearing diff --git a/dep/Linux/SDL/Debug/.gitignore b/dep/Linux/SDL/Debug/.gitignore new file mode 100644 index 000000000..42c6dc2c6 --- /dev/null +++ b/dep/Linux/SDL/Debug/.gitignore @@ -0,0 +1,2 @@ +# DON'T REMOVE +# This keeps the folder from disappearing diff --git a/dep/Linux/SDL/Release/.gitignore b/dep/Linux/SDL/Release/.gitignore new file mode 100644 index 000000000..42c6dc2c6 --- /dev/null +++ b/dep/Linux/SDL/Release/.gitignore @@ -0,0 +1,2 @@ +# DON'T REMOVE +# This keeps the folder from disappearing diff --git a/dep/Linux64/SDL/Debug/.gitignore b/dep/Linux64/SDL/Debug/.gitignore new file mode 100644 index 000000000..42c6dc2c6 --- /dev/null +++ b/dep/Linux64/SDL/Debug/.gitignore @@ -0,0 +1,2 @@ +# DON'T REMOVE +# This keeps the folder from disappearing diff --git a/dep/Linux64/SDL/Release/.gitignore b/dep/Linux64/SDL/Release/.gitignore new file mode 100644 index 000000000..42c6dc2c6 --- /dev/null +++ b/dep/Linux64/SDL/Release/.gitignore @@ -0,0 +1,2 @@ +# DON'T REMOVE +# This keeps the folder from disappearing diff --git a/dep/MasterClient/.gitignore b/dep/MasterClient/.gitignore new file mode 100644 index 000000000..42c6dc2c6 --- /dev/null +++ b/dep/MasterClient/.gitignore @@ -0,0 +1,2 @@ +# DON'T REMOVE +# This keeps the folder from disappearing diff --git a/dep/MasterServer/.gitignore b/dep/MasterServer/.gitignore new file mode 100644 index 000000000..42c6dc2c6 --- /dev/null +++ b/dep/MasterServer/.gitignore @@ -0,0 +1,2 @@ +# DON'T REMOVE +# This keeps the folder from disappearing diff --git a/dep/Mingw/Debug/.gitignore b/dep/Mingw/Debug/.gitignore new file mode 100644 index 000000000..42c6dc2c6 --- /dev/null +++ b/dep/Mingw/Debug/.gitignore @@ -0,0 +1,2 @@ +# DON'T REMOVE +# This keeps the folder from disappearing diff --git a/dep/Mingw/Release/.gitignore b/dep/Mingw/Release/.gitignore new file mode 100644 index 000000000..42c6dc2c6 --- /dev/null +++ b/dep/Mingw/Release/.gitignore @@ -0,0 +1,2 @@ +# DON'T REMOVE +# This keeps the folder from disappearing diff --git a/dep/Mingw/SDL/Debug/.gitignore b/dep/Mingw/SDL/Debug/.gitignore new file mode 100644 index 000000000..42c6dc2c6 --- /dev/null +++ b/dep/Mingw/SDL/Debug/.gitignore @@ -0,0 +1,2 @@ +# DON'T REMOVE +# This keeps the folder from disappearing diff --git a/dep/Mingw/SDL/Release/.gitignore b/dep/Mingw/SDL/Release/.gitignore new file mode 100644 index 000000000..42c6dc2c6 --- /dev/null +++ b/dep/Mingw/SDL/Release/.gitignore @@ -0,0 +1,2 @@ +# DON'T REMOVE +# This keeps the folder from disappearing diff --git a/dep/Mingw64/Debug/.gitignore b/dep/Mingw64/Debug/.gitignore new file mode 100644 index 000000000..42c6dc2c6 --- /dev/null +++ b/dep/Mingw64/Debug/.gitignore @@ -0,0 +1,2 @@ +# DON'T REMOVE +# This keeps the folder from disappearing diff --git a/dep/Mingw64/Release/.gitignore b/dep/Mingw64/Release/.gitignore new file mode 100644 index 000000000..42c6dc2c6 --- /dev/null +++ b/dep/Mingw64/Release/.gitignore @@ -0,0 +1,2 @@ +# DON'T REMOVE +# This keeps the folder from disappearing diff --git a/dep/Mingw64/SDL/Debug/.gitignore b/dep/Mingw64/SDL/Debug/.gitignore new file mode 100644 index 000000000..42c6dc2c6 --- /dev/null +++ b/dep/Mingw64/SDL/Debug/.gitignore @@ -0,0 +1,2 @@ +# DON'T REMOVE +# This keeps the folder from disappearing diff --git a/dep/Mingw64/SDL/Release/.gitignore b/dep/Mingw64/SDL/Release/.gitignore new file mode 100644 index 000000000..42c6dc2c6 --- /dev/null +++ b/dep/Mingw64/SDL/Release/.gitignore @@ -0,0 +1,2 @@ +# DON'T REMOVE +# This keeps the folder from disappearing diff --git a/dep/SDL/Release/.gitignore b/dep/SDL/Release/.gitignore new file mode 100644 index 000000000..42c6dc2c6 --- /dev/null +++ b/dep/SDL/Release/.gitignore @@ -0,0 +1,2 @@ +# DON'T REMOVE +# This keeps the folder from disappearing diff --git a/dep/VC/.gitignore b/dep/VC/.gitignore new file mode 100644 index 000000000..42c6dc2c6 --- /dev/null +++ b/dep/VC/.gitignore @@ -0,0 +1,2 @@ +# DON'T REMOVE +# This keeps the folder from disappearing diff --git a/dep/VC9/.gitignore b/dep/VC9/.gitignore new file mode 100644 index 000000000..42c6dc2c6 --- /dev/null +++ b/dep/VC9/.gitignore @@ -0,0 +1,2 @@ +# DON'T REMOVE +# This keeps the folder from disappearing diff --git a/dep/cygwin/Debug/.gitignore b/dep/cygwin/Debug/.gitignore new file mode 100644 index 000000000..42c6dc2c6 --- /dev/null +++ b/dep/cygwin/Debug/.gitignore @@ -0,0 +1,2 @@ +# DON'T REMOVE +# This keeps the folder from disappearing diff --git a/dep/cygwin/Release/.gitignore b/dep/cygwin/Release/.gitignore new file mode 100644 index 000000000..42c6dc2c6 --- /dev/null +++ b/dep/cygwin/Release/.gitignore @@ -0,0 +1,2 @@ +# DON'T REMOVE +# This keeps the folder from disappearing diff --git a/dep/dummy/.gitignore b/dep/dummy/.gitignore new file mode 100644 index 000000000..42c6dc2c6 --- /dev/null +++ b/dep/dummy/.gitignore @@ -0,0 +1,2 @@ +# DON'T REMOVE +# This keeps the folder from disappearing From 5f4e21ed3a97063c917d7f9ff406548b7e873ddd Mon Sep 17 00:00:00 2001 From: James R Date: Sun, 28 Feb 2021 17:02:08 -0800 Subject: [PATCH 0613/1080] Fix dependency file trying to be made for SRB2.res and not for interface/blua/hardware files --- src/Makefile | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/Makefile b/src/Makefile index 260175a69..471c55ed3 100644 --- a/src/Makefile +++ b/src/Makefile @@ -554,7 +554,7 @@ OBJS:=$(i_main_o) \ $(i_sound_o) \ $(OBJS) -DEPS:=$(patsubst $(OBJDIR)/%.o,$(DEPDIR)/%.d,$(OBJS)) +DEPS:=$(patsubst $(OBJDIR)/%.o,$(DEPDIR)/%.d,$(filter %.o,$(OBJS))) OBJS+=$(OBJDIR)/comptime.o ifndef SILENT @@ -688,14 +688,33 @@ $(call print,Checking dependency files...) endif endif -$(DEPDIR)/%.d: %.c +undefine deps_rule + # windows makes it too hard ! ifndef WINDOWSHELL ifdef echoName +define deps_rule = @printf "%-20.20s\r" $< + +endef endif endif + +define deps_rule += $(CC) $(CFLAGS) -M -MF $@ -MT $(OBJDIR)/$< $< +endef + +$(DEPDIR)/%.d: %.c + $(deps_rule) + +$(DEPDIR)/%.d: $(INTERFACE)/%.c + $(deps_rule) + +$(DEPDIR)/%.d: hardware/%.c + $(deps_rule) + +$(DEPDIR)/%.d: blua/%.c + $(deps_rule) ifdef VALGRIND $(OBJDIR)/z_zone.o: z_zone.c From f6cb1798ccfc161264c3039bd294c0e061f650a7 Mon Sep 17 00:00:00 2001 From: Jaime Ita Passos Date: Tue, 2 Mar 2021 02:27:14 -0300 Subject: [PATCH 0614/1080] Fix a few renderflags oversights in OpenGL --- src/hardware/hw_main.c | 40 ++++++++++++++++++---------------------- src/hardware/hw_md2.c | 11 +++++------ 2 files changed, 23 insertions(+), 28 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index a7e37d231..c2d617eaf 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -3665,7 +3665,7 @@ static void HWR_DrawDropShadow(mobj_t *thing, fixed_t scale) static void HWR_RotateSpritePolyToAim(gl_vissprite_t *spr, FOutVector *wallVerts, const boolean precip) { if (cv_glspritebillboarding.value - && spr && spr->mobj && !(spr->mobj->frame & FF_PAPERSPRITE) + && spr && spr->mobj && !R_ThingIsPaperSprite(spr->mobj) && wallVerts) { float basey = FIXED_TO_FLOAT(spr->mobj->z); @@ -3707,7 +3707,6 @@ static void HWR_SplitSprite(gl_vissprite_t *spr) FBITFIELD blend = 0; FBITFIELD occlusion; boolean use_linkdraw_hack = false; - boolean splat = R_ThingIsFloorSprite(spr->mobj); UINT8 alpha; INT32 i; @@ -3766,22 +3765,19 @@ static void HWR_SplitSprite(gl_vissprite_t *spr) baseWallVerts[0].t = baseWallVerts[1].t = ((GLPatch_t *)gpatch->hardware)->max_t; } - if (!splat) - { - // if it has a dispoffset, push it a little towards the camera - if (spr->dispoffset) { - float co = -gl_viewcos*(0.05f*spr->dispoffset); - float si = -gl_viewsin*(0.05f*spr->dispoffset); - baseWallVerts[0].z = baseWallVerts[3].z = baseWallVerts[0].z+si; - baseWallVerts[1].z = baseWallVerts[2].z = baseWallVerts[1].z+si; - baseWallVerts[0].x = baseWallVerts[3].x = baseWallVerts[0].x+co; - baseWallVerts[1].x = baseWallVerts[2].x = baseWallVerts[1].x+co; - } - - // Let dispoffset work first since this adjust each vertex - HWR_RotateSpritePolyToAim(spr, baseWallVerts, false); + // if it has a dispoffset, push it a little towards the camera + if (spr->dispoffset) { + float co = -gl_viewcos*(0.05f*spr->dispoffset); + float si = -gl_viewsin*(0.05f*spr->dispoffset); + baseWallVerts[0].z = baseWallVerts[3].z = baseWallVerts[0].z+si; + baseWallVerts[1].z = baseWallVerts[2].z = baseWallVerts[1].z+si; + baseWallVerts[0].x = baseWallVerts[3].x = baseWallVerts[0].x+co; + baseWallVerts[1].x = baseWallVerts[2].x = baseWallVerts[1].x+co; } + // Let dispoffset work first since this adjust each vertex + HWR_RotateSpritePolyToAim(spr, baseWallVerts, false); + realtop = top = baseWallVerts[3].y; realbot = bot = baseWallVerts[0].y; ttop = baseWallVerts[3].t; @@ -3914,7 +3910,7 @@ static void HWR_SplitSprite(gl_vissprite_t *spr) // The x and y only need to be adjusted in the case that it's not a papersprite if (cv_glspritebillboarding.value - && spr->mobj && !(spr->mobj->frame & FF_PAPERSPRITE)) + && spr->mobj && !R_ThingIsPaperSprite(spr->mobj)) { // Get the x and z of the vertices so billboarding draws correctly realheight = realbot - realtop; @@ -3983,7 +3979,7 @@ static void HWR_SplitSprite(gl_vissprite_t *spr) static void HWR_DrawSprite(gl_vissprite_t *spr) { FOutVector wallVerts[4]; - patch_t *gpatch; // sprite patch converted to hardware + patch_t *gpatch; FSurfaceInfo Surf; const boolean splat = R_ThingIsFloorSprite(spr->mobj); @@ -4284,7 +4280,7 @@ static inline void HWR_DrawPrecipitationSprite(gl_vissprite_t *spr) { FBITFIELD blend = 0; FOutVector wallVerts[4]; - patch_t *gpatch; // sprite patch converted to hardware + patch_t *gpatch; FSurfaceInfo Surf; if (!spr->mobj) @@ -4337,7 +4333,7 @@ static inline void HWR_DrawPrecipitationSprite(gl_vissprite_t *spr) // Always use the light at the top instead of whatever I was doing before INT32 light = R_GetPlaneLight(sector, spr->mobj->z + spr->mobj->height, false); - if (!(spr->mobj->frame & FF_FULLBRIGHT)) + if (!R_ThingIsFullBright(spr->mobj)) lightlevel = *sector->lightlist[light].lightlevel > 255 ? 255 : *sector->lightlist[light].lightlevel; if (*sector->lightlist[light].extra_colormap) @@ -4345,7 +4341,7 @@ static inline void HWR_DrawPrecipitationSprite(gl_vissprite_t *spr) } else { - if (!(spr->mobj->frame & FF_FULLBRIGHT)) + if (!R_ThingIsFullBright(spr->mobj)) lightlevel = sector->lightlevel > 255 ? 255 : sector->lightlevel; if (sector->extra_colormap) @@ -4921,8 +4917,8 @@ static void HWR_ProjectSprite(mobj_t *thing) angle_t ang; INT32 heightsec, phs; - const boolean papersprite = R_ThingIsPaperSprite(thing); const boolean splat = R_ThingIsFloorSprite(thing); + const boolean papersprite = (R_ThingIsPaperSprite(thing) && !splat); angle_t mobjangle = (thing->player ? thing->player->drawangle : thing->angle); float z1, z2; diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index 2e944d3e6..3ef746b9f 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -1314,7 +1314,7 @@ boolean HWR_DrawModel(gl_vissprite_t *spr) light = R_GetPlaneLight(sector, spr->mobj->z + spr->mobj->height, false); // Always use the light at the top instead of whatever I was doing before - if (!(spr->mobj->frame & FF_FULLBRIGHT)) + if (!R_ThingIsFullBright(spr->mobj)) lightlevel = *sector->lightlist[light].lightlevel > 255 ? 255 : *sector->lightlist[light].lightlevel; if (*sector->lightlist[light].extra_colormap) @@ -1322,7 +1322,7 @@ boolean HWR_DrawModel(gl_vissprite_t *spr) } else { - if (!(spr->mobj->frame & FF_FULLBRIGHT)) + if (!R_ThingIsFullBright(spr->mobj)) lightlevel = sector->lightlevel > 255 ? 255 : sector->lightlevel; if (sector->extra_colormap) @@ -1340,10 +1340,9 @@ boolean HWR_DrawModel(gl_vissprite_t *spr) GLPatch_t *hwrPatch = NULL, *hwrBlendPatch = NULL; INT32 durs = spr->mobj->state->tics; INT32 tics = spr->mobj->tics; - //mdlframe_t *next = NULL; - const boolean papersprite = (spr->mobj->frame & FF_PAPERSPRITE); - const UINT8 flip = (UINT8)(!(spr->mobj->eflags & MFE_VERTICALFLIP) != !(spr->mobj->frame & FF_VERTICALFLIP)); - const UINT8 hflip = (UINT8)(!(spr->mobj->mirrored) != !(spr->mobj->frame & FF_HORIZONTALFLIP)); + const boolean papersprite = (R_ThingIsPaperSprite(spr->mobj) && !R_ThingIsFloorSprite(spr->mobj)); + const UINT8 flip = (UINT8)(!(spr->mobj->eflags & MFE_VERTICALFLIP) != !R_ThingVerticallyFlipped(spr->mobj)); + const UINT8 hflip = (UINT8)(!(spr->mobj->mirrored) != !R_ThingHorizontallyFlipped(spr->mobj)); spritedef_t *sprdef; spriteframe_t *sprframe; spriteinfo_t *sprinfo; From caab4e96cd5b59b603b77b672ea1edaa1052a095 Mon Sep 17 00:00:00 2001 From: Hannu Hanhi Date: Sat, 6 Mar 2021 19:38:17 +0200 Subject: [PATCH 0615/1080] Remove misplaced SetShader call in CompileShaders --- src/hardware/r_opengl/r_opengl.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index 2568a7d08..6967bab74 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -962,8 +962,6 @@ EXPORT boolean HWRAPI(CompileShaders) (void) } } - SetShader(SHADER_DEFAULT); - return true; #else return false; From 8cc49a0f2e3a658495094c3972f6c69376bd6a26 Mon Sep 17 00:00:00 2001 From: Hannu Hanhi Date: Sat, 6 Mar 2021 19:56:25 +0200 Subject: [PATCH 0616/1080] Use double precision in R_StoreWallRange sloped seg culling calculations Fixes culling issues in CEZ2 skybox --- src/r_segs.c | 47 +++++++++++++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 20 deletions(-) diff --git a/src/r_segs.c b/src/r_segs.c index c79071e9b..a6772f964 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -1649,23 +1649,26 @@ void R_StoreWallRange(INT32 start, INT32 stop) // left temp = xtoviewangle[start]+viewangle; +#define FIXED_TO_DOUBLE(x) (((double)(x)) / ((double)FRACUNIT)) +#define DOUBLE_TO_FIXED(x) (fixed_t)((x) * ((double)FRACUNIT)) + { // Both lines can be written in slope-intercept form, so figure out line intersection - float a1, b1, c1, a2, b2, c2, det; // 1 is the seg, 2 is the view angle vector... - ///TODO: convert to FPU + double a1, b1, c1, a2, b2, c2, det; // 1 is the seg, 2 is the view angle vector... + ///TODO: convert to fixed point - a1 = FIXED_TO_FLOAT(curline->v2->y-curline->v1->y); - b1 = FIXED_TO_FLOAT(curline->v1->x-curline->v2->x); - c1 = a1*FIXED_TO_FLOAT(curline->v1->x) + b1*FIXED_TO_FLOAT(curline->v1->y); + a1 = FIXED_TO_DOUBLE(curline->v2->y-curline->v1->y); + b1 = FIXED_TO_DOUBLE(curline->v1->x-curline->v2->x); + c1 = a1*FIXED_TO_DOUBLE(curline->v1->x) + b1*FIXED_TO_DOUBLE(curline->v1->y); - a2 = -FIXED_TO_FLOAT(FINESINE(temp>>ANGLETOFINESHIFT)); - b2 = FIXED_TO_FLOAT(FINECOSINE(temp>>ANGLETOFINESHIFT)); - c2 = a2*FIXED_TO_FLOAT(viewx) + b2*FIXED_TO_FLOAT(viewy); + a2 = -FIXED_TO_DOUBLE(FINESINE(temp>>ANGLETOFINESHIFT)); + b2 = FIXED_TO_DOUBLE(FINECOSINE(temp>>ANGLETOFINESHIFT)); + c2 = a2*FIXED_TO_DOUBLE(viewx) + b2*FIXED_TO_DOUBLE(viewy); det = a1*b2 - a2*b1; - ds_p->leftpos.x = segleft.x = FLOAT_TO_FIXED((b2*c1 - b1*c2)/det); - ds_p->leftpos.y = segleft.y = FLOAT_TO_FIXED((a1*c2 - a2*c1)/det); + ds_p->leftpos.x = segleft.x = DOUBLE_TO_FIXED((b2*c1 - b1*c2)/det); + ds_p->leftpos.y = segleft.y = DOUBLE_TO_FIXED((a1*c2 - a2*c1)/det); } // right @@ -1673,22 +1676,26 @@ void R_StoreWallRange(INT32 start, INT32 stop) { // Both lines can be written in slope-intercept form, so figure out line intersection - float a1, b1, c1, a2, b2, c2, det; // 1 is the seg, 2 is the view angle vector... - ///TODO: convert to FPU + double a1, b1, c1, a2, b2, c2, det; // 1 is the seg, 2 is the view angle vector... + ///TODO: convert to fixed point - a1 = FIXED_TO_FLOAT(curline->v2->y-curline->v1->y); - b1 = FIXED_TO_FLOAT(curline->v1->x-curline->v2->x); - c1 = a1*FIXED_TO_FLOAT(curline->v1->x) + b1*FIXED_TO_FLOAT(curline->v1->y); + a1 = FIXED_TO_DOUBLE(curline->v2->y-curline->v1->y); + b1 = FIXED_TO_DOUBLE(curline->v1->x-curline->v2->x); + c1 = a1*FIXED_TO_DOUBLE(curline->v1->x) + b1*FIXED_TO_DOUBLE(curline->v1->y); - a2 = -FIXED_TO_FLOAT(FINESINE(temp>>ANGLETOFINESHIFT)); - b2 = FIXED_TO_FLOAT(FINECOSINE(temp>>ANGLETOFINESHIFT)); - c2 = a2*FIXED_TO_FLOAT(viewx) + b2*FIXED_TO_FLOAT(viewy); + a2 = -FIXED_TO_DOUBLE(FINESINE(temp>>ANGLETOFINESHIFT)); + b2 = FIXED_TO_DOUBLE(FINECOSINE(temp>>ANGLETOFINESHIFT)); + c2 = a2*FIXED_TO_DOUBLE(viewx) + b2*FIXED_TO_DOUBLE(viewy); det = a1*b2 - a2*b1; - ds_p->rightpos.x = segright.x = FLOAT_TO_FIXED((b2*c1 - b1*c2)/det); - ds_p->rightpos.y = segright.y = FLOAT_TO_FIXED((a1*c2 - a2*c1)/det); + ds_p->rightpos.x = segright.x = DOUBLE_TO_FIXED((b2*c1 - b1*c2)/det); + ds_p->rightpos.y = segright.y = DOUBLE_TO_FIXED((a1*c2 - a2*c1)/det); } + +#undef FIXED_TO_DOUBLE +#undef DOUBLE_TO_FIXED + } From efdfa55328c68a53c9d821537a2c60f6a68f4f08 Mon Sep 17 00:00:00 2001 From: LJ Sonic Date: Fri, 12 Mar 2021 19:54:01 +0100 Subject: [PATCH 0617/1080] Remove misleading comment --- src/lua_maplib.c | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/src/lua_maplib.c b/src/lua_maplib.c index 9598f7708..016141796 100644 --- a/src/lua_maplib.c +++ b/src/lua_maplib.c @@ -583,17 +583,6 @@ static int sector_get(lua_State *L) lua_pushinteger(L, sector->special); return 1; case sector_tag: - // HELLO - // THIS IS LJ SONIC - // HOW IS YOUR DAY? - // BY THE WAY WHEN 2.3 OR 3.0 OR 4.0 OR SRB3 OR SRB4 OR WHATEVER IS OUT - // YOU SHOULD REMEMBER TO CHANGE THIS SO IT ALWAYS RETURNS A UNSIGNED VALUE - // HAVE A NICE DAY - // - // - // - // - // you are ugly lua_pushinteger(L, (UINT16)Tag_FGet(§or->tags)); return 1; case sector_taglist: From 746c84e0b5431c55841d91ac2cbfbd1ef78b0ebf Mon Sep 17 00:00:00 2001 From: Hannu Hanhi Date: Sat, 13 Mar 2021 23:07:51 +0200 Subject: [PATCH 0618/1080] Fix wrong color on player models' first frame by updating variable after loading blend texture --- src/hardware/hw_md2.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index 2e944d3e6..aa005c2fd 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -1405,6 +1405,11 @@ boolean HWR_DrawModel(gl_vissprite_t *spr) || ((!hwrBlendPatch->mipmap->format || !hwrBlendPatch->mipmap->downloaded) && !md2->noblendfile))) md2_loadBlendTexture(md2); + // Load it again, because it isn't being loaded into blendgpatch after md2_loadblendtexture... + blendgpatch = md2->blendgrpatch; + if (blendgpatch) + hwrBlendPatch = ((GLPatch_t *)blendgpatch->hardware); + if (md2->error) return false; // we already failed loading this before :( if (!md2->model) From 36c2be283caad32c51093872f73aa5db6dcb9b4c Mon Sep 17 00:00:00 2001 From: lachablock Date: Mon, 15 Mar 2021 15:17:55 +1100 Subject: [PATCH 0619/1080] Disallow write_backtrace on Windows entirely --- src/sdl/i_system.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/sdl/i_system.c b/src/sdl/i_system.c index e8c5d59fb..a0dd6e1da 100644 --- a/src/sdl/i_system.c +++ b/src/sdl/i_system.c @@ -140,6 +140,7 @@ typedef LPVOID (WINAPI *p_MapViewOfFile) (HANDLE, DWORD, DWORD, DWORD, SIZE_T); #if defined (__unix__) || defined(__APPLE__) || defined (UNIXCOMMON) #include #include +#define UNIXBACKTRACE #endif // Locations for searching the srb2.pk3 @@ -243,6 +244,7 @@ SDL_bool framebuffer = SDL_FALSE; UINT8 keyboard_started = false; +#ifdef UNIXBACKTRACE #define STDERR_WRITE(string) if (fd != -1) I_OutputMsg("%s", string) #define CRASHLOG_WRITE(string) if (fd != -1) write(fd, string, strlen(string)) #define CRASHLOG_STDERR_WRITE(string) \ @@ -252,7 +254,6 @@ UINT8 keyboard_started = false; static void write_backtrace(INT32 signal) { -#if defined (__unix__) || defined(__APPLE__) || defined (UNIXCOMMON) int fd = -1; size_t size; time_t rawtime; @@ -302,11 +303,11 @@ static void write_backtrace(INT32 signal) CRASHLOG_WRITE("\n"); // Write another newline to the log so it looks nice :) close(fd); -#endif } #undef STDERR_WRITE #undef CRASHLOG_WRITE #undef CRASHLOG_STDERR_WRITE +#endif // UNIXBACKTRACE static void I_ReportSignal(int num, int coredumped) { @@ -367,7 +368,9 @@ FUNCNORETURN static ATTRNORETURN void signal_handler(INT32 num) { D_QuitNetGame(); // Fix server freezes CL_AbortDownloadResume(); +#ifdef UNIXBACKTRACE write_backtrace(num); +#endif I_ReportSignal(num, 0); I_ShutdownSystem(); signal(num, SIG_DFL); //default signal action @@ -761,7 +764,9 @@ static void I_RegisterSignals (void) #ifdef NEWSIGNALHANDLER static void signal_handler_child(INT32 num) { +#ifdef UNIXBACKTRACE write_backtrace(num); +#endif signal(num, SIG_DFL); //default signal action raise(num); From 95eff8cbc5f4b0be2ae09a83b8fc04e654a81579 Mon Sep 17 00:00:00 2001 From: sphere Date: Mon, 15 Mar 2021 18:11:02 +0100 Subject: [PATCH 0620/1080] Avoid savemoddata being set in W_InitFile to fix addons with gamedata. --- 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 2cbcdecb5..91c8331f7 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -821,7 +821,8 @@ UINT16 W_InitFile(const char *filename, boolean mainfile, boolean startup) } if (important && !mainfile) - G_SetGameModified(true); + //G_SetGameModified(true); + modifiedgame = true; // avoid savemoddata being set to false // // link wad file to search files From 0c22fecafa04ad263cfa411833835ca6415b2c4b Mon Sep 17 00:00:00 2001 From: sphere Date: Wed, 17 Mar 2021 12:42:18 +0100 Subject: [PATCH 0621/1080] Make horizontal springs above floors put the player in spring state. --- src/p_map.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/p_map.c b/src/p_map.c index a1cad524e..214d2096e 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -419,10 +419,10 @@ boolean P_DoSpring(mobj_t *spring, mobj_t *object) } else if (object->player->dashmode >= DASHMODE_THRESHOLD) P_SetPlayerMobjState(object, S_PLAY_DASH); - else if (P_IsObjectOnGround(object) && horizspeed >= FixedMul(object->player->runspeed, object->scale)) - P_SetPlayerMobjState(object, S_PLAY_RUN); + else if (P_IsObjectOnGround(object)) + P_SetPlayerMobjState(object, (horizspeed >= FixedMul(object->player->runspeed, object->scale)) ? S_PLAY_RUN : S_PLAY_WALK); else - P_SetPlayerMobjState(object, S_PLAY_WALK); + P_SetPlayerMobjState(object, (object->momz > 0) ? S_PLAY_SPRING : S_PLAY_FALL); } else if (P_MobjFlip(object)*vertispeed > 0) P_SetPlayerMobjState(object, S_PLAY_SPRING); From b882aea2e4286ccdc3f82bf5cc0bdbc51bd4e8fd Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Sun, 21 Mar 2021 19:49:32 +0000 Subject: [PATCH 0622/1080] Fix clobbering error in hw_md2.c by adding "volatile" to png_FILE. (Apparently Kart made this exact fix 2 years ago and it was never backported?) --- 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 ac637dfb7..5caf344f7 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -158,7 +158,7 @@ static GLTextureFormat_t PNG_Load(const char *filename, int *w, int *h, GLPatch_ jmp_buf jmpbuf; #endif #endif - png_FILE_p png_FILE; + volatile png_FILE_p png_FILE; //Filename checking fixed ~Monster Iestyn and Golden char *pngfilename = va("%s"PATHSEP"models"PATHSEP"%s", srb2home, filename); From 42cfcbf7be35372fb10363858488b6f68e74fa22 Mon Sep 17 00:00:00 2001 From: katsy Date: Sun, 21 Mar 2021 16:09:11 -0500 Subject: [PATCH 0623/1080] fix sigsegv in A_Custom3DRotate --- src/p_enemy.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/p_enemy.c b/src/p_enemy.c index 203e04af1..ceacc1962 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -9868,22 +9868,23 @@ void A_Custom3DRotate(mobj_t *actor) if (LUA_CallAction(A_CUSTOM3DROTATE, actor)) return; + if (!actor->target) // Ensure we actually have a target first. + { + CONS_Printf("Error: A_Custom3DRotate: Object has no target.\n"); + P_RemoveMobj(actor); + return; + } + if (actor->target->health == 0) { P_RemoveMobj(actor); return; } - if (!actor->target) // This should NEVER happen. - { - if (cv_debug) - CONS_Printf("Error: Object has no target\n"); - P_RemoveMobj(actor); - return; - } if (hspeed==0 && vspeed==0) { - CONS_Printf("Error: A_Custom3DRotate: Object has no speed.\n"); + if (cv_debug) + CONS_Printf("Error: A_Custom3DRotate: Object has no speed.\n"); return; } From 2aaaddae7c46e8f3ec108841bc1903cd54fd450a Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Mon, 22 Mar 2021 14:17:22 +0000 Subject: [PATCH 0624/1080] Fix mistake I made with my previous commit for r_skins.c --- src/r_skins.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/r_skins.c b/src/r_skins.c index 228ec46d0..c56f55e01 100644 --- a/src/r_skins.c +++ b/src/r_skins.c @@ -303,7 +303,7 @@ void SetPlayerSkin(INT32 playernum, const char *skinname) if ((i != -1) && R_SkinUsable(playernum, i)) { - SetSkin(playernum, i); + SetSkin(player, i); return; } From ee8acccd3cd54b87d2f9effa3f49aa8a8cbd969f Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Mon, 22 Mar 2021 14:43:26 +0000 Subject: [PATCH 0625/1080] RETURN OF THE PORTS CHOPPING BLOCK: Destroy DOS! Remove all remaining traces of the following macros for the obsolete DOS port, which were missed previously: * `DJGPP` * `__DJGPP__` * `DJGPPDOS` * `PC_DOS` * `WATTCP` May get rid of `MSDOS` later once I get word on whether I should kill it or not --- src/Makefile | 3 -- src/d_main.h | 4 -- src/d_netfil.c | 6 +-- src/doomdef.h | 2 +- src/doomtype.h | 13 +----- src/i_addrinfo.c | 2 +- src/i_tcp.c | 106 ++--------------------------------------------- src/m_fixed.h | 2 +- src/m_misc.c | 2 - src/s_sound.c | 2 - 10 files changed, 8 insertions(+), 134 deletions(-) diff --git a/src/Makefile b/src/Makefile index 9518942b2..929612271 100644 --- a/src/Makefile +++ b/src/Makefile @@ -98,7 +98,6 @@ ALL_SYSTEMS=\ MINGW64\ HAIKU\ DUMMY\ - DJGPPDOS\ MINGW\ UNIX\ LINUX\ @@ -622,8 +621,6 @@ asm: $(REMOVE) $(OBJDIR)/tmp.exe # executable -# NOTE: DJGPP's objcopy do not have --add-gnu-debuglink - $(BIN)/$(EXENAME): $(POS) $(OBJS) -$(MKDIR) $(BIN) $(call echo,Linking $(EXENAME)...) diff --git a/src/d_main.h b/src/d_main.h index 81de0634d..4e5df87e3 100644 --- a/src/d_main.h +++ b/src/d_main.h @@ -40,10 +40,6 @@ void D_SRB2Main(void); // Called by IO functions when input is detected. void D_PostEvent(const event_t *ev); -#if defined (PC_DOS) && !defined (DOXYGEN) -void D_PostEvent_end(void); // delimiter for locking memory -#endif - void D_ProcessEvents(void); const char *D_Home(void); diff --git a/src/d_netfil.c b/src/d_netfil.c index 8f661bb5f..4729eb09d 100644 --- a/src/d_netfil.c +++ b/src/d_netfil.c @@ -15,7 +15,7 @@ #include -#if defined (_WIN32) || defined (__DJGPP__) +#ifdef _WIN32 #include #include #else @@ -30,10 +30,6 @@ #elif defined (_WIN32) #include #endif -#ifdef __DJGPP__ -#include -#include -#endif #include "doomdef.h" #include "doomstat.h" diff --git a/src/doomdef.h b/src/doomdef.h index 52abc9597..5f36f2d69 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -100,7 +100,7 @@ #include #include -#if defined (_WIN32) || defined (__DJGPP__) +#ifdef _WIN32 #include #endif diff --git a/src/doomtype.h b/src/doomtype.h index 950f50856..ffaa540b1 100644 --- a/src/doomtype.h +++ b/src/doomtype.h @@ -54,17 +54,6 @@ typedef long ssize_t; #define PDWORD_PTR PDWORD #endif #endif -#elif defined (__DJGPP__) -#define UINT8 unsigned char -#define SINT8 signed char - -#define UINT16 unsigned short int -#define INT16 signed short int - -#define INT32 signed long -#define UINT32 unsigned long -#define INT64 signed long long -#define UINT64 unsigned long long #else #define __STDC_LIMIT_MACROS #include @@ -136,7 +125,7 @@ char *strcasestr(const char *in, const char *what); #endif #endif //macintosh -#if defined (PC_DOS) || defined (_WIN32) || defined (__HAIKU__) +#if defined (_WIN32) || defined (__HAIKU__) #define HAVE_DOSSTR_FUNCS #endif diff --git a/src/i_addrinfo.c b/src/i_addrinfo.c index e77774549..ff0dfbd32 100644 --- a/src/i_addrinfo.c +++ b/src/i_addrinfo.c @@ -20,7 +20,7 @@ #else #include #endif -#elif !defined (__DJGPP__) +#else #include #include #include diff --git a/src/i_tcp.c b/src/i_tcp.c index ab8a69a9f..a9f617dc9 100644 --- a/src/i_tcp.c +++ b/src/i_tcp.c @@ -107,15 +107,6 @@ #endif #endif // USE_WINSOCK - #ifdef __DJGPP__ - #ifdef WATTCP // Alam_GBC: Wattcp may need this - #include - #define strerror strerror_s - #else // wattcp - #include - #endif // libsocket - #endif // djgpp - typedef union { struct sockaddr any; @@ -149,25 +140,15 @@ #include "doomstat.h" -// win32 or djgpp -#if defined (USE_WINSOCK) || defined (__DJGPP__) +// win32 +#ifdef USE_WINSOCK // winsock stuff (in winsock a socket is not a file) #define ioctl ioctlsocket #define close closesocket #endif #include "i_addrinfo.h" - -#ifdef __DJGPP__ - -#ifdef WATTCP #define SELECTTEST -#endif - -#else -#define SELECTTEST -#endif - #define DEFAULTPORT "5029" #if defined (USE_WINSOCK) && !defined (NONET) @@ -184,7 +165,7 @@ #ifndef NONET // define socklen_t in DOS/Windows if it is not already defined - #if (defined (WATTCP) && !defined (__libsocket_socklen_t)) || defined (USE_WINSOCK1) + #ifdef USE_WINSOCK1 typedef int socklen_t; #endif static SOCKET_TYPE mysockets[MAXNETNODES+1] = {ERRSOCKET}; @@ -207,19 +188,6 @@ static const char *serverport_name = DEFAULTPORT; static const char *clientport_name;/* any port */ #ifndef NONET - -#ifdef WATTCP -static void wattcp_outch(char s) -{ - static char old = '\0'; - char pr[2] = {s,0}; - if (s == old && old == ' ') return; - else old = s; - if (s == '\r') CONS_Printf("\n"); - else if (s != '\n') CONS_Printf(pr); -} -#endif - #ifdef USE_WINSOCK // stupid microsoft makes things complicated static char *get_WSAErrorStr(int e) @@ -764,11 +732,7 @@ static SOCKET_TYPE UDP_Bind(int family, struct sockaddr *addr, socklen_t addrlen int opt; socklen_t opts; #ifdef FIONBIO -#ifdef WATTCP - char trueval = true; -#else unsigned long trueval = true; -#endif #endif mysockaddr_t straddr; struct sockaddr_in sin; @@ -1138,61 +1102,7 @@ boolean I_InitTcpDriver(void) CONS_Debug(DBG_NETPLAY, "WinSock description: %s\n",WSAData.szDescription); CONS_Debug(DBG_NETPLAY, "WinSock System Status: %s\n",WSAData.szSystemStatus); #endif -#ifdef __DJGPP__ -#ifdef WATTCP // Alam_GBC: survive bootp, dhcp, rarp and wattcp/pktdrv from failing to load - survive_eth = 1; // would be needed to not exit if pkt_eth_init() fails - survive_bootp = 1; // ditto for BOOTP - survive_dhcp = 1; // ditto for DHCP/RARP - survive_rarp = 1; - //_watt_do_exit = false; - //_watt_handle_cbreak = false; - //_watt_no_config = true; - _outch = wattcp_outch; - init_misc(); -//#ifdef DEBUGFILE - dbug_init(); -//#endif - switch (sock_init()) - { - case 0: - init_tcp_driver = true; - break; - case 3: - CONS_Debug(DBG_NETPLAY, "No packet driver detected\n"); - break; - case 4: - CONS_Debug(DBG_NETPLAY, "Error while talking to packet driver\n"); - break; - case 5: - CONS_Debug(DBG_NETPLAY, "BOOTP failed\n"); - break; - case 6: - CONS_Debug(DBG_NETPLAY, "DHCP failed\n"); - break; - case 7: - CONS_Debug(DBG_NETPLAY, "RARP failed\n"); - break; - case 8: - CONS_Debug(DBG_NETPLAY, "TCP/IP failed\n"); - break; - case 9: - CONS_Debug(DBG_NETPLAY, "PPPoE login/discovery failed\n"); - break; - default: - CONS_Debug(DBG_NETPLAY, "Unknown error with TCP/IP stack\n"); - break; - } - hires_timer(0); -#else // wattcp - if (__lsck_init()) - init_tcp_driver = true; - else - CONS_Debug(DBG_NETPLAY, "No TCP/IP driver detected\n"); -#endif // libsocket -#endif // __DJGPP__ -#ifndef __DJGPP__ init_tcp_driver = true; -#endif } #endif if (!tcp_was_up && init_tcp_driver) @@ -1217,10 +1127,8 @@ static void SOCK_CloseSocket(void) if (mysockets[i] != (SOCKET_TYPE)ERRSOCKET && FD_ISSET(mysockets[i], &masterset)) { -#if !defined (__DJGPP__) || defined (WATTCP) FD_CLR(mysockets[i], &masterset); close(mysockets[i]); -#endif } mysockets[i] = ERRSOCKET; } @@ -1237,14 +1145,6 @@ void I_ShutdownTcpDriver(void) WS_addrinfocleanup(); WSACleanup(); #endif -#ifdef __DJGPP__ -#ifdef WATTCP // wattcp - //_outch = NULL; - sock_exit(); -#else - __lsck_uninit(); -#endif // libsocket -#endif // __DJGPP__ CONS_Printf("shut down\n"); init_tcp_driver = false; #endif diff --git a/src/m_fixed.h b/src/m_fixed.h index 289ca442a..f634028c7 100644 --- a/src/m_fixed.h +++ b/src/m_fixed.h @@ -71,7 +71,7 @@ FUNCMATH FUNCINLINE static ATTRINLINE fixed_t FloatToFixed(float f) value [eax] \ modify exact [eax edx] #elif defined (__GNUC__) && defined (__i386__) && !defined (NOASM) - // DJGPP, i386 linux, cygwin or mingw + // i386 linux, cygwin or mingw FUNCMATH FUNCINLINE static inline fixed_t FixedMul(fixed_t a, fixed_t b) // asm { fixed_t ret; diff --git a/src/m_misc.c b/src/m_misc.c index ad2d133ab..a9defab3c 100644 --- a/src/m_misc.c +++ b/src/m_misc.c @@ -64,8 +64,6 @@ typedef off_t off64_t; #define PRIdS "u" #elif defined (_WIN32) #define PRIdS "Iu" -#elif defined (DJGPP) -#define PRIdS "u" #else #define PRIdS "zu" #endif diff --git a/src/s_sound.c b/src/s_sound.c index 392a5b453..7f644b12c 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -1033,11 +1033,9 @@ void S_SetSfxVolume(INT32 volume) void S_ClearSfx(void) { -#ifndef DJGPPDOS size_t i; for (i = 1; i < NUMSFX; i++) I_FreeSfx(S_sfx + i); -#endif } static void S_StopChannel(INT32 cnum) From dca158096df47f730e2827736bf650c1ddb8fe3d Mon Sep 17 00:00:00 2001 From: Jaime Ita Passos Date: Mon, 22 Mar 2021 23:56:55 -0300 Subject: [PATCH 0626/1080] Experimental implementation --- src/blua/lbaselib.c | 2 +- src/d_clisrv.c | 4 +- src/d_main.c | 35 ++++- src/d_netcmd.c | 204 +++++++++++++++++++++++- src/d_netcmd.h | 14 +- src/d_netfil.c | 48 +++++- src/d_netfil.h | 6 + src/filesrch.c | 345 +++++++++++++++++++++++++++++++++++++++-- src/filesrch.h | 8 +- src/hardware/hw_main.c | 2 +- src/m_misc.c | 19 +++ src/m_misc.h | 3 + src/p_setup.c | 45 ++++-- src/p_setup.h | 1 + src/r_textures.c | 17 +- src/r_things.c | 1 + src/w_wad.c | 337 ++++++++++++++++++++++++++++++++++++---- src/w_wad.h | 11 +- 18 files changed, 1007 insertions(+), 95 deletions(-) diff --git a/src/blua/lbaselib.c b/src/blua/lbaselib.c index 644565c28..0fc222038 100644 --- a/src/blua/lbaselib.c +++ b/src/blua/lbaselib.c @@ -274,7 +274,7 @@ static int luaB_dofile (lua_State *L) { UINT16 lumpnum; int n = lua_gettop(L); - if (wadfiles[numwadfiles - 1]->type != RET_PK3) + if (!W_FileHasFolders(wadfiles[numwadfiles - 1])) luaL_error(L, "dofile() only works with PK3 files"); snprintf(fullfilename, sizeof(fullfilename), "Lua/%s", filename); diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 7c2dec6a1..3dfb5cea8 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -4486,9 +4486,9 @@ static INT16 Consistancy(void) { if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) continue; - + mo = (mobj_t *)th; - + if (mo->flags & (MF_SPECIAL | MF_SOLID | MF_PUSHABLE | MF_BOSS | MF_MISSILE | MF_SPRING | MF_MONITOR | MF_FIRE | MF_ENEMY | MF_PAIN | MF_STICKY)) { ret -= mo->type; diff --git a/src/d_main.c b/src/d_main.c index 23a2c0133..09f678ba6 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -873,10 +873,26 @@ static void D_AddFile(char **list, const char *file) newfile = malloc(strlen(file) + 1); if (!newfile) - { I_Error("No more free memory to AddFile %s",file); - } + strcpy(newfile, file); + list[pnumwadfiles] = newfile; +} + +static void D_AddFolder(char **list, const char *file) +{ + size_t pnumwadfiles, len = strlen(file); + char *newfile; + + for (pnumwadfiles = 0; list[pnumwadfiles]; pnumwadfiles++) + ; + + newfile = malloc(len + 2); // NULL terminator + path separator + if (!newfile) + I_Error("No more free memory to AddFolder %s",file); + + strcpy(newfile, file); + strcat(newfile, PATHSEP); list[pnumwadfiles] = newfile; } @@ -1180,7 +1196,7 @@ void D_SRB2Main(void) { if (M_CheckParm("-file")) { - // the parms after p are wadfile/lump names, + // the parms after p are wadfile names, // until end of parms or another - preceded parm while (M_IsNextParm()) { @@ -1190,6 +1206,19 @@ void D_SRB2Main(void) D_AddFile(startuppwads, s); } } + + if (M_CheckParm("-folder")) + { + // the parms after p are folder names, + // until end of parms or another - preceded parm + while (M_IsNextParm()) + { + const char *s = M_GetNextParm(); + + if (s) // Check for NULL? + D_AddFolder(startuppwads, s); + } + } } // get map from parms diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 09f9d4651..c177e4a4a 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -63,7 +63,9 @@ static void Got_WeaponPref(UINT8 **cp, INT32 playernum); static void Got_Mapcmd(UINT8 **cp, INT32 playernum); static void Got_ExitLevelcmd(UINT8 **cp, INT32 playernum); static void Got_RequestAddfilecmd(UINT8 **cp, INT32 playernum); +static void Got_RequestAddfoldercmd(UINT8 **cp, INT32 playernum); static void Got_Addfilecmd(UINT8 **cp, INT32 playernum); +static void Got_Addfoldercmd(UINT8 **cp, INT32 playernum); static void Got_Pause(UINT8 **cp, INT32 playernum); static void Got_Suicide(UINT8 **cp, INT32 playernum); static void Got_RandomSeed(UINT8 **cp, INT32 playernum); @@ -115,6 +117,7 @@ static void Command_Map_f(void); static void Command_ResetCamera_f(void); static void Command_Addfile(void); +static void Command_Addfolder(void); static void Command_ListWADS_f(void); static void Command_RunSOC(void); static void Command_Pause(void); @@ -398,16 +401,16 @@ const char *netxcmdnames[MAXNETXCMD - 1] = "MAP", "EXITLEVEL", "ADDFILE", + "ADDFOLDER", "PAUSE", "ADDPLAYER", "TEAMCHANGE", "CLEARSCORES", - "LOGIN", "VERIFIED", "RANDOMSEED", "RUNSOC", "REQADDFILE", - "DELFILE", // replace next time we add an XD + "REQADDFOLDER", "SETMOTD", "SUICIDE", "LUACMD", @@ -441,7 +444,9 @@ void D_RegisterServerCommands(void) RegisterNetXCmd(XD_MAP, Got_Mapcmd); RegisterNetXCmd(XD_EXITLEVEL, Got_ExitLevelcmd); RegisterNetXCmd(XD_ADDFILE, Got_Addfilecmd); + RegisterNetXCmd(XD_ADDFOLDER, Got_Addfoldercmd); RegisterNetXCmd(XD_REQADDFILE, Got_RequestAddfilecmd); + RegisterNetXCmd(XD_REQADDFOLDER, Got_RequestAddfoldercmd); RegisterNetXCmd(XD_PAUSE, Got_Pause); RegisterNetXCmd(XD_SUICIDE, Got_Suicide); RegisterNetXCmd(XD_RUNSOC, Got_RunSOCcmd); @@ -472,6 +477,7 @@ void D_RegisterServerCommands(void) COM_AddCommand("showmap", Command_Showmap_f); COM_AddCommand("mapmd5", Command_Mapmd5_f); + COM_AddCommand("addfolder", Command_Addfolder); COM_AddCommand("addfile", Command_Addfile); COM_AddCommand("listwad", Command_ListWADS_f); @@ -3323,9 +3329,9 @@ static void Command_Addfile(void) ++p; // check total packet size and no of files currently loaded - // See W_LoadWadFile in w_wad.c + // See W_InitFile in w_wad.c if ((numwadfiles >= MAX_WADFILES) - || ((packetsizetally + nameonlylength(fn) + 22) > MAXFILENEEDED*sizeof(UINT8))) + || ((packetsizetally + nameonlylength(fn) + FILENEEDEDSIZE) > MAXFILENEEDED*sizeof(UINT8))) { CONS_Alert(CONS_ERROR, M_GetText("Too many files loaded to add %s\n"), fn); return; @@ -3373,6 +3379,89 @@ static void Command_Addfile(void) } } +static void Command_Addfolder(void) +{ + size_t argc = COM_Argc(); // amount of arguments total + size_t curarg; // current argument index + + const char *addedfolders[argc]; // list of filenames already processed + size_t numfoldersadded = 0; // the amount of filenames processed + + if (argc < 2) + { + CONS_Printf(M_GetText("addfolder [path2...] [...]: Load add-ons\n")); + return; + } + + // start at one to skip command name + for (curarg = 1; curarg < argc; curarg++) + { + const char *fn, *p; + char buf[256]; + char *buf_p = buf; + INT32 i; + size_t ii; + boolean folderadded = false; + + fn = COM_Argv(curarg); + + // For the amount of filenames previously processed... + for (ii = 0; ii < numfoldersadded; ii++) + { + // If this is one of them, don't try to add it. + if (!strcmp(fn, addedfolders[ii])) + { + folderadded = true; + break; + } + } + + // If we've added this one, skip to the next one. + if (folderadded) + { + CONS_Alert(CONS_WARNING, M_GetText("Already processed %s, skipping\n"), fn); + continue; + } + + // Disallow non-printing characters and semicolons. + for (i = 0; fn[i] != '\0'; i++) + if (!isprint(fn[i]) || fn[i] == ';') + return; + + // Add file on your client directly if you aren't in a netgame. + if (!(netgame || multiplayer)) + { + P_AddFolder(fn); + addedfolders[numfoldersadded++] = fn; + continue; + } + + p = fn+strlen(fn); + while(--p >= fn) + if (*p == '\\' || *p == '/' || *p == ':') + break; + ++p; + + // check total packet size and no of files currently loaded + // See W_InitFile in w_wad.c + if ((numwadfiles >= MAX_WADFILES) + || ((packetsizetally + strlen(fn) + FILENEEDEDSIZE) > MAXFILENEEDED*sizeof(UINT8))) + { + CONS_Alert(CONS_ERROR, M_GetText("Too many files loaded to add %s\n"), fn); + return; + } + + WRITESTRINGN(buf_p,p,240); + + addedfolders[numfoldersadded++] = fn; + + if (IsPlayerAdmin(consoleplayer) && (!server)) // Request to add file + SendNetXCmd(XD_REQADDFOLDER, buf, buf_p - buf); + else + SendNetXCmd(XD_ADDFOLDER, buf, buf_p - buf); + } +} + static void Got_RequestAddfilecmd(UINT8 **cp, INT32 playernum) { char filename[241]; @@ -3401,9 +3490,9 @@ static void Got_RequestAddfilecmd(UINT8 **cp, INT32 playernum) return; } - // See W_LoadWadFile in w_wad.c + // See W_InitFile in w_wad.c if ((numwadfiles >= MAX_WADFILES) - || ((packetsizetally + nameonlylength(filename) + 22) > MAXFILENEEDED*sizeof(UINT8))) + || ((packetsizetally + nameonlylength(filename) + FILENEEDEDSIZE) > MAXFILENEEDED*sizeof(UINT8))) toomany = true; else ncs = findfile(filename,md5sum,true); @@ -3433,6 +3522,64 @@ static void Got_RequestAddfilecmd(UINT8 **cp, INT32 playernum) COM_BufAddText(va("addfile %s\n", filename)); } +static void Got_RequestAddfoldercmd(UINT8 **cp, INT32 playernum) +{ + char path[241]; + filestatus_t ncs = FS_NOTFOUND; + boolean kick = false; + boolean toomany = false; + INT32 i,j; + + READSTRINGN(*cp, path, 240); + + /// \todo Integrity checks. + + // Only the server processes this message. + if (client) + return; + + // Disallow non-printing characters and semicolons. + for (i = 0; path[i] != '\0'; i++) + if (!isprint(path[i]) || path[i] == ';') + kick = true; + + if ((playernum != serverplayer && !IsPlayerAdmin(playernum)) || kick) + { + CONS_Alert(CONS_WARNING, M_GetText("Illegal addfolder command received from %s\n"), player_names[playernum]); + SendKick(playernum, KICK_MSG_CON_FAIL | KICK_MSG_KEEP_BODY); + return; + } + + // See W_InitFile in w_wad.c + if ((numwadfiles >= MAX_WADFILES) + || ((packetsizetally + strlen(path) + FILENEEDEDSIZE) > MAXFILENEEDED*sizeof(UINT8))) + toomany = true; + else + ncs = findfolder(path); + + if (ncs != FS_FOUND || toomany) + { + char message[256]; + + if (toomany) + sprintf(message, M_GetText("Too many files loaded to add %s\n"), path); + else if (ncs == FS_NOTFOUND) + sprintf(message, M_GetText("The server doesn't have %s\n"), path); + else + sprintf(message, M_GetText("Unknown error finding folder (%s)\n"), path); + + CONS_Printf("%s",message); + + for (j = 0; j < MAXPLAYERS; j++) + if (adminplayers[j]) + COM_BufAddText(va("sayto %d %s", adminplayers[j], message)); + + return; + } + + COM_BufAddText(va("addfolder \"%s\"\n", path)); +} + static void Got_Addfilecmd(UINT8 **cp, INT32 playernum) { char filename[241]; @@ -3481,6 +3628,49 @@ static void Got_Addfilecmd(UINT8 **cp, INT32 playernum) G_SetGameModified(true); } +static void Got_Addfoldercmd(UINT8 **cp, INT32 playernum) +{ + char path[241]; + filestatus_t ncs = FS_NOTFOUND; + + READSTRINGN(*cp, path, 240); + + /// \todo Integrity checks. + + if (playernum != serverplayer) + { + CONS_Alert(CONS_WARNING, M_GetText("Illegal addfolder command received from %s\n"), player_names[playernum]); + if (server) + SendKick(playernum, KICK_MSG_CON_FAIL | KICK_MSG_KEEP_BODY); + return; + } + + ncs = findfolder(path); + + if (ncs != FS_FOUND || !P_AddFolder(path)) + { + Command_ExitGame_f(); + if (ncs == FS_FOUND) + { + CONS_Printf(M_GetText("The server tried to add %s,\nbut you have too many files added.\nRestart the game to clear loaded files\nand play on this server."), path); + M_StartMessage(va("The server added a folder \n(%s)\nbut you have too many files added.\nRestart the game to clear loaded files.\n\nPress ESC\n",path), NULL, MM_NOTHING); + } + else if (ncs == FS_NOTFOUND) + { + CONS_Printf(M_GetText("The server tried to add %s,\nbut you don't have this file.\nYou need to find it in order\nto play on this server."), path); + M_StartMessage(va("The server added a folder \n(%s)\nthat you do not have.\n\nPress ESC\n",path), NULL, MM_NOTHING); + } + else + { + CONS_Printf(M_GetText("Unknown error finding folder (%s) the server added.\n"), path); + M_StartMessage(va("Unknown error trying to load a folder\nthat the server added \n(%s).\n\nPress ESC\n",path), NULL, MM_NOTHING); + } + return; + } + + G_SetGameModified(true); +} + static void Command_ListWADS_f(void) { INT32 i = numwadfiles; @@ -3495,6 +3685,8 @@ static void Command_ListWADS_f(void) CONS_Printf("\x82 * %.2d\x80: %s\n", i, tempname); else if (!wadfiles[i]->important) CONS_Printf("\x86 %.2d: %s\n", i, tempname); + else if (wadfiles[i]->type == RET_FOLDER) + CONS_Printf("\x82 * %.2d\x84: %s\n", i, tempname); else CONS_Printf(" %.2d: %s\n", i, tempname); } diff --git a/src/d_netcmd.h b/src/d_netcmd.h index ac39626a4..e7076cabf 100644 --- a/src/d_netcmd.h +++ b/src/d_netcmd.h @@ -128,16 +128,16 @@ typedef enum XD_MAP, // 6 XD_EXITLEVEL, // 7 XD_ADDFILE, // 8 - XD_PAUSE, // 9 - XD_ADDPLAYER, // 10 - XD_TEAMCHANGE, // 11 - XD_CLEARSCORES, // 12 - // UNUSED 13 (Because I don't want to change these comments) - XD_VERIFIED = 14,//14 + XD_ADDFOLDER, // 9 + XD_PAUSE, // 10 + XD_ADDPLAYER, // 11 + XD_TEAMCHANGE, // 12 + XD_CLEARSCORES, // 13 + XD_VERIFIED, // 14 XD_RANDOMSEED, // 15 XD_RUNSOC, // 16 XD_REQADDFILE, // 17 - XD_DELFILE, // 18 - replace next time we add an XD + XD_REQADDFOLDER,// 18 XD_SETMOTD, // 19 XD_SUICIDE, // 20 XD_DEMOTED, // 21 diff --git a/src/d_netfil.c b/src/d_netfil.c index 8f661bb5f..4e93f6600 100644 --- a/src/d_netfil.c +++ b/src/d_netfil.c @@ -120,7 +120,7 @@ char luafiledir[256 + 16] = "luafiles"; /** Fills a serverinfo packet with information about wad files loaded. * * \todo Give this function a better name since it is in global scope. - * Used to have size limiting built in - now handled via W_LoadWadFile in w_wad.c + * Used to have size limiting built in - now handled via W_InitFile in w_wad.c * */ UINT8 *PutFileNeeded(void) @@ -128,7 +128,7 @@ UINT8 *PutFileNeeded(void) size_t i, count = 0; UINT8 *p = netbuffer->u.serverinfo.fileneeded; char wadfilename[MAX_WADPATH] = ""; - UINT8 filestatus; + UINT8 filestatus, folder; for (i = 0; i < numwadfiles; i++) { @@ -137,9 +137,10 @@ UINT8 *PutFileNeeded(void) continue; filestatus = 1; // Importance - not really used any more, holds 1 by default for backwards compat with MS + folder = (wadfiles[i]->type == RET_FOLDER); // Store in the upper four bits - if (!cv_downloading.value) + if (!cv_downloading.value || folder) /// \todo Implement folder downloading. filestatus += (2 << 4); // Won't send else if ((wadfiles[i]->filesize <= (UINT32)cv_maxsend.value * 1024)) filestatus += (1 << 4); // Will send if requested @@ -147,6 +148,7 @@ UINT8 *PutFileNeeded(void) // filestatus += (0 << 4); -- Won't send, too big WRITEUINT8(p, filestatus); + WRITEUINT8(p, folder); count++; WRITEUINT32(p, wadfiles[i]->filesize); @@ -178,6 +180,7 @@ void D_ParseFileneeded(INT32 fileneedednum_parm, UINT8 *fileneededstr) fileneeded[i].status = FS_NOTFOUND; // We haven't even started looking for the file yet fileneeded[i].justdownloaded = false; filestatus = READUINT8(p); // The first byte is the file status + fileneeded[i].folder = READUINT8(p); // The second byte is the folder flag 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 @@ -420,7 +423,7 @@ INT32 CL_CheckFiles(void) return 1; } - // See W_LoadWadFile in w_wad.c + // See W_InitFile in w_wad.c packetsize = packetsizetally; for (i = 1; i < fileneedednum; i++) @@ -442,7 +445,10 @@ INT32 CL_CheckFiles(void) if (fileneeded[i].status != FS_NOTFOUND) continue; - packetsize += nameonlylength(fileneeded[i].filename) + 22; + if (fileneeded[i].folder) + packetsize += strlen(fileneeded[i].filename) + FILENEEDEDSIZE; + else + packetsize += nameonlylength(fileneeded[i].filename) + FILENEEDEDSIZE; if ((numwadfiles+filestoget >= MAX_WADFILES) || (packetsize > MAXFILENEEDED*sizeof(UINT8))) @@ -450,7 +456,10 @@ INT32 CL_CheckFiles(void) filestoget++; - fileneeded[i].status = findfile(fileneeded[i].filename, fileneeded[i].md5sum, true); + if (fileneeded[i].folder) + fileneeded[i].status = findfolder(fileneeded[i].filename); + else + fileneeded[i].status = findfile(fileneeded[i].filename, fileneeded[i].md5sum, true); CONS_Debug(DBG_NETPLAY, "found %d\n", fileneeded[i].status); if (fileneeded[i].status != FS_FOUND) ret = 0; @@ -472,7 +481,10 @@ void CL_LoadServerFiles(void) continue; // Already loaded else if (fileneeded[i].status == FS_FOUND) { - P_AddWadFile(fileneeded[i].filename); + if (fileneeded[i].folder) + P_AddFolder(fileneeded[i].filename); + else + P_AddWadFile(fileneeded[i].filename); G_SetGameModified(true); fileneeded[i].status = FS_OPEN; } @@ -757,7 +769,7 @@ static boolean AddFileToSendQueue(INT32 node, const char *filename, UINT8 fileid // This formerly checked if (!findfile(p->id.filename, NULL, true)) // Not found - // Don't inform client (probably someone who thought they could leak 2.2 ACZ) + // Don't inform client DEBFILE(va("Client %d request %s: not found\n", node, filename)); free(p->id.filename); free(p); @@ -1556,3 +1568,23 @@ filestatus_t findfile(char *filename, const UINT8 *wantedmd5sum, boolean complet return (badmd5 ? FS_MD5SUMBAD : FS_NOTFOUND); // md5 sum bad or file not found } + +filestatus_t findfolder(const char *path) +{ + // Check the path by itself first. + if (checkfolderpath(path, NULL, true)) + return FS_FOUND; + +#define checkpath(startpath) { \ + if (checkfolderpath(path, startpath, true)) \ + return FS_FOUND; \ + } + + checkpath(srb2home) // Then, look in srb2home. + checkpath(srb2path) // Now, look in srb2path. + checkpath(".") // Finally, look in ".". + +#undef checkpath + + return FS_NOTFOUND; +} diff --git a/src/d_netfil.h b/src/d_netfil.h index 1b399be75..7cd6e06d3 100644 --- a/src/d_netfil.h +++ b/src/d_netfil.h @@ -38,6 +38,7 @@ typedef enum typedef struct { UINT8 willsend; // Is the server willing to send it? + UINT8 folder; // File is a folder char filename[MAX_WADPATH]; UINT8 md5sum[16]; filestatus_t status; // The value returned by recsearch @@ -54,6 +55,8 @@ typedef struct UINT32 ackresendposition; // Used when resuming downloads } fileneeded_t; +#define FILENEEDEDSIZE 23 + extern INT32 fileneedednum; extern fileneeded_t fileneeded[MAX_WADFILES]; extern char downloaddir[512]; @@ -133,6 +136,9 @@ filestatus_t findfile(char *filename, const UINT8 *wantedmd5sum, boolean completepath); filestatus_t checkfilemd5(char *filename, const UINT8 *wantedmd5sum); +// Searches for a folder +filestatus_t findfolder(const char *path); + void nameonly(char *s); size_t nameonlylength(const char *s); diff --git a/src/filesrch.c b/src/filesrch.c index cb53d07be..f01fc0bd2 100644 --- a/src/filesrch.c +++ b/src/filesrch.c @@ -29,6 +29,7 @@ #include "m_misc.h" #include "z_zone.h" #include "m_menu.h" // Addons_option_Onchange +#include "w_wad.h" #if defined (_WIN32) && defined (_MSC_VER) @@ -340,6 +341,11 @@ char *refreshdirname = NULL; size_t packetsizetally = 0; size_t mainwadstally = 0; +#define folderpathlen 1024 +#define maxfolderdepth 48 + +#define isuptree(dirent) ((dirent)[0]=='.' && ((dirent)[1]=='\0' || ((dirent)[1]=='.' && (dirent)[2]=='\0'))) + filestatus_t filesearch(char *filename, const char *startpath, const UINT8 *wantedmd5sum, boolean completepath, int maxsearchdepth) { filestatus_t retval = FS_NOTFOUND; @@ -387,10 +393,7 @@ filestatus_t filesearch(char *filename, const char *startpath, const UINT8 *want continue; } - if (dent->d_name[0]=='.' && - (dent->d_name[1]=='\0' || - (dent->d_name[1]=='.' && - dent->d_name[2]=='\0'))) + if (isuptree(dent->d_name)) { // we don't want to scan uptree continue; @@ -445,6 +448,329 @@ filestatus_t filesearch(char *filename, const char *startpath, const UINT8 *want return retval; } +// Called from findfolder and ResGetLumpsFolder in w_wad.c. +// Call with cleanup true if the path has to be verified. +boolean checkfolderpath(const char *path, const char *startpath, boolean cleanup) +{ + char folderpath[folderpathlen], basepath[folderpathlen], *fn = NULL; + DIR *dirhandle; + + // Remove path separators from the filename, and don't try adding "/". + // See also the same code in W_InitFolder. + if (cleanup) + { + const char *p = path + strlen(path); + size_t len; + + --p; + while (*p == '\\' || *p == '/' || *p == ':') + { + p--; + if (p < path) + return false; + } + ++p; + + // Allocate the new path name. + len = (p - path) + 1; + fn = ZZ_Alloc(len); + strlcpy(fn, path, len); + } + + if (startpath) + { + snprintf(basepath, sizeof basepath, "%s" PATHSEP, startpath); + + if (cleanup) + { + snprintf(folderpath, sizeof folderpath, "%s%s", basepath, fn); + Z_Free(fn); // Don't need this anymore. + } + else + snprintf(folderpath, sizeof folderpath, "%s%s", basepath, path); + + // Home path and folder path are the same? Not valid. + if (!strcmp(basepath, folderpath)) + return false; + } + else if (cleanup) + { + snprintf(folderpath, sizeof folderpath, "%s", fn); + Z_Free(fn); // Don't need this anymore. + } + else + snprintf(folderpath, sizeof folderpath, "%s", path); + + dirhandle = opendir(folderpath); + if (dirhandle == NULL) + return false; + else + closedir(dirhandle); + + return true; +} + +INT32 pathisfolder(const char *path) +{ + struct stat fsstat; + + if (stat(path, &fsstat) < 0) + return -1; + else if (S_ISDIR(fsstat.st_mode)) + return 1; + + return 0; +} + +INT32 samepaths(const char *path1, const char *path2) +{ + struct stat stat1; + struct stat stat2; + + if (stat(path1, &stat1) < 0) + return -1; + if (stat(path2, &stat2) < 0) + return -1; + + if (stat1.st_dev == stat2.st_dev) + { +#if !defined(_WIN32) + return (stat1.st_ino == stat2.st_ino); +#else + HANDLE file1 = CreateFileA(path1, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL); + HANDLE file2 = CreateFileA(path2, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL); + BY_HANDLE_FILE_INFORMATION file1info, file2info; + boolean ok = false; + + if (file1 != INVALID_HANDLE_VALUE && file2 != INVALID_HANDLE_VALUE) + { + if (GetFileInformationByHandle(file1, &file1info) && GetFileInformationByHandle(file2, &file2info)) + { + if (file1info.dwVolumeSerialNumber == file2info.dwVolumeSerialNumber + && file1info.nFileIndexLow == file2info.nFileIndexLow + && file1info.nFileIndexHigh == file2info.nFileIndexHigh) + ok = true; + } + } + + if (file1 != INVALID_HANDLE_VALUE) + CloseHandle(file1); + if (file2 != INVALID_HANDLE_VALUE) + CloseHandle(file2); + + return ok; +#endif + } + + return false; +} + +// +// Folder loading +// + +static void initfolderpath(char *folderpath, size_t *folderpathindex, int depthleft) +{ + folderpathindex[depthleft] = strlen(folderpath) + 1; + + if (folderpath[folderpathindex[depthleft]-2] != PATHSEP[0]) + { + folderpath[folderpathindex[depthleft]-1] = PATHSEP[0]; + folderpath[folderpathindex[depthleft]] = 0; + } + else + folderpathindex[depthleft]--; +} + +lumpinfo_t *getfolderfiles(const char *path, UINT16 *nlmp, UINT16 *nfiles, UINT16 *nfolders) +{ + DIR **dirhandle; + struct dirent *dent; + struct stat fsstat; + + int rootfolder = (maxfolderdepth - 1); + int depthleft = rootfolder; + + char folderpath[folderpathlen]; + size_t *folderpathindex; + + lumpinfo_t *lumpinfo, *lump_p; + UINT16 i = 0, numlumps = (*nlmp); + + dirhandle = (DIR **)malloc(maxfolderdepth * sizeof (DIR*)); + folderpathindex = (size_t *)malloc(maxfolderdepth * sizeof(size_t)); + + // Open the root directory + strlcpy(folderpath, path, folderpathlen); + dirhandle[depthleft] = opendir(folderpath); + + if (dirhandle[depthleft] == NULL) + { + free(dirhandle); + free(folderpathindex); + return NULL; + } + + initfolderpath(folderpath, folderpathindex, depthleft); + (*nfiles) = 0; + (*nfolders) = 0; + + // Count files and directories + while (depthleft < maxfolderdepth) + { + folderpath[folderpathindex[depthleft]] = 0; + dent = readdir(dirhandle[depthleft]); + + if (!dent) + { + if (depthleft != rootfolder) // Don't close the root directory + closedir(dirhandle[depthleft]); + depthleft++; + continue; + } + else if (isuptree(dent->d_name)) + continue; + + strcpy(&folderpath[folderpathindex[depthleft]], dent->d_name); + + if (stat(folderpath, &fsstat) < 0) + ; + else if (S_ISDIR(fsstat.st_mode) && depthleft) + { + folderpathindex[--depthleft] = strlen(folderpath) + 1; + dirhandle[depthleft] = opendir(folderpath); + + if (dirhandle[depthleft]) + { + numlumps++; + (*nfolders)++; + } + else + depthleft++; + + folderpath[folderpathindex[depthleft]-1] = '/'; + folderpath[folderpathindex[depthleft]] = 0; + } + else + { + numlumps++; + (*nfiles)++; + } + + if (numlumps == (UINT16_MAX-1)) + break; + } + + // Failure: No files have been found. + if (!(*nfiles)) + { + (*nfiles) = UINT16_MAX; + free(folderpathindex); + free(dirhandle); + for (; depthleft < maxfolderdepth; closedir(dirhandle[depthleft++])); // Close any open directories. + return NULL; + } + + // Create the files and directories as lump entries + // It's possible to create lumps and count files at the same time, + // but I didn't to constantly have to reallocate memory for every lump. + rewinddir(dirhandle[rootfolder]); + depthleft = rootfolder; + + strlcpy(folderpath, path, folderpathlen); + initfolderpath(folderpath, folderpathindex, depthleft); + + lump_p = lumpinfo = Z_Calloc(numlumps * sizeof(lumpinfo_t), PU_STATIC, NULL); + + while (depthleft < maxfolderdepth) + { + char *fullname, *trimname; + + folderpath[folderpathindex[depthleft]] = 0; + dent = readdir(dirhandle[depthleft]); + + if (!dent) + { + closedir(dirhandle[depthleft++]); + continue; + } + else if (isuptree(dent->d_name)) + continue; + + strcpy(&folderpath[folderpathindex[depthleft]], dent->d_name); + + if (stat(folderpath, &fsstat) < 0) + continue; + else if (S_ISDIR(fsstat.st_mode) && depthleft) + { + folderpathindex[--depthleft] = strlen(folderpath) + 1; + dirhandle[depthleft] = opendir(folderpath); + + if (!dirhandle[depthleft]) + { + depthleft++; + continue; + } + + folderpath[folderpathindex[depthleft]-1] = '/'; + folderpath[folderpathindex[depthleft]] = 0; + } + + lump_p->diskpath = Z_StrDup(folderpath); // Path in the filesystem to the file + lump_p->compression = CM_NOCOMPRESSION; // Lump is uncompressed + + // Remove the folder path. + fullname = lump_p->diskpath; + if (strstr(fullname, path)) + fullname += strlen(path) + 1; + + // Get the 8-character long lump name. + trimname = strrchr(fullname, '/'); + if (trimname) + trimname++; + else + trimname = fullname; + + if (trimname[0]) + { + char *dotpos = strrchr(trimname, '.'); + if (dotpos == NULL) + dotpos = fullname + strlen(fullname); + + strncpy(lump_p->name, trimname, min(8, dotpos - trimname)); + + // The name of the file, without the extension. + lump_p->longname = Z_Calloc(dotpos - trimname + 1, PU_STATIC, NULL); + strlcpy(lump_p->longname, trimname, dotpos - trimname + 1); + } + else + lump_p->longname = Z_Calloc(1, PU_STATIC, NULL); + + // The complete name of the file, with its extension, + // excluding the path of the folder where it resides. + lump_p->fullname = Z_StrDup(fullname); + + lump_p++; + i++; + + if (i > numlumps || i == (UINT16_MAX-1)) + { + for (; depthleft < maxfolderdepth; closedir(dirhandle[depthleft++])); // Close any open directories. + break; + } + } + + free(folderpathindex); + free(dirhandle); + + (*nlmp) = numlumps; + return lumpinfo; +} + +// +// Addons menu +// + char exttable[NUM_EXT_TABLE][7] = { // maximum extension length (currently 4) plus 3 (null terminator, stop, and length including previous two) "\5.txt", "\5.cfg", // exec "\5.wad", @@ -455,7 +781,6 @@ char exttable[NUM_EXT_TABLE][7] = { // maximum extension length (currently 4) pl char filenamebuf[MAX_WADFILES][MAX_WADPATH]; - static boolean filemenucmp(char *haystack, char *needle) { static char localhaystack[128]; @@ -640,10 +965,7 @@ boolean preparefilemenu(boolean samedepth) if (!dent) break; - else if (dent->d_name[0]=='.' && - (dent->d_name[1]=='\0' || - (dent->d_name[1]=='.' && - dent->d_name[2]=='\0'))) + else if (isuptree(dent->d_name)) continue; // we don't want to scan uptree strcpy(&menupath[menupathindex[menudepthleft]],dent->d_name); @@ -704,10 +1026,7 @@ boolean preparefilemenu(boolean samedepth) if (!dent) break; - else if (dent->d_name[0]=='.' && - (dent->d_name[1]=='\0' || - (dent->d_name[1]=='.' && - dent->d_name[2]=='\0'))) + else if (isuptree(dent->d_name)) continue; // we don't want to scan uptree strcpy(&menupath[menupathindex[menudepthleft]],dent->d_name); diff --git a/src/filesrch.h b/src/filesrch.h index dfea8979e..92e3341f3 100644 --- a/src/filesrch.h +++ b/src/filesrch.h @@ -7,6 +7,7 @@ #include "doomdef.h" #include "d_netfil.h" #include "m_menu.h" // MAXSTRINGLENGTH +#include "w_wad.h" extern consvar_t cv_addons_option, cv_addons_folder, cv_addons_md5, cv_addons_showall, cv_addons_search_case, cv_addons_search_type; @@ -28,6 +29,12 @@ extern consvar_t cv_addons_option, cv_addons_folder, cv_addons_md5, cv_addons_sh filestatus_t filesearch(char *filename, const char *startpath, const UINT8 *wantedmd5sum, boolean completepath, int maxsearchdepth); +INT32 pathisfolder(const char *path); +boolean checkfolderpath(const char *path, const char *startpath, boolean cleanup); +INT32 samepaths(const char *path1, const char *path2); + +lumpinfo_t *getfolderfiles(const char *path, UINT16 *nlmp, UINT16 *nfiles, UINT16 *nfolders); + #define menudepth 20 extern char menupath[1024]; @@ -94,5 +101,4 @@ typedef enum void closefilemenu(boolean validsize); void searchfilemenu(char *tempname); boolean preparefilemenu(boolean samedepth); - #endif // __FILESRCH_H__ diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index c2d617eaf..8bbe78f00 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -6681,7 +6681,7 @@ void HWR_LoadAllCustomShaders(void) // read every custom shader for (i = 0; i < numwadfiles; i++) - HWR_LoadCustomShadersFromFile(i, (wadfiles[i]->type == RET_PK3)); + HWR_LoadCustomShadersFromFile(i, W_FileHasFolders(wadfiles[i])); } void HWR_LoadCustomShadersFromFile(UINT16 wadnum, boolean PK3) diff --git a/src/m_misc.c b/src/m_misc.c index ad2d133ab..74c30dedd 100644 --- a/src/m_misc.c +++ b/src/m_misc.c @@ -2688,3 +2688,22 @@ const char * M_Ftrim (double f) return &dig[1];/* skip the 0 */ } } + +// Returns true if the string is empty. +boolean M_IsStringEmpty(const char *s) +{ + const char *ch = s; + + if (ch == NULL || (ch && strlen(ch) < 1)) + return true; + + for (;;ch++) + { + if (!(*ch)) + break; + if (!isspace((*ch))) + return false; + } + + return true; +} diff --git a/src/m_misc.h b/src/m_misc.h index c5ef9f9f2..d23c53978 100644 --- a/src/m_misc.h +++ b/src/m_misc.h @@ -117,6 +117,9 @@ trailing zeros, or "" if the fractional part is zero. */ const char * M_Ftrim (double); +// Returns true if the string is empty. +boolean M_IsStringEmpty(const char *s); + // counting bits, for weapon ammo code, usually FUNCMATH UINT8 M_CountBits(UINT32 num, UINT8 size); diff --git a/src/p_setup.c b/src/p_setup.c index 66243fb0e..d1c0f1740 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -4385,10 +4385,9 @@ static lumpinfo_t* FindFolder(const char *folName, UINT16 *start, UINT16 *end, l // Add a wadfile to the active wad files, // replace sounds, musics, patches, textures, sprites and maps // -boolean P_AddWadFile(const char *wadfilename) +static boolean P_LoadAddon(UINT16 wadnum, UINT16 numlumps) { size_t i, j, sreplaces = 0, mreplaces = 0, digmreplaces = 0; - UINT16 numlumps, wadnum; char *name; lumpinfo_t *lumpinfo; @@ -4409,18 +4408,10 @@ boolean P_AddWadFile(const char *wadfilename) // UINT16 flaPos, flaNum = 0; // UINT16 mapPos, mapNum = 0; - // Init file. - if ((numlumps = W_InitFile(wadfilename, false, false)) == INT16_MAX) - { - refreshdirmenu |= REFRESHDIR_NOTLOADED; - return false; - } - else - wadnum = (UINT16)(numwadfiles-1); - switch(wadfiles[wadnum]->type) { case RET_PK3: + case RET_FOLDER: // Look for the lumps that act as resource delimitation markers. lumpinfo = wadfiles[wadnum]->lumpinfo; for (i = 0; i < numlumps; i++, lumpinfo++) @@ -4584,3 +4575,35 @@ boolean P_AddWadFile(const char *wadfilename) return true; } + +boolean P_AddWadFile(const char *wadfilename) +{ + UINT16 numlumps, wadnum; + + // Init file. + if ((numlumps = W_InitFile(wadfilename, false, false)) == INT16_MAX) + { + refreshdirmenu |= REFRESHDIR_NOTLOADED; + return false; + } + else + wadnum = (UINT16)(numwadfiles-1); + + return P_LoadAddon(wadnum, numlumps); +} + +boolean P_AddFolder(const char *folderpath) +{ + UINT16 numlumps, wadnum; + + // Init file. + if ((numlumps = W_InitFolder(folderpath, false, false)) == INT16_MAX) + { + refreshdirmenu |= REFRESHDIR_NOTLOADED; + return false; + } + else + wadnum = (UINT16)(numwadfiles-1); + + return P_LoadAddon(wadnum, numlumps); +} diff --git a/src/p_setup.h b/src/p_setup.h index 5d13ae7d4..ae849acbf 100644 --- a/src/p_setup.h +++ b/src/p_setup.h @@ -103,6 +103,7 @@ boolean P_LoadLevel(boolean fromnetsave, boolean reloadinggamestate); void HWR_LoadLevel(void); #endif boolean P_AddWadFile(const char *wadfilename); +boolean P_AddFolder(const char *folderpath); boolean P_RunSOC(const char *socfilename); void P_LoadSoundsRange(UINT16 wadnum, UINT16 first, UINT16 num); void P_LoadMusicsRange(UINT16 wadnum, UINT16 first, UINT16 num); diff --git a/src/r_textures.c b/src/r_textures.c index a006d739f..0a1248100 100644 --- a/src/r_textures.c +++ b/src/r_textures.c @@ -732,7 +732,7 @@ Rloadflats (INT32 i, INT32 w) texpatch_t *patch; // Yes - if (wadfiles[w]->type == RET_PK3) + if (W_FileHasFolders(wadfiles[w])) { texstart = W_CheckNumForFolderStartPK3("flats/", (UINT16)w, 0); texend = W_CheckNumForFolderEndPK3("flats/", (UINT16)w, texstart); @@ -754,7 +754,7 @@ Rloadflats (INT32 i, INT32 w) size_t lumplength; size_t flatsize = 0; - if (wadfiles[w]->type == RET_PK3) + if (W_FileHasFolders(wadfiles[w])) { if (W_IsLumpFolder(wadnum, lumpnum)) // Check if lump is a folder continue; // If it is then SKIP IT @@ -844,7 +844,7 @@ Rloadtextures (INT32 i, INT32 w) texpatch_t *patch; // Get the lump numbers for the markers in the WAD, if they exist. - if (wadfiles[w]->type == RET_PK3) + if (W_FileHasFolders(wadfiles[w])) { texstart = W_CheckNumForFolderStartPK3("textures/", (UINT16)w, 0); texend = W_CheckNumForFolderEndPK3("textures/", (UINT16)w, texstart); @@ -875,7 +875,7 @@ Rloadtextures (INT32 i, INT32 w) size_t lumplength; #endif - if (wadfiles[w]->type == RET_PK3) + if (W_FileHasFolders(wadfiles[w])) { if (W_IsLumpFolder(wadnum, lumpnum)) // Check if lump is a folder continue; // If it is then SKIP IT @@ -964,7 +964,7 @@ void R_LoadTextures(void) { #ifdef WALLFLATS // Count flats - if (wadfiles[w]->type == RET_PK3) + if (W_FileHasFolders(wadfiles[w])) { texstart = W_CheckNumForFolderStartPK3("flats/", (UINT16)w, 0); texend = W_CheckNumForFolderEndPK3("flats/", (UINT16)w, texstart); @@ -978,7 +978,7 @@ void R_LoadTextures(void) if (!( texstart == INT16_MAX || texend == INT16_MAX )) { // PK3s have subfolders, so we can't just make a simple sum - if (wadfiles[w]->type == RET_PK3) + if (W_FileHasFolders(wadfiles[w])) { for (j = texstart; j < texend; j++) { @@ -1002,7 +1002,7 @@ void R_LoadTextures(void) } // Count single-patch textures - if (wadfiles[w]->type == RET_PK3) + if (W_FileHasFolders(wadfiles[w])) { texstart = W_CheckNumForFolderStartPK3("textures/", (UINT16)w, 0); texend = W_CheckNumForFolderEndPK3("textures/", (UINT16)w, texstart); @@ -1017,7 +1017,7 @@ void R_LoadTextures(void) continue; // PK3s have subfolders, so we can't just make a simple sum - if (wadfiles[w]->type == RET_PK3) + if (W_FileHasFolders(wadfiles[w])) { for (j = texstart; j < texend; j++) { @@ -1558,6 +1558,7 @@ lumpnum_t R_GetFlatNumForName(const char *name) continue; break; case RET_PK3: + case RET_FOLDER: if ((start = W_CheckNumForFolderStartPK3("Flats/", i, 0)) == INT16_MAX) continue; if ((end = W_CheckNumForFolderEndPK3("Flats/", i, start)) == INT16_MAX) diff --git a/src/r_things.c b/src/r_things.c index 14eed9cf2..135c4c5bf 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -443,6 +443,7 @@ void R_AddSpriteDefs(UINT16 wadnum) end = W_CheckNumForNamePwad("SS_END",wadnum,start); //deutex compatib. break; case RET_PK3: + case RET_FOLDER: start = W_CheckNumForFolderStartPK3("Sprites/", wadnum, 0); end = W_CheckNumForFolderEndPK3("Sprites/", wadnum, start); break; diff --git a/src/w_wad.c b/src/w_wad.c index 2cbcdecb5..b305d89e9 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -50,16 +50,17 @@ #include "filesrch.h" -#include "i_video.h" // rendermode +#include "d_main.h" #include "d_netfil.h" -#include "dehacked.h" #include "d_clisrv.h" +#include "dehacked.h" #include "r_defs.h" #include "r_data.h" #include "r_textures.h" #include "r_patch.h" #include "r_picformats.h" #include "i_system.h" +#include "i_video.h" // rendermode #include "md5.h" #include "lua_script.h" #ifdef SCANTHINGS @@ -117,10 +118,15 @@ void W_Shutdown(void) { wadfile_t *wad = wadfiles[numwadfiles]; - fclose(wad->handle); + if (wad->handle) + fclose(wad->handle); Z_Free(wad->filename); + if (wad->path) + Z_Free(wad->path); while (wad->numlumps--) { + if (wad->lumpinfo[wad->numlumps].diskpath) + Z_Free(wad->lumpinfo[wad->numlumps].diskpath); Z_Free(wad->lumpinfo[wad->numlumps].longname); Z_Free(wad->lumpinfo[wad->numlumps].fullname); } @@ -421,6 +427,7 @@ static lumpinfo_t* ResGetLumpsWad (FILE* handle, UINT16* nlmp, const char* filen { lump_p->position = LONG(fileinfo->filepos); lump_p->size = lump_p->disksize = LONG(fileinfo->size); + lump_p->diskpath = NULL; if (compressed) // wad is compressed, lump might be { UINT32 realsize = 0; @@ -602,6 +609,7 @@ static lumpinfo_t* ResGetLumpsZip (FILE* handle, UINT16* nlmp) lump_p->position = zentry.offset; // NOT ACCURATE YET: we still need to read the local entry to find our true position lump_p->disksize = zentry.compsize; + lump_p->diskpath = NULL; lump_p->size = zentry.size; fullname = malloc(zentry.namelen + 1); @@ -679,6 +687,58 @@ static lumpinfo_t* ResGetLumpsZip (FILE* handle, UINT16* nlmp) return lumpinfo; } +// Checks if the combination of the first path and the second path are valid. +// If they are, the concatenated path is returned. +static char *W_CheckFolderPath(const char *startpath, const char *path) +{ + if (checkfolderpath(path, startpath, false)) + { + char *fn; + + if (startpath) + { + size_t len = strlen(startpath) + strlen(path) + strlen(PATHSEP) + 1; + fn = ZZ_Alloc(len); + snprintf(fn, len, "%s" PATHSEP "%s", startpath, path); + } + else + fn = Z_StrDup(path); + + return fn; + } + + return NULL; +} + +// Returns the first valid path for a folder. +static char *W_GetFullFolderPath(const char *path) +{ + // Check the path by itself first. + char *fn = W_CheckFolderPath(NULL, path); + if (fn) + return fn; + +#define checkpath(startpath) { \ + fn = W_CheckFolderPath(startpath, path); \ + if (fn) \ + return fn; \ +} \ + + checkpath(srb2home) // Then, look in srb2home. + checkpath(srb2path) // Now, look in srb2path. + checkpath(".") // Finally, look in ".". + +#undef checkpath + + return NULL; +} + +// Loads files from a folder into a lumpinfo structure. +static lumpinfo_t *ResGetLumpsFolder(const char *path, UINT16 *nlmp, UINT16 *nfiles, UINT16 *nfolders) +{ + return getfolderfiles(path, nlmp, nfiles, nfolders); +} + static UINT16 W_InitFileError (const char *filename, boolean exitworthy) { if (exitworthy) @@ -694,6 +754,19 @@ static UINT16 W_InitFileError (const char *filename, boolean exitworthy) return INT16_MAX; } +static void W_ReadFileShaders(wadfile_t *wadfile) +{ +#ifdef HWRENDER + if (rendermode == render_opengl && (vid.glstate == VID_GL_LIBRARY_LOADED)) + { + HWR_LoadCustomShadersFromFile(numwadfiles - 1, W_FileHasFolders(wadfile)); + HWR_CompileShaders(); + } +#else + (void)wadfile; +#endif +} + // Allocate a wadfile, setup the lumpinfo (directory) and // lumpcache, add the wadfile to the current active wadfiles // @@ -760,7 +833,7 @@ UINT16 W_InitFile(const char *filename, boolean mainfile, boolean startup) // see PutFileNeeded in d_netfil.c if ((important = !important)) { - packetsize = packetsizetally + nameonlylength(filename) + 22; + packetsize = packetsizetally + nameonlylength(filename) + FILENEEDEDSIZE; if (packetsize > MAXFILENEEDED*sizeof(UINT8)) { @@ -788,7 +861,7 @@ UINT16 W_InitFile(const char *filename, boolean mainfile, boolean startup) { CONS_Alert(CONS_ERROR, M_GetText("%s is already loaded\n"), filename); if (important) - packetsizetally -= nameonlylength(filename) + 22; + packetsizetally -= nameonlylength(filename) + FILENEEDEDSIZE; if (handle) fclose(handle); return W_InitFileError(filename, false); @@ -828,9 +901,11 @@ UINT16 W_InitFile(const char *filename, boolean mainfile, boolean startup) // wadfile = Z_Malloc(sizeof (*wadfile), PU_STATIC, NULL); wadfile->filename = Z_StrDup(filename); + wadfile->path = NULL; wadfile->type = type; wadfile->handle = handle; - wadfile->numlumps = (UINT16)numlumps; + wadfile->numlumps = numlumps; + wadfile->filecount = wadfile->foldercount = 0; wadfile->lumpinfo = lumpinfo; wadfile->important = important; fseek(handle, 0, SEEK_END); @@ -853,14 +928,8 @@ UINT16 W_InitFile(const char *filename, boolean mainfile, boolean startup) wadfiles[numwadfiles] = wadfile; numwadfiles++; // must come BEFORE W_LoadDehackedLumps, so any addfile called by COM_BufInsertText called by Lua doesn't overwrite what we just loaded -#ifdef HWRENDER // Read shaders from file - if (rendermode == render_opengl && (vid.glstate == VID_GL_LIBRARY_LOADED)) - { - HWR_LoadCustomShadersFromFile(numwadfiles - 1, (type == RET_PK3)); - HWR_CompileShaders(); - } -#endif // HWRENDER + W_ReadFileShaders(wadfile); // 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. switch (wadfile->type) @@ -886,6 +955,153 @@ UINT16 W_InitFile(const char *filename, boolean mainfile, boolean startup) return wadfile->numlumps; } +// +// Loads a folder as a WAD. +// +UINT16 W_InitFolder(const char *path, boolean mainfile, boolean startup) +{ + lumpinfo_t *lumpinfo = NULL; + wadfile_t *wadfile; + UINT16 numlumps = 0; + UINT16 filecount, foldercount; + size_t i; + char *fn, *fullpath; + const char *p; + int important; + + if (!(refreshdirmenu & REFRESHDIR_ADDFILE)) + refreshdirmenu = REFRESHDIR_NORMAL|REFRESHDIR_ADDFILE; // clean out cons_alerts that happened earlier + + if (refreshdirname) + Z_Free(refreshdirname); + if (dirmenu) + refreshdirname = Z_StrDup(path); + else + refreshdirname = NULL; + + if (numwadfiles >= MAX_WADFILES) + { + CONS_Alert(CONS_ERROR, M_GetText("Maximum wad files reached\n")); + refreshdirmenu |= REFRESHDIR_MAX; + return W_InitFileError(path, startup); + } + + important = 0; // ??? + + /// \todo Implement a W_VerifyFolder. + if ((important = !important)) + { + size_t packetsize = packetsizetally + strlen(path) + FILENEEDEDSIZE; + + if (packetsize > MAXFILENEEDED*sizeof(UINT8)) + { + CONS_Alert(CONS_ERROR, M_GetText("Maximum wad files reached\n")); + refreshdirmenu |= REFRESHDIR_MAX; + return W_InitFileError(path, startup); + } + + packetsizetally = packetsize; + } + + // Remove path separators from the filename, and don't try adding "/". + p = path+strlen(path); + --p; + + while (*p == '\\' || *p == '/' || *p == ':') + { + p--; + if (p < path) + { + CONS_Alert(CONS_ERROR, M_GetText("Path %s is prohibited\n"), path); + return W_InitFileError(path, startup); + } + } + p++; + + // Allocate the new path name. + i = (p - path) + 1; + fn = ZZ_Alloc(i); + strlcpy(fn, path, i); + + if (M_IsStringEmpty(fn)) + { + CONS_Alert(CONS_ERROR, M_GetText("Folder name is empty\n")); + Z_Free(fn); + + if (startup) + return W_InitFileError("A folder", true); + else + return W_InitFileError("a folder", false); + } + + // Get the full path for this filename. + fullpath = W_GetFullFolderPath(fn); + if (fullpath == NULL) + { + Z_Free(fn); + return W_InitFileError(path, false); + } + + for (i = 0; i < numwadfiles; i++) + { + if (wadfiles[i]->type != RET_FOLDER) + continue; + + if (samepaths(wadfiles[i]->path, fullpath) > 0) + { + CONS_Alert(CONS_ERROR, M_GetText("%s is already loaded\n"), path); + if (important) + packetsizetally -= strlen(path) + FILENEEDEDSIZE; + Z_Free(fn); + Z_Free(fullpath); + return W_InitFileError(path, false); + } + } + + lumpinfo = ResGetLumpsFolder(fullpath, &numlumps, &filecount, &foldercount); + if (lumpinfo == NULL) + { + if (filecount == UINT16_MAX) + CONS_Alert(CONS_ERROR, M_GetText("Folder %s is empty\n"), path); + + Z_Free(fn); + Z_Free(fullpath); + + return W_InitFileError(path, startup); + } + + if (important && !mainfile) + G_SetGameModified(true); + + wadfile = Z_Malloc(sizeof (*wadfile), PU_STATIC, NULL); + wadfile->filename = fn; + wadfile->path = fullpath; + wadfile->type = RET_FOLDER; + wadfile->handle = NULL; + wadfile->numlumps = numlumps; + wadfile->filecount = filecount; + wadfile->foldercount = foldercount; + wadfile->lumpinfo = lumpinfo; + wadfile->important = important; + + // Irrelevant. + wadfile->filesize = 0; + memset(wadfile->md5sum, 0x00, 16); + + Z_Calloc(numlumps * sizeof (*wadfile->lumpcache), PU_STATIC, &wadfile->lumpcache); + Z_Calloc(numlumps * sizeof (*wadfile->patchcache), PU_STATIC, &wadfile->patchcache); + + CONS_Printf(M_GetText("Added folder %s (%u files, %u folders)\n"), fn, filecount, foldercount); + wadfiles[numwadfiles] = wadfile; + numwadfiles++; + + W_ReadFileShaders(wadfile); + W_LoadDehackedLumpsPK3(numwadfiles - 1, mainfile); + W_InvalidateLumpnumCache(); + + return wadfile->numlumps; +} + /** Tries to load a series of files. * All files are wads unless they have an extension of ".soc" or ".lua". * @@ -897,11 +1113,18 @@ UINT16 W_InitFile(const char *filename, boolean mainfile, boolean startup) */ void W_InitMultipleFiles(char **filenames) { - // will be realloced as lumps are added for (; *filenames; filenames++) { - //CONS_Debug(DBG_SETUP, "Loading %s\n", *filenames); - W_InitFile(*filenames, numwadfiles < mainwads, true); + const char *fn = (*filenames); + char pathsep = fn[strlen(fn) - 1]; + boolean mainfile = (numwadfiles < mainwads); + + //CONS_Debug(DBG_SETUP, "Loading %s\n", fn); + + if (pathsep == '\\' || pathsep == '/') + W_InitFolder(fn, mainfile, true); + else + W_InitFile(fn, mainfile, true); } } @@ -1175,7 +1398,7 @@ lumpnum_t W_CheckNumForMap(const char *name) if (!strncmp(name, (wadfiles[i]->lumpinfo + lumpNum)->name, 8)) return (i<<16) + lumpNum; } - else if (wadfiles[i]->type == RET_PK3) + else if (W_FileHasFolders(wadfiles[i])) { lumpNum = W_CheckNumForFolderStartPK3("maps/", i, 0); if (lumpNum != INT16_MAX) @@ -1273,9 +1496,34 @@ UINT8 W_LumpExists(const char *name) size_t W_LumpLengthPwad(UINT16 wad, UINT16 lump) { + lumpinfo_t *l; + if (!TestValidLump(wad, lump)) return 0; - return wadfiles[wad]->lumpinfo[lump].size; + + l = wadfiles[wad]->lumpinfo + lump; + + if (wadfiles[wad]->type == RET_FOLDER) + { + INT32 stat = pathisfolder(l->diskpath); + + if (stat < 0) + I_Error("W_LumpLengthPwad: could not stat %s", l->diskpath); + else if (stat == 1) // Path is a folder. + return 0; + else + { + FILE *handle = fopen(l->diskpath, "rb"); + if (handle == NULL) + I_Error("W_LumpLengthPwad: could not open file %s", l->diskpath); + + fseek(handle, 0, SEEK_END); + l->size = l->disksize = ftell(handle); + fclose(handle); + } + } + + return l->size; } /** Returns the buffer size needed to load the given lump. @@ -1294,7 +1542,7 @@ size_t W_LumpLength(lumpnum_t lumpnum) // boolean W_IsLumpWad(lumpnum_t lumpnum) { - if (wadfiles[WADFILENUM(lumpnum)]->type == RET_PK3) + if (W_FileHasFolders(wadfiles[WADFILENUM(lumpnum)])) { const char *lumpfullName = (wadfiles[WADFILENUM(lumpnum)]->lumpinfo + LUMPNUM(lumpnum))->fullname; @@ -1312,7 +1560,7 @@ boolean W_IsLumpWad(lumpnum_t lumpnum) // boolean W_IsLumpFolder(UINT16 wad, UINT16 lump) { - if (wadfiles[wad]->type == RET_PK3) + if (W_FileHasFolders(wadfiles[wad])) { const char *name = wadfiles[wad]->lumpinfo[lump].fullname; @@ -1362,17 +1610,44 @@ void zerr(int ret) */ size_t W_ReadLumpHeaderPwad(UINT16 wad, UINT16 lump, void *dest, size_t size, size_t offset) { - size_t lumpsize; + size_t lumpsize, bytesread; lumpinfo_t *l; - FILE *handle; + FILE *handle = NULL; if (!TestValidLump(wad,lump)) return 0; + l = wadfiles[wad]->lumpinfo + lump; + + // Open the external file for this lump, if the WAD is a folder. + if (wadfiles[wad]->type == RET_FOLDER) + { + INT32 stat = pathisfolder(l->diskpath); + + if (stat < 0) + I_Error("W_ReadLumpHeaderPwad: could not stat %s", l->diskpath); + else if (stat == 1) // Path is a folder. + return 0; + else + { + handle = fopen(l->diskpath, "rb"); + if (handle == NULL) + I_Error("W_ReadLumpHeaderPwad: could not open file %s", l->diskpath); + + // Find length of file + fseek(handle, 0, SEEK_END); + l->size = l->disksize = ftell(handle); + } + } + lumpsize = wadfiles[wad]->lumpinfo[lump].size; // empty resource (usually markers like S_START, F_END ..) if (!lumpsize || lumpsizetype == RET_FOLDER) + fclose(handle); return 0; + } // zero size means read all the lump if (!size || size+offset > lumpsize) @@ -1380,24 +1655,22 @@ size_t W_ReadLumpHeaderPwad(UINT16 wad, UINT16 lump, void *dest, size_t size, si // Let's get the raw lump data. // We setup the desired file handle to read the lump data. - l = wadfiles[wad]->lumpinfo + lump; - handle = wadfiles[wad]->handle; + if (wadfiles[wad]->type != RET_FOLDER) + handle = wadfiles[wad]->handle; 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) { case CM_NOCOMPRESSION: // If it's uncompressed, we directly write the data into our destination, and return the bytes read. + bytesread = fread(dest, 1, size, handle); + if (wadfiles[wad]->type == RET_FOLDER) + fclose(handle); #ifdef NO_PNG_LUMPS - { - size_t bytesread = fread(dest, 1, size, handle); - if (Picture_IsLumpPNG((UINT8 *)dest, bytesread)) - Picture_ThrowPNGError(l->fullname, wadfiles[wad]->filename); - return bytesread; - } -#else - return fread(dest, 1, size, handle); + if (Picture_IsLumpPNG((UINT8 *)dest, bytesread)) + Picture_ThrowPNGError(l->fullname, wadfiles[wad]->filename); #endif + return bytesread; case CM_LZF: // Is it LZF compressed? Used by ZWADs. { #ifdef ZWAD diff --git a/src/w_wad.h b/src/w_wad.h index d0a86bcb4..8b3c3808e 100644 --- a/src/w_wad.h +++ b/src/w_wad.h @@ -69,6 +69,7 @@ typedef struct char name[9]; // filelump_t name[] e.g. "LongEntr" char *longname; // e.g. "LongEntryName" char *fullname; // e.g. "Folder/Subfolder/LongEntryName.extension" + char *diskpath; // path to the file e.g. "/usr/games/srb2/Addon/Folder/Subfolder/LongEntryName.extension" size_t size; // real (uncompressed) size compmethod compression; // lump compression method } lumpinfo_t; @@ -109,17 +110,19 @@ typedef enum restype RET_SOC, RET_LUA, RET_PK3, + RET_FOLDER, RET_UNKNOWN, } restype_t; typedef struct wadfile_s { - char *filename; + char *filename, *path; restype_t type; lumpinfo_t *lumpinfo; lumpcache_t *lumpcache; lumpcache_t *patchcache; UINT16 numlumps; // this wad's number of resources + UINT16 filecount, foldercount; // file and folder count FILE *handle; UINT32 filesize; // for network UINT8 md5sum[16]; @@ -127,7 +130,7 @@ typedef struct wadfile_s boolean important; // also network - !W_VerifyNMUSlumps } wadfile_t; -#define WADFILENUM(lumpnum) (UINT16)((lumpnum)>>16) // wad flumpnum>>16) // wad file number in upper word +#define WADFILENUM(lumpnum) (UINT16)((lumpnum)>>16) // wad file number in upper word #define LUMPNUM(lumpnum) (UINT16)((lumpnum)&0xFFFF) // lump number for this pwad extern UINT16 numwadfiles; @@ -141,10 +144,14 @@ void W_Shutdown(void); 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 UINT16 W_InitFile(const char *filename, boolean mainfile, boolean startup); +// Adds a folder as a file +UINT16 W_InitFolder(const char *path, boolean mainfile, boolean startup); // W_InitMultipleFiles exits if a file was not found, but not if all is okay. void W_InitMultipleFiles(char **filenames); +#define W_FileHasFolders(wadfile) ((wadfile)->type == RET_PK3 || (wadfile)->type == RET_FOLDER) + const char *W_CheckNameForNumPwad(UINT16 wad, UINT16 lump); const char *W_CheckNameForNum(lumpnum_t lumpnum); From 0405b3922c6104a4e1c1eee899e8ebb07209260a Mon Sep 17 00:00:00 2001 From: lachablock Date: Tue, 23 Mar 2021 14:49:22 +1100 Subject: [PATCH 0627/1080] Do not let nonspin characters enter sectors they could not enter if standing at full height --- src/lua_baselib.c | 22 ++++++++++++++++++++++ src/p_local.h | 2 ++ src/p_map.c | 11 +++++++++++ src/p_user.c | 24 ++++++++++++++++++------ 4 files changed, 53 insertions(+), 6 deletions(-) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 916fa9254..a59ba546e 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -1671,6 +1671,26 @@ static int lib_pSwitchShield(lua_State *L) return 0; } +static int lib_pPlayerCanEnterSpinGaps(lua_State *L) +{ + player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); + INLEVEL + if (!player) + return LUA_ErrInvalid(L, "player_t"); + lua_pushboolean(L, P_PlayerCanEnterSpinGaps(player)); + return 1; +} + +static int lib_pPlayerShouldUseSpinHeight(lua_State *L) +{ + player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); + INLEVEL + if (!player) + return LUA_ErrInvalid(L, "player_t"); + lua_pushboolean(L, P_PlayerShouldUseSpinHeight(player)); + return 1; +} + // P_MAP /////////// @@ -3872,6 +3892,8 @@ static luaL_Reg lib[] = { {"P_SpawnSpinMobj",lib_pSpawnSpinMobj}, {"P_Telekinesis",lib_pTelekinesis}, {"P_SwitchShield",lib_pSwitchShield}, + {"P_PlayerCanEnterSpinGaps",lib_pPlayerCanEnterSpinGaps}, + {"P_PlayerShouldUseSpinHeight",lib_pPlayerShouldUseSpinHeight}, // p_map {"P_CheckPosition",lib_pCheckPosition}, diff --git a/src/p_local.h b/src/p_local.h index 8caab0d27..8568dd4f8 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -143,6 +143,8 @@ angle_t P_GetLocalAngle(player_t *player); void P_SetLocalAngle(player_t *player, angle_t angle); void P_ForceLocalAngle(player_t *player, angle_t angle); boolean P_PlayerFullbright(player_t *player); +boolean P_PlayerCanEnterSpinGaps(player_t *player); +boolean P_PlayerShouldUseSpinHeight(player_t *player); boolean P_IsObjectInGoop(mobj_t *mo); boolean P_IsObjectOnGround(mobj_t *mo); diff --git a/src/p_map.c b/src/p_map.c index a1cad524e..7eec0937c 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -1955,6 +1955,12 @@ static boolean PIT_CheckLine(line_t *ld) // set openrange, opentop, openbottom P_LineOpening(ld, tmthing); + // players should not always cross into sectors that they could not at full height + if (tmthing->player + && openrange < P_GetPlayerHeight(tmthing->player) + && !P_PlayerCanEnterSpinGaps(tmthing->player)) + return false; + // adjust floor / ceiling heights if (opentop < tmceilingz) { @@ -3331,6 +3337,11 @@ static boolean PTR_LineIsBlocking(line_t *li) if (openbottom - slidemo->z > FixedMul(MAXSTEPMOVE, slidemo->scale)) return true; // too big a step up + if (slidemo->player + && openrange < P_GetPlayerHeight(slidemo->player) + && !P_PlayerCanEnterSpinGaps(slidemo->player)) + return true; // nonspin character should not take this path + return false; } diff --git a/src/p_user.c b/src/p_user.c index 02592053d..38f13f8fd 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -8653,12 +8653,7 @@ void P_MovePlayer(player_t *player) fixed_t oldheight = player->mo->height; // Less height while spinning. Good for spinning under things...? - if ((player->mo->state == &states[player->mo->info->painstate]) - || ((player->pflags & PF_JUMPED) && !(player->pflags & PF_NOJUMPDAMAGE)) - || (player->pflags & PF_SPINNING) - || player->powers[pw_tailsfly] || player->pflags & PF_GLIDING - || (player->charability == CA_GLIDEANDCLIMB && player->mo->state-states == S_PLAY_GLIDE_LANDING) - || (player->charability == CA_FLY && player->mo->state-states == S_PLAY_FLY_TIRED)) + if (P_PlayerShouldUseSpinHeight(player)) { player->mo->height = P_GetPlayerSpinHeight(player); atspinheight = true; @@ -12953,3 +12948,20 @@ boolean P_PlayerFullbright(player_t *player) || !(player->mo->state >= &states[S_PLAY_NIGHTS_TRANS1] && player->mo->state < &states[S_PLAY_NIGHTS_TRANS6])))); // Note the < instead of <= } + +// returns true if the player can enter a sector that they could not if standing at their skin's full height +boolean P_PlayerCanEnterSpinGaps(player_t *player) +{ + return ((player->pflags & (PF_SPINNING|PF_GLIDING)) + || (player->charability == CA_GLIDEANDCLIMB && player->mo->state-states == S_PLAY_GLIDE_LANDING)); +} + +// returns true if the player should use their skin's spinheight instead of their skin's height +boolean P_PlayerShouldUseSpinHeight(player_t *player) +{ + return (P_PlayerCanEnterSpinGaps(player) + || (player->mo->state == &states[player->mo->info->painstate]) + || ((player->pflags & PF_JUMPED) && !(player->pflags & PF_NOJUMPDAMAGE)) + || player->powers[pw_tailsfly] + || (player->charability == CA_FLY && player->mo->state-states == S_PLAY_FLY_TIRED)); +} From 08937f892a4eec9c6cdf7c0c3c1ce255941c8ba6 Mon Sep 17 00:00:00 2001 From: Jaime Ita Passos Date: Tue, 23 Mar 2021 01:18:28 -0300 Subject: [PATCH 0628/1080] Allocate a buffer for non-RGBA to RGBA texture conversions. UpdateTexture will I_Error (from AllocTextureBuffer) if the allocation fails. --- src/hardware/r_opengl/r_opengl.c | 124 ++++++++++++++++++++----------- 1 file changed, 82 insertions(+), 42 deletions(-) diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index 6967bab74..7c77c27ea 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -131,7 +131,6 @@ static const GLfloat byte2float[256] = { // -----------------+ // GL_DBG_Printf : Output debug messages to debug log if DEBUG_TO_FILE is defined, // : else do nothing -// Returns : // -----------------+ #ifdef DEBUG_TO_FILE @@ -159,8 +158,6 @@ FUNCPRINTF void GL_DBG_Printf(const char *format, ...) // -----------------+ // GL_MSG_Warning : Raises a warning. -// : -// Returns : // -----------------+ static void GL_MSG_Warning(const char *format, ...) @@ -184,8 +181,6 @@ static void GL_MSG_Warning(const char *format, ...) // -----------------+ // GL_MSG_Error : Raises an error. -// : -// Returns : // -----------------+ static void GL_MSG_Error(const char *format, ...) @@ -207,6 +202,32 @@ static void GL_MSG_Error(const char *format, ...) #endif } +// ----------------------+ +// GetTextureFormatName : Returns the corresponding texture format string from the texture format enumeration. +// ----------------------+ +static const char *GetTextureFormatName(INT32 format) +{ + static char num[12]; + + switch (format) + { + case GL_TEXFMT_P_8: return "GL_TEXFMT_P_8"; + case GL_TEXFMT_AP_88: return "GL_TEXFMT_AP_88"; + case GL_TEXFMT_RGBA: return "GL_TEXFMT_RGBA"; + case GL_TEXFMT_ALPHA_8: return "GL_TEXFMT_ALPHA_8"; + case GL_TEXFMT_INTENSITY_8: return "GL_TEXFMT_INTENSITY_8"; + case GL_TEXFMT_ALPHA_INTENSITY_88: return "GL_TEXFMT_ALPHA_INTENSITY_88"; + default: break; + } + + // If the texture format is not known (due to it being invalid), + // return a string containing the format index instead. + format = INT32_MIN; + snprintf(num, sizeof(num), "%d", format); + + return num; +} + #ifdef STATIC_OPENGL /* 1.0 functions */ /* Miscellaneous */ @@ -1375,7 +1396,6 @@ INT32 isExtAvailable(const char *extension, const GLubyte *start) // -----------------+ // Init : Initialise the OpenGL interface API -// Returns : // -----------------+ EXPORT boolean HWRAPI(Init) (void) { @@ -1737,37 +1757,59 @@ EXPORT void HWRAPI(SetBlend) (FBITFIELD PolyFlags) CurrentPolyFlags = PolyFlags; } +// -------------------+ +// AllocTextureBuffer : Allocates memory for converting a non-RGBA texture into an RGBA texture. +// -------------------+ +static RGBA_t *AllocTextureBuffer(GLMipmap_t *pTexInfo) +{ + size_t len = (pTexInfo->width * pTexInfo->height); + RGBA_t *tex = calloc(len, sizeof(RGBA_t)); + + if (tex == NULL) + I_Error("AllocTextureBuffer: out of memory allocating %s bytes for texture %d, format %s", + sizeu1(len * sizeof(RGBA_t)), pTexInfo->downloaded, GetTextureFormatName(pTexInfo->format)); + + return tex; +} + +// ------------------+ +// FreeTextureBuffer : Frees memory allocated by AllocTextureBuffer. +// ------------------+ +static void FreeTextureBuffer(RGBA_t *tex) +{ + if (tex) + free(tex); +} + // -----------------+ -// UpdateTexture : Updates the texture data. +// UpdateTexture : Updates texture data. // -----------------+ EXPORT void HWRAPI(UpdateTexture) (GLMipmap_t *pTexInfo) { - // Download a mipmap - boolean updatemipmap = true; - static RGBA_t tex[2048*2048]; - const GLvoid *ptex = tex; - INT32 w, h; - GLuint texnum = 0; + // Upload a texture + GLuint num = pTexInfo->downloaded; + boolean update = true; - if (!pTexInfo->downloaded) + INT32 w = pTexInfo->width, h = pTexInfo->height; + INT32 i, j; + + const GLubyte *pImgData = (const GLubyte *)pTexInfo->data; + const GLvoid *ptex = NULL; + RGBA_t *tex = NULL; + + // Generate a new texture name. + if (!num) { - pglGenTextures(1, &texnum); - pTexInfo->downloaded = texnum; - updatemipmap = false; + pglGenTextures(1, &num); + pTexInfo->downloaded = num; + update = false; } - else - texnum = pTexInfo->downloaded; - //GL_DBG_Printf ("DownloadMipmap %d %x\n",(INT32)texnum,pTexInfo->data); + //GL_DBG_Printf("UpdateTexture %d %x\n", (INT32)num, pImgData); - w = pTexInfo->width; - h = pTexInfo->height; - - if ((pTexInfo->format == GL_TEXFMT_P_8) || - (pTexInfo->format == GL_TEXFMT_AP_88)) + if ((pTexInfo->format == GL_TEXFMT_P_8) || (pTexInfo->format == GL_TEXFMT_AP_88)) { - const GLubyte *pImgData = (const GLubyte *)pTexInfo->data; - INT32 i, j; + ptex = tex = AllocTextureBuffer(pTexInfo); for (j = 0; j < h; j++) { @@ -1798,20 +1840,17 @@ EXPORT void HWRAPI(UpdateTexture) (GLMipmap_t *pTexInfo) tex[w*j+i].s.alpha = *pImgData; pImgData++; } - } } } else if (pTexInfo->format == GL_TEXFMT_RGBA) { - // corona test : passed as ARGB 8888, which is not in glide formats - // Hurdler: not used for coronas anymore, just for dynamic lighting - ptex = pTexInfo->data; + // Directly upload the texture data without any kind of conversion. + ptex = pImgData; } else if (pTexInfo->format == GL_TEXFMT_ALPHA_INTENSITY_88) { - const GLubyte *pImgData = (const GLubyte *)pTexInfo->data; - INT32 i, j; + ptex = tex = AllocTextureBuffer(pTexInfo); for (j = 0; j < h; j++) { @@ -1828,8 +1867,7 @@ EXPORT void HWRAPI(UpdateTexture) (GLMipmap_t *pTexInfo) } else if (pTexInfo->format == GL_TEXFMT_ALPHA_8) // Used for fade masks { - const GLubyte *pImgData = (const GLubyte *)pTexInfo->data; - INT32 i, j; + ptex = tex = AllocTextureBuffer(pTexInfo); for (j = 0; j < h; j++) { @@ -1844,11 +1882,10 @@ EXPORT void HWRAPI(UpdateTexture) (GLMipmap_t *pTexInfo) } } else - GL_MSG_Warning ("SetTexture(bad format) %ld\n", pTexInfo->format); + GL_MSG_Warning("UpdateTexture: bad format %d\n", pTexInfo->format); - // the texture number was already generated by pglGenTextures - pglBindTexture(GL_TEXTURE_2D, texnum); - tex_downloaded = texnum; + pglBindTexture(GL_TEXTURE_2D, num); + tex_downloaded = num; // disable texture filtering on any texture that has holes so there's no dumb borders or blending issues if (pTexInfo->flags & TF_TRANSPARENT) @@ -1877,7 +1914,7 @@ EXPORT void HWRAPI(UpdateTexture) (GLMipmap_t *pTexInfo) } else { - if (updatemipmap) + if (update) pglTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, w, h, GL_RGBA, GL_UNSIGNED_BYTE, ptex); else pglTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE_ALPHA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, ptex); @@ -1898,7 +1935,7 @@ EXPORT void HWRAPI(UpdateTexture) (GLMipmap_t *pTexInfo) } else { - if (updatemipmap) + if (update) pglTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, w, h, GL_RGBA, GL_UNSIGNED_BYTE, ptex); else pglTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, ptex); @@ -1918,13 +1955,16 @@ EXPORT void HWRAPI(UpdateTexture) (GLMipmap_t *pTexInfo) } else { - if (updatemipmap) + if (update) pglTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, w, h, GL_RGBA, GL_UNSIGNED_BYTE, ptex); else pglTexImage2D(GL_TEXTURE_2D, 0, textureformatGL, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, ptex); } } + // Free the texture buffer + FreeTextureBuffer(tex); + if (pTexInfo->flags & TF_WRAPX) pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); else From f99d89742a7c0347bb7e2092fa1ede7a02766abc Mon Sep 17 00:00:00 2001 From: lachablock Date: Thu, 25 Mar 2021 15:09:04 +1100 Subject: [PATCH 0629/1080] Revise conditions under which players use spinheight and enter gaps: - players with SF_NOJUMPDAMAGE but *not* SF_NOJUMPSPIN now always use spinheight while jumping (i.e. even with PF_NOJUMPDAMAGE), as long as their panim is PA_JUMP or PA_ROLL - players with SF_NOJUMPSPIN no longer use spinheight while jumping (but,) - PA_ROLL is now an acceptable condition for using spinheight (but not for entering gaps, e.g. S3K shields will shrink the hitbox but not allow gap entry on their own) - flying players now only use spinheight if they do not have SF_NOJUMPSPIN (you're welcome, EggpackRE) - players with neither SF_NOJUMPSPIN nor SF_NOJUMPDAMAGE use the same conditions as in 2.2.9 prerelease, i.e. use spinheight and can enter gaps unless they have PF_NOJUMPDAMAGE --- src/p_user.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index 38f13f8fd..63942e0be 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -12949,11 +12949,18 @@ boolean P_PlayerFullbright(player_t *player) && player->mo->state < &states[S_PLAY_NIGHTS_TRANS6])))); // Note the < instead of <= } +#define JUMPCURLED(player) ((player->pflags & PF_JUMPED)\ + && (!(player->charflags & SF_NOJUMPSPIN))\ + && (!(player->pflags & PF_NOJUMPDAMAGE)\ + || ((player->charflags & SF_NOJUMPDAMAGE)\ + && (player->panim == PA_JUMP || player->panim == PA_ROLL))))\ + // returns true if the player can enter a sector that they could not if standing at their skin's full height boolean P_PlayerCanEnterSpinGaps(player_t *player) { - return ((player->pflags & (PF_SPINNING|PF_GLIDING)) - || (player->charability == CA_GLIDEANDCLIMB && player->mo->state-states == S_PLAY_GLIDE_LANDING)); + return ((player->pflags & (PF_SPINNING|PF_GLIDING)) // players who are spinning or gliding + || (player->charability == CA_GLIDEANDCLIMB && player->mo->state-states == S_PLAY_GLIDE_LANDING) // players who are landing from a glide + || JUMPCURLED(player)); // players who are jumpcurled, but only if they would normally jump that way } // returns true if the player should use their skin's spinheight instead of their skin's height @@ -12961,7 +12968,7 @@ boolean P_PlayerShouldUseSpinHeight(player_t *player) { return (P_PlayerCanEnterSpinGaps(player) || (player->mo->state == &states[player->mo->info->painstate]) - || ((player->pflags & PF_JUMPED) && !(player->pflags & PF_NOJUMPDAMAGE)) - || player->powers[pw_tailsfly] - || (player->charability == CA_FLY && player->mo->state-states == S_PLAY_FLY_TIRED)); + || (player->panim == PA_ROLL) + || ((player->powers[pw_tailsfly] || (player->charability == CA_FLY && player->mo->state-states == S_PLAY_FLY_TIRED)) + && !(player->charflags & SF_NOJUMPSPIN))); } From b1a926288961fceda7cab4205fed66a706500726 Mon Sep 17 00:00:00 2001 From: lachablock Date: Thu, 25 Mar 2021 15:25:35 +1100 Subject: [PATCH 0630/1080] Fix P_PlayerCanEnterGaps issues with polyobject collision --- src/p_map.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/p_map.c b/src/p_map.c index 7eec0937c..bf668ba3e 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -1955,12 +1955,6 @@ static boolean PIT_CheckLine(line_t *ld) // set openrange, opentop, openbottom P_LineOpening(ld, tmthing); - // players should not always cross into sectors that they could not at full height - if (tmthing->player - && openrange < P_GetPlayerHeight(tmthing->player) - && !P_PlayerCanEnterSpinGaps(tmthing->player)) - return false; - // adjust floor / ceiling heights if (opentop < tmceilingz) { @@ -2729,7 +2723,10 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff) if (thing->type == MT_SKIM) maxstep = 0; - if (tmceilingz - tmfloorz < thing->height) + if (tmceilingz - tmfloorz < thing->height + || (thing->player + && tmceilingz - tmfloorz < P_GetPlayerHeight(thing->player) + && !P_PlayerCanEnterSpinGaps(thing->player))) { if (tmfloorthing) tmhitthing = tmfloorthing; From 6ea96536810cc8ad95708436a4f5afd03be3154f Mon Sep 17 00:00:00 2001 From: lachablock Date: Thu, 25 Mar 2021 21:41:09 +1100 Subject: [PATCH 0631/1080] Add PlayerHeight and PlayerCanEnterSpinGaps Lua hooks --- src/lua_hook.h | 4 +++ src/lua_hooklib.c | 90 +++++++++++++++++++++++++++++++++++++++++++++++ src/p_user.c | 21 +++++++++-- 3 files changed, 112 insertions(+), 3 deletions(-) diff --git a/src/lua_hook.h b/src/lua_hook.h index 5cfcb8360..0d631aa4e 100644 --- a/src/lua_hook.h +++ b/src/lua_hook.h @@ -61,6 +61,8 @@ enum hook { hook_GameQuit, hook_PlayerCmd, hook_MusicChange, + hook_PlayerHeight, + hook_PlayerCanEnterSpinGaps, hook_MAX // last hook }; @@ -118,3 +120,5 @@ boolean LUAh_ShouldJingleContinue(player_t *player, const char *musname); // Hoo void LUAh_GameQuit(boolean quitting); // Hook for game quitting boolean LUAh_PlayerCmd(player_t *player, ticcmd_t *cmd); // Hook for building player's ticcmd struct (Ported from SRB2Kart) boolean LUAh_MusicChange(const char *oldname, char *newname, UINT16 *mflags, boolean *looping, UINT32 *position, UINT32 *prefadems, UINT32 *fadeinms); // Hook for music changes +fixed_t LUAh_PlayerHeight(player_t *player); +UINT8 LUAh_PlayerCanEnterSpinGaps(player_t *player); diff --git a/src/lua_hooklib.c b/src/lua_hooklib.c index 29c15a4de..6e9b9d65c 100644 --- a/src/lua_hooklib.c +++ b/src/lua_hooklib.c @@ -77,6 +77,8 @@ const char *const hookNames[hook_MAX+1] = { "GameQuit", "PlayerCmd", "MusicChange", + "PlayerHeight", + "PlayerCanEnterSpinGaps", NULL }; @@ -221,6 +223,8 @@ static int lib_addHook(lua_State *L) case hook_ShieldSpawn: case hook_ShieldSpecial: case hook_PlayerThink: + case hook_PlayerHeight: + case hook_PlayerCanEnterSpinGaps: lastp = &playerhooks; break; case hook_LinedefExecute: @@ -1971,3 +1975,89 @@ boolean LUAh_MusicChange(const char *oldname, char *newname, UINT16 *mflags, boo newname[6] = 0; return hooked; } + +// Hook for determining player height +fixed_t LUAh_PlayerHeight(player_t *player) +{ + hook_p hookp; + fixed_t newheight = -1; + if (!gL || !(hooksAvailable[hook_PlayerHeight/8] & (1<<(hook_PlayerHeight%8)))) + return 0; + + lua_settop(gL, 0); + lua_pushcfunction(gL, LUA_GetErrorMessage); + + for (hookp = playerhooks; hookp; hookp = hookp->next) + { + if (hookp->type != hook_PlayerHeight) + continue; + + ps_lua_mobjhooks++; + if (lua_gettop(gL) == 1) + LUA_PushUserdata(gL, player, META_PLAYER); + PushHook(gL, hookp); + lua_pushvalue(gL, -2); + if (lua_pcall(gL, 1, 1, 1)) { + if (!hookp->error || cv_debug & DBG_LUA) + CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); + lua_pop(gL, 1); + hookp->error = true; + continue; + } + if (!lua_isnil(gL, -1)) + { + fixed_t returnedheight = lua_tonumber(gL, -1); + // 0 height has... strange results, but it's not problematic like negative heights are. + // when an object's height is set to a negative number directly with lua, it's forced to 0 instead. + // here, I think it's better to ignore negatives so that they don't replace any results of previous hooks! + if (returnedheight >= 0) + newheight = returnedheight; + } + lua_pop(gL, 1); + } + + lua_settop(gL, 0); + return newheight; +} + +// Hook for determining whether players are allowed passage through spin gaps +UINT8 LUAh_PlayerCanEnterSpinGaps(player_t *player) +{ + hook_p hookp; + UINT8 canEnter = 0; // 0 = default, 1 = force yes, 2 = force no. + if (!gL || !(hooksAvailable[hook_PlayerCanEnterSpinGaps/8] & (1<<(hook_PlayerCanEnterSpinGaps%8)))) + return 0; + + lua_settop(gL, 0); + lua_pushcfunction(gL, LUA_GetErrorMessage); + + for (hookp = playerhooks; hookp; hookp = hookp->next) + { + if (hookp->type != hook_PlayerCanEnterSpinGaps) + continue; + + ps_lua_mobjhooks++; + if (lua_gettop(gL) == 1) + LUA_PushUserdata(gL, player, META_PLAYER); + PushHook(gL, hookp); + lua_pushvalue(gL, -2); + if (lua_pcall(gL, 1, 1, 1)) { + if (!hookp->error || cv_debug & DBG_LUA) + CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); + lua_pop(gL, 1); + hookp->error = true; + continue; + } + if (!lua_isnil(gL, -1)) + { // if nil, leave canEnter = 0. + if (lua_toboolean(gL, -1)) + canEnter = 1; // Force yes + else + canEnter = 2; // Force no + } + lua_pop(gL, 1); + } + + lua_settop(gL, 0); + return canEnter; +} diff --git a/src/p_user.c b/src/p_user.c index 63942e0be..56767f433 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -8651,9 +8651,16 @@ void P_MovePlayer(player_t *player) { boolean atspinheight = false; fixed_t oldheight = player->mo->height; + fixed_t luaheight = LUAh_PlayerHeight(player); + if (luaheight != -1) + { + player->mo->height = luaheight; + if (luaheight <= P_GetPlayerSpinHeight(player)) + atspinheight = true; // spinning will not save you from being crushed + } // Less height while spinning. Good for spinning under things...? - if (P_PlayerShouldUseSpinHeight(player)) + else if (P_PlayerShouldUseSpinHeight(player)) { player->mo->height = P_GetPlayerSpinHeight(player); atspinheight = true; @@ -12958,6 +12965,12 @@ boolean P_PlayerFullbright(player_t *player) // returns true if the player can enter a sector that they could not if standing at their skin's full height boolean P_PlayerCanEnterSpinGaps(player_t *player) { + UINT8 canEnter = LUAh_PlayerCanEnterSpinGaps(player); + if (canEnter == 1) + return true; + else if (canEnter == 2) + return false; + return ((player->pflags & (PF_SPINNING|PF_GLIDING)) // players who are spinning or gliding || (player->charability == CA_GLIDEANDCLIMB && player->mo->state-states == S_PLAY_GLIDE_LANDING) // players who are landing from a glide || JUMPCURLED(player)); // players who are jumpcurled, but only if they would normally jump that way @@ -12966,9 +12979,11 @@ boolean P_PlayerCanEnterSpinGaps(player_t *player) // returns true if the player should use their skin's spinheight instead of their skin's height boolean P_PlayerShouldUseSpinHeight(player_t *player) { - return (P_PlayerCanEnterSpinGaps(player) + return ((player->pflags & (PF_SPINNING|PF_GLIDING)) || (player->mo->state == &states[player->mo->info->painstate]) || (player->panim == PA_ROLL) || ((player->powers[pw_tailsfly] || (player->charability == CA_FLY && player->mo->state-states == S_PLAY_FLY_TIRED)) - && !(player->charflags & SF_NOJUMPSPIN))); + && !(player->charflags & SF_NOJUMPSPIN)) + || (player->charability == CA_GLIDEANDCLIMB && player->mo->state-states == S_PLAY_GLIDE_LANDING) + || JUMPCURLED(player)); } From 000e865f80f3e4f7e77184cc140eaf0dabb1c09b Mon Sep 17 00:00:00 2001 From: lachablock Date: Thu, 25 Mar 2021 21:42:25 +1100 Subject: [PATCH 0632/1080] Revise spinheight/gap entry conditions (again), let's keep things WAY simpler: - PF_NOJUMPDAMAGE no longer affects height at all (you're welcome katsy). - Characters with SF_NOJUMPSPIN will only use spinheight when panim is PA_ROLL. They cannot enter gaps when jumping with spinheight, unless also spinning or gliding. - All other characters use spinheight when panim is PA_JUMP or PA_ROLL. They can enter gaps when jumping with spinheight. --- src/p_user.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index 56767f433..6c7cdb0d0 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -12958,9 +12958,7 @@ boolean P_PlayerFullbright(player_t *player) #define JUMPCURLED(player) ((player->pflags & PF_JUMPED)\ && (!(player->charflags & SF_NOJUMPSPIN))\ - && (!(player->pflags & PF_NOJUMPDAMAGE)\ - || ((player->charflags & SF_NOJUMPDAMAGE)\ - && (player->panim == PA_JUMP || player->panim == PA_ROLL))))\ + && (player->panim == PA_JUMP || player->panim == PA_ROLL))\ // returns true if the player can enter a sector that they could not if standing at their skin's full height boolean P_PlayerCanEnterSpinGaps(player_t *player) From 6267abac8add71a70409fd9987630c44fc56befd Mon Sep 17 00:00:00 2001 From: SwitchKaze Date: Thu, 25 Mar 2021 12:43:30 -0500 Subject: [PATCH 0633/1080] Fix console text bleeding --- src/console.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/console.c b/src/console.c index f3b0aa603..2d95e10b8 100644 --- a/src/console.c +++ b/src/console.c @@ -1652,6 +1652,7 @@ static void CON_DrawHudlines(void) { charflags = (*p & 0x7f) << V_CHARCOLORSHIFT; p++; + c++; } if (*p < HU_FONTSTART) ;//charwidth = 4 * con_scalefactor; @@ -1774,6 +1775,7 @@ static void CON_DrawConsole(void) { charflags = (*p & 0x7f) << V_CHARCOLORSHIFT; p++; + c++; } V_DrawCharacter(x, y, (INT32)(*p) | charflags | cv_constextsize.value | V_NOSCALESTART, true); } From b6e5837161e29191e9ce16f2f08e760b45030acb Mon Sep 17 00:00:00 2001 From: LJ Sonic Date: Thu, 25 Mar 2021 22:28:07 +0100 Subject: [PATCH 0634/1080] Use a separate transfer status for disconnected nodes --- src/d_netfil.c | 16 +++++++++------- src/d_netfil.h | 5 +++-- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/d_netfil.c b/src/d_netfil.c index 8f661bb5f..e15c15bd5 100644 --- a/src/d_netfil.c +++ b/src/d_netfil.c @@ -562,7 +562,7 @@ static void SV_PrepareSendLuaFileToNextNode(void) // Find a client to send the file to for (i = 1; i < MAXNETNODES; i++) - if (nodeingame[i] && luafiletransfers->nodestatus[i] == LFTNS_WAITING) // Node waiting + if (luafiletransfers->nodestatus[i] == LFTNS_WAITING) // Node waiting { // Tell the client we're about to send them the file netbuffer->packettype = PT_SENDINGLUAFILE; @@ -588,7 +588,7 @@ void SV_PrepareSendLuaFile(void) // Set status to "waiting" for everyone for (i = 0; i < MAXNETNODES; i++) - luafiletransfers->nodestatus[i] = LFTNS_WAITING; + luafiletransfers->nodestatus[i] = (nodeingame[i] ? LFTNS_WAITING : LFTNS_NONE); if (FIL_ReadFileOK(luafiletransfers->realfilename)) { @@ -649,12 +649,14 @@ void RemoveAllLuaFileTransfers(void) void SV_AbortLuaFileTransfer(INT32 node) { - if (luafiletransfers - && (luafiletransfers->nodestatus[node] == LFTNS_ASKED - || luafiletransfers->nodestatus[node] == LFTNS_SENDING)) + if (luafiletransfers) { - luafiletransfers->nodestatus[node] = LFTNS_WAITING; - SV_PrepareSendLuaFileToNextNode(); + if (luafiletransfers->nodestatus[node] == LFTNS_ASKED + || luafiletransfers->nodestatus[node] == LFTNS_SENDING) + { + SV_PrepareSendLuaFileToNextNode(); + } + luafiletransfers->nodestatus[node] = LFTNS_NONE; } } diff --git a/src/d_netfil.h b/src/d_netfil.h index 1b399be75..2e656e0f6 100644 --- a/src/d_netfil.h +++ b/src/d_netfil.h @@ -85,10 +85,11 @@ boolean PT_RequestFile(INT32 node); typedef enum { + LFTNS_NONE, // This node is not connected LFTNS_WAITING, // This node is waiting for the server to send the file - LFTNS_ASKED, // The server has told the node they're ready to send the file + LFTNS_ASKED, // The server has told the node they're ready to send the file LFTNS_SENDING, // The server is sending the file to this node - LFTNS_SENT // The node already has the file + LFTNS_SENT // The node already has the file } luafiletransfernodestatus_t; typedef struct luafiletransfer_s From 854e43ea7c7cf3b3eb81e7388958f6546ce28ab6 Mon Sep 17 00:00:00 2001 From: LJ Sonic Date: Thu, 25 Mar 2021 22:28:07 +0100 Subject: [PATCH 0635/1080] Kick clients if they take too long to download a Lua file --- src/d_netfil.c | 17 +++++++++++++++++ src/d_netfil.h | 1 + 2 files changed, 18 insertions(+) diff --git a/src/d_netfil.c b/src/d_netfil.c index e15c15bd5..50dc2ba60 100644 --- a/src/d_netfil.c +++ b/src/d_netfil.c @@ -570,6 +570,7 @@ static void SV_PrepareSendLuaFileToNextNode(void) I_Error("Failed to send a PT_SENDINGLUAFILE packet\n"); // !!! Todo: Handle failure a bit better lol luafiletransfers->nodestatus[i] = LFTNS_ASKED; + luafiletransfers->nodetimeouts[i] = I_GetTime() + 30 * TICRATE; return; } @@ -930,6 +931,22 @@ void FileSendTicker(void) filetx_t *f; INT32 packetsent, ram, i, j; + // If someone is taking too long to download, kick them with a timeout + // to prevent blocking the rest of the server... + if (luafiletransfers) + { + for (i = 1; i < MAXNETNODES; i++) + { + luafiletransfernodestatus_t status = luafiletransfers->nodestatus[i]; + + if (status != LFTNS_NONE && status != LFTNS_WAITING && status != LFTNS_SENT + && I_GetTime() > luafiletransfers->nodetimeouts[i]) + { + Net_ConnectionTimeout(i); + } + } + } + if (!filestosend) // No file to send return; diff --git a/src/d_netfil.h b/src/d_netfil.h index 2e656e0f6..158149477 100644 --- a/src/d_netfil.h +++ b/src/d_netfil.h @@ -100,6 +100,7 @@ typedef struct luafiletransfer_s INT32 id; // Callback ID boolean ongoing; luafiletransfernodestatus_t nodestatus[MAXNETNODES]; + tic_t nodetimeouts[MAXNETNODES]; struct luafiletransfer_s *next; } luafiletransfer_t; From 8162d90c9427dea87223133048998d42afc7d032 Mon Sep 17 00:00:00 2001 From: lachablock Date: Fri, 26 Mar 2021 18:01:55 +1100 Subject: [PATCH 0636/1080] Fix LUAh_PlayerHeight returning wrong default value --- src/lua_hooklib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lua_hooklib.c b/src/lua_hooklib.c index 6e9b9d65c..637809fd8 100644 --- a/src/lua_hooklib.c +++ b/src/lua_hooklib.c @@ -1982,7 +1982,7 @@ fixed_t LUAh_PlayerHeight(player_t *player) hook_p hookp; fixed_t newheight = -1; if (!gL || !(hooksAvailable[hook_PlayerHeight/8] & (1<<(hook_PlayerHeight%8)))) - return 0; + return newheight; lua_settop(gL, 0); lua_pushcfunction(gL, LUA_GetErrorMessage); From 55d63000f4eb4de8cfcd533d6e1d3c46f0db5306 Mon Sep 17 00:00:00 2001 From: katsy Date: Sat, 27 Mar 2021 18:30:59 -0500 Subject: [PATCH 0637/1080] don't HWR_ClearAllTextures() in software --- src/p_setup.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index 41d8822e2..28ea613d5 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -4135,7 +4135,7 @@ boolean P_LoadLevel(boolean fromnetsave, boolean reloadinggamestate) #ifdef HWRENDER // Free GPU textures before freeing patches. - if (vid.glstate == VID_GL_LIBRARY_LOADED) + if (rendermode == render_opengl && (vid.glstate == VID_GL_LIBRARY_LOADED)) HWR_ClearAllTextures(); #endif @@ -4500,7 +4500,7 @@ boolean P_AddWadFile(const char *wadfilename) #ifdef HWRENDER // Free GPU textures before freeing patches. - if (vid.glstate == VID_GL_LIBRARY_LOADED) + if (rendermode == render_opengl && (vid.glstate == VID_GL_LIBRARY_LOADED)) HWR_ClearAllTextures(); #endif From d6eaf7e0ff479a1c6ae907779c47877e3abc88e3 Mon Sep 17 00:00:00 2001 From: katsy Date: Sun, 28 Mar 2021 12:22:04 -0500 Subject: [PATCH 0638/1080] clear before switching, not after --- src/screen.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/screen.c b/src/screen.c index 9d36eee39..02de884bf 100644 --- a/src/screen.c +++ b/src/screen.c @@ -33,6 +33,11 @@ #include "s_sound.h" // ditto #include "g_game.h" // ditto #include "p_local.h" // P_AutoPause() +#ifdef HWRENDER +#include "hardware/hw_main.h" +#include "hardware/hw_light.h" +#include "hardware/hw_model.h" +#endif #if defined (USEASM) && !defined (NORUSEASM)//&& (!defined (_MSC_VER) || (_MSC_VER <= 1200)) @@ -423,6 +428,10 @@ void SCR_ChangeRenderer(void) CONS_Alert(CONS_ERROR, "OpenGL never loaded\n"); return; } + + if (rendermode == render_opengl && (vid.glstate == VID_GL_LIBRARY_LOADED)) // Clear these out before switching to software + HWR_ClearAllTextures(); + #endif // Set the new render mode From 428ae3127e76753aa47c79b07867560bf9145c60 Mon Sep 17 00:00:00 2001 From: Mari0shi06 Date: Sun, 28 Mar 2021 17:12:58 -0400 Subject: [PATCH 0639/1080] Change Raspberry's chat colormap to V_ROSYMAP --- src/info.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/info.c b/src/info.c index ee836a372..19a477e5b 100644 --- a/src/info.c +++ b/src/info.c @@ -21761,7 +21761,7 @@ skincolor_t skincolors[MAXSKINCOLORS] = { {"Violet", {0xd0, 0xd1, 0xd2, 0xca, 0xcc, 0xb8, 0xb9, 0xb9, 0xba, 0xa8, 0xa8, 0xa9, 0xa9, 0xfd, 0xfe, 0xfe}, SKINCOLOR_MINT, 6, V_MAGENTAMAP, true}, // SKINCOLOR_VIOLET {"Lilac", {0x00, 0xd0, 0xd1, 0xd2, 0xd3, 0xc1, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc5, 0xc6, 0xc6, 0xfe, 0x1f}, SKINCOLOR_VAPOR, 4, V_ROSYMAP, true}, // SKINCOLOR_LILAC {"Plum", {0xc8, 0xd3, 0xd5, 0xd6, 0xd7, 0xce, 0xcf, 0xb9, 0xb9, 0xba, 0xba, 0xa9, 0xa9, 0xa9, 0xfd, 0xfe}, SKINCOLOR_MINT, 7, V_ROSYMAP, true}, // SKINCOLOR_PLUM - {"Raspberry", {0xc8, 0xc9, 0xca, 0xcb, 0xcb, 0xcc, 0xcd, 0xcd, 0xce, 0xb9, 0xb9, 0xba, 0xba, 0xbb, 0xfe, 0xfe}, SKINCOLOR_APPLE, 13, V_MAGENTAMAP, true}, // SKINCOLOR_RASPBERRY + {"Raspberry", {0xc8, 0xc9, 0xca, 0xcb, 0xcb, 0xcc, 0xcd, 0xcd, 0xce, 0xb9, 0xb9, 0xba, 0xba, 0xbb, 0xfe, 0xfe}, SKINCOLOR_APPLE, 13, V_ROSYMAP, true}, // SKINCOLOR_RASPBERRY {"Rosy", {0xfc, 0xc8, 0xc8, 0xc9, 0xc9, 0xca, 0xca, 0xcb, 0xcb, 0xcc, 0xcc, 0xcd, 0xcd, 0xce, 0xce, 0xcf}, SKINCOLOR_AQUA, 1, V_ROSYMAP, true}, // SKINCOLOR_ROSY // super From 424f67a74b5aff5083c174a81a21664a1a63e6dc Mon Sep 17 00:00:00 2001 From: Mari0shi06 Date: Sun, 28 Mar 2021 21:19:26 +0000 Subject: [PATCH 0640/1080] Revert "Change Raspberry's chat colormap to V_ROSYMAP" This reverts commit 428ae3127e76753aa47c79b07867560bf9145c60 --- src/info.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/info.c b/src/info.c index 19a477e5b..ee836a372 100644 --- a/src/info.c +++ b/src/info.c @@ -21761,7 +21761,7 @@ skincolor_t skincolors[MAXSKINCOLORS] = { {"Violet", {0xd0, 0xd1, 0xd2, 0xca, 0xcc, 0xb8, 0xb9, 0xb9, 0xba, 0xa8, 0xa8, 0xa9, 0xa9, 0xfd, 0xfe, 0xfe}, SKINCOLOR_MINT, 6, V_MAGENTAMAP, true}, // SKINCOLOR_VIOLET {"Lilac", {0x00, 0xd0, 0xd1, 0xd2, 0xd3, 0xc1, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc5, 0xc6, 0xc6, 0xfe, 0x1f}, SKINCOLOR_VAPOR, 4, V_ROSYMAP, true}, // SKINCOLOR_LILAC {"Plum", {0xc8, 0xd3, 0xd5, 0xd6, 0xd7, 0xce, 0xcf, 0xb9, 0xb9, 0xba, 0xba, 0xa9, 0xa9, 0xa9, 0xfd, 0xfe}, SKINCOLOR_MINT, 7, V_ROSYMAP, true}, // SKINCOLOR_PLUM - {"Raspberry", {0xc8, 0xc9, 0xca, 0xcb, 0xcb, 0xcc, 0xcd, 0xcd, 0xce, 0xb9, 0xb9, 0xba, 0xba, 0xbb, 0xfe, 0xfe}, SKINCOLOR_APPLE, 13, V_ROSYMAP, true}, // SKINCOLOR_RASPBERRY + {"Raspberry", {0xc8, 0xc9, 0xca, 0xcb, 0xcb, 0xcc, 0xcd, 0xcd, 0xce, 0xb9, 0xb9, 0xba, 0xba, 0xbb, 0xfe, 0xfe}, SKINCOLOR_APPLE, 13, V_MAGENTAMAP, true}, // SKINCOLOR_RASPBERRY {"Rosy", {0xfc, 0xc8, 0xc8, 0xc9, 0xc9, 0xca, 0xca, 0xcb, 0xcb, 0xcc, 0xcc, 0xcd, 0xcd, 0xce, 0xce, 0xcf}, SKINCOLOR_AQUA, 1, V_ROSYMAP, true}, // SKINCOLOR_ROSY // super From 192fa5cb4b2d13ac6e1a026c3a190cece32201fc Mon Sep 17 00:00:00 2001 From: Mari0shi06 Date: Sun, 28 Mar 2021 17:26:41 -0400 Subject: [PATCH 0641/1080] Change Raspberry's chat color to V_ROSYMAP --- src/info.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/info.c b/src/info.c index ee836a372..2b577c07e 100644 --- a/src/info.c +++ b/src/info.c @@ -21761,7 +21761,7 @@ skincolor_t skincolors[MAXSKINCOLORS] = { {"Violet", {0xd0, 0xd1, 0xd2, 0xca, 0xcc, 0xb8, 0xb9, 0xb9, 0xba, 0xa8, 0xa8, 0xa9, 0xa9, 0xfd, 0xfe, 0xfe}, SKINCOLOR_MINT, 6, V_MAGENTAMAP, true}, // SKINCOLOR_VIOLET {"Lilac", {0x00, 0xd0, 0xd1, 0xd2, 0xd3, 0xc1, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc5, 0xc6, 0xc6, 0xfe, 0x1f}, SKINCOLOR_VAPOR, 4, V_ROSYMAP, true}, // SKINCOLOR_LILAC {"Plum", {0xc8, 0xd3, 0xd5, 0xd6, 0xd7, 0xce, 0xcf, 0xb9, 0xb9, 0xba, 0xba, 0xa9, 0xa9, 0xa9, 0xfd, 0xfe}, SKINCOLOR_MINT, 7, V_ROSYMAP, true}, // SKINCOLOR_PLUM - {"Raspberry", {0xc8, 0xc9, 0xca, 0xcb, 0xcb, 0xcc, 0xcd, 0xcd, 0xce, 0xb9, 0xb9, 0xba, 0xba, 0xbb, 0xfe, 0xfe}, SKINCOLOR_APPLE, 13, V_MAGENTAMAP, true}, // SKINCOLOR_RASPBERRY + {"Raspberry", {0xc8, 0xc9, 0xca, 0xcb, 0xcb, 0xcc, 0xcd, 0xcd, 0xce, 0xb9, 0xb9, 0xba, 0xba, 0xbb, 0xfe, 0xfe}, SKINCOLOR_APPLE, 13, V_ROSYMAP, true}, // SKINCOLOR_RASPBERRY {"Rosy", {0xfc, 0xc8, 0xc8, 0xc9, 0xc9, 0xca, 0xca, 0xcb, 0xcb, 0xcc, 0xcc, 0xcd, 0xcd, 0xce, 0xce, 0xcf}, SKINCOLOR_AQUA, 1, V_ROSYMAP, true}, // SKINCOLOR_ROSY // super From 715a3661b5e2cdc8ae3ef8dd5374427031d9da4b Mon Sep 17 00:00:00 2001 From: Mari0shi06 Date: Sun, 28 Mar 2021 21:27:46 +0000 Subject: [PATCH 0642/1080] Revert "Change Raspberry's chat color to V_ROSYMAP" This reverts commit 192fa5cb4b2d13ac6e1a026c3a190cece32201fc --- src/info.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/info.c b/src/info.c index 2b577c07e..ee836a372 100644 --- a/src/info.c +++ b/src/info.c @@ -21761,7 +21761,7 @@ skincolor_t skincolors[MAXSKINCOLORS] = { {"Violet", {0xd0, 0xd1, 0xd2, 0xca, 0xcc, 0xb8, 0xb9, 0xb9, 0xba, 0xa8, 0xa8, 0xa9, 0xa9, 0xfd, 0xfe, 0xfe}, SKINCOLOR_MINT, 6, V_MAGENTAMAP, true}, // SKINCOLOR_VIOLET {"Lilac", {0x00, 0xd0, 0xd1, 0xd2, 0xd3, 0xc1, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc5, 0xc6, 0xc6, 0xfe, 0x1f}, SKINCOLOR_VAPOR, 4, V_ROSYMAP, true}, // SKINCOLOR_LILAC {"Plum", {0xc8, 0xd3, 0xd5, 0xd6, 0xd7, 0xce, 0xcf, 0xb9, 0xb9, 0xba, 0xba, 0xa9, 0xa9, 0xa9, 0xfd, 0xfe}, SKINCOLOR_MINT, 7, V_ROSYMAP, true}, // SKINCOLOR_PLUM - {"Raspberry", {0xc8, 0xc9, 0xca, 0xcb, 0xcb, 0xcc, 0xcd, 0xcd, 0xce, 0xb9, 0xb9, 0xba, 0xba, 0xbb, 0xfe, 0xfe}, SKINCOLOR_APPLE, 13, V_ROSYMAP, true}, // SKINCOLOR_RASPBERRY + {"Raspberry", {0xc8, 0xc9, 0xca, 0xcb, 0xcb, 0xcc, 0xcd, 0xcd, 0xce, 0xb9, 0xb9, 0xba, 0xba, 0xbb, 0xfe, 0xfe}, SKINCOLOR_APPLE, 13, V_MAGENTAMAP, true}, // SKINCOLOR_RASPBERRY {"Rosy", {0xfc, 0xc8, 0xc8, 0xc9, 0xc9, 0xca, 0xca, 0xcb, 0xcb, 0xcc, 0xcc, 0xcd, 0xcd, 0xce, 0xce, 0xcf}, SKINCOLOR_AQUA, 1, V_ROSYMAP, true}, // SKINCOLOR_ROSY // super From 29704e141b9bc2b265a58f41a2ff1c7a293b3ad7 Mon Sep 17 00:00:00 2001 From: Mari0shi06 Date: Sun, 28 Mar 2021 17:29:24 -0400 Subject: [PATCH 0643/1080] Change Raspberry's chat colormap to V_ROSYMAP --- src/info.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/info.c b/src/info.c index ee836a372..2b577c07e 100644 --- a/src/info.c +++ b/src/info.c @@ -21761,7 +21761,7 @@ skincolor_t skincolors[MAXSKINCOLORS] = { {"Violet", {0xd0, 0xd1, 0xd2, 0xca, 0xcc, 0xb8, 0xb9, 0xb9, 0xba, 0xa8, 0xa8, 0xa9, 0xa9, 0xfd, 0xfe, 0xfe}, SKINCOLOR_MINT, 6, V_MAGENTAMAP, true}, // SKINCOLOR_VIOLET {"Lilac", {0x00, 0xd0, 0xd1, 0xd2, 0xd3, 0xc1, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc5, 0xc6, 0xc6, 0xfe, 0x1f}, SKINCOLOR_VAPOR, 4, V_ROSYMAP, true}, // SKINCOLOR_LILAC {"Plum", {0xc8, 0xd3, 0xd5, 0xd6, 0xd7, 0xce, 0xcf, 0xb9, 0xb9, 0xba, 0xba, 0xa9, 0xa9, 0xa9, 0xfd, 0xfe}, SKINCOLOR_MINT, 7, V_ROSYMAP, true}, // SKINCOLOR_PLUM - {"Raspberry", {0xc8, 0xc9, 0xca, 0xcb, 0xcb, 0xcc, 0xcd, 0xcd, 0xce, 0xb9, 0xb9, 0xba, 0xba, 0xbb, 0xfe, 0xfe}, SKINCOLOR_APPLE, 13, V_MAGENTAMAP, true}, // SKINCOLOR_RASPBERRY + {"Raspberry", {0xc8, 0xc9, 0xca, 0xcb, 0xcb, 0xcc, 0xcd, 0xcd, 0xce, 0xb9, 0xb9, 0xba, 0xba, 0xbb, 0xfe, 0xfe}, SKINCOLOR_APPLE, 13, V_ROSYMAP, true}, // SKINCOLOR_RASPBERRY {"Rosy", {0xfc, 0xc8, 0xc8, 0xc9, 0xc9, 0xca, 0xca, 0xcb, 0xcb, 0xcc, 0xcc, 0xcd, 0xcd, 0xce, 0xce, 0xcf}, SKINCOLOR_AQUA, 1, V_ROSYMAP, true}, // SKINCOLOR_ROSY // super From 4025a1d5177b2b9b9d9c535a19d0b2c1324a35de Mon Sep 17 00:00:00 2001 From: Jaime Ita Passos Date: Mon, 29 Mar 2021 23:04:13 -0300 Subject: [PATCH 0644/1080] [Software] A few floorsprite fixes This fixes the texture of the floorsprite sometimes facing the wrong way, since plane rendering can change the view angle. --- src/r_data.c | 6 +----- src/r_draw8.c | 12 +----------- src/r_plane.c | 13 +++---------- src/r_splats.c | 27 +++++++++++---------------- src/r_splats.h | 3 +-- src/r_textures.c | 9 ++------- src/r_things.c | 5 +++-- src/r_things.h | 1 + 8 files changed, 23 insertions(+), 53 deletions(-) diff --git a/src/r_data.c b/src/r_data.c index af672f6dc..2cfe9cb7a 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -30,10 +30,6 @@ #include "byteptr.h" #include "dehacked.h" -#ifdef _WIN32 -#include // alloca(sizeof) -#endif - // // Graphics. // SRB2 graphics for walls and sprites diff --git a/src/r_draw8.c b/src/r_draw8.c index e78ba8a6c..1f451115e 100644 --- a/src/r_draw8.c +++ b/src/r_draw8.c @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -1447,10 +1447,7 @@ void R_DrawFloorSprite_8 (void) // SoM: Why didn't I see this earlier? the spot variable is a waste now because we don't // have the uber complicated math to calculate it now, so that was a memory write we didn't // need! - // - // 4194303 = (2048x2048)-1 (2048x2048 is maximum flat size) val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift); - val &= 4194303; val = source[val]; if (val & 0xFF00) dest[0] = colormap[translation[val & 0xFF]]; @@ -1458,7 +1455,6 @@ void R_DrawFloorSprite_8 (void) yposition += ystep; val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift); - val &= 4194303; val = source[val]; if (val & 0xFF00) dest[1] = colormap[translation[val & 0xFF]]; @@ -1466,7 +1462,6 @@ void R_DrawFloorSprite_8 (void) yposition += ystep; val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift); - val &= 4194303; val = source[val]; if (val & 0xFF00) dest[2] = colormap[translation[val & 0xFF]]; @@ -1474,7 +1469,6 @@ void R_DrawFloorSprite_8 (void) yposition += ystep; val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift); - val &= 4194303; val = source[val]; if (val & 0xFF00) dest[3] = colormap[translation[val & 0xFF]]; @@ -1482,7 +1476,6 @@ void R_DrawFloorSprite_8 (void) yposition += ystep; val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift); - val &= 4194303; val = source[val]; if (val & 0xFF00) dest[4] = colormap[translation[val & 0xFF]]; @@ -1490,7 +1483,6 @@ void R_DrawFloorSprite_8 (void) yposition += ystep; val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift); - val &= 4194303; val = source[val]; if (val & 0xFF00) dest[5] = colormap[translation[val & 0xFF]]; @@ -1498,7 +1490,6 @@ void R_DrawFloorSprite_8 (void) yposition += ystep; val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift); - val &= 4194303; val = source[val]; if (val & 0xFF00) dest[6] = colormap[translation[val & 0xFF]]; @@ -1506,7 +1497,6 @@ void R_DrawFloorSprite_8 (void) yposition += ystep; val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift); - val &= 4194303; val = source[val]; if (val & 0xFF00) dest[7] = colormap[translation[val & 0xFF]]; diff --git a/src/r_plane.c b/src/r_plane.c index 45d635213..ea4dfa4e8 100644 --- a/src/r_plane.c +++ b/src/r_plane.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -154,14 +154,10 @@ static void R_UpdatePlaneRipple(void) // R_MapPlane // // Uses global vars: +// planeheight // basexscale // baseyscale // centerx -// viewx -// viewy -// viewsin -// viewcos -// viewheight void R_MapPlane(INT32 y, INT32 x1, INT32 x2) { @@ -580,7 +576,7 @@ void R_ExpandPlane(visplane_t *pl, INT32 start, INT32 stop) // void R_MakeSpans(INT32 x, INT32 t1, INT32 b1, INT32 t2, INT32 b2) { - // Alam: from r_splats's R_RenderFloorSplat + // Alam: from r_splats's R_RasterizeFloorSplat if (t1 >= vid.height) t1 = vid.height-1; if (b1 >= vid.height) b1 = vid.height-1; if (t2 >= vid.height) t2 = vid.height-1; @@ -607,7 +603,6 @@ void R_MakeSpans(INT32 x, INT32 t1, INT32 b1, INT32 t2, INT32 b2) void R_DrawPlanes(void) { visplane_t *pl; - angle_t va = viewangle; INT32 i; R_UpdatePlaneRipple(); @@ -622,8 +617,6 @@ void R_DrawPlanes(void) R_DrawSinglePlane(pl); } } - - viewangle = va; } // R_DrawSkyPlane diff --git a/src/r_splats.c b/src/r_splats.c index a3fad82d8..72cac9fd9 100644 --- a/src/r_splats.c +++ b/src/r_splats.c @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -28,11 +28,12 @@ static void prepare_rastertab(void); // FLOOR SPLATS // ========================================================================== +static void R_RasterizeFloorSplat(floorsplat_t *pSplat, vector2_t *verts, vissprite_t *vis); + #ifdef USEASM void ASMCALL rasterize_segment_tex_asm(INT32 x1, INT32 y1, INT32 x2, INT32 y2, INT32 tv1, INT32 tv2, INT32 tc, INT32 dir); #endif -// Lactozilla static void rasterize_segment_tex(INT32 x1, INT32 y1, INT32 x2, INT32 y2, INT32 tv1, INT32 tv2, INT32 tc, INT32 dir) { #ifdef USEASM @@ -137,7 +138,7 @@ static void rasterize_segment_tex(INT32 x1, INT32 y1, INT32 x2, INT32 y2, INT32 } } -void R_DrawFloorSprite(vissprite_t *spr) +void R_DrawFloorSplat(vissprite_t *spr) { floorsplat_t splat; mobj_t *mobj = spr->mobj; @@ -187,7 +188,7 @@ void R_DrawFloorSprite(vissprite_t *spr) if (spr->rotateflags & SRF_3D || renderflags & RF_NOSPLATBILLBOARD) splatangle = mobj->angle; else - splatangle = viewangle; + splatangle = spr->viewangle; if (!(spr->cut & SC_ISROTATED)) splatangle += mobj->rollangle; @@ -265,7 +266,6 @@ void R_DrawFloorSprite(vissprite_t *spr) if (splat.tilted) { - // Lactozilla: Just copy the entire slope LMFAOOOO pslope_t *s = &splat.slope; s->o.x = slope->o.x; @@ -330,7 +330,7 @@ void R_DrawFloorSprite(vissprite_t *spr) v2d[i].y = (centeryfrac + FixedMul(rot_z, yscale))>>FRACBITS; } - R_RenderFloorSplat(&splat, v2d, spr); + R_RasterizeFloorSplat(&splat, v2d, spr); } // -------------------------------------------------------------------------- @@ -338,7 +338,7 @@ void R_DrawFloorSprite(vissprite_t *spr) // fill the polygon with linear interpolation, call span drawer for each // scan line // -------------------------------------------------------------------------- -void R_RenderFloorSplat(floorsplat_t *pSplat, vector2_t *verts, vissprite_t *vis) +static void R_RasterizeFloorSplat(floorsplat_t *pSplat, vector2_t *verts, vissprite_t *vis) { // rasterizing INT32 miny = viewheight + 1, maxy = 0; @@ -416,11 +416,10 @@ void R_RenderFloorSplat(floorsplat_t *pSplat, vector2_t *verts, vissprite_t *vis if (R_CheckPowersOfTwo()) R_CheckFlatLength(ds_flatwidth * ds_flatheight); - // Lactozilla: I don't know what I'm doing if (pSplat->tilted) { R_SetTiltedSpan(0); - R_CalculateSlopeVectors(&pSplat->slope, viewx, viewy, viewz, pSplat->xscale, pSplat->yscale, -pSplat->verts[0].x, pSplat->verts[0].y, viewangle, pSplat->angle, 1.0f); + R_CalculateSlopeVectors(&pSplat->slope, viewx, viewy, viewz, pSplat->xscale, pSplat->yscale, -pSplat->verts[0].x, pSplat->verts[0].y, vis->viewangle, pSplat->angle, 1.0f); spanfunctype = SPANDRAWFUNC_TILTEDSPRITE; } else @@ -533,7 +532,7 @@ void R_RenderFloorSplat(floorsplat_t *pSplat, vector2_t *verts, vissprite_t *vis fixed_t xstep, ystep; fixed_t distance, span; - angle_t angle = (viewangle + pSplat->angle)>>ANGLETOFINESHIFT; + angle_t angle = (vis->viewangle + pSplat->angle)>>ANGLETOFINESHIFT; angle_t planecos = FINECOSINE(angle); angle_t planesin = FINESINE(angle); @@ -543,17 +542,13 @@ void R_RenderFloorSplat(floorsplat_t *pSplat, vector2_t *verts, vissprite_t *vis distance = cacheddistance[y] = FixedMul(planeheight, yslope[y]); span = abs(centery - y); - if (span) // don't divide by zero + if (span) // Don't divide by zero { xstep = FixedMul(planesin, planeheight) / span; ystep = FixedMul(planecos, planeheight) / span; } else - { - // ah - xstep = FRACUNIT; - ystep = FRACUNIT; - } + xstep = ystep = FRACUNIT; cachedxstep[y] = xstep; cachedystep[y] = ystep; diff --git a/src/r_splats.h b/src/r_splats.h index e1f836f48..05d8b66b0 100644 --- a/src/r_splats.h +++ b/src/r_splats.h @@ -42,7 +42,6 @@ typedef struct floorsplat_s mobj_t *mobj; // Mobj it is tied to } floorsplat_t; -void R_DrawFloorSprite(vissprite_t *spr); -void R_RenderFloorSplat(floorsplat_t *pSplat, vector2_t *verts, vissprite_t *vis); +void R_DrawFloorSplat(vissprite_t *spr); #endif /*__R_SPLATS_H__*/ diff --git a/src/r_textures.c b/src/r_textures.c index a006d739f..d5da69018 100644 --- a/src/r_textures.c +++ b/src/r_textures.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -28,11 +28,6 @@ #include "byteptr.h" #include "dehacked.h" -// I don't know what this is even for, but r_data.c had it. -#ifdef _WIN32 -#include // alloca(sizeof) -#endif - #ifdef HWRENDER #include "hardware/hw_glob.h" // HWR_LoadMapTextures #endif @@ -626,7 +621,7 @@ void *R_GetLevelFlat(levelflat_t *levelflat) // // R_CheckPowersOfTwo // -// Self-explanatory? +// Sets ds_powersoftwo true if the flat's dimensions are powers of two, and returns that. // boolean R_CheckPowersOfTwo(void) { diff --git a/src/r_things.c b/src/r_things.c index 14eed9cf2..98e7d00ca 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -1956,6 +1956,7 @@ static void R_ProjectSprite(mobj_t *thing) vis->paperoffset = paperoffset; vis->paperdistance = paperdistance; vis->centerangle = centerangle; + vis->viewangle = viewangle; vis->shear.tan = sheartan; vis->shear.offset = 0; @@ -2783,7 +2784,7 @@ static void R_DrawSprite(vissprite_t *spr) mceilingclip = spr->cliptop; if (spr->cut & SC_SPLAT) - R_DrawFloorSprite(spr); + R_DrawFloorSplat(spr); else R_DrawVisSprite(spr); } diff --git a/src/r_things.h b/src/r_things.h index 708b6c24c..95b4215af 100644 --- a/src/r_things.h +++ b/src/r_things.h @@ -164,6 +164,7 @@ typedef struct vissprite_s fixed_t xiscale; // negative if flipped angle_t centerangle; // for paper sprites + angle_t viewangle; // for floor sprites, the viewpoint's current angle struct { fixed_t tan; // The amount to shear the sprite vertically per row From 0d5284c36c2485d370c7fda604ad458e85cf0ec4 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Tue, 30 Mar 2021 19:27:10 +0100 Subject: [PATCH 0645/1080] Murder `MSDOS`, another of the remaining DOS port related macros I also put in a missing `defined (__APPLE__)` in d_netcmd.h related to cv_mouse2opt Also removed a redundant `!defined (__APPLE__)` in d_main.c --- src/d_main.c | 10 +++++----- src/d_netcmd.c | 6 +++--- src/d_netcmd.h | 2 +- src/doomdef.h | 4 ++-- src/doomtype.h | 2 +- src/i_tcp.c | 4 ++-- src/m_menu.c | 8 ++++---- src/sdl/i_system.c | 2 +- src/v_video.c | 4 ++-- 9 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index 23a2c0133..cc02c5398 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -15,7 +15,7 @@ /// plus functions to parse command line parameters, configure game /// parameters, and call the startup functions. -#if (defined (__unix__) && !defined (MSDOS)) || defined(__APPLE__) || defined (UNIXCOMMON) +#if defined (__unix__) || defined (__APPLE__) || defined (UNIXCOMMON) #include #include #endif @@ -934,7 +934,7 @@ static void IdentifyVersion(void) char *srb2wad; const char *srb2waddir = NULL; -#if (defined (__unix__) && !defined (MSDOS)) || defined (UNIXCOMMON) || defined (HAVE_SDL) +#if defined (__unix__) || defined (UNIXCOMMON) || defined (HAVE_SDL) // change to the directory where 'srb2.pk3' is found srb2waddir = I_LocateWad(); #endif @@ -1107,7 +1107,7 @@ void D_SRB2Main(void) if (!userhome) { -#if ((defined (__unix__) && !defined (MSDOS)) || defined(__APPLE__) || defined (UNIXCOMMON)) && !defined (__CYGWIN__) +#if (defined (__unix__) || defined (__APPLE__) || defined (UNIXCOMMON)) && !defined (__CYGWIN__) I_Error("Please set $HOME to your home directory\n"); #else if (dedicated) @@ -1287,7 +1287,7 @@ void D_SRB2Main(void) G_LoadGameData(); -#if (defined (__unix__) && !defined (MSDOS)) || defined (UNIXCOMMON) || defined (HAVE_SDL) +#if defined (__unix__) || defined (UNIXCOMMON) || defined (HAVE_SDL) VID_PrepareModeList(); // Regenerate Modelist according to cv_fullscreen #endif @@ -1553,7 +1553,7 @@ const char *D_Home(void) userhome = M_GetNextParm(); else { -#if !((defined (__unix__) && !defined (MSDOS)) || defined(__APPLE__) || defined (UNIXCOMMON)) && !defined (__APPLE__) +#if !(defined (__unix__) || defined (__APPLE__) || defined (UNIXCOMMON)) if (FIL_FileOK(CONFIGFILENAME)) usehome = false; // Let's NOT use home else diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 09f9d4651..e2ccd0172 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -168,7 +168,7 @@ void SendWeaponPref(void); void SendWeaponPref2(void); static CV_PossibleValue_t usemouse_cons_t[] = {{0, "Off"}, {1, "On"}, {2, "Force"}, {0, NULL}}; -#if (defined (__unix__) && !defined (MSDOS)) || defined(__APPLE__) || defined (UNIXCOMMON) +#if defined (__unix__) || defined (__APPLE__) || defined (UNIXCOMMON) static CV_PossibleValue_t mouse2port_cons_t[] = {{0, "/dev/gpmdata"}, {1, "/dev/ttyS0"}, {2, "/dev/ttyS1"}, {3, "/dev/ttyS2"}, {4, "/dev/ttyS3"}, {0, NULL}}; #else @@ -255,7 +255,7 @@ consvar_t cv_joyscale2 = CVAR_INIT ("padscale2", "1", CV_SAVE|CV_CALL, NULL, I_J consvar_t cv_joyscale = CVAR_INIT ("padscale", "1", CV_SAVE|CV_HIDEN, NULL, NULL); //Alam: Dummy for save consvar_t cv_joyscale2 = CVAR_INIT ("padscale2", "1", CV_SAVE|CV_HIDEN, NULL, NULL); //Alam: Dummy for save #endif -#if (defined (__unix__) && !defined (MSDOS)) || defined(__APPLE__) || defined (UNIXCOMMON) +#if defined (__unix__) || defined (__APPLE__) || defined (UNIXCOMMON) consvar_t cv_mouse2port = CVAR_INIT ("mouse2port", "/dev/gpmdata", CV_SAVE, mouse2port_cons_t, NULL); consvar_t cv_mouse2opt = CVAR_INIT ("mouse2opt", "0", CV_SAVE, NULL, NULL); #else @@ -788,7 +788,7 @@ void D_RegisterClientCommands(void) // WARNING: the order is important when initialising mouse2 // we need the mouse2port CV_RegisterVar(&cv_mouse2port); -#if (defined (__unix__) && !defined (MSDOS)) || defined(__APPLE__) || defined (UNIXCOMMON) +#if defined (__unix__) || defined (__APPLE__) || defined (UNIXCOMMON) CV_RegisterVar(&cv_mouse2opt); #endif CV_RegisterVar(&cv_controlperkey); diff --git a/src/d_netcmd.h b/src/d_netcmd.h index ac39626a4..59c231255 100644 --- a/src/d_netcmd.h +++ b/src/d_netcmd.h @@ -45,7 +45,7 @@ extern consvar_t cv_joyscale2; // splitscreen with second mouse extern consvar_t cv_mouse2port; extern consvar_t cv_usemouse2; -#if (defined (__unix__) && !defined (MSDOS)) || defined (UNIXCOMMON) +#if defined (__unix__) || defined (__APPLE__) || defined (UNIXCOMMON) extern consvar_t cv_mouse2opt; #endif diff --git a/src/doomdef.h b/src/doomdef.h index 5f36f2d69..0c88d1add 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -112,7 +112,7 @@ //#define PARANOIA // do some tests that never fail but maybe // turn this on by make etc.. DEBUGMODE = 1 or use the Debug profile in the VC++ projects //#endif -#if defined (_WIN32) || (defined (__unix__) && !defined (MSDOS)) || defined(__APPLE__) || defined (UNIXCOMMON) || defined (macintosh) +#if defined (_WIN32) || defined (__unix__) || defined(__APPLE__) || defined (UNIXCOMMON) || defined (macintosh) #define LOGMESSAGES // write message in log.txt #endif @@ -415,7 +415,7 @@ enum { }; // Name of local directory for config files and savegames -#if (((defined (__unix__) && !defined (MSDOS)) || defined (UNIXCOMMON)) && !defined (__CYGWIN__)) && !defined (__APPLE__) +#if (defined (__unix__) || defined (UNIXCOMMON)) && !defined (__CYGWIN__) && !defined (__APPLE__) #define DEFAULTDIR ".srb2" #else #define DEFAULTDIR "srb2" diff --git a/src/doomtype.h b/src/doomtype.h index ffaa540b1..f04314f54 100644 --- a/src/doomtype.h +++ b/src/doomtype.h @@ -97,7 +97,7 @@ typedef long ssize_t; #define strncasecmp strnicmp #define strcasecmp strcmpi #endif -#if (defined (__unix__) && !defined (MSDOS)) || defined(__APPLE__) || defined (UNIXCOMMON) +#if defined (__unix__) || defined (__APPLE__) || defined (UNIXCOMMON) #undef stricmp #define stricmp(x,y) strcasecmp(x,y) #undef strnicmp diff --git a/src/i_tcp.c b/src/i_tcp.c index a9f617dc9..f54dd6878 100644 --- a/src/i_tcp.c +++ b/src/i_tcp.c @@ -64,7 +64,7 @@ #include #include - #if (defined (__unix__) && !defined (MSDOS)) || defined(__APPLE__) || defined (UNIXCOMMON) + #if defined (__unix__) || defined (__APPLE__) || defined (UNIXCOMMON) #include #endif // UNIXCOMMON #endif @@ -155,7 +155,7 @@ typedef SOCKET SOCKET_TYPE; #define ERRSOCKET (SOCKET_ERROR) #else - #if (defined (__unix__) && !defined (MSDOS)) || defined (__APPLE__) || defined (__HAIKU__) + #if defined (__unix__) || defined (__APPLE__) || defined (__HAIKU__) typedef int SOCKET_TYPE; #else typedef unsigned long SOCKET_TYPE; diff --git a/src/m_menu.c b/src/m_menu.c index 516bd34c1..a41c2db26 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1322,7 +1322,7 @@ static menuitem_t OP_Camera2ExtendedOptionsMenu[] = enum { op_video_resolution = 1, -#if (defined (__unix__) && !defined (MSDOS)) || defined (UNIXCOMMON) || defined (HAVE_SDL) +#if defined (__unix__) || defined (UNIXCOMMON) || defined (HAVE_SDL) op_video_fullscreen, #endif op_video_vsync, @@ -1334,7 +1334,7 @@ static menuitem_t OP_VideoOptionsMenu[] = {IT_HEADER, NULL, "Screen", NULL, 0}, {IT_STRING | IT_CALL, NULL, "Set Resolution...", M_VideoModeMenu, 6}, -#if (defined (__unix__) && !defined (MSDOS)) || defined (UNIXCOMMON) || defined (HAVE_SDL) +#if defined (__unix__) || defined (UNIXCOMMON) || defined (HAVE_SDL) {IT_STRING|IT_CVAR, NULL, "Fullscreen", &cv_fullscreen, 11}, #endif {IT_STRING | IT_CVAR, NULL, "Vertical Sync", &cv_vidwait, 16}, @@ -1453,7 +1453,7 @@ static menuitem_t OP_OpenGLOptionsMenu[] = #ifdef ALAM_LIGHTING {IT_SUBMENU|IT_STRING, NULL, "Lighting...", &OP_OpenGLLightingDef, 144}, #endif -#if defined (_WINDOWS) && (!((defined (__unix__) && !defined (MSDOS)) || defined (UNIXCOMMON) || defined (HAVE_SDL))) +#if defined (_WINDOWS) && (!(defined (__unix__) || defined (UNIXCOMMON) || defined (HAVE_SDL))) {IT_STRING|IT_CVAR, NULL, "Fullscreen", &cv_fullscreen, 154}, #endif }; @@ -12923,7 +12923,7 @@ static void M_VideoModeMenu(INT32 choice) memset(modedescs, 0, sizeof(modedescs)); -#if (defined (__unix__) && !defined (MSDOS)) || defined (UNIXCOMMON) || defined (HAVE_SDL) +#if defined (__unix__) || defined (UNIXCOMMON) || defined (HAVE_SDL) VID_PrepareModeList(); // FIXME: hack #endif vidm_nummodes = 0; diff --git a/src/sdl/i_system.c b/src/sdl/i_system.c index a0dd6e1da..e3a0c2563 100644 --- a/src/sdl/i_system.c +++ b/src/sdl/i_system.c @@ -102,7 +102,7 @@ typedef LPVOID (WINAPI *p_MapViewOfFile) (HANDLE, DWORD, DWORD, DWORD, SIZE_T); #endif #endif -#if (defined (__unix__) && !defined (_MSDOS)) || (defined (UNIXCOMMON) && !defined(__APPLE__)) +#if defined (__unix__) || (defined (UNIXCOMMON) && !defined (__APPLE__)) #include #include #define NEWSIGNALHANDLER diff --git a/src/v_video.c b/src/v_video.c index 4713db0d8..1c383a2ac 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -418,7 +418,7 @@ void V_SetPalette(INT32 palettenum) #ifdef HWRENDER if (rendermode == render_opengl) HWR_SetPalette(&pLocalPalette[palettenum*256]); -#if (defined (__unix__) && !defined (MSDOS)) || defined (UNIXCOMMON) || defined (HAVE_SDL) +#if defined (__unix__) || defined (UNIXCOMMON) || defined (HAVE_SDL) else #endif #endif @@ -432,7 +432,7 @@ void V_SetPaletteLump(const char *pal) #ifdef HWRENDER if (rendermode == render_opengl) HWR_SetPalette(pLocalPalette); -#if (defined (__unix__) && !defined (MSDOS)) || defined (UNIXCOMMON) || defined (HAVE_SDL) +#if defined (__unix__) || defined (UNIXCOMMON) || defined (HAVE_SDL) else #endif #endif From eece82c481dfa2cc7ab6a3fa1480f2976484b6f4 Mon Sep 17 00:00:00 2001 From: Jaime Ita Passos Date: Tue, 30 Mar 2021 17:03:05 -0300 Subject: [PATCH 0646/1080] Blend modes revision This changes how blend modes render, and includes fixes. --- src/hardware/hw_defs.h | 13 ++- src/hardware/hw_light.c | 8 +- src/hardware/hw_main.c | 32 ++++--- src/hardware/r_opengl/r_opengl.c | 8 +- src/r_draw.c | 148 ++++++++++++++++++++++++------- src/r_draw.h | 5 +- src/r_things.c | 6 +- 7 files changed, 156 insertions(+), 64 deletions(-) diff --git a/src/hardware/hw_defs.h b/src/hardware/hw_defs.h index bd6afc74f..4bff8fc6a 100644 --- a/src/hardware/hw_defs.h +++ b/src/hardware/hw_defs.h @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -216,14 +216,13 @@ enum EPolyFlags PF_Masked = 0x00000001, // Poly is alpha scaled and 0 alpha pixels are discarded (holes in texture) PF_Translucent = 0x00000002, // Poly is transparent, alpha = level of transparency PF_Environment = 0x00000004, // Poly should be drawn environment mapped. (Hurdler: used for text drawing) - PF_Additive = 0x00000008, // Additive color blending - PF_AdditiveSource = 0x00000010, // Source blending factor is additive. This is the opposite of regular additive blending. - PF_Subtractive = 0x00000020, // Subtractive color blending - PF_ReverseSubtract = 0x00000040, // Reverse subtract, used in wall splats (decals) - PF_Multiplicative = 0x00000080, // Multiplicative color blending + PF_Additive = 0x00000008, // Source blending factor is additive. + PF_Subtractive = 0x00000010, // Subtractive color blending + PF_ReverseSubtract = 0x00000020, // Reverse subtract, used in wall splats (decals) + PF_Multiplicative = 0x00000040, // Multiplicative color blending PF_Fog = 0x20000000, // Fog blocks PF_NoAlphaTest = 0x40000000, // Disables alpha testing - PF_Blending = (PF_Masked|PF_Translucent|PF_Environment|PF_Additive|PF_AdditiveSource|PF_Subtractive|PF_ReverseSubtract|PF_Multiplicative|PF_Fog) & ~PF_NoAlphaTest, + PF_Blending = (PF_Masked|PF_Translucent|PF_Environment|PF_Additive|PF_Subtractive|PF_ReverseSubtract|PF_Multiplicative|PF_Fog) & ~PF_NoAlphaTest, // other flag bits PF_Occlude = 0x00000100, // Updates the depth buffer diff --git a/src/hardware/hw_light.c b/src/hardware/hw_light.c index 93c61f4e7..e83d9a6ec 100644 --- a/src/hardware/hw_light.c +++ b/src/hardware/hw_light.c @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -35,7 +35,7 @@ #define DL_HIGH_QUALITY //#define STATICLIGHT //Hurdler: TODO! -#define LIGHTMAPFLAGS (PF_Modulated|PF_AdditiveSource) +#define LIGHTMAPFLAGS (PF_Modulated|PF_Additive) #ifdef ALAM_LIGHTING static dynlights_t view_dynlights[2]; // 2 players in splitscreen mode @@ -1056,7 +1056,7 @@ void HWR_DoCoronasLighting(FOutVector *outVerts, gl_vissprite_t *spr) HWR_GetPic(coronalumpnum); /// \todo use different coronas - HWD.pfnDrawPolygon (&Surf, light, 4, PF_Modulated | PF_AdditiveSource | PF_Corona | PF_NoDepthTest); + HWD.pfnDrawPolygon (&Surf, light, 4, PF_Modulated | PF_Additive | PF_Corona | PF_NoDepthTest); } } #endif @@ -1144,7 +1144,7 @@ void HWR_DrawCoronas(void) light[3].y = cy+size*1.33f; light[3].s = 0.0f; light[3].t = 1.0f; - HWD.pfnDrawPolygon (&Surf, light, 4, PF_Modulated | PF_AdditiveSource | PF_NoDepthTest | PF_Corona); + HWD.pfnDrawPolygon (&Surf, light, 4, PF_Modulated | PF_Additive | PF_NoDepthTest | PF_Corona); } } #endif diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index c2d617eaf..0602c5c49 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -706,6 +706,8 @@ FBITFIELD HWR_GetBlendModeFlag(INT32 ast) { switch (ast) { + case AST_COPY: + return PF_Masked; case AST_ADD: return PF_Additive; case AST_SUBTRACT: @@ -744,7 +746,7 @@ UINT8 HWR_GetTranstableAlpha(INT32 transtablenum) FBITFIELD HWR_SurfaceBlend(INT32 style, INT32 transtablenum, FSurfaceInfo *pSurf) { - if (!transtablenum) + if (!transtablenum || style == AST_COPY) { pSurf->PolyColor.s.alpha = 0xff; return PF_Masked; @@ -3813,8 +3815,6 @@ static void HWR_SplitSprite(gl_vissprite_t *spr) else if (spr->mobj->frame & FF_TRANSMASK) { INT32 trans = (spr->mobj->frame & FF_TRANSMASK)>>FF_TRANSSHIFT; - if (spr->mobj->blendmode == AST_TRANSLUCENT && trans >= NUMTRANSMAPS) - return; blend = HWR_SurfaceBlend(spr->mobj->blendmode, trans, &Surf); } else @@ -4240,8 +4240,6 @@ static void HWR_DrawSprite(gl_vissprite_t *spr) else if (spr->mobj->frame & FF_TRANSMASK) { INT32 trans = (spr->mobj->frame & FF_TRANSMASK)>>FF_TRANSSHIFT; - if (spr->mobj->blendmode == AST_TRANSLUCENT && trans >= NUMTRANSMAPS) - return; blend = HWR_SurfaceBlend(spr->mobj->blendmode, trans, &Surf); } else @@ -4354,9 +4352,7 @@ static inline void HWR_DrawPrecipitationSprite(gl_vissprite_t *spr) if (spr->mobj->frame & FF_TRANSMASK) { INT32 trans = (spr->mobj->frame & FF_TRANSMASK)>>FF_TRANSSHIFT; - if (spr->mobj->blendmode == AST_TRANSLUCENT && trans >= NUMTRANSMAPS) - return; - blend = HWR_SurfaceBlend(spr->mobj->blendmode, trans, &Surf); + blend = HWR_SurfaceBlend(AST_TRANSLUCENT, trans, &Surf); } else { @@ -4935,6 +4931,13 @@ static void HWR_ProjectSprite(mobj_t *thing) if (thing->spritexscale < 1 || thing->spriteyscale < 1) return; + // Visibility check by the blend mode. + if (thing->frame & FF_TRANSMASK) + { + if (!R_BlendLevelVisible(thing->blendmode, (thing->frame & FF_TRANSMASK)>>FF_TRANSSHIFT)) + return; + } + dispoffset = thing->info->dispoffset; this_scale = FIXED_TO_FLOAT(thing->scale); @@ -5321,6 +5324,13 @@ static void HWR_ProjectPrecipitationSprite(precipmobj_t *thing) unsigned rot = 0; UINT8 flip; + // Visibility check by the blend mode. + if (thing->frame & FF_TRANSMASK) + { + if (!R_BlendLevelVisible(thing->blendmode, (thing->frame & FF_TRANSMASK)>>FF_TRANSSHIFT)) + return; + } + // transform the origin point tr_x = FIXED_TO_FLOAT(thing->x) - gl_viewx; tr_y = FIXED_TO_FLOAT(thing->y) - gl_viewy; @@ -5354,7 +5364,7 @@ static void HWR_ProjectPrecipitationSprite(precipmobj_t *thing) return; #endif - sprframe = &sprdef->spriteframes[ thing->frame & FF_FRAMEMASK]; + sprframe = &sprdef->spriteframes[thing->frame & FF_FRAMEMASK]; // use single rotation for all views lumpoff = sprframe->lumpid[0]; @@ -6510,7 +6520,7 @@ void HWR_DoPostProcessor(player_t *player) Surf.PolyColor.s.alpha = 0xc0; // match software mode - HWD.pfnDrawPolygon(&Surf, v, 4, PF_Modulated|PF_AdditiveSource|PF_NoTexture|PF_NoDepthTest); + HWD.pfnDrawPolygon(&Surf, v, 4, PF_Modulated|PF_Additive|PF_NoTexture|PF_NoDepthTest); } // Capture the screen for intermission and screen waving diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index 6967bab74..3969f7f35 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -1576,12 +1576,11 @@ static void SetBlendMode(FBITFIELD flags) case PF_Additive & PF_Blending: case PF_Subtractive & PF_Blending: case PF_ReverseSubtract & PF_Blending: + pglBlendFunc(GL_SRC_ALPHA, GL_ONE); // src * alpha + dest + break; case PF_Environment & PF_Blending: pglBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); break; - case PF_AdditiveSource & PF_Blending: - pglBlendFunc(GL_SRC_ALPHA, GL_ONE); // src * alpha + dest - break; case PF_Multiplicative & PF_Blending: pglBlendFunc(GL_DST_COLOR, GL_ZERO); break; @@ -1620,7 +1619,6 @@ static void SetBlendMode(FBITFIELD flags) break; case PF_Translucent & PF_Blending: case PF_Additive & PF_Blending: - case PF_AdditiveSource & PF_Blending: case PF_Subtractive & PF_Blending: case PF_ReverseSubtract & PF_Blending: case PF_Environment & PF_Blending: @@ -2752,7 +2750,7 @@ static void DrawModelEx(model_t *model, INT32 frameIndex, INT32 duration, INT32 fade.alpha = byte2float[Surface->FadeColor.s.alpha]; flags = (Surface->PolyFlags | PF_Modulated); - if (Surface->PolyFlags & (PF_Additive|PF_AdditiveSource|PF_Subtractive|PF_ReverseSubtract|PF_Multiplicative)) + if (Surface->PolyFlags & (PF_Additive|PF_Subtractive|PF_ReverseSubtract|PF_Multiplicative)) flags |= PF_Occlude; else if (Surface->PolyColor.s.alpha == 0xFF) flags |= (PF_Occlude | PF_Masked); diff --git a/src/r_draw.c b/src/r_draw.c index c3d4efae3..0ebdb4dd8 100644 --- a/src/r_draw.c +++ b/src/r_draw.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -198,43 +198,15 @@ void R_InitTranslucencyTables(void) R_GenerateBlendTables(); } -void R_GenerateBlendTables(void) -{ - INT32 i; - - for (i = 0; i < NUMBLENDMAPS; i++) - { - if (i == blendtab_modulate) - continue; - blendtables[i] = Z_MallocAlign((NUMTRANSTABLES + 1) * 0x10000, PU_STATIC, NULL, 16); - } - - for (i = 0; i <= 9; i++) - { - const size_t offs = (0x10000 * i); - const UINT8 alpha = TRANSTAB_AMTMUL10 * i; - - R_GenerateTranslucencyTable(blendtables[blendtab_add] + offs, AST_ADD, alpha); - R_GenerateTranslucencyTable(blendtables[blendtab_subtract] + offs, AST_SUBTRACT, alpha); - R_GenerateTranslucencyTable(blendtables[blendtab_reversesubtract] + offs, AST_REVERSESUBTRACT, alpha); - } - - // Modulation blending only requires a single table - blendtables[blendtab_modulate] = Z_MallocAlign(0x10000, PU_STATIC, NULL, 16); - R_GenerateTranslucencyTable(blendtables[blendtab_modulate], AST_MODULATE, 0); -} - static colorlookup_t transtab_lut; -void R_GenerateTranslucencyTable(UINT8 *table, int style, UINT8 blendamt) +static void R_GenerateTranslucencyTable(UINT8 *table, int style, UINT8 blendamt) { INT16 bg, fg; if (table == NULL) I_Error("R_GenerateTranslucencyTable: input table was NULL!"); - InitColorLUT(&transtab_lut, pMasterPalette, false); - for (bg = 0; bg < 0xFF; bg++) { for (fg = 0; fg < 0xFF; fg++) @@ -243,12 +215,117 @@ void R_GenerateTranslucencyTable(UINT8 *table, int style, UINT8 blendamt) RGBA_t frontrgba = V_GetMasterColor(fg); RGBA_t result; - result.rgba = ASTBlendPixel(backrgba, frontrgba, style, blendamt); + result.rgba = ASTBlendPixel(backrgba, frontrgba, style, 0xFF); + result.rgba = ASTBlendPixel(result, frontrgba, AST_TRANSLUCENT, blendamt); + table[((bg * 0x100) + fg)] = GetColorLUT(&transtab_lut, result.s.red, result.s.green, result.s.blue); } } } +static void R_GenerateSubtractiveTable(UINT8 *table, int style, UINT8 blendamt) +{ + INT16 bg, fg; + + if (table == NULL) + I_Error("R_GenerateSubtractiveTable: input table was NULL!"); + + blendamt = 0xFF - blendamt; + if (!blendamt) + { + memset(table, GetColorLUT(&transtab_lut, 0, 0, 0), 0x10000); + return; + } + + for (bg = 0; bg < 0xFF; bg++) + { + for (fg = 0; fg < 0xFF; fg++) + { + RGBA_t backrgba = V_GetMasterColor(bg); + RGBA_t frontrgba = V_GetMasterColor(fg); + RGBA_t result; + + result.rgba = ASTBlendPixel(backrgba, frontrgba, style, 0xFF); + result.s.red = (result.s.red * blendamt) / 0xFF; + result.s.green = (result.s.green * blendamt) / 0xFF; + result.s.blue = (result.s.blue * blendamt) / 0xFF; + + table[((bg * 0x100) + fg)] = GetColorLUT(&transtab_lut, result.s.red, result.s.green, result.s.blue); + } + } +} + +static void R_GenerateModulationTable(UINT8 *table) +{ + INT16 bg, fg; + + if (table == NULL) + I_Error("R_GenerateModulationTable: input table was NULL!"); + + for (bg = 0; bg < 0xFF; bg++) + { + for (fg = 0; fg < 0xFF; fg++) + { + RGBA_t backrgba = V_GetMasterColor(bg); + RGBA_t frontrgba = V_GetMasterColor(fg); + RGBA_t result; + result.rgba = ASTBlendPixel(backrgba, frontrgba, AST_MODULATE, 0); + table[((bg * 0x100) + fg)] = GetColorLUT(&transtab_lut, result.s.red, result.s.green, result.s.blue); + } + } +} + +static INT32 R_GetBlendTableCount(INT32 style) +{ + INT32 count = NUMTRANSTABLES; + if (style == blendtab_subtract || style == blendtab_reversesubtract) + count++; + return count; +} + +static void R_GenerateBlendTableMaps(INT32 tab, INT32 style, void (*genfunc)(UINT8 *, int, UINT8)) +{ + INT32 i = 0; + for (; i <= R_GetBlendTableCount(tab); i++) + { + const size_t offs = (0x10000 * i); + const UINT16 alpha = min(TRANSTAB_AMTMUL10 * i, 0xFF); + genfunc(blendtables[tab] + offs, style, alpha); + } +} + +void R_GenerateBlendTables(void) +{ + INT32 i; + + for (i = 0; i < NUMBLENDMAPS; i++) + { + if (i == blendtab_modulate) + continue; + blendtables[i] = Z_MallocAlign((R_GetBlendTableCount(i) + 1) * 0x10000, PU_STATIC, NULL, 16); + } + + InitColorLUT(&transtab_lut, pMasterPalette, false); + + // Additive + R_GenerateBlendTableMaps(blendtab_add, AST_ADD, R_GenerateTranslucencyTable); + + // Subtractive +#if 1 + R_GenerateBlendTableMaps(blendtab_subtract, AST_SUBTRACT, R_GenerateSubtractiveTable); +#else + R_GenerateBlendTableMaps(blendtab_subtract, AST_SUBTRACT, R_GenerateTranslucencyTable); +#endif + + // Reverse subtractive + R_GenerateBlendTableMaps(blendtab_reversesubtract, AST_REVERSESUBTRACT, R_GenerateTranslucencyTable); + + // Modulation blending only requires a single table + blendtables[blendtab_modulate] = Z_MallocAlign(0x10000, PU_STATIC, NULL, 16); + R_GenerateModulationTable(blendtables[blendtab_modulate]); +} + +#define ClipBlendLevel(style, trans) max(min((trans), R_GetBlendTableCount(style)+1), 0) #define ClipTransLevel(trans) max(min((trans), NUMTRANSMAPS-2), 0) UINT8 *R_GetTranslucencyTable(INT32 alphalevel) @@ -258,7 +335,7 @@ UINT8 *R_GetTranslucencyTable(INT32 alphalevel) UINT8 *R_GetBlendTable(int style, INT32 alphalevel) { - size_t offs = (ClipTransLevel(alphalevel) << FF_TRANSSHIFT); + size_t offs = (ClipBlendLevel(style, alphalevel) << FF_TRANSSHIFT); // Lactozilla: Returns the equivalent to AST_TRANSLUCENT // if no alpha style matches any of the blend tables. @@ -283,6 +360,13 @@ UINT8 *R_GetBlendTable(int style, INT32 alphalevel) return NULL; } +boolean R_BlendLevelVisible(INT32 blendmode, INT32 alphalevel) +{ + if (blendmode == AST_COPY || blendmode == AST_SUBTRACT || blendmode == AST_MODULATE) + return true; + return (alphalevel < R_GetBlendTableCount(blendmode)); +} + // Define for getting accurate color brightness readings according to how the human eye sees them. // https://en.wikipedia.org/wiki/Relative_luminance // 0.2126 to red diff --git a/src/r_draw.h b/src/r_draw.h index d1eb83033..caf43fd89 100644 --- a/src/r_draw.h +++ b/src/r_draw.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -140,11 +140,12 @@ extern UINT8 *blendtables[NUMBLENDMAPS]; void R_InitTranslucencyTables(void); void R_GenerateBlendTables(void); -void R_GenerateTranslucencyTable(UINT8 *table, int style, UINT8 blendamt); UINT8 *R_GetTranslucencyTable(INT32 alphalevel); UINT8 *R_GetBlendTable(int style, INT32 alphalevel); +boolean R_BlendLevelVisible(INT32 blendmode, INT32 alphalevel); + // Color ramp modification should force a recache extern UINT8 skincolor_modified[]; diff --git a/src/r_things.c b/src/r_things.c index 14eed9cf2..aa28b7c2b 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -1803,7 +1803,7 @@ static void R_ProjectSprite(mobj_t *thing) else if (oldthing->frame & FF_TRANSMASK) { trans = (oldthing->frame & FF_TRANSMASK) >> FF_TRANSSHIFT; - if (oldthing->blendmode == AST_TRANSLUCENT && trans >= NUMTRANSMAPS) + if (!R_BlendLevelVisible(oldthing->blendmode, trans)) return; } else @@ -2199,7 +2199,7 @@ static void R_ProjectPrecipitationSprite(precipmobj_t *thing) // specific translucency if (thing->frame & FF_TRANSMASK) - vis->transmap = (thing->frame & FF_TRANSMASK) - 0x10000 + transtables; + vis->transmap = R_GetTranslucencyTable((thing->frame & FF_TRANSMASK) >> FF_TRANSSHIFT); else vis->transmap = NULL; From 59be35e533c420f392da56987f5414cb679e9c25 Mon Sep 17 00:00:00 2001 From: Jaime Ita Passos Date: Tue, 30 Mar 2021 22:12:31 -0300 Subject: [PATCH 0647/1080] Rename functions, make more efficient, fix subtractive in Software --- src/hardware/hw_main.c | 3 +- src/r_draw.c | 92 +++++++++++++++++++++++------------------- 2 files changed, 53 insertions(+), 42 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 0602c5c49..f2af1cc40 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -707,6 +707,7 @@ FBITFIELD HWR_GetBlendModeFlag(INT32 ast) switch (ast) { case AST_COPY: + case AST_OVERLAY: return PF_Masked; case AST_ADD: return PF_Additive; @@ -746,7 +747,7 @@ UINT8 HWR_GetTranstableAlpha(INT32 transtablenum) FBITFIELD HWR_SurfaceBlend(INT32 style, INT32 transtablenum, FSurfaceInfo *pSurf) { - if (!transtablenum || style == AST_COPY) + if (!transtablenum || style == AST_COPY || style == AST_OVERLAY) { pSurf->PolyColor.s.alpha = 0xff; return PF_Masked; diff --git a/src/r_draw.c b/src/r_draw.c index 0ebdb4dd8..8625fbab2 100644 --- a/src/r_draw.c +++ b/src/r_draw.c @@ -173,14 +173,12 @@ static INT32 CacheIndexToSkin(INT32 ttc) CV_PossibleValue_t Color_cons_t[MAXSKINCOLORS+1]; -#define TRANSTAB_AMTMUL10 (256.0f / 10.0f) - /** \brief Initializes the translucency tables used by the Software renderer. */ void R_InitTranslucencyTables(void) { - // Load here the transparency lookup tables 'TINTTAB' - // NOTE: the TINTTAB resource MUST BE aligned on 64k for the asm + // Load here the transparency lookup tables 'TRANSx0' + // NOTE: the TRANSx0 resources MUST BE aligned on 64k for the asm // optimised code (in other words, transtables pointer low word is 0) transtables = Z_MallocAlign(NUMTRANSTABLES*0x10000, PU_STATIC, NULL, 16); @@ -200,12 +198,12 @@ void R_InitTranslucencyTables(void) static colorlookup_t transtab_lut; -static void R_GenerateTranslucencyTable(UINT8 *table, int style, UINT8 blendamt) +static void BlendTab_Translucent(UINT8 *table, int style, UINT8 blendamt) { INT16 bg, fg; if (table == NULL) - I_Error("R_GenerateTranslucencyTable: input table was NULL!"); + I_Error("BlendTab_Translucent: input table was NULL!"); for (bg = 0; bg < 0xFF; bg++) { @@ -223,15 +221,14 @@ static void R_GenerateTranslucencyTable(UINT8 *table, int style, UINT8 blendamt) } } -static void R_GenerateSubtractiveTable(UINT8 *table, int style, UINT8 blendamt) +static void BlendTab_Subtractive(UINT8 *table, int style, UINT8 blendamt) { INT16 bg, fg; if (table == NULL) - I_Error("R_GenerateSubtractiveTable: input table was NULL!"); + I_Error("BlendTab_Subtractive: input table was NULL!"); - blendamt = 0xFF - blendamt; - if (!blendamt) + if (blendamt == 0xFF) { memset(table, GetColorLUT(&transtab_lut, 0, 0, 0), 0x10000); return; @@ -246,21 +243,21 @@ static void R_GenerateSubtractiveTable(UINT8 *table, int style, UINT8 blendamt) RGBA_t result; result.rgba = ASTBlendPixel(backrgba, frontrgba, style, 0xFF); - result.s.red = (result.s.red * blendamt) / 0xFF; - result.s.green = (result.s.green * blendamt) / 0xFF; - result.s.blue = (result.s.blue * blendamt) / 0xFF; + result.s.red = max(0, result.s.red - blendamt); + result.s.green = max(0, result.s.green - blendamt); + result.s.blue = max(0, result.s.blue - blendamt); table[((bg * 0x100) + fg)] = GetColorLUT(&transtab_lut, result.s.red, result.s.green, result.s.blue); } } } -static void R_GenerateModulationTable(UINT8 *table) +static void BlendTab_Modulative(UINT8 *table) { INT16 bg, fg; if (table == NULL) - I_Error("R_GenerateModulationTable: input table was NULL!"); + I_Error("BlendTab_Modulative: input table was NULL!"); for (bg = 0; bg < 0xFF; bg++) { @@ -275,21 +272,33 @@ static void R_GenerateModulationTable(UINT8 *table) } } -static INT32 R_GetBlendTableCount(INT32 style) +static INT32 BlendTab_Count[NUMBLENDMAPS] = { - INT32 count = NUMTRANSTABLES; - if (style == blendtab_subtract || style == blendtab_reversesubtract) - count++; - return count; -} + NUMTRANSTABLES, // blendtab_add + NUMTRANSTABLES+1, // blendtab_subtract + NUMTRANSTABLES+1, // blendtab_reversesubtract + 1 // blendtab_modulate +}; -static void R_GenerateBlendTableMaps(INT32 tab, INT32 style, void (*genfunc)(UINT8 *, int, UINT8)) +static INT32 BlendTab_FromStyle[] = { - INT32 i = 0; - for (; i <= R_GetBlendTableCount(tab); i++) + 0, // AST_COPY + 0, // AST_TRANSLUCENT + blendtab_add, // AST_ADD + blendtab_subtract, // AST_SUBTRACT + blendtab_reversesubtract, // AST_REVERSESUBTRACT + blendtab_modulate, // AST_MODULATE + 0 // AST_OVERLAY +}; + +static void BlendTab_GenerateMaps(INT32 tab, INT32 style, void (*genfunc)(UINT8 *, int, UINT8)) +{ + INT32 i = 0, num = BlendTab_Count[tab]; + const float amtmul = (256.0f / (float)(NUMTRANSTABLES)); + for (; i < num; i++) { const size_t offs = (0x10000 * i); - const UINT16 alpha = min(TRANSTAB_AMTMUL10 * i, 0xFF); + const UINT16 alpha = min(amtmul * i, 0xFF); genfunc(blendtables[tab] + offs, style, alpha); } } @@ -299,33 +308,28 @@ void R_GenerateBlendTables(void) INT32 i; for (i = 0; i < NUMBLENDMAPS; i++) - { - if (i == blendtab_modulate) - continue; - blendtables[i] = Z_MallocAlign((R_GetBlendTableCount(i) + 1) * 0x10000, PU_STATIC, NULL, 16); - } + blendtables[i] = Z_MallocAlign(BlendTab_Count[i] * 0x10000, PU_STATIC, NULL, 16); InitColorLUT(&transtab_lut, pMasterPalette, false); // Additive - R_GenerateBlendTableMaps(blendtab_add, AST_ADD, R_GenerateTranslucencyTable); + BlendTab_GenerateMaps(blendtab_add, AST_ADD, BlendTab_Translucent); // Subtractive #if 1 - R_GenerateBlendTableMaps(blendtab_subtract, AST_SUBTRACT, R_GenerateSubtractiveTable); + BlendTab_GenerateMaps(blendtab_subtract, AST_SUBTRACT, BlendTab_Subtractive); #else - R_GenerateBlendTableMaps(blendtab_subtract, AST_SUBTRACT, R_GenerateTranslucencyTable); + BlendTab_GenerateMaps(blendtab_subtract, AST_SUBTRACT, BlendTab_Translucent); #endif // Reverse subtractive - R_GenerateBlendTableMaps(blendtab_reversesubtract, AST_REVERSESUBTRACT, R_GenerateTranslucencyTable); + BlendTab_GenerateMaps(blendtab_reversesubtract, AST_REVERSESUBTRACT, BlendTab_Translucent); - // Modulation blending only requires a single table - blendtables[blendtab_modulate] = Z_MallocAlign(0x10000, PU_STATIC, NULL, 16); - R_GenerateModulationTable(blendtables[blendtab_modulate]); + // Modulative blending only requires a single table + BlendTab_Modulative(blendtables[blendtab_modulate]); } -#define ClipBlendLevel(style, trans) max(min((trans), R_GetBlendTableCount(style)+1), 0) +#define ClipBlendLevel(style, trans) max(min((trans), BlendTab_Count[BlendTab_FromStyle[style]]-1), 0) #define ClipTransLevel(trans) max(min((trans), NUMTRANSMAPS-2), 0) UINT8 *R_GetTranslucencyTable(INT32 alphalevel) @@ -335,7 +339,12 @@ UINT8 *R_GetTranslucencyTable(INT32 alphalevel) UINT8 *R_GetBlendTable(int style, INT32 alphalevel) { - size_t offs = (ClipBlendLevel(style, alphalevel) << FF_TRANSSHIFT); + size_t offs; + + if (style == AST_COPY || style == AST_OVERLAY) + return NULL; + + offs = (ClipBlendLevel(style, alphalevel) << FF_TRANSSHIFT); // Lactozilla: Returns the equivalent to AST_TRANSLUCENT // if no alpha style matches any of the blend tables. @@ -362,9 +371,10 @@ UINT8 *R_GetBlendTable(int style, INT32 alphalevel) boolean R_BlendLevelVisible(INT32 blendmode, INT32 alphalevel) { - if (blendmode == AST_COPY || blendmode == AST_SUBTRACT || blendmode == AST_MODULATE) + if (blendmode == AST_COPY || blendmode == AST_SUBTRACT || blendmode == AST_MODULATE || blendmode == AST_OVERLAY) return true; - return (alphalevel < R_GetBlendTableCount(blendmode)); + + return (alphalevel < BlendTab_Count[BlendTab_FromStyle[blendmode]]); } // Define for getting accurate color brightness readings according to how the human eye sees them. From 7e6bc9724053dc3af859d0fc02893a8ec5eb6b91 Mon Sep 17 00:00:00 2001 From: Jaime Ita Passos Date: Tue, 30 Mar 2021 22:52:50 -0300 Subject: [PATCH 0648/1080] Smoother freelook in Software Mhm hmm... --- src/r_main.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/r_main.c b/src/r_main.c index f82fb589e..04bdebc58 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -1089,8 +1089,6 @@ subsector_t *R_PointInSubsectorOrNull(fixed_t x, fixed_t y) // 18/08/18: (No it's actually 16*viewheight, thanks Jimita for finding this out) static void R_SetupFreelook(player_t *player, boolean skybox) { - INT32 dy = 0; - #ifndef HWRENDER (void)player; (void)skybox; @@ -1109,14 +1107,15 @@ static void R_SetupFreelook(player_t *player, boolean skybox) G_SoftwareClipAimingPitch((INT32 *)&aimingangle); } - if (rendermode == render_soft) - { - dy = (AIMINGTODY(aimingangle)>>FRACBITS) * viewwidth/BASEVIDWIDTH; - yslope = &yslopetab[viewheight*8 - (viewheight/2 + dy)]; - } + centeryfrac = (viewheight/2)< Date: Sat, 13 Feb 2021 20:33:41 +0100 Subject: [PATCH 0649/1080] Our menu system sucks. That's all I have to say. --- src/m_menu.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index 516bd34c1..0fca39801 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -11419,9 +11419,9 @@ static void M_ServerOptions(INT32 choice) OP_ServerOptionsMenu[ 2].status = IT_GRAYEDOUT; // Max players OP_ServerOptionsMenu[ 3].status = IT_GRAYEDOUT; // Allow add-on downloading OP_ServerOptionsMenu[ 4].status = IT_GRAYEDOUT; // Allow players to join - OP_ServerOptionsMenu[35].status = IT_GRAYEDOUT; // Master server - OP_ServerOptionsMenu[36].status = IT_GRAYEDOUT; // Minimum delay between joins - OP_ServerOptionsMenu[37].status = IT_GRAYEDOUT; // Attempts to resynchronise + OP_ServerOptionsMenu[36].status = IT_GRAYEDOUT; // Master server + OP_ServerOptionsMenu[37].status = IT_GRAYEDOUT; // Minimum delay between joins + OP_ServerOptionsMenu[38].status = IT_GRAYEDOUT; // Attempts to resynchronise } else { @@ -11429,11 +11429,11 @@ static void M_ServerOptions(INT32 choice) OP_ServerOptionsMenu[ 2].status = IT_STRING | IT_CVAR; OP_ServerOptionsMenu[ 3].status = IT_STRING | IT_CVAR; OP_ServerOptionsMenu[ 4].status = IT_STRING | IT_CVAR; - OP_ServerOptionsMenu[35].status = (netgame + OP_ServerOptionsMenu[36].status = (netgame ? IT_GRAYEDOUT : (IT_STRING | IT_CVAR | IT_CV_STRING)); - OP_ServerOptionsMenu[36].status = IT_STRING | IT_CVAR; OP_ServerOptionsMenu[37].status = IT_STRING | IT_CVAR; + OP_ServerOptionsMenu[38].status = IT_STRING | IT_CVAR; } #endif From 6bf76602ed442a6a9d3f141896c0f2dd0a0bf2a8 Mon Sep 17 00:00:00 2001 From: SwitchKaze Date: Tue, 23 Mar 2021 00:02:49 -0500 Subject: [PATCH 0650/1080] Refactor mouse --- src/d_main.c | 9 +++++++++ src/g_game.c | 31 ++++++++++++------------------- src/g_input.c | 34 ++++++++++++++++++++++++---------- src/g_input.h | 17 ++++++++++++++--- 4 files changed, 59 insertions(+), 32 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index 23a2c0133..2a4e9ab81 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -175,6 +175,10 @@ void D_ProcessEvents(void) boolean eaten; + // Reset possibly stale mouse info + G_SetMouseData(0, 0, 1); + G_SetMouseData(0, 0, 2); + for (; eventtail != eventhead; eventtail = (eventtail+1) & (MAXEVENTS-1)) { ev = &events[eventtail]; @@ -219,6 +223,11 @@ void D_ProcessEvents(void) G_Responder(ev); } + + if (mouse.rdx || mouse.rdy) + G_SetMouseData(mouse.rdx, mouse.rdy, 1); + if (mouse2.rdx || mouse2.rdy) + G_SetMouseData(mouse2.rdx, mouse2.rdy, 2); } // diff --git a/src/g_game.c b/src/g_game.c index 2b304b4fd..e46a7f816 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1094,7 +1094,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) angle_t drawangleoffset = (player->powers[pw_carry] == CR_ROLLOUT) ? ANGLE_180 : 0; INT32 chasecam, chasefreelook, alwaysfreelook, usejoystick, invertmouse, turnmultiplier, mousemove; controlstyle_e controlstyle = G_ControlStyle(ssplayer); - INT32 *mx; INT32 *my; INT32 *mly; + mouse_t *m = &mouse; static INT32 turnheld[2]; // for accelerative turning static boolean keyboard_look[2]; // true if lookup/down using keyboard @@ -1117,9 +1117,6 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) invertmouse = cv_invertmouse.value; turnmultiplier = cv_cam_turnmultiplier.value; mousemove = cv_mousemove.value; - mx = &mousex; - my = &mousey; - mly = &mlooky; G_CopyTiccmd(cmd, I_BaseTiccmd(), 1); // empty, or external driver } else @@ -1131,9 +1128,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) invertmouse = cv_invertmouse2.value; turnmultiplier = cv_cam2_turnmultiplier.value; mousemove = cv_mousemove2.value; - mx = &mouse2x; - my = &mouse2y; - mly = &mlook2y; + m = &mouse2; G_CopyTiccmd(cmd, I_BaseTiccmd2(), 1); // empty, or external driver } @@ -1476,7 +1471,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) keyboard_look[forplayer] = false; // looking up/down - *myaiming += (*mly<<19)*player_invert*screen_invert; + *myaiming += (m->mlookdy<<19)*player_invert*screen_invert; } if (analogjoystickmove && joyaiming[forplayer] && lookjoystickvector.yaxis != 0 && configlookaxis != 0) @@ -1510,24 +1505,22 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) } if (!mouseaiming && mousemove) - forward += *my; + forward += m->dy; if ((!demoplayback && (player->pflags & PF_SLIDING))) // Analog for mouse - side += *mx*2; + side += m->dx*2; else if (controlstyle == CS_LMAOGALOG) { - if (*mx) + if (m->dx) { - if (*mx > 0) + if (m->dx > 0) cmd->buttons |= BT_CAMRIGHT; else cmd->buttons |= BT_CAMLEFT; } } else - cmd->angleturn = (INT16)(cmd->angleturn - (*mx*8)); - - *mx = *my = *mly = 0; + cmd->angleturn = (INT16)(cmd->angleturn - (m->dx*8)); if (forward > MAXPLMOVE) forward = MAXPLMOVE; @@ -1873,8 +1866,8 @@ void G_DoLoadLevel(boolean resetplayer) joyxmove[i] = joyymove[i] = 0; joy2xmove[i] = joy2ymove[i] = 0; } - mousex = mousey = 0; - mouse2x = mouse2y = 0; + G_SetMouseData(0, 0, 1); + G_SetMouseData(0, 0, 2); // clear hud messages remains (usually from game startup) CON_ClearHUD(); @@ -3095,8 +3088,8 @@ void G_DoReborn(INT32 playernum) joyxmove[i] = joyymove[i] = 0; joy2xmove[i] = joy2ymove[i] = 0; } - mousex = mousey = 0; - mouse2x = mouse2y = 0; + G_SetMouseData(0, 0, 1); + G_SetMouseData(0, 0, 2); // clear hud messages remains (usually from game startup) CON_ClearHUD(); diff --git a/src/g_input.c b/src/g_input.c index d3c21e774..049a4d82c 100644 --- a/src/g_input.c +++ b/src/g_input.c @@ -31,10 +31,8 @@ consvar_t cv_mouseysens = CVAR_INIT ("mouseysens", "20", CV_SAVE, mousesens_cons consvar_t cv_mouseysens2 = CVAR_INIT ("mouseysens2", "20", CV_SAVE, mousesens_cons_t, NULL); consvar_t cv_controlperkey = CVAR_INIT ("controlperkey", "One", CV_SAVE, onecontrolperkey_cons_t, NULL); -INT32 mousex, mousey; -INT32 mlooky; // like mousey but with a custom sensitivity for mlook - -INT32 mouse2x, mouse2y, mlook2y; +mouse_t mouse; +mouse_t mouse2; // joystick values are repeated INT32 joyxmove[JOYAXISSET], joyymove[JOYAXISSET], joy2xmove[JOYAXISSET], joy2ymove[JOYAXISSET]; @@ -142,9 +140,8 @@ void G_MapEventsToControls(event_t *ev) case ev_mouse: // buttons are virtual keys if (menuactive || CON_Ready() || chat_on) break; - mousex = (INT32)(ev->data2*((cv_mousesens.value*cv_mousesens.value)/110.0f + 0.1f)); - mousey = (INT32)(ev->data3*((cv_mousesens.value*cv_mousesens.value)/110.0f + 0.1f)); - mlooky = (INT32)(ev->data3*((cv_mouseysens.value*cv_mousesens.value)/110.0f + 0.1f)); + mouse.rdx = ev->data2; + mouse.rdy = ev->data3; break; case ev_joystick: // buttons are virtual keys @@ -166,9 +163,8 @@ void G_MapEventsToControls(event_t *ev) case ev_mouse2: // buttons are virtual keys if (menuactive || CON_Ready() || chat_on) break; - mouse2x = (INT32)(ev->data2*((cv_mousesens2.value*cv_mousesens2.value)/110.0f + 0.1f)); - mouse2y = (INT32)(ev->data3*((cv_mousesens2.value*cv_mousesens2.value)/110.0f + 0.1f)); - mlook2y = (INT32)(ev->data3*((cv_mouseysens2.value*cv_mousesens2.value)/110.0f + 0.1f)); + mouse2.rdx = ev->data2; + mouse2.rdy = ev->data3; break; default: @@ -1073,3 +1069,21 @@ void Command_Setcontrol2_f(void) setcontrol(gamecontrolbis); } + +void G_SetMouseData(INT32 realdx, INT32 realdy, UINT8 ssplayer) +{ + mouse_t *m = ssplayer == 1 ? &mouse : &mouse2; + consvar_t *cvsens, *cvysens; + + if (!realdx && !realdy) { + memset(m, 0, sizeof(*m)); + return; + } + cvsens = ssplayer == 1 ? &cv_mousesens : &cv_mousesens2; + cvysens = ssplayer == 1 ? &cv_mouseysens : &cv_mouseysens2; + m->rdx = realdx; + m->rdy = realdy; + m->dx = (INT32)(m->rdx*((cvsens->value*cvsens->value)/110.0f + 0.1f)); + m->dy = (INT32)(m->rdy*((cvsens->value*cvsens->value)/110.0f + 0.1f)); + m->mlookdy = (INT32)(m->rdy*((cvysens->value*cvsens->value)/110.0f + 0.1f)); +} diff --git a/src/g_input.h b/src/g_input.h index ce38f6ba9..5912bfdc7 100644 --- a/src/g_input.h +++ b/src/g_input.h @@ -116,9 +116,17 @@ extern consvar_t cv_mousesens, cv_mouseysens; extern consvar_t cv_mousesens2, cv_mouseysens2; extern consvar_t cv_controlperkey; -extern INT32 mousex, mousey; -extern INT32 mlooky; //mousey with mlookSensitivity -extern INT32 mouse2x, mouse2y, mlook2y; +typedef struct +{ + INT32 dx; // deltas with mousemove sensitivity + INT32 dy; + INT32 mlookdy; // dy with mouselook sensitivity + INT32 rdx; // deltas without sensitivity + INT32 rdy; +} mouse_t; + +extern mouse_t mouse; +extern mouse_t mouse2; extern INT32 joyxmove[JOYAXISSET], joyymove[JOYAXISSET], joy2xmove[JOYAXISSET], joy2ymove[JOYAXISSET]; @@ -175,4 +183,7 @@ void G_CopyControls(INT32 (*setupcontrols)[2], INT32 (*fromcontrols)[2], const I void G_SaveKeySetting(FILE *f, INT32 (*fromcontrols)[2], INT32 (*fromcontrolsbis)[2]); INT32 G_CheckDoubleUsage(INT32 keynum, boolean modify); +// sets the members of a mouse_t given position deltas +void G_SetMouseData(INT32 realdx, INT32 realdy, UINT8 ssplayer); + #endif From 3faa98cf4a824ac21a7fa8eae2292f2c6e6d917c Mon Sep 17 00:00:00 2001 From: SwitchKaze Date: Wed, 24 Mar 2021 03:54:11 -0500 Subject: [PATCH 0651/1080] Expose inputs to Lua --- src/CMakeLists.txt | 1 + src/blua/Makefile.cfg | 3 +- src/console.c | 4 +- src/d_main.c | 17 +++ src/deh_tables.c | 59 ++++++++ src/g_game.c | 84 +++++------ src/g_game.h | 20 +++ src/g_input.c | 16 +- src/g_input.h | 4 +- src/lua_baselib.c | 2 + src/lua_hook.h | 4 + src/lua_hooklib.c | 72 +++++++++ src/lua_inputlib.c | 214 +++++++++++++++++++++++++++ src/lua_libs.h | 3 + src/lua_script.c | 21 ++- src/m_menu.c | 4 +- src/sdl/Srb2SDL-vc10.vcxproj | 1 + src/sdl/Srb2SDL-vc10.vcxproj.filters | 3 + 18 files changed, 471 insertions(+), 61 deletions(-) create mode 100644 src/lua_inputlib.c diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 87a0499b6..77b5a0e4f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -281,6 +281,7 @@ set(SRB2_LUA_SOURCES lua_mobjlib.c lua_playerlib.c lua_polyobjlib.c + lua_inputlib.c lua_script.c lua_skinlib.c lua_thinkerlib.c diff --git a/src/blua/Makefile.cfg b/src/blua/Makefile.cfg index 3a2962e65..4536628ba 100644 --- a/src/blua/Makefile.cfg +++ b/src/blua/Makefile.cfg @@ -50,4 +50,5 @@ OBJS:=$(OBJS) \ $(OBJDIR)/lua_taglib.o \ $(OBJDIR)/lua_polyobjlib.o \ $(OBJDIR)/lua_blockmaplib.o \ - $(OBJDIR)/lua_hudlib.o + $(OBJDIR)/lua_hudlib.o \ + $(OBJDIR)/lua_inputlib.o diff --git a/src/console.c b/src/console.c index 121605b10..3b29e9c4f 100644 --- a/src/console.c +++ b/src/console.c @@ -221,7 +221,7 @@ static void CONS_Bind_f(void) for (key = 0; key < NUMINPUTS; key++) if (bindtable[key]) { - CONS_Printf("%s : \"%s\"\n", G_KeynumToString(key), bindtable[key]); + CONS_Printf("%s : \"%s\"\n", G_KeyNumToString(key), bindtable[key]); na = 1; } if (!na) @@ -229,7 +229,7 @@ static void CONS_Bind_f(void) return; } - key = G_KeyStringtoNum(COM_Argv(1)); + key = G_KeyStringToNum(COM_Argv(1)); if (key <= 0 || key >= NUMINPUTS) { CONS_Alert(CONS_NOTICE, M_GetText("Invalid key name\n")); diff --git a/src/d_main.c b/src/d_main.c index 2a4e9ab81..d60a6cf47 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -181,6 +181,8 @@ void D_ProcessEvents(void) for (; eventtail != eventhead; eventtail = (eventtail+1) & (MAXEVENTS-1)) { + boolean hooked = false; + ev = &events[eventtail]; // Screenshots over everything so that they can be taken anywhere. @@ -193,6 +195,12 @@ void D_ProcessEvents(void) continue; } + if (!CON_Ready() && !menuactive) { + if (G_LuaResponder(ev)) + continue; + hooked = true; + } + // Menu input #ifdef HAVE_THREADS I_lock_mutex(&m_menu_mutex); @@ -207,6 +215,12 @@ void D_ProcessEvents(void) if (eaten) continue; // menu ate the event + if (!hooked && !CON_Ready()) { + if (G_LuaResponder(ev)) + continue; + hooked = true; + } + // console input #ifdef HAVE_THREADS I_lock_mutex(&con_mutex); @@ -221,6 +235,9 @@ void D_ProcessEvents(void) if (eaten) continue; // ate the event + if (!hooked && G_LuaResponder(ev)) + continue; + G_Responder(ev); } diff --git a/src/deh_tables.c b/src/deh_tables.c index dd6d7d69f..7bfe723da 100644 --- a/src/deh_tables.c +++ b/src/deh_tables.c @@ -22,6 +22,8 @@ #include "v_video.h" // video flags (for lua) #include "i_sound.h" // musictype_t (for lua) #include "g_state.h" // gamestate_t (for lua) +#include "g_game.h" // Joystick axes (for lua) +#include "g_input.h" // Game controls (for lua) #include "deh_tables.h" @@ -5455,6 +5457,63 @@ struct int_const_s const INT_CONST[] = { {"GS_DEDICATEDSERVER",GS_DEDICATEDSERVER}, {"GS_WAITINGPLAYERS",GS_WAITINGPLAYERS}, + // Joystick axes + {"JA_NONE",JA_NONE}, + {"JA_TURN",JA_TURN}, + {"JA_MOVE",JA_MOVE}, + {"JA_LOOK",JA_LOOK}, + {"JA_STRAFE",JA_STRAFE}, + {"JA_DIGITAL",JA_DIGITAL}, + {"JA_JUMP",JA_JUMP}, + {"JA_SPIN",JA_SPIN}, + {"JA_FIRE",JA_FIRE}, + {"JA_FIRENORMAL",JA_FIRENORMAL}, + + // Game controls + {"gc_null",gc_null}, + {"gc_forward",gc_forward}, + {"gc_backward",gc_backward}, + {"gc_strafeleft",gc_strafeleft}, + {"gc_straferight",gc_straferight}, + {"gc_turnleft",gc_turnleft}, + {"gc_turnright",gc_turnright}, + {"gc_weaponnext",gc_weaponnext}, + {"gc_weaponprev",gc_weaponprev}, + {"gc_wepslot1",gc_wepslot1}, + {"gc_wepslot2",gc_wepslot2}, + {"gc_wepslot3",gc_wepslot3}, + {"gc_wepslot4",gc_wepslot4}, + {"gc_wepslot5",gc_wepslot5}, + {"gc_wepslot6",gc_wepslot6}, + {"gc_wepslot7",gc_wepslot7}, + {"gc_wepslot8",gc_wepslot8}, + {"gc_wepslot9",gc_wepslot9}, + {"gc_wepslot10",gc_wepslot10}, + {"gc_fire",gc_fire}, + {"gc_firenormal",gc_firenormal}, + {"gc_tossflag",gc_tossflag}, + {"gc_spin",gc_spin}, + {"gc_camtoggle",gc_camtoggle}, + {"gc_camreset",gc_camreset}, + {"gc_lookup",gc_lookup}, + {"gc_lookdown",gc_lookdown}, + {"gc_centerview",gc_centerview}, + {"gc_mouseaiming",gc_mouseaiming}, + {"gc_talkkey",gc_talkkey}, + {"gc_teamkey",gc_teamkey}, + {"gc_scores",gc_scores}, + {"gc_jump",gc_jump}, + {"gc_console",gc_console}, + {"gc_pause",gc_pause}, + {"gc_systemmenu",gc_systemmenu}, + {"gc_screenshot",gc_screenshot}, + {"gc_recordgif",gc_recordgif}, + {"gc_viewpoint",gc_viewpoint}, + {"gc_custom1",gc_custom1}, + {"gc_custom2",gc_custom2}, + {"gc_custom3",gc_custom3}, + {"num_gamecontrols",num_gamecontrols}, + {NULL,0} }; diff --git a/src/g_game.c b/src/g_game.c index e46a7f816..823ea7c56 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -406,22 +406,6 @@ consvar_t cv_cam_lockonboss[2] = { CVAR_INIT ("cam2_lockaimassist", "Bosses", CV_SAVE, lockedassist_cons_t, NULL), }; -typedef enum -{ - AXISNONE = 0, - AXISTURN, - AXISMOVE, - AXISLOOK, - AXISSTRAFE, - - AXISDIGITAL, // axes below this use digital deadzone - - AXISJUMP, - AXISSPIN, - AXISFIRE, - AXISFIRENORMAL, -} axis_input_e; - consvar_t cv_turnaxis = CVAR_INIT ("joyaxis_turn", "X-Rudder", CV_SAVE, joyaxis_cons_t, NULL); consvar_t cv_moveaxis = CVAR_INIT ("joyaxis_move", "Y-Axis", CV_SAVE, joyaxis_cons_t, NULL); consvar_t cv_sideaxis = CVAR_INIT ("joyaxis_side", "X-Axis", CV_SAVE, joyaxis_cons_t, NULL); @@ -841,7 +825,7 @@ INT16 G_SoftwareClipAimingPitch(INT32 *aiming) return (INT16)((*aiming)>>16); } -static INT32 JoyAxis(axis_input_e axissel) +INT32 JoyAxis(joyaxis_e axissel) { INT32 retaxis; INT32 axisval; @@ -850,28 +834,28 @@ static INT32 JoyAxis(axis_input_e axissel) //find what axis to get switch (axissel) { - case AXISTURN: + case JA_TURN: axisval = cv_turnaxis.value; break; - case AXISMOVE: + case JA_MOVE: axisval = cv_moveaxis.value; break; - case AXISLOOK: + case JA_LOOK: axisval = cv_lookaxis.value; break; - case AXISSTRAFE: + case JA_STRAFE: axisval = cv_sideaxis.value; break; - case AXISJUMP: + case JA_JUMP: axisval = cv_jumpaxis.value; break; - case AXISSPIN: + case JA_SPIN: axisval = cv_spinaxis.value; break; - case AXISFIRE: + case JA_FIRE: axisval = cv_fireaxis.value; break; - case AXISFIRENORMAL: + case JA_FIRENORMAL: axisval = cv_firenaxis.value; break; default: @@ -903,7 +887,7 @@ static INT32 JoyAxis(axis_input_e axissel) if (retaxis > (+JOYAXISRANGE)) retaxis = +JOYAXISRANGE; - if (!Joystick.bGamepadStyle && axissel > AXISDIGITAL) + if (!Joystick.bGamepadStyle && axissel > JA_DIGITAL) { const INT32 jdeadzone = ((JOYAXISRANGE-1) * cv_digitaldeadzone.value) >> FRACBITS; if (-jdeadzone < retaxis && retaxis < jdeadzone) @@ -914,7 +898,7 @@ static INT32 JoyAxis(axis_input_e axissel) return retaxis; } -static INT32 Joy2Axis(axis_input_e axissel) +INT32 Joy2Axis(joyaxis_e axissel) { INT32 retaxis; INT32 axisval; @@ -923,28 +907,28 @@ static INT32 Joy2Axis(axis_input_e axissel) //find what axis to get switch (axissel) { - case AXISTURN: + case JA_TURN: axisval = cv_turnaxis2.value; break; - case AXISMOVE: + case JA_MOVE: axisval = cv_moveaxis2.value; break; - case AXISLOOK: + case JA_LOOK: axisval = cv_lookaxis2.value; break; - case AXISSTRAFE: + case JA_STRAFE: axisval = cv_sideaxis2.value; break; - case AXISJUMP: + case JA_JUMP: axisval = cv_jumpaxis2.value; break; - case AXISSPIN: + case JA_SPIN: axisval = cv_spinaxis2.value; break; - case AXISFIRE: + case JA_FIRE: axisval = cv_fireaxis2.value; break; - case AXISFIRENORMAL: + case JA_FIRENORMAL: axisval = cv_firenaxis2.value; break; default: @@ -978,7 +962,7 @@ static INT32 Joy2Axis(axis_input_e axissel) if (retaxis > (+JOYAXISRANGE)) retaxis = +JOYAXISRANGE; - if (!Joystick2.bGamepadStyle && axissel > AXISDIGITAL) + if (!Joystick2.bGamepadStyle && axissel > JA_DIGITAL) { const INT32 jdeadzone = ((JOYAXISRANGE-1) * cv_digitaldeadzone2.value) >> FRACBITS; if (-jdeadzone < retaxis && retaxis < jdeadzone) @@ -1174,10 +1158,10 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) *myaiming = 0; joyaiming[forplayer] = thisjoyaiming; - turnaxis = PlayerJoyAxis(ssplayer, AXISTURN); + turnaxis = PlayerJoyAxis(ssplayer, JA_TURN); if (strafeisturn) - turnaxis += PlayerJoyAxis(ssplayer, AXISSTRAFE); - lookaxis = PlayerJoyAxis(ssplayer, AXISLOOK); + turnaxis += PlayerJoyAxis(ssplayer, JA_STRAFE); + lookaxis = PlayerJoyAxis(ssplayer, JA_LOOK); lookjoystickvector.xaxis = turnaxis; lookjoystickvector.yaxis = lookaxis; G_HandleAxisDeadZone(forplayer, &lookjoystickvector); @@ -1256,8 +1240,8 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) tta_factor[forplayer] = 0; // suspend turn to angle } - strafeaxis = strafeisturn ? 0 : PlayerJoyAxis(ssplayer, AXISSTRAFE); - moveaxis = PlayerJoyAxis(ssplayer, AXISMOVE); + strafeaxis = strafeisturn ? 0 : PlayerJoyAxis(ssplayer, JA_STRAFE); + moveaxis = PlayerJoyAxis(ssplayer, JA_MOVE); movejoystickvector.xaxis = strafeaxis; movejoystickvector.yaxis = moveaxis; G_HandleAxisDeadZone(forplayer, &movejoystickvector); @@ -1313,12 +1297,12 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) } // fire with any button/key - axis = PlayerJoyAxis(ssplayer, AXISFIRE); + axis = PlayerJoyAxis(ssplayer, JA_FIRE); if (PLAYERINPUTDOWN(ssplayer, gc_fire) || (usejoystick && axis > 0)) cmd->buttons |= BT_ATTACK; // fire normal with any button/key - axis = PlayerJoyAxis(ssplayer, AXISFIRENORMAL); + axis = PlayerJoyAxis(ssplayer, JA_FIRENORMAL); if (PLAYERINPUTDOWN(ssplayer, gc_firenormal) || (usejoystick && axis > 0)) cmd->buttons |= BT_FIRENORMAL; @@ -1334,7 +1318,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) cmd->buttons |= BT_CUSTOM3; // use with any button/key - axis = PlayerJoyAxis(ssplayer, AXISSPIN); + axis = PlayerJoyAxis(ssplayer, JA_SPIN); if (PLAYERINPUTDOWN(ssplayer, gc_spin) || (usejoystick && axis > 0)) cmd->buttons |= BT_SPIN; @@ -1452,7 +1436,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) // jump button - axis = PlayerJoyAxis(ssplayer, AXISJUMP); + axis = PlayerJoyAxis(ssplayer, JA_JUMP); if (PLAYERINPUTDOWN(ssplayer, gc_jump) || (usejoystick && axis > 0)) cmd->buttons |= BT_JUMP; @@ -2191,6 +2175,16 @@ boolean G_Responder(event_t *ev) return false; } +// +// G_LuaResponder +// Let Lua handle key events. +// +boolean G_LuaResponder(event_t *ev) +{ + return (ev->type == ev_keydown && LUAh_KeyDown(ev->data1)) || + (ev->type == ev_keyup && LUAh_KeyUp(ev->data1)); +} + // // G_Ticker // Make ticcmd_ts for the players. diff --git a/src/g_game.h b/src/g_game.h index 744d6755a..0cc380294 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -85,6 +85,25 @@ typedef enum } lockassist_e; +typedef enum +{ + JA_NONE = 0, + JA_TURN, + JA_MOVE, + JA_LOOK, + JA_STRAFE, + + JA_DIGITAL, // axes below this use digital deadzone + + JA_JUMP, + JA_SPIN, + JA_FIRE, + JA_FIRENORMAL, +} joyaxis_e; + +INT32 JoyAxis(joyaxis_e axissel); +INT32 Joy2Axis(joyaxis_e axissel); + // mouseaiming (looking up/down with the mouse or keyboard) #define KB_LOOKSPEED (1<<25) #define MAXPLMOVE (50) @@ -204,6 +223,7 @@ void G_EndGame(void); // moved from y_inter.c/h and renamed void G_Ticker(boolean run); boolean G_Responder(event_t *ev); +boolean G_LuaResponder(event_t *ev); void G_AddPlayer(INT32 playernum); diff --git a/src/g_input.c b/src/g_input.c index 049a4d82c..629b389e5 100644 --- a/src/g_input.c +++ b/src/g_input.c @@ -626,7 +626,7 @@ void G_ClearAllControlKeys(void) // Returns the name of a key (or virtual key for mouse and joy) // the input value being an keynum // -const char *G_KeynumToString(INT32 keynum) +const char *G_KeyNumToString(INT32 keynum) { static char keynamestr[8]; @@ -650,7 +650,7 @@ const char *G_KeynumToString(INT32 keynum) return keynamestr; } -INT32 G_KeyStringtoNum(const char *keystr) +INT32 G_KeyStringToNum(const char *keystr) { UINT32 j; @@ -813,10 +813,10 @@ void G_SaveKeySetting(FILE *f, INT32 (*fromcontrols)[2], INT32 (*fromcontrolsbis for (i = 1; i < num_gamecontrols; i++) { fprintf(f, "setcontrol \"%s\" \"%s\"", gamecontrolname[i], - G_KeynumToString(fromcontrols[i][0])); + G_KeyNumToString(fromcontrols[i][0])); if (fromcontrols[i][1]) - fprintf(f, " \"%s\"\n", G_KeynumToString(fromcontrols[i][1])); + fprintf(f, " \"%s\"\n", G_KeyNumToString(fromcontrols[i][1])); else fprintf(f, "\n"); } @@ -824,10 +824,10 @@ void G_SaveKeySetting(FILE *f, INT32 (*fromcontrols)[2], INT32 (*fromcontrolsbis for (i = 1; i < num_gamecontrols; i++) { fprintf(f, "setcontrol2 \"%s\" \"%s\"", gamecontrolname[i], - G_KeynumToString(fromcontrolsbis[i][0])); + G_KeyNumToString(fromcontrolsbis[i][0])); if (fromcontrolsbis[i][1]) - fprintf(f, " \"%s\"\n", G_KeynumToString(fromcontrolsbis[i][1])); + fprintf(f, " \"%s\"\n", G_KeyNumToString(fromcontrolsbis[i][1])); else fprintf(f, "\n"); } @@ -1003,8 +1003,8 @@ static void setcontrol(INT32 (*gc)[2]) CONS_Printf(M_GetText("Control '%s' unknown\n"), namectrl); return; } - keynum1 = G_KeyStringtoNum(COM_Argv(2)); - keynum2 = G_KeyStringtoNum(COM_Argv(3)); + keynum1 = G_KeyStringToNum(COM_Argv(2)); + keynum2 = G_KeyStringToNum(COM_Argv(3)); keynum = G_FilterKeyByVersion(numctrl, 0, player, &keynum1, &keynum2, &nestedoverride); if (keynum >= 0) diff --git a/src/g_input.h b/src/g_input.h index 5912bfdc7..96139e751 100644 --- a/src/g_input.h +++ b/src/g_input.h @@ -169,8 +169,8 @@ extern const INT32 gcl_jump_spin[num_gcl_jump_spin]; void G_MapEventsToControls(event_t *ev); // returns the name of a key -const char *G_KeynumToString(INT32 keynum); -INT32 G_KeyStringtoNum(const char *keystr); +const char *G_KeyNumToString(INT32 keynum); +INT32 G_KeyStringToNum(const char *keystr); // detach any keys associated to the given game control void G_ClearControlKeys(INT32 (*setupcontrols)[2], INT32 control); diff --git a/src/lua_baselib.c b/src/lua_baselib.c index a59ba546e..71282d09c 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -212,6 +212,8 @@ static const struct { {META_ACTION, "action"}, {META_LUABANKS, "luabanks[]"}, + + {META_MOUSE, "mouse_t"}, {NULL, NULL} }; diff --git a/src/lua_hook.h b/src/lua_hook.h index 0d631aa4e..ae1c17a4d 100644 --- a/src/lua_hook.h +++ b/src/lua_hook.h @@ -63,6 +63,8 @@ enum hook { hook_MusicChange, hook_PlayerHeight, hook_PlayerCanEnterSpinGaps, + hook_KeyDown, + hook_KeyUp, hook_MAX // last hook }; @@ -122,3 +124,5 @@ boolean LUAh_PlayerCmd(player_t *player, ticcmd_t *cmd); // Hook for building pl boolean LUAh_MusicChange(const char *oldname, char *newname, UINT16 *mflags, boolean *looping, UINT32 *position, UINT32 *prefadems, UINT32 *fadeinms); // Hook for music changes fixed_t LUAh_PlayerHeight(player_t *player); UINT8 LUAh_PlayerCanEnterSpinGaps(player_t *player); +boolean LUAh_KeyDown(INT32 keycode); // Hooks for key events +boolean LUAh_KeyUp(INT32 keycode); diff --git a/src/lua_hooklib.c b/src/lua_hooklib.c index 637809fd8..8a7ce2cb9 100644 --- a/src/lua_hooklib.c +++ b/src/lua_hooklib.c @@ -79,6 +79,8 @@ const char *const hookNames[hook_MAX+1] = { "MusicChange", "PlayerHeight", "PlayerCanEnterSpinGaps", + "KeyDown", + "KeyUp", NULL }; @@ -2061,3 +2063,73 @@ UINT8 LUAh_PlayerCanEnterSpinGaps(player_t *player) lua_settop(gL, 0); return canEnter; } + +// Hook for key press +boolean LUAh_KeyDown(INT32 keycode) +{ + hook_p hookp; + boolean override = false; + if (!gL || !(hooksAvailable[hook_KeyDown/8] & (1<<(hook_KeyDown%8)))) + return false; + + lua_settop(gL, 0); + lua_pushcfunction(gL, LUA_GetErrorMessage); + + for (hookp = roothook; hookp; hookp = hookp->next) + { + if (hookp->type != hook_KeyDown) + continue; + + PushHook(gL, hookp); + lua_pushinteger(gL, keycode); + if (lua_pcall(gL, 1, 1, 1)) { + if (!hookp->error || cv_debug & DBG_LUA) + CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); + lua_pop(gL, 1); + hookp->error = true; + continue; + } + if (lua_toboolean(gL, -1)) + override = true; + lua_pop(gL, 1); + } + + lua_settop(gL, 0); + + return override; +} + +// Hook for key release +boolean LUAh_KeyUp(INT32 keycode) +{ + hook_p hookp; + boolean override = false; + if (!gL || !(hooksAvailable[hook_KeyUp/8] & (1<<(hook_KeyUp%8)))) + return false; + + lua_settop(gL, 0); + lua_pushcfunction(gL, LUA_GetErrorMessage); + + for (hookp = roothook; hookp; hookp = hookp->next) + { + if (hookp->type != hook_KeyUp) + continue; + + PushHook(gL, hookp); + lua_pushinteger(gL, keycode); + if (lua_pcall(gL, 1, 1, 1)) { + if (!hookp->error || cv_debug & DBG_LUA) + CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); + lua_pop(gL, 1); + hookp->error = true; + continue; + } + if (lua_toboolean(gL, -1)) + override = true; + lua_pop(gL, 1); + } + + lua_settop(gL, 0); + + return override; +} diff --git a/src/lua_inputlib.c b/src/lua_inputlib.c new file mode 100644 index 000000000..1b5991e57 --- /dev/null +++ b/src/lua_inputlib.c @@ -0,0 +1,214 @@ +// SONIC ROBO BLAST 2 +//----------------------------------------------------------------------------- +// Copyright (C) 2021 by Sonic Team Junior. +// +// This program is free software distributed under the +// terms of the GNU General Public License, version 2. +// See the 'LICENSE' file for more details. +//----------------------------------------------------------------------------- +/// \file lua_inputlib.c +/// \brief input library for Lua scripting + +#include "doomdef.h" +#include "fastcmp.h" +#include "g_input.h" +#include "g_game.h" +#include "hu_stuff.h" + +#include "lua_script.h" +#include "lua_libs.h" + +/////////////// +// FUNCTIONS // +/////////////// + +static int lib_gameControlDown(lua_State *L) +{ + int i = luaL_checkinteger(L, 1); + if (i < 0 || i >= num_gamecontrols) + return luaL_error(L, "gc_* constant %d out of range (0 - %d)", i, num_gamecontrols-1); + lua_pushinteger(L, PLAYER1INPUTDOWN(i)); + return 1; +} + +static int lib_gameControl2Down(lua_State *L) +{ + int i = luaL_checkinteger(L, 1); + if (i < 0 || i >= num_gamecontrols) + return luaL_error(L, "gc_* constant %d out of range (0 - %d)", i, num_gamecontrols-1); + lua_pushinteger(L, PLAYER2INPUTDOWN(i)); + return 1; +} + +static int lib_gameControlToKeyNum(lua_State *L) +{ + int i = luaL_checkinteger(L, 1); + if (i < 0 || i >= num_gamecontrols) + return luaL_error(L, "gc_* constant %d out of range (0 - %d)", i, num_gamecontrols-1); + lua_pushinteger(L, gamecontrol[i][0]); + lua_pushinteger(L, gamecontrol[i][1]); + return 2; +} + +static int lib_gameControl2ToKeyNum(lua_State *L) +{ + int i = luaL_checkinteger(L, 1); + if (i < 0 || i >= num_gamecontrols) + return luaL_error(L, "gc_* constant %d out of range (0 - %d)", i, num_gamecontrols-1); + lua_pushinteger(L, gamecontrolbis[i][0]); + lua_pushinteger(L, gamecontrolbis[i][1]); + return 2; +} + +static int lib_joyAxis(lua_State *L) +{ + int i = luaL_checkinteger(L, 1); + lua_pushinteger(L, JoyAxis(i)); + return 1; +} + +static int lib_joy2Axis(lua_State *L) +{ + int i = luaL_checkinteger(L, 1); + lua_pushinteger(L, Joy2Axis(i)); + return 1; +} + +static int lib_keyNumToString(lua_State *L) +{ + int i = luaL_checkinteger(L, 1); + lua_pushstring(L, G_KeyNumToString(i)); + return 1; +} + +static int lib_keyStringToNum(lua_State *L) +{ + const char *str = luaL_checkstring(L, 1); + lua_pushinteger(L, G_KeyStringToNum(str)); + return 1; +} + +static int lib_keyNumPrintable(lua_State *L) +{ + int i = luaL_checkinteger(L, 1); + lua_pushboolean(L, i >= 32 && i <= 127); + return 1; +} + +static int lib_shiftKeyNum(lua_State *L) +{ + int i = luaL_checkinteger(L, 1); + if (i >= 32 && i <= 127) + lua_pushinteger(L, shiftxform[i]); + return 1; +} + +static luaL_Reg lib[] = { + {"G_GameControlDown", lib_gameControlDown}, + {"G_GameControl2Down", lib_gameControl2Down}, + {"G_GameControlToKeyNum", lib_gameControlToKeyNum}, + {"G_GameControl2ToKeyNum", lib_gameControl2ToKeyNum}, + {"G_JoyAxis", lib_joyAxis}, + {"G_Joy2Axis", lib_joy2Axis}, + {"G_KeyNumToString", lib_keyNumToString}, + {"G_KeyStringToNum", lib_keyStringToNum}, + {"HU_KeyNumPrintable", lib_keyNumPrintable}, + {"HU_ShiftKeyNum", lib_shiftKeyNum}, + {NULL, NULL} +}; + +/////////////////// +// gamekeydown[] // +/////////////////// + +static int lib_getGameKeyDown(lua_State *L) +{ + int i = luaL_checkinteger(L, 2); + if (i < 0 || i >= NUMINPUTS) + return luaL_error(L, "gamekeydown[] index %d out of range (0 - %d)", i, NUMINPUTS-1); + lua_pushboolean(L, gamekeydown[i]); + return 1; +} + +static int lib_setGameKeyDown(lua_State *L) +{ + int i = luaL_checkinteger(L, 2); + boolean j = luaL_checkboolean(L, 3); + if (i < 0 || i >= NUMINPUTS) + return luaL_error(L, "gamekeydown[] index %d out of range (0 - %d)", i, NUMINPUTS-1); + gamekeydown[i] = j; + return 0; +} + +static int lib_lenGameKeyDown(lua_State *L) +{ + lua_pushinteger(L, NUMINPUTS); + return 1; +} + +/////////// +// MOUSE // +/////////// + +static int mouse_get(lua_State *L) +{ + mouse_t *m = *((mouse_t **)luaL_checkudata(L, 1, META_MOUSE)); + const char *field = luaL_checkstring(L, 2); + + I_Assert(m != NULL); + + if (fastcmp(field,"dx")) + lua_pushinteger(L, m->dx); + else if (fastcmp(field,"dy")) + lua_pushinteger(L, m->dy); + else if (fastcmp(field,"mlookdy")) + lua_pushinteger(L, m->mlookdy); + else if (fastcmp(field,"rdx")) + lua_pushinteger(L, m->rdx); + else if (fastcmp(field,"rdy")) + lua_pushinteger(L, m->rdy); + else + return luaL_error(L, "mouse_t has no field named %s", field); + + return 1; +} + +// #mouse -> 1 or 2 +static int mouse_num(lua_State *L) +{ + mouse_t *m = *((mouse_t **)luaL_checkudata(L, 1, META_MOUSE)); + + I_Assert(m != NULL); + + lua_pushinteger(L, m == &mouse ? 1 : 2); + return 1; +} + +int LUA_InputLib(lua_State *L) +{ + lua_newuserdata(L, 0); + lua_createtable(L, 0, 2); + lua_pushcfunction(L, lib_getGameKeyDown); + lua_setfield(L, -2, "__index"); + + lua_pushcfunction(L, lib_setGameKeyDown); + lua_setfield(L, -2, "__newindex"); + + lua_pushcfunction(L, lib_lenGameKeyDown); + lua_setfield(L, -2, "__len"); + lua_setmetatable(L, -2); + lua_setglobal(L, "gamekeydown"); + + luaL_newmetatable(L, META_MOUSE); + lua_pushcfunction(L, mouse_get); + lua_setfield(L, -2, "__index"); + + lua_pushcfunction(L, mouse_num); + lua_setfield(L, -2, "__len"); + lua_pop(L, 1); + + // Set global functions + lua_pushvalue(L, LUA_GLOBALSINDEX); + luaL_register(L, NULL, lib); + return 0; +} diff --git a/src/lua_libs.h b/src/lua_libs.h index fbe8d4878..d56c45ab4 100644 --- a/src/lua_libs.h +++ b/src/lua_libs.h @@ -88,6 +88,8 @@ extern lua_State *gL; #define META_LUABANKS "LUABANKS[]*" +#define META_MOUSE "MOUSE_T*" + boolean luaL_checkboolean(lua_State *L, int narg); int LUA_EnumLib(lua_State *L); @@ -106,3 +108,4 @@ int LUA_TagLib(lua_State *L); int LUA_PolyObjLib(lua_State *L); int LUA_BlockmapLib(lua_State *L); int LUA_HudLib(lua_State *L); +int LUA_InputLib(lua_State *L); diff --git a/src/lua_script.c b/src/lua_script.c index 7fd5a98e6..45c18178a 100644 --- a/src/lua_script.c +++ b/src/lua_script.c @@ -20,6 +20,7 @@ #include "r_state.h" #include "r_sky.h" #include "g_game.h" +#include "g_input.h" #include "f_finale.h" #include "byteptr.h" #include "p_saveg.h" @@ -57,6 +58,7 @@ static lua_CFunction liblist[] = { LUA_PolyObjLib, // polyobj_t LUA_BlockmapLib, // blockmap stuff LUA_HudLib, // HUD stuff + LUA_InputLib, // inputs NULL }; @@ -380,6 +382,12 @@ int LUA_PushGlobals(lua_State *L, const char *word) } else if (fastcmp(word, "gamestate")) { lua_pushinteger(L, gamestate); return 1; + } else if (fastcmp(word, "mouse")) { + LUA_PushUserdata(L, &mouse, META_MOUSE); + return 1; + } else if (fastcmp(word, "mouse2")) { + LUA_PushUserdata(L, &mouse2, META_MOUSE); + return 1; } return 0; } @@ -934,6 +942,7 @@ enum ARCH_SLOPE, ARCH_MAPHEADER, ARCH_SKINCOLOR, + ARCH_MOUSE, ARCH_TEND=0xFF, }; @@ -961,6 +970,7 @@ static const struct { {META_SLOPE, ARCH_SLOPE}, {META_MAPHEADER, ARCH_MAPHEADER}, {META_SKINCOLOR, ARCH_SKINCOLOR}, + {META_MOUSE, ARCH_MOUSE}, {NULL, ARCH_NULL} }; @@ -1268,7 +1278,6 @@ static UINT8 ArchiveValue(int TABLESINDEX, int myindex) } break; } - case ARCH_SKINCOLOR: { skincolor_t *info = *((skincolor_t **)lua_touserdata(gL, myindex)); @@ -1276,6 +1285,13 @@ static UINT8 ArchiveValue(int TABLESINDEX, int myindex) WRITEUINT16(save_p, info - skincolors); break; } + case ARCH_MOUSE: + { + mouse_t *m = *((mouse_t **)lua_touserdata(gL, myindex)); + WRITEUINT8(save_p, ARCH_MOUSE); + WRITEUINT8(save_p, m == &mouse ? 1 : 2); + break; + } default: WRITEUINT8(save_p, ARCH_NULL); return 2; @@ -1527,6 +1543,9 @@ static UINT8 UnArchiveValue(int TABLESINDEX) case ARCH_SKINCOLOR: LUA_PushUserdata(gL, &skincolors[READUINT16(save_p)], META_SKINCOLOR); break; + case ARCH_MOUSE: + LUA_PushUserdata(gL, READUINT16(save_p) == 1 ? &mouse : &mouse2, META_MOUSE); + break; case ARCH_TEND: return 1; } diff --git a/src/m_menu.c b/src/m_menu.c index 0fca39801..fffe08cd2 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -12683,13 +12683,13 @@ static void M_DrawControl(void) else { if (keys[0] != KEY_NULL) - strcat (tmp, G_KeynumToString (keys[0])); + strcat (tmp, G_KeyNumToString (keys[0])); if (keys[0] != KEY_NULL && keys[1] != KEY_NULL) strcat(tmp," or "); if (keys[1] != KEY_NULL) - strcat (tmp, G_KeynumToString (keys[1])); + strcat (tmp, G_KeyNumToString (keys[1])); } diff --git a/src/sdl/Srb2SDL-vc10.vcxproj b/src/sdl/Srb2SDL-vc10.vcxproj index d46a4af2b..707b5c2d8 100644 --- a/src/sdl/Srb2SDL-vc10.vcxproj +++ b/src/sdl/Srb2SDL-vc10.vcxproj @@ -406,6 +406,7 @@ + diff --git a/src/sdl/Srb2SDL-vc10.vcxproj.filters b/src/sdl/Srb2SDL-vc10.vcxproj.filters index adae2f446..dbc32c502 100644 --- a/src/sdl/Srb2SDL-vc10.vcxproj.filters +++ b/src/sdl/Srb2SDL-vc10.vcxproj.filters @@ -720,6 +720,9 @@ LUA + + LUA + LUA From eb2dc9e99bba9b321a0a1cc6c19071fa756a3d62 Mon Sep 17 00:00:00 2001 From: SwitchKaze Date: Thu, 25 Mar 2021 21:14:59 -0500 Subject: [PATCH 0652/1080] Mouse improvements --- src/d_main.c | 45 +++++++++++++++++++++++++++++++++++++++++---- src/deh_tables.c | 14 ++++++++++++++ src/g_game.c | 32 ++++++++++++++++++++------------ src/g_input.c | 12 +++--------- src/g_input.h | 14 +++++++++++++- src/i_system.h | 12 ++++++++++++ src/lua_inputlib.c | 28 ++++++++++++++++++++++++++++ src/m_menu.c | 2 +- src/sdl/i_system.c | 2 +- src/sdl/i_video.c | 22 ++++++++++++++++++++-- 10 files changed, 153 insertions(+), 30 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index d60a6cf47..0d21d2531 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -176,8 +176,10 @@ void D_ProcessEvents(void) boolean eaten; // Reset possibly stale mouse info - G_SetMouseData(0, 0, 1); - G_SetMouseData(0, 0, 2); + G_SetMouseDeltas(0, 0, 1); + G_SetMouseDeltas(0, 0, 2); + mouse.buttons &= ~(MB_SCROLLUP|MB_SCROLLDOWN); + mouse2.buttons &= ~(MB_SCROLLUP|MB_SCROLLDOWN); for (; eventtail != eventhead; eventtail = (eventtail+1) & (MAXEVENTS-1)) { @@ -185,6 +187,41 @@ void D_ProcessEvents(void) ev = &events[eventtail]; + // Set mouse buttons early in case event is eaten later + if (ev->type == ev_keydown || ev->type == ev_keyup) + { + // Mouse buttons + if ((UINT32)(ev->data1 - KEY_MOUSE1) < MOUSEBUTTONS) + { + if (ev->type == ev_keydown) + mouse.buttons |= 1 << (ev->data1 - KEY_MOUSE1); + else + mouse.buttons &= ~(1 << (ev->data1 - KEY_MOUSE1)); + } + else if ((UINT32)(ev->data1 - KEY_2MOUSE1) < MOUSEBUTTONS) + { + if (ev->type == ev_keydown) + mouse2.buttons |= 1 << (ev->data1 - KEY_2MOUSE1); + else + mouse2.buttons &= ~(1 << (ev->data1 - KEY_2MOUSE1)); + } + // Scroll (has no keyup event) + else switch (ev->data1) { + case KEY_MOUSEWHEELUP: + mouse.buttons |= MB_SCROLLUP; + break; + case KEY_MOUSEWHEELDOWN: + mouse.buttons |= MB_SCROLLDOWN; + break; + case KEY_2MOUSEWHEELUP: + mouse2.buttons |= MB_SCROLLUP; + break; + case KEY_2MOUSEWHEELDOWN: + mouse2.buttons |= MB_SCROLLDOWN; + break; + } + } + // Screenshots over everything so that they can be taken anywhere. if (M_ScreenshotResponder(ev)) continue; // ate the event @@ -242,9 +279,9 @@ void D_ProcessEvents(void) } if (mouse.rdx || mouse.rdy) - G_SetMouseData(mouse.rdx, mouse.rdy, 1); + G_SetMouseDeltas(mouse.rdx, mouse.rdy, 1); if (mouse2.rdx || mouse2.rdy) - G_SetMouseData(mouse2.rdx, mouse2.rdy, 2); + G_SetMouseDeltas(mouse2.rdx, mouse2.rdy, 2); } // diff --git a/src/deh_tables.c b/src/deh_tables.c index 7bfe723da..79f0d1f11 100644 --- a/src/deh_tables.c +++ b/src/deh_tables.c @@ -23,6 +23,7 @@ #include "i_sound.h" // musictype_t (for lua) #include "g_state.h" // gamestate_t (for lua) #include "g_game.h" // Joystick axes (for lua) +#include "i_joy.h" #include "g_input.h" // Game controls (for lua) #include "deh_tables.h" @@ -5468,6 +5469,7 @@ struct int_const_s const INT_CONST[] = { {"JA_SPIN",JA_SPIN}, {"JA_FIRE",JA_FIRE}, {"JA_FIRENORMAL",JA_FIRENORMAL}, + {"JOYAXISRANGE",JOYAXISRANGE}, // Game controls {"gc_null",gc_null}, @@ -5514,6 +5516,18 @@ struct int_const_s const INT_CONST[] = { {"gc_custom3",gc_custom3}, {"num_gamecontrols",num_gamecontrols}, + // Mouse buttons + {"MB_BUTTON1",MB_BUTTON1}, + {"MB_BUTTON2",MB_BUTTON2}, + {"MB_BUTTON3",MB_BUTTON3}, + {"MB_BUTTON4",MB_BUTTON4}, + {"MB_BUTTON5",MB_BUTTON5}, + {"MB_BUTTON6",MB_BUTTON6}, + {"MB_BUTTON7",MB_BUTTON7}, + {"MB_BUTTON8",MB_BUTTON8}, + {"MB_SCROLLUP",MB_SCROLLUP}, + {"MB_SCROLLDOWN",MB_SCROLLDOWN}, + {NULL,0} }; diff --git a/src/g_game.c b/src/g_game.c index 823ea7c56..a7fbbd92f 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1078,7 +1078,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) angle_t drawangleoffset = (player->powers[pw_carry] == CR_ROLLOUT) ? ANGLE_180 : 0; INT32 chasecam, chasefreelook, alwaysfreelook, usejoystick, invertmouse, turnmultiplier, mousemove; controlstyle_e controlstyle = G_ControlStyle(ssplayer); - mouse_t *m = &mouse; + INT32 mdx, mdy, mldy; static INT32 turnheld[2]; // for accelerative turning static boolean keyboard_look[2]; // true if lookup/down using keyboard @@ -1101,6 +1101,9 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) invertmouse = cv_invertmouse.value; turnmultiplier = cv_cam_turnmultiplier.value; mousemove = cv_mousemove.value; + mdx = mouse.dx; + mdy = -mouse.dy; + mldy = -mouse.mlookdy; G_CopyTiccmd(cmd, I_BaseTiccmd(), 1); // empty, or external driver } else @@ -1112,10 +1115,15 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) invertmouse = cv_invertmouse2.value; turnmultiplier = cv_cam2_turnmultiplier.value; mousemove = cv_mousemove2.value; - m = &mouse2; + mdx = mouse2.dx; + mdy = -mouse2.dy; + mldy = -mouse2.mlookdy; G_CopyTiccmd(cmd, I_BaseTiccmd2(), 1); // empty, or external driver } + if (menuactive || CON_Ready() || chat_on) + mdx = mdy = mldy = 0; + strafeisturn = controlstyle == CS_SIMPLE && ticcmd_centerviewdown[forplayer] && ((cv_cam_lockedinput[forplayer].value && !ticcmd_ztargetfocus[forplayer]) || (player->pflags & PF_STARTDASH)) && !player->climbing && player->powers[pw_carry] != CR_MINECART; @@ -1455,7 +1463,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) keyboard_look[forplayer] = false; // looking up/down - *myaiming += (m->mlookdy<<19)*player_invert*screen_invert; + *myaiming += (mldy<<19)*player_invert*screen_invert; } if (analogjoystickmove && joyaiming[forplayer] && lookjoystickvector.yaxis != 0 && configlookaxis != 0) @@ -1489,22 +1497,22 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) } if (!mouseaiming && mousemove) - forward += m->dy; + forward += mdy; if ((!demoplayback && (player->pflags & PF_SLIDING))) // Analog for mouse - side += m->dx*2; + side += mdx*2; else if (controlstyle == CS_LMAOGALOG) { - if (m->dx) + if (mdx) { - if (m->dx > 0) + if (mdx > 0) cmd->buttons |= BT_CAMRIGHT; else cmd->buttons |= BT_CAMLEFT; } } else - cmd->angleturn = (INT16)(cmd->angleturn - (m->dx*8)); + cmd->angleturn = (INT16)(cmd->angleturn - (mdx*8)); if (forward > MAXPLMOVE) forward = MAXPLMOVE; @@ -1850,8 +1858,8 @@ void G_DoLoadLevel(boolean resetplayer) joyxmove[i] = joyymove[i] = 0; joy2xmove[i] = joy2ymove[i] = 0; } - G_SetMouseData(0, 0, 1); - G_SetMouseData(0, 0, 2); + G_SetMouseDeltas(0, 0, 1); + G_SetMouseDeltas(0, 0, 2); // clear hud messages remains (usually from game startup) CON_ClearHUD(); @@ -3082,8 +3090,8 @@ void G_DoReborn(INT32 playernum) joyxmove[i] = joyymove[i] = 0; joy2xmove[i] = joy2ymove[i] = 0; } - G_SetMouseData(0, 0, 1); - G_SetMouseData(0, 0, 2); + G_SetMouseDeltas(0, 0, 1); + G_SetMouseDeltas(0, 0, 2); // clear hud messages remains (usually from game startup) CON_ClearHUD(); diff --git a/src/g_input.c b/src/g_input.c index 629b389e5..3e8df9eb0 100644 --- a/src/g_input.c +++ b/src/g_input.c @@ -138,8 +138,6 @@ void G_MapEventsToControls(event_t *ev) break; case ev_mouse: // buttons are virtual keys - if (menuactive || CON_Ready() || chat_on) - break; mouse.rdx = ev->data2; mouse.rdy = ev->data3; break; @@ -1070,19 +1068,15 @@ void Command_Setcontrol2_f(void) setcontrol(gamecontrolbis); } -void G_SetMouseData(INT32 realdx, INT32 realdy, UINT8 ssplayer) +void G_SetMouseDeltas(INT32 dx, INT32 dy, UINT8 ssplayer) { mouse_t *m = ssplayer == 1 ? &mouse : &mouse2; consvar_t *cvsens, *cvysens; - if (!realdx && !realdy) { - memset(m, 0, sizeof(*m)); - return; - } cvsens = ssplayer == 1 ? &cv_mousesens : &cv_mousesens2; cvysens = ssplayer == 1 ? &cv_mouseysens : &cv_mouseysens2; - m->rdx = realdx; - m->rdy = realdy; + m->rdx = dx; + m->rdy = dy; m->dx = (INT32)(m->rdx*((cvsens->value*cvsens->value)/110.0f + 0.1f)); m->dy = (INT32)(m->rdy*((cvsens->value*cvsens->value)/110.0f + 0.1f)); m->mlookdy = (INT32)(m->rdy*((cvysens->value*cvsens->value)/110.0f + 0.1f)); diff --git a/src/g_input.h b/src/g_input.h index 96139e751..6127050ed 100644 --- a/src/g_input.h +++ b/src/g_input.h @@ -123,8 +123,20 @@ typedef struct INT32 mlookdy; // dy with mouselook sensitivity INT32 rdx; // deltas without sensitivity INT32 rdy; + UINT16 buttons; } mouse_t; +#define MB_BUTTON1 0x0001 +#define MB_BUTTON2 0x0002 +#define MB_BUTTON3 0x0004 +#define MB_BUTTON4 0x0008 +#define MB_BUTTON5 0x0010 +#define MB_BUTTON6 0x0020 +#define MB_BUTTON7 0x0040 +#define MB_BUTTON8 0x0080 +#define MB_SCROLLUP 0x0100 +#define MB_SCROLLDOWN 0x0200 + extern mouse_t mouse; extern mouse_t mouse2; @@ -184,6 +196,6 @@ void G_SaveKeySetting(FILE *f, INT32 (*fromcontrols)[2], INT32 (*fromcontrolsbis INT32 G_CheckDoubleUsage(INT32 keynum, boolean modify); // sets the members of a mouse_t given position deltas -void G_SetMouseData(INT32 realdx, INT32 realdy, UINT8 ssplayer); +void G_SetMouseDeltas(INT32 dx, INT32 dy, UINT8 ssplayer); #endif diff --git a/src/i_system.h b/src/i_system.h index 12f0d751d..787be88ee 100644 --- a/src/i_system.h +++ b/src/i_system.h @@ -314,4 +314,16 @@ const char *I_ClipboardPaste(void); void I_RegisterSysCommands(void); +/** \brief Return the position of the cursor relative to the top-left window corner. +*/ +void I_GetCursorPosition(INT32 *x, INT32 *y); + +/** \brief Retursn whether the mouse is grabbed +*/ +boolean I_GetMouseGrab(void); + +/** \brief Sets whether the mouse is grabbed +*/ +void I_SetMouseGrab(boolean grab); + #endif diff --git a/src/lua_inputlib.c b/src/lua_inputlib.c index 1b5991e57..217202222 100644 --- a/src/lua_inputlib.c +++ b/src/lua_inputlib.c @@ -14,6 +14,7 @@ #include "g_input.h" #include "g_game.h" #include "hu_stuff.h" +#include "i_system.h" #include "lua_script.h" #include "lua_libs.h" @@ -103,6 +104,28 @@ static int lib_shiftKeyNum(lua_State *L) return 1; } +static int lib_getMouseGrab(lua_State *L) +{ + lua_pushboolean(L, I_GetMouseGrab()); + return 1; +} + +static int lib_setMouseGrab(lua_State *L) +{ + boolean grab = luaL_checkboolean(L, 1); + I_SetMouseGrab(grab); + return 0; +} + +static boolean lib_getCursorPosition(lua_State *L) +{ + int x, y; + I_GetCursorPosition(&x, &y); + lua_pushinteger(L, x); + lua_pushinteger(L, y); + return 2; +} + static luaL_Reg lib[] = { {"G_GameControlDown", lib_gameControlDown}, {"G_GameControl2Down", lib_gameControl2Down}, @@ -114,6 +137,9 @@ static luaL_Reg lib[] = { {"G_KeyStringToNum", lib_keyStringToNum}, {"HU_KeyNumPrintable", lib_keyNumPrintable}, {"HU_ShiftKeyNum", lib_shiftKeyNum}, + {"I_GetMouseGrab", lib_getMouseGrab}, + {"I_SetMouseGrab", lib_setMouseGrab}, + {"I_GetCursorPosition", lib_getCursorPosition}, {NULL, NULL} }; @@ -167,6 +193,8 @@ static int mouse_get(lua_State *L) lua_pushinteger(L, m->rdx); else if (fastcmp(field,"rdy")) lua_pushinteger(L, m->rdy); + else if (fastcmp(field,"buttons")) + lua_pushinteger(L, m->buttons); else return luaL_error(L, "mouse_t has no field named %s", field); diff --git a/src/m_menu.c b/src/m_menu.c index fffe08cd2..cc495c122 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -3305,7 +3305,7 @@ boolean M_Responder(event_t *ev) } else if (ev->type == ev_mouse && mousewait < I_GetTime()) { - pmousey += ev->data3; + pmousey -= ev->data3; if (pmousey < lasty-30) { ch = KEY_DOWNARROW; diff --git a/src/sdl/i_system.c b/src/sdl/i_system.c index a0dd6e1da..bd9d3d9a3 100644 --- a/src/sdl/i_system.c +++ b/src/sdl/i_system.c @@ -1969,7 +1969,7 @@ void I_GetMouseEvents(void) event.data1 = 0; // event.data1 = buttons; // not needed event.data2 = handlermouse2x << 1; - event.data3 = -handlermouse2y << 1; + event.data3 = handlermouse2y << 1; handlermouse2x = 0; handlermouse2y = 0; diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index 0ed10463f..20f2c8869 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -405,6 +405,19 @@ void I_UpdateMouseGrab(void) SDLdoGrabMouse(); } +boolean I_GetMouseGrab(void) +{ + return SDL_GetWindowGrab(window); +} + +void I_SetMouseGrab(boolean grab) +{ + if (grab) + SDLdoGrabMouse(); + else + SDLdoUngrabMouse(); +} + static void VID_Command_NumModes_f (void) { CONS_Printf(M_GetText("%d video mode(s) available(s)\n"), VID_NumModes()); @@ -673,8 +686,8 @@ static void Impl_HandleMouseMotionEvent(SDL_MouseMotionEvent evt) { if (SDL_GetMouseFocus() == window && SDL_GetKeyboardFocus() == window) { - mousemovex += evt.xrel; - mousemovey += -evt.yrel; + mousemovex += evt.xrel; + mousemovey += evt.yrel; SDL_SetWindowGrab(window, SDL_TRUE); } firstmove = false; @@ -1938,3 +1951,8 @@ void I_ShutdownGraphics(void) framebuffer = SDL_FALSE; } #endif + +void I_GetCursorPosition(INT32 *x, INT32 *y) +{ + SDL_GetMouseState(x, y); +} From cb3a8f7a58d535f17a9b60166fcd2c9ced3a84cf Mon Sep 17 00:00:00 2001 From: SwitchKaze Date: Thu, 25 Mar 2021 22:21:53 -0500 Subject: [PATCH 0653/1080] Remove key stuff --- src/console.c | 4 +- src/d_main.c | 17 ------- src/deh_tables.c | 46 ------------------ src/g_game.c | 10 ---- src/g_game.h | 1 - src/g_input.c | 16 +++--- src/g_input.h | 4 +- src/lua_baselib.c | 2 +- src/lua_inputlib.c | 118 --------------------------------------------- src/m_menu.c | 4 +- 10 files changed, 15 insertions(+), 207 deletions(-) diff --git a/src/console.c b/src/console.c index 3b29e9c4f..121605b10 100644 --- a/src/console.c +++ b/src/console.c @@ -221,7 +221,7 @@ static void CONS_Bind_f(void) for (key = 0; key < NUMINPUTS; key++) if (bindtable[key]) { - CONS_Printf("%s : \"%s\"\n", G_KeyNumToString(key), bindtable[key]); + CONS_Printf("%s : \"%s\"\n", G_KeynumToString(key), bindtable[key]); na = 1; } if (!na) @@ -229,7 +229,7 @@ static void CONS_Bind_f(void) return; } - key = G_KeyStringToNum(COM_Argv(1)); + key = G_KeyStringtoNum(COM_Argv(1)); if (key <= 0 || key >= NUMINPUTS) { CONS_Alert(CONS_NOTICE, M_GetText("Invalid key name\n")); diff --git a/src/d_main.c b/src/d_main.c index 0d21d2531..9c95a2ac3 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -183,8 +183,6 @@ void D_ProcessEvents(void) for (; eventtail != eventhead; eventtail = (eventtail+1) & (MAXEVENTS-1)) { - boolean hooked = false; - ev = &events[eventtail]; // Set mouse buttons early in case event is eaten later @@ -232,12 +230,6 @@ void D_ProcessEvents(void) continue; } - if (!CON_Ready() && !menuactive) { - if (G_LuaResponder(ev)) - continue; - hooked = true; - } - // Menu input #ifdef HAVE_THREADS I_lock_mutex(&m_menu_mutex); @@ -252,12 +244,6 @@ void D_ProcessEvents(void) if (eaten) continue; // menu ate the event - if (!hooked && !CON_Ready()) { - if (G_LuaResponder(ev)) - continue; - hooked = true; - } - // console input #ifdef HAVE_THREADS I_lock_mutex(&con_mutex); @@ -272,9 +258,6 @@ void D_ProcessEvents(void) if (eaten) continue; // ate the event - if (!hooked && G_LuaResponder(ev)) - continue; - G_Responder(ev); } diff --git a/src/deh_tables.c b/src/deh_tables.c index 79f0d1f11..4ff193dcd 100644 --- a/src/deh_tables.c +++ b/src/deh_tables.c @@ -24,7 +24,6 @@ #include "g_state.h" // gamestate_t (for lua) #include "g_game.h" // Joystick axes (for lua) #include "i_joy.h" -#include "g_input.h" // Game controls (for lua) #include "deh_tables.h" @@ -5471,51 +5470,6 @@ struct int_const_s const INT_CONST[] = { {"JA_FIRENORMAL",JA_FIRENORMAL}, {"JOYAXISRANGE",JOYAXISRANGE}, - // Game controls - {"gc_null",gc_null}, - {"gc_forward",gc_forward}, - {"gc_backward",gc_backward}, - {"gc_strafeleft",gc_strafeleft}, - {"gc_straferight",gc_straferight}, - {"gc_turnleft",gc_turnleft}, - {"gc_turnright",gc_turnright}, - {"gc_weaponnext",gc_weaponnext}, - {"gc_weaponprev",gc_weaponprev}, - {"gc_wepslot1",gc_wepslot1}, - {"gc_wepslot2",gc_wepslot2}, - {"gc_wepslot3",gc_wepslot3}, - {"gc_wepslot4",gc_wepslot4}, - {"gc_wepslot5",gc_wepslot5}, - {"gc_wepslot6",gc_wepslot6}, - {"gc_wepslot7",gc_wepslot7}, - {"gc_wepslot8",gc_wepslot8}, - {"gc_wepslot9",gc_wepslot9}, - {"gc_wepslot10",gc_wepslot10}, - {"gc_fire",gc_fire}, - {"gc_firenormal",gc_firenormal}, - {"gc_tossflag",gc_tossflag}, - {"gc_spin",gc_spin}, - {"gc_camtoggle",gc_camtoggle}, - {"gc_camreset",gc_camreset}, - {"gc_lookup",gc_lookup}, - {"gc_lookdown",gc_lookdown}, - {"gc_centerview",gc_centerview}, - {"gc_mouseaiming",gc_mouseaiming}, - {"gc_talkkey",gc_talkkey}, - {"gc_teamkey",gc_teamkey}, - {"gc_scores",gc_scores}, - {"gc_jump",gc_jump}, - {"gc_console",gc_console}, - {"gc_pause",gc_pause}, - {"gc_systemmenu",gc_systemmenu}, - {"gc_screenshot",gc_screenshot}, - {"gc_recordgif",gc_recordgif}, - {"gc_viewpoint",gc_viewpoint}, - {"gc_custom1",gc_custom1}, - {"gc_custom2",gc_custom2}, - {"gc_custom3",gc_custom3}, - {"num_gamecontrols",num_gamecontrols}, - // Mouse buttons {"MB_BUTTON1",MB_BUTTON1}, {"MB_BUTTON2",MB_BUTTON2}, diff --git a/src/g_game.c b/src/g_game.c index a7fbbd92f..1d8eed964 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -2183,16 +2183,6 @@ boolean G_Responder(event_t *ev) return false; } -// -// G_LuaResponder -// Let Lua handle key events. -// -boolean G_LuaResponder(event_t *ev) -{ - return (ev->type == ev_keydown && LUAh_KeyDown(ev->data1)) || - (ev->type == ev_keyup && LUAh_KeyUp(ev->data1)); -} - // // G_Ticker // Make ticcmd_ts for the players. diff --git a/src/g_game.h b/src/g_game.h index 0cc380294..ae93adf46 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -223,7 +223,6 @@ void G_EndGame(void); // moved from y_inter.c/h and renamed void G_Ticker(boolean run); boolean G_Responder(event_t *ev); -boolean G_LuaResponder(event_t *ev); void G_AddPlayer(INT32 playernum); diff --git a/src/g_input.c b/src/g_input.c index 3e8df9eb0..cc301e8e5 100644 --- a/src/g_input.c +++ b/src/g_input.c @@ -624,7 +624,7 @@ void G_ClearAllControlKeys(void) // Returns the name of a key (or virtual key for mouse and joy) // the input value being an keynum // -const char *G_KeyNumToString(INT32 keynum) +const char *G_KeynumToString(INT32 keynum) { static char keynamestr[8]; @@ -648,7 +648,7 @@ const char *G_KeyNumToString(INT32 keynum) return keynamestr; } -INT32 G_KeyStringToNum(const char *keystr) +INT32 G_KeyStringtoNum(const char *keystr) { UINT32 j; @@ -811,10 +811,10 @@ void G_SaveKeySetting(FILE *f, INT32 (*fromcontrols)[2], INT32 (*fromcontrolsbis for (i = 1; i < num_gamecontrols; i++) { fprintf(f, "setcontrol \"%s\" \"%s\"", gamecontrolname[i], - G_KeyNumToString(fromcontrols[i][0])); + G_KeynumToString(fromcontrols[i][0])); if (fromcontrols[i][1]) - fprintf(f, " \"%s\"\n", G_KeyNumToString(fromcontrols[i][1])); + fprintf(f, " \"%s\"\n", G_KeynumToString(fromcontrols[i][1])); else fprintf(f, "\n"); } @@ -822,10 +822,10 @@ void G_SaveKeySetting(FILE *f, INT32 (*fromcontrols)[2], INT32 (*fromcontrolsbis for (i = 1; i < num_gamecontrols; i++) { fprintf(f, "setcontrol2 \"%s\" \"%s\"", gamecontrolname[i], - G_KeyNumToString(fromcontrolsbis[i][0])); + G_KeynumToString(fromcontrolsbis[i][0])); if (fromcontrolsbis[i][1]) - fprintf(f, " \"%s\"\n", G_KeyNumToString(fromcontrolsbis[i][1])); + fprintf(f, " \"%s\"\n", G_KeynumToString(fromcontrolsbis[i][1])); else fprintf(f, "\n"); } @@ -1001,8 +1001,8 @@ static void setcontrol(INT32 (*gc)[2]) CONS_Printf(M_GetText("Control '%s' unknown\n"), namectrl); return; } - keynum1 = G_KeyStringToNum(COM_Argv(2)); - keynum2 = G_KeyStringToNum(COM_Argv(3)); + keynum1 = G_KeyStringtoNum(COM_Argv(2)); + keynum2 = G_KeyStringtoNum(COM_Argv(3)); keynum = G_FilterKeyByVersion(numctrl, 0, player, &keynum1, &keynum2, &nestedoverride); if (keynum >= 0) diff --git a/src/g_input.h b/src/g_input.h index 6127050ed..798d888cd 100644 --- a/src/g_input.h +++ b/src/g_input.h @@ -181,8 +181,8 @@ extern const INT32 gcl_jump_spin[num_gcl_jump_spin]; void G_MapEventsToControls(event_t *ev); // returns the name of a key -const char *G_KeyNumToString(INT32 keynum); -INT32 G_KeyStringToNum(const char *keystr); +const char *G_KeynumToString(INT32 keynum); +INT32 G_KeyStringtoNum(const char *keystr); // detach any keys associated to the given game control void G_ClearControlKeys(INT32 (*setupcontrols)[2], INT32 control); diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 71282d09c..6d4bde18d 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -212,7 +212,7 @@ static const struct { {META_ACTION, "action"}, {META_LUABANKS, "luabanks[]"}, - + {META_MOUSE, "mouse_t"}, {NULL, NULL} }; diff --git a/src/lua_inputlib.c b/src/lua_inputlib.c index 217202222..875c29e70 100644 --- a/src/lua_inputlib.c +++ b/src/lua_inputlib.c @@ -13,7 +13,6 @@ #include "fastcmp.h" #include "g_input.h" #include "g_game.h" -#include "hu_stuff.h" #include "i_system.h" #include "lua_script.h" @@ -23,44 +22,6 @@ // FUNCTIONS // /////////////// -static int lib_gameControlDown(lua_State *L) -{ - int i = luaL_checkinteger(L, 1); - if (i < 0 || i >= num_gamecontrols) - return luaL_error(L, "gc_* constant %d out of range (0 - %d)", i, num_gamecontrols-1); - lua_pushinteger(L, PLAYER1INPUTDOWN(i)); - return 1; -} - -static int lib_gameControl2Down(lua_State *L) -{ - int i = luaL_checkinteger(L, 1); - if (i < 0 || i >= num_gamecontrols) - return luaL_error(L, "gc_* constant %d out of range (0 - %d)", i, num_gamecontrols-1); - lua_pushinteger(L, PLAYER2INPUTDOWN(i)); - return 1; -} - -static int lib_gameControlToKeyNum(lua_State *L) -{ - int i = luaL_checkinteger(L, 1); - if (i < 0 || i >= num_gamecontrols) - return luaL_error(L, "gc_* constant %d out of range (0 - %d)", i, num_gamecontrols-1); - lua_pushinteger(L, gamecontrol[i][0]); - lua_pushinteger(L, gamecontrol[i][1]); - return 2; -} - -static int lib_gameControl2ToKeyNum(lua_State *L) -{ - int i = luaL_checkinteger(L, 1); - if (i < 0 || i >= num_gamecontrols) - return luaL_error(L, "gc_* constant %d out of range (0 - %d)", i, num_gamecontrols-1); - lua_pushinteger(L, gamecontrolbis[i][0]); - lua_pushinteger(L, gamecontrolbis[i][1]); - return 2; -} - static int lib_joyAxis(lua_State *L) { int i = luaL_checkinteger(L, 1); @@ -75,35 +36,6 @@ static int lib_joy2Axis(lua_State *L) return 1; } -static int lib_keyNumToString(lua_State *L) -{ - int i = luaL_checkinteger(L, 1); - lua_pushstring(L, G_KeyNumToString(i)); - return 1; -} - -static int lib_keyStringToNum(lua_State *L) -{ - const char *str = luaL_checkstring(L, 1); - lua_pushinteger(L, G_KeyStringToNum(str)); - return 1; -} - -static int lib_keyNumPrintable(lua_State *L) -{ - int i = luaL_checkinteger(L, 1); - lua_pushboolean(L, i >= 32 && i <= 127); - return 1; -} - -static int lib_shiftKeyNum(lua_State *L) -{ - int i = luaL_checkinteger(L, 1); - if (i >= 32 && i <= 127) - lua_pushinteger(L, shiftxform[i]); - return 1; -} - static int lib_getMouseGrab(lua_State *L) { lua_pushboolean(L, I_GetMouseGrab()); @@ -127,51 +59,14 @@ static boolean lib_getCursorPosition(lua_State *L) } static luaL_Reg lib[] = { - {"G_GameControlDown", lib_gameControlDown}, - {"G_GameControl2Down", lib_gameControl2Down}, - {"G_GameControlToKeyNum", lib_gameControlToKeyNum}, - {"G_GameControl2ToKeyNum", lib_gameControl2ToKeyNum}, {"G_JoyAxis", lib_joyAxis}, {"G_Joy2Axis", lib_joy2Axis}, - {"G_KeyNumToString", lib_keyNumToString}, - {"G_KeyStringToNum", lib_keyStringToNum}, - {"HU_KeyNumPrintable", lib_keyNumPrintable}, - {"HU_ShiftKeyNum", lib_shiftKeyNum}, {"I_GetMouseGrab", lib_getMouseGrab}, {"I_SetMouseGrab", lib_setMouseGrab}, {"I_GetCursorPosition", lib_getCursorPosition}, {NULL, NULL} }; -/////////////////// -// gamekeydown[] // -/////////////////// - -static int lib_getGameKeyDown(lua_State *L) -{ - int i = luaL_checkinteger(L, 2); - if (i < 0 || i >= NUMINPUTS) - return luaL_error(L, "gamekeydown[] index %d out of range (0 - %d)", i, NUMINPUTS-1); - lua_pushboolean(L, gamekeydown[i]); - return 1; -} - -static int lib_setGameKeyDown(lua_State *L) -{ - int i = luaL_checkinteger(L, 2); - boolean j = luaL_checkboolean(L, 3); - if (i < 0 || i >= NUMINPUTS) - return luaL_error(L, "gamekeydown[] index %d out of range (0 - %d)", i, NUMINPUTS-1); - gamekeydown[i] = j; - return 0; -} - -static int lib_lenGameKeyDown(lua_State *L) -{ - lua_pushinteger(L, NUMINPUTS); - return 1; -} - /////////// // MOUSE // /////////// @@ -214,19 +109,6 @@ static int mouse_num(lua_State *L) int LUA_InputLib(lua_State *L) { - lua_newuserdata(L, 0); - lua_createtable(L, 0, 2); - lua_pushcfunction(L, lib_getGameKeyDown); - lua_setfield(L, -2, "__index"); - - lua_pushcfunction(L, lib_setGameKeyDown); - lua_setfield(L, -2, "__newindex"); - - lua_pushcfunction(L, lib_lenGameKeyDown); - lua_setfield(L, -2, "__len"); - lua_setmetatable(L, -2); - lua_setglobal(L, "gamekeydown"); - luaL_newmetatable(L, META_MOUSE); lua_pushcfunction(L, mouse_get); lua_setfield(L, -2, "__index"); diff --git a/src/m_menu.c b/src/m_menu.c index cc495c122..be7fa8a7d 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -12683,13 +12683,13 @@ static void M_DrawControl(void) else { if (keys[0] != KEY_NULL) - strcat (tmp, G_KeyNumToString (keys[0])); + strcat (tmp, G_KeynumToString (keys[0])); if (keys[0] != KEY_NULL && keys[1] != KEY_NULL) strcat(tmp," or "); if (keys[1] != KEY_NULL) - strcat (tmp, G_KeyNumToString (keys[1])); + strcat (tmp, G_KeynumToString (keys[1])); } From 5a247bf375b7b1c973a52d702c37cf48de628fea Mon Sep 17 00:00:00 2001 From: SwitchKaze Date: Thu, 25 Mar 2021 23:29:42 -0500 Subject: [PATCH 0654/1080] Fix typo in comment of I_GetMouseGrab --- src/i_system.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/i_system.h b/src/i_system.h index 787be88ee..3f46eb592 100644 --- a/src/i_system.h +++ b/src/i_system.h @@ -318,7 +318,7 @@ void I_RegisterSysCommands(void); */ void I_GetCursorPosition(INT32 *x, INT32 *y); -/** \brief Retursn whether the mouse is grabbed +/** \brief Returns whether the mouse is grabbed */ boolean I_GetMouseGrab(void); From 0db07cef0ebac2f4d006094fe1b99b061bedfd57 Mon Sep 17 00:00:00 2001 From: SwitchKaze Date: Fri, 26 Mar 2021 02:03:52 -0500 Subject: [PATCH 0655/1080] Adjust joystick axis enum --- src/g_game.c | 4 ++-- src/g_game.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index 1d8eed964..d8b615cbc 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -887,7 +887,7 @@ INT32 JoyAxis(joyaxis_e axissel) if (retaxis > (+JOYAXISRANGE)) retaxis = +JOYAXISRANGE; - if (!Joystick.bGamepadStyle && axissel > JA_DIGITAL) + if (!Joystick.bGamepadStyle && axissel >= JA_DIGITAL) { const INT32 jdeadzone = ((JOYAXISRANGE-1) * cv_digitaldeadzone.value) >> FRACBITS; if (-jdeadzone < retaxis && retaxis < jdeadzone) @@ -962,7 +962,7 @@ INT32 Joy2Axis(joyaxis_e axissel) if (retaxis > (+JOYAXISRANGE)) retaxis = +JOYAXISRANGE; - if (!Joystick2.bGamepadStyle && axissel > JA_DIGITAL) + if (!Joystick2.bGamepadStyle && axissel >= JA_DIGITAL) { const INT32 jdeadzone = ((JOYAXISRANGE-1) * cv_digitaldeadzone2.value) >> FRACBITS; if (-jdeadzone < retaxis && retaxis < jdeadzone) diff --git a/src/g_game.h b/src/g_game.h index ae93adf46..c7fdad3ac 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -93,9 +93,9 @@ typedef enum JA_LOOK, JA_STRAFE, - JA_DIGITAL, // axes below this use digital deadzone + JA_DIGITAL, // axes henceforth use digital deadzone - JA_JUMP, + JA_JUMP = JA_DIGITAL, JA_SPIN, JA_FIRE, JA_FIRENORMAL, From 3895c023308c0ff71194531ce071860ad40764ae Mon Sep 17 00:00:00 2001 From: SwitchKaze Date: Thu, 1 Apr 2021 13:19:50 -0500 Subject: [PATCH 0656/1080] Revert "Remove key stuff" This reverts commit a439e569 --- src/console.c | 4 +- src/d_main.c | 17 +++++++ src/deh_tables.c | 46 ++++++++++++++++++ src/g_game.c | 10 ++++ src/g_game.h | 1 + src/g_input.c | 16 +++--- src/g_input.h | 4 +- src/lua_hooklib.c | 2 +- src/lua_inputlib.c | 118 +++++++++++++++++++++++++++++++++++++++++++++ src/m_menu.c | 4 +- 10 files changed, 207 insertions(+), 15 deletions(-) diff --git a/src/console.c b/src/console.c index 121605b10..3b29e9c4f 100644 --- a/src/console.c +++ b/src/console.c @@ -221,7 +221,7 @@ static void CONS_Bind_f(void) for (key = 0; key < NUMINPUTS; key++) if (bindtable[key]) { - CONS_Printf("%s : \"%s\"\n", G_KeynumToString(key), bindtable[key]); + CONS_Printf("%s : \"%s\"\n", G_KeyNumToString(key), bindtable[key]); na = 1; } if (!na) @@ -229,7 +229,7 @@ static void CONS_Bind_f(void) return; } - key = G_KeyStringtoNum(COM_Argv(1)); + key = G_KeyStringToNum(COM_Argv(1)); if (key <= 0 || key >= NUMINPUTS) { CONS_Alert(CONS_NOTICE, M_GetText("Invalid key name\n")); diff --git a/src/d_main.c b/src/d_main.c index 9c95a2ac3..0d21d2531 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -183,6 +183,8 @@ void D_ProcessEvents(void) for (; eventtail != eventhead; eventtail = (eventtail+1) & (MAXEVENTS-1)) { + boolean hooked = false; + ev = &events[eventtail]; // Set mouse buttons early in case event is eaten later @@ -230,6 +232,12 @@ void D_ProcessEvents(void) continue; } + if (!CON_Ready() && !menuactive) { + if (G_LuaResponder(ev)) + continue; + hooked = true; + } + // Menu input #ifdef HAVE_THREADS I_lock_mutex(&m_menu_mutex); @@ -244,6 +252,12 @@ void D_ProcessEvents(void) if (eaten) continue; // menu ate the event + if (!hooked && !CON_Ready()) { + if (G_LuaResponder(ev)) + continue; + hooked = true; + } + // console input #ifdef HAVE_THREADS I_lock_mutex(&con_mutex); @@ -258,6 +272,9 @@ void D_ProcessEvents(void) if (eaten) continue; // ate the event + if (!hooked && G_LuaResponder(ev)) + continue; + G_Responder(ev); } diff --git a/src/deh_tables.c b/src/deh_tables.c index 4ff193dcd..79f0d1f11 100644 --- a/src/deh_tables.c +++ b/src/deh_tables.c @@ -24,6 +24,7 @@ #include "g_state.h" // gamestate_t (for lua) #include "g_game.h" // Joystick axes (for lua) #include "i_joy.h" +#include "g_input.h" // Game controls (for lua) #include "deh_tables.h" @@ -5470,6 +5471,51 @@ struct int_const_s const INT_CONST[] = { {"JA_FIRENORMAL",JA_FIRENORMAL}, {"JOYAXISRANGE",JOYAXISRANGE}, + // Game controls + {"gc_null",gc_null}, + {"gc_forward",gc_forward}, + {"gc_backward",gc_backward}, + {"gc_strafeleft",gc_strafeleft}, + {"gc_straferight",gc_straferight}, + {"gc_turnleft",gc_turnleft}, + {"gc_turnright",gc_turnright}, + {"gc_weaponnext",gc_weaponnext}, + {"gc_weaponprev",gc_weaponprev}, + {"gc_wepslot1",gc_wepslot1}, + {"gc_wepslot2",gc_wepslot2}, + {"gc_wepslot3",gc_wepslot3}, + {"gc_wepslot4",gc_wepslot4}, + {"gc_wepslot5",gc_wepslot5}, + {"gc_wepslot6",gc_wepslot6}, + {"gc_wepslot7",gc_wepslot7}, + {"gc_wepslot8",gc_wepslot8}, + {"gc_wepslot9",gc_wepslot9}, + {"gc_wepslot10",gc_wepslot10}, + {"gc_fire",gc_fire}, + {"gc_firenormal",gc_firenormal}, + {"gc_tossflag",gc_tossflag}, + {"gc_spin",gc_spin}, + {"gc_camtoggle",gc_camtoggle}, + {"gc_camreset",gc_camreset}, + {"gc_lookup",gc_lookup}, + {"gc_lookdown",gc_lookdown}, + {"gc_centerview",gc_centerview}, + {"gc_mouseaiming",gc_mouseaiming}, + {"gc_talkkey",gc_talkkey}, + {"gc_teamkey",gc_teamkey}, + {"gc_scores",gc_scores}, + {"gc_jump",gc_jump}, + {"gc_console",gc_console}, + {"gc_pause",gc_pause}, + {"gc_systemmenu",gc_systemmenu}, + {"gc_screenshot",gc_screenshot}, + {"gc_recordgif",gc_recordgif}, + {"gc_viewpoint",gc_viewpoint}, + {"gc_custom1",gc_custom1}, + {"gc_custom2",gc_custom2}, + {"gc_custom3",gc_custom3}, + {"num_gamecontrols",num_gamecontrols}, + // Mouse buttons {"MB_BUTTON1",MB_BUTTON1}, {"MB_BUTTON2",MB_BUTTON2}, diff --git a/src/g_game.c b/src/g_game.c index d8b615cbc..5939cfe3b 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -2183,6 +2183,16 @@ boolean G_Responder(event_t *ev) return false; } +// +// G_LuaResponder +// Let Lua handle key events. +// +boolean G_LuaResponder(event_t *ev) +{ + return (ev->type == ev_keydown && LUAh_KeyDown(ev->data1)) || + (ev->type == ev_keyup && LUAh_KeyUp(ev->data1)); +} + // // G_Ticker // Make ticcmd_ts for the players. diff --git a/src/g_game.h b/src/g_game.h index c7fdad3ac..00958abd0 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -223,6 +223,7 @@ void G_EndGame(void); // moved from y_inter.c/h and renamed void G_Ticker(boolean run); boolean G_Responder(event_t *ev); +boolean G_LuaResponder(event_t *ev); void G_AddPlayer(INT32 playernum); diff --git a/src/g_input.c b/src/g_input.c index cc301e8e5..3e8df9eb0 100644 --- a/src/g_input.c +++ b/src/g_input.c @@ -624,7 +624,7 @@ void G_ClearAllControlKeys(void) // Returns the name of a key (or virtual key for mouse and joy) // the input value being an keynum // -const char *G_KeynumToString(INT32 keynum) +const char *G_KeyNumToString(INT32 keynum) { static char keynamestr[8]; @@ -648,7 +648,7 @@ const char *G_KeynumToString(INT32 keynum) return keynamestr; } -INT32 G_KeyStringtoNum(const char *keystr) +INT32 G_KeyStringToNum(const char *keystr) { UINT32 j; @@ -811,10 +811,10 @@ void G_SaveKeySetting(FILE *f, INT32 (*fromcontrols)[2], INT32 (*fromcontrolsbis for (i = 1; i < num_gamecontrols; i++) { fprintf(f, "setcontrol \"%s\" \"%s\"", gamecontrolname[i], - G_KeynumToString(fromcontrols[i][0])); + G_KeyNumToString(fromcontrols[i][0])); if (fromcontrols[i][1]) - fprintf(f, " \"%s\"\n", G_KeynumToString(fromcontrols[i][1])); + fprintf(f, " \"%s\"\n", G_KeyNumToString(fromcontrols[i][1])); else fprintf(f, "\n"); } @@ -822,10 +822,10 @@ void G_SaveKeySetting(FILE *f, INT32 (*fromcontrols)[2], INT32 (*fromcontrolsbis for (i = 1; i < num_gamecontrols; i++) { fprintf(f, "setcontrol2 \"%s\" \"%s\"", gamecontrolname[i], - G_KeynumToString(fromcontrolsbis[i][0])); + G_KeyNumToString(fromcontrolsbis[i][0])); if (fromcontrolsbis[i][1]) - fprintf(f, " \"%s\"\n", G_KeynumToString(fromcontrolsbis[i][1])); + fprintf(f, " \"%s\"\n", G_KeyNumToString(fromcontrolsbis[i][1])); else fprintf(f, "\n"); } @@ -1001,8 +1001,8 @@ static void setcontrol(INT32 (*gc)[2]) CONS_Printf(M_GetText("Control '%s' unknown\n"), namectrl); return; } - keynum1 = G_KeyStringtoNum(COM_Argv(2)); - keynum2 = G_KeyStringtoNum(COM_Argv(3)); + keynum1 = G_KeyStringToNum(COM_Argv(2)); + keynum2 = G_KeyStringToNum(COM_Argv(3)); keynum = G_FilterKeyByVersion(numctrl, 0, player, &keynum1, &keynum2, &nestedoverride); if (keynum >= 0) diff --git a/src/g_input.h b/src/g_input.h index 798d888cd..6127050ed 100644 --- a/src/g_input.h +++ b/src/g_input.h @@ -181,8 +181,8 @@ extern const INT32 gcl_jump_spin[num_gcl_jump_spin]; void G_MapEventsToControls(event_t *ev); // returns the name of a key -const char *G_KeynumToString(INT32 keynum); -INT32 G_KeyStringtoNum(const char *keystr); +const char *G_KeyNumToString(INT32 keynum); +INT32 G_KeyStringToNum(const char *keystr); // detach any keys associated to the given game control void G_ClearControlKeys(INT32 (*setupcontrols)[2], INT32 control); diff --git a/src/lua_hooklib.c b/src/lua_hooklib.c index 8a7ce2cb9..28ae487b9 100644 --- a/src/lua_hooklib.c +++ b/src/lua_hooklib.c @@ -1944,7 +1944,7 @@ boolean LUAh_MusicChange(const char *oldname, char *newname, UINT16 *mflags, boo lua_pushinteger(gL, *prefadems); lua_pushinteger(gL, *fadeinms); if (lua_pcall(gL, 7, 6, 1)) { - CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL,-1)); + CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); lua_pop(gL, 1); continue; } diff --git a/src/lua_inputlib.c b/src/lua_inputlib.c index 875c29e70..217202222 100644 --- a/src/lua_inputlib.c +++ b/src/lua_inputlib.c @@ -13,6 +13,7 @@ #include "fastcmp.h" #include "g_input.h" #include "g_game.h" +#include "hu_stuff.h" #include "i_system.h" #include "lua_script.h" @@ -22,6 +23,44 @@ // FUNCTIONS // /////////////// +static int lib_gameControlDown(lua_State *L) +{ + int i = luaL_checkinteger(L, 1); + if (i < 0 || i >= num_gamecontrols) + return luaL_error(L, "gc_* constant %d out of range (0 - %d)", i, num_gamecontrols-1); + lua_pushinteger(L, PLAYER1INPUTDOWN(i)); + return 1; +} + +static int lib_gameControl2Down(lua_State *L) +{ + int i = luaL_checkinteger(L, 1); + if (i < 0 || i >= num_gamecontrols) + return luaL_error(L, "gc_* constant %d out of range (0 - %d)", i, num_gamecontrols-1); + lua_pushinteger(L, PLAYER2INPUTDOWN(i)); + return 1; +} + +static int lib_gameControlToKeyNum(lua_State *L) +{ + int i = luaL_checkinteger(L, 1); + if (i < 0 || i >= num_gamecontrols) + return luaL_error(L, "gc_* constant %d out of range (0 - %d)", i, num_gamecontrols-1); + lua_pushinteger(L, gamecontrol[i][0]); + lua_pushinteger(L, gamecontrol[i][1]); + return 2; +} + +static int lib_gameControl2ToKeyNum(lua_State *L) +{ + int i = luaL_checkinteger(L, 1); + if (i < 0 || i >= num_gamecontrols) + return luaL_error(L, "gc_* constant %d out of range (0 - %d)", i, num_gamecontrols-1); + lua_pushinteger(L, gamecontrolbis[i][0]); + lua_pushinteger(L, gamecontrolbis[i][1]); + return 2; +} + static int lib_joyAxis(lua_State *L) { int i = luaL_checkinteger(L, 1); @@ -36,6 +75,35 @@ static int lib_joy2Axis(lua_State *L) return 1; } +static int lib_keyNumToString(lua_State *L) +{ + int i = luaL_checkinteger(L, 1); + lua_pushstring(L, G_KeyNumToString(i)); + return 1; +} + +static int lib_keyStringToNum(lua_State *L) +{ + const char *str = luaL_checkstring(L, 1); + lua_pushinteger(L, G_KeyStringToNum(str)); + return 1; +} + +static int lib_keyNumPrintable(lua_State *L) +{ + int i = luaL_checkinteger(L, 1); + lua_pushboolean(L, i >= 32 && i <= 127); + return 1; +} + +static int lib_shiftKeyNum(lua_State *L) +{ + int i = luaL_checkinteger(L, 1); + if (i >= 32 && i <= 127) + lua_pushinteger(L, shiftxform[i]); + return 1; +} + static int lib_getMouseGrab(lua_State *L) { lua_pushboolean(L, I_GetMouseGrab()); @@ -59,14 +127,51 @@ static boolean lib_getCursorPosition(lua_State *L) } static luaL_Reg lib[] = { + {"G_GameControlDown", lib_gameControlDown}, + {"G_GameControl2Down", lib_gameControl2Down}, + {"G_GameControlToKeyNum", lib_gameControlToKeyNum}, + {"G_GameControl2ToKeyNum", lib_gameControl2ToKeyNum}, {"G_JoyAxis", lib_joyAxis}, {"G_Joy2Axis", lib_joy2Axis}, + {"G_KeyNumToString", lib_keyNumToString}, + {"G_KeyStringToNum", lib_keyStringToNum}, + {"HU_KeyNumPrintable", lib_keyNumPrintable}, + {"HU_ShiftKeyNum", lib_shiftKeyNum}, {"I_GetMouseGrab", lib_getMouseGrab}, {"I_SetMouseGrab", lib_setMouseGrab}, {"I_GetCursorPosition", lib_getCursorPosition}, {NULL, NULL} }; +/////////////////// +// gamekeydown[] // +/////////////////// + +static int lib_getGameKeyDown(lua_State *L) +{ + int i = luaL_checkinteger(L, 2); + if (i < 0 || i >= NUMINPUTS) + return luaL_error(L, "gamekeydown[] index %d out of range (0 - %d)", i, NUMINPUTS-1); + lua_pushboolean(L, gamekeydown[i]); + return 1; +} + +static int lib_setGameKeyDown(lua_State *L) +{ + int i = luaL_checkinteger(L, 2); + boolean j = luaL_checkboolean(L, 3); + if (i < 0 || i >= NUMINPUTS) + return luaL_error(L, "gamekeydown[] index %d out of range (0 - %d)", i, NUMINPUTS-1); + gamekeydown[i] = j; + return 0; +} + +static int lib_lenGameKeyDown(lua_State *L) +{ + lua_pushinteger(L, NUMINPUTS); + return 1; +} + /////////// // MOUSE // /////////// @@ -109,6 +214,19 @@ static int mouse_num(lua_State *L) int LUA_InputLib(lua_State *L) { + lua_newuserdata(L, 0); + lua_createtable(L, 0, 2); + lua_pushcfunction(L, lib_getGameKeyDown); + lua_setfield(L, -2, "__index"); + + lua_pushcfunction(L, lib_setGameKeyDown); + lua_setfield(L, -2, "__newindex"); + + lua_pushcfunction(L, lib_lenGameKeyDown); + lua_setfield(L, -2, "__len"); + lua_setmetatable(L, -2); + lua_setglobal(L, "gamekeydown"); + luaL_newmetatable(L, META_MOUSE); lua_pushcfunction(L, mouse_get); lua_setfield(L, -2, "__index"); diff --git a/src/m_menu.c b/src/m_menu.c index be7fa8a7d..cc495c122 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -12683,13 +12683,13 @@ static void M_DrawControl(void) else { if (keys[0] != KEY_NULL) - strcat (tmp, G_KeynumToString (keys[0])); + strcat (tmp, G_KeyNumToString (keys[0])); if (keys[0] != KEY_NULL && keys[1] != KEY_NULL) strcat(tmp," or "); if (keys[1] != KEY_NULL) - strcat (tmp, G_KeynumToString (keys[1])); + strcat (tmp, G_KeyNumToString (keys[1])); } From 57c7a18a20b3049a47bc4bf6a3cc8fc678085e6f Mon Sep 17 00:00:00 2001 From: katsy Date: Fri, 2 Apr 2021 20:50:56 -0400 Subject: [PATCH 0657/1080] don't say we launched if we didn't actually launch --- src/p_slopes.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/p_slopes.c b/src/p_slopes.c index e93b0f6c9..bd0f15d2e 100644 --- a/src/p_slopes.c +++ b/src/p_slopes.c @@ -777,13 +777,13 @@ void P_SlopeLaunch(mobj_t *mo) mo->momx = slopemom.x; mo->momy = slopemom.y; mo->momz = slopemom.z/2; + + if (mo->player) + mo->player->powers[pw_justlaunched] = 1; } //CONS_Printf("Launched off of slope.\n"); mo->standingslope = NULL; - - if (mo->player) - mo->player->powers[pw_justlaunched] = 1; } // From e9213b2b41fd60b2331ccad987409786fd337499 Mon Sep 17 00:00:00 2001 From: Hannu Hanhi Date: Sun, 4 Apr 2021 21:29:15 +0300 Subject: [PATCH 0658/1080] Fix a OpenGL backend DeleteTexture crash --- src/hardware/r_opengl/r_opengl.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index 6967bab74..064457c03 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -1301,8 +1301,12 @@ EXPORT void HWRAPI(DeleteTexture) (GLMipmap_t *pTexInfo) { if (head->next) head->next->prev = head->prev; + else // no next -> tail is being deleted -> update TexCacheTail + TexCacheTail = head->prev; if (head->prev) head->prev->next = head->next; + else // no prev -> head is being deleted -> update TexCacheHead + TexCacheHead = head->next; free(head); break; } From 84191252d2c5116b19fc17066e9e313fefa47223 Mon Sep 17 00:00:00 2001 From: James R Date: Sun, 4 Apr 2021 17:01:54 -0700 Subject: [PATCH 0659/1080] Remove code that converts uppercase letters to lower, when coming from dedicated console --- src/console.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/console.c b/src/console.c index 121605b10..1560220f6 100644 --- a/src/console.c +++ b/src/console.c @@ -1303,10 +1303,6 @@ boolean CON_Responder(event_t *ev) if (key < 32 || key > 127) return true; - // add key to cmd line here - if (key >= 'A' && key <= 'Z' && !(shiftdown ^ capslock)) //this is only really necessary for dedicated servers - key = key + 'a' - 'A'; - if (input_sel != input_cur) CON_InputDelSelection(); CON_InputAddChar(key); From 5b2abfa18d672a37320fb3a2cbcb2bba01e5c670 Mon Sep 17 00:00:00 2001 From: GoldenTails Date: Sun, 28 Mar 2021 20:16:17 -0500 Subject: [PATCH 0660/1080] Replace some decimal constants with more descriptive hex constants. --- src/r_draw8.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/r_draw8.c b/src/r_draw8.c index 1f451115e..4a72dcda4 100644 --- a/src/r_draw8.c +++ b/src/r_draw8.c @@ -1227,8 +1227,9 @@ void R_DrawSplat_8 (void) // need! // // 4194303 = (2048x2048)-1 (2048x2048 is maximum flat size) + // Why decimal? 0x3FFFF == 4194303... ~Golden val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift); - val &= 4194303; + val &= 0x3FFFF; val = source[val]; if (val != TRANSPARENTPIXEL) dest[0] = colormap[val]; @@ -1236,7 +1237,7 @@ void R_DrawSplat_8 (void) yposition += ystep; val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift); - val &= 4194303; + val &= 0x3FFFF; val = source[val]; if (val != TRANSPARENTPIXEL) dest[1] = colormap[val]; @@ -1244,7 +1245,7 @@ void R_DrawSplat_8 (void) yposition += ystep; val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift); - val &= 4194303; + val &= 0x3FFFF; val = source[val]; if (val != TRANSPARENTPIXEL) dest[2] = colormap[val]; @@ -1252,7 +1253,7 @@ void R_DrawSplat_8 (void) yposition += ystep; val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift); - val &= 4194303; + val &= 0x3FFFF; val = source[val]; if (val != TRANSPARENTPIXEL) dest[3] = colormap[val]; @@ -1260,7 +1261,7 @@ void R_DrawSplat_8 (void) yposition += ystep; val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift); - val &= 4194303; + val &= 0x3FFFF; val = source[val]; if (val != TRANSPARENTPIXEL) dest[4] = colormap[val]; @@ -1268,7 +1269,7 @@ void R_DrawSplat_8 (void) yposition += ystep; val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift); - val &= 4194303; + val &= 0x3FFFF; val = source[val]; if (val != TRANSPARENTPIXEL) dest[5] = colormap[val]; @@ -1276,7 +1277,7 @@ void R_DrawSplat_8 (void) yposition += ystep; val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift); - val &= 4194303; + val &= 0x3FFFF; val = source[val]; if (val != TRANSPARENTPIXEL) dest[6] = colormap[val]; @@ -1284,7 +1285,7 @@ void R_DrawSplat_8 (void) yposition += ystep; val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift); - val &= 4194303; + val &= 0x3FFFF; val = source[val]; if (val != TRANSPARENTPIXEL) dest[7] = colormap[val]; From 776ce2a7506037b528fb7ce4acd81f22f3718582 Mon Sep 17 00:00:00 2001 From: GoldenTails Date: Sun, 28 Mar 2021 20:22:57 -0500 Subject: [PATCH 0661/1080] bruh i messed up --- src/r_draw8.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/r_draw8.c b/src/r_draw8.c index 4a72dcda4..b4c1491a0 100644 --- a/src/r_draw8.c +++ b/src/r_draw8.c @@ -1227,9 +1227,9 @@ void R_DrawSplat_8 (void) // need! // // 4194303 = (2048x2048)-1 (2048x2048 is maximum flat size) - // Why decimal? 0x3FFFF == 4194303... ~Golden + // Why decimal? 0x3FFFFF == 4194303... ~Golden val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift); - val &= 0x3FFFF; + val &= 0x3FFFFF; val = source[val]; if (val != TRANSPARENTPIXEL) dest[0] = colormap[val]; @@ -1237,7 +1237,7 @@ void R_DrawSplat_8 (void) yposition += ystep; val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift); - val &= 0x3FFFF; + val &= 0x3FFFFF; val = source[val]; if (val != TRANSPARENTPIXEL) dest[1] = colormap[val]; @@ -1245,7 +1245,7 @@ void R_DrawSplat_8 (void) yposition += ystep; val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift); - val &= 0x3FFFF; + val &= 0x3FFFFF; val = source[val]; if (val != TRANSPARENTPIXEL) dest[2] = colormap[val]; @@ -1253,7 +1253,7 @@ void R_DrawSplat_8 (void) yposition += ystep; val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift); - val &= 0x3FFFF; + val &= 0x3FFFFF; val = source[val]; if (val != TRANSPARENTPIXEL) dest[3] = colormap[val]; @@ -1261,7 +1261,7 @@ void R_DrawSplat_8 (void) yposition += ystep; val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift); - val &= 0x3FFFF; + val &= 0x3FFFFF; val = source[val]; if (val != TRANSPARENTPIXEL) dest[4] = colormap[val]; @@ -1269,7 +1269,7 @@ void R_DrawSplat_8 (void) yposition += ystep; val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift); - val &= 0x3FFFF; + val &= 0x3FFFFF; val = source[val]; if (val != TRANSPARENTPIXEL) dest[5] = colormap[val]; @@ -1277,7 +1277,7 @@ void R_DrawSplat_8 (void) yposition += ystep; val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift); - val &= 0x3FFFF; + val &= 0x3FFFFF; val = source[val]; if (val != TRANSPARENTPIXEL) dest[6] = colormap[val]; @@ -1285,7 +1285,7 @@ void R_DrawSplat_8 (void) yposition += ystep; val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift); - val &= 0x3FFFF; + val &= 0x3FFFFF; val = source[val]; if (val != TRANSPARENTPIXEL) dest[7] = colormap[val]; From 3dd04b90c630574f41ae0f70f03104706ac051dd Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Mon, 5 Apr 2021 16:59:02 -0400 Subject: [PATCH 0662/1080] Fix jet fume crash when dashmode is above DASHMODE_MAX I would like to use higher dashmode values for extra leniency, the jet fume kicks and screams when this happens. --- 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 b8e7d1746..03682b938 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -11310,7 +11310,7 @@ static void P_DoMetalJetFume(player_t *player, mobj_t *fume) angle_t angle = player->drawangle; fixed_t dist; panim_t panim = player->panim; - tic_t dashmode = player->dashmode; + tic_t dashmode = min(player->dashmode, DASHMODE_MAX); boolean underwater = mo->eflags & MFE_UNDERWATER; statenum_t stat = fume->state-states; From a01a420aa06176fce2cc249eacbdfd64ed73d93c Mon Sep 17 00:00:00 2001 From: James R Date: Mon, 5 Apr 2021 18:10:34 -0700 Subject: [PATCH 0663/1080] Brackets --- src/w_wad.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/w_wad.c b/src/w_wad.c index 91c8331f7..6149aec6e 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -821,8 +821,10 @@ UINT16 W_InitFile(const char *filename, boolean mainfile, boolean startup) } if (important && !mainfile) + { //G_SetGameModified(true); modifiedgame = true; // avoid savemoddata being set to false + } // // link wad file to search files From 397fdef034faf90bb89116e7028340f806c81488 Mon Sep 17 00:00:00 2001 From: Steel Titanium Date: Mon, 5 Apr 2021 22:34:52 -0400 Subject: [PATCH 0664/1080] Load intermission patches in Y_LoadIntermisionData --- src/g_game.c | 1 + src/y_inter.c | 133 ++++++++++++++++++++++++++++++++------------------ src/y_inter.h | 1 + 3 files changed, 87 insertions(+), 48 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index 2b304b4fd..29ad4086e 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -3973,6 +3973,7 @@ static void G_DoCompleted(void) { G_SetGamestate(GS_INTERMISSION); Y_StartIntermission(); + Y_LoadIntermisionData(); G_UpdateVisited(); G_HandleSaveLevel(); } diff --git a/src/y_inter.c b/src/y_inter.c index bd3b557d7..629d07426 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -215,6 +215,86 @@ static void Y_IntermissionTokenDrawer(void) V_DrawCroppedPatch(32<width, calc); } + +// +// Y_LoadData +// +// Load patches for drawing the intermission, if acceptable +// +void Y_LoadIntermisionData(void) +{ + INT32 i; + + if (dedicated) + return; + + switch (intertype) + { + case int_coop: + { + for (i = 0; i < 4; ++i) + { + if (strlen(data.coop.bonuses[i].patch)) + data.coop.bonuspatches[i] = W_CachePatchName(data.coop.bonuses[i].patch, PU_PATCH); + } + data.coop.ptotal = W_CachePatchName("YB_TOTAL", PU_PATCH); + + // get background patches + bgpatch = W_CachePatchName("INTERSCR", PU_PATCH); + + // grab an interscreen if appropriate + if (mapheaderinfo[gamemap-1]->interscreen[0] != '#') + interpic = W_CachePatchName(mapheaderinfo[gamemap-1]->interscreen, PU_PATCH); + break; + } + case int_spec: + { + for (i = 0; i < 2; ++i) + data.spec.bonuspatches[i] = W_CachePatchName(data.spec.bonuses[i].patch, PU_PATCH); + + data.spec.pscore = W_CachePatchName("YB_SCORE", PU_PATCH); + data.spec.pcontinues = W_CachePatchName("YB_CONTI", PU_PATCH); + + // get background tile + bgtile = W_CachePatchName("SPECTILE", PU_PATCH); + + // grab an interscreen if appropriate + if (mapheaderinfo[gamemap-1]->interscreen[0] != '#') + interpic = W_CachePatchName(mapheaderinfo[gamemap-1]->interscreen, PU_PATCH); + break; + } + case int_match: + case int_race: + case int_teammatch: + case int_ctf: + { + if (intertype == int_match || intertype == int_race) + { + // get RESULT header + data.match.result = W_CachePatchName("RESULT", PU_PATCH); + } + + if (intertype == int_ctf) + { + data.match.redflag = rflagico; + data.match.blueflag = bflagico; + } + else // team match + { + data.match.redflag = rmatcico; + data.match.blueflag = bmatcico; + } + + // get background tile + bgtile = W_CachePatchName("SRB2BACK", PU_PATCH); + break; + } + case int_none: + default: + break; + } +} + // // Y_ConsiderScreenBuffer // @@ -1176,6 +1256,11 @@ void Y_DetermineIntermissionType(void) intertype = int_ctf; } +// +// Y_StartIntermission +// +// Called by G_DoCompleted. Sets up data for intermission drawer/ticker. +// // // Y_StartIntermission // @@ -1183,8 +1268,6 @@ void Y_DetermineIntermissionType(void) // void Y_StartIntermission(void) { - INT32 i; - intertic = -1; #ifdef PARANOIA @@ -1228,23 +1311,12 @@ void Y_StartIntermission(void) // setup time data data.coop.tics = players[consoleplayer].realtime; - for (i = 0; i < 4; ++i) - { - if (strlen(data.coop.bonuses[i].patch)) - data.coop.bonuspatches[i] = W_CachePatchName(data.coop.bonuses[i].patch, PU_PATCH); - } - data.coop.ptotal = W_CachePatchName("YB_TOTAL", PU_PATCH); - // get act number data.coop.actnum = mapheaderinfo[gamemap-1]->actnum; - // get background patches - bgpatch = W_CachePatchName("INTERSCR", PU_PATCH); - // grab an interscreen if appropriate if (mapheaderinfo[gamemap-1]->interscreen[0] != '#') { - interpic = W_CachePatchName(mapheaderinfo[gamemap-1]->interscreen, PU_PATCH); useinterpic = true; usebuffer = false; } @@ -1301,21 +1373,9 @@ void Y_StartIntermission(void) // give out ring bonuses Y_AwardSpecialStageBonus(); - for (i = 0; i < 2; ++i) - data.spec.bonuspatches[i] = W_CachePatchName(data.spec.bonuses[i].patch, PU_PATCH); - - data.spec.pscore = W_CachePatchName("YB_SCORE", PU_PATCH); - data.spec.pcontinues = W_CachePatchName("YB_CONTI", PU_PATCH); - - // get background tile - bgtile = W_CachePatchName("SPECTILE", PU_PATCH); - // grab an interscreen if appropriate if (mapheaderinfo[gamemap-1]->interscreen[0] != '#') - { - interpic = W_CachePatchName(mapheaderinfo[gamemap-1]->interscreen, PU_PATCH); useinterpic = true; - } else useinterpic = false; @@ -1408,11 +1468,6 @@ void Y_StartIntermission(void) data.match.levelstring[sizeof data.match.levelstring - 1] = '\0'; - // get RESULT header - data.match.result = - W_CachePatchName("RESULT", PU_PATCH); - - bgtile = W_CachePatchName("SRB2BACK", PU_PATCH); usetile = true; useinterpic = false; break; @@ -1437,10 +1492,6 @@ void Y_StartIntermission(void) data.match.levelstring[sizeof data.match.levelstring - 1] = '\0'; - // get RESULT header - data.match.result = W_CachePatchName("RESULT", PU_PATCH); - - bgtile = W_CachePatchName("SRB2BACK", PU_PATCH); usetile = true; useinterpic = false; break; @@ -1466,18 +1517,6 @@ void Y_StartIntermission(void) data.match.levelstring[sizeof data.match.levelstring - 1] = '\0'; - if (intertype == int_ctf) - { - data.match.redflag = rflagico; - data.match.blueflag = bflagico; - } - else // team match - { - data.match.redflag = rmatcico; - data.match.blueflag = bmatcico; - } - - bgtile = W_CachePatchName("SRB2BACK", PU_PATCH); usetile = true; useinterpic = false; break; @@ -1502,8 +1541,6 @@ void Y_StartIntermission(void) data.competition.levelstring[sizeof data.competition.levelstring - 1] = '\0'; - // get background tile - bgtile = W_CachePatchName("SRB2BACK", PU_PATCH); usetile = true; useinterpic = false; break; diff --git a/src/y_inter.h b/src/y_inter.h index 859144b1d..08f7cf9bd 100644 --- a/src/y_inter.h +++ b/src/y_inter.h @@ -14,6 +14,7 @@ extern boolean usebuffer; void Y_IntermissionDrawer(void); void Y_Ticker(void); +void Y_LoadIntermisionData(void); void Y_StartIntermission(void); void Y_EndIntermission(void); From 35c0f8b5cc46ee8addc3cac102daebe7051aef8e Mon Sep 17 00:00:00 2001 From: Steel Titanium Date: Mon, 5 Apr 2021 22:44:16 -0400 Subject: [PATCH 0665/1080] Correct function name comment --- src/y_inter.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/y_inter.c b/src/y_inter.c index 629d07426..e1bbd16f6 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -217,7 +217,7 @@ static void Y_IntermissionTokenDrawer(void) // -// Y_LoadData +// Y_LoadIntermisionData // // Load patches for drawing the intermission, if acceptable // From 33b7075d4607a4d68a64d9c7d35f06e99fb22399 Mon Sep 17 00:00:00 2001 From: Steel Titanium Date: Mon, 5 Apr 2021 22:50:22 -0400 Subject: [PATCH 0666/1080] bruh --- src/g_game.c | 2 +- src/y_inter.c | 4 ++-- src/y_inter.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index 29ad4086e..13423ce77 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -3973,7 +3973,7 @@ static void G_DoCompleted(void) { G_SetGamestate(GS_INTERMISSION); Y_StartIntermission(); - Y_LoadIntermisionData(); + Y_LoadIntermissionData(); G_UpdateVisited(); G_HandleSaveLevel(); } diff --git a/src/y_inter.c b/src/y_inter.c index e1bbd16f6..4e10e7398 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -217,11 +217,11 @@ static void Y_IntermissionTokenDrawer(void) // -// Y_LoadIntermisionData +// Y_LoadIntermissionData // // Load patches for drawing the intermission, if acceptable // -void Y_LoadIntermisionData(void) +void Y_LoadIntermissionData(void) { INT32 i; diff --git a/src/y_inter.h b/src/y_inter.h index 08f7cf9bd..7268b1a47 100644 --- a/src/y_inter.h +++ b/src/y_inter.h @@ -14,7 +14,7 @@ extern boolean usebuffer; void Y_IntermissionDrawer(void); void Y_Ticker(void); -void Y_LoadIntermisionData(void); +void Y_LoadIntermissionData(void); void Y_StartIntermission(void); void Y_EndIntermission(void); From 101b6e46d413821f74aa8f10d8e55a4d1959634f Mon Sep 17 00:00:00 2001 From: Steel Titanium Date: Mon, 5 Apr 2021 22:56:03 -0400 Subject: [PATCH 0667/1080] Even more bruhs --- src/y_inter.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/y_inter.c b/src/y_inter.c index 4e10e7398..32dfb52a7 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -1262,10 +1262,6 @@ void Y_DetermineIntermissionType(void) // Called by G_DoCompleted. Sets up data for intermission drawer/ticker. // // -// Y_StartIntermission -// -// Called by G_DoCompleted. Sets up data for intermission drawer/ticker. -// void Y_StartIntermission(void) { intertic = -1; From e39bf7503fe37dfe412ef06b45ef9dba7095b9dc Mon Sep 17 00:00:00 2001 From: James R Date: Tue, 6 Apr 2021 03:55:57 -0700 Subject: [PATCH 0668/1080] Makefile: fix object file not depending on headers BRUH MOMENT --- src/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Makefile b/src/Makefile index 471c55ed3..cf06ce904 100644 --- a/src/Makefile +++ b/src/Makefile @@ -701,7 +701,7 @@ endif endif define deps_rule += - $(CC) $(CFLAGS) -M -MF $@ -MT $(OBJDIR)/$< $< + $(CC) $(CFLAGS) -M -MF $@ -MT $(OBJDIR)/$(<:.c=.o) $< endef $(DEPDIR)/%.d: %.c From c3d5740e983891b18bd45fccf45ac89cd9345403 Mon Sep 17 00:00:00 2001 From: SwitchKaze Date: Tue, 6 Apr 2021 15:06:44 -0500 Subject: [PATCH 0669/1080] Fix console text bleeding edge case A single character could prematurely read if there were enough special characters to push 'c' past 'con_width'. --- src/console.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/console.c b/src/console.c index 2d95e10b8..208b55212 100644 --- a/src/console.c +++ b/src/console.c @@ -1654,6 +1654,8 @@ static void CON_DrawHudlines(void) p++; c++; } + if (c >= con_width) + break; if (*p < HU_FONTSTART) ;//charwidth = 4 * con_scalefactor; else @@ -1777,6 +1779,8 @@ static void CON_DrawConsole(void) p++; c++; } + if (c >= con_width) + break; V_DrawCharacter(x, y, (INT32)(*p) | charflags | cv_constextsize.value | V_NOSCALESTART, true); } } From a501b7b00d74bcdce98e2ca0d6b69ddfb0c39ea9 Mon Sep 17 00:00:00 2001 From: Steel Titanium Date: Wed, 7 Apr 2021 00:55:08 -0400 Subject: [PATCH 0670/1080] Reorganize the switch block, add missing int_comp case --- src/y_inter.c | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/src/y_inter.c b/src/y_inter.c index 32dfb52a7..5dd3e845d 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -263,28 +263,23 @@ void Y_LoadIntermissionData(void) interpic = W_CachePatchName(mapheaderinfo[gamemap-1]->interscreen, PU_PATCH); break; } + case int_ctf: + case int_teammatch: + { + data.match.redflag = (intertype == int_ctf) ? rflagico : rmatcico; + data.match.blueflag = (intertype == int_ctf) ? bflagico : bmatcico; + } + /* FALLTHRU */ case int_match: case int_race: - case int_teammatch: - case int_ctf: + case int_comp: { - if (intertype == int_match || intertype == int_race) + if (intertype == int_match || intertype == int_race || intertype == int_comp) { // get RESULT header data.match.result = W_CachePatchName("RESULT", PU_PATCH); } - if (intertype == int_ctf) - { - data.match.redflag = rflagico; - data.match.blueflag = bflagico; - } - else // team match - { - data.match.redflag = rmatcico; - data.match.blueflag = bmatcico; - } - // get background tile bgtile = W_CachePatchName("SRB2BACK", PU_PATCH); break; From 77f2b1f682b1b4112d7f3d74e1f937107479aaef Mon Sep 17 00:00:00 2001 From: Steel Titanium Date: Wed, 7 Apr 2021 01:11:39 -0400 Subject: [PATCH 0671/1080] Prevent redudant result patch caching on competition --- src/y_inter.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/y_inter.c b/src/y_inter.c index 5dd3e845d..6833ca2b5 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -274,7 +274,7 @@ void Y_LoadIntermissionData(void) case int_race: case int_comp: { - if (intertype == int_match || intertype == int_race || intertype == int_comp) + if (intertype == int_match || intertype == int_race) { // get RESULT header data.match.result = W_CachePatchName("RESULT", PU_PATCH); From 3f086ff6123341cfe236165908edb779014aa854 Mon Sep 17 00:00:00 2001 From: SMS Alfredo <65426124+SMS-Alfredo@users.noreply.github.com> Date: Wed, 7 Apr 2021 01:14:32 -0500 Subject: [PATCH 0672/1080] The intial --- src/deh_tables.c | 3 +++ src/p_mobj.c | 41 ++++++++++++++++++++++++++++++++++++----- src/r_defs.h | 4 ++++ 3 files changed, 43 insertions(+), 5 deletions(-) diff --git a/src/deh_tables.c b/src/deh_tables.c index dd6d7d69f..f3a77d528 100644 --- a/src/deh_tables.c +++ b/src/deh_tables.c @@ -4905,6 +4905,9 @@ struct int_const_s const INT_CONST[] = { {"RF_SHADOWDRAW",RF_SHADOWDRAW}, {"RF_SHADOWEFFECTS",RF_SHADOWEFFECTS}, {"RF_DROPSHADOW",RF_DROPSHADOW}, + {"RF_FORCESUPER",RF_FORCESUPER}, + {"RF_FORCENOSUPER",RF_FORCENOSUPER}, + {"RF_REVERSESUPER",RF_REVERSESUPER}, // Level flags {"LF_SCRIPTISFILE",LF_SCRIPTISFILE}, diff --git a/src/p_mobj.c b/src/p_mobj.c index 49db6daee..3f77f28aa 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -325,9 +325,7 @@ boolean P_SetPlayerMobjState(mobj_t *mobj, statenum_t state) mobj->tics = st->tics; // Adjust the player's animation speed to match their velocity. - if (state == S_PLAY_STND && player->powers[pw_super] && skins[player->skin].sprites[SPR2_WAIT|FF_SPR2SUPER].numframes == 0) // if no super wait, don't wait at all - mobj->tics = -1; - else if (player->panim == PA_EDGE && (player->charflags & SF_FASTEDGE)) + if (player->panim == PA_EDGE && (player->charflags & SF_FASTEDGE)) mobj->tics = 2; else if (!(disableSpeedAdjust || player->charflags & SF_NOSPEEDADJUST)) { @@ -396,8 +394,26 @@ boolean P_SetPlayerMobjState(mobj_t *mobj, statenum_t state) if (skin) { - spr2 = P_GetSkinSprite2(skin, (((player->powers[pw_super] && !(player->charflags & SF_NOSUPERSPRITES)) ? FF_SPR2SUPER : 0)|st->frame) & FF_FRAMEMASK, mobj->player); + UINT16 stateframe = st->frame; + + // Add/Remove FF_SPR2SUPER based on certain conditions + if (player->powers[pw_super] && !(player->charflags & SF_NOSUPERSPRITES)) + stateframe = stateframe | FF_SPR2SUPER; + + if (stateframe & FF_SPR2SUPER) + { + if (mobj->renderflags & RF_FORCENOSUPER) + stateframe = stateframe & ~FF_SPR2SUPER; + } + else if (mobj->renderflags & RF_FORCESUPER) + stateframe = stateframe | FF_SPR2SUPER; + + // Get the sprite2 and frame number + spr2 = P_GetSkinSprite2(skin, (stateframe & FF_FRAMEMASK), mobj->player); numframes = skin->sprites[spr2].numframes; + + if (state == S_PLAY_STND && (spr2 & FF_SPR2SUPER) && skin->sprites[SPR2_WAIT|FF_SPR2SUPER].numframes == 0) + mobj->tics = -1; // If no super wait, don't wait at all } else { @@ -522,8 +538,23 @@ boolean P_SetMobjState(mobj_t *mobj, statenum_t state) if (skin) { - spr2 = P_GetSkinSprite2(skin, st->frame & FF_FRAMEMASK, mobj->player); + UINT16 stateframe = st->frame; + + // Add/Remove FF_SPR2SUPER based on certain conditions + if (stateframe & FF_SPR2SUPER) + { + if (mobj->renderflags & RF_FORCENOSUPER) + stateframe = stateframe & ~FF_SPR2SUPER; + } + else if (mobj->renderflags & RF_FORCESUPER) + stateframe = stateframe | FF_SPR2SUPER; + + // Get the sprite2 and frame number + spr2 = P_GetSkinSprite2(skin, (stateframe & FF_FRAMEMASK), NULL); numframes = skin->sprites[spr2].numframes; + + if (state == S_PLAY_STND && (spr2 & FF_SPR2SUPER) && skin->sprites[SPR2_WAIT|FF_SPR2SUPER].numframes == 0) + mobj->tics = -1; // If no super wait, don't wait at all } else { diff --git a/src/r_defs.h b/src/r_defs.h index 9c649fbc4..31f30dd6f 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -738,6 +738,10 @@ typedef enum RF_SHADOWDRAW = 0x10000, // Stretches and skews the sprite like a shadow. RF_SHADOWEFFECTS = 0x20000, // Scales and becomes transparent like a shadow. RF_DROPSHADOW = (RF_SHADOWDRAW | RF_SHADOWEFFECTS | RF_FULLDARK), + + RF_FORCESUPER = 0x40000, // Forces an object to use super sprites with SPR_PLAY. + RF_FORCENOSUPER = 0x80000, // Forces an object to NOT use super sprites with SPR_PLAY. + RF_REVERSESUPER = (RF_FORCESUPER | RF_FORCENOSUPER), //Use normal sprites in place of super sprites and vice-versa } renderflags_t; typedef enum From 876daa7d6ef762312fd4ec990c30fc3b3c499c4d Mon Sep 17 00:00:00 2001 From: katsy Date: Wed, 7 Apr 2021 04:57:18 -0500 Subject: [PATCH 0673/1080] fix ctf flag garbage --- src/st_stuff.c | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/src/st_stuff.c b/src/st_stuff.c index 649644620..a1fbbec03 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -299,10 +299,6 @@ void ST_LoadGraphics(void) gravboots = W_CachePatchName("TVGVICON", PU_HUDGFX); tagico = W_CachePatchName("TAGICO", PU_HUDGFX); - rflagico = W_CachePatchName("RFLAGICO", PU_HUDGFX); - bflagico = W_CachePatchName("BFLAGICO", PU_HUDGFX); - rmatcico = W_CachePatchName("RMATCICO", PU_HUDGFX); - bmatcico = W_CachePatchName("BMATCICO", PU_HUDGFX); gotrflag = W_CachePatchName("GOTRFLAG", PU_HUDGFX); gotbflag = W_CachePatchName("GOTBFLAG", PU_HUDGFX); fnshico = W_CachePatchName("FNSHICO", PU_HUDGFX); @@ -2363,27 +2359,29 @@ static inline void ST_drawRaceHUD(void) static void ST_drawTeamHUD(void) { - patch_t *p; #define SEP 20 if (F_GetPromptHideHud(0)) // y base is 0 return; - if (gametyperules & GTR_TEAMFLAGS) - p = bflagico; - else - p = bmatcico; + rflagico = W_CachePatchName("RFLAGICO", PU_HUDGFX); + bflagico = W_CachePatchName("BFLAGICO", PU_HUDGFX); + rmatcico = W_CachePatchName("RMATCICO", PU_HUDGFX); + bmatcico = W_CachePatchName("BMATCICO", PU_HUDGFX); if (LUA_HudEnabled(hud_teamscores)) - V_DrawSmallScaledPatch(BASEVIDWIDTH/2 - SEP - (p->width / 4), 4, V_HUDTRANS|V_PERPLAYER|V_SNAPTOTOP, p); - - if (gametyperules & GTR_TEAMFLAGS) - p = rflagico; - else - p = rmatcico; - - if (LUA_HudEnabled(hud_teamscores)) - V_DrawSmallScaledPatch(BASEVIDWIDTH/2 + SEP - (p->width / 4), 4, V_HUDTRANS|V_PERPLAYER|V_SNAPTOTOP, p); + { + if (gametyperules & GTR_TEAMFLAGS) + { + V_DrawSmallScaledPatch(BASEVIDWIDTH/2 - SEP - (bflagico->width / 4), 4, V_HUDTRANS|V_PERPLAYER|V_SNAPTOTOP, bflagico); + V_DrawSmallScaledPatch(BASEVIDWIDTH/2 + SEP - (rflagico->width / 4), 4, V_HUDTRANS|V_PERPLAYER|V_SNAPTOTOP, rflagico); + } + else + { + V_DrawSmallScaledPatch(BASEVIDWIDTH/2 - SEP - (bmatcico->width / 4), 4, V_HUDTRANS|V_PERPLAYER|V_SNAPTOTOP, bmatcico); + V_DrawSmallScaledPatch(BASEVIDWIDTH/2 + SEP - (rmatcico->width / 4), 4, V_HUDTRANS|V_PERPLAYER|V_SNAPTOTOP, rmatcico); + } + } if (!(gametyperules & GTR_TEAMFLAGS)) goto num; From 0d628c351aa57d2dfa95c77fd86c49a3a1a7a3b0 Mon Sep 17 00:00:00 2001 From: sphere Date: Sat, 10 Apr 2021 17:44:42 +0200 Subject: [PATCH 0674/1080] Update Zone Builder configuration. --- extras/conf/SRB2-22.cfg | 146 ++++++++++++++++++++++++++++------------ 1 file changed, 104 insertions(+), 42 deletions(-) diff --git a/extras/conf/SRB2-22.cfg b/extras/conf/SRB2-22.cfg index a0d40cdf0..3fd4b6ccd 100644 --- a/extras/conf/SRB2-22.cfg +++ b/extras/conf/SRB2-22.cfg @@ -746,13 +746,13 @@ linedeftypes 20 { - title = "First Line"; + title = "PolyObject First Line"; prefix = "(20)"; } 22 { - title = "Parameters"; + title = "PolyObject Parameters"; prefix = "(22)"; flags8text = "[3] Set translucency by X offset"; flags32text = "[5] Render outer sides only"; @@ -765,19 +765,19 @@ linedeftypes 30 { - title = "Waving Flag"; + title = "PolyObject Waving Flag"; prefix = "(30)"; } 31 { - title = "Displacement by Front Sector"; + title = "Move PolyObject by Front Sector Displacement"; prefix = "(31)"; } 32 { - title = "Angular Displacement by Front Sector"; + title = "Rotate PolyObject by Front Sector Displacement"; prefix = "(32)"; flags64text = "[6] Don't turn players"; flags512text = "[9] Turn all objects"; @@ -2498,35 +2498,35 @@ linedeftypes 480 { - title = "Door Slide"; + title = "PolyObject Door Slide"; prefix = "(480)"; flags8text = "[3] Set delay by backside sector"; } 481 { - title = "Door Swing"; + title = "PolyObject Door Swing"; prefix = "(481)"; flags8text = "[3] Set delay by backside sector"; } 482 { - title = "Move"; + title = "Move PolyObject"; prefix = "(482)"; flags8text = "[3] Set delay by backside sector"; } 483 { - title = "Move, Override"; + title = "Move PolyObject, Override"; prefix = "(483)"; flags8text = "[3] Set delay by backside sector"; } 484 { - title = "Rotate Right"; + title = "Rotate PolyObject Right"; prefix = "(484)"; flags8text = "[3] Set delay by backside sector"; flags64text = "[6] Don't turn players"; @@ -2535,7 +2535,7 @@ linedeftypes 485 { - title = "Rotate Right, Override"; + title = "Rotate PolyObject Right, Override"; prefix = "(485)"; flags8text = "[3] Set delay by backside sector"; flags64text = "[6] Don't turn players"; @@ -2544,7 +2544,7 @@ linedeftypes 486 { - title = "Rotate Left"; + title = "Rotate PolyObject Left"; prefix = "(486)"; flags8text = "[3] Set delay by backside sector"; flags64text = "[6] Don't turn players"; @@ -2553,7 +2553,7 @@ linedeftypes 487 { - title = "Rotate Left, Override"; + title = "Rotate PolyObject Left, Override"; prefix = "(487)"; flags8text = "[3] Set delay by backside sector"; flags64text = "[6] Don't turn players"; @@ -2562,7 +2562,7 @@ linedeftypes 488 { - title = "Move by Waypoints"; + title = "Move PolyObject by Waypoints"; prefix = "(488)"; flags8text = "[3] Set delay by backside sector"; flags32text = "[5] Reverse order"; @@ -2573,7 +2573,7 @@ linedeftypes 489 { - title = "Turn Invisible, Intangible"; + title = "Turn PolyObject Invisible, Intangible"; prefix = "(489)"; flags8text = "[3] Set delay by backside sector"; flags64text = "[6] Only invisible"; @@ -2581,7 +2581,7 @@ linedeftypes 490 { - title = "Turn Visible, Tangible"; + title = "Turn PolyObject Visible, Tangible"; prefix = "(490)"; flags8text = "[3] Set delay by backside sector"; flags64text = "[6] Only visible"; @@ -2589,7 +2589,7 @@ linedeftypes 491 { - title = "Set Translucency"; + title = "Set PolyObject Translucency"; prefix = "(491)"; flags8text = "[3] Set delay by backside sector"; flags16text = "[4] Set raw alpha by Front X"; @@ -2598,7 +2598,7 @@ linedeftypes 492 { - title = "Fade Translucency"; + title = "Fade PolyObject Translucency"; prefix = "(492)"; flags8text = "[3] Set delay by backside sector"; flags16text = "[4] Set raw alpha by Front X"; @@ -3393,6 +3393,7 @@ thingtypes width = 8; height = 28; angletext = "Jump strength"; + fixedrotation = 1; } 103 { @@ -3431,6 +3432,7 @@ thingtypes width = 12; height = 64; angletext = "Firing delay"; + fixedrotation = 1; } 122 { @@ -3547,9 +3549,10 @@ thingtypes { title = "Pterabyte Spawner"; sprite = "PTERA2A8"; - width = 16; - height = 16; - parametertext = "No. Pterabytes"; + width = 24; + height = 48; + parametertext = "Spawns +1"; + arrow = 0; } 136 { @@ -3771,6 +3774,7 @@ thingtypes height = 16; sprite = "internal:capsule"; angletext = "Tag"; + fixedrotation = 1; } 292 { @@ -3781,11 +3785,13 @@ thingtypes flags8text = "[8] Sea Egg shooting point"; sprite = "internal:eggmanway"; angletext = "No. (Sea Egg)"; + fixedrotation = 1; flagsvaluetext = "No. (Brak)"; parametertext = "Next"; } 293 { + arrow = 0; title = "Metal Sonic Gather Point"; sprite = "internal:metal"; width = 8; @@ -3793,6 +3799,7 @@ thingtypes } 294 { + arrow = 0; title = "Fang Waypoint"; flags8text = "[8] Center waypoint"; sprite = "internal:eggmanway"; @@ -3820,79 +3827,79 @@ thingtypes 301 { title = "Bounce Ring"; - sprite = "internal:RNGBA0"; + sprite = "RNGBA0"; } 302 { title = "Rail Ring"; - sprite = "internal:RNGRA0"; + sprite = "RNGRA0"; } 303 { title = "Infinity Ring"; - sprite = "internal:RNGIA0"; + sprite = "RNGIA0"; } 304 { title = "Automatic Ring"; - sprite = "internal:RNGAA0"; + sprite = "RNGAA0"; } 305 { title = "Explosion Ring"; - sprite = "internal:RNGEA0"; + sprite = "RNGEA0"; } 306 { title = "Scatter Ring"; - sprite = "internal:RNGSA0"; + sprite = "RNGSA0"; } 307 { title = "Grenade Ring"; - sprite = "internal:RNGGA0"; + sprite = "RNGGA0"; } 308 { title = "CTF Team Ring (Red)"; - sprite = "internal:RRNGA0"; + sprite = "internal:TRNGA0r"; width = 16; } 309 { title = "CTF Team Ring (Blue)"; - sprite = "internal:BRNGA0"; + sprite = "internal:TRNGA0b"; width = 16; } 330 { title = "Bounce Ring Panel"; - sprite = "internal:PIKBA0"; + sprite = "PIKBA0"; } 331 { title = "Rail Ring Panel"; - sprite = "internal:PIKRA0"; + sprite = "PIKRA0"; } 332 { title = "Automatic Ring Panel"; - sprite = "internal:PIKAA0"; + sprite = "PIKAA0"; } 333 { title = "Explosion Ring Panel"; - sprite = "internal:PIKEA0"; + sprite = "PIKEA0"; } 334 { title = "Scatter Ring Panel"; - sprite = "internal:PIKSA0"; + sprite = "PIKSA0"; } 335 { title = "Grenade Ring Panel"; - sprite = "internal:PIKGA0"; + sprite = "PIKGA0"; } } @@ -3986,6 +3993,7 @@ thingtypes flags8height = 24; flags8text = "[8] Float"; angletext = "Tag"; + fixedrotation = 1; } } @@ -4000,6 +4008,7 @@ thingtypes flags4text = "[4] Random (Strong)"; flags8text = "[8] Random (Weak)"; angletext = "Tag"; + fixedrotation = 1; 400 { @@ -4131,6 +4140,7 @@ thingtypes height = 44; flags1text = "[1] Run linedef executor on pop"; angletext = "Tag"; + fixedrotation = 1; 431 { @@ -4228,6 +4238,7 @@ thingtypes height = 128; flags4text = "[4] Respawn at center"; angletext = "Angle/Order"; + fixedrotation = 1; parametertext = "Order"; } 520 @@ -4259,7 +4270,7 @@ thingtypes flags1text = "[1] Start retracted"; flags4text = "[4] Retractable"; flags8text = "[8] Intangible"; - parametertext = "Initial delay"; + parametertext = "Start delay"; } 523 { @@ -4271,7 +4282,8 @@ thingtypes flags4text = "[4] Retractable"; flags8text = "[8] Intangible"; angletext = "Retraction interval"; - parametertext = "Initial delay"; + fixedrotation = 1; + parametertext = "Start delay"; } 1130 { @@ -4320,6 +4332,7 @@ thingtypes flags4text = "[4] Invisible"; flags8text = "[8] No distance check"; angletext = "Lift height"; + fixedrotation = 1; } 541 { @@ -4335,6 +4348,7 @@ thingtypes width = 32; height = 64; angletext = "Strength"; + fixedrotation = 1; } 543 { @@ -4344,6 +4358,7 @@ thingtypes height = 64; flags8text = "[8] Respawn"; angletext = "Color"; + fixedrotation = 1; } 550 { @@ -4617,6 +4632,9 @@ thingtypes title = "Slope Vertex"; sprite = "internal:vertexslope"; angletext = "Tag"; + fixedrotation = 1; + parametertext = "Absolute?"; + flagsvaluetext = "Absolute Z"; } 751 @@ -4638,6 +4656,7 @@ thingtypes title = "Zoom Tube Waypoint"; sprite = "internal:zoom"; angletext = "Order"; + fixedrotation = 1; } 754 @@ -4647,6 +4666,7 @@ thingtypes flags8text = "[8] Push using XYZ"; sprite = "GWLGA0"; angletext = "Radius"; + fixedrotation = 1; } 755 { @@ -4655,6 +4675,7 @@ thingtypes flags8text = "[8] Pull using XYZ"; sprite = "GWLRA0"; angletext = "Radius"; + fixedrotation = 1; } 756 { @@ -4663,6 +4684,7 @@ thingtypes width = 32; height = 16; angletext = "Tag"; + fixedrotation = 1; } 757 { @@ -4671,6 +4693,7 @@ thingtypes width = 8; height = 16; angletext = "Tag"; + fixedrotation = 1; } 758 { @@ -4681,21 +4704,24 @@ thingtypes { title = "PolyObject Anchor"; sprite = "internal:polyanchor"; - angletext = "ID"; + angletext = "Tag"; + fixedrotation = 1; } 761 { title = "PolyObject Spawn Point"; sprite = "internal:polycenter"; - angletext = "ID"; + angletext = "Tag"; + fixedrotation = 1; } 762 { title = "PolyObject Spawn Point (Crush)"; sprite = "internal:polycentercrush"; - angletext = "ID"; + angletext = "Tag"; + fixedrotation = 1; } 780 { @@ -4703,6 +4729,7 @@ thingtypes sprite = "internal:skyb"; flags4text = "[4] In-map centerpoint"; parametertext = "ID"; + fixedrotation = 1; } } @@ -4897,6 +4924,7 @@ thingtypes height = 16; hangs = 1; angletext = "Dripping interval"; + fixedrotation = 1; } 1003 { @@ -4953,7 +4981,7 @@ thingtypes 1011 { title = "Stalagmite (DSZ2)"; - sprite = "DSTGA0"; + sprite = "DSTGB0"; width = 8; height = 116; flags4text = "[4] Double size"; @@ -5038,6 +5066,8 @@ thingtypes flags4text = "[4] No sounds"; flags8text = "[8] Double size"; angletext = "Tag"; + parametertext = "Spokes"; + fixedrotation = 1; } 1105 { @@ -5048,6 +5078,8 @@ thingtypes flags4text = "[4] No sounds"; flags8text = "[8] Double size"; angletext = "Tag"; + parametertext = "Spokes"; + fixedrotation = 1; } 1106 { @@ -5058,6 +5090,8 @@ thingtypes flags4text = "[4] No sounds"; flags8text = "[8] Red spring"; angletext = "Tag"; + parametertext = "Spokes"; + fixedrotation = 1; } 1107 { @@ -5067,6 +5101,8 @@ thingtypes height = 34; flags8text = "[8] Double size"; angletext = "Tag"; + parametertext = "Spokes"; + fixedrotation = 1; } 1108 { @@ -5086,6 +5122,8 @@ thingtypes flags4text = "[4] No sounds"; flags8text = "[8] Double size"; angletext = "Tag"; + parametertext = "Spokes"; + fixedrotation = 1; } 1110 { @@ -5095,6 +5133,8 @@ thingtypes height = 34; flags4text = "[4] No sounds"; angletext = "Tag"; + parametertext = "Spokes"; + fixedrotation = 1; } 1111 { @@ -5224,6 +5264,7 @@ thingtypes sprite = "EGR1A1"; width = 20; height = 72; + arrow = 1; } 1128 { @@ -5272,6 +5313,7 @@ thingtypes width = 8; height = 16; angletext = "Tag"; + fixedrotation = 1; } 1203 { @@ -5342,6 +5384,7 @@ thingtypes sprite = "WWSGAR"; width = 22; height = 64; + arrow = 1; } 1213 { @@ -5349,6 +5392,7 @@ thingtypes sprite = "WWS2AR"; width = 22; height = 64; + arrow = 1; } 1214 { @@ -5356,6 +5400,7 @@ thingtypes sprite = "WWS3ALAR"; width = 16; height = 192; + arrow = 1; } 1215 { @@ -5371,6 +5416,7 @@ thingtypes sprite = "BARRA1"; width = 24; height = 63; + arrow = 1; } 1217 { @@ -5392,6 +5438,7 @@ thingtypes sprite = "MCRTCLFR"; width = 22; height = 32; + arrow = 1; } 1220 { @@ -5399,6 +5446,7 @@ thingtypes sprite = "MCRTIR"; width = 32; height = 32; + arrow = 1; } 1221 { @@ -5406,6 +5454,7 @@ thingtypes sprite = "SALDARAL"; width = 96; height = 160; + arrow = 1; flags8text = "[8] Allow non-minecart players"; } 1222 @@ -5467,6 +5516,7 @@ thingtypes height = 40; flags8text = "[8] Waves vertically"; angletext = "On/Off time"; + fixedrotation = 1; parametertext = "Strength"; } 1301 @@ -5477,6 +5527,7 @@ thingtypes height = 40; flags8text = "[8] Shoot downwards"; angletext = "On/Off time"; + fixedrotation = 1; parametertext = "Strength"; } 1302 @@ -5500,6 +5551,7 @@ thingtypes width = 30; height = 32; angletext = "Initial delay"; + fixedrotation = 1; flags8text = "[8] Double size"; } 1305 @@ -5537,6 +5589,7 @@ thingtypes sprite = "WVINALAR"; width = 1; height = 288; + arrow = 1; } 1310 { @@ -5544,6 +5597,7 @@ thingtypes sprite = "WVINBLBR"; width = 1; height = 288; + arrow = 1; } } @@ -5901,6 +5955,7 @@ thingtypes width = 8; height = 4096; sprite = "UNKNA0"; + fixedrotation = 1; 1700 { @@ -5959,6 +6014,7 @@ thingtypes flags4text = "[4] Align player to top"; flags8text = "[8] Die upon time up"; angletext = "Time limit"; + fixedrotation = 1; parametertext = "Height"; } 1704 @@ -5971,6 +6027,7 @@ thingtypes unflippable = true; flagsvaluetext = "Pitch"; angletext = "Yaw"; + fixedrotation = 1; } 1705 { @@ -5983,6 +6040,7 @@ thingtypes centerHitbox = true; flagsvaluetext = "Height"; angletext = "Pitch/Yaw"; + fixedrotation = 1; } 1706 { @@ -6104,6 +6162,7 @@ thingtypes width = 8; height = 16; angletext = "Jump strength"; + fixedrotation = 1; } 1806 { @@ -6336,6 +6395,7 @@ thingtypes width = 18; height = 28; angletext = "Initial delay"; + fixedrotation = 1; } 2001 { @@ -6459,6 +6519,7 @@ thingtypes sprite = "XMS6A0"; width = 52; height = 106; + hangs = 1; } } @@ -6472,6 +6533,7 @@ thingtypes flags4text = "[4] No movement"; flags8text = "[8] Hop"; angletext = "Radius"; + fixedrotation = 1; 2200 { From dbc7f93f15479d7d123b5507b5aaf94e7f952249 Mon Sep 17 00:00:00 2001 From: sphere Date: Sat, 10 Apr 2021 11:52:15 -0400 Subject: [PATCH 0675/1080] Fix incorrect prefixes in the config --- extras/conf/SRB2-22.cfg | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/extras/conf/SRB2-22.cfg b/extras/conf/SRB2-22.cfg index 246ef9b64..a8217754d 100644 --- a/extras/conf/SRB2-22.cfg +++ b/extras/conf/SRB2-22.cfg @@ -3110,7 +3110,7 @@ linedeftypes 733 { title = "Copy Backside Floor Slope to Frontside"; - prefix = "(730)"; + prefix = "(733)"; slope = "copy"; copyslopeargs = 2; } @@ -3118,7 +3118,7 @@ linedeftypes 734 { title = "Copy Backside Ceiling Slope to Frontside"; - prefix = "(731)"; + prefix = "(734)"; slope = "copy"; copyslopeargs = 8; } @@ -3126,7 +3126,7 @@ linedeftypes 735 { title = "Copy Backside Floor and Ceiling Slope to Frontside"; - prefix = "(732)"; + prefix = "(735)"; slope = "copy"; copyslopeargs = 10; } From 4f3802a2cc400a0c93818fce5ac40d60ea2f6424 Mon Sep 17 00:00:00 2001 From: GoldenTails Date: Sun, 11 Apr 2021 18:29:14 -0500 Subject: [PATCH 0676/1080] acos Lua exposure --- src/lua_mathlib.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/lua_mathlib.c b/src/lua_mathlib.c index b6046ab53..9a288e17b 100644 --- a/src/lua_mathlib.c +++ b/src/lua_mathlib.c @@ -87,6 +87,12 @@ static int lib_finetangent(lua_State *L) return 1; } +static int lib_finearccosine(lua_State *L) +{ + lua_pushangle(L, FixedAcos(luaL_checkfixed(L, 1))); + return 1; +} + // Fixed math //////////////// @@ -192,6 +198,7 @@ static luaL_Reg lib[] = { {"sin", lib_finesine}, {"cos", lib_finecosine}, {"tan", lib_finetangent}, + {"acos", lib_finearccosine}, {"FixedAngle", lib_fixedangle}, {"fixangle" , lib_fixedangle}, {"AngleFixed", lib_anglefixed}, From 8f322fd86fc8b2709c364ef4d2b1e4f363265f78 Mon Sep 17 00:00:00 2001 From: GoldenTails Date: Sun, 11 Apr 2021 18:33:11 -0500 Subject: [PATCH 0677/1080] name kinda sucked --- src/lua_mathlib.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lua_mathlib.c b/src/lua_mathlib.c index 9a288e17b..45168ad79 100644 --- a/src/lua_mathlib.c +++ b/src/lua_mathlib.c @@ -87,7 +87,7 @@ static int lib_finetangent(lua_State *L) return 1; } -static int lib_finearccosine(lua_State *L) +static int lib_fixedacos(lua_State *L) { lua_pushangle(L, FixedAcos(luaL_checkfixed(L, 1))); return 1; @@ -198,7 +198,7 @@ static luaL_Reg lib[] = { {"sin", lib_finesine}, {"cos", lib_finecosine}, {"tan", lib_finetangent}, - {"acos", lib_finearccosine}, + {"acos", lib_fixedacos}, {"FixedAngle", lib_fixedangle}, {"fixangle" , lib_fixedangle}, {"AngleFixed", lib_anglefixed}, From 701c6c8968fea04dc13f02c3cc5e3e7841e48345 Mon Sep 17 00:00:00 2001 From: "X.organic" Date: Tue, 6 Apr 2021 01:01:33 +0200 Subject: [PATCH 0678/1080] Fix myhashfgets-related buffer overflows in deh_soc.c --- src/deh_soc.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/deh_soc.c b/src/deh_soc.c index 5b12ea1b0..bc7533ee0 100644 --- a/src/deh_soc.c +++ b/src/deh_soc.c @@ -229,7 +229,10 @@ void readPlayer(MYFILE *f, INT32 num) SLOTFOUND - 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 < MAXLINELEN-note_size-3; i++) { if (s[i] == '=') { @@ -239,8 +242,9 @@ void readPlayer(MYFILE *f, INT32 num) } 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, ""); @@ -249,7 +253,7 @@ 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++; @@ -1140,8 +1144,10 @@ void readgametype(MYFILE *f, char *gtname) } if (descr) { - strcpy(gtdescription, descr); - strcat(gtdescription, myhashfgets(descr, sizeof (gtdescription), f)); + strlcpy(gtdescription, descr, sizeof (gtdescription)); + strlcat(gtdescription, + myhashfgets(descr, sizeof (gtdescription), f), + sizeof (gtdescription)); } else strcpy(gtdescription, ""); From f0f3b33d71db97ccf4b747f8962022df3104a18c Mon Sep 17 00:00:00 2001 From: "X.organic" Date: Tue, 6 Apr 2021 03:12:46 +0200 Subject: [PATCH 0679/1080] Edit note_size alias to get rid of warnings --- src/deh_soc.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/deh_soc.c b/src/deh_soc.c index bc7533ee0..72f785eff 100644 --- a/src/deh_soc.c +++ b/src/deh_soc.c @@ -230,9 +230,9 @@ void readPlayer(MYFILE *f, INT32 num) SLOTFOUND // A friendly neighborhood alias for brevity's sake - const size_t note_size = sizeof(description[num].notes); +#define NOTE_SIZE sizeof(description[num].notes) - for (i = 0; i < MAXLINELEN-note_size-3; i++) + for (i = 0; i < (INT32)(MAXLINELEN-NOTE_SIZE-3); i++) { if (s[i] == '=') { @@ -242,9 +242,9 @@ void readPlayer(MYFILE *f, INT32 num) } if (playertext) { - strlcpy(description[num].notes, playertext, note_size); + strlcpy(description[num].notes, playertext, NOTE_SIZE); strlcat(description[num].notes, - myhashfgets(playertext, note_size, f), note_size); + myhashfgets(playertext, NOTE_SIZE, f), NOTE_SIZE); } else strcpy(description[num].notes, ""); @@ -253,7 +253,7 @@ void readPlayer(MYFILE *f, INT32 num) // It works down here, though. { INT32 numline = 0; - for (i = 0; (size_t)i < note_size-1; i++) + for (i = 0; (size_t)i < NOTE_SIZE-1; i++) { if (numline < 20 && description[num].notes[i] == '\n') numline++; @@ -264,6 +264,7 @@ void readPlayer(MYFILE *f, INT32 num) } description[num].notes[strlen(description[num].notes)-1] = '\0'; description[num].notes[i] = '\0'; +#undef NOTE_SIZE continue; } From 6f0b4a4f6d5f129631f7aed997c332afbfe263e0 Mon Sep 17 00:00:00 2001 From: "X.organic" Date: Tue, 6 Apr 2021 03:13:38 +0200 Subject: [PATCH 0680/1080] Remove some dead code from DEH_LoadDehackedFile Also fixes a buffer overflow, but said overflow generally got caught by the stack smashing protector. Still, it's better for SOC files not to be able to crash the game that easily. --- src/dehacked.c | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/src/dehacked.c b/src/dehacked.c index c2ea28d27..3f066a924 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -188,26 +188,11 @@ static void DEH_LoadDehackedFile(MYFILE *f, boolean mainfile) dbg_line = -1; // start at -1 so the first line is 0. while (!myfeof(f)) { - char origpos[128]; - INT32 size = 0; - char *traverse; - myfgets(s, MAXLINELEN, f); memcpy(textline, s, MAXLINELEN); if (s[0] == '\n' || s[0] == '#') continue; - traverse = s; - - while (traverse[0] != '\n') - { - traverse++; - size++; - } - - strncpy(origpos, s, size); - origpos[size] = '\0'; - if (NULL != (word = strtok(s, " "))) { strupr(word); if (word[strlen(word)-1] == '\n') From 23759c67aa402a1f474edc8a8db25196393397e9 Mon Sep 17 00:00:00 2001 From: katsy Date: Mon, 12 Apr 2021 21:26:29 -0500 Subject: [PATCH 0681/1080] move HWR_GetMappedPatch earlier --- src/hardware/hw_main.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index c2d617eaf..5772b67d9 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -4137,6 +4137,11 @@ static void HWR_DrawSprite(gl_vissprite_t *spr) wallVerts[1].z = wallVerts[2].z = spr->z2; } + // cache the patch in the graphics card memory + //12/12/99: Hurdler: same comment as above (for md2) + //Hurdler: 25/04/2000: now support colormap in hardware mode + HWR_GetMappedPatch(gpatch, spr->colormap); + if (spr->flip) { wallVerts[0].s = wallVerts[3].s = ((GLPatch_t *)gpatch->hardware)->max_s; @@ -4156,11 +4161,6 @@ static void HWR_DrawSprite(gl_vissprite_t *spr) wallVerts[0].t = wallVerts[1].t = ((GLPatch_t *)gpatch->hardware)->max_t; } - // cache the patch in the graphics card memory - //12/12/99: Hurdler: same comment as above (for md2) - //Hurdler: 25/04/2000: now support colormap in hardware mode - HWR_GetMappedPatch(gpatch, spr->colormap); - if (!splat) { // if it has a dispoffset, push it a little towards the camera From 0d4d2ed6d8cf25398e6286e0982bbc2795cdb121 Mon Sep 17 00:00:00 2001 From: Jaime Ita Passos Date: Tue, 13 Apr 2021 12:11:31 -0300 Subject: [PATCH 0682/1080] Fix blend tables generation --- src/r_draw.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/r_draw.c b/src/r_draw.c index 8625fbab2..9a835ee58 100644 --- a/src/r_draw.c +++ b/src/r_draw.c @@ -274,7 +274,7 @@ static void BlendTab_Modulative(UINT8 *table) static INT32 BlendTab_Count[NUMBLENDMAPS] = { - NUMTRANSTABLES, // blendtab_add + NUMTRANSTABLES+1, // blendtab_add NUMTRANSTABLES+1, // blendtab_subtract NUMTRANSTABLES+1, // blendtab_reversesubtract 1 // blendtab_modulate @@ -294,7 +294,7 @@ static INT32 BlendTab_FromStyle[] = static void BlendTab_GenerateMaps(INT32 tab, INT32 style, void (*genfunc)(UINT8 *, int, UINT8)) { INT32 i = 0, num = BlendTab_Count[tab]; - const float amtmul = (256.0f / (float)(NUMTRANSTABLES)); + const float amtmul = (256.0f / (float)(NUMTRANSTABLES + 1)); for (; i < num; i++) { const size_t offs = (0x10000 * i); From b3d7df74c085464cc7f3dd3d78da6f54b8804305 Mon Sep 17 00:00:00 2001 From: Jaime Ita Passos Date: Wed, 14 Apr 2021 10:55:52 -0300 Subject: [PATCH 0683/1080] This is my attempted fix for texture rotation on slopes, in Software. --- src/r_draw8.c | 64 +++++++-------- src/r_draw8_npo2.c | 152 +++++++++++++++++----------------- src/r_plane.c | 197 +++++++++++++++++++++++---------------------- src/r_plane.h | 4 +- src/r_splats.c | 3 +- 5 files changed, 212 insertions(+), 208 deletions(-) diff --git a/src/r_draw8.c b/src/r_draw8.c index 1f451115e..5c62b5595 100644 --- a/src/r_draw8.c +++ b/src/r_draw8.c @@ -693,8 +693,8 @@ void R_DrawTiltedSpan_8(void) do { double z = 1.f/iz; - u = (INT64)(uz*z) + viewx; - v = (INT64)(vz*z) + viewy; + u = (INT64)(uz*z); + v = (INT64)(vz*z); colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); @@ -726,8 +726,8 @@ void R_DrawTiltedSpan_8(void) endv = vz*endz; stepu = (INT64)((endu - startu) * INVSPAN); stepv = (INT64)((endv - startv) * INVSPAN); - u = (INT64)(startu) + viewx; - v = (INT64)(startv) + viewy; + u = (INT64)(startu); + v = (INT64)(startv); for (i = SPANSIZE-1; i >= 0; i--) { @@ -763,8 +763,8 @@ void R_DrawTiltedSpan_8(void) left = 1.f/left; stepu = (INT64)((endu - startu) * left); stepv = (INT64)((endv - startv) * left); - u = (INT64)(startu) + viewx; - v = (INT64)(startv) + viewy; + u = (INT64)(startu); + v = (INT64)(startv); for (; width != 0; width--) { @@ -826,8 +826,8 @@ void R_DrawTiltedTranslucentSpan_8(void) do { double z = 1.f/iz; - u = (INT64)(uz*z) + viewx; - v = (INT64)(vz*z) + viewy; + u = (INT64)(uz*z); + v = (INT64)(vz*z); colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); *dest = *(ds_transmap + (colormap[source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)]] << 8) + *dest); @@ -858,8 +858,8 @@ void R_DrawTiltedTranslucentSpan_8(void) endv = vz*endz; stepu = (INT64)((endu - startu) * INVSPAN); stepv = (INT64)((endv - startv) * INVSPAN); - u = (INT64)(startu) + viewx; - v = (INT64)(startv) + viewy; + u = (INT64)(startu); + v = (INT64)(startv); for (i = SPANSIZE-1; i >= 0; i--) { @@ -895,8 +895,8 @@ void R_DrawTiltedTranslucentSpan_8(void) left = 1.f/left; stepu = (INT64)((endu - startu) * left); stepv = (INT64)((endv - startv) * left); - u = (INT64)(startu) + viewx; - v = (INT64)(startv) + viewy; + u = (INT64)(startu); + v = (INT64)(startv); for (; width != 0; width--) { @@ -960,8 +960,8 @@ void R_DrawTiltedTranslucentWaterSpan_8(void) do { double z = 1.f/iz; - u = (INT64)(uz*z) + viewx; - v = (INT64)(vz*z) + viewy; + u = (INT64)(uz*z); + v = (INT64)(vz*z); colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); *dest = *(ds_transmap + (colormap[source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)]] << 8) + *dsrc++); @@ -992,8 +992,8 @@ void R_DrawTiltedTranslucentWaterSpan_8(void) endv = vz*endz; stepu = (INT64)((endu - startu) * INVSPAN); stepv = (INT64)((endv - startv) * INVSPAN); - u = (INT64)(startu) + viewx; - v = (INT64)(startv) + viewy; + u = (INT64)(startu); + v = (INT64)(startv); for (i = SPANSIZE-1; i >= 0; i--) { @@ -1029,8 +1029,8 @@ void R_DrawTiltedTranslucentWaterSpan_8(void) left = 1.f/left; stepu = (INT64)((endu - startu) * left); stepv = (INT64)((endv - startv) * left); - u = (INT64)(startu) + viewx; - v = (INT64)(startv) + viewy; + u = (INT64)(startu); + v = (INT64)(startv); for (; width != 0; width--) { @@ -1091,8 +1091,8 @@ void R_DrawTiltedSplat_8(void) do { double z = 1.f/iz; - u = (INT64)(uz*z) + viewx; - v = (INT64)(vz*z) + viewy; + u = (INT64)(uz*z); + v = (INT64)(vz*z); colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); @@ -1127,8 +1127,8 @@ void R_DrawTiltedSplat_8(void) endv = vz*endz; stepu = (INT64)((endu - startu) * INVSPAN); stepv = (INT64)((endv - startv) * INVSPAN); - u = (INT64)(startu) + viewx; - v = (INT64)(startv) + viewy; + u = (INT64)(startu); + v = (INT64)(startv); for (i = SPANSIZE-1; i >= 0; i--) { @@ -1168,8 +1168,8 @@ void R_DrawTiltedSplat_8(void) left = 1.f/left; stepu = (INT64)((endu - startu) * left); stepv = (INT64)((endv - startv) * left); - u = (INT64)(startu) + viewx; - v = (INT64)(startv) + viewy; + u = (INT64)(startu); + v = (INT64)(startv); for (; width != 0; width--) { @@ -1672,8 +1672,8 @@ void R_DrawTiltedFloorSprite_8(void) endv = vz*endz; stepu = (INT64)((endu - startu) * INVSPAN); stepv = (INT64)((endv - startv) * INVSPAN); - u = (INT64)(startu) + viewx; - v = (INT64)(startv) + viewy; + u = (INT64)(startu); + v = (INT64)(startv); for (i = SPANSIZE-1; i >= 0; i--) { @@ -1712,8 +1712,8 @@ void R_DrawTiltedFloorSprite_8(void) left = 1.f/left; stepu = (INT64)((endu - startu) * left); stepv = (INT64)((endv - startv) * left); - u = (INT64)(startu) + viewx; - v = (INT64)(startv) + viewy; + u = (INT64)(startu); + v = (INT64)(startv); for (; width != 0; width--) { @@ -1781,8 +1781,8 @@ void R_DrawTiltedTranslucentFloorSprite_8(void) endv = vz*endz; stepu = (INT64)((endu - startu) * INVSPAN); stepv = (INT64)((endv - startv) * INVSPAN); - u = (INT64)(startu) + viewx; - v = (INT64)(startv) + viewy; + u = (INT64)(startu); + v = (INT64)(startv); for (i = SPANSIZE-1; i >= 0; i--) { @@ -1821,8 +1821,8 @@ void R_DrawTiltedTranslucentFloorSprite_8(void) left = 1.f/left; stepu = (INT64)((endu - startu) * left); stepv = (INT64)((endv - startv) * left); - u = (INT64)(startu) + viewx; - v = (INT64)(startv) + viewy; + u = (INT64)(startu); + v = (INT64)(startv); for (; width != 0; width--) { diff --git a/src/r_draw8_npo2.c b/src/r_draw8_npo2.c index a34a20e9a..b5614898c 100644 --- a/src/r_draw8_npo2.c +++ b/src/r_draw8_npo2.c @@ -133,15 +133,15 @@ void R_DrawTiltedSpan_NPO2_8(void) do { double z = 1.f/iz; - u = (INT64)(uz*z) + viewx; - v = (INT64)(vz*z) + viewy; + u = (INT64)(uz*z); + v = (INT64)(vz*z); colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); // Lactozilla: Non-powers-of-two { - fixed_t x = (((fixed_t)u-viewx) >> FRACBITS); - fixed_t y = (((fixed_t)v-viewy) >> FRACBITS); + fixed_t x = (((fixed_t)u) >> FRACBITS); + fixed_t y = (((fixed_t)v) >> FRACBITS); // Carefully align all of my Friends. if (x < 0) @@ -181,16 +181,16 @@ void R_DrawTiltedSpan_NPO2_8(void) endv = vz*endz; stepu = (INT64)((endu - startu) * INVSPAN); stepv = (INT64)((endv - startv) * INVSPAN); - u = (INT64)(startu) + viewx; - v = (INT64)(startv) + viewy; + u = (INT64)(startu); + v = (INT64)(startv); for (i = SPANSIZE-1; i >= 0; i--) { colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); // Lactozilla: Non-powers-of-two { - fixed_t x = (((fixed_t)u-viewx) >> FRACBITS); - fixed_t y = (((fixed_t)v-viewy) >> FRACBITS); + fixed_t x = (((fixed_t)u) >> FRACBITS); + fixed_t y = (((fixed_t)v) >> FRACBITS); // Carefully align all of my Friends. if (x < 0) @@ -220,8 +220,8 @@ void R_DrawTiltedSpan_NPO2_8(void) colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); // Lactozilla: Non-powers-of-two { - fixed_t x = (((fixed_t)u-viewx) >> FRACBITS); - fixed_t y = (((fixed_t)v-viewy) >> FRACBITS); + fixed_t x = (((fixed_t)u) >> FRACBITS); + fixed_t y = (((fixed_t)v) >> FRACBITS); // Carefully align all of my Friends. if (x < 0) @@ -248,16 +248,16 @@ void R_DrawTiltedSpan_NPO2_8(void) left = 1.f/left; stepu = (INT64)((endu - startu) * left); stepv = (INT64)((endv - startv) * left); - u = (INT64)(startu) + viewx; - v = (INT64)(startv) + viewy; + u = (INT64)(startu); + v = (INT64)(startv); for (; width != 0; width--) { colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); // Lactozilla: Non-powers-of-two { - fixed_t x = (((fixed_t)u-viewx) >> FRACBITS); - fixed_t y = (((fixed_t)v-viewy) >> FRACBITS); + fixed_t x = (((fixed_t)u) >> FRACBITS); + fixed_t y = (((fixed_t)v) >> FRACBITS); // Carefully align all of my Friends. if (x < 0) @@ -326,14 +326,14 @@ void R_DrawTiltedTranslucentSpan_NPO2_8(void) do { double z = 1.f/iz; - u = (INT64)(uz*z) + viewx; - v = (INT64)(vz*z) + viewy; + u = (INT64)(uz*z); + v = (INT64)(vz*z); colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); // Lactozilla: Non-powers-of-two { - fixed_t x = (((fixed_t)u-viewx) >> FRACBITS); - fixed_t y = (((fixed_t)v-viewy) >> FRACBITS); + fixed_t x = (((fixed_t)u) >> FRACBITS); + fixed_t y = (((fixed_t)v) >> FRACBITS); // Carefully align all of my Friends. if (x < 0) @@ -373,16 +373,16 @@ void R_DrawTiltedTranslucentSpan_NPO2_8(void) endv = vz*endz; stepu = (INT64)((endu - startu) * INVSPAN); stepv = (INT64)((endv - startv) * INVSPAN); - u = (INT64)(startu) + viewx; - v = (INT64)(startv) + viewy; + u = (INT64)(startu); + v = (INT64)(startv); for (i = SPANSIZE-1; i >= 0; i--) { colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); // Lactozilla: Non-powers-of-two { - fixed_t x = (((fixed_t)u-viewx) >> FRACBITS); - fixed_t y = (((fixed_t)v-viewy) >> FRACBITS); + fixed_t x = (((fixed_t)u) >> FRACBITS); + fixed_t y = (((fixed_t)v) >> FRACBITS); // Carefully align all of my Friends. if (x < 0) @@ -412,8 +412,8 @@ void R_DrawTiltedTranslucentSpan_NPO2_8(void) colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); // Lactozilla: Non-powers-of-two { - fixed_t x = (((fixed_t)u-viewx) >> FRACBITS); - fixed_t y = (((fixed_t)v-viewy) >> FRACBITS); + fixed_t x = (((fixed_t)u) >> FRACBITS); + fixed_t y = (((fixed_t)v) >> FRACBITS); // Carefully align all of my Friends. if (x < 0) @@ -440,16 +440,16 @@ void R_DrawTiltedTranslucentSpan_NPO2_8(void) left = 1.f/left; stepu = (INT64)((endu - startu) * left); stepv = (INT64)((endv - startv) * left); - u = (INT64)(startu) + viewx; - v = (INT64)(startv) + viewy; + u = (INT64)(startu); + v = (INT64)(startv); for (; width != 0; width--) { colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); // Lactozilla: Non-powers-of-two { - fixed_t x = (((fixed_t)u-viewx) >> FRACBITS); - fixed_t y = (((fixed_t)v-viewy) >> FRACBITS); + fixed_t x = (((fixed_t)u) >> FRACBITS); + fixed_t y = (((fixed_t)v) >> FRACBITS); // Carefully align all of my Friends. if (x < 0) @@ -517,15 +517,15 @@ void R_DrawTiltedSplat_NPO2_8(void) do { double z = 1.f/iz; - u = (INT64)(uz*z) + viewx; - v = (INT64)(vz*z) + viewy; + u = (INT64)(uz*z); + v = (INT64)(vz*z); colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); // Lactozilla: Non-powers-of-two { - fixed_t x = (((fixed_t)u-viewx) >> FRACBITS); - fixed_t y = (((fixed_t)v-viewy) >> FRACBITS); + fixed_t x = (((fixed_t)u) >> FRACBITS); + fixed_t y = (((fixed_t)v) >> FRACBITS); // Carefully align all of my Friends. if (x < 0) @@ -569,16 +569,16 @@ void R_DrawTiltedSplat_NPO2_8(void) endv = vz*endz; stepu = (INT64)((endu - startu) * INVSPAN); stepv = (INT64)((endv - startv) * INVSPAN); - u = (INT64)(startu) + viewx; - v = (INT64)(startv) + viewy; + u = (INT64)(startu); + v = (INT64)(startv); for (i = SPANSIZE-1; i >= 0; i--) { colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); // Lactozilla: Non-powers-of-two { - fixed_t x = (((fixed_t)u-viewx) >> FRACBITS); - fixed_t y = (((fixed_t)v-viewy) >> FRACBITS); + fixed_t x = (((fixed_t)u) >> FRACBITS); + fixed_t y = (((fixed_t)v) >> FRACBITS); // Carefully align all of my Friends. if (x < 0) @@ -610,8 +610,8 @@ void R_DrawTiltedSplat_NPO2_8(void) colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); // Lactozilla: Non-powers-of-two { - fixed_t x = (((fixed_t)u-viewx) >> FRACBITS); - fixed_t y = (((fixed_t)v-viewy) >> FRACBITS); + fixed_t x = (((fixed_t)u) >> FRACBITS); + fixed_t y = (((fixed_t)v) >> FRACBITS); // Carefully align all of my Friends. if (x < 0) @@ -640,8 +640,8 @@ void R_DrawTiltedSplat_NPO2_8(void) left = 1.f/left; stepu = (INT64)((endu - startu) * left); stepv = (INT64)((endv - startv) * left); - u = (INT64)(startu) + viewx; - v = (INT64)(startv) + viewy; + u = (INT64)(startu); + v = (INT64)(startv); for (; width != 0; width--) { @@ -649,8 +649,8 @@ void R_DrawTiltedSplat_NPO2_8(void) val = source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)]; // Lactozilla: Non-powers-of-two { - fixed_t x = (((fixed_t)u-viewx) >> FRACBITS); - fixed_t y = (((fixed_t)v-viewy) >> FRACBITS); + fixed_t x = (((fixed_t)u) >> FRACBITS); + fixed_t y = (((fixed_t)v) >> FRACBITS); // Carefully align all of my Friends. if (x < 0) @@ -1002,14 +1002,14 @@ void R_DrawTiltedFloorSprite_NPO2_8(void) endv = vz*endz; stepu = (INT64)((endu - startu) * INVSPAN); stepv = (INT64)((endv - startv) * INVSPAN); - u = (INT64)(startu) + viewx; - v = (INT64)(startv) + viewy; + u = (INT64)(startu); + v = (INT64)(startv); for (i = SPANSIZE-1; i >= 0; i--) { // Lactozilla: Non-powers-of-two - fixed_t x = (((fixed_t)u-viewx) >> FRACBITS); - fixed_t y = (((fixed_t)v-viewy) >> FRACBITS); + fixed_t x = (((fixed_t)u) >> FRACBITS); + fixed_t y = (((fixed_t)v) >> FRACBITS); // Carefully align all of my Friends. if (x < 0) @@ -1040,8 +1040,8 @@ void R_DrawTiltedFloorSprite_NPO2_8(void) v = (INT64)(startv); // Lactozilla: Non-powers-of-two { - fixed_t x = (((fixed_t)u-viewx) >> FRACBITS); - fixed_t y = (((fixed_t)v-viewy) >> FRACBITS); + fixed_t x = (((fixed_t)u) >> FRACBITS); + fixed_t y = (((fixed_t)v) >> FRACBITS); // Carefully align all of my Friends. if (x < 0) @@ -1070,14 +1070,14 @@ void R_DrawTiltedFloorSprite_NPO2_8(void) left = 1.f/left; stepu = (INT64)((endu - startu) * left); stepv = (INT64)((endv - startv) * left); - u = (INT64)(startu) + viewx; - v = (INT64)(startv) + viewy; + u = (INT64)(startu); + v = (INT64)(startv); for (; width != 0; width--) { // Lactozilla: Non-powers-of-two - fixed_t x = (((fixed_t)u-viewx) >> FRACBITS); - fixed_t y = (((fixed_t)v-viewy) >> FRACBITS); + fixed_t x = (((fixed_t)u) >> FRACBITS); + fixed_t y = (((fixed_t)v) >> FRACBITS); // Carefully align all of my Friends. if (x < 0) @@ -1152,14 +1152,14 @@ void R_DrawTiltedTranslucentFloorSprite_NPO2_8(void) endv = vz*endz; stepu = (INT64)((endu - startu) * INVSPAN); stepv = (INT64)((endv - startv) * INVSPAN); - u = (INT64)(startu) + viewx; - v = (INT64)(startv) + viewy; + u = (INT64)(startu); + v = (INT64)(startv); for (i = SPANSIZE-1; i >= 0; i--) { // Lactozilla: Non-powers-of-two - fixed_t x = (((fixed_t)u-viewx) >> FRACBITS); - fixed_t y = (((fixed_t)v-viewy) >> FRACBITS); + fixed_t x = (((fixed_t)u) >> FRACBITS); + fixed_t y = (((fixed_t)v) >> FRACBITS); // Carefully align all of my Friends. if (x < 0) @@ -1190,8 +1190,8 @@ void R_DrawTiltedTranslucentFloorSprite_NPO2_8(void) v = (INT64)(startv); // Lactozilla: Non-powers-of-two { - fixed_t x = (((fixed_t)u-viewx) >> FRACBITS); - fixed_t y = (((fixed_t)v-viewy) >> FRACBITS); + fixed_t x = (((fixed_t)u) >> FRACBITS); + fixed_t y = (((fixed_t)v) >> FRACBITS); // Carefully align all of my Friends. if (x < 0) @@ -1220,14 +1220,14 @@ void R_DrawTiltedTranslucentFloorSprite_NPO2_8(void) left = 1.f/left; stepu = (INT64)((endu - startu) * left); stepv = (INT64)((endv - startv) * left); - u = (INT64)(startu) + viewx; - v = (INT64)(startv) + viewy; + u = (INT64)(startu); + v = (INT64)(startv); for (; width != 0; width--) { // Lactozilla: Non-powers-of-two - fixed_t x = (((fixed_t)u-viewx) >> FRACBITS); - fixed_t y = (((fixed_t)v-viewy) >> FRACBITS); + fixed_t x = (((fixed_t)u) >> FRACBITS); + fixed_t y = (((fixed_t)v) >> FRACBITS); // Carefully align all of my Friends. if (x < 0) @@ -1429,14 +1429,14 @@ void R_DrawTiltedTranslucentWaterSpan_NPO2_8(void) do { double z = 1.f/iz; - u = (INT64)(uz*z) + viewx; - v = (INT64)(vz*z) + viewy; + u = (INT64)(uz*z); + v = (INT64)(vz*z); colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); // Lactozilla: Non-powers-of-two { - fixed_t x = (((fixed_t)u-viewx) >> FRACBITS); - fixed_t y = (((fixed_t)v-viewy) >> FRACBITS); + fixed_t x = (((fixed_t)u) >> FRACBITS); + fixed_t y = (((fixed_t)v) >> FRACBITS); // Carefully align all of my Friends. if (x < 0) @@ -1476,16 +1476,16 @@ void R_DrawTiltedTranslucentWaterSpan_NPO2_8(void) endv = vz*endz; stepu = (INT64)((endu - startu) * INVSPAN); stepv = (INT64)((endv - startv) * INVSPAN); - u = (INT64)(startu) + viewx; - v = (INT64)(startv) + viewy; + u = (INT64)(startu); + v = (INT64)(startv); for (i = SPANSIZE-1; i >= 0; i--) { colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); // Lactozilla: Non-powers-of-two { - fixed_t x = (((fixed_t)u-viewx) >> FRACBITS); - fixed_t y = (((fixed_t)v-viewy) >> FRACBITS); + fixed_t x = (((fixed_t)u) >> FRACBITS); + fixed_t y = (((fixed_t)v) >> FRACBITS); // Carefully align all of my Friends. if (x < 0) @@ -1515,8 +1515,8 @@ void R_DrawTiltedTranslucentWaterSpan_NPO2_8(void) colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); // Lactozilla: Non-powers-of-two { - fixed_t x = (((fixed_t)u-viewx) >> FRACBITS); - fixed_t y = (((fixed_t)v-viewy) >> FRACBITS); + fixed_t x = (((fixed_t)u) >> FRACBITS); + fixed_t y = (((fixed_t)v) >> FRACBITS); // Carefully align all of my Friends. if (x < 0) @@ -1543,16 +1543,16 @@ void R_DrawTiltedTranslucentWaterSpan_NPO2_8(void) left = 1.f/left; stepu = (INT64)((endu - startu) * left); stepv = (INT64)((endv - startv) * left); - u = (INT64)(startu) + viewx; - v = (INT64)(startv) + viewy; + u = (INT64)(startu); + v = (INT64)(startv); for (; width != 0; width--) { colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); // Lactozilla: Non-powers-of-two { - fixed_t x = (((fixed_t)u-viewx) >> FRACBITS); - fixed_t y = (((fixed_t)v-viewy) >> FRACBITS); + fixed_t x = (((fixed_t)u) >> FRACBITS); + fixed_t y = (((fixed_t)v) >> FRACBITS); // Carefully align all of my Friends. if (x < 0) diff --git a/src/r_plane.c b/src/r_plane.c index ea4dfa4e8..a936b0911 100644 --- a/src/r_plane.c +++ b/src/r_plane.c @@ -104,6 +104,7 @@ fixed_t cachedxstep[MAXVIDHEIGHT]; fixed_t cachedystep[MAXVIDHEIGHT]; static fixed_t xoffs, yoffs; +static floatv3_t ds_slope_origin, ds_slope_u, ds_slope_v; // // R_InitPlanes @@ -662,69 +663,91 @@ static void R_DrawSkyPlane(visplane_t *pl) } } -// Potentially override other stuff for now cus we're mean. :< But draw a slope plane! -// I copied ZDoom's code and adapted it to SRB2... -Red -void R_CalculateSlopeVectors(pslope_t *slope, fixed_t planeviewx, fixed_t planeviewy, fixed_t planeviewz, fixed_t planexscale, fixed_t planeyscale, fixed_t planexoffset, fixed_t planeyoffset, angle_t planeviewangle, angle_t planeangle, float fudge) +// Sets the origin vector of the sloped plane. +static void R_SetSlopePlaneOrigin(pslope_t *slope, fixed_t xpos, fixed_t ypos, fixed_t zpos, fixed_t xoff, fixed_t yoff, fixed_t angle) { - floatv3_t p, m, n; - float ang; - float vx, vy, vz; - float xscale = FIXED_TO_FLOAT(planexscale); - float yscale = FIXED_TO_FLOAT(planeyscale); - // compiler complains when P_GetSlopeZAt is used in FLOAT_TO_FIXED directly - // use this as a temp var to store P_GetSlopeZAt's return value each time - fixed_t temp; + floatv3_t *p = &ds_slope_origin; - vx = FIXED_TO_FLOAT(planeviewx+planexoffset); - vy = FIXED_TO_FLOAT(planeviewy-planeyoffset); - vz = FIXED_TO_FLOAT(planeviewz); + float vx = FixedToFloat(xpos + xoff); + float vy = FixedToFloat(ypos - yoff); + float vz = FixedToFloat(zpos); + float ang = ANG2RAD(ANGLE_270 - angle); - temp = P_GetSlopeZAt(slope, planeviewx, planeviewy); - zeroheight = FIXED_TO_FLOAT(temp); + zeroheight = FixedToFloat(P_GetSlopeZAt(slope, xpos, ypos)); // p is the texture origin in view space // Don't add in the offsets at this stage, because doing so can result in // errors if the flat is rotated. - ang = ANG2RAD(ANGLE_270 - planeviewangle); - p.x = vx * cos(ang) - vy * sin(ang); - p.z = vx * sin(ang) + vy * cos(ang); - temp = P_GetSlopeZAt(slope, -planexoffset, planeyoffset); - p.y = FIXED_TO_FLOAT(temp) - vz; + p->x = vx * cos(ang) - vy * sin(ang); + p->z = vx * sin(ang) + vy * cos(ang); + p->y = FixedToFloat(P_GetSlopeZAt(slope, -xoff, yoff)) - vz; +} + +// This function calculates all of the vectors necessary for drawing a tilted span. +void R_SetSlopePlane(pslope_t *slope, fixed_t xpos, fixed_t ypos, fixed_t zpos, fixed_t xoff, fixed_t yoff, angle_t angle, angle_t plangle) +{ + // Potentially override other stuff for now cus we're mean. :< But draw a slope plane! + // I copied ZDoom's code and adapted it to SRB2... -Red + floatv3_t *m = &ds_slope_v, *n = &ds_slope_u; + fixed_t temp; + float ang; + + R_SetSlopePlaneOrigin(slope, xpos, ypos, zpos, xoff, yoff, angle); // m is the v direction vector in view space - ang = ANG2RAD(ANGLE_180 - (planeviewangle + planeangle)); - m.x = yscale * cos(ang); - m.z = yscale * sin(ang); + ang = ANG2RAD(ANGLE_180 - (angle + plangle)); + m->x = cos(ang); + m->z = sin(ang); // n is the u direction vector in view space - n.x = xscale * sin(ang); - n.z = -xscale * cos(ang); + n->x = sin(ang); + n->z = -cos(ang); - ang = ANG2RAD(planeangle); - temp = P_GetSlopeZAt(slope, planeviewx + FLOAT_TO_FIXED(yscale * sin(ang)), planeviewy + FLOAT_TO_FIXED(yscale * cos(ang))); - m.y = FIXED_TO_FLOAT(temp) - zeroheight; - temp = P_GetSlopeZAt(slope, planeviewx + FLOAT_TO_FIXED(xscale * cos(ang)), planeviewy - FLOAT_TO_FIXED(xscale * sin(ang))); - n.y = FIXED_TO_FLOAT(temp) - zeroheight; + ang = ANG2RAD(plangle); + temp = P_GetSlopeZAt(slope, xpos + FloatToFixed(sin(ang)), ypos + FloatToFixed(cos(ang))); + m->y = FixedToFloat(temp) - zeroheight; + temp = P_GetSlopeZAt(slope, xpos + FloatToFixed(cos(ang)), ypos - FloatToFixed(sin(ang))); + n->y = FixedToFloat(temp) - zeroheight; +} - if (ds_powersoftwo) - { - m.x /= fudge; - m.y /= fudge; - m.z /= fudge; +// This function calculates all of the vectors necessary for drawing a scaled, tilted span. +void R_SetSlopePlaneScaled(pslope_t *slope, fixed_t xpos, fixed_t ypos, fixed_t zpos, fixed_t xs, fixed_t ys, fixed_t xoff, fixed_t yoff, angle_t angle, angle_t plangle) +{ + floatv3_t *m = &ds_slope_v, *n = &ds_slope_u; + fixed_t temp; - n.x *= fudge; - n.y *= fudge; - n.z *= fudge; - } + float xscale = FixedToFloat(xs); + float yscale = FixedToFloat(ys); + float ang; + R_SetSlopePlaneOrigin(slope, xpos, ypos, zpos, xoff, yoff, angle); + + // m is the v direction vector in view space + ang = ANG2RAD(ANGLE_180 - (angle + plangle)); + m->x = yscale * cos(ang); + m->z = yscale * sin(ang); + + // n is the u direction vector in view space + n->x = xscale * sin(ang); + n->z = -xscale * cos(ang); + + ang = ANG2RAD(plangle); + temp = P_GetSlopeZAt(slope, xpos + FloatToFixed(yscale * sin(ang)), ypos + FloatToFixed(yscale * cos(ang))); + m->y = FixedToFloat(temp) - zeroheight; + temp = P_GetSlopeZAt(slope, xpos + FloatToFixed(xscale * cos(ang)), ypos - FloatToFixed(xscale * sin(ang))); + n->y = FixedToFloat(temp) - zeroheight; +} + +void R_CalculateSlopeVectors(void) +{ // Eh. I tried making this stuff fixed-point and it exploded on me. Here's a macro for the only floating-point vector function I recall using. #define CROSS(d, v1, v2) \ d->x = (v1.y * v2.z) - (v1.z * v2.y);\ d->y = (v1.z * v2.x) - (v1.x * v2.z);\ d->z = (v1.x * v2.y) - (v1.y * v2.x) - CROSS(ds_sup, p, m); - CROSS(ds_svp, p, n); - CROSS(ds_szp, m, n); + CROSS(ds_sup, ds_slope_origin, ds_slope_v); + CROSS(ds_svp, ds_slope_origin, ds_slope_u); + CROSS(ds_szp, ds_slope_v, ds_slope_u); #undef CROSS ds_sup->z *= focallengthf; @@ -769,10 +792,11 @@ void R_SetTiltedSpan(INT32 span) ds_szp = &ds_sz[span]; } -static void R_SetSlopePlaneVectors(visplane_t *pl, INT32 y, fixed_t xoff, fixed_t yoff, float fudge) +static void R_SetSlopePlaneVectors(visplane_t *pl, INT32 y, fixed_t xoff, fixed_t yoff) { R_SetTiltedSpan(y); - R_CalculateSlopeVectors(pl->slope, pl->viewx, pl->viewy, pl->viewz, FRACUNIT, FRACUNIT, xoff, yoff, pl->viewangle, pl->plangle, fudge); + R_SetSlopePlane(pl->slope, pl->viewx, pl->viewy, pl->viewz, xoff, yoff, pl->viewangle, pl->plangle); + R_CalculateSlopeVectors(); } void R_DrawSinglePlane(visplane_t *pl) @@ -782,8 +806,8 @@ void R_DrawSinglePlane(visplane_t *pl) INT32 x; INT32 stop, angle; ffloor_t *rover; - int type; - int spanfunctype = BASEDRAWFUNC; + INT32 type; + INT32 spanfunctype = BASEDRAWFUNC; if (!(pl->minx <= pl->maxx)) return; @@ -953,61 +977,38 @@ void R_DrawSinglePlane(visplane_t *pl) if (pl->slope) { - float fudgecanyon = 0; - angle_t hack = (pl->plangle & (ANGLE_90-1)); + const fixed_t modmaskw = (ds_flatwidth << FRACBITS) - 1; + const fixed_t modmaskh = (ds_flatheight << FRACBITS) - 1; - yoffs *= 1; + /* + Essentially: We can't & the components along the regular axes when the plane is rotated. + This is because the distance on each regular axis in order to loop is different. + We rotate them, & the components, add them together, & them again, and then rotate them back. + These three seperate & operations are done per axis in order to prevent overflows. + toast 10/04/17 + */ + const fixed_t cosinecomponent = FINECOSINE(pl->plangle>>ANGLETOFINESHIFT); + const fixed_t sinecomponent = FINESINE(pl->plangle>>ANGLETOFINESHIFT); - if (ds_powersoftwo) - { - fixed_t temp; - // Okay, look, don't ask me why this works, but without this setup there's a disgusting-looking misalignment with the textures. -Red - fudgecanyon = ((1<>ANGLETOFINESHIFT); - const fixed_t sinecomponent = FINESINE(hack>>ANGLETOFINESHIFT); + fixed_t ox = (FixedMul(pl->slope->o.x,cosinecomponent) & modmaskw) - (FixedMul(pl->slope->o.y,sinecomponent) & modmaskh); + fixed_t oy = (-FixedMul(pl->slope->o.x,sinecomponent) & modmaskw) - (FixedMul(pl->slope->o.y,cosinecomponent) & modmaskh); - const fixed_t modmask = ((1 << (32-nflatshiftup)) - 1); + fixed_t temp = ox & modmaskw; + oy &= modmaskh; + ox = FixedMul(temp,cosinecomponent)+FixedMul(oy,-sinecomponent); // negative sine for opposite direction + oy = -FixedMul(temp,-sinecomponent)+FixedMul(oy,cosinecomponent); - fixed_t ox = (FixedMul(pl->slope->o.x,cosinecomponent) & modmask) - (FixedMul(pl->slope->o.y,sinecomponent) & modmask); - fixed_t oy = (-FixedMul(pl->slope->o.x,sinecomponent) & modmask) - (FixedMul(pl->slope->o.y,cosinecomponent) & modmask); + temp = xoffs; + xoffs = (FixedMul(temp,cosinecomponent) & modmaskw) + (FixedMul(yoffs,sinecomponent) & modmaskh); + yoffs = (-FixedMul(temp,sinecomponent) & modmaskw) + (FixedMul(yoffs,cosinecomponent) & modmaskh); - temp = ox & modmask; - oy &= modmask; - ox = FixedMul(temp,cosinecomponent)+FixedMul(oy,-sinecomponent); // negative sine for opposite direction - oy = -FixedMul(temp,-sinecomponent)+FixedMul(oy,cosinecomponent); + temp = xoffs & modmaskw; + yoffs &= modmaskh; + xoffs = FixedMul(temp,cosinecomponent)+FixedMul(yoffs,-sinecomponent); // ditto + yoffs = -FixedMul(temp,-sinecomponent)+FixedMul(yoffs,cosinecomponent); - temp = xoffs; - xoffs = (FixedMul(temp,cosinecomponent) & modmask) + (FixedMul(yoffs,sinecomponent) & modmask); - yoffs = (-FixedMul(temp,sinecomponent) & modmask) + (FixedMul(yoffs,cosinecomponent) & modmask); - - temp = xoffs & modmask; - yoffs &= modmask; - xoffs = FixedMul(temp,cosinecomponent)+FixedMul(yoffs,-sinecomponent); // ditto - yoffs = -FixedMul(temp,-sinecomponent)+FixedMul(yoffs,cosinecomponent); - - xoffs -= (pl->slope->o.x - ox); - yoffs += (pl->slope->o.y + oy); - } - else - { - xoffs &= ((1 << (32-nflatshiftup))-1); - yoffs &= ((1 << (32-nflatshiftup))-1); - xoffs -= (pl->slope->o.x + (1 << (31-nflatshiftup))) & ~((1 << (32-nflatshiftup))-1); - yoffs += (pl->slope->o.y + (1 << (31-nflatshiftup))) & ~((1 << (32-nflatshiftup))-1); - } - - xoffs = (fixed_t)(xoffs*fudgecanyon); - yoffs = (fixed_t)(yoffs/fudgecanyon); - } + xoffs -= (pl->slope->o.x - ox); + yoffs += (pl->slope->o.y + oy); if (planeripple.active) { @@ -1018,11 +1019,11 @@ void R_DrawSinglePlane(visplane_t *pl) for (x = pl->high; x < pl->low; x++) { R_CalculatePlaneRipple(pl, x, plheight, true); - R_SetSlopePlaneVectors(pl, x, (xoffs + planeripple.xfrac), (yoffs + planeripple.yfrac), fudgecanyon); + R_SetSlopePlaneVectors(pl, x, (xoffs + planeripple.xfrac), (yoffs + planeripple.yfrac)); } } else - R_SetSlopePlaneVectors(pl, 0, xoffs, yoffs, fudgecanyon); + R_SetSlopePlaneVectors(pl, 0, xoffs, yoffs); switch (spanfunctype) { diff --git a/src/r_plane.h b/src/r_plane.h index 0d11c5b72..8f7574744 100644 --- a/src/r_plane.h +++ b/src/r_plane.h @@ -94,7 +94,9 @@ boolean R_CheckPowersOfTwo(void); void R_DrawSinglePlane(visplane_t *pl); // Calculates the slope vectors needed for tilted span drawing. -void R_CalculateSlopeVectors(pslope_t *slope, fixed_t planeviewx, fixed_t planeviewy, fixed_t planeviewz, fixed_t planexscale, fixed_t planeyscale, fixed_t planexoffset, fixed_t planeyoffset, angle_t planeviewangle, angle_t planeangle, float fudge); +void R_SetSlopePlane(pslope_t *slope, fixed_t xpos, fixed_t ypos, fixed_t zpos, fixed_t xoff, fixed_t yoff, angle_t angle, angle_t plangle); +void R_SetSlopePlaneScaled(pslope_t *slope, fixed_t xpos, fixed_t ypos, fixed_t zpos, fixed_t xs, fixed_t ys, fixed_t xoff, fixed_t yoff, angle_t angle, angle_t plangle); +void R_CalculateSlopeVectors(void); // Sets the slope vector pointers for the current tilted span. void R_SetTiltedSpan(INT32 span); diff --git a/src/r_splats.c b/src/r_splats.c index 72cac9fd9..49b66304b 100644 --- a/src/r_splats.c +++ b/src/r_splats.c @@ -419,7 +419,8 @@ static void R_RasterizeFloorSplat(floorsplat_t *pSplat, vector2_t *verts, visspr if (pSplat->tilted) { R_SetTiltedSpan(0); - R_CalculateSlopeVectors(&pSplat->slope, viewx, viewy, viewz, pSplat->xscale, pSplat->yscale, -pSplat->verts[0].x, pSplat->verts[0].y, vis->viewangle, pSplat->angle, 1.0f); + R_SetSlopePlaneScaled(&pSplat->slope, viewx, viewy, viewz, pSplat->xscale, pSplat->yscale, -pSplat->verts[0].x, pSplat->verts[0].y, vis->viewangle, pSplat->angle); + R_CalculateSlopeVectors(); spanfunctype = SPANDRAWFUNC_TILTEDSPRITE; } else From d5e9005dd0f49b66e7fa384eaaa6360e535638f1 Mon Sep 17 00:00:00 2001 From: Jaime Ita Passos Date: Wed, 14 Apr 2021 11:34:36 -0300 Subject: [PATCH 0684/1080] Fix NPOT flats, other minor changes. --- src/r_plane.c | 42 ++++++++++++++++-------------------------- src/r_plane.h | 2 +- src/r_splats.c | 2 +- 3 files changed, 18 insertions(+), 28 deletions(-) diff --git a/src/r_plane.c b/src/r_plane.c index a936b0911..10d87b9cc 100644 --- a/src/r_plane.c +++ b/src/r_plane.c @@ -663,7 +663,7 @@ static void R_DrawSkyPlane(visplane_t *pl) } } -// Sets the origin vector of the sloped plane. +// Sets the texture origin vector of the sloped plane. static void R_SetSlopePlaneOrigin(pslope_t *slope, fixed_t xpos, fixed_t ypos, fixed_t zpos, fixed_t xoff, fixed_t yoff, fixed_t angle) { floatv3_t *p = &ds_slope_origin; @@ -683,7 +683,7 @@ static void R_SetSlopePlaneOrigin(pslope_t *slope, fixed_t xpos, fixed_t ypos, f p->y = FixedToFloat(P_GetSlopeZAt(slope, -xoff, yoff)) - vz; } -// This function calculates all of the vectors necessary for drawing a tilted span. +// This function calculates all of the vectors necessary for drawing a sloped plane. void R_SetSlopePlane(pslope_t *slope, fixed_t xpos, fixed_t ypos, fixed_t zpos, fixed_t xoff, fixed_t yoff, angle_t angle, angle_t plangle) { // Potentially override other stuff for now cus we're mean. :< But draw a slope plane! @@ -710,8 +710,8 @@ void R_SetSlopePlane(pslope_t *slope, fixed_t xpos, fixed_t ypos, fixed_t zpos, n->y = FixedToFloat(temp) - zeroheight; } -// This function calculates all of the vectors necessary for drawing a scaled, tilted span. -void R_SetSlopePlaneScaled(pslope_t *slope, fixed_t xpos, fixed_t ypos, fixed_t zpos, fixed_t xs, fixed_t ys, fixed_t xoff, fixed_t yoff, angle_t angle, angle_t plangle) +// This function calculates all of the vectors necessary for drawing a sloped and scaled plane. +void R_SetScaledSlopePlane(pslope_t *slope, fixed_t xpos, fixed_t ypos, fixed_t zpos, fixed_t xs, fixed_t ys, fixed_t xoff, fixed_t yoff, angle_t angle, angle_t plangle) { floatv3_t *m = &ds_slope_v, *n = &ds_slope_u; fixed_t temp; @@ -740,6 +740,8 @@ void R_SetSlopePlaneScaled(pslope_t *slope, fixed_t xpos, fixed_t ypos, fixed_t void R_CalculateSlopeVectors(void) { + float sfmult = 65536.f; + // Eh. I tried making this stuff fixed-point and it exploded on me. Here's a macro for the only floating-point vector function I recall using. #define CROSS(d, v1, v2) \ d->x = (v1.y * v2.z) - (v1.z * v2.y);\ @@ -755,27 +757,15 @@ d->z = (v1.x * v2.y) - (v1.y * v2.x) ds_szp->z *= focallengthf; // Premultiply the texture vectors with the scale factors -#define SFMULT 65536.f if (ds_powersoftwo) - { - ds_sup->x *= (SFMULT * (1<y *= (SFMULT * (1<z *= (SFMULT * (1<x *= (SFMULT * (1<y *= (SFMULT * (1<z *= (SFMULT * (1<x *= SFMULT; - ds_sup->y *= SFMULT; - ds_sup->z *= SFMULT; - ds_svp->x *= SFMULT; - ds_svp->y *= SFMULT; - ds_svp->z *= SFMULT; - } -#undef SFMULT + sfmult *= (1 << nflatshiftup); + + ds_sup->x *= sfmult; + ds_sup->y *= sfmult; + ds_sup->z *= sfmult; + ds_svp->x *= sfmult; + ds_svp->y *= sfmult; + ds_svp->z *= sfmult; } void R_SetTiltedSpan(INT32 span) @@ -977,8 +967,8 @@ void R_DrawSinglePlane(visplane_t *pl) if (pl->slope) { - const fixed_t modmaskw = (ds_flatwidth << FRACBITS) - 1; - const fixed_t modmaskh = (ds_flatheight << FRACBITS) - 1; + const fixed_t modmaskw = (ds_powersoftwo) ? (ds_flatwidth << FRACBITS) - 1 : (signed)(0xFFFFFFFF); + const fixed_t modmaskh = (ds_powersoftwo) ? (ds_flatheight << FRACBITS) - 1 : (signed)(0xFFFFFFFF); /* Essentially: We can't & the components along the regular axes when the plane is rotated. diff --git a/src/r_plane.h b/src/r_plane.h index 8f7574744..9b7e31e3e 100644 --- a/src/r_plane.h +++ b/src/r_plane.h @@ -95,7 +95,7 @@ void R_DrawSinglePlane(visplane_t *pl); // Calculates the slope vectors needed for tilted span drawing. void R_SetSlopePlane(pslope_t *slope, fixed_t xpos, fixed_t ypos, fixed_t zpos, fixed_t xoff, fixed_t yoff, angle_t angle, angle_t plangle); -void R_SetSlopePlaneScaled(pslope_t *slope, fixed_t xpos, fixed_t ypos, fixed_t zpos, fixed_t xs, fixed_t ys, fixed_t xoff, fixed_t yoff, angle_t angle, angle_t plangle); +void R_SetScaledSlopePlane(pslope_t *slope, fixed_t xpos, fixed_t ypos, fixed_t zpos, fixed_t xs, fixed_t ys, fixed_t xoff, fixed_t yoff, angle_t angle, angle_t plangle); void R_CalculateSlopeVectors(void); // Sets the slope vector pointers for the current tilted span. diff --git a/src/r_splats.c b/src/r_splats.c index 49b66304b..4783fb640 100644 --- a/src/r_splats.c +++ b/src/r_splats.c @@ -419,7 +419,7 @@ static void R_RasterizeFloorSplat(floorsplat_t *pSplat, vector2_t *verts, visspr if (pSplat->tilted) { R_SetTiltedSpan(0); - R_SetSlopePlaneScaled(&pSplat->slope, viewx, viewy, viewz, pSplat->xscale, pSplat->yscale, -pSplat->verts[0].x, pSplat->verts[0].y, vis->viewangle, pSplat->angle); + R_SetScaledSlopePlane(&pSplat->slope, viewx, viewy, viewz, pSplat->xscale, pSplat->yscale, -pSplat->verts[0].x, pSplat->verts[0].y, vis->viewangle, pSplat->angle); R_CalculateSlopeVectors(); spanfunctype = SPANDRAWFUNC_TILTEDSPRITE; } From 7b83345c75d8350c1875765d292b588d257a71a2 Mon Sep 17 00:00:00 2001 From: katsy Date: Wed, 14 Apr 2021 19:29:53 -0500 Subject: [PATCH 0685/1080] need to create the patches here if they don't already exist --- src/y_inter.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/y_inter.c b/src/y_inter.c index 6833ca2b5..dca8cd377 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -266,6 +266,14 @@ void Y_LoadIntermissionData(void) case int_ctf: case int_teammatch: { + if (!rflagico) //prevent a crash if we haven't cached our team graphics yet + { + rflagico = W_CachePatchName("RFLAGICO", PU_HUDGFX); + bflagico = W_CachePatchName("BFLAGICO", PU_HUDGFX); + rmatcico = W_CachePatchName("RMATCICO", PU_HUDGFX); + bmatcico = W_CachePatchName("BMATCICO", PU_HUDGFX); + } + data.match.redflag = (intertype == int_ctf) ? rflagico : rmatcico; data.match.blueflag = (intertype == int_ctf) ? bflagico : bmatcico; } From 3670af5a31b0810cce9a5f1f4c78158b4914e8db Mon Sep 17 00:00:00 2001 From: Hannu Hanhi Date: Fri, 16 Apr 2021 00:38:34 +0300 Subject: [PATCH 0686/1080] Fix incorrect values caused by outdated use of timing functions in perfstats 3 --- src/lua_hooklib.c | 2 +- src/m_perfstats.c | 4 ++-- src/m_perfstats.h | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/lua_hooklib.c b/src/lua_hooklib.c index 637809fd8..1665e36b0 100644 --- a/src/lua_hooklib.c +++ b/src/lua_hooklib.c @@ -473,7 +473,7 @@ void LUAh_ThinkFrame(void) hook_p hookp; // variables used by perf stats int hook_index = 0; - int time_taken = 0; + precise_t time_taken = 0; if (!gL || !(hooksAvailable[hook_ThinkFrame/8] & (1<<(hook_ThinkFrame%8)))) return; diff --git a/src/m_perfstats.c b/src/m_perfstats.c index 1596a87e5..b58599b6d 100644 --- a/src/m_perfstats.c +++ b/src/m_perfstats.c @@ -62,7 +62,7 @@ int thinkframe_hooks_capacity = 16; static INT32 draw_row; -void PS_SetThinkFrameHookInfo(int index, UINT32 time_taken, char* short_src) +void PS_SetThinkFrameHookInfo(int index, precise_t time_taken, char* short_src) { if (!thinkframe_hooks) { @@ -565,7 +565,7 @@ void M_DrawPerfStats(void) len = (int)strlen(str); if (len > 20) str += len - 20; - snprintf(s, sizeof s - 1, "%20s: %u", str, thinkframe_hooks[i].time_taken); + snprintf(s, sizeof s - 1, "%20s: %d", str, I_PreciseToMicros(thinkframe_hooks[i].time_taken)); V_DrawSmallString(x, y, V_MONOSPACE | V_ALLOWLOWERCASE | text_color, s); y += 4; // repeated code! if (y > 192) diff --git a/src/m_perfstats.h b/src/m_perfstats.h index 132bea38c..1ca71957f 100644 --- a/src/m_perfstats.h +++ b/src/m_perfstats.h @@ -30,11 +30,11 @@ extern int ps_lua_mobjhooks; typedef struct { - UINT32 time_taken; + precise_t time_taken; char short_src[LUA_IDSIZE]; } ps_hookinfo_t; -void PS_SetThinkFrameHookInfo(int index, UINT32 time_taken, char* short_src); +void PS_SetThinkFrameHookInfo(int index, precise_t time_taken, char* short_src); void M_DrawPerfStats(void); From d35a1811d6a0fd94808a4fcb189a0ffe38bc7483 Mon Sep 17 00:00:00 2001 From: katsy Date: Fri, 16 Apr 2021 04:49:33 -0500 Subject: [PATCH 0687/1080] clean up bouncy fof code --- src/p_user.c | 46 +++++++--------------------------------------- 1 file changed, 7 insertions(+), 39 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index 4413cc6cd..c7eecce9b 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -2772,16 +2772,9 @@ static void P_CheckBouncySectors(player_t *player) player->mo->momx = -FixedMul(player->mo->momx,bouncestrength); player->mo->momy = -FixedMul(player->mo->momy,bouncestrength); - if (player->pflags & PF_SPINNING) - { - player->pflags &= ~PF_SPINNING; - player->pflags |= P_GetJumpFlags(player); - player->pflags |= PF_THOKKED; - } } else { - fixed_t newmom; pslope_t *slope = (abs(oldz - topheight) < abs(oldz + player->mo->height - bottomheight)) ? *rover->t_slope : *rover->b_slope; momentum.x = player->mo->momx; @@ -2791,53 +2784,28 @@ static void P_CheckBouncySectors(player_t *player) if (slope) P_ReverseQuantizeMomentumToSlope(&momentum, slope); - newmom = momentum.z = -FixedMul(momentum.z,bouncestrength)/2; + momentum.z = -FixedMul(momentum.z,bouncestrength)/2; - if (abs(newmom) < (bouncestrength*2)) + if (abs(momentum.z) < (bouncestrength*2)) goto bouncydone; - if (!(rover->master->flags & ML_BOUNCY)) - { - if (newmom > 0) - { - if (newmom < 8*FRACUNIT) - newmom = 8*FRACUNIT; - } - else if (newmom < 0) - { - if (newmom > -8*FRACUNIT) - 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; - - momentum.z = newmom*2; + if (momentum.z > FixedMul(24*FRACUNIT, player->mo->scale)) //half of the default player height + momentum.z = FixedMul(24*FRACUNIT, player->mo->scale); + else if (momentum.z < -FixedMul(24*FRACUNIT, player->mo->scale)) + momentum.z = -FixedMul(24*FRACUNIT, player->mo->scale); if (slope) P_QuantizeMomentumToSlope(&momentum, slope); player->mo->momx = momentum.x; player->mo->momy = momentum.y; - player->mo->momz = momentum.z/2; + player->mo->momz = momentum.z; if (player->pflags & PF_SPINNING) { - player->pflags &= ~PF_SPINNING; - player->pflags |= P_GetJumpFlags(player); player->pflags |= PF_THOKKED; } } - - if ((player->pflags & PF_SPINNING) && player->speed < FixedMul(1<mo->scale) && player->mo->momz) - { - player->pflags &= ~PF_SPINNING; - player->pflags |= P_GetJumpFlags(player); - } - goto bouncydone; } } From ee578b68f48c338bebc50ff66beb70bc919ae3a6 Mon Sep 17 00:00:00 2001 From: Hannu Hanhi Date: Sat, 17 Apr 2021 03:11:29 +0300 Subject: [PATCH 0688/1080] Remove bad pointer arithmetic in polygon comparators, that was causing glitches --- src/hardware/hw_batching.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/hardware/hw_batching.c b/src/hardware/hw_batching.c index fb3417158..b13ad03ea 100644 --- a/src/hardware/hw_batching.c +++ b/src/hardware/hw_batching.c @@ -137,6 +137,8 @@ static int comparePolygons(const void *p1, const void *p2) PolygonArrayEntry* poly2 = &polygonArray[index2]; int diff; INT64 diff64; + UINT32 downloaded1 = 0; + UINT32 downloaded2 = 0; int shader1 = poly1->shader; int shader2 = poly2->shader; @@ -152,7 +154,11 @@ static int comparePolygons(const void *p1, const void *p2) if (shader1 == -1 && shader2 == -1) return index1 - index2; - diff64 = poly1->texture - poly2->texture; + if (poly1->texture) + downloaded1 = poly1->texture->downloaded; // there should be a opengl texture name here, usable for comparisons + if (poly2->texture) + downloaded2 = poly2->texture->downloaded; + diff64 = downloaded1 - downloaded2; if (diff64 != 0) return diff64; diff = poly1->polyFlags - poly2->polyFlags; @@ -184,16 +190,21 @@ static int comparePolygonsNoShaders(const void *p1, const void *p2) GLMipmap_t *texture1 = poly1->texture; GLMipmap_t *texture2 = poly2->texture; + UINT32 downloaded1 = 0; + UINT32 downloaded2 = 0; if (poly1->polyFlags & PF_NoTexture || poly1->horizonSpecial) texture1 = NULL; if (poly2->polyFlags & PF_NoTexture || poly2->horizonSpecial) texture2 = NULL; - diff64 = texture1 - texture2; - if (diff64 != 0) return diff64; - + if (texture1) + downloaded1 = texture1->downloaded; // there should be a opengl texture name here, usable for comparisons + if (texture2) + downloaded2 = texture2->downloaded; // skywalls and horizon lines must retain their order for horizon lines to work - if (texture1 == NULL && texture2 == NULL) + if (!texture1 && !texture2) return index1 - index2; + diff64 = downloaded1 - downloaded2; + if (diff64 != 0) return diff64; diff = poly1->polyFlags - poly2->polyFlags; if (diff != 0) return diff; From d59f25a6cdd16fd1133c089bf6ba740dbc42e657 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Sun, 18 Apr 2021 12:59:49 -0400 Subject: [PATCH 0689/1080] stagefailed is more useful - Can now apply to normal stages, simply defaults to "false" in normal stages. - Post-level cutscenes are now always skipped when the stage was failed. - Exposed the boolean as a Lua read+write global. Desired for SUGOI, as it allows for visited flags not be updated, and level completion emblems to not be awarded. Which means a lot less crappy non-ideal workarounds. Normal stage intermission currently does not reflect failure state at all. Maybe it could always skip, never award score bonuses, have different text... etc. Probably would leave that up to vanilla dev opinion. --- src/doomstat.h | 2 +- src/g_game.c | 15 +++++++++++---- src/lua_script.c | 5 +++++ src/p_setup.c | 6 ++++-- 4 files changed, 21 insertions(+), 7 deletions(-) diff --git a/src/doomstat.h b/src/doomstat.h index 2d28b81af..2dbb144e6 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -496,7 +496,7 @@ extern UINT32 lastcustomtol; extern tic_t totalplaytime; -extern UINT8 stagefailed; +extern boolean stagefailed; // Emeralds stored as bits to throw savegame hackers off. extern UINT16 emeralds; diff --git a/src/g_game.c b/src/g_game.c index 2b304b4fd..e6c445d68 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -169,7 +169,7 @@ static boolean exitgame = false; static boolean retrying = false; static boolean retryingmodeattack = false; -UINT8 stagefailed; // Used for GEMS BONUS? Also to see if you beat the stage. +boolean stagefailed = false; // Used for GEMS BONUS? Also to see if you beat the stage. UINT16 emeralds; INT32 luabanks[NUM_LUABANKS]; @@ -3742,7 +3742,7 @@ static void G_UpdateVisited(void) // Update visitation flags? if ((!modifiedgame || savemoddata) // Not modified && !multiplayer && !demoplayback && (gametype == GT_COOP) // SP/RA/NiGHTS mode - && !(spec && stagefailed)) // Not failed the special stage + && !stagefailed) // Did not fail the stage { UINT8 earnedEmblems; @@ -3963,7 +3963,7 @@ static void G_DoCompleted(void) // If the current gametype has no intermission screen set, then don't start it. Y_DetermineIntermissionType(); - if ((skipstats && !modeattacking) || (spec && modeattacking && stagefailed) || (intertype == int_none)) + if ((skipstats && !modeattacking) || (modeattacking && stagefailed) || (intertype == int_none)) { G_UpdateVisited(); G_HandleSaveLevel(); @@ -3994,8 +3994,15 @@ void G_AfterIntermission(void) HU_ClearCEcho(); - if ((gametyperules & GTR_CUTSCENES) && mapheaderinfo[gamemap-1]->cutscenenum && !modeattacking && skipstats <= 1 && (gamecomplete || !(marathonmode & MA_NOCUTSCENES))) // Start a custom cutscene. + if ((gametyperules & GTR_CUTSCENES) && mapheaderinfo[gamemap-1]->cutscenenum + && !modeattacking + && skipstats <= 1 + && (gamecomplete || !(marathonmode & MA_NOCUTSCENES)) + && stagefailed == false) + { + // Start a custom cutscene. F_StartCustomCutscene(mapheaderinfo[gamemap-1]->cutscenenum-1, false, false); + } else { if (nextmap < 1100-1) diff --git a/src/lua_script.c b/src/lua_script.c index 7fd5a98e6..0a7e44422 100644 --- a/src/lua_script.c +++ b/src/lua_script.c @@ -380,6 +380,9 @@ int LUA_PushGlobals(lua_State *L, const char *word) } else if (fastcmp(word, "gamestate")) { lua_pushinteger(L, gamestate); return 1; + } else if (fastcmp(word, "stagefailed")) { + lua_pushboolean(L, stagefailed); + return 1; } return 0; } @@ -429,6 +432,8 @@ int LUA_CheckGlobals(lua_State *L, const char *word) } else if (fastcmp(word, "mapmusflags")) mapmusflags = (UINT16)luaL_checkinteger(L, 2); + else if (fastcmp(word, "stagefailed")) + stagefailed = luaL_checkboolean(L, 2); else return 0; diff --git a/src/p_setup.c b/src/p_setup.c index 40dd1a284..2e7db1055 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -3394,8 +3394,10 @@ static void P_InitLevelSettings(void) numstarposts = 0; ssspheres = timeinmap = 0; - // special stage - stagefailed = true; // assume failed unless proven otherwise - P_GiveEmerald or emerald touchspecial + // Assume Special Stages were failed in unless proven otherwise - via P_GiveEmerald or emerald touchspecial + // Normal stages will default to be OK, unless a Lua script sets to false. + stagefailed = G_IsSpecialStage(gamemap); + // Reset temporary record data memset(&ntemprecords, 0, sizeof(nightsdata_t)); From b026a6991cb87b870de07daa191b9fa87a2ac087 Mon Sep 17 00:00:00 2001 From: Jaime Ita Passos Date: Mon, 19 Apr 2021 15:52:07 -0300 Subject: [PATCH 0690/1080] Easing functions --- src/CMakeLists.txt | 2 + src/Makefile | 1 + src/m_easing.c | 399 +++++++++++++++++++++++++++++++++++++++++++++ src/m_easing.h | 95 +++++++++++ 4 files changed, 497 insertions(+) create mode 100644 src/m_easing.c create mode 100644 src/m_easing.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 87a0499b6..cd6e17386 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -32,6 +32,7 @@ set(SRB2_CORE_SOURCES m_bbox.c m_cheat.c m_cond.c + m_easing.c m_fixed.c m_menu.c m_misc.c @@ -101,6 +102,7 @@ set(SRB2_CORE_HEADERS m_cheat.h m_cond.h m_dllist.h + m_easing.h m_fixed.h m_menu.h m_misc.h diff --git a/src/Makefile b/src/Makefile index a4c3c4fdb..bdca6dc08 100644 --- a/src/Makefile +++ b/src/Makefile @@ -503,6 +503,7 @@ OBJS:=$(i_main_o) \ $(OBJDIR)/m_bbox.o \ $(OBJDIR)/m_cheat.o \ $(OBJDIR)/m_cond.o \ + $(OBJDIR)/m_easing.o \ $(OBJDIR)/m_fixed.o \ $(OBJDIR)/m_menu.o \ $(OBJDIR)/m_misc.o \ diff --git a/src/m_easing.c b/src/m_easing.c new file mode 100644 index 000000000..b3ea8842f --- /dev/null +++ b/src/m_easing.c @@ -0,0 +1,399 @@ +// SONIC ROBO BLAST 2 +//----------------------------------------------------------------------------- +// Copyright (C) 2020-2021 by Jaime "Lactozilla" Passos. +// +// This program is free software distributed under the +// terms of the GNU General Public License, version 2. +// See the 'LICENSE' file for more details. +//----------------------------------------------------------------------------- +/// \file m_easing.c +/// \brief Easing functions +/// Referenced from https://easings.net/ + +#include "m_easing.h" +#include "tables.h" +#include "doomdef.h" + +/* + For the computation of the logarithm, we choose, by trial and error, from among + a sequence of particular factors those, that when multiplied with the function + argument, normalize it to unity. For every factor chosen, we add up the + corresponding logarithm value stored in a table. The sum then corresponds to + the logarithm of the function argument. + + For the integer portion, we would want to choose + 2^i, i = 1, 2, 4, 8, ... + and for the factional part we choose + 1+2^-i, i = 1, 2, 3, 4, 5 ... + + The algorithm for the exponential is closely related and quite literally the inverse + of the logarithm algorithm. From among the sequence of tabulated logarithms for our + chosen factors, we pick those that when subtracted from the function argument ultimately + reduce it to zero. Starting with unity, we multiply with all the factors whose logarithms + we have subtracted in the process. The resulting product corresponds to the result of the exponentiation. + + Logarithms of values greater than unity can be computed by applying the algorithm to the reciprocal + of the function argument (with the negation of the result as appropriate), likewise exponentiation with + negative function arguments requires us negate the function argument and compute the reciprocal at the end. +*/ + +static fixed_t logtabdec[FRACBITS] = +{ + 0x95c1, 0x526a, 0x2b80, 0x1663, + 0xb5d, 0x5b9, 0x2e0, 0x170, + 0xb8, 0x5c, 0x2e, 0x17, + 0x0b, 0x06, 0x03, 0x01 +}; + +static fixed_t fixlog2(fixed_t a) +{ + UINT32 x = a, y = 0; + INT32 t, i, shift = 8; + + if (x > FRACUNIT) + x = FixedDiv(FRACUNIT, x); + + // Integer part + // 1<<19 = 0x80000 + // 1<<18 = 0x40000 + // 1<<17 = 0x20000 + // 1<<16 = 0x10000 + +#define dologtab(i) \ + t = (x << shift); \ + if (t < FRACUNIT) \ + { \ + x = t; \ + y += (1 << (19 - i)); \ + } \ + shift /= 2; + + dologtab(0) + dologtab(1) + dologtab(2) + dologtab(3) + +#undef dologtab + + // Decimal part + for (i = 0; i < FRACBITS; i++) + { + t = x + (x >> (i + 1)); + if (t < FRACUNIT) + { + x = t; + y += logtabdec[i]; + } + } + + if (a <= FRACUNIT) + return -y; + + return y; +} + +// Notice how this is symmetric to fixlog2. +static INT32 fixexp(fixed_t a) +{ + UINT32 x, y; + fixed_t t, i, shift = 8; + + // Underflow prevention. + if (a <= -15 * FRACUNIT) + return 0; + + x = (a < 0) ? (-a) : (a); + y = FRACUNIT; + + // Integer part (see fixlog2) +#define dologtab(i) \ + t = x - (1 << (19 - i)); \ + if (t >= 0) \ + { \ + x = t; \ + y <<= shift; \ + } \ + shift /= 2; + + dologtab(0) + dologtab(1) + dologtab(2) + dologtab(3) + +#undef dologtab + + // Decimal part + for (i = 0; i < FRACBITS; i++) + { + t = (x - logtabdec[i]); + if (t >= 0) + { + x = t; + y += (y >> (i + 1)); + } + } + + if (a < 0) + return FixedDiv(FRACUNIT, y); + + return y; +} + +#define fixpow(x, y) fixexp(FixedMul((y), fixlog2(x))) +#define fixintmul(x, y) FixedMul((x) * FRACUNIT, y) +#define fixintdiv(x, y) FixedDiv(x, (y) * FRACUNIT) +#define fixinterp(start, end, t) FixedMul((FRACUNIT - (t)), start) + FixedMul(t, end) + +#define EASINGFUNC(type) fixed_t Easing_ ## type (fixed_t start, fixed_t end, fixed_t t) + +// +// Linear +// + +EASINGFUNC(Linear) +{ + return fixinterp(start, end, t); +} + +// +// Sine +// + +// This is equivalent to calculating (x * pi) and converting the result from radians into degrees. +#define fixang(x) FixedMul((x), 180*FRACUNIT) + +EASINGFUNC(InSine) +{ + fixed_t c = fixang(t / 2); + fixed_t x = FRACUNIT - FINECOSINE(FixedAngle(c)>>ANGLETOFINESHIFT); + return fixinterp(start, end, x); +} + +EASINGFUNC(OutSine) +{ + fixed_t c = fixang(t / 2); + fixed_t x = FINESINE(FixedAngle(c)>>ANGLETOFINESHIFT); + return fixinterp(start, end, x); +} + +EASINGFUNC(InOutSine) +{ + fixed_t c = fixang(t); + fixed_t x = -(FINECOSINE(FixedAngle(c)>>ANGLETOFINESHIFT) - FRACUNIT) / 2; + return fixinterp(start, end, x); +} + +#undef fixang + +// +// Quad +// + +EASINGFUNC(InQuad) +{ + return fixinterp(start, end, FixedMul(t, t)); +} + +EASINGFUNC(OutQuad) +{ + return fixinterp(start, end, FRACUNIT - FixedMul(FRACUNIT - t, FRACUNIT - t)); +} + +EASINGFUNC(InOutQuad) +{ + fixed_t x = t < (FRACUNIT/2) + ? fixintmul(2, FixedMul(t, t)) + : FRACUNIT - fixpow(FixedMul(-2*FRACUNIT, t) + 2*FRACUNIT, 2*FRACUNIT) / 2; + return fixinterp(start, end, x); +} + +// +// Cubic +// + +EASINGFUNC(InCubic) +{ + fixed_t x = FixedMul(t, FixedMul(t, t)); + return fixinterp(start, end, x); +} + +EASINGFUNC(OutCubic) +{ + return fixinterp(start, end, FRACUNIT - fixpow(FRACUNIT - t, 3*FRACUNIT)); +} + +EASINGFUNC(InOutCubic) +{ + fixed_t x = t < (FRACUNIT/2) + ? fixintmul(4, FixedMul(t, FixedMul(t, t))) + : FRACUNIT - fixpow(fixintmul(-2, t) + 2*FRACUNIT, 3*FRACUNIT) / 2; + return fixinterp(start, end, x); +} + +// +// "Quart" +// + +EASINGFUNC(InQuart) +{ + fixed_t x = FixedMul(FixedMul(t, t), FixedMul(t, t)); + return fixinterp(start, end, x); +} + +EASINGFUNC(OutQuart) +{ + fixed_t x = FRACUNIT - fixpow(FRACUNIT - t, 4 * FRACUNIT); + return fixinterp(start, end, x); +} + +EASINGFUNC(InOutQuart) +{ + fixed_t x = t < (FRACUNIT/2) + ? fixintmul(8, FixedMul(FixedMul(t, t), FixedMul(t, t))) + : FRACUNIT - fixpow(fixintmul(-2, t) + 2*FRACUNIT, 4*FRACUNIT) / 2; + return fixinterp(start, end, x); +} + +// +// "Quint" +// + +EASINGFUNC(InQuint) +{ + fixed_t x = FixedMul(t, FixedMul(FixedMul(t, t), FixedMul(t, t))); + return fixinterp(start, end, x); +} + +EASINGFUNC(OutQuint) +{ + fixed_t x = FRACUNIT - fixpow(FRACUNIT - t, 5 * FRACUNIT); + return fixinterp(start, end, x); +} + +EASINGFUNC(InOutQuint) +{ + fixed_t x = t < (FRACUNIT/2) + ? FixedMul(16*FRACUNIT, FixedMul(t, FixedMul(FixedMul(t, t), FixedMul(t, t)))) + : FRACUNIT - fixpow(fixintmul(-2, t) + 2*FRACUNIT, 5*FRACUNIT) / 2; + return fixinterp(start, end, x); +} + +// +// Exponential +// + +EASINGFUNC(InExpo) +{ + fixed_t x = (!t) ? 0 : fixpow(2*FRACUNIT, fixintmul(10, t) - 10*FRACUNIT); + return fixinterp(start, end, x); +} + +EASINGFUNC(OutExpo) +{ + fixed_t x = (t >= FRACUNIT) ? FRACUNIT + : FRACUNIT - fixpow(2*FRACUNIT, fixintmul(-10, t)); + return fixinterp(start, end, x); +} + +EASINGFUNC(InOutExpo) +{ + fixed_t x; + + if (!t) + x = 0; + else if (t >= FRACUNIT) + x = FRACUNIT; + else + { + if (t < FRACUNIT / 2) + { + x = fixpow(2*FRACUNIT, fixintmul(20, t) - 10*FRACUNIT); + x = fixintdiv(x, 2); + } + else + { + x = fixpow(2*FRACUNIT, fixintmul(-20, t) + 10*FRACUNIT); + x = fixintdiv((2*FRACUNIT) - x, 2); + } + } + + return fixinterp(start, end, x); +} + +// +// "Back" +// + +#define EASEBACKCONST1 111514 // 1.70158 +#define EASEBACKCONST2 99942 // 1.525 + +EASINGFUNC(InBack) +{ + const fixed_t c1 = EASEBACKCONST1; + const fixed_t c3 = c1 + FRACUNIT; + fixed_t x = FixedMul(FixedMul(t, t), FixedMul(c3, t) - c1); + return fixinterp(start, end, x); +} + +EASINGFUNC(OutBack) +{ + const fixed_t c1 = EASEBACKCONST1; + const fixed_t c3 = c1 + FRACUNIT; + fixed_t x; + t -= FRACUNIT; + x = FRACUNIT + FixedMul(FixedMul(t, t), FixedMul(c3, t) + c1); + return fixinterp(start, end, x); +} + +static fixed_t DoEaseInOutBack(fixed_t start, fixed_t end, fixed_t t, fixed_t c2) +{ + fixed_t x; + + c2 += FRACUNIT; + + if (t < FRACUNIT / 2) + { + x = fixintmul(7, t) - c2; + x = fixintmul(2, x); + x = FixedMul(FixedMul(t, t), x); + } + else + { + t -= FRACUNIT; + x = fixintmul(2, fixintmul(7, t) + c2); + x = FixedMul(FixedMul(t, t), x); + x = FRACUNIT + x; + } + + return fixinterp(start, end, x); +} + +EASINGFUNC(InOutBack) +{ + return DoEaseInOutBack(start, end, t, EASEBACKCONST2); +} + +#undef EASINGFUNC + +// Function list + +#define EASINGFUNC(type) Easing_ ## type +#define COMMA , + +easingfunc_t easing_funclist[EASE_MAX] = +{ + EASINGFUNCLIST(COMMA) +}; + +// Function names + +#undef EASINGFUNC +#define EASINGFUNC(type) #type + +const char *easing_funcnames[EASE_MAX] = +{ + EASINGFUNCLIST(COMMA) +}; + +#undef COMMA +#undef EASINGFUNC diff --git a/src/m_easing.h b/src/m_easing.h new file mode 100644 index 000000000..e5571ece3 --- /dev/null +++ b/src/m_easing.h @@ -0,0 +1,95 @@ +// SONIC ROBO BLAST 2 +//----------------------------------------------------------------------------- +// Copyright (C) 2020-2021 by Jaime "Lactozilla" Passos. +// +// This program is free software distributed under the +// terms of the GNU General Public License, version 2. +// See the 'LICENSE' file for more details. +//----------------------------------------------------------------------------- +/// \file m_easing.h +/// \brief Easing functions + +#ifndef __M_EASING_H__ +#define __M_EASING_H__ + +#include "doomtype.h" +#include "m_fixed.h" + +typedef enum +{ + EASE_LINEAR = 0, + + EASE_INSINE, + EASE_OUTSINE, + EASE_INOUTSINE, + + EASE_INQUAD, + EASE_OUTQUAD, + EASE_INOUTQUAD, + + EASE_INCUBIC, + EASE_OUTCUBIC, + EASE_INOUTCUBIC, + + EASE_INQUART, + EASE_OUTQUART, + EASE_INOUTQUART, + + EASE_INQUINT, + EASE_OUTQUINT, + EASE_INOUTQUINT, + + EASE_INEXPO, + EASE_OUTEXPO, + EASE_INOUTEXPO, + + EASE_INBACK, + EASE_OUTBACK, + EASE_INOUTBACK, + + EASE_MAX, +} easing_t; + +typedef fixed_t (*easingfunc_t)(fixed_t, fixed_t, fixed_t); + +extern easingfunc_t easing_funclist[EASE_MAX]; +extern const char *easing_funcnames[EASE_MAX]; + +#define EASINGFUNCLIST(sep) \ + EASINGFUNC(Linear) sep \ + \ + EASINGFUNC(InSine) sep \ + EASINGFUNC(OutSine) sep \ + EASINGFUNC(InOutSine) sep \ + \ + EASINGFUNC(InQuad) sep \ + EASINGFUNC(OutQuad) sep \ + EASINGFUNC(InOutQuad) sep \ + \ + EASINGFUNC(InCubic) sep \ + EASINGFUNC(OutCubic) sep \ + EASINGFUNC(InOutCubic) sep \ + \ + EASINGFUNC(InQuart) sep \ + EASINGFUNC(OutQuart) sep \ + EASINGFUNC(InOutQuart) sep \ + \ + EASINGFUNC(InQuint) sep \ + EASINGFUNC(OutQuint) sep \ + EASINGFUNC(InOutQuint) sep \ + \ + EASINGFUNC(InExpo) sep \ + EASINGFUNC(OutExpo) sep \ + EASINGFUNC(InOutExpo) sep \ + \ + EASINGFUNC(InBack) sep \ + EASINGFUNC(OutBack) sep \ + EASINGFUNC(InOutBack) sep + +#define EASINGFUNC(type) fixed_t Easing_ ## type (fixed_t start, fixed_t end, fixed_t t); + +EASINGFUNCLIST() + +#undef EASINGFUNC + +#endif From 228668ce986e2f44fec2e085c9ee7e174ed3f3d3 Mon Sep 17 00:00:00 2001 From: SMS Alfredo <65426124+SMS-Alfredo@users.noreply.github.com> Date: Mon, 19 Apr 2021 14:25:34 -0500 Subject: [PATCH 0691/1080] Change the render flags to extra flags and improve SF_NOSUPERSPRITES --- src/deh_tables.c | 5 ++--- src/p_mobj.c | 12 +++++++----- src/p_mobj.h | 29 +++++++++++++++++------------ src/r_defs.h | 4 ---- 4 files changed, 26 insertions(+), 24 deletions(-) diff --git a/src/deh_tables.c b/src/deh_tables.c index f3a77d528..621c6aae4 100644 --- a/src/deh_tables.c +++ b/src/deh_tables.c @@ -4351,6 +4351,8 @@ const char *const MOBJEFLAG_LIST[] = { "SPRUNG", // Mobj was already sprung this tic "APPLYPMOMZ", // Platform movement "TRACERANGLE", // Compute and trigger on mobj angle relative to tracer + "FORCESUPER", // Forces an object to use super sprites with SPR_PLAY. + "FORCENOSUPER", // Forces an object to NOT use super sprites with SPR_PLAY. NULL }; @@ -4905,9 +4907,6 @@ struct int_const_s const INT_CONST[] = { {"RF_SHADOWDRAW",RF_SHADOWDRAW}, {"RF_SHADOWEFFECTS",RF_SHADOWEFFECTS}, {"RF_DROPSHADOW",RF_DROPSHADOW}, - {"RF_FORCESUPER",RF_FORCESUPER}, - {"RF_FORCENOSUPER",RF_FORCENOSUPER}, - {"RF_REVERSESUPER",RF_REVERSESUPER}, // Level flags {"LF_SCRIPTISFILE",LF_SCRIPTISFILE}, diff --git a/src/p_mobj.c b/src/p_mobj.c index 3f77f28aa..4e9015e8a 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -397,15 +397,17 @@ boolean P_SetPlayerMobjState(mobj_t *mobj, statenum_t state) UINT16 stateframe = st->frame; // Add/Remove FF_SPR2SUPER based on certain conditions - if (player->powers[pw_super] && !(player->charflags & SF_NOSUPERSPRITES)) + if (player->charflags & SF_NOSUPERSPRITES) + stateframe = stateframe & ~FF_SPR2SUPER; + else if (player->powers[pw_super]) stateframe = stateframe | FF_SPR2SUPER; if (stateframe & FF_SPR2SUPER) { - if (mobj->renderflags & RF_FORCENOSUPER) + if (mobj->eflags & MFE_FORCENOSUPER) stateframe = stateframe & ~FF_SPR2SUPER; } - else if (mobj->renderflags & RF_FORCESUPER) + else if (mobj->eflags & MFE_FORCESUPER) stateframe = stateframe | FF_SPR2SUPER; // Get the sprite2 and frame number @@ -543,10 +545,10 @@ boolean P_SetMobjState(mobj_t *mobj, statenum_t state) // Add/Remove FF_SPR2SUPER based on certain conditions if (stateframe & FF_SPR2SUPER) { - if (mobj->renderflags & RF_FORCENOSUPER) + if (mobj->eflags & MFE_FORCENOSUPER) stateframe = stateframe & ~FF_SPR2SUPER; } - else if (mobj->renderflags & RF_FORCESUPER) + else if (mobj->eflags & MFE_FORCESUPER) stateframe = stateframe | FF_SPR2SUPER; // Get the sprite2 and frame number diff --git a/src/p_mobj.h b/src/p_mobj.h index 5bb7c908e..c4567c27d 100644 --- a/src/p_mobj.h +++ b/src/p_mobj.h @@ -218,33 +218,38 @@ typedef enum typedef enum { // The mobj stands on solid floor (not on another mobj or in air) - MFE_ONGROUND = 1, + MFE_ONGROUND = 1, // The mobj just hit the floor while falling, this is cleared on next frame // (instant damage in lava/slime sectors to prevent jump cheat..) - MFE_JUSTHITFLOOR = 1<<1, + MFE_JUSTHITFLOOR = 1<<1, // The mobj stands in a sector with water, and touches the surface // this bit is set once and for all at the start of mobjthinker - MFE_TOUCHWATER = 1<<2, + MFE_TOUCHWATER = 1<<2, // The mobj stands in a sector with water, and his waist is BELOW the water surface // (for player, allows swimming up/down) - MFE_UNDERWATER = 1<<3, + MFE_UNDERWATER = 1<<3, // used for ramp sectors - MFE_JUSTSTEPPEDDOWN = 1<<4, + MFE_JUSTSTEPPEDDOWN = 1<<4, // Vertically flip sprite/allow upside-down physics - MFE_VERTICALFLIP = 1<<5, + MFE_VERTICALFLIP = 1<<5, // Goo water - MFE_GOOWATER = 1<<6, + MFE_GOOWATER = 1<<6, // The mobj is touching a lava block - MFE_TOUCHLAVA = 1<<7, + MFE_TOUCHLAVA = 1<<7, // Mobj was already pushed this tic - MFE_PUSHED = 1<<8, + MFE_PUSHED = 1<<8, // Mobj was already sprung this tic - MFE_SPRUNG = 1<<9, + MFE_SPRUNG = 1<<9, // Platform movement - MFE_APPLYPMOMZ = 1<<10, + MFE_APPLYPMOMZ = 1<<10, // Compute and trigger on mobj angle relative to tracer // See Linedef Exec 457 (Track mobj angle to point) - MFE_TRACERANGLE = 1<<11, + MFE_TRACERANGLE = 1<<11, + // Forces an object to use super sprites with SPR_PLAY. + MFE_FORCESUPER = 1<<12, + // Forces an object to NOT use super sprites with SPR_PLAY. + MFE_FORCENOSUPER = 1<<13, + // free: to and including 1<<15 } mobjeflag_t; diff --git a/src/r_defs.h b/src/r_defs.h index 31f30dd6f..9c649fbc4 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -738,10 +738,6 @@ typedef enum RF_SHADOWDRAW = 0x10000, // Stretches and skews the sprite like a shadow. RF_SHADOWEFFECTS = 0x20000, // Scales and becomes transparent like a shadow. RF_DROPSHADOW = (RF_SHADOWDRAW | RF_SHADOWEFFECTS | RF_FULLDARK), - - RF_FORCESUPER = 0x40000, // Forces an object to use super sprites with SPR_PLAY. - RF_FORCENOSUPER = 0x80000, // Forces an object to NOT use super sprites with SPR_PLAY. - RF_REVERSESUPER = (RF_FORCESUPER | RF_FORCENOSUPER), //Use normal sprites in place of super sprites and vice-versa } renderflags_t; typedef enum From d8d3dee46f73d974310a5d18046497087a07a5ad Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Mon, 19 Apr 2021 17:20:34 -0400 Subject: [PATCH 0692/1080] Add linedef executor for toggling stagefailed By default, the executor will fail the stage. If Not Climbable is checked, the stage can be completed normally again. --- src/p_setup.c | 2 +- src/p_spec.c | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/p_setup.c b/src/p_setup.c index 2e7db1055..ec516992e 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -3395,7 +3395,7 @@ static void P_InitLevelSettings(void) ssspheres = timeinmap = 0; // Assume Special Stages were failed in unless proven otherwise - via P_GiveEmerald or emerald touchspecial - // Normal stages will default to be OK, unless a Lua script sets to false. + // Normal stages will default to be OK, until a Lua script / linedef executor says otherwise. stagefailed = G_IsSpecialStage(gamemap); // Reset temporary record data diff --git a/src/p_spec.c b/src/p_spec.c index 226e58d15..be120b686 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -3902,6 +3902,21 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) } break; + case 466: // Set level failure state + { + if (line->flags & ML_NOCLIMB) + { + stagefailed = false; + CONS_Debug(DBG_GAMELOGIC, "Stage can be completed successfully!\n"); + } + else + { + stagefailed = true; + CONS_Debug(DBG_GAMELOGIC, "Stage will end in failure...\n"); + } + } + break; + case 480: // Polyobj_DoorSlide case 481: // Polyobj_DoorSwing PolyDoor(line); From 30e7455178f43661ad7508ce79fd90bb89020d0d Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Mon, 19 Apr 2021 17:50:49 -0400 Subject: [PATCH 0693/1080] Failing a stage just displays the level title --- src/y_inter.c | 51 +++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 37 insertions(+), 14 deletions(-) diff --git a/src/y_inter.c b/src/y_inter.c index bd3b557d7..4b37b9f61 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -1259,24 +1259,40 @@ void Y_StartIntermission(void) usetile = false; // set up the "got through act" message according to skin name - // too long so just show "YOU GOT THROUGH THE ACT" - if (strlen(skins[players[consoleplayer].skin].realname) > 13) + if (stagefailed) { - strcpy(data.coop.passed1, "you got"); - strcpy(data.coop.passed2, (mapheaderinfo[gamemap-1]->actnum) ? "through act" : "through the act"); + strcpy(data.coop.passed1, mapheaderinfo[gamemap-1]->lvlttl); + + if (mapheaderinfo[gamemap-1]->levelflags & LF_NOZONE) + { + data.spec.passed2[0] = '\0'; + } + else + { + strcpy(data.coop.passed2, "Zone"); + } } - // long enough that "X GOT" won't fit so use "X PASSED THE ACT" - else if (strlen(skins[players[consoleplayer].skin].realname) > 8) - { - strcpy(data.coop.passed1, skins[players[consoleplayer].skin].realname); - strcpy(data.coop.passed2, (mapheaderinfo[gamemap-1]->actnum) ? "passed act" : "passed the act"); - } - // length is okay for normal use else { - snprintf(data.coop.passed1, sizeof data.coop.passed1, "%s got", - skins[players[consoleplayer].skin].realname); - strcpy(data.coop.passed2, (mapheaderinfo[gamemap-1]->actnum) ? "through act" : "through the act"); + // too long so just show "YOU GOT THROUGH THE ACT" + if (strlen(skins[players[consoleplayer].skin].realname) > 13) + { + strcpy(data.coop.passed1, "you got"); + strcpy(data.coop.passed2, (mapheaderinfo[gamemap-1]->actnum) ? "through act" : "through the act"); + } + // long enough that "X GOT" won't fit so use "X PASSED THE ACT" + else if (strlen(skins[players[consoleplayer].skin].realname) > 8) + { + strcpy(data.coop.passed1, skins[players[consoleplayer].skin].realname); + strcpy(data.coop.passed2, (mapheaderinfo[gamemap-1]->actnum) ? "passed act" : "passed the act"); + } + // length is okay for normal use + else + { + snprintf(data.coop.passed1, sizeof data.coop.passed1, "%s got", + skins[players[consoleplayer].skin].realname); + strcpy(data.coop.passed2, (mapheaderinfo[gamemap-1]->actnum) ? "through act" : "through the act"); + } } // set X positions @@ -1293,6 +1309,13 @@ void Y_StartIntermission(void) // The above value is not precalculated because it needs only be computed once // at the start of intermission, and precalculating it would preclude mods // changing the font to one of a slightly different width. + + if ((stagefailed) && !(mapheaderinfo[gamemap-1]->levelflags & LF_NOZONE)) + { + // Bit of a hack, offset so that the "Zone" text is right aligned like title cards. + data.coop.passedx2 = (data.coop.passedx1 + V_LevelNameWidth(data.coop.passed1)) - V_LevelNameWidth(data.coop.passed2); + } + break; } From 41f492f2f90225ed55c82c8bee377d0ae2365a4b Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Mon, 19 Apr 2021 17:59:55 -0400 Subject: [PATCH 0694/1080] Don't award any potentially cheesable bonuses if the stage was failed. Time Bonus is 0'd out if the stage was failed, since you can defeat the whole point of it if the stage lets you fail it immediately. Same with Guard Bonus -- it's not really a no-hit run if you didn't interact with anything. Kept others that are more effort-based like Ring Bonus to give the player a little bit of partial credit, especially since Special Stages do this too. --- src/y_inter.c | 60 +++++++++++++++++++++++++++++++++------------------ 1 file changed, 39 insertions(+), 21 deletions(-) diff --git a/src/y_inter.c b/src/y_inter.c index 4b37b9f61..0627a3aa7 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -1771,21 +1771,30 @@ static void Y_SetTimeBonus(player_t *player, y_bonus_t *bstruct) strncpy(bstruct->patch, "YB_TIME", sizeof(bstruct->patch)); bstruct->display = true; - // calculate time bonus - secs = player->realtime / TICRATE; - if (secs < 30) /* :30 */ bonus = 50000; - else if (secs < 60) /* 1:00 */ bonus = 10000; - else if (secs < 90) /* 1:30 */ bonus = 5000; - else if (secs < 120) /* 2:00 */ bonus = 4000; - else if (secs < 180) /* 3:00 */ bonus = 3000; - else if (secs < 240) /* 4:00 */ bonus = 2000; - else if (secs < 300) /* 5:00 */ bonus = 1000; - else if (secs < 360) /* 6:00 */ bonus = 500; - else if (secs < 420) /* 7:00 */ bonus = 400; - else if (secs < 480) /* 8:00 */ bonus = 300; - else if (secs < 540) /* 9:00 */ bonus = 200; - else if (secs < 600) /* 10:00 */ bonus = 100; - else /* TIME TAKEN: TOO LONG */ bonus = 0; + if (stagefailed == true) + { + // Time Bonus would be very easy to cheese by failing immediately. + bonus = 0; + } + else + { + // calculate time bonus + secs = player->realtime / TICRATE; + if (secs < 30) /* :30 */ bonus = 50000; + else if (secs < 60) /* 1:00 */ bonus = 10000; + else if (secs < 90) /* 1:30 */ bonus = 5000; + else if (secs < 120) /* 2:00 */ bonus = 4000; + else if (secs < 180) /* 3:00 */ bonus = 3000; + else if (secs < 240) /* 4:00 */ bonus = 2000; + else if (secs < 300) /* 5:00 */ bonus = 1000; + else if (secs < 360) /* 6:00 */ bonus = 500; + else if (secs < 420) /* 7:00 */ bonus = 400; + else if (secs < 480) /* 8:00 */ bonus = 300; + else if (secs < 540) /* 9:00 */ bonus = 200; + else if (secs < 600) /* 10:00 */ bonus = 100; + else /* TIME TAKEN: TOO LONG */ bonus = 0; + } + bstruct->points = bonus; } @@ -1838,12 +1847,21 @@ static void Y_SetGuardBonus(player_t *player, y_bonus_t *bstruct) strncpy(bstruct->patch, "YB_GUARD", sizeof(bstruct->patch)); bstruct->display = true; - if (player->timeshit == 0) bonus = 10000; - else if (player->timeshit == 1) bonus = 5000; - else if (player->timeshit == 2) bonus = 1000; - else if (player->timeshit == 3) bonus = 500; - else if (player->timeshit == 4) bonus = 100; - else bonus = 0; + if (stagefailed == true) + { + // "No-hit" runs would be very easy to cheese by failing immediately. + bonus = 0; + } + else + { + if (player->timeshit == 0) bonus = 10000; + else if (player->timeshit == 1) bonus = 5000; + else if (player->timeshit == 2) bonus = 1000; + else if (player->timeshit == 3) bonus = 500; + else if (player->timeshit == 4) bonus = 100; + else bonus = 0; + } + bstruct->points = bonus; } From 77b8578d04763398a60d372afcc834e05bc5fe77 Mon Sep 17 00:00:00 2001 From: Jaime Ita Passos Date: Mon, 19 Apr 2021 21:42:00 -0300 Subject: [PATCH 0695/1080] Add ease Lua library --- src/lua_mathlib.c | 119 +++++++++++++++++++++++++++++++++++++++++++++- src/m_easing.c | 63 +++++++++++++++++------- src/m_easing.h | 52 +++++++++++--------- 3 files changed, 193 insertions(+), 41 deletions(-) diff --git a/src/lua_mathlib.c b/src/lua_mathlib.c index b6046ab53..1b7113b36 100644 --- a/src/lua_mathlib.c +++ b/src/lua_mathlib.c @@ -16,6 +16,7 @@ #include "p_local.h" #include "doomstat.h" // for ALL7EMERALDS #include "r_main.h" // for R_PointToDist2 +#include "m_easing.h" #include "lua_script.h" #include "lua_libs.h" @@ -185,7 +186,7 @@ static int lib_coloropposite(lua_State *L) return 2; } -static luaL_Reg lib[] = { +static luaL_Reg lib_math[] = { {"abs", lib_abs}, {"min", lib_min}, {"max", lib_max}, @@ -223,9 +224,123 @@ static luaL_Reg lib[] = { {NULL, NULL} }; +// +// Easing functions +// + +#define EASINGFUNC(easetype) \ +{ \ + fixed_t start = 0; \ + fixed_t end = FRACUNIT; \ + fixed_t t = luaL_checkfixed(L, 1); \ + int n = lua_gettop(L); \ + if (n == 2) \ + end = luaL_checkfixed(L, 2); \ + else if (n >= 3) \ + { \ + start = luaL_checkfixed(L, 2); \ + end = luaL_checkfixed(L, 3); \ + } \ + lua_pushfixed(L, (Easing_ ## easetype)(t, start, end)); \ + return 1; \ +} \ + +static int lib_easelinear(lua_State *L) { EASINGFUNC(Linear) } + +static int lib_easeinsine(lua_State *L) { EASINGFUNC(InSine) } +static int lib_easeoutsine(lua_State *L) { EASINGFUNC(OutSine) } +static int lib_easeinoutsine(lua_State *L) { EASINGFUNC(InOutSine) } + +static int lib_easeinquad(lua_State *L) { EASINGFUNC(InQuad) } +static int lib_easeoutquad(lua_State *L) { EASINGFUNC(OutQuad) } +static int lib_easeinoutquad(lua_State *L) { EASINGFUNC(InOutQuad) } + +static int lib_easeincubic(lua_State *L) { EASINGFUNC(InCubic) } +static int lib_easeoutcubic(lua_State *L) { EASINGFUNC(OutCubic) } +static int lib_easeinoutcubic(lua_State *L) { EASINGFUNC(InOutCubic) } + +static int lib_easeinquart(lua_State *L) { EASINGFUNC(InQuart) } +static int lib_easeoutquart(lua_State *L) { EASINGFUNC(OutQuart) } +static int lib_easeinoutquart(lua_State *L) { EASINGFUNC(InOutQuart) } + +static int lib_easeinquint(lua_State *L) { EASINGFUNC(InQuint) } +static int lib_easeoutquint(lua_State *L) { EASINGFUNC(OutQuint) } +static int lib_easeinoutquint(lua_State *L) { EASINGFUNC(InOutQuint) } + +static int lib_easeinexpo(lua_State *L) { EASINGFUNC(InExpo) } +static int lib_easeoutexpo(lua_State *L) { EASINGFUNC(OutExpo) } +static int lib_easeinoutexpo(lua_State *L) { EASINGFUNC(InOutExpo) } + +#undef EASINGFUNC + +#define EASINGFUNC(easetype) \ +{ \ + boolean useparam = false; \ + fixed_t param = 0; \ + fixed_t start = 0; \ + fixed_t end = FRACUNIT; \ + fixed_t t = luaL_checkfixed(L, 1); \ + int n = lua_gettop(L); \ + if (n == 2) \ + end = luaL_checkfixed(L, 2); \ + else if (n >= 3) \ + { \ + start = (fixed_t)luaL_optinteger(L, 2, start); \ + end = (fixed_t)luaL_optinteger(L, 3, end); \ + if ((n >= 4) && (useparam = (!lua_isnil(L, 4)))) \ + param = luaL_checkfixed(L, 4); \ + } \ + if (useparam) \ + lua_pushfixed(L, (Easing_ ## easetype ## Parameterized)(t, start, end, param)); \ + else \ + lua_pushfixed(L, (Easing_ ## easetype)(t, start, end)); \ + return 1; \ +} \ + +static int lib_easeinback(lua_State *L) { EASINGFUNC(InBack) } +static int lib_easeoutback(lua_State *L) { EASINGFUNC(OutBack) } +static int lib_easeinoutback(lua_State *L) { EASINGFUNC(InOutBack) } + +#undef EASINGFUNC + +static luaL_Reg lib_ease[] = { + {"linear", lib_easelinear}, + + {"insine", lib_easeinsine}, + {"outsine", lib_easeoutsine}, + {"inoutsine", lib_easeinoutsine}, + + {"inquad", lib_easeinquad}, + {"outquad", lib_easeoutquad}, + {"inoutquad", lib_easeinoutquad}, + + {"incubic", lib_easeincubic}, + {"outcubic", lib_easeoutcubic}, + {"inoutcubic", lib_easeinoutcubic}, + + {"inquart", lib_easeinquart}, + {"outquart", lib_easeoutquart}, + {"inoutquart", lib_easeinoutquart}, + + {"inquint", lib_easeinquint}, + {"outquint", lib_easeoutquint}, + {"inoutquint", lib_easeinoutquint}, + + {"inexpo", lib_easeinexpo}, + {"outexpo", lib_easeoutexpo}, + {"inoutexpo", lib_easeinoutexpo}, + + {"inback", lib_easeinback}, + {"outback", lib_easeoutback}, + {"inoutback", lib_easeinoutback}, + + {NULL, NULL} +}; + int LUA_MathLib(lua_State *L) { lua_pushvalue(L, LUA_GLOBALSINDEX); - luaL_register(L, NULL, lib); + luaL_register(L, NULL, lib_math); + luaL_register(L, "ease", lib_ease); return 0; } diff --git a/src/m_easing.c b/src/m_easing.c index b3ea8842f..c871d3106 100644 --- a/src/m_easing.c +++ b/src/m_easing.c @@ -144,7 +144,11 @@ static INT32 fixexp(fixed_t a) #define fixintdiv(x, y) FixedDiv(x, (y) * FRACUNIT) #define fixinterp(start, end, t) FixedMul((FRACUNIT - (t)), start) + FixedMul(t, end) -#define EASINGFUNC(type) fixed_t Easing_ ## type (fixed_t start, fixed_t end, fixed_t t) +// ================== +// EASING FUNCTIONS +// ================== + +#define EASINGFUNC(type) fixed_t Easing_ ## type (fixed_t t, fixed_t start, fixed_t end) // // Linear @@ -327,17 +331,20 @@ EASINGFUNC(InOutExpo) #define EASEBACKCONST1 111514 // 1.70158 #define EASEBACKCONST2 99942 // 1.525 -EASINGFUNC(InBack) +static fixed_t EaseInBack(fixed_t t, fixed_t start, fixed_t end, fixed_t c1) { - const fixed_t c1 = EASEBACKCONST1; const fixed_t c3 = c1 + FRACUNIT; fixed_t x = FixedMul(FixedMul(t, t), FixedMul(c3, t) - c1); return fixinterp(start, end, x); } -EASINGFUNC(OutBack) +EASINGFUNC(InBack) +{ + return EaseInBack(t, start, end, EASEBACKCONST1); +} + +static fixed_t EaseOutBack(fixed_t t, fixed_t start, fixed_t end, fixed_t c1) { - const fixed_t c1 = EASEBACKCONST1; const fixed_t c3 = c1 + FRACUNIT; fixed_t x; t -= FRACUNIT; @@ -345,32 +352,56 @@ EASINGFUNC(OutBack) return fixinterp(start, end, x); } -static fixed_t DoEaseInOutBack(fixed_t start, fixed_t end, fixed_t t, fixed_t c2) +EASINGFUNC(OutBack) { - fixed_t x; + return EaseOutBack(t, start, end, EASEBACKCONST1); +} - c2 += FRACUNIT; +static fixed_t EaseInOutBack(fixed_t t, fixed_t start, fixed_t end, fixed_t c2) +{ + fixed_t x, y; + const fixed_t f2 = 2*FRACUNIT; if (t < FRACUNIT / 2) { - x = fixintmul(7, t) - c2; - x = fixintmul(2, x); - x = FixedMul(FixedMul(t, t), x); + x = fixpow(FixedMul(t, f2), f2); + y = FixedMul(c2 + FRACUNIT, FixedMul(t, f2)); + x = FixedMul(x, y - c2); } else { - t -= FRACUNIT; - x = fixintmul(2, fixintmul(7, t) + c2); - x = FixedMul(FixedMul(t, t), x); - x = FRACUNIT + x; + x = fixpow(-(FixedMul(t, f2) - f2), f2); + y = FixedMul(c2 + FRACUNIT, FixedMul(t, f2) - f2); + x = FixedMul(x, y + c2); + x += f2; } + x /= 2; + return fixinterp(start, end, x); } EASINGFUNC(InOutBack) { - return DoEaseInOutBack(start, end, t, EASEBACKCONST2); + return EaseInOutBack(t, start, end, EASEBACKCONST2); +} + +#undef EASINGFUNC +#define EASINGFUNC(type) fixed_t Easing_ ## type (fixed_t t, fixed_t start, fixed_t end, fixed_t param) + +EASINGFUNC(InBackParameterized) +{ + return EaseInBack(t, start, end, param); +} + +EASINGFUNC(OutBackParameterized) +{ + return EaseOutBack(t, start, end, param); +} + +EASINGFUNC(InOutBackParameterized) +{ + return EaseInOutBack(t, start, end, param); } #undef EASINGFUNC diff --git a/src/m_easing.h b/src/m_easing.h index e5571ece3..435ad35e7 100644 --- a/src/m_easing.h +++ b/src/m_easing.h @@ -56,40 +56,46 @@ extern easingfunc_t easing_funclist[EASE_MAX]; extern const char *easing_funcnames[EASE_MAX]; #define EASINGFUNCLIST(sep) \ - EASINGFUNC(Linear) sep \ + EASINGFUNC(Linear) sep /* Easing_Linear */ \ \ - EASINGFUNC(InSine) sep \ - EASINGFUNC(OutSine) sep \ - EASINGFUNC(InOutSine) sep \ + EASINGFUNC(InSine) sep /* Easing_InSine */ \ + EASINGFUNC(OutSine) sep /* Easing_OutSine */ \ + EASINGFUNC(InOutSine) sep /* Easing_InOutSine */ \ \ - EASINGFUNC(InQuad) sep \ - EASINGFUNC(OutQuad) sep \ - EASINGFUNC(InOutQuad) sep \ + EASINGFUNC(InQuad) sep /* Easing_InQuad */ \ + EASINGFUNC(OutQuad) sep /* Easing_OutQuad */ \ + EASINGFUNC(InOutQuad) sep /* Easing_InOutQuad */ \ \ - EASINGFUNC(InCubic) sep \ - EASINGFUNC(OutCubic) sep \ - EASINGFUNC(InOutCubic) sep \ + EASINGFUNC(InCubic) sep /* Easing_InCubic */ \ + EASINGFUNC(OutCubic) sep /* Easing_OutCubic */ \ + EASINGFUNC(InOutCubic) sep /* Easing_InOutCubic */ \ \ - EASINGFUNC(InQuart) sep \ - EASINGFUNC(OutQuart) sep \ - EASINGFUNC(InOutQuart) sep \ + EASINGFUNC(InQuart) sep /* Easing_InQuart */ \ + EASINGFUNC(OutQuart) sep /* Easing_OutQuart */ \ + EASINGFUNC(InOutQuart) sep /* Easing_InOutQuart */ \ \ - EASINGFUNC(InQuint) sep \ - EASINGFUNC(OutQuint) sep \ - EASINGFUNC(InOutQuint) sep \ + EASINGFUNC(InQuint) sep /* Easing_InQuint */ \ + EASINGFUNC(OutQuint) sep /* Easing_OutQuint */ \ + EASINGFUNC(InOutQuint) sep /* Easing_InOutQuint */ \ \ - EASINGFUNC(InExpo) sep \ - EASINGFUNC(OutExpo) sep \ - EASINGFUNC(InOutExpo) sep \ + EASINGFUNC(InExpo) sep /* Easing_InExpo */ \ + EASINGFUNC(OutExpo) sep /* Easing_OutExpo */ \ + EASINGFUNC(InOutExpo) sep /* Easing_InOutExpo */ \ \ - EASINGFUNC(InBack) sep \ - EASINGFUNC(OutBack) sep \ - EASINGFUNC(InOutBack) sep + EASINGFUNC(InBack) sep /* Easing_InBack */ \ + EASINGFUNC(OutBack) sep /* Easing_OutBack */ \ + EASINGFUNC(InOutBack) sep /* Easing_InOutBack */ -#define EASINGFUNC(type) fixed_t Easing_ ## type (fixed_t start, fixed_t end, fixed_t t); +#define EASINGFUNC(type) fixed_t Easing_ ## type (fixed_t t, fixed_t start, fixed_t end); EASINGFUNCLIST() #undef EASINGFUNC +#define EASINGFUNC(type) fixed_t Easing_ ## type (fixed_t t, fixed_t start, fixed_t end, fixed_t param); +EASINGFUNC(InBackParameterized) /* Easing_InBackParameterized */ +EASINGFUNC(OutBackParameterized) /* Easing_OutBackParameterized */ +EASINGFUNC(InOutBackParameterized) /* Easing_InOutBackParameterized */ + +#undef EASINGFUNC #endif From 8f01e85adef84af55ed29ce8adbe789d6abec817 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Tue, 20 Apr 2021 22:10:11 -0400 Subject: [PATCH 0696/1080] Allow spaces in captions defined in SOC --- src/deh_soc.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/deh_soc.c b/src/deh_soc.c index 5b12ea1b0..eebaf1316 100644 --- a/src/deh_soc.c +++ b/src/deh_soc.c @@ -2839,26 +2839,28 @@ void readsound(MYFILE *f, INT32 num) if (s[0] == '\n') break; + // First remove trailing newline, if there is one + tmp = strchr(s, '\n'); + if (tmp) + *tmp = '\0'; + tmp = strchr(s, '#'); if (tmp) *tmp = '\0'; if (s == tmp) continue; // Skip comment lines, but don't break. - word = strtok(s, " "); - if (word) - strupr(word); + // Get the part before the " = " + tmp = strchr(s, '='); + if (tmp) + *(tmp-1) = '\0'; else break; + strupr(word); - word2 = strtok(NULL, " "); - if (word2) - value = atoi(word2); - else - { - deh_warning("No value for token %s", word); - continue; - } + // Now get the part after + word2 = tmp += 2; + value = atoi(word2); // used for numerical settings if (fastcmp(word, "SINGULAR")) { From ce3c5e081e26b601fc7486281df9bd58dc6c51eb Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Tue, 20 Apr 2021 22:19:56 -0400 Subject: [PATCH 0697/1080] Missed a few lines in the prev commit --- src/deh_soc.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/deh_soc.c b/src/deh_soc.c index eebaf1316..60aaf1287 100644 --- a/src/deh_soc.c +++ b/src/deh_soc.c @@ -2850,6 +2850,9 @@ void readsound(MYFILE *f, INT32 num) if (s == tmp) continue; // Skip comment lines, but don't break. + // Set / reset word + word = s; + // Get the part before the " = " tmp = strchr(s, '='); if (tmp) From 6c4e7e13e09e2d0a93c019a0ca93985133afb038 Mon Sep 17 00:00:00 2001 From: GoldenTails Date: Mon, 14 Dec 2020 01:23:57 -0600 Subject: [PATCH 0698/1080] Allow Lua to disable the emeralds that appear in the Special Stage intermission. --- src/lua_hud.h | 1 + src/lua_hudlib.c | 1 + src/y_inter.c | 1 + 3 files changed, 3 insertions(+) diff --git a/src/lua_hud.h b/src/lua_hud.h index 1e9dca00b..4be20c815 100644 --- a/src/lua_hud.h +++ b/src/lua_hud.h @@ -38,6 +38,7 @@ enum hud { // Intermission hud_intermissiontally, hud_intermissionmessages, + hud_intermissionemeralds, hud_MAX }; diff --git a/src/lua_hudlib.c b/src/lua_hudlib.c index 8d451e99c..51c7f91ae 100644 --- a/src/lua_hudlib.c +++ b/src/lua_hudlib.c @@ -64,6 +64,7 @@ static const char *const hud_disable_options[] = { "intermissiontally", "intermissionmessages", + "intermissionemeralds", NULL}; enum hudinfo { diff --git a/src/y_inter.c b/src/y_inter.c index dca8cd377..d6baf06c6 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -638,6 +638,7 @@ void Y_IntermissionDrawer(void) // draw the emeralds //if (intertic & 1) + if (LUA_HudEnabled(hud_intermissionemeralds)) { boolean drawthistic = !(ALL7EMERALDS(emeralds) && (intertic & 1)); INT32 emeraldx = 152 - 3*28; From aa54a04c9e38ae0fb4c0b4ed834a32258e1ec409 Mon Sep 17 00:00:00 2001 From: GoldenTails Date: Thu, 17 Dec 2020 02:30:57 -0600 Subject: [PATCH 0699/1080] Allow Lua to stop the intermission level title strings from drawing --- src/lua_hud.h | 1 + src/lua_hudlib.c | 1 + src/y_inter.c | 72 +++++++++++++++++++++++++++--------------------- 3 files changed, 43 insertions(+), 31 deletions(-) diff --git a/src/lua_hud.h b/src/lua_hud.h index 4be20c815..0a83b6de7 100644 --- a/src/lua_hud.h +++ b/src/lua_hud.h @@ -37,6 +37,7 @@ enum hud { hud_tabemblems, // Intermission hud_intermissiontally, + hud_intermissiontitletext, hud_intermissionmessages, hud_intermissionemeralds, hud_MAX diff --git a/src/lua_hudlib.c b/src/lua_hudlib.c index 51c7f91ae..862ab4423 100644 --- a/src/lua_hudlib.c +++ b/src/lua_hudlib.c @@ -63,6 +63,7 @@ static const char *const hud_disable_options[] = { "tabemblems", "intermissiontally", + "intermissiontitletext", "intermissionmessages", "intermissionemeralds", NULL}; diff --git a/src/y_inter.c b/src/y_inter.c index d6baf06c6..6240663fa 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -471,14 +471,17 @@ void Y_IntermissionDrawer(void) } } - // draw the "got through act" lines and act number - V_DrawLevelTitle(data.coop.passedx1, 49, 0, data.coop.passed1); + if (LUA_HudEnabled(hud_intermissiontitletext)) { - INT32 h = V_LevelNameHeight(data.coop.passed2); - V_DrawLevelTitle(data.coop.passedx2, 49+h+2, 0, data.coop.passed2); + // draw the "got through act" lines and act number + V_DrawLevelTitle(data.coop.passedx1, 49, 0, data.coop.passed1); + { + INT32 h = V_LevelNameHeight(data.coop.passed2); + V_DrawLevelTitle(data.coop.passedx2, 49+h+2, 0, data.coop.passed2); - if (data.coop.actnum) - V_DrawLevelActNum(244, 42+h, 0, data.coop.actnum); + if (data.coop.actnum) + V_DrawLevelActNum(244, 42+h, 0, data.coop.actnum); + } } bonusy = 150; @@ -562,37 +565,44 @@ void Y_IntermissionDrawer(void) if (drawsection == 1) { - const char *ringtext = "\x82" "50 rings, no shield"; - const char *tut1text = "\x82" "press " "\x80" "spin"; - const char *tut2text = "\x82" "mid-" "\x80" "jump"; - ttheight = 8; - V_DrawLevelTitle(data.spec.passedx1 + xoffset1, ttheight, 0, data.spec.passed1); - ttheight += V_LevelNameHeight(data.spec.passed3) + 2; - V_DrawLevelTitle(data.spec.passedx3 + xoffset2, ttheight, 0, data.spec.passed3); - ttheight += V_LevelNameHeight(data.spec.passed4) + 2; - V_DrawLevelTitle(data.spec.passedx4 + xoffset3, ttheight, 0, data.spec.passed4); + if (LUA_HudEnabled(hud_intermissiontitletext)) + { + const char *ringtext = "\x82" "50 rings, no shield"; + const char *tut1text = "\x82" "press " "\x80" "spin"; + const char *tut2text = "\x82" "mid-" "\x80" "jump"; + ttheight = 8; + V_DrawLevelTitle(data.spec.passedx1 + xoffset1, ttheight, 0, data.spec.passed1); + ttheight += V_LevelNameHeight(data.spec.passed3) + 2; + V_DrawLevelTitle(data.spec.passedx3 + xoffset2, ttheight, 0, data.spec.passed3); + ttheight += V_LevelNameHeight(data.spec.passed4) + 2; + V_DrawLevelTitle(data.spec.passedx4 + xoffset3, ttheight, 0, data.spec.passed4); - ttheight = 108; - V_DrawLevelTitle(BASEVIDWIDTH/2 + xoffset4 - (V_LevelNameWidth(ringtext)/2), ttheight, 0, ringtext); - ttheight += V_LevelNameHeight(tut1text) + 2; - V_DrawLevelTitle(BASEVIDWIDTH/2 + xoffset5 - (V_LevelNameWidth(tut1text)/2), ttheight, 0, tut1text); - ttheight += V_LevelNameHeight(tut2text) + 2; - V_DrawLevelTitle(BASEVIDWIDTH/2 + xoffset6 - (V_LevelNameWidth(tut2text)/2), ttheight, 0, tut2text); + ttheight = 108; + V_DrawLevelTitle(BASEVIDWIDTH/2 + xoffset4 - (V_LevelNameWidth(ringtext)/2), ttheight, 0, ringtext); + ttheight += V_LevelNameHeight(tut1text) + 2; + V_DrawLevelTitle(BASEVIDWIDTH/2 + xoffset5 - (V_LevelNameWidth(tut1text)/2), ttheight, 0, tut1text); + ttheight += V_LevelNameHeight(tut2text) + 2; + V_DrawLevelTitle(BASEVIDWIDTH/2 + xoffset6 - (V_LevelNameWidth(tut2text)/2), ttheight, 0, tut2text); + } } else { INT32 yoffset = 0; - if (data.spec.passed1[0] != '\0') + + if (LUA_HudEnabled(hud_intermissiontitletext)) { - ttheight = 24; - V_DrawLevelTitle(data.spec.passedx1 + xoffset1, ttheight, 0, data.spec.passed1); - ttheight += V_LevelNameHeight(data.spec.passed2) + 2; - V_DrawLevelTitle(data.spec.passedx2 + xoffset2, ttheight, 0, data.spec.passed2); - } - else - { - ttheight = 24 + (V_LevelNameHeight(data.spec.passed2)/2) + 2; - V_DrawLevelTitle(data.spec.passedx2 + xoffset1, ttheight, 0, data.spec.passed2); + if (data.spec.passed1[0] != '\0') + { + ttheight = 24; + V_DrawLevelTitle(data.spec.passedx1 + xoffset1, ttheight, 0, data.spec.passed1); + ttheight += V_LevelNameHeight(data.spec.passed2) + 2; + V_DrawLevelTitle(data.spec.passedx2 + xoffset2, ttheight, 0, data.spec.passed2); + } + else + { + ttheight = 24 + (V_LevelNameHeight(data.spec.passed2)/2) + 2; + V_DrawLevelTitle(data.spec.passedx2 + xoffset1, ttheight, 0, data.spec.passed2); + } } V_DrawScaledPatch(152 + xoffset3, 108, 0, data.spec.bonuspatches[0]); From 43c21edcbd9185dacb3f271a6c7d7733500951eb Mon Sep 17 00:00:00 2001 From: GoldenTails Date: Thu, 17 Dec 2020 03:09:20 -0600 Subject: [PATCH 0700/1080] Send IntermissionThinker and intermission hud hooks `stagefailed`. --- src/lua_hook.h | 2 +- src/lua_hooklib.c | 7 +++++-- src/lua_hud.h | 2 +- src/lua_hudlib.c | 12 ++++++++---- src/y_inter.c | 4 ++-- 5 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/lua_hook.h b/src/lua_hook.h index 0d631aa4e..fa6df2ee9 100644 --- a/src/lua_hook.h +++ b/src/lua_hook.h @@ -111,7 +111,7 @@ boolean LUAh_MapThingSpawn(mobj_t *mo, mapthing_t *mthing); // Hook for P_SpawnM boolean LUAh_FollowMobj(player_t *player, mobj_t *mobj); // Hook for P_PlayerAfterThink Smiles mobj-following UINT8 LUAh_PlayerCanDamage(player_t *player, mobj_t *mobj); // Hook for P_PlayerCanDamage void LUAh_PlayerQuit(player_t *plr, kickreason_t reason); // Hook for player quitting -void LUAh_IntermissionThinker(void); // Hook for Y_Ticker +void LUAh_IntermissionThinker(boolean stagefailed); // Hook for Y_Ticker boolean LUAh_TeamSwitch(player_t *player, int newteam, boolean fromspectators, boolean tryingautobalance, boolean tryingscramble); // Hook for team switching in... uh.... UINT8 LUAh_ViewpointSwitch(player_t *player, player_t *newdisplayplayer, boolean forced); // Hook for spy mode boolean LUAh_SeenPlayer(player_t *player, player_t *seenfriend); // Hook for MT_NAMECHECK diff --git a/src/lua_hooklib.c b/src/lua_hooklib.c index 1665e36b0..130fc0a28 100644 --- a/src/lua_hooklib.c +++ b/src/lua_hooklib.c @@ -1633,7 +1633,7 @@ void LUAh_PlayerQuit(player_t *plr, kickreason_t reason) } // Hook for Y_Ticker -void LUAh_IntermissionThinker(void) +void LUAh_IntermissionThinker(boolean failedstage) { hook_p hookp; if (!gL || !(hooksAvailable[hook_IntermissionThinker/8] & (1<<(hook_IntermissionThinker%8)))) @@ -1646,8 +1646,11 @@ void LUAh_IntermissionThinker(void) if (hookp->type != hook_IntermissionThinker) continue; + lua_pushboolean(gL, failedstage); // stagefailed + PushHook(gL, hookp); - if (lua_pcall(gL, 0, 0, 1)) { + lua_pushvalue(gL, -2); // stagefailed + if (lua_pcall(gL, 1, 0, 1)) { if (!hookp->error || cv_debug & DBG_LUA) CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); lua_pop(gL, 1); diff --git a/src/lua_hud.h b/src/lua_hud.h index 0a83b6de7..a7f17aab5 100644 --- a/src/lua_hud.h +++ b/src/lua_hud.h @@ -51,4 +51,4 @@ void LUAh_GameHUD(player_t *stplyr); void LUAh_ScoresHUD(void); void LUAh_TitleHUD(void); void LUAh_TitleCardHUD(player_t *stplayr); -void LUAh_IntermissionHUD(void); +void LUAh_IntermissionHUD(boolean failedstage); diff --git a/src/lua_hudlib.c b/src/lua_hudlib.c index 862ab4423..3dacd121e 100644 --- a/src/lua_hudlib.c +++ b/src/lua_hudlib.c @@ -1386,7 +1386,7 @@ void LUAh_TitleCardHUD(player_t *stplayr) hud_running = false; } -void LUAh_IntermissionHUD(void) +void LUAh_IntermissionHUD(boolean failedstage) { if (!gL || !(hudAvailable & (1< Date: Thu, 17 Dec 2020 12:26:27 -0600 Subject: [PATCH 0701/1080] Allow Lua to draw level title strings, and get the width and height of what would be drawn --- src/lua_hudlib.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/src/lua_hudlib.c b/src/lua_hudlib.c index 3dacd121e..951c63e54 100644 --- a/src/lua_hudlib.c +++ b/src/lua_hudlib.c @@ -859,6 +859,26 @@ static int libd_drawScaledNameTag(lua_State *L) return 0; } +static int libd_drawLevelTitle(lua_State *L) +{ + INT32 x; + INT32 y; + const char *str; + INT32 flags; + + HUDONLY + + x = luaL_checkinteger(L, 1); + y = luaL_checkinteger(L, 2); + str = luaL_checkstring(L, 3); + flags = luaL_optinteger(L, 4, 0); + + flags &= ~V_PARAMMASK; // Don't let crashes happen. + + V_DrawLevelTitle(x, y, flags, str); + return 0; +} + static int libd_stringWidth(lua_State *L) { const char *str = luaL_checkstring(L, 1); @@ -888,6 +908,20 @@ static int libd_nameTagWidth(lua_State *L) return 1; } +static int libd_levelTitleWidth(lua_State *L) +{ + HUDONLY + lua_pushinteger(L, V_LevelNameWidth(luaL_checkstring(L, 1))); + return 1; +} + +static int libd_levelTitleHeight(lua_State *L) +{ + HUDONLY + lua_pushinteger(L, V_LevelNameHeight(luaL_checkstring(L, 1))); + return 1; +} + static int libd_getColormap(lua_State *L) { INT32 skinnum = TC_DEFAULT; @@ -1093,10 +1127,13 @@ static luaL_Reg lib_draw[] = { {"drawString", libd_drawString}, {"drawNameTag", libd_drawNameTag}, {"drawScaledNameTag", libd_drawScaledNameTag}, + {"drawLevelTitle", libd_drawLevelTitle}, {"fadeScreen", libd_fadeScreen}, // misc {"stringWidth", libd_stringWidth}, {"nameTagWidth", libd_nameTagWidth}, + {"levelTitleWidth", libd_levelTitleWidth}, + {"levelTitleHeight", libd_levelTitleHeight}, // m_random {"RandomFixed",libd_RandomFixed}, {"RandomByte",libd_RandomByte}, From abc886b9ac25cd5528142b09c62498b335f3c22f Mon Sep 17 00:00:00 2001 From: SMS Alfredo <65426124+SMS-Alfredo@users.noreply.github.com> Date: Wed, 21 Apr 2021 18:20:56 -0500 Subject: [PATCH 0702/1080] REVERSESUPER rises from the grave --- src/deh_lua.c | 5 +++++ src/p_mobj.h | 2 ++ 2 files changed, 7 insertions(+) diff --git a/src/deh_lua.c b/src/deh_lua.c index e6a436421..e920154cc 100644 --- a/src/deh_lua.c +++ b/src/deh_lua.c @@ -264,6 +264,11 @@ static inline int lib_getenum(lua_State *L) lua_pushinteger(L, ((lua_Integer)1< Date: Wed, 21 Apr 2021 19:58:14 -0400 Subject: [PATCH 0703/1080] Kart cmd->latency port Nev3r was talking about something that would've been drastically improved with this, and it is really simple, so I ported it :) --- src/d_ticcmd.h | 3 +++ src/g_demo.c | 12 ++++++++++++ src/g_game.c | 8 ++++++++ src/lua_playerlib.c | 6 ++++++ 4 files changed, 29 insertions(+) diff --git a/src/d_ticcmd.h b/src/d_ticcmd.h index 2a5ef0981..04cbeef19 100644 --- a/src/d_ticcmd.h +++ b/src/d_ticcmd.h @@ -21,6 +21,8 @@ #pragma interface #endif +#define MAXPREDICTTICS 12 + // Button/action code definitions. typedef enum { @@ -63,6 +65,7 @@ typedef struct INT16 angleturn; // <<16 for angle delta - saved as 1 byte into demos INT16 aiming; // vertical aiming, see G_BuildTicCmd UINT16 buttons; + UINT8 latency; // Netgames: how many tics ago was this ticcmd generated from this player's end? } ATTRPACK ticcmd_t; #if defined(_MSC_VER) diff --git a/src/g_demo.c b/src/g_demo.c index 593fd7723..16477ab48 100644 --- a/src/g_demo.c +++ b/src/g_demo.c @@ -109,6 +109,7 @@ demoghost *ghosts = NULL; #define ZT_ANGLE 0x04 #define ZT_BUTTONS 0x08 #define ZT_AIMING 0x10 +#define ZT_LATENCY 0x20 #define DEMOMARKER 0x80 // demoend #define METALDEATH 0x44 #define METALSNICE 0x69 @@ -181,6 +182,8 @@ void G_ReadDemoTiccmd(ticcmd_t *cmd, INT32 playernum) oldcmd.buttons = (oldcmd.buttons & (BT_CAMLEFT|BT_CAMRIGHT)) | (READUINT16(demo_p) & ~(BT_CAMLEFT|BT_CAMRIGHT)); if (ziptic & ZT_AIMING) oldcmd.aiming = READINT16(demo_p); + if (ziptic & ZT_LATENCY) + oldcmd.latency = READUINT8(demo_p); G_CopyTiccmd(cmd, &oldcmd, 1); players[playernum].angleturn = cmd->angleturn; @@ -238,6 +241,13 @@ void G_WriteDemoTiccmd(ticcmd_t *cmd, INT32 playernum) ziptic |= ZT_AIMING; } + if (cmd->latency != oldcmd.latency) + { + WRITEUINT8(demo_p,cmd->latency); + oldcmd.latency = cmd->latency; + ziptic |= ZT_LATENCY; + } + *ziptic_p = ziptic; // attention here for the ticcmd size! @@ -679,6 +689,8 @@ void G_GhostTicker(void) g->p += 2; if (ziptic & ZT_AIMING) g->p += 2; + if (ziptic & ZT_LATENCY) + g->p++; // Grab ghost data. ziptic = READUINT8(g->p); diff --git a/src/g_game.c b/src/g_game.c index 13423ce77..c6b3292b0 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1693,6 +1693,10 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) cmd->angleturn = origangle + extra; *myangle += extra << 16; *myaiming += (cmd->aiming - origaiming) << 16; + + // Send leveltime when this tic was generated to the server for control lag calculations. + // Only do this when in a level. Also do this after the hook, so that it can't overwrite this. + cmd->latency = (leveltime & 0xFF); } //Reset away view if a command is given. @@ -1724,6 +1728,7 @@ ticcmd_t *G_MoveTiccmd(ticcmd_t* dest, const ticcmd_t* src, const size_t n) dest[i].angleturn = SHORT(src[i].angleturn); dest[i].aiming = (INT16)SHORT(src[i].aiming); dest[i].buttons = (UINT16)SHORT(src[i].buttons); + dest[i].latency = src[i].latency; } return dest; } @@ -2306,6 +2311,9 @@ void G_Ticker(boolean run) players[i].cmd.angleturn &= ~TICCMD_RECEIVED; players[i].cmd.angleturn |= received; + + // Use the leveltime sent in the player's ticcmd to determine control lag + players[i].cmd.latency = min(((leveltime & 0xFF) - players[i].cmd.latency) & 0xFF, MAXPREDICTTICS-1); } } diff --git a/src/lua_playerlib.c b/src/lua_playerlib.c index 0eb54808f..d37d46c42 100644 --- a/src/lua_playerlib.c +++ b/src/lua_playerlib.c @@ -795,6 +795,7 @@ static int power_len(lua_State *L) } #define NOFIELD luaL_error(L, LUA_QL("ticcmd_t") " has no field named " LUA_QS, field) +#define NOSET luaL_error(L, LUA_QL("ticcmd_t") " field " LUA_QS " should not be set directly.", field) static int ticcmd_get(lua_State *L) { @@ -813,6 +814,8 @@ static int ticcmd_get(lua_State *L) lua_pushinteger(L, cmd->aiming); else if (fastcmp(field,"buttons")) lua_pushinteger(L, cmd->buttons); + else if (fastcmp(field,"latency")) + lua_pushinteger(L, cmd->latency); else return NOFIELD; @@ -839,6 +842,8 @@ static int ticcmd_set(lua_State *L) cmd->aiming = (INT16)luaL_checkinteger(L, 3); else if (fastcmp(field,"buttons")) cmd->buttons = (UINT16)luaL_checkinteger(L, 3); + else if (fastcmp(field,"latency")) + return NOSET; else return NOFIELD; @@ -846,6 +851,7 @@ static int ticcmd_set(lua_State *L) } #undef NOFIELD +#undef NOSET int LUA_PlayerLib(lua_State *L) { From da56e84d2c1f202789c87afc3aeab6c3b6eb65b1 Mon Sep 17 00:00:00 2001 From: Tatsuru <44866610+TatsuruIKR@users.noreply.github.com> Date: Wed, 21 Apr 2021 22:14:37 -0300 Subject: [PATCH 0704/1080] Change TOL_ERZ3 identifier --- 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 13423ce77..bd09e4c79 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -3506,7 +3506,7 @@ tolinfo_t TYPEOFLEVEL[NUMTOLNAMES] = { {"2D",TOL_2D}, {"MARIO",TOL_MARIO}, {"NIGHTS",TOL_NIGHTS}, - {"OLDBRAK",TOL_ERZ3}, + {"ERZ3",TOL_ERZ3}, {"XMAS",TOL_XMAS}, {"CHRISTMAS",TOL_XMAS}, From 4f2f94d02d4f982d05900e10b5f00be28b0599ac Mon Sep 17 00:00:00 2001 From: Tatsuru <44866610+TatsuruIKR@users.noreply.github.com> Date: Wed, 21 Apr 2021 22:22:37 -0300 Subject: [PATCH 0705/1080] Compatibility with the current identifier --- src/g_game.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/g_game.c b/src/g_game.c index bd09e4c79..399c4f2bd 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -3506,6 +3506,7 @@ tolinfo_t TYPEOFLEVEL[NUMTOLNAMES] = { {"2D",TOL_2D}, {"MARIO",TOL_MARIO}, {"NIGHTS",TOL_NIGHTS}, + {"OLDBRAK",TOL_ERZ3}, {"ERZ3",TOL_ERZ3}, {"XMAS",TOL_XMAS}, From e510e71617a2102001d5038dbc48c7abdf855792 Mon Sep 17 00:00:00 2001 From: Radicalicious Date: Fri, 23 Apr 2021 15:50:48 -0400 Subject: [PATCH 0706/1080] Remove fire shield flash --- src/p_mobj.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index 7ba6d1fad..59f306d1d 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -3283,11 +3283,9 @@ void P_MobjCheckWater(mobj_t *mobj) boolean electric = !!(p->powers[pw_shield] & SH_PROTECTELECTRIC); if (electric || ((p->powers[pw_shield] & SH_PROTECTFIRE) && !(p->powers[pw_shield] & SH_PROTECTWATER) && !(mobj->eflags & MFE_TOUCHLAVA))) { // Water removes electric and non-water fire shields... - P_FlashPal(p, - electric - ? PAL_WHITE - : PAL_NUKE, - 1); + if (electric) + P_FlashPal(p, PAL_WHITE, 1); + p->powers[pw_shield] = p->powers[pw_shield] & SH_STACK; } } From 8278e621fb5cbe685c014c1e72c9145e9c906909 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Sun, 25 Apr 2021 07:18:32 -0400 Subject: [PATCH 0707/1080] Removed skin->availability Locked skins now are a specific unlockable type, instead of being tied to the skin's properties. This has plagued custom gamedata since 2.2 launch. It's extremely obnoxious having to set aside random numbers as dummy unlockables just to ensure that Amy Fang & Metal are unlocked from the start in a custom map pack. Other changes made to accommodate this: - R_GetSkinAvailabilities is now created from the list of unlockables set to skin type. (1st skin unlockable defined is (1), 2nd skin unlockable defined is (1 << 1), etc...) - The "Added skin x" print shows up when loading addons but not at all for the base game, because the previous behavior of hiding based on if the skin was locked would now require iterating unlockables, which felt wrong to do during that stage of the loading process - I noticed in my test wad that Sonic&Tails would give you Sonic&Sonic out if Tails was locked. I fixed that by making both skins required to show the character select option. Mods that reserved empty dummy unlockables for Amy Fang and Metal won't have to do anything. Mods that wanted to re-lock them behind different requirements will have to update, but in the future they will not have to be in specific slots. Additionally, now Sonic Tails and Knuckles can also be locked for mods. --- src/d_netcmd.c | 26 ++++++++-- src/deh_soc.c | 23 ++++++--- src/lua_skinlib.c | 5 -- src/m_cond.h | 1 + src/m_menu.c | 9 +++- src/p_enemy.c | 29 +++++++++-- src/p_setup.c | 4 +- src/r_skins.c | 120 ++++++++++++++++++++++++++++++++++++---------- src/r_skins.h | 6 +-- src/r_things.c | 4 +- 10 files changed, 175 insertions(+), 52 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 09f9d4651..9261770c7 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -1475,7 +1475,8 @@ static void Got_NameAndColor(UINT8 **cp, INT32 playernum) if (server && (p != &players[consoleplayer] && p != &players[secondarydisplayplayer])) { boolean kick = false; - INT32 s; + UINT32 unlockShift = 0; + UINT32 i; // team colors if (G_GametypeHasTeams()) @@ -1491,12 +1492,29 @@ static void Got_NameAndColor(UINT8 **cp, INT32 playernum) kick = true; // availabilities - for (s = 0; s < MAXSKINS; s++) + for (i = 0; i < MAXUNLOCKABLES; i++) { - if (!skins[s].availability && (p->availabilities & (1 << s))) + if (unlockables[i].type != SECRET_SKIN) + { + continue; + } + + unlockShift++; + } + + // If they set an invalid bit to true, then likely a modified client + if (unlockShift < 32) // 32 is the max the data type allows + { + UINT32 illegalMask = UINT32_MAX; + + for (i = 0; i < unlockShift; i++) + { + illegalMask &= ~(1 << i); + } + + if ((p->availabilities & illegalMask) != 0) { kick = true; - break; } } diff --git a/src/deh_soc.c b/src/deh_soc.c index 5b12ea1b0..e5cba5185 100644 --- a/src/deh_soc.c +++ b/src/deh_soc.c @@ -3219,19 +3219,30 @@ void readunlockable(MYFILE *f, INT32 num) unlockables[num].type = SECRET_WARP; else if (fastcmp(word2, "SOUNDTEST")) unlockables[num].type = SECRET_SOUNDTEST; + else if (fastcmp(word2, "SKIN")) + unlockables[num].type = SECRET_SKIN; else unlockables[num].type = (INT16)i; } else if (fastcmp(word, "VAR")) { - // Support using the actual map name, - // i.e., Level AB, Level FZ, etc. + INT32 skinnum = R_SkinAvailable(word2); - // Convert to map number - if (word2[0] >= 'A' && word2[0] <= 'Z') - i = M_MapNumber(word2[0], word2[1]); + if (skinnum != -1) + { + unlockables[num].variable = (INT16)skinnum; + } + else + { + // Support using the actual map name, + // i.e., Level AB, Level FZ, etc. - unlockables[num].variable = (INT16)i; + // Convert to map number + if (word2[0] >= 'A' && word2[0] <= 'Z') + i = M_MapNumber(word2[0], word2[1]); + + unlockables[num].variable = (INT16)i; + } } else deh_warning("Unlockable %d: unknown word '%s'", num+1, word); diff --git a/src/lua_skinlib.c b/src/lua_skinlib.c index 56be6bf4f..f6c0879bd 100644 --- a/src/lua_skinlib.c +++ b/src/lua_skinlib.c @@ -53,7 +53,6 @@ enum skin { skin_contspeed, skin_contangle, skin_soundsid, - skin_availability, skin_sprites }; static const char *const skin_opt[] = { @@ -91,7 +90,6 @@ static const char *const skin_opt[] = { "contspeed", "contangle", "soundsid", - "availability", "sprites", NULL}; @@ -209,9 +207,6 @@ static int skin_get(lua_State *L) case skin_soundsid: LUA_PushUserdata(L, skin->soundsid, META_SOUNDSID); break; - case skin_availability: - lua_pushinteger(L, skin->availability); - break; case skin_sprites: LUA_PushLightUserdata(L, skin->sprites, META_SKINSPRITES); break; diff --git a/src/m_cond.h b/src/m_cond.h index 9bb162ff3..08b47c63a 100644 --- a/src/m_cond.h +++ b/src/m_cond.h @@ -132,6 +132,7 @@ typedef struct #define SECRET_WARP 2 // Selectable warp #define SECRET_SOUNDTEST 3 // Sound Test #define SECRET_CREDITS 4 // Enables Credits +#define SECRET_SKIN 5 // Unlocks a skin // If you have more secrets than these variables allow in your game, // you seriously need to get a life. diff --git a/src/m_menu.c b/src/m_menu.c index 0fca39801..651dbecc6 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -8963,7 +8963,7 @@ static void M_CacheCharacterSelectEntry(INT32 i, INT32 skinnum) static UINT8 M_SetupChoosePlayerDirect(INT32 choice) { - INT32 skinnum; + INT32 skinnum, botskin; UINT8 i; UINT8 firstvalid = 255, lastvalid = 255; boolean allowed = false; @@ -8995,6 +8995,13 @@ static UINT8 M_SetupChoosePlayerDirect(INT32 choice) skinnum = description[i].skinnum[0]; if ((skinnum != -1) && (R_SkinUsable(-1, skinnum))) { + botskin = description[i].skinnum[1]; + if ((botskin != -1) && (!R_SkinUsable(-1, botskin))) + { + // Bot skin isn't unlocked + continue; + } + // Handling order. if (firstvalid == 255) firstvalid = i; diff --git a/src/p_enemy.c b/src/p_enemy.c index 59176d6cc..306b8b399 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -25,6 +25,7 @@ #include "i_video.h" #include "z_zone.h" #include "lua_hook.h" +#include "m_cond.h" // SECRET_SKIN #ifdef HW3SOUND #include "hardware/hw3sound.h" @@ -5101,6 +5102,28 @@ void A_SignSpin(mobj_t *actor) } } +static boolean SignSkinCheck(player_t *player, INT32 num) +{ + INT32 i; + + if (player != NULL) + { + // Use player's availabilities + return R_SkinUsable(player - players, num); + } + + // Player invalid, only show characters that are unlocked from the start. + for (i = 0; i < MAXUNLOCKABLES; i++) + { + if (unlockables[i].type == SECRET_SKIN && unlockables[i].variable == num) + { + return false; + } + } + + return true; +} + // Function: A_SignPlayer // // Description: Changes the state of a level end sign to reflect the player that hit it. @@ -5161,23 +5184,21 @@ void A_SignPlayer(mobj_t *actor) // I turned this function into a fucking mess. I'm so sorry. -Lach if (locvar1 == -2) // random skin { -#define skincheck(num) (player ? !R_SkinUsable(player-players, num) : skins[num].availability > 0) player_t *player = actor->target ? actor->target->player : NULL; UINT8 skinnum; UINT8 skincount = 0; for (skinnum = 0; skinnum < numskins; skinnum++) - if (!skincheck(skinnum)) + if (SignSkinCheck(player, skinnum)) skincount++; skinnum = P_RandomKey(skincount); for (skincount = 0; skincount < numskins; skincount++) { if (skincount > skinnum) break; - if (skincheck(skincount)) + if (!SignSkinCheck(player, skincount)) skinnum++; } skin = &skins[skinnum]; -#undef skincheck } else // specific skin skin = &skins[locvar1]; diff --git a/src/p_setup.c b/src/p_setup.c index 40dd1a284..ae68bac80 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -4527,8 +4527,8 @@ boolean P_AddWadFile(const char *wadfilename) // // look for skins // - R_AddSkins(wadnum); // faB: wadfile index in wadfiles[] - R_PatchSkins(wadnum); // toast: PATCH PATCH + R_AddSkins(wadnum, false); // faB: wadfile index in wadfiles[] + R_PatchSkins(wadnum, false); // toast: PATCH PATCH ST_ReloadSkinFaceGraphics(); // diff --git a/src/r_skins.c b/src/r_skins.c index 6f150f234..587259ae0 100644 --- a/src/r_skins.c +++ b/src/r_skins.c @@ -148,8 +148,6 @@ static void Sk_SetDefaultValue(skin_t *skin) skin->contspeed = 17; skin->contangle = 0; - skin->availability = 0; - for (i = 0; i < sfx_skinsoundslot0; i++) if (S_sfx[i].skinsound != -1) skin->soundsid[S_sfx[i].skinsound] = i; @@ -176,14 +174,34 @@ void R_InitSkins(void) UINT32 R_GetSkinAvailabilities(void) { - INT32 s; UINT32 response = 0; + UINT32 unlockShift = 0; + INT32 i; - for (s = 0; s < MAXSKINS; s++) + for (i = 0; i < MAXUNLOCKABLES; i++) { - if (skins[s].availability && unlockables[skins[s].availability - 1].unlocked) - response |= (1 << s); + if (unlockables[i].type != SECRET_SKIN) + { + continue; + } + + if (unlockShift >= 32) + { + // This crash is impossible to trigger as is, + // but it could happen if MAXUNLOCKABLES is ever made higher than 32, + // and someone makes a mod that has 33+ unlockable characters. :V + I_Error("Too many unlockable characters\n"); + return 0; + } + + if (unlockables[i].unlocked) + { + response |= (1 << unlockShift); + } + + unlockShift++; } + return response; } @@ -191,14 +209,74 @@ UINT32 R_GetSkinAvailabilities(void) // warning don't use with an invalid skinnum other than -1 which always returns true boolean R_SkinUsable(INT32 playernum, INT32 skinnum) { - return ((skinnum == -1) // Simplifies things elsewhere, since there's already plenty of checks for less-than-0... - || (!skins[skinnum].availability) - || (((netgame || multiplayer) && playernum != -1) ? (players[playernum].availabilities & (1 << skinnum)) : (unlockables[skins[skinnum].availability - 1].unlocked)) - || (modeattacking) // If you have someone else's run you might as well take a look - || (Playing() && (R_SkinAvailable(mapheaderinfo[gamemap-1]->forcecharacter) == skinnum)) // Force 1. - || (netgame && (cv_forceskin.value == skinnum)) // Force 2. - || (metalrecording && skinnum == 5) // Force 3. - ); + INT32 unlockID = -1; + UINT32 unlockShift = 0; + INT32 i; + + if (skinnum == -1) + { + // Simplifies things elsewhere, since there's already plenty of checks for less-than-0... + return true; + } + + if (modeattacking) + { + // If you have someone else's run you might as well take a look + return true; + } + + if (Playing() && (R_SkinAvailable(mapheaderinfo[gamemap-1]->forcecharacter) == skinnum)) + { + // Force 1. + return true; + } + + if (netgame && (cv_forceskin.value == skinnum)) + { + // Force 2. + return true; + } + + if (metalrecording && skinnum == 5) + { + // Force 3. + return true; + } + + // We will now check if this skin is supposed to be locked or not. + + for (i = 0; i < MAXUNLOCKABLES; i++) + { + if (unlockables[i].type != SECRET_SKIN) + { + continue; + } + + if (unlockables[i].variable == skinnum) + { + unlockID = i; + break; + } + + unlockShift++; + } + + if (unlockID == -1) + { + // This skin isn't locked at all, we're good. + return true; + } + + if ((netgame || multiplayer) && playernum != -1) + { + // We want to check per-player unlockables. + return (players[playernum].availabilities & (1 << unlockShift)); + } + else + { + // We want to check our global unlockables. + return (unlockables[unlockID].unlocked); + } } // returns true if the skin name is found (loaded from pwad) @@ -558,7 +636,7 @@ static boolean R_ProcessPatchableFields(skin_t *skin, char *stoken, char *value) // // Find skin sprites, sounds & optional status bar face, & add them // -void R_AddSkins(UINT16 wadnum) +void R_AddSkins(UINT16 wadnum, boolean mainfile) { UINT16 lump, lastlump = 0; char *buf; @@ -673,12 +751,6 @@ void R_AddSkins(UINT16 wadnum) if (!realname) STRBUFCPY(skin->realname, skin->hudname); } - else if (!stricmp(stoken, "availability")) - { - skin->availability = atoi(value); - if (skin->availability >= MAXUNLOCKABLES) - skin->availability = 0; - } else if (!R_ProcessPatchableFields(skin, stoken, value)) CONS_Debug(DBG_SETUP, "R_AddSkins: Unknown keyword '%s' in S_SKIN lump #%d (WAD %s)\n", stoken, lump, wadfiles[wadnum]->filename); @@ -693,7 +765,7 @@ next_token: R_FlushTranslationColormapCache(); - if (!skin->availability) // Safe to print... + if (mainfile == false) CONS_Printf(M_GetText("Added skin '%s'\n"), skin->name); #ifdef SKINVALUES skin_cons_t[numskins].value = numskins; @@ -713,7 +785,7 @@ next_token: // // Patch skin sprites // -void R_PatchSkins(UINT16 wadnum) +void R_PatchSkins(UINT16 wadnum, boolean mainfile) { UINT16 lump, lastlump = 0; char *buf; @@ -826,7 +898,7 @@ next_token: R_FlushTranslationColormapCache(); - if (!skin->availability) // Safe to print... + if (mainfile == false) CONS_Printf(M_GetText("Patched skin '%s'\n"), skin->name); } return; diff --git a/src/r_skins.h b/src/r_skins.h index fbbb38743..5efd70307 100644 --- a/src/r_skins.h +++ b/src/r_skins.h @@ -80,8 +80,6 @@ typedef struct // contains super versions too spritedef_t sprites[NUMPLAYERSPRITES*2]; spriteinfo_t sprinfo[NUMPLAYERSPRITES*2]; - - UINT8 availability; // lock? } skin_t; /// Externs @@ -96,8 +94,8 @@ void SetPlayerSkinByNum(INT32 playernum,INT32 skinnum); // Tails 03-16-2002 boolean R_SkinUsable(INT32 playernum, INT32 skinnum); UINT32 R_GetSkinAvailabilities(void); INT32 R_SkinAvailable(const char *name); -void R_PatchSkins(UINT16 wadnum); -void R_AddSkins(UINT16 wadnum); +void R_AddSkins(UINT16 wadnum, boolean mainfile); +void R_PatchSkins(UINT16 wadnum, boolean mainfile); UINT8 P_GetSkinSprite2(skin_t *skin, UINT8 spr2, player_t *player); diff --git a/src/r_things.c b/src/r_things.c index a7c44c237..c5cf3aeae 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -547,8 +547,8 @@ void R_InitSprites(void) R_InitSkins(); for (i = 0; i < numwadfiles; i++) { - R_AddSkins((UINT16)i); - R_PatchSkins((UINT16)i); + R_AddSkins((UINT16)i, true); + R_PatchSkins((UINT16)i, true); R_LoadSpriteInfoLumps(i, wadfiles[i]->numlumps); } ST_ReloadSkinFaceGraphics(); From 376d6cd6a200128168f8d6b2c9575257d48aa575 Mon Sep 17 00:00:00 2001 From: Tatsuru <44866610+TatsuruIKR@users.noreply.github.com> Date: Sun, 25 Apr 2021 14:26:43 -0300 Subject: [PATCH 0708/1080] Don't try to free patches in dedicated --- src/y_inter.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/y_inter.c b/src/y_inter.c index dca8cd377..4354a1677 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -2069,7 +2069,8 @@ static void Y_AwardSpecialStageBonus(void) // void Y_EndIntermission(void) { - Y_UnloadData(); + if (!dedicated) + Y_UnloadData(); endtic = -1; intertype = int_none; From 65624bf6c0892b2b8f7579fa8eaf1f5cd66a17ee Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Sun, 25 Apr 2021 19:01:51 +0100 Subject: [PATCH 0709/1080] Change numadded counter to UINT16 instead of UINT8, to allow for more sprites properly --- src/r_things.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/r_things.c b/src/r_things.c index a7c44c237..5c0e5fda9 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -230,7 +230,7 @@ boolean R_AddSingleSpriteDef(const char *sprname, spritedef_t *spritedef, UINT16 UINT8 rotation; lumpinfo_t *lumpinfo; softwarepatch_t patch; - UINT8 numadded = 0; + UINT16 numadded = 0; memset(sprtemp,0xFF, sizeof (sprtemp)); maxframe = (size_t)-1; From 70939a7a3dc75faf77ab0d1d7e3c967d8c1f6927 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Sun, 25 Apr 2021 21:08:12 +0100 Subject: [PATCH 0710/1080] Set "allocated" flag to off if setting a string from PossibleValue afterwards, or if not setting a new value at all. --- src/command.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/command.c b/src/command.c index 58434ef89..f1bf7dfb5 100644 --- a/src/command.c +++ b/src/command.c @@ -1433,6 +1433,7 @@ static void Setvalue(consvar_t *var, const char *valstr, boolean stealth) if (var->revert.allocated) { Z_Free(var->revert.v.string); + var->revert.allocated = false; // the below value is not allocated in zone memory, don't try to free it! } var->revert.v.const_munge = var->PossibleValue[i].strvalue; @@ -1505,6 +1506,7 @@ found: if (var->revert.allocated) { Z_Free(var->revert.v.string); + var->revert.allocated = false; // the below value is not allocated in zone memory, don't try to free it! } var->revert.v.const_munge = var->PossibleValue[i].strvalue; @@ -1523,6 +1525,7 @@ found: if (var->revert.allocated) { Z_Free(var->revert.v.string); + // Z_StrDup creates a new zone memory block, so we can keep the allocated flag on } var->revert.v.string = Z_StrDup(valstr); @@ -1787,6 +1790,7 @@ void CV_RevertNetVars(void) if (cvar->revert.allocated) { Z_Free(cvar->revert.v.string); + cvar->revert.allocated = false; // no value being held now } cvar->revert.v.string = NULL; From 382c0aa7de42b38e647bdfd3b157ff239d1bb5fc Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Sun, 25 Apr 2021 16:27:15 -0400 Subject: [PATCH 0711/1080] Fix overshadowed declaration --- src/m_menu.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index 651dbecc6..eb330c9e9 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -8963,7 +8963,7 @@ static void M_CacheCharacterSelectEntry(INT32 i, INT32 skinnum) static UINT8 M_SetupChoosePlayerDirect(INT32 choice) { - INT32 skinnum, botskin; + INT32 skinnum, botskinnum; UINT8 i; UINT8 firstvalid = 255, lastvalid = 255; boolean allowed = false; @@ -8995,8 +8995,8 @@ static UINT8 M_SetupChoosePlayerDirect(INT32 choice) skinnum = description[i].skinnum[0]; if ((skinnum != -1) && (R_SkinUsable(-1, skinnum))) { - botskin = description[i].skinnum[1]; - if ((botskin != -1) && (!R_SkinUsable(-1, botskin))) + botskinnum = description[i].skinnum[1]; + if ((botskinnum != -1) && (!R_SkinUsable(-1, botskinnum))) { // Bot skin isn't unlocked continue; From f0b9e0e415982f5dfee3942bb8cbdabc80a2b16f Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Sun, 25 Apr 2021 16:38:33 -0400 Subject: [PATCH 0712/1080] Default to first usable skin instead of 0, I_Error if none are usable --- src/r_skins.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/r_skins.c b/src/r_skins.c index 587259ae0..758d0980d 100644 --- a/src/r_skins.c +++ b/src/r_skins.c @@ -294,6 +294,23 @@ INT32 R_SkinAvailable(const char *name) return -1; } +// Gets the player to the first usuable skin in the game. (If your mod locked them all, then you kinda stupid) +void SetPlayerDefaultSkin(INT32 playernum) +{ + INT32 i; + + for (i = 0; i < numskins; i++) + { + if (R_SkinUsable(playernum, i)) + { + SetPlayerSkinByNum(playernum, i); + return; + } + } + + I_Error("All characters are locked."); +} + // network code calls this when a 'skin change' is received void SetPlayerSkin(INT32 playernum, const char *skinname) { @@ -311,7 +328,7 @@ void SetPlayerSkin(INT32 playernum, const char *skinname) else if(server || IsPlayerAdmin(consoleplayer)) CONS_Alert(CONS_WARNING, M_GetText("Player %d (%s) skin '%s' not found\n"), playernum, player_names[playernum], skinname); - SetPlayerSkinByNum(playernum, 0); + SetPlayerDefaultSkin(playernum); } // Same as SetPlayerSkin, but uses the skin #. @@ -402,7 +419,8 @@ void SetPlayerSkinByNum(INT32 playernum, INT32 skinnum) CONS_Alert(CONS_WARNING, M_GetText("Requested skin %d not found\n"), skinnum); else if(server || IsPlayerAdmin(consoleplayer)) CONS_Alert(CONS_WARNING, "Player %d (%s) skin %d not found\n", playernum, player_names[playernum], skinnum); - SetPlayerSkinByNum(playernum, 0); // not found put the sonic skin + + SetPlayerDefaultSkin(playernum); } // From 92107f28d5dc48e7cb01f0c274aef85911f0ebdd Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Sun, 25 Apr 2021 17:54:47 -0400 Subject: [PATCH 0713/1080] Add string variable for unlockables and emblems Skin unlockables / skin emblems are now checked at runtime to see if there's any matches. --- src/d_netcmd.c | 5 +++-- src/deh_soc.c | 54 +++++++++++++++++++++++++++++++++++++------------- src/deh_soc.h | 2 ++ src/dehacked.c | 7 ++----- src/m_cond.c | 48 ++++++++++++++++++++++++++++++++++++++++++++ src/m_cond.h | 5 +++++ src/p_enemy.c | 9 +++++++-- src/p_mobj.c | 16 +++++++++++++-- src/r_skins.c | 25 +++++++++++++++-------- src/r_skins.h | 2 ++ 10 files changed, 140 insertions(+), 33 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 9261770c7..17ab52eb5 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -1313,8 +1313,9 @@ static void SendNameAndColor(void) cv_skin.value = R_SkinAvailable(cv_skin.string); if ((cv_skin.value < 0) || !R_SkinUsable(consoleplayer, cv_skin.value)) { - CV_StealthSet(&cv_skin, DEFAULTSKIN); - cv_skin.value = 0; + INT32 defaultSkinNum = GetPlayerDefaultSkin(consoleplayer); + CV_StealthSet(&cv_skin, skins[defaultSkinNum].name); + cv_skin.value = defaultSkinNum; } // Finally write out the complete packet and send it off. diff --git a/src/deh_soc.c b/src/deh_soc.c index e5cba5185..1dde6c9f0 100644 --- a/src/deh_soc.c +++ b/src/deh_soc.c @@ -127,6 +127,33 @@ static float searchfvalue(const char *s) #endif // These are for clearing all of various things +void clear_emblems(void) +{ + INT32 i; + + for (i = 0; i < MAXEMBLEMS; ++i) + { + Z_Free(emblemlocations[i].stringVar); + emblemlocations[i].stringVar = NULL; + } + + memset(&emblemlocations, 0, sizeof(emblemlocations)); + numemblems = 0; +} + +void clear_unlockables(void) +{ + INT32 i; + + for (i = 0; i < MAXUNLOCKABLES; ++i) + { + Z_Free(unlockables[i].stringVar); + unlockables[i].stringVar = NULL; + } + + memset(&unlockables, 0, sizeof(unlockables)); +} + void clear_conditionsets(void) { UINT8 i; @@ -3017,7 +3044,12 @@ void reademblemdata(MYFILE *f, INT32 num) else if (fastcmp(word, "COLOR")) emblemlocations[num-1].color = get_number(word2); else if (fastcmp(word, "VAR")) + { + Z_Free(emblemlocations[num-1].stringVar); + emblemlocations[num-1].stringVar = Z_StrDup(word2); + emblemlocations[num-1].var = get_number(word2); + } else deh_warning("Emblem %d: unknown word '%s'", num, word); } @@ -3226,23 +3258,17 @@ void readunlockable(MYFILE *f, INT32 num) } else if (fastcmp(word, "VAR")) { - INT32 skinnum = R_SkinAvailable(word2); + Z_Free(unlockables[num].stringVar); + unlockables[num].stringVar = Z_StrDup(word2); - if (skinnum != -1) - { - unlockables[num].variable = (INT16)skinnum; - } - else - { - // Support using the actual map name, - // i.e., Level AB, Level FZ, etc. + // Support using the actual map name, + // i.e., Level AB, Level FZ, etc. - // Convert to map number - if (word2[0] >= 'A' && word2[0] <= 'Z') - i = M_MapNumber(word2[0], word2[1]); + // Convert to map number + if (word2[0] >= 'A' && word2[0] <= 'Z') + i = M_MapNumber(word2[0], word2[1]); - unlockables[num].variable = (INT16)i; - } + unlockables[num].variable = (INT16)i; } else deh_warning("Unlockable %d: unknown word '%s'", num+1, word); diff --git a/src/deh_soc.h b/src/deh_soc.h index 2bcb52e70..9a3b0884d 100644 --- a/src/deh_soc.h +++ b/src/deh_soc.h @@ -84,6 +84,8 @@ void readskincolor(MYFILE *f, INT32 num); void readthing(MYFILE *f, INT32 num); void readfreeslots(MYFILE *f); void readPlayer(MYFILE *f, INT32 num); +void clear_emblems(void); +void clear_unlockables(void); void clear_levels(void); void clear_conditionsets(void); #endif diff --git a/src/dehacked.c b/src/dehacked.c index c2ea28d27..a68537f77 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -562,13 +562,10 @@ static void DEH_LoadDehackedFile(MYFILE *f, boolean mainfile) } if (clearall || fastcmp(word2, "UNLOCKABLES")) - memset(&unlockables, 0, sizeof(unlockables)); + clear_unlockables(); if (clearall || fastcmp(word2, "EMBLEMS")) - { - memset(&emblemlocations, 0, sizeof(emblemlocations)); - numemblems = 0; - } + clear_emblems(); if (clearall || fastcmp(word2, "EXTRAEMBLEMS")) { diff --git a/src/m_cond.c b/src/m_cond.c index 36fcd7cf2..ee8e96d64 100644 --- a/src/m_cond.c +++ b/src/m_cond.c @@ -496,6 +496,54 @@ UINT8 M_GotHighEnoughRings(INT32 trings) return false; } +// Gets the skin number for a SECRET_SKIN unlockable. +INT32 M_UnlockableSkinNum(unlockable_t *unlock) +{ + if (unlock->type != SECRET_SKIN) + { + // This isn't a skin unlockable... + return -1; + } + + if (unlock->stringVar && strcmp(unlock->stringVar, "")) + { + // Get the skin from the string. + return R_SkinAvailable(unlock->stringVar); + } + else if (unlock->variable >= 0 && unlock->variable < numskins) + { + // Use the number directly. + return unlock->variable; + } + + // Invalid skin unlockable. + return -1; +} + +// Gets the skin number for a ET_SKIN emblem. +INT32 M_EmblemSkinNum(emblem_t *emblem) +{ + if (emblem->type != ET_SKIN) + { + // This isn't a skin emblem... + return -1; + } + + if (emblem->stringVar && strcmp(emblem->stringVar, "")) + { + // Get the skin from the string. + return R_SkinAvailable(emblem->stringVar); + } + else if (emblem->var >= 0 && emblem->var < numskins) + { + // Use the number directly. + return emblem->var; + } + + // Invalid skin emblem. + return -1; +} + // ---------------- // Misc Emblem shit // ---------------- diff --git a/src/m_cond.h b/src/m_cond.h index 08b47c63a..8003433a7 100644 --- a/src/m_cond.h +++ b/src/m_cond.h @@ -92,6 +92,7 @@ typedef struct UINT8 sprite; ///< emblem sprite to use, 0 - 25 UINT16 color; ///< skincolor to use INT32 var; ///< If needed, specifies information on the target amount to achieve (or target skin) + char *stringVar; ///< String version char hint[110]; ///< Hint for emblem hints menu UINT8 collected; ///< Do you have this emblem? } emblem_t; @@ -116,6 +117,7 @@ typedef struct UINT8 showconditionset; INT16 type; INT16 variable; + char *stringVar; UINT8 nocecho; UINT8 nochecklist; UINT8 unlocked; @@ -186,4 +188,7 @@ UINT8 M_GotHighEnoughScore(INT32 tscore); UINT8 M_GotLowEnoughTime(INT32 tictime); UINT8 M_GotHighEnoughRings(INT32 trings); +INT32 M_UnlockableSkinNum(unlockable_t *unlock); +INT32 M_EmblemSkinNum(emblem_t *emblem); + #define M_Achieved(a) ((a) >= MAXCONDITIONSETS || conditionSets[a].achieved) diff --git a/src/p_enemy.c b/src/p_enemy.c index 306b8b399..44dace26f 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -5115,9 +5115,14 @@ static boolean SignSkinCheck(player_t *player, INT32 num) // Player invalid, only show characters that are unlocked from the start. for (i = 0; i < MAXUNLOCKABLES; i++) { - if (unlockables[i].type == SECRET_SKIN && unlockables[i].variable == num) + if (unlockables[i].type == SECRET_SKIN) { - return false; + INT32 lockedSkin = M_UnlockableSkinNum(&unlockables[i]); + + if (lockedSkin == num) + { + return false; + } } } diff --git a/src/p_mobj.c b/src/p_mobj.c index 49db6daee..540642134 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -11964,6 +11964,7 @@ static boolean P_SetupEmblem(mapthing_t *mthing, mobj_t *mobj) INT32 j; emblem_t* emblem = M_GetLevelEmblems(gamemap); skincolornum_t emcolor; + boolean validEmblem = true; while (emblem) { @@ -11988,8 +11989,19 @@ static boolean P_SetupEmblem(mapthing_t *mthing, mobj_t *mobj) emcolor = M_GetEmblemColor(&emblemlocations[j]); // workaround for compiler complaint about bad function casting mobj->color = (UINT16)emcolor; - if (emblemlocations[j].collected - || (emblemlocations[j].type == ET_SKIN && emblemlocations[j].var != players[0].skin)) + validEmblem = !emblemlocations[j].collected; + + if (emblemlocations[j].type == ET_SKIN) + { + INT32 skinnum = M_EmblemSkinNum(&emblemlocations[j]); + + if (players[0].skin != skinnum) + { + validEmblem = false; + } + } + + if (validEmblem == false) { P_UnsetThingPosition(mobj); mobj->flags |= MF_NOCLIP; diff --git a/src/r_skins.c b/src/r_skins.c index 758d0980d..d6021ebbc 100644 --- a/src/r_skins.c +++ b/src/r_skins.c @@ -247,12 +247,16 @@ boolean R_SkinUsable(INT32 playernum, INT32 skinnum) for (i = 0; i < MAXUNLOCKABLES; i++) { + INT32 unlockSkin = -1; + if (unlockables[i].type != SECRET_SKIN) { continue; } - if (unlockables[i].variable == skinnum) + unlockSkin = M_UnlockableSkinNum(&unlockables[i]); + + if (unlockSkin == skinnum) { unlockID = i; break; @@ -294,8 +298,7 @@ INT32 R_SkinAvailable(const char *name) return -1; } -// Gets the player to the first usuable skin in the game. (If your mod locked them all, then you kinda stupid) -void SetPlayerDefaultSkin(INT32 playernum) +INT32 GetPlayerDefaultSkin(INT32 playernum) { INT32 i; @@ -303,12 +306,18 @@ void SetPlayerDefaultSkin(INT32 playernum) { if (R_SkinUsable(playernum, i)) { - SetPlayerSkinByNum(playernum, i); - return; + return i; } } - I_Error("All characters are locked."); + I_Error("All characters are locked!"); + return 0; +} + +// Gets the player to the first usuable skin in the game. (If your mod locked them all, then you kinda stupid) +void SetPlayerDefaultSkin(INT32 playernum) +{ + SetPlayerSkinByNum(playernum, GetPlayerDefaultSkin(playernum)); } // network code calls this when a 'skin change' is received @@ -325,7 +334,7 @@ void SetPlayerSkin(INT32 playernum, const char *skinname) if (P_IsLocalPlayer(player)) CONS_Alert(CONS_WARNING, M_GetText("Skin '%s' not found.\n"), skinname); - else if(server || IsPlayerAdmin(consoleplayer)) + else if (server || IsPlayerAdmin(consoleplayer)) CONS_Alert(CONS_WARNING, M_GetText("Player %d (%s) skin '%s' not found\n"), playernum, player_names[playernum], skinname); SetPlayerDefaultSkin(playernum); @@ -417,7 +426,7 @@ void SetPlayerSkinByNum(INT32 playernum, INT32 skinnum) if (P_IsLocalPlayer(player)) CONS_Alert(CONS_WARNING, M_GetText("Requested skin %d not found\n"), skinnum); - else if(server || IsPlayerAdmin(consoleplayer)) + else if (server || IsPlayerAdmin(consoleplayer)) CONS_Alert(CONS_WARNING, "Player %d (%s) skin %d not found\n", playernum, player_names[playernum], skinnum); SetPlayerDefaultSkin(playernum); diff --git a/src/r_skins.h b/src/r_skins.h index 5efd70307..675eac5cc 100644 --- a/src/r_skins.h +++ b/src/r_skins.h @@ -89,6 +89,8 @@ extern skin_t skins[MAXSKINS]; /// Function prototypes void R_InitSkins(void); +INT32 GetPlayerDefaultSkin(INT32 playernum); +void SetPlayerDefaultSkin(INT32 playernum); void SetPlayerSkin(INT32 playernum,const char *skinname); void SetPlayerSkinByNum(INT32 playernum,INT32 skinnum); // Tails 03-16-2002 boolean R_SkinUsable(INT32 playernum, INT32 skinnum); From 4bafd622716f74df2c5d0b71a317c27257b83b4d Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Sun, 25 Apr 2021 18:44:07 -0400 Subject: [PATCH 0714/1080] Only return skin string number if it existed --- src/m_cond.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/m_cond.c b/src/m_cond.c index ee8e96d64..2fc730d3f 100644 --- a/src/m_cond.c +++ b/src/m_cond.c @@ -508,9 +508,14 @@ INT32 M_UnlockableSkinNum(unlockable_t *unlock) if (unlock->stringVar && strcmp(unlock->stringVar, "")) { // Get the skin from the string. - return R_SkinAvailable(unlock->stringVar); + INT32 skinnum = R_SkinAvailable(unlock->stringVar); + if (skinnum != -1) + { + return skinnum; + } } - else if (unlock->variable >= 0 && unlock->variable < numskins) + + if (unlock->variable >= 0 && unlock->variable < numskins) { // Use the number directly. return unlock->variable; @@ -532,9 +537,14 @@ INT32 M_EmblemSkinNum(emblem_t *emblem) if (emblem->stringVar && strcmp(emblem->stringVar, "")) { // Get the skin from the string. - return R_SkinAvailable(emblem->stringVar); + INT32 skinnum = R_SkinAvailable(emblem->stringVar); + if (skinnum != -1) + { + return skinnum; + } } - else if (emblem->var >= 0 && emblem->var < numskins) + + if (emblem->var >= 0 && emblem->var < numskins) { // Use the number directly. return emblem->var; From c51c478740d1bb22dbe0a28923c433038ec76cfc Mon Sep 17 00:00:00 2001 From: James R Date: Sun, 25 Apr 2021 21:51:24 -0700 Subject: [PATCH 0715/1080] Lua: ensure order of MIN, MAX possible values Cvars could now have a range (MIN, MAX) plus some preset values, but Lua could not take advantage of this due to table order not being guaranteed. --- src/lua_consolelib.c | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/src/lua_consolelib.c b/src/lua_consolelib.c index 5344fee76..e839d4e15 100644 --- a/src/lua_consolelib.c +++ b/src/lua_consolelib.c @@ -361,6 +361,9 @@ static int lib_cvRegisterVar(lua_State *L) size_t count = 0; CV_PossibleValue_t *cvpv; + const char * const MINMAX[2] = {"MIN", "MAX"}; + int minmax_unset = 3; + lua_pushnil(L); while (lua_next(L, 4)) { count++; @@ -377,16 +380,45 @@ static int lib_cvRegisterVar(lua_State *L) i = 0; lua_pushnil(L); while (lua_next(L, 4)) { + INT32 n; + const char * strval; + // stack: [...] PossibleValue table, index, value // 4 5 6 if (lua_type(L, 5) != LUA_TSTRING || lua_type(L, 6) != LUA_TNUMBER) FIELDERROR("PossibleValue", "custom PossibleValue table requires a format of string=integer, i.e. {MIN=0, MAX=9999}"); - cvpv[i].strvalue = Z_StrDup(lua_tostring(L, 5)); - cvpv[i].value = (INT32)lua_tonumber(L, 6); + + strval = lua_tostring(L, 5); + + if ( + stricmp(strval, MINMAX[n=0]) == 0 || + stricmp(strval, MINMAX[n=1]) == 0 + ){ + /* need to shift forward */ + if (minmax_unset == 3) + { + memmove(&cvpv[2], &cvpv[0], + i * sizeof *cvpv); + } + cvpv[n].strvalue = MINMAX[n]; + minmax_unset &= ~(1 << n); + } + else + { + n = i; + cvpv[n].strvalue = Z_StrDup(strval); + } + + cvpv[n].value = (INT32)lua_tonumber(L, 6); + i++; lua_pop(L, 1); } + + if (minmax_unset) + FIELDERROR("PossibleValue", "custom PossibleValue table requires requires both MIN and MAX keys if one is present"); + cvpv[i].value = 0; cvpv[i].strvalue = NULL; cvar->PossibleValue = cvpv; From 85914cc7cd9143b08353409b1dea2a0d536e31de Mon Sep 17 00:00:00 2001 From: James R Date: Sun, 25 Apr 2021 21:55:04 -0700 Subject: [PATCH 0716/1080] Free zstring when switching to preset value This is only applicable for bounded cvars (MIN, MAX), since otherwise there's no way to allocate a zstring. --- src/command.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/command.c b/src/command.c index f1bf7dfb5..00116a0cb 100644 --- a/src/command.c +++ b/src/command.c @@ -1441,6 +1441,10 @@ static void Setvalue(consvar_t *var, const char *valstr, boolean stealth) return; } + // free the old value string + Z_Free(var->zstring); + var->zstring = NULL; + var->value = var->PossibleValue[i].value; var->string = var->PossibleValue[i].strvalue; goto finish; From 92aeadc36b8e32e1c18b25eaac03e0eb9b86171b Mon Sep 17 00:00:00 2001 From: James R Date: Sun, 25 Apr 2021 22:01:40 -0700 Subject: [PATCH 0717/1080] It is impossible for a string to be allocated in this case --- src/command.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/command.c b/src/command.c index 00116a0cb..951e3dd09 100644 --- a/src/command.c +++ b/src/command.c @@ -1507,14 +1507,7 @@ static void Setvalue(consvar_t *var, const char *valstr, boolean stealth) found: if (client && execversion_enabled) { - if (var->revert.allocated) - { - Z_Free(var->revert.v.string); - var->revert.allocated = false; // the below value is not allocated in zone memory, don't try to free it! - } - var->revert.v.const_munge = var->PossibleValue[i].strvalue; - return; } From 7cd41a8eb7ef8285255a65d5c1776608e77a486d Mon Sep 17 00:00:00 2001 From: Steel Titanium Date: Mon, 26 Apr 2021 03:48:38 -0400 Subject: [PATCH 0718/1080] Compile with -rdynamic on UNIXCOMMON platforms --- src/sdl/MakeNIX.cfg | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/sdl/MakeNIX.cfg b/src/sdl/MakeNIX.cfg index 47c944eb5..c2f3ff0b6 100644 --- a/src/sdl/MakeNIX.cfg +++ b/src/sdl/MakeNIX.cfg @@ -18,9 +18,11 @@ endif # #here is GNU/Linux and other # - OPTS=-DUNIXCOMMON +#Use -rdynamic so a backtrace log shows function names instead of addresses + LDFLAGS+=-rdynamic + #LDFLAGS = -L/usr/local/lib LIBS=-lm ifdef LINUX From 34fa9771928961196c46d2e7dbaec46d28bdcfb2 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Mon, 26 Apr 2021 19:07:11 +0100 Subject: [PATCH 0719/1080] move the old "can't load the level" error to its proper place, added specific error messages for all the times that unarchiving Lua banks can fail --- src/d_clisrv.c | 1 - src/p_saveg.c | 18 ++++++++++++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 7c2dec6a1..89077ad6c 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -1567,7 +1567,6 @@ static void CL_LoadReceivedSavegame(boolean reloading) } else { - CONS_Alert(CONS_ERROR, M_GetText("Can't load the level!\n")); Z_Free(savebuffer); save_p = NULL; if (unlink(tmpsave) == -1) diff --git a/src/p_saveg.c b/src/p_saveg.c index 03229e740..818596cac 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -4190,7 +4190,10 @@ static inline boolean P_NetUnArchiveMisc(boolean reloading) tokenlist = READUINT32(save_p); if (!P_LoadLevel(true, reloading)) + { + CONS_Alert(CONS_ERROR, M_GetText("Can't load the level!\n")); return false; + } // get the time leveltime = READUINT32(save_p); @@ -4268,19 +4271,26 @@ static inline boolean P_UnArchiveLuabanksAndConsistency(void) { switch (READUINT8(save_p)) { - case 0xb7: + case 0xb7: // luabanks marker { UINT8 i, banksinuse = READUINT8(save_p); if (banksinuse > NUM_LUABANKS) + { + CONS_Alert(CONS_ERROR, M_GetText("Corrupt Luabanks! (Too many banks in use)\n")); return false; + } for (i = 0; i < banksinuse; i++) luabanks[i] = READINT32(save_p); - if (READUINT8(save_p) != 0x1d) + if (READUINT8(save_p) != 0x1d) // consistency marker + { + CONS_Alert(CONS_ERROR, M_GetText("Corrupt Luabanks! (Failed consistency check)\n")); return false; + } } - case 0x1d: + case 0x1d: // consistency marker break; - default: + default: // anything else is nonsense + CONS_Alert(CONS_ERROR, M_GetText("Failed consistency check (???)\n")); return false; } From cd4cfba5000d141e97a9ac6ef0e3204e6cb8f905 Mon Sep 17 00:00:00 2001 From: LJ Sonic Date: Mon, 26 Apr 2021 21:07:35 +0200 Subject: [PATCH 0720/1080] Delete faulty return --- src/d_clisrv.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 7c2dec6a1..c4026d52d 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -1568,11 +1568,6 @@ static void CL_LoadReceivedSavegame(boolean reloading) else { CONS_Alert(CONS_ERROR, M_GetText("Can't load the level!\n")); - Z_Free(savebuffer); - save_p = NULL; - if (unlink(tmpsave) == -1) - CONS_Alert(CONS_ERROR, M_GetText("Can't delete %s\n"), tmpsave); - return; } // done @@ -4486,9 +4481,9 @@ static INT16 Consistancy(void) { if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) continue; - + mo = (mobj_t *)th; - + if (mo->flags & (MF_SPECIAL | MF_SOLID | MF_PUSHABLE | MF_BOSS | MF_MISSILE | MF_SPRING | MF_MONITOR | MF_FIRE | MF_ENEMY | MF_PAIN | MF_STICKY)) { ret -= mo->type; From 0d4d3a520777bf81609df4c28b144330ab66b640 Mon Sep 17 00:00:00 2001 From: LJ Sonic Date: Mon, 26 Apr 2021 21:07:35 +0200 Subject: [PATCH 0721/1080] Revert "Lua: ensure order of MIN, MAX possible values" This reverts commit c51c478740d1bb22dbe0a28923c433038ec76cfc. --- src/lua_consolelib.c | 36 ++---------------------------------- 1 file changed, 2 insertions(+), 34 deletions(-) diff --git a/src/lua_consolelib.c b/src/lua_consolelib.c index e839d4e15..5344fee76 100644 --- a/src/lua_consolelib.c +++ b/src/lua_consolelib.c @@ -361,9 +361,6 @@ static int lib_cvRegisterVar(lua_State *L) size_t count = 0; CV_PossibleValue_t *cvpv; - const char * const MINMAX[2] = {"MIN", "MAX"}; - int minmax_unset = 3; - lua_pushnil(L); while (lua_next(L, 4)) { count++; @@ -380,45 +377,16 @@ static int lib_cvRegisterVar(lua_State *L) i = 0; lua_pushnil(L); while (lua_next(L, 4)) { - INT32 n; - const char * strval; - // stack: [...] PossibleValue table, index, value // 4 5 6 if (lua_type(L, 5) != LUA_TSTRING || lua_type(L, 6) != LUA_TNUMBER) FIELDERROR("PossibleValue", "custom PossibleValue table requires a format of string=integer, i.e. {MIN=0, MAX=9999}"); - - strval = lua_tostring(L, 5); - - if ( - stricmp(strval, MINMAX[n=0]) == 0 || - stricmp(strval, MINMAX[n=1]) == 0 - ){ - /* need to shift forward */ - if (minmax_unset == 3) - { - memmove(&cvpv[2], &cvpv[0], - i * sizeof *cvpv); - } - cvpv[n].strvalue = MINMAX[n]; - minmax_unset &= ~(1 << n); - } - else - { - n = i; - cvpv[n].strvalue = Z_StrDup(strval); - } - - cvpv[n].value = (INT32)lua_tonumber(L, 6); - + cvpv[i].strvalue = Z_StrDup(lua_tostring(L, 5)); + cvpv[i].value = (INT32)lua_tonumber(L, 6); i++; lua_pop(L, 1); } - - if (minmax_unset) - FIELDERROR("PossibleValue", "custom PossibleValue table requires requires both MIN and MAX keys if one is present"); - cvpv[i].value = 0; cvpv[i].strvalue = NULL; cvar->PossibleValue = cvpv; From 34911128187161136db79cbb9df302cb8c8fccc1 Mon Sep 17 00:00:00 2001 From: LJ Sonic Date: Mon, 26 Apr 2021 21:07:35 +0200 Subject: [PATCH 0722/1080] Update copyright date --- 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 23a2c0133..61510d590 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -1045,7 +1045,7 @@ void D_SRB2Main(void) // Print GPL notice for our console users (Linux) CONS_Printf( "\n\nSonic Robo Blast 2\n" - "Copyright (C) 1998-2020 by Sonic Team Junior\n\n" + "Copyright (C) 1998-2021 by Sonic Team Junior\n\n" "This program comes with ABSOLUTELY NO WARRANTY.\n\n" "This is free software, and you are welcome to redistribute it\n" "and/or modify it under the terms of the GNU General Public License\n" From f437d6afec08bebab2d44f0d383c316f11df4934 Mon Sep 17 00:00:00 2001 From: Vincent Robinson Date: Mon, 26 Apr 2021 16:27:39 -0700 Subject: [PATCH 0723/1080] Add linedef specials for multitagging in binary maps --- extras/conf/SRB2-22.cfg | 18 ++++++++++++++++++ src/p_setup.c | 21 +++++++++++++++++++++ src/taglist.c | 6 ++++-- 3 files changed, 43 insertions(+), 2 deletions(-) diff --git a/extras/conf/SRB2-22.cfg b/extras/conf/SRB2-22.cfg index 3fd4b6ccd..9a8484df5 100644 --- a/extras/conf/SRB2-22.cfg +++ b/extras/conf/SRB2-22.cfg @@ -640,6 +640,24 @@ linedeftypes prefix = "(63)"; } + 97 + { + title = "Apply Tag to Front Sector"; + prefix = "(97)"; + } + + 98 + { + title = "Apply Tag to Back Sector"; + prefix = "(98)"; + } + + 99 + { + title = "Apply Tag to Front and Back Sectors"; + prefix = "(99)"; + } + 540 { title = "Floor Friction"; diff --git a/src/p_setup.c b/src/p_setup.c index 40dd1a284..1b060660d 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2950,6 +2950,24 @@ static void P_LinkMapData(void) } } +// For maps in binary format, add multi-tags from linedef specials. This must be done +// before any linedef specials have been processed. +static void P_AddBinaryMapTags(void) +{ + size_t i; + + for (i = 0; i < numlines; i++) + { + // 97: Apply Tag to Front Sector + // 98: Apply Tag to Back Sector + // 99: Apply Tag to Front and Back Sectors + if (lines[i].special == 97 || lines[i].special == 99) + Tag_Add(&lines[i].frontsector->tags, Tag_FGet(&lines[i].tags)); + if (lines[i].special == 98 || lines[i].special == 99) + Tag_Add(&lines[i].backsector->tags, Tag_FGet(&lines[i].tags)); + } +} + //For maps in binary format, converts setup of specials to UDMF format. static void P_ConvertBinaryMap(void) { @@ -3287,6 +3305,9 @@ static boolean P_LoadMapFromFile(void) P_LinkMapData(); + if (!udmf) + P_AddBinaryMapTags(); + Taglist_InitGlobalTables(); if (!udmf) diff --git a/src/taglist.c b/src/taglist.c index a759f4d02..e8b64d3f4 100644 --- a/src/taglist.c +++ b/src/taglist.c @@ -27,11 +27,13 @@ taggroup_t* tags_sectors[MAXTAGS + 1]; taggroup_t* tags_lines[MAXTAGS + 1]; taggroup_t* tags_mapthings[MAXTAGS + 1]; -/// Adds a tag to a given element's taglist. +/// Adds a tag to a given element's taglist. It will not add a duplicate. /// \warning This does not rebuild the global taggroups, which are used for iteration. void Tag_Add (taglist_t* list, const mtag_t tag) { - list->tags = Z_Realloc(list->tags, (list->count + 1) * sizeof(list->tags), PU_LEVEL, NULL); + if (Tag_Find(list, tag)) + return; + list->tags = Z_Realloc(list->tags, (list->count + 1) * sizeof(mtag_t), PU_LEVEL, NULL); list->tags[list->count++] = tag; } From 85c53b35cd3a00ddd8d30fbca15499e3b529179b Mon Sep 17 00:00:00 2001 From: Jaime Ita Passos Date: Mon, 26 Apr 2021 22:17:03 -0300 Subject: [PATCH 0724/1080] Use old routine for PO2 spans --- src/r_plane.c | 108 +++++++++++++++++++++++++++++++++++--------------- 1 file changed, 76 insertions(+), 32 deletions(-) diff --git a/src/r_plane.c b/src/r_plane.c index 10d87b9cc..ea5a7a3c3 100644 --- a/src/r_plane.c +++ b/src/r_plane.c @@ -789,6 +789,78 @@ static void R_SetSlopePlaneVectors(visplane_t *pl, INT32 y, fixed_t xoff, fixed_ R_CalculateSlopeVectors(); } +/* + Essentially: We can't & the components along the regular axes when the plane is rotated. + This is because the distance on each regular axis in order to loop is different. + We rotate them, & the components, add them together, & them again, and then rotate them back. + These three seperate & operations are done per axis in order to prevent overflows. + toast 10/04/17 +*/ +static inline void R_AdjustSlopeCoordinates(visplane_t *pl) +{ + const fixed_t modmask = ((1 << (32-nflatshiftup)) - 1); + + const fixed_t cosinecomponent = FINECOSINE(pl->plangle>>ANGLETOFINESHIFT); + const fixed_t sinecomponent = FINESINE(pl->plangle>>ANGLETOFINESHIFT); + + fixed_t ox = (FixedMul(pl->slope->o.x,cosinecomponent) & modmask) - (FixedMul(pl->slope->o.y,sinecomponent) & modmask); + fixed_t oy = (-FixedMul(pl->slope->o.x,sinecomponent) & modmask) - (FixedMul(pl->slope->o.y,cosinecomponent) & modmask); + + fixed_t temp = ox & modmask; + oy &= modmask; + + ox = FixedMul(temp,cosinecomponent)+FixedMul(oy,-sinecomponent); // negative sine for opposite direction + oy = -FixedMul(temp,-sinecomponent)+FixedMul(oy,cosinecomponent); + + if (xoffs || yoffs) + { + temp = xoffs; + xoffs = (FixedMul(temp,cosinecomponent) & modmask) + (FixedMul(yoffs,sinecomponent) & modmask); + yoffs = (-FixedMul(temp,sinecomponent) & modmask) + (FixedMul(yoffs,cosinecomponent) & modmask); + + temp = xoffs & modmask; + yoffs &= modmask; + xoffs = FixedMul(temp,cosinecomponent)+FixedMul(yoffs,-sinecomponent); // ditto + yoffs = -FixedMul(temp,-sinecomponent)+FixedMul(yoffs,cosinecomponent); + } + + xoffs -= (pl->slope->o.x - ox); + yoffs += (pl->slope->o.y + oy); +} + +static inline void R_AdjustSlopeCoordinatesNPO2(visplane_t *pl) +{ + const fixed_t modmaskw = (ds_flatwidth << FRACBITS); + const fixed_t modmaskh = (ds_flatheight << FRACBITS); + + const fixed_t cosinecomponent = FINECOSINE(pl->plangle>>ANGLETOFINESHIFT); + const fixed_t sinecomponent = FINESINE(pl->plangle>>ANGLETOFINESHIFT); + + fixed_t ox = (FixedMul(pl->slope->o.x,cosinecomponent) % modmaskw) - (FixedMul(pl->slope->o.y,sinecomponent) % modmaskh); + fixed_t oy = (-FixedMul(pl->slope->o.x,sinecomponent) % modmaskw) - (FixedMul(pl->slope->o.y,cosinecomponent) % modmaskh); + + fixed_t temp = ox % modmaskw; + oy %= modmaskh; + + ox = FixedMul(temp,cosinecomponent)+FixedMul(oy,-sinecomponent); // negative sine for opposite direction + oy = -FixedMul(temp,-sinecomponent)+FixedMul(oy,cosinecomponent); + + if (xoffs || yoffs) + { + temp = xoffs; + xoffs = (FixedMul(temp,cosinecomponent) % modmaskw) + (FixedMul(yoffs,sinecomponent) % modmaskh); + yoffs = (-FixedMul(temp,sinecomponent) % modmaskw) + (FixedMul(yoffs,cosinecomponent) % modmaskh); + + temp = xoffs % modmaskw; + yoffs %= modmaskh; + xoffs = FixedMul(temp,cosinecomponent)+FixedMul(yoffs,-sinecomponent); // ditto + yoffs = -FixedMul(temp,-sinecomponent)+FixedMul(yoffs,cosinecomponent); + } + + xoffs -= (pl->slope->o.x - ox); + yoffs += (pl->slope->o.y + oy); +} + void R_DrawSinglePlane(visplane_t *pl) { levelflat_t *levelflat; @@ -967,38 +1039,10 @@ void R_DrawSinglePlane(visplane_t *pl) if (pl->slope) { - const fixed_t modmaskw = (ds_powersoftwo) ? (ds_flatwidth << FRACBITS) - 1 : (signed)(0xFFFFFFFF); - const fixed_t modmaskh = (ds_powersoftwo) ? (ds_flatheight << FRACBITS) - 1 : (signed)(0xFFFFFFFF); - - /* - Essentially: We can't & the components along the regular axes when the plane is rotated. - This is because the distance on each regular axis in order to loop is different. - We rotate them, & the components, add them together, & them again, and then rotate them back. - These three seperate & operations are done per axis in order to prevent overflows. - toast 10/04/17 - */ - const fixed_t cosinecomponent = FINECOSINE(pl->plangle>>ANGLETOFINESHIFT); - const fixed_t sinecomponent = FINESINE(pl->plangle>>ANGLETOFINESHIFT); - - fixed_t ox = (FixedMul(pl->slope->o.x,cosinecomponent) & modmaskw) - (FixedMul(pl->slope->o.y,sinecomponent) & modmaskh); - fixed_t oy = (-FixedMul(pl->slope->o.x,sinecomponent) & modmaskw) - (FixedMul(pl->slope->o.y,cosinecomponent) & modmaskh); - - fixed_t temp = ox & modmaskw; - oy &= modmaskh; - ox = FixedMul(temp,cosinecomponent)+FixedMul(oy,-sinecomponent); // negative sine for opposite direction - oy = -FixedMul(temp,-sinecomponent)+FixedMul(oy,cosinecomponent); - - temp = xoffs; - xoffs = (FixedMul(temp,cosinecomponent) & modmaskw) + (FixedMul(yoffs,sinecomponent) & modmaskh); - yoffs = (-FixedMul(temp,sinecomponent) & modmaskw) + (FixedMul(yoffs,cosinecomponent) & modmaskh); - - temp = xoffs & modmaskw; - yoffs &= modmaskh; - xoffs = FixedMul(temp,cosinecomponent)+FixedMul(yoffs,-sinecomponent); // ditto - yoffs = -FixedMul(temp,-sinecomponent)+FixedMul(yoffs,cosinecomponent); - - xoffs -= (pl->slope->o.x - ox); - yoffs += (pl->slope->o.y + oy); + if (ds_powersoftwo) + R_AdjustSlopeCoordinates(pl); + else + R_AdjustSlopeCoordinatesNPO2(pl); if (planeripple.active) { From 548554431b945d684725459bab14a6a00951244f Mon Sep 17 00:00:00 2001 From: Jaime Ita Passos Date: Tue, 27 Apr 2021 00:20:41 -0300 Subject: [PATCH 0725/1080] Handle invalid blend modes properly --- src/hardware/hw_main.c | 15 ++++++--------- src/hardware/hw_main.h | 2 +- src/lua_mobjlib.c | 8 +++++++- src/r_draw.c | 4 ++-- 4 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index e94c637e4..41de5ddcf 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -712,13 +712,12 @@ static void HWR_RenderSkyPlane(extrasubsector_t *xsub, fixed_t fixedheight) #endif //doplanes -FBITFIELD HWR_GetBlendModeFlag(INT32 ast) +FBITFIELD HWR_GetBlendModeFlag(INT32 style) { - switch (ast) + switch (style) { - case AST_COPY: - case AST_OVERLAY: - return PF_Masked; + case AST_TRANSLUCENT: + return PF_Translucent; case AST_ADD: return PF_Additive; case AST_SUBTRACT: @@ -728,10 +727,8 @@ FBITFIELD HWR_GetBlendModeFlag(INT32 ast) case AST_MODULATE: return PF_Multiplicative; default: - return PF_Translucent; + return PF_Masked; } - - return 0; } UINT8 HWR_GetTranstableAlpha(INT32 transtablenum) @@ -757,7 +754,7 @@ UINT8 HWR_GetTranstableAlpha(INT32 transtablenum) FBITFIELD HWR_SurfaceBlend(INT32 style, INT32 transtablenum, FSurfaceInfo *pSurf) { - if (!transtablenum || style == AST_COPY || style == AST_OVERLAY) + if (!transtablenum || style <= AST_COPY || style >= AST_OVERLAY) { pSurf->PolyColor.s.alpha = 0xff; return PF_Masked; diff --git a/src/hardware/hw_main.h b/src/hardware/hw_main.h index 4ad09aa3d..2c7d237bf 100644 --- a/src/hardware/hw_main.h +++ b/src/hardware/hw_main.h @@ -69,7 +69,7 @@ void HWR_Lighting(FSurfaceInfo *Surface, INT32 light_level, extracolormap_t *col UINT8 HWR_FogBlockAlpha(INT32 light, extracolormap_t *colormap); // Let's see if this can work UINT8 HWR_GetTranstableAlpha(INT32 transtablenum); -FBITFIELD HWR_GetBlendModeFlag(INT32 ast); +FBITFIELD HWR_GetBlendModeFlag(INT32 style); FBITFIELD HWR_SurfaceBlend(INT32 style, INT32 transtablenum, FSurfaceInfo *pSurf); FBITFIELD HWR_TranstableToAlpha(INT32 transtablenum, FSurfaceInfo *pSurf); diff --git a/src/lua_mobjlib.c b/src/lua_mobjlib.c index 65adceb15..994f6a789 100644 --- a/src/lua_mobjlib.c +++ b/src/lua_mobjlib.c @@ -12,6 +12,7 @@ #include "doomdef.h" #include "fastcmp.h" +#include "r_data.h" #include "r_skins.h" #include "p_local.h" #include "g_game.h" @@ -654,8 +655,13 @@ static int mobj_set(lua_State *L) break; } case mobj_blendmode: - mo->blendmode = (INT32)luaL_checkinteger(L, 3); + { + INT32 blendmode = (INT32)luaL_checkinteger(L, 3); + if (blendmode < 0 || blendmode > AST_OVERLAY) + return luaL_error(L, "mobj.blendmode %d out of range (0 - %d).", blendmode, AST_OVERLAY); + mo->blendmode = blendmode; break; + } case mobj_bnext: return NOSETPOS; case mobj_bprev: diff --git a/src/r_draw.c b/src/r_draw.c index 9a835ee58..1d2d8352f 100644 --- a/src/r_draw.c +++ b/src/r_draw.c @@ -341,7 +341,7 @@ UINT8 *R_GetBlendTable(int style, INT32 alphalevel) { size_t offs; - if (style == AST_COPY || style == AST_OVERLAY) + if (style <= AST_COPY || style >= AST_OVERLAY) return NULL; offs = (ClipBlendLevel(style, alphalevel) << FF_TRANSSHIFT); @@ -371,7 +371,7 @@ UINT8 *R_GetBlendTable(int style, INT32 alphalevel) boolean R_BlendLevelVisible(INT32 blendmode, INT32 alphalevel) { - if (blendmode == AST_COPY || blendmode == AST_SUBTRACT || blendmode == AST_MODULATE || blendmode == AST_OVERLAY) + if (blendmode <= AST_COPY || blendmode == AST_SUBTRACT || blendmode == AST_MODULATE || blendmode >= AST_OVERLAY) return true; return (alphalevel < BlendTab_Count[BlendTab_FromStyle[blendmode]]); From 21da6ce704c5665a77fcb42e21beb995fce65453 Mon Sep 17 00:00:00 2001 From: Zwip-Zwap Zapony Date: Tue, 27 Apr 2021 21:30:00 +0200 Subject: [PATCH 0726/1080] Auto-crop at splitscreen borders V_DrawCroppedPatch will no longer go beyond splitscreen borders when V_PERPLAYER is used --- src/hardware/hw_draw.c | 70 ++++++++++++++++++++++++++++++++++++++++++ src/v_video.c | 31 +++++++++++++++++++ 2 files changed, 101 insertions(+) diff --git a/src/hardware/hw_draw.c b/src/hardware/hw_draw.c index 8722495e4..7deb36b69 100644 --- a/src/hardware/hw_draw.c +++ b/src/hardware/hw_draw.c @@ -596,6 +596,76 @@ void HWR_DrawCroppedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale, if (option & V_WRAPY) flags |= PF_ForceWrapY; + // Auto-crop at splitscreen borders! + if (splitscreen && (option & V_PERPLAYER)) + { +#define flerp(a,b,amount) (((a) * (1.0f - (amount))) + ((b) * (amount))) // Float lerp + +#ifdef QUADS + if (splitscreen > 1) // 3 or 4 players + { + #error Auto-cropping doesnt take quadscreen into account! Fix it! + // Hint: For player 1/2, copy player 1's code below. For player 3/4, copy player 2's code below + // For player 1/3 and 2/4, mangle the below code to apply horizontally instead of vertically + } + else +#endif + // 2 players + { + if (stplyr == &players[displayplayer]) // Player 1's screen, crop at the bottom + { + if ((cy - fheight) < 0) // If the bottom is below the border + { + if (cy <= 0) // If the whole patch is beyond the border... + return; // ...crop away the entire patch, don't draw anything + + if (fheight <= 0) // Don't divide by zero + return; + + v[2].y = v[3].y = 0; // Clamp the polygon edge vertex position + // Now for the UV-map... Uh-oh, math time! + + // On second thought, a basic linear interpolation suffices + //float full_height = fheight; + //float cropped_height = fheight - cy; + //float remaining_height = cy; + //float cropped_percentage = (fheight - cy) / fheight; + //float remaining_percentage = cy / fheight; + //v[2].t = v[3].t = lerp(v[2].t, v[0].t, cropped_percentage); + // By swapping v[2] and v[0], we can use remaining_percentage for less operations + //v[2].t = v[3].t = lerp(v[0].t, v[2].t, remaining_percentage); + + v[2].t = v[3].t = flerp(v[0].t, v[2].t, cy/fheight); + } + } + else //if (stplyr == &players[secondarydisplayplayer]) // Player 2's screen, crop at the top + { + if (cy > 0) // If the top is above the border + { + if ((cy - fheight) >= 0) // If the whole patch is beyond the border... + return; // ...crop away the entire patch, don't draw anything + + if (fheight <= 0) // Don't divide by zero + return; + + v[0].y = v[1].y = 0; // Clamp the polygon edge vertex position + // Now for the UV-map... Uh-oh, math time! + + // On second thought, a basic linear interpolation suffices + //float full_height = fheight; + //float cropped_height = cy; + //float remaining_height = fheight - cy; + //float cropped_percentage = cy / fheight; + //float remaining_percentage = (fheight - cy) / fheight; + //v[0].t = v[1].t = lerp(v[0].t, v[2].t, cropped_percentage); + + v[0].t = v[1].t = flerp(v[0].t, v[2].t, cy/fheight); + } + } + } +#undef flerp + } + // clip it since it is used for bunny scroll in doom I if (alphalevel) { diff --git a/src/v_video.c b/src/v_video.c index 4ac8e4d27..bc919af72 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -1019,6 +1019,37 @@ void V_DrawCroppedPatch(fixed_t x, fixed_t y, fixed_t pscale, fixed_t vscale, IN desttop += (y*vid.width) + x; } + // Auto-crop at splitscreen borders! + if (splitscreen && (scrn & V_PERPLAYER)) + { +#ifdef QUADS + if (splitscreen > 1) // 3 or 4 players + { + #error Auto-cropping doesnt take quadscreen into account! Fix it! + // Hint: For player 1/2, copy player 1's code below. For player 3/4, copy player 2's code below + // For player 1/3 and 2/4, hijack the X wrap prevention lines? That's probably easiest + } + else +#endif + // 2 players + { + if (stplyr == &players[displayplayer]) // Player 1's screen, crop at the bottom + { + // Just put a big old stop sign halfway through the screen + deststop -= vid.rowbytes * (vid.height>>1); + } + else //if (stplyr == &players[secondarydisplayplayer]) // Player 2's screen, crop at the top + { + if (y < (vid.height>>1)) // If the top is above the border + { + sy += ((vid.height>>1) - y) * rowfrac; // Start further down on the patch + h -= ((vid.height>>1) - y) * rowfrac; // Draw less downwards from the start + desttop += ((vid.height>>1) - y) * vid.width; // Start drawing at the border + } + } + } + } + for (col = sx; (col>>FRACBITS) < patch->width && (col - sx) < w; col += colfrac, ++x, desttop++) { INT32 topdelta, prevdelta = -1; From e4b8dc6584de4fed284cb14801b2dbb9b6dcafe6 Mon Sep 17 00:00:00 2001 From: Jaime Ita Passos Date: Tue, 27 Apr 2021 19:01:09 -0300 Subject: [PATCH 0727/1080] Fix sloped plane offsets in Software, and fix rotated flat alignment in OpenGL. + unrelated slope plane optimizations in Software --- src/hardware/hw_main.c | 31 ++-- src/r_draw.h | 2 +- src/r_plane.c | 313 +++++++++++++++++++++-------------------- src/r_plane.h | 4 +- 4 files changed, 170 insertions(+), 180 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index f2af1cc40..b261c6460 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -362,10 +362,10 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool float fflatwidth = 64.0f, fflatheight = 64.0f; INT32 flatflag = 63; boolean texflat = false; - float scrollx = 0.0f, scrolly = 0.0f; + float scrollx = 0.0f, scrolly = 0.0f, anglef = 0.0f; angle_t angle = 0; FSurfaceInfo Surf; - fixed_t tempxsow, tempytow; + float tempxsow, tempytow; pslope_t *slope = NULL; static FOutVector *planeVerts = NULL; @@ -499,24 +499,15 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool } } - if (angle) // Only needs to be done if there's an altered angle { + tempxsow = flatxref; + tempytow = flatyref; - angle = (InvAngle(angle))>>ANGLETOFINESHIFT; + anglef = ANG2RAD(InvAngle(angle)); - // This needs to be done so that it scrolls in a different direction after rotation like software - /*tempxsow = FLOAT_TO_FIXED(scrollx); - tempytow = FLOAT_TO_FIXED(scrolly); - scrollx = (FIXED_TO_FLOAT(FixedMul(tempxsow, FINECOSINE(angle)) - FixedMul(tempytow, FINESINE(angle)))); - scrolly = (FIXED_TO_FLOAT(FixedMul(tempxsow, FINESINE(angle)) + FixedMul(tempytow, FINECOSINE(angle))));*/ - - // This needs to be done so everything aligns after rotation - // It would be done so that rotation is done, THEN the translation, but I couldn't get it to rotate AND scroll like software does - tempxsow = FLOAT_TO_FIXED(flatxref); - tempytow = FLOAT_TO_FIXED(flatyref); - flatxref = (FIXED_TO_FLOAT(FixedMul(tempxsow, FINECOSINE(angle)) - FixedMul(tempytow, FINESINE(angle)))); - flatyref = (FIXED_TO_FLOAT(FixedMul(tempxsow, FINESINE(angle)) + FixedMul(tempytow, FINECOSINE(angle)))); + flatxref = (tempxsow * cos(anglef)) - (tempytow * sin(anglef)); + flatyref = (tempxsow * sin(anglef)) + (tempytow * cos(anglef)); } #define SETUP3DVERT(vert, vx, vy) {\ @@ -535,10 +526,10 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool /* Need to rotate before translate */\ if (angle) /* Only needs to be done if there's an altered angle */\ {\ - tempxsow = FLOAT_TO_FIXED(vert->s);\ - tempytow = FLOAT_TO_FIXED(vert->t);\ - vert->s = (FIXED_TO_FLOAT(FixedMul(tempxsow, FINECOSINE(angle)) - FixedMul(tempytow, FINESINE(angle))));\ - vert->t = (FIXED_TO_FLOAT(FixedMul(tempxsow, FINESINE(angle)) + FixedMul(tempytow, FINECOSINE(angle))));\ + tempxsow = vert->s;\ + tempytow = vert->t;\ + vert->s = (tempxsow * cos(anglef)) - (tempytow * sin(anglef));\ + vert->t = (tempxsow * sin(anglef)) + (tempytow * cos(anglef));\ }\ \ vert->x = (vx);\ diff --git a/src/r_draw.h b/src/r_draw.h index caf43fd89..2173c7a5a 100644 --- a/src/r_draw.h +++ b/src/r_draw.h @@ -177,7 +177,7 @@ void R_Draw2sMultiPatchTranslucentColumn_8(void); void R_DrawFogColumn_8(void); void R_DrawColumnShadowed_8(void); -#define PLANELIGHTFLOAT (BASEVIDWIDTH * BASEVIDWIDTH / vid.width / (zeroheight - FIXED_TO_FLOAT(viewz)) / 21.0f * FIXED_TO_FLOAT(fovtan)) +#define PLANELIGHTFLOAT (BASEVIDWIDTH * BASEVIDWIDTH / vid.width / zeroheight / 21.0f * FIXED_TO_FLOAT(fovtan)) void R_DrawSpan_8(void); void R_DrawTranslucentSpan_8(void); diff --git a/src/r_plane.c b/src/r_plane.c index ea5a7a3c3..ee7b161da 100644 --- a/src/r_plane.c +++ b/src/r_plane.c @@ -31,13 +31,6 @@ #include "z_zone.h" #include "p_tick.h" -#ifdef TIMING -#include "p5prof.h" - INT64 mycount; - INT64 mytotal = 0; - UINT32 nombre = 100000; -#endif - // // opening // @@ -128,21 +121,20 @@ struct boolean active; } planeripple; -static void R_CalculatePlaneRipple(visplane_t *plane, INT32 y, fixed_t plheight, boolean calcfrac) +// ripples da water texture +static fixed_t R_CalculateRippleOffset(INT32 y) { - fixed_t distance = FixedMul(plheight, yslope[y]); + fixed_t distance = FixedMul(planeheight, yslope[y]); const INT32 yay = (planeripple.offset + (distance>>9)) & 8191; + return FixedDiv(FINESINE(yay), (1<<12) + (distance>>11)); +} - // ripples da water texture - ds_bgofs = FixedDiv(FINESINE(yay), (1<<12) + (distance>>11))>>FRACBITS; - - if (calcfrac) - { - angle_t angle = (plane->viewangle + plane->plangle)>>ANGLETOFINESHIFT; - angle = (angle + 2048) & 8191; // 90 degrees - planeripple.xfrac = FixedMul(FINECOSINE(angle), (ds_bgofs<>= ANGLETOFINESHIFT; + angle = (angle + 2048) & 8191; // 90 degrees + planeripple.xfrac = FixedMul(FINECOSINE(angle), ds_bgofs); + planeripple.yfrac = FixedMul(FINESINE(angle), ds_bgofs); } static void R_UpdatePlaneRipple(void) @@ -160,7 +152,7 @@ static void R_UpdatePlaneRipple(void) // baseyscale // centerx -void R_MapPlane(INT32 y, INT32 x1, INT32 x2) +static void R_MapPlane(INT32 y, INT32 x1, INT32 x2) { angle_t angle, planecos, planesin; fixed_t distance = 0, span; @@ -174,60 +166,50 @@ void R_MapPlane(INT32 y, INT32 x1, INT32 x2) if (x1 >= vid.width) x1 = vid.width - 1; - if (!currentplane->slope) + angle = (currentplane->viewangle + currentplane->plangle)>>ANGLETOFINESHIFT; + planecos = FINECOSINE(angle); + planesin = FINESINE(angle); + + if (planeheight != cachedheight[y]) { - angle = (currentplane->viewangle + currentplane->plangle)>>ANGLETOFINESHIFT; - planecos = FINECOSINE(angle); - planesin = FINESINE(angle); + cachedheight[y] = planeheight; + cacheddistance[y] = distance = FixedMul(planeheight, yslope[y]); + span = abs(centery - y); - if (planeheight != cachedheight[y]) + if (span) // don't divide by zero { - cachedheight[y] = planeheight; - cacheddistance[y] = distance = FixedMul(planeheight, yslope[y]); - span = abs(centery - y); - - if (span) // don't divide by zero - { - ds_xstep = FixedMul(planesin, planeheight) / span; - ds_ystep = FixedMul(planecos, planeheight) / span; - } - else - { - ds_xstep = FixedMul(distance, basexscale); - ds_ystep = FixedMul(distance, baseyscale); - } - - cachedxstep[y] = ds_xstep; - cachedystep[y] = ds_ystep; + ds_xstep = FixedMul(planesin, planeheight) / span; + ds_ystep = FixedMul(planecos, planeheight) / span; } else { - distance = cacheddistance[y]; - ds_xstep = cachedxstep[y]; - ds_ystep = cachedystep[y]; + ds_xstep = FixedMul(distance, basexscale); + ds_ystep = FixedMul(distance, baseyscale); } - ds_xfrac = xoffs + FixedMul(planecos, distance) + (x1 - centerx) * ds_xstep; - ds_yfrac = yoffs - FixedMul(planesin, distance) + (x1 - centerx) * ds_ystep; + cachedxstep[y] = ds_xstep; + cachedystep[y] = ds_ystep; } + else + { + distance = cacheddistance[y]; + ds_xstep = cachedxstep[y]; + ds_ystep = cachedystep[y]; + } + + ds_xfrac = xoffs + FixedMul(planecos, distance) + (x1 - centerx) * ds_xstep; + ds_yfrac = yoffs - FixedMul(planesin, distance) + (x1 - centerx) * ds_ystep; // Water ripple effect if (planeripple.active) { - // Needed for ds_bgofs - R_CalculatePlaneRipple(currentplane, y, planeheight, (!currentplane->slope)); + ds_bgofs = R_CalculateRippleOffset(y); - if (currentplane->slope) - { - ds_sup = &ds_su[y]; - ds_svp = &ds_sv[y]; - ds_szp = &ds_sz[y]; - } - else - { - ds_xfrac += planeripple.xfrac; - ds_yfrac += planeripple.yfrac; - } + R_CalculatePlaneRipple(currentplane->viewangle + currentplane->plangle); + + ds_xfrac += planeripple.xfrac; + ds_yfrac += planeripple.yfrac; + ds_bgofs >>= FRACBITS; if ((y + ds_bgofs) >= viewheight) ds_bgofs = viewheight-y-1; @@ -235,16 +217,11 @@ void R_MapPlane(INT32 y, INT32 x1, INT32 x2) ds_bgofs = -y; } - if (currentplane->slope) - ds_colormap = colormaps; - else - { - pindex = distance >> LIGHTZSHIFT; - if (pindex >= MAXLIGHTZ) - pindex = MAXLIGHTZ - 1; - ds_colormap = planezlight[pindex]; - } + pindex = distance >> LIGHTZSHIFT; + if (pindex >= MAXLIGHTZ) + pindex = MAXLIGHTZ - 1; + ds_colormap = planezlight[pindex]; if (currentplane->extra_colormap) ds_colormap = currentplane->extra_colormap->colormap + (ds_colormap - colormaps); @@ -252,19 +229,46 @@ void R_MapPlane(INT32 y, INT32 x1, INT32 x2) ds_x1 = x1; ds_x2 = x2; - // profile drawer -#ifdef TIMING - ProfZeroTimer(); + spanfunc(); +} + +static void R_MapTiltedPlane(INT32 y, INT32 x1, INT32 x2) +{ +#ifdef RANGECHECK + if (x2 < x1 || x1 < 0 || x2 >= viewwidth || y > viewheight) + I_Error("R_MapTiltedPlane: %d, %d at %d", x1, x2, y); #endif + if (x1 >= vid.width) + x1 = vid.width - 1; + + // Water ripple effect + if (planeripple.active) + { + ds_bgofs = R_CalculateRippleOffset(y); + + ds_sup = &ds_su[y]; + ds_svp = &ds_sv[y]; + ds_szp = &ds_sz[y]; + + ds_bgofs >>= FRACBITS; + + if ((y + ds_bgofs) >= viewheight) + ds_bgofs = viewheight-y-1; + if ((y + ds_bgofs) < 0) + ds_bgofs = -y; + } + + if (currentplane->extra_colormap) + ds_colormap = currentplane->extra_colormap->colormap; + else + ds_colormap = colormaps; + + ds_y = y; + ds_x1 = x1; + ds_x2 = x2; + spanfunc(); - -#ifdef TIMING - RDMSR(0x10, &mycount); - mytotal += mycount; // 64bit add - if (!(nombre--)) - I_Error("spanfunc() CPU Spy reports: 0x%d %d\n", *((INT32 *)&mytotal+1), (INT32)mytotal); -#endif } void R_ClearFFloorClips (void) @@ -572,10 +576,7 @@ void R_ExpandPlane(visplane_t *pl, INT32 start, INT32 stop) } -// -// R_MakeSpans -// -void R_MakeSpans(INT32 x, INT32 t1, INT32 b1, INT32 t2, INT32 b2) +static void R_MakeSpans(INT32 x, INT32 t1, INT32 b1, INT32 t2, INT32 b2) { // Alam: from r_splats's R_RasterizeFloorSplat if (t1 >= vid.height) t1 = vid.height-1; @@ -601,6 +602,32 @@ void R_MakeSpans(INT32 x, INT32 t1, INT32 b1, INT32 t2, INT32 b2) spanstart[b2--] = x; } +static void R_MakeTiltedSpans(INT32 x, INT32 t1, INT32 b1, INT32 t2, INT32 b2) +{ + // Alam: from r_splats's R_RasterizeFloorSplat + if (t1 >= vid.height) t1 = vid.height-1; + if (b1 >= vid.height) b1 = vid.height-1; + if (t2 >= vid.height) t2 = vid.height-1; + if (b2 >= vid.height) b2 = vid.height-1; + if (x-1 >= vid.width) x = vid.width; + + while (t1 < t2 && t1 <= b1) + { + R_MapTiltedPlane(t1, spanstart[t1], x - 1); + t1++; + } + while (b1 > b2 && b1 >= t1) + { + R_MapTiltedPlane(b1, spanstart[b1], x - 1); + b1--; + } + + while (t2 < t1 && t2 <= b2) + spanstart[t2++] = x; + while (b2 > b1 && b2 >= t2) + spanstart[b2--] = x; +} + void R_DrawPlanes(void) { visplane_t *pl; @@ -670,17 +697,14 @@ static void R_SetSlopePlaneOrigin(pslope_t *slope, fixed_t xpos, fixed_t ypos, f float vx = FixedToFloat(xpos + xoff); float vy = FixedToFloat(ypos - yoff); - float vz = FixedToFloat(zpos); float ang = ANG2RAD(ANGLE_270 - angle); - zeroheight = FixedToFloat(P_GetSlopeZAt(slope, xpos, ypos)); - // p is the texture origin in view space // Don't add in the offsets at this stage, because doing so can result in // errors if the flat is rotated. p->x = vx * cos(ang) - vy * sin(ang); p->z = vx * sin(ang) + vy * cos(ang); - p->y = FixedToFloat(P_GetSlopeZAt(slope, -xoff, yoff)) - vz; + p->y = FixedToFloat(P_GetSlopeZAt(slope, -xoff, yoff) - zpos); } // This function calculates all of the vectors necessary for drawing a sloped plane. @@ -689,10 +713,12 @@ void R_SetSlopePlane(pslope_t *slope, fixed_t xpos, fixed_t ypos, fixed_t zpos, // Potentially override other stuff for now cus we're mean. :< But draw a slope plane! // I copied ZDoom's code and adapted it to SRB2... -Red floatv3_t *m = &ds_slope_v, *n = &ds_slope_u; - fixed_t temp; + fixed_t height, temp; float ang; R_SetSlopePlaneOrigin(slope, xpos, ypos, zpos, xoff, yoff, angle); + height = P_GetSlopeZAt(slope, xpos, ypos); + zeroheight = FixedToFloat(height - zpos); // m is the v direction vector in view space ang = ANG2RAD(ANGLE_180 - (angle + plangle)); @@ -703,24 +729,26 @@ void R_SetSlopePlane(pslope_t *slope, fixed_t xpos, fixed_t ypos, fixed_t zpos, n->x = sin(ang); n->z = -cos(ang); - ang = ANG2RAD(plangle); - temp = P_GetSlopeZAt(slope, xpos + FloatToFixed(sin(ang)), ypos + FloatToFixed(cos(ang))); - m->y = FixedToFloat(temp) - zeroheight; - temp = P_GetSlopeZAt(slope, xpos + FloatToFixed(cos(ang)), ypos - FloatToFixed(sin(ang))); - n->y = FixedToFloat(temp) - zeroheight; + plangle >>= ANGLETOFINESHIFT; + temp = P_GetSlopeZAt(slope, xpos + FINESINE(plangle), ypos + FINECOSINE(plangle)); + m->y = FixedToFloat(temp - height); + temp = P_GetSlopeZAt(slope, xpos + FINECOSINE(plangle), ypos - FINESINE(plangle)); + n->y = FixedToFloat(temp - height); } // This function calculates all of the vectors necessary for drawing a sloped and scaled plane. void R_SetScaledSlopePlane(pslope_t *slope, fixed_t xpos, fixed_t ypos, fixed_t zpos, fixed_t xs, fixed_t ys, fixed_t xoff, fixed_t yoff, angle_t angle, angle_t plangle) { floatv3_t *m = &ds_slope_v, *n = &ds_slope_u; - fixed_t temp; + fixed_t height, temp; float xscale = FixedToFloat(xs); float yscale = FixedToFloat(ys); float ang; R_SetSlopePlaneOrigin(slope, xpos, ypos, zpos, xoff, yoff, angle); + height = P_GetSlopeZAt(slope, xpos, ypos); + zeroheight = FixedToFloat(height - zpos); // m is the v direction vector in view space ang = ANG2RAD(ANGLE_180 - (angle + plangle)); @@ -733,9 +761,9 @@ void R_SetScaledSlopePlane(pslope_t *slope, fixed_t xpos, fixed_t ypos, fixed_t ang = ANG2RAD(plangle); temp = P_GetSlopeZAt(slope, xpos + FloatToFixed(yscale * sin(ang)), ypos + FloatToFixed(yscale * cos(ang))); - m->y = FixedToFloat(temp) - zeroheight; + m->y = FixedToFloat(temp - height); temp = P_GetSlopeZAt(slope, xpos + FloatToFixed(xscale * cos(ang)), ypos - FloatToFixed(xscale * sin(ang))); - n->y = FixedToFloat(temp) - zeroheight; + n->y = FixedToFloat(temp - height); } void R_CalculateSlopeVectors(void) @@ -803,29 +831,14 @@ static inline void R_AdjustSlopeCoordinates(visplane_t *pl) const fixed_t cosinecomponent = FINECOSINE(pl->plangle>>ANGLETOFINESHIFT); const fixed_t sinecomponent = FINESINE(pl->plangle>>ANGLETOFINESHIFT); - fixed_t ox = (FixedMul(pl->slope->o.x,cosinecomponent) & modmask) - (FixedMul(pl->slope->o.y,sinecomponent) & modmask); - fixed_t oy = (-FixedMul(pl->slope->o.x,sinecomponent) & modmask) - (FixedMul(pl->slope->o.y,cosinecomponent) & modmask); + fixed_t temp = xoffs; + xoffs = (FixedMul(temp,cosinecomponent) & modmask) + (FixedMul(yoffs,sinecomponent) & modmask); + yoffs = (-FixedMul(temp,sinecomponent) & modmask) + (FixedMul(yoffs,cosinecomponent) & modmask); - fixed_t temp = ox & modmask; - oy &= modmask; - - ox = FixedMul(temp,cosinecomponent)+FixedMul(oy,-sinecomponent); // negative sine for opposite direction - oy = -FixedMul(temp,-sinecomponent)+FixedMul(oy,cosinecomponent); - - if (xoffs || yoffs) - { - temp = xoffs; - xoffs = (FixedMul(temp,cosinecomponent) & modmask) + (FixedMul(yoffs,sinecomponent) & modmask); - yoffs = (-FixedMul(temp,sinecomponent) & modmask) + (FixedMul(yoffs,cosinecomponent) & modmask); - - temp = xoffs & modmask; - yoffs &= modmask; - xoffs = FixedMul(temp,cosinecomponent)+FixedMul(yoffs,-sinecomponent); // ditto - yoffs = -FixedMul(temp,-sinecomponent)+FixedMul(yoffs,cosinecomponent); - } - - xoffs -= (pl->slope->o.x - ox); - yoffs += (pl->slope->o.y + oy); + temp = xoffs & modmask; + yoffs &= modmask; + xoffs = FixedMul(temp,cosinecomponent)+FixedMul(yoffs,-sinecomponent); // negative sine for opposite direction + yoffs = -FixedMul(temp,-sinecomponent)+FixedMul(yoffs,cosinecomponent); } static inline void R_AdjustSlopeCoordinatesNPO2(visplane_t *pl) @@ -836,29 +849,14 @@ static inline void R_AdjustSlopeCoordinatesNPO2(visplane_t *pl) const fixed_t cosinecomponent = FINECOSINE(pl->plangle>>ANGLETOFINESHIFT); const fixed_t sinecomponent = FINESINE(pl->plangle>>ANGLETOFINESHIFT); - fixed_t ox = (FixedMul(pl->slope->o.x,cosinecomponent) % modmaskw) - (FixedMul(pl->slope->o.y,sinecomponent) % modmaskh); - fixed_t oy = (-FixedMul(pl->slope->o.x,sinecomponent) % modmaskw) - (FixedMul(pl->slope->o.y,cosinecomponent) % modmaskh); + fixed_t temp = xoffs; + xoffs = (FixedMul(temp,cosinecomponent) % modmaskw) + (FixedMul(yoffs,sinecomponent) % modmaskh); + yoffs = (-FixedMul(temp,sinecomponent) % modmaskw) + (FixedMul(yoffs,cosinecomponent) % modmaskh); - fixed_t temp = ox % modmaskw; - oy %= modmaskh; - - ox = FixedMul(temp,cosinecomponent)+FixedMul(oy,-sinecomponent); // negative sine for opposite direction - oy = -FixedMul(temp,-sinecomponent)+FixedMul(oy,cosinecomponent); - - if (xoffs || yoffs) - { - temp = xoffs; - xoffs = (FixedMul(temp,cosinecomponent) % modmaskw) + (FixedMul(yoffs,sinecomponent) % modmaskh); - yoffs = (-FixedMul(temp,sinecomponent) % modmaskw) + (FixedMul(yoffs,cosinecomponent) % modmaskh); - - temp = xoffs % modmaskw; - yoffs %= modmaskh; - xoffs = FixedMul(temp,cosinecomponent)+FixedMul(yoffs,-sinecomponent); // ditto - yoffs = -FixedMul(temp,-sinecomponent)+FixedMul(yoffs,cosinecomponent); - } - - xoffs -= (pl->slope->o.x - ox); - yoffs += (pl->slope->o.y + oy); + temp = xoffs % modmaskw; + yoffs %= modmaskh; + xoffs = FixedMul(temp,cosinecomponent)+FixedMul(yoffs,-sinecomponent); // ditto + yoffs = -FixedMul(temp,-sinecomponent)+FixedMul(yoffs,cosinecomponent); } void R_DrawSinglePlane(visplane_t *pl) @@ -1029,7 +1027,6 @@ void R_DrawSinglePlane(visplane_t *pl) xoffs = pl->xoffs; yoffs = pl->yoffs; - planeheight = abs(pl->height - pl->viewz); if (light >= LIGHTLEVELS) light = LIGHTLEVELS-1; @@ -1039,20 +1036,24 @@ void R_DrawSinglePlane(visplane_t *pl) if (pl->slope) { - if (ds_powersoftwo) - R_AdjustSlopeCoordinates(pl); - else - R_AdjustSlopeCoordinatesNPO2(pl); + if (xoffs || yoffs) + { + if (ds_powersoftwo) + R_AdjustSlopeCoordinates(pl); + else + R_AdjustSlopeCoordinatesNPO2(pl); + } if (planeripple.active) { - fixed_t plheight = abs(P_GetSlopeZAt(pl->slope, pl->viewx, pl->viewy) - pl->viewz); + planeheight = abs(P_GetSlopeZAt(pl->slope, pl->viewx, pl->viewy) - pl->viewz); R_PlaneBounds(pl); for (x = pl->high; x < pl->low; x++) { - R_CalculatePlaneRipple(pl, x, plheight, true); + ds_bgofs = R_CalculateRippleOffset(x); + R_CalculatePlaneRipple(pl->viewangle + pl->plangle); R_SetSlopePlaneVectors(pl, x, (xoffs + planeripple.xfrac), (yoffs + planeripple.yfrac)); } } @@ -1078,7 +1079,10 @@ void R_DrawSinglePlane(visplane_t *pl) planezlight = scalelight[light]; } else + { + planeheight = abs(pl->height - pl->viewz); planezlight = zlight[light]; + } // Use the correct span drawer depending on the powers-of-twoness if (!ds_powersoftwo) @@ -1099,18 +1103,15 @@ void R_DrawSinglePlane(visplane_t *pl) stop = pl->maxx + 1; - if (viewx != pl->viewx || viewy != pl->viewy) + if (pl->slope) { - viewx = pl->viewx; - viewy = pl->viewy; + for (x = pl->minx; x <= stop; x++) + R_MakeTiltedSpans(x, pl->top[x-1], pl->bottom[x-1], pl->top[x], pl->bottom[x]); } - if (viewz != pl->viewz) - viewz = pl->viewz; - - for (x = pl->minx; x <= stop; x++) + else { - R_MakeSpans(x, pl->top[x-1], pl->bottom[x-1], - pl->top[x], pl->bottom[x]); + for (x = pl->minx; x <= stop; x++) + R_MakeSpans(x, pl->top[x-1], pl->bottom[x-1], pl->top[x], pl->bottom[x]); } /* diff --git a/src/r_plane.h b/src/r_plane.h index 9b7e31e3e..bdad77930 100644 --- a/src/r_plane.h +++ b/src/r_plane.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -78,8 +78,6 @@ void R_InitPlanes(void); void R_ClearPlanes(void); void R_ClearFFloorClips (void); -void R_MapPlane(INT32 y, INT32 x1, INT32 x2); -void R_MakeSpans(INT32 x, INT32 t1, INT32 b1, INT32 t2, INT32 b2); void R_DrawPlanes(void); visplane_t *R_FindPlane(fixed_t height, INT32 picnum, INT32 lightlevel, fixed_t xoff, fixed_t yoff, angle_t plangle, extracolormap_t *planecolormap, ffloor_t *ffloor, polyobj_t *polyobj, pslope_t *slope); From 1c6296653a0e8010642e1acd0e749bb547de79c1 Mon Sep 17 00:00:00 2001 From: Jaime Ita Passos Date: Tue, 27 Apr 2021 20:32:41 -0300 Subject: [PATCH 0728/1080] Use floating point GetSlopeZAt for the texture origin vector --- src/r_plane.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/r_plane.c b/src/r_plane.c index ee7b161da..355260a11 100644 --- a/src/r_plane.c +++ b/src/r_plane.c @@ -690,6 +690,18 @@ static void R_DrawSkyPlane(visplane_t *pl) } } +// Returns the height of the sloped plane at (px, py) as a floating point number +static float R_GetSlopeZAt(const pslope_t *slope, fixed_t px, fixed_t py) +{ + float x = FixedToFloat(px - slope->o.x); + float y = FixedToFloat(py - slope->o.y); + + x = (x * FixedToFloat(slope->d.x)); + y = (y * FixedToFloat(slope->d.y)); + + return FixedToFloat(slope->o.z) + ((x + y) * FixedToFloat(slope->zdelta)); +} + // Sets the texture origin vector of the sloped plane. static void R_SetSlopePlaneOrigin(pslope_t *slope, fixed_t xpos, fixed_t ypos, fixed_t zpos, fixed_t xoff, fixed_t yoff, fixed_t angle) { @@ -697,6 +709,7 @@ static void R_SetSlopePlaneOrigin(pslope_t *slope, fixed_t xpos, fixed_t ypos, f float vx = FixedToFloat(xpos + xoff); float vy = FixedToFloat(ypos - yoff); + float vz = FixedToFloat(zpos); float ang = ANG2RAD(ANGLE_270 - angle); // p is the texture origin in view space @@ -704,7 +717,7 @@ static void R_SetSlopePlaneOrigin(pslope_t *slope, fixed_t xpos, fixed_t ypos, f // errors if the flat is rotated. p->x = vx * cos(ang) - vy * sin(ang); p->z = vx * sin(ang) + vy * cos(ang); - p->y = FixedToFloat(P_GetSlopeZAt(slope, -xoff, yoff) - zpos); + p->y = R_GetSlopeZAt(slope, -xoff, yoff) - vz; } // This function calculates all of the vectors necessary for drawing a sloped plane. From 63761a2d07f7b336eb4f7a26778fffd04a38f810 Mon Sep 17 00:00:00 2001 From: Jaime Ita Passos Date: Tue, 27 Apr 2021 20:42:59 -0300 Subject: [PATCH 0729/1080] Use floating point trig in R_SetSlopePlane --- src/r_plane.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/r_plane.c b/src/r_plane.c index 355260a11..3ea046595 100644 --- a/src/r_plane.c +++ b/src/r_plane.c @@ -742,10 +742,10 @@ void R_SetSlopePlane(pslope_t *slope, fixed_t xpos, fixed_t ypos, fixed_t zpos, n->x = sin(ang); n->z = -cos(ang); - plangle >>= ANGLETOFINESHIFT; - temp = P_GetSlopeZAt(slope, xpos + FINESINE(plangle), ypos + FINECOSINE(plangle)); + ang = ANG2RAD(plangle); + temp = P_GetSlopeZAt(slope, xpos + FloatToFixed(sin(ang)), ypos + FloatToFixed(cos(ang))); m->y = FixedToFloat(temp - height); - temp = P_GetSlopeZAt(slope, xpos + FINECOSINE(plangle), ypos - FINESINE(plangle)); + temp = P_GetSlopeZAt(slope, xpos + FloatToFixed(cos(ang)), ypos - FloatToFixed(sin(ang))); n->y = FixedToFloat(temp - height); } From 0fba870a3526eb4397f261fe77388095173b82f8 Mon Sep 17 00:00:00 2001 From: Jaime Ita Passos Date: Tue, 27 Apr 2021 22:54:56 -0300 Subject: [PATCH 0730/1080] Revert "Use floating point trig in R_SetSlopePlane" This reverts commit 63761a2d07f7b336eb4f7a26778fffd04a38f810. --- src/r_plane.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/r_plane.c b/src/r_plane.c index 3ea046595..355260a11 100644 --- a/src/r_plane.c +++ b/src/r_plane.c @@ -742,10 +742,10 @@ void R_SetSlopePlane(pslope_t *slope, fixed_t xpos, fixed_t ypos, fixed_t zpos, n->x = sin(ang); n->z = -cos(ang); - ang = ANG2RAD(plangle); - temp = P_GetSlopeZAt(slope, xpos + FloatToFixed(sin(ang)), ypos + FloatToFixed(cos(ang))); + plangle >>= ANGLETOFINESHIFT; + temp = P_GetSlopeZAt(slope, xpos + FINESINE(plangle), ypos + FINECOSINE(plangle)); m->y = FixedToFloat(temp - height); - temp = P_GetSlopeZAt(slope, xpos + FloatToFixed(cos(ang)), ypos - FloatToFixed(sin(ang))); + temp = P_GetSlopeZAt(slope, xpos + FINECOSINE(plangle), ypos - FINESINE(plangle)); n->y = FixedToFloat(temp - height); } From 8f47a7e9cc98af4b1631e32e98ff4421f03c49d9 Mon Sep 17 00:00:00 2001 From: Jaime Ita Passos Date: Tue, 27 Apr 2021 22:59:06 -0300 Subject: [PATCH 0731/1080] Prevent texture wobbling on planes with no flat alignment --- src/r_plane.c | 102 +++++++++++++++++++++++++++++++++++--------------- 1 file changed, 72 insertions(+), 30 deletions(-) diff --git a/src/r_plane.c b/src/r_plane.c index 355260a11..acbbc8a5c 100644 --- a/src/r_plane.c +++ b/src/r_plane.c @@ -690,16 +690,16 @@ static void R_DrawSkyPlane(visplane_t *pl) } } -// Returns the height of the sloped plane at (px, py) as a floating point number -static float R_GetSlopeZAt(const pslope_t *slope, fixed_t px, fixed_t py) +// Returns the height of the sloped plane at (x, y) as a 32.16 fixed_t +static INT64 R_GetSlopeZAt(const pslope_t *slope, fixed_t x, fixed_t y) { - float x = FixedToFloat(px - slope->o.x); - float y = FixedToFloat(py - slope->o.y); + x = ((INT64)x - (INT64)slope->o.x); + y = ((INT64)y - (INT64)slope->o.y); - x = (x * FixedToFloat(slope->d.x)); - y = (y * FixedToFloat(slope->d.y)); + x = (x * (INT64)slope->d.x) / FRACUNIT; + y = (y * (INT64)slope->d.y) / FRACUNIT; - return FixedToFloat(slope->o.z) + ((x + y) * FixedToFloat(slope->zdelta)); + return (INT64)slope->o.z + ((x + y) * (INT64)slope->zdelta) / FRACUNIT; } // Sets the texture origin vector of the sloped plane. @@ -709,7 +709,6 @@ static void R_SetSlopePlaneOrigin(pslope_t *slope, fixed_t xpos, fixed_t ypos, f float vx = FixedToFloat(xpos + xoff); float vy = FixedToFloat(ypos - yoff); - float vz = FixedToFloat(zpos); float ang = ANG2RAD(ANGLE_270 - angle); // p is the texture origin in view space @@ -717,7 +716,7 @@ static void R_SetSlopePlaneOrigin(pslope_t *slope, fixed_t xpos, fixed_t ypos, f // errors if the flat is rotated. p->x = vx * cos(ang) - vy * sin(ang); p->z = vx * sin(ang) + vy * cos(ang); - p->y = R_GetSlopeZAt(slope, -xoff, yoff) - vz; + p->y = (R_GetSlopeZAt(slope, -xoff, yoff) - zpos) / (float)FRACUNIT; } // This function calculates all of the vectors necessary for drawing a sloped plane. @@ -844,14 +843,37 @@ static inline void R_AdjustSlopeCoordinates(visplane_t *pl) const fixed_t cosinecomponent = FINECOSINE(pl->plangle>>ANGLETOFINESHIFT); const fixed_t sinecomponent = FINESINE(pl->plangle>>ANGLETOFINESHIFT); - fixed_t temp = xoffs; - xoffs = (FixedMul(temp,cosinecomponent) & modmask) + (FixedMul(yoffs,sinecomponent) & modmask); - yoffs = (-FixedMul(temp,sinecomponent) & modmask) + (FixedMul(yoffs,cosinecomponent) & modmask); + fixed_t ox, oy, temp; - temp = xoffs & modmask; - yoffs &= modmask; - xoffs = FixedMul(temp,cosinecomponent)+FixedMul(yoffs,-sinecomponent); // negative sine for opposite direction - yoffs = -FixedMul(temp,-sinecomponent)+FixedMul(yoffs,cosinecomponent); + if (!pl->plangle) + { + ox = (FixedMul(pl->slope->o.x,cosinecomponent) & modmask) - (FixedMul(pl->slope->o.y,sinecomponent) & modmask); + oy = (-FixedMul(pl->slope->o.x,sinecomponent) & modmask) - (FixedMul(pl->slope->o.y,cosinecomponent) & modmask); + + temp = ox & modmask; + oy &= modmask; + + ox = FixedMul(temp,cosinecomponent)+FixedMul(oy,-sinecomponent); // negative sine for opposite direction + oy = -FixedMul(temp,-sinecomponent)+FixedMul(oy,cosinecomponent); + } + + if (xoffs || yoffs) + { + temp = xoffs; + xoffs = (FixedMul(temp,cosinecomponent) & modmask) + (FixedMul(yoffs,sinecomponent) & modmask); + yoffs = (-FixedMul(temp,sinecomponent) & modmask) + (FixedMul(yoffs,cosinecomponent) & modmask); + + temp = xoffs & modmask; + yoffs &= modmask; + xoffs = FixedMul(temp,cosinecomponent)+FixedMul(yoffs,-sinecomponent); // ditto + yoffs = -FixedMul(temp,-sinecomponent)+FixedMul(yoffs,cosinecomponent); + } + + if (!pl->plangle) + { + xoffs -= (pl->slope->o.x - ox); + yoffs += (pl->slope->o.y + oy); + } } static inline void R_AdjustSlopeCoordinatesNPO2(visplane_t *pl) @@ -862,14 +884,37 @@ static inline void R_AdjustSlopeCoordinatesNPO2(visplane_t *pl) const fixed_t cosinecomponent = FINECOSINE(pl->plangle>>ANGLETOFINESHIFT); const fixed_t sinecomponent = FINESINE(pl->plangle>>ANGLETOFINESHIFT); - fixed_t temp = xoffs; - xoffs = (FixedMul(temp,cosinecomponent) % modmaskw) + (FixedMul(yoffs,sinecomponent) % modmaskh); - yoffs = (-FixedMul(temp,sinecomponent) % modmaskw) + (FixedMul(yoffs,cosinecomponent) % modmaskh); + fixed_t ox, oy, temp; - temp = xoffs % modmaskw; - yoffs %= modmaskh; - xoffs = FixedMul(temp,cosinecomponent)+FixedMul(yoffs,-sinecomponent); // ditto - yoffs = -FixedMul(temp,-sinecomponent)+FixedMul(yoffs,cosinecomponent); + if (!pl->plangle) + { + ox = (FixedMul(pl->slope->o.x,cosinecomponent) % modmaskw) - (FixedMul(pl->slope->o.y,sinecomponent) % modmaskh); + oy = (-FixedMul(pl->slope->o.x,sinecomponent) % modmaskw) - (FixedMul(pl->slope->o.y,cosinecomponent) % modmaskh); + + temp = ox % modmaskw; + oy %= modmaskh; + + ox = FixedMul(temp,cosinecomponent)+FixedMul(oy,-sinecomponent); // negative sine for opposite direction + oy = -FixedMul(temp,-sinecomponent)+FixedMul(oy,cosinecomponent); + } + + if (xoffs || yoffs) + { + temp = xoffs; + xoffs = (FixedMul(temp,cosinecomponent) % modmaskw) + (FixedMul(yoffs,sinecomponent) % modmaskh); + yoffs = (-FixedMul(temp,sinecomponent) % modmaskw) + (FixedMul(yoffs,cosinecomponent) % modmaskh); + + temp = xoffs % modmaskw; + yoffs %= modmaskh; + xoffs = FixedMul(temp,cosinecomponent)+FixedMul(yoffs,-sinecomponent); // ditto + yoffs = -FixedMul(temp,-sinecomponent)+FixedMul(yoffs,cosinecomponent); + } + + if (!pl->plangle) + { + xoffs -= (pl->slope->o.x - ox); + yoffs += (pl->slope->o.y + oy); + } } void R_DrawSinglePlane(visplane_t *pl) @@ -1049,13 +1094,10 @@ void R_DrawSinglePlane(visplane_t *pl) if (pl->slope) { - if (xoffs || yoffs) - { - if (ds_powersoftwo) - R_AdjustSlopeCoordinates(pl); - else - R_AdjustSlopeCoordinatesNPO2(pl); - } + if (ds_powersoftwo) + R_AdjustSlopeCoordinates(pl); + else + R_AdjustSlopeCoordinatesNPO2(pl); if (planeripple.active) { From 090f304f3368d96cb02c2ffb89701864d07c2191 Mon Sep 17 00:00:00 2001 From: Jaime Ita Passos Date: Wed, 28 Apr 2021 22:00:20 -0300 Subject: [PATCH 0732/1080] Use 64-bit x/y in R_GetSlopeZAt --- src/r_plane.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/r_plane.c b/src/r_plane.c index acbbc8a5c..8db4801b5 100644 --- a/src/r_plane.c +++ b/src/r_plane.c @@ -693,13 +693,13 @@ static void R_DrawSkyPlane(visplane_t *pl) // Returns the height of the sloped plane at (x, y) as a 32.16 fixed_t static INT64 R_GetSlopeZAt(const pslope_t *slope, fixed_t x, fixed_t y) { - x = ((INT64)x - (INT64)slope->o.x); - y = ((INT64)y - (INT64)slope->o.y); + INT64 x64 = ((INT64)x - (INT64)slope->o.x); + INT64 y64 = ((INT64)y - (INT64)slope->o.y); - x = (x * (INT64)slope->d.x) / FRACUNIT; - y = (y * (INT64)slope->d.y) / FRACUNIT; + x64 = (x64 * (INT64)slope->d.x) / FRACUNIT; + y64 = (y64 * (INT64)slope->d.y) / FRACUNIT; - return (INT64)slope->o.z + ((x + y) * (INT64)slope->zdelta) / FRACUNIT; + return (INT64)slope->o.z + ((x64 + y64) * (INT64)slope->zdelta) / FRACUNIT; } // Sets the texture origin vector of the sloped plane. From 9d41325843d9c63c5e9862034e06863f7be0d65c Mon Sep 17 00:00:00 2001 From: Jaime Ita Passos Date: Wed, 28 Apr 2021 22:15:05 -0300 Subject: [PATCH 0733/1080] Only adjust slope offsets if the plane isn't rotated --- src/r_plane.c | 98 +++++++++++---------------------------------------- 1 file changed, 21 insertions(+), 77 deletions(-) diff --git a/src/r_plane.c b/src/r_plane.c index 8db4801b5..c56a222df 100644 --- a/src/r_plane.c +++ b/src/r_plane.c @@ -829,92 +829,33 @@ static void R_SetSlopePlaneVectors(visplane_t *pl, INT32 y, fixed_t xoff, fixed_ R_CalculateSlopeVectors(); } -/* - Essentially: We can't & the components along the regular axes when the plane is rotated. - This is because the distance on each regular axis in order to loop is different. - We rotate them, & the components, add them together, & them again, and then rotate them back. - These three seperate & operations are done per axis in order to prevent overflows. - toast 10/04/17 -*/ -static inline void R_AdjustSlopeCoordinates(visplane_t *pl) +static inline void R_AdjustSlopeCoordinates(vector3_t *origin) { const fixed_t modmask = ((1 << (32-nflatshiftup)) - 1); - const fixed_t cosinecomponent = FINECOSINE(pl->plangle>>ANGLETOFINESHIFT); - const fixed_t sinecomponent = FINESINE(pl->plangle>>ANGLETOFINESHIFT); + fixed_t ox = (origin->x & modmask); + fixed_t oy = -(origin->y & modmask); - fixed_t ox, oy, temp; + xoffs &= modmask; + yoffs &= modmask; - if (!pl->plangle) - { - ox = (FixedMul(pl->slope->o.x,cosinecomponent) & modmask) - (FixedMul(pl->slope->o.y,sinecomponent) & modmask); - oy = (-FixedMul(pl->slope->o.x,sinecomponent) & modmask) - (FixedMul(pl->slope->o.y,cosinecomponent) & modmask); - - temp = ox & modmask; - oy &= modmask; - - ox = FixedMul(temp,cosinecomponent)+FixedMul(oy,-sinecomponent); // negative sine for opposite direction - oy = -FixedMul(temp,-sinecomponent)+FixedMul(oy,cosinecomponent); - } - - if (xoffs || yoffs) - { - temp = xoffs; - xoffs = (FixedMul(temp,cosinecomponent) & modmask) + (FixedMul(yoffs,sinecomponent) & modmask); - yoffs = (-FixedMul(temp,sinecomponent) & modmask) + (FixedMul(yoffs,cosinecomponent) & modmask); - - temp = xoffs & modmask; - yoffs &= modmask; - xoffs = FixedMul(temp,cosinecomponent)+FixedMul(yoffs,-sinecomponent); // ditto - yoffs = -FixedMul(temp,-sinecomponent)+FixedMul(yoffs,cosinecomponent); - } - - if (!pl->plangle) - { - xoffs -= (pl->slope->o.x - ox); - yoffs += (pl->slope->o.y + oy); - } + xoffs -= (origin->x - ox); + yoffs += (origin->y + oy); } -static inline void R_AdjustSlopeCoordinatesNPO2(visplane_t *pl) +static inline void R_AdjustSlopeCoordinatesNPO2(vector3_t *origin) { const fixed_t modmaskw = (ds_flatwidth << FRACBITS); const fixed_t modmaskh = (ds_flatheight << FRACBITS); - const fixed_t cosinecomponent = FINECOSINE(pl->plangle>>ANGLETOFINESHIFT); - const fixed_t sinecomponent = FINESINE(pl->plangle>>ANGLETOFINESHIFT); + fixed_t ox = (origin->x % modmaskw); + fixed_t oy = -(origin->y % modmaskh); - fixed_t ox, oy, temp; + xoffs %= modmaskw; + yoffs %= modmaskh; - if (!pl->plangle) - { - ox = (FixedMul(pl->slope->o.x,cosinecomponent) % modmaskw) - (FixedMul(pl->slope->o.y,sinecomponent) % modmaskh); - oy = (-FixedMul(pl->slope->o.x,sinecomponent) % modmaskw) - (FixedMul(pl->slope->o.y,cosinecomponent) % modmaskh); - - temp = ox % modmaskw; - oy %= modmaskh; - - ox = FixedMul(temp,cosinecomponent)+FixedMul(oy,-sinecomponent); // negative sine for opposite direction - oy = -FixedMul(temp,-sinecomponent)+FixedMul(oy,cosinecomponent); - } - - if (xoffs || yoffs) - { - temp = xoffs; - xoffs = (FixedMul(temp,cosinecomponent) % modmaskw) + (FixedMul(yoffs,sinecomponent) % modmaskh); - yoffs = (-FixedMul(temp,sinecomponent) % modmaskw) + (FixedMul(yoffs,cosinecomponent) % modmaskh); - - temp = xoffs % modmaskw; - yoffs %= modmaskh; - xoffs = FixedMul(temp,cosinecomponent)+FixedMul(yoffs,-sinecomponent); // ditto - yoffs = -FixedMul(temp,-sinecomponent)+FixedMul(yoffs,cosinecomponent); - } - - if (!pl->plangle) - { - xoffs -= (pl->slope->o.x - ox); - yoffs += (pl->slope->o.y + oy); - } + xoffs -= (origin->x - ox); + yoffs += (origin->y + oy); } void R_DrawSinglePlane(visplane_t *pl) @@ -1094,10 +1035,13 @@ void R_DrawSinglePlane(visplane_t *pl) if (pl->slope) { - if (ds_powersoftwo) - R_AdjustSlopeCoordinates(pl); - else - R_AdjustSlopeCoordinatesNPO2(pl); + if (!pl->plangle) + { + if (ds_powersoftwo) + R_AdjustSlopeCoordinates(&pl->slope->o); + else + R_AdjustSlopeCoordinatesNPO2(&pl->slope->o); + } if (planeripple.active) { From b4a09405a77d5bb5ec1c677a123f763ff2193ebb Mon Sep 17 00:00:00 2001 From: Jaime Ita Passos Date: Thu, 29 Apr 2021 19:24:37 -0300 Subject: [PATCH 0734/1080] Use 64-bit math for calculating the texture origin X/Z --- src/r_plane.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/r_plane.c b/src/r_plane.c index c56a222df..d26c124ef 100644 --- a/src/r_plane.c +++ b/src/r_plane.c @@ -707,15 +707,18 @@ static void R_SetSlopePlaneOrigin(pslope_t *slope, fixed_t xpos, fixed_t ypos, f { floatv3_t *p = &ds_slope_origin; - float vx = FixedToFloat(xpos + xoff); - float vy = FixedToFloat(ypos - yoff); + INT64 vx = (INT64)xpos + (INT64)xoff; + INT64 vy = (INT64)ypos - (INT64)yoff; + + float vxf = vx / (float)FRACUNIT; + float vyf = vy / (float)FRACUNIT; float ang = ANG2RAD(ANGLE_270 - angle); // p is the texture origin in view space // Don't add in the offsets at this stage, because doing so can result in // errors if the flat is rotated. - p->x = vx * cos(ang) - vy * sin(ang); - p->z = vx * sin(ang) + vy * cos(ang); + p->x = vxf * cos(ang) - vyf * sin(ang); + p->z = vxf * sin(ang) + vyf * cos(ang); p->y = (R_GetSlopeZAt(slope, -xoff, yoff) - zpos) / (float)FRACUNIT; } From ea7b332525901bd4bd29eca368fe75ae31e413a4 Mon Sep 17 00:00:00 2001 From: Tatsuru <44866610+TatsuruIKR@users.noreply.github.com> Date: Fri, 30 Apr 2021 15:49:09 -0300 Subject: [PATCH 0735/1080] Visit srb2.org/addons to get & make addons! --- 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 0fca39801..562779d39 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -6234,7 +6234,7 @@ static void M_AddonsOptions(INT32 choice) M_SetupNextMenu(&OP_AddonsOptionsDef); } -#define LOCATIONSTRING1 "Visit \x83SRB2.ORG/MODS\x80 to get & make add-ons!" +#define LOCATIONSTRING1 "Visit \x83SRB2.ORG/ADDONS\x80 to get & make addons!" //#define LOCATIONSTRING2 "Visit \x88SRB2.ORG/MODS\x80 to get & make add-ons!" static void M_LoadAddonsPatches(void) From 858cb98e57020be1cf822a114025d79f9d43c57c Mon Sep 17 00:00:00 2001 From: katsy Date: Fri, 30 Apr 2021 17:26:09 -0500 Subject: [PATCH 0736/1080] attempt to resolve teleportation resync issue --- 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 7c2dec6a1..62817ea08 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -4268,7 +4268,7 @@ static void HandlePacketFromPlayer(SINT8 node) case PT_RECEIVEDGAMESTATE: sendingsavegame[node] = false; resendingsavegame[node] = false; - savegameresendcooldown[node] = I_GetTime() + 15 * TICRATE; + savegameresendcooldown[node] = I_GetTime() + TICRATE; break; // -------------------------------------------- CLIENT RECEIVE ---------- case PT_SERVERTICS: From bda0ffe94b4491628df2626d4831c98a475a6e1f Mon Sep 17 00:00:00 2001 From: SMS Alfredo <65426124+SMS-Alfredo@users.noreply.github.com> Date: Fri, 30 Apr 2021 18:20:55 -0500 Subject: [PATCH 0737/1080] You've been blocked --- src/lua_hook.h | 2 +- src/lua_hooklib.c | 74 +++++++++++++++++++++++++++++++++++++++++++++++ src/p_mobj.c | 2 +- 3 files changed, 76 insertions(+), 2 deletions(-) diff --git a/src/lua_hook.h b/src/lua_hook.h index 0d631aa4e..8d80ec8c6 100644 --- a/src/lua_hook.h +++ b/src/lua_hook.h @@ -106,7 +106,7 @@ boolean LUAh_HurtMsg(player_t *player, mobj_t *inflictor, mobj_t *source, UINT8 #define LUAh_PlayerSpawn(player) LUAh_PlayerHook(player, hook_PlayerSpawn) // Hook for G_SpawnPlayer #define LUAh_ShieldSpawn(player) LUAh_PlayerHook(player, hook_ShieldSpawn) // Hook for P_SpawnShieldOrb #define LUAh_ShieldSpecial(player) LUAh_PlayerHook(player, hook_ShieldSpecial) // Hook for shield abilities -#define LUAh_MobjMoveBlocked(mo) LUAh_MobjHook(mo, hook_MobjMoveBlocked) // Hook for P_XYMovement (when movement is blocked) +boolean LUAh_MobjMoveBlocked(mobj_t *mo, mobj_t *thing, line_t *line); // Hook for P_XYMovement (when movement is blocked) boolean LUAh_MapThingSpawn(mobj_t *mo, mapthing_t *mthing); // Hook for P_SpawnMapThing by mobj type boolean LUAh_FollowMobj(player_t *player, mobj_t *mobj); // Hook for P_PlayerAfterThink Smiles mobj-following UINT8 LUAh_PlayerCanDamage(player_t *player, mobj_t *mobj); // Hook for P_PlayerCanDamage diff --git a/src/lua_hooklib.c b/src/lua_hooklib.c index 1665e36b0..2b4eda525 100644 --- a/src/lua_hooklib.c +++ b/src/lua_hooklib.c @@ -1414,6 +1414,80 @@ void LUAh_NetArchiveHook(lua_CFunction archFunc) // stack: tables } +boolean LUAh_MobjMoveBlocked(mobj_t *mo, mobj_t *thing, line_t *line) +{ + hook_p hookp; + boolean hooked = false; + if (!gL || !(hooksAvailable[hook_MobjMoveBlocked/8] & (1<<(hook_MobjMoveBlocked%8)))) + return false; + + if (!(mobjhooks[MT_NULL] || mobjhooks[mo->type])) + return false; + + lua_settop(gL, 0); + lua_pushcfunction(gL, LUA_GetErrorMessage); + + // Look for all generic mobj move blocked hooks + for (hookp = mobjhooks[MT_NULL]; hookp; hookp = hookp->next) + { + if (hookp->type != hook_MobjMoveBlocked) + continue; + + ps_lua_mobjhooks++; + if (lua_gettop(gL) == 1) + { + LUA_PushUserdata(gL, mo, META_MOBJ); + LUA_PushUserdata(gL, thing, META_MOBJ); + LUA_PushUserdata(gL, line, META_LINE); + } + PushHook(gL, hookp); + lua_pushvalue(gL, -4); + lua_pushvalue(gL, -4); + lua_pushvalue(gL, -4); + if (lua_pcall(gL, 3, 1, 1)) { + if (!hookp->error || cv_debug & DBG_LUA) + CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); + lua_pop(gL, 1); + hookp->error = true; + continue; + } + if (lua_toboolean(gL, -1)) + hooked = true; + lua_pop(gL, 1); + } + + for (hookp = mobjhooks[mo->type]; hookp; hookp = hookp->next) + { + if (hookp->type != hook_MobjMoveBlocked) + continue; + + ps_lua_mobjhooks++; + if (lua_gettop(gL) == 1) + { + LUA_PushUserdata(gL, mo, META_MOBJ); + LUA_PushUserdata(gL, thing, META_MOBJ); + LUA_PushUserdata(gL, line, META_LINE); + } + PushHook(gL, hookp); + lua_pushvalue(gL, -4); + lua_pushvalue(gL, -4); + lua_pushvalue(gL, -4); + if (lua_pcall(gL, 3, 1, 1)) { + if (!hookp->error || cv_debug & DBG_LUA) + CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); + lua_pop(gL, 1); + hookp->error = true; + continue; + } + if (lua_toboolean(gL, -1)) + hooked = true; + lua_pop(gL, 1); + } + + lua_settop(gL, 0); + return hooked; +} + boolean LUAh_MapThingSpawn(mobj_t *mo, mapthing_t *mthing) { hook_p hookp; diff --git a/src/p_mobj.c b/src/p_mobj.c index 49db6daee..bac3cd2df 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -1844,7 +1844,7 @@ void P_XYMovement(mobj_t *mo) B_MoveBlocked(player); } - if (LUAh_MobjMoveBlocked(mo)) + if (LUAh_MobjMoveBlocked(mo, tmhitthing, blockingline)) { if (P_MobjWasRemoved(mo)) return; From 815db014385b59664041927a97ca4c2322abe19c Mon Sep 17 00:00:00 2001 From: katsy Date: Fri, 30 Apr 2021 20:30:35 -0400 Subject: [PATCH 0738/1080] adjust cooldown to 5 seconds (bandage fix for 2.2.9) --- 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 62817ea08..04c34e7bc 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -4268,7 +4268,7 @@ static void HandlePacketFromPlayer(SINT8 node) case PT_RECEIVEDGAMESTATE: sendingsavegame[node] = false; resendingsavegame[node] = false; - savegameresendcooldown[node] = I_GetTime() + TICRATE; + savegameresendcooldown[node] = I_GetTime() + 5 * TICRATE; break; // -------------------------------------------- CLIENT RECEIVE ---------- case PT_SERVERTICS: From 381ead4d7e378b557f135a39d582d6a11a8d8af7 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Fri, 30 Apr 2021 21:46:09 -0400 Subject: [PATCH 0739/1080] Level select no longer assumes that games will always be linear - If a level is in-between two with the same header, it would previously create two headers with the same name. Now it groups all levels with the same header together. - Previously, a header would only be visible if its first map was visible. Now it will show the header if you've visited any level under the header. For SUGOI. --- src/m_menu.c | 195 ++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 148 insertions(+), 47 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index 0fca39801..5a5c98241 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -5166,34 +5166,75 @@ static boolean M_GametypeHasLevels(INT32 gt) static INT32 M_CountRowsToShowOnPlatter(INT32 gt) { - INT32 mapnum = 0, prevmapnum = 0, col = 0, rows = 0; + INT32 col = 0, rows = 0; + INT32 mapIterate = 0; + INT32 headingIterate = 0; + boolean mapAddedAlready[NUMMAPS]; - while (mapnum < NUMMAPS) + memset(mapAddedAlready, 0, sizeof mapAddedAlready); + + for (mapIterate = 0; mapIterate < NUMMAPS; mapIterate++) { - if (M_CanShowLevelOnPlatter(mapnum, gt)) + boolean forceNewRow = true; + + if (mapAddedAlready[mapIterate] == true) { - if (rows == 0) + // Already added under another heading + continue; + } + + if (M_CanShowLevelOnPlatter(mapIterate, gt) == false) + { + // Don't show this one + continue; + } + + for (headingIterate = mapIterate; headingIterate < NUMMAPS; headingIterate++) + { + boolean wide = false; + + if (mapAddedAlready[headingIterate] == true) + { + // Already added under another heading + continue; + } + + if (M_CanShowLevelOnPlatter(headingIterate, gt) == false) + { + // Don't show this one + continue; + } + + if (!fastcmp(mapheaderinfo[mapIterate]->selectheading, mapheaderinfo[headingIterate]->selectheading)) + { + // Headers don't match + continue; + } + + wide = (mapheaderinfo[headingIterate]->menuflags & LF2_WIDEICON); + + // preparing next position to drop mapnum into + if (col == 2 // no more space on the row? + || wide || forceNewRow) + { + col = 0; rows++; + } else { - if (col == 2 - || (mapheaderinfo[prevmapnum]->menuflags & LF2_WIDEICON) - || (mapheaderinfo[mapnum]->menuflags & LF2_WIDEICON) - || !(fastcmp(mapheaderinfo[mapnum]->selectheading, mapheaderinfo[prevmapnum]->selectheading))) - { - col = 0; - rows++; - } - else - col++; + col++; } - prevmapnum = mapnum; + + // Done adding this one + mapAddedAlready[headingIterate] = true; + forceNewRow = wide; } - mapnum++; } if (levellistmode == LLM_CREATESERVER) + { rows++; + } return rows; } @@ -5223,7 +5264,10 @@ static void M_CacheLevelPlatter(void) static boolean M_PrepareLevelPlatter(INT32 gt, boolean nextmappick) { INT32 numrows = M_CountRowsToShowOnPlatter(gt); - INT32 mapnum = 0, prevmapnum = 0, col = 0, row = 0, startrow = 0; + INT32 col = 0, row = 0, startrow = 0; + INT32 mapIterate = 0; // First level of map loop -- find starting points for select headings + INT32 headingIterate = 0; // Second level of map loop -- finding maps that match mapIterate's heading. + boolean mapAddedAlready[NUMMAPS]; if (!numrows) return false; @@ -5240,6 +5284,8 @@ static boolean M_PrepareLevelPlatter(INT32 gt, boolean nextmappick) // done here so lsrow and lscol can be set if cv_nextmap is on the platter lsrow = lscol = lshli = lsoffs[0] = lsoffs[1] = 0; + memset(mapAddedAlready, 0, sizeof mapAddedAlready); + if (levellistmode == LLM_CREATESERVER) { sprintf(levelselect.rows[0].header, "Gametype"); @@ -5251,31 +5297,75 @@ static boolean M_PrepareLevelPlatter(INT32 gt, boolean nextmappick) char_notes = NULL; } - while (mapnum < NUMMAPS) + for (mapIterate = 0; mapIterate < NUMMAPS; mapIterate++) { - if (M_CanShowLevelOnPlatter(mapnum, gt)) + INT32 headerRow = -1; + boolean anyAvailable = false; + boolean forceNewRow = true; + + if (mapAddedAlready[mapIterate] == true) { - const UINT8 actnum = mapheaderinfo[mapnum]->actnum; - const boolean headingisname = (fastcmp(mapheaderinfo[mapnum]->selectheading, mapheaderinfo[mapnum]->lvlttl)); - const boolean wide = (mapheaderinfo[mapnum]->menuflags & LF2_WIDEICON); + // Already added under another heading + continue; + } + + if (M_CanShowLevelOnPlatter(mapIterate, gt) == false) + { + // Don't show this one + continue; + } + + for (headingIterate = mapIterate; headingIterate < NUMMAPS; headingIterate++) + { + UINT8 actnum = 0; + boolean headingisname = false; + boolean wide = false; + + if (mapAddedAlready[headingIterate] == true) + { + // Already added under another heading + continue; + } + + if (M_CanShowLevelOnPlatter(headingIterate, gt) == false) + { + // Don't show this one + continue; + } + + if (!fastcmp(mapheaderinfo[mapIterate]->selectheading, mapheaderinfo[headingIterate]->selectheading)) + { + // Headers don't match + continue; + } + + actnum = mapheaderinfo[headingIterate]->actnum; + headingisname = (fastcmp(mapheaderinfo[headingIterate]->selectheading, mapheaderinfo[headingIterate]->lvlttl)); + wide = (mapheaderinfo[headingIterate]->menuflags & LF2_WIDEICON); // preparing next position to drop mapnum into if (levelselect.rows[startrow].maplist[0]) { if (col == 2 // no more space on the row? - || wide - || (mapheaderinfo[prevmapnum]->menuflags & LF2_WIDEICON) - || !(fastcmp(mapheaderinfo[mapnum]->selectheading, mapheaderinfo[prevmapnum]->selectheading))) // a new heading is starting? + || wide || forceNewRow) { col = 0; row++; } else + { col++; + } } - levelselect.rows[row].maplist[col] = mapnum+1; // putting the map on the platter - levelselect.rows[row].mapavailable[col] = M_LevelAvailableOnPlatter(mapnum); + if (headerRow == -1) + { + // Set where the header row is meant to be + headerRow = row; + } + + levelselect.rows[row].maplist[col] = headingIterate+1; // putting the map on the platter + levelselect.rows[row].mapavailable[col] = M_LevelAvailableOnPlatter(headingIterate); if ((lswide(row) = wide)) // intentionally assignment { @@ -5283,7 +5373,7 @@ static boolean M_PrepareLevelPlatter(INT32 gt, boolean nextmappick) levelselect.rows[row].mapavailable[2] = levelselect.rows[row].mapavailable[1] = levelselect.rows[row].mapavailable[0]; } - if (nextmappick && cv_nextmap.value == mapnum+1) // A little quality of life improvement. + if (nextmappick && cv_nextmap.value == headingIterate+1) // A little quality of life improvement. { lsrow = row; lscol = col; @@ -5292,6 +5382,8 @@ static boolean M_PrepareLevelPlatter(INT32 gt, boolean nextmappick) // individual map name if (levelselect.rows[row].mapavailable[col]) { + anyAvailable = true; + if (headingisname) { if (actnum) @@ -5302,7 +5394,7 @@ static boolean M_PrepareLevelPlatter(INT32 gt, boolean nextmappick) else if (wide) { // Yes, with LF2_WIDEICON it'll continue on over into the next 17+1 char block. That's alright; col is always zero, the string is contiguous, and the maximum length is lvlttl[22] + ' ' + ZONE + ' ' + INT32, which is about 39 or so - barely crossing into the third column. - char* mapname = G_BuildMapTitle(mapnum+1); + char* mapname = G_BuildMapTitle(headingIterate+1); strcpy(levelselect.rows[row].mapnames[col], (const char *)mapname); Z_Free(mapname); } @@ -5311,9 +5403,9 @@ static boolean M_PrepareLevelPlatter(INT32 gt, boolean nextmappick) char mapname[22+1+11]; // lvlttl[22] + ' ' + INT32 if (actnum) - sprintf(mapname, "%s %d", mapheaderinfo[mapnum]->lvlttl, actnum); + sprintf(mapname, "%s %d", mapheaderinfo[headingIterate]->lvlttl, actnum); else - strcpy(mapname, mapheaderinfo[mapnum]->lvlttl); + strcpy(mapname, mapheaderinfo[headingIterate]->lvlttl); if (strlen(mapname) >= 17) strcpy(mapname+17-3, "..."); @@ -5322,27 +5414,36 @@ static boolean M_PrepareLevelPlatter(INT32 gt, boolean nextmappick) } } else - sprintf(levelselect.rows[row].mapnames[col], "???"); - - // creating header text - if (!col && ((row == startrow) || !(fastcmp(mapheaderinfo[mapnum]->selectheading, mapheaderinfo[levelselect.rows[row-1].maplist[0]-1]->selectheading)))) { - if (!levelselect.rows[row].mapavailable[col]) - sprintf(levelselect.rows[row].header, "???"); - else - { - sprintf(levelselect.rows[row].header, "%s", mapheaderinfo[mapnum]->selectheading); - if (!(mapheaderinfo[mapnum]->levelflags & LF_NOZONE) && headingisname) - { - sprintf(levelselect.rows[row].header + strlen(levelselect.rows[row].header), " ZONE"); - } - } + sprintf(levelselect.rows[row].mapnames[col], "???"); } - prevmapnum = mapnum; + // Done adding this one + mapAddedAlready[headingIterate] = true; + forceNewRow = wide; } - mapnum++; + if (headerRow == -1) + { + // Shouldn't happen + continue; + } + + // creating header text + if (anyAvailable == false) + { + sprintf(levelselect.rows[headerRow].header, "???"); + } + else + { + sprintf(levelselect.rows[headerRow].header, "%s", mapheaderinfo[mapIterate]->selectheading); + + if (!(mapheaderinfo[mapIterate]->levelflags & LF_NOZONE) + && fastcmp(mapheaderinfo[mapIterate]->selectheading, mapheaderinfo[mapIterate]->lvlttl)) + { + sprintf(levelselect.rows[headerRow].header + strlen(levelselect.rows[headerRow].header), " ZONE"); + } + } } #ifdef SYMMETRICAL_PLATTER From aac3ca320bc1f235e36babdae27b0ba2eb23571c Mon Sep 17 00:00:00 2001 From: Tatsuru <44866610+TatsuruIKR@users.noreply.github.com> Date: Sat, 1 May 2021 10:24:28 -0300 Subject: [PATCH 0740/1080] Update LOCATIONSTRING2 as well --- 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 562779d39..13531f1b8 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -6235,7 +6235,7 @@ static void M_AddonsOptions(INT32 choice) } #define LOCATIONSTRING1 "Visit \x83SRB2.ORG/ADDONS\x80 to get & make addons!" -//#define LOCATIONSTRING2 "Visit \x88SRB2.ORG/MODS\x80 to get & make add-ons!" +//#define LOCATIONSTRING2 "Visit \x88SRB2.ORG/ADDONS\x80 to get & make addons!" static void M_LoadAddonsPatches(void) { From ab84bd5370a390fdf048027624c1c2d40a8b2c88 Mon Sep 17 00:00:00 2001 From: GoldenTails Date: Sun, 2 May 2021 00:03:35 -0500 Subject: [PATCH 0741/1080] Fix the console splitting up halfway through startup. --- src/v_video.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/v_video.c b/src/v_video.c index 4713db0d8..2e7d7e4ea 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -455,7 +455,8 @@ void VID_BlitLinearScreen_ASM(const UINT8 *srcptr, UINT8 *destptr, INT32 width, static void CV_constextsize_OnChange(void) { - con_recalc = true; + if (!con_refresh) + con_recalc = true; } From ed5a7f51e877ce1c125fdcda6412661f7a521ba5 Mon Sep 17 00:00:00 2001 From: James R Date: Sun, 2 May 2021 21:32:07 -0700 Subject: [PATCH 0742/1080] Revert "Merge branch 'lightmemedata' into 'next'" This reverts commit d4c08a84101d6d5cd75e550bacda5d9929413b72, reversing changes made to e100f21ddaa46c8b82393baaa32cf84d222af616. --- src/lua_baselib.c | 12 +++--------- src/lua_consolelib.c | 18 ++++++++++++++++-- src/lua_script.c | 21 --------------------- src/lua_script.h | 1 - 4 files changed, 19 insertions(+), 33 deletions(-) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index a59ba546e..a265465da 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -242,16 +242,10 @@ static const char *GetUserdataUType(lua_State *L) // or players[0].powers -> "player_t.powers" static int lib_userdataType(lua_State *L) { - int type; lua_settop(L, 1); // pop everything except arg 1 (in case somebody decided to add more) - type = lua_type(L, 1); - if (type == LUA_TLIGHTUSERDATA || type == LUA_TUSERDATA) - { - lua_pushstring(L, GetUserdataUType(L)); - return 1; - } - else - return luaL_typerror(L, 1, "userdata"); + luaL_checktype(L, 1, LUA_TUSERDATA); + lua_pushstring(L, GetUserdataUType(L)); + return 1; } // Takes a metatable as first and only argument diff --git a/src/lua_consolelib.c b/src/lua_consolelib.c index 5344fee76..10959324e 100644 --- a/src/lua_consolelib.c +++ b/src/lua_consolelib.c @@ -440,8 +440,22 @@ static int lib_cvRegisterVar(lua_State *L) static int lib_cvFindVar(lua_State *L) { - LUA_PushLightUserdata(L, CV_FindVar(luaL_checkstring(L,1)), META_CVAR); - return 1; + consvar_t *cv; + if (( cv = CV_FindVar(luaL_checkstring(L,1)) )) + { + lua_settop(L,1);/* We only want one argument in the stack. */ + lua_pushlightuserdata(L, cv);/* Now the second value on stack. */ + luaL_getmetatable(L, META_CVAR); + /* + The metatable is the last value on the stack, so this + applies it to the second value, which is the cvar. + */ + lua_setmetatable(L,2); + lua_pushvalue(L,2); + return 1; + } + else + return 0; } static int CVarSetFunction diff --git a/src/lua_script.c b/src/lua_script.c index 7fd5a98e6..9f8432832 100644 --- a/src/lua_script.c +++ b/src/lua_script.c @@ -714,27 +714,6 @@ fixed_t LUA_EvalMath(const char *word) return res; } -/* -LUA_PushUserdata but no userdata is created. -You can't invalidate it therefore. -*/ - -void LUA_PushLightUserdata (lua_State *L, void *data, const char *meta) -{ - if (data) - { - lua_pushlightuserdata(L, data); - luaL_getmetatable(L, meta); - /* - The metatable is the last value on the stack, so this - applies it to the second value, which is the userdata. - */ - lua_setmetatable(L, -2); - } - else - lua_pushnil(L); -} - // Takes a pointer, any pointer, and a metatable name // Creates a userdata for that pointer with the given metatable // Pushes it to the stack and stores it in the registry. diff --git a/src/lua_script.h b/src/lua_script.h index 77fbb7c1d..9311a727a 100644 --- a/src/lua_script.h +++ b/src/lua_script.h @@ -87,7 +87,6 @@ typedef enum { LPUSHED_EXISTING, } lpushed_t; -void LUA_PushLightUserdata(lua_State *L, void *data, const char *meta); void LUA_PushUserdata(lua_State *L, void *data, const char *meta); lpushed_t LUA_RawPushUserdata(lua_State *L, void *data); From aee963f4e96191c14f7506cc5a7c7e06e7734fa0 Mon Sep 17 00:00:00 2001 From: James R Date: Sun, 2 May 2021 21:59:23 -0700 Subject: [PATCH 0743/1080] Replace LUA_PushLightUserdata with LUA_PushUserdata See 7df6a309 and 83a87042. I didn't realize that light userdata's metatable is shared--like numbers or strings. So it cannot be paired with a metatable. I also made a few minor tweaks to Lua cvars, other than accounting for the double pointer in the userdata. --- src/command.c | 2 +- src/lua_consolelib.c | 68 +++++++++++--------------------------------- src/lua_script.h | 2 +- src/lua_skinlib.c | 8 +++--- 4 files changed, 23 insertions(+), 57 deletions(-) diff --git a/src/command.c b/src/command.c index 951e3dd09..d73cde5c2 100644 --- a/src/command.c +++ b/src/command.c @@ -1577,7 +1577,7 @@ finish: } var->flags |= CV_MODIFIED; // raise 'on change' code - LUA_CVarChanged(var->name); // let consolelib know what cvar this is. + LUA_CVarChanged(var); // let consolelib know what cvar this is. if (var->flags & CV_CALL && !stealth) var->func(); diff --git a/src/lua_consolelib.c b/src/lua_consolelib.c index 10959324e..a8ef6b7c0 100644 --- a/src/lua_consolelib.c +++ b/src/lua_consolelib.c @@ -28,7 +28,7 @@ return luaL_error(L, "HUD rendering code should not call this function!"); #define NOHOOK if (!lua_lumploading)\ return luaL_error(L, "This function cannot be called from within a hook or coroutine!"); -static const char *cvname = NULL; +static consvar_t *this_cvar; void Got_Luacmd(UINT8 **cp, INT32 playernum) { @@ -273,16 +273,13 @@ static int lib_comBufInsertText(lua_State *L) return 0; } -void LUA_CVarChanged(const char *name) +void LUA_CVarChanged(void *cvar) { - cvname = name; + this_cvar = cvar; } static void Lua_OnChange(void) { - I_Assert(gL != NULL); - I_Assert(cvname != NULL); - /// \todo Network this! XD_LUAVAR lua_pushcfunction(gL, LUA_GetErrorMessage); @@ -291,13 +288,10 @@ static void Lua_OnChange(void) // From CV_OnChange registry field, get the function for this cvar by name. lua_getfield(gL, LUA_REGISTRYINDEX, "CV_OnChange"); I_Assert(lua_istable(gL, -1)); - lua_getfield(gL, -1, cvname); // get function + lua_pushlightuserdata(gL, this_cvar); + lua_rawget(gL, -2); // get function - // From the CV_Vars registry field, get the cvar's userdata by name. - lua_getfield(gL, LUA_REGISTRYINDEX, "CV_Vars"); - I_Assert(lua_istable(gL, -1)); - lua_getfield(gL, -1, cvname); // get consvar_t* userdata. - lua_remove(gL, -2); // pop the CV_Vars table. + LUA_RawPushUserdata(gL, this_cvar); LUA_Call(gL, 1, 0, 1); // call function(cvar) lua_pop(gL, 1); // pop CV_OnChange table @@ -312,15 +306,12 @@ static int lib_cvRegisterVar(lua_State *L) luaL_checktype(L, 1, LUA_TTABLE); lua_settop(L, 1); // Clear out all other possible arguments, leaving only the first one. NOHOOK - cvar = lua_newuserdata(L, sizeof(consvar_t)); - luaL_getmetatable(L, META_CVAR); - lua_setmetatable(L, -2); + cvar = ZZ_Calloc(sizeof(consvar_t)); + LUA_PushUserdata(L, cvar, META_CVAR); #define FIELDERROR(f, e) luaL_error(L, "bad value for " LUA_QL(f) " in table passed to " LUA_QL("CV_RegisterVar") " (%s)", e); #define TYPEERROR(f, t) FIELDERROR(f, va("%s expected, got %s", lua_typename(L, t), luaL_typename(L, -1))) - memset(cvar, 0x00, sizeof(consvar_t)); // zero everything by default - lua_pushnil(L); while (lua_next(L, 1)) { // stack: cvar table, cvar userdata, key/index, value @@ -369,7 +360,7 @@ static int lib_cvRegisterVar(lua_State *L) lua_getfield(L, LUA_REGISTRYINDEX, "CV_PossibleValue"); I_Assert(lua_istable(L, 5)); - lua_pushvalue(L, 2); // cvar userdata + lua_pushlightuserdata(L, cvar); cvpv = lua_newuserdata(L, sizeof(CV_PossibleValue_t) * (count+1)); lua_rawset(L, 5); lua_pop(L, 1); // pop CV_PossibleValue registry table @@ -397,8 +388,9 @@ static int lib_cvRegisterVar(lua_State *L) TYPEERROR("func", LUA_TFUNCTION) lua_getfield(L, LUA_REGISTRYINDEX, "CV_OnChange"); I_Assert(lua_istable(L, 5)); + lua_pushlightuserdata(L, cvar); lua_pushvalue(L, 4); - lua_setfield(L, 5, cvar->name); + lua_rawset(L, 5); lua_pop(L, 1); cvar->func = Lua_OnChange; } @@ -415,19 +407,6 @@ static int lib_cvRegisterVar(lua_State *L) if ((cvar->flags & CV_CALL) && !cvar->func) return luaL_error(L, M_GetText("Variable %s has CV_CALL without a function\n"), cvar->name); - // stack: cvar table, cvar userdata - lua_getfield(L, LUA_REGISTRYINDEX, "CV_Vars"); - I_Assert(lua_istable(L, 3)); - - lua_getfield(L, 3, cvar->name); - if (lua_type(L, -1) != LUA_TNIL) - return luaL_error(L, M_GetText("Variable %s is already defined\n"), cvar->name); - lua_pop(L, 1); - - lua_pushvalue(L, 2); - lua_setfield(L, 3, cvar->name); - lua_pop(L, 1); - // actually time to register it to the console now! Finally! cvar->flags |= CV_MODIFIED; CV_RegisterVar(cvar); @@ -440,22 +419,9 @@ static int lib_cvRegisterVar(lua_State *L) static int lib_cvFindVar(lua_State *L) { - consvar_t *cv; - if (( cv = CV_FindVar(luaL_checkstring(L,1)) )) - { - lua_settop(L,1);/* We only want one argument in the stack. */ - lua_pushlightuserdata(L, cv);/* Now the second value on stack. */ - luaL_getmetatable(L, META_CVAR); - /* - The metatable is the last value on the stack, so this - applies it to the second value, which is the cvar. - */ - lua_setmetatable(L,2); - lua_pushvalue(L,2); - return 1; - } - else - return 0; + const char *name = luaL_checkstring(L, 1); + LUA_PushUserdata(L, CV_FindVar(name), META_CVAR); + return 1; } static int CVarSetFunction @@ -464,7 +430,7 @@ static int CVarSetFunction void (*Set)(consvar_t *, const char *), void (*SetValue)(consvar_t *, INT32) ){ - consvar_t *cvar = (consvar_t *)luaL_checkudata(L, 1, META_CVAR); + consvar_t *cvar = *(consvar_t **)luaL_checkudata(L, 1, META_CVAR); if (cvar->flags & CV_NOLUA) return luaL_error(L, "Variable %s cannot be set from Lua.", cvar->name); @@ -496,7 +462,7 @@ static int lib_cvStealthSet(lua_State *L) static int lib_cvAddValue(lua_State *L) { - consvar_t *cvar = (consvar_t *)luaL_checkudata(L, 1, META_CVAR); + consvar_t *cvar = *(consvar_t **)luaL_checkudata(L, 1, META_CVAR); if (cvar->flags & CV_NOLUA) return luaL_error(L, "Variable %s cannot be set from Lua.", cvar->name); @@ -555,7 +521,7 @@ static luaL_Reg lib[] = { static int cvar_get(lua_State *L) { - consvar_t *cvar = (consvar_t *)luaL_checkudata(L, 1, META_CVAR); + consvar_t *cvar = *(consvar_t **)luaL_checkudata(L, 1, META_CVAR); const char *field = luaL_checkstring(L, 2); if(fastcmp(field,"name")) diff --git a/src/lua_script.h b/src/lua_script.h index 9311a727a..89ba7b6ee 100644 --- a/src/lua_script.h +++ b/src/lua_script.h @@ -56,7 +56,7 @@ void LUA_UnArchive(void); int LUA_PushGlobals(lua_State *L, const char *word); int LUA_CheckGlobals(lua_State *L, const char *word); void Got_Luacmd(UINT8 **cp, INT32 playernum); // lua_consolelib.c -void LUA_CVarChanged(const char *name); // lua_consolelib.c +void LUA_CVarChanged(void *cvar); // lua_consolelib.c int Lua_optoption(lua_State *L, int narg, const char *def, const char *const lst[]); void LUAh_NetArchiveHook(lua_CFunction archFunc); diff --git a/src/lua_skinlib.c b/src/lua_skinlib.c index 56be6bf4f..7e7480be3 100644 --- a/src/lua_skinlib.c +++ b/src/lua_skinlib.c @@ -213,7 +213,7 @@ static int skin_get(lua_State *L) lua_pushinteger(L, skin->availability); break; case skin_sprites: - LUA_PushLightUserdata(L, skin->sprites, META_SKINSPRITES); + LUA_PushUserdata(L, skin->sprites, META_SKINSPRITES); break; } return 1; @@ -336,13 +336,13 @@ static const char *const sprites_opt[] = { // skin.sprites[i] -> sprites[i] static int lib_getSkinSprite(lua_State *L) { - spritedef_t *sprites = (spritedef_t *)luaL_checkudata(L, 1, META_SKINSPRITES); + spritedef_t *sprites = *(spritedef_t **)luaL_checkudata(L, 1, META_SKINSPRITES); playersprite_t i = luaL_checkinteger(L, 2); if (i < 0 || i >= NUMPLAYERSPRITES*2) return luaL_error(L, LUA_QL("skin_t") " field 'sprites' index %d out of range (0 - %d)", i, (NUMPLAYERSPRITES*2)-1); - LUA_PushLightUserdata(L, &sprites[i], META_SKINSPRITESLIST); + LUA_PushUserdata(L, &sprites[i], META_SKINSPRITESLIST); return 1; } @@ -355,7 +355,7 @@ static int lib_numSkinsSprites(lua_State *L) static int sprite_get(lua_State *L) { - spritedef_t *sprite = (spritedef_t *)luaL_checkudata(L, 1, META_SKINSPRITESLIST); + spritedef_t *sprite = *(spritedef_t **)luaL_checkudata(L, 1, META_SKINSPRITESLIST); enum spritesopt field = luaL_checkoption(L, 2, NULL, sprites_opt); switch (field) From 80fe39bbd1433c91131d2cdb36ba709f37d3b5f3 Mon Sep 17 00:00:00 2001 From: Steel Titanium Date: Mon, 3 May 2021 01:40:02 -0400 Subject: [PATCH 0744/1080] Fix MusicChange hook not returning some values correctly --- src/lua_hooklib.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lua_hooklib.c b/src/lua_hooklib.c index 1665e36b0..a3f4a95d2 100644 --- a/src/lua_hooklib.c +++ b/src/lua_hooklib.c @@ -1959,13 +1959,13 @@ boolean LUAh_MusicChange(const char *oldname, char *newname, UINT16 *mflags, boo if (lua_isboolean(gL, -4)) *looping = lua_toboolean(gL, -4); // output 4: position override - if (lua_isboolean(gL, -3)) + if (lua_isnumber(gL, -3)) *position = lua_tonumber(gL, -3); // output 5: prefadems override - if (lua_isboolean(gL, -2)) + if (lua_isnumber(gL, -2)) *prefadems = lua_tonumber(gL, -2); // output 6: fadeinms override - if (lua_isboolean(gL, -1)) + if (lua_isnumber(gL, -1)) *fadeinms = lua_tonumber(gL, -1); lua_pop(gL, 7); // Pop returned values and error handler From 44d217807f71d15bd7ca69dad226458e7060ccab Mon Sep 17 00:00:00 2001 From: James R Date: Sat, 1 May 2021 19:07:44 -0700 Subject: [PATCH 0745/1080] Collect makefiles --- src/{blua/Makefile.cfg => Makefile.d/lua.mk} | 0 src/{sdl/MakeNIX.cfg => Makefile.d/nix.mk} | 0 src/{sdl/Makefile.cfg => Makefile.d/sdl.mk} | 0 src/{Makefile.cfg => Makefile.d/versions.mk} | 0 src/{win32/Makefile.cfg => Makefile.d/win32.mk} | 0 5 files changed, 0 insertions(+), 0 deletions(-) rename src/{blua/Makefile.cfg => Makefile.d/lua.mk} (100%) rename src/{sdl/MakeNIX.cfg => Makefile.d/nix.mk} (100%) rename src/{sdl/Makefile.cfg => Makefile.d/sdl.mk} (100%) rename src/{Makefile.cfg => Makefile.d/versions.mk} (100%) rename src/{win32/Makefile.cfg => Makefile.d/win32.mk} (100%) diff --git a/src/blua/Makefile.cfg b/src/Makefile.d/lua.mk similarity index 100% rename from src/blua/Makefile.cfg rename to src/Makefile.d/lua.mk diff --git a/src/sdl/MakeNIX.cfg b/src/Makefile.d/nix.mk similarity index 100% rename from src/sdl/MakeNIX.cfg rename to src/Makefile.d/nix.mk diff --git a/src/sdl/Makefile.cfg b/src/Makefile.d/sdl.mk similarity index 100% rename from src/sdl/Makefile.cfg rename to src/Makefile.d/sdl.mk diff --git a/src/Makefile.cfg b/src/Makefile.d/versions.mk similarity index 100% rename from src/Makefile.cfg rename to src/Makefile.d/versions.mk diff --git a/src/win32/Makefile.cfg b/src/Makefile.d/win32.mk similarity index 100% rename from src/win32/Makefile.cfg rename to src/Makefile.d/win32.mk From f637e28d0c1877c44acd7b01f7130625d5ea4099 Mon Sep 17 00:00:00 2001 From: James R Date: Tue, 4 May 2021 04:14:00 -0700 Subject: [PATCH 0746/1080] Remove bin, objs and dep directories --- bin/FreeBSD/Debug/.gitignore | 2 -- bin/FreeBSD/Release/.gitignore | 2 -- bin/Linux/Debug/.gitignore | 1 - bin/Linux/Release/.gitignore | 3 --- bin/Linux64/Debug/.gitignore | 1 - bin/Linux64/Release/.gitignore | 1 - bin/Mingw/Debug/.gitignore | 3 --- bin/Mingw/Release/.gitignore | 4 ---- bin/Mingw64/Debug/.gitignore | 3 --- bin/Mingw64/Release/.gitignore | 3 --- bin/SDL/Debug/.gitignore | 2 -- bin/SDL/Release/.gitignore | 2 -- bin/VC/.gitignore | 2 -- bin/VC9/.gitignore | 2 -- bin/dummy/.gitignore | 2 -- dep/.gitignore | 2 -- dep/FreeBSD/SDL/Debug/.gitignore | 2 -- dep/FreeBSD/SDL/Release/.gitignore | 2 -- dep/Linux/SDL/Debug/.gitignore | 2 -- dep/Linux/SDL/Release/.gitignore | 2 -- dep/Linux64/SDL/Debug/.gitignore | 2 -- dep/Linux64/SDL/Release/.gitignore | 2 -- dep/MasterClient/.gitignore | 2 -- dep/MasterServer/.gitignore | 2 -- dep/Mingw/Debug/.gitignore | 2 -- dep/Mingw/Release/.gitignore | 2 -- dep/Mingw/SDL/Debug/.gitignore | 2 -- dep/Mingw/SDL/Release/.gitignore | 2 -- dep/Mingw64/Debug/.gitignore | 2 -- dep/Mingw64/Release/.gitignore | 2 -- dep/Mingw64/SDL/Debug/.gitignore | 2 -- dep/Mingw64/SDL/Release/.gitignore | 2 -- dep/SDL/Release/.gitignore | 2 -- dep/VC/.gitignore | 2 -- dep/VC9/.gitignore | 2 -- dep/cygwin/Debug/.gitignore | 2 -- dep/cygwin/Release/.gitignore | 2 -- dep/dummy/.gitignore | 2 -- objs/.gitignore | 8 -------- objs/FreeBSD/SDL/Debug/.gitignore | 2 -- objs/FreeBSD/SDL/Release/.gitignore | 2 -- objs/Linux/SDL/Debug/.gitignore | 2 -- objs/Linux/SDL/Release/.gitignore | 2 -- objs/Linux64/SDL/Debug/.gitignore | 2 -- objs/Linux64/SDL/Release/.gitignore | 2 -- objs/MasterClient/.gitignore | 2 -- objs/MasterServer/.gitignore | 2 -- objs/Mingw/Debug/.gitignore | 2 -- objs/Mingw/Release/.gitignore | 2 -- objs/Mingw/SDL/Debug/.gitignore | 2 -- objs/Mingw/SDL/Release/.gitignore | 2 -- objs/Mingw64/Debug/.gitignore | 2 -- objs/Mingw64/Release/.gitignore | 2 -- objs/Mingw64/SDL/Debug/.gitignore | 2 -- objs/Mingw64/SDL/Release/.gitignore | 2 -- objs/SDL/Release/.gitignore | 2 -- objs/VC/.gitignore | 2 -- objs/VC9/.gitignore | 2 -- objs/cygwin/Debug/.gitignore | 2 -- objs/cygwin/Release/.gitignore | 2 -- objs/dummy/.gitignore | 2 -- 61 files changed, 131 deletions(-) delete mode 100644 bin/FreeBSD/Debug/.gitignore delete mode 100644 bin/FreeBSD/Release/.gitignore delete mode 100644 bin/Linux/Debug/.gitignore delete mode 100644 bin/Linux/Release/.gitignore delete mode 100644 bin/Linux64/Debug/.gitignore delete mode 100644 bin/Linux64/Release/.gitignore delete mode 100644 bin/Mingw/Debug/.gitignore delete mode 100644 bin/Mingw/Release/.gitignore delete mode 100644 bin/Mingw64/Debug/.gitignore delete mode 100644 bin/Mingw64/Release/.gitignore delete mode 100644 bin/SDL/Debug/.gitignore delete mode 100644 bin/SDL/Release/.gitignore delete mode 100644 bin/VC/.gitignore delete mode 100644 bin/VC9/.gitignore delete mode 100644 bin/dummy/.gitignore delete mode 100644 dep/.gitignore delete mode 100644 dep/FreeBSD/SDL/Debug/.gitignore delete mode 100644 dep/FreeBSD/SDL/Release/.gitignore delete mode 100644 dep/Linux/SDL/Debug/.gitignore delete mode 100644 dep/Linux/SDL/Release/.gitignore delete mode 100644 dep/Linux64/SDL/Debug/.gitignore delete mode 100644 dep/Linux64/SDL/Release/.gitignore delete mode 100644 dep/MasterClient/.gitignore delete mode 100644 dep/MasterServer/.gitignore delete mode 100644 dep/Mingw/Debug/.gitignore delete mode 100644 dep/Mingw/Release/.gitignore delete mode 100644 dep/Mingw/SDL/Debug/.gitignore delete mode 100644 dep/Mingw/SDL/Release/.gitignore delete mode 100644 dep/Mingw64/Debug/.gitignore delete mode 100644 dep/Mingw64/Release/.gitignore delete mode 100644 dep/Mingw64/SDL/Debug/.gitignore delete mode 100644 dep/Mingw64/SDL/Release/.gitignore delete mode 100644 dep/SDL/Release/.gitignore delete mode 100644 dep/VC/.gitignore delete mode 100644 dep/VC9/.gitignore delete mode 100644 dep/cygwin/Debug/.gitignore delete mode 100644 dep/cygwin/Release/.gitignore delete mode 100644 dep/dummy/.gitignore delete mode 100644 objs/.gitignore delete mode 100644 objs/FreeBSD/SDL/Debug/.gitignore delete mode 100644 objs/FreeBSD/SDL/Release/.gitignore delete mode 100644 objs/Linux/SDL/Debug/.gitignore delete mode 100644 objs/Linux/SDL/Release/.gitignore delete mode 100644 objs/Linux64/SDL/Debug/.gitignore delete mode 100644 objs/Linux64/SDL/Release/.gitignore delete mode 100644 objs/MasterClient/.gitignore delete mode 100644 objs/MasterServer/.gitignore delete mode 100644 objs/Mingw/Debug/.gitignore delete mode 100644 objs/Mingw/Release/.gitignore delete mode 100644 objs/Mingw/SDL/Debug/.gitignore delete mode 100644 objs/Mingw/SDL/Release/.gitignore delete mode 100644 objs/Mingw64/Debug/.gitignore delete mode 100644 objs/Mingw64/Release/.gitignore delete mode 100644 objs/Mingw64/SDL/Debug/.gitignore delete mode 100644 objs/Mingw64/SDL/Release/.gitignore delete mode 100644 objs/SDL/Release/.gitignore delete mode 100644 objs/VC/.gitignore delete mode 100644 objs/VC9/.gitignore delete mode 100644 objs/cygwin/Debug/.gitignore delete mode 100644 objs/cygwin/Release/.gitignore delete mode 100644 objs/dummy/.gitignore diff --git a/bin/FreeBSD/Debug/.gitignore b/bin/FreeBSD/Debug/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/bin/FreeBSD/Debug/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/bin/FreeBSD/Release/.gitignore b/bin/FreeBSD/Release/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/bin/FreeBSD/Release/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/bin/Linux/Debug/.gitignore b/bin/Linux/Debug/.gitignore deleted file mode 100644 index 56dee6f95..000000000 --- a/bin/Linux/Debug/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/lsdlsrb2 diff --git a/bin/Linux/Release/.gitignore b/bin/Linux/Release/.gitignore deleted file mode 100644 index 5b5c54a54..000000000 --- a/bin/Linux/Release/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -/lsdlsrb2 -/pnd -/*.mo diff --git a/bin/Linux64/Debug/.gitignore b/bin/Linux64/Debug/.gitignore deleted file mode 100644 index 56dee6f95..000000000 --- a/bin/Linux64/Debug/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/lsdlsrb2 diff --git a/bin/Linux64/Release/.gitignore b/bin/Linux64/Release/.gitignore deleted file mode 100644 index 56dee6f95..000000000 --- a/bin/Linux64/Release/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/lsdlsrb2 diff --git a/bin/Mingw/Debug/.gitignore b/bin/Mingw/Debug/.gitignore deleted file mode 100644 index 834f313e3..000000000 --- a/bin/Mingw/Debug/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -*.exe -*.mo -r_opengl.dll diff --git a/bin/Mingw/Release/.gitignore b/bin/Mingw/Release/.gitignore deleted file mode 100644 index 3458ff764..000000000 --- a/bin/Mingw/Release/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -*.exe -*.mo -r_opengl.dll -*.bat diff --git a/bin/Mingw64/Debug/.gitignore b/bin/Mingw64/Debug/.gitignore deleted file mode 100644 index e431dca5d..000000000 --- a/bin/Mingw64/Debug/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -/srb2sdl.exe -/srb2win.exe -/r_opengl.dll diff --git a/bin/Mingw64/Release/.gitignore b/bin/Mingw64/Release/.gitignore deleted file mode 100644 index e431dca5d..000000000 --- a/bin/Mingw64/Release/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -/srb2sdl.exe -/srb2win.exe -/r_opengl.dll diff --git a/bin/SDL/Debug/.gitignore b/bin/SDL/Debug/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/bin/SDL/Debug/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/bin/SDL/Release/.gitignore b/bin/SDL/Release/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/bin/SDL/Release/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/bin/VC/.gitignore b/bin/VC/.gitignore deleted file mode 100644 index e52f825b2..000000000 --- a/bin/VC/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/Release -/Debug diff --git a/bin/VC9/.gitignore b/bin/VC9/.gitignore deleted file mode 100644 index 205fe45de..000000000 --- a/bin/VC9/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/Win32 -/x64 diff --git a/bin/dummy/.gitignore b/bin/dummy/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/bin/dummy/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/dep/.gitignore b/dep/.gitignore deleted file mode 100644 index fb941664f..000000000 --- a/dep/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -#All folders -*.d diff --git a/dep/FreeBSD/SDL/Debug/.gitignore b/dep/FreeBSD/SDL/Debug/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/dep/FreeBSD/SDL/Debug/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/dep/FreeBSD/SDL/Release/.gitignore b/dep/FreeBSD/SDL/Release/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/dep/FreeBSD/SDL/Release/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/dep/Linux/SDL/Debug/.gitignore b/dep/Linux/SDL/Debug/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/dep/Linux/SDL/Debug/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/dep/Linux/SDL/Release/.gitignore b/dep/Linux/SDL/Release/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/dep/Linux/SDL/Release/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/dep/Linux64/SDL/Debug/.gitignore b/dep/Linux64/SDL/Debug/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/dep/Linux64/SDL/Debug/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/dep/Linux64/SDL/Release/.gitignore b/dep/Linux64/SDL/Release/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/dep/Linux64/SDL/Release/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/dep/MasterClient/.gitignore b/dep/MasterClient/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/dep/MasterClient/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/dep/MasterServer/.gitignore b/dep/MasterServer/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/dep/MasterServer/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/dep/Mingw/Debug/.gitignore b/dep/Mingw/Debug/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/dep/Mingw/Debug/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/dep/Mingw/Release/.gitignore b/dep/Mingw/Release/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/dep/Mingw/Release/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/dep/Mingw/SDL/Debug/.gitignore b/dep/Mingw/SDL/Debug/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/dep/Mingw/SDL/Debug/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/dep/Mingw/SDL/Release/.gitignore b/dep/Mingw/SDL/Release/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/dep/Mingw/SDL/Release/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/dep/Mingw64/Debug/.gitignore b/dep/Mingw64/Debug/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/dep/Mingw64/Debug/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/dep/Mingw64/Release/.gitignore b/dep/Mingw64/Release/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/dep/Mingw64/Release/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/dep/Mingw64/SDL/Debug/.gitignore b/dep/Mingw64/SDL/Debug/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/dep/Mingw64/SDL/Debug/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/dep/Mingw64/SDL/Release/.gitignore b/dep/Mingw64/SDL/Release/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/dep/Mingw64/SDL/Release/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/dep/SDL/Release/.gitignore b/dep/SDL/Release/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/dep/SDL/Release/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/dep/VC/.gitignore b/dep/VC/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/dep/VC/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/dep/VC9/.gitignore b/dep/VC9/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/dep/VC9/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/dep/cygwin/Debug/.gitignore b/dep/cygwin/Debug/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/dep/cygwin/Debug/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/dep/cygwin/Release/.gitignore b/dep/cygwin/Release/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/dep/cygwin/Release/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/dep/dummy/.gitignore b/dep/dummy/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/dep/dummy/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/objs/.gitignore b/objs/.gitignore deleted file mode 100644 index 35ecd6def..000000000 --- a/objs/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -#All folders -SRB2.res -depend.dep -depend.ped -*.o -#VC9 folder only -/VC9/Win32 -/VC9/x64 diff --git a/objs/FreeBSD/SDL/Debug/.gitignore b/objs/FreeBSD/SDL/Debug/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/objs/FreeBSD/SDL/Debug/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/objs/FreeBSD/SDL/Release/.gitignore b/objs/FreeBSD/SDL/Release/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/objs/FreeBSD/SDL/Release/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/objs/Linux/SDL/Debug/.gitignore b/objs/Linux/SDL/Debug/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/objs/Linux/SDL/Debug/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/objs/Linux/SDL/Release/.gitignore b/objs/Linux/SDL/Release/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/objs/Linux/SDL/Release/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/objs/Linux64/SDL/Debug/.gitignore b/objs/Linux64/SDL/Debug/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/objs/Linux64/SDL/Debug/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/objs/Linux64/SDL/Release/.gitignore b/objs/Linux64/SDL/Release/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/objs/Linux64/SDL/Release/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/objs/MasterClient/.gitignore b/objs/MasterClient/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/objs/MasterClient/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/objs/MasterServer/.gitignore b/objs/MasterServer/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/objs/MasterServer/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/objs/Mingw/Debug/.gitignore b/objs/Mingw/Debug/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/objs/Mingw/Debug/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/objs/Mingw/Release/.gitignore b/objs/Mingw/Release/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/objs/Mingw/Release/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/objs/Mingw/SDL/Debug/.gitignore b/objs/Mingw/SDL/Debug/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/objs/Mingw/SDL/Debug/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/objs/Mingw/SDL/Release/.gitignore b/objs/Mingw/SDL/Release/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/objs/Mingw/SDL/Release/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/objs/Mingw64/Debug/.gitignore b/objs/Mingw64/Debug/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/objs/Mingw64/Debug/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/objs/Mingw64/Release/.gitignore b/objs/Mingw64/Release/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/objs/Mingw64/Release/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/objs/Mingw64/SDL/Debug/.gitignore b/objs/Mingw64/SDL/Debug/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/objs/Mingw64/SDL/Debug/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/objs/Mingw64/SDL/Release/.gitignore b/objs/Mingw64/SDL/Release/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/objs/Mingw64/SDL/Release/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/objs/SDL/Release/.gitignore b/objs/SDL/Release/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/objs/SDL/Release/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/objs/VC/.gitignore b/objs/VC/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/objs/VC/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/objs/VC9/.gitignore b/objs/VC9/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/objs/VC9/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/objs/cygwin/Debug/.gitignore b/objs/cygwin/Debug/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/objs/cygwin/Debug/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/objs/cygwin/Release/.gitignore b/objs/cygwin/Release/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/objs/cygwin/Release/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/objs/dummy/.gitignore b/objs/dummy/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/objs/dummy/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing From b31056c7d977fe3c2a5e0637589fd9521f1f6c04 Mon Sep 17 00:00:00 2001 From: James R Date: Sun, 2 May 2021 02:54:51 -0700 Subject: [PATCH 0747/1080] Rewrite Makefile to be modular as well as more automated Some key points for programmers: - Source code files are mostly listed in a 'Sourcefile'. So you no longer directly edit the object list. There can be multiple Sourcefiles and they can even live in subdirectories--the directory name will be prepended to every filename in the list. Of course, the Makefile still needs to be edited to read from each Sourcefile. - Different rules are no longer required for source code files that live in subdirectories (such as sdl/ or hardware/). Subdirectories Just Work so go ham! In addition to those points, another important change is that the bin directory is no longer divided into platform subdirectories (Linux64, Mingw, etc). Executables now go directly into bin. If you use DEBUGMODE or target 64-bit, then subdirectories for 'debug' and '64' will be made though. Oh by the way, I don't think make clean actually removed files before on Windows. It should now. I also fixed as many little inconsistencies like that as I noticed. And now just an overview of the technical aspects that shouldn't affect anyone who doesn't REALLY care about the Makefile... objs and dep directories have been moved to a make directory. Makefile.cfg and its variants have been moved out of their various subdirectories to src/Makefile.d make distclean removes the bin and make directories entirely, but make clean and cleandep still only affect the current build target. When I say automation, I mean that a lot of copy pasting in the Makefile has been reduced. --- .gitignore | 4 +- CMakeLists.txt | 2 +- src/Makefile | 1087 +++++++++++------------------------- src/Makefile.d/detect.mk | 104 ++++ src/Makefile.d/features.mk | 76 +++ src/Makefile.d/lua.mk | 51 -- src/Makefile.d/nix.mk | 94 +--- src/Makefile.d/platform.mk | 67 +++ src/Makefile.d/sdl.mk | 153 +++-- src/Makefile.d/util.mk | 89 +++ src/Makefile.d/versions.mk | 385 ++----------- src/Makefile.d/win32.mk | 187 +++---- src/Sourcefile | 87 +++ src/blua/Sourcefile | 25 + src/hardware/Sourcefile | 13 + src/sdl/Sourcefile | 7 + 16 files changed, 1017 insertions(+), 1414 deletions(-) create mode 100644 src/Makefile.d/detect.mk create mode 100644 src/Makefile.d/features.mk delete mode 100644 src/Makefile.d/lua.mk create mode 100644 src/Makefile.d/platform.mk create mode 100644 src/Makefile.d/util.mk create mode 100644 src/Sourcefile create mode 100644 src/blua/Sourcefile create mode 100644 src/hardware/Sourcefile create mode 100644 src/sdl/Sourcefile diff --git a/.gitignore b/.gitignore index 3090417dd..7023aaa80 100644 --- a/.gitignore +++ b/.gitignore @@ -13,11 +13,11 @@ Win32_LIB_ASM_Release *.dgb *.debug *.debug.txt -/bin/VC10/ -/objs/VC10/ *.user *.db *.opendb /.vs /debian /assets/debian +/make +/bin diff --git a/CMakeLists.txt b/CMakeLists.txt index 5d2d4a7e6..148f17ef0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -119,7 +119,7 @@ set(SRB2_SDL2_EXE_NAME srb2 CACHE STRING "Executable binary output name") include_directories(${CMAKE_CURRENT_BINARY_DIR}/src) add_subdirectory(src) -add_subdirectory(assets) +#add_subdirectory(assets) ## config.h generation diff --git a/src/Makefile b/src/Makefile index cf06ce904..dafec3645 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,817 +1,402 @@ - -# GNU Make makefile for SRB2 -############################################################################# -# Copyright (C) 1998-2000 by DooM Legacy Team. -# Copyright (C) 2003-2021 by Sonic Team Junior. +# GNU Makefile for SRB2 +# the poly3 Makefile adapted over and over... +# +# Copyright 1998-2000 DooM Legacy Team. +# Copyright 2020-2021 James R. +# Copyright 2003-2021 Sonic Team Junior. # # This program is free software distributed under the # terms of the GNU General Public License, version 2. # See the 'LICENSE' file for more details. # -# -DLINUX -> use for the GNU/Linux specific -# -D_WINDOWS -> use for the Win32/DirectX specific -# -DHAVE_SDL -> use for the SDL interface +# Special targets: # -# Sets: -# Compile the SDL/Mingw version with 'make MINGW=1' -# Compile the SDL/Linux version with 'make LINUX=1' -# Compile the SDL/Solaris version with 'make SOLARIS=1' -# Compile the SDL/FreeBSD version with 'gmake FREEBSD=1' -# Compile the SDL/Cygwin version with 'make CYGWIN32=1' -# Compile the SDL/other version try with 'make SDL=1' +# clean - remove executables and objects for this build +# cleandep - remove dependency files for this build +# distclean - remove entire executable, object and +# dependency file directory structure. +# info - print settings # -# 'Targets': -# clean -# Remove all object files -# cleandep -# Remove dependency files -# distclean -# Remove autogenerated files -# dll -# compile primary HW render DLL/SO -# all_dll -# compile all HW render and 3D sound DLLs for the set -# opengl_dll -# Pure Mingw only, compile OpenGL HW render DLL -# ds3d_dll -# Pure Mingw only, compile DirectX DirectSound HW sound DLL -# fmod_dll -# Pure Mingw only, compile FMOD HW sound DLL -# openal_dll -# Pure Mingw only, compile OpenAL HW sound DLL -# fmod_so -# Non-Mingw, compile FMOD HW sound SO -# openal_so -# Non-Mingw, compile OpenAL HW sound SO +# This Makefile can automatically detect the host system +# as well as the compiler version. If system or compiler +# version cannot be detected, you may need to set a flag +# manually. # +# On Windows machines, 32-bit Windows is always targetted. # -# Addon: -# To Cross-Compile, CC=gcc-version make * PREFIX= -# Compile with GCC 2.97 version, add 'GCC29=1' -# Compile with GCC 4.0x version, add 'GCC40=1' -# Compile with GCC 4.1x version, add 'GCC41=1' -# Compile with GCC 4.2x version, add 'GCC42=1' -# Compile with GCC 4.3x version, add 'GCC43=1' -# Compile with GCC 4.4x version, add 'GCC44=1' -# Compile with GCC 4.5x version, add 'GCC45=1' -# Compile with GCC 4.6x version, add 'GCC46=1' -# Compile a profile version, add 'PROFILEMODE=1' -# Compile a debug version, add 'DEBUGMODE=1' -# Compile with less warnings, add 'RELAXWARNINGS=1' -# Generate compiler errors for most compiler warnings, add 'ERRORMODE=1' -# Compile without NASM's tmap.nas, add 'NOASM=1' -# Compile without 3D hardware support, add 'NOHW=1' -# Compile with GDBstubs, add 'RDB=1' -# Compile without PNG, add 'NOPNG=1' -# Compile without zlib, add 'NOZLIB=1' +# Platform/system flags: # -# Addon for SDL: -# To Cross-Compile, add 'SDL_CONFIG=/usr/*/bin/sdl-config' -# Compile without SDL_Mixer, add 'NOMIXER=1' -# Compile without SDL_Mixer_X, add 'NOMIXERX=1' (Win32 only) -# Compile without GME, add 'NOGME=1' -# Compile without BSD API, add 'NONET=1' -# Compile without IPX/SPX, add 'NOIPX=1' -# Compile Mingw/SDL with S_DS3S, add 'DS3D=1' -# Compile without libopenmpt, add 'NOOPENMPT=1' -# Compile with S_FMOD3D, add 'FMOD=1' (WIP) -# Compile with S_OPENAL, add 'OPENAL=1' (WIP) -# To link with the whole SDL_Image lib to load Icons, add 'SDL_IMAGE=1' but it isn't not realy needed -# To link with SDLMain to hide console or make on a console-less binary, add 'SDLMAIN=1' +# LINUX=1, LINUX64=1 +# MINGW=1, MINGW64=1 - Windows (MinGW toolchain) +# UNIX=1 - Generic Unix like system +# FREEBSD=1 +# SDL=1 - Use SDL backend. SDL is the only backend though +# and thus, always enabled. # -############################################################################# +# A list of supported GCC versions can be found in +# Makefile.d/detect.mk -- search 'gcc_versions'. +# +# Feature flags: +# +# Safe to use online +# ------------------ +# NO_IPV6=1 - Disable IPv6 address support. +# NOHW=1 - Disable OpenGL renderer. +# ZDEBUG=1 - Enable more detailed memory debugging +# HAVE_MINIUPNPC=1 - Enable automated port forwarding. +# Already enabled by default for 32-bit +# Windows. +# NOASM=1 - Disable hand optimized assembly code for the +# Software renderer. +# NOPNG=1 - Disable PNG graphics support. (TODO: double +# check netplay compatible.) +# NOCURL=1 - Disable libcurl--HTTP capability. +# NOGME=1 - Disable game music emu, retro VGM support. +# NOOPENMPT=1 - Disable module (tracker) music support. +# NOMIXER=1 - Disable SDL Mixer (audio playback). +# NOMIXERX=1 - Forgo SDL Mixer X--revert to standard SDL +# Mixer. Mixer X is the default for Windows +# builds. +# HAVE_MIXERX=1 - Enable SDL Mixer X. Outside of Windows +# builds, SDL Mixer X is not the default. +# NOTHREADS=1 - Disable multithreading. +# +# Netplay incompatible +# -------------------- +# NONET=1 - Disable online capability. +# NOMD5=1 - Disable MD5 checksum (validation tool). +# NOPOSTPROCESSING=1 - ? +# MOBJCONSISTANCY=1 - ?? +# PACKETDROP=1 - ?? +# DEBUGMODE=1 - Enable various debugging capabilities. +# Also disables optimizations. +# NOZLIB=1 - Disable some compression capability. Implies +# NOPNG=1. +# +# Development flags: +# +# VALGRIND=1 - Enable Valgrind memory debugging support. +# PROFILEMODE=1 - Enable performance profiling (gprof). +# +# General flags for building: +# +# STATIC=1 - Use static linking. +# DISTCC=1 +# CCACHE=1 +# NOOBJDUMP=1 - Don't disassemble executable. +# NOUPX=1 - Don't compress executable. +# WINDOWSHELL=1 - Use Windows commands. +# PREFIX= - Prefix to many commands, for cross compiling. +# YASM=1 - Use Yasm instead of NASM assembler. +# STABS=1 - ? +# ECHO=1 - Print out each command in the build process. +# NOECHOFILENAMES=1 - Don't print out each that is being +# worked on. +# SILENT=1 - Print absolutely nothing except errors. +# RELAXWARNINGS=1 - Use less compiler warnings/errors. +# ERRORMODE=1 - Treat most compiler warnings as errors. +# NOCASTALIGNWARN=1 - ? +# NOLDWARNING=1 - ? +# NOSDLMAIN=1 - ? +# SDLMAIN=1 - ? +# +# Library configuration flags: +# Everything here is an override. +# +# PNG_PKGCONFIG= - libpng-config command. +# PNG_CFLAGS=, PNG_LDFLAGS= +# +# CURLCONFIG= - curl-config command. +# CURL_CFLAGS=, CURL_LDFLAGS= +# +# VALGRIND_PKGCONFIG= - pkg-config package name. +# VALGRIND_CFLAGS=, VALGRIND_LDFLAGS= +# +# LIBGME_PKGCONFIG=, LIBGME_CFLAGS=, LIBGME_LDFLAGS= -,=, +# LIBOPENMPT_PKGCONFIG= +# LIBOPENMPT_CFLAGS=, LIBOPENMPT_LDFLAGS= +# +# ZLIB_PKGCONFIG=, ZLIB_CFLAGS=, ZLIB_LDFLAGS= +# +# SDL_PKGCONFIG= +# SDL_CONFIG= - sdl-config command. +# SDL_CFLAGS=, SDL_LDFLAGS= -ifeq (,$(filter-out cleandep clean distclean,$(or $(MAKECMDGOALS),all))) -CLEANONLY=1 -else ifndef SILENT -echo=@echo "$(1)" -ifndef MAKE_RESTARTS -print=$(info $(1)) -endif -endif +clean_targets=cleandep clean distclean info -ALL_SYSTEMS=\ - PANDORA\ - LINUX64\ - MINGW64\ - HAIKU\ - DUMMY\ - DJGPPDOS\ - MINGW\ - UNIX\ - LINUX\ - SOLARIS\ - FREEBSD\ - MACOSX\ - SDL\ +.PHONY : $(clean_targets) all -# check for user specified system -ifeq (,$(filter $(ALL_SYSTEMS),$(.VARIABLES))) -ifeq ($(OS),Windows_NT) # all windows are Windows_NT... +goals:=$(or $(MAKECMDGOALS),all) +cleanonly:=$(filter $(clean_targets),$(goals)) +destructive:=$(filter-out info,$(cleanonly)) - $(call print,Detected a Windows system$(,) compiling for 32-bit MinGW SDL2...) +include Makefile.d/util.mk - # go for a 32-bit sdl mingw exe by default - MINGW=1 - WINDOWSHELL=1 - -else # if you on the *nix - - system:=$(shell uname -s) - - ifeq ($(system),Linux) - new_system=LINUX - else - - $(error \ - Could not automatically detect your system,\ - try specifying a system manually) - - endif - - ifeq ($(shell getconf LONG_BIT),64) - system+=64-bit - new_system:=$(new_system)64 - endif - - $(call print,Detected $(system) ($(new_system))...) - $(new_system)=1 - -endif -endif - - -# SRB2 data files -D_DIR?=../bin/Resources -D_FILES=$(D_DIR)/srb2.pk3 \ - $(D_DIR)/player.dta \ - $(D_DIR)/zones.pk3 \ - $(D_DIR)/music.dta \ - -PKG_CONFIG?=pkg-config - -ifdef PANDORA -LINUX=1 -endif - -ifdef LINUX64 -LINUX=1 -NONX86=1 -# LINUX64 does not imply X86_64=1; could mean ARM64 or Itanium -endif - -ifdef MINGW64 -MINGW=1 -NONX86=1 -NOASM=1 -# MINGW64 should not necessarily imply X86_64=1, but we make that assumption elsewhere -# Once that changes, remove this -X86_64=1 -endif #ifdef MINGW64 - -ifdef HAIKU -SDL=1 -endif - -include Makefile.cfg - -ifdef DUMMY -NOPNG=1 -NOZLIB=1 -NONET=1 -NOHW=1 -NOASM=1 -NOIPX=1 -EXENAME?=srb2dummy -OBJS=$(OBJDIR)/i_video.o -LIBS=-lm -endif - -ifdef HAIKU -NOIPX=1 -NOASM=1 -ifndef NONET -LIBS=-lnetwork -endif -CFLAGS+=-DUNIXCOMMON -PNG_CFLAGS?= -PNG_LDFLAGS?=-lpng -endif - -ifdef PANDORA -NONX86=1 -NOHW=1 -endif - -ifndef NOOPENMPT -HAVE_OPENMPT=1 -endif - -ifdef MINGW -include win32/Makefile.cfg -endif #ifdef MINGW - -ifdef UNIX -UNIXCOMMON=1 -endif - -ifdef LINUX -UNIXCOMMON=1 -ifndef NOGME -HAVE_LIBGME=1 -endif -endif - -ifdef SOLARIS -UNIXCOMMON=1 -endif - -ifdef FREEBSD -UNIXCOMMON=1 -endif - -ifdef MACOSX -UNIXCOMMON=1 -endif - -ifdef SDL - include sdl/Makefile.cfg -endif #ifdef SDL - -ifdef DISTCC - CC:=distcc $(CC) -endif - -ifdef CCACHE - CC:=ccache $(CC) -endif - -MSGFMT?=msgfmt - -ifdef WINDOWSHELL - COMPTIME=-..\comptime.bat -else - COMPTIME=-../comptime.sh -endif - -ifndef ECHO - NASM:=@$(NASM) - REMOVE:=@$(REMOVE) - CC:=@$(CC) - CXX:=@$(CXX) - OBJCOPY:=@$(OBJCOPY) - OBJDUMP:=@$(OBJDUMP) - STRIP:=@$(STRIP) - WINDRES:=@$(WINDRES) - MKDIR:=@$(MKDIR) - GZIP:=@$(GZIP) - MSGFMT:=@$(MSGFMT) - UPX:=@$(UPX) - UPX_OPTS+=-q - COMPTIME:=@$(COMPTIME) -endif - -ifdef NONET - OPTS+=-DNONET - NOCURL=1 -else -ifdef NO_IPV6 - OPTS+=-DNO_IPV6 -endif -endif - -ifdef NOHW - OPTS+=-DNOHW -else - OPTS+=-DHWRENDER - OBJS+=$(OBJDIR)/hw_bsp.o $(OBJDIR)/hw_draw.o $(OBJDIR)/hw_light.o \ - $(OBJDIR)/hw_main.o $(OBJDIR)/hw_clip.o $(OBJDIR)/hw_md2.o $(OBJDIR)/hw_cache.o \ - $(OBJDIR)/hw_md2load.o $(OBJDIR)/hw_md3load.o $(OBJDIR)/hw_model.o $(OBJDIR)/u_list.o $(OBJDIR)/hw_batching.o -endif - -OPTS += -DCOMPVERSION - -ifndef NONX86 -ifndef GCC29 - ARCHOPTS?=-msse3 -mfpmath=sse -else - ARCHOPTS?=-mpentium -endif -else -ifdef X86_64 - ARCHOPTS?=-march=nocona -endif -endif - -ifndef NOASM -ifndef NONX86 - OBJS+=$(OBJDIR)/tmap.o $(OBJDIR)/tmap_mmx.o - OPTS+=-DUSEASM -endif -endif - -ifndef NOPNG -OPTS+=-DHAVE_PNG - -ifdef PNG_PKGCONFIG -PNG_CFLAGS?=$(shell $(PKG_CONFIG) $(PNG_PKGCONFIG) --cflags) -PNG_LDFLAGS?=$(shell $(PKG_CONFIG) $(PNG_PKGCONFIG) --libs) -else ifdef PREFIX -PNG_CONFIG?=$(PREFIX)-libpng-config +CC:=$(PREFIX)-gcc +endif + +OBJDUMP_OPTS?=--wide --source --line-numbers + +OBJCOPY:=$(call Prefix,objcopy) +OBJDUMP:=$(call Prefix,objdump) $(OBJDUMP_OPTS) +WINDRES:=$(call Prefix,windres) + +ifdef YASM +NASM?=yasm else -PNG_CONFIG?=libpng-config +NASM?=nasm endif -ifdef PNG_STATIC -PNG_CFLAGS?=$(shell $(PNG_CONFIG) --static --cflags) -PNG_LDFLAGS?=$(shell $(PNG_CONFIG) --static --ldflags) -else -PNG_CFLAGS?=$(shell $(PNG_CONFIG) --cflags) -PNG_LDFLAGS?=$(shell $(PNG_CONFIG) --ldflags) -endif -endif - -ifdef LINUX -PNG_CFLAGS+=-D_LARGEFILE64_SOURCE -endif - -LIBS+=$(PNG_LDFLAGS) -CFLAGS+=$(PNG_CFLAGS) - -OBJS+=$(OBJDIR)/apng.o -endif - -ifdef HAVE_LIBGME -OPTS+=-DHAVE_LIBGME - -LIBGME_PKGCONFIG?=libgme -LIBGME_CFLAGS?=$(shell $(PKG_CONFIG) $(LIBGME_PKGCONFIG) --cflags) -LIBGME_LDFLAGS?=$(shell $(PKG_CONFIG) $(LIBGME_PKGCONFIG) --libs) - -LIBS+=$(LIBGME_LDFLAGS) -CFLAGS+=$(LIBGME_CFLAGS) -endif - -ifdef HAVE_OPENMPT -OPTS+=-DHAVE_OPENMPT - -LIBOPENMPT_PKGCONFIG?=libopenmpt -LIBOPENMPT_CFLAGS?=$(shell $(PKG_CONFIG) $(LIBOPENMPT_PKGCONFIG) --cflags) -LIBOPENMPT_LDFLAGS?=$(shell $(PKG_CONFIG) $(LIBOPENMPT_PKGCONFIG) --libs) - -LIBS+=$(LIBOPENMPT_LDFLAGS) -CFLAGS+=$(LIBOPENMPT_CFLAGS) -endif - -ifndef NOZLIB -OPTS+=-DHAVE_ZLIB -ZLIB_PKGCONFIG?=zlib -ZLIB_CFLAGS?=$(shell $(PKG_CONFIG) $(ZLIB_PKGCONFIG) --cflags) -ZLIB_LDFLAGS?=$(shell $(PKG_CONFIG) $(ZLIB_PKGCONFIG) --libs) - -LIBS+=$(ZLIB_LDFLAGS) -CFLAGS+=$(ZLIB_CFLAGS) -else -NOPNG=1 -endif - -ifndef NOCURL -OPTS+=-DHAVE_CURL -CURLCONFIG?=curl-config -CURL_CFLAGS?=$(shell $(CURLCONFIG) --cflags) -CURL_LDFLAGS?=$(shell $(CURLCONFIG) --libs) - -LIBS+=$(CURL_LDFLAGS) -CFLAGS+=$(CURL_CFLAGS) -endif - -ifdef STATIC -LIBS:=-static $(LIBS) -endif - -ifdef HAVE_MINIUPNPC -ifdef NONET -HAVE_MINIUPNPC='' -else -LIBS+=-lminiupnpc -ifdef MINGW -LIBS+=-lws2_32 -liphlpapi -endif -CFLAGS+=-DHAVE_MINIUPNPC -endif -endif - -include blua/Makefile.cfg - -ifdef NOMD5 - OPTS+=-DNOMD5 -else - OBJS:=$(OBJDIR)/md5.o $(OBJS) -endif - -ifdef NOPOSTPROCESSING - OPTS+=-DNOPOSTPROCESSING -endif - - OPTS:=-fno-exceptions $(OPTS) - -ifdef MOBJCONSISTANCY - OPTS+=-DMOBJCONSISTANCY -endif - -ifdef PACKETDROP - OPTS+=-DPACKETDROP -endif - -ifdef DEBUGMODE - - # build with debugging information - WINDRESFLAGS = -D_DEBUG -ifdef GCC48 - CFLAGS+=-Og -else - CFLAGS+=-O0 -endif - CFLAGS+= -Wall -DPARANOIA -DRANGECHECK -DPACKETDROP -DMOBJCONSISTANCY -else - - - # build a normal optimised version - WINDRESFLAGS = -DNDEBUG - CFLAGS+=-O3 -endif - CFLAGS+=-g $(OPTS) $(ARCHOPTS) $(WINDRESFLAGS) - ifdef YASM ifdef STABS - NASMOPTS?= -g stabs +NASMOPTS?=-g stabs else - NASMOPTS?= -g dwarf2 +NASMOPTS?=-g dwarf2 endif else - NASMOPTS?= -g +NASMOPTS?=-g endif -ifdef PROFILEMODE - # build with profiling information - CFLAGS+=-pg - LDFLAGS+=-pg +GZIP?=gzip +GZIP_OPTS?=-9 -f -n +ifdef WINDOWSHELL +GZIP_OPTS+=--rsyncable endif -ifdef ZDEBUG - CPPFLAGS+=-DZDEBUG +UPX?=upx +UPX_OPTS?=--best --preserve-build-id +ifndef ECHO +UPX_OPTS+=-qq endif -OPTS+=$(CPPFLAGS) +include Makefile.d/detect.mk -# default EXENAME if all else fails +# make would try to remove the implicitly made directories +.PRECIOUS : %/ comptime.c + +# very sophisticated dependency +sources:=\ + $(call List,Sourcefile)\ + $(call List,blua/Sourcefile)\ + +makedir:=../make + +# -DCOMPVERSION: flag to use comptime.h +opts:=-DCOMPVERSION -g +libs:= + +nasm_format:= + +# This is a list of variables names, of which if defined, +# also defines the name as a macro to the compiler. +passthru_opts:= + +include Makefile.d/platform.mk +include Makefile.d/features.mk +include Makefile.d/versions.mk + +ifdef DEBUGMODE +makedir:=$(makedir)/debug +endif + +depdir:=$(makedir)/deps +objdir:=$(makedir)/objs + +depends:=$(basename $(filter %.c %.s,$(sources))) +objects:=$(basename $(filter %.c %.s %.nas,$(sources))) + +depends:=$(depends:%=$(depdir)/%.d) + +# comptime.o added directly to objects instead of thru +# sources because comptime.c includes comptime.h, but +# comptime.h may not exist yet. It's a headache so this is +# easier. +objects:=$(objects:=.o) comptime.o + +# windows resource file +rc_file:=$(basename $(filter %.rc,$(sources))) +ifdef rc_file +objects+=$(rc_file:=.res) +endif + +objects:=$(addprefix $(objdir)/,$(objects)) + +ifdef DEBUGMODE +bin:=../bin/debug +else +bin:=../bin +endif + +# default EXENAME (usually set by platform) EXENAME?=srb2 DBGNAME?=$(EXENAME).debug -# $(OBJDIR)/dstrings.o \ +exe:=$(bin)/$(EXENAME) +dbg:=$(bin)/$(DBGNAME) -# not too sophisticated dependency -OBJS:=$(i_main_o) \ - $(OBJDIR)/string.o \ - $(OBJDIR)/d_main.o \ - $(OBJDIR)/d_clisrv.o \ - $(OBJDIR)/d_net.o \ - $(OBJDIR)/d_netfil.o \ - $(OBJDIR)/d_netcmd.o \ - $(OBJDIR)/dehacked.o \ - $(OBJDIR)/z_zone.o \ - $(OBJDIR)/f_finale.o \ - $(OBJDIR)/f_wipe.o \ - $(OBJDIR)/g_demo.o \ - $(OBJDIR)/g_game.o \ - $(OBJDIR)/g_input.o \ - $(OBJDIR)/am_map.o \ - $(OBJDIR)/command.o \ - $(OBJDIR)/console.o \ - $(OBJDIR)/hu_stuff.o \ - $(OBJDIR)/y_inter.o \ - $(OBJDIR)/st_stuff.o \ - $(OBJDIR)/m_aatree.o \ - $(OBJDIR)/m_anigif.o \ - $(OBJDIR)/m_argv.o \ - $(OBJDIR)/m_bbox.o \ - $(OBJDIR)/m_cheat.o \ - $(OBJDIR)/m_cond.o \ - $(OBJDIR)/m_fixed.o \ - $(OBJDIR)/m_menu.o \ - $(OBJDIR)/m_misc.o \ - $(OBJDIR)/m_random.o \ - $(OBJDIR)/m_queue.o \ - $(OBJDIR)/info.o \ - $(OBJDIR)/p_ceilng.o \ - $(OBJDIR)/p_enemy.o \ - $(OBJDIR)/p_floor.o \ - $(OBJDIR)/p_inter.o \ - $(OBJDIR)/p_lights.o \ - $(OBJDIR)/p_map.o \ - $(OBJDIR)/p_maputl.o \ - $(OBJDIR)/p_mobj.o \ - $(OBJDIR)/p_polyobj.o\ - $(OBJDIR)/p_saveg.o \ - $(OBJDIR)/p_setup.o \ - $(OBJDIR)/p_sight.o \ - $(OBJDIR)/p_spec.o \ - $(OBJDIR)/p_telept.o \ - $(OBJDIR)/p_tick.o \ - $(OBJDIR)/p_user.o \ - $(OBJDIR)/p_slopes.o \ - $(OBJDIR)/tables.o \ - $(OBJDIR)/r_bsp.o \ - $(OBJDIR)/r_data.o \ - $(OBJDIR)/r_draw.o \ - $(OBJDIR)/r_main.o \ - $(OBJDIR)/r_plane.o \ - $(OBJDIR)/r_segs.o \ - $(OBJDIR)/r_skins.o \ - $(OBJDIR)/r_sky.o \ - $(OBJDIR)/r_splats.o \ - $(OBJDIR)/r_things.o \ - $(OBJDIR)/r_textures.o \ - $(OBJDIR)/r_picformats.o \ - $(OBJDIR)/r_portal.o \ - $(OBJDIR)/screen.o \ - $(OBJDIR)/v_video.o \ - $(OBJDIR)/s_sound.o \ - $(OBJDIR)/sounds.o \ - $(OBJDIR)/w_wad.o \ - $(OBJDIR)/filesrch.o \ - $(OBJDIR)/mserv.o \ - $(OBJDIR)/http-mserv.o\ - $(OBJDIR)/i_tcp.o \ - $(OBJDIR)/lzf.o \ - $(OBJDIR)/vid_copy.o \ - $(OBJDIR)/b_bot.o \ - $(i_net_o) \ - $(i_system_o) \ - $(i_sound_o) \ - $(OBJS) +build_done=Build is done, please look for $( srb2.s - $(REMOVE) $(OBJDIR)/tmp.exe - -# executable -# NOTE: DJGPP's objcopy do not have --add-gnu-debuglink - -$(BIN)/$(EXENAME): $(POS) $(OBJS) - -$(MKDIR) $(BIN) - $(call echo,Linking $(EXENAME)...) - $(LD) $(LDFLAGS) $(OBJS) -o $(BIN)/$(EXENAME) $(LIBS) ifndef VALGRIND ifndef NOOBJDUMP - $(call echo,Dumping debugging info) - $(OBJDUMP) $(OBJDUMP_OPTS) $(BIN)/$(EXENAME) > $(BIN)/$(DBGNAME).txt -ifdef WINDOWSHELL - -$(GZIP) $(GZIP_OPTS) $(BIN)/$(DBGNAME).txt -else - -$(GZIP) $(GZIP_OPT2) $(BIN)/$(DBGNAME).txt +all : $(dbg).txt endif endif -# mac os x lsdlsrb2 does not like objcopy -ifndef MACOSX - $(OBJCOPY) $(BIN)/$(EXENAME) $(BIN)/$(DBGNAME) - $(OBJCOPY) --strip-debug $(BIN)/$(EXENAME) - -$(OBJCOPY) --add-gnu-debuglink=$(BIN)/$(DBGNAME) $(BIN)/$(EXENAME) +ifdef STATIC +libs+=-static endif + +# build with profiling information +ifdef PROFILEMODE +opts+=-pg +libs+=-pg +endif + +ifdef DEBUGMODE +debug_opts=-D_DEBUG +else # build a normal optimized version +debug_opts=-DNDEBUG +opts+=-O3 +endif + +# debug_opts also get passed to windres +opts+=$(debug_opts) + +opts+=$(foreach v,$(passthru_opts),$(if $($(v)),-D$(v))) + +CFLAGS:=$(opts) $(WFLAGS) $(CPPFLAGS) $(CFLAGS) +LDFLAGS:=$(libs) $(LDFLAGS) +ASFLAGS+=-x assembler-with-cpp + +ifdef DISTCC +CC:=distcc $(CC) +endif + +ifdef CCACHE +CC:=ccache $(CC) +endif + +ifndef SILENT +# makefile will 'restart' when it finishes including the +# dependencies. +ifndef MAKE_RESTARTS +ifndef destrutive +$(shell $(CC) -v) +define flags = + +CC ........ $(CC) + +CFLAGS .... $(CFLAGS) + +LDFLAGS ... $(LDFLAGS) + +endef +$(info $(flags)) +endif +# don't generate dependency files if only cleaning +ifndef cleanonly +$(info Checking dependency files...) +include $(depends) +endif +endif +endif + +LD:=$(CC) +CC:=$(CC) $(CFLAGS) +NASM:=$(NASM) $(NASMOPTS) -f $(nasm_format) +GZIP:=$(GZIP) $(GZIP_OPTS) +UPX:=$(UPX) $(UPX_OPTS) +WINDRES:=$(WINDRES) $(WINDRESFLAGS)\ + $(debug_opts) --include-dir=win32 -O coff + +%/ : + $(.)$(mkdir) $@ + +# this is needed so the target can be referenced in the +# prerequisites +.SECONDEXPANSION : + +# executable stripped of debugging symbols +$(exe) : $(dbg) | $$(@D)/ + $(.)$(OBJCOPY) --strip-debug $< $@ + $(.)-$(OBJCOPY) --add-gnu-debuglink=$< $@ ifndef NOUPX - -$(UPX) $(UPX_OPTS) $(BIN)/$(EXENAME) + $(call Echo,Compressing final executable...) + $(.)-$(UPX) $@ endif -endif - $(call echo,Build is done$(,) please look for $(EXENAME) in $(BIN)$(,) (checking for post steps)) -reobjdump: - $(call echo,Redumping debugging info) - $(OBJDUMP) $(OBJDUMP_OPTS) $(BIN)/$(DBGNAME) > $(BIN)/$(DBGNAME).txt +# original executable with debugging symbols +$(dbg) : $(objects) | $$(@D)/ + $(call Echo,Linking $(@F)...) + $(.)$(LD) -o $@ $^ $(LDFLAGS) + +# disassembly of executable +$(dbg).txt : $(dbg) + $(call Echo,Dumping debugging info...) + $(.)$(OBJDUMP) $< > $@ + $(.)$(GZIP) $@ + +# '::' means run unconditionally +# this really updates comptime.h +comptime.c :: ifdef WINDOWSHELL - -$(GZIP) $(GZIP_OPTS) $(BIN)/$(DBGNAME).txt + $(.)..\comptime.bat . else - -$(GZIP) $(GZIP_OPT2) $(BIN)/$(DBGNAME).txt + $(.)../comptime.sh . endif -$(OBJDIR): - -$(MKDIR) $(OBJDIR) +# I wish I could make dependencies out of rc files :( +$(objdir)/win32/Srb2win.res : \ + win32/afxres.h win32/resource.h -ifdef SDL -ifdef MINGW -$(OBJDIR)/r_opengl.o: hardware/r_opengl/r_opengl.c hardware/r_opengl/r_opengl.h \ - doomdef.h doomtype.h g_state.h m_swap.h hardware/hw_drv.h screen.h \ - command.h hardware/hw_data.h hardware/hw_defs.h \ - hardware/hw_md2.h hardware/hw_glob.h hardware/hw_main.h hardware/hw_clip.h \ - hardware/hw_md2load.h hardware/hw_md3load.h hardware/hw_model.h hardware/u_list.h \ - am_map.h d_event.h d_player.h p_pspr.h m_fixed.h tables.h info.h d_think.h \ - p_mobj.h doomdata.h d_ticcmd.h r_defs.h hardware/hw_dll.h - $(echoName) - $(CC) $(CFLAGS) $(WFLAGS) -c $< -o $@ -else -$(OBJDIR)/r_opengl.o: hardware/r_opengl/r_opengl.c hardware/r_opengl/r_opengl.h \ - doomdef.h doomtype.h g_state.h m_swap.h hardware/hw_drv.h screen.h \ - command.h hardware/hw_data.h hardware/hw_defs.h \ - hardware/hw_md2.h hardware/hw_glob.h hardware/hw_main.h hardware/hw_clip.h \ - hardware/hw_md2load.h hardware/hw_md3load.h hardware/hw_model.h hardware/u_list.h \ - am_map.h d_event.h d_player.h p_pspr.h m_fixed.h tables.h info.h d_think.h \ - p_mobj.h doomdata.h d_ticcmd.h r_defs.h hardware/hw_dll.h - $(echoName) - $(CC) $(CFLAGS) $(WFLAGS) -I/usr/X11R6/include -c $< -o $@ -endif -endif - -#dependecy made by gcc itself ! -ifndef DUMMY -ifndef CLEANONLY -$(call print,Checking dependency files...) --include $(DEPS) -endif -endif - -undefine deps_rule - -# windows makes it too hard ! +# dependency recipe template +# 1: source file suffix +# 2: extra flags to gcc +define _recipe = +$(depdir)/%.d : %.$(1) | $$$$(@D)/ ifndef WINDOWSHELL -ifdef echoName -define deps_rule = - @printf "%-20.20s\r" $< - -endef +ifdef Echo_name + @printf '%-20.20s\r' $$< endif endif - -define deps_rule += - $(CC) $(CFLAGS) -M -MF $@ -MT $(OBJDIR)/$(<:.c=.o) $< + $(.)$(CC) -MM -MF $$@ -MT $(objdir)/$$(*F).o $(2) $$< endef -$(DEPDIR)/%.d: %.c - $(deps_rule) +$(eval $(call _recipe,c)) +$(eval $(call _recipe,s,$(ASFLAGS))) -$(DEPDIR)/%.d: $(INTERFACE)/%.c - $(deps_rule) +# compiling recipe template +# 1: target file suffix +# 2: source file suffix +# 3: compile command +define _recipe = +$(objdir)/%.$(1) : %.$(2) | $$$$(@D)/ + $(call Echo_name,$$<) + $(.)$(3) +endef -$(DEPDIR)/%.d: hardware/%.c - $(deps_rule) +$(eval $(call _recipe,o,c,$(CC) -c -o $$@ $$<)) +$(eval $(call _recipe,o,nas,$(NASM) -o $$@ $$<)) +$(eval $(call _recipe,o,s,$(CC) $(ASFLAGS) -c -o $$@ $$<)) +$(eval $(call _recipe,res,rc,$(WINDRES) -i $$< -o $$@)) -$(DEPDIR)/%.d: blua/%.c - $(deps_rule) +cleandep : + $(.)$(rmrf) $(depends) comptime.h -ifdef VALGRIND -$(OBJDIR)/z_zone.o: z_zone.c - $(echoName) - $(CC) $(CFLAGS) $(WFLAGS) -DHAVE_VALGRIND $(VALGRIND_CFLAGS) -c $< -o $@ -endif +clean : + $(.)$(rmrf) $(exe) $(dbg) $(dbg).txt $(objects) -$(OBJDIR)/comptime.o:: -ifdef echoName - @echo -- comptime.c ... -endif - $(COMPTIME) . - $(CC) $(CFLAGS) $(WFLAGS) -c comptime.c -o $@ +distclean : + $(.)$(rmrf) ../bin ../objs ../deps comptime.h -$(BIN)/%.mo: locale/%.po - -$(MKDIR) $(BIN) - $(echoName) - $(MSGFMT) -f -o $@ $< - -$(OBJDIR)/%.o: %.c - $(echoName) - $(CC) $(CFLAGS) $(WFLAGS) -c $< -o $@ - -$(OBJDIR)/%.o: $(INTERFACE)/%.c - $(echoName) - $(CC) $(CFLAGS) $(WFLAGS) -c $< -o $@ - -ifdef MACOSX -$(OBJDIR)/%.o: sdl/macosx/%.c - $(echoName) - $(CC) $(CFLAGS) $(WFLAGS) -c $< -o $@ -endif - -$(OBJDIR)/%.o: hardware/%.c - $(echoName) - $(CC) $(CFLAGS) $(WFLAGS) -c $< -o $@ - -$(OBJDIR)/%.o: blua/%.c - $(echoName) - $(CC) $(CFLAGS) $(LUA_CFLAGS) $(WFLAGS) -c $< -o $@ - -$(OBJDIR)/%.o: %.nas - $(echoName) - $(NASM) $(NASMOPTS) -o $@ -f $(NASMFORMAT) $< - -$(OBJDIR)/vid_copy.o: vid_copy.s asm_defs.inc - $(echoName) - $(CC) $(OPTS) $(ASFLAGS) -x assembler-with-cpp -c $< -o $@ - -$(OBJDIR)/%.o: %.s - $(echoName) - $(CC) $(OPTS) -x assembler-with-cpp -c $< -o $@ - -$(OBJDIR)/SRB2.res: win32/Srb2win.rc win32/afxres.h win32/resource.h - $(echoName) - $(WINDRES) -i $< -O rc $(WINDRESFLAGS) --include-dir=win32 -o $@ -O coff - - -ifdef SDL - -ifdef MINGW -$(OBJDIR)/win_dbg.o: win32/win_dbg.c - $(echoName) - $(CC) $(CFLAGS) $(WFLAGS) -c $< -o $@ -endif - -ifdef STATICHS -$(OBJDIR)/s_openal.o: hardware/s_openal/s_openal.c hardware/hw3dsdrv.h \ - hardware/hw_dll.h - $(echoName) - $(CC) $(CFLAGS) $(WFLAGS) -c $< -o $@ - -$(OBJDIR)/s_fmod.o: hardware/s_fmod/s_fmod.c hardware/hw3dsdrv.h \ - hardware/hw_dll.h - $(echoName) - $(CC) $(CFLAGS) $(WFLAGS) -c $< -o $@ - -ifdef MINGW -$(OBJDIR)/s_ds3d.o: hardware/s_ds3d/s_ds3d.c hardware/hw3dsdrv.h \ - hardware/hw_dll.h - $(echoName) - $(CC) $(CFLAGS) $(WFLAGS) -c $< -o $@ -endif +info: +ifdef WINDOWSHELL + @REM else - -$(OBJDIR)/s_fmod.o: hardware/s_fmod/s_fmod.c hardware/hw3dsdrv.h \ - hardware/hw_dll.h - $(echoName) - $(CC) $(ARCHOPTS) -Os -o $(OBJDIR)/s_fmod.o -DHW3SOUND -DUNIXCOMMON -shared -nostartfiles -c hardware/s_fmod/s_fmod.c - -$(OBJDIR)/s_openal.o: hardware/s_openal/s_openal.c hardware/hw3dsdrv.h \ - hardware/hw_dll.h - $(echoName) - $(CC) $(ARCHOPTS) -Os -o $(OBJDIR)/s_openal.o -DHW3SOUND -DUNIXCOMMON -shared -nostartfiles -c hardware/s_openal/s_openal.c + @: endif -endif - -############################################################# -# -############################################################# diff --git a/src/Makefile.d/detect.mk b/src/Makefile.d/detect.mk new file mode 100644 index 000000000..f576bcf78 --- /dev/null +++ b/src/Makefile.d/detect.mk @@ -0,0 +1,104 @@ +# +# Detect the host system and compiler version. +# + +# Previously featured:\ + PANDORA\ + HAIKU\ + DUMMY\ + DJGPPDOS\ + SOLARIS\ + MACOSX\ + +all_systems:=\ + LINUX64\ + MINGW64\ + MINGW\ + UNIX\ + LINUX\ + FREEBSD\ + SDL\ + +# check for user specified system +ifeq (,$(filter $(all_systems),$(.VARIABLES))) +ifeq ($(OS),Windows_NT) # all windows are Windows_NT... + +_m=Detected a Windows system,\ + compiling for 32-bit MinGW SDL...) +$(call Print,$(_m)) + +# go for a 32-bit sdl mingw exe by default +MINGW:=1 +WINDOWSHELL:=1 + +else # if you on the *nix + +system:=$(shell uname -s) + +ifeq ($(system),Linux) +new_system:=LINUX +else + +$(error \ + Could not automatically detect your system,\ + try specifying a system manually) + +endif + +ifeq ($(shell getconf LONG_BIT),64) +system+=64-bit +new_system:=$(new_system)64 +endif + +$(call Print,Detected $(system) ($(new_system))...) +$(new_system):=1 + +endif +endif + +# This must have high to low order. +gcc_versions:=\ + 102 101\ + 93 92 91\ + 84 83 82 81\ + 75 74 73 72 71\ + 64 63 62 61\ + 55 54 53 52 51\ + 49 48 47 46 45 44 43 42 41 40 + +latest_gcc_version:=10.2 + +# Automatically set version flag, but not if one was +# manually set. And don't bother if this is a clean only +# run. +ifeq (,$(call Wildvar,GCC% destructive)) +version:=$(shell $(CC) --version) + +# check if this is in fact GCC +ifneq (,$(or $(findstring gcc,$(version)),\ + $(findstring GCC,$(version)))) + +version:=$(shell $(CC) -dumpversion) + +# Turn version into words of major, minor +v:=$(subst ., ,$(version)) +# concat. major minor +v:=$(word 1,$(v))$(word 2,$(v)) + +# If this version is not in the list, +# default to the latest supported +ifeq (,$(filter $(v),$(gcc_versions))) +define line = +Your compiler version, GCC $(version), \ +is not supported by the Makefile. +The Makefile will assume GCC $(latest_gcc_version).)) +endef +$(call Print,$(line)) +GCC$(subst .,,$(latest_gcc_version)):=1 +else +$(call Print,Detected GCC $(version) (GCC$(v))) +GCC$(v):=1 +endif + +endif +endif diff --git a/src/Makefile.d/features.mk b/src/Makefile.d/features.mk new file mode 100644 index 000000000..abdc342b7 --- /dev/null +++ b/src/Makefile.d/features.mk @@ -0,0 +1,76 @@ +# +# Makefile for feature flags. +# + +passthru_opts+=\ + NONET NO_IPV6 NOHW NOMD5 NOPOSTPROCESSING\ + MOBJCONSISTANCY PACKETDROP ZDEBUG\ + HAVE_MINIUPNPC\ + +# build with debugging information +ifdef DEBUGMODE +MOBJCONSISTANCY=1 +PACKETDROP=1 +opts+=-DPARANOIA -DRANGECHECK +endif + +ifndef NOHW +opts+=-DHWRENDER +sources+=$(call List,hardware/Sourcefile) +endif + +ifndef NOASM +ifndef NONX86 +sources+=tmap.nas tmap_mmx.nas +opts+=-DUSEASM +endif +endif + +ifndef NOMD5 +sources+=md5.c +endif + +ifndef NOZLIB +ifndef NOPNG +ifdef PNG_PKGCONFIG +$(eval $(call Use_pkg_config,PNG_PKGCONFIG)) +else +PNG_CONFIG?=$(call Prefix,libpng-config) +$(eval $(call Configure,PNG,$(PNG_CONFIG) \ + $(if $(PNG_STATIC),--static),,--ldflags)) +endif +ifdef LINUX +opts+=-D_LARGFILE64_SOURCE +endif +opts+=-DHAVE_PNG +sources+=apng.c +endif +endif + +ifndef NONET +ifndef NOCURL +CURLCONFIG?=curl-config +$(eval $(call Configure,CURL,$(CURLCONFIG))) +opts+=-DHAVE_CURL +endif +endif + +ifdef HAVE_MINIUPNPC +libs+=-lminiupnpc +endif + +# (Valgrind is a memory debugger.) +ifdef VALGRIND +VALGRIND_PKGCONFIG?=valgrind +$(eval $(call Use_pkg_config,VALGRIND)) +ZDEBUG=1 +opts+=-DHAVE_VALGRIND +endif + +default_packages:=\ + GME/libgme/LIBGME\ + OPENMPT/libopenmpt/LIBOPENMPT\ + ZLIB/zlib\ + +$(foreach p,$(default_packages),\ + $(eval $(call Check_pkg_config,$(p)))) diff --git a/src/Makefile.d/lua.mk b/src/Makefile.d/lua.mk deleted file mode 100644 index 12ea064b4..000000000 --- a/src/Makefile.d/lua.mk +++ /dev/null @@ -1,51 +0,0 @@ -ifdef UNIXCOMMON -LUA_CFLAGS+=-DLUA_USE_POSIX -endif -ifdef LINUX -LUA_CFLAGS+=-DLUA_USE_POSIX -endif -ifdef GCC43 -ifndef GCC44 -WFLAGS+=-Wno-logical-op -endif -endif - -OBJS:=$(OBJS) \ - $(OBJDIR)/lapi.o \ - $(OBJDIR)/lbaselib.o \ - $(OBJDIR)/ldo.o \ - $(OBJDIR)/lfunc.o \ - $(OBJDIR)/linit.o \ - $(OBJDIR)/liolib.o \ - $(OBJDIR)/llex.o \ - $(OBJDIR)/lmem.o \ - $(OBJDIR)/lobject.o \ - $(OBJDIR)/lstate.o \ - $(OBJDIR)/lstrlib.o \ - $(OBJDIR)/ltablib.o \ - $(OBJDIR)/lundump.o \ - $(OBJDIR)/lzio.o \ - $(OBJDIR)/lauxlib.o \ - $(OBJDIR)/lcode.o \ - $(OBJDIR)/ldebug.o \ - $(OBJDIR)/ldump.o \ - $(OBJDIR)/lgc.o \ - $(OBJDIR)/lopcodes.o \ - $(OBJDIR)/lparser.o \ - $(OBJDIR)/lstring.o \ - $(OBJDIR)/ltable.o \ - $(OBJDIR)/ltm.o \ - $(OBJDIR)/lvm.o \ - $(OBJDIR)/lua_script.o \ - $(OBJDIR)/lua_baselib.o \ - $(OBJDIR)/lua_mathlib.o \ - $(OBJDIR)/lua_hooklib.o \ - $(OBJDIR)/lua_consolelib.o \ - $(OBJDIR)/lua_infolib.o \ - $(OBJDIR)/lua_mobjlib.o \ - $(OBJDIR)/lua_playerlib.o \ - $(OBJDIR)/lua_skinlib.o \ - $(OBJDIR)/lua_thinkerlib.o \ - $(OBJDIR)/lua_maplib.o \ - $(OBJDIR)/lua_blockmaplib.o \ - $(OBJDIR)/lua_hudlib.o diff --git a/src/Makefile.d/nix.mk b/src/Makefile.d/nix.mk index 47c944eb5..fdcd40d4d 100644 --- a/src/Makefile.d/nix.mk +++ b/src/Makefile.d/nix.mk @@ -1,74 +1,40 @@ # -# sdl/makeNIX.cfg for SRB2/?nix +# Makefile options for unices (linux, bsd...) # -#Valgrind support -ifdef VALGRIND -VALGRIND_PKGCONFIG?=valgrind -VALGRIND_CFLAGS?=$(shell $(PKG_CONFIG) $(VALGRIND_PKGCONFIG) --cflags) -VALGRIND_LDFLAGS?=$(shell $(PKG_CONFIG) $(VALGRIND_PKGCONFIG) --libs) -ZDEBUG=1 -LIBS+=$(VALGRIND_LDFLAGS) -ifdef GCC46 -WFLAGS+=-Wno-error=unused-but-set-variable -WFLAGS+=-Wno-unused-but-set-variable -endif -endif +EXENAME?=lsdl2srb2 -# -#here is GNU/Linux and other -# +opts+=-DUNIXCOMMON -DLUA_USE_POSIX +libs+=-lm - OPTS=-DUNIXCOMMON - - #LDFLAGS = -L/usr/local/lib - LIBS=-lm -ifdef LINUX - LIBS+=-lrt -ifdef NOTERMIOS - OPTS+=-DNOTERMIOS -endif -endif - -ifdef LINUX64 - OPTS+=-DLINUX64 -endif - -# -#here is Solaris -# -ifdef SOLARIS - NOIPX=1 - NOASM=1 - OPTS+=-DSOLARIS -DINADDR_NONE=INADDR_ANY -DBSD_COMP - OPTS+=-I/usr/local/include -I/opt/sfw/include - LDFLAGS+=-L/opt/sfw/lib - LIBS+=-lsocket -lnsl -endif - -# -#here is FreeBSD -# -ifdef FREEBSD - OPTS+=-DLINUX -DFREEBSD -I/usr/X11R6/include - SDL_CONFIG?=sdl11-config - LDFLAGS+=-L/usr/X11R6/lib - LIBS+=-lipx -lkvm -endif - -# -#here is Mac OS X -# -ifdef MACOSX - OBJS+=$(OBJDIR)/mac_resources.o - OBJS+=$(OBJDIR)/mac_alert.o - LIBS+=-framework CoreFoundation +ifndef nasm_format +nasm_format:=elf -DLINUX endif ifndef NOHW - OPTS+=-I/usr/X11R6/include - LDFLAGS+=-L/usr/X11R6/lib +opts+=-I/usr/X11R6/include +libs+=-L/usr/X11R6/lib endif - # name of the exefile - EXENAME?=lsdl2srb2 +SDL=1 + +# In common usage. +ifdef LINUX +libs+=-lrt +passthru_opts+=NOTERMIOS +endif + +# Tested by Steel, as of release 2.2.8. +ifdef FREEBSD +opts+=-I/usr/X11R6/include -DLINUX -DFREEBSD +libs+=-L/usr/X11R6/lib -lipx -lkvm +endif + +# FIXME +#ifdef SOLARIS +#NOIPX=1 +#NOASM=1 +#opts+=-I/usr/local/include -I/opt/sfw/include \ +# -DSOLARIS -DINADDR_NONE=INADDR_ANY -DBSD_COMP +#libs+=-L/opt/sfw/lib -lsocket -lnsl +#endif diff --git a/src/Makefile.d/platform.mk b/src/Makefile.d/platform.mk new file mode 100644 index 000000000..ca00806d9 --- /dev/null +++ b/src/Makefile.d/platform.mk @@ -0,0 +1,67 @@ +# +# Platform specific options. +# + +PKG_CONFIG?=pkg-config + +ifdef WINDOWSHELL +rmrf?=DEL /S /Q +mkdir?=MD +else +rmrf?=rm -rf +mkdir?=mkdir -p +endif + +ifdef LINUX64 +LINUX=1 +endif + +ifdef MINGW64 +MINGW=1 +endif + +ifdef LINUX +UNIX=1 +ifdef LINUX64 +NONX86=1 +# LINUX64 does not imply X86_64=1; +# could mean ARM64 or Itanium +platform=linux/64 +else +platform=linux +endif +else ifdef FREEBSD +UNIX=1 +platform=freebsd +else ifdef SOLARIS # FIXME +UNIX=1 +platform=solaris +else ifdef CYGWIN32 # FIXME +nasm_format=win32 +platform=cygwin +else ifdef MINGW +ifdef MINGW64 +NONX86=1 +NOASM=1 +# MINGW64 should not necessarily imply X86_64=1, +# but we make that assumption elsewhere +# Once that changes, remove this +X86_64=1 +platform=mingw +else +platform=mingw/64 +endif +include Makefile.d/win32.mk +endif + +ifdef platform +makedir:=$(makedir)/$(platform) +endif + +ifdef UNIX +include Makefile.d/nix.mk +endif + +ifdef SDL +include Makefile.d/sdl.mk +endif diff --git a/src/Makefile.d/sdl.mk b/src/Makefile.d/sdl.mk index 45d0d6ba7..43a2ffced 100644 --- a/src/Makefile.d/sdl.mk +++ b/src/Makefile.d/sdl.mk @@ -1,125 +1,98 @@ # -# sdl/makefile.cfg for SRB2/SDL +# Makefile options for SDL2 backend. # # -#SDL...., *looks at Alam*, THIS IS A MESS! +# SDL...., *looks at Alam*, THIS IS A MESS! +# +# ...a little bird flexes its muscles... # -ifdef UNIXCOMMON -include sdl/MakeNIX.cfg -endif +makedir:=$(makedir)/SDL -ifdef PANDORA -include sdl/SRB2Pandora/Makefile.cfg -endif #ifdef PANDORA +sources+=$(call List,sdl/Sourcefile) +opts+=-DDIRECTFULLSCREEN -DHAVE_SDL -ifdef CYGWIN32 -include sdl/MakeCYG.cfg -endif #ifdef CYGWIN32 +# FIXME +#ifdef PANDORA +#include sdl/SRB2Pandora/Makefile.cfg +#endif #ifdef PANDORA -ifdef SDL_PKGCONFIG -SDL_CFLAGS?=$(shell $(PKG_CONFIG) $(SDL_PKGCONFIG) --cflags) -SDL_LDFLAGS?=$(shell $(PKG_CONFIG) $(SDL_PKGCONFIG) --libs) -else -ifdef PREFIX - SDL_CONFIG?=$(PREFIX)-sdl2-config -else - SDL_CONFIG?=sdl2-config -endif - -ifdef STATIC - SDL_CFLAGS?=$(shell $(SDL_CONFIG) --cflags) - SDL_LDFLAGS?=$(shell $(SDL_CONFIG) --static-libs) -else - SDL_CFLAGS?=$(shell $(SDL_CONFIG) --cflags) - SDL_LDFLAGS?=$(shell $(SDL_CONFIG) --libs) -endif -endif - - - #use the x86 asm code -ifndef CYGWIN32 -ifndef NOASM - USEASM=1 -endif -endif - - OBJS+=$(OBJDIR)/i_video.o $(OBJDIR)/dosstr.o $(OBJDIR)/endtxt.o $(OBJDIR)/hwsym_sdl.o - - OPTS+=-DDIRECTFULLSCREEN -DHAVE_SDL +# FIXME +#ifdef CYGWIN32 +#include sdl/MakeCYG.cfg +#endif #ifdef CYGWIN32 ifndef NOHW - OBJS+=$(OBJDIR)/r_opengl.o $(OBJDIR)/ogl_sdl.o +sources+=sdl/ogl_sdl.c endif ifdef NOMIXER - i_sound_o=$(OBJDIR)/sdl_sound.o +sources+=sdl/sdl_sound.c else - i_sound_o=$(OBJDIR)/mixer_sound.o - OPTS+=-DHAVE_MIXER -ifdef HAVE_MIXERX - OPTS+=-DHAVE_MIXERX - SDL_LDFLAGS+=-lSDL2_mixer_ext -else - SDL_LDFLAGS+=-lSDL2_mixer -endif +opts+=-DHAVE_MIXER +sources+=sdl/mixer_sound.c + + ifdef HAVE_MIXERX + opts+=-DHAVE_MIXERX + libs+=-lSDL2_mixer_ext + else + libs+=-lSDL2_mixer + endif endif ifndef NOTHREADS - OPTS+=-DHAVE_THREADS - OBJS+=$(OBJDIR)/i_threads.o +opts+=-DHAVE_THREADS +sources+=sdl/i_threads.c endif -ifdef SDL_TTF - OPTS+=-DHAVE_TTF - SDL_LDFLAGS+=-lSDL2_ttf -lfreetype -lz - OBJS+=$(OBJDIR)/i_ttf.o +ifdef SDL_PKGCONFIG +$(eval $(call Use_pkg_config,SDL)) +else +SDL_CONFIG?=$(call Prefix,sdl2-config) +SDL_CFLAGS?=$(shell $(SDL_CONFIG) --cflags) +SDL_LDFLAGS?=$(shell $(SDL_CONFIG) \ + $(if $(STATIC),--static-libs,--libs)) +$(eval $(call Propogate_flags,SDL)) endif -ifdef SDL_IMAGE - OPTS+=-DHAVE_IMAGE - SDL_LDFLAGS+=-lSDL2_image +# use the x86 asm code +ifndef CYGWIN32 +ifndef NOASM +USEASM=1 +endif endif -ifdef SDL_NET - OPTS+=-DHAVE_SDLNET - SDL_LDFLAGS+=-lSDL2_net -endif +# FIXME +#ifdef SDL_TTF +# OPTS+=-DHAVE_TTF +# SDL_LDFLAGS+=-lSDL2_ttf -lfreetype -lz +# OBJS+=$(OBJDIR)/i_ttf.o +#endif + +# FIXME +#ifdef SDL_IMAGE +# OPTS+=-DHAVE_IMAGE +# SDL_LDFLAGS+=-lSDL2_image +#endif + +# FIXME +#ifdef SDL_NET +# OPTS+=-DHAVE_SDLNET +# SDL_LDFLAGS+=-lSDL2_net +#endif ifdef MINGW ifndef NOSDLMAIN - SDLMAIN=1 +SDLMAIN=1 endif endif ifdef SDLMAIN - OPTS+=-DSDLMAIN +opts+=-DSDLMAIN else ifdef MINGW - SDL_CFLAGS+=-Umain - SDL_LDFLAGS+=-mconsole +opts+=-Umain +libs+=-mconsole endif endif - -ifndef NOHW -ifdef OPENAL -ifdef MINGW - LIBS:=-lopenal32 $(LIBS) -else - LIBS:=-lopenal $(LIBS) -endif -else -ifdef MINGW -ifdef DS3D - LIBS:=-ldsound -luuid $(LIBS) -endif -endif -endif -endif - -CFLAGS+=$(SDL_CFLAGS) -LIBS:=$(SDL_LDFLAGS) $(LIBS) -ifdef STATIC - LIBS+=$(shell $(SDL_CONFIG) --static-libs) -endif diff --git a/src/Makefile.d/util.mk b/src/Makefile.d/util.mk new file mode 100644 index 000000000..88f141bee --- /dev/null +++ b/src/Makefile.d/util.mk @@ -0,0 +1,89 @@ +# +# Utility macros for the rest of the Makefiles. +# + +Ifnot=$(if $(1),$(3),$(2)) +Ifndef=$(call Ifnot,$($(1)),$(2),$(3)) + +# Match and expand a list of variables by pattern. +Wildvar=$(foreach v,$(filter $(1),$(.VARIABLES)),$($(v))) + +# Read a list of words from file and prepend each with the +# directory of the file. +List=$(addprefix $(dir $(1)),$(file < $(1))) + +define Propogate_flags = +opts+=$$($(1)_CFLAGS) +libs+=$$($(1)_LDFLAGS) +endef + +# Set library's _CFLAGS and _LDFLAGS from some command. +# Automatically propogates the flags too. +# 1: variable prefix (e.g. CURL) +# 2: start of command (e.g. curl-config) +# --- optional ---- +# 3: CFLAGS command arguments, default '--cflags' +# 4: LDFLAGS command arguments, default '--libs' +# 5: common command arguments at the end of command +define Configure = +$(1)_CFLAGS?=$$(shell $(2) $(or $(3),--cflags) $(5)) +$(1)_LDFLAGS?=$$(shell $(2) $(or $(4),--libs) $(5)) +$(call Propogate_flags,$(1)) +endef + +# Configure library with pkg-config. The package name is +# taken from a _PKGCONFIG variable. +# 1: variable prefix +# +# LIBGME_PKGCONFIG=libgme +# $(eval $(call Use_pkg_config,LIBGME)) +define Use_pkg_config = +$(call Configure,$(1),$(PKG_CONFIG),,,$($(1)_PKGCONFIG)) +endef + +# Check disabling flag and configure package in one step +# according to delimited argument. +# (There is only one argument, but it split by slash.) +# 1/: short form library name (uppercase). This is +# prefixed with 'NO' and 'HAVE_'. E.g. NOGME, HAVE_GME +# /2: package name (e.g. libgme) +# /3: variable prefix +# +# The following example would check if NOGME is not +# defined before attempting to define LIBGME_CFLAGS and +# LIBGME_LDFLAGS as with Use_pkg_config. +# +# $(eval $(call Check_pkg_config,GME/libgme/LIBGME)) +define Check_pkg_config = +_p:=$(subst /, ,$(1)) +_v1:=$$(word 1,$$(_p)) +_v2:=$$(or $$(word 3,$$(_p)),$$(_v1)) +ifndef NO$$(_v1) +$$(_v2)_PKGCONFIG?=$$(word 2,$$(_p)) +$$(eval $$(call Use_pkg_config,$$(_v2))) +opts+=-DHAVE_$$(_v1) +endif +endef + +# $(call Prefix,gcc) +Prefix=$(if $(PREFIX),$(PREFIX)-)$(1) + +Echo= +Echo_name= +Print= + +ifndef SILENT +Echo=@echo "$(1)" +ifndef ECHO +ifndef NOECHOFILENAMES +Echo_name=$(call Echo,-- $(1) ...) +endif +endif +ifndef MAKE_RESTARTS +ifndef destructive +Print=$(info $(1)) +endif +endif +endif + +.=$(call Ifndef,ECHO,@) diff --git a/src/Makefile.d/versions.mk b/src/Makefile.d/versions.mk index 075cd2d3a..fe2b6b851 100644 --- a/src/Makefile.d/versions.mk +++ b/src/Makefile.d/versions.mk @@ -1,215 +1,23 @@ -# vim: ft=make # -# Makefile.cfg for SRB2 +# Flags to put a sock in GCC! # -# -# GNU compiler & tools' flags -# and other things -# - -# See the following variable don't start with 'GCC'. This is -# to avoid a false positive with the version detection... - -SUPPORTED_GCC_VERSIONS:=\ - 101 102\ - 91 92 93\ - 81 82 83 84\ - 71 72 73 74 75\ - 61 62 63 64\ - 51 52 53 54 55\ - 40 41 42 43 44 45 46 47 48 49 - -LATEST_GCC_VERSION=10.2 - -# gcc or g++ -ifdef PREFIX - CC=$(PREFIX)-gcc - CXX=$(PREFIX)-g++ - OBJCOPY=$(PREFIX)-objcopy - OBJDUMP=$(PREFIX)-objdump - STRIP=$(PREFIX)-strip - WINDRES=$(PREFIX)-windres -else - OBJCOPY=objcopy - OBJDUMP=objdump - STRIP=strip - WINDRES=windres +# See the versions list in detect.mk +# This will define all version flags going backward. +# Yes, it's magic. +define _predecessor = +ifdef GCC$(firstword $(1)) +GCC$(lastword $(1)):=1 endif +endef +_n:=$(words $(gcc_versions)) +$(foreach v,$(join $(wordlist 2,$(_n),- $(gcc_versions)),\ + $(addprefix =,$(wordlist 2,$(_n),$(gcc_versions)))),\ + $(and $(findstring =,$(v)),\ + $(eval $(call _predecessor,$(subst =, ,$(v)))))) -# because Apple screws with us on this -# need to get bintools from homebrew -ifdef MACOSX - CC=clang - CXX=clang - OBJCOPY=gobjcopy - OBJDUMP=gobjdump -endif - -# Automatically set version flag, but not if one was manually set -# And don't bother if this is a clean only run -ifeq (,$(filter GCC% CLEANONLY,$(.VARIABLES))) - version:=$(shell $(CC) --version) - # check if this is in fact GCC - ifneq (,$(or $(findstring gcc,$(version)),$(findstring GCC,$(version)))) - version:=$(shell $(CC) -dumpversion) - - # Turn version into words of major, minor - v:=$(subst ., ,$(version)) - # concat. major minor - v:=$(word 1,$(v))$(word 2,$(v)) - - # If this version is not in the list, default to the latest supported - ifeq (,$(filter $(v),$(SUPPORTED_GCC_VERSIONS))) - define line = - Your compiler version, GCC $(version), is not supported by the Makefile. - The Makefile will assume GCC $(LATEST_GCC_VERSION).)) - endef - $(call print,$(line)) - GCC$(subst .,,$(LATEST_GCC_VERSION))=1 - else - $(call print,Detected GCC $(version) (GCC$(v))) - GCC$(v)=1 - endif - endif -endif - -ifdef GCC102 -GCC101=1 -endif - -ifdef GCC101 -GCC93=1 -endif - -ifdef GCC93 -GCC92=1 -endif - -ifdef GCC92 -GCC91=1 -endif - -ifdef GCC91 -GCC84=1 -endif - -ifdef GCC84 -GCC83=1 -endif - -ifdef GCC83 -GCC82=1 -endif - -ifdef GCC82 -GCC81=1 -endif - -ifdef GCC81 -GCC75=1 -endif - -ifdef GCC75 -GCC74=1 -endif - -ifdef GCC74 -GCC73=1 -endif - -ifdef GCC73 -GCC72=1 -endif - -ifdef GCC72 -GCC71=1 -endif - -ifdef GCC71 -GCC64=1 -endif - -ifdef GCC64 -GCC63=1 -endif - -ifdef GCC63 -GCC62=1 -endif - -ifdef GCC62 -GCC61=1 -endif - -ifdef GCC61 -GCC55=1 -endif - -ifdef GCC55 -GCC54=1 -endif - -ifdef GCC54 -GCC53=1 -endif - -ifdef GCC53 -GCC52=1 -endif - -ifdef GCC52 -GCC51=1 -endif - -ifdef GCC51 -GCC49=1 -endif - -ifdef GCC49 -GCC48=1 -endif - -ifdef GCC48 -GCC47=1 -endif - -ifdef GCC47 -GCC46=1 -endif - -ifdef GCC46 -GCC45=1 -endif - -ifdef GCC45 -GCC44=1 -endif - -ifdef GCC44 -GCC43=1 -endif - -ifdef GCC43 -GCC42=1 -endif - -ifdef GCC42 -GCC41=1 -endif - -ifdef GCC41 -GCC40=1 -VCHELP=1 -endif - -ifdef GCC295 -GCC29=1 -endif - -OLDWFLAGS:=$(WFLAGS) # -W -Wno-unused -WFLAGS=-Wall +WFLAGS:=-Wall ifndef GCC295 #WFLAGS+=-Wno-packed endif @@ -222,15 +30,13 @@ endif #WFLAGS+=-Wsystem-headers WFLAGS+=-Wfloat-equal #WFLAGS+=-Wtraditional -ifdef VCHELP - WFLAGS+=-Wdeclaration-after-statement - WFLAGS+=-Wno-error=declaration-after-statement -endif WFLAGS+=-Wundef ifndef GCC295 WFLAGS+=-Wendif-labels endif ifdef GCC41 + WFLAGS+=-Wdeclaration-after-statement + WFLAGS+=-Wno-error=declaration-after-statement WFLAGS+=-Wshadow endif #WFLAGS+=-Wlarger-than-%len% @@ -308,8 +114,6 @@ ifdef ERRORMODE WFLAGS+=-Werror endif -WFLAGS+=$(OLDWFLAGS) - ifdef GCC43 #WFLAGS+=-Wno-error=clobbered endif @@ -338,141 +142,36 @@ ifdef GCC81 WFLAGS+=-Wno-error=multistatement-macros endif - -#indicate platform and what interface use with -ifndef LINUX -ifndef FREEBSD -ifndef CYGWIN32 -ifndef MINGW -ifndef MINGW64 -ifndef SDL -ifndef DUMMY -$(error No interface or platform flag defined) -endif -endif -endif -endif -endif -endif -endif - -#determine the interface directory (where you put all i_*.c) -i_net_o=$(OBJDIR)/i_net.o -i_system_o=$(OBJDIR)/i_system.o -i_sound_o=$(OBJDIR)/i_sound.o -i_main_o=$(OBJDIR)/i_main.o -#set OBJDIR and BIN's starting place -OBJDIR=../objs -BIN=../bin -DEPDIR=../dep -#Nasm ASM and rm -ifdef YASM -NASM?=yasm +ifdef NONX86 + ifdef X86_64 # yeah that SEEMS contradictory + opts+=-march=nocona + endif else -NASM?=nasm -endif -REMOVE?=rm -f -MKDIR?=mkdir -p -GZIP?=gzip -GZIP_OPTS?=-9 -f -n -GZIP_OPT2=$(GZIP_OPTS) --rsyncable -UPX?=upx -UPX_OPTS?=--best --preserve-build-id -ifndef ECHO -UPX_OPTS+=-q + ifndef GCC29 + opts+=-msse3 -mfpmath=sse + else + opts+=-mpentium + endif endif -#Interface Setup -ifdef DUMMY - INTERFACE=dummy - OBJDIR:=$(OBJDIR)/dummy - BIN:=$(BIN)/dummy - DEPDIR:=$(DEPDIR)/dummy -else -ifdef LINUX - NASMFORMAT=elf -DLINUX - SDL=1 -ifdef LINUX64 - OBJDIR:=$(OBJDIR)/Linux64 - BIN:=$(BIN)/Linux64 - DEPDIR:=$(DEPDIR)/Linux64 -else - OBJDIR:=$(OBJDIR)/Linux - BIN:=$(BIN)/Linux - DEPDIR:=$(DEPDIR)/Linux -endif -else -ifdef FREEBSD - INTERFACE=sdl - NASMFORMAT=elf -DLINUX - SDL=1 - - OBJDIR:=$(OBJDIR)/FreeBSD - BIN:=$(BIN)/FreeBSD - DEPDIR:=$(DEPDIR)/Linux -else -ifdef SOLARIS - INTERFACE=sdl - NASMFORMAT=elf -DLINUX - SDL=1 - - OBJDIR:=$(OBJDIR)/Solaris - BIN:=$(BIN)/Solaris - DEPDIR:=$(DEPDIR)/Solaris -else -ifdef CYGWIN32 - INTERFACE=sdl - NASMFORMAT=win32 - SDL=1 - - OBJDIR:=$(OBJDIR)/cygwin - BIN:=$(BIN)/Cygwin - DEPDIR:=$(DEPDIR)/Cygwin -else -ifdef MINGW64 - #NASMFORMAT=win64 - SDL=1 - OBJDIR:=$(OBJDIR)/Mingw64 - BIN:=$(BIN)/Mingw64 - DEPDIR:=$(DEPDIR)/Mingw64 -else -ifdef MINGW - NASMFORMAT=win32 - SDL=1 - OBJDIR:=$(OBJDIR)/Mingw - BIN:=$(BIN)/Mingw - DEPDIR:=$(DEPDIR)/Mingw -endif -endif -endif -endif -endif -endif -endif - -ifdef ARCHNAME - OBJDIR:=$(OBJDIR)/$(ARCHNAME) - BIN:=$(BIN)/$(ARCHNAME) - DEPDIR:=$(DEPDIR)/$(ARCHNAME) -endif - -OBJDUMP_OPTS?=--wide --source --line-numbers -LD=$(CC) - -ifdef SDL - INTERFACE=sdl - OBJDIR:=$(OBJDIR)/SDL - DEPDIR:=$(DEPDIR)/SDL -endif - -ifndef DUMMY ifdef DEBUGMODE - OBJDIR:=$(OBJDIR)/Debug - BIN:=$(BIN)/Debug - DEPDIR:=$(DEPDIR)/Debug +ifdef GCC48 +opts+=-Og else - OBJDIR:=$(OBJDIR)/Release - BIN:=$(BIN)/Release - DEPDIR:=$(DEPDIR)/Release +opts+=O0 +endif +endif + +ifdef VALGRIND +ifdef GCC46 +WFLAGS+=-Wno-error=unused-but-set-variable +WFLAGS+=-Wno-unused-but-set-variable +endif +endif + +# Lua +ifdef GCC43 +ifndef GCC44 +WFLAGS+=-Wno-logical-op endif endif diff --git a/src/Makefile.d/win32.mk b/src/Makefile.d/win32.mk index 702ae3765..0c671b268 100644 --- a/src/Makefile.d/win32.mk +++ b/src/Makefile.d/win32.mk @@ -1,136 +1,99 @@ # -# win32/Makefile.cfg for SRB2/Minwgw +# Mingw, if you don't know, that's Win32/Win64 # -# -#Mingw, if you don't know, that's Win32/Win64 -# +ifndef MINGW64 +EXENAME?=srb2win.exe +else +EXENAME?=srb2win64.exe +endif + +sources+=win32/Srb2win.rc +opts+=-DSTDC_HEADERS +libs+=-ladvapi32 -lkernel32 -lmsvcrt -luser32 + +nasm_format:=win32 + +SDL=1 + +ifndef NOHW +opts+=-DUSE_WGL_SWAP +endif ifdef MINGW64 - HAVE_LIBGME=1 - LIBGME_CFLAGS=-I../libs/gme/include - LIBGME_LDFLAGS=-L../libs/gme/win64 -lgme -ifdef HAVE_OPENMPT - LIBOPENMPT_CFLAGS?=-I../libs/libopenmpt/inc - LIBOPENMPT_LDFLAGS?=-L../libs/libopenmpt/lib/x86_64/mingw -lopenmpt -endif -ifndef NOMIXERX - HAVE_MIXERX=1 - SDL_CFLAGS?=-I../libs/SDL2/x86_64-w64-mingw32/include/SDL2 -I../libs/SDLMixerX/x86_64-w64-mingw32/include/SDL2 -Dmain=SDL_main - SDL_LDFLAGS?=-L../libs/SDL2/x86_64-w64-mingw32/lib -L../libs/SDLMixerX/x86_64-w64-mingw32/lib -lmingw32 -lSDL2main -lSDL2 -mwindows +libs+=-lws2_32 else - SDL_CFLAGS?=-I../libs/SDL2/x86_64-w64-mingw32/include/SDL2 -I../libs/SDL2_mixer/x86_64-w64-mingw32/include/SDL2 -Dmain=SDL_main - SDL_LDFLAGS?=-L../libs/SDL2/x86_64-w64-mingw32/lib -L../libs/SDL2_mixer/x86_64-w64-mingw32/lib -lmingw32 -lSDL2main -lSDL2 -mwindows -endif +ifdef NO_IPV6 +libs+=-lwsock32 else - HAVE_LIBGME=1 - LIBGME_CFLAGS=-I../libs/gme/include - LIBGME_LDFLAGS=-L../libs/gme/win32 -lgme -ifdef HAVE_OPENMPT - LIBOPENMPT_CFLAGS?=-I../libs/libopenmpt/inc - LIBOPENMPT_LDFLAGS?=-L../libs/libopenmpt/lib/x86/mingw -lopenmpt +libs+=-lws2_32 endif -ifndef NOMIXERX - HAVE_MIXERX=1 - SDL_CFLAGS?=-I../libs/SDL2/i686-w64-mingw32/include/SDL2 -I../libs/SDLMixerX/i686-w64-mingw32/include/SDL2 -Dmain=SDL_main - SDL_LDFLAGS?=-L../libs/SDL2/i686-w64-mingw32/lib -L../libs/SDLMixerX/i686-w64-mingw32/lib -lmingw32 -lSDL2main -lSDL2 -mwindows -else - SDL_CFLAGS?=-I../libs/SDL2/i686-w64-mingw32/include/SDL2 -I../libs/SDL2_mixer/i686-w64-mingw32/include/SDL2 -Dmain=SDL_main - SDL_LDFLAGS?=-L../libs/SDL2/i686-w64-mingw32/lib -L../libs/SDL2_mixer/i686-w64-mingw32/lib -lmingw32 -lSDL2main -lSDL2 -mwindows -endif -endif - -ifndef NOASM - USEASM=1 endif ifndef NONET -ifndef MINGW64 #miniupnc is broken with MINGW64 - HAVE_MINIUPNPC=1 +ifndef MINGW64 # miniupnc is broken with MINGW64 +opts+=-I../libs -DSTATIC_MINIUPNPC +libs+=-L../libs/miniupnpc/mingw$(32) -lws2_32 -liphlpapi endif endif - OPTS=-DSTDC_HEADERS - -ifndef GCC44 - #OPTS+=-mms-bitfields -endif - - LIBS+=-ladvapi32 -lkernel32 -lmsvcrt -luser32 -ifdef MINGW64 - LIBS+=-lws2_32 +ifndef MINGW64 +32=32 +x86=x86 +i686=i686 else -ifdef NO_IPV6 - LIBS+=-lwsock32 +32=64 +x86=x86_64 +i686=x86_64 +endif + +mingw:=$(i686)-w64-mingw32 + +define _set = +$(1)_CFLAGS?=$($(1)_opts) +$(1)_LDFLAGS?=$($(1)_libs) +endef + +lib:=../libs/gme +LIBGME_opts:=-I$(lib)/include +LIBGME_libs:=-L$(lib)/win$(32) -lgme +$(eval $(call _set,LIBGME)) + +lib:=../libs/libopenmpt +LIBOPENMPT_opts:=-I$(lib)/inc +LIBOPENMPT_libs:=-L$(lib)/lib/$(x86)/mingw -lopenmpt +$(eval $(call _set,LIBOPENMPT)) + +ifndef NOMIXERX +HAVE_MIXERX=1 +lib:=../libs/SDLMixerX/$(mingw) else - LIBS+=-lws2_32 -endif +lib:=../libs/SDL2_mixer/$(mingw) endif - # name of the exefile - EXENAME?=srb2win.exe +mixer_opts:=-I$(lib)/include/SDL2 +mixer_libs:=-L$(lib)/lib -ifdef SDL - i_system_o+=$(OBJDIR)/SRB2.res - #i_main_o+=$(OBJDIR)/win_dbg.o -ifndef NOHW - OPTS+=-DUSE_WGL_SWAP -endif -endif +lib:=../libs/SDL2/$(mingw) +SDL_opts:=-I$(lib)/include/SDL2\ + $(mixer_opts) -Dmain=SDL_main +SDL_libs:=-L$(lib)/lib $(mixer_libs)\ + -lmingw32 -lSDL2main -lSDL2 -mwindows +$(eval $(call _set,SDL)) +lib:=../libs/zlib +ZLIB_opts:=-I$(lib) +ZLIB_libs:=-L$(lib)/win32 -lz$(32) +$(eval $(call _set,ZLIB)) -ZLIB_CFLAGS?=-I../libs/zlib -ifdef MINGW64 -ZLIB_LDFLAGS?=-L../libs/zlib/win32 -lz64 -else -ZLIB_LDFLAGS?=-L../libs/zlib/win32 -lz32 -endif - -ifndef NOPNG ifndef PNG_CONFIG - PNG_CFLAGS?=-I../libs/libpng-src -ifdef MINGW64 - PNG_LDFLAGS?=-L../libs/libpng-src/projects -lpng64 -else - PNG_LDFLAGS?=-L../libs/libpng-src/projects -lpng32 -endif #MINGW64 -endif #PNG_CONFIG -endif #NOPNG - -ifdef GETTEXT -ifndef CCBS - MSGFMT?=../libs/gettext/bin32/msgfmt.exe -endif -ifdef MINGW64 - CPPFLAGS+=-I../libs/gettext/include64 - LDFLAGS+=-L../libs/gettext/lib64 - LIBS+=-lmingwex -else - CPPFLAGS+=-I../libs/gettext/include32 - LDFLAGS+=-L../libs/gettext/lib32 - STATIC_GETTEXT=1 -endif #MINGW64 -ifdef STATIC_GETTEXT - LIBS+=-lasprintf -lintl -else - LIBS+=-lintl.dll -endif #STATIC_GETTEXT -endif #GETTEXT - -ifdef HAVE_MINIUPNPC - CPPFLAGS+=-I../libs/ -DSTATIC_MINIUPNPC -ifdef MINGW64 - LDFLAGS+=-L../libs/miniupnpc/mingw64 -else - LDFLAGS+=-L../libs/miniupnpc/mingw32 -endif #MINGW64 +lib:=../libs/libpng-src +PNG_opts:=-I$(lib) +PNG_libs:=-L$(lib)/projects -lpng$(32) +$(eval $(call _set,PNG)) endif -ifndef NOCURL - CURL_CFLAGS+=-I../libs/curl/include -ifdef MINGW64 - CURL_LDFLAGS+=-L../libs/curl/lib64 -lcurl -else - CURL_LDFLAGS+=-L../libs/curl/lib32 -lcurl -endif #MINGW64 -endif +lib:=../libs/curl +CURL_opts:=-I$(lib)/include +CURL_libs:=-L$(lib)/lib$(32) -lcurl +$(eval $(call _set,CURL)) diff --git a/src/Sourcefile b/src/Sourcefile new file mode 100644 index 000000000..9f27f2810 --- /dev/null +++ b/src/Sourcefile @@ -0,0 +1,87 @@ +string.c +d_main.c +d_clisrv.c +d_net.c +d_netfil.c +d_netcmd.c +dehacked.c +z_zone.c +f_finale.c +f_wipe.c +g_demo.c +g_game.c +g_input.c +am_map.c +command.c +console.c +hu_stuff.c +y_inter.c +st_stuff.c +m_aatree.c +m_anigif.c +m_argv.c +m_bbox.c +m_cheat.c +m_cond.c +m_fixed.c +m_menu.c +m_misc.c +m_random.c +m_queue.c +info.c +p_ceilng.c +p_enemy.c +p_floor.c +p_inter.c +p_lights.c +p_map.c +p_maputl.c +p_mobj.c +p_polyobj.c +p_saveg.c +p_setup.c +p_sight.c +p_spec.c +p_telept.c +p_tick.c +p_user.c +p_slopes.c +tables.c +r_bsp.c +r_data.c +r_draw.c +r_main.c +r_plane.c +r_segs.c +r_skins.c +r_sky.c +r_splats.c +r_things.c +r_textures.c +r_picformats.c +r_portal.c +screen.c +v_video.c +s_sound.c +sounds.c +w_wad.c +filesrch.c +mserv.c +http-mserv.c +i_tcp.c +lzf.c +vid_copy.s +b_bot.c +lua_script.c +lua_baselib.c +lua_mathlib.c +lua_hooklib.c +lua_consolelib.c +lua_infolib.c +lua_mobjlib.c +lua_playerlib.c +lua_skinlib.c +lua_thinkerlib.c +lua_maplib.c +lua_blockmaplib.c +lua_hudlib.c diff --git a/src/blua/Sourcefile b/src/blua/Sourcefile new file mode 100644 index 000000000..f99c89c8d --- /dev/null +++ b/src/blua/Sourcefile @@ -0,0 +1,25 @@ +lapi.c +lbaselib.c +ldo.c +lfunc.c +linit.c +liolib.c +llex.c +lmem.c +lobject.c +lstate.c +lstrlib.c +ltablib.c +lundump.c +lzio.c +lauxlib.c +lcode.c +ldebug.c +ldump.c +lgc.c +lopcodes.c +lparser.c +lstring.c +ltable.c +ltm.c +lvm.c diff --git a/src/hardware/Sourcefile b/src/hardware/Sourcefile new file mode 100644 index 000000000..1c05de76c --- /dev/null +++ b/src/hardware/Sourcefile @@ -0,0 +1,13 @@ +hw_bsp.c +hw_draw.c +hw_light.c +hw_main.c +hw_clip.c +hw_md2.c +hw_cache.c +hw_md2load.c +hw_md3load.c +hw_model.c +u_list.c +hw_batching.c +r_opengl/r_opengl.c diff --git a/src/sdl/Sourcefile b/src/sdl/Sourcefile new file mode 100644 index 000000000..82d5ce073 --- /dev/null +++ b/src/sdl/Sourcefile @@ -0,0 +1,7 @@ +i_net.c +i_system.c +i_main.c +i_video.c +dosstr.c +endtxt.c +hwsym_sdl.c From 53d1cbe8264196e46911c86bc4be13d44aa35dfe Mon Sep 17 00:00:00 2001 From: James R Date: Tue, 4 May 2021 16:50:50 -0700 Subject: [PATCH 0748/1080] Appveyor: update executable directory --- appveyor.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 2acc2f712..d9cff5333 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -100,9 +100,9 @@ build_script: after_build: - if [%X86_64%] == [1] ( - set "BUILD_PATH=bin\Mingw64\Release" + set "BUILD_PATH=bin\64" ) else ( - set "BUILD_PATH=bin\Mingw\Release" + set "BUILD_PATH=bin" ) - if [%X86_64%] == [1] ( set "CONFIGURATION=%CONFIGURATION%64" ) - ccache -s From 888073d64d1885cae0ad8b5d54bfec31e9793e0a Mon Sep 17 00:00:00 2001 From: James R Date: Tue, 4 May 2021 16:54:47 -0700 Subject: [PATCH 0749/1080] Fix make clean printing header --- src/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Makefile b/src/Makefile index dafec3645..8c31b212d 100644 --- a/src/Makefile +++ b/src/Makefile @@ -285,7 +285,7 @@ ifndef SILENT # makefile will 'restart' when it finishes including the # dependencies. ifndef MAKE_RESTARTS -ifndef destrutive +ifndef destructive $(shell $(CC) -v) define flags = From 8840bef2cb7c1913599d4c17b5027988638b50c8 Mon Sep 17 00:00:00 2001 From: James R Date: Tue, 4 May 2021 17:05:17 -0700 Subject: [PATCH 0750/1080] Appveyor: update to correct executable directory this time --- appveyor.yml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index d9cff5333..8a20986cf 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -99,16 +99,11 @@ build_script: - cmd: mingw32-make.exe %SRB2_MFLAGS% ERRORMODE=1 -k after_build: -- if [%X86_64%] == [1] ( - set "BUILD_PATH=bin\64" - ) else ( - set "BUILD_PATH=bin" - ) - if [%X86_64%] == [1] ( set "CONFIGURATION=%CONFIGURATION%64" ) - ccache -s - set BUILD_ARCHIVE=%REPO%-%GITSHORT%-%CONFIGURATION%.7z - set BUILDSARCHIVE=%REPO%-%CONFIGURATION%.7z -- cmd: 7z a %BUILD_ARCHIVE% %BUILD_PATH% -xr!.gitignore +- cmd: 7z a %BUILD_ARCHIVE% bin -xr!.gitignore - appveyor PushArtifact %BUILD_ARCHIVE% #- cmd: copy %BUILD_ARCHIVE% %BUILDSARCHIVE% #- appveyor PushArtifact %BUILDSARCHIVE% From 3d7205d4942d1e1b2627fdf5acf9d9c82437a97b Mon Sep 17 00:00:00 2001 From: James R Date: Tue, 4 May 2021 22:34:20 -0700 Subject: [PATCH 0751/1080] Fix minor errors with Windows ECHO, DEL, MD - Quotes were not removed by ECHO. - DEL would print an error on nonexistent file. - MD would do this plus return a nonzero exit code. --- src/Makefile | 10 ++++++---- src/Makefile.d/platform.mk | 8 ++++---- src/Makefile.d/util.mk | 5 ++++- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/Makefile b/src/Makefile index 8c31b212d..0c44afe55 100644 --- a/src/Makefile +++ b/src/Makefile @@ -315,7 +315,7 @@ WINDRES:=$(WINDRES) $(WINDRESFLAGS)\ $(debug_opts) --include-dir=win32 -O coff %/ : - $(.)$(mkdir) $@ + $(.)$(mkdir) $(call Windows_path,$@) # this is needed so the target can be referenced in the # prerequisites @@ -385,14 +385,16 @@ $(eval $(call _recipe,o,nas,$(NASM) -o $$@ $$<)) $(eval $(call _recipe,o,s,$(CC) $(ASFLAGS) -c -o $$@ $$<)) $(eval $(call _recipe,res,rc,$(WINDRES) -i $$< -o $$@)) +_rm=$(.)$(rmrf) $(call Windows_path,$(1)) + cleandep : - $(.)$(rmrf) $(depends) comptime.h + $(call _rm,$(depends) comptime.h) clean : - $(.)$(rmrf) $(exe) $(dbg) $(dbg).txt $(objects) + $(call _rm,$(exe) $(dbg) $(dbg).txt $(objects)) distclean : - $(.)$(rmrf) ../bin ../objs ../deps comptime.h + $(call _rm,../bin ../objs ../deps comptime.h) info: ifdef WINDOWSHELL diff --git a/src/Makefile.d/platform.mk b/src/Makefile.d/platform.mk index ca00806d9..4f110594e 100644 --- a/src/Makefile.d/platform.mk +++ b/src/Makefile.d/platform.mk @@ -5,11 +5,11 @@ PKG_CONFIG?=pkg-config ifdef WINDOWSHELL -rmrf?=DEL /S /Q -mkdir?=MD +rmrf=2>NUL DEL /S /Q +mkdir=-2>NUL MD else -rmrf?=rm -rf -mkdir?=mkdir -p +rmrf=rm -rf +mkdir=mkdir -p endif ifdef LINUX64 diff --git a/src/Makefile.d/util.mk b/src/Makefile.d/util.mk index 88f141bee..e76e32422 100644 --- a/src/Makefile.d/util.mk +++ b/src/Makefile.d/util.mk @@ -12,6 +12,9 @@ Wildvar=$(foreach v,$(filter $(1),$(.VARIABLES)),$($(v))) # directory of the file. List=$(addprefix $(dir $(1)),$(file < $(1))) +# Convert path separators to backslash on Windows. +Windows_path=$(if $(WINDOWSHELL),$(subst /,\,$(1)),$(1)) + define Propogate_flags = opts+=$$($(1)_CFLAGS) libs+=$$($(1)_LDFLAGS) @@ -73,7 +76,7 @@ Echo_name= Print= ifndef SILENT -Echo=@echo "$(1)" +Echo=@echo $(1) ifndef ECHO ifndef NOECHOFILENAMES Echo_name=$(call Echo,-- $(1) ...) From f9813844e7f0dfa6229062b1ebd83e4e8150c120 Mon Sep 17 00:00:00 2001 From: James R Date: Wed, 5 May 2021 03:56:57 -0700 Subject: [PATCH 0752/1080] Update CMakeLists.txt to use Sourcefiles This establishes (near) parity of source code file lists between the Makefile and CMakeLists.txt To make that change I messed around CMakeLists.txt a bit. It now uses target_sources and target_compile_definitions. I also removed some MSVC stuff since we don't actually care about MSVC--it made things easier. CMake minimum version 3.0 -> 3.13 for target_sources. --- CMakeLists.txt | 17 +- src/CMakeLists.txt | 383 ++---------------------------------- src/blua/CMakeLists.txt | 1 + src/hardware/CMakeLists.txt | 1 + src/sdl/CMakeLists.txt | 136 ++----------- 5 files changed, 47 insertions(+), 491 deletions(-) create mode 100644 src/blua/CMakeLists.txt create mode 100644 src/hardware/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 148f17ef0..bc764fc87 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.0) +cmake_minimum_required(VERSION 3.13) # Enable CCache early set(SRB2_USE_CCACHE OFF CACHE BOOL "Use CCache") @@ -34,12 +34,11 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/") ### Useful functions -# Prepend sources with current source directory -function(prepend_sources SOURCE_FILES) - foreach(SOURCE_FILE ${${SOURCE_FILES}}) - set(MODIFIED ${MODIFIED} ${CMAKE_CURRENT_SOURCE_DIR}/${SOURCE_FILE}) - endforeach() - set(${SOURCE_FILES} ${MODIFIED} PARENT_SCOPE) +# Add sources from Sourcefile +function(target_sourcefile type) + file(STRINGS Sourcefile list + REGEX "[-0-9A-Za-z_]+\.${type}") + target_sources(SRB2SDL2 PRIVATE ${list}) endfunction() # Macro to add OSX framework @@ -118,8 +117,10 @@ set(SRB2_SDL2_EXE_NAME srb2 CACHE STRING "Executable binary output name") include_directories(${CMAKE_CURRENT_BINARY_DIR}/src) +add_executable(SRB2SDL2 MACOSX_BUNDLE WIN32) + add_subdirectory(src) -#add_subdirectory(assets) +add_subdirectory(assets) ## config.h generation diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 47a790194..0148d605f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,224 +1,12 @@ # SRB2 Core # Core sources -set(SRB2_CORE_SOURCES - am_map.c - b_bot.c - command.c - comptime.c - console.c - d_clisrv.c - d_main.c - d_net.c - d_netcmd.c - d_netfil.c - dehacked.c - f_finale.c - f_wipe.c - filesrch.c - g_demo.c - g_game.c - g_input.c - hu_stuff.c - i_tcp.c - info.c - lzf.c - m_aatree.c - m_anigif.c - m_argv.c - m_bbox.c - m_cheat.c - m_cond.c - m_fixed.c - m_menu.c - m_misc.c - m_queue.c - m_random.c - md5.c - mserv.c - http-mserv.c - s_sound.c - screen.c - sounds.c - st_stuff.c - #string.c - tables.c - v_video.c - w_wad.c - y_inter.c - z_zone.c -) +target_sourcefile(c) +target_sources(SRB2SDL2 PRIVATE comptime.c md5.c config.h) -set(SRB2_CORE_HEADERS - am_map.h - b_bot.h - byteptr.h - command.h - console.h - d_clisrv.h - d_event.h - d_main.h - d_net.h - d_netcmd.h - d_netfil.h - d_player.h - d_think.h - d_ticcmd.h - dehacked.h - doomdata.h - doomdef.h - doomstat.h - doomtype.h - endian.h - f_finale.h - fastcmp.h - filesrch.h - g_demo.h - g_game.h - g_input.h - g_state.h - hu_stuff.h - i_joy.h - i_net.h - i_sound.h - i_system.h - i_tcp.h - i_video.h - info.h - keys.h - lzf.h - m_aatree.h - m_anigif.h - m_argv.h - m_bbox.h - m_cheat.h - m_cond.h - m_dllist.h - m_fixed.h - m_menu.h - m_misc.h - m_queue.h - m_random.h - m_swap.h - md5.h - mserv.h - p5prof.h - s_sound.h - screen.h - sounds.h - st_stuff.h - tables.h - v_video.h - w_wad.h - y_inter.h - z_zone.h - - config.h.in -) - -set(SRB2_CORE_RENDER_SOURCES - r_bsp.c - r_data.c - r_draw.c - r_main.c - r_plane.c - r_segs.c - r_skins.c - r_sky.c - r_splats.c - r_things.c - r_textures.c - r_picformats.c - r_portal.c - - r_bsp.h - r_data.h - r_defs.h - r_draw.h - r_local.h - r_main.h - r_plane.h - r_segs.h - r_skins.h - r_sky.h - r_splats.h - r_state.h - r_things.h - r_textures.h - r_picformats.h - r_portal.h -) - -set(SRB2_CORE_GAME_SOURCES - p_ceilng.c - p_enemy.c - p_floor.c - p_inter.c - p_lights.c - p_map.c - p_maputl.c - p_mobj.c - p_polyobj.c - p_saveg.c - p_setup.c - p_sight.c - p_slopes.c - p_spec.c - p_telept.c - p_tick.c - p_user.c - - p_local.h - p_maputl.h - p_mobj.h - p_polyobj.h - p_pspr.h - p_saveg.h - p_setup.h - p_slopes.h - p_spec.h - p_tick.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) -prepend_sources(SRB2_CORE_GAME_SOURCES) - -set(SRB2_CORE_HEADERS ${SRB2_CORE_HEADERS} ${CMAKE_CURRENT_BINARY_DIR}/config.h) -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}) - - -set(SRB2_ASM_SOURCES - ${CMAKE_CURRENT_SOURCE_DIR}/vid_copy.s -) - -set(SRB2_NASM_SOURCES - ${CMAKE_CURRENT_SOURCE_DIR}/tmap_mmx.nas - ${CMAKE_CURRENT_SOURCE_DIR}/tmap.nas -) - -if(MSVC) - list(APPEND SRB2_NASM_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/tmap_vc.nas) -endif() - -set(SRB2_NASM_OBJECTS - ${CMAKE_CURRENT_BINARY_DIR}/tmap_mmx.obj - ${CMAKE_CURRENT_BINARY_DIR}/tmap.obj -) - -if(MSVC) - list(APPEND SRB2_NASM_OBJECTS ${CMAKE_CURRENT_BINARY_DIR}/tmap_vc.obj) -endif() - -source_group("Assembly" FILES ${SRB2_ASM_SOURCES} ${SRB2_NASM_SOURCES}) +set(SRB2_ASM_SOURCES vid_copy.s) +set(SRB2_NASM_SOURCES tmap_mmx.nas tmap.nas) ### Configuration set(SRB2_CONFIG_HAVE_PNG ON CACHE BOOL @@ -254,90 +42,7 @@ if(${CMAKE_SYSTEM} MATCHES "Windows") ###set on Windows only "Use SRB2's internal copies of required dependencies (SDL2, PNG, zlib, GME, OpenMPT).") endif() -set(SRB2_LUA_SOURCES - lua_baselib.c - lua_blockmaplib.c - lua_consolelib.c - lua_hooklib.c - lua_hudlib.c - lua_infolib.c - lua_maplib.c - lua_mathlib.c - lua_mobjlib.c - lua_playerlib.c - lua_script.c - lua_skinlib.c - lua_thinkerlib.c -) -set(SRB2_LUA_HEADERS - lua_hook.h - lua_hud.h - lua_libs.h - lua_script.h -) - -prepend_sources(SRB2_LUA_SOURCES) -prepend_sources(SRB2_LUA_HEADERS) - -source_group("LUA" FILES ${SRB2_LUA_SOURCES} ${SRB2_LUA_HEADERS}) - -set(SRB2_BLUA_SOURCES - blua/lapi.c - blua/lauxlib.c - blua/lbaselib.c - blua/lcode.c - blua/ldebug.c - blua/ldo.c - blua/ldump.c - blua/lfunc.c - blua/lgc.c - blua/linit.c - blua/liolib.c - blua/llex.c - blua/lmem.c - blua/lobject.c - blua/lopcodes.c - blua/lparser.c - blua/lstate.c - blua/lstring.c - blua/lstrlib.c - blua/ltable.c - blua/ltablib.c - blua/ltm.c - blua/lundump.c - blua/lvm.c - blua/lzio.c -) -set(SRB2_BLUA_HEADERS - blua/lapi.h - blua/lauxlib.h - blua/lcode.h - blua/ldebug.h - blua/ldo.h - blua/lfunc.h - blua/lgc.h - blua/llex.h - blua/llimits.h - blua/lmem.h - blua/lobject.h - blua/lopcodes.h - blua/lparser.h - blua/lstate.h - blua/lstring.h - blua/ltable.h - blua/ltm.h - blua/lua.h - blua/luaconf.h - blua/lualib.h - blua/lundump.h - blua/lvm.h - blua/lzio.h -) - -prepend_sources(SRB2_BLUA_SOURCES) -prepend_sources(SRB2_BLUA_HEADERS) - -source_group("LUA\\Interpreter" FILES ${SRB2_BLUA_SOURCES} ${SRB2_BLUA_HEADERS}) +add_subdirectory(blua) if(${SRB2_CONFIG_HAVE_GME}) if(${SRB2_CONFIG_USE_INTERNAL_LIBRARIES}) @@ -353,7 +58,7 @@ if(${SRB2_CONFIG_HAVE_GME}) endif() if(${GME_FOUND}) set(SRB2_HAVE_GME ON) - add_definitions(-DHAVE_LIBGME) + target_compile_definitions(SRB2SDL2 PRIVATE -DHAVE_LIBGME) else() message(WARNING "You have specified that GME is available but it was not found.") endif() @@ -373,7 +78,7 @@ if(${SRB2_CONFIG_HAVE_OPENMPT}) endif() if(${OPENMPT_FOUND}) set(SRB2_HAVE_OPENMPT ON) - add_definitions(-DHAVE_OPENMPT) + target_compile_definitions(SRB2SDL2 PRIVATE -DHAVE_OPENMPT) else() message(WARNING "You have specified that OpenMPT is available but it was not found.") endif() @@ -396,8 +101,7 @@ if(${SRB2_CONFIG_HAVE_MIXERX}) endif() if(${MIXERX_FOUND}) set(SRB2_HAVE_MIXERX ON) - set(SRB2_SDL2_SOUNDIMPL mixer_sound.c) - add_definitions(-DHAVE_MIXERX) + target_compile_definitions(SRB2SDL2 PRIVATE -DHAVE_MIXERX) else() message(WARNING "You have specified that SDL Mixer X is available but it was not found.") endif() @@ -417,7 +121,7 @@ if(${SRB2_CONFIG_HAVE_ZLIB}) endif() if(${ZLIB_FOUND}) set(SRB2_HAVE_ZLIB ON) - add_definitions(-DHAVE_ZLIB) + target_compile_definitions(SRB2SDL2 PRIVATE -DHAVE_ZLIB) else() message(WARNING "You have specified that ZLIB is available but it was not found. SRB2 may not compile correctly.") endif() @@ -438,14 +142,9 @@ if(${SRB2_CONFIG_HAVE_PNG} AND ${SRB2_CONFIG_HAVE_ZLIB}) endif() if(${PNG_FOUND}) set(SRB2_HAVE_PNG ON) - add_definitions(-DHAVE_PNG) - add_definitions(-D_LARGEFILE64_SOURCE) - set(SRB2_PNG_SOURCES apng.c) - set(SRB2_PNG_HEADERS apng.h) - prepend_sources(SRB2_PNG_SOURCES) - prepend_sources(SRB2_PNG_HEADERS) - source_group("Main" FILES ${SRB2_CORE_SOURCES} ${SRB2_CORE_HEADERS} - ${SRB2_PNG_SOURCES} ${SRB2_PNG_HEADERS}) + target_compile_definitions(SRB2SDL2 PRIVATE -DHAVE_PNG) + target_compile_definitions(SRB2SDL2 PRIVATE -D_LARGEFILE64_SOURCE) + target_sources(SRB2SDL2 PRIVATE apng.c) else() message(WARNING "You have specified that PNG is available but it was not found. SRB2 may not compile correctly.") endif() @@ -466,7 +165,7 @@ if(${SRB2_CONFIG_HAVE_CURL}) endif() if(${CURL_FOUND}) set(SRB2_HAVE_CURL ON) - add_definitions(-DHAVE_CURL) + target_compile_definitions(SRB2SDL2 PRIVATE -DHAVE_CURL) else() message(WARNING "You have specified that CURL is available but it was not found. SRB2 may not compile correctly.") endif() @@ -474,59 +173,19 @@ endif() if(${SRB2_CONFIG_HAVE_THREADS}) set(SRB2_HAVE_THREADS ON) - set(SRB2_CORE_HEADERS ${SRB2_CORE_HEADERS} ${CMAKE_CURRENT_SOURCE_DIR}/i_threads.h) - add_definitions(-DHAVE_THREADS) + target_compile_definitions(SRB2SDL2 PRIVATE -DHAVE_THREADS) endif() if(${SRB2_CONFIG_HWRENDER}) - add_definitions(-DHWRENDER) - set(SRB2_HWRENDER_SOURCES - ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_batching.c - ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_bsp.c - ${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_light.c - ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_main.c - ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_md2.c - ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_md2load.c - ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_md3load.c - ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_model.c - ${CMAKE_CURRENT_SOURCE_DIR}/hardware/u_list.c - ) - - set (SRB2_HWRENDER_HEADERS - ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_batching.h - ${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_drv.h - ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_glob.h - ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_light.h - ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_main.h - ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_md2.h - ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_md2load.h - ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_md3load.h - ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_model.h - ${CMAKE_CURRENT_SOURCE_DIR}/hardware/u_list.h - ) - - set(SRB2_R_OPENGL_SOURCES - ${CMAKE_CURRENT_SOURCE_DIR}/hardware/r_opengl/r_opengl.c - ) - - set(SRB2_R_OPENGL_HEADERS - ${CMAKE_CURRENT_SOURCE_DIR}/hardware/r_opengl/r_opengl.h - ) - + target_compile_definitions(SRB2SDL2 PRIVATE -DHWRENDER) + add_subdirectory(hardware) endif() if(${SRB2_CONFIG_HWRENDER} AND ${SRB2_CONFIG_STATIC_OPENGL}) find_package(OpenGL) if(${OPENGL_FOUND}) - add_definitions(-DHWRENDER) - add_definitions(-DSTATIC_OPENGL) + target_compile_definitions(SRB2SDL2 PRIVATE -DHWRENDER) + target_compile_definitions(SRB2SDL2 PRIVATE -DSTATIC_OPENGL) else() message(WARNING "You have specified static opengl but opengl was not found. Not setting HWRENDER.") endif() @@ -548,11 +207,11 @@ if(${SRB2_CONFIG_USEASM}) enable_language(ASM_NASM) endif() set(SRB2_USEASM ON) - add_definitions(-DUSEASM) + target_compile_definitions(SRB2SDL2 PRIVATE -DUSEASM) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse3 -mfpmath=sse") else() set(SRB2_USEASM OFF) - add_definitions(-DNONX86 -DNORUSEASM) + target_compile_definitions(SRB2SDL2 PRIVATE -DNONX86 -DNORUSEASM) endif() # Targets @@ -588,7 +247,7 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} -Wno-absolute-value) endif() -add_definitions(-DCMAKECONFIG) +target_compile_definitions(SRB2SDL2 PRIVATE -DCMAKECONFIG) #add_library(SRB2Core STATIC # ${SRB2_CORE_SOURCES} diff --git a/src/blua/CMakeLists.txt b/src/blua/CMakeLists.txt new file mode 100644 index 000000000..4e9c67d2f --- /dev/null +++ b/src/blua/CMakeLists.txt @@ -0,0 +1 @@ +target_sourcefile(c) diff --git a/src/hardware/CMakeLists.txt b/src/hardware/CMakeLists.txt new file mode 100644 index 000000000..4e9c67d2f --- /dev/null +++ b/src/hardware/CMakeLists.txt @@ -0,0 +1 @@ +target_sourcefile(c) diff --git a/src/sdl/CMakeLists.txt b/src/sdl/CMakeLists.txt index a7f015c86..a1d55ad4d 100644 --- a/src/sdl/CMakeLists.txt +++ b/src/sdl/CMakeLists.txt @@ -21,46 +21,25 @@ if(${SRB2_CONFIG_SDL2_USEMIXER}) endif() if(${SDL2_MIXER_FOUND}) set(SRB2_HAVE_MIXER ON) - set(SRB2_SDL2_SOUNDIMPL mixer_sound.c) + target_sources(SRB2SDL2 PRIVATE mixer_sound.c) else() message(WARNING "You specified that SDL2_mixer is available, but it was not found. Falling back to sdl sound.") - set(SRB2_SDL2_SOUNDIMPL sdl_sound.c) + target_sources(SRB2SDL2 PRIVATE sdl_sound.c) endif() elseif(${MIXERX_FOUND}) - set(SRB2_SDL2_SOUNDIMPL mixer_sound.c) + target_sources(SRB2SDL2 PRIVATE mixer_sound.c) else() - set(SRB2_SDL2_SOUNDIMPL sdl_sound.c) + target_sources(SRB2SDL2 PRIVATE sdl_sound.c) endif() -set(SRB2_SDL2_SOURCES - dosstr.c - endtxt.c - hwsym_sdl.c - i_main.c - i_net.c - i_system.c - i_ttf.c - i_video.c - #IMG_xpm.c - ogl_sdl.c +target_sourcefile(c) - ${SRB2_SDL2_SOUNDIMPL} -) - -set(SRB2_SDL2_HEADERS - endtxt.h - hwsym_sdl.h - i_ttf.h - ogl_sdl.h - sdlmain.h -) +target_sources(SRB2SDL2 PRIVATE ogl_sdl.c) if(${SRB2_CONFIG_HAVE_THREADS}) - set(SRB2_SDL2_SOURCES ${SRB2_SDL2_SOURCES} i_threads.c) + target_sources(SRB2SDL2 PRIVATE i_threads.c) endif() -source_group("Interface Code" FILES ${SRB2_SDL2_SOURCES} ${SRB2_SDL2_HEADERS}) - # Dependency if(${SRB2_CONFIG_USE_INTERNAL_LIBRARIES}) set(SDL2_FOUND ON) @@ -76,79 +55,31 @@ else() endif() if(${SDL2_FOUND}) - set(SRB2_SDL2_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_SDL2_SOURCES} - ${SRB2_SDL2_HEADERS} - ) - - source_group("Main" FILES ${SRB2_CORE_SOURCES} ${SRB2_CORE_HEADERS} - ${SRB2_PNG_SOURCES} ${SRB2_PNG_HEADERS}) - source_group("Renderer" FILES ${SRB2_CORE_RENDER_SOURCES}) - source_group("Game" FILES ${SRB2_CORE_GAME_SOURCES}) - source_group("Assembly" FILES ${SRB2_ASM_SOURCES} ${SRB2_NASM_SOURCES}) - source_group("LUA" FILES ${SRB2_LUA_SOURCES} ${SRB2_LUA_HEADERS}) - source_group("LUA\\Interpreter" FILES ${SRB2_BLUA_SOURCES} ${SRB2_BLUA_HEADERS}) - - if(${SRB2_CONFIG_HWRENDER}) - set(SRB2_SDL2_TOTAL_SOURCES ${SRB2_SDL2_TOTAL_SOURCES} - ${SRB2_HWRENDER_SOURCES} - ${SRB2_HWRENDER_HEADERS} - ${SRB2_R_OPENGL_SOURCES} - ${SRB2_R_OPENGL_HEADERS} - ) - - source_group("Hardware" FILES ${SRB2_HWRENDER_SOURCES} ${SRB2_HWRENDER_HEADERS}) - source_group("Hardware\\OpenGL Renderer" FILES ${SRB2_R_OPENGL_SOURCES} ${SRB2_R_OPENGL_HEADERS}) - endif() - if(${SRB2_USEASM}) - set(SRB2_SDL2_TOTAL_SOURCES ${SRB2_SDL2_TOTAL_SOURCES} - ${SRB2_NASM_SOURCES} - ) - if(MSVC) - set(SRB2_SDL2_TOTAL_SOURCES ${SRB2_SDL2_TOTAL_SOURCES} - ${SRB2_NASM_OBJECTS} - ) - set_source_files_properties(${SRB2_NASM_OBJECTS} PROPERTIES GENERATED ON) - else() - list(APPEND SRB2_SDL2_TOTAL_SOURCES ${SRB2_ASM_SOURCES}) - set_source_files_properties(${SRB2_ASM_SOURCES} PROPERTIES LANGUAGE C) - set_source_files_properties(${SRB2_ASM_SOURCES} PROPERTIES COMPILE_FLAGS "-x assembler-with-cpp") - endif() + target_sources(SRB2SDL2 PRIVATE ${SRB2_ASM_SOURCES} + ${SRB2_NASM_SOURCES}) + set_source_files_properties(${SRB2_ASM_SOURCES} PROPERTIES LANGUAGE C) + set_source_files_properties(${SRB2_ASM_SOURCES} PROPERTIES COMPILE_FLAGS "-x assembler-with-cpp") endif() if(${CMAKE_SYSTEM} MATCHES Windows) - set(SRB2_SDL2_TOTAL_SOURCES ${SRB2_SDL2_TOTAL_SOURCES} - ${CMAKE_SOURCE_DIR}/src/win32/win_dbg.c - ${CMAKE_SOURCE_DIR}/src/win32/Srb2win.rc - ) + target_sources(SRB2SDL2 PRIVATE + ../win32/win_dbg.c + ../win32/Srb2win.rc) endif() if(${CMAKE_SYSTEM} MATCHES Darwin) set(MACOSX_BUNDLE_ICON_FILE Srb2mac.icns) set_source_files_properties(macosx/Srb2mac.icns PROPERTIES MACOSX_PACKAGE_LOCATION "Resources") - set(SRB2_SDL2_MAC_SOURCES + target_sources(SRB2SDL2 PRIVATE macosx/mac_alert.c macosx/mac_alert.h macosx/mac_resources.c macosx/mac_resources.h macosx/Srb2mac.icns ) - source_group("Interface Code\\OSX Compatibility" FILES ${SRB2_SDL2_MAC_SOURCES}) - set(SRB2_SDL2_TOTAL_SOURCES ${SRB2_SDL2_TOTAL_SOURCES} ${SRB2_SDL2_MAC_SOURCES}) endif() - add_executable(SRB2SDL2 MACOSX_BUNDLE WIN32 ${SRB2_SDL2_TOTAL_SOURCES}) if(${CMAKE_SYSTEM} MATCHES Windows) set_target_properties(SRB2SDL2 PROPERTIES OUTPUT_NAME srb2win) elseif(${CMAKE_SYSTEM} MATCHES Linux) @@ -205,18 +136,6 @@ if(${SDL2_FOUND}) set(ASM_ASSEMBLER_OBJFORMAT ${CMAKE_ASM_NASM_OBJECT_FORMAT}) set_source_files_properties(${SRB2_NASM_SOURCES} LANGUAGE ASM_NASM) endif() - - if(MSVC) - # using assembler with msvc doesn't work, must do it manually - foreach(ASMFILE ${SRB2_NASM_SOURCES}) - get_filename_component(ASMFILE_NAME ${ASMFILE} NAME_WE) - set(ASMFILE_NAME ${ASMFILE_NAME}.obj) - add_custom_command(TARGET SRB2SDL2 PRE_LINK - COMMAND ${ASM_ASSEMBLER_TEMP} ARGS -f ${ASM_ASSEMBLER_OBJFORMAT} -o ${CMAKE_CURRENT_BINARY_DIR}/${ASMFILE_NAME} ${ASMFILE} - COMMENT "assemble ${ASMFILE_NAME}." - ) - endforeach() - endif() endif() set_target_properties(SRB2SDL2 PROPERTIES VERSION ${SRB2_VERSION}) @@ -230,31 +149,6 @@ if(${SDL2_FOUND}) ) endif() - if(MSVC) - if(${SRB2_CONFIG_USE_INTERNAL_LIBRARIES}) - set(SDL2_MAIN_FOUND ON) - if(${SRB2_SYSTEM_BITS} EQUAL 64) - set(SDL2_MAIN_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/libs/SDL2/x86_64-w64-mingw32/include/SDL2) - set(SDL2_MAIN_LIBRARIES "-L${CMAKE_SOURCE_DIR}/libs/SDL2/x86_64-w64-mingw32/lib -lSDL2main") - else() # 32-bit - set(SDL2_MAIN_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/libs/SDL2/i686-w64-mingw32/include/SDL2) - set(SDL2_MAIN_LIBRARIES "-L${CMAKE_SOURCE_DIR}/libs/SDL2/i686-w64-mingw32/lib -lSDL2main") - endif() - else() - find_package(SDL2_MAIN REQUIRED) - endif() - target_link_libraries(SRB2SDL2 PRIVATE - ${SDL2_MAIN_LIBRARIES} - ) - target_compile_options(SRB2SDL2 PRIVATE - /Umain - /D_CRT_SECURE_NO_WARNINGS # something about string functions. - /D_CRT_NONSTDC_NO_DEPRECATE - /DSDLMAIN - /D_WINSOCK_DEPRECATED_NO_WARNINGS # Don't care - ) - endif() - target_include_directories(SRB2SDL2 PRIVATE ${SDL2_INCLUDE_DIRS} ${SDL2_MIXER_INCLUDE_DIRS} From ec8b63d6759f0c124693ea6d5a521e8d82efd566 Mon Sep 17 00:00:00 2001 From: James R Date: Wed, 5 May 2021 21:21:55 -0700 Subject: [PATCH 0753/1080] Makefile: remove last of unused flags --- src/Makefile.d/nix.mk | 2 +- src/Makefile.d/platform.mk | 4 ++-- src/Makefile.d/sdl.mk | 23 ++--------------------- 3 files changed, 5 insertions(+), 24 deletions(-) diff --git a/src/Makefile.d/nix.mk b/src/Makefile.d/nix.mk index fdcd40d4d..f1645e1e4 100644 --- a/src/Makefile.d/nix.mk +++ b/src/Makefile.d/nix.mk @@ -30,7 +30,7 @@ opts+=-I/usr/X11R6/include -DLINUX -DFREEBSD libs+=-L/usr/X11R6/lib -lipx -lkvm endif -# FIXME +# FIXME: UNTESTED #ifdef SOLARIS #NOIPX=1 #NOASM=1 diff --git a/src/Makefile.d/platform.mk b/src/Makefile.d/platform.mk index 4f110594e..be8d35830 100644 --- a/src/Makefile.d/platform.mk +++ b/src/Makefile.d/platform.mk @@ -33,10 +33,10 @@ endif else ifdef FREEBSD UNIX=1 platform=freebsd -else ifdef SOLARIS # FIXME +else ifdef SOLARIS # FIXME: UNTESTED UNIX=1 platform=solaris -else ifdef CYGWIN32 # FIXME +else ifdef CYGWIN32 # FIXME: UNTESTED nasm_format=win32 platform=cygwin else ifdef MINGW diff --git a/src/Makefile.d/sdl.mk b/src/Makefile.d/sdl.mk index 43a2ffced..99ca624e6 100644 --- a/src/Makefile.d/sdl.mk +++ b/src/Makefile.d/sdl.mk @@ -13,12 +13,12 @@ makedir:=$(makedir)/SDL sources+=$(call List,sdl/Sourcefile) opts+=-DDIRECTFULLSCREEN -DHAVE_SDL -# FIXME +# FIXME: UNTESTED #ifdef PANDORA #include sdl/SRB2Pandora/Makefile.cfg #endif #ifdef PANDORA -# FIXME +# FIXME: UNTESTED #ifdef CYGWIN32 #include sdl/MakeCYG.cfg #endif #ifdef CYGWIN32 @@ -63,25 +63,6 @@ USEASM=1 endif endif -# FIXME -#ifdef SDL_TTF -# OPTS+=-DHAVE_TTF -# SDL_LDFLAGS+=-lSDL2_ttf -lfreetype -lz -# OBJS+=$(OBJDIR)/i_ttf.o -#endif - -# FIXME -#ifdef SDL_IMAGE -# OPTS+=-DHAVE_IMAGE -# SDL_LDFLAGS+=-lSDL2_image -#endif - -# FIXME -#ifdef SDL_NET -# OPTS+=-DHAVE_SDLNET -# SDL_LDFLAGS+=-lSDL2_net -#endif - ifdef MINGW ifndef NOSDLMAIN SDLMAIN=1 From 3159d5a6e490666324278c3b283c1bf8b02b79bb Mon Sep 17 00:00:00 2001 From: Tatsuru <44866610+TatsuruIKR@users.noreply.github.com> Date: Thu, 6 May 2021 21:58:21 -0300 Subject: [PATCH 0754/1080] 2.2.9 prep --- appveyor.yml | 2 +- src/config.h.in | 5 +++-- src/p_enemy.c | 2 +- src/version.h | 4 ++-- src/win32/Srb2win.rc | 4 ++-- 5 files changed, 9 insertions(+), 8 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 2acc2f712..e94a709cd 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,4 +1,4 @@ -version: 2.2.8.{branch}-{build} +version: 2.2.9.{branch}-{build} os: MinGW environment: diff --git a/src/config.h.in b/src/config.h.in index a6f43a7d7..6bdb00bab 100644 --- a/src/config.h.in +++ b/src/config.h.in @@ -34,12 +34,13 @@ * Last updated 2020 / 07 / 10 - v2.2.6 - player.dta & patch.pk3 * Last updated 2020 / 09 / 27 - v2.2.7 - patch.pk3 * Last updated 2020 / 10 / 02 - v2.2.8 - patch.pk3 + * Last updated 2020 / 05 / 06 - v2.2.9 - patch.pk3 & zones.pk3 */ #define ASSET_HASH_SRB2_PK3 "0277c9416756627004e83cbb5b2e3e28" -#define ASSET_HASH_ZONES_PK3 "f7e88afb6af7996a834c7d663144bead" +#define ASSET_HASH_ZONES_PK3 "f8f3e2b5deacf40f14e36686a07d44bb" #define ASSET_HASH_PLAYER_DTA "49dad7b24634c89728cc3e0b689e12bb" #ifdef USE_PATCH_DTA -#define ASSET_HASH_PATCH_PK3 "466cdf60075262b3f5baa5e07f0999e8" +#define ASSET_HASH_PATCH_PK3 "7d467a883f7887b3c311798ee2f56b6a" #endif #endif diff --git a/src/p_enemy.c b/src/p_enemy.c index 59176d6cc..51f18f596 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -4201,7 +4201,7 @@ void A_CustomPower(mobj_t *actor) return; } - if (locvar1 >= NUMPOWERS) + if (locvar1 >= NUMPOWERS || locvar1 < 0) { CONS_Debug(DBG_GAMELOGIC, "Power #%d out of range!\n", locvar1); return; diff --git a/src/version.h b/src/version.h index ece084beb..4470fbd6e 100644 --- a/src/version.h +++ b/src/version.h @@ -1,4 +1,4 @@ -#define SRB2VERSION "2.2.8"/* this must be the first line, for cmake !! */ +#define SRB2VERSION "2.2.9"/* this must be the first line, for cmake !! */ // The Modification ID; must be obtained from a Master Server Admin ( https://mb.srb2.org/showgroups.php ). // DO NOT try to set this otherwise, or your modification will be unplayable through the Master Server. @@ -9,7 +9,7 @@ // it's only for detection of the version the player is using so the MS can alert them of an update. // Only set it higher, not lower, obviously. // Note that we use this to help keep internal testing in check; this is why v2.2.0 is not version "1". -#define MODVERSION 49 +#define MODVERSION 50 // Define this as a prerelease version suffix // #define BETAVERSION "RC1" diff --git a/src/win32/Srb2win.rc b/src/win32/Srb2win.rc index d5d59922c..b0eb2532e 100644 --- a/src/win32/Srb2win.rc +++ b/src/win32/Srb2win.rc @@ -76,8 +76,8 @@ END #include "../doomdef.h" // Needed for version string VS_VERSION_INFO VERSIONINFO - FILEVERSION 2,2,8,0 - PRODUCTVERSION 2,2,8,0 + FILEVERSION 2,2,9,0 + PRODUCTVERSION 2,2,9,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L From 8b021ec16bcd78c566995ca65f5da920cbdd6315 Mon Sep 17 00:00:00 2001 From: lachablock Date: Fri, 7 May 2021 12:38:24 +1000 Subject: [PATCH 0755/1080] but if you close your eyes EH OH, EH OH --- src/config.h.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/config.h.in b/src/config.h.in index 6bdb00bab..db794cccc 100644 --- a/src/config.h.in +++ b/src/config.h.in @@ -34,7 +34,7 @@ * Last updated 2020 / 07 / 10 - v2.2.6 - player.dta & patch.pk3 * Last updated 2020 / 09 / 27 - v2.2.7 - patch.pk3 * Last updated 2020 / 10 / 02 - v2.2.8 - patch.pk3 - * Last updated 2020 / 05 / 06 - v2.2.9 - patch.pk3 & zones.pk3 + * Last updated 2021 / 05 / 06 - v2.2.9 - patch.pk3 & zones.pk3 */ #define ASSET_HASH_SRB2_PK3 "0277c9416756627004e83cbb5b2e3e28" #define ASSET_HASH_ZONES_PK3 "f8f3e2b5deacf40f14e36686a07d44bb" From d325c7e6d314562f79f1890f7d0c5bf5e1496c93 Mon Sep 17 00:00:00 2001 From: LJ Sonic Date: Fri, 7 May 2021 17:45:56 +0200 Subject: [PATCH 0756/1080] The year is 2021 --- src/am_map.c | 2 +- src/am_map.h | 2 +- src/apng.c | 2 +- src/apng.h | 2 +- src/asm_defs.inc | 2 +- src/b_bot.c | 2 +- src/b_bot.h | 2 +- src/byteptr.h | 2 +- src/command.c | 2 +- src/command.h | 2 +- src/console.c | 2 +- src/console.h | 2 +- src/d_clisrv.c | 2 +- src/d_clisrv.h | 2 +- src/d_event.h | 2 +- src/d_main.c | 2 +- src/d_main.h | 2 +- src/d_net.c | 2 +- src/d_net.h | 2 +- src/d_netcmd.c | 2 +- src/d_netcmd.h | 2 +- src/d_netfil.c | 2 +- src/d_netfil.h | 2 +- src/d_player.h | 2 +- src/d_think.h | 2 +- src/d_ticcmd.h | 2 +- src/deh_lua.c | 2 +- src/deh_lua.h | 2 +- src/deh_soc.c | 2 +- src/deh_soc.h | 2 +- src/deh_tables.c | 2 +- src/deh_tables.h | 2 +- src/dehacked.c | 2 +- src/dehacked.h | 2 +- src/doomdata.h | 2 +- src/doomdef.h | 2 +- src/doomstat.h | 2 +- src/doomtype.h | 2 +- src/endian.h | 2 +- src/f_finale.c | 2 +- src/f_finale.h | 2 +- src/f_wipe.c | 2 +- src/g_demo.c | 2 +- src/g_demo.h | 2 +- src/g_game.c | 2 +- src/g_game.h | 2 +- src/g_input.c | 2 +- src/g_input.h | 2 +- src/g_state.h | 2 +- src/hardware/hw_batching.c | 2 +- src/hardware/hw_batching.h | 2 +- src/hardware/hw_cache.c | 2 +- src/hardware/hw_data.h | 2 +- src/hardware/hw_draw.c | 2 +- src/hardware/hw_drv.h | 2 +- src/hardware/hw_glob.h | 2 +- src/hardware/hw_light.h | 2 +- src/hardware/hw_main.h | 2 +- src/hardware/hw_md2.c | 2 +- src/hardware/hw_md2.h | 2 +- src/hardware/r_opengl/r_opengl.c | 2 +- src/http-mserv.c | 2 +- src/hu_stuff.c | 2 +- src/hu_stuff.h | 2 +- src/i_addrinfo.c | 2 +- src/i_addrinfo.h | 2 +- src/i_joy.h | 2 +- src/i_net.h | 2 +- src/i_sound.h | 2 +- src/i_system.h | 2 +- src/i_tcp.c | 2 +- src/i_tcp.h | 2 +- src/i_threads.h | 2 +- src/i_video.h | 2 +- src/info.c | 2 +- src/info.h | 2 +- src/keys.h | 2 +- src/lua_baselib.c | 2 +- src/lua_blockmaplib.c | 4 ++-- src/lua_consolelib.c | 2 +- src/lua_hook.h | 2 +- src/lua_hooklib.c | 2 +- src/lua_hud.h | 2 +- src/lua_hudlib.c | 2 +- src/lua_infolib.c | 2 +- src/lua_libs.h | 2 +- src/lua_maplib.c | 2 +- src/lua_mathlib.c | 2 +- src/lua_mobjlib.c | 2 +- src/lua_playerlib.c | 2 +- src/lua_polyobjlib.c | 4 ++-- src/lua_script.c | 2 +- src/lua_script.h | 2 +- src/lua_skinlib.c | 2 +- src/lua_taglib.c | 4 ++-- src/lua_thinkerlib.c | 2 +- src/m_aatree.c | 2 +- src/m_aatree.h | 2 +- src/m_anigif.c | 2 +- src/m_anigif.h | 2 +- src/m_argv.c | 2 +- src/m_argv.h | 2 +- src/m_bbox.c | 2 +- src/m_bbox.h | 2 +- src/m_cheat.c | 2 +- src/m_cheat.h | 2 +- src/m_cond.c | 2 +- src/m_cond.h | 2 +- src/m_dllist.h | 2 +- src/m_fixed.c | 2 +- src/m_fixed.h | 2 +- src/m_menu.c | 2 +- src/m_menu.h | 2 +- src/m_misc.c | 2 +- src/m_misc.h | 2 +- src/m_perfstats.c | 2 +- src/m_perfstats.h | 2 +- src/m_queue.c | 2 +- src/m_queue.h | 2 +- src/m_random.c | 2 +- src/m_random.h | 2 +- src/m_swap.h | 2 +- src/mserv.c | 4 ++-- src/mserv.h | 4 ++-- src/p_ceilng.c | 2 +- src/p_enemy.c | 2 +- src/p_floor.c | 2 +- src/p_inter.c | 2 +- src/p_lights.c | 2 +- src/p_local.h | 2 +- src/p_map.c | 2 +- src/p_maputl.c | 2 +- src/p_maputl.h | 2 +- src/p_mobj.c | 2 +- src/p_mobj.h | 2 +- src/p_polyobj.c | 2 +- src/p_polyobj.h | 2 +- src/p_pspr.h | 2 +- src/p_saveg.c | 2 +- src/p_saveg.h | 2 +- src/p_setup.c | 2 +- src/p_setup.h | 2 +- src/p_sight.c | 2 +- src/p_slopes.c | 2 +- src/p_slopes.h | 2 +- src/p_spec.c | 2 +- src/p_spec.h | 2 +- src/p_telept.c | 2 +- src/p_tick.c | 2 +- src/p_tick.h | 2 +- src/p_user.c | 2 +- src/r_bsp.c | 2 +- src/r_bsp.h | 2 +- src/r_data.h | 2 +- src/r_defs.h | 2 +- src/r_draw16.c | 2 +- src/r_draw8_npo2.c | 2 +- src/r_local.h | 2 +- src/r_main.c | 2 +- src/r_main.h | 2 +- src/r_patch.c | 2 +- src/r_patch.h | 2 +- src/r_patchrotation.c | 2 +- src/r_patchrotation.h | 2 +- src/r_picformats.c | 4 ++-- src/r_picformats.h | 4 ++-- src/r_plane.h | 2 +- src/r_portal.c | 2 +- src/r_portal.h | 2 +- src/r_segs.c | 2 +- src/r_segs.h | 2 +- src/r_skins.c | 2 +- src/r_skins.h | 2 +- src/r_sky.c | 2 +- src/r_sky.h | 2 +- src/r_splats.h | 2 +- src/r_state.h | 2 +- src/r_textures.h | 2 +- src/r_things.h | 2 +- src/s_sound.c | 2 +- src/s_sound.h | 2 +- src/screen.c | 2 +- src/screen.h | 2 +- src/sdl/i_system.c | 2 +- src/sdl/i_threads.c | 2 +- src/sdl/i_video.c | 2 +- src/sdl/mixer_sound.c | 4 ++-- src/sdl/ogl_sdl.c | 2 +- src/sdl/ogl_sdl.h | 2 +- src/sdl/sdl_sound.c | 2 +- src/sdl/sdlmain.h | 2 +- src/sounds.c | 2 +- src/sounds.h | 2 +- src/st_stuff.c | 2 +- src/st_stuff.h | 2 +- src/strcasestr.c | 2 +- src/string.c | 2 +- src/tables.c | 2 +- src/tables.h | 2 +- src/taglist.c | 4 ++-- src/taglist.h | 4 ++-- src/tmap.nas | 2 +- src/tmap.s | 2 +- src/tmap_asm.s | 2 +- src/tmap_mmx.nas | 2 +- src/tmap_vc.nas | 2 +- src/v_video.c | 2 +- src/v_video.h | 2 +- src/vid_copy.s | 2 +- src/w_wad.c | 2 +- src/w_wad.h | 2 +- src/win32/Srb2win.rc | 2 +- src/y_inter.c | 2 +- src/y_inter.h | 2 +- src/z_zone.c | 2 +- src/z_zone.h | 2 +- 216 files changed, 226 insertions(+), 226 deletions(-) diff --git a/src/am_map.c b/src/am_map.c index 53a7480a5..ef0ebb88c 100644 --- a/src/am_map.c +++ b/src/am_map.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/am_map.h b/src/am_map.h index 1c8fa70e4..022a7208b 100644 --- a/src/am_map.h +++ b/src/am_map.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/apng.c b/src/apng.c index 0abbe541d..36b205c60 100644 --- a/src/apng.c +++ b/src/apng.c @@ -1,5 +1,5 @@ /* -Copyright 2019-2020, James R. +Copyright 2019-2021, James R. All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/src/apng.h b/src/apng.h index a8b5c8f24..893b523cb 100644 --- a/src/apng.h +++ b/src/apng.h @@ -1,5 +1,5 @@ /* -Copyright 2019-2020, James R. +Copyright 2019-2021, James R. All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/src/asm_defs.inc b/src/asm_defs.inc index ec286b0bd..9074f20f8 100644 --- a/src/asm_defs.inc +++ b/src/asm_defs.inc @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/b_bot.c b/src/b_bot.c index d3635f32c..5b4124627 100644 --- a/src/b_bot.c +++ b/src/b_bot.c @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 2007-2016 by John "JTE" Muniz. -// Copyright (C) 2011-2020 by Sonic Team Junior. +// Copyright (C) 2011-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/b_bot.h b/src/b_bot.h index 2806bd68f..9f55637d1 100644 --- a/src/b_bot.h +++ b/src/b_bot.h @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 2007-2016 by John "JTE" Muniz. -// Copyright (C) 2012-2020 by Sonic Team Junior. +// Copyright (C) 2012-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/byteptr.h b/src/byteptr.h index 01a6293b4..4c8414fae 100644 --- a/src/byteptr.h +++ b/src/byteptr.h @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/command.c b/src/command.c index d73cde5c2..95b1fd67d 100644 --- a/src/command.c +++ b/src/command.c @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/command.h b/src/command.h index d4033e6ef..34fd15963 100644 --- a/src/command.h +++ b/src/command.h @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/console.c b/src/console.c index 1560220f6..8c3703dd8 100644 --- a/src/console.c +++ b/src/console.c @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/console.h b/src/console.h index 0296f4f6e..28f40d308 100644 --- a/src/console.h +++ b/src/console.h @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 911a91355..4176b8a11 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/d_clisrv.h b/src/d_clisrv.h index 3d67525da..f3eb52423 100644 --- a/src/d_clisrv.h +++ b/src/d_clisrv.h @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/d_event.h b/src/d_event.h index 3cce8fad1..1fd2e3824 100644 --- a/src/d_event.h +++ b/src/d_event.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/d_main.c b/src/d_main.c index 61510d590..2a608cfc8 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/d_main.h b/src/d_main.h index 81de0634d..943da8418 100644 --- a/src/d_main.h +++ b/src/d_main.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/d_net.c b/src/d_net.c index d534b1b08..9e5abe24a 100644 --- a/src/d_net.c +++ b/src/d_net.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/d_net.h b/src/d_net.h index ea6b5d4d9..dbc6d8ba5 100644 --- a/src/d_net.h +++ b/src/d_net.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 09f9d4651..97a2921a2 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/d_netcmd.h b/src/d_netcmd.h index ac39626a4..fcdd1d4bb 100644 --- a/src/d_netcmd.h +++ b/src/d_netcmd.h @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/d_netfil.c b/src/d_netfil.c index 50dc2ba60..9618c8073 100644 --- a/src/d_netfil.c +++ b/src/d_netfil.c @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/d_netfil.h b/src/d_netfil.h index 158149477..ddcbcfec3 100644 --- a/src/d_netfil.h +++ b/src/d_netfil.h @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/d_player.h b/src/d_player.h index 2e7afed88..54ab34288 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/d_think.h b/src/d_think.h index 4bdac4627..c3f91edc4 100644 --- a/src/d_think.h +++ b/src/d_think.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/d_ticcmd.h b/src/d_ticcmd.h index 2a5ef0981..374585edf 100644 --- a/src/d_ticcmd.h +++ b/src/d_ticcmd.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/deh_lua.c b/src/deh_lua.c index e6a436421..3af97999c 100644 --- a/src/deh_lua.c +++ b/src/deh_lua.c @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/deh_lua.h b/src/deh_lua.h index cd927b9fd..9df4028bd 100644 --- a/src/deh_lua.h +++ b/src/deh_lua.h @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/deh_soc.c b/src/deh_soc.c index 5b12ea1b0..fc764b411 100644 --- a/src/deh_soc.c +++ b/src/deh_soc.c @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/deh_soc.h b/src/deh_soc.h index 2bcb52e70..4064deb3f 100644 --- a/src/deh_soc.h +++ b/src/deh_soc.h @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/deh_tables.c b/src/deh_tables.c index dd6d7d69f..23faf0092 100644 --- a/src/deh_tables.c +++ b/src/deh_tables.c @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/deh_tables.h b/src/deh_tables.h index d094bcbad..1f265cc99 100644 --- a/src/deh_tables.h +++ b/src/deh_tables.h @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/dehacked.c b/src/dehacked.c index c2ea28d27..7d8629567 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/dehacked.h b/src/dehacked.h index 1620314ca..1b200e246 100644 --- a/src/dehacked.h +++ b/src/dehacked.h @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/doomdata.h b/src/doomdata.h index b3f7f5c4d..e317fec1b 100644 --- a/src/doomdata.h +++ b/src/doomdata.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/doomdef.h b/src/doomdef.h index 52abc9597..9dc44d3bb 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/doomstat.h b/src/doomstat.h index 2d28b81af..843202395 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/doomtype.h b/src/doomtype.h index 950f50856..a094cbb08 100644 --- a/src/doomtype.h +++ b/src/doomtype.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/endian.h b/src/endian.h index 24d8e35cd..e78204e72 100644 --- a/src/endian.h +++ b/src/endian.h @@ -1,6 +1,6 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- -// Copyright (C) 2014-2020 by Sonic Team Junior. +// Copyright (C) 2014-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/f_finale.c b/src/f_finale.c index fdcfad279..bfba7cf96 100644 --- a/src/f_finale.c +++ b/src/f_finale.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/f_finale.h b/src/f_finale.h index b3abf1778..4aa2c3f05 100644 --- a/src/f_finale.h +++ b/src/f_finale.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/f_wipe.c b/src/f_wipe.c index 6afb8a6a7..7526aeca3 100644 --- a/src/f_wipe.c +++ b/src/f_wipe.c @@ -3,7 +3,7 @@ // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. // Copyright (C) 2013-2016 by Matthew "Kaito Sinclaire" Walsh. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/g_demo.c b/src/g_demo.c index 593fd7723..ea71c9bd4 100644 --- a/src/g_demo.c +++ b/src/g_demo.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/g_demo.h b/src/g_demo.h index df25042c4..73cf27358 100644 --- a/src/g_demo.h +++ b/src/g_demo.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/g_game.c b/src/g_game.c index 399c4f2bd..9911baab6 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/g_game.h b/src/g_game.h index 744d6755a..98336ad44 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/g_input.c b/src/g_input.c index d3c21e774..357081e1d 100644 --- a/src/g_input.c +++ b/src/g_input.c @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/g_input.h b/src/g_input.h index ce38f6ba9..609141825 100644 --- a/src/g_input.h +++ b/src/g_input.h @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/g_state.h b/src/g_state.h index e364c5a35..589dc6361 100644 --- a/src/g_state.h +++ b/src/g_state.h @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/hardware/hw_batching.c b/src/hardware/hw_batching.c index b13ad03ea..3a8eef55e 100644 --- a/src/hardware/hw_batching.c +++ b/src/hardware/hw_batching.c @@ -1,6 +1,6 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- -// Copyright (C) 2020 by Sonic Team Junior. +// Copyright (C) 2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/hardware/hw_batching.h b/src/hardware/hw_batching.h index 42291a0df..d886dcf2a 100644 --- a/src/hardware/hw_batching.h +++ b/src/hardware/hw_batching.h @@ -1,6 +1,6 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- -// Copyright (C) 2020 by Sonic Team Junior. +// Copyright (C) 2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/hardware/hw_cache.c b/src/hardware/hw_cache.c index 83a4e2e03..317efd320 100644 --- a/src/hardware/hw_cache.c +++ b/src/hardware/hw_cache.c @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/hardware/hw_data.h b/src/hardware/hw_data.h index 7e56a14d0..5aba6a2a9 100644 --- a/src/hardware/hw_data.h +++ b/src/hardware/hw_data.h @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/hardware/hw_draw.c b/src/hardware/hw_draw.c index ba4923d10..e83aff0d7 100644 --- a/src/hardware/hw_draw.c +++ b/src/hardware/hw_draw.c @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/hardware/hw_drv.h b/src/hardware/hw_drv.h index 8cae144ff..d4a586d41 100644 --- a/src/hardware/hw_drv.h +++ b/src/hardware/hw_drv.h @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/hardware/hw_glob.h b/src/hardware/hw_glob.h index 2aba62248..37d77b467 100644 --- a/src/hardware/hw_glob.h +++ b/src/hardware/hw_glob.h @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/hardware/hw_light.h b/src/hardware/hw_light.h index fed7db47f..244cc921f 100644 --- a/src/hardware/hw_light.h +++ b/src/hardware/hw_light.h @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/hardware/hw_main.h b/src/hardware/hw_main.h index 4ad09aa3d..ba6532c38 100644 --- a/src/hardware/hw_main.h +++ b/src/hardware/hw_main.h @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index 5caf344f7..9c3aa9e58 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/hardware/hw_md2.h b/src/hardware/hw_md2.h index 0f4d2c7bc..9249c034c 100644 --- a/src/hardware/hw_md2.h +++ b/src/hardware/hw_md2.h @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index af06a198f..645a3bbae 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -1,6 +1,6 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- -// Copyright (C) 1998-2020 by Sonic Team Junior. +// Copyright (C) 1998-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/http-mserv.c b/src/http-mserv.c index 7c7d04495..0b9eb2f92 100644 --- a/src/http-mserv.c +++ b/src/http-mserv.c @@ -1,6 +1,6 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- -// Copyright (C) 2020 by James R. +// Copyright (C) 2021 by James R. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 7c4f1acf1..0c073866e 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/hu_stuff.h b/src/hu_stuff.h index 63d85f1b8..9b7cee2d3 100644 --- a/src/hu_stuff.h +++ b/src/hu_stuff.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/i_addrinfo.c b/src/i_addrinfo.c index e77774549..79709899e 100644 --- a/src/i_addrinfo.c +++ b/src/i_addrinfo.c @@ -1,6 +1,6 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- -// Copyright (C) 2011-2020 by Sonic Team Junior. +// Copyright (C) 2011-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/i_addrinfo.h b/src/i_addrinfo.h index 7ae006719..397a1969d 100644 --- a/src/i_addrinfo.h +++ b/src/i_addrinfo.h @@ -1,6 +1,6 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- -// Copyright (C) 2011-2020 by Sonic Team Junior. +// Copyright (C) 2011-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/i_joy.h b/src/i_joy.h index 2a2797fc4..0c7c8dd3f 100644 --- a/src/i_joy.h +++ b/src/i_joy.h @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/i_net.h b/src/i_net.h index 5d93f191e..dbc82db65 100644 --- a/src/i_net.h +++ b/src/i_net.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/i_sound.h b/src/i_sound.h index d45c0b323..e38a17626 100644 --- a/src/i_sound.h +++ b/src/i_sound.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/i_system.h b/src/i_system.h index 12f0d751d..b88ea3177 100644 --- a/src/i_system.h +++ b/src/i_system.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/i_tcp.c b/src/i_tcp.c index ab8a69a9f..679553039 100644 --- a/src/i_tcp.c +++ b/src/i_tcp.c @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/i_tcp.h b/src/i_tcp.h index 738b8b4d1..785734415 100644 --- a/src/i_tcp.h +++ b/src/i_tcp.h @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/i_threads.h b/src/i_threads.h index ecb9fce67..924d283c4 100644 --- a/src/i_threads.h +++ b/src/i_threads.h @@ -1,6 +1,6 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- -// Copyright (C) 2020 by James R. +// Copyright (C) 2021 by James R. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/i_video.h b/src/i_video.h index ab48881d4..2d07fcf10 100644 --- a/src/i_video.h +++ b/src/i_video.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/info.c b/src/info.c index ee836a372..bb1279b6b 100644 --- a/src/info.c +++ b/src/info.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/info.h b/src/info.h index 60e970246..031a08b43 100644 --- a/src/info.h +++ b/src/info.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/keys.h b/src/keys.h index 6cdd7956c..b19259320 100644 --- a/src/keys.h +++ b/src/keys.h @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/lua_baselib.c b/src/lua_baselib.c index a265465da..a0c99411b 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 2012-2016 by John "JTE" Muniz. -// Copyright (C) 2012-2020 by Sonic Team Junior. +// Copyright (C) 2012-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/lua_blockmaplib.c b/src/lua_blockmaplib.c index 1949d56bb..9089d19b6 100644 --- a/src/lua_blockmaplib.c +++ b/src/lua_blockmaplib.c @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- -// Copyright (C) 2016-2020 by Iestyn "Monster Iestyn" Jealous. -// Copyright (C) 2016-2020 by Sonic Team Junior. +// Copyright (C) 2016-2021 by Iestyn "Monster Iestyn" Jealous. +// Copyright (C) 2016-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/lua_consolelib.c b/src/lua_consolelib.c index a8ef6b7c0..414d9692a 100644 --- a/src/lua_consolelib.c +++ b/src/lua_consolelib.c @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 2012-2016 by John "JTE" Muniz. -// Copyright (C) 2012-2020 by Sonic Team Junior. +// Copyright (C) 2012-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/lua_hook.h b/src/lua_hook.h index 0d631aa4e..c22309eaa 100644 --- a/src/lua_hook.h +++ b/src/lua_hook.h @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 2012-2016 by John "JTE" Muniz. -// Copyright (C) 2012-2020 by Sonic Team Junior. +// Copyright (C) 2012-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/lua_hooklib.c b/src/lua_hooklib.c index a3f4a95d2..3715aae04 100644 --- a/src/lua_hooklib.c +++ b/src/lua_hooklib.c @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 2012-2016 by John "JTE" Muniz. -// Copyright (C) 2012-2020 by Sonic Team Junior. +// Copyright (C) 2012-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/lua_hud.h b/src/lua_hud.h index 1e9dca00b..a7b1a4cf5 100644 --- a/src/lua_hud.h +++ b/src/lua_hud.h @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 2014-2016 by John "JTE" Muniz. -// Copyright (C) 2014-2020 by Sonic Team Junior. +// Copyright (C) 2014-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/lua_hudlib.c b/src/lua_hudlib.c index 8d451e99c..b0548c321 100644 --- a/src/lua_hudlib.c +++ b/src/lua_hudlib.c @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 2014-2016 by John "JTE" Muniz. -// Copyright (C) 2014-2020 by Sonic Team Junior. +// Copyright (C) 2014-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/lua_infolib.c b/src/lua_infolib.c index 6e86f47b7..af2d99a0c 100644 --- a/src/lua_infolib.c +++ b/src/lua_infolib.c @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 2012-2016 by John "JTE" Muniz. -// Copyright (C) 2012-2020 by Sonic Team Junior. +// Copyright (C) 2012-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/lua_libs.h b/src/lua_libs.h index fbe8d4878..05061f118 100644 --- a/src/lua_libs.h +++ b/src/lua_libs.h @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 2012-2016 by John "JTE" Muniz. -// Copyright (C) 2012-2020 by Sonic Team Junior. +// Copyright (C) 2012-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/lua_maplib.c b/src/lua_maplib.c index 016141796..9031c99f1 100644 --- a/src/lua_maplib.c +++ b/src/lua_maplib.c @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 2012-2016 by John "JTE" Muniz. -// Copyright (C) 2012-2020 by Sonic Team Junior. +// Copyright (C) 2012-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/lua_mathlib.c b/src/lua_mathlib.c index b6046ab53..a1dca9e15 100644 --- a/src/lua_mathlib.c +++ b/src/lua_mathlib.c @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 2012-2016 by John "JTE" Muniz. -// Copyright (C) 2012-2020 by Sonic Team Junior. +// Copyright (C) 2012-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/lua_mobjlib.c b/src/lua_mobjlib.c index 65adceb15..5d5f0e85b 100644 --- a/src/lua_mobjlib.c +++ b/src/lua_mobjlib.c @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 2012-2016 by John "JTE" Muniz. -// Copyright (C) 2012-2020 by Sonic Team Junior. +// Copyright (C) 2012-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/lua_playerlib.c b/src/lua_playerlib.c index 0eb54808f..687cee2eb 100644 --- a/src/lua_playerlib.c +++ b/src/lua_playerlib.c @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 2012-2016 by John "JTE" Muniz. -// Copyright (C) 2012-2020 by Sonic Team Junior. +// Copyright (C) 2012-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/lua_polyobjlib.c b/src/lua_polyobjlib.c index 2a5bcfbf1..cfd6b67d4 100644 --- a/src/lua_polyobjlib.c +++ b/src/lua_polyobjlib.c @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- -// Copyright (C) 2020 by Iestyn "Monster Iestyn" Jealous. -// Copyright (C) 2020 by Sonic Team Junior. +// Copyright (C) 2021 by Iestyn "Monster Iestyn" Jealous. +// Copyright (C) 2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/lua_script.c b/src/lua_script.c index 9f8432832..aa1db3aeb 100644 --- a/src/lua_script.c +++ b/src/lua_script.c @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 2012-2016 by John "JTE" Muniz. -// Copyright (C) 2012-2020 by Sonic Team Junior. +// Copyright (C) 2012-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/lua_script.h b/src/lua_script.h index 89ba7b6ee..a9c8762ad 100644 --- a/src/lua_script.h +++ b/src/lua_script.h @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 2012-2016 by John "JTE" Muniz. -// Copyright (C) 2012-2020 by Sonic Team Junior. +// Copyright (C) 2012-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/lua_skinlib.c b/src/lua_skinlib.c index 7e7480be3..3370f8f72 100644 --- a/src/lua_skinlib.c +++ b/src/lua_skinlib.c @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 2014-2016 by John "JTE" Muniz. -// Copyright (C) 2014-2020 by Sonic Team Junior. +// Copyright (C) 2014-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/lua_taglib.c b/src/lua_taglib.c index c9f320fe8..55abb09cd 100644 --- a/src/lua_taglib.c +++ b/src/lua_taglib.c @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- -// Copyright (C) 2020 by James R. -// Copyright (C) 2020 by Sonic Team Junior. +// Copyright (C) 2021 by James R. +// Copyright (C) 2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/lua_thinkerlib.c b/src/lua_thinkerlib.c index 82baa6469..65bf8c313 100644 --- a/src/lua_thinkerlib.c +++ b/src/lua_thinkerlib.c @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 2012-2016 by John "JTE" Muniz. -// Copyright (C) 2012-2020 by Sonic Team Junior. +// Copyright (C) 2012-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/m_aatree.c b/src/m_aatree.c index c0bb739f8..b228ed63d 100644 --- a/src/m_aatree.c +++ b/src/m_aatree.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/m_aatree.h b/src/m_aatree.h index b784eb17a..5a240394f 100644 --- a/src/m_aatree.h +++ b/src/m_aatree.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/m_anigif.c b/src/m_anigif.c index 41f99254e..fe04a5cb4 100644 --- a/src/m_anigif.c +++ b/src/m_anigif.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 2013-2016 by Matthew "Kaito Sinclaire" Walsh. // Copyright (C) 2013 by "Ninji". -// Copyright (C) 2013-2020 by Sonic Team Junior. +// Copyright (C) 2013-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/m_anigif.h b/src/m_anigif.h index abe05dd96..ca7563b1e 100644 --- a/src/m_anigif.h +++ b/src/m_anigif.h @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 2013-2016 by Matthew "Kaito Sinclaire" Walsh. -// Copyright (C) 2013-2020 by Sonic Team Junior. +// Copyright (C) 2013-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/m_argv.c b/src/m_argv.c index 7d43d96bc..453d6e45c 100644 --- a/src/m_argv.c +++ b/src/m_argv.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/m_argv.h b/src/m_argv.h index 92770f4e9..f39db513f 100644 --- a/src/m_argv.h +++ b/src/m_argv.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/m_bbox.c b/src/m_bbox.c index 02d534164..e0505fd95 100644 --- a/src/m_bbox.c +++ b/src/m_bbox.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/m_bbox.h b/src/m_bbox.h index 9b63c61b6..c56bd22c0 100644 --- a/src/m_bbox.h +++ b/src/m_bbox.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/m_cheat.c b/src/m_cheat.c index 6e0fb8c5c..c958bb4a4 100644 --- a/src/m_cheat.c +++ b/src/m_cheat.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/m_cheat.h b/src/m_cheat.h index ac2540408..ee4ba5f55 100644 --- a/src/m_cheat.h +++ b/src/m_cheat.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/m_cond.c b/src/m_cond.c index 36fcd7cf2..a54238ab2 100644 --- a/src/m_cond.c +++ b/src/m_cond.c @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 2012-2016 by Matthew "Kaito Sinclaire" Walsh. -// Copyright (C) 2012-2020 by Sonic Team Junior. +// Copyright (C) 2012-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/m_cond.h b/src/m_cond.h index 9bb162ff3..690b6fb26 100644 --- a/src/m_cond.h +++ b/src/m_cond.h @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 2012-2016 by Matthew "Kaito Sinclaire" Walsh. -// Copyright (C) 2012-2020 by Sonic Team Junior. +// Copyright (C) 2012-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/m_dllist.h b/src/m_dllist.h index 680c2cd80..65303b4a3 100644 --- a/src/m_dllist.h +++ b/src/m_dllist.h @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 2005 by James Haley -// Copyright (C) 2005-2020 by Sonic Team Junior. +// Copyright (C) 2005-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/m_fixed.c b/src/m_fixed.c index eb10fd5f8..d40ccd98e 100644 --- a/src/m_fixed.c +++ b/src/m_fixed.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/m_fixed.h b/src/m_fixed.h index 289ca442a..73adf52f6 100644 --- a/src/m_fixed.h +++ b/src/m_fixed.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/m_menu.c b/src/m_menu.c index 13531f1b8..496ce6b4c 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -3,7 +3,7 @@ // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. // Copyright (C) 2011-2016 by Matthew "Kaito Sinclaire" Walsh. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/m_menu.h b/src/m_menu.h index 0465128ef..ba9c326a0 100644 --- a/src/m_menu.h +++ b/src/m_menu.h @@ -3,7 +3,7 @@ // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. // Copyright (C) 2011-2016 by Matthew "Kaito Sinclaire" Walsh. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/m_misc.c b/src/m_misc.c index 17a398b83..999ee0961 100644 --- a/src/m_misc.c +++ b/src/m_misc.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/m_misc.h b/src/m_misc.h index c5ef9f9f2..fc5430f01 100644 --- a/src/m_misc.h +++ b/src/m_misc.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/m_perfstats.c b/src/m_perfstats.c index b58599b6d..c4b2044b3 100644 --- a/src/m_perfstats.c +++ b/src/m_perfstats.c @@ -1,6 +1,6 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- -// Copyright (C) 2020 by Sonic Team Junior. +// Copyright (C) 2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/m_perfstats.h b/src/m_perfstats.h index 1ca71957f..8f87146f2 100644 --- a/src/m_perfstats.h +++ b/src/m_perfstats.h @@ -1,6 +1,6 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- -// Copyright (C) 2020 by Sonic Team Junior. +// Copyright (C) 2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/m_queue.c b/src/m_queue.c index 8603ab202..a337ca4ce 100644 --- a/src/m_queue.c +++ b/src/m_queue.c @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 2003 by James Haley -// Copyright (C) 2003-2020 by Sonic Team Junior. +// Copyright (C) 2003-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/m_queue.h b/src/m_queue.h index 3e9579e11..cc64b8dd7 100644 --- a/src/m_queue.h +++ b/src/m_queue.h @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 2003 by James Haley -// Copyright (C) 2003-2020 by Sonic Team Junior. +// Copyright (C) 2003-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/m_random.c b/src/m_random.c index 481fdb72b..6b281fc24 100644 --- a/src/m_random.c +++ b/src/m_random.c @@ -3,7 +3,7 @@ // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. // Copyright (C) 2012-2016 by Matthew "Kaito Sinclaire" Walsh. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/m_random.h b/src/m_random.h index 01190e046..df10b4bb3 100644 --- a/src/m_random.h +++ b/src/m_random.h @@ -3,7 +3,7 @@ // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. // Copyright (C) 2012-2016 by Matthew "Kaito Sinclaire" Walsh. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/m_swap.h b/src/m_swap.h index b44d6de8c..6aa347d97 100644 --- a/src/m_swap.h +++ b/src/m_swap.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/mserv.c b/src/mserv.c index dfb417415..f46a3d444 100644 --- a/src/mserv.c +++ b/src/mserv.c @@ -1,8 +1,8 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. -// Copyright (C) 2020 by James R. +// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 2021 by James R. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/mserv.h b/src/mserv.h index d0d5e49df..ff12fa1f8 100644 --- a/src/mserv.h +++ b/src/mserv.h @@ -1,8 +1,8 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. -// Copyright (C) 2020 by James R. +// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 2021 by James R. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/p_ceilng.c b/src/p_ceilng.c index f12499d5c..ac93e8e2e 100644 --- a/src/p_ceilng.c +++ b/src/p_ceilng.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/p_enemy.c b/src/p_enemy.c index 51f18f596..ca88b7831 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/p_floor.c b/src/p_floor.c index 7c26065b5..d7e417f5c 100644 --- a/src/p_floor.c +++ b/src/p_floor.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/p_inter.c b/src/p_inter.c index e9a16a3dd..380040bc8 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/p_lights.c b/src/p_lights.c index d396e92d3..937808ef1 100644 --- a/src/p_lights.c +++ b/src/p_lights.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/p_local.h b/src/p_local.h index 8568dd4f8..1fcd3050d 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/p_map.c b/src/p_map.c index bf668ba3e..19b999c43 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/p_maputl.c b/src/p_maputl.c index 90718a41c..efcebe736 100644 --- a/src/p_maputl.c +++ b/src/p_maputl.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/p_maputl.h b/src/p_maputl.h index 08b606833..cec344d03 100644 --- a/src/p_maputl.h +++ b/src/p_maputl.h @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/p_mobj.c b/src/p_mobj.c index 49db6daee..690842270 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/p_mobj.h b/src/p_mobj.h index 5bb7c908e..82cd056a8 100644 --- a/src/p_mobj.h +++ b/src/p_mobj.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/p_polyobj.c b/src/p_polyobj.c index 874edbd50..6431e4624 100644 --- a/src/p_polyobj.c +++ b/src/p_polyobj.c @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 2006 by James Haley -// Copyright (C) 2006-2020 by Sonic Team Junior. +// Copyright (C) 2006-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/p_polyobj.h b/src/p_polyobj.h index 8c2946965..7c814e0bf 100644 --- a/src/p_polyobj.h +++ b/src/p_polyobj.h @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 2006 by James Haley -// Copyright (C) 2006-2020 by Sonic Team Junior. +// Copyright (C) 2006-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/p_pspr.h b/src/p_pspr.h index 231262beb..4525ba14c 100644 --- a/src/p_pspr.h +++ b/src/p_pspr.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/p_saveg.c b/src/p_saveg.c index 03229e740..ba4d8a32e 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/p_saveg.h b/src/p_saveg.h index be98953eb..ed9297a4d 100644 --- a/src/p_saveg.h +++ b/src/p_saveg.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/p_setup.c b/src/p_setup.c index 40dd1a284..5a8248a28 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/p_setup.h b/src/p_setup.h index 5d13ae7d4..9fa70d516 100644 --- a/src/p_setup.h +++ b/src/p_setup.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/p_sight.c b/src/p_sight.c index 2e1e49997..e4a37a718 100644 --- a/src/p_sight.c +++ b/src/p_sight.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/p_slopes.c b/src/p_slopes.c index aa46a8402..05955c5d6 100644 --- a/src/p_slopes.c +++ b/src/p_slopes.c @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 2004 by Stephen McGranahan -// Copyright (C) 2015-2020 by Sonic Team Junior. +// Copyright (C) 2015-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/p_slopes.h b/src/p_slopes.h index 46e8dc1e7..ae040ae56 100644 --- a/src/p_slopes.h +++ b/src/p_slopes.h @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 2004 by Stephen McGranahan -// Copyright (C) 2015-2020 by Sonic Team Junior. +// Copyright (C) 2015-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/p_spec.c b/src/p_spec.c index 226e58d15..0bb12cf58 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/p_spec.h b/src/p_spec.h index bba7c4a40..3b8abfcf8 100644 --- a/src/p_spec.h +++ b/src/p_spec.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/p_telept.c b/src/p_telept.c index f6feddf4b..6bac5ad20 100644 --- a/src/p_telept.c +++ b/src/p_telept.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/p_tick.c b/src/p_tick.c index c0a1c5700..9f00ef8dc 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/p_tick.h b/src/p_tick.h index 1fb88f3f2..ae481c6a2 100644 --- a/src/p_tick.h +++ b/src/p_tick.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/p_user.c b/src/p_user.c index 4413cc6cd..29770ccb5 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/r_bsp.c b/src/r_bsp.c index 6f2a90d2d..5acd4e70c 100644 --- a/src/r_bsp.c +++ b/src/r_bsp.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/r_bsp.h b/src/r_bsp.h index e2da8ebaf..40d24ffec 100644 --- a/src/r_bsp.h +++ b/src/r_bsp.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/r_data.h b/src/r_data.h index aec52b54b..571fdc54f 100644 --- a/src/r_data.h +++ b/src/r_data.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/r_defs.h b/src/r_defs.h index 9c649fbc4..1be3a1b8c 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/r_draw16.c b/src/r_draw16.c index 8b1d29e8d..1a2fed773 100644 --- a/src/r_draw16.c +++ b/src/r_draw16.c @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/r_draw8_npo2.c b/src/r_draw8_npo2.c index a34a20e9a..6bb2880b2 100644 --- a/src/r_draw8_npo2.c +++ b/src/r_draw8_npo2.c @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/r_local.h b/src/r_local.h index 4ccb766cf..ba78ea87d 100644 --- a/src/r_local.h +++ b/src/r_local.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/r_main.c b/src/r_main.c index 04bdebc58..be9bbd7d0 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/r_main.h b/src/r_main.h index 2ac6abf5a..f81447c45 100644 --- a/src/r_main.h +++ b/src/r_main.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/r_patch.c b/src/r_patch.c index 1a08d1892..ef41aa574 100644 --- a/src/r_patch.c +++ b/src/r_patch.c @@ -1,6 +1,6 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- -// Copyright (C) 2020 by Jaime "Lactozilla" Passos. +// Copyright (C) 2021 by Jaime "Lactozilla" Passos. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/r_patch.h b/src/r_patch.h index 32bcb3909..d4ca8e6ee 100644 --- a/src/r_patch.h +++ b/src/r_patch.h @@ -1,6 +1,6 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- -// Copyright (C) 2020 by Jaime "Lactozilla" Passos. +// Copyright (C) 2021 by Jaime "Lactozilla" Passos. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/r_patchrotation.c b/src/r_patchrotation.c index 123c4eef2..a6c2b41ce 100644 --- a/src/r_patchrotation.c +++ b/src/r_patchrotation.c @@ -1,6 +1,6 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- -// Copyright (C) 2020 by Jaime "Lactozilla" Passos. +// Copyright (C) 2021 by Jaime "Lactozilla" Passos. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/r_patchrotation.h b/src/r_patchrotation.h index 2744f71d2..c64a08366 100644 --- a/src/r_patchrotation.h +++ b/src/r_patchrotation.h @@ -1,6 +1,6 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- -// Copyright (C) 2020 by Jaime "Lactozilla" Passos. +// Copyright (C) 2021 by Jaime "Lactozilla" Passos. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/r_picformats.c b/src/r_picformats.c index f87362c76..3bbbf82ec 100644 --- a/src/r_picformats.c +++ b/src/r_picformats.c @@ -2,8 +2,8 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 2005-2009 by Andrey "entryway" Budko. -// Copyright (C) 2018-2020 by Jaime "Lactozilla" Passos. -// Copyright (C) 2019-2020 by Sonic Team Junior. +// Copyright (C) 2018-2021 by Jaime "Lactozilla" Passos. +// Copyright (C) 2019-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/r_picformats.h b/src/r_picformats.h index 8d3999013..b1bb35edd 100644 --- a/src/r_picformats.h +++ b/src/r_picformats.h @@ -1,8 +1,8 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. -// Copyright (C) 2018-2020 by Jaime "Lactozilla" Passos. -// Copyright (C) 2019-2020 by Sonic Team Junior. +// Copyright (C) 2018-2021 by Jaime "Lactozilla" Passos. +// Copyright (C) 2019-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/r_plane.h b/src/r_plane.h index 0d11c5b72..748a7f007 100644 --- a/src/r_plane.h +++ b/src/r_plane.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/r_portal.c b/src/r_portal.c index 1aca145ec..3026f4e4c 100644 --- a/src/r_portal.c +++ b/src/r_portal.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/r_portal.h b/src/r_portal.h index e665a26e6..0effd07b5 100644 --- a/src/r_portal.h +++ b/src/r_portal.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/r_segs.c b/src/r_segs.c index a6772f964..c9f9bbfe6 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/r_segs.h b/src/r_segs.h index ace5711d4..da7d44ad4 100644 --- a/src/r_segs.h +++ b/src/r_segs.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/r_skins.c b/src/r_skins.c index 6f150f234..7b6c4517b 100644 --- a/src/r_skins.c +++ b/src/r_skins.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/r_skins.h b/src/r_skins.h index fbbb38743..3f67bfdab 100644 --- a/src/r_skins.h +++ b/src/r_skins.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/r_sky.c b/src/r_sky.c index 7cdcfa44d..041cccfc5 100644 --- a/src/r_sky.c +++ b/src/r_sky.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/r_sky.h b/src/r_sky.h index 55d866b86..f4356dcfa 100644 --- a/src/r_sky.h +++ b/src/r_sky.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/r_splats.h b/src/r_splats.h index 05d8b66b0..cab3d63b6 100644 --- a/src/r_splats.h +++ b/src/r_splats.h @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/r_state.h b/src/r_state.h index 25aa69702..5a606ed8c 100644 --- a/src/r_state.h +++ b/src/r_state.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/r_textures.h b/src/r_textures.h index 74a94a9ed..dd286b6ac 100644 --- a/src/r_textures.h +++ b/src/r_textures.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/r_things.h b/src/r_things.h index 95b4215af..9315b36e9 100644 --- a/src/r_things.h +++ b/src/r_things.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/s_sound.c b/src/s_sound.c index 392a5b453..ea1479cae 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/s_sound.h b/src/s_sound.h index 4ac3c70bf..f736833f9 100644 --- a/src/s_sound.h +++ b/src/s_sound.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/screen.c b/src/screen.c index d37724390..770f1c802 100644 --- a/src/screen.c +++ b/src/screen.c @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/screen.h b/src/screen.h index e4944775d..67880e2b9 100644 --- a/src/screen.h +++ b/src/screen.h @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/sdl/i_system.c b/src/sdl/i_system.c index a0dd6e1da..df29e348b 100644 --- a/src/sdl/i_system.c +++ b/src/sdl/i_system.c @@ -5,7 +5,7 @@ // // Copyright (C) 1993-1996 by id Software, Inc. // Portions Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 2014-2020 by Sonic Team Junior. +// Copyright (C) 2014-2021 by Sonic Team Junior. // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License diff --git a/src/sdl/i_threads.c b/src/sdl/i_threads.c index 3b1c20b9a..bf9668584 100644 --- a/src/sdl/i_threads.c +++ b/src/sdl/i_threads.c @@ -1,6 +1,6 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- -// Copyright (C) 2020 by James R. +// Copyright (C) 2021 by James R. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index 0ed10463f..5f18720f8 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -4,7 +4,7 @@ // // Copyright (C) 1993-1996 by id Software, Inc. // Portions Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 2014-2020 by Sonic Team Junior. +// Copyright (C) 2014-2021 by Sonic Team Junior. // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index 412a21ea0..2f1a87266 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -1,6 +1,6 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- -// Copyright (C) 2014-2020 by Sonic Team Junior. +// Copyright (C) 2014-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -1301,7 +1301,7 @@ boolean I_PlaySong(boolean looping) #if defined (GME_VERSION) && GME_VERSION >= 0x000603 if (looping) gme_set_autoload_playback_limit(gme, 0); -#endif +#endif gme_set_equalizer(gme, &eq); gme_start_track(gme, 0); current_track = 0; diff --git a/src/sdl/ogl_sdl.c b/src/sdl/ogl_sdl.c index 52727c056..c426e6792 100644 --- a/src/sdl/ogl_sdl.c +++ b/src/sdl/ogl_sdl.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 2014-2020 by Sonic Team Junior. +// Copyright (C) 2014-2021 by Sonic Team Junior. // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License diff --git a/src/sdl/ogl_sdl.h b/src/sdl/ogl_sdl.h index 748e30bae..8f87f688e 100644 --- a/src/sdl/ogl_sdl.h +++ b/src/sdl/ogl_sdl.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 2014-2020 by Sonic Team Junior. +// Copyright (C) 2014-2021 by Sonic Team Junior. // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License diff --git a/src/sdl/sdl_sound.c b/src/sdl/sdl_sound.c index 86e294fb5..058b601c3 100644 --- a/src/sdl/sdl_sound.c +++ b/src/sdl/sdl_sound.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // // Copyright (C) 1993-1996 by id Software, Inc. -// Copyright (C) 2014-2020 by Sonic Team Junior. +// Copyright (C) 2014-2021 by Sonic Team Junior. // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License diff --git a/src/sdl/sdlmain.h b/src/sdl/sdlmain.h index e35506114..a9676b5c2 100644 --- a/src/sdl/sdlmain.h +++ b/src/sdl/sdlmain.h @@ -1,7 +1,7 @@ // Emacs style mode select -*- C++ -*- //----------------------------------------------------------------------------- // -// Copyright (C) 2006-2020 by Sonic Team Junior. +// Copyright (C) 2006-2021 by Sonic Team Junior. // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License diff --git a/src/sounds.c b/src/sounds.c index 092bda21f..4c5b11ee9 100644 --- a/src/sounds.c +++ b/src/sounds.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/sounds.h b/src/sounds.h index e49dd2f3e..2dd37953c 100644 --- a/src/sounds.h +++ b/src/sounds.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/st_stuff.c b/src/st_stuff.c index a1fbbec03..a0457ba53 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/st_stuff.h b/src/st_stuff.h index 4ea307d2b..b1ea2942d 100644 --- a/src/st_stuff.h +++ b/src/st_stuff.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/strcasestr.c b/src/strcasestr.c index b266278ed..1cbee286a 100644 --- a/src/strcasestr.c +++ b/src/strcasestr.c @@ -2,7 +2,7 @@ strcasestr -- case insensitive substring searching function. */ /* -Copyright 2019-2020 James R. +Copyright 2019-2021 James R. All rights reserved. Redistribution and use in source forms, with or without modification, is diff --git a/src/string.c b/src/string.c index e430c5cc3..f32025612 100644 --- a/src/string.c +++ b/src/string.c @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 2006 by Graue. -// Copyright (C) 2006-2020 by Sonic Team Junior. +// Copyright (C) 2006-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/tables.c b/src/tables.c index 70a1ecd0a..9263f42d3 100644 --- a/src/tables.c +++ b/src/tables.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/tables.h b/src/tables.h index 953d891ce..baa3adf36 100644 --- a/src/tables.h +++ b/src/tables.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/taglist.c b/src/taglist.c index a759f4d02..1b4a64ecd 100644 --- a/src/taglist.c +++ b/src/taglist.c @@ -1,8 +1,8 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. -// Copyright (C) 2020 by Nev3r. +// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 2021 by Nev3r. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/taglist.h b/src/taglist.h index a0529ab6b..80100f80a 100644 --- a/src/taglist.h +++ b/src/taglist.h @@ -1,8 +1,8 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. -// Copyright (C) 2020 by Nev3r. +// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 2021 by Nev3r. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/tmap.nas b/src/tmap.nas index 69282d0b4..5bf28359e 100644 --- a/src/tmap.nas +++ b/src/tmap.nas @@ -1,7 +1,7 @@ ;; SONIC ROBO BLAST 2 ;;----------------------------------------------------------------------------- ;; Copyright (C) 1998-2000 by DooM Legacy Team. -;; Copyright (C) 1999-2020 by Sonic Team Junior. +;; Copyright (C) 1999-2021 by Sonic Team Junior. ;; ;; This program is free software distributed under the ;; terms of the GNU General Public License, version 2. diff --git a/src/tmap.s b/src/tmap.s index 3a4cf2e1a..62dcf85dc 100644 --- a/src/tmap.s +++ b/src/tmap.s @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/tmap_asm.s b/src/tmap_asm.s index 3cd0f87cc..b5a0a51e9 100644 --- a/src/tmap_asm.s +++ b/src/tmap_asm.s @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/tmap_mmx.nas b/src/tmap_mmx.nas index 15b97499d..8b6ef91a6 100644 --- a/src/tmap_mmx.nas +++ b/src/tmap_mmx.nas @@ -1,7 +1,7 @@ ;; SONIC ROBO BLAST 2 ;;----------------------------------------------------------------------------- ;; Copyright (C) 1998-2000 by DOSDOOM. -;; Copyright (C) 2010-2020 by Sonic Team Junior. +;; Copyright (C) 2010-2021 by Sonic Team Junior. ;; ;; This program is free software distributed under the ;; terms of the GNU General Public License, version 2. diff --git a/src/tmap_vc.nas b/src/tmap_vc.nas index 49eb21a6d..b6ee26e6b 100644 --- a/src/tmap_vc.nas +++ b/src/tmap_vc.nas @@ -1,7 +1,7 @@ ;; SONIC ROBO BLAST 2 ;;----------------------------------------------------------------------------- ;; Copyright (C) 1998-2000 by DooM Legacy Team. -;; Copyright (C) 1999-2020 by Sonic Team Junior. +;; Copyright (C) 1999-2021 by Sonic Team Junior. ;; ;; This program is free software distributed under the ;; terms of the GNU General Public License, version 2. diff --git a/src/v_video.c b/src/v_video.c index 4713db0d8..9cbf6d792 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/v_video.h b/src/v_video.h index 8a18f82ad..7184e799e 100644 --- a/src/v_video.h +++ b/src/v_video.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/vid_copy.s b/src/vid_copy.s index eae435ea4..6a3788356 100644 --- a/src/vid_copy.s +++ b/src/vid_copy.s @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/w_wad.c b/src/w_wad.c index 6149aec6e..cbff5c67b 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/w_wad.h b/src/w_wad.h index d0a86bcb4..130967712 100644 --- a/src/w_wad.h +++ b/src/w_wad.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/win32/Srb2win.rc b/src/win32/Srb2win.rc index b0eb2532e..0a280448b 100644 --- a/src/win32/Srb2win.rc +++ b/src/win32/Srb2win.rc @@ -97,7 +97,7 @@ BEGIN VALUE "FileDescription", "Sonic Robo Blast 2\0" VALUE "FileVersion", VERSIONSTRING_RC VALUE "InternalName", "srb2\0" - VALUE "LegalCopyright", "Copyright 1998-2020 by Sonic Team Junior\0" + VALUE "LegalCopyright", "Copyright 1998-2021 by Sonic Team Junior\0" VALUE "LegalTrademarks", "Sonic the Hedgehog and related characters are trademarks of Sega.\0" VALUE "OriginalFilename", "srb2win.exe\0" VALUE "PrivateBuild", "\0" diff --git a/src/y_inter.c b/src/y_inter.c index 4354a1677..dc78a1983 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -1,6 +1,6 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- -// Copyright (C) 2004-2020 by Sonic Team Junior. +// Copyright (C) 2004-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/y_inter.h b/src/y_inter.h index 7268b1a47..871142858 100644 --- a/src/y_inter.h +++ b/src/y_inter.h @@ -1,6 +1,6 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- -// Copyright (C) 2004-2020 by Sonic Team Junior. +// Copyright (C) 2004-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/z_zone.c b/src/z_zone.c index d7da17e51..34ff3d37e 100644 --- a/src/z_zone.c +++ b/src/z_zone.c @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 2006 by Graue. -// Copyright (C) 2006-2020 by Sonic Team Junior. +// Copyright (C) 2006-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/z_zone.h b/src/z_zone.h index 7b58be8f3..be55bf994 100644 --- a/src/z_zone.h +++ b/src/z_zone.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 1999-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. From 07e69c5eb30d83f229e42db460dd180c3188f9dd Mon Sep 17 00:00:00 2001 From: LJ Sonic Date: Fri, 7 May 2021 18:04:30 +0200 Subject: [PATCH 0757/1080] Add copyright date ranges for files created in 2020 --- src/hardware/hw_batching.c | 2 +- src/hardware/hw_batching.h | 2 +- src/http-mserv.c | 2 +- src/i_threads.h | 2 +- src/lua_polyobjlib.c | 4 ++-- src/lua_taglib.c | 4 ++-- src/m_perfstats.c | 2 +- src/m_perfstats.h | 2 +- src/mserv.c | 2 +- src/mserv.h | 2 +- src/r_patch.c | 2 +- src/r_patch.h | 2 +- src/r_patchrotation.c | 2 +- src/r_patchrotation.h | 2 +- src/sdl/i_threads.c | 2 +- src/taglist.c | 2 +- src/taglist.h | 2 +- 17 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/hardware/hw_batching.c b/src/hardware/hw_batching.c index 3a8eef55e..0ac33d136 100644 --- a/src/hardware/hw_batching.c +++ b/src/hardware/hw_batching.c @@ -1,6 +1,6 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- -// Copyright (C) 2021 by Sonic Team Junior. +// Copyright (C) 2020-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/hardware/hw_batching.h b/src/hardware/hw_batching.h index d886dcf2a..9ccc7de3d 100644 --- a/src/hardware/hw_batching.h +++ b/src/hardware/hw_batching.h @@ -1,6 +1,6 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- -// Copyright (C) 2021 by Sonic Team Junior. +// Copyright (C) 2020-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/http-mserv.c b/src/http-mserv.c index 0b9eb2f92..f9134ba50 100644 --- a/src/http-mserv.c +++ b/src/http-mserv.c @@ -1,6 +1,6 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- -// Copyright (C) 2021 by James R. +// Copyright (C) 2020-2021 by James R. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/i_threads.h b/src/i_threads.h index 924d283c4..bc752181f 100644 --- a/src/i_threads.h +++ b/src/i_threads.h @@ -1,6 +1,6 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- -// Copyright (C) 2021 by James R. +// Copyright (C) 2020-2021 by James R. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/lua_polyobjlib.c b/src/lua_polyobjlib.c index cfd6b67d4..5d76a912d 100644 --- a/src/lua_polyobjlib.c +++ b/src/lua_polyobjlib.c @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- -// Copyright (C) 2021 by Iestyn "Monster Iestyn" Jealous. -// Copyright (C) 2021 by Sonic Team Junior. +// Copyright (C) 2020-2021 by Iestyn "Monster Iestyn" Jealous. +// Copyright (C) 2020-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/lua_taglib.c b/src/lua_taglib.c index 55abb09cd..d0cf385a9 100644 --- a/src/lua_taglib.c +++ b/src/lua_taglib.c @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- -// Copyright (C) 2021 by James R. -// Copyright (C) 2021 by Sonic Team Junior. +// Copyright (C) 2020-2021 by James R. +// Copyright (C) 2020-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/m_perfstats.c b/src/m_perfstats.c index c4b2044b3..8a99312e6 100644 --- a/src/m_perfstats.c +++ b/src/m_perfstats.c @@ -1,6 +1,6 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- -// Copyright (C) 2021 by Sonic Team Junior. +// Copyright (C) 2020-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/m_perfstats.h b/src/m_perfstats.h index 8f87146f2..71208fbc1 100644 --- a/src/m_perfstats.h +++ b/src/m_perfstats.h @@ -1,6 +1,6 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- -// Copyright (C) 2021 by Sonic Team Junior. +// Copyright (C) 2020-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/mserv.c b/src/mserv.c index f46a3d444..f64c7bea9 100644 --- a/src/mserv.c +++ b/src/mserv.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. // Copyright (C) 1999-2021 by Sonic Team Junior. -// Copyright (C) 2021 by James R. +// Copyright (C) 2020-2021 by James R. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/mserv.h b/src/mserv.h index ff12fa1f8..7a3b3d8ec 100644 --- a/src/mserv.h +++ b/src/mserv.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. // Copyright (C) 1999-2021 by Sonic Team Junior. -// Copyright (C) 2021 by James R. +// Copyright (C) 2020-2021 by James R. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/r_patch.c b/src/r_patch.c index ef41aa574..6827cd12c 100644 --- a/src/r_patch.c +++ b/src/r_patch.c @@ -1,6 +1,6 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- -// Copyright (C) 2021 by Jaime "Lactozilla" Passos. +// Copyright (C) 2020-2021 by Jaime "Lactozilla" Passos. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/r_patch.h b/src/r_patch.h index d4ca8e6ee..96fbb0e28 100644 --- a/src/r_patch.h +++ b/src/r_patch.h @@ -1,6 +1,6 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- -// Copyright (C) 2021 by Jaime "Lactozilla" Passos. +// Copyright (C) 2020-2021 by Jaime "Lactozilla" Passos. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/r_patchrotation.c b/src/r_patchrotation.c index a6c2b41ce..a9b4a2b8f 100644 --- a/src/r_patchrotation.c +++ b/src/r_patchrotation.c @@ -1,6 +1,6 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- -// Copyright (C) 2021 by Jaime "Lactozilla" Passos. +// Copyright (C) 2020-2021 by Jaime "Lactozilla" Passos. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/r_patchrotation.h b/src/r_patchrotation.h index c64a08366..689b7d411 100644 --- a/src/r_patchrotation.h +++ b/src/r_patchrotation.h @@ -1,6 +1,6 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- -// Copyright (C) 2021 by Jaime "Lactozilla" Passos. +// Copyright (C) 2020-2021 by Jaime "Lactozilla" Passos. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/sdl/i_threads.c b/src/sdl/i_threads.c index bf9668584..f73d00bcf 100644 --- a/src/sdl/i_threads.c +++ b/src/sdl/i_threads.c @@ -1,6 +1,6 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- -// Copyright (C) 2021 by James R. +// Copyright (C) 2020-2021 by James R. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/taglist.c b/src/taglist.c index 1b4a64ecd..28fa48c25 100644 --- a/src/taglist.c +++ b/src/taglist.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. // Copyright (C) 1999-2021 by Sonic Team Junior. -// Copyright (C) 2021 by Nev3r. +// Copyright (C) 2020-2021 by Nev3r. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/taglist.h b/src/taglist.h index 80100f80a..146d76131 100644 --- a/src/taglist.h +++ b/src/taglist.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. // Copyright (C) 1999-2021 by Sonic Team Junior. -// Copyright (C) 2021 by Nev3r. +// Copyright (C) 2020-2021 by Nev3r. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. From 8e8881b534e5844e45a06f9bdbfb3f6728a8f9cd Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Fri, 7 May 2021 14:14:31 -0400 Subject: [PATCH 0758/1080] Fix custom title card text not looping properly --- 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 a1fbbec03..5f7307b58 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -1367,7 +1367,7 @@ void ST_drawTitleCard(void) zzticker = lt_ticker; V_DrawMappedPatch(FixedInt(lt_zigzag), (-zzticker) % zigzag->height, V_SNAPTOTOP|V_SNAPTOLEFT, zigzag, colormap); V_DrawMappedPatch(FixedInt(lt_zigzag), (zigzag->height-zzticker) % zigzag->height, V_SNAPTOTOP|V_SNAPTOLEFT, zigzag, colormap); - V_DrawMappedPatch(FixedInt(lt_zigzag), (-zigzag->height+zzticker) % zztext->height, V_SNAPTOTOP|V_SNAPTOLEFT, zztext, colormap); + V_DrawMappedPatch(FixedInt(lt_zigzag), (-zztext->height+zzticker) % zztext->height, V_SNAPTOTOP|V_SNAPTOLEFT, zztext, colormap); V_DrawMappedPatch(FixedInt(lt_zigzag), (zzticker) % zztext->height, V_SNAPTOTOP|V_SNAPTOLEFT, zztext, colormap); } From 44782654001339da3ec60e3b31772b198cd11d03 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Fri, 7 May 2021 14:15:37 -0400 Subject: [PATCH 0759/1080] Fix title card patches not actually having enough room for an entire lump name --- src/doomstat.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/doomstat.h b/src/doomstat.h index 2d28b81af..ee6756759 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -337,9 +337,9 @@ typedef struct fixed_t gravity; ///< Map-wide gravity. // Title card. - char ltzzpatch[8]; ///< Zig zag patch. - char ltzztext[8]; ///< Zig zag text. - char ltactdiamond[8]; ///< Act diamond. + char ltzzpatch[9]; ///< Zig zag patch. + char ltzztext[9]; ///< Zig zag text. + char ltactdiamond[9]; ///< Act diamond. // Freed animals stuff. UINT8 numFlickies; ///< Internal. For freed flicky support. From c06817d0085ee77b0027917bca91a24e60c7deba Mon Sep 17 00:00:00 2001 From: James R Date: Fri, 7 May 2021 15:30:46 -0700 Subject: [PATCH 0760/1080] Makefile: fix mingw/64 swapped with 32-bit --- src/Makefile.d/platform.mk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Makefile.d/platform.mk b/src/Makefile.d/platform.mk index be8d35830..f13488823 100644 --- a/src/Makefile.d/platform.mk +++ b/src/Makefile.d/platform.mk @@ -47,9 +47,9 @@ NOASM=1 # but we make that assumption elsewhere # Once that changes, remove this X86_64=1 -platform=mingw -else platform=mingw/64 +else +platform=mingw endif include Makefile.d/win32.mk endif From 9e7d80c2c44199126fa451c59fca0f98d23ad14d Mon Sep 17 00:00:00 2001 From: James R Date: Fri, 7 May 2021 16:08:24 -0700 Subject: [PATCH 0761/1080] Makefile: suppress DEL error --- src/Makefile.d/platform.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Makefile.d/platform.mk b/src/Makefile.d/platform.mk index f13488823..531d073e9 100644 --- a/src/Makefile.d/platform.mk +++ b/src/Makefile.d/platform.mk @@ -5,7 +5,7 @@ PKG_CONFIG?=pkg-config ifdef WINDOWSHELL -rmrf=2>NUL DEL /S /Q +rmrf=-2>NUL DEL /S /Q mkdir=-2>NUL MD else rmrf=rm -rf From dc6851dabc376a939673fadac8bacc903e74127e Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Thu, 6 May 2021 17:41:43 -0400 Subject: [PATCH 0762/1080] Save skin name instead of skin number into save files Allows you to save a game as any character, and you don't have to load the files in a specific order to access the save file. --- src/g_game.c | 25 +++++++++++- src/m_menu.c | 105 ++++++++++++++++++++++++++++++++++++++------------ src/p_saveg.c | 49 ++++++++++++++++++++--- src/p_saveg.h | 2 + 4 files changed, 150 insertions(+), 31 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index 399c4f2bd..08d07dbbb 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -4619,6 +4619,9 @@ void G_SaveGameOver(UINT32 slot, boolean modifylives) UINT8 *end_p = savebuffer + length; UINT8 *lives_p; SINT8 pllives; +#ifdef NEWSKINSAVES + INT16 backwardsCompat = 0; +#endif save_p = savebuffer; // Version check @@ -4637,9 +4640,29 @@ void G_SaveGameOver(UINT32 slot, boolean modifylives) // P_UnArchivePlayer() CHECKPOS - (void)READUINT16(save_p); +#ifdef NEWSKINSAVES + backwardsCompat = READUINT16(save_p); CHECKPOS + if (backwardsCompat == NEWSKINSAVES) // New save, read skin names +#endif + { + boolean haveBot = false; + char ourSkinName[SKINNAMESIZE+1]; + + READSTRINGN(save_p, ourSkinName, SKINNAMESIZE); + CHECKPOS + haveBot = (boolean)READUINT8(save_p); + CHECKPOS + + if (haveBot == true) + { + char botSkinName[SKINNAMESIZE+1]; + READSTRINGN(save_p, botSkinName, SKINNAMESIZE); + CHECKPOS + } + } + WRITEUINT8(save_p, numgameovers); CHECKPOS diff --git a/src/m_menu.c b/src/m_menu.c index 40215090c..03487e2fa 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -62,6 +62,8 @@ #include "i_joy.h" // for joystick menu controls +#include "p_saveg.h" // Only for NEWSKINSAVES + // Condition Sets #include "m_cond.h" @@ -8580,7 +8582,7 @@ static void M_LoadSelect(INT32 choice) #define VERSIONSIZE 16 #define BADSAVE { savegameinfo[slot].lives = -666; Z_Free(savebuffer); return; } -#define CHECKPOS if (save_p >= end_p) BADSAVE +#define CHECKPOS if (sav_p >= end_p) BADSAVE // Reads the save file to list lives, level, player, etc. // Tails 05-29-2003 static void M_ReadSavegameInfo(UINT32 slot) @@ -8589,10 +8591,13 @@ static void M_ReadSavegameInfo(UINT32 slot) char savename[255]; UINT8 *savebuffer; UINT8 *end_p; // buffer end point, don't read past here - UINT8 *save_p; + UINT8 *sav_p; INT32 fake; // Dummy variable char temp[sizeof(timeattackfolder)]; char vcheck[VERSIONSIZE]; +#ifdef NEWSKINSAVES + INT16 backwardsCompat = 0; +#endif sprintf(savename, savegamename, slot); @@ -8608,19 +8613,19 @@ static void M_ReadSavegameInfo(UINT32 slot) end_p = savebuffer + length; // skip the description field - save_p = savebuffer; + sav_p = savebuffer; // Version check memset(vcheck, 0, sizeof (vcheck)); sprintf(vcheck, "version %d", VERSION); - if (strcmp((const char *)save_p, (const char *)vcheck)) BADSAVE - save_p += VERSIONSIZE; + if (strcmp((const char *)sav_p, (const char *)vcheck)) BADSAVE + sav_p += VERSIONSIZE; // dearchive all the modifications // P_UnArchiveMisc() CHECKPOS - fake = READINT16(save_p); + fake = READINT16(sav_p); if (((fake-1) & 8191) >= NUMMAPS) BADSAVE @@ -8637,54 +8642,104 @@ static void M_ReadSavegameInfo(UINT32 slot) savegameinfo[slot].gamemap = fake; CHECKPOS - savegameinfo[slot].numemeralds = READUINT16(save_p)-357; // emeralds + savegameinfo[slot].numemeralds = READUINT16(sav_p)-357; // emeralds CHECKPOS - READSTRINGN(save_p, temp, sizeof(temp)); // mod it belongs to + READSTRINGN(sav_p, temp, sizeof(temp)); // mod it belongs to if (strcmp(temp, timeattackfolder)) BADSAVE // P_UnArchivePlayer() +#ifdef NEWSKINSAVES CHECKPOS - fake = READUINT16(save_p); - savegameinfo[slot].skinnum = fake & ((1<<5) - 1); - if (savegameinfo[slot].skinnum >= numskins - || !R_SkinUsable(-1, savegameinfo[slot].skinnum)) - BADSAVE - savegameinfo[slot].botskin = fake >> 5; - if (savegameinfo[slot].botskin-1 >= numskins - || !R_SkinUsable(-1, savegameinfo[slot].botskin-1)) - BADSAVE + backwardsCompat = READUINT16(sav_p); + + if (backwardsCompat != NEWSKINSAVES) + { + CONS_Printf("Old behavior for %d\n", slot); + + // Backwards compat + savegameinfo[slot].skinnum = backwardsCompat & ((1<<5) - 1); + + if (savegameinfo[slot].skinnum >= numskins + || !R_SkinUsable(-1, savegameinfo[slot].skinnum)) + BADSAVE + + CONS_Printf("Read skinnum successfully\n"); + + savegameinfo[slot].botskin = backwardsCompat >> 5; + if (savegameinfo[slot].botskin-1 >= numskins + || !R_SkinUsable(-1, savegameinfo[slot].botskin-1)) + BADSAVE + + CONS_Printf("Read botskin successfully\n"); + } + else +#endif + { + boolean haveBot = false; + char ourSkinName[SKINNAMESIZE+1]; + + CONS_Printf("New behavior for %d\n", slot); + + CHECKPOS + READSTRINGN(sav_p, ourSkinName, SKINNAMESIZE); + savegameinfo[slot].skinnum = R_SkinAvailable(ourSkinName); + + if (savegameinfo[slot].skinnum >= numskins + || !R_SkinUsable(-1, savegameinfo[slot].skinnum)) + BADSAVE + + CONS_Printf("Read skinnum successfully\n"); + + CHECKPOS + haveBot = (boolean)READUINT8(sav_p); + + if (haveBot == true) + { + char botSkinName[SKINNAMESIZE+1]; + + CHECKPOS + READSTRINGN(sav_p, botSkinName, SKINNAMESIZE); + savegameinfo[slot].botskin = (R_SkinAvailable(botSkinName) + 1); + + if (savegameinfo[slot].botskin-1 >= numskins + || !R_SkinUsable(-1, savegameinfo[slot].botskin-1)) + BADSAVE + } + + CONS_Printf("Read botskin successfully\n"); + } CHECKPOS - savegameinfo[slot].numgameovers = READUINT8(save_p); // numgameovers + savegameinfo[slot].numgameovers = READUINT8(sav_p); // numgameovers CHECKPOS - savegameinfo[slot].lives = READSINT8(save_p); // lives + savegameinfo[slot].lives = READSINT8(sav_p); // lives CHECKPOS - savegameinfo[slot].continuescore = READINT32(save_p); // score + savegameinfo[slot].continuescore = READINT32(sav_p); // score CHECKPOS - fake = READINT32(save_p); // continues + fake = READINT32(sav_p); // continues if (useContinues) savegameinfo[slot].continuescore = fake; // File end marker check CHECKPOS - switch (READUINT8(save_p)) + switch (READUINT8(sav_p)) { case 0xb7: { UINT8 i, banksinuse; CHECKPOS - banksinuse = READUINT8(save_p); + banksinuse = READUINT8(sav_p); CHECKPOS if (banksinuse > NUM_LUABANKS) BADSAVE for (i = 0; i < banksinuse; i++) { - (void)READINT32(save_p); + (void)READINT32(sav_p); CHECKPOS } - if (READUINT8(save_p) != 0x1d) + if (READUINT8(sav_p) != 0x1d) BADSAVE } case 0x1d: diff --git a/src/p_saveg.c b/src/p_saveg.c index 818596cac..cd9235e05 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -64,12 +64,26 @@ typedef enum static inline void P_ArchivePlayer(void) { const player_t *player = &players[consoleplayer]; - INT16 skininfo = player->skin + (botskin<<5); SINT8 pllives = player->lives; if (pllives < startinglivesbalance[numgameovers]) // Bump up to 3 lives if the player pllives = startinglivesbalance[numgameovers]; // has less than that. - WRITEUINT16(save_p, skininfo); +#ifdef NEWSKINSAVES + WRITEUINT16(save_p, NEWSKINSAVES); +#endif + + WRITESTRINGN(save_p, skins[player->skin].name, SKINNAMESIZE); + + if (botskin != 0) + { + WRITEUINT8(save_p, 1); + WRITESTRINGN(save_p, skins[botskin-1].name, SKINNAMESIZE); + } + else + { + WRITEUINT8(save_p, 0); + } + WRITEUINT8(save_p, numgameovers); WRITESINT8(save_p, pllives); WRITEUINT32(save_p, player->score); @@ -78,9 +92,34 @@ static inline void P_ArchivePlayer(void) static inline void P_UnArchivePlayer(void) { - INT16 skininfo = READUINT16(save_p); - savedata.skin = skininfo & ((1<<5) - 1); - savedata.botskin = skininfo >> 5; +#ifdef NEWSKINSAVES + INT16 backwardsCompat = READUINT16(save_p); + + if (backwardsCompat != NEWSKINSAVES) + { + // Backwards compat + savedata.skin = backwardsCompat & ((1<<5) - 1); + savedata.botskin = backwardsCompat >> 5; + } + else +#endif + { + boolean haveBot = false; + char ourSkinName[SKINNAMESIZE+1]; + + READSTRINGN(save_p, ourSkinName, SKINNAMESIZE); + savedata.skin = R_SkinAvailable(ourSkinName); + + haveBot = (boolean)READUINT8(save_p); + + if (haveBot == true) + { + char botSkinName[SKINNAMESIZE+1]; + + READSTRINGN(save_p, botSkinName, SKINNAMESIZE); + savedata.botskin = R_SkinAvailable(botSkinName) + 1; + } + } savedata.numgameovers = READUINT8(save_p); savedata.lives = READSINT8(save_p); diff --git a/src/p_saveg.h b/src/p_saveg.h index be98953eb..1649d32d7 100644 --- a/src/p_saveg.h +++ b/src/p_saveg.h @@ -18,6 +18,8 @@ #pragma interface #endif +#define NEWSKINSAVES (INT16_MAX) // Purely for backwards compatibility, remove this for 2.3 + // Persistent storage/archiving. // These are the load / save game routines. From a5830270062f6a2e34c041eed2ba096546dafc33 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Fri, 7 May 2021 19:52:29 -0400 Subject: [PATCH 0763/1080] Remove prints --- src/m_menu.c | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index 03487e2fa..b72ba0be4 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -8656,8 +8656,6 @@ static void M_ReadSavegameInfo(UINT32 slot) if (backwardsCompat != NEWSKINSAVES) { - CONS_Printf("Old behavior for %d\n", slot); - // Backwards compat savegameinfo[slot].skinnum = backwardsCompat & ((1<<5) - 1); @@ -8665,14 +8663,10 @@ static void M_ReadSavegameInfo(UINT32 slot) || !R_SkinUsable(-1, savegameinfo[slot].skinnum)) BADSAVE - CONS_Printf("Read skinnum successfully\n"); - savegameinfo[slot].botskin = backwardsCompat >> 5; if (savegameinfo[slot].botskin-1 >= numskins || !R_SkinUsable(-1, savegameinfo[slot].botskin-1)) BADSAVE - - CONS_Printf("Read botskin successfully\n"); } else #endif @@ -8680,8 +8674,6 @@ static void M_ReadSavegameInfo(UINT32 slot) boolean haveBot = false; char ourSkinName[SKINNAMESIZE+1]; - CONS_Printf("New behavior for %d\n", slot); - CHECKPOS READSTRINGN(sav_p, ourSkinName, SKINNAMESIZE); savegameinfo[slot].skinnum = R_SkinAvailable(ourSkinName); @@ -8690,8 +8682,6 @@ static void M_ReadSavegameInfo(UINT32 slot) || !R_SkinUsable(-1, savegameinfo[slot].skinnum)) BADSAVE - CONS_Printf("Read skinnum successfully\n"); - CHECKPOS haveBot = (boolean)READUINT8(sav_p); @@ -8707,8 +8697,6 @@ static void M_ReadSavegameInfo(UINT32 slot) || !R_SkinUsable(-1, savegameinfo[slot].botskin-1)) BADSAVE } - - CONS_Printf("Read botskin successfully\n"); } CHECKPOS From d136c60a3fa9f73a7ae0f26d0552f67b4d5f0d8e Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Fri, 7 May 2021 20:13:16 -0400 Subject: [PATCH 0764/1080] Add some comments, write an empty string instead of a boolean determining if the bot skin exists or not. I was a little scared of doing this at first, but after a bit of thought & some testing that it'll be fine. --- src/g_game.c | 12 +++--------- src/m_menu.c | 20 ++++++-------------- src/p_saveg.c | 22 +++++++++------------- 3 files changed, 18 insertions(+), 36 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index 08d07dbbb..ad60fe47a 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -4647,20 +4647,14 @@ void G_SaveGameOver(UINT32 slot, boolean modifylives) if (backwardsCompat == NEWSKINSAVES) // New save, read skin names #endif { - boolean haveBot = false; char ourSkinName[SKINNAMESIZE+1]; + char botSkinName[SKINNAMESIZE+1]; READSTRINGN(save_p, ourSkinName, SKINNAMESIZE); CHECKPOS - haveBot = (boolean)READUINT8(save_p); - CHECKPOS - if (haveBot == true) - { - char botSkinName[SKINNAMESIZE+1]; - READSTRINGN(save_p, botSkinName, SKINNAMESIZE); - CHECKPOS - } + READSTRINGN(save_p, botSkinName, SKINNAMESIZE); + CHECKPOS } WRITEUINT8(save_p, numgameovers); diff --git a/src/m_menu.c b/src/m_menu.c index b72ba0be4..2cbbe400f 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -8671,8 +8671,8 @@ static void M_ReadSavegameInfo(UINT32 slot) else #endif { - boolean haveBot = false; char ourSkinName[SKINNAMESIZE+1]; + char botSkinName[SKINNAMESIZE+1]; CHECKPOS READSTRINGN(sav_p, ourSkinName, SKINNAMESIZE); @@ -8683,20 +8683,12 @@ static void M_ReadSavegameInfo(UINT32 slot) BADSAVE CHECKPOS - haveBot = (boolean)READUINT8(sav_p); + READSTRINGN(sav_p, botSkinName, SKINNAMESIZE); + savegameinfo[slot].botskin = (R_SkinAvailable(botSkinName) + 1); - if (haveBot == true) - { - char botSkinName[SKINNAMESIZE+1]; - - CHECKPOS - READSTRINGN(sav_p, botSkinName, SKINNAMESIZE); - savegameinfo[slot].botskin = (R_SkinAvailable(botSkinName) + 1); - - if (savegameinfo[slot].botskin-1 >= numskins - || !R_SkinUsable(-1, savegameinfo[slot].botskin-1)) - BADSAVE - } + if (savegameinfo[slot].botskin-1 >= numskins + || !R_SkinUsable(-1, savegameinfo[slot].botskin-1)) + BADSAVE } CHECKPOS diff --git a/src/p_saveg.c b/src/p_saveg.c index cd9235e05..abfd4b905 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -69,19 +69,22 @@ static inline void P_ArchivePlayer(void) pllives = startinglivesbalance[numgameovers]; // has less than that. #ifdef NEWSKINSAVES + // Write a specific value into the old skininfo location. + // If we read something other than this, it's an older save file that used skin numbers. WRITEUINT16(save_p, NEWSKINSAVES); #endif + // Write skin names, so that loading skins in different orders + // doesn't change who the save file is for! WRITESTRINGN(save_p, skins[player->skin].name, SKINNAMESIZE); if (botskin != 0) { - WRITEUINT8(save_p, 1); WRITESTRINGN(save_p, skins[botskin-1].name, SKINNAMESIZE); } else { - WRITEUINT8(save_p, 0); + WRITESTRINGN(save_p, "\0", SKINNAMESIZE); } WRITEUINT8(save_p, numgameovers); @@ -97,28 +100,21 @@ static inline void P_UnArchivePlayer(void) if (backwardsCompat != NEWSKINSAVES) { - // Backwards compat + // This is an older save file, which used direct skin numbers. savedata.skin = backwardsCompat & ((1<<5) - 1); savedata.botskin = backwardsCompat >> 5; } else #endif { - boolean haveBot = false; char ourSkinName[SKINNAMESIZE+1]; + char botSkinName[SKINNAMESIZE+1]; READSTRINGN(save_p, ourSkinName, SKINNAMESIZE); savedata.skin = R_SkinAvailable(ourSkinName); - haveBot = (boolean)READUINT8(save_p); - - if (haveBot == true) - { - char botSkinName[SKINNAMESIZE+1]; - - READSTRINGN(save_p, botSkinName, SKINNAMESIZE); - savedata.botskin = R_SkinAvailable(botSkinName) + 1; - } + READSTRINGN(save_p, botSkinName, SKINNAMESIZE); + savedata.botskin = R_SkinAvailable(botSkinName) + 1; } savedata.numgameovers = READUINT8(save_p); From 87afa7655a71539c7cbc7db12df18c4253187fbc Mon Sep 17 00:00:00 2001 From: James R Date: Fri, 7 May 2021 18:57:46 -0700 Subject: [PATCH 0765/1080] CMake: fix ASM compile - target_sources from correct directory - enable_language must be used in add_executable directory --- CMakeLists.txt | 2 -- src/CMakeLists.txt | 6 ++++++ src/sdl/CMakeLists.txt | 2 -- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bc764fc87..6f901d3d7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -117,8 +117,6 @@ set(SRB2_SDL2_EXE_NAME srb2 CACHE STRING "Executable binary output name") include_directories(${CMAKE_CURRENT_BINARY_DIR}/src) -add_executable(SRB2SDL2 MACOSX_BUNDLE WIN32) - add_subdirectory(src) add_subdirectory(assets) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 0148d605f..3b690a20a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,5 +1,7 @@ # SRB2 Core +add_executable(SRB2SDL2 MACOSX_BUNDLE WIN32) + # Core sources target_sourcefile(c) target_sources(SRB2SDL2 PRIVATE comptime.c md5.c config.h) @@ -206,9 +208,13 @@ if(${SRB2_CONFIG_USEASM}) set(CMAKE_ASM_NASM_FLAGS "${SRB2_ASM_FLAGS}" CACHE STRING "Flags used by the assembler during all build types.") enable_language(ASM_NASM) endif() + set(SRB2_USEASM ON) target_compile_definitions(SRB2SDL2 PRIVATE -DUSEASM) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse3 -mfpmath=sse") + + target_sources(SRB2SDL2 PRIVATE ${SRB2_ASM_SOURCES} + ${SRB2_NASM_SOURCES}) else() set(SRB2_USEASM OFF) target_compile_definitions(SRB2SDL2 PRIVATE -DNONX86 -DNORUSEASM) diff --git a/src/sdl/CMakeLists.txt b/src/sdl/CMakeLists.txt index a1d55ad4d..4f19d93df 100644 --- a/src/sdl/CMakeLists.txt +++ b/src/sdl/CMakeLists.txt @@ -56,8 +56,6 @@ endif() if(${SDL2_FOUND}) if(${SRB2_USEASM}) - target_sources(SRB2SDL2 PRIVATE ${SRB2_ASM_SOURCES} - ${SRB2_NASM_SOURCES}) set_source_files_properties(${SRB2_ASM_SOURCES} PROPERTIES LANGUAGE C) set_source_files_properties(${SRB2_ASM_SOURCES} PROPERTIES COMPILE_FLAGS "-x assembler-with-cpp") endif() From 3880263f1fb9e206f94a5b170a6c3775efbe5313 Mon Sep 17 00:00:00 2001 From: lachablock Date: Sat, 8 May 2021 12:27:29 +1000 Subject: [PATCH 0766/1080] Add machine dashmode as a condition for gap passage. (Also remove the sprite2 check, we don't need to be that stingy since PlayerHeight hooks allow greater control over that now!) --- src/p_user.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/p_user.c b/src/p_user.c index 4dbbcc04f..dc7209763 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -12972,6 +12972,8 @@ boolean P_PlayerCanEnterSpinGaps(player_t *player) return ((player->pflags & (PF_SPINNING|PF_GLIDING)) // players who are spinning or gliding || (player->charability == CA_GLIDEANDCLIMB && player->mo->state-states == S_PLAY_GLIDE_LANDING) // players who are landing from a glide + || ((player->charflags & (SF_DASHMODE|SF_MACHINE)) == (SF_DASHMODE|SF_MACHINE) + && player->dashmode >= DASHMODE_THRESHOLD && player->mo->state-states == S_PLAY_DASH) // machine players in dashmode || JUMPCURLED(player)); // players who are jumpcurled, but only if they would normally jump that way } From d2db204058a6f7dac39a68704c93a11e63a1d0de Mon Sep 17 00:00:00 2001 From: lachablock Date: Sat, 8 May 2021 18:34:32 +1000 Subject: [PATCH 0767/1080] Fix rollout rock controls in 2D mode --- src/p_user.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/p_user.c b/src/p_user.c index b3bfb763c..57cb056fd 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -12727,7 +12727,10 @@ void P_PlayerAfterThink(player_t *player) if (player->cmd.forwardmove || player->cmd.sidemove) { rock->flags2 |= MF2_STRONGBOX; // signifies the rock should not slow to a halt - rock->movedir = (player->cmd.angleturn << FRACBITS) + R_PointToAngle2(0, 0, player->cmd.forwardmove << FRACBITS, -player->cmd.sidemove << FRACBITS); + if (twodlevel || (mo->flags2 & MF2_TWOD)) + rock->movedir = mo->angle; + else + rock->movedir = (player->cmd.angleturn << FRACBITS) + R_PointToAngle2(0, 0, player->cmd.forwardmove << FRACBITS, -player->cmd.sidemove << FRACBITS); P_Thrust(rock, rock->movedir, rock->scale >> 1); } else From ec8e884a310fe7978bba4d720ce1259d918a5c8b Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Sat, 8 May 2021 12:56:33 -0400 Subject: [PATCH 0768/1080] Removed this function --- src/r_skins.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/r_skins.h b/src/r_skins.h index 675eac5cc..70e9b49c0 100644 --- a/src/r_skins.h +++ b/src/r_skins.h @@ -90,7 +90,6 @@ extern skin_t skins[MAXSKINS]; void R_InitSkins(void); INT32 GetPlayerDefaultSkin(INT32 playernum); -void SetPlayerDefaultSkin(INT32 playernum); void SetPlayerSkin(INT32 playernum,const char *skinname); void SetPlayerSkinByNum(INT32 playernum,INT32 skinnum); // Tails 03-16-2002 boolean R_SkinUsable(INT32 playernum, INT32 skinnum); From 210c9419e4bddd1fe8e9be7cb66de31119fa0d68 Mon Sep 17 00:00:00 2001 From: James R Date: Sat, 8 May 2021 16:48:40 -0700 Subject: [PATCH 0769/1080] Ignore -Wtrigraphs --- src/CMakeLists.txt | 2 ++ src/Makefile.cfg | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 87a0499b6..88ab1cdcb 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -604,6 +604,8 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} -Wno-absolute-value) endif() +set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} -Wno-trigraphs) + add_definitions(-DCMAKECONFIG) #add_library(SRB2Core STATIC diff --git a/src/Makefile.cfg b/src/Makefile.cfg index 075cd2d3a..79d332f85 100644 --- a/src/Makefile.cfg +++ b/src/Makefile.cfg @@ -209,7 +209,7 @@ endif OLDWFLAGS:=$(WFLAGS) # -W -Wno-unused -WFLAGS=-Wall +WFLAGS=-Wall -Wno-trigraphs ifndef GCC295 #WFLAGS+=-Wno-packed endif From 35244fa736cd2b5d1a35b471ef75cfaaba6a3a2a Mon Sep 17 00:00:00 2001 From: James R Date: Sat, 8 May 2021 16:49:23 -0700 Subject: [PATCH 0770/1080] Clang: fix -Wimplicit-const-int-float-conversion Some of these integers exceed the precision of float. In that case the number is rounded. The rounding shouldn't matter too much anyway, so just shut the compiler up. --- src/hardware/hw_main.c | 2 +- src/m_random.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index e94c637e4..dd633d6fc 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -5715,7 +5715,7 @@ static void HWR_DrawSkyBackground(player_t *player) dimensionmultiply = ((float)textures[texturetranslation[skytexture]]->width/256.0f); - v[0].s = v[3].s = (-1.0f * angle) / ((ANGLE_90-1)*dimensionmultiply); // left + v[0].s = v[3].s = (-1.0f * angle) / (((float)ANGLE_90-1.0f)*dimensionmultiply); // left v[2].s = v[1].s = v[0].s + (1.0f/dimensionmultiply); // right (or left + 1.0f) // use +angle and -1.0f above instead if you wanted old backwards behavior diff --git a/src/m_random.c b/src/m_random.c index 481fdb72b..b00eff60f 100644 --- a/src/m_random.c +++ b/src/m_random.c @@ -60,7 +60,7 @@ UINT8 M_RandomByte(void) */ INT32 M_RandomKey(INT32 a) { - return (INT32)((rand()/((unsigned)RAND_MAX+1.0f))*a); + return (INT32)((rand()/((float)RAND_MAX+1.0f))*a); } /** Provides a random integer in a given range. @@ -73,7 +73,7 @@ INT32 M_RandomKey(INT32 a) */ INT32 M_RandomRange(INT32 a, INT32 b) { - return (INT32)((rand()/((unsigned)RAND_MAX+1.0f))*(b-a+1))+a; + return (INT32)((rand()/((float)RAND_MAX+1.0f))*(b-a+1))+a; } From 69647eb78d36c0b2f5febecd2c4e55f622325217 Mon Sep 17 00:00:00 2001 From: RJPFonseca Date: Sun, 9 May 2021 19:10:53 +0100 Subject: [PATCH 0771/1080] Used spaces instead of tabs in Makefile.cfg --- src/Makefile.cfg | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Makefile.cfg b/src/Makefile.cfg index 075cd2d3a..e6821a4c9 100644 --- a/src/Makefile.cfg +++ b/src/Makefile.cfg @@ -61,10 +61,10 @@ ifeq (,$(filter GCC% CLEANONLY,$(.VARIABLES))) # If this version is not in the list, default to the latest supported ifeq (,$(filter $(v),$(SUPPORTED_GCC_VERSIONS))) - define line = + define line = Your compiler version, GCC $(version), is not supported by the Makefile. The Makefile will assume GCC $(LATEST_GCC_VERSION).)) - endef + endef $(call print,$(line)) GCC$(subst .,,$(LATEST_GCC_VERSION))=1 else From 0edbca5e02dfc0ffa23696e4c1d86cd12f8e516b Mon Sep 17 00:00:00 2001 From: James R Date: Mon, 10 May 2021 16:51:18 -0700 Subject: [PATCH 0772/1080] Actually report server version mismatches Incompatible servers get dropped from the server list. It turns out the server list is also used when connecting directly to a server. This meant that if you tried connecting to a server that was incompatible, you'd just get an infinite connection screen, as if the server was completely unreachable. Now it won't drop the server if you are directly connecting to it. I also copied some incompatibility messages from HandleConnect. --- src/d_clisrv.c | 113 ++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 88 insertions(+), 25 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 7fa6d8d59..8b80e58f5 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -1667,20 +1667,24 @@ static void SL_InsertServer(serverinfo_pak* info, SINT8 node) if (serverlistcount >= MAXSERVERLIST) return; // list full - if (info->_255 != 255) - return;/* old packet format */ + /* check it later if connecting to this one */ + if (node != servernode) + { + if (info->_255 != 255) + return;/* old packet format */ - if (info->packetversion != PACKETVERSION) - return;/* old new packet format */ + if (info->packetversion != PACKETVERSION) + return;/* old new packet format */ - if (info->version != VERSION) - return; // Not same version. + if (info->version != VERSION) + return; // Not same version. - if (info->subversion != SUBVERSION) - return; // Close, but no cigar. + if (info->subversion != SUBVERSION) + return; // Close, but no cigar. - if (strcmp(info->application, SRB2APPLICATION)) - return;/* that's a different mod */ + if (strcmp(info->application, SRB2APPLICATION)) + return;/* that's a different mod */ + } i = serverlistcount++; } @@ -1829,6 +1833,65 @@ void CL_UpdateServerList(boolean internetsearch, INT32 room) #endif // ifndef NONET +static const char * InvalidServerReason (INT32 i) +{ +#define EOT "\nPress ESC\n" + + serverinfo_pak *info = &serverlist[i].info; + + /* magic number for new packet format */ + if (info->_255 != 255) + { + return + "Outdated server (version unknown).\n" EOT; + } + + if (strncmp(info->application, SRB2APPLICATION, sizeof + info->application)) + { + return va( + "%s cannot connect\n" + "to %s servers.\n" EOT, + SRB2APPLICATION, + info->application); + } + + if ( + info->packetversion != PACKETVERSION || + info->version != VERSION || + info->subversion != SUBVERSION + ){ + return va( + "Incompatible %s versions.\n" + "(server version %d.%d.%d)\n" EOT, + SRB2APPLICATION, + info->version / 100, + info->version % 100, + info->subversion); + } + + if (info->refusereason) + { + if (serverlist[i].info.refusereason == 1) + return + "The server is not accepting\n" + "joins for the moment.\n" EOT; + else if (serverlist[i].info.refusereason == 2) + return va( + "Maximum players reached: %d\n" EOT, + info->maxplayer); + else + return + "You can't join.\n" + "I don't know why,\n" + "but you can't join.\n" EOT; + } + + return NULL; + +#undef EOT +} + /** Called by CL_ServerConnectionTicker * * \param asksent The last time we asked the server to join. We re-ask every second in case our request got lost in transmit. @@ -1859,23 +1922,23 @@ static boolean CL_ServerConnectionSearchTicker(tic_t *asksent) return true; } - // Quit here rather than downloading files and being refused later. - if (serverlist[i].info.refusereason) - { - D_QuitNetGame(); - CL_Reset(); - D_StartTitle(); - if (serverlist[i].info.refusereason == 1) - M_StartMessage(M_GetText("The server is not accepting\njoins for the moment.\n\nPress ESC\n"), NULL, MM_NOTHING); - else if (serverlist[i].info.refusereason == 2) - M_StartMessage(va(M_GetText("Maximum players reached: %d\n\nPress ESC\n"), serverlist[i].info.maxplayer), NULL, MM_NOTHING); - else - M_StartMessage(M_GetText("You can't join.\nI don't know why,\nbut you can't join.\n\nPress ESC\n"), NULL, MM_NOTHING); - return false; - } - if (client) { + const char *reason = InvalidServerReason(i); + + // Quit here rather than downloading files + // and being refused later. + if (reason) + { + char *message = Z_StrDup(reason); + D_QuitNetGame(); + CL_Reset(); + D_StartTitle(); + M_StartMessage(message, NULL, MM_NOTHING); + Z_Free(message); + return false; + } + D_ParseFileneeded(serverlist[i].info.fileneedednum, serverlist[i].info.fileneeded); CONS_Printf(M_GetText("Checking files...\n")); From 22bfc2db78e2c0afbe839681310a7470b17a9325 Mon Sep 17 00:00:00 2001 From: James R Date: Mon, 10 May 2021 17:50:01 -0700 Subject: [PATCH 0773/1080] Refactor HandleConnect refusals Also removed some version fields from serverconfig_pak and clientconfig_pak. Client version will be checked with SRB2APPLICATION and MODVERSION. Not updating PACKETVERSION because those packets shouldn't have been packetversion'd in the first place. --- src/d_clisrv.c | 115 +++++++++++++++++++++++++++++++++++-------------- src/d_clisrv.h | 8 +--- 2 files changed, 83 insertions(+), 40 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 8b80e58f5..27e104596 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -1150,15 +1150,14 @@ static boolean CL_SendJoin(void) CONS_Printf(M_GetText("Sending join request...\n")); netbuffer->packettype = PT_CLIENTJOIN; + netbuffer->u.clientcfg.modversion = MODVERSION; + strncpy(netbuffer->u.clientcfg.application, + SRB2APPLICATION, + sizeof netbuffer->u.clientcfg.application); + if (splitscreen || botingame) localplayers++; netbuffer->u.clientcfg.localplayers = localplayers; - netbuffer->u.clientcfg._255 = 255; - 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); CleanupPlayerName(consoleplayer, cv_playername.zstring); if (splitscreen) @@ -1344,9 +1343,6 @@ static boolean SV_SendServerConfig(INT32 node) netbuffer->packettype = PT_SERVERCFG; - netbuffer->u.servercfg.version = VERSION; - netbuffer->u.servercfg.subversion = SUBVERSION; - netbuffer->u.servercfg.serverplayer = (UINT8)serverplayer; netbuffer->u.servercfg.totalslotnum = (UINT8)(doomcom->numslots); netbuffer->u.servercfg.gametic = (tic_t)LONG(gametic); @@ -3683,6 +3679,78 @@ static size_t TotalTextCmdPerTic(tic_t tic) return total; } +static const char * +ConnectionRefused (SINT8 node, INT32 rejoinernum) +{ + clientconfig_pak *cc = &netbuffer->u.clientcfg; + + boolean rejoining = (rejoinernum != -1); + + if (!node)/* server connecting to itself */ + return NULL; + + if ( + cc->modversion != MODVERSION || + strncmp(cc->application, SRB2APPLICATION, + sizeof cc->application) + ){ + return/* this is probably client's fault */ + "Incompatible."; + } + else if (bannednode && bannednode[node]) + { + return + "You have been banned\n" + "from the server."; + } + else if (cc->localplayers != 1) + { + return + "Wrong player count."; + } + + if (!rejoining) + { + if (!cv_allownewplayer.value) + { + return + "The server is not accepting\n" + "joins for the moment."; + } + else if (D_NumPlayers() >= cv_maxplayers.value) + { + return va( + "Maximum players reached: %d", + cv_maxplayers.value); + } + } + + if (luafiletransfers) + { + return + "The serveris broadcasting a file\n" + "requested by a Lua script.\n" + "Please wait a bit and then\n" + "try rejoining."; + } + + if (netgame) + { + const tic_t th = 2 * cv_joindelay.value * TICRATE; + + if (joindelay > th) + { + return va( + "Too many people are connecting.\n" + "Please wait %d seconds and then\n" + "try rejoining.", + (joindelay - th) / TICRATE); + } + } + + return NULL; +} + /** Called when a PT_CLIENTJOIN packet is received * * \param node The packet sender @@ -3693,33 +3761,14 @@ static void HandleConnect(SINT8 node) char names[MAXSPLITSCREENPLAYERS][MAXPLAYERNAME + 1]; INT32 rejoinernum; INT32 i; + const char *refuse; rejoinernum = FindRejoinerNum(node); - if (bannednode && bannednode[node]) - SV_SendRefuse(node, M_GetText("You have been banned\nfrom the server.")); - else if (netbuffer->u.clientcfg._255 != 255 || - netbuffer->u.clientcfg.packetversion != PACKETVERSION) - SV_SendRefuse(node, "Incompatible packet formats."); - else if (strncmp(netbuffer->u.clientcfg.application, SRB2APPLICATION, - sizeof netbuffer->u.clientcfg.application)) - SV_SendRefuse(node, "Different SRB2 modifications\nare not compatible."); - else if (netbuffer->u.clientcfg.version != VERSION - || netbuffer->u.clientcfg.subversion != SUBVERSION) - SV_SendRefuse(node, va(M_GetText("Different SRB2 versions cannot\nplay a netgame!\n(server version %d.%d.%d)"), VERSION/100, VERSION%100, SUBVERSION)); - else if (!cv_allownewplayer.value && node && rejoinernum == -1) - SV_SendRefuse(node, M_GetText("The server is not accepting\njoins for the moment.")); - else if (D_NumPlayers() >= cv_maxplayers.value && rejoinernum == -1) - SV_SendRefuse(node, va(M_GetText("Maximum players reached: %d"), cv_maxplayers.value)); - else if (netgame && netbuffer->u.clientcfg.localplayers > 1) // Hacked client? - SV_SendRefuse(node, M_GetText("Too many players from\nthis node.")); - else if (netgame && !netbuffer->u.clientcfg.localplayers) // Stealth join? - SV_SendRefuse(node, M_GetText("No players from\nthis node.")); - else if (luafiletransfers) - SV_SendRefuse(node, M_GetText("The server is broadcasting a file\nrequested by a Lua script.\nPlease wait a bit and then\ntry rejoining.")); - else if (netgame && joindelay > 2 * (tic_t)cv_joindelay.value * TICRATE) - SV_SendRefuse(node, va(M_GetText("Too many people are connecting.\nPlease wait %d seconds and then\ntry rejoining."), - (joindelay - 2 * cv_joindelay.value * TICRATE) / TICRATE)); + refuse = ConnectionRefused(node, rejoinernum); + + if (refuse) + SV_SendRefuse(node, refuse); else { #ifndef NONET diff --git a/src/d_clisrv.h b/src/d_clisrv.h index 3d67525da..9b690da84 100644 --- a/src/d_clisrv.h +++ b/src/d_clisrv.h @@ -141,9 +141,6 @@ typedef struct typedef struct { - UINT8 version; // Different versions don't work - UINT8 subversion; // Contains build version - // Server launch stuffs UINT8 serverplayer; UINT8 totalslotnum; // "Slots": highest player number in use plus one. @@ -190,11 +187,8 @@ typedef struct typedef struct { - UINT8 _255;/* see serverinfo_pak */ - UINT8 packetversion; + UINT8 modversion; char application[MAXAPPLICATION]; - UINT8 version; // Different versions don't work - UINT8 subversion; // Contains build version UINT8 localplayers; UINT8 mode; char names[MAXSPLITSCREENPLAYERS][MAXPLAYERNAME]; From 8486a9386d84293375465420fa80cfeed9859cd1 Mon Sep 17 00:00:00 2001 From: James R Date: Mon, 10 May 2021 18:10:16 -0700 Subject: [PATCH 0774/1080] serverinfo: enumerate refusereason --- src/d_clisrv.c | 41 +++++++++++++++++++++++++---------------- src/d_clisrv.h | 7 ++++++- 2 files changed, 31 insertions(+), 17 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 27e104596..a06a935a7 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -1200,6 +1200,19 @@ static INT32 FindRejoinerNum(SINT8 node) return -1; } +static UINT8 +GetRefuseReason (INT32 node) +{ + if (!node || FindRejoinerNum(node) != -1) + return 0; + else if (!cv_allownewplayer.value) + return REFUSE_JOINS_DISABLED; + else if (D_NumPlayers() >= cv_maxplayers.value) + return REFUSE_SLOTS_FULL; + else + return 0; +} + static void SV_SendServerInfo(INT32 node, tic_t servertime) { UINT8 *p; @@ -1218,14 +1231,7 @@ static void SV_SendServerInfo(INT32 node, tic_t servertime) netbuffer->u.serverinfo.numberofplayer = (UINT8)D_NumPlayers(); netbuffer->u.serverinfo.maxplayer = (UINT8)cv_maxplayers.value; - if (!node || FindRejoinerNum(node) != -1) - netbuffer->u.serverinfo.refusereason = 0; - else if (!cv_allownewplayer.value) - netbuffer->u.serverinfo.refusereason = 1; - else if (D_NumPlayers() >= cv_maxplayers.value) - netbuffer->u.serverinfo.refusereason = 2; - else - netbuffer->u.serverinfo.refusereason = 0; + netbuffer->u.serverinfo.refusereason = GetRefuseReason(node); strncpy(netbuffer->u.serverinfo.gametypename, Gametype_Names[gametype], sizeof netbuffer->u.serverinfo.gametypename); @@ -1866,21 +1872,24 @@ static const char * InvalidServerReason (INT32 i) info->subversion); } - if (info->refusereason) + switch (info->refusereason) { - if (serverlist[i].info.refusereason == 1) + case REFUSE_JOINS_DISABLED: return "The server is not accepting\n" "joins for the moment.\n" EOT; - else if (serverlist[i].info.refusereason == 2) + case REFUSE_SLOTS_FULL: return va( "Maximum players reached: %d\n" EOT, info->maxplayer); - else - return - "You can't join.\n" - "I don't know why,\n" - "but you can't join.\n" EOT; + default: + if (info->refusereason) + { + return + "You can't join.\n" + "I don't know why,\n" + "but you can't join.\n" EOT; + } } return NULL; diff --git a/src/d_clisrv.h b/src/d_clisrv.h index 9b690da84..0e8e4c2b8 100644 --- a/src/d_clisrv.h +++ b/src/d_clisrv.h @@ -194,6 +194,11 @@ typedef struct char names[MAXSPLITSCREENPLAYERS][MAXPLAYERNAME]; } ATTRPACK clientconfig_pak; +enum { + REFUSE_JOINS_DISABLED = 1, + REFUSE_SLOTS_FULL, +}; + #define MAXSERVERNAME 32 #define MAXFILENEEDED 915 // This packet is too large @@ -211,7 +216,7 @@ typedef struct UINT8 subversion; UINT8 numberofplayer; UINT8 maxplayer; - UINT8 refusereason; // 0: joinable, 1: joins disabled, 2: full + UINT8 refusereason; // 0: joinable, REFUSE enum char gametypename[24]; UINT8 modifiedgame; UINT8 cheatsenabled; From c13e1a74ddb5fba981d801d1137c11537d4505f7 Mon Sep 17 00:00:00 2001 From: James R Date: Mon, 10 May 2021 18:10:53 -0700 Subject: [PATCH 0775/1080] Reject banned players with refusereason --- src/d_clisrv.c | 6 ++++++ src/d_clisrv.h | 13 +++++++++---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index a06a935a7..e87edf43d 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -1205,6 +1205,8 @@ GetRefuseReason (INT32 node) { if (!node || FindRejoinerNum(node) != -1) return 0; + else if (bannednode && bannednode[node]) + return REFUSE_BANNED; else if (!cv_allownewplayer.value) return REFUSE_JOINS_DISABLED; else if (D_NumPlayers() >= cv_maxplayers.value) @@ -1874,6 +1876,10 @@ static const char * InvalidServerReason (INT32 i) switch (info->refusereason) { + case REFUSE_BANNED: + return + "You have been banned\n" + "from the server.\n" EOT; case REFUSE_JOINS_DISABLED: return "The server is not accepting\n" diff --git a/src/d_clisrv.h b/src/d_clisrv.h index 0e8e4c2b8..99274b5de 100644 --- a/src/d_clisrv.h +++ b/src/d_clisrv.h @@ -22,11 +22,15 @@ #include "mserv.h" /* -The 'packet version' is used to distinguish packet formats. -This version is independent of VERSION and SUBVERSION. Different -applications may follow different packet versions. +The 'packet version' is used to distinguish packet +formats. This version is independent of VERSION and +SUBVERSION. Different applications may follow different +packet versions. + +If you change the struct or the meaning of a field +therein, increment this number. */ -#define PACKETVERSION 3 +#define PACKETVERSION 4 // Network play related stuff. // There is a data struct that stores network @@ -197,6 +201,7 @@ typedef struct enum { REFUSE_JOINS_DISABLED = 1, REFUSE_SLOTS_FULL, + REFUSE_BANNED, }; #define MAXSERVERNAME 32 From f55a5b3b0b964ccf77279bab9136ee7ce883a2e1 Mon Sep 17 00:00:00 2001 From: Steel Titanium Date: Tue, 11 May 2021 20:02:12 -0400 Subject: [PATCH 0776/1080] Add badge to readme showing latest stable release --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 8a5ca1a1f..49a3cc36d 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ # Sonic Robo Blast 2 +[![latest release](https://badgen.net/github/release/STJr/SRB2/stable)](https://github.com/STJr/SRB2/releases/latest) [![Build status](https://ci.appveyor.com/api/projects/status/399d4hcw9yy7hg2y?svg=true)](https://ci.appveyor.com/project/STJr/srb2) [![Build status](https://travis-ci.org/STJr/SRB2.svg?branch=master)](https://travis-ci.org/STJr/SRB2) From 5b86b8991c7408ba7ebb78d0d6ff4438d447936e Mon Sep 17 00:00:00 2001 From: Jaime Ita Passos Date: Sun, 16 May 2021 21:43:52 -0300 Subject: [PATCH 0777/1080] Use floating point trigonometry --- src/r_plane.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/r_plane.c b/src/r_plane.c index d26c124ef..4c757d8ca 100644 --- a/src/r_plane.c +++ b/src/r_plane.c @@ -368,11 +368,11 @@ visplane_t *R_FindPlane(fixed_t height, INT32 picnum, INT32 lightlevel, if (plangle != 0) { // Add the view offset, rotated by the plane angle. - fixed_t cosinecomponent = FINECOSINE(plangle>>ANGLETOFINESHIFT); - fixed_t sinecomponent = FINESINE(plangle>>ANGLETOFINESHIFT); - fixed_t oldxoff = xoff; - xoff = FixedMul(xoff,cosinecomponent)+FixedMul(yoff,sinecomponent); - yoff = -FixedMul(oldxoff,sinecomponent)+FixedMul(yoff,cosinecomponent); + float ang = ANG2RAD(plangle); + float x = FixedToFloat(xoff); + float y = FixedToFloat(yoff); + xoff = FloatToFixed(x * cos(ang) + y * sin(ang)); + yoff = FloatToFixed(-x * sin(ang) + y * cos(ang)); } } From 7c11bc8ac5807414fee671df0b6d82c040a067bc Mon Sep 17 00:00:00 2001 From: lachablock Date: Fri, 21 May 2021 20:28:50 +1000 Subject: [PATCH 0778/1080] Remove camera dependency from P_GetPlayerControlDirection --- src/p_user.c | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index 6ebee5afc..3b8248e97 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -5624,16 +5624,10 @@ INT32 P_GetPlayerControlDirection(player_t *player) { ticcmd_t *cmd = &player->cmd; angle_t controllerdirection, controlplayerdirection; - camera_t *thiscam; angle_t dangle; fixed_t tempx = 0, tempy = 0; angle_t tempangle, origtempangle; - if (splitscreen && player == &players[secondarydisplayplayer]) - thiscam = &camera2; - else - thiscam = &camera; - if (!cmd->forwardmove && !cmd->sidemove) return 0; @@ -5649,17 +5643,15 @@ INT32 P_GetPlayerControlDirection(player_t *player) origtempangle = tempangle = 0; // relative to the axis rather than the player! controlplayerdirection = R_PointToAngle2(0, 0, player->mo->momx, player->mo->momy); } - else if ((P_ControlStyle(player) & CS_LMAOGALOG) && thiscam->chase) + else { if (player->awayviewtics) origtempangle = tempangle = player->awayviewmobj->angle; + else if (P_ControlStyle(player) & CS_LMAOGALOG) + origtempangle = tempangle = (cmd->angleturn << 16); else - origtempangle = tempangle = thiscam->angle; - controlplayerdirection = player->mo->angle; - } - else - { - origtempangle = tempangle = player->mo->angle; + origtempangle = tempangle = player->mo->angle; + controlplayerdirection = R_PointToAngle2(0, 0, player->mo->momx, player->mo->momy); } From 4e5c3566c95cd9526d42629837f779c041fe0a92 Mon Sep 17 00:00:00 2001 From: lachablock Date: Sat, 22 May 2021 16:52:01 +1000 Subject: [PATCH 0779/1080] Respect mobj->color while enemies & bosses flash --- src/r_draw.c | 4 ++++ src/r_things.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/r_draw.c b/src/r_draw.c index 9a835ee58..c7bf36e64 100644 --- a/src/r_draw.c +++ b/src/r_draw.c @@ -481,8 +481,12 @@ static void R_GenerateTranslationColormap(UINT8 *dest_colormap, INT32 skinnum, U // White! if (skinnum == TC_BOSS) { + UINT8 *originalColormap = R_GetTranslationColormap(TC_DEFAULT, (skincolornum_t)color, GTC_CACHE); for (i = 0; i < 16; i++) + { + dest_colormap[DEFAULT_STARTTRANSCOLOR + i] = originalColormap[DEFAULT_STARTTRANSCOLOR + i]; dest_colormap[31-i] = i; + } } else if (skinnum == TC_METALSONIC) { diff --git a/src/r_things.c b/src/r_things.c index 5c0e5fda9..bbae345db 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -753,7 +753,7 @@ UINT8 *R_GetSpriteTranslation(vissprite_t *vis) else if (vis->mobj->type == MT_METALSONIC_BATTLE) return R_GetTranslationColormap(TC_METALSONIC, 0, GTC_CACHE); else - return R_GetTranslationColormap(TC_BOSS, 0, GTC_CACHE); + return R_GetTranslationColormap(TC_BOSS, vis->mobj->color, GTC_CACHE); } else if (vis->mobj->color) { From 99ad18826332cb95798d17b658ccb4fa9c83b3f6 Mon Sep 17 00:00:00 2001 From: lachablock Date: Sat, 22 May 2021 18:17:48 +1000 Subject: [PATCH 0780/1080] Fix models interpolating to frame 0 from a same-sprite2 FF_SPR2ENDSTATE state --- src/hardware/hw_md2.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index 9c3aa9e58..e3b612678 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -1533,7 +1533,12 @@ boolean HWR_DrawModel(gl_vissprite_t *spr) { nextFrame = (spr->mobj->frame & FF_FRAMEMASK) + 1; if (nextFrame >= mod) - nextFrame = 0; + { + if (spr->mobj->state->frame & FF_SPR2ENDSTATE) + nextFrame--; + else + nextFrame = 0; + } if (frame || !(spr->mobj->state->frame & FF_SPR2ENDSTATE)) nextFrame = md2->model->spr2frames[spr2].frames[nextFrame]; else From 750bdd9d607f1a078d16b88a87d59b12bf0992a7 Mon Sep 17 00:00:00 2001 From: lachablock Date: Sat, 22 May 2021 23:25:36 +1000 Subject: [PATCH 0781/1080] Respect mobj->color while enemies & bosses flash, but in OpenGL --- src/hardware/hw_main.c | 2 +- src/hardware/hw_md2.c | 28 ++++++++++------------------ 2 files changed, 11 insertions(+), 19 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index dd633d6fc..cec55e601 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -5327,7 +5327,7 @@ static void HWR_ProjectSprite(mobj_t *thing) else if (vis->mobj->type == MT_METALSONIC_BATTLE) vis->colormap = R_GetTranslationColormap(TC_METALSONIC, 0, GTC_CACHE); else - vis->colormap = R_GetTranslationColormap(TC_BOSS, 0, GTC_CACHE); + vis->colormap = R_GetTranslationColormap(TC_BOSS, vis->mobj->color, GTC_CACHE); } else if (thing->color) { diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index 9c3aa9e58..fd7b67aad 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -777,24 +777,7 @@ static void HWR_CreateBlendedTexture(patch_t *gpatch, patch_t *blendgpatch, GLMi while (size--) { - if (skinnum == TC_BOSS) - { - // Turn everything below a certain threshold white - if ((image->s.red == image->s.green) && (image->s.green == image->s.blue) && image->s.blue < 127) - { - // Lactozilla: Invert the colors - cur->s.red = cur->s.green = cur->s.blue = (255 - image->s.blue); - } - else - { - cur->s.red = image->s.red; - cur->s.green = image->s.green; - cur->s.blue = image->s.blue; - } - - cur->s.alpha = image->s.alpha; - } - else if (skinnum == TC_ALLWHITE) + if (skinnum == TC_ALLWHITE) { // Turn everything white cur->s.red = cur->s.green = cur->s.blue = 255; @@ -1065,6 +1048,15 @@ skippixel: cur->s.alpha = image->s.alpha; } + else if (skinnum == TC_BOSS) + { + // Turn everything below a certain threshold white + if ((image->s.red == image->s.green) && (image->s.green == image->s.blue) && image->s.blue < 127) + { + // Lactozilla: Invert the colors + cur->s.red = cur->s.green = cur->s.blue = (255 - image->s.blue); + } + } } } From a1553c46232f6a4df12b71af9ff7f29bf36b9607 Mon Sep 17 00:00:00 2001 From: Jaime Ita Passos Date: Sat, 22 May 2021 20:08:11 -0300 Subject: [PATCH 0782/1080] Update r_opengl.c --- src/hardware/r_opengl/r_opengl.c | 75 ++++++++++---------------------- 1 file changed, 22 insertions(+), 53 deletions(-) diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index 003a1b3ca..de0e8c6a6 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -62,6 +62,9 @@ static FBITFIELD CurrentPolyFlags; static FTextureInfo *TexCacheTail = NULL; static FTextureInfo *TexCacheHead = NULL; +static RGBA_t *textureBuffer = NULL; +static size_t textureBufferSize = 0; + RGBA_t myPaletteData[256]; GLint screen_width = 0; // used by Draw2DLine() GLint screen_height = 0; @@ -202,32 +205,6 @@ static void GL_MSG_Error(const char *format, ...) #endif } -// ----------------------+ -// GetTextureFormatName : Returns the corresponding texture format string from the texture format enumeration. -// ----------------------+ -static const char *GetTextureFormatName(INT32 format) -{ - static char num[12]; - - switch (format) - { - case GL_TEXFMT_P_8: return "GL_TEXFMT_P_8"; - case GL_TEXFMT_AP_88: return "GL_TEXFMT_AP_88"; - case GL_TEXFMT_RGBA: return "GL_TEXFMT_RGBA"; - case GL_TEXFMT_ALPHA_8: return "GL_TEXFMT_ALPHA_8"; - case GL_TEXFMT_INTENSITY_8: return "GL_TEXFMT_INTENSITY_8"; - case GL_TEXFMT_ALPHA_INTENSITY_88: return "GL_TEXFMT_ALPHA_INTENSITY_88"; - default: break; - } - - // If the texture format is not known (due to it being invalid), - // return a string containing the format index instead. - format = INT32_MIN; - snprintf(num, sizeof(num), "%d", format); - - return num; -} - #ifdef STATIC_OPENGL /* 1.0 functions */ /* Miscellaneous */ @@ -1366,6 +1343,10 @@ void Flush(void) TexCacheTail = TexCacheHead = NULL; //Hurdler: well, TexCacheHead is already NULL tex_downloaded = 0; + + free(textureBuffer); + textureBuffer = NULL; + textureBufferSize = 0; } @@ -1758,28 +1739,16 @@ EXPORT void HWRAPI(SetBlend) (FBITFIELD PolyFlags) CurrentPolyFlags = PolyFlags; } -// -------------------+ -// AllocTextureBuffer : Allocates memory for converting a non-RGBA texture into an RGBA texture. -// -------------------+ -static RGBA_t *AllocTextureBuffer(GLMipmap_t *pTexInfo) +static void AllocTextureBuffer(GLMipmap_t *pTexInfo) { - size_t len = (pTexInfo->width * pTexInfo->height); - RGBA_t *tex = calloc(len, sizeof(RGBA_t)); - - if (tex == NULL) - I_Error("AllocTextureBuffer: out of memory allocating %s bytes for texture %d, format %s", - sizeu1(len * sizeof(RGBA_t)), pTexInfo->downloaded, GetTextureFormatName(pTexInfo->format)); - - return tex; -} - -// ------------------+ -// FreeTextureBuffer : Frees memory allocated by AllocTextureBuffer. -// ------------------+ -static void FreeTextureBuffer(RGBA_t *tex) -{ - if (tex) - free(tex); + size_t size = pTexInfo->width * pTexInfo->height; + if (size > textureBufferSize) + { + textureBuffer = realloc(textureBuffer, size * sizeof(RGBA_t)); + if (textureBuffer == NULL) + I_Error("AllocTextureBuffer: out of memory allocating %s bytes", sizeu1(size * sizeof(RGBA_t))); + textureBufferSize = size; + } } // -----------------+ @@ -1810,7 +1779,8 @@ EXPORT void HWRAPI(UpdateTexture) (GLMipmap_t *pTexInfo) if ((pTexInfo->format == GL_TEXFMT_P_8) || (pTexInfo->format == GL_TEXFMT_AP_88)) { - ptex = tex = AllocTextureBuffer(pTexInfo); + AllocTextureBuffer(pTexInfo); + ptex = tex = textureBuffer; for (j = 0; j < h; j++) { @@ -1851,7 +1821,8 @@ EXPORT void HWRAPI(UpdateTexture) (GLMipmap_t *pTexInfo) } else if (pTexInfo->format == GL_TEXFMT_ALPHA_INTENSITY_88) { - ptex = tex = AllocTextureBuffer(pTexInfo); + AllocTextureBuffer(pTexInfo); + ptex = tex = textureBuffer; for (j = 0; j < h; j++) { @@ -1868,7 +1839,8 @@ EXPORT void HWRAPI(UpdateTexture) (GLMipmap_t *pTexInfo) } else if (pTexInfo->format == GL_TEXFMT_ALPHA_8) // Used for fade masks { - ptex = tex = AllocTextureBuffer(pTexInfo); + AllocTextureBuffer(pTexInfo); + ptex = tex = textureBuffer; for (j = 0; j < h; j++) { @@ -1963,9 +1935,6 @@ EXPORT void HWRAPI(UpdateTexture) (GLMipmap_t *pTexInfo) } } - // Free the texture buffer - FreeTextureBuffer(tex); - if (pTexInfo->flags & TF_WRAPX) pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); else From 75397c347db01720f32547ca02c8c7b9486a727c Mon Sep 17 00:00:00 2001 From: Jaime Ita Passos Date: Sat, 22 May 2021 21:09:06 -0300 Subject: [PATCH 0783/1080] Remove FRACUNIT/2 --- src/r_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/r_main.c b/src/r_main.c index be9bbd7d0..17e124cb9 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -955,7 +955,7 @@ void R_ExecuteSetViewSize(void) j = viewheight*16; for (i = 0; i < j; i++) { - dy = ((i - viewheight*8)< Date: Sun, 23 May 2021 19:21:23 -0500 Subject: [PATCH 0784/1080] Allow people to update their Master Server listing on command. --- src/mserv.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mserv.c b/src/mserv.c index f64c7bea9..ff62f2cdc 100644 --- a/src/mserv.c +++ b/src/mserv.c @@ -98,6 +98,7 @@ void AddMServCommands(void) CV_RegisterVar(&cv_servername); #ifdef MASTERSERVER COM_AddCommand("listserv", Command_Listserv_f); + COM_AddCommand("masterserver_update", Update_parameters); // allows people to updates manually in case you were delisted by accident #endif #endif } From b2ae7c79e7bc3e340884448f1535cc104eafbf22 Mon Sep 17 00:00:00 2001 From: katsy Date: Mon, 24 May 2021 00:00:01 -0500 Subject: [PATCH 0785/1080] make a few messages more helpful --- src/d_clisrv.c | 6 +++--- src/locale/en.po | 6 +++--- src/locale/srb2.pot | 6 +++--- src/p_setup.c | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 3a0e64c56..64efd3b60 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -2952,7 +2952,7 @@ static void Got_KickCmd(UINT8 **p, INT32 playernum) { case KICK_MSG_GO_AWAY: if (!players[pnum].quittime) - HU_AddChatText(va("\x82*%s has been kicked (Go away)", player_names[pnum]), false); + HU_AddChatText(va("\x82*%s has been kicked (No reason given)", player_names[pnum]), false); kickreason = KR_KICK; break; case KICK_MSG_PING_HIGH: @@ -2960,7 +2960,7 @@ static void Got_KickCmd(UINT8 **p, INT32 playernum) kickreason = KR_PINGLIMIT; break; case KICK_MSG_CON_FAIL: - HU_AddChatText(va("\x82*%s left the game (Synch Failure)", player_names[pnum]), false); + HU_AddChatText(va("\x82*%s left the game (Synch failure)", player_names[pnum]), false); kickreason = KR_SYNCH; if (M_CheckParm("-consisdump")) // Helps debugging some problems @@ -3006,7 +3006,7 @@ static void Got_KickCmd(UINT8 **p, INT32 playernum) kickreason = KR_LEAVE; break; case KICK_MSG_BANNED: - HU_AddChatText(va("\x82*%s has been banned (Don't come back)", player_names[pnum]), false); + HU_AddChatText(va("\x82*%s has been banned (No reason given)", player_names[pnum]), false); kickreason = KR_BAN; break; case KICK_MSG_CUSTOM_KICK: diff --git a/src/locale/en.po b/src/locale/en.po index 30ebe4368..8dd08173d 100644 --- a/src/locale/en.po +++ b/src/locale/en.po @@ -466,7 +466,7 @@ msgid "" msgstr "" #: d_clisrv.c:1764 -msgid "has been kicked (Go away)\n" +msgid "has been kicked (No reason given)\n" msgstr "" #: d_clisrv.c:1768 @@ -474,7 +474,7 @@ msgid "left the game (Broke ping limit)\n" msgstr "" #: d_clisrv.c:1772 -msgid "left the game (Consistency failure)\n" +msgid "left the game (Synch failure)\n" msgstr "" #: d_clisrv.c:1778 @@ -501,7 +501,7 @@ msgid "left the game\n" msgstr "" #: d_clisrv.c:1798 -msgid "has been banned (Don't come back)\n" +msgid "has been banned (No reason given)\n" msgstr "" #: d_clisrv.c:1802 diff --git a/src/locale/srb2.pot b/src/locale/srb2.pot index 960c36dbe..cd2db750d 100644 --- a/src/locale/srb2.pot +++ b/src/locale/srb2.pot @@ -459,7 +459,7 @@ msgid "" msgstr "" #: d_clisrv.c:1889 -msgid "has been kicked (Go away)\n" +msgid "has been kicked (No reason given)\n" msgstr "" #: d_clisrv.c:1893 @@ -467,7 +467,7 @@ msgid "left the game (Broke ping limit)\n" msgstr "" #: d_clisrv.c:1897 -msgid "left the game (Consistency failure)\n" +msgid "left the game (Synch failure)\n" msgstr "" #: d_clisrv.c:1903 @@ -494,7 +494,7 @@ msgid "left the game\n" msgstr "" #: d_clisrv.c:1923 -msgid "has been banned (Don't come back)\n" +msgid "has been banned (No reason given)\n" msgstr "" #: d_clisrv.c:1927 diff --git a/src/p_setup.c b/src/p_setup.c index 16c080248..231e5ed57 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2486,7 +2486,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"); From a1235e144dfddd2151471071c8cdd713ae46d89b Mon Sep 17 00:00:00 2001 From: katsy Date: Wed, 26 May 2021 01:09:56 -0500 Subject: [PATCH 0786/1080] allow sliders passage through spin gaps --- 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 6ebee5afc..45867ee5b 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -12971,7 +12971,7 @@ boolean P_PlayerCanEnterSpinGaps(player_t *player) else if (canEnter == 2) return false; - return ((player->pflags & (PF_SPINNING|PF_GLIDING)) // players who are spinning or gliding + return ((player->pflags & (PF_SPINNING|PF_SLIDING|PF_GLIDING)) // players who are spinning, sliding, or gliding || (player->charability == CA_GLIDEANDCLIMB && player->mo->state-states == S_PLAY_GLIDE_LANDING) // players who are landing from a glide || JUMPCURLED(player)); // players who are jumpcurled, but only if they would normally jump that way } From 6286fc8b05909e332dac676de5c7fe01d33266c0 Mon Sep 17 00:00:00 2001 From: katsy Date: Wed, 26 May 2021 02:37:46 -0400 Subject: [PATCH 0787/1080] add sliding flag to spinheight conditions --- 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 45867ee5b..9cb00967a 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -12979,7 +12979,7 @@ boolean P_PlayerCanEnterSpinGaps(player_t *player) // returns true if the player should use their skin's spinheight instead of their skin's height boolean P_PlayerShouldUseSpinHeight(player_t *player) { - return ((player->pflags & (PF_SPINNING|PF_GLIDING)) + return ((player->pflags & (PF_SPINNING|PF_SLIDING|PF_GLIDING)) || (player->mo->state == &states[player->mo->info->painstate]) || (player->panim == PA_ROLL) || ((player->powers[pw_tailsfly] || (player->charability == CA_FLY && player->mo->state-states == S_PLAY_FLY_TIRED)) From fd82357d4f72d2f8b7922551a98c3688bca77d5b Mon Sep 17 00:00:00 2001 From: flarn2006 Date: Thu, 27 May 2021 18:35:15 -0400 Subject: [PATCH 0788/1080] Expose M_MapNumber to Lua --- src/lua_baselib.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index a0c99411b..2a8c62a37 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -28,6 +28,7 @@ #include "console.h" #include "d_netcmd.h" // IsPlayerAdmin #include "m_menu.h" // Player Setup menu color stuff +#include "m_misc.h" // M_MapNumber #include "lua_script.h" #include "lua_libs.h" @@ -357,6 +358,23 @@ static int lib_pGetColorAfter(lua_State *L) return 1; } +// M_MISC +////////////// + +static int lib_mMapNumber(lua_State *L) +{ + const char *arg = luaL_checkstring(L, 1); + size_t len = strlen(arg); + if (len == 2 || len == 5) { + char first = arg[len-2]; + char second = arg[len-1]; + lua_pushinteger(L, M_MapNumber(first, second)); + } else { + lua_pushinteger(L, 0); + } + return 1; +} + // M_RANDOM ////////////// @@ -3778,6 +3796,9 @@ static luaL_Reg lib[] = { {"M_GetColorAfter",lib_pGetColorAfter}, {"M_GetColorBefore",lib_pGetColorBefore}, + // m_misc + {"M_MapNumber",lib_mMapNumber}, + // m_random {"P_RandomFixed",lib_pRandomFixed}, {"P_RandomByte",lib_pRandomByte}, From 07801a2a184b2120608759f80889a3a6113a02d3 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Fri, 28 May 2021 18:42:19 +0100 Subject: [PATCH 0789/1080] move P_MapEnd call in P_LoadLevel further down, so that the P_MapStart/End pair also encloses cached actions and the MapLoad Lua hook --- 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 16c080248..1abdccc21 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -4223,7 +4223,7 @@ boolean P_LoadLevel(boolean fromnetsave, boolean reloadinggamestate) P_ResetWaypoints(); - P_MapStart(); + P_MapStart(); // tmthing can be used starting from this point if (!P_LoadMapFromFile()) return false; @@ -4276,8 +4276,6 @@ boolean P_LoadLevel(boolean fromnetsave, boolean reloadinggamestate) // clear special respawning que iquehead = iquetail = 0; - P_MapEnd(); - // Remove the loading shit from the screen if (rendermode != render_none && !(titlemapinaction || reloadinggamestate)) F_WipeColorFill(levelfadecol); @@ -4323,6 +4321,8 @@ boolean P_LoadLevel(boolean fromnetsave, boolean reloadinggamestate) LUAh_MapLoad(); } + P_MapEnd(); // tmthing is no longer needed from this point onwards + // No render mode or reloading gamestate, stop here. if (rendermode == render_none || reloadinggamestate) return true; From ada6ec07dbc76d0d6e732e3b761ef79819c38412 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Fri, 28 May 2021 18:47:09 +0100 Subject: [PATCH 0790/1080] Fix Lua versions of P_ZMovement and its clones as well as P_MovePlayer so tmthing changes don't linger afterwards --- src/lua_baselib.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index df370a431..daf1ee6b0 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -1044,48 +1044,56 @@ static int lib_pSceneryXYMovement(lua_State *L) static int lib_pZMovement(lua_State *L) { mobj_t *actor = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); + mobj_t *ptmthing = tmthing; NOHUD INLEVEL if (!actor) return LUA_ErrInvalid(L, "mobj_t"); lua_pushboolean(L, P_ZMovement(actor)); P_CheckPosition(actor, actor->x, actor->y); + P_SetTarget(&tmthing, ptmthing); return 1; } static int lib_pRingZMovement(lua_State *L) { mobj_t *actor = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); + mobj_t *ptmthing = tmthing; NOHUD INLEVEL if (!actor) return LUA_ErrInvalid(L, "mobj_t"); P_RingZMovement(actor); P_CheckPosition(actor, actor->x, actor->y); + P_SetTarget(&tmthing, ptmthing); return 0; } static int lib_pSceneryZMovement(lua_State *L) { mobj_t *actor = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); + mobj_t *ptmthing = tmthing; NOHUD INLEVEL if (!actor) return LUA_ErrInvalid(L, "mobj_t"); lua_pushboolean(L, P_SceneryZMovement(actor)); P_CheckPosition(actor, actor->x, actor->y); + P_SetTarget(&tmthing, ptmthing); return 1; } static int lib_pPlayerZMovement(lua_State *L) { mobj_t *actor = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); + mobj_t *ptmthing = tmthing; NOHUD INLEVEL if (!actor) return LUA_ErrInvalid(L, "mobj_t"); P_PlayerZMovement(actor); P_CheckPosition(actor, actor->x, actor->y); + P_SetTarget(&tmthing, ptmthing); return 0; } @@ -1472,11 +1480,13 @@ static int lib_pSpawnSkidDust(lua_State *L) static int lib_pMovePlayer(lua_State *L) { player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); + mobj_t *ptmthing = tmthing; NOHUD INLEVEL if (!player) return LUA_ErrInvalid(L, "player_t"); P_MovePlayer(player); + P_SetTarget(&tmthing, ptmthing); return 0; } From 45b1223f3e356544ef8968c1d7054727e261cd1e Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Fri, 28 May 2021 18:56:32 +0100 Subject: [PATCH 0791/1080] My mistake, `P_PreTicker` calls `P_MapStart` and `P_MapEnd` too, so rework my earlier fix a bit --- src/p_setup.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index 1abdccc21..913dfe403 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -4295,6 +4295,8 @@ boolean P_LoadLevel(boolean fromnetsave, boolean reloadinggamestate) P_RunCachedActions(); + P_MapEnd(); // tmthing is no longer needed from this point onwards + // Took me 3 hours to figure out why my progression kept on getting overwritten with the titlemap... if (!titlemapinaction) { @@ -4318,11 +4320,11 @@ boolean P_LoadLevel(boolean fromnetsave, boolean reloadinggamestate) G_CopyTiccmd(&players[i].cmd, &netcmds[buf][i], 1); } P_PreTicker(2); + P_MapStart(); // just in case MapLoad modifies tmthing LUAh_MapLoad(); + P_MapEnd(); // just in case MapLoad modifies tmthing } - P_MapEnd(); // tmthing is no longer needed from this point onwards - // No render mode or reloading gamestate, stop here. if (rendermode == render_none || reloadinggamestate) return true; From 21dab7bd6652688930879af9e42c2ec54dd46859 Mon Sep 17 00:00:00 2001 From: Riku Salminen <38985578+Riku-S@users.noreply.github.com> Date: Fri, 28 May 2021 22:30:43 +0300 Subject: [PATCH 0792/1080] Add previous demo version to acceptable demo versions for demo comparison --- src/g_demo.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/g_demo.c b/src/g_demo.c index ea71c9bd4..635b42b13 100644 --- a/src/g_demo.c +++ b/src/g_demo.c @@ -1668,6 +1668,7 @@ UINT8 G_CmpDemoTime(char *oldname, char *newname) switch(oldversion) // demoversion { case DEMOVERSION: // latest always supported + case 0x000d: // latest always supported case 0x000c: // all that changed between then and now was longer color name break; // too old, cannot support. From 22aaffa35d3bf2abb73a16b27f887162722ca0f4 Mon Sep 17 00:00:00 2001 From: Riku Salminen <38985578+Riku-S@users.noreply.github.com> Date: Fri, 28 May 2021 22:32:11 +0300 Subject: [PATCH 0793/1080] non-misleading comment --- src/g_demo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/g_demo.c b/src/g_demo.c index 635b42b13..16d29fb88 100644 --- a/src/g_demo.c +++ b/src/g_demo.c @@ -1668,7 +1668,7 @@ UINT8 G_CmpDemoTime(char *oldname, char *newname) switch(oldversion) // demoversion { case DEMOVERSION: // latest always supported - case 0x000d: // latest always supported + case 0x000d: // The previous demoversion also supported case 0x000c: // all that changed between then and now was longer color name break; // too old, cannot support. From 8d8f62baefdcbb1b71d75d505b95e3cc4a675056 Mon Sep 17 00:00:00 2001 From: flarn2006 Date: Fri, 28 May 2021 23:59:39 -0400 Subject: [PATCH 0794/1080] Add additional multitagging functionality --- extras/conf/SRB2-22.cfg | 14 ++++++++++++++ src/p_setup.c | 33 +++++++++++++++++++++++++++++---- 2 files changed, 43 insertions(+), 4 deletions(-) diff --git a/extras/conf/SRB2-22.cfg b/extras/conf/SRB2-22.cfg index d36c16b75..ad930a485 100644 --- a/extras/conf/SRB2-22.cfg +++ b/extras/conf/SRB2-22.cfg @@ -640,22 +640,36 @@ linedeftypes prefix = "(63)"; } + 96 + { + title = "Apply Tag to Tagged Sectors"; + prefix = "(96)"; + flags8192text = "[13] Use Front Side Offsets"; + flags32768text = "[15] Use Back Side Offsets"; + } + 97 { title = "Apply Tag to Front Sector"; prefix = "(97)"; + flags8192text = "[13] Use Front Side Offsets"; + flags32768text = "[15] Use Back Side Offsets"; } 98 { title = "Apply Tag to Back Sector"; prefix = "(98)"; + flags8192text = "[13] Use Front Side Offsets"; + flags32768text = "[15] Use Back Side Offsets"; } 99 { title = "Apply Tag to Front and Back Sectors"; prefix = "(99)"; + flags8192text = "[13] Use Front Side Offsets"; + flags32768text = "[15] Use Back Side Offsets"; } 540 diff --git a/src/p_setup.c b/src/p_setup.c index 16c080248..6375decac 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2952,19 +2952,44 @@ static void P_LinkMapData(void) // For maps in binary format, add multi-tags from linedef specials. This must be done // before any linedef specials have been processed. +static void P_AddBinaryMapTagsFromLine(sector_t *sector, line_t *line) +{ + Tag_Add(§or->tags, Tag_FGet(&line->tags)); + if (line->flags & ML_EFFECT6) { + if (sides[line->sidenum[0]].textureoffset) + Tag_Add(§or->tags, (INT32)sides[line->sidenum[0]].textureoffset); + if (sides[line->sidenum[0]].rowoffset) + Tag_Add(§or->tags, (INT32)sides[line->sidenum[0]].rowoffset); + } + if (line->flags & ML_TFERLINE) { + if (sides[line->sidenum[1]].textureoffset) + Tag_Add(§or->tags, (INT32)sides[line->sidenum[1]].textureoffset); + if (sides[line->sidenum[1]].rowoffset) + Tag_Add(§or->tags, (INT32)sides[line->sidenum[1]].rowoffset); + } +} + static void P_AddBinaryMapTags(void) { size_t i; for (i = 0; i < numlines; i++) { + // 96: Apply Tag to Tagged Sectors // 97: Apply Tag to Front Sector // 98: Apply Tag to Back Sector // 99: Apply Tag to Front and Back Sectors - if (lines[i].special == 97 || lines[i].special == 99) - Tag_Add(&lines[i].frontsector->tags, Tag_FGet(&lines[i].tags)); - if (lines[i].special == 98 || lines[i].special == 99) - Tag_Add(&lines[i].backsector->tags, Tag_FGet(&lines[i].tags)); + if (lines[i].special == 96) { + mtag_t tag = Tag_FGet(&lines[i].frontsector->tags); + INT32 s; + TAG_ITER_DECLARECOUNTER(0); + TAG_ITER_SECTORS(0, tag, s) + P_AddBinaryMapTagsFromLine(§ors[s], &lines[i]); + } else if (lines[i].special == 97 || lines[i].special == 99) { + P_AddBinaryMapTagsFromLine(lines[i].frontsector, &lines[i]); + } else if (lines[i].special == 98 || lines[i].special == 99) { + P_AddBinaryMapTagsFromLine(lines[i].backsector, &lines[i]); + } } } From 7d71d534d47941faaa5dbe962a20b52ab850a8b8 Mon Sep 17 00:00:00 2001 From: flarn2006 Date: Sat, 29 May 2021 00:40:06 -0400 Subject: [PATCH 0795/1080] Add missing "/ FRACUNIT" to texture offset code --- 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 6375decac..4bb47c943 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2957,15 +2957,15 @@ static void P_AddBinaryMapTagsFromLine(sector_t *sector, line_t *line) Tag_Add(§or->tags, Tag_FGet(&line->tags)); if (line->flags & ML_EFFECT6) { if (sides[line->sidenum[0]].textureoffset) - Tag_Add(§or->tags, (INT32)sides[line->sidenum[0]].textureoffset); + Tag_Add(§or->tags, (INT32)sides[line->sidenum[0]].textureoffset / FRACUNIT); if (sides[line->sidenum[0]].rowoffset) - Tag_Add(§or->tags, (INT32)sides[line->sidenum[0]].rowoffset); + Tag_Add(§or->tags, (INT32)sides[line->sidenum[0]].rowoffset / FRACUNIT); } if (line->flags & ML_TFERLINE) { if (sides[line->sidenum[1]].textureoffset) - Tag_Add(§or->tags, (INT32)sides[line->sidenum[1]].textureoffset); + Tag_Add(§or->tags, (INT32)sides[line->sidenum[1]].textureoffset / FRACUNIT); if (sides[line->sidenum[1]].rowoffset) - Tag_Add(§or->tags, (INT32)sides[line->sidenum[1]].rowoffset); + Tag_Add(§or->tags, (INT32)sides[line->sidenum[1]].rowoffset / FRACUNIT); } } From eee894581aecc4575baf0edb4cb46941806efbf8 Mon Sep 17 00:00:00 2001 From: flarn2006 Date: Sat, 29 May 2021 00:54:31 -0400 Subject: [PATCH 0796/1080] Make linedef 96 skip the control sector --- src/p_setup.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index 4bb47c943..336cf9886 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2983,8 +2983,10 @@ static void P_AddBinaryMapTags(void) mtag_t tag = Tag_FGet(&lines[i].frontsector->tags); INT32 s; TAG_ITER_DECLARECOUNTER(0); - TAG_ITER_SECTORS(0, tag, s) - P_AddBinaryMapTagsFromLine(§ors[s], &lines[i]); + TAG_ITER_SECTORS(0, tag, s) { + if (s != lines[i].frontsector - sectors) // Skip the control sector + P_AddBinaryMapTagsFromLine(§ors[s], &lines[i]); + } } else if (lines[i].special == 97 || lines[i].special == 99) { P_AddBinaryMapTagsFromLine(lines[i].frontsector, &lines[i]); } else if (lines[i].special == 98 || lines[i].special == 99) { From 93de054786147c7f64360177cd271ed70eedb2fb Mon Sep 17 00:00:00 2001 From: flarn2006 Date: Sat, 29 May 2021 11:08:46 -0400 Subject: [PATCH 0797/1080] Fix linedef type 96 (I had it all wrong) --- src/p_setup.c | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index 336cf9886..0d061aaab 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2980,12 +2980,36 @@ static void P_AddBinaryMapTags(void) // 98: Apply Tag to Back Sector // 99: Apply Tag to Front and Back Sectors if (lines[i].special == 96) { + size_t j; mtag_t tag = Tag_FGet(&lines[i].frontsector->tags); - INT32 s; - TAG_ITER_DECLARECOUNTER(0); - TAG_ITER_SECTORS(0, tag, s) { - if (s != lines[i].frontsector - sectors) // Skip the control sector - P_AddBinaryMapTagsFromLine(§ors[s], &lines[i]); + mtag_t target_tags[5]; + target_tags[0] = Tag_FGet(&lines[i].tags); + if (lines[i].flags & ML_EFFECT6) { + target_tags[1] = (INT32)sides[lines[i].sidenum[0]].textureoffset / FRACUNIT; + target_tags[2] = (INT32)sides[lines[i].sidenum[0]].rowoffset / FRACUNIT; + } else { + target_tags[1] = target_tags[2] = 0; + } + if (lines[i].flags & ML_TFERLINE) { + target_tags[3] = (INT32)sides[lines[i].sidenum[1]].textureoffset / FRACUNIT; + target_tags[4] = (INT32)sides[lines[i].sidenum[1]].rowoffset / FRACUNIT; + } else { + target_tags[3] = target_tags[4] = 0; + } + + for (j = 0; j < numsectors; j++) { + CONS_Printf("Sector %zu (tag %d):\n", j, Tag_FGet(§ors[j].tags)); + size_t k; for (k = 0; k < 5; k++) { + if (k > 0 && !target_tags[k]) + continue; + if (Tag_Find(§ors[j].tags, target_tags[k])) { + Tag_Add(§ors[j].tags, tag); + CONS_Printf(" Tag %d found, added tag %d\n", target_tags[k], tag); + break; + } else { + CONS_Printf(" Tag %d not found\n", target_tags[k]); + } + } } } else if (lines[i].special == 97 || lines[i].special == 99) { P_AddBinaryMapTagsFromLine(lines[i].frontsector, &lines[i]); From 5090de58097eed382a58402af0f3217eb3493381 Mon Sep 17 00:00:00 2001 From: flarn2006 Date: Sat, 29 May 2021 12:09:30 -0400 Subject: [PATCH 0798/1080] Remove leftover debug printfs --- src/p_setup.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index 0d061aaab..ea655f5f9 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2998,16 +2998,13 @@ static void P_AddBinaryMapTags(void) } for (j = 0; j < numsectors; j++) { - CONS_Printf("Sector %zu (tag %d):\n", j, Tag_FGet(§ors[j].tags)); size_t k; for (k = 0; k < 5; k++) { if (k > 0 && !target_tags[k]) continue; if (Tag_Find(§ors[j].tags, target_tags[k])) { Tag_Add(§ors[j].tags, tag); - CONS_Printf(" Tag %d found, added tag %d\n", target_tags[k], tag); break; } else { - CONS_Printf(" Tag %d not found\n", target_tags[k]); } } } From 2d4411d077a0d36a78707e655863b94afd127ec4 Mon Sep 17 00:00:00 2001 From: flarn2006 Date: Sat, 29 May 2021 12:23:35 -0400 Subject: [PATCH 0799/1080] Remove empty 'else' block (also leftover) --- src/p_setup.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/p_setup.c b/src/p_setup.c index ea655f5f9..095524203 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -3004,7 +3004,6 @@ static void P_AddBinaryMapTags(void) if (Tag_Find(§ors[j].tags, target_tags[k])) { Tag_Add(§ors[j].tags, tag); break; - } else { } } } From f8fe763df22285af086f51389186ebf8ab15b2b8 Mon Sep 17 00:00:00 2001 From: flarn2006 Date: Sat, 29 May 2021 12:28:06 -0400 Subject: [PATCH 0800/1080] Fix linedef type 99 --- src/p_setup.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index 095524203..f60af94ed 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -3007,10 +3007,11 @@ static void P_AddBinaryMapTags(void) } } } - } else if (lines[i].special == 97 || lines[i].special == 99) { - P_AddBinaryMapTagsFromLine(lines[i].frontsector, &lines[i]); - } else if (lines[i].special == 98 || lines[i].special == 99) { - P_AddBinaryMapTagsFromLine(lines[i].backsector, &lines[i]); + } else { + if (lines[i].special == 97 || lines[i].special == 99) + P_AddBinaryMapTagsFromLine(lines[i].frontsector, &lines[i]); + if (lines[i].special == 98 || lines[i].special == 99) + P_AddBinaryMapTagsFromLine(lines[i].backsector, &lines[i]); } } } From d10cf4faf52734dc48b7fe7d4865610bce018e0a Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Sat, 29 May 2021 22:54:58 +0100 Subject: [PATCH 0801/1080] A_Custom3DRotate: don't scale hspeed and vspeed - they are angular speeds, not linear! (I added the scaling to this action somewhere between 7-9 years ago, and somehow never knew I made this mistake until now, welp.) --- src/p_enemy.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/p_enemy.c b/src/p_enemy.c index 3b13fe295..b90a87cc0 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -9899,8 +9899,8 @@ void A_Custom3DRotate(mobj_t *actor) const fixed_t radius = FixedMul(loc1lw*FRACUNIT, actor->scale); const fixed_t hOff = FixedMul(loc1up*FRACUNIT, actor->scale); - const fixed_t hspeed = FixedMul(loc2up*FRACUNIT/10, actor->scale); - const fixed_t vspeed = FixedMul(loc2lw*FRACUNIT/10, actor->scale); + const fixed_t hspeed = loc2up*FRACUNIT/10; // Monster's note (29/05/21): DO NOT SCALE, this is an angular speed! + const fixed_t vspeed = loc2lw*FRACUNIT/10; // ditto if (LUA_CallAction(A_CUSTOM3DROTATE, actor)) return; From 0b51b391f1a7e61f1e64992c92cd96e483b1ed08 Mon Sep 17 00:00:00 2001 From: flarn2006 Date: Sun, 30 May 2021 12:16:15 -0400 Subject: [PATCH 0802/1080] Make 96's flags consistent with 97-99 by default --- extras/conf/SRB2-22.cfg | 17 +++++++++-------- src/p_setup.c | 35 +++++++++++++++++++---------------- 2 files changed, 28 insertions(+), 24 deletions(-) diff --git a/extras/conf/SRB2-22.cfg b/extras/conf/SRB2-22.cfg index ad930a485..5a464eb5d 100644 --- a/extras/conf/SRB2-22.cfg +++ b/extras/conf/SRB2-22.cfg @@ -644,32 +644,33 @@ linedeftypes { title = "Apply Tag to Tagged Sectors"; prefix = "(96)"; - flags8192text = "[13] Use Front Side Offsets"; - flags32768text = "[15] Use Back Side Offsets"; + flags1024text = "[10] Offsets are target tags"; + flags8192text = "[13] Use front side offsets"; + flags32768text = "[15] Use back side offsets"; } 97 { title = "Apply Tag to Front Sector"; prefix = "(97)"; - flags8192text = "[13] Use Front Side Offsets"; - flags32768text = "[15] Use Back Side Offsets"; + flags8192text = "[13] Use front side offsets"; + flags32768text = "[15] Use back side offsets"; } 98 { title = "Apply Tag to Back Sector"; prefix = "(98)"; - flags8192text = "[13] Use Front Side Offsets"; - flags32768text = "[15] Use Back Side Offsets"; + flags8192text = "[13] Use front side offsets"; + flags32768text = "[15] Use back side offsets"; } 99 { title = "Apply Tag to Front and Back Sectors"; prefix = "(99)"; - flags8192text = "[13] Use Front Side Offsets"; - flags32768text = "[15] Use Back Side Offsets"; + flags8192text = "[13] Use front side offsets"; + flags32768text = "[15] Use back side offsets"; } 540 diff --git a/src/p_setup.c b/src/p_setup.c index f60af94ed..7ecaf2ff4 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2982,28 +2982,31 @@ static void P_AddBinaryMapTags(void) if (lines[i].special == 96) { size_t j; mtag_t tag = Tag_FGet(&lines[i].frontsector->tags); - mtag_t target_tags[5]; - target_tags[0] = Tag_FGet(&lines[i].tags); + mtag_t target_tag = Tag_FGet(&lines[i].tags); + mtag_t offset_tags[4]; + memset(offset_tags, 0, sizeof(mtag_t)*4); if (lines[i].flags & ML_EFFECT6) { - target_tags[1] = (INT32)sides[lines[i].sidenum[0]].textureoffset / FRACUNIT; - target_tags[2] = (INT32)sides[lines[i].sidenum[0]].rowoffset / FRACUNIT; - } else { - target_tags[1] = target_tags[2] = 0; + offset_tags[1] = (INT32)sides[lines[i].sidenum[0]].textureoffset / FRACUNIT; + offset_tags[2] = (INT32)sides[lines[i].sidenum[0]].rowoffset / FRACUNIT; } if (lines[i].flags & ML_TFERLINE) { - target_tags[3] = (INT32)sides[lines[i].sidenum[1]].textureoffset / FRACUNIT; - target_tags[4] = (INT32)sides[lines[i].sidenum[1]].rowoffset / FRACUNIT; - } else { - target_tags[3] = target_tags[4] = 0; + offset_tags[3] = (INT32)sides[lines[i].sidenum[1]].textureoffset / FRACUNIT; + offset_tags[4] = (INT32)sides[lines[i].sidenum[1]].rowoffset / FRACUNIT; } for (j = 0; j < numsectors; j++) { - size_t k; for (k = 0; k < 5; k++) { - if (k > 0 && !target_tags[k]) - continue; - if (Tag_Find(§ors[j].tags, target_tags[k])) { - Tag_Add(§ors[j].tags, tag); - break; + boolean matches_target_tag = Tag_Find(§ors[j].tags, target_tag); + size_t k; for (k = 0; k < 4; k++) { + if (lines[i].flags & ML_EFFECT5) { + if (matches_target_tag || offset_tags[k] && Tag_Find(§ors[j].tags, offset_tags[k])) { + Tag_Add(§ors[j].tags, tag); + break; + } + } else if (matches_target_tag) { + if (k == 0) + Tag_Add(§ors[j].tags, tag); + if (offset_tags[k]) + Tag_Add(§ors[j].tags, offset_tags[k]); } } } From 92209bf246068c10b1ac318faecc85313dd85e8a Mon Sep 17 00:00:00 2001 From: Radicalicious Date: Mon, 31 May 2021 15:09:54 -0400 Subject: [PATCH 0803/1080] Update p_user.c --- 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 c5f919c78..6b3a8f585 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -2992,7 +2992,7 @@ static void P_CheckUnderwaterAndSpaceTimer(player_t *player) player->powers[pw_spacetime] = 0; // Underwater audio cues - if (P_IsLocalPlayer(player) && !player->bot) + if (P_IsLocalPlayer(player) && !player->bot && !(player->mo->eflags & MFE_COLDWATER)) { if ((player->powers[pw_underwater] == 25*TICRATE + 1) || (player->powers[pw_underwater] == 20*TICRATE + 1) From 3e91a8b2d4ce08cdcda59fd37db8b2c986397c6e Mon Sep 17 00:00:00 2001 From: Radicalicious Date: Mon, 31 May 2021 19:23:37 +0000 Subject: [PATCH 0804/1080] Revert "Update p_user.c" This reverts commit 92209bf246068c10b1ac318faecc85313dd85e8a --- 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 6b3a8f585..c5f919c78 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -2992,7 +2992,7 @@ static void P_CheckUnderwaterAndSpaceTimer(player_t *player) player->powers[pw_spacetime] = 0; // Underwater audio cues - if (P_IsLocalPlayer(player) && !player->bot && !(player->mo->eflags & MFE_COLDWATER)) + if (P_IsLocalPlayer(player) && !player->bot) { if ((player->powers[pw_underwater] == 25*TICRATE + 1) || (player->powers[pw_underwater] == 20*TICRATE + 1) From 172454f108ea17ee4c0b289df4924fc4dd8b1b02 Mon Sep 17 00:00:00 2001 From: flarn2006 Date: Tue, 1 Jun 2021 10:09:57 -0400 Subject: [PATCH 0805/1080] Fix offset_tags array indices --- 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 7ecaf2ff4..50b073a21 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2986,12 +2986,12 @@ static void P_AddBinaryMapTags(void) mtag_t offset_tags[4]; memset(offset_tags, 0, sizeof(mtag_t)*4); if (lines[i].flags & ML_EFFECT6) { - offset_tags[1] = (INT32)sides[lines[i].sidenum[0]].textureoffset / FRACUNIT; - offset_tags[2] = (INT32)sides[lines[i].sidenum[0]].rowoffset / FRACUNIT; + offset_tags[0] = (INT32)sides[lines[i].sidenum[0]].textureoffset / FRACUNIT; + offset_tags[1] = (INT32)sides[lines[i].sidenum[0]].rowoffset / FRACUNIT; } if (lines[i].flags & ML_TFERLINE) { - offset_tags[3] = (INT32)sides[lines[i].sidenum[1]].textureoffset / FRACUNIT; - offset_tags[4] = (INT32)sides[lines[i].sidenum[1]].rowoffset / FRACUNIT; + offset_tags[2] = (INT32)sides[lines[i].sidenum[1]].textureoffset / FRACUNIT; + offset_tags[3] = (INT32)sides[lines[i].sidenum[1]].rowoffset / FRACUNIT; } for (j = 0; j < numsectors; j++) { From 115254efc9e2b42c15c93d478611d0a64f4a27bd Mon Sep 17 00:00:00 2001 From: flarn2006 Date: Tue, 1 Jun 2021 17:10:29 -0400 Subject: [PATCH 0806/1080] Fix compiler warning related to precedence --- 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 50b073a21..61d1a5e46 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2998,7 +2998,7 @@ static void P_AddBinaryMapTags(void) boolean matches_target_tag = Tag_Find(§ors[j].tags, target_tag); size_t k; for (k = 0; k < 4; k++) { if (lines[i].flags & ML_EFFECT5) { - if (matches_target_tag || offset_tags[k] && Tag_Find(§ors[j].tags, offset_tags[k])) { + if (matches_target_tag || (offset_tags[k] && Tag_Find(§ors[j].tags, offset_tags[k]))) { Tag_Add(§ors[j].tags, tag); break; } From 8cb62eeca5515552d8d9745ea9356291697792a0 Mon Sep 17 00:00:00 2001 From: Nev3r Date: Wed, 2 Jun 2021 10:57:57 +0200 Subject: [PATCH 0807/1080] Initialize slopes before the map loads. --- src/p_setup.c | 2 ++ src/p_slopes.c | 10 +++++++--- src/p_slopes.h | 1 + 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index 51d2f474d..aa22fed86 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -4274,6 +4274,8 @@ boolean P_LoadLevel(boolean fromnetsave, boolean reloadinggamestate) P_MapStart(); // tmthing can be used starting from this point + P_InitSlopes(); + if (!P_LoadMapFromFile()) return false; diff --git a/src/p_slopes.c b/src/p_slopes.c index 4e93e4a45..9ce5af838 100644 --- a/src/p_slopes.c +++ b/src/p_slopes.c @@ -635,9 +635,6 @@ pslope_t *P_SlopeById(UINT16 id) void P_SpawnSlopes(const boolean fromsave) { size_t i; - slopelist = NULL; - slopecount = 0; - /// Generates vertex slopes. SpawnVertexSlopes(); @@ -671,6 +668,13 @@ void P_SpawnSlopes(const boolean fromsave) { } } +/// Initializes slopes. +void P_InitSlopes(void) +{ + slopelist = NULL; + slopecount = 0; +} + // ============================================================================ // // Various utilities related to slopes diff --git a/src/p_slopes.h b/src/p_slopes.h index ae040ae56..f627cae70 100644 --- a/src/p_slopes.h +++ b/src/p_slopes.h @@ -50,6 +50,7 @@ typedef enum void P_LinkSlopeThinkers (void); void P_CalculateSlopeNormal(pslope_t *slope); +void P_InitSlopes(void); void P_SpawnSlopes(const boolean fromsave); // From 36ce44e0a37b3f8deac01f109f5eb3f83ed9972a Mon Sep 17 00:00:00 2001 From: Nev3r Date: Wed, 2 Jun 2021 10:58:36 +0200 Subject: [PATCH 0808/1080] Add slope equation constant parsing functionality. --- src/p_slopes.c | 40 ++++++++++++++++++++++++++++++++++++++++ src/p_slopes.h | 1 + 2 files changed, 41 insertions(+) diff --git a/src/p_slopes.c b/src/p_slopes.c index 9ce5af838..09094a32a 100644 --- a/src/p_slopes.c +++ b/src/p_slopes.c @@ -90,6 +90,36 @@ static void ReconfigureViaVertexes (pslope_t *slope, const vector3_t v1, const v } } +/// Setup slope via constants. +static void ReconfigureViaConstants (pslope_t *slope, const fixed_t a, const fixed_t b, const fixed_t c, const fixed_t d) +{ + fixed_t m; + vector3_t *normal = &slope->normal; + + // Set origin. + FV3_Load(&slope->o, 0, 0, c ? -FixedDiv(d, c) : 0); + + // Get slope's normal. + FV3_Load(normal, a, b, c); + FV3_Normalize(normal); + + // Invert normal if it's facing down. + if (normal->z < 0) + FV3_Negate(normal); + + // Get direction vector + m = FixedHypot(normal->x, normal->y); + slope->d.x = -FixedDiv(normal->x, m); + slope->d.y = -FixedDiv(normal->y, m); + + // Z delta + slope->zdelta = FixedDiv(m, normal->z); + + // Get angles + slope->xydirection = R_PointToAngle2(0, 0, slope->d.x, slope->d.y)+ANGLE_180; + slope->zangle = InvAngle(R_PointToAngle2(0, 0, FRACUNIT, slope->zdelta)); +} + /// Recalculate dynamic slopes. void T_DynamicSlopeLine (dynplanethink_t* th) { @@ -631,6 +661,16 @@ pslope_t *P_SlopeById(UINT16 id) return ret; } +/// Creates a new slope from equation constants. +pslope_t *MakeViaEquationConstants(const fixed_t a, const fixed_t b, const fixed_t c, const fixed_t d) +{ + pslope_t* ret = Slope_Add(0); + + ReconfigureViaConstants(ret, a, b, c, d); + + return ret; +} + /// Initializes and reads the slopes from the map data. void P_SpawnSlopes(const boolean fromsave) { size_t i; diff --git a/src/p_slopes.h b/src/p_slopes.h index f627cae70..43cd3edb0 100644 --- a/src/p_slopes.h +++ b/src/p_slopes.h @@ -87,6 +87,7 @@ fixed_t P_GetWallTransferMomZ(mobj_t *mo, pslope_t *slope); void P_HandleSlopeLanding(mobj_t *thing, pslope_t *slope); void P_ButteredSlope(mobj_t *mo); +pslope_t *MakeViaEquationConstants(const fixed_t a, const fixed_t b, const fixed_t c, const fixed_t d); /// Dynamic plane type enum for the thinker. Will have a different functionality depending on this. typedef enum { From aec1ab304a154deb156a8c8e13fe39f6e74b8714 Mon Sep 17 00:00:00 2001 From: Nev3r Date: Wed, 2 Jun 2021 10:59:05 +0200 Subject: [PATCH 0809/1080] Let equation slopes be read from textmaps. --- src/p_setup.c | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) diff --git a/src/p_setup.c b/src/p_setup.c index aa22fed86..330b3e1fc 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -1501,6 +1501,22 @@ typedef struct textmap_colormap_s { textmap_colormap_t textmap_colormap = { false, 0, 25, 0, 25, 0, 31, 0 }; +typedef enum +{ + PD_A = 1, + PD_B = 1<<1, + PD_C = 1<<2, + PD_D = 1<<3, +} planedef_t; + +typedef struct textmap_plane_s { + UINT8 defined; + fixed_t a, b, c, d; +} textmap_plane_t; + +textmap_plane_t textmap_planefloor = {0, 0, 0, 0, 0}; +textmap_plane_t textmap_planeceiling = {0, 0, 0, 0, 0}; + static void ParseTextmapSectorParameter(UINT32 i, char *param, char *val) { if (fastcmp(param, "heightfloor")) @@ -1539,6 +1555,46 @@ static void ParseTextmapSectorParameter(UINT32 i, char *param, char *val) sectors[i].floorpic_angle = FixedAngle(FLOAT_TO_FIXED(atof(val))); else if (fastcmp(param, "rotationceiling")) sectors[i].ceilingpic_angle = FixedAngle(FLOAT_TO_FIXED(atof(val))); + else if (fastcmp(param, "floorplane_a")) + { + textmap_planefloor.defined |= PD_A; + textmap_planefloor.a = FLOAT_TO_FIXED(atof(val)); + } + else if (fastcmp(param, "floorplane_b")) + { + textmap_planefloor.defined |= PD_B; + textmap_planefloor.a = FLOAT_TO_FIXED(atof(val)); + } + else if (fastcmp(param, "floorplane_c")) + { + textmap_planefloor.defined |= PD_C; + textmap_planefloor.a = FLOAT_TO_FIXED(atof(val)); + } + else if (fastcmp(param, "floorplane_d")) + { + textmap_planefloor.defined |= PD_D; + textmap_planefloor.a = FLOAT_TO_FIXED(atof(val)); + } + else if (fastcmp(param, "ceilingplane_a")) + { + textmap_planeceiling.defined |= PD_A; + textmap_planeceiling.a = FLOAT_TO_FIXED(atof(val)); + } + else if (fastcmp(param, "ceilingplane_b")) + { + textmap_planeceiling.defined |= PD_B; + textmap_planeceiling.a = FLOAT_TO_FIXED(atof(val)); + } + else if (fastcmp(param, "ceilingplane_c")) + { + textmap_planeceiling.defined |= PD_C; + textmap_planeceiling.a = FLOAT_TO_FIXED(atof(val)); + } + else if (fastcmp(param, "ceilingplane_d")) + { + textmap_planeceiling.defined |= PD_D; + textmap_planeceiling.a = FLOAT_TO_FIXED(atof(val)); + } else if (fastcmp(param, "lightcolor")) { textmap_colormap.used = true; @@ -1868,6 +1924,10 @@ static void P_LoadTextmap(void) textmap_colormap.fadestart = 0; textmap_colormap.fadeend = 31; textmap_colormap.flags = 0; + + textmap_planefloor.defined = 0; + textmap_planeceiling.defined = 0; + TextmapParse(sectorsPos[i], i, ParseTextmapSectorParameter); P_InitializeSector(sc); @@ -1877,6 +1937,19 @@ static void P_LoadTextmap(void) INT32 fadergba = P_ColorToRGBA(textmap_colormap.fadecolor, textmap_colormap.fadealpha); sc->extra_colormap = sc->spawn_extra_colormap = R_CreateColormap(rgba, fadergba, textmap_colormap.fadestart, textmap_colormap.fadeend, textmap_colormap.flags); } + + if (textmap_planefloor.defined == (PD_A|PD_B|PD_C|PD_D)) + { + sc->f_slope = MakeViaEquationConstants(textmap_planefloor.a, textmap_planefloor.b, textmap_planefloor.c, textmap_planefloor.d); + sc->hasslope = true; + } + + if (textmap_planeceiling.defined == (PD_A|PD_B|PD_C|PD_D)) + { + sc->c_slope = MakeViaEquationConstants(textmap_planeceiling.a, textmap_planeceiling.b, textmap_planeceiling.c, textmap_planeceiling.d); + sc->hasslope = true; + } + TextmapFixFlatOffsets(sc); } From 9c68f8cbb0982a09eeeff4ec8df2486ac38f200f Mon Sep 17 00:00:00 2001 From: Nev3r Date: Wed, 2 Jun 2021 11:21:37 +0200 Subject: [PATCH 0810/1080] Fix the equation constant fields not being filled properly. --- src/p_setup.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index 330b3e1fc..c198d0c08 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -1563,17 +1563,17 @@ static void ParseTextmapSectorParameter(UINT32 i, char *param, char *val) else if (fastcmp(param, "floorplane_b")) { textmap_planefloor.defined |= PD_B; - textmap_planefloor.a = FLOAT_TO_FIXED(atof(val)); + textmap_planefloor.b = FLOAT_TO_FIXED(atof(val)); } else if (fastcmp(param, "floorplane_c")) { textmap_planefloor.defined |= PD_C; - textmap_planefloor.a = FLOAT_TO_FIXED(atof(val)); + textmap_planefloor.c = FLOAT_TO_FIXED(atof(val)); } else if (fastcmp(param, "floorplane_d")) { textmap_planefloor.defined |= PD_D; - textmap_planefloor.a = FLOAT_TO_FIXED(atof(val)); + textmap_planefloor.d = FLOAT_TO_FIXED(atof(val)); } else if (fastcmp(param, "ceilingplane_a")) { @@ -1583,17 +1583,17 @@ static void ParseTextmapSectorParameter(UINT32 i, char *param, char *val) else if (fastcmp(param, "ceilingplane_b")) { textmap_planeceiling.defined |= PD_B; - textmap_planeceiling.a = FLOAT_TO_FIXED(atof(val)); + textmap_planeceiling.b = FLOAT_TO_FIXED(atof(val)); } else if (fastcmp(param, "ceilingplane_c")) { textmap_planeceiling.defined |= PD_C; - textmap_planeceiling.a = FLOAT_TO_FIXED(atof(val)); + textmap_planeceiling.c = FLOAT_TO_FIXED(atof(val)); } else if (fastcmp(param, "ceilingplane_d")) { textmap_planeceiling.defined |= PD_D; - textmap_planeceiling.a = FLOAT_TO_FIXED(atof(val)); + textmap_planeceiling.d = FLOAT_TO_FIXED(atof(val)); } else if (fastcmp(param, "lightcolor")) { @@ -3308,7 +3308,7 @@ static void P_ConvertBinaryMap(void) lines[i].args[4] |= TMSC_BACKTOFRONTCEILING; lines[i].special = 720; break; - + case 900: //Translucent wall (10%) case 901: //Translucent wall (20%) case 902: //Translucent wall (30%) From a4300220e94d924d49a4a3067de0a348e16a3705 Mon Sep 17 00:00:00 2001 From: Nev3r Date: Wed, 2 Jun 2021 11:36:52 +0200 Subject: [PATCH 0811/1080] whitespace --- src/p_slopes.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_slopes.c b/src/p_slopes.c index 09094a32a..41cfbf337 100644 --- a/src/p_slopes.c +++ b/src/p_slopes.c @@ -817,7 +817,7 @@ void P_SlopeLaunch(mobj_t *mo) mo->momx = slopemom.x; mo->momy = slopemom.y; mo->momz = slopemom.z/2; - + if (mo->player) mo->player->powers[pw_justlaunched] = 1; } From 476dcc861be0c82e4a99f9379970588c95cbcefa Mon Sep 17 00:00:00 2001 From: lachablock Date: Thu, 3 Jun 2021 14:36:29 +1000 Subject: [PATCH 0812/1080] Restore P_AproxDistance Lua parity --- src/lua_baselib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 1a0b53920..594ac6af2 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -444,7 +444,7 @@ static int lib_pAproxDistance(lua_State *L) fixed_t dx = luaL_checkfixed(L, 1); fixed_t dy = luaL_checkfixed(L, 2); //HUDSAFE - lua_pushfixed(L, R_PointToDist2(0, 0, dx, dy)); + lua_pushfixed(L, P_AproxDistance(dx, dy)); return 1; } From cb5e433a49c61fda688de6d5dd5910c106df34e3 Mon Sep 17 00:00:00 2001 From: Radicalicious Date: Thu, 3 Jun 2021 09:34:18 -0400 Subject: [PATCH 0813/1080] Update lua_hudlib.c --- src/lua_hudlib.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/src/lua_hudlib.c b/src/lua_hudlib.c index 684e47c38..14d7d7f3c 100644 --- a/src/lua_hudlib.c +++ b/src/lua_hudlib.c @@ -794,6 +794,27 @@ static int libd_drawString(lua_State *L) return 0; } +static int libd_drawLevelActNum(lua_State *L) +{ + INT32 x; + INT32 y; + INT32 flags; + UINT8 num; + + HUDONLY + + x = luaL_checkinteger(L, 1); + y = luaL_checkinteger(L, 2); + flags = luaL_optinteger(L, 3, 0); + num = luaL_checkinteger(L, 4); + + flags &= ~V_PARAMMASK; // Don't let crashes happen. + + V_DrawLevelActNum(x, y, flags, num); + return 0; +} + + static int libd_drawNameTag(lua_State *L) { INT32 x; @@ -878,6 +899,20 @@ static int libd_stringWidth(lua_State *L) return 1; } +static int libd_levelActNumWidth(lua_State *L) +{ + HUDONLY + lua_pushinteger(L, V_LevelActNumWidth(luaL_checkinteger(L, 1))); + return 1; +} + +static int libd_levelActNumHeight(lua_State *L) +{ + HUDONLY + lua_pushinteger(L, V_LevelActNumHeight(luaL_checkinteger(L, 1))); + return 1; +} + static int libd_nameTagWidth(lua_State *L) { HUDONLY @@ -1086,11 +1121,14 @@ static luaL_Reg lib_draw[] = { {"drawPaddedNum", libd_drawPaddedNum}, {"drawFill", libd_drawFill}, {"drawString", libd_drawString}, + {"drawLevelActNum", libd_drawLevelActNum}, {"drawNameTag", libd_drawNameTag}, {"drawScaledNameTag", libd_drawScaledNameTag}, {"fadeScreen", libd_fadeScreen}, // misc {"stringWidth", libd_stringWidth}, + {"levelActNumWidth", libd_levelActNumWidth}, + {"levelActNumHeight", libd_levelActNumHeight}, {"nameTagWidth", libd_nameTagWidth}, // m_random {"RandomFixed",libd_RandomFixed}, From 6ff212b79f4bc97b2f34edf2ebc62e79e64ca519 Mon Sep 17 00:00:00 2001 From: sphere Date: Thu, 3 Jun 2021 16:01:09 +0200 Subject: [PATCH 0814/1080] Use floating-point math for polyobject planes as well. --- src/r_plane.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/r_plane.c b/src/r_plane.c index 4c757d8ca..818770906 100644 --- a/src/r_plane.c +++ b/src/r_plane.c @@ -380,9 +380,11 @@ visplane_t *R_FindPlane(fixed_t height, INT32 picnum, INT32 lightlevel, { if (polyobj->angle != 0) { - angle_t fineshift = polyobj->angle >> ANGLETOFINESHIFT; - xoff -= FixedMul(FINECOSINE(fineshift), polyobj->centerPt.x)+FixedMul(FINESINE(fineshift), polyobj->centerPt.y); - yoff -= FixedMul(FINESINE(fineshift), polyobj->centerPt.x)-FixedMul(FINECOSINE(fineshift), polyobj->centerPt.y); + float ang = ANG2RAD(polyobj->angle); + float x = FixedToFloat(polyobj->centerPt.x); + float y = FixedToFloat(polyobj->centerPt.y); + xoff -= FloatToFixed(x * cos(ang) + y * sin(ang)); + yoff -= FloatToFixed(x * sin(ang) - y * cos(ang)); } else { From 7483a9d049230e983e5fd8b44dd733c7bf26bb16 Mon Sep 17 00:00:00 2001 From: Radicalicious Date: Thu, 3 Jun 2021 10:55:42 -0400 Subject: [PATCH 0815/1080] Switch num and flags so flags is optional --- src/lua_hudlib.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lua_hudlib.c b/src/lua_hudlib.c index 14d7d7f3c..5e974675f 100644 --- a/src/lua_hudlib.c +++ b/src/lua_hudlib.c @@ -798,15 +798,15 @@ static int libd_drawLevelActNum(lua_State *L) { INT32 x; INT32 y; - INT32 flags; UINT8 num; + INT32 flags; HUDONLY x = luaL_checkinteger(L, 1); y = luaL_checkinteger(L, 2); - flags = luaL_optinteger(L, 3, 0); - num = luaL_checkinteger(L, 4); + num = luaL_checkinteger(L, 3); + flags = luaL_optinteger(L, 4, 0); flags &= ~V_PARAMMASK; // Don't let crashes happen. From 409cba678dcabcc7cb2960cf3d444a45b064a47b Mon Sep 17 00:00:00 2001 From: GoldenTails Date: Sat, 5 Jun 2021 18:35:44 -0500 Subject: [PATCH 0816/1080] metalrecording --- src/lua_script.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/lua_script.c b/src/lua_script.c index 6b8613812..4e04c2ee0 100644 --- a/src/lua_script.c +++ b/src/lua_script.c @@ -184,6 +184,9 @@ int LUA_PushGlobals(lua_State *L, const char *word) } else if (fastcmp(word,"modeattacking")) { lua_pushboolean(L, modeattacking); return 1; + } else if (fastcmp(word,"metalrecording")) { + lua_pushboolean(L, metalrecording); + return 1; } else if (fastcmp(word,"splitscreen")) { lua_pushboolean(L, splitscreen); return 1; From 0f4eb4fab949976276c4a8e9426d45bbfc275eec Mon Sep 17 00:00:00 2001 From: James R Date: Mon, 7 Jun 2021 18:13:22 -0700 Subject: [PATCH 0817/1080] Merge conflicts 4d22b9f17 --- src/lua_hook.h | 6 +++++- src/lua_hooklib.c | 45 ++++++++++++++++++++++++++++++++++++++++----- src/p_user.c | 46 +++++++++++++++++++++++----------------------- 3 files changed, 68 insertions(+), 29 deletions(-) diff --git a/src/lua_hook.h b/src/lua_hook.h index 0f8482794..b44233734 100644 --- a/src/lua_hook.h +++ b/src/lua_hook.h @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 2012-2016 by John "JTE" Muniz. -// Copyright (C) 2012-2020 by Sonic Team Junior. +// Copyright (C) 2012-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -68,6 +68,8 @@ automatically. X (GameQuit),\ X (PlayerCmd),/* building the player's ticcmd struct (Ported from SRB2Kart) */\ X (MusicChange),\ + X (PlayerHeight),/* override player height */\ + X (PlayerCanEnterSpinGaps),\ #define STRING_HOOK_LIST(X) \ X (BotAI),/* B_BuildTailsTiccmd by skin name */\ @@ -124,3 +126,5 @@ int LUA_HookSeenPlayer(player_t *player, player_t *seenfriend); int LUA_HookShouldJingleContinue(player_t *, const char *musname); int LUA_HookPlayerCmd(player_t *, ticcmd_t *); int LUA_HookMusicChange(const char *oldname, struct MusicChange *); +fixed_t LUA_HookPlayerHeight(player_t *player); +int LUA_HookPlayerCanEnterSpinGaps(player_t *player); diff --git a/src/lua_hooklib.c b/src/lua_hooklib.c index 7f5e3dc96..9f4fa4c88 100644 --- a/src/lua_hooklib.c +++ b/src/lua_hooklib.c @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 2012-2016 by John "JTE" Muniz. -// Copyright (C) 2012-2020 by Sonic Team Junior. +// Copyright (C) 2012-2021 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -231,7 +231,7 @@ typedef struct Hook_State Hook_State; typedef void (*Hook_Callback)(Hook_State *); struct Hook_State { - int status;/* return status to calling function */ + INT32 status;/* return status to calling function */ void * userdata; int hook_type; mobjtype_t mobj_type;/* >0 if mobj hook */ @@ -1005,13 +1005,13 @@ static void res_musicchange(Hook_State *hook) if (lua_isboolean(gL, -4)) *musicchange->looping = lua_toboolean(gL, -4); // output 4: position override - if (lua_isboolean(gL, -3)) + if (lua_isnumber(gL, -3)) *musicchange->position = lua_tonumber(gL, -3); // output 5: prefadems override - if (lua_isboolean(gL, -2)) + if (lua_isnumber(gL, -2)) *musicchange->prefadems = lua_tonumber(gL, -2); // output 6: fadeinms override - if (lua_isboolean(gL, -1)) + if (lua_isnumber(gL, -1)) *musicchange->fadeinms = lua_tonumber(gL, -1); } @@ -1052,3 +1052,38 @@ int LUA_HookMusicChange(const char *oldname, struct MusicChange *param) return hook.status; } + +static void res_playerheight(Hook_State *hook) +{ + if (!lua_isnil(gL, -1)) + { + fixed_t returnedheight = lua_tonumber(gL, -1); + // 0 height has... strange results, but it's not problematic like negative heights are. + // when an object's height is set to a negative number directly with lua, it's forced to 0 instead. + // here, I think it's better to ignore negatives so that they don't replace any results of previous hooks! + if (returnedheight >= 0) + hook->status = returnedheight; + } +} + +fixed_t LUA_HookPlayerHeight(player_t *player) +{ + Hook_State hook; + if (prepare_hook(&hook, -1, HOOK(PlayerHeight))) + { + LUA_PushUserdata(gL, player, META_PLAYER); + call_hooks(&hook, 1, 1, res_playerheight); + } + return hook.status; +} + +int LUA_HookPlayerCanEnterSpinGaps(player_t *player) +{ + Hook_State hook; + if (prepare_hook(&hook, 0, HOOK(PlayerCanEnterSpinGaps))) + { + LUA_PushUserdata(gL, player, META_PLAYER); + call_hooks(&hook, 1, 1, res_force); + } + return hook.status; +} diff --git a/src/p_user.c b/src/p_user.c index 2b773c84a..c3184b52f 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -1111,7 +1111,7 @@ boolean P_PlayerCanDamage(player_t *player, mobj_t *thing) return false; { - UINT8 shouldCollide = LUAh_PlayerCanDamage(player, thing); + UINT8 shouldCollide = LUA_HookPlayerCanDamage(player, thing); if (P_MobjWasRemoved(thing)) return false; // removed??? if (shouldCollide == 1) @@ -1594,7 +1594,7 @@ boolean P_EvaluateMusicStatus(UINT16 status, const char *musname) break; case JT_OTHER: // Other state - result = LUAh_ShouldJingleContinue(&players[i], musname); + result = LUA_HookShouldJingleContinue(&players[i], musname); break; case JT_NONE: // Null state @@ -1860,7 +1860,7 @@ void P_SpawnShieldOrb(player_t *player) I_Error("P_SpawnShieldOrb: player->mo is NULL!\n"); #endif - if (LUAh_ShieldSpawn(player)) + if (LUA_HookPlayer(player, HOOK(ShieldSpawn))) return; if (player->powers[pw_shield] & SH_FORCE) @@ -4583,7 +4583,7 @@ static void P_DoSpinAbility(player_t *player, ticcmd_t *cmd) if (cmd->buttons & BT_SPIN) { - if (LUAh_SpinSpecial(player)) + if (LUA_HookPlayer(player, HOOK(SpinSpecial))) return; } @@ -5055,7 +5055,7 @@ static boolean P_PlayerShieldThink(player_t *player, ticcmd_t *cmd, mobj_t *lock } } } - if ((!(player->charflags & SF_NOSHIELDABILITY)) && (cmd->buttons & BT_SPIN && !LUAh_ShieldSpecial(player))) // Spin button effects + if ((!(player->charflags & SF_NOSHIELDABILITY)) && (cmd->buttons & BT_SPIN && !LUA_HookPlayer(player, HOOK(ShieldSpecial)))) // Spin button effects { // Force stop if ((player->powers[pw_shield] & ~(SH_FORCEHP|SH_STACK)) == SH_FORCE) @@ -5179,7 +5179,7 @@ static void P_DoJumpStuff(player_t *player, ticcmd_t *cmd) // and you don't have a shield, do it! P_DoSuperTransformation(player, false); } - else if (!LUAh_JumpSpinSpecial(player)) + else if (!LUA_HookPlayer(player, HOOK(JumpSpinSpecial))) switch (player->charability) { case CA_THOK: @@ -5252,7 +5252,7 @@ static void P_DoJumpStuff(player_t *player, ticcmd_t *cmd) if (cmd->buttons & BT_JUMP && !player->exiting && !P_PlayerInPain(player)) { - if (LUAh_JumpSpecial(player)) + if (LUA_HookPlayer(player, HOOK(JumpSpecial))) ; // all situations below this require jump button not to be pressed already else if (player->pflags & PF_JUMPDOWN) @@ -5287,7 +5287,7 @@ static void P_DoJumpStuff(player_t *player, ticcmd_t *cmd) }*/ else if (player->pflags & PF_JUMPED) { - if (!LUAh_AbilitySpecial(player)) + if (!LUA_HookPlayer(player, HOOK(AbilitySpecial))) switch (player->charability) { case CA_THOK: @@ -5480,7 +5480,7 @@ static void P_DoJumpStuff(player_t *player, ticcmd_t *cmd) } else if (player->pflags & PF_THOKKED) { - if (!LUAh_AbilitySpecial(player)) + if (!LUA_HookPlayer(player, HOOK(AbilitySpecial))) switch (player->charability) { case CA_FLY: @@ -5503,7 +5503,7 @@ static void P_DoJumpStuff(player_t *player, ticcmd_t *cmd) break; } } - else if ((!(player->charflags & SF_NOSHIELDABILITY)) && ((player->powers[pw_shield] & SH_NOSTACK) == SH_WHIRLWIND && !player->powers[pw_super] && !LUAh_ShieldSpecial(player))) + else if ((!(player->charflags & SF_NOSHIELDABILITY)) && ((player->powers[pw_shield] & SH_NOSTACK) == SH_WHIRLWIND && !player->powers[pw_super] && !LUA_HookPlayer(player, HOOK(ShieldSpecial)))) P_DoJumpShield(player); } @@ -8653,7 +8653,7 @@ void P_MovePlayer(player_t *player) { boolean atspinheight = false; fixed_t oldheight = player->mo->height; - fixed_t luaheight = LUAh_PlayerHeight(player); + fixed_t luaheight = LUA_HookPlayerHeight(player); if (luaheight != -1) { @@ -10515,7 +10515,7 @@ boolean P_SpectatorJoinGame(player_t *player) else changeto = (P_RandomFixed() & 1) + 1; - if (!LUAh_TeamSwitch(player, changeto, true, false, false)) + if (!LUA_HookTeamSwitch(player, changeto, true, false, false)) return false; if (player->mo) @@ -10532,7 +10532,7 @@ boolean P_SpectatorJoinGame(player_t *player) { // Call ViewpointSwitch hooks here. // The viewpoint was forcibly changed. - LUAh_ViewpointSwitch(player, &players[consoleplayer], true); + LUA_HookViewpointSwitch(player, &players[consoleplayer], true); displayplayer = consoleplayer; } @@ -10550,7 +10550,7 @@ boolean P_SpectatorJoinGame(player_t *player) // respawn in place and sit there for the rest of the round. if (!((gametyperules & GTR_HIDEFROZEN) && leveltime > (hidetime * TICRATE))) { - if (!LUAh_TeamSwitch(player, 3, true, false, false)) + if (!LUA_HookTeamSwitch(player, 3, true, false, false)) return false; if (player->mo) { @@ -10577,7 +10577,7 @@ boolean P_SpectatorJoinGame(player_t *player) { // Call ViewpointSwitch hooks here. // The viewpoint was forcibly changed. - LUAh_ViewpointSwitch(player, &players[consoleplayer], true); + LUA_HookViewpointSwitch(player, &players[consoleplayer], true); displayplayer = consoleplayer; } @@ -11503,7 +11503,7 @@ void P_PlayerThink(player_t *player) } if (player->playerstate == PST_REBORN) { - LUAh_PlayerThink(player); + LUA_HookPlayer(player, HOOK(PlayerThink)); return; } } @@ -11605,7 +11605,7 @@ void P_PlayerThink(player_t *player) if (player->playerstate == PST_DEAD) { - LUAh_PlayerThink(player); + LUA_HookPlayer(player, HOOK(PlayerThink)); return; } } @@ -11726,7 +11726,7 @@ void P_PlayerThink(player_t *player) { player->mo->flags2 &= ~MF2_SHADOW; P_DeathThink(player); - LUAh_PlayerThink(player); + LUA_HookPlayer(player, HOOK(PlayerThink)); return; } @@ -11768,7 +11768,7 @@ void P_PlayerThink(player_t *player) { if (P_SpectatorJoinGame(player)) { - LUAh_PlayerThink(player); + LUA_HookPlayer(player, HOOK(PlayerThink)); return; // player->mo was removed. } } @@ -11873,7 +11873,7 @@ void P_PlayerThink(player_t *player) if (!player->mo) { - LUAh_PlayerThink(player); + LUA_HookPlayer(player, HOOK(PlayerThink)); return; // P_MovePlayer removed player->mo. } @@ -12327,7 +12327,7 @@ void P_PlayerThink(player_t *player) } #undef dashmode - LUAh_PlayerThink(player); + LUA_HookPlayer(player, HOOK(PlayerThink)); /* // Colormap verification @@ -12896,7 +12896,7 @@ void P_PlayerAfterThink(player_t *player) if (player->followmobj) { - if (LUAh_FollowMobj(player, player->followmobj) || P_MobjWasRemoved(player->followmobj)) + if (LUA_HookFollowMobj(player, player->followmobj) || P_MobjWasRemoved(player->followmobj)) {;} else { @@ -12975,7 +12975,7 @@ boolean P_PlayerFullbright(player_t *player) // returns true if the player can enter a sector that they could not if standing at their skin's full height boolean P_PlayerCanEnterSpinGaps(player_t *player) { - UINT8 canEnter = LUAh_PlayerCanEnterSpinGaps(player); + UINT8 canEnter = LUA_HookPlayerCanEnterSpinGaps(player); if (canEnter == 1) return true; else if (canEnter == 2) From 4d1b3edb035b362cf6c3e37f78ea755f4e61cf1b Mon Sep 17 00:00:00 2001 From: lachablock Date: Tue, 8 Jun 2021 17:21:54 +1000 Subject: [PATCH 0818/1080] Split up x/y/z averages in A_Boss3ShockThink --- src/p_enemy.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/p_enemy.c b/src/p_enemy.c index 9a9edb5e3..eb4b0c080 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -8272,7 +8272,7 @@ void A_Boss3ShockThink(mobj_t *actor) fixed_t x0, y0, x1, y1; // Break the link if movements are too different - if (FixedHypot(snext->momx - actor->momx, snext->momy - actor->momy) > 12*actor->scale) + if (R_PointToDist2(0, 0, snext->momx - actor->momx, snext->momy - actor->momy) > 12*actor->scale) { P_SetTarget(&actor->hnext, NULL); return; @@ -8283,9 +8283,11 @@ void A_Boss3ShockThink(mobj_t *actor) y0 = actor->y; x1 = snext->x; y1 = snext->y; - if (FixedHypot(x1 - x0, y1 - y0) > 2*actor->radius) + if (R_PointToDist2(0, 0, x1 - x0, y1 - y0) > 2*actor->radius) { - snew = P_SpawnMobj((x0 + x1) >> 1, (y0 + y1) >> 1, (actor->z + snext->z) >> 1, actor->type); + snew = P_SpawnMobj((x0 >> 1) + (x1 >> 1), + (y0 >> 1) + (y1 >> 1), + (actor->z >> 1) + (snext->z >> 1), actor->type); snew->momx = (actor->momx + snext->momx) >> 1; snew->momy = (actor->momy + snext->momy) >> 1; snew->momz = (actor->momz + snext->momz) >> 1; // is this really needed? From 976373dd37fa37531dcfb4df322e56b285b7abc2 Mon Sep 17 00:00:00 2001 From: Radicalicious Date: Tue, 8 Jun 2021 23:45:50 -0400 Subject: [PATCH 0819/1080] Calculate maxstep for pushables --- src/p_map.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/p_map.c b/src/p_map.c index 922c0d9ec..55b8a9d7e 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -2698,6 +2698,17 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff) { //All things are affected by their scale. fixed_t maxstep = FixedMul(MAXSTEPMOVE, thing->scale); + + if (thing->flags & MF_PUSHABLE) + { + // If using type Section1:13, double the maxstep. + if (GETSECSPECIAL(R_PointInSubsector(x, y)->sector->special, 1) == 13) + maxstep <<= 1; + + // If using type Section1:14, no maxstep. + if (GETSECSPECIAL(R_PointInSubsector(x, y)->sector->special, 1) == 14) + maxstep = 0; + } if (thing->player) { From fbeabad7972c966776a3d86617caefc799a1e440 Mon Sep 17 00:00:00 2001 From: Riku Salminen <38985578+Riku-S@users.noreply.github.com> Date: Wed, 9 Jun 2021 19:28:14 +0300 Subject: [PATCH 0820/1080] Revert "Made height/spinheight and height change values in replays more accurate" This reverts commit 3daee0ebf882d795ec0aef7fb54d48b74f940c59. --- src/g_demo.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/g_demo.c b/src/g_demo.c index 7793e0272..80968cd1c 100644 --- a/src/g_demo.c +++ b/src/g_demo.c @@ -463,7 +463,8 @@ void G_WriteGhostTic(mobj_t *ghost) WRITEUINT16(demo_p,oldghost.sprite); if (ghostext.flags & EZT_HEIGHT) { - WRITEFIXED(demo_p, height); + height >>= FRACBITS; + WRITEINT16(demo_p, height); } ghostext.flags = 0; } @@ -619,7 +620,7 @@ void G_ConsGhostTic(void) if (xziptic & EZT_SPRITE) demo_p += sizeof(UINT16); if (xziptic & EZT_HEIGHT) - demo_p += (demoversion < 0x000e) ? sizeof(INT16) : sizeof(fixed_t); + demo_p += sizeof(INT16); } if (ziptic & GZT_FOLLOW) @@ -853,7 +854,7 @@ void G_GhostTicker(void) g->mo->sprite = READUINT16(g->p); if (xziptic & EZT_HEIGHT) { - fixed_t temp = (g->version < 0x000e) ? READINT16(g->p)<p); + fixed_t temp = READINT16(g->p)<mo->height = FixedMul(temp, g->mo->scale); } } @@ -1117,7 +1118,7 @@ void G_ReadMetalTic(mobj_t *metal) metal->sprite = READUINT16(metal_p); if (xziptic & EZT_HEIGHT) { - fixed_t temp = (metalversion < 0x000e) ? READINT16(metal_p)<height = FixedMul(temp, metal->scale); } } @@ -1304,7 +1305,8 @@ void G_WriteMetalTic(mobj_t *metal) WRITEUINT16(demo_p,oldmetal.sprite); if (ghostext.flags & EZT_HEIGHT) { - WRITEFIXED(demo_p, height); + height >>= FRACBITS; + WRITEINT16(demo_p, height); } ghostext.flags = 0; } @@ -1484,8 +1486,8 @@ void G_BeginRecording(void) WRITEUINT8(demo_p,player->thrustfactor); WRITEUINT8(demo_p,player->accelstart); WRITEUINT8(demo_p,player->acceleration); - WRITEFIXED(demo_p,player->height); - WRITEFIXED(demo_p,player->spinheight); + WRITEUINT8(demo_p,player->height>>FRACBITS); + WRITEUINT8(demo_p,player->spinheight>>FRACBITS); WRITEUINT8(demo_p,player->camerascale>>FRACBITS); WRITEUINT8(demo_p,player->shieldscale>>FRACBITS); @@ -1911,8 +1913,8 @@ void G_DoPlayDemo(char *defdemoname) thrustfactor = READUINT8(demo_p); accelstart = READUINT8(demo_p); acceleration = READUINT8(demo_p); - height = (demoversion < 0x000e) ? (fixed_t)READUINT8(demo_p)< Date: Wed, 9 Jun 2021 19:40:59 +0300 Subject: [PATCH 0821/1080] Revert "Revert "Made height/spinheight and height change values in replays more accurate"" This reverts commit fbeabad7972c966776a3d86617caefc799a1e440. --- src/g_demo.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/src/g_demo.c b/src/g_demo.c index 80968cd1c..7793e0272 100644 --- a/src/g_demo.c +++ b/src/g_demo.c @@ -463,8 +463,7 @@ void G_WriteGhostTic(mobj_t *ghost) WRITEUINT16(demo_p,oldghost.sprite); if (ghostext.flags & EZT_HEIGHT) { - height >>= FRACBITS; - WRITEINT16(demo_p, height); + WRITEFIXED(demo_p, height); } ghostext.flags = 0; } @@ -620,7 +619,7 @@ void G_ConsGhostTic(void) if (xziptic & EZT_SPRITE) demo_p += sizeof(UINT16); if (xziptic & EZT_HEIGHT) - demo_p += sizeof(INT16); + demo_p += (demoversion < 0x000e) ? sizeof(INT16) : sizeof(fixed_t); } if (ziptic & GZT_FOLLOW) @@ -854,7 +853,7 @@ void G_GhostTicker(void) g->mo->sprite = READUINT16(g->p); if (xziptic & EZT_HEIGHT) { - fixed_t temp = READINT16(g->p)<version < 0x000e) ? READINT16(g->p)<p); g->mo->height = FixedMul(temp, g->mo->scale); } } @@ -1118,7 +1117,7 @@ void G_ReadMetalTic(mobj_t *metal) metal->sprite = READUINT16(metal_p); if (xziptic & EZT_HEIGHT) { - fixed_t temp = READINT16(metal_p)<height = FixedMul(temp, metal->scale); } } @@ -1305,8 +1304,7 @@ void G_WriteMetalTic(mobj_t *metal) WRITEUINT16(demo_p,oldmetal.sprite); if (ghostext.flags & EZT_HEIGHT) { - height >>= FRACBITS; - WRITEINT16(demo_p, height); + WRITEFIXED(demo_p, height); } ghostext.flags = 0; } @@ -1486,8 +1484,8 @@ void G_BeginRecording(void) WRITEUINT8(demo_p,player->thrustfactor); WRITEUINT8(demo_p,player->accelstart); WRITEUINT8(demo_p,player->acceleration); - WRITEUINT8(demo_p,player->height>>FRACBITS); - WRITEUINT8(demo_p,player->spinheight>>FRACBITS); + WRITEFIXED(demo_p,player->height); + WRITEFIXED(demo_p,player->spinheight); WRITEUINT8(demo_p,player->camerascale>>FRACBITS); WRITEUINT8(demo_p,player->shieldscale>>FRACBITS); @@ -1913,8 +1911,8 @@ void G_DoPlayDemo(char *defdemoname) thrustfactor = READUINT8(demo_p); accelstart = READUINT8(demo_p); acceleration = READUINT8(demo_p); - height = (fixed_t)READUINT8(demo_p)< Date: Wed, 9 Jun 2021 12:59:06 -0400 Subject: [PATCH 0822/1080] Fix player maxstep, oops --- src/p_map.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/p_map.c b/src/p_map.c index 55b8a9d7e..fbc7447ce 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -2698,17 +2698,6 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff) { //All things are affected by their scale. fixed_t maxstep = FixedMul(MAXSTEPMOVE, thing->scale); - - if (thing->flags & MF_PUSHABLE) - { - // If using type Section1:13, double the maxstep. - if (GETSECSPECIAL(R_PointInSubsector(x, y)->sector->special, 1) == 13) - maxstep <<= 1; - - // If using type Section1:14, no maxstep. - if (GETSECSPECIAL(R_PointInSubsector(x, y)->sector->special, 1) == 14) - maxstep = 0; - } if (thing->player) { @@ -2728,6 +2717,16 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff) && P_MobjFlip(thing)*thing->momz > FixedMul(FRACUNIT, thing->scale)) maxstep = 0; } + else if (thing->flags & MF_PUSHABLE) + { + // If using type Section1:13, double the maxstep. + if (GETSECSPECIAL(R_PointInSubsector(x, y)->sector->special, 1) == 13) + maxstep <<= 1; + + // If using type Section1:14, no maxstep. + if (GETSECSPECIAL(R_PointInSubsector(x, y)->sector->special, 1) == 14) + maxstep = 0; + } if (thing->type == MT_SKIM) maxstep = 0; From 52f9b47ce35008b8b4afce5bba2ccff73f5bfe17 Mon Sep 17 00:00:00 2001 From: sphere Date: Thu, 10 Jun 2021 17:49:33 +0200 Subject: [PATCH 0823/1080] Ignore a linedef tag of 0 when using linedef action 96. --- 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 51d2f474d..db44e4be0 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2995,7 +2995,7 @@ static void P_AddBinaryMapTags(void) } for (j = 0; j < numsectors; j++) { - boolean matches_target_tag = Tag_Find(§ors[j].tags, target_tag); + boolean matches_target_tag = target_tag && Tag_Find(§ors[j].tags, target_tag); size_t k; for (k = 0; k < 4; k++) { if (lines[i].flags & ML_EFFECT5) { if (matches_target_tag || (offset_tags[k] && Tag_Find(§ors[j].tags, offset_tags[k]))) { From 9210923b86ead23f81f16f1153f9b8d046431faa Mon Sep 17 00:00:00 2001 From: Radicalicious Date: Thu, 10 Jun 2021 12:59:54 -0400 Subject: [PATCH 0824/1080] Cut cv_hidetime's minimum value to 5 seconds --- 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 31c10f58a..78fc83474 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -286,7 +286,7 @@ consvar_t cv_gravity = CVAR_INIT ("gravity", "0.5", CV_RESTRICT|CV_FLOAT|CV_CALL consvar_t cv_soundtest = CVAR_INIT ("soundtest", "0", CV_CALL, NULL, SoundTest_OnChange); -static CV_PossibleValue_t minitimelimit_cons_t[] = {{15, "MIN"}, {9999, "MAX"}, {0, NULL}}; +static CV_PossibleValue_t minitimelimit_cons_t[] = {{5, "MIN"}, {9999, "MAX"}, {0, NULL}}; consvar_t cv_countdowntime = CVAR_INIT ("countdowntime", "60", CV_SAVE|CV_NETVAR|CV_CHEAT, minitimelimit_cons_t, NULL); consvar_t cv_touchtag = CVAR_INIT ("touchtag", "Off", CV_SAVE|CV_NETVAR, CV_OnOff, NULL); From f1a96bd7ee1df2e3cf0c2ab7b6b6f9ce4841778b Mon Sep 17 00:00:00 2001 From: Riku Salminen <38985578+Riku-S@users.noreply.github.com> Date: Thu, 10 Jun 2021 21:18:45 +0300 Subject: [PATCH 0825/1080] Add support for ghosts with netvars in 2.2.6 and before --- src/g_demo.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/g_demo.c b/src/g_demo.c index 7793e0272..45d09fdbd 100644 --- a/src/g_demo.c +++ b/src/g_demo.c @@ -726,6 +726,7 @@ void G_GhostTicker(void) g->mo->y = g->oldmo.y; g->mo->z = g->oldmo.z; P_SetThingPosition(g->mo); + g->mo->frame = g->oldmo.frame | tr_trans30<fadein) { @@ -2023,7 +2024,7 @@ void G_AddGhost(char *defdemoname) char name[17],skin[17],color[MAXCOLORNAME+1],*n,*pdemoname,md5[16]; UINT8 cnamelen; demoghost *gh; - UINT8 flags; + UINT8 flags, subversion; UINT8 *buffer,*p; mapthing_t *mthing; UINT16 count, ghostversion; @@ -2071,7 +2072,7 @@ void G_AddGhost(char *defdemoname) return; } p += 12; // DEMOHEADER p++; // VERSION - p++; // SUBVERSION + subversion = READUINT8(p); // SUBVERSION ghostversion = READUINT16(p); switch(ghostversion) { @@ -2170,9 +2171,19 @@ void G_AddGhost(char *defdemoname) count = READUINT16(p); while (count--) { - SKIPSTRING(p); - SKIPSTRING(p); - p++; + // In 2.2.7 netvar saving was updated + if (subversion < 7) + { + p += 2; + SKIPSTRING(p); + p++; + } + else + { + SKIPSTRING(p); + SKIPSTRING(p); + p++; + } } if (*p == DEMOMARKER) From 2a891546672cedc06174ab753c92d26316eb0240 Mon Sep 17 00:00:00 2001 From: Ors Date: Thu, 10 Jun 2021 14:23:51 -0400 Subject: [PATCH 0826/1080] Revert an accidental whitespace change --- src/g_demo.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/g_demo.c b/src/g_demo.c index 45d09fdbd..bf2013107 100644 --- a/src/g_demo.c +++ b/src/g_demo.c @@ -726,7 +726,6 @@ void G_GhostTicker(void) g->mo->y = g->oldmo.y; g->mo->z = g->oldmo.z; P_SetThingPosition(g->mo); - g->mo->frame = g->oldmo.frame | tr_trans30<fadein) { From 4c9b83b6bdd8cd3e2626505940de75668e3db0c2 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Thu, 10 Jun 2021 21:20:42 +0100 Subject: [PATCH 0827/1080] Allow P_CheckSight to see through FF_FOG FOFs --- src/p_sight.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/p_sight.c b/src/p_sight.c index e4a37a718..706745f35 100644 --- a/src/p_sight.c +++ b/src/p_sight.c @@ -307,7 +307,7 @@ static boolean P_CrossSubsector(size_t num, register los_t *los) for (rover = front->ffloors; rover; rover = rover->next) { if (!(rover->flags & FF_EXISTS) - || !(rover->flags & FF_RENDERSIDES) || rover->flags & FF_TRANSLUCENT) + || !(rover->flags & FF_RENDERSIDES) || (rover->flags & (FF_TRANSLUCENT|FF_FOG))) { continue; } @@ -323,7 +323,7 @@ static boolean P_CrossSubsector(size_t num, register los_t *los) for (rover = back->ffloors; rover; rover = rover->next) { if (!(rover->flags & FF_EXISTS) - || !(rover->flags & FF_RENDERSIDES) || rover->flags & FF_TRANSLUCENT) + || !(rover->flags & FF_RENDERSIDES) || (rover->flags & (FF_TRANSLUCENT|FF_FOG))) { continue; } @@ -452,7 +452,7 @@ boolean P_CheckSight(mobj_t *t1, mobj_t *t2) /// \todo Improve by checking fog density/translucency /// and setting a sight limit. if (!(rover->flags & FF_EXISTS) - || !(rover->flags & FF_RENDERPLANES) || rover->flags & FF_TRANSLUCENT) + || !(rover->flags & FF_RENDERPLANES) || (rover->flags & (FF_TRANSLUCENT|FF_FOG))) { continue; } From c9417f26e59bffcf2b0f2f5452d8ce5e98e2da55 Mon Sep 17 00:00:00 2001 From: James R Date: Thu, 10 Jun 2021 17:47:03 -0700 Subject: [PATCH 0828/1080] Fix pop original table in lua net archive --- src/lua_hooklib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lua_hooklib.c b/src/lua_hooklib.c index 9f4fa4c88..a8d49db7e 100644 --- a/src/lua_hooklib.c +++ b/src/lua_hooklib.c @@ -851,7 +851,7 @@ void LUA_HookNetArchive(lua_CFunction archFunc) init_hook_call(&hook, 1, 0, res_none); call_mapped(&hook, map); - lua_pop(gL, 2); // pop hook table and archFunc + lua_pop(gL, 1); // pop archFunc lua_remove(gL, EINDEX); // pop error handler // stack: tables } From 46ca9613c68422a26910cbb034a9f3e004a967c3 Mon Sep 17 00:00:00 2001 From: James R Date: Thu, 10 Jun 2021 18:09:39 -0700 Subject: [PATCH 0829/1080] Pop hook id fetched from table --- src/lua_hooklib.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/lua_hooklib.c b/src/lua_hooklib.c index a8d49db7e..63a1b111d 100644 --- a/src/lua_hooklib.c +++ b/src/lua_hooklib.c @@ -352,6 +352,7 @@ static void get_hook_from_table(Hook_State *hook, int n) { lua_rawgeti(gL, -1, n); hook->id = lua_tonumber(gL, -1); + lua_pop(gL, 1); lua_getref(gL, hookRefs[hook->id]); } From 460d46bbc9095820c9a3c84bf716079735977fea Mon Sep 17 00:00:00 2001 From: Radicalicious Date: Fri, 11 Jun 2021 10:52:31 -0400 Subject: [PATCH 0830/1080] Cut cv_hidetime's minimum value all the way down to 1 --- 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 78fc83474..c6091d9e0 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -286,7 +286,7 @@ consvar_t cv_gravity = CVAR_INIT ("gravity", "0.5", CV_RESTRICT|CV_FLOAT|CV_CALL consvar_t cv_soundtest = CVAR_INIT ("soundtest", "0", CV_CALL, NULL, SoundTest_OnChange); -static CV_PossibleValue_t minitimelimit_cons_t[] = {{5, "MIN"}, {9999, "MAX"}, {0, NULL}}; +static CV_PossibleValue_t minitimelimit_cons_t[] = {{1, "MIN"}, {9999, "MAX"}, {0, NULL}}; consvar_t cv_countdowntime = CVAR_INIT ("countdowntime", "60", CV_SAVE|CV_NETVAR|CV_CHEAT, minitimelimit_cons_t, NULL); consvar_t cv_touchtag = CVAR_INIT ("touchtag", "Off", CV_SAVE|CV_NETVAR, CV_OnOff, NULL); From 8be7c1a03d8a4c011b777eb41d8e906e4539e7bc Mon Sep 17 00:00:00 2001 From: James R Date: Fri, 11 Jun 2021 18:31:38 -0700 Subject: [PATCH 0831/1080] Fix double micros conv. blame e0a307da15 --- src/lua_hooklib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lua_hooklib.c b/src/lua_hooklib.c index 63a1b111d..2ecd12589 100644 --- a/src/lua_hooklib.c +++ b/src/lua_hooklib.c @@ -624,7 +624,7 @@ void LUA_HookThinkFrame(void) if (cv_perfstats.value == 3) { lua_Debug ar; - time_taken = I_PreciseToMicros(I_GetPreciseTime() - time_taken); + time_taken = I_GetPreciseTime() - time_taken; lua_getinfo(gL, ">S", &ar); PS_SetThinkFrameHookInfo(hook_index, time_taken, ar.short_src); hook_index++; From 781678389f8c591c5f201b2c789e5d92b90788c8 Mon Sep 17 00:00:00 2001 From: Radicalicious Date: Sat, 12 Jun 2021 20:36:57 -0400 Subject: [PATCH 0832/1080] Replace "II" with "2" for consistency --- src/f_finale.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/f_finale.c b/src/f_finale.c index 688cd4fc7..bfea57a60 100644 --- a/src/f_finale.c +++ b/src/f_finale.c @@ -1063,7 +1063,7 @@ boolean F_IntroResponder(event_t *event) // CREDITS // ========= static const char *credits[] = { - "\1Sonic Robo Blast II", + "\1Sonic Robo Blast 2", "\1Credits", "", "\1Game Design", From df5c9933ec355b2924c0dc8d10cf6044ec7fd4fd Mon Sep 17 00:00:00 2001 From: sphere Date: Wed, 16 Jun 2021 16:12:38 +0200 Subject: [PATCH 0833/1080] Restore toggle for Robo-Hood to not jump away from nearby players. --- extras/conf/SRB2-22.cfg | 1 + src/p_enemy.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/extras/conf/SRB2-22.cfg b/extras/conf/SRB2-22.cfg index 5a464eb5d..f457fe972 100644 --- a/extras/conf/SRB2-22.cfg +++ b/extras/conf/SRB2-22.cfg @@ -3589,6 +3589,7 @@ thingtypes sprite = "ARCHA1"; width = 24; height = 32; + flags8text = "[8] Don't jump away"; } 118 { diff --git a/src/p_enemy.c b/src/p_enemy.c index 9a9edb5e3..def3a87f5 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -1709,7 +1709,7 @@ void A_HoodThink(mobj_t *actor) dx = (actor->target->x - actor->x), dy = (actor->target->y - actor->y), dz = (actor->target->z - actor->z); dm = P_AproxDistance(dx, dy); // Target dangerously close to robohood, retreat then. - if ((dm < 256<flags2 & MF2_AMBUSH)) { S_StartSound(actor, actor->info->attacksound); P_SetMobjState(actor, actor->info->raisestate); From 3a044e71cc7cf6c80d9836189511c1a58c108370 Mon Sep 17 00:00:00 2001 From: James R Date: Wed, 16 Jun 2021 15:34:58 -0700 Subject: [PATCH 0834/1080] Disable EXE disassembly and compression by default NOOBJDUMP=1 and NOUPX=1 have been removed. Make 'dump' target to disassemble. UPX=upx to compress executable. Setting UPX used to cause it to fail. That has been fixed. --- src/Makefile | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/Makefile b/src/Makefile index 0c44afe55..6ec009044 100644 --- a/src/Makefile +++ b/src/Makefile @@ -15,6 +15,7 @@ # cleandep - remove dependency files for this build # distclean - remove entire executable, object and # dependency file directory structure. +# dump - disassemble executable # info - print settings # # This Makefile can automatically detect the host system @@ -83,8 +84,8 @@ # STATIC=1 - Use static linking. # DISTCC=1 # CCACHE=1 -# NOOBJDUMP=1 - Don't disassemble executable. -# NOUPX=1 - Don't compress executable. +# UPX= - UPX command to use for compressing final +# executable. # WINDOWSHELL=1 - Use Windows commands. # PREFIX= - Prefix to many commands, for cross compiling. # YASM=1 - Use Yasm instead of NASM assembler. @@ -165,7 +166,6 @@ ifdef WINDOWSHELL GZIP_OPTS+=--rsyncable endif -UPX?=upx UPX_OPTS?=--best --preserve-build-id ifndef ECHO UPX_OPTS+=-qq @@ -242,9 +242,7 @@ all : $(exe) $(call Echo,$(build_done)) ifndef VALGRIND -ifndef NOOBJDUMP -all : $(dbg).txt -endif +dump : $(dbg).txt endif ifdef STATIC @@ -310,7 +308,9 @@ LD:=$(CC) CC:=$(CC) $(CFLAGS) NASM:=$(NASM) $(NASMOPTS) -f $(nasm_format) GZIP:=$(GZIP) $(GZIP_OPTS) +ifdef UPX UPX:=$(UPX) $(UPX_OPTS) +endif WINDRES:=$(WINDRES) $(WINDRESFLAGS)\ $(debug_opts) --include-dir=win32 -O coff @@ -321,11 +321,14 @@ WINDRES:=$(WINDRES) $(WINDRESFLAGS)\ # prerequisites .SECONDEXPANSION : +# 'UPX' is also recognized in the enviornment by upx +unexport UPX + # executable stripped of debugging symbols $(exe) : $(dbg) | $$(@D)/ $(.)$(OBJCOPY) --strip-debug $< $@ $(.)-$(OBJCOPY) --add-gnu-debuglink=$< $@ -ifndef NOUPX +ifdef UPX $(call Echo,Compressing final executable...) $(.)-$(UPX) $@ endif From c142b3241ddb8f1ea9b5090d20dffa43a17129ab Mon Sep 17 00:00:00 2001 From: James R Date: Wed, 16 Jun 2021 15:48:16 -0700 Subject: [PATCH 0835/1080] Makefile: alert full path of final executable With added textual contrast. --- src/Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Makefile b/src/Makefile index 6ec009044..6d2d68477 100644 --- a/src/Makefile +++ b/src/Makefile @@ -236,7 +236,8 @@ DBGNAME?=$(EXENAME).debug exe:=$(bin)/$(EXENAME) dbg:=$(bin)/$(DBGNAME) -build_done=Build is done, please look for $( Date: Wed, 16 Jun 2021 15:57:08 -0700 Subject: [PATCH 0836/1080] Add a proxy Makefile at top level --- Makefile | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 000000000..7ee12d837 --- /dev/null +++ b/Makefile @@ -0,0 +1,8 @@ +ifdef SILENT +MAKEFLAGS+=--no-print-directory +endif + +all : + +% :: + @$(MAKE) -C src $(MAKECMDGOALS) From b04c79d8a7ba4ae8f888ab94d394b6714699e107 Mon Sep 17 00:00:00 2001 From: James R Date: Wed, 16 Jun 2021 16:58:47 -0700 Subject: [PATCH 0837/1080] Say 'at' --- src/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Makefile b/src/Makefile index 6d2d68477..18ab524b8 100644 --- a/src/Makefile +++ b/src/Makefile @@ -237,7 +237,7 @@ exe:=$(bin)/$(EXENAME) dbg:=$(bin)/$(DBGNAME) build_done==== Build is done, look for \ - $( Date: Thu, 17 Jun 2021 13:23:27 +0200 Subject: [PATCH 0838/1080] Add flag to line slopes for copying their slopes to the other side. --- extras/conf/SRB2-22.cfg | 16 ++++++++++++++++ src/p_setup.c | 6 ++++++ src/p_slopes.c | 3 +++ 3 files changed, 25 insertions(+) diff --git a/extras/conf/SRB2-22.cfg b/extras/conf/SRB2-22.cfg index 5a464eb5d..a9027f14a 100644 --- a/extras/conf/SRB2-22.cfg +++ b/extras/conf/SRB2-22.cfg @@ -2950,8 +2950,10 @@ linedeftypes prefix = "(700)"; flags2048text = "[11] No physics"; flags4096text = "[12] Dynamic"; + flags32768text = "[15] Copy to other side"; slope = "regular"; slopeargs = 1; + copyslopeargs = 1; } 701 @@ -2960,8 +2962,10 @@ linedeftypes prefix = "(701)"; flags2048text = "[11] No physics"; flags4096text = "[12] Dynamic"; + flags32768text = "[15] Copy to other side"; slope = "regular"; slopeargs = 2; + copyslopeargs = 4; } 702 @@ -2970,8 +2974,10 @@ linedeftypes prefix = "(702)"; flags2048text = "[11] No physics"; flags4096text = "[12] Dynamic"; + flags32768text = "[15] Copy to other side"; slope = "regular"; slopeargs = 3; + copyslopeargs = 5; } 703 @@ -2980,8 +2986,10 @@ linedeftypes prefix = "(703)"; flags2048text = "[11] No physics"; flags4096text = "[12] Dynamic"; + flags32768text = "[15] Copy to other side"; slope = "regular"; slopeargs = 9; + copyslopeargs = 8; } 704 @@ -3012,8 +3020,10 @@ linedeftypes prefix = "(710)"; flags2048text = "[11] No physics"; flags4096text = "[12] Dynamic"; + flags32768text = "[15] Copy to other side"; slope = "regular"; slopeargs = 4; + copyslopeargs = 2; } 711 @@ -3022,8 +3032,10 @@ linedeftypes prefix = "(711)"; flags2048text = "[11] No physics"; flags4096text = "[12] Dynamic"; + flags32768text = "[15] Copy to other side"; slope = "regular"; slopeargs = 8; + copyslopeargs = 8; } 712 @@ -3032,8 +3044,10 @@ linedeftypes prefix = "(712)"; flags2048text = "[11] No physics"; flags4096text = "[12] Dynamic"; + flags32768text = "[15] Copy to other side"; slope = "regular"; slopeargs = 12; + copyslopeargs = 10; } 713 @@ -3042,8 +3056,10 @@ linedeftypes prefix = "(713)"; flags2048text = "[11] No physics"; flags4096text = "[12] Dynamic"; + flags32768text = "[15] Copy to other side"; slope = "regular"; slopeargs = 6; + copyslopeargs = 6; } 714 diff --git a/src/p_setup.c b/src/p_setup.c index 51d2f474d..8d2ba4b01 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -3154,6 +3154,12 @@ static void P_ConvertBinaryMap(void) if (lines[i].flags & ML_NONET) lines[i].args[2] |= TMSL_DYNAMIC; + if (lines[i].flags & ML_TFERLINE) + { + lines[i].args[4] |= backfloor ? TMSC_BACKTOFRONTFLOOR : (frontfloor ? TMSC_FRONTTOBACKFLOOR : 0); + lines[i].args[4] |= backceil ? TMSC_BACKTOFRONTCEILING : (frontceil ? TMSC_FRONTTOBACKCEILING : 0); + } + lines[i].special = 700; break; } diff --git a/src/p_slopes.c b/src/p_slopes.c index 4e93e4a45..e99ecc64c 100644 --- a/src/p_slopes.c +++ b/src/p_slopes.c @@ -664,6 +664,9 @@ void P_SpawnSlopes(const boolean fromsave) { for (i = 0; i < numlines; i++) switch (lines[i].special) { + case 700: + if (lines[i].flags & ML_TFERLINE) P_CopySectorSlope(&lines[i]); + break; case 720: P_CopySectorSlope(&lines[i]); default: From e46afda89620a85fbfcf47afeaac5b436a4e587c Mon Sep 17 00:00:00 2001 From: Radicalicious Date: Fri, 18 Jun 2021 01:04:49 -0400 Subject: [PATCH 0839/1080] Hopefully fix ghosts --- src/g_demo.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/g_demo.c b/src/g_demo.c index 9d3b86015..1367c87b9 100644 --- a/src/g_demo.c +++ b/src/g_demo.c @@ -784,6 +784,18 @@ void G_GhostTicker(void) mobj = P_SpawnGhostMobj(g->mo); // does a large portion of the work for us mobj->frame = (mobj->frame & ~FF_FRAMEMASK)|tr_trans60<mo, 0, 0, g->mo->scale * 24, type); + mobj->angle = g->mo->angle + ANGLE_90; + mobj->fuse = 7; + mobj->scale = FRACUNIT / 3; + mobj->destscale = 10*FRACUNIT; + mobj->colorized = true; + mobj->color = g->mo->color; + mobj->momx = -g->mo->momx / 2; + mobj->momy = -g->mo->momy / 2; + } else { mobj = P_SpawnMobjFromMobj(g->mo, 0, 0, -FixedDiv(FixedMul(g->mo->info->height, g->mo->scale) - g->mo->height,3*FRACUNIT), MT_THOK); @@ -1074,6 +1086,18 @@ void G_ReadMetalTic(mobj_t *metal) { mobj = P_SpawnGhostMobj(metal); // does a large portion of the work for us } + else if (type == MT_THOKEFFECT) + { + mobj = P_SpawnMobjFromMobj(metal, 0, 0, metal->scale * 24, type); + mobj->angle = metal->angle + ANGLE_90; + mobj->fuse = 7; + mobj->scale = FRACUNIT / 3; + mobj->destscale = 10*FRACUNIT; + mobj->colorized = true; + mobj->color = metal->color; + mobj->momx = -metal->momx / 2; + mobj->momy = -metal->momy / 2; + } else { mobj = P_SpawnMobjFromMobj(metal, 0, 0, -FixedDiv(FixedMul(metal->info->height, metal->scale) - metal->height,3*FRACUNIT), MT_THOK); From 63d217b689ee4d39fc906a77e5b93b3557898fca Mon Sep 17 00:00:00 2001 From: Radicalicious Date: Fri, 18 Jun 2021 05:06:52 +0000 Subject: [PATCH 0840/1080] Revert "Hopefully fix ghosts" This reverts commit e46afda89620a85fbfcf47afeaac5b436a4e587c --- src/g_demo.c | 24 ------------------------ 1 file changed, 24 deletions(-) diff --git a/src/g_demo.c b/src/g_demo.c index 1367c87b9..9d3b86015 100644 --- a/src/g_demo.c +++ b/src/g_demo.c @@ -784,18 +784,6 @@ void G_GhostTicker(void) mobj = P_SpawnGhostMobj(g->mo); // does a large portion of the work for us mobj->frame = (mobj->frame & ~FF_FRAMEMASK)|tr_trans60<mo, 0, 0, g->mo->scale * 24, type); - mobj->angle = g->mo->angle + ANGLE_90; - mobj->fuse = 7; - mobj->scale = FRACUNIT / 3; - mobj->destscale = 10*FRACUNIT; - mobj->colorized = true; - mobj->color = g->mo->color; - mobj->momx = -g->mo->momx / 2; - mobj->momy = -g->mo->momy / 2; - } else { mobj = P_SpawnMobjFromMobj(g->mo, 0, 0, -FixedDiv(FixedMul(g->mo->info->height, g->mo->scale) - g->mo->height,3*FRACUNIT), MT_THOK); @@ -1086,18 +1074,6 @@ void G_ReadMetalTic(mobj_t *metal) { mobj = P_SpawnGhostMobj(metal); // does a large portion of the work for us } - else if (type == MT_THOKEFFECT) - { - mobj = P_SpawnMobjFromMobj(metal, 0, 0, metal->scale * 24, type); - mobj->angle = metal->angle + ANGLE_90; - mobj->fuse = 7; - mobj->scale = FRACUNIT / 3; - mobj->destscale = 10*FRACUNIT; - mobj->colorized = true; - mobj->color = metal->color; - mobj->momx = -metal->momx / 2; - mobj->momy = -metal->momy / 2; - } else { mobj = P_SpawnMobjFromMobj(metal, 0, 0, -FixedDiv(FixedMul(metal->info->height, metal->scale) - metal->height,3*FRACUNIT), MT_THOK); From c1aca51fc3815de8262381cd2235b1b4e1349841 Mon Sep 17 00:00:00 2001 From: James R Date: Sat, 19 Jun 2021 18:32:56 -0700 Subject: [PATCH 0841/1080] Fix basic warnings --- src/lua_inputlib.c | 2 +- src/sdl/i_video.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lua_inputlib.c b/src/lua_inputlib.c index 217202222..71eb1033f 100644 --- a/src/lua_inputlib.c +++ b/src/lua_inputlib.c @@ -117,7 +117,7 @@ static int lib_setMouseGrab(lua_State *L) return 0; } -static boolean lib_getCursorPosition(lua_State *L) +static int lib_getCursorPosition(lua_State *L) { int x, y; I_GetCursorPosition(&x, &y); diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index c387e5a18..234585cf3 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -407,7 +407,7 @@ void I_UpdateMouseGrab(void) boolean I_GetMouseGrab(void) { - return SDL_GetWindowGrab(window); + return (boolean)SDL_GetWindowGrab(window); } void I_SetMouseGrab(boolean grab) From 2d7a8c3c571bcc5335437e9db074c75af00408ce Mon Sep 17 00:00:00 2001 From: James R Date: Mon, 21 Jun 2021 14:47:42 -0700 Subject: [PATCH 0842/1080] Makefile: use shell commands to read in Sourcefile File function is not supported < Make 4.2. --- src/Makefile | 11 ++++++----- src/Makefile.d/platform.mk | 2 ++ src/Makefile.d/util.mk | 3 ++- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/Makefile b/src/Makefile index 18ab524b8..7104a91cf 100644 --- a/src/Makefile +++ b/src/Makefile @@ -176,11 +176,7 @@ include Makefile.d/detect.mk # make would try to remove the implicitly made directories .PRECIOUS : %/ comptime.c -# very sophisticated dependency -sources:=\ - $(call List,Sourcefile)\ - $(call List,blua/Sourcefile)\ - +sources:= makedir:=../make # -DCOMPVERSION: flag to use comptime.h @@ -204,6 +200,11 @@ endif depdir:=$(makedir)/deps objdir:=$(makedir)/objs +# very sophisticated dependency +sources+=\ + $(call List,Sourcefile)\ + $(call List,blua/Sourcefile)\ + depends:=$(basename $(filter %.c %.s,$(sources))) objects:=$(basename $(filter %.c %.s %.nas,$(sources))) diff --git a/src/Makefile.d/platform.mk b/src/Makefile.d/platform.mk index 531d073e9..fad4be191 100644 --- a/src/Makefile.d/platform.mk +++ b/src/Makefile.d/platform.mk @@ -7,9 +7,11 @@ PKG_CONFIG?=pkg-config ifdef WINDOWSHELL rmrf=-2>NUL DEL /S /Q mkdir=-2>NUL MD +cat=TYPE else rmrf=rm -rf mkdir=mkdir -p +cat=cat endif ifdef LINUX64 diff --git a/src/Makefile.d/util.mk b/src/Makefile.d/util.mk index e76e32422..bda68df13 100644 --- a/src/Makefile.d/util.mk +++ b/src/Makefile.d/util.mk @@ -10,7 +10,8 @@ Wildvar=$(foreach v,$(filter $(1),$(.VARIABLES)),$($(v))) # Read a list of words from file and prepend each with the # directory of the file. -List=$(addprefix $(dir $(1)),$(file < $(1))) +_cat=$(shell $(cat) $(call Windows_path,$(1))) +List=$(addprefix $(dir $(1)),$(call _cat,$(1))) # Convert path separators to backslash on Windows. Windows_path=$(if $(WINDOWSHELL),$(subst /,\,$(1)),$(1)) From d5146945a69ebf30e6fc1fbb64558e456e0b7459 Mon Sep 17 00:00:00 2001 From: James R Date: Mon, 21 Jun 2021 16:10:13 -0700 Subject: [PATCH 0843/1080] Makefile: don't automatically set WINDOWSHELL unless PATH matches Windows norms This is for MSYS2, which requires unix shell commands. --- src/Makefile.d/detect.mk | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Makefile.d/detect.mk b/src/Makefile.d/detect.mk index f576bcf78..89c193a32 100644 --- a/src/Makefile.d/detect.mk +++ b/src/Makefile.d/detect.mk @@ -29,7 +29,10 @@ $(call Print,$(_m)) # go for a 32-bit sdl mingw exe by default MINGW:=1 +# cmd.exe uses native Windows semicolon delimited PATH +ifneq (,$(findstring ;,$(PATH))) WINDOWSHELL:=1 +endif else # if you on the *nix From 389cea2bc18a29f34132c41ad1027a1e588b6205 Mon Sep 17 00:00:00 2001 From: GoldenTails Date: Tue, 22 Jun 2021 01:38:37 -0500 Subject: [PATCH 0844/1080] You probably don't want to memorise the formula to convert arccos to arcsin so --- src/lua_mathlib.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/lua_mathlib.c b/src/lua_mathlib.c index e6f8c98c1..bd9218a3d 100644 --- a/src/lua_mathlib.c +++ b/src/lua_mathlib.c @@ -88,6 +88,12 @@ static int lib_finetangent(lua_State *L) return 1; } +static int lib_fixedasin(lua_State *L) +{ + lua_pushangle(L, -FixedAcos(luaL_checkfixed(L, 1)) + ANGLE_90); + return 1; +} + static int lib_fixedacos(lua_State *L) { lua_pushangle(L, FixedAcos(luaL_checkfixed(L, 1))); @@ -199,6 +205,7 @@ static luaL_Reg lib_math[] = { {"sin", lib_finesine}, {"cos", lib_finecosine}, {"tan", lib_finetangent}, + {"asin", lib_fixedasin}, {"acos", lib_fixedacos}, {"FixedAngle", lib_fixedangle}, {"fixangle" , lib_fixedangle}, From 5f4d7e3c5b013afe03ae2a441c82ad79bae7c66c Mon Sep 17 00:00:00 2001 From: James R Date: Tue, 22 Jun 2021 15:14:42 -0700 Subject: [PATCH 0845/1080] Makefile: fail if old build directories exist After a checkout from before revision, old directories such as bin/Linux64 only remain if untracked files exist within. This may be confusing to the user. They may even use an outdated executable if it is one of those untracked files. --- src/Makefile | 6 +++++- src/Makefile.d/old.mk | 16 ++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 src/Makefile.d/old.mk diff --git a/src/Makefile b/src/Makefile index 7104a91cf..61a4c5e34 100644 --- a/src/Makefile +++ b/src/Makefile @@ -132,6 +132,10 @@ goals:=$(or $(MAKECMDGOALS),all) cleanonly:=$(filter $(clean_targets),$(goals)) destructive:=$(filter-out info,$(cleanonly)) +ifndef cleanonly +include Makefile.d/old.mk +endif + include Makefile.d/util.mk ifdef PREFIX @@ -399,7 +403,7 @@ clean : $(call _rm,$(exe) $(dbg) $(dbg).txt $(objects)) distclean : - $(call _rm,../bin ../objs ../deps comptime.h) + $(call _rm,../bin ../objs ../deps ../make comptime.h) info: ifdef WINDOWSHELL diff --git a/src/Makefile.d/old.mk b/src/Makefile.d/old.mk new file mode 100644 index 000000000..e5890eedd --- /dev/null +++ b/src/Makefile.d/old.mk @@ -0,0 +1,16 @@ +# +# Warn about old build directories and offer to purge. +# + +_old:=$(wildcard $(addprefix ../bin/,FreeBSD Linux \ + Linux64 Mingw Mingw64 SDL dummy) ../objs ../deps) + +ifdef _old +$(foreach v,$(_old),$(info $(abspath $(v)))) +$(info ) +$(info These directories are no longer\ + required and should be removed.) +$(info You may remove them manually or\ + by using 'make distclean') +$(error ) +endif From c3ad5de912fccfdd64c510f5684883afceaa7d36 Mon Sep 17 00:00:00 2001 From: James R Date: Tue, 22 Jun 2021 15:47:48 -0700 Subject: [PATCH 0846/1080] Makefile: let variables be defined on Make line If a variable is defined as in 'make CC=gcc-10', then that definition overrides anything other definition in the Makefile. --- src/Makefile | 51 ++++++++++++++++++++++++++------------------------- 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/src/Makefile b/src/Makefile index 61a4c5e34..90776b812 100644 --- a/src/Makefile +++ b/src/Makefile @@ -145,7 +145,7 @@ endif OBJDUMP_OPTS?=--wide --source --line-numbers OBJCOPY:=$(call Prefix,objcopy) -OBJDUMP:=$(call Prefix,objdump) $(OBJDUMP_OPTS) +OBJDUMP:=$(call Prefix,objdump) WINDRES:=$(call Prefix,windres) ifdef YASM @@ -273,16 +273,18 @@ opts+=$(debug_opts) opts+=$(foreach v,$(passthru_opts),$(if $($(v)),-D$(v))) -CFLAGS:=$(opts) $(WFLAGS) $(CPPFLAGS) $(CFLAGS) -LDFLAGS:=$(libs) $(LDFLAGS) -ASFLAGS+=-x assembler-with-cpp +opts+=$(WFLAGS) $(CPPFLAGS) $(CFLAGS) +libs+=$(LDFLAGS) +asflags:=$(ASFLAGS) -x assembler-with-cpp + +cc=$(CC) ifdef DISTCC -CC:=distcc $(CC) +cc=distcc $(CC) endif ifdef CCACHE -CC:=ccache $(CC) +cc=ccache $(CC) endif ifndef SILENT @@ -293,11 +295,11 @@ ifndef destructive $(shell $(CC) -v) define flags = -CC ........ $(CC) +CC ........ $(cc) -CFLAGS .... $(CFLAGS) +CFLAGS .... $(opts) -LDFLAGS ... $(LDFLAGS) +LDFLAGS ... $(libs) endef $(info $(flags)) @@ -311,13 +313,12 @@ endif endif LD:=$(CC) -CC:=$(CC) $(CFLAGS) -NASM:=$(NASM) $(NASMOPTS) -f $(nasm_format) -GZIP:=$(GZIP) $(GZIP_OPTS) +cc:=$(cc) $(opts) +nasm=$(NASM) $(NASMOPTS) -f $(nasm_format) ifdef UPX -UPX:=$(UPX) $(UPX_OPTS) +upx=$(UPX) $(UPX_OPTS) endif -WINDRES:=$(WINDRES) $(WINDRESFLAGS)\ +windres=$(WINDRES) $(WINDRESFLAGS)\ $(debug_opts) --include-dir=win32 -O coff %/ : @@ -327,7 +328,7 @@ WINDRES:=$(WINDRES) $(WINDRESFLAGS)\ # prerequisites .SECONDEXPANSION : -# 'UPX' is also recognized in the enviornment by upx +# 'UPX' is also recognized in the environment by upx unexport UPX # executable stripped of debugging symbols @@ -336,19 +337,19 @@ $(exe) : $(dbg) | $$(@D)/ $(.)-$(OBJCOPY) --add-gnu-debuglink=$< $@ ifdef UPX $(call Echo,Compressing final executable...) - $(.)-$(UPX) $@ + $(.)-$(upx) $@ endif # original executable with debugging symbols $(dbg) : $(objects) | $$(@D)/ $(call Echo,Linking $(@F)...) - $(.)$(LD) -o $@ $^ $(LDFLAGS) + $(.)$(LD) -o $@ $^ $(libs) # disassembly of executable $(dbg).txt : $(dbg) $(call Echo,Dumping debugging info...) - $(.)$(OBJDUMP) $< > $@ - $(.)$(GZIP) $@ + $(.)$(OBJDUMP) $(OBJDUMP_OPTS) $< > $@ + $(.)$(GZIP) $(GZIP_OPTS) $@ # '::' means run unconditionally # this really updates comptime.h @@ -373,11 +374,11 @@ ifdef Echo_name @printf '%-20.20s\r' $$< endif endif - $(.)$(CC) -MM -MF $$@ -MT $(objdir)/$$(*F).o $(2) $$< + $(.)$(cc) -MM -MF $$@ -MT $(objdir)/$$(*F).o $(2) $$< endef $(eval $(call _recipe,c)) -$(eval $(call _recipe,s,$(ASFLAGS))) +$(eval $(call _recipe,s,$(asflags))) # compiling recipe template # 1: target file suffix @@ -389,10 +390,10 @@ $(objdir)/%.$(1) : %.$(2) | $$$$(@D)/ $(.)$(3) endef -$(eval $(call _recipe,o,c,$(CC) -c -o $$@ $$<)) -$(eval $(call _recipe,o,nas,$(NASM) -o $$@ $$<)) -$(eval $(call _recipe,o,s,$(CC) $(ASFLAGS) -c -o $$@ $$<)) -$(eval $(call _recipe,res,rc,$(WINDRES) -i $$< -o $$@)) +$(eval $(call _recipe,o,c,$(cc) -c -o $$@ $$<)) +$(eval $(call _recipe,o,nas,$(nasm) -o $$@ $$<)) +$(eval $(call _recipe,o,s,$(cc) $(asflags) -c -o $$@ $$<)) +$(eval $(call _recipe,res,rc,$(windres) -i $$< -o $$@)) _rm=$(.)$(rmrf) $(call Windows_path,$(1)) From ed85e994a46ace07cf022b38a9abac1698a8667e Mon Sep 17 00:00:00 2001 From: James R Date: Tue, 22 Jun 2021 15:49:59 -0700 Subject: [PATCH 0847/1080] Remove misplaced parentheses --- 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 89c193a32..3edf0dad4 100644 --- a/src/Makefile.d/detect.mk +++ b/src/Makefile.d/detect.mk @@ -94,7 +94,7 @@ ifeq (,$(filter $(v),$(gcc_versions))) define line = Your compiler version, GCC $(version), \ is not supported by the Makefile. -The Makefile will assume GCC $(latest_gcc_version).)) +The Makefile will assume GCC $(latest_gcc_version). endef $(call Print,$(line)) GCC$(subst .,,$(latest_gcc_version)):=1 From 22272732f0e45d9cfa637880f8eb36b00bf838b3 Mon Sep 17 00:00:00 2001 From: flarn2006 Date: Sat, 26 Jun 2021 14:59:56 -0400 Subject: [PATCH 0848/1080] Exclude MT_BOXSPARKLE from Mario blocks --- src/p_floor.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/p_floor.c b/src/p_floor.c index d81a022e5..e98670f17 100644 --- a/src/p_floor.c +++ b/src/p_floor.c @@ -1062,6 +1062,7 @@ static mobj_t *SearchMarioNode(msecnode_t *node) case MT_HOOPCOLLIDE: case MT_NIGHTSCORE: case MT_NAMECHECK: // DEFINITELY not this, because it is client-side. + case MT_BOXSPARKLE: continue; default: break; From a5cd764772760583d55d4d116b3cbfdf09cafeaa Mon Sep 17 00:00:00 2001 From: flarn2006 Date: Sat, 26 Jun 2021 15:42:41 -0400 Subject: [PATCH 0849/1080] move MT_BOXSPARKLE in the list --- src/p_floor.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_floor.c b/src/p_floor.c index e98670f17..263644f70 100644 --- a/src/p_floor.c +++ b/src/p_floor.c @@ -1042,6 +1042,7 @@ static mobj_t *SearchMarioNode(msecnode_t *node) case MT_THUNDERCOIN_ORB: case MT_IVSP: case MT_SUPERSPARK: + case MT_BOXSPARKLE: case MT_RAIN: case MT_SNOWFLAKE: case MT_SPLISH: @@ -1062,7 +1063,6 @@ static mobj_t *SearchMarioNode(msecnode_t *node) case MT_HOOPCOLLIDE: case MT_NIGHTSCORE: case MT_NAMECHECK: // DEFINITELY not this, because it is client-side. - case MT_BOXSPARKLE: continue; default: break; From 90763d42e1352efb03a81fee3c53de7fcd9d0d3e Mon Sep 17 00:00:00 2001 From: James R Date: Tue, 29 Jun 2021 01:49:09 -0700 Subject: [PATCH 0850/1080] Shuffle LUA_HookKey --- src/lua_hook.h | 2 +- src/lua_hooklib.c | 22 +++++++++++----------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/lua_hook.h b/src/lua_hook.h index e3af951f5..223b83c61 100644 --- a/src/lua_hook.h +++ b/src/lua_hook.h @@ -107,6 +107,7 @@ void LUA_HookInt(INT32 integer, int hook); void LUA_HookBool(boolean value, int hook); int LUA_HookPlayer(player_t *, int hook); int LUA_HookTiccmd(player_t *, ticcmd_t *, int hook); +int LUA_HookKey(INT32 keycode, int hook); // Hooks for key events void LUA_HookThinkFrame(void); int LUA_HookMobjLineCollide(mobj_t *, line_t *); @@ -130,4 +131,3 @@ int LUA_HookPlayerCmd(player_t *, ticcmd_t *); int LUA_HookMusicChange(const char *oldname, struct MusicChange *); fixed_t LUA_HookPlayerHeight(player_t *player); int LUA_HookPlayerCanEnterSpinGaps(player_t *player); -int LUA_HookKey(INT32 keycode, int hooktype); // Hooks for key events diff --git a/src/lua_hooklib.c b/src/lua_hooklib.c index 39aa5ea18..6c709bf48 100644 --- a/src/lua_hooklib.c +++ b/src/lua_hooklib.c @@ -588,6 +588,17 @@ int LUA_HookTiccmd(player_t *player, ticcmd_t *cmd, int hook_type) return hook.status; } +int LUA_HookKey(INT32 keycode, int hook_type) +{ + Hook_State hook; + if (prepare_hook(&hook, false, hook_type)) + { + lua_pushinteger(gL, keycode); + call_hooks(&hook, 1, 0, res_true); + } + return hook.status; +} + /* ========================================================================= SPECIALIZED HOOKS ========================================================================= */ @@ -1088,14 +1099,3 @@ int LUA_HookPlayerCanEnterSpinGaps(player_t *player) } return hook.status; } - -int LUA_HookKey(INT32 keycode, int hooktype) -{ - Hook_State hook; - if (prepare_hook(&hook, 0, hooktype)) - { - lua_pushinteger(gL, keycode); - call_hooks(&hook, 1, 0, res_true); - } - return hook.status; -} From 7d01bd38d8dc7fc6744d20c3376e38ccdf480d9a Mon Sep 17 00:00:00 2001 From: James R Date: Tue, 29 Jun 2021 01:49:53 -0700 Subject: [PATCH 0851/1080] Fix return value of Lua key hooks not being used --- src/lua_hooklib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lua_hooklib.c b/src/lua_hooklib.c index 6c709bf48..d1b0d3bdd 100644 --- a/src/lua_hooklib.c +++ b/src/lua_hooklib.c @@ -594,7 +594,7 @@ int LUA_HookKey(INT32 keycode, int hook_type) if (prepare_hook(&hook, false, hook_type)) { lua_pushinteger(gL, keycode); - call_hooks(&hook, 1, 0, res_true); + call_hooks(&hook, 1, 1, res_true); } return hook.status; } From c1ecfa306f6a0b168d4f6cbc3224ebebd4deec51 Mon Sep 17 00:00:00 2001 From: James R Date: Tue, 29 Jun 2021 13:58:38 -0700 Subject: [PATCH 0852/1080] Makefile: 'dep' not 'deps' --- src/Makefile.d/old.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Makefile.d/old.mk b/src/Makefile.d/old.mk index e5890eedd..ec9b6d776 100644 --- a/src/Makefile.d/old.mk +++ b/src/Makefile.d/old.mk @@ -3,7 +3,7 @@ # _old:=$(wildcard $(addprefix ../bin/,FreeBSD Linux \ - Linux64 Mingw Mingw64 SDL dummy) ../objs ../deps) + Linux64 Mingw Mingw64 SDL dummy) ../objs ../dep) ifdef _old $(foreach v,$(_old),$(info $(abspath $(v)))) From c3fa9bea0fd6a426e448d4ecb8240a75593ecd50 Mon Sep 17 00:00:00 2001 From: CobaltBW Date: Tue, 29 Jun 2021 13:30:10 -0700 Subject: [PATCH 0853/1080] ri# mified: src/tazx# mofied: src/tazx# modified: src/tazx# modified: src/tazxc --- src/g_game.c | 5 +---- src/r_skins.c | 1 - 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index 83531bb35..9f2d05ff0 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -2317,16 +2317,13 @@ void G_Ticker(boolean run) P_ForceLocalAngle(&players[i], players[i].angleturn << 16); else players[i].cmd.angleturn = players[i].angleturn; - players[i].angleturn += players[i].cmd.angleturn - players[i].oldrelangleturn; - players[i].oldrelangleturn = players[i].cmd.angleturn; if (P_ControlStyle(&players[i]) == CS_LMAOGALOG) P_ForceLocalAngle(&players[i], players[i].angleturn << 16); else players[i].cmd.angleturn = players[i].angleturn; players[i].cmd.angleturn &= ~TICCMD_RECEIVED; - - // Use the leveltime sent in the player's ticcmd to determine control lag + // Use the leveltime sent in the player's ticcmd to determine control lag players[i].cmd.latency = min(((leveltime & 0xFF) - players[i].cmd.latency) & 0xFF, MAXPREDICTTICS-1); } else // Less work is required if we're building a bot ticcmd. diff --git a/src/r_skins.c b/src/r_skins.c index f67f2afd4..c734b6001 100644 --- a/src/r_skins.c +++ b/src/r_skins.c @@ -286,7 +286,6 @@ boolean R_SkinUsable(INT32 playernum, INT32 skinnum) // We want to check our global unlockables. return (unlockables[unlockID].unlocked); } ->>>>>>> src/r_skins.c } // returns true if the skin name is found (loaded from pwad) From 6c03f9b5b3590e01773f05bc1c31cc67a2d88fc2 Mon Sep 17 00:00:00 2001 From: James R Date: Tue, 29 Jun 2021 14:42:40 -0700 Subject: [PATCH 0854/1080] fuck --- src/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Makefile b/src/Makefile index 90776b812..8bb7b54ef 100644 --- a/src/Makefile +++ b/src/Makefile @@ -404,7 +404,7 @@ clean : $(call _rm,$(exe) $(dbg) $(dbg).txt $(objects)) distclean : - $(call _rm,../bin ../objs ../deps ../make comptime.h) + $(call _rm,../bin ../objs ../dep ../make comptime.h) info: ifdef WINDOWSHELL From abdf5c101cbe80657f210c0b90800e2c4c6f0c05 Mon Sep 17 00:00:00 2001 From: James R Date: Tue, 29 Jun 2021 16:22:46 -0700 Subject: [PATCH 0855/1080] Makefile: report SHELL --- src/Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Makefile b/src/Makefile index 8bb7b54ef..ce0e84987 100644 --- a/src/Makefile +++ b/src/Makefile @@ -295,6 +295,8 @@ ifndef destructive $(shell $(CC) -v) define flags = +SHELL ..... $(SHELL) + CC ........ $(cc) CFLAGS .... $(opts) From 22ab611daa17bd23225f3afeeba39147c0d0fe17 Mon Sep 17 00:00:00 2001 From: James R Date: Tue, 29 Jun 2021 16:23:27 -0700 Subject: [PATCH 0856/1080] Makefile: do not automatically set WINDOWSHELL According to this answer-- https://stackoverflow.com/a/45952425 --Make will always prefer a unix shell, even on Windows, if one can be found in Path. So we can't check PATH to determine if it's a Windows shell... this is just too much bother. --- src/Makefile.d/detect.mk | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/Makefile.d/detect.mk b/src/Makefile.d/detect.mk index 3edf0dad4..9c8a0a227 100644 --- a/src/Makefile.d/detect.mk +++ b/src/Makefile.d/detect.mk @@ -29,10 +29,6 @@ $(call Print,$(_m)) # go for a 32-bit sdl mingw exe by default MINGW:=1 -# cmd.exe uses native Windows semicolon delimited PATH -ifneq (,$(findstring ;,$(PATH))) -WINDOWSHELL:=1 -endif else # if you on the *nix From f79e0ee540564fcec5da7c0dc4006906492a7f30 Mon Sep 17 00:00:00 2001 From: James R Date: Tue, 29 Jun 2021 14:33:55 -0700 Subject: [PATCH 0857/1080] Appveyor: remove 64-bit target --- appveyor.yml | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index d5f76c344..a74d3c415 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -4,12 +4,9 @@ os: MinGW environment: CC: ccache CCACHE_CC: i686-w64-mingw32-gcc - CCACHE_CC_64: x86_64-w64-mingw32-gcc WINDRES: windres # c:\mingw-w64 i686 has gcc 6.3.0, so use c:\msys64 7.3.0 instead MINGW_SDK: c:\msys64\mingw32 - # c:\msys64 x86_64 has gcc 8.2.0, so use c:\mingw-w64 7.3.0 instead - MINGW_SDK_64: C:\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64 CFLAGS: -Wall -W -Werror -Wno-error=implicit-fallthrough -Wimplicit-fallthrough=3 -Wno-tautological-compare -Wno-error=suggest-attribute=noreturn NASM_ZIP: nasm-2.12.01 NASM_URL: http://www.nasm.us/pub/nasm/releasebuilds/2.12.01/win64/nasm-2.12.01-win64.zip @@ -53,11 +50,6 @@ cache: - C:\Users\appveyor\srb2_cache install: -- if [%CONFIGURATION%] == [SDL64] ( set "X86_64=1" ) -- if [%CONFIGURATION%] == [SDL64] ( set "CONFIGURATION=SDL" ) -- if [%X86_64%] == [1] ( set "MINGW_SDK=%MINGW_SDK_64%" ) -- if [%X86_64%] == [1] ( set "CCACHE_CC=%CCACHE_CC_64%" ) - - if not exist "%NASM_ZIP%.zip" appveyor DownloadFile "%NASM_URL%" -FileName "%NASM_ZIP%.zip" - 7z x -y "%NASM_ZIP%.zip" -o%TMP% >null - robocopy /S /xx /ns /nc /nfl /ndl /np /njh /njs "%TMP%\%NASM_ZIP%" "%MINGW_SDK%\bin" nasm.exe || exit 0 @@ -72,13 +64,12 @@ install: configuration: - SDL -- SDL64 before_build: - set "Path=%MINGW_SDK%\bin;%Path%" -- if [%X86_64%] == [1] ( x86_64-w64-mingw32-gcc --version ) else ( i686-w64-mingw32-gcc --version ) +- i686-w64-mingw32-gcc --version - mingw32-make --version -- if not [%X86_64%] == [1] ( nasm -v ) +- nasm -v - if not [%NOUPX%] == [1] ( upx -V ) - ccache -V - ccache -s @@ -91,7 +82,7 @@ before_build: - if not [%APPVEYOR_PULL_REQUEST_HEAD_REPO_NAME%] == [] ( if not [%APPVEYOR_PULL_REQUEST_HEAD_REPO_NAME%] == [%APPVEYOR_REPO_NAME%] ( for /f "delims=/" %%a in ("%APPVEYOR_PULL_REQUEST_HEAD_REPO_NAME%") do set "REPO=%%a-%APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH%" ) ) - set "EXENAME=EXENAME=srb2win-%REPO%-%GITSHORT%.exe" - set "SRB2_MFLAGS=-C src WARNINGMODE=1 CCACHE=1 NOOBJDUMP=1 %NOUPX% %EXENAME%" -- if [%X86_64%] == [1] ( set "MINGW_FLAGS=MINGW64=1 X86_64=1 GCC81=1" ) else ( set "MINGW_FLAGS=MINGW=1 GCC91=1" ) +- set "MINGW_FLAGS=MINGW=1 GCC91=1" - set "SRB2_MFLAGS=%SRB2_MFLAGS% %MINGW_FLAGS% %CONFIGURATION%=1" build_script: @@ -99,7 +90,6 @@ build_script: - cmd: mingw32-make.exe %SRB2_MFLAGS% ERRORMODE=1 -k after_build: -- if [%X86_64%] == [1] ( set "CONFIGURATION=%CONFIGURATION%64" ) - ccache -s - set BUILD_ARCHIVE=%REPO%-%GITSHORT%-%CONFIGURATION%.7z - set BUILDSARCHIVE=%REPO%-%CONFIGURATION%.7z @@ -134,3 +124,4 @@ test: off on_finish: #- cmd: echo xfreerdp /u:appveyor /cert-ignore +clipboard /v:: #- ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1')) +# vim: et ts=1 From faee657572f23cd6f8b68c077873e01c4278414e Mon Sep 17 00:00:00 2001 From: James R Date: Tue, 29 Jun 2021 14:55:06 -0700 Subject: [PATCH 0858/1080] Appveyor: update for new Makefile --- appveyor.yml | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index a74d3c415..26a1e2a9b 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -2,8 +2,7 @@ version: 2.2.9.{branch}-{build} os: MinGW environment: - CC: ccache - CCACHE_CC: i686-w64-mingw32-gcc + CC: i686-w64-mingw32-gcc WINDRES: windres # c:\mingw-w64 i686 has gcc 6.3.0, so use c:\msys64 7.3.0 instead MINGW_SDK: c:\msys64\mingw32 @@ -16,8 +15,6 @@ environment: CCACHE_URL: http://alam.srb2.org/ccache.exe CCACHE_COMPRESS: true CCACHE_DIR: C:\Users\appveyor\.ccache - # Disable UPX by default. The user can override this in their Appveyor project settings - NOUPX: 1 ############################## # DEPLOYER VARIABLES # DPL_ENABLED=1 builds installers for branch names starting with `deployer`. @@ -67,23 +64,18 @@ configuration: before_build: - set "Path=%MINGW_SDK%\bin;%Path%" -- i686-w64-mingw32-gcc --version - mingw32-make --version - nasm -v - if not [%NOUPX%] == [1] ( upx -V ) - ccache -V - ccache -s -- if [%NOUPX%] == [1] ( set "NOUPX=NOUPX=1" ) else ( set "NOUPX=" ) - if defined [%APPVEYOR_PULL_REQUEST_HEAD_COMMIT%] ( set "COMMIT=%APPVEYOR_PULL_REQUEST_HEAD_COMMIT%" ) else ( set "COMMIT=%APPVEYOR_REPO_COMMIT%" ) - cmd: git rev-parse --short %COMMIT%>%TMP%/gitshort.txt - cmd: set /P GITSHORT=<%TMP%/gitshort.txt # for pull requests, take the owner's name only, if this isn't the same repo of course - set "REPO=%APPVEYOR_REPO_BRANCH%" - if not [%APPVEYOR_PULL_REQUEST_HEAD_REPO_NAME%] == [] ( if not [%APPVEYOR_PULL_REQUEST_HEAD_REPO_NAME%] == [%APPVEYOR_REPO_NAME%] ( for /f "delims=/" %%a in ("%APPVEYOR_PULL_REQUEST_HEAD_REPO_NAME%") do set "REPO=%%a-%APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH%" ) ) -- set "EXENAME=EXENAME=srb2win-%REPO%-%GITSHORT%.exe" -- set "SRB2_MFLAGS=-C src WARNINGMODE=1 CCACHE=1 NOOBJDUMP=1 %NOUPX% %EXENAME%" -- set "MINGW_FLAGS=MINGW=1 GCC91=1" -- set "SRB2_MFLAGS=%SRB2_MFLAGS% %MINGW_FLAGS% %CONFIGURATION%=1" +- set "SRB2_MFLAGS=-C src CCACHE=1 EXENAME=srb2win-%REPO%-%GITSHORT%.exe" build_script: - cmd: mingw32-make.exe %SRB2_MFLAGS% clean From 44b82dea58612e6f07830647e2b08555f54a7caa Mon Sep 17 00:00:00 2001 From: James R Date: Tue, 29 Jun 2021 19:55:14 -0700 Subject: [PATCH 0859/1080] Appveyor: remove redundant CFLAGS Also changed -Wno-error=implicit-fallthrough to -Wno-implicit-fallthrough. For some reason Appveyor's version of GCC is triggering these warnings despite the comments, so just shut it up. --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 26a1e2a9b..962444a18 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -6,7 +6,7 @@ environment: WINDRES: windres # c:\mingw-w64 i686 has gcc 6.3.0, so use c:\msys64 7.3.0 instead MINGW_SDK: c:\msys64\mingw32 - CFLAGS: -Wall -W -Werror -Wno-error=implicit-fallthrough -Wimplicit-fallthrough=3 -Wno-tautological-compare -Wno-error=suggest-attribute=noreturn + CFLAGS: -Wno-implicit-fallthrough NASM_ZIP: nasm-2.12.01 NASM_URL: http://www.nasm.us/pub/nasm/releasebuilds/2.12.01/win64/nasm-2.12.01-win64.zip UPX_ZIP: upx391w From db919accd22350c087c1fd0e5122d8e490e2f171 Mon Sep 17 00:00:00 2001 From: James R Date: Tue, 29 Jun 2021 20:01:14 -0700 Subject: [PATCH 0860/1080] Appveyor: suppress real time file names --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 962444a18..b9f84f395 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -75,7 +75,7 @@ before_build: # for pull requests, take the owner's name only, if this isn't the same repo of course - set "REPO=%APPVEYOR_REPO_BRANCH%" - if not [%APPVEYOR_PULL_REQUEST_HEAD_REPO_NAME%] == [] ( if not [%APPVEYOR_PULL_REQUEST_HEAD_REPO_NAME%] == [%APPVEYOR_REPO_NAME%] ( for /f "delims=/" %%a in ("%APPVEYOR_PULL_REQUEST_HEAD_REPO_NAME%") do set "REPO=%%a-%APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH%" ) ) -- set "SRB2_MFLAGS=-C src CCACHE=1 EXENAME=srb2win-%REPO%-%GITSHORT%.exe" +- set "SRB2_MFLAGS=-C src NOECHOFILENAMES=1 CCACHE=1 EXENAME=srb2win-%REPO%-%GITSHORT%.exe" build_script: - cmd: mingw32-make.exe %SRB2_MFLAGS% clean From dad361721fa3c1f572ba5d40ae5af0884258fb17 Mon Sep 17 00:00:00 2001 From: Shane Ellis Date: Wed, 30 Jun 2021 01:32:24 -0400 Subject: [PATCH 0861/1080] comment cleanup --- src/p_user.c | 27 ++++----------------------- 1 file changed, 4 insertions(+), 23 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index dadc23193..7ab7d8105 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -776,7 +776,7 @@ void P_NightserizePlayer(player_t *player, INT32 nighttime) { UINT8 oldmare, oldmarelap, oldmarebonuslap; - //! Bots can't be NiGHTSerized, silly!1 :P + // Bots can't be NiGHTSerized, silly!1 :P if (player->bot == BOT_2PAI || player->bot == BOT_2PHUMAN) return; @@ -1188,7 +1188,6 @@ void P_GivePlayerRings(player_t *player, INT32 num_rings) { if (!player) return; - //! if ((player->bot == BOT_2PAI || player->bot == BOT_2PHUMAN) && player->botleader) player = player->botleader; @@ -5965,23 +5964,6 @@ static void P_3dMovement(player_t *player) acceleration = 96 + (FixedDiv(player->speed, player->mo->scale)>>FRACBITS) * 40; topspeed = normalspd; } - //! Kill this! - /* else if (player->bot == BOT_2PAI || player->bot == BOT_2PHUMAN) - { // Bot steals player 1's stats - normalspd = FixedMul(players[consoleplayer].normalspeed, player->mo->scale); - thrustfactor = players[consoleplayer].thrustfactor; - acceleration = players[consoleplayer].accelstart + (FixedDiv(player->speed, player->mo->scale)>>FRACBITS) * players[consoleplayer].acceleration; - - if (player->powers[pw_tailsfly]) - topspeed = normalspd/2; - else if (player->mo->eflags & (MFE_UNDERWATER|MFE_GOOWATER)) - { - topspeed = normalspd/2; - acceleration = 2*acceleration/3; - } - else - topspeed = normalspd; - } */ else { if (player->powers[pw_super] || player->powers[pw_sneakers]) @@ -11488,7 +11470,7 @@ void P_PlayerThink(player_t *player) I_Error("p_playerthink: players[%s].mo == NULL", sizeu1(playeri)); #endif - //! Reset terrain blocked status for this frame + // Reset terrain blocked status for this frame player->blocked = false; // todo: Figure out what is actually causing these problems in the first place... @@ -11641,7 +11623,7 @@ void P_PlayerThink(player_t *player) INT32 i; for (i = 0; i < MAXPLAYERS; i++) - { //! + { if (!playeringame[i] || players[i].spectator || players[i].bot == BOT_2PAI || players[i].bot == BOT_2PHUMAN) continue; if (players[i].lives <= 0) @@ -11673,7 +11655,7 @@ void P_PlayerThink(player_t *player) INT32 i, total = 0, exiting = 0; for (i = 0; i < MAXPLAYERS; i++) - { //! + { if (!playeringame[i] || players[i].spectator || players[i].bot == BOT_2PAI || players[i].bot == BOT_2PHUMAN) continue; if (players[i].quittime > 30 * TICRATE) @@ -12614,7 +12596,6 @@ void P_PlayerAfterThink(player_t *player) player->mo->momy = tails->momy; player->mo->momz = tails->momz; } - //! if (G_CoopGametype() && tails->player && tails->player->bot != BOT_2PAI) { player->mo->angle = tails->angle; From ee765d1043893bb798cdd84cf22d3383812812e6 Mon Sep 17 00:00:00 2001 From: Shane Ellis Date: Wed, 30 Jun 2021 01:34:21 -0400 Subject: [PATCH 0862/1080] comment cleanup --- 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 0643350b6..6e900d026 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -3005,7 +3005,7 @@ void G_DoReborn(INT32 playernum) // Make sure objectplace is OFF when you first start the level! OP_ResetObjectplace(); - //! Tailsbot + // Tailsbot if (player->bot == BOT_2PAI || player->bot == BOT_2PHUMAN) { // Bots respawn next to their master. mobj_t *oldmo = NULL; From 94441d6eee252c3ebc7cd438c32d3d15dbb3c012 Mon Sep 17 00:00:00 2001 From: Shane Ellis Date: Wed, 30 Jun 2021 01:36:28 -0400 Subject: [PATCH 0863/1080] comment cleanup --- src/b_bot.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/b_bot.c b/src/b_bot.c index c61e56f5f..cdd74fc07 100644 --- a/src/b_bot.c +++ b/src/b_bot.c @@ -25,8 +25,6 @@ void B_UpdateBotleader(player_t *player) fixed_t neardist = INT32_MAX; player_t *nearplayer = NULL; //Find new botleader - //if (!player->botleader) - //{ for (i = 0; i < MAXPLAYERS; i++) { if (players[i].bot || players[i].playerstate != PST_LIVE || players[i].spectator || !players[i].mo) @@ -46,7 +44,6 @@ void B_UpdateBotleader(player_t *player) } //Set botleader to best candidate (or null if none available) player->botleader = nearplayer; - //} } static inline void B_ResetAI(botmem_t *mem) @@ -102,7 +99,6 @@ static void B_BuildTailsTiccmd(mobj_t *sonic, mobj_t *tails, ticcmd_t *cmd) if (tails->player->powers[pw_carry] == CR_MACESPIN || tails->player->powers[pw_carry] == CR_GENERIC) { boolean isrelevant = (sonic->player->powers[pw_carry] == CR_MACESPIN || sonic->player->powers[pw_carry] == CR_GENERIC); - //dist = P_AproxDistance(tails->x-sonic->x, tails->y-sonic->y); //! This is totally redundant. if (sonic->player->cmd.buttons & BT_JUMP && (sonic->player->pflags & PF_JUMPED) && isrelevant) cmd->buttons |= BT_JUMP; if (isrelevant) @@ -402,8 +398,6 @@ void B_KeysToTiccmd(mobj_t *mo, ticcmd_t *cmd, boolean forward, boolean backward { player_t *player = mo->player; // don't try to do stuff if your sonic is in a minecart or something - //if (players[consoleplayer].powers[pw_carry] && players[consoleplayer].powers[pw_carry] != CR_PLAYER) - //!!! if (&player->botleader && player->botleader->powers[pw_carry] && player->botleader->powers[pw_carry] != CR_PLAYER) return; // Turn the virtual keypresses into ticcmd_t. @@ -576,7 +570,6 @@ void B_RespawnBot(INT32 playernum) player->powers[pw_spacetime] = sonic->player->powers[pw_spacetime]; player->powers[pw_gravityboots] = sonic->player->powers[pw_gravityboots]; player->powers[pw_nocontrol] = sonic->player->powers[pw_nocontrol]; - //!!! Nuke the speed equivalencies player->pflags |= PF_AUTOBRAKE|(sonic->player->pflags & PF_DIRECTIONCHAR); P_TeleportMove(tails, x, y, z); From afa8466b304207f15367c30352da5af7e1ede59f Mon Sep 17 00:00:00 2001 From: Shane Ellis Date: Wed, 30 Jun 2021 01:38:04 -0400 Subject: [PATCH 0864/1080] comment cleanup --- src/p_mobj.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index 4924ec053..8af7ab0d0 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -1839,7 +1839,6 @@ void P_XYMovement(mobj_t *mo) // blocked move moved = false; - //!!! if (player) B_MoveBlocked(player); From 0482eacb7c9a625c47a19c017304a3f4af2bd24c Mon Sep 17 00:00:00 2001 From: LJ Sonic Date: Sat, 3 Jul 2021 19:58:59 +0200 Subject: [PATCH 0865/1080] Load add-ons in the order in which the -file and -folder arguments are specified --- src/d_main.c | 41 ++++++++++++++++------------------------- 1 file changed, 16 insertions(+), 25 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index 0d0e2434a..7866ccbed 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -1253,34 +1253,25 @@ void D_SRB2Main(void) // Do this up here so that WADs loaded through the command line can use ExecCfg COM_Init(); - // add any files specified on the command line with -file wadfile - // to the wad list + // Add any files specified on the command line with + // "-file " or "-folder " to the add-on list if (!((M_GetUrlProtocolArg() || M_CheckParm("-connect")) && !M_CheckParm("-server"))) { - if (M_CheckParm("-file")) + INT32 addontype = 0; + INT32 i; + + for (i = 1; i < myargc; i++) { - // the parms after p are wadfile names, - // until end of parms or another - preceded parm - while (M_IsNextParm()) - { - const char *s = M_GetNextParm(); - - if (s) // Check for NULL? - D_AddFile(startuppwads, s); - } - } - - if (M_CheckParm("-folder")) - { - // the parms after p are folder names, - // until end of parms or another - preceded parm - while (M_IsNextParm()) - { - const char *s = M_GetNextParm(); - - if (s) // Check for NULL? - D_AddFolder(startuppwads, s); - } + if (!strcasecmp(myargv[i], "-file")) + addontype = 1; + else if (!strcasecmp(myargv[i], "-folder")) + addontype = 2; + else if (myargv[i][0] == '-' || myargv[i][0] == '+') + addontype = 0; + else if (addontype == 1) + D_AddFile(startuppwads, myargv[i]); + else if (addontype == 2) + D_AddFolder(startuppwads, myargv[i]); } } From 18cbc1e37047f2fabf61e32a4bc2997125ad21b4 Mon Sep 17 00:00:00 2001 From: James R Date: Mon, 5 Jul 2021 18:31:04 -0700 Subject: [PATCH 0866/1080] Fix aliases bypass COM_SAFE --- src/command.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/command.c b/src/command.c index 95b1fd67d..0e0b1a685 100644 --- a/src/command.c +++ b/src/command.c @@ -650,7 +650,7 @@ static void COM_ExecuteString(char *ptext) else { // Monster Iestyn: keep track of how many levels of recursion we're in recursion++; - COM_BufInsertText(a->value); + COM_BufInsertTextEx(a->value, com_flags); recursion--; } return; From 14c5d2c916e42c926dcf8267df3b49bd3dcab31d Mon Sep 17 00:00:00 2001 From: James R Date: Mon, 5 Jul 2021 18:39:12 -0700 Subject: [PATCH 0867/1080] Warn if Lua attempted access NOLUA consvar And quote variable name. --- src/command.c | 5 ++++- src/lua_consolelib.c | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/command.c b/src/command.c index 0e0b1a685..e6c6587e8 100644 --- a/src/command.c +++ b/src/command.c @@ -2364,7 +2364,10 @@ static boolean CV_Command(void) return false; if (( com_flags & COM_SAFE ) && ( v->flags & CV_NOLUA )) - return false; + { + CONS_Alert(CONS_WARNING, "Variable '%s' cannot be changed from Lua.\n", v->name); + return true; + } // perform a variable print or set if (COM_Argc() == 1) diff --git a/src/lua_consolelib.c b/src/lua_consolelib.c index 414d9692a..2b8cad69b 100644 --- a/src/lua_consolelib.c +++ b/src/lua_consolelib.c @@ -433,7 +433,7 @@ static int CVarSetFunction consvar_t *cvar = *(consvar_t **)luaL_checkudata(L, 1, META_CVAR); if (cvar->flags & CV_NOLUA) - return luaL_error(L, "Variable %s cannot be set from Lua.", cvar->name); + return luaL_error(L, "Variable '%s' cannot be set from Lua.", cvar->name); switch (lua_type(L, 2)) { From a75d4a1c360874a3c301a494e38ea49cd89b6616 Mon Sep 17 00:00:00 2001 From: James R Date: Tue, 6 Jul 2021 18:42:08 -0700 Subject: [PATCH 0868/1080] Automatically count hook values --- src/lua_hooklib.c | 91 +++++++++++++++++++++++++---------------------- 1 file changed, 49 insertions(+), 42 deletions(-) diff --git a/src/lua_hooklib.c b/src/lua_hooklib.c index d1b0d3bdd..5f733c3ef 100644 --- a/src/lua_hooklib.c +++ b/src/lua_hooklib.c @@ -259,11 +259,16 @@ static void push_string(void) lua_pushvalue(gL, SINDEX); } -static boolean start_hook_stack(void) +static boolean begin_hook_values(Hook_State *hook) +{ + hook->top = lua_gettop(gL); + return true; +} + +static void start_hook_stack(void) { lua_settop(gL, 0); push_error_handler(); - return true; } static boolean init_hook_type @@ -279,10 +284,11 @@ static boolean init_hook_type if (nonzero) { + start_hook_stack(); hook->hook_type = hook_type; hook->mobj_type = mobj_type; hook->string = string; - return start_hook_stack(); + return begin_hook_values(hook); } else return false; @@ -323,7 +329,7 @@ static boolean prepare_string_hook stringHooks[hook_type].ref)) { lua_pushstring(gL, string); - return true; + return begin_hook_values(hook); } else return false; @@ -332,12 +338,12 @@ static boolean prepare_string_hook static void init_hook_call ( Hook_State * hook, - int values, int results, Hook_Callback results_handler ){ - hook->top = lua_gettop(gL); - hook->values = values; + const int top = lua_gettop(gL); + hook->values = (top - hook->top); + hook->top = top; hook->results = results; hook->results_handler = results_handler; } @@ -447,13 +453,12 @@ static int call_mobj_type_hooks(Hook_State *hook, mobjtype_t mobj_type) static int call_hooks ( Hook_State * hook, - int values, int results, Hook_Callback results_handler ){ int calls = 0; - init_hook_call(hook, values, results, results_handler); + init_hook_call(hook, results, results_handler); if (hook->string) { @@ -514,7 +519,7 @@ int LUA_HookMobj(mobj_t *mobj, int hook_type) if (prepare_mobj_hook(&hook, false, hook_type, mobj->type)) { LUA_PushUserdata(gL, mobj, META_MOBJ); - call_hooks(&hook, 1, 1, res_true); + call_hooks(&hook, 1, res_true); } return hook.status; } @@ -526,7 +531,7 @@ int LUA_Hook2Mobj(mobj_t *t1, mobj_t *t2, int hook_type) { LUA_PushUserdata(gL, t1, META_MOBJ); LUA_PushUserdata(gL, t2, META_MOBJ); - call_hooks(&hook, 2, 1, res_force); + call_hooks(&hook, 1, res_force); } return hook.status; } @@ -535,7 +540,7 @@ void LUA_HookVoid(int type) { Hook_State hook; if (prepare_hook(&hook, 0, type)) - call_hooks(&hook, 0, 0, res_none); + call_hooks(&hook, 0, res_none); } void LUA_HookInt(INT32 number, int hook_type) @@ -544,7 +549,7 @@ void LUA_HookInt(INT32 number, int hook_type) if (prepare_hook(&hook, 0, hook_type)) { lua_pushinteger(gL, number); - call_hooks(&hook, 1, 0, res_none); + call_hooks(&hook, 0, res_none); } } @@ -554,7 +559,7 @@ void LUA_HookBool(boolean value, int hook_type) if (prepare_hook(&hook, 0, hook_type)) { lua_pushboolean(gL, value); - call_hooks(&hook, 1, 0, res_none); + call_hooks(&hook, 0, res_none); } } @@ -564,7 +569,7 @@ int LUA_HookPlayer(player_t *player, int hook_type) if (prepare_hook(&hook, false, hook_type)) { LUA_PushUserdata(gL, player, META_PLAYER); - call_hooks(&hook, 1, 1, res_true); + call_hooks(&hook, 1, res_true); } return hook.status; } @@ -580,7 +585,7 @@ int LUA_HookTiccmd(player_t *player, ticcmd_t *cmd, int hook_type) if (hook_type == HOOK(PlayerCmd)) hook_cmd_running = true; - call_hooks(&hook, 2, 1, res_true); + call_hooks(&hook, 1, res_true); if (hook_type == HOOK(PlayerCmd)) hook_cmd_running = false; @@ -594,7 +599,7 @@ int LUA_HookKey(INT32 keycode, int hook_type) if (prepare_hook(&hook, false, hook_type)) { lua_pushinteger(gL, keycode); - call_hooks(&hook, 1, 1, res_true); + call_hooks(&hook, 1, res_true); } return hook.status; } @@ -618,7 +623,7 @@ void LUA_HookThinkFrame(void) if (prepare_hook(&hook, 0, type)) { - init_hook_call(&hook, 0, 0, res_none); + init_hook_call(&hook, 0, res_none); for (k = 0; k < map->numHooks; ++k) { @@ -653,7 +658,7 @@ int LUA_HookMobjLineCollide(mobj_t *mobj, line_t *line) { LUA_PushUserdata(gL, mobj, META_MOBJ); LUA_PushUserdata(gL, line, META_LINE); - call_hooks(&hook, 2, 1, res_force); + call_hooks(&hook, 1, res_force); } return hook.status; } @@ -665,7 +670,7 @@ int LUA_HookTouchSpecial(mobj_t *special, mobj_t *toucher) { LUA_PushUserdata(gL, special, META_MOBJ); LUA_PushUserdata(gL, toucher, META_MOBJ); - call_hooks(&hook, 2, 1, res_true); + call_hooks(&hook, 1, res_true); } return hook.status; } @@ -678,7 +683,6 @@ static int damage_hook INT32 damage, UINT8 damagetype, int hook_type, - int values, Hook_Callback results_handler ){ Hook_State hook; @@ -687,10 +691,10 @@ static int damage_hook LUA_PushUserdata(gL, target, META_MOBJ); LUA_PushUserdata(gL, inflictor, META_MOBJ); LUA_PushUserdata(gL, source, META_MOBJ); - if (values == 5) + if (hook_type != MOBJ_HOOK(MobjDeath)) lua_pushinteger(gL, damage); lua_pushinteger(gL, damagetype); - call_hooks(&hook, values, 1, results_handler); + call_hooks(&hook, 1, results_handler); } return hook.status; } @@ -698,19 +702,19 @@ static int damage_hook int LUA_HookShouldDamage(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 damage, UINT8 damagetype) { return damage_hook(target, inflictor, source, damage, damagetype, - MOBJ_HOOK(ShouldDamage), 5, res_force); + MOBJ_HOOK(ShouldDamage), res_force); } int LUA_HookMobjDamage(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 damage, UINT8 damagetype) { return damage_hook(target, inflictor, source, damage, damagetype, - MOBJ_HOOK(MobjDamage), 5, res_true); + MOBJ_HOOK(MobjDamage), res_true); } int LUA_HookMobjDeath(mobj_t *target, mobj_t *inflictor, mobj_t *source, UINT8 damagetype) { return damage_hook(target, inflictor, source, 0, damagetype, - MOBJ_HOOK(MobjDeath), 4, res_true); + MOBJ_HOOK(MobjDeath), res_true); } typedef struct { @@ -783,7 +787,7 @@ int LUA_HookBotAI(mobj_t *sonic, mobj_t *tails, ticcmd_t *cmd) hook.userdata = &botai; - call_hooks(&hook, 2, 8, res_botai); + call_hooks(&hook, 8, res_botai); } return hook.status; @@ -798,7 +802,7 @@ void LUA_HookLinedefExecute(line_t *line, mobj_t *mo, sector_t *sector) LUA_PushUserdata(gL, line, META_LINE); LUA_PushUserdata(gL, mo, META_MOBJ); LUA_PushUserdata(gL, sector, META_SECTOR); - ps_lua_mobjhooks += call_hooks(&hook, 3, 0, res_none); + ps_lua_mobjhooks += call_hooks(&hook, 0, res_none); } } @@ -822,7 +826,7 @@ int LUA_HookPlayerMsg(int source, int target, int flags, char *msg) LUA_PushUserdata(gL, &players[target-1], META_PLAYER); // target } lua_pushstring(gL, msg); // msg - call_hooks(&hook, 4, 1, res_true); + call_hooks(&hook, 1, res_true); } return hook.status; } @@ -836,7 +840,7 @@ int LUA_HookHurtMsg(player_t *player, mobj_t *inflictor, mobj_t *source, UINT8 d LUA_PushUserdata(gL, inflictor, META_MOBJ); LUA_PushUserdata(gL, source, META_MOBJ); lua_pushinteger(gL, damagetype); - call_hooks(&hook, 4, 1, res_true); + call_hooks(&hook, 1, res_true); } return hook.status; } @@ -855,12 +859,14 @@ void LUA_HookNetArchive(lua_CFunction archFunc) push_error_handler(); lua_insert(gL, EINDEX); + begin_hook_values(&hook); + // tables becomes an upvalue of archFunc lua_pushvalue(gL, -1); lua_pushcclosure(gL, archFunc, 1); // stack: tables, archFunc - init_hook_call(&hook, 1, 0, res_none); + init_hook_call(&hook, 0, res_none); call_mapped(&hook, map); lua_pop(gL, 1); // pop archFunc @@ -876,7 +882,7 @@ int LUA_HookMapThingSpawn(mobj_t *mobj, mapthing_t *mthing) { LUA_PushUserdata(gL, mobj, META_MOBJ); LUA_PushUserdata(gL, mthing, META_MAPTHING); - call_hooks(&hook, 2, 1, res_true); + call_hooks(&hook, 1, res_true); } return hook.status; } @@ -888,7 +894,7 @@ int LUA_HookFollowMobj(player_t *player, mobj_t *mobj) { LUA_PushUserdata(gL, player, META_PLAYER); LUA_PushUserdata(gL, mobj, META_MOBJ); - call_hooks(&hook, 2, 1, res_true); + call_hooks(&hook, 1, res_true); } return hook.status; } @@ -900,7 +906,7 @@ int LUA_HookPlayerCanDamage(player_t *player, mobj_t *mobj) { LUA_PushUserdata(gL, player, META_PLAYER); LUA_PushUserdata(gL, mobj, META_MOBJ); - call_hooks(&hook, 2, 1, res_force); + call_hooks(&hook, 1, res_force); } return hook.status; } @@ -912,7 +918,7 @@ void LUA_HookPlayerQuit(player_t *plr, kickreason_t reason) { LUA_PushUserdata(gL, plr, META_PLAYER); // Player that quit lua_pushinteger(gL, reason); // Reason for quitting - call_hooks(&hook, 2, 0, res_none); + call_hooks(&hook, 0, res_none); } } @@ -926,7 +932,7 @@ int LUA_HookTeamSwitch(player_t *player, int newteam, boolean fromspectators, bo lua_pushboolean(gL, fromspectators); lua_pushboolean(gL, tryingautobalance); lua_pushboolean(gL, tryingscramble); - call_hooks(&hook, 5, 1, res_false); + call_hooks(&hook, 1, res_false); } return hook.status; } @@ -941,7 +947,7 @@ int LUA_HookViewpointSwitch(player_t *player, player_t *newdisplayplayer, boolea lua_pushboolean(gL, forced); hud_running = true; // local hook - call_hooks(&hook, 3, 1, res_force); + call_hooks(&hook, 1, res_force); hud_running = false; } return hook.status; @@ -956,7 +962,7 @@ int LUA_HookSeenPlayer(player_t *player, player_t *seenfriend) LUA_PushUserdata(gL, seenfriend, META_PLAYER); hud_running = true; // local hook - call_hooks(&hook, 2, 1, res_false); + call_hooks(&hook, 1, res_false); hud_running = false; } return hook.status; @@ -972,7 +978,7 @@ int LUA_HookShouldJingleContinue(player_t *player, const char *musname) push_string(); hud_running = true; // local hook - call_hooks(&hook, 2, 1, res_true); + call_hooks(&hook, 1, res_true); hud_running = false; } return hook.status; @@ -1038,7 +1044,8 @@ int LUA_HookMusicChange(const char *oldname, struct MusicChange *param) if (prepare_hook(&hook, false, type)) { - init_hook_call(&hook, 7, 6, res_musicchange); + init_hook_call(&hook, 6, res_musicchange); + hook.values = 7;/* values pushed later */ hook.userdata = param; lua_pushstring(gL, oldname);/* the only constant value */ @@ -1084,7 +1091,7 @@ fixed_t LUA_HookPlayerHeight(player_t *player) if (prepare_hook(&hook, -1, HOOK(PlayerHeight))) { LUA_PushUserdata(gL, player, META_PLAYER); - call_hooks(&hook, 1, 1, res_playerheight); + call_hooks(&hook, 1, res_playerheight); } return hook.status; } @@ -1095,7 +1102,7 @@ int LUA_HookPlayerCanEnterSpinGaps(player_t *player) if (prepare_hook(&hook, 0, HOOK(PlayerCanEnterSpinGaps))) { LUA_PushUserdata(gL, player, META_PLAYER); - call_hooks(&hook, 1, 1, res_force); + call_hooks(&hook, 1, res_force); } return hook.status; } From 331329306cad257d52f84e47a92d9214d9eaa8d3 Mon Sep 17 00:00:00 2001 From: James R Date: Tue, 6 Jul 2021 19:12:47 -0700 Subject: [PATCH 0869/1080] Refactor hook ref allocation --- src/lua_hooklib.c | 58 +++++++++++++++++++++++++---------------------- 1 file changed, 31 insertions(+), 27 deletions(-) diff --git a/src/lua_hooklib.c b/src/lua_hooklib.c index 5f733c3ef..ce1b16f75 100644 --- a/src/lua_hooklib.c +++ b/src/lua_hooklib.c @@ -56,6 +56,7 @@ static stringhook_t stringHooks[STRING_HOOK(MAX)]; // This will be indexed by hook id, the value of which fetches the registry. static int * hookRefs; +static int nextid; // After a hook errors once, don't print the error again. static UINT8 * hooksErrored; @@ -104,13 +105,13 @@ static void get_table(lua_State *L) lua_remove(L, -2); } -static void add_hook_to_table(lua_State *L, int id, int n) +static void add_hook_to_table(lua_State *L, int n) { - lua_pushnumber(L, id); + lua_pushnumber(L, nextid); lua_rawseti(L, -2, n); } -static void add_string_hook(lua_State *L, int type, int id) +static void add_string_hook(lua_State *L, int type) { stringhook_t * hook = &stringHooks[type]; @@ -146,33 +147,48 @@ static void add_string_hook(lua_State *L, int type, int id) { lua_pushstring(L, string); get_table(L); - add_hook_to_table(L, id, 1 + lua_objlen(L, -1)); + add_hook_to_table(L, 1 + lua_objlen(L, -1)); } else - add_hook_to_table(L, id, ++hook->numGeneric); + add_hook_to_table(L, ++hook->numGeneric); } -static void add_hook(hook_t *map, int id) +static void add_hook(hook_t *map) { Z_Realloc(map->ids, (map->numHooks + 1) * sizeof *map->ids, PU_STATIC, &map->ids); - map->ids[map->numHooks++] = id; + map->ids[map->numHooks++] = nextid; } -static void add_mobj_hook(lua_State *L, int hook_type, int id) +static void add_mobj_hook(lua_State *L, int hook_type) { mobjtype_t mobj_type = luaL_optnumber(L, 3, MT_NULL); luaL_argcheck(L, mobj_type < NUMMOBJTYPES, 3, "invalid mobjtype_t"); - add_hook(&mobjHookIds[mobj_type][hook_type], id); + add_hook(&mobjHookIds[mobj_type][hook_type]); +} + +static void add_hook_ref(lua_State *L, int idx) +{ + if (!(nextid & 7)) + { + Z_Realloc(hooksErrored, + BIT_ARRAY_SIZE (nextid + 1) * sizeof *hooksErrored, + PU_STATIC, &hooksErrored); + hooksErrored[nextid >> 3] = 0; + } + + Z_Realloc(hookRefs, (nextid + 1) * sizeof *hookRefs, PU_STATIC, &hookRefs); + + // set the hook function in the registry. + lua_pushvalue(L, idx); + hookRefs[nextid++] = luaL_ref(L, LUA_REGISTRYINDEX); } // Takes hook, function, and additional arguments (mobj type to act on, etc.) static int lib_addHook(lua_State *L) { - static int nextid; - const char * name; int type; @@ -185,34 +201,22 @@ static int lib_addHook(lua_State *L) /* this is a very special case */ if (( type = hook_in_list(name, stringHookNames) ) < STRING_HOOK(MAX)) { - add_string_hook(L, type, nextid); + add_string_hook(L, type); } else if (( type = hook_in_list(name, mobjHookNames) ) < MOBJ_HOOK(MAX)) { - add_mobj_hook(L, type, nextid); + add_mobj_hook(L, type); } else if (( type = hook_in_list(name, hookNames) ) < HOOK(MAX)) { - add_hook(&hookIds[type], nextid); + add_hook(&hookIds[type]); } else { return luaL_argerror(L, 1, lua_pushfstring(L, "invalid hook " LUA_QS, name)); } - if (!(nextid & 7)) - { - Z_Realloc(hooksErrored, - BIT_ARRAY_SIZE (nextid + 1) * sizeof *hooksErrored, - PU_STATIC, &hooksErrored); - hooksErrored[nextid >> 3] = 0; - } - - Z_Realloc(hookRefs, (nextid + 1) * sizeof *hookRefs, PU_STATIC, &hookRefs); - - // set the hook function in the registry. - lua_pushvalue(L, 2);/* the function */ - hookRefs[nextid++] = luaL_ref(L, LUA_REGISTRYINDEX); + add_hook_ref(L, 2);/* the function */ return 0; } From ae57b6ca8664e00ff4d9544339dbf29a41138040 Mon Sep 17 00:00:00 2001 From: James R Date: Tue, 6 Jul 2021 20:23:38 -0700 Subject: [PATCH 0870/1080] MORE MACROS I just can't stop myself! --- src/lua_hook.h | 10 +++++++--- src/lua_hooklib.c | 12 +++++++----- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/lua_hook.h b/src/lua_hook.h index 223b83c61..1af1697a7 100644 --- a/src/lua_hook.h +++ b/src/lua_hook.h @@ -90,9 +90,13 @@ grepped and found in the lists above. #define HOOK(name) hook_ ## name #define STRING_HOOK(name) stringhook_ ## name -enum { MOBJ_HOOK_LIST (MOBJ_HOOK) MOBJ_HOOK(MAX) }; -enum { HOOK_LIST (HOOK) HOOK(MAX) }; -enum { STRING_HOOK_LIST (STRING_HOOK) STRING_HOOK(MAX) }; +#define ENUM(X) enum { X ## _LIST (X) X(MAX) } + +ENUM (MOBJ_HOOK); +ENUM (HOOK); +ENUM (STRING_HOOK); + +#undef ENUM /* dead simple, LUA_HOOK(GameQuit) */ #define LUA_HOOK(type) LUA_HookVoid(HOOK(type)) diff --git a/src/lua_hooklib.c b/src/lua_hooklib.c index ce1b16f75..5815f17b3 100644 --- a/src/lua_hooklib.c +++ b/src/lua_hooklib.c @@ -31,12 +31,14 @@ ABSTRACTION ========================================================================= */ -static const char * const mobjHookNames[] = { MOBJ_HOOK_LIST (TOSTR) NULL }; -static const char * const hookNames[] = { HOOK_LIST (TOSTR) NULL }; +#define LIST(id, M) \ + static const char * const id [] = { M (TOSTR) NULL } -static const char * const stringHookNames[] = { - STRING_HOOK_LIST (TOSTR) NULL -}; +LIST (mobjHookNames, MOBJ_HOOK_LIST); +LIST (hookNames, HOOK_LIST); +LIST (stringHookNames, STRING_HOOK_LIST); + +#undef LIST typedef struct { int numHooks; From b4fa98d2fbab180f487ce3efedb8ab715e5f3390 Mon Sep 17 00:00:00 2001 From: James R Date: Wed, 7 Jul 2021 00:23:51 -0700 Subject: [PATCH 0871/1080] Refactor hudlib hooks to hooklib HUD hooks now meet the standard of hooklib. HUD registry magic numbers are gone. HUD hooks may also be added using addHook. addHook('HUD', fn[, type]) hud.add still exists, but the intention is to remove it eventually. --- src/f_finale.c | 3 +- src/hu_stuff.c | 2 +- src/lua_hook.h | 11 +++ src/lua_hooklib.c | 47 +++++++++ src/lua_hud.h | 6 +- src/lua_hudlib.c | 236 ++++++---------------------------------------- src/st_stuff.c | 5 +- src/y_inter.c | 2 +- 8 files changed, 93 insertions(+), 219 deletions(-) diff --git a/src/f_finale.c b/src/f_finale.c index e8757c18a..401ab45b1 100644 --- a/src/f_finale.c +++ b/src/f_finale.c @@ -41,6 +41,7 @@ #include "console.h" #include "lua_hud.h" +#include "lua_hook.h" // Stage of animation: // 0 = text, 1 = art screen @@ -3423,7 +3424,7 @@ void F_TitleScreenDrawer(void) } luahook: - LUAh_TitleHUD(); + LUA_HUDHOOK(title); } // separate animation timer for backgrounds, since we also count diff --git a/src/hu_stuff.c b/src/hu_stuff.c index e0eaf8fb1..be215ff21 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -2104,7 +2104,7 @@ void HU_Drawer(void) } else HU_DrawCoopOverlay(); - LUAh_ScoresHUD(); + LUA_HUDHOOK(scores); } if (gamestate != GS_LEVEL) diff --git a/src/lua_hook.h b/src/lua_hook.h index 1af1697a7..1c01d1d66 100644 --- a/src/lua_hook.h +++ b/src/lua_hook.h @@ -78,6 +78,13 @@ automatically. X (LinedefExecute),\ X (ShouldJingleContinue),/* should jingle of the given music continue playing */\ +#define HUD_HOOK_LIST(X) \ + X (game),\ + X (scores),/* emblems/multiplayer list */\ + X (title),/* titlescreen */\ + X (titlecard),\ + X (intermission),\ + /* I chose to access the hook enums through a macro as well. This could provide a hint to lookup the macro's definition instead of the enum's definition. @@ -88,22 +95,26 @@ grepped and found in the lists above. #define MOBJ_HOOK(name) mobjhook_ ## name #define HOOK(name) hook_ ## name +#define HUD_HOOK(name) hudhook_ ## name #define STRING_HOOK(name) stringhook_ ## name #define ENUM(X) enum { X ## _LIST (X) X(MAX) } ENUM (MOBJ_HOOK); ENUM (HOOK); +ENUM (HUD_HOOK); ENUM (STRING_HOOK); #undef ENUM /* dead simple, LUA_HOOK(GameQuit) */ #define LUA_HOOK(type) LUA_HookVoid(HOOK(type)) +#define LUA_HUDHOOK(type) LUA_HookHUD(HUD_HOOK(type)) extern boolean hook_cmd_running; void LUA_HookVoid(int hook); +void LUA_HookHUD(int hook); int LUA_HookMobj(mobj_t *, int hook); int LUA_Hook2Mobj(mobj_t *, mobj_t *, int hook); diff --git a/src/lua_hooklib.c b/src/lua_hooklib.c index 5815f17b3..96cb04543 100644 --- a/src/lua_hooklib.c +++ b/src/lua_hooklib.c @@ -36,6 +36,7 @@ LIST (mobjHookNames, MOBJ_HOOK_LIST); LIST (hookNames, HOOK_LIST); +LIST (hudHookNames, HUD_HOOK_LIST); LIST (stringHookNames, STRING_HOOK_LIST); #undef LIST @@ -51,6 +52,7 @@ typedef struct { } stringhook_t; static hook_t hookIds[HOOK(MAX)]; +static hook_t hudHookIds[HUD_HOOK(MAX)]; static hook_t mobjHookIds[NUMMOBJTYPES][MOBJ_HOOK(MAX)]; // Lua tables are used to lookup string hook ids. @@ -171,6 +173,12 @@ static void add_mobj_hook(lua_State *L, int hook_type) add_hook(&mobjHookIds[mobj_type][hook_type]); } +static void add_hud_hook(lua_State *L, int idx) +{ + add_hook(&hudHookIds[luaL_checkoption(L, + idx, "game", hudHookNames)]); +} + static void add_hook_ref(lua_State *L, int idx) { if (!(nextid & 7)) @@ -213,6 +221,10 @@ static int lib_addHook(lua_State *L) { add_hook(&hookIds[type]); } + else if (strcmp(name, "HUD") == 0) + { + add_hud_hook(L, 3); + } else { return luaL_argerror(L, 1, lua_pushfstring(L, "invalid hook " LUA_QS, name)); @@ -233,6 +245,23 @@ int LUA_HookLib(lua_State *L) return 0; } +/* TODO: remove in next backwards incompatible release */ +#if MODID == 18 +int lib_hudadd(lua_State *L);/* yeah compiler */ +int lib_hudadd(lua_State *L) +{ + if (!lua_lumploading) + return luaL_error(L, "This function cannot be called from within a hook or coroutine!"); + + luaL_checktype(L, 1, LUA_TFUNCTION); + + add_hud_hook(L, 2); + add_hook_ref(L, 1); + + return 0; +} +#endif + typedef struct Hook_State Hook_State; typedef void (*Hook_Callback)(Hook_State *); @@ -610,6 +639,24 @@ int LUA_HookKey(INT32 keycode, int hook_type) return hook.status; } +void LUA_HookHUD(int hook_type) +{ + const hook_t * map = &hudHookIds[hook_type]; + Hook_State hook; + if (map->numHooks > 0) + { + start_hook_stack(); + begin_hook_values(&hook); + + LUA_SetHudHook(hook_type); + + hud_running = true; // local hook + init_hook_call(&hook, 0, res_none); + call_mapped(&hook, map); + hud_running = false; + } +} + /* ========================================================================= SPECIALIZED HOOKS ========================================================================= */ diff --git a/src/lua_hud.h b/src/lua_hud.h index d2f5bceca..c1d2d164b 100644 --- a/src/lua_hud.h +++ b/src/lua_hud.h @@ -47,8 +47,4 @@ extern boolean hud_running; boolean LUA_HudEnabled(enum hud option); -void LUAh_GameHUD(player_t *stplyr); -void LUAh_ScoresHUD(void); -void LUAh_TitleHUD(void); -void LUAh_TitleCardHUD(player_t *stplayr); -void LUAh_IntermissionHUD(boolean failedstage); +void LUA_SetHudHook(int hook); diff --git a/src/lua_hudlib.c b/src/lua_hudlib.c index 9a3e676d5..b60cdcde0 100644 --- a/src/lua_hudlib.c +++ b/src/lua_hudlib.c @@ -23,18 +23,18 @@ #include "v_video.h" #include "w_wad.h" #include "z_zone.h" +#include "y_inter.h" #include "lua_script.h" #include "lua_libs.h" #include "lua_hud.h" +#include "lua_hook.h" #define HUDONLY if (!hud_running) return luaL_error(L, "HUD rendering code should not be called outside of rendering hooks!"); boolean hud_running = false; static UINT8 hud_enabled[(hud_MAX/8)+1]; -static UINT8 hudAvailable; // hud hooks field - // must match enum hud in lua_hud.h static const char *const hud_disable_options[] = { "stagetitle", @@ -95,21 +95,6 @@ static const char *const patch_opt[] = { "topoffset", NULL}; -enum hudhook { - hudhook_game = 0, - hudhook_scores, - hudhook_intermission, - hudhook_title, - hudhook_titlecard -}; -static const char *const hudhook_opt[] = { - "game", - "scores", - "intermission", - "title", - "titlecard", - NULL}; - // alignment types for v.drawString enum align { align_left = 0, @@ -1152,6 +1137,8 @@ static luaL_Reg lib_draw[] = { {NULL, NULL} }; +static int lib_draw_ref; + // // lib_hud // @@ -1186,28 +1173,7 @@ static int lib_hudenabled(lua_State *L) // add a HUD element for rendering -static int lib_hudadd(lua_State *L) -{ - enum hudhook field; - - luaL_checktype(L, 1, LUA_TFUNCTION); - field = luaL_checkoption(L, 2, "game", hudhook_opt); - - if (!lua_lumploading) - return luaL_error(L, "This function cannot be called from within a hook or coroutine!"); - - lua_getfield(L, LUA_REGISTRYINDEX, "HUD"); - I_Assert(lua_istable(L, -1)); - lua_rawgeti(L, -1, field+2); // HUD[2+] - I_Assert(lua_istable(L, -1)); - lua_remove(L, -2); - - lua_pushvalue(L, 1); - lua_rawseti(L, -2, (int)(lua_objlen(L, -2) + 1)); - - hudAvailable |= 1< Date: Wed, 7 Jul 2021 19:57:28 -0500 Subject: [PATCH 0872/1080] Rebase on !1307 --- src/lua_hook.h | 1 + src/lua_hooklib.c | 13 +++++++++++++ src/p_mobj.c | 2 +- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/lua_hook.h b/src/lua_hook.h index 223b83c61..1af28aac5 100644 --- a/src/lua_hook.h +++ b/src/lua_hook.h @@ -115,6 +115,7 @@ int LUA_HookTouchSpecial(mobj_t *special, mobj_t *toucher); int LUA_HookShouldDamage(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 damage, UINT8 damagetype); int LUA_HookMobjDamage(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 damage, UINT8 damagetype); int LUA_HookMobjDeath(mobj_t *target, mobj_t *inflictor, mobj_t *source, UINT8 damagetype); +int LUA_HookMobjMoveBlocked(mobj_t *, mobj_t *, line_t *); int LUA_HookBotAI(mobj_t *sonic, mobj_t *tails, ticcmd_t *cmd); void LUA_HookLinedefExecute(line_t *, mobj_t *, sector_t *); int LUA_HookPlayerMsg(int source, int target, int flags, char *msg); diff --git a/src/lua_hooklib.c b/src/lua_hooklib.c index d1b0d3bdd..f2e9b5233 100644 --- a/src/lua_hooklib.c +++ b/src/lua_hooklib.c @@ -713,6 +713,19 @@ int LUA_HookMobjDeath(mobj_t *target, mobj_t *inflictor, mobj_t *source, UINT8 d MOBJ_HOOK(MobjDeath), 4, res_true); } +int LUA_HookMobjMoveBlocked(mobj_t *t1, mobj_t *t2, line_t *line) +{ + Hook_State hook; + if (prepare_mobj_hook(&hook, 0, MOBJ_HOOK(MobjMoveBlocked), t1->type)) + { + LUA_PushUserdata(gL, t1, META_MOBJ); + LUA_PushUserdata(gL, t2, META_MOBJ); + LUA_PushUserdata(gL, line, META_LINE); + call_hooks(&hook, 3, 1, res_true); + } + return hook.status; +} + typedef struct { mobj_t * tails; ticcmd_t * cmd; diff --git a/src/p_mobj.c b/src/p_mobj.c index 10220fff6..f2fae6cc6 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -1844,7 +1844,7 @@ void P_XYMovement(mobj_t *mo) B_MoveBlocked(player); } - if (LUA_HookMobj(mo, MOBJ_HOOK(MobjMoveBlocked))) + if (LUA_HookMobjMoveBlocked(mo, tmhitthing, blockingline)) { if (P_MobjWasRemoved(mo)) return; From e30d4f954b9ec90632484b31673b7fe6185481a5 Mon Sep 17 00:00:00 2001 From: James R Date: Thu, 8 Jul 2021 14:37:03 -0700 Subject: [PATCH 0873/1080] Revert netvars after demo finishes playback (Demos do not call CL_Reset BTW.) --- src/command.c | 4 +++- src/d_clisrv.c | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/command.c b/src/command.c index 95b1fd67d..da777310a 100644 --- a/src/command.c +++ b/src/command.c @@ -1738,6 +1738,8 @@ void CV_SaveVars(UINT8 **p, boolean in_demo) static void CV_LoadVars(UINT8 **p, consvar_t *(*got)(UINT8 **p, char **ret_value, boolean *ret_stealth)) { + const boolean store = (client || demoplayback); + consvar_t *cvar; UINT16 count; @@ -1751,7 +1753,7 @@ static void CV_LoadVars(UINT8 **p, { if (cvar->flags & CV_NETVAR) { - if (client && cvar->revert.v.string == NULL) + if (store && cvar->revert.v.string == NULL) { cvar->revert.v.const_munge = cvar->string; cvar->revert.allocated = ( cvar->zstring != NULL ); diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 1549811c1..1d895c0e1 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -2599,7 +2599,6 @@ void CL_Reset(void) doomcom->numslots = 1; SV_StopServer(); SV_ResetServer(); - CV_RevertNetVars(); // make sure we don't leave any fileneeded gunk over from a failed join fileneedednum = 0; @@ -3231,6 +3230,8 @@ void SV_ResetServer(void) // clear server_context memset(server_context, '-', 8); + CV_RevertNetVars(); + DEBFILE("\n-=-=-=-=-=-=-= Server Reset =-=-=-=-=-=-=-\n\n"); } From 366b1f65a18a89b26afcd30c71255bcd9d1995be Mon Sep 17 00:00:00 2001 From: lachablock Date: Sat, 10 Jul 2021 18:22:07 +1000 Subject: [PATCH 0874/1080] Allow Lua write access to camera_t variables & expose the cameras globally --- src/lua_hudlib.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++++ src/lua_script.c | 8 +++++++ 2 files changed, 64 insertions(+) diff --git a/src/lua_hudlib.c b/src/lua_hudlib.c index 9a3e676d5..306ffaf94 100644 --- a/src/lua_hudlib.c +++ b/src/lua_hudlib.c @@ -384,6 +384,59 @@ static int camera_get(lua_State *L) return 1; } +static int camera_set(lua_State *L) +{ + camera_t *cam = *((camera_t **)luaL_checkudata(L, 1, META_CAMERA)); + enum cameraf field = luaL_checkoption(L, 2, NULL, camera_opt); + + I_Assert(cam != NULL); + + switch(field) + { + case camera_subsector: + case camera_floorz: + case camera_ceilingz: + case camera_height: + case camera_radius: + return luaL_error(L, LUA_QL("camera_t") " field " LUA_QS " should not be set directly.", camera_opt[field]); + case camera_chase: + if (cam == &camera) + CV_SetValue(&cv_chasecam, (INT32)luaL_checkboolean(L, 3)); + else if (cam == &camera2) + CV_SetValue(&cv_chasecam2, (INT32)luaL_checkboolean(L, 3)); + else // ??? this should never happen, but ok + cam->chase = luaL_checkboolean(L, 3); + break; + case camera_aiming: + cam->aiming = luaL_checkangle(L, 3); + break; + case camera_x: + cam->x = luaL_checkfixed(L, 3); + break; + case camera_y: + cam->y = luaL_checkfixed(L, 3); + break; + case camera_z: + cam->z = luaL_checkfixed(L, 3); + break; + case camera_angle: + cam->angle = luaL_checkangle(L, 3); + break; + case camera_momx: + cam->momx = luaL_checkfixed(L, 3); + break; + case camera_momy: + cam->momy = luaL_checkfixed(L, 3); + break; + case camera_momz: + cam->momz = luaL_checkfixed(L, 3); + break; + default: + return luaL_error(L, LUA_QL("camera_t") " has no field named " LUA_QS, camera_opt[field]); + } + return 0; +} + // // lib_draw // @@ -1283,6 +1336,9 @@ int LUA_HudLib(lua_State *L) luaL_newmetatable(L, META_CAMERA); lua_pushcfunction(L, camera_get); lua_setfield(L, -2, "__index"); + + lua_pushcfunction(L, camera_set); + lua_setfield(L, -2, "__newindex"); lua_pop(L,1); luaL_register(L, "hud", lib_hud); diff --git a/src/lua_script.c b/src/lua_script.c index 6faff8729..54ab124fc 100644 --- a/src/lua_script.c +++ b/src/lua_script.c @@ -393,6 +393,14 @@ int LUA_PushGlobals(lua_State *L, const char *word) } else if (fastcmp(word, "mouse2")) { LUA_PushUserdata(L, &mouse2, META_MOUSE); return 1; + } else if (fastcmp(word, "camera")) { + LUA_PushUserdata(L, &camera, META_CAMERA); + return 1; + } else if (fastcmp(word, "camera2")) { + if (!splitscreen) + return 0; + LUA_PushUserdata(L, &camera2, META_CAMERA); + return 1; } return 0; } From 117e3e267087d8c13914037f14b282d47177d474 Mon Sep 17 00:00:00 2001 From: lachablock Date: Sun, 11 Jul 2021 16:23:50 +1000 Subject: [PATCH 0875/1080] Expose P_TryCameraMove and P_TeleportCameraMove, disallow write access to camera.x and camera.y, allow write access to camera.height and camera.radius --- src/lua_baselib.c | 33 +++++++++++++++++++++++++++++++++ src/lua_hudlib.c | 31 ++++++++++++++++++++++--------- 2 files changed, 55 insertions(+), 9 deletions(-) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index d6f40846c..a3f1d9811 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -1883,6 +1883,37 @@ static int lib_pDoSpring(lua_State *L) return 1; } +static int lib_pTryCameraMove(lua_State *L) +{ + camera_t *cam = *((camera_t **)luaL_checkudata(L, 1, META_CAMERA)); + fixed_t x = luaL_checkfixed(L, 2); + fixed_t y = luaL_checkfixed(L, 3); + + if (!cam) + return LUA_ErrInvalid(L, "camera_t"); + lua_pushboolean(L, P_TryCameraMove(x, y, cam)); + return 1; +} + +static int lib_pTeleportCameraMove(lua_State *L) +{ + camera_t *cam = *((camera_t **)luaL_checkudata(L, 1, META_CAMERA)); + fixed_t x = luaL_checkfixed(L, 2); + fixed_t y = luaL_checkfixed(L, 3); + fixed_t z = luaL_checkfixed(L, 4); + + if (!cam) + return LUA_ErrInvalid(L, "camera_t"); + cam->x = x; + cam->y = y; + cam->z = z; + P_CheckCameraPosition(x, y, cam); + cam->subsector = R_PointInSubsector(x, y); + cam->floorz = tmfloorz; + cam->ceilingz = tmceilingz; + return 0; +} + // P_INTER //////////// @@ -3881,6 +3912,8 @@ static luaL_Reg lib[] = { {"P_FloorzAtPos",lib_pFloorzAtPos}, {"P_CeilingzAtPos",lib_pCeilingzAtPos}, {"P_DoSpring",lib_pDoSpring}, + {"P_TryCameraMove", lib_pTryCameraMove}, + {"P_TeleportCameraMove", lib_pTeleportCameraMove}, // p_inter {"P_RemoveShield",lib_pRemoveShield}, diff --git a/src/lua_hudlib.c b/src/lua_hudlib.c index 306ffaf94..0f8ccb089 100644 --- a/src/lua_hudlib.c +++ b/src/lua_hudlib.c @@ -396,9 +396,9 @@ static int camera_set(lua_State *L) case camera_subsector: case camera_floorz: case camera_ceilingz: - case camera_height: - case camera_radius: - return luaL_error(L, LUA_QL("camera_t") " field " LUA_QS " should not be set directly.", camera_opt[field]); + case camera_x: + case camera_y: + return luaL_error(L, LUA_QL("camera_t") " field " LUA_QS " should not be set directly. Use " LUA_QL("P_TryCameraMove") " or " LUA_QL("P_TeleportCameraMove") " instead.", camera_opt[field]); case camera_chase: if (cam == &camera) CV_SetValue(&cv_chasecam, (INT32)luaL_checkboolean(L, 3)); @@ -410,18 +410,31 @@ static int camera_set(lua_State *L) case camera_aiming: cam->aiming = luaL_checkangle(L, 3); break; - case camera_x: - cam->x = luaL_checkfixed(L, 3); - break; - case camera_y: - cam->y = luaL_checkfixed(L, 3); - break; case camera_z: cam->z = luaL_checkfixed(L, 3); + P_CheckCameraPosition(cam->x, cam->y, cam); + cam->floorz = tmfloorz; + cam->ceilingz = tmceilingz; break; case camera_angle: cam->angle = luaL_checkangle(L, 3); break; + case camera_radius: + cam->radius = luaL_checkfixed(L, 3); + if (cam->radius < 0) + cam->radius = 0; + P_CheckCameraPosition(cam->x, cam->y, cam); + cam->floorz = tmfloorz; + cam->ceilingz = tmceilingz; + break; + case camera_height: + cam->height = luaL_checkfixed(L, 3); + if (cam->height < 0) + cam->height = 0; + P_CheckCameraPosition(cam->x, cam->y, cam); + cam->floorz = tmfloorz; + cam->ceilingz = tmceilingz; + break; case camera_momx: cam->momx = luaL_checkfixed(L, 3); break; From c337709d105696f91ed923371346326e11dd93ee Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Sun, 11 Jul 2021 16:32:36 -0400 Subject: [PATCH 0876/1080] Update f_finale.c --- src/f_finale.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/f_finale.c b/src/f_finale.c index e8757c18a..4d9a8f825 100644 --- a/src/f_finale.c +++ b/src/f_finale.c @@ -1166,7 +1166,6 @@ static const char *credits[] = { "Alexander \"DrTapeworm\" Moench-Ford", "Stefan \"Stuf\" Rimalia", "Shane Mychal Sexton", - "\"Spazzo\"", "David \"Big Wave Dave\" Spencer Sr.", "David \"Instant Sonic\" Spencer Jr.", "\"SSNTails\"", @@ -1191,7 +1190,6 @@ static const char *credits[] = { "\"Revan\"", "Anna \"QueenDelta\" Sandlin", "Wessel \"sphere\" Smit", - "\"Spazzo\"", "\"SSNTails\"", "Rob Tisdell", "\"Torgo\"", From 0faecf095987e4df5333a9d4fed6f06cd75bd9f0 Mon Sep 17 00:00:00 2001 From: SteelT Date: Sun, 11 Jul 2021 20:51:06 -0400 Subject: [PATCH 0877/1080] version.h: Update comment about contacting an MS admin --- src/version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/version.h b/src/version.h index 4470fbd6e..28fc71c36 100644 --- a/src/version.h +++ b/src/version.h @@ -1,6 +1,6 @@ #define SRB2VERSION "2.2.9"/* this must be the first line, for cmake !! */ -// The Modification ID; must be obtained from a Master Server Admin ( https://mb.srb2.org/showgroups.php ). +// The Modification ID; must be obtained from a Master Server Admin ( https://mb.srb2.org/members/?key=ms_admin ). // DO NOT try to set this otherwise, or your modification will be unplayable through the Master Server. // "18" is the default mod ID for version 2.2 #define MODID 18 From 58fa44e8dc0444eecbe701f31872fad9fa563a6a Mon Sep 17 00:00:00 2001 From: James R Date: Mon, 12 Jul 2021 03:50:44 -0700 Subject: [PATCH 0878/1080] CMP0115 --- src/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 4c125c4b8..721cd6dca 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -4,7 +4,7 @@ add_executable(SRB2SDL2 MACOSX_BUNDLE WIN32) # Core sources target_sourcefile(c) -target_sources(SRB2SDL2 PRIVATE comptime.c md5.c config.h) +target_sources(SRB2SDL2 PRIVATE comptime.c md5.c config.h.in) set(SRB2_ASM_SOURCES vid_copy.s) From 33ae95bf134571967f3f9875e5b3efeb2a352127 Mon Sep 17 00:00:00 2001 From: Shane Ellis Date: Mon, 12 Jul 2021 23:38:52 -0400 Subject: [PATCH 0879/1080] G_RemovePlayer error handling --- src/lua_baselib.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 9946a9fd3..34d1b1a94 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -3482,15 +3482,16 @@ static int lib_gAddPlayer(lua_State *L) static int lib_gRemovePlayer(lua_State *L) { UINT8 pnum = -1; - //const char *kickreason = luaL_checkstring(L, 2); - if (!lua_isnoneornil(L, 1)) pnum = luaL_checkinteger(L, 1); - if (&players[pnum]) + else // No argument + return luaL_error(L, "argument #1 not given (expected number)"); + if (pnum >= MAXPLAYERS) // Out of range + return luaL_error(L, "playernum %d out of range (0 - %d)", pnum, MAXPLAYERS-1); + if (playeringame[pnum]) // Found player { - if (players[pnum].bot != BOT_NONE) + if (players[pnum].bot != BOT_NONE) // Can't remove clients. { -// CL_RemovePlayer(pnum, *kickreason); CL_RemovePlayer(pnum, pnum); if (netgame) { @@ -3503,9 +3504,11 @@ static int lib_gRemovePlayer(lua_State *L) lua_pushboolean(L, true); return 1; } + else + return luaL_error(L, "G_RemovePlayer can only be used on players with a bot value other than BOT_NONE."); } - lua_pushboolean(L, false); - return 1; + // Fell through. Invalid player + return LUA_ErrInvalid(L, "player_t"); } From aed86781fc2794bb50a8245cbd0f2e5ea455d5c4 Mon Sep 17 00:00:00 2001 From: Nev3r Date: Tue, 13 Jul 2021 17:41:38 +0200 Subject: [PATCH 0880/1080] Bugfix - Fix sporadically occurring incorrect userdata types in Lua, caused by previously loaded userdata which didn't get invalidated in previous sessions. Invalidate userdata for line and mapthing args. Invalidate userdata for slopes and their normal, origin and direction vectors. --- src/lua_script.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/lua_script.c b/src/lua_script.c index 6faff8729..506a888ea 100644 --- a/src/lua_script.c +++ b/src/lua_script.c @@ -25,7 +25,7 @@ #include "byteptr.h" #include "p_saveg.h" #include "p_local.h" -#include "p_slopes.h" // for P_SlopeById +#include "p_slopes.h" // for P_SlopeById and slopelist #include "p_polyobj.h" // polyobj_t, PolyObjects #ifdef LUA_ALLOW_BYTECODE #include "d_netfil.h" // for LUA_DumpFile @@ -851,6 +851,7 @@ void LUA_InvalidateLevel(void) { LUA_InvalidateUserdata(&lines[i]); LUA_InvalidateUserdata(&lines[i].tags); + LUA_InvalidateUserdata(&lines[i].args); LUA_InvalidateUserdata(lines[i].sidenum); } for (i = 0; i < numsides; i++) @@ -863,6 +864,13 @@ void LUA_InvalidateLevel(void) LUA_InvalidateUserdata(&PolyObjects[i].vertices); LUA_InvalidateUserdata(&PolyObjects[i].lines); } + for (pslope_t *slope = slopelist; slope; slope = slope->next) + { + LUA_InvalidateUserdata(slope); + LUA_InvalidateUserdata(&slope->normal); + LUA_InvalidateUserdata(&slope->o); + LUA_InvalidateUserdata(&slope->d); + } #ifdef HAVE_LUA_SEGS for (i = 0; i < numsegs; i++) LUA_InvalidateUserdata(&segs[i]); @@ -885,6 +893,7 @@ void LUA_InvalidateMapthings(void) { LUA_InvalidateUserdata(&mapthings[i]); LUA_InvalidateUserdata(&mapthings[i].tags); + LUA_InvalidateUserdata(&mapthings[i].args); } } From 22dfa05c318b02bd77b9ee75990482b2d1378ad9 Mon Sep 17 00:00:00 2001 From: Nev3r Date: Tue, 13 Jul 2021 17:44:28 +0200 Subject: [PATCH 0881/1080] Forgot the stringargs. --- src/lua_script.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/lua_script.c b/src/lua_script.c index 506a888ea..a7bd67456 100644 --- a/src/lua_script.c +++ b/src/lua_script.c @@ -852,6 +852,7 @@ void LUA_InvalidateLevel(void) LUA_InvalidateUserdata(&lines[i]); LUA_InvalidateUserdata(&lines[i].tags); LUA_InvalidateUserdata(&lines[i].args); + LUA_InvalidateUserdata(&lines[i].stringargs); LUA_InvalidateUserdata(lines[i].sidenum); } for (i = 0; i < numsides; i++) @@ -894,6 +895,7 @@ void LUA_InvalidateMapthings(void) LUA_InvalidateUserdata(&mapthings[i]); LUA_InvalidateUserdata(&mapthings[i].tags); LUA_InvalidateUserdata(&mapthings[i].args); + LUA_InvalidateUserdata(&mapthings[i].stringargs); } } From 3a49b9519dc0faefa8f6f88d1354ac235b29c6c1 Mon Sep 17 00:00:00 2001 From: Nev3r Date: Tue, 13 Jul 2021 17:55:06 +0200 Subject: [PATCH 0882/1080] Remove &, since args and stringargs are arrays --- src/lua_script.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lua_script.c b/src/lua_script.c index a7bd67456..9eb1912b3 100644 --- a/src/lua_script.c +++ b/src/lua_script.c @@ -851,8 +851,8 @@ void LUA_InvalidateLevel(void) { LUA_InvalidateUserdata(&lines[i]); LUA_InvalidateUserdata(&lines[i].tags); - LUA_InvalidateUserdata(&lines[i].args); - LUA_InvalidateUserdata(&lines[i].stringargs); + LUA_InvalidateUserdata(lines[i].args); + LUA_InvalidateUserdata(lines[i].stringargs); LUA_InvalidateUserdata(lines[i].sidenum); } for (i = 0; i < numsides; i++) @@ -894,8 +894,8 @@ void LUA_InvalidateMapthings(void) { LUA_InvalidateUserdata(&mapthings[i]); LUA_InvalidateUserdata(&mapthings[i].tags); - LUA_InvalidateUserdata(&mapthings[i].args); - LUA_InvalidateUserdata(&mapthings[i].stringargs); + LUA_InvalidateUserdata(mapthings[i].args); + LUA_InvalidateUserdata(mapthings[i].stringargs); } } From 1c3a898bbbd5539f666b08d085692a356501f219 Mon Sep 17 00:00:00 2001 From: CobaltBW Date: Thu, 15 Jul 2021 12:53:13 -0700 Subject: [PATCH 0883/1080] Fixed locked characters being visible in multiplayer select screen --- src/r_skins.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/r_skins.c b/src/r_skins.c index c734b6001..86c0bbc54 100644 --- a/src/r_skins.c +++ b/src/r_skins.c @@ -242,7 +242,7 @@ boolean R_SkinUsable(INT32 playernum, INT32 skinnum) // Force 3. return true; } - if (players[playernum].bot) + if (playernum != -1 && players[playernum].bot) { //Force 4. return true; From 4486ff065af8d6ad3567043af16a58a300aff041 Mon Sep 17 00:00:00 2001 From: CobaltBW Date: Thu, 15 Jul 2021 13:03:26 -0700 Subject: [PATCH 0884/1080] All remaining player->bot checks modified to rely on BOT_ constants --- src/p_inter.c | 54 +++++++++++++++++++++++++-------------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/src/p_inter.c b/src/p_inter.c index 7e43c46a8..21e3bfa3d 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -151,7 +151,7 @@ boolean P_CanPickupItem(player_t *player, boolean weapon) if (!player->mo || player->mo->health <= 0) return false; - if (player->bot && player->bot != 3) + if (player->bot && player->bot != BOT_MPAI) { if (weapon) return false; @@ -178,7 +178,7 @@ void P_DoNightsScore(player_t *player) return; // Don't do any fancy shit for failures. dummymo = P_SpawnMobj(player->mo->x, player->mo->y, player->mo->z+player->mo->height/2, MT_NIGHTSCORE); - if (player->bot && player->bot != 3) + if (player->bot && player->bot != BOT_MPAI) player = &players[consoleplayer]; if (G_IsSpecialStage(gamemap)) // Global link count? Maybe not a good idea... @@ -630,7 +630,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) // ***************************** // // Special Stage Token case MT_TOKEN: - if (player->bot && player->bot != 3) + if (player->bot && player->bot != BOT_MPAI) return; P_AddPlayerScore(player, 1000); @@ -670,7 +670,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) // Emerald Hunt case MT_EMERHUNT: - if (player->bot && player->bot != 3) + if (player->bot && player->bot != BOT_MPAI) return; if (hunt1 == special) @@ -701,7 +701,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) case MT_EMERALD5: case MT_EMERALD6: case MT_EMERALD7: - if (player->bot && player->bot != 3) + if (player->bot && player->bot != BOT_MPAI) return; if (special->threshold) @@ -738,7 +738,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) // Secret emblem thingy case MT_EMBLEM: { - if (demoplayback || (player->bot && player->bot != 3)) + if (demoplayback || (player->bot && player->bot != BOT_MPAI)) return; emblemlocations[special->health-1].collected = true; @@ -751,7 +751,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) // CTF Flags case MT_REDFLAG: case MT_BLUEFLAG: - if (player->bot && player->bot != 3) + if (player->bot && player->bot != BOT_MPAI) return; if (player->powers[pw_flashing] || player->tossdelay) return; @@ -826,7 +826,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) { boolean spec = G_IsSpecialStage(gamemap); boolean cangiveemmy = false; - if (player->bot && player->bot != 3) + if (player->bot && player->bot != BOT_MPAI) return; if (player->exiting) return; @@ -1072,7 +1072,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) } return; case MT_EGGCAPSULE: - if (player->bot && player->bot != 3) + if (player->bot && player->bot != BOT_MPAI) return; // make sure everything is as it should be, THEN take rings from players in special stages @@ -1164,7 +1164,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) } return; case MT_NIGHTSSUPERLOOP: - if ((player->bot && player->bot != 3) || !(player->powers[pw_carry] == CR_NIGHTSMODE)) + if ((player->bot && player->bot != BOT_MPAI) || !(player->powers[pw_carry] == CR_NIGHTSMODE)) return; if (!G_IsSpecialStage(gamemap)) player->powers[pw_nights_superloop] = (UINT16)special->info->speed; @@ -1186,7 +1186,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) } break; case MT_NIGHTSDRILLREFILL: - if ((player->bot && player->bot != 3) || !(player->powers[pw_carry] == CR_NIGHTSMODE)) + if ((player->bot && player->bot != BOT_MPAI) || !(player->powers[pw_carry] == CR_NIGHTSMODE)) return; if (!G_IsSpecialStage(gamemap)) player->drillmeter = special->info->speed; @@ -1208,7 +1208,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) } break; case MT_NIGHTSHELPER: - if ((player->bot && player->bot != 3) || !(player->powers[pw_carry] == CR_NIGHTSMODE)) + if ((player->bot && player->bot != BOT_MPAI) || !(player->powers[pw_carry] == CR_NIGHTSMODE)) return; if (!G_IsSpecialStage(gamemap)) { @@ -1240,7 +1240,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) } break; case MT_NIGHTSEXTRATIME: - if ((player->bot && player->bot != 3) || !(player->powers[pw_carry] == CR_NIGHTSMODE)) + if ((player->bot && player->bot != BOT_MPAI) || !(player->powers[pw_carry] == CR_NIGHTSMODE)) return; if (!G_IsSpecialStage(gamemap)) { @@ -1272,7 +1272,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) } break; case MT_NIGHTSLINKFREEZE: - if ((player->bot && player->bot != 3) || !(player->powers[pw_carry] == CR_NIGHTSMODE)) + if ((player->bot && player->bot != BOT_MPAI) || !(player->powers[pw_carry] == CR_NIGHTSMODE)) return; if (!G_IsSpecialStage(gamemap)) { @@ -1332,7 +1332,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) if (playeringame[i] && players[i].powers[pw_carry] == CR_NIGHTSMODE) players[i].drillmeter += TICRATE/2; } - else if (player->bot && player->bot != 3) + else if (player->bot && player->bot != BOT_MPAI) players[consoleplayer].drillmeter += TICRATE/2; else player->drillmeter += TICRATE/2; @@ -1385,7 +1385,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) thinker_t *th; mobj_t *mo2; - if (player->bot && player->bot != 3) + if (player->bot && player->bot != BOT_MPAI) return; // Initialize my junk @@ -1423,7 +1423,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) return; } case MT_FIREFLOWER: - if (player->bot && player->bot != 3) + if (player->bot && player->bot != BOT_MPAI) return; S_StartSound(toucher, sfx_mario3); @@ -1685,7 +1685,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) return; // Only go in the mouth // Eaten by player! - if ((!player->bot || player->bot == 3) && (player->powers[pw_underwater] && player->powers[pw_underwater] <= 12*TICRATE + 1)) + if ((!player->bot || player->bot == BOT_MPAI) && (player->powers[pw_underwater] && player->powers[pw_underwater] <= 12*TICRATE + 1)) { player->powers[pw_underwater] = underwatertics + 1; P_RestoreMusic(player); @@ -1696,7 +1696,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) if (!player->climbing) { - if (player->bot && player->bot != 3 && toucher->state-states != S_PLAY_GASP) + if (player->bot && player->bot != BOT_MPAI && toucher->state-states != S_PLAY_GASP) S_StartSound(toucher, special->info->deathsound); // Force it to play a sound for bots P_SetPlayerMobjState(toucher, S_PLAY_GASP); P_ResetPlayer(player); @@ -1704,7 +1704,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) toucher->momx = toucher->momy = toucher->momz = 0; - if (player->bot && player->bot != 3) + if (player->bot && player->bot != BOT_MPAI) return; else break; @@ -1736,7 +1736,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) return; case MT_MINECARTSPAWNER: - if (!player->bot && player->bot != 3 && special->fuse <= TICRATE && player->powers[pw_carry] != CR_MINECART && !(player->powers[pw_ignorelatch] & (1<<15))) + if (!player->bot && player->bot != BOT_MPAI && special->fuse <= TICRATE && player->powers[pw_carry] != CR_MINECART && !(player->powers[pw_ignorelatch] & (1<<15))) { mobj_t *mcart = P_SpawnMobj(special->x, special->y, special->z, MT_MINECART); P_SetTarget(&mcart->target, toucher); @@ -1789,7 +1789,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) } return; default: // SOC or script pickup - if (player->bot && player->bot != 3) + if (player->bot && player->bot != BOT_MPAI) return; P_SetTarget(&special->target, toucher); break; @@ -1813,7 +1813,7 @@ void P_TouchStarPost(mobj_t *post, player_t *player, boolean snaptopost) mobj_t *toucher = player->mo; mobj_t *checkbase = snaptopost ? post : toucher; - if (player->bot && player->bot != 3) + if (player->bot && player->bot != BOT_MPAI) return; // In circuit, player must have touched all previous starposts if (circuitmap @@ -2555,7 +2555,7 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, UINT8 damaget if ((target->player->lives <= 1) && (netgame || multiplayer) && G_GametypeUsesCoopLives() && (cv_cooplives.value == 0)) ; - else if ((!target->player->bot || target->player->bot == 3) && !target->player->spectator && (target->player->lives != INFLIVES) + else if ((!target->player->bot || target->player->bot == BOT_MPAI) && !target->player->spectator && (target->player->lives != INFLIVES) && G_GametypeUsesLives()) { if (!(target->player->pflags & PF_FINISHED)) @@ -3475,7 +3475,7 @@ void P_SpecialStageDamage(player_t *player, mobj_t *inflictor, mobj_t *source) if (inflictor && inflictor->type == MT_LHRT) return; - if (player->powers[pw_shield] || (player->bot && player->bot != 3)) //If One-Hit Shield + if (player->powers[pw_shield] || (player->bot && player->bot != BOT_MPAI)) //If One-Hit Shield { P_RemoveShield(player); S_StartSound(player->mo, sfx_shldls); // Ba-Dum! Shield loss. @@ -3566,7 +3566,7 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da return false; // Make sure that boxes cannot be popped by enemies, red rings, etc. - if (target->flags & MF_MONITOR && ((!source || !source->player || (source->player->bot && source->player->bot != 3)) + if (target->flags & MF_MONITOR && ((!source || !source->player || (source->player->bot && source->player->bot != BOT_MPAI)) || (inflictor && (inflictor->type == MT_REDRING || (inflictor->type >= MT_THROWNBOUNCE && inflictor->type <= MT_THROWNGRENADE))))) return false; } @@ -3701,7 +3701,7 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da } else if (LUA_HookMobjDamage(target, inflictor, source, damage, damagetype)) return true; - else if (player->powers[pw_shield] || (player->bot && player->bot != 3 && !ultimatemode)) //If One-Hit Shield + else if (player->powers[pw_shield] || (player->bot && player->bot != BOT_MPAI && !ultimatemode)) //If One-Hit Shield { P_ShieldDamage(player, inflictor, source, damage, damagetype); damage = 0; From 48514ee88d54a5d36a92c2af0fdd1feb587acf2d Mon Sep 17 00:00:00 2001 From: CobaltBW Date: Thu, 15 Jul 2021 15:04:24 -0700 Subject: [PATCH 0885/1080] Fixed G_RemovePlayer crash in players.iterate This was done by storing flag-for-removal status as a boolean inside the player struct. Bot players are instead removed at the start of G_Ticker, rather than being removed immediately by G_RemovePlayer. --- src/d_player.h | 1 + src/g_game.c | 22 +++++++++++++++++++++- src/lua_baselib.c | 14 ++------------ src/p_saveg.c | 2 ++ 4 files changed, 26 insertions(+), 13 deletions(-) diff --git a/src/d_player.h b/src/d_player.h index 89776fe5e..a0db1402d 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -559,6 +559,7 @@ typedef struct player_s boolean spectator; boolean outofcoop; + boolean removing; UINT8 bot; struct player_s *botleader; UINT16 lastbuttons; diff --git a/src/g_game.c b/src/g_game.c index 0643350b6..4d501f526 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1545,7 +1545,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) cmd->forwardmove = (SINT8)(cmd->forwardmove + forward); cmd->sidemove = (SINT8)(cmd->sidemove + side); - //Note: Majority of botstuffs are handled in G_Ticker now. + // Note: Majority of botstuffs are handled in G_Ticker now. if (player->bot == BOT_2PHUMAN) //Player-controlled bot { G_CopyTiccmd(cmd, I_BaseTiccmd2(), 1); // empty, or external driver @@ -2198,6 +2198,23 @@ void G_Ticker(boolean run) UINT32 i; INT32 buf; + // Bot players queued for removal + for (i = MAXPLAYERS-1; i != UINT32_MAX; i--) + { + if (playeringame[i] && players[i].removing) + { + CL_RemovePlayer(i, i); + if (netgame) + { + char kickmsg[256]; + + strcpy(kickmsg, M_GetText("\x82*Bot %s has been removed")); + strcpy(kickmsg, va(kickmsg, player_names[i], i)); + HU_AddChatText(kickmsg, false); + } + } + } + // see also SCR_DisplayMarathonInfo if ((marathonmode & (MA_INIT|MA_INGAME)) == MA_INGAME && gamestate == GS_LEVEL) marathontime++; @@ -2520,6 +2537,7 @@ void G_PlayerReborn(INT32 player, boolean betweenmaps) tic_t quittime; boolean spectator; boolean outofcoop; + boolean removing; INT16 bot; SINT8 pity; INT16 rings; @@ -2536,6 +2554,7 @@ void G_PlayerReborn(INT32 player, boolean betweenmaps) quittime = players[player].quittime; spectator = players[player].spectator; outofcoop = players[player].outofcoop; + removing = players[player].removing; pflags = (players[player].pflags & (PF_FLIPCAM|PF_ANALOGMODE|PF_DIRECTIONCHAR|PF_AUTOBRAKE|PF_TAGIT|PF_GAMETYPEOVER)); playerangleturn = players[player].angleturn; oldrelangleturn = players[player].oldrelangleturn; @@ -2612,6 +2631,7 @@ void G_PlayerReborn(INT32 player, boolean betweenmaps) p->quittime = quittime; p->spectator = spectator; p->outofcoop = outofcoop; + p->removing = removing; p->angleturn = playerangleturn; p->oldrelangleturn = oldrelangleturn; diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 9946a9fd3..9e01a98c0 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -3482,24 +3482,14 @@ static int lib_gAddPlayer(lua_State *L) static int lib_gRemovePlayer(lua_State *L) { UINT8 pnum = -1; - //const char *kickreason = luaL_checkstring(L, 2); if (!lua_isnoneornil(L, 1)) pnum = luaL_checkinteger(L, 1); if (&players[pnum]) { - if (players[pnum].bot != BOT_NONE) + if (players[pnum].bot != BOT_NONE && players[pnum].removing == false) { -// CL_RemovePlayer(pnum, *kickreason); - CL_RemovePlayer(pnum, pnum); - if (netgame) - { - char kickmsg[256]; - - strcpy(kickmsg, M_GetText("\x82*Bot %s has been removed")); - strcpy(kickmsg, va(kickmsg, player_names[pnum], pnum)); - HU_AddChatText(kickmsg, false); - } + players[pnum].removing = true; // This function can be run in players.iterate(), which isn't equipped to deal with players being removed mid-process. Instead we'll remove the player at the beginning of the next ticframe. lua_pushboolean(L, true); return 1; } diff --git a/src/p_saveg.c b/src/p_saveg.c index 7e9d7b6d4..1270064c0 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -201,6 +201,7 @@ static void P_NetArchivePlayers(void) WRITEUINT8(save_p, players[i].botmem.lastBlocked); WRITEUINT8(save_p, players[i].botmem.catchup_tics); WRITEUINT8(save_p, players[i].botmem.thinkstate); + WRITEUINT8(save_p, players[i].removing); WRITEUINT8(save_p, players[i].blocked); WRITEUINT16(save_p, players[i].lastbuttons); @@ -428,6 +429,7 @@ static void P_NetUnArchivePlayers(void) players[i].botmem.lastBlocked = READUINT8(save_p); players[i].botmem.catchup_tics = READUINT8(save_p); players[i].botmem.thinkstate = READUINT8(save_p); + players[i].removing = READUINT8(save_p); players[i].blocked = READUINT8(save_p); players[i].lastbuttons = READUINT16(save_p); From 22f42efb61e242a75a017712d6b753149c3a91ce Mon Sep 17 00:00:00 2001 From: CobaltBW Date: Thu, 15 Jul 2021 15:09:02 -0700 Subject: [PATCH 0886/1080] Cleaned up leftover comments --- src/b_bot.c | 4 ---- src/g_game.c | 2 +- src/p_mobj.c | 1 - src/p_user.c | 29 ++++++----------------------- 4 files changed, 7 insertions(+), 29 deletions(-) diff --git a/src/b_bot.c b/src/b_bot.c index c61e56f5f..6f4b0ce15 100644 --- a/src/b_bot.c +++ b/src/b_bot.c @@ -102,7 +102,6 @@ static void B_BuildTailsTiccmd(mobj_t *sonic, mobj_t *tails, ticcmd_t *cmd) if (tails->player->powers[pw_carry] == CR_MACESPIN || tails->player->powers[pw_carry] == CR_GENERIC) { boolean isrelevant = (sonic->player->powers[pw_carry] == CR_MACESPIN || sonic->player->powers[pw_carry] == CR_GENERIC); - //dist = P_AproxDistance(tails->x-sonic->x, tails->y-sonic->y); //! This is totally redundant. if (sonic->player->cmd.buttons & BT_JUMP && (sonic->player->pflags & PF_JUMPED) && isrelevant) cmd->buttons |= BT_JUMP; if (isrelevant) @@ -402,8 +401,6 @@ void B_KeysToTiccmd(mobj_t *mo, ticcmd_t *cmd, boolean forward, boolean backward { player_t *player = mo->player; // don't try to do stuff if your sonic is in a minecart or something - //if (players[consoleplayer].powers[pw_carry] && players[consoleplayer].powers[pw_carry] != CR_PLAYER) - //!!! if (&player->botleader && player->botleader->powers[pw_carry] && player->botleader->powers[pw_carry] != CR_PLAYER) return; // Turn the virtual keypresses into ticcmd_t. @@ -576,7 +573,6 @@ void B_RespawnBot(INT32 playernum) player->powers[pw_spacetime] = sonic->player->powers[pw_spacetime]; player->powers[pw_gravityboots] = sonic->player->powers[pw_gravityboots]; player->powers[pw_nocontrol] = sonic->player->powers[pw_nocontrol]; - //!!! Nuke the speed equivalencies player->pflags |= PF_AUTOBRAKE|(sonic->player->pflags & PF_DIRECTIONCHAR); P_TeleportMove(tails, x, y, z); diff --git a/src/g_game.c b/src/g_game.c index 4d501f526..8cdeaf079 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -3025,7 +3025,7 @@ void G_DoReborn(INT32 playernum) // Make sure objectplace is OFF when you first start the level! OP_ResetObjectplace(); - //! Tailsbot + // Tailsbot if (player->bot == BOT_2PAI || player->bot == BOT_2PHUMAN) { // Bots respawn next to their master. mobj_t *oldmo = NULL; diff --git a/src/p_mobj.c b/src/p_mobj.c index 4924ec053..8af7ab0d0 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -1839,7 +1839,6 @@ void P_XYMovement(mobj_t *mo) // blocked move moved = false; - //!!! if (player) B_MoveBlocked(player); diff --git a/src/p_user.c b/src/p_user.c index dadc23193..b3535623c 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -776,7 +776,7 @@ void P_NightserizePlayer(player_t *player, INT32 nighttime) { UINT8 oldmare, oldmarelap, oldmarebonuslap; - //! Bots can't be NiGHTSerized, silly!1 :P + // Bots can't be NiGHTSerized, silly!1 :P if (player->bot == BOT_2PAI || player->bot == BOT_2PHUMAN) return; @@ -1188,7 +1188,7 @@ void P_GivePlayerRings(player_t *player, INT32 num_rings) { if (!player) return; - //! + if ((player->bot == BOT_2PAI || player->bot == BOT_2PHUMAN) && player->botleader) player = player->botleader; @@ -5965,23 +5965,6 @@ static void P_3dMovement(player_t *player) acceleration = 96 + (FixedDiv(player->speed, player->mo->scale)>>FRACBITS) * 40; topspeed = normalspd; } - //! Kill this! - /* else if (player->bot == BOT_2PAI || player->bot == BOT_2PHUMAN) - { // Bot steals player 1's stats - normalspd = FixedMul(players[consoleplayer].normalspeed, player->mo->scale); - thrustfactor = players[consoleplayer].thrustfactor; - acceleration = players[consoleplayer].accelstart + (FixedDiv(player->speed, player->mo->scale)>>FRACBITS) * players[consoleplayer].acceleration; - - if (player->powers[pw_tailsfly]) - topspeed = normalspd/2; - else if (player->mo->eflags & (MFE_UNDERWATER|MFE_GOOWATER)) - { - topspeed = normalspd/2; - acceleration = 2*acceleration/3; - } - else - topspeed = normalspd; - } */ else { if (player->powers[pw_super] || player->powers[pw_sneakers]) @@ -11488,7 +11471,7 @@ void P_PlayerThink(player_t *player) I_Error("p_playerthink: players[%s].mo == NULL", sizeu1(playeri)); #endif - //! Reset terrain blocked status for this frame + // Reset terrain blocked status for this frame player->blocked = false; // todo: Figure out what is actually causing these problems in the first place... @@ -11641,7 +11624,7 @@ void P_PlayerThink(player_t *player) INT32 i; for (i = 0; i < MAXPLAYERS; i++) - { //! + { if (!playeringame[i] || players[i].spectator || players[i].bot == BOT_2PAI || players[i].bot == BOT_2PHUMAN) continue; if (players[i].lives <= 0) @@ -11673,7 +11656,7 @@ void P_PlayerThink(player_t *player) INT32 i, total = 0, exiting = 0; for (i = 0; i < MAXPLAYERS; i++) - { //! + { if (!playeringame[i] || players[i].spectator || players[i].bot == BOT_2PAI || players[i].bot == BOT_2PHUMAN) continue; if (players[i].quittime > 30 * TICRATE) @@ -12614,7 +12597,7 @@ void P_PlayerAfterThink(player_t *player) player->mo->momy = tails->momy; player->mo->momz = tails->momz; } - //! + if (G_CoopGametype() && tails->player && tails->player->bot != BOT_2PAI) { player->mo->angle = tails->angle; From 95359fef5142d1dce33ebce35b18d13846e2ca56 Mon Sep 17 00:00:00 2001 From: CobaltBW Date: Thu, 15 Jul 2021 15:19:47 -0700 Subject: [PATCH 0887/1080] Amendment to G_RemovePlayer to preserve lua error handlers --- src/lua_baselib.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 9e01a98c0..f287fb78c 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -3482,20 +3482,25 @@ static int lib_gAddPlayer(lua_State *L) static int lib_gRemovePlayer(lua_State *L) { UINT8 pnum = -1; - if (!lua_isnoneornil(L, 1)) pnum = luaL_checkinteger(L, 1); - if (&players[pnum]) + else // No argument + return luaL_error(L, "argument #1 not given (expected number)"); + if (pnum >= MAXPLAYERS) // Out of range + return luaL_error(L, "playernum %d out of range (0 - %d)", pnum, MAXPLAYERS-1); + if (playeringame[pnum]) // Found player { - if (players[pnum].bot != BOT_NONE && players[pnum].removing == false) + if (players[pnum].bot == BOT_NONE) // Can't remove clients. + return luaL_error(L, "G_RemovePlayer can only be used on players with a bot value other than BOT_NONE."); + else { - players[pnum].removing = true; // This function can be run in players.iterate(), which isn't equipped to deal with players being removed mid-process. Instead we'll remove the player at the beginning of the next ticframe. + players[pnum].removing = true; lua_pushboolean(L, true); return 1; } } - lua_pushboolean(L, false); - return 1; + // Fell through. Invalid player + return LUA_ErrInvalid(L, "player_t"); } From 71f905f95bd4fe62dbca87208cf71b7309f12de1 Mon Sep 17 00:00:00 2001 From: SteelT Date: Fri, 16 Jul 2021 15:26:09 -0400 Subject: [PATCH 0888/1080] Fix gme support being effectively disabled I found this easier than trying to adjust the makefile, as it uses the same thing to automatically generate the various NO* compile options. --- src/CMakeLists.txt | 2 +- src/sdl/mixer_sound.c | 46 +++++++++++++++++++++---------------------- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 721cd6dca..ae93aac37 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -60,7 +60,7 @@ if(${SRB2_CONFIG_HAVE_GME}) endif() if(${GME_FOUND}) set(SRB2_HAVE_GME ON) - target_compile_definitions(SRB2SDL2 PRIVATE -DHAVE_LIBGME) + target_compile_definitions(SRB2SDL2 PRIVATE -DHAVE_GME) else() message(WARNING "You have specified that GME is available but it was not found.") endif() diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index 2f1a87266..35a79acc0 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -9,7 +9,7 @@ /// \file /// \brief SDL Mixer interface for sound -#ifdef HAVE_LIBGME +#ifdef HAVE_GME #ifdef HAVE_ZLIB #ifndef _MSC_VER #ifndef _LARGEFILE64_SOURCE @@ -27,7 +27,7 @@ #include #endif // HAVE_ZLIB -#endif // HAVE_LIBGME +#endif // HAVE_GME #include "../doomdef.h" #include "../doomstat.h" // menuactive @@ -73,11 +73,11 @@ #define MUS_MODPLUG MUS_MODPLUG_UNUSED #endif -#ifdef HAVE_LIBGME +#ifdef HAVE_GME #include "gme/gme.h" #define GME_TREBLE 5.0f #define GME_BASS 1.0f -#endif // HAVE_LIBGME +#endif // HAVE_GME static UINT16 BUFFERSIZE = 2048; static UINT16 SAMPLERATE = 44100; @@ -110,7 +110,7 @@ static INT32 fading_id; static void (*fading_callback)(void); static boolean fading_nocleanup; -#ifdef HAVE_LIBGME +#ifdef HAVE_GME static Music_Emu *gme; static UINT16 current_track; #endif @@ -220,7 +220,7 @@ static void var_cleanup(void) internal_volume = 100; } -#if defined (HAVE_LIBGME) && defined (HAVE_ZLIB) +#if defined (HAVE_GME) && defined (HAVE_ZLIB) static const char* get_zlib_error(int zErr) { switch (zErr) @@ -318,7 +318,7 @@ void I_ShutdownSound(void) SDL_QuitSubSystem(SDL_INIT_AUDIO); -#ifdef HAVE_LIBGME +#ifdef HAVE_GME if (gme) gme_delete(gme); #endif @@ -453,7 +453,7 @@ void *I_GetSfx(sfxinfo_t *sfx) void *lump; Mix_Chunk *chunk; SDL_RWops *rw; -#ifdef HAVE_LIBGME +#ifdef HAVE_GME Music_Emu *emu; gme_info_t *info; #endif @@ -473,7 +473,7 @@ void *I_GetSfx(sfxinfo_t *sfx) } // Not a doom sound? Try something else. -#ifdef HAVE_LIBGME +#ifdef HAVE_GME // VGZ format if (((UINT8 *)lump)[0] == 0x1F && ((UINT8 *)lump)[1] == 0x8B) @@ -729,7 +729,7 @@ static UINT32 music_fade(UINT32 interval, void *param) } } -#ifdef HAVE_LIBGME +#ifdef HAVE_GME static void mix_gme(void *udata, Uint8 *stream, int len) { int i; @@ -797,7 +797,7 @@ void I_ShutdownMusic(void) musictype_t I_SongType(void) { -#ifdef HAVE_LIBGME +#ifdef HAVE_GME if (gme) return MU_GME; else @@ -828,7 +828,7 @@ musictype_t I_SongType(void) boolean I_SongPlaying(void) { return ( -#ifdef HAVE_LIBGME +#ifdef HAVE_GME (I_SongType() == MU_GME && gme) || #endif #ifdef HAVE_OPENMPT @@ -851,7 +851,7 @@ boolean I_SetSongSpeed(float speed) { if (speed > 250.0f) speed = 250.0f; //limit speed up to 250x -#ifdef HAVE_LIBGME +#ifdef HAVE_GME if (gme) { SDL_LockAudio(); @@ -893,7 +893,7 @@ UINT32 I_GetSongLength(void) { INT32 length; -#ifdef HAVE_LIBGME +#ifdef HAVE_GME if (gme) { gme_info_t *info; @@ -963,7 +963,7 @@ boolean I_SetSongLoopPoint(UINT32 looppoint) UINT32 I_GetSongLoopPoint(void) { -#ifdef HAVE_LIBGME +#ifdef HAVE_GME if (gme) { INT32 looppoint; @@ -992,7 +992,7 @@ UINT32 I_GetSongLoopPoint(void) boolean I_SetSongPosition(UINT32 position) { UINT32 length; -#ifdef HAVE_LIBGME +#ifdef HAVE_GME if (gme) { // this is unstable, so fail silently @@ -1055,7 +1055,7 @@ boolean I_SetSongPosition(UINT32 position) UINT32 I_GetSongPosition(void) { -#ifdef HAVE_LIBGME +#ifdef HAVE_GME if (gme) { INT32 position = gme_tell(gme); @@ -1124,7 +1124,7 @@ boolean I_LoadSong(char *data, size_t len) SDL_RWops *rw; if (music -#ifdef HAVE_LIBGME +#ifdef HAVE_GME || gme #endif #ifdef HAVE_OPENMPT @@ -1136,7 +1136,7 @@ boolean I_LoadSong(char *data, size_t len) // always do this whether or not a music already exists var_cleanup(); -#ifdef HAVE_LIBGME +#ifdef HAVE_GME if ((UINT8)data[0] == 0x1F && (UINT8)data[1] == 0x8B) { @@ -1271,7 +1271,7 @@ void I_UnloadSong(void) { I_StopSong(); -#ifdef HAVE_LIBGME +#ifdef HAVE_GME if (gme) { gme_delete(gme); @@ -1294,7 +1294,7 @@ void I_UnloadSong(void) boolean I_PlaySong(boolean looping) { -#ifdef HAVE_LIBGME +#ifdef HAVE_GME if (gme) { gme_equalizer_t eq = {GME_TREBLE, GME_BASS, 0,0,0,0,0,0,0,0}; @@ -1360,7 +1360,7 @@ void I_StopSong(void) if (!fading_nocleanup) I_StopFadingSong(); -#ifdef HAVE_LIBGME +#ifdef HAVE_GME if (gme) { Mix_HookMusic(NULL, NULL); @@ -1433,7 +1433,7 @@ void I_SetMusicVolume(UINT8 volume) boolean I_SetSongTrack(int track) { -#ifdef HAVE_LIBGME +#ifdef HAVE_GME // If the specified track is within the number of tracks playing, then change it if (gme) { From 58db5a6904943ef944f76ca45d260a1bc123463f Mon Sep 17 00:00:00 2001 From: Radicalicious Date: Wed, 28 Jul 2021 15:42:44 +0000 Subject: [PATCH 0889/1080] Fix P_PlayerInPain crash. --- src/p_user.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/p_user.c b/src/p_user.c index c5f919c78..f3ebc7dff 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -969,6 +969,9 @@ pflags_t P_GetJumpFlags(player_t *player) // boolean P_PlayerInPain(player_t *player) { + // If the player doesn't have a mobj, it can't be in pain. + if !(player->mo) + return false; // no silly, sliding isn't pain if (!(player->pflags & PF_SLIDING) && player->mo->state == &states[player->mo->info->painstate] && player->powers[pw_flashing]) return true; From d50e3bff70f1ac28fc74e85f8e93642a979f0b52 Mon Sep 17 00:00:00 2001 From: Radicalicious Date: Thu, 29 Jul 2021 15:55:19 +0000 Subject: [PATCH 0890/1080] ACTUALLY fix the issue. --- 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 f3ebc7dff..740688b45 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -970,7 +970,7 @@ pflags_t P_GetJumpFlags(player_t *player) boolean P_PlayerInPain(player_t *player) { // If the player doesn't have a mobj, it can't be in pain. - if !(player->mo) + if (!player->mo) return false; // no silly, sliding isn't pain if (!(player->pflags & PF_SLIDING) && player->mo->state == &states[player->mo->info->painstate] && player->powers[pw_flashing]) From 7dddc631d798469725e40bd3fbc1a2617f4982ee Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Sat, 31 Jul 2021 21:14:48 +0100 Subject: [PATCH 0891/1080] P_ZMovement: add a P_MobjWasRemoved check after P_CheckPosition, so we can bail out if the mobj was removed (by Lua most likely) --- src/p_mobj.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/p_mobj.c b/src/p_mobj.c index 10220fff6..3bb7ac58d 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -2549,6 +2549,10 @@ boolean P_ZMovement(mobj_t *mo) } P_CheckPosition(mo, mo->x, mo->y); // Sets mo->standingslope correctly + + if (P_MobjWasRemoved(mobj)) // 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; From df99cde40ffd1163cfec164e72f7b5d3b31261cb Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Sat, 31 Jul 2021 22:11:44 +0100 Subject: [PATCH 0892/1080] mo not mobj! --- 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 3bb7ac58d..da7385be5 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -2550,7 +2550,7 @@ boolean P_ZMovement(mobj_t *mo) P_CheckPosition(mo, mo->x, mo->y); // Sets mo->standingslope correctly - if (P_MobjWasRemoved(mobj)) // mobjs can be removed by P_CheckPosition -- Monster Iestyn 31/07/21 + if (P_MobjWasRemoved(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)) From 2d218859ff4f879ee13fbf3e45d6dc890be9012a Mon Sep 17 00:00:00 2001 From: SMS Alfredo <65426124+SMS-Alfredo@users.noreply.github.com> Date: Fri, 6 Aug 2021 23:25:19 -0500 Subject: [PATCH 0893/1080] Give coins a drop shadow --- src/p_mobj.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/p_mobj.c b/src/p_mobj.c index da7385be5..c7e0a7909 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -10391,6 +10391,9 @@ static fixed_t P_DefaultMobjShadowScale (mobj_t *thing) case MT_RING: case MT_FLINGRING: + + case MT_COIN: + case MT_FLINGCOIN: case MT_BLUESPHERE: case MT_FLINGBLUESPHERE: From d1e8b05749447da3c7944d852b0484c6c9dc3842 Mon Sep 17 00:00:00 2001 From: LJ Sonic Date: Sun, 8 Aug 2021 19:43:42 +0200 Subject: [PATCH 0894/1080] Don't call map load trigger linedefs when joining or reloading gamestate --- src/p_spec.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/p_spec.c b/src/p_spec.c index 4b566acfb..e5e546b7a 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -7102,7 +7102,8 @@ void P_SpawnSpecials(boolean fromnetsave) } } - P_RunLevelLoadExecutors(); + if (!fromnetsave) + P_RunLevelLoadExecutors(); } /** Adds 3Dfloors as appropriate based on a common control linedef. From a9b35a6f7a68d7dfd2e0df907b628f8bc3135a1f Mon Sep 17 00:00:00 2001 From: LJ Sonic Date: Tue, 10 Aug 2021 00:15:44 +0200 Subject: [PATCH 0895/1080] Fix incorrect error message during Lua archiving --- src/lua_script.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/lua_script.c b/src/lua_script.c index 9eb1912b3..25e0a8f37 100644 --- a/src/lua_script.c +++ b/src/lua_script.c @@ -1384,21 +1384,13 @@ static void ArchiveTables(void) // Write key e = ArchiveValue(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) - { - lua_pushvalue(gL, -2); - 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, 1); - } + CONS_Alert(CONS_ERROR, "Index '%s' (%s) of table %d could not be archived!\n", lua_tostring(gL, -2), luaL_typename(gL, -2), i); // Write value e = ArchiveValue(TABLESINDEX, -1); if (e == 1) n++; // the table contained a new table we'll have to archive. :( else if (e == 2) // invalid value type - { - lua_pushvalue(gL, -2); 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, -1)); - lua_pop(gL, 1); - } lua_pop(gL, 1); } From 6403a38c72cfdb57a25ccd380037034eb831fcff Mon Sep 17 00:00:00 2001 From: LJ Sonic Date: Tue, 10 Aug 2021 01:48:26 +0200 Subject: [PATCH 0896/1080] Fix again --- src/lua_script.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lua_script.c b/src/lua_script.c index 25e0a8f37..bf262c065 100644 --- a/src/lua_script.c +++ b/src/lua_script.c @@ -1390,7 +1390,7 @@ static void ArchiveTables(void) 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, -1), luaL_typename(gL, -1)); + 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); } From 15b7221c7895d05103239a08c34ac1ff890ad000 Mon Sep 17 00:00:00 2001 From: litten Date: Thu, 12 Aug 2021 12:39:28 -0500 Subject: [PATCH 0897/1080] modified: debian-template/rules --- debian-template/rules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian-template/rules b/debian-template/rules index 0a77624cb..12ceaf98b 100644 --- a/debian-template/rules +++ b/debian-template/rules @@ -78,7 +78,7 @@ NONX86 = $(shell test "`echo $(CROSS_COMPILE_HOST) | grep 'i[3-6]86'`" || echo " MAKEARGS = $(OS) $(NONX86) $(PREFIX) EXENAME=$(EXENAME) DBGNAME=$(DBGNAME) NOOBJDUMP=1 # SDL_PKGCONFIG=sdl2 PNG_PKGCONFIG=libpng MENUFILE1 = ?package($(PACKAGE)):needs="X11" section="$(SECTION)" MENUFILE2 = title="$(TITLE)" command="/$(PKGDIR)/$(PACKAGE)" -BINDIR := $(DIR)/bin/Linux/Release +BINDIR := $(DIR)/bin/ # FIXME pkg-config dir hacks # Launchpad doesn't need this; it actually makes i386 builds fail due to cross-compile From 8adf4b672acc12b6726192be980f18e30e70624f Mon Sep 17 00:00:00 2001 From: LJ Sonic Date: Fri, 13 Aug 2021 21:58:34 +0200 Subject: [PATCH 0898/1080] Put Lua input library in its own namespace --- src/lua_inputlib.c | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/src/lua_inputlib.c b/src/lua_inputlib.c index 71eb1033f..7ad265eff 100644 --- a/src/lua_inputlib.c +++ b/src/lua_inputlib.c @@ -127,19 +127,19 @@ static int lib_getCursorPosition(lua_State *L) } static luaL_Reg lib[] = { - {"G_GameControlDown", lib_gameControlDown}, - {"G_GameControl2Down", lib_gameControl2Down}, - {"G_GameControlToKeyNum", lib_gameControlToKeyNum}, - {"G_GameControl2ToKeyNum", lib_gameControl2ToKeyNum}, - {"G_JoyAxis", lib_joyAxis}, - {"G_Joy2Axis", lib_joy2Axis}, - {"G_KeyNumToString", lib_keyNumToString}, - {"G_KeyStringToNum", lib_keyStringToNum}, - {"HU_KeyNumPrintable", lib_keyNumPrintable}, - {"HU_ShiftKeyNum", lib_shiftKeyNum}, - {"I_GetMouseGrab", lib_getMouseGrab}, - {"I_SetMouseGrab", lib_setMouseGrab}, - {"I_GetCursorPosition", lib_getCursorPosition}, + {"gameControlDown", lib_gameControlDown}, + {"gameControl2Down", lib_gameControl2Down}, + {"gameControlToKeyNum", lib_gameControlToKeyNum}, + {"gameControl2ToKeyNum", lib_gameControl2ToKeyNum}, + {"joyAxis", lib_joyAxis}, + {"joy2Axis", lib_joy2Axis}, + {"keyNumToString", lib_keyNumToString}, + {"keyStringToNum", lib_keyStringToNum}, + {"keyNumPrintable", lib_keyNumPrintable}, + {"shiftKeyNum", lib_shiftKeyNum}, + {"getMouseGrab", lib_getMouseGrab}, + {"setMouseGrab", lib_setMouseGrab}, + {"getCursorPosition", lib_getCursorPosition}, {NULL, NULL} }; @@ -235,8 +235,6 @@ int LUA_InputLib(lua_State *L) lua_setfield(L, -2, "__len"); lua_pop(L, 1); - // Set global functions - lua_pushvalue(L, LUA_GLOBALSINDEX); - luaL_register(L, NULL, lib); + luaL_register(L, "input", lib); return 0; } From 38e82e55fcf39ccd0e4d2316839e502958ba76cf Mon Sep 17 00:00:00 2001 From: LJ Sonic Date: Sat, 14 Aug 2021 20:33:20 +0200 Subject: [PATCH 0899/1080] Add a "repeated" field to event_t --- src/d_event.h | 1 + src/sdl/i_system.c | 4 ++-- src/sdl/i_video.c | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/d_event.h b/src/d_event.h index 1fd2e3824..70b55c328 100644 --- a/src/d_event.h +++ b/src/d_event.h @@ -36,6 +36,7 @@ typedef struct INT32 data1; // keys / mouse/joystick buttons INT32 data2; // mouse/joystick x move INT32 data3; // mouse/joystick y move + boolean repeated; // key repeat } event_t; // diff --git a/src/sdl/i_system.c b/src/sdl/i_system.c index d68e3e435..1594c8d61 100644 --- a/src/sdl/i_system.c +++ b/src/sdl/i_system.c @@ -1012,7 +1012,7 @@ void I_ShutdownJoystick(void) void I_GetJoystickEvents(void) { - static event_t event = {0,0,0,0}; + static event_t event = {0,0,0,0,false}; INT32 i = 0; UINT64 joyhats = 0; #if 0 @@ -1282,7 +1282,7 @@ void I_ShutdownJoystick2(void) void I_GetJoystick2Events(void) { - static event_t event = {0,0,0,0}; + static event_t event = {0,0,0,0,false}; INT32 i = 0; UINT64 joyhats = 0; #if 0 diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index 819589eaf..1f4b866c1 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -664,6 +664,7 @@ static void Impl_HandleKeyboardEvent(SDL_KeyboardEvent evt, Uint32 type) return; } event.data1 = Impl_SDL_Scancode_To_Keycode(evt.keysym.scancode); + event.repeated = (evt.repeat != 0); if (event.data1) D_PostEvent(&event); } From 5b949a6751c34a939a3aa6cef3cdb7d0dfc2f181 Mon Sep 17 00:00:00 2001 From: LJ Sonic Date: Sat, 14 Aug 2021 20:33:42 +0200 Subject: [PATCH 0900/1080] Expose keyevent_t to Lua --- src/lua_inputlib.c | 28 ++++++++++++++++++++++++++++ src/lua_libs.h | 1 + 2 files changed, 29 insertions(+) diff --git a/src/lua_inputlib.c b/src/lua_inputlib.c index 7ad265eff..01ad9af3c 100644 --- a/src/lua_inputlib.c +++ b/src/lua_inputlib.c @@ -172,6 +172,29 @@ static int lib_lenGameKeyDown(lua_State *L) return 1; } +/////////////// +// KEY EVENT // +/////////////// + +static int keyevent_get(lua_State *L) +{ + event_t *event = *((event_t **)luaL_checkudata(L, 1, META_KEYEVENT)); + const char *field = luaL_checkstring(L, 2); + + I_Assert(event != NULL); + + if (fastcmp(field,"name")) + lua_pushstring(L, G_KeyNumToString(event->data1)); + else if (fastcmp(field,"num")) + lua_pushinteger(L, event->data1); + else if (fastcmp(field,"repeated")) + lua_pushboolean(L, event->repeated); + else + return luaL_error(L, "keyevent_t has no field named %s", field); + + return 1; +} + /////////// // MOUSE // /////////// @@ -227,6 +250,11 @@ int LUA_InputLib(lua_State *L) lua_setmetatable(L, -2); lua_setglobal(L, "gamekeydown"); + luaL_newmetatable(L, META_KEYEVENT); + lua_pushcfunction(L, keyevent_get); + lua_setfield(L, -2, "__index"); + lua_pop(L, 1); + luaL_newmetatable(L, META_MOUSE); lua_pushcfunction(L, mouse_get); lua_setfield(L, -2, "__index"); diff --git a/src/lua_libs.h b/src/lua_libs.h index 668eb99b0..de174283c 100644 --- a/src/lua_libs.h +++ b/src/lua_libs.h @@ -88,6 +88,7 @@ extern lua_State *gL; #define META_LUABANKS "LUABANKS[]*" +#define META_KEYEVENT "KEYEVENT_T*" #define META_MOUSE "MOUSE_T*" boolean luaL_checkboolean(lua_State *L, int narg); From c2907b89f703a4e09cf236907b9be28c28242b54 Mon Sep 17 00:00:00 2001 From: LJ Sonic Date: Sat, 14 Aug 2021 20:34:59 +0200 Subject: [PATCH 0901/1080] Pass a keyevent_t userdatum to key hooks --- src/g_game.c | 18 +++++++++++++++--- src/lua_hook.h | 3 ++- src/lua_hooklib.c | 4 ++-- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index 13fdab877..a35d89aa1 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -45,6 +45,7 @@ #include "lua_hook.h" #include "b_bot.h" #include "m_cond.h" // condition sets +#include "lua_script.h" #include "lua_hud.h" @@ -2194,8 +2195,20 @@ boolean G_Responder(event_t *ev) // boolean G_LuaResponder(event_t *ev) { - return (ev->type == ev_keydown && LUA_HookKey(ev->data1, HOOK(KeyDown))) || - (ev->type == ev_keyup && LUA_HookKey(ev->data1, HOOK(KeyUp))); + boolean cancelled = false; + + if (ev->type == ev_keydown) + { + cancelled = LUA_HookKey(ev, HOOK(KeyDown)); + LUA_InvalidateUserdata(ev); + } + else if (ev->type == ev_keyup) + { + cancelled = LUA_HookKey(ev, HOOK(KeyUp)); + LUA_InvalidateUserdata(ev); + } + + return cancelled; } // @@ -5240,4 +5253,3 @@ INT32 G_TicsToMilliseconds(tic_t tics) { return (INT32)((tics%TICRATE) * (1000.00f/TICRATE)); } - diff --git a/src/lua_hook.h b/src/lua_hook.h index 223b83c61..55f3bb817 100644 --- a/src/lua_hook.h +++ b/src/lua_hook.h @@ -13,6 +13,7 @@ #include "r_defs.h" #include "d_player.h" #include "s_sound.h" +#include "d_event.h" /* Do you know what an 'X Macro' is? Such a macro is called over each element of @@ -107,7 +108,7 @@ void LUA_HookInt(INT32 integer, int hook); void LUA_HookBool(boolean value, int hook); int LUA_HookPlayer(player_t *, int hook); int LUA_HookTiccmd(player_t *, ticcmd_t *, int hook); -int LUA_HookKey(INT32 keycode, int hook); // Hooks for key events +int LUA_HookKey(event_t *event, int hook); // Hooks for key events void LUA_HookThinkFrame(void); int LUA_HookMobjLineCollide(mobj_t *, line_t *); diff --git a/src/lua_hooklib.c b/src/lua_hooklib.c index d1b0d3bdd..1e0462126 100644 --- a/src/lua_hooklib.c +++ b/src/lua_hooklib.c @@ -588,12 +588,12 @@ int LUA_HookTiccmd(player_t *player, ticcmd_t *cmd, int hook_type) return hook.status; } -int LUA_HookKey(INT32 keycode, int hook_type) +int LUA_HookKey(event_t *event, int hook_type) { Hook_State hook; if (prepare_hook(&hook, false, hook_type)) { - lua_pushinteger(gL, keycode); + LUA_PushUserdata(gL, event, META_KEYEVENT); call_hooks(&hook, 1, 1, res_true); } return hook.status; From 5bc0ce7a62c816e33e6d2a7ddc4b4b1360fd9df4 Mon Sep 17 00:00:00 2001 From: LJ Sonic Date: Sat, 14 Aug 2021 23:42:39 +0200 Subject: [PATCH 0902/1080] Give fields in event_t better names --- src/am_map.c | 6 +- src/console.c | 4 +- src/d_event.h | 6 +- src/d_main.c | 14 +-- src/f_finale.c | 6 +- src/g_game.c | 20 ++--- src/g_input.c | 32 +++---- src/hu_stuff.c | 18 ++-- src/lua_inputlib.c | 4 +- src/m_cheat.c | 6 +- src/m_menu.c | 34 ++++---- src/m_misc.c | 2 +- src/sdl/i_system.c | 108 +++++++++++------------ src/sdl/i_video.c | 46 +++++----- src/win32/win_main.c | 24 ++--- src/win32/win_sys.c | 202 +++++++++++++++++++++---------------------- 16 files changed, 266 insertions(+), 266 deletions(-) diff --git a/src/am_map.c b/src/am_map.c index ef0ebb88c..24379e2f1 100644 --- a/src/am_map.c +++ b/src/am_map.c @@ -458,7 +458,7 @@ boolean AM_Responder(event_t *ev) { if (!automapactive) { - if (ev->type == ev_keydown && ev->data1 == AM_TOGGLEKEY) + if (ev->type == ev_keydown && ev->key == AM_TOGGLEKEY) { //faB: prevent alt-tab in win32 version to activate automap just before // minimizing the app; doesn't do any harm to the DOS version @@ -473,7 +473,7 @@ boolean AM_Responder(event_t *ev) else if (ev->type == ev_keydown) { rc = true; - switch (ev->data1) + switch (ev->key) { case AM_PANRIGHTKEY: // pan right if (!followplayer) @@ -550,7 +550,7 @@ boolean AM_Responder(event_t *ev) else if (ev->type == ev_keyup) { rc = false; - switch (ev->data1) + switch (ev->key) { case AM_PANRIGHTKEY: if (!followplayer) diff --git a/src/console.c b/src/console.c index b3c413840..7941e1dbb 100644 --- a/src/console.c +++ b/src/console.c @@ -913,12 +913,12 @@ boolean CON_Responder(event_t *ev) // let go keyup events, don't eat them if (ev->type != ev_keydown && ev->type != ev_console) { - if (ev->data1 == gamecontrol[gc_console][0] || ev->data1 == gamecontrol[gc_console][1]) + if (ev->key == gamecontrol[gc_console][0] || ev->key == gamecontrol[gc_console][1]) consdown = false; return false; } - key = ev->data1; + key = ev->key; // check for console toggle key if (ev->type != ev_console) diff --git a/src/d_event.h b/src/d_event.h index 70b55c328..c30a8ced2 100644 --- a/src/d_event.h +++ b/src/d_event.h @@ -33,9 +33,9 @@ typedef enum typedef struct { evtype_t type; - INT32 data1; // keys / mouse/joystick buttons - INT32 data2; // mouse/joystick x move - INT32 data3; // mouse/joystick y move + INT32 key; // keys/mouse/joystick buttons + INT32 x; // mouse/joystick x move + INT32 y; // mouse/joystick y move boolean repeated; // key repeat } event_t; diff --git a/src/d_main.c b/src/d_main.c index 1b3449ec1..5acb9073f 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -191,22 +191,22 @@ void D_ProcessEvents(void) if (ev->type == ev_keydown || ev->type == ev_keyup) { // Mouse buttons - if ((UINT32)(ev->data1 - KEY_MOUSE1) < MOUSEBUTTONS) + if ((UINT32)(ev->key - KEY_MOUSE1) < MOUSEBUTTONS) { if (ev->type == ev_keydown) - mouse.buttons |= 1 << (ev->data1 - KEY_MOUSE1); + mouse.buttons |= 1 << (ev->key - KEY_MOUSE1); else - mouse.buttons &= ~(1 << (ev->data1 - KEY_MOUSE1)); + mouse.buttons &= ~(1 << (ev->key - KEY_MOUSE1)); } - else if ((UINT32)(ev->data1 - KEY_2MOUSE1) < MOUSEBUTTONS) + else if ((UINT32)(ev->key - KEY_2MOUSE1) < MOUSEBUTTONS) { if (ev->type == ev_keydown) - mouse2.buttons |= 1 << (ev->data1 - KEY_2MOUSE1); + mouse2.buttons |= 1 << (ev->key - KEY_2MOUSE1); else - mouse2.buttons &= ~(1 << (ev->data1 - KEY_2MOUSE1)); + mouse2.buttons &= ~(1 << (ev->key - KEY_2MOUSE1)); } // Scroll (has no keyup event) - else switch (ev->data1) { + else switch (ev->key) { case KEY_MOUSEWHEELUP: mouse.buttons |= MB_SCROLLUP; break; diff --git a/src/f_finale.c b/src/f_finale.c index 4d9a8f825..4887b11a4 100644 --- a/src/f_finale.c +++ b/src/f_finale.c @@ -1011,7 +1011,7 @@ void F_IntroTicker(void) // boolean F_IntroResponder(event_t *event) { - INT32 key = event->data1; + INT32 key = event->key; // remap virtual keys (mouse & joystick buttons) switch (key) @@ -1397,7 +1397,7 @@ void F_CreditTicker(void) boolean F_CreditResponder(event_t *event) { - INT32 key = event->data1; + INT32 key = event->key; // remap virtual keys (mouse & joystick buttons) switch (key) @@ -3821,7 +3821,7 @@ void F_ContinueTicker(void) boolean F_ContinueResponder(event_t *event) { - INT32 key = event->data1; + INT32 key = event->key; if (keypressed) return true; diff --git a/src/g_game.c b/src/g_game.c index a35d89aa1..5c89bcae8 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1969,7 +1969,7 @@ boolean G_Responder(event_t *ev) if (gameaction == ga_nothing && !singledemo && ((demoplayback && !modeattacking && !titledemo) || gamestate == GS_TITLESCREEN)) { - if (ev->type == ev_keydown && ev->data1 != 301 && !(gamestate == GS_TITLESCREEN && finalecount < TICRATE)) + if (ev->type == ev_keydown && ev->key != 301 && !(gamestate == GS_TITLESCREEN && finalecount < TICRATE)) { M_StartControlPanel(); return true; @@ -2045,7 +2045,7 @@ boolean G_Responder(event_t *ev) // allow spy mode changes even during the demo if (gamestate == GS_LEVEL && ev->type == ev_keydown - && (ev->data1 == KEY_F12 || ev->data1 == gamecontrol[gc_viewpoint][0] || ev->data1 == gamecontrol[gc_viewpoint][1])) + && (ev->key == KEY_F12 || ev->key == gamecontrol[gc_viewpoint][0] || ev->key == gamecontrol[gc_viewpoint][1])) { // ViewpointSwitch Lua hook. UINT8 canSwitchView = 0; @@ -2118,13 +2118,13 @@ boolean G_Responder(event_t *ev) switch (ev->type) { case ev_keydown: - if (ev->data1 == gamecontrol[gc_pause][0] - || ev->data1 == gamecontrol[gc_pause][1] - || ev->data1 == KEY_PAUSE) + if (ev->key == gamecontrol[gc_pause][0] + || ev->key == gamecontrol[gc_pause][1] + || ev->key == KEY_PAUSE) { if (modeattacking && !demoplayback && (gamestate == GS_LEVEL)) { - pausebreakkey = (ev->data1 == KEY_PAUSE); + pausebreakkey = (ev->key == KEY_PAUSE); if (menuactive || pausedelay < 0 || leveltime < 2) return true; @@ -2149,8 +2149,8 @@ boolean G_Responder(event_t *ev) } } } - if (ev->data1 == gamecontrol[gc_camtoggle][0] - || ev->data1 == gamecontrol[gc_camtoggle][1]) + if (ev->key == gamecontrol[gc_camtoggle][0] + || ev->key == gamecontrol[gc_camtoggle][1]) { if (!camtoggledelay) { @@ -2158,8 +2158,8 @@ boolean G_Responder(event_t *ev) CV_SetValue(&cv_chasecam, cv_chasecam.value ? 0 : 1); } } - if (ev->data1 == gamecontrolbis[gc_camtoggle][0] - || ev->data1 == gamecontrolbis[gc_camtoggle][1]) + if (ev->key == gamecontrolbis[gc_camtoggle][0] + || ev->key == gamecontrolbis[gc_camtoggle][1]) { if (!camtoggledelay2) { diff --git a/src/g_input.c b/src/g_input.c index 2f7980c64..e0a27d1ca 100644 --- a/src/g_input.c +++ b/src/g_input.c @@ -115,54 +115,54 @@ void G_MapEventsToControls(event_t *ev) switch (ev->type) { case ev_keydown: - if (ev->data1 < NUMINPUTS) - gamekeydown[ev->data1] = 1; + if (ev->key < NUMINPUTS) + gamekeydown[ev->key] = 1; #ifdef PARANOIA else { - CONS_Debug(DBG_GAMELOGIC, "Bad downkey input %d\n",ev->data1); + CONS_Debug(DBG_GAMELOGIC, "Bad downkey input %d\n",ev->key); } #endif break; case ev_keyup: - if (ev->data1 < NUMINPUTS) - gamekeydown[ev->data1] = 0; + if (ev->key < NUMINPUTS) + gamekeydown[ev->key] = 0; #ifdef PARANOIA else { - CONS_Debug(DBG_GAMELOGIC, "Bad upkey input %d\n",ev->data1); + CONS_Debug(DBG_GAMELOGIC, "Bad upkey input %d\n",ev->key); } #endif break; case ev_mouse: // buttons are virtual keys - mouse.rdx = ev->data2; - mouse.rdy = ev->data3; + mouse.rdx = ev->x; + mouse.rdy = ev->y; break; case ev_joystick: // buttons are virtual keys - i = ev->data1; + i = ev->key; if (i >= JOYAXISSET || menuactive || CON_Ready() || chat_on) break; - if (ev->data2 != INT32_MAX) joyxmove[i] = ev->data2; - if (ev->data3 != INT32_MAX) joyymove[i] = ev->data3; + if (ev->x != INT32_MAX) joyxmove[i] = ev->x; + if (ev->y != INT32_MAX) joyymove[i] = ev->y; break; case ev_joystick2: // buttons are virtual keys - i = ev->data1; + i = ev->key; if (i >= JOYAXISSET || menuactive || CON_Ready() || chat_on) break; - if (ev->data2 != INT32_MAX) joy2xmove[i] = ev->data2; - if (ev->data3 != INT32_MAX) joy2ymove[i] = ev->data3; + if (ev->x != INT32_MAX) joy2xmove[i] = ev->x; + if (ev->y != INT32_MAX) joy2ymove[i] = ev->y; break; case ev_mouse2: // buttons are virtual keys if (menuactive || CON_Ready() || chat_on) break; - mouse2.rdx = ev->data2; - mouse2.rdy = ev->data3; + mouse2.rdx = ev->x; + mouse2.rdy = ev->y; break; default: diff --git a/src/hu_stuff.c b/src/hu_stuff.c index e0eaf8fb1..3bd263210 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -1111,12 +1111,12 @@ boolean HU_Responder(event_t *ev) // (Unless if you're sharing a keyboard, since you probably establish when you start chatting that you have dibs on it...) // (Ahhh, the good ol days when I was a kid who couldn't afford an extra USB controller...) - if (ev->data1 >= KEY_MOUSE1) + if (ev->key >= KEY_MOUSE1) { INT32 i; for (i = 0; i < num_gamecontrols; i++) { - if (gamecontrol[i][0] == ev->data1 || gamecontrol[i][1] == ev->data1) + if (gamecontrol[i][0] == ev->key || gamecontrol[i][1] == ev->key) break; } @@ -1125,12 +1125,12 @@ boolean HU_Responder(event_t *ev) }*/ //We don't actually care about that unless we get splitscreen netgames. :V #ifndef NONET - c = (INT32)ev->data1; + c = (INT32)ev->key; if (!chat_on) { // enter chat mode - if ((ev->data1 == gamecontrol[gc_talkkey][0] || ev->data1 == gamecontrol[gc_talkkey][1]) + if ((ev->key == gamecontrol[gc_talkkey][0] || ev->key == gamecontrol[gc_talkkey][1]) && netgame && !OLD_MUTE) // check for old chat mute, still let the players open the chat incase they want to scroll otherwise. { chat_on = true; @@ -1140,7 +1140,7 @@ boolean HU_Responder(event_t *ev) typelines = 1; return true; } - if ((ev->data1 == gamecontrol[gc_teamkey][0] || ev->data1 == gamecontrol[gc_teamkey][1]) + if ((ev->key == gamecontrol[gc_teamkey][0] || ev->key == gamecontrol[gc_teamkey][1]) && netgame && !OLD_MUTE) { chat_on = true; @@ -1157,12 +1157,12 @@ boolean HU_Responder(event_t *ev) // Ignore modifier keys // Note that we do this here so users can still set // their chat keys to one of these, if they so desire. - if (ev->data1 == KEY_LSHIFT || ev->data1 == KEY_RSHIFT - || ev->data1 == KEY_LCTRL || ev->data1 == KEY_RCTRL - || ev->data1 == KEY_LALT || ev->data1 == KEY_RALT) + if (ev->key == KEY_LSHIFT || ev->key == KEY_RSHIFT + || ev->key == KEY_LCTRL || ev->key == KEY_RCTRL + || ev->key == KEY_LALT || ev->key == KEY_RALT) return true; - c = (INT32)ev->data1; + c = (INT32)ev->key; // I know this looks very messy but this works. If it ain't broke, don't fix it! // shift LETTERS to uppercase if we have capslock or are holding shift diff --git a/src/lua_inputlib.c b/src/lua_inputlib.c index 01ad9af3c..01383a57b 100644 --- a/src/lua_inputlib.c +++ b/src/lua_inputlib.c @@ -184,9 +184,9 @@ static int keyevent_get(lua_State *L) I_Assert(event != NULL); if (fastcmp(field,"name")) - lua_pushstring(L, G_KeyNumToString(event->data1)); + lua_pushstring(L, G_KeyNumToString(event->key)); else if (fastcmp(field,"num")) - lua_pushinteger(L, event->data1); + lua_pushinteger(L, event->key); else if (fastcmp(field,"repeated")) lua_pushboolean(L, event->repeated); else diff --git a/src/m_cheat.c b/src/m_cheat.c index c958bb4a4..ef896c991 100644 --- a/src/m_cheat.c +++ b/src/m_cheat.c @@ -203,11 +203,11 @@ boolean cht_Responder(event_t *ev) if (ev->type != ev_keydown) return false; - if (ev->data1 > 0xFF) + if (ev->key > 0xFF) { // map some fake (joy) inputs into keys // map joy inputs into keys - switch (ev->data1) + switch (ev->key) { case KEY_JOY1: case KEY_JOY1 + 2: @@ -231,7 +231,7 @@ boolean cht_Responder(event_t *ev) } } else - ch = (UINT8)ev->data1; + ch = (UINT8)ev->key; ret += cht_CheckCheat(&cheat_ultimate, (char)ch); ret += cht_CheckCheat(&cheat_ultimate_joy, (char)ch); diff --git a/src/m_menu.c b/src/m_menu.c index db2aa09c6..92754705b 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -3229,7 +3229,7 @@ boolean M_Responder(event_t *ev) if (ev->type == ev_keydown) { keydown++; - ch = ev->data1; + ch = ev->key; // added 5-2-98 remap virtual keys (mouse & joystick buttons) switch (ch) @@ -3262,44 +3262,44 @@ boolean M_Responder(event_t *ev) break; } } - else if (ev->type == ev_joystick && ev->data1 == 0 && joywait < I_GetTime()) + else if (ev->type == ev_joystick && ev->key == 0 && joywait < I_GetTime()) { const INT32 jdeadzone = (JOYAXISRANGE * cv_digitaldeadzone.value) / FRACUNIT; - if (ev->data3 != INT32_MAX) + if (ev->y != INT32_MAX) { - if (Joystick.bGamepadStyle || abs(ev->data3) > jdeadzone) + if (Joystick.bGamepadStyle || abs(ev->y) > jdeadzone) { - if (ev->data3 < 0 && pjoyy >= 0) + if (ev->y < 0 && pjoyy >= 0) { ch = KEY_UPARROW; joywait = I_GetTime() + NEWTICRATE/7; } - else if (ev->data3 > 0 && pjoyy <= 0) + else if (ev->y > 0 && pjoyy <= 0) { ch = KEY_DOWNARROW; joywait = I_GetTime() + NEWTICRATE/7; } - pjoyy = ev->data3; + pjoyy = ev->y; } else pjoyy = 0; } - if (ev->data2 != INT32_MAX) + if (ev->x != INT32_MAX) { - if (Joystick.bGamepadStyle || abs(ev->data2) > jdeadzone) + if (Joystick.bGamepadStyle || abs(ev->x) > jdeadzone) { - if (ev->data2 < 0 && pjoyx >= 0) + if (ev->x < 0 && pjoyx >= 0) { ch = KEY_LEFTARROW; joywait = I_GetTime() + NEWTICRATE/17; } - else if (ev->data2 > 0 && pjoyx <= 0) + else if (ev->x > 0 && pjoyx <= 0) { ch = KEY_RIGHTARROW; joywait = I_GetTime() + NEWTICRATE/17; } - pjoyx = ev->data2; + pjoyx = ev->x; } else pjoyx = 0; @@ -3307,7 +3307,7 @@ boolean M_Responder(event_t *ev) } else if (ev->type == ev_mouse && mousewait < I_GetTime()) { - pmousey -= ev->data3; + pmousey -= ev->y; if (pmousey < lasty-30) { ch = KEY_DOWNARROW; @@ -3321,7 +3321,7 @@ boolean M_Responder(event_t *ev) pmousey = lasty += 30; } - pmousex += ev->data2; + pmousex += ev->x; if (pmousex < lastx - 30) { ch = KEY_LEFTARROW; @@ -3339,7 +3339,7 @@ boolean M_Responder(event_t *ev) keydown = 0; } else if (ev->type == ev_keydown) // Preserve event for other responders - ch = ev->data1; + ch = ev->key; if (ch == -1) return false; @@ -12859,7 +12859,7 @@ static void M_ChangecontrolResponse(event_t *ev) { INT32 control; INT32 found; - INT32 ch = ev->data1; + INT32 ch = ev->key; // ESCAPE cancels; dummy out PAUSE if (ch != KEY_ESCAPE && ch != KEY_PAUSE) @@ -12878,7 +12878,7 @@ static void M_ChangecontrolResponse(event_t *ev) // keypad arrows are converted for the menu in cursor arrows // so use the event instead of ch case ev_keydown: - ch = ev->data1; + ch = ev->key; break; default: diff --git a/src/m_misc.c b/src/m_misc.c index ac60d49c7..f9a23ad44 100644 --- a/src/m_misc.c +++ b/src/m_misc.c @@ -1631,7 +1631,7 @@ boolean M_ScreenshotResponder(event_t *ev) if (dedicated || ev->type != ev_keydown) return false; - ch = ev->data1; + ch = ev->key; if (ch >= KEY_MOUSE1 && menuactive) // If it's not a keyboard key, then don't allow it in the menus! return false; diff --git a/src/sdl/i_system.c b/src/sdl/i_system.c index 1594c8d61..a3908c570 100644 --- a/src/sdl/i_system.c +++ b/src/sdl/i_system.c @@ -572,7 +572,7 @@ void I_GetConsoleEvents(void) tty_con.buffer[tty_con.cursor] = '\0'; tty_Back(); } - ev.data1 = KEY_BACKSPACE; + ev.key = KEY_BACKSPACE; } else if (key < ' ') // check if this is a control char { @@ -580,19 +580,19 @@ void I_GetConsoleEvents(void) { tty_Clear(); tty_con.cursor = 0; - ev.data1 = KEY_ENTER; + ev.key = KEY_ENTER; } else return; } else { // push regular character - ev.data1 = tty_con.buffer[tty_con.cursor] = key; + ev.key = tty_con.buffer[tty_con.cursor] = key; tty_con.cursor++; // print the current line (this is differential) d = write(STDOUT_FILENO, &key, 1); } - if (ev.data1) D_PostEvent(&ev); + if (ev.key) D_PostEvent(&ev); //tty_FlushIn(); (void)d; } @@ -626,18 +626,18 @@ static void Impl_HandleKeyboardConsoleEvent(KEY_EVENT_RECORD evt, HANDLE co) { case VK_ESCAPE: case VK_TAB: - event.data1 = KEY_NULL; + event.key = KEY_NULL; break; case VK_RETURN: entering_con_command = false; /* FALLTHRU */ default: - //event.data1 = MapVirtualKey(evt.wVirtualKeyCode,2); // convert in to char - event.data1 = evt.uChar.AsciiChar; + //event.key = MapVirtualKey(evt.wVirtualKeyCode,2); // convert in to char + event.key = evt.uChar.AsciiChar; } if (co != INVALID_HANDLE_VALUE && GetFileType(co) == FILE_TYPE_CHAR && GetConsoleMode(co, &t)) { - if (event.data1 && event.data1 != KEY_LSHIFT && event.data1 != KEY_RSHIFT) + if (event.key && event.key != KEY_LSHIFT && event.key != KEY_RSHIFT) { #ifdef _UNICODE WriteConsole(co, &evt.uChar.UnicodeChar, 1, &t, NULL); @@ -652,7 +652,7 @@ static void Impl_HandleKeyboardConsoleEvent(KEY_EVENT_RECORD evt, HANDLE co) } } } - if (event.data1) D_PostEvent(&event); + if (event.key) D_PostEvent(&event); } void I_GetConsoleEvents(void) @@ -917,7 +917,7 @@ INT32 I_GetKey (void) ev = &events[eventtail]; if (ev->type == ev_keydown || ev->type == ev_console) { - rc = ev->data1; + rc = ev->key; continue; } } @@ -977,22 +977,22 @@ void I_ShutdownJoystick(void) INT32 i; event_t event; event.type=ev_keyup; - event.data2 = 0; - event.data3 = 0; + event.x = 0; + event.y = 0; lastjoybuttons = lastjoyhats = 0; // emulate the up of all joystick buttons for (i=0;i= 0; i--) { - event.data1 = i; + event.key = i; if (i*2 + 1 <= JoyInfo.axises) axisx = SDL_JoystickGetAxis(JoyInfo.dev, i*2 + 0); else axisx = 0; @@ -1110,15 +1110,15 @@ void I_GetJoystickEvents(void) { // gamepad control type, on or off, live or die if (axisx < -(JOYAXISRANGE/2)) - event.data2 = -1; + event.x = -1; else if (axisx > (JOYAXISRANGE/2)) - event.data2 = 1; - else event.data2 = 0; + event.x = 1; + else event.x = 0; if (axisy < -(JOYAXISRANGE/2)) - event.data3 = -1; + event.y = -1; else if (axisy > (JOYAXISRANGE/2)) - event.data3 = 1; - else event.data3 = 0; + event.y = 1; + else event.y = 0; } else { @@ -1132,8 +1132,8 @@ void I_GetJoystickEvents(void) #endif // analog control style , just send the raw data - event.data2 = axisx; // x axis - event.data3 = axisy; // y axis + event.x = axisx; // x axis + event.y = axisy; // y axis } D_PostEvent(&event); } @@ -1247,22 +1247,22 @@ void I_ShutdownJoystick2(void) INT32 i; event_t event; event.type = ev_keyup; - event.data2 = 0; - event.data3 = 0; + event.x = 0; + event.y = 0; lastjoy2buttons = lastjoy2hats = 0; // emulate the up of all joystick buttons for (i = 0; i < JOYBUTTONS; i++) { - event.data1 = KEY_2JOY1 + i; + event.key = KEY_2JOY1 + i; D_PostEvent(&event); } // emulate the up of all joystick hats for (i = 0; i < JOYHATS*4; i++) { - event.data1 = KEY_2HAT1 + i; + event.key = KEY_2HAT1 + i; D_PostEvent(&event); } @@ -1270,7 +1270,7 @@ void I_ShutdownJoystick2(void) event.type = ev_joystick2; for (i = 0; i < JOYAXISSET; i++) { - event.data1 = i; + event.key = i; D_PostEvent(&event); } @@ -1321,7 +1321,7 @@ void I_GetJoystick2Events(void) event.type = ev_keydown; else event.type = ev_keyup; - event.data1 = KEY_2JOY1 + i; + event.key = KEY_2JOY1 + i; D_PostEvent(&event); } } @@ -1352,7 +1352,7 @@ void I_GetJoystick2Events(void) event.type = ev_keydown; else event.type = ev_keyup; - event.data1 = KEY_2HAT1 + i; + event.key = KEY_2HAT1 + i; D_PostEvent(&event); } } @@ -1364,7 +1364,7 @@ void I_GetJoystick2Events(void) for (i = JOYAXISSET - 1; i >= 0; i--) { - event.data1 = i; + event.key = i; if (i*2 + 1 <= JoyInfo2.axises) axisx = SDL_JoystickGetAxis(JoyInfo2.dev, i*2 + 0); else axisx = 0; @@ -1380,17 +1380,17 @@ void I_GetJoystick2Events(void) { // gamepad control type, on or off, live or die if (axisx < -(JOYAXISRANGE/2)) - event.data2 = -1; + event.x = -1; else if (axisx > (JOYAXISRANGE/2)) - event.data2 = 1; + event.x = 1; else - event.data2 = 0; + event.x = 0; if (axisy < -(JOYAXISRANGE/2)) - event.data3 = -1; + event.y = -1; else if (axisy > (JOYAXISRANGE/2)) - event.data3 = 1; + event.y = 1; else - event.data3 = 0; + event.y = 0; } else { @@ -1404,8 +1404,8 @@ void I_GetJoystick2Events(void) #endif // analog control style , just send the raw data - event.data2 = axisx; // x axis - event.data3 = axisy; // y axis + event.x = axisx; // x axis + event.y = axisy; // y axis } D_PostEvent(&event); } @@ -1804,7 +1804,7 @@ void I_GetMouseEvents(void) if (!(button & (1< 0) { - event.data1 = KEY_MOUSEWHEELUP; + event.key = KEY_MOUSEWHEELUP; event.type = ev_keydown; } if (evt.y < 0) { - event.data1 = KEY_MOUSEWHEELDOWN; + event.key = KEY_MOUSEWHEELDOWN; event.type = ev_keydown; } if (evt.y == 0) { - event.data1 = 0; + event.key = 0; event.type = ev_keyup; } if (event.type == ev_keyup || event.type == ev_keydown) @@ -796,7 +796,7 @@ static void Impl_HandleJoystickAxisEvent(SDL_JoyAxisEvent evt) joyid[1] = SDL_JoystickInstanceID(JoyInfo2.dev); evt.axis++; - event.data1 = event.data2 = event.data3 = INT32_MAX; + event.key = event.x = event.y = INT32_MAX; if (evt.which == joyid[0]) { @@ -813,14 +813,14 @@ static void Impl_HandleJoystickAxisEvent(SDL_JoyAxisEvent evt) //vaule if (evt.axis%2) { - event.data1 = evt.axis / 2; - event.data2 = SDLJoyAxis(evt.value, event.type); + event.key = evt.axis / 2; + event.x = SDLJoyAxis(evt.value, event.type); } else { evt.axis--; - event.data1 = evt.axis / 2; - event.data3 = SDLJoyAxis(evt.value, event.type); + event.key = evt.axis / 2; + event.y = SDLJoyAxis(evt.value, event.type); } D_PostEvent(&event); } @@ -840,11 +840,11 @@ static void Impl_HandleJoystickHatEvent(SDL_JoyHatEvent evt) if (evt.which == joyid[0]) { - event.data1 = KEY_HAT1 + (evt.hat*4); + event.key = KEY_HAT1 + (evt.hat*4); } else if (evt.which == joyid[1]) { - event.data1 = KEY_2HAT1 + (evt.hat*4); + event.key = KEY_2HAT1 + (evt.hat*4); } else return; @@ -863,11 +863,11 @@ static void Impl_HandleJoystickButtonEvent(SDL_JoyButtonEvent evt, Uint32 type) if (evt.which == joyid[0]) { - event.data1 = KEY_JOY1; + event.key = KEY_JOY1; } else if (evt.which == joyid[1]) { - event.data1 = KEY_2JOY1; + event.key = KEY_2JOY1; } else return; if (type == SDL_JOYBUTTONUP) @@ -881,7 +881,7 @@ static void Impl_HandleJoystickButtonEvent(SDL_JoyButtonEvent evt, Uint32 type) else return; if (evt.button < JOYBUTTONS) { - event.data1 += evt.button; + event.key += evt.button; } else return; @@ -1085,9 +1085,9 @@ void I_GetEvent(void) SDL_GetWindowSize(window, &wwidth, &wheight); //SDL_memset(&event, 0, sizeof(event_t)); 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.key = 0; + event.x = (INT32)lround(mousemovex * ((float)wwidth / (float)realwidth)); + event.y = (INT32)lround(mousemovey * ((float)wheight / (float)realheight)); D_PostEvent(&event); } diff --git a/src/win32/win_main.c b/src/win32/win_main.c index e1d90881b..a5ebf3211 100644 --- a/src/win32/win_main.c +++ b/src/win32/win_main.c @@ -188,11 +188,11 @@ static LRESULT CALLBACK MainWndproc(HWND hWnd, UINT message, WPARAM wParam, LPAR ev.type = ev_keydown; handleKeyDoom: - ev.data1 = 0; + ev.key = 0; if (wParam == VK_PAUSE) // intercept PAUSE key { - ev.data1 = KEY_PAUSE; + ev.key = KEY_PAUSE; } else if (!keyboard_started) // post some keys during the game startup @@ -201,14 +201,14 @@ static LRESULT CALLBACK MainWndproc(HWND hWnd, UINT message, WPARAM wParam, LPAR { switch (wParam) { - case VK_ESCAPE: ev.data1 = KEY_ESCAPE; break; - case VK_RETURN: ev.data1 = KEY_ENTER; break; - case VK_SHIFT: ev.data1 = KEY_LSHIFT; break; - default: ev.data1 = MapVirtualKey((DWORD)wParam,2); // convert in to char + case VK_ESCAPE: ev.key = KEY_ESCAPE; break; + case VK_RETURN: ev.key = KEY_ENTER; break; + case VK_SHIFT: ev.key = KEY_LSHIFT; break; + default: ev.key = MapVirtualKey((DWORD)wParam,2); // convert in to char } } - if (ev.data1) + if (ev.key) D_PostEvent (&ev); return 0; @@ -240,7 +240,7 @@ static LRESULT CALLBACK MainWndproc(HWND hWnd, UINT message, WPARAM wParam, LPAR if (nodinput) { ev.type = ev_keyup; - ev.data1 = KEY_MOUSE1 + 3 + HIWORD(wParam); + ev.key = KEY_MOUSE1 + 3 + HIWORD(wParam); D_PostEvent(&ev); return TRUE; } @@ -249,7 +249,7 @@ static LRESULT CALLBACK MainWndproc(HWND hWnd, UINT message, WPARAM wParam, LPAR if (nodinput) { ev.type = ev_keydown; - ev.data1 = KEY_MOUSE1 + 3 + HIWORD(wParam); + ev.key = KEY_MOUSE1 + 3 + HIWORD(wParam); D_PostEvent(&ev); return TRUE; } @@ -258,9 +258,9 @@ static LRESULT CALLBACK MainWndproc(HWND hWnd, UINT message, WPARAM wParam, LPAR //I_OutputMsg("MW_WHEEL dispatched.\n"); ev.type = ev_keydown; if ((INT16)HIWORD(wParam) > 0) - ev.data1 = KEY_MOUSEWHEELUP; + ev.key = KEY_MOUSEWHEELUP; else - ev.data1 = KEY_MOUSEWHEELDOWN; + ev.key = KEY_MOUSEWHEELDOWN; D_PostEvent(&ev); break; @@ -271,7 +271,7 @@ static LRESULT CALLBACK MainWndproc(HWND hWnd, UINT message, WPARAM wParam, LPAR case WM_CLOSE: PostQuitMessage(0); //to quit while in-game - ev.data1 = KEY_ESCAPE; //to exit network synchronization + ev.key = KEY_ESCAPE; //to exit network synchronization ev.type = ev_keydown; D_PostEvent (&ev); return 0; diff --git a/src/win32/win_sys.c b/src/win32/win_sys.c index da0d5b47e..ff443935f 100644 --- a/src/win32/win_sys.c +++ b/src/win32/win_sys.c @@ -322,20 +322,20 @@ static inline VOID I_GetConsoleEvents(VOID) { case VK_ESCAPE: case VK_TAB: - ev.data1 = KEY_NULL; + ev.key = KEY_NULL; break; case VK_SHIFT: - ev.data1 = KEY_LSHIFT; + ev.key = KEY_LSHIFT; break; case VK_RETURN: entering_con_command = false; /* FALLTHRU */ default: - ev.data1 = MapVirtualKey(input.Event.KeyEvent.wVirtualKeyCode,2); // convert in to char + ev.key = MapVirtualKey(input.Event.KeyEvent.wVirtualKeyCode,2); // convert in to char } if (co != INVALID_HANDLE_VALUE && GetFileType(co) == FILE_TYPE_CHAR && GetConsoleMode(co, &t)) { - if (ev.data1 && ev.data1 != KEY_LSHIFT && ev.data1 != KEY_RSHIFT) + if (ev.key && ev.key != KEY_LSHIFT && ev.key != KEY_RSHIFT) { #ifdef UNICODE WriteConsole(co, &input.Event.KeyEvent.uChar.UnicodeChar, 1, &t, NULL); @@ -356,13 +356,13 @@ static inline VOID I_GetConsoleEvents(VOID) switch (input.Event.KeyEvent.wVirtualKeyCode) { case VK_SHIFT: - ev.data1 = KEY_LSHIFT; + ev.key = KEY_LSHIFT; break; default: break; } } - if (ev.data1) D_PostEvent(&ev); + if (ev.key) D_PostEvent(&ev); break; case MOUSE_EVENT: case WINDOW_BUFFER_SIZE_EVENT: @@ -945,7 +945,7 @@ static void I_ShutdownMouse2(VOID) for (i = 0; i < MOUSEBUTTONS; i++) { event.type = ev_keyup; - event.data1 = KEY_2MOUSE1 + i; + event.key = KEY_2MOUSE1 + i; D_PostEvent(&event); } @@ -1135,14 +1135,14 @@ VOID I_GetSysMouseEvents(INT mouse_state) if ((mouse_state & (1 << i)) && !(old_mouse_state & (1 << i))) { event.type = ev_keydown; - event.data1 = KEY_MOUSE1 + i; + event.key = KEY_MOUSE1 + i; D_PostEvent(&event); } // check if button released if (!(mouse_state & (1 << i)) && (old_mouse_state & (1 << i))) { event.type = ev_keyup; - event.data1 = KEY_MOUSE1 + i; + event.key = KEY_MOUSE1 + i; D_PostEvent(&event); } } @@ -1156,9 +1156,9 @@ VOID I_GetSysMouseEvents(INT mouse_state) if (xmickeys || ymickeys) { event.type = ev_mouse; - event.data1 = 0; - event.data2 = xmickeys; - event.data3 = -ymickeys; + event.key = 0; + event.x = xmickeys; + event.y = -ymickeys; D_PostEvent(&event); SetCursorPos(center_x, center_y); } @@ -1240,7 +1240,7 @@ static void I_ShutdownMouse(void) for (i = 0; i < MOUSEBUTTONS; i++) { event.type = ev_keyup; - event.data1 = KEY_MOUSE1 + i; + event.key = KEY_MOUSE1 + i; D_PostEvent(&event); } if (nodinput) @@ -1281,7 +1281,7 @@ void I_GetMouseEvents(void) event.type = ev_keydown; else event.type = ev_keyup; - event.data1 = KEY_2MOUSE1 + i; + event.key = KEY_2MOUSE1 + i; D_PostEvent(&event); } } @@ -1289,9 +1289,9 @@ void I_GetMouseEvents(void) if (handlermouse2x || handlermouse2y) { event.type = ev_mouse2; - event.data1 = 0; - event.data2 = handlermouse2x<<1; - event.data3 = -handlermouse2y<<1; + event.key = 0; + event.x = handlermouse2x<<1; + event.y = -handlermouse2y<<1; handlermouse2x = 0; handlermouse2y = 0; @@ -1330,7 +1330,7 @@ getBufferedData: else event.type = ev_keyup; // Button up - event.data1 = rgdod[d].dwOfs - DIMOFS_BUTTON0 + KEY_MOUSE1; + event.key = rgdod[d].dwOfs - DIMOFS_BUTTON0 + KEY_MOUSE1; D_PostEvent(&event); } else if (rgdod[d].dwOfs == DIMOFS_X) @@ -1342,9 +1342,9 @@ getBufferedData: { // z-axes the wheel if ((int)rgdod[d].dwData > 0) - event.data1 = KEY_MOUSEWHEELUP; + event.key = KEY_MOUSEWHEELUP; else - event.data1 = KEY_MOUSEWHEELDOWN; + event.key = KEY_MOUSEWHEELDOWN; event.type = ev_keydown; D_PostEvent(&event); } @@ -1354,9 +1354,9 @@ getBufferedData: if (xmickeys || ymickeys) { event.type = ev_mouse; - event.data1 = 0; - event.data2 = xmickeys; - event.data3 = -ymickeys; + event.key = 0; + event.x = xmickeys; + event.y = -ymickeys; D_PostEvent(&event); } } @@ -2395,14 +2395,14 @@ static VOID I_ShutdownJoystick(VOID) // emulate the up of all joystick buttons for (i = 0;i < JOYBUTTONS;i++) { - event.data1 = KEY_JOY1+i; + event.key = KEY_JOY1+i; D_PostEvent(&event); } // emulate the up of all joystick hats for (i = 0;i < JOYHATS*4;i++) { - event.data1 = KEY_HAT1+i; + event.key = KEY_HAT1+i; D_PostEvent(&event); } @@ -2410,7 +2410,7 @@ static VOID I_ShutdownJoystick(VOID) event.type = ev_joystick; for (i = 0;i < JOYAXISSET; i++) { - event.data1 = i; + event.key = i; D_PostEvent(&event); } @@ -2460,14 +2460,14 @@ static VOID I_ShutdownJoystick2(VOID) // emulate the up of all joystick buttons for (i = 0;i < JOYBUTTONS;i++) { - event.data1 = KEY_2JOY1+i; + event.key = KEY_2JOY1+i; D_PostEvent(&event); } // emulate the up of all joystick hats for (i = 0;i < JOYHATS*4;i++) { - event.data1 = KEY_2HAT1+i; + event.key = KEY_2HAT1+i; D_PostEvent(&event); } @@ -2475,7 +2475,7 @@ static VOID I_ShutdownJoystick2(VOID) event.type = ev_joystick2; for (i = 0;i < JOYAXISSET; i++) { - event.data1 = i; + event.key = i; D_PostEvent(&event); } @@ -2598,7 +2598,7 @@ acquire: event.type = ev_keydown; else event.type = ev_keyup; - event.data1 = KEY_JOY1 + i; + event.key = KEY_JOY1 + i; D_PostEvent(&event); } } @@ -2618,7 +2618,7 @@ acquire: event.type = ev_keydown; else event.type = ev_keyup; - event.data1 = KEY_HAT1 + i; + event.key = KEY_HAT1 + i; D_PostEvent(&event); } } @@ -2627,7 +2627,7 @@ acquire: // send joystick axis positions event.type = ev_joystick; - event.data1 = event.data2 = event.data3 = 0; + event.key = event.x = event.y = 0; if (Joystick.bGamepadStyle) { @@ -2635,29 +2635,29 @@ acquire: if (JoyInfo.X) { if (js.lX < -(JOYAXISRANGE/2)) - event.data2 = -1; + event.x = -1; else if (js.lX > JOYAXISRANGE/2) - event.data2 = 1; + event.x = 1; } if (JoyInfo.Y) { if (js.lY < -(JOYAXISRANGE/2)) - event.data3 = -1; + event.y = -1; else if (js.lY > JOYAXISRANGE/2) - event.data3 = 1; + event.y = 1; } } else { // analog control style, just send the raw data - if (JoyInfo.X) event.data2 = js.lX; // x axis - if (JoyInfo.Y) event.data3 = js.lY; // y axis + if (JoyInfo.X) event.x = js.lX; // x axis + if (JoyInfo.Y) event.y = js.lY; // y axis } D_PostEvent(&event); #if JOYAXISSET > 1 - event.data1 = 1; - event.data2 = event.data3 = 0; + event.key = 1; + event.x = event.y = 0; if (Joystick.bGamepadStyle) { @@ -2665,30 +2665,30 @@ acquire: if (JoyInfo.Z) { if (js.lZ < -(JOYAXISRANGE/2)) - event.data2 = -1; + event.x = -1; else if (js.lZ > JOYAXISRANGE/2) - event.data2 = 1; + event.x = 1; } if (JoyInfo.Rx) { if (js.lRx < -(JOYAXISRANGE/2)) - event.data3 = -1; + event.y = -1; else if (js.lRx > JOYAXISRANGE/2) - event.data3 = 1; + event.y = 1; } } else { // analog control style, just send the raw data - if (JoyInfo.Z) event.data2 = js.lZ; // z axis - if (JoyInfo.Rx) event.data3 = js.lRx; // rx axis + if (JoyInfo.Z) event.x = js.lZ; // z axis + if (JoyInfo.Rx) event.y = js.lRx; // rx axis } D_PostEvent(&event); #endif #if JOYAXISSET > 2 - event.data1 = 2; - event.data2 = event.data3 = 0; + event.key = 2; + event.x = event.y = 0; if (Joystick.bGamepadStyle) { @@ -2696,53 +2696,53 @@ acquire: if (JoyInfo.Rx) { if (js.lRy < -(JOYAXISRANGE/2)) - event.data2 = -1; + event.x = -1; else if (js.lRy > JOYAXISRANGE/2) - event.data2 = 1; + event.x = 1; } if (JoyInfo.Rz) { if (js.lRz < -(JOYAXISRANGE/2)) - event.data3 = -1; + event.y = -1; else if (js.lRz > JOYAXISRANGE/2) - event.data3 = 1; + event.y = 1; } } else { // analog control style, just send the raw data - if (JoyInfo.Ry) event.data2 = js.lRy; // ry axis - if (JoyInfo.Rz) event.data3 = js.lRz; // rz axis + if (JoyInfo.Ry) event.x = js.lRy; // ry axis + if (JoyInfo.Rz) event.y = js.lRz; // rz axis } D_PostEvent(&event); #endif #if JOYAXISSET > 3 - event.data1 = 3; - event.data2 = event.data3 = 0; + event.key = 3; + event.x = event.y = 0; if (Joystick.bGamepadStyle) { // gamepad control type, on or off, live or die if (JoyInfo.U) { if (js.rglSlider[0] < -(JOYAXISRANGE/2)) - event.data2 = -1; + event.x = -1; else if (js.rglSlider[0] > JOYAXISRANGE/2) - event.data2 = 1; + event.x = 1; } if (JoyInfo.V) { if (js.rglSlider[1] < -(JOYAXISRANGE/2)) - event.data3 = -1; + event.y = -1; else if (js.rglSlider[1] > JOYAXISRANGE/2) - event.data3 = 1; + event.y = 1; } } else { // analog control style, just send the raw data - if (JoyInfo.U) event.data2 = js.rglSlider[0]; // U axis - if (JoyInfo.V) event.data3 = js.rglSlider[1]; // V axis + if (JoyInfo.U) event.x = js.rglSlider[0]; // U axis + if (JoyInfo.V) event.y = js.rglSlider[1]; // V axis } D_PostEvent(&event); #endif @@ -2842,7 +2842,7 @@ acquire: event.type = ev_keydown; else event.type = ev_keyup; - event.data1 = KEY_2JOY1 + i; + event.key = KEY_2JOY1 + i; D_PostEvent(&event); } } @@ -2862,7 +2862,7 @@ acquire: event.type = ev_keydown; else event.type = ev_keyup; - event.data1 = KEY_2HAT1 + i; + event.key = KEY_2HAT1 + i; D_PostEvent(&event); } } @@ -2871,7 +2871,7 @@ acquire: // send joystick axis positions event.type = ev_joystick2; - event.data1 = event.data2 = event.data3 = 0; + event.key = event.x = event.y = 0; if (Joystick2.bGamepadStyle) { @@ -2879,29 +2879,29 @@ acquire: if (JoyInfo2.X) { if (js.lX < -(JOYAXISRANGE/2)) - event.data2 = -1; + event.x = -1; else if (js.lX > JOYAXISRANGE/2) - event.data2 = 1; + event.x = 1; } if (JoyInfo2.Y) { if (js.lY < -(JOYAXISRANGE/2)) - event.data3 = -1; + event.y = -1; else if (js.lY > JOYAXISRANGE/2) - event.data3 = 1; + event.y = 1; } } else { // analog control style, just send the raw data - if (JoyInfo2.X) event.data2 = js.lX; // x axis - if (JoyInfo2.Y) event.data3 = js.lY; // y axis + if (JoyInfo2.X) event.x = js.lX; // x axis + if (JoyInfo2.Y) event.y = js.lY; // y axis } D_PostEvent(&event); #if JOYAXISSET > 1 - event.data1 = 1; - event.data2 = event.data3 = 0; + event.key = 1; + event.x = event.y = 0; if (Joystick2.bGamepadStyle) { @@ -2909,30 +2909,30 @@ acquire: if (JoyInfo2.Z) { if (js.lZ < -(JOYAXISRANGE/2)) - event.data2 = -1; + event.x = -1; else if (js.lZ > JOYAXISRANGE/2) - event.data2 = 1; + event.x = 1; } if (JoyInfo2.Rx) { if (js.lRx < -(JOYAXISRANGE/2)) - event.data3 = -1; + event.y = -1; else if (js.lRx > JOYAXISRANGE/2) - event.data3 = 1; + event.y = 1; } } else { // analog control style, just send the raw data - if (JoyInfo2.Z) event.data2 = js.lZ; // z axis - if (JoyInfo2.Rx) event.data3 = js.lRx; // rx axis + if (JoyInfo2.Z) event.x = js.lZ; // z axis + if (JoyInfo2.Rx) event.y = js.lRx; // rx axis } D_PostEvent(&event); #endif #if JOYAXISSET > 2 - event.data1 = 2; - event.data2 = event.data3 = 0; + event.key = 2; + event.x = event.y = 0; if (Joystick2.bGamepadStyle) { @@ -2940,53 +2940,53 @@ acquire: if (JoyInfo2.Rx) { if (js.lRy < -(JOYAXISRANGE/2)) - event.data2 = -1; + event.x = -1; else if (js.lRy > JOYAXISRANGE/2) - event.data2 = 1; + event.x = 1; } if (JoyInfo2.Rz) { if (js.lRz < -(JOYAXISRANGE/2)) - event.data3 = -1; + event.y = -1; else if (js.lRz > JOYAXISRANGE/2) - event.data3 = 1; + event.y = 1; } } else { // analog control style, just send the raw data - if (JoyInfo2.Ry) event.data2 = js.lRy; // ry axis - if (JoyInfo2.Rz) event.data3 = js.lRz; // rz axis + if (JoyInfo2.Ry) event.x = js.lRy; // ry axis + if (JoyInfo2.Rz) event.y = js.lRz; // rz axis } D_PostEvent(&event); #endif #if JOYAXISSET > 3 - event.data1 = 3; - event.data2 = event.data3 = 0; + event.key = 3; + event.x = event.y = 0; if (Joystick2.bGamepadStyle) { // gamepad control type, on or off, live or die if (JoyInfo2.U) { if (js.rglSlider[0] < -(JOYAXISRANGE/2)) - event.data2 = -1; + event.x = -1; else if (js.rglSlider[0] > JOYAXISRANGE/2) - event.data2 = 1; + event.x = 1; } if (JoyInfo2.V) { if (js.rglSlider[1] < -(JOYAXISRANGE/2)) - event.data3 = -1; + event.y = -1; else if (js.rglSlider[1] > JOYAXISRANGE/2) - event.data3 = 1; + event.y = 1; } } else { // analog control style, just send the raw data - if (JoyInfo2.U) event.data2 = js.rglSlider[0]; // U axis - if (JoyInfo2.V) event.data3 = js.rglSlider[1]; // V axis + if (JoyInfo2.U) event.x = js.rglSlider[0]; // U axis + if (JoyInfo2.V) event.y = js.rglSlider[1]; // V axis } D_PostEvent(&event); #endif @@ -3194,7 +3194,7 @@ INT32 I_GetKey(void) ev = &events[eventtail]; eventtail = (eventtail+1) & (MAXEVENTS-1); if (ev->type == ev_keydown || ev->type == ev_console) - return ev->data1; + return ev->key; else return 0; } @@ -3308,7 +3308,7 @@ static VOID I_GetKeyboardEvents(VOID) if (!appActive && RepeatKeyCode) // Stop when lost focus { event.type = ev_keyup; - event.data1 = RepeatKeyCode; + event.key = RepeatKeyCode; D_PostEvent(&event); RepeatKeyCode = 0; } @@ -3363,9 +3363,9 @@ getBufferedData: ch = rgdod[d].dwOfs & 0xFF; if (ASCIINames[ch]) - event.data1 = ASCIINames[ch]; + event.key = ASCIINames[ch]; else - event.data1 = 0x80; + event.key = 0x80; D_PostEvent(&event); } @@ -3378,7 +3378,7 @@ getBufferedData: // delay is tripled for first repeating key RepeatKeyTics = hacktics + (KEY_REPEAT_DELAY*3); if (event.type == ev_keydown) // use the last event! - RepeatKeyCode = event.data1; + RepeatKeyCode = event.key; } else { @@ -3386,7 +3386,7 @@ getBufferedData: if (RepeatKeyCode && hacktics - RepeatKeyTics > KEY_REPEAT_DELAY) { event.type = ev_keydown; - event.data1 = RepeatKeyCode; + event.key = RepeatKeyCode; D_PostEvent(&event); RepeatKeyTics = hacktics; From 824b1ab28cdddfd1c018454a9af14dabaab49fcd Mon Sep 17 00:00:00 2001 From: James R Date: Sat, 14 Aug 2021 15:29:21 -0700 Subject: [PATCH 0903/1080] Makefile: use full stem in dependency generation Previously took only the filename, so the directory component was stripped. This broke dependencies for basically every file. --- src/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Makefile b/src/Makefile index ce0e84987..9659a4994 100644 --- a/src/Makefile +++ b/src/Makefile @@ -376,7 +376,7 @@ ifdef Echo_name @printf '%-20.20s\r' $$< endif endif - $(.)$(cc) -MM -MF $$@ -MT $(objdir)/$$(*F).o $(2) $$< + $(.)$(cc) -MM -MF $$@ -MT $(objdir)/$$*.o $(2) $$< endef $(eval $(call _recipe,c)) From 772695741c7935a3798d3e48d0d5c9151df7ae28 Mon Sep 17 00:00:00 2001 From: LJ Sonic Date: Sun, 15 Aug 2021 15:24:23 +0200 Subject: [PATCH 0904/1080] Rename KeyNumToString to KeyNumToName and vice-versa --- src/console.c | 4 ++-- src/g_input.c | 16 ++++++++-------- src/g_input.h | 4 ++-- src/lua_inputlib.c | 14 +++++++------- src/m_menu.c | 4 ++-- 5 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/console.c b/src/console.c index 7941e1dbb..d615f3e6b 100644 --- a/src/console.c +++ b/src/console.c @@ -221,7 +221,7 @@ static void CONS_Bind_f(void) for (key = 0; key < NUMINPUTS; key++) if (bindtable[key]) { - CONS_Printf("%s : \"%s\"\n", G_KeyNumToString(key), bindtable[key]); + CONS_Printf("%s : \"%s\"\n", G_KeyNumToName(key), bindtable[key]); na = 1; } if (!na) @@ -229,7 +229,7 @@ static void CONS_Bind_f(void) return; } - key = G_KeyStringToNum(COM_Argv(1)); + key = G_KeyNameToNum(COM_Argv(1)); if (key <= 0 || key >= NUMINPUTS) { CONS_Alert(CONS_NOTICE, M_GetText("Invalid key name\n")); diff --git a/src/g_input.c b/src/g_input.c index e0a27d1ca..494edbd56 100644 --- a/src/g_input.c +++ b/src/g_input.c @@ -624,7 +624,7 @@ void G_ClearAllControlKeys(void) // Returns the name of a key (or virtual key for mouse and joy) // the input value being an keynum // -const char *G_KeyNumToString(INT32 keynum) +const char *G_KeyNumToName(INT32 keynum) { static char keynamestr[8]; @@ -648,7 +648,7 @@ const char *G_KeyNumToString(INT32 keynum) return keynamestr; } -INT32 G_KeyStringToNum(const char *keystr) +INT32 G_KeyNameToNum(const char *keystr) { UINT32 j; @@ -811,10 +811,10 @@ void G_SaveKeySetting(FILE *f, INT32 (*fromcontrols)[2], INT32 (*fromcontrolsbis for (i = 1; i < num_gamecontrols; i++) { fprintf(f, "setcontrol \"%s\" \"%s\"", gamecontrolname[i], - G_KeyNumToString(fromcontrols[i][0])); + G_KeyNumToName(fromcontrols[i][0])); if (fromcontrols[i][1]) - fprintf(f, " \"%s\"\n", G_KeyNumToString(fromcontrols[i][1])); + fprintf(f, " \"%s\"\n", G_KeyNumToName(fromcontrols[i][1])); else fprintf(f, "\n"); } @@ -822,10 +822,10 @@ void G_SaveKeySetting(FILE *f, INT32 (*fromcontrols)[2], INT32 (*fromcontrolsbis for (i = 1; i < num_gamecontrols; i++) { fprintf(f, "setcontrol2 \"%s\" \"%s\"", gamecontrolname[i], - G_KeyNumToString(fromcontrolsbis[i][0])); + G_KeyNumToName(fromcontrolsbis[i][0])); if (fromcontrolsbis[i][1]) - fprintf(f, " \"%s\"\n", G_KeyNumToString(fromcontrolsbis[i][1])); + fprintf(f, " \"%s\"\n", G_KeyNumToName(fromcontrolsbis[i][1])); else fprintf(f, "\n"); } @@ -1001,8 +1001,8 @@ static void setcontrol(INT32 (*gc)[2]) CONS_Printf(M_GetText("Control '%s' unknown\n"), namectrl); return; } - keynum1 = G_KeyStringToNum(COM_Argv(2)); - keynum2 = G_KeyStringToNum(COM_Argv(3)); + keynum1 = G_KeyNameToNum(COM_Argv(2)); + keynum2 = G_KeyNameToNum(COM_Argv(3)); keynum = G_FilterKeyByVersion(numctrl, 0, player, &keynum1, &keynum2, &nestedoverride); if (keynum >= 0) diff --git a/src/g_input.h b/src/g_input.h index ffd0cb560..39c0180e7 100644 --- a/src/g_input.h +++ b/src/g_input.h @@ -181,8 +181,8 @@ extern const INT32 gcl_jump_spin[num_gcl_jump_spin]; void G_MapEventsToControls(event_t *ev); // returns the name of a key -const char *G_KeyNumToString(INT32 keynum); -INT32 G_KeyStringToNum(const char *keystr); +const char *G_KeyNumToName(INT32 keynum); +INT32 G_KeyNameToNum(const char *keystr); // detach any keys associated to the given game control void G_ClearControlKeys(INT32 (*setupcontrols)[2], INT32 control); diff --git a/src/lua_inputlib.c b/src/lua_inputlib.c index 01383a57b..3affeea7b 100644 --- a/src/lua_inputlib.c +++ b/src/lua_inputlib.c @@ -75,17 +75,17 @@ static int lib_joy2Axis(lua_State *L) return 1; } -static int lib_keyNumToString(lua_State *L) +static int lib_keyNumToName(lua_State *L) { int i = luaL_checkinteger(L, 1); - lua_pushstring(L, G_KeyNumToString(i)); + lua_pushstring(L, G_KeyNumToName(i)); return 1; } -static int lib_keyStringToNum(lua_State *L) +static int lib_keyNameToNum(lua_State *L) { const char *str = luaL_checkstring(L, 1); - lua_pushinteger(L, G_KeyStringToNum(str)); + lua_pushinteger(L, G_KeyNameToNum(str)); return 1; } @@ -133,8 +133,8 @@ static luaL_Reg lib[] = { {"gameControl2ToKeyNum", lib_gameControl2ToKeyNum}, {"joyAxis", lib_joyAxis}, {"joy2Axis", lib_joy2Axis}, - {"keyNumToString", lib_keyNumToString}, - {"keyStringToNum", lib_keyStringToNum}, + {"keyNumToName", lib_keyNumToName}, + {"keyNameToNum", lib_keyNameToNum}, {"keyNumPrintable", lib_keyNumPrintable}, {"shiftKeyNum", lib_shiftKeyNum}, {"getMouseGrab", lib_getMouseGrab}, @@ -184,7 +184,7 @@ static int keyevent_get(lua_State *L) I_Assert(event != NULL); if (fastcmp(field,"name")) - lua_pushstring(L, G_KeyNumToString(event->key)); + lua_pushstring(L, G_KeyNumToName(event->key)); else if (fastcmp(field,"num")) lua_pushinteger(L, event->key); else if (fastcmp(field,"repeated")) diff --git a/src/m_menu.c b/src/m_menu.c index 92754705b..4a0fefb1b 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -12826,13 +12826,13 @@ static void M_DrawControl(void) else { if (keys[0] != KEY_NULL) - strcat (tmp, G_KeyNumToString (keys[0])); + strcat (tmp, G_KeyNumToName (keys[0])); if (keys[0] != KEY_NULL && keys[1] != KEY_NULL) strcat(tmp," or "); if (keys[1] != KEY_NULL) - strcat (tmp, G_KeyNumToString (keys[1])); + strcat (tmp, G_KeyNumToName (keys[1])); } From 5340db5f6755fb927b36c33aacd845c11ea5cca4 Mon Sep 17 00:00:00 2001 From: LJ Sonic Date: Sun, 15 Aug 2021 16:15:28 +0200 Subject: [PATCH 0905/1080] Make gc_ constants uppercase --- src/console.c | 4 +- src/d_clisrv.c | 4 +- src/deh_tables.c | 86 ++++++++--------- src/g_game.c | 62 ++++++------ src/g_input.c | 228 ++++++++++++++++++++++----------------------- src/g_input.h | 94 +++++++++---------- src/hu_stuff.c | 14 +-- src/lua_inputlib.c | 16 ++-- src/m_menu.c | 80 ++++++++-------- src/m_misc.c | 4 +- src/p_user.c | 4 +- 11 files changed, 298 insertions(+), 298 deletions(-) diff --git a/src/console.c b/src/console.c index d615f3e6b..b9348d10e 100644 --- a/src/console.c +++ b/src/console.c @@ -913,7 +913,7 @@ boolean CON_Responder(event_t *ev) // let go keyup events, don't eat them if (ev->type != ev_keydown && ev->type != ev_console) { - if (ev->key == gamecontrol[gc_console][0] || ev->key == gamecontrol[gc_console][1]) + if (ev->key == gamecontrol[GC_CONSOLE][0] || ev->key == gamecontrol[GC_CONSOLE][1]) consdown = false; return false; } @@ -926,7 +926,7 @@ boolean CON_Responder(event_t *ev) if (modeattacking || metalrecording || marathonmode) return false; - if (key == gamecontrol[gc_console][0] || key == gamecontrol[gc_console][1]) + if (key == gamecontrol[GC_CONSOLE][0] || key == gamecontrol[GC_CONSOLE][1]) { if (consdown) // ignore repeat return true; diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 36a0d7df7..326105a3b 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -663,14 +663,14 @@ static void Snake_Handle(void) UINT16 i; // Handle retry - if (snake->gameover && (PLAYER1INPUTDOWN(gc_jump) || gamekeydown[KEY_ENTER])) + if (snake->gameover && (PLAYER1INPUTDOWN(GC_JUMP) || gamekeydown[KEY_ENTER])) { Snake_Initialise(); snake->pausepressed = true; // Avoid accidental pause on respawn } // Handle pause - if (PLAYER1INPUTDOWN(gc_pause) || gamekeydown[KEY_ENTER]) + if (PLAYER1INPUTDOWN(GC_PAUSE) || gamekeydown[KEY_ENTER]) { if (!snake->pausepressed) snake->paused = !snake->paused; diff --git a/src/deh_tables.c b/src/deh_tables.c index 677b23214..088bc26c0 100644 --- a/src/deh_tables.c +++ b/src/deh_tables.c @@ -5472,49 +5472,49 @@ struct int_const_s const INT_CONST[] = { {"JOYAXISRANGE",JOYAXISRANGE}, // Game controls - {"gc_null",gc_null}, - {"gc_forward",gc_forward}, - {"gc_backward",gc_backward}, - {"gc_strafeleft",gc_strafeleft}, - {"gc_straferight",gc_straferight}, - {"gc_turnleft",gc_turnleft}, - {"gc_turnright",gc_turnright}, - {"gc_weaponnext",gc_weaponnext}, - {"gc_weaponprev",gc_weaponprev}, - {"gc_wepslot1",gc_wepslot1}, - {"gc_wepslot2",gc_wepslot2}, - {"gc_wepslot3",gc_wepslot3}, - {"gc_wepslot4",gc_wepslot4}, - {"gc_wepslot5",gc_wepslot5}, - {"gc_wepslot6",gc_wepslot6}, - {"gc_wepslot7",gc_wepslot7}, - {"gc_wepslot8",gc_wepslot8}, - {"gc_wepslot9",gc_wepslot9}, - {"gc_wepslot10",gc_wepslot10}, - {"gc_fire",gc_fire}, - {"gc_firenormal",gc_firenormal}, - {"gc_tossflag",gc_tossflag}, - {"gc_spin",gc_spin}, - {"gc_camtoggle",gc_camtoggle}, - {"gc_camreset",gc_camreset}, - {"gc_lookup",gc_lookup}, - {"gc_lookdown",gc_lookdown}, - {"gc_centerview",gc_centerview}, - {"gc_mouseaiming",gc_mouseaiming}, - {"gc_talkkey",gc_talkkey}, - {"gc_teamkey",gc_teamkey}, - {"gc_scores",gc_scores}, - {"gc_jump",gc_jump}, - {"gc_console",gc_console}, - {"gc_pause",gc_pause}, - {"gc_systemmenu",gc_systemmenu}, - {"gc_screenshot",gc_screenshot}, - {"gc_recordgif",gc_recordgif}, - {"gc_viewpoint",gc_viewpoint}, - {"gc_custom1",gc_custom1}, - {"gc_custom2",gc_custom2}, - {"gc_custom3",gc_custom3}, - {"num_gamecontrols",num_gamecontrols}, + {"GC_NULL",GC_NULL}, + {"GC_FORWARD",GC_FORWARD}, + {"GC_BACKWARD",GC_BACKWARD}, + {"GC_STRAFELEFT",GC_STRAFELEFT}, + {"GC_STRAFERIGHT",GC_STRAFERIGHT}, + {"GC_TURNLEFT",GC_TURNLEFT}, + {"GC_TURNRIGHT",GC_TURNRIGHT}, + {"GC_WEAPONNEXT",GC_WEAPONNEXT}, + {"GC_WEAPONPREV",GC_WEAPONPREV}, + {"GC_WEPSLOT1",GC_WEPSLOT1}, + {"GC_WEPSLOT2",GC_WEPSLOT2}, + {"GC_WEPSLOT3",GC_WEPSLOT3}, + {"GC_WEPSLOT4",GC_WEPSLOT4}, + {"GC_WEPSLOT5",GC_WEPSLOT5}, + {"GC_WEPSLOT6",GC_WEPSLOT6}, + {"GC_WEPSLOT7",GC_WEPSLOT7}, + {"GC_WEPSLOT8",GC_WEPSLOT8}, + {"GC_WEPSLOT9",GC_WEPSLOT9}, + {"GC_WEPSLOT10",GC_WEPSLOT10}, + {"GC_FIRE",GC_FIRE}, + {"GC_FIRENORMAL",GC_FIRENORMAL}, + {"GC_TOSSFLAG",GC_TOSSFLAG}, + {"GC_SPIN",GC_SPIN}, + {"GC_CAMTOGGLE",GC_CAMTOGGLE}, + {"GC_CAMRESET",GC_CAMRESET}, + {"GC_LOOKUP",GC_LOOKUP}, + {"GC_LOOKDOWN",GC_LOOKDOWN}, + {"GC_CENTERVIEW",GC_CENTERVIEW}, + {"GC_MOUSEAIMING",GC_MOUSEAIMING}, + {"GC_TALKKEY",GC_TALKKEY}, + {"GC_TEAMKEY",GC_TEAMKEY}, + {"GC_SCORES",GC_SCORES}, + {"GC_JUMP",GC_JUMP}, + {"GC_CONSOLE",GC_CONSOLE}, + {"GC_PAUSE",GC_PAUSE}, + {"GC_SYSTEMMENU",GC_SYSTEMMENU}, + {"GC_SCREENSHOT",GC_SCREENSHOT}, + {"GC_RECORDGIF",GC_RECORDGIF}, + {"GC_VIEWPOINT",GC_VIEWPOINT}, + {"GC_CUSTOM1",GC_CUSTOM1}, + {"GC_CUSTOM2",GC_CUSTOM2}, + {"GC_CUSTOM3",GC_CUSTOM3}, + {"NUM_GAMECONTROLS",NUM_GAMECONTROLS}, // Mouse buttons {"MB_BUTTON1",MB_BUTTON1}, diff --git a/src/g_game.c b/src/g_game.c index 5c89bcae8..bc86e255a 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1140,13 +1140,13 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) return; } - turnright = PLAYERINPUTDOWN(ssplayer, gc_turnright); - turnleft = PLAYERINPUTDOWN(ssplayer, gc_turnleft); + turnright = PLAYERINPUTDOWN(ssplayer, GC_TURNRIGHT); + turnleft = PLAYERINPUTDOWN(ssplayer, GC_TURNLEFT); - straferkey = PLAYERINPUTDOWN(ssplayer, gc_straferight); - strafelkey = PLAYERINPUTDOWN(ssplayer, gc_strafeleft); - movefkey = PLAYERINPUTDOWN(ssplayer, gc_forward); - movebkey = PLAYERINPUTDOWN(ssplayer, gc_backward); + straferkey = PLAYERINPUTDOWN(ssplayer, GC_STRAFERIGHT); + strafelkey = PLAYERINPUTDOWN(ssplayer, GC_STRAFELEFT); + movefkey = PLAYERINPUTDOWN(ssplayer, GC_FORWARD); + movebkey = PLAYERINPUTDOWN(ssplayer, GC_BACKWARD); if (strafeisturn) { @@ -1155,7 +1155,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) straferkey = strafelkey = false; } - mouseaiming = (PLAYERINPUTDOWN(ssplayer, gc_mouseaiming)) ^ + mouseaiming = (PLAYERINPUTDOWN(ssplayer, GC_MOUSEAIMING)) ^ ((chasecam && !player->spectator) ? chasefreelook : alwaysfreelook); analogjoystickmove = usejoystick && !Joystick.bGamepadStyle; gamepadjoystickmove = usejoystick && Joystick.bGamepadStyle; @@ -1271,11 +1271,11 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) // forward with key or button if (movefkey || (gamepadjoystickmove && movejoystickvector.yaxis < 0) || ((player->powers[pw_carry] == CR_NIGHTSMODE) - && (PLAYERINPUTDOWN(ssplayer, gc_lookup) || (gamepadjoystickmove && lookjoystickvector.yaxis > 0)))) + && (PLAYERINPUTDOWN(ssplayer, GC_LOOKUP) || (gamepadjoystickmove && lookjoystickvector.yaxis > 0)))) forward = forwardmove[speed]; if (movebkey || (gamepadjoystickmove && movejoystickvector.yaxis > 0) || ((player->powers[pw_carry] == CR_NIGHTSMODE) - && (PLAYERINPUTDOWN(ssplayer, gc_lookdown) || (gamepadjoystickmove && lookjoystickvector.yaxis < 0)))) + && (PLAYERINPUTDOWN(ssplayer, GC_LOOKDOWN) || (gamepadjoystickmove && lookjoystickvector.yaxis < 0)))) forward -= forwardmove[speed]; if (analogjoystickmove && movejoystickvector.yaxis != 0) @@ -1288,9 +1288,9 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) if (strafelkey) side -= sidemove[speed]; - if (PLAYERINPUTDOWN(ssplayer, gc_weaponnext)) + if (PLAYERINPUTDOWN(ssplayer, GC_WEAPONNEXT)) cmd->buttons |= BT_WEAPONNEXT; // Next Weapon - if (PLAYERINPUTDOWN(ssplayer, gc_weaponprev)) + if (PLAYERINPUTDOWN(ssplayer, GC_WEAPONPREV)) cmd->buttons |= BT_WEAPONPREV; // Previous Weapon #if NUM_WEAPONS > 10 @@ -1299,7 +1299,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) //use the four avaliable bits to determine the weapon. cmd->buttons &= ~BT_WEAPONMASK; for (i = 0; i < NUM_WEAPONS; ++i) - if (PLAYERINPUTDOWN(ssplayer, gc_wepslot1 + i)) + if (PLAYERINPUTDOWN(ssplayer, GC_WEPSLOT1 + i)) { cmd->buttons |= (UINT16)(i + 1); break; @@ -1307,34 +1307,34 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) // fire with any button/key axis = PlayerJoyAxis(ssplayer, JA_FIRE); - if (PLAYERINPUTDOWN(ssplayer, gc_fire) || (usejoystick && axis > 0)) + if (PLAYERINPUTDOWN(ssplayer, GC_FIRE) || (usejoystick && axis > 0)) cmd->buttons |= BT_ATTACK; // fire normal with any button/key axis = PlayerJoyAxis(ssplayer, JA_FIRENORMAL); - if (PLAYERINPUTDOWN(ssplayer, gc_firenormal) || (usejoystick && axis > 0)) + if (PLAYERINPUTDOWN(ssplayer, GC_FIRENORMAL) || (usejoystick && axis > 0)) cmd->buttons |= BT_FIRENORMAL; - if (PLAYERINPUTDOWN(ssplayer, gc_tossflag)) + if (PLAYERINPUTDOWN(ssplayer, GC_TOSSFLAG)) cmd->buttons |= BT_TOSSFLAG; // Lua scriptable buttons - if (PLAYERINPUTDOWN(ssplayer, gc_custom1)) + if (PLAYERINPUTDOWN(ssplayer, GC_CUSTOM1)) cmd->buttons |= BT_CUSTOM1; - if (PLAYERINPUTDOWN(ssplayer, gc_custom2)) + if (PLAYERINPUTDOWN(ssplayer, GC_CUSTOM2)) cmd->buttons |= BT_CUSTOM2; - if (PLAYERINPUTDOWN(ssplayer, gc_custom3)) + if (PLAYERINPUTDOWN(ssplayer, GC_CUSTOM3)) cmd->buttons |= BT_CUSTOM3; // use with any button/key axis = PlayerJoyAxis(ssplayer, JA_SPIN); - if (PLAYERINPUTDOWN(ssplayer, gc_spin) || (usejoystick && axis > 0)) + if (PLAYERINPUTDOWN(ssplayer, GC_SPIN) || (usejoystick && axis > 0)) cmd->buttons |= BT_SPIN; // Centerview can be a toggle in simple mode! { static boolean last_centerviewdown[2], centerviewhold[2]; // detect taps for toggle behavior - boolean down = PLAYERINPUTDOWN(ssplayer, gc_centerview); + boolean down = PLAYERINPUTDOWN(ssplayer, GC_CENTERVIEW); if (!(controlstyle == CS_SIMPLE && cv_cam_centertoggle[forplayer].value)) centerviewdown = down; @@ -1433,7 +1433,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) if (ticcmd_centerviewdown[forplayer] && controlstyle == CS_SIMPLE) controlstyle = CS_LEGACY; - if (PLAYERINPUTDOWN(ssplayer, gc_camreset)) + if (PLAYERINPUTDOWN(ssplayer, GC_CAMRESET)) { if (thiscam->chase && !resetdown[forplayer]) P_ResetCamera(&players[ssplayer == 1 ? displayplayer : secondarydisplayplayer], thiscam); @@ -1446,7 +1446,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) // jump button axis = PlayerJoyAxis(ssplayer, JA_JUMP); - if (PLAYERINPUTDOWN(ssplayer, gc_jump) || (usejoystick && axis > 0)) + if (PLAYERINPUTDOWN(ssplayer, GC_JUMP) || (usejoystick && axis > 0)) cmd->buttons |= BT_JUMP; // player aiming shit, ahhhh... @@ -1476,12 +1476,12 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) if (!(player->powers[pw_carry] == CR_NIGHTSMODE)) { - if (PLAYERINPUTDOWN(ssplayer, gc_lookup) || (gamepadjoystickmove && lookjoystickvector.yaxis < 0)) + if (PLAYERINPUTDOWN(ssplayer, GC_LOOKUP) || (gamepadjoystickmove && lookjoystickvector.yaxis < 0)) { *myaiming += KB_LOOKSPEED * screen_invert; keyboard_look[forplayer] = true; } - else if (PLAYERINPUTDOWN(ssplayer, gc_lookdown) || (gamepadjoystickmove && lookjoystickvector.yaxis > 0)) + else if (PLAYERINPUTDOWN(ssplayer, GC_LOOKDOWN) || (gamepadjoystickmove && lookjoystickvector.yaxis > 0)) { *myaiming -= KB_LOOKSPEED * screen_invert; keyboard_look[forplayer] = true; @@ -2045,7 +2045,7 @@ boolean G_Responder(event_t *ev) // allow spy mode changes even during the demo if (gamestate == GS_LEVEL && ev->type == ev_keydown - && (ev->key == KEY_F12 || ev->key == gamecontrol[gc_viewpoint][0] || ev->key == gamecontrol[gc_viewpoint][1])) + && (ev->key == KEY_F12 || ev->key == gamecontrol[GC_VIEWPOINT][0] || ev->key == gamecontrol[GC_VIEWPOINT][1])) { // ViewpointSwitch Lua hook. UINT8 canSwitchView = 0; @@ -2118,8 +2118,8 @@ boolean G_Responder(event_t *ev) switch (ev->type) { case ev_keydown: - if (ev->key == gamecontrol[gc_pause][0] - || ev->key == gamecontrol[gc_pause][1] + if (ev->key == gamecontrol[GC_PAUSE][0] + || ev->key == gamecontrol[GC_PAUSE][1] || ev->key == KEY_PAUSE) { if (modeattacking && !demoplayback && (gamestate == GS_LEVEL)) @@ -2149,8 +2149,8 @@ boolean G_Responder(event_t *ev) } } } - if (ev->key == gamecontrol[gc_camtoggle][0] - || ev->key == gamecontrol[gc_camtoggle][1]) + if (ev->key == gamecontrol[GC_CAMTOGGLE][0] + || ev->key == gamecontrol[GC_CAMTOGGLE][1]) { if (!camtoggledelay) { @@ -2158,8 +2158,8 @@ boolean G_Responder(event_t *ev) CV_SetValue(&cv_chasecam, cv_chasecam.value ? 0 : 1); } } - if (ev->key == gamecontrolbis[gc_camtoggle][0] - || ev->key == gamecontrolbis[gc_camtoggle][1]) + if (ev->key == gamecontrolbis[GC_CAMTOGGLE][0] + || ev->key == gamecontrolbis[GC_CAMTOGGLE][1]) { if (!camtoggledelay2) { diff --git a/src/g_input.c b/src/g_input.c index 494edbd56..cd4536bba 100644 --- a/src/g_input.c +++ b/src/g_input.c @@ -41,49 +41,49 @@ INT32 joyxmove[JOYAXISSET], joyymove[JOYAXISSET], joy2xmove[JOYAXISSET], joy2ymo UINT8 gamekeydown[NUMINPUTS]; // two key codes (or virtual key) per game control -INT32 gamecontrol[num_gamecontrols][2]; -INT32 gamecontrolbis[num_gamecontrols][2]; // secondary splitscreen player -INT32 gamecontroldefault[num_gamecontrolschemes][num_gamecontrols][2]; // default control storage, use 0 (gcs_custom) for memory retention -INT32 gamecontrolbisdefault[num_gamecontrolschemes][num_gamecontrols][2]; +INT32 gamecontrol[NUM_GAMECONTROLS][2]; +INT32 gamecontrolbis[NUM_GAMECONTROLS][2]; // secondary splitscreen player +INT32 gamecontroldefault[num_gamecontrolschemes][NUM_GAMECONTROLS][2]; // default control storage, use 0 (gcs_custom) for memory retention +INT32 gamecontrolbisdefault[num_gamecontrolschemes][NUM_GAMECONTROLS][2]; // lists of GC codes for selective operation const INT32 gcl_tutorial_check[num_gcl_tutorial_check] = { - gc_forward, gc_backward, gc_strafeleft, gc_straferight, - gc_turnleft, gc_turnright + GC_FORWARD, GC_BACKWARD, GC_STRAFELEFT, GC_STRAFERIGHT, + GC_TURNLEFT, GC_TURNRIGHT }; const INT32 gcl_tutorial_used[num_gcl_tutorial_used] = { - gc_forward, gc_backward, gc_strafeleft, gc_straferight, - gc_turnleft, gc_turnright, - gc_jump, gc_spin + GC_FORWARD, GC_BACKWARD, GC_STRAFELEFT, GC_STRAFERIGHT, + GC_TURNLEFT, GC_TURNRIGHT, + GC_JUMP, GC_SPIN }; const INT32 gcl_tutorial_full[num_gcl_tutorial_full] = { - gc_forward, gc_backward, gc_strafeleft, gc_straferight, - gc_lookup, gc_lookdown, gc_turnleft, gc_turnright, gc_centerview, - gc_jump, gc_spin, - gc_fire, gc_firenormal + GC_FORWARD, GC_BACKWARD, GC_STRAFELEFT, GC_STRAFERIGHT, + GC_LOOKUP, GC_LOOKDOWN, GC_TURNLEFT, GC_TURNRIGHT, GC_CENTERVIEW, + GC_JUMP, GC_SPIN, + GC_FIRE, GC_FIRENORMAL }; const INT32 gcl_movement[num_gcl_movement] = { - gc_forward, gc_backward, gc_strafeleft, gc_straferight + GC_FORWARD, GC_BACKWARD, GC_STRAFELEFT, GC_STRAFERIGHT }; const INT32 gcl_camera[num_gcl_camera] = { - gc_turnleft, gc_turnright + GC_TURNLEFT, GC_TURNRIGHT }; const INT32 gcl_movement_camera[num_gcl_movement_camera] = { - gc_forward, gc_backward, gc_strafeleft, gc_straferight, - gc_turnleft, gc_turnright + GC_FORWARD, GC_BACKWARD, GC_STRAFELEFT, GC_STRAFERIGHT, + GC_TURNLEFT, GC_TURNRIGHT }; -const INT32 gcl_jump[num_gcl_jump] = { gc_jump }; +const INT32 gcl_jump[num_gcl_jump] = { GC_JUMP }; -const INT32 gcl_spin[num_gcl_spin] = { gc_spin }; +const INT32 gcl_spin[num_gcl_spin] = { GC_SPIN }; const INT32 gcl_jump_spin[num_gcl_jump_spin] = { - gc_jump, gc_spin + GC_JUMP, GC_SPIN }; typedef struct @@ -553,9 +553,9 @@ static keyname_t keynames[] = }; -static const char *gamecontrolname[num_gamecontrols] = +static const char *gamecontrolname[NUM_GAMECONTROLS] = { - "nothing", // a key/button mapped to gc_null has no effect + "nothing", // a key/button mapped to GC_NULL has no effect "forward", "backward", "strafeleft", @@ -613,7 +613,7 @@ void G_ClearControlKeys(INT32 (*setupcontrols)[2], INT32 control) void G_ClearAllControlKeys(void) { INT32 i; - for (i = 0; i < num_gamecontrols; i++) + for (i = 0; i < NUM_GAMECONTROLS; i++) { G_ClearControlKeys(gamecontrol, i); G_ClearControlKeys(gamecontrolbis, i); @@ -676,92 +676,92 @@ void G_DefineDefaultControls(void) INT32 i; // FPS game controls (WASD) - gamecontroldefault[gcs_fps][gc_forward ][0] = 'w'; - gamecontroldefault[gcs_fps][gc_backward ][0] = 's'; - gamecontroldefault[gcs_fps][gc_strafeleft ][0] = 'a'; - gamecontroldefault[gcs_fps][gc_straferight][0] = 'd'; - gamecontroldefault[gcs_fps][gc_lookup ][0] = KEY_UPARROW; - gamecontroldefault[gcs_fps][gc_lookdown ][0] = KEY_DOWNARROW; - gamecontroldefault[gcs_fps][gc_turnleft ][0] = KEY_LEFTARROW; - gamecontroldefault[gcs_fps][gc_turnright ][0] = KEY_RIGHTARROW; - gamecontroldefault[gcs_fps][gc_centerview ][0] = KEY_END; - gamecontroldefault[gcs_fps][gc_jump ][0] = KEY_SPACE; - gamecontroldefault[gcs_fps][gc_spin ][0] = KEY_LSHIFT; - gamecontroldefault[gcs_fps][gc_fire ][0] = KEY_RCTRL; - gamecontroldefault[gcs_fps][gc_fire ][1] = KEY_MOUSE1+0; - gamecontroldefault[gcs_fps][gc_firenormal ][0] = 'c'; + gamecontroldefault[gcs_fps][GC_FORWARD ][0] = 'w'; + gamecontroldefault[gcs_fps][GC_BACKWARD ][0] = 's'; + gamecontroldefault[gcs_fps][GC_STRAFELEFT ][0] = 'a'; + gamecontroldefault[gcs_fps][GC_STRAFERIGHT][0] = 'd'; + gamecontroldefault[gcs_fps][GC_LOOKUP ][0] = KEY_UPARROW; + gamecontroldefault[gcs_fps][GC_LOOKDOWN ][0] = KEY_DOWNARROW; + gamecontroldefault[gcs_fps][GC_TURNLEFT ][0] = KEY_LEFTARROW; + gamecontroldefault[gcs_fps][GC_TURNRIGHT ][0] = KEY_RIGHTARROW; + gamecontroldefault[gcs_fps][GC_CENTERVIEW ][0] = KEY_END; + gamecontroldefault[gcs_fps][GC_JUMP ][0] = KEY_SPACE; + gamecontroldefault[gcs_fps][GC_SPIN ][0] = KEY_LSHIFT; + gamecontroldefault[gcs_fps][GC_FIRE ][0] = KEY_RCTRL; + gamecontroldefault[gcs_fps][GC_FIRE ][1] = KEY_MOUSE1+0; + gamecontroldefault[gcs_fps][GC_FIRENORMAL ][0] = 'c'; // Platform game controls (arrow keys) - gamecontroldefault[gcs_platform][gc_forward ][0] = KEY_UPARROW; - gamecontroldefault[gcs_platform][gc_backward ][0] = KEY_DOWNARROW; - gamecontroldefault[gcs_platform][gc_strafeleft ][0] = 'a'; - gamecontroldefault[gcs_platform][gc_straferight][0] = 'd'; - gamecontroldefault[gcs_platform][gc_lookup ][0] = KEY_PGUP; - gamecontroldefault[gcs_platform][gc_lookdown ][0] = KEY_PGDN; - gamecontroldefault[gcs_platform][gc_turnleft ][0] = KEY_LEFTARROW; - gamecontroldefault[gcs_platform][gc_turnright ][0] = KEY_RIGHTARROW; - gamecontroldefault[gcs_platform][gc_centerview ][0] = KEY_END; - gamecontroldefault[gcs_platform][gc_jump ][0] = KEY_SPACE; - gamecontroldefault[gcs_platform][gc_spin ][0] = KEY_LSHIFT; - gamecontroldefault[gcs_platform][gc_fire ][0] = 's'; - gamecontroldefault[gcs_platform][gc_fire ][1] = KEY_MOUSE1+0; - gamecontroldefault[gcs_platform][gc_firenormal ][0] = 'w'; + gamecontroldefault[gcs_platform][GC_FORWARD ][0] = KEY_UPARROW; + gamecontroldefault[gcs_platform][GC_BACKWARD ][0] = KEY_DOWNARROW; + gamecontroldefault[gcs_platform][GC_STRAFELEFT ][0] = 'a'; + gamecontroldefault[gcs_platform][GC_STRAFERIGHT][0] = 'd'; + gamecontroldefault[gcs_platform][GC_LOOKUP ][0] = KEY_PGUP; + gamecontroldefault[gcs_platform][GC_LOOKDOWN ][0] = KEY_PGDN; + gamecontroldefault[gcs_platform][GC_TURNLEFT ][0] = KEY_LEFTARROW; + gamecontroldefault[gcs_platform][GC_TURNRIGHT ][0] = KEY_RIGHTARROW; + gamecontroldefault[gcs_platform][GC_CENTERVIEW ][0] = KEY_END; + gamecontroldefault[gcs_platform][GC_JUMP ][0] = KEY_SPACE; + gamecontroldefault[gcs_platform][GC_SPIN ][0] = KEY_LSHIFT; + gamecontroldefault[gcs_platform][GC_FIRE ][0] = 's'; + gamecontroldefault[gcs_platform][GC_FIRE ][1] = KEY_MOUSE1+0; + gamecontroldefault[gcs_platform][GC_FIRENORMAL ][0] = 'w'; for (i = 1; i < num_gamecontrolschemes; i++) // skip gcs_custom (0) { - gamecontroldefault[i][gc_weaponnext ][0] = KEY_MOUSEWHEELUP+0; - gamecontroldefault[i][gc_weaponprev ][0] = KEY_MOUSEWHEELDOWN+0; - gamecontroldefault[i][gc_wepslot1 ][0] = '1'; - gamecontroldefault[i][gc_wepslot2 ][0] = '2'; - gamecontroldefault[i][gc_wepslot3 ][0] = '3'; - gamecontroldefault[i][gc_wepslot4 ][0] = '4'; - gamecontroldefault[i][gc_wepslot5 ][0] = '5'; - gamecontroldefault[i][gc_wepslot6 ][0] = '6'; - gamecontroldefault[i][gc_wepslot7 ][0] = '7'; - gamecontroldefault[i][gc_wepslot8 ][0] = '8'; - gamecontroldefault[i][gc_wepslot9 ][0] = '9'; - gamecontroldefault[i][gc_wepslot10 ][0] = '0'; - gamecontroldefault[i][gc_tossflag ][0] = '\''; - gamecontroldefault[i][gc_camtoggle ][0] = 'v'; - gamecontroldefault[i][gc_camreset ][0] = 'r'; - gamecontroldefault[i][gc_talkkey ][0] = 't'; - gamecontroldefault[i][gc_teamkey ][0] = 'y'; - gamecontroldefault[i][gc_scores ][0] = KEY_TAB; - gamecontroldefault[i][gc_console ][0] = KEY_CONSOLE; - gamecontroldefault[i][gc_pause ][0] = 'p'; - gamecontroldefault[i][gc_screenshot ][0] = KEY_F8; - gamecontroldefault[i][gc_recordgif ][0] = KEY_F9; - gamecontroldefault[i][gc_viewpoint ][0] = KEY_F12; + gamecontroldefault[i][GC_WEAPONNEXT ][0] = KEY_MOUSEWHEELUP+0; + gamecontroldefault[i][GC_WEAPONPREV ][0] = KEY_MOUSEWHEELDOWN+0; + gamecontroldefault[i][GC_WEPSLOT1 ][0] = '1'; + gamecontroldefault[i][GC_WEPSLOT2 ][0] = '2'; + gamecontroldefault[i][GC_WEPSLOT3 ][0] = '3'; + gamecontroldefault[i][GC_WEPSLOT4 ][0] = '4'; + gamecontroldefault[i][GC_WEPSLOT5 ][0] = '5'; + gamecontroldefault[i][GC_WEPSLOT6 ][0] = '6'; + gamecontroldefault[i][GC_WEPSLOT7 ][0] = '7'; + gamecontroldefault[i][GC_WEPSLOT8 ][0] = '8'; + gamecontroldefault[i][GC_WEPSLOT9 ][0] = '9'; + gamecontroldefault[i][GC_WEPSLOT10 ][0] = '0'; + gamecontroldefault[i][GC_TOSSFLAG ][0] = '\''; + gamecontroldefault[i][GC_CAMTOGGLE ][0] = 'v'; + gamecontroldefault[i][GC_CAMRESET ][0] = 'r'; + gamecontroldefault[i][GC_TALKKEY ][0] = 't'; + gamecontroldefault[i][GC_TEAMKEY ][0] = 'y'; + gamecontroldefault[i][GC_SCORES ][0] = KEY_TAB; + gamecontroldefault[i][GC_CONSOLE ][0] = KEY_CONSOLE; + gamecontroldefault[i][GC_PAUSE ][0] = 'p'; + gamecontroldefault[i][GC_SCREENSHOT ][0] = KEY_F8; + gamecontroldefault[i][GC_RECORDGIF ][0] = KEY_F9; + gamecontroldefault[i][GC_VIEWPOINT ][0] = KEY_F12; // Gamepad controls -- same for both schemes - gamecontroldefault[i][gc_weaponnext ][1] = KEY_JOY1+1; // B - gamecontroldefault[i][gc_weaponprev ][1] = KEY_JOY1+2; // X - gamecontroldefault[i][gc_tossflag ][1] = KEY_JOY1+0; // A - gamecontroldefault[i][gc_spin ][1] = KEY_JOY1+4; // LB - gamecontroldefault[i][gc_camtoggle ][1] = KEY_HAT1+0; // D-Pad Up - gamecontroldefault[i][gc_camreset ][1] = KEY_JOY1+3; // Y - gamecontroldefault[i][gc_centerview ][1] = KEY_JOY1+9; // Right Stick - gamecontroldefault[i][gc_talkkey ][1] = KEY_HAT1+2; // D-Pad Left - gamecontroldefault[i][gc_scores ][1] = KEY_HAT1+3; // D-Pad Right - gamecontroldefault[i][gc_jump ][1] = KEY_JOY1+5; // RB - gamecontroldefault[i][gc_pause ][1] = KEY_JOY1+6; // Back - gamecontroldefault[i][gc_screenshot ][1] = KEY_HAT1+1; // D-Pad Down - gamecontroldefault[i][gc_systemmenu ][0] = KEY_JOY1+7; // Start + gamecontroldefault[i][GC_WEAPONNEXT ][1] = KEY_JOY1+1; // B + gamecontroldefault[i][GC_WEAPONPREV ][1] = KEY_JOY1+2; // X + gamecontroldefault[i][GC_TOSSFLAG ][1] = KEY_JOY1+0; // A + gamecontroldefault[i][GC_SPIN ][1] = KEY_JOY1+4; // LB + gamecontroldefault[i][GC_CAMTOGGLE ][1] = KEY_HAT1+0; // D-Pad Up + gamecontroldefault[i][GC_CAMRESET ][1] = KEY_JOY1+3; // Y + gamecontroldefault[i][GC_CENTERVIEW ][1] = KEY_JOY1+9; // Right Stick + gamecontroldefault[i][GC_TALKKEY ][1] = KEY_HAT1+2; // D-Pad Left + gamecontroldefault[i][GC_SCORES ][1] = KEY_HAT1+3; // D-Pad Right + gamecontroldefault[i][GC_JUMP ][1] = KEY_JOY1+5; // RB + gamecontroldefault[i][GC_PAUSE ][1] = KEY_JOY1+6; // Back + gamecontroldefault[i][GC_SCREENSHOT ][1] = KEY_HAT1+1; // D-Pad Down + gamecontroldefault[i][GC_SYSTEMMENU ][0] = KEY_JOY1+7; // Start // Second player controls only have joypad defaults - gamecontrolbisdefault[i][gc_weaponnext][0] = KEY_2JOY1+1; // B - gamecontrolbisdefault[i][gc_weaponprev][0] = KEY_2JOY1+2; // X - gamecontrolbisdefault[i][gc_tossflag ][0] = KEY_2JOY1+0; // A - gamecontrolbisdefault[i][gc_spin ][0] = KEY_2JOY1+4; // LB - gamecontrolbisdefault[i][gc_camreset ][0] = KEY_2JOY1+3; // Y - gamecontrolbisdefault[i][gc_centerview][0] = KEY_2JOY1+9; // Right Stick - gamecontrolbisdefault[i][gc_jump ][0] = KEY_2JOY1+5; // RB - //gamecontrolbisdefault[i][gc_pause ][0] = KEY_2JOY1+6; // Back - //gamecontrolbisdefault[i][gc_systemmenu][0] = KEY_2JOY1+7; // Start - gamecontrolbisdefault[i][gc_camtoggle ][0] = KEY_2HAT1+0; // D-Pad Up - gamecontrolbisdefault[i][gc_screenshot][0] = KEY_2HAT1+1; // D-Pad Down - //gamecontrolbisdefault[i][gc_talkkey ][0] = KEY_2HAT1+2; // D-Pad Left - //gamecontrolbisdefault[i][gc_scores ][0] = KEY_2HAT1+3; // D-Pad Right + gamecontrolbisdefault[i][GC_WEAPONNEXT][0] = KEY_2JOY1+1; // B + gamecontrolbisdefault[i][GC_WEAPONPREV][0] = KEY_2JOY1+2; // X + gamecontrolbisdefault[i][GC_TOSSFLAG ][0] = KEY_2JOY1+0; // A + gamecontrolbisdefault[i][GC_SPIN ][0] = KEY_2JOY1+4; // LB + gamecontrolbisdefault[i][GC_CAMRESET ][0] = KEY_2JOY1+3; // Y + gamecontrolbisdefault[i][GC_CENTERVIEW][0] = KEY_2JOY1+9; // Right Stick + gamecontrolbisdefault[i][GC_JUMP ][0] = KEY_2JOY1+5; // RB + //gamecontrolbisdefault[i][GC_PAUSE ][0] = KEY_2JOY1+6; // Back + //gamecontrolbisdefault[i][GC_SYSTEMMENU][0] = KEY_2JOY1+7; // Start + gamecontrolbisdefault[i][GC_CAMTOGGLE ][0] = KEY_2HAT1+0; // D-Pad Up + gamecontrolbisdefault[i][GC_SCREENSHOT][0] = KEY_2HAT1+1; // D-Pad Down + //gamecontrolbisdefault[i][GC_TALKKEY ][0] = KEY_2HAT1+2; // D-Pad Left + //gamecontrolbisdefault[i][GC_SCORES ][0] = KEY_2HAT1+3; // D-Pad Right } } @@ -773,7 +773,7 @@ INT32 G_GetControlScheme(INT32 (*fromcontrols)[2], const INT32 *gclist, INT32 gc for (i = 1; i < num_gamecontrolschemes; i++) // skip gcs_custom (0) { skipscheme = false; - for (j = 0; j < (gclist && gclen ? gclen : num_gamecontrols); j++) + for (j = 0; j < (gclist && gclen ? gclen : NUM_GAMECONTROLS); j++) { gc = (gclist && gclen) ? gclist[j] : j; if (((fromcontrols[gc][0] && gamecontroldefault[i][gc][0]) ? fromcontrols[gc][0] != gamecontroldefault[i][gc][0] : true) && @@ -796,7 +796,7 @@ void G_CopyControls(INT32 (*setupcontrols)[2], INT32 (*fromcontrols)[2], const I { INT32 i, gc; - for (i = 0; i < (gclist && gclen ? gclen : num_gamecontrols); i++) + for (i = 0; i < (gclist && gclen ? gclen : NUM_GAMECONTROLS); i++) { gc = (gclist && gclen) ? gclist[i] : i; setupcontrols[gc][0] = fromcontrols[gc][0]; @@ -808,7 +808,7 @@ void G_SaveKeySetting(FILE *f, INT32 (*fromcontrols)[2], INT32 (*fromcontrolsbis { INT32 i; - for (i = 1; i < num_gamecontrols; i++) + for (i = 1; i < NUM_GAMECONTROLS; i++) { fprintf(f, "setcontrol \"%s\" \"%s\"", gamecontrolname[i], G_KeyNumToName(fromcontrols[i][0])); @@ -819,7 +819,7 @@ void G_SaveKeySetting(FILE *f, INT32 (*fromcontrols)[2], INT32 (*fromcontrolsbis fprintf(f, "\n"); } - for (i = 1; i < num_gamecontrols; i++) + for (i = 1; i < NUM_GAMECONTROLS; i++) { fprintf(f, "setcontrol2 \"%s\" \"%s\"", gamecontrolname[i], G_KeyNumToName(fromcontrolsbis[i][0])); @@ -833,11 +833,11 @@ void G_SaveKeySetting(FILE *f, INT32 (*fromcontrols)[2], INT32 (*fromcontrolsbis INT32 G_CheckDoubleUsage(INT32 keynum, boolean modify) { - INT32 result = gc_null; + INT32 result = GC_NULL; if (cv_controlperkey.value == 1) { INT32 i; - for (i = 0; i < num_gamecontrols; i++) + for (i = 0; i < NUM_GAMECONTROLS; i++) { if (gamecontrol[i][0] == keynum) { @@ -883,11 +883,11 @@ static INT32 G_FilterKeyByVersion(INT32 numctrl, INT32 keyidx, INT32 player, INT return -1; // skip setting control if (GETMAJOREXECVERSION(cv_execversion.value) < 27 && ( // v2.1.22 - numctrl == gc_weaponnext || numctrl == gc_weaponprev || numctrl == gc_tossflag || - numctrl == gc_spin || numctrl == gc_camreset || numctrl == gc_jump || - numctrl == gc_pause || numctrl == gc_systemmenu || numctrl == gc_camtoggle || - numctrl == gc_screenshot || numctrl == gc_talkkey || numctrl == gc_scores || - numctrl == gc_centerview + numctrl == GC_WEAPONNEXT || numctrl == GC_WEAPONPREV || numctrl == GC_TOSSFLAG || + numctrl == GC_SPIN || numctrl == GC_CAMRESET || numctrl == GC_JUMP || + numctrl == GC_PAUSE || numctrl == GC_SYSTEMMENU || numctrl == GC_CAMTOGGLE || + numctrl == GC_SCREENSHOT || numctrl == GC_TALKKEY || numctrl == GC_SCORES || + numctrl == GC_CENTERVIEW )) { INT32 keynum = 0, existingctrl = 0; @@ -895,7 +895,7 @@ static INT32 G_FilterKeyByVersion(INT32 numctrl, INT32 keyidx, INT32 player, INT boolean defaultoverride = false; // get the default gamecontrol - if (player == 0 && numctrl == gc_systemmenu) + if (player == 0 && numctrl == GC_SYSTEMMENU) defaultkey = gamecontrol[numctrl][0]; else defaultkey = (player == 1 ? gamecontrolbis[numctrl][0] : gamecontrol[numctrl][1]); @@ -993,10 +993,10 @@ static void setcontrol(INT32 (*gc)[2]) // Update me for 2.3 namectrl = (stricmp(COM_Argv(1), "use")) ? COM_Argv(1) : "spin"; - for (numctrl = 0; numctrl < num_gamecontrols && stricmp(namectrl, gamecontrolname[numctrl]); + for (numctrl = 0; numctrl < NUM_GAMECONTROLS && stricmp(namectrl, gamecontrolname[numctrl]); numctrl++) ; - if (numctrl == num_gamecontrols) + if (numctrl == NUM_GAMECONTROLS) { CONS_Printf(M_GetText("Control '%s' unknown\n"), namectrl); return; diff --git a/src/g_input.h b/src/g_input.h index 39c0180e7..2e9f53dcf 100644 --- a/src/g_input.h +++ b/src/g_input.h @@ -58,49 +58,49 @@ typedef enum typedef enum { - gc_null = 0, // a key/button mapped to gc_null has no effect - gc_forward, - gc_backward, - gc_strafeleft, - gc_straferight, - gc_turnleft, - gc_turnright, - gc_weaponnext, - gc_weaponprev, - gc_wepslot1, - gc_wepslot2, - gc_wepslot3, - gc_wepslot4, - gc_wepslot5, - gc_wepslot6, - gc_wepslot7, - gc_wepslot8, - gc_wepslot9, - gc_wepslot10, - gc_fire, - gc_firenormal, - gc_tossflag, - gc_spin, - gc_camtoggle, - gc_camreset, - gc_lookup, - gc_lookdown, - gc_centerview, - gc_mouseaiming, // mouse aiming is momentary (toggleable in the menu) - gc_talkkey, - gc_teamkey, - gc_scores, - gc_jump, - gc_console, - gc_pause, - gc_systemmenu, - gc_screenshot, - gc_recordgif, - gc_viewpoint, - gc_custom1, // Lua scriptable - gc_custom2, // Lua scriptable - gc_custom3, // Lua scriptable - num_gamecontrols + GC_NULL = 0, // a key/button mapped to GC_NULL has no effect + GC_FORWARD, + GC_BACKWARD, + GC_STRAFELEFT, + GC_STRAFERIGHT, + GC_TURNLEFT, + GC_TURNRIGHT, + GC_WEAPONNEXT, + GC_WEAPONPREV, + GC_WEPSLOT1, + GC_WEPSLOT2, + GC_WEPSLOT3, + GC_WEPSLOT4, + GC_WEPSLOT5, + GC_WEPSLOT6, + GC_WEPSLOT7, + GC_WEPSLOT8, + GC_WEPSLOT9, + GC_WEPSLOT10, + GC_FIRE, + GC_FIRENORMAL, + GC_TOSSFLAG, + GC_SPIN, + GC_CAMTOGGLE, + GC_CAMRESET, + GC_LOOKUP, + GC_LOOKDOWN, + GC_CENTERVIEW, + GC_MOUSEAIMING, // mouse aiming is momentary (toggleable in the menu) + GC_TALKKEY, + GC_TEAMKEY, + GC_SCORES, + GC_JUMP, + GC_CONSOLE, + GC_PAUSE, + GC_SYSTEMMENU, + GC_SCREENSHOT, + GC_RECORDGIF, + GC_VIEWPOINT, + GC_CUSTOM1, // Lua scriptable + GC_CUSTOM2, // Lua scriptable + GC_CUSTOM3, // Lua scriptable + NUM_GAMECONTROLS } gamecontrols_e; typedef enum @@ -146,10 +146,10 @@ extern INT32 joyxmove[JOYAXISSET], joyymove[JOYAXISSET], joy2xmove[JOYAXISSET], extern UINT8 gamekeydown[NUMINPUTS]; // two key codes (or virtual key) per game control -extern INT32 gamecontrol[num_gamecontrols][2]; -extern INT32 gamecontrolbis[num_gamecontrols][2]; // secondary splitscreen player -extern INT32 gamecontroldefault[num_gamecontrolschemes][num_gamecontrols][2]; // default control storage, use 0 (gcs_custom) for memory retention -extern INT32 gamecontrolbisdefault[num_gamecontrolschemes][num_gamecontrols][2]; +extern INT32 gamecontrol[NUM_GAMECONTROLS][2]; +extern INT32 gamecontrolbis[NUM_GAMECONTROLS][2]; // secondary splitscreen player +extern INT32 gamecontroldefault[num_gamecontrolschemes][NUM_GAMECONTROLS][2]; // default control storage, use 0 (gcs_custom) for memory retention +extern INT32 gamecontrolbisdefault[num_gamecontrolschemes][NUM_GAMECONTROLS][2]; #define PLAYER1INPUTDOWN(gc) (gamekeydown[gamecontrol[gc][0]] || gamekeydown[gamecontrol[gc][1]]) #define PLAYER2INPUTDOWN(gc) (gamekeydown[gamecontrolbis[gc][0]] || gamekeydown[gamecontrolbis[gc][1]]) #define PLAYERINPUTDOWN(p, gc) ((p) == 2 ? PLAYER2INPUTDOWN(gc) : PLAYER1INPUTDOWN(gc)) diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 3bd263210..d8891d508 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -936,7 +936,7 @@ void HU_Ticker(void) hu_tick++; hu_tick &= 7; // currently only to blink chat input cursor - if (PLAYER1INPUTDOWN(gc_scores)) + if (PLAYER1INPUTDOWN(GC_SCORES)) hu_showscores = !chat_on; else hu_showscores = false; @@ -1114,13 +1114,13 @@ boolean HU_Responder(event_t *ev) if (ev->key >= KEY_MOUSE1) { INT32 i; - for (i = 0; i < num_gamecontrols; i++) + for (i = 0; i < NUM_GAMECONTROLS; i++) { if (gamecontrol[i][0] == ev->key || gamecontrol[i][1] == ev->key) break; } - if (i == num_gamecontrols) + if (i == NUM_GAMECONTROLS) return false; }*/ //We don't actually care about that unless we get splitscreen netgames. :V @@ -1130,7 +1130,7 @@ boolean HU_Responder(event_t *ev) if (!chat_on) { // enter chat mode - if ((ev->key == gamecontrol[gc_talkkey][0] || ev->key == gamecontrol[gc_talkkey][1]) + if ((ev->key == gamecontrol[GC_TALKKEY][0] || ev->key == gamecontrol[GC_TALKKEY][1]) && netgame && !OLD_MUTE) // check for old chat mute, still let the players open the chat incase they want to scroll otherwise. { chat_on = true; @@ -1140,7 +1140,7 @@ boolean HU_Responder(event_t *ev) typelines = 1; return true; } - if ((ev->key == gamecontrol[gc_teamkey][0] || ev->key == gamecontrol[gc_teamkey][1]) + if ((ev->key == gamecontrol[GC_TEAMKEY][0] || ev->key == gamecontrol[GC_TEAMKEY][1]) && netgame && !OLD_MUTE) { chat_on = true; @@ -1234,8 +1234,8 @@ boolean HU_Responder(event_t *ev) I_UpdateMouseGrab(); } else if (c == KEY_ESCAPE - || ((c == gamecontrol[gc_talkkey][0] || c == gamecontrol[gc_talkkey][1] - || c == gamecontrol[gc_teamkey][0] || c == gamecontrol[gc_teamkey][1]) + || ((c == gamecontrol[GC_TALKKEY][0] || c == gamecontrol[GC_TALKKEY][1] + || c == gamecontrol[GC_TEAMKEY][0] || c == gamecontrol[GC_TEAMKEY][1]) && c >= KEY_MOUSE1)) // If it's not a keyboard key, then the chat button is used as a toggle. { chat_on = false; diff --git a/src/lua_inputlib.c b/src/lua_inputlib.c index 3affeea7b..6e3085e94 100644 --- a/src/lua_inputlib.c +++ b/src/lua_inputlib.c @@ -26,8 +26,8 @@ static int lib_gameControlDown(lua_State *L) { int i = luaL_checkinteger(L, 1); - if (i < 0 || i >= num_gamecontrols) - return luaL_error(L, "gc_* constant %d out of range (0 - %d)", i, num_gamecontrols-1); + if (i < 0 || i >= NUM_GAMECONTROLS) + return luaL_error(L, "GC_* constant %d out of range (0 - %d)", i, NUM_GAMECONTROLS-1); lua_pushinteger(L, PLAYER1INPUTDOWN(i)); return 1; } @@ -35,8 +35,8 @@ static int lib_gameControlDown(lua_State *L) static int lib_gameControl2Down(lua_State *L) { int i = luaL_checkinteger(L, 1); - if (i < 0 || i >= num_gamecontrols) - return luaL_error(L, "gc_* constant %d out of range (0 - %d)", i, num_gamecontrols-1); + if (i < 0 || i >= NUM_GAMECONTROLS) + return luaL_error(L, "GC_* constant %d out of range (0 - %d)", i, NUM_GAMECONTROLS-1); lua_pushinteger(L, PLAYER2INPUTDOWN(i)); return 1; } @@ -44,8 +44,8 @@ static int lib_gameControl2Down(lua_State *L) static int lib_gameControlToKeyNum(lua_State *L) { int i = luaL_checkinteger(L, 1); - if (i < 0 || i >= num_gamecontrols) - return luaL_error(L, "gc_* constant %d out of range (0 - %d)", i, num_gamecontrols-1); + if (i < 0 || i >= NUM_GAMECONTROLS) + return luaL_error(L, "GC_* constant %d out of range (0 - %d)", i, NUM_GAMECONTROLS-1); lua_pushinteger(L, gamecontrol[i][0]); lua_pushinteger(L, gamecontrol[i][1]); return 2; @@ -54,8 +54,8 @@ static int lib_gameControlToKeyNum(lua_State *L) static int lib_gameControl2ToKeyNum(lua_State *L) { int i = luaL_checkinteger(L, 1); - if (i < 0 || i >= num_gamecontrols) - return luaL_error(L, "gc_* constant %d out of range (0 - %d)", i, num_gamecontrols-1); + if (i < 0 || i >= NUM_GAMECONTROLS) + return luaL_error(L, "GC_* constant %d out of range (0 - %d)", i, NUM_GAMECONTROLS-1); lua_pushinteger(L, gamecontrolbis[i][0]); lua_pushinteger(L, gamecontrolbis[i][1]); return 2; diff --git a/src/m_menu.c b/src/m_menu.c index 4a0fefb1b..56d7e889e 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1106,55 +1106,55 @@ static menuitem_t OP_ChangeControlsMenu[] = { {IT_HEADER, NULL, "Movement", NULL, 0}, {IT_SPACE, NULL, NULL, NULL, 0}, // padding - {IT_CALL | IT_STRING2, NULL, "Move Forward", M_ChangeControl, gc_forward }, - {IT_CALL | IT_STRING2, NULL, "Move Backward", M_ChangeControl, gc_backward }, - {IT_CALL | IT_STRING2, NULL, "Move Left", M_ChangeControl, gc_strafeleft }, - {IT_CALL | IT_STRING2, NULL, "Move Right", M_ChangeControl, gc_straferight }, - {IT_CALL | IT_STRING2, NULL, "Jump", M_ChangeControl, gc_jump }, - {IT_CALL | IT_STRING2, NULL, "Spin", M_ChangeControl, gc_spin }, + {IT_CALL | IT_STRING2, NULL, "Move Forward", M_ChangeControl, GC_FORWARD }, + {IT_CALL | IT_STRING2, NULL, "Move Backward", M_ChangeControl, GC_BACKWARD }, + {IT_CALL | IT_STRING2, NULL, "Move Left", M_ChangeControl, GC_STRAFELEFT }, + {IT_CALL | IT_STRING2, NULL, "Move Right", M_ChangeControl, GC_STRAFERIGHT }, + {IT_CALL | IT_STRING2, NULL, "Jump", M_ChangeControl, GC_JUMP }, + {IT_CALL | IT_STRING2, NULL, "Spin", M_ChangeControl, GC_SPIN }, {IT_HEADER, NULL, "Camera", NULL, 0}, {IT_SPACE, NULL, NULL, NULL, 0}, // padding - {IT_CALL | IT_STRING2, NULL, "Look Up", M_ChangeControl, gc_lookup }, - {IT_CALL | IT_STRING2, NULL, "Look Down", M_ChangeControl, gc_lookdown }, - {IT_CALL | IT_STRING2, NULL, "Look Left", M_ChangeControl, gc_turnleft }, - {IT_CALL | IT_STRING2, NULL, "Look Right", M_ChangeControl, gc_turnright }, - {IT_CALL | IT_STRING2, NULL, "Center View", M_ChangeControl, gc_centerview }, - {IT_CALL | IT_STRING2, NULL, "Toggle Mouselook", M_ChangeControl, gc_mouseaiming }, - {IT_CALL | IT_STRING2, NULL, "Toggle Third-Person", M_ChangeControl, gc_camtoggle}, - {IT_CALL | IT_STRING2, NULL, "Reset Camera", M_ChangeControl, gc_camreset }, + {IT_CALL | IT_STRING2, NULL, "Look Up", M_ChangeControl, GC_LOOKUP }, + {IT_CALL | IT_STRING2, NULL, "Look Down", M_ChangeControl, GC_LOOKDOWN }, + {IT_CALL | IT_STRING2, NULL, "Look Left", M_ChangeControl, GC_TURNLEFT }, + {IT_CALL | IT_STRING2, NULL, "Look Right", M_ChangeControl, GC_TURNRIGHT }, + {IT_CALL | IT_STRING2, NULL, "Center View", M_ChangeControl, GC_CENTERVIEW }, + {IT_CALL | IT_STRING2, NULL, "Toggle Mouselook", M_ChangeControl, GC_MOUSEAIMING }, + {IT_CALL | IT_STRING2, NULL, "Toggle Third-Person", M_ChangeControl, GC_CAMTOGGLE}, + {IT_CALL | IT_STRING2, NULL, "Reset Camera", M_ChangeControl, GC_CAMRESET }, {IT_HEADER, NULL, "Meta", NULL, 0}, {IT_SPACE, NULL, NULL, NULL, 0}, // padding {IT_CALL | IT_STRING2, NULL, "Game Status", - M_ChangeControl, gc_scores }, - {IT_CALL | IT_STRING2, NULL, "Pause / Run Retry", M_ChangeControl, gc_pause }, - {IT_CALL | IT_STRING2, NULL, "Screenshot", M_ChangeControl, gc_screenshot }, - {IT_CALL | IT_STRING2, NULL, "Toggle GIF Recording", M_ChangeControl, gc_recordgif }, - {IT_CALL | IT_STRING2, NULL, "Open/Close Menu (ESC)", M_ChangeControl, gc_systemmenu }, - {IT_CALL | IT_STRING2, NULL, "Change Viewpoint", M_ChangeControl, gc_viewpoint }, - {IT_CALL | IT_STRING2, NULL, "Console", M_ChangeControl, gc_console }, + M_ChangeControl, GC_SCORES }, + {IT_CALL | IT_STRING2, NULL, "Pause / Run Retry", M_ChangeControl, GC_PAUSE }, + {IT_CALL | IT_STRING2, NULL, "Screenshot", M_ChangeControl, GC_SCREENSHOT }, + {IT_CALL | IT_STRING2, NULL, "Toggle GIF Recording", M_ChangeControl, GC_RECORDGIF }, + {IT_CALL | IT_STRING2, NULL, "Open/Close Menu (ESC)", M_ChangeControl, GC_SYSTEMMENU }, + {IT_CALL | IT_STRING2, NULL, "Change Viewpoint", M_ChangeControl, GC_VIEWPOINT }, + {IT_CALL | IT_STRING2, NULL, "Console", M_ChangeControl, GC_CONSOLE }, {IT_HEADER, NULL, "Multiplayer", NULL, 0}, {IT_SPACE, NULL, NULL, NULL, 0}, // padding - {IT_CALL | IT_STRING2, NULL, "Talk", M_ChangeControl, gc_talkkey }, - {IT_CALL | IT_STRING2, NULL, "Talk (Team only)", M_ChangeControl, gc_teamkey }, + {IT_CALL | IT_STRING2, NULL, "Talk", M_ChangeControl, GC_TALKKEY }, + {IT_CALL | IT_STRING2, NULL, "Talk (Team only)", M_ChangeControl, GC_TEAMKEY }, {IT_HEADER, NULL, "Ringslinger (Match, CTF, Tag, H&S)", NULL, 0}, {IT_SPACE, NULL, NULL, NULL, 0}, // padding - {IT_CALL | IT_STRING2, NULL, "Fire", M_ChangeControl, gc_fire }, - {IT_CALL | IT_STRING2, NULL, "Fire Normal", M_ChangeControl, gc_firenormal }, - {IT_CALL | IT_STRING2, NULL, "Toss Flag", M_ChangeControl, gc_tossflag }, - {IT_CALL | IT_STRING2, NULL, "Next Weapon", M_ChangeControl, gc_weaponnext }, - {IT_CALL | IT_STRING2, NULL, "Prev Weapon", M_ChangeControl, gc_weaponprev }, - {IT_CALL | IT_STRING2, NULL, "Normal / Infinity", M_ChangeControl, gc_wepslot1 }, - {IT_CALL | IT_STRING2, NULL, "Automatic", M_ChangeControl, gc_wepslot2 }, - {IT_CALL | IT_STRING2, NULL, "Bounce", M_ChangeControl, gc_wepslot3 }, - {IT_CALL | IT_STRING2, NULL, "Scatter", M_ChangeControl, gc_wepslot4 }, - {IT_CALL | IT_STRING2, NULL, "Grenade", M_ChangeControl, gc_wepslot5 }, - {IT_CALL | IT_STRING2, NULL, "Explosion", M_ChangeControl, gc_wepslot6 }, - {IT_CALL | IT_STRING2, NULL, "Rail", M_ChangeControl, gc_wepslot7 }, + {IT_CALL | IT_STRING2, NULL, "Fire", M_ChangeControl, GC_FIRE }, + {IT_CALL | IT_STRING2, NULL, "Fire Normal", M_ChangeControl, GC_FIRENORMAL }, + {IT_CALL | IT_STRING2, NULL, "Toss Flag", M_ChangeControl, GC_TOSSFLAG }, + {IT_CALL | IT_STRING2, NULL, "Next Weapon", M_ChangeControl, GC_WEAPONNEXT }, + {IT_CALL | IT_STRING2, NULL, "Prev Weapon", M_ChangeControl, GC_WEAPONPREV }, + {IT_CALL | IT_STRING2, NULL, "Normal / Infinity", M_ChangeControl, GC_WEPSLOT1 }, + {IT_CALL | IT_STRING2, NULL, "Automatic", M_ChangeControl, GC_WEPSLOT2 }, + {IT_CALL | IT_STRING2, NULL, "Bounce", M_ChangeControl, GC_WEPSLOT3 }, + {IT_CALL | IT_STRING2, NULL, "Scatter", M_ChangeControl, GC_WEPSLOT4 }, + {IT_CALL | IT_STRING2, NULL, "Grenade", M_ChangeControl, GC_WEPSLOT5 }, + {IT_CALL | IT_STRING2, NULL, "Explosion", M_ChangeControl, GC_WEPSLOT6 }, + {IT_CALL | IT_STRING2, NULL, "Rail", M_ChangeControl, GC_WEPSLOT7 }, {IT_HEADER, NULL, "Add-ons", NULL, 0}, {IT_SPACE, NULL, NULL, NULL, 0}, // padding - {IT_CALL | IT_STRING2, NULL, "Custom Action 1", M_ChangeControl, gc_custom1 }, - {IT_CALL | IT_STRING2, NULL, "Custom Action 2", M_ChangeControl, gc_custom2 }, - {IT_CALL | IT_STRING2, NULL, "Custom Action 3", M_ChangeControl, gc_custom3 }, + {IT_CALL | IT_STRING2, NULL, "Custom Action 1", M_ChangeControl, GC_CUSTOM1 }, + {IT_CALL | IT_STRING2, NULL, "Custom Action 2", M_ChangeControl, GC_CUSTOM2 }, + {IT_CALL | IT_STRING2, NULL, "Custom Action 3", M_ChangeControl, GC_CUSTOM3 }, }; static menuitem_t OP_Joystick1Menu[] = @@ -3343,7 +3343,7 @@ boolean M_Responder(event_t *ev) if (ch == -1) return false; - else if (ch == gamecontrol[gc_systemmenu][0] || ch == gamecontrol[gc_systemmenu][1]) // allow remappable ESC key + else if (ch == gamecontrol[GC_SYSTEMMENU][0] || ch == gamecontrol[GC_SYSTEMMENU][1]) // allow remappable ESC key ch = KEY_ESCAPE; // F-Keys @@ -12929,7 +12929,7 @@ static void M_ChangecontrolResponse(event_t *ev) static char tmp[158]; menu_t *prev = currentMenu->prevMenu; - if (controltochange == gc_pause) + if (controltochange == GC_PAUSE) sprintf(tmp, M_GetText("The \x82Pause Key \x80is enabled, but \nit cannot be used to retry runs \nduring Record Attack. \n\nHit another key for\n%s\nESC for Cancel"), controltochangetext); else diff --git a/src/m_misc.c b/src/m_misc.c index f9a23ad44..dcdddf9d5 100644 --- a/src/m_misc.c +++ b/src/m_misc.c @@ -1636,9 +1636,9 @@ boolean M_ScreenshotResponder(event_t *ev) if (ch >= KEY_MOUSE1 && menuactive) // If it's not a keyboard key, then don't allow it in the menus! return false; - if (ch == KEY_F8 || ch == gamecontrol[gc_screenshot][0] || ch == gamecontrol[gc_screenshot][1]) // remappable F8 + if (ch == KEY_F8 || ch == gamecontrol[GC_SCREENSHOT][0] || ch == gamecontrol[GC_SCREENSHOT][1]) // remappable F8 M_ScreenShot(); - else if (ch == KEY_F9 || ch == gamecontrol[gc_recordgif][0] || ch == gamecontrol[gc_recordgif][1]) // remappable F9 + else if (ch == KEY_F9 || ch == gamecontrol[GC_RECORDGIF][0] || ch == gamecontrol[GC_RECORDGIF][1]) // remappable F9 ((moviemode) ? M_StopMovie : M_StartMovie)(); else return false; diff --git a/src/p_user.c b/src/p_user.c index c3184b52f..d12affd1d 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -5357,9 +5357,9 @@ static void P_DoJumpStuff(player_t *player, ticcmd_t *cmd) // disabled because it seemed to disorient people and Z-targeting exists now /*if (!demoplayback) { - if (player == &players[consoleplayer] && cv_cam_turnfacingability[0].value > 0 && !(PLAYER1INPUTDOWN(gc_turnleft) || PLAYER1INPUTDOWN(gc_turnright))) + if (player == &players[consoleplayer] && cv_cam_turnfacingability[0].value > 0 && !(PLAYER1INPUTDOWN(GC_TURNLEFT) || PLAYER1INPUTDOWN(GC_TURNRIGHT))) P_SetPlayerAngle(player, player->mo->angle);; - else if (player == &players[secondarydisplayplayer] && cv_cam_turnfacingability[1].value > 0 && !(PLAYER2INPUTDOWN(gc_turnleft) || PLAYER2INPUTDOWN(gc_turnright))) + else if (player == &players[secondarydisplayplayer] && cv_cam_turnfacingability[1].value > 0 && !(PLAYER2INPUTDOWN(GC_TURNLEFT) || PLAYER2INPUTDOWN(GC_TURNRIGHT))) P_SetPlayerAngle(player, player->mo->angle); }*/ } From 9b7263855e573747cc396c6af6f789fdb95ac5aa Mon Sep 17 00:00:00 2001 From: LJ Sonic Date: Wed, 18 Aug 2021 20:58:13 +0200 Subject: [PATCH 0906/1080] Prevent input.setMouseGrab from interfering with window focus --- src/d_clisrv.c | 4 ++++ src/lua_inputlib.c | 8 +++++--- src/lua_libs.h | 2 ++ src/sdl/i_video.c | 4 ++++ 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 326105a3b..4cf7259bf 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -43,6 +43,7 @@ #include "lzf.h" #include "lua_script.h" #include "lua_hook.h" +#include "lua_libs.h" #include "md5.h" #include "m_perfstats.h" @@ -3331,6 +3332,9 @@ static inline void SV_GenContext(void) // void D_QuitNetGame(void) { + mousegrabbedbylua = true; + I_UpdateMouseGrab(); + if (!netgame || !netbuffer) return; diff --git a/src/lua_inputlib.c b/src/lua_inputlib.c index 6e3085e94..661d93641 100644 --- a/src/lua_inputlib.c +++ b/src/lua_inputlib.c @@ -19,6 +19,8 @@ #include "lua_script.h" #include "lua_libs.h" +boolean mousegrabbedbylua = true; + /////////////// // FUNCTIONS // /////////////// @@ -106,14 +108,14 @@ static int lib_shiftKeyNum(lua_State *L) static int lib_getMouseGrab(lua_State *L) { - lua_pushboolean(L, I_GetMouseGrab()); + lua_pushboolean(L, mousegrabbedbylua); return 1; } static int lib_setMouseGrab(lua_State *L) { - boolean grab = luaL_checkboolean(L, 1); - I_SetMouseGrab(grab); + mousegrabbedbylua = luaL_checkboolean(L, 1); + I_UpdateMouseGrab(); return 0; } diff --git a/src/lua_libs.h b/src/lua_libs.h index de174283c..8903834e8 100644 --- a/src/lua_libs.h +++ b/src/lua_libs.h @@ -12,6 +12,8 @@ extern lua_State *gL; +extern boolean mousegrabbedbylua; + #define MUTABLE_TAGS #define LREG_VALID "VALID_USERDATA" diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index a18ea32ba..97e4a7214 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -73,6 +73,8 @@ #include "../console.h" #include "../command.h" #include "../r_main.h" +#include "../lua_script.h" +#include "../lua_libs.h" #include "../lua_hook.h" #include "sdlmain.h" #ifdef HWRENDER @@ -372,6 +374,8 @@ static boolean IgnoreMouse(void) if (gamestate != GS_LEVEL && gamestate != GS_INTERMISSION && gamestate != GS_CONTINUING && gamestate != GS_CUTSCENE) return true; + if (!mousegrabbedbylua) + return true; return false; } From 4a6acc2c8dcd7cd94305da19f15ff790fae277de Mon Sep 17 00:00:00 2001 From: SteelT Date: Sun, 22 Aug 2021 16:13:40 -0400 Subject: [PATCH 0907/1080] Fix metal recordings not being saved in srb2home --- src/g_demo.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/g_demo.c b/src/g_demo.c index 701f930e5..e75c6a738 100644 --- a/src/g_demo.c +++ b/src/g_demo.c @@ -2422,12 +2422,13 @@ ATTRNORETURN void FUNCNORETURN G_StopMetalRecording(boolean kill) { WRITEUINT8(demo_p, (kill) ? METALDEATH : DEMOMARKER); // add the demo end (or metal death) marker WriteDemoChecksum(); - saved = FIL_WriteFile(va("%sMS.LMP", G_BuildMapName(gamemap)), demobuffer, demo_p - demobuffer); // finally output the file. + sprintf(demoname, "%sMS.LMP", G_BuildMapName(gamemap)); + saved = FIL_WriteFile(va(pandf, srb2home, demoname), demobuffer, demo_p - demobuffer); // finally output the file. } free(demobuffer); metalrecording = false; if (saved) - I_Error("Saved to %sMS.LMP", G_BuildMapName(gamemap)); + I_Error("Saved to %s", demoname); I_Error("Failed to save demo!"); } From 450955cba264ea3dde9eb3f745ff9816307635ce Mon Sep 17 00:00:00 2001 From: Jaime Ita Passos Date: Thu, 26 Aug 2021 13:22:32 -0300 Subject: [PATCH 0908/1080] Fix floor sprite projection --- src/r_plane.c | 124 ++++++++----------------------------------------- src/r_plane.h | 1 - src/r_splats.c | 91 ++++++++++++++---------------------- src/r_splats.h | 3 +- src/r_things.c | 5 +- src/r_things.h | 10 +++- 6 files changed, 68 insertions(+), 166 deletions(-) diff --git a/src/r_plane.c b/src/r_plane.c index 818770906..d844048ae 100644 --- a/src/r_plane.c +++ b/src/r_plane.c @@ -89,8 +89,6 @@ static fixed_t planeheight; fixed_t yslopetab[MAXVIDHEIGHT*16]; fixed_t *yslope; -fixed_t basexscale, baseyscale; - fixed_t cachedheight[MAXVIDHEIGHT]; fixed_t cacheddistance[MAXVIDHEIGHT]; fixed_t cachedxstep[MAXVIDHEIGHT]; @@ -114,7 +112,7 @@ void R_InitPlanes(void) // Sets planeripple.xfrac and planeripple.yfrac, added to ds_xfrac and ds_yfrac, if the span is not tilted. // -struct +static struct { INT32 offset; fixed_t xfrac, yfrac; @@ -143,15 +141,6 @@ static void R_UpdatePlaneRipple(void) planeripple.offset = (leveltime * 140); } -// -// R_MapPlane -// -// Uses global vars: -// planeheight -// basexscale -// baseyscale -// centerx - static void R_MapPlane(INT32 y, INT32 x1, INT32 x2) { angle_t angle, planecos, planesin; @@ -176,16 +165,13 @@ static void R_MapPlane(INT32 y, INT32 x1, INT32 x2) cacheddistance[y] = distance = FixedMul(planeheight, yslope[y]); span = abs(centery - y); - if (span) // don't divide by zero + if (span) // Don't divide by zero { ds_xstep = FixedMul(planesin, planeheight) / span; ds_ystep = FixedMul(planecos, planeheight) / span; } else - { - ds_xstep = FixedMul(distance, basexscale); - ds_ystep = FixedMul(distance, baseyscale); - } + ds_xstep = ds_ystep = FRACUNIT; cachedxstep[y] = ds_xstep; cachedystep[y] = ds_ystep; @@ -197,6 +183,11 @@ static void R_MapPlane(INT32 y, INT32 x1, INT32 x2) ds_ystep = cachedystep[y]; } + // [RH] Instead of using the xtoviewangle array, I calculated the fractional values + // at the middle of the screen, then used the calculated ds_xstep and ds_ystep + // to step from those to the proper texture coordinate to start drawing at. + // That way, the texture coordinate is always calculated by its position + // on the screen and not by its position relative to the edge of the visplane. ds_xfrac = xoffs + FixedMul(planecos, distance) + (x1 - centerx) * ds_xstep; ds_yfrac = yoffs - FixedMul(planesin, distance) + (x1 - centerx) * ds_ystep; @@ -295,7 +286,6 @@ void R_ClearFFloorClips (void) void R_ClearPlanes(void) { INT32 i, p; - angle_t angle; // opening / clipping determination for (i = 0; i < viewwidth; i++) @@ -321,13 +311,6 @@ void R_ClearPlanes(void) // texture calculation memset(cachedheight, 0, sizeof (cachedheight)); - - // left to right mapping - angle = (viewangle-ANGLE_90)>>ANGLETOFINESHIFT; - - // scale will be unit scale at SCREENWIDTH/2 distance - basexscale = FixedDiv (FINECOSINE(angle),centerxfrac); - baseyscale = -FixedDiv (FINESINE(angle),centerxfrac); } static visplane_t *new_visplane(unsigned hash) @@ -532,53 +515,22 @@ visplane_t *R_CheckPlane(visplane_t *pl, INT32 start, INT32 stop) // // R_ExpandPlane // -// This function basically expands the visplane or I_Errors. +// This function basically expands the visplane. // The reason for this is that when creating 3D floor planes, there is no // need to create new ones with R_CheckPlane, because 3D floor planes // are created by subsector and there is no way a subsector can graphically // overlap. void R_ExpandPlane(visplane_t *pl, INT32 start, INT32 stop) { -// INT32 unionl, unionh; -// INT32 x; - // Don't expand polyobject planes here - we do that on our own. if (pl->polyobj) return; if (pl->minx > start) pl->minx = start; if (pl->maxx < stop) pl->maxx = stop; -/* - if (start < pl->minx) - { - unionl = start; - } - else - { - unionl = pl->minx; - } - - if (stop > pl->maxx) - { - unionh = stop; - } - else - { - unionh = pl->maxx; - } - for (x = start; x <= stop; x++) - if (pl->top[x] != 0xffff || pl->bottom[x] != 0x0000) - break; - - if (x <= stop) - I_Error("R_ExpandPlane: planes in same subsector overlap?!\nminx: %d, maxx: %d, start: %d, stop: %d\n", pl->minx, pl->maxx, start, stop); - - pl->minx = unionl, pl->maxx = unionh; -*/ - } -static void R_MakeSpans(INT32 x, INT32 t1, INT32 b1, INT32 t2, INT32 b2) +static void R_MakeSpans(void (*mapfunc)(INT32, INT32, INT32), INT32 x, INT32 t1, INT32 b1, INT32 t2, INT32 b2) { // Alam: from r_splats's R_RasterizeFloorSplat if (t1 >= vid.height) t1 = vid.height-1; @@ -589,38 +541,12 @@ static void R_MakeSpans(INT32 x, INT32 t1, INT32 b1, INT32 t2, INT32 b2) while (t1 < t2 && t1 <= b1) { - R_MapPlane(t1, spanstart[t1], x - 1); + mapfunc(t1, spanstart[t1], x - 1); t1++; } while (b1 > b2 && b1 >= t1) { - R_MapPlane(b1, spanstart[b1], x - 1); - b1--; - } - - while (t2 < t1 && t2 <= b2) - spanstart[t2++] = x; - while (b2 > b1 && b2 >= t2) - spanstart[b2--] = x; -} - -static void R_MakeTiltedSpans(INT32 x, INT32 t1, INT32 b1, INT32 t2, INT32 b2) -{ - // Alam: from r_splats's R_RasterizeFloorSplat - if (t1 >= vid.height) t1 = vid.height-1; - if (b1 >= vid.height) b1 = vid.height-1; - if (t2 >= vid.height) t2 = vid.height-1; - if (b2 >= vid.height) b2 = vid.height-1; - if (x-1 >= vid.width) x = vid.width; - - while (t1 < t2 && t1 <= b1) - { - R_MapTiltedPlane(t1, spanstart[t1], x - 1); - t1++; - } - while (b1 > b2 && b1 >= t1) - { - R_MapTiltedPlane(b1, spanstart[b1], x - 1); + mapfunc(b1, spanstart[b1], x - 1); b1--; } @@ -867,11 +793,10 @@ void R_DrawSinglePlane(visplane_t *pl) { levelflat_t *levelflat; INT32 light = 0; - INT32 x; - INT32 stop, angle; + INT32 x, stop; ffloor_t *rover; - INT32 type; - INT32 spanfunctype = BASEDRAWFUNC; + INT32 type, spanfunctype = BASEDRAWFUNC; + void (*mapfunc)(INT32, INT32, INT32) = R_MapPlane; if (!(pl->minx <= pl->maxx)) return; @@ -1023,9 +948,6 @@ void R_DrawSinglePlane(visplane_t *pl) && viewangle != pl->viewangle+pl->plangle) { memset(cachedheight, 0, sizeof (cachedheight)); - angle = (pl->viewangle+pl->plangle-ANGLE_90)>>ANGLETOFINESHIFT; - basexscale = FixedDiv(FINECOSINE(angle),centerxfrac); - baseyscale = -FixedDiv(FINESINE(angle),centerxfrac); viewangle = pl->viewangle+pl->plangle; } @@ -1040,6 +962,8 @@ void R_DrawSinglePlane(visplane_t *pl) if (pl->slope) { + mapfunc = R_MapTiltedPlane; + if (!pl->plangle) { if (ds_powersoftwo) @@ -1107,16 +1031,8 @@ void R_DrawSinglePlane(visplane_t *pl) stop = pl->maxx + 1; - if (pl->slope) - { - for (x = pl->minx; x <= stop; x++) - R_MakeTiltedSpans(x, pl->top[x-1], pl->bottom[x-1], pl->top[x], pl->bottom[x]); - } - else - { - for (x = pl->minx; x <= stop; x++) - R_MakeSpans(x, pl->top[x-1], pl->bottom[x-1], pl->top[x], pl->bottom[x]); - } + for (x = pl->minx; x <= stop; x++) + R_MakeSpans(mapfunc, x, pl->top[x-1], pl->bottom[x-1], pl->top[x], pl->bottom[x]); /* QUINCUNX anti-aliasing technique (sort of) @@ -1183,7 +1099,7 @@ using the palette colors. stop = pl->maxx + 1; for (x = pl->minx; x <= stop; x++) - R_MakeSpans(x, pl->top[x-1], pl->bottom[x-1], + R_MakeSpans(mapfunc, x, pl->top[x-1], pl->bottom[x-1], pl->top[x], pl->bottom[x]); } } diff --git a/src/r_plane.h b/src/r_plane.h index bdad77930..862b95069 100644 --- a/src/r_plane.h +++ b/src/r_plane.h @@ -69,7 +69,6 @@ extern fixed_t cachedheight[MAXVIDHEIGHT]; extern fixed_t cacheddistance[MAXVIDHEIGHT]; extern fixed_t cachedxstep[MAXVIDHEIGHT]; extern fixed_t cachedystep[MAXVIDHEIGHT]; -extern fixed_t basexscale, baseyscale; extern fixed_t *yslope; extern lighttable_t **planezlight; diff --git a/src/r_splats.c b/src/r_splats.c index 4783fb640..c554e9b1f 100644 --- a/src/r_splats.c +++ b/src/r_splats.c @@ -155,7 +155,6 @@ void R_DrawFloorSplat(vissprite_t *spr) fixed_t xscale, yscale; fixed_t xoffset, yoffset; fixed_t leftoffset, topoffset; - pslope_t *slope = NULL; INT32 i; boolean hflip = (spr->xiscale < 0); @@ -188,7 +187,7 @@ void R_DrawFloorSplat(vissprite_t *spr) if (spr->rotateflags & SRF_3D || renderflags & RF_NOSPLATBILLBOARD) splatangle = mobj->angle; else - splatangle = spr->viewangle; + splatangle = spr->viewpoint.angle; if (!(spr->cut & SC_ISROTATED)) splatangle += mobj->rollangle; @@ -218,7 +217,7 @@ void R_DrawFloorSplat(vissprite_t *spr) splat.x = x; splat.y = y; splat.z = mobj->z; - splat.tilted = false; + splat.slope = NULL; // Set positions @@ -238,9 +237,9 @@ void R_DrawFloorSplat(vissprite_t *spr) splat.verts[3].x = w - xoffset; splat.verts[3].y = -h + yoffset; - angle = -splat.angle; - ca = FINECOSINE(angle>>ANGLETOFINESHIFT); - sa = FINESINE(angle>>ANGLETOFINESHIFT); + angle = -splat.angle>>ANGLETOFINESHIFT; + ca = FINECOSINE(angle); + sa = FINESINE(angle); // Rotate for (i = 0; i < 4; i++) @@ -255,36 +254,10 @@ void R_DrawFloorSplat(vissprite_t *spr) // The slope that was defined for the sprite. if (renderflags & RF_SLOPESPLAT) - slope = mobj->floorspriteslope; + splat.slope = mobj->floorspriteslope; if (standingslope && (renderflags & RF_OBJECTSLOPESPLAT)) - slope = standingslope; - - // Set splat as tilted - splat.tilted = (slope != NULL); - } - - if (splat.tilted) - { - pslope_t *s = &splat.slope; - - s->o.x = slope->o.x; - s->o.y = slope->o.y; - s->o.z = slope->o.z; - - s->d.x = slope->d.x; - s->d.y = slope->d.y; - - s->normal.x = slope->normal.x; - s->normal.y = slope->normal.y; - s->normal.z = slope->normal.z; - - s->zdelta = slope->zdelta; - s->zangle = slope->zangle; - s->xydirection = slope->xydirection; - - s->next = NULL; - s->flags = 0; + splat.slope = standingslope; } // Translate @@ -293,9 +266,9 @@ void R_DrawFloorSplat(vissprite_t *spr) tr_x = rotated[i].x + x; tr_y = rotated[i].y + y; - if (slope) + if (splat.slope) { - rot_z = P_GetSlopeZAt(slope, tr_x, tr_y); + rot_z = P_GetSlopeZAt(splat.slope, tr_x, tr_y); splat.verts[i].z = rot_z; } else @@ -305,18 +278,23 @@ void R_DrawFloorSplat(vissprite_t *spr) splat.verts[i].y = tr_y; } + angle = spr->viewpoint.angle >> ANGLETOFINESHIFT; + ca = FINECOSINE(angle); + sa = FINESINE(angle); + + // Project for (i = 0; i < 4; i++) { v3d = &splat.verts[i]; // transform the origin point - tr_x = v3d->x - viewx; - tr_y = v3d->y - viewy; + tr_x = v3d->x - spr->viewpoint.x; + tr_y = v3d->y - spr->viewpoint.y; // rotation around vertical y axis - rot_x = FixedMul(tr_x, viewsin) - FixedMul(tr_y, viewcos); - rot_y = FixedMul(tr_x, viewcos) + FixedMul(tr_y, viewsin); - rot_z = v3d->z - viewz; + rot_x = FixedMul(tr_x, sa) - FixedMul(tr_y, ca); + rot_y = FixedMul(tr_x, ca) + FixedMul(tr_y, sa); + rot_z = v3d->z - spr->viewpoint.z; if (rot_y < FRACUNIT) return; @@ -416,31 +394,32 @@ static void R_RasterizeFloorSplat(floorsplat_t *pSplat, vector2_t *verts, visspr if (R_CheckPowersOfTwo()) R_CheckFlatLength(ds_flatwidth * ds_flatheight); - if (pSplat->tilted) + if (pSplat->slope) { R_SetTiltedSpan(0); - R_SetScaledSlopePlane(&pSplat->slope, viewx, viewy, viewz, pSplat->xscale, pSplat->yscale, -pSplat->verts[0].x, pSplat->verts[0].y, vis->viewangle, pSplat->angle); + R_SetScaledSlopePlane(pSplat->slope, vis->viewpoint.x, vis->viewpoint.y, vis->viewpoint.z, pSplat->xscale, pSplat->yscale, -pSplat->verts[0].x, pSplat->verts[0].y, vis->viewpoint.angle, pSplat->angle); R_CalculateSlopeVectors(); spanfunctype = SPANDRAWFUNC_TILTEDSPRITE; } else { - planeheight = abs(pSplat->z - viewz); + planeheight = abs(pSplat->z - vis->viewpoint.z); if (pSplat->angle) { - // Add the view offset, rotated by the plane angle. - fixed_t a = -pSplat->verts[0].x + viewx; - fixed_t b = -pSplat->verts[0].y + viewy; - angle_t angle = (pSplat->angle >> ANGLETOFINESHIFT); - offsetx = FixedMul(a, FINECOSINE(angle)) - FixedMul(b,FINESINE(angle)); - offsety = -FixedMul(a, FINESINE(angle)) - FixedMul(b,FINECOSINE(angle)); memset(cachedheight, 0, sizeof(cachedheight)); + + // Add the view offset, rotated by the plane angle. + fixed_t a = -pSplat->verts[0].x + vis->viewpoint.x; + fixed_t b = -pSplat->verts[0].y + vis->viewpoint.y; + angle_t angle = (pSplat->angle >> ANGLETOFINESHIFT); + offsetx = FixedMul(a, FINECOSINE(angle)) - FixedMul(b, FINESINE(angle)); + offsety = -FixedMul(a, FINESINE(angle)) - FixedMul(b, FINECOSINE(angle)); } else { - offsetx = viewx - pSplat->verts[0].x; - offsety = pSplat->verts[0].y - viewy; + offsetx = vis->viewpoint.x - pSplat->verts[0].x; + offsety = pSplat->verts[0].y - vis->viewpoint.y; } } @@ -461,7 +440,7 @@ static void R_RasterizeFloorSplat(floorsplat_t *pSplat, vector2_t *verts, visspr { ds_transmap = vis->transmap; - if (pSplat->tilted) + if (pSplat->slope) spanfunctype = SPANDRAWFUNC_TILTEDTRANSSPRITE; else spanfunctype = SPANDRAWFUNC_TRANSSPRITE; @@ -528,12 +507,12 @@ static void R_RasterizeFloorSplat(floorsplat_t *pSplat, vector2_t *verts, visspr if (x2 < x1) continue; - if (!pSplat->tilted) + if (!pSplat->slope) { fixed_t xstep, ystep; fixed_t distance, span; - angle_t angle = (vis->viewangle + pSplat->angle)>>ANGLETOFINESHIFT; + angle_t angle = (vis->viewpoint.angle + pSplat->angle)>>ANGLETOFINESHIFT; angle_t planecos = FINECOSINE(angle); angle_t planesin = FINESINE(angle); @@ -577,7 +556,7 @@ static void R_RasterizeFloorSplat(floorsplat_t *pSplat, vector2_t *verts, visspr rastertab[y].maxx = INT32_MIN; } - if (pSplat->angle && !pSplat->tilted) + if (pSplat->angle && !pSplat->slope) memset(cachedheight, 0, sizeof(cachedheight)); } diff --git a/src/r_splats.h b/src/r_splats.h index cab3d63b6..7e31406d1 100644 --- a/src/r_splats.h +++ b/src/r_splats.h @@ -34,8 +34,7 @@ typedef struct floorsplat_s INT32 width, height; fixed_t scale, xscale, yscale; angle_t angle; - boolean tilted; // Uses the tilted drawer - pslope_t slope; + pslope_t *slope; vector3_t verts[4]; // (x,y,z) as viewed from above on map fixed_t x, y, z; // position diff --git a/src/r_things.c b/src/r_things.c index 0283712b8..f1996d743 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -1956,9 +1956,12 @@ static void R_ProjectSprite(mobj_t *thing) vis->paperoffset = paperoffset; vis->paperdistance = paperdistance; vis->centerangle = centerangle; - vis->viewangle = viewangle; vis->shear.tan = sheartan; vis->shear.offset = 0; + vis->viewpoint.x = viewx; + vis->viewpoint.y = viewy; + vis->viewpoint.z = viewz; + vis->viewpoint.angle = viewangle; vis->mobj = thing; // Easy access! Tails 06-07-2002 diff --git a/src/r_things.h b/src/r_things.h index 9315b36e9..79dc80d94 100644 --- a/src/r_things.h +++ b/src/r_things.h @@ -164,7 +164,12 @@ typedef struct vissprite_s fixed_t xiscale; // negative if flipped angle_t centerangle; // for paper sprites - angle_t viewangle; // for floor sprites, the viewpoint's current angle + + // for floor sprites + struct { + fixed_t x, y, z; // the viewpoint's current position + angle_t angle; // the viewpoint's current angle + } viewpoint; struct { fixed_t tan; // The amount to shear the sprite vertically per row @@ -185,9 +190,10 @@ typedef struct vissprite_s extracolormap_t *extra_colormap; // global colormaps - // Precalculated top and bottom screen coords for the sprite. fixed_t thingheight; // The actual height of the thing (for 3D floors) sector_t *sector; // The sector containing the thing. + + // Precalculated top and bottom screen coords for the sprite. INT16 sz, szt; spritecut_e cut; From 3ff8d9d3b1d3fec83cb4ba20ff40fefb97ec2dde Mon Sep 17 00:00:00 2001 From: Jaime Ita Passos Date: Thu, 26 Aug 2021 13:37:52 -0300 Subject: [PATCH 0909/1080] Fix issue with png_get_tRNS This fixes an oversight where the return value of png_get_tRNS was being ignored. --- src/r_picformats.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/r_picformats.c b/src/r_picformats.c index 59b1d16c5..5c81d1e02 100644 --- a/src/r_picformats.c +++ b/src/r_picformats.c @@ -901,9 +901,8 @@ static png_bytep *PNG_Read( png_colorp palette; int palette_size; - png_bytep trans; - int trans_num; - png_color_16p trans_values; + png_bytep trans = NULL; + int num_trans = 0; #ifdef PNG_SETJMP_SUPPORTED #ifdef USE_FAR_KEYWORD @@ -998,12 +997,12 @@ static png_bytep *PNG_Read( // color is present on the image, the palette flag is disabled. if (usepal) { - png_get_tRNS(png_ptr, png_info_ptr, &trans, &trans_num, &trans_values); + png_uint_32 result = png_get_tRNS(png_ptr, png_info_ptr, &trans, &num_trans, NULL); - if (trans && trans_num > 0) + if ((result & PNG_INFO_tRNS) && num_trans > 0 && trans != NULL) { INT32 i; - for (i = 0; i < trans_num; i++) + for (i = 0; i < num_trans; i++) { // libpng will transform this image into RGBA even if // the transparent index does not exist in the image, From b73c24a0c5a0a01078c27242ec72d98a31f8b524 Mon Sep 17 00:00:00 2001 From: Shane Ellis Date: Sat, 28 Aug 2021 17:14:36 +0000 Subject: [PATCH 0910/1080] Add VERSIONSTRING_RC to DEVELOP builds for compiler compatibility --- src/doomdef.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/doomdef.h b/src/doomdef.h index 11ca80538..37edca896 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -127,6 +127,7 @@ extern char logfilename[1024]; //#define DEVELOP // Disable this for release builds to remove excessive cheat commands and enable MD5 checking and stuff, all in one go. :3 #ifdef DEVELOP #define VERSIONSTRING "Development EXE" +#define VERSIONSTRING_RC "Development EXE" "\0" // most interface strings are ignored in development mode. // we use comprevision and compbranch instead. // VERSIONSTRING_RC is for the resource-definition script used by windows builds From 1a8ec7975c20e1d652cbbdb7a9e366192e41c05f Mon Sep 17 00:00:00 2001 From: GoldenTails Date: Sat, 28 Aug 2021 15:39:34 -0500 Subject: [PATCH 0911/1080] Makefile: Improve gcc detection Wasn't working for me until I fixed it. Turns out gcc really doesn't like giving its name out. Most of the time it reads argv[0]. --- src/Makefile.d/detect.mk | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/Makefile.d/detect.mk b/src/Makefile.d/detect.mk index 9c8a0a227..f458b044c 100644 --- a/src/Makefile.d/detect.mk +++ b/src/Makefile.d/detect.mk @@ -71,13 +71,17 @@ latest_gcc_version:=10.2 # manually set. And don't bother if this is a clean only # run. ifeq (,$(call Wildvar,GCC% destructive)) -version:=$(shell $(CC) --version) + +# can't use $(CC) --version here since that uses argv[0] to display the name +# also gcc outputs the information to stderr, so I had to do 2>&1 +# this program really doesn't like identifying itself +version:=$(shell $(CC) -v 2>&1) # check if this is in fact GCC -ifneq (,$(or $(findstring gcc,$(version)),\ - $(findstring GCC,$(version)))) +ifneq (,$(findstring gcc version,$(version))) -version:=$(shell $(CC) -dumpversion) +# in stark contrast to the name, gcc will give me a nicely formatted version number for free +version:=$(shell $(CC) -dumpfullversion) # Turn version into words of major, minor v:=$(subst ., ,$(version)) From f4f7af6f6d87451c3271606c965762755617cdc1 Mon Sep 17 00:00:00 2001 From: James R Date: Mon, 30 Aug 2021 18:40:36 -0700 Subject: [PATCH 0912/1080] Add my full name --- src/f_finale.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/f_finale.c b/src/f_finale.c index 4d9a8f825..acad7b248 100644 --- a/src/f_finale.c +++ b/src/f_finale.c @@ -1089,7 +1089,6 @@ static const char *credits[] = { "\"Hannu_Hanhi\"", // For many OpenGL performance improvements! "Kepa \"Nev3r\" Iceta", "Thomas \"Shadow Hog\" Igoe", - "\"james\"", "Iestyn \"Monster Iestyn\" Jealous", "\"Jimita\"", "\"Kaito Sinclaire\"", @@ -1102,6 +1101,7 @@ static const char *credits[] = { "Louis-Antoine \"LJ Sonic\" de Moulins", // de Rochefort doesn't quite fit on the screen sorry lol "John \"JTE\" Muniz", "Colin \"Sonict\" Pfaff", + "James \"james\" Robert Roman", "Sean \"Sryder13\" Ryder", "Ehab \"Wolfy\" Saeed", "Tasos \"tatokis\" Sahanidis", // Corrected C FixedMul, making 64-bit builds netplay compatible From 39bd9c6da8dbcb47660cc41ac53bbbacb4c020ab Mon Sep 17 00:00:00 2001 From: namishere Date: Mon, 30 Aug 2021 23:18:25 -0700 Subject: [PATCH 0913/1080] Make next compile again --- src/lua_baselib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index f287fb78c..1c3b483fa 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -3405,7 +3405,7 @@ static int lib_gAddPlayer(lua_State *L) { INT16 i, newplayernum, botcount = 1; player_t *newplayer; - INT8 skinnum = 0, bot; + SINT8 skinnum = 0, bot; for (i = 0; i < MAXPLAYERS; i++) { From 8e0831a183dbcd3dad5696c6f6514c95df861417 Mon Sep 17 00:00:00 2001 From: James R Date: Fri, 3 Sep 2021 17:13:12 -0700 Subject: [PATCH 0914/1080] Fix unused variable warning under NOPNG --- src/r_picformats.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/r_picformats.h b/src/r_picformats.h index b1bb35edd..c74f8a13a 100644 --- a/src/r_picformats.h +++ b/src/r_picformats.h @@ -116,9 +116,9 @@ void *Picture_PNGConvert( size_t insize, size_t *outsize, pictureflags_t flags); boolean Picture_PNGDimensions(UINT8 *png, INT32 *width, INT32 *height, INT16 *topoffset, INT16 *leftoffset, size_t size); -#endif #define PICTURE_PNG_USELOOKUP +#endif // SpriteInfo extern spriteinfo_t spriteinfo[NUMSPRITES]; From cbc5cc3b2acd0f8f87a4616b8fadf57400dffbcb Mon Sep 17 00:00:00 2001 From: James R Date: Fri, 3 Sep 2021 17:18:00 -0700 Subject: [PATCH 0915/1080] Fix GCC 11 array-bounds warning in P_SetupStateAnimation Removing inline here silences the warning somehow, it could be a GCC bug? --- 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 690842270..b77dbc42a 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -78,7 +78,7 @@ void P_AddCachedAction(mobj_t *mobj, INT32 statenum) // // P_SetupStateAnimation // -FUNCINLINE static ATTRINLINE void P_SetupStateAnimation(mobj_t *mobj, state_t *st) +static void P_SetupStateAnimation(mobj_t *mobj, state_t *st) { INT32 animlength = (mobj->sprite == SPR_PLAY && mobj->skin) ? (INT32)(((skin_t *)mobj->skin)->sprites[mobj->sprite2].numframes) - 1 From 50fe45efe68f01dc8dd79d4f040a776d5d043857 Mon Sep 17 00:00:00 2001 From: katsy <205-katsy@users.noreply.git.do.srb2.org> Date: Fri, 10 Sep 2021 17:00:43 +0000 Subject: [PATCH 0916/1080] Refactor weather switching (fixes #541) --- src/p_mobj.c | 14 ++------ src/p_spec.c | 93 ++++++++++------------------------------------------ 2 files changed, 21 insertions(+), 86 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index 10220fff6..c32371888 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -11051,7 +11051,7 @@ void P_SpawnPrecipitation(void) subsector_t *precipsector = NULL; precipmobj_t *rainmo = NULL; - if (dedicated || !(cv_drawdist_precip.value) || curWeather == PRECIP_NONE) + if (dedicated || !(cv_drawdist_precip.value) || curWeather == PRECIP_NONE || curWeather == PRECIP_STORM_NORAIN) return; // Use the blockmap to narrow down our placing patterns @@ -11097,22 +11097,14 @@ void P_SpawnPrecipitation(void) continue; rainmo = P_SpawnRainMobj(x, y, height, MT_RAIN); + if (curWeather == PRECIP_BLANK) + rainmo->precipflags |= PCF_INVISIBLE; } // Randomly assign a height, now that floorz is set. rainmo->z = M_RandomRange(rainmo->floorz>>FRACBITS, rainmo->ceilingz>>FRACBITS)<flags = mobjinfo[MT_RAIN].flags; st = &states[mobjinfo[MT_RAIN].spawnstate]; @@ -2078,7 +2039,7 @@ void P_SwitchWeather(INT32 weathernum) precipmobj->precipflags |= PCF_RAIN; //think->function.acp1 = (actionf_p1)P_RainThinker; } - else if (swap == PRECIP_SNOW) // Rain To Snow + else if (weathernum == PRECIP_SNOW) // Rain To Snow { INT32 z; @@ -2103,7 +2064,7 @@ void P_SwitchWeather(INT32 weathernum) //think->function.acp1 = (actionf_p1)P_SnowThinker; } - else if (swap == PRECIP_BLANK || swap == PRECIP_STORM_NORAIN) // Remove precip, but keep it around for reuse. + else // Remove precip, but keep it around for reuse. { //think->function.acp1 = (actionf_p1)P_NullPrecipThinker; @@ -2116,49 +2077,34 @@ void P_SwitchWeather(INT32 weathernum) { case PRECIP_SNOW: // snow curWeather = PRECIP_SNOW; - - if (!swap) + + if (purge) P_SpawnPrecipitation(); break; case PRECIP_RAIN: // rain { - boolean dontspawn = false; - - if (curWeather == PRECIP_RAIN || curWeather == PRECIP_STORM || curWeather == PRECIP_STORM_NOSTRIKES) - dontspawn = true; - curWeather = PRECIP_RAIN; - if (!dontspawn && !swap) + if (purge) P_SpawnPrecipitation(); break; } case PRECIP_STORM: // storm { - boolean dontspawn = false; - - if (curWeather == PRECIP_RAIN || curWeather == PRECIP_STORM || curWeather == PRECIP_STORM_NOSTRIKES) - dontspawn = true; - curWeather = PRECIP_STORM; - if (!dontspawn && !swap) + if (purge) P_SpawnPrecipitation(); break; } case PRECIP_STORM_NOSTRIKES: // storm w/o lightning { - boolean dontspawn = false; - - if (curWeather == PRECIP_RAIN || curWeather == PRECIP_STORM || curWeather == PRECIP_STORM_NOSTRIKES) - dontspawn = true; - curWeather = PRECIP_STORM_NOSTRIKES; - if (!dontspawn && !swap) + if (purge) P_SpawnPrecipitation(); break; @@ -2166,14 +2112,11 @@ void P_SwitchWeather(INT32 weathernum) case PRECIP_STORM_NORAIN: // storm w/o rain curWeather = PRECIP_STORM_NORAIN; - if (!swap) - P_SpawnPrecipitation(); - break; - case PRECIP_BLANK: + case PRECIP_BLANK: //preloaded curWeather = PRECIP_BLANK; - if (!swap) + if (purge) P_SpawnPrecipitation(); break; From aaf4653f1e111edfd5efe1f2004f1f48e34883ad Mon Sep 17 00:00:00 2001 From: LZA <73-LZA@users.noreply.git.do.srb2.org> Date: Sun, 12 Sep 2021 21:08:06 +0000 Subject: [PATCH 0917/1080] Fix minor issues with folder addons --- src/d_main.c | 4 +- src/d_netcmd.c | 56 ++++++++- src/d_netfil.c | 19 +-- src/filesrch.c | 329 ++++++++++++++++++++++++++++--------------------- src/filesrch.h | 10 +- src/m_misc.c | 2 +- src/w_wad.c | 168 ++++++++++++++++++++----- src/w_wad.h | 5 +- 8 files changed, 405 insertions(+), 188 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index 7866ccbed..36f41e0a4 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -944,13 +944,13 @@ static void D_AddFile(char **list, const char *file) static void D_AddFolder(char **list, const char *file) { - size_t pnumwadfiles, len = strlen(file); + size_t pnumwadfiles; char *newfile; for (pnumwadfiles = 0; list[pnumwadfiles]; pnumwadfiles++) ; - newfile = malloc(len + 2); // NULL terminator + path separator + newfile = malloc(strlen(file) + 2); // Path delimiter + NULL terminator if (!newfile) I_Error("No more free memory to AddFolder %s",file); diff --git a/src/d_netcmd.c b/src/d_netcmd.c index ea0d9ca80..1e4e2b464 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -1518,7 +1518,7 @@ static void Got_NameAndColor(UINT8 **cp, INT32 playernum) { illegalMask &= ~(1 << i); } - + if ((p->availabilities & illegalMask) != 0) { kick = true; @@ -3416,9 +3416,10 @@ static void Command_Addfolder(void) for (curarg = 1; curarg < argc; curarg++) { const char *fn, *p; + char *fullpath; char buf[256]; char *buf_p = buf; - INT32 i; + INT32 i, stat; size_t ii; boolean folderadded = false; @@ -3461,6 +3462,13 @@ static void Command_Addfolder(void) break; ++p; + // Don't add an empty path. + if (M_IsStringEmpty(fn)) + { + CONS_Alert(CONS_WARNING, M_GetText("Folder name is empty, skipping\n")); + continue; + } + // check total packet size and no of files currently loaded // See W_InitFile in w_wad.c if ((numwadfiles >= MAX_WADFILES) @@ -3470,10 +3478,52 @@ static void Command_Addfolder(void) return; } - WRITESTRINGN(buf_p,p,240); + // Check if the path is valid. + stat = W_IsPathToFolderValid(fn); + + if (stat == 0) + { + CONS_Alert(CONS_WARNING, M_GetText("Path %s is invalid, skipping\n"), fn); + continue; + } + else if (stat < 0) + { +#ifndef AVOID_ERRNO + CONS_Alert(CONS_WARNING, M_GetText("Error accessing %s (%s), skipping\n"), fn, strerror(direrror)); +#else + CONS_Alert(CONS_WARNING, M_GetText("Error accessing %s, skipping\n"), fn); +#endif + continue; + } + + // Get the full path for this folder. + fullpath = W_GetFullFolderPath(fn); + + if (fullpath == NULL) + { + CONS_Alert(CONS_WARNING, M_GetText("Path %s is invalid, skipping\n"), fn); + continue; + } + + // Check if the folder is already added. + for (i = 0; i < numwadfiles; i++) + { + if (wadfiles[i]->type != RET_FOLDER) + continue; + + if (samepaths(wadfiles[i]->path, fullpath) > 0) + { + CONS_Alert(CONS_ERROR, M_GetText("%s is already loaded\n"), fn); + continue; + } + } + + Z_Free(fullpath); addedfolders[numfoldersadded++] = fn; + WRITESTRINGN(buf_p,p,240); + if (IsPlayerAdmin(consoleplayer) && (!server)) // Request to add file SendNetXCmd(XD_REQADDFOLDER, buf, buf_p - buf); else diff --git a/src/d_netfil.c b/src/d_netfil.c index 15f9f1ff5..12c5ee6a2 100644 --- a/src/d_netfil.c +++ b/src/d_netfil.c @@ -1584,20 +1584,23 @@ filestatus_t findfile(char *filename, const UINT8 *wantedmd5sum, boolean complet return (badmd5 ? FS_MD5SUMBAD : FS_NOTFOUND); // md5 sum bad or file not found } +// Searches for a folder. +// This can be used with a full path, or an incomplete path. +// In the latter case, the function will try to find folders in +// srb2home, srb2path, and the current directory. filestatus_t findfolder(const char *path) { // Check the path by itself first. - if (checkfolderpath(path, NULL, true)) + if (concatpaths(path, NULL) == 1) return FS_FOUND; -#define checkpath(startpath) { \ - if (checkfolderpath(path, startpath, true)) \ - return FS_FOUND; \ - } +#define checkpath(startpath) \ + if (concatpaths(path, startpath) == 1) \ + return FS_FOUND - checkpath(srb2home) // Then, look in srb2home. - checkpath(srb2path) // Now, look in srb2path. - checkpath(".") // Finally, look in ".". + checkpath(srb2home); // Then, look in srb2home. + checkpath(srb2path); // Now, look in srb2path. + checkpath("."); // Finally, look in the current directory. #undef checkpath diff --git a/src/filesrch.c b/src/filesrch.c index f01fc0bd2..e5c9b2158 100644 --- a/src/filesrch.c +++ b/src/filesrch.c @@ -341,8 +341,8 @@ char *refreshdirname = NULL; size_t packetsizetally = 0; size_t mainwadstally = 0; -#define folderpathlen 1024 -#define maxfolderdepth 48 +#define dirpathlen 1024 +#define maxdirdepth 48 #define isuptree(dirent) ((dirent)[0]=='.' && ((dirent)[1]=='\0' || ((dirent)[1]=='.' && (dirent)[2]=='\0'))) @@ -448,182 +448,227 @@ filestatus_t filesearch(char *filename, const char *startpath, const UINT8 *want return retval; } -// Called from findfolder and ResGetLumpsFolder in w_wad.c. -// Call with cleanup true if the path has to be verified. -boolean checkfolderpath(const char *path, const char *startpath, boolean cleanup) -{ - char folderpath[folderpathlen], basepath[folderpathlen], *fn = NULL; - DIR *dirhandle; +#ifndef AVOID_ERRNO +int direrror = 0; +#endif - // Remove path separators from the filename, and don't try adding "/". - // See also the same code in W_InitFolder. - if (cleanup) - { - const char *p = path + strlen(path); - size_t len; - - --p; - while (*p == '\\' || *p == '/' || *p == ':') - { - p--; - if (p < path) - return false; - } - ++p; - - // Allocate the new path name. - len = (p - path) + 1; - fn = ZZ_Alloc(len); - strlcpy(fn, path, len); - } - - if (startpath) - { - snprintf(basepath, sizeof basepath, "%s" PATHSEP, startpath); - - if (cleanup) - { - snprintf(folderpath, sizeof folderpath, "%s%s", basepath, fn); - Z_Free(fn); // Don't need this anymore. - } - else - snprintf(folderpath, sizeof folderpath, "%s%s", basepath, path); - - // Home path and folder path are the same? Not valid. - if (!strcmp(basepath, folderpath)) - return false; - } - else if (cleanup) - { - snprintf(folderpath, sizeof folderpath, "%s", fn); - Z_Free(fn); // Don't need this anymore. - } - else - snprintf(folderpath, sizeof folderpath, "%s", path); - - dirhandle = opendir(folderpath); - if (dirhandle == NULL) - return false; - else - closedir(dirhandle); - - return true; -} - -INT32 pathisfolder(const char *path) +// Checks if the specified path is a directory. +// Returns 1 if so, 0 if not, and -1 if an error occurred. +// direrror is set if there was an error. +INT32 pathisdirectory(const char *path) { struct stat fsstat; if (stat(path, &fsstat) < 0) + { +#ifndef AVOID_ERRNO + direrror = errno; +#endif return -1; + } else if (S_ISDIR(fsstat.st_mode)) return 1; return 0; } +// Concatenates two paths, and checks if it is a directory that can be opened. +// Returns 1 if so, 0 if not, and -1 if an error occurred. +INT32 concatpaths(const char *path, const char *startpath) +{ + char dirpath[dirpathlen]; + DIR *dirhandle; + INT32 stat; + + if (startpath) + { + char basepath[dirpathlen]; + + snprintf(basepath, sizeof basepath, "%s" PATHSEP, startpath); + snprintf(dirpath, sizeof dirpath, "%s%s", basepath, path); + + // Base path and directory path are the same? Not valid. + stat = samepaths(basepath, dirpath); + + if (stat == 1) + return 0; + else if (stat < 0) + return -1; + } + else + snprintf(dirpath, sizeof dirpath, "%s", path); + + // Check if the path is a directory. + // Will return -1 if there was an error. + stat = pathisdirectory(dirpath); + if (stat == 0) + return 0; + else if (stat < 0) + { + // The path doesn't exist, so it can't be a directory. + if (direrror == ENOENT) + return 0; + + return -1; + } + + // Open the directory. + // Will return 0 if it couldn't be opened. + dirhandle = opendir(dirpath); + if (dirhandle == NULL) + return 0; + else + closedir(dirhandle); + + return 1; +} + +// Checks if two paths are the same. Returns 1 if so, and 0 if not. +// Returns -1 if an error occurred with the first path, +// and returns -2 if an error occurred with the second path. +// direrror is set if there was an error. INT32 samepaths(const char *path1, const char *path2) { struct stat stat1; struct stat stat2; if (stat(path1, &stat1) < 0) + { +#ifndef AVOID_ERRNO + direrror = errno; +#endif return -1; + } if (stat(path2, &stat2) < 0) - return -1; + { +#ifndef AVOID_ERRNO + direrror = errno; +#endif + return -2; + } if (stat1.st_dev == stat2.st_dev) { #if !defined(_WIN32) return (stat1.st_ino == stat2.st_ino); #else + // The above doesn't work on NTFS or FAT. HANDLE file1 = CreateFileA(path1, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL); HANDLE file2 = CreateFileA(path2, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL); BY_HANDLE_FILE_INFORMATION file1info, file2info; - boolean ok = false; - if (file1 != INVALID_HANDLE_VALUE && file2 != INVALID_HANDLE_VALUE) + if (file1 == INVALID_HANDLE_VALUE) { - if (GetFileInformationByHandle(file1, &file1info) && GetFileInformationByHandle(file2, &file2info)) - { - if (file1info.dwVolumeSerialNumber == file2info.dwVolumeSerialNumber - && file1info.nFileIndexLow == file2info.nFileIndexLow - && file1info.nFileIndexHigh == file2info.nFileIndexHigh) - ok = true; - } +#ifndef AVOID_ERRNO + direrror = ENOENT; +#endif + return -1; + } + else if (file2 == INVALID_HANDLE_VALUE) + { + CloseHandle(file1); +#ifndef AVOID_ERRNO + direrror = ENOENT; +#endif + return -2; } - if (file1 != INVALID_HANDLE_VALUE) + // I have no idea why GetFileInformationByHandle would fail. + // Microsoft's documentation doesn't tell me. + // I'll just use EIO... + if (!GetFileInformationByHandle(file1, &file1info)) + { +#ifndef AVOID_ERRNO + direrror = EIO; +#endif + return -1; + } + else if (!GetFileInformationByHandle(file2, &file2info)) + { CloseHandle(file1); - if (file2 != INVALID_HANDLE_VALUE) CloseHandle(file2); +#ifndef AVOID_ERRNO + direrror = EIO; +#endif + return -2; + } - return ok; + if (file1info.dwVolumeSerialNumber == file2info.dwVolumeSerialNumber + && file1info.nFileIndexLow == file2info.nFileIndexLow + && file1info.nFileIndexHigh == file2info.nFileIndexHigh) + { + CloseHandle(file1); + CloseHandle(file2); + return 1; + } + + return 0; #endif } - return false; + return 0; } // -// Folder loading +// Directory loading // -static void initfolderpath(char *folderpath, size_t *folderpathindex, int depthleft) +static void initdirpath(char *dirpath, size_t *dirpathindex, int depthleft) { - folderpathindex[depthleft] = strlen(folderpath) + 1; + dirpathindex[depthleft] = strlen(dirpath) + 1; - if (folderpath[folderpathindex[depthleft]-2] != PATHSEP[0]) + if (dirpath[dirpathindex[depthleft]-2] != PATHSEP[0]) { - folderpath[folderpathindex[depthleft]-1] = PATHSEP[0]; - folderpath[folderpathindex[depthleft]] = 0; + dirpath[dirpathindex[depthleft]-1] = PATHSEP[0]; + dirpath[dirpathindex[depthleft]] = 0; } else - folderpathindex[depthleft]--; + dirpathindex[depthleft]--; } -lumpinfo_t *getfolderfiles(const char *path, UINT16 *nlmp, UINT16 *nfiles, UINT16 *nfolders) +lumpinfo_t *getdirectoryfiles(const char *path, UINT16 *nlmp, UINT16 *nfolders) { DIR **dirhandle; struct dirent *dent; struct stat fsstat; - int rootfolder = (maxfolderdepth - 1); - int depthleft = rootfolder; + int rootdir = (maxdirdepth - 1); + int depthleft = rootdir; - char folderpath[folderpathlen]; - size_t *folderpathindex; + char dirpath[dirpathlen]; + size_t *dirpathindex; lumpinfo_t *lumpinfo, *lump_p; - UINT16 i = 0, numlumps = (*nlmp); + UINT16 i = 0, numlumps = 0; - dirhandle = (DIR **)malloc(maxfolderdepth * sizeof (DIR*)); - folderpathindex = (size_t *)malloc(maxfolderdepth * sizeof(size_t)); + boolean failure = false; + + dirhandle = (DIR **)malloc(maxdirdepth * sizeof (DIR*)); + dirpathindex = (size_t *)malloc(maxdirdepth * sizeof(size_t)); // Open the root directory - strlcpy(folderpath, path, folderpathlen); - dirhandle[depthleft] = opendir(folderpath); + strlcpy(dirpath, path, dirpathlen); + dirhandle[depthleft] = opendir(dirpath); if (dirhandle[depthleft] == NULL) { free(dirhandle); - free(folderpathindex); + free(dirpathindex); return NULL; } - initfolderpath(folderpath, folderpathindex, depthleft); - (*nfiles) = 0; + initdirpath(dirpath, dirpathindex, depthleft); (*nfolders) = 0; // Count files and directories - while (depthleft < maxfolderdepth) + while (depthleft < maxdirdepth) { - folderpath[folderpathindex[depthleft]] = 0; + dirpath[dirpathindex[depthleft]] = 0; dent = readdir(dirhandle[depthleft]); if (!dent) { - if (depthleft != rootfolder) // Don't close the root directory + if (depthleft != rootdir) // Don't close the root directory closedir(dirhandle[depthleft]); depthleft++; continue; @@ -631,62 +676,67 @@ lumpinfo_t *getfolderfiles(const char *path, UINT16 *nlmp, UINT16 *nfiles, UINT1 else if (isuptree(dent->d_name)) continue; - strcpy(&folderpath[folderpathindex[depthleft]], dent->d_name); + strcpy(&dirpath[dirpathindex[depthleft]], dent->d_name); - if (stat(folderpath, &fsstat) < 0) + if (stat(dirpath, &fsstat) < 0) ; else if (S_ISDIR(fsstat.st_mode) && depthleft) { - folderpathindex[--depthleft] = strlen(folderpath) + 1; - dirhandle[depthleft] = opendir(folderpath); + dirpathindex[--depthleft] = strlen(dirpath) + 1; + dirhandle[depthleft] = opendir(dirpath); if (dirhandle[depthleft]) - { - numlumps++; (*nfolders)++; - } else depthleft++; - folderpath[folderpathindex[depthleft]-1] = '/'; - folderpath[folderpathindex[depthleft]] = 0; + dirpath[dirpathindex[depthleft]-1] = '/'; + dirpath[dirpathindex[depthleft]] = 0; } else - { numlumps++; - (*nfiles)++; - } - if (numlumps == (UINT16_MAX-1)) + // Failure: Too many files. + if (numlumps == UINT16_MAX) + { + (*nlmp) = UINT16_MAX; + failure = true; break; + } } // Failure: No files have been found. - if (!(*nfiles)) + if (!numlumps) { - (*nfiles) = UINT16_MAX; - free(folderpathindex); + (*nlmp) = 0; + failure = true; + } + + // Close any open directories and return if something went wrong. + if (failure) + { + free(dirpathindex); free(dirhandle); - for (; depthleft < maxfolderdepth; closedir(dirhandle[depthleft++])); // Close any open directories. + for (; depthleft < maxdirdepth; closedir(dirhandle[depthleft++])); return NULL; } // Create the files and directories as lump entries // It's possible to create lumps and count files at the same time, - // but I didn't to constantly have to reallocate memory for every lump. - rewinddir(dirhandle[rootfolder]); - depthleft = rootfolder; + // but I didn't want to have to reallocate memory for every lump. + rewinddir(dirhandle[rootdir]); + depthleft = rootdir; - strlcpy(folderpath, path, folderpathlen); - initfolderpath(folderpath, folderpathindex, depthleft); + strlcpy(dirpath, path, dirpathlen); + initdirpath(dirpath, dirpathindex, depthleft); lump_p = lumpinfo = Z_Calloc(numlumps * sizeof(lumpinfo_t), PU_STATIC, NULL); - while (depthleft < maxfolderdepth) + while (depthleft < maxdirdepth) { char *fullname, *trimname; - folderpath[folderpathindex[depthleft]] = 0; + dirpath[dirpathindex[depthleft]] = 0; dent = readdir(dirhandle[depthleft]); if (!dent) @@ -697,29 +747,30 @@ lumpinfo_t *getfolderfiles(const char *path, UINT16 *nlmp, UINT16 *nfiles, UINT1 else if (isuptree(dent->d_name)) continue; - strcpy(&folderpath[folderpathindex[depthleft]], dent->d_name); + strcpy(&dirpath[dirpathindex[depthleft]], dent->d_name); - if (stat(folderpath, &fsstat) < 0) + if (stat(dirpath, &fsstat) < 0) continue; else if (S_ISDIR(fsstat.st_mode) && depthleft) { - folderpathindex[--depthleft] = strlen(folderpath) + 1; - dirhandle[depthleft] = opendir(folderpath); + dirpathindex[--depthleft] = strlen(dirpath) + 1; + dirhandle[depthleft] = opendir(dirpath); - if (!dirhandle[depthleft]) + if (dirhandle[depthleft]) { - depthleft++; - continue; + dirpath[dirpathindex[depthleft]-1] = '/'; + dirpath[dirpathindex[depthleft]] = 0; } + else + depthleft++; - folderpath[folderpathindex[depthleft]-1] = '/'; - folderpath[folderpathindex[depthleft]] = 0; + continue; } - lump_p->diskpath = Z_StrDup(folderpath); // Path in the filesystem to the file + lump_p->diskpath = Z_StrDup(dirpath); // Path in the filesystem to the file lump_p->compression = CM_NOCOMPRESSION; // Lump is uncompressed - // Remove the folder path. + // Remove the directory's path. fullname = lump_p->diskpath; if (strstr(fullname, path)) fullname += strlen(path) + 1; @@ -747,7 +798,7 @@ lumpinfo_t *getfolderfiles(const char *path, UINT16 *nlmp, UINT16 *nfiles, UINT1 lump_p->longname = Z_Calloc(1, PU_STATIC, NULL); // The complete name of the file, with its extension, - // excluding the path of the folder where it resides. + // excluding the path of the directory where it resides. lump_p->fullname = Z_StrDup(fullname); lump_p++; @@ -755,12 +806,12 @@ lumpinfo_t *getfolderfiles(const char *path, UINT16 *nlmp, UINT16 *nfiles, UINT1 if (i > numlumps || i == (UINT16_MAX-1)) { - for (; depthleft < maxfolderdepth; closedir(dirhandle[depthleft++])); // Close any open directories. + for (; depthleft < maxdirdepth; closedir(dirhandle[depthleft++])); // Close any open directories. break; } } - free(folderpathindex); + free(dirpathindex); free(dirhandle); (*nlmp) = numlumps; diff --git a/src/filesrch.h b/src/filesrch.h index 92e3341f3..e358d7993 100644 --- a/src/filesrch.h +++ b/src/filesrch.h @@ -29,11 +29,15 @@ extern consvar_t cv_addons_option, cv_addons_folder, cv_addons_md5, cv_addons_sh filestatus_t filesearch(char *filename, const char *startpath, const UINT8 *wantedmd5sum, boolean completepath, int maxsearchdepth); -INT32 pathisfolder(const char *path); -boolean checkfolderpath(const char *path, const char *startpath, boolean cleanup); +INT32 pathisdirectory(const char *path); INT32 samepaths(const char *path1, const char *path2); +boolean concatpaths(const char *path, const char *startpath); -lumpinfo_t *getfolderfiles(const char *path, UINT16 *nlmp, UINT16 *nfiles, UINT16 *nfolders); +#ifndef AVOID_ERRNO +extern int direrror; +#endif + +lumpinfo_t *getdirectoryfiles(const char *path, UINT16 *nlmp, UINT16 *nfolders); #define menudepth 20 diff --git a/src/m_misc.c b/src/m_misc.c index 4100a8f17..17d6d738b 100644 --- a/src/m_misc.c +++ b/src/m_misc.c @@ -2694,7 +2694,7 @@ boolean M_IsStringEmpty(const char *s) { const char *ch = s; - if (ch == NULL || (ch && strlen(ch) < 1)) + if (s == NULL || s[0] == '\0') return true; for (;;ch++) diff --git a/src/w_wad.c b/src/w_wad.c index e37c86bac..3ff301117 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -687,11 +687,67 @@ static lumpinfo_t* ResGetLumpsZip (FILE* handle, UINT16* nlmp) return lumpinfo; } +static INT32 CheckPathsNotEqual(const char *path1, const char *path2) +{ + INT32 stat = samepaths(path1, path2); + + if (stat == 1) + return 0; + else if (stat < 0) + return -1; + + return 1; +} + +// Returns 1 if the path is valid, 0 if not, and -1 if there was an error. +INT32 W_IsPathToFolderValid(const char *path) +{ + INT32 stat; + + // Remove path delimiters. + const char *p = path + (strlen(path) - 1); + while (*p == '\\' || *p == '/' || *p == ':') + { + p--; + if (p < path) + return 0; + } + + // Check if the path is a directory. + stat = pathisdirectory(path); + if (stat == 0) + return 0; + else if (stat < 0) + { + // The path doesn't exist, so it can't be a directory. + if (direrror == ENOENT) + return 0; + + return -1; + } + + // Don't add your home, you sodding tic tac. + stat = CheckPathsNotEqual(path, srb2home); + if (stat != 1) + return stat; + + // Do the same checks for SRB2's path, and the current directory. + stat = CheckPathsNotEqual(path, srb2path); + if (stat != 1) + return stat; + + stat = CheckPathsNotEqual(path, "."); + if (stat != 1) + return stat; + + return 1; +} + // Checks if the combination of the first path and the second path are valid. // If they are, the concatenated path is returned. -static char *W_CheckFolderPath(const char *startpath, const char *path) +static char *CheckConcatFolderPath(const char *startpath, const char *path) { - if (checkfolderpath(path, startpath, false)) + if (concatpaths(path, startpath) == 1) { char *fn; @@ -710,23 +766,23 @@ static char *W_CheckFolderPath(const char *startpath, const char *path) return NULL; } -// Returns the first valid path for a folder. -static char *W_GetFullFolderPath(const char *path) +// Looks for the first valid full path for a folder. +// Returns NULL if the folder doesn't exist, or it isn't valid. +char *W_GetFullFolderPath(const char *path) { // Check the path by itself first. - char *fn = W_CheckFolderPath(NULL, path); + char *fn = CheckConcatFolderPath(NULL, path); if (fn) return fn; -#define checkpath(startpath) { \ - fn = W_CheckFolderPath(startpath, path); \ +#define checkpath(startpath) \ + fn = CheckConcatFolderPath(startpath, path); \ if (fn) \ - return fn; \ -} \ + return fn - checkpath(srb2home) // Then, look in srb2home. - checkpath(srb2path) // Now, look in srb2path. - checkpath(".") // Finally, look in ".". + checkpath(srb2home); // Then, look in srb2home. + checkpath(srb2path); // Now, look in srb2path. + checkpath("."); // Finally, look in the current directory. #undef checkpath @@ -734,9 +790,9 @@ static char *W_GetFullFolderPath(const char *path) } // Loads files from a folder into a lumpinfo structure. -static lumpinfo_t *ResGetLumpsFolder(const char *path, UINT16 *nlmp, UINT16 *nfiles, UINT16 *nfolders) +static lumpinfo_t *ResGetLumpsFolder(const char *path, UINT16 *nlmp, UINT16 *nfolders) { - return getfolderfiles(path, nlmp, nfiles, nfolders); + return getdirectoryfiles(path, nlmp, nfolders); } static UINT16 W_InitFileError (const char *filename, boolean exitworthy) @@ -908,7 +964,7 @@ UINT16 W_InitFile(const char *filename, boolean mainfile, boolean startup) wadfile->type = type; wadfile->handle = handle; wadfile->numlumps = numlumps; - wadfile->filecount = wadfile->foldercount = 0; + wadfile->foldercount = 0; wadfile->lumpinfo = lumpinfo; wadfile->important = important; fseek(handle, 0, SEEK_END); @@ -966,11 +1022,12 @@ UINT16 W_InitFolder(const char *path, boolean mainfile, boolean startup) lumpinfo_t *lumpinfo = NULL; wadfile_t *wadfile; UINT16 numlumps = 0; - UINT16 filecount, foldercount; + UINT16 foldercount; size_t i; char *fn, *fullpath; const char *p; int important; + INT32 stat; if (!(refreshdirmenu & REFRESHDIR_ADDFILE)) refreshdirmenu = REFRESHDIR_NORMAL|REFRESHDIR_ADDFILE; // clean out cons_alerts that happened earlier @@ -1006,16 +1063,15 @@ UINT16 W_InitFolder(const char *path, boolean mainfile, boolean startup) packetsizetally = packetsize; } - // Remove path separators from the filename, and don't try adding "/". - p = path+strlen(path); - --p; + // Remove path delimiters. + p = path + (strlen(path) - 1); while (*p == '\\' || *p == '/' || *p == ':') { p--; if (p < path) { - CONS_Alert(CONS_ERROR, M_GetText("Path %s is prohibited\n"), path); + CONS_Alert(CONS_ERROR, M_GetText("Path %s is invalid\n"), path); return W_InitFileError(path, startup); } } @@ -1026,6 +1082,7 @@ UINT16 W_InitFolder(const char *path, boolean mainfile, boolean startup) fn = ZZ_Alloc(i); strlcpy(fn, path, i); + // Don't add an empty path. if (M_IsStringEmpty(fn)) { CONS_Alert(CONS_ERROR, M_GetText("Folder name is empty\n")); @@ -1037,14 +1094,36 @@ UINT16 W_InitFolder(const char *path, boolean mainfile, boolean startup) return W_InitFileError("a folder", false); } - // Get the full path for this filename. + // Check if the path is valid. + stat = W_IsPathToFolderValid(fn); + + if (stat != 1) + { + if (stat == 0) + CONS_Alert(CONS_ERROR, M_GetText("Path %s is invalid\n"), fn); + else if (stat < 0) + { +#ifndef AVOID_ERRNO + CONS_Alert(CONS_ERROR, M_GetText("Could not stat %s: %s\n"), fn, strerror(direrror)); +#else + CONS_Alert(CONS_ERROR, M_GetText("Could not stat %s\n"), fn); +#endif + } + + Z_Free(fn); + return W_InitFileError(path, startup); + } + + // Get the full path for this folder. fullpath = W_GetFullFolderPath(fn); if (fullpath == NULL) { + CONS_Alert(CONS_ERROR, M_GetText("Path %s is invalid\n"), fn); Z_Free(fn); - return W_InitFileError(path, false); + return W_InitFileError(path, startup); } + // Check if the folder is already added. for (i = 0; i < numwadfiles; i++) { if (wadfiles[i]->type != RET_FOLDER) @@ -1061,11 +1140,16 @@ UINT16 W_InitFolder(const char *path, boolean mainfile, boolean startup) } } - lumpinfo = ResGetLumpsFolder(fullpath, &numlumps, &filecount, &foldercount); + lumpinfo = ResGetLumpsFolder(fullpath, &numlumps, &foldercount); + if (lumpinfo == NULL) { - if (filecount == UINT16_MAX) + if (!numlumps) CONS_Alert(CONS_ERROR, M_GetText("Folder %s is empty\n"), path); + else if (numlumps == UINT16_MAX) + CONS_Alert(CONS_ERROR, M_GetText("Folder %s contains too many files\n"), path); + else + CONS_Alert(CONS_ERROR, M_GetText("Unknown error enumerating files from folder %s\n"), path); Z_Free(fn); Z_Free(fullpath); @@ -1082,7 +1166,6 @@ UINT16 W_InitFolder(const char *path, boolean mainfile, boolean startup) wadfile->type = RET_FOLDER; wadfile->handle = NULL; wadfile->numlumps = numlumps; - wadfile->filecount = filecount; wadfile->foldercount = foldercount; wadfile->lumpinfo = lumpinfo; wadfile->important = important; @@ -1094,7 +1177,7 @@ UINT16 W_InitFolder(const char *path, boolean mainfile, boolean startup) Z_Calloc(numlumps * sizeof (*wadfile->lumpcache), PU_STATIC, &wadfile->lumpcache); Z_Calloc(numlumps * sizeof (*wadfile->patchcache), PU_STATIC, &wadfile->patchcache); - CONS_Printf(M_GetText("Added folder %s (%u files, %u folders)\n"), fn, filecount, foldercount); + CONS_Printf(M_GetText("Added folder %s (%u files, %u folders)\n"), fn, numlumps, foldercount); wadfiles[numwadfiles] = wadfile; numwadfiles++; @@ -1506,12 +1589,24 @@ size_t W_LumpLengthPwad(UINT16 wad, UINT16 lump) l = wadfiles[wad]->lumpinfo + lump; + // Open the external file for this lump, if the WAD is a folder. if (wadfiles[wad]->type == RET_FOLDER) { - INT32 stat = pathisfolder(l->diskpath); + // pathisdirectory calls stat, so if anything wrong has happened, + // this is the time to be aware of it. + INT32 stat = pathisdirectory(l->diskpath); if (stat < 0) - I_Error("W_LumpLengthPwad: could not stat %s", l->diskpath); + { +#ifndef AVOID_ERRNO + if (direrror == ENOENT) + I_Error("W_LumpLengthPwad: file %s doesn't exist", l->diskpath); + else + I_Error("W_LumpLengthPwad: could not stat %s: %s", l->diskpath, strerror(direrror)); +#else + I_Error("W_LumpLengthPwad: could not access %s", l->diskpath); +#endif + } else if (stat == 1) // Path is a folder. return 0; else @@ -1617,7 +1712,7 @@ size_t W_ReadLumpHeaderPwad(UINT16 wad, UINT16 lump, void *dest, size_t size, si lumpinfo_t *l; FILE *handle = NULL; - if (!TestValidLump(wad,lump)) + if (!TestValidLump(wad, lump)) return 0; l = wadfiles[wad]->lumpinfo + lump; @@ -1625,10 +1720,21 @@ size_t W_ReadLumpHeaderPwad(UINT16 wad, UINT16 lump, void *dest, size_t size, si // Open the external file for this lump, if the WAD is a folder. if (wadfiles[wad]->type == RET_FOLDER) { - INT32 stat = pathisfolder(l->diskpath); + // pathisdirectory calls stat, so if anything wrong has happened, + // this is the time to be aware of it. + INT32 stat = pathisdirectory(l->diskpath); if (stat < 0) - I_Error("W_ReadLumpHeaderPwad: could not stat %s", l->diskpath); + { +#ifndef AVOID_ERRNO + if (direrror == ENOENT) + I_Error("W_ReadLumpHeaderPwad: file %s doesn't exist", l->diskpath); + else + I_Error("W_ReadLumpHeaderPwad: could not stat %s: %s", l->diskpath, strerror(direrror)); +#else + I_Error("W_ReadLumpHeaderPwad: could not access %s", l->diskpath); +#endif + } else if (stat == 1) // Path is a folder. return 0; else diff --git a/src/w_wad.h b/src/w_wad.h index 25b4bffa8..3958f7faf 100644 --- a/src/w_wad.h +++ b/src/w_wad.h @@ -122,7 +122,7 @@ typedef struct wadfile_s lumpcache_t *lumpcache; lumpcache_t *patchcache; UINT16 numlumps; // this wad's number of resources - UINT16 filecount, foldercount; // file and folder count + UINT16 foldercount; // folder count FILE *handle; UINT32 filesize; // for network UINT8 md5sum[16]; @@ -152,6 +152,9 @@ void W_InitMultipleFiles(char **filenames); #define W_FileHasFolders(wadfile) ((wadfile)->type == RET_PK3 || (wadfile)->type == RET_FOLDER) +boolean W_IsPathToFolderValid(const char *path); +char *W_GetFullFolderPath(const char *path); + const char *W_CheckNameForNumPwad(UINT16 wad, UINT16 lump); const char *W_CheckNameForNum(lumpnum_t lumpnum); From d5cdb2dc789530ab00a874a56e37f31d7ec4b3f8 Mon Sep 17 00:00:00 2001 From: SMS Alfredo Date: Sun, 12 Sep 2021 22:04:28 +0000 Subject: [PATCH 0918/1080] Add a missing scale assignment to A_Boss3ShockThink --- src/p_enemy.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/p_enemy.c b/src/p_enemy.c index 6a92c5d33..d148b11e0 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -8292,6 +8292,10 @@ void A_Boss3ShockThink(mobj_t *actor) snew->angle = (actor->angle + snext->angle) >> 1; P_SetTarget(&snew->target, actor->target); snew->fuse = actor->fuse; + + P_SetScale(snew, actor->scale); + snew->destscale = actor->destscale; + snew->scalespeed = actor->scalespeed; P_SetTarget(&actor->hnext, snew); P_SetTarget(&snew->hnext, snext); From db92f31f7d41ddd4356acdbf3cd7f4f420d7d34f Mon Sep 17 00:00:00 2001 From: Tatsuru Date: Sun, 12 Sep 2021 18:41:36 -0400 Subject: [PATCH 0919/1080] Revert "Merge branch 'draw-act-num' into 'next'" This reverts merge request !1532 --- src/lua_hudlib.c | 38 -------------------------------------- 1 file changed, 38 deletions(-) diff --git a/src/lua_hudlib.c b/src/lua_hudlib.c index 0bfcfd9ea..3ce36f4f1 100644 --- a/src/lua_hudlib.c +++ b/src/lua_hudlib.c @@ -919,27 +919,6 @@ static int libd_drawString(lua_State *L) return 0; } -static int libd_drawLevelActNum(lua_State *L) -{ - INT32 x; - INT32 y; - UINT8 num; - INT32 flags; - - HUDONLY - - x = luaL_checkinteger(L, 1); - y = luaL_checkinteger(L, 2); - num = luaL_checkinteger(L, 3); - flags = luaL_optinteger(L, 4, 0); - - flags &= ~V_PARAMMASK; // Don't let crashes happen. - - V_DrawLevelActNum(x, y, flags, num); - return 0; -} - - static int libd_drawNameTag(lua_State *L) { INT32 x; @@ -1044,20 +1023,6 @@ static int libd_stringWidth(lua_State *L) return 1; } -static int libd_levelActNumWidth(lua_State *L) -{ - HUDONLY - lua_pushinteger(L, V_LevelActNumWidth(luaL_checkinteger(L, 1))); - return 1; -} - -static int libd_levelActNumHeight(lua_State *L) -{ - HUDONLY - lua_pushinteger(L, V_LevelActNumHeight(luaL_checkinteger(L, 1))); - return 1; -} - static int libd_nameTagWidth(lua_State *L) { HUDONLY @@ -1287,15 +1252,12 @@ static luaL_Reg lib_draw[] = { {"drawPaddedNum", libd_drawPaddedNum}, {"drawFill", libd_drawFill}, {"drawString", libd_drawString}, - {"drawLevelActNum", libd_drawLevelActNum}, {"drawNameTag", libd_drawNameTag}, {"drawScaledNameTag", libd_drawScaledNameTag}, {"drawLevelTitle", libd_drawLevelTitle}, {"fadeScreen", libd_fadeScreen}, // misc {"stringWidth", libd_stringWidth}, - {"levelActNumWidth", libd_levelActNumWidth}, - {"levelActNumHeight", libd_levelActNumHeight}, {"nameTagWidth", libd_nameTagWidth}, {"levelTitleWidth", libd_levelTitleWidth}, {"levelTitleHeight", libd_levelTitleHeight}, From fec5f2778e6ec27dc6c4272a720e744fc5c902ec Mon Sep 17 00:00:00 2001 From: James R Date: Sun, 12 Sep 2021 18:53:51 -0700 Subject: [PATCH 0920/1080] Fix compiler warnings --- src/filesrch.c | 2 +- src/filesrch.h | 2 +- src/lua_hudlib.c | 10 ++++++---- src/sdl/i_system.c | 2 +- src/w_wad.h | 2 +- 5 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/filesrch.c b/src/filesrch.c index e5c9b2158..b4039e526 100644 --- a/src/filesrch.c +++ b/src/filesrch.c @@ -13,6 +13,7 @@ /// FS_FOUND #include +#include #ifdef __GNUC__ #include #endif @@ -33,7 +34,6 @@ #if defined (_WIN32) && defined (_MSC_VER) -#include #include #include diff --git a/src/filesrch.h b/src/filesrch.h index e358d7993..9d5f31bbb 100644 --- a/src/filesrch.h +++ b/src/filesrch.h @@ -31,7 +31,7 @@ filestatus_t filesearch(char *filename, const char *startpath, const UINT8 *want INT32 pathisdirectory(const char *path); INT32 samepaths(const char *path1, const char *path2); -boolean concatpaths(const char *path, const char *startpath); +INT32 concatpaths(const char *path, const char *startpath); #ifndef AVOID_ERRNO extern int direrror; diff --git a/src/lua_hudlib.c b/src/lua_hudlib.c index 25f513e65..fca832053 100644 --- a/src/lua_hudlib.c +++ b/src/lua_hudlib.c @@ -401,14 +401,16 @@ static int camera_set(lua_State *L) case camera_x: case camera_y: return luaL_error(L, LUA_QL("camera_t") " field " LUA_QS " should not be set directly. Use " LUA_QL("P_TryCameraMove") " or " LUA_QL("P_TeleportCameraMove") " instead.", camera_opt[field]); - case camera_chase: + case camera_chase: { + INT32 chase = luaL_checkboolean(L, 3); if (cam == &camera) - CV_SetValue(&cv_chasecam, (INT32)luaL_checkboolean(L, 3)); + CV_SetValue(&cv_chasecam, chase); else if (cam == &camera2) - CV_SetValue(&cv_chasecam2, (INT32)luaL_checkboolean(L, 3)); + CV_SetValue(&cv_chasecam2, chase); else // ??? this should never happen, but ok - cam->chase = luaL_checkboolean(L, 3); + cam->chase = chase; break; + } case camera_aiming: cam->aiming = luaL_checkangle(L, 3); break; diff --git a/src/sdl/i_system.c b/src/sdl/i_system.c index a3908c570..2ec28ebc8 100644 --- a/src/sdl/i_system.c +++ b/src/sdl/i_system.c @@ -550,7 +550,7 @@ static void I_StartupConsole(void) void I_GetConsoleEvents(void) { // we use this when sending back commands - event_t ev = {0,0,0,0}; + event_t ev = {0}; char key = 0; ssize_t d; diff --git a/src/w_wad.h b/src/w_wad.h index 3958f7faf..949bab9fe 100644 --- a/src/w_wad.h +++ b/src/w_wad.h @@ -152,7 +152,7 @@ void W_InitMultipleFiles(char **filenames); #define W_FileHasFolders(wadfile) ((wadfile)->type == RET_PK3 || (wadfile)->type == RET_FOLDER) -boolean W_IsPathToFolderValid(const char *path); +INT32 W_IsPathToFolderValid(const char *path); char *W_GetFullFolderPath(const char *path); const char *W_CheckNameForNumPwad(UINT16 wad, UINT16 lump); From 923e6f31aa1737183f03e61dcddcd6cc3f27b5b6 Mon Sep 17 00:00:00 2001 From: James R Date: Sun, 12 Sep 2021 19:01:30 -0700 Subject: [PATCH 0921/1080] Fix faulty comparison Logical comparisons evaluate to a boolean value... --- src/p_spec.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/p_spec.c b/src/p_spec.c index 8e51f788c..8ae0ec125 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -1981,6 +1981,22 @@ void P_LinedefExecute(INT16 tag, mobj_t *actor, sector_t *caller) } } +static boolean is_rain_type (INT32 weathernum) +{ + switch (weathernum) + { + case PRECIP_SNOW: + case PRECIP_RAIN: + case PRECIP_STORM: + case PRECIP_STORM_NOSTRIKES: + case PRECIP_BLANK: + return true; + + default: + return false; + } +} + // // P_SwitchWeather // @@ -1989,12 +2005,12 @@ void P_LinedefExecute(INT16 tag, mobj_t *actor, sector_t *caller) void P_SwitchWeather(INT32 weathernum) { boolean purge = true; - boolean raintype = (PRECIP_SNOW || PRECIP_RAIN || PRECIP_STORM || PRECIP_STORM_NOSTRIKES || PRECIP_BLANK); if (weathernum == curWeather) return; - if (weathernum == raintype && curWeather == raintype) + if (is_rain_type(weathernum) && + is_rain_type(curWeather)) purge = false; if (purge) From 0ac36b7ce1cc28af073fb157af4ab139571746e4 Mon Sep 17 00:00:00 2001 From: James R Date: Sun, 12 Sep 2021 19:07:40 -0700 Subject: [PATCH 0922/1080] Remove mixed code and declarations warning --- src/Makefile.d/versions.mk | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Makefile.d/versions.mk b/src/Makefile.d/versions.mk index d7d0c3dd1..f0b59658e 100644 --- a/src/Makefile.d/versions.mk +++ b/src/Makefile.d/versions.mk @@ -35,8 +35,6 @@ ifndef GCC295 WFLAGS+=-Wendif-labels endif ifdef GCC41 - WFLAGS+=-Wdeclaration-after-statement - WFLAGS+=-Wno-error=declaration-after-statement WFLAGS+=-Wshadow endif #WFLAGS+=-Wlarger-than-%len% From 3d2f9e6150ab7216d8beea232262850d9e669125 Mon Sep 17 00:00:00 2001 From: katsy Date: Mon, 13 Sep 2021 17:20:20 -0500 Subject: [PATCH 0923/1080] don't create the default patches if we have an interscreen --- src/y_inter.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/y_inter.c b/src/y_inter.c index 6e1bc2e61..1abe01792 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -239,12 +239,12 @@ void Y_LoadIntermissionData(void) } data.coop.ptotal = W_CachePatchName("YB_TOTAL", PU_PATCH); - // get background patches - bgpatch = W_CachePatchName("INTERSCR", PU_PATCH); // grab an interscreen if appropriate if (mapheaderinfo[gamemap-1]->interscreen[0] != '#') interpic = W_CachePatchName(mapheaderinfo[gamemap-1]->interscreen, PU_PATCH); + else // no interscreen? use default background + bgpatch = W_CachePatchName("INTERSCR", PU_PATCH); break; } case int_spec: @@ -255,12 +255,11 @@ void Y_LoadIntermissionData(void) data.spec.pscore = W_CachePatchName("YB_SCORE", PU_PATCH); data.spec.pcontinues = W_CachePatchName("YB_CONTI", PU_PATCH); - // get background tile - bgtile = W_CachePatchName("SPECTILE", PU_PATCH); - // grab an interscreen if appropriate if (mapheaderinfo[gamemap-1]->interscreen[0] != '#') interpic = W_CachePatchName(mapheaderinfo[gamemap-1]->interscreen, PU_PATCH); + else // no interscreen? use default background + bgtile = W_CachePatchName("SPECTILE", PU_PATCH); break; } case int_ctf: From 143a515445f1307b98dbd79a458f966f71601185 Mon Sep 17 00:00:00 2001 From: James R Date: Tue, 21 Sep 2021 02:15:11 -0700 Subject: [PATCH 0924/1080] Correct Big Wave Dave/InstantSonic credits --- src/f_finale.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/f_finale.c b/src/f_finale.c index aecf79fc2..dc736a720 100644 --- a/src/f_finale.c +++ b/src/f_finale.c @@ -1167,8 +1167,8 @@ static const char *credits[] = { "Alexander \"DrTapeworm\" Moench-Ford", "Stefan \"Stuf\" Rimalia", "Shane Mychal Sexton", - "David \"Big Wave Dave\" Spencer Sr.", - "David \"Instant Sonic\" Spencer Jr.", + "Dave \"Big Wave Dave\" Spencer", + "David \"InstantSonic\" Spencer", "\"SSNTails\"", "", "\1Level Design", From d88eb7cc14c239dfb30fbfae3dc00ebdd1a8b388 Mon Sep 17 00:00:00 2001 From: James R Date: Tue, 21 Sep 2021 02:17:44 -0700 Subject: [PATCH 0925/1080] Missed the 'i' --- src/f_finale.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/f_finale.c b/src/f_finale.c index dc736a720..47786bb60 100644 --- a/src/f_finale.c +++ b/src/f_finale.c @@ -1168,7 +1168,7 @@ static const char *credits[] = { "Stefan \"Stuf\" Rimalia", "Shane Mychal Sexton", "Dave \"Big Wave Dave\" Spencer", - "David \"InstantSonic\" Spencer", + "David \"instantSonic\" Spencer", "\"SSNTails\"", "", "\1Level Design", From 791b981fd80cb23cee19d27170b347e10ce96ef1 Mon Sep 17 00:00:00 2001 From: katsy Date: Wed, 22 Sep 2021 16:22:47 -0500 Subject: [PATCH 0926/1080] null gamestate during pre-intermission to prevent unwanted interaction --- src/g_game.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/g_game.c b/src/g_game.c index de1a774f4..e497aa13f 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -3927,6 +3927,9 @@ static void G_DoCompleted(void) if (metalrecording) G_StopMetalRecording(false); + G_SetGamestate(GS_NULL); + wipegamestate = GS_NULL; + for (i = 0; i < MAXPLAYERS; i++) if (playeringame[i]) G_PlayerFinishLevel(i); // take away cards and stuff From ed5942a0b6fb05c861384786f389f63d1fc528dc Mon Sep 17 00:00:00 2001 From: katsy Date: Wed, 22 Sep 2021 23:18:54 -0500 Subject: [PATCH 0927/1080] fix tailsbot controls --- src/g_game.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index de1a774f4..ce2aa41f5 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1549,8 +1549,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) // Note: Majority of botstuffs are handled in G_Ticker now. if (player->bot == BOT_2PHUMAN) //Player-controlled bot { - G_CopyTiccmd(cmd, I_BaseTiccmd2(), 1); // empty, or external driver - // Fix offset angle for P2-controlled Tailsbot when P2's controls are set to non-Legacy + // Fix offset angle for P2-controlled Tailsbot when P2's controls are set to non-Strafe cmd->angleturn = (INT16)((localangle - *myangle) >> 16); } From 0f4074f22d6e1bab37fa6c4e138270ec95e72a04 Mon Sep 17 00:00:00 2001 From: SteelT Date: Thu, 23 Sep 2021 13:45:42 -0400 Subject: [PATCH 0928/1080] Remove unused I_GetMouseGrab function --- src/i_system.h | 4 ---- src/sdl/i_video.c | 5 ----- 2 files changed, 9 deletions(-) diff --git a/src/i_system.h b/src/i_system.h index e046fd620..a3790dca3 100644 --- a/src/i_system.h +++ b/src/i_system.h @@ -318,10 +318,6 @@ void I_RegisterSysCommands(void); */ void I_GetCursorPosition(INT32 *x, INT32 *y); -/** \brief Returns whether the mouse is grabbed -*/ -boolean I_GetMouseGrab(void); - /** \brief Sets whether the mouse is grabbed */ void I_SetMouseGrab(boolean grab); diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index 97e4a7214..ed766ff23 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -409,11 +409,6 @@ void I_UpdateMouseGrab(void) SDLdoGrabMouse(); } -boolean I_GetMouseGrab(void) -{ - return (boolean)SDL_GetWindowGrab(window); -} - void I_SetMouseGrab(boolean grab) { if (grab) From f70491b2b58c3a48857602d5004b09c70224ed48 Mon Sep 17 00:00:00 2001 From: Vincent Robinson Date: Mon, 4 Oct 2021 12:20:15 -0700 Subject: [PATCH 0929/1080] Make linedef 96 apply to tags from 97-99, but not to itself --- src/p_setup.c | 77 ++++++++++++++++++++++++++++----------------------- 1 file changed, 42 insertions(+), 35 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index 588815aee..7f9674e4e 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -3046,48 +3046,55 @@ static void P_AddBinaryMapTags(void) { size_t i; - for (i = 0; i < numlines; i++) - { - // 96: Apply Tag to Tagged Sectors + for (i = 0; i < numlines; i++) { // 97: Apply Tag to Front Sector // 98: Apply Tag to Back Sector // 99: Apply Tag to Front and Back Sectors - if (lines[i].special == 96) { - size_t j; - mtag_t tag = Tag_FGet(&lines[i].frontsector->tags); - mtag_t target_tag = Tag_FGet(&lines[i].tags); - mtag_t offset_tags[4]; - memset(offset_tags, 0, sizeof(mtag_t)*4); - if (lines[i].flags & ML_EFFECT6) { - offset_tags[0] = (INT32)sides[lines[i].sidenum[0]].textureoffset / FRACUNIT; - offset_tags[1] = (INT32)sides[lines[i].sidenum[0]].rowoffset / FRACUNIT; - } - if (lines[i].flags & ML_TFERLINE) { - offset_tags[2] = (INT32)sides[lines[i].sidenum[1]].textureoffset / FRACUNIT; - offset_tags[3] = (INT32)sides[lines[i].sidenum[1]].rowoffset / FRACUNIT; - } + if (lines[i].special == 97 || lines[i].special == 99) + P_AddBinaryMapTagsFromLine(lines[i].frontsector, &lines[i]); + if (lines[i].special == 98 || lines[i].special == 99) + P_AddBinaryMapTagsFromLine(lines[i].backsector, &lines[i]); + } - for (j = 0; j < numsectors; j++) { - boolean matches_target_tag = target_tag && Tag_Find(§ors[j].tags, target_tag); - size_t k; for (k = 0; k < 4; k++) { - if (lines[i].flags & ML_EFFECT5) { - if (matches_target_tag || (offset_tags[k] && Tag_Find(§ors[j].tags, offset_tags[k]))) { - Tag_Add(§ors[j].tags, tag); - break; - } - } else if (matches_target_tag) { - if (k == 0) - Tag_Add(§ors[j].tags, tag); - if (offset_tags[k]) - Tag_Add(§ors[j].tags, offset_tags[k]); + // Run this loop after the 97-99 loop to ensure that 96 can search through all of the + // 97-99-applied tags. + for (i = 0; i < numlines; i++) { + size_t j; + mtag_t tag, target_tag; + mtag_t offset_tags[4]; + + // 96: Apply Tag to Tagged Sectors + if (lines[i].special != 96) + continue; + + tag = Tag_FGet(&lines[i].frontsector->tags); + target_tag = Tag_FGet(&lines[i].tags); + memset(offset_tags, 0, sizeof(mtag_t)*4); + if (lines[i].flags & ML_EFFECT6) { + offset_tags[0] = (INT32)sides[lines[i].sidenum[0]].textureoffset / FRACUNIT; + offset_tags[1] = (INT32)sides[lines[i].sidenum[0]].rowoffset / FRACUNIT; + } + if (lines[i].flags & ML_TFERLINE) { + offset_tags[2] = (INT32)sides[lines[i].sidenum[1]].textureoffset / FRACUNIT; + offset_tags[3] = (INT32)sides[lines[i].sidenum[1]].rowoffset / FRACUNIT; + } + + for (j = 0; j < numsectors; j++) { + boolean matches_target_tag = target_tag && Tag_Find(§ors[j].tags, target_tag); + size_t k; + for (k = 0; k < 4; k++) { + if (lines[i].flags & ML_EFFECT5) { + if (matches_target_tag || (offset_tags[k] && Tag_Find(§ors[j].tags, offset_tags[k]))) { + Tag_Add(§ors[j].tags, tag); + break; } + } else if (matches_target_tag) { + if (k == 0) + Tag_Add(§ors[j].tags, tag); + if (offset_tags[k]) + Tag_Add(§ors[j].tags, offset_tags[k]); } } - } else { - if (lines[i].special == 97 || lines[i].special == 99) - P_AddBinaryMapTagsFromLine(lines[i].frontsector, &lines[i]); - if (lines[i].special == 98 || lines[i].special == 99) - P_AddBinaryMapTagsFromLine(lines[i].backsector, &lines[i]); } } } From a8c6a652605b921d2accbf256c2ebbd27c9dd596 Mon Sep 17 00:00:00 2001 From: FlykeSpice Date: Mon, 11 Oct 2021 00:20:11 -0400 Subject: [PATCH 0930/1080] Fix visplanes getting allocated twice I guess that is legacy remnant stuff --- src/r_plane.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/r_plane.c b/src/r_plane.c index d844048ae..45719ce58 100644 --- a/src/r_plane.c +++ b/src/r_plane.c @@ -318,7 +318,7 @@ static visplane_t *new_visplane(unsigned hash) visplane_t *check = freetail; if (!check) { - check = calloc(2, sizeof (*check)); + check = malloc(sizeof (*check)); if (check == NULL) I_Error("%s: Out of memory", "new_visplane"); // FIXME: ugly } else From 8110473643e6b6e541a7f8e8217bed45dd64d671 Mon Sep 17 00:00:00 2001 From: GoldenTails Date: Fri, 22 Oct 2021 18:31:37 -0500 Subject: [PATCH 0931/1080] Give userdata that needed names some names. --- src/lua_baselib.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 350c1585f..a0b5ff873 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -187,6 +187,8 @@ static const struct { {META_MAPHEADER, "mapheader_t"}, {META_POLYOBJ, "polyobj_t"}, + {META_POLYOBJVERTICES, "polyobj_t.vertices"}, + {META_POLYOBJLINES, "polyobj_t.lines"}, {META_CVAR, "consvar_t"}, @@ -216,6 +218,7 @@ static const struct { {META_LUABANKS, "luabanks[]"}, + {META_KEYEVENT, "keyevent_t"}, {META_MOUSE, "mouse_t"}, {NULL, NULL} }; From e10eddd11da065f0cb0955700055d09509bfd11a Mon Sep 17 00:00:00 2001 From: katsy <205-katsy@users.noreply.git.do.srb2.org> Date: Wed, 27 Oct 2021 17:52:29 +0000 Subject: [PATCH 0932/1080] Fix broken rain to rain weather switching --- src/p_spec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_spec.c b/src/p_spec.c index 8ae0ec125..07410efa2 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -2040,7 +2040,7 @@ void P_SwitchWeather(INT32 weathernum) continue; // not a precipmobj thinker precipmobj = (precipmobj_t *)think; - if (weathernum == (PRECIP_RAIN || PRECIP_STORM || PRECIP_STORM_NOSTRIKES)) // Snow To Rain + if (weathernum == PRECIP_RAIN || weathernum == PRECIP_STORM || weathernum == PRECIP_STORM_NOSTRIKES) // Snow To Rain { precipmobj->flags = mobjinfo[MT_RAIN].flags; st = &states[mobjinfo[MT_RAIN].spawnstate]; From 77ecfb9cdc92faea474cb91b65edd45c32a4ff40 Mon Sep 17 00:00:00 2001 From: Hannu Hanhi Date: Mon, 25 Oct 2021 20:49:15 +0300 Subject: [PATCH 0933/1080] Perfstats averaging and refactor --- src/d_clisrv.c | 11 +- src/d_main.c | 14 +- src/d_netcmd.c | 12 +- src/d_netcmd.h | 2 + src/hardware/hw_batching.c | 31 +- src/hardware/hw_main.c | 70 +-- src/hardware/hw_main.h | 30 +- src/lua_hooklib.c | 4 +- src/m_perfstats.c | 1074 ++++++++++++++++++++++-------------- src/m_perfstats.h | 43 +- src/p_map.c | 2 +- src/p_tick.c | 20 +- src/r_bsp.c | 4 +- src/r_main.c | 49 +- src/r_main.h | 26 +- src/r_things.c | 2 +- src/z_zone.h | 1 + 17 files changed, 840 insertions(+), 555 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index b7071320c..61b855319 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -4974,16 +4974,23 @@ void TryRunTics(tic_t realtics) // run the count * tics while (neededtic > gametic) { + boolean update_stats = !(paused || P_AutoPause()); + DEBFILE(va("============ Running tic %d (local %d)\n", gametic, localgametic)); - ps_tictime = I_GetPreciseTime(); + if (update_stats) + PS_START_TIMING(ps_tictime); G_Ticker((gametic % NEWTICRATERATIO) == 0); ExtraDataTicker(); gametic++; consistancy[gametic%BACKUPTICS] = Consistancy(); - ps_tictime = I_GetPreciseTime() - ps_tictime; + if (update_stats) + { + PS_STOP_TIMING(ps_tictime); + PS_UpdateTickStats(); + } // Leave a certain amount of tics present in the net buffer as long as we've ran at least one tic this frame. if (client && gamestate == GS_LEVEL && leveltime > 3 && neededtic <= gametic + cv_netticbuffer.value) diff --git a/src/d_main.c b/src/d_main.c index b4b668f4b..3845f08bd 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -476,7 +476,7 @@ static void D_Display(void) if (!automapactive && !dedicated && cv_renderview.value) { - ps_rendercalltime = I_GetPreciseTime(); + PS_START_TIMING(ps_rendercalltime); if (players[displayplayer].mo || players[displayplayer].playerstate == PST_DEAD) { topleft = screens[0] + viewwindowy*vid.width + viewwindowx; @@ -523,7 +523,7 @@ static void D_Display(void) if (postimgtype2) V_DoPostProcessor(1, postimgtype2, postimgparam2); } - ps_rendercalltime = I_GetPreciseTime() - ps_rendercalltime; + PS_STOP_TIMING(ps_rendercalltime); } if (lastdraw) @@ -537,7 +537,7 @@ static void D_Display(void) lastdraw = false; } - ps_uitime = I_GetPreciseTime(); + PS_START_TIMING(ps_uitime); if (gamestate == GS_LEVEL) { @@ -550,7 +550,7 @@ static void D_Display(void) } else { - ps_uitime = I_GetPreciseTime(); + PS_START_TIMING(ps_uitime); } } @@ -592,7 +592,7 @@ static void D_Display(void) CON_Drawer(); - ps_uitime = I_GetPreciseTime() - ps_uitime; + PS_STOP_TIMING(ps_uitime); // // wipe update @@ -678,9 +678,9 @@ static void D_Display(void) M_DrawPerfStats(); } - ps_swaptime = I_GetPreciseTime(); + PS_START_TIMING(ps_swaptime); I_FinishUpdate(); // page flip or blit buffer - ps_swaptime = I_GetPreciseTime() - ps_swaptime; + PS_STOP_TIMING(ps_swaptime); } } diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 5eb360bef..9d32f1bb1 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -47,6 +47,7 @@ #include "m_cond.h" #include "m_anigif.h" #include "md5.h" +#include "m_perfstats.h" #ifdef NETGAME_DEVMODE #define CV_RESTRICT CV_NETVAR @@ -374,7 +375,14 @@ consvar_t cv_sleep = CVAR_INIT ("cpusleep", "1", CV_SAVE, sleeping_cons_t, NULL) static CV_PossibleValue_t perfstats_cons_t[] = { {0, "Off"}, {1, "Rendering"}, {2, "Logic"}, {3, "ThinkFrame"}, {0, NULL}}; -consvar_t cv_perfstats = CVAR_INIT ("perfstats", "Off", 0, perfstats_cons_t, NULL); +consvar_t cv_perfstats = CVAR_INIT ("perfstats", "Off", CV_CALL, perfstats_cons_t, PS_PerfStats_OnChange); +static CV_PossibleValue_t ps_samplesize_cons_t[] = { + {1, "MIN"}, {1000, "MAX"}, {0, NULL}}; +consvar_t cv_ps_samplesize = CVAR_INIT ("ps_samplesize", "1", CV_CALL, ps_samplesize_cons_t, PS_SampleSize_OnChange); +static CV_PossibleValue_t ps_descriptor_cons_t[] = { + {1, "Average"}, {2, "SD"}, {3, "Minimum"}, {4, "Maximum"}, {0, NULL}}; +consvar_t cv_ps_descriptor = CVAR_INIT ("ps_descriptor", "Average", 0, ps_descriptor_cons_t, NULL); + consvar_t cv_freedemocamera = CVAR_INIT("freedemocamera", "Off", CV_SAVE, CV_OnOff, NULL); char timedemo_name[256]; @@ -867,6 +875,8 @@ void D_RegisterClientCommands(void) CV_RegisterVar(&cv_soundtest); CV_RegisterVar(&cv_perfstats); + CV_RegisterVar(&cv_ps_samplesize); + CV_RegisterVar(&cv_ps_descriptor); // ingame object placing COM_AddCommand("objectplace", Command_ObjectPlace_f); diff --git a/src/d_netcmd.h b/src/d_netcmd.h index cae32643e..30b39c0eb 100644 --- a/src/d_netcmd.h +++ b/src/d_netcmd.h @@ -110,6 +110,8 @@ extern consvar_t cv_skipmapcheck; extern consvar_t cv_sleep; extern consvar_t cv_perfstats; +extern consvar_t cv_ps_samplesize; +extern consvar_t cv_ps_descriptor; extern char timedemo_name[256]; extern boolean timedemo_csv; diff --git a/src/hardware/hw_batching.c b/src/hardware/hw_batching.c index 0ac33d136..da0319bcc 100644 --- a/src/hardware/hw_batching.c +++ b/src/hardware/hw_batching.c @@ -245,13 +245,16 @@ void HWR_RenderBatches(void) currently_batching = false;// no longer collecting batches if (!polygonArraySize) { - ps_hw_numpolys = ps_hw_numcalls = ps_hw_numshaders = ps_hw_numtextures = ps_hw_numpolyflags = ps_hw_numcolors = 0; + ps_hw_numpolys.value.i = ps_hw_numcalls.value.i = ps_hw_numshaders.value.i + = ps_hw_numtextures.value.i = ps_hw_numpolyflags.value.i + = ps_hw_numcolors.value.i = 0; return;// nothing to draw } // init stats vars - ps_hw_numpolys = polygonArraySize; - ps_hw_numcalls = ps_hw_numverts = 0; - ps_hw_numshaders = ps_hw_numtextures = ps_hw_numpolyflags = ps_hw_numcolors = 1; + ps_hw_numpolys.value.i = polygonArraySize; + ps_hw_numcalls.value.i = ps_hw_numverts.value.i = 0; + ps_hw_numshaders.value.i = ps_hw_numtextures.value.i + = ps_hw_numpolyflags.value.i = ps_hw_numcolors.value.i = 1; // init polygonIndexArray for (i = 0; i < polygonArraySize; i++) { @@ -259,12 +262,12 @@ void HWR_RenderBatches(void) } // sort polygons - ps_hw_batchsorttime = I_GetPreciseTime(); + PS_START_TIMING(ps_hw_batchsorttime); if (cv_glshaders.value && gl_shadersavailable) qsort(polygonIndexArray, polygonArraySize, sizeof(unsigned int), comparePolygons); else qsort(polygonIndexArray, polygonArraySize, sizeof(unsigned int), comparePolygonsNoShaders); - ps_hw_batchsorttime = I_GetPreciseTime() - ps_hw_batchsorttime; + PS_STOP_TIMING(ps_hw_batchsorttime); // sort order // 1. shader // 2. texture @@ -272,7 +275,7 @@ void HWR_RenderBatches(void) // 4. colors + light level // not sure about what order of the last 2 should be, or if it even matters - ps_hw_batchdrawtime = I_GetPreciseTime(); + PS_START_TIMING(ps_hw_batchdrawtime); currentShader = polygonArray[polygonIndexArray[0]].shader; currentTexture = polygonArray[polygonIndexArray[0]].texture; @@ -408,8 +411,8 @@ void HWR_RenderBatches(void) // execute draw call HWD.pfnDrawIndexedTriangles(¤tSurfaceInfo, finalVertexArray, finalIndexWritePos, currentPolyFlags, finalVertexIndexArray); // update stats - ps_hw_numcalls++; - ps_hw_numverts += finalIndexWritePos; + ps_hw_numcalls.value.i++; + ps_hw_numverts.value.i += finalIndexWritePos; // reset write positions finalVertexWritePos = 0; finalIndexWritePos = 0; @@ -426,7 +429,7 @@ void HWR_RenderBatches(void) currentShader = nextShader; changeShader = false; - ps_hw_numshaders++; + ps_hw_numshaders.value.i++; } if (changeTexture) { @@ -435,21 +438,21 @@ void HWR_RenderBatches(void) currentTexture = nextTexture; changeTexture = false; - ps_hw_numtextures++; + ps_hw_numtextures.value.i++; } if (changePolyFlags) { currentPolyFlags = nextPolyFlags; changePolyFlags = false; - ps_hw_numpolyflags++; + ps_hw_numpolyflags.value.i++; } if (changeSurfaceInfo) { currentSurfaceInfo = nextSurfaceInfo; changeSurfaceInfo = false; - ps_hw_numcolors++; + ps_hw_numcolors.value.i++; } // and that should be it? } @@ -457,7 +460,7 @@ void HWR_RenderBatches(void) polygonArraySize = 0; unsortedVertexArraySize = 0; - ps_hw_batchdrawtime = I_GetPreciseTime() - ps_hw_batchdrawtime; + PS_STOP_TIMING(ps_hw_batchdrawtime); } diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index e0851af85..9bade3d6f 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -147,22 +147,22 @@ static angle_t gl_aimingangle; static void HWR_SetTransformAiming(FTransform *trans, player_t *player, boolean skybox); // Render stats -precise_t ps_hw_skyboxtime = 0; -precise_t ps_hw_nodesorttime = 0; -precise_t ps_hw_nodedrawtime = 0; -precise_t ps_hw_spritesorttime = 0; -precise_t ps_hw_spritedrawtime = 0; +ps_metric_t ps_hw_skyboxtime = {0}; +ps_metric_t ps_hw_nodesorttime = {0}; +ps_metric_t ps_hw_nodedrawtime = {0}; +ps_metric_t ps_hw_spritesorttime = {0}; +ps_metric_t ps_hw_spritedrawtime = {0}; // Render stats for batching -int ps_hw_numpolys = 0; -int ps_hw_numverts = 0; -int ps_hw_numcalls = 0; -int ps_hw_numshaders = 0; -int ps_hw_numtextures = 0; -int ps_hw_numpolyflags = 0; -int ps_hw_numcolors = 0; -precise_t ps_hw_batchsorttime = 0; -precise_t ps_hw_batchdrawtime = 0; +ps_metric_t ps_hw_numpolys = {0}; +ps_metric_t ps_hw_numverts = {0}; +ps_metric_t ps_hw_numcalls = {0}; +ps_metric_t ps_hw_numshaders = {0}; +ps_metric_t ps_hw_numtextures = {0}; +ps_metric_t ps_hw_numpolyflags = {0}; +ps_metric_t ps_hw_numcolors = {0}; +ps_metric_t ps_hw_batchsorttime = {0}; +ps_metric_t ps_hw_batchdrawtime = {0}; boolean gl_init = false; boolean gl_maploaded = false; @@ -3235,7 +3235,7 @@ static void HWR_Subsector(size_t num) } // for render stats - ps_numpolyobjects += numpolys; + ps_numpolyobjects.value.i += numpolys; // Sort polyobjects R_SortPolyObjects(sub); @@ -3343,7 +3343,7 @@ static void HWR_RenderBSPNode(INT32 bspnum) // Decide which side the view point is on INT32 side; - ps_numbspcalls++; + ps_numbspcalls.value.i++; // Found a subsector? if (bspnum & NF_SUBSECTOR) @@ -4718,7 +4718,7 @@ static void HWR_CreateDrawNodes(void) // that is already lying around. This should all be in some sort of linked list or lists. sortindex = Z_Calloc(sizeof(size_t) * (numplanes + numpolyplanes + numwalls), PU_STATIC, NULL); - ps_hw_nodesorttime = I_GetPreciseTime(); + PS_START_TIMING(ps_hw_nodesorttime); for (i = 0; i < numplanes; i++, p++) { @@ -4738,7 +4738,7 @@ static void HWR_CreateDrawNodes(void) sortindex[p] = p; } - ps_numdrawnodes = p; + ps_numdrawnodes.value.i = p; // p is the number of stuff to sort @@ -4773,9 +4773,9 @@ static void HWR_CreateDrawNodes(void) } } - ps_hw_nodesorttime = I_GetPreciseTime() - ps_hw_nodesorttime; + PS_STOP_TIMING(ps_hw_nodesorttime); - ps_hw_nodedrawtime = I_GetPreciseTime(); + PS_START_TIMING(ps_hw_nodedrawtime); // Okay! Let's draw it all! Woo! HWD.pfnSetTransform(&atransform); @@ -4812,7 +4812,7 @@ static void HWR_CreateDrawNodes(void) } } - ps_hw_nodedrawtime = I_GetPreciseTime() - ps_hw_nodedrawtime; + PS_STOP_TIMING(ps_hw_nodedrawtime); numwalls = 0; numplanes = 0; @@ -6095,10 +6095,10 @@ void HWR_RenderPlayerView(INT32 viewnumber, player_t *player) if (viewnumber == 0) // Only do it if it's the first screen being rendered HWD.pfnClearBuffer(true, false, &ClearColor); // Clear the Color Buffer, stops HOMs. Also seems to fix the skybox issue on Intel GPUs. - ps_hw_skyboxtime = I_GetPreciseTime(); + PS_START_TIMING(ps_hw_skyboxtime); if (skybox && drawsky) // If there's a skybox and we should be drawing the sky, draw the skybox HWR_RenderSkyboxView(viewnumber, player); // This is drawn before everything else so it is placed behind - ps_hw_skyboxtime = I_GetPreciseTime() - ps_hw_skyboxtime; + PS_STOP_TIMING(ps_hw_skyboxtime); { // do we really need to save player (is it not the same)? @@ -6208,9 +6208,9 @@ void HWR_RenderPlayerView(INT32 viewnumber, player_t *player) // Reset the shader state. HWR_SetShaderState(); - ps_numbspcalls = 0; - ps_numpolyobjects = 0; - ps_bsptime = I_GetPreciseTime(); + ps_numbspcalls.value.i = 0; + ps_numpolyobjects.value.i = 0; + PS_START_TIMING(ps_bsptime); validcount++; @@ -6248,7 +6248,7 @@ void HWR_RenderPlayerView(INT32 viewnumber, player_t *player) } #endif - ps_bsptime = I_GetPreciseTime() - ps_bsptime; + PS_STOP_TIMING(ps_bsptime); if (cv_glbatching.value) HWR_RenderBatches(); @@ -6263,22 +6263,22 @@ void HWR_RenderPlayerView(INT32 viewnumber, player_t *player) #endif // Draw MD2 and sprites - ps_numsprites = gl_visspritecount; - ps_hw_spritesorttime = I_GetPreciseTime(); + ps_numsprites.value.i = gl_visspritecount; + PS_START_TIMING(ps_hw_spritesorttime); HWR_SortVisSprites(); - ps_hw_spritesorttime = I_GetPreciseTime() - ps_hw_spritesorttime; - ps_hw_spritedrawtime = I_GetPreciseTime(); + PS_STOP_TIMING(ps_hw_spritesorttime); + PS_START_TIMING(ps_hw_spritedrawtime); HWR_DrawSprites(); - ps_hw_spritedrawtime = I_GetPreciseTime() - ps_hw_spritedrawtime; + PS_STOP_TIMING(ps_hw_spritedrawtime); #ifdef NEWCORONAS //Hurdler: they must be drawn before translucent planes, what about gl fog? HWR_DrawCoronas(); #endif - ps_numdrawnodes = 0; - ps_hw_nodesorttime = 0; - ps_hw_nodedrawtime = 0; + ps_numdrawnodes.value.i = 0; + ps_hw_nodesorttime.value.p = 0; + ps_hw_nodedrawtime.value.p = 0; if (numplanes || numpolyplanes || numwalls) //Hurdler: render 3D water and transparent walls after everything { HWR_CreateDrawNodes(); diff --git a/src/hardware/hw_main.h b/src/hardware/hw_main.h index b751b2a6e..3f90f0ae1 100644 --- a/src/hardware/hw_main.h +++ b/src/hardware/hw_main.h @@ -20,6 +20,8 @@ #include "../d_player.h" #include "../r_defs.h" +#include "../m_perfstats.h" + // Startup & Shutdown the hardware mode renderer void HWR_Startup(void); void HWR_Switch(void); @@ -116,22 +118,22 @@ extern FTransform atransform; // Render stats -extern precise_t ps_hw_skyboxtime; -extern precise_t ps_hw_nodesorttime; -extern precise_t ps_hw_nodedrawtime; -extern precise_t ps_hw_spritesorttime; -extern precise_t ps_hw_spritedrawtime; +extern ps_metric_t ps_hw_skyboxtime; +extern ps_metric_t ps_hw_nodesorttime; +extern ps_metric_t ps_hw_nodedrawtime; +extern ps_metric_t ps_hw_spritesorttime; +extern ps_metric_t ps_hw_spritedrawtime; // Render stats for batching -extern int ps_hw_numpolys; -extern int ps_hw_numverts; -extern int ps_hw_numcalls; -extern int ps_hw_numshaders; -extern int ps_hw_numtextures; -extern int ps_hw_numpolyflags; -extern int ps_hw_numcolors; -extern precise_t ps_hw_batchsorttime; -extern precise_t ps_hw_batchdrawtime; +extern ps_metric_t ps_hw_numpolys; +extern ps_metric_t ps_hw_numverts; +extern ps_metric_t ps_hw_numcalls; +extern ps_metric_t ps_hw_numshaders; +extern ps_metric_t ps_hw_numtextures; +extern ps_metric_t ps_hw_numpolyflags; +extern ps_metric_t ps_hw_numcolors; +extern ps_metric_t ps_hw_batchsorttime; +extern ps_metric_t ps_hw_batchdrawtime; extern boolean gl_init; extern boolean gl_maploaded; diff --git a/src/lua_hooklib.c b/src/lua_hooklib.c index 32b5e52fb..a72b22b5a 100644 --- a/src/lua_hooklib.c +++ b/src/lua_hooklib.c @@ -505,7 +505,7 @@ static int call_hooks calls += call_mobj_type_hooks(hook, MT_NULL); calls += call_mobj_type_hooks(hook, hook->mobj_type); - ps_lua_mobjhooks += calls; + ps_lua_mobjhooks.value.i += calls; } else calls += call_mapped(hook, &hookIds[hook->hook_type]); @@ -868,7 +868,7 @@ void LUA_HookLinedefExecute(line_t *line, mobj_t *mo, sector_t *sector) LUA_PushUserdata(gL, line, META_LINE); LUA_PushUserdata(gL, mo, META_MOBJ); LUA_PushUserdata(gL, sector, META_SECTOR); - ps_lua_mobjhooks += call_hooks(&hook, 0, res_none); + ps_lua_mobjhooks.value.i += call_hooks(&hook, 0, res_none); } } diff --git a/src/m_perfstats.c b/src/m_perfstats.c index 8a99312e6..9285b31be 100644 --- a/src/m_perfstats.c +++ b/src/m_perfstats.c @@ -22,46 +22,173 @@ #include "hardware/hw_main.h" #endif -struct perfstatcol; struct perfstatrow; -typedef struct perfstatcol perfstatcol_t; typedef struct perfstatrow perfstatrow_t; -struct perfstatcol { - INT32 lores_x; - INT32 hires_x; - INT32 color; - perfstatrow_t * rows; -}; - struct perfstatrow { - const char * lores_label; - const char * hires_label; - void * value; + const char * lores_label; + const char * hires_label; + ps_metric_t * metric; + UINT8 flags; }; -static precise_t ps_frametime = 0; +// perfstatrow_t flags -precise_t ps_tictime = 0; +#define PS_TIME 1 // metric measures time (uses precise_t instead of INT32) +#define PS_LEVEL 2 // metric is valid only when a level is active +#define PS_SW 4 // metric is valid only in software mode +#define PS_HW 8 // metric is valid only in opengl mode +#define PS_BATCHING 16 // metric is valid only when opengl batching is active +#define PS_HIDE_ZERO 32 // hide metric if its value is zero -precise_t ps_playerthink_time = 0; -precise_t ps_thinkertime = 0; +static ps_metric_t ps_frametime = {0}; -precise_t ps_thlist_times[NUM_THINKERLISTS]; +ps_metric_t ps_tictime = {0}; -int ps_checkposition_calls = 0; +ps_metric_t ps_playerthink_time = {0}; +ps_metric_t ps_thinkertime = {0}; -precise_t ps_lua_thinkframe_time = 0; -int ps_lua_mobjhooks = 0; +ps_metric_t ps_thlist_times[NUM_THINKERLISTS]; + +static ps_metric_t ps_thinkercount = {0}; +static ps_metric_t ps_polythcount = {0}; +static ps_metric_t ps_mainthcount = {0}; +static ps_metric_t ps_mobjcount = {0}; +static ps_metric_t ps_regularcount = {0}; +static ps_metric_t ps_scenerycount = {0}; +static ps_metric_t ps_nothinkcount = {0}; +static ps_metric_t ps_dynslopethcount = {0}; +static ps_metric_t ps_precipcount = {0}; +static ps_metric_t ps_removecount = {0}; + +ps_metric_t ps_checkposition_calls = {0}; + +ps_metric_t ps_lua_thinkframe_time = {0}; +ps_metric_t ps_lua_mobjhooks = {0}; + +ps_metric_t ps_otherlogictime = {0}; + +// Columns for perfstats pages. + +// Position on screen is determined separately in the drawing functions. + +// New columns must also be added to the drawing and update functions. +// Drawing functions: PS_DrawRenderStats, PS_DrawGameLogicStats, etc. +// Update functions: +// - PS_UpdateFrameStats for frame-dependent values +// - PS_UpdateTickStats for tick-dependent values + +// Rendering stats columns + +perfstatrow_t rendertime_rows[] = { + {"frmtime", "Frame time: ", &ps_frametime, PS_TIME}, + {"drwtime", "3d rendering: ", &ps_rendercalltime, PS_TIME|PS_LEVEL}, + +#ifdef HWRENDER + {" skybox ", " Skybox render: ", &ps_hw_skyboxtime, PS_TIME|PS_LEVEL|PS_HW}, + {" bsptime", " RenderBSPNode: ", &ps_bsptime, PS_TIME|PS_LEVEL|PS_HW}, + {" batsort", " Batch sort: ", &ps_hw_batchsorttime, PS_TIME|PS_LEVEL|PS_HW|PS_BATCHING}, + {" batdraw", " Batch render: ", &ps_hw_batchdrawtime, PS_TIME|PS_LEVEL|PS_HW|PS_BATCHING}, + {" sprsort", " Sprite sort: ", &ps_hw_spritesorttime, PS_TIME|PS_LEVEL|PS_HW}, + {" sprdraw", " Sprite render: ", &ps_hw_spritedrawtime, PS_TIME|PS_LEVEL|PS_HW}, + {" nodesrt", " Drwnode sort: ", &ps_hw_nodesorttime, PS_TIME|PS_LEVEL|PS_HW}, + {" nodedrw", " Drwnode render:", &ps_hw_nodedrawtime, PS_TIME|PS_LEVEL|PS_HW}, + {" other ", " Other: ", &ps_otherrendertime, PS_TIME|PS_LEVEL|PS_HW}, +#endif + + {" bsptime", " RenderBSPNode: ", &ps_bsptime, PS_TIME|PS_LEVEL|PS_SW}, + {" sprclip", " R_ClipSprites: ", &ps_sw_spritecliptime, PS_TIME|PS_LEVEL|PS_SW}, + {" portals", " Portals+Skybox:", &ps_sw_portaltime, PS_TIME|PS_LEVEL|PS_SW}, + {" planes ", " R_DrawPlanes: ", &ps_sw_planetime, PS_TIME|PS_LEVEL|PS_SW}, + {" masked ", " R_DrawMasked: ", &ps_sw_maskedtime, PS_TIME|PS_LEVEL|PS_SW}, + {" other ", " Other: ", &ps_otherrendertime, PS_TIME|PS_LEVEL|PS_SW}, + + {"ui ", "UI render: ", &ps_uitime, PS_TIME}, + {"finupdt", "I_FinishUpdate:", &ps_swaptime, PS_TIME}, + {0} +}; + +perfstatrow_t gamelogicbrief_row[] = { + {"logic ", "Game logic: ", &ps_tictime, PS_TIME}, + {0} +}; + +perfstatrow_t commoncounter_rows[] = { + {"bspcall", "BSP calls: ", &ps_numbspcalls, 0}, + {"sprites", "Sprites: ", &ps_numsprites, 0}, + {"drwnode", "Drawnodes: ", &ps_numdrawnodes, 0}, + {"plyobjs", "Polyobjects: ", &ps_numpolyobjects, 0}, + {0} +}; + +#ifdef HWRENDER +perfstatrow_t batchcount_rows[] = { + {"polygon", "Polygons: ", &ps_hw_numpolys, 0}, + {"vertex ", "Vertices: ", &ps_hw_numverts, 0}, + {0} +}; + +perfstatrow_t batchcalls_rows[] = { + {"drwcall", "Draw calls:", &ps_hw_numcalls, 0}, + {"shaders", "Shaders: ", &ps_hw_numshaders, 0}, + {"texture", "Textures: ", &ps_hw_numtextures, 0}, + {"polyflg", "Polyflags: ", &ps_hw_numpolyflags, 0}, + {"colors ", "Colors: ", &ps_hw_numcolors, 0}, + {0} +}; +#endif + +// Game logic stats columns + +perfstatrow_t gamelogic_rows[] = { + {"logic ", "Game logic: ", &ps_tictime, PS_TIME}, + {" plrthnk", " P_PlayerThink: ", &ps_playerthink_time, PS_TIME|PS_LEVEL}, + {" thnkers", " P_RunThinkers: ", &ps_thinkertime, PS_TIME|PS_LEVEL}, + {" plyobjs", " Polyobjects: ", &ps_thlist_times[THINK_POLYOBJ], PS_TIME|PS_LEVEL}, + {" main ", " Main: ", &ps_thlist_times[THINK_MAIN], PS_TIME|PS_LEVEL}, + {" mobjs ", " Mobjs: ", &ps_thlist_times[THINK_MOBJ], PS_TIME|PS_LEVEL}, + {" dynslop", " Dynamic slopes: ", &ps_thlist_times[THINK_DYNSLOPE], PS_TIME|PS_LEVEL}, + {" precip ", " Precipitation: ", &ps_thlist_times[THINK_PRECIP], PS_TIME|PS_LEVEL}, + {" lthinkf", " LUAh_ThinkFrame:", &ps_lua_thinkframe_time, PS_TIME|PS_LEVEL}, + {" other ", " Other: ", &ps_otherlogictime, PS_TIME|PS_LEVEL}, + {0} +}; + +perfstatrow_t thinkercount_rows[] = { + {"thnkers", "Thinkers: ", &ps_thinkercount, PS_LEVEL}, + {" plyobjs", " Polyobjects: ", &ps_polythcount, PS_LEVEL}, + {" main ", " Main: ", &ps_mainthcount, 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}, + {" dynslop", " Dynamic slopes: ", &ps_dynslopethcount, PS_LEVEL}, + {" precip ", " Precipitation: ", &ps_precipcount, PS_LEVEL}, + {" remove ", " Pending removal:", &ps_removecount, PS_LEVEL}, + {0} +}; + +perfstatrow_t misc_calls_rows[] = { + {"lmhook", "Lua mobj hooks: ", &ps_lua_mobjhooks, PS_LEVEL}, + {"chkpos", "P_CheckPosition:", &ps_checkposition_calls, PS_LEVEL}, + {0} +}; + +// Sample collection status for averaging. +// Maximum of these two is shown to user if nonzero to tell that +// the reported averages are not correct yet. +int ps_frame_samples_left = 0; +int ps_tick_samples_left = 0; +// History writing positions for frame and tick based metrics +int ps_frame_index = 0; +int ps_tick_index = 0; // dynamically allocated resizeable array for thinkframe hook stats ps_hookinfo_t *thinkframe_hooks = NULL; int thinkframe_hooks_length = 0; int thinkframe_hooks_capacity = 16; -static INT32 draw_row; - void PS_SetThinkFrameHookInfo(int index, precise_t time_taken, char* short_src) { if (!thinkframe_hooks) @@ -76,506 +203,617 @@ void PS_SetThinkFrameHookInfo(int index, precise_t time_taken, char* short_src) thinkframe_hooks = Z_Realloc(thinkframe_hooks, sizeof(ps_hookinfo_t) * thinkframe_hooks_capacity, PU_STATIC, NULL); } - thinkframe_hooks[index].time_taken = time_taken; + thinkframe_hooks[index].time_taken.value.p = time_taken; memcpy(thinkframe_hooks[index].short_src, short_src, LUA_IDSIZE * sizeof(char)); // since the values are set sequentially from begin to end, the last call should leave // the correct value to this variable thinkframe_hooks_length = index + 1; } -static void PS_SetFrameTime(void) -{ - precise_t currenttime = I_GetPreciseTime(); - ps_frametime = currenttime - ps_prevframetime; - ps_prevframetime = currenttime; -} - -static boolean M_HighResolution(void) +static boolean PS_HighResolution(void) { return (vid.width >= 640 && vid.height >= 400); } -enum { - PERF_TIME, - PERF_COUNT, -}; - -static void M_DrawPerfString(perfstatcol_t *col, int type) +static boolean PS_IsLevelActive(void) { - const boolean hires = M_HighResolution(); + return gamestate == GS_LEVEL || + (gamestate == GS_TITLESCREEN && titlemapinaction); +} - INT32 draw_flags = V_MONOSPACE | col->color; +// Is the row valid in the current context? +static boolean PS_IsRowValid(perfstatrow_t *row) +{ + return !((row->flags & PS_LEVEL && !PS_IsLevelActive()) || + (row->flags & PS_SW && rendermode != render_soft) || + (row->flags & PS_HW && rendermode != render_opengl) || + (row->flags & PS_BATCHING && !cv_glbatching.value)); +} +// Should the row be visible on the screen? +static boolean PS_IsRowVisible(perfstatrow_t *row) +{ + boolean value_is_zero; + + if (row->flags & PS_TIME) + value_is_zero = row->metric->value.p == 0; + else + value_is_zero = row->metric->value.i == 0; + + return !(!PS_IsRowValid(row) || + (row->flags & PS_HIDE_ZERO && value_is_zero)); +} + +static INT32 PS_GetMetricAverage(ps_metric_t *metric, boolean time_metric) +{ + char* history_read_pos = metric->history; // char* used for pointer arithmetic + INT64 sum = 0; + int i; + int value_size = time_metric ? sizeof(precise_t) : sizeof(INT32); + + for (i = 0; i < cv_ps_samplesize.value; i++) + { + if (time_metric) + sum += I_PreciseToMicros(*((precise_t*)history_read_pos)); + else + sum += *((INT32*)history_read_pos); + history_read_pos += value_size; + } + + return sum / cv_ps_samplesize.value; +} + +static INT32 PS_GetMetricMinOrMax(ps_metric_t *metric, boolean time_metric, boolean get_max) +{ + char* history_read_pos = metric->history; // char* used for pointer arithmetic + INT32 found_value = get_max ? INT32_MIN : INT32_MAX; + int i; + int value_size = time_metric ? sizeof(precise_t) : sizeof(INT32); + + for (i = 0; i < cv_ps_samplesize.value; i++) + { + INT32 value; + if (time_metric) + value = I_PreciseToMicros(*((precise_t*)history_read_pos)); + else + value = *((INT32*)history_read_pos); + + if ((get_max && value > found_value) || + (!get_max && value < found_value)) + { + found_value = value; + } + history_read_pos += value_size; + } + + return found_value; +} + +// Calculates the standard deviation for metric. +static INT32 PS_GetMetricSD(ps_metric_t *metric, boolean time_metric) +{ + char* history_read_pos = metric->history; // char* used for pointer arithmetic + INT64 sum = 0; + int i; + int value_size = time_metric ? sizeof(precise_t) : sizeof(INT32); + INT32 avg = PS_GetMetricAverage(metric, time_metric); + + for (i = 0; i < cv_ps_samplesize.value; i++) + { + INT64 value; + if (time_metric) + value = I_PreciseToMicros(*((precise_t*)history_read_pos)); + else + value = *((INT32*)history_read_pos); + + value -= avg; + sum += value * value; + + history_read_pos += value_size; + } + + return round(sqrt(sum / cv_ps_samplesize.value)); +} + +// Returns the value to show on screen for metric. +static INT32 PS_GetMetricScreenValue(ps_metric_t *metric, boolean time_metric) +{ + if (cv_ps_samplesize.value > 1 && metric->history) + { + if (cv_ps_descriptor.value == 1) + return PS_GetMetricAverage(metric, time_metric); + else if (cv_ps_descriptor.value == 2) + return PS_GetMetricSD(metric, time_metric); + else if (cv_ps_descriptor.value == 3) + return PS_GetMetricMinOrMax(metric, time_metric, false); + else + return PS_GetMetricMinOrMax(metric, time_metric, true); + } + else + { + if (time_metric) + return I_PreciseToMicros(metric->value.p); + else + return metric->value.i; + } +} + +static int PS_DrawPerfRows(int x, int y, int color, perfstatrow_t *rows) +{ + const boolean hires = PS_HighResolution(); + INT32 draw_flags = V_MONOSPACE | color; perfstatrow_t * row; - - int value; + int draw_y = y; if (hires) draw_flags |= V_ALLOWLOWERCASE; - for (row = col->rows; row->lores_label; ++row) + for (row = rows; row->lores_label; ++row) { - if (type == PERF_TIME) - value = I_PreciseToMicros(*(precise_t *)row->value); - else - value = *(int *)row->value; + const char *label; + INT32 value; + char *final_str; + + if (!PS_IsRowVisible(row)) + continue; + + label = hires ? row->hires_label : row->lores_label; + value = PS_GetMetricScreenValue(row->metric, !!(row->flags & PS_TIME)); + final_str = va("%s %d", label, value); if (hires) { - V_DrawSmallString(col->hires_x, draw_row, draw_flags, - va("%s %d", row->hires_label, value)); - - draw_row += 5; + V_DrawSmallString(x, draw_y, draw_flags, final_str); + draw_y += 5; } else { - V_DrawThinString(col->lores_x, draw_row, draw_flags, - va("%s %d", row->lores_label, value)); - - draw_row += 8; + V_DrawThinString(x, draw_y, draw_flags, final_str); + draw_y += 8; } } + + return draw_y; +} + +static void PS_UpdateMetricHistory(ps_metric_t *metric, boolean time_metric, boolean frame_metric, boolean set_user) +{ + int index = frame_metric ? ps_frame_index : ps_tick_index; + + if (!metric->history) + { + // allocate history table + int value_size = time_metric ? sizeof(precise_t) : sizeof(INT32); + void** memory_user = set_user ? &metric->history : NULL; + + metric->history = Z_Calloc(value_size * cv_ps_samplesize.value, PU_PERFSTATS, + memory_user); + + // reset "samples left" counter since this history table needs to be filled + if (frame_metric) + ps_frame_samples_left = cv_ps_samplesize.value; + else + ps_tick_samples_left = cv_ps_samplesize.value; + } + + if (time_metric) + { + precise_t *history = (precise_t*)metric->history; + history[index] = metric->value.p; + } + else + { + INT32 *history = (INT32*)metric->history; + history[index] = metric->value.i; + } } -static void M_DrawPerfTiming(perfstatcol_t *col) +static void PS_UpdateRowHistories(perfstatrow_t *rows, boolean frame_metric) { - M_DrawPerfString(col, PERF_TIME); -} - -static void M_DrawPerfCount(perfstatcol_t *col) -{ - M_DrawPerfString(col, PERF_COUNT); -} - -static void M_DrawRenderStats(void) -{ - const boolean hires = M_HighResolution(); - - const int half_row = hires ? 5 : 4; - - precise_t extrarendertime; - - perfstatrow_t frametime_row[] = { - {"frmtime", "Frame time: ", &ps_frametime}, - {0} - }; - - perfstatrow_t rendercalltime_row[] = { - {"drwtime", "3d rendering: ", &ps_rendercalltime}, - {0} - }; - - perfstatrow_t opengltime_row[] = { - {"skybox ", "Skybox render: ", &ps_hw_skyboxtime}, - {"bsptime", "RenderBSPNode: ", &ps_bsptime}, - {"nodesrt", "Drwnode sort: ", &ps_hw_nodesorttime}, - {"nodedrw", "Drwnode render:", &ps_hw_nodedrawtime}, - {"sprsort", "Sprite sort: ", &ps_hw_spritesorttime}, - {"sprdraw", "Sprite render: ", &ps_hw_spritedrawtime}, - {"other ", "Other: ", &extrarendertime}, - {0} - }; - - perfstatrow_t softwaretime_row[] = { - {"bsptime", "RenderBSPNode: ", &ps_bsptime}, - {"sprclip", "R_ClipSprites: ", &ps_sw_spritecliptime}, - {"portals", "Portals+Skybox:", &ps_sw_portaltime}, - {"planes ", "R_DrawPlanes: ", &ps_sw_planetime}, - {"masked ", "R_DrawMasked: ", &ps_sw_maskedtime}, - {"other ", "Other: ", &extrarendertime}, - {0} - }; - - perfstatrow_t uiswaptime_row[] = { - {"ui ", "UI render: ", &ps_uitime}, - {"finupdt", "I_FinishUpdate:", &ps_swaptime}, - {0} - }; - - perfstatrow_t tictime_row[] = { - {"logic ", "Game logic: ", &ps_tictime}, - {0} - }; - - perfstatrow_t rendercalls_row[] = { - {"bspcall", "BSP calls: ", &ps_numbspcalls}, - {"sprites", "Sprites: ", &ps_numsprites}, - {"drwnode", "Drawnodes: ", &ps_numdrawnodes}, - {"plyobjs", "Polyobjects: ", &ps_numpolyobjects}, - {0} - }; - - perfstatrow_t batchtime_row[] = { - {"batsort", "Batch sort: ", &ps_hw_batchsorttime}, - {"batdraw", "Batch render:", &ps_hw_batchdrawtime}, - {0} - }; - - perfstatrow_t batchcount_row[] = { - {"polygon", "Polygons: ", &ps_hw_numpolys}, - {"vertex ", "Vertices: ", &ps_hw_numverts}, - {0} - }; - - perfstatrow_t batchcalls_row[] = { - {"drwcall", "Draw calls:", &ps_hw_numcalls}, - {"shaders", "Shaders: ", &ps_hw_numshaders}, - {"texture", "Textures: ", &ps_hw_numtextures}, - {"polyflg", "Polyflags: ", &ps_hw_numpolyflags}, - {"colors ", "Colors: ", &ps_hw_numcolors}, - {0} - }; - - perfstatcol_t frametime_col = {20, 20, V_YELLOWMAP, frametime_row}; - perfstatcol_t rendercalltime_col = {20, 20, V_YELLOWMAP, rendercalltime_row}; - - perfstatcol_t opengltime_col = {24, 24, V_YELLOWMAP, opengltime_row}; - perfstatcol_t softwaretime_col = {24, 24, V_YELLOWMAP, softwaretime_row}; - - perfstatcol_t uiswaptime_col = {20, 20, V_YELLOWMAP, uiswaptime_row}; - perfstatcol_t tictime_col = {20, 20, V_GRAYMAP, tictime_row}; - - perfstatcol_t rendercalls_col = {90, 115, V_BLUEMAP, rendercalls_row}; - - perfstatcol_t batchtime_col = {90, 115, V_REDMAP, batchtime_row}; - - perfstatcol_t batchcount_col = {155, 200, V_PURPLEMAP, batchcount_row}; - perfstatcol_t batchcalls_col = {220, 200, V_PURPLEMAP, batchcalls_row}; - - - boolean rendering = ( - gamestate == GS_LEVEL || - (gamestate == GS_TITLESCREEN && titlemapinaction) - ); - - draw_row = 10; - M_DrawPerfTiming(&frametime_col); - - if (rendering) + perfstatrow_t *row; + for (row = rows; row->lores_label; row++) { - M_DrawPerfTiming(&rendercalltime_col); + if (PS_IsRowValid(row)) + PS_UpdateMetricHistory(row->metric, !!(row->flags & PS_TIME), frame_metric, true); + } +} +// Update all metrics that are calculated on every frame. +static void PS_UpdateFrameStats(void) +{ + // update frame time + precise_t currenttime = I_GetPreciseTime(); + ps_frametime.value.p = currenttime - ps_prevframetime; + ps_prevframetime = currenttime; + + // update 3d rendering stats + if (PS_IsLevelActive()) + { // Remember to update this calculation when adding more 3d rendering stats! - extrarendertime = ps_rendercalltime - ps_bsptime; + ps_otherrendertime.value.p = ps_rendercalltime.value.p - ps_bsptime.value.p; #ifdef HWRENDER if (rendermode == render_opengl) { - extrarendertime -= - ps_hw_skyboxtime + - ps_hw_nodesorttime + - ps_hw_nodedrawtime + - ps_hw_spritesorttime + - ps_hw_spritedrawtime; + ps_otherrendertime.value.p -= + ps_hw_skyboxtime.value.p + + ps_hw_nodesorttime.value.p + + ps_hw_nodedrawtime.value.p + + ps_hw_spritesorttime.value.p + + ps_hw_spritedrawtime.value.p; if (cv_glbatching.value) { - extrarendertime -= - ps_hw_batchsorttime + - ps_hw_batchdrawtime; + ps_otherrendertime.value.p -= + ps_hw_batchsorttime.value.p + + ps_hw_batchdrawtime.value.p; } - - M_DrawPerfTiming(&opengltime_col); } else #endif { - extrarendertime -= - ps_sw_spritecliptime + - ps_sw_portaltime + - ps_sw_planetime + - ps_sw_maskedtime; - - M_DrawPerfTiming(&softwaretime_col); + ps_otherrendertime.value.p -= + ps_sw_spritecliptime.value.p + + ps_sw_portaltime.value.p + + ps_sw_planetime.value.p + + ps_sw_maskedtime.value.p; } } - M_DrawPerfTiming(&uiswaptime_col); - - draw_row += half_row; - M_DrawPerfTiming(&tictime_col); - - if (rendering) + if (cv_ps_samplesize.value > 1) { - draw_row = 10; - M_DrawPerfCount(&rendercalls_col); + PS_UpdateRowHistories(rendertime_rows, true); + if (PS_IsLevelActive()) + PS_UpdateRowHistories(commoncounter_rows, true); #ifdef HWRENDER if (rendermode == render_opengl && cv_glbatching.value) { - draw_row += half_row; - M_DrawPerfTiming(&batchtime_col); - - draw_row = 10; - M_DrawPerfCount(&batchcount_col); - - if (hires) - draw_row += half_row; - else - draw_row = 10; - - M_DrawPerfCount(&batchcalls_col); + PS_UpdateRowHistories(batchcount_rows, true); + PS_UpdateRowHistories(batchcalls_rows, true); } #endif + + ps_frame_index++; + if (ps_frame_index >= cv_ps_samplesize.value) + ps_frame_index = 0; + if (ps_frame_samples_left) + ps_frame_samples_left--; } } -static void M_DrawTickStats(void) +// Update thinker counters by iterating the thinker lists. +static void PS_CountThinkers(void) { - int i = 0; + int i; thinker_t *thinker; - int thinkercount = 0; - int polythcount = 0; - int mainthcount = 0; - int mobjcount = 0; - int nothinkcount = 0; - int scenerycount = 0; - int regularcount = 0; - int dynslopethcount = 0; - int precipcount = 0; - int removecount = 0; - precise_t extratime = - ps_tictime - - ps_playerthink_time - - ps_thinkertime - - ps_lua_thinkframe_time; - - perfstatrow_t tictime_row[] = { - {"logic ", "Game logic: ", &ps_tictime}, - {0} - }; - - perfstatrow_t thinker_time_row[] = { - {"plrthnk", "P_PlayerThink: ", &ps_playerthink_time}, - {"thnkers", "P_RunThinkers: ", &ps_thinkertime}, - {0} - }; - - perfstatrow_t detailed_thinker_time_row[] = { - {"plyobjs", "Polyobjects: ", &ps_thlist_times[THINK_POLYOBJ]}, - {"main ", "Main: ", &ps_thlist_times[THINK_MAIN]}, - {"mobjs ", "Mobjs: ", &ps_thlist_times[THINK_MOBJ]}, - {"dynslop", "Dynamic slopes: ", &ps_thlist_times[THINK_DYNSLOPE]}, - {"precip ", "Precipitation: ", &ps_thlist_times[THINK_PRECIP]}, - {0} - }; - - perfstatrow_t extra_thinker_time_row[] = { - {"lthinkf", "LUAh_ThinkFrame:", &ps_lua_thinkframe_time}, - {"other ", "Other: ", &extratime}, - {0} - }; - - perfstatrow_t thinkercount_row[] = { - {"thnkers", "Thinkers: ", &thinkercount}, - {0} - }; - - perfstatrow_t detailed_thinkercount_row[] = { - {"plyobjs", "Polyobjects: ", &polythcount}, - {"main ", "Main: ", &mainthcount}, - {"mobjs ", "Mobjs: ", &mobjcount}, - {0} - }; - - perfstatrow_t mobjthinkercount_row[] = { - {"regular", "Regular: ", ®ularcount}, - {"scenery", "Scenery: ", &scenerycount}, - {0} - }; - - perfstatrow_t nothinkcount_row[] = { - {"nothink", "Nothink: ", ¬hinkcount}, - {0} - }; - - perfstatrow_t detailed_thinkercount_row2[] = { - {"dynslop", "Dynamic slopes: ", &dynslopethcount}, - {"precip ", "Precipitation: ", &precipcount}, - {"remove ", "Pending removal:", &removecount}, - {0} - }; - - perfstatrow_t misc_calls_row[] = { - {"lmhook", "Lua mobj hooks: ", &ps_lua_mobjhooks}, - {"chkpos", "P_CheckPosition:", &ps_checkposition_calls}, - {0} - }; - - perfstatcol_t tictime_col = {20, 20, V_YELLOWMAP, tictime_row}; - perfstatcol_t thinker_time_col = {24, 24, V_YELLOWMAP, thinker_time_row}; - perfstatcol_t detailed_thinker_time_col = {28, 28, V_YELLOWMAP, detailed_thinker_time_row}; - perfstatcol_t extra_thinker_time_col = {24, 24, V_YELLOWMAP, extra_thinker_time_row}; - - perfstatcol_t thinkercount_col = {90, 115, V_BLUEMAP, thinkercount_row}; - perfstatcol_t detailed_thinkercount_col = {94, 119, V_BLUEMAP, detailed_thinkercount_row}; - perfstatcol_t mobjthinkercount_col = {98, 123, V_BLUEMAP, mobjthinkercount_row}; - perfstatcol_t nothinkcount_col = {98, 123, V_BLUEMAP, nothinkcount_row}; - perfstatcol_t detailed_thinkercount_col2 = {94, 119, V_BLUEMAP, detailed_thinkercount_row2}; - perfstatcol_t misc_calls_col = {170, 216, V_PURPLEMAP, misc_calls_row}; + ps_thinkercount.value.i = 0; + ps_polythcount.value.i = 0; + ps_mainthcount.value.i = 0; + ps_mobjcount.value.i = 0; + ps_regularcount.value.i = 0; + ps_scenerycount.value.i = 0; + ps_nothinkcount.value.i = 0; + ps_dynslopethcount.value.i = 0; + ps_precipcount.value.i = 0; + ps_removecount.value.i = 0; for (i = 0; i < NUM_THINKERLISTS; i++) { for (thinker = thlist[i].next; thinker != &thlist[i]; thinker = thinker->next) { - thinkercount++; + ps_thinkercount.value.i++; if (thinker->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) - removecount++; + ps_removecount.value.i++; else if (i == THINK_POLYOBJ) - polythcount++; + ps_polythcount.value.i++; else if (i == THINK_MAIN) - mainthcount++; + ps_mainthcount.value.i++; else if (i == THINK_MOBJ) { if (thinker->function.acp1 == (actionf_p1)P_MobjThinker) { mobj_t *mobj = (mobj_t*)thinker; - mobjcount++; + ps_mobjcount.value.i++; if (mobj->flags & MF_NOTHINK) - nothinkcount++; + ps_nothinkcount.value.i++; else if (mobj->flags & MF_SCENERY) - scenerycount++; + ps_scenerycount.value.i++; else - regularcount++; + ps_regularcount.value.i++; } } else if (i == THINK_DYNSLOPE) - dynslopethcount++; + ps_dynslopethcount.value.i++; else if (i == THINK_PRECIP) - precipcount++; + ps_precipcount.value.i++; } } +} - draw_row = 10; - M_DrawPerfTiming(&tictime_col); - M_DrawPerfTiming(&thinker_time_col); - M_DrawPerfTiming(&detailed_thinker_time_col); - M_DrawPerfTiming(&extra_thinker_time_col); - - draw_row = 10; - M_DrawPerfCount(&thinkercount_col); - M_DrawPerfCount(&detailed_thinkercount_col); - M_DrawPerfCount(&mobjthinkercount_col); - - if (nothinkcount) - M_DrawPerfCount(¬hinkcount_col); - - M_DrawPerfCount(&detailed_thinkercount_col2); - - if (M_HighResolution()) +// Update all metrics that are calculated on every tick. +void PS_UpdateTickStats(void) +{ + if (cv_perfstats.value == 1 && cv_ps_samplesize.value > 1) { + PS_UpdateRowHistories(gamelogicbrief_row, false); + } + if (cv_perfstats.value == 2) + { + if (PS_IsLevelActive()) + { + ps_otherlogictime.value.p = + ps_tictime.value.p - + ps_playerthink_time.value.p - + ps_thinkertime.value.p - + ps_lua_thinkframe_time.value.p; + + PS_CountThinkers(); + } + + if (cv_ps_samplesize.value > 1) + { + PS_UpdateRowHistories(gamelogic_rows, false); + PS_UpdateRowHistories(thinkercount_rows, false); + PS_UpdateRowHistories(misc_calls_rows, false); + } + } + if (cv_perfstats.value == 3 && cv_ps_samplesize.value > 1 && PS_IsLevelActive()) + { + int i; + for (i = 0; i < thinkframe_hooks_length; i++) + { + PS_UpdateMetricHistory(&thinkframe_hooks[i].time_taken, true, false, false); + } + } + if (cv_perfstats.value && cv_ps_samplesize.value > 1) + { + ps_tick_index++; + if (ps_tick_index >= cv_ps_samplesize.value) + ps_tick_index = 0; + if (ps_tick_samples_left) + ps_tick_samples_left--; + } +} + +static void PS_DrawDescriptorHeader(void) +{ + if (cv_ps_samplesize.value > 1) + { + const char* descriptor_names[] = { + "average", + "standard deviation", + "minimum", + "maximum" + }; + const boolean hires = PS_HighResolution(); + char* str; + INT32 flags = V_MONOSPACE | V_ALLOWLOWERCASE; + int samples_left = max(ps_frame_samples_left, ps_tick_samples_left); + int x, y; + + if (cv_perfstats.value == 3) + { + x = 2; + y = 0; + } + else + { + x = 20; + y = hires ? 5 : 2; + } + + if (samples_left) + { + str = va("Samples needed for correct results: %d", samples_left); + flags |= V_REDMAP; + } + else + { + str = va("Showing the %s of %d samples.", + descriptor_names[cv_ps_descriptor.value - 1], cv_ps_samplesize.value); + flags |= V_GREENMAP; + } + + if (hires) + V_DrawSmallString(x, y, flags, str); + else + V_DrawThinString(x, y, flags, str); + } +} + +static void PS_DrawRenderStats(void) +{ + const boolean hires = PS_HighResolution(); + const int half_row = hires ? 5 : 4; + int x, y; + + PS_DrawDescriptorHeader(); + + y = PS_DrawPerfRows(20, 10, V_YELLOWMAP, rendertime_rows); + + PS_DrawPerfRows(20, y + half_row, V_GRAYMAP, gamelogicbrief_row); + + if (PS_IsLevelActive()) + { + x = hires ? 115 : 90; + PS_DrawPerfRows(x, 10, V_BLUEMAP, commoncounter_rows); + +#ifdef HWRENDER + if (rendermode == render_opengl && cv_glbatching.value) + { + x = hires ? 200 : 155; + y = PS_DrawPerfRows(x, 10, V_PURPLEMAP, batchcount_rows); + + x = hires ? 200 : 220; + y = hires ? y + half_row : 10; + PS_DrawPerfRows(x, y, V_PURPLEMAP, batchcalls_rows); + } +#endif + } +} + +static void PS_DrawGameLogicStats(void) +{ + const boolean hires = PS_HighResolution(); + int x, y; + + PS_DrawDescriptorHeader(); + + PS_DrawPerfRows(20, 10, V_YELLOWMAP, gamelogic_rows); + + x = hires ? 115 : 90; + PS_DrawPerfRows(x, 10, V_BLUEMAP, thinkercount_rows); + + if (hires) V_DrawSmallString(212, 10, V_MONOSPACE | V_ALLOWLOWERCASE | V_PURPLEMAP, "Calls:"); - draw_row = 15; - } - else - { - draw_row = 10; - } + x = hires ? 216 : 170; + y = hires ? 15 : 10; + PS_DrawPerfRows(x, y, V_PURPLEMAP, misc_calls_rows); +} - M_DrawPerfCount(&misc_calls_col); +static void PS_DrawThinkFrameStats(void) +{ + char s[100]; + int i; + // text writing position + int x = 2; + int y = 4; + UINT32 text_color; + char tempbuffer[LUA_IDSIZE]; + char last_mod_name[LUA_IDSIZE]; + last_mod_name[0] = '\0'; + + PS_DrawDescriptorHeader(); + + for (i = 0; i < thinkframe_hooks_length; i++) + { + +#define NEXT_ROW() \ +y += 4; \ +if (y > 192) \ +{ \ + y = 4; \ + x += 106; \ + if (x > 214) \ + break; \ +} + + char* str = thinkframe_hooks[i].short_src; + char* tempstr = tempbuffer; + int len = (int)strlen(str); + char* str_ptr; + if (strcmp(".lua", str + len - 4) == 0) + { + str[len-4] = '\0'; // remove .lua at end + len -= 4; + } + // we locate the wad/pk3 name in the string and compare it to + // what we found on the previous iteration. + // if the name has changed, print it out on the screen + strcpy(tempstr, str); + str_ptr = strrchr(tempstr, '|'); + if (str_ptr) + { + *str_ptr = '\0'; + str = str_ptr + 1; // this is the name of the hook without the mod file name + str_ptr = strrchr(tempstr, PATHSEP[0]); + if (str_ptr) + tempstr = str_ptr + 1; + // tempstr should now point to the mod name, (wad/pk3) possibly truncated + if (strcmp(tempstr, last_mod_name) != 0) + { + strcpy(last_mod_name, tempstr); + len = (int)strlen(tempstr); + if (len > 25) + tempstr += len - 25; + snprintf(s, sizeof s - 1, "%s", tempstr); + V_DrawSmallString(x, y, V_MONOSPACE | V_ALLOWLOWERCASE | V_GRAYMAP, s); + NEXT_ROW() + } + text_color = V_YELLOWMAP; + } + else + { + // probably a standalone lua file + // cut off the folder if it's there + str_ptr = strrchr(tempstr, PATHSEP[0]); + if (str_ptr) + str = str_ptr + 1; + text_color = 0; // white + } + len = (int)strlen(str); + if (len > 20) + str += len - 20; + snprintf(s, sizeof s - 1, "%20s: %d", str, + PS_GetMetricScreenValue(&thinkframe_hooks[i].time_taken, true)); + V_DrawSmallString(x, y, V_MONOSPACE | V_ALLOWLOWERCASE | text_color, s); + NEXT_ROW() + +#undef NEXT_ROW + + } } void M_DrawPerfStats(void) { - char s[100]; - - PS_SetFrameTime(); - if (cv_perfstats.value == 1) // rendering { - M_DrawRenderStats(); + PS_UpdateFrameStats(); + PS_DrawRenderStats(); } else if (cv_perfstats.value == 2) // logic { - M_DrawTickStats(); + // 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 { - if (!(gamestate == GS_LEVEL || (gamestate == GS_TITLESCREEN && titlemapinaction))) + if (!PS_IsLevelActive()) return; - if (vid.width < 640 || vid.height < 400) // low resolution + if (!PS_HighResolution()) { - // it's not gonna fit very well.. - V_DrawThinString(30, 30, V_MONOSPACE | V_ALLOWLOWERCASE | V_YELLOWMAP, "Not available for resolutions below 640x400"); + // Low resolutions can't really use V_DrawSmallString that is used by thinkframe stats. + // A low-res version using V_DrawThinString could be implemented, + // but it would have much less space for information. + V_DrawThinString(80, 92, V_MONOSPACE | V_ALLOWLOWERCASE | V_YELLOWMAP, "Perfstats 3 is not available"); + V_DrawThinString(80, 100, V_MONOSPACE | V_ALLOWLOWERCASE | V_YELLOWMAP, "for resolutions below 640x400."); } - else // high resolution + else { - int i; - // text writing position - int x = 2; - int y = 4; - UINT32 text_color; - char tempbuffer[LUA_IDSIZE]; - char last_mod_name[LUA_IDSIZE]; - last_mod_name[0] = '\0'; - for (i = 0; i < thinkframe_hooks_length; i++) - { - char* str = thinkframe_hooks[i].short_src; - char* tempstr = tempbuffer; - int len = (int)strlen(str); - char* str_ptr; - if (strcmp(".lua", str + len - 4) == 0) - { - str[len-4] = '\0'; // remove .lua at end - len -= 4; - } - // we locate the wad/pk3 name in the string and compare it to - // what we found on the previous iteration. - // if the name has changed, print it out on the screen - strcpy(tempstr, str); - str_ptr = strrchr(tempstr, '|'); - if (str_ptr) - { - *str_ptr = '\0'; - str = str_ptr + 1; // this is the name of the hook without the mod file name - str_ptr = strrchr(tempstr, PATHSEP[0]); - if (str_ptr) - tempstr = str_ptr + 1; - // tempstr should now point to the mod name, (wad/pk3) possibly truncated - if (strcmp(tempstr, last_mod_name) != 0) - { - strcpy(last_mod_name, tempstr); - len = (int)strlen(tempstr); - if (len > 25) - tempstr += len - 25; - snprintf(s, sizeof s - 1, "%s", tempstr); - V_DrawSmallString(x, y, V_MONOSPACE | V_ALLOWLOWERCASE | V_GRAYMAP, s); - y += 4; // repeated code! - if (y > 192) - { - y = 4; - x += 106; - if (x > 214) - break; - } - } - text_color = V_YELLOWMAP; - } - else - { - // probably a standalone lua file - // cut off the folder if it's there - str_ptr = strrchr(tempstr, PATHSEP[0]); - if (str_ptr) - str = str_ptr + 1; - text_color = 0; // white - } - len = (int)strlen(str); - if (len > 20) - str += len - 20; - snprintf(s, sizeof s - 1, "%20s: %d", str, I_PreciseToMicros(thinkframe_hooks[i].time_taken)); - V_DrawSmallString(x, y, V_MONOSPACE | V_ALLOWLOWERCASE | text_color, s); - y += 4; // repeated code! - if (y > 192) - { - y = 4; - x += 106; - if (x > 214) - break; - } - } + PS_DrawThinkFrameStats(); } } } + +// remove and unallocate history from all metrics +static void PS_ClearHistory(void) +{ + int i; + + Z_FreeTag(PU_PERFSTATS); + // thinkframe hook metric history pointers need to be cleared manually + for (i = 0; i < thinkframe_hooks_length; i++) + { + thinkframe_hooks[i].time_taken.history = NULL; + } + + ps_frame_index = ps_tick_index = 0; + // PS_UpdateMetricHistory will set these correctly when it runs + ps_frame_samples_left = ps_tick_samples_left = 0; +} + +void PS_PerfStats_OnChange(void) +{ + if (cv_perfstats.value && cv_ps_samplesize.value > 1) + PS_ClearHistory(); +} + +void PS_SampleSize_OnChange(void) +{ + if (cv_ps_samplesize.value > 1) + PS_ClearHistory(); +} diff --git a/src/m_perfstats.h b/src/m_perfstats.h index 71208fbc1..3ff0e6c6b 100644 --- a/src/m_perfstats.h +++ b/src/m_perfstats.h @@ -16,26 +16,45 @@ #include "lua_script.h" #include "p_local.h" -extern precise_t ps_tictime; - -extern precise_t ps_playerthink_time; -extern precise_t ps_thinkertime; - -extern precise_t ps_thlist_times[]; - -extern int ps_checkposition_calls; - -extern precise_t ps_lua_thinkframe_time; -extern int ps_lua_mobjhooks; +typedef struct +{ + union { + precise_t p; + INT32 i; + } value; + void *history; +} ps_metric_t; typedef struct { - precise_t time_taken; + ps_metric_t time_taken; char short_src[LUA_IDSIZE]; } ps_hookinfo_t; +#define PS_START_TIMING(metric) metric.value.p = I_GetPreciseTime() +#define PS_STOP_TIMING(metric) metric.value.p = I_GetPreciseTime() - metric.value.p + +extern ps_metric_t ps_tictime; + +extern ps_metric_t ps_playerthink_time; +extern ps_metric_t ps_thinkertime; + +extern ps_metric_t ps_thlist_times[]; + +extern ps_metric_t ps_checkposition_calls; + +extern ps_metric_t ps_lua_thinkframe_time; +extern ps_metric_t ps_lua_mobjhooks; + +extern ps_metric_t ps_otherlogictime; + void PS_SetThinkFrameHookInfo(int index, precise_t time_taken, char* short_src); +void PS_UpdateTickStats(void); + void M_DrawPerfStats(void); +void PS_PerfStats_OnChange(void); +void PS_SampleSize_OnChange(void); + #endif diff --git a/src/p_map.c b/src/p_map.c index e55bebb9a..1d3197fab 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -2029,7 +2029,7 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) subsector_t *newsubsec; boolean blockval = true; - ps_checkposition_calls++; + ps_checkposition_calls.value.i++; I_Assert(thing != NULL); #ifdef PARANOIA diff --git a/src/p_tick.c b/src/p_tick.c index d7357eb82..1cdea9ac6 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -323,7 +323,7 @@ static inline void P_RunThinkers(void) size_t i; for (i = 0; i < NUM_THINKERLISTS; i++) { - ps_thlist_times[i] = I_GetPreciseTime(); + PS_START_TIMING(ps_thlist_times[i]); for (currentthinker = thlist[i].next; currentthinker != &thlist[i]; currentthinker = currentthinker->next) { #ifdef PARANOIA @@ -331,7 +331,7 @@ static inline void P_RunThinkers(void) #endif currentthinker->function.acp1(currentthinker); } - ps_thlist_times[i] = I_GetPreciseTime() - ps_thlist_times[i]; + PS_STOP_TIMING(ps_thlist_times[i]); } } @@ -653,16 +653,16 @@ void P_Ticker(boolean run) } } - ps_lua_mobjhooks = 0; - ps_checkposition_calls = 0; + ps_lua_mobjhooks.value.i = 0; + ps_checkposition_calls.value.i = 0; LUA_HOOK(PreThinkFrame); - ps_playerthink_time = I_GetPreciseTime(); + PS_START_TIMING(ps_playerthink_time); for (i = 0; i < MAXPLAYERS; i++) if (playeringame[i] && players[i].mo && !P_MobjWasRemoved(players[i].mo)) P_PlayerThink(&players[i]); - ps_playerthink_time = I_GetPreciseTime() - ps_playerthink_time; + PS_STOP_TIMING(ps_playerthink_time); } // Keep track of how long they've been playing! @@ -677,18 +677,18 @@ void P_Ticker(boolean run) if (run) { - ps_thinkertime = I_GetPreciseTime(); + PS_START_TIMING(ps_thinkertime); P_RunThinkers(); - ps_thinkertime = I_GetPreciseTime() - ps_thinkertime; + PS_STOP_TIMING(ps_thinkertime); // Run any "after all the other thinkers" stuff for (i = 0; i < MAXPLAYERS; i++) if (playeringame[i] && players[i].mo && !P_MobjWasRemoved(players[i].mo)) P_PlayerAfterThink(&players[i]); - ps_lua_thinkframe_time = I_GetPreciseTime(); + PS_START_TIMING(ps_lua_thinkframe_time); LUA_HookThinkFrame(); - ps_lua_thinkframe_time = I_GetPreciseTime() - ps_lua_thinkframe_time; + PS_STOP_TIMING(ps_lua_thinkframe_time); } // Run shield positioning diff --git a/src/r_bsp.c b/src/r_bsp.c index 5acd4e70c..b8559d39e 100644 --- a/src/r_bsp.c +++ b/src/r_bsp.c @@ -804,7 +804,7 @@ static void R_AddPolyObjects(subsector_t *sub) } // for render stats - ps_numpolyobjects += numpolys; + ps_numpolyobjects.value.i += numpolys; // sort polyobjects R_SortPolyObjects(sub); @@ -1239,7 +1239,7 @@ void R_RenderBSPNode(INT32 bspnum) node_t *bsp; INT32 side; - ps_numbspcalls++; + ps_numbspcalls.value.i++; while (!(bspnum & NF_SUBSECTOR)) // Found a subsector? { diff --git a/src/r_main.c b/src/r_main.c index 17e124cb9..8729b5dcb 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -101,21 +101,22 @@ extracolormap_t *extra_colormaps = NULL; // Render stats precise_t ps_prevframetime = 0; -precise_t ps_rendercalltime = 0; -precise_t ps_uitime = 0; -precise_t ps_swaptime = 0; +ps_metric_t ps_rendercalltime = {0}; +ps_metric_t ps_otherrendertime = {0}; +ps_metric_t ps_uitime = {0}; +ps_metric_t ps_swaptime = {0}; -precise_t ps_bsptime = 0; +ps_metric_t ps_bsptime = {0}; -precise_t ps_sw_spritecliptime = 0; -precise_t ps_sw_portaltime = 0; -precise_t ps_sw_planetime = 0; -precise_t ps_sw_maskedtime = 0; +ps_metric_t ps_sw_spritecliptime = {0}; +ps_metric_t ps_sw_portaltime = {0}; +ps_metric_t ps_sw_planetime = {0}; +ps_metric_t ps_sw_maskedtime = {0}; -int ps_numbspcalls = 0; -int ps_numsprites = 0; -int ps_numdrawnodes = 0; -int ps_numpolyobjects = 0; +ps_metric_t ps_numbspcalls = {0}; +ps_metric_t ps_numsprites = {0}; +ps_metric_t ps_numdrawnodes = {0}; +ps_metric_t ps_numpolyobjects = {0}; static CV_PossibleValue_t drawdist_cons_t[] = { {256, "256"}, {512, "512"}, {768, "768"}, @@ -1496,11 +1497,11 @@ void R_RenderPlayerView(player_t *player) mytotal = 0; ProfZeroTimer(); #endif - ps_numbspcalls = ps_numpolyobjects = ps_numdrawnodes = 0; - ps_bsptime = I_GetPreciseTime(); + ps_numbspcalls.value.i = ps_numpolyobjects.value.i = ps_numdrawnodes.value.i = 0; + PS_START_TIMING(ps_bsptime); R_RenderBSPNode((INT32)numnodes - 1); - ps_bsptime = I_GetPreciseTime() - ps_bsptime; - ps_numsprites = visspritecount; + PS_STOP_TIMING(ps_bsptime); + ps_numsprites.value.i = visspritecount; #ifdef TIMING RDMSR(0x10, &mycount); mytotal += mycount; // 64bit add @@ -1510,9 +1511,9 @@ void R_RenderPlayerView(player_t *player) //profile stuff --------------------------------------------------------- Mask_Post(&masks[nummasks - 1]); - ps_sw_spritecliptime = I_GetPreciseTime(); + PS_START_TIMING(ps_sw_spritecliptime); R_ClipSprites(drawsegs, NULL); - ps_sw_spritecliptime = I_GetPreciseTime() - ps_sw_spritecliptime; + PS_STOP_TIMING(ps_sw_spritecliptime); // Add skybox portals caused by sky visplanes. @@ -1520,7 +1521,7 @@ void R_RenderPlayerView(player_t *player) Portal_AddSkyboxPortals(); // Portal rendering. Hijacks the BSP traversal. - ps_sw_portaltime = I_GetPreciseTime(); + PS_START_TIMING(ps_sw_portaltime); if (portal_base) { portal_t *portal; @@ -1560,17 +1561,17 @@ void R_RenderPlayerView(player_t *player) Portal_Remove(portal); } } - ps_sw_portaltime = I_GetPreciseTime() - ps_sw_portaltime; + PS_STOP_TIMING(ps_sw_portaltime); - ps_sw_planetime = I_GetPreciseTime(); + PS_START_TIMING(ps_sw_planetime); R_DrawPlanes(); - ps_sw_planetime = I_GetPreciseTime() - ps_sw_planetime; + PS_STOP_TIMING(ps_sw_planetime); // draw mid texture and sprite // And now 3D floors/sides! - ps_sw_maskedtime = I_GetPreciseTime(); + PS_START_TIMING(ps_sw_maskedtime); R_DrawMasked(masks, nummasks); - ps_sw_maskedtime = I_GetPreciseTime() - ps_sw_maskedtime; + PS_STOP_TIMING(ps_sw_maskedtime); free(masks); } diff --git a/src/r_main.h b/src/r_main.h index f81447c45..5f3bed980 100644 --- a/src/r_main.h +++ b/src/r_main.h @@ -17,6 +17,7 @@ #include "d_player.h" #include "r_data.h" #include "r_textures.h" +#include "m_perfstats.h" // ps_metric_t // // POV related. @@ -79,21 +80,22 @@ boolean R_DoCulling(line_t *cullheight, line_t *viewcullheight, fixed_t vz, fixe // Render stats extern precise_t ps_prevframetime;// time when previous frame was rendered -extern precise_t ps_rendercalltime; -extern precise_t ps_uitime; -extern precise_t ps_swaptime; +extern ps_metric_t ps_rendercalltime; +extern ps_metric_t ps_otherrendertime; +extern ps_metric_t ps_uitime; +extern ps_metric_t ps_swaptime; -extern precise_t ps_bsptime; +extern ps_metric_t ps_bsptime; -extern precise_t ps_sw_spritecliptime; -extern precise_t ps_sw_portaltime; -extern precise_t ps_sw_planetime; -extern precise_t ps_sw_maskedtime; +extern ps_metric_t ps_sw_spritecliptime; +extern ps_metric_t ps_sw_portaltime; +extern ps_metric_t ps_sw_planetime; +extern ps_metric_t ps_sw_maskedtime; -extern int ps_numbspcalls; -extern int ps_numsprites; -extern int ps_numdrawnodes; -extern int ps_numpolyobjects; +extern ps_metric_t ps_numbspcalls; +extern ps_metric_t ps_numsprites; +extern ps_metric_t ps_numdrawnodes; +extern ps_metric_t ps_numpolyobjects; // // REFRESH - the actual rendering functions. diff --git a/src/r_things.c b/src/r_things.c index ea57e4086..bed71a6d7 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -2745,7 +2745,7 @@ static drawnode_t *R_CreateDrawNode(drawnode_t *link) node->ffloor = NULL; node->sprite = NULL; - ps_numdrawnodes++; + ps_numdrawnodes.value.i++; return node; } diff --git a/src/z_zone.h b/src/z_zone.h index be55bf994..17f572a90 100644 --- a/src/z_zone.h +++ b/src/z_zone.h @@ -39,6 +39,7 @@ enum // Tags < PU_LEVEL are not purged until freed explicitly. PU_STATIC = 1, // static entire execution time PU_LUA = 2, // static entire execution time -- used by lua so it doesn't get caught in loops forever + PU_PERFSTATS = 3, // static between changes to ps_samplesize cvar PU_SOUND = 11, // static while playing PU_MUSIC = 12, // static while playing From 865c0a081da3292f9923216f0b31a3128b462c81 Mon Sep 17 00:00:00 2001 From: SMS Alfredo Date: Fri, 29 Oct 2021 10:40:25 +0000 Subject: [PATCH 0934/1080] Make Overlay objects account for player->drawangle --- src/p_enemy.c | 2 +- src/p_mobj.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/p_enemy.c b/src/p_enemy.c index 49907bdcc..0cada7f9f 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -5297,7 +5297,7 @@ void A_OverlayThink(mobj_t *actor) actor->z = actor->target->z + actor->target->height - mobjinfo[actor->type].height - ((var2>>16) ? -1 : 1)*(var2&0xFFFF)*FRACUNIT; else actor->z = actor->target->z + ((var2>>16) ? -1 : 1)*(var2&0xFFFF)*FRACUNIT; - actor->angle = actor->target->angle + actor->movedir; + actor->angle = (actor->target->player ? actor->target->player->drawangle : actor->target->angle) + actor->movedir; actor->eflags = actor->target->eflags; actor->momx = actor->target->momx; diff --git a/src/p_mobj.c b/src/p_mobj.c index a1bb2d6ff..41377373d 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -6837,7 +6837,7 @@ void P_RunOverlays(void) mo->eflags = (mo->eflags & ~MFE_VERTICALFLIP) | (mo->target->eflags & MFE_VERTICALFLIP); mo->scale = mo->destscale = mo->target->scale; - mo->angle = mo->target->angle + mo->movedir; + mo->angle = (mo->target->player ? mo->target->player->drawangle : mo->target->angle) + mo->movedir; if (!(mo->state->frame & FF_ANIMATE)) zoffs = FixedMul(((signed)mo->state->var2)*FRACUNIT, mo->scale); From c55e973364ab990afbd29f081c94aad245a13809 Mon Sep 17 00:00:00 2001 From: SteelT Date: Wed, 3 Nov 2021 17:13:34 -0400 Subject: [PATCH 0935/1080] MSYS2: Don't compile with dynamic base Resolves #671 --- src/Makefile.d/win32.mk | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Makefile.d/win32.mk b/src/Makefile.d/win32.mk index 0c671b268..768133c15 100644 --- a/src/Makefile.d/win32.mk +++ b/src/Makefile.d/win32.mk @@ -8,6 +8,11 @@ else EXENAME?=srb2win64.exe endif +# disable dynamicbase if under msys2 +ifdef MSYSTEM +libs+=-Wl,--disable-dynamicbase +endif + sources+=win32/Srb2win.rc opts+=-DSTDC_HEADERS libs+=-ladvapi32 -lkernel32 -lmsvcrt -luser32 From da33cb674e419eba5b4870c134f8dacab86ffb6f Mon Sep 17 00:00:00 2001 From: katsy Date: Fri, 5 Nov 2021 16:51:44 -0500 Subject: [PATCH 0936/1080] fix water fof height calculation on slopes --- src/p_mobj.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index a1bb2d6ff..c5a84f333 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -3236,8 +3236,8 @@ 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); + topheight = P_GetSpecialTopZ(mobj, sectors + rover->secnum, sector); + bottomheight = P_GetSpecialBottomZ(mobj, sectors + rover->secnum, sector); if (mobj->eflags & MFE_VERTICALFLIP) { From 0ecfc38c468944b4de997199c0ece750cb39750f Mon Sep 17 00:00:00 2001 From: Jaime Ita Passos Date: Sat, 6 Nov 2021 01:49:29 -0300 Subject: [PATCH 0937/1080] Remove misplaced line from R_DrawTiltedSplat_NPO2_8 --- src/r_draw8_npo2.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/r_draw8_npo2.c b/src/r_draw8_npo2.c index 71ec99948..2433cb402 100644 --- a/src/r_draw8_npo2.c +++ b/src/r_draw8_npo2.c @@ -666,7 +666,6 @@ void R_DrawTiltedSplat_NPO2_8(void) for (; width != 0; width--) { colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); - val = source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)]; // Lactozilla: Non-powers-of-two { fixed_t x = (((fixed_t)u) >> FRACBITS); From 9a5bb5980107050c1203276a72fcc4f23fd22e60 Mon Sep 17 00:00:00 2001 From: sphere Date: Sun, 7 Nov 2021 12:51:21 +0100 Subject: [PATCH 0938/1080] https://mb.srb2.org/threads/the-most-utterly-unimportant-typo-ever.27152 --- src/f_finale.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/f_finale.c b/src/f_finale.c index 47786bb60..0b2fe9741 100644 --- a/src/f_finale.c +++ b/src/f_finale.c @@ -1219,7 +1219,7 @@ static const char *credits[] = { "Bill \"Tets\" Reed", "", "\1Special Thanks", - "iD Software", + "id Software", "Doom Legacy Project", "FreeDoom Project", // Used some of the mancubus and rocket launcher sprites for Brak "Kart Krew", From 270c7701b4c43faa59b642be5774a0a867a0f1ed Mon Sep 17 00:00:00 2001 From: Hannu Hanhi Date: Mon, 8 Nov 2021 01:17:30 +0200 Subject: [PATCH 0939/1080] Timestamp function for Lua --- src/i_system.h | 2 +- src/lua_baselib.c | 9 +++++++++ src/sdl/i_system.c | 8 +++++++- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/i_system.h b/src/i_system.h index a3790dca3..a2dd81cca 100644 --- a/src/i_system.h +++ b/src/i_system.h @@ -50,7 +50,7 @@ tic_t I_GetTime(void); */ precise_t I_GetPreciseTime(void); -/** \brief Returns the difference between precise times as microseconds. +/** \brief Converts a precise_t to microseconds and casts it to a 32 bit integer. */ int I_PreciseToMicros(precise_t); diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 350c1585f..61f0e43cb 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -31,6 +31,7 @@ #include "m_misc.h" // M_MapNumber #include "b_bot.h" // B_UpdateBotleader #include "d_clisrv.h" // CL_RemovePlayer +#include "i_system.h" // I_GetPreciseTime, I_PreciseToMicros #include "lua_script.h" #include "lua_libs.h" @@ -3876,6 +3877,12 @@ static int lib_gTicsToMilliseconds(lua_State *L) return 1; } +static int lib_iGetTimestamp(lua_State *L) +{ + lua_pushinteger(L, I_PreciseToMicros(I_GetPreciseTime())); + return 1; +} + static luaL_Reg lib[] = { {"print", lib_print}, {"chatprint", lib_chatprint}, @@ -4150,6 +4157,8 @@ static luaL_Reg lib[] = { {"G_TicsToCentiseconds",lib_gTicsToCentiseconds}, {"G_TicsToMilliseconds",lib_gTicsToMilliseconds}, + {"I_GetTimestamp",lib_iGetTimestamp}, + {NULL, NULL} }; diff --git a/src/sdl/i_system.c b/src/sdl/i_system.c index 2ec28ebc8..ccec37093 100644 --- a/src/sdl/i_system.c +++ b/src/sdl/i_system.c @@ -2163,7 +2163,13 @@ precise_t I_GetPreciseTime(void) int I_PreciseToMicros(precise_t d) { - return (int)(d / (timer_frequency / 1000000.0)); + // d is going to be converted into a double. So remove the highest bits + // to avoid loss of precision in the lower bits, for the (probably rare) case + // that the higher bits are actually used. + d &= ((precise_t)1 << 53) - 1; // The mantissa of a double can handle 53 bits at most. + // The resulting double from the calculation is converted first to UINT64 to avoid overflow, + // which is undefined behaviour when converting floating point values to integers. + return (int)(UINT64)(d / (timer_frequency / 1000000.0)); } // From a14c008dee4e4841e5eb78df57429e59136027b7 Mon Sep 17 00:00:00 2001 From: Jaime Ita Passos Date: Mon, 8 Nov 2021 00:38:24 -0300 Subject: [PATCH 0940/1080] Fix #555 --- src/r_patchrotation.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/r_patchrotation.c b/src/r_patchrotation.c index a9b4a2b8f..dae3a7b53 100644 --- a/src/r_patchrotation.c +++ b/src/r_patchrotation.c @@ -227,8 +227,8 @@ void RotatedPatch_DoRotation(rotsprite_t *rotsprite, patch_t *patch, INT32 angle ox = (newwidth / 2) + (leftoffset - xpivot); oy = (newheight / 2) + (patch->topoffset - ypivot); - width = (maxx - minx); - height = (maxy - miny); + width = (maxx+1 - minx); + height = (maxy+1 - miny); if ((unsigned)(width * height) != size) { From 34b05efdf1fe548763901a49b0e20b80cc25d95c Mon Sep 17 00:00:00 2001 From: LZA <73-LZA@users.noreply.git.do.srb2.org> Date: Mon, 8 Nov 2021 03:40:53 +0000 Subject: [PATCH 0941/1080] Revert "Merge branch 'writable-colormaps' into 'next'" This reverts merge request !959 --- src/lua_hudlib.c | 33 +++------------------------------ 1 file changed, 3 insertions(+), 30 deletions(-) diff --git a/src/lua_hudlib.c b/src/lua_hudlib.c index fca832053..0dd951efd 100644 --- a/src/lua_hudlib.c +++ b/src/lua_hudlib.c @@ -265,7 +265,7 @@ static int hudinfo_num(lua_State *L) static int colormap_get(lua_State *L) { - UINT8 *colormap = *((UINT8 **)luaL_checkudata(L, 1, META_COLORMAP)); + const UINT8 *colormap = *((UINT8 **)luaL_checkudata(L, 1, META_COLORMAP)); UINT32 i = luaL_checkinteger(L, 2); if (i >= 256) return luaL_error(L, "colormap index %d out of range (0 - %d)", i, 255); @@ -273,23 +273,6 @@ static int colormap_get(lua_State *L) return 1; } -static int colormap_set(lua_State *L) -{ - UINT8 *colormap = *((UINT8 **)luaL_checkudata(L, 1, META_COLORMAP)); - UINT32 i = luaL_checkinteger(L, 2); - if (i >= 256) - return luaL_error(L, "colormap index %d out of range (0 - %d)", i, 255); - colormap[i] = (UINT8)luaL_checkinteger(L, 3); - return 0; -} - -static int colormap_free(lua_State *L) -{ - UINT8 *colormap = *((UINT8 **)luaL_checkudata(L, 1, META_COLORMAP)); - Z_Free(colormap); - return 0; -} - static int patch_get(lua_State *L) { patch_t *patch = *((patch_t **)luaL_checkudata(L, 1, META_PATCH)); @@ -1057,7 +1040,7 @@ static int libd_getColormap(lua_State *L) // all was successful above, now we generate the colormap at last! - colormap = R_GetTranslationColormap(skinnum, color, 0); + colormap = R_GetTranslationColormap(skinnum, color, GTC_CACHE); LUA_PushUserdata(L, colormap, META_COLORMAP); // push as META_COLORMAP userdata, specifically for patches to use! return 1; } @@ -1066,14 +1049,10 @@ static int libd_getStringColormap(lua_State *L) { INT32 flags = luaL_checkinteger(L, 1); UINT8* colormap = NULL; - UINT8* lua_colormap = NULL; HUDONLY colormap = V_GetStringColormap(flags & V_CHARCOLORMASK); if (colormap) { - lua_colormap = Z_Malloc(256 * sizeof(UINT8), PU_LUA, NULL); - memcpy(lua_colormap, colormap, 256 * sizeof(UINT8)); - - LUA_PushUserdata(L, lua_colormap, META_COLORMAP); // push as META_COLORMAP userdata, specifically for patches to use! + LUA_PushUserdata(L, colormap, META_COLORMAP); // push as META_COLORMAP userdata, specifically for patches to use! return 1; } return 0; @@ -1348,12 +1327,6 @@ int LUA_HudLib(lua_State *L) luaL_newmetatable(L, META_COLORMAP); lua_pushcfunction(L, colormap_get); lua_setfield(L, -2, "__index"); - - lua_pushcfunction(L, colormap_set); - lua_setfield(L, -2, "__newindex"); - - lua_pushcfunction(L, colormap_free); - lua_setfield(L, -2, "__gc"); lua_pop(L,1); luaL_newmetatable(L, META_PATCH); From 32a68f35c95d46f6bb2090d309a400814754476f Mon Sep 17 00:00:00 2001 From: Jaime Ita Passos Date: Mon, 8 Nov 2021 01:11:51 -0300 Subject: [PATCH 0942/1080] Change my name --- src/f_finale.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/f_finale.c b/src/f_finale.c index 0b2fe9741..8dd03d44f 100644 --- a/src/f_finale.c +++ b/src/f_finale.c @@ -1091,11 +1091,11 @@ static const char *credits[] = { "Kepa \"Nev3r\" Iceta", "Thomas \"Shadow Hog\" Igoe", "Iestyn \"Monster Iestyn\" Jealous", - "\"Jimita\"", "\"Kaito Sinclaire\"", "\"Kalaron\"", // Coded some of Sryder13's collection of OpenGL fixes, especially fog "Ronald \"Furyhunter\" Kinard", // The SDL2 port "\"Lat'\"", // SRB2-CHAT, the chat window from Kart + "\"LZA\"", "Matthew \"Shuffle\" Marsalko", "Steven \"StroggOnMeth\" McGranahan", "\"Morph\"", // For SRB2Morphed stuff From 1d7061b8921e348502a8b8569a0361a97a8fc76d Mon Sep 17 00:00:00 2001 From: Jaime Ita Passos Date: Mon, 8 Nov 2021 01:34:03 -0300 Subject: [PATCH 0943/1080] Fix NONET compiling --- src/d_clisrv.c | 74 ++++++++++++++++++++++++++++---------------------- 1 file changed, 42 insertions(+), 32 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index b7071320c..efe6473d4 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -1836,8 +1836,6 @@ void CL_UpdateServerList(boolean internetsearch, INT32 room) #endif/*MASTERSERVER*/ } -#endif // ifndef NONET - static const char * InvalidServerReason (INT32 i) { #define EOT "\nPress ESC\n" @@ -1904,6 +1902,8 @@ static const char * InvalidServerReason (INT32 i) #undef EOT } +#endif // ifndef NONET + /** Called by CL_ServerConnectionTicker * * \param asksent The last time we asked the server to join. We re-ask every second in case our request got lost in transmit. @@ -2932,6 +2932,34 @@ static void Command_Kick(void) else CONS_Printf(M_GetText("Only the server or a remote admin can use this.\n")); } + +static void Command_ResendGamestate(void) +{ + SINT8 playernum; + + if (COM_Argc() == 1) + { + CONS_Printf(M_GetText("resendgamestate : resend the game state to a player\n")); + return; + } + else if (client) + { + CONS_Printf(M_GetText("Only the server can use this.\n")); + return; + } + + playernum = nametonum(COM_Argv(1)); + if (playernum == -1 || playernum == 0) + return; + + // Send a PT_WILLRESENDGAMESTATE packet to the client so they know what's going on + netbuffer->packettype = PT_WILLRESENDGAMESTATE; + if (!HSendPacket(playernode[playernum], true, 0, 0)) + { + CONS_Alert(CONS_ERROR, M_GetText("A problem occured, please try again.\n")); + return; + } +} #endif static void Got_KickCmd(UINT8 **p, INT32 playernum) @@ -3139,34 +3167,6 @@ static void Got_KickCmd(UINT8 **p, INT32 playernum) CL_RemovePlayer(pnum, kickreason); } -static void Command_ResendGamestate(void) -{ - SINT8 playernum; - - if (COM_Argc() == 1) - { - CONS_Printf(M_GetText("resendgamestate : resend the game state to a player\n")); - return; - } - else if (client) - { - CONS_Printf(M_GetText("Only the server can use this.\n")); - return; - } - - playernum = nametonum(COM_Argv(1)); - if (playernum == -1 || playernum == 0) - return; - - // Send a PT_WILLRESENDGAMESTATE packet to the client so they know what's going on - netbuffer->packettype = PT_WILLRESENDGAMESTATE; - if (!HSendPacket(playernode[playernum], true, 0, 0)) - { - CONS_Alert(CONS_ERROR, M_GetText("A problem occured, please try again.\n")); - return; - } -} - static CV_PossibleValue_t netticbuffer_cons_t[] = {{0, "MIN"}, {3, "MAX"}, {0, NULL}}; consvar_t cv_netticbuffer = CVAR_INIT ("netticbuffer", "1", CV_SAVE, netticbuffer_cons_t, NULL); @@ -3903,6 +3903,7 @@ static void HandleServerInfo(SINT8 node) static void PT_WillResendGamestate(void) { +#ifndef NONET char tmpsave[256]; if (server || cl_redownloadinggamestate) @@ -3925,10 +3926,12 @@ static void PT_WillResendGamestate(void) CL_PrepareDownloadSaveGame(tmpsave); cl_redownloadinggamestate = true; +#endif } static void PT_CanReceiveGamestate(SINT8 node) { +#ifndef NONET if (client || sendingsavegame[node]) return; @@ -3936,6 +3939,9 @@ static void PT_CanReceiveGamestate(SINT8 node) SV_SendSaveGame(node, true); // Resend a complete game state resendingsavegame[node] = true; +#else + (void)node; +#endif } /** Handles a packet received from a node that isn't in game @@ -4222,8 +4228,10 @@ static void HandlePacketFromPlayer(SINT8 node) // Check player consistancy during the level if (realstart <= gametic && realstart + BACKUPTICS - 1 > gametic && gamestate == GS_LEVEL && consistancy[realstart%BACKUPTICS] != SHORT(netbuffer->u.clientpak.consistancy) - && !resendingsavegame[node] && savegameresendcooldown[node] <= I_GetTime() - && !SV_ResendingSavegameToAnyone()) +#ifndef NONET + && !SV_ResendingSavegameToAnyone() +#endif + && !resendingsavegame[node] && savegameresendcooldown[node] <= I_GetTime()) { if (cv_resynchattempts.value) { @@ -5127,9 +5135,11 @@ void NetUpdate(void) if (client) { +#ifndef NONET // If the client just finished redownloading the game state, load it if (cl_redownloadinggamestate && fileneeded[0].status == FS_FOUND) CL_ReloadReceivedSavegame(); +#endif CL_SendClientCmd(); // Send tic cmd hu_redownloadinggamestate = cl_redownloadinggamestate; From 56c5a887c858aaf9e1def23327e56d09c546f333 Mon Sep 17 00:00:00 2001 From: Hannu Hanhi Date: Mon, 8 Nov 2021 20:28:35 +0200 Subject: [PATCH 0944/1080] Call the Lua timestamp function getTimeMicros --- src/lua_baselib.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 61f0e43cb..29de7a05f 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -3877,7 +3877,7 @@ static int lib_gTicsToMilliseconds(lua_State *L) return 1; } -static int lib_iGetTimestamp(lua_State *L) +static int lib_getTimeMicros(lua_State *L) { lua_pushinteger(L, I_PreciseToMicros(I_GetPreciseTime())); return 1; @@ -4157,7 +4157,7 @@ static luaL_Reg lib[] = { {"G_TicsToCentiseconds",lib_gTicsToCentiseconds}, {"G_TicsToMilliseconds",lib_gTicsToMilliseconds}, - {"I_GetTimestamp",lib_iGetTimestamp}, + {"getTimeMicros",lib_getTimeMicros}, {NULL, NULL} }; From cade6f3cf69cb3e4f3cbf7e4952706b317e7ea88 Mon Sep 17 00:00:00 2001 From: Zwip-Zwap Zapony Date: Tue, 9 Nov 2021 16:59:49 +0100 Subject: [PATCH 0945/1080] Fix Ringslinger weapon ring penalty missplitment --- 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 784666ad4..a1b9206b0 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -2188,7 +2188,7 @@ static void ST_drawMatchHUD(void) { sprintf(penaltystr, "-%d", stplyr->ammoremoval); V_DrawString(offset + 8 + stplyr->ammoremovalweapon * 20, y, - V_REDMAP|V_SNAPTOBOTTOM, penaltystr); + V_REDMAP|V_SNAPTOBOTTOM|V_PERPLAYER, penaltystr); } } From 8136f5522b83d7328b20def28433ee274bd913cb Mon Sep 17 00:00:00 2001 From: Hannu Hanhi Date: Wed, 10 Nov 2021 01:55:31 +0200 Subject: [PATCH 0946/1080] Fix uninitialized history pointers in thinkframe_hooks array --- src/m_perfstats.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/m_perfstats.c b/src/m_perfstats.c index 9285b31be..439a9da1c 100644 --- a/src/m_perfstats.c +++ b/src/m_perfstats.c @@ -194,14 +194,18 @@ void PS_SetThinkFrameHookInfo(int index, precise_t time_taken, char* short_src) if (!thinkframe_hooks) { // array needs to be initialized - thinkframe_hooks = Z_Malloc(sizeof(ps_hookinfo_t) * thinkframe_hooks_capacity, PU_STATIC, NULL); + thinkframe_hooks = Z_Calloc(sizeof(ps_hookinfo_t) * thinkframe_hooks_capacity, PU_STATIC, NULL); } if (index >= thinkframe_hooks_capacity) { // array needs more space, realloc with double size - thinkframe_hooks_capacity *= 2; + int new_capacity = thinkframe_hooks_capacity * 2; thinkframe_hooks = Z_Realloc(thinkframe_hooks, - sizeof(ps_hookinfo_t) * thinkframe_hooks_capacity, PU_STATIC, NULL); + sizeof(ps_hookinfo_t) * new_capacity, PU_STATIC, NULL); + // initialize new memory with zeros so the pointers in the structs are null + memset(&thinkframe_hooks[thinkframe_hooks_capacity], 0, + sizeof(ps_hookinfo_t) * thinkframe_hooks_capacity); + thinkframe_hooks_capacity = new_capacity; } thinkframe_hooks[index].time_taken.value.p = time_taken; memcpy(thinkframe_hooks[index].short_src, short_src, LUA_IDSIZE * sizeof(char)); From a48c8826a1c5b1a8514632b9a3433161b3a35ebd Mon Sep 17 00:00:00 2001 From: sphere Date: Sat, 8 May 2021 18:13:35 +0200 Subject: [PATCH 0947/1080] Add modifiedgame warning to save select menu. --- src/m_menu.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/m_menu.c b/src/m_menu.c index 7a82fd8fb..271936b0e 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -8652,6 +8652,12 @@ static void M_DrawLoad(void) loadgameoffset = 0; M_DrawLoadGameData(); + + if (modifiedgame && !savemoddata) + { + V_DrawCenteredThinString(BASEVIDWIDTH/2, 184, 0, "\x85WARNING: \x80The game is modified."); + V_DrawCenteredThinString(BASEVIDWIDTH/2, 192, 0, "Progress will not be saved."); + } } // From d9fde5c39558248e43d8ec6f32a12c2a4c5d7cd3 Mon Sep 17 00:00:00 2001 From: sphere Date: Sun, 9 May 2021 16:47:52 +0200 Subject: [PATCH 0948/1080] Add emblem counter to the Extras checklist. --- src/m_menu.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/m_menu.c b/src/m_menu.c index 271936b0e..8f956e9a7 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -7187,13 +7187,20 @@ static void M_HandleChecklist(INT32 choice) static void M_DrawChecklist(void) { - INT32 i = check_on, j = 0, y = currentMenu->y; + INT32 i = check_on, j = 0, y = currentMenu->y, emblems = numemblems+numextraemblems; UINT32 condnum, previd, maxcond; condition_t *cond; // draw title (or big pic) M_DrawMenuTitle(); + // draw emblem counter + if (emblems > 0) + { + V_DrawString(42, 20, (emblems == M_CountEmblems()) ? V_GREENMAP : 0, va("%d/%d", M_CountEmblems(), emblems)); + V_DrawSmallScaledPatch(28, 20, 0, W_CachePatchName("EMBLICON", PU_PATCH)); + } + if (check_on) V_DrawString(10, y-(skullAnimCounter/5), V_YELLOWMAP, "\x1A"); From 08e63fc822005bf061c004c8f6aaea37f56c4702 Mon Sep 17 00:00:00 2001 From: sphere Date: Fri, 8 Oct 2021 18:00:08 +0200 Subject: [PATCH 0949/1080] Show values on (float) sliders in the options menu. --- src/m_menu.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index 8f956e9a7..eeb51d0da 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -4062,14 +4062,6 @@ static void M_DrawSlider(INT32 x, INT32 y, const consvar_t *cv, boolean ontop) for (i = 1; i < SLIDER_RANGE; i++) V_DrawScaledPatch (x+i*8, y, 0,p); - if (ontop) - { - V_DrawCharacter(x - 6 - (skullAnimCounter/5), y, - '\x1C' | V_YELLOWMAP, false); - V_DrawCharacter(x+i*8 + 8 + (skullAnimCounter/5), y, - '\x1D' | V_YELLOWMAP, false); - } - p = W_CachePatchName("M_SLIDER", PU_PATCH); V_DrawScaledPatch(x+i*8, y, 0, p); @@ -4105,6 +4097,16 @@ static void M_DrawSlider(INT32 x, INT32 y, const consvar_t *cv, boolean ontop) range = 100; V_DrawMappedPatch(x + 2 + (SLIDER_RANGE*8*range)/100, y, 0, p, yellowmap); + + if (ontop) + { + V_DrawCharacter(x - 6 - (skullAnimCounter/5), y, + '\x1C' | V_YELLOWMAP, false); + V_DrawCharacter(x + 80 + (skullAnimCounter/5), y, + '\x1D' | V_YELLOWMAP, false); + V_DrawCenteredString(x + 40, y, V_30TRANS, + (cv->flags & CV_FLOAT) ? va("%.2f", FIXED_TO_FLOAT(cv->value)) : va("%d", cv->value)); + } } // From 4480af69c7dde61cb3d0a3e82dd9e1587e133157 Mon Sep 17 00:00:00 2001 From: spherallic Date: Fri, 26 Nov 2021 14:09:10 +0100 Subject: [PATCH 0950/1080] Only show Ultimate mode warning in unmodified vanilla gameplay. --- 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 eeb51d0da..b99ec186b 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -8968,7 +8968,7 @@ static void M_HandleLoadSave(INT32 choice) break; case KEY_ENTER: - if (ultimate_selectable && saveSlotSelected == NOSAVESLOT) + if (ultimate_selectable && saveSlotSelected == NOSAVESLOT && !savemoddata && !modifiedgame) { loadgamescroll = 0; S_StartSound(NULL, sfx_skid); From cf79bc8382c414ae6973636b92cecb1403cd36c9 Mon Sep 17 00:00:00 2001 From: SMS Alfredo Date: Fri, 26 Nov 2021 14:11:09 +0000 Subject: [PATCH 0951/1080] Fix #214 (Crushstacean + Fireball Player Removal) --- src/p_enemy.c | 4 +--- src/p_inter.c | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/p_enemy.c b/src/p_enemy.c index 49907bdcc..8329b4f57 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -3518,9 +3518,7 @@ void A_Scream(mobj_t *actor) if (LUA_CallAction(A_SCREAM, actor)) return; - if (actor->tracer && (actor->tracer->type == MT_SHELL || actor->tracer->type == MT_FIREBALL)) - S_StartScreamSound(actor, sfx_mario2); - else if (actor->info->deathsound) + if (actor->info->deathsound && !S_SoundPlaying(actor, sfx_mario2)) S_StartScreamSound(actor, actor->info->deathsound); } diff --git a/src/p_inter.c b/src/p_inter.c index 21e3bfa3d..4b958fb89 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -2391,7 +2391,7 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, UINT8 damaget mobj_t *mo; if (inflictor && (inflictor->type == MT_SHELL || inflictor->type == MT_FIREBALL)) - P_SetTarget(&target->tracer, inflictor); + S_StartScreamSound(target, sfx_mario2); if (!(maptol & TOL_NIGHTS) && G_IsSpecialStage(gamemap) && target->player && target->player->nightstime > 6) target->player->nightstime = 6; // Just let P_Ticker take care of the rest. From 6a6b292c730be21e492735ed8366a4c9f2ba5cb4 Mon Sep 17 00:00:00 2001 From: spherallic Date: Sat, 27 Nov 2021 14:22:21 +0100 Subject: [PATCH 0952/1080] Fix Flame Shield interactions in old-style special stages. --- src/p_tick.c | 2 +- src/st_stuff.c | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/p_tick.c b/src/p_tick.c index d7357eb82..cee658953 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -487,7 +487,7 @@ static inline void P_DoSpecialStageStuff(void) continue; // If in water, deplete timer 6x as fast. - if (players[i].mo->eflags & (MFE_TOUCHWATER|MFE_UNDERWATER) && !(players[i].powers[pw_shield] & SH_PROTECTWATER)) + if (players[i].mo->eflags & (MFE_TOUCHWATER|MFE_UNDERWATER) && !(players[i].powers[pw_shield] & ((players[i].mo->eflags & MFE_TOUCHLAVA) ? SH_PROTECTFIRE : SH_PROTECTWATER))) players[i].nightstime -= 5; if (--players[i].nightstime > 6) { diff --git a/src/st_stuff.c b/src/st_stuff.c index a1b9206b0..a328d669e 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -2037,9 +2037,8 @@ static void ST_drawNiGHTSHUD(void) else numbersize = 48/2; - if ((oldspecialstage && leveltime & 2) - && (stplyr->mo->eflags & (MFE_TOUCHWATER|MFE_UNDERWATER)) - && !(stplyr->powers[pw_shield] & SH_PROTECTWATER)) + if ((oldspecialstage && leveltime & 2) && + (stplyr->mo->eflags & (MFE_TOUCHWATER|MFE_UNDERWATER) && !(stplyr->powers[pw_shield] & ((stplyr->mo->eflags & MFE_TOUCHLAVA) ? SH_PROTECTFIRE : SH_PROTECTWATER)))) col = SKINCOLOR_ORANGE; ST_DrawNightsOverlayNum((160 + numbersize)< Date: Sat, 27 Nov 2021 14:23:02 +0100 Subject: [PATCH 0953/1080] Make Brak's electric barrier damage Elemental and Flame Shields. --- src/p_inter.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_inter.c b/src/p_inter.c index 4b958fb89..b37689fd8 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -3651,7 +3651,7 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da return true; } - if (!force && inflictor && inflictor->flags & MF_FIRE) + if (!force && inflictor && inflictor->flags & MF_FIRE && !(damagetype && damagetype != DMG_FIRE)) { if (player->powers[pw_shield] & SH_PROTECTFIRE) return false; // Invincible to fire objects From 49e6e7a80f40b25e18faa99c54c121e0b2ac3b14 Mon Sep 17 00:00:00 2001 From: spherallic Date: Sat, 27 Nov 2021 16:19:04 +0100 Subject: [PATCH 0954/1080] Fix retracting spikes dealing typeless damage instead of spike damage. --- src/info.c | 4 ++-- src/p_map.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/info.c b/src/info.c index efcf1c044..b9d088662 100644 --- a/src/info.c +++ b/src/info.c @@ -7974,7 +7974,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = 8*FRACUNIT, // radius 32*FRACUNIT, // height 0, // display offset - 4, // mass + DMG_SPIKE, // mass 0, // damage sfx_None, // activesound MF_NOBLOCKMAP|MF_SCENERY|MF_NOCLIPHEIGHT, // flags @@ -8001,7 +8001,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = 16*FRACUNIT, // radius 14*FRACUNIT, // height 0, // display offset - 4, // mass + DMG_SPIKE, // mass 0, // damage sfx_None, // activesound MF_NOBLOCKMAP|MF_NOGRAVITY|MF_SCENERY|MF_NOCLIPHEIGHT|MF_PAPERCOLLISION, // flags diff --git a/src/p_map.c b/src/p_map.c index e55bebb9a..c01c91e3c 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -1156,7 +1156,7 @@ static boolean PIT_CheckThing(mobj_t *thing) else thing->z = tmthing->z + tmthing->height + FixedMul(FRACUNIT, tmthing->scale); if (thing->flags & MF_SHOOTABLE) - P_DamageMobj(thing, tmthing, tmthing, 1, 0); + P_DamageMobj(thing, tmthing, tmthing, 1, DMG_SPIKE); return true; } From 9bdfafc9dd3b274243c429a60ee7c14cceeeae2f Mon Sep 17 00:00:00 2001 From: spherallic Date: Mon, 29 Nov 2021 19:25:30 +0100 Subject: [PATCH 0955/1080] Add DMG_FIRE to Pyrefly fire and lavafall objects. --- src/info.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/info.c b/src/info.c index b9d088662..24c8f7bf7 100644 --- a/src/info.c +++ b/src/info.c @@ -5199,7 +5199,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = 24*FRACUNIT, // radius 34*FRACUNIT, // height 0, // display offset - 100, // mass + DMG_FIRE, // mass 0, // damage sfx_None, // activesound MF_NOGRAVITY|MF_NOBLOCKMAP|MF_FIRE|MF_PAIN, // flags @@ -13401,7 +13401,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = 30*FRACUNIT, // radius 48*FRACUNIT, // height 0, // display offset - 100, // mass + DMG_FIRE, // mass 0, // damage sfx_None, // activesound MF_SPECIAL|MF_PAIN|MF_NOGRAVITY|MF_FIRE, // flags @@ -13806,7 +13806,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = 8*FRACUNIT, // radius 32*FRACUNIT, // height 0, // display offset - 0, // mass + 0, // mass 0, // damage sfx_None, // activesound MF_NOGRAVITY|MF_PAIN, // flags From a5e1167ad2181a3b6278f6aeaa9e2cbb7d4dff97 Mon Sep 17 00:00:00 2001 From: SMS Alfredo <65426124+SMS-Alfredo@users.noreply.github.com> Date: Tue, 30 Nov 2021 20:51:15 -0600 Subject: [PATCH 0956/1080] balls --- src/info.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/info.c b/src/info.c index efcf1c044..1cd80f383 100644 --- a/src/info.c +++ b/src/info.c @@ -11430,7 +11430,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = 17*FRACUNIT, // radius 34*FRACUNIT, // height 1, // display offset - 0, // mass + DMG_SPIKE, // mass 1, // damage sfx_s3kc9s, //sfx_mswing, -- activesound MF_SCENERY|MF_PAIN|MF_NOGRAVITY, // flags @@ -11457,7 +11457,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = 34*FRACUNIT, // radius 68*FRACUNIT, // height 1, // display offset - 0, // mass + DMG_SPIKE, // mass 1, // damage sfx_s3kc9s, //sfx_mswing, -- activesound MF_SCENERY|MF_PAIN|MF_NOGRAVITY, // flags @@ -20380,7 +20380,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = 18*FRACUNIT, // radius 28*FRACUNIT, // height 0, // display offset - 0, // mass + DMG_SPIKE, // mass 0, // damage sfx_None, // activesound MF_NOGRAVITY|MF_PAIN, // flags From aca0ba0f4b0175072dbd71f4b9cca4c2cbf17982 Mon Sep 17 00:00:00 2001 From: SMS Alfredo <65426124+SMS-Alfredo@users.noreply.github.com> Date: Tue, 30 Nov 2021 22:46:51 -0600 Subject: [PATCH 0957/1080] wow --- src/info.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/info.c b/src/info.c index efcf1c044..4e991e81c 100644 --- a/src/info.c +++ b/src/info.c @@ -2069,7 +2069,7 @@ state_t states[NUMSTATES] = {SPR_TVFL, 2, 18, {A_GiveShield}, SH_FLAMEAURA, 0, S_NULL}, // S_FLAMEAURA_ICON2 {SPR_TVBB, FF_ANIMATE|2, 18, {NULL}, 3, 4, S_BUBBLEWRAP_ICON2}, // S_BUBBLEWRAP_ICON1 - {SPR_TVBB, 2, 18, {A_GiveShield}, SH_BUBBLEWRAP, 0, S_NULL}, // S_BUBBLERWAP_ICON2 + {SPR_TVBB, 2, 18, {A_GiveShield}, SH_BUBBLEWRAP, 0, S_NULL}, // S_BUBBLEWRAP_ICON2 {SPR_TVZP, FF_ANIMATE|2, 18, {NULL}, 3, 4, S_THUNDERCOIN_ICON2}, // S_THUNDERCOIN_ICON1 {SPR_TVZP, 2, 18, {A_GiveShield}, SH_THUNDERCOIN, 0, S_NULL}, // S_THUNDERCOIN_ICON2 From c1c7607cb0a1e359cdce4db3cd252c1004e100ee Mon Sep 17 00:00:00 2001 From: spherallic Date: Thu, 2 Dec 2021 01:52:45 +0100 Subject: [PATCH 0958/1080] Add toggle for linedef action 401 to not change the ceiling texture. --- extras/conf/SRB2-22.cfg | 7 ++++--- src/p_ceilng.c | 11 ++++++++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/extras/conf/SRB2-22.cfg b/extras/conf/SRB2-22.cfg index 0ca8a6715..4ed68e1ca 100644 --- a/extras/conf/SRB2-22.cfg +++ b/extras/conf/SRB2-22.cfg @@ -1992,7 +1992,7 @@ linedeftypes title = "Set Tagged Sector's Floor Height/Texture"; prefix = "(400)"; flags8text = "[3] Set delay by backside sector"; - flags64text = "[6] Keep floor flat"; + flags64text = "[6] Don't change floor texture"; } 401 @@ -2000,6 +2000,7 @@ linedeftypes title = "Set Tagged Sector's Ceiling Height/Texture"; prefix = "(401)"; flags8text = "[3] Set delay by backside sector"; + flags64text = "[6] Don't change ceiling texture"; } 402 @@ -2090,7 +2091,7 @@ linedeftypes prefix = "(403)"; flags2text = "[1] Trigger linedef executor"; flags8text = "[3] Set delay by backside sector"; - flags64text = "[6] Change floor flat"; + flags64text = "[6] Change floor texture"; } 404 @@ -2099,7 +2100,7 @@ linedeftypes prefix = "(404)"; flags2text = "[1] Trigger linedef executor"; flags8text = "[3] Set delay by backside sector"; - flags64text = "[6] Change ceiling flat"; + flags64text = "[6] Change ceiling texture"; } 405 diff --git a/src/p_ceilng.c b/src/p_ceilng.c index 43f3cc1d5..e28f9b5b1 100644 --- a/src/p_ceilng.c +++ b/src/p_ceilng.c @@ -67,7 +67,8 @@ void T_MoveCeiling(ceiling_t *ceiling) switch (ceiling->type) { case instantMoveCeilingByFrontSector: - ceiling->sector->ceilingpic = ceiling->texture; + if (ceiling->texture > -1) + ceiling->sector->ceilingpic = ceiling->texture; ceiling->sector->ceilingdata = NULL; ceiling->sector->ceilspeed = 0; P_RemoveThinker(&ceiling->thinker); @@ -186,7 +187,8 @@ void T_MoveCeiling(ceiling_t *ceiling) break; case instantMoveCeilingByFrontSector: - ceiling->sector->ceilingpic = ceiling->texture; + if (ceiling->texture > -1) + ceiling->sector->ceilingpic = ceiling->texture; ceiling->sector->ceilingdata = NULL; ceiling->sector->ceilspeed = 0; P_RemoveThinker(&ceiling->thinker); @@ -512,7 +514,10 @@ INT32 EV_DoCeiling(line_t *line, ceiling_e type) ceiling->direction = -1; ceiling->bottomheight = line->frontsector->ceilingheight; } - ceiling->texture = line->frontsector->ceilingpic; + if (line->flags & ML_NOCLIMB) + ceiling->texture = -1; + else + ceiling->texture = line->frontsector->ceilingpic; break; case moveCeilingByFrontTexture: From 443c51714a3e78eb47a1b10091f5852d86521b99 Mon Sep 17 00:00:00 2001 From: LJ Sonic Date: Thu, 2 Dec 2021 21:02:54 +0100 Subject: [PATCH 0959/1080] Fix KeyUp hook being called when the console is open --- 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 679a596b3..99b3c3ebd 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -272,7 +272,7 @@ void D_ProcessEvents(void) if (eaten) continue; // ate the event - if (!hooked && G_LuaResponder(ev)) + if (!hooked && !CON_Ready() && G_LuaResponder(ev)) continue; G_Responder(ev); From 425d1f1b536dc634f81dd9d0a2473f03ab82a0a7 Mon Sep 17 00:00:00 2001 From: LJ Sonic Date: Thu, 2 Dec 2021 21:03:16 +0100 Subject: [PATCH 0960/1080] Make all key identifiers lowercase --- src/g_input.c | 570 +++++++++++++++++++++++++------------------------- 1 file changed, 285 insertions(+), 285 deletions(-) diff --git a/src/g_input.c b/src/g_input.c index cd4536bba..6383c3f00 100644 --- a/src/g_input.c +++ b/src/g_input.c @@ -233,323 +233,323 @@ typedef struct static keyname_t keynames[] = { - {KEY_SPACE, "SPACE"}, - {KEY_CAPSLOCK, "CAPS LOCK"}, - {KEY_ENTER, "ENTER"}, - {KEY_TAB, "TAB"}, - {KEY_ESCAPE, "ESCAPE"}, - {KEY_BACKSPACE, "BACKSPACE"}, + {KEY_SPACE, "space"}, + {KEY_CAPSLOCK, "caps lock"}, + {KEY_ENTER, "enter"}, + {KEY_TAB, "tab"}, + {KEY_ESCAPE, "escape"}, + {KEY_BACKSPACE, "backspace"}, - {KEY_NUMLOCK, "NUMLOCK"}, - {KEY_SCROLLLOCK, "SCROLLLOCK"}, + {KEY_NUMLOCK, "numlock"}, + {KEY_SCROLLLOCK, "scrolllock"}, // bill gates keys - {KEY_LEFTWIN, "LEFTWIN"}, - {KEY_RIGHTWIN, "RIGHTWIN"}, - {KEY_MENU, "MENU"}, + {KEY_LEFTWIN, "leftwin"}, + {KEY_RIGHTWIN, "rightwin"}, + {KEY_MENU, "menu"}, - {KEY_LSHIFT, "LSHIFT"}, - {KEY_RSHIFT, "RSHIFT"}, - {KEY_LSHIFT, "SHIFT"}, - {KEY_LCTRL, "LCTRL"}, - {KEY_RCTRL, "RCTRL"}, - {KEY_LCTRL, "CTRL"}, - {KEY_LALT, "LALT"}, - {KEY_RALT, "RALT"}, - {KEY_LALT, "ALT"}, + {KEY_LSHIFT, "lshift"}, + {KEY_RSHIFT, "rshift"}, + {KEY_LSHIFT, "shift"}, + {KEY_LCTRL, "lctrl"}, + {KEY_RCTRL, "rctrl"}, + {KEY_LCTRL, "ctrl"}, + {KEY_LALT, "lalt"}, + {KEY_RALT, "ralt"}, + {KEY_LALT, "alt"}, // keypad keys - {KEY_KPADSLASH, "KEYPAD /"}, - {KEY_KEYPAD7, "KEYPAD 7"}, - {KEY_KEYPAD8, "KEYPAD 8"}, - {KEY_KEYPAD9, "KEYPAD 9"}, - {KEY_MINUSPAD, "KEYPAD -"}, - {KEY_KEYPAD4, "KEYPAD 4"}, - {KEY_KEYPAD5, "KEYPAD 5"}, - {KEY_KEYPAD6, "KEYPAD 6"}, - {KEY_PLUSPAD, "KEYPAD +"}, - {KEY_KEYPAD1, "KEYPAD 1"}, - {KEY_KEYPAD2, "KEYPAD 2"}, - {KEY_KEYPAD3, "KEYPAD 3"}, - {KEY_KEYPAD0, "KEYPAD 0"}, - {KEY_KPADDEL, "KEYPAD ."}, + {KEY_KPADSLASH, "keypad /"}, + {KEY_KEYPAD7, "keypad 7"}, + {KEY_KEYPAD8, "keypad 8"}, + {KEY_KEYPAD9, "keypad 9"}, + {KEY_MINUSPAD, "keypad -"}, + {KEY_KEYPAD4, "keypad 4"}, + {KEY_KEYPAD5, "keypad 5"}, + {KEY_KEYPAD6, "keypad 6"}, + {KEY_PLUSPAD, "keypad +"}, + {KEY_KEYPAD1, "keypad 1"}, + {KEY_KEYPAD2, "keypad 2"}, + {KEY_KEYPAD3, "keypad 3"}, + {KEY_KEYPAD0, "keypad 0"}, + {KEY_KPADDEL, "keypad ."}, // extended keys (not keypad) - {KEY_HOME, "HOME"}, - {KEY_UPARROW, "UP ARROW"}, - {KEY_PGUP, "PGUP"}, - {KEY_LEFTARROW, "LEFT ARROW"}, - {KEY_RIGHTARROW, "RIGHT ARROW"}, - {KEY_END, "END"}, - {KEY_DOWNARROW, "DOWN ARROW"}, - {KEY_PGDN, "PGDN"}, - {KEY_INS, "INS"}, - {KEY_DEL, "DEL"}, + {KEY_HOME, "home"}, + {KEY_UPARROW, "up arrow"}, + {KEY_PGUP, "pgup"}, + {KEY_LEFTARROW, "left arrow"}, + {KEY_RIGHTARROW, "right arrow"}, + {KEY_END, "end"}, + {KEY_DOWNARROW, "down arrow"}, + {KEY_PGDN, "pgdn"}, + {KEY_INS, "ins"}, + {KEY_DEL, "del"}, // other keys - {KEY_F1, "F1"}, - {KEY_F2, "F2"}, - {KEY_F3, "F3"}, - {KEY_F4, "F4"}, - {KEY_F5, "F5"}, - {KEY_F6, "F6"}, - {KEY_F7, "F7"}, - {KEY_F8, "F8"}, - {KEY_F9, "F9"}, - {KEY_F10, "F10"}, - {KEY_F11, "F11"}, - {KEY_F12, "F12"}, + {KEY_F1, "f1"}, + {KEY_F2, "f2"}, + {KEY_F3, "f3"}, + {KEY_F4, "f4"}, + {KEY_F5, "f5"}, + {KEY_F6, "f6"}, + {KEY_F7, "f7"}, + {KEY_F8, "f8"}, + {KEY_F9, "f9"}, + {KEY_F10, "f10"}, + {KEY_F11, "f11"}, + {KEY_F12, "f12"}, // KEY_CONSOLE has an exception in the keyname code {'`', "TILDE"}, - {KEY_PAUSE, "PAUSE/BREAK"}, + {KEY_PAUSE, "pause/break"}, // virtual keys for mouse buttons and joystick buttons - {KEY_MOUSE1+0,"MOUSE1"}, - {KEY_MOUSE1+1,"MOUSE2"}, - {KEY_MOUSE1+2,"MOUSE3"}, - {KEY_MOUSE1+3,"MOUSE4"}, - {KEY_MOUSE1+4,"MOUSE5"}, - {KEY_MOUSE1+5,"MOUSE6"}, - {KEY_MOUSE1+6,"MOUSE7"}, - {KEY_MOUSE1+7,"MOUSE8"}, - {KEY_2MOUSE1+0,"SEC_MOUSE2"}, // BP: sorry my mouse handler swap button 1 and 2 - {KEY_2MOUSE1+1,"SEC_MOUSE1"}, - {KEY_2MOUSE1+2,"SEC_MOUSE3"}, - {KEY_2MOUSE1+3,"SEC_MOUSE4"}, - {KEY_2MOUSE1+4,"SEC_MOUSE5"}, - {KEY_2MOUSE1+5,"SEC_MOUSE6"}, - {KEY_2MOUSE1+6,"SEC_MOUSE7"}, - {KEY_2MOUSE1+7,"SEC_MOUSE8"}, - {KEY_MOUSEWHEELUP, "Wheel 1 UP"}, - {KEY_MOUSEWHEELDOWN, "Wheel 1 Down"}, - {KEY_2MOUSEWHEELUP, "Wheel 2 UP"}, - {KEY_2MOUSEWHEELDOWN, "Wheel 2 Down"}, + {KEY_MOUSE1+0,"mouse1"}, + {KEY_MOUSE1+1,"mouse2"}, + {KEY_MOUSE1+2,"mouse3"}, + {KEY_MOUSE1+3,"mouse4"}, + {KEY_MOUSE1+4,"mouse5"}, + {KEY_MOUSE1+5,"mouse6"}, + {KEY_MOUSE1+6,"mouse7"}, + {KEY_MOUSE1+7,"mouse8"}, + {KEY_2MOUSE1+0,"sec_mouse2"}, // BP: sorry my mouse handler swap button 1 and 2 + {KEY_2MOUSE1+1,"sec_mouse1"}, + {KEY_2MOUSE1+2,"sec_mouse3"}, + {KEY_2MOUSE1+3,"sec_mouse4"}, + {KEY_2MOUSE1+4,"sec_mouse5"}, + {KEY_2MOUSE1+5,"sec_mouse6"}, + {KEY_2MOUSE1+6,"sec_mouse7"}, + {KEY_2MOUSE1+7,"sec_mouse8"}, + {KEY_MOUSEWHEELUP, "wheel 1 up"}, + {KEY_MOUSEWHEELDOWN, "wheel 1 down"}, + {KEY_2MOUSEWHEELUP, "wheel 2 up"}, + {KEY_2MOUSEWHEELDOWN, "wheel 2 down"}, - {KEY_JOY1+0, "JOY1"}, - {KEY_JOY1+1, "JOY2"}, - {KEY_JOY1+2, "JOY3"}, - {KEY_JOY1+3, "JOY4"}, - {KEY_JOY1+4, "JOY5"}, - {KEY_JOY1+5, "JOY6"}, - {KEY_JOY1+6, "JOY7"}, - {KEY_JOY1+7, "JOY8"}, - {KEY_JOY1+8, "JOY9"}, + {KEY_JOY1+0, "joy1"}, + {KEY_JOY1+1, "joy2"}, + {KEY_JOY1+2, "joy3"}, + {KEY_JOY1+3, "joy4"}, + {KEY_JOY1+4, "joy5"}, + {KEY_JOY1+5, "joy6"}, + {KEY_JOY1+6, "joy7"}, + {KEY_JOY1+7, "joy8"}, + {KEY_JOY1+8, "joy9"}, #if !defined (NOMOREJOYBTN_1S) // we use up to 32 buttons in DirectInput - {KEY_JOY1+9, "JOY10"}, - {KEY_JOY1+10, "JOY11"}, - {KEY_JOY1+11, "JOY12"}, - {KEY_JOY1+12, "JOY13"}, - {KEY_JOY1+13, "JOY14"}, - {KEY_JOY1+14, "JOY15"}, - {KEY_JOY1+15, "JOY16"}, - {KEY_JOY1+16, "JOY17"}, - {KEY_JOY1+17, "JOY18"}, - {KEY_JOY1+18, "JOY19"}, - {KEY_JOY1+19, "JOY20"}, - {KEY_JOY1+20, "JOY21"}, - {KEY_JOY1+21, "JOY22"}, - {KEY_JOY1+22, "JOY23"}, - {KEY_JOY1+23, "JOY24"}, - {KEY_JOY1+24, "JOY25"}, - {KEY_JOY1+25, "JOY26"}, - {KEY_JOY1+26, "JOY27"}, - {KEY_JOY1+27, "JOY28"}, - {KEY_JOY1+28, "JOY29"}, - {KEY_JOY1+29, "JOY30"}, - {KEY_JOY1+30, "JOY31"}, - {KEY_JOY1+31, "JOY32"}, + {KEY_JOY1+9, "joy10"}, + {KEY_JOY1+10, "joy11"}, + {KEY_JOY1+11, "joy12"}, + {KEY_JOY1+12, "joy13"}, + {KEY_JOY1+13, "joy14"}, + {KEY_JOY1+14, "joy15"}, + {KEY_JOY1+15, "joy16"}, + {KEY_JOY1+16, "joy17"}, + {KEY_JOY1+17, "joy18"}, + {KEY_JOY1+18, "joy19"}, + {KEY_JOY1+19, "joy20"}, + {KEY_JOY1+20, "joy21"}, + {KEY_JOY1+21, "joy22"}, + {KEY_JOY1+22, "joy23"}, + {KEY_JOY1+23, "joy24"}, + {KEY_JOY1+24, "joy25"}, + {KEY_JOY1+25, "joy26"}, + {KEY_JOY1+26, "joy27"}, + {KEY_JOY1+27, "joy28"}, + {KEY_JOY1+28, "joy29"}, + {KEY_JOY1+29, "joy30"}, + {KEY_JOY1+30, "joy31"}, + {KEY_JOY1+31, "joy32"}, #endif // the DOS version uses Allegro's joystick support - {KEY_HAT1+0, "HATUP"}, - {KEY_HAT1+1, "HATDOWN"}, - {KEY_HAT1+2, "HATLEFT"}, - {KEY_HAT1+3, "HATRIGHT"}, - {KEY_HAT1+4, "HATUP2"}, - {KEY_HAT1+5, "HATDOWN2"}, - {KEY_HAT1+6, "HATLEFT2"}, - {KEY_HAT1+7, "HATRIGHT2"}, - {KEY_HAT1+8, "HATUP3"}, - {KEY_HAT1+9, "HATDOWN3"}, - {KEY_HAT1+10, "HATLEFT3"}, - {KEY_HAT1+11, "HATRIGHT3"}, - {KEY_HAT1+12, "HATUP4"}, - {KEY_HAT1+13, "HATDOWN4"}, - {KEY_HAT1+14, "HATLEFT4"}, - {KEY_HAT1+15, "HATRIGHT4"}, + {KEY_HAT1+0, "hatup"}, + {KEY_HAT1+1, "hatdown"}, + {KEY_HAT1+2, "hatleft"}, + {KEY_HAT1+3, "hatright"}, + {KEY_HAT1+4, "hatup2"}, + {KEY_HAT1+5, "hatdown2"}, + {KEY_HAT1+6, "hatleft2"}, + {KEY_HAT1+7, "hatright2"}, + {KEY_HAT1+8, "hatup3"}, + {KEY_HAT1+9, "hatdown3"}, + {KEY_HAT1+10, "hatleft3"}, + {KEY_HAT1+11, "hatright3"}, + {KEY_HAT1+12, "hatup4"}, + {KEY_HAT1+13, "hatdown4"}, + {KEY_HAT1+14, "hatleft4"}, + {KEY_HAT1+15, "hatright4"}, - {KEY_DBLMOUSE1+0, "DBLMOUSE1"}, - {KEY_DBLMOUSE1+1, "DBLMOUSE2"}, - {KEY_DBLMOUSE1+2, "DBLMOUSE3"}, - {KEY_DBLMOUSE1+3, "DBLMOUSE4"}, - {KEY_DBLMOUSE1+4, "DBLMOUSE5"}, - {KEY_DBLMOUSE1+5, "DBLMOUSE6"}, - {KEY_DBLMOUSE1+6, "DBLMOUSE7"}, - {KEY_DBLMOUSE1+7, "DBLMOUSE8"}, - {KEY_DBL2MOUSE1+0, "DBLSEC_MOUSE2"}, // BP: sorry my mouse handler swap button 1 and 2 - {KEY_DBL2MOUSE1+1, "DBLSEC_MOUSE1"}, - {KEY_DBL2MOUSE1+2, "DBLSEC_MOUSE3"}, - {KEY_DBL2MOUSE1+3, "DBLSEC_MOUSE4"}, - {KEY_DBL2MOUSE1+4, "DBLSEC_MOUSE5"}, - {KEY_DBL2MOUSE1+5, "DBLSEC_MOUSE6"}, - {KEY_DBL2MOUSE1+6, "DBLSEC_MOUSE7"}, - {KEY_DBL2MOUSE1+7, "DBLSEC_MOUSE8"}, + {KEY_DBLMOUSE1+0, "dblmouse1"}, + {KEY_DBLMOUSE1+1, "dblmouse2"}, + {KEY_DBLMOUSE1+2, "dblmouse3"}, + {KEY_DBLMOUSE1+3, "dblmouse4"}, + {KEY_DBLMOUSE1+4, "dblmouse5"}, + {KEY_DBLMOUSE1+5, "dblmouse6"}, + {KEY_DBLMOUSE1+6, "dblmouse7"}, + {KEY_DBLMOUSE1+7, "dblmouse8"}, + {KEY_DBL2MOUSE1+0, "dblsec_mouse2"}, // BP: sorry my mouse handler swap button 1 and 2 + {KEY_DBL2MOUSE1+1, "dblsec_mouse1"}, + {KEY_DBL2MOUSE1+2, "dblsec_mouse3"}, + {KEY_DBL2MOUSE1+3, "dblsec_mouse4"}, + {KEY_DBL2MOUSE1+4, "dblsec_mouse5"}, + {KEY_DBL2MOUSE1+5, "dblsec_mouse6"}, + {KEY_DBL2MOUSE1+6, "dblsec_mouse7"}, + {KEY_DBL2MOUSE1+7, "dblsec_mouse8"}, - {KEY_DBLJOY1+0, "DBLJOY1"}, - {KEY_DBLJOY1+1, "DBLJOY2"}, - {KEY_DBLJOY1+2, "DBLJOY3"}, - {KEY_DBLJOY1+3, "DBLJOY4"}, - {KEY_DBLJOY1+4, "DBLJOY5"}, - {KEY_DBLJOY1+5, "DBLJOY6"}, - {KEY_DBLJOY1+6, "DBLJOY7"}, - {KEY_DBLJOY1+7, "DBLJOY8"}, + {KEY_DBLJOY1+0, "dbljoy1"}, + {KEY_DBLJOY1+1, "dbljoy2"}, + {KEY_DBLJOY1+2, "dbljoy3"}, + {KEY_DBLJOY1+3, "dbljoy4"}, + {KEY_DBLJOY1+4, "dbljoy5"}, + {KEY_DBLJOY1+5, "dbljoy6"}, + {KEY_DBLJOY1+6, "dbljoy7"}, + {KEY_DBLJOY1+7, "dbljoy8"}, #if !defined (NOMOREJOYBTN_1DBL) - {KEY_DBLJOY1+8, "DBLJOY9"}, - {KEY_DBLJOY1+9, "DBLJOY10"}, - {KEY_DBLJOY1+10, "DBLJOY11"}, - {KEY_DBLJOY1+11, "DBLJOY12"}, - {KEY_DBLJOY1+12, "DBLJOY13"}, - {KEY_DBLJOY1+13, "DBLJOY14"}, - {KEY_DBLJOY1+14, "DBLJOY15"}, - {KEY_DBLJOY1+15, "DBLJOY16"}, - {KEY_DBLJOY1+16, "DBLJOY17"}, - {KEY_DBLJOY1+17, "DBLJOY18"}, - {KEY_DBLJOY1+18, "DBLJOY19"}, - {KEY_DBLJOY1+19, "DBLJOY20"}, - {KEY_DBLJOY1+20, "DBLJOY21"}, - {KEY_DBLJOY1+21, "DBLJOY22"}, - {KEY_DBLJOY1+22, "DBLJOY23"}, - {KEY_DBLJOY1+23, "DBLJOY24"}, - {KEY_DBLJOY1+24, "DBLJOY25"}, - {KEY_DBLJOY1+25, "DBLJOY26"}, - {KEY_DBLJOY1+26, "DBLJOY27"}, - {KEY_DBLJOY1+27, "DBLJOY28"}, - {KEY_DBLJOY1+28, "DBLJOY29"}, - {KEY_DBLJOY1+29, "DBLJOY30"}, - {KEY_DBLJOY1+30, "DBLJOY31"}, - {KEY_DBLJOY1+31, "DBLJOY32"}, + {KEY_DBLJOY1+8, "dbljoy9"}, + {KEY_DBLJOY1+9, "dbljoy10"}, + {KEY_DBLJOY1+10, "dbljoy11"}, + {KEY_DBLJOY1+11, "dbljoy12"}, + {KEY_DBLJOY1+12, "dbljoy13"}, + {KEY_DBLJOY1+13, "dbljoy14"}, + {KEY_DBLJOY1+14, "dbljoy15"}, + {KEY_DBLJOY1+15, "dbljoy16"}, + {KEY_DBLJOY1+16, "dbljoy17"}, + {KEY_DBLJOY1+17, "dbljoy18"}, + {KEY_DBLJOY1+18, "dbljoy19"}, + {KEY_DBLJOY1+19, "dbljoy20"}, + {KEY_DBLJOY1+20, "dbljoy21"}, + {KEY_DBLJOY1+21, "dbljoy22"}, + {KEY_DBLJOY1+22, "dbljoy23"}, + {KEY_DBLJOY1+23, "dbljoy24"}, + {KEY_DBLJOY1+24, "dbljoy25"}, + {KEY_DBLJOY1+25, "dbljoy26"}, + {KEY_DBLJOY1+26, "dbljoy27"}, + {KEY_DBLJOY1+27, "dbljoy28"}, + {KEY_DBLJOY1+28, "dbljoy29"}, + {KEY_DBLJOY1+29, "dbljoy30"}, + {KEY_DBLJOY1+30, "dbljoy31"}, + {KEY_DBLJOY1+31, "dbljoy32"}, #endif - {KEY_DBLHAT1+0, "DBLHATUP"}, - {KEY_DBLHAT1+1, "DBLHATDOWN"}, - {KEY_DBLHAT1+2, "DBLHATLEFT"}, - {KEY_DBLHAT1+3, "DBLHATRIGHT"}, - {KEY_DBLHAT1+4, "DBLHATUP2"}, - {KEY_DBLHAT1+5, "DBLHATDOWN2"}, - {KEY_DBLHAT1+6, "DBLHATLEFT2"}, - {KEY_DBLHAT1+7, "DBLHATRIGHT2"}, - {KEY_DBLHAT1+8, "DBLHATUP3"}, - {KEY_DBLHAT1+9, "DBLHATDOWN3"}, - {KEY_DBLHAT1+10, "DBLHATLEFT3"}, - {KEY_DBLHAT1+11, "DBLHATRIGHT3"}, - {KEY_DBLHAT1+12, "DBLHATUP4"}, - {KEY_DBLHAT1+13, "DBLHATDOWN4"}, - {KEY_DBLHAT1+14, "DBLHATLEFT4"}, - {KEY_DBLHAT1+15, "DBLHATRIGHT4"}, + {KEY_DBLHAT1+0, "dblhatup"}, + {KEY_DBLHAT1+1, "dblhatdown"}, + {KEY_DBLHAT1+2, "dblhatleft"}, + {KEY_DBLHAT1+3, "dblhatright"}, + {KEY_DBLHAT1+4, "dblhatup2"}, + {KEY_DBLHAT1+5, "dblhatdown2"}, + {KEY_DBLHAT1+6, "dblhatleft2"}, + {KEY_DBLHAT1+7, "dblhatright2"}, + {KEY_DBLHAT1+8, "dblhatup3"}, + {KEY_DBLHAT1+9, "dblhatdown3"}, + {KEY_DBLHAT1+10, "dblhatleft3"}, + {KEY_DBLHAT1+11, "dblhatright3"}, + {KEY_DBLHAT1+12, "dblhatup4"}, + {KEY_DBLHAT1+13, "dblhatdown4"}, + {KEY_DBLHAT1+14, "dblhatleft4"}, + {KEY_DBLHAT1+15, "dblhatright4"}, - {KEY_2JOY1+0, "SEC_JOY1"}, - {KEY_2JOY1+1, "SEC_JOY2"}, - {KEY_2JOY1+2, "SEC_JOY3"}, - {KEY_2JOY1+3, "SEC_JOY4"}, - {KEY_2JOY1+4, "SEC_JOY5"}, - {KEY_2JOY1+5, "SEC_JOY6"}, - {KEY_2JOY1+6, "SEC_JOY7"}, - {KEY_2JOY1+7, "SEC_JOY8"}, + {KEY_2JOY1+0, "sec_joy1"}, + {KEY_2JOY1+1, "sec_joy2"}, + {KEY_2JOY1+2, "sec_joy3"}, + {KEY_2JOY1+3, "sec_joy4"}, + {KEY_2JOY1+4, "sec_joy5"}, + {KEY_2JOY1+5, "sec_joy6"}, + {KEY_2JOY1+6, "sec_joy7"}, + {KEY_2JOY1+7, "sec_joy8"}, #if !defined (NOMOREJOYBTN_2S) // we use up to 32 buttons in DirectInput - {KEY_2JOY1+8, "SEC_JOY9"}, - {KEY_2JOY1+9, "SEC_JOY10"}, - {KEY_2JOY1+10, "SEC_JOY11"}, - {KEY_2JOY1+11, "SEC_JOY12"}, - {KEY_2JOY1+12, "SEC_JOY13"}, - {KEY_2JOY1+13, "SEC_JOY14"}, - {KEY_2JOY1+14, "SEC_JOY15"}, - {KEY_2JOY1+15, "SEC_JOY16"}, - {KEY_2JOY1+16, "SEC_JOY17"}, - {KEY_2JOY1+17, "SEC_JOY18"}, - {KEY_2JOY1+18, "SEC_JOY19"}, - {KEY_2JOY1+19, "SEC_JOY20"}, - {KEY_2JOY1+20, "SEC_JOY21"}, - {KEY_2JOY1+21, "SEC_JOY22"}, - {KEY_2JOY1+22, "SEC_JOY23"}, - {KEY_2JOY1+23, "SEC_JOY24"}, - {KEY_2JOY1+24, "SEC_JOY25"}, - {KEY_2JOY1+25, "SEC_JOY26"}, - {KEY_2JOY1+26, "SEC_JOY27"}, - {KEY_2JOY1+27, "SEC_JOY28"}, - {KEY_2JOY1+28, "SEC_JOY29"}, - {KEY_2JOY1+29, "SEC_JOY30"}, - {KEY_2JOY1+30, "SEC_JOY31"}, - {KEY_2JOY1+31, "SEC_JOY32"}, + {KEY_2JOY1+8, "sec_joy9"}, + {KEY_2JOY1+9, "sec_joy10"}, + {KEY_2JOY1+10, "sec_joy11"}, + {KEY_2JOY1+11, "sec_joy12"}, + {KEY_2JOY1+12, "sec_joy13"}, + {KEY_2JOY1+13, "sec_joy14"}, + {KEY_2JOY1+14, "sec_joy15"}, + {KEY_2JOY1+15, "sec_joy16"}, + {KEY_2JOY1+16, "sec_joy17"}, + {KEY_2JOY1+17, "sec_joy18"}, + {KEY_2JOY1+18, "sec_joy19"}, + {KEY_2JOY1+19, "sec_joy20"}, + {KEY_2JOY1+20, "sec_joy21"}, + {KEY_2JOY1+21, "sec_joy22"}, + {KEY_2JOY1+22, "sec_joy23"}, + {KEY_2JOY1+23, "sec_joy24"}, + {KEY_2JOY1+24, "sec_joy25"}, + {KEY_2JOY1+25, "sec_joy26"}, + {KEY_2JOY1+26, "sec_joy27"}, + {KEY_2JOY1+27, "sec_joy28"}, + {KEY_2JOY1+28, "sec_joy29"}, + {KEY_2JOY1+29, "sec_joy30"}, + {KEY_2JOY1+30, "sec_joy31"}, + {KEY_2JOY1+31, "sec_joy32"}, #endif // the DOS version uses Allegro's joystick support - {KEY_2HAT1+0, "SEC_HATUP"}, - {KEY_2HAT1+1, "SEC_HATDOWN"}, - {KEY_2HAT1+2, "SEC_HATLEFT"}, - {KEY_2HAT1+3, "SEC_HATRIGHT"}, - {KEY_2HAT1+4, "SEC_HATUP2"}, - {KEY_2HAT1+5, "SEC_HATDOWN2"}, - {KEY_2HAT1+6, "SEC_HATLEFT2"}, - {KEY_2HAT1+7, "SEC_HATRIGHT2"}, - {KEY_2HAT1+8, "SEC_HATUP3"}, - {KEY_2HAT1+9, "SEC_HATDOWN3"}, - {KEY_2HAT1+10, "SEC_HATLEFT3"}, - {KEY_2HAT1+11, "SEC_HATRIGHT3"}, - {KEY_2HAT1+12, "SEC_HATUP4"}, - {KEY_2HAT1+13, "SEC_HATDOWN4"}, - {KEY_2HAT1+14, "SEC_HATLEFT4"}, - {KEY_2HAT1+15, "SEC_HATRIGHT4"}, + {KEY_2HAT1+0, "sec_hatup"}, + {KEY_2HAT1+1, "sec_hatdown"}, + {KEY_2HAT1+2, "sec_hatleft"}, + {KEY_2HAT1+3, "sec_hatright"}, + {KEY_2HAT1+4, "sec_hatup2"}, + {KEY_2HAT1+5, "sec_hatdown2"}, + {KEY_2HAT1+6, "sec_hatleft2"}, + {KEY_2HAT1+7, "sec_hatright2"}, + {KEY_2HAT1+8, "sec_hatup3"}, + {KEY_2HAT1+9, "sec_hatdown3"}, + {KEY_2HAT1+10, "sec_hatleft3"}, + {KEY_2HAT1+11, "sec_hatright3"}, + {KEY_2HAT1+12, "sec_hatup4"}, + {KEY_2HAT1+13, "sec_hatdown4"}, + {KEY_2HAT1+14, "sec_hatleft4"}, + {KEY_2HAT1+15, "sec_hatright4"}, - {KEY_DBL2JOY1+0, "DBLSEC_JOY1"}, - {KEY_DBL2JOY1+1, "DBLSEC_JOY2"}, - {KEY_DBL2JOY1+2, "DBLSEC_JOY3"}, - {KEY_DBL2JOY1+3, "DBLSEC_JOY4"}, - {KEY_DBL2JOY1+4, "DBLSEC_JOY5"}, - {KEY_DBL2JOY1+5, "DBLSEC_JOY6"}, - {KEY_DBL2JOY1+6, "DBLSEC_JOY7"}, - {KEY_DBL2JOY1+7, "DBLSEC_JOY8"}, + {KEY_DBL2JOY1+0, "dblsec_joy1"}, + {KEY_DBL2JOY1+1, "dblsec_joy2"}, + {KEY_DBL2JOY1+2, "dblsec_joy3"}, + {KEY_DBL2JOY1+3, "dblsec_joy4"}, + {KEY_DBL2JOY1+4, "dblsec_joy5"}, + {KEY_DBL2JOY1+5, "dblsec_joy6"}, + {KEY_DBL2JOY1+6, "dblsec_joy7"}, + {KEY_DBL2JOY1+7, "dblsec_joy8"}, #if !defined (NOMOREJOYBTN_2DBL) - {KEY_DBL2JOY1+8, "DBLSEC_JOY9"}, - {KEY_DBL2JOY1+9, "DBLSEC_JOY10"}, - {KEY_DBL2JOY1+10, "DBLSEC_JOY11"}, - {KEY_DBL2JOY1+11, "DBLSEC_JOY12"}, - {KEY_DBL2JOY1+12, "DBLSEC_JOY13"}, - {KEY_DBL2JOY1+13, "DBLSEC_JOY14"}, - {KEY_DBL2JOY1+14, "DBLSEC_JOY15"}, - {KEY_DBL2JOY1+15, "DBLSEC_JOY16"}, - {KEY_DBL2JOY1+16, "DBLSEC_JOY17"}, - {KEY_DBL2JOY1+17, "DBLSEC_JOY18"}, - {KEY_DBL2JOY1+18, "DBLSEC_JOY19"}, - {KEY_DBL2JOY1+19, "DBLSEC_JOY20"}, - {KEY_DBL2JOY1+20, "DBLSEC_JOY21"}, - {KEY_DBL2JOY1+21, "DBLSEC_JOY22"}, - {KEY_DBL2JOY1+22, "DBLSEC_JOY23"}, - {KEY_DBL2JOY1+23, "DBLSEC_JOY24"}, - {KEY_DBL2JOY1+24, "DBLSEC_JOY25"}, - {KEY_DBL2JOY1+25, "DBLSEC_JOY26"}, - {KEY_DBL2JOY1+26, "DBLSEC_JOY27"}, - {KEY_DBL2JOY1+27, "DBLSEC_JOY28"}, - {KEY_DBL2JOY1+28, "DBLSEC_JOY29"}, - {KEY_DBL2JOY1+29, "DBLSEC_JOY30"}, - {KEY_DBL2JOY1+30, "DBLSEC_JOY31"}, - {KEY_DBL2JOY1+31, "DBLSEC_JOY32"}, + {KEY_DBL2JOY1+8, "dblsec_joy9"}, + {KEY_DBL2JOY1+9, "dblsec_joy10"}, + {KEY_DBL2JOY1+10, "dblsec_joy11"}, + {KEY_DBL2JOY1+11, "dblsec_joy12"}, + {KEY_DBL2JOY1+12, "dblsec_joy13"}, + {KEY_DBL2JOY1+13, "dblsec_joy14"}, + {KEY_DBL2JOY1+14, "dblsec_joy15"}, + {KEY_DBL2JOY1+15, "dblsec_joy16"}, + {KEY_DBL2JOY1+16, "dblsec_joy17"}, + {KEY_DBL2JOY1+17, "dblsec_joy18"}, + {KEY_DBL2JOY1+18, "dblsec_joy19"}, + {KEY_DBL2JOY1+19, "dblsec_joy20"}, + {KEY_DBL2JOY1+20, "dblsec_joy21"}, + {KEY_DBL2JOY1+21, "dblsec_joy22"}, + {KEY_DBL2JOY1+22, "dblsec_joy23"}, + {KEY_DBL2JOY1+23, "dblsec_joy24"}, + {KEY_DBL2JOY1+24, "dblsec_joy25"}, + {KEY_DBL2JOY1+25, "dblsec_joy26"}, + {KEY_DBL2JOY1+26, "dblsec_joy27"}, + {KEY_DBL2JOY1+27, "dblsec_joy28"}, + {KEY_DBL2JOY1+28, "dblsec_joy29"}, + {KEY_DBL2JOY1+29, "dblsec_joy30"}, + {KEY_DBL2JOY1+30, "dblsec_joy31"}, + {KEY_DBL2JOY1+31, "dblsec_joy32"}, #endif - {KEY_DBL2HAT1+0, "DBLSEC_HATUP"}, - {KEY_DBL2HAT1+1, "DBLSEC_HATDOWN"}, - {KEY_DBL2HAT1+2, "DBLSEC_HATLEFT"}, - {KEY_DBL2HAT1+3, "DBLSEC_HATRIGHT"}, - {KEY_DBL2HAT1+4, "DBLSEC_HATUP2"}, - {KEY_DBL2HAT1+5, "DBLSEC_HATDOWN2"}, - {KEY_DBL2HAT1+6, "DBLSEC_HATLEFT2"}, - {KEY_DBL2HAT1+7, "DBLSEC_HATRIGHT2"}, - {KEY_DBL2HAT1+8, "DBLSEC_HATUP3"}, - {KEY_DBL2HAT1+9, "DBLSEC_HATDOWN3"}, - {KEY_DBL2HAT1+10, "DBLSEC_HATLEFT3"}, - {KEY_DBL2HAT1+11, "DBLSEC_HATRIGHT3"}, - {KEY_DBL2HAT1+12, "DBLSEC_HATUP4"}, - {KEY_DBL2HAT1+13, "DBLSEC_HATDOWN4"}, - {KEY_DBL2HAT1+14, "DBLSEC_HATLEFT4"}, - {KEY_DBL2HAT1+15, "DBLSEC_HATRIGHT4"}, + {KEY_DBL2HAT1+0, "dblsec_hatup"}, + {KEY_DBL2HAT1+1, "dblsec_hatdown"}, + {KEY_DBL2HAT1+2, "dblsec_hatleft"}, + {KEY_DBL2HAT1+3, "dblsec_hatright"}, + {KEY_DBL2HAT1+4, "dblsec_hatup2"}, + {KEY_DBL2HAT1+5, "dblsec_hatdown2"}, + {KEY_DBL2HAT1+6, "dblsec_hatleft2"}, + {KEY_DBL2HAT1+7, "dblsec_hatright2"}, + {KEY_DBL2HAT1+8, "dblsec_hatup3"}, + {KEY_DBL2HAT1+9, "dblsec_hatdown3"}, + {KEY_DBL2HAT1+10, "dblsec_hatleft3"}, + {KEY_DBL2HAT1+11, "dblsec_hatright3"}, + {KEY_DBL2HAT1+12, "dblsec_hatup4"}, + {KEY_DBL2HAT1+13, "dblsec_hatdown4"}, + {KEY_DBL2HAT1+14, "dblsec_hatleft4"}, + {KEY_DBL2HAT1+15, "dblsec_hatright4"}, }; From 14403737efa4715ce49effd15a48fcb8c7384eb0 Mon Sep 17 00:00:00 2001 From: LJ Sonic Date: Thu, 2 Dec 2021 23:15:55 +0100 Subject: [PATCH 0961/1080] Raise the file upload speed drastically --- 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 efe6473d4..5aab9c3cf 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -3189,7 +3189,7 @@ consvar_t cv_maxsend = CVAR_INIT ("maxsend", "4096", CV_SAVE|CV_NETVAR, maxsend_ consvar_t cv_noticedownload = CVAR_INIT ("noticedownload", "Off", CV_SAVE|CV_NETVAR, CV_OnOff, NULL); // Speed of file downloading (in packets per tic) -static CV_PossibleValue_t downloadspeed_cons_t[] = {{0, "MIN"}, {32, "MAX"}, {0, NULL}}; +static CV_PossibleValue_t downloadspeed_cons_t[] = {{0, "MIN"}, {300, "MAX"}, {0, NULL}}; consvar_t cv_downloadspeed = CVAR_INIT ("downloadspeed", "16", CV_SAVE|CV_NETVAR, downloadspeed_cons_t, NULL); static void Got_AddPlayer(UINT8 **p, INT32 playernum); From ff037a81608eead67faa44fa4ea1bbbbeb46989c Mon Sep 17 00:00:00 2001 From: LJ Sonic Date: Thu, 2 Dec 2021 23:34:28 +0100 Subject: [PATCH 0962/1080] Remove downloadspeed cruft --- src/d_clisrv.c | 2 +- src/d_netfil.c | 10 +--------- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 5aab9c3cf..47733a3ee 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -3189,7 +3189,7 @@ consvar_t cv_maxsend = CVAR_INIT ("maxsend", "4096", CV_SAVE|CV_NETVAR, maxsend_ consvar_t cv_noticedownload = CVAR_INIT ("noticedownload", "Off", CV_SAVE|CV_NETVAR, CV_OnOff, NULL); // Speed of file downloading (in packets per tic) -static CV_PossibleValue_t downloadspeed_cons_t[] = {{0, "MIN"}, {300, "MAX"}, {0, NULL}}; +static CV_PossibleValue_t downloadspeed_cons_t[] = {{1, "MIN"}, {300, "MAX"}, {0, NULL}}; consvar_t cv_downloadspeed = CVAR_INIT ("downloadspeed", "16", CV_SAVE|CV_NETVAR, downloadspeed_cons_t, NULL); static void Got_AddPlayer(UINT8 **p, INT32 playernum); diff --git a/src/d_netfil.c b/src/d_netfil.c index 12c5ee6a2..daf6271bf 100644 --- a/src/d_netfil.c +++ b/src/d_netfil.c @@ -925,7 +925,6 @@ static void SV_EndFileSend(INT32 node) filestosend--; } -#define PACKETPERTIC net_bandwidth/(TICRATE*software_MAXPACKETLENGTH) #define FILEFRAGMENTSIZE (software_MAXPACKETLENGTH - (FILETXHEADER + BASEPACKETSIZE)) /** Handles file transmission @@ -958,14 +957,7 @@ void FileSendTicker(void) if (!filestosend) // No file to send return; - if (cv_downloadspeed.value) // New behavior - packetsent = cv_downloadspeed.value; - else // Old behavior - { - packetsent = PACKETPERTIC; - if (!packetsent) - packetsent = 1; - } + packetsent = cv_downloadspeed.value; netbuffer->packettype = PT_FILEFRAGMENT; From a3353be0dce216dd7945a3c2f6af6ac24092e820 Mon Sep 17 00:00:00 2001 From: LZA <73-LZA@users.noreply.git.do.srb2.org> Date: Thu, 2 Dec 2021 22:50:44 +0000 Subject: [PATCH 0963/1080] Raise addon limit --- src/d_clisrv.c | 547 +++++++++++++++++++++++++++++++++++++------------ src/d_clisrv.h | 18 +- src/d_main.c | 102 +++++---- src/d_net.c | 2 + src/d_netcmd.c | 43 ++-- src/d_netcmd.h | 1 + src/d_netfil.c | 278 +++++++++++++++---------- src/d_netfil.h | 27 ++- src/doomdef.h | 3 + src/filesrch.c | 15 +- src/filesrch.h | 3 - src/m_menu.c | 11 +- src/w_wad.c | 74 ++----- src/w_wad.h | 20 +- 14 files changed, 768 insertions(+), 376 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index efe6473d4..36ced7f64 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -128,10 +128,14 @@ static UINT8 localtextcmd[MAXTEXTCMD]; static UINT8 localtextcmd2[MAXTEXTCMD]; // splitscreen static tic_t neededtic; SINT8 servernode = 0; // the number of the server node + /// \brief do we accept new players? /// \todo WORK! boolean acceptnewnode = true; +static boolean serverisfull = false; //lets us be aware if the server was full after we check files, but before downloading, so we can ask if the user still wants to download or not +static tic_t firstconnectattempttime = 0; + // engine // Must be a power of two @@ -511,18 +515,24 @@ static INT16 Consistancy(void); typedef enum { CL_SEARCHING, + CL_CHECKFILES, CL_DOWNLOADFILES, CL_ASKJOIN, + CL_LOADFILES, CL_WAITJOINRESPONSE, CL_DOWNLOADSAVEGAME, CL_CONNECTED, - CL_ABORTED + CL_ABORTED, + CL_ASKFULLFILELIST, + CL_CONFIRMCONNECT } cl_mode_t; static void GetPackets(void); static cl_mode_t cl_mode = CL_SEARCHING; +static UINT16 cl_lastcheckedfilecount = 0; // used for full file list + #ifndef NONET #define SNAKE_SPEED 5 @@ -920,6 +930,8 @@ static void Snake_Draw(void) INT16 i; // Background + V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 31); + V_DrawFlatFill( SNAKE_LEFT_X + SNAKE_BORDER_SIZE, SNAKE_TOP_Y + SNAKE_BORDER_SIZE, @@ -1021,6 +1033,13 @@ static void Snake_Draw(void) ); } +static void CL_DrawConnectionStatusBox(void) +{ + M_DrawTextBox(BASEVIDWIDTH/2-128-8, BASEVIDHEIGHT-16-8, 32, 1); + if (cl_mode != CL_CONFIRMCONNECT) + V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-16-16, V_YELLOWMAP, "Press ESC to abort"); +} + // // CL_DrawConnectionStatus // @@ -1031,28 +1050,32 @@ static inline void CL_DrawConnectionStatus(void) INT32 ccstime = I_GetTime(); // Draw background fade - if (!menuactive) // menu already draws its own fade - V_DrawFadeScreen(0xFF00, 16); // force default + V_DrawFadeScreen(0xFF00, 16); // force default - // Draw the bottom box. - M_DrawTextBox(BASEVIDWIDTH/2-128-8, BASEVIDHEIGHT-16-8, 32, 1); - V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-16-16, V_YELLOWMAP, "Press ESC to abort"); - - if (cl_mode != CL_DOWNLOADFILES) + if (cl_mode != CL_DOWNLOADFILES && cl_mode != CL_LOADFILES) { INT32 i, animtime = ((ccstime / 4) & 15) + 16; - UINT8 palstart = (cl_mode == CL_SEARCHING) ? 32 : 96; - // 15 pal entries total. + UINT8 palstart; const char *cltext; + // Draw the bottom box. + CL_DrawConnectionStatusBox(); + + if (cl_mode == CL_SEARCHING) + palstart = 32; // Red + else if (cl_mode == CL_CONFIRMCONNECT) + palstart = 48; // Orange + else + palstart = 96; // Green + if (!(cl_mode == CL_DOWNLOADSAVEGAME && lastfilenum != -1)) - for (i = 0; i < 16; ++i) + for (i = 0; i < 16; ++i) // 15 pal entries total. V_DrawFill((BASEVIDWIDTH/2-128) + (i * 16), BASEVIDHEIGHT-16, 16, 8, palstart + ((animtime - i) & 15)); switch (cl_mode) { case CL_DOWNLOADSAVEGAME: - if (lastfilenum != -1) + if (fileneeded && lastfilenum != -1) { UINT32 currentsize = fileneeded[lastfilenum].currentsize; UINT32 totalsize = fileneeded[lastfilenum].totalsize; @@ -1076,9 +1099,22 @@ static inline void CL_DrawConnectionStatus(void) else cltext = M_GetText("Waiting to download game state..."); break; + case CL_ASKFULLFILELIST: + case CL_CHECKFILES: + cltext = M_GetText("Checking server addon list..."); + break; + case CL_CONFIRMCONNECT: + cltext = ""; + break; + case CL_LOADFILES: + cltext = M_GetText("Loading server addons..."); + break; case CL_ASKJOIN: case CL_WAITJOINRESPONSE: - cltext = M_GetText("Requesting to join..."); + if (serverisfull) + cltext = M_GetText("Server full, waiting for a slot..."); + else + cltext = M_GetText("Requesting to join..."); break; default: cltext = M_GetText("Connecting to server..."); @@ -1088,14 +1124,51 @@ static inline void CL_DrawConnectionStatus(void) } else { - if (lastfilenum != -1) + if (cl_mode == CL_LOADFILES) + { + INT32 totalfileslength; + INT32 loadcompletednum = 0; + INT32 i; + + V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-16-16, V_YELLOWMAP, "Press ESC to abort"); + + //ima just count files here + if (fileneeded) + { + for (i = 0; i < fileneedednum; i++) + if (fileneeded[i].status == FS_OPEN) + loadcompletednum++; + } + + // Loading progress + V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-16-24, V_YELLOWMAP, "Loading server addons..."); + totalfileslength = (INT32)((loadcompletednum/(double)(fileneedednum)) * 256); + M_DrawTextBox(BASEVIDWIDTH/2-128-8, BASEVIDHEIGHT-16-8, 32, 1); + V_DrawFill(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-16, 256, 8, 111); + V_DrawFill(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-16, totalfileslength, 8, 96); + V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-16, V_20TRANS|V_MONOSPACE, + va(" %2u/%2u Files",loadcompletednum,fileneedednum)); + } + else if (lastfilenum != -1) { INT32 dldlength; static char tempname[28]; - fileneeded_t *file = &fileneeded[lastfilenum]; - char *filename = file->filename; + fileneeded_t *file; + char *filename; - Snake_Draw(); + if (snake) + Snake_Draw(); + + // Draw the bottom box. + CL_DrawConnectionStatusBox(); + + if (fileneeded) + { + file = &fileneeded[lastfilenum]; + filename = file->filename; + } + else + return; Net_GetNetStat(); dldlength = (INT32)((file->currentsize/(double)file->totalsize) * 256); @@ -1128,20 +1201,32 @@ static inline void CL_DrawConnectionStatus(void) va("%3.1fK/s ", ((double)getbps)/1024)); } else + { + if (snake) + Snake_Draw(); + + CL_DrawConnectionStatusBox(); V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-16-24, V_YELLOWMAP, M_GetText("Waiting to download files...")); + } } } #endif +static boolean CL_AskFileList(INT32 firstfile) +{ + netbuffer->packettype = PT_TELLFILESNEEDED; + netbuffer->u.filesneedednum = firstfile; + + return HSendPacket(servernode, false, 0, sizeof (INT32)); +} + /** Sends a special packet to declare how many players in local * Used only in arbitratrenetstart() * Sends a PT_CLIENTJOIN packet to the server * * \return True if the packet was successfully sent * \todo Improve the description... - * Because to be honest, I have no idea what arbitratrenetstart is... - * Is it even used...? * */ static boolean CL_SendJoin(void) @@ -1240,7 +1325,7 @@ static void SV_SendServerInfo(INT32 node, tic_t servertime) sizeof netbuffer->u.serverinfo.gametypename); netbuffer->u.serverinfo.modifiedgame = (UINT8)modifiedgame; netbuffer->u.serverinfo.cheatsenabled = CV_CheatsEnabled(); - netbuffer->u.serverinfo.isdedicated = (UINT8)dedicated; + netbuffer->u.serverinfo.flags = (dedicated ? SV_DEDICATED : 0); strncpy(netbuffer->u.serverinfo.servername, cv_servername.string, MAXSERVERNAME); strncpy(netbuffer->u.serverinfo.mapname, G_BuildMapName(gamemap), 7); @@ -1275,7 +1360,7 @@ static void SV_SendServerInfo(INT32 node, tic_t servertime) if (mapheaderinfo[gamemap-1]) netbuffer->u.serverinfo.actnum = mapheaderinfo[gamemap-1]->actnum; - p = PutFileNeeded(); + p = PutFileNeeded(0); HSendPacket(node, false, 0, p - ((UINT8 *)&netbuffer->u)); } @@ -1526,6 +1611,8 @@ static void CL_LoadReceivedSavegame(boolean reloading) size_t length, decompressedlen; char tmpsave[256]; + FreeFileNeeded(); + sprintf(tmpsave, "%s" PATHSEP TMPSAVENAME, srb2home); length = FIL_ReadFile(tmpsave, &savebuffer); @@ -1836,12 +1923,164 @@ void CL_UpdateServerList(boolean internetsearch, INT32 room) #endif/*MASTERSERVER*/ } -static const char * InvalidServerReason (INT32 i) +#endif // ifndef NONET + +static void M_ConfirmConnect(event_t *ev) +{ +#ifndef NONET + if (ev->type == ev_keydown) + { + if (ev->key == ' ' || ev->key == 'y' || ev->key == KEY_ENTER) + { + if (totalfilesrequestednum > 0) + { + if (CL_SendFileRequest()) + { + cl_mode = CL_DOWNLOADFILES; + Snake_Initialise(); + } + } + else + cl_mode = CL_LOADFILES; + + M_ClearMenus(true); + } + else if (ev->key == 'n' || ev->key == KEY_ESCAPE) + { + cl_mode = CL_ABORTED; + M_ClearMenus(true); + } + } +#else + (void)ev; +#endif +} + +static boolean CL_FinishedFileList(void) +{ + INT32 i; + char *downloadsize = NULL; + //CONS_Printf(M_GetText("Checking files...\n")); + i = CL_CheckFiles(); + if (i == 4) // still checking ... + { + return true; + } + else if (i == 3) // too many files + { + D_QuitNetGame(); + CL_Reset(); + D_StartTitle(); + M_StartMessage(M_GetText( + "You have too many WAD files loaded\n" + "to add ones the server is using.\n" + "Please restart SRB2 before connecting.\n\n" + "Press ESC\n" + ), NULL, MM_NOTHING); + return false; + } + else if (i == 2) // cannot join for some reason + { + D_QuitNetGame(); + CL_Reset(); + D_StartTitle(); + M_StartMessage(M_GetText( + "You have the wrong addons loaded.\n\n" + "To play on this server, restart\n" + "the game and don't load any addons.\n" + "SRB2 will automatically add\n" + "everything you need when you join.\n\n" + "Press ESC\n" + ), NULL, MM_NOTHING); + return false; + } + else if (i == 1) + { + if (serverisfull) + { + M_StartMessage(M_GetText( + "This server is full!\n" + "\n" + "You may load server addons (if any), and wait for a slot.\n" + "\n" + "Press ENTER to continue\nor ESC to cancel.\n\n" + ), M_ConfirmConnect, MM_EVENTHANDLER); + cl_mode = CL_CONFIRMCONNECT; + curfadevalue = 0; + } + else + cl_mode = CL_LOADFILES; + } + else + { + // must download something + // can we, though? + if (!CL_CheckDownloadable()) // nope! + { + D_QuitNetGame(); + CL_Reset(); + D_StartTitle(); + M_StartMessage(M_GetText( + "An error occured when trying to\n" + "download missing addons.\n" + "(This is almost always a problem\n" + "with the server, not your game.)\n\n" + "See the console or log file\n" + "for additional details.\n\n" + "Press ESC\n" + ), NULL, MM_NOTHING); + return false; + } + +#ifndef NONET + downloadcompletednum = 0; + downloadcompletedsize = 0; + totalfilesrequestednum = 0; + totalfilesrequestedsize = 0; + + if (fileneeded == NULL) + I_Error("CL_FinishedFileList: fileneeded == NULL"); + + for (i = 0; i < fileneedednum; i++) + if (fileneeded[i].status == FS_NOTFOUND || fileneeded[i].status == FS_MD5SUMBAD) + { + totalfilesrequestednum++; + totalfilesrequestedsize += fileneeded[i].totalsize; + } + + if (totalfilesrequestedsize>>20 >= 100) + downloadsize = Z_StrDup(va("%uM",totalfilesrequestedsize>>20)); + else + downloadsize = Z_StrDup(va("%uK",totalfilesrequestedsize>>10)); +#endif + + if (serverisfull) + M_StartMessage(va(M_GetText( + "This server is full!\n" + "Download of %s additional content\nis required to join.\n" + "\n" + "You may download, load server addons,\nand wait for a slot.\n" + "\n" + "Press ENTER to continue\nor ESC to cancel.\n" + ), downloadsize), M_ConfirmConnect, MM_EVENTHANDLER); + else + M_StartMessage(va(M_GetText( + "Download of %s additional content\nis required to join.\n" + "\n" + "Press ENTER to continue\nor ESC to cancel.\n" + ), downloadsize), M_ConfirmConnect, MM_EVENTHANDLER); + + Z_Free(downloadsize); + cl_mode = CL_CONFIRMCONNECT; + curfadevalue = 0; + } + return true; +} + +static const char * InvalidServerReason (serverinfo_pak *info) { #define EOT "\nPress ESC\n" - serverinfo_pak *info = &serverlist[i].info; - /* magic number for new packet format */ if (info->_255 != 255) { @@ -1902,8 +2141,6 @@ static const char * InvalidServerReason (INT32 i) #undef EOT } -#endif // ifndef NONET - /** Called by CL_ServerConnectionTicker * * \param asksent The last time we asked the server to join. We re-ask every second in case our request got lost in transmit. @@ -1936,86 +2173,44 @@ static boolean CL_ServerConnectionSearchTicker(tic_t *asksent) if (client) { - const char *reason = InvalidServerReason(i); + serverinfo_pak *info = &serverlist[i].info; - // Quit here rather than downloading files - // and being refused later. - if (reason) - { - char *message = Z_StrDup(reason); - D_QuitNetGame(); - CL_Reset(); - D_StartTitle(); - M_StartMessage(message, NULL, MM_NOTHING); - Z_Free(message); - return false; - } - - D_ParseFileneeded(serverlist[i].info.fileneedednum, - serverlist[i].info.fileneeded); - CONS_Printf(M_GetText("Checking files...\n")); - i = CL_CheckFiles(); - if (i == 3) // too many files - { - D_QuitNetGame(); - CL_Reset(); - D_StartTitle(); - M_StartMessage(M_GetText( - "You have too many WAD files loaded\n" - "to add ones the server is using.\n" - "Please restart SRB2 before connecting.\n\n" - "Press ESC\n" - ), NULL, MM_NOTHING); - return false; - } - else if (i == 2) // cannot join for some reason - { - D_QuitNetGame(); - CL_Reset(); - D_StartTitle(); - M_StartMessage(M_GetText( - "You have the wrong addons loaded.\n\n" - "To play on this server, restart\n" - "the game and don't load any addons.\n" - "SRB2 will automatically add\n" - "everything you need when you join.\n\n" - "Press ESC\n" - ), NULL, MM_NOTHING); - return false; - } - else if (i == 1) - cl_mode = CL_ASKJOIN; + if (info->refusereason == REFUSE_SLOTS_FULL) + serverisfull = true; else { - // must download something - // can we, though? - if (!CL_CheckDownloadable()) // nope! + const char *reason = InvalidServerReason(info); + + // Quit here rather than downloading files + // and being refused later. + if (reason) { + char *message = Z_StrDup(reason); D_QuitNetGame(); CL_Reset(); D_StartTitle(); - M_StartMessage(M_GetText( - "You cannot connect to this server\n" - "because you cannot download the files\n" - "that you are missing from the server.\n\n" - "See the console or log file for\n" - "more details.\n\n" - "Press ESC\n" - ), NULL, MM_NOTHING); + M_StartMessage(message, NULL, MM_NOTHING); + Z_Free(message); return false; } - // no problem if can't send packet, we will retry later - if (CL_SendFileRequest()) - { - cl_mode = CL_DOWNLOADFILES; -#ifndef NONET - Snake_Initialise(); -#endif - } } + + D_ParseFileneeded(info->fileneedednum, info->fileneeded, 0); + + if (info->flags & SV_LOTSOFADDONS) + { + cl_mode = CL_ASKFULLFILELIST; + cl_lastcheckedfilecount = 0; + return true; + } + + cl_mode = CL_CHECKFILES; } else + { cl_mode = CL_ASKJOIN; // files need not be checked for the server. + *asksent = 0; + } return true; } @@ -2061,6 +2256,22 @@ static boolean CL_ServerConnectionTicker(const char *tmpsave, tic_t *oldtic, tic return false; break; + case CL_ASKFULLFILELIST: + if (cl_lastcheckedfilecount == UINT16_MAX) // All files retrieved + cl_mode = CL_CHECKFILES; + else if (fileneedednum != cl_lastcheckedfilecount || I_GetTime() >= *asksent) + { + if (CL_AskFileList(fileneedednum)) + { + cl_lastcheckedfilecount = fileneedednum; + *asksent = I_GetTime() + NEWTICRATE; + } + } + break; + case CL_CHECKFILES: + if (!CL_FinishedFileList()) + return false; + break; case CL_DOWNLOADFILES: waitmore = false; for (i = 0; i < fileneedednum; i++) @@ -2081,21 +2292,51 @@ static boolean CL_ServerConnectionTicker(const char *tmpsave, tic_t *oldtic, tic } #endif - cl_mode = CL_ASKJOIN; // don't break case continue to cljoin request now - /* FALLTHRU */ - + cl_mode = CL_LOADFILES; + break; + case CL_LOADFILES: + if (CL_LoadServerFiles()) + { + FreeFileNeeded(); + *asksent = 0; //This ensure the first join ask is right away + firstconnectattempttime = I_GetTime(); + cl_mode = CL_ASKJOIN; + } + break; case CL_ASKJOIN: - CL_LoadServerFiles(); + if (firstconnectattempttime + NEWTICRATE*300 < I_GetTime() && !server) + { + CONS_Printf(M_GetText("5 minute wait time exceeded.\n")); + CONS_Printf(M_GetText("Network game synchronization aborted.\n")); + D_QuitNetGame(); + CL_Reset(); + D_StartTitle(); + M_StartMessage(M_GetText( + "5 minute wait time exceeded.\n" + "You may retry connection.\n" + "\n" + "Press ESC\n" + ), NULL, MM_NOTHING); + return false; + } #ifndef NONET // prepare structures to save the file // WARNING: this can be useless in case of server not in GS_LEVEL // but since the network layer doesn't provide ordered packets... CL_PrepareDownloadSaveGame(tmpsave); #endif - if (CL_SendJoin()) + if (I_GetTime() >= *asksent && CL_SendJoin()) + { + *asksent = I_GetTime() + NEWTICRATE*3; cl_mode = CL_WAITJOINRESPONSE; + } + break; + case CL_WAITJOINRESPONSE: + if (I_GetTime() >= *asksent) + { + cl_mode = CL_ASKJOIN; + } break; - #ifndef NONET case CL_DOWNLOADSAVEGAME: // At this state, the first (and only) needed file is the gamestate @@ -2109,8 +2350,8 @@ static boolean CL_ServerConnectionTicker(const char *tmpsave, tic_t *oldtic, tic break; #endif - case CL_WAITJOINRESPONSE: case CL_CONNECTED: + case CL_CONFIRMCONNECT: //logic is handled by M_ConfirmConnect default: break; @@ -2118,7 +2359,6 @@ static boolean CL_ServerConnectionTicker(const char *tmpsave, tic_t *oldtic, tic case CL_ABORTED: cl_mode = CL_SEARCHING; return false; - } GetPackets(); @@ -2128,13 +2368,19 @@ static boolean CL_ServerConnectionTicker(const char *tmpsave, tic_t *oldtic, tic if (*oldtic != I_GetTime()) { I_OsPolling(); - for (; eventtail != eventhead; eventtail = (eventtail+1) & (MAXEVENTS-1)) - G_MapEventsToControls(&events[eventtail]); - if (gamekeydown[KEY_ESCAPE] || gamekeydown[KEY_JOY1+1]) + if (cl_mode == CL_CONFIRMCONNECT) + D_ProcessEvents(); //needed for menu system to receive inputs + else + { + for (; eventtail != eventhead; eventtail = (eventtail+1) & (MAXEVENTS-1)) + G_MapEventsToControls(&events[eventtail]); + } + + if (gamekeydown[KEY_ESCAPE] || gamekeydown[KEY_JOY1+1] || cl_mode == CL_ABORTED) { CONS_Printf(M_GetText("Network game synchronization aborted.\n")); -// M_StartMessage(M_GetText("Network game synchronization aborted.\n\nPress ESC\n"), NULL, MM_NOTHING); + M_StartMessage(M_GetText("Network game synchronization aborted.\n\nPress ESC\n"), NULL, MM_NOTHING); #ifndef NONET if (snake) @@ -2167,13 +2413,20 @@ static boolean CL_ServerConnectionTicker(const char *tmpsave, tic_t *oldtic, tic #ifndef NONET if (client && cl_mode != CL_CONNECTED && cl_mode != CL_ABORTED) { - if (cl_mode != CL_DOWNLOADFILES && cl_mode != CL_DOWNLOADSAVEGAME) + if (!snake) { F_MenuPresTicker(true); // title sky F_TitleScreenTicker(true); F_TitleScreenDrawer(); } CL_DrawConnectionStatus(); +#ifdef HAVE_THREADS + I_lock_mutex(&m_menu_mutex); +#endif + M_Drawer(); //Needed for drawing messageboxes on the connection screen +#ifdef HAVE_THREADS + I_unlock_mutex(m_menu_mutex); +#endif I_UpdateNoVsync(); // page flip or blit buffer if (moviemode) M_SaveFrame(); @@ -2235,8 +2488,10 @@ static void CL_ConnectToServer(void) ClearAdminPlayers(); pnumnodes = 1; oldtic = I_GetTime() - 1; + #ifndef NONET asksent = (tic_t) - TICRATE; + firstconnectattempttime = I_GetTime(); i = SL_SearchServer(servernode); @@ -2676,8 +2931,16 @@ void CL_Reset(void) SV_ResetServer(); // make sure we don't leave any fileneeded gunk over from a failed join + FreeFileNeeded(); fileneedednum = 0; - memset(fileneeded, 0, sizeof(fileneeded)); + +#ifndef NONET + totalfilesrequestednum = 0; + totalfilesrequestedsize = 0; +#endif + firstconnectattempttime = 0; + serverisfull = false; + connectiontimeout = (tic_t)cv_nettimeout.value; //reset this temporary hack // D_StartTitle should get done now, but the calling function will handle it } @@ -3968,31 +4231,40 @@ static void HandlePacketFromAwayNode(SINT8 node) switch (netbuffer->packettype) { case PT_ASKINFOVIAMS: -#if 0 + Net_CloseConnection(node); + break; + + case PT_TELLFILESNEEDED: if (server && serverrunning) { - INT32 clientnode; - if (ms_RoomId < 0) // ignore if we're not actually on the MS right now - { - Net_CloseConnection(node); // and yes, close connection - return; - } - clientnode = I_NetMakeNode(netbuffer->u.msaskinfo.clientaddr); - if (clientnode != -1) - { - SV_SendServerInfo(clientnode, (tic_t)LONG(netbuffer->u.msaskinfo.time)); - SV_SendPlayerInfo(clientnode); // Send extra info - Net_CloseConnection(clientnode); - // Don't close connection to MS... - } - else - Net_CloseConnection(node); // ...unless the IP address is not valid + UINT8 *p; + INT32 firstfile = netbuffer->u.filesneedednum; + + netbuffer->packettype = PT_MOREFILESNEEDED; + netbuffer->u.filesneededcfg.first = firstfile; + netbuffer->u.filesneededcfg.more = 0; + + p = PutFileNeeded(firstfile); + + HSendPacket(node, false, 0, p - ((UINT8 *)&netbuffer->u)); + } + else // Shouldn't get this if you aren't the server...? + Net_CloseConnection(node); + break; + + case PT_MOREFILESNEEDED: + if (server && serverrunning) + { // But wait I thought I'm the server? + Net_CloseConnection(node); + break; + } + SERVERONLY + if (cl_mode == CL_ASKFULLFILELIST && netbuffer->u.filesneededcfg.first == fileneedednum) + { + D_ParseFileneeded(netbuffer->u.filesneededcfg.num, netbuffer->u.filesneededcfg.files, netbuffer->u.filesneededcfg.first); + if (!netbuffer->u.filesneededcfg.more) + cl_lastcheckedfilecount = UINT16_MAX; // Got the whole file list } - else - Net_CloseConnection(node); // you're not supposed to get it, so ignore it -#else - Net_CloseConnection(node); -#endif break; case PT_ASKINFO: @@ -4018,13 +4290,24 @@ static void HandlePacketFromAwayNode(SINT8 node) if (!reason) I_Error("Out of memory!\n"); - D_QuitNetGame(); - CL_Reset(); - D_StartTitle(); + if (strstr(reason, "Maximum players reached")) + { + serverisfull = true; + //Special timeout for when refusing due to player cap. The client will wait 3 seconds between join requests when waiting for a slot, so we need this to be much longer + //We set it back to the value of cv_nettimeout.value in CL_Reset + connectiontimeout = NEWTICRATE*7; + cl_mode = CL_ASKJOIN; + free(reason); + break; + } M_StartMessage(va(M_GetText("Server refuses connection\n\nReason:\n%s"), reason), NULL, MM_NOTHING); + D_QuitNetGame(); + CL_Reset(); + D_StartTitle(); + free(reason); // Will be reset by caller. Signals refusal. diff --git a/src/d_clisrv.h b/src/d_clisrv.h index a89c054e1..8e75fb963 100644 --- a/src/d_clisrv.h +++ b/src/d_clisrv.h @@ -94,6 +94,9 @@ typedef enum PT_LOGIN, // Login attempt from the client. + PT_TELLFILESNEEDED, // Client, to server: "what other files do I need starting from this number?" + PT_MOREFILESNEEDED, // Server, to client: "you need these (+ more on top of those)" + PT_PING, // Packet sent to tell clients the other client's latency to server. NUMPACKETTYPE } packettype_t; @@ -198,6 +201,9 @@ typedef struct char names[MAXSPLITSCREENPLAYERS][MAXPLAYERNAME]; } ATTRPACK clientconfig_pak; +#define SV_DEDICATED 0x40 // server is dedicated +#define SV_LOTSOFADDONS 0x20 // flag used to ask for full file list in d_netfil + enum { REFUSE_JOINS_DISABLED = 1, REFUSE_SLOTS_FULL, @@ -225,7 +231,7 @@ typedef struct char gametypename[24]; UINT8 modifiedgame; UINT8 cheatsenabled; - UINT8 isdedicated; + UINT8 flags; UINT8 fileneedednum; tic_t time; tic_t leveltime; @@ -279,6 +285,14 @@ typedef struct UINT8 ctfteam; } ATTRPACK plrconfig; +typedef struct +{ + INT32 first; + UINT8 num; + UINT8 more; + UINT8 files[MAXFILENEEDED]; // is filled with writexxx (byteptr.h) +} ATTRPACK filesneededconfig_pak; + // // Network packet data // @@ -308,6 +322,8 @@ typedef struct msaskinfo_pak msaskinfo; // 22 bytes plrinfo playerinfo[MAXPLAYERS]; // 576 bytes(?) plrconfig playerconfig[MAXPLAYERS]; // (up to) 528 bytes(?) + INT32 filesneedednum; // 4 bytes + filesneededconfig_pak filesneededcfg; // ??? bytes UINT32 pingtable[MAXPLAYERS+1]; // 68 bytes } u; // This is needed to pack diff packet types data together } ATTRPACK doomdata_t; diff --git a/src/d_main.c b/src/d_main.c index 679a596b3..15f85f2e8 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -65,7 +65,7 @@ #include "m_cond.h" // condition initialization #include "fastcmp.h" #include "keys.h" -#include "filesrch.h" // refreshdirmenu, mainwadstally +#include "filesrch.h" // refreshdirmenu #include "g_input.h" // tutorial mode control scheming #include "m_perfstats.h" @@ -96,11 +96,8 @@ int SUBVERSION; // platform independant focus loss UINT8 window_notinfocus = false; -// -// DEMO LOOP -// -static char *startupwadfiles[MAX_WADFILES]; -static char *startuppwads[MAX_WADFILES]; +static addfilelist_t startupwadfiles; +static addfilelist_t startuppwads; boolean devparm = false; // started game with -devparm @@ -119,6 +116,9 @@ boolean midi_disabled = false; boolean sound_disabled = false; boolean digital_disabled = false; +// +// DEMO LOOP +// boolean advancedemo; #ifdef DEBUGFILE INT32 debugload = 0; @@ -923,51 +923,68 @@ void D_StartTitle(void) tutorialmode = false; } -// -// D_AddFile -// -static void D_AddFile(char **list, const char *file) -{ - size_t pnumwadfiles; - char *newfile; +#define REALLOC_FILE_LIST \ + if (list->files == NULL) \ + { \ + list->files = calloc(sizeof(list->files), 2); \ + list->numfiles = 1; \ + } \ + else \ + { \ + index = list->numfiles; \ + list->files = realloc(list->files, sizeof(list->files) * ((++list->numfiles) + 1)); \ + if (list->files == NULL) \ + I_Error("%s: No more free memory to add file %s", __FUNCTION__, file); \ + } - for (pnumwadfiles = 0; list[pnumwadfiles]; pnumwadfiles++) - ; +static void D_AddFile(addfilelist_t *list, const char *file) +{ + char *newfile; + size_t index = 0; + + REALLOC_FILE_LIST newfile = malloc(strlen(file) + 1); if (!newfile) - I_Error("No more free memory to AddFile %s",file); + I_Error("D_AddFile: No more free memory to add file %s", file); strcpy(newfile, file); - list[pnumwadfiles] = newfile; + list->files[index] = newfile; } -static void D_AddFolder(char **list, const char *file) +static void D_AddFolder(addfilelist_t *list, const char *file) { - size_t pnumwadfiles; char *newfile; + size_t index = 0; - for (pnumwadfiles = 0; list[pnumwadfiles]; pnumwadfiles++) - ; + REALLOC_FILE_LIST newfile = malloc(strlen(file) + 2); // Path delimiter + NULL terminator if (!newfile) - I_Error("No more free memory to AddFolder %s",file); + I_Error("D_AddFolder: No more free memory to add folder %s", file); strcpy(newfile, file); strcat(newfile, PATHSEP); - list[pnumwadfiles] = newfile; + list->files[index] = newfile; } -static inline void D_CleanFile(char **list) +#undef REALLOC_FILE_LIST + +static inline void D_CleanFile(addfilelist_t *list) { - size_t pnumwadfiles; - for (pnumwadfiles = 0; list[pnumwadfiles]; pnumwadfiles++) + if (list->files) { - free(list[pnumwadfiles]); - list[pnumwadfiles] = NULL; + size_t pnumwadfiles = 0; + + for (; pnumwadfiles < list->numfiles; pnumwadfiles++) + free(list->files[pnumwadfiles]); + + free(list->files); + list->files = NULL; } + + list->numfiles = 0; } ///\brief Checks if a netgame URL is being handled, and changes working directory to the EXE's if so. @@ -1051,7 +1068,7 @@ static void IdentifyVersion(void) // Load the IWAD if (srb2wad != NULL && FIL_ReadFileOK(srb2wad)) - D_AddFile(startupwadfiles, srb2wad); + D_AddFile(&startupwadfiles, srb2wad); else I_Error("srb2.pk3 not found! Expected in %s, ss file: %s\n", srb2waddir, srb2wad); @@ -1062,14 +1079,14 @@ static void IdentifyVersion(void) // checking in D_SRB2Main // Add the maps - D_AddFile(startupwadfiles, va(pandf,srb2waddir,"zones.pk3")); + D_AddFile(&startupwadfiles, va(pandf,srb2waddir, "zones.pk3")); // Add the players - D_AddFile(startupwadfiles, va(pandf,srb2waddir, "player.dta")); + D_AddFile(&startupwadfiles, va(pandf,srb2waddir, "player.dta")); #ifdef USE_PATCH_DTA // Add our crappy patches to fix our bugs - D_AddFile(startupwadfiles, va(pandf,srb2waddir,"patch.pk3")); + D_AddFile(&startupwadfiles, va(pandf,srb2waddir, "patch.pk3")); #endif #if !defined (HAVE_SDL) || defined (HAVE_MIXER) @@ -1079,7 +1096,7 @@ static void IdentifyVersion(void) const char *musicpath = va(pandf,srb2waddir,str);\ int ms = W_VerifyNMUSlumps(musicpath, false); \ if (ms == 1) \ - D_AddFile(startupwadfiles, musicpath); \ + D_AddFile(&startupwadfiles, musicpath); \ else if (ms == 0) \ I_Error("File "str" has been modified with non-music/sound lumps"); \ } @@ -1269,9 +1286,9 @@ void D_SRB2Main(void) else if (myargv[i][0] == '-' || myargv[i][0] == '+') addontype = 0; else if (addontype == 1) - D_AddFile(startuppwads, myargv[i]); + D_AddFile(&startuppwads, myargv[i]); else if (addontype == 2) - D_AddFolder(startuppwads, myargv[i]); + D_AddFolder(&startuppwads, myargv[i]); } } @@ -1310,8 +1327,8 @@ void D_SRB2Main(void) // load wad, including the main wad file CONS_Printf("W_InitMultipleFiles(): Adding IWAD and main PWADs.\n"); - W_InitMultipleFiles(startupwadfiles); - D_CleanFile(startupwadfiles); + W_InitMultipleFiles(&startupwadfiles); + D_CleanFile(&startupwadfiles); #ifndef DEVELOP // md5s last updated 22/02/20 (ddmmyy) @@ -1326,8 +1343,6 @@ void D_SRB2Main(void) // ...except it does if they slip maps in there, and that's what W_VerifyNMUSlumps is for. #endif //ifndef DEVELOP - mainwadstally = packetsizetally; // technically not accurate atm, remember to port the two-stage -file process from kart in 2.2.x - cht_Init(); //---------------------------------------------------- READY SCREEN @@ -1360,9 +1375,12 @@ void D_SRB2Main(void) CON_StopRefresh(); // Temporarily stop refreshing the screen for wad loading - CONS_Printf("W_InitMultipleFiles(): Adding extra PWADs.\n"); - W_InitMultipleFiles(startuppwads); - D_CleanFile(startuppwads); + if (startuppwads.numfiles) + { + CONS_Printf("W_InitMultipleFiles(): Adding extra PWADs.\n"); + W_InitMultipleFiles(&startuppwads); + D_CleanFile(&startuppwads); + } CON_StartRefresh(); // Restart the refresh! diff --git a/src/d_net.c b/src/d_net.c index 9e5abe24a..3a4746002 100644 --- a/src/d_net.c +++ b/src/d_net.c @@ -815,6 +815,8 @@ static const char *packettypename[NUMPACKETTYPE] = "CLIENTJOIN", "NODETIMEOUT", "LOGIN", + "TELLFILESNEEDED", + "MOREFILESNEEDED", "PING" }; diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 5eb360bef..7024e64fb 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -3223,7 +3223,7 @@ static void Command_RunSOC(void) static void Got_RunSOCcmd(UINT8 **cp, INT32 playernum) { char filename[256]; - filestatus_t ncs = FS_NOTFOUND; + filestatus_t ncs = FS_NOTCHECKED; if (playernum != serverplayer && !IsPlayerAdmin(playernum)) { @@ -3347,10 +3347,9 @@ static void Command_Addfile(void) break; ++p; - // check total packet size and no of files currently loaded - // See W_InitFile in w_wad.c - if ((numwadfiles >= MAX_WADFILES) - || ((packetsizetally + nameonlylength(fn) + FILENEEDEDSIZE) > MAXFILENEEDED*sizeof(UINT8))) + // check no of files currently loaded + // See W_LoadWadFile in w_wad.c + if (numwadfiles >= MAX_WADFILES) { CONS_Alert(CONS_ERROR, M_GetText("Too many files loaded to add %s\n"), fn); return; @@ -3379,6 +3378,9 @@ static void Command_Addfile(void) for (i = 0; i < numwadfiles; i++) { + if (wadfiles[i]->type == RET_FOLDER) + continue; + if (!memcmp(wadfiles[i]->md5sum, md5sum, 16)) { CONS_Alert(CONS_ERROR, M_GetText("%s is already loaded\n"), fn); @@ -3469,10 +3471,9 @@ static void Command_Addfolder(void) continue; } - // check total packet size and no of files currently loaded - // See W_InitFile in w_wad.c - if ((numwadfiles >= MAX_WADFILES) - || ((packetsizetally + strlen(fn) + FILENEEDEDSIZE) > MAXFILENEEDED*sizeof(UINT8))) + // check no of files currently loaded + // See W_LoadWadFile in w_wad.c + if (numwadfiles >= MAX_WADFILES) { CONS_Alert(CONS_ERROR, M_GetText("Too many files loaded to add %s\n"), fn); return; @@ -3534,7 +3535,7 @@ static void Command_Addfolder(void) static void Got_RequestAddfilecmd(UINT8 **cp, INT32 playernum) { char filename[241]; - filestatus_t ncs = FS_NOTFOUND; + filestatus_t ncs = FS_NOTCHECKED; UINT8 md5sum[16]; boolean kick = false; boolean toomany = false; @@ -3559,9 +3560,7 @@ static void Got_RequestAddfilecmd(UINT8 **cp, INT32 playernum) return; } - // See W_InitFile in w_wad.c - if ((numwadfiles >= MAX_WADFILES) - || ((packetsizetally + nameonlylength(filename) + FILENEEDEDSIZE) > MAXFILENEEDED*sizeof(UINT8))) + if (numwadfiles >= MAX_WADFILES) toomany = true; else ncs = findfile(filename,md5sum,true); @@ -3594,7 +3593,7 @@ static void Got_RequestAddfilecmd(UINT8 **cp, INT32 playernum) static void Got_RequestAddfoldercmd(UINT8 **cp, INT32 playernum) { char path[241]; - filestatus_t ncs = FS_NOTFOUND; + filestatus_t ncs = FS_NOTCHECKED; boolean kick = false; boolean toomany = false; INT32 i,j; @@ -3619,9 +3618,7 @@ static void Got_RequestAddfoldercmd(UINT8 **cp, INT32 playernum) return; } - // See W_InitFile in w_wad.c - if ((numwadfiles >= MAX_WADFILES) - || ((packetsizetally + strlen(path) + FILENEEDEDSIZE) > MAXFILENEEDED*sizeof(UINT8))) + if (numwadfiles >= MAX_WADFILES) toomany = true; else ncs = findfolder(path); @@ -3652,7 +3649,7 @@ static void Got_RequestAddfoldercmd(UINT8 **cp, INT32 playernum) static void Got_Addfilecmd(UINT8 **cp, INT32 playernum) { char filename[241]; - filestatus_t ncs = FS_NOTFOUND; + filestatus_t ncs = FS_NOTCHECKED; UINT8 md5sum[16]; READSTRINGN(*cp, filename, 240); @@ -3700,7 +3697,7 @@ static void Got_Addfilecmd(UINT8 **cp, INT32 playernum) static void Got_Addfoldercmd(UINT8 **cp, INT32 playernum) { char path[241]; - filestatus_t ncs = FS_NOTFOUND; + filestatus_t ncs = FS_NOTCHECKED; READSTRINGN(*cp, path, 240); @@ -3744,7 +3741,13 @@ static void Command_ListWADS_f(void) { INT32 i = numwadfiles; char *tempname; - CONS_Printf(M_GetText("There are %d wads loaded:\n"),numwadfiles); + +#ifdef ENFORCE_WAD_LIMIT + CONS_Printf(M_GetText("There are %d/%d files loaded:\n"),numwadfiles,MAX_WADFILES); +#else + CONS_Printf(M_GetText("There are %d files loaded:\n"),numwadfiles); +#endif + for (i--; i >= 0; i--) { nameonly(tempname = va("%s", wadfiles[i]->filename)); diff --git a/src/d_netcmd.h b/src/d_netcmd.h index cae32643e..efe00552a 100644 --- a/src/d_netcmd.h +++ b/src/d_netcmd.h @@ -73,6 +73,7 @@ extern consvar_t cv_teamscramble; extern consvar_t cv_scrambleonchange; extern consvar_t cv_netstat; +extern consvar_t cv_nettimeout; extern consvar_t cv_countdowntime; extern consvar_t cv_runscripts; diff --git a/src/d_netfil.c b/src/d_netfil.c index 12c5ee6a2..a1dd02eeb 100644 --- a/src/d_netfil.c +++ b/src/d_netfil.c @@ -52,7 +52,7 @@ #include // Prototypes -static boolean AddFileToSendQueue(INT32 node, const char *filename, UINT8 fileid); +static boolean AddFileToSendQueue(INT32 node, UINT8 fileid); // Sender structure typedef struct filetx_s @@ -87,7 +87,7 @@ static filetran_t transfer[MAXNETNODES]; // Receiver structure INT32 fileneedednum; // Number of files needed to join the server -fileneeded_t fileneeded[MAX_WADFILES]; // List of needed files +fileneeded_t *fileneeded; // List of needed files static tic_t lasttimeackpacketsent = 0; char downloaddir[512] = "DOWNLOAD"; @@ -105,6 +105,10 @@ static pauseddownload_t *pauseddownload = NULL; #ifndef NONET // for cl loading screen INT32 lastfilenum = -1; +INT32 downloadcompletednum = 0; +UINT32 downloadcompletedsize = 0; +INT32 totalfilesrequestednum = 0; +UINT32 totalfilesrequestedsize = 0; #endif luafiletransfer_t *luafiletransfers = NULL; @@ -113,25 +117,62 @@ boolean waitingforluafilecommand = false; char luafiledir[256 + 16] = "luafiles"; +static UINT16 GetWadNumFromFileNeededId(UINT8 id) +{ + UINT16 wadnum; + + for (wadnum = mainwads; wadnum < numwadfiles; wadnum++) + { + if (!wadfiles[wadnum]->important) + continue; + if (id == 0) + return wadnum; + id--; + } + + return UINT16_MAX; +} + /** Fills a serverinfo packet with information about wad files loaded. * * \todo Give this function a better name since it is in global scope. * Used to have size limiting built in - now handled via W_InitFile in w_wad.c * */ -UINT8 *PutFileNeeded(void) +UINT8 *PutFileNeeded(UINT16 firstfile) { - size_t i, count = 0; - UINT8 *p = netbuffer->u.serverinfo.fileneeded; + size_t i; + UINT8 count = 0; + UINT8 *p_start = netbuffer->packettype == PT_MOREFILESNEEDED ? netbuffer->u.filesneededcfg.files : netbuffer->u.serverinfo.fileneeded; + UINT8 *p = p_start; char wadfilename[MAX_WADPATH] = ""; UINT8 filestatus, folder; - for (i = 0; i < numwadfiles; i++) + for (i = mainwads; i < numwadfiles; i++) //mainwads, otherwise we start on the first mainwad { // If it has only music/sound lumps, don't put it in the list if (!wadfiles[i]->important) continue; + if (firstfile) + { // Skip files until we reach the first file. + firstfile--; + continue; + } + + nameonly(strcpy(wadfilename, wadfiles[i]->filename)); + + // Look below at the WRITE macros to understand what these numbers mean. + if (p + 1 + 4 + min(strlen(wadfilename) + 1, MAX_WADPATH) + 16 > p_start + MAXFILENEEDED) + { + // Too many files to send all at once + if (netbuffer->packettype == PT_MOREFILESNEEDED) + netbuffer->u.filesneededcfg.more = 1; + else + netbuffer->u.serverinfo.flags |= SV_LOTSOFADDONS; + break; + } + filestatus = 1; // Importance - not really used any more, holds 1 by default for backwards compat with MS folder = (wadfiles[i]->type == RET_FOLDER); @@ -148,32 +189,53 @@ UINT8 *PutFileNeeded(void) count++; WRITEUINT32(p, wadfiles[i]->filesize); - nameonly(strcpy(wadfilename, wadfiles[i]->filename)); WRITESTRINGN(p, wadfilename, MAX_WADPATH); WRITEMEM(p, wadfiles[i]->md5sum, 16); } - netbuffer->u.serverinfo.fileneedednum = (UINT8)count; + + if (netbuffer->packettype == PT_MOREFILESNEEDED) + netbuffer->u.filesneededcfg.num = count; + else + netbuffer->u.serverinfo.fileneedednum = count; return p; } +void AllocFileNeeded(INT32 size) +{ + if (fileneeded == NULL) + fileneeded = Z_Calloc(sizeof(fileneeded_t) * size, PU_STATIC, NULL); + else + fileneeded = Z_Realloc(fileneeded, sizeof(fileneeded_t) * size, PU_STATIC, NULL); +} + +void FreeFileNeeded(void) +{ + Z_Free(fileneeded); + fileneeded = NULL; +} + /** Parses the serverinfo packet and fills the fileneeded table on client * * \param fileneedednum_parm The number of files needed to join the server * \param fileneededstr The memory block containing the list of needed files * */ -void D_ParseFileneeded(INT32 fileneedednum_parm, UINT8 *fileneededstr) +void D_ParseFileneeded(INT32 fileneedednum_parm, UINT8 *fileneededstr, UINT16 firstfile) { INT32 i; UINT8 *p; UINT8 filestatus; - fileneedednum = fileneedednum_parm; + fileneedednum = firstfile + fileneedednum_parm; p = (UINT8 *)fileneededstr; - for (i = 0; i < fileneedednum; i++) + + AllocFileNeeded(fileneedednum); + + for (i = firstfile; i < fileneedednum; i++) { - fileneeded[i].status = FS_NOTFOUND; // We haven't even started looking for the file yet + fileneeded[i].type = FILENEEDED_WAD; + fileneeded[i].status = FS_NOTCHECKED; // We haven't even started looking for the file yet fileneeded[i].justdownloaded = false; filestatus = READUINT8(p); // The first byte is the file status fileneeded[i].folder = READUINT8(p); // The second byte is the folder flag @@ -191,7 +253,11 @@ void CL_PrepareDownloadSaveGame(const char *tmpsave) lastfilenum = -1; #endif + FreeFileNeeded(); + AllocFileNeeded(1); + fileneedednum = 1; + fileneeded[0].type = FILENEEDED_SAVEGAME; fileneeded[0].status = FS_REQUESTED; fileneeded[0].justdownloaded = false; fileneeded[0].totalsize = UINT32_MAX; @@ -322,14 +388,18 @@ boolean CL_SendFileRequest(void) if ((fileneeded[i].status == FS_NOTFOUND || fileneeded[i].status == FS_MD5SUMBAD)) { totalfreespaceneeded += fileneeded[i].totalsize; - nameonly(fileneeded[i].filename); + WRITEUINT8(p, i); // fileid - WRITESTRINGN(p, fileneeded[i].filename, MAX_WADPATH); + // put it in download dir + nameonly(fileneeded[i].filename); strcatbf(fileneeded[i].filename, downloaddir, "/"); + fileneeded[i].status = FS_REQUESTED; } + WRITEUINT8(p, 0xFF); + I_GetDiskFreeSpace(&availablefreespace); if (totalfreespaceneeded > availablefreespace) I_Error("To play on this server you must download %s KB,\n" @@ -345,21 +415,22 @@ boolean CL_SendFileRequest(void) // returns false if a requested file was not found or cannot be sent boolean PT_RequestFile(INT32 node) { - char wad[MAX_WADPATH+1]; UINT8 *p = netbuffer->u.textcmd; UINT8 id; + while (p < netbuffer->u.textcmd + MAXTEXTCMD-1) // Don't allow hacked client to overflow { id = READUINT8(p); if (id == 0xFF) break; - READSTRINGN(p, wad, MAX_WADPATH); - if (!AddFileToSendQueue(node, wad, id)) + + if (!AddFileToSendQueue(node, id)) { SV_AbortSendFiles(node); return false; // don't read the rest of the files } } + return true; // no problems with any files } @@ -368,23 +439,16 @@ boolean PT_RequestFile(INT32 node) * \return 0 if some files are missing * 1 if all files exist * 2 if some already loaded files are not requested or are in a different order + * 3 too many files, over WADLIMIT + * 4 still checking, continuing next tic * */ INT32 CL_CheckFiles(void) { INT32 i, j; char wadfilename[MAX_WADPATH]; - INT32 ret = 1; - size_t packetsize = 0; - size_t filestoget = 0; - -// if (M_CheckParm("-nofiles")) -// return 1; - - // the first is the iwad (the main wad file) - // we don't care if it's called srb2.pk3 or not. - // Never download the IWAD, just assume it's there and identical - fileneeded[0].status = FS_OPEN; + size_t filestoload = 0; + boolean downloadrequired = false; // Modified game handling -- check for an identical file list // must be identical in files loaded AND in order @@ -392,7 +456,7 @@ INT32 CL_CheckFiles(void) if (modifiedgame) { CONS_Debug(DBG_NETPLAY, "game is modified; only doing basic checks\n"); - for (i = 1, j = 1; i < fileneedednum || j < numwadfiles;) + for (i = 0, j = mainwads; i < fileneedednum || j < numwadfiles;) { if (j < numwadfiles && !wadfiles[j]->important) { @@ -419,15 +483,21 @@ INT32 CL_CheckFiles(void) return 1; } - // See W_InitFile in w_wad.c - packetsize = packetsizetally; - - for (i = 1; i < fileneedednum; i++) + for (i = 0; i < fileneedednum; i++) { + if (fileneeded[i].status == FS_NOTFOUND || fileneeded[i].status == FS_MD5SUMBAD) + downloadrequired = true; + + 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 + continue; + CONS_Debug(DBG_NETPLAY, "searching for '%s' ", fileneeded[i].filename); // Check in already loaded files - for (j = 1; wadfiles[j]; j++) + for (j = mainwads; wadfiles[j]; j++) { nameonly(strcpy(wadfilename, wadfiles[j]->filename)); if (!stricmp(wadfilename, fileneeded[i].filename) && @@ -435,43 +505,34 @@ INT32 CL_CheckFiles(void) { CONS_Debug(DBG_NETPLAY, "already loaded\n"); fileneeded[i].status = FS_OPEN; - break; + return 4; } } - if (fileneeded[i].status != FS_NOTFOUND) - continue; - - if (fileneeded[i].folder) - packetsize += strlen(fileneeded[i].filename) + FILENEEDEDSIZE; - else - packetsize += nameonlylength(fileneeded[i].filename) + FILENEEDEDSIZE; - - if ((numwadfiles+filestoget >= MAX_WADFILES) - || (packetsize > MAXFILENEEDED*sizeof(UINT8))) - return 3; - - filestoget++; if (fileneeded[i].folder) fileneeded[i].status = findfolder(fileneeded[i].filename); else fileneeded[i].status = findfile(fileneeded[i].filename, fileneeded[i].md5sum, true); + CONS_Debug(DBG_NETPLAY, "found %d\n", fileneeded[i].status); - if (fileneeded[i].status != FS_FOUND) - ret = 0; + return 4; } - return ret; + + //now making it here means we've checked the entire list and no FS_NOTCHECKED files remain + if (numwadfiles+filestoload > MAX_WADFILES) + return 3; + else if (downloadrequired) + return 0; //some stuff is FS_NOTFOUND, needs download + else + return 1; //everything is FS_OPEN or FS_FOUND, proceed to loading } // Load it now -void CL_LoadServerFiles(void) +boolean CL_LoadServerFiles(void) { INT32 i; -// if (M_CheckParm("-nofiles")) -// return; - - for (i = 1; i < fileneedednum; i++) + for (i = 0; i < fileneedednum; i++) { if (fileneeded[i].status == FS_OPEN) continue; // Already loaded @@ -483,6 +544,7 @@ void CL_LoadServerFiles(void) P_AddWadFile(fileneeded[i].filename); G_SetGameModified(true); fileneeded[i].status = FS_OPEN; + return false; } else if (fileneeded[i].status == FS_MD5SUMBAD) I_Error("Wrong version of file %s", fileneeded[i].filename); @@ -508,6 +570,7 @@ void CL_LoadServerFiles(void) fileneeded[i].status, s); } } + return true; } void AddLuaFileTransfer(const char *filename, const char *mode) @@ -689,7 +752,11 @@ void CL_PrepareDownloadLuaFile(void) netbuffer->packettype = PT_ASKLUAFILE; HSendPacket(servernode, true, 0, 0); + FreeFileNeeded(); + AllocFileNeeded(1); + fileneedednum = 1; + fileneeded[0].type = FILENEEDED_LUAFILE; fileneeded[0].status = FS_REQUESTED; fileneeded[0].justdownloaded = false; fileneeded[0].totalsize = UINT32_MAX; @@ -716,15 +783,11 @@ static INT32 filestosend = 0; * \sa AddLuaFileToSendQueue * */ -static boolean AddFileToSendQueue(INT32 node, const char *filename, UINT8 fileid) +static boolean AddFileToSendQueue(INT32 node, UINT8 fileid) { filetx_t **q; // A pointer to the "next" field of the last file in the list filetx_t *p; // The new file request - INT32 i; - char wadfilename[MAX_WADPATH]; - - if (cv_noticedownload.value) - CONS_Printf("Sending file \"%s\" to node %d (%s)\n", filename, node, I_GetNodeAddress(node)); + UINT16 wadnum; // Find the last file in the list and set a pointer to its "next" field q = &transfer[node].txlist; @@ -744,51 +807,43 @@ static boolean AddFileToSendQueue(INT32 node, const char *filename, UINT8 fileid if (!p->id.filename) I_Error("AddFileToSendQueue: No more memory\n"); - // Set the file name and get rid of the path - strlcpy(p->id.filename, filename, MAX_WADPATH); - nameonly(p->id.filename); - - // Look for the requested file through all loaded files - for (i = 0; wadfiles[i]; i++) - { - strlcpy(wadfilename, wadfiles[i]->filename, MAX_WADPATH); - nameonly(wadfilename); - if (!stricmp(wadfilename, p->id.filename)) - { - // Copy file name with full path - strlcpy(p->id.filename, wadfiles[i]->filename, MAX_WADPATH); - break; - } - } + // Find the wad the ID refers to + wadnum = GetWadNumFromFileNeededId(fileid); // Handle non-loaded file requests - if (!wadfiles[i]) + if (wadnum == UINT16_MAX) { - DEBFILE(va("%s not found in wadfiles\n", filename)); + DEBFILE(va("fileneeded %d not found in wadfiles\n", fileid)); // This formerly checked if (!findfile(p->id.filename, NULL, true)) // Not found // Don't inform client - DEBFILE(va("Client %d request %s: not found\n", node, filename)); + DEBFILE(va("Client %d request fileneeded %d: not found\n", node, fileid)); free(p->id.filename); free(p); *q = NULL; return false; // cancel the rest of the requests } + // Set the file name and get rid of the path + strlcpy(p->id.filename, wadfiles[wadnum]->filename, MAX_WADPATH); + // Handle huge file requests (i.e. bigger than cv_maxsend.value KB) - if (wadfiles[i]->filesize > (UINT32)cv_maxsend.value * 1024) + if (wadfiles[wadnum]->filesize > (UINT32)cv_maxsend.value * 1024) { // Too big // Don't inform client (client sucks, man) - DEBFILE(va("Client %d request %s: file too big, not sending\n", node, filename)); + DEBFILE(va("Client %d request %s: file too big, not sending\n", node, p->id.filename)); free(p->id.filename); free(p); *q = NULL; return false; // cancel the rest of the requests } - DEBFILE(va("Sending file %s (id=%d) to %d\n", filename, fileid, node)); + if (cv_noticedownload.value) + CONS_Printf("Sending file \"%s\" to node %d (%s)\n", p->id.filename, node, I_GetNodeAddress(node)); + + DEBFILE(va("Sending file %s (id=%d) to %d\n", p->id.filename, fileid, node)); p->ram = SF_FILE; // It's a file, we need to close it and free its name once we're done sending it p->fileid = fileid; p->next = NULL; // End of list @@ -1242,6 +1297,9 @@ void PT_FileFragment(void) UINT16 boundedfragmentsize = doomcom->datalength - BASEPACKETSIZE - sizeof(netbuffer->u.filetxpak); char *filename; + if (!file) + return; + filename = va("%s", file->filename); nameonly(filename); @@ -1353,6 +1411,7 @@ void PT_FileFragment(void) // Tell the server we have received the file netbuffer->packettype = PT_HASLUAFILE; HSendPacket(servernode, true, 0, 0); + FreeFileNeeded(); } } } @@ -1423,32 +1482,37 @@ void CloseNetFile(void) SV_AbortSendFiles(i); // Receiving a file? - for (i = 0; i < MAX_WADFILES; i++) - if (fileneeded[i].status == FS_DOWNLOADING && fileneeded[i].file) - { - fclose(fileneeded[i].file); - free(fileneeded[i].ackpacket); - - if (!pauseddownload && i != 0) // 0 is either srb2.srb or the gamestate... + if (fileneeded) + { + for (i = 0; i < fileneedednum; i++) + if (fileneeded[i].status == FS_DOWNLOADING && fileneeded[i].file) { - // Don't remove the file, save it for later in case we resume the download - pauseddownload = malloc(sizeof(*pauseddownload)); - if (!pauseddownload) - I_Error("CloseNetFile: No more memory\n"); + fclose(fileneeded[i].file); + free(fileneeded[i].ackpacket); - strcpy(pauseddownload->filename, fileneeded[i].filename); - memcpy(pauseddownload->md5sum, fileneeded[i].md5sum, 16); - pauseddownload->currentsize = fileneeded[i].currentsize; - pauseddownload->receivedfragments = fileneeded[i].receivedfragments; - pauseddownload->fragmentsize = fileneeded[i].fragmentsize; + if (!pauseddownload && (fileneeded[i].type == FILENEEDED_WAD || i != 0)) // 0 is the gamestate... + { + // Don't remove the file, save it for later in case we resume the download + pauseddownload = malloc(sizeof(*pauseddownload)); + if (!pauseddownload) + I_Error("CloseNetFile: No more memory\n"); + + strcpy(pauseddownload->filename, fileneeded[i].filename); + memcpy(pauseddownload->md5sum, fileneeded[i].md5sum, 16); + pauseddownload->currentsize = fileneeded[i].currentsize; + pauseddownload->receivedfragments = fileneeded[i].receivedfragments; + pauseddownload->fragmentsize = fileneeded[i].fragmentsize; + } + else + { + // File is not complete, delete it. + free(fileneeded[i].receivedfragments); + remove(fileneeded[i].filename); + } } - else - { - free(fileneeded[i].receivedfragments); - // File is not complete delete it - remove(fileneeded[i].filename); - } - } + } + + FreeFileNeeded(); } void Command_Downloads_f(void) diff --git a/src/d_netfil.h b/src/d_netfil.h index 70b721bf7..3d713c150 100644 --- a/src/d_netfil.h +++ b/src/d_netfil.h @@ -27,6 +27,7 @@ typedef enum typedef enum { + FS_NOTCHECKED, FS_NOTFOUND, FS_FOUND, FS_REQUESTED, @@ -35,13 +36,21 @@ typedef enum FS_MD5SUMBAD } filestatus_t; +typedef enum +{ + FILENEEDED_WAD, + FILENEEDED_SAVEGAME, + FILENEEDED_LUAFILE +} fileneededtype_t; + typedef struct { - UINT8 willsend; // Is the server willing to send it? - UINT8 folder; // File is a folder char filename[MAX_WADPATH]; UINT8 md5sum[16]; filestatus_t status; // The value returned by recsearch + UINT8 willsend; // Is the server willing to send it? + UINT8 folder; // File is a folder + fileneededtype_t type; boolean justdownloaded; // To prevent late fragments from causing an I_Error // Used only for download @@ -58,19 +67,25 @@ typedef struct #define FILENEEDEDSIZE 23 extern INT32 fileneedednum; -extern fileneeded_t fileneeded[MAX_WADFILES]; +extern fileneeded_t *fileneeded; extern char downloaddir[512]; #ifndef NONET extern INT32 lastfilenum; +extern INT32 downloadcompletednum; +extern UINT32 downloadcompletedsize; +extern INT32 totalfilesrequestednum; +extern UINT32 totalfilesrequestedsize; #endif -UINT8 *PutFileNeeded(void); -void D_ParseFileneeded(INT32 fileneedednum_parm, UINT8 *fileneededstr); +void AllocFileNeeded(INT32 size); +void FreeFileNeeded(void); +UINT8 *PutFileNeeded(UINT16 firstfile); +void D_ParseFileneeded(INT32 fileneedednum_parm, UINT8 *fileneededstr, UINT16 firstfile); void CL_PrepareDownloadSaveGame(const char *tmpsave); INT32 CL_CheckFiles(void); -void CL_LoadServerFiles(void); +boolean CL_LoadServerFiles(void); void AddRamToSendQueue(INT32 node, void *data, size_t size, freemethod_t freemethod, UINT8 fileid); diff --git a/src/doomdef.h b/src/doomdef.h index 37edca896..7e7e35599 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -152,6 +152,9 @@ extern char logfilename[1024]; // Comment or uncomment this as necessary. #define USE_PATCH_DTA +// Enforce a limit of loaded WAD files. +//#define ENFORCE_WAD_LIMIT + // Use .kart extension addons //#define USE_KART diff --git a/src/filesrch.c b/src/filesrch.c index b4039e526..ec095518e 100644 --- a/src/filesrch.c +++ b/src/filesrch.c @@ -338,9 +338,6 @@ size_t dir_on[menudepth]; UINT8 refreshdirmenu = 0; char *refreshdirname = NULL; -size_t packetsizetally = 0; -size_t mainwadstally = 0; - #define dirpathlen 1024 #define maxdirdepth 48 @@ -830,7 +827,7 @@ char exttable[NUM_EXT_TABLE][7] = { // maximum extension length (currently 4) pl #endif "\5.pk3", "\5.soc", "\5.lua"}; // addfile -char filenamebuf[MAX_WADFILES][MAX_WADPATH]; +static char (*filenamebuf)[MAX_WADPATH]; static boolean filemenucmp(char *haystack, char *needle) { @@ -1102,6 +1099,10 @@ boolean preparefilemenu(boolean samedepth) if (ext >= EXT_LOADSTART) { size_t i; + + if (filenamebuf == NULL) + filenamebuf = calloc(sizeof(char) * MAX_WADPATH, numwadfiles); + for (i = 0; i < numwadfiles; i++) { if (!filenamebuf[i][0]) @@ -1151,6 +1152,12 @@ boolean preparefilemenu(boolean samedepth) } } + if (filenamebuf) + { + free(filenamebuf); + filenamebuf = NULL; + } + closedir(dirhandle); if ((menudepthleft != menudepth-1) // now for UP... entry diff --git a/src/filesrch.h b/src/filesrch.h index 9d5f31bbb..59ef5269b 100644 --- a/src/filesrch.h +++ b/src/filesrch.h @@ -53,9 +53,6 @@ extern size_t dir_on[menudepth]; extern UINT8 refreshdirmenu; extern char *refreshdirname; -extern size_t packetsizetally; -extern size_t mainwadstally; - typedef enum { EXT_FOLDER = 0, diff --git a/src/m_menu.c b/src/m_menu.c index 7a82fd8fb..d5fa5e95b 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -3215,7 +3215,7 @@ boolean M_Responder(event_t *ev) if (gamestate == GS_TITLESCREEN && finalecount < TICRATE) return false; - if (CON_Ready()) + if (CON_Ready() && gamestate != GS_WAITINGPLAYERS) return false; if (noFurtherInput) @@ -6410,6 +6410,7 @@ static void M_Addons(INT32 choice) M_SetupNextMenu(&MISC_AddonsDef); } +#ifdef ENFORCE_WAD_LIMIT #define width 4 #define vpadding 27 #define h (BASEVIDHEIGHT-(2*vpadding)) @@ -6457,6 +6458,7 @@ static void M_DrawTemperature(INT32 x, fixed_t t) #undef vpadding #undef h #undef NUMCOLOURS +#endif static char *M_AddonsHeaderPath(void) { @@ -6550,21 +6552,20 @@ static void M_DrawAddons(void) V_DrawCenteredString(BASEVIDWIDTH/2, 5, 0, LOCATIONSTRING1); // (recommendedflags == V_SKYMAP ? LOCATIONSTRING2 : LOCATIONSTRING1) +#ifdef ENFORCE_WAD_LIMIT if (numwadfiles <= mainwads+1) y = 0; else if (numwadfiles >= MAX_WADFILES) y = FRACUNIT; else { - x = FixedDiv(((ssize_t)(numwadfiles) - (ssize_t)(mainwads+1))< y) - y = x; + y = FixedDiv(((ssize_t)(numwadfiles) - (ssize_t)(mainwads+1))< FRACUNIT) // happens because of how we're shrinkin' it a little y = FRACUNIT; } M_DrawTemperature(BASEVIDWIDTH - 19 - 5, y); +#endif // DRAW MENU x = currentMenu->x; diff --git a/src/w_wad.c b/src/w_wad.c index 3ff301117..e49e0ce82 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -105,7 +105,7 @@ static UINT16 lumpnumcacheindex = 0; // GLOBALS //=========================================================================== UINT16 numwadfiles; // number of active wadfiles -wadfile_t *wadfiles[MAX_WADFILES]; // 0 to numwadfiles-1 are valid +wadfile_t **wadfiles; // 0 to numwadfiles-1 are valid // W_Shutdown // Closes all of the WAD files before quitting @@ -134,6 +134,8 @@ void W_Shutdown(void) Z_Free(wad->lumpinfo); Z_Free(wad); } + + Z_Free(wadfiles); } //=========================================================================== @@ -844,7 +846,6 @@ UINT16 W_InitFile(const char *filename, boolean mainfile, boolean startup) #ifndef NOMD5 size_t i; #endif - size_t packetsize; UINT8 md5sum[16]; int important; @@ -862,9 +863,8 @@ UINT16 W_InitFile(const char *filename, boolean mainfile, boolean startup) refreshdirname = NULL; //CONS_Debug(DBG_SETUP, "Loading %s\n", filename); - // - // check if limit of active wadfiles - // + + // Check if the game reached the limit of active wadfiles. if (numwadfiles >= MAX_WADFILES) { CONS_Alert(CONS_ERROR, M_GetText("Maximum wad files reached\n")); @@ -884,24 +884,7 @@ UINT16 W_InitFile(const char *filename, boolean mainfile, boolean startup) return INT16_MAX; } - // Check if wad files will overflow fileneededbuffer. Only the filename part - // is send in the packet; cf. - // see PutFileNeeded in d_netfil.c - if ((important = !important)) - { - packetsize = packetsizetally + nameonlylength(filename) + FILENEEDEDSIZE; - - if (packetsize > MAXFILENEEDED*sizeof(UINT8)) - { - CONS_Alert(CONS_ERROR, M_GetText("Maximum wad files reached\n")); - refreshdirmenu |= REFRESHDIR_MAX; - if (handle) - fclose(handle); - return W_InitFileError(filename, startup); - } - - packetsizetally = packetsize; - } + important = !important; #ifndef NOMD5 // @@ -913,11 +896,12 @@ UINT16 W_InitFile(const char *filename, boolean mainfile, boolean startup) for (i = 0; i < numwadfiles; i++) { + if (wadfiles[i]->type == RET_FOLDER) + continue; + if (!memcmp(wadfiles[i]->md5sum, md5sum, 16)) { CONS_Alert(CONS_ERROR, M_GetText("%s is already loaded\n"), filename); - if (important) - packetsizetally -= nameonlylength(filename) + FILENEEDEDSIZE; if (handle) fclose(handle); return W_InitFileError(filename, false); @@ -984,6 +968,7 @@ UINT16 W_InitFile(const char *filename, boolean mainfile, boolean startup) // add the wadfile // CONS_Printf(M_GetText("Added file %s (%u lumps)\n"), filename, numlumps); + wadfiles = Z_Realloc(wadfiles, sizeof(wadfile_t) * (numwadfiles + 1), PU_STATIC, NULL); wadfiles[numwadfiles] = wadfile; numwadfiles++; // must come BEFORE W_LoadDehackedLumps, so any addfile called by COM_BufInsertText called by Lua doesn't overwrite what we just loaded @@ -1046,22 +1031,7 @@ UINT16 W_InitFolder(const char *path, boolean mainfile, boolean startup) return W_InitFileError(path, startup); } - important = 0; // ??? - - /// \todo Implement a W_VerifyFolder. - if ((important = !important)) - { - size_t packetsize = packetsizetally + strlen(path) + FILENEEDEDSIZE; - - if (packetsize > MAXFILENEEDED*sizeof(UINT8)) - { - CONS_Alert(CONS_ERROR, M_GetText("Maximum wad files reached\n")); - refreshdirmenu |= REFRESHDIR_MAX; - return W_InitFileError(path, startup); - } - - packetsizetally = packetsize; - } + important = 0; /// \todo Implement a W_VerifyFolder. // Remove path delimiters. p = path + (strlen(path) - 1); @@ -1132,8 +1102,6 @@ UINT16 W_InitFolder(const char *path, boolean mainfile, boolean startup) if (samepaths(wadfiles[i]->path, fullpath) > 0) { CONS_Alert(CONS_ERROR, M_GetText("%s is already loaded\n"), path); - if (important) - packetsizetally -= strlen(path) + FILENEEDEDSIZE; Z_Free(fn); Z_Free(fullpath); return W_InitFileError(path, false); @@ -1197,11 +1165,13 @@ UINT16 W_InitFolder(const char *path, boolean mainfile, boolean startup) * * \param filenames A null-terminated list of files to use. */ -void W_InitMultipleFiles(char **filenames) +void W_InitMultipleFiles(addfilelist_t *list) { - for (; *filenames; filenames++) + size_t i = 0; + + for (; i < list->numfiles; i++) { - const char *fn = (*filenames); + const char *fn = list->files[i]; char pathsep = fn[strlen(fn) - 1]; boolean mainfile = (numwadfiles < mainwads); @@ -1219,7 +1189,7 @@ void W_InitMultipleFiles(char **filenames) */ static boolean TestValidLump(UINT16 wad, UINT16 lump) { - I_Assert(wad < MAX_WADFILES); + I_Assert(wad < numwadfiles); if (!wadfiles[wad]) // make sure the wad file exists return false; @@ -1636,7 +1606,7 @@ size_t W_LumpLength(lumpnum_t lumpnum) // // W_IsLumpWad -// Is the lump a WAD? (presumably in a PK3) +// Is the lump a WAD? (presumably not in a WAD) // boolean W_IsLumpWad(lumpnum_t lumpnum) { @@ -1649,12 +1619,12 @@ boolean W_IsLumpWad(lumpnum_t lumpnum) return !strnicmp(lumpfullName + strlen(lumpfullName) - 4, ".wad", 4); } - return false; // WADs should never be inside non-PK3s as far as SRB2 is concerned + return false; // WADs should never be inside WADs as far as SRB2 is concerned } // // W_IsLumpFolder -// Is the lump a folder? (in a PK3 obviously) +// Is the lump a folder? (not in a WAD obviously) // boolean W_IsLumpFolder(UINT16 wad, UINT16 lump) { @@ -1665,7 +1635,7 @@ boolean W_IsLumpFolder(UINT16 wad, UINT16 lump) return (name[strlen(name)-1] == '/'); // folders end in '/' } - return false; // non-PK3s don't have folders + return false; // WADs don't have folders } #ifdef HAVE_ZLIB @@ -2217,7 +2187,7 @@ void W_VerifyFileMD5(UINT16 wadfilenum, const char *matchmd5) #else I_Error #endif - (M_GetText("File is old, is corrupt or has been modified: %s (found md5: %s, wanted: %s)\n"), wadfiles[wadfilenum]->filename, actualmd5text, matchmd5); + (M_GetText("File is old, is corrupt or has been modified:\n%s\nFound MD5: %s\nWanted MD5: %s\n"), wadfiles[wadfilenum]->filename, actualmd5text, matchmd5); } #endif } diff --git a/src/w_wad.h b/src/w_wad.h index 949bab9fe..a41ba1724 100644 --- a/src/w_wad.h +++ b/src/w_wad.h @@ -97,9 +97,15 @@ virtlump_t* vres_Find(const virtres_t*, const char*); // DYNAMIC WAD LOADING // ========================================================================= +// Maximum of files that can be loaded +// (there is a max of simultaneous open files anyway) +#ifdef ENFORCE_WAD_LIMIT +#define MAX_WADFILES 2048 // This cannot be any higher than UINT16_MAX. +#else +#define MAX_WADFILES UINT16_MAX +#endif + #define MAX_WADPATH 512 -#define MAX_WADFILES 48 // maximum of wad files used at the same time -// (there is a max of simultaneous open files anyway, and this should be plenty) #define lumpcache_t void * @@ -134,7 +140,13 @@ typedef struct wadfile_s #define LUMPNUM(lumpnum) (UINT16)((lumpnum)&0xFFFF) // lump number for this pwad extern UINT16 numwadfiles; -extern wadfile_t *wadfiles[MAX_WADFILES]; +extern wadfile_t **wadfiles; + +typedef struct +{ + char **files; + size_t numfiles; +} addfilelist_t; // ========================================================================= @@ -148,7 +160,7 @@ UINT16 W_InitFile(const char *filename, boolean mainfile, boolean startup); UINT16 W_InitFolder(const char *path, boolean mainfile, boolean startup); // W_InitMultipleFiles exits if a file was not found, but not if all is okay. -void W_InitMultipleFiles(char **filenames); +void W_InitMultipleFiles(addfilelist_t *list); #define W_FileHasFolders(wadfile) ((wadfile)->type == RET_PK3 || (wadfile)->type == RET_FOLDER) From 86edb1e4caf4798d612ae373a50b0309ca6737da Mon Sep 17 00:00:00 2001 From: Radicalicious Date: Fri, 3 Dec 2021 23:20:07 -0600 Subject: [PATCH 0964/1080] Fix player disappearing when drowning in painstate --- 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 f21118a81..ee76d29a8 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -12206,7 +12206,7 @@ void P_PlayerThink(player_t *player) player->losstime--; // Flash player after being hit. - if (player->powers[pw_flashing] > 0 && player->powers[pw_flashing] < flashingtics && (leveltime & 1)) + if (player->powers[pw_flashing] > 0 && player->powers[pw_flashing] < flashingtics && (leveltime & 1) && player->playerstate == PST_LIVE) player->mo->flags2 |= MF2_DONTDRAW; else player->mo->flags2 &= ~MF2_DONTDRAW; From 3802f601a9b9a459f556b35776c6ce3dbae1f7a2 Mon Sep 17 00:00:00 2001 From: sphere Date: Mon, 15 Nov 2021 18:03:07 +0100 Subject: [PATCH 0965/1080] blentran part 1: Flag changes & semibright support. --- src/deh_tables.c | 25 ++++++++++++++++------ src/hardware/hw_draw.c | 44 +++++++++------------------------------ src/hardware/hw_main.c | 6 ++++++ src/hu_stuff.c | 22 ++++++++++++-------- src/m_menu.c | 10 ++++----- src/p_pspr.h | 47 ++++++++++++++++++++++++++++++------------ src/r_data.h | 3 --- src/r_defs.h | 23 +++++++++++++-------- src/r_things.c | 22 ++++++++++++++++---- src/r_things.h | 16 +++++++------- src/v_video.c | 29 ++++++++------------------ src/v_video.h | 22 +++++++++++++------- 12 files changed, 151 insertions(+), 118 deletions(-) diff --git a/src/deh_tables.c b/src/deh_tables.c index f30f7c14d..146a04f7f 100644 --- a/src/deh_tables.c +++ b/src/deh_tables.c @@ -4843,9 +4843,18 @@ struct int_const_s const INT_CONST[] = { {"FF_RANDOMANIM",FF_RANDOMANIM}, {"FF_GLOBALANIM",FF_GLOBALANIM}, {"FF_FULLBRIGHT",FF_FULLBRIGHT}, + {"FF_SEMIBRIGHT",FF_SEMIBRIGHT}, + {"FF_FULLDARK",FF_FULLDARK}, {"FF_VERTICALFLIP",FF_VERTICALFLIP}, {"FF_HORIZONTALFLIP",FF_HORIZONTALFLIP}, {"FF_PAPERSPRITE",FF_PAPERSPRITE}, + {"FF_FLOORSPRITE",FF_FLOORSPRITE}, + {"FF_BLENDMASK",FF_BLENDMASK}, + {"FF_BLENDSHIFT",FF_BLENDSHIFT}, + {"FF_ADD",FF_ADD}, + {"FF_SUBTRACT",FF_SUBTRACT}, + {"FF_REVERSESUBTRACT",FF_REVERSESUBTRACT}, + {"FF_MODULATE",FF_MODULATE}, {"FF_TRANSMASK",FF_TRANSMASK}, {"FF_TRANSSHIFT",FF_TRANSSHIFT}, // new preshifted translucency (used in source) @@ -4900,9 +4909,10 @@ struct int_const_s const INT_CONST[] = { {"RF_OBJECTSLOPESPLAT",RF_OBJECTSLOPESPLAT}, {"RF_NOSPLATBILLBOARD",RF_NOSPLATBILLBOARD}, {"RF_NOSPLATROLLANGLE",RF_NOSPLATROLLANGLE}, - {"RF_BLENDMASK",RF_BLENDMASK}, + {"RF_BRIGHTMASK",RF_BRIGHTMASK}, {"RF_FULLBRIGHT",RF_FULLBRIGHT}, {"RF_FULLDARK",RF_FULLDARK}, + {"RF_SEMIBRIGHT",RF_SEMIBRIGHT}, {"RF_NOCOLORMAPS",RF_NOCOLORMAPS}, {"RF_SPRITETYPEMASK",RF_SPRITETYPEMASK}, {"RF_PAPERSPRITE",RF_PAPERSPRITE}, @@ -5391,9 +5401,12 @@ struct int_const_s const INT_CONST[] = { {"V_HUDTRANSHALF",V_HUDTRANSHALF}, {"V_HUDTRANS",V_HUDTRANS}, {"V_HUDTRANSDOUBLE",V_HUDTRANSDOUBLE}, - {"V_AUTOFADEOUT",V_AUTOFADEOUT}, - {"V_RETURN8",V_RETURN8}, - {"V_OFFSET",V_OFFSET}, + {"V_BLENDSHIFT",V_BLENDSHIFT}, + {"V_BLENDMASK",V_BLENDMASK}, + {"V_ADD",V_ADD}, + {"V_SUBTRACT",V_SUBTRACT}, + {"V_REVERSESUBTRACT",V_REVERSESUBTRACT}, + {"V_MODULATE",V_MODULATE}, {"V_ALLOWLOWERCASE",V_ALLOWLOWERCASE}, {"V_FLIP",V_FLIP}, {"V_CENTERNAMETAG",V_CENTERNAMETAG}, @@ -5401,8 +5414,8 @@ struct int_const_s const INT_CONST[] = { {"V_SNAPTOBOTTOM",V_SNAPTOBOTTOM}, {"V_SNAPTOLEFT",V_SNAPTOLEFT}, {"V_SNAPTORIGHT",V_SNAPTORIGHT}, - {"V_WRAPX",V_WRAPX}, - {"V_WRAPY",V_WRAPY}, + {"V_AUTOFADEOUT",V_AUTOFADEOUT}, + {"V_RETURN8",V_RETURN8}, {"V_NOSCALESTART",V_NOSCALESTART}, {"V_PERPLAYER",V_PERPLAYER}, diff --git a/src/hardware/hw_draw.c b/src/hardware/hw_draw.c index 8223705bd..89d43a6b4 100644 --- a/src/hardware/hw_draw.c +++ b/src/hardware/hw_draw.c @@ -119,11 +119,6 @@ void HWR_DrawPatch(patch_t *gpatch, INT32 x, INT32 y, INT32 option) flags = PF_Translucent|PF_NoDepthTest; - if (option & V_WRAPX) - flags |= PF_ForceWrapX; - if (option & V_WRAPY) - flags |= PF_ForceWrapY; - // clip it since it is used for bunny scroll in doom I HWD.pfnDrawPolygon(NULL, v, 4, flags); } @@ -145,9 +140,6 @@ void HWR_DrawStretchyFixedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t p UINT8 perplayershuffle = 0; - if (alphalevel >= 10 && alphalevel < 13) - return; - // make patch ready in hardware cache if (!colormap) HWR_GetPatch(gpatch); @@ -191,15 +183,9 @@ void HWR_DrawStretchyFixedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t p offsetx = (float)(gpatch->leftoffset) * fscalew; // top offset - // TODO: make some kind of vertical version of V_FLIP, maybe by deprecating V_OFFSET in future?!? + // TODO: make some kind of vertical version of V_FLIP offsety = (float)(gpatch->topoffset) * fscaleh; - if ((option & (V_NOSCALESTART|V_OFFSET)) == (V_NOSCALESTART|V_OFFSET)) // Multiply by dupx/dupy for crosshairs - { - offsetx *= dupx; - offsety *= dupy; - } - cx -= offsetx; cy -= offsety; } @@ -361,19 +347,15 @@ void HWR_DrawStretchyFixedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t p flags = PF_Translucent|PF_NoDepthTest; - if (option & V_WRAPX) - flags |= PF_ForceWrapX; - if (option & V_WRAPY) - flags |= PF_ForceWrapY; - // clip it since it is used for bunny scroll in doom I if (alphalevel) { FSurfaceInfo Surf; Surf.PolyColor.s.red = Surf.PolyColor.s.green = Surf.PolyColor.s.blue = 0xff; - if (alphalevel == 13) Surf.PolyColor.s.alpha = softwaretranstogl_lo[st_translucency]; - else if (alphalevel == 14) Surf.PolyColor.s.alpha = softwaretranstogl[st_translucency]; - else if (alphalevel == 15) Surf.PolyColor.s.alpha = softwaretranstogl_hi[st_translucency]; + + if (alphalevel == 10) Surf.PolyColor.s.alpha = softwaretranstogl_lo[st_translucency]; + else if (alphalevel == 11) Surf.PolyColor.s.alpha = softwaretranstogl[st_translucency]; + else if (alphalevel == 12) Surf.PolyColor.s.alpha = softwaretranstogl_hi[st_translucency]; else Surf.PolyColor.s.alpha = softwaretranstogl[10-alphalevel]; flags |= PF_Modulated; HWD.pfnDrawPolygon(&Surf, v, 4, flags); @@ -399,9 +381,6 @@ void HWR_DrawCroppedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale, UINT8 perplayershuffle = 0; - if (alphalevel >= 10 && alphalevel < 13) - return; - // make patch ready in hardware cache if (!colormap) HWR_GetPatch(gpatch); @@ -591,11 +570,6 @@ void HWR_DrawCroppedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale, flags = PF_Translucent|PF_NoDepthTest; - if (option & V_WRAPX) - flags |= PF_ForceWrapX; - if (option & V_WRAPY) - flags |= PF_ForceWrapY; - // Auto-crop at splitscreen borders! if (splitscreen && (option & V_PERPLAYER)) { @@ -671,10 +645,12 @@ void HWR_DrawCroppedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale, { FSurfaceInfo Surf; Surf.PolyColor.s.red = Surf.PolyColor.s.green = Surf.PolyColor.s.blue = 0xff; - if (alphalevel == 13) Surf.PolyColor.s.alpha = softwaretranstogl_lo[st_translucency]; - else if (alphalevel == 14) Surf.PolyColor.s.alpha = softwaretranstogl[st_translucency]; - else if (alphalevel == 15) Surf.PolyColor.s.alpha = softwaretranstogl_hi[st_translucency]; + + if (alphalevel == 10) Surf.PolyColor.s.alpha = softwaretranstogl_lo[st_translucency]; + else if (alphalevel == 11) Surf.PolyColor.s.alpha = softwaretranstogl[st_translucency]; + else if (alphalevel == 12) Surf.PolyColor.s.alpha = softwaretranstogl_hi[st_translucency]; else Surf.PolyColor.s.alpha = softwaretranstogl[10-alphalevel]; + flags |= PF_Modulated; HWD.pfnDrawPolygon(&Surf, v, 4, flags); } diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 9bade3d6f..c5e5a3218 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -3916,6 +3916,9 @@ static void HWR_SplitSprite(gl_vissprite_t *spr) } } + if (R_ThingIsSemiBright(spr->mobj)) + lightlevel = 128 + (lightlevel>>1); + for (i = 0; i < sector->numlights; i++) { if (endtop < endrealbot && top < realbot) @@ -4269,6 +4272,9 @@ static void HWR_DrawSprite(gl_vissprite_t *spr) else if (!lightset) lightlevel = sector->lightlevel > 255 ? 255 : sector->lightlevel; + if (R_ThingIsSemiBright(spr->mobj)) + lightlevel = 128 + (lightlevel>>1); + HWR_Lighting(&Surf, lightlevel, colormap); } diff --git a/src/hu_stuff.c b/src/hu_stuff.c index f4c5e4c3b..129724585 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -1869,7 +1869,7 @@ static void HU_DrawChat_Old(void) static inline void HU_DrawCrosshair(void) { - INT32 i, y; + INT32 i, y, dupz; i = cv_crosshair.value & 3; if (!i) @@ -1885,12 +1885,14 @@ static inline void HU_DrawCrosshair(void) #endif y = viewwindowy + (viewheight>>1); - V_DrawScaledPatch(vid.width>>1, y, V_NOSCALESTART|V_OFFSET|V_TRANSLUCENT, crosshair[i - 1]); + dupz = (vid.dupx < vid.dupy ? vid.dupx : vid.dupy); + + V_DrawFixedPatch(vid.width<<(FRACBITS-1), y<>1); - if (splitscreen) - { -#ifdef HWRENDER + if (!splitscreen) + return; + + #ifdef HWRENDER if (rendermode != render_soft) y += (INT32)gl_viewheight; else -#endif + #endif y += viewheight; - V_DrawScaledPatch(vid.width>>1, y, V_NOSCALESTART|V_OFFSET|V_TRANSLUCENT, crosshair[i - 1]); - } + dupz = (vid.dupx < vid.dupy ? vid.dupx : vid.dupy); + + V_DrawFixedPatch(vid.width<<(FRACBITS-1), y<width - p->leftoffset; for (i = 0; i < 16; i++) { - V_DrawScaledPatch(xx, y, V_WRAPX, W_CachePatchNum(centerlump[i & 1], PU_PATCH)); + V_DrawScaledPatch(xx, y, 0, W_CachePatchNum(centerlump[i & 1], PU_PATCH)); xx += 8; } V_DrawScaledPatch(xx, y, 0, W_CachePatchNum(rightlump, PU_PATCH)); @@ -4134,7 +4134,7 @@ void M_DrawTextBox(INT32 x, INT32 y, INT32 width, INT32 boxlines) p = W_CachePatchNum(viewborderlump[BRDR_L], PU_PATCH); for (n = 0; n < boxlines; n++) { - V_DrawScaledPatch(cx, cy, V_WRAPY, p); + V_DrawScaledPatch(cx, cy, 0, p); cy += step; } V_DrawScaledPatch(cx, cy, 0, W_CachePatchNum(viewborderlump[BRDR_BL], PU_PATCH)); @@ -4146,8 +4146,8 @@ void M_DrawTextBox(INT32 x, INT32 y, INT32 width, INT32 boxlines) cy = y; while (width > 0) { - V_DrawScaledPatch(cx, cy, V_WRAPX, W_CachePatchNum(viewborderlump[BRDR_T], PU_PATCH)); - V_DrawScaledPatch(cx, y + boff + boxlines*step, V_WRAPX, W_CachePatchNum(viewborderlump[BRDR_B], PU_PATCH)); + V_DrawScaledPatch(cx, cy, 0, W_CachePatchNum(viewborderlump[BRDR_T], PU_PATCH)); + V_DrawScaledPatch(cx, y + boff + boxlines*step, 0, W_CachePatchNum(viewborderlump[BRDR_B], PU_PATCH)); width--; cx += step; } @@ -4159,7 +4159,7 @@ void M_DrawTextBox(INT32 x, INT32 y, INT32 width, INT32 boxlines) p = W_CachePatchNum(viewborderlump[BRDR_R], PU_PATCH); for (n = 0; n < boxlines; n++) { - V_DrawScaledPatch(cx, cy, V_WRAPY, p); + V_DrawScaledPatch(cx, cy, 0, p); cy += step; } V_DrawScaledPatch(cx, cy, 0, W_CachePatchNum(viewborderlump[BRDR_BR], PU_PATCH)); diff --git a/src/p_pspr.h b/src/p_pspr.h index 4525ba14c..27002b713 100644 --- a/src/p_pspr.h +++ b/src/p_pspr.h @@ -41,9 +41,20 @@ /// \brief Frame flags - SPR2: Super sprite2 #define FF_SPR2SUPER 0x80 /// \brief Frame flags - SPR2: A change of state at the end of Sprite2 animation -#define FF_SPR2ENDSTATE 0x1000 +#define FF_SPR2ENDSTATE 0x100 /// \brief Frame flags - SPR2: 50% of starting in middle of Sprite2 animation -#define FF_SPR2MIDSTART 0x2000 +#define FF_SPR2MIDSTART 0x200 + +/// \brief Frame flags: blend types +#define FF_BLENDMASK 0x7000 +/// \brief shift for FF_BLENDMASK +#define FF_BLENDSHIFT 12 +/// \brief preshifted blend flags minus 1 as effects don't distinguish between AST_COPY and AST_TRANSLUCENT +#define FF_ADD ((AST_ADD-1)<= MAXLIGHTSCALE) lindex = MAXLIGHTSCALE-1; + + if (newsprite->cut & SC_SEMIBRIGHT) + lindex = (MAXLIGHTSCALE/2) + (lindex >>1); + newsprite->colormap = spritelights[lindex]; } } @@ -2023,6 +2027,8 @@ static void R_ProjectSprite(mobj_t *thing) if (R_ThingIsFullBright(oldthing) || oldthing->flags2 & MF2_SHADOW || thing->flags2 & MF2_SHADOW) vis->cut |= SC_FULLBRIGHT; + else if (R_ThingIsSemiBright(oldthing)) + vis->cut |= SC_SEMIBRIGHT; else if (R_ThingIsFullDark(oldthing)) vis->cut |= SC_FULLDARK; @@ -2045,6 +2051,9 @@ static void R_ProjectSprite(mobj_t *thing) if (lindex >= MAXLIGHTSCALE) lindex = MAXLIGHTSCALE-1; + if (vis->cut & SC_SEMIBRIGHT) + lindex = (MAXLIGHTSCALE/2) + (lindex >> 1); + vis->colormap = spritelights[lindex]; } @@ -3012,7 +3021,7 @@ boolean R_ThingVisible (mobj_t *thing) { return (!( thing->sprite == SPR_NULL || - ( thing->flags2 & (MF2_DONTDRAW) ) || + ( thing->flags2 & (MF2_DONTDRAW) ) || ( thing->renderflags & (RF_DONTDRAW) ) || (r_viewmobj && (thing == r_viewmobj || (r_viewmobj->player && r_viewmobj->player->followmobj == thing))) )); } @@ -3073,17 +3082,22 @@ boolean R_ThingIsPaperSprite(mobj_t *thing) boolean R_ThingIsFloorSprite(mobj_t *thing) { - return (thing->flags2 & MF2_SPLAT || thing->renderflags & RF_FLOORSPRITE); + return (thing->flags2 & MF2_SPLAT || thing->frame & FF_FLOORSPRITE || thing->renderflags & RF_FLOORSPRITE); } boolean R_ThingIsFullBright(mobj_t *thing) { - return (thing->frame & FF_FULLBRIGHT || thing->renderflags & RF_FULLBRIGHT); + return ((thing->frame & FF_BRIGHTMASK) == FF_FULLBRIGHT || (thing->renderflags & RF_BRIGHTMASK) == RF_FULLBRIGHT); +} + +boolean R_ThingIsSemiBright(mobj_t *thing) +{ + return ((thing->frame & FF_BRIGHTMASK) == FF_SEMIBRIGHT || (thing->renderflags & RF_BRIGHTMASK) == RF_SEMIBRIGHT); } boolean R_ThingIsFullDark(mobj_t *thing) { - return (thing->renderflags & RF_FULLDARK); + return ((thing->frame & FF_BRIGHTMASK) == FF_FULLDARK || (thing->renderflags & RF_BRIGHTMASK) == RF_FULLDARK); } // diff --git a/src/r_things.h b/src/r_things.h index 79dc80d94..b1ff32b1e 100644 --- a/src/r_things.h +++ b/src/r_things.h @@ -82,6 +82,7 @@ boolean R_ThingIsPaperSprite (mobj_t *thing); boolean R_ThingIsFloorSprite (mobj_t *thing); boolean R_ThingIsFullBright (mobj_t *thing); +boolean R_ThingIsSemiBright (mobj_t *thing); boolean R_ThingIsFullDark (mobj_t *thing); // -------------- @@ -123,13 +124,14 @@ typedef enum SC_PRECIP = 1<<2, SC_LINKDRAW = 1<<3, SC_FULLBRIGHT = 1<<4, - SC_FULLDARK = 1<<5, - SC_VFLIP = 1<<6, - SC_ISSCALED = 1<<7, - SC_ISROTATED = 1<<8, - SC_SHADOW = 1<<9, - SC_SHEAR = 1<<10, - SC_SPLAT = 1<<11, + SC_SEMIBRIGHT = 1<<5, + SC_FULLDARK = 1<<6, + SC_VFLIP = 1<<7, + SC_ISSCALED = 1<<8, + SC_ISROTATED = 1<<9, + SC_SHADOW = 1<<10, + SC_SHEAR = 1<<11, + SC_SPLAT = 1<<12, // masks SC_CUTMASK = SC_TOP|SC_BOTTOM, SC_FLAGMASK = ~SC_CUTMASK diff --git a/src/v_video.c b/src/v_video.c index c39938544..ad0164816 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -540,11 +540,11 @@ void V_DrawStretchyFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, fixed_t vsca v_translevel = NULL; if ((alphalevel = ((scrn & V_ALPHAMASK) >> V_ALPHASHIFT))) { - if (alphalevel == 13) + if (alphalevel == 10) alphalevel = hudminusalpha[st_translucency]; - else if (alphalevel == 14) + else if (alphalevel == 11) alphalevel = 10 - st_translucency; - else if (alphalevel == 15) + else if (alphalevel == 12) alphalevel = hudplusalpha[st_translucency]; if (alphalevel >= 10) @@ -591,10 +591,6 @@ void V_DrawStretchyFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, fixed_t vsca colfrac = FixedDiv(FRACUNIT, fdup); rowfrac = FixedDiv(FRACUNIT, vdup); - // So it turns out offsets aren't scaled in V_NOSCALESTART unless V_OFFSET is applied ...poo, that's terrible - // For now let's just at least give V_OFFSET the ability to support V_FLIP - // I'll probably make a better fix for 2.2 where I don't have to worry about breaking existing support for stuff - // -- Monster Iestyn 29/10/18 { fixed_t offsetx = 0, offsety = 0; @@ -605,15 +601,8 @@ void V_DrawStretchyFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, fixed_t vsca offsetx = FixedMul(patch->leftoffset<topoffset<> V_ALPHASHIFT))) { - if (alphalevel == 13) + if (alphalevel == 10) alphalevel = hudminusalpha[st_translucency]; - else if (alphalevel == 14) + else if (alphalevel == 11) alphalevel = 10 - st_translucency; - else if (alphalevel == 15) + else if (alphalevel == 12) alphalevel = hudplusalpha[st_translucency]; if (alphalevel >= 10) @@ -1411,11 +1400,11 @@ void V_DrawFillConsoleMap(INT32 x, INT32 y, INT32 w, INT32 h, INT32 c) if ((alphalevel = ((c & V_ALPHAMASK) >> V_ALPHASHIFT))) { - if (alphalevel == 13) + if (alphalevel == 10) alphalevel = hudminusalpha[st_translucency]; - else if (alphalevel == 14) + else if (alphalevel == 11) alphalevel = 10 - st_translucency; - else if (alphalevel == 15) + else if (alphalevel == 12) alphalevel = hudplusalpha[st_translucency]; if (alphalevel >= 10) diff --git a/src/v_video.h b/src/v_video.h index c10ab22ce..bcb39706e 100644 --- a/src/v_video.h +++ b/src/v_video.h @@ -122,17 +122,23 @@ void V_CubeApply(UINT8 *red, UINT8 *green, UINT8 *blue); #define V_70TRANS 0x00070000 #define V_80TRANS 0x00080000 // used to be V_8020TRANS #define V_90TRANS 0x00090000 -#define V_HUDTRANSHALF 0x000D0000 -#define V_HUDTRANS 0x000E0000 // draw the hud translucent -#define V_HUDTRANSDOUBLE 0x000F0000 +#define V_HUDTRANSHALF 0x000A0000 +#define V_HUDTRANS 0x000B0000 // draw the hud translucent +#define V_HUDTRANSDOUBLE 0x000C0000 // Macros follow #define V_USERHUDTRANSHALF ((10-(cv_translucenthud.value/2))< Date: Mon, 15 Nov 2021 19:07:20 +0100 Subject: [PATCH 0966/1080] blentran part 2: Sprite & patch blendmodes. --- src/hardware/hw_draw.c | 16 ++++++++++++---- src/hardware/hw_main.c | 32 +++++++++++++++++++++++++------- src/r_things.c | 14 ++++++++++---- src/v_video.c | 22 ++++++++++++++++------ 4 files changed, 63 insertions(+), 21 deletions(-) diff --git a/src/hardware/hw_draw.c b/src/hardware/hw_draw.c index 89d43a6b4..e02dbea5b 100644 --- a/src/hardware/hw_draw.c +++ b/src/hardware/hw_draw.c @@ -130,6 +130,7 @@ void HWR_DrawStretchyFixedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t p float cx = FIXED_TO_FLOAT(x); float cy = FIXED_TO_FLOAT(y); UINT8 alphalevel = ((option & V_ALPHAMASK) >> V_ALPHASHIFT); + UINT8 blendmode = ((option & V_BLENDMASK) >> V_BLENDSHIFT); GLPatch_t *hwrPatch; // 3--2 @@ -345,9 +346,12 @@ void HWR_DrawStretchyFixedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t p v[0].t = v[1].t = 0.0f; v[2].t = v[3].t = hwrPatch->max_t; - flags = PF_Translucent|PF_NoDepthTest; - // clip it since it is used for bunny scroll in doom I + if (blendmode) + flags = HWR_GetBlendModeFlag(blendmode+1)|PF_NoDepthTest; + else + flags = PF_Translucent|PF_NoDepthTest; + if (alphalevel) { FSurfaceInfo Surf; @@ -371,6 +375,7 @@ void HWR_DrawCroppedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale, float cx = FIXED_TO_FLOAT(x); float cy = FIXED_TO_FLOAT(y); UINT8 alphalevel = ((option & V_ALPHAMASK) >> V_ALPHASHIFT); + UINT8 blendmode = ((option & V_BLENDMASK) >> V_BLENDSHIFT); GLPatch_t *hwrPatch; // 3--2 @@ -568,8 +573,6 @@ void HWR_DrawCroppedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale, else v[2].t = v[3].t = (FIXED_TO_FLOAT(sy+h)/(float)(gpatch->height))*hwrPatch->max_t; - flags = PF_Translucent|PF_NoDepthTest; - // Auto-crop at splitscreen borders! if (splitscreen && (option & V_PERPLAYER)) { @@ -641,6 +644,11 @@ 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 (blendmode) + flags = HWR_GetBlendModeFlag(blendmode+1)|PF_NoDepthTest; + else + flags = PF_Translucent|PF_NoDepthTest; + if (alphalevel) { FSurfaceInfo Surf; diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index c5e5a3218..63f1191ca 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -3853,6 +3853,12 @@ static void HWR_SplitSprite(gl_vissprite_t *spr) else occlusion = PF_Occlude; + INT32 blendmode; + if (spr->mobj->frame & FF_BLENDMASK) + blendmode = ((spr->mobj->frame & FF_BLENDMASK) >> FF_BLENDSHIFT) + 1; + else + blendmode = spr->mobj->blendmode; + if (!cv_translucency.value) // translucency disabled { Surf.PolyColor.s.alpha = 0xFF; @@ -3862,12 +3868,12 @@ static void HWR_SplitSprite(gl_vissprite_t *spr) else if (spr->mobj->flags2 & MF2_SHADOW) { Surf.PolyColor.s.alpha = 0x40; - blend = HWR_GetBlendModeFlag(spr->mobj->blendmode); + blend = HWR_GetBlendModeFlag(blendmode); } else if (spr->mobj->frame & FF_TRANSMASK) { INT32 trans = (spr->mobj->frame & FF_TRANSMASK)>>FF_TRANSSHIFT; - blend = HWR_SurfaceBlend(spr->mobj->blendmode, trans, &Surf); + blend = HWR_SurfaceBlend(blendmode, trans, &Surf); } else { @@ -3876,7 +3882,7 @@ static void HWR_SplitSprite(gl_vissprite_t *spr) // Hurdler: PF_Environement would be cool, but we need to fix // the issue with the fog before Surf.PolyColor.s.alpha = 0xFF; - blend = HWR_GetBlendModeFlag(spr->mobj->blendmode)|occlusion; + blend = HWR_GetBlendModeFlag(blendmode)|occlusion; if (!occlusion) use_linkdraw_hack = true; } @@ -4291,6 +4297,12 @@ static void HWR_DrawSprite(gl_vissprite_t *spr) else occlusion = PF_Occlude; + INT32 blendmode; + if (spr->mobj->frame & FF_BLENDMASK) + blendmode = ((spr->mobj->frame & FF_BLENDMASK) >> FF_BLENDSHIFT) + 1; + else + blendmode = spr->mobj->blendmode; + if (!cv_translucency.value) // translucency disabled { Surf.PolyColor.s.alpha = 0xFF; @@ -4300,12 +4312,12 @@ static void HWR_DrawSprite(gl_vissprite_t *spr) else if (spr->mobj->flags2 & MF2_SHADOW) { Surf.PolyColor.s.alpha = 0x40; - blend = HWR_GetBlendModeFlag(spr->mobj->blendmode); + blend = HWR_GetBlendModeFlag(blendmode); } else if (spr->mobj->frame & FF_TRANSMASK) { INT32 trans = (spr->mobj->frame & FF_TRANSMASK)>>FF_TRANSSHIFT; - blend = HWR_SurfaceBlend(spr->mobj->blendmode, trans, &Surf); + blend = HWR_SurfaceBlend(blendmode, trans, &Surf); } else { @@ -4314,7 +4326,7 @@ static void HWR_DrawSprite(gl_vissprite_t *spr) // Hurdler: PF_Environement would be cool, but we need to fix // the issue with the fog before Surf.PolyColor.s.alpha = 0xFF; - blend = HWR_GetBlendModeFlag(spr->mobj->blendmode)|occlusion; + blend = HWR_GetBlendModeFlag(blendmode)|occlusion; if (!occlusion) use_linkdraw_hack = true; } @@ -5009,10 +5021,16 @@ static void HWR_ProjectSprite(mobj_t *thing) if (thing->spritexscale < 1 || thing->spriteyscale < 1) return; + INT32 blendmode; + if (thing->frame & FF_BLENDMASK) + blendmode = ((thing->frame & FF_BLENDMASK) >> FF_BLENDSHIFT) + 1; + else + blendmode = thing->blendmode; + // Visibility check by the blend mode. if (thing->frame & FF_TRANSMASK) { - if (!R_BlendLevelVisible(thing->blendmode, (thing->frame & FF_TRANSMASK)>>FF_TRANSSHIFT)) + if (!R_BlendLevelVisible(blendmode, (thing->frame & FF_TRANSMASK)>>FF_TRANSSHIFT)) return; } diff --git a/src/r_things.c b/src/r_things.c index 5d5be8753..accd1e2b3 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -1802,13 +1802,19 @@ static void R_ProjectSprite(mobj_t *thing) return; } + INT32 blendmode; + if (oldthing->frame & FF_BLENDMASK) + blendmode = ((oldthing->frame & FF_BLENDMASK) >> FF_BLENDSHIFT) + 1; + else + blendmode = oldthing->blendmode; + // Determine the translucency value. if (oldthing->flags2 & MF2_SHADOW || 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 (oldthing->frame & FF_TRANSMASK) { trans = (oldthing->frame & FF_TRANSMASK) >> FF_TRANSSHIFT; - if (!R_BlendLevelVisible(oldthing->blendmode, trans)) + if (!R_BlendLevelVisible(blendmode, trans)) return; } else @@ -2020,8 +2026,8 @@ static void R_ProjectSprite(mobj_t *thing) vis->scale += FixedMul(scalestep, spriteyscale) * (vis->x1 - x1); } - if ((oldthing->blendmode != AST_COPY) && cv_translucency.value) - vis->transmap = R_GetBlendTable(oldthing->blendmode, trans); + if ((blendmode != AST_COPY) && cv_translucency.value) + vis->transmap = R_GetBlendTable(blendmode, trans); else vis->transmap = NULL; @@ -3021,7 +3027,7 @@ boolean R_ThingVisible (mobj_t *thing) { return (!( thing->sprite == SPR_NULL || - ( thing->flags2 & (MF2_DONTDRAW) ) || ( thing->renderflags & (RF_DONTDRAW) ) || + ( thing->flags2 & (MF2_DONTDRAW) ) || (r_viewmobj && (thing == r_viewmobj || (r_viewmobj->player && r_viewmobj->player->followmobj == thing))) )); } diff --git a/src/v_video.c b/src/v_video.c index ad0164816..12588f9c2 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -511,7 +511,8 @@ static inline UINT8 transmappedpdraw(const UINT8 *dest, const UINT8 *source, fix void V_DrawStretchyFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, fixed_t vscale, INT32 scrn, patch_t *patch, const UINT8 *colormap) { UINT8 (*patchdrawfunc)(const UINT8*, const UINT8*, fixed_t); - UINT32 alphalevel = 0; + UINT32 alphalevel = ((scrn & V_ALPHAMASK) >> V_ALPHASHIFT); + UINT32 blendmode = ((scrn & V_BLENDMASK) >> V_BLENDSHIFT); fixed_t col, ofs, colfrac, rowfrac, fdup, vdup; INT32 dupx, dupy; @@ -538,7 +539,7 @@ void V_DrawStretchyFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, fixed_t vsca patchdrawfunc = standardpdraw; v_translevel = NULL; - if ((alphalevel = ((scrn & V_ALPHAMASK) >> V_ALPHASHIFT))) + if (alphalevel) { if (alphalevel == 10) alphalevel = hudminusalpha[st_translucency]; @@ -552,7 +553,11 @@ void V_DrawStretchyFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, fixed_t vsca if (alphalevel) { - v_translevel = R_GetTranslucencyTable(alphalevel); + if (blendmode) + v_translevel = R_GetBlendTable(blendmode+1, alphalevel); + else + v_translevel = R_GetTranslucencyTable(alphalevel); + patchdrawfunc = translucentpdraw; } } @@ -801,7 +806,8 @@ void V_DrawStretchyFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, fixed_t vsca void V_DrawCroppedPatch(fixed_t x, fixed_t y, fixed_t pscale, fixed_t vscale, INT32 scrn, patch_t *patch, const UINT8 *colormap, fixed_t sx, fixed_t sy, fixed_t w, fixed_t h) { UINT8 (*patchdrawfunc)(const UINT8*, const UINT8*, fixed_t); - UINT32 alphalevel = 0; + UINT32 alphalevel = ((scrn & V_ALPHAMASK) >> V_ALPHASHIFT); + UINT32 blendmode = ((scrn & V_BLENDMASK) >> V_BLENDSHIFT); // boolean flip = false; fixed_t col, ofs, colfrac, rowfrac, fdup, vdup; @@ -827,7 +833,7 @@ void V_DrawCroppedPatch(fixed_t x, fixed_t y, fixed_t pscale, fixed_t vscale, IN patchdrawfunc = standardpdraw; v_translevel = NULL; - if ((alphalevel = ((scrn & V_ALPHAMASK) >> V_ALPHASHIFT))) + if (alphalevel) { if (alphalevel == 10) alphalevel = hudminusalpha[st_translucency]; @@ -841,7 +847,11 @@ void V_DrawCroppedPatch(fixed_t x, fixed_t y, fixed_t pscale, fixed_t vscale, IN if (alphalevel) { - v_translevel = R_GetTranslucencyTable(alphalevel); + if (blendmode) + v_translevel = R_GetBlendTable(blendmode+1, alphalevel); + else + v_translevel = R_GetTranslucencyTable(alphalevel); + patchdrawfunc = translucentpdraw; } } From 7601afb6c1fe3fb0648c4f5404eb268554856273 Mon Sep 17 00:00:00 2001 From: sphere Date: Fri, 19 Nov 2021 19:01:41 +0100 Subject: [PATCH 0967/1080] blentran part 3: Wall & plane blendmodes. --- src/hardware/hw_main.c | 68 ++++++++++++++++++++++++++---------------- src/lua_maplib.c | 8 +++++ src/p_setup.c | 39 +++++++++++++++--------- src/p_spec.c | 11 ++++++- src/r_defs.h | 2 ++ src/r_draw.c | 3 ++ src/r_plane.c | 32 +++++++------------- src/r_segs.c | 43 ++++++++++++-------------- 8 files changed, 120 insertions(+), 86 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 63f1191ca..a1dd53eb7 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -556,7 +556,7 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool HWR_Lighting(&Surf, lightlevel, planecolormap); - if (PolyFlags & (PF_Translucent|PF_Fog)) + if (PolyFlags & (PF_Translucent|PF_Fog|PF_Additive|PF_Subtractive|PF_ReverseSubtract|PF_Multiplicative|PF_Environment)) { Surf.PolyColor.s.alpha = (UINT8)alpha; PolyFlags |= PF_Modulated; @@ -980,8 +980,8 @@ static void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, if (cutflag & FF_FOG) HWR_AddTransparentWall(wallVerts, Surf, texnum, PF_Fog|PF_NoTexture|polyflags, true, lightnum, colormap); - else if (cutflag & FF_TRANSLUCENT) - HWR_AddTransparentWall(wallVerts, Surf, texnum, PF_Translucent|polyflags, false, lightnum, colormap); + else if (polyflags & (PF_Translucent|PF_Additive|PF_Subtractive|PF_ReverseSubtract|PF_Multiplicative|PF_Environment)) + HWR_AddTransparentWall(wallVerts, Surf, texnum, polyflags, false, lightnum, colormap); else HWR_ProjectWall(wallVerts, Surf, PF_Masked|polyflags, lightnum, colormap); @@ -1009,8 +1009,8 @@ static void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, if (cutflag & FF_FOG) HWR_AddTransparentWall(wallVerts, Surf, texnum, PF_Fog|PF_NoTexture|polyflags, true, lightnum, colormap); - else if (cutflag & FF_TRANSLUCENT) - HWR_AddTransparentWall(wallVerts, Surf, texnum, PF_Translucent|polyflags, false, lightnum, colormap); + else if (polyflags & (PF_Translucent|PF_Additive|PF_Subtractive|PF_ReverseSubtract|PF_Multiplicative|PF_Environment)) + HWR_AddTransparentWall(wallVerts, Surf, texnum, polyflags, false, lightnum, colormap); else HWR_ProjectWall(wallVerts, Surf, PF_Masked|polyflags, lightnum, colormap); } @@ -1264,6 +1264,7 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom else HWR_ProjectWall(wallVerts, &Surf, PF_Masked, lightnum, colormap); } + gl_midtexture = R_GetTextureNum(gl_sidedef->midtexture); if (gl_midtexture) { @@ -1453,10 +1454,20 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom case 221: case 253: case 256: - blendmode = PF_Translucent; + if (gl_linedef->blendmode) + blendmode = HWR_SurfaceBlend(gl_linedef->blendmode, R_GetLinedefTransTable(gl_linedef->alpha), &Surf); + else + blendmode = PF_Translucent; break; default: - if (gl_linedef->alpha >= 0 && gl_linedef->alpha < FRACUNIT) + if (gl_linedef->blendmode) + { + if (gl_linedef->alpha >= 0 && gl_linedef->alpha < FRACUNIT) + blendmode = HWR_SurfaceBlend(gl_linedef->blendmode, R_GetLinedefTransTable(gl_linedef->alpha), &Surf); + else + blendmode = HWR_GetBlendModeFlag(gl_linedef->blendmode); + } + else if (gl_linedef->alpha >= 0 && gl_linedef->alpha < FRACUNIT) blendmode = HWR_TranstableToAlpha(R_GetLinedefTransTable(gl_linedef->alpha), &Surf); else blendmode = PF_Masked; @@ -1481,11 +1492,9 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom if (gl_frontsector->numlights) { if (!(blendmode & PF_Masked)) - HWR_SplitWall(gl_frontsector, wallVerts, gl_midtexture, &Surf, FF_TRANSLUCENT, NULL, PF_Decal); + HWR_SplitWall(gl_frontsector, wallVerts, gl_midtexture, &Surf, FF_TRANSLUCENT, NULL, blendmode); else - { - HWR_SplitWall(gl_frontsector, wallVerts, gl_midtexture, &Surf, FF_CUTLEVEL, NULL, PF_Decal); - } + HWR_SplitWall(gl_frontsector, wallVerts, gl_midtexture, &Surf, FF_CUTLEVEL, NULL, blendmode); } else if (!(blendmode & PF_Masked)) HWR_AddTransparentWall(wallVerts, &Surf, gl_midtexture, blendmode, false, lightnum, colormap); @@ -1745,7 +1754,7 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom Surf.PolyColor.s.alpha = HWR_FogBlockAlpha(rover->master->frontsector->lightlevel, rover->master->frontsector->extra_colormap); if (gl_frontsector->numlights) - HWR_SplitWall(gl_frontsector, wallVerts, 0, &Surf, rover->flags, rover, 0); + HWR_SplitWall(gl_frontsector, wallVerts, 0, &Surf, rover->flags, rover, blendmode); else HWR_AddTransparentWall(wallVerts, &Surf, 0, blendmode, true, lightnum, colormap); } @@ -1753,14 +1762,14 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom { FBITFIELD blendmode = PF_Masked; - if (rover->flags & FF_TRANSLUCENT && rover->alpha < 256) + if ((rover->flags & FF_TRANSLUCENT && rover->alpha < 256) || rover->blend) { - blendmode = PF_Translucent; + blendmode = rover->blend ? HWR_GetBlendModeFlag(rover->blend) : PF_Translucent; Surf.PolyColor.s.alpha = (UINT8)rover->alpha-1 > 255 ? 255 : rover->alpha-1; } if (gl_frontsector->numlights) - HWR_SplitWall(gl_frontsector, wallVerts, texnum, &Surf, rover->flags, rover, 0); + HWR_SplitWall(gl_frontsector, wallVerts, texnum, &Surf, rover->flags, rover, blendmode); else { if (blendmode != PF_Masked) @@ -1868,7 +1877,7 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom Surf.PolyColor.s.alpha = HWR_FogBlockAlpha(rover->master->frontsector->lightlevel, rover->master->frontsector->extra_colormap); if (gl_backsector->numlights) - HWR_SplitWall(gl_backsector, wallVerts, 0, &Surf, rover->flags, rover, 0); + HWR_SplitWall(gl_backsector, wallVerts, 0, &Surf, rover->flags, rover, blendmode); else HWR_AddTransparentWall(wallVerts, &Surf, 0, blendmode, true, lightnum, colormap); } @@ -1876,14 +1885,14 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom { FBITFIELD blendmode = PF_Masked; - if (rover->flags & FF_TRANSLUCENT && rover->alpha < 256) + if ((rover->flags & FF_TRANSLUCENT && rover->alpha < 256) || rover->blend) { - blendmode = PF_Translucent; + blendmode = rover->blend ? HWR_GetBlendModeFlag(rover->blend) : PF_Translucent; Surf.PolyColor.s.alpha = (UINT8)rover->alpha-1 > 255 ? 255 : rover->alpha-1; } if (gl_backsector->numlights) - HWR_SplitWall(gl_backsector, wallVerts, texnum, &Surf, rover->flags, rover, 0); + HWR_SplitWall(gl_backsector, wallVerts, texnum, &Surf, rover->flags, rover, blendmode); else { if (blendmode != PF_Masked) @@ -2960,6 +2969,13 @@ static void HWR_AddPolyObjectPlanes(void) } } +static FBITFIELD HWR_RippleBlend(sector_t *sector, ffloor_t *rover, boolean ceiling) +{ + (void)sector; + (void)ceiling; + return /*R_IsRipplePlane(sector, rover, ceiling)*/ (rover->flags & FF_RIPPLE) ? PF_Ripple : 0; +} + // -----------------+ // HWR_Subsector : Determine floor/ceiling planes. // : Add sprites of things in sector. @@ -3150,7 +3166,7 @@ static void HWR_Subsector(size_t num) alpha, rover->master->frontsector, PF_Fog|PF_NoTexture, true, rover->master->frontsector->extra_colormap); } - else if (rover->flags & FF_TRANSLUCENT && rover->alpha < 256) // SoM: Flags are more efficient + else if ((rover->flags & FF_TRANSLUCENT && rover->alpha < 256) || rover->blend) // SoM: Flags are more efficient { light = R_GetPlaneLight(gl_frontsector, centerHeight, dup_viewz < cullHeight ? true : false); @@ -3159,14 +3175,15 @@ static void HWR_Subsector(size_t num) false, *rover->bottomheight, *gl_frontsector->lightlist[light].lightlevel, - rover->alpha-1 > 255 ? 255 : rover->alpha-1, rover->master->frontsector, (rover->flags & FF_RIPPLE ? PF_Ripple : 0)|PF_Translucent, + rover->alpha-1 > 255 ? 255 : rover->alpha-1, rover->master->frontsector, + HWR_RippleBlend(gl_frontsector, rover, false) | (rover->blend ? HWR_GetBlendModeFlag(rover->blend) : PF_Translucent), false, *gl_frontsector->lightlist[light].extra_colormap); } else { HWR_GetLevelFlat(&levelflats[*rover->bottompic]); light = R_GetPlaneLight(gl_frontsector, centerHeight, dup_viewz < cullHeight ? true : false); - HWR_RenderPlane(sub, &extrasubsectors[num], false, *rover->bottomheight, (rover->flags & FF_RIPPLE ? PF_Ripple : 0)|PF_Occlude, *gl_frontsector->lightlist[light].lightlevel, &levelflats[*rover->bottompic], + HWR_RenderPlane(sub, &extrasubsectors[num], false, *rover->bottomheight, HWR_RippleBlend(gl_frontsector, rover, false)|PF_Occlude, *gl_frontsector->lightlist[light].lightlevel, &levelflats[*rover->bottompic], rover->master->frontsector, 255, *gl_frontsector->lightlist[light].extra_colormap); } } @@ -3195,7 +3212,7 @@ static void HWR_Subsector(size_t num) alpha, rover->master->frontsector, PF_Fog|PF_NoTexture, true, rover->master->frontsector->extra_colormap); } - else if (rover->flags & FF_TRANSLUCENT && rover->alpha < 256) + else if ((rover->flags & FF_TRANSLUCENT && rover->alpha < 256) || rover->blend) { light = R_GetPlaneLight(gl_frontsector, centerHeight, dup_viewz < cullHeight ? true : false); @@ -3204,14 +3221,15 @@ static void HWR_Subsector(size_t num) true, *rover->topheight, *gl_frontsector->lightlist[light].lightlevel, - rover->alpha-1 > 255 ? 255 : rover->alpha-1, rover->master->frontsector, (rover->flags & FF_RIPPLE ? PF_Ripple : 0)|PF_Translucent, + rover->alpha-1 > 255 ? 255 : rover->alpha-1, rover->master->frontsector, + HWR_RippleBlend(gl_frontsector, rover, false) | (rover->blend ? HWR_GetBlendModeFlag(rover->blend) : PF_Translucent), false, *gl_frontsector->lightlist[light].extra_colormap); } else { HWR_GetLevelFlat(&levelflats[*rover->toppic]); light = R_GetPlaneLight(gl_frontsector, centerHeight, dup_viewz < cullHeight ? true : false); - HWR_RenderPlane(sub, &extrasubsectors[num], true, *rover->topheight, (rover->flags & FF_RIPPLE ? PF_Ripple : 0)|PF_Occlude, *gl_frontsector->lightlist[light].lightlevel, &levelflats[*rover->toppic], + HWR_RenderPlane(sub, &extrasubsectors[num], true, *rover->topheight, HWR_RippleBlend(gl_frontsector, rover, false)|PF_Occlude, *gl_frontsector->lightlist[light].lightlevel, &levelflats[*rover->toppic], rover->master->frontsector, 255, *gl_frontsector->lightlist[light].extra_colormap); } } diff --git a/src/lua_maplib.c b/src/lua_maplib.c index 9031c99f1..04e6fde8d 100644 --- a/src/lua_maplib.c +++ b/src/lua_maplib.c @@ -196,6 +196,7 @@ enum ffloor_e { ffloor_next, ffloor_prev, ffloor_alpha, + ffloor_blend, }; static const char *const ffloor_opt[] = { @@ -214,6 +215,7 @@ static const char *const ffloor_opt[] = { "next", "prev", "alpha", + "blend", NULL}; #ifdef HAVE_LUA_SEGS @@ -1807,6 +1809,9 @@ static int ffloor_get(lua_State *L) case ffloor_alpha: lua_pushinteger(L, ffloor->alpha); return 1; + case ffloor_blend: + lua_pushinteger(L, ffloor->blend); + return 1; } return 0; } @@ -1885,6 +1890,9 @@ static int ffloor_set(lua_State *L) case ffloor_alpha: ffloor->alpha = (INT32)luaL_checkinteger(L, 3); break; + case ffloor_blend: + ffloor->blend = (INT32)luaL_checkinteger(L, 3); + break; } return 0; } diff --git a/src/p_setup.c b/src/p_setup.c index 588815aee..6320edc22 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -1350,8 +1350,11 @@ static void P_LoadSidedefs(UINT8 *data) if (msd->toptexture[0] == '#') { char *col = msd->toptexture; - sd->toptexture = sd->bottomtexture = - ((col[1]-'0')*100 + (col[2]-'0')*10 + col[3]-'0') + 1; + sd->toptexture = + ((col[1]-'0')*100 + (col[2]-'0')*10 + col[3]-'0')+1; + if (col[4]) // extra num for blendmode + sd->toptexture += (col[4]-'0')*1000; + sd->bottomtexture = sd->toptexture; sd->midtexture = R_TextureNumForName(msd->midtexture); } else @@ -3314,22 +3317,30 @@ static void P_ConvertBinaryMap(void) lines[i].args[4] |= TMSC_BACKTOFRONTCEILING; lines[i].special = 720; break; - - case 900: //Translucent wall (10%) - case 901: //Translucent wall (20%) - case 902: //Translucent wall (30%) - case 903: //Translucent wall (40%) - case 904: //Translucent wall (50%) - case 905: //Translucent wall (60%) - case 906: //Translucent wall (70%) - case 907: //Translucent wall (80%) - case 908: //Translucent wall (90%) - lines[i].alpha = ((909 - lines[i].special) << FRACBITS)/10; - break; default: break; } + // Set alpha for translucent walls + if (lines[i].special >= 900 && lines[i].special < 909) + lines[i].alpha = ((909 - lines[i].special) << FRACBITS)/10; + + // Set alpha for additive/subtractive/reverse subtractive walls + if (lines[i].special >= 910 && lines[i].special <= 939) + lines[i].alpha = ((10 - lines[i].special % 10) << FRACBITS)/10; + + if (lines[i].special >= 910 && lines[i].special <= 919) // additive + lines[i].blendmode = AST_ADD; + + if (lines[i].special >= 920 && lines[i].special <= 929) // subtractive + lines[i].blendmode = AST_SUBTRACT; + + if (lines[i].special >= 930 && lines[i].special <= 939) // reverse subtractive + lines[i].blendmode = AST_REVERSESUBTRACT; + + if (lines[i].special == 940) // modulate + lines[i].blendmode = AST_MODULATE; + //Linedef executor delay if (lines[i].special >= 400 && lines[i].special < 500) { diff --git a/src/p_spec.c b/src/p_spec.c index 07410efa2..ebabe6a79 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -5601,7 +5601,16 @@ static ffloor_t *P_AddFakeFloor(sector_t *sec, sector_t *sec2, line_t *master, f if (flags & FF_TRANSLUCENT) { if (sides[master->sidenum[0]].toptexture > 0) - fflr->alpha = sides[master->sidenum[0]].toptexture; // for future reference, "#0" is 1, and "#255" is 256. Be warned + { + // for future reference, "#0" is 1, and "#255" is 256. Be warned + fflr->alpha = sides[master->sidenum[0]].toptexture; + + if (fflr->alpha >= 1001) // fourth digit + { + fflr->blend = (fflr->alpha/1000)+1; // becomes an AST + fflr->alpha %= 1000; + } + } else fflr->alpha = 0x80; } diff --git a/src/r_defs.h b/src/r_defs.h index f4ab58295..3c2178937 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -184,6 +184,7 @@ typedef struct ffloor_s INT32 lastlight; INT32 alpha; + UINT8 blend; // blendmode tic_t norender; // for culling // these are saved for netgames, so do not let Lua touch these! @@ -397,6 +398,7 @@ typedef struct line_s // Visual appearance: sidedefs. UINT16 sidenum[2]; // sidenum[1] will be 0xffff if one-sided fixed_t alpha; // translucency + UINT8 blendmode; // blendmode INT32 executordelay; fixed_t bbox[4]; // bounding box for the extent of the linedef diff --git a/src/r_draw.c b/src/r_draw.c index f0a19a462..65bb87bfb 100644 --- a/src/r_draw.c +++ b/src/r_draw.c @@ -248,6 +248,9 @@ static void BlendTab_Subtractive(UINT8 *table, int style, UINT8 blendamt) result.s.green = max(0, result.s.green - blendamt); result.s.blue = max(0, result.s.blue - blendamt); + //probably incorrect, but does look better at lower opacity... + //result.rgba = ASTBlendPixel(result, frontrgba, AST_TRANSLUCENT, blendamt); + table[((bg * 0x100) + fg)] = GetColorLUT(&transtab_lut, result.s.red, result.s.green, result.s.blue); } } diff --git a/src/r_plane.c b/src/r_plane.c index 45719ce58..d854c2342 100644 --- a/src/r_plane.c +++ b/src/r_plane.c @@ -855,28 +855,16 @@ void R_DrawSinglePlane(visplane_t *pl) spanfunctype = (pl->ffloor->master->flags & ML_EFFECT6) ? SPANDRAWFUNC_TRANSSPLAT : SPANDRAWFUNC_TRANS; // Hacked up support for alpha value in software mode Tails 09-24-2002 - if (pl->ffloor->alpha < 12) - return; // Don't even draw it - else if (pl->ffloor->alpha < 38) - ds_transmap = R_GetTranslucencyTable(tr_trans90); - else if (pl->ffloor->alpha < 64) - ds_transmap = R_GetTranslucencyTable(tr_trans80); - else if (pl->ffloor->alpha < 89) - ds_transmap = R_GetTranslucencyTable(tr_trans70); - else if (pl->ffloor->alpha < 115) - ds_transmap = R_GetTranslucencyTable(tr_trans60); - else if (pl->ffloor->alpha < 140) - ds_transmap = R_GetTranslucencyTable(tr_trans50); - else if (pl->ffloor->alpha < 166) - ds_transmap = R_GetTranslucencyTable(tr_trans40); - else if (pl->ffloor->alpha < 192) - ds_transmap = R_GetTranslucencyTable(tr_trans30); - else if (pl->ffloor->alpha < 217) - ds_transmap = R_GetTranslucencyTable(tr_trans20); - else if (pl->ffloor->alpha < 243) - ds_transmap = R_GetTranslucencyTable(tr_trans10); - else // Opaque, but allow transparent flat pixels - spanfunctype = SPANDRAWFUNC_SPLAT; + // ...unhacked by toaster 04-01-2021, re-hacked a little by sphere 19-11-2021 + { + INT32 trans = (10*((256+12) - pl->ffloor->alpha))/255; + if (trans >= 10) + return; // Don't even draw it + if (pl->ffloor->blend) // additive, (reverse) subtractive, modulative + ds_transmap = R_GetBlendTable(pl->ffloor->blend, trans); + else if (!(ds_transmap = R_GetTranslucencyTable(trans))) + spanfunctype = SPANDRAWFUNC_SPLAT; // Opaque, but allow transparent flat pixels + } if ((spanfunctype == SPANDRAWFUNC_SPLAT) || (pl->extra_colormap && (pl->extra_colormap->flags & CMF_FOG))) light = (pl->lightlevel >> LIGHTSEGSHIFT); diff --git a/src/r_segs.c b/src/r_segs.c index a8c85ec33..4460f9f90 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -155,11 +155,18 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2) if (!ldef->alpha) return; - if (ldef->alpha > 0 && ldef->alpha < FRACUNIT) + if (ldef->blendmode) + { + if (ldef->alpha == NUMTRANSMAPS || ldef->blendmode == AST_MODULATE) + dc_transmap = R_GetBlendTable(ldef->blendmode, 0); + else + dc_transmap = R_GetBlendTable(ldef->blendmode, R_GetLinedefTransTable(ldef->alpha)); + colfunc = colfuncs[COLDRAWFUNC_FUZZY]; + } + else if (ldef->alpha > 0 && ldef->alpha < FRACUNIT) { dc_transmap = R_GetTranslucencyTable(R_GetLinedefTransTable(ldef->alpha)); colfunc = colfuncs[COLDRAWFUNC_FUZZY]; - } else if (ldef->special == 909) { @@ -600,28 +607,16 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) boolean fuzzy = true; // Hacked up support for alpha value in software mode Tails 09-24-2002 - if (pfloor->alpha < 12) - return; // Don't even draw it - else if (pfloor->alpha < 38) - dc_transmap = R_GetTranslucencyTable(tr_trans90); - else if (pfloor->alpha < 64) - dc_transmap = R_GetTranslucencyTable(tr_trans80); - else if (pfloor->alpha < 89) - dc_transmap = R_GetTranslucencyTable(tr_trans70); - else if (pfloor->alpha < 115) - dc_transmap = R_GetTranslucencyTable(tr_trans60); - else if (pfloor->alpha < 140) - dc_transmap = R_GetTranslucencyTable(tr_trans50); - else if (pfloor->alpha < 166) - dc_transmap = R_GetTranslucencyTable(tr_trans40); - else if (pfloor->alpha < 192) - dc_transmap = R_GetTranslucencyTable(tr_trans30); - else if (pfloor->alpha < 217) - dc_transmap = R_GetTranslucencyTable(tr_trans20); - else if (pfloor->alpha < 243) - dc_transmap = R_GetTranslucencyTable(tr_trans10); - else - fuzzy = false; // Opaque + // ...unhacked by toaster 04-01-2021, re-hacked a little by sphere 19-11-2021 + { + INT32 trans = (10*((256+12) - pfloor->alpha))/255; + if (trans >= 10) + return; // Don't even draw it + if (pfloor->blend) // additive, (reverse) subtractive, modulative + dc_transmap = R_GetBlendTable(pfloor->blend, trans); + else if (!(dc_transmap = R_GetTranslucencyTable(trans))) + fuzzy = false; // Opaque + } if (fuzzy) colfunc = colfuncs[COLDRAWFUNC_FUZZY]; From 55fc7cbd67234d30b50139bed1958bc2ee986fdc Mon Sep 17 00:00:00 2001 From: MascaraSnake Date: Sun, 5 Dec 2021 07:20:55 +0100 Subject: [PATCH 0968/1080] Fix "all players" check in T_EachTimeThinker --- src/p_floor.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/p_floor.c b/src/p_floor.c index 263644f70..dd9331e73 100644 --- a/src/p_floor.c +++ b/src/p_floor.c @@ -1516,8 +1516,8 @@ void T_EachTimeThinker(eachtime_t *eachtime) { for (i = 0; i < MAXPLAYERS; i++) { - if (P_IsPlayerValid(i) && playersArea[i]) - continue; + if (P_IsPlayerValid(i) && !playersArea[i]) + return; } } From b2d693a54704f08eecca461192753c1f57f44acf Mon Sep 17 00:00:00 2001 From: katsy Date: Sun, 5 Dec 2021 02:13:09 -0600 Subject: [PATCH 0969/1080] minor spike optimisations --- src/info.c | 6 +- src/p_map.c | 152 ++++++++++++++++++++++++--------------------------- src/p_mobj.c | 98 +++++++++++++++++++-------------- 3 files changed, 129 insertions(+), 127 deletions(-) diff --git a/src/info.c b/src/info.c index f56e5d78e..65185517a 100644 --- a/src/info.c +++ b/src/info.c @@ -7977,7 +7977,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = DMG_SPIKE, // mass 0, // damage sfx_None, // activesound - MF_NOBLOCKMAP|MF_SCENERY|MF_NOCLIPHEIGHT, // flags + MF_SOLID|MF_SCENERY, // flags S_NULL // raisestate }, @@ -8004,7 +8004,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = DMG_SPIKE, // mass 0, // damage sfx_None, // activesound - MF_NOBLOCKMAP|MF_NOGRAVITY|MF_SCENERY|MF_NOCLIPHEIGHT|MF_PAPERCOLLISION, // flags + MF_SOLID|MF_NOGRAVITY|MF_SCENERY|MF_PAPERCOLLISION, // flags S_NULL // raisestate }, @@ -8031,7 +8031,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = 4, // mass 0, // damage sfx_None, // activesound - MF_NOBLOCKMAP|MF_NOGRAVITY|MF_NOCLIP|MF_NOCLIPTHING, // flags + MF_NOBLOCKMAP|MF_NOGRAVITY|MF_SCENERY|MF_NOCLIP|MF_NOCLIPTHING, // flags S_NULL // raisestate }, diff --git a/src/p_map.c b/src/p_map.c index 836e75c4e..b2dd52127 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -1465,86 +1465,6 @@ static boolean PIT_CheckThing(mobj_t *thing) return true; } - // Sprite Spikes! - // Do not return because solidity code comes below. - if (tmthing->type == MT_SPIKE && tmthing->flags & MF_SOLID && thing->player) // moving spike rams into player?! - { - if (tmthing->eflags & MFE_VERTICALFLIP) - { - if (thing->z + thing->height <= tmthing->z + FixedMul(FRACUNIT, tmthing->scale) - && thing->z + thing->height + thing->momz >= tmthing->z + FixedMul(FRACUNIT, tmthing->scale) + tmthing->momz - && !(thing->player->charability == CA_BOUNCE && thing->player->panim == PA_ABILITY && thing->eflags & MFE_VERTICALFLIP)) - P_DamageMobj(thing, tmthing, tmthing, 1, DMG_SPIKE); - } - else if (thing->z >= tmthing->z + tmthing->height - FixedMul(FRACUNIT, tmthing->scale) - && thing->z + thing->momz <= tmthing->z + tmthing->height - FixedMul(FRACUNIT, tmthing->scale) + tmthing->momz - && !(thing->player->charability == CA_BOUNCE && thing->player->panim == PA_ABILITY && !(thing->eflags & MFE_VERTICALFLIP))) - P_DamageMobj(thing, tmthing, tmthing, 1, DMG_SPIKE); - } - else if (thing->type == MT_SPIKE && thing->flags & MF_SOLID && tmthing->player) // unfortunate player falls into spike?! - { - if (thing->eflags & MFE_VERTICALFLIP) - { - if (tmthing->z + tmthing->height <= thing->z - FixedMul(FRACUNIT, thing->scale) - && tmthing->z + tmthing->height + tmthing->momz >= thing->z - FixedMul(FRACUNIT, thing->scale) - && !(tmthing->player->charability == CA_BOUNCE && tmthing->player->panim == PA_ABILITY && tmthing->eflags & MFE_VERTICALFLIP)) - P_DamageMobj(tmthing, thing, thing, 1, DMG_SPIKE); - } - else if (tmthing->z >= thing->z + thing->height + FixedMul(FRACUNIT, thing->scale) - && tmthing->z + tmthing->momz <= thing->z + thing->height + FixedMul(FRACUNIT, thing->scale) - && !(tmthing->player->charability == CA_BOUNCE && tmthing->player->panim == PA_ABILITY && !(tmthing->eflags & MFE_VERTICALFLIP))) - P_DamageMobj(tmthing, thing, thing, 1, DMG_SPIKE); - } - - if (tmthing->type == MT_WALLSPIKE && tmthing->flags & MF_SOLID && thing->player) // wall spike impales player - { - fixed_t bottomz, topz; - bottomz = tmthing->z; - topz = tmthing->z + tmthing->height; - if (tmthing->eflags & MFE_VERTICALFLIP) - bottomz -= FixedMul(FRACUNIT, tmthing->scale); - else - topz += FixedMul(FRACUNIT, tmthing->scale); - - if (thing->z + thing->height > bottomz // above bottom - && thing->z < topz) // below top - // don't check angle, the player was clearly in the way in this case - P_DamageMobj(thing, tmthing, tmthing, 1, DMG_SPIKE); - } - else if (thing->type == MT_WALLSPIKE && thing->flags & MF_SOLID && tmthing->player) - { - fixed_t bottomz, topz; - angle_t touchangle = R_PointToAngle2(thing->tracer->x, thing->tracer->y, tmthing->x, tmthing->y); - - if (P_PlayerInPain(tmthing->player) && (tmthing->momx || tmthing->momy)) - { - angle_t playerangle = R_PointToAngle2(0, 0, tmthing->momx, tmthing->momy) - touchangle; - if (playerangle > ANGLE_180) - playerangle = InvAngle(playerangle); - if (playerangle < ANGLE_90) - return true; // Yes, this is intentionally outside the z-height check. No standing on spikes whilst moving away from them. - } - - bottomz = thing->z; - topz = thing->z + thing->height; - - if (thing->eflags & MFE_VERTICALFLIP) - bottomz -= FixedMul(FRACUNIT, thing->scale); - else - topz += FixedMul(FRACUNIT, thing->scale); - - if (tmthing->z + tmthing->height > bottomz // above bottom - && tmthing->z < topz // below top - && !P_MobjWasRemoved(thing->tracer)) // this probably wouldn't work if we didn't have a tracer - { // use base as a reference point to determine what angle you touched the spike at - touchangle = thing->angle - touchangle; - if (touchangle > ANGLE_180) - touchangle = InvAngle(touchangle); - if (touchangle <= ANGLE_22h) // if you touched it at this close an angle, you get poked! - P_DamageMobj(tmthing, thing, thing, 1, DMG_SPIKE); - } - } - if (thing->flags & MF_PUSHABLE) { if (tmthing->type == MT_FAN || tmthing->type == MT_STEAM) @@ -1623,6 +1543,22 @@ static boolean PIT_CheckThing(mobj_t *thing) if (thing->player) { + if (tmthing->type == MT_WALLSPIKE && (tmthing->flags & MF_SOLID)) // wall spike impales player + { + fixed_t bottomz, topz; + bottomz = tmthing->z; + topz = tmthing->z + tmthing->height; + if (tmthing->eflags & MFE_VERTICALFLIP) + bottomz -= FixedMul(FRACUNIT, tmthing->scale); + else + topz += FixedMul(FRACUNIT, tmthing->scale); + + if (thing->z + thing->height > bottomz // above bottom + && thing->z < topz) // below top + // don't check angle, the player was clearly in the way in this case + P_DamageMobj(thing, tmthing, tmthing, 1, DMG_SPIKE); + } + // Doesn't matter what gravity player's following! Just do your stuff in YOUR direction only if (tmthing->eflags & MFE_VERTICALFLIP && (tmthing->z + tmthing->height + tmthing->momz < thing->z @@ -1657,6 +1593,55 @@ static boolean PIT_CheckThing(mobj_t *thing) if (!tmthing->health) return true; + if (thing->type == MT_SPIKE && (thing->flags & MF_SOLID)) // unfortunate player falls into spike?! + { + if (thing->eflags & MFE_VERTICALFLIP) + { + if (tmthing->z + tmthing->height <= thing->z - FixedMul(FRACUNIT, thing->scale) + && tmthing->z + tmthing->height + tmthing->momz >= thing->z - FixedMul(FRACUNIT, thing->scale) + && !(tmthing->player->charability == CA_BOUNCE && tmthing->player->panim == PA_ABILITY && tmthing->eflags & MFE_VERTICALFLIP)) + P_DamageMobj(tmthing, thing, thing, 1, DMG_SPIKE); + } + else if (tmthing->z >= thing->z + thing->height + FixedMul(FRACUNIT, thing->scale) + && tmthing->z + tmthing->momz <= thing->z + thing->height + FixedMul(FRACUNIT, thing->scale) + && !(tmthing->player->charability == CA_BOUNCE && tmthing->player->panim == PA_ABILITY && !(tmthing->eflags & MFE_VERTICALFLIP))) + P_DamageMobj(tmthing, thing, thing, 1, DMG_SPIKE); + } + + if (thing->type == MT_WALLSPIKE && (thing->flags & MF_SOLID)) + { + fixed_t bottomz, topz; + angle_t touchangle = R_PointToAngle2(thing->tracer->x, thing->tracer->y, tmthing->x, tmthing->y); + + if (P_PlayerInPain(tmthing->player) && (tmthing->momx || tmthing->momy)) + { + angle_t playerangle = R_PointToAngle2(0, 0, tmthing->momx, tmthing->momy) - touchangle; + if (playerangle > ANGLE_180) + playerangle = InvAngle(playerangle); + if (playerangle < ANGLE_90) + return true; // Yes, this is intentionally outside the z-height check. No standing on spikes whilst moving away from them. + } + + bottomz = thing->z; + topz = thing->z + thing->height; + + if (thing->eflags & MFE_VERTICALFLIP) + bottomz -= FixedMul(FRACUNIT, thing->scale); + else + topz += FixedMul(FRACUNIT, thing->scale); + + if (tmthing->z + tmthing->height > bottomz // above bottom + && tmthing->z < topz // below top + && !P_MobjWasRemoved(thing->tracer)) // this probably wouldn't work if we didn't have a tracer + { // use base as a reference point to determine what angle you touched the spike at + touchangle = thing->angle - touchangle; + if (touchangle > ANGLE_180) + touchangle = InvAngle(touchangle); + if (touchangle <= ANGLE_22h) // if you touched it at this close an angle, you get poked! + P_DamageMobj(tmthing, thing, thing, 1, DMG_SPIKE); + } + } + if (thing->type == MT_FAN || thing->type == MT_STEAM) P_DoFanAndGasJet(thing, tmthing); else if (thing->flags & MF_SPRING && tmthing->player->powers[pw_carry] != CR_MINECART) @@ -1721,8 +1706,8 @@ static boolean PIT_CheckThing(mobj_t *thing) } } - if ((tmthing->flags & MF_SPRING || tmthing->type == MT_STEAM || tmthing->type == MT_SPIKE || tmthing->type == MT_WALLSPIKE) && (thing->player)) - ; // springs, gas jets and springs should never be able to step up onto a player + if ((thing->player) && (tmthing->flags & MF_SPRING || tmthing->type == MT_STEAM)) + ; // springs and gas jets should never be able to step up onto a player // z checking at last // Treat noclip things as non-solid! else if ((thing->flags & (MF_SOLID|MF_NOCLIP)) == MF_SOLID @@ -1730,6 +1715,9 @@ static boolean PIT_CheckThing(mobj_t *thing) { fixed_t topz, tmtopz; + if (tmthing->type == MT_SPIKE || tmthing->type == MT_WALLSPIKE) // do not run height checks if you are a spike + return true; + if (tmthing->eflags & MFE_VERTICALFLIP) { // pass under diff --git a/src/p_mobj.c b/src/p_mobj.c index 83f9ebf3c..e43414a80 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -7842,6 +7842,48 @@ static void P_MobjSceneryThink(mobj_t *mobj) if (P_MobjFlip(mobj)*mobj->momz < mobj->info->speed) mobj->momz = P_MobjFlip(mobj)*mobj->info->speed; break; + case MT_SPIKE: + if (mobj->fuse) + { + mobj->fuse--; + break; + } + P_SetMobjState(mobj, mobj->state->nextstate); + mobj->fuse = mobj->info->speed; + if (mobj->spawnpoint) + mobj->fuse += mobj->spawnpoint->angle; + break; + case MT_WALLSPIKE: + if (mobj->fuse) + { + mobj->fuse--; + break; + } + P_SetMobjState(mobj, mobj->state->nextstate); + mobj->fuse = mobj->info->speed; + if (mobj->spawnpoint) + mobj->fuse += (mobj->spawnpoint->angle / 360); + break; + case MT_WALLSPIKEBASE: + if (!mobj->target) + { + P_RemoveMobj(mobj); + return; + } + mobj->frame = (mobj->frame & ~FF_FRAMEMASK)|(mobj->target->frame & FF_FRAMEMASK); +#if 0 + if (mobj->angle != mobj->target->angle + ANGLE_90) // reposition if not the correct angle + { + mobj_t* target = mobj->target; // shortcut + const fixed_t baseradius = target->radius - (target->scale/2); //FixedMul(FRACUNIT/2, target->scale); + P_UnsetThingPosition(mobj); + mobj->x = target->x - P_ReturnThrustX(target, target->angle, baseradius); + mobj->y = target->y - P_ReturnThrustY(target, target->angle, baseradius); + P_SetThingPosition(mobj); + mobj->angle = target->angle + ANGLE_90; + } +#endif + break; case MT_ROCKCRUMBLE1: case MT_ROCKCRUMBLE2: case MT_ROCKCRUMBLE3: @@ -9238,25 +9280,6 @@ static boolean P_MobjRegularThink(mobj_t *mobj) switch (mobj->type) { - case MT_WALLSPIKEBASE: - if (!mobj->target) { - P_RemoveMobj(mobj); - return false; - } - mobj->frame = (mobj->frame & ~FF_FRAMEMASK)|(mobj->target->frame & FF_FRAMEMASK); -#if 0 - if (mobj->angle != mobj->target->angle + ANGLE_90) // reposition if not the correct angle - { - mobj_t* target = mobj->target; // shortcut - const fixed_t baseradius = target->radius - (target->scale/2); //FixedMul(FRACUNIT/2, target->scale); - P_UnsetThingPosition(mobj); - mobj->x = target->x - P_ReturnThrustX(target, target->angle, baseradius); - mobj->y = target->y - P_ReturnThrustY(target, target->angle, baseradius); - P_SetThingPosition(mobj); - mobj->angle = target->angle + ANGLE_90; - } -#endif - break; case MT_FALLINGROCK: // Despawn rocks here in case zmovement code can't do so (blame slopes) if (!mobj->momx && !mobj->momy && !mobj->momz @@ -9942,18 +9965,6 @@ static boolean P_FuseThink(mobj_t *mobj) break; case MT_METALSONIC_BATTLE: break; // don't remove - case MT_SPIKE: - P_SetMobjState(mobj, mobj->state->nextstate); - mobj->fuse = mobj->info->speed; - if (mobj->spawnpoint) - mobj->fuse += mobj->spawnpoint->angle; - break; - case MT_WALLSPIKE: - P_SetMobjState(mobj, mobj->state->nextstate); - mobj->fuse = mobj->info->speed; - if (mobj->spawnpoint) - mobj->fuse += (mobj->spawnpoint->angle / 360); - break; case MT_NIGHTSCORE: P_RemoveMobj(mobj); return false; @@ -12956,17 +12967,18 @@ static boolean P_SetupSpawnedMapThing(mapthing_t *mthing, mobj_t *mobj, boolean // Pop up spikes! if (mthing->options & MTF_OBJECTSPECIAL) { - mobj->flags &= ~MF_SCENERY; mobj->fuse = (16 - mthing->extrainfo)*(mthing->angle + mobj->info->speed)/16; if (mthing->options & MTF_EXTRA) P_SetMobjState(mobj, mobj->info->meleestate); } - // Use per-thing collision for spikes if the deaf flag isn't checked. - if (!(mthing->options & MTF_AMBUSH) && !metalrecording) + else + mobj->flags |= MF_NOTHINK; + // no collision for spikes if the ambush flag is checked + if ((mthing->options & MTF_AMBUSH) || metalrecording) { P_UnsetThingPosition(mobj); - mobj->flags &= ~(MF_NOBLOCKMAP|MF_NOGRAVITY|MF_NOCLIPHEIGHT); - mobj->flags |= MF_SOLID; + mobj->flags |= (MF_NOBLOCKMAP|MF_NOCLIPHEIGHT); + mobj->flags &= ~MF_SOLID; P_SetThingPosition(mobj); } break; @@ -12974,20 +12986,20 @@ static boolean P_SetupSpawnedMapThing(mapthing_t *mthing, mobj_t *mobj, boolean // Pop up spikes! if (mthing->options & MTF_OBJECTSPECIAL) { - mobj->flags &= ~MF_SCENERY; mobj->fuse = (16 - mthing->extrainfo)*((mthing->angle/360) + mobj->info->speed)/16; if (mthing->options & MTF_EXTRA) P_SetMobjState(mobj, mobj->info->meleestate); } - // Use per-thing collision for spikes if the deaf flag isn't checked. - if (!(mthing->options & MTF_AMBUSH) && !metalrecording) + else + mobj->flags |= MF_NOTHINK; + // no collision for spikes if the ambush flag is checked + if ((mthing->options & MTF_AMBUSH) || metalrecording) { P_UnsetThingPosition(mobj); - mobj->flags &= ~(MF_NOBLOCKMAP | MF_NOCLIPHEIGHT); - mobj->flags |= MF_SOLID; + mobj->flags |= (MF_NOBLOCKMAP|MF_NOCLIPHEIGHT); + mobj->flags &= ~MF_SOLID; P_SetThingPosition(mobj); } - // spawn base { const angle_t mobjangle = FixedAngle(mthing->angle << FRACBITS); // the mobj's own angle hasn't been set quite yet so... @@ -13001,6 +13013,8 @@ static boolean P_SetupSpawnedMapThing(mapthing_t *mthing, mobj_t *mobj, boolean P_SetScale(base, mobj->scale); P_SetTarget(&base->target, mobj); P_SetTarget(&mobj->tracer, base); + if (!(mthing->options & MTF_OBJECTSPECIAL)) + base->flags |= MF_NOTHINK; } break; case MT_RING_BOX: From fdc825721f5f2961e29defb52f32de69c870f7bc Mon Sep 17 00:00:00 2001 From: spherallic Date: Sun, 5 Dec 2021 12:47:20 +0100 Subject: [PATCH 0970/1080] some hud fixes, by Confusion --- src/hu_stuff.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/hu_stuff.c b/src/hu_stuff.c index f4c5e4c3b..3107057a1 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -2472,7 +2472,7 @@ static void HU_Draw32TeamTabRankings(playersort_t *tab, INT32 whiteplayer) if (!players[tab[i].num].quittime || (leveltime / (TICRATE/2) & 1)) V_DrawString(x + 10, y, ((tab[i].num == whiteplayer) ? V_YELLOWMAP : 0) - | (greycheck ? 0 : V_TRANSLUCENT) + | (greycheck ? V_TRANSLUCENT : 0) | V_ALLOWLOWERCASE, name); if (gametyperules & GTR_TEAMFLAGS) @@ -2733,12 +2733,12 @@ void HU_DrawDualTabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scoreline if (circuitmap) { if (players[tab[i].num].exiting) - V_DrawRightAlignedThinString(x+146, y, 0, va("%i:%02i.%02i", G_TicsToMinutes(players[tab[i].num].realtime,true), G_TicsToSeconds(players[tab[i].num].realtime), G_TicsToCentiseconds(players[tab[i].num].realtime))); + V_DrawRightAlignedThinString(x+100, y, 0, va("%i:%02i.%02i", G_TicsToMinutes(players[tab[i].num].realtime,true), G_TicsToSeconds(players[tab[i].num].realtime), G_TicsToCentiseconds(players[tab[i].num].realtime))); else - V_DrawRightAlignedThinString(x+146, y, (greycheck ? V_TRANSLUCENT : 0), va("%u", tab[i].count)); + V_DrawRightAlignedThinString(x+100, y, (greycheck ? V_TRANSLUCENT : 0), va("%u", tab[i].count)); } else - V_DrawRightAlignedThinString(x+146, y, (greycheck ? V_TRANSLUCENT : 0), va("%i:%02i.%02i", G_TicsToMinutes(tab[i].count,true), G_TicsToSeconds(tab[i].count), G_TicsToCentiseconds(tab[i].count))); + V_DrawRightAlignedThinString(x+100, y, (greycheck ? V_TRANSLUCENT : 0), va("%i:%02i.%02i", G_TicsToMinutes(tab[i].count,true), G_TicsToSeconds(tab[i].count), G_TicsToCentiseconds(tab[i].count))); } else V_DrawRightAlignedThinString(x+100, y, (greycheck ? V_TRANSLUCENT : 0), va("%u", tab[i].count)); @@ -2786,7 +2786,7 @@ static void HU_Draw32TabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scor if (!players[tab[i].num].quittime || (leveltime / (TICRATE/2) & 1)) V_DrawString(x + 10, y, ((tab[i].num == whiteplayer) ? V_YELLOWMAP : 0) - | (greycheck ? 0 : V_TRANSLUCENT) + | (greycheck ? V_TRANSLUCENT : 0) | V_ALLOWLOWERCASE, name); if (G_GametypeUsesLives()) //show lives @@ -2846,13 +2846,13 @@ static void HU_Draw32TabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scor if (players[tab[i].num].exiting) V_DrawRightAlignedThinString(x+128, y, 0, va("%i:%02i.%02i", G_TicsToMinutes(players[tab[i].num].realtime,true), G_TicsToSeconds(players[tab[i].num].realtime), G_TicsToCentiseconds(players[tab[i].num].realtime))); else - V_DrawRightAlignedThinString(x+128, y, (greycheck ? 0 : V_TRANSLUCENT), va("%u", tab[i].count)); + V_DrawRightAlignedThinString(x+128, y, (greycheck ? V_TRANSLUCENT : 0), va("%u", tab[i].count)); } else - V_DrawRightAlignedThinString(x+128, y, (greycheck ? 0 : V_TRANSLUCENT), va("%i:%02i.%02i", G_TicsToMinutes(tab[i].count,true), G_TicsToSeconds(tab[i].count), G_TicsToCentiseconds(tab[i].count))); + V_DrawRightAlignedThinString(x+128, y, (greycheck ? V_TRANSLUCENT : 0), va("%i:%02i.%02i", G_TicsToMinutes(tab[i].count,true), G_TicsToSeconds(tab[i].count), G_TicsToCentiseconds(tab[i].count))); } else - V_DrawRightAlignedThinString(x+128, y, (greycheck ? 0 : V_TRANSLUCENT), va("%u", tab[i].count)); + V_DrawRightAlignedThinString(x+128, y, (greycheck ? V_TRANSLUCENT : 0), va("%u", tab[i].count)); y += 9; if (i == 16) @@ -3091,7 +3091,7 @@ static void HU_DrawRankings(void) HU_DrawTeamTabRankings(tab, whiteplayer); else if (scorelines <= 9 && !cv_compactscoreboard.value) HU_DrawTabRankings(40, 32, tab, scorelines, whiteplayer); - else if (scorelines <= 20 && !cv_compactscoreboard.value) + else if (scorelines <= 18 && !cv_compactscoreboard.value) HU_DrawDualTabRankings(32, 32, tab, scorelines, whiteplayer); else HU_Draw32TabRankings(14, 28, tab, scorelines, whiteplayer); From f271f88c7f3084523a03ca7f47060d6527724796 Mon Sep 17 00:00:00 2001 From: LJ Sonic Date: Sun, 5 Dec 2021 17:59:33 +0100 Subject: [PATCH 0971/1080] Fix MusicChange hook crashing when called BRUH MOMENT BRUH MOMENT PREPARE THE HALL OF SHAME --- src/lua_hooklib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lua_hooklib.c b/src/lua_hooklib.c index a72b22b5a..287a185bc 100644 --- a/src/lua_hooklib.c +++ b/src/lua_hooklib.c @@ -1117,7 +1117,7 @@ int LUA_HookMusicChange(const char *oldname, struct MusicChange *param) lua_pushstring(gL, oldname);/* the only constant value */ lua_pushstring(gL, param->newname);/* semi constant */ - for (k = 0; k <= map->numHooks; ++k) + for (k = 0; k < map->numHooks; ++k) { get_hook(&hook, map->ids, k); From 97e2fe18c6d36fae3d1321de3d26e47163ba5d84 Mon Sep 17 00:00:00 2001 From: katsy Date: Mon, 6 Dec 2021 18:00:30 -0600 Subject: [PATCH 0972/1080] fix spike sandwich teleportation issue --- src/p_map.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/p_map.c b/src/p_map.c index 836e75c4e..59756d8a6 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -1152,9 +1152,9 @@ static boolean PIT_CheckThing(mobj_t *thing) return true; // underneath if (tmthing->eflags & MFE_VERTICALFLIP) - thing->z = tmthing->z - thing->height - FixedMul(FRACUNIT, tmthing->scale); + P_TeleportMove(thing, thing->x, thing->y, tmthing->z - thing->height - FixedMul(FRACUNIT, tmthing->scale)); else - thing->z = tmthing->z + tmthing->height + FixedMul(FRACUNIT, tmthing->scale); + P_TeleportMove(thing, thing->x, thing->y, tmthing->z + tmthing->height + FixedMul(FRACUNIT, tmthing->scale)); if (thing->flags & MF_SHOOTABLE) P_DamageMobj(thing, tmthing, tmthing, 1, DMG_SPIKE); return true; From f3c5addab7cb028c164b8af149402e9d11aef1ef Mon Sep 17 00:00:00 2001 From: Hannu Hanhi Date: Tue, 7 Dec 2021 22:35:04 +0200 Subject: [PATCH 0973/1080] Improve OpenGL GDI Generic error message --- src/sdl/ogl_sdl.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/sdl/ogl_sdl.c b/src/sdl/ogl_sdl.c index c426e6792..bdc693ca5 100644 --- a/src/sdl/ogl_sdl.c +++ b/src/sdl/ogl_sdl.c @@ -177,7 +177,9 @@ boolean OglSdlSurface(INT32 w, INT32 h) // Also set the renderer variable back to software so the next launch won't // repeat this error. CV_StealthSet(&cv_renderer, "Software"); - I_Error("OpenGL Error: Failed to access the GPU. There may be an issue with your graphics drivers."); + I_Error("OpenGL Error: Failed to access the GPU. Possible reasons include:\n" + "- GPU vendor has dropped OpenGL support on your GPU and OS. (Old GPU?)\n" + "- GPU drivers are missing or broken. You may need to update your drivers."); } } first_init = true; From c420de6f119c8b362dcc4991a544928ccca6bba5 Mon Sep 17 00:00:00 2001 From: John FrostFox Date: Thu, 9 Dec 2021 11:42:06 +0300 Subject: [PATCH 0974/1080] Include pmomz for mobjs in net savestates and load if it exists --- src/p_saveg.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index 1270064c0..722340f41 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -1603,7 +1603,7 @@ static void SaveMobjThinker(const thinker_t *th, const UINT8 type) diff2 = 0; // not the default but the most probable - if (mobj->momx != 0 || mobj->momy != 0 || mobj->momz != 0) + if (mobj->momx != 0 || mobj->momy != 0 || mobj->momz != 0 || mobj->pmomz !=0) diff |= MD_MOM; if (mobj->radius != mobj->info->radius) diff |= MD_RADIUS; @@ -1778,6 +1778,7 @@ static void SaveMobjThinker(const thinker_t *th, const UINT8 type) WRITEFIXED(save_p, mobj->momx); WRITEFIXED(save_p, mobj->momy); WRITEFIXED(save_p, mobj->momz); + WRITEFIXED(save_p, mobj->pmomz); } if (diff & MD_RADIUS) WRITEFIXED(save_p, mobj->radius); @@ -2776,6 +2777,7 @@ static thinker_t* LoadMobjThinker(actionf_p1 thinker) mobj->momx = READFIXED(save_p); mobj->momy = READFIXED(save_p); mobj->momz = READFIXED(save_p); + mobj->pmomz = READFIXED(save_p); } // otherwise they're zero, and the memset took care of it if (diff & MD_RADIUS) From 6f5b34f7c16e3012b481a7522613b3dcc744a4fe Mon Sep 17 00:00:00 2001 From: spherallic Date: Thu, 9 Dec 2021 12:45:18 +0100 Subject: [PATCH 0975/1080] Don't award end-of-level bonuses to bots. --- src/y_inter.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/y_inter.c b/src/y_inter.c index f24436d40..288a821e6 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -2023,7 +2023,7 @@ static void Y_AwardCoopBonuses(void) for (i = 0; i < MAXPLAYERS; ++i) { - if (!playeringame[i] || players[i].lives < 1) // not active or game over + if (!playeringame[i] || players[i].lives < 1 || players[i].bot == BOT_2PAI || players[i].bot == BOT_2PHUMAN) // not active, game over or tails bot bonusnum = 0; // all null else bonusnum = mapheaderinfo[prevmap]->bonustype + 1; // -1 is none @@ -2073,7 +2073,7 @@ static void Y_AwardSpecialStageBonus(void) { oldscore = players[i].score; - if (!playeringame[i] || players[i].lives < 1) // not active or game over + if (!playeringame[i] || players[i].lives < 1 || players[i].bot == BOT_2PAI || players[i].bot == BOT_2PHUMAN) // not active, game over or tails bot { Y_SetNullBonus(&players[i], &localbonuses[0]); Y_SetNullBonus(&players[i], &localbonuses[1]); From f431b209112b451d0caea4ed245596f4e86b2726 Mon Sep 17 00:00:00 2001 From: MascaraSnake Date: Sun, 12 Dec 2021 06:54:48 +0100 Subject: [PATCH 0976/1080] Add new blendmode linedef types to config --- extras/conf/SRB2-22.cfg | 186 +++++++++++++++++++ extras/conf/udb/Includes/SRB222_linedefs.cfg | 155 ++++++++++++++++ 2 files changed, 341 insertions(+) diff --git a/extras/conf/SRB2-22.cfg b/extras/conf/SRB2-22.cfg index 4ed68e1ca..2b4bdbcd7 100644 --- a/extras/conf/SRB2-22.cfg +++ b/extras/conf/SRB2-22.cfg @@ -3251,6 +3251,192 @@ linedeftypes title = "Fog Wall"; prefix = "(909)"; } + + 910 + { + title = "100% Additive"; + prefix = "(910)"; + } + + 911 + { + title = "90% Additive"; + prefix = "(911)"; + } + + 912 + { + title = "80% Additive"; + prefix = "(912)"; + } + + 913 + { + title = "70% Additive"; + prefix = "(913)"; + } + + 914 + { + title = "60% Additive"; + prefix = "(914)"; + } + + 915 + { + title = "50% Additive"; + prefix = "(915)"; + } + + 916 + { + title = "40% Additive"; + prefix = "(916)"; + } + + 917 + { + title = "30% Additive"; + prefix = "(917)"; + } + + 918 + { + title = "20% Additive"; + prefix = "(918)"; + } + + 919 + { + title = "10% Additive"; + prefix = "(919)"; + } + + 920 + { + title = "100% Subtractive"; + prefix = "(920)"; + } + + 921 + { + title = "90% Subtractive"; + prefix = "(921)"; + } + + 922 + { + title = "80% Subtractive"; + prefix = "(922)"; + } + + 923 + { + title = "70% Subtractive"; + prefix = "(923)"; + } + + 924 + { + title = "60% Subtractive"; + prefix = "(924)"; + } + + 925 + { + title = "50% Subtractive"; + prefix = "(925)"; + } + + 926 + { + title = "40% Subtractive"; + prefix = "(926)"; + } + + 927 + { + title = "30% Subtractive"; + prefix = "(927)"; + } + + 928 + { + title = "20% Subtractive"; + prefix = "(928)"; + } + + 929 + { + title = "10% Subtractive"; + prefix = "(929)"; + } + + 930 + { + title = "100% Reverse Subtractive"; + prefix = "(930)"; + } + + 931 + { + title = "90% Reverse Subtractive"; + prefix = "(931)"; + } + + 932 + { + title = "80% Reverse Subtractive"; + prefix = "(932)"; + } + + 933 + { + title = "70% Reverse Subtractive"; + prefix = "(933)"; + } + + 934 + { + title = "60% Reverse Subtractive"; + prefix = "(934)"; + } + + 935 + { + title = "50% Reverse Subtractive"; + prefix = "(935)"; + } + + 936 + { + title = "40% Reverse Subtractive"; + prefix = "(936)"; + } + + 937 + { + title = "30% Reverse Subtractive"; + prefix = "(937)"; + } + + 938 + { + title = "20% Reverse Subtractive"; + prefix = "(938)"; + } + + 939 + { + title = "10% Reverse Subtractive"; + prefix = "(939)"; + } + + 940 + { + title = "Modulate"; + prefix = "(940)"; + } } } diff --git a/extras/conf/udb/Includes/SRB222_linedefs.cfg b/extras/conf/udb/Includes/SRB222_linedefs.cfg index 1f87c2c3a..c6b0cb1c8 100644 --- a/extras/conf/udb/Includes/SRB222_linedefs.cfg +++ b/extras/conf/udb/Includes/SRB222_linedefs.cfg @@ -1500,6 +1500,161 @@ doom title = "Fog Wall"; prefix = "(909)"; } + 910 + { + title = "100% Additive"; + prefix = "(910)"; + } + 911 + { + title = "90% Additive"; + prefix = "(911)"; + } + 912 + { + title = "80% Additive"; + prefix = "(912)"; + } + 913 + { + title = "70% Additive"; + prefix = "(913)"; + } + 914 + { + title = "60% Additive"; + prefix = "(914)"; + } + 915 + { + title = "50% Additive"; + prefix = "(915)"; + } + 916 + { + title = "40% Additive"; + prefix = "(916)"; + } + 917 + { + title = "30% Additive"; + prefix = "(917)"; + } + 918 + { + title = "20% Additive"; + prefix = "(918)"; + } + 919 + { + title = "10% Additive"; + prefix = "(919)"; + } + 920 + { + title = "100% Subtractive"; + prefix = "(920)"; + } + 921 + { + title = "90% Subtractive"; + prefix = "(921)"; + } + 922 + { + title = "80% Subtractive"; + prefix = "(922)"; + } + 923 + { + title = "70% Subtractive"; + prefix = "(923)"; + } + 924 + { + title = "60% Subtractive"; + prefix = "(924)"; + } + 925 + { + title = "50% Subtractive"; + prefix = "(925)"; + } + 926 + { + title = "40% Subtractive"; + prefix = "(926)"; + } + 927 + { + title = "30% Subtractive"; + prefix = "(927)"; + } + 928 + { + title = "20% Subtractive"; + prefix = "(928)"; + } + 929 + { + title = "10% Subtractive"; + prefix = "(929)"; + } + 930 + { + title = "100% Reverse Subtractive"; + prefix = "(930)"; + } + 931 + { + title = "90% Reverse Subtractive"; + prefix = "(931)"; + } + 932 + { + title = "80% Reverse Subtractive"; + prefix = "(932)"; + } + 933 + { + title = "70% Reverse Subtractive"; + prefix = "(933)"; + } + 934 + { + title = "60% Reverse Subtractive"; + prefix = "(934)"; + } + 935 + { + title = "50% Reverse Subtractive"; + prefix = "(935)"; + } + 936 + { + title = "40% Reverse Subtractive"; + prefix = "(936)"; + } + 937 + { + title = "30% Reverse Subtractive"; + prefix = "(937)"; + } + 938 + { + title = "20% Reverse Subtractive"; + prefix = "(938)"; + } + 939 + { + title = "10% Reverse Subtractive"; + prefix = "(939)"; + } + 940 + { + title = "Modulate"; + prefix = "(940)"; + } } } From ac3dd146c7cf238df536f47d2649e276cbaf798f Mon Sep 17 00:00:00 2001 From: MascaraSnake Date: Sun, 12 Dec 2021 07:02:17 +0100 Subject: [PATCH 0977/1080] Expose blendmodes to UDMF --- extras/conf/udb/Includes/SRB222_common.cfg | 4 ++-- extras/conf/udb/Includes/SRB222_misc.cfg | 9 ++++++--- src/p_setup.c | 13 +++++++++++++ 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/extras/conf/udb/Includes/SRB222_common.cfg b/extras/conf/udb/Includes/SRB222_common.cfg index d67835aeb..b752e3654 100644 --- a/extras/conf/udb/Includes/SRB222_common.cfg +++ b/extras/conf/udb/Includes/SRB222_common.cfg @@ -264,10 +264,10 @@ mapformat_udmf } // LINEDEF RENDERSTYLES - /*linedefrenderstyles + linedefrenderstyles { include("SRB222_misc.cfg", "linedefrenderstyles"); - }*/ + } // THING FLAGS thingflags diff --git a/extras/conf/udb/Includes/SRB222_misc.cfg b/extras/conf/udb/Includes/SRB222_misc.cfg index 68629149e..1b4fb4b4b 100644 --- a/extras/conf/udb/Includes/SRB222_misc.cfg +++ b/extras/conf/udb/Includes/SRB222_misc.cfg @@ -63,11 +63,14 @@ linedefflags_udmf transfer = "Transfer Line"; } -/*linedefrenderstyles +linedefrenderstyles { translucent = "Translucent"; - fog = "Fog"; -}*/ + add = "Add"; + subtract = "Subtract"; + reversesubtract = "Reverse subtract"; + modulate = "Modulate"; +} sectorflags { diff --git a/src/p_setup.c b/src/p_setup.c index 6320edc22..6f0e11c03 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -1701,6 +1701,19 @@ static void ParseTextmapLinedefParameter(UINT32 i, char *param, char *val) lines[i].sidenum[1] = atol(val); else if (fastcmp(param, "alpha")) lines[i].alpha = FLOAT_TO_FIXED(atof(val)); + else if (fastcmp(param, "blendmode") || fastcmp(param, "renderstyle")) + { + if (fastcmp(val, "translucent")) + lines[i].blendmode = AST_COPY; + else if (fastcmp(val, "add")) + lines[i].blendmode = AST_ADD; + else if (fastcmp(val, "subtract")) + lines[i].blendmode = AST_SUBTRACT; + else if (fastcmp(val, "reversesubtract")) + lines[i].blendmode = AST_REVERSESUBTRACT; + else if (fastcmp(val, "modulate")) + lines[i].blendmode = AST_MODULATE; + } else if (fastcmp(param, "executordelay")) lines[i].executordelay = atol(val); From 2794727201c2ec38ef8d9640f1cfb0b3e03fa3f6 Mon Sep 17 00:00:00 2001 From: lachablock Date: Sun, 12 Dec 2021 18:52:27 +1100 Subject: [PATCH 0978/1080] Improve bot handling: - bot ticcmds are generated and sent by the server only - fix issue where server would not send all ticcmds to clients if bots were in the game - fix bots still responding to P1's inputs while P1's controls are locked - fix bot player's directional controls being rotated when controlled by P2 --- src/b_bot.c | 65 +++++++++++++++++++++++++++++---------------- src/d_clisrv.c | 31 +++++++++++++++++++++ src/d_ticcmd.h | 9 +++++++ src/deh_tables.c | 5 ++++ src/g_demo.c | 12 +++++++++ src/g_game.c | 63 +++++++++++++++---------------------------- src/lua_baselib.c | 3 +++ src/lua_playerlib.c | 4 +++ src/p_saveg.c | 43 +++++++++++++++++++----------- src/p_user.c | 12 ++++++--- 10 files changed, 164 insertions(+), 83 deletions(-) diff --git a/src/b_bot.c b/src/b_bot.c index cdd74fc07..ffdcace6d 100644 --- a/src/b_bot.c +++ b/src/b_bot.c @@ -127,17 +127,17 @@ static void B_BuildTailsTiccmd(mobj_t *sonic, mobj_t *tails, ticcmd_t *cmd) // Update catchup_tics if (mem->thinkstate == AI_SPINFOLLOW) { - mem-> catchup_tics = 0; + mem->catchup_tics = 0; } else if (dist > followmax || zdist > comfortheight || stalled) { - mem-> catchup_tics = min(mem-> catchup_tics + 2, 70); - if (mem-> catchup_tics >= 70) + mem->catchup_tics = min(mem->catchup_tics + 2, 70); + if (mem->catchup_tics >= 70) mem->thinkstate = AI_CATCHUP; } else { - mem-> catchup_tics = max(mem-> catchup_tics - 1, 0); + mem->catchup_tics = max(mem->catchup_tics - 1, 0); if (mem->thinkstate == AI_CATCHUP) mem->thinkstate = AI_FOLLOW; } @@ -171,7 +171,6 @@ static void B_BuildTailsTiccmd(mobj_t *sonic, mobj_t *tails, ticcmd_t *cmd) { jump = true; mem->thinkstate = AI_FLYSTANDBY; - bot->pflags |= PF_CANCARRY; } } @@ -183,7 +182,10 @@ static void B_BuildTailsTiccmd(mobj_t *sonic, mobj_t *tails, ticcmd_t *cmd) && P_IsObjectOnGround(sonic) && P_IsObjectOnGround(tails) && !(player->pflags & PF_STASIS) && bot->charability == CA_FLY) - mem->thinkstate = AI_THINKFLY; + { + mem->thinkstate = AI_THINKFLY; + cmd->flags |= TCF_FLIGHTINDICATOR; + } else if (mem->thinkstate == AI_THINKFLY) mem->thinkstate = AI_FOLLOW; @@ -204,6 +206,8 @@ static void B_BuildTailsTiccmd(mobj_t *sonic, mobj_t *tails, ticcmd_t *cmd) // Abort if the player moves away or spins if (dist > followthres || player->dashspeed) mem->thinkstate = AI_FOLLOW; + else + cmd->flags |= TCF_SETCARRY; } // Read player inputs while carrying else if (mem->thinkstate == AI_FLYCARRY) @@ -312,7 +316,6 @@ static void B_BuildTailsTiccmd(mobj_t *sonic, mobj_t *tails, ticcmd_t *cmd) { // Copy inputs cmd->angleturn = (sonic->angle) >> 16; // NOT FRACBITS DAMNIT - bot->drawangle = ang; cmd->forwardmove = 8 * pcmd->forwardmove / 10; cmd->sidemove = 8 * pcmd->sidemove / 10; } @@ -339,7 +342,7 @@ static void B_BuildTailsTiccmd(mobj_t *sonic, mobj_t *tails, ticcmd_t *cmd) else if (!jump_last && !(bot->pflags & PF_JUMPED) //&& !(player->pflags & PF_SPINNING) && ((zdist > 32*scale && player->pflags & PF_JUMPED) // Following || (zdist > 64*scale && mem->thinkstate == AI_CATCHUP) // Vertical catch-up - || (stalled && mem-> catchup_tics > 20 && bot->powers[pw_carry] == CR_NONE) + || (stalled && mem->catchup_tics > 20 && bot->powers[pw_carry] == CR_NONE) //|| (bmom < scale>>3 && dist > followthres && !(bot->powers[pw_carry])) // Stopped & not in carry state || (bot->pflags & PF_SPINNING && !(bot->pflags & PF_JUMPED)))) // Spinning jump = true; @@ -385,7 +388,6 @@ void B_BuildTiccmd(player_t *player, ticcmd_t *cmd) return; // Make sure we have a valid main character to follow - B_UpdateBotleader(player); if (!player->botleader) return; @@ -398,7 +400,7 @@ void B_KeysToTiccmd(mobj_t *mo, ticcmd_t *cmd, boolean forward, boolean backward { player_t *player = mo->player; // don't try to do stuff if your sonic is in a minecart or something - if (&player->botleader && player->botleader->powers[pw_carry] && player->botleader->powers[pw_carry] != CR_PLAYER) + if (player->botleader && player->botleader->powers[pw_carry] && player->botleader->powers[pw_carry] != CR_PLAYER) return; // Turn the virtual keypresses into ticcmd_t. if (twodlevel || mo->flags2 & MF2_TWOD) { @@ -587,26 +589,43 @@ void B_RespawnBot(INT32 playernum) void B_HandleFlightIndicator(player_t *player) { mobj_t *tails = player->mo; - botmem_t *mem = &player->botmem; + boolean shouldExist; + if (!tails) return; - if (mem->thinkstate == AI_THINKFLY && player->bot == BOT_2PAI && tails->health) + shouldExist = (player->cmd.flags & TCF_FLIGHTINDICATOR) && player->botleader + && player->bot == BOT_2PAI && player->playerstate == PST_LIVE; + + // check whether the indicator doesn't exist + if (P_MobjWasRemoved(tails->hnext)) { - if (!tails->hnext) - { - P_SetTarget(&tails->hnext, P_SpawnMobjFromMobj(tails, 0, 0, 0, MT_OVERLAY)); - if (tails->hnext) - { - P_SetTarget(&tails->hnext->target, tails); - P_SetTarget(&tails->hnext->hprev, tails); - P_SetMobjState(tails->hnext, S_FLIGHTINDICATOR); - } - } + // if it shouldn't exist, everything is fine + if (!shouldExist) + return; + + // otherwise, spawn it + P_SetTarget(&tails->hnext, P_SpawnMobjFromMobj(tails, 0, 0, 0, MT_OVERLAY)); + P_SetTarget(&tails->hnext->target, tails); + P_SetTarget(&tails->hnext->hprev, tails); + P_SetMobjState(tails->hnext, S_FLIGHTINDICATOR); } - else if (tails->hnext && tails->hnext->type == MT_OVERLAY && tails->hnext->state == states+S_FLIGHTINDICATOR) + + // if the mobj isn't a flight indicator, let's not mess with it + if (tails->hnext->type != MT_OVERLAY || (tails->hnext->state != states+S_FLIGHTINDICATOR)) + return; + + // if it shouldn't exist, remove it + if (!shouldExist) { P_RemoveMobj(tails->hnext); P_SetTarget(&tails->hnext, NULL); + return; } + + // otherwise, update its visibility + if (P_IsLocalPlayer(player->botleader)) + tails->hnext->flags2 &= ~MF2_DONTDRAW; + else + tails->hnext->flags2 |= MF2_DONTDRAW; } diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 78a3ebe6c..c70532494 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -46,6 +46,7 @@ #include "lua_libs.h" #include "md5.h" #include "m_perfstats.h" +#include "b_bot.h" // B_BuildTiccmd #ifndef NONET // cl loading screen @@ -5166,6 +5167,25 @@ static void Local_Maketic(INT32 realtics) localcmds2.angleturn |= TICCMD_RECEIVED; } +static void SV_MakeBotTics(void) +{ + UINT8 i; + for (i = 0; i < MAXPLAYERS; i++) + { + if (!playeringame[i]) + continue; + + if (players[i].bot == BOT_2PAI || players[i].bot == BOT_MPAI) + { + ticcmd_t *cmd = &netcmds[maketic % BACKUPTICS][i]; + + G_CopyTiccmd(cmd, I_BaseTiccmd(), 1); // empty, or external driver + B_BuildTiccmd(&players[i], cmd); + cmd->angleturn |= TICCMD_RECEIVED; + } + } +} + // create missed tic static void SV_Maketic(void) { @@ -5409,6 +5429,15 @@ void NetUpdate(void) if (client) maketic = neededtic; + // update players' lastbuttons so they can be used in ticcmd generation + for (i = 0; i < MAXPLAYERS; i++) + { + if (!playeringame[i]) + continue; + + players[i].lastbuttons = players[i].cmd.buttons; + } + Local_Maketic(realtics); // make local tic, and call menu? if (server) @@ -5452,6 +5481,8 @@ void NetUpdate(void) Net_ConnectionTimeout(i); } + SV_MakeBotTics(); + // Don't erase tics not acknowledged counts = realtics; diff --git a/src/d_ticcmd.h b/src/d_ticcmd.h index 182b30e6a..480fbe2d4 100644 --- a/src/d_ticcmd.h +++ b/src/d_ticcmd.h @@ -45,6 +45,14 @@ typedef enum BT_CUSTOM3 = 1<<15, } buttoncode_t; +// ticcmd flags +typedef enum +{ + TCF_FLIGHTINDICATOR = 1 << 0, // show flight indicator + TCF_SETCARRY = 1 << 1, // set PF_CARRY upon activating flight + // free up to and including 1 << 7 +} ticcmdflag_t; + // The data sampled per tick (single player) // and transmitted to other peers (multiplayer). // Mainly movements/button commands per game tick, @@ -66,6 +74,7 @@ typedef struct INT16 aiming; // vertical aiming, see G_BuildTicCmd UINT16 buttons; UINT8 latency; // Netgames: how many tics ago was this ticcmd generated from this player's end? + UINT8 flags; // miscellaneous info } ATTRPACK ticcmd_t; #if defined(_MSC_VER) diff --git a/src/deh_tables.c b/src/deh_tables.c index f30f7c14d..3aece916c 100644 --- a/src/deh_tables.c +++ b/src/deh_tables.c @@ -5333,6 +5333,11 @@ struct int_const_s const INT_CONST[] = { {"BT_CUSTOM2",BT_CUSTOM2}, // Lua customizable {"BT_CUSTOM3",BT_CUSTOM3}, // Lua customizable + // Ticcmd flags (ticcmdflag_t) + // (maybe move these into their own table in the future but I cba when there's only 2 LOL) + {"TCF_FLIGHTINDICATOR", TCF_FLIGHTINDICATOR}, + {"TCF_SETCARRY", TCF_SETCARRY}, + // Lua command registration flags {"COM_ADMIN",COM_ADMIN}, {"COM_SPLITSCREEN",COM_SPLITSCREEN}, diff --git a/src/g_demo.c b/src/g_demo.c index c97dbcf9e..2e2f6d56a 100644 --- a/src/g_demo.c +++ b/src/g_demo.c @@ -110,6 +110,7 @@ demoghost *ghosts = NULL; #define ZT_BUTTONS 0x08 #define ZT_AIMING 0x10 #define ZT_LATENCY 0x20 +#define ZT_FLAGS 0x40 #define DEMOMARKER 0x80 // demoend #define METALDEATH 0x44 #define METALSNICE 0x69 @@ -184,6 +185,8 @@ void G_ReadDemoTiccmd(ticcmd_t *cmd, INT32 playernum) oldcmd.aiming = READINT16(demo_p); if (ziptic & ZT_LATENCY) oldcmd.latency = READUINT8(demo_p); + if (ziptic & ZT_FLAGS) + oldcmd.flags = READUINT8(demo_p); G_CopyTiccmd(cmd, &oldcmd, 1); players[playernum].angleturn = cmd->angleturn; @@ -248,6 +251,13 @@ void G_WriteDemoTiccmd(ticcmd_t *cmd, INT32 playernum) ziptic |= ZT_LATENCY; } + if (cmd->flags != oldcmd.flags) + { + WRITEUINT8(demo_p, cmd->flags); + oldcmd.flags = cmd->flags; + ziptic |= ZT_FLAGS; + } + *ziptic_p = ziptic; // attention here for the ticcmd size! @@ -691,6 +701,8 @@ void G_GhostTicker(void) g->p += 2; if (ziptic & ZT_LATENCY) g->p++; + if (ziptic & ZT_FLAGS) + g->p++; // Grab ghost data. ziptic = READUINT8(g->p); diff --git a/src/g_game.c b/src/g_game.c index 3955834b2..050f2d714 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1546,12 +1546,17 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) cmd->forwardmove = (SINT8)(cmd->forwardmove + forward); cmd->sidemove = (SINT8)(cmd->sidemove + side); - // Note: Majority of botstuffs are handled in G_Ticker now. - if (player->bot == BOT_2PHUMAN) //Player-controlled bot + // Note: Majority of botstuffs are handled in G_Ticker and NetUpdate now. + if (player->bot == BOT_2PAI + && !player->powers[pw_tailsfly] + && (cmd->forwardmove || cmd->sidemove || cmd->buttons)) { - // Fix offset angle for P2-controlled Tailsbot when P2's controls are set to non-Strafe - cmd->angleturn = (INT16)((localangle - *myangle) >> 16); - } + player->bot = BOT_2PHUMAN; // A player-controlled bot. Returns to AI when it respawns. + CV_SetValue(&cv_analog[1], true); + } + + if (player->bot == BOT_2PHUMAN) + cmd->angleturn = (localangle - *myangle) >> 16; *myangle += (cmd->angleturn<<16); @@ -1705,6 +1710,7 @@ ticcmd_t *G_MoveTiccmd(ticcmd_t* dest, const ticcmd_t* src, const size_t n) dest[i].aiming = (INT16)SHORT(src[i].aiming); dest[i].buttons = (UINT16)SHORT(src[i].buttons); dest[i].latency = src[i].latency; + dest[i].flags = src[i].flags; } return dest; } @@ -2312,57 +2318,32 @@ void G_Ticker(boolean run) if (playeringame[i]) { INT16 received; - // Save last frame's button readings - players[i].lastbuttons = players[i].cmd.buttons; G_CopyTiccmd(&players[i].cmd, &netcmds[buf][i], 1); - // Bot ticcmd handling - // Yes, ordinarily this would be handled in G_BuildTiccmd... - // ...however, bot players won't have a corresponding consoleplayer or splitscreen player 2 to send that information. - // Therefore, this has to be done after ticcmd sends are received. - if (players[i].bot == BOT_2PAI) { // Tailsbot for P2 - if (!players[i].powers[pw_tailsfly] && (players[i].cmd.forwardmove || players[i].cmd.sidemove || players[i].cmd.buttons)) - { - players[i].bot = BOT_2PHUMAN; // A player-controlled bot. Returns to AI when it respawns. - CV_SetValue(&cv_analog[1], true); - } - else - { - B_BuildTiccmd(&players[i], &players[i].cmd); - } - B_HandleFlightIndicator(&players[i]); - } - else if (players[i].bot == BOT_MPAI) { - B_BuildTiccmd(&players[i], &players[i].cmd); - } - - // Do angle adjustments. + if (players[i].bot == BOT_NONE || players[i].bot == BOT_2PHUMAN) { + // Use the leveltime sent in the player's ticcmd to determine control lag + players[i].cmd.latency = min(((leveltime & 0xFF) - players[i].cmd.latency) & 0xFF, MAXPREDICTTICS-1); + + // Do angle adjustments. received = (players[i].cmd.angleturn & TICCMD_RECEIVED); + players[i].angleturn += players[i].cmd.angleturn - players[i].oldrelangleturn; players[i].oldrelangleturn = players[i].cmd.angleturn; if (P_ControlStyle(&players[i]) == CS_LMAOGALOG) P_ForceLocalAngle(&players[i], players[i].angleturn << 16); else players[i].cmd.angleturn = players[i].angleturn; - if (P_ControlStyle(&players[i]) == CS_LMAOGALOG) - P_ForceLocalAngle(&players[i], players[i].angleturn << 16); - else - players[i].cmd.angleturn = players[i].angleturn; - - players[i].cmd.angleturn &= ~TICCMD_RECEIVED; - // Use the leveltime sent in the player's ticcmd to determine control lag - players[i].cmd.latency = min(((leveltime & 0xFF) - players[i].cmd.latency) & 0xFF, MAXPREDICTTICS-1); } else // Less work is required if we're building a bot ticcmd. { - // Since bot TicCmd is pre-determined for both the client and server, the latency and packet checks are simplified. - received = 1; - players[i].cmd.latency = 0; - players[i].angleturn = players[i].cmd.angleturn; - players[i].oldrelangleturn = players[i].cmd.angleturn; + // Since bot TicCmd is pre-determined for both the client and server, the latency and packet checks are simplified. + players[i].cmd.latency = 0; + P_SetPlayerAngle(&players[i], players[i].cmd.angleturn << 16); } + + players[i].cmd.angleturn &= ~TICCMD_RECEIVED; players[i].cmd.angleturn |= received; } } diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 12ad4fee0..e0d09dee9 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -32,6 +32,7 @@ #include "b_bot.h" // B_UpdateBotleader #include "d_clisrv.h" // CL_RemovePlayer #include "i_system.h" // I_GetPreciseTime, I_PreciseToMicros +#include "i_net.h" // doomcom #include "lua_script.h" #include "lua_libs.h" @@ -3463,6 +3464,8 @@ static int lib_gAddPlayer(lua_State *L) playeringame[newplayernum] = true; G_AddPlayer(newplayernum); + if (newplayernum+1 > doomcom->numslots) + doomcom->numslots = (INT16)(newplayernum+1); newplayer = &players[newplayernum]; newplayer->jointime = 0; diff --git a/src/lua_playerlib.c b/src/lua_playerlib.c index 1c634da45..097fd94e4 100644 --- a/src/lua_playerlib.c +++ b/src/lua_playerlib.c @@ -833,6 +833,8 @@ static int ticcmd_get(lua_State *L) lua_pushinteger(L, cmd->buttons); else if (fastcmp(field,"latency")) lua_pushinteger(L, cmd->latency); + else if (fastcmp(field,"flags")) + lua_pushinteger(L, cmd->flags); else return NOFIELD; @@ -861,6 +863,8 @@ static int ticcmd_set(lua_State *L) cmd->buttons = (UINT16)luaL_checkinteger(L, 3); else if (fastcmp(field,"latency")) return NOSET; + else if (fastcmp(field,"flags")) + cmd->buttons = (UINT8)luaL_checkinteger(L, 3); else return NOFIELD; diff --git a/src/p_saveg.c b/src/p_saveg.c index 1270064c0..8a75013a3 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -51,14 +51,15 @@ UINT8 *save_p; // than an UINT16 typedef enum { -// RFLAGPOINT = 0x01, -// BFLAGPOINT = 0x02, - CAPSULE = 0x04, - AWAYVIEW = 0x08, - FIRSTAXIS = 0x10, - SECONDAXIS = 0x20, - FOLLOW = 0x40, - DRONE = 0x80, +// RFLAGPOINT = 0x001, +// BFLAGPOINT = 0x002, + CAPSULE = 0x004, + AWAYVIEW = 0x008, + FIRSTAXIS = 0x010, + SECONDAXIS = 0x020, + FOLLOW = 0x040, + DRONE = 0x080, + BOTLEADER = 0x100, } player_saveflags; static inline void P_ArchivePlayer(void) @@ -197,10 +198,11 @@ static void P_NetArchivePlayers(void) // Bots // ////////// WRITEUINT8(save_p, players[i].bot); - WRITEUINT8(save_p, players[i].botmem.lastForward); - WRITEUINT8(save_p, players[i].botmem.lastBlocked); - WRITEUINT8(save_p, players[i].botmem.catchup_tics); - WRITEUINT8(save_p, players[i].botmem.thinkstate); + // We no longer need to sync these since ticcmds are generated only by the server + //WRITEUINT8(save_p, players[i].botmem.lastForward); + //WRITEUINT8(save_p, players[i].botmem.lastBlocked); + //WRITEUINT8(save_p, players[i].botmem.catchup_tics); + //WRITEUINT8(save_p, players[i].botmem.thinkstate); WRITEUINT8(save_p, players[i].removing); WRITEUINT8(save_p, players[i].blocked); @@ -293,6 +295,9 @@ static void P_NetArchivePlayers(void) if (players[i].drone) flags |= DRONE; + if (players[i].botleader) + flags |= BOTLEADER; + WRITEINT16(save_p, players[i].lastsidehit); WRITEINT16(save_p, players[i].lastlinehit); @@ -325,6 +330,9 @@ static void P_NetArchivePlayers(void) if (flags & DRONE) WRITEUINT32(save_p, players[i].drone->mobjnum); + if (flags & BOTLEADER) + WRITEUINT8(save_p, (UINT8)(players[i].botleader - players)); + WRITEFIXED(save_p, players[i].camerascale); WRITEFIXED(save_p, players[i].shieldscale); @@ -425,10 +433,10 @@ static void P_NetUnArchivePlayers(void) ////////// players[i].bot = READUINT8(save_p); - players[i].botmem.lastForward = READUINT8(save_p); - players[i].botmem.lastBlocked = READUINT8(save_p); - players[i].botmem.catchup_tics = READUINT8(save_p); - players[i].botmem.thinkstate = READUINT8(save_p); + //players[i].botmem.lastForward = READUINT8(save_p); + //players[i].botmem.lastBlocked = READUINT8(save_p); + //players[i].botmem.catchup_tics = READUINT8(save_p); + //players[i].botmem.thinkstate = READUINT8(save_p); players[i].removing = READUINT8(save_p); players[i].blocked = READUINT8(save_p); @@ -535,6 +543,9 @@ static void P_NetUnArchivePlayers(void) if (flags & DRONE) players[i].drone = (mobj_t *)(size_t)READUINT32(save_p); + if (flags & BOTLEADER) + players[i].botleader = &players[READUINT8(save_p)]; + players[i].camerascale = READFIXED(save_p); players[i].shieldscale = READFIXED(save_p); diff --git a/src/p_user.c b/src/p_user.c index f21118a81..cc232d08d 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -5349,10 +5349,10 @@ static void P_DoJumpStuff(player_t *player, ticcmd_t *cmd) player->powers[pw_tailsfly] = tailsflytics + 1; // Set the fly timer player->pflags &= ~(PF_JUMPED|PF_NOJUMPDAMAGE|PF_SPINNING|PF_STARTDASH); - if (player->bot == BOT_2PAI) - player->pflags |= PF_THOKKED; - else + if ((player->bot != BOT_2PAI) || (cmd->flags & TCF_SETCARRY)) player->pflags |= (PF_THOKKED|PF_CANCARRY); + else + player->pflags |= PF_THOKKED; } break; case CA_GLIDEANDCLIMB: @@ -11450,6 +11450,12 @@ void P_PlayerThink(player_t *player) { if (B_CheckRespawn(player)) player->playerstate = PST_REBORN; + else + { + if (player->bot == BOT_2PAI) + B_UpdateBotleader(player); + B_HandleFlightIndicator(player); + } } if (player->playerstate == PST_REBORN) { From 7ed817837214101a18bd9eb5f4f1edbdd7286044 Mon Sep 17 00:00:00 2001 From: lachablock Date: Sun, 12 Dec 2021 19:18:13 +1100 Subject: [PATCH 0979/1080] Oops typo --- src/lua_playerlib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lua_playerlib.c b/src/lua_playerlib.c index 097fd94e4..edd1351e8 100644 --- a/src/lua_playerlib.c +++ b/src/lua_playerlib.c @@ -864,7 +864,7 @@ static int ticcmd_set(lua_State *L) else if (fastcmp(field,"latency")) return NOSET; else if (fastcmp(field,"flags")) - cmd->buttons = (UINT8)luaL_checkinteger(L, 3); + cmd->flags = (UINT8)luaL_checkinteger(L, 3); else return NOFIELD; From e7a7a3b2138017b08d19276cb95497f4298aef8c Mon Sep 17 00:00:00 2001 From: spherallic Date: Mon, 13 Dec 2021 15:20:43 +0100 Subject: [PATCH 0980/1080] Prevent Pyrefly fire from warping up nearby ledges. --- src/info.c | 4 ++-- src/p_mobj.c | 22 ++++++++++++---------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/info.c b/src/info.c index f56e5d78e..086293cd6 100644 --- a/src/info.c +++ b/src/info.c @@ -5198,11 +5198,11 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = 0, // speed 24*FRACUNIT, // radius 34*FRACUNIT, // height - 0, // display offset + 1, // display offset DMG_FIRE, // mass 0, // damage sfx_None, // activesound - MF_NOGRAVITY|MF_NOBLOCKMAP|MF_FIRE|MF_PAIN, // flags + MF_NOGRAVITY|MF_NOBLOCKMAP|MF_NOCLIPHEIGHT|MF_FIRE|MF_PAIN, // flags S_NULL // raisestate }, diff --git a/src/p_mobj.c b/src/p_mobj.c index 83f9ebf3c..4b0337873 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -395,13 +395,13 @@ boolean P_SetPlayerMobjState(mobj_t *mobj, statenum_t state) if (skin) { UINT16 stateframe = st->frame; - + // Add/Remove FF_SPR2SUPER based on certain conditions if (player->charflags & SF_NOSUPERSPRITES) stateframe = stateframe & ~FF_SPR2SUPER; else if (player->powers[pw_super]) stateframe = stateframe | FF_SPR2SUPER; - + if (stateframe & FF_SPR2SUPER) { if (mobj->eflags & MFE_FORCENOSUPER) @@ -409,11 +409,11 @@ boolean P_SetPlayerMobjState(mobj_t *mobj, statenum_t state) } else if (mobj->eflags & MFE_FORCESUPER) stateframe = stateframe | FF_SPR2SUPER; - + // Get the sprite2 and frame number spr2 = P_GetSkinSprite2(skin, (stateframe & FF_FRAMEMASK), mobj->player); numframes = skin->sprites[spr2].numframes; - + if (state == S_PLAY_STND && (spr2 & FF_SPR2SUPER) && skin->sprites[SPR2_WAIT|FF_SPR2SUPER].numframes == 0) mobj->tics = -1; // If no super wait, don't wait at all } @@ -541,7 +541,7 @@ boolean P_SetMobjState(mobj_t *mobj, statenum_t state) if (skin) { UINT16 stateframe = st->frame; - + // Add/Remove FF_SPR2SUPER based on certain conditions if (stateframe & FF_SPR2SUPER) { @@ -550,11 +550,11 @@ boolean P_SetMobjState(mobj_t *mobj, statenum_t state) } else if (mobj->eflags & MFE_FORCESUPER) stateframe = stateframe | FF_SPR2SUPER; - + // Get the sprite2 and frame number spr2 = P_GetSkinSprite2(skin, (stateframe & FF_FRAMEMASK), NULL); numframes = skin->sprites[spr2].numframes; - + if (state == S_PLAY_STND && (spr2 & FF_SPR2SUPER) && skin->sprites[SPR2_WAIT|FF_SPR2SUPER].numframes == 0) mobj->tics = -1; // If no super wait, don't wait at all } @@ -1872,7 +1872,7 @@ void P_XYMovement(mobj_t *mo) // blocked move moved = false; - if (player) + if (player) B_MoveBlocked(player); if (LUA_HookMobjMoveBlocked(mo, tmhitthing, blockingline)) @@ -3323,7 +3323,7 @@ void P_MobjCheckWater(mobj_t *mobj) { // Water removes electric and non-water fire shields... if (electric) P_FlashPal(p, PAL_WHITE, 1); - + p->powers[pw_shield] = p->powers[pw_shield] & SH_STACK; } } @@ -7059,6 +7059,8 @@ static void P_PyreFlyBurn(mobj_t *mobj, fixed_t hoffs, INT16 vrange, mobjtype_t fixed_t zoffs = P_RandomRange(-vrange, vrange)*FRACUNIT; mobj_t *particle = P_SpawnMobjFromMobj(mobj, xoffs, yoffs, zoffs, mobjtype); particle->momz = momz; + particle->flags2 |= MF2_LINKDRAW; + P_SetTarget(&particle->tracer, mobj); } static void P_MobjScaleThink(mobj_t *mobj) @@ -10422,7 +10424,7 @@ static fixed_t P_DefaultMobjShadowScale (mobj_t *thing) case MT_RING: case MT_FLINGRING: - + case MT_COIN: case MT_FLINGCOIN: From 1eb1ad2677b1a3425a5d2879f002a213ae9fdf22 Mon Sep 17 00:00:00 2001 From: lachablock Date: Wed, 22 Dec 2021 19:46:16 +1100 Subject: [PATCH 0981/1080] Fix compile warning --- src/g_game.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index 050f2d714..3ab3dae18 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -2317,8 +2317,6 @@ void G_Ticker(boolean run) { if (playeringame[i]) { - INT16 received; - G_CopyTiccmd(&players[i].cmd, &netcmds[buf][i], 1); if (players[i].bot == BOT_NONE || players[i].bot == BOT_2PHUMAN) @@ -2327,14 +2325,13 @@ void G_Ticker(boolean run) players[i].cmd.latency = min(((leveltime & 0xFF) - players[i].cmd.latency) & 0xFF, MAXPREDICTTICS-1); // Do angle adjustments. - received = (players[i].cmd.angleturn & TICCMD_RECEIVED); players[i].angleturn += players[i].cmd.angleturn - players[i].oldrelangleturn; players[i].oldrelangleturn = players[i].cmd.angleturn; if (P_ControlStyle(&players[i]) == CS_LMAOGALOG) P_ForceLocalAngle(&players[i], players[i].angleturn << 16); else - players[i].cmd.angleturn = players[i].angleturn; + players[i].cmd.angleturn = (players[i].angleturn & ~TICCMD_RECEIVED) | (players[i].cmd.angleturn & TICCMD_RECEIVED); } else // Less work is required if we're building a bot ticcmd. { @@ -2342,9 +2339,6 @@ void G_Ticker(boolean run) players[i].cmd.latency = 0; P_SetPlayerAngle(&players[i], players[i].cmd.angleturn << 16); } - - players[i].cmd.angleturn &= ~TICCMD_RECEIVED; - players[i].cmd.angleturn |= received; } } From 9b10473e0df43842ad77bb9c7f45b7a7edc0308a Mon Sep 17 00:00:00 2001 From: katsy Date: Fri, 24 Dec 2021 19:36:26 -0600 Subject: [PATCH 0982/1080] add invert flashpal constant --- src/deh_tables.c | 1 + src/p_local.h | 1 + 2 files changed, 2 insertions(+) diff --git a/src/deh_tables.c b/src/deh_tables.c index f30f7c14d..b80e88ec2 100644 --- a/src/deh_tables.c +++ b/src/deh_tables.c @@ -5088,6 +5088,7 @@ struct int_const_s const INT_CONST[] = { {"PAL_MIXUP",PAL_MIXUP}, {"PAL_RECYCLE",PAL_RECYCLE}, {"PAL_NUKE",PAL_NUKE}, + {"PAL_INVERT",PAL_INVERT}, // for P_DamageMobj //// Damage types {"DMG_WATER",DMG_WATER}, diff --git a/src/p_local.h b/src/p_local.h index 1fcd3050d..28a77afe5 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -349,6 +349,7 @@ void P_FlashPal(player_t *pl, UINT16 type, UINT16 duration); #define PAL_MIXUP 2 #define PAL_RECYCLE 3 #define PAL_NUKE 4 +#define PAL_INVERT 5 // // P_ENEMY From 243a797efe9fe89c4b51c974b5137afeedded808 Mon Sep 17 00:00:00 2001 From: katsy <205-katsy@users.noreply.git.do.srb2.org> Date: Sun, 26 Dec 2021 12:41:49 +0000 Subject: [PATCH 0983/1080] Set a default botleader if we don't have one (resolves #717) --- src/b_bot.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/b_bot.c b/src/b_bot.c index cdd74fc07..bf2dbbb68 100644 --- a/src/b_bot.c +++ b/src/b_bot.c @@ -29,11 +29,16 @@ void B_UpdateBotleader(player_t *player) { if (players[i].bot || players[i].playerstate != PST_LIVE || players[i].spectator || !players[i].mo) continue; - if (!player->mo) //Can't do distance calculations if there's no player object, so we'll just take the first we find + + if (!player->botleader) { - player->botleader = &players[i]; + player->botleader = &players[i]; // set default return; } + + if (!player->mo) + return; + //Update best candidate based on nearest distance dist = R_PointToDist2(player->mo->x, player->mo->y, players[i].mo->x, players[i].mo->y); if (neardist > dist) From bb514d227ca5f2d53e6295c8b599a1dc205c69f1 Mon Sep 17 00:00:00 2001 From: spherallic Date: Sun, 26 Dec 2021 21:12:39 +0100 Subject: [PATCH 0984/1080] Don't count music.dta as a main wad when using listwad --- 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 cca3102d0..fe7e7678f 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -3763,7 +3763,7 @@ static void Command_ListWADS_f(void) nameonly(tempname = va("%s", wadfiles[i]->filename)); if (!i) CONS_Printf("\x82 IWAD\x80: %s\n", tempname); - else if (i <= mainwads) + else if (i < mainwads) CONS_Printf("\x82 * %.2d\x80: %s\n", i, tempname); else if (!wadfiles[i]->important) CONS_Printf("\x86 %.2d: %s\n", i, tempname); From b830fee2e30ae5f9d36b85781c22d2484af59931 Mon Sep 17 00:00:00 2001 From: spherallic Date: Sun, 26 Dec 2021 21:30:36 +0100 Subject: [PATCH 0985/1080] Allow changing the master server address while hosting a netgame. --- src/m_menu.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index fc1e33b67..3ec49356c 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -11588,9 +11588,7 @@ static void M_ServerOptions(INT32 choice) OP_ServerOptionsMenu[ 2].status = IT_STRING | IT_CVAR; OP_ServerOptionsMenu[ 3].status = IT_STRING | IT_CVAR; OP_ServerOptionsMenu[ 4].status = IT_STRING | IT_CVAR; - OP_ServerOptionsMenu[36].status = (netgame - ? IT_GRAYEDOUT - : (IT_STRING | IT_CVAR | IT_CV_STRING)); + OP_ServerOptionsMenu[36].status = IT_STRING | IT_CVAR | IT_CV_STRING; OP_ServerOptionsMenu[37].status = IT_STRING | IT_CVAR; OP_ServerOptionsMenu[38].status = IT_STRING | IT_CVAR; } From 1040141560d717fc60e09e71f5d78aa5780d0d14 Mon Sep 17 00:00:00 2001 From: spherallic Date: Mon, 27 Dec 2021 12:41:04 +0100 Subject: [PATCH 0986/1080] Fix enemy/boss/minecart explosions in death pits --- 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 40ef447f8..39c6731b8 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -2522,7 +2522,7 @@ boolean P_ZMovement(mobj_t *mo) { P_KillMobj(mo, NULL, NULL, 0); } - return false; + return !P_MobjWasRemoved(mo); // allows explosion states to run } else { From 392e7828938c6b4f54e84a759e55b339f346aeee Mon Sep 17 00:00:00 2001 From: lachablock Date: Mon, 27 Dec 2021 23:35:01 +1100 Subject: [PATCH 0987/1080] Don't modify drawangle when taking damage in strafe mode --- src/p_user.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/p_user.c b/src/p_user.c index da06510d3..d9d92f3b2 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -1048,7 +1048,8 @@ void P_DoPlayerPain(player_t *player, mobj_t *source, mobj_t *inflictor) fallbackspeed = FixedMul(4*FRACUNIT, player->mo->scale); } - player->drawangle = ang + ANGLE_180; + if (player->pflags & PF_DIRECTIONCHAR) + player->drawangle = ang + ANGLE_180; P_InstaThrust(player->mo, ang, fallbackspeed); } From effcb948ade86387fcf446b234fd212eb79aa951 Mon Sep 17 00:00:00 2001 From: katsy <205-katsy@users.noreply.git.do.srb2.org> Date: Wed, 29 Dec 2021 09:59:54 +0000 Subject: [PATCH 0988/1080] Don't count bots in playersforexit --- src/g_game.c | 2 +- src/p_user.c | 4 ++-- src/st_stuff.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index 3955834b2..e671eb2d7 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -3300,7 +3300,7 @@ boolean G_EnoughPlayersFinished(void) for (i = 0; i < MAXPLAYERS; i++) { - if (!playeringame[i] || players[i].spectator || players[i].bot == BOT_2PAI || players[i].bot == BOT_2PHUMAN) + if (!playeringame[i] || players[i].spectator || players[i].bot) continue; if (players[i].quittime > 30 * TICRATE) continue; diff --git a/src/p_user.c b/src/p_user.c index ee76d29a8..b6c30256f 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -11588,7 +11588,7 @@ void P_PlayerThink(player_t *player) for (i = 0; i < MAXPLAYERS; i++) { - if (!playeringame[i] || players[i].spectator || players[i].bot == BOT_2PAI || players[i].bot == BOT_2PHUMAN) + if (!playeringame[i] || players[i].spectator || players[i].bot) continue; if (players[i].lives <= 0) continue; @@ -11620,7 +11620,7 @@ void P_PlayerThink(player_t *player) for (i = 0; i < MAXPLAYERS; i++) { - if (!playeringame[i] || players[i].spectator || players[i].bot == BOT_2PAI || players[i].bot == BOT_2PHUMAN) + if (!playeringame[i] || players[i].spectator || players[i].bot) continue; if (players[i].quittime > 30 * TICRATE) continue; diff --git a/src/st_stuff.c b/src/st_stuff.c index a328d669e..ebf188a06 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -2291,7 +2291,7 @@ static void ST_drawTextHUD(void) for (i = 0; i < MAXPLAYERS; i++) { - if (!playeringame[i] || players[i].spectator) + if (!playeringame[i] || players[i].spectator || players[i].bot) continue; if (players[i].lives <= 0) continue; From 0a38fef147666bbf09320f0e88dc4fb900c5e21f Mon Sep 17 00:00:00 2001 From: spherallic Date: Thu, 16 Dec 2021 15:28:37 +0100 Subject: [PATCH 0989/1080] Several changes to default control settings: - Renamed Simple to Automatic, and made it the default - Renamed Standard to Manual - Changed some camera settings to make Automatic easier to control - Changed most default gamepad controls, to fit Automatic playstyle - Changed a few default keyboard controls - Added default binds for custom actions 1-3 - Removed forced camera settings in the tutorial (to account for upcoming tutorial update) - Also lowered default sound/music volume a little bit --- src/g_game.c | 46 +++++++++++++++++++-------------------- src/g_input.c | 60 ++++++++++++++++++++++++++++----------------------- src/m_menu.c | 29 +++++++++++++------------ src/p_user.c | 30 +++++++++----------------- src/s_sound.c | 6 +++--- 5 files changed, 84 insertions(+), 87 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index e671eb2d7..44860bbbc 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -346,8 +346,8 @@ consvar_t cv_analog[2] = { CVAR_INIT ("sessionanalog2", "Off", CV_CALL|CV_NOSHOWHELP, CV_OnOff, Analog2_OnChange), }; consvar_t cv_useranalog[2] = { - CVAR_INIT ("configanalog", "Off", CV_SAVE|CV_CALL|CV_NOSHOWHELP, CV_OnOff, UserAnalog_OnChange), - CVAR_INIT ("configanalog2", "Off", CV_SAVE|CV_CALL|CV_NOSHOWHELP, CV_OnOff, UserAnalog2_OnChange), + CVAR_INIT ("configanalog", "On", CV_SAVE|CV_CALL|CV_NOSHOWHELP, CV_OnOff, UserAnalog_OnChange), + CVAR_INIT ("configanalog2", "On", CV_SAVE|CV_CALL|CV_NOSHOWHELP, CV_OnOff, UserAnalog2_OnChange), }; // deez New User eXperiences @@ -362,8 +362,8 @@ consvar_t cv_autobrake2 = CVAR_INIT ("autobrake2", "On", CV_SAVE|CV_CALL, CV_OnO // hi here's some new controls static CV_PossibleValue_t zerotoone_cons_t[] = {{0, "MIN"}, {FRACUNIT, "MAX"}, {0, NULL}}; consvar_t cv_cam_shiftfacing[2] = { - CVAR_INIT ("cam_shiftfacingchar", "0.33", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL), - CVAR_INIT ("cam2_shiftfacingchar", "0.33", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL), + CVAR_INIT ("cam_shiftfacingchar", "0.375", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL), + CVAR_INIT ("cam2_shiftfacingchar", "0.375", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL), }; consvar_t cv_cam_turnfacing[2] = { CVAR_INIT ("cam_turnfacingchar", "0.25", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL), @@ -374,12 +374,12 @@ consvar_t cv_cam_turnfacingability[2] = { CVAR_INIT ("cam2_turnfacingability", "0.125", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL), }; consvar_t cv_cam_turnfacingspindash[2] = { - CVAR_INIT ("cam_turnfacingspindash", "0.5", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL), - CVAR_INIT ("cam2_turnfacingspindash", "0.5", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL), + CVAR_INIT ("cam_turnfacingspindash", "0.25", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL), + CVAR_INIT ("cam2_turnfacingspindash", "0.25", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL), }; consvar_t cv_cam_turnfacinginput[2] = { - CVAR_INIT ("cam_turnfacinginput", "0.25", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL), - CVAR_INIT ("cam2_turnfacinginput", "0.25", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL), + CVAR_INIT ("cam_turnfacinginput", "0.375", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL), + CVAR_INIT ("cam2_turnfacinginput", "0.375", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL), }; static CV_PossibleValue_t centertoggle_cons_t[] = {{0, "Hold"}, {1, "Toggle"}, {2, "Sticky Hold"}, {0, NULL}}; @@ -403,28 +403,28 @@ static CV_PossibleValue_t lockedassist_cons_t[] = { {0, NULL} }; consvar_t cv_cam_lockonboss[2] = { - CVAR_INIT ("cam_lockaimassist", "Bosses", CV_SAVE, lockedassist_cons_t, NULL), - CVAR_INIT ("cam2_lockaimassist", "Bosses", CV_SAVE, lockedassist_cons_t, NULL), + CVAR_INIT ("cam_lockaimassist", "Full", CV_SAVE, lockedassist_cons_t, NULL), + CVAR_INIT ("cam2_lockaimassist", "Full", CV_SAVE, lockedassist_cons_t, NULL), }; -consvar_t cv_turnaxis = CVAR_INIT ("joyaxis_turn", "X-Rudder", CV_SAVE, joyaxis_cons_t, NULL); consvar_t cv_moveaxis = CVAR_INIT ("joyaxis_move", "Y-Axis", CV_SAVE, joyaxis_cons_t, NULL); consvar_t cv_sideaxis = CVAR_INIT ("joyaxis_side", "X-Axis", CV_SAVE, joyaxis_cons_t, NULL); consvar_t cv_lookaxis = CVAR_INIT ("joyaxis_look", "Y-Rudder-", CV_SAVE, joyaxis_cons_t, NULL); +consvar_t cv_turnaxis = CVAR_INIT ("joyaxis_turn", "X-Rudder", CV_SAVE, joyaxis_cons_t, NULL); consvar_t cv_jumpaxis = CVAR_INIT ("joyaxis_jump", "None", CV_SAVE, joyaxis_cons_t, NULL); consvar_t cv_spinaxis = CVAR_INIT ("joyaxis_spin", "None", CV_SAVE, joyaxis_cons_t, NULL); -consvar_t cv_fireaxis = CVAR_INIT ("joyaxis_fire", "Z-Axis-", CV_SAVE, joyaxis_cons_t, NULL); +consvar_t cv_fireaxis = CVAR_INIT ("joyaxis_fire", "Z-Rudder", CV_SAVE, joyaxis_cons_t, NULL); consvar_t cv_firenaxis = CVAR_INIT ("joyaxis_firenormal", "Z-Axis", CV_SAVE, joyaxis_cons_t, NULL); consvar_t cv_deadzone = CVAR_INIT ("joy_deadzone", "0.125", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL); consvar_t cv_digitaldeadzone = CVAR_INIT ("joy_digdeadzone", "0.25", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL); -consvar_t cv_turnaxis2 = CVAR_INIT ("joyaxis2_turn", "X-Rudder", CV_SAVE, joyaxis_cons_t, NULL); consvar_t cv_moveaxis2 = CVAR_INIT ("joyaxis2_move", "Y-Axis", CV_SAVE, joyaxis_cons_t, NULL); consvar_t cv_sideaxis2 = CVAR_INIT ("joyaxis2_side", "X-Axis", CV_SAVE, joyaxis_cons_t, NULL); consvar_t cv_lookaxis2 = CVAR_INIT ("joyaxis2_look", "Y-Rudder-", CV_SAVE, joyaxis_cons_t, NULL); +consvar_t cv_turnaxis2 = CVAR_INIT ("joyaxis2_turn", "X-Rudder", CV_SAVE, joyaxis_cons_t, NULL); consvar_t cv_jumpaxis2 = CVAR_INIT ("joyaxis2_jump", "None", CV_SAVE, joyaxis_cons_t, NULL); consvar_t cv_spinaxis2 = CVAR_INIT ("joyaxis2_spin", "None", CV_SAVE, joyaxis_cons_t, NULL); -consvar_t cv_fireaxis2 = CVAR_INIT ("joyaxis2_fire", "Z-Axis-", CV_SAVE, joyaxis_cons_t, NULL); +consvar_t cv_fireaxis2 = CVAR_INIT ("joyaxis2_fire", "Z-Rudder", CV_SAVE, joyaxis_cons_t, NULL); consvar_t cv_firenaxis2 = CVAR_INIT ("joyaxis2_firenormal", "Z-Axis", CV_SAVE, joyaxis_cons_t, NULL); consvar_t cv_deadzone2 = CVAR_INIT ("joy_deadzone2", "0.125", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL); consvar_t cv_digitaldeadzone2 = CVAR_INIT ("joy_digdeadzone2", "0.25", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL); @@ -1551,8 +1551,8 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) { // Fix offset angle for P2-controlled Tailsbot when P2's controls are set to non-Strafe cmd->angleturn = (INT16)((localangle - *myangle) >> 16); - } - + } + *myangle += (cmd->angleturn<<16); if (controlstyle == CS_LMAOGALOG) { @@ -2335,7 +2335,7 @@ void G_Ticker(boolean run) else if (players[i].bot == BOT_MPAI) { B_BuildTiccmd(&players[i], &players[i].cmd); } - + // Do angle adjustments. if (players[i].bot == BOT_NONE || players[i].bot == BOT_2PHUMAN) { @@ -2350,7 +2350,7 @@ void G_Ticker(boolean run) P_ForceLocalAngle(&players[i], players[i].angleturn << 16); else players[i].cmd.angleturn = players[i].angleturn; - + players[i].cmd.angleturn &= ~TICCMD_RECEIVED; // Use the leveltime sent in the player's ticcmd to determine control lag players[i].cmd.latency = min(((leveltime & 0xFF) - players[i].cmd.latency) & 0xFF, MAXPREDICTTICS-1); @@ -3056,15 +3056,15 @@ void G_DoReborn(INT32 playernum) return; } - + // Additional players (e.g. independent bots) in Single Player - if (playernum != consoleplayer && !(netgame || multiplayer)) - { + if (playernum != consoleplayer && !(netgame || multiplayer)) + { mobj_t *oldmo = NULL; // Do nothing if out of lives if (player->lives <= 0) return; - + // Otherwise do respawn, starting by removing the player object if (player->mo) { @@ -3075,7 +3075,7 @@ void G_DoReborn(INT32 playernum) G_SpawnPlayer(playernum); if (oldmo) G_ChangePlayerReferences(oldmo, players[playernum].mo); - + return; //Exit function to avoid proccing other SP related mechanics } diff --git a/src/g_input.c b/src/g_input.c index 6383c3f00..250a24772 100644 --- a/src/g_input.c +++ b/src/g_input.c @@ -684,14 +684,18 @@ void G_DefineDefaultControls(void) gamecontroldefault[gcs_fps][GC_LOOKDOWN ][0] = KEY_DOWNARROW; gamecontroldefault[gcs_fps][GC_TURNLEFT ][0] = KEY_LEFTARROW; gamecontroldefault[gcs_fps][GC_TURNRIGHT ][0] = KEY_RIGHTARROW; - gamecontroldefault[gcs_fps][GC_CENTERVIEW ][0] = KEY_END; + gamecontroldefault[gcs_fps][GC_CENTERVIEW ][0] = KEY_LCTRL; gamecontroldefault[gcs_fps][GC_JUMP ][0] = KEY_SPACE; gamecontroldefault[gcs_fps][GC_SPIN ][0] = KEY_LSHIFT; gamecontroldefault[gcs_fps][GC_FIRE ][0] = KEY_RCTRL; gamecontroldefault[gcs_fps][GC_FIRE ][1] = KEY_MOUSE1+0; - gamecontroldefault[gcs_fps][GC_FIRENORMAL ][0] = 'c'; + gamecontroldefault[gcs_fps][GC_FIRENORMAL ][0] = KEY_RALT; + gamecontroldefault[gcs_fps][GC_FIRENORMAL ][1] = KEY_MOUSE1+1; + gamecontroldefault[gcs_fps][GC_CUSTOM1 ][0] = 'z'; + gamecontroldefault[gcs_fps][GC_CUSTOM2 ][0] = 'x'; + gamecontroldefault[gcs_fps][GC_CUSTOM3 ][0] = 'c'; - // Platform game controls (arrow keys) + // Platform game controls (arrow keys), currently unused gamecontroldefault[gcs_platform][GC_FORWARD ][0] = KEY_UPARROW; gamecontroldefault[gcs_platform][GC_BACKWARD ][0] = KEY_DOWNARROW; gamecontroldefault[gcs_platform][GC_STRAFELEFT ][0] = 'a'; @@ -734,34 +738,36 @@ void G_DefineDefaultControls(void) gamecontroldefault[i][GC_VIEWPOINT ][0] = KEY_F12; // Gamepad controls -- same for both schemes - gamecontroldefault[i][GC_WEAPONNEXT ][1] = KEY_JOY1+1; // B - gamecontroldefault[i][GC_WEAPONPREV ][1] = KEY_JOY1+2; // X - gamecontroldefault[i][GC_TOSSFLAG ][1] = KEY_JOY1+0; // A - gamecontroldefault[i][GC_SPIN ][1] = KEY_JOY1+4; // LB - gamecontroldefault[i][GC_CAMTOGGLE ][1] = KEY_HAT1+0; // D-Pad Up - gamecontroldefault[i][GC_CAMRESET ][1] = KEY_JOY1+3; // Y + gamecontroldefault[i][GC_JUMP ][1] = KEY_JOY1+0; // A + gamecontroldefault[i][GC_SPIN ][1] = KEY_JOY1+2; // X + gamecontroldefault[i][GC_CUSTOM1 ][1] = KEY_JOY1+1; // B + gamecontroldefault[i][GC_CUSTOM2 ][1] = KEY_JOY1+3; // Y + gamecontroldefault[i][GC_CUSTOM3 ][1] = KEY_JOY1+8; // Left Stick gamecontroldefault[i][GC_CENTERVIEW ][1] = KEY_JOY1+9; // Right Stick - gamecontroldefault[i][GC_TALKKEY ][1] = KEY_HAT1+2; // D-Pad Left - gamecontroldefault[i][GC_SCORES ][1] = KEY_HAT1+3; // D-Pad Right - gamecontroldefault[i][GC_JUMP ][1] = KEY_JOY1+5; // RB - gamecontroldefault[i][GC_PAUSE ][1] = KEY_JOY1+6; // Back - gamecontroldefault[i][GC_SCREENSHOT ][1] = KEY_HAT1+1; // D-Pad Down + gamecontroldefault[i][GC_WEAPONPREV ][1] = KEY_JOY1+4; // LB + gamecontroldefault[i][GC_WEAPONNEXT ][1] = KEY_JOY1+5; // RB + gamecontroldefault[i][GC_SCREENSHOT ][1] = KEY_JOY1+6; // Back gamecontroldefault[i][GC_SYSTEMMENU ][0] = KEY_JOY1+7; // Start + gamecontroldefault[i][GC_CAMTOGGLE ][1] = KEY_HAT1+0; // D-Pad Up + gamecontroldefault[i][GC_VIEWPOINT ][1] = KEY_HAT1+1; // D-Pad Down + gamecontroldefault[i][GC_TOSSFLAG ][1] = KEY_HAT1+2; // D-Pad Left + gamecontroldefault[i][GC_SCORES ][1] = KEY_HAT1+3; // D-Pad Right // Second player controls only have joypad defaults - gamecontrolbisdefault[i][GC_WEAPONNEXT][0] = KEY_2JOY1+1; // B - gamecontrolbisdefault[i][GC_WEAPONPREV][0] = KEY_2JOY1+2; // X - gamecontrolbisdefault[i][GC_TOSSFLAG ][0] = KEY_2JOY1+0; // A - gamecontrolbisdefault[i][GC_SPIN ][0] = KEY_2JOY1+4; // LB - gamecontrolbisdefault[i][GC_CAMRESET ][0] = KEY_2JOY1+3; // Y - gamecontrolbisdefault[i][GC_CENTERVIEW][0] = KEY_2JOY1+9; // Right Stick - gamecontrolbisdefault[i][GC_JUMP ][0] = KEY_2JOY1+5; // RB - //gamecontrolbisdefault[i][GC_PAUSE ][0] = KEY_2JOY1+6; // Back - //gamecontrolbisdefault[i][GC_SYSTEMMENU][0] = KEY_2JOY1+7; // Start - gamecontrolbisdefault[i][GC_CAMTOGGLE ][0] = KEY_2HAT1+0; // D-Pad Up - gamecontrolbisdefault[i][GC_SCREENSHOT][0] = KEY_2HAT1+1; // D-Pad Down - //gamecontrolbisdefault[i][GC_TALKKEY ][0] = KEY_2HAT1+2; // D-Pad Left - //gamecontrolbisdefault[i][GC_SCORES ][0] = KEY_2HAT1+3; // D-Pad Right + gamecontrolbisdefault[i][GC_JUMP ][1] = KEY_2JOY1+0; // A + gamecontrolbisdefault[i][GC_SPIN ][1] = KEY_2JOY1+2; // X + gamecontrolbisdefault[i][GC_CUSTOM1 ][1] = KEY_2JOY1+1; // B + gamecontrolbisdefault[i][GC_CUSTOM2 ][1] = KEY_2JOY1+3; // Y + gamecontrolbisdefault[i][GC_CUSTOM3 ][1] = KEY_2JOY1+8; // Left Stick + gamecontrolbisdefault[i][GC_CENTERVIEW ][1] = KEY_2JOY1+9; // Right Stick + gamecontrolbisdefault[i][GC_WEAPONPREV ][1] = KEY_2JOY1+4; // LB + gamecontrolbisdefault[i][GC_WEAPONNEXT ][1] = KEY_2JOY1+5; // RB + gamecontrolbisdefault[i][GC_SCREENSHOT ][1] = KEY_2JOY1+6; // Back + //gamecontrolbisdefault[i][GC_SYSTEMMENU ][0] = KEY_2JOY1+7; // Start + gamecontrolbisdefault[i][GC_CAMTOGGLE ][1] = KEY_2HAT1+0; // D-Pad Up + gamecontrolbisdefault[i][GC_VIEWPOINT ][1] = KEY_2HAT1+1; // D-Pad Down + gamecontrolbisdefault[i][GC_TOSSFLAG ][1] = KEY_2HAT1+2; // D-Pad Left + //gamecontrolbisdefault[i][GC_SCORES ][1] = KEY_2HAT1+3; // D-Pad Right } } diff --git a/src/m_menu.c b/src/m_menu.c index 3ec49356c..7d9b2249f 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -4438,22 +4438,21 @@ static void M_DrawGenericMenu(void) } } -const char *PlaystyleNames[4] = {"Strafe", "Standard", "Simple", "Old Analog??"}; +const char *PlaystyleNames[4] = {"\x86Strafe\x80", "Manual", "Automatic", "Old Analog??"}; const char *PlaystyleDesc[4] = { - // Legacy - "The play style used for\n" - "old-school SRB2.\n" + // Strafe (or Legacy) + "A play style resembling\n" + "old-school SRB2 gameplay.\n" "\n" "This play style is identical\n" - "to Standard, except that the\n" + "to Manual, except that the\n" "player always looks in the\n" "direction of the camera." , - // Standard - "The default play style,\n" - "designed for full control\n" - "with a keyboard and mouse.\n" + // Manual (formerly Standard) + "A play style made for full control,\n" + "using a keyboard and mouse.\n" "\n" "The camera rotates only when\n" "you tell it to. The player\n" @@ -4465,8 +4464,8 @@ const char *PlaystyleDesc[4] = { "open up the highest level of play!" , - // Simple - "A play style designed for\n" + // Automatic (formerly Simple) + "The default play style, designed for\n" "gamepads and hassle-free play.\n" "\n" "The camera rotates automatically\n" @@ -4475,7 +4474,8 @@ const char *PlaystyleDesc[4] = { "they're moving.\n" "\n" "Hold \x82" "Center View\x80 to lock the\n" - "camera behind the player!\n" + "camera behind the player, or target\n" + "enemies, bosses and monitors!\n" , // Old Analog @@ -4486,7 +4486,7 @@ const char *PlaystyleDesc[4] = { "your config file and brought it back.\n" "\n" "That's absolutely valid, but I implore\n" - "you to try the new Simple play style\n" + "you to try the new Automatic play style\n" "instead!" }; @@ -9062,7 +9062,7 @@ static void M_LoadGame(INT32 choice) if (tutorialmap && cv_tutorialprompt.value) { - M_StartMessage("Do you want to \x82play a brief Tutorial\x80?\n\nWe highly recommend this because \nthe controls are slightly different \nfrom other games.\n\nPress 'Y' or 'Enter' to go\nPress 'N' or any key to skip\n", + M_StartMessage("Do you want to \x82play a brief Tutorial\x80?\n\nWe highly recommend this because \nthe controls are slightly different \nfrom other games.\n\nPress the \x82\Y\x80 key or the \x83\A button\x80 to go\nPress the \x82\N\x80 key or the \x83\Y button\x80 to skip\n", M_FirstTimeResponse, MM_YESNO); return; } @@ -13008,6 +13008,7 @@ static void M_DrawPlaystyleMenu(void) if (i == playstyle_currentchoice) { + V_DrawFill(20, 40, 280, 150, 159); V_DrawScaledPatch((i+1)*BASEVIDWIDTH/4 - 8, 10, 0, W_CachePatchName("M_CURSOR", PU_CACHE)); V_DrawString(30, 50, V_ALLOWLOWERCASE, PlaystyleDesc[i]); } diff --git a/src/p_user.c b/src/p_user.c index 9b48442fe..bfb8d9283 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -1191,7 +1191,7 @@ void P_GivePlayerRings(player_t *player, INT32 num_rings) { if (!player) return; - + if ((player->bot == BOT_2PAI || player->bot == BOT_2PHUMAN) && player->botleader) player = player->botleader; @@ -9624,7 +9624,7 @@ consvar_t cv_cam_still = CVAR_INIT ("cam_still", "Off", 0, CV_OnOff, NULL); consvar_t cv_cam_speed = CVAR_INIT ("cam_speed", "0.3", CV_FLOAT|CV_SAVE, CV_CamSpeed, NULL); consvar_t cv_cam_rotate = CVAR_INIT ("cam_rotate", "0", CV_CALL|CV_NOINIT, CV_CamRotate, CV_CamRotate_OnChange); consvar_t cv_cam_rotspeed = CVAR_INIT ("cam_rotspeed", "10", CV_SAVE, rotation_cons_t, NULL); -consvar_t cv_cam_turnmultiplier = CVAR_INIT ("cam_turnmultiplier", "1.0", CV_FLOAT|CV_SAVE, multiplier_cons_t, NULL); +consvar_t cv_cam_turnmultiplier = CVAR_INIT ("cam_turnmultiplier", "0.75", CV_FLOAT|CV_SAVE, multiplier_cons_t, NULL); consvar_t cv_cam_orbit = CVAR_INIT ("cam_orbit", "Off", CV_SAVE, CV_OnOff, NULL); consvar_t cv_cam_adjust = CVAR_INIT ("cam_adjust", "On", CV_SAVE, CV_OnOff, NULL); consvar_t cv_cam2_dist = CVAR_INIT ("cam2_curdist", "160", CV_FLOAT, NULL, NULL); @@ -9633,19 +9633,19 @@ consvar_t cv_cam2_still = CVAR_INIT ("cam2_still", "Off", 0, CV_OnOff, NULL); consvar_t cv_cam2_speed = CVAR_INIT ("cam2_speed", "0.3", CV_FLOAT|CV_SAVE, CV_CamSpeed, NULL); consvar_t cv_cam2_rotate = CVAR_INIT ("cam2_rotate", "0", CV_CALL|CV_NOINIT, CV_CamRotate, CV_CamRotate2_OnChange); consvar_t cv_cam2_rotspeed = CVAR_INIT ("cam2_rotspeed", "10", CV_SAVE, rotation_cons_t, NULL); -consvar_t cv_cam2_turnmultiplier = CVAR_INIT ("cam2_turnmultiplier", "1.0", CV_FLOAT|CV_SAVE, multiplier_cons_t, NULL); +consvar_t cv_cam2_turnmultiplier = CVAR_INIT ("cam2_turnmultiplier", "0.75", CV_FLOAT|CV_SAVE, multiplier_cons_t, NULL); consvar_t cv_cam2_orbit = CVAR_INIT ("cam2_orbit", "Off", CV_SAVE, CV_OnOff, NULL); consvar_t cv_cam2_adjust = CVAR_INIT ("cam2_adjust", "On", CV_SAVE, CV_OnOff, NULL); // [standard vs simple][p1 or p2] consvar_t cv_cam_savedist[2][2] = { { // standard - CVAR_INIT ("cam_dist", "160", CV_FLOAT|CV_SAVE|CV_CALL, NULL, CV_UpdateCamDist), - CVAR_INIT ("cam2_dist", "160", CV_FLOAT|CV_SAVE|CV_CALL, NULL, CV_UpdateCam2Dist), + CVAR_INIT ("cam_dist", "192", CV_FLOAT|CV_SAVE|CV_CALL, NULL, CV_UpdateCamDist), + CVAR_INIT ("cam2_dist", "192", CV_FLOAT|CV_SAVE|CV_CALL, NULL, CV_UpdateCam2Dist), }, { // simple - CVAR_INIT ("cam_simpledist", "224", CV_FLOAT|CV_SAVE|CV_CALL, NULL, CV_UpdateCamDist), - CVAR_INIT ("cam2_simpledist", "224", CV_FLOAT|CV_SAVE|CV_CALL, NULL, CV_UpdateCam2Dist), + CVAR_INIT ("cam_simpledist", "256", CV_FLOAT|CV_SAVE|CV_CALL, NULL, CV_UpdateCamDist), + CVAR_INIT ("cam2_simpledist", "256", CV_FLOAT|CV_SAVE|CV_CALL, NULL, CV_UpdateCam2Dist), } }; @@ -9838,17 +9838,7 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall if (P_CameraThinker(player, thiscam, resetcalled)) return true; - if (tutorialmode) - { - // force defaults because we have a camera look section - camspeed = (INT32)(atof(cv_cam_speed.defaultvalue) * FRACUNIT); - camstill = (!stricmp(cv_cam_still.defaultvalue, "off")) ? false : true; - camorbit = (!stricmp(cv_cam_orbit.defaultvalue, "off")) ? false : true; - camrotate = atoi(cv_cam_rotate.defaultvalue); - camdist = FixedMul((INT32)(atof(cv_cam_dist.defaultvalue) * FRACUNIT), mo->scale); - camheight = FixedMul((INT32)(atof(cv_cam_height.defaultvalue) * FRACUNIT), mo->scale); - } - else if (thiscam == &camera) + if (thiscam == &camera) { camspeed = cv_cam_speed.value; camstill = cv_cam_still.value; @@ -11619,7 +11609,7 @@ void P_PlayerThink(player_t *player) INT32 i, total = 0, exiting = 0; for (i = 0; i < MAXPLAYERS; i++) - { + { if (!playeringame[i] || players[i].spectator || players[i].bot) continue; if (players[i].quittime > 30 * TICRATE) @@ -12560,7 +12550,7 @@ void P_PlayerAfterThink(player_t *player) player->mo->momy = tails->momy; player->mo->momz = tails->momz; } - + if (G_CoopGametype() && tails->player && tails->player->bot != BOT_2PAI) { player->mo->angle = tails->angle; diff --git a/src/s_sound.c b/src/s_sound.c index 30f242369..76f0d67c1 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -74,9 +74,9 @@ consvar_t stereoreverse = CVAR_INIT ("stereoreverse", "Off", CV_SAVE, CV_OnOff, static consvar_t precachesound = CVAR_INIT ("precachesound", "Off", CV_SAVE, CV_OnOff, NULL); // actual general (maximum) sound & music volume, saved into the config -consvar_t cv_soundvolume = CVAR_INIT ("soundvolume", "18", CV_SAVE, soundvolume_cons_t, NULL); -consvar_t cv_digmusicvolume = CVAR_INIT ("digmusicvolume", "18", CV_SAVE, soundvolume_cons_t, NULL); -consvar_t cv_midimusicvolume = CVAR_INIT ("midimusicvolume", "18", CV_SAVE, soundvolume_cons_t, NULL); +consvar_t cv_soundvolume = CVAR_INIT ("soundvolume", "16", CV_SAVE, soundvolume_cons_t, NULL); +consvar_t cv_digmusicvolume = CVAR_INIT ("digmusicvolume", "16", CV_SAVE, soundvolume_cons_t, NULL); +consvar_t cv_midimusicvolume = CVAR_INIT ("midimusicvolume", "16", CV_SAVE, soundvolume_cons_t, NULL); static void Captioning_OnChange(void) { From 4d1fb04327bbd52c7b654a0da34adfd1a376f4ac Mon Sep 17 00:00:00 2001 From: spherallic Date: Fri, 17 Dec 2021 11:53:10 +0100 Subject: [PATCH 0990/1080] Update playstyle names on the input display --- src/st_stuff.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/st_stuff.c b/src/st_stuff.c index ebf188a06..f17b58fa6 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -1176,7 +1176,17 @@ static void ST_drawInput(void) break; case CS_SIMPLE: - V_DrawThinString(x, y, hudinfo[HUD_LIVES].f, "SIMPLE"); + V_DrawThinString(x, y, hudinfo[HUD_LIVES].f, "AUTOMATIC"); + y -= 8; + break; + + case CS_STANDARD: + V_DrawThinString(x, y, hudinfo[HUD_LIVES].f, "MANUAL"); + y -= 8; + break; + + case CS_LEGACY: + V_DrawThinString(x, y, hudinfo[HUD_LIVES].f, "STRAFE"); y -= 8; break; From 17251895ea33f106874cb680b9c45e1cf995af46 Mon Sep 17 00:00:00 2001 From: spherallic Date: Fri, 24 Dec 2021 18:07:14 +0100 Subject: [PATCH 0991/1080] Increase default camera height for both playstyles --- src/p_user.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index bfb8d9283..0aff39949 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -9651,12 +9651,12 @@ consvar_t cv_cam_savedist[2][2] = { }; consvar_t cv_cam_saveheight[2][2] = { { // standard - CVAR_INIT ("cam_height", "25", CV_FLOAT|CV_SAVE|CV_CALL, NULL, CV_UpdateCamDist), - CVAR_INIT ("cam2_height", "25", CV_FLOAT|CV_SAVE|CV_CALL, NULL, CV_UpdateCam2Dist), + CVAR_INIT ("cam_height", "40", CV_FLOAT|CV_SAVE|CV_CALL, NULL, CV_UpdateCamDist), + CVAR_INIT ("cam2_height", "40", CV_FLOAT|CV_SAVE|CV_CALL, NULL, CV_UpdateCam2Dist), }, { // simple - CVAR_INIT ("cam_simpleheight", "48", CV_FLOAT|CV_SAVE|CV_CALL, NULL, CV_UpdateCamDist), - CVAR_INIT ("cam2_simpleheight", "48", CV_FLOAT|CV_SAVE|CV_CALL, NULL, CV_UpdateCam2Dist), + CVAR_INIT ("cam_simpleheight", "60", CV_FLOAT|CV_SAVE|CV_CALL, NULL, CV_UpdateCamDist), + CVAR_INIT ("cam2_simpleheight", "60", CV_FLOAT|CV_SAVE|CV_CALL, NULL, CV_UpdateCam2Dist), } }; From d9410e3e6a7cd19c5b68a53bc24d58b5bbe635fe Mon Sep 17 00:00:00 2001 From: spherallic Date: Thu, 30 Dec 2021 16:29:37 +0100 Subject: [PATCH 0992/1080] fix compile warnings (this really puts the mess in message) --- 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 7d9b2249f..af22e62a0 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -9062,7 +9062,7 @@ static void M_LoadGame(INT32 choice) if (tutorialmap && cv_tutorialprompt.value) { - M_StartMessage("Do you want to \x82play a brief Tutorial\x80?\n\nWe highly recommend this because \nthe controls are slightly different \nfrom other games.\n\nPress the \x82\Y\x80 key or the \x83\A button\x80 to go\nPress the \x82\N\x80 key or the \x83\Y button\x80 to skip\n", + M_StartMessage("Do you want to \x82play a brief Tutorial\x80?\n\nWe highly recommend this because \nthe controls are slightly different \nfrom other games.\n\nPress the\x82 Y\x80 key or the\x83 A button\x80 to go\nPress the\x82 N\x80 key or the\x83 Y button\x80 to skip\n", M_FirstTimeResponse, MM_YESNO); return; } From 2886a277d8d4a4deb725a1e840579d8e5dc1070e Mon Sep 17 00:00:00 2001 From: MascaraSnake Date: Fri, 31 Dec 2021 15:00:27 +0100 Subject: [PATCH 0993/1080] Turn the fog wall linedef type into a blendmode --- extras/conf/udb/Includes/SRB222_misc.cfg | 1 + src/deh_tables.c | 1 + src/hardware/hw_main.c | 4 ++-- src/p_setup.c | 5 +++++ src/r_defs.h | 2 +- src/r_segs.c | 14 +++++++------- 6 files changed, 17 insertions(+), 10 deletions(-) diff --git a/extras/conf/udb/Includes/SRB222_misc.cfg b/extras/conf/udb/Includes/SRB222_misc.cfg index 1b4fb4b4b..50c83e456 100644 --- a/extras/conf/udb/Includes/SRB222_misc.cfg +++ b/extras/conf/udb/Includes/SRB222_misc.cfg @@ -70,6 +70,7 @@ linedefrenderstyles subtract = "Subtract"; reversesubtract = "Reverse subtract"; modulate = "Modulate"; + fog = "Fog"; } sectorflags diff --git a/src/deh_tables.c b/src/deh_tables.c index 146a04f7f..e07d44453 100644 --- a/src/deh_tables.c +++ b/src/deh_tables.c @@ -4898,6 +4898,7 @@ struct int_const_s const INT_CONST[] = { {"AST_REVERSESUBTRACT",AST_REVERSESUBTRACT}, {"AST_MODULATE",AST_MODULATE}, {"AST_OVERLAY",AST_OVERLAY}, + {"AST_FOG",AST_FOG}, // Render flags {"RF_HORIZONTALFLIP",RF_HORIZONTALFLIP}, diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index a1dd53eb7..13b2a39c3 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -1454,13 +1454,13 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom case 221: case 253: case 256: - if (gl_linedef->blendmode) + if (gl_linedef->blendmode != AST_FOG) blendmode = HWR_SurfaceBlend(gl_linedef->blendmode, R_GetLinedefTransTable(gl_linedef->alpha), &Surf); else blendmode = PF_Translucent; break; default: - if (gl_linedef->blendmode) + if (gl_linedef->blendmode != AST_FOG) { if (gl_linedef->alpha >= 0 && gl_linedef->alpha < FRACUNIT) blendmode = HWR_SurfaceBlend(gl_linedef->blendmode, R_GetLinedefTransTable(gl_linedef->alpha), &Surf); diff --git a/src/p_setup.c b/src/p_setup.c index 6f0e11c03..6f06abf1b 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -1713,6 +1713,8 @@ static void ParseTextmapLinedefParameter(UINT32 i, char *param, char *val) lines[i].blendmode = AST_REVERSESUBTRACT; else if (fastcmp(val, "modulate")) lines[i].blendmode = AST_MODULATE; + if (fastcmp(val, "fog")) + lines[i].blendmode = AST_FOG; } else if (fastcmp(param, "executordelay")) lines[i].executordelay = atol(val); @@ -3330,6 +3332,9 @@ static void P_ConvertBinaryMap(void) lines[i].args[4] |= TMSC_BACKTOFRONTCEILING; lines[i].special = 720; break; + case 909: //Fog wall + lines[i].blendmode = AST_FOG; + break; default: break; } diff --git a/src/r_defs.h b/src/r_defs.h index 3c2178937..fa63de400 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -716,7 +716,7 @@ typedef struct #endif // Possible alpha types for a patch. -enum patchalphastyle {AST_COPY, AST_TRANSLUCENT, AST_ADD, AST_SUBTRACT, AST_REVERSESUBTRACT, AST_MODULATE, AST_OVERLAY}; +enum patchalphastyle {AST_COPY, AST_TRANSLUCENT, AST_ADD, AST_SUBTRACT, AST_REVERSESUBTRACT, AST_MODULATE, AST_OVERLAY, AST_FOG}; typedef enum { diff --git a/src/r_segs.c b/src/r_segs.c index 4460f9f90..2459436b5 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -155,7 +155,13 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2) if (!ldef->alpha) return; - if (ldef->blendmode) + if (ldef->blendmode == AST_FOG) + { + colfunc = colfuncs[COLDRAWFUNC_FOG]; + windowtop = frontsector->ceilingheight; + windowbottom = frontsector->floorheight; + } + else if (ldef->blendmode) { if (ldef->alpha == NUMTRANSMAPS || ldef->blendmode == AST_MODULATE) dc_transmap = R_GetBlendTable(ldef->blendmode, 0); @@ -168,12 +174,6 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2) dc_transmap = R_GetTranslucencyTable(R_GetLinedefTransTable(ldef->alpha)); colfunc = colfuncs[COLDRAWFUNC_FUZZY]; } - else if (ldef->special == 909) - { - colfunc = colfuncs[COLDRAWFUNC_FOG]; - windowtop = frontsector->ceilingheight; - windowbottom = frontsector->floorheight; - } else colfunc = colfuncs[BASEDRAWFUNC]; From 719ceb0586bdc462f14800a902a4af9502a59896 Mon Sep 17 00:00:00 2001 From: spherallic Date: Sat, 1 Jan 2022 19:34:27 +0100 Subject: [PATCH 0994/1080] Add collision check for flipped water drops --- src/p_mobj.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index 39c6731b8..87e20fd4a 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -7740,7 +7740,8 @@ static void P_MobjSceneryThink(mobj_t *mobj) break; case MT_WATERDROP: P_SceneryCheckWater(mobj); - if ((mobj->z <= mobj->floorz || mobj->z <= mobj->watertop) + if (((!(mobj->eflags & MFE_VERTICALFLIP) && (mobj->z <= mobj->floorz || mobj->z <= mobj->watertop)) + || (mobj->eflags & MFE_VERTICALFLIP && mobj->z + mobj->height >= mobj->ceilingz)) && mobj->health > 0) { mobj->health = 0; From d9bc478822f4ea9df901ea6485f6f62f3d4426ec Mon Sep 17 00:00:00 2001 From: LJ Sonic Date: Sun, 2 Jan 2022 15:39:16 +0100 Subject: [PATCH 0995/1080] Cleanup blank chatbox checking code --- src/hu_stuff.c | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 3107057a1..086d9f799 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -946,25 +946,15 @@ void HU_Ticker(void) static boolean teamtalk = false; -// Clear spaces so we don't end up with messages only made out of emptiness -static boolean HU_clearChatSpaces(void) +static boolean HU_chatboxContainsOnlySpaces(void) { - size_t i = 0; // Used to just check our message - char c; // current character we're iterating. - boolean nothingbutspaces = true; + size_t i; - for (; i < strlen(w_chat); i++) // iterate through message and eradicate all spaces that don't belong. - { - c = w_chat[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. + for (i = 0; w_chat[i]; i++) + if (w_chat[i] != ' ') + return false; - if (c != ' ') // Isn't a space - { - nothingbutspaces = false; - } - } - return nothingbutspaces; + return true; } // @@ -980,8 +970,9 @@ static void HU_queueChatChar(char c) size_t ci = 2; INT32 target = 0; - if (HU_clearChatSpaces()) // Avoids being able to send empty messages, or something. - return; // If this returns true, that means our message was NOTHING but spaces, so don't send it period. + // if our message was nothing but spaces, don't send it. + if (HU_chatboxContainsOnlySpaces()) + return; do { c = w_chat[-2+ci++]; From 34ad64ba591aa969d080a56edfaf5f4bc53b3ddd Mon Sep 17 00:00:00 2001 From: LJ Sonic Date: Sun, 2 Jan 2022 15:41:54 +0100 Subject: [PATCH 0996/1080] Cleanup chatbox reset code --- src/hu_stuff.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 086d9f799..50be5e233 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -966,7 +966,6 @@ static void HU_queueChatChar(char c) { char buf[2+256]; char *msg = &buf[2]; - size_t i = 0; size_t ci = 2; INT32 target = 0; @@ -980,9 +979,7 @@ static void HU_queueChatChar(char c) buf[ci-1]=c; } while (c); - for (;(i Date: Sun, 2 Jan 2022 15:48:31 +0100 Subject: [PATCH 0997/1080] Cleanup chatbox sanitizing code --- src/hu_stuff.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 50be5e233..fdbef2980 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -966,18 +966,21 @@ static void HU_queueChatChar(char c) { char buf[2+256]; char *msg = &buf[2]; - size_t ci = 2; + size_t ci; INT32 target = 0; // if our message was nothing but spaces, don't send it. if (HU_chatboxContainsOnlySpaces()) return; - do { - c = w_chat[-2+ci++]; - if (!c || (c >= ' ' && !(c & 0x80))) // copy printable characters and terminating '\0' only. - buf[ci-1]=c; - } while (c); + // copy printable characters and terminating '\0' only. + for (ci = 2; w_chat[ci-2]; ci++) + { + c = w_chat[ci-2]; + if (c >= ' ' && !(c & 0x80)) + buf[ci] = c; + }; + buf[ci] = '\0'; memset(w_chat, '\0', HU_MAXMSGLEN); c_input = 0; From 3638d5d55692090da133b66ad93d9ddbf5570555 Mon Sep 17 00:00:00 2001 From: LJ Sonic Date: Sun, 2 Jan 2022 17:08:10 +0100 Subject: [PATCH 0998/1080] Cleanup chat code a little --- src/hu_stuff.c | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/src/hu_stuff.c b/src/hu_stuff.c index fdbef2980..29686cd26 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -957,11 +957,8 @@ static boolean HU_chatboxContainsOnlySpaces(void) return true; } -// -// static void HU_queueChatChar(char c) { - // send automaticly the message (no more chat char) if (c == KEY_ENTER) { char buf[2+256]; @@ -1010,7 +1007,7 @@ static void HU_queueChatChar(char c) strncpy(playernum, msg+3, 3); // check for undesirable characters in our "number" - if (((playernum[0] < '0') || (playernum[0] > '9')) || ((playernum[1] < '0') || (playernum[1] > '9'))) + if (!(isdigit(playernum[0]) && isdigit(playernum[1]))) { // check if playernum[1] is a space if (playernum[1] == ' ') @@ -1023,17 +1020,13 @@ static void HU_queueChatChar(char c) } } // I'm very bad at C, I swear I am, additional checks eww! - if (spc != 0) + if (spc != 0 && msg[5] != ' ') { - if (msg[5] != ' ') - { - HU_AddChatText("\x82NOTICE: \x80Invalid command format. Correct format is \'/pm \'.", false); - return; - } + HU_AddChatText("\x82NOTICE: \x80Invalid command format. Correct format is \'/pm \'.", false); + return; } target = atoi(playernum); // turn that into a number - //CONS_Printf("%d\n", target); // check for target player, if it doesn't exist then we can't send the message! if (target < MAXPLAYERS && playeringame[target]) // player exists @@ -1050,11 +1043,7 @@ static void HU_queueChatChar(char c) } if (ci > 3) // don't send target+flags+empty message. { - if (teamtalk) - buf[0] = -1; // target - else - buf[0] = target; - + buf[0] = teamtalk ? -1 : target; // target buf[1] = 0; // flags SendNetXCmd(XD_SAY, buf, 2 + strlen(&buf[2]) + 1); } From b8975b6a71c9814aa9f0f0630de1d77754a0b56c Mon Sep 17 00:00:00 2001 From: LJ Sonic Date: Sun, 2 Jan 2022 17:38:49 +0100 Subject: [PATCH 0999/1080] Group related chat stuff together --- src/hu_stuff.c | 144 ++++++++++++++++++++++++------------------------- 1 file changed, 71 insertions(+), 73 deletions(-) diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 29686cd26..60f3d9969 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -858,72 +858,6 @@ static void Got_Saycmd(UINT8 **p, INT32 playernum) #endif } -// Handles key input and string input -// -static inline boolean HU_keyInChatString(char *s, char ch) -{ - size_t l; - - if ((ch >= HU_FONTSTART && ch <= HU_FONTEND && hu_font[ch-HU_FONTSTART]) - || ch == ' ') // Allow spaces, of course - { - l = strlen(s); - if (l < HU_MAXMSGLEN - 1) - { - if (c_input >= strlen(s)) // don't do anything complicated - { - s[l++] = ch; - s[l]=0; - } - else - { - - // move everything past c_input for new characters: - size_t m = HU_MAXMSGLEN-1; - while (m>=c_input) - { - if (s[m]) - s[m+1] = (s[m]); - if (m == 0) // prevent overflow - break; - m--; - } - s[c_input] = ch; // and replace this. - } - c_input++; - return true; - } - return false; - } - else if (ch == KEY_BACKSPACE) - { - size_t i = c_input; - - if (c_input <= 0) - return false; - - if (!s[i-1]) - return false; - - if (i >= strlen(s)-1) - { - s[strlen(s)-1] = 0; - c_input--; - return false; - } - - for (; (i < HU_MAXMSGLEN); i++) - { - s[i-1] = s[i]; - } - c_input--; - } - else if (ch != KEY_ENTER) - return false; // did not eat key - - return true; // ate the key -} - #endif // @@ -945,6 +879,10 @@ void HU_Ticker(void) #ifndef NONET static boolean teamtalk = false; +static boolean justscrolleddown; +static boolean justscrolledup; +static INT16 typelines = 1; // number of drawfill lines we need when drawing the chat. it's some weird hack and might be one frame off but I'm lazy to make another loop. +// It's up here since it has to be reset when we open the chat. static boolean HU_chatboxContainsOnlySpaces(void) { @@ -1050,6 +988,73 @@ static void HU_queueChatChar(char c) return; } } + +// Handles key input and string input +// +static inline boolean HU_keyInChatString(char *s, char ch) +{ + size_t l; + + if ((ch >= HU_FONTSTART && ch <= HU_FONTEND && hu_font[ch-HU_FONTSTART]) + || ch == ' ') // Allow spaces, of course + { + l = strlen(s); + if (l < HU_MAXMSGLEN - 1) + { + if (c_input >= strlen(s)) // don't do anything complicated + { + s[l++] = ch; + s[l]=0; + } + else + { + + // move everything past c_input for new characters: + size_t m = HU_MAXMSGLEN-1; + while (m>=c_input) + { + if (s[m]) + s[m+1] = (s[m]); + if (m == 0) // prevent overflow + break; + m--; + } + s[c_input] = ch; // and replace this. + } + c_input++; + return true; + } + return false; + } + else if (ch == KEY_BACKSPACE) + { + size_t i = c_input; + + if (c_input <= 0) + return false; + + if (!s[i-1]) + return false; + + if (i >= strlen(s)-1) + { + s[strlen(s)-1] = 0; + c_input--; + return false; + } + + for (; (i < HU_MAXMSGLEN); i++) + { + s[i-1] = s[i]; + } + c_input--; + } + else if (ch != KEY_ENTER) + return false; // did not eat key + + return true; // ate the key +} + #endif void HU_clearChatChars(void) @@ -1061,13 +1066,6 @@ void HU_clearChatChars(void) I_UpdateMouseGrab(); } -#ifndef NONET -static boolean justscrolleddown; -static boolean justscrolledup; -static INT16 typelines = 1; // number of drawfill lines we need when drawing the chat. it's some weird hack and might be one frame off but I'm lazy to make another loop. -// It's up here since it has to be reset when we open the chat. -#endif - // // Returns true if key eaten // From 2bbbd57c6e3ce058b9bb4510260a1fb0496585ef Mon Sep 17 00:00:00 2001 From: LJ Sonic Date: Sun, 2 Jan 2022 17:55:14 +0100 Subject: [PATCH 1000/1080] Turn HU_queueChatChar into HU_sendChatMessage --- src/hu_stuff.c | 179 +++++++++++++++++++++++-------------------------- 1 file changed, 84 insertions(+), 95 deletions(-) diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 60f3d9969..1def5c153 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -895,103 +895,99 @@ static boolean HU_chatboxContainsOnlySpaces(void) return true; } -static void HU_queueChatChar(char c) +static void HU_sendChatMessage(void) { - if (c == KEY_ENTER) + char buf[2+256]; + char *msg = &buf[2]; + size_t ci; + INT32 target = 0; + + // if our message was nothing but spaces, don't send it. + if (HU_chatboxContainsOnlySpaces()) + return; + + // copy printable characters and terminating '\0' only. + for (ci = 2; w_chat[ci-2]; ci++) { - char buf[2+256]; - char *msg = &buf[2]; - size_t ci; - INT32 target = 0; + char c = w_chat[ci-2]; + if (c >= ' ' && !(c & 0x80)) + buf[ci] = c; + }; + buf[ci] = '\0'; - // if our message was nothing but spaces, don't send it. - if (HU_chatboxContainsOnlySpaces()) - return; + memset(w_chat, '\0', HU_MAXMSGLEN); + c_input = 0; - // copy printable characters and terminating '\0' only. - for (ci = 2; w_chat[ci-2]; ci++) + // last minute mute check + if (CHAT_MUTE) + { + HU_AddChatText(va("%s>ERROR: The chat is muted. You can't say anything.", "\x85"), false); + return; + } + + if (strlen(msg) > 4 && strnicmp(msg, "/pm", 3) == 0) // used /pm + { + INT32 spc = 1; // used if playernum[1] is a space. + char playernum[3]; + const char *newmsg; + + // what we're gonna do now is check if the player exists + // with that logic, characters 4 and 5 are our numbers: + + // teamtalk can't send PMs, just don't send it, else everyone would be able to see it, and no one wants to see your sex RP sicko. + if (teamtalk) { - c = w_chat[ci-2]; - if (c >= ' ' && !(c & 0x80)) - buf[ci] = c; - }; - buf[ci] = '\0'; - - memset(w_chat, '\0', HU_MAXMSGLEN); - c_input = 0; - - // last minute mute check - if (CHAT_MUTE) - { - HU_AddChatText(va("%s>ERROR: The chat is muted. You can't say anything.", "\x85"), false); + HU_AddChatText(va("%sCannot send sayto in Say-Team.", "\x85"), false); return; } - if (strlen(msg) > 4 && strnicmp(msg, "/pm", 3) == 0) // used /pm + strncpy(playernum, msg+3, 3); + // check for undesirable characters in our "number" + if (!(isdigit(playernum[0]) && isdigit(playernum[1]))) { - INT32 spc = 1; // used if playernum[1] is a space. - char playernum[3]; - const char *newmsg; - - // what we're gonna do now is check if the player exists - // with that logic, characters 4 and 5 are our numbers: - - // teamtalk can't send PMs, just don't send it, else everyone would be able to see it, and no one wants to see your sex RP sicko. - if (teamtalk) - { - HU_AddChatText(va("%sCannot send sayto in Say-Team.", "\x85"), false); - return; - } - - strncpy(playernum, msg+3, 3); - // check for undesirable characters in our "number" - if (!(isdigit(playernum[0]) && isdigit(playernum[1]))) - { - // check if playernum[1] is a space - if (playernum[1] == ' ') - spc = 0; - // let it slide - else - { - HU_AddChatText("\x82NOTICE: \x80Invalid command format. Correct format is \'/pm \'.", false); - return; - } - } - // I'm very bad at C, I swear I am, additional checks eww! - if (spc != 0 && msg[5] != ' ') + // check if playernum[1] is a space + if (playernum[1] == ' ') + spc = 0; + // let it slide + else { HU_AddChatText("\x82NOTICE: \x80Invalid command format. Correct format is \'/pm \'.", false); return; } - - target = atoi(playernum); // turn that into a number - - // check for target player, if it doesn't exist then we can't send the message! - if (target < MAXPLAYERS && playeringame[target]) // player exists - target++; // even though playernums are from 0 to 31, target is 1 to 32, so up that by 1 to have it work! - else - { - HU_AddChatText(va("\x82NOTICE: \x80Player %d does not exist.", target), false); // same - return; - } - - // we need to get rid of the /pm - newmsg = msg+5+spc; - strlcpy(msg, newmsg, 255); } - if (ci > 3) // don't send target+flags+empty message. + // I'm very bad at C, I swear I am, additional checks eww! + if (spc != 0 && msg[5] != ' ') { - buf[0] = teamtalk ? -1 : target; // target - buf[1] = 0; // flags - SendNetXCmd(XD_SAY, buf, 2 + strlen(&buf[2]) + 1); + HU_AddChatText("\x82NOTICE: \x80Invalid command format. Correct format is \'/pm \'.", false); + return; } - return; + + target = atoi(playernum); // turn that into a number + + // check for target player, if it doesn't exist then we can't send the message! + if (target < MAXPLAYERS && playeringame[target]) // player exists + target++; // even though playernums are from 0 to 31, target is 1 to 32, so up that by 1 to have it work! + else + { + HU_AddChatText(va("\x82NOTICE: \x80Player %d does not exist.", target), false); // same + return; + } + + // we need to get rid of the /pm + newmsg = msg+5+spc; + strlcpy(msg, newmsg, 255); + } + if (ci > 3) // don't send target+flags+empty message. + { + buf[0] = teamtalk ? -1 : target; // target + buf[1] = 0; // flags + SendNetXCmd(XD_SAY, buf, 2 + strlen(&buf[2]) + 1); } } // Handles key input and string input // -static inline boolean HU_keyInChatString(char *s, char ch) +static inline void HU_keyInChatString(char *s, char ch) { size_t l; @@ -1022,25 +1018,25 @@ static inline boolean HU_keyInChatString(char *s, char ch) s[c_input] = ch; // and replace this. } c_input++; - return true; + return; } - return false; + return; } else if (ch == KEY_BACKSPACE) { size_t i = c_input; if (c_input <= 0) - return false; + return; if (!s[i-1]) - return false; + return; if (i >= strlen(s)-1) { s[strlen(s)-1] = 0; c_input--; - return false; + return; } for (; (i < HU_MAXMSGLEN); i++) @@ -1049,10 +1045,6 @@ static inline boolean HU_keyInChatString(char *s, char ch) } c_input--; } - else if (ch != KEY_ENTER) - return false; // did not eat key - - return true; // ate the key } #endif @@ -1174,14 +1166,9 @@ boolean HU_Responder(event_t *ev) { memcpy(&w_chat[chatlen], paste, pastelen); // copy all of that. c_input += pastelen; - /*size_t i = 0; - for (;i= c_input) @@ -1198,12 +1185,11 @@ boolean HU_Responder(event_t *ev) } } - if (!CHAT_MUTE && HU_keyInChatString(w_chat,c)) - { - HU_queueChatChar(c); - } if (c == KEY_ENTER) { + if (!CHAT_MUTE) + HU_sendChatMessage(); + chat_on = false; c_input = 0; // reset input cursor chat_scrollmedown = true; // you hit enter, so you might wanna autoscroll to see what you just sent. :) @@ -1244,6 +1230,9 @@ boolean HU_Responder(event_t *ev) else c_input++; } + else if (!CHAT_MUTE) + HU_keyInChatString(w_chat, c); + return true; } #endif From 1a21ca14f018748e930ba7cf8eb116a658a9e31c Mon Sep 17 00:00:00 2001 From: spherallic Date: Sun, 2 Jan 2022 20:44:24 +0100 Subject: [PATCH 1001/1080] Fix cyan pixel cutting in Software --- src/r_plane.c | 2 +- src/r_segs.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/r_plane.c b/src/r_plane.c index d854c2342..1f5c0192e 100644 --- a/src/r_plane.c +++ b/src/r_plane.c @@ -862,7 +862,7 @@ void R_DrawSinglePlane(visplane_t *pl) return; // Don't even draw it if (pl->ffloor->blend) // additive, (reverse) subtractive, modulative ds_transmap = R_GetBlendTable(pl->ffloor->blend, trans); - else if (!(ds_transmap = R_GetTranslucencyTable(trans))) + else if (!(ds_transmap = R_GetTranslucencyTable(trans)) || trans == 0) spanfunctype = SPANDRAWFUNC_SPLAT; // Opaque, but allow transparent flat pixels } diff --git a/src/r_segs.c b/src/r_segs.c index 2459436b5..157cf466e 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -614,7 +614,7 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) return; // Don't even draw it if (pfloor->blend) // additive, (reverse) subtractive, modulative dc_transmap = R_GetBlendTable(pfloor->blend, trans); - else if (!(dc_transmap = R_GetTranslucencyTable(trans))) + else if (!(dc_transmap = R_GetTranslucencyTable(trans)) || trans == 0) fuzzy = false; // Opaque } From e761e36c55e3ecf412ee552b6a2dadd25e77d635 Mon Sep 17 00:00:00 2001 From: LJ Sonic Date: Sun, 2 Jan 2022 23:06:34 +0100 Subject: [PATCH 1002/1080] Cleanup and fix chat deleting and pasting --- src/hu_stuff.c | 87 ++++++++++---------------------------------------- src/hu_stuff.h | 2 +- 2 files changed, 17 insertions(+), 72 deletions(-) diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 1def5c153..c43d6b62a 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -76,7 +76,7 @@ patch_t *nto_font[NT_FONTSIZE]; static player_t *plr; boolean chat_on; // entering a chat message? -static char w_chat[HU_MAXMSGLEN]; +static char w_chat[HU_MAXMSGLEN + 1]; static size_t c_input = 0; // let's try to make the chat input less shitty. static boolean headsupactive = false; boolean hu_showscores; // draw rankings @@ -915,7 +915,7 @@ static void HU_sendChatMessage(void) }; buf[ci] = '\0'; - memset(w_chat, '\0', HU_MAXMSGLEN); + memset(w_chat, '\0', sizeof(w_chat)); c_input = 0; // last minute mute check @@ -985,64 +985,27 @@ static void HU_sendChatMessage(void) } } +// // Handles key input and string input // static inline void HU_keyInChatString(char *s, char ch) { - size_t l; - if ((ch >= HU_FONTSTART && ch <= HU_FONTEND && hu_font[ch-HU_FONTSTART]) || ch == ' ') // Allow spaces, of course { - l = strlen(s); - if (l < HU_MAXMSGLEN - 1) - { - if (c_input >= strlen(s)) // don't do anything complicated - { - s[l++] = ch; - s[l]=0; - } - else - { - - // move everything past c_input for new characters: - size_t m = HU_MAXMSGLEN-1; - while (m>=c_input) - { - if (s[m]) - s[m+1] = (s[m]); - if (m == 0) // prevent overflow - break; - m--; - } - s[c_input] = ch; // and replace this. - } - c_input++; + if (strlen(s) >= HU_MAXMSGLEN) return; - } - return; + + memmove(&s[c_input + 1], &s[c_input], strlen(s) - c_input + 1); + s[c_input] = ch; + c_input++; } else if (ch == KEY_BACKSPACE) { - size_t i = c_input; - if (c_input <= 0) return; - if (!s[i-1]) - return; - - if (i >= strlen(s)-1) - { - s[strlen(s)-1] = 0; - c_input--; - return; - } - - for (; (i < HU_MAXMSGLEN); i++) - { - s[i-1] = s[i]; - } + memmove(&s[c_input - 1], &s[c_input], strlen(s) - c_input + 1); c_input--; } } @@ -1051,7 +1014,7 @@ static inline void HU_keyInChatString(char *s, char ch) void HU_clearChatChars(void) { - memset(w_chat, '\0', HU_MAXMSGLEN); + memset(w_chat, '\0', sizeof(w_chat)); chat_on = false; c_input = 0; @@ -1148,12 +1111,11 @@ boolean HU_Responder(event_t *ev) // pasting. pasting is cool. chat is a bit limited, though :( if (((c == 'v' || c == 'V') && ctrldown) && !CHAT_MUTE) { - const char *paste = I_ClipboardPaste(); + const char *paste; size_t chatlen; size_t pastelen; - // create a dummy string real quickly - + paste = I_ClipboardPaste(); if (paste == NULL) return true; @@ -1162,27 +1124,10 @@ boolean HU_Responder(event_t *ev) if (chatlen+pastelen > HU_MAXMSGLEN) return true; // we can't paste this!! - if (c_input >= strlen(w_chat)) // add it at the end of the string. - { - memcpy(&w_chat[chatlen], paste, pastelen); // copy all of that. - c_input += pastelen; - return true; - } - else // otherwise, we need to shift everything and make space, etc etc - { - size_t i = HU_MAXMSGLEN-1; - while (i >= c_input) - { - if (w_chat[i]) - w_chat[i+pastelen] = w_chat[i]; - if (i == 0) // prevent overflow - break; - i--; - } - memcpy(&w_chat[c_input], paste, pastelen); // copy all of that. - c_input += pastelen; - return true; - } + memmove(&w_chat[c_input + pastelen], &w_chat[c_input], pastelen); + memcpy(&w_chat[c_input], paste, pastelen); // copy all of that. + c_input += pastelen; + return true; } if (c == KEY_ENTER) diff --git a/src/hu_stuff.h b/src/hu_stuff.h index 9b7cee2d3..bb1a59e69 100644 --- a/src/hu_stuff.h +++ b/src/hu_stuff.h @@ -62,7 +62,7 @@ typedef struct //------------------------------------ // chat stuff //------------------------------------ -#define HU_MAXMSGLEN 224 +#define HU_MAXMSGLEN 223 #define CHAT_BUFSIZE 64 // that's enough messages, right? We'll delete the older ones when that gets out of hand. #ifdef NETSPLITSCREEN #define OLDCHAT (cv_consolechat.value == 1 || dedicated || vid.width < 640) From b933316f23e809a8ebb5d4d4a41e7051a88cdab1 Mon Sep 17 00:00:00 2001 From: LJ Sonic Date: Sun, 2 Jan 2022 23:19:34 +0100 Subject: [PATCH 1003/1080] Cleanup chat event handling --- src/hu_stuff.c | 55 ++++++++++++++++++++++---------------------------- 1 file changed, 24 insertions(+), 31 deletions(-) diff --git a/src/hu_stuff.c b/src/hu_stuff.c index c43d6b62a..755e7a237 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -985,31 +985,6 @@ static void HU_sendChatMessage(void) } } -// -// Handles key input and string input -// -static inline void HU_keyInChatString(char *s, char ch) -{ - if ((ch >= HU_FONTSTART && ch <= HU_FONTEND && hu_font[ch-HU_FONTSTART]) - || ch == ' ') // Allow spaces, of course - { - if (strlen(s) >= HU_MAXMSGLEN) - return; - - memmove(&s[c_input + 1], &s[c_input], strlen(s) - c_input + 1); - s[c_input] = ch; - c_input++; - } - else if (ch == KEY_BACKSPACE) - { - if (c_input <= 0) - return; - - memmove(&s[c_input - 1], &s[c_input], strlen(s) - c_input + 1); - c_input--; - } -} - #endif void HU_clearChatChars(void) @@ -1102,19 +1077,22 @@ boolean HU_Responder(event_t *ev) if (shiftdown ^ capslock) c = shiftxform[c]; } - 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) c = shiftxform[c]; } // pasting. pasting is cool. chat is a bit limited, though :( - if (((c == 'v' || c == 'V') && ctrldown) && !CHAT_MUTE) + if ((c == 'v' || c == 'V') && ctrldown) { const char *paste; size_t chatlen; size_t pastelen; + if (CHAT_MUTE) + return true; + paste = I_ClipboardPaste(); if (paste == NULL) return true; @@ -1129,8 +1107,7 @@ boolean HU_Responder(event_t *ev) c_input += pastelen; return true; } - - if (c == KEY_ENTER) + else if (c == KEY_ENTER) { if (!CHAT_MUTE) HU_sendChatMessage(); @@ -1175,8 +1152,24 @@ boolean HU_Responder(event_t *ev) else c_input++; } - else if (!CHAT_MUTE) - HU_keyInChatString(w_chat, c); + else if ((c >= HU_FONTSTART && c <= HU_FONTEND && hu_font[c-HU_FONTSTART]) + || c == ' ') // Allow spaces, of course + { + if (CHAT_MUTE || strlen(w_chat) >= HU_MAXMSGLEN) + return true; + + memmove(&w_chat[c_input + 1], &w_chat[c_input], strlen(w_chat) - c_input + 1); + w_chat[c_input] = c; + c_input++; + } + else if (c == KEY_BACKSPACE) + { + if (CHAT_MUTE || c_input <= 0) + return true; + + memmove(&w_chat[c_input - 1], &w_chat[c_input], strlen(w_chat) - c_input + 1); + c_input--; + } return true; } From 055d57c56c9233e7dbf6f588b110373bf54cffb2 Mon Sep 17 00:00:00 2001 From: LJ Sonic Date: Mon, 3 Jan 2022 00:06:20 +0100 Subject: [PATCH 1004/1080] Fix single-letter messages not being sent --- 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 755e7a237..484f3ee43 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -977,7 +977,7 @@ static void HU_sendChatMessage(void) newmsg = msg+5+spc; strlcpy(msg, newmsg, 255); } - if (ci > 3) // don't send target+flags+empty message. + if (ci > 2) // don't send target+flags+empty message. { buf[0] = teamtalk ? -1 : target; // target buf[1] = 0; // flags From 3c8a29f1ff5b62a0ca4ff636b9668df0ff894068 Mon Sep 17 00:00:00 2001 From: LJ Sonic Date: Mon, 3 Jan 2022 00:06:43 +0100 Subject: [PATCH 1005/1080] Add SKIPSTRINGN macro --- src/byteptr.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/byteptr.h b/src/byteptr.h index 4c8414fae..4de415505 100644 --- a/src/byteptr.h +++ b/src/byteptr.h @@ -154,7 +154,8 @@ FUNCINLINE static ATTRINLINE UINT32 readulong(void *ptr) #define WRITESTRING(p,s) do { size_t tmp_i = 0; for (; s[tmp_i] != '\0'; tmp_i++) WRITECHAR(p, s[tmp_i]); WRITECHAR(p, '\0');} while (0) #define WRITEMEM(p,s,n) do { memcpy(p, s, n); p += n; } while (0) -#define SKIPSTRING(p) while (READCHAR(p) != '\0') +#define SKIPSTRING(p) while (READCHAR(p) != '\0') +#define SKIPSTRINGN(p,n) ({ size_t tmp_i = 0; for (; tmp_i < n && READCHAR(p) != '\0'; tmp_i++); }) #define READSTRINGN(p,s,n) ({ size_t tmp_i = 0; for (; tmp_i < n && (s[tmp_i] = READCHAR(p)) != '\0'; tmp_i++); s[tmp_i] = '\0';}) #define READSTRING(p,s) ({ size_t tmp_i = 0; for (; (s[tmp_i] = READCHAR(p)) != '\0'; tmp_i++); s[tmp_i] = '\0';}) From af629fefe996f58a0a77bb0d759a40e31b7e23a6 Mon Sep 17 00:00:00 2001 From: LJ Sonic Date: Mon, 3 Jan 2022 00:08:23 +0100 Subject: [PATCH 1006/1080] Fix long chat messages crashing the game --- 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 484f3ee43..8a8a6498d 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -644,7 +644,7 @@ static void Got_Saycmd(UINT8 **p, INT32 playernum) target = READSINT8(*p); flags = READUINT8(*p); msg = (char *)*p; - SKIPSTRING(*p); + SKIPSTRINGN(*p, HU_MAXMSGLEN); if ((cv_mute.value || flags & (HU_CSAY|HU_SERVER_SAY)) && playernum != serverplayer && !(IsPlayerAdmin(playernum))) { From 159be00109ebe379dd737f811b9f03fc85454681 Mon Sep 17 00:00:00 2001 From: LJ Sonic Date: Mon, 3 Jan 2022 00:30:16 +0100 Subject: [PATCH 1007/1080] Support delete key in chatbox --- src/hu_stuff.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 8a8a6498d..fbd485b0a 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -1170,6 +1170,13 @@ boolean HU_Responder(event_t *ev) memmove(&w_chat[c_input - 1], &w_chat[c_input], strlen(w_chat) - c_input + 1); c_input--; } + else if (c == KEY_DEL) + { + if (CHAT_MUTE || c_input >= strlen(w_chat)) + return true; + + memmove(&w_chat[c_input], &w_chat[c_input + 1], strlen(w_chat) - c_input); + } return true; } From 0241016f6a258f1ef14d5dd2520f76f45bac95fd Mon Sep 17 00:00:00 2001 From: LJ Sonic Date: Mon, 3 Jan 2022 12:13:55 +0100 Subject: [PATCH 1008/1080] Do not attempt to disconnect when a packet checksum is invalid --- src/d_net.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/d_net.c b/src/d_net.c index 3a4746002..fc029f967 100644 --- a/src/d_net.c +++ b/src/d_net.c @@ -1144,8 +1144,9 @@ boolean HGetPacket(void) if (netbuffer->checksum != NetbufferChecksum()) { DEBFILE("Bad packet checksum\n"); - //Net_CloseConnection(nodejustjoined ? (doomcom->remotenode | FORCECLOSE) : doomcom->remotenode); - Net_CloseConnection(doomcom->remotenode); + // Do not disconnect or anything, just ignore the packet. + // Bad checksums with UDP tend to happen very scarcely + // so they are not normally an issue. continue; } From 13778247990d60c2ad8aa5729bc0397ab764eaaa Mon Sep 17 00:00:00 2001 From: LJ Sonic Date: Mon, 3 Jan 2022 22:37:19 +0100 Subject: [PATCH 1009/1080] Fix long chat messages causing net command failures --- src/hu_stuff.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/hu_stuff.c b/src/hu_stuff.c index fbd485b0a..5f838b894 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -634,7 +634,8 @@ static void Got_Saycmd(UINT8 **p, INT32 playernum) SINT8 target; UINT8 flags; const char *dispname; - char *msg; + char msgbuf[HU_MAXMSGLEN + 1]; + char *msg = msgbuf; boolean action = false; char *ptr; INT32 spam_eatmsg = 0; @@ -643,8 +644,7 @@ static void Got_Saycmd(UINT8 **p, INT32 playernum) target = READSINT8(*p); flags = READUINT8(*p); - msg = (char *)*p; - SKIPSTRINGN(*p, HU_MAXMSGLEN); + READSTRINGN(*p, msgbuf, HU_MAXMSGLEN); if ((cv_mute.value || flags & (HU_CSAY|HU_SERVER_SAY)) && playernum != serverplayer && !(IsPlayerAdmin(playernum))) { @@ -913,7 +913,11 @@ static void HU_sendChatMessage(void) if (c >= ' ' && !(c & 0x80)) buf[ci] = c; }; - buf[ci] = '\0'; + if (ci-2 < HU_MAXMSGLEN) + { + buf[ci] = '\0'; + ci++; + } memset(w_chat, '\0', sizeof(w_chat)); c_input = 0; @@ -981,7 +985,7 @@ static void HU_sendChatMessage(void) { buf[0] = teamtalk ? -1 : target; // target buf[1] = 0; // flags - SendNetXCmd(XD_SAY, buf, 2 + strlen(&buf[2]) + 1); + SendNetXCmd(XD_SAY, buf, ci); } } From f9d2fd9ce573b1c47f44c5a09fe9ae65cb4b6e11 Mon Sep 17 00:00:00 2001 From: sphere Date: Mon, 15 Nov 2021 18:03:07 +0100 Subject: [PATCH 1010/1080] blentran part 1: Flag changes & semibright support. --- src/deh_tables.c | 25 ++++++++++++++++------ src/hardware/hw_draw.c | 44 +++++++++------------------------------ src/hardware/hw_main.c | 6 ++++++ src/hu_stuff.c | 22 ++++++++++++-------- src/m_menu.c | 10 ++++----- src/p_pspr.h | 47 ++++++++++++++++++++++++++++++------------ src/r_data.h | 3 --- src/r_defs.h | 23 +++++++++++++-------- src/r_things.c | 22 ++++++++++++++++---- src/r_things.h | 16 +++++++------- src/v_video.c | 29 ++++++++------------------ src/v_video.h | 22 +++++++++++++------- 12 files changed, 151 insertions(+), 118 deletions(-) diff --git a/src/deh_tables.c b/src/deh_tables.c index b80e88ec2..730ae959b 100644 --- a/src/deh_tables.c +++ b/src/deh_tables.c @@ -4843,9 +4843,18 @@ struct int_const_s const INT_CONST[] = { {"FF_RANDOMANIM",FF_RANDOMANIM}, {"FF_GLOBALANIM",FF_GLOBALANIM}, {"FF_FULLBRIGHT",FF_FULLBRIGHT}, + {"FF_SEMIBRIGHT",FF_SEMIBRIGHT}, + {"FF_FULLDARK",FF_FULLDARK}, {"FF_VERTICALFLIP",FF_VERTICALFLIP}, {"FF_HORIZONTALFLIP",FF_HORIZONTALFLIP}, {"FF_PAPERSPRITE",FF_PAPERSPRITE}, + {"FF_FLOORSPRITE",FF_FLOORSPRITE}, + {"FF_BLENDMASK",FF_BLENDMASK}, + {"FF_BLENDSHIFT",FF_BLENDSHIFT}, + {"FF_ADD",FF_ADD}, + {"FF_SUBTRACT",FF_SUBTRACT}, + {"FF_REVERSESUBTRACT",FF_REVERSESUBTRACT}, + {"FF_MODULATE",FF_MODULATE}, {"FF_TRANSMASK",FF_TRANSMASK}, {"FF_TRANSSHIFT",FF_TRANSSHIFT}, // new preshifted translucency (used in source) @@ -4900,9 +4909,10 @@ struct int_const_s const INT_CONST[] = { {"RF_OBJECTSLOPESPLAT",RF_OBJECTSLOPESPLAT}, {"RF_NOSPLATBILLBOARD",RF_NOSPLATBILLBOARD}, {"RF_NOSPLATROLLANGLE",RF_NOSPLATROLLANGLE}, - {"RF_BLENDMASK",RF_BLENDMASK}, + {"RF_BRIGHTMASK",RF_BRIGHTMASK}, {"RF_FULLBRIGHT",RF_FULLBRIGHT}, {"RF_FULLDARK",RF_FULLDARK}, + {"RF_SEMIBRIGHT",RF_SEMIBRIGHT}, {"RF_NOCOLORMAPS",RF_NOCOLORMAPS}, {"RF_SPRITETYPEMASK",RF_SPRITETYPEMASK}, {"RF_PAPERSPRITE",RF_PAPERSPRITE}, @@ -5392,9 +5402,12 @@ struct int_const_s const INT_CONST[] = { {"V_HUDTRANSHALF",V_HUDTRANSHALF}, {"V_HUDTRANS",V_HUDTRANS}, {"V_HUDTRANSDOUBLE",V_HUDTRANSDOUBLE}, - {"V_AUTOFADEOUT",V_AUTOFADEOUT}, - {"V_RETURN8",V_RETURN8}, - {"V_OFFSET",V_OFFSET}, + {"V_BLENDSHIFT",V_BLENDSHIFT}, + {"V_BLENDMASK",V_BLENDMASK}, + {"V_ADD",V_ADD}, + {"V_SUBTRACT",V_SUBTRACT}, + {"V_REVERSESUBTRACT",V_REVERSESUBTRACT}, + {"V_MODULATE",V_MODULATE}, {"V_ALLOWLOWERCASE",V_ALLOWLOWERCASE}, {"V_FLIP",V_FLIP}, {"V_CENTERNAMETAG",V_CENTERNAMETAG}, @@ -5402,8 +5415,8 @@ struct int_const_s const INT_CONST[] = { {"V_SNAPTOBOTTOM",V_SNAPTOBOTTOM}, {"V_SNAPTOLEFT",V_SNAPTOLEFT}, {"V_SNAPTORIGHT",V_SNAPTORIGHT}, - {"V_WRAPX",V_WRAPX}, - {"V_WRAPY",V_WRAPY}, + {"V_AUTOFADEOUT",V_AUTOFADEOUT}, + {"V_RETURN8",V_RETURN8}, {"V_NOSCALESTART",V_NOSCALESTART}, {"V_PERPLAYER",V_PERPLAYER}, diff --git a/src/hardware/hw_draw.c b/src/hardware/hw_draw.c index 8223705bd..89d43a6b4 100644 --- a/src/hardware/hw_draw.c +++ b/src/hardware/hw_draw.c @@ -119,11 +119,6 @@ void HWR_DrawPatch(patch_t *gpatch, INT32 x, INT32 y, INT32 option) flags = PF_Translucent|PF_NoDepthTest; - if (option & V_WRAPX) - flags |= PF_ForceWrapX; - if (option & V_WRAPY) - flags |= PF_ForceWrapY; - // clip it since it is used for bunny scroll in doom I HWD.pfnDrawPolygon(NULL, v, 4, flags); } @@ -145,9 +140,6 @@ void HWR_DrawStretchyFixedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t p UINT8 perplayershuffle = 0; - if (alphalevel >= 10 && alphalevel < 13) - return; - // make patch ready in hardware cache if (!colormap) HWR_GetPatch(gpatch); @@ -191,15 +183,9 @@ void HWR_DrawStretchyFixedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t p offsetx = (float)(gpatch->leftoffset) * fscalew; // top offset - // TODO: make some kind of vertical version of V_FLIP, maybe by deprecating V_OFFSET in future?!? + // TODO: make some kind of vertical version of V_FLIP offsety = (float)(gpatch->topoffset) * fscaleh; - if ((option & (V_NOSCALESTART|V_OFFSET)) == (V_NOSCALESTART|V_OFFSET)) // Multiply by dupx/dupy for crosshairs - { - offsetx *= dupx; - offsety *= dupy; - } - cx -= offsetx; cy -= offsety; } @@ -361,19 +347,15 @@ void HWR_DrawStretchyFixedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t p flags = PF_Translucent|PF_NoDepthTest; - if (option & V_WRAPX) - flags |= PF_ForceWrapX; - if (option & V_WRAPY) - flags |= PF_ForceWrapY; - // clip it since it is used for bunny scroll in doom I if (alphalevel) { FSurfaceInfo Surf; Surf.PolyColor.s.red = Surf.PolyColor.s.green = Surf.PolyColor.s.blue = 0xff; - if (alphalevel == 13) Surf.PolyColor.s.alpha = softwaretranstogl_lo[st_translucency]; - else if (alphalevel == 14) Surf.PolyColor.s.alpha = softwaretranstogl[st_translucency]; - else if (alphalevel == 15) Surf.PolyColor.s.alpha = softwaretranstogl_hi[st_translucency]; + + if (alphalevel == 10) Surf.PolyColor.s.alpha = softwaretranstogl_lo[st_translucency]; + else if (alphalevel == 11) Surf.PolyColor.s.alpha = softwaretranstogl[st_translucency]; + else if (alphalevel == 12) Surf.PolyColor.s.alpha = softwaretranstogl_hi[st_translucency]; else Surf.PolyColor.s.alpha = softwaretranstogl[10-alphalevel]; flags |= PF_Modulated; HWD.pfnDrawPolygon(&Surf, v, 4, flags); @@ -399,9 +381,6 @@ void HWR_DrawCroppedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale, UINT8 perplayershuffle = 0; - if (alphalevel >= 10 && alphalevel < 13) - return; - // make patch ready in hardware cache if (!colormap) HWR_GetPatch(gpatch); @@ -591,11 +570,6 @@ void HWR_DrawCroppedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale, flags = PF_Translucent|PF_NoDepthTest; - if (option & V_WRAPX) - flags |= PF_ForceWrapX; - if (option & V_WRAPY) - flags |= PF_ForceWrapY; - // Auto-crop at splitscreen borders! if (splitscreen && (option & V_PERPLAYER)) { @@ -671,10 +645,12 @@ void HWR_DrawCroppedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale, { FSurfaceInfo Surf; Surf.PolyColor.s.red = Surf.PolyColor.s.green = Surf.PolyColor.s.blue = 0xff; - if (alphalevel == 13) Surf.PolyColor.s.alpha = softwaretranstogl_lo[st_translucency]; - else if (alphalevel == 14) Surf.PolyColor.s.alpha = softwaretranstogl[st_translucency]; - else if (alphalevel == 15) Surf.PolyColor.s.alpha = softwaretranstogl_hi[st_translucency]; + + if (alphalevel == 10) Surf.PolyColor.s.alpha = softwaretranstogl_lo[st_translucency]; + else if (alphalevel == 11) Surf.PolyColor.s.alpha = softwaretranstogl[st_translucency]; + else if (alphalevel == 12) Surf.PolyColor.s.alpha = softwaretranstogl_hi[st_translucency]; else Surf.PolyColor.s.alpha = softwaretranstogl[10-alphalevel]; + flags |= PF_Modulated; HWD.pfnDrawPolygon(&Surf, v, 4, flags); } diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 9bade3d6f..c5e5a3218 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -3916,6 +3916,9 @@ static void HWR_SplitSprite(gl_vissprite_t *spr) } } + if (R_ThingIsSemiBright(spr->mobj)) + lightlevel = 128 + (lightlevel>>1); + for (i = 0; i < sector->numlights; i++) { if (endtop < endrealbot && top < realbot) @@ -4269,6 +4272,9 @@ static void HWR_DrawSprite(gl_vissprite_t *spr) else if (!lightset) lightlevel = sector->lightlevel > 255 ? 255 : sector->lightlevel; + if (R_ThingIsSemiBright(spr->mobj)) + lightlevel = 128 + (lightlevel>>1); + HWR_Lighting(&Surf, lightlevel, colormap); } diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 3107057a1..cf7118fbe 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -1869,7 +1869,7 @@ static void HU_DrawChat_Old(void) static inline void HU_DrawCrosshair(void) { - INT32 i, y; + INT32 i, y, dupz; i = cv_crosshair.value & 3; if (!i) @@ -1885,12 +1885,14 @@ static inline void HU_DrawCrosshair(void) #endif y = viewwindowy + (viewheight>>1); - V_DrawScaledPatch(vid.width>>1, y, V_NOSCALESTART|V_OFFSET|V_TRANSLUCENT, crosshair[i - 1]); + dupz = (vid.dupx < vid.dupy ? vid.dupx : vid.dupy); + + V_DrawFixedPatch(vid.width<<(FRACBITS-1), y<>1); - if (splitscreen) - { -#ifdef HWRENDER + if (!splitscreen) + return; + + #ifdef HWRENDER if (rendermode != render_soft) y += (INT32)gl_viewheight; else -#endif + #endif y += viewheight; - V_DrawScaledPatch(vid.width>>1, y, V_NOSCALESTART|V_OFFSET|V_TRANSLUCENT, crosshair[i - 1]); - } + dupz = (vid.dupx < vid.dupy ? vid.dupx : vid.dupy); + + V_DrawFixedPatch(vid.width<<(FRACBITS-1), y<width - p->leftoffset; for (i = 0; i < 16; i++) { - V_DrawScaledPatch(xx, y, V_WRAPX, W_CachePatchNum(centerlump[i & 1], PU_PATCH)); + V_DrawScaledPatch(xx, y, 0, W_CachePatchNum(centerlump[i & 1], PU_PATCH)); xx += 8; } V_DrawScaledPatch(xx, y, 0, W_CachePatchNum(rightlump, PU_PATCH)); @@ -4134,7 +4134,7 @@ void M_DrawTextBox(INT32 x, INT32 y, INT32 width, INT32 boxlines) p = W_CachePatchNum(viewborderlump[BRDR_L], PU_PATCH); for (n = 0; n < boxlines; n++) { - V_DrawScaledPatch(cx, cy, V_WRAPY, p); + V_DrawScaledPatch(cx, cy, 0, p); cy += step; } V_DrawScaledPatch(cx, cy, 0, W_CachePatchNum(viewborderlump[BRDR_BL], PU_PATCH)); @@ -4146,8 +4146,8 @@ void M_DrawTextBox(INT32 x, INT32 y, INT32 width, INT32 boxlines) cy = y; while (width > 0) { - V_DrawScaledPatch(cx, cy, V_WRAPX, W_CachePatchNum(viewborderlump[BRDR_T], PU_PATCH)); - V_DrawScaledPatch(cx, y + boff + boxlines*step, V_WRAPX, W_CachePatchNum(viewborderlump[BRDR_B], PU_PATCH)); + V_DrawScaledPatch(cx, cy, 0, W_CachePatchNum(viewborderlump[BRDR_T], PU_PATCH)); + V_DrawScaledPatch(cx, y + boff + boxlines*step, 0, W_CachePatchNum(viewborderlump[BRDR_B], PU_PATCH)); width--; cx += step; } @@ -4159,7 +4159,7 @@ void M_DrawTextBox(INT32 x, INT32 y, INT32 width, INT32 boxlines) p = W_CachePatchNum(viewborderlump[BRDR_R], PU_PATCH); for (n = 0; n < boxlines; n++) { - V_DrawScaledPatch(cx, cy, V_WRAPY, p); + V_DrawScaledPatch(cx, cy, 0, p); cy += step; } V_DrawScaledPatch(cx, cy, 0, W_CachePatchNum(viewborderlump[BRDR_BR], PU_PATCH)); diff --git a/src/p_pspr.h b/src/p_pspr.h index 4525ba14c..27002b713 100644 --- a/src/p_pspr.h +++ b/src/p_pspr.h @@ -41,9 +41,20 @@ /// \brief Frame flags - SPR2: Super sprite2 #define FF_SPR2SUPER 0x80 /// \brief Frame flags - SPR2: A change of state at the end of Sprite2 animation -#define FF_SPR2ENDSTATE 0x1000 +#define FF_SPR2ENDSTATE 0x100 /// \brief Frame flags - SPR2: 50% of starting in middle of Sprite2 animation -#define FF_SPR2MIDSTART 0x2000 +#define FF_SPR2MIDSTART 0x200 + +/// \brief Frame flags: blend types +#define FF_BLENDMASK 0x7000 +/// \brief shift for FF_BLENDMASK +#define FF_BLENDSHIFT 12 +/// \brief preshifted blend flags minus 1 as effects don't distinguish between AST_COPY and AST_TRANSLUCENT +#define FF_ADD ((AST_ADD-1)<= MAXLIGHTSCALE) lindex = MAXLIGHTSCALE-1; + + if (newsprite->cut & SC_SEMIBRIGHT) + lindex = (MAXLIGHTSCALE/2) + (lindex >>1); + newsprite->colormap = spritelights[lindex]; } } @@ -2023,6 +2027,8 @@ static void R_ProjectSprite(mobj_t *thing) if (R_ThingIsFullBright(oldthing) || oldthing->flags2 & MF2_SHADOW || thing->flags2 & MF2_SHADOW) vis->cut |= SC_FULLBRIGHT; + else if (R_ThingIsSemiBright(oldthing)) + vis->cut |= SC_SEMIBRIGHT; else if (R_ThingIsFullDark(oldthing)) vis->cut |= SC_FULLDARK; @@ -2045,6 +2051,9 @@ static void R_ProjectSprite(mobj_t *thing) if (lindex >= MAXLIGHTSCALE) lindex = MAXLIGHTSCALE-1; + if (vis->cut & SC_SEMIBRIGHT) + lindex = (MAXLIGHTSCALE/2) + (lindex >> 1); + vis->colormap = spritelights[lindex]; } @@ -3012,7 +3021,7 @@ boolean R_ThingVisible (mobj_t *thing) { return (!( thing->sprite == SPR_NULL || - ( thing->flags2 & (MF2_DONTDRAW) ) || + ( thing->flags2 & (MF2_DONTDRAW) ) || ( thing->renderflags & (RF_DONTDRAW) ) || (r_viewmobj && (thing == r_viewmobj || (r_viewmobj->player && r_viewmobj->player->followmobj == thing))) )); } @@ -3073,17 +3082,22 @@ boolean R_ThingIsPaperSprite(mobj_t *thing) boolean R_ThingIsFloorSprite(mobj_t *thing) { - return (thing->flags2 & MF2_SPLAT || thing->renderflags & RF_FLOORSPRITE); + return (thing->flags2 & MF2_SPLAT || thing->frame & FF_FLOORSPRITE || thing->renderflags & RF_FLOORSPRITE); } boolean R_ThingIsFullBright(mobj_t *thing) { - return (thing->frame & FF_FULLBRIGHT || thing->renderflags & RF_FULLBRIGHT); + return ((thing->frame & FF_BRIGHTMASK) == FF_FULLBRIGHT || (thing->renderflags & RF_BRIGHTMASK) == RF_FULLBRIGHT); +} + +boolean R_ThingIsSemiBright(mobj_t *thing) +{ + return ((thing->frame & FF_BRIGHTMASK) == FF_SEMIBRIGHT || (thing->renderflags & RF_BRIGHTMASK) == RF_SEMIBRIGHT); } boolean R_ThingIsFullDark(mobj_t *thing) { - return (thing->renderflags & RF_FULLDARK); + return ((thing->frame & FF_BRIGHTMASK) == FF_FULLDARK || (thing->renderflags & RF_BRIGHTMASK) == RF_FULLDARK); } // diff --git a/src/r_things.h b/src/r_things.h index 79dc80d94..b1ff32b1e 100644 --- a/src/r_things.h +++ b/src/r_things.h @@ -82,6 +82,7 @@ boolean R_ThingIsPaperSprite (mobj_t *thing); boolean R_ThingIsFloorSprite (mobj_t *thing); boolean R_ThingIsFullBright (mobj_t *thing); +boolean R_ThingIsSemiBright (mobj_t *thing); boolean R_ThingIsFullDark (mobj_t *thing); // -------------- @@ -123,13 +124,14 @@ typedef enum SC_PRECIP = 1<<2, SC_LINKDRAW = 1<<3, SC_FULLBRIGHT = 1<<4, - SC_FULLDARK = 1<<5, - SC_VFLIP = 1<<6, - SC_ISSCALED = 1<<7, - SC_ISROTATED = 1<<8, - SC_SHADOW = 1<<9, - SC_SHEAR = 1<<10, - SC_SPLAT = 1<<11, + SC_SEMIBRIGHT = 1<<5, + SC_FULLDARK = 1<<6, + SC_VFLIP = 1<<7, + SC_ISSCALED = 1<<8, + SC_ISROTATED = 1<<9, + SC_SHADOW = 1<<10, + SC_SHEAR = 1<<11, + SC_SPLAT = 1<<12, // masks SC_CUTMASK = SC_TOP|SC_BOTTOM, SC_FLAGMASK = ~SC_CUTMASK diff --git a/src/v_video.c b/src/v_video.c index c39938544..ad0164816 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -540,11 +540,11 @@ void V_DrawStretchyFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, fixed_t vsca v_translevel = NULL; if ((alphalevel = ((scrn & V_ALPHAMASK) >> V_ALPHASHIFT))) { - if (alphalevel == 13) + if (alphalevel == 10) alphalevel = hudminusalpha[st_translucency]; - else if (alphalevel == 14) + else if (alphalevel == 11) alphalevel = 10 - st_translucency; - else if (alphalevel == 15) + else if (alphalevel == 12) alphalevel = hudplusalpha[st_translucency]; if (alphalevel >= 10) @@ -591,10 +591,6 @@ void V_DrawStretchyFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, fixed_t vsca colfrac = FixedDiv(FRACUNIT, fdup); rowfrac = FixedDiv(FRACUNIT, vdup); - // So it turns out offsets aren't scaled in V_NOSCALESTART unless V_OFFSET is applied ...poo, that's terrible - // For now let's just at least give V_OFFSET the ability to support V_FLIP - // I'll probably make a better fix for 2.2 where I don't have to worry about breaking existing support for stuff - // -- Monster Iestyn 29/10/18 { fixed_t offsetx = 0, offsety = 0; @@ -605,15 +601,8 @@ void V_DrawStretchyFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, fixed_t vsca offsetx = FixedMul(patch->leftoffset<topoffset<> V_ALPHASHIFT))) { - if (alphalevel == 13) + if (alphalevel == 10) alphalevel = hudminusalpha[st_translucency]; - else if (alphalevel == 14) + else if (alphalevel == 11) alphalevel = 10 - st_translucency; - else if (alphalevel == 15) + else if (alphalevel == 12) alphalevel = hudplusalpha[st_translucency]; if (alphalevel >= 10) @@ -1411,11 +1400,11 @@ void V_DrawFillConsoleMap(INT32 x, INT32 y, INT32 w, INT32 h, INT32 c) if ((alphalevel = ((c & V_ALPHAMASK) >> V_ALPHASHIFT))) { - if (alphalevel == 13) + if (alphalevel == 10) alphalevel = hudminusalpha[st_translucency]; - else if (alphalevel == 14) + else if (alphalevel == 11) alphalevel = 10 - st_translucency; - else if (alphalevel == 15) + else if (alphalevel == 12) alphalevel = hudplusalpha[st_translucency]; if (alphalevel >= 10) diff --git a/src/v_video.h b/src/v_video.h index c10ab22ce..bcb39706e 100644 --- a/src/v_video.h +++ b/src/v_video.h @@ -122,17 +122,23 @@ void V_CubeApply(UINT8 *red, UINT8 *green, UINT8 *blue); #define V_70TRANS 0x00070000 #define V_80TRANS 0x00080000 // used to be V_8020TRANS #define V_90TRANS 0x00090000 -#define V_HUDTRANSHALF 0x000D0000 -#define V_HUDTRANS 0x000E0000 // draw the hud translucent -#define V_HUDTRANSDOUBLE 0x000F0000 +#define V_HUDTRANSHALF 0x000A0000 +#define V_HUDTRANS 0x000B0000 // draw the hud translucent +#define V_HUDTRANSDOUBLE 0x000C0000 // Macros follow #define V_USERHUDTRANSHALF ((10-(cv_translucenthud.value/2))< Date: Mon, 15 Nov 2021 19:07:20 +0100 Subject: [PATCH 1011/1080] blentran part 2: Sprite & patch blendmodes. --- src/hardware/hw_draw.c | 16 ++++++++++++---- src/hardware/hw_main.c | 32 +++++++++++++++++++++++++------- src/r_things.c | 14 ++++++++++---- src/v_video.c | 22 ++++++++++++++++------ 4 files changed, 63 insertions(+), 21 deletions(-) diff --git a/src/hardware/hw_draw.c b/src/hardware/hw_draw.c index 89d43a6b4..e02dbea5b 100644 --- a/src/hardware/hw_draw.c +++ b/src/hardware/hw_draw.c @@ -130,6 +130,7 @@ void HWR_DrawStretchyFixedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t p float cx = FIXED_TO_FLOAT(x); float cy = FIXED_TO_FLOAT(y); UINT8 alphalevel = ((option & V_ALPHAMASK) >> V_ALPHASHIFT); + UINT8 blendmode = ((option & V_BLENDMASK) >> V_BLENDSHIFT); GLPatch_t *hwrPatch; // 3--2 @@ -345,9 +346,12 @@ void HWR_DrawStretchyFixedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t p v[0].t = v[1].t = 0.0f; v[2].t = v[3].t = hwrPatch->max_t; - flags = PF_Translucent|PF_NoDepthTest; - // clip it since it is used for bunny scroll in doom I + if (blendmode) + flags = HWR_GetBlendModeFlag(blendmode+1)|PF_NoDepthTest; + else + flags = PF_Translucent|PF_NoDepthTest; + if (alphalevel) { FSurfaceInfo Surf; @@ -371,6 +375,7 @@ void HWR_DrawCroppedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale, float cx = FIXED_TO_FLOAT(x); float cy = FIXED_TO_FLOAT(y); UINT8 alphalevel = ((option & V_ALPHAMASK) >> V_ALPHASHIFT); + UINT8 blendmode = ((option & V_BLENDMASK) >> V_BLENDSHIFT); GLPatch_t *hwrPatch; // 3--2 @@ -568,8 +573,6 @@ void HWR_DrawCroppedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale, else v[2].t = v[3].t = (FIXED_TO_FLOAT(sy+h)/(float)(gpatch->height))*hwrPatch->max_t; - flags = PF_Translucent|PF_NoDepthTest; - // Auto-crop at splitscreen borders! if (splitscreen && (option & V_PERPLAYER)) { @@ -641,6 +644,11 @@ 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 (blendmode) + flags = HWR_GetBlendModeFlag(blendmode+1)|PF_NoDepthTest; + else + flags = PF_Translucent|PF_NoDepthTest; + if (alphalevel) { FSurfaceInfo Surf; diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index c5e5a3218..63f1191ca 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -3853,6 +3853,12 @@ static void HWR_SplitSprite(gl_vissprite_t *spr) else occlusion = PF_Occlude; + INT32 blendmode; + if (spr->mobj->frame & FF_BLENDMASK) + blendmode = ((spr->mobj->frame & FF_BLENDMASK) >> FF_BLENDSHIFT) + 1; + else + blendmode = spr->mobj->blendmode; + if (!cv_translucency.value) // translucency disabled { Surf.PolyColor.s.alpha = 0xFF; @@ -3862,12 +3868,12 @@ static void HWR_SplitSprite(gl_vissprite_t *spr) else if (spr->mobj->flags2 & MF2_SHADOW) { Surf.PolyColor.s.alpha = 0x40; - blend = HWR_GetBlendModeFlag(spr->mobj->blendmode); + blend = HWR_GetBlendModeFlag(blendmode); } else if (spr->mobj->frame & FF_TRANSMASK) { INT32 trans = (spr->mobj->frame & FF_TRANSMASK)>>FF_TRANSSHIFT; - blend = HWR_SurfaceBlend(spr->mobj->blendmode, trans, &Surf); + blend = HWR_SurfaceBlend(blendmode, trans, &Surf); } else { @@ -3876,7 +3882,7 @@ static void HWR_SplitSprite(gl_vissprite_t *spr) // Hurdler: PF_Environement would be cool, but we need to fix // the issue with the fog before Surf.PolyColor.s.alpha = 0xFF; - blend = HWR_GetBlendModeFlag(spr->mobj->blendmode)|occlusion; + blend = HWR_GetBlendModeFlag(blendmode)|occlusion; if (!occlusion) use_linkdraw_hack = true; } @@ -4291,6 +4297,12 @@ static void HWR_DrawSprite(gl_vissprite_t *spr) else occlusion = PF_Occlude; + INT32 blendmode; + if (spr->mobj->frame & FF_BLENDMASK) + blendmode = ((spr->mobj->frame & FF_BLENDMASK) >> FF_BLENDSHIFT) + 1; + else + blendmode = spr->mobj->blendmode; + if (!cv_translucency.value) // translucency disabled { Surf.PolyColor.s.alpha = 0xFF; @@ -4300,12 +4312,12 @@ static void HWR_DrawSprite(gl_vissprite_t *spr) else if (spr->mobj->flags2 & MF2_SHADOW) { Surf.PolyColor.s.alpha = 0x40; - blend = HWR_GetBlendModeFlag(spr->mobj->blendmode); + blend = HWR_GetBlendModeFlag(blendmode); } else if (spr->mobj->frame & FF_TRANSMASK) { INT32 trans = (spr->mobj->frame & FF_TRANSMASK)>>FF_TRANSSHIFT; - blend = HWR_SurfaceBlend(spr->mobj->blendmode, trans, &Surf); + blend = HWR_SurfaceBlend(blendmode, trans, &Surf); } else { @@ -4314,7 +4326,7 @@ static void HWR_DrawSprite(gl_vissprite_t *spr) // Hurdler: PF_Environement would be cool, but we need to fix // the issue with the fog before Surf.PolyColor.s.alpha = 0xFF; - blend = HWR_GetBlendModeFlag(spr->mobj->blendmode)|occlusion; + blend = HWR_GetBlendModeFlag(blendmode)|occlusion; if (!occlusion) use_linkdraw_hack = true; } @@ -5009,10 +5021,16 @@ static void HWR_ProjectSprite(mobj_t *thing) if (thing->spritexscale < 1 || thing->spriteyscale < 1) return; + INT32 blendmode; + if (thing->frame & FF_BLENDMASK) + blendmode = ((thing->frame & FF_BLENDMASK) >> FF_BLENDSHIFT) + 1; + else + blendmode = thing->blendmode; + // Visibility check by the blend mode. if (thing->frame & FF_TRANSMASK) { - if (!R_BlendLevelVisible(thing->blendmode, (thing->frame & FF_TRANSMASK)>>FF_TRANSSHIFT)) + if (!R_BlendLevelVisible(blendmode, (thing->frame & FF_TRANSMASK)>>FF_TRANSSHIFT)) return; } diff --git a/src/r_things.c b/src/r_things.c index 5d5be8753..accd1e2b3 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -1802,13 +1802,19 @@ static void R_ProjectSprite(mobj_t *thing) return; } + INT32 blendmode; + if (oldthing->frame & FF_BLENDMASK) + blendmode = ((oldthing->frame & FF_BLENDMASK) >> FF_BLENDSHIFT) + 1; + else + blendmode = oldthing->blendmode; + // Determine the translucency value. if (oldthing->flags2 & MF2_SHADOW || 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 (oldthing->frame & FF_TRANSMASK) { trans = (oldthing->frame & FF_TRANSMASK) >> FF_TRANSSHIFT; - if (!R_BlendLevelVisible(oldthing->blendmode, trans)) + if (!R_BlendLevelVisible(blendmode, trans)) return; } else @@ -2020,8 +2026,8 @@ static void R_ProjectSprite(mobj_t *thing) vis->scale += FixedMul(scalestep, spriteyscale) * (vis->x1 - x1); } - if ((oldthing->blendmode != AST_COPY) && cv_translucency.value) - vis->transmap = R_GetBlendTable(oldthing->blendmode, trans); + if ((blendmode != AST_COPY) && cv_translucency.value) + vis->transmap = R_GetBlendTable(blendmode, trans); else vis->transmap = NULL; @@ -3021,7 +3027,7 @@ boolean R_ThingVisible (mobj_t *thing) { return (!( thing->sprite == SPR_NULL || - ( thing->flags2 & (MF2_DONTDRAW) ) || ( thing->renderflags & (RF_DONTDRAW) ) || + ( thing->flags2 & (MF2_DONTDRAW) ) || (r_viewmobj && (thing == r_viewmobj || (r_viewmobj->player && r_viewmobj->player->followmobj == thing))) )); } diff --git a/src/v_video.c b/src/v_video.c index ad0164816..12588f9c2 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -511,7 +511,8 @@ static inline UINT8 transmappedpdraw(const UINT8 *dest, const UINT8 *source, fix void V_DrawStretchyFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, fixed_t vscale, INT32 scrn, patch_t *patch, const UINT8 *colormap) { UINT8 (*patchdrawfunc)(const UINT8*, const UINT8*, fixed_t); - UINT32 alphalevel = 0; + UINT32 alphalevel = ((scrn & V_ALPHAMASK) >> V_ALPHASHIFT); + UINT32 blendmode = ((scrn & V_BLENDMASK) >> V_BLENDSHIFT); fixed_t col, ofs, colfrac, rowfrac, fdup, vdup; INT32 dupx, dupy; @@ -538,7 +539,7 @@ void V_DrawStretchyFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, fixed_t vsca patchdrawfunc = standardpdraw; v_translevel = NULL; - if ((alphalevel = ((scrn & V_ALPHAMASK) >> V_ALPHASHIFT))) + if (alphalevel) { if (alphalevel == 10) alphalevel = hudminusalpha[st_translucency]; @@ -552,7 +553,11 @@ void V_DrawStretchyFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, fixed_t vsca if (alphalevel) { - v_translevel = R_GetTranslucencyTable(alphalevel); + if (blendmode) + v_translevel = R_GetBlendTable(blendmode+1, alphalevel); + else + v_translevel = R_GetTranslucencyTable(alphalevel); + patchdrawfunc = translucentpdraw; } } @@ -801,7 +806,8 @@ void V_DrawStretchyFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, fixed_t vsca void V_DrawCroppedPatch(fixed_t x, fixed_t y, fixed_t pscale, fixed_t vscale, INT32 scrn, patch_t *patch, const UINT8 *colormap, fixed_t sx, fixed_t sy, fixed_t w, fixed_t h) { UINT8 (*patchdrawfunc)(const UINT8*, const UINT8*, fixed_t); - UINT32 alphalevel = 0; + UINT32 alphalevel = ((scrn & V_ALPHAMASK) >> V_ALPHASHIFT); + UINT32 blendmode = ((scrn & V_BLENDMASK) >> V_BLENDSHIFT); // boolean flip = false; fixed_t col, ofs, colfrac, rowfrac, fdup, vdup; @@ -827,7 +833,7 @@ void V_DrawCroppedPatch(fixed_t x, fixed_t y, fixed_t pscale, fixed_t vscale, IN patchdrawfunc = standardpdraw; v_translevel = NULL; - if ((alphalevel = ((scrn & V_ALPHAMASK) >> V_ALPHASHIFT))) + if (alphalevel) { if (alphalevel == 10) alphalevel = hudminusalpha[st_translucency]; @@ -841,7 +847,11 @@ void V_DrawCroppedPatch(fixed_t x, fixed_t y, fixed_t pscale, fixed_t vscale, IN if (alphalevel) { - v_translevel = R_GetTranslucencyTable(alphalevel); + if (blendmode) + v_translevel = R_GetBlendTable(blendmode+1, alphalevel); + else + v_translevel = R_GetTranslucencyTable(alphalevel); + patchdrawfunc = translucentpdraw; } } From f455bf347beea6c9a96c2865fb8b7228d4ea810d Mon Sep 17 00:00:00 2001 From: sphere Date: Fri, 19 Nov 2021 19:01:41 +0100 Subject: [PATCH 1012/1080] blentran part 3: Wall & plane blendmodes. --- src/hardware/hw_main.c | 68 ++++++++++++++++++++++++++---------------- src/lua_maplib.c | 8 +++++ src/p_setup.c | 39 +++++++++++++++--------- src/p_spec.c | 11 ++++++- src/r_defs.h | 2 ++ src/r_draw.c | 3 ++ src/r_plane.c | 32 +++++++------------- src/r_segs.c | 43 ++++++++++++-------------- 8 files changed, 120 insertions(+), 86 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 63f1191ca..a1dd53eb7 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -556,7 +556,7 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool HWR_Lighting(&Surf, lightlevel, planecolormap); - if (PolyFlags & (PF_Translucent|PF_Fog)) + if (PolyFlags & (PF_Translucent|PF_Fog|PF_Additive|PF_Subtractive|PF_ReverseSubtract|PF_Multiplicative|PF_Environment)) { Surf.PolyColor.s.alpha = (UINT8)alpha; PolyFlags |= PF_Modulated; @@ -980,8 +980,8 @@ static void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, if (cutflag & FF_FOG) HWR_AddTransparentWall(wallVerts, Surf, texnum, PF_Fog|PF_NoTexture|polyflags, true, lightnum, colormap); - else if (cutflag & FF_TRANSLUCENT) - HWR_AddTransparentWall(wallVerts, Surf, texnum, PF_Translucent|polyflags, false, lightnum, colormap); + else if (polyflags & (PF_Translucent|PF_Additive|PF_Subtractive|PF_ReverseSubtract|PF_Multiplicative|PF_Environment)) + HWR_AddTransparentWall(wallVerts, Surf, texnum, polyflags, false, lightnum, colormap); else HWR_ProjectWall(wallVerts, Surf, PF_Masked|polyflags, lightnum, colormap); @@ -1009,8 +1009,8 @@ static void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, if (cutflag & FF_FOG) HWR_AddTransparentWall(wallVerts, Surf, texnum, PF_Fog|PF_NoTexture|polyflags, true, lightnum, colormap); - else if (cutflag & FF_TRANSLUCENT) - HWR_AddTransparentWall(wallVerts, Surf, texnum, PF_Translucent|polyflags, false, lightnum, colormap); + else if (polyflags & (PF_Translucent|PF_Additive|PF_Subtractive|PF_ReverseSubtract|PF_Multiplicative|PF_Environment)) + HWR_AddTransparentWall(wallVerts, Surf, texnum, polyflags, false, lightnum, colormap); else HWR_ProjectWall(wallVerts, Surf, PF_Masked|polyflags, lightnum, colormap); } @@ -1264,6 +1264,7 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom else HWR_ProjectWall(wallVerts, &Surf, PF_Masked, lightnum, colormap); } + gl_midtexture = R_GetTextureNum(gl_sidedef->midtexture); if (gl_midtexture) { @@ -1453,10 +1454,20 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom case 221: case 253: case 256: - blendmode = PF_Translucent; + if (gl_linedef->blendmode) + blendmode = HWR_SurfaceBlend(gl_linedef->blendmode, R_GetLinedefTransTable(gl_linedef->alpha), &Surf); + else + blendmode = PF_Translucent; break; default: - if (gl_linedef->alpha >= 0 && gl_linedef->alpha < FRACUNIT) + if (gl_linedef->blendmode) + { + if (gl_linedef->alpha >= 0 && gl_linedef->alpha < FRACUNIT) + blendmode = HWR_SurfaceBlend(gl_linedef->blendmode, R_GetLinedefTransTable(gl_linedef->alpha), &Surf); + else + blendmode = HWR_GetBlendModeFlag(gl_linedef->blendmode); + } + else if (gl_linedef->alpha >= 0 && gl_linedef->alpha < FRACUNIT) blendmode = HWR_TranstableToAlpha(R_GetLinedefTransTable(gl_linedef->alpha), &Surf); else blendmode = PF_Masked; @@ -1481,11 +1492,9 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom if (gl_frontsector->numlights) { if (!(blendmode & PF_Masked)) - HWR_SplitWall(gl_frontsector, wallVerts, gl_midtexture, &Surf, FF_TRANSLUCENT, NULL, PF_Decal); + HWR_SplitWall(gl_frontsector, wallVerts, gl_midtexture, &Surf, FF_TRANSLUCENT, NULL, blendmode); else - { - HWR_SplitWall(gl_frontsector, wallVerts, gl_midtexture, &Surf, FF_CUTLEVEL, NULL, PF_Decal); - } + HWR_SplitWall(gl_frontsector, wallVerts, gl_midtexture, &Surf, FF_CUTLEVEL, NULL, blendmode); } else if (!(blendmode & PF_Masked)) HWR_AddTransparentWall(wallVerts, &Surf, gl_midtexture, blendmode, false, lightnum, colormap); @@ -1745,7 +1754,7 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom Surf.PolyColor.s.alpha = HWR_FogBlockAlpha(rover->master->frontsector->lightlevel, rover->master->frontsector->extra_colormap); if (gl_frontsector->numlights) - HWR_SplitWall(gl_frontsector, wallVerts, 0, &Surf, rover->flags, rover, 0); + HWR_SplitWall(gl_frontsector, wallVerts, 0, &Surf, rover->flags, rover, blendmode); else HWR_AddTransparentWall(wallVerts, &Surf, 0, blendmode, true, lightnum, colormap); } @@ -1753,14 +1762,14 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom { FBITFIELD blendmode = PF_Masked; - if (rover->flags & FF_TRANSLUCENT && rover->alpha < 256) + if ((rover->flags & FF_TRANSLUCENT && rover->alpha < 256) || rover->blend) { - blendmode = PF_Translucent; + blendmode = rover->blend ? HWR_GetBlendModeFlag(rover->blend) : PF_Translucent; Surf.PolyColor.s.alpha = (UINT8)rover->alpha-1 > 255 ? 255 : rover->alpha-1; } if (gl_frontsector->numlights) - HWR_SplitWall(gl_frontsector, wallVerts, texnum, &Surf, rover->flags, rover, 0); + HWR_SplitWall(gl_frontsector, wallVerts, texnum, &Surf, rover->flags, rover, blendmode); else { if (blendmode != PF_Masked) @@ -1868,7 +1877,7 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom Surf.PolyColor.s.alpha = HWR_FogBlockAlpha(rover->master->frontsector->lightlevel, rover->master->frontsector->extra_colormap); if (gl_backsector->numlights) - HWR_SplitWall(gl_backsector, wallVerts, 0, &Surf, rover->flags, rover, 0); + HWR_SplitWall(gl_backsector, wallVerts, 0, &Surf, rover->flags, rover, blendmode); else HWR_AddTransparentWall(wallVerts, &Surf, 0, blendmode, true, lightnum, colormap); } @@ -1876,14 +1885,14 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom { FBITFIELD blendmode = PF_Masked; - if (rover->flags & FF_TRANSLUCENT && rover->alpha < 256) + if ((rover->flags & FF_TRANSLUCENT && rover->alpha < 256) || rover->blend) { - blendmode = PF_Translucent; + blendmode = rover->blend ? HWR_GetBlendModeFlag(rover->blend) : PF_Translucent; Surf.PolyColor.s.alpha = (UINT8)rover->alpha-1 > 255 ? 255 : rover->alpha-1; } if (gl_backsector->numlights) - HWR_SplitWall(gl_backsector, wallVerts, texnum, &Surf, rover->flags, rover, 0); + HWR_SplitWall(gl_backsector, wallVerts, texnum, &Surf, rover->flags, rover, blendmode); else { if (blendmode != PF_Masked) @@ -2960,6 +2969,13 @@ static void HWR_AddPolyObjectPlanes(void) } } +static FBITFIELD HWR_RippleBlend(sector_t *sector, ffloor_t *rover, boolean ceiling) +{ + (void)sector; + (void)ceiling; + return /*R_IsRipplePlane(sector, rover, ceiling)*/ (rover->flags & FF_RIPPLE) ? PF_Ripple : 0; +} + // -----------------+ // HWR_Subsector : Determine floor/ceiling planes. // : Add sprites of things in sector. @@ -3150,7 +3166,7 @@ static void HWR_Subsector(size_t num) alpha, rover->master->frontsector, PF_Fog|PF_NoTexture, true, rover->master->frontsector->extra_colormap); } - else if (rover->flags & FF_TRANSLUCENT && rover->alpha < 256) // SoM: Flags are more efficient + else if ((rover->flags & FF_TRANSLUCENT && rover->alpha < 256) || rover->blend) // SoM: Flags are more efficient { light = R_GetPlaneLight(gl_frontsector, centerHeight, dup_viewz < cullHeight ? true : false); @@ -3159,14 +3175,15 @@ static void HWR_Subsector(size_t num) false, *rover->bottomheight, *gl_frontsector->lightlist[light].lightlevel, - rover->alpha-1 > 255 ? 255 : rover->alpha-1, rover->master->frontsector, (rover->flags & FF_RIPPLE ? PF_Ripple : 0)|PF_Translucent, + rover->alpha-1 > 255 ? 255 : rover->alpha-1, rover->master->frontsector, + HWR_RippleBlend(gl_frontsector, rover, false) | (rover->blend ? HWR_GetBlendModeFlag(rover->blend) : PF_Translucent), false, *gl_frontsector->lightlist[light].extra_colormap); } else { HWR_GetLevelFlat(&levelflats[*rover->bottompic]); light = R_GetPlaneLight(gl_frontsector, centerHeight, dup_viewz < cullHeight ? true : false); - HWR_RenderPlane(sub, &extrasubsectors[num], false, *rover->bottomheight, (rover->flags & FF_RIPPLE ? PF_Ripple : 0)|PF_Occlude, *gl_frontsector->lightlist[light].lightlevel, &levelflats[*rover->bottompic], + HWR_RenderPlane(sub, &extrasubsectors[num], false, *rover->bottomheight, HWR_RippleBlend(gl_frontsector, rover, false)|PF_Occlude, *gl_frontsector->lightlist[light].lightlevel, &levelflats[*rover->bottompic], rover->master->frontsector, 255, *gl_frontsector->lightlist[light].extra_colormap); } } @@ -3195,7 +3212,7 @@ static void HWR_Subsector(size_t num) alpha, rover->master->frontsector, PF_Fog|PF_NoTexture, true, rover->master->frontsector->extra_colormap); } - else if (rover->flags & FF_TRANSLUCENT && rover->alpha < 256) + else if ((rover->flags & FF_TRANSLUCENT && rover->alpha < 256) || rover->blend) { light = R_GetPlaneLight(gl_frontsector, centerHeight, dup_viewz < cullHeight ? true : false); @@ -3204,14 +3221,15 @@ static void HWR_Subsector(size_t num) true, *rover->topheight, *gl_frontsector->lightlist[light].lightlevel, - rover->alpha-1 > 255 ? 255 : rover->alpha-1, rover->master->frontsector, (rover->flags & FF_RIPPLE ? PF_Ripple : 0)|PF_Translucent, + rover->alpha-1 > 255 ? 255 : rover->alpha-1, rover->master->frontsector, + HWR_RippleBlend(gl_frontsector, rover, false) | (rover->blend ? HWR_GetBlendModeFlag(rover->blend) : PF_Translucent), false, *gl_frontsector->lightlist[light].extra_colormap); } else { HWR_GetLevelFlat(&levelflats[*rover->toppic]); light = R_GetPlaneLight(gl_frontsector, centerHeight, dup_viewz < cullHeight ? true : false); - HWR_RenderPlane(sub, &extrasubsectors[num], true, *rover->topheight, (rover->flags & FF_RIPPLE ? PF_Ripple : 0)|PF_Occlude, *gl_frontsector->lightlist[light].lightlevel, &levelflats[*rover->toppic], + HWR_RenderPlane(sub, &extrasubsectors[num], true, *rover->topheight, HWR_RippleBlend(gl_frontsector, rover, false)|PF_Occlude, *gl_frontsector->lightlist[light].lightlevel, &levelflats[*rover->toppic], rover->master->frontsector, 255, *gl_frontsector->lightlist[light].extra_colormap); } } diff --git a/src/lua_maplib.c b/src/lua_maplib.c index 9031c99f1..04e6fde8d 100644 --- a/src/lua_maplib.c +++ b/src/lua_maplib.c @@ -196,6 +196,7 @@ enum ffloor_e { ffloor_next, ffloor_prev, ffloor_alpha, + ffloor_blend, }; static const char *const ffloor_opt[] = { @@ -214,6 +215,7 @@ static const char *const ffloor_opt[] = { "next", "prev", "alpha", + "blend", NULL}; #ifdef HAVE_LUA_SEGS @@ -1807,6 +1809,9 @@ static int ffloor_get(lua_State *L) case ffloor_alpha: lua_pushinteger(L, ffloor->alpha); return 1; + case ffloor_blend: + lua_pushinteger(L, ffloor->blend); + return 1; } return 0; } @@ -1885,6 +1890,9 @@ static int ffloor_set(lua_State *L) case ffloor_alpha: ffloor->alpha = (INT32)luaL_checkinteger(L, 3); break; + case ffloor_blend: + ffloor->blend = (INT32)luaL_checkinteger(L, 3); + break; } return 0; } diff --git a/src/p_setup.c b/src/p_setup.c index 7f9674e4e..591b446c8 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -1350,8 +1350,11 @@ static void P_LoadSidedefs(UINT8 *data) if (msd->toptexture[0] == '#') { char *col = msd->toptexture; - sd->toptexture = sd->bottomtexture = - ((col[1]-'0')*100 + (col[2]-'0')*10 + col[3]-'0') + 1; + sd->toptexture = + ((col[1]-'0')*100 + (col[2]-'0')*10 + col[3]-'0')+1; + if (col[4]) // extra num for blendmode + sd->toptexture += (col[4]-'0')*1000; + sd->bottomtexture = sd->toptexture; sd->midtexture = R_TextureNumForName(msd->midtexture); } else @@ -3321,22 +3324,30 @@ static void P_ConvertBinaryMap(void) lines[i].args[4] |= TMSC_BACKTOFRONTCEILING; lines[i].special = 720; break; - - case 900: //Translucent wall (10%) - case 901: //Translucent wall (20%) - case 902: //Translucent wall (30%) - case 903: //Translucent wall (40%) - case 904: //Translucent wall (50%) - case 905: //Translucent wall (60%) - case 906: //Translucent wall (70%) - case 907: //Translucent wall (80%) - case 908: //Translucent wall (90%) - lines[i].alpha = ((909 - lines[i].special) << FRACBITS)/10; - break; default: break; } + // Set alpha for translucent walls + if (lines[i].special >= 900 && lines[i].special < 909) + lines[i].alpha = ((909 - lines[i].special) << FRACBITS)/10; + + // Set alpha for additive/subtractive/reverse subtractive walls + if (lines[i].special >= 910 && lines[i].special <= 939) + lines[i].alpha = ((10 - lines[i].special % 10) << FRACBITS)/10; + + if (lines[i].special >= 910 && lines[i].special <= 919) // additive + lines[i].blendmode = AST_ADD; + + if (lines[i].special >= 920 && lines[i].special <= 929) // subtractive + lines[i].blendmode = AST_SUBTRACT; + + if (lines[i].special >= 930 && lines[i].special <= 939) // reverse subtractive + lines[i].blendmode = AST_REVERSESUBTRACT; + + if (lines[i].special == 940) // modulate + lines[i].blendmode = AST_MODULATE; + //Linedef executor delay if (lines[i].special >= 400 && lines[i].special < 500) { diff --git a/src/p_spec.c b/src/p_spec.c index 07410efa2..ebabe6a79 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -5601,7 +5601,16 @@ static ffloor_t *P_AddFakeFloor(sector_t *sec, sector_t *sec2, line_t *master, f if (flags & FF_TRANSLUCENT) { if (sides[master->sidenum[0]].toptexture > 0) - fflr->alpha = sides[master->sidenum[0]].toptexture; // for future reference, "#0" is 1, and "#255" is 256. Be warned + { + // for future reference, "#0" is 1, and "#255" is 256. Be warned + fflr->alpha = sides[master->sidenum[0]].toptexture; + + if (fflr->alpha >= 1001) // fourth digit + { + fflr->blend = (fflr->alpha/1000)+1; // becomes an AST + fflr->alpha %= 1000; + } + } else fflr->alpha = 0x80; } diff --git a/src/r_defs.h b/src/r_defs.h index f4ab58295..3c2178937 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -184,6 +184,7 @@ typedef struct ffloor_s INT32 lastlight; INT32 alpha; + UINT8 blend; // blendmode tic_t norender; // for culling // these are saved for netgames, so do not let Lua touch these! @@ -397,6 +398,7 @@ typedef struct line_s // Visual appearance: sidedefs. UINT16 sidenum[2]; // sidenum[1] will be 0xffff if one-sided fixed_t alpha; // translucency + UINT8 blendmode; // blendmode INT32 executordelay; fixed_t bbox[4]; // bounding box for the extent of the linedef diff --git a/src/r_draw.c b/src/r_draw.c index f0a19a462..65bb87bfb 100644 --- a/src/r_draw.c +++ b/src/r_draw.c @@ -248,6 +248,9 @@ static void BlendTab_Subtractive(UINT8 *table, int style, UINT8 blendamt) result.s.green = max(0, result.s.green - blendamt); result.s.blue = max(0, result.s.blue - blendamt); + //probably incorrect, but does look better at lower opacity... + //result.rgba = ASTBlendPixel(result, frontrgba, AST_TRANSLUCENT, blendamt); + table[((bg * 0x100) + fg)] = GetColorLUT(&transtab_lut, result.s.red, result.s.green, result.s.blue); } } diff --git a/src/r_plane.c b/src/r_plane.c index 45719ce58..d854c2342 100644 --- a/src/r_plane.c +++ b/src/r_plane.c @@ -855,28 +855,16 @@ void R_DrawSinglePlane(visplane_t *pl) spanfunctype = (pl->ffloor->master->flags & ML_EFFECT6) ? SPANDRAWFUNC_TRANSSPLAT : SPANDRAWFUNC_TRANS; // Hacked up support for alpha value in software mode Tails 09-24-2002 - if (pl->ffloor->alpha < 12) - return; // Don't even draw it - else if (pl->ffloor->alpha < 38) - ds_transmap = R_GetTranslucencyTable(tr_trans90); - else if (pl->ffloor->alpha < 64) - ds_transmap = R_GetTranslucencyTable(tr_trans80); - else if (pl->ffloor->alpha < 89) - ds_transmap = R_GetTranslucencyTable(tr_trans70); - else if (pl->ffloor->alpha < 115) - ds_transmap = R_GetTranslucencyTable(tr_trans60); - else if (pl->ffloor->alpha < 140) - ds_transmap = R_GetTranslucencyTable(tr_trans50); - else if (pl->ffloor->alpha < 166) - ds_transmap = R_GetTranslucencyTable(tr_trans40); - else if (pl->ffloor->alpha < 192) - ds_transmap = R_GetTranslucencyTable(tr_trans30); - else if (pl->ffloor->alpha < 217) - ds_transmap = R_GetTranslucencyTable(tr_trans20); - else if (pl->ffloor->alpha < 243) - ds_transmap = R_GetTranslucencyTable(tr_trans10); - else // Opaque, but allow transparent flat pixels - spanfunctype = SPANDRAWFUNC_SPLAT; + // ...unhacked by toaster 04-01-2021, re-hacked a little by sphere 19-11-2021 + { + INT32 trans = (10*((256+12) - pl->ffloor->alpha))/255; + if (trans >= 10) + return; // Don't even draw it + if (pl->ffloor->blend) // additive, (reverse) subtractive, modulative + ds_transmap = R_GetBlendTable(pl->ffloor->blend, trans); + else if (!(ds_transmap = R_GetTranslucencyTable(trans))) + spanfunctype = SPANDRAWFUNC_SPLAT; // Opaque, but allow transparent flat pixels + } if ((spanfunctype == SPANDRAWFUNC_SPLAT) || (pl->extra_colormap && (pl->extra_colormap->flags & CMF_FOG))) light = (pl->lightlevel >> LIGHTSEGSHIFT); diff --git a/src/r_segs.c b/src/r_segs.c index a8c85ec33..4460f9f90 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -155,11 +155,18 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2) if (!ldef->alpha) return; - if (ldef->alpha > 0 && ldef->alpha < FRACUNIT) + if (ldef->blendmode) + { + if (ldef->alpha == NUMTRANSMAPS || ldef->blendmode == AST_MODULATE) + dc_transmap = R_GetBlendTable(ldef->blendmode, 0); + else + dc_transmap = R_GetBlendTable(ldef->blendmode, R_GetLinedefTransTable(ldef->alpha)); + colfunc = colfuncs[COLDRAWFUNC_FUZZY]; + } + else if (ldef->alpha > 0 && ldef->alpha < FRACUNIT) { dc_transmap = R_GetTranslucencyTable(R_GetLinedefTransTable(ldef->alpha)); colfunc = colfuncs[COLDRAWFUNC_FUZZY]; - } else if (ldef->special == 909) { @@ -600,28 +607,16 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) boolean fuzzy = true; // Hacked up support for alpha value in software mode Tails 09-24-2002 - if (pfloor->alpha < 12) - return; // Don't even draw it - else if (pfloor->alpha < 38) - dc_transmap = R_GetTranslucencyTable(tr_trans90); - else if (pfloor->alpha < 64) - dc_transmap = R_GetTranslucencyTable(tr_trans80); - else if (pfloor->alpha < 89) - dc_transmap = R_GetTranslucencyTable(tr_trans70); - else if (pfloor->alpha < 115) - dc_transmap = R_GetTranslucencyTable(tr_trans60); - else if (pfloor->alpha < 140) - dc_transmap = R_GetTranslucencyTable(tr_trans50); - else if (pfloor->alpha < 166) - dc_transmap = R_GetTranslucencyTable(tr_trans40); - else if (pfloor->alpha < 192) - dc_transmap = R_GetTranslucencyTable(tr_trans30); - else if (pfloor->alpha < 217) - dc_transmap = R_GetTranslucencyTable(tr_trans20); - else if (pfloor->alpha < 243) - dc_transmap = R_GetTranslucencyTable(tr_trans10); - else - fuzzy = false; // Opaque + // ...unhacked by toaster 04-01-2021, re-hacked a little by sphere 19-11-2021 + { + INT32 trans = (10*((256+12) - pfloor->alpha))/255; + if (trans >= 10) + return; // Don't even draw it + if (pfloor->blend) // additive, (reverse) subtractive, modulative + dc_transmap = R_GetBlendTable(pfloor->blend, trans); + else if (!(dc_transmap = R_GetTranslucencyTable(trans))) + fuzzy = false; // Opaque + } if (fuzzy) colfunc = colfuncs[COLDRAWFUNC_FUZZY]; From 84dfea458033456deb5cb9ab35a54b50b730ee02 Mon Sep 17 00:00:00 2001 From: MascaraSnake Date: Sun, 12 Dec 2021 06:54:48 +0100 Subject: [PATCH 1013/1080] Add new blendmode linedef types to config --- extras/conf/SRB2-22.cfg | 186 +++++++++++++++++++ extras/conf/udb/Includes/SRB222_linedefs.cfg | 155 ++++++++++++++++ 2 files changed, 341 insertions(+) diff --git a/extras/conf/SRB2-22.cfg b/extras/conf/SRB2-22.cfg index 4ed68e1ca..2b4bdbcd7 100644 --- a/extras/conf/SRB2-22.cfg +++ b/extras/conf/SRB2-22.cfg @@ -3251,6 +3251,192 @@ linedeftypes title = "Fog Wall"; prefix = "(909)"; } + + 910 + { + title = "100% Additive"; + prefix = "(910)"; + } + + 911 + { + title = "90% Additive"; + prefix = "(911)"; + } + + 912 + { + title = "80% Additive"; + prefix = "(912)"; + } + + 913 + { + title = "70% Additive"; + prefix = "(913)"; + } + + 914 + { + title = "60% Additive"; + prefix = "(914)"; + } + + 915 + { + title = "50% Additive"; + prefix = "(915)"; + } + + 916 + { + title = "40% Additive"; + prefix = "(916)"; + } + + 917 + { + title = "30% Additive"; + prefix = "(917)"; + } + + 918 + { + title = "20% Additive"; + prefix = "(918)"; + } + + 919 + { + title = "10% Additive"; + prefix = "(919)"; + } + + 920 + { + title = "100% Subtractive"; + prefix = "(920)"; + } + + 921 + { + title = "90% Subtractive"; + prefix = "(921)"; + } + + 922 + { + title = "80% Subtractive"; + prefix = "(922)"; + } + + 923 + { + title = "70% Subtractive"; + prefix = "(923)"; + } + + 924 + { + title = "60% Subtractive"; + prefix = "(924)"; + } + + 925 + { + title = "50% Subtractive"; + prefix = "(925)"; + } + + 926 + { + title = "40% Subtractive"; + prefix = "(926)"; + } + + 927 + { + title = "30% Subtractive"; + prefix = "(927)"; + } + + 928 + { + title = "20% Subtractive"; + prefix = "(928)"; + } + + 929 + { + title = "10% Subtractive"; + prefix = "(929)"; + } + + 930 + { + title = "100% Reverse Subtractive"; + prefix = "(930)"; + } + + 931 + { + title = "90% Reverse Subtractive"; + prefix = "(931)"; + } + + 932 + { + title = "80% Reverse Subtractive"; + prefix = "(932)"; + } + + 933 + { + title = "70% Reverse Subtractive"; + prefix = "(933)"; + } + + 934 + { + title = "60% Reverse Subtractive"; + prefix = "(934)"; + } + + 935 + { + title = "50% Reverse Subtractive"; + prefix = "(935)"; + } + + 936 + { + title = "40% Reverse Subtractive"; + prefix = "(936)"; + } + + 937 + { + title = "30% Reverse Subtractive"; + prefix = "(937)"; + } + + 938 + { + title = "20% Reverse Subtractive"; + prefix = "(938)"; + } + + 939 + { + title = "10% Reverse Subtractive"; + prefix = "(939)"; + } + + 940 + { + title = "Modulate"; + prefix = "(940)"; + } } } diff --git a/extras/conf/udb/Includes/SRB222_linedefs.cfg b/extras/conf/udb/Includes/SRB222_linedefs.cfg index 1f87c2c3a..c6b0cb1c8 100644 --- a/extras/conf/udb/Includes/SRB222_linedefs.cfg +++ b/extras/conf/udb/Includes/SRB222_linedefs.cfg @@ -1500,6 +1500,161 @@ doom title = "Fog Wall"; prefix = "(909)"; } + 910 + { + title = "100% Additive"; + prefix = "(910)"; + } + 911 + { + title = "90% Additive"; + prefix = "(911)"; + } + 912 + { + title = "80% Additive"; + prefix = "(912)"; + } + 913 + { + title = "70% Additive"; + prefix = "(913)"; + } + 914 + { + title = "60% Additive"; + prefix = "(914)"; + } + 915 + { + title = "50% Additive"; + prefix = "(915)"; + } + 916 + { + title = "40% Additive"; + prefix = "(916)"; + } + 917 + { + title = "30% Additive"; + prefix = "(917)"; + } + 918 + { + title = "20% Additive"; + prefix = "(918)"; + } + 919 + { + title = "10% Additive"; + prefix = "(919)"; + } + 920 + { + title = "100% Subtractive"; + prefix = "(920)"; + } + 921 + { + title = "90% Subtractive"; + prefix = "(921)"; + } + 922 + { + title = "80% Subtractive"; + prefix = "(922)"; + } + 923 + { + title = "70% Subtractive"; + prefix = "(923)"; + } + 924 + { + title = "60% Subtractive"; + prefix = "(924)"; + } + 925 + { + title = "50% Subtractive"; + prefix = "(925)"; + } + 926 + { + title = "40% Subtractive"; + prefix = "(926)"; + } + 927 + { + title = "30% Subtractive"; + prefix = "(927)"; + } + 928 + { + title = "20% Subtractive"; + prefix = "(928)"; + } + 929 + { + title = "10% Subtractive"; + prefix = "(929)"; + } + 930 + { + title = "100% Reverse Subtractive"; + prefix = "(930)"; + } + 931 + { + title = "90% Reverse Subtractive"; + prefix = "(931)"; + } + 932 + { + title = "80% Reverse Subtractive"; + prefix = "(932)"; + } + 933 + { + title = "70% Reverse Subtractive"; + prefix = "(933)"; + } + 934 + { + title = "60% Reverse Subtractive"; + prefix = "(934)"; + } + 935 + { + title = "50% Reverse Subtractive"; + prefix = "(935)"; + } + 936 + { + title = "40% Reverse Subtractive"; + prefix = "(936)"; + } + 937 + { + title = "30% Reverse Subtractive"; + prefix = "(937)"; + } + 938 + { + title = "20% Reverse Subtractive"; + prefix = "(938)"; + } + 939 + { + title = "10% Reverse Subtractive"; + prefix = "(939)"; + } + 940 + { + title = "Modulate"; + prefix = "(940)"; + } } } From 3b08a1586057c2b037625f91537465c86b84de3a Mon Sep 17 00:00:00 2001 From: MascaraSnake Date: Sun, 12 Dec 2021 07:02:17 +0100 Subject: [PATCH 1014/1080] Expose blendmodes to UDMF --- extras/conf/udb/Includes/SRB222_common.cfg | 4 ++-- extras/conf/udb/Includes/SRB222_misc.cfg | 9 ++++++--- src/p_setup.c | 13 +++++++++++++ 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/extras/conf/udb/Includes/SRB222_common.cfg b/extras/conf/udb/Includes/SRB222_common.cfg index d67835aeb..b752e3654 100644 --- a/extras/conf/udb/Includes/SRB222_common.cfg +++ b/extras/conf/udb/Includes/SRB222_common.cfg @@ -264,10 +264,10 @@ mapformat_udmf } // LINEDEF RENDERSTYLES - /*linedefrenderstyles + linedefrenderstyles { include("SRB222_misc.cfg", "linedefrenderstyles"); - }*/ + } // THING FLAGS thingflags diff --git a/extras/conf/udb/Includes/SRB222_misc.cfg b/extras/conf/udb/Includes/SRB222_misc.cfg index 68629149e..1b4fb4b4b 100644 --- a/extras/conf/udb/Includes/SRB222_misc.cfg +++ b/extras/conf/udb/Includes/SRB222_misc.cfg @@ -63,11 +63,14 @@ linedefflags_udmf transfer = "Transfer Line"; } -/*linedefrenderstyles +linedefrenderstyles { translucent = "Translucent"; - fog = "Fog"; -}*/ + add = "Add"; + subtract = "Subtract"; + reversesubtract = "Reverse subtract"; + modulate = "Modulate"; +} sectorflags { diff --git a/src/p_setup.c b/src/p_setup.c index 591b446c8..9a2e14cab 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -1701,6 +1701,19 @@ static void ParseTextmapLinedefParameter(UINT32 i, char *param, char *val) lines[i].sidenum[1] = atol(val); else if (fastcmp(param, "alpha")) lines[i].alpha = FLOAT_TO_FIXED(atof(val)); + else if (fastcmp(param, "blendmode") || fastcmp(param, "renderstyle")) + { + if (fastcmp(val, "translucent")) + lines[i].blendmode = AST_COPY; + else if (fastcmp(val, "add")) + lines[i].blendmode = AST_ADD; + else if (fastcmp(val, "subtract")) + lines[i].blendmode = AST_SUBTRACT; + else if (fastcmp(val, "reversesubtract")) + lines[i].blendmode = AST_REVERSESUBTRACT; + else if (fastcmp(val, "modulate")) + lines[i].blendmode = AST_MODULATE; + } else if (fastcmp(param, "executordelay")) lines[i].executordelay = atol(val); From 8c17bb57e68305afae177096fc9d9bd34edd69cb Mon Sep 17 00:00:00 2001 From: MascaraSnake Date: Fri, 31 Dec 2021 15:00:27 +0100 Subject: [PATCH 1015/1080] Turn the fog wall linedef type into a blendmode --- extras/conf/udb/Includes/SRB222_misc.cfg | 1 + src/deh_tables.c | 1 + src/hardware/hw_main.c | 4 ++-- src/p_setup.c | 5 +++++ src/r_defs.h | 2 +- src/r_segs.c | 14 +++++++------- 6 files changed, 17 insertions(+), 10 deletions(-) diff --git a/extras/conf/udb/Includes/SRB222_misc.cfg b/extras/conf/udb/Includes/SRB222_misc.cfg index 1b4fb4b4b..50c83e456 100644 --- a/extras/conf/udb/Includes/SRB222_misc.cfg +++ b/extras/conf/udb/Includes/SRB222_misc.cfg @@ -70,6 +70,7 @@ linedefrenderstyles subtract = "Subtract"; reversesubtract = "Reverse subtract"; modulate = "Modulate"; + fog = "Fog"; } sectorflags diff --git a/src/deh_tables.c b/src/deh_tables.c index 730ae959b..cfc98f631 100644 --- a/src/deh_tables.c +++ b/src/deh_tables.c @@ -4898,6 +4898,7 @@ struct int_const_s const INT_CONST[] = { {"AST_REVERSESUBTRACT",AST_REVERSESUBTRACT}, {"AST_MODULATE",AST_MODULATE}, {"AST_OVERLAY",AST_OVERLAY}, + {"AST_FOG",AST_FOG}, // Render flags {"RF_HORIZONTALFLIP",RF_HORIZONTALFLIP}, diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index a1dd53eb7..13b2a39c3 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -1454,13 +1454,13 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom case 221: case 253: case 256: - if (gl_linedef->blendmode) + if (gl_linedef->blendmode != AST_FOG) blendmode = HWR_SurfaceBlend(gl_linedef->blendmode, R_GetLinedefTransTable(gl_linedef->alpha), &Surf); else blendmode = PF_Translucent; break; default: - if (gl_linedef->blendmode) + if (gl_linedef->blendmode != AST_FOG) { if (gl_linedef->alpha >= 0 && gl_linedef->alpha < FRACUNIT) blendmode = HWR_SurfaceBlend(gl_linedef->blendmode, R_GetLinedefTransTable(gl_linedef->alpha), &Surf); diff --git a/src/p_setup.c b/src/p_setup.c index 9a2e14cab..4f21922a0 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -1713,6 +1713,8 @@ static void ParseTextmapLinedefParameter(UINT32 i, char *param, char *val) lines[i].blendmode = AST_REVERSESUBTRACT; else if (fastcmp(val, "modulate")) lines[i].blendmode = AST_MODULATE; + if (fastcmp(val, "fog")) + lines[i].blendmode = AST_FOG; } else if (fastcmp(param, "executordelay")) lines[i].executordelay = atol(val); @@ -3337,6 +3339,9 @@ static void P_ConvertBinaryMap(void) lines[i].args[4] |= TMSC_BACKTOFRONTCEILING; lines[i].special = 720; break; + case 909: //Fog wall + lines[i].blendmode = AST_FOG; + break; default: break; } diff --git a/src/r_defs.h b/src/r_defs.h index 3c2178937..fa63de400 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -716,7 +716,7 @@ typedef struct #endif // Possible alpha types for a patch. -enum patchalphastyle {AST_COPY, AST_TRANSLUCENT, AST_ADD, AST_SUBTRACT, AST_REVERSESUBTRACT, AST_MODULATE, AST_OVERLAY}; +enum patchalphastyle {AST_COPY, AST_TRANSLUCENT, AST_ADD, AST_SUBTRACT, AST_REVERSESUBTRACT, AST_MODULATE, AST_OVERLAY, AST_FOG}; typedef enum { diff --git a/src/r_segs.c b/src/r_segs.c index 4460f9f90..2459436b5 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -155,7 +155,13 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2) if (!ldef->alpha) return; - if (ldef->blendmode) + if (ldef->blendmode == AST_FOG) + { + colfunc = colfuncs[COLDRAWFUNC_FOG]; + windowtop = frontsector->ceilingheight; + windowbottom = frontsector->floorheight; + } + else if (ldef->blendmode) { if (ldef->alpha == NUMTRANSMAPS || ldef->blendmode == AST_MODULATE) dc_transmap = R_GetBlendTable(ldef->blendmode, 0); @@ -168,12 +174,6 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2) dc_transmap = R_GetTranslucencyTable(R_GetLinedefTransTable(ldef->alpha)); colfunc = colfuncs[COLDRAWFUNC_FUZZY]; } - else if (ldef->special == 909) - { - colfunc = colfuncs[COLDRAWFUNC_FOG]; - windowtop = frontsector->ceilingheight; - windowbottom = frontsector->floorheight; - } else colfunc = colfuncs[BASEDRAWFUNC]; From c7281d1801d45036e60bebbaa703af419b3bb20a Mon Sep 17 00:00:00 2001 From: spherallic Date: Sun, 2 Jan 2022 20:44:24 +0100 Subject: [PATCH 1016/1080] Fix cyan pixel cutting in Software --- src/r_plane.c | 2 +- src/r_segs.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/r_plane.c b/src/r_plane.c index d854c2342..1f5c0192e 100644 --- a/src/r_plane.c +++ b/src/r_plane.c @@ -862,7 +862,7 @@ void R_DrawSinglePlane(visplane_t *pl) return; // Don't even draw it if (pl->ffloor->blend) // additive, (reverse) subtractive, modulative ds_transmap = R_GetBlendTable(pl->ffloor->blend, trans); - else if (!(ds_transmap = R_GetTranslucencyTable(trans))) + else if (!(ds_transmap = R_GetTranslucencyTable(trans)) || trans == 0) spanfunctype = SPANDRAWFUNC_SPLAT; // Opaque, but allow transparent flat pixels } diff --git a/src/r_segs.c b/src/r_segs.c index 2459436b5..157cf466e 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -614,7 +614,7 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) return; // Don't even draw it if (pfloor->blend) // additive, (reverse) subtractive, modulative dc_transmap = R_GetBlendTable(pfloor->blend, trans); - else if (!(dc_transmap = R_GetTranslucencyTable(trans))) + else if (!(dc_transmap = R_GetTranslucencyTable(trans)) || trans == 0) fuzzy = false; // Opaque } From a8fe12ae9836e6e4dff788bd9d8d2a0da77c6937 Mon Sep 17 00:00:00 2001 From: Hannu Hanhi Date: Tue, 4 Jan 2022 22:30:50 +0200 Subject: [PATCH 1017/1080] Hack that fixes software drop shadow crashes by bypassing incorrectly set variables --- src/r_draw.h | 1 + src/r_draw8.c | 33 +++++++++++++++++++++++++++++++++ src/r_things.c | 6 ++++++ 3 files changed, 40 insertions(+) diff --git a/src/r_draw.h b/src/r_draw.h index 2173c7a5a..2576e1577 100644 --- a/src/r_draw.h +++ b/src/r_draw.h @@ -170,6 +170,7 @@ void R_DrawViewBorder(void); void R_DrawColumn_8(void); void R_DrawShadeColumn_8(void); void R_DrawTranslucentColumn_8(void); +void R_DrawDropShadowColumn_8(void); void R_DrawTranslatedColumn_8(void); void R_DrawTranslatedTranslucentColumn_8(void); void R_Draw2sMultiPatchColumn_8(void); diff --git a/src/r_draw8.c b/src/r_draw8.c index b8a63d5c0..182182574 100644 --- a/src/r_draw8.c +++ b/src/r_draw8.c @@ -416,6 +416,39 @@ void R_DrawTranslucentColumn_8(void) } } +// Hack: A cut-down copy of R_DrawTranslucentColumn_8 that does not read texture +// data since something about calculating the texture reading address for drop shadows is broken. +// dc_texturemid and dc_iscale get wrong values for drop shadows, however those are not strictly +// needed for the current design of the shadows, so this function bypasses the issue +// by not using those variables at all. +void R_DrawDropShadowColumn_8(void) +{ + register INT32 count; + register UINT8 *dest; + + count = dc_yh - dc_yl + 1; + + if (count <= 0) // Zero length, column does not exceed a pixel. + return; + + dest = &topleft[dc_yl*vid.width + dc_x]; + + { +#define DSCOLOR 31 // palette index for the color of the shadow + register const UINT8 *transmap_offset = dc_transmap + (dc_colormap[DSCOLOR] << 8); +#undef DSCOLOR + while ((count -= 2) >= 0) + { + *dest = *(transmap_offset + (*dest)); + dest += vid.width; + *dest = *(transmap_offset + (*dest)); + dest += vid.width; + } + if (count & 1) + *dest = *(transmap_offset + (*dest)); + } +} + /** \brief The R_DrawTranslatedTranslucentColumn_8 function Spiffy function. Not only does it colormap a sprite, but does translucency as well. Uber-kudos to Cyan Helkaraxe diff --git a/src/r_things.c b/src/r_things.c index bed71a6d7..85c085043 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -837,6 +837,12 @@ static void R_DrawVisSprite(vissprite_t *vis) else if (vis->mobj->sprite == SPR_PLAY) // Looks like a player, but doesn't have a color? Get rid of green sonic syndrome. colfunc = colfuncs[COLDRAWFUNC_TRANS]; + // Hack: Use a special column function for drop shadows that bypasses + // invalid memory access crashes caused by R_ProjectDropShadow putting wrong values + // in dc_texturemid and dc_iscale when the shadow is sloped. + if (vis->cut & SC_SHADOW) + colfunc = R_DrawDropShadowColumn_8; + if (vis->extra_colormap && !(vis->renderflags & RF_NOCOLORMAPS)) { if (!dc_colormap) From a08c7eac1fedd1f4cc5439e37775b547866fd60d Mon Sep 17 00:00:00 2001 From: spherallic Date: Wed, 5 Jan 2022 09:55:46 +0100 Subject: [PATCH 1018/1080] wip: staterange actions --- src/deh_tables.c | 2 ++ src/doomdef.h | 4 ++-- src/info.h | 4 ++++ src/p_enemy.c | 47 ++++++++++++++++++++++++++++++++++++++++++++++- 4 files changed, 54 insertions(+), 3 deletions(-) diff --git a/src/deh_tables.c b/src/deh_tables.c index cfc98f631..73da7313a 100644 --- a/src/deh_tables.c +++ b/src/deh_tables.c @@ -224,6 +224,8 @@ actionpointer_t actionpointers[] = {{A_SetObjectFlags2}, "A_SETOBJECTFLAGS2"}, {{A_RandomState}, "A_RANDOMSTATE"}, {{A_RandomStateRange}, "A_RANDOMSTATERANGE"}, + {{A_StateRangeByAngle}, "A_STATERANGEBYANGLE"}, + {{A_StateRangeByParameter}, "A_STATERANGEBYPARAMETER"}, {{A_DualAction}, "A_DUALACTION"}, {{A_RemoteAction}, "A_REMOTEACTION"}, {{A_ToggleFlameJet}, "A_TOGGLEFLAMEJET"}, diff --git a/src/doomdef.h b/src/doomdef.h index 7e7e35599..a5ee79cd3 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -124,7 +124,7 @@ extern char logfilename[1024]; /* A mod name to further distinguish versions. */ #define SRB2APPLICATION "SRB2" -//#define DEVELOP // Disable this for release builds to remove excessive cheat commands and enable MD5 checking and stuff, all in one go. :3 +#define DEVELOP // Disable this for release builds to remove excessive cheat commands and enable MD5 checking and stuff, all in one go. :3 #ifdef DEVELOP #define VERSIONSTRING "Development EXE" #define VERSIONSTRING_RC "Development EXE" "\0" @@ -150,7 +150,7 @@ extern char logfilename[1024]; // Does this version require an added patch file? // Comment or uncomment this as necessary. -#define USE_PATCH_DTA +//#define USE_PATCH_DTA // Enforce a limit of loaded WAD files. //#define ENFORCE_WAD_LIMIT diff --git a/src/info.h b/src/info.h index 031a08b43..a0e141606 100644 --- a/src/info.h +++ b/src/info.h @@ -177,6 +177,8 @@ enum actionnum A_SETOBJECTFLAGS2, A_RANDOMSTATE, A_RANDOMSTATERANGE, + A_STATERANGEBYANGLE, + A_STATERANGEBYPARAMETER, A_DUALACTION, A_REMOTEACTION, A_TOGGLEFLAMEJET, @@ -443,6 +445,8 @@ void A_SetObjectFlags(); void A_SetObjectFlags2(); void A_RandomState(); void A_RandomStateRange(); +void A_StateRangeByAngle(); +void A_StateRangeByParameter(); void A_DualAction(); void A_RemoteAction(); void A_ToggleFlameJet(); diff --git a/src/p_enemy.c b/src/p_enemy.c index 9d51aced5..c7b3673d6 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -200,6 +200,8 @@ void A_SetObjectFlags(mobj_t *actor); void A_SetObjectFlags2(mobj_t *actor); void A_RandomState(mobj_t *actor); void A_RandomStateRange(mobj_t *actor); +void A_StateRangeByAngle(mobj_t *actor); +void A_StateRangeByParameter(mobj_t *actor); void A_DualAction(mobj_t *actor); void A_RemoteAction(mobj_t *actor); void A_ToggleFlameJet(mobj_t *actor); @@ -8292,7 +8294,7 @@ void A_Boss3ShockThink(mobj_t *actor) snew->angle = (actor->angle + snext->angle) >> 1; P_SetTarget(&snew->target, actor->target); snew->fuse = actor->fuse; - + P_SetScale(snew, actor->scale); snew->destscale = actor->destscale; snew->scalespeed = actor->scalespeed; @@ -9290,6 +9292,49 @@ void A_RandomStateRange(mobj_t *actor) P_SetMobjState(actor, P_RandomRange(locvar1, locvar2)); } +// Function: A_StateRangeByAngle +// +// Description: Chooses a state within the range supplied, depending on the actor's angle. +// +// var1 = Minimum state number to use. +// var2 = Maximum state number to use. The difference will act as a modulo operator. +// +void A_StateRangeByAngle(mobj_t *actor) +{ + INT32 locvar1 = var1; + INT32 locvar2 = var2; + + if (LUA_CallAction(A_STATERANGEBYANGLE, actor)) + return; + + if (locvar2 - locvar1 < 0) + return; // invalid range + + P_SetMobjState(actor, locvar1 + (AngleFixed(actor->angle)>>FRACBITS % (1 + locvar2 - locvar1))); +} + +// Function: A_StateRangeByParameter +// +// Description: Chooses a state within the range supplied, depending on the actor's parameter/extrainfo value. +// +// var1 = Minimum state number to use. +// var2 = Maximum state number to use. The difference will act as a modulo operator. +// +void A_StateRangeByParameter(mobj_t *actor) +{ + INT32 locvar1 = var1; + INT32 locvar2 = var2; + UINT8 parameter = (actor->spawnpoint ? actor->spawnpoint->extrainfo : 0); + + if (LUA_CallAction(A_STATERANGEBYANGLE, actor)) + return; + + if (locvar2 - locvar1 < 0) + return; // invalid range + + P_SetMobjState(actor, locvar1 + (parameter % (1 + locvar2 - locvar1))); +} + // Function: A_DualAction // // Description: Calls two actions. Be careful, if you reference the same state this action is called from, you can create an infinite loop. From 549569e75b4c072a54d9ab39926521c6cc198895 Mon Sep 17 00:00:00 2001 From: MascaraSnake Date: Wed, 5 Jan 2022 10:08:49 +0100 Subject: [PATCH 1019/1080] Fix offset calculation for segs that represent linedef backsides --- src/p_setup.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/p_setup.c b/src/p_setup.c index 7f9674e4e..de91f4674 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2494,7 +2494,10 @@ static boolean P_LoadExtendedSubsectorsAndSegs(UINT8 **data, nodetype_t nodetype P_InitializeSeg(seg); seg->angle = R_PointToAngle2(v1->x, v1->y, v2->x, v2->y); if (seg->linedef) - segs[i].offset = FixedHypot(v1->x - seg->linedef->v1->x, v1->y - seg->linedef->v1->y); + { + vertex_t *v = (seg->side == 1) ? seg->linedef->v2 : seg->linedef->v1; + segs[i].offset = FixedHypot(v1->x - v->x, v1->y - v->y); + } seg->length = P_SegLength(seg); #ifdef HWRENDER seg->flength = (rendermode == render_opengl) ? P_SegLengthFloat(seg) : 0; From 5149699def1c54cb4666fb10cce5598687f349da Mon Sep 17 00:00:00 2001 From: MascaraSnake Date: Fri, 7 Jan 2022 18:00:56 +0100 Subject: [PATCH 1020/1080] Update VS project files --- src/sdl/Srb2SDL-vc10.vcxproj | 5 ++++ src/sdl/Srb2SDL-vc10.vcxproj.filters | 35 ++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/src/sdl/Srb2SDL-vc10.vcxproj b/src/sdl/Srb2SDL-vc10.vcxproj index 105e1def8..d79dde766 100644 --- a/src/sdl/Srb2SDL-vc10.vcxproj +++ b/src/sdl/Srb2SDL-vc10.vcxproj @@ -245,6 +245,7 @@ + @@ -304,6 +305,7 @@ + @@ -415,6 +417,7 @@ + @@ -475,10 +478,12 @@ + + true diff --git a/src/sdl/Srb2SDL-vc10.vcxproj.filters b/src/sdl/Srb2SDL-vc10.vcxproj.filters index 404890397..4d2532ca4 100644 --- a/src/sdl/Srb2SDL-vc10.vcxproj.filters +++ b/src/sdl/Srb2SDL-vc10.vcxproj.filters @@ -135,6 +135,16 @@ D_Doom + + D_Doom + + + D_Doom + + + D_Doom + + D_Doom @@ -288,6 +298,9 @@ I_Interface + + I_Interface + I_Interface @@ -402,6 +415,9 @@ P_Play + + P_Play + R_Rend @@ -600,6 +616,16 @@ D_Doom + + D_Doom + + + D_Doom + + + D_Doom + + D_Doom @@ -747,6 +773,9 @@ LUA + + LUA + LUA @@ -792,6 +821,9 @@ M_Misc + + M_Misc + O_Other @@ -852,6 +884,9 @@ P_Play + + P_Play + P_Play From 3248556fa9987c9cbb30893a0657a20581cdcb42 Mon Sep 17 00:00:00 2001 From: MascaraSnake Date: Fri, 7 Jan 2022 18:42:56 +0100 Subject: [PATCH 1021/1080] Speed up taglist creation --- src/taglist.c | 38 +++++++++++++++++++++++++++++++++++--- src/taglist.h | 1 + 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/src/taglist.c b/src/taglist.c index ad1b9dc4b..d08750f9b 100644 --- a/src/taglist.c +++ b/src/taglist.c @@ -191,6 +191,38 @@ void Taggroup_Add (taggroup_t *garray[], const mtag_t tag, size_t id) group->elements[i] = id; } +static void Taggroup_Add_Init(taggroup_t *garray[], const mtag_t tag, size_t id) +{ + taggroup_t *group; + + if (tag == MTAG_GLOBAL) + return; + + group = garray[(UINT16)tag]; + + if (! in_bit_array(tags_available, tag)) + { + num_tags++; + set_bit_array(tags_available, tag); + } + + // Create group if empty. + if (!group) + group = garray[(UINT16)tag] = Z_Calloc(sizeof(taggroup_t), PU_LEVEL, NULL); + else if (group->elements[group->count - 1] == id) + return; // Don't add duplicates + + group->count++; + + if (group->count > group->capacity) + { + group->capacity = 2 * group->count; + group->elements = Z_Realloc(group->elements, group->capacity * sizeof(size_t), PU_LEVEL, NULL); + } + + group->elements[group->count - 1] = id; +} + static size_t total_elements_with_tag (const mtag_t tag) { return @@ -250,17 +282,17 @@ void Taggroup_Remove (taggroup_t *garray[], const mtag_t tag, size_t id) static void Taglist_AddToSectors (const mtag_t tag, const size_t itemid) { - Taggroup_Add(tags_sectors, tag, itemid); + Taggroup_Add_Init(tags_sectors, tag, itemid); } static void Taglist_AddToLines (const mtag_t tag, const size_t itemid) { - Taggroup_Add(tags_lines, tag, itemid); + Taggroup_Add_Init(tags_lines, tag, itemid); } static void Taglist_AddToMapthings (const mtag_t tag, const size_t itemid) { - Taggroup_Add(tags_mapthings, tag, itemid); + Taggroup_Add_Init(tags_mapthings, tag, itemid); } /// After all taglists have been built for each element (sectors, lines, things), diff --git a/src/taglist.h b/src/taglist.h index d045eb827..ae1a81c89 100644 --- a/src/taglist.h +++ b/src/taglist.h @@ -41,6 +41,7 @@ typedef struct { size_t *elements; size_t count; + size_t capacity; } taggroup_t; extern bitarray_t tags_available[]; From 8651123463c0f74edbf9fa46e782ae8a5ef7d92f Mon Sep 17 00:00:00 2001 From: spherallic Date: Sat, 8 Jan 2022 19:47:00 +0100 Subject: [PATCH 1022/1080] Fix errors with the hardcoded Nightopians from Dream Hill. --- src/info.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/info.c b/src/info.c index 331e114b6..57899f4f1 100644 --- a/src/info.c +++ b/src/info.c @@ -3743,7 +3743,7 @@ state_t states[NUMSTATES] = {SPR_NTPN, 3, 4, {NULL}, 0, 0, S_PIAN5}, // S_PIAN4 {SPR_NTPN, 2, 4, {NULL}, 0, 0, S_PIAN6}, // S_PIAN5 {SPR_NTPN, 1, 4, {NULL}, 0, 0, S_PIAN1}, // S_PIAN6 - {SPR_NTPN, 5|FF_ANIMATE, 4, {NULL}, 1, 4, S_PIAN1}, // S_PIANSING + {SPR_NTPN, 4|FF_ANIMATE, 24, {NULL}, 1, 4, S_PIAN1}, // S_PIANSING // Shleep {SPR_SHLP, 0, 15, {NULL}, 0, 0, S_SHLEEP2}, // S_SHLEEP1 @@ -20128,8 +20128,8 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = S_NULL, // painstate 200, // painchance sfx_None, // painsound - S_PIANSING, // meleestate - S_NULL, // missilestate + S_NULL, // meleestate + S_PIANSING, // missilestate S_NULL, // deathstate S_NULL, // xdeathstate sfx_None, // deathsound @@ -20140,7 +20140,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = 16, // mass 0, // damage sfx_None, // activesound - MF_SLIDEME|MF_ENEMY|MF_SPECIAL|MF_SHOOTABLE|MF_NOGRAVITY, // flags + MF_SLIDEME|MF_SPECIAL|MF_NOGRAVITY, // flags S_NULL // raisestate }, From 95e909400f90a53a9ee7d83e38e8259cbf2da2b4 Mon Sep 17 00:00:00 2001 From: MascaraSnake Date: Sun, 9 Jan 2022 13:45:56 +0100 Subject: [PATCH 1023/1080] Fix blendmode regression in OpenGL caused by faulty fog wall support --- src/hardware/hw_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 13b2a39c3..d2982afe4 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -1454,13 +1454,13 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom case 221: case 253: case 256: - if (gl_linedef->blendmode != AST_FOG) + if (gl_linedef->blendmode && gl_linedef->blendmode != AST_FOG) blendmode = HWR_SurfaceBlend(gl_linedef->blendmode, R_GetLinedefTransTable(gl_linedef->alpha), &Surf); else blendmode = PF_Translucent; break; default: - if (gl_linedef->blendmode != AST_FOG) + if (gl_linedef->blendmode && gl_linedef->blendmode != AST_FOG) { if (gl_linedef->alpha >= 0 && gl_linedef->alpha < FRACUNIT) blendmode = HWR_SurfaceBlend(gl_linedef->blendmode, R_GetLinedefTransTable(gl_linedef->alpha), &Surf); From e0afc2d2b67d49ddd7d031c60bc610b8325df158 Mon Sep 17 00:00:00 2001 From: GoldenTails Date: Sun, 9 Jan 2022 17:09:57 -0600 Subject: [PATCH 1024/1080] Add a player->mo check before attempting to account for ztargetting. --- 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 3955834b2..c2eda8fa0 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1411,7 +1411,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) newtarget = P_SpawnMobj(ticcmd_ztargetfocus[forplayer]->x, ticcmd_ztargetfocus[forplayer]->y, ticcmd_ztargetfocus[forplayer]->z, MT_LOCKON); // positioning, flip handled in P_SceneryThinker P_SetTarget(&newtarget->target, ticcmd_ztargetfocus[forplayer]); - if (P_AproxDistance( + if (player->mo && P_AproxDistance( player->mo->x - ticcmd_ztargetfocus[forplayer]->x, player->mo->y - ticcmd_ztargetfocus[forplayer]->y ) > 50*player->mo->scale) From a66854608855b2ee9336169cf7393b8a21c1b86e Mon Sep 17 00:00:00 2001 From: LJ Sonic Date: Mon, 10 Jan 2022 18:56:42 +0100 Subject: [PATCH 1025/1080] Make byte stream manipulation code easier to read --- src/byteptr.h | 71 ++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 51 insertions(+), 20 deletions(-) diff --git a/src/byteptr.h b/src/byteptr.h index 4de415505..f66d9fcaf 100644 --- a/src/byteptr.h +++ b/src/byteptr.h @@ -150,27 +150,58 @@ FUNCINLINE static ATTRINLINE UINT32 readulong(void *ptr) #undef DEALIGNED -#define WRITESTRINGN(p,s,n) do { size_t tmp_i = 0; for (; tmp_i < n && s[tmp_i] != '\0'; tmp_i++) WRITECHAR(p, s[tmp_i]); if (tmp_i < n) WRITECHAR(p, '\0');} while (0) -#define WRITESTRING(p,s) do { size_t tmp_i = 0; for (; s[tmp_i] != '\0'; tmp_i++) WRITECHAR(p, s[tmp_i]); WRITECHAR(p, '\0');} while (0) -#define WRITEMEM(p,s,n) do { memcpy(p, s, n); p += n; } while (0) +#define WRITESTRINGN(p, s, n) ({ \ + size_t tmp_i; \ + \ + for (tmp_i = 0; tmp_i < n && s[tmp_i] != '\0'; tmp_i++) \ + WRITECHAR(p, s[tmp_i]); \ + \ + if (tmp_i < n) \ + WRITECHAR(p, '\0'); \ +}) -#define SKIPSTRING(p) while (READCHAR(p) != '\0') -#define SKIPSTRINGN(p,n) ({ size_t tmp_i = 0; for (; tmp_i < n && READCHAR(p) != '\0'; tmp_i++); }) +#define WRITESTRING(p, s) ({ \ + size_t tmp_i; \ + \ + for (tmp_i = 0; s[tmp_i] != '\0'; tmp_i++) \ + WRITECHAR(p, s[tmp_i]); \ + \ + WRITECHAR(p, '\0'); \ +}) -#define READSTRINGN(p,s,n) ({ size_t tmp_i = 0; for (; tmp_i < n && (s[tmp_i] = READCHAR(p)) != '\0'; tmp_i++); s[tmp_i] = '\0';}) -#define READSTRING(p,s) ({ size_t tmp_i = 0; for (; (s[tmp_i] = READCHAR(p)) != '\0'; tmp_i++); s[tmp_i] = '\0';}) -#define READMEM(p,s,n) ({ memcpy(s, p, n); p += n; }) +#define WRITEMEM(p, s, n) ({ \ + memcpy(p, s, n); \ + p += n; \ +}) -#if 0 // old names -#define WRITEBYTE(p,b) WRITEUINT8(p,b) -#define WRITESHORT(p,b) WRITEINT16(p,b) -#define WRITEUSHORT(p,b) WRITEUINT16(p,b) -#define WRITELONG(p,b) WRITEINT32(p,b) -#define WRITEULONG(p,b) WRITEUINT32(p,b) +#define SKIPSTRING(p) while (READCHAR(p) != '\0') -#define READBYTE(p) READUINT8(p) -#define READSHORT(p) READINT16(p) -#define READUSHORT(p) READUINT16(p) -#define READLONG(p) READINT32(p) -#define READULONG(p) READUINT32(p) -#endif +#define SKIPSTRINGN(p, n) ({ \ + size_t tmp_i = 0; \ + \ + while (tmp_i < n && READCHAR(p) != '\0') \ + tmp_i++; \ +}) + +#define READSTRINGN(p, s, n) ({ \ + size_t tmp_i = 0; \ + \ + while (tmp_i < n && (s[tmp_i] = READCHAR(p)) != '\0') \ + tmp_i++; \ + \ + s[tmp_i] = '\0'; \ +}) + +#define READSTRING(p, s) ({ \ + size_t tmp_i = 0; \ + \ + while ((s[tmp_i] = READCHAR(p)) != '\0') \ + tmp_i++; \ + \ + s[tmp_i] = '\0'; \ +}) + +#define READMEM(p, s, n) ({ \ + memcpy(s, p, n); \ + p += n; \ +}) From 3083290af868a18bdf3f2bd7a251f8567d266ef0 Mon Sep 17 00:00:00 2001 From: LJ Sonic Date: Mon, 10 Jan 2022 18:57:18 +0100 Subject: [PATCH 1026/1080] Add READSTRINGL and WRITESTRINGL macros --- src/byteptr.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/byteptr.h b/src/byteptr.h index f66d9fcaf..3a1366577 100644 --- a/src/byteptr.h +++ b/src/byteptr.h @@ -160,6 +160,15 @@ FUNCINLINE static ATTRINLINE UINT32 readulong(void *ptr) WRITECHAR(p, '\0'); \ }) +#define WRITESTRINGL(p, s, n) ({ \ + size_t tmp_i; \ + \ + for (tmp_i = 0; tmp_i < n - 1 && s[tmp_i] != '\0'; tmp_i++) \ + WRITECHAR(p, s[tmp_i]); \ + \ + WRITECHAR(p, '\0'); \ +}) + #define WRITESTRING(p, s) ({ \ size_t tmp_i; \ \ @@ -192,6 +201,15 @@ FUNCINLINE static ATTRINLINE UINT32 readulong(void *ptr) s[tmp_i] = '\0'; \ }) +#define READSTRINGL(p, s, n) ({ \ + size_t tmp_i = 0; \ + \ + while (tmp_i < n - 1 && (s[tmp_i] = READCHAR(p)) != '\0') \ + tmp_i++; \ + \ + s[tmp_i] = '\0'; \ +}) + #define READSTRING(p, s) ({ \ size_t tmp_i = 0; \ \ From 7ea81eacc5986e0fec4b68e945db3443897e8561 Mon Sep 17 00:00:00 2001 From: LJ Sonic Date: Mon, 10 Jan 2022 19:31:41 +0100 Subject: [PATCH 1027/1080] Fix say command and its variants using hardcoded buffer size --- src/hu_stuff.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 5f838b894..4c07e07d9 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -461,7 +461,7 @@ void HU_AddChatText(const char *text, boolean playsound) static void DoSayCommand(SINT8 target, size_t usedargs, UINT8 flags) { - char buf[254]; + char buf[2 + HU_MAXMSGLEN + 1]; size_t numwords, ix; char *msg = &buf[2]; const size_t msgspace = sizeof buf - 2; @@ -537,7 +537,7 @@ static void DoSayCommand(SINT8 target, size_t usedargs, UINT8 flags) } buf[0] = target; newmsg = msg+5+spc; - strlcpy(msg, newmsg, 252); + strlcpy(msg, newmsg, HU_MAXMSGLEN + 1); } SendNetXCmd(XD_SAY, buf, strlen(msg) + 1 + msg-buf); From 05f1a9edc19ebcc0e383aca72bb52a9f6b83b349 Mon Sep 17 00:00:00 2001 From: LJ Sonic Date: Mon, 10 Jan 2022 19:57:15 +0100 Subject: [PATCH 1028/1080] Revert "Fix long chat messages causing net command failures" This reverts commit 13778247990d60c2ad8aa5729bc0397ab764eaaa. --- src/hu_stuff.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 4c07e07d9..edbb2d8ec 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -634,8 +634,7 @@ static void Got_Saycmd(UINT8 **p, INT32 playernum) SINT8 target; UINT8 flags; const char *dispname; - char msgbuf[HU_MAXMSGLEN + 1]; - char *msg = msgbuf; + char *msg; boolean action = false; char *ptr; INT32 spam_eatmsg = 0; @@ -644,7 +643,8 @@ static void Got_Saycmd(UINT8 **p, INT32 playernum) target = READSINT8(*p); flags = READUINT8(*p); - READSTRINGN(*p, msgbuf, HU_MAXMSGLEN); + msg = (char *)*p; + SKIPSTRINGN(*p, HU_MAXMSGLEN); if ((cv_mute.value || flags & (HU_CSAY|HU_SERVER_SAY)) && playernum != serverplayer && !(IsPlayerAdmin(playernum))) { @@ -913,11 +913,7 @@ static void HU_sendChatMessage(void) if (c >= ' ' && !(c & 0x80)) buf[ci] = c; }; - if (ci-2 < HU_MAXMSGLEN) - { - buf[ci] = '\0'; - ci++; - } + buf[ci] = '\0'; memset(w_chat, '\0', sizeof(w_chat)); c_input = 0; @@ -985,7 +981,7 @@ static void HU_sendChatMessage(void) { buf[0] = teamtalk ? -1 : target; // target buf[1] = 0; // flags - SendNetXCmd(XD_SAY, buf, ci); + SendNetXCmd(XD_SAY, buf, 2 + strlen(&buf[2]) + 1); } } From aee7803621d5b4c77c69a626dac1077f93b19264 Mon Sep 17 00:00:00 2001 From: LJ Sonic Date: Mon, 10 Jan 2022 20:03:29 +0100 Subject: [PATCH 1029/1080] Add SKIPSTRINGL macro --- src/byteptr.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/byteptr.h b/src/byteptr.h index 3a1366577..ee16bc13f 100644 --- a/src/byteptr.h +++ b/src/byteptr.h @@ -192,6 +192,8 @@ FUNCINLINE static ATTRINLINE UINT32 readulong(void *ptr) tmp_i++; \ }) +#define SKIPSTRINGL(p, n) SKIPSTRINGN(p, n) + #define READSTRINGN(p, s, n) ({ \ size_t tmp_i = 0; \ \ From de9d6ecbe682d14153a7af0bba02f62de4a42ccc Mon Sep 17 00:00:00 2001 From: LJ Sonic Date: Mon, 10 Jan 2022 20:05:58 +0100 Subject: [PATCH 1030/1080] Fix long chat messages causing net command failures --- 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 edbb2d8ec..a6341ff29 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -644,7 +644,7 @@ static void Got_Saycmd(UINT8 **p, INT32 playernum) target = READSINT8(*p); flags = READUINT8(*p); msg = (char *)*p; - SKIPSTRINGN(*p, HU_MAXMSGLEN); + SKIPSTRINGL(*p, HU_MAXMSGLEN + 1); if ((cv_mute.value || flags & (HU_CSAY|HU_SERVER_SAY)) && playernum != serverplayer && !(IsPlayerAdmin(playernum))) { From a6808de96c18d744550bf9ce0b48ef4f3dc12d00 Mon Sep 17 00:00:00 2001 From: LJ Sonic Date: Mon, 10 Jan 2022 20:12:27 +0100 Subject: [PATCH 1031/1080] Fix message sending code using hardcoded buffer size --- src/hu_stuff.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hu_stuff.c b/src/hu_stuff.c index a6341ff29..32ca59e6a 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -897,7 +897,7 @@ static boolean HU_chatboxContainsOnlySpaces(void) static void HU_sendChatMessage(void) { - char buf[2+256]; + char buf[2 + HU_MAXMSGLEN + 1]; char *msg = &buf[2]; size_t ci; INT32 target = 0; @@ -975,7 +975,7 @@ static void HU_sendChatMessage(void) // we need to get rid of the /pm newmsg = msg+5+spc; - strlcpy(msg, newmsg, 255); + strlcpy(msg, newmsg, HU_MAXMSGLEN + 1); } if (ci > 2) // don't send target+flags+empty message. { From af5173c90f1960245415a88febd3d67505fa5674 Mon Sep 17 00:00:00 2001 From: spherallic Date: Mon, 10 Jan 2022 21:38:30 +0100 Subject: [PATCH 1032/1080] Increase Eggman's hitboxes to actually match the current sprites. --- src/info.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/info.c b/src/info.c index 331e114b6..544ed1e31 100644 --- a/src/info.c +++ b/src/info.c @@ -5601,8 +5601,8 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = S_EGGMOBILE_FLEE1, // xdeathstate sfx_s3kb4, // deathsound 4, // speed - 24*FRACUNIT, // radius - 76*FRACUNIT, // height + 48*FRACUNIT, // radius + 84*FRACUNIT, // height 0, // display offset sfx_None, // mass 3, // damage @@ -5736,8 +5736,8 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = S_EGGMOBILE2_FLEE1,// xdeathstate sfx_s3kb4, // deathsound 2*FRACUNIT, // speed - 24*FRACUNIT, // radius - 76*FRACUNIT, // height + 48*FRACUNIT, // radius + 96*FRACUNIT, // height 0, // display offset 0, // mass 3, // damage @@ -5844,7 +5844,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = S_EGGMOBILE3_FLEE1, // xdeathstate sfx_s3kb4, // deathsound 8*FRACUNIT, // speed - 32*FRACUNIT, // radius + 48*FRACUNIT, // radius 116*FRACUNIT, // height 0, // display offset MT_FAKEMOBILE, // mass @@ -5925,8 +5925,8 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = S_EGGMOBILE4_FLEE1,// xdeathstate sfx_s3kb4, // deathsound 0, // speed - 24*FRACUNIT, // radius - 76*FRACUNIT, // height + 48*FRACUNIT, // radius + 84*FRACUNIT, // height 0, // display offset 0, // mass 3, // damage From 2e4c5d1446f312d830b02d2d2d9163d233ca6d88 Mon Sep 17 00:00:00 2001 From: katsy Date: Mon, 10 Jan 2022 19:32:21 -0600 Subject: [PATCH 1033/1080] alternate fix to #555 which doesn't crash the game --- src/r_patchrotation.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/r_patchrotation.c b/src/r_patchrotation.c index dae3a7b53..5dbc30286 100644 --- a/src/r_patchrotation.c +++ b/src/r_patchrotation.c @@ -227,10 +227,10 @@ void RotatedPatch_DoRotation(rotsprite_t *rotsprite, patch_t *patch, INT32 angle ox = (newwidth / 2) + (leftoffset - xpivot); oy = (newheight / 2) + (patch->topoffset - ypivot); - width = (maxx+1 - minx); - height = (maxy+1 - miny); + width = (maxx - minx); + height = (maxy - miny); - if ((unsigned)(width * height) != size) + if ((unsigned)(width * height) > size) { UINT16 *src, *dest; From 93512ae9f9c39363f0b9da9eac7fbb8fd8ec3443 Mon Sep 17 00:00:00 2001 From: spherallic Date: Wed, 12 Jan 2022 00:46:24 +0100 Subject: [PATCH 1034/1080] Update Zone Builder configuration. --- extras/conf/SRB2-22.cfg | 92 +++++++++++++++++++++++++++++++---------- 1 file changed, 70 insertions(+), 22 deletions(-) diff --git a/extras/conf/SRB2-22.cfg b/extras/conf/SRB2-22.cfg index 2b4bdbcd7..b780ff75f 100644 --- a/extras/conf/SRB2-22.cfg +++ b/extras/conf/SRB2-22.cfg @@ -1091,6 +1091,7 @@ linedeftypes { title = "Water, Opaque"; prefix = "(120)"; + flags2text = "[1] Make lava intangible"; flags8text = "[3] Slope skew sides"; flags64text = "[6] Use two light levels"; flags512text = "[9] Use target light level"; @@ -1106,6 +1107,7 @@ linedeftypes { title = "Water, Translucent"; prefix = "(121)"; + flags2text = "[1] Make lava intangible"; flags8text = "[3] Slope skew sides"; flags64text = "[6] Use two light levels"; flags512text = "[9] Use target light level"; @@ -1122,6 +1124,7 @@ linedeftypes { title = "Water, Opaque, No Sides"; prefix = "(122)"; + flags2text = "[1] Make lava intangible"; flags64text = "[6] Use two light levels"; flags512text = "[9] Use target light level"; flags1024text = "[10] Ripple effect"; @@ -1136,6 +1139,7 @@ linedeftypes { title = "Water, Translucent, No Sides"; prefix = "(123)"; + flags2text = "[1] Make lava intangible"; flags64text = "[6] Use two light levels"; flags512text = "[9] Use target light level"; flags1024text = "[10] Ripple effect"; @@ -1151,6 +1155,7 @@ linedeftypes { title = "Goo Water, Translucent"; prefix = "(124)"; + flags2text = "[1] Make lava intangible"; flags8text = "[3] Slope skew sides"; flags64text = "[6] Use two light levels"; flags512text = "[9] Use target light level"; @@ -1167,6 +1172,7 @@ linedeftypes { title = "Goo Water, Translucent, No Sides"; prefix = "(125)"; + flags2text = "[1] Make lava intangible"; flags64text = "[6] Use two light levels"; flags512text = "[9] Use target light level"; flags1024text = "[10] Ripple effect"; @@ -1669,12 +1675,14 @@ linedeftypes { title = "Continuous"; prefix = "(300)"; + flags1024text = "[10] Use faster, unordered execution"; } 301 { title = "Each Time"; prefix = "(301)"; + flags1024text = "[10] Use faster, unordered execution"; flags16384text = "[14] Also trigger on exit"; } @@ -1682,6 +1690,7 @@ linedeftypes { title = "Once"; prefix = "(302)"; + flags1024text = "[10] Use faster, unordered execution"; } 303 @@ -1691,6 +1700,7 @@ linedeftypes flags2text = "[1] Rings greater or equal"; flags64text = "[6] Rings less or equal"; flags512text = "[9] Consider all players"; + flags1024text = "[10] Use faster, unordered execution"; } 304 @@ -1700,18 +1710,21 @@ linedeftypes flags2text = "[1] Rings greater or equal"; flags64text = "[6] Rings less or equal"; flags512text = "[9] Consider all players"; + flags1024text = "[10] Use faster, unordered execution"; } 305 { title = "Character Ability - Continuous"; prefix = "(305)"; + flags1024text = "[10] Use faster, unordered execution"; } 306 { title = "Character Ability - Each Time"; prefix = "(306)"; + flags1024text = "[10] Use faster, unordered execution"; flags16384text = "[14] Also trigger on exit"; } @@ -1719,24 +1732,28 @@ linedeftypes { title = "Character Ability - Once"; prefix = "(307)"; + flags1024text = "[10] Use faster, unordered execution"; } 308 { title = "Race Only - Once"; prefix = "(308)"; + flags1024text = "[10] Use faster, unordered execution"; } 309 { title = "CTF Red Team - Continuous"; prefix = "(309)"; + flags1024text = "[10] Use faster, unordered execution"; } 310 { title = "CTF Red Team - Each Time"; prefix = "(310)"; + flags1024text = "[10] Use faster, unordered execution"; flags16384text = "[14] Also trigger on exit"; } @@ -1744,12 +1761,14 @@ linedeftypes { title = "CTF Blue Team - Continuous"; prefix = "(311)"; + flags1024text = "[10] Use faster, unordered execution"; } 312 { title = "CTF Blue Team - Each Time"; prefix = "(312)"; + flags1024text = "[10] Use faster, unordered execution"; flags16384text = "[14] Also trigger on exit"; } @@ -1757,6 +1776,7 @@ linedeftypes { title = "No More Enemies - Once"; prefix = "(313)"; + flags1024text = "[10] Use faster, unordered execution"; } 314 @@ -1765,6 +1785,7 @@ linedeftypes prefix = "(314)"; flags64text = "[6] Number greater or equal"; flags512text = "[9] Number less"; + flags1024text = "[10] Use faster, unordered execution"; } 315 @@ -1773,30 +1794,35 @@ linedeftypes prefix = "(315)"; flags64text = "[6] Number greater or equal"; flags512text = "[9] Number less"; + flags1024text = "[10] Use faster, unordered execution"; } 317 { title = "Condition Set Trigger - Continuous"; prefix = "(317)"; + flags1024text = "[10] Use faster, unordered execution"; } 318 { title = "Condition Set Trigger - Once"; prefix = "(318)"; + flags1024text = "[10] Use faster, unordered execution"; } 319 { title = "Unlockable - Continuous"; prefix = "(319)"; + flags1024text = "[10] Use faster, unordered execution"; } 320 { title = "Unlockable - Once"; prefix = "(320)"; + flags1024text = "[10] Use faster, unordered execution"; } 321 @@ -1804,6 +1830,7 @@ linedeftypes title = "Trigger After X Calls - Continuous"; prefix = "(321)"; flags64text = "[6] Trigger more than once"; + flags1024text = "[10] Use faster, unordered execution"; } @@ -1812,6 +1839,7 @@ linedeftypes title = "Trigger After X Calls - Each Time"; prefix = "(322)"; flags64text = "[6] Trigger more than once"; + flags1024text = "[10] Use faster, unordered execution"; } 323 @@ -1826,6 +1854,7 @@ linedeftypes flags128text = "[7] Lap >= Front Y Offset"; flags256text = "[8] Count laps from Bonus Time"; flags512text = "[9] Count from triggering player"; + flags1024text = "[10] Use faster, unordered execution"; flags16384text = "[14] Run if no more mares"; flags32768text = "[15] Run if player is not NiGHTS"; } @@ -1833,6 +1862,7 @@ linedeftypes 324 { title = "NiGHTSerize - Once"; + prefix = "(324)"; flags2text = "[1] Mare >= Front X Offset"; flags8text = "[3] Run only if player is NiGHTS"; flags16text = "[4] Count from lowest of players"; @@ -1841,14 +1871,15 @@ linedeftypes flags128text = "[7] Lap >= Front Y Offset"; flags256text = "[8] Count laps from Bonus Time"; flags512text = "[9] Count from triggering player"; + flags1024text = "[10] Use faster, unordered execution"; flags16384text = "[14] Run if no more mares"; flags32768text = "[15] Run if player is not NiGHTS"; - prefix = "(324)"; } 325 { title = "De-NiGHTSerize - Each Time"; + prefix = "(325)"; flags2text = "[1] Mare >= Front X Offset"; flags8text = "[3] Run if anyone is NiGHTS"; flags16text = "[4] Count from lowest of players"; @@ -1857,13 +1888,14 @@ linedeftypes flags128text = "[7] Lap >= Front Y Offset"; flags256text = "[8] Count laps from Bonus Time"; flags512text = "[9] Count from triggering player"; + flags1024text = "[10] Use faster, unordered execution"; flags32768text = "[15] Run if no one is NiGHTS"; - prefix = "(325)"; } 326 { title = "De-NiGHTSerize - Once"; + prefix = "(326)"; flags2text = "[1] Mare >= Front X Offset"; flags8text = "[3] Run if anyone is NiGHTS"; flags16text = "[4] Count from lowest of players"; @@ -1872,13 +1904,14 @@ linedeftypes flags128text = "[7] Lap >= Front Y Offset"; flags256text = "[8] Count laps from Bonus Time"; flags512text = "[9] Count from triggering player"; + flags1024text = "[10] Use faster, unordered execution"; flags32768text = "[15] Run if no one is NiGHTS"; - prefix = "(326)"; } 327 { title = "NiGHTS Lap - Each Time"; + prefix = "(327)"; flags2text = "[1] Mare >= Front X Offset"; flags16text = "[4] Count from lowest of players"; flags32text = "[5] Lap <= Front Y Offset"; @@ -1886,12 +1919,13 @@ linedeftypes flags128text = "[7] Lap >= Front Y Offset"; flags256text = "[8] Count laps from Bonus Time"; flags512text = "[9] Count from triggering player"; - prefix = "(327)"; + flags1024text = "[10] Use faster, unordered execution"; } 328 { title = "NiGHTS Lap - Once"; + prefix = "(328)"; flags2text = "[1] Mare >= Front X Offset"; flags16text = "[4] Count from lowest of players"; flags32text = "[5] Lap <= Front Y Offset"; @@ -1899,12 +1933,13 @@ linedeftypes flags128text = "[7] Lap >= Front Y Offset"; flags256text = "[8] Count laps from Bonus Time"; flags512text = "[9] Count from triggering player"; - prefix = "(328)"; + flags1024text = "[10] Use faster, unordered execution"; } 329 { title = "Ideya Capture Touch - Each Time"; + prefix = "(329)"; flags2text = "[1] Mare >= Front X Offset"; flags8text = "[3] Run regardless of spheres"; flags16text = "[4] Count from lowest of players"; @@ -1913,14 +1948,15 @@ linedeftypes flags128text = "[7] Lap >= Front Y Offset"; flags256text = "[8] Count laps from Bonus Time"; flags512text = "[9] Count from triggering player"; + flags1024text = "[10] Use faster, unordered execution"; flags16384text = "[14] Only if not enough spheres"; flags32768text = "[15] Run when entering Capture"; - prefix = "(329)"; } 330 { title = "Ideya Capture Touch - Once"; + prefix = "(330)"; flags2text = "[1] Mare >= Front X Offset"; flags8text = "[3] Run regardless of spheres"; flags16text = "[4] Count from lowest of players"; @@ -1929,57 +1965,64 @@ linedeftypes flags128text = "[7] Lap >= Front Y Offset"; flags256text = "[8] Count laps from Bonus Time"; flags512text = "[9] Count from triggering player"; + flags1024text = "[10] Use faster, unordered execution"; flags16384text = "[14] Only if not enough spheres"; flags32768text = "[15] Run when entering Capture"; - prefix = "(330)"; } 331 { title = "Player Skin - Continuous"; - flags64text = "[6] Disable for this skin"; prefix = "(331)"; + flags64text = "[6] Disable for this skin"; + flags1024text = "[10] Use faster, unordered execution"; } 332 { title = "Player Skin - Each Time"; - flags64text = "[6] Disable for this skin"; prefix = "(332)"; + flags64text = "[6] Disable for this skin"; + flags1024text = "[10] Use faster, unordered execution"; } 333 { title = "Player Skin - Once"; - flags64text = "[6] Disable for this skin"; prefix = "(333)"; + flags64text = "[6] Disable for this skin"; + flags1024text = "[10] Use faster, unordered execution"; } 334 { title = "Object Dye - Continuous"; - flags64text = "[6] Disable for this color"; prefix = "(334)"; + flags64text = "[6] Disable for this color"; + flags1024text = "[10] Use faster, unordered execution"; } 335 { title = "Object Dye - Each Time"; - flags64text = "[6] Disable for this color"; prefix = "(335)"; + flags64text = "[6] Disable for this color"; + flags1024text = "[10] Use faster, unordered execution"; } 336 { title = "Object Dye - Once"; - flags64text = "[6] Disable for this color"; prefix = "(336)"; + flags64text = "[6] Disable for this color"; + flags1024text = "[10] Use faster, unordered execution"; } 399 { title = "Level Load"; prefix = "(399)"; + flags1024text = "[10] Use faster, unordered execution"; } } @@ -2662,7 +2705,7 @@ linedeftypes 502 { - title = "Scroll Tagged Wall"; + title = "Scroll Tagged Walls"; prefix = "(502)"; flags128text = "[7] Use texture offsets"; flags256text = "[8] Scroll back side"; @@ -2670,7 +2713,7 @@ linedeftypes 503 { - title = "Scroll Tagged Wall (Accelerative)"; + title = "Scroll Tagged Walls (Accelerative)"; prefix = "(503)"; flags128text = "[7] Use texture offsets"; flags256text = "[8] Scroll back side"; @@ -2678,7 +2721,7 @@ linedeftypes 504 { - title = "Scroll Tagged Wall (Displacement)"; + title = "Scroll Tagged Walls (Displacement)"; prefix = "(504)"; flags128text = "[7] Use texture offsets"; flags256text = "[8] Scroll back side"; @@ -3112,7 +3155,7 @@ linedeftypes 723 { title = "Copy Backside Floor Slope from Line Tag"; - prefix = "(720)"; + prefix = "(723)"; slope = "copy"; slopeargs = 4; } @@ -3120,7 +3163,7 @@ linedeftypes 724 { title = "Copy Backside Ceiling Slope from Line Tag"; - prefix = "(721)"; + prefix = "(724)"; slope = "copy"; slopeargs = 8; } @@ -3128,7 +3171,7 @@ linedeftypes 725 { title = "Copy Backside Floor and Ceiling Slope from Line Tag"; - prefix = "(722)"; + prefix = "(725)"; slope = "copy"; slopeargs = 12; } @@ -3190,7 +3233,7 @@ linedeftypes transwall { - title = "Translucent Wall"; + title = "Translucent Walls"; 900 { @@ -3966,6 +4009,7 @@ thingtypes sprite = "BUMBA1"; width = 16; height = 32; + flags8text = "[8] Cannot move"; } 124 { @@ -3996,7 +4040,6 @@ thingtypes width = 24; height = 76; flags4text = "[4] End level on death"; - flags8text = "[8] Alternate laser attack"; } 201 { @@ -4031,6 +4074,7 @@ thingtypes height = 60; flags1text = "[1] Grayscale mode"; flags4text = "[4] End level on death"; + flags8text = "[8] Skip intro"; } 206 { @@ -5232,7 +5276,7 @@ thingtypes width = 8; height = 16; hangs = 1; - angletext = "Dripping interval"; + angletext = "Dripping delay"; fixedrotation = 1; } 1003 @@ -5574,6 +5618,8 @@ thingtypes width = 20; height = 72; arrow = 1; + flags4text = "[4] Move right"; + flags8text = "[8] Move left"; } 1128 { @@ -5726,6 +5772,7 @@ thingtypes width = 24; height = 63; arrow = 1; + flags8text = "[8] Not pushable"; } 1217 { @@ -5861,6 +5908,7 @@ thingtypes height = 32; angletext = "Initial delay"; fixedrotation = 1; + hangs = 1; flags8text = "[8] Double size"; } 1305 From b7dbb7782e5e1ca96ea3e79521f9ce0d7f5ab7f7 Mon Sep 17 00:00:00 2001 From: LJ Sonic Date: Wed, 12 Jan 2022 23:06:26 +0100 Subject: [PATCH 1035/1080] Only load map lumps that are WADs or have no extension --- src/p_setup.c | 2 +- src/w_wad.c | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index 4f21922a0..f6abc70e6 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -4373,7 +4373,7 @@ boolean P_LoadLevel(boolean fromnetsave, boolean reloadinggamestate) // internal game map maplumpname = G_BuildMapName(gamemap); - lastloadedmaplumpnum = W_CheckNumForName(maplumpname); + lastloadedmaplumpnum = W_CheckNumForMap(maplumpname); if (lastloadedmaplumpnum == LUMPERROR) I_Error("Map %s not found.\n", maplumpname); diff --git a/src/w_wad.c b/src/w_wad.c index e49e0ce82..b594912f1 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -1463,8 +1463,14 @@ lumpnum_t W_CheckNumForMap(const char *name) continue; // Now look for the specified map. for (; lumpNum < end; lumpNum++) - if (!strnicmp(name, (wadfiles[i]->lumpinfo + lumpNum)->name, 8)) - return (i<<16) + lumpNum; + { + if (!strnicmp(name, wadfiles[i]->lumpinfo[lumpNum].name, 8)) + { + const char *extension = strrchr(wadfiles[i]->lumpinfo[lumpNum].fullname, '.'); + if (!(extension && stricmp(extension, ".wad"))) + return (i<<16) + lumpNum; + } + } } } return LUMPERROR; From 4af820e82ce46d112a1895c133cac5f41986b522 Mon Sep 17 00:00:00 2001 From: lachablock Date: Thu, 13 Jan 2022 09:56:47 +1100 Subject: [PATCH 1036/1080] Restore a cast I didn't realize used to be there --- 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 ebb5f33ea..eae22a0d4 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1556,7 +1556,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) } if (player->bot == BOT_2PHUMAN) - cmd->angleturn = (localangle - *myangle) >> 16; + cmd->angleturn = (INT16)((localangle - *myangle) >> 16); *myangle += (cmd->angleturn<<16); From fe3a201df58f8e185d61bbd7b2bde83ee9d26496 Mon Sep 17 00:00:00 2001 From: katsy Date: Thu, 13 Jan 2022 02:52:10 -0600 Subject: [PATCH 1037/1080] fix oldringexplode not scaling or flipping --- src/p_enemy.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/p_enemy.c b/src/p_enemy.c index 9d51aced5..3b1d0a7cd 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -6542,7 +6542,7 @@ void A_OldRingExplode(mobj_t *actor) { { const angle_t fa = (i*FINEANGLES/16) & FINEMASK; - mo = P_SpawnMobj(actor->x, actor->y, actor->z, locvar1); + mo = P_SpawnMobjFromMobj(actor, 0, 0, 0, locvar1); P_SetTarget(&mo->target, actor->target); // Transfer target so player gets the points mo->momx = FixedMul(FINECOSINE(fa),ns); @@ -6568,7 +6568,7 @@ void A_OldRingExplode(mobj_t *actor) { } } - mo = P_SpawnMobj(actor->x, actor->y, actor->z, locvar1); + mo = P_SpawnMobjFromMobj(actor, 0, 0, 0, locvar1); P_SetTarget(&mo->target, actor->target); mo->momz = ns; @@ -6583,7 +6583,7 @@ void A_OldRingExplode(mobj_t *actor) { mo->color = skincolor_bluering; } - mo = P_SpawnMobj(actor->x, actor->y, actor->z, locvar1); + mo = P_SpawnMobjFromMobj(actor, 0, 0, 0, locvar1); P_SetTarget(&mo->target, actor->target); mo->momz = -ns; From f72f45d93ab530af40fb05b10be4a52a5c3db256 Mon Sep 17 00:00:00 2001 From: Hannu Hanhi Date: Fri, 14 Jan 2022 19:53:03 +0200 Subject: [PATCH 1038/1080] Fix software splats breaking and crashing in skyboxes --- src/r_things.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/r_things.c b/src/r_things.c index accd1e2b3..423276a59 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -3001,13 +3001,25 @@ void R_ClipVisSprite(vissprite_t *spr, INT32 x1, INT32 x2, drawseg_t* dsstart, p if (portal) { - for (x = x1; x <= x2; x++) + INT32 start_index = max(portal->start, x1); + INT32 end_index = min(portal->start + portal->end - portal->start, x2); + for (x = x1; x < start_index; x++) + { + 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]) spr->clipbot[x] = portal->floorclip[x - portal->start]; 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; + } } } From d0966f123fc825befe3a90286c70f92b85d0f9c8 Mon Sep 17 00:00:00 2001 From: Hannu Hanhi Date: Fri, 14 Jan 2022 20:11:49 +0200 Subject: [PATCH 1039/1080] Fix software splats not being clipped by ceiling walls --- src/r_splats.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/r_splats.c b/src/r_splats.c index c554e9b1f..21048c46d 100644 --- a/src/r_splats.c +++ b/src/r_splats.c @@ -482,7 +482,7 @@ static void R_RasterizeFloorSplat(floorsplat_t *pSplat, vector2_t *verts, visspr continue; for (i = x1; i <= x2; i++) - cliptab[i] = (y >= mfloorclip[i]); + cliptab[i] = (y >= mfloorclip[i] || y <= mceilingclip[i]); // clip left while (cliptab[x1]) From 49d03913d72769e3343555c5784ea60a755faf96 Mon Sep 17 00:00:00 2001 From: Hannu Hanhi Date: Fri, 14 Jan 2022 20:45:28 +0200 Subject: [PATCH 1040/1080] Add missing optimization to npo2 sloped floor sprites --- src/r_draw8_npo2.c | 72 +++++++++++++++++++++++++++------------------- 1 file changed, 42 insertions(+), 30 deletions(-) diff --git a/src/r_draw8_npo2.c b/src/r_draw8_npo2.c index 2433cb402..90201c771 100644 --- a/src/r_draw8_npo2.c +++ b/src/r_draw8_npo2.c @@ -992,6 +992,9 @@ void R_DrawTiltedFloorSprite_NPO2_8(void) double endz, endu, endv; UINT32 stepu, stepv; + struct libdivide_u32_t x_divider = libdivide_u32_gen(ds_flatwidth); + struct libdivide_u32_t y_divider = libdivide_u32_gen(ds_flatheight); + iz = ds_szp->z + ds_szp->y*(centery-ds_y) + ds_szp->x*(ds_x1-centerx); uz = ds_sup->z + ds_sup->y*(centery-ds_y) + ds_sup->x*(ds_x1-centerx); vz = ds_svp->z + ds_svp->y*(centery-ds_y) + ds_svp->x*(ds_x1-centerx); @@ -1033,12 +1036,13 @@ void R_DrawTiltedFloorSprite_NPO2_8(void) // Carefully align all of my Friends. if (x < 0) - x = ds_flatwidth - ((UINT32)(ds_flatwidth - x) % ds_flatwidth); + x += (libdivide_u32_do((UINT32)(-x-1), &x_divider) + 1) * ds_flatwidth; + else + x -= libdivide_u32_do((UINT32)x, &x_divider) * ds_flatwidth; if (y < 0) - y = ds_flatheight - ((UINT32)(ds_flatheight - y) % ds_flatheight); - - x %= ds_flatwidth; - y %= ds_flatheight; + y += (libdivide_u32_do((UINT32)(-y-1), &y_divider) + 1) * ds_flatheight; + else + y -= libdivide_u32_do((UINT32)y, &y_divider) * ds_flatheight; val = source[((y * ds_flatwidth) + x)]; if (val & 0xFF00) @@ -1065,12 +1069,13 @@ void R_DrawTiltedFloorSprite_NPO2_8(void) // Carefully align all of my Friends. if (x < 0) - x = ds_flatwidth - ((UINT32)(ds_flatwidth - x) % ds_flatwidth); + x += (libdivide_u32_do((UINT32)(-x-1), &x_divider) + 1) * ds_flatwidth; + else + x -= libdivide_u32_do((UINT32)x, &x_divider) * ds_flatwidth; if (y < 0) - y = ds_flatheight - ((UINT32)(ds_flatheight - y) % ds_flatheight); - - x %= ds_flatwidth; - y %= ds_flatheight; + y += (libdivide_u32_do((UINT32)(-y-1), &y_divider) + 1) * ds_flatheight; + else + y -= libdivide_u32_do((UINT32)y, &y_divider) * ds_flatheight; val = source[((y * ds_flatwidth) + x)]; if (val & 0xFF00) @@ -1101,12 +1106,13 @@ void R_DrawTiltedFloorSprite_NPO2_8(void) // Carefully align all of my Friends. if (x < 0) - x = ds_flatwidth - ((UINT32)(ds_flatwidth - x) % ds_flatwidth); + x += (libdivide_u32_do((UINT32)(-x-1), &x_divider) + 1) * ds_flatwidth; + else + x -= libdivide_u32_do((UINT32)x, &x_divider) * ds_flatwidth; if (y < 0) - y = ds_flatheight - ((UINT32)(ds_flatheight - y) % ds_flatheight); - - x %= ds_flatwidth; - y %= ds_flatheight; + y += (libdivide_u32_do((UINT32)(-y-1), &y_divider) + 1) * ds_flatheight; + else + y -= libdivide_u32_do((UINT32)y, &y_divider) * ds_flatheight; val = source[((y * ds_flatwidth) + x)]; if (val & 0xFF00) @@ -1142,6 +1148,9 @@ void R_DrawTiltedTranslucentFloorSprite_NPO2_8(void) double endz, endu, endv; UINT32 stepu, stepv; + struct libdivide_u32_t x_divider = libdivide_u32_gen(ds_flatwidth); + struct libdivide_u32_t y_divider = libdivide_u32_gen(ds_flatheight); + iz = ds_szp->z + ds_szp->y*(centery-ds_y) + ds_szp->x*(ds_x1-centerx); uz = ds_sup->z + ds_sup->y*(centery-ds_y) + ds_sup->x*(ds_x1-centerx); vz = ds_svp->z + ds_svp->y*(centery-ds_y) + ds_svp->x*(ds_x1-centerx); @@ -1183,12 +1192,13 @@ void R_DrawTiltedTranslucentFloorSprite_NPO2_8(void) // Carefully align all of my Friends. if (x < 0) - x = ds_flatwidth - ((UINT32)(ds_flatwidth - x) % ds_flatwidth); + x += (libdivide_u32_do((UINT32)(-x-1), &x_divider) + 1) * ds_flatwidth; + else + x -= libdivide_u32_do((UINT32)x, &x_divider) * ds_flatwidth; if (y < 0) - y = ds_flatheight - ((UINT32)(ds_flatheight - y) % ds_flatheight); - - x %= ds_flatwidth; - y %= ds_flatheight; + y += (libdivide_u32_do((UINT32)(-y-1), &y_divider) + 1) * ds_flatheight; + else + y -= libdivide_u32_do((UINT32)y, &y_divider) * ds_flatheight; val = source[((y * ds_flatwidth) + x)]; if (val & 0xFF00) @@ -1215,12 +1225,13 @@ void R_DrawTiltedTranslucentFloorSprite_NPO2_8(void) // Carefully align all of my Friends. if (x < 0) - x = ds_flatwidth - ((UINT32)(ds_flatwidth - x) % ds_flatwidth); + x += (libdivide_u32_do((UINT32)(-x-1), &x_divider) + 1) * ds_flatwidth; + else + x -= libdivide_u32_do((UINT32)x, &x_divider) * ds_flatwidth; if (y < 0) - y = ds_flatheight - ((UINT32)(ds_flatheight - y) % ds_flatheight); - - x %= ds_flatwidth; - y %= ds_flatheight; + y += (libdivide_u32_do((UINT32)(-y-1), &y_divider) + 1) * ds_flatheight; + else + y -= libdivide_u32_do((UINT32)y, &y_divider) * ds_flatheight; val = source[((y * ds_flatwidth) + x)]; if (val & 0xFF00) @@ -1251,12 +1262,13 @@ void R_DrawTiltedTranslucentFloorSprite_NPO2_8(void) // Carefully align all of my Friends. if (x < 0) - x = ds_flatwidth - ((UINT32)(ds_flatwidth - x) % ds_flatwidth); + x += (libdivide_u32_do((UINT32)(-x-1), &x_divider) + 1) * ds_flatwidth; + else + x -= libdivide_u32_do((UINT32)x, &x_divider) * ds_flatwidth; if (y < 0) - y = ds_flatheight - ((UINT32)(ds_flatheight - y) % ds_flatheight); - - x %= ds_flatwidth; - y %= ds_flatheight; + y += (libdivide_u32_do((UINT32)(-y-1), &y_divider) + 1) * ds_flatheight; + else + y -= libdivide_u32_do((UINT32)y, &y_divider) * ds_flatheight; val = source[((y * ds_flatwidth) + x)]; if (val & 0xFF00) From bf2809b213fadfffdb5d199f660bcb4a0b3d37d3 Mon Sep 17 00:00:00 2001 From: spherallic Date: Sat, 15 Jan 2022 17:12:33 +0100 Subject: [PATCH 1041/1080] Fix crosshairs not displaying and refactor their code. --- src/hu_stuff.c | 77 +++++++++----------------------------------------- 1 file changed, 14 insertions(+), 63 deletions(-) diff --git a/src/hu_stuff.c b/src/hu_stuff.c index cf7118fbe..281280c9b 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -1863,64 +1863,25 @@ static void HU_DrawChat_Old(void) } #endif -// draw the Crosshair, at the exact center of the view. -// +// Draw crosshairs at the exact center of the view. +// In splitscreen, crosshairs are stretched vertically to compensate for V_PERPLAYER squishing them. // Crosshairs are pre-cached at HU_Init -static inline void HU_DrawCrosshair(void) +static inline void HU_DrawCrosshairs(void) { - INT32 i, y, dupz; + INT32 cross1 = cv_crosshair.value & 3; + INT32 cross2 = cv_crosshair2.value & 3; - i = cv_crosshair.value & 3; - if (!i) + if (automapactive || demoplayback) return; - if ((netgame || multiplayer) && players[displayplayer].spectator) - return; + stplyr = ((stplyr == &players[displayplayer]) ? &players[secondarydisplayplayer] : &players[displayplayer]); + if (!players[displayplayer].spectator && (!camera.chase || ticcmd_ztargetfocus[0]) && cross1) + V_DrawStretchyFixedPatch((BASEVIDWIDTH/2)<>1); - - dupz = (vid.dupx < vid.dupy ? vid.dupx : vid.dupy); - - V_DrawFixedPatch(vid.width<<(FRACBITS-1), y<>1); - - if (!splitscreen) - return; - - #ifdef HWRENDER - if (rendermode != render_soft) - y += (INT32)gl_viewheight; - else - #endif - y += viewheight; - - dupz = (vid.dupx < vid.dupy ? vid.dupx : vid.dupy); - - V_DrawFixedPatch(vid.width<<(FRACBITS-1), y< Date: Wed, 19 Jan 2022 00:01:26 +1100 Subject: [PATCH 1042/1080] Revert server-sidedness of bots --- src/b_bot.c | 15 ++++++------ src/d_clisrv.c | 31 ------------------------ src/d_ticcmd.h | 9 ------- src/deh_tables.c | 5 ---- src/g_demo.c | 12 ---------- src/g_game.c | 57 ++++++++++++++++++++++++++------------------- src/lua_baselib.c | 3 --- src/lua_playerlib.c | 4 ---- src/p_saveg.c | 43 +++++++++++++--------------------- src/p_user.c | 10 +++----- 10 files changed, 60 insertions(+), 129 deletions(-) diff --git a/src/b_bot.c b/src/b_bot.c index 4fdfc8714..82075eb8e 100644 --- a/src/b_bot.c +++ b/src/b_bot.c @@ -17,6 +17,7 @@ #include "p_local.h" #include "b_bot.h" #include "lua_hook.h" +#include "i_system.h" // I_BaseTiccmd void B_UpdateBotleader(player_t *player) { @@ -176,6 +177,7 @@ static void B_BuildTailsTiccmd(mobj_t *sonic, mobj_t *tails, ticcmd_t *cmd) { jump = true; mem->thinkstate = AI_FLYSTANDBY; + bot->pflags |= PF_CANCARRY; } } @@ -187,10 +189,7 @@ static void B_BuildTailsTiccmd(mobj_t *sonic, mobj_t *tails, ticcmd_t *cmd) && P_IsObjectOnGround(sonic) && P_IsObjectOnGround(tails) && !(player->pflags & PF_STASIS) && bot->charability == CA_FLY) - { - mem->thinkstate = AI_THINKFLY; - cmd->flags |= TCF_FLIGHTINDICATOR; - } + mem->thinkstate = AI_THINKFLY; else if (mem->thinkstate == AI_THINKFLY) mem->thinkstate = AI_FOLLOW; @@ -211,8 +210,6 @@ static void B_BuildTailsTiccmd(mobj_t *sonic, mobj_t *tails, ticcmd_t *cmd) // Abort if the player moves away or spins if (dist > followthres || player->dashspeed) mem->thinkstate = AI_FOLLOW; - else - cmd->flags |= TCF_SETCARRY; } // Read player inputs while carrying else if (mem->thinkstate == AI_FLYCARRY) @@ -374,6 +371,8 @@ static void B_BuildTailsTiccmd(mobj_t *sonic, mobj_t *tails, ticcmd_t *cmd) void B_BuildTiccmd(player_t *player, ticcmd_t *cmd) { + G_CopyTiccmd(cmd, I_BaseTiccmd(), 1); // empty, or external driver + // Can't build a ticcmd if we aren't spawned... if (!player->mo) return; @@ -393,6 +392,7 @@ void B_BuildTiccmd(player_t *player, ticcmd_t *cmd) return; // Make sure we have a valid main character to follow + B_UpdateBotleader(player); if (!player->botleader) return; @@ -594,12 +594,13 @@ void B_RespawnBot(INT32 playernum) void B_HandleFlightIndicator(player_t *player) { mobj_t *tails = player->mo; + botmem_t *mem = &player->botmem; boolean shouldExist; if (!tails) return; - shouldExist = (player->cmd.flags & TCF_FLIGHTINDICATOR) && player->botleader + shouldExist = (mem->thinkstate == AI_THINKFLY) && player->botleader && player->bot == BOT_2PAI && player->playerstate == PST_LIVE; // check whether the indicator doesn't exist diff --git a/src/d_clisrv.c b/src/d_clisrv.c index c70532494..78a3ebe6c 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -46,7 +46,6 @@ #include "lua_libs.h" #include "md5.h" #include "m_perfstats.h" -#include "b_bot.h" // B_BuildTiccmd #ifndef NONET // cl loading screen @@ -5167,25 +5166,6 @@ static void Local_Maketic(INT32 realtics) localcmds2.angleturn |= TICCMD_RECEIVED; } -static void SV_MakeBotTics(void) -{ - UINT8 i; - for (i = 0; i < MAXPLAYERS; i++) - { - if (!playeringame[i]) - continue; - - if (players[i].bot == BOT_2PAI || players[i].bot == BOT_MPAI) - { - ticcmd_t *cmd = &netcmds[maketic % BACKUPTICS][i]; - - G_CopyTiccmd(cmd, I_BaseTiccmd(), 1); // empty, or external driver - B_BuildTiccmd(&players[i], cmd); - cmd->angleturn |= TICCMD_RECEIVED; - } - } -} - // create missed tic static void SV_Maketic(void) { @@ -5429,15 +5409,6 @@ void NetUpdate(void) if (client) maketic = neededtic; - // update players' lastbuttons so they can be used in ticcmd generation - for (i = 0; i < MAXPLAYERS; i++) - { - if (!playeringame[i]) - continue; - - players[i].lastbuttons = players[i].cmd.buttons; - } - Local_Maketic(realtics); // make local tic, and call menu? if (server) @@ -5481,8 +5452,6 @@ void NetUpdate(void) Net_ConnectionTimeout(i); } - SV_MakeBotTics(); - // Don't erase tics not acknowledged counts = realtics; diff --git a/src/d_ticcmd.h b/src/d_ticcmd.h index 480fbe2d4..182b30e6a 100644 --- a/src/d_ticcmd.h +++ b/src/d_ticcmd.h @@ -45,14 +45,6 @@ typedef enum BT_CUSTOM3 = 1<<15, } buttoncode_t; -// ticcmd flags -typedef enum -{ - TCF_FLIGHTINDICATOR = 1 << 0, // show flight indicator - TCF_SETCARRY = 1 << 1, // set PF_CARRY upon activating flight - // free up to and including 1 << 7 -} ticcmdflag_t; - // The data sampled per tick (single player) // and transmitted to other peers (multiplayer). // Mainly movements/button commands per game tick, @@ -74,7 +66,6 @@ typedef struct INT16 aiming; // vertical aiming, see G_BuildTicCmd UINT16 buttons; UINT8 latency; // Netgames: how many tics ago was this ticcmd generated from this player's end? - UINT8 flags; // miscellaneous info } ATTRPACK ticcmd_t; #if defined(_MSC_VER) diff --git a/src/deh_tables.c b/src/deh_tables.c index b150aa51d..cfc98f631 100644 --- a/src/deh_tables.c +++ b/src/deh_tables.c @@ -5345,11 +5345,6 @@ struct int_const_s const INT_CONST[] = { {"BT_CUSTOM2",BT_CUSTOM2}, // Lua customizable {"BT_CUSTOM3",BT_CUSTOM3}, // Lua customizable - // Ticcmd flags (ticcmdflag_t) - // (maybe move these into their own table in the future but I cba when there's only 2 LOL) - {"TCF_FLIGHTINDICATOR", TCF_FLIGHTINDICATOR}, - {"TCF_SETCARRY", TCF_SETCARRY}, - // Lua command registration flags {"COM_ADMIN",COM_ADMIN}, {"COM_SPLITSCREEN",COM_SPLITSCREEN}, diff --git a/src/g_demo.c b/src/g_demo.c index 2e2f6d56a..c97dbcf9e 100644 --- a/src/g_demo.c +++ b/src/g_demo.c @@ -110,7 +110,6 @@ demoghost *ghosts = NULL; #define ZT_BUTTONS 0x08 #define ZT_AIMING 0x10 #define ZT_LATENCY 0x20 -#define ZT_FLAGS 0x40 #define DEMOMARKER 0x80 // demoend #define METALDEATH 0x44 #define METALSNICE 0x69 @@ -185,8 +184,6 @@ void G_ReadDemoTiccmd(ticcmd_t *cmd, INT32 playernum) oldcmd.aiming = READINT16(demo_p); if (ziptic & ZT_LATENCY) oldcmd.latency = READUINT8(demo_p); - if (ziptic & ZT_FLAGS) - oldcmd.flags = READUINT8(demo_p); G_CopyTiccmd(cmd, &oldcmd, 1); players[playernum].angleturn = cmd->angleturn; @@ -251,13 +248,6 @@ void G_WriteDemoTiccmd(ticcmd_t *cmd, INT32 playernum) ziptic |= ZT_LATENCY; } - if (cmd->flags != oldcmd.flags) - { - WRITEUINT8(demo_p, cmd->flags); - oldcmd.flags = cmd->flags; - ziptic |= ZT_FLAGS; - } - *ziptic_p = ziptic; // attention here for the ticcmd size! @@ -701,8 +691,6 @@ void G_GhostTicker(void) g->p += 2; if (ziptic & ZT_LATENCY) g->p++; - if (ziptic & ZT_FLAGS) - g->p++; // Grab ghost data. ziptic = READUINT8(g->p); diff --git a/src/g_game.c b/src/g_game.c index eae22a0d4..c12b7e522 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1546,7 +1546,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) cmd->forwardmove = (SINT8)(cmd->forwardmove + forward); cmd->sidemove = (SINT8)(cmd->sidemove + side); - // Note: Majority of botstuffs are handled in G_Ticker and NetUpdate now. + // Note: Majority of botstuffs are handled in G_Ticker now. if (player->bot == BOT_2PAI && !player->powers[pw_tailsfly] && (cmd->forwardmove || cmd->sidemove || cmd->buttons)) @@ -1710,7 +1710,6 @@ ticcmd_t *G_MoveTiccmd(ticcmd_t* dest, const ticcmd_t* src, const size_t n) dest[i].aiming = (INT16)SHORT(src[i].aiming); dest[i].buttons = (UINT16)SHORT(src[i].buttons); dest[i].latency = src[i].latency; - dest[i].flags = src[i].flags; } return dest; } @@ -2313,35 +2312,45 @@ void G_Ticker(boolean run) buf = gametic % BACKUPTICS; + // Generate ticcmds for bots FIRST, then copy received ticcmds for players. + // This emulates pre-2.2.10 behaviour where the bot referenced their leader's last copied ticcmd, + // which is desirable because P_PlayerThink can override inputs (e.g. while PF_STASIS is applied or in a waterslide), + // and the bot AI needs to respect that. +#define ISHUMAN (players[i].bot == BOT_NONE || players[i].bot == BOT_2PHUMAN) for (i = 0; i < MAXPLAYERS; i++) { - if (playeringame[i]) + if (playeringame[i] && !ISHUMAN) // Less work is required if we're building a bot ticcmd. { - G_CopyTiccmd(&players[i].cmd, &netcmds[buf][i], 1); + players[i].lastbuttons = players[i].cmd.buttons; // Save last frame's button readings + B_BuildTiccmd(&players[i], &players[i].cmd); - if (players[i].bot == BOT_NONE || players[i].bot == BOT_2PHUMAN) - { - // Use the leveltime sent in the player's ticcmd to determine control lag - players[i].cmd.latency = min(((leveltime & 0xFF) - players[i].cmd.latency) & 0xFF, MAXPREDICTTICS-1); - - // Do angle adjustments. - - players[i].angleturn += players[i].cmd.angleturn - players[i].oldrelangleturn; - players[i].oldrelangleturn = players[i].cmd.angleturn; - if (P_ControlStyle(&players[i]) == CS_LMAOGALOG) - P_ForceLocalAngle(&players[i], players[i].angleturn << 16); - else - players[i].cmd.angleturn = (players[i].angleturn & ~TICCMD_RECEIVED) | (players[i].cmd.angleturn & TICCMD_RECEIVED); - } - else // Less work is required if we're building a bot ticcmd. - { - // Since bot TicCmd is pre-determined for both the client and server, the latency and packet checks are simplified. - players[i].cmd.latency = 0; - P_SetPlayerAngle(&players[i], players[i].cmd.angleturn << 16); - } + // Since bot TicCmd is pre-determined for both the client and server, the latency and packet checks are simplified. + players[i].cmd.latency = 0; + P_SetPlayerAngle(&players[i], players[i].cmd.angleturn << 16); } } + for (i = 0; i < MAXPLAYERS; i++) + { + if (playeringame[i] && ISHUMAN) + { + players[i].lastbuttons = players[i].cmd.buttons; // Save last frame's button readings + G_CopyTiccmd(&players[i].cmd, &netcmds[buf][i], 1); + + // Use the leveltime sent in the player's ticcmd to determine control lag + players[i].cmd.latency = min(((leveltime & 0xFF) - players[i].cmd.latency) & 0xFF, MAXPREDICTTICS-1); + + // Do angle adjustments. + players[i].angleturn += players[i].cmd.angleturn - players[i].oldrelangleturn; + players[i].oldrelangleturn = players[i].cmd.angleturn; + if (P_ControlStyle(&players[i]) == CS_LMAOGALOG) + P_ForceLocalAngle(&players[i], players[i].angleturn << 16); + else + players[i].cmd.angleturn = (players[i].angleturn & ~TICCMD_RECEIVED) | (players[i].cmd.angleturn & TICCMD_RECEIVED); + } + } +#undef ISHUMAN + // do main actions switch (gamestate) { diff --git a/src/lua_baselib.c b/src/lua_baselib.c index e0d09dee9..12ad4fee0 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -32,7 +32,6 @@ #include "b_bot.h" // B_UpdateBotleader #include "d_clisrv.h" // CL_RemovePlayer #include "i_system.h" // I_GetPreciseTime, I_PreciseToMicros -#include "i_net.h" // doomcom #include "lua_script.h" #include "lua_libs.h" @@ -3464,8 +3463,6 @@ static int lib_gAddPlayer(lua_State *L) playeringame[newplayernum] = true; G_AddPlayer(newplayernum); - if (newplayernum+1 > doomcom->numslots) - doomcom->numslots = (INT16)(newplayernum+1); newplayer = &players[newplayernum]; newplayer->jointime = 0; diff --git a/src/lua_playerlib.c b/src/lua_playerlib.c index edd1351e8..1c634da45 100644 --- a/src/lua_playerlib.c +++ b/src/lua_playerlib.c @@ -833,8 +833,6 @@ static int ticcmd_get(lua_State *L) lua_pushinteger(L, cmd->buttons); else if (fastcmp(field,"latency")) lua_pushinteger(L, cmd->latency); - else if (fastcmp(field,"flags")) - lua_pushinteger(L, cmd->flags); else return NOFIELD; @@ -863,8 +861,6 @@ static int ticcmd_set(lua_State *L) cmd->buttons = (UINT16)luaL_checkinteger(L, 3); else if (fastcmp(field,"latency")) return NOSET; - else if (fastcmp(field,"flags")) - cmd->flags = (UINT8)luaL_checkinteger(L, 3); else return NOFIELD; diff --git a/src/p_saveg.c b/src/p_saveg.c index f9938763a..722340f41 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -51,15 +51,14 @@ UINT8 *save_p; // than an UINT16 typedef enum { -// RFLAGPOINT = 0x001, -// BFLAGPOINT = 0x002, - CAPSULE = 0x004, - AWAYVIEW = 0x008, - FIRSTAXIS = 0x010, - SECONDAXIS = 0x020, - FOLLOW = 0x040, - DRONE = 0x080, - BOTLEADER = 0x100, +// RFLAGPOINT = 0x01, +// BFLAGPOINT = 0x02, + CAPSULE = 0x04, + AWAYVIEW = 0x08, + FIRSTAXIS = 0x10, + SECONDAXIS = 0x20, + FOLLOW = 0x40, + DRONE = 0x80, } player_saveflags; static inline void P_ArchivePlayer(void) @@ -198,11 +197,10 @@ static void P_NetArchivePlayers(void) // Bots // ////////// WRITEUINT8(save_p, players[i].bot); - // We no longer need to sync these since ticcmds are generated only by the server - //WRITEUINT8(save_p, players[i].botmem.lastForward); - //WRITEUINT8(save_p, players[i].botmem.lastBlocked); - //WRITEUINT8(save_p, players[i].botmem.catchup_tics); - //WRITEUINT8(save_p, players[i].botmem.thinkstate); + WRITEUINT8(save_p, players[i].botmem.lastForward); + WRITEUINT8(save_p, players[i].botmem.lastBlocked); + WRITEUINT8(save_p, players[i].botmem.catchup_tics); + WRITEUINT8(save_p, players[i].botmem.thinkstate); WRITEUINT8(save_p, players[i].removing); WRITEUINT8(save_p, players[i].blocked); @@ -295,9 +293,6 @@ static void P_NetArchivePlayers(void) if (players[i].drone) flags |= DRONE; - if (players[i].botleader) - flags |= BOTLEADER; - WRITEINT16(save_p, players[i].lastsidehit); WRITEINT16(save_p, players[i].lastlinehit); @@ -330,9 +325,6 @@ static void P_NetArchivePlayers(void) if (flags & DRONE) WRITEUINT32(save_p, players[i].drone->mobjnum); - if (flags & BOTLEADER) - WRITEUINT8(save_p, (UINT8)(players[i].botleader - players)); - WRITEFIXED(save_p, players[i].camerascale); WRITEFIXED(save_p, players[i].shieldscale); @@ -433,10 +425,10 @@ static void P_NetUnArchivePlayers(void) ////////// players[i].bot = READUINT8(save_p); - //players[i].botmem.lastForward = READUINT8(save_p); - //players[i].botmem.lastBlocked = READUINT8(save_p); - //players[i].botmem.catchup_tics = READUINT8(save_p); - //players[i].botmem.thinkstate = READUINT8(save_p); + players[i].botmem.lastForward = READUINT8(save_p); + players[i].botmem.lastBlocked = READUINT8(save_p); + players[i].botmem.catchup_tics = READUINT8(save_p); + players[i].botmem.thinkstate = READUINT8(save_p); players[i].removing = READUINT8(save_p); players[i].blocked = READUINT8(save_p); @@ -543,9 +535,6 @@ static void P_NetUnArchivePlayers(void) if (flags & DRONE) players[i].drone = (mobj_t *)(size_t)READUINT32(save_p); - if (flags & BOTLEADER) - players[i].botleader = &players[READUINT8(save_p)]; - players[i].camerascale = READFIXED(save_p); players[i].shieldscale = READFIXED(save_p); diff --git a/src/p_user.c b/src/p_user.c index ca7252584..b3e555e2d 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -5349,10 +5349,10 @@ static void P_DoJumpStuff(player_t *player, ticcmd_t *cmd) player->powers[pw_tailsfly] = tailsflytics + 1; // Set the fly timer player->pflags &= ~(PF_JUMPED|PF_NOJUMPDAMAGE|PF_SPINNING|PF_STARTDASH); - if ((player->bot != BOT_2PAI) || (cmd->flags & TCF_SETCARRY)) - player->pflags |= (PF_THOKKED|PF_CANCARRY); - else + if (player->bot == BOT_2PAI) player->pflags |= PF_THOKKED; + else + player->pflags |= (PF_THOKKED|PF_CANCARRY); } break; case CA_GLIDEANDCLIMB: @@ -11441,11 +11441,7 @@ void P_PlayerThink(player_t *player) if (B_CheckRespawn(player)) player->playerstate = PST_REBORN; else - { - if (player->bot == BOT_2PAI) - B_UpdateBotleader(player); B_HandleFlightIndicator(player); - } } if (player->playerstate == PST_REBORN) { From 9a07c1ca8c25996e091d9f442578be4cea60db4c Mon Sep 17 00:00:00 2001 From: spherallic Date: Wed, 19 Jan 2022 10:09:57 +0100 Subject: [PATCH 1043/1080] Fix HUD/graphic blendmodes not working at full opacity in Software. --- src/v_video.c | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/src/v_video.c b/src/v_video.c index 12588f9c2..49601ad78 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -539,7 +539,7 @@ void V_DrawStretchyFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, fixed_t vsca patchdrawfunc = standardpdraw; v_translevel = NULL; - if (alphalevel) + if (alphalevel || blendmode) { if (alphalevel == 10) alphalevel = hudminusalpha[st_translucency]; @@ -551,15 +551,13 @@ void V_DrawStretchyFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, fixed_t vsca if (alphalevel >= 10) return; // invis - if (alphalevel) - { - if (blendmode) - v_translevel = R_GetBlendTable(blendmode+1, alphalevel); - else - v_translevel = R_GetTranslucencyTable(alphalevel); + if (blendmode) + v_translevel = R_GetBlendTable(blendmode+1, alphalevel); + else if (alphalevel) + v_translevel = R_GetTranslucencyTable(alphalevel); + if (v_translevel) patchdrawfunc = translucentpdraw; - } } v_colormap = NULL; @@ -833,7 +831,7 @@ void V_DrawCroppedPatch(fixed_t x, fixed_t y, fixed_t pscale, fixed_t vscale, IN patchdrawfunc = standardpdraw; v_translevel = NULL; - if (alphalevel) + if (alphalevel || blendmode) { if (alphalevel == 10) alphalevel = hudminusalpha[st_translucency]; @@ -845,15 +843,13 @@ void V_DrawCroppedPatch(fixed_t x, fixed_t y, fixed_t pscale, fixed_t vscale, IN if (alphalevel >= 10) return; // invis - if (alphalevel) - { - if (blendmode) - v_translevel = R_GetBlendTable(blendmode+1, alphalevel); - else - v_translevel = R_GetTranslucencyTable(alphalevel); + if (blendmode) + v_translevel = R_GetBlendTable(blendmode+1, alphalevel); + else if (alphalevel) + v_translevel = R_GetTranslucencyTable(alphalevel); + if (v_translevel) patchdrawfunc = translucentpdraw; - } } v_colormap = NULL; From 15755ef992de4b44fc5a18d3b0e5ebf6e151c7e5 Mon Sep 17 00:00:00 2001 From: spherallic Date: Wed, 19 Jan 2022 13:17:57 +0100 Subject: [PATCH 1044/1080] Remove unneeded R_GetTranslucencyTable calls, add V_HUDTRANS* comments --- src/hardware/hw_draw.c | 22 ++++++++-------------- src/v_video.c | 34 +++++++++++++++------------------- 2 files changed, 23 insertions(+), 33 deletions(-) diff --git a/src/hardware/hw_draw.c b/src/hardware/hw_draw.c index e02dbea5b..02697789e 100644 --- a/src/hardware/hw_draw.c +++ b/src/hardware/hw_draw.c @@ -347,19 +347,16 @@ void HWR_DrawStretchyFixedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t p v[2].t = v[3].t = hwrPatch->max_t; // clip it since it is used for bunny scroll in doom I - if (blendmode) - flags = HWR_GetBlendModeFlag(blendmode+1)|PF_NoDepthTest; - else - flags = PF_Translucent|PF_NoDepthTest; + flags = HWR_GetBlendModeFlag(blendmode+1)|PF_NoDepthTest; if (alphalevel) { FSurfaceInfo Surf; Surf.PolyColor.s.red = Surf.PolyColor.s.green = Surf.PolyColor.s.blue = 0xff; - if (alphalevel == 10) Surf.PolyColor.s.alpha = softwaretranstogl_lo[st_translucency]; - else if (alphalevel == 11) Surf.PolyColor.s.alpha = softwaretranstogl[st_translucency]; - else if (alphalevel == 12) Surf.PolyColor.s.alpha = softwaretranstogl_hi[st_translucency]; + if (alphalevel == 10) Surf.PolyColor.s.alpha = softwaretranstogl_lo[st_translucency]; // V_HUDTRANSHALF + else if (alphalevel == 11) Surf.PolyColor.s.alpha = softwaretranstogl[st_translucency]; // V_HUDTRANS + else if (alphalevel == 12) Surf.PolyColor.s.alpha = softwaretranstogl_hi[st_translucency]; // V_HUDTRANSDOUBLE else Surf.PolyColor.s.alpha = softwaretranstogl[10-alphalevel]; flags |= PF_Modulated; HWD.pfnDrawPolygon(&Surf, v, 4, flags); @@ -644,19 +641,16 @@ 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 (blendmode) - flags = HWR_GetBlendModeFlag(blendmode+1)|PF_NoDepthTest; - else - flags = PF_Translucent|PF_NoDepthTest; + flags = HWR_GetBlendModeFlag(blendmode+1)|PF_NoDepthTest; if (alphalevel) { FSurfaceInfo Surf; Surf.PolyColor.s.red = Surf.PolyColor.s.green = Surf.PolyColor.s.blue = 0xff; - if (alphalevel == 10) Surf.PolyColor.s.alpha = softwaretranstogl_lo[st_translucency]; - else if (alphalevel == 11) Surf.PolyColor.s.alpha = softwaretranstogl[st_translucency]; - else if (alphalevel == 12) Surf.PolyColor.s.alpha = softwaretranstogl_hi[st_translucency]; + if (alphalevel == 10) Surf.PolyColor.s.alpha = softwaretranstogl_lo[st_translucency]; // V_HUDTRANSHALF + else if (alphalevel == 11) Surf.PolyColor.s.alpha = softwaretranstogl[st_translucency]; // V_HUDTRANS + else if (alphalevel == 12) Surf.PolyColor.s.alpha = softwaretranstogl_hi[st_translucency]; // V_HUDTRANSDOUBLE else Surf.PolyColor.s.alpha = softwaretranstogl[10-alphalevel]; flags |= PF_Modulated; diff --git a/src/v_video.c b/src/v_video.c index 49601ad78..4e17a4497 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -541,23 +541,21 @@ void V_DrawStretchyFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, fixed_t vsca v_translevel = NULL; if (alphalevel || blendmode) { - if (alphalevel == 10) + if (alphalevel == 10) // V_HUDTRANSHALF alphalevel = hudminusalpha[st_translucency]; - else if (alphalevel == 11) + else if (alphalevel == 11) // V_HUDTRANS alphalevel = 10 - st_translucency; - else if (alphalevel == 12) + else if (alphalevel == 12) // V_HUDTRANSDOUBLE alphalevel = hudplusalpha[st_translucency]; if (alphalevel >= 10) return; // invis - if (blendmode) + if (alphalevel || blendmode) + { v_translevel = R_GetBlendTable(blendmode+1, alphalevel); - else if (alphalevel) - v_translevel = R_GetTranslucencyTable(alphalevel); - - if (v_translevel) patchdrawfunc = translucentpdraw; + } } v_colormap = NULL; @@ -833,23 +831,21 @@ void V_DrawCroppedPatch(fixed_t x, fixed_t y, fixed_t pscale, fixed_t vscale, IN v_translevel = NULL; if (alphalevel || blendmode) { - if (alphalevel == 10) + if (alphalevel == 10) // V_HUDTRANSHALF alphalevel = hudminusalpha[st_translucency]; - else if (alphalevel == 11) + else if (alphalevel == 11) // V_HUDTRANS alphalevel = 10 - st_translucency; - else if (alphalevel == 12) + else if (alphalevel == 12) // V_HUDTRANSDOUBLE alphalevel = hudplusalpha[st_translucency]; if (alphalevel >= 10) return; // invis - if (blendmode) + if (alphalevel || blendmode) + { v_translevel = R_GetBlendTable(blendmode+1, alphalevel); - else if (alphalevel) - v_translevel = R_GetTranslucencyTable(alphalevel); - - if (v_translevel) patchdrawfunc = translucentpdraw; + } } v_colormap = NULL; @@ -1406,11 +1402,11 @@ void V_DrawFillConsoleMap(INT32 x, INT32 y, INT32 w, INT32 h, INT32 c) if ((alphalevel = ((c & V_ALPHAMASK) >> V_ALPHASHIFT))) { - if (alphalevel == 10) + if (alphalevel == 10) // V_HUDTRANSHALF alphalevel = hudminusalpha[st_translucency]; - else if (alphalevel == 11) + else if (alphalevel == 11) // V_HUDTRANS alphalevel = 10 - st_translucency; - else if (alphalevel == 12) + else if (alphalevel == 12) // V_HUDTRANSDOUBLE alphalevel = hudplusalpha[st_translucency]; if (alphalevel >= 10) From 6d19a55de937a6a57a74e0b4e12ed6f98df3e919 Mon Sep 17 00:00:00 2001 From: spherallic Date: Sun, 23 Jan 2022 19:19:26 +0100 Subject: [PATCH 1045/1080] oops --- src/p_enemy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_enemy.c b/src/p_enemy.c index c7b3673d6..33692ba98 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -9326,7 +9326,7 @@ void A_StateRangeByParameter(mobj_t *actor) INT32 locvar2 = var2; UINT8 parameter = (actor->spawnpoint ? actor->spawnpoint->extrainfo : 0); - if (LUA_CallAction(A_STATERANGEBYANGLE, actor)) + if (LUA_CallAction(A_STATERANGEBYPARAMETER, actor)) return; if (locvar2 - locvar1 < 0) From be7f628e2cd750e4653296a3bd828a3fadc9f008 Mon Sep 17 00:00:00 2001 From: spherallic Date: Sun, 23 Jan 2022 20:13:26 +0100 Subject: [PATCH 1046/1080] Add new plant object for the revamped tutorial. --- extras/conf/SRB2-22.cfg | 13 ++++ src/deh_tables.c | 56 ++++++++++++++ src/info.c | 162 ++++++++++++++++++++++++++++++++++++++++ src/info.h | 60 +++++++++++++++ src/p_mobj.c | 22 ++++++ 5 files changed, 313 insertions(+) diff --git a/extras/conf/SRB2-22.cfg b/extras/conf/SRB2-22.cfg index b780ff75f..f9595e868 100644 --- a/extras/conf/SRB2-22.cfg +++ b/extras/conf/SRB2-22.cfg @@ -6880,6 +6880,19 @@ thingtypes } } + tutorial + { + color = 10; // Green + title = "Tutorial"; + + 799 + { + title = "Tutorial Plant"; + sprite = "TUPFH0"; + width = 32; + height = 144; + } + flickies { color = 10; // Green diff --git a/src/deh_tables.c b/src/deh_tables.c index 73da7313a..85fdd41d4 100644 --- a/src/deh_tables.c +++ b/src/deh_tables.c @@ -1753,6 +1753,56 @@ const char *const STATE_LIST[] = { // array length left dynamic for sanity testi // The letter "S_LETTER", + // Tutorial Scenery + "S_TUTORIALLEAF1", + "S_TUTORIALLEAF2", + "S_TUTORIALLEAF3", + "S_TUTORIALLEAF4", + "S_TUTORIALLEAF5", + "S_TUTORIALLEAF6", + "S_TUTORIALLEAF7", + "S_TUTORIALLEAF8", + "S_TUTORIALLEAF9", + "S_TUTORIALLEAF10", + "S_TUTORIALLEAF11", + "S_TUTORIALLEAF12", + "S_TUTORIALLEAF13", + "S_TUTORIALLEAF14", + "S_TUTORIALLEAF15", + "S_TUTORIALLEAF16", + "S_TUTORIALFLOWER1", + "S_TUTORIALFLOWER2", + "S_TUTORIALFLOWER3", + "S_TUTORIALFLOWER4", + "S_TUTORIALFLOWER5", + "S_TUTORIALFLOWER6", + "S_TUTORIALFLOWER7", + "S_TUTORIALFLOWER8", + "S_TUTORIALFLOWER9", + "S_TUTORIALFLOWER10", + "S_TUTORIALFLOWER11", + "S_TUTORIALFLOWER12", + "S_TUTORIALFLOWER13", + "S_TUTORIALFLOWER14", + "S_TUTORIALFLOWER15", + "S_TUTORIALFLOWER16", + "S_TUTORIALFLOWERF1", + "S_TUTORIALFLOWERF2", + "S_TUTORIALFLOWERF3", + "S_TUTORIALFLOWERF4", + "S_TUTORIALFLOWERF5", + "S_TUTORIALFLOWERF6", + "S_TUTORIALFLOWERF7", + "S_TUTORIALFLOWERF8", + "S_TUTORIALFLOWERF9", + "S_TUTORIALFLOWERF10", + "S_TUTORIALFLOWERF11", + "S_TUTORIALFLOWERF12", + "S_TUTORIALFLOWERF13", + "S_TUTORIALFLOWERF14", + "S_TUTORIALFLOWERF15", + "S_TUTORIALFLOWERF16", + // GFZ flowers "S_GFZFLOWERA", "S_GFZFLOWERB", @@ -3765,6 +3815,12 @@ const char *const MOBJTYPE_LIST[] = { // array length left dynamic for sanity t // The letter "MT_LETTER", + // Tutorial Scenery + "MT_TUTORIALPLANT", + "MT_TUTORIALLEAF", + "MT_TUTORIALFLOWER", + "MT_TUTORIALFLOWERF", + // Greenflower Scenery "MT_GFZFLOWER1", "MT_GFZFLOWER2", diff --git a/src/info.c b/src/info.c index 331e114b6..98fc5b7d4 100644 --- a/src/info.c +++ b/src/info.c @@ -203,6 +203,10 @@ char sprnames[NUMSPRITES + 1][5] = // The letter "LETR", + // Tutorial Scenery + "TUPL", + "TUPF", + // Greenflower Scenery "FWR1", "FWR2", // GFZ Sunflower @@ -2117,6 +2121,56 @@ state_t states[NUMSTATES] = {SPR_LETR, FF_PAPERSPRITE, -1, {NULL}, 0, 0, S_NULL}, // S_LETTER + // Tutorial scenery + {SPR_TUPL, FF_SEMIBRIGHT|FF_ADD|FF_PAPERSPRITE|0, 3, {NULL}, 0, 0, S_TUTORIALLEAF2}, // S_TUTORIALLEAF1 + {SPR_TUPL, FF_SEMIBRIGHT|FF_ADD|FF_PAPERSPRITE|1, 3, {NULL}, 0, 0, S_TUTORIALLEAF3}, // S_TUTORIALLEAF2 + {SPR_TUPL, FF_SEMIBRIGHT|FF_ADD|FF_PAPERSPRITE|2, 3, {NULL}, 0, 0, S_TUTORIALLEAF4}, // S_TUTORIALLEAF3 + {SPR_TUPL, FF_SEMIBRIGHT|FF_ADD|FF_PAPERSPRITE|3, 3, {NULL}, 0, 0, S_TUTORIALLEAF5}, // S_TUTORIALLEAF4 + {SPR_TUPL, FF_SEMIBRIGHT|FF_ADD|FF_PAPERSPRITE|4, 3, {NULL}, 0, 0, S_TUTORIALLEAF6}, // S_TUTORIALLEAF5 + {SPR_TUPL, FF_SEMIBRIGHT|FF_ADD|FF_PAPERSPRITE|5, 3, {NULL}, 0, 0, S_TUTORIALLEAF7}, // S_TUTORIALLEAF6 + {SPR_TUPL, FF_SEMIBRIGHT|FF_ADD|FF_PAPERSPRITE|6, 3, {NULL}, 0, 0, S_TUTORIALLEAF8}, // S_TUTORIALLEAF7 + {SPR_TUPL, FF_SEMIBRIGHT|FF_ADD|FF_PAPERSPRITE|7, 3, {NULL}, 0, 0, S_TUTORIALLEAF9}, // S_TUTORIALLEAF8 + {SPR_TUPL, FF_SEMIBRIGHT|FF_ADD|FF_PAPERSPRITE|7, 3, {NULL}, 0, 0, S_TUTORIALLEAF10}, // S_TUTORIALLEAF9 + {SPR_TUPL, FF_SEMIBRIGHT|FF_ADD|FF_PAPERSPRITE|6, 3, {NULL}, 0, 0, S_TUTORIALLEAF11}, // S_TUTORIALLEAF10 + {SPR_TUPL, FF_SEMIBRIGHT|FF_ADD|FF_PAPERSPRITE|5, 3, {NULL}, 0, 0, S_TUTORIALLEAF12}, // S_TUTORIALLEAF11 + {SPR_TUPL, FF_SEMIBRIGHT|FF_ADD|FF_PAPERSPRITE|4, 3, {NULL}, 0, 0, S_TUTORIALLEAF13}, // S_TUTORIALLEAF12 + {SPR_TUPL, FF_SEMIBRIGHT|FF_ADD|FF_PAPERSPRITE|3, 3, {NULL}, 0, 0, S_TUTORIALLEAF14}, // S_TUTORIALLEAF13 + {SPR_TUPL, FF_SEMIBRIGHT|FF_ADD|FF_PAPERSPRITE|2, 3, {NULL}, 0, 0, S_TUTORIALLEAF15}, // S_TUTORIALLEAF14 + {SPR_TUPL, FF_SEMIBRIGHT|FF_ADD|FF_PAPERSPRITE|1, 3, {NULL}, 0, 0, S_TUTORIALLEAF16}, // S_TUTORIALLEAF15 + {SPR_TUPL, FF_SEMIBRIGHT|FF_ADD|FF_PAPERSPRITE|0, 3, {NULL}, 0, 0, S_TUTORIALLEAF1}, // S_TUTORIALLEAF16 + {SPR_TUPF, FF_SEMIBRIGHT|FF_ADD|FF_PAPERSPRITE|0, 3, {NULL}, 0, 0, S_TUTORIALFLOWER2}, // S_TUTORIALFLOWER1 + {SPR_TUPF, FF_SEMIBRIGHT|FF_ADD|FF_PAPERSPRITE|1, 3, {NULL}, 0, 0, S_TUTORIALFLOWER3}, // S_TUTORIALFLOWER2 + {SPR_TUPF, FF_SEMIBRIGHT|FF_ADD|FF_PAPERSPRITE|2, 3, {NULL}, 0, 0, S_TUTORIALFLOWER4}, // S_TUTORIALFLOWER3 + {SPR_TUPF, FF_SEMIBRIGHT|FF_ADD|FF_PAPERSPRITE|3, 3, {NULL}, 0, 0, S_TUTORIALFLOWER5}, // S_TUTORIALFLOWER4 + {SPR_TUPF, FF_SEMIBRIGHT|FF_ADD|FF_PAPERSPRITE|4, 3, {NULL}, 0, 0, S_TUTORIALFLOWER6}, // S_TUTORIALFLOWER5 + {SPR_TUPF, FF_SEMIBRIGHT|FF_ADD|FF_PAPERSPRITE|5, 3, {NULL}, 0, 0, S_TUTORIALFLOWER7}, // S_TUTORIALFLOWER6 + {SPR_TUPF, FF_SEMIBRIGHT|FF_ADD|FF_PAPERSPRITE|6, 3, {NULL}, 0, 0, S_TUTORIALFLOWER8}, // S_TUTORIALFLOWER7 + {SPR_TUPF, FF_SEMIBRIGHT|FF_ADD|FF_PAPERSPRITE|7, 3, {NULL}, 0, 0, S_TUTORIALFLOWER9}, // S_TUTORIALFLOWER8 + {SPR_TUPF, FF_SEMIBRIGHT|FF_ADD|FF_PAPERSPRITE|7, 3, {NULL}, 0, 0, S_TUTORIALFLOWER10}, // S_TUTORIALFLOWER9 + {SPR_TUPF, FF_SEMIBRIGHT|FF_ADD|FF_PAPERSPRITE|6, 3, {NULL}, 0, 0, S_TUTORIALFLOWER11}, // S_TUTORIALFLOWER10 + {SPR_TUPF, FF_SEMIBRIGHT|FF_ADD|FF_PAPERSPRITE|5, 3, {NULL}, 0, 0, S_TUTORIALFLOWER12}, // S_TUTORIALFLOWER11 + {SPR_TUPF, FF_SEMIBRIGHT|FF_ADD|FF_PAPERSPRITE|4, 3, {NULL}, 0, 0, S_TUTORIALFLOWER13}, // S_TUTORIALFLOWER12 + {SPR_TUPF, FF_SEMIBRIGHT|FF_ADD|FF_PAPERSPRITE|3, 3, {NULL}, 0, 0, S_TUTORIALFLOWER14}, // S_TUTORIALFLOWER13 + {SPR_TUPF, FF_SEMIBRIGHT|FF_ADD|FF_PAPERSPRITE|2, 3, {NULL}, 0, 0, S_TUTORIALFLOWER15}, // S_TUTORIALFLOWER14 + {SPR_TUPF, FF_SEMIBRIGHT|FF_ADD|FF_PAPERSPRITE|1, 3, {NULL}, 0, 0, S_TUTORIALFLOWER16}, // S_TUTORIALFLOWER15 + {SPR_TUPF, FF_SEMIBRIGHT|FF_ADD|FF_PAPERSPRITE|0, 3, {NULL}, 0, 0, S_TUTORIALFLOWER1}, // S_TUTORIALFLOWER16 + {SPR_TUPF, FF_SEMIBRIGHT|FF_ADD|FF_FLOORSPRITE|0, 3, {NULL}, 0, 0, S_TUTORIALFLOWERF2}, // S_TUTORIALFLOWERF1 + {SPR_TUPF, FF_SEMIBRIGHT|FF_ADD|FF_FLOORSPRITE|1, 3, {NULL}, 0, 0, S_TUTORIALFLOWERF3}, // S_TUTORIALFLOWERF2 + {SPR_TUPF, FF_SEMIBRIGHT|FF_ADD|FF_FLOORSPRITE|2, 3, {NULL}, 0, 0, S_TUTORIALFLOWERF4}, // S_TUTORIALFLOWERF3 + {SPR_TUPF, FF_SEMIBRIGHT|FF_ADD|FF_FLOORSPRITE|3, 3, {NULL}, 0, 0, S_TUTORIALFLOWERF5}, // S_TUTORIALFLOWERF4 + {SPR_TUPF, FF_SEMIBRIGHT|FF_ADD|FF_FLOORSPRITE|4, 3, {NULL}, 0, 0, S_TUTORIALFLOWERF6}, // S_TUTORIALFLOWERF5 + {SPR_TUPF, FF_SEMIBRIGHT|FF_ADD|FF_FLOORSPRITE|5, 3, {NULL}, 0, 0, S_TUTORIALFLOWERF7}, // S_TUTORIALFLOWERF6 + {SPR_TUPF, FF_SEMIBRIGHT|FF_ADD|FF_FLOORSPRITE|6, 3, {NULL}, 0, 0, S_TUTORIALFLOWERF8}, // S_TUTORIALFLOWERF7 + {SPR_TUPF, FF_SEMIBRIGHT|FF_ADD|FF_FLOORSPRITE|7, 3, {NULL}, 0, 0, S_TUTORIALFLOWERF9}, // S_TUTORIALFLOWERF8 + {SPR_TUPF, FF_SEMIBRIGHT|FF_ADD|FF_FLOORSPRITE|7, 3, {NULL}, 0, 0, S_TUTORIALFLOWERF10}, // S_TUTORIALFLOWERF9 + {SPR_TUPF, FF_SEMIBRIGHT|FF_ADD|FF_FLOORSPRITE|6, 3, {NULL}, 0, 0, S_TUTORIALFLOWERF11}, // S_TUTORIALFLOWERF10 + {SPR_TUPF, FF_SEMIBRIGHT|FF_ADD|FF_FLOORSPRITE|5, 3, {NULL}, 0, 0, S_TUTORIALFLOWERF12}, // S_TUTORIALFLOWERF11 + {SPR_TUPF, FF_SEMIBRIGHT|FF_ADD|FF_FLOORSPRITE|4, 3, {NULL}, 0, 0, S_TUTORIALFLOWERF13}, // S_TUTORIALFLOWERF12 + {SPR_TUPF, FF_SEMIBRIGHT|FF_ADD|FF_FLOORSPRITE|3, 3, {NULL}, 0, 0, S_TUTORIALFLOWERF14}, // S_TUTORIALFLOWERF13 + {SPR_TUPF, FF_SEMIBRIGHT|FF_ADD|FF_FLOORSPRITE|2, 3, {NULL}, 0, 0, S_TUTORIALFLOWERF15}, // S_TUTORIALFLOWERF14 + {SPR_TUPF, FF_SEMIBRIGHT|FF_ADD|FF_FLOORSPRITE|1, 3, {NULL}, 0, 0, S_TUTORIALFLOWERF16}, // S_TUTORIALFLOWERF15 + {SPR_TUPF, FF_SEMIBRIGHT|FF_ADD|FF_FLOORSPRITE|0, 3, {NULL}, 0, 0, S_TUTORIALFLOWERF1}, // S_TUTORIALFLOWERF16 + // GFZ flowers {SPR_FWR1, FF_ANIMATE, -1, {NULL}, 7, 3, S_NULL}, // S_GFZFLOWERA {SPR_FWR2, FF_ANIMATE, -1, {NULL}, 19, 3, S_NULL}, // S_GFZFLOWERB @@ -9979,6 +10033,114 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = S_NULL // raisestate }, + { // MT_TUTORIALPLANT + 799, // doomednum + S_NULL, // spawnstate + 1000, // spawnhealth + S_NULL, // seestate + sfx_None, // seesound + 8, // reactiontime + sfx_None, // attacksound + S_NULL, // painstate + 0, // painchance + sfx_None, // painsound + S_NULL, // meleestate + S_NULL, // missilestate + S_NULL, // deathstate + S_NULL, // xdeathstate + sfx_None, // deathsound + 0, // speed + 32*FRACUNIT, // radius + 32*FRACUNIT, // height + 0, // display offset + 100, // mass + 0, // damage + sfx_None, // activesound + MF_NOBLOCKMAP|MF_NOCLIP|MF_NOGRAVITY|MF_SCENERY, // flags + S_NULL // raisestate + }, + + { // MT_TUTORIALLEAF + -1, // doomednum + S_TUTORIALLEAF1, // spawnstate + 1000, // spawnhealth + S_NULL, // seestate + sfx_None, // seesound + 8, // reactiontime + sfx_None, // attacksound + S_NULL, // painstate + 0, // painchance + sfx_None, // painsound + S_NULL, // meleestate + S_NULL, // missilestate + S_NULL, // deathstate + S_NULL, // xdeathstate + sfx_None, // deathsound + 0, // speed + 32*FRACUNIT, // radius + 32*FRACUNIT, // height + 0, // display offset + 100, // mass + 0, // damage + sfx_None, // activesound + MF_NOBLOCKMAP|MF_NOCLIP|MF_NOGRAVITY|MF_SCENERY, // flags + S_NULL // raisestate + }, + + { // MT_TUTORIALFLOWER + -1, // doomednum + S_TUTORIALFLOWER1, // spawnstate + 1000, // spawnhealth + S_NULL, // seestate + sfx_None, // seesound + 8, // reactiontime + sfx_None, // attacksound + S_NULL, // painstate + 0, // painchance + sfx_None, // painsound + S_NULL, // meleestate + S_NULL, // missilestate + S_NULL, // deathstate + S_NULL, // xdeathstate + sfx_None, // deathsound + 0, // speed + 32*FRACUNIT, // radius + 32*FRACUNIT, // height + 0, // display offset + 100, // mass + 0, // damage + sfx_None, // activesound + MF_NOBLOCKMAP|MF_NOCLIP|MF_NOGRAVITY|MF_SCENERY, // flags + S_NULL // raisestate + }, + + { // MT_TUTORIALFLOWERF + -1, // doomednum + S_TUTORIALFLOWERF1, // spawnstate + 1000, // spawnhealth + S_NULL, // seestate + sfx_None, // seesound + 8, // reactiontime + sfx_None, // attacksound + S_NULL, // painstate + 0, // painchance + sfx_None, // painsound + S_NULL, // meleestate + S_NULL, // missilestate + S_NULL, // deathstate + S_NULL, // xdeathstate + sfx_None, // deathsound + 0, // speed + 32*FRACUNIT, // radius + 32*FRACUNIT, // height + 0, // display offset + 100, // mass + 0, // damage + sfx_None, // activesound + MF_NOBLOCKMAP|MF_NOCLIP|MF_NOGRAVITY|MF_SCENERY, // flags + S_NULL // raisestate + }, + { // MT_GFZFLOWER1 800, // doomednum S_GFZFLOWERA, // spawnstate diff --git a/src/info.h b/src/info.h index a0e141606..9b67e29cd 100644 --- a/src/info.h +++ b/src/info.h @@ -741,6 +741,10 @@ typedef enum sprite // The letter SPR_LETR, + // Tutorial scenery + SPR_TUPL, + SPR_TUPF, + // Greenflower Scenery SPR_FWR1, SPR_FWR2, // GFZ Sunflower @@ -2555,6 +2559,56 @@ typedef enum state // The letter S_LETTER, + // Tutorial scenery + S_TUTORIALLEAF1, + S_TUTORIALLEAF2, + S_TUTORIALLEAF3, + S_TUTORIALLEAF4, + S_TUTORIALLEAF5, + S_TUTORIALLEAF6, + S_TUTORIALLEAF7, + S_TUTORIALLEAF8, + S_TUTORIALLEAF9, + S_TUTORIALLEAF10, + S_TUTORIALLEAF11, + S_TUTORIALLEAF12, + S_TUTORIALLEAF13, + S_TUTORIALLEAF14, + S_TUTORIALLEAF15, + S_TUTORIALLEAF16, + S_TUTORIALFLOWER1, + S_TUTORIALFLOWER2, + S_TUTORIALFLOWER3, + S_TUTORIALFLOWER4, + S_TUTORIALFLOWER5, + S_TUTORIALFLOWER6, + S_TUTORIALFLOWER7, + S_TUTORIALFLOWER8, + S_TUTORIALFLOWER9, + S_TUTORIALFLOWER10, + S_TUTORIALFLOWER11, + S_TUTORIALFLOWER12, + S_TUTORIALFLOWER13, + S_TUTORIALFLOWER14, + S_TUTORIALFLOWER15, + S_TUTORIALFLOWER16, + S_TUTORIALFLOWERF1, + S_TUTORIALFLOWERF2, + S_TUTORIALFLOWERF3, + S_TUTORIALFLOWERF4, + S_TUTORIALFLOWERF5, + S_TUTORIALFLOWERF6, + S_TUTORIALFLOWERF7, + S_TUTORIALFLOWERF8, + S_TUTORIALFLOWERF9, + S_TUTORIALFLOWERF10, + S_TUTORIALFLOWERF11, + S_TUTORIALFLOWERF12, + S_TUTORIALFLOWERF13, + S_TUTORIALFLOWERF14, + S_TUTORIALFLOWERF15, + S_TUTORIALFLOWERF16, + // GFZ flowers S_GFZFLOWERA, S_GFZFLOWERB, @@ -4587,6 +4641,12 @@ typedef enum mobj_type // The letter MT_LETTER, + // Tutorial Scenery + MT_TUTORIALPLANT, + MT_TUTORIALLEAF, + MT_TUTORIALFLOWER, + MT_TUTORIALFLOWERF, + // Greenflower Scenery MT_GFZFLOWER1, MT_GFZFLOWER2, diff --git a/src/p_mobj.c b/src/p_mobj.c index 87e20fd4a..25e78d67b 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -7978,6 +7978,9 @@ static void P_MobjSceneryThink(mobj_t *mobj) P_SetScale(mobj, mobj->target->scale); } break; + case MT_TUTORIALFLOWER: + mobj->angle += FixedAngle(3*FRACUNIT); + break; case MT_VWREF: case MT_VWREB: { @@ -12827,6 +12830,25 @@ static boolean P_SetupSpawnedMapThing(mapthing_t *mthing, mobj_t *mobj, boolean P_SpawnMobjFromMobj(mobj, -FRACUNIT, 0, 0, MT_THZTREEBRANCH)->angle = mobjangle + ANGLE_270; } break; + case MT_TUTORIALPLANT: + { + INT32 i; + mobj_t *segment; + for (i = 0; i < 6; i++) + { + segment = P_SpawnMobjFromMobj(mobj, 0, 0, 0, MT_TUTORIALLEAF); + segment->angle = mobj->angle + FixedAngle(i*60*FRACUNIT); + P_SetMobjState(segment, S_TUTORIALLEAF1 + mthing->extrainfo); + } + for (i = 0; i < 3; i++) + { + segment = P_SpawnMobjFromMobj(mobj, 0, 0, 112*FRACUNIT, MT_TUTORIALFLOWER); + segment->angle = mobj->angle + FixedAngle(i*120*FRACUNIT); + P_SetMobjState(segment, S_TUTORIALFLOWER1 + mthing->extrainfo); + } + P_SetMobjState(P_SpawnMobjFromMobj(mobj, 0, 0, 112*FRACUNIT, MT_TUTORIALFLOWERF), S_TUTORIALFLOWERF1 + mthing->extrainfo); + } + break; case MT_CEZPOLE1: case MT_CEZPOLE2: { // Spawn the banner From cdef5a679b2ddb3cb86344a496932a6d3f2f76b7 Mon Sep 17 00:00:00 2001 From: spherallic Date: Sun, 23 Jan 2022 20:39:17 +0100 Subject: [PATCH 1047/1080] disable develop --- src/doomdef.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/doomdef.h b/src/doomdef.h index a5ee79cd3..7e7e35599 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -124,7 +124,7 @@ extern char logfilename[1024]; /* A mod name to further distinguish versions. */ #define SRB2APPLICATION "SRB2" -#define DEVELOP // Disable this for release builds to remove excessive cheat commands and enable MD5 checking and stuff, all in one go. :3 +//#define DEVELOP // Disable this for release builds to remove excessive cheat commands and enable MD5 checking and stuff, all in one go. :3 #ifdef DEVELOP #define VERSIONSTRING "Development EXE" #define VERSIONSTRING_RC "Development EXE" "\0" @@ -150,7 +150,7 @@ extern char logfilename[1024]; // Does this version require an added patch file? // Comment or uncomment this as necessary. -//#define USE_PATCH_DTA +#define USE_PATCH_DTA // Enforce a limit of loaded WAD files. //#define ENFORCE_WAD_LIMIT From c705067173d02ebd9215ebc87b1a449f0a8eabae Mon Sep 17 00:00:00 2001 From: spherallic Date: Mon, 24 Jan 2022 13:50:14 +0100 Subject: [PATCH 1048/1080] Update ZB configuration for the tutorial plant. --- extras/conf/SRB2-22.cfg | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/extras/conf/SRB2-22.cfg b/extras/conf/SRB2-22.cfg index f9595e868..02b20081a 100644 --- a/extras/conf/SRB2-22.cfg +++ b/extras/conf/SRB2-22.cfg @@ -6889,8 +6889,9 @@ thingtypes { title = "Tutorial Plant"; sprite = "TUPFH0"; - width = 32; + width = 40; height = 144; + parametertext = "Start frame"; } flickies From ba04b045e68252cec7b87a788ec253631a6aae27 Mon Sep 17 00:00:00 2001 From: Hannu Hanhi Date: Tue, 25 Jan 2022 04:53:09 +0200 Subject: [PATCH 1049/1080] Fix portals - Resetting portalcullsector fixes the major visual glitches - Using 32 bits for nummasks and i fixes crashes when rendering lots of portals --- src/r_main.c | 3 +-- src/r_portal.c | 1 + src/r_things.c | 4 ++-- src/r_things.h | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/r_main.c b/src/r_main.c index 8729b5dcb..e25d257c6 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -1450,7 +1450,7 @@ static void Mask_Post (maskcount_t* m) void R_RenderPlayerView(player_t *player) { - UINT8 nummasks = 1; + INT32 nummasks = 1; maskcount_t* masks = malloc(sizeof(maskcount_t)); if (cv_homremoval.value && player == &players[displayplayer]) // if this is display player 1 @@ -1515,7 +1515,6 @@ void R_RenderPlayerView(player_t *player) R_ClipSprites(drawsegs, NULL); PS_STOP_TIMING(ps_sw_spritecliptime); - // Add skybox portals caused by sky visplanes. if (cv_skybox.value && skyboxmo[0]) Portal_AddSkyboxPortals(); diff --git a/src/r_portal.c b/src/r_portal.c index 3026f4e4c..cba98db05 100644 --- a/src/r_portal.c +++ b/src/r_portal.c @@ -132,6 +132,7 @@ static portal_t* Portal_Add (const INT16 x1, const INT16 x2) void Portal_Remove (portal_t* portal) { + portalcullsector = NULL; portal_base = portal->next; Z_Free(portal->ceilingclip); Z_Free(portal->floorclip); diff --git a/src/r_things.c b/src/r_things.c index accd1e2b3..520f42688 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -3168,10 +3168,10 @@ static void R_DrawMaskedList (drawnode_t* head) } } -void R_DrawMasked(maskcount_t* masks, UINT8 nummasks) +void R_DrawMasked(maskcount_t* masks, INT32 nummasks) { drawnode_t *heads; /**< Drawnode lists; as many as number of views/portals. */ - SINT8 i; + INT32 i; heads = calloc(nummasks, sizeof(drawnode_t)); diff --git a/src/r_things.h b/src/r_things.h index b1ff32b1e..b4676fbbd 100644 --- a/src/r_things.h +++ b/src/r_things.h @@ -100,7 +100,7 @@ typedef struct sector_t* viewsector; } maskcount_t; -void R_DrawMasked(maskcount_t* masks, UINT8 nummasks); +void R_DrawMasked(maskcount_t* masks, INT32 nummasks); // ---------- // VISSPRITES From 89843d0eca6588dd37cbdf1aa42b1476ee4c47ae Mon Sep 17 00:00:00 2001 From: Hannu Hanhi Date: Tue, 25 Jan 2022 05:01:23 +0200 Subject: [PATCH 1050/1080] did not mean to remove this line --- src/r_main.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/r_main.c b/src/r_main.c index e25d257c6..0d6a74a3b 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -1515,6 +1515,7 @@ void R_RenderPlayerView(player_t *player) R_ClipSprites(drawsegs, NULL); PS_STOP_TIMING(ps_sw_spritecliptime); + // Add skybox portals caused by sky visplanes. if (cv_skybox.value && skyboxmo[0]) Portal_AddSkyboxPortals(); From 611054b6cd6d2cccb97adc2dae4b643fcaa1eb02 Mon Sep 17 00:00:00 2001 From: Hannu Hanhi Date: Sat, 29 Jan 2022 02:24:52 +0200 Subject: [PATCH 1051/1080] Fix perfstats failing to compile with NOHW=1 --- src/m_perfstats.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/m_perfstats.c b/src/m_perfstats.c index 439a9da1c..b11e0e26a 100644 --- a/src/m_perfstats.c +++ b/src/m_perfstats.c @@ -228,10 +228,13 @@ static boolean PS_IsLevelActive(void) // Is the row valid in the current context? static boolean PS_IsRowValid(perfstatrow_t *row) { - return !((row->flags & PS_LEVEL && !PS_IsLevelActive()) || - (row->flags & PS_SW && rendermode != render_soft) || - (row->flags & PS_HW && rendermode != render_opengl) || - (row->flags & PS_BATCHING && !cv_glbatching.value)); + return !((row->flags & PS_LEVEL && !PS_IsLevelActive()) + || (row->flags & PS_SW && rendermode != render_soft) + || (row->flags & PS_HW && rendermode != render_opengl) +#ifdef HWRENDER + || (row->flags & PS_BATCHING && !cv_glbatching.value) +#endif + ); } // Should the row be visible on the screen? From 0a0c17da7c793ec29e80c5bdaa66b02da0884078 Mon Sep 17 00:00:00 2001 From: James R Date: Tue, 1 Feb 2022 02:27:27 -0800 Subject: [PATCH 1052/1080] PARANOIA: I_Error if mobj hook is called with MT_NULL --- src/lua_hooklib.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/lua_hooklib.c b/src/lua_hooklib.c index 287a185bc..d5f1cf25e 100644 --- a/src/lua_hooklib.c +++ b/src/lua_hooklib.c @@ -347,6 +347,10 @@ static boolean prepare_mobj_hook int hook_type, mobjtype_t mobj_type ){ +#ifdef PARANOIA + if (mobj_type == MT_NULL) + I_Error("MT_NULL has been passed to a mobj hook\n"); +#endif return init_hook_type(hook, default_status, hook_type, mobj_type, NULL, mobj_hook_available(hook_type, mobj_type)); From f6f002e70b645982dddd83d6f831a601faa0fdae Mon Sep 17 00:00:00 2001 From: James R Date: Tue, 1 Feb 2022 02:42:33 -0800 Subject: [PATCH 1053/1080] A_LobShot: remove ??? MT_NULL spawning, not cool bro. --- src/p_enemy.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/p_enemy.c b/src/p_enemy.c index 3b1d0a7cd..9c226481e 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -2655,7 +2655,7 @@ void A_LobShot(mobj_t *actor) { INT32 locvar1 = var1; INT32 locvar2 = var2 >> 16; - mobj_t *shot, *hitspot; + mobj_t *shot; angle_t an; fixed_t z; fixed_t dist; @@ -2694,11 +2694,6 @@ void A_LobShot(mobj_t *actor) P_SetScale(shot, actor->scale); } - // Keep track of where it's going to land - hitspot = P_SpawnMobj(actor->target->x&(64*FRACUNIT-1), actor->target->y&(64*FRACUNIT-1), actor->target->subsector->sector->floorheight, MT_NULL); - hitspot->tics = airtime; - P_SetTarget(&shot->tracer, hitspot); - P_SetTarget(&shot->target, actor); // where it came from shot->angle = an = actor->angle; From 518de0ce104166c3eacd10ebe6ade422307ce671 Mon Sep 17 00:00:00 2001 From: James R Date: Tue, 1 Feb 2022 03:29:38 -0800 Subject: [PATCH 1054/1080] Add P_CheckMove Checks if P_TryMove would succeed without actually moving. --- src/deh_tables.c | 1 + src/info.c | 27 +++++++++++++++++++++++++++ src/info.h | 1 + src/p_local.h | 1 + src/p_map.c | 43 +++++++++++++++++++++++++++++++++++++------ 5 files changed, 67 insertions(+), 6 deletions(-) diff --git a/src/deh_tables.c b/src/deh_tables.c index cfc98f631..9db18be9b 100644 --- a/src/deh_tables.c +++ b/src/deh_tables.c @@ -3496,6 +3496,7 @@ const char *const STATE_LIST[] = { // array length left dynamic for sanity testi // because sadly no one remembers this place while searching for full state names. const char *const MOBJTYPE_LIST[] = { // array length left dynamic for sanity testing later. "MT_NULL", + "MT_RAY", "MT_UNKNOWN", "MT_THOK", // Thok! mobj diff --git a/src/info.c b/src/info.c index 57899f4f1..eaea5110a 100644 --- a/src/info.c +++ b/src/info.c @@ -3964,6 +3964,33 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = S_NULL // raisestate }, + { // MT_RAY + -1, // doomednum + S_NULL, // spawnstate + 0, // spawnhealth + S_NULL, // seestate + sfx_None, // seesound + 0, // reactiontime + sfx_None, // attacksound + S_NULL, // painstate + 0, // painchance + sfx_None, // painsound + S_NULL, // meleestate + S_NULL, // missilestate + S_NULL, // deathstate + S_NULL, // xdeathstate + sfx_None, // deathsound + 0, // speed + 0, // radius + 0, // height + 0, // display offset + 0, // mass + 0, // damage + sfx_None, // activesound + MF_NOBLOCKMAP|MF_NOSECTOR|MF_NOCLIP|MF_NOCLIPHEIGHT|MF_NOGRAVITY|MF_SCENERY, // flags + S_NULL // raisestate + }, + { // MT_UNKNOWN -1, // doomednum S_UNKNOWN, // spawnstate diff --git a/src/info.h b/src/info.h index 031a08b43..9ceeead2c 100644 --- a/src/info.h +++ b/src/info.h @@ -4316,6 +4316,7 @@ extern playersprite_t free_spr2; typedef enum mobj_type { MT_NULL, + MT_RAY, // General purpose mobj MT_UNKNOWN, MT_THOK, // Thok! mobj diff --git a/src/p_local.h b/src/p_local.h index 28a77afe5..4fa244a05 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -410,6 +410,7 @@ void P_SetUnderlayPosition(mobj_t *thing); boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y); boolean P_CheckCameraPosition(fixed_t x, fixed_t y, camera_t *thiscam); +boolean P_CheckMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff); boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff); boolean P_Move(mobj_t *actor, fixed_t speed); boolean P_TeleportMove(mobj_t *thing, fixed_t x, fixed_t y, fixed_t z); diff --git a/src/p_map.c b/src/p_map.c index 329224d0b..bd504ca17 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -2654,17 +2654,17 @@ boolean PIT_PushableMoved(mobj_t *thing) return true; } -// -// P_TryMove -// Attempt to move to a new position. -// -boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff) +static boolean +increment_move +( 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; - fixed_t startingonground = P_IsObjectOnGround(thing); floatok = false; if (radius < MAXRADIUS/2) @@ -2802,7 +2802,38 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff) } } while (tryx != x || tryy != y); + return true; +} + +// +// P_CheckMove +// Check if a P_TryMove would be successful. +// +boolean P_CheckMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff) +{ + boolean moveok; + mobj_t *hack = P_SpawnMobjFromMobj(thing, 0, 0, 0, MT_RAY); + + hack->radius = thing->radius; + hack->height = thing->height; + + moveok = increment_move(hack, x, y, allowdropoff); + P_RemoveMobj(hack); + + return moveok; +} + +// +// P_TryMove +// Attempt to move to a new position. +// +boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff) +{ + fixed_t startingonground = P_IsObjectOnGround(thing); + // The move is ok! + if (!increment_move(thing, x, y, allowdropoff)) + return false; // If it's a pushable object, check if anything is // standing on top and move it, too. From 9dfa153e7497403d874e980868b7aa6d15595286 Mon Sep 17 00:00:00 2001 From: James R Date: Tue, 1 Feb 2022 03:40:26 -0800 Subject: [PATCH 1055/1080] Use P_CheckMove --- src/p_enemy.c | 15 +++++---------- src/p_user.c | 15 ++++----------- 2 files changed, 9 insertions(+), 21 deletions(-) diff --git a/src/p_enemy.c b/src/p_enemy.c index 9c226481e..94c030d0f 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -3333,10 +3333,8 @@ void A_SkullAttack(mobj_t *actor) UINT32 oldflags = mobjinfo[MT_NULL].flags; fixed_t oldradius = mobjinfo[MT_NULL].radius; fixed_t oldheight = mobjinfo[MT_NULL].height; - mobj_t *check; INT32 i, j; static INT32 k;/* static for (at least) GCC 9.1 weirdness */ - boolean allow; angle_t testang = 0; mobjinfo[MT_NULL].spawnstate = S_INVISIBLE; @@ -3355,15 +3353,12 @@ void A_SkullAttack(mobj_t *actor) j = 9; } -#define dostuff(q) check = P_SpawnMobjFromMobj(actor, 0, 0, 0, MT_NULL);\ +#define dostuff(q) \ testang = actor->angle + ((i+(q))*ANG10);\ - allow = (P_TryMove(check,\ - P_ReturnThrustX(check, testang, dist + 2*actor->radius),\ - P_ReturnThrustY(check, testang, dist + 2*actor->radius),\ - true));\ - P_RemoveMobj(check);\ - if (allow)\ - break; + if (P_CheckMove(actor,\ + P_ReturnThrustX(actor, testang, dist + 2*actor->radius),\ + P_ReturnThrustY(actor, testang, dist + 2*actor->radius),\ + true)) break; if (P_RandomChance(FRACUNIT/2)) // port priority 2? { diff --git a/src/p_user.c b/src/p_user.c index 83eb4ea02..e1998cdff 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -6281,18 +6281,11 @@ static void P_NightsTransferPoints(player_t *player, fixed_t xspeed, fixed_t rad if (player->exiting) return; + if (!P_CheckMove(player->mo, + player->mo->x + player->mo->momx, + player->mo->y + player->mo->momy, true)) { - boolean notallowed; - mobj_t *hack = P_SpawnMobjFromMobj(player->mo, 0, 0, 0, MT_NULL); - hack->flags = MF_NOGRAVITY; - hack->radius = player->mo->radius; - hack->height = player->mo->height; - hack->z = player->mo->z; - P_SetThingPosition(hack); - notallowed = (!(P_TryMove(hack, player->mo->x+player->mo->momx, player->mo->y+player->mo->momy, true))); - P_RemoveMobj(hack); - if (notallowed) - return; + return; } { From 6325185091d852aae5fecb35b20d4341bd0ebfaf Mon Sep 17 00:00:00 2001 From: James R Date: Tue, 1 Feb 2022 03:51:01 -0800 Subject: [PATCH 1056/1080] Add P_SetPower; remove mobj hack from line 434 --- src/p_enemy.c | 8 +------- src/p_local.h | 1 + src/p_spec.c | 21 ++++++++------------- src/p_user.c | 18 ++++++++++++++++++ 4 files changed, 28 insertions(+), 20 deletions(-) diff --git a/src/p_enemy.c b/src/p_enemy.c index 94c030d0f..2e99436da 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -4179,7 +4179,6 @@ void A_CustomPower(mobj_t *actor) player_t *player; INT32 locvar1 = var1; INT32 locvar2 = var2; - boolean spawnshield = false; if (LUA_CallAction(A_CUSTOMPOWER, actor)) return; @@ -4198,15 +4197,10 @@ void A_CustomPower(mobj_t *actor) player = actor->target->player; - if (locvar1 == pw_shield && player->powers[pw_shield] != locvar2) - spawnshield = true; + P_SetPower(player, locvar1, locvar2); - player->powers[locvar1] = (UINT16)locvar2; if (actor->info->seesound) S_StartSound(player->mo, actor->info->seesound); - - if (spawnshield) //workaround for a bug - P_SpawnShieldOrb(player); } // Function: A_GiveWeapon diff --git a/src/p_local.h b/src/p_local.h index 4fa244a05..38c7f5d13 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -155,6 +155,7 @@ boolean P_PlayerHitFloor(player_t *player, boolean dorollstuff); void P_SetObjectMomZ(mobj_t *mo, fixed_t value, boolean relative); void P_RestoreMusic(player_t *player); +void P_SetPower(player_t *player, powertype_t power, UINT16 value); void P_SpawnShieldOrb(player_t *player); void P_SwitchShield(player_t *player, UINT16 shieldtype); mobj_t *P_SpawnGhostMobj(mobj_t *mobj); diff --git a/src/p_spec.c b/src/p_spec.c index ebabe6a79..459ee80a9 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -2888,25 +2888,20 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) case 434: // Custom Power if (mo && mo->player) { - mobj_t *dummy = P_SpawnMobj(mo->x, mo->y, mo->z, MT_NULL); - - var1 = sides[line->sidenum[0]].toptexture; //(line->dx>>FRACBITS)-1; + powertype_t power = sides[line->sidenum[0]].toptexture; //(line->dx>>FRACBITS)-1; + UINT16 value; if (line->sidenum[1] != 0xffff && line->flags & ML_BLOCKMONSTERS) // read power from back sidedef - var2 = sides[line->sidenum[1]].toptexture; + value = sides[line->sidenum[1]].toptexture; else if (line->flags & ML_NOCLIMB) // 'Infinite' - var2 = UINT16_MAX; + value = UINT16_MAX; else - var2 = sides[line->sidenum[0]].textureoffset>>FRACBITS; + value = sides[line->sidenum[0]].textureoffset>>FRACBITS; - P_SetTarget(&dummy->target, mo); - A_CustomPower(dummy); + P_SetPower(mo->player, power, value); - if (bot) { - P_SetTarget(&dummy->target, bot); - A_CustomPower(dummy); - } - P_RemoveMobj(dummy); + if (bot) + P_SetPower(bot->player, power, value); } break; diff --git a/src/p_user.c b/src/p_user.c index e1998cdff..a81d90905 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -2011,6 +2011,24 @@ void P_SwitchShield(player_t *player, UINT16 shieldtype) } } +// +// P_SetPower +// +// Sets a power and spawns a shield orb if required. +// +void P_SetPower(player_t *player, powertype_t power, UINT16 value) +{ + boolean spawnshield = false; + + if (power == pw_shield && player->powers[pw_shield] != value) + spawnshield = true; + + player->powers[power] = value; + + if (spawnshield) //workaround for a bug + P_SpawnShieldOrb(player); +} + // // P_SpawnGhostMobj // From a8c658b545e3c7709212a43489163f33ffbe91f0 Mon Sep 17 00:00:00 2001 From: James R Date: Tue, 1 Feb 2022 04:04:53 -0800 Subject: [PATCH 1057/1080] Never spawn MT_NULL --- src/p_mobj.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index 87e20fd4a..ca5c03ed0 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -10481,7 +10481,17 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type) const mobjinfo_t *info = &mobjinfo[type]; SINT8 sc = -1; state_t *st; - mobj_t *mobj = Z_Calloc(sizeof (*mobj), PU_LEVEL, NULL); + mobj_t *mobj; + + if (type == MT_NULL) + { +#ifdef PARANOIA + I_Error("Tried to spawn MT_NULL\n"); +#endif + return NULL; + } + + mobj = Z_Calloc(sizeof (*mobj), PU_LEVEL, NULL); // this is officially a mobj, declared as soon as possible. mobj->thinker.function.acp1 = (actionf_p1)P_MobjThinker; From e301327dee6339ff89d089c5633f171f066c6717 Mon Sep 17 00:00:00 2001 From: spherallic Date: Wed, 2 Feb 2022 12:15:14 +0100 Subject: [PATCH 1058/1080] Avoid using old explosion states for Jetty-Syn/Skim mines. --- src/info.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/info.c b/src/info.c index 57899f4f1..eed919b6c 100644 --- a/src/info.c +++ b/src/info.c @@ -9776,8 +9776,8 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = sfx_None, // painsound S_NULL, // meleestate S_NULL, // missilestate - S_MINE_BOOM1, // deathstate - S_MINE_BOOM1, // xdeathstate + S_XPLD1, // deathstate + S_XPLD1, // xdeathstate sfx_cybdth, // deathsound 0, // speed 8*FRACUNIT, // radius From 6e105a23f643c44e6986f5389e89b5a41476341e Mon Sep 17 00:00:00 2001 From: spherallic Date: Wed, 2 Feb 2022 14:43:22 +0100 Subject: [PATCH 1059/1080] Update Nightopian states for the new sprites & fix another bug --- src/deh_tables.c | 15 +++++++-------- src/info.c | 23 +++++++++++------------ src/info.h | 15 +++++++-------- 3 files changed, 25 insertions(+), 28 deletions(-) diff --git a/src/deh_tables.c b/src/deh_tables.c index cfc98f631..77b4b0f0f 100644 --- a/src/deh_tables.c +++ b/src/deh_tables.c @@ -3293,14 +3293,13 @@ const char *const STATE_LIST[] = { // array length left dynamic for sanity testi "S_NIGHTOPIANHELPER9", // Nightopian - "S_PIAN0", - "S_PIAN1", - "S_PIAN2", - "S_PIAN3", - "S_PIAN4", - "S_PIAN5", - "S_PIAN6", - "S_PIANSING", + "S_PIAN_LOOK1", + "S_PIAN_LOOK2", + "S_PIAN_LOOK3", + "S_PIAN_FLY1", + "S_PIAN_FLY2", + "S_PIAN_FLY3", + "S_PIAN_SING", // Shleep "S_SHLEEP1", diff --git a/src/info.c b/src/info.c index eed919b6c..a26cc2d86 100644 --- a/src/info.c +++ b/src/info.c @@ -3736,14 +3736,13 @@ state_t states[NUMSTATES] = {SPR_FL01, 3, 1, {A_OrbitNights}, ANG2*2, 180 | 0x10000, S_NIGHTOPIANHELPER1}, // S_NIGHTOPIANHELPER9 // Nightopian - {SPR_NTPN, 0, 4, {A_Look}, 0, 0, S_PIAN0}, // S_PIAN0 - {SPR_NTPN, 0, 4, {A_JetgThink}, 0, 0, S_PIAN2}, // S_PIAN1 - {SPR_NTPN, 1, 4, {NULL}, 0, 0, S_PIAN3}, // S_PIAN2 - {SPR_NTPN, 2, 4, {NULL}, 0, 0, S_PIAN4}, // S_PIAN3 - {SPR_NTPN, 3, 4, {NULL}, 0, 0, S_PIAN5}, // S_PIAN4 - {SPR_NTPN, 2, 4, {NULL}, 0, 0, S_PIAN6}, // S_PIAN5 - {SPR_NTPN, 1, 4, {NULL}, 0, 0, S_PIAN1}, // S_PIAN6 - {SPR_NTPN, 4|FF_ANIMATE, 24, {NULL}, 1, 4, S_PIAN1}, // S_PIANSING + {SPR_NTPN, 0, 2, {A_Look}, 1, 1, S_PIAN_LOOK2}, // S_PIAN_LOOK1 + {SPR_NTPN, 1, 2, {A_Look}, 1, 1, S_PIAN_LOOK3}, // S_PIAN_LOOK1 + {SPR_NTPN, 2, 2, {A_Look}, 1, 1, S_PIAN_LOOK1}, // S_PIAN_LOOK1 + {SPR_NTPN, 0, 2, {A_JetgThink}, 0, 0, S_PIAN_FLY2}, // S_PIAN_FLY1 + {SPR_NTPN, 1, 2, {NULL}, 0, 0, S_PIAN_FLY3}, // S_PIAN_FLY2 + {SPR_NTPN, 2, 2, {NULL}, 0, 0, S_PIAN_FLY1}, // S_PIAN_FLY3 + {SPR_NTPN, 3|FF_ANIMATE, 24, {NULL}, 2, 2, S_PIAN_FLY1}, // S_PIANSING // Shleep {SPR_SHLP, 0, 15, {NULL}, 0, 0, S_SHLEEP2}, // S_SHLEEP1 @@ -20119,9 +20118,9 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { // MT_PIAN 1602, // doomednum - S_PIAN0, // spawnstate + S_PIAN_LOOK1, // spawnstate 1000, // spawnhealth - S_PIAN1, // seestate + S_PIAN_FLY1, // seestate sfx_None, // seesound 0, // reactiontime sfx_None, // attacksound @@ -20129,7 +20128,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = 200, // painchance sfx_None, // painsound S_NULL, // meleestate - S_PIANSING, // missilestate + S_PIAN_SING, // missilestate S_NULL, // deathstate S_NULL, // xdeathstate sfx_None, // deathsound @@ -20140,7 +20139,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = 16, // mass 0, // damage sfx_None, // activesound - MF_SLIDEME|MF_SPECIAL|MF_NOGRAVITY, // flags + MF_SLIDEME|MF_NOGRAVITY, // flags S_NULL // raisestate }, diff --git a/src/info.h b/src/info.h index 031a08b43..4f7c962bf 100644 --- a/src/info.h +++ b/src/info.h @@ -4093,14 +4093,13 @@ typedef enum state S_NIGHTOPIANHELPER9, // Nightopian - S_PIAN0, - S_PIAN1, - S_PIAN2, - S_PIAN3, - S_PIAN4, - S_PIAN5, - S_PIAN6, - S_PIANSING, + S_PIAN_LOOK1, + S_PIAN_LOOK2, + S_PIAN_LOOK3, + S_PIAN_FLY1, + S_PIAN_FLY2, + S_PIAN_FLY3, + S_PIAN_SING, // Shleep S_SHLEEP1, From 878b4dc5b6025e1deef775ccb72b8a871833598a Mon Sep 17 00:00:00 2001 From: spherallic Date: Fri, 4 Feb 2022 20:09:37 +0100 Subject: [PATCH 1060/1080] Don't read or set MT_NULL's properties in A_SkullAttack --- src/p_enemy.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/p_enemy.c b/src/p_enemy.c index 2e99436da..0a3edc8bb 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -3329,18 +3329,18 @@ void A_SkullAttack(mobj_t *actor) actor->angle += (P_RandomChance(FRACUNIT/2)) ? ANGLE_90 : -ANGLE_90; else if (locvar1 == 3) { - statenum_t oldspawnstate = mobjinfo[MT_NULL].spawnstate; - UINT32 oldflags = mobjinfo[MT_NULL].flags; - fixed_t oldradius = mobjinfo[MT_NULL].radius; - fixed_t oldheight = mobjinfo[MT_NULL].height; + statenum_t oldspawnstate = mobjinfo[MT_RAY].spawnstate; + UINT32 oldflags = mobjinfo[MT_RAY].flags; + fixed_t oldradius = mobjinfo[MT_RAY].radius; + fixed_t oldheight = mobjinfo[MT_RAY].height; INT32 i, j; static INT32 k;/* static for (at least) GCC 9.1 weirdness */ angle_t testang = 0; - mobjinfo[MT_NULL].spawnstate = S_INVISIBLE; - mobjinfo[MT_NULL].flags = MF_NOGRAVITY|MF_NOTHINK|MF_NOCLIPTHING|MF_NOBLOCKMAP; - mobjinfo[MT_NULL].radius = mobjinfo[actor->type].radius; - mobjinfo[MT_NULL].height = mobjinfo[actor->type].height; + mobjinfo[MT_RAY].spawnstate = S_INVISIBLE; + mobjinfo[MT_RAY].flags = MF_NOGRAVITY|MF_NOTHINK|MF_NOCLIPTHING|MF_NOBLOCKMAP; + mobjinfo[MT_RAY].radius = mobjinfo[actor->type].radius; + mobjinfo[MT_RAY].height = mobjinfo[actor->type].height; if (P_RandomChance(FRACUNIT/2)) // port priority 1? { @@ -3384,10 +3384,10 @@ void A_SkullAttack(mobj_t *actor) #undef dostuff - mobjinfo[MT_NULL].spawnstate = oldspawnstate; - mobjinfo[MT_NULL].flags = oldflags; - mobjinfo[MT_NULL].radius = oldradius; - mobjinfo[MT_NULL].height = oldheight; + mobjinfo[MT_RAY].spawnstate = oldspawnstate; + mobjinfo[MT_RAY].flags = oldflags; + mobjinfo[MT_RAY].radius = oldradius; + mobjinfo[MT_RAY].height = oldheight; } an = actor->angle >> ANGLETOFINESHIFT; @@ -8276,7 +8276,7 @@ void A_Boss3ShockThink(mobj_t *actor) snew->angle = (actor->angle + snext->angle) >> 1; P_SetTarget(&snew->target, actor->target); snew->fuse = actor->fuse; - + P_SetScale(snew, actor->scale); snew->destscale = actor->destscale; snew->scalespeed = actor->scalespeed; From c49dd5f535bc652bdf54ca1b652e72a9c1991dd0 Mon Sep 17 00:00:00 2001 From: GoldenTails Date: Sat, 5 Feb 2022 18:19:00 -0600 Subject: [PATCH 1061/1080] Make dedicated servers not pop up that annoying SDL error window So they don't mess with shell scripts that expect SRB2 to exit when it crashes (like most other programs) --- src/sdl/i_system.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/src/sdl/i_system.c b/src/sdl/i_system.c index ccec37093..ab63be946 100644 --- a/src/sdl/i_system.c +++ b/src/sdl/i_system.c @@ -358,9 +358,10 @@ static void I_ReportSignal(int num, int coredumped) I_OutputMsg("\nProcess killed by signal: %s\n\n", sigmsg); - SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, - "Process killed by signal", - sigmsg, NULL); + if (!M_CheckParm("-dedicated")) + SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, + "Process killed by signal", + sigmsg, NULL); } #ifndef NEWSIGNALHANDLER @@ -2202,9 +2203,10 @@ static 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); @@ -2405,9 +2407,10 @@ void 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, - "SRB2 "VERSIONSTRING" Recursive Error", - buffer, NULL); + if (!M_CheckParm("-dedicated")) + SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, + "SRB2 "VERSIONSTRING" Recursive Error", + buffer, NULL); W_Shutdown(); exit(-1); // recursive errors detected @@ -2449,9 +2452,10 @@ void 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, - "SRB2 "VERSIONSTRING" Error", - buffer, NULL); + if (!M_CheckParm("-dedicated")) + SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, + "SRB2 "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 9fee550fb05052df36526a41c59ef7d0d7cfd7d2 Mon Sep 17 00:00:00 2001 From: spherallic Date: Tue, 8 Feb 2022 14:58:09 +0100 Subject: [PATCH 1062/1080] Actually check bot names in lib_gAddPlayer. --- src/lua_baselib.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 12ad4fee0..e12ec146d 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -3455,7 +3455,7 @@ static int lib_gAddPlayer(lua_State *L) lua_pushnil(L); return 1; } - + newplayernum = i; @@ -3486,15 +3486,15 @@ static int lib_gAddPlayer(lua_State *L) // Read the bot name, if given if (!lua_isnoneornil(L, 3)) - strcpy(player_names[newplayernum], luaL_checkstring(L, 3)); - + strlcpy(player_names[newplayernum], luaL_checkstring(L, 3), sizeof(*player_names)); + bot = luaL_optinteger(L, 4, 3); newplayer->bot = (bot >= BOT_NONE && bot <= BOT_MPAI) ? bot : BOT_MPAI; - + // If our bot is a 2P type, we'll need to set its leader so it can spawn if (newplayer->bot == BOT_2PAI || newplayer->bot == BOT_2PHUMAN) B_UpdateBotleader(newplayer); - + // Set the skin (can't do this until AFTER bot type is set!) SetPlayerSkinByNum(newplayernum, skinnum); @@ -3507,7 +3507,7 @@ static int lib_gAddPlayer(lua_State *L) strcpy(joinmsg, va(joinmsg, player_names[newplayernum], newplayernum)); HU_AddChatText(joinmsg, false); } - + LUA_PushUserdata(L, newplayer, META_PLAYER); return 1; } From bb84ae1793e24d3fd6c600d3010331026553bae5 Mon Sep 17 00:00:00 2001 From: spherallic Date: Thu, 10 Feb 2022 13:10:56 +0100 Subject: [PATCH 1063/1080] Decrease hitbox sizes to prevent collision with thin air. --- extras/conf/SRB2-22.cfg | 14 +++++++------- src/info.c | 12 ++++++------ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/extras/conf/SRB2-22.cfg b/extras/conf/SRB2-22.cfg index 4ed68e1ca..b6e8bc53c 100644 --- a/extras/conf/SRB2-22.cfg +++ b/extras/conf/SRB2-22.cfg @@ -3807,8 +3807,8 @@ thingtypes { title = "Egg Mobile"; sprite = "EGGMA1"; - width = 24; - height = 76; + width = 36; + height = 84; flags4text = "[4] End level on death"; flags8text = "[8] Alternate laser attack"; } @@ -3816,8 +3816,8 @@ thingtypes { title = "Egg Slimer"; sprite = "EGGNA1"; - width = 24; - height = 76; + width = 36; + height = 84; flags4text = "[4] End level on death"; flags8text = "[8] Speed up when hit"; } @@ -3825,7 +3825,7 @@ thingtypes { title = "Sea Egg"; sprite = "EGGOA1"; - width = 32; + width = 36; height = 116; flags4text = "[4] End level on death"; } @@ -3833,8 +3833,8 @@ thingtypes { title = "Egg Colosseum"; sprite = "EGGPA1"; - width = 24; - height = 76; + width = 36; + height = 84; flags4text = "[4] End level on death"; } 204 diff --git a/src/info.c b/src/info.c index 544ed1e31..4b0625961 100644 --- a/src/info.c +++ b/src/info.c @@ -5601,7 +5601,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = S_EGGMOBILE_FLEE1, // xdeathstate sfx_s3kb4, // deathsound 4, // speed - 48*FRACUNIT, // radius + 36*FRACUNIT, // radius 84*FRACUNIT, // height 0, // display offset sfx_None, // mass @@ -5736,8 +5736,8 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = S_EGGMOBILE2_FLEE1,// xdeathstate sfx_s3kb4, // deathsound 2*FRACUNIT, // speed - 48*FRACUNIT, // radius - 96*FRACUNIT, // height + 36*FRACUNIT, // radius + 84*FRACUNIT, // height 0, // display offset 0, // mass 3, // damage @@ -5844,7 +5844,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = S_EGGMOBILE3_FLEE1, // xdeathstate sfx_s3kb4, // deathsound 8*FRACUNIT, // speed - 48*FRACUNIT, // radius + 36*FRACUNIT, // radius 116*FRACUNIT, // height 0, // display offset MT_FAKEMOBILE, // mass @@ -5871,7 +5871,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = S_NULL, // xdeathstate sfx_mswarp, // deathsound 8*FRACUNIT, // speed - 32*FRACUNIT, // radius + 36*FRACUNIT, // radius 116*FRACUNIT, // height 0, // display offset 0, // mass @@ -5925,7 +5925,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = S_EGGMOBILE4_FLEE1,// xdeathstate sfx_s3kb4, // deathsound 0, // speed - 48*FRACUNIT, // radius + 36*FRACUNIT, // radius 84*FRACUNIT, // height 0, // display offset 0, // mass From a4778075b2bde8d0e45a540311e95cf337b1890a Mon Sep 17 00:00:00 2001 From: spherallic Date: Mon, 14 Feb 2022 14:57:00 +0100 Subject: [PATCH 1064/1080] Convert old frame flags in Metal recordings to their 2.2.10 equivalents. --- src/g_demo.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++----- src/g_demo.h | 1 + 2 files changed, 58 insertions(+), 5 deletions(-) diff --git a/src/g_demo.c b/src/g_demo.c index c97dbcf9e..8324a4f21 100644 --- a/src/g_demo.c +++ b/src/g_demo.c @@ -94,7 +94,7 @@ demoghost *ghosts = NULL; // DEMO RECORDING // -#define DEMOVERSION 0x000e +#define DEMOVERSION 0x000f #define DEMOHEADER "\xF0" "SRB2Replay" "\x0F" #define DF_GHOST 0x01 // This demo contains ghost data too! @@ -1029,7 +1029,11 @@ void G_ReadMetalTic(mobj_t *metal) if (ziptic & GZT_ANGLE) metal->angle = READUINT8(metal_p)<<24; if (ziptic & GZT_FRAME) + { oldmetal.frame = READUINT32(metal_p); + if (metalversion < 0x000f) + oldmetal.frame = G_ConvertOldFrameFlags(oldmetal.frame); + } if (ziptic & GZT_SPR2) oldmetal.sprite2 = READUINT8(metal_p); @@ -1169,6 +1173,8 @@ void G_ReadMetalTic(mobj_t *metal) follow->sprite2 = 0; follow->sprite = READUINT16(metal_p); follow->frame = READUINT32(metal_p); // NOT & FF_FRAMEMASK here, so 32 bits + if (metalversion < 0x000f) + follow->frame = G_ConvertOldFrameFlags(follow->frame); follow->angle = metal->angle; follow->color = (metalversion==0x000c) ? READUINT8(metal_p) : READUINT16(metal_p); @@ -1680,8 +1686,9 @@ UINT8 G_CmpDemoTime(char *oldname, char *newname) switch(oldversion) // demoversion { case DEMOVERSION: // latest always supported - case 0x000d: // The previous demoversion also supported - case 0x000c: // all that changed between then and now was longer color name + case 0x000e: // The previous demoversions also supported + case 0x000d: // all that changed between then and now was longer color name + case 0x000c: break; // too old, cannot support. default: @@ -1824,6 +1831,7 @@ void G_DoPlayDemo(char *defdemoname) switch(demoversion) { case 0x000d: + case 0x000e: case DEMOVERSION: // latest always supported cnamelen = MAXCOLORNAME; break; @@ -2077,6 +2085,7 @@ void G_AddGhost(char *defdemoname) switch(ghostversion) { case 0x000d: + case 0x000e: case DEMOVERSION: // latest always supported cnamelen = MAXCOLORNAME; break; @@ -2337,8 +2346,9 @@ void G_DoPlayMetal(void) switch(metalversion) { case DEMOVERSION: // latest always supported - case 0x000d: // There are checks wheter the momentum is from older demo versions or not - case 0x000c: // all that changed between then and now was longer color name + case 0x000e: // There are checks wheter the momentum is from older demo versions or not + case 0x000d: // all that changed between then and now was longer color name + case 0x000c: break; // too old, cannot support. default: @@ -2554,3 +2564,45 @@ boolean G_CheckDemoStatus(void) return false; } + +// 2.2.10 shifted some frame flags around, this function converts frame flags from older versions to their 2.2.10 equivalents. +INT32 G_ConvertOldFrameFlags(INT32 frame) +{ + if (frame & 0x01000000) // was FF_ANIMATE, is now FF_VERTICALFLIP + { + frame &= ~0x01000000; + frame |= FF_ANIMATE; + } + + if (frame & 0x02000000) // was FF_RANDOMANIM, is now FF_HORIZONTALFLIP + { + frame &= ~0x02000000; + frame |= FF_RANDOMANIM; + } + + if (frame & 0x04000000) // was FF_GLOBALANIM, is now empty + { + frame &= ~0x04000000; + frame |= FF_GLOBALANIM; + } + + if (frame & 0x00200000) // was FF_VERTICALFLIP, is now FF_FULLDARK + { + frame &= ~0x00200000; + frame |= FF_VERTICALFLIP; + } + + if (frame & 0x00400000) // was FF_HORIZONTALFLIP, is now FF_PAPERSPRITE + { + frame &= ~0x00400000; + frame |= FF_HORIZONTALFLIP; + } + + if (frame & 0x00800000) // was FF_PAPERSPRITE, is now FF_FLOORSPRITE + { + frame &= ~0x00800000; + frame |= FF_PAPERSPRITE; + } + + return frame; +} diff --git a/src/g_demo.h b/src/g_demo.h index 73cf27358..1a618ba64 100644 --- a/src/g_demo.h +++ b/src/g_demo.h @@ -82,5 +82,6 @@ void G_StopMetalDemo(void); ATTRNORETURN void FUNCNORETURN G_StopMetalRecording(boolean kill); void G_StopDemo(void); boolean G_CheckDemoStatus(void); +INT32 G_ConvertOldFrameFlags(INT32 frame); #endif // __G_DEMO__ From 7218060a7ac454be458338299c0181cc3f34bb6a Mon Sep 17 00:00:00 2001 From: sphere Date: Sat, 19 Feb 2022 01:49:19 +0000 Subject: [PATCH 1065/1080] :lachyes: --- src/info.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/info.c b/src/info.c index a26cc2d86..7a3476669 100644 --- a/src/info.c +++ b/src/info.c @@ -3737,12 +3737,12 @@ state_t states[NUMSTATES] = // Nightopian {SPR_NTPN, 0, 2, {A_Look}, 1, 1, S_PIAN_LOOK2}, // S_PIAN_LOOK1 - {SPR_NTPN, 1, 2, {A_Look}, 1, 1, S_PIAN_LOOK3}, // S_PIAN_LOOK1 - {SPR_NTPN, 2, 2, {A_Look}, 1, 1, S_PIAN_LOOK1}, // S_PIAN_LOOK1 + {SPR_NTPN, 1, 2, {A_Look}, 1, 1, S_PIAN_LOOK3}, // S_PIAN_LOOK2 + {SPR_NTPN, 2, 2, {A_Look}, 1, 1, S_PIAN_LOOK1}, // S_PIAN_LOOK3 {SPR_NTPN, 0, 2, {A_JetgThink}, 0, 0, S_PIAN_FLY2}, // S_PIAN_FLY1 {SPR_NTPN, 1, 2, {NULL}, 0, 0, S_PIAN_FLY3}, // S_PIAN_FLY2 {SPR_NTPN, 2, 2, {NULL}, 0, 0, S_PIAN_FLY1}, // S_PIAN_FLY3 - {SPR_NTPN, 3|FF_ANIMATE, 24, {NULL}, 2, 2, S_PIAN_FLY1}, // S_PIANSING + {SPR_NTPN, 3|FF_ANIMATE, 24, {NULL}, 2, 2, S_PIAN_FLY1}, // S_PIAN_SING // Shleep {SPR_SHLP, 0, 15, {NULL}, 0, 0, S_SHLEEP2}, // S_SHLEEP1 From 946100939aa29b21975a7e1abc658fb8768d4c4c Mon Sep 17 00:00:00 2001 From: spherallic Date: Sat, 19 Feb 2022 22:19:39 +0100 Subject: [PATCH 1066/1080] Update editor configurations & increase Nightopians' hitbox height. --- extras/conf/SRB2-22.cfg | 6 +++--- extras/conf/udb/Includes/SRB222_things.cfg | 6 +++--- src/info.c | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/extras/conf/SRB2-22.cfg b/extras/conf/SRB2-22.cfg index b780ff75f..bd3728e01 100644 --- a/extras/conf/SRB2-22.cfg +++ b/extras/conf/SRB2-22.cfg @@ -6298,10 +6298,10 @@ thingtypes } 1602 { - title = "Pian"; - sprite = "NTPNALAR"; + title = "Nightopian"; + sprite = "NTPNA1"; width = 16; - height = 32; + height = 40; } } diff --git a/extras/conf/udb/Includes/SRB222_things.cfg b/extras/conf/udb/Includes/SRB222_things.cfg index 113c1a4c2..0407741fc 100644 --- a/extras/conf/udb/Includes/SRB222_things.cfg +++ b/extras/conf/udb/Includes/SRB222_things.cfg @@ -2528,10 +2528,10 @@ dreamhill } 1602 { - title = "Pian"; - sprite = "NTPNALAR"; + title = "Nightopian"; + sprite = "NTPNA1"; width = 16; - height = 32; + height = 40; } } diff --git a/src/info.c b/src/info.c index 7a3476669..19789a93d 100644 --- a/src/info.c +++ b/src/info.c @@ -20134,7 +20134,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = sfx_None, // deathsound FRACUNIT, // speed 16*FRACUNIT, // radius - 32*FRACUNIT, // height + 40*FRACUNIT, // height 0, // display offset 16, // mass 0, // damage From fcc28d0714abb569de4830e36de666a716a2f1db Mon Sep 17 00:00:00 2001 From: spherallic Date: Mon, 21 Feb 2022 16:00:21 +0100 Subject: [PATCH 1067/1080] Update seaweed state to utilize new features & sprites. --- src/info.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/info.c b/src/info.c index 19789a93d..3806b5356 100644 --- a/src/info.c +++ b/src/info.c @@ -2168,7 +2168,7 @@ state_t states[NUMSTATES] = {SPR_GARG, 1, -1, {NULL}, 0, 0, S_NULL}, // S_BIGGARGOYLE // DSZ Seaweed - {SPR_SEWE, 0, -1, {NULL}, 0, 0, S_SEAWEED2}, // S_SEAWEED1 + {SPR_SEWE, FF_ANIMATE|FF_RANDOMANIM, -1, {NULL}, 26, 3, S_SEAWEED1}, // S_SEAWEED1 {SPR_SEWE, 1, 5, {NULL}, 0, 0, S_SEAWEED3}, // S_SEAWEED2 {SPR_SEWE, 2, 5, {NULL}, 0, 0, S_SEAWEED4}, // S_SEAWEED3 {SPR_SEWE, 3, 5, {NULL}, 0, 0, S_SEAWEED5}, // S_SEAWEED4 From a6c52f5bad1f2507e4fa8ea648b4667bc9287fc9 Mon Sep 17 00:00:00 2001 From: spherallic Date: Tue, 22 Feb 2022 15:49:16 +0100 Subject: [PATCH 1068/1080] Move MT_RAY to the very end of the mobj list. --- src/deh_tables.c | 2 +- src/info.c | 54 ++++++++++++++++++++++++------------------------ src/info.h | 2 +- 3 files changed, 29 insertions(+), 29 deletions(-) diff --git a/src/deh_tables.c b/src/deh_tables.c index 9db18be9b..9aacd3c50 100644 --- a/src/deh_tables.c +++ b/src/deh_tables.c @@ -3496,7 +3496,6 @@ const char *const STATE_LIST[] = { // array length left dynamic for sanity testi // because sadly no one remembers this place while searching for full state names. const char *const MOBJTYPE_LIST[] = { // array length left dynamic for sanity testing later. "MT_NULL", - "MT_RAY", "MT_UNKNOWN", "MT_THOK", // Thok! mobj @@ -4270,6 +4269,7 @@ const char *const MOBJTYPE_LIST[] = { // array length left dynamic for sanity t "MT_YELLOWBRICKDEBRIS", "MT_NAMECHECK", + "MT_RAY", }; const char *const MOBJFLAG_LIST[] = { diff --git a/src/info.c b/src/info.c index 991bf383e..fe419b5c4 100644 --- a/src/info.c +++ b/src/info.c @@ -3964,33 +3964,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = S_NULL // raisestate }, - { // MT_RAY - -1, // doomednum - S_NULL, // spawnstate - 0, // spawnhealth - S_NULL, // seestate - sfx_None, // seesound - 0, // reactiontime - sfx_None, // attacksound - S_NULL, // painstate - 0, // painchance - sfx_None, // painsound - S_NULL, // meleestate - S_NULL, // missilestate - S_NULL, // deathstate - S_NULL, // xdeathstate - sfx_None, // deathsound - 0, // speed - 0, // radius - 0, // height - 0, // display offset - 0, // mass - 0, // damage - sfx_None, // activesound - MF_NOBLOCKMAP|MF_NOSECTOR|MF_NOCLIP|MF_NOCLIPHEIGHT|MF_NOGRAVITY|MF_SCENERY, // flags - S_NULL // raisestate - }, - { // MT_UNKNOWN -1, // doomednum S_UNKNOWN, // spawnstate @@ -21712,6 +21685,33 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = MF_NOBLOCKMAP|MF_MISSILE|MF_NOGRAVITY|MF_NOSECTOR, // flags S_NULL // raisestate }, + + { // MT_RAY + -1, // doomednum + S_NULL, // spawnstate + 0, // spawnhealth + S_NULL, // seestate + sfx_None, // seesound + 0, // reactiontime + sfx_None, // attacksound + S_NULL, // painstate + 0, // painchance + sfx_None, // painsound + S_NULL, // meleestate + S_NULL, // missilestate + S_NULL, // deathstate + S_NULL, // xdeathstate + sfx_None, // deathsound + 0, // speed + 0, // radius + 0, // height + 0, // display offset + 0, // mass + 0, // damage + sfx_None, // activesound + MF_NOBLOCKMAP|MF_NOSECTOR|MF_NOCLIP|MF_NOCLIPHEIGHT|MF_NOGRAVITY|MF_SCENERY, // flags + S_NULL // raisestate + }, }; skincolor_t skincolors[MAXSKINCOLORS] = { diff --git a/src/info.h b/src/info.h index 9ceeead2c..0539f0b12 100644 --- a/src/info.h +++ b/src/info.h @@ -4316,7 +4316,6 @@ extern playersprite_t free_spr2; typedef enum mobj_type { MT_NULL, - MT_RAY, // General purpose mobj MT_UNKNOWN, MT_THOK, // Thok! mobj @@ -5090,6 +5089,7 @@ typedef enum mobj_type MT_YELLOWBRICKDEBRIS, // for CEZ3 MT_NAMECHECK, + MT_RAY, // General purpose mobj MT_FIRSTFREESLOT, MT_LASTFREESLOT = MT_FIRSTFREESLOT + NUMMOBJFREESLOTS - 1, From d624ee2541e97234de2a827b8cbe1619021b850b Mon Sep 17 00:00:00 2001 From: spherallic Date: Mon, 28 Feb 2022 14:30:01 +0100 Subject: [PATCH 1069/1080] Revert "minor spike optimisations" This reverts commit b2d693a54704f08eecca461192753c1f57f44acf. --- src/info.c | 6 +- src/p_map.c | 152 +++++++++++++++++++++++++++------------------------ src/p_mobj.c | 98 ++++++++++++++------------------- 3 files changed, 127 insertions(+), 129 deletions(-) diff --git a/src/info.c b/src/info.c index 991bf383e..238ea0fe8 100644 --- a/src/info.c +++ b/src/info.c @@ -8004,7 +8004,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = DMG_SPIKE, // mass 0, // damage sfx_None, // activesound - MF_SOLID|MF_SCENERY, // flags + MF_NOBLOCKMAP|MF_SCENERY|MF_NOCLIPHEIGHT, // flags S_NULL // raisestate }, @@ -8031,7 +8031,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = DMG_SPIKE, // mass 0, // damage sfx_None, // activesound - MF_SOLID|MF_NOGRAVITY|MF_SCENERY|MF_PAPERCOLLISION, // flags + MF_NOBLOCKMAP|MF_NOGRAVITY|MF_SCENERY|MF_NOCLIPHEIGHT|MF_PAPERCOLLISION, // flags S_NULL // raisestate }, @@ -8058,7 +8058,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = 4, // mass 0, // damage sfx_None, // activesound - MF_NOBLOCKMAP|MF_NOGRAVITY|MF_SCENERY|MF_NOCLIP|MF_NOCLIPTHING, // flags + MF_NOBLOCKMAP|MF_NOGRAVITY|MF_NOCLIP|MF_NOCLIPTHING, // flags S_NULL // raisestate }, diff --git a/src/p_map.c b/src/p_map.c index bd504ca17..ce1e793ff 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -1465,6 +1465,86 @@ static boolean PIT_CheckThing(mobj_t *thing) return true; } + // Sprite Spikes! + // Do not return because solidity code comes below. + if (tmthing->type == MT_SPIKE && tmthing->flags & MF_SOLID && thing->player) // moving spike rams into player?! + { + if (tmthing->eflags & MFE_VERTICALFLIP) + { + if (thing->z + thing->height <= tmthing->z + FixedMul(FRACUNIT, tmthing->scale) + && thing->z + thing->height + thing->momz >= tmthing->z + FixedMul(FRACUNIT, tmthing->scale) + tmthing->momz + && !(thing->player->charability == CA_BOUNCE && thing->player->panim == PA_ABILITY && thing->eflags & MFE_VERTICALFLIP)) + P_DamageMobj(thing, tmthing, tmthing, 1, DMG_SPIKE); + } + else if (thing->z >= tmthing->z + tmthing->height - FixedMul(FRACUNIT, tmthing->scale) + && thing->z + thing->momz <= tmthing->z + tmthing->height - FixedMul(FRACUNIT, tmthing->scale) + tmthing->momz + && !(thing->player->charability == CA_BOUNCE && thing->player->panim == PA_ABILITY && !(thing->eflags & MFE_VERTICALFLIP))) + P_DamageMobj(thing, tmthing, tmthing, 1, DMG_SPIKE); + } + else if (thing->type == MT_SPIKE && thing->flags & MF_SOLID && tmthing->player) // unfortunate player falls into spike?! + { + if (thing->eflags & MFE_VERTICALFLIP) + { + if (tmthing->z + tmthing->height <= thing->z - FixedMul(FRACUNIT, thing->scale) + && tmthing->z + tmthing->height + tmthing->momz >= thing->z - FixedMul(FRACUNIT, thing->scale) + && !(tmthing->player->charability == CA_BOUNCE && tmthing->player->panim == PA_ABILITY && tmthing->eflags & MFE_VERTICALFLIP)) + P_DamageMobj(tmthing, thing, thing, 1, DMG_SPIKE); + } + else if (tmthing->z >= thing->z + thing->height + FixedMul(FRACUNIT, thing->scale) + && tmthing->z + tmthing->momz <= thing->z + thing->height + FixedMul(FRACUNIT, thing->scale) + && !(tmthing->player->charability == CA_BOUNCE && tmthing->player->panim == PA_ABILITY && !(tmthing->eflags & MFE_VERTICALFLIP))) + P_DamageMobj(tmthing, thing, thing, 1, DMG_SPIKE); + } + + if (tmthing->type == MT_WALLSPIKE && tmthing->flags & MF_SOLID && thing->player) // wall spike impales player + { + fixed_t bottomz, topz; + bottomz = tmthing->z; + topz = tmthing->z + tmthing->height; + if (tmthing->eflags & MFE_VERTICALFLIP) + bottomz -= FixedMul(FRACUNIT, tmthing->scale); + else + topz += FixedMul(FRACUNIT, tmthing->scale); + + if (thing->z + thing->height > bottomz // above bottom + && thing->z < topz) // below top + // don't check angle, the player was clearly in the way in this case + P_DamageMobj(thing, tmthing, tmthing, 1, DMG_SPIKE); + } + else if (thing->type == MT_WALLSPIKE && thing->flags & MF_SOLID && tmthing->player) + { + fixed_t bottomz, topz; + angle_t touchangle = R_PointToAngle2(thing->tracer->x, thing->tracer->y, tmthing->x, tmthing->y); + + if (P_PlayerInPain(tmthing->player) && (tmthing->momx || tmthing->momy)) + { + angle_t playerangle = R_PointToAngle2(0, 0, tmthing->momx, tmthing->momy) - touchangle; + if (playerangle > ANGLE_180) + playerangle = InvAngle(playerangle); + if (playerangle < ANGLE_90) + return true; // Yes, this is intentionally outside the z-height check. No standing on spikes whilst moving away from them. + } + + bottomz = thing->z; + topz = thing->z + thing->height; + + if (thing->eflags & MFE_VERTICALFLIP) + bottomz -= FixedMul(FRACUNIT, thing->scale); + else + topz += FixedMul(FRACUNIT, thing->scale); + + if (tmthing->z + tmthing->height > bottomz // above bottom + && tmthing->z < topz // below top + && !P_MobjWasRemoved(thing->tracer)) // this probably wouldn't work if we didn't have a tracer + { // use base as a reference point to determine what angle you touched the spike at + touchangle = thing->angle - touchangle; + if (touchangle > ANGLE_180) + touchangle = InvAngle(touchangle); + if (touchangle <= ANGLE_22h) // if you touched it at this close an angle, you get poked! + P_DamageMobj(tmthing, thing, thing, 1, DMG_SPIKE); + } + } + if (thing->flags & MF_PUSHABLE) { if (tmthing->type == MT_FAN || tmthing->type == MT_STEAM) @@ -1543,22 +1623,6 @@ static boolean PIT_CheckThing(mobj_t *thing) if (thing->player) { - if (tmthing->type == MT_WALLSPIKE && (tmthing->flags & MF_SOLID)) // wall spike impales player - { - fixed_t bottomz, topz; - bottomz = tmthing->z; - topz = tmthing->z + tmthing->height; - if (tmthing->eflags & MFE_VERTICALFLIP) - bottomz -= FixedMul(FRACUNIT, tmthing->scale); - else - topz += FixedMul(FRACUNIT, tmthing->scale); - - if (thing->z + thing->height > bottomz // above bottom - && thing->z < topz) // below top - // don't check angle, the player was clearly in the way in this case - P_DamageMobj(thing, tmthing, tmthing, 1, DMG_SPIKE); - } - // Doesn't matter what gravity player's following! Just do your stuff in YOUR direction only if (tmthing->eflags & MFE_VERTICALFLIP && (tmthing->z + tmthing->height + tmthing->momz < thing->z @@ -1593,55 +1657,6 @@ static boolean PIT_CheckThing(mobj_t *thing) if (!tmthing->health) return true; - if (thing->type == MT_SPIKE && (thing->flags & MF_SOLID)) // unfortunate player falls into spike?! - { - if (thing->eflags & MFE_VERTICALFLIP) - { - if (tmthing->z + tmthing->height <= thing->z - FixedMul(FRACUNIT, thing->scale) - && tmthing->z + tmthing->height + tmthing->momz >= thing->z - FixedMul(FRACUNIT, thing->scale) - && !(tmthing->player->charability == CA_BOUNCE && tmthing->player->panim == PA_ABILITY && tmthing->eflags & MFE_VERTICALFLIP)) - P_DamageMobj(tmthing, thing, thing, 1, DMG_SPIKE); - } - else if (tmthing->z >= thing->z + thing->height + FixedMul(FRACUNIT, thing->scale) - && tmthing->z + tmthing->momz <= thing->z + thing->height + FixedMul(FRACUNIT, thing->scale) - && !(tmthing->player->charability == CA_BOUNCE && tmthing->player->panim == PA_ABILITY && !(tmthing->eflags & MFE_VERTICALFLIP))) - P_DamageMobj(tmthing, thing, thing, 1, DMG_SPIKE); - } - - if (thing->type == MT_WALLSPIKE && (thing->flags & MF_SOLID)) - { - fixed_t bottomz, topz; - angle_t touchangle = R_PointToAngle2(thing->tracer->x, thing->tracer->y, tmthing->x, tmthing->y); - - if (P_PlayerInPain(tmthing->player) && (tmthing->momx || tmthing->momy)) - { - angle_t playerangle = R_PointToAngle2(0, 0, tmthing->momx, tmthing->momy) - touchangle; - if (playerangle > ANGLE_180) - playerangle = InvAngle(playerangle); - if (playerangle < ANGLE_90) - return true; // Yes, this is intentionally outside the z-height check. No standing on spikes whilst moving away from them. - } - - bottomz = thing->z; - topz = thing->z + thing->height; - - if (thing->eflags & MFE_VERTICALFLIP) - bottomz -= FixedMul(FRACUNIT, thing->scale); - else - topz += FixedMul(FRACUNIT, thing->scale); - - if (tmthing->z + tmthing->height > bottomz // above bottom - && tmthing->z < topz // below top - && !P_MobjWasRemoved(thing->tracer)) // this probably wouldn't work if we didn't have a tracer - { // use base as a reference point to determine what angle you touched the spike at - touchangle = thing->angle - touchangle; - if (touchangle > ANGLE_180) - touchangle = InvAngle(touchangle); - if (touchangle <= ANGLE_22h) // if you touched it at this close an angle, you get poked! - P_DamageMobj(tmthing, thing, thing, 1, DMG_SPIKE); - } - } - if (thing->type == MT_FAN || thing->type == MT_STEAM) P_DoFanAndGasJet(thing, tmthing); else if (thing->flags & MF_SPRING && tmthing->player->powers[pw_carry] != CR_MINECART) @@ -1706,8 +1721,8 @@ static boolean PIT_CheckThing(mobj_t *thing) } } - if ((thing->player) && (tmthing->flags & MF_SPRING || tmthing->type == MT_STEAM)) - ; // springs and gas jets should never be able to step up onto a player + if ((tmthing->flags & MF_SPRING || tmthing->type == MT_STEAM || tmthing->type == MT_SPIKE || tmthing->type == MT_WALLSPIKE) && (thing->player)) + ; // springs, gas jets and springs should never be able to step up onto a player // z checking at last // Treat noclip things as non-solid! else if ((thing->flags & (MF_SOLID|MF_NOCLIP)) == MF_SOLID @@ -1715,9 +1730,6 @@ static boolean PIT_CheckThing(mobj_t *thing) { fixed_t topz, tmtopz; - if (tmthing->type == MT_SPIKE || tmthing->type == MT_WALLSPIKE) // do not run height checks if you are a spike - return true; - if (tmthing->eflags & MFE_VERTICALFLIP) { // pass under diff --git a/src/p_mobj.c b/src/p_mobj.c index ca5c03ed0..04e02f847 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -7845,48 +7845,6 @@ static void P_MobjSceneryThink(mobj_t *mobj) if (P_MobjFlip(mobj)*mobj->momz < mobj->info->speed) mobj->momz = P_MobjFlip(mobj)*mobj->info->speed; break; - case MT_SPIKE: - if (mobj->fuse) - { - mobj->fuse--; - break; - } - P_SetMobjState(mobj, mobj->state->nextstate); - mobj->fuse = mobj->info->speed; - if (mobj->spawnpoint) - mobj->fuse += mobj->spawnpoint->angle; - break; - case MT_WALLSPIKE: - if (mobj->fuse) - { - mobj->fuse--; - break; - } - P_SetMobjState(mobj, mobj->state->nextstate); - mobj->fuse = mobj->info->speed; - if (mobj->spawnpoint) - mobj->fuse += (mobj->spawnpoint->angle / 360); - break; - case MT_WALLSPIKEBASE: - if (!mobj->target) - { - P_RemoveMobj(mobj); - return; - } - mobj->frame = (mobj->frame & ~FF_FRAMEMASK)|(mobj->target->frame & FF_FRAMEMASK); -#if 0 - if (mobj->angle != mobj->target->angle + ANGLE_90) // reposition if not the correct angle - { - mobj_t* target = mobj->target; // shortcut - const fixed_t baseradius = target->radius - (target->scale/2); //FixedMul(FRACUNIT/2, target->scale); - P_UnsetThingPosition(mobj); - mobj->x = target->x - P_ReturnThrustX(target, target->angle, baseradius); - mobj->y = target->y - P_ReturnThrustY(target, target->angle, baseradius); - P_SetThingPosition(mobj); - mobj->angle = target->angle + ANGLE_90; - } -#endif - break; case MT_ROCKCRUMBLE1: case MT_ROCKCRUMBLE2: case MT_ROCKCRUMBLE3: @@ -9283,6 +9241,25 @@ static boolean P_MobjRegularThink(mobj_t *mobj) switch (mobj->type) { + case MT_WALLSPIKEBASE: + if (!mobj->target) { + P_RemoveMobj(mobj); + return false; + } + mobj->frame = (mobj->frame & ~FF_FRAMEMASK)|(mobj->target->frame & FF_FRAMEMASK); +#if 0 + if (mobj->angle != mobj->target->angle + ANGLE_90) // reposition if not the correct angle + { + mobj_t* target = mobj->target; // shortcut + const fixed_t baseradius = target->radius - (target->scale/2); //FixedMul(FRACUNIT/2, target->scale); + P_UnsetThingPosition(mobj); + mobj->x = target->x - P_ReturnThrustX(target, target->angle, baseradius); + mobj->y = target->y - P_ReturnThrustY(target, target->angle, baseradius); + P_SetThingPosition(mobj); + mobj->angle = target->angle + ANGLE_90; + } +#endif + break; case MT_FALLINGROCK: // Despawn rocks here in case zmovement code can't do so (blame slopes) if (!mobj->momx && !mobj->momy && !mobj->momz @@ -9968,6 +9945,18 @@ static boolean P_FuseThink(mobj_t *mobj) break; case MT_METALSONIC_BATTLE: break; // don't remove + case MT_SPIKE: + P_SetMobjState(mobj, mobj->state->nextstate); + mobj->fuse = mobj->info->speed; + if (mobj->spawnpoint) + mobj->fuse += mobj->spawnpoint->angle; + break; + case MT_WALLSPIKE: + P_SetMobjState(mobj, mobj->state->nextstate); + mobj->fuse = mobj->info->speed; + if (mobj->spawnpoint) + mobj->fuse += (mobj->spawnpoint->angle / 360); + break; case MT_NIGHTSCORE: P_RemoveMobj(mobj); return false; @@ -12980,18 +12969,17 @@ static boolean P_SetupSpawnedMapThing(mapthing_t *mthing, mobj_t *mobj, boolean // Pop up spikes! if (mthing->options & MTF_OBJECTSPECIAL) { + mobj->flags &= ~MF_SCENERY; mobj->fuse = (16 - mthing->extrainfo)*(mthing->angle + mobj->info->speed)/16; if (mthing->options & MTF_EXTRA) P_SetMobjState(mobj, mobj->info->meleestate); } - else - mobj->flags |= MF_NOTHINK; - // no collision for spikes if the ambush flag is checked - if ((mthing->options & MTF_AMBUSH) || metalrecording) + // Use per-thing collision for spikes if the deaf flag isn't checked. + if (!(mthing->options & MTF_AMBUSH) && !metalrecording) { P_UnsetThingPosition(mobj); - mobj->flags |= (MF_NOBLOCKMAP|MF_NOCLIPHEIGHT); - mobj->flags &= ~MF_SOLID; + mobj->flags &= ~(MF_NOBLOCKMAP|MF_NOGRAVITY|MF_NOCLIPHEIGHT); + mobj->flags |= MF_SOLID; P_SetThingPosition(mobj); } break; @@ -12999,20 +12987,20 @@ static boolean P_SetupSpawnedMapThing(mapthing_t *mthing, mobj_t *mobj, boolean // Pop up spikes! if (mthing->options & MTF_OBJECTSPECIAL) { + mobj->flags &= ~MF_SCENERY; mobj->fuse = (16 - mthing->extrainfo)*((mthing->angle/360) + mobj->info->speed)/16; if (mthing->options & MTF_EXTRA) P_SetMobjState(mobj, mobj->info->meleestate); } - else - mobj->flags |= MF_NOTHINK; - // no collision for spikes if the ambush flag is checked - if ((mthing->options & MTF_AMBUSH) || metalrecording) + // Use per-thing collision for spikes if the deaf flag isn't checked. + if (!(mthing->options & MTF_AMBUSH) && !metalrecording) { P_UnsetThingPosition(mobj); - mobj->flags |= (MF_NOBLOCKMAP|MF_NOCLIPHEIGHT); - mobj->flags &= ~MF_SOLID; + mobj->flags &= ~(MF_NOBLOCKMAP | MF_NOCLIPHEIGHT); + mobj->flags |= MF_SOLID; P_SetThingPosition(mobj); } + // spawn base { const angle_t mobjangle = FixedAngle(mthing->angle << FRACBITS); // the mobj's own angle hasn't been set quite yet so... @@ -13026,8 +13014,6 @@ static boolean P_SetupSpawnedMapThing(mapthing_t *mthing, mobj_t *mobj, boolean P_SetScale(base, mobj->scale); P_SetTarget(&base->target, mobj); P_SetTarget(&mobj->tracer, base); - if (!(mthing->options & MTF_OBJECTSPECIAL)) - base->flags |= MF_NOTHINK; } break; case MT_RING_BOX: From 34f8464cbfc01adf1650da1311a0751fce5b0678 Mon Sep 17 00:00:00 2001 From: SteelT Date: Wed, 2 Mar 2022 12:35:03 -0500 Subject: [PATCH 1070/1080] Spawn MT_RAY when attempting to spawn MT_NULL Some code assumes that P_SpawnMobj can never return NULL So spawn MT_RAY in it's place when attempting to spawn MT_NULL and show a console warning --- src/p_mobj.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/p_mobj.c b/src/p_mobj.c index 04e02f847..e8fd5fd13 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -10474,10 +10474,17 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type) if (type == MT_NULL) { +#if 0 #ifdef PARANOIA I_Error("Tried to spawn MT_NULL\n"); #endif return NULL; +#endif + // Hack: Some code assumes that P_SpawnMobj can never return NULL + // So replace MT_NULL with MT_RAY in the meantime + // Remove when dealt properly + CONS_Alert(CONS_WARNING, "Tried to spawn MT_NULL, using MT_RAY\n"); + type = MT_RAY; } mobj = Z_Calloc(sizeof (*mobj), PU_LEVEL, NULL); From 893ea10a677274b8cb3aa0987f22f162521b6311 Mon Sep 17 00:00:00 2001 From: SteelT Date: Wed, 2 Mar 2022 12:46:24 -0500 Subject: [PATCH 1071/1080] Turn the console warning into a devmode print because turns out it happens more often than I thought --- 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 e8fd5fd13..96683a123 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -10483,7 +10483,7 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type) // Hack: Some code assumes that P_SpawnMobj can never return NULL // So replace MT_NULL with MT_RAY in the meantime // Remove when dealt properly - CONS_Alert(CONS_WARNING, "Tried to spawn MT_NULL, using MT_RAY\n"); + CONS_Debug(DBG_GAMELOGIC, "Tried to spawn MT_NULL, using MT_RAY\n"); type = MT_RAY; } From 3b75ef7e7643dd3188ce628051245617516ba1ea Mon Sep 17 00:00:00 2001 From: spherallic Date: Thu, 3 Mar 2022 12:08:15 +0100 Subject: [PATCH 1072/1080] Fix warning when compiling with NONET=1 --- src/d_clisrv.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 78a3ebe6c..734337ada 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -2077,6 +2077,7 @@ static boolean CL_FinishedFileList(void) return true; } +#ifndef NONET static const char * InvalidServerReason (serverinfo_pak *info) { #define EOT "\nPress ESC\n" @@ -2140,6 +2141,7 @@ static const char * InvalidServerReason (serverinfo_pak *info) #undef EOT } +#endif // ifndef NONET /** Called by CL_ServerConnectionTicker * From 14295ac7de8fd8f836769753f594977f291fa768 Mon Sep 17 00:00:00 2001 From: spherallic Date: Thu, 3 Mar 2022 20:24:46 +0100 Subject: [PATCH 1073/1080] 2022 --- src/Makefile | 4 ++-- src/am_map.c | 2 +- src/am_map.h | 2 +- src/apng.c | 2 +- src/apng.h | 2 +- src/asm_defs.inc | 2 +- src/b_bot.c | 2 +- src/b_bot.h | 2 +- src/byteptr.h | 2 +- src/command.c | 2 +- src/command.h | 2 +- src/console.c | 2 +- src/console.h | 2 +- src/d_clisrv.c | 2 +- src/d_clisrv.h | 2 +- src/d_event.h | 2 +- src/d_main.c | 4 ++-- src/d_main.h | 2 +- src/d_net.c | 2 +- src/d_net.h | 2 +- src/d_netcmd.c | 2 +- src/d_netcmd.h | 2 +- src/d_netfil.c | 2 +- src/d_netfil.h | 2 +- src/d_player.h | 2 +- src/d_think.h | 2 +- src/d_ticcmd.h | 2 +- src/deh_lua.c | 2 +- src/deh_lua.h | 2 +- src/deh_soc.c | 2 +- src/deh_soc.h | 2 +- src/deh_tables.c | 2 +- src/deh_tables.h | 2 +- src/dehacked.c | 2 +- src/dehacked.h | 2 +- src/doomdata.h | 2 +- src/doomdef.h | 2 +- src/doomstat.h | 2 +- src/doomtype.h | 2 +- src/endian.h | 2 +- src/f_finale.c | 2 +- src/f_finale.h | 2 +- src/f_wipe.c | 2 +- src/g_demo.c | 2 +- src/g_demo.h | 2 +- src/g_game.c | 4 ++-- src/g_game.h | 2 +- src/g_input.c | 2 +- src/g_input.h | 2 +- src/g_state.h | 2 +- src/hardware/hw_batching.c | 2 +- src/hardware/hw_batching.h | 2 +- src/hardware/hw_cache.c | 2 +- src/hardware/hw_data.h | 2 +- src/hardware/hw_defs.h | 2 +- src/hardware/hw_draw.c | 2 +- src/hardware/hw_drv.h | 2 +- src/hardware/hw_glob.h | 2 +- src/hardware/hw_light.c | 2 +- src/hardware/hw_light.h | 2 +- src/hardware/hw_main.c | 2 +- src/hardware/hw_main.h | 2 +- src/hardware/hw_md2.c | 2 +- src/hardware/hw_md2.h | 2 +- src/hardware/r_opengl/r_opengl.c | 2 +- src/http-mserv.c | 2 +- src/hu_stuff.c | 2 +- src/hu_stuff.h | 2 +- src/i_addrinfo.c | 2 +- src/i_addrinfo.h | 2 +- src/i_joy.h | 2 +- src/i_net.h | 2 +- src/i_sound.h | 2 +- src/i_system.h | 2 +- src/i_tcp.c | 2 +- src/i_tcp.h | 2 +- src/i_threads.h | 2 +- src/i_video.h | 2 +- src/info.c | 2 +- src/info.h | 2 +- src/keys.h | 2 +- src/lua_baselib.c | 2 +- src/lua_blockmaplib.c | 4 ++-- src/lua_consolelib.c | 2 +- src/lua_hook.h | 2 +- src/lua_hooklib.c | 2 +- src/lua_hud.h | 2 +- src/lua_hudlib.c | 2 +- src/lua_infolib.c | 2 +- src/lua_inputlib.c | 2 +- src/lua_libs.h | 2 +- src/lua_maplib.c | 2 +- src/lua_mathlib.c | 2 +- src/lua_mobjlib.c | 2 +- src/lua_playerlib.c | 2 +- src/lua_polyobjlib.c | 4 ++-- src/lua_script.c | 2 +- src/lua_script.h | 2 +- src/lua_skinlib.c | 2 +- src/lua_taglib.c | 4 ++-- src/lua_thinkerlib.c | 2 +- src/m_aatree.c | 2 +- src/m_aatree.h | 2 +- src/m_anigif.c | 2 +- src/m_anigif.h | 2 +- src/m_argv.c | 2 +- src/m_argv.h | 2 +- src/m_bbox.c | 2 +- src/m_bbox.h | 2 +- src/m_cheat.c | 2 +- src/m_cheat.h | 2 +- src/m_cond.c | 2 +- src/m_cond.h | 2 +- src/m_dllist.h | 2 +- src/m_easing.c | 2 +- src/m_easing.h | 2 +- src/m_fixed.c | 2 +- src/m_fixed.h | 2 +- src/m_menu.c | 2 +- src/m_menu.h | 2 +- src/m_misc.c | 2 +- src/m_misc.h | 2 +- src/m_perfstats.c | 2 +- src/m_perfstats.h | 2 +- src/m_queue.c | 2 +- src/m_queue.h | 2 +- src/m_random.c | 2 +- src/m_random.h | 2 +- src/m_swap.h | 2 +- src/mserv.c | 4 ++-- src/mserv.h | 4 ++-- src/p_ceilng.c | 2 +- src/p_enemy.c | 2 +- src/p_floor.c | 2 +- src/p_inter.c | 10 +++++----- src/p_lights.c | 2 +- src/p_local.h | 2 +- src/p_map.c | 2 +- src/p_maputl.c | 2 +- src/p_maputl.h | 2 +- src/p_mobj.c | 2 +- src/p_mobj.h | 4 ++-- src/p_polyobj.c | 2 +- src/p_polyobj.h | 2 +- src/p_pspr.h | 2 +- src/p_saveg.c | 2 +- src/p_saveg.h | 2 +- src/p_setup.c | 2 +- src/p_setup.h | 2 +- src/p_sight.c | 2 +- src/p_slopes.c | 2 +- src/p_slopes.h | 2 +- src/p_spec.c | 4 ++-- src/p_spec.h | 2 +- src/p_telept.c | 2 +- src/p_tick.c | 2 +- src/p_tick.h | 2 +- src/p_user.c | 2 +- src/r_bsp.c | 2 +- src/r_bsp.h | 2 +- src/r_data.c | 2 +- src/r_data.h | 2 +- src/r_defs.h | 2 +- src/r_draw.c | 2 +- src/r_draw.h | 2 +- src/r_draw16.c | 2 +- src/r_draw8.c | 2 +- src/r_draw8_npo2.c | 2 +- src/r_local.h | 2 +- src/r_main.c | 2 +- src/r_main.h | 2 +- src/r_patch.c | 2 +- src/r_patch.h | 2 +- src/r_patchrotation.c | 2 +- src/r_patchrotation.h | 2 +- src/r_picformats.c | 4 ++-- src/r_picformats.h | 4 ++-- src/r_plane.c | 2 +- src/r_plane.h | 2 +- src/r_portal.c | 2 +- src/r_portal.h | 2 +- src/r_segs.c | 2 +- src/r_segs.h | 2 +- src/r_skins.c | 2 +- src/r_skins.h | 2 +- src/r_sky.c | 2 +- src/r_sky.h | 2 +- src/r_splats.c | 2 +- src/r_splats.h | 2 +- src/r_state.h | 2 +- src/r_textures.c | 2 +- src/r_textures.h | 2 +- src/r_things.c | 2 +- src/r_things.h | 2 +- src/s_sound.c | 2 +- src/s_sound.h | 2 +- src/screen.c | 2 +- src/screen.h | 2 +- src/sdl/i_system.c | 2 +- src/sdl/i_threads.c | 2 +- src/sdl/i_video.c | 2 +- src/sdl/mixer_sound.c | 2 +- src/sdl/ogl_sdl.c | 2 +- src/sdl/ogl_sdl.h | 2 +- src/sdl/sdl_sound.c | 2 +- src/sdl/sdlmain.h | 2 +- src/sounds.c | 2 +- src/sounds.h | 2 +- src/st_stuff.c | 2 +- src/st_stuff.h | 2 +- src/strcasestr.c | 2 +- src/string.c | 2 +- src/tables.c | 2 +- src/tables.h | 2 +- src/taglist.c | 4 ++-- src/taglist.h | 4 ++-- src/tmap.nas | 2 +- src/tmap.s | 2 +- src/tmap_asm.s | 2 +- src/tmap_mmx.nas | 2 +- src/tmap_vc.nas | 2 +- src/v_video.c | 2 +- src/v_video.h | 2 +- src/vid_copy.s | 2 +- src/w_wad.c | 2 +- src/w_wad.h | 2 +- src/win32/Srb2win.rc | 3 +-- src/y_inter.c | 2 +- src/y_inter.h | 2 +- src/z_zone.c | 2 +- src/z_zone.h | 2 +- 231 files changed, 249 insertions(+), 250 deletions(-) diff --git a/src/Makefile b/src/Makefile index 9659a4994..c1aa35742 100644 --- a/src/Makefile +++ b/src/Makefile @@ -2,8 +2,8 @@ # the poly3 Makefile adapted over and over... # # Copyright 1998-2000 DooM Legacy Team. -# Copyright 2020-2021 James R. -# Copyright 2003-2021 Sonic Team Junior. +# Copyright 2020-2022 James R. +# Copyright 2003-2022 Sonic Team Junior. # # This program is free software distributed under the # terms of the GNU General Public License, version 2. diff --git a/src/am_map.c b/src/am_map.c index 24379e2f1..65a57c09e 100644 --- a/src/am_map.c +++ b/src/am_map.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/am_map.h b/src/am_map.h index 022a7208b..89c4ad9fa 100644 --- a/src/am_map.h +++ b/src/am_map.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/apng.c b/src/apng.c index 36b205c60..f4c08d979 100644 --- a/src/apng.c +++ b/src/apng.c @@ -1,5 +1,5 @@ /* -Copyright 2019-2021, James R. +Copyright 2019-2022, James R. All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/src/apng.h b/src/apng.h index 893b523cb..6b9347424 100644 --- a/src/apng.h +++ b/src/apng.h @@ -1,5 +1,5 @@ /* -Copyright 2019-2021, James R. +Copyright 2019-2022, James R. All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/src/asm_defs.inc b/src/asm_defs.inc index 9074f20f8..a8c60f19e 100644 --- a/src/asm_defs.inc +++ b/src/asm_defs.inc @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/b_bot.c b/src/b_bot.c index 82075eb8e..775a13e29 100644 --- a/src/b_bot.c +++ b/src/b_bot.c @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 2007-2016 by John "JTE" Muniz. -// Copyright (C) 2011-2021 by Sonic Team Junior. +// Copyright (C) 2011-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/b_bot.h b/src/b_bot.h index a89cfab19..c29974c50 100644 --- a/src/b_bot.h +++ b/src/b_bot.h @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 2007-2016 by John "JTE" Muniz. -// Copyright (C) 2012-2021 by Sonic Team Junior. +// Copyright (C) 2012-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/byteptr.h b/src/byteptr.h index ee16bc13f..33c2c8a4b 100644 --- a/src/byteptr.h +++ b/src/byteptr.h @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/command.c b/src/command.c index ae4a7178e..50310f112 100644 --- a/src/command.c +++ b/src/command.c @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/command.h b/src/command.h index 34fd15963..30d7e5bbe 100644 --- a/src/command.h +++ b/src/command.h @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/console.c b/src/console.c index 6f21aeb3d..40fb43121 100644 --- a/src/console.c +++ b/src/console.c @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/console.h b/src/console.h index accf89d96..1cd032ac1 100644 --- a/src/console.h +++ b/src/console.h @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 78a3ebe6c..d26aed6c2 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/d_clisrv.h b/src/d_clisrv.h index 8e75fb963..bf3f0b64f 100644 --- a/src/d_clisrv.h +++ b/src/d_clisrv.h @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/d_event.h b/src/d_event.h index c30a8ced2..c0b9cef77 100644 --- a/src/d_event.h +++ b/src/d_event.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/d_main.c b/src/d_main.c index 83419d266..eb82280bc 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -1141,7 +1141,7 @@ void D_SRB2Main(void) // Print GPL notice for our console users (Linux) CONS_Printf( "\n\nSonic Robo Blast 2\n" - "Copyright (C) 1998-2021 by Sonic Team Junior\n\n" + "Copyright (C) 1998-2022 by Sonic Team Junior\n\n" "This program comes with ABSOLUTELY NO WARRANTY.\n\n" "This is free software, and you are welcome to redistribute it\n" "and/or modify it under the terms of the GNU General Public License\n" diff --git a/src/d_main.h b/src/d_main.h index e282906d9..8189a9f2b 100644 --- a/src/d_main.h +++ b/src/d_main.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/d_net.c b/src/d_net.c index fc029f967..5e5c10889 100644 --- a/src/d_net.c +++ b/src/d_net.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/d_net.h b/src/d_net.h index dbc6d8ba5..5baa593a0 100644 --- a/src/d_net.h +++ b/src/d_net.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/d_netcmd.c b/src/d_netcmd.c index fe7e7678f..d9080d342 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/d_netcmd.h b/src/d_netcmd.h index 7bb7eab03..0beeae154 100644 --- a/src/d_netcmd.h +++ b/src/d_netcmd.h @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/d_netfil.c b/src/d_netfil.c index fdc0026a8..37fb7265f 100644 --- a/src/d_netfil.c +++ b/src/d_netfil.c @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/d_netfil.h b/src/d_netfil.h index 3d713c150..f778a518f 100644 --- a/src/d_netfil.h +++ b/src/d_netfil.h @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/d_player.h b/src/d_player.h index a0db1402d..755926480 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/d_think.h b/src/d_think.h index c3f91edc4..90a58ab68 100644 --- a/src/d_think.h +++ b/src/d_think.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/d_ticcmd.h b/src/d_ticcmd.h index 182b30e6a..e632a74a8 100644 --- a/src/d_ticcmd.h +++ b/src/d_ticcmd.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/deh_lua.c b/src/deh_lua.c index a2ffca95b..1f4d22dca 100644 --- a/src/deh_lua.c +++ b/src/deh_lua.c @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/deh_lua.h b/src/deh_lua.h index 9df4028bd..657e66b6e 100644 --- a/src/deh_lua.h +++ b/src/deh_lua.h @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/deh_soc.c b/src/deh_soc.c index 3a611f3ba..9e3c2f242 100644 --- a/src/deh_soc.c +++ b/src/deh_soc.c @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/deh_soc.h b/src/deh_soc.h index 28e3c9512..f972ec26e 100644 --- a/src/deh_soc.h +++ b/src/deh_soc.h @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/deh_tables.c b/src/deh_tables.c index 9aacd3c50..c53fb5174 100644 --- a/src/deh_tables.c +++ b/src/deh_tables.c @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/deh_tables.h b/src/deh_tables.h index 1f265cc99..972b08838 100644 --- a/src/deh_tables.h +++ b/src/deh_tables.h @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/dehacked.c b/src/dehacked.c index da8c81c35..3f339e477 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/dehacked.h b/src/dehacked.h index 1b200e246..b4651c66a 100644 --- a/src/dehacked.h +++ b/src/dehacked.h @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/doomdata.h b/src/doomdata.h index e317fec1b..009af00fa 100644 --- a/src/doomdata.h +++ b/src/doomdata.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/doomdef.h b/src/doomdef.h index 7e7e35599..d38886296 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/doomstat.h b/src/doomstat.h index 32669b68b..bce43416b 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/doomtype.h b/src/doomtype.h index 3a57d90e8..5ddd9ae44 100644 --- a/src/doomtype.h +++ b/src/doomtype.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/endian.h b/src/endian.h index e78204e72..86297f0cb 100644 --- a/src/endian.h +++ b/src/endian.h @@ -1,6 +1,6 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- -// Copyright (C) 2014-2021 by Sonic Team Junior. +// Copyright (C) 2014-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/f_finale.c b/src/f_finale.c index 8dd03d44f..b5715b863 100644 --- a/src/f_finale.c +++ b/src/f_finale.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/f_finale.h b/src/f_finale.h index 4aa2c3f05..efdc9d4ad 100644 --- a/src/f_finale.h +++ b/src/f_finale.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/f_wipe.c b/src/f_wipe.c index 7526aeca3..43b7180b7 100644 --- a/src/f_wipe.c +++ b/src/f_wipe.c @@ -3,7 +3,7 @@ // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. // Copyright (C) 2013-2016 by Matthew "Kaito Sinclaire" Walsh. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/g_demo.c b/src/g_demo.c index 8324a4f21..e293ad9dc 100644 --- a/src/g_demo.c +++ b/src/g_demo.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/g_demo.h b/src/g_demo.h index 1a618ba64..37664dc71 100644 --- a/src/g_demo.h +++ b/src/g_demo.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/g_game.c b/src/g_game.c index fa0900b02..39d003056 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -1557,7 +1557,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) if (player->bot == BOT_2PHUMAN) cmd->angleturn = (INT16)((localangle - *myangle) >> 16); - + *myangle += (cmd->angleturn<<16); if (controlstyle == CS_LMAOGALOG) { diff --git a/src/g_game.h b/src/g_game.h index f98269fce..dca043f2e 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/g_input.c b/src/g_input.c index 250a24772..7bb2e799d 100644 --- a/src/g_input.c +++ b/src/g_input.c @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/g_input.h b/src/g_input.h index 2e9f53dcf..bf6ad39b3 100644 --- a/src/g_input.h +++ b/src/g_input.h @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/g_state.h b/src/g_state.h index 589dc6361..a6ac1970d 100644 --- a/src/g_state.h +++ b/src/g_state.h @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/hardware/hw_batching.c b/src/hardware/hw_batching.c index da0319bcc..f9c6542ae 100644 --- a/src/hardware/hw_batching.c +++ b/src/hardware/hw_batching.c @@ -1,6 +1,6 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- -// Copyright (C) 2020-2021 by Sonic Team Junior. +// Copyright (C) 2020-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/hardware/hw_batching.h b/src/hardware/hw_batching.h index 9ccc7de3d..df5c478a3 100644 --- a/src/hardware/hw_batching.h +++ b/src/hardware/hw_batching.h @@ -1,6 +1,6 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- -// Copyright (C) 2020-2021 by Sonic Team Junior. +// Copyright (C) 2020-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/hardware/hw_cache.c b/src/hardware/hw_cache.c index 317efd320..fe0b65c50 100644 --- a/src/hardware/hw_cache.c +++ b/src/hardware/hw_cache.c @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/hardware/hw_data.h b/src/hardware/hw_data.h index 5aba6a2a9..ceefe9abd 100644 --- a/src/hardware/hw_data.h +++ b/src/hardware/hw_data.h @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/hardware/hw_defs.h b/src/hardware/hw_defs.h index 8df9b8916..fca9b80a3 100644 --- a/src/hardware/hw_defs.h +++ b/src/hardware/hw_defs.h @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/hardware/hw_draw.c b/src/hardware/hw_draw.c index 02697789e..691e3cd3f 100644 --- a/src/hardware/hw_draw.c +++ b/src/hardware/hw_draw.c @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/hardware/hw_drv.h b/src/hardware/hw_drv.h index d4a586d41..718774773 100644 --- a/src/hardware/hw_drv.h +++ b/src/hardware/hw_drv.h @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/hardware/hw_glob.h b/src/hardware/hw_glob.h index 37d77b467..8b30a3468 100644 --- a/src/hardware/hw_glob.h +++ b/src/hardware/hw_glob.h @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/hardware/hw_light.c b/src/hardware/hw_light.c index e83d9a6ec..eb3c9bbbb 100644 --- a/src/hardware/hw_light.c +++ b/src/hardware/hw_light.c @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/hardware/hw_light.h b/src/hardware/hw_light.h index 244cc921f..a0a9e93ad 100644 --- a/src/hardware/hw_light.h +++ b/src/hardware/hw_light.h @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index d2982afe4..92076e644 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/hardware/hw_main.h b/src/hardware/hw_main.h index 3f90f0ae1..cd822c0c1 100644 --- a/src/hardware/hw_main.h +++ b/src/hardware/hw_main.h @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index b66f91e19..d546e2f7f 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/hardware/hw_md2.h b/src/hardware/hw_md2.h index 9249c034c..966ed016b 100644 --- a/src/hardware/hw_md2.h +++ b/src/hardware/hw_md2.h @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index de0e8c6a6..7ec7ee270 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -1,6 +1,6 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- -// Copyright (C) 1998-2021 by Sonic Team Junior. +// Copyright (C) 1998-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/http-mserv.c b/src/http-mserv.c index f9134ba50..b0ef37fa1 100644 --- a/src/http-mserv.c +++ b/src/http-mserv.c @@ -1,6 +1,6 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- -// Copyright (C) 2020-2021 by James R. +// Copyright (C) 2020-2022 by James R. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 39ad1d9ed..5d893a551 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/hu_stuff.h b/src/hu_stuff.h index bb1a59e69..110486378 100644 --- a/src/hu_stuff.h +++ b/src/hu_stuff.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/i_addrinfo.c b/src/i_addrinfo.c index 5dcea1002..49aadf27d 100644 --- a/src/i_addrinfo.c +++ b/src/i_addrinfo.c @@ -1,6 +1,6 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- -// Copyright (C) 2011-2021 by Sonic Team Junior. +// Copyright (C) 2011-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/i_addrinfo.h b/src/i_addrinfo.h index 397a1969d..592e693f4 100644 --- a/src/i_addrinfo.h +++ b/src/i_addrinfo.h @@ -1,6 +1,6 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- -// Copyright (C) 2011-2021 by Sonic Team Junior. +// Copyright (C) 2011-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/i_joy.h b/src/i_joy.h index 0c7c8dd3f..27584cea6 100644 --- a/src/i_joy.h +++ b/src/i_joy.h @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/i_net.h b/src/i_net.h index dbc82db65..62b7528d5 100644 --- a/src/i_net.h +++ b/src/i_net.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/i_sound.h b/src/i_sound.h index e38a17626..6358fbefb 100644 --- a/src/i_sound.h +++ b/src/i_sound.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/i_system.h b/src/i_system.h index a2dd81cca..27fcdeb3f 100644 --- a/src/i_system.h +++ b/src/i_system.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/i_tcp.c b/src/i_tcp.c index cae97a7d1..8838ba725 100644 --- a/src/i_tcp.c +++ b/src/i_tcp.c @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/i_tcp.h b/src/i_tcp.h index 785734415..b6e5b9235 100644 --- a/src/i_tcp.h +++ b/src/i_tcp.h @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/i_threads.h b/src/i_threads.h index bc752181f..c7b71d26c 100644 --- a/src/i_threads.h +++ b/src/i_threads.h @@ -1,6 +1,6 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- -// Copyright (C) 2020-2021 by James R. +// Copyright (C) 2020-2022 by James R. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/i_video.h b/src/i_video.h index 2d07fcf10..638fcb668 100644 --- a/src/i_video.h +++ b/src/i_video.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/info.c b/src/info.c index 20f0dfe4f..7260caf52 100644 --- a/src/info.c +++ b/src/info.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/info.h b/src/info.h index 0539f0b12..5e088619b 100644 --- a/src/info.h +++ b/src/info.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/keys.h b/src/keys.h index b19259320..df12c95ae 100644 --- a/src/keys.h +++ b/src/keys.h @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/lua_baselib.c b/src/lua_baselib.c index e12ec146d..120ab671e 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 2012-2016 by John "JTE" Muniz. -// Copyright (C) 2012-2021 by Sonic Team Junior. +// Copyright (C) 2012-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/lua_blockmaplib.c b/src/lua_blockmaplib.c index 9089d19b6..8c63a9d6d 100644 --- a/src/lua_blockmaplib.c +++ b/src/lua_blockmaplib.c @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- -// Copyright (C) 2016-2021 by Iestyn "Monster Iestyn" Jealous. -// Copyright (C) 2016-2021 by Sonic Team Junior. +// Copyright (C) 2016-2022 by Iestyn "Monster Iestyn" Jealous. +// Copyright (C) 2016-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/lua_consolelib.c b/src/lua_consolelib.c index 2b8cad69b..c8e914e6d 100644 --- a/src/lua_consolelib.c +++ b/src/lua_consolelib.c @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 2012-2016 by John "JTE" Muniz. -// Copyright (C) 2012-2021 by Sonic Team Junior. +// Copyright (C) 2012-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/lua_hook.h b/src/lua_hook.h index 531d16288..fc6a5f4ee 100644 --- a/src/lua_hook.h +++ b/src/lua_hook.h @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 2012-2016 by John "JTE" Muniz. -// Copyright (C) 2012-2021 by Sonic Team Junior. +// Copyright (C) 2012-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/lua_hooklib.c b/src/lua_hooklib.c index d5f1cf25e..81f863e03 100644 --- a/src/lua_hooklib.c +++ b/src/lua_hooklib.c @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 2012-2016 by John "JTE" Muniz. -// Copyright (C) 2012-2021 by Sonic Team Junior. +// Copyright (C) 2012-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/lua_hud.h b/src/lua_hud.h index c1d2d164b..ad2b51d3e 100644 --- a/src/lua_hud.h +++ b/src/lua_hud.h @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 2014-2016 by John "JTE" Muniz. -// Copyright (C) 2014-2021 by Sonic Team Junior. +// Copyright (C) 2014-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/lua_hudlib.c b/src/lua_hudlib.c index 0dd951efd..c7f2bbc28 100644 --- a/src/lua_hudlib.c +++ b/src/lua_hudlib.c @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 2014-2016 by John "JTE" Muniz. -// Copyright (C) 2014-2021 by Sonic Team Junior. +// Copyright (C) 2014-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/lua_infolib.c b/src/lua_infolib.c index af2d99a0c..ac41de419 100644 --- a/src/lua_infolib.c +++ b/src/lua_infolib.c @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 2012-2016 by John "JTE" Muniz. -// Copyright (C) 2012-2021 by Sonic Team Junior. +// Copyright (C) 2012-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/lua_inputlib.c b/src/lua_inputlib.c index 661d93641..1710b0355 100644 --- a/src/lua_inputlib.c +++ b/src/lua_inputlib.c @@ -1,6 +1,6 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- -// Copyright (C) 2021 by Sonic Team Junior. +// Copyright (C) 2021-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/lua_libs.h b/src/lua_libs.h index 8903834e8..b4a891edb 100644 --- a/src/lua_libs.h +++ b/src/lua_libs.h @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 2012-2016 by John "JTE" Muniz. -// Copyright (C) 2012-2021 by Sonic Team Junior. +// Copyright (C) 2012-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/lua_maplib.c b/src/lua_maplib.c index 04e6fde8d..23a293d6b 100644 --- a/src/lua_maplib.c +++ b/src/lua_maplib.c @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 2012-2016 by John "JTE" Muniz. -// Copyright (C) 2012-2021 by Sonic Team Junior. +// Copyright (C) 2012-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/lua_mathlib.c b/src/lua_mathlib.c index bd9218a3d..c7501da60 100644 --- a/src/lua_mathlib.c +++ b/src/lua_mathlib.c @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 2012-2016 by John "JTE" Muniz. -// Copyright (C) 2012-2021 by Sonic Team Junior. +// Copyright (C) 2012-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/lua_mobjlib.c b/src/lua_mobjlib.c index cf8ccab2c..953b39000 100644 --- a/src/lua_mobjlib.c +++ b/src/lua_mobjlib.c @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 2012-2016 by John "JTE" Muniz. -// Copyright (C) 2012-2021 by Sonic Team Junior. +// Copyright (C) 2012-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/lua_playerlib.c b/src/lua_playerlib.c index 1c634da45..58cfab76c 100644 --- a/src/lua_playerlib.c +++ b/src/lua_playerlib.c @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 2012-2016 by John "JTE" Muniz. -// Copyright (C) 2012-2021 by Sonic Team Junior. +// Copyright (C) 2012-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/lua_polyobjlib.c b/src/lua_polyobjlib.c index 5d76a912d..e254b0e4a 100644 --- a/src/lua_polyobjlib.c +++ b/src/lua_polyobjlib.c @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- -// Copyright (C) 2020-2021 by Iestyn "Monster Iestyn" Jealous. -// Copyright (C) 2020-2021 by Sonic Team Junior. +// Copyright (C) 2020-2022 by Iestyn "Monster Iestyn" Jealous. +// Copyright (C) 2020-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/lua_script.c b/src/lua_script.c index a1376ca2e..a36e5bf98 100644 --- a/src/lua_script.c +++ b/src/lua_script.c @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 2012-2016 by John "JTE" Muniz. -// Copyright (C) 2012-2021 by Sonic Team Junior. +// Copyright (C) 2012-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/lua_script.h b/src/lua_script.h index e88256941..e586b04a8 100644 --- a/src/lua_script.h +++ b/src/lua_script.h @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 2012-2016 by John "JTE" Muniz. -// Copyright (C) 2012-2021 by Sonic Team Junior. +// Copyright (C) 2012-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/lua_skinlib.c b/src/lua_skinlib.c index e66a379e9..9c7c4ad03 100644 --- a/src/lua_skinlib.c +++ b/src/lua_skinlib.c @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 2014-2016 by John "JTE" Muniz. -// Copyright (C) 2014-2021 by Sonic Team Junior. +// Copyright (C) 2014-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/lua_taglib.c b/src/lua_taglib.c index d0cf385a9..b69416362 100644 --- a/src/lua_taglib.c +++ b/src/lua_taglib.c @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- -// Copyright (C) 2020-2021 by James R. -// Copyright (C) 2020-2021 by Sonic Team Junior. +// Copyright (C) 2020-2022 by James R. +// Copyright (C) 2020-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/lua_thinkerlib.c b/src/lua_thinkerlib.c index 65bf8c313..963fdbd5a 100644 --- a/src/lua_thinkerlib.c +++ b/src/lua_thinkerlib.c @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 2012-2016 by John "JTE" Muniz. -// Copyright (C) 2012-2021 by Sonic Team Junior. +// Copyright (C) 2012-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/m_aatree.c b/src/m_aatree.c index b228ed63d..522e38a53 100644 --- a/src/m_aatree.c +++ b/src/m_aatree.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/m_aatree.h b/src/m_aatree.h index 5a240394f..ed011644e 100644 --- a/src/m_aatree.h +++ b/src/m_aatree.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/m_anigif.c b/src/m_anigif.c index fe04a5cb4..b3a1d0fe2 100644 --- a/src/m_anigif.c +++ b/src/m_anigif.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 2013-2016 by Matthew "Kaito Sinclaire" Walsh. // Copyright (C) 2013 by "Ninji". -// Copyright (C) 2013-2021 by Sonic Team Junior. +// Copyright (C) 2013-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/m_anigif.h b/src/m_anigif.h index ca7563b1e..ad64dff7b 100644 --- a/src/m_anigif.h +++ b/src/m_anigif.h @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 2013-2016 by Matthew "Kaito Sinclaire" Walsh. -// Copyright (C) 2013-2021 by Sonic Team Junior. +// Copyright (C) 2013-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/m_argv.c b/src/m_argv.c index 453d6e45c..1444f0c38 100644 --- a/src/m_argv.c +++ b/src/m_argv.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/m_argv.h b/src/m_argv.h index f39db513f..cdb6aa246 100644 --- a/src/m_argv.h +++ b/src/m_argv.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/m_bbox.c b/src/m_bbox.c index e0505fd95..7fde0c171 100644 --- a/src/m_bbox.c +++ b/src/m_bbox.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/m_bbox.h b/src/m_bbox.h index c56bd22c0..588000fae 100644 --- a/src/m_bbox.h +++ b/src/m_bbox.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/m_cheat.c b/src/m_cheat.c index ef896c991..82d0b9d5a 100644 --- a/src/m_cheat.c +++ b/src/m_cheat.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/m_cheat.h b/src/m_cheat.h index ee4ba5f55..c22e262fb 100644 --- a/src/m_cheat.h +++ b/src/m_cheat.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/m_cond.c b/src/m_cond.c index 85d732a48..1406317c5 100644 --- a/src/m_cond.c +++ b/src/m_cond.c @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 2012-2016 by Matthew "Kaito Sinclaire" Walsh. -// Copyright (C) 2012-2021 by Sonic Team Junior. +// Copyright (C) 2012-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/m_cond.h b/src/m_cond.h index b2c6d65e6..f36c80009 100644 --- a/src/m_cond.h +++ b/src/m_cond.h @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 2012-2016 by Matthew "Kaito Sinclaire" Walsh. -// Copyright (C) 2012-2021 by Sonic Team Junior. +// Copyright (C) 2012-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/m_dllist.h b/src/m_dllist.h index 65303b4a3..d8ca6648a 100644 --- a/src/m_dllist.h +++ b/src/m_dllist.h @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 2005 by James Haley -// Copyright (C) 2005-2021 by Sonic Team Junior. +// Copyright (C) 2005-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/m_easing.c b/src/m_easing.c index c871d3106..0f1cc1d02 100644 --- a/src/m_easing.c +++ b/src/m_easing.c @@ -1,6 +1,6 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- -// Copyright (C) 2020-2021 by Jaime "Lactozilla" Passos. +// Copyright (C) 2020-2022 by Jaime "Lactozilla" Passos. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/m_easing.h b/src/m_easing.h index 435ad35e7..229222a15 100644 --- a/src/m_easing.h +++ b/src/m_easing.h @@ -1,6 +1,6 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- -// Copyright (C) 2020-2021 by Jaime "Lactozilla" Passos. +// Copyright (C) 2020-2022 by Jaime "Lactozilla" Passos. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/m_fixed.c b/src/m_fixed.c index d40ccd98e..70b7623da 100644 --- a/src/m_fixed.c +++ b/src/m_fixed.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/m_fixed.h b/src/m_fixed.h index 1cf2f00d1..fe5efc551 100644 --- a/src/m_fixed.h +++ b/src/m_fixed.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/m_menu.c b/src/m_menu.c index 3c1d8d7ca..5b85f65df 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -3,7 +3,7 @@ // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. // Copyright (C) 2011-2016 by Matthew "Kaito Sinclaire" Walsh. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/m_menu.h b/src/m_menu.h index ba9c326a0..5d2ef69ec 100644 --- a/src/m_menu.h +++ b/src/m_menu.h @@ -3,7 +3,7 @@ // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. // Copyright (C) 2011-2016 by Matthew "Kaito Sinclaire" Walsh. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/m_misc.c b/src/m_misc.c index 59783d5d3..d7d6d6bbb 100644 --- a/src/m_misc.c +++ b/src/m_misc.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/m_misc.h b/src/m_misc.h index 82ccd58c7..5b79c6c8c 100644 --- a/src/m_misc.h +++ b/src/m_misc.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/m_perfstats.c b/src/m_perfstats.c index 439a9da1c..3edbd4196 100644 --- a/src/m_perfstats.c +++ b/src/m_perfstats.c @@ -1,6 +1,6 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- -// Copyright (C) 2020-2021 by Sonic Team Junior. +// Copyright (C) 2020-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/m_perfstats.h b/src/m_perfstats.h index 3ff0e6c6b..f6a7c1f74 100644 --- a/src/m_perfstats.h +++ b/src/m_perfstats.h @@ -1,6 +1,6 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- -// Copyright (C) 2020-2021 by Sonic Team Junior. +// Copyright (C) 2020-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/m_queue.c b/src/m_queue.c index a337ca4ce..2cc3f7cb8 100644 --- a/src/m_queue.c +++ b/src/m_queue.c @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 2003 by James Haley -// Copyright (C) 2003-2021 by Sonic Team Junior. +// Copyright (C) 2003-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/m_queue.h b/src/m_queue.h index cc64b8dd7..071f9d8fa 100644 --- a/src/m_queue.h +++ b/src/m_queue.h @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 2003 by James Haley -// Copyright (C) 2003-2021 by Sonic Team Junior. +// Copyright (C) 2003-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/m_random.c b/src/m_random.c index 2e6213e12..112795500 100644 --- a/src/m_random.c +++ b/src/m_random.c @@ -3,7 +3,7 @@ // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. // Copyright (C) 2012-2016 by Matthew "Kaito Sinclaire" Walsh. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/m_random.h b/src/m_random.h index df10b4bb3..aa5ffb0bb 100644 --- a/src/m_random.h +++ b/src/m_random.h @@ -3,7 +3,7 @@ // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. // Copyright (C) 2012-2016 by Matthew "Kaito Sinclaire" Walsh. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/m_swap.h b/src/m_swap.h index 6aa347d97..df5f3e907 100644 --- a/src/m_swap.h +++ b/src/m_swap.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/mserv.c b/src/mserv.c index ff62f2cdc..bff562c95 100644 --- a/src/mserv.c +++ b/src/mserv.c @@ -1,8 +1,8 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. -// Copyright (C) 2020-2021 by James R. +// Copyright (C) 1999-2022 by Sonic Team Junior. +// Copyright (C) 2020-2022 by James R. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/mserv.h b/src/mserv.h index 7a3b3d8ec..23b26fbc5 100644 --- a/src/mserv.h +++ b/src/mserv.h @@ -1,8 +1,8 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. -// Copyright (C) 2020-2021 by James R. +// Copyright (C) 1999-2022 by Sonic Team Junior. +// Copyright (C) 2020-2022 by James R. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/p_ceilng.c b/src/p_ceilng.c index e28f9b5b1..50344ee0c 100644 --- a/src/p_ceilng.c +++ b/src/p_ceilng.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/p_enemy.c b/src/p_enemy.c index 0a3edc8bb..d091e303c 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/p_floor.c b/src/p_floor.c index dd9331e73..5536ee913 100644 --- a/src/p_floor.c +++ b/src/p_floor.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/p_inter.c b/src/p_inter.c index b37689fd8..7c36bf477 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -470,14 +470,14 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) if (!(player->charability2 == CA2_MELEE && player->panim == PA_ABILITY2)) { fixed_t setmomz = -toucher->momz; // Store this, momz get changed by P_DoJump within P_DoBubbleBounce - + if (elementalpierce == 2) // Reset bubblewrap, part 1 P_DoBubbleBounce(player); toucher->momz = setmomz; if (elementalpierce == 2) // Reset bubblewrap, part 2 { boolean underwater = toucher->eflags & MFE_UNDERWATER; - + if (underwater) toucher->momz /= 2; toucher->momz -= (toucher->momz/(underwater ? 8 : 4)); // Cap the height! @@ -1387,7 +1387,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) if (player->bot && player->bot != BOT_MPAI) return; - + // Initialize my junk junk.tags.tags = NULL; junk.tags.count = 0; @@ -1617,7 +1617,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) if (special->tracer && !(special->tracer->flags2 & MF2_STRONGBOX)) macespin = true; - + if (macespin ? (player->powers[pw_ignorelatch] & (1<<15)) : (player->powers[pw_ignorelatch])) return; diff --git a/src/p_lights.c b/src/p_lights.c index 1e41146da..d7bbea90c 100644 --- a/src/p_lights.c +++ b/src/p_lights.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/p_local.h b/src/p_local.h index 38c7f5d13..ba8cbe166 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/p_map.c b/src/p_map.c index ce1e793ff..8cd0223d0 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/p_maputl.c b/src/p_maputl.c index efcebe736..43a7e92a1 100644 --- a/src/p_maputl.c +++ b/src/p_maputl.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/p_maputl.h b/src/p_maputl.h index cec344d03..b7779d88a 100644 --- a/src/p_maputl.h +++ b/src/p_maputl.h @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/p_mobj.c b/src/p_mobj.c index 04e02f847..c99b6293f 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/p_mobj.h b/src/p_mobj.h index 2d096385b..b1b79fd82 100644 --- a/src/p_mobj.h +++ b/src/p_mobj.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -251,7 +251,7 @@ typedef enum MFE_FORCENOSUPER = 1<<13, // Makes an object use super sprites where they wouldn't have otherwise and vice-versa MFE_REVERSESUPER = MFE_FORCESUPER|MFE_FORCENOSUPER - + // free: to and including 1<<15 } mobjeflag_t; diff --git a/src/p_polyobj.c b/src/p_polyobj.c index 6431e4624..0ccb6ebde 100644 --- a/src/p_polyobj.c +++ b/src/p_polyobj.c @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 2006 by James Haley -// Copyright (C) 2006-2021 by Sonic Team Junior. +// Copyright (C) 2006-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/p_polyobj.h b/src/p_polyobj.h index 7c814e0bf..4cc1221db 100644 --- a/src/p_polyobj.h +++ b/src/p_polyobj.h @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 2006 by James Haley -// Copyright (C) 2006-2021 by Sonic Team Junior. +// Copyright (C) 2006-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/p_pspr.h b/src/p_pspr.h index 27002b713..4136c2118 100644 --- a/src/p_pspr.h +++ b/src/p_pspr.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/p_saveg.c b/src/p_saveg.c index 722340f41..99ec58bb9 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/p_saveg.h b/src/p_saveg.h index a909282fe..9f4a2633f 100644 --- a/src/p_saveg.h +++ b/src/p_saveg.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/p_setup.c b/src/p_setup.c index 5f2a63e79..a1c96bed3 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/p_setup.h b/src/p_setup.h index c3c680fdd..9cb44ed59 100644 --- a/src/p_setup.h +++ b/src/p_setup.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/p_sight.c b/src/p_sight.c index 706745f35..1aa231a6c 100644 --- a/src/p_sight.c +++ b/src/p_sight.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/p_slopes.c b/src/p_slopes.c index bfca153a6..ffbfef2d3 100644 --- a/src/p_slopes.c +++ b/src/p_slopes.c @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 2004 by Stephen McGranahan -// Copyright (C) 2015-2021 by Sonic Team Junior. +// Copyright (C) 2015-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/p_slopes.h b/src/p_slopes.h index 43cd3edb0..d1a053d28 100644 --- a/src/p_slopes.h +++ b/src/p_slopes.h @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 2004 by Stephen McGranahan -// Copyright (C) 2015-2021 by Sonic Team Junior. +// Copyright (C) 2015-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/p_spec.c b/src/p_spec.c index 459ee80a9..fa590b5cb 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -2093,7 +2093,7 @@ void P_SwitchWeather(INT32 weathernum) { case PRECIP_SNOW: // snow curWeather = PRECIP_SNOW; - + if (purge) P_SpawnPrecipitation(); diff --git a/src/p_spec.h b/src/p_spec.h index 3b8abfcf8..75954abe2 100644 --- a/src/p_spec.h +++ b/src/p_spec.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/p_telept.c b/src/p_telept.c index 6bac5ad20..cbbd0ff6b 100644 --- a/src/p_telept.c +++ b/src/p_telept.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/p_tick.c b/src/p_tick.c index 55a16fd81..28ace9288 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/p_tick.h b/src/p_tick.h index ae481c6a2..d355bc6d7 100644 --- a/src/p_tick.h +++ b/src/p_tick.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/p_user.c b/src/p_user.c index bbd268fc4..1f14d96c1 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/r_bsp.c b/src/r_bsp.c index b8559d39e..c9f269816 100644 --- a/src/r_bsp.c +++ b/src/r_bsp.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/r_bsp.h b/src/r_bsp.h index 40d24ffec..88757cf4b 100644 --- a/src/r_bsp.h +++ b/src/r_bsp.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/r_data.c b/src/r_data.c index 2cfe9cb7a..51ed15dd6 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/r_data.h b/src/r_data.h index 7580a94ea..63772e7b0 100644 --- a/src/r_data.h +++ b/src/r_data.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/r_defs.h b/src/r_defs.h index fa63de400..c6467a970 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/r_draw.c b/src/r_draw.c index 65bb87bfb..e12d7ebdd 100644 --- a/src/r_draw.c +++ b/src/r_draw.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/r_draw.h b/src/r_draw.h index 2576e1577..c96b29e30 100644 --- a/src/r_draw.h +++ b/src/r_draw.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/r_draw16.c b/src/r_draw16.c index 1a2fed773..763fd1631 100644 --- a/src/r_draw16.c +++ b/src/r_draw16.c @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/r_draw8.c b/src/r_draw8.c index 182182574..c9a9e9575 100644 --- a/src/r_draw8.c +++ b/src/r_draw8.c @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/r_draw8_npo2.c b/src/r_draw8_npo2.c index 90201c771..49ec28dd8 100644 --- a/src/r_draw8_npo2.c +++ b/src/r_draw8_npo2.c @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/r_local.h b/src/r_local.h index ba78ea87d..a5b590e5c 100644 --- a/src/r_local.h +++ b/src/r_local.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/r_main.c b/src/r_main.c index 0d6a74a3b..13d2413fa 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/r_main.h b/src/r_main.h index 5f3bed980..c0edb31b3 100644 --- a/src/r_main.h +++ b/src/r_main.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/r_patch.c b/src/r_patch.c index 6827cd12c..e771e5c94 100644 --- a/src/r_patch.c +++ b/src/r_patch.c @@ -1,6 +1,6 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- -// Copyright (C) 2020-2021 by Jaime "Lactozilla" Passos. +// Copyright (C) 2020-2022 by Jaime "Lactozilla" Passos. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/r_patch.h b/src/r_patch.h index 96fbb0e28..26c28e1f9 100644 --- a/src/r_patch.h +++ b/src/r_patch.h @@ -1,6 +1,6 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- -// Copyright (C) 2020-2021 by Jaime "Lactozilla" Passos. +// Copyright (C) 2020-2022 by Jaime "Lactozilla" Passos. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/r_patchrotation.c b/src/r_patchrotation.c index 5dbc30286..b24e065ba 100644 --- a/src/r_patchrotation.c +++ b/src/r_patchrotation.c @@ -1,6 +1,6 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- -// Copyright (C) 2020-2021 by Jaime "Lactozilla" Passos. +// Copyright (C) 2020-2022 by Jaime "Lactozilla" Passos. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/r_patchrotation.h b/src/r_patchrotation.h index 689b7d411..e6bee80ed 100644 --- a/src/r_patchrotation.h +++ b/src/r_patchrotation.h @@ -1,6 +1,6 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- -// Copyright (C) 2020-2021 by Jaime "Lactozilla" Passos. +// Copyright (C) 2020-2022 by Jaime "Lactozilla" Passos. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/r_picformats.c b/src/r_picformats.c index 5c81d1e02..6aa4659b9 100644 --- a/src/r_picformats.c +++ b/src/r_picformats.c @@ -2,8 +2,8 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 2005-2009 by Andrey "entryway" Budko. -// Copyright (C) 2018-2021 by Jaime "Lactozilla" Passos. -// Copyright (C) 2019-2021 by Sonic Team Junior. +// Copyright (C) 2018-2022 by Jaime "Lactozilla" Passos. +// Copyright (C) 2019-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/r_picformats.h b/src/r_picformats.h index c74f8a13a..573fb4946 100644 --- a/src/r_picformats.h +++ b/src/r_picformats.h @@ -1,8 +1,8 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. -// Copyright (C) 2018-2021 by Jaime "Lactozilla" Passos. -// Copyright (C) 2019-2021 by Sonic Team Junior. +// Copyright (C) 2018-2022 by Jaime "Lactozilla" Passos. +// Copyright (C) 2019-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/r_plane.c b/src/r_plane.c index 1f5c0192e..e31d52be9 100644 --- a/src/r_plane.c +++ b/src/r_plane.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/r_plane.h b/src/r_plane.h index 862b95069..09648fead 100644 --- a/src/r_plane.h +++ b/src/r_plane.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/r_portal.c b/src/r_portal.c index cba98db05..4d4132133 100644 --- a/src/r_portal.c +++ b/src/r_portal.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/r_portal.h b/src/r_portal.h index 0effd07b5..687ee058f 100644 --- a/src/r_portal.h +++ b/src/r_portal.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/r_segs.c b/src/r_segs.c index 157cf466e..41ffa4103 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/r_segs.h b/src/r_segs.h index da7d44ad4..4075cc0bb 100644 --- a/src/r_segs.h +++ b/src/r_segs.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/r_skins.c b/src/r_skins.c index 86c0bbc54..cd53128d2 100644 --- a/src/r_skins.c +++ b/src/r_skins.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/r_skins.h b/src/r_skins.h index a38997f4d..aeaa9f3e0 100644 --- a/src/r_skins.h +++ b/src/r_skins.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/r_sky.c b/src/r_sky.c index 041cccfc5..e21b7cbf1 100644 --- a/src/r_sky.c +++ b/src/r_sky.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/r_sky.h b/src/r_sky.h index f4356dcfa..31c821d22 100644 --- a/src/r_sky.h +++ b/src/r_sky.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/r_splats.c b/src/r_splats.c index 21048c46d..0a84a3a33 100644 --- a/src/r_splats.c +++ b/src/r_splats.c @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/r_splats.h b/src/r_splats.h index 7e31406d1..ec6885e26 100644 --- a/src/r_splats.h +++ b/src/r_splats.h @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/r_state.h b/src/r_state.h index 5a606ed8c..69989e7ac 100644 --- a/src/r_state.h +++ b/src/r_state.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/r_textures.c b/src/r_textures.c index 793e5237f..ff5c49675 100644 --- a/src/r_textures.c +++ b/src/r_textures.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/r_textures.h b/src/r_textures.h index dd286b6ac..d9c2ab49b 100644 --- a/src/r_textures.h +++ b/src/r_textures.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/r_things.c b/src/r_things.c index 34a2dd336..5d752b6f7 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/r_things.h b/src/r_things.h index b4676fbbd..857b03b24 100644 --- a/src/r_things.h +++ b/src/r_things.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/s_sound.c b/src/s_sound.c index 76f0d67c1..7e61e8a55 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/s_sound.h b/src/s_sound.h index 8fcb816d9..6223c4fdb 100644 --- a/src/s_sound.h +++ b/src/s_sound.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/screen.c b/src/screen.c index 770f1c802..73af4313d 100644 --- a/src/screen.c +++ b/src/screen.c @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/screen.h b/src/screen.h index 67880e2b9..376953169 100644 --- a/src/screen.h +++ b/src/screen.h @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/sdl/i_system.c b/src/sdl/i_system.c index ab63be946..9de632734 100644 --- a/src/sdl/i_system.c +++ b/src/sdl/i_system.c @@ -5,7 +5,7 @@ // // Copyright (C) 1993-1996 by id Software, Inc. // Portions Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 2014-2021 by Sonic Team Junior. +// Copyright (C) 2014-2022 by Sonic Team Junior. // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License diff --git a/src/sdl/i_threads.c b/src/sdl/i_threads.c index f73d00bcf..a182ae197 100644 --- a/src/sdl/i_threads.c +++ b/src/sdl/i_threads.c @@ -1,6 +1,6 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- -// Copyright (C) 2020-2021 by James R. +// Copyright (C) 2020-2022 by James R. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index ed766ff23..a27a5ebd2 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -4,7 +4,7 @@ // // Copyright (C) 1993-1996 by id Software, Inc. // Portions Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 2014-2021 by Sonic Team Junior. +// Copyright (C) 2014-2022 by Sonic Team Junior. // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index 35a79acc0..748cd374b 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -1,6 +1,6 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- -// Copyright (C) 2014-2021 by Sonic Team Junior. +// Copyright (C) 2014-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/sdl/ogl_sdl.c b/src/sdl/ogl_sdl.c index bdc693ca5..67e98d4f5 100644 --- a/src/sdl/ogl_sdl.c +++ b/src/sdl/ogl_sdl.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 2014-2021 by Sonic Team Junior. +// Copyright (C) 2014-2022 by Sonic Team Junior. // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License diff --git a/src/sdl/ogl_sdl.h b/src/sdl/ogl_sdl.h index 8f87f688e..9744bc6f1 100644 --- a/src/sdl/ogl_sdl.h +++ b/src/sdl/ogl_sdl.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 2014-2021 by Sonic Team Junior. +// Copyright (C) 2014-2022 by Sonic Team Junior. // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License diff --git a/src/sdl/sdl_sound.c b/src/sdl/sdl_sound.c index 058b601c3..0de3788fe 100644 --- a/src/sdl/sdl_sound.c +++ b/src/sdl/sdl_sound.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // // Copyright (C) 1993-1996 by id Software, Inc. -// Copyright (C) 2014-2021 by Sonic Team Junior. +// Copyright (C) 2014-2022 by Sonic Team Junior. // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License diff --git a/src/sdl/sdlmain.h b/src/sdl/sdlmain.h index a9676b5c2..6b6e79d97 100644 --- a/src/sdl/sdlmain.h +++ b/src/sdl/sdlmain.h @@ -1,7 +1,7 @@ // Emacs style mode select -*- C++ -*- //----------------------------------------------------------------------------- // -// Copyright (C) 2006-2021 by Sonic Team Junior. +// Copyright (C) 2006-2022 by Sonic Team Junior. // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License diff --git a/src/sounds.c b/src/sounds.c index 4c5b11ee9..f7f3ad328 100644 --- a/src/sounds.c +++ b/src/sounds.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/sounds.h b/src/sounds.h index 2dd37953c..eec518689 100644 --- a/src/sounds.h +++ b/src/sounds.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/st_stuff.c b/src/st_stuff.c index f17b58fa6..6c9a0eeca 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/st_stuff.h b/src/st_stuff.h index b1ea2942d..c59bc2ac6 100644 --- a/src/st_stuff.h +++ b/src/st_stuff.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/strcasestr.c b/src/strcasestr.c index 1cbee286a..6a686d6dc 100644 --- a/src/strcasestr.c +++ b/src/strcasestr.c @@ -2,7 +2,7 @@ strcasestr -- case insensitive substring searching function. */ /* -Copyright 2019-2021 James R. +Copyright 2019-2022 James R. All rights reserved. Redistribution and use in source forms, with or without modification, is diff --git a/src/string.c b/src/string.c index f32025612..5534a3f0c 100644 --- a/src/string.c +++ b/src/string.c @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 2006 by Graue. -// Copyright (C) 2006-2021 by Sonic Team Junior. +// Copyright (C) 2006-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/tables.c b/src/tables.c index 9263f42d3..13949b6a7 100644 --- a/src/tables.c +++ b/src/tables.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/tables.h b/src/tables.h index baa3adf36..c44c7d525 100644 --- a/src/tables.h +++ b/src/tables.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/taglist.c b/src/taglist.c index d08750f9b..6b50a51ab 100644 --- a/src/taglist.c +++ b/src/taglist.c @@ -1,8 +1,8 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. -// Copyright (C) 2020-2021 by Nev3r. +// Copyright (C) 1999-2022 by Sonic Team Junior. +// Copyright (C) 2020-2022 by Nev3r. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/taglist.h b/src/taglist.h index ae1a81c89..d326ef357 100644 --- a/src/taglist.h +++ b/src/taglist.h @@ -1,8 +1,8 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. -// Copyright (C) 2020-2021 by Nev3r. +// Copyright (C) 1999-2022 by Sonic Team Junior. +// Copyright (C) 2020-2022 by Nev3r. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/tmap.nas b/src/tmap.nas index 5bf28359e..f096c8141 100644 --- a/src/tmap.nas +++ b/src/tmap.nas @@ -1,7 +1,7 @@ ;; SONIC ROBO BLAST 2 ;;----------------------------------------------------------------------------- ;; Copyright (C) 1998-2000 by DooM Legacy Team. -;; Copyright (C) 1999-2021 by Sonic Team Junior. +;; Copyright (C) 1999-2022 by Sonic Team Junior. ;; ;; This program is free software distributed under the ;; terms of the GNU General Public License, version 2. diff --git a/src/tmap.s b/src/tmap.s index 62dcf85dc..5bb2dea12 100644 --- a/src/tmap.s +++ b/src/tmap.s @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/tmap_asm.s b/src/tmap_asm.s index b5a0a51e9..8e307f42b 100644 --- a/src/tmap_asm.s +++ b/src/tmap_asm.s @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/tmap_mmx.nas b/src/tmap_mmx.nas index 8b6ef91a6..5312f3c76 100644 --- a/src/tmap_mmx.nas +++ b/src/tmap_mmx.nas @@ -1,7 +1,7 @@ ;; SONIC ROBO BLAST 2 ;;----------------------------------------------------------------------------- ;; Copyright (C) 1998-2000 by DOSDOOM. -;; Copyright (C) 2010-2021 by Sonic Team Junior. +;; Copyright (C) 2010-2022 by Sonic Team Junior. ;; ;; This program is free software distributed under the ;; terms of the GNU General Public License, version 2. diff --git a/src/tmap_vc.nas b/src/tmap_vc.nas index b6ee26e6b..44b2d2e7b 100644 --- a/src/tmap_vc.nas +++ b/src/tmap_vc.nas @@ -1,7 +1,7 @@ ;; SONIC ROBO BLAST 2 ;;----------------------------------------------------------------------------- ;; Copyright (C) 1998-2000 by DooM Legacy Team. -;; Copyright (C) 1999-2021 by Sonic Team Junior. +;; Copyright (C) 1999-2022 by Sonic Team Junior. ;; ;; This program is free software distributed under the ;; terms of the GNU General Public License, version 2. diff --git a/src/v_video.c b/src/v_video.c index 4e17a4497..da725f78a 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/v_video.h b/src/v_video.h index bcb39706e..2831230a3 100644 --- a/src/v_video.h +++ b/src/v_video.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/vid_copy.s b/src/vid_copy.s index 6a3788356..8e43e23c1 100644 --- a/src/vid_copy.s +++ b/src/vid_copy.s @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/w_wad.c b/src/w_wad.c index b594912f1..cf954a55e 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/w_wad.h b/src/w_wad.h index a41ba1724..f099b9fd2 100644 --- a/src/w_wad.h +++ b/src/w_wad.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/win32/Srb2win.rc b/src/win32/Srb2win.rc index 0a280448b..730f0a395 100644 --- a/src/win32/Srb2win.rc +++ b/src/win32/Srb2win.rc @@ -97,7 +97,7 @@ BEGIN VALUE "FileDescription", "Sonic Robo Blast 2\0" VALUE "FileVersion", VERSIONSTRING_RC VALUE "InternalName", "srb2\0" - VALUE "LegalCopyright", "Copyright 1998-2021 by Sonic Team Junior\0" + VALUE "LegalCopyright", "Copyright 1998-2022 by Sonic Team Junior\0" VALUE "LegalTrademarks", "Sonic the Hedgehog and related characters are trademarks of Sega.\0" VALUE "OriginalFilename", "srb2win.exe\0" VALUE "PrivateBuild", "\0" @@ -128,4 +128,3 @@ END ///////////////////////////////////////////////////////////////////////////// #endif // not APSTUDIO_INVOKED - diff --git a/src/y_inter.c b/src/y_inter.c index 288a821e6..34e58494f 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -1,6 +1,6 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- -// Copyright (C) 2004-2021 by Sonic Team Junior. +// Copyright (C) 2004-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/y_inter.h b/src/y_inter.h index 871142858..74183066e 100644 --- a/src/y_inter.h +++ b/src/y_inter.h @@ -1,6 +1,6 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- -// Copyright (C) 2004-2021 by Sonic Team Junior. +// Copyright (C) 2004-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/z_zone.c b/src/z_zone.c index 34ff3d37e..b949730e3 100644 --- a/src/z_zone.c +++ b/src/z_zone.c @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 2006 by Graue. -// Copyright (C) 2006-2021 by Sonic Team Junior. +// Copyright (C) 2006-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/z_zone.h b/src/z_zone.h index 17f572a90..d7e1ed528 100644 --- a/src/z_zone.h +++ b/src/z_zone.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 1999-2022 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. From 77d4f873b01988dd72a9c5b26980af5691b9952a Mon Sep 17 00:00:00 2001 From: spherallic Date: Sun, 6 Mar 2022 12:20:41 +0100 Subject: [PATCH 1074/1080] Add upper bound to emblemlocations[] access. --- src/p_inter.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/p_inter.c b/src/p_inter.c index b37689fd8..2ac498085 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -470,14 +470,14 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) if (!(player->charability2 == CA2_MELEE && player->panim == PA_ABILITY2)) { fixed_t setmomz = -toucher->momz; // Store this, momz get changed by P_DoJump within P_DoBubbleBounce - + if (elementalpierce == 2) // Reset bubblewrap, part 1 P_DoBubbleBounce(player); toucher->momz = setmomz; if (elementalpierce == 2) // Reset bubblewrap, part 2 { boolean underwater = toucher->eflags & MFE_UNDERWATER; - + if (underwater) toucher->momz /= 2; toucher->momz -= (toucher->momz/(underwater ? 8 : 4)); // Cap the height! @@ -738,12 +738,11 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) // Secret emblem thingy case MT_EMBLEM: { - if (demoplayback || (player->bot && player->bot != BOT_MPAI)) + if (demoplayback || (player->bot && player->bot != BOT_MPAI) || special->health > MAXEMBLEMS) return; emblemlocations[special->health-1].collected = true; M_UpdateUnlockablesAndExtraEmblems(); - G_SaveGameData(); break; } @@ -1387,7 +1386,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) if (player->bot && player->bot != BOT_MPAI) return; - + // Initialize my junk junk.tags.tags = NULL; junk.tags.count = 0; @@ -1617,7 +1616,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) if (special->tracer && !(special->tracer->flags2 & MF2_STRONGBOX)) macespin = true; - + if (macespin ? (player->powers[pw_ignorelatch] & (1<<15)) : (player->powers[pw_ignorelatch])) return; From 098fcaa4b096bd2a67801732222429b125b20978 Mon Sep 17 00:00:00 2001 From: spherallic Date: Sun, 6 Mar 2022 20:22:22 +0100 Subject: [PATCH 1075/1080] 2.2.10 --- appveyor.yml | 2 +- assets/CMakeLists.txt | 3 +-- src/config.h.in | 7 ++++--- src/d_main.c | 5 +---- src/doomdef.h | 2 +- src/version.h | 8 ++++---- src/win32/Srb2win.rc | 4 ++-- 7 files changed, 14 insertions(+), 17 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index b9f84f395..348b727b1 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,4 +1,4 @@ -version: 2.2.9.{branch}-{build} +version: 2.2.10.{branch}-{build} os: MinGW environment: diff --git a/assets/CMakeLists.txt b/assets/CMakeLists.txt index 3ea7c28df..ef228759c 100644 --- a/assets/CMakeLists.txt +++ b/assets/CMakeLists.txt @@ -22,8 +22,7 @@ set(SRB2_ASSET_INSTALL ON set(SRB2_ASSET_HASHED "srb2.pk3;\ player.dta;\ -zones.pk3;\ -patch.pk3" +zones.pk3" CACHE STRING "Asset filenames to apply MD5 checks. No spaces between entries!" ) diff --git a/src/config.h.in b/src/config.h.in index db794cccc..587a881c7 100644 --- a/src/config.h.in +++ b/src/config.h.in @@ -35,10 +35,11 @@ * Last updated 2020 / 09 / 27 - v2.2.7 - patch.pk3 * Last updated 2020 / 10 / 02 - v2.2.8 - patch.pk3 * Last updated 2021 / 05 / 06 - v2.2.9 - patch.pk3 & zones.pk3 + * Last updated 2022 / 03 / 06 - v2.2.10 - main assets */ -#define ASSET_HASH_SRB2_PK3 "0277c9416756627004e83cbb5b2e3e28" -#define ASSET_HASH_ZONES_PK3 "f8f3e2b5deacf40f14e36686a07d44bb" -#define ASSET_HASH_PLAYER_DTA "49dad7b24634c89728cc3e0b689e12bb" +#define ASSET_HASH_SRB2_PK3 "ad911f29a28a18968ee5b2d11c2acb39" +#define ASSET_HASH_ZONES_PK3 "86ae55cae4e0a93ceda868635706a093" +#define ASSET_HASH_PLAYER_DTA "2e7aaae8a6b1b77d90ffe7606ceadb6c" #ifdef USE_PATCH_DTA #define ASSET_HASH_PATCH_PK3 "7d467a883f7887b3c311798ee2f56b6a" #endif diff --git a/src/d_main.c b/src/d_main.c index eb82280bc..fa9e21337 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -1102,10 +1102,7 @@ static void IdentifyVersion(void) } MUSICTEST("music.dta") - MUSICTEST("patch_music.pk3") -#ifdef DEVELOP // remove when music_new.dta is merged into music.dta - MUSICTEST("music_new.dta") -#endif + //MUSICTEST("patch_music.pk3") } #endif } diff --git a/src/doomdef.h b/src/doomdef.h index d38886296..3b9eeb193 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -150,7 +150,7 @@ extern char logfilename[1024]; // Does this version require an added patch file? // Comment or uncomment this as necessary. -#define USE_PATCH_DTA +// #define USE_PATCH_DTA // Enforce a limit of loaded WAD files. //#define ENFORCE_WAD_LIMIT diff --git a/src/version.h b/src/version.h index 28fc71c36..7a12fbbbe 100644 --- a/src/version.h +++ b/src/version.h @@ -1,4 +1,4 @@ -#define SRB2VERSION "2.2.9"/* this must be the first line, for cmake !! */ +#define SRB2VERSION "2.2.10"/* this must be the first line, for cmake !! */ // The Modification ID; must be obtained from a Master Server Admin ( https://mb.srb2.org/members/?key=ms_admin ). // DO NOT try to set this otherwise, or your modification will be unplayable through the Master Server. @@ -9,7 +9,7 @@ // it's only for detection of the version the player is using so the MS can alert them of an update. // Only set it higher, not lower, obviously. // Note that we use this to help keep internal testing in check; this is why v2.2.0 is not version "1". -#define MODVERSION 50 +#define MODVERSION 51 -// Define this as a prerelease version suffix -// #define BETAVERSION "RC1" +// Define this as a prerelease version suffix (pre#, RC#) +// #define BETAVERSION "pre1" diff --git a/src/win32/Srb2win.rc b/src/win32/Srb2win.rc index 730f0a395..83948ac81 100644 --- a/src/win32/Srb2win.rc +++ b/src/win32/Srb2win.rc @@ -76,8 +76,8 @@ END #include "../doomdef.h" // Needed for version string VS_VERSION_INFO VERSIONINFO - FILEVERSION 2,2,9,0 - PRODUCTVERSION 2,2,9,0 + FILEVERSION 2,2,10,0 + PRODUCTVERSION 2,2,10,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L From 82fb731cab932a8ecbf9382b3fd160425e652423 Mon Sep 17 00:00:00 2001 From: spherallic Date: Sun, 6 Mar 2022 22:52:43 +0100 Subject: [PATCH 1076/1080] :dramahog: --- src/p_inter.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_inter.c b/src/p_inter.c index 601f2677b..582cdb0d0 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -738,7 +738,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) // Secret emblem thingy case MT_EMBLEM: { - if (demoplayback || (player->bot && player->bot != BOT_MPAI) || special->health > MAXEMBLEMS) + if (demoplayback || (player->bot && player->bot != BOT_MPAI) || special->health <= 0 || special->health > MAXEMBLEMS) return; emblemlocations[special->health-1].collected = true; From 86336d6bed80bee6f8168078aa8856109091e50f Mon Sep 17 00:00:00 2001 From: katsy Date: Mon, 7 Mar 2022 18:33:15 -0600 Subject: [PATCH 1077/1080] remove MODID check from hooklib to fix compile issue --- src/lua_hooklib.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/lua_hooklib.c b/src/lua_hooklib.c index 81f863e03..48980f4a4 100644 --- a/src/lua_hooklib.c +++ b/src/lua_hooklib.c @@ -246,7 +246,6 @@ int LUA_HookLib(lua_State *L) } /* TODO: remove in next backwards incompatible release */ -#if MODID == 18 int lib_hudadd(lua_State *L);/* yeah compiler */ int lib_hudadd(lua_State *L) { @@ -260,7 +259,6 @@ int lib_hudadd(lua_State *L) return 0; } -#endif typedef struct Hook_State Hook_State; typedef void (*Hook_Callback)(Hook_State *); From b161cb4588edbcc16fe38a0772d9380f6dc65301 Mon Sep 17 00:00:00 2001 From: katsy <205-katsy@users.noreply.git.do.srb2.org> Date: Tue, 8 Mar 2022 01:06:01 +0000 Subject: [PATCH 1078/1080] e --- src/Makefile.d/features.mk | 150 ++++++++++++++++++------------------- 1 file changed, 75 insertions(+), 75 deletions(-) diff --git a/src/Makefile.d/features.mk b/src/Makefile.d/features.mk index 46194390d..8ba33383b 100644 --- a/src/Makefile.d/features.mk +++ b/src/Makefile.d/features.mk @@ -1,75 +1,75 @@ -# -# Makefile for feature flags. -# - -passthru_opts+=\ - NONET NO_IPV6 NOHW NOMD5 NOPOSTPROCESSING\ - MOBJCONSISTANCY PACKETDROP ZDEBUG\ - HAVE_MINIUPNPC\ - -# build with debugging information -ifdef DEBUGMODE -PACKETDROP=1 -opts+=-DPARANOIA -DRANGECHECK -endif - -ifndef NOHW -opts+=-DHWRENDER -sources+=$(call List,hardware/Sourcefile) -endif - -ifndef NOASM -ifndef NONX86 -sources+=tmap.nas tmap_mmx.nas -opts+=-DUSEASM -endif -endif - -ifndef NOMD5 -sources+=md5.c -endif - -ifndef NOZLIB -ifndef NOPNG -ifdef PNG_PKGCONFIG -$(eval $(call Use_pkg_config,PNG_PKGCONFIG)) -else -PNG_CONFIG?=$(call Prefix,libpng-config) -$(eval $(call Configure,PNG,$(PNG_CONFIG) \ - $(if $(PNG_STATIC),--static),,--ldflags)) -endif -ifdef LINUX -opts+=-D_LARGFILE64_SOURCE -endif -opts+=-DHAVE_PNG -sources+=apng.c -endif -endif - -ifndef NONET -ifndef NOCURL -CURLCONFIG?=curl-config -$(eval $(call Configure,CURL,$(CURLCONFIG))) -opts+=-DHAVE_CURL -endif -endif - -ifdef HAVE_MINIUPNPC -libs+=-lminiupnpc -endif - -# (Valgrind is a memory debugger.) -ifdef VALGRIND -VALGRIND_PKGCONFIG?=valgrind -$(eval $(call Use_pkg_config,VALGRIND)) -ZDEBUG=1 -opts+=-DHAVE_VALGRIND -endif - -default_packages:=\ - GME/libgme/LIBGME\ - OPENMPT/libopenmpt/LIBOPENMPT\ - ZLIB/zlib\ - -$(foreach p,$(default_packages),\ - $(eval $(call Check_pkg_config,$(p)))) +# +# Makefile for feature flags. +# + +passthru_opts+=\ + NONET NO_IPV6 NOHW NOMD5 NOPOSTPROCESSING\ + MOBJCONSISTANCY PACKETDROP ZDEBUG\ + HAVE_MINIUPNPC\ + +# build with debugging information +ifdef DEBUGMODE +PACKETDROP=1 +opts+=-DPARANOIA -DRANGECHECK +endif + +ifndef NOHW +opts+=-DHWRENDER +sources+=$(call List,hardware/Sourcefile) +endif + +ifndef NOASM +ifndef NONX86 +sources+=tmap.nas tmap_mmx.nas +opts+=-DUSEASM +endif +endif + +ifndef NOMD5 +sources+=md5.c +endif + +ifndef NOZLIB +ifndef NOPNG +ifdef PNG_PKGCONFIG +$(eval $(call Use_pkg_config,PNG_PKGCONFIG)) +else +PNG_CONFIG?=$(call Prefix,libpng-config) +$(eval $(call Configure,PNG,$(PNG_CONFIG) \ + $(if $(PNG_STATIC),--static),,--ldflags)) +endif +ifdef LINUX +opts+=-D_LARGEFILE64_SOURCE +endif +opts+=-DHAVE_PNG +sources+=apng.c +endif +endif + +ifndef NONET +ifndef NOCURL +CURLCONFIG?=curl-config +$(eval $(call Configure,CURL,$(CURLCONFIG))) +opts+=-DHAVE_CURL +endif +endif + +ifdef HAVE_MINIUPNPC +libs+=-lminiupnpc +endif + +# (Valgrind is a memory debugger.) +ifdef VALGRIND +VALGRIND_PKGCONFIG?=valgrind +$(eval $(call Use_pkg_config,VALGRIND)) +ZDEBUG=1 +opts+=-DHAVE_VALGRIND +endif + +default_packages:=\ + GME/libgme/LIBGME\ + OPENMPT/libopenmpt/LIBOPENMPT\ + ZLIB/zlib\ + +$(foreach p,$(default_packages),\ + $(eval $(call Check_pkg_config,$(p)))) From 65d47ba35539a4b620c8de747f055e771d4953e9 Mon Sep 17 00:00:00 2001 From: spherallic Date: Sun, 13 Mar 2022 13:33:46 +0100 Subject: [PATCH 1079/1080] Update README.txt --- assets/README.txt | 45 +++++++++++++++++++++------------------------ 1 file changed, 21 insertions(+), 24 deletions(-) diff --git a/assets/README.txt b/assets/README.txt index 8d2fefa54..e84fa4b5e 100644 --- a/assets/README.txt +++ b/assets/README.txt @@ -1,24 +1,21 @@ SONIC ROBO BLAST 2 -Sonic Robo Blast 2 (SRB2) is a 3D Sonic the Hedgehog fangame based on a -modified version of Doom Legacy. +Sonic Robo Blast 2 (SRB2) is a 3D Sonic the Hedgehog fangame, based on a modified version of Doom Legacy. + +https://srb2.org LICENSE -The source code for SRB2 is licensed under the GNU General Public -License, Version 2. See LICENSE.txt for the full text of this license. +The source code for SRB2 is licensed under the GNU General Public License, Version 2. See LICENSE.txt for the full text of this license. -SRB2 uses various third-party libraries, including SDL, SDL Mixer, and -their dependencies. See LICENSE-3RD-PARTY.txt for the licenses of these -libraries. +SRB2 uses various third-party libraries, including SDL, SDL Mixer, and their dependencies. See LICENSE-3RD-PARTY.txt for the licenses of these libraries. SOURCE CODE -You may obtain the source code for SRB2, including the source code for -specific version releases, at the following web sites: +You may obtain the source code for SRB2, including the source code for specific version releases, at the following web sites: STJr GitLab: -https://git.magicalgirl.moe/STJr/SRB2 +https://git.do.srb2.org/STJr/SRB2 GitHub: https://github.com/STJr/SRB2 @@ -27,25 +24,25 @@ CONTACT You may contact Sonic Team Junior via the following web sites: -SRB2.ORG: -https://www.srb2.org - SRB2 Message Board: https://mb.srb2.org SRB2 Official Discord: -https://discord.gg/pYDXzpX (13+) +https://discord.gg/b3BGb8A + +Twitter: +https://twitter.com/SonicTeamJr + +Facebook: +https://facebook.com/SonicRoboBlast2 + COPYRIGHT AND DISCLAIMER -Design and content on SRB2 is copyright 1998-2019 by Sonic Team Junior. -All non-original material on SRB2.ORG is copyrighted by their -respective owners, and no copyright infringement is intended. The owner -of the SRB2.ORG domain is only acting as an ISP, and is therefore not -responsible for any content on SRB2.ORG under the 1998 DMCA. This -site, its webmaster, and its staff make no profit whatsoever (in fact, -we lose money). Sonic Team Junior assumes no responsibility for the -content on any Sonic Team Junior fan sites. +Design and content in Sonic Robo Blast 2 is copyright 1998-2022 by Sonic Team Jr. -Sonic Team Junior is in no way affiliated with SEGA or Sonic Team. We do -not claim ownership of any of SEGA's intellectual property used in SRB2. +All original material in this game is copyrighted by their respective owners, and no copyright infringement is intended. Sonic Team Jr. is in no way affiliated with SEGA or Sonic Team, and we do not claim ownership of any of SEGA's intellectual property used in SRB2. + +Sonic Robo Blast 2 is not commercial software. If you purchased this game, you have been scammed! Sonic Team Jr.'s staff makes no profit whatsoever (in fact, we lose money). + +This software is provided as-is with no warranty whatsoever. From 29892a5f0c26f869e57587a524c9be1a02394c50 Mon Sep 17 00:00:00 2001 From: spherallic Date: Sun, 13 Mar 2022 14:22:22 +0100 Subject: [PATCH 1080/1080] Update README.txt again --- assets/README.txt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/assets/README.txt b/assets/README.txt index e84fa4b5e..5480cb7b0 100644 --- a/assets/README.txt +++ b/assets/README.txt @@ -2,7 +2,7 @@ SONIC ROBO BLAST 2 Sonic Robo Blast 2 (SRB2) is a 3D Sonic the Hedgehog fangame, based on a modified version of Doom Legacy. -https://srb2.org +https://www.srb2.org LICENSE @@ -43,6 +43,8 @@ Design and content in Sonic Robo Blast 2 is copyright 1998-2022 by Sonic Team Jr All original material in this game is copyrighted by their respective owners, and no copyright infringement is intended. Sonic Team Jr. is in no way affiliated with SEGA or Sonic Team, and we do not claim ownership of any of SEGA's intellectual property used in SRB2. -Sonic Robo Blast 2 is not commercial software. If you purchased this game, you have been scammed! Sonic Team Jr.'s staff makes no profit whatsoever (in fact, we lose money). +Sonic Robo Blast 2 is not commercial software. If you purchased this game, you have been scammed! Sonic Team Jr.'s staff makes no profit whatsoever (in fact, we lose money). + +The owner of the srb2.org domain is only acting as an ISP, and is therefore not responsible for any content on srb2.org under the 1998 DMCA. Sonic Team Jr. assumes no responsibility for the content on any Sonic Team Jr. fan sites. This software is provided as-is with no warranty whatsoever.