From 3bc56a91b261d69b0f9bbba84e8af5f6922e3117 Mon Sep 17 00:00:00 2001 From: Yukita Mayako Date: Fri, 29 May 2015 04:34:53 -0400 Subject: [PATCH 1/6] Hotfix for platform movement being dropped on players. Now players will apply platform movement when jumping, but only if the platform is moving the same direction as their jump is, and all other objects will have an appropriate pmomz in reverse gravity FOF situations. --- src/p_map.c | 6 +++++- src/p_mobj.c | 49 ++++++++++--------------------------------------- src/p_user.c | 12 +++++++++--- 3 files changed, 24 insertions(+), 43 deletions(-) diff --git a/src/p_map.c b/src/p_map.c index 62cbf7b77..4b2ea52cc 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -2047,6 +2047,7 @@ boolean P_SceneryTryMove(mobj_t *thing, fixed_t x, fixed_t y) // static boolean P_ThingHeightClip(mobj_t *thing) { + boolean floormoved; fixed_t oldfloorz = thing->floorz; boolean onfloor = P_IsObjectOnGround(thing);//(thing->z <= thing->floorz); @@ -2058,6 +2059,9 @@ static boolean P_ThingHeightClip(mobj_t *thing) if (P_MobjWasRemoved(thing)) return true; + floormoved = (thing->eflags & MFE_VERTICALFLIP && tmceilingz != thing->ceilingz) + || (!(thing->eflags & MFE_VERTICALFLIP) && tmfloorz != thing->floorz); + thing->floorz = tmfloorz; thing->ceilingz = tmceilingz; @@ -2066,7 +2070,7 @@ static boolean P_ThingHeightClip(mobj_t *thing) if (tmfloorz > oldfloorz+thing->height) return true; - if (/*!tmfloorthing && */onfloor && !(thing->flags & MF_NOGRAVITY)) + if (onfloor && !(thing->flags & MF_NOGRAVITY) && floormoved) { if (thing->eflags & MFE_VERTICALFLIP) thing->pmomz = thing->ceilingz - (thing->z + thing->height); diff --git a/src/p_mobj.c b/src/p_mobj.c index cac4bc24b..f1fc6bb78 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -1986,12 +1986,8 @@ static void P_PlayerZMovement(mobj_t *mo) (FixedMul(cv_viewheight.value<scale) - mo->player->viewheight)>>3; } - // adjust height -/* if (mo->pmomz && mo->z > mo->floorz && !(mo->player->pflags & PF_JUMPED)) - { - mo->momz += mo->pmomz; + if (mo->pmomz && mo->z > mo->floorz) mo->pmomz = 0; - }*/ mo->z += mo->momz; @@ -2899,6 +2895,7 @@ static void P_PlayerMobjThinker(mobj_t *mobj) msecnode_t *node; I_Assert(mobj != NULL); + I_Assert(mobj->player != NULL); I_Assert(!P_MobjWasRemoved(mobj)); P_MobjCheckWater(mobj); @@ -2917,7 +2914,7 @@ static void P_PlayerMobjThinker(mobj_t *mobj) P_CheckPosition(mobj, mobj->x, mobj->y); goto animonly; } - else if (mobj->player && (mobj->player->pflags & PF_MACESPIN) && mobj->tracer) + else if (mobj->player->pflags & PF_MACESPIN && mobj->tracer) { P_CheckPosition(mobj, mobj->x, mobj->y); goto animonly; @@ -2936,7 +2933,7 @@ static void P_PlayerMobjThinker(mobj_t *mobj) else P_TryMove(mobj, mobj->x, mobj->y, true); - if (!(netgame && mobj->player && mobj->player->spectator)) + if (!(netgame && mobj->player->spectator)) { // Crumbling platforms for (node = mobj->touching_sectorlist; node; node = node->m_snext) @@ -3019,18 +3016,14 @@ static void P_PlayerMobjThinker(mobj_t *mobj) } else { - if (mobj->player) + mobj->player->jumping = 0; + mobj->player->pflags &= ~PF_JUMPED; + if (mobj->player->secondjump || mobj->player->powers[pw_tailsfly]) { - mobj->player->jumping = 0; - mobj->player->pflags &= ~PF_JUMPED; - if (mobj->player->secondjump || mobj->player->powers[pw_tailsfly]) - { - mobj->player->secondjump = 0; - mobj->player->powers[pw_tailsfly] = 0; - P_SetPlayerMobjState(mobj, S_PLAY_RUN1); - } + mobj->player->secondjump = 0; + mobj->player->powers[pw_tailsfly] = 0; + P_SetPlayerMobjState(mobj, S_PLAY_RUN1); } - mobj->pmomz = 0; mobj->eflags &= ~MFE_JUSTHITFLOOR; } @@ -6643,17 +6636,6 @@ for (i = ((mobj->flags2 & MF2_STRONGBOX) ? strongboxamt : weakboxamt); i; --i) s } else { - if (mobj->player) - { - mobj->player->jumping = 0; - mobj->player->pflags &= ~PF_JUMPED; - if (mobj->player->secondjump || mobj->player->powers[pw_tailsfly]) - { - mobj->player->secondjump = 0; - mobj->player->powers[pw_tailsfly] = 0; - P_SetPlayerMobjState(mobj, S_PLAY_RUN1); - } - } mobj->pmomz = 0; // to prevent that weird rocketing gargoyle bug mobj->eflags &= ~MFE_JUSTHITFLOOR; } @@ -6854,17 +6836,6 @@ void P_SceneryThinker(mobj_t *mobj) } else { - if (mobj->player) - { - mobj->player->jumping = 0; - mobj->player->pflags &= ~PF_JUMPED; - if (mobj->player->secondjump || mobj->player->powers[pw_tailsfly]) - { - mobj->player->secondjump = 0; - mobj->player->powers[pw_tailsfly] = 0; - P_SetPlayerMobjState(mobj, S_PLAY_RUN1); - } - } mobj->pmomz = 0; // to prevent that weird rocketing gargoyle bug mobj->eflags &= ~MFE_JUSTHITFLOOR; } diff --git a/src/p_user.c b/src/p_user.c index 6844d2cba..c5c5ab73b 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3619,11 +3619,18 @@ void P_DoJump(player_t *player, boolean soundandstate) // set just an eensy above the ground if (player->mo->eflags & MFE_VERTICALFLIP) + { player->mo->z--; + if (player->mo->pmomz < 0) + player->mo->momz += player->mo->pmomz; // Add the platform's momentum to your jump. + } else + { player->mo->z++; - - player->mo->z += player->mo->pmomz; // Solves problem of 'hitting around again after jumping on a moving platform'. + if (player->mo->pmomz > 0) + player->mo->momz += player->mo->pmomz; // Add the platform's momentum to your jump. + } + player->mo->pmomz = 0; player->pflags |= PF_JUMPED; @@ -9028,7 +9035,6 @@ void P_PlayerThink(player_t *player) player->mo->tracer->flags2 &= ~MF2_DONTDRAW; } - player->mo->pmomz = 0; player->pflags &= ~PF_SLIDING; /* From 213a0caa23f3651a50e30262af256c4d45cada52 Mon Sep 17 00:00:00 2001 From: Yukita Mayako Date: Fri, 29 May 2015 05:47:01 -0400 Subject: [PATCH 2/6] Hotfix amendment Also gain velocity from walking off an "up" elevator normally? This _looks_ incorrect because the camera stops matching the platform movement the moment you step off, but I assure you it is a correct and accurate movement. (Try it with chasecam off.) --- src/p_mobj.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index f1fc6bb78..4796e18b0 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -1986,8 +1986,14 @@ static void P_PlayerZMovement(mobj_t *mo) (FixedMul(cv_viewheight.value<scale) - mo->player->viewheight)>>3; } - if (mo->pmomz && mo->z > mo->floorz) + // adjust height + if (mo->pmomz && !P_IsObjectOnGround(mo)) + { + if ((mo->eflags & MFE_VERTICALFLIP && mo->pmomz < 0) + || (!(mo->eflags & MFE_VERTICALFLIP) && mo->pmomz > 0)) + mo->momz += mo->pmomz; mo->pmomz = 0; + } mo->z += mo->momz; From a1c67e7e67c10b5825cc8df23c90ad27cdcb2d36 Mon Sep 17 00:00:00 2001 From: Yukita Mayako Date: Fri, 29 May 2015 13:53:06 -0400 Subject: [PATCH 3/6] Add MFE_APPLYPMOMZ to fix camera movement. Here's how it works: When a player walks off the moving platform, it applies their pmomz once, and then _keeps pmomz set_ so that the camera still adds pmomz to its movements until they hit another floor. This way, the camera doesn't jerk around. --- src/dehacked.c | 4 +-- src/lua_mobjlib.c | 1 + src/p_map.c | 9 +------ src/p_mobj.c | 62 +++++++++++++++++++++++------------------------ src/p_mobj.h | 3 ++- src/p_user.c | 6 ++++- 6 files changed, 42 insertions(+), 43 deletions(-) diff --git a/src/dehacked.c b/src/dehacked.c index a332da5df..3b463f7f2 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -7193,7 +7193,7 @@ static const char *const MOBJFLAG2_LIST[] = { NULL }; -static const char *const MOBJEFLAG_LIST[] = { +static const char *const MOBJEFLAG_LIST[8] = { "ONGROUND", // The mobj stands on solid floor (not on another mobj or in air) "JUSTHITFLOOR", // The mobj just hit the floor while falling, this is cleared on next frame "TOUCHWATER", // The mobj stands in a sector with water, and touches the surface @@ -7201,7 +7201,7 @@ static const char *const MOBJEFLAG_LIST[] = { "JUSTSTEPPEDDOWN", // used for ramp sectors "VERTICALFLIP", // Vertically flip sprite/allow upside-down physics "GOOWATER", // Goo water - NULL + "APPLYPMOMZ" // Platform movement }; static const char *const MAPTHINGFLAG_LIST[4] = { diff --git a/src/lua_mobjlib.c b/src/lua_mobjlib.c index f455edf1f..b5bf25d82 100644 --- a/src/lua_mobjlib.c +++ b/src/lua_mobjlib.c @@ -449,6 +449,7 @@ static int mobj_set(lua_State *L) break; case mobj_pmomz: mo->pmomz = (fixed_t)luaL_checkinteger(L, 3); + mo->eflags |= MFE_APPLYPMOMZ; break; case mobj_tics: mo->tics = luaL_checkinteger(L, 3); diff --git a/src/p_map.c b/src/p_map.c index 4b2ea52cc..ca11ae2e1 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -2076,14 +2076,7 @@ static boolean P_ThingHeightClip(mobj_t *thing) thing->pmomz = thing->ceilingz - (thing->z + thing->height); else thing->pmomz = thing->floorz - thing->z; - - if (thing->player) - { - if (splitscreen && camera2.chase && thing->player == &players[secondarydisplayplayer]) - camera2.z += thing->pmomz; - else if (camera.chase && thing->player == &players[displayplayer]) - camera.z += thing->pmomz; - } + thing->eflags |= MFE_APPLYPMOMZ; if (thing->eflags & MFE_VERTICALFLIP) thing->z = thing->ceilingz - thing->height; diff --git a/src/p_mobj.c b/src/p_mobj.c index 4796e18b0..bbd5d3fe1 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -1493,12 +1493,13 @@ static void P_RingZMovement(mobj_t *mo) P_AdjustMobjFloorZ_PolyObjs(mo, mo->subsector); // adjust height - if (mo->pmomz && mo->z != mo->floorz) + mo->z += mo->momz; + + if (mo->eflags & MFE_APPLYPMOMZ && !P_IsObjectOnGround(mo)) { mo->momz += mo->pmomz; - mo->pmomz = 0; + mo->eflags &= ~MFE_APPLYPMOMZ; } - mo->z += mo->momz; // clip movement if (mo->z <= mo->floorz && !(mo->flags & MF_NOCLIPHEIGHT)) @@ -1562,12 +1563,13 @@ static boolean P_ZMovement(mobj_t *mo) P_AdjustMobjFloorZ_PolyObjs(mo, mo->subsector); // adjust height - if (mo->pmomz && mo->z != mo->floorz) + mo->z += mo->momz; + + if (mo->eflags & MFE_APPLYPMOMZ && !P_IsObjectOnGround(mo)) { mo->momz += mo->pmomz; - mo->pmomz = 0; + mo->eflags &= ~MFE_APPLYPMOMZ; } - mo->z += mo->momz; switch (mo->type) { @@ -1987,16 +1989,14 @@ static void P_PlayerZMovement(mobj_t *mo) } // adjust height - if (mo->pmomz && !P_IsObjectOnGround(mo)) - { - if ((mo->eflags & MFE_VERTICALFLIP && mo->pmomz < 0) - || (!(mo->eflags & MFE_VERTICALFLIP) && mo->pmomz > 0)) - mo->momz += mo->pmomz; - mo->pmomz = 0; - } - mo->z += mo->momz; + if (mo->eflags & MFE_APPLYPMOMZ && !P_IsObjectOnGround(mo)) + { + mo->momz += mo->pmomz; + mo->eflags &= ~MFE_APPLYPMOMZ; + } + // Have player fall through floor? if (mo->player->playerstate == PST_DEAD || mo->player->playerstate == PST_REBORN) @@ -2010,7 +2010,7 @@ static void P_PlayerZMovement(mobj_t *mo) else mo->z = mo->floorz; - if (mo->player && (mo->player->pflags & PF_NIGHTSMODE)) + if (mo->player->pflags & PF_NIGHTSMODE) { if (mo->player->flyangle < 90 || mo->player->flyangle >= 270) mo->player->flyangle += P_MobjFlip(mo)*90; @@ -2025,12 +2025,11 @@ static void P_PlayerZMovement(mobj_t *mo) if (P_MobjFlip(mo)*mo->momz < 0) // falling { + mo->pmomz = 0; // We're on a new floor, don't keep doing platform movement. + // Squat down. Decrease viewheight for a moment after hitting the ground (hard), - if (mo->player) - { - if (P_MobjFlip(mo)*mo->momz < -FixedMul(8*FRACUNIT, mo->scale)) - mo->player->deltaviewheight = (P_MobjFlip(mo)*mo->momz)>>3; // make sure momz is negative - } + if (P_MobjFlip(mo)*mo->momz < -FixedMul(8*FRACUNIT, mo->scale)) + mo->player->deltaviewheight = (P_MobjFlip(mo)*mo->momz)>>3; // make sure momz is negative if (!tmfloorthing || tmfloorthing->flags & (MF_PUSHABLE|MF_MONITOR) || tmfloorthing->flags2 & MF2_STANDONME || tmfloorthing->type == MT_PLAYER) // Spin Attack @@ -2103,14 +2102,14 @@ static void P_PlayerZMovement(mobj_t *mo) // Cut momentum in half when you hit the ground and // aren't pressing any controls. - if (!mo->player || (!(mo->player->cmd.forwardmove || mo->player->cmd.sidemove) && !mo->player->cmomx && !mo->player->cmomy && !(mo->player->pflags & PF_SPINNING))) + if (!(mo->player->cmd.forwardmove || mo->player->cmd.sidemove) && !mo->player->cmomx && !mo->player->cmomy && !(mo->player->pflags & PF_SPINNING)) { mo->momx = mo->momx/2; mo->momy = mo->momy/2; } } - if (mo->health && mo->player) + if (mo->health) { if (mo->player->pflags & PF_GLIDING) // ground gliding { @@ -2156,7 +2155,7 @@ static void P_PlayerZMovement(mobj_t *mo) mo->player->powers[pw_tailsfly] = 0; } } - if (mo->player && !(mo->player->pflags & PF_SPINNING)) + if (!(mo->player->pflags & PF_SPINNING)) mo->player->pflags &= ~PF_STARTDASH; if (tmfloorthing && (tmfloorthing->flags & (MF_PUSHABLE|MF_MONITOR) @@ -2199,7 +2198,7 @@ nightsdone: else mo->z = mo->ceilingz - mo->height; - if (mo->player && (mo->player->pflags & PF_NIGHTSMODE)) + if (mo->player->pflags & PF_NIGHTSMODE) { if (mo->player->flyangle < 90 || mo->player->flyangle >= 270) mo->player->flyangle -= P_MobjFlip(mo)*90; @@ -2214,7 +2213,7 @@ nightsdone: { msecnode_t *node; - if (CheckForMarioBlocks && mo->player && !(netgame && mo->player->spectator)) // Only let the player punch + 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) @@ -2242,7 +2241,7 @@ nightsdone: if (mariomode) S_StartSound(mo, sfx_mario1); - if (!(mo->player && mo->player->climbing)) + if (!mo->player->climbing) mo->momz = 0; } } @@ -2257,12 +2256,13 @@ static boolean P_SceneryZMovement(mobj_t *mo) P_AdjustMobjFloorZ_PolyObjs(mo, mo->subsector); // adjust height - if (mo->pmomz && mo->z != mo->floorz) + mo->z += mo->momz; + + if (mo->eflags & MFE_APPLYPMOMZ && !P_IsObjectOnGround(mo)) { mo->momz += mo->pmomz; - mo->pmomz = 0; + mo->eflags &= ~MFE_APPLYPMOMZ; } - mo->z += mo->momz; switch (mo->type) { @@ -2840,10 +2840,10 @@ boolean P_CameraThinker(player_t *player, camera_t *thiscam, boolean resetcalled thiscam->floorz = tmfloorz; thiscam->ceilingz = tmceilingz; - if (thiscam->momz) + if (thiscam->momz || player->mo->pmomz) { // adjust height - thiscam->z += thiscam->momz; + thiscam->z += thiscam->momz + player->mo->pmomz; if (!itsatwodlevel && !(player->pflags & PF_NOCLIP)) { diff --git a/src/p_mobj.h b/src/p_mobj.h index 6d120c473..c07b96211 100644 --- a/src/p_mobj.h +++ b/src/p_mobj.h @@ -232,7 +232,8 @@ typedef enum MFE_VERTICALFLIP = 1<<5, // Goo water MFE_GOOWATER = 1<<6, - // free: to and including 1<<7 + // Platform movement + MFE_APPLYPMOMZ = 1<<7 } mobjeflag_t; // diff --git a/src/p_user.c b/src/p_user.c index c5c5ab73b..d6fc5b35a 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3623,14 +3623,18 @@ void P_DoJump(player_t *player, boolean soundandstate) player->mo->z--; if (player->mo->pmomz < 0) player->mo->momz += player->mo->pmomz; // Add the platform's momentum to your jump. + else + player->mo->pmomz = 0; } else { player->mo->z++; if (player->mo->pmomz > 0) player->mo->momz += player->mo->pmomz; // Add the platform's momentum to your jump. + else + player->mo->pmomz = 0; } - player->mo->pmomz = 0; + player->mo->eflags &= ~MFE_APPLYPMOMZ; player->pflags |= PF_JUMPED; From c16516ef0db316f9469f1e1d4ca6a94f238d8ee1 Mon Sep 17 00:00:00 2001 From: Yukita Mayako Date: Fri, 29 May 2015 17:22:31 -0400 Subject: [PATCH 4/6] Partial revert. This partially reverts commit a1c67e7e67c10b5825cc8df23c90ad27cdcb2d36. --- src/dehacked.c | 2 +- src/p_mobj.c | 13 +++++-------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/dehacked.c b/src/dehacked.c index 3b463f7f2..b3bbc343b 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -7193,7 +7193,7 @@ static const char *const MOBJFLAG2_LIST[] = { NULL }; -static const char *const MOBJEFLAG_LIST[8] = { +static const char *const MOBJEFLAG_LIST[] = { "ONGROUND", // The mobj stands on solid floor (not on another mobj or in air) "JUSTHITFLOOR", // The mobj just hit the floor while falling, this is cleared on next frame "TOUCHWATER", // The mobj stands in a sector with water, and touches the surface diff --git a/src/p_mobj.c b/src/p_mobj.c index bbd5d3fe1..e7e7b8678 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -1493,13 +1493,12 @@ static void P_RingZMovement(mobj_t *mo) P_AdjustMobjFloorZ_PolyObjs(mo, mo->subsector); // adjust height - mo->z += mo->momz; - if (mo->eflags & MFE_APPLYPMOMZ && !P_IsObjectOnGround(mo)) { mo->momz += mo->pmomz; mo->eflags &= ~MFE_APPLYPMOMZ; } + mo->z += mo->momz; // clip movement if (mo->z <= mo->floorz && !(mo->flags & MF_NOCLIPHEIGHT)) @@ -1563,13 +1562,12 @@ static boolean P_ZMovement(mobj_t *mo) P_AdjustMobjFloorZ_PolyObjs(mo, mo->subsector); // adjust height - mo->z += mo->momz; - if (mo->eflags & MFE_APPLYPMOMZ && !P_IsObjectOnGround(mo)) { mo->momz += mo->pmomz; mo->eflags &= ~MFE_APPLYPMOMZ; } + mo->z += mo->momz; switch (mo->type) { @@ -1989,14 +1987,14 @@ static void P_PlayerZMovement(mobj_t *mo) } // adjust height - mo->z += mo->momz; - if (mo->eflags & MFE_APPLYPMOMZ && !P_IsObjectOnGround(mo)) { mo->momz += mo->pmomz; mo->eflags &= ~MFE_APPLYPMOMZ; } + mo->z += mo->momz; + // Have player fall through floor? if (mo->player->playerstate == PST_DEAD || mo->player->playerstate == PST_REBORN) @@ -2256,13 +2254,12 @@ static boolean P_SceneryZMovement(mobj_t *mo) P_AdjustMobjFloorZ_PolyObjs(mo, mo->subsector); // adjust height - mo->z += mo->momz; - if (mo->eflags & MFE_APPLYPMOMZ && !P_IsObjectOnGround(mo)) { mo->momz += mo->pmomz; mo->eflags &= ~MFE_APPLYPMOMZ; } + mo->z += mo->momz; switch (mo->type) { From 9a9025b1ee3a3396d9a4e82749e4a6b96876e54a Mon Sep 17 00:00:00 2001 From: Yukita Mayako Date: Tue, 9 Jun 2015 06:59:34 -0400 Subject: [PATCH 5/6] Remove pmomz from players who are on ground. Assume that every frame the player is on the ground, their pmomz will be re-set properly if the floor is moving, therefore if the platform STOPS, we need this to set it to 0. --- src/p_user.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/p_user.c b/src/p_user.c index d6fc5b35a..ce6e2b732 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -9391,4 +9391,7 @@ void P_PlayerAfterThink(player_t *player) player->mo->flags2 |= MF2_DONTDRAW; player->mo->flags |= MF_NOGRAVITY; } + + if (P_IsObjectOnGround(player->mo)) + player->mo->pmomz = 0; } From 36cf4c1bd25452e8e1e2fa8c49097329c6994702 Mon Sep 17 00:00:00 2001 From: Yukita Mayako Date: Tue, 9 Jun 2015 19:51:33 -0400 Subject: [PATCH 6/6] Fix comma error. --- src/dehacked.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dehacked.c b/src/dehacked.c index 5f1f89ec2..376826149 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -7204,7 +7204,7 @@ static const char *const MOBJEFLAG_LIST[] = { "GOOWATER", // Goo water "PUSHED", // Mobj was already pushed this tic "SPRUNG", // Mobj was already sprung this tic - "APPLYPMOMZ" // Platform movement + "APPLYPMOMZ", // Platform movement NULL };