From 91502f14999f46c6e4179ad5e0b5abd47326564f Mon Sep 17 00:00:00 2001 From: James R Date: Mon, 15 Jul 2019 15:39:58 -0700 Subject: [PATCH 01/24] Don't send login final hashes to everyone Someone thought it was a good fucking idea to make logins NetXCmds. NetXCmds are sent to everyone however. Thankfully logins are two passes. And the second pass uses a salt based on the playernum. Therefore, in order to actually make use of the final hash, you'd have to be the same playernum as who originally sent it. Still a stupid exploit. P.S. The netcode is LOL XD by VincyTM -Telos --- src/d_clisrv.c | 58 +++++++++++++++++++++++++++++++++++++++ src/d_clisrv.h | 9 +++++++ src/d_netcmd.c | 73 ++++---------------------------------------------- src/d_netcmd.h | 4 +-- 4 files changed, 74 insertions(+), 70 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 274fe398a..64d3ee6da 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -44,6 +44,7 @@ #include "lzf.h" #include "lua_script.h" #include "lua_hook.h" +#include "md5.h" #ifdef CLIENT_LOADINGSCREEN // cl loading screen @@ -116,6 +117,9 @@ static UINT8 resynch_local_inprogress = false; // WE are desynched and getting p static UINT8 player_joining = false; UINT8 hu_resynching = 0; +UINT8 adminpassmd5[MD5_LEN]; +boolean adminpasswordset = false; + // Client specific static ticcmd_t localcmds; static ticcmd_t localcmds2; @@ -3760,6 +3764,7 @@ static void HandlePacketFromPlayer(SINT8 node) XBOXSTATIC INT32 netconsole; XBOXSTATIC tic_t realend, realstart; XBOXSTATIC UINT8 *pak, *txtpak, numtxtpak; + XBOXSTATIC UINT8 finalmd5[MD5_LEN];/* Well, it's the cool thing to do? */ FILESTAMP txtpak = NULL; @@ -3958,6 +3963,33 @@ FILESTAMP textcmd[0] += (UINT8)netbuffer->u.textcmd[0]; } break; + case PT_LOGIN: + CONS_Printf("I received LOGIN\n"); + if (client) + break; + +#ifndef NOMD5 + if (doomcom->datalength < MD5_LEN)/* 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, MD5_LEN, va("PNUM%02d", netconsole), &finalmd5); + + if (!memcmp(netbuffer->u.md5sum, finalmd5, MD5_LEN)) + { + 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) @@ -4841,3 +4873,29 @@ 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 + XBOXSTATIC 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 +} diff --git a/src/d_clisrv.h b/src/d_clisrv.h index 8443b3fc0..96591ed93 100644 --- a/src/d_clisrv.h +++ b/src/d_clisrv.h @@ -70,6 +70,9 @@ typedef enum 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. + #ifdef NEWPING PT_PING, // Packet sent to tell clients the other client's latency to server. #endif @@ -398,6 +401,7 @@ typedef struct UINT8 textcmd[MAXTEXTCMD+1]; // 66049 bytes (wut??? 64k??? More like 257 bytes...) filetx_pak filetxpak; // 139 bytes clientconfig_pak clientcfg; // 136 bytes + UINT8 md5sum[MD5_LEN]; serverinfo_pak serverinfo; // 1024 bytes serverrefuse_pak serverrefuse; // 65025 bytes (somehow I feel like those values are garbage...) askinfo_pak askinfo; // 61 bytes @@ -526,5 +530,10 @@ void D_ResetTiccmds(void); tic_t GetLag(INT32 node); UINT8 GetFreeXCmdSize(void); +void D_MD5PasswordPass(const UINT8 *buffer, size_t len, const char *salt, void *dest); + extern UINT8 hu_resynching; + +extern UINT8 adminpassmd5[MD5_LEN]; +extern boolean adminpasswordset; #endif diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 998eef05d..1c2d380c1 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -34,13 +34,13 @@ #include "p_spec.h" #include "m_cheat.h" #include "d_clisrv.h" +#include "d_net.h" #include "v_video.h" #include "d_main.h" #include "m_random.h" #include "f_finale.h" #include "filesrch.h" #include "mserv.h" -#include "md5.h" #include "z_zone.h" #include "lua_script.h" #include "lua_hook.h" @@ -143,7 +143,6 @@ static void Command_Clearscores_f(void); // Remote Administration static void Command_Changepassword_f(void); static void Command_Login_f(void); -static void Got_Login(UINT8 **cp, INT32 playernum); static void Got_Verification(UINT8 **cp, INT32 playernum); static void Got_Removal(UINT8 **cp, INT32 playernum); static void Command_Verify_f(void); @@ -437,7 +436,6 @@ void D_RegisterServerCommands(void) // Remote Administration COM_AddCommand("password", Command_Changepassword_f); - RegisterNetXCmd(XD_LOGIN, Got_Login); COM_AddCommand("login", Command_Login_f); // useful in dedicated to kick off remote admin COM_AddCommand("promote", Command_Verify_f); RegisterNetXCmd(XD_VERIFIED, Got_Verification); @@ -2652,35 +2650,7 @@ static void Got_Teamchange(UINT8 **cp, INT32 playernum) // Attempts to make password system a little sane without // rewriting the entire goddamn XD_file system // -#include "md5.h" -static 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 - XBOXSTATIC 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 -} - #define BASESALT "basepasswordstorage" -static UINT8 adminpassmd5[16]; -static boolean adminpasswordset = false; void D_SetPassword(const char *pw) { @@ -2718,7 +2688,6 @@ static void Command_Login_f(void) // If we have no MD5 support then completely disable XD_LOGIN responses for security. CONS_Alert(CONS_NOTICE, "Remote administration commands are not supported in this build.\n"); #else - XBOXSTATIC UINT8 finalmd5[16]; const char *pw; if (!netgame) @@ -2738,47 +2707,15 @@ static void Command_Login_f(void) pw = COM_Argv(1); // Do the base pass to get what the server has (or should?) - D_MD5PasswordPass((const UINT8 *)pw, strlen(pw), BASESALT, &finalmd5); + D_MD5PasswordPass((const UINT8 *)pw, strlen(pw), BASESALT, &netbuffer->u.md5sum); // Do the final pass to get the comparison the server will come up with - D_MD5PasswordPass(finalmd5, 16, va("PNUM%02d", consoleplayer), &finalmd5); + D_MD5PasswordPass(netbuffer->u.md5sum, MD5_LEN, va("PNUM%02d", consoleplayer), &netbuffer->u.md5sum); CONS_Printf(M_GetText("Sending login... (Notice only given if password is correct.)\n")); - SendNetXCmd(XD_LOGIN, finalmd5, 16); -#endif -} - -static void Got_Login(UINT8 **cp, INT32 playernum) -{ -#ifdef NOMD5 - // If we have no MD5 support then completely disable XD_LOGIN responses for security. - (void)cp; - (void)playernum; -#else - UINT8 sentmd5[16], finalmd5[16]; - - READMEM(*cp, sentmd5, 16); - - if (client) - return; - - if (!adminpasswordset) - { - CONS_Printf(M_GetText("Password from %s failed (no password set).\n"), player_names[playernum]); - return; - } - - // Do the final pass to compare with the sent md5 - D_MD5PasswordPass(adminpassmd5, 16, va("PNUM%02d", playernum), &finalmd5); - - if (!memcmp(sentmd5, finalmd5, 16)) - { - CONS_Printf(M_GetText("%s passed authentication.\n"), player_names[playernum]); - COM_BufInsertText(va("promote %d\n", playernum)); // do this immediately - } - else - CONS_Printf(M_GetText("Password from %s failed.\n"), player_names[playernum]); + netbuffer->packettype = PT_LOGIN; + HSendPacket(servernode, true, 0, MD5_LEN); #endif } diff --git a/src/d_netcmd.h b/src/d_netcmd.h index b82065c82..244693356 100644 --- a/src/d_netcmd.h +++ b/src/d_netcmd.h @@ -125,8 +125,8 @@ typedef enum XD_ADDPLAYER, // 10 XD_TEAMCHANGE, // 11 XD_CLEARSCORES, // 12 - XD_LOGIN, // 13 - XD_VERIFIED, // 14 + // UNUSED 13 (Because I don't want to change these comments) + XD_VERIFIED = 14,//14 XD_RANDOMSEED, // 15 XD_RUNSOC, // 16 XD_REQADDFILE, // 17 From e3aec8e067ce71698c4ffd447e204f718d1c1780 Mon Sep 17 00:00:00 2001 From: toaster Date: Sat, 10 Aug 2019 16:06:59 +0100 Subject: [PATCH 02/24] Fix all our landing woes. (For now.) * Player state upon collision with ground after rolling now sets state properly. * Fix the thing where Knuckles can glide up a slope like it's nothing WHILE keeping things working for bouncers. --- src/p_slopes.c | 10 ++++++---- src/p_user.c | 13 +++++-------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/p_slopes.c b/src/p_slopes.c index f89dd3c96..b06460084 100644 --- a/src/p_slopes.c +++ b/src/p_slopes.c @@ -716,9 +716,11 @@ void P_HandleSlopeLanding(mobj_t *thing, pslope_t *slope) vector3_t mom; // Ditto. if (slope->flags & SL_NOPHYSICS) { // No physics, no need to make anything complicated. - if (P_MobjFlip(thing)*(thing->momz) < 0) { // falling, land on slope - //thing->momz = -P_MobjFlip(thing); + if (P_MobjFlip(thing)*(thing->momz) < 0) // falling, land on slope + { thing->standingslope = slope; + if (!thing->player || !(thing->player->pflags & PF_BOUNCING)) + thing->momz = -P_MobjFlip(thing); } return; } @@ -732,9 +734,9 @@ void P_HandleSlopeLanding(mobj_t *thing, pslope_t *slope) if (P_MobjFlip(thing)*mom.z < 0) { // falling, land on slope thing->momx = mom.x; thing->momy = mom.y; - //thing->momz = -P_MobjFlip(thing); - thing->standingslope = slope; + if (!thing->player || !(thing->player->pflags & PF_BOUNCING)) + thing->momz = -P_MobjFlip(thing); } } diff --git a/src/p_user.c b/src/p_user.c index 0861398d6..128d4e7d7 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -2194,13 +2194,10 @@ boolean P_PlayerHitFloor(player_t *player, boolean dorollstuff) if ((clipmomz = !(P_CheckDeathPitCollide(player->mo))) && player->mo->health && !player->spectator) { - if (dorollstuff) - { - if ((player->charability2 == CA2_SPINDASH) && !(player->pflags & PF_THOKKED) && (player->cmd.buttons & BT_USE) && (FixedHypot(player->mo->momx, player->mo->momy) > (5*player->mo->scale))) - player->pflags |= PF_SPINNING; - else - player->pflags &= ~PF_SPINNING; - } + if (dorollstuff && (player->charability2 == CA2_SPINDASH) && !(player->pflags & PF_THOKKED) && (player->cmd.buttons & BT_USE) && (FixedHypot(player->mo->momx, player->mo->momy) > (5*player->mo->scale))) + player->pflags |= PF_SPINNING; + else if (!(player->pflags & PF_STARTDASH)) + player->pflags &= ~PF_SPINNING; if (player->pflags & PF_SPINNING) { @@ -2268,7 +2265,7 @@ boolean P_PlayerHitFloor(player_t *player, boolean dorollstuff) } else if (player->charability2 == CA2_GUNSLINGER && player->panim == PA_ABILITY2) ; - else if (player->pflags & PF_JUMPED || player->powers[pw_tailsfly] || player->mo->state-states == S_PLAY_FLY_TIRED) + else if (player->panim != PA_IDLE && player->panim != PA_WALK && player->panim != PA_RUN && player->panim != PA_DASH) { if (player->cmomx || player->cmomy) { From ed8ad7abde7968688b027ad6da23b7ccd7de495e Mon Sep 17 00:00:00 2001 From: toaster Date: Sun, 11 Aug 2019 14:36:52 +0100 Subject: [PATCH 03/24] Did some testing, needed to fix one more issue with moving surfaces and spinning. --- src/p_map.c | 2 +- src/p_user.c | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/p_map.c b/src/p_map.c index 6beca92f1..8b00397ca 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -2884,7 +2884,7 @@ static boolean P_ThingHeightClip(mobj_t *thing) if (thing->z != oldz) { if (thing->player) - P_PlayerHitFloor(thing->player, false); + P_PlayerHitFloor(thing->player, !onfloor); } // debug: be sure it falls to the floor diff --git a/src/p_user.c b/src/p_user.c index 128d4e7d7..c583e076b 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -2194,10 +2194,13 @@ boolean P_PlayerHitFloor(player_t *player, boolean dorollstuff) if ((clipmomz = !(P_CheckDeathPitCollide(player->mo))) && player->mo->health && !player->spectator) { - if (dorollstuff && (player->charability2 == CA2_SPINDASH) && !(player->pflags & PF_THOKKED) && (player->cmd.buttons & BT_USE) && (FixedHypot(player->mo->momx, player->mo->momy) > (5*player->mo->scale))) - player->pflags |= PF_SPINNING; - else if (!(player->pflags & PF_STARTDASH)) - player->pflags &= ~PF_SPINNING; + if (dorollstuff) + { + if ((player->charability2 == CA2_SPINDASH) && !(player->pflags & PF_THOKKED) && (player->cmd.buttons & BT_USE) && (FixedHypot(player->mo->momx, player->mo->momy) > (5*player->mo->scale))) + player->pflags |= PF_SPINNING; + else if (!(player->pflags & PF_STARTDASH)) + player->pflags &= ~PF_SPINNING; + } if (player->pflags & PF_SPINNING) { From f85bc7c61fa4f3d28221b6e0f7d08a872448cb24 Mon Sep 17 00:00:00 2001 From: toaster Date: Sun, 11 Aug 2019 19:37:15 +0100 Subject: [PATCH 04/24] Fix Rob's Knuckles 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 c583e076b..82bf9f99f 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -2217,7 +2217,7 @@ boolean P_PlayerHitFloor(player_t *player, boolean dorollstuff) player->skidtime = TICRATE; player->mo->tics = -1; } - else + else if (!player->skidtime) player->pflags &= ~PF_GLIDING; } else if (player->charability2 == CA2_MELEE && player->panim == PA_ABILITY2) From 7ba4bbf867f076711d2dd1e576c11e953d03fcde Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Mon, 12 Aug 2019 14:00:26 +0100 Subject: [PATCH 05/24] Turn Color_Opposite into a 2D array to simplify usage somewhat. Also fix ColorOpposite for Lua --- src/doomdata.h | 2 +- src/lua_mathlib.c | 12 ++--- src/m_menu.c | 4 +- src/p_enemy.c | 6 +-- src/r_draw.c | 130 +++++++++++++++++++++++----------------------- 5 files changed, 78 insertions(+), 76 deletions(-) diff --git a/src/doomdata.h b/src/doomdata.h index 38727b85c..b4142463c 100644 --- a/src/doomdata.h +++ b/src/doomdata.h @@ -210,7 +210,7 @@ typedef struct extern const UINT8 Color_Index[MAXTRANSLATIONS-1][16]; extern const char *Color_Names[MAXSKINCOLORS + NUMSUPERCOLORS]; -extern const UINT8 Color_Opposite[(MAXSKINCOLORS - 1)*2]; +extern const UINT8 Color_Opposite[MAXSKINCOLORS - 1][2]; #define NUMMAPS 1035 diff --git a/src/lua_mathlib.c b/src/lua_mathlib.c index 1f0d6e287..4c5424577 100644 --- a/src/lua_mathlib.c +++ b/src/lua_mathlib.c @@ -173,15 +173,15 @@ static int lib_all7emeralds(lua_State *L) return 1; } -// Whee, special Lua-exclusive function for making use of Color_Opposite[] without needing *2 or +1 -// Returns both color and frame numbers! +// Whee, special Lua-exclusive function for making use of Color_Opposite[] +// Returns both color and signpost shade numbers! static int lib_coloropposite(lua_State *L) { UINT8 colornum = (UINT8)luaL_checkinteger(L, 1); - if (colornum >= MAXSKINCOLORS) - return luaL_error(L, "skincolor %d out of range (0 - %d).", colornum, MAXSKINCOLORS-1); - lua_pushinteger(L, Color_Opposite[colornum*2]); // push color - lua_pushinteger(L, Color_Opposite[colornum*2+1]); // push frame + if (!colornum || colornum >= MAXSKINCOLORS) + return luaL_error(L, "skincolor %d out of range (1 - %d).", colornum, MAXSKINCOLORS-1); + lua_pushinteger(L, Color_Opposite[colornum-1][0]); // push color + lua_pushinteger(L, Color_Opposite[colornum-1][1]); // push sign shade index, 0-15 return 2; } diff --git a/src/m_menu.c b/src/m_menu.c index ca389a94d..128b15a76 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -6980,8 +6980,8 @@ static void M_DrawLoadGameData(void) col = 134; else { - col = (charskin->prefcolor - 1)*2; - col = Color_Index[Color_Opposite[col]-1][Color_Opposite[col+1]]; + col = charskin->prefcolor - 1; + col = Color_Index[Color_Opposite[col][0]-1][Color_Opposite[col][1]]; } V_DrawFill(x+6, y+64, 72, 50, col); diff --git a/src/p_enemy.c b/src/p_enemy.c index 4126d0716..7bc9c14b7 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -4898,12 +4898,12 @@ void A_SignPlayer(mobj_t *actor) of in the name. If you have a better idea, feel free to let me know. ~toast 2016/07/20 */ - actor->frame += (15 - Color_Opposite[(Color_Opposite[(skin->prefoppositecolor - 1)*2] - 1)*2 + 1]); + actor->frame += (15 - Color_Opposite[Color_Opposite[skin->prefoppositecolor - 1][0] - 1][1]); } else if (actor->target->player->skincolor) // Set the sign to be an appropriate background color for this player's skincolor. { - actor->color = Color_Opposite[(actor->target->player->skincolor - 1)*2]; - actor->frame += (15 - Color_Opposite[(actor->target->player->skincolor - 1)*2 + 1]); + actor->color = Color_Opposite[actor->target->player->skincolor - 1][0]; + actor->frame += (15 - Color_Opposite[actor->target->player->skincolor - 1][1]); } if (skin->sprites[SPR2_SIGN].numframes) diff --git a/src/r_draw.c b/src/r_draw.c index f8e435624..af82d3fa8 100644 --- a/src/r_draw.c +++ b/src/r_draw.c @@ -352,77 +352,79 @@ const char *Color_Names[MAXSKINCOLORS + NUMSUPERCOLORS] = A word of warning: If the following array is non-symmetrical, A_SignPlayer's prefoppositecolor behaviour will break. */ -const UINT8 Color_Opposite[(MAXSKINCOLORS - 1)*2] = +// [0] = opposite skin color, +// [1] = shade index used by signpost, 0-15 (actual sprite frame is 15 minus this value) +const UINT8 Color_Opposite[MAXSKINCOLORS - 1][2] = { - // SKINCOLOR_NONE,8, // SKINCOLOR_NONE + // {SKINCOLOR_NONE, 8}, // SKINCOLOR_NONE // Greyscale ranges - SKINCOLOR_BLACK,5, // SKINCOLOR_WHITE, - SKINCOLOR_JET,7, // SKINCOLOR_BONE, - SKINCOLOR_CARBON,7, // SKINCOLOR_CLOUDY, - SKINCOLOR_AETHER,12, // SKINCOLOR_GREY, - SKINCOLOR_SLATE,12, // SKINCOLOR_SILVER, - SKINCOLOR_CLOUDY,7, // SKINCOLOR_CARBON, - SKINCOLOR_BONE,7, // SKINCOLOR_JET, - SKINCOLOR_WHITE,7, // SKINCOLOR_BLACK, + {SKINCOLOR_BLACK, 5}, // SKINCOLOR_WHITE, + {SKINCOLOR_JET, 7}, // SKINCOLOR_BONE, + {SKINCOLOR_CARBON, 7}, // SKINCOLOR_CLOUDY, + {SKINCOLOR_AETHER, 12}, // SKINCOLOR_GREY, + {SKINCOLOR_SLATE, 12}, // SKINCOLOR_SILVER, + {SKINCOLOR_CLOUDY, 7}, // SKINCOLOR_CARBON, + {SKINCOLOR_BONE, 7}, // SKINCOLOR_JET, + {SKINCOLOR_WHITE, 7}, // SKINCOLOR_BLACK, // Desaturated - SKINCOLOR_GREY,15, // SKINCOLOR_AETHER, - SKINCOLOR_SILVER,12, // SKINCOLOR_SLATE, - SKINCOLOR_AZURE,9, // SKINCOLOR_PINK, - SKINCOLOR_RUST,7, // SKINCOLOR_YOGURT, - SKINCOLOR_TAN,2, // SKINCOLOR_BROWN, - SKINCOLOR_BROWN,12, // SKINCOLOR_TAN, - SKINCOLOR_MOSS,5, // SKINCOLOR_BEIGE, - SKINCOLOR_BEIGE,13, // SKINCOLOR_MOSS, - SKINCOLOR_PINK,5, // SKINCOLOR_AZURE, - SKINCOLOR_GOLD,4, // SKINCOLOR_LAVENDER, + {SKINCOLOR_GREY, 15}, // SKINCOLOR_AETHER, + {SKINCOLOR_SILVER, 12}, // SKINCOLOR_SLATE, + {SKINCOLOR_AZURE, 9}, // SKINCOLOR_PINK, + {SKINCOLOR_RUST, 7}, // SKINCOLOR_YOGURT, + {SKINCOLOR_TAN, 2}, // SKINCOLOR_BROWN, + {SKINCOLOR_BROWN, 12}, // SKINCOLOR_TAN, + {SKINCOLOR_MOSS, 5}, // SKINCOLOR_BEIGE, + {SKINCOLOR_BEIGE, 13}, // SKINCOLOR_MOSS, + {SKINCOLOR_PINK, 5}, // SKINCOLOR_AZURE, + {SKINCOLOR_GOLD, 4}, // SKINCOLOR_LAVENDER, // Viv's vivid colours (toast 21/07/17) - SKINCOLOR_EMERALD,10, // SKINCOLOR_RUBY, - SKINCOLOR_FOREST,6, // SKINCOLOR_SALMON, - SKINCOLOR_GREEN,10, // SKINCOLOR_RED, - SKINCOLOR_ICY,10, // SKINCOLOR_CRIMSON, - SKINCOLOR_PURPLE,8, // SKINCOLOR_FLAME, - SKINCOLOR_TEAL,7, // SKINCOLOR_PEACHY, - SKINCOLOR_WAVE,5, // SKINCOLOR_QUAIL, - SKINCOLOR_SAPPHIRE,5, // SKINCOLOR_SUNSET, - SKINCOLOR_CYAN,4, // SKINCOLOR_APRICOT, - SKINCOLOR_BLUE,4, // SKINCOLOR_ORANGE, - SKINCOLOR_YOGURT,8, // SKINCOLOR_RUST, - SKINCOLOR_LAVENDER,10, // SKINCOLOR_GOLD, - SKINCOLOR_SKY,8, // SKINCOLOR_SANDY, - SKINCOLOR_CORNFLOWER,8, // SKINCOLOR_YELLOW, - SKINCOLOR_DUSK,3, // SKINCOLOR_OLIVE, - SKINCOLOR_MAGENTA,9, // SKINCOLOR_LIME, - SKINCOLOR_COBALT,2, // SKINCOLOR_PERIDOT, - SKINCOLOR_RED,6, // SKINCOLOR_GREEN, - SKINCOLOR_SALMON,9, // SKINCOLOR_FOREST, - SKINCOLOR_RUBY,4, // SKINCOLOR_EMERALD, - SKINCOLOR_VIOLET,5, // SKINCOLOR_MINT, - SKINCOLOR_PLUM,6, // SKINCOLOR_SEAFOAM, - SKINCOLOR_ROSY,7, // SKINCOLOR_AQUA, - SKINCOLOR_PEACHY,7, // SKINCOLOR_TEAL, - SKINCOLOR_QUAIL,5, // SKINCOLOR_WAVE, - SKINCOLOR_APRICOT,6, // SKINCOLOR_CYAN, - SKINCOLOR_SANDY,1, // SKINCOLOR_SKY, - SKINCOLOR_NEON,4, // SKINCOLOR_CERULEAN, - SKINCOLOR_CRIMSON,0, // SKINCOLOR_ICY, - SKINCOLOR_SUNSET,5, // SKINCOLOR_SAPPHIRE, - SKINCOLOR_YELLOW,4, // SKINCOLOR_CORNFLOWER, - SKINCOLOR_ORANGE,5, // SKINCOLOR_BLUE, - SKINCOLOR_PERIDOT,5, // SKINCOLOR_COBALT, - SKINCOLOR_LILAC,4, // SKINCOLOR_VAPOR, - SKINCOLOR_OLIVE,0, // SKINCOLOR_DUSK, - SKINCOLOR_BUBBLEGUM,9, // SKINCOLOR_PASTEL, - SKINCOLOR_FLAME,7, // SKINCOLOR_PURPLE, - SKINCOLOR_PASTEL,8, // SKINCOLOR_BUBBLEGUM, - SKINCOLOR_LIME,6, // SKINCOLOR_MAGENTA, - SKINCOLOR_CERULEAN,2, // SKINCOLOR_NEON, - SKINCOLOR_MINT,6, // SKINCOLOR_VIOLET, - SKINCOLOR_VAPOR,4, // SKINCOLOR_LILAC, - SKINCOLOR_MINT,7, // SKINCOLOR_PLUM, - SKINCOLOR_AQUA,1 // SKINCOLOR_ROSY, + {SKINCOLOR_EMERALD, 10}, // SKINCOLOR_RUBY, + {SKINCOLOR_FOREST, 6}, // SKINCOLOR_SALMON, + {SKINCOLOR_GREEN, 10}, // SKINCOLOR_RED, + {SKINCOLOR_ICY, 10}, // SKINCOLOR_CRIMSON, + {SKINCOLOR_PURPLE, 8}, // SKINCOLOR_FLAME, + {SKINCOLOR_TEAL, 7}, // SKINCOLOR_PEACHY, + {SKINCOLOR_WAVE, 5}, // SKINCOLOR_QUAIL, + {SKINCOLOR_SAPPHIRE, 5}, // SKINCOLOR_SUNSET, + {SKINCOLOR_CYAN, 4}, // SKINCOLOR_APRICOT, + {SKINCOLOR_BLUE, 4}, // SKINCOLOR_ORANGE, + {SKINCOLOR_YOGURT, 8}, // SKINCOLOR_RUST, + {SKINCOLOR_LAVENDER, 10}, // SKINCOLOR_GOLD, + {SKINCOLOR_SKY, 8}, // SKINCOLOR_SANDY, + {SKINCOLOR_CORNFLOWER, 8}, // SKINCOLOR_YELLOW, + {SKINCOLOR_DUSK, 3}, // SKINCOLOR_OLIVE, + {SKINCOLOR_MAGENTA, 9}, // SKINCOLOR_LIME, + {SKINCOLOR_COBALT, 2}, // SKINCOLOR_PERIDOT, + {SKINCOLOR_RED, 6}, // SKINCOLOR_GREEN, + {SKINCOLOR_SALMON, 9}, // SKINCOLOR_FOREST, + {SKINCOLOR_RUBY, 4}, // SKINCOLOR_EMERALD, + {SKINCOLOR_VIOLET, 5}, // SKINCOLOR_MINT, + {SKINCOLOR_PLUM, 6}, // SKINCOLOR_SEAFOAM, + {SKINCOLOR_ROSY, 7}, // SKINCOLOR_AQUA, + {SKINCOLOR_PEACHY, 7}, // SKINCOLOR_TEAL, + {SKINCOLOR_QUAIL, 5}, // SKINCOLOR_WAVE, + {SKINCOLOR_APRICOT, 6}, // SKINCOLOR_CYAN, + {SKINCOLOR_SANDY, 1}, // SKINCOLOR_SKY, + {SKINCOLOR_NEON, 4}, // SKINCOLOR_CERULEAN, + {SKINCOLOR_CRIMSON, 0}, // SKINCOLOR_ICY, + {SKINCOLOR_SUNSET, 5}, // SKINCOLOR_SAPPHIRE, + {SKINCOLOR_YELLOW, 4}, // SKINCOLOR_CORNFLOWER, + {SKINCOLOR_ORANGE, 5}, // SKINCOLOR_BLUE, + {SKINCOLOR_PERIDOT, 5}, // SKINCOLOR_COBALT, + {SKINCOLOR_LILAC, 4}, // SKINCOLOR_VAPOR, + {SKINCOLOR_OLIVE, 0}, // SKINCOLOR_DUSK, + {SKINCOLOR_BUBBLEGUM, 9}, // SKINCOLOR_PASTEL, + {SKINCOLOR_FLAME, 7}, // SKINCOLOR_PURPLE, + {SKINCOLOR_PASTEL, 8}, // SKINCOLOR_BUBBLEGUM, + {SKINCOLOR_LIME, 6}, // SKINCOLOR_MAGENTA, + {SKINCOLOR_CERULEAN, 2}, // SKINCOLOR_NEON, + {SKINCOLOR_MINT, 6}, // SKINCOLOR_VIOLET, + {SKINCOLOR_VAPOR, 4}, // SKINCOLOR_LILAC, + {SKINCOLOR_MINT, 7}, // SKINCOLOR_PLUM, + {SKINCOLOR_AQUA, 1} // SKINCOLOR_ROSY, }; CV_PossibleValue_t Color_cons_t[MAXSKINCOLORS+1]; From b7a2b3f7a2afb40e2274c31038db8a462eeae83b Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Mon, 12 Aug 2019 15:02:36 +0100 Subject: [PATCH 06/24] Added switch cases to skin color related functions in r_draw.c, added extra error checking --- src/r_draw.c | 77 ++++++++++++++++++++++++++++++++-------------------- 1 file changed, 47 insertions(+), 30 deletions(-) diff --git a/src/r_draw.c b/src/r_draw.c index af82d3fa8..847a117ec 100644 --- a/src/r_draw.c +++ b/src/r_draw.c @@ -523,33 +523,44 @@ static void R_GenerateTranslationColormap(UINT8 *dest_colormap, INT32 skinnum, U INT32 i, starttranscolor, skinramplength; // Handle a couple of simple special cases - if (skinnum == TC_BOSS - || skinnum == TC_ALLWHITE - || skinnum == TC_METALSONIC - || skinnum == TC_BLINK - || color == SKINCOLOR_NONE) + if (skinnum < TC_DEFAULT) { - if (skinnum == TC_ALLWHITE) - memset(dest_colormap, 0, NUM_PALETTE_ENTRIES * sizeof(UINT8)); - else if (skinnum == TC_BLINK && color != SKINCOLOR_NONE) - memset(dest_colormap, Color_Index[color-1][3], NUM_PALETTE_ENTRIES * sizeof(UINT8)); - else + switch (skinnum) { - for (i = 0; i < NUM_PALETTE_ENTRIES; i++) - dest_colormap[i] = (UINT8)i; + case TC_RAINBOW: + R_RainbowColormap(dest_colormap, color); + return; + case TC_ALLWHITE: + memset(dest_colormap, 0, NUM_PALETTE_ENTRIES * sizeof(UINT8)); + return; + case TC_BLINK: + if (color >= MAXTRANSLATIONS) + I_Error("Invalid skin color #%hu.", (UINT16)color); + if (color != SKINCOLOR_NONE) + { + memset(dest_colormap, Color_Index[color-1][3], NUM_PALETTE_ENTRIES * sizeof(UINT8)); + return; + } + /* FALLTHRU */ + case TC_BOSS: + case TC_METALSONIC: + default: + for (i = 0; i < NUM_PALETTE_ENTRIES; i++) + dest_colormap[i] = (UINT8)i; + + // White! + if (skinnum == TC_BOSS) + dest_colormap[31] = 0; + else if (skinnum == TC_METALSONIC) + dest_colormap[159] = 0; + + return; } - - // White! - if (skinnum == TC_BOSS) - dest_colormap[31] = 0; - else if (skinnum == TC_METALSONIC) - dest_colormap[159] = 0; - - return; } - else if (skinnum == TC_RAINBOW) + else if (color == SKINCOLOR_NONE) { - R_RainbowColormap(dest_colormap, color); + for (i = 0; i < NUM_PALETTE_ENTRIES; i++) + dest_colormap[i] = (UINT8)i; return; } @@ -558,6 +569,9 @@ static void R_GenerateTranslationColormap(UINT8 *dest_colormap, INT32 skinnum, U starttranscolor = (skinnum != TC_DEFAULT) ? skins[skinnum].starttranscolor : DEFAULT_STARTTRANSCOLOR; + if (starttranscolor >= NUM_PALETTE_ENTRIES) + I_Error("Invalid startcolor #%d.", starttranscolor); + // Fill in the entries of the palette that are fixed for (i = 0; i < starttranscolor; i++) dest_colormap[i] = (UINT8)i; @@ -570,7 +584,7 @@ static void R_GenerateTranslationColormap(UINT8 *dest_colormap, INT32 skinnum, U skinramplength = 16; } else - skinramplength = i - NUM_PALETTE_ENTRIES; + skinramplength = i - NUM_PALETTE_ENTRIES; // shouldn't this be NUM_PALETTE_ENTRIES - starttranscolor? // Build the translated ramp for (i = 0; i < skinramplength; i++) @@ -592,13 +606,16 @@ UINT8* R_GetTranslationColormap(INT32 skinnum, skincolors_t color, UINT8 flags) INT32 skintableindex; // Adjust if we want the default colormap - if (skinnum == TC_DEFAULT) skintableindex = DEFAULT_TT_CACHE_INDEX; - else if (skinnum == TC_BOSS) skintableindex = BOSS_TT_CACHE_INDEX; - else if (skinnum == TC_METALSONIC) skintableindex = METALSONIC_TT_CACHE_INDEX; - else if (skinnum == TC_ALLWHITE) skintableindex = ALLWHITE_TT_CACHE_INDEX; - else if (skinnum == TC_RAINBOW) skintableindex = RAINBOW_TT_CACHE_INDEX; - else if (skinnum == TC_BLINK) skintableindex = BLINK_TT_CACHE_INDEX; - else skintableindex = skinnum; + 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; + default: skintableindex = skinnum; break; + } if (flags & GTC_CACHE) { From 0685b9705c5c1a8f81a880a087349504c1a0f100 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Mon, 12 Aug 2019 15:18:36 +0100 Subject: [PATCH 07/24] Initialise player_names[] in D_RegisterClientCommands such that we don't need to have to manually update it if MAXPLAYERS ever changed --- src/d_netcmd.c | 5 +++++ src/g_game.c | 42 +++--------------------------------------- 2 files changed, 8 insertions(+), 39 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index e6f5244f0..1b57dd480 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -599,6 +599,11 @@ void D_RegisterClientCommands(void) Color_cons_t[MAXSKINCOLORS].value = 0; Color_cons_t[MAXSKINCOLORS].strvalue = NULL; + // Set default player names + // Monster Iestyn (12/08/19): not sure where else I could have actually put this, but oh well + for (i = 0; i < MAXPLAYERS; i++) + sprintf(player_names[i], "Player %d", i); + if (dedicated) return; diff --git a/src/g_game.c b/src/g_game.c index c96b0805c..e70241269 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -416,49 +416,13 @@ consvar_t cv_spinaxis2 = {"joyaxis2_spin", "None", CV_SAVE, joyaxis_cons_t, 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}; -#if MAXPLAYERS > 32 -#error "please update player_name table using the new value for MAXPLAYERS" -#endif - #ifdef SEENAMES player_t *seenplayer; // player we're aiming at right now #endif -char player_names[MAXPLAYERS][MAXPLAYERNAME+1] = -{ - "Player 1", - "Player 2", - "Player 3", - "Player 4", - "Player 5", - "Player 6", - "Player 7", - "Player 8", - "Player 9", - "Player 10", - "Player 11", - "Player 12", - "Player 13", - "Player 14", - "Player 15", - "Player 16", - "Player 17", - "Player 18", - "Player 19", - "Player 20", - "Player 21", - "Player 22", - "Player 23", - "Player 24", - "Player 25", - "Player 26", - "Player 27", - "Player 28", - "Player 29", - "Player 30", - "Player 31", - "Player 32" -}; +// now automatically allocated in D_RegisterClientCommands +// so that it doesn't have to be updated depending on the value of MAXPLAYERS +char player_names[MAXPLAYERS][MAXPLAYERNAME+1]; INT16 rw_maximums[NUM_WEAPONS] = { From f5332ccf8ee9b757e637ff58172351a4e4acc931 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Mon, 12 Aug 2019 19:06:18 +0100 Subject: [PATCH 08/24] Fixed TC_RAINBOW so it doesn't accept invalid colors, whoopsies --- src/r_draw.c | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/src/r_draw.c b/src/r_draw.c index 847a117ec..d8b720caf 100644 --- a/src/r_draw.c +++ b/src/r_draw.c @@ -527,12 +527,18 @@ static void R_GenerateTranslationColormap(UINT8 *dest_colormap, INT32 skinnum, U { switch (skinnum) { - case TC_RAINBOW: - R_RainbowColormap(dest_colormap, color); - return; case TC_ALLWHITE: memset(dest_colormap, 0, NUM_PALETTE_ENTRIES * sizeof(UINT8)); return; + case TC_RAINBOW: + if (color >= MAXTRANSLATIONS) + I_Error("Invalid skin color #%hu.", (UINT16)color); + if (color != SKINCOLOR_NONE) + { + R_RainbowColormap(dest_colormap, color); + return; + } + break; case TC_BLINK: if (color >= MAXTRANSLATIONS) I_Error("Invalid skin color #%hu.", (UINT16)color); @@ -541,21 +547,20 @@ static void R_GenerateTranslationColormap(UINT8 *dest_colormap, INT32 skinnum, U memset(dest_colormap, Color_Index[color-1][3], NUM_PALETTE_ENTRIES * sizeof(UINT8)); return; } - /* FALLTHRU */ - case TC_BOSS: - case TC_METALSONIC: + break; default: - for (i = 0; i < NUM_PALETTE_ENTRIES; i++) - dest_colormap[i] = (UINT8)i; - - // White! - if (skinnum == TC_BOSS) - dest_colormap[31] = 0; - else if (skinnum == TC_METALSONIC) - dest_colormap[159] = 0; - - return; + break; } + + for (i = 0; i < NUM_PALETTE_ENTRIES; i++) + dest_colormap[i] = (UINT8)i; + + // White! + if (skinnum == TC_BOSS) + dest_colormap[31] = 0; + else if (skinnum == TC_METALSONIC) + dest_colormap[159] = 0; + return; } else if (color == SKINCOLOR_NONE) { From 8fa54c1ab4a5d21be0183def857948f6ab6a052a Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Thu, 15 Aug 2019 14:20:52 +0100 Subject: [PATCH 09/24] Modify P_CheckSector with a modified version of Sal's attempted proper fix for polyobjects crushing, so that we only need to check the polyobject's control sector directly in the waypoints code. This time I've definitely fixed that teleport to ground issue I'm pretty sure, I don't get it in my tests at least. --- src/p_map.c | 97 ++++++++++++++++++++++++++++++++++++++++++++++++- src/p_polyobj.c | 8 ++-- 2 files changed, 99 insertions(+), 6 deletions(-) diff --git a/src/p_map.c b/src/p_map.c index 95ad02588..6540a99b2 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -3345,6 +3345,7 @@ static boolean PIT_ChangeSector(mobj_t *thing, boolean realcrush) boolean P_CheckSector(sector_t *sector, boolean crunch) { msecnode_t *n; + size_t i; nofit = false; crushchange = crunch; @@ -3359,9 +3360,57 @@ boolean P_CheckSector(sector_t *sector, boolean crunch) // First, let's see if anything will keep it from crushing. + + // Sal: This stupid function chain is required to fix polyobjects not being able to crush. + // Monster Iestyn: don't use P_CheckSector actually just look for objects in the blockmap instead + validcount++; + + for (i = 0; i < sector->linecount; i++) + { + if (sector->lines[i]->polyobj) + { + polyobj_t *po = sector->lines[i]->polyobj; + if (po->validcount == validcount) + continue; // skip if already checked + if (!(po->flags & POF_SOLID)) + continue; + if (po->lines[0]->backsector == sector) // Make sure you're currently checking the control sector + { + INT32 x, y; + po->validcount = validcount; + + for (y = po->blockbox[BOXBOTTOM]; y <= po->blockbox[BOXTOP]; ++y) + { + for (x = po->blockbox[BOXLEFT]; x <= po->blockbox[BOXRIGHT]; ++x) + { + mobj_t *mo; + + if (x < 0 || y < 0 || x >= bmapwidth || y >= bmapheight) + continue; + + mo = blocklinks[y * bmapwidth + x]; + + for (; mo; mo = mo->bnext) + { + // Monster Iestyn: do we need to check if a mobj has already been checked? ...probably not I suspect + + if (!P_MobjTouchingPolyobj(po, mo)) + continue; + + if (!PIT_ChangeSector(mo, false)) + { + nofit = true; + return nofit; + } + } + } + } + } + } + } + if (sector->numattached) { - size_t i; sector_t *sec; for (i = 0; i < sector->numattached; i++) { @@ -3421,9 +3470,53 @@ boolean P_CheckSector(sector_t *sector, boolean crunch) } while (n); // repeat from scratch until all things left are marked valid // Nothing blocked us, so lets crush for real! + + // Sal: This stupid function chain is required to fix polyobjects not being able to crush. + // Monster Iestyn: don't use P_CheckSector actually just look for objects in the blockmap instead + validcount++; + + for (i = 0; i < sector->linecount; i++) + { + if (sector->lines[i]->polyobj) + { + polyobj_t *po = sector->lines[i]->polyobj; + if (po->validcount == validcount) + continue; // skip if already checked + if (!(po->flags & POF_SOLID)) + continue; + if (po->lines[0]->backsector == sector) // Make sure you're currently checking the control sector + { + INT32 x, y; + po->validcount = validcount; + + for (y = po->blockbox[BOXBOTTOM]; y <= po->blockbox[BOXTOP]; ++y) + { + for (x = po->blockbox[BOXLEFT]; x <= po->blockbox[BOXRIGHT]; ++x) + { + mobj_t *mo; + + if (x < 0 || y < 0 || x >= bmapwidth || y >= bmapheight) + continue; + + mo = blocklinks[y * bmapwidth + x]; + + for (; mo; mo = mo->bnext) + { + // Monster Iestyn: do we need to check if a mobj has already been checked? ...probably not I suspect + + if (!P_MobjTouchingPolyobj(po, mo)) + continue; + + PIT_ChangeSector(mo, true); + return nofit; + } + } + } + } + } + } if (sector->numattached) { - size_t i; sector_t *sec; for (i = 0; i < sector->numattached; i++) { diff --git a/src/p_polyobj.c b/src/p_polyobj.c index 82c57c85b..21d8af5f2 100644 --- a/src/p_polyobj.c +++ b/src/p_polyobj.c @@ -1860,7 +1860,7 @@ void T_PolyObjWaypoint(polywaypoint_t *th) po->lines[0]->backsector->floorheight = target->z - amtz; po->lines[0]->backsector->ceilingheight = target->z + amtz; // Sal: Remember to check your sectors! - P_CheckSector(po->lines[0]->frontsector, (boolean)(po->damage)); + //P_CheckSector(po->lines[0]->frontsector, (boolean)(po->damage)); P_CheckSector(po->lines[0]->backsector, (boolean)(po->damage)); // Apply action to mirroring polyobjects as well start = 0; @@ -1874,7 +1874,7 @@ void T_PolyObjWaypoint(polywaypoint_t *th) po->lines[0]->backsector->floorheight += diffz; // move up/down by same amount as the parent did po->lines[0]->backsector->ceilingheight += diffz; // Sal: Remember to check your sectors! - P_CheckSector(po->lines[0]->frontsector, (boolean)(po->damage)); + //P_CheckSector(po->lines[0]->frontsector, (boolean)(po->damage)); P_CheckSector(po->lines[0]->backsector, (boolean)(po->damage)); } @@ -2037,7 +2037,7 @@ void T_PolyObjWaypoint(polywaypoint_t *th) po->lines[0]->backsector->floorheight += momz; po->lines[0]->backsector->ceilingheight += momz; // Sal: Remember to check your sectors! - P_CheckSector(po->lines[0]->frontsector, (boolean)(po->damage)); // frontsector is NEEDED for crushing + //P_CheckSector(po->lines[0]->frontsector, (boolean)(po->damage)); // frontsector is NEEDED for crushing P_CheckSector(po->lines[0]->backsector, (boolean)(po->damage)); // backsector may not be necessary, but just in case // Apply action to mirroring polyobjects as well @@ -2052,7 +2052,7 @@ void T_PolyObjWaypoint(polywaypoint_t *th) po->lines[0]->backsector->floorheight += momz; po->lines[0]->backsector->ceilingheight += momz; // Sal: Remember to check your sectors! - P_CheckSector(po->lines[0]->frontsector, (boolean)(po->damage)); + //P_CheckSector(po->lines[0]->frontsector, (boolean)(po->damage)); P_CheckSector(po->lines[0]->backsector, (boolean)(po->damage)); } } From 27dd99ae72366c09cf884e45d6bc60238524ae69 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Sat, 3 Aug 2019 19:06:45 +0100 Subject: [PATCH 10/24] Remove commented out P_CheckSector calls and add extra comments explaining the situation --- src/p_polyobj.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/p_polyobj.c b/src/p_polyobj.c index 21d8af5f2..ba01ee442 100644 --- a/src/p_polyobj.c +++ b/src/p_polyobj.c @@ -1860,7 +1860,8 @@ void T_PolyObjWaypoint(polywaypoint_t *th) po->lines[0]->backsector->floorheight = target->z - amtz; po->lines[0]->backsector->ceilingheight = target->z + amtz; // Sal: Remember to check your sectors! - //P_CheckSector(po->lines[0]->frontsector, (boolean)(po->damage)); + // Monster Iestyn: we only need to bother with the back sector, now that P_CheckSector automatically checks the blockmap + // updating objects in the front one too just added teleporting to ground bugs P_CheckSector(po->lines[0]->backsector, (boolean)(po->damage)); // Apply action to mirroring polyobjects as well start = 0; @@ -1874,7 +1875,8 @@ void T_PolyObjWaypoint(polywaypoint_t *th) po->lines[0]->backsector->floorheight += diffz; // move up/down by same amount as the parent did po->lines[0]->backsector->ceilingheight += diffz; // Sal: Remember to check your sectors! - //P_CheckSector(po->lines[0]->frontsector, (boolean)(po->damage)); + // Monster Iestyn: we only need to bother with the back sector, now that P_CheckSector automatically checks the blockmap + // updating objects in the front one too just added teleporting to ground bugs P_CheckSector(po->lines[0]->backsector, (boolean)(po->damage)); } @@ -2037,8 +2039,9 @@ void T_PolyObjWaypoint(polywaypoint_t *th) po->lines[0]->backsector->floorheight += momz; po->lines[0]->backsector->ceilingheight += momz; // Sal: Remember to check your sectors! - //P_CheckSector(po->lines[0]->frontsector, (boolean)(po->damage)); // frontsector is NEEDED for crushing - P_CheckSector(po->lines[0]->backsector, (boolean)(po->damage)); // backsector may not be necessary, but just in case + // Monster Iestyn: we only need to bother with the back sector, now that P_CheckSector automatically checks the blockmap + // updating objects in the front one too just added teleporting to ground bugs + P_CheckSector(po->lines[0]->backsector, (boolean)(po->damage)); // Apply action to mirroring polyobjects as well start = 0; @@ -2052,7 +2055,8 @@ void T_PolyObjWaypoint(polywaypoint_t *th) po->lines[0]->backsector->floorheight += momz; po->lines[0]->backsector->ceilingheight += momz; // Sal: Remember to check your sectors! - //P_CheckSector(po->lines[0]->frontsector, (boolean)(po->damage)); + // Monster Iestyn: we only need to bother with the back sector, now that P_CheckSector automatically checks the blockmap + // updating objects in the front one too just added teleporting to ground bugs P_CheckSector(po->lines[0]->backsector, (boolean)(po->damage)); } } From c8d1dd3be8558408cc82396e09ce35c0856d3936 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Wed, 7 Aug 2019 23:27:26 +0100 Subject: [PATCH 11/24] P_LineOpening: set int32 max/min as defaults for opentop, openbottom etc if a linedef you touched belongs to a polyobjetc. the only thing that really matters in this scenario is the polyobject itself after all! # Conflicts: # src/p_maputl.c --- src/p_maputl.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/p_maputl.c b/src/p_maputl.c index 1be57399c..bd17ecf4a 100644 --- a/src/p_maputl.c +++ b/src/p_maputl.c @@ -517,6 +517,20 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) I_Assert(front != NULL); I_Assert(back != NULL); +#ifdef POLYOBJECTS + if (linedef->polyobj) + { + // set these defaults so that polyobjects don't interfere with collision above or below them + opentop = INT32_MAX; + openbottom = INT32_MIN; + highceiling = INT32_MIN; + lowfloor = INT32_MAX; +#ifdef ESLOPE + opentopslope = openbottomslope = NULL; +#endif + } + else +#endif { // Set open and high/low values here fixed_t frontheight, backheight; From cda81cc1660cded2836e4b9130daadb0edb0c497 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Thu, 8 Aug 2019 16:37:09 +0100 Subject: [PATCH 12/24] Edit a lot of the rest of the polyobject-related code in P_LineOpening to make more sense and be more optimised. * If you collide with a line belonging to a polyobject, you should NEVER have to care about any FOFs that might be present in either sector of the linedef. This could lead to colliding with ghostly FOFs that aren't actually there or something dumb, if someone decided to give either of the polyobject's control sectors FOFs for some reason. We don't want that, obviously. * Polyobjects without POF_CLIPPLANE apparently are supposed to have a top and bottom "physical" height of value INT32_MAX and _MIN respectively, according to P_CheckPosition ...let's be consistent with this. * Finally, there is no more need for that back = front nonsense hack anymore with my changes made. # Conflicts: # src/p_maputl.c --- src/p_maputl.c | 85 ++++++++++++++++++++++++-------------------------- 1 file changed, 40 insertions(+), 45 deletions(-) diff --git a/src/p_maputl.c b/src/p_maputl.c index bd17ecf4a..a98cc0340 100644 --- a/src/p_maputl.c +++ b/src/p_maputl.c @@ -500,19 +500,8 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) return; } - // Treat polyobjects kind of like 3D Floors -#ifdef POLYOBJECTS - if (linedef->polyobj && (linedef->polyobj->flags & POF_TESTHEIGHT)) - { - front = linedef->frontsector; - back = linedef->frontsector; - } - else -#endif - { - front = linedef->frontsector; - back = linedef->backsector; - } + front = linedef->frontsector; + back = linedef->backsector; I_Assert(front != NULL); I_Assert(back != NULL); @@ -636,13 +625,46 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) } } } - - // Check for fake floors in the sector. - if (front->ffloors || back->ffloors #ifdef POLYOBJECTS - || linedef->polyobj + if (linedef->polyobj) + { + // Treat polyobj's backsector like a 3D Floor + if (linedef->polyobj->flags & POF_TESTHEIGHT) + { + const sector_t *polysec = linedef->backsector; + fixed_t polytop, polybottom; + fixed_t delta1, delta2; + + if (linedef->polyobj->flags & POF_CLIPPLANES) + { + polytop = polysec->ceilingheight; + polybottom = polysec->floorheight; + } + else + { + polytop = INT32_MAX; + polybottom = INT32_MIN; + } + + delta1 = abs(mobj->z - (polybottom + ((polytop - polybottom)/2))); + delta2 = abs(thingtop - (polybottom + ((polytop - polybottom)/2))); + + if (polybottom < opentop && delta1 >= delta2) + opentop = polybottom; + else if (polybottom < highceiling && delta1 >= delta2) + highceiling = polybottom; + + if (polytop > openbottom && delta1 < delta2) + openbottom = polytop; + else if (polytop > lowfloor && delta1 < delta2) + lowfloor = polytop; + } + // otherwise don't do anything special, pretend there's nothing else there + } + else #endif - ) + // Check for fake floors in the sector. + if (front->ffloors || back->ffloors) { ffloor_t *rover; @@ -744,33 +766,6 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) } } -#ifdef POLYOBJECTS - // Treat polyobj's backsector like a 3D Floor - if (linedef->polyobj && (linedef->polyobj->flags & POF_TESTHEIGHT)) - { - const sector_t *polysec = linedef->backsector; - - delta1 = abs(mobj->z - (polysec->floorheight + ((polysec->ceilingheight - polysec->floorheight)/2))); - delta2 = abs(thingtop - (polysec->floorheight + ((polysec->ceilingheight - polysec->floorheight)/2))); - if (polysec->floorheight < lowestceiling && delta1 >= delta2) { - lowestceiling = polysec->floorheight; -#ifdef ESLOPE - ceilingslope = NULL; -#endif - } - else if (polysec->floorheight < highestceiling && delta1 >= delta2) - highestceiling = polysec->floorheight; - - if (polysec->ceilingheight > highestfloor && delta1 < delta2) { - highestfloor = polysec->ceilingheight; -#ifdef ESLOPE - floorslope = NULL; -#endif - } - else if (polysec->ceilingheight > lowestfloor && delta1 < delta2) - lowestfloor = polysec->ceilingheight; - } -#endif if (highestceiling < highceiling) highceiling = highestceiling; From bbefc3b7f4c8d48b3b815c1e099f466ad7073631 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Thu, 8 Aug 2019 23:04:47 +0100 Subject: [PATCH 13/24] After looking at the FOF part of P_LineOpening for a while I now realise many of these variables aren't even necessary, so I removed them all. (Naturally I did the same to the camera equivalent) # Conflicts: # src/p_maputl.c --- src/p_maputl.c | 117 +++++++++++++++---------------------------------- 1 file changed, 36 insertions(+), 81 deletions(-) diff --git a/src/p_maputl.c b/src/p_maputl.c index a98cc0340..5368c137e 100644 --- a/src/p_maputl.c +++ b/src/p_maputl.c @@ -418,10 +418,6 @@ void P_CameraLineOpening(line_t *linedef) if (front->ffloors || back->ffloors) { ffloor_t *rover; - fixed_t highestceiling = highceiling; - fixed_t lowestceiling = opentop; - fixed_t highestfloor = openbottom; - fixed_t lowestfloor = lowfloor; fixed_t delta1, delta2; // Check for frontsector's fake floors @@ -437,15 +433,15 @@ void P_CameraLineOpening(line_t *linedef) delta1 = abs(mapcampointer->z - (bottomheight + ((topheight - bottomheight)/2))); delta2 = abs(thingtop - (bottomheight + ((topheight - bottomheight)/2))); - if (bottomheight < lowestceiling && delta1 >= delta2) - lowestceiling = bottomheight; - else if (bottomheight < highestceiling && delta1 >= delta2) - highestceiling = bottomheight; + if (bottomheight < opentop && delta1 >= delta2) + opentop = bottomheight; + else if (bottomheight < highceiling && delta1 >= delta2) + highceiling = bottomheight; - if (topheight > highestfloor && delta1 < delta2) - highestfloor = topheight; - else if (topheight > lowestfloor && delta1 < delta2) - lowestfloor = topheight; + if (topheight > openbottom && delta1 < delta2) + openbottom = topheight; + else if (topheight > lowfloor && delta1 < delta2) + lowfloor = topheight; } // Check for backsectors fake floors @@ -461,28 +457,16 @@ void P_CameraLineOpening(line_t *linedef) delta1 = abs(mapcampointer->z - (bottomheight + ((topheight - bottomheight)/2))); delta2 = abs(thingtop - (bottomheight + ((topheight - bottomheight)/2))); - if (bottomheight < lowestceiling && delta1 >= delta2) - lowestceiling = bottomheight; - else if (bottomheight < highestceiling && delta1 >= delta2) - highestceiling = bottomheight; + if (bottomheight < opentop && delta1 >= delta2) + opentop = bottomheight; + else if (bottomheight < highceiling && delta1 >= delta2) + highceiling = bottomheight; - if (topheight > highestfloor && delta1 < delta2) - highestfloor = topheight; - else if (topheight > lowestfloor && delta1 < delta2) - lowestfloor = topheight; + if (topheight > openbottom && delta1 < delta2) + openbottom = topheight; + else if (topheight > lowfloor && delta1 < delta2) + lowfloor = topheight; } - - if (highestceiling < highceiling) - highceiling = highestceiling; - - if (highestfloor > openbottom) - openbottom = highestfloor; - - if (lowestceiling < opentop) - opentop = lowestceiling; - - if (lowestfloor > lowfloor) - lowfloor = lowestfloor; } openrange = opentop - openbottom; return; @@ -667,16 +651,7 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) if (front->ffloors || back->ffloors) { ffloor_t *rover; - - fixed_t highestceiling = highceiling; - fixed_t lowestceiling = opentop; - fixed_t highestfloor = openbottom; - fixed_t lowestfloor = lowfloor; fixed_t delta1, delta2; -#ifdef ESLOPE - pslope_t *ceilingslope = opentopslope; - pslope_t *floorslope = openbottomslope; -#endif // Check for frontsector's fake floors for (rover = front->ffloors; rover; rover = rover->next) @@ -699,26 +674,26 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) if (delta1 >= delta2 && !(rover->flags & FF_PLATFORM)) // thing is below FOF { - if (bottomheight < lowestceiling) { - lowestceiling = bottomheight; + if (bottomheight < opentop) { + opentop = bottomheight; #ifdef ESLOPE - ceilingslope = *rover->b_slope; + opentopslope = *rover->b_slope; #endif } - else if (bottomheight < highestceiling) - highestceiling = bottomheight; + else if (bottomheight < highceiling) + highceiling = bottomheight; } if (delta1 < delta2 && !(rover->flags & FF_REVERSEPLATFORM)) // thing is above FOF { - if (topheight > highestfloor) { - highestfloor = topheight; + if (topheight > openbottom) { + openbottom = topheight; #ifdef ESLOPE - floorslope = *rover->t_slope; + openbottomslope = *rover->t_slope; #endif } - else if (topheight > lowestfloor) - lowestfloor = topheight; + else if (topheight > lowfloor) + lowfloor = topheight; } } @@ -743,48 +718,28 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) if (delta1 >= delta2 && !(rover->flags & FF_PLATFORM)) // thing is below FOF { - if (bottomheight < lowestceiling) { - lowestceiling = bottomheight; + if (bottomheight < opentop) { + opentop = bottomheight; #ifdef ESLOPE - ceilingslope = *rover->b_slope; + opentopslope = *rover->b_slope; #endif } - else if (bottomheight < highestceiling) - highestceiling = bottomheight; + else if (bottomheight < highceiling) + highceiling = bottomheight; } if (delta1 < delta2 && !(rover->flags & FF_REVERSEPLATFORM)) // thing is above FOF { - if (topheight > highestfloor) { - highestfloor = topheight; + if (topheight > openbottom) { + openbottom = topheight; #ifdef ESLOPE - floorslope = *rover->t_slope; + openbottomslope = *rover->t_slope; #endif } - else if (topheight > lowestfloor) - lowestfloor = topheight; + else if (topheight > lowfloor) + lowfloor = topheight; } } - - if (highestceiling < highceiling) - highceiling = highestceiling; - - if (highestfloor > openbottom) { - openbottom = highestfloor; -#ifdef ESLOPE - openbottomslope = floorslope; -#endif - } - - if (lowestceiling < opentop) { - opentop = lowestceiling; -#ifdef ESLOPE - opentopslope = ceilingslope; -#endif - } - - if (lowestfloor > lowfloor) - lowfloor = lowestfloor; } } From d55790097fbcf81b15f28f2f8fe88dcfb268b798 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Sun, 11 Nov 2018 21:01:55 +0000 Subject: [PATCH 14/24] split MT_TAILSOVERLAY handling code into a function of its own, since there's so much of it # Conflicts: # src/p_user.c --- src/p_user.c | 369 ++++++++++++++++++++++++++------------------------- 1 file changed, 187 insertions(+), 182 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index b74cafd21..862aa1baa 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -10134,6 +10134,7 @@ void P_DoPityCheck(player_t *player) } } + static sector_t *P_GetMinecartSector(fixed_t x, fixed_t y, fixed_t z, fixed_t *nz) { sector_t *sec = R_PointInSubsector(x, y)->sector; @@ -10546,6 +10547,191 @@ static void P_MinecartThink(player_t *player) player->powers[pw_flashing]--; } +// Handle Tails' fluff +static void P_DoTailsOverlay(player_t *player, mobj_t *tails) +{ + // init... + boolean smilesonground = P_IsObjectOnGround(player->mo); + angle_t horizangle = player->drawangle; + fixed_t zoffs = 0; + fixed_t backwards = -1*FRACUNIT; + boolean doroll = (player->panim == PA_ROLL || player->panim == PA_JUMP); + angle_t rollangle; + boolean panimchange; + INT32 ticnum = 0; + statenum_t chosenstate; + + if (!tails->skin) + { + tails->skin = player->mo->skin; + P_SetMobjState(tails, S_TAILSOVERLAY_STAND); + tails->movecount = -1; + } + + panimchange = (tails->movecount != (INT32)player->panim); + + // initial position... + if (doroll) + { + fixed_t testval, zdist; + if (player->speed < FRACUNIT) + testval = FRACUNIT; + else + { + testval = (FixedMul(player->speed, FINECOSINE((horizangle - R_PointToAngle2(0, 0, player->rmomx, player->rmomy)) >> ANGLETOFINESHIFT))); + if (testval < FRACUNIT) + testval = FRACUNIT; + } + if (smilesonground && !player->mo->reactiontime) + zdist = (player->mo->z - tails->threshold); + else + zdist = player->mo->momz; + rollangle = R_PointToAngle2(0, 0, testval, -P_MobjFlip(player->mo)*zdist); + zoffs = 3*FRACUNIT + 12*FINESINE(rollangle >> ANGLETOFINESHIFT); + backwards = -12*FINECOSINE(rollangle >> ANGLETOFINESHIFT); + } + else if (player->panim == PA_RUN) + backwards = -5*FRACUNIT; + else if (player->panim == PA_SPRING) + { + zoffs += 4*FRACUNIT; + backwards /= 2; + } + else if (player->panim == PA_PAIN) + backwards /= 16; + else if (player->mo->state-states == S_PLAY_GASP) + { + backwards /= 16; + zoffs += 12*FRACUNIT; + } + else if (player->mo->state-states == S_PLAY_EDGE) + { + backwards /= 16; + zoffs = 3*FRACUNIT; + } + else if (player->panim == PA_ABILITY2) + { + zoffs = -7*FRACUNIT; + backwards = -9*FRACUNIT; + } + else if (player->mo->sprite2 == SPR2_FLY || player->mo->sprite2 == SPR2_TIRE) + backwards = -5*FRACUNIT; + + // sprite... + if (doroll) + { + statenum_t add = ((rollangle > ANGLE_180) ? 2 : 0); + if (add) + rollangle = InvAngle(rollangle); + rollangle += ANG15; // modify the thresholds to be nice clean numbers + if (rollangle > ANG60) + chosenstate = S_TAILSOVERLAY_PLUS60DEGREES + add; + else if (rollangle > ANG30) + chosenstate = S_TAILSOVERLAY_PLUS30DEGREES + add; + else + chosenstate = S_TAILSOVERLAY_0DEGREES; + } + else if (player->panim == PA_SPRING) + chosenstate = S_TAILSOVERLAY_MINUS60DEGREES; + else if (player->panim == PA_FALL || player->mo->state-states == S_PLAY_RIDE) + chosenstate = S_TAILSOVERLAY_PLUS60DEGREES; + else if (player->panim == PA_PAIN) + chosenstate = S_TAILSOVERLAY_PAIN; + else if (player->mo->state-states == S_PLAY_GASP) + 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_WALK) + { + if (!smilesonground || player->mo->state-states == S_PLAY_SKID) + chosenstate = S_TAILSOVERLAY_PLUS30DEGREES; + else if (player->speed >= FixedMul(player->runspeed/2, player->mo->scale)) + chosenstate = S_TAILSOVERLAY_0DEGREES; + else + chosenstate = S_TAILSOVERLAY_MINUS30DEGREES; + } + else if (player->mo->sprite2 == SPR2_FLY) + chosenstate = S_TAILSOVERLAY_FLY; + else if (player->mo->sprite2 == SPR2_TIRE) + chosenstate = S_TAILSOVERLAY_TIRE; + else if (player->panim == PA_ABILITY2) + chosenstate = S_TAILSOVERLAY_PLUS30DEGREES; + else if (player->panim == PA_IDLE) + chosenstate = S_TAILSOVERLAY_STAND; + else + chosenstate = S_INVISIBLE; + + // state... + if (panimchange) + { + tails->sprite2 = -1; + P_SetMobjState(tails, chosenstate); + } + else + { + if (tails->state != states+chosenstate) + { + if (states[chosenstate].sprite == SPR_PLAY) + tails->sprite2 = P_GetSkinSprite2(((skin_t *)tails->skin), (states[chosenstate].frame & FF_FRAMEMASK), player); + P_SetMobjState(tails, chosenstate); + } + } + + if (player->fly1 != 0 && player->powers[pw_tailsfly] != 0 && !smilesonground) + P_SetMobjState(tails, chosenstate); + + // animation... + if (player->panim == PA_SPRING || player->panim == PA_FALL || player->mo->state-states == S_PLAY_RIDE) + { + if (FixedDiv(abs(player->mo->momz), player->mo->scale) < 20<panim == PA_PAIN) + ticnum = 2; + else if (player->mo->state-states == S_PLAY_GASP) + tails->tics = -1; + else if (player->mo->sprite2 == SPR2_TIRE) + ticnum = 4; + else if (player->panim != PA_IDLE) + ticnum = player->mo->tics; + + if (ticnum && tails->tics > ticnum) + tails->tics = ticnum; + + // final handling... + tails->color = player->mo->color; + tails->threshold = player->mo->z; + tails->movecount = player->panim; + tails->angle = horizangle; + P_SetScale(tails, player->mo->scale); + tails->destscale = player->mo->destscale; + tails->radius = player->mo->radius; + tails->height = player->mo->height; + zoffs = FixedMul(zoffs, tails->scale); + + if (player->mo->eflags & MFE_VERTICALFLIP) + { + tails->eflags |= MFE_VERTICALFLIP; + tails->flags2 |= MF2_OBJECTFLIP; + zoffs = player->mo->height - tails->height - zoffs; + } + else + { + tails->eflags &= ~MFE_VERTICALFLIP; + tails->flags2 &= ~MF2_OBJECTFLIP; + } + + P_UnsetThingPosition(tails); + tails->x = player->mo->x + P_ReturnThrustX(tails, tails->angle, FixedMul(backwards, tails->scale)); + tails->y = player->mo->y + P_ReturnThrustY(tails, tails->angle, FixedMul(backwards, tails->scale)); + tails->z = player->mo->z + zoffs; + P_SetThingPosition(tails); +} + // // P_PlayerThink // @@ -11684,188 +11870,7 @@ void P_PlayerAfterThink(player_t *player) switch (player->followmobj->type) { case MT_TAILSOVERLAY: // c: - { - // init... - boolean smilesonground = P_IsObjectOnGround(player->mo); - angle_t horizangle = player->drawangle; - fixed_t zoffs = 0; - fixed_t backwards = -1*FRACUNIT; - boolean doroll = (player->panim == PA_ROLL || player->panim == PA_JUMP); - angle_t rollangle; - boolean panimchange; - INT32 ticnum = 0; - statenum_t chosenstate; - - if (!player->followmobj->skin) - { - player->followmobj->skin = player->mo->skin; - P_SetMobjState(player->followmobj, S_TAILSOVERLAY_STAND); - player->followmobj->movecount = -1; - } - - panimchange = (player->followmobj->movecount != (INT32)player->panim); - - // initial position... - if (doroll) - { - fixed_t testval, zdist; - if (player->speed < FRACUNIT) - testval = FRACUNIT; - else - { - testval = (FixedMul(player->speed, FINECOSINE((horizangle - R_PointToAngle2(0, 0, player->rmomx, player->rmomy)) >> ANGLETOFINESHIFT))); - if (testval < FRACUNIT) - testval = FRACUNIT; - } - if (smilesonground && !player->mo->reactiontime) - zdist = (player->mo->z - player->followmobj->threshold); - else - zdist = player->mo->momz; - rollangle = R_PointToAngle2(0, 0, testval, -P_MobjFlip(player->mo)*zdist); - zoffs = 3*FRACUNIT + 12*FINESINE(rollangle >> ANGLETOFINESHIFT); - backwards = -12*FINECOSINE(rollangle >> ANGLETOFINESHIFT); - } - else if (player->panim == PA_RUN) - backwards = -5*FRACUNIT; - else if (player->panim == PA_SPRING) - { - zoffs += 4*FRACUNIT; - backwards /= 2; - } - else if (player->panim == PA_PAIN) - backwards /= 16; - else if (player->mo->state-states == S_PLAY_GASP) - { - backwards /= 16; - zoffs += 12*FRACUNIT; - } - else if (player->mo->state-states == S_PLAY_EDGE) - { - backwards /= 16; - zoffs = 3*FRACUNIT; - } - else if (player->panim == PA_ABILITY2) - { - zoffs = -7*FRACUNIT; - backwards = -9*FRACUNIT; - } - else if (player->mo->sprite2 == SPR2_FLY || player->mo->sprite2 == SPR2_TIRE) - backwards = -5*FRACUNIT; - - // sprite... - if (doroll) - { - statenum_t add = ((rollangle > ANGLE_180) ? 2 : 0); - if (add) - rollangle = InvAngle(rollangle); - rollangle += ANG15; // modify the thresholds to be nice clean numbers - if (rollangle > ANG60) - chosenstate = S_TAILSOVERLAY_PLUS60DEGREES + add; - else if (rollangle > ANG30) - chosenstate = S_TAILSOVERLAY_PLUS30DEGREES + add; - else - chosenstate = S_TAILSOVERLAY_0DEGREES; - } - else if (player->panim == PA_SPRING) - chosenstate = S_TAILSOVERLAY_MINUS60DEGREES; - else if (player->panim == PA_FALL || player->mo->state-states == S_PLAY_RIDE) - chosenstate = S_TAILSOVERLAY_PLUS60DEGREES; - else if (player->panim == PA_PAIN) - chosenstate = S_TAILSOVERLAY_PAIN; - else if (player->mo->state-states == S_PLAY_GASP) - 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_WALK) - { - if (!smilesonground || player->mo->state-states == S_PLAY_SKID) - chosenstate = S_TAILSOVERLAY_PLUS30DEGREES; - else if (player->speed >= FixedMul(player->runspeed/2, player->mo->scale)) - chosenstate = S_TAILSOVERLAY_0DEGREES; - else - chosenstate = S_TAILSOVERLAY_MINUS30DEGREES; - } - else if (player->mo->sprite2 == SPR2_FLY) - chosenstate = S_TAILSOVERLAY_FLY; - else if (player->mo->sprite2 == SPR2_TIRE) - chosenstate = S_TAILSOVERLAY_TIRE; - else if (player->panim == PA_ABILITY2) - chosenstate = S_TAILSOVERLAY_PLUS30DEGREES; - else if (player->panim == PA_IDLE) - chosenstate = S_TAILSOVERLAY_STAND; - else - chosenstate = S_INVISIBLE; - - // state... - if (panimchange) - { - player->followmobj->sprite2 = -1; - P_SetMobjState(player->followmobj, chosenstate); - } - else - { - if (player->followmobj->state != states+chosenstate) - { - if (states[chosenstate].sprite == SPR_PLAY) - player->followmobj->sprite2 = P_GetSkinSprite2(((skin_t *)player->followmobj->skin), (states[chosenstate].frame & FF_FRAMEMASK), player); - P_SetMobjState(player->followmobj, chosenstate); - } - } - - if (player->fly1 != 0 && player->powers[pw_tailsfly] != 0 && !smilesonground) - P_SetMobjState(player->followmobj, chosenstate); - - // animation... - if (player->panim == PA_SPRING || player->panim == PA_FALL || player->mo->state-states == S_PLAY_RIDE) - { - if (FixedDiv(abs(player->mo->momz), player->mo->scale) < 20<panim == PA_PAIN) - ticnum = 2; - else if (player->mo->state-states == S_PLAY_GASP) - player->followmobj->tics = -1; - else if (player->mo->sprite2 == SPR2_TIRE) - ticnum = 4; - else if (player->panim != PA_IDLE) - ticnum = player->mo->tics; - - if (ticnum && player->followmobj->tics > ticnum) - player->followmobj->tics = ticnum; - - // final handling... - player->followmobj->color = player->mo->color; - player->followmobj->threshold = player->mo->z; - player->followmobj->movecount = player->panim; - player->followmobj->angle = horizangle; - P_SetScale(player->followmobj, player->mo->scale); - player->followmobj->destscale = player->mo->destscale; - player->followmobj->radius = player->mo->radius; - player->followmobj->height = player->mo->height; - zoffs = FixedMul(zoffs, player->followmobj->scale); - - if (player->mo->eflags & MFE_VERTICALFLIP) - { - player->followmobj->eflags |= MFE_VERTICALFLIP; - player->followmobj->flags2 |= MF2_OBJECTFLIP; - zoffs = player->mo->height - player->followmobj->height - zoffs; - } - else - { - player->followmobj->eflags &= ~MFE_VERTICALFLIP; - player->followmobj->flags2 &= ~MF2_OBJECTFLIP; - } - - P_UnsetThingPosition(player->followmobj); - player->followmobj->x = player->mo->x + P_ReturnThrustX(player->followmobj, player->followmobj->angle, FixedMul(backwards, player->followmobj->scale)); - player->followmobj->y = player->mo->y + P_ReturnThrustY(player->followmobj, player->followmobj->angle, FixedMul(backwards, player->followmobj->scale)); - player->followmobj->z = player->mo->z + zoffs; - P_SetThingPosition(player->followmobj); - } + P_DoTailsOverlay(player, player->followmobj); break; default: var1 = 1; From 5c2786b1632962be9717071b8400591d6c7d6afc Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Mon, 12 Nov 2018 11:30:51 +0000 Subject: [PATCH 15/24] Make the various carry types' handling code into a switch case --- src/p_user.c | 251 +++++++++++++++++++++++++++------------------------ 1 file changed, 135 insertions(+), 116 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index 862aa1baa..09ac0a0ee 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -11686,130 +11686,149 @@ void P_PlayerAfterThink(player_t *player) /* if (player->powers[pw_carry] == CR_NONE && player->mo->tracer && !player->homing) P_SetTarget(&player->mo->tracer, NULL); else */ - if (player->powers[pw_carry] == CR_PLAYER && player->mo->tracer) + if (player->mo->tracer) { - player->mo->height = FixedDiv(P_GetPlayerHeight(player), FixedDiv(14*FRACUNIT,10*FRACUNIT)); - - if (player->mo->tracer->player && !(player->mo->tracer->player->pflags & PF_CANCARRY)) - player->powers[pw_carry] = CR_NONE; - - if (player->mo->eflags & MFE_VERTICALFLIP) + switch (player->powers[pw_carry]) { - if ((player->mo->tracer->z + player->mo->tracer->height + player->mo->height + FixedMul(FRACUNIT, player->mo->scale)) <= player->mo->tracer->ceilingz - && (player->mo->tracer->eflags & MFE_VERTICALFLIP)) // Reverse gravity check for the carrier - Flame - player->mo->z = player->mo->tracer->z + player->mo->tracer->height + FixedMul(FRACUNIT, player->mo->scale); - else - player->powers[pw_carry] = CR_NONE; - } - else - { - if ((player->mo->tracer->z - player->mo->height - FixedMul(FRACUNIT, player->mo->scale)) >= player->mo->tracer->floorz - && !(player->mo->tracer->eflags & MFE_VERTICALFLIP)) // Correct gravity check for the carrier - Flame - player->mo->z = player->mo->tracer->z - player->mo->height - FixedMul(FRACUNIT, player->mo->scale); - else - player->powers[pw_carry] = CR_NONE; - } - - if (player->mo->tracer->health <= 0) - player->powers[pw_carry] = CR_NONE; - else - { - P_TryMove(player->mo, player->mo->tracer->x, player->mo->tracer->y, true); - player->mo->momx = player->mo->tracer->momx; - player->mo->momy = player->mo->tracer->momy; - player->mo->momz = player->mo->tracer->momz; - } - - if (gametype == GT_COOP) - { - player->mo->angle = player->mo->tracer->angle; - - if (!demoplayback || P_AnalogMove(player)) + case CR_PLAYER: // being carried by a flying character (such as Tails) { - if (player == &players[consoleplayer]) - localangle = player->mo->angle; - else if (player == &players[secondarydisplayplayer]) - localangle2 = player->mo->angle; - } - } + mobj_t *tails = player->mo->tracer; + player->mo->height = FixedDiv(P_GetPlayerHeight(player), FixedDiv(14*FRACUNIT,10*FRACUNIT)); - if (P_AproxDistance(player->mo->x - player->mo->tracer->x, player->mo->y - player->mo->tracer->y) > player->mo->radius) - player->powers[pw_carry] = CR_NONE; + if (tails->player && !(tails->player->pflags & PF_CANCARRY)) + player->powers[pw_carry] = CR_NONE; - if (player->powers[pw_carry] != CR_NONE) - { - if (player->mo->state-states != S_PLAY_RIDE) - P_SetPlayerMobjState(player->mo, S_PLAY_RIDE); - } - else - P_SetTarget(&player->mo->tracer, NULL); - - if (player-players == consoleplayer && botingame) - CV_SetValue(&cv_analog2, (player->powers[pw_carry] != CR_PLAYER)); - } - else if (player->powers[pw_carry] == CR_GENERIC && player->mo->tracer) - { - // tracer is what you're hanging onto - P_UnsetThingPosition(player->mo); - player->mo->x = player->mo->tracer->x; - player->mo->y = player->mo->tracer->y; - if (player->mo->eflags & MFE_VERTICALFLIP) - player->mo->z = player->mo->tracer->z + player->mo->tracer->height - FixedDiv(player->mo->height, 3*FRACUNIT); - else - player->mo->z = player->mo->tracer->z - FixedDiv(player->mo->height, 3*FRACUNIT/2); - player->mo->momx = player->mo->momy = player->mo->momz = 0; - P_SetThingPosition(player->mo); - if (player->mo->state-states != S_PLAY_RIDE) - P_SetPlayerMobjState(player->mo, S_PLAY_RIDE); - - // Controllable missile - if (player->mo->tracer->type == MT_BLACKEGGMAN_MISSILE) - { - if (cmd->forwardmove > 0) - player->mo->tracer->momz += FixedMul(FRACUNIT/4, player->mo->tracer->scale); - else if (cmd->forwardmove < 0) - player->mo->tracer->momz -= FixedMul(FRACUNIT/4, player->mo->tracer->scale); - - player->mo->tracer->angle = player->mo->angle; - P_InstaThrust(player->mo->tracer, player->mo->tracer->angle, FixedMul(player->mo->tracer->info->speed, player->mo->tracer->scale)); - - if (player->mo->z <= player->mo->floorz - || player->mo->tracer->health <= 0) - { - player->powers[pw_carry] = CR_NONE; - P_SetTarget(&player->mo->tracer, NULL); - } - } - } - else if (player->powers[pw_carry] == CR_MACESPIN && player->mo->tracer && player->mo->tracer->tracer) - { - player->mo->height = P_GetPlayerSpinHeight(player); - // tracer is what you're hanging onto.... - player->mo->momx = (player->mo->tracer->x - player->mo->x)*2; - player->mo->momy = (player->mo->tracer->y - player->mo->y)*2; - player->mo->momz = (player->mo->tracer->z - (player->mo->height-player->mo->tracer->height/2) - player->mo->z)*2; - P_TeleportMove(player->mo, player->mo->tracer->x, player->mo->tracer->y, player->mo->tracer->z - (player->mo->height-player->mo->tracer->height/2)); - if (!player->powers[pw_flashing]) // handle getting hurt - { - player->pflags |= PF_JUMPED; - player->pflags &= ~PF_NOJUMPDAMAGE; - player->secondjump = 0; - player->pflags &= ~PF_THOKKED; - - if ((player->mo->tracer->tracer->flags & MF_SLIDEME) // Noclimb on chain parameters gives this - && !(twodlevel || player->mo->flags2 & MF2_TWOD)) // why on earth would you want to turn them in 2D mode? - { - player->mo->tracer->tracer->angle += cmd->sidemove<mo->angle += cmd->sidemove< ANGLE_MAX - - if (!demoplayback || P_AnalogMove(player)) + if (player->mo->eflags & MFE_VERTICALFLIP) { - if (player == &players[consoleplayer]) - localangle = player->mo->angle; // Adjust the local control angle. - else if (player == &players[secondarydisplayplayer]) - localangle2 = player->mo->angle; + if ((tails->z + tails->height + player->mo->height + FixedMul(FRACUNIT, player->mo->scale)) <= tails->ceilingz + && (tails->eflags & MFE_VERTICALFLIP)) // Reverse gravity check for the carrier - Flame + player->mo->z = tails->z + tails->height + FixedMul(FRACUNIT, player->mo->scale); + else + player->powers[pw_carry] = CR_NONE; } + else + { + if ((tails->z - player->mo->height - FixedMul(FRACUNIT, player->mo->scale)) >= tails->floorz + && !(tails->eflags & MFE_VERTICALFLIP)) // Correct gravity check for the carrier - Flame + player->mo->z = tails->z - player->mo->height - FixedMul(FRACUNIT, player->mo->scale); + else + player->powers[pw_carry] = CR_NONE; + } + + if (tails->health <= 0) + player->powers[pw_carry] = CR_NONE; + else + { + P_TryMove(player->mo, tails->x, tails->y, true); + player->mo->momx = tails->momx; + player->mo->momy = tails->momy; + player->mo->momz = tails->momz; + } + + if (gametype == GT_COOP) + { + player->mo->angle = tails->angle; + + if (!demoplayback || P_AnalogMove(player)) + { + if (player == &players[consoleplayer]) + localangle = player->mo->angle; + else if (player == &players[secondarydisplayplayer]) + localangle2 = player->mo->angle; + } + } + + 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->mo->state-states != S_PLAY_RIDE) + P_SetPlayerMobjState(player->mo, S_PLAY_RIDE); + } + else + P_SetTarget(&player->mo->tracer, NULL); + + if (player-players == consoleplayer && botingame) + CV_SetValue(&cv_analog2, (player->powers[pw_carry] != CR_PLAYER)); + break; } + case CR_GENERIC: // being carried by some generic item + { + mobj_t *item = player->mo->tracer; + // tracer is what you're hanging onto + P_UnsetThingPosition(player->mo); + player->mo->x = item->x; + player->mo->y = item->y; + if (player->mo->eflags & MFE_VERTICALFLIP) + player->mo->z = item->z + item->height - FixedDiv(player->mo->height, 3*FRACUNIT); + else + player->mo->z = item->z - FixedDiv(player->mo->height, 3*FRACUNIT/2); + player->mo->momx = player->mo->momy = player->mo->momz = 0; + P_SetThingPosition(player->mo); + if (player->mo->state-states != S_PLAY_RIDE) + P_SetPlayerMobjState(player->mo, S_PLAY_RIDE); + + // Controllable missile + if (item->type == MT_BLACKEGGMAN_MISSILE) + { + if (cmd->forwardmove > 0) + item->momz += FixedMul(FRACUNIT/4, item->scale); + else if (cmd->forwardmove < 0) + item->momz -= FixedMul(FRACUNIT/4, item->scale); + + item->angle = player->mo->angle; + P_InstaThrust(item, item->angle, FixedMul(item->info->speed, item->scale)); + + if (player->mo->z <= player->mo->floorz || item->health <= 0) + { + player->powers[pw_carry] = CR_NONE; + P_SetTarget(&player->mo->tracer, NULL); + } + } + break; + } + case CR_MACESPIN: // being carried by a spinning chain + { + mobj_t *chain; + mobj_t *macecenter; + if (!player->mo->tracer->tracer) // can't spin around a point if... there is no point in doing so + break; + chain = player->mo->tracer; + macecenter = player->mo->tracer->tracer; + + player->mo->height = P_GetPlayerSpinHeight(player); + // tracer is what you're hanging onto.... + player->mo->momx = (chain->x - player->mo->x)*2; + player->mo->momy = (chain->y - player->mo->y)*2; + player->mo->momz = (chain->z - (player->mo->height-chain->height/2) - player->mo->z)*2; + P_TeleportMove(player->mo, chain->x, chain->y, chain->z - (player->mo->height-chain->height/2)); + if (!player->powers[pw_flashing]) // handle getting hurt + { + player->pflags |= PF_JUMPED; + player->pflags &= ~PF_NOJUMPDAMAGE; + player->secondjump = 0; + player->pflags &= ~PF_THOKKED; + + if ((macecenter->flags & MF_SLIDEME) // Noclimb on chain parameters gives this + && !(twodlevel || player->mo->flags2 & MF2_TWOD)) // why on earth would you want to turn them in 2D mode? + { + macecenter->angle += cmd->sidemove<mo->angle += cmd->sidemove< ANGLE_MAX + + if (!demoplayback || P_AnalogMove(player)) + { + if (player == &players[consoleplayer]) + localangle = player->mo->angle; // Adjust the local control angle. + else if (player == &players[secondarydisplayplayer]) + localangle2 = player->mo->angle; + } + } + } + break; + } + default: + break; } } From ae9ecef5920b0383ca7f5e5b7fecc70dddb4b6b3 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Fri, 16 Aug 2019 14:54:01 +0100 Subject: [PATCH 16/24] Use P_MobjInsidePolyobj instead of P_MobjTouchingPolyobj, so that you can be crushed by the polyobject's middle rather than just its edges --- 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 6540a99b2..3ce82b4da 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -3394,7 +3394,7 @@ boolean P_CheckSector(sector_t *sector, boolean crunch) { // Monster Iestyn: do we need to check if a mobj has already been checked? ...probably not I suspect - if (!P_MobjTouchingPolyobj(po, mo)) + if (!P_MobjInsidePolyobj(po, mo)) continue; if (!PIT_ChangeSector(mo, false)) @@ -3504,7 +3504,7 @@ boolean P_CheckSector(sector_t *sector, boolean crunch) { // Monster Iestyn: do we need to check if a mobj has already been checked? ...probably not I suspect - if (!P_MobjTouchingPolyobj(po, mo)) + if (!P_MobjInsidePolyobj(po, mo)) continue; PIT_ChangeSector(mo, true); From e52a314ddb7d3f587638a4d54b7800251e20346f Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Fri, 16 Aug 2019 20:14:01 +0100 Subject: [PATCH 17/24] Update version to 2.1.25 --- CMakeLists.txt | 2 +- appveyor.yml | 2 +- src/doomdef.h | 8 ++++---- src/sdl/macosx/Srb2mac.xcodeproj/project.pbxproj | 4 ++-- src/sdl12/macosx/Srb2mac.xcodeproj/project.pbxproj | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b70221859..96e32a06d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.0) # DO NOT CHANGE THIS SRB2 STRING! Some variable names depend on this string. # Version change is fine. project(SRB2 - VERSION 2.1.24 + VERSION 2.1.25 LANGUAGES C) if(${PROJECT_SOURCE_DIR} MATCHES ${PROJECT_BINARY_DIR}) diff --git a/appveyor.yml b/appveyor.yml index b37bd1a65..d58976fd5 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,4 +1,4 @@ -version: 2.1.24.{branch}-{build} +version: 2.1.25.{branch}-{build} os: MinGW environment: diff --git a/src/doomdef.h b/src/doomdef.h index 6b6afbf1b..1c034f5f7 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -150,9 +150,9 @@ extern FILE *logstream; // we use comprevision and compbranch instead. #else #define VERSION 201 // Game version -#define SUBVERSION 24 // more precise version number -#define VERSIONSTRING "v2.1.24" -#define VERSIONSTRINGW L"v2.1.24" +#define SUBVERSION 25 // more precise version number +#define VERSIONSTRING "v2.1.25" +#define VERSIONSTRINGW L"v2.1.25" // Hey! If you change this, add 1 to the MODVERSION below! // Otherwise we can't force updates! #endif @@ -217,7 +217,7 @@ extern FILE *logstream; // 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.1.0 is not version "1". -#define MODVERSION 29 +#define MODVERSION 30 // To version config.cfg, MAJOREXECVERSION is set equal to MODVERSION automatically. // Increment MINOREXECVERSION whenever a config change is needed that does not correspond diff --git a/src/sdl/macosx/Srb2mac.xcodeproj/project.pbxproj b/src/sdl/macosx/Srb2mac.xcodeproj/project.pbxproj index 878db3d8d..9297833e2 100644 --- a/src/sdl/macosx/Srb2mac.xcodeproj/project.pbxproj +++ b/src/sdl/macosx/Srb2mac.xcodeproj/project.pbxproj @@ -1219,7 +1219,7 @@ C01FCF4B08A954540054247B /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - CURRENT_PROJECT_VERSION = 2.1.24; + CURRENT_PROJECT_VERSION = 2.1.25; GCC_PREPROCESSOR_DEFINITIONS = ( "$(inherited)", NORMALSRB2, @@ -1231,7 +1231,7 @@ C01FCF4C08A954540054247B /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - CURRENT_PROJECT_VERSION = 2.1.24; + CURRENT_PROJECT_VERSION = 2.1.25; GCC_ENABLE_FIX_AND_CONTINUE = NO; GCC_GENERATE_DEBUGGING_SYMBOLS = NO; GCC_PREPROCESSOR_DEFINITIONS = ( diff --git a/src/sdl12/macosx/Srb2mac.xcodeproj/project.pbxproj b/src/sdl12/macosx/Srb2mac.xcodeproj/project.pbxproj index 6b3997b1f..d67903819 100644 --- a/src/sdl12/macosx/Srb2mac.xcodeproj/project.pbxproj +++ b/src/sdl12/macosx/Srb2mac.xcodeproj/project.pbxproj @@ -1219,7 +1219,7 @@ C01FCF4B08A954540054247B /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - CURRENT_PROJECT_VERSION = 2.1.24; + CURRENT_PROJECT_VERSION = 2.1.25; GCC_PREPROCESSOR_DEFINITIONS = ( "$(inherited)", NORMALSRB2, @@ -1231,7 +1231,7 @@ C01FCF4C08A954540054247B /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - CURRENT_PROJECT_VERSION = 2.1.24; + CURRENT_PROJECT_VERSION = 2.1.25; GCC_ENABLE_FIX_AND_CONTINUE = NO; GCC_GENERATE_DEBUGGING_SYMBOLS = NO; GCC_PREPROCESSOR_DEFINITIONS = ( From 450ea0cc43e303c00f5eaa27baf1077cdc2b72ae Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Fri, 16 Aug 2019 23:19:43 +0100 Subject: [PATCH 18/24] Disable the level end music fade code for now, because we discovered it causes freezes sometimes. --- src/p_user.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/p_user.c b/src/p_user.c index 03e1e4e23..3710e87f1 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -8818,6 +8818,9 @@ void P_PlayerThink(player_t *player) if (player->exiting && countdown2) player->exiting = 5; + // The following code is disabled for now as this causes the game to freeze sometimes + // Monster Iestyn -- 16/08/19 +#if 0 // Same check as below, just at 1 second before // so we can fade music if (!exitfadestarted && @@ -8855,6 +8858,7 @@ void P_PlayerThink(player_t *player) S_FadeOutStopMusic(1*MUSICRATE); } } +#endif if (player->exiting == 2 || countdown2 == 2) { From 0949406b9cca290e9c0d95d2eb921503472caf5c Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Sat, 17 Aug 2019 18:15:23 +0100 Subject: [PATCH 19/24] Update MD5 for patch.dta --- 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 1e6a7f514..63d24a3be 100644 --- a/src/config.h.in +++ b/src/config.h.in @@ -35,7 +35,7 @@ #define ASSET_HASH_PLAYER_DTA "cfca0f1c73023cbbd8f844f45480f799" #define ASSET_HASH_RINGS_DTA "85901ad4bf94637e5753d2ac2c03ea26" #ifdef USE_PATCH_DTA -#define ASSET_HASH_PATCH_DTA "b04fd9624bfd94dc96dcf4f400f7deb4" +#define ASSET_HASH_PATCH_DTA "636BD1C9269629AEAC2C3C184754D471" #endif #endif From 19dd9a3c14365956e69e2cf5da9a9c01d6990a1e Mon Sep 17 00:00:00 2001 From: James R Date: Sat, 17 Aug 2019 10:33:14 -0700 Subject: [PATCH 20/24] Kart discrepancies --- src/d_clisrv.c | 10 +++++----- src/d_clisrv.h | 4 ++-- src/d_netcmd.c | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 64d3ee6da..f62a4b6f0 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -117,7 +117,7 @@ static UINT8 resynch_local_inprogress = false; // WE are desynched and getting p static UINT8 player_joining = false; UINT8 hu_resynching = 0; -UINT8 adminpassmd5[MD5_LEN]; +UINT8 adminpassmd5[16]; boolean adminpasswordset = false; // Client specific @@ -3764,7 +3764,7 @@ static void HandlePacketFromPlayer(SINT8 node) XBOXSTATIC INT32 netconsole; XBOXSTATIC tic_t realend, realstart; XBOXSTATIC UINT8 *pak, *txtpak, numtxtpak; - XBOXSTATIC UINT8 finalmd5[MD5_LEN];/* Well, it's the cool thing to do? */ + XBOXSTATIC UINT8 finalmd5[16];/* Well, it's the cool thing to do? */ FILESTAMP txtpak = NULL; @@ -3969,7 +3969,7 @@ FILESTAMP break; #ifndef NOMD5 - if (doomcom->datalength < MD5_LEN)/* ignore partial sends */ + if (doomcom->datalength < 16)/* ignore partial sends */ break; if (!adminpasswordset) @@ -3979,9 +3979,9 @@ FILESTAMP } // Do the final pass to compare with the sent md5 - D_MD5PasswordPass(adminpassmd5, MD5_LEN, va("PNUM%02d", netconsole), &finalmd5); + D_MD5PasswordPass(adminpassmd5, 16, va("PNUM%02d", netconsole), &finalmd5); - if (!memcmp(netbuffer->u.md5sum, finalmd5, MD5_LEN)) + 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 diff --git a/src/d_clisrv.h b/src/d_clisrv.h index 96591ed93..c005f3f9a 100644 --- a/src/d_clisrv.h +++ b/src/d_clisrv.h @@ -401,7 +401,7 @@ typedef struct UINT8 textcmd[MAXTEXTCMD+1]; // 66049 bytes (wut??? 64k??? More like 257 bytes...) filetx_pak filetxpak; // 139 bytes clientconfig_pak clientcfg; // 136 bytes - UINT8 md5sum[MD5_LEN]; + UINT8 md5sum[16]; serverinfo_pak serverinfo; // 1024 bytes serverrefuse_pak serverrefuse; // 65025 bytes (somehow I feel like those values are garbage...) askinfo_pak askinfo; // 61 bytes @@ -534,6 +534,6 @@ void D_MD5PasswordPass(const UINT8 *buffer, size_t len, const char *salt, void * extern UINT8 hu_resynching; -extern UINT8 adminpassmd5[MD5_LEN]; +extern UINT8 adminpassmd5[16]; extern boolean adminpasswordset; #endif diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 1c2d380c1..38004d5ff 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -2710,12 +2710,12 @@ static void Command_Login_f(void) D_MD5PasswordPass((const UINT8 *)pw, strlen(pw), BASESALT, &netbuffer->u.md5sum); // Do the final pass to get the comparison the server will come up with - D_MD5PasswordPass(netbuffer->u.md5sum, MD5_LEN, va("PNUM%02d", consoleplayer), &netbuffer->u.md5sum); + D_MD5PasswordPass(netbuffer->u.md5sum, 16, va("PNUM%02d", consoleplayer), &netbuffer->u.md5sum); CONS_Printf(M_GetText("Sending login... (Notice only given if password is correct.)\n")); netbuffer->packettype = PT_LOGIN; - HSendPacket(servernode, true, 0, MD5_LEN); + HSendPacket(servernode, true, 0, 16); #endif } From c1ba72ead8af7db7766e9838a1e992d9aff6c44f Mon Sep 17 00:00:00 2001 From: James R Date: Sat, 17 Aug 2019 10:33:33 -0700 Subject: [PATCH 21/24] Remove a printf --- src/d_clisrv.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index f62a4b6f0..28d327ece 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -3964,7 +3964,6 @@ FILESTAMP } break; case PT_LOGIN: - CONS_Printf("I received LOGIN\n"); if (client) break; From 9c1fa867faeeabbd76122a3ec1d59312ff740ffd Mon Sep 17 00:00:00 2001 From: James R Date: Sat, 17 Aug 2019 10:34:19 -0700 Subject: [PATCH 22/24] Include md5.h --- src/d_netcmd.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 38004d5ff..aadebab80 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -46,6 +46,7 @@ #include "lua_hook.h" #include "m_cond.h" #include "m_anigif.h" +#include "md5.h" #ifdef NETGAME_DEVMODE #define CV_RESTRICT CV_NETVAR From 03ce0adef8264a9e80e04638fab423f90aa1959e Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Tue, 20 Aug 2019 14:13:38 +0100 Subject: [PATCH 23/24] Remove references to old console ports that slipped in from the 2.1 source code a while back --- src/apng.h | 2 -- src/command.c | 16 ---------------- 2 files changed, 18 deletions(-) diff --git a/src/apng.h b/src/apng.h index aa7fac3df..0f22dca6d 100644 --- a/src/apng.h +++ b/src/apng.h @@ -24,12 +24,10 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define APNG_H #ifndef _MSC_VER -#ifndef _WII #ifndef _LARGEFILE64_SOURCE #define _LARGEFILE64_SOURCE #endif #endif -#endif #ifndef _LFS64_LARGEFILE #define _LFS64_LARGEFILE diff --git a/src/command.c b/src/command.c index 600803cdb..cfb36f02f 100644 --- a/src/command.c +++ b/src/command.c @@ -1666,7 +1666,6 @@ static boolean CV_FilterJoyAxisVars(consvar_t *v, const char *valstr) if (joyaxis_default) { -#if !defined (_WII) && !defined (WMINPUT) if (!stricmp(v->name, "joyaxis_turn")) { if (joyaxis_count > 6) return false; @@ -1676,7 +1675,6 @@ static boolean CV_FilterJoyAxisVars(consvar_t *v, const char *valstr) if (!stricmp(valstr, "X-Axis")) joyaxis_count++; else joyaxis_default = false; } -#if !defined (PSP) if (!stricmp(v->name, "joyaxis_move")) { if (joyaxis_count > 6) return false; @@ -1685,8 +1683,6 @@ static boolean CV_FilterJoyAxisVars(consvar_t *v, const char *valstr) if (!stricmp(valstr, "Y-Axis")) joyaxis_count++; else joyaxis_default = false; } -#endif -#if !defined (_arch_dreamcast) && !defined (_XBOX) && !defined (PSP) if (!stricmp(v->name, "joyaxis_side")) { if (joyaxis_count > 6) return false; @@ -1695,8 +1691,6 @@ static boolean CV_FilterJoyAxisVars(consvar_t *v, const char *valstr) if (!stricmp(valstr, "Z-Axis")) joyaxis_count++; else joyaxis_default = false; } -#endif -#if !defined (_XBOX) && !defined (PSP) if (!stricmp(v->name, "joyaxis_look")) { if (joyaxis_count > 6) return false; @@ -1705,7 +1699,6 @@ static boolean CV_FilterJoyAxisVars(consvar_t *v, const char *valstr) if (!stricmp(valstr, "None")) joyaxis_count++; else joyaxis_default = false; } -#endif if (!stricmp(v->name, "joyaxis_fire") || !stricmp(v->name, "joyaxis_firenormal")) { @@ -1715,7 +1708,6 @@ static boolean CV_FilterJoyAxisVars(consvar_t *v, const char *valstr) if (!stricmp(valstr, "None")) joyaxis_count++; else joyaxis_default = false; } -#endif // reset all axis settings to defaults if (joyaxis_count == 6) { @@ -1732,7 +1724,6 @@ static boolean CV_FilterJoyAxisVars(consvar_t *v, const char *valstr) if (joyaxis2_default) { -#if !defined (_WII) && !defined (WMINPUT) if (!stricmp(v->name, "joyaxis2_turn")) { if (joyaxis2_count > 6) return false; @@ -1742,7 +1733,6 @@ static boolean CV_FilterJoyAxisVars(consvar_t *v, const char *valstr) if (!stricmp(valstr, "X-Axis")) joyaxis2_count++; else joyaxis2_default = false; } -// #if !defined (PSP) if (!stricmp(v->name, "joyaxis2_move")) { if (joyaxis2_count > 6) return false; @@ -1751,8 +1741,6 @@ static boolean CV_FilterJoyAxisVars(consvar_t *v, const char *valstr) if (!stricmp(valstr, "Y-Axis")) joyaxis2_count++; else joyaxis2_default = false; } -// #endif -#if !defined (_arch_dreamcast) && !defined (_XBOX) && !defined (PSP) if (!stricmp(v->name, "joyaxis2_side")) { if (joyaxis2_count > 6) return false; @@ -1761,8 +1749,6 @@ static boolean CV_FilterJoyAxisVars(consvar_t *v, const char *valstr) if (!stricmp(valstr, "Z-Axis")) joyaxis2_count++; else joyaxis2_default = false; } -#endif -#if !defined (_XBOX) // && !defined (PSP) if (!stricmp(v->name, "joyaxis2_look")) { if (joyaxis2_count > 6) return false; @@ -1771,7 +1757,6 @@ static boolean CV_FilterJoyAxisVars(consvar_t *v, const char *valstr) if (!stricmp(valstr, "None")) joyaxis2_count++; else joyaxis2_default = false; } -#endif if (!stricmp(v->name, "joyaxis2_fire") || !stricmp(v->name, "joyaxis2_firenormal")) { @@ -1781,7 +1766,6 @@ static boolean CV_FilterJoyAxisVars(consvar_t *v, const char *valstr) if (!stricmp(valstr, "None")) joyaxis2_count++; else joyaxis2_default = false; } -#endif // reset all axis settings to defaults if (joyaxis2_count == 6) From eacc589ae1737d7018331ba9e4bda50218cfc0c4 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Tue, 20 Aug 2019 20:31:28 +0100 Subject: [PATCH 24/24] Added quick validity checks for three linedef executor specials that require a player mobj to be the triggerer (432, 434 and 437) --- src/p_spec.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/p_spec.c b/src/p_spec.c index 5e06a18a7..37a1652f0 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -3096,7 +3096,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) break; case 432: // Enable 2D Mode (Disable if noclimb) - if (mo->player) + if (mo && mo->player) { if (line->flags & ML_NOCLIMB) mo->flags2 &= ~MF2_TWOD; @@ -3122,7 +3122,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) break; case 434: // Custom Power - if (mo->player) + if (mo && mo->player) { mobj_t *dummy = P_SpawnMobj(mo->x, mo->y, mo->z, MT_NULL); @@ -3205,7 +3205,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) break; case 437: // Disable Player Controls - if (mo->player) + if (mo && mo->player) { UINT16 fractime = (UINT16)(sides[line->sidenum[0]].textureoffset>>FRACBITS); if (fractime < 1)