From ebd2bdd1c82eaef65526de767dc9a40401f63393 Mon Sep 17 00:00:00 2001 From: wolfy852 Date: Fri, 1 Jan 2016 14:53:29 -0600 Subject: [PATCH 01/71] Add CA_DASHMODE to the game This works fine in single player on vanilla builds, multiplayer is untested. This might not be the best way to handle the ability, so modifications for efficiency/sanity might be necessary. --- src/d_player.h | 3 ++- src/dehacked.c | 1 + src/p_user.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 63 insertions(+), 1 deletion(-) diff --git a/src/d_player.h b/src/d_player.h index e2a1081b0..08c98b7a3 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -57,7 +57,8 @@ typedef enum CA_FALLSWITCH, CA_JUMPBOOST, CA_AIRDRILL, - CA_JUMPTHOK + CA_JUMPTHOK, + CA_DASHMODE } charability_t; //Secondary skin abilities diff --git a/src/dehacked.c b/src/dehacked.c index 0ba054f07..3fd05ffe6 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -7623,6 +7623,7 @@ struct { {"CA_JUMPBOOST",CA_JUMPBOOST}, {"CA_AIRDRILL",CA_AIRDRILL}, {"CA_JUMPTHOK",CA_JUMPTHOK}, + {"CA_DASHMODE",CA_DASHMODE}, // Secondary {"CA2_NONE",CA2_NONE}, // now slot 0! {"CA2_SPINDASH",CA2_SPINDASH}, diff --git a/src/p_user.c b/src/p_user.c index 8854d8d64..4b307feca 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -4072,6 +4072,7 @@ static void P_DoJumpStuff(player_t *player, ticcmd_t *cmd) case CA_THOK: case CA_HOMINGTHOK: case CA_JUMPTHOK: // Credit goes to CZ64 and Sryder13 for the original + case CA_DASHMODE: // Credit goes to Iceman404 // Now it's Sonic's abilities turn! // THOK! if (!(player->pflags & PF_THOKKED) || (player->charability2 == CA2_MULTIABILITY)) @@ -8664,6 +8665,8 @@ void P_DoPityCheck(player_t *player) // boolean playerdeadview; // show match/chaos/tag/capture the flag rankings while in death view +INT32 dashmode = 0; // initial variable set for CA_DASHMODE +boolean dashmodeflag = false; void P_PlayerThink(player_t *player) { @@ -9148,6 +9151,63 @@ void P_PlayerThink(player_t *player) player->pflags &= ~PF_SLIDING; + // Dash mode ability for Metal Sonic + if ((player->charability == CA_DASHMODE) && !(maptol & TOL_NIGHTS)) // woo, dashmode! no nights tho. + { + fixed_t defspeed = skins[player->skin].normalspeed; // Default normalspeed. + fixed_t maxtop = skins[player->skin].normalspeed * 55/36; + + if (!(player->speed > player->normalspeed)) //are we currently exceeding our normalspeed? + player->actionspd = player->normalspeed; //if not, force thok to normalspeed + else + player->actionspd = player->speed; //otherwise, thok at your current speed (this fixes super and speedshoes thok slowing you down) + + if (player->speed >= (defspeed - 5*FRACUNIT) || (player->pflags & PF_STARTDASH)) + { + dashmode++; // Counter. Adds 1 to dash mode per tic in top speed. + if (dashmode == 3*TICRATE) // This isn't in the ">=" equation because it'd cause the sound to play infinitely. + S_StartSound(player->mo, sfx_s3ka2); // If the player enters dashmode, play this sound on the the tic it starts. + } + else if (!(player->pflags & PF_SPINNING)) + { + if (dashmode > 0) + dashmode = dashmode - 3; // Rather than lose it all, it gently counts back down! + else if (dashmode < 0) + dashmode = 0; + } + + if (dashmode >= 3*TICRATE && P_IsObjectOnGround(player->mo)) // Dash Mode can continue counting in the air, but will only activate on floor touch. + dashmodeflag = true; + + if (dashmode < 3*TICRATE) // Exits Dash Mode if you drop below speed/dash counter tics. Not in the above block so it doesn't keep disabling in midair. + { + player->normalspeed = defspeed; // Reset to default if not capable of entering dash mode. + player->jumpfactor = 1*FRACUNIT; + dashmodeflag = false; + } + + //WHEN PARAMETERS ARE MET, REWARD THE DASH MODE EFFECTS + if (dashmodeflag) + { + if (player->normalspeed < maxtop) // If the player is not currently at 50 normalspeed in dash mode, add speed each tic + { + player->normalspeed = player->normalspeed + 1*FRACUNIT/5; // Enter Dash Mode smoothly. + if (player->jumpfactor < 5*FRACUNIT/4) + player->jumpfactor = player->jumpfactor + 1*FRACUNIT/300; // Boosts his jumpheight. Remember fractions instead of decimals. "1.5*FRACUNIT = 3*FRACUNIT/2" + } + } + + //COSMETIC STUPIDITY! + if (dashmode > 108) //Dash Mode will go down a tic a bit above activation, this makes dust spawn every other tic. + dashmode = 107; + + if (player->normalspeed >= maxtop) + { + mobj_t *ghost = P_SpawnGhostMobj(player->mo); // Spawns afterimages + ghost->fuse = 2; // Makes the images fade quickly + } + } + /* // Colormap verification { From a15a4ace7e8bac122a90ddc6645f76f76de1ff87 Mon Sep 17 00:00:00 2001 From: RedEnchilada Date: Sat, 2 Jan 2016 22:34:55 -0600 Subject: [PATCH 02/71] Do dashmode thok speed adjustments at thok instead of modifying actionspd --- src/p_user.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/p_user.c b/src/p_user.c index 4b307feca..034bab498 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -4079,13 +4079,19 @@ static void P_DoJumpStuff(player_t *player, ticcmd_t *cmd) { // Catapult the player fixed_t actionspd = player->actionspd; + + if (player->charability == CA_DASHMODE) + actionspd = max(player->normalspeed, FixedDiv(player->speed, player->mo->scale)); + if (player->mo->eflags & MFE_UNDERWATER) actionspd >>= 1; + if ((player->charability == CA_JUMPTHOK) && !(player->pflags & PF_THOKKED)) { player->pflags &= ~PF_JUMPED; P_DoJump(player, false); } + P_InstaThrust(player->mo, player->mo->angle, FixedMul(actionspd, player->mo->scale)); if (maptol & TOL_2D) From ba8c0dfc6e55e1116aa93b3ce4b030711340d114 Mon Sep 17 00:00:00 2001 From: RedEnchilada Date: Sat, 2 Jan 2016 22:58:35 -0600 Subject: [PATCH 03/71] Clean up dash mode and make multiplayer-compatible Actionspd is now the running speed in dashmode. --- src/p_user.c | 45 ++++++++++++++------------------------------- 1 file changed, 14 insertions(+), 31 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index 034bab498..802e7f9c3 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -8671,8 +8671,6 @@ void P_DoPityCheck(player_t *player) // boolean playerdeadview; // show match/chaos/tag/capture the flag rankings while in death view -INT32 dashmode = 0; // initial variable set for CA_DASHMODE -boolean dashmodeflag = false; void P_PlayerThink(player_t *player) { @@ -9160,15 +9158,10 @@ void P_PlayerThink(player_t *player) // Dash mode ability for Metal Sonic if ((player->charability == CA_DASHMODE) && !(maptol & TOL_NIGHTS)) // woo, dashmode! no nights tho. { - fixed_t defspeed = skins[player->skin].normalspeed; // Default normalspeed. +#define dashmode player->glidetime fixed_t maxtop = skins[player->skin].normalspeed * 55/36; - if (!(player->speed > player->normalspeed)) //are we currently exceeding our normalspeed? - player->actionspd = player->normalspeed; //if not, force thok to normalspeed - else - player->actionspd = player->speed; //otherwise, thok at your current speed (this fixes super and speedshoes thok slowing you down) - - if (player->speed >= (defspeed - 5*FRACUNIT) || (player->pflags & PF_STARTDASH)) + if (player->speed >= FixedMul(skins[player->skin].normalspeed - 5*FRACUNIT, player->mo->scale) || (player->pflags & PF_STARTDASH)) { dashmode++; // Counter. Adds 1 to dash mode per tic in top speed. if (dashmode == 3*TICRATE) // This isn't in the ">=" equation because it'd cause the sound to play infinitely. @@ -9176,42 +9169,32 @@ void P_PlayerThink(player_t *player) } else if (!(player->pflags & PF_SPINNING)) { - if (dashmode > 0) + if (dashmode > 3) dashmode = dashmode - 3; // Rather than lose it all, it gently counts back down! - else if (dashmode < 0) + else dashmode = 0; } - - if (dashmode >= 3*TICRATE && P_IsObjectOnGround(player->mo)) // Dash Mode can continue counting in the air, but will only activate on floor touch. - dashmodeflag = true; if (dashmode < 3*TICRATE) // Exits Dash Mode if you drop below speed/dash counter tics. Not in the above block so it doesn't keep disabling in midair. { - player->normalspeed = defspeed; // Reset to default if not capable of entering dash mode. - player->jumpfactor = 1*FRACUNIT; - dashmodeflag = false; + player->normalspeed = skins[player->skin].normalspeed; // Reset to default if not capable of entering dash mode. + player->jumpfactor = skins[player->skin].jumpfactor; } - - //WHEN PARAMETERS ARE MET, REWARD THE DASH MODE EFFECTS - if (dashmodeflag) + else if (P_IsObjectOnGround(player->mo)) // Activate dash mode if we're on the ground. { - if (player->normalspeed < maxtop) // If the player is not currently at 50 normalspeed in dash mode, add speed each tic - { + if (player->normalspeed < skins[player->skin].actionspd) // If the player normalspeed is not currently at actionspd in dash mode, add speed each tic player->normalspeed = player->normalspeed + 1*FRACUNIT/5; // Enter Dash Mode smoothly. - if (player->jumpfactor < 5*FRACUNIT/4) - player->jumpfactor = player->jumpfactor + 1*FRACUNIT/300; // Boosts his jumpheight. Remember fractions instead of decimals. "1.5*FRACUNIT = 3*FRACUNIT/2" - } + + if (player->jumpfactor < FixedMul(skins[player->skin].jumpfactor, 5*FRACUNIT/4)) // Boost jump height. + player->jumpfactor = player->jumpfactor + 1*FRACUNIT/300; } - - //COSMETIC STUPIDITY! - if (dashmode > 108) //Dash Mode will go down a tic a bit above activation, this makes dust spawn every other tic. - dashmode = 107; - - if (player->normalspeed >= maxtop) + + if (player->normalspeed >= skins[player->skin].actionspd) { mobj_t *ghost = P_SpawnGhostMobj(player->mo); // Spawns afterimages ghost->fuse = 2; // Makes the images fade quickly } +#undef dashmode } /* From c38af2c6a2751336da1512d9e3a15ec1e75c565e Mon Sep 17 00:00:00 2001 From: RedEnchilada Date: Sat, 2 Jan 2016 23:26:22 -0600 Subject: [PATCH 04/71] Remove unused maxtop variable --- src/p_user.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index 802e7f9c3..3b0d48628 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -9159,8 +9159,6 @@ void P_PlayerThink(player_t *player) if ((player->charability == CA_DASHMODE) && !(maptol & TOL_NIGHTS)) // woo, dashmode! no nights tho. { #define dashmode player->glidetime - fixed_t maxtop = skins[player->skin].normalspeed * 55/36; - if (player->speed >= FixedMul(skins[player->skin].normalspeed - 5*FRACUNIT, player->mo->scale) || (player->pflags & PF_STARTDASH)) { dashmode++; // Counter. Adds 1 to dash mode per tic in top speed. From 95d6cba18405b5ce7f9224e1849b3f0751bc6f02 Mon Sep 17 00:00:00 2001 From: wolfy852 Date: Mon, 25 Jan 2016 01:49:37 -0600 Subject: [PATCH 05/71] [HACK] Make dashmode work again Fixed one of Red's mistakes, and used a different struct variable for dashmode. This needs to be changed though, because everything will break if someone loads a circuit map. --- src/p_user.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index 3b0d48628..91bbfc6f2 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -9158,7 +9158,7 @@ void P_PlayerThink(player_t *player) // Dash mode ability for Metal Sonic if ((player->charability == CA_DASHMODE) && !(maptol & TOL_NIGHTS)) // woo, dashmode! no nights tho. { -#define dashmode player->glidetime +#define dashmode player->laps if (player->speed >= FixedMul(skins[player->skin].normalspeed - 5*FRACUNIT, player->mo->scale) || (player->pflags & PF_STARTDASH)) { dashmode++; // Counter. Adds 1 to dash mode per tic in top speed. @@ -9168,10 +9168,13 @@ void P_PlayerThink(player_t *player) else if (!(player->pflags & PF_SPINNING)) { if (dashmode > 3) - dashmode = dashmode - 3; // Rather than lose it all, it gently counts back down! + dashmode -= 3; // Rather than lose it all, it gently counts back down! else dashmode = 0; } + + if (dashmode > 254) + dashmode = 3*TICRATE+1; if (dashmode < 3*TICRATE) // Exits Dash Mode if you drop below speed/dash counter tics. Not in the above block so it doesn't keep disabling in midair. { From 67b92d727344ab66bb5e070a9d45e8e647942c87 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Mon, 25 Jan 2016 11:47:33 +0000 Subject: [PATCH 06/71] Went and fixed the dashmode variable hack nonsense once and for all myself would have gone for "dashtime", but then I was reminded that was already a name for something to do with spindash. Oh well --- src/d_clisrv.c | 2 ++ src/d_clisrv.h | 1 + src/d_player.h | 1 + src/lua_playerlib.c | 4 ++++ src/p_saveg.c | 2 ++ src/p_user.c | 11 ++++++----- 6 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 31738e9b2..ee2d18961 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -531,6 +531,7 @@ static inline void resynch_write_player(resynch_pak *rsp, const size_t i) 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->cmomx = (fixed_t)LONG(players[i].cmomx); rsp->cmomy = (fixed_t)LONG(players[i].cmomy); rsp->rmomx = (fixed_t)LONG(players[i].rmomx); @@ -656,6 +657,7 @@ static void resynch_read_player(resynch_pak *rsp) 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].cmomx = (fixed_t)LONG(rsp->cmomx); players[i].cmomy = (fixed_t)LONG(rsp->cmomy); players[i].rmomx = (fixed_t)LONG(rsp->rmomx); diff --git a/src/d_clisrv.h b/src/d_clisrv.h index 6bc06f13a..2bcfad176 100644 --- a/src/d_clisrv.h +++ b/src/d_clisrv.h @@ -191,6 +191,7 @@ typedef struct INT32 deadtimer; tic_t exiting; UINT8 homing; + tic_t dashmode; fixed_t cmomx; fixed_t cmomy; fixed_t rmomx; diff --git a/src/d_player.h b/src/d_player.h index 08c98b7a3..a3acb8728 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -352,6 +352,7 @@ typedef struct player_s tic_t exiting; // Exitlevel timer UINT8 homing; // Are you homing? + tic_t dashmode; // counter for dashmode ability tic_t skidtime; // Skid timer diff --git a/src/lua_playerlib.c b/src/lua_playerlib.c index 64513ab97..b03833354 100644 --- a/src/lua_playerlib.c +++ b/src/lua_playerlib.c @@ -202,6 +202,8 @@ static int player_get(lua_State *L) lua_pushinteger(L, plr->exiting); else if (fastcmp(field,"homing")) lua_pushinteger(L, plr->homing); + else if (fastcmp(field,"dashmode")) + lua_pushinteger(L, plr->dashmode); else if (fastcmp(field,"skidtime")) lua_pushinteger(L, plr->skidtime); else if (fastcmp(field,"cmomx")) @@ -452,6 +454,8 @@ static int player_set(lua_State *L) plr->exiting = (tic_t)luaL_checkinteger(L, 3); else if (fastcmp(field,"homing")) plr->homing = (UINT8)luaL_checkinteger(L, 3); + else if (fastcmp(field,"dashmode")) + plr->dashmode = (tic_t)luaL_checkinteger(L, 3); else if (fastcmp(field,"skidtime")) plr->skidtime = (tic_t)luaL_checkinteger(L, 3); else if (fastcmp(field,"cmomx")) diff --git a/src/p_saveg.c b/src/p_saveg.c index 07e7b3564..a574afb55 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -162,6 +162,7 @@ static inline void P_NetArchivePlayers(void) WRITEINT32(save_p, players[i].deadtimer); WRITEUINT32(save_p, players[i].exiting); WRITEUINT8(save_p, players[i].homing); + WRITEUINT32(save_p, players[i].dashmode); WRITEUINT32(save_p, players[i].skidtime); //////////////////////////// @@ -337,6 +338,7 @@ static inline void P_NetUnArchivePlayers(void) players[i].deadtimer = READINT32(save_p); // End game if game over lasts too long players[i].exiting = READUINT32(save_p); // Exitlevel timer players[i].homing = READUINT8(save_p); // Are you homing? + players[i].dashmode = READUINT32(save_p); // counter for dashmode ability players[i].skidtime = READUINT32(save_p); // Skid timer //////////////////////////// diff --git a/src/p_user.c b/src/p_user.c index 91bbfc6f2..8a6d8b871 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -9155,10 +9155,10 @@ void P_PlayerThink(player_t *player) player->pflags &= ~PF_SLIDING; +#define dashmode player->dashmode // Dash mode ability for Metal Sonic if ((player->charability == CA_DASHMODE) && !(maptol & TOL_NIGHTS)) // woo, dashmode! no nights tho. { -#define dashmode player->laps if (player->speed >= FixedMul(skins[player->skin].normalspeed - 5*FRACUNIT, player->mo->scale) || (player->pflags & PF_STARTDASH)) { dashmode++; // Counter. Adds 1 to dash mode per tic in top speed. @@ -9172,10 +9172,10 @@ void P_PlayerThink(player_t *player) else dashmode = 0; } - + if (dashmode > 254) dashmode = 3*TICRATE+1; - + if (dashmode < 3*TICRATE) // Exits Dash Mode if you drop below speed/dash counter tics. Not in the above block so it doesn't keep disabling in midair. { player->normalspeed = skins[player->skin].normalspeed; // Reset to default if not capable of entering dash mode. @@ -9195,9 +9195,10 @@ void P_PlayerThink(player_t *player) mobj_t *ghost = P_SpawnGhostMobj(player->mo); // Spawns afterimages ghost->fuse = 2; // Makes the images fade quickly } -#undef dashmode } - + else + dashmode = 0; +#undef dashmode /* // Colormap verification { From e314b442b2762d79df4f07d5a6da0ae0d6c6c57c Mon Sep 17 00:00:00 2001 From: wolfy852 Date: Mon, 25 Jan 2016 20:26:31 -0600 Subject: [PATCH 07/71] Remove dashmode limit since tic_t is UINT32 This might be overpowered as hell. Needs testing for sure. --- src/p_user.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index 8a6d8b871..3c86c3621 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -9173,9 +9173,6 @@ void P_PlayerThink(player_t *player) dashmode = 0; } - if (dashmode > 254) - dashmode = 3*TICRATE+1; - if (dashmode < 3*TICRATE) // Exits Dash Mode if you drop below speed/dash counter tics. Not in the above block so it doesn't keep disabling in midair. { player->normalspeed = skins[player->skin].normalspeed; // Reset to default if not capable of entering dash mode. From a2aeece419b3632ea3d783a38a424195290b3384 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Mon, 30 May 2016 21:53:29 +0100 Subject: [PATCH 08/71] Significant rework of main seg-rendering code, to eliminate the possibility of drawing off-screen and crashing the game as result NOTE: HOMs sometimes appear in the sky in maps like AGZ (map40), so this isn't completely fine yet. I'll fix that later --- src/r_segs.c | 110 +++++++++++++++++++++++++++++++-------------------- 1 file changed, 68 insertions(+), 42 deletions(-) diff --git a/src/r_segs.c b/src/r_segs.c index 11b4c8aef..931b79a66 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -1453,34 +1453,45 @@ static void R_RenderSegLoop (void) frontscale[rw_x] = rw_scale; // draw the wall tiers - if (midtexture && yl <= yh && yh < vid.height && yh > 0) + if (midtexture) { // single sided line - dc_yl = yl; - dc_yh = yh; - dc_texturemid = rw_midtexturemid; - dc_source = R_GetColumn(midtexture,texturecolumn); - dc_texheight = textureheight[midtexture]>>FRACBITS; + if (yl <= yh && yh >= 0 && yl < viewheight) + { + dc_yl = yl; + dc_yh = yh; + dc_texturemid = rw_midtexturemid; + dc_source = R_GetColumn(midtexture,texturecolumn); + dc_texheight = textureheight[midtexture]>>FRACBITS; - //profile stuff --------------------------------------------------------- + //profile stuff --------------------------------------------------------- #ifdef TIMING - ProfZeroTimer(); + ProfZeroTimer(); #endif - colfunc(); + colfunc(); #ifdef TIMING - RDMSR(0x10,&mycount); - mytotal += mycount; //64bit add + RDMSR(0x10,&mycount); + mytotal += mycount; //64bit add - if (nombre--==0) - I_Error("R_DrawColumn CPU Spy reports: 0x%d %d\n", *((INT32 *)&mytotal+1), - (INT32)mytotal); + if (nombre--==0) + I_Error("R_DrawColumn CPU Spy reports: 0x%d %d\n", *((INT32 *)&mytotal+1), + (INT32)mytotal); #endif - //profile stuff --------------------------------------------------------- + //profile stuff --------------------------------------------------------- - // dont draw anything more for this column, since - // a midtexture blocks the view - ceilingclip[rw_x] = (INT16)viewheight; - floorclip[rw_x] = -1; + // dont draw anything more for this column, since + // a midtexture blocks the view + ceilingclip[rw_x] = (INT16)viewheight; + floorclip[rw_x] = -1; + } + else + { + // note: don't use min/max macros here + if (markceiling && yl >= 0) + ceilingclip[rw_x] = (yl-1 > viewheight) ? (INT16)viewheight : (INT16)((INT16)yl - 1); + if (markfloor && yh < viewheight) + floorclip[rw_x] = (yh < -1) ? -1 : (INT16)((INT16)yh + 1); + } } else { @@ -1494,21 +1505,27 @@ static void R_RenderSegLoop (void) if (mid >= floorclip[rw_x]) mid = floorclip[rw_x]-1; - if (mid >= yl && yh < vid.height && yh > 0) + if (yl < 0) + ; // do nothing, off-screen + else if (mid >= yl && yl < viewheight) { - dc_yl = yl; - dc_yh = mid; - dc_texturemid = rw_toptexturemid; - dc_source = R_GetColumn(toptexture,texturecolumn); - dc_texheight = textureheight[toptexture]>>FRACBITS; - colfunc(); - ceilingclip[rw_x] = (INT16)mid; + if (mid >= 0) + { + dc_yl = yl; + dc_yh = mid; + dc_texturemid = rw_toptexturemid; + dc_source = R_GetColumn(toptexture,texturecolumn); + dc_texheight = textureheight[toptexture]>>FRACBITS; + colfunc(); + ceilingclip[rw_x] = (INT16)mid; + } + // else do nothing, off-screen } else - ceilingclip[rw_x] = (INT16)((INT16)yl - 1); + ceilingclip[rw_x] = (yl > viewheight) ? (INT16)viewheight : (INT16)((INT16)yl - 1); } - else if (markceiling) // no top wall - ceilingclip[rw_x] = (INT16)((INT16)yl - 1); + else if (markceiling && yl >= 0) // no top wall + ceilingclip[rw_x] = (yl > viewheight) ? (INT16)viewheight : (INT16)((INT16)yl - 1); if (bottomtexture) { @@ -1520,24 +1537,33 @@ static void R_RenderSegLoop (void) if (mid <= ceilingclip[rw_x]) mid = ceilingclip[rw_x]+1; - if (mid <= yh && yh < vid.height && yh > 0) + if (yh >= viewheight) + ; // do nothing, off-screen + else if (mid <= yh && yh >= 0) { - dc_yl = mid; - dc_yh = yh; - dc_texturemid = rw_bottomtexturemid; - dc_source = R_GetColumn(bottomtexture, - texturecolumn); - dc_texheight = textureheight[bottomtexture]>>FRACBITS; - colfunc(); - floorclip[rw_x] = (INT16)mid; + if (mid < viewheight) + { + dc_yl = mid; + dc_yh = yh; + dc_texturemid = rw_bottomtexturemid; + dc_source = R_GetColumn(bottomtexture, + texturecolumn); + dc_texheight = textureheight[bottomtexture]>>FRACBITS; + colfunc(); + floorclip[rw_x] = (INT16)mid; + } + // else do nothing, off-screen } else - floorclip[rw_x] = (INT16)((INT16)yh + 1); + floorclip[rw_x] = (yh < -1) ? -1 : (INT16)((INT16)yh + 1); } - else if (markfloor) // no bottom wall - floorclip[rw_x] = (INT16)((INT16)yh + 1); + else if (markfloor && yh < viewheight) // no bottom wall + floorclip[rw_x] = (yh < -1) ? -1 : (INT16)((INT16)yh + 1), -1; } + if (floorclip[rw_x] > viewheight) + I_Error("floorclip[%d] > viewheight (value is %d)", rw_x, floorclip[rw_x]); + if (maskedtexture || numthicksides) { // save texturecol From eb90f4f50deec77b35d31224a456144683cd096a Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Mon, 30 May 2016 22:53:22 +0100 Subject: [PATCH 09/71] welp no success in fixing the sky HOMs yet, committing progress anyway --- src/r_segs.c | 58 ++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 40 insertions(+), 18 deletions(-) diff --git a/src/r_segs.c b/src/r_segs.c index 931b79a66..99324d03f 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -1487,10 +1487,20 @@ static void R_RenderSegLoop (void) else { // note: don't use min/max macros here - if (markceiling && yl >= 0) - ceilingclip[rw_x] = (yl-1 > viewheight) ? (INT16)viewheight : (INT16)((INT16)yl - 1); - if (markfloor && yh < viewheight) - floorclip[rw_x] = (yh < -1) ? -1 : (INT16)((INT16)yh + 1); + if (markceiling) + { + if (yl >= 0) + ceilingclip[rw_x] = (yl > viewheight) ? (INT16)viewheight : (INT16)((INT16)yl - 1); + else + ceilingclip[rw_x] = -1; + } + else if (markfloor) + { + if (yh < viewheight) + floorclip[rw_x] = (yh < -1) ? -1 : (INT16)((INT16)yh + 1); + else + floorclip[rw_x] = (INT16)viewheight; + } } } else @@ -1505,9 +1515,7 @@ static void R_RenderSegLoop (void) if (mid >= floorclip[rw_x]) mid = floorclip[rw_x]-1; - if (yl < 0) - ; // do nothing, off-screen - else if (mid >= yl && yl < viewheight) + if (mid >= yl && yl < viewheight) { if (mid >= 0) { @@ -1519,13 +1527,21 @@ static void R_RenderSegLoop (void) colfunc(); ceilingclip[rw_x] = (INT16)mid; } - // else do nothing, off-screen + else + ceilingclip[rw_x] = -1; } - else + else if (yl >= 0) ceilingclip[rw_x] = (yl > viewheight) ? (INT16)viewheight : (INT16)((INT16)yl - 1); + else + ceilingclip[rw_x] = -1; + } + else if (markceiling) // no top wall + { + if (yl >= 0) + ceilingclip[rw_x] = (yl > viewheight) ? (INT16)viewheight : (INT16)((INT16)yl - 1); + else + ceilingclip[rw_x] = -1; } - else if (markceiling && yl >= 0) // no top wall - ceilingclip[rw_x] = (yl > viewheight) ? (INT16)viewheight : (INT16)((INT16)yl - 1); if (bottomtexture) { @@ -1537,9 +1553,7 @@ static void R_RenderSegLoop (void) if (mid <= ceilingclip[rw_x]) mid = ceilingclip[rw_x]+1; - if (yh >= viewheight) - ; // do nothing, off-screen - else if (mid <= yh && yh >= 0) + if (mid <= yh && yh >= 0) { if (mid < viewheight) { @@ -1552,13 +1566,21 @@ static void R_RenderSegLoop (void) colfunc(); floorclip[rw_x] = (INT16)mid; } - // else do nothing, off-screen + else + floorclip[rw_x] = (INT16)viewheight; } - else + else if (yh < viewheight) floorclip[rw_x] = (yh < -1) ? -1 : (INT16)((INT16)yh + 1); + else + floorclip[rw_x] = (INT16)viewheight; + } + else if (markfloor) // no bottom wall + { + if (yh < viewheight) + floorclip[rw_x] = (yh < -1) ? -1 : (INT16)((INT16)yh + 1); + else + floorclip[rw_x] = (INT16)viewheight; } - else if (markfloor && yh < viewheight) // no bottom wall - floorclip[rw_x] = (yh < -1) ? -1 : (INT16)((INT16)yh + 1), -1; } if (floorclip[rw_x] > viewheight) From fa002e58ad0f11f362a5bdfdb0629c9494906a1b Mon Sep 17 00:00:00 2001 From: toasterbabe Date: Tue, 31 May 2016 15:01:19 +0100 Subject: [PATCH 10/71] Did a bunch of things to/for slopes. *The No Physics flag now works (Red, you might want to doublecheck this to see whether I haven't missed any eosteric stuff out). Going downhill is a little bumpy, and I'm not sure whether that's good or not. Someone help me out here? *The SRB2CB typeshims are now behind #ifdef ESLOPE_TYPESHIM instead of #if 1 for easier disabling. *Slopes' downhill thrusts are now scaled with regards to object gravity. This is actually untested in gravities other than normal and reverse normal but it's one line which can be easily reverted in that circumstance. I also checked with MI to make sure this is how it's calculated elsewhere, so fingers crossed this doesn't cause any edge cases. *As a consequence of the above point, there's now a function in p_mobj.c/h that returns an object's internal gravity - seperated out from the logic of P_CheckGravity, which really didn't need to be so monolithic. Multiply by global gravity to get the thrust. This should probably be available to Lua somehow, but I have absolutely no idea where to start with that. Wolfs, maybe? Non-comprehensive test file available at /toaster/slptst3.wad on the ftp. --- src/doomdef.h | 6 ++++++ src/p_mobj.c | 31 ++++++++++++++++++++++--------- src/p_mobj.h | 3 +++ src/p_slopes.c | 50 ++++++++++++++++++++++++++++++++++---------------- src/p_user.c | 8 ++++---- 5 files changed, 69 insertions(+), 29 deletions(-) diff --git a/src/doomdef.h b/src/doomdef.h index 9a1e5af9e..e645c0848 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -431,6 +431,12 @@ extern const char *compdate, *comptime, *comprevision, *compbranch; /// Kalaron/Eternity Engine slope code (SRB2CB ported) #define ESLOPE +#if defined(ESLOPE) +/// Backwards compatibility with SRB2CB's slope linedef types. +/// \note A simple shim that prints a warning. +#define ESLOPE_TYPESHIM +#endif + /// Delete file while the game is running. /// \note EXTREMELY buggy, tends to crash game. //#define DELFILE diff --git a/src/p_mobj.c b/src/p_mobj.c index 68fb1696f..775cd9d6d 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -1252,13 +1252,12 @@ static void P_PlayerFlip(mobj_t *mo) } // -// P_CheckGravity +// P_GetMobjGravity // -// Checks the current gravity state -// of the object. If affect is true, -// a gravity force will be applied. +// Returns the current gravity +// value of the object. // -void P_CheckGravity(mobj_t *mo, boolean affect) +fixed_t P_GetMobjGravity(mobj_t *mo) { fixed_t gravityadd = 0; boolean no3dfloorgrav = true; // Custom gravity @@ -1400,11 +1399,25 @@ void P_CheckGravity(mobj_t *mo, boolean affect) if (goopgravity) gravityadd = -gravityadd/5; - if (affect) - mo->momz += FixedMul(gravityadd, mo->scale); - if (mo->player && !!(mo->eflags & MFE_VERTICALFLIP) != wasflip) P_PlayerFlip(mo); + + return gravityadd; +} + +// +// P_CheckGravity +// +// Checks the current gravity state +// of the object. If affect is true, +// a gravity force will be applied. +// +void P_CheckGravity(mobj_t *mo, boolean affect) +{ + fixed_t gravityadd = P_GetMobjGravity(mo); + + if (affect) + mo->momz += FixedMul(gravityadd, mo->scale); if (mo->type == MT_SKIM && mo->z + mo->momz <= mo->watertop && mo->z >= mo->watertop) { @@ -1480,7 +1493,7 @@ static void P_XYFriction(mobj_t *mo, fixed_t oldx, fixed_t oldy) && abs(player->rmomy) < FixedMul(STOPSPEED, mo->scale) && (!(player->cmd.forwardmove && !(twodlevel || mo->flags2 & MF2_TWOD)) && !player->cmd.sidemove && !(player->pflags & PF_SPINNING)) #ifdef ESLOPE - && !(player->mo->standingslope && abs(player->mo->standingslope->zdelta) >= FRACUNIT/2) + && !(player->mo->standingslope && (!(player->mo->standingslope->flags & SL_NOPHYSICS)) && (abs(player->mo->standingslope->zdelta) >= FRACUNIT/2)) #endif ) { diff --git a/src/p_mobj.h b/src/p_mobj.h index 9542ce8ba..de7f0c8d5 100644 --- a/src/p_mobj.h +++ b/src/p_mobj.h @@ -425,6 +425,9 @@ void P_AddCachedAction(mobj_t *mobj, INT32 statenum); // check mobj against water content, before movement code void P_MobjCheckWater(mobj_t *mobj); +// get mobj gravity +fixed_t P_GetMobjGravity(mobj_t *mo); + // Player spawn points void P_SpawnPlayer(INT32 playernum); void P_MovePlayerToSpawn(INT32 playernum, mapthing_t *mthing); diff --git a/src/p_slopes.c b/src/p_slopes.c index 6393ca4b5..f4ef4dcc2 100644 --- a/src/p_slopes.c +++ b/src/p_slopes.c @@ -16,6 +16,7 @@ #include "m_bbox.h" #include "z_zone.h" #include "p_local.h" +#include "p_mobj.h" #include "p_spec.h" #include "p_slopes.h" #include "p_setup.h" @@ -881,7 +882,7 @@ void P_SetSlopesFromVertexHeights(lumpnum_t lumpnum) // Reset the dynamic slopes pointer, and read all of the fancy schmancy slopes void P_ResetDynamicSlopes(void) { size_t i; -#if 1 // Rewrite old specials to new ones, and give a console warning +#ifdef ESLOPE_TYPESHIM // Rewrite old specials to new ones, and give a console warning boolean warned = false; #endif @@ -894,7 +895,7 @@ void P_ResetDynamicSlopes(void) { { switch (lines[i].special) { -#if 1 // Rewrite old specials to new ones, and give a console warning +#ifdef ESLOPE_TYPESHIM // Rewrite old specials to new ones, and give a console warning #define WARNME if (!warned) {warned = true; CONS_Alert(CONS_WARNING, "This level uses old slope specials.\nA conversion will be needed before 2.2's release.\n");} case 386: case 387: @@ -1018,6 +1019,9 @@ fixed_t P_GetZAt(pslope_t *slope, fixed_t x, fixed_t y) // When given a vector, rotates it and aligns it to a slope void P_QuantizeMomentumToSlope(vector3_t *momentum, pslope_t *slope) { + if (slope->flags & SL_NOPHYSICS) + return; // No physics, no quantizing. + vector3_t axis; axis.x = -slope->d.y; axis.y = slope->d.x; @@ -1032,26 +1036,37 @@ void P_QuantizeMomentumToSlope(vector3_t *momentum, pslope_t *slope) // Handles slope ejection for objects void P_SlopeLaunch(mobj_t *mo) { - // Double the pre-rotation Z, then halve the post-rotation Z. This reduces the - // vertical launch given from slopes while increasing the horizontal launch - // given. Good for SRB2's gravity and horizontal speeds. - vector3_t slopemom; - slopemom.x = mo->momx; - slopemom.y = mo->momy; - slopemom.z = mo->momz*2; - P_QuantizeMomentumToSlope(&slopemom, mo->standingslope); - - mo->momx = slopemom.x; - mo->momy = slopemom.y; - mo->momz = slopemom.z/2; + if (!(mo->standingslope->flags & SL_NOPHYSICS)) // If there's physics, time for launching. + { + // Double the pre-rotation Z, then halve the post-rotation Z. This reduces the + // vertical launch given from slopes while increasing the horizontal launch + // given. Good for SRB2's gravity and horizontal speeds. + vector3_t slopemom; + slopemom.x = mo->momx; + slopemom.y = mo->momy; + slopemom.z = mo->momz*2; + P_QuantizeMomentumToSlope(&slopemom, mo->standingslope); + mo->momx = slopemom.x; + mo->momy = slopemom.y; + mo->momz = slopemom.z/2; + } + //CONS_Printf("Launched off of slope.\n"); mo->standingslope = NULL; } // Function to help handle landing on slopes void P_HandleSlopeLanding(mobj_t *thing, pslope_t *slope) -{ +{ + 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); + thing->standingslope = slope; + } + return; + } + vector3_t mom; mom.x = thing->momx; mom.y = thing->momy; @@ -1081,6 +1096,9 @@ void P_ButteredSlope(mobj_t *mo) if (!mo->standingslope) return; + + if (mo->standingslope->flags & SL_NOPHYSICS) + return; // No physics, no butter. if (mo->flags & (MF_NOCLIPHEIGHT|MF_NOGRAVITY)) return; // don't slide down slopes if you can't touch them or you're not affected by gravity @@ -1116,7 +1134,7 @@ void P_ButteredSlope(mobj_t *mo) // This makes it harder to zigzag up steep slopes, as well as allows greater top speed when rolling down // Multiply by gravity - thrust = FixedMul(thrust, gravity); // TODO account for per-sector gravity etc + thrust = FixedMul(thrust, FixedMul(gravity, abs(P_GetMobjGravity(mo)))); // Now uses the absolute of mobj gravity. You're welcome. // Multiply by scale (gravity strength depends on mobj scale) thrust = FixedMul(thrust, mo->scale); diff --git a/src/p_user.c b/src/p_user.c index 4117cfc4c..461497bcb 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3741,7 +3741,7 @@ static void P_DoSpinDash(player_t *player, ticcmd_t *cmd) { if ((cmd->buttons & BT_USE) && player->speed < FixedMul(5<mo->scale) && !player->mo->momz && onground && !(player->pflags & PF_USEDOWN) && !(player->pflags & PF_SPINNING) #ifdef ESLOPE - && (!player->mo->standingslope || abs(player->mo->standingslope->zdelta) < FRACUNIT/2) + && (!player->mo->standingslope || (player->mo->standingslope->flags & SL_NOPHYSICS) || abs(player->mo->standingslope->zdelta) < FRACUNIT/2) #endif ) { @@ -3774,7 +3774,7 @@ static void P_DoSpinDash(player_t *player, ticcmd_t *cmd) else if ((cmd->buttons & BT_USE || ((twodlevel || (player->mo->flags2 & MF2_TWOD)) && cmd->forwardmove < -20)) && !player->climbing && !player->mo->momz && onground && (player->speed > FixedMul(5<mo->scale) #ifdef ESLOPE - || (player->mo->standingslope && abs(player->mo->standingslope->zdelta) >= FRACUNIT/2) + || (player->mo->standingslope && (!(player->mo->standingslope->flags & SL_NOPHYSICS)) && abs(player->mo->standingslope->zdelta) >= FRACUNIT/2) #endif ) && !(player->pflags & PF_USEDOWN) && !(player->pflags & PF_SPINNING)) { @@ -3790,7 +3790,7 @@ static void P_DoSpinDash(player_t *player, ticcmd_t *cmd) if (onground && player->pflags & PF_SPINNING && !(player->pflags & PF_STARTDASH) && player->speed < FixedMul(5*FRACUNIT,player->mo->scale) #ifdef ESLOPE - && (!player->mo->standingslope || abs(player->mo->standingslope->zdelta) < FRACUNIT/2) + && (!player->mo->standingslope || (player->mo->standingslope->flags & SL_NOPHYSICS) || abs(player->mo->standingslope->zdelta) < FRACUNIT/2) #endif ) { @@ -4776,7 +4776,7 @@ static void P_3dMovement(player_t *player) #ifdef ESLOPE if ((totalthrust.x || totalthrust.y) - && player->mo->standingslope && abs(player->mo->standingslope->zdelta) > FRACUNIT/2) { + && player->mo->standingslope && (!(player->mo->standingslope->flags & SL_NOPHYSICS)) && abs(player->mo->standingslope->zdelta) > FRACUNIT/2) { // Factor thrust to slope, but only for the part pushing up it! // The rest is unaffected. angle_t thrustangle = R_PointToAngle2(0, 0, totalthrust.x, totalthrust.y)-player->mo->standingslope->xydirection; From ad61050bb07825453b83fdd8735c2e85460d6ac2 Mon Sep 17 00:00:00 2001 From: toasterbabe Date: Tue, 31 May 2016 16:01:05 +0100 Subject: [PATCH 11/71] Whitespace removal. --- src/p_mobj.c | 2 +- src/p_slopes.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index 775cd9d6d..35d8f1ad2 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -1401,7 +1401,7 @@ fixed_t P_GetMobjGravity(mobj_t *mo) if (mo->player && !!(mo->eflags & MFE_VERTICALFLIP) != wasflip) P_PlayerFlip(mo); - + return gravityadd; } diff --git a/src/p_slopes.c b/src/p_slopes.c index f4ef4dcc2..462f7c3cb 100644 --- a/src/p_slopes.c +++ b/src/p_slopes.c @@ -1021,7 +1021,7 @@ void P_QuantizeMomentumToSlope(vector3_t *momentum, pslope_t *slope) { if (slope->flags & SL_NOPHYSICS) return; // No physics, no quantizing. - + vector3_t axis; axis.x = -slope->d.y; axis.y = slope->d.x; @@ -1051,14 +1051,14 @@ void P_SlopeLaunch(mobj_t *mo) mo->momy = slopemom.y; mo->momz = slopemom.z/2; } - + //CONS_Printf("Launched off of slope.\n"); mo->standingslope = NULL; } // Function to help handle landing on slopes void P_HandleSlopeLanding(mobj_t *thing, pslope_t *slope) -{ +{ 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); @@ -1096,7 +1096,7 @@ void P_ButteredSlope(mobj_t *mo) if (!mo->standingslope) return; - + if (mo->standingslope->flags & SL_NOPHYSICS) return; // No physics, no butter. From 8b2b49fb043ee32a8269ff4a0fe2db74c47e3d1a Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Tue, 31 May 2016 16:08:29 +0100 Subject: [PATCH 12/71] Just some final cleanup of the code I changed --- src/r_segs.c | 59 ++++++++++++++++------------------------------------ 1 file changed, 18 insertions(+), 41 deletions(-) diff --git a/src/r_segs.c b/src/r_segs.c index 99324d03f..ec3eaa180 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -1486,21 +1486,11 @@ static void R_RenderSegLoop (void) } else { - // note: don't use min/max macros here + // note: don't use min/max macros, since casting from INT32 to INT16 is involved here if (markceiling) - { - if (yl >= 0) - ceilingclip[rw_x] = (yl > viewheight) ? (INT16)viewheight : (INT16)((INT16)yl - 1); - else - ceilingclip[rw_x] = -1; - } - else if (markfloor) - { - if (yh < viewheight) - floorclip[rw_x] = (yh < -1) ? -1 : (INT16)((INT16)yh + 1); - else - floorclip[rw_x] = (INT16)viewheight; - } + ceilingclip[rw_x] = (yh >= 0) ? ((yl > viewheight) ? (INT16)viewheight : (INT16)((INT16)yl - 1)) : -1; + if (markfloor) + floorclip[rw_x] = (yh < viewheight) ? ((yh < -1) ? -1 : (INT16)((INT16)yh + 1)) : (INT16)viewheight; } } else @@ -1515,9 +1505,11 @@ static void R_RenderSegLoop (void) if (mid >= floorclip[rw_x]) mid = floorclip[rw_x]-1; - if (mid >= yl && yl < viewheight) + if (mid >= yl) // back ceiling lower than front ceiling ? { - if (mid >= 0) + if (yl >= viewheight) // entirely off bottom of screen + ceilingclip[rw_x] = (INT16)viewheight; + else if (mid >= 0) // safe to draw top texture { dc_yl = yl; dc_yh = mid; @@ -1527,21 +1519,14 @@ static void R_RenderSegLoop (void) colfunc(); ceilingclip[rw_x] = (INT16)mid; } - else + else // entirely off top of screen ceilingclip[rw_x] = -1; } - else if (yl >= 0) - ceilingclip[rw_x] = (yl > viewheight) ? (INT16)viewheight : (INT16)((INT16)yl - 1); else - ceilingclip[rw_x] = -1; + ceilingclip[rw_x] = (yh >= 0) ? ((yl > viewheight) ? (INT16)viewheight : (INT16)((INT16)yl - 1)) : -1; } else if (markceiling) // no top wall - { - if (yl >= 0) - ceilingclip[rw_x] = (yl > viewheight) ? (INT16)viewheight : (INT16)((INT16)yl - 1); - else - ceilingclip[rw_x] = -1; - } + ceilingclip[rw_x] = (yh >= 0) ? ((yl > viewheight) ? (INT16)viewheight : (INT16)((INT16)yl - 1)) : -1; if (bottomtexture) { @@ -1553,9 +1538,11 @@ static void R_RenderSegLoop (void) if (mid <= ceilingclip[rw_x]) mid = ceilingclip[rw_x]+1; - if (mid <= yh && yh >= 0) + if (mid <= yh) // back floor higher than front floor ? { - if (mid < viewheight) + if (yh < 0) // entirely off top of screen + floorclip[rw_x] = -1; + else if (mid < viewheight) // safe to draw bottom texture { dc_yl = mid; dc_yh = yh; @@ -1566,26 +1553,16 @@ static void R_RenderSegLoop (void) colfunc(); floorclip[rw_x] = (INT16)mid; } - else + else // entirely off bottom of screen floorclip[rw_x] = (INT16)viewheight; } - else if (yh < viewheight) - floorclip[rw_x] = (yh < -1) ? -1 : (INT16)((INT16)yh + 1); else - floorclip[rw_x] = (INT16)viewheight; + floorclip[rw_x] = (yh < viewheight) ? ((yh < -1) ? -1 : (INT16)((INT16)yh + 1)) : (INT16)viewheight; } else if (markfloor) // no bottom wall - { - if (yh < viewheight) - floorclip[rw_x] = (yh < -1) ? -1 : (INT16)((INT16)yh + 1); - else - floorclip[rw_x] = (INT16)viewheight; - } + floorclip[rw_x] = (yh < viewheight) ? ((yh < -1) ? -1 : (INT16)((INT16)yh + 1)) : (INT16)viewheight; } - if (floorclip[rw_x] > viewheight) - I_Error("floorclip[%d] > viewheight (value is %d)", rw_x, floorclip[rw_x]); - if (maskedtexture || numthicksides) { // save texturecol From 6058eec1c9c4c0b5129c72f94dce0e4a7dca01d8 Mon Sep 17 00:00:00 2001 From: toasterbabe Date: Tue, 31 May 2016 16:14:21 +0100 Subject: [PATCH 13/71] Holy shit. I spent two hours staring at how garbage this code was and didn't even realise it was #ifdef'd out behind a define not even mentioned in doomdef.h. It's not actually used anywhere (superseded entirely by the much nicer, much more relevant P_NewVertexSlope()... out with you, ancient, foul demons who should've been SPRINGCLEANed long ago. --- src/p_slopes.c | 255 ------------------------------------------------- src/p_slopes.h | 20 ---- 2 files changed, 275 deletions(-) diff --git a/src/p_slopes.c b/src/p_slopes.c index 462f7c3cb..cb5f07b2b 100644 --- a/src/p_slopes.c +++ b/src/p_slopes.c @@ -624,261 +624,6 @@ pslope_t *P_SlopeById(UINT16 id) return ret; } -#ifdef SPRINGCLEAN -#include "byteptr.h" - -#include "p_setup.h" -#include "p_local.h" - -//========================================================================== -// -// P_SetSlopesFromVertexHeights -// -//========================================================================== -void P_SetSlopesFromVertexHeights(lumpnum_t lumpnum) -{ - mapthing_t *mt; - boolean vt_found = false; - size_t i, j, k, l, q; - - //size_t i; - //mapthing_t *mt; - char *data; - char *datastart; - - // SRB2CBTODO: WHAT IS (5 * sizeof (short))?! It = 10 - // anything else seems to make a map not load properly, - // but this hard-coded value MUST have some reason for being what it is - size_t snummapthings = W_LumpLength(lumpnum) / (5 * sizeof (short)); - mapthing_t *smapthings = Z_Calloc(snummapthings * sizeof (*smapthings), PU_LEVEL, NULL); - fixed_t x, y; - sector_t *sector; - // Spawn axis points first so they are - // at the front of the list for fast searching. - data = datastart = W_CacheLumpNum(lumpnum, PU_LEVEL); - mt = smapthings; - for (i = 0; i < snummapthings; i++, mt++) - { - mt->x = READINT16(data); - mt->y = READINT16(data); - mt->angle = READINT16(data); - mt->type = READINT16(data); - mt->options = READINT16(data); - // mt->z hasn't been set yet! - //mt->extrainfo = (byte)(mt->type >> 12); // slope things are special, they have a bigger range of types - - //mt->type &= 4095; // SRB2CBTODO: WHAT IS THIS???? Mobj type limits?!!!! - x = mt->x*FRACUNIT; - y = mt->y*FRACUNIT; - sector = R_PointInSubsector(x, y)->sector; - // Z for objects -#ifdef ESLOPE - if (sector->f_slope) - mt->z = (short)(P_GetZAt(sector->f_slope, x, y)>>FRACBITS); - else -#endif - mt->z = (short)(sector->floorheight>>FRACBITS); - - mt->z = mt->z + (mt->options >> ZSHIFT); - - if (mt->type == THING_VertexFloorZ || mt->type == THING_VertexCeilingZ) // THING_VertexFloorZ - { - for(l = 0; l < numvertexes; l++) - { - if (vertexes[l].x == mt->x*FRACUNIT && vertexes[l].y == mt->y*FRACUNIT) - { - if (mt->type == THING_VertexFloorZ) - { - vertexes[l].z = mt->z*FRACUNIT; - //I_Error("Z value: %i", vertexes[l].z/FRACUNIT); - - } - else - { - vertexes[l].z = mt->z*FRACUNIT; // celing floor - } - vt_found = true; - } - } - //mt->type = 0; // VPHYSICS: Dynamic slopes - - - - - - - if (vt_found) - { - for (k = 0; k < numsectors; k++) - { - sector_t *sec = §ors[k]; - if (sec->linecount != 3) continue; // only works with triangular sectors - - v3float_t vt1, vt2, vt3; // cross = ret->normalf - v3float_t vec1, vec2; - - int vi1, vi2, vi3; - - vi1 = (int)(sec->lines[0]->v1 - vertexes); - vi2 = (int)(sec->lines[0]->v2 - vertexes); - vi3 = (sec->lines[1]->v1 == sec->lines[0]->v1 || sec->lines[1]->v1 == sec->lines[0]->v2)? - (int)(sec->lines[1]->v2 - vertexes) : (int)(sec->lines[1]->v1 - vertexes); - - //if (vertexes[vi1].z) - // I_Error("OSNAP %i", vertexes[vi1].z/FRACUNIT); - //if (vertexes[vi2].z) - // I_Error("OSNAP %i", vertexes[vi2].z/FRACUNIT); - //if (vertexes[vi3].z) - // I_Error("OSNAP %i", vertexes[vi3].z/FRACUNIT); - - //I_Error("%i, %i", mt->z*FRACUNIT, vertexes[vi1].z); - - //I_Error("%i, %i, %i", mt->x, mt->y, mt->z); - //P_SpawnMobj(mt->x*FRACUNIT, mt->y*FRACUNIT, mt->z*FRACUNIT, MT_RING); - - // TODO: Make sure not to spawn in the same place 2x! (we need an object in every vertex of the - // triangle sector to setup the real vertex slopes - // Check for the vertexes of all sectors - for(q = 0; q < numvertexes; q++) - { - if (vertexes[q].x == mt->x*FRACUNIT && vertexes[q].y == mt->y*FRACUNIT) - { - //I_Error("yeah %i", vertexes[q].z); - P_SpawnMobj(vertexes[q].x, vertexes[q].y, vertexes[q].z, MT_RING); -#if 0 - if ((mt->y*FRACUNIT == vertexes[vi1].y && mt->x*FRACUNIT == vertexes[vi1].x && mt->z*FRACUNIT == vertexes[vi1].z) - && !(mt->y*FRACUNIT == vertexes[vi2].y && mt->x*FRACUNIT == vertexes[vi2].x && mt->z*FRACUNIT == vertexes[vi2].z) - && !(mt->y*FRACUNIT == vertexes[vi3].y && mt->x*FRACUNIT == vertexes[vi3].x && mt->z*FRACUNIT == vertexes[vi3].z)) - P_SpawnMobj(vertexes[vi1].x, vertexes[vi1].y, vertexes[vi1].z, MT_RING); - else if ((mt->y*FRACUNIT == vertexes[vi2].y && mt->x*FRACUNIT == vertexes[vi2].x && mt->z*FRACUNIT == vertexes[vi2].z) - && !(mt->y*FRACUNIT == vertexes[vi1].y && mt->x*FRACUNIT == vertexes[vi1].x && mt->z*FRACUNIT == vertexes[vi1].z) - && !(mt->y*FRACUNIT == vertexes[vi3].y && mt->x*FRACUNIT == vertexes[vi3].x && mt->z*FRACUNIT == vertexes[vi3].z)) - P_SpawnMobj(vertexes[vi2].x, vertexes[vi2].y, vertexes[vi2].z, MT_BOUNCETV); - else if ((mt->y*FRACUNIT == vertexes[vi3].y && mt->x*FRACUNIT == vertexes[vi3].x && mt->z*FRACUNIT == vertexes[vi3].z) - && !(mt->y*FRACUNIT == vertexes[vi2].y && mt->x*FRACUNIT == vertexes[vi2].x && mt->z*FRACUNIT == vertexes[vi2].z) - && !(mt->y*FRACUNIT == vertexes[vi1].y && mt->x*FRACUNIT == vertexes[vi1].x && mt->z*FRACUNIT == vertexes[vi1].z)) - P_SpawnMobj(vertexes[vi3].x, vertexes[vi3].y, vertexes[vi3].z, MT_GFZFLOWER1); - else -#endif - continue; - } - } - - vt1.x = FIXED_TO_FLOAT(vertexes[vi1].x); - vt1.y = FIXED_TO_FLOAT(vertexes[vi1].y); - vt2.x = FIXED_TO_FLOAT(vertexes[vi2].x); - vt2.y = FIXED_TO_FLOAT(vertexes[vi2].y); - vt3.x = FIXED_TO_FLOAT(vertexes[vi3].x); - vt3.y = FIXED_TO_FLOAT(vertexes[vi3].y); - - for(j = 0; j < 2; j++) - { - - fixed_t z3; - //I_Error("Lo hicimos"); - - vt1.z = mt->z;//FIXED_TO_FLOAT(j==0 ? sec->floorheight : sec->ceilingheight); - vt2.z = mt->z;//FIXED_TO_FLOAT(j==0? sec->floorheight : sec->ceilingheight); - z3 = mt->z;//j==0? sec->floorheight : sec->ceilingheight; // Destination height - vt3.z = FIXED_TO_FLOAT(z3); - - if (P_PointOnLineSide(vertexes[vi3].x, vertexes[vi3].y, sec->lines[0]) == 0) - { - vec1.x = vt2.x - vt3.x; - vec1.y = vt2.y - vt3.y; - vec1.z = vt2.z - vt3.z; - - vec2.x = vt1.x - vt3.x; - vec2.y = vt1.y - vt3.y; - vec2.z = vt1.z - vt3.z; - } - else - { - vec1.x = vt1.x - vt3.x; - vec1.y = vt1.y - vt3.y; - vec1.z = vt1.z - vt3.z; - - vec2.x = vt2.x - vt3.x; - vec2.y = vt2.y - vt3.y; - vec2.z = vt2.z - vt3.z; - } - - - pslope_t *ret = Z_Malloc(sizeof(pslope_t), PU_LEVEL, NULL); - memset(ret, 0, sizeof(*ret)); - - { - M_CrossProduct3f(&ret->normalf, &vec1, &vec2); - - // Cross product length - float len = (float)sqrt(ret->normalf.x * ret->normalf.x + - ret->normalf.y * ret->normalf.y + - ret->normalf.z * ret->normalf.z); - - if (len == 0) - { - // Only happens when all vertices in this sector are on the same line. - // Let's just ignore this case. - //CONS_Printf("Slope thing at (%d,%d) lies directly on its target line.\n", (int)(x>>16), (int)(y>>16)); - return; - } - // cross/len - ret->normalf.x /= len; - ret->normalf.y /= len; - ret->normalf.z /= len; - - // ZDoom cross = ret->normalf - // Fix backward normals - if ((ret->normalf.z < 0 && j == 0) || (ret->normalf.z > 0 && j == 1)) - { - // cross = -cross - ret->normalf.x = -ret->normalf.x; - ret->normalf.y = -ret->normalf.x; - ret->normalf.z = -ret->normalf.x; - } - } - - secplane_t *srcplane = Z_Calloc(sizeof(*srcplane), PU_LEVEL, NULL); - - srcplane->a = FLOAT_TO_FIXED (ret->normalf.x); - srcplane->b = FLOAT_TO_FIXED (ret->normalf.y); - srcplane->c = FLOAT_TO_FIXED (ret->normalf.z); - //srcplane->ic = FixedDiv(FRACUNIT, srcplane->c); - srcplane->d = -TMulScale16 (srcplane->a, vertexes[vi3].x, - srcplane->b, vertexes[vi3].y, - srcplane->c, z3); - - if (j == 0) - { - sec->f_slope = ret; - sec->f_slope->secplane = *srcplane; - } - else if (j == 1) - { - sec->c_slope = ret; - sec->c_slope->secplane = *srcplane; - } - } - } - } - - - - - - - - - } - } - Z_Free(datastart); - - - - -} -#endif - // Reset the dynamic slopes pointer, and read all of the fancy schmancy slopes void P_ResetDynamicSlopes(void) { size_t i; diff --git a/src/p_slopes.h b/src/p_slopes.h index 80921a84b..dd9b6f2d2 100644 --- a/src/p_slopes.h +++ b/src/p_slopes.h @@ -21,26 +21,6 @@ void P_RunDynamicSlopes(void); // sectors. void P_SpawnSlope_Line(int linenum); -#ifdef SPRINGCLEAN -// Loads just map objects that make slopes, -// terrain affecting objects have to be spawned first -void P_SetSlopesFromVertexHeights(lumpnum_t lumpnum); - -typedef enum -{ - THING_SlopeFloorPointLine = 9500, - THING_SlopeCeilingPointLine = 9501, - THING_SetFloorSlope = 9502, - THING_SetCeilingSlope = 9503, - THING_CopyFloorPlane = 9510, - THING_CopyCeilingPlane = 9511, - THING_VavoomFloor=1500, - THING_VavoomCeiling=1501, - THING_VertexFloorZ=1504, - THING_VertexCeilingZ=1505, -} slopething_e; -#endif - // // P_CopySectorSlope // From da2abbb39ff5302ee7a86e0dd717f1185af0a00a Mon Sep 17 00:00:00 2001 From: toasterbabe Date: Tue, 31 May 2016 16:24:51 +0100 Subject: [PATCH 14/71] Failed a build because C is an obnoxious language. --- src/p_slopes.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/p_slopes.c b/src/p_slopes.c index cb5f07b2b..bd354c500 100644 --- a/src/p_slopes.c +++ b/src/p_slopes.c @@ -764,10 +764,11 @@ fixed_t P_GetZAt(pslope_t *slope, fixed_t x, fixed_t y) // When given a vector, rotates it and aligns it to a slope void P_QuantizeMomentumToSlope(vector3_t *momentum, pslope_t *slope) { + vector3_t axis; // Fuck you, C90. + if (slope->flags & SL_NOPHYSICS) return; // No physics, no quantizing. - vector3_t axis; axis.x = -slope->d.y; axis.y = slope->d.x; axis.z = 0; @@ -804,6 +805,8 @@ void P_SlopeLaunch(mobj_t *mo) // Function to help handle landing on slopes 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); @@ -812,7 +815,6 @@ void P_HandleSlopeLanding(mobj_t *thing, pslope_t *slope) return; } - vector3_t mom; mom.x = thing->momx; mom.y = thing->momy; mom.z = thing->momz*2; From d998ddfae46f0250d1336488fe3e99ca1d2c4c95 Mon Sep 17 00:00:00 2001 From: toasterbabe Date: Tue, 31 May 2016 17:07:28 +0100 Subject: [PATCH 15/71] When you haven't found all the vertices, it's just not safe to carry on. Hit them with a descriptive I_Error so they don't get confused as hell like Glaber did. http://mb.srb2.org/showthread.php?t=41455 for reference. Also took the opportunity to nuke or otherwise neuter a bunch of Kalaron's bizzare ramblings (most are questions which have long-been answered by Red's efforts) at the same time. --- src/p_slopes.c | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/src/p_slopes.c b/src/p_slopes.c index bd354c500..659f8b330 100644 --- a/src/p_slopes.c +++ b/src/p_slopes.c @@ -200,7 +200,6 @@ static fixed_t P_GetExtent(sector_t *sector, line_t *line) // Find furthest vertex from the reference line. It, along with the two ends // of the line, will define the plane. - // SRB2CBTODO: Use a formula to get the slope to slide objects depending on how steep for(i = 0; i < sector->linecount; i++) { line_t *li = sector->lines[i]; @@ -232,7 +231,6 @@ static fixed_t P_GetExtent(sector_t *sector, line_t *line) // // Creates one or more slopes based on the given line type and front/back // sectors. -// Kalaron: Check if dynamic slopes need recalculation // void P_SpawnSlope_Line(int linenum) { @@ -277,7 +275,7 @@ void P_SpawnSlope_Line(int linenum) ny = -FixedDiv(line->dx, len); } - // SRB2CBTODO: Transform origin relative to the bounds of an individual FOF + // TODO: Transform origin relative to the bounds of an individual FOF origin.x = line->v1->x + (line->v2->x - line->v1->x)/2; origin.y = line->v1->y + (line->v2->y - line->v1->y)/2; @@ -328,7 +326,7 @@ void P_SpawnSlope_Line(int linenum) // fslope->normal is a 3D line perpendicular to the 3D vector // Sync the linedata of the line that started this slope - // SRB2CBTODO: Anything special for remote(control sector)-based slopes later? + // TODO: Anything special for control sector based slopes later? fslope->sourceline = line; // To find the real highz/lowz of a slope, you need to check all the vertexes @@ -380,7 +378,7 @@ void P_SpawnSlope_Line(int linenum) cslope->refpos = 2; // Sync the linedata of the line that started this slope - // SRB2CBTODO: Anything special for remote(control sector)-based slopes later? + // TODO: Anything special for control sector based slopes later? cslope->sourceline = line; // Remember the way the slope is formed @@ -446,7 +444,7 @@ void P_SpawnSlope_Line(int linenum) fslope->refpos = 3; // Sync the linedata of the line that started this slope - // SRB2CBTODO: Anything special for remote(control sector)-based slopes later? + // TODO: Anything special for control sector based slopes later? fslope->sourceline = line; // Remember the way the slope is formed @@ -489,7 +487,7 @@ void P_SpawnSlope_Line(int linenum) cslope->refpos = 4; // Sync the linedata of the line that started this slope - // SRB2CBTODO: Anything special for remote(control sector)-based slopes later? + // TODO: Anything special for control sector based slopes later? cslope->sourceline = line; // Remember the way the slope is formed @@ -555,16 +553,11 @@ static pslope_t *P_NewVertexSlope(INT16 tag1, INT16 tag2, INT16 tag3, UINT8 flag ret->vertices[2] = mt; } - if (!ret->vertices[0]) - CONS_Printf("PANIC 0\n"); - if (!ret->vertices[1]) - CONS_Printf("PANIC 1\n"); - if (!ret->vertices[2]) - CONS_Printf("PANIC 2\n"); - // Now set heights for each vertex, because they haven't been set yet for (i = 0; i < 3; i++) { mt = ret->vertices[i]; + if (!mt) // If a vertex wasn't found, it's game over. There's nothing you can do to recover (except maybe try and kill the slope instead - TODO?) + I_Error("Slope vertex %d (for linedef tag %d) not found.", i, tag1); if (mt->extrainfo) mt->z = mt->options; else From d4d44777f43297f398247f8db81302d493f25763 Mon Sep 17 00:00:00 2001 From: toasterbabe Date: Tue, 31 May 2016 17:43:27 +0100 Subject: [PATCH 16/71] Okay, now vertex slopes aren't placement-order-dependent any more. Hopefully this is the best way to handle things. --- src/p_slopes.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/p_slopes.c b/src/p_slopes.c index 659f8b330..d9e2cef66 100644 --- a/src/p_slopes.c +++ b/src/p_slopes.c @@ -546,9 +546,17 @@ static pslope_t *P_NewVertexSlope(INT16 tag1, INT16 tag2, INT16 tag3, UINT8 flag continue; if (!ret->vertices[0] && mt->angle == tag1) + { ret->vertices[0] = mt; + mt = mapthings; + i = 0; + } else if (!ret->vertices[1] && mt->angle == tag2) + { ret->vertices[1] = mt; + mt = mapthings; + i = 0; + } else if (!ret->vertices[2] && mt->angle == tag3) ret->vertices[2] = mt; } From 7071fbe29e5c078631c6dae366ca81bcbc570e34 Mon Sep 17 00:00:00 2001 From: toasterbabe Date: Tue, 31 May 2016 18:13:17 +0100 Subject: [PATCH 17/71] I made a mistake. Fuck git reverts, they are a nightmare, let's just do this the old fashioned way. --- src/p_slopes.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/p_slopes.c b/src/p_slopes.c index d9e2cef66..659f8b330 100644 --- a/src/p_slopes.c +++ b/src/p_slopes.c @@ -546,17 +546,9 @@ static pslope_t *P_NewVertexSlope(INT16 tag1, INT16 tag2, INT16 tag3, UINT8 flag continue; if (!ret->vertices[0] && mt->angle == tag1) - { ret->vertices[0] = mt; - mt = mapthings; - i = 0; - } else if (!ret->vertices[1] && mt->angle == tag2) - { ret->vertices[1] = mt; - mt = mapthings; - i = 0; - } else if (!ret->vertices[2] && mt->angle == tag3) ret->vertices[2] = mt; } From 62c4338d60740d8147fab5503f23130f7604444f Mon Sep 17 00:00:00 2001 From: toasterbabe Date: Wed, 1 Jun 2016 13:19:44 +0100 Subject: [PATCH 18/71] Added P_GetMobjGravity to Lua. Check /toaster/gravitytest.lua for sample script. --- src/lua_baselib.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 7678c7c49..05ba00d68 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -13,6 +13,7 @@ #include "doomdef.h" #ifdef HAVE_BLUA #include "p_local.h" +#include "p_mobj.h" // So we can have P_GetMobjGravity #include "p_setup.h" // So we can have P_SetupLevelSky #include "z_zone.h" #include "r_main.h" @@ -437,6 +438,16 @@ static int lib_pMobjFlip(lua_State *L) return 1; } +static int lib_pGetMobjGravity(lua_State *L) +{ + mobj_t *mobj = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); + //HUDSAFE + if (!mobj) + return LUA_ErrInvalid(L, "mobj_t"); + lua_pushinteger(L, P_GetMobjGravity(mobj)); + return 1; +} + static int lib_pWeaponOrPanel(lua_State *L) { mobjtype_t type = luaL_checkinteger(L, 1); @@ -2008,6 +2019,7 @@ static luaL_Reg lib[] = { {"P_SPMAngle",lib_pSPMAngle}, {"P_SpawnPlayerMissile",lib_pSpawnPlayerMissile}, {"P_MobjFlip",lib_pMobjFlip}, + {"P_GetMobjGravity",lib_pGetMobjGravity}, {"P_WeaponOrPanel",lib_pWeaponOrPanel}, {"P_FlashPal",lib_pFlashPal}, {"P_GetClosestAxis",lib_pGetClosestAxis}, From 76d108d760a004a6e522c3364452c89074c68f0b Mon Sep 17 00:00:00 2001 From: toasterbabe Date: Wed, 1 Jun 2016 14:49:14 +0100 Subject: [PATCH 19/71] Whoops, didn't realise pushing fixed and integer were different. My mistake. --- 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 05ba00d68..c88ece50c 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -444,7 +444,7 @@ static int lib_pGetMobjGravity(lua_State *L) //HUDSAFE if (!mobj) return LUA_ErrInvalid(L, "mobj_t"); - lua_pushinteger(L, P_GetMobjGravity(mobj)); + lua_pushfixed(L, P_GetMobjGravity(mobj)); return 1; } From ae8b45965c4eb13856faffa1d4330634d200250d Mon Sep 17 00:00:00 2001 From: toasterbabe Date: Wed, 1 Jun 2016 16:45:10 +0100 Subject: [PATCH 20/71] No Size_t --> int in an I_Error print! [/rhyme] --- 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 659f8b330..4a8eadc5f 100644 --- a/src/p_slopes.c +++ b/src/p_slopes.c @@ -557,7 +557,7 @@ static pslope_t *P_NewVertexSlope(INT16 tag1, INT16 tag2, INT16 tag3, UINT8 flag for (i = 0; i < 3; i++) { mt = ret->vertices[i]; if (!mt) // If a vertex wasn't found, it's game over. There's nothing you can do to recover (except maybe try and kill the slope instead - TODO?) - I_Error("Slope vertex %d (for linedef tag %d) not found.", i, tag1); + I_Error("Slope vertex %s (for linedef tag %d) not found.", sizeu1(i), tag1); if (mt->extrainfo) mt->z = mt->options; else From 44a6e8bb54db02e7085ddf7098fad38c56928210 Mon Sep 17 00:00:00 2001 From: toasterbabe Date: Wed, 1 Jun 2016 19:52:12 +0100 Subject: [PATCH 21/71] I_Error description syntax consistency (buzzword buzzword buzzword). --- 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 4a8eadc5f..72abf02bb 100644 --- a/src/p_slopes.c +++ b/src/p_slopes.c @@ -557,7 +557,7 @@ static pslope_t *P_NewVertexSlope(INT16 tag1, INT16 tag2, INT16 tag3, UINT8 flag for (i = 0; i < 3; i++) { mt = ret->vertices[i]; if (!mt) // If a vertex wasn't found, it's game over. There's nothing you can do to recover (except maybe try and kill the slope instead - TODO?) - I_Error("Slope vertex %s (for linedef tag %d) not found.", sizeu1(i), tag1); + I_Error("P_NewVertexSlope: Slope vertex %s (for linedef tag %d) not found!", sizeu1(i), tag1); if (mt->extrainfo) mt->z = mt->options; else From 1493537dfc7f0d2544d621fbf30157a34693d29d Mon Sep 17 00:00:00 2001 From: toasterbabe Date: Thu, 2 Jun 2016 14:39:41 +0100 Subject: [PATCH 22/71] Moved the standingslope check in P_ZMovement to after the FOF and height adjustment as it is in P_PlayerZMovement, as reccomended. Doesn't actually stop Crawla jittering, but might as well make it happen for consistency's sake. --- src/p_mobj.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index 35d8f1ad2..acf5b1b36 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -2165,16 +2165,6 @@ static boolean P_ZMovement(mobj_t *mo) I_Assert(mo != NULL); I_Assert(!P_MobjWasRemoved(mo)); -#ifdef ESLOPE - if (mo->standingslope) - { - if (mo->flags & MF_NOCLIPHEIGHT) - mo->standingslope = NULL; - else if (!P_IsObjectOnGround(mo)) - P_SlopeLaunch(mo); - } -#endif - // Intercept the stupid 'fall through 3dfloors' bug if (mo->subsector->sector->ffloors) P_AdjustMobjFloorZ_FFloors(mo, mo->subsector->sector, 0); @@ -2189,6 +2179,16 @@ static boolean P_ZMovement(mobj_t *mo) } mo->z += mo->momz; +#ifdef ESLOPE + if (mo->standingslope) + { + if (mo->flags & MF_NOCLIPHEIGHT) + mo->standingslope = NULL; + else if (!P_IsObjectOnGround(mo)) + P_SlopeLaunch(mo); + } +#endif + switch (mo->type) { case MT_THROWNBOUNCE: From 213a9632ca4b5cd68902bc805cc625d5b24d3e41 Mon Sep 17 00:00:00 2001 From: toasterbabe Date: Thu, 2 Jun 2016 16:09:33 +0100 Subject: [PATCH 23/71] Let's multiply the thrust by the mobj's friction. You should have less chance of purchase on a slippery slope (tee hee) and more on a rough one, but the slopes were basically identical during testing before I implemented this change. --- src/p_slopes.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/p_slopes.c b/src/p_slopes.c index 72abf02bb..ec07ab2fe 100644 --- a/src/p_slopes.c +++ b/src/p_slopes.c @@ -864,8 +864,6 @@ void P_ButteredSlope(mobj_t *mo) mult = FINECOSINE(angle >> ANGLETOFINESHIFT); } - //CONS_Printf("%d\n", mult); - thrust = FixedMul(thrust, FRACUNIT*2/3 + mult/8); } @@ -873,11 +871,18 @@ void P_ButteredSlope(mobj_t *mo) 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 - // Multiply by gravity - thrust = FixedMul(thrust, FixedMul(gravity, abs(P_GetMobjGravity(mo)))); // Now uses the absolute of mobj gravity. You're welcome. - // Multiply by scale (gravity strength depends on mobj scale) + // The strength of gravity depends on the global gravity base setting... + thrust = FixedMul(thrust, gravity); + + // ...the sector-based gravity strength... + thrust = FixedMul(thrust, abs(P_GetMobjGravity(mo))); + + // ...and the scale of the object. thrust = FixedMul(thrust, mo->scale); + // Let's also multiply by friction for good measure. + thrust = FixedMul(thrust, mo->friction); + P_Thrust(mo, mo->standingslope->xydirection, thrust); } From 882622d2e70616376e81f82b8471645a1ac75721 Mon Sep 17 00:00:00 2001 From: toasterbabe Date: Thu, 2 Jun 2016 16:42:07 +0100 Subject: [PATCH 24/71] ...I made two major mistakes with P_GetMobjGravity. *Didn't take into account object scale *Doubled force when on the ground (ignore what the comment of the line I moved says, it was relevant for slopes...) This also led to a mistake with slopes, where I was double-multiplying by the gravity constant to get half (because of a quirk of numbers...) --- src/p_mobj.c | 10 ++++++---- src/p_slopes.c | 12 +++--------- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index acf5b1b36..843123d57 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -1316,9 +1316,6 @@ fixed_t P_GetMobjGravity(mobj_t *mo) if (mo->eflags & MFE_UNDERWATER && !goopgravity) gravityadd = gravityadd/3; - if (!mo->momz) // mobj at stop, no floor, so feel the push of gravity! - gravityadd <<= 1; - if (mo->player) { if (mo->player->charability == CA_FLY && (mo->player->powers[pw_tailsfly] @@ -1402,6 +1399,8 @@ fixed_t P_GetMobjGravity(mobj_t *mo) if (mo->player && !!(mo->eflags & MFE_VERTICALFLIP) != wasflip) P_PlayerFlip(mo); + gravityadd = FixedMul(gravityadd, mo->scale); + return gravityadd; } @@ -1416,8 +1415,11 @@ void P_CheckGravity(mobj_t *mo, boolean affect) { fixed_t gravityadd = P_GetMobjGravity(mo); + if (!mo->momz) // mobj at stop, no floor, so feel the push of gravity! + gravityadd <<= 1; + if (affect) - mo->momz += FixedMul(gravityadd, mo->scale); + mo->momz += gravityadd; if (mo->type == MT_SKIM && mo->z + mo->momz <= mo->watertop && mo->z >= mo->watertop) { diff --git a/src/p_slopes.c b/src/p_slopes.c index ec07ab2fe..ed25f00f3 100644 --- a/src/p_slopes.c +++ b/src/p_slopes.c @@ -812,7 +812,7 @@ void P_HandleSlopeLanding(mobj_t *thing, pslope_t *slope) mom.y = thing->momy; mom.z = thing->momz*2; - //CONS_Printf("langing on slope\n"); + //CONS_Printf("Landing on slope\n"); // Reverse quantizing might could use its own function later slope->zangle = ANGLE_MAX-slope->zangle; @@ -871,16 +871,10 @@ void P_ButteredSlope(mobj_t *mo) 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 - // The strength of gravity depends on the global gravity base setting... - thrust = FixedMul(thrust, gravity); - - // ...the sector-based gravity strength... + // Let's get the gravity strength for the object... thrust = FixedMul(thrust, abs(P_GetMobjGravity(mo))); - // ...and the scale of the object. - thrust = FixedMul(thrust, mo->scale); - - // Let's also multiply by friction for good measure. + // ... and its friction against the ground for good measure. thrust = FixedMul(thrust, mo->friction); P_Thrust(mo, mo->standingslope->xydirection, thrust); From c1caf2132328985fc5abdbe65f08dc22bbd0aa8e Mon Sep 17 00:00:00 2001 From: toasterbabe Date: Thu, 2 Jun 2016 16:51:12 +0100 Subject: [PATCH 25/71] Reccomended by MI: Dividing by the original friction value just so slopes with normal friction don't behave differently between next and this branch. --- src/p_slopes.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/p_slopes.c b/src/p_slopes.c index ed25f00f3..797c6a558 100644 --- a/src/p_slopes.c +++ b/src/p_slopes.c @@ -874,8 +874,8 @@ void P_ButteredSlope(mobj_t *mo) // Let's get the gravity strength for the object... thrust = FixedMul(thrust, abs(P_GetMobjGravity(mo))); - // ... and its friction against the ground for good measure. - thrust = FixedMul(thrust, mo->friction); + // ... and its friction against the ground for good measure (divided by original friction to keep behaviour for normal slopes the same). + thrust = FixedMul(thrust, FixedDiv(mo->friction, ORIG_FRICTION)); P_Thrust(mo, mo->standingslope->xydirection, thrust); } From ba528a075ee578bd4b10d4f1bb56b424c6e1ae44 Mon Sep 17 00:00:00 2001 From: toasterbabe Date: Sat, 4 Jun 2016 19:47:40 +0100 Subject: [PATCH 26/71] Last few changes as reccomended by Red. (<3 u, no hetero) --- src/doomdef.h | 2 +- src/p_slopes.c | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/doomdef.h b/src/doomdef.h index e645c0848..cec46a32c 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -431,7 +431,7 @@ extern const char *compdate, *comptime, *comprevision, *compbranch; /// Kalaron/Eternity Engine slope code (SRB2CB ported) #define ESLOPE -#if defined(ESLOPE) +#ifdef ESLOPE /// Backwards compatibility with SRB2CB's slope linedef types. /// \note A simple shim that prints a warning. #define ESLOPE_TYPESHIM diff --git a/src/p_slopes.c b/src/p_slopes.c index 797c6a558..b6338d95d 100644 --- a/src/p_slopes.c +++ b/src/p_slopes.c @@ -275,7 +275,6 @@ void P_SpawnSlope_Line(int linenum) ny = -FixedDiv(line->dx, len); } - // TODO: Transform origin relative to the bounds of an individual FOF origin.x = line->v1->x + (line->v2->x - line->v1->x)/2; origin.y = line->v1->y + (line->v2->y - line->v1->y)/2; From 60dd8dab3c92dff4cdd236644db189ca151c47f6 Mon Sep 17 00:00:00 2001 From: toasterbabe Date: Mon, 6 Jun 2016 18:11:23 +0100 Subject: [PATCH 27/71] Backported clipping fix for FF_REVERSEPLATFORM collision. --- 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 68fb1696f..aa795a153 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -2018,7 +2018,8 @@ static void P_AdjustMobjFloorZ_FFloors(mobj_t *mo, sector_t *sector, UINT8 motyp mo->floorz = topheight; } if (bottomheight < mo->ceilingz && abs(delta1) >= abs(delta2) - && !(rover->flags & FF_PLATFORM)) + && !(rover->flags & FF_PLATFORM) + && ((mo->momz > 0) || (!(rover->flags & FF_REVERSEPLATFORM)))) // Only clip for FOFs that are intangible from the top if you're coming from below { mo->ceilingz = bottomheight; } From 7c0eee6ff1b37488f4a84af37b7ab68e4b8bcf28 Mon Sep 17 00:00:00 2001 From: toasterbabe Date: Mon, 6 Jun 2016 20:53:29 +0100 Subject: [PATCH 28/71] The fix now takes reverse gravity platform step-up into account properly. --- src/p_mobj.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index aa795a153..e15eae747 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -2013,13 +2013,14 @@ static void P_AdjustMobjFloorZ_FFloors(mobj_t *mo, sector_t *sector, UINT8 motyp delta1 = mo->z - (bottomheight + ((topheight - bottomheight)/2)); delta2 = thingtop - (bottomheight + ((topheight - bottomheight)/2)); if (topheight > mo->floorz && abs(delta1) < abs(delta2) - && !(rover->flags & FF_REVERSEPLATFORM)) + && !(rover->flags & FF_REVERSEPLATFORM) + && ((P_MobjFlip(mo)*mo->momz < 0) || (!(rover->flags & FF_PLATFORM)))) // In reverse gravity, only clip for FOFs that are intangible from their bottom (the "top" you're falling through) if you're coming from above ("below" in your frame of reference) { mo->floorz = topheight; } if (bottomheight < mo->ceilingz && abs(delta1) >= abs(delta2) && !(rover->flags & FF_PLATFORM) - && ((mo->momz > 0) || (!(rover->flags & FF_REVERSEPLATFORM)))) // Only clip for FOFs that are intangible from the top if you're coming from below + && ((P_MobjFlip(mo)*mo->momz > 0) || (!(rover->flags & FF_REVERSEPLATFORM)))) // In normal gravity, only clip for FOFs that are intangible from the top if you're coming from below { mo->ceilingz = bottomheight; } From 26744c2a6b914150719f923e7ef0c9112fb82d85 Mon Sep 17 00:00:00 2001 From: toasterbabe Date: Mon, 6 Jun 2016 21:02:47 +0100 Subject: [PATCH 29/71] woops #1 --- 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 e15eae747..6a6736793 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -2014,7 +2014,7 @@ static void P_AdjustMobjFloorZ_FFloors(mobj_t *mo, sector_t *sector, UINT8 motyp delta2 = thingtop - (bottomheight + ((topheight - bottomheight)/2)); if (topheight > mo->floorz && abs(delta1) < abs(delta2) && !(rover->flags & FF_REVERSEPLATFORM) - && ((P_MobjFlip(mo)*mo->momz < 0) || (!(rover->flags & FF_PLATFORM)))) // In reverse gravity, only clip for FOFs that are intangible from their bottom (the "top" you're falling through) if you're coming from above ("below" in your frame of reference) + && ((P_MobjFlip(mo)*mo->momz > 0) || (!(rover->flags & FF_PLATFORM)))) // In reverse gravity, only clip for FOFs that are intangible from their bottom (the "top" you're falling through) if you're coming from above ("below" in your frame of reference) { mo->floorz = topheight; } From 9d221f4f3f7817c567ad2a7f750ad58b57d1971c Mon Sep 17 00:00:00 2001 From: toasterbabe Date: Tue, 7 Jun 2016 17:37:25 +0100 Subject: [PATCH 30/71] Teetering now supports slopes properly. Behaves ALMOST as you'd expect. It gets the z position of the slope at the player coordinates when it comes to the sectorlist check (which is first), though, so there's a few oddities that are amplified with steep slopes: * If the slope's sloping away from you at a steep angle, you might not be able to step down onto it, but you won't teeter (because it's at a step-down-able height if it extended to directly beneath you) * If the slope's sloping towards you at a steep angle, you might end up in teetering frames when you're able to step down onto it (because it's NOT at a step-down-able height if it extended to directly beneath you) HOWEVER, it would be pretty obnoxious to hold back code which is functionally superior in every way otherwise, and it doesn't really seem like there's a good way to get that checked tbph --- src/p_user.c | 202 +++++++++++++++++++++++++++++++++------------------ 1 file changed, 132 insertions(+), 70 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index 461497bcb..346dd3ded 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -2853,90 +2853,124 @@ static void P_DoTeeter(player_t *player) boolean teeter = false; boolean roverfloor; // solid 3d floors? boolean checkedforteeter = false; + fixed_t floorheight, ceilingheight; + fixed_t topheight, bottomheight; // for 3d floor usage const fixed_t tiptop = FixedMul(MAXSTEPMOVE, player->mo->scale); // Distance you have to be above the ground in order to teeter. - for (node = player->mo->touching_sectorlist; node; node = node->m_snext) +#define maxzdelta 3<<(FRACBITS-2) // 3/4 on the fixed scale + if (player->mo->standingslope && player->mo->standingslope->zdelta >= maxzdelta) // Always teeter if the slope is too steep. + teeter = true; +#undef maxzdelta + else // Let's do some checks... { - // Ledge teetering. Check if any nearby sectors are low enough from your current one. - checkedforteeter = true; - roverfloor = false; - if (node->m_sector->ffloors) + for (node = player->mo->touching_sectorlist; node; node = node->m_snext) { - ffloor_t *rover; - for (rover = node->m_sector->ffloors; rover; rover = rover->next) + // Ledge teetering. Check if any nearby sectors are low enough from your current one. + checkedforteeter = true; + roverfloor = false; + + ceilingheight = node->m_sector->ceilingheight; + floorheight = node->m_sector->floorheight; +#ifdef ESLOPE + if (node->m_sector->c_slope) + ceilingheight = P_GetZAt(node->m_sector->c_slope, player->mo->x, player->mo->y) + FixedMul(node->m_sector->c_slope->zdelta, tiptop); + if (node->m_sector->f_slope) + floorheight = P_GetZAt(node->m_sector->f_slope, player->mo->x, player->mo->y); +#endif + + if (node->m_sector->ffloors) { - if (!(rover->flags & FF_EXISTS)) continue; - - if (P_CheckSolidLava(player->mo, rover)) - ; - else if (!(rover->flags & FF_BLOCKPLAYER || rover->flags & FF_QUICKSAND)) - continue; // intangible 3d floor - - if (player->mo->eflags & MFE_VERTICALFLIP) + ffloor_t *rover; + for (rover = node->m_sector->ffloors; rover; rover = rover->next) { - if (*rover->bottomheight > node->m_sector->ceilingheight) // Above the ceiling - continue; + if (!(rover->flags & FF_EXISTS)) continue; - if (*rover->bottomheight > player->mo->z + player->mo->height + tiptop - || (*rover->topheight < player->mo->z - && player->mo->z + player->mo->height < node->m_sector->ceilingheight - tiptop)) + topheight = *rover->topheight; + bottomheight = *rover->bottomheight; + +#ifdef ESLOPE + if (*rover->t_slope) + topheight = P_GetZAt(*rover->t_slope, player->mo->x, player->mo->y); + if (*rover->b_slope) + bottomheight = P_GetZAt(*rover->b_slope, player->mo->x, player->mo->y); +#endif + + if (P_CheckSolidLava(player->mo, rover)) + ; + else if (!(rover->flags & FF_BLOCKPLAYER || rover->flags & FF_QUICKSAND)) + continue; // intangible 3d floor + + if (player->mo->eflags & MFE_VERTICALFLIP) { - teeter = true; - roverfloor = true; + if (bottomheight > ceilingheight) // Above the ceiling + continue; + + if (bottomheight > player->mo->z + player->mo->height + tiptop + || (topheight < player->mo->z + && player->mo->z + player->mo->height < ceilingheight - tiptop)) + { + teeter = true; + roverfloor = true; + } + else + { + teeter = false; + roverfloor = true; + break; + } } else { - teeter = false; - roverfloor = true; - break; + if (topheight < floorheight) // Below the floor + continue; + + if (topheight < player->mo->z - tiptop + || (bottomheight > player->mo->z + player->mo->height + && player->mo->z > floorheight + tiptop)) + { + teeter = true; + roverfloor = true; + } + else + { + teeter = false; + roverfloor = true; + break; + } } } + } + + if (!teeter && !roverfloor) + { + if (player->mo->eflags & MFE_VERTICALFLIP) + { + if (ceilingheight > player->mo->z + player->mo->height + tiptop) + teeter = true; + } else { - if (*rover->topheight < node->m_sector->floorheight) // Below the floor - continue; - - if (*rover->topheight < player->mo->z - tiptop - || (*rover->bottomheight > player->mo->z + player->mo->height - && player->mo->z > node->m_sector->floorheight + tiptop)) - { + if (floorheight < player->mo->z - tiptop) teeter = true; - roverfloor = true; - } - else - { - teeter = false; - roverfloor = true; - break; - } } } } - - if (!teeter && !roverfloor) - { - if (player->mo->eflags & MFE_VERTICALFLIP) - { - if (node->m_sector->ceilingheight > player->mo->z + player->mo->height + tiptop) - teeter = true; - } - else - { - if (node->m_sector->floorheight < player->mo->z - tiptop) - teeter = true; - } - } } if (checkedforteeter && !teeter) // Backup code { subsector_t *subsec[4]; // changed abcd into array instead + fixed_t subsecfloorheight[4]; + fixed_t subsecceilingheight[4]; UINT8 i; + // Following is replaced by xsign and ysign code + /* subsec[0] = R_PointInSubsector(player->mo->x + FixedMul(5*FRACUNIT, player->mo->scale), player->mo->y + FixedMul(5*FRACUNIT, player->mo->scale)); subsec[1] = R_PointInSubsector(player->mo->x - FixedMul(5*FRACUNIT, player->mo->scale), player->mo->y + FixedMul(5*FRACUNIT, player->mo->scale)); subsec[2] = R_PointInSubsector(player->mo->x + FixedMul(5*FRACUNIT, player->mo->scale), player->mo->y - FixedMul(5*FRACUNIT, player->mo->scale)); subsec[3] = R_PointInSubsector(player->mo->x - FixedMul(5*FRACUNIT, player->mo->scale), player->mo->y - FixedMul(5*FRACUNIT, player->mo->scale)); + */ teeter = false; roverfloor = false; @@ -2944,6 +2978,24 @@ static void P_DoTeeter(player_t *player) { ffloor_t *rover; +#define xsign ((i & 1) ? -1 : 1) // 0 -> 1 | 1 -> -1 | 2 -> 1 | 3 -> -1 +#define ysign ((i & 2) ? 1 : -1) // 0 -> 1 | 1 -> 1 | 2 -> -1 | 3 -> -1 + fixed_t checkx = player->mo->x + (xsign*FixedMul(5*FRACUNIT, player->mo->scale)); + fixed_t checky = player->mo->y + (ysign*FixedMul(5*FRACUNIT, player->mo->scale)); + + subsec[i] = R_PointInSubsector(checkx, checky); + + subsecceilingheight[i] = subsec[i]->sector->ceilingheight; + subsecfloorheight[i] = subsec[i]->sector->floorheight; +#ifdef ESLOPE + if (subsec[i]->sector->c_slope) + subsecceilingheight[i] = P_GetZAt(subsec[i]->sector->c_slope, checkx, checky); + if (subsec[i]->sector->f_slope) + subsecfloorheight[i] = P_GetZAt(subsec[i]->sector->f_slope, checkx, checky); +#endif +#undef xsign +#undef ysign + if (!(subsec[i]->sector->ffloors)) continue; // move on to the next subsector @@ -2951,6 +3003,16 @@ static void P_DoTeeter(player_t *player) { if (!(rover->flags & FF_EXISTS)) continue; + topheight = *rover->topheight; + bottomheight = *rover->bottomheight; + +#ifdef ESLOPE + if (*rover->t_slope) + topheight = P_GetZAt(*rover->t_slope, player->mo->x, player->mo->y); + if (*rover->b_slope) + bottomheight = P_GetZAt(*rover->b_slope, player->mo->x, player->mo->y); +#endif + if (P_CheckSolidLava(player->mo, rover)) ; else if (!(rover->flags & FF_BLOCKPLAYER || rover->flags & FF_QUICKSAND)) @@ -2958,12 +3020,12 @@ static void P_DoTeeter(player_t *player) if (player->mo->eflags & MFE_VERTICALFLIP) { - if (*rover->bottomheight > subsec[i]->sector->ceilingheight) // Above the ceiling + if (bottomheight > subsecceilingheight[i]) // Above the ceiling continue; - if (*rover->bottomheight > player->mo->z + player->mo->height + tiptop - || (*rover->topheight < player->mo->z - && player->mo->z + player->mo->height < subsec[i]->sector->ceilingheight - tiptop)) + if (bottomheight > player->mo->z + player->mo->height + tiptop + || (topheight < player->mo->z + && player->mo->z + player->mo->height < subsecceilingheight[i] - tiptop)) { teeter = true; roverfloor = true; @@ -2977,12 +3039,12 @@ static void P_DoTeeter(player_t *player) } else { - if (*rover->topheight < subsec[i]->sector->floorheight) // Below the floor + if (topheight < subsecfloorheight[i]) // Below the floor continue; - if (*rover->topheight < player->mo->z - tiptop - || (*rover->bottomheight > player->mo->z + player->mo->height - && player->mo->z > subsec[i]->sector->floorheight + tiptop)) + if (topheight < player->mo->z - tiptop + || (bottomheight > player->mo->z + player->mo->height + && player->mo->z > subsecfloorheight[i] + tiptop)) { teeter = true; roverfloor = true; @@ -3000,18 +3062,18 @@ static void P_DoTeeter(player_t *player) if (player->mo->eflags & MFE_VERTICALFLIP) { - if (!teeter && !roverfloor && (subsec[0]->sector->ceilingheight > player->mo->ceilingz + tiptop - || subsec[1]->sector->ceilingheight > player->mo->ceilingz + tiptop - || subsec[2]->sector->ceilingheight > player->mo->ceilingz + tiptop - || subsec[3]->sector->ceilingheight > player->mo->ceilingz + tiptop)) + if (!teeter && !roverfloor && (subsecceilingheight[0] > player->mo->ceilingz + tiptop + || subsecceilingheight[1] > player->mo->ceilingz + tiptop + || subsecceilingheight[2] > player->mo->ceilingz + tiptop + || subsecceilingheight[3] > player->mo->ceilingz + tiptop)) teeter = true; } else { - if (!teeter && !roverfloor && (subsec[0]->sector->floorheight < player->mo->floorz - tiptop - || subsec[1]->sector->floorheight < player->mo->floorz - tiptop - || subsec[2]->sector->floorheight < player->mo->floorz - tiptop - || subsec[3]->sector->floorheight < player->mo->floorz - tiptop)) + if (!teeter && !roverfloor && (subsecfloorheight[0] < player->mo->floorz - tiptop + || subsecfloorheight[1] < player->mo->floorz - tiptop + || subsecfloorheight[2] < player->mo->floorz - tiptop + || subsecfloorheight[3] < player->mo->floorz - tiptop)) teeter = true; } } From 9df72a966e8b5e3668f704bc6ba7a54b1edd4931 Mon Sep 17 00:00:00 2001 From: toasterbabe Date: Tue, 7 Jun 2016 17:55:03 +0100 Subject: [PATCH 31/71] Some simplifications after MI pointed out that the sector heights are the only thing accessed outside of the iteration. --- src/p_user.c | 56 ++++++++++++++++++++++------------------------------ 1 file changed, 24 insertions(+), 32 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index 346dd3ded..ba252b49d 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -2959,19 +2959,11 @@ static void P_DoTeeter(player_t *player) if (checkedforteeter && !teeter) // Backup code { - subsector_t *subsec[4]; // changed abcd into array instead - fixed_t subsecfloorheight[4]; - fixed_t subsecceilingheight[4]; + sector_t *sec; + fixed_t secfloorheight[4]; + fixed_t secceilingheight[4]; UINT8 i; - // Following is replaced by xsign and ysign code - /* - subsec[0] = R_PointInSubsector(player->mo->x + FixedMul(5*FRACUNIT, player->mo->scale), player->mo->y + FixedMul(5*FRACUNIT, player->mo->scale)); - subsec[1] = R_PointInSubsector(player->mo->x - FixedMul(5*FRACUNIT, player->mo->scale), player->mo->y + FixedMul(5*FRACUNIT, player->mo->scale)); - subsec[2] = R_PointInSubsector(player->mo->x + FixedMul(5*FRACUNIT, player->mo->scale), player->mo->y - FixedMul(5*FRACUNIT, player->mo->scale)); - subsec[3] = R_PointInSubsector(player->mo->x - FixedMul(5*FRACUNIT, player->mo->scale), player->mo->y - FixedMul(5*FRACUNIT, player->mo->scale)); - */ - teeter = false; roverfloor = false; for (i = 0; i < 4; i++) @@ -2983,23 +2975,23 @@ static void P_DoTeeter(player_t *player) fixed_t checkx = player->mo->x + (xsign*FixedMul(5*FRACUNIT, player->mo->scale)); fixed_t checky = player->mo->y + (ysign*FixedMul(5*FRACUNIT, player->mo->scale)); - subsec[i] = R_PointInSubsector(checkx, checky); + sec = R_PointInSubsector(checkx, checky)->sector; - subsecceilingheight[i] = subsec[i]->sector->ceilingheight; - subsecfloorheight[i] = subsec[i]->sector->floorheight; + secceilingheight[i] = sec->ceilingheight; + secfloorheight[i] = sec->floorheight; #ifdef ESLOPE - if (subsec[i]->sector->c_slope) - subsecceilingheight[i] = P_GetZAt(subsec[i]->sector->c_slope, checkx, checky); - if (subsec[i]->sector->f_slope) - subsecfloorheight[i] = P_GetZAt(subsec[i]->sector->f_slope, checkx, checky); + if (sec->c_slope) + secceilingheight[i] = P_GetZAt(sec->c_slope, checkx, checky); + if (sec->f_slope) + secfloorheight[i] = P_GetZAt(sec->f_slope, checkx, checky); #endif #undef xsign #undef ysign - if (!(subsec[i]->sector->ffloors)) + if (!(sec->ffloors)) continue; // move on to the next subsector - for (rover = subsec[i]->sector->ffloors; rover; rover = rover->next) + for (rover = sec->ffloors; rover; rover = rover->next) { if (!(rover->flags & FF_EXISTS)) continue; @@ -3020,12 +3012,12 @@ static void P_DoTeeter(player_t *player) if (player->mo->eflags & MFE_VERTICALFLIP) { - if (bottomheight > subsecceilingheight[i]) // Above the ceiling + if (bottomheight > secceilingheight[i]) // Above the ceiling continue; if (bottomheight > player->mo->z + player->mo->height + tiptop || (topheight < player->mo->z - && player->mo->z + player->mo->height < subsecceilingheight[i] - tiptop)) + && player->mo->z + player->mo->height < secceilingheight[i] - tiptop)) { teeter = true; roverfloor = true; @@ -3039,12 +3031,12 @@ static void P_DoTeeter(player_t *player) } else { - if (topheight < subsecfloorheight[i]) // Below the floor + if (topheight < secfloorheight[i]) // Below the floor continue; if (topheight < player->mo->z - tiptop || (bottomheight > player->mo->z + player->mo->height - && player->mo->z > subsecfloorheight[i] + tiptop)) + && player->mo->z > secfloorheight[i] + tiptop)) { teeter = true; roverfloor = true; @@ -3062,18 +3054,18 @@ static void P_DoTeeter(player_t *player) if (player->mo->eflags & MFE_VERTICALFLIP) { - if (!teeter && !roverfloor && (subsecceilingheight[0] > player->mo->ceilingz + tiptop - || subsecceilingheight[1] > player->mo->ceilingz + tiptop - || subsecceilingheight[2] > player->mo->ceilingz + tiptop - || subsecceilingheight[3] > player->mo->ceilingz + tiptop)) + if (!teeter && !roverfloor && (secceilingheight[0] > player->mo->ceilingz + tiptop + || secceilingheight[1] > player->mo->ceilingz + tiptop + || secceilingheight[2] > player->mo->ceilingz + tiptop + || secceilingheight[3] > player->mo->ceilingz + tiptop)) teeter = true; } else { - if (!teeter && !roverfloor && (subsecfloorheight[0] < player->mo->floorz - tiptop - || subsecfloorheight[1] < player->mo->floorz - tiptop - || subsecfloorheight[2] < player->mo->floorz - tiptop - || subsecfloorheight[3] < player->mo->floorz - tiptop)) + if (!teeter && !roverfloor && (secfloorheight[0] < player->mo->floorz - tiptop + || secfloorheight[1] < player->mo->floorz - tiptop + || secfloorheight[2] < player->mo->floorz - tiptop + || secfloorheight[3] < player->mo->floorz - tiptop)) teeter = true; } } From aa113045d7c10dc8d412549eab7dea8feb6c8628 Mon Sep 17 00:00:00 2001 From: toasterbabe Date: Tue, 7 Jun 2016 18:18:47 +0100 Subject: [PATCH 32/71] MI pointed out opportunity for more optimisation, and who could resist? --- src/p_user.c | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index ba252b49d..9eff0ae28 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -2960,9 +2960,9 @@ static void P_DoTeeter(player_t *player) if (checkedforteeter && !teeter) // Backup code { sector_t *sec; - fixed_t secfloorheight[4]; - fixed_t secceilingheight[4]; UINT8 i; + fixed_t highestceilingheight = INT32_MIN; + fixed_t lowestfloorheight = INT32_MAX; teeter = false; roverfloor = false; @@ -2977,14 +2977,16 @@ static void P_DoTeeter(player_t *player) sec = R_PointInSubsector(checkx, checky)->sector; - secceilingheight[i] = sec->ceilingheight; - secfloorheight[i] = sec->floorheight; + fixed_t ceilingheight = sec->ceilingheight; + fixed_t floorheight = sec->floorheight; #ifdef ESLOPE if (sec->c_slope) - secceilingheight[i] = P_GetZAt(sec->c_slope, checkx, checky); + ceilingheight = P_GetZAt(sec->c_slope, checkx, checky); if (sec->f_slope) - secfloorheight[i] = P_GetZAt(sec->f_slope, checkx, checky); + floorheight = P_GetZAt(sec->f_slope, checkx, checky); #endif + highestceilingheight = (ceilingheight > highestceilingheight) ? ceilingheight : highestceilingheight; + lowestfloorheight = (floorheight < lowestfloorheight) ? floorheight : lowestfloorheight; #undef xsign #undef ysign @@ -3012,12 +3014,12 @@ static void P_DoTeeter(player_t *player) if (player->mo->eflags & MFE_VERTICALFLIP) { - if (bottomheight > secceilingheight[i]) // Above the ceiling + if (bottomheight > ceilingheight) // Above the ceiling continue; if (bottomheight > player->mo->z + player->mo->height + tiptop || (topheight < player->mo->z - && player->mo->z + player->mo->height < secceilingheight[i] - tiptop)) + && player->mo->z + player->mo->height < ceilingheight - tiptop)) { teeter = true; roverfloor = true; @@ -3031,12 +3033,12 @@ static void P_DoTeeter(player_t *player) } else { - if (topheight < secfloorheight[i]) // Below the floor + if (topheight < floorheight) // Below the floor continue; if (topheight < player->mo->z - tiptop || (bottomheight > player->mo->z + player->mo->height - && player->mo->z > secfloorheight[i] + tiptop)) + && player->mo->z > floorheight + tiptop)) { teeter = true; roverfloor = true; @@ -3054,18 +3056,12 @@ static void P_DoTeeter(player_t *player) if (player->mo->eflags & MFE_VERTICALFLIP) { - if (!teeter && !roverfloor && (secceilingheight[0] > player->mo->ceilingz + tiptop - || secceilingheight[1] > player->mo->ceilingz + tiptop - || secceilingheight[2] > player->mo->ceilingz + tiptop - || secceilingheight[3] > player->mo->ceilingz + tiptop)) + if (!teeter && !roverfloor && (highestceilingheight > player->mo->ceilingz + tiptop)) teeter = true; } else { - if (!teeter && !roverfloor && (secfloorheight[0] < player->mo->floorz - tiptop - || secfloorheight[1] < player->mo->floorz - tiptop - || secfloorheight[2] < player->mo->floorz - tiptop - || secfloorheight[3] < player->mo->floorz - tiptop)) + if (!teeter && !roverfloor && (lowestfloorheight < player->mo->floorz - tiptop)) teeter = true; } } From 51c769247a41de31d734f5d1996776ea8d2fdfb9 Mon Sep 17 00:00:00 2001 From: toasterbabe Date: Tue, 7 Jun 2016 19:44:43 +0100 Subject: [PATCH 33/71] Compiling fixes. --- 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 9eff0ae28..2e9f0b295 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -2977,8 +2977,8 @@ static void P_DoTeeter(player_t *player) sec = R_PointInSubsector(checkx, checky)->sector; - fixed_t ceilingheight = sec->ceilingheight; - fixed_t floorheight = sec->floorheight; + ceilingheight = sec->ceilingheight; + floorheight = sec->floorheight; #ifdef ESLOPE if (sec->c_slope) ceilingheight = P_GetZAt(sec->c_slope, checkx, checky); From 0b920ee2492566d245c93f7a624418b6896e9080 Mon Sep 17 00:00:00 2001 From: toasterbabe Date: Thu, 9 Jun 2016 00:02:50 +0100 Subject: [PATCH 34/71] You know that problem where you bumped on the edges of Mario blocks and Bustable blocks and Bouncy FOFs sometimes? Wham. Bam. In the van. Issue was caused by attempting to traverse the sector's thing-touching-list across all the things in the sector (which would inevitably have the same sector as the first node in mobj->touching_sectorlist) instead of traversing the thing's sector-touching-list (which has the same thing but different sector references). I wonder how many times AJ copypasted this code with absolutely no idea why it wasn't working properly. I'll figure that out tomorrow, maybe set up some compiler macros so this mistake is never made again. For now, I must sleeb. --- src/p_mobj.c | 4 ++-- src/p_user.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index 68fb1696f..759fa0d8c 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -1530,7 +1530,7 @@ static void P_PushableCheckBustables(mobj_t *mo) mo->y += mo->momy; P_SetThingPosition(mo); - for (node = mo->touching_sectorlist; node; node = node->m_snext) + for (node = mo->touching_sectorlist; node; node = node->m_tnext) { if (!node->m_sector) break; @@ -2880,7 +2880,7 @@ nightsdone: if (CheckForMarioBlocks && !(netgame && mo->player->spectator)) // Only let the player punch { // Search the touching sectors, from side-to-side... - for (node = mo->touching_sectorlist; node; node = node->m_snext) + for (node = mo->touching_sectorlist; node; node = node->m_tnext) { ffloor_t *rover; if (!node->m_sector->ffloors) diff --git a/src/p_user.c b/src/p_user.c index 4117cfc4c..fab8cd37e 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -1684,7 +1684,7 @@ static void P_CheckBustableBlocks(player_t *player) player->mo->y += player->mo->momy; P_SetThingPosition(player->mo); - for (node = player->mo->touching_sectorlist; node; node = node->m_snext) + for (node = player->mo->touching_sectorlist; node; node = node->m_tnext) { if (!node->m_sector) break; @@ -1801,7 +1801,7 @@ static void P_CheckBouncySectors(player_t *player) player->mo->z += player->mo->momz; P_SetThingPosition(player->mo); - for (node = player->mo->touching_sectorlist; node; node = node->m_snext) + for (node = player->mo->touching_sectorlist; node; node = node->m_tnext) { if (!node->m_sector) break; From 17e0adcbacc98f6b71b5d7e9a8ebc7d67ec251b2 Mon Sep 17 00:00:00 2001 From: toasterbabe Date: Thu, 9 Jun 2016 14:16:02 +0100 Subject: [PATCH 35/71] Renamed some struct variables so the problem this branch sets out to fix is more obvious at a glance. * m_snext ==> m_thinglist_next * m_sprev ==> m_thinglist_prev * m_tnext ==> m_sectorlist_next * m_tprev ==> m_sectorlist_prev --- src/p_floor.c | 10 +++--- src/p_map.c | 96 +++++++++++++++++++++++++-------------------------- src/p_mobj.c | 14 ++++---- src/p_spec.c | 24 ++++++------- src/p_user.c | 8 ++--- src/r_defs.h | 20 +++++------ 6 files changed, 86 insertions(+), 86 deletions(-) diff --git a/src/p_floor.c b/src/p_floor.c index 1c396c877..911213014 100644 --- a/src/p_floor.c +++ b/src/p_floor.c @@ -1163,7 +1163,7 @@ void T_SpikeSector(levelspecthink_t *spikes) node = spikes->sector->touching_thinglist; // things touching this sector - for (; node; node = node->m_snext) + for (; node; node = node->m_thinglist_next) { thing = node->m_thing; if (!thing->player) @@ -1316,7 +1316,7 @@ void T_BridgeThinker(levelspecthink_t *bridge) controlsec = §ors[k]; // Is a player standing on me? - for (node = sector->touching_thinglist; node; node = node->m_snext) + for (node = sector->touching_thinglist; node; node = node->m_thinglist_next) { thing = node->m_thing; @@ -1739,7 +1739,7 @@ wegotit: static mobj_t *SearchMarioNode(msecnode_t *node) { mobj_t *thing = NULL; - for (; node; node = node->m_snext) + for (; node; node = node->m_thinglist_next) { // Things which should NEVER be ejected from a MarioBlock, by type. switch (node->m_thing->type) @@ -2003,7 +2003,7 @@ void T_NoEnemiesSector(levelspecthink_t *nobaddies) goto foundenemy; } - node = node->m_snext; + node = node->m_thinglist_next; } } } @@ -2288,7 +2288,7 @@ void T_RaiseSector(levelspecthink_t *raise) sector = §ors[i]; // Is a player standing on me? - for (node = sector->touching_thinglist; node; node = node->m_snext) + for (node = sector->touching_thinglist; node; node = node->m_thinglist_next) { thing = node->m_thing; diff --git a/src/p_map.c b/src/p_map.c index 71adf2e16..44df30018 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -3365,7 +3365,7 @@ boolean P_CheckSector(sector_t *sector, boolean crunch) for (i = 0; i < sector->numattached; i++) { sec = §ors[sector->attached[i]]; - for (n = sec->touching_thinglist; n; n = n->m_snext) + for (n = sec->touching_thinglist; n; n = n->m_thinglist_next) n->visited = false; sec->moved = true; @@ -3377,7 +3377,7 @@ boolean P_CheckSector(sector_t *sector, boolean crunch) do { - for (n = sec->touching_thinglist; n; n = n->m_snext) + for (n = sec->touching_thinglist; n; n = n->m_thinglist_next) if (!n->visited) { n->visited = true; @@ -3398,12 +3398,12 @@ boolean P_CheckSector(sector_t *sector, boolean crunch) // Mark all things invalid sector->moved = true; - for (n = sector->touching_thinglist; n; n = n->m_snext) + for (n = sector->touching_thinglist; n; n = n->m_thinglist_next) n->visited = false; do { - for (n = sector->touching_thinglist; n; n = n->m_snext) // go through list + for (n = sector->touching_thinglist; n; n = n->m_thinglist_next) // go through list if (!n->visited) // unprocessed thing found { n->visited = true; // mark thing as processed @@ -3427,7 +3427,7 @@ boolean P_CheckSector(sector_t *sector, boolean crunch) for (i = 0; i < sector->numattached; i++) { sec = §ors[sector->attached[i]]; - for (n = sec->touching_thinglist; n; n = n->m_snext) + for (n = sec->touching_thinglist; n; n = n->m_thinglist_next) n->visited = false; sec->moved = true; @@ -3439,7 +3439,7 @@ boolean P_CheckSector(sector_t *sector, boolean crunch) do { - for (n = sec->touching_thinglist; n; n = n->m_snext) + for (n = sec->touching_thinglist; n; n = n->m_thinglist_next) if (!n->visited) { n->visited = true; @@ -3457,12 +3457,12 @@ boolean P_CheckSector(sector_t *sector, boolean crunch) // Mark all things invalid sector->moved = true; - for (n = sector->touching_thinglist; n; n = n->m_snext) + for (n = sector->touching_thinglist; n; n = n->m_thinglist_next) n->visited = false; do { - for (n = sector->touching_thinglist; n; n = n->m_snext) // go through list + for (n = sector->touching_thinglist; n; n = n->m_thinglist_next) // go through list if (!n->visited) // unprocessed thing found { n->visited = true; // mark thing as processed @@ -3502,7 +3502,7 @@ static msecnode_t *P_GetSecnode(void) if (headsecnode) { node = headsecnode; - headsecnode = headsecnode->m_snext; + headsecnode = headsecnode->m_thinglist_next; } else node = Z_Calloc(sizeof (*node), PU_LEVEL, NULL); @@ -3516,7 +3516,7 @@ static mprecipsecnode_t *P_GetPrecipSecnode(void) if (headprecipsecnode) { node = headprecipsecnode; - headprecipsecnode = headprecipsecnode->m_snext; + headprecipsecnode = headprecipsecnode->m_thinglist_next; } else node = Z_Calloc(sizeof (*node), PU_LEVEL, NULL); @@ -3527,14 +3527,14 @@ static mprecipsecnode_t *P_GetPrecipSecnode(void) static inline void P_PutSecnode(msecnode_t *node) { - node->m_snext = headsecnode; + node->m_thinglist_next = headsecnode; headsecnode = node; } // Tails 08-25-2002 static inline void P_PutPrecipSecnode(mprecipsecnode_t *node) { - node->m_snext = headprecipsecnode; + node->m_thinglist_next = headprecipsecnode; headprecipsecnode = node; } @@ -3555,7 +3555,7 @@ static msecnode_t *P_AddSecnode(sector_t *s, mobj_t *thing, msecnode_t *nextnode node->m_thing = thing; // Yes. Setting m_thing says 'keep it'. return nextnode; } - node = node->m_tnext; + node = node->m_sectorlist_next; } // Couldn't find an existing node for this sector. Add one at the head @@ -3568,17 +3568,17 @@ static msecnode_t *P_AddSecnode(sector_t *s, mobj_t *thing, msecnode_t *nextnode node->m_sector = s; // sector node->m_thing = thing; // mobj - node->m_tprev = NULL; // prev node on Thing thread - node->m_tnext = nextnode; // next node on Thing thread + node->m_sectorlist_prev = NULL; // prev node on Thing thread + node->m_sectorlist_next = nextnode; // next node on Thing thread if (nextnode) - nextnode->m_tprev = node; // set back link on Thing + nextnode->m_sectorlist_prev = node; // set back link on Thing // Add new node at head of sector thread starting at s->touching_thinglist - node->m_sprev = NULL; // prev node on sector thread - node->m_snext = s->touching_thinglist; // next node on sector thread + node->m_thinglist_prev = NULL; // prev node on sector thread + node->m_thinglist_next = s->touching_thinglist; // next node on sector thread if (s->touching_thinglist) - node->m_snext->m_sprev = node; + node->m_thinglist_next->m_thinglist_prev = node; s->touching_thinglist = node; return node; } @@ -3596,7 +3596,7 @@ static mprecipsecnode_t *P_AddPrecipSecnode(sector_t *s, precipmobj_t *thing, mp node->m_thing = thing; // Yes. Setting m_thing says 'keep it'. return nextnode; } - node = node->m_tnext; + node = node->m_sectorlist_next; } // Couldn't find an existing node for this sector. Add one at the head @@ -3609,17 +3609,17 @@ static mprecipsecnode_t *P_AddPrecipSecnode(sector_t *s, precipmobj_t *thing, mp node->m_sector = s; // sector node->m_thing = thing; // mobj - node->m_tprev = NULL; // prev node on Thing thread - node->m_tnext = nextnode; // next node on Thing thread + node->m_sectorlist_prev = NULL; // prev node on Thing thread + node->m_sectorlist_next = nextnode; // next node on Thing thread if (nextnode) - nextnode->m_tprev = node; // set back link on Thing + nextnode->m_sectorlist_prev = node; // set back link on Thing // Add new node at head of sector thread starting at s->touching_thinglist - node->m_sprev = NULL; // prev node on sector thread - node->m_snext = s->touching_preciplist; // next node on sector thread + node->m_thinglist_prev = NULL; // prev node on sector thread + node->m_thinglist_next = s->touching_preciplist; // next node on sector thread if (s->touching_preciplist) - node->m_snext->m_sprev = node; + node->m_thinglist_next->m_thinglist_prev = node; s->touching_preciplist = node; return node; } @@ -3641,24 +3641,24 @@ static msecnode_t *P_DelSecnode(msecnode_t *node) // Unlink from the Thing thread. The Thing thread begins at // sector_list and not from mobj_t->touching_sectorlist. - tp = node->m_tprev; - tn = node->m_tnext; + tp = node->m_sectorlist_prev; + tn = node->m_sectorlist_next; if (tp) - tp->m_tnext = tn; + tp->m_sectorlist_next = tn; if (tn) - tn->m_tprev = tp; + tn->m_sectorlist_prev = tp; // Unlink from the sector thread. This thread begins at // sector_t->touching_thinglist. - sp = node->m_sprev; - sn = node->m_snext; + sp = node->m_thinglist_prev; + sn = node->m_thinglist_next; if (sp) - sp->m_snext = sn; + sp->m_thinglist_next = sn; else node->m_sector->touching_thinglist = sn; if (sn) - sn->m_sprev = sp; + sn->m_thinglist_prev = sp; // Return this node to the freelist @@ -3680,24 +3680,24 @@ static mprecipsecnode_t *P_DelPrecipSecnode(mprecipsecnode_t *node) // Unlink from the Thing thread. The Thing thread begins at // sector_list and not from mobj_t->touching_sectorlist. - tp = node->m_tprev; - tn = node->m_tnext; + tp = node->m_sectorlist_prev; + tn = node->m_sectorlist_next; if (tp) - tp->m_tnext = tn; + tp->m_sectorlist_next = tn; if (tn) - tn->m_tprev = tp; + tn->m_sectorlist_prev = tp; // Unlink from the sector thread. This thread begins at // sector_t->touching_thinglist. - sp = node->m_sprev; - sn = node->m_snext; + sp = node->m_thinglist_prev; + sn = node->m_thinglist_next; if (sp) - sp->m_snext = sn; + sp->m_thinglist_next = sn; else node->m_sector->touching_preciplist = sn; if (sn) - sn->m_sprev = sp; + sn->m_thinglist_prev = sp; // Return this node to the freelist @@ -3812,7 +3812,7 @@ void P_CreateSecNodeList(mobj_t *thing, fixed_t x, fixed_t y) while (node) { node->m_thing = NULL; - node = node->m_tnext; + node = node->m_sectorlist_next; } P_SetTarget(&tmthing, thing); @@ -3850,11 +3850,11 @@ void P_CreateSecNodeList(mobj_t *thing, fixed_t x, fixed_t y) if (!node->m_thing) { if (node == sector_list) - sector_list = node->m_tnext; + sector_list = node->m_sectorlist_next; node = P_DelSecnode(node); } else - node = node->m_tnext; + node = node->m_sectorlist_next; } /* cph - @@ -3895,7 +3895,7 @@ void P_CreatePrecipSecNodeList(precipmobj_t *thing,fixed_t x,fixed_t y) while (node) { node->m_thing = NULL; - node = node->m_tnext; + node = node->m_sectorlist_next; } tmprecipthing = thing; @@ -3929,11 +3929,11 @@ void P_CreatePrecipSecNodeList(precipmobj_t *thing,fixed_t x,fixed_t y) if (!node->m_thing) { if (node == precipsector_list) - precipsector_list = node->m_tnext; + precipsector_list = node->m_sectorlist_next; node = P_DelPrecipSecnode(node); } else - node = node->m_tnext; + node = node->m_sectorlist_next; } /* cph - diff --git a/src/p_mobj.c b/src/p_mobj.c index 759fa0d8c..0141c47d3 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -1530,7 +1530,7 @@ static void P_PushableCheckBustables(mobj_t *mo) mo->y += mo->momy; P_SetThingPosition(mo); - for (node = mo->touching_sectorlist; node; node = node->m_tnext) + for (node = mo->touching_sectorlist; node; node = node->m_sectorlist_next) { if (!node->m_sector) break; @@ -2703,7 +2703,7 @@ static void P_PlayerZMovement(mobj_t *mo) msecnode_t *node; boolean stopmovecut = false; - for (node = mo->touching_sectorlist; node; node = node->m_snext) + for (node = mo->touching_sectorlist; node; node = node->m_thinglist_next) { sector_t *sec = node->m_sector; subsector_t *newsubsec; @@ -2880,7 +2880,7 @@ nightsdone: if (CheckForMarioBlocks && !(netgame && mo->player->spectator)) // Only let the player punch { // Search the touching sectors, from side-to-side... - for (node = mo->touching_sectorlist; node; node = node->m_tnext) + for (node = mo->touching_sectorlist; node; node = node->m_sectorlist_next) { ffloor_t *rover; if (!node->m_sector->ffloors) @@ -3648,7 +3648,7 @@ static void P_PlayerMobjThinker(mobj_t *mobj) if (!(netgame && mobj->player->spectator)) { // Crumbling platforms - for (node = mobj->touching_sectorlist; node; node = node->m_snext) + for (node = mobj->touching_sectorlist; node; node = node->m_thinglist_next) { fixed_t topheight, bottomheight; ffloor_t *rover; @@ -3673,7 +3673,7 @@ static void P_PlayerMobjThinker(mobj_t *mobj) { boolean thereiswater = false; - for (node = mobj->touching_sectorlist; node; node = node->m_snext) + for (node = mobj->touching_sectorlist; node; node = node->m_thinglist_next) { if (node->m_sector->ffloors) { @@ -3694,7 +3694,7 @@ static void P_PlayerMobjThinker(mobj_t *mobj) } if (thereiswater) { - for (node = mobj->touching_sectorlist; node; node = node->m_snext) + for (node = mobj->touching_sectorlist; node; node = node->m_thinglist_next) { if (node->m_sector->ffloors) { @@ -3807,7 +3807,7 @@ void P_RecalcPrecipInSector(sector_t *sector) sector->moved = true; // Recalc lighting and things too, maybe - for (psecnode = sector->touching_preciplist; psecnode; psecnode = psecnode->m_snext) + for (psecnode = sector->touching_preciplist; psecnode; psecnode = psecnode->m_thinglist_next) CalculatePrecipFloor(psecnode->m_thing); } diff --git a/src/p_spec.c b/src/p_spec.c index 9e4c3f079..25e32e578 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -1642,7 +1642,7 @@ boolean P_RunTriggerLinedef(line_t *triggerline, mobj_t *actor, sector_t *caller mo = node->m_thing; if (mo->flags & MF_PUSHABLE) numpush++; - node = node->m_snext; + node = node->m_thinglist_next; } if (triggerline->flags & ML_NOCLIMB) // Need at least or more @@ -3144,7 +3144,7 @@ void P_SetupSignExit(player_t *player) thinker_t *think; INT32 numfound = 0; - for (; node; node = node->m_snext) + for (; node; node = node->m_thinglist_next) { thing = node->m_thing; if (thing->type != MT_SIGN) @@ -3308,7 +3308,7 @@ sector_t *P_PlayerTouchingSectorSpecial(player_t *player, INT32 section, INT32 n return rover->master->frontsector; } - for (node = player->mo->touching_sectorlist; node; node = node->m_snext) + for (node = player->mo->touching_sectorlist; node; node = node->m_thinglist_next) { if (GETSECSPECIAL(node->m_sector->special, section) == number) { @@ -4657,7 +4657,7 @@ void P_PlayerInSpecialSector(player_t *player) P_RunSpecialSectorCheck(player, sector); // Iterate through touching_sectorlist - for (node = player->mo->touching_sectorlist; node; node = node->m_snext) + for (node = player->mo->touching_sectorlist; node; node = node->m_thinglist_next) { sector = node->m_sector; @@ -5308,7 +5308,7 @@ void T_LaserFlash(laserthink_t *flash) S_StartSound(§or->soundorg, sfx_laser); // Seek out objects to DESTROY! MUAHAHHAHAHAA!!!*cough* - for (node = sector->touching_thinglist; node && node->m_thing; node = node->m_snext) + for (node = sector->touching_thinglist; node && node->m_thing; node = node->m_thinglist_next) { thing = node->m_thing; @@ -6579,7 +6579,7 @@ void T_Scroll(scroll_t *s) sector_t *psec; psec = sectors + sect; - for (node = psec->touching_thinglist; node; node = node->m_snext) + for (node = psec->touching_thinglist; node; node = node->m_thinglist_next) { thing = node->m_thing; @@ -6601,7 +6601,7 @@ void T_Scroll(scroll_t *s) if (!is3dblock) { - for (node = sec->touching_thinglist; node; node = node->m_snext) + for (node = sec->touching_thinglist; node; node = node->m_thinglist_next) { thing = node->m_thing; @@ -6642,7 +6642,7 @@ void T_Scroll(scroll_t *s) sector_t *psec; psec = sectors + sect; - for (node = psec->touching_thinglist; node; node = node->m_snext) + for (node = psec->touching_thinglist; node; node = node->m_thinglist_next) { thing = node->m_thing; @@ -6664,7 +6664,7 @@ void T_Scroll(scroll_t *s) if (!is3dblock) { - for (node = sec->touching_thinglist; node; node = node->m_snext) + for (node = sec->touching_thinglist; node; node = node->m_thinglist_next) { thing = node->m_thing; @@ -7014,7 +7014,7 @@ void T_Friction(friction_t *f) { if (thing->floorz != P_GetSpecialTopZ(thing, referrer, sec)) { - node = node->m_snext; + node = node->m_thinglist_next; continue; } @@ -7032,7 +7032,7 @@ void T_Friction(friction_t *f) thing->movefactor = f->movefactor; } } - node = node->m_snext; + node = node->m_thinglist_next; } } @@ -7372,7 +7372,7 @@ void T_Pusher(pusher_t *p) // constant pushers p_wind and p_current node = sec->touching_thinglist; // things touching this sector - for (; node; node = node->m_snext) + for (; node; node = node->m_thinglist_next) { thing = node->m_thing; if (thing->flags & (MF_NOGRAVITY | MF_NOCLIP) diff --git a/src/p_user.c b/src/p_user.c index fab8cd37e..2156f0fc0 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -1684,7 +1684,7 @@ static void P_CheckBustableBlocks(player_t *player) player->mo->y += player->mo->momy; P_SetThingPosition(player->mo); - for (node = player->mo->touching_sectorlist; node; node = node->m_tnext) + for (node = player->mo->touching_sectorlist; node; node = node->m_sectorlist_next) { if (!node->m_sector) break; @@ -1801,7 +1801,7 @@ static void P_CheckBouncySectors(player_t *player) player->mo->z += player->mo->momz; P_SetThingPosition(player->mo); - for (node = player->mo->touching_sectorlist; node; node = node->m_tnext) + for (node = player->mo->touching_sectorlist; node; node = node->m_sectorlist_next) { if (!node->m_sector) break; @@ -2855,7 +2855,7 @@ static void P_DoTeeter(player_t *player) boolean checkedforteeter = false; const fixed_t tiptop = FixedMul(MAXSTEPMOVE, player->mo->scale); // Distance you have to be above the ground in order to teeter. - for (node = player->mo->touching_sectorlist; node; node = node->m_snext) + for (node = player->mo->touching_sectorlist; node; node = node->m_thinglist_next) { // Ledge teetering. Check if any nearby sectors are low enough from your current one. checkedforteeter = true; @@ -7037,7 +7037,7 @@ static void P_MovePlayer(player_t *player) player->mo->y += player->mo->momy; P_SetThingPosition(player->mo); - for (node = player->mo->touching_sectorlist; node; node = node->m_snext) + for (node = player->mo->touching_sectorlist; node; node = node->m_thinglist_next) { if (!node->m_sector) break; diff --git a/src/r_defs.h b/src/r_defs.h index 848708164..2c5860ee7 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -500,10 +500,10 @@ typedef struct subsector_s // Sector list node showing all sectors an object appears in. // // There are two threads that flow through these nodes. The first thread -// starts at touching_thinglist in a sector_t and flows through the m_snext +// starts at touching_thinglist in a sector_t and flows through the m_thinglist_next // links to find all mobjs that are entirely or partially in the sector. // The second thread starts at touching_sectorlist in an mobj_t and flows -// through the m_tnext links to find all sectors a thing touches. This is +// through the m_sectorlist_next links to find all sectors a thing touches. This is // useful when applying friction or push effects to sectors. These effects // can be done as thinkers that act upon all objects touching their sectors. // As an mobj moves through the world, these nodes are created and @@ -515,10 +515,10 @@ typedef struct msecnode_s { sector_t *m_sector; // a sector containing this object struct mobj_s *m_thing; // this object - struct msecnode_s *m_tprev; // prev msecnode_t for this thing - struct msecnode_s *m_tnext; // next msecnode_t for this thing - struct msecnode_s *m_sprev; // prev msecnode_t for this sector - struct msecnode_s *m_snext; // next msecnode_t for this sector + struct msecnode_s *m_sectorlist_prev; // prev msecnode_t for this thing + struct msecnode_s *m_sectorlist_next; // next msecnode_t for this thing + struct msecnode_s *m_thinglist_prev; // prev msecnode_t for this sector + struct msecnode_s *m_thinglist_next; // next msecnode_t for this sector boolean visited; // used in search algorithms } msecnode_t; @@ -526,10 +526,10 @@ typedef struct mprecipsecnode_s { sector_t *m_sector; // a sector containing this object struct precipmobj_s *m_thing; // this object - struct mprecipsecnode_s *m_tprev; // prev msecnode_t for this thing - struct mprecipsecnode_s *m_tnext; // next msecnode_t for this thing - struct mprecipsecnode_s *m_sprev; // prev msecnode_t for this sector - struct mprecipsecnode_s *m_snext; // next msecnode_t for this sector + struct mprecipsecnode_s *m_sectorlist_prev; // prev msecnode_t for this thing + struct mprecipsecnode_s *m_sectorlist_next; // next msecnode_t for this thing + struct mprecipsecnode_s *m_thinglist_prev; // prev msecnode_t for this sector + struct mprecipsecnode_s *m_thinglist_next; // next msecnode_t for this sector boolean visited; // used in search algorithms } mprecipsecnode_t; From 7af14c20ed0b38531e86ee86e1f4e0f143ae5f12 Mon Sep 17 00:00:00 2001 From: toasterbabe Date: Thu, 9 Jun 2016 14:56:24 +0100 Subject: [PATCH 36/71] Everywhere in the code that was doing things wrong has been changed. Two interesting points of note: * The touchspecial sector flag seems to actually do its job now. * Detection of sectors with polyobjects in seems to have done this incorrectly, but this doesn't mess with anything about touching the polies themselves so it seems to really only handle edge cases where the polyobject was too close to the border of another sector (which would've likely made rendering glitches anyways). * There was a whole swathe of teetering code that was basically never run properly because of this mistake. I did a simple fix at first, but you started teetering whenever you were slightly less than your radius away from a sector's edge, which was completely different and undesirable behaviour. Instead, I cut out the code that was never running, and just left the hacky method in instead since it was more accurate to what we want in general. --- src/p_mobj.c | 8 +++--- src/p_spec.c | 4 +-- src/p_user.c | 80 ++-------------------------------------------------- 3 files changed, 8 insertions(+), 84 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index 0141c47d3..d65ecee3a 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -2703,7 +2703,7 @@ static void P_PlayerZMovement(mobj_t *mo) msecnode_t *node; boolean stopmovecut = false; - for (node = mo->touching_sectorlist; node; node = node->m_thinglist_next) + for (node = mo->touching_sectorlist; node; node = node->m_sectorlist_next) { sector_t *sec = node->m_sector; subsector_t *newsubsec; @@ -3648,7 +3648,7 @@ static void P_PlayerMobjThinker(mobj_t *mobj) if (!(netgame && mobj->player->spectator)) { // Crumbling platforms - for (node = mobj->touching_sectorlist; node; node = node->m_thinglist_next) + for (node = mobj->touching_sectorlist; node; node = node->m_sectorlist_next) { fixed_t topheight, bottomheight; ffloor_t *rover; @@ -3673,7 +3673,7 @@ static void P_PlayerMobjThinker(mobj_t *mobj) { boolean thereiswater = false; - for (node = mobj->touching_sectorlist; node; node = node->m_thinglist_next) + for (node = mobj->touching_sectorlist; node; node = node->m_sectorlist_next) { if (node->m_sector->ffloors) { @@ -3694,7 +3694,7 @@ static void P_PlayerMobjThinker(mobj_t *mobj) } if (thereiswater) { - for (node = mobj->touching_sectorlist; node; node = node->m_thinglist_next) + for (node = mobj->touching_sectorlist; node; node = node->m_sectorlist_next) { if (node->m_sector->ffloors) { diff --git a/src/p_spec.c b/src/p_spec.c index 25e32e578..0bd530279 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -3308,7 +3308,7 @@ sector_t *P_PlayerTouchingSectorSpecial(player_t *player, INT32 section, INT32 n return rover->master->frontsector; } - for (node = player->mo->touching_sectorlist; node; node = node->m_thinglist_next) + for (node = player->mo->touching_sectorlist; node; node = node->m_sectorlist_next) { if (GETSECSPECIAL(node->m_sector->special, section) == number) { @@ -4657,7 +4657,7 @@ void P_PlayerInSpecialSector(player_t *player) P_RunSpecialSectorCheck(player, sector); // Iterate through touching_sectorlist - for (node = player->mo->touching_sectorlist; node; node = node->m_thinglist_next) + for (node = player->mo->touching_sectorlist; node; node = node->m_sectorlist_next) { sector = node->m_sector; diff --git a/src/p_user.c b/src/p_user.c index 2156f0fc0..c9ac9f541 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -2849,86 +2849,10 @@ static boolean PIT_CheckSolidsTeeter(mobj_t *thing) // static void P_DoTeeter(player_t *player) { - msecnode_t *node; boolean teeter = false; boolean roverfloor; // solid 3d floors? - boolean checkedforteeter = false; const fixed_t tiptop = FixedMul(MAXSTEPMOVE, player->mo->scale); // Distance you have to be above the ground in order to teeter. - for (node = player->mo->touching_sectorlist; node; node = node->m_thinglist_next) - { - // Ledge teetering. Check if any nearby sectors are low enough from your current one. - checkedforteeter = true; - roverfloor = false; - if (node->m_sector->ffloors) - { - ffloor_t *rover; - for (rover = node->m_sector->ffloors; rover; rover = rover->next) - { - if (!(rover->flags & FF_EXISTS)) continue; - - if (P_CheckSolidLava(player->mo, rover)) - ; - else if (!(rover->flags & FF_BLOCKPLAYER || rover->flags & FF_QUICKSAND)) - continue; // intangible 3d floor - - if (player->mo->eflags & MFE_VERTICALFLIP) - { - if (*rover->bottomheight > node->m_sector->ceilingheight) // Above the ceiling - continue; - - if (*rover->bottomheight > player->mo->z + player->mo->height + tiptop - || (*rover->topheight < player->mo->z - && player->mo->z + player->mo->height < node->m_sector->ceilingheight - tiptop)) - { - teeter = true; - roverfloor = true; - } - else - { - teeter = false; - roverfloor = true; - break; - } - } - else - { - if (*rover->topheight < node->m_sector->floorheight) // Below the floor - continue; - - if (*rover->topheight < player->mo->z - tiptop - || (*rover->bottomheight > player->mo->z + player->mo->height - && player->mo->z > node->m_sector->floorheight + tiptop)) - { - teeter = true; - roverfloor = true; - } - else - { - teeter = false; - roverfloor = true; - break; - } - } - } - } - - if (!teeter && !roverfloor) - { - if (player->mo->eflags & MFE_VERTICALFLIP) - { - if (node->m_sector->ceilingheight > player->mo->z + player->mo->height + tiptop) - teeter = true; - } - else - { - if (node->m_sector->floorheight < player->mo->z - tiptop) - teeter = true; - } - } - } - - if (checkedforteeter && !teeter) // Backup code { subsector_t *subsec[4]; // changed abcd into array instead UINT8 i; @@ -3147,7 +3071,7 @@ teeterdone: if ((player->mo->state == &states[S_PLAY_STND] || player->mo->state == &states[S_PLAY_TAP1] || player->mo->state == &states[S_PLAY_TAP2] || player->mo->state == &states[S_PLAY_SUPERSTAND])) P_SetPlayerMobjState(player->mo, S_PLAY_TEETER1); } - else if (checkedforteeter && (player->mo->state == &states[S_PLAY_TEETER1] || player->mo->state == &states[S_PLAY_TEETER2] || player->mo->state == &states[S_PLAY_SUPERTEETER])) + else if ((player->mo->state == &states[S_PLAY_TEETER1] || player->mo->state == &states[S_PLAY_TEETER2] || player->mo->state == &states[S_PLAY_SUPERTEETER])) P_SetPlayerMobjState(player->mo, S_PLAY_STND); } @@ -7037,7 +6961,7 @@ static void P_MovePlayer(player_t *player) player->mo->y += player->mo->momy; P_SetThingPosition(player->mo); - for (node = player->mo->touching_sectorlist; node; node = node->m_thinglist_next) + for (node = player->mo->touching_sectorlist; node; node = node->m_sectorlist_next) { if (!node->m_sector) break; From 19b186e52e004098f6b43bff78e6ea82d01c8127 Mon Sep 17 00:00:00 2001 From: toasterbabe Date: Thu, 9 Jun 2016 15:16:25 +0100 Subject: [PATCH 37/71] Changed teetering to match the discoveries made about it in the sectorlist_traversal branch in a way that matches my revamps here, since I DID change a lot. --- src/p_user.c | 104 ++------------------------------------------------- 1 file changed, 4 insertions(+), 100 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index 2e9f0b295..313dad1d5 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -2852,8 +2852,8 @@ static void P_DoTeeter(player_t *player) msecnode_t *node; boolean teeter = false; boolean roverfloor; // solid 3d floors? - boolean checkedforteeter = false; fixed_t floorheight, ceilingheight; + fixed_t highestceilingheight, lowestfloorheight; fixed_t topheight, bottomheight; // for 3d floor usage const fixed_t tiptop = FixedMul(MAXSTEPMOVE, player->mo->scale); // Distance you have to be above the ground in order to teeter. @@ -2862,107 +2862,11 @@ static void P_DoTeeter(player_t *player) teeter = true; #undef maxzdelta else // Let's do some checks... - { - for (node = player->mo->touching_sectorlist; node; node = node->m_snext) - { - // Ledge teetering. Check if any nearby sectors are low enough from your current one. - checkedforteeter = true; - roverfloor = false; - - ceilingheight = node->m_sector->ceilingheight; - floorheight = node->m_sector->floorheight; -#ifdef ESLOPE - if (node->m_sector->c_slope) - ceilingheight = P_GetZAt(node->m_sector->c_slope, player->mo->x, player->mo->y) + FixedMul(node->m_sector->c_slope->zdelta, tiptop); - if (node->m_sector->f_slope) - floorheight = P_GetZAt(node->m_sector->f_slope, player->mo->x, player->mo->y); -#endif - - if (node->m_sector->ffloors) - { - ffloor_t *rover; - for (rover = node->m_sector->ffloors; rover; rover = rover->next) - { - if (!(rover->flags & FF_EXISTS)) continue; - - topheight = *rover->topheight; - bottomheight = *rover->bottomheight; - -#ifdef ESLOPE - if (*rover->t_slope) - topheight = P_GetZAt(*rover->t_slope, player->mo->x, player->mo->y); - if (*rover->b_slope) - bottomheight = P_GetZAt(*rover->b_slope, player->mo->x, player->mo->y); -#endif - - if (P_CheckSolidLava(player->mo, rover)) - ; - else if (!(rover->flags & FF_BLOCKPLAYER || rover->flags & FF_QUICKSAND)) - continue; // intangible 3d floor - - if (player->mo->eflags & MFE_VERTICALFLIP) - { - if (bottomheight > ceilingheight) // Above the ceiling - continue; - - if (bottomheight > player->mo->z + player->mo->height + tiptop - || (topheight < player->mo->z - && player->mo->z + player->mo->height < ceilingheight - tiptop)) - { - teeter = true; - roverfloor = true; - } - else - { - teeter = false; - roverfloor = true; - break; - } - } - else - { - if (topheight < floorheight) // Below the floor - continue; - - if (topheight < player->mo->z - tiptop - || (bottomheight > player->mo->z + player->mo->height - && player->mo->z > floorheight + tiptop)) - { - teeter = true; - roverfloor = true; - } - else - { - teeter = false; - roverfloor = true; - break; - } - } - } - } - - if (!teeter && !roverfloor) - { - if (player->mo->eflags & MFE_VERTICALFLIP) - { - if (ceilingheight > player->mo->z + player->mo->height + tiptop) - teeter = true; - } - else - { - if (floorheight < player->mo->z - tiptop) - teeter = true; - } - } - } - } - - if (checkedforteeter && !teeter) // Backup code { sector_t *sec; UINT8 i; - fixed_t highestceilingheight = INT32_MIN; - fixed_t lowestfloorheight = INT32_MAX; + highestceilingheight = INT32_MIN; + lowestfloorheight = INT32_MAX; teeter = false; roverfloor = false; @@ -3197,7 +3101,7 @@ teeterdone: if ((player->mo->state == &states[S_PLAY_STND] || player->mo->state == &states[S_PLAY_TAP1] || player->mo->state == &states[S_PLAY_TAP2] || player->mo->state == &states[S_PLAY_SUPERSTAND])) P_SetPlayerMobjState(player->mo, S_PLAY_TEETER1); } - else if (checkedforteeter && (player->mo->state == &states[S_PLAY_TEETER1] || player->mo->state == &states[S_PLAY_TEETER2] || player->mo->state == &states[S_PLAY_SUPERTEETER])) + else if ((player->mo->state == &states[S_PLAY_TEETER1] || player->mo->state == &states[S_PLAY_TEETER2] || player->mo->state == &states[S_PLAY_SUPERTEETER])) P_SetPlayerMobjState(player->mo, S_PLAY_STND); } From c5ff41d6a640f34d833a61c6bc05472938efc7d4 Mon Sep 17 00:00:00 2001 From: toasterbabe Date: Thu, 9 Jun 2016 15:20:45 +0100 Subject: [PATCH 38/71] Fixed compile error and placed the #undefs for xsign and ysign in more logical places. --- 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 313dad1d5..ca0224132 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -2878,6 +2878,8 @@ static void P_DoTeeter(player_t *player) #define ysign ((i & 2) ? 1 : -1) // 0 -> 1 | 1 -> 1 | 2 -> -1 | 3 -> -1 fixed_t checkx = player->mo->x + (xsign*FixedMul(5*FRACUNIT, player->mo->scale)); fixed_t checky = player->mo->y + (ysign*FixedMul(5*FRACUNIT, player->mo->scale)); +#undef xsign +#undef ysign sec = R_PointInSubsector(checkx, checky)->sector; @@ -2891,8 +2893,6 @@ static void P_DoTeeter(player_t *player) #endif highestceilingheight = (ceilingheight > highestceilingheight) ? ceilingheight : highestceilingheight; lowestfloorheight = (floorheight < lowestfloorheight) ? floorheight : lowestfloorheight; -#undef xsign -#undef ysign if (!(sec->ffloors)) continue; // move on to the next subsector From 1723bb55f9cd5a579670c9c1fe594c449691ef83 Mon Sep 17 00:00:00 2001 From: toasterbabe Date: Thu, 9 Jun 2016 15:24:23 +0100 Subject: [PATCH 39/71] Okay, NOW I fixed the compile error. Forgot to stage this. --- src/p_user.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/p_user.c b/src/p_user.c index ca0224132..499966798 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -2849,7 +2849,6 @@ static boolean PIT_CheckSolidsTeeter(mobj_t *thing) // static void P_DoTeeter(player_t *player) { - msecnode_t *node; boolean teeter = false; boolean roverfloor; // solid 3d floors? fixed_t floorheight, ceilingheight; From 661da15146d4385891fbc4d7e82a518b2bc23034 Mon Sep 17 00:00:00 2001 From: toasterbabe Date: Thu, 9 Jun 2016 18:16:13 +0100 Subject: [PATCH 40/71] Reinforcing encapsulation I originally broke down to allow for P_GetMobjGravity. When I first wrote this, I thought the .h file that contained a function declaration needed to have the same name as the .c file the function was in. Now I know that's not the case, off to p_local.h with you. --- src/lua_baselib.c | 1 - src/p_local.h | 1 + src/p_mobj.h | 3 --- src/p_slopes.c | 1 - 4 files changed, 1 insertion(+), 5 deletions(-) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index c88ece50c..e8e8fd020 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -13,7 +13,6 @@ #include "doomdef.h" #ifdef HAVE_BLUA #include "p_local.h" -#include "p_mobj.h" // So we can have P_GetMobjGravity #include "p_setup.h" // So we can have P_SetupLevelSky #include "z_zone.h" #include "r_main.h" diff --git a/src/p_local.h b/src/p_local.h index c8930aeda..5ffd473f1 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -251,6 +251,7 @@ mobj_t *P_SPMAngle(mobj_t *source, mobjtype_t type, angle_t angle, UINT8 aimtype #endif void P_ColorTeamMissile(mobj_t *missile, player_t *source); SINT8 P_MobjFlip(mobj_t *mobj); +fixed_t P_GetMobjGravity(mobj_t *mo); boolean P_WeaponOrPanel(mobjtype_t type); boolean P_CameraThinker(player_t *player, camera_t *thiscam, boolean resetcalled); diff --git a/src/p_mobj.h b/src/p_mobj.h index de7f0c8d5..9542ce8ba 100644 --- a/src/p_mobj.h +++ b/src/p_mobj.h @@ -425,9 +425,6 @@ void P_AddCachedAction(mobj_t *mobj, INT32 statenum); // check mobj against water content, before movement code void P_MobjCheckWater(mobj_t *mobj); -// get mobj gravity -fixed_t P_GetMobjGravity(mobj_t *mo); - // Player spawn points void P_SpawnPlayer(INT32 playernum); void P_MovePlayerToSpawn(INT32 playernum, mapthing_t *mthing); diff --git a/src/p_slopes.c b/src/p_slopes.c index b6338d95d..8df94e757 100644 --- a/src/p_slopes.c +++ b/src/p_slopes.c @@ -16,7 +16,6 @@ #include "m_bbox.h" #include "z_zone.h" #include "p_local.h" -#include "p_mobj.h" #include "p_spec.h" #include "p_slopes.h" #include "p_setup.h" From 20c2d84c78a3423beeef30d5d50a4a777b1b1dad Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Thu, 9 Jun 2016 20:37:36 +0100 Subject: [PATCH 41/71] Fix single side line midtexture skewing Red apparently left in code for single-sided linedefs to NOT skew their midtextures ...but it doesn't work because it doesn't stop the skewing code from running instead, regardless of whether Effect 1 is on or not. If it's decided single-sided line midtextures shouldn't do this though, the non-skew code could just as well be thrown out lol (or something else I guess?) --- src/r_segs.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/r_segs.c b/src/r_segs.c index 11b4c8aef..a2487771b 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -1862,8 +1862,9 @@ void R_StoreWallRange(INT32 start, INT32 stop) if (linedef->flags & ML_DONTPEGBOTTOM) rw_midtexturemid = frontsector->floorheight + textureheight[sidedef->midtexture] - viewz; else - rw_midtexturemid = frontsector->ceilingheight; + rw_midtexturemid = frontsector->ceilingheight - viewz; } + else #endif if (linedef->flags & ML_DONTPEGBOTTOM) { From a04fcce3a998025b765a567791595b3129ae414d Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Thu, 9 Jun 2016 22:07:43 +0100 Subject: [PATCH 42/71] Hack to fix midtextures for polyobjects being mucked up "frontsector" in this part of the code isn't actually the polyobject's sector for back-side polyobject segs, it's the in-level sector the polyobject as a whole is being rendered in it turns out. --- src/r_segs.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/r_segs.c b/src/r_segs.c index a2487771b..07fe554c2 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -2483,6 +2483,15 @@ void R_StoreWallRange(INT32 start, INT32 stop) #ifdef ESLOPE maskedtextureheight = ds_p->maskedtextureheight; // note to red, this == &(ds_p->maskedtextureheight[0]) +#ifdef POLYOBJECTS + if (curline->polyseg) { // use REAL front and back floors please, so midtexture rendering isn't mucked up + rw_midtextureslide = rw_midtexturebackslide = 0; + if (!!(linedef->flags & ML_DONTPEGBOTTOM) ^ !!(linedef->flags & ML_EFFECT3)) + rw_midtexturemid = rw_midtextureback = max(curline->frontsector->floorheight, curline->backsector->floorheight) - viewz; + else + rw_midtexturemid = rw_midtextureback = min(curline->frontsector->ceilingheight, curline->backsector->ceilingheight) - viewz; + } else +#endif // Set midtexture starting height if (linedef->flags & ML_EFFECT2) { // Ignore slopes when texturing rw_midtextureslide = rw_midtexturebackslide = 0; From 9e87f6d85d9e9b874dcfa876a35272720cdb1b12 Mon Sep 17 00:00:00 2001 From: toasterbabe Date: Fri, 10 Jun 2016 22:45:42 +0100 Subject: [PATCH 43/71] i did so much in this branch, so UPGRADE ME TO PROGRAMMER note: once this is merged into internal, you should probably remove me from "programming assistance" so i'm not duplicated for no clear reason. unless you want me to slowly take over every section in the credits >:3c --- src/f_finale.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/f_finale.c b/src/f_finale.c index 776bec981..efc2a127a 100644 --- a/src/f_finale.c +++ b/src/f_finale.c @@ -973,6 +973,7 @@ static const char *credits[] = { "Callum Dickinson", "Scott \"Graue\" Feeney", "Nathan \"Jazz\" Giroux", + "Vivian \"toaster\" Grannell", "Thomas \"Shadow Hog\" Igoe", "\"Monster\" Iestyn Jealous", "Ronald \"Furyhunter\" Kinard", // The SDL2 port From df92dc8d9ea84a58f66ba1d6c187d6d4ebeecbc4 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Sat, 11 Jun 2016 16:14:08 +0100 Subject: [PATCH 44/71] Print debugging message if sector->linecount is zero --- src/p_setup.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index b36bf0b80..0beb3be30 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -1931,10 +1931,18 @@ static void P_GroupLines(void) // allocate linebuffers for each sector for (i = 0, sector = sectors; i < numsectors; i++, sector++) { - sector->lines = Z_Calloc(sector->linecount * sizeof(line_t*), PU_LEVEL, NULL); + if (sector->linecount == 0) // no lines found? + { + sector->lines = NULL; + CONS_Debug(DBG_SETUP, "P_GroupLines: sector %d has no lines\n", i); + } + else + { + sector->lines = Z_Calloc(sector->linecount * sizeof(line_t*), PU_LEVEL, NULL); - // zero the count, since we'll later use this to track how many we've recorded - sector->linecount = 0; + // zero the count, since we'll later use this to track how many we've recorded + sector->linecount = 0; + } } // iterate through lines, assigning them to sectors' linebuffers, @@ -1952,11 +1960,14 @@ static void P_GroupLines(void) { M_ClearBox(bbox); - for (j = 0; j < sector->linecount; j++) + if (sector->linecount != 0) { - li = sector->lines[j]; - M_AddToBox(bbox, li->v1->x, li->v1->y); - M_AddToBox(bbox, li->v2->x, li->v2->y); + for (j = 0; j < sector->linecount; j++) + { + li = sector->lines[j]; + M_AddToBox(bbox, li->v1->x, li->v1->y); + M_AddToBox(bbox, li->v2->x, li->v2->y); + } } // set the degenmobj_t to the middle of the bounding box From a7a7a7ee6d6f3b89fd85046b9b66d0a711e1a88b Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Sat, 11 Jun 2016 18:45:56 +0100 Subject: [PATCH 45/71] Added P_LoadReject function to properly check if REJECT lump is valid or not when loading it, so P_CheckSight can avoid accessing it if not. This should mean that maps built with ZBSDP (no reject) should have less or no problems in netgames compared to the standard ZenNode maps now, hopefully. =) --- src/p_setup.c | 27 ++++++++++++++++++++++++++- src/p_sight.c | 9 ++++++--- 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index 0beb3be30..087ca6332 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -1977,6 +1977,31 @@ static void P_GroupLines(void) } } +// +// P_LoadReject +// +// Detect if the REJECT lump is valid, +// if not, rejectmatrix will be NULL +static void P_LoadReject(lumpnum_t lumpnum) +{ + size_t count; + const char *lumpname = W_CheckNameForNum(lumpnum); + + // Check if the lump exists, and if it's named "REJECT" + if (!lumpname || memcmp(lumpname, "REJECT", 8) != 0) + { + rejectmatrix = NULL; + return; + } + + count = W_LumpLength(lumpnum); + + if (!count) // zero length, someone probably used ZDBSP + rejectmatrix = NULL; + else + rejectmatrix = W_CacheLumpNum(lumpnum, PU_LEVEL); +} + #if 0 static char *levellumps[] = { @@ -2585,7 +2610,7 @@ boolean P_SetupLevel(boolean skipprecip) P_LoadSubsectors(lastloadedmaplumpnum + ML_SSECTORS); P_LoadNodes(lastloadedmaplumpnum + ML_NODES); P_LoadSegs(lastloadedmaplumpnum + ML_SEGS); - rejectmatrix = W_CacheLumpNum(lastloadedmaplumpnum + ML_REJECT, PU_LEVEL); + P_LoadReject(lastloadedmaplumpnum + ML_REJECT); P_GroupLines(); numdmstarts = numredctfstarts = numbluectfstarts = 0; diff --git a/src/p_sight.c b/src/p_sight.c index 14c1c945f..bd6ab4d73 100644 --- a/src/p_sight.c +++ b/src/p_sight.c @@ -325,9 +325,12 @@ boolean P_CheckSight(mobj_t *t1, mobj_t *t2) s2 = t2->subsector->sector; pnum = (s1-sectors)*numsectors + (s2-sectors); - // Check in REJECT table. - if (rejectmatrix[pnum>>3] & (1 << (pnum&7))) // can't possibly be connected - return false; + if (rejectmatrix != NULL) + { + // Check in REJECT table. + if (rejectmatrix[pnum>>3] & (1 << (pnum&7))) // can't possibly be connected + return false; + } // killough 11/98: shortcut for melee situations // same subsector? obviously visible From 1d0e74f9c0c268bb37b2e2375b1fac0529687ea9 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Sat, 11 Jun 2016 21:19:16 +0100 Subject: [PATCH 46/71] "REJECT" is only 5 chars long, not 8. --- 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 087ca6332..d7d169e6b 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -1988,7 +1988,7 @@ static void P_LoadReject(lumpnum_t lumpnum) const char *lumpname = W_CheckNameForNum(lumpnum); // Check if the lump exists, and if it's named "REJECT" - if (!lumpname || memcmp(lumpname, "REJECT", 8) != 0) + if (!lumpname || memcmp(lumpname, "REJECT", 5) != 0) { rejectmatrix = NULL; return; From 472dce1ae65df01972acda0e13d3d00e629a3508 Mon Sep 17 00:00:00 2001 From: Alam Ed Arias Date: Sat, 11 Jun 2016 21:42:02 -0400 Subject: [PATCH 47/71] Do not why we are not checking REJECT\0\0, let fix this check --- 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 d7d169e6b..755f32a85 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -1988,7 +1988,7 @@ static void P_LoadReject(lumpnum_t lumpnum) const char *lumpname = W_CheckNameForNum(lumpnum); // Check if the lump exists, and if it's named "REJECT" - if (!lumpname || memcmp(lumpname, "REJECT", 5) != 0) + if (!lumpname || memcmp(lumpname, "REJECT", 7) != 0) { rejectmatrix = NULL; return; From 305d32870f537c90c9035b75dc175ee00e148287 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Sun, 12 Jun 2016 18:47:27 +0100 Subject: [PATCH 48/71] Effect 2 (No Midtexture Skew) now toggles off skewing for midtextures on single-sided lines, which was what was intended for them to begin with apparently. This means the current skewing-by-default effect isn't changed, and OpenGL's equivalent code doesn't have to be touched since apparently it was already like that. --- 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 07fe554c2..1ee9777d0 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -1858,7 +1858,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) // a single sided line is terminal, so it must mark ends markfloor = markceiling = true; #ifdef ESLOPE - if (!(linedef->flags & ML_EFFECT1)) { + if (linedef->flags & ML_EFFECT2) { if (linedef->flags & ML_DONTPEGBOTTOM) rw_midtexturemid = frontsector->floorheight + textureheight[sidedef->midtexture] - viewz; else From 2c676eea433f883b5812a6f712e189dab2fc9a49 Mon Sep 17 00:00:00 2001 From: toasterbabe Date: Sun, 12 Jun 2016 19:27:34 +0100 Subject: [PATCH 49/71] P_ReverseQuantiseMomentumToSlope is now a function. (I was thinking about a macro, but couldn't get it down.) Also, the teetering angle on slopes is now FRACUNIT/2 because there's literally no way to stand still on a slope that steep unless it doesn't have physics. --- src/p_mobj.c | 5 +---- src/p_slopes.c | 18 ++++++++++++------ src/p_slopes.h | 1 + src/p_user.c | 10 +++------- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index 843123d57..2cf94e835 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -2377,10 +2377,7 @@ static boolean P_ZMovement(mobj_t *mo) if ((mo->eflags & MFE_VERTICALFLIP) ? tmceilingslope : tmfloorslope) { mo->standingslope = (mo->eflags & MFE_VERTICALFLIP) ? tmceilingslope : tmfloorslope; - // Reverse quantizing might could use its own function later - mo->standingslope->zangle = ANGLE_MAX-mo->standingslope->zangle; - P_QuantizeMomentumToSlope(&mom, mo->standingslope); - mo->standingslope->zangle = ANGLE_MAX-mo->standingslope->zangle; + P_ReverseQuantizeMomentumToSlope(&mom, mo->standingslope); } #endif diff --git a/src/p_slopes.c b/src/p_slopes.c index 8df94e757..d939fee98 100644 --- a/src/p_slopes.c +++ b/src/p_slopes.c @@ -767,6 +767,17 @@ void P_QuantizeMomentumToSlope(vector3_t *momentum, pslope_t *slope) FV3_Rotate(momentum, &axis, slope->zangle >> ANGLETOFINESHIFT); } +// +// P_ReverseQuantizeMomentumToSlope +// +// When given a vector, rotates and aligns it to a flat surface (from being relative to a given slope) +void P_ReverseQuantizeMomentumToSlope(vector3_t *momentum, pslope_t *slope) +{ + slope->zangle = InvAngle(slope->zangle); + P_QuantizeMomentumToSlope(momentum, slope); + slope->zangle = InvAngle(slope->zangle); +} + // // P_SlopeLaunch // @@ -810,12 +821,7 @@ void P_HandleSlopeLanding(mobj_t *thing, pslope_t *slope) mom.y = thing->momy; mom.z = thing->momz*2; - //CONS_Printf("Landing on slope\n"); - - // Reverse quantizing might could use its own function later - slope->zangle = ANGLE_MAX-slope->zangle; - P_QuantizeMomentumToSlope(&mom, slope); - slope->zangle = ANGLE_MAX-slope->zangle; + P_ReverseQuantizeMomentumToSlope(&mom, slope); if (P_MobjFlip(thing)*mom.z < 0) { // falling, land on slope thing->momx = mom.x; diff --git a/src/p_slopes.h b/src/p_slopes.h index dd9b6f2d2..de38f1d9e 100644 --- a/src/p_slopes.h +++ b/src/p_slopes.h @@ -35,6 +35,7 @@ fixed_t P_GetZAt(pslope_t *slope, fixed_t x, fixed_t y); // Lots of physics-based bullshit void P_QuantizeMomentumToSlope(vector3_t *momentum, pslope_t *slope); +void P_ReverseQuantizeMomentumToSlope(vector3_t *momentum, pslope_t *slope); void P_SlopeLaunch(mobj_t *mo); void P_HandleSlopeLanding(mobj_t *thing, pslope_t *slope); void P_ButteredSlope(mobj_t *mo); diff --git a/src/p_user.c b/src/p_user.c index 499966798..7bf2b1f66 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -1851,12 +1851,8 @@ static void P_CheckBouncySectors(player_t *player) momentum.y = player->mo->momy; momentum.z = player->mo->momz*2; - if (slope) { - // Reverse quantizing might could use its own function later - slope->zangle = ANGLE_MAX-slope->zangle; - P_QuantizeMomentumToSlope(&momentum, slope); - slope->zangle = ANGLE_MAX-slope->zangle; - } + if (slope) + P_ReverseQuantizeMomentumToSlope(&momentum, slope); newmom = momentum.z = -FixedMul(momentum.z,linedist)/2; #else @@ -2856,7 +2852,7 @@ static void P_DoTeeter(player_t *player) fixed_t topheight, bottomheight; // for 3d floor usage const fixed_t tiptop = FixedMul(MAXSTEPMOVE, player->mo->scale); // Distance you have to be above the ground in order to teeter. -#define maxzdelta 3<<(FRACBITS-2) // 3/4 on the fixed scale +#define maxzdelta 1<<(FRACBITS-1) // 1/2 on the fixed scale if (player->mo->standingslope && player->mo->standingslope->zdelta >= maxzdelta) // Always teeter if the slope is too steep. teeter = true; #undef maxzdelta From 6271adcbe7db2a8e011ecf2fec0dec502bf16f1c Mon Sep 17 00:00:00 2001 From: Alam Ed Arias Date: Sun, 12 Jun 2016 15:55:06 -0400 Subject: [PATCH 50/71] make sure !BLUA EXE works without warnings --- src/dehacked.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/dehacked.c b/src/dehacked.c index 199ea43ca..01174aa6f 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -6717,12 +6717,14 @@ static const char *const MOBJEFLAG_LIST[] = { NULL }; +#ifdef HAVE_BLUA static const char *const MAPTHINGFLAG_LIST[4] = { NULL, "OBJECTFLIP", // Reverse gravity flag for objects. "OBJECTSPECIAL", // Special flag used with certain objects. "AMBUSH" // Deaf monsters/do not react to sound. }; +#endif static const char *const PLAYERFLAG_LIST[] = { // Flip camera angle with gravity flip prefrence. @@ -6795,6 +6797,7 @@ static const char *const PLAYERFLAG_LIST[] = { NULL // stop loop here. }; +#ifdef HAVE_BLUA // Linedef flags static const char *const ML_LIST[16] = { "IMPASSIBLE", @@ -6814,6 +6817,7 @@ static const char *const ML_LIST[16] = { "BOUNCY", "TFERLINE" }; +#endif // This DOES differ from r_draw's Color_Names, unfortunately. // Also includes Super colors From 1e3631425f19b3666c2f6a8fc683c752f04b77a4 Mon Sep 17 00:00:00 2001 From: Alam Ed Arias Date: Sun, 12 Jun 2016 15:57:16 -0400 Subject: [PATCH 51/71] r_opengl: move DrawMD2i code to DrawMD2Ex --- src/hardware/r_opengl/r_opengl.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index 1a81fe796..1085a7123 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -1836,10 +1836,7 @@ EXPORT void HWRAPI(SetSpecialState) (hwdspecialstate_t IdState, INT32 Value) } } -// -----------------+ -// HWRAPI DrawMD2 : Draw an MD2 model with glcommands -// -----------------+ -EXPORT void HWRAPI(DrawMD2i) (INT32 *gl_cmd_buffer, md2_frame_t *frame, UINT32 duration, UINT32 tics, md2_frame_t *nextframe, FTransform *pos, float scale, UINT8 flipped, UINT8 *color) +static inline void DrawMD2Ex(INT32 *gl_cmd_buffer, md2_frame_t *frame, UINT32 duration, UINT32 tics, md2_frame_t *nextframe, FTransform *pos, float scale, UINT8 flipped, UINT8 *color) { INT32 val, count, pindex; GLfloat s, t; @@ -2007,11 +2004,20 @@ EXPORT void HWRAPI(DrawMD2i) (INT32 *gl_cmd_buffer, md2_frame_t *frame, UINT32 d pglDisable(GL_CULL_FACE); } +// -----------------+ +// HWRAPI DrawMD2 : Draw an MD2 model with glcommands +// -----------------+ +EXPORT void HWRAPI(DrawMD2i) (INT32 *gl_cmd_buffer, md2_frame_t *frame, UINT32 duration, UINT32 tics, md2_frame_t *nextframe, FTransform *pos, float scale, UINT8 flipped, UINT8 *color) +{ + DrawMD2Ex(gl_cmd_buffer, frame, duration, tics, nextframe, pos, scale, flipped, color); +} + EXPORT void HWRAPI(DrawMD2) (INT32 *gl_cmd_buffer, md2_frame_t *frame, FTransform *pos, float scale) { - DrawMD2i(gl_cmd_buffer, frame, 0, 0, NULL, pos, scale, false, NULL); + DrawMD2Ex(gl_cmd_buffer, frame, 0, 0, NULL, pos, scale, false, NULL); } + // -----------------+ // SetTransform : // -----------------+ From 1e507d3d1e12e2b345fc07f6914af5a1de915173 Mon Sep 17 00:00:00 2001 From: Alam Ed Arias Date: Sun, 12 Jun 2016 15:58:42 -0400 Subject: [PATCH 52/71] added printf checks to hardware's I_Error --- src/hardware/hw_dll.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hardware/hw_dll.h b/src/hardware/hw_dll.h index d9620be02..6b9f4d538 100644 --- a/src/hardware/hw_dll.h +++ b/src/hardware/hw_dll.h @@ -54,7 +54,7 @@ #endif #endif -typedef void (*I_Error_t) (const char *error, ...); +typedef void (*I_Error_t) (const char *error, ...) FUNCIERROR; // ========================================================================== // MATHS From 4d6a3e339821e5dcfbca4a01d6e295a2eecf10f1 Mon Sep 17 00:00:00 2001 From: Alam Ed Arias Date: Sun, 12 Jun 2016 15:58:03 -0400 Subject: [PATCH 53/71] FUNCMATH fun --- src/d_main.h | 2 +- src/dehacked.c | 2 +- src/f_finale.h | 2 +- src/hu_stuff.h | 2 +- src/p_local.h | 2 +- src/p_mobj.h | 2 +- src/r_plane.h | 2 +- src/r_splats.h | 4 ++++ src/s_sound.h | 2 +- src/screen.c | 7 +++++++ src/screen.h | 4 +--- src/sdl/i_cdmus.c | 16 ++++++++-------- src/sdl/i_system.c | 16 ++++++++-------- src/sdl/i_video.c | 6 +++--- src/sdl/mixer_sound.c | 6 +++--- src/st_stuff.h | 2 +- src/tables.h | 2 +- 17 files changed, 44 insertions(+), 35 deletions(-) diff --git a/src/d_main.h b/src/d_main.h index 88387a579..6dc273b15 100644 --- a/src/d_main.h +++ b/src/d_main.h @@ -41,7 +41,7 @@ void D_SRB2Main(void); // Called by IO functions when input is detected. void D_PostEvent(const event_t *ev); #ifndef DOXYGEN -void D_PostEvent_end(void); // delimiter for locking memory +FUNCMATH void D_PostEvent_end(void); // delimiter for locking memory #endif void D_ProcessEvents(void); diff --git a/src/dehacked.c b/src/dehacked.c index 01174aa6f..e798d8f10 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -7766,7 +7766,7 @@ fixed_t get_number(const char *word) #endif } -void DEH_Check(void) +void FUNCMATH DEH_Check(void) { #if defined(_DEBUG) || defined(PARANOIA) const size_t dehstates = sizeof(STATE_LIST)/sizeof(const char*); diff --git a/src/f_finale.h b/src/f_finale.h index 8ee02bdf3..1f23643be 100644 --- a/src/f_finale.h +++ b/src/f_finale.h @@ -35,7 +35,7 @@ void F_CutsceneTicker(void); void F_TitleDemoTicker(void); // Called by main loop. -void F_GameEndDrawer(void); +FUNCMATH void F_GameEndDrawer(void); void F_IntroDrawer(void); void F_TitleScreenDrawer(void); diff --git a/src/hu_stuff.h b/src/hu_stuff.h index f0dd40096..7b22f33f1 100644 --- a/src/hu_stuff.h +++ b/src/hu_stuff.h @@ -87,7 +87,7 @@ void HU_Init(void); void HU_LoadGraphics(void); // reset heads up when consoleplayer respawns. -void HU_Start(void); +FUNCMATH void HU_Start(void); boolean HU_Responder(event_t *ev); diff --git a/src/p_local.h b/src/p_local.h index c8930aeda..972e26e79 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -251,7 +251,7 @@ mobj_t *P_SPMAngle(mobj_t *source, mobjtype_t type, angle_t angle, UINT8 aimtype #endif void P_ColorTeamMissile(mobj_t *missile, player_t *source); SINT8 P_MobjFlip(mobj_t *mobj); -boolean P_WeaponOrPanel(mobjtype_t type); +FUNCMATH boolean P_WeaponOrPanel(mobjtype_t type); boolean P_CameraThinker(player_t *player, camera_t *thiscam, boolean resetcalled); diff --git a/src/p_mobj.h b/src/p_mobj.h index 9542ce8ba..79cffae89 100644 --- a/src/p_mobj.h +++ b/src/p_mobj.h @@ -441,7 +441,7 @@ boolean P_SupermanLook4Players(mobj_t *actor); void P_DestroyRobots(void); void P_SnowThinker(precipmobj_t *mobj); void P_RainThinker(precipmobj_t *mobj); -void P_NullPrecipThinker(precipmobj_t *mobj); +FUNCMATH void P_NullPrecipThinker(precipmobj_t *mobj); void P_RemovePrecipMobj(precipmobj_t *mobj); void P_SetScale(mobj_t *mobj, fixed_t newscale); void P_XYMovement(mobj_t *mo); diff --git a/src/r_plane.h b/src/r_plane.h index 8730bcefd..ec1940716 100644 --- a/src/r_plane.h +++ b/src/r_plane.h @@ -87,7 +87,7 @@ extern lighttable_t **planezlight; extern fixed_t *yslope; extern fixed_t distscale[MAXVIDWIDTH]; -void R_InitPlanes(void); +FUNCMATH void R_InitPlanes(void); void R_PortalStoreClipValues(INT32 start, INT32 end, INT16 *ceil, INT16 *floor, fixed_t *scale); void R_PortalRestoreClipValues(INT32 start, INT32 end, INT16 *ceil, INT16 *floor, fixed_t *scale); void R_ClearPlanes(void); diff --git a/src/r_splats.h b/src/r_splats.h index 349d8fa7a..c0ba6881c 100644 --- a/src/r_splats.h +++ b/src/r_splats.h @@ -63,7 +63,11 @@ typedef struct floorsplat_s fixed_t P_SegLength(seg_t *seg); // call at P_SetupLevel() +#if !(defined (WALLSPLATS) || defined (FLOORSPLATS)) +FUNCMATH void R_ClearLevelSplats(void); +#else void R_ClearLevelSplats(void); +#endif #ifdef WALLSPLATS void R_AddWallSplat(line_t *wallline, INT16 sectorside, const char *patchname, fixed_t top, diff --git a/src/s_sound.h b/src/s_sound.h index bcc7979a1..39ec769a6 100644 --- a/src/s_sound.h +++ b/src/s_sound.h @@ -119,7 +119,7 @@ void S_ResumeAudio(void); // void S_UpdateSounds(void); -fixed_t S_CalculateSoundDistance(fixed_t px1, fixed_t py1, fixed_t pz1, fixed_t px2, fixed_t py2, fixed_t pz2); +FUNCMATH fixed_t S_CalculateSoundDistance(fixed_t px1, fixed_t py1, fixed_t pz1, fixed_t px2, fixed_t py2, fixed_t pz2); void S_SetDigMusicVolume(INT32 volume); void S_SetMIDIMusicVolume(INT32 volume); diff --git a/src/screen.c b/src/screen.c index 3834f72d5..376586c5d 100644 --- a/src/screen.c +++ b/src/screen.c @@ -69,6 +69,13 @@ 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}; #endif consvar_t cv_renderview = {"renderview", "On", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; + +#ifdef DIRECTFULLSCREEN +static FUNCMATH void SCR_ChangeFullscreen (void); +#else +static void SCR_ChangeFullscreen (void); +#endif + consvar_t cv_fullscreen = {"fullscreen", "Yes", CV_SAVE|CV_CALL, CV_YesNo, SCR_ChangeFullscreen, 0, NULL, NULL, 0, 0, NULL}; // ========================================================================= diff --git a/src/screen.h b/src/screen.h index bdf8e5a7d..2dff4590e 100644 --- a/src/screen.h +++ b/src/screen.h @@ -175,9 +175,7 @@ void SCR_SetDefaultMode (void); void SCR_Startup (void); -void SCR_ChangeFullscreen (void); - -boolean SCR_IsAspectCorrect(INT32 width, INT32 height); +FUNCMATH boolean SCR_IsAspectCorrect(INT32 width, INT32 height); // move out to main code for consistency void SCR_DisplayTicRate(void); diff --git a/src/sdl/i_cdmus.c b/src/sdl/i_cdmus.c index f3f703667..3105f5122 100644 --- a/src/sdl/i_cdmus.c +++ b/src/sdl/i_cdmus.c @@ -12,25 +12,25 @@ consvar_t cd_volume = {"cd_volume","31",CV_SAVE,soundvolume_cons_t, NULL, 0, NUL consvar_t cdUpdate = {"cd_update","1",CV_SAVE, NULL, NULL, 0, NULL, NULL, 0, 0, NULL}; -void I_InitCD(void){} +FUNCMATH void I_InitCD(void){} -void I_StopCD(void){} +FUNCMATH void I_StopCD(void){} -void I_PauseCD(void){} +FUNCMATH void I_PauseCD(void){} -void I_ResumeCD(void){} +FUNCMATH void I_ResumeCD(void){} -void I_ShutdownCD(void){} +FUNCMATH void I_ShutdownCD(void){} -void I_UpdateCD(void){} +FUNCMATH void I_UpdateCD(void){} -void I_PlayCD(UINT8 track, UINT8 looping) +FUNCMATH void I_PlayCD(UINT8 track, UINT8 looping) { (void)track; (void)looping; } -boolean I_SetVolumeCD(int volume) +FUNCMATH boolean I_SetVolumeCD(int volume) { (void)volume; return false; diff --git a/src/sdl/i_system.c b/src/sdl/i_system.c index 0212e620b..ea8ade8c1 100644 --- a/src/sdl/i_system.c +++ b/src/sdl/i_system.c @@ -2049,14 +2049,14 @@ void I_StartupMouse2(void) // // I_Tactile // -void I_Tactile(FFType pFFType, const JoyFF_t *FFEffect) +FUNCMATH void I_Tactile(FFType pFFType, const JoyFF_t *FFEffect) { // UNUSED. (void)pFFType; (void)FFEffect; } -void I_Tactile2(FFType pFFType, const JoyFF_t *FFEffect) +FUNCMATH void I_Tactile2(FFType pFFType, const JoyFF_t *FFEffect) { // UNUSED. (void)pFFType; @@ -2067,7 +2067,7 @@ void I_Tactile2(FFType pFFType, const JoyFF_t *FFEffect) */ static ticcmd_t emptycmd; -ticcmd_t *I_BaseTiccmd(void) +FUNCMATH ticcmd_t *I_BaseTiccmd(void) { return &emptycmd; } @@ -2076,7 +2076,7 @@ ticcmd_t *I_BaseTiccmd(void) */ static ticcmd_t emptycmd2; -ticcmd_t *I_BaseTiccmd2(void) +FUNCMATH ticcmd_t *I_BaseTiccmd2(void) { return &emptycmd2; } @@ -2179,7 +2179,7 @@ tic_t I_GetTime (void) // //I_StartupTimer // -void I_StartupTimer(void) +FUNCMATH void I_StartupTimer(void) { #if (defined (_WIN32) && !defined (_WIN32_WCE)) && !defined (_XBOX) // for win2k time bug @@ -2313,11 +2313,11 @@ void I_WaitVBL(INT32 count) SDL_Delay(count); } -void I_BeginRead(void) +FUNCMATH void I_BeginRead(void) { } -void I_EndRead(void) +FUNCMATH void I_EndRead(void) { } @@ -3067,5 +3067,5 @@ const CPUInfoFlags *I_CPUInfo(void) } // note CPUAFFINITY code used to reside here -void I_RegisterSysCommands(void) {} +FUNCMATH void I_RegisterSysCommands(void) {} #endif diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index b5168dad5..76c8ba2ca 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -1346,7 +1346,7 @@ void I_SetPalette(RGBA_t *palette) } // return number of fullscreen + X11 modes -INT32 VID_NumModes(void) + FUNCMATH INT32 VID_NumModes(void) { if (USE_FULLSCREEN && numVidModes != -1) return numVidModes - firstEntry; @@ -1354,7 +1354,7 @@ INT32 VID_NumModes(void) return MAXWINMODES; } -const char *VID_GetModeName(INT32 modeNum) +FUNCMATH const char *VID_GetModeName(INT32 modeNum) { #if 0 if (USE_FULLSCREEN && numVidModes != -1) // fullscreen modes @@ -1384,7 +1384,7 @@ const char *VID_GetModeName(INT32 modeNum) return &vidModeName[modeNum][0]; } -INT32 VID_GetModeForSize(INT32 w, INT32 h) +FUNCMATH INT32 VID_GetModeForSize(INT32 w, INT32 h) { int i; for (i = 0; i < MAXWINMODES; i++) diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index faebca6b4..4a46813c1 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -126,7 +126,7 @@ void I_ShutdownSound(void) #endif } -void I_UpdateSound(void) +FUNCMATH void I_UpdateSound(void) { } @@ -464,7 +464,7 @@ static void mix_gme(void *udata, Uint8 *stream, int len) } #endif -void I_InitMusic(void) +FUNCMATH void I_InitMusic(void) { } @@ -769,7 +769,7 @@ boolean I_SetSongTrack(int track) // MIDI Music // -void I_InitMIDIMusic(void) +FUNCMATH void I_InitMIDIMusic(void) { } diff --git a/src/st_stuff.h b/src/st_stuff.h index 6fafca404..c11559d2b 100644 --- a/src/st_stuff.h +++ b/src/st_stuff.h @@ -24,7 +24,7 @@ // // Called by main loop. -void ST_Ticker(void); +FUNCMATH void ST_Ticker(void); // Called by main loop. void ST_Drawer(void); diff --git a/src/tables.h b/src/tables.h index 0e4853cb9..e05b81845 100644 --- a/src/tables.h +++ b/src/tables.h @@ -82,7 +82,7 @@ typedef UINT32 angle_t; extern angle_t tantoangle[SLOPERANGE+1]; // Utility function, called by R_PointToAngle. -unsigned SlopeDiv(unsigned num, unsigned den); +FUNCMATH unsigned SlopeDiv(unsigned num, unsigned den); // 360 - angle_t(ANGLE_45) = ANGLE_315 FUNCMATH FUNCINLINE static ATTRINLINE angle_t InvAngle(angle_t a) From f94dd510adb882147528c150d5fdd682ec27fdb6 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Sun, 12 Jun 2016 21:16:41 +0100 Subject: [PATCH 54/71] change back to 8, add \0s --- 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 755f32a85..8dcfa6d91 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -1988,7 +1988,7 @@ static void P_LoadReject(lumpnum_t lumpnum) const char *lumpname = W_CheckNameForNum(lumpnum); // Check if the lump exists, and if it's named "REJECT" - if (!lumpname || memcmp(lumpname, "REJECT", 7) != 0) + if (!lumpname || memcmp(lumpname, "REJECT\0\0", 8) != 0) { rejectmatrix = NULL; return; From 9b037164bcef8410a006ab3d44dbda97303b6ceb Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Sun, 12 Jun 2016 21:51:27 +0100 Subject: [PATCH 55/71] Added debug messages for when REJECT lump is not loaded --- src/p_setup.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/p_setup.c b/src/p_setup.c index 8dcfa6d91..6c14e3614 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -1991,13 +1991,17 @@ static void P_LoadReject(lumpnum_t lumpnum) if (!lumpname || memcmp(lumpname, "REJECT\0\0", 8) != 0) { rejectmatrix = NULL; + CONS_Debug(DBG_SETUP, "P_LoadReject: No valid REJECT lump found\n"); return; } count = W_LumpLength(lumpnum); if (!count) // zero length, someone probably used ZDBSP + { rejectmatrix = NULL; + CONS_Debug(DBG_SETUP, "P_LoadReject: REJECT lump has size 0, will not be loaded\n"); + } else rejectmatrix = W_CacheLumpNum(lumpnum, PU_LEVEL); } From 2c8008e11ea419fa7ba61d548b5414127c891bcf Mon Sep 17 00:00:00 2001 From: Alam Ed Arias Date: Mon, 13 Jun 2016 10:07:10 -0400 Subject: [PATCH 56/71] NULL checks --- src/blua/lvm.c | 3 ++- src/command.c | 6 ++++-- src/hardware/hw_main.c | 14 +++++++++----- src/hardware/r_opengl/r_opengl.c | 2 +- src/r_things.c | 3 ++- 5 files changed, 18 insertions(+), 10 deletions(-) diff --git a/src/blua/lvm.c b/src/blua/lvm.c index a921d4437..b654613f4 100644 --- a/src/blua/lvm.c +++ b/src/blua/lvm.c @@ -732,7 +732,8 @@ void luaV_execute (lua_State *L, int nexeccalls) { luaG_runerror(L, LUA_QL("for") " limit must be a number"); else if (!tonumber(pstep, ra+2)) luaG_runerror(L, LUA_QL("for") " step must be a number"); - setnvalue(ra, luai_numsub(nvalue(ra), nvalue(pstep))); + if (ra && pstep) + setnvalue(ra, luai_numsub(nvalue(ra), nvalue(pstep))); dojump(L, pc, GETARG_sBx(i)); continue; } diff --git a/src/command.c b/src/command.c index 84d777acf..a15471c83 100644 --- a/src/command.c +++ b/src/command.c @@ -966,9 +966,11 @@ void CV_RegisterVar(consvar_t *variable) // check net variables if (variable->flags & CV_NETVAR) { + const consvar_t *netvar; variable->netid = CV_ComputeNetid(variable->name); - if (CV_FindNetVar(variable->netid)) - I_Error("Variables %s and %s have same netid\n", variable->name, CV_FindNetVar(variable->netid)->name); + netvar = CV_FindNetVar(variable->netid); + if (netvar) + I_Error("Variables %s and %s have same netid\n", variable->name, netvar->name); } // link the variable in diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 35a01ffd1..ca4e000bb 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -4529,7 +4529,8 @@ static void HWR_SortVisSprites(void) // Fix first and last. ds still points to the last one after the loop dsfirst->prev = &unsorted; unsorted.next = dsfirst; - ds->next = &unsorted; + if (ds) + ds->next = &unsorted; unsorted.prev = ds; // pull the vissprites out by scale @@ -4552,10 +4553,13 @@ static void HWR_SortVisSprites(void) best = ds; } } - best->next->prev = best->prev; - best->prev->next = best->next; - best->next = &gr_vsprsortedhead; - best->prev = gr_vsprsortedhead.prev; + if (best) + { + best->next->prev = best->prev; + best->prev->next = best->next; + best->next = &gr_vsprsortedhead; + best->prev = gr_vsprsortedhead.prev; + } gr_vsprsortedhead.prev->next = best; gr_vsprsortedhead.prev = best; } diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index 1085a7123..54dd94854 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -1928,7 +1928,7 @@ static inline void DrawMD2Ex(INT32 *gl_cmd_buffer, md2_frame_t *frame, UINT32 du //pglBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // alpha = level of transparency // Remove depth mask when the model is transparent so it doesn't cut thorugh sprites // SRB2CBTODO: For all stuff too?! - if (color[3] < 255) + if (color && color[3] < 255) { pglBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // alpha = level of transparency pglDepthMask(GL_FALSE); diff --git a/src/r_things.c b/src/r_things.c index eaab53613..76251d880 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -1634,7 +1634,8 @@ void R_SortVisSprites(void) // Fix first and last. ds still points to the last one after the loop dsfirst->prev = &unsorted; unsorted.next = dsfirst; - ds->next = &unsorted; + if (ds) + ds->next = &unsorted; unsorted.prev = ds; // pull the vissprites out by scale From a046d3807ede9722881232fa235d58504bd839bd Mon Sep 17 00:00:00 2001 From: Alam Ed Arias Date: Mon, 13 Jun 2016 11:11:02 -0400 Subject: [PATCH 57/71] strings return by M_GetText() can not be changed --- 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 884b22ad3..cf5512a18 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -3626,7 +3626,7 @@ void P_PlayerFlagBurst(player_t *player, boolean toss) // Flag text { char plname[MAXPLAYERNAME+4]; - char *flagtext; + const char *flagtext; char flagcolor; snprintf(plname, sizeof(plname), "%s%s%s", From 3fe87eff97641ca484010f8dba91c2065395f8d2 Mon Sep 17 00:00:00 2001 From: toasterbabe Date: Sat, 18 Jun 2016 23:55:43 +0100 Subject: [PATCH 58/71] Disabling the functionality of SL_NOPHYSICS for 2.1 patches by never applying it --- src/p_slopes.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/p_slopes.c b/src/p_slopes.c index d939fee98..f134b20e9 100644 --- a/src/p_slopes.c +++ b/src/p_slopes.c @@ -250,7 +250,7 @@ void P_SpawnSlope_Line(int linenum) UINT8 flags = 0; // Slope flags if (line->flags & ML_NOSONIC) - flags |= SL_NOPHYSICS; + ; // flags |= SL_NOPHYSICS; - disabled for 2.1 if (line->flags & ML_NOTAILS) flags |= SL_NODYNAMIC; if (line->flags & ML_NOKNUX) @@ -686,7 +686,7 @@ void P_ResetDynamicSlopes(void) { UINT8 flags = SL_VERTEXSLOPE; if (lines[i].flags & ML_NOSONIC) - flags |= SL_NOPHYSICS; + ; // flags |= SL_NOPHYSICS; - disabled for 2.1 if (!(lines[i].flags & ML_NOTAILS)) flags |= SL_NODYNAMIC; From f5f2c4ad48a8d3f6236f9578089559ea96d6f3d9 Mon Sep 17 00:00:00 2001 From: toasterbabe Date: Sun, 19 Jun 2016 16:38:04 +0100 Subject: [PATCH 59/71] Revert "Okay, NOW I fixed the compile error. Forgot to stage this." This reverts commit 1723bb55f9cd5a579670c9c1fe594c449691ef83. --- src/p_user.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/p_user.c b/src/p_user.c index 7bf2b1f66..36cf71b0e 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -2845,6 +2845,7 @@ static boolean PIT_CheckSolidsTeeter(mobj_t *thing) // static void P_DoTeeter(player_t *player) { + msecnode_t *node; boolean teeter = false; boolean roverfloor; // solid 3d floors? fixed_t floorheight, ceilingheight; From 1147428904e2bcec78758d4a7796ada0de65bbde Mon Sep 17 00:00:00 2001 From: toasterbabe Date: Sun, 19 Jun 2016 16:38:11 +0100 Subject: [PATCH 60/71] Revert "Changed teetering to match the discoveries made about it in the sectorlist_traversal branch in a way that matches my revamps here, since I DID change a lot." This reverts commit 19b186e52e004098f6b43bff78e6ea82d01c8127. --- src/p_user.c | 104 +++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 100 insertions(+), 4 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index 36cf71b0e..317523a36 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -2848,8 +2848,8 @@ static void P_DoTeeter(player_t *player) msecnode_t *node; boolean teeter = false; boolean roverfloor; // solid 3d floors? + boolean checkedforteeter = false; fixed_t floorheight, ceilingheight; - fixed_t highestceilingheight, lowestfloorheight; fixed_t topheight, bottomheight; // for 3d floor usage const fixed_t tiptop = FixedMul(MAXSTEPMOVE, player->mo->scale); // Distance you have to be above the ground in order to teeter. @@ -2858,11 +2858,107 @@ static void P_DoTeeter(player_t *player) teeter = true; #undef maxzdelta else // Let's do some checks... + { + for (node = player->mo->touching_sectorlist; node; node = node->m_snext) + { + // Ledge teetering. Check if any nearby sectors are low enough from your current one. + checkedforteeter = true; + roverfloor = false; + + ceilingheight = node->m_sector->ceilingheight; + floorheight = node->m_sector->floorheight; +#ifdef ESLOPE + if (node->m_sector->c_slope) + ceilingheight = P_GetZAt(node->m_sector->c_slope, player->mo->x, player->mo->y) + FixedMul(node->m_sector->c_slope->zdelta, tiptop); + if (node->m_sector->f_slope) + floorheight = P_GetZAt(node->m_sector->f_slope, player->mo->x, player->mo->y); +#endif + + if (node->m_sector->ffloors) + { + ffloor_t *rover; + for (rover = node->m_sector->ffloors; rover; rover = rover->next) + { + if (!(rover->flags & FF_EXISTS)) continue; + + topheight = *rover->topheight; + bottomheight = *rover->bottomheight; + +#ifdef ESLOPE + if (*rover->t_slope) + topheight = P_GetZAt(*rover->t_slope, player->mo->x, player->mo->y); + if (*rover->b_slope) + bottomheight = P_GetZAt(*rover->b_slope, player->mo->x, player->mo->y); +#endif + + if (P_CheckSolidLava(player->mo, rover)) + ; + else if (!(rover->flags & FF_BLOCKPLAYER || rover->flags & FF_QUICKSAND)) + continue; // intangible 3d floor + + if (player->mo->eflags & MFE_VERTICALFLIP) + { + if (bottomheight > ceilingheight) // Above the ceiling + continue; + + if (bottomheight > player->mo->z + player->mo->height + tiptop + || (topheight < player->mo->z + && player->mo->z + player->mo->height < ceilingheight - tiptop)) + { + teeter = true; + roverfloor = true; + } + else + { + teeter = false; + roverfloor = true; + break; + } + } + else + { + if (topheight < floorheight) // Below the floor + continue; + + if (topheight < player->mo->z - tiptop + || (bottomheight > player->mo->z + player->mo->height + && player->mo->z > floorheight + tiptop)) + { + teeter = true; + roverfloor = true; + } + else + { + teeter = false; + roverfloor = true; + break; + } + } + } + } + + if (!teeter && !roverfloor) + { + if (player->mo->eflags & MFE_VERTICALFLIP) + { + if (ceilingheight > player->mo->z + player->mo->height + tiptop) + teeter = true; + } + else + { + if (floorheight < player->mo->z - tiptop) + teeter = true; + } + } + } + } + + if (checkedforteeter && !teeter) // Backup code { sector_t *sec; UINT8 i; - highestceilingheight = INT32_MIN; - lowestfloorheight = INT32_MAX; + fixed_t highestceilingheight = INT32_MIN; + fixed_t lowestfloorheight = INT32_MAX; teeter = false; roverfloor = false; @@ -3097,7 +3193,7 @@ teeterdone: if ((player->mo->state == &states[S_PLAY_STND] || player->mo->state == &states[S_PLAY_TAP1] || player->mo->state == &states[S_PLAY_TAP2] || player->mo->state == &states[S_PLAY_SUPERSTAND])) P_SetPlayerMobjState(player->mo, S_PLAY_TEETER1); } - else if ((player->mo->state == &states[S_PLAY_TEETER1] || player->mo->state == &states[S_PLAY_TEETER2] || player->mo->state == &states[S_PLAY_SUPERTEETER])) + else if (checkedforteeter && (player->mo->state == &states[S_PLAY_TEETER1] || player->mo->state == &states[S_PLAY_TEETER2] || player->mo->state == &states[S_PLAY_SUPERTEETER])) P_SetPlayerMobjState(player->mo, S_PLAY_STND); } From 86721f1457b059b04474ca2b26ee43b920723a18 Mon Sep 17 00:00:00 2001 From: toasterbabe Date: Sun, 19 Jun 2016 17:29:04 +0100 Subject: [PATCH 61/71] Compilation fix of the patch to disable this feature ( :c ). --- src/p_slopes.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/p_slopes.c b/src/p_slopes.c index f134b20e9..936af4426 100644 --- a/src/p_slopes.c +++ b/src/p_slopes.c @@ -249,8 +249,8 @@ void P_SpawnSlope_Line(int linenum) boolean backceil = (special == 711 || special == 712 || special == 703); UINT8 flags = 0; // Slope flags - if (line->flags & ML_NOSONIC) - ; // flags |= SL_NOPHYSICS; - disabled for 2.1 + /*if (line->flags & ML_NOSONIC) + flags |= SL_NOPHYSICS; - disabled for 2.1*/ if (line->flags & ML_NOTAILS) flags |= SL_NODYNAMIC; if (line->flags & ML_NOKNUX) @@ -685,8 +685,8 @@ void P_ResetDynamicSlopes(void) { size_t which = lines[i].special; UINT8 flags = SL_VERTEXSLOPE; - if (lines[i].flags & ML_NOSONIC) - ; // flags |= SL_NOPHYSICS; - disabled for 2.1 + /*if (line->flags & ML_NOSONIC) + flags |= SL_NOPHYSICS; - disabled for 2.1*/ if (!(lines[i].flags & ML_NOTAILS)) flags |= SL_NODYNAMIC; From e87e747a29e98aa6253176bbc892a783b4e3c6b7 Mon Sep 17 00:00:00 2001 From: Alam Ed Arias Date: Sun, 19 Jun 2016 12:48:35 -0400 Subject: [PATCH 62/71] clean up warning done in setup-fixes --- 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 6c14e3614..e56c44c70 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -1934,7 +1934,7 @@ static void P_GroupLines(void) if (sector->linecount == 0) // no lines found? { sector->lines = NULL; - CONS_Debug(DBG_SETUP, "P_GroupLines: sector %d has no lines\n", i); + CONS_Debug(DBG_SETUP, "P_GroupLines: sector %s has no lines\n", sizeu1(i)); } else { From 6f4c52c993f043e172b6a4ba443a7cbea212c4ec Mon Sep 17 00:00:00 2001 From: Alam Ed Arias Date: Sun, 19 Jun 2016 12:51:56 -0400 Subject: [PATCH 63/71] travis: treat warnings as errors --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index e3408cf6f..d728758ed 100644 --- a/.travis.yml +++ b/.travis.yml @@ -98,7 +98,7 @@ matrix: - p7zip-full - gcc-6 compiler: gcc-6 - env: WFLAGS="-Wno-error=tautological-compare" + env: WFLAGS="-Wno-tautological-compare" #gcc-6 (Ubuntu 6.1.1-3ubuntu11~14.04.1) 6.1.1 20160511 - os: linux compiler: clang @@ -213,7 +213,7 @@ before_script: - 7z x $HOME/srb2_cache/SRB2-v2115-assets-2.7z -oassets - mkdir build - cd build - - export CFLAGS="-Wall -W $WFLAGS" + - export CFLAGS="-Wall -W -Werror $WFLAGS" - export CCACHE_COMPRESS=true - cmake .. -DCMAKE_BUILD_TYPE=Release From 71f5d4ea85d12356aacc15b5bd0e34e26af10e72 Mon Sep 17 00:00:00 2001 From: toasterbabe Date: Mon, 20 Jun 2016 00:20:20 +0100 Subject: [PATCH 64/71] ...completely misunderstood the reasons we weren't merging toast_slopes, mom holy fuck i'm stupid and bad Enjoy your slopes without physics, people :D --- src/f_finale.c | 2 +- src/p_slopes.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/f_finale.c b/src/f_finale.c index efc2a127a..784d82047 100644 --- a/src/f_finale.c +++ b/src/f_finale.c @@ -973,7 +973,6 @@ static const char *credits[] = { "Callum Dickinson", "Scott \"Graue\" Feeney", "Nathan \"Jazz\" Giroux", - "Vivian \"toaster\" Grannell", "Thomas \"Shadow Hog\" Igoe", "\"Monster\" Iestyn Jealous", "Ronald \"Furyhunter\" Kinard", // The SDL2 port @@ -987,6 +986,7 @@ static const char *credits[] = { "\"chi.miru\"", // Red's secret weapon, the REAL reason slopes exist (also helped port drawing code from ZDoom) "Andrew \"orospakr\" Clunis", "Gregor \"Oogaland\" Dick", + "Vivian \"toaster\" Grannell", "Julio \"Chaos Zero 64\" Guir", "\"Kalaron\"", // Coded some of Sryder13's collection of OpenGL fixes, especially fog "Matthew \"Shuffle\" Marsalko", diff --git a/src/p_slopes.c b/src/p_slopes.c index 936af4426..d939fee98 100644 --- a/src/p_slopes.c +++ b/src/p_slopes.c @@ -249,8 +249,8 @@ void P_SpawnSlope_Line(int linenum) boolean backceil = (special == 711 || special == 712 || special == 703); UINT8 flags = 0; // Slope flags - /*if (line->flags & ML_NOSONIC) - flags |= SL_NOPHYSICS; - disabled for 2.1*/ + if (line->flags & ML_NOSONIC) + flags |= SL_NOPHYSICS; if (line->flags & ML_NOTAILS) flags |= SL_NODYNAMIC; if (line->flags & ML_NOKNUX) @@ -685,8 +685,8 @@ void P_ResetDynamicSlopes(void) { size_t which = lines[i].special; UINT8 flags = SL_VERTEXSLOPE; - /*if (line->flags & ML_NOSONIC) - flags |= SL_NOPHYSICS; - disabled for 2.1*/ + if (lines[i].flags & ML_NOSONIC) + flags |= SL_NOPHYSICS; if (!(lines[i].flags & ML_NOTAILS)) flags |= SL_NODYNAMIC; From 7126d57fd7a7d8562cf19eabddc07fc311ce9da6 Mon Sep 17 00:00:00 2001 From: Alam Ed Arias Date: Sun, 19 Jun 2016 20:25:09 -0400 Subject: [PATCH 65/71] whitespace cleanup --- 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 76c8ba2ca..71baca510 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -1346,7 +1346,7 @@ void I_SetPalette(RGBA_t *palette) } // return number of fullscreen + X11 modes - FUNCMATH INT32 VID_NumModes(void) +FUNCMATH INT32 VID_NumModes(void) { if (USE_FULLSCREEN && numVidModes != -1) return numVidModes - firstEntry; From 20ffbbdc41e29fc0138be2c5c7de0827d92ef08c Mon Sep 17 00:00:00 2001 From: toasterbabe Date: Mon, 20 Jun 2016 01:50:47 +0100 Subject: [PATCH 66/71] Climbing now supports one-sided linedefs. The whole thing needs a refactor in general, but it's almost 2am here, I need my sleeb, and this fix would probably break something with 2.1 climbing if I made it any more/less (depending on viewpoint) complicated. --- src/p_map.c | 6 +- src/p_user.c | 475 ++++++++++++++++++++++++++------------------------- 2 files changed, 245 insertions(+), 236 deletions(-) diff --git a/src/p_map.c b/src/p_map.c index 44df30018..449223721 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -2423,6 +2423,8 @@ isblocking: // // P_IsClimbingValid // +// Unlike P_DoClimbing, don't use when up against a one-sided linedef. +// static boolean P_IsClimbingValid(player_t *player, angle_t angle) { fixed_t platx, platy; @@ -2657,9 +2659,11 @@ isblocking: climbangle += (ANGLE_90 * (whichside ? -1 : 1)); + boolean canclimb = (li->backsector ? P_IsClimbingValid(slidemo->player, climbangle) : true); + if (((!slidemo->player->climbing && abs((signed)(slidemo->angle - ANGLE_90 - climbline)) < ANGLE_45) || (slidemo->player->climbing == 1 && abs((signed)(slidemo->angle - climbline)) < ANGLE_135)) - && P_IsClimbingValid(slidemo->player, climbangle)) + && canclimb) { slidemo->angle = climbangle; if (!demoplayback || P_AnalogMove(slidemo->player)) diff --git a/src/p_user.c b/src/p_user.c index c9ac9f541..93c721623 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -2284,9 +2284,9 @@ static void P_DoClimbing(player_t *player) platx = P_ReturnThrustX(player->mo, player->mo->angle, player->mo->radius + FixedMul(8*FRACUNIT, player->mo->scale)); platy = P_ReturnThrustY(player->mo, player->mo->angle, player->mo->radius + FixedMul(8*FRACUNIT, player->mo->scale)); - glidesector = R_PointInSubsector(player->mo->x + platx, player->mo->y + platy); + glidesector = R_IsPointInSubsector(player->mo->x + platx, player->mo->y + platy); - if (glidesector->sector != player->mo->subsector->sector) + if (!glidesector || glidesector->sector != player->mo->subsector->sector) { boolean floorclimb; boolean thrust; @@ -2298,299 +2298,304 @@ static void P_DoClimbing(player_t *player) boostup = false; skyclimber = false; -#ifdef ESLOPE - floorheight = glidesector->sector->f_slope ? P_GetZAt(glidesector->sector->f_slope, player->mo->x, player->mo->y) - : glidesector->sector->floorheight; - ceilingheight = glidesector->sector->c_slope ? P_GetZAt(glidesector->sector->c_slope, player->mo->x, player->mo->y) - : glidesector->sector->ceilingheight; -#else - floorheight = glidesector->sector->floorheight; - ceilingheight = glidesector->sector->ceilingheight; -#endif - - if (glidesector->sector->ffloors) + if (glidesector) { - ffloor_t *rover; - fixed_t topheight, bottomheight; // ESLOPE +#ifdef ESLOPE + floorheight = glidesector->sector->f_slope ? P_GetZAt(glidesector->sector->f_slope, player->mo->x, player->mo->y) + : glidesector->sector->floorheight; + ceilingheight = glidesector->sector->c_slope ? P_GetZAt(glidesector->sector->c_slope, player->mo->x, player->mo->y) + : glidesector->sector->ceilingheight; +#else + floorheight = glidesector->sector->floorheight; + ceilingheight = glidesector->sector->ceilingheight; +#endif - for (rover = glidesector->sector->ffloors; rover; rover = rover->next) + if (glidesector->sector->ffloors) { - if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_BLOCKPLAYER) || (rover->flags & FF_BUSTUP)) - continue; + ffloor_t *rover; + fixed_t topheight, bottomheight; // ESLOPE - floorclimb = true; + for (rover = glidesector->sector->ffloors; rover; rover = rover->next) + { + if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_BLOCKPLAYER) || (rover->flags & FF_BUSTUP)) + continue; + + floorclimb = true; #ifdef ESLOPE - bottomheight = *rover->b_slope ? P_GetZAt(*rover->b_slope, player->mo->x, player->mo->y) : *rover->bottomheight; - 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; + topheight = *rover->t_slope ? P_GetZAt(*rover->t_slope, player->mo->x, player->mo->y) : *rover->topheight; #else - bottomheight = *rover->bottomheight; - topheight = *rover->topheight; + bottomheight = *rover->bottomheight; + topheight = *rover->topheight; #endif - // Only supports rovers that are moving like an 'elevator', not just the top or bottom. - if (rover->master->frontsector->floorspeed && rover->master->frontsector->ceilspeed == 42) - { - if ((!(player->mo->eflags & MFE_VERTICALFLIP) && (bottomheight < player->mo->z+player->mo->height) - && (topheight >= player->mo->z + FixedMul(16*FRACUNIT, player->mo->scale))) - || ((player->mo->eflags & MFE_VERTICALFLIP) && (topheight > player->mo->z) - && (bottomheight <= player->mo->z + player->mo->height - FixedMul(16*FRACUNIT, player->mo->scale)))) + // Only supports rovers that are moving like an 'elevator', not just the top or bottom. + if (rover->master->frontsector->floorspeed && rover->master->frontsector->ceilspeed == 42) { - if (cmd->forwardmove != 0) - player->mo->momz += rover->master->frontsector->floorspeed; - else + if ((!(player->mo->eflags & MFE_VERTICALFLIP) && (bottomheight < player->mo->z+player->mo->height) + && (topheight >= player->mo->z + FixedMul(16*FRACUNIT, player->mo->scale))) + || ((player->mo->eflags & MFE_VERTICALFLIP) && (topheight > player->mo->z) + && (bottomheight <= player->mo->z + player->mo->height - FixedMul(16*FRACUNIT, player->mo->scale)))) { - player->mo->momz = rover->master->frontsector->floorspeed; - climb = false; + if (cmd->forwardmove != 0) + player->mo->momz += rover->master->frontsector->floorspeed; + else + { + player->mo->momz = rover->master->frontsector->floorspeed; + climb = false; + } } } - } - // Gravity is flipped, so the comments are, too. - if (player->mo->eflags & MFE_VERTICALFLIP) - { - // Trying to climb down past the bottom of the FOF - if ((topheight >= player->mo->z + player->mo->height) && ((player->mo->z + player->mo->height + player->mo->momz) >= topheight)) + // Gravity is flipped, so the comments are, too. + if (player->mo->eflags & MFE_VERTICALFLIP) { - fixed_t bottomheight2; - ffloor_t *roverbelow; - boolean foundfof = false; - floorclimb = true; - boostup = false; - - // Is there a FOF directly below this one that we can move onto? - for (roverbelow = glidesector->sector->ffloors; roverbelow; roverbelow = roverbelow->next) + // Trying to climb down past the bottom of the FOF + if ((topheight >= player->mo->z + player->mo->height) && ((player->mo->z + player->mo->height + player->mo->momz) >= topheight)) { - if (!(roverbelow->flags & FF_EXISTS) || !(roverbelow->flags & FF_BLOCKPLAYER) || (roverbelow->flags & FF_BUSTUP)) - continue; + fixed_t bottomheight2; + ffloor_t *roverbelow; + boolean foundfof = false; + floorclimb = true; + boostup = false; - if (roverbelow == rover) - continue; + // 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)) + continue; + + if (roverbelow == rover) + continue; #ifdef ESLOPE - bottomheight2 = *roverbelow->b_slope ? P_GetZAt(*roverbelow->b_slope, player->mo->x, player->mo->y) : *roverbelow->bottomheight; + bottomheight2 = *roverbelow->b_slope ? P_GetZAt(*roverbelow->b_slope, player->mo->x, player->mo->y) : *roverbelow->bottomheight; #else - bottomheight2 = *roverbelow->bottomheight; + bottomheight2 = *roverbelow->bottomheight; #endif - if (bottomheight2 < topheight + FixedMul(16*FRACUNIT, player->mo->scale)) - foundfof = true; + if (bottomheight2 < topheight + FixedMul(16*FRACUNIT, player->mo->scale)) + foundfof = true; + } + + if (!foundfof) + player->mo->momz = 0; } - if (!foundfof) - player->mo->momz = 0; - } - - // Below the FOF - if (topheight <= player->mo->z) - { - floorclimb = false; - boostup = false; - thrust = false; - } - - // Above the FOF - if (bottomheight > player->mo->z + player->mo->height - FixedMul(16*FRACUNIT, player->mo->scale)) - { - floorclimb = false; - thrust = true; - boostup = true; - } - } - else - { - // Trying to climb down past the bottom of a FOF - if ((bottomheight <= player->mo->z) && ((player->mo->z + player->mo->momz) <= bottomheight)) - { - fixed_t topheight2; - ffloor_t *roverbelow; - boolean foundfof = false; - floorclimb = true; - boostup = false; - - // Is there a FOF directly below this one that we can move onto? - for (roverbelow = glidesector->sector->ffloors; roverbelow; roverbelow = roverbelow->next) + // Below the FOF + if (topheight <= player->mo->z) { - if (!(roverbelow->flags & FF_EXISTS) || !(roverbelow->flags & FF_BLOCKPLAYER) || (roverbelow->flags & FF_BUSTUP)) - continue; + floorclimb = false; + boostup = false; + thrust = false; + } - if (roverbelow == rover) - continue; + // Above the FOF + if (bottomheight > player->mo->z + player->mo->height - FixedMul(16*FRACUNIT, player->mo->scale)) + { + floorclimb = false; + thrust = true; + boostup = true; + } + } + else + { + // Trying to climb down past the bottom of a FOF + if ((bottomheight <= player->mo->z) && ((player->mo->z + player->mo->momz) <= bottomheight)) + { + fixed_t topheight2; + ffloor_t *roverbelow; + boolean foundfof = false; + floorclimb = true; + boostup = false; + + // 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)) + continue; + + if (roverbelow == rover) + continue; #ifdef ESLOPE - topheight2 = *roverbelow->t_slope ? P_GetZAt(*roverbelow->t_slope, player->mo->x, player->mo->y) : *roverbelow->topheight; + topheight2 = *roverbelow->t_slope ? P_GetZAt(*roverbelow->t_slope, player->mo->x, player->mo->y) : *roverbelow->topheight; #else - topheight2 = *roverbelow->topheight; + topheight2 = *roverbelow->topheight; #endif - if (topheight2 > bottomheight - FixedMul(16*FRACUNIT, player->mo->scale)) - foundfof = true; + if (topheight2 > bottomheight - FixedMul(16*FRACUNIT, player->mo->scale)) + foundfof = true; + } + + if (!foundfof) + player->mo->momz = 0; } - if (!foundfof) - player->mo->momz = 0; + // Below the FOF + if (bottomheight >= player->mo->z + player->mo->height) + { + floorclimb = false; + boostup = false; + thrust = false; + } + + // Above the FOF + if (topheight < player->mo->z + FixedMul(16*FRACUNIT, player->mo->scale)) + { + floorclimb = false; + thrust = true; + boostup = true; + } } - // Below the FOF - if (bottomheight >= player->mo->z + player->mo->height) + if (floorclimb) { - floorclimb = false; - boostup = false; - thrust = false; + if (rover->flags & FF_CRUMBLE && !(netgame && player->spectator)) + EV_StartCrumble(rover->master->frontsector, rover, (rover->flags & FF_FLOATBOB), player, rover->alpha, !(rover->flags & FF_NORETURN)); + break; } - - // Above the FOF - if (topheight < player->mo->z + FixedMul(16*FRACUNIT, player->mo->scale)) - { - floorclimb = false; - thrust = true; - boostup = true; - } - } - - if (floorclimb) - { - if (rover->flags & FF_CRUMBLE && !(netgame && player->spectator)) - EV_StartCrumble(rover->master->frontsector, rover, (rover->flags & FF_FLOATBOB), player, rover->alpha, !(rover->flags & FF_NORETURN)); - break; } } - } - // Gravity is flipped, so are comments. - if (player->mo->eflags & MFE_VERTICALFLIP) - { - // Trying to climb down past the upper texture area - if ((floorheight >= player->mo->z + player->mo->height) && ((player->mo->z + player->mo->height + player->mo->momz) >= floorheight)) + // Gravity is flipped, so are comments. + if (player->mo->eflags & MFE_VERTICALFLIP) { - boolean foundfof = false; - floorclimb = true; - - // Is there a FOF directly below that we can move onto? - if (glidesector->sector->ffloors) + // Trying to climb down past the upper texture area + if ((floorheight >= player->mo->z + player->mo->height) && ((player->mo->z + player->mo->height + player->mo->momz) >= floorheight)) { - fixed_t bottomheight; - ffloor_t *rover; - for (rover = glidesector->sector->ffloors; rover; rover = rover->next) + boolean foundfof = false; + floorclimb = true; + + // Is there a FOF directly below that we can move onto? + if (glidesector->sector->ffloors) { - if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_BLOCKPLAYER) || (rover->flags & FF_BUSTUP)) - continue; + fixed_t bottomheight; + 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)) + continue; #ifdef ESLOPE - bottomheight = *rover->b_slope ? P_GetZAt(*rover->b_slope, player->mo->x, player->mo->y) : *rover->bottomheight; + bottomheight = *rover->b_slope ? P_GetZAt(*rover->b_slope, player->mo->x, player->mo->y) : *rover->bottomheight; #else - bottomheight = *rover->bottomheight; + bottomheight = *rover->bottomheight; #endif - if (bottomheight < floorheight + FixedMul(16*FRACUNIT, player->mo->scale)) - { - foundfof = true; - break; + if (bottomheight < floorheight + FixedMul(16*FRACUNIT, player->mo->scale)) + { + foundfof = true; + break; + } } } + + if (!foundfof) + player->mo->momz = 0; } - if (!foundfof) - player->mo->momz = 0; + // Reached the top of the lower texture area + if (!floorclimb && ceilingheight > player->mo->z + player->mo->height - FixedMul(16*FRACUNIT, player->mo->scale) + && (glidesector->sector->ceilingpic == skyflatnum || floorheight < (player->mo->z - FixedMul(8*FRACUNIT, player->mo->scale)))) + { + thrust = true; + boostup = true; + // Play climb-up animation here + } + } + else + { + // Trying to climb down past the upper texture area + if ((ceilingheight <= player->mo->z) && ((player->mo->z + player->mo->momz) <= ceilingheight)) + { + boolean foundfof = false; + floorclimb = true; + + // Is there a FOF directly below that we can move onto? + if (glidesector->sector->ffloors) + { + 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)) + continue; + + if (*rover->topheight > ceilingheight - FixedMul(16*FRACUNIT, player->mo->scale)) + { + foundfof = true; + break; + } + } + } + + if (!foundfof) + player->mo->momz = 0; + } + + // Allow climbing from a FOF or lower texture onto the upper texture and vice versa. + if (player->mo->z > ceilingheight - FixedMul(16*FRACUNIT, player->mo->scale)) + { + floorclimb = true; + thrust = false; + boostup = false; + } + + // Reached the top of the lower texture area + if (!floorclimb && floorheight < player->mo->z + FixedMul(16*FRACUNIT, player->mo->scale) + && (glidesector->sector->ceilingpic == skyflatnum || ceilingheight > (player->mo->z + player->mo->height + FixedMul(8*FRACUNIT, player->mo->scale)))) + { + thrust = true; + boostup = true; + // Play climb-up animation here + } } - // Reached the top of the lower texture area - if (!floorclimb && ceilingheight > player->mo->z + player->mo->height - FixedMul(16*FRACUNIT, player->mo->scale) - && (glidesector->sector->ceilingpic == skyflatnum || floorheight < (player->mo->z - FixedMul(8*FRACUNIT, player->mo->scale)))) + // Trying to climb on the sky + if ((ceilingheight < player->mo->z) && glidesector->sector->ceilingpic == skyflatnum) { - thrust = true; - boostup = true; - // Play climb-up animation here + skyclimber = true; + } + + // Climbing on the lower texture area? + if ((!(player->mo->eflags & MFE_VERTICALFLIP) && player->mo->z + FixedMul(16*FRACUNIT, player->mo->scale) < floorheight) + || ((player->mo->eflags & MFE_VERTICALFLIP) && player->mo->z + player->mo->height <= floorheight)) + { + floorclimb = true; + + if (glidesector->sector->floorspeed) + { + if (cmd->forwardmove != 0) + player->mo->momz += glidesector->sector->floorspeed; + else + { + player->mo->momz = glidesector->sector->floorspeed; + climb = false; + } + } + } + // Climbing on the upper texture area? + else if ((!(player->mo->eflags & MFE_VERTICALFLIP) && player->mo->z >= ceilingheight) + || ((player->mo->eflags & MFE_VERTICALFLIP) && player->mo->z + player->mo->height - FixedMul(16*FRACUNIT, player->mo->scale) > ceilingheight)) + { + floorclimb = true; + + if (glidesector->sector->ceilspeed) + { + if (cmd->forwardmove != 0) + player->mo->momz += glidesector->sector->ceilspeed; + else + { + player->mo->momz = glidesector->sector->ceilspeed; + climb = false; + } + } } } else - { - // Trying to climb down past the upper texture area - if ((ceilingheight <= player->mo->z) && ((player->mo->z + player->mo->momz) <= ceilingheight)) - { - boolean foundfof = false; - floorclimb = true; - - // Is there a FOF directly below that we can move onto? - if (glidesector->sector->ffloors) - { - 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)) - continue; - - if (*rover->topheight > ceilingheight - FixedMul(16*FRACUNIT, player->mo->scale)) - { - foundfof = true; - break; - } - } - } - - if (!foundfof) - player->mo->momz = 0; - } - - // Allow climbing from a FOF or lower texture onto the upper texture and vice versa. - if (player->mo->z > ceilingheight - FixedMul(16*FRACUNIT, player->mo->scale)) - { - floorclimb = true; - thrust = false; - boostup = false; - } - - // Reached the top of the lower texture area - if (!floorclimb && floorheight < player->mo->z + FixedMul(16*FRACUNIT, player->mo->scale) - && (glidesector->sector->ceilingpic == skyflatnum || ceilingheight > (player->mo->z + player->mo->height + FixedMul(8*FRACUNIT, player->mo->scale)))) - { - thrust = true; - boostup = true; - // Play climb-up animation here - } - } - - // Trying to climb on the sky - if ((ceilingheight < player->mo->z) && glidesector->sector->ceilingpic == skyflatnum) - { - skyclimber = true; - } - - // Climbing on the lower texture area? - if ((!(player->mo->eflags & MFE_VERTICALFLIP) && player->mo->z + FixedMul(16*FRACUNIT, player->mo->scale) < floorheight) - || ((player->mo->eflags & MFE_VERTICALFLIP) && player->mo->z + player->mo->height <= floorheight)) - { floorclimb = true; - if (glidesector->sector->floorspeed) - { - if (cmd->forwardmove != 0) - player->mo->momz += glidesector->sector->floorspeed; - else - { - player->mo->momz = glidesector->sector->floorspeed; - climb = false; - } - } - } - // Climbing on the upper texture area? - else if ((!(player->mo->eflags & MFE_VERTICALFLIP) && player->mo->z >= ceilingheight) - || ((player->mo->eflags & MFE_VERTICALFLIP) && player->mo->z + player->mo->height - FixedMul(16*FRACUNIT, player->mo->scale) > ceilingheight)) - { - floorclimb = true; - - if (glidesector->sector->ceilspeed) - { - if (cmd->forwardmove != 0) - player->mo->momz += glidesector->sector->ceilspeed; - else - { - player->mo->momz = glidesector->sector->ceilspeed; - climb = false; - } - } - } - if (player->lastsidehit != -1 && player->lastlinehit != -1) { thinker_t *think; From f93b31f0a77f7230e953aaf2334ed5bdc98652b1 Mon Sep 17 00:00:00 2001 From: toasterbabe Date: Mon, 20 Jun 2016 02:08:07 +0100 Subject: [PATCH 67/71] FUCK C90 --- src/p_map.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/p_map.c b/src/p_map.c index 449223721..8621ba202 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -2649,6 +2649,7 @@ isblocking: // see about climbing on the wall if (!(checkline->flags & ML_NOCLIMB)) { + boolean canclimb; // FUCK C90 angle_t climbangle, climbline; INT32 whichside = P_PointOnLineSide(slidemo->x, slidemo->y, li); @@ -2659,7 +2660,7 @@ isblocking: climbangle += (ANGLE_90 * (whichside ? -1 : 1)); - boolean canclimb = (li->backsector ? P_IsClimbingValid(slidemo->player, climbangle) : true); + canclimb = (li->backsector ? P_IsClimbingValid(slidemo->player, climbangle) : true); if (((!slidemo->player->climbing && abs((signed)(slidemo->angle - ANGLE_90 - climbline)) < ANGLE_45) || (slidemo->player->climbing == 1 && abs((signed)(slidemo->angle - climbline)) < ANGLE_135)) From 331ea9814facf87f270e344a3ea3ec4be6ad2090 Mon Sep 17 00:00:00 2001 From: Inuyasha Date: Wed, 29 Jun 2016 20:01:22 -0700 Subject: [PATCH 68/71] version numbers, etc --- src/doomdef.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/doomdef.h b/src/doomdef.h index cec46a32c..66e649ee0 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -149,9 +149,9 @@ extern FILE *logstream; // we use comprevision and compbranch instead. #else #define VERSION 201 // Game version -#define SUBVERSION 15 // more precise version number -#define VERSIONSTRING "v2.1.15" -#define VERSIONSTRINGW L"v2.1.15" +#define SUBVERSION 16 // more precise version number +#define VERSIONSTRING "v2.1.16" +#define VERSIONSTRINGW L"v2.1.16" // Hey! If you change this, add 1 to the MODVERSION below! // Otherwise we can't force updates! #endif @@ -213,7 +213,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 20 +#define MODVERSION 21 // ========================================================================= From c5ca1a8f24e21c6cc13e5d145f55a2cd6f717bd8 Mon Sep 17 00:00:00 2001 From: toasterbabe Date: Thu, 7 Jul 2016 01:40:28 +0100 Subject: [PATCH 69/71] The dashmode struct variable now has a cap, per a Wolfs request. --- src/p_user.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index 48f678601..6b57bb7a9 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -9171,40 +9171,42 @@ void P_PlayerThink(player_t *player) #define dashmode player->dashmode // Dash mode ability for Metal Sonic - if ((player->charability == CA_DASHMODE) && !(maptol & TOL_NIGHTS)) // woo, dashmode! no nights tho. + if ((player->charability == CA_DASHMODE) && !(maptol & TOL_NIGHTS)) // woo, dashmode! no nights tho. { if (player->speed >= FixedMul(skins[player->skin].normalspeed - 5*FRACUNIT, player->mo->scale) || (player->pflags & PF_STARTDASH)) { - dashmode++; // Counter. Adds 1 to dash mode per tic in top speed. - if (dashmode == 3*TICRATE) // This isn't in the ">=" equation because it'd cause the sound to play infinitely. - S_StartSound(player->mo, sfx_s3ka2); // If the player enters dashmode, play this sound on the the tic it starts. + dashmode++; // Counter. Adds 1 to dash mode per tic in top speed. + if (dashmode == 3*TICRATE) // This isn't in the ">=" equation because it'd cause the sound to play infinitely. + S_StartSound(player->mo, sfx_s3ka2); // If the player enters dashmode, play this sound on the the tic it starts. } else if (!(player->pflags & PF_SPINNING)) { if (dashmode > 3) - dashmode -= 3; // Rather than lose it all, it gently counts back down! + dashmode -= 3; // Rather than lose it all, it gently counts back down! else dashmode = 0; } - if (dashmode < 3*TICRATE) // Exits Dash Mode if you drop below speed/dash counter tics. Not in the above block so it doesn't keep disabling in midair. + if (dashmode < 3*TICRATE) // Exits Dash Mode if you drop below speed/dash counter tics. Not in the above block so it doesn't keep disabling in midair. { - player->normalspeed = skins[player->skin].normalspeed; // Reset to default if not capable of entering dash mode. + player->normalspeed = skins[player->skin].normalspeed; // Reset to default if not capable of entering dash mode. player->jumpfactor = skins[player->skin].jumpfactor; } - else if (P_IsObjectOnGround(player->mo)) // Activate dash mode if we're on the ground. + else if (P_IsObjectOnGround(player->mo)) // Activate dash mode if we're on the ground. { - if (player->normalspeed < skins[player->skin].actionspd) // If the player normalspeed is not currently at actionspd in dash mode, add speed each tic - player->normalspeed = player->normalspeed + 1*FRACUNIT/5; // Enter Dash Mode smoothly. + if (player->normalspeed < skins[player->skin].actionspd) // If the player normalspeed is not currently at actionspd in dash mode, add speed each tic + player->normalspeed = player->normalspeed + 1*FRACUNIT/5; // Enter Dash Mode smoothly. if (player->jumpfactor < FixedMul(skins[player->skin].jumpfactor, 5*FRACUNIT/4)) // Boost jump height. player->jumpfactor = player->jumpfactor + 1*FRACUNIT/300; } + dashmode = min(dashmode, 3*TICRATE + 3); + if (player->normalspeed >= skins[player->skin].actionspd) { - mobj_t *ghost = P_SpawnGhostMobj(player->mo); // Spawns afterimages - ghost->fuse = 2; // Makes the images fade quickly + mobj_t *ghost = P_SpawnGhostMobj(player->mo); // Spawns afterimages + ghost->fuse = 2; // Makes the images fade quickly } } else From cee37819cde19ea88a41ae2b4ca419bd67dc6622 Mon Sep 17 00:00:00 2001 From: toasterbabe Date: Sat, 9 Jul 2016 14:52:49 +0100 Subject: [PATCH 70/71] Dashmode now has its own animation, SPR2_PEEL. Requires a new PLAYER.DTA. I made a lot of references to the peelout here because I'm not sure what else to call a Sonic character's faster-than-usual-running animation and SPR2_DASH was taken. * SPR2_PEEL, SPR2_SPEE. * S_PLAY_PEEL, S_PLAY_SUPER_PEEL. * PA_PEEL. * Dashmode actually starts charging from runspeed instead of the arbitrarily calculated (normalspeed - 5*FRACUNIT). This just made things easier, honestly, and it's 1 FU of difference compared to the current test case. --- src/d_player.h | 1 + src/dehacked.c | 3 +++ src/info.c | 4 ++++ src/info.h | 4 ++++ src/p_mobj.c | 20 ++++++++++++++++++-- src/p_user.c | 17 ++++++++++++++--- 6 files changed, 44 insertions(+), 5 deletions(-) diff --git a/src/d_player.h b/src/d_player.h index 0e4c5ec51..4a5d0e702 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -165,6 +165,7 @@ typedef enum PA_EDGE, PA_WALK, PA_RUN, + PA_PEEL, PA_PAIN, PA_ROLL, PA_SPRING, diff --git a/src/dehacked.c b/src/dehacked.c index 37584c6e1..57496d20c 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -3794,6 +3794,7 @@ static const char *const STATE_LIST[] = { // array length left dynamic for sanit "S_PLAY_WAIT", "S_PLAY_WALK", "S_PLAY_RUN", + "S_PLAY_PEEL", "S_PLAY_PAIN", "S_PLAY_DEAD", "S_PLAY_DRWN", @@ -3819,6 +3820,7 @@ static const char *const STATE_LIST[] = { // array length left dynamic for sanit "S_PLAY_SUPER_STND", "S_PLAY_SUPER_WALK", "S_PLAY_SUPER_RUN", + "S_PLAY_SUPER_PEEL", "S_PLAY_SUPER_PAIN", "S_PLAY_SUPER_STUN", "S_PLAY_SUPER_DEAD", @@ -7188,6 +7190,7 @@ struct { {"PA_EDGE",PA_EDGE}, {"PA_WALK",PA_WALK}, {"PA_RUN",PA_RUN}, + {"PA_PEEL",PA_PEEL}, {"PA_PAIN",PA_PAIN}, {"PA_ROLL",PA_ROLL}, {"PA_SPRING",PA_SPRING}, diff --git a/src/info.c b/src/info.c index dc71ad163..8eec24818 100644 --- a/src/info.c +++ b/src/info.c @@ -62,6 +62,7 @@ char spr2names[NUMPLAYERSPRITES][5] = "WAIT", "WALK", "RUN_", + "PEEL", "PAIN", "DEAD", "DRWN", @@ -88,6 +89,7 @@ char spr2names[NUMPLAYERSPRITES][5] = "SSTD", "SWLK", "SRUN", + "SPEE", "SPAN", "SMSL", "SDTH", @@ -132,6 +134,7 @@ state_t states[NUMSTATES] = {SPR_PLAY, SPR2_WAIT, 16, {NULL}, 0, 0, S_PLAY_WAIT}, // S_PLAY_WAIT {SPR_PLAY, SPR2_WALK, 4, {NULL}, 0, 0, S_PLAY_WALK}, // S_PLAY_WALK {SPR_PLAY, SPR2_RUN , 2, {NULL}, 0, 0, S_PLAY_RUN}, // S_PLAY_RUN + {SPR_PLAY, SPR2_PEEL, 2, {NULL}, 0, 0, S_PLAY_PEEL}, // S_PLAY_PEEL {SPR_PLAY, SPR2_PAIN, 350, {NULL}, 0, 0, S_PLAY_FALL}, // S_PLAY_PAIN {SPR_PLAY, SPR2_DEAD, 4, {NULL}, 0, 0, S_PLAY_DEAD}, // S_PLAY_DEAD {SPR_PLAY, SPR2_DRWN, 4, {NULL}, 0, 0, S_PLAY_DRWN}, // S_PLAY_DRWN @@ -157,6 +160,7 @@ state_t states[NUMSTATES] = {SPR_PLAY, SPR2_SSTD, 7, {NULL}, 0, 0, S_PLAY_SUPER_STND}, // S_PLAY_SUPER_STND {SPR_PLAY, SPR2_SWLK, 7, {NULL}, 0, 0, S_PLAY_SUPER_WALK}, // S_PLAY_SUPER_WALK {SPR_PLAY, SPR2_SRUN, 7, {NULL}, 0, 0, S_PLAY_SUPER_RUN}, // S_PLAY_SUPER_RUN + {SPR_PLAY, SPR2_SPEE, 7, {NULL}, 0, 0, S_PLAY_SUPER_PEEL}, // S_PLAY_SUPER_PEEL {SPR_PLAY, SPR2_SPAN, -1, {NULL}, 0, 0, S_PLAY_SUPER_STND}, // S_PLAY_SUPER_PAIN {SPR_PLAY, SPR2_SMSL, -1, {NULL}, 0, 0, S_PLAY_SUPER_STND}, // S_PLAY_SUPER_STUN {SPR_PLAY, SPR2_SDTH, 4, {NULL}, 0, 0, S_PLAY_SUPER_DEAD}, // S_PLAY_SUPER_DEAD diff --git a/src/info.h b/src/info.h index 46fdde46b..46b76096b 100644 --- a/src/info.h +++ b/src/info.h @@ -581,6 +581,7 @@ enum playersprite SPR2_WAIT, SPR2_WALK, SPR2_RUN , + SPR2_PEEL, SPR2_PAIN, SPR2_DEAD, SPR2_DRWN, @@ -607,6 +608,7 @@ enum playersprite SPR2_SSTD, SPR2_SWLK, SPR2_SRUN, + SPR2_SPEE, SPR2_SPAN, SPR2_SMSL, SPR2_SDTH, @@ -645,6 +647,7 @@ typedef enum state S_PLAY_WAIT, S_PLAY_WALK, S_PLAY_RUN, + S_PLAY_PEEL, S_PLAY_PAIN, S_PLAY_DEAD, S_PLAY_DRWN, @@ -670,6 +673,7 @@ typedef enum state S_PLAY_SUPER_STND, S_PLAY_SUPER_WALK, S_PLAY_SUPER_RUN, + S_PLAY_SUPER_PEEL, S_PLAY_SUPER_PAIN, S_PLAY_SUPER_STUN, S_PLAY_SUPER_DEAD, diff --git a/src/p_mobj.c b/src/p_mobj.c index 5fb3c81d7..bffa796dd 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -175,6 +175,8 @@ boolean P_SetPlayerMobjState(mobj_t *mobj, statenum_t state) return P_SetPlayerMobjState(mobj, S_PLAY_SUPER_WALK); case S_PLAY_RUN: return P_SetPlayerMobjState(mobj, S_PLAY_SUPER_RUN); + case S_PLAY_PEEL: + return P_SetPlayerMobjState(mobj, S_PLAY_SUPER_PEEL); case S_PLAY_PAIN: return P_SetPlayerMobjState(mobj, S_PLAY_SUPER_PAIN); case S_PLAY_DEAD: @@ -231,6 +233,10 @@ boolean P_SetPlayerMobjState(mobj_t *mobj, statenum_t state) case S_PLAY_SUPER_RUN: player->panim = PA_RUN; break; + case S_PLAY_PEEL: + case S_PLAY_SUPER_PEEL: + player->panim = PA_PEEL; + break; case S_PLAY_PAIN: case S_PLAY_SUPER_PAIN: case S_PLAY_SUPER_STUN: @@ -316,7 +322,7 @@ boolean P_SetPlayerMobjState(mobj_t *mobj, statenum_t state) else mobj->tics = 4; } - else if (player->panim == PA_RUN) + else if ((player->panim == PA_RUN) || (player->panim == PA_PEEL)) { if (speed > 52<tics = 1; @@ -339,6 +345,9 @@ boolean P_SetPlayerMobjState(mobj_t *mobj, statenum_t state) { switch(spr2) { + case SPR2_PEEL: + spr2 = SPR2_RUN; + break; case SPR2_RUN: spr2 = SPR2_WALK; break; @@ -393,6 +402,9 @@ boolean P_SetPlayerMobjState(mobj_t *mobj, statenum_t state) case SPR2_SRUN: spr2 = SPR2_RUN; break; + case SPR2_SPEE: + spr2 = SPR2_PEEL; + break; case SPR2_SPAN: spr2 = SPR2_PAIN; break; @@ -2955,7 +2967,9 @@ static void P_PlayerZMovement(mobj_t *mo) { if (mo->player->cmomx || mo->player->cmomy) { - if (mo->player->speed >= FixedMul(mo->player->runspeed, mo->scale) && mo->player->panim != PA_RUN) + if (mo->player->dashmode >= 3*TICRATE && mo->player->panim != PA_PEEL) + P_SetPlayerMobjState(mo, S_PLAY_PEEL); + else if (mo->player->speed >= FixedMul(mo->player->runspeed, mo->scale) && mo->player->panim != PA_RUN) P_SetPlayerMobjState(mo, S_PLAY_RUN); else if ((mo->player->rmomx || mo->player->rmomy) && (mo->player->panim != PA_WALK || mo->state-states == S_PLAY_SUPER_FLOAT)) P_SetPlayerMobjState(mo, S_PLAY_WALK); @@ -2964,6 +2978,8 @@ static void P_PlayerZMovement(mobj_t *mo) } else { + if (mo->player->dashmode >= 3*TICRATE && mo->player->panim != PA_PEEL) + P_SetPlayerMobjState(mo, S_PLAY_PEEL); if (mo->player->speed >= FixedMul(mo->player->runspeed, mo->scale) && mo->player->panim != PA_RUN) P_SetPlayerMobjState(mo, S_PLAY_RUN); else if ((mo->momx || mo->momy) && (mo->player->panim != PA_WALK || mo->state-states == S_PLAY_SUPER_FLOAT)) diff --git a/src/p_user.c b/src/p_user.c index 6b57bb7a9..0eef60b13 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3501,6 +3501,9 @@ static void P_DoSuperStuff(player_t *player) case S_PLAY_SUPER_RUN: P_SetPlayerMobjState(player->mo, S_PLAY_RUN); break; + case S_PLAY_SUPER_PEEL: + P_SetPlayerMobjState(player->mo, S_PLAY_PEEL); + break; case S_PLAY_SUPER_PAIN: P_SetPlayerMobjState(player->mo, S_PLAY_PAIN); break; @@ -6507,9 +6510,12 @@ static void P_MovePlayer(player_t *player) if ((cmd->forwardmove != 0 || cmd->sidemove != 0) || (player->powers[pw_super] && !onground)) { + // If the player is in dashmode, here's their peelout. + if (player->charability == CA_DASHMODE && player->dashmode >= 3*TICRATE && player->panim == PA_RUN && !player->skidtime && (onground || player->powers[pw_super])) + P_SetPlayerMobjState (player->mo, S_PLAY_PEEL); // If the player is moving fast enough, // break into a run! - if (player->speed >= runspd && player->panim == PA_WALK && !player->skidtime && (onground || player->powers[pw_super])) + else if (player->speed >= runspd && player->panim == PA_WALK && !player->skidtime && (onground || player->powers[pw_super])) P_SetPlayerMobjState (player->mo, S_PLAY_RUN); // Super floating at slow speeds has its own special animation. @@ -6521,6 +6527,11 @@ static void P_MovePlayer(player_t *player) P_SetPlayerMobjState (player->mo, S_PLAY_WALK); } + // If your peelout animation is playing, and you're + // going too slow, switch back to the run. + if (player->panim == PA_PEEL && player->dashmode < 3*TICRATE) + P_SetPlayerMobjState(player->mo, S_PLAY_RUN); + // If your running animation is playing, and you're // going too slow, switch back to the walking frames. if (player->panim == PA_RUN && player->speed < runspd) @@ -6851,7 +6862,7 @@ static void P_MovePlayer(player_t *player) #endif } // Otherwise, face the direction you're travelling. - else if (player->panim == PA_WALK || player->panim == PA_RUN || player->panim == PA_ROLL + else if (player->panim == PA_WALK || player->panim == PA_RUN || player->panim == PA_PEEL || player->panim == PA_ROLL || (player->mo->state-states == S_PLAY_FLY || player->mo->state-states == S_PLAY_FLY_TIRED)) player->mo->angle = R_PointToAngle2(0, 0, player->rmomx, player->rmomy); @@ -9173,7 +9184,7 @@ void P_PlayerThink(player_t *player) // Dash mode ability for Metal Sonic if ((player->charability == CA_DASHMODE) && !(maptol & TOL_NIGHTS)) // woo, dashmode! no nights tho. { - if (player->speed >= FixedMul(skins[player->skin].normalspeed - 5*FRACUNIT, player->mo->scale) || (player->pflags & PF_STARTDASH)) + if (player->speed >= FixedMul(player->runspeed, player->mo->scale) || (player->pflags & PF_STARTDASH)) { dashmode++; // Counter. Adds 1 to dash mode per tic in top speed. if (dashmode == 3*TICRATE) // This isn't in the ">=" equation because it'd cause the sound to play infinitely. From 625cb39af74057329478fb635be870e99e16b120 Mon Sep 17 00:00:00 2001 From: toasterbabe Date: Sat, 9 Jul 2016 16:53:41 +0100 Subject: [PATCH 71/71] Dashmode now destroys spikes and monitors on contact. Enemies? Probably not for now. --- src/p_map.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/p_map.c b/src/p_map.c index 668ba19c2..6ad475099 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -448,6 +448,35 @@ static boolean PIT_CheckThing(mobj_t *thing) return true; } + // Dashmode users destroy spikes and monitors. + if ((tmthing->player) && (tmthing->player->charability == CA_DASHMODE) && (tmthing->player->dashmode >= 3*TICRATE) + && (thing->flags & (MF_MONITOR) || thing->type == MT_SPIKE)) + { + if ((thing->flags & (MF_MONITOR)) && (thing->health <= 0 || !(thing->flags & MF_SHOOTABLE))) + return true; + blockdist = thing->radius + tmthing->radius; + if (abs(thing->x - tmx) >= blockdist || abs(thing->y - tmy) >= blockdist) + return true; // didn't hit it + // see if it went over / under + if (tmthing->z > thing->z + thing->height) + return true; // overhead + if (tmthing->z + tmthing->height < thing->z) + return true; // underneath + if (thing->type == MT_SPIKE) + { + S_StartSound(tmthing, thing->info->deathsound); + for (thing = thing->subsector->sector->thinglist; thing; thing = thing->snext) + if (thing->type == MT_SPIKE && thing->health > 0 && thing->flags & MF_SOLID && P_AproxDistance(thing->x - tmthing->x, thing->y - tmthing->y) < FixedMul(56*FRACUNIT, thing->scale)) + P_KillMobj(thing, tmthing, tmthing, 0); + } + else + { + thing->health = 0; + P_KillMobj(thing, tmthing, tmthing, 0); + } + return true; + } + if (!(thing->flags & (MF_SOLID|MF_SPECIAL|MF_PAIN|MF_SHOOTABLE))) return true;