From 81d162d19c75258ea22a3ec6185e713d63eea4d5 Mon Sep 17 00:00:00 2001 From: James R Date: Tue, 16 Feb 2021 04:42:27 -0800 Subject: [PATCH] Add some helper functions for objects in reverse gravity --- src/p_local.h | 4 ++++ src/p_mobj.c | 25 +++++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/src/p_local.h b/src/p_local.h index a6622b5c1..90408e011 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -158,6 +158,7 @@ boolean P_IsObjectInGoop(mobj_t *mo); boolean P_IsObjectOnGround(mobj_t *mo); boolean P_IsObjectOnGroundIn(mobj_t *mo, sector_t *sec); boolean P_IsObjectOnRealGround(mobj_t *mo, sector_t *sec); // SRB2Kart +#define P_IsObjectFlipped(o) ((o)->eflags & MFE_VERTICALFLIP) boolean P_InQuicksand(mobj_t *mo); boolean P_PlayerHitFloor(player_t *player, boolean dorollstuff); @@ -522,5 +523,8 @@ void P_ExplodeMissile(mobj_t *mo); void P_CheckGravity(mobj_t *mo, boolean affect); void P_SetPitchRollFromSlope(mobj_t *mo, pslope_t *slope); fixed_t P_ScaleFromMap(fixed_t, fixed_t scale); +fixed_t P_GetMobjHead(const mobj_t *); +fixed_t P_GetMobjFeet(const mobj_t *); +fixed_t P_GetMobjGround(const mobj_t *); #endif // __P_LOCAL__ diff --git a/src/p_mobj.c b/src/p_mobj.c index 5975da344..ae5179c44 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -12786,3 +12786,28 @@ mobj_t *P_SpawnMobjFromMobj(mobj_t *mobj, fixed_t xofs, fixed_t yofs, fixed_t zo return newmobj; } + +// +// P_GetMobjHead & P_GetMobjFeet +// Returns the top and bottom of an object, follows appearance, not physics, +// in reverse gravity. +// + +fixed_t P_GetMobjHead(const mobj_t *mobj) +{ + return P_IsObjectFlipped(mobj) ? mobj->z : mobj->z + mobj->height; +} + +fixed_t P_GetMobjFeet(const mobj_t *mobj) +{ + return P_IsObjectFlipped(mobj) ? mobj->z + mobj->height : mobj->z; +} + +// +// P_GetMobjGround +// Returns the object's floor, or ceiling in reverse gravity. +// +fixed_t P_GetMobjGround(const mobj_t *mobj) +{ + return P_IsObjectFlipped(mobj) ? mobj->ceilingz : mobj->floorz; +}