mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2026-04-27 20:41:46 +00:00
Add P_CheckMove
Checks if P_TryMove would succeed without actually moving. (cherry picked from commit 518de0ce104166c3eacd10ebe6ade422307ce671)
This commit is contained in:
parent
b17717babe
commit
ba1b6bb253
5 changed files with 75 additions and 9 deletions
|
|
@ -4506,6 +4506,7 @@ const char *const STATE_LIST[] = { // array length left dynamic for sanity testi
|
||||||
// because sadly no one remembers this place while searching for full state names.
|
// because sadly no one remembers this place while searching for full state names.
|
||||||
const char *const MOBJTYPE_LIST[] = { // array length left dynamic for sanity testing later.
|
const char *const MOBJTYPE_LIST[] = { // array length left dynamic for sanity testing later.
|
||||||
"MT_NULL",
|
"MT_NULL",
|
||||||
|
"MT_RAY",
|
||||||
"MT_UNKNOWN",
|
"MT_UNKNOWN",
|
||||||
|
|
||||||
"MT_THOK", // Thok! mobj
|
"MT_THOK", // Thok! mobj
|
||||||
|
|
|
||||||
27
src/info.c
27
src/info.c
|
|
@ -5120,6 +5120,33 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] =
|
||||||
S_NULL // raisestate
|
S_NULL // raisestate
|
||||||
},
|
},
|
||||||
|
|
||||||
|
{ // MT_RAY
|
||||||
|
-1, // doomednum
|
||||||
|
S_NULL, // spawnstate
|
||||||
|
0, // spawnhealth
|
||||||
|
S_NULL, // seestate
|
||||||
|
sfx_None, // seesound
|
||||||
|
0, // reactiontime
|
||||||
|
sfx_None, // attacksound
|
||||||
|
S_NULL, // painstate
|
||||||
|
0, // painchance
|
||||||
|
sfx_None, // painsound
|
||||||
|
S_NULL, // meleestate
|
||||||
|
S_NULL, // missilestate
|
||||||
|
S_NULL, // deathstate
|
||||||
|
S_NULL, // xdeathstate
|
||||||
|
sfx_None, // deathsound
|
||||||
|
0, // speed
|
||||||
|
0, // radius
|
||||||
|
0, // height
|
||||||
|
0, // display offset
|
||||||
|
0, // mass
|
||||||
|
0, // damage
|
||||||
|
sfx_None, // activesound
|
||||||
|
MF_NOBLOCKMAP|MF_NOSECTOR|MF_NOCLIP|MF_NOCLIPHEIGHT|MF_NOGRAVITY|MF_SCENERY, // flags
|
||||||
|
S_NULL // raisestate
|
||||||
|
},
|
||||||
|
|
||||||
{ // MT_UNKNOWN
|
{ // MT_UNKNOWN
|
||||||
-1, // doomednum
|
-1, // doomednum
|
||||||
S_UNKNOWN, // spawnstate
|
S_UNKNOWN, // spawnstate
|
||||||
|
|
|
||||||
|
|
@ -5532,6 +5532,7 @@ extern playersprite_t free_spr2;
|
||||||
typedef enum mobj_type
|
typedef enum mobj_type
|
||||||
{
|
{
|
||||||
MT_NULL,
|
MT_NULL,
|
||||||
|
MT_RAY, // General purpose mobj
|
||||||
MT_UNKNOWN,
|
MT_UNKNOWN,
|
||||||
|
|
||||||
MT_THOK, // Thok! mobj
|
MT_THOK, // Thok! mobj
|
||||||
|
|
|
||||||
|
|
@ -410,6 +410,7 @@ boolean P_IsLineBlocking(const line_t *ld, const mobj_t *thing);
|
||||||
boolean P_IsLineTripWire(const line_t *ld);
|
boolean P_IsLineTripWire(const line_t *ld);
|
||||||
boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y);
|
boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y);
|
||||||
boolean P_CheckCameraPosition(fixed_t x, fixed_t y, camera_t *thiscam);
|
boolean P_CheckCameraPosition(fixed_t x, fixed_t y, camera_t *thiscam);
|
||||||
|
boolean P_CheckMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff);
|
||||||
fixed_t P_BaseStepUp(void);
|
fixed_t P_BaseStepUp(void);
|
||||||
fixed_t P_GetThingStepUp(mobj_t *thing);
|
fixed_t P_GetThingStepUp(mobj_t *thing);
|
||||||
boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff);
|
boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff);
|
||||||
|
|
|
||||||
54
src/p_map.c
54
src/p_map.c
|
|
@ -2489,21 +2489,19 @@ fixed_t P_GetThingStepUp(mobj_t *thing)
|
||||||
return maxstep;
|
return maxstep;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
static boolean
|
||||||
// P_TryMove
|
increment_move
|
||||||
// Attempt to move to a new position.
|
( mobj_t * thing,
|
||||||
//
|
fixed_t x,
|
||||||
boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff)
|
fixed_t y,
|
||||||
|
boolean allowdropoff,
|
||||||
|
fixed_t * return_stairjank)
|
||||||
{
|
{
|
||||||
fixed_t tryx = thing->x;
|
fixed_t tryx = thing->x;
|
||||||
fixed_t tryy = thing->y;
|
fixed_t tryy = thing->y;
|
||||||
fixed_t oldx = tryx;
|
|
||||||
fixed_t oldy = tryy;
|
|
||||||
fixed_t radius = thing->radius;
|
fixed_t radius = thing->radius;
|
||||||
fixed_t thingtop;
|
fixed_t thingtop;
|
||||||
fixed_t startingonground = P_IsObjectOnGround(thing);
|
|
||||||
fixed_t stairjank = 0;
|
fixed_t stairjank = 0;
|
||||||
pslope_t *oldslope = thing->standingslope;
|
|
||||||
floatok = false;
|
floatok = false;
|
||||||
|
|
||||||
// reset this to 0 at the start of each trymove call as it's only used here
|
// reset this to 0 at the start of each trymove call as it's only used here
|
||||||
|
|
@ -2644,7 +2642,45 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff)
|
||||||
}
|
}
|
||||||
} while (tryx != x || tryy != y);
|
} while (tryx != x || tryy != y);
|
||||||
|
|
||||||
|
if (return_stairjank)
|
||||||
|
*return_stairjank = stairjank;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// P_CheckMove
|
||||||
|
// Check if a P_TryMove would be successful.
|
||||||
|
//
|
||||||
|
boolean P_CheckMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff)
|
||||||
|
{
|
||||||
|
boolean moveok;
|
||||||
|
mobj_t *hack = P_SpawnMobjFromMobj(thing, 0, 0, 0, MT_RAY);
|
||||||
|
|
||||||
|
hack->radius = thing->radius;
|
||||||
|
hack->height = thing->height;
|
||||||
|
|
||||||
|
moveok = increment_move(hack, x, y, allowdropoff, NULL);
|
||||||
|
P_RemoveMobj(hack);
|
||||||
|
|
||||||
|
return moveok;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// P_TryMove
|
||||||
|
// Attempt to move to a new position.
|
||||||
|
//
|
||||||
|
boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff)
|
||||||
|
{
|
||||||
|
fixed_t oldx = thing->x;
|
||||||
|
fixed_t oldy = thing->y;
|
||||||
|
fixed_t startingonground = P_IsObjectOnGround(thing);
|
||||||
|
fixed_t stairjank = 0;
|
||||||
|
pslope_t *oldslope = thing->standingslope;
|
||||||
|
|
||||||
// The move is ok!
|
// The move is ok!
|
||||||
|
if (!increment_move(thing, x, y, allowdropoff, &stairjank))
|
||||||
|
return false;
|
||||||
|
|
||||||
// If it's a pushable object, check if anything is
|
// If it's a pushable object, check if anything is
|
||||||
// standing on top and move it, too.
|
// standing on top and move it, too.
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue