Put tm* variables into a struct

This makes it significantly easier to save/restore the state of these variables, whenever we need to do so for calling movement functions in the middle of other movement functions. This will also make it easier to move it out of global variable hell if desired later.
This commit is contained in:
Sally Coolatta 2022-11-20 19:27:34 -05:00
parent fa3feeb44a
commit b31aa1bbb0
14 changed files with 830 additions and 868 deletions

View file

@ -2729,7 +2729,7 @@ void F_EndTextPrompt(boolean forceexec, boolean noexec)
// \todo net safety, maybe loop all player thinkers?
if ((promptwasactive || forceexec) && !noexec && promptpostexectag)
{
if (tmthing) // edge case where starting an invalid prompt immediately on level load will make P_MapStart fail
if (tm.thing) // edge case where starting an invalid prompt immediately on level load will make P_MapStart fail
P_LinedefExecute(promptpostexectag, promptmo, NULL);
else
{

View file

@ -655,12 +655,12 @@ boolean K_BubbleShieldCollide(mobj_t *t1, mobj_t *t2)
{
// Counter desyncs
/*mobj_t *oldthing = thing;
mobj_t *oldtmthing = tmthing;
mobj_t *oldtm.thing = tm.thing;
P_Thrust(tmthing, R_PointToAngle2(thing->x, thing->y, tmthing->x, tmthing->y), 4*thing->scale);
P_Thrust(tm.thing, R_PointToAngle2(thing->x, thing->y, tm.thing->x, tm.thing->y), 4*thing->scale);
thing = oldthing;
P_SetTarget(&tmthing, oldtmthing);*/
P_SetTarget(&tm.thing, oldtm.thing);*/
if (P_PlayerInPain(t2->player)
|| t2->player->flashing || t2->player->hyudorotimer

View file

@ -1004,108 +1004,108 @@ static int lib_pRemoveFloorSpriteSlope(lua_State *L)
static int lib_pRailThinker(lua_State *L)
{
mobj_t *mobj = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
mobj_t *ptmthing = tmthing;
tm_t ptm = tm;
NOHUD
INLEVEL
if (!mobj)
return LUA_ErrInvalid(L, "mobj_t");
lua_pushboolean(L, P_RailThinker(mobj));
P_SetTarget(&tmthing, ptmthing);
tm = ptm;
return 1;
}
static int lib_pXYMovement(lua_State *L)
{
mobj_t *actor = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
mobj_t *ptmthing = tmthing;
tm_t ptm = tm;
NOHUD
INLEVEL
if (!actor)
return LUA_ErrInvalid(L, "mobj_t");
P_XYMovement(actor);
P_SetTarget(&tmthing, ptmthing);
tm = ptm;
return 0;
}
static int lib_pRingXYMovement(lua_State *L)
{
mobj_t *actor = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
mobj_t *ptmthing = tmthing;
tm_t ptm = tm;
NOHUD
INLEVEL
if (!actor)
return LUA_ErrInvalid(L, "mobj_t");
P_RingXYMovement(actor);
P_SetTarget(&tmthing, ptmthing);
tm = ptm;
return 0;
}
static int lib_pSceneryXYMovement(lua_State *L)
{
mobj_t *actor = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
mobj_t *ptmthing = tmthing;
tm_t ptm = tm;
NOHUD
INLEVEL
if (!actor)
return LUA_ErrInvalid(L, "mobj_t");
P_SceneryXYMovement(actor);
P_SetTarget(&tmthing, ptmthing);
tm = ptm;
return 0;
}
static int lib_pZMovement(lua_State *L)
{
mobj_t *actor = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
mobj_t *ptmthing = tmthing;
tm_t ptm = tm;
NOHUD
INLEVEL
if (!actor)
return LUA_ErrInvalid(L, "mobj_t");
lua_pushboolean(L, P_ZMovement(actor));
P_CheckPosition(actor, actor->x, actor->y);
P_SetTarget(&tmthing, ptmthing);
tm = ptm;
return 1;
}
static int lib_pRingZMovement(lua_State *L)
{
mobj_t *actor = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
mobj_t *ptmthing = tmthing;
tm_t ptm = tm;
NOHUD
INLEVEL
if (!actor)
return LUA_ErrInvalid(L, "mobj_t");
P_RingZMovement(actor);
P_CheckPosition(actor, actor->x, actor->y);
P_SetTarget(&tmthing, ptmthing);
tm = ptm;
return 0;
}
static int lib_pSceneryZMovement(lua_State *L)
{
mobj_t *actor = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
mobj_t *ptmthing = tmthing;
tm_t ptm = tm;
NOHUD
INLEVEL
if (!actor)
return LUA_ErrInvalid(L, "mobj_t");
lua_pushboolean(L, P_SceneryZMovement(actor));
P_CheckPosition(actor, actor->x, actor->y);
P_SetTarget(&tmthing, ptmthing);
tm = ptm;
return 1;
}
static int lib_pPlayerZMovement(lua_State *L)
{
mobj_t *actor = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
mobj_t *ptmthing = tmthing;
tm_t ptm = tm;
NOHUD
INLEVEL
if (!actor)
return LUA_ErrInvalid(L, "mobj_t");
P_PlayerZMovement(actor);
P_CheckPosition(actor, actor->x, actor->y);
P_SetTarget(&tmthing, ptmthing);
tm = ptm;
return 0;
}
@ -1307,13 +1307,13 @@ static int lib_pGivePlayerLives(lua_State *L)
static int lib_pMovePlayer(lua_State *L)
{
player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER));
mobj_t *ptmthing = tmthing;
tm_t ptm = tm;
NOHUD
INLEVEL
if (!player)
return LUA_ErrInvalid(L, "player_t");
P_MovePlayer(player);
P_SetTarget(&tmthing, ptmthing);
tm = ptm;
return 0;
}
@ -1385,7 +1385,7 @@ static int lib_pNukeEnemies(lua_State *L)
static int lib_pCheckPosition(lua_State *L)
{
mobj_t *ptmthing = tmthing;
tm_t ptm = tm;
mobj_t *thing = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
fixed_t x = luaL_checkfixed(L, 2);
fixed_t y = luaL_checkfixed(L, 3);
@ -1394,14 +1394,14 @@ static int lib_pCheckPosition(lua_State *L)
if (!thing)
return LUA_ErrInvalid(L, "mobj_t");
lua_pushboolean(L, P_CheckPosition(thing, x, y));
LUA_PushUserdata(L, tmthing, META_MOBJ);
P_SetTarget(&tmthing, ptmthing);
LUA_PushUserdata(L, tm.thing, META_MOBJ);
tm = ptm;
return 2;
}
static int lib_pTryMove(lua_State *L)
{
mobj_t *ptmthing = tmthing;
tm_t ptm = tm;
mobj_t *thing = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
fixed_t x = luaL_checkfixed(L, 2);
fixed_t y = luaL_checkfixed(L, 3);
@ -1411,14 +1411,14 @@ static int lib_pTryMove(lua_State *L)
if (!thing)
return LUA_ErrInvalid(L, "mobj_t");
lua_pushboolean(L, P_TryMove(thing, x, y, allowdropoff));
LUA_PushUserdata(L, tmthing, META_MOBJ);
P_SetTarget(&tmthing, ptmthing);
LUA_PushUserdata(L, tm.thing, META_MOBJ);
tm = ptm;
return 2;
}
static int lib_pMove(lua_State *L)
{
mobj_t *ptmthing = tmthing;
tm_t ptm = tm;
mobj_t *actor = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
fixed_t speed = luaL_checkfixed(L, 2);
NOHUD
@ -1426,14 +1426,14 @@ static int lib_pMove(lua_State *L)
if (!actor)
return LUA_ErrInvalid(L, "mobj_t");
lua_pushboolean(L, P_Move(actor, speed));
LUA_PushUserdata(L, tmthing, META_MOBJ);
P_SetTarget(&tmthing, ptmthing);
LUA_PushUserdata(L, tm.thing, META_MOBJ);
tm = ptm;
return 2;
}
static int lib_pTeleportMove(lua_State *L)
{
mobj_t *ptmthing = tmthing;
tm_t ptm = tm;
mobj_t *thing = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
fixed_t x = luaL_checkfixed(L, 2);
fixed_t y = luaL_checkfixed(L, 3);
@ -1444,14 +1444,14 @@ static int lib_pTeleportMove(lua_State *L)
return LUA_ErrInvalid(L, "mobj_t");
LUA_Deprecated(L, "P_TeleportMove", "P_SetOrigin\" or \"P_MoveOrigin");
lua_pushboolean(L, P_MoveOrigin(thing, x, y, z));
LUA_PushUserdata(L, tmthing, META_MOBJ);
P_SetTarget(&tmthing, ptmthing);
LUA_PushUserdata(L, tm.thing, META_MOBJ);
tm = ptm;
return 2;
}
static int lib_pSetOrigin(lua_State *L)
{
mobj_t *ptmthing = tmthing;
tm_t ptm = tm;
mobj_t *thing = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
fixed_t x = luaL_checkfixed(L, 2);
fixed_t y = luaL_checkfixed(L, 3);
@ -1461,14 +1461,14 @@ static int lib_pSetOrigin(lua_State *L)
if (!thing)
return LUA_ErrInvalid(L, "mobj_t");
lua_pushboolean(L, P_SetOrigin(thing, x, y, z));
LUA_PushUserdata(L, tmthing, META_MOBJ);
P_SetTarget(&tmthing, ptmthing);
LUA_PushUserdata(L, tm.thing, META_MOBJ);
tm = ptm;
return 2;
}
static int lib_pMoveOrigin(lua_State *L)
{
mobj_t *ptmthing = tmthing;
tm_t ptm = tm;
mobj_t *thing = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
fixed_t x = luaL_checkfixed(L, 2);
fixed_t y = luaL_checkfixed(L, 3);
@ -1478,8 +1478,8 @@ static int lib_pMoveOrigin(lua_State *L)
if (!thing)
return LUA_ErrInvalid(L, "mobj_t");
lua_pushboolean(L, P_MoveOrigin(thing, x, y, z));
LUA_PushUserdata(L, tmthing, META_MOBJ);
P_SetTarget(&tmthing, ptmthing);
LUA_PushUserdata(L, tm.thing, META_MOBJ);
tm = ptm;
return 2;
}

View file

@ -722,7 +722,7 @@ static int sector_set(lua_State *L)
return luaL_error(L, "sector_t field " LUA_QS " cannot be set.", sector_opt[field]);
case sector_floorheight: { // floorheight
boolean flag;
mobj_t *ptmthing = tmthing;
tm_t ptm = tm;
fixed_t lastpos = sector->floorheight;
sector->floorheight = luaL_checkfixed(L, 3);
flag = P_CheckSector(sector, true);
@ -731,12 +731,12 @@ static int sector_set(lua_State *L)
sector->floorheight = lastpos;
P_CheckSector(sector, true);
}
P_SetTarget(&tmthing, ptmthing);
tm = ptm;
break;
}
case sector_ceilingheight: { // ceilingheight
boolean flag;
mobj_t *ptmthing = tmthing;
tm_t ptm = tm;
fixed_t lastpos = sector->ceilingheight;
sector->ceilingheight = luaL_checkfixed(L, 3);
flag = P_CheckSector(sector, true);
@ -745,7 +745,7 @@ static int sector_set(lua_State *L)
sector->ceilingheight = lastpos;
P_CheckSector(sector, true);
}
P_SetTarget(&tmthing, ptmthing);
tm = ptm;
break;
}
case sector_floorpic:
@ -2127,7 +2127,7 @@ static int ffloor_set(lua_State *L)
case ffloor_topheight: { // topheight
boolean flag;
fixed_t lastpos = *ffloor->topheight;
mobj_t *ptmthing = tmthing;
tm_t ptm = tm;
sector_t *sector = &sectors[ffloor->secnum];
sector->ceilingheight = luaL_checkfixed(L, 3);
flag = P_CheckSector(sector, true);
@ -2136,7 +2136,7 @@ static int ffloor_set(lua_State *L)
*ffloor->topheight = lastpos;
P_CheckSector(sector, true);
}
P_SetTarget(&tmthing, ptmthing);
tm = ptm;
break;
}
case ffloor_toppic:
@ -2148,7 +2148,7 @@ static int ffloor_set(lua_State *L)
case ffloor_bottomheight: { // bottomheight
boolean flag;
fixed_t lastpos = *ffloor->bottomheight;
mobj_t *ptmthing = tmthing;
tm_t ptm = tm;
sector_t *sector = &sectors[ffloor->secnum];
sector->floorheight = luaL_checkfixed(L, 3);
flag = P_CheckSector(sector, true);
@ -2157,7 +2157,7 @@ static int ffloor_set(lua_State *L)
*ffloor->bottomheight = lastpos;
P_CheckSector(sector, true);
}
P_SetTarget(&tmthing, ptmthing);
tm = ptm;
break;
}
case ffloor_bottompic:

View file

@ -515,14 +515,14 @@ static int mobj_set(lua_State *L)
case mobj_z:
{
// z doesn't cross sector bounds so it's okay.
mobj_t *ptmthing = tmthing;
tm_t ptm = tm;
mo->z = luaL_checkfixed(L, 3);
P_CheckPosition(mo, mo->x, mo->y);
mo->floorz = tmfloorz;
mo->ceilingz = tmceilingz;
mo->floorrover = tmfloorrover;
mo->ceilingrover = tmceilingrover;
P_SetTarget(&tmthing, ptmthing);
mo->floorz = tm.floorz;
mo->ceilingz = tm.ceilingz;
mo->floorrover = tm.floorrover;
mo->ceilingrover = tm.ceilingrover;
tm = ptm;
break;
}
case mobj_snext:
@ -583,30 +583,30 @@ static int mobj_set(lua_State *L)
return NOSET;
case mobj_radius:
{
mobj_t *ptmthing = tmthing;
tm_t ptm = tm;
mo->radius = luaL_checkfixed(L, 3);
if (mo->radius < 0)
mo->radius = 0;
P_CheckPosition(mo, mo->x, mo->y);
mo->floorz = tmfloorz;
mo->ceilingz = tmceilingz;
mo->floorrover = tmfloorrover;
mo->ceilingrover = tmceilingrover;
P_SetTarget(&tmthing, ptmthing);
mo->floorz = tm.floorz;
mo->ceilingz = tm.ceilingz;
mo->floorrover = tm.floorrover;
mo->ceilingrover = tm.ceilingrover;
tm = ptm;
break;
}
case mobj_height:
{
mobj_t *ptmthing = tmthing;
tm_t ptm = tm;
mo->height = luaL_checkfixed(L, 3);
if (mo->height < 0)
mo->height = 0;
P_CheckPosition(mo, mo->x, mo->y);
mo->floorz = tmfloorz;
mo->ceilingz = tmceilingz;
mo->floorrover = tmfloorrover;
mo->ceilingrover = tmceilingrover;
P_SetTarget(&tmthing, ptmthing);
mo->floorz = tm.floorz;
mo->ceilingz = tm.ceilingz;
mo->floorrover = tm.floorrover;
mo->ceilingrover = tm.ceilingrover;
tm = ptm;
break;
}
case mobj_momx:

View file

@ -543,10 +543,10 @@ boolean P_Move(mobj_t *actor, fixed_t speed)
if (!P_TryMove(actor, tryx, tryy, false))
{
if (actor->flags & MF_FLOAT && floatok)
if (actor->flags & MF_FLOAT && tm.floatok)
{
// must adjust height
if (actor->z < tmfloorz)
if (actor->z < tm.floorz)
actor->z += FixedMul(FLOATSPEED, actor->scale);
else
actor->z -= FixedMul(FLOATSPEED, actor->scale);
@ -10421,13 +10421,13 @@ void A_FlickyCenter(mobj_t *actor)
{
actor->extravalue2 = 1;
P_SetOrigin(actor, actor->target->x, actor->target->y, actor->target->z);
tmthing = NULL;
P_SetTarget(&tm.thing, NULL);
}
else if(actor->extravalue2)
{
actor->extravalue2 = 0;
P_SetOrigin(actor, originx, originy, originz);
tmthing = NULL;
P_SetTarget(&tm.thing, NULL);
}
}
}

View file

@ -381,25 +381,46 @@ void P_InternalFlickyHop(mobj_t *actor, fixed_t momz, fixed_t momh, angle_t angl
// P_MAP
//
// If "floatok" true, move would be ok
// if within "tmfloorz - tmceilingz".
extern boolean floatok;
extern fixed_t tmfloorz;
extern fixed_t tmceilingz;
extern ffloor_t *tmfloorrover, *tmceilingrover;
extern mobj_t *tmfloorthing, *tmhitthing, *tmthing;
typedef struct tm_s
{
mobj_t *thing;
fixed_t x, y;
fixed_t bbox[4];
INT32 flags;
precipmobj_t *precipthing;
fixed_t precipbbox[4];
// If "floatok" true, move would be ok
// if within "tm.floorz - tm.ceilingz".
boolean floatok;
fixed_t floorz, ceilingz;
fixed_t dropoffz, drpoffceilz; // drop-off floor/ceiling heights
mobj_t *floorthing; // the thing corresponding to tm.floorz or NULL if tm.floorz is from a sector
mobj_t *hitthing; // the solid thing you bumped into (for collisions)
ffloor_t *floorrover, *ceilingrover;
pslope_t *floorslope, *ceilingslope;
INT32 floorpic, ceilingpic;
fixed_t floorstep, ceilingstep;
// keep track of the line that lowers the ceiling,
// so missiles don't explode against sky hack walls
line_t *ceilingline;
// set by PIT_CheckLine() for any line that stopped the PIT_CheckLine()
// that is, for any line which is 'solid'
line_t *blockingline;
} tm_t;
extern tm_t tm;
extern camera_t *mapcampointer;
extern fixed_t tmx;
extern fixed_t tmy;
extern pslope_t *tmfloorslope, *tmceilingslope;
extern INT32 tmfloorpic, tmceilingpic;
/* cphipps 2004/08/30 */
extern void P_MapStart(void);
extern void P_MapEnd(void);
extern line_t *ceilingline;
extern line_t *blockingline;
extern msecnode_t *sector_list;
extern mprecipsecnode_t *precipsector_list;

File diff suppressed because it is too large Load diff

View file

@ -379,8 +379,8 @@ void P_CameraLineOpening(line_t *linedef)
}
else
{
frontfloor = P_CameraGetFloorZ (mapcampointer, front, tmx, tmy, linedef);
frontceiling = P_CameraGetCeilingZ(mapcampointer, front, tmx, tmy, linedef);
frontfloor = P_CameraGetFloorZ (mapcampointer, front, tm.x, tm.y, linedef);
frontceiling = P_CameraGetCeilingZ(mapcampointer, front, tm.x, tm.y, linedef);
}
if (back->camsec >= 0)
@ -397,8 +397,8 @@ void P_CameraLineOpening(line_t *linedef)
}
else
{
backfloor = P_CameraGetFloorZ(mapcampointer, back, tmx, tmy, linedef);
backceiling = P_CameraGetCeilingZ(mapcampointer, back, tmx, tmy, linedef);
backfloor = P_CameraGetFloorZ(mapcampointer, back, tm.x, tm.y, linedef);
backceiling = P_CameraGetCeilingZ(mapcampointer, back, tm.x, tm.y, linedef);
}
{
@ -440,8 +440,8 @@ void P_CameraLineOpening(line_t *linedef)
if (!(rover->fofflags & FOF_BLOCKOTHERS) || !(rover->fofflags & FOF_RENDERALL) || !(rover->fofflags & FOF_EXISTS) || (rover->master->frontsector->flags & MSF_NOCLIPCAMERA))
continue;
topheight = P_CameraGetFOFTopZ(mapcampointer, front, rover, tmx, tmy, linedef);
bottomheight = P_CameraGetFOFBottomZ(mapcampointer, front, rover, tmx, tmy, linedef);
topheight = P_CameraGetFOFTopZ(mapcampointer, front, rover, tm.x, tm.y, linedef);
bottomheight = P_CameraGetFOFBottomZ(mapcampointer, front, rover, tm.x, tm.y, linedef);
delta1 = abs(mapcampointer->z - (bottomheight + ((topheight - bottomheight)/2)));
delta2 = abs(thingtop - (bottomheight + ((topheight - bottomheight)/2)));
@ -464,8 +464,8 @@ void P_CameraLineOpening(line_t *linedef)
if (!(rover->fofflags & FOF_BLOCKOTHERS) || !(rover->fofflags & FOF_RENDERALL) || !(rover->fofflags & FOF_EXISTS) || (rover->master->frontsector->flags & MSF_NOCLIPCAMERA))
continue;
topheight = P_CameraGetFOFTopZ(mapcampointer, back, rover, tmx, tmy, linedef);
bottomheight = P_CameraGetFOFBottomZ(mapcampointer, back, rover, tmx, tmy, linedef);
topheight = P_CameraGetFOFTopZ(mapcampointer, back, rover, tm.x, tm.y, linedef);
bottomheight = P_CameraGetFOFBottomZ(mapcampointer, back, rover, tm.x, tm.y, linedef);
delta1 = abs(mapcampointer->z - (bottomheight + ((topheight - bottomheight)/2)));
delta2 = abs(thingtop - (bottomheight + ((topheight - bottomheight)/2)));
@ -614,7 +614,7 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj)
return;
}
P_ClosestPointOnLine(tmx, tmy, linedef, &cross);
P_ClosestPointOnLine(tm.x, tm.y, linedef, &cross);
// Treat polyobjects kind of like 3D Floors
if (linedef->polyobj && (linedef->polyobj->flags & POF_TESTHEIGHT))
@ -656,8 +656,8 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj)
fixed_t height[2];
const sector_t * sector[2] = { front, back };
height[FRONT] = P_GetCeilingZ(mobj, front, tmx, tmy, linedef);
height[BACK] = P_GetCeilingZ(mobj, back, tmx, tmy, linedef);
height[FRONT] = P_GetCeilingZ(mobj, front, tm.x, tm.y, linedef);
height[BACK] = P_GetCeilingZ(mobj, back, tm.x, tm.y, linedef);
hi = ( height[0] < height[1] );
lo = ! hi;
@ -676,8 +676,8 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj)
openceilingdrop = ( topedge[hi] - topedge[lo] );
}
height[FRONT] = P_GetFloorZ(mobj, front, tmx, tmy, linedef);
height[BACK] = P_GetFloorZ(mobj, back, tmx, tmy, linedef);
height[FRONT] = P_GetFloorZ(mobj, front, tm.x, tm.y, linedef);
height[BACK] = P_GetFloorZ(mobj, back, tm.x, tm.y, linedef);
hi = ( height[0] < height[1] );
lo = ! hi;
@ -818,8 +818,8 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj)
|| (rover->fofflags & FOF_BLOCKOTHERS && !mobj->player)))
continue;
topheight = P_GetFOFTopZ(mobj, front, rover, tmx, tmy, linedef);
bottomheight = P_GetFOFBottomZ(mobj, front, rover, tmx, tmy, linedef);
topheight = P_GetFOFTopZ(mobj, front, rover, tm.x, tm.y, linedef);
bottomheight = P_GetFOFBottomZ(mobj, front, rover, tm.x, tm.y, linedef);
delta1 = abs(mobj->z - (bottomheight + ((topheight - bottomheight)/2)));
delta2 = abs(thingtop - (bottomheight + ((topheight - bottomheight)/2)));
@ -862,8 +862,8 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj)
|| (rover->fofflags & FOF_BLOCKOTHERS && !mobj->player)))
continue;
topheight = P_GetFOFTopZ(mobj, back, rover, tmx, tmy, linedef);
bottomheight = P_GetFOFBottomZ(mobj, back, rover, tmx, tmy, linedef);
topheight = P_GetFOFTopZ(mobj, back, rover, tm.x, tm.y, linedef);
bottomheight = P_GetFOFBottomZ(mobj, back, rover, tm.x, tm.y, linedef);
delta1 = abs(mobj->z - (bottomheight + ((topheight - bottomheight)/2)));
delta2 = abs(thingtop - (bottomheight + ((topheight - bottomheight)/2)));
@ -1596,16 +1596,16 @@ boolean P_RadiusLinesCheck(fixed_t radius, fixed_t x, fixed_t y,
INT32 xl, xh, yl, yh;
INT32 bx, by;
tmbbox[BOXTOP] = y + radius;
tmbbox[BOXBOTTOM] = y - radius;
tmbbox[BOXRIGHT] = x + radius;
tmbbox[BOXLEFT] = x - radius;
tm.bbox[BOXTOP] = y + radius;
tm.bbox[BOXBOTTOM] = y - radius;
tm.bbox[BOXRIGHT] = x + radius;
tm.bbox[BOXLEFT] = x - radius;
// check lines
xl = (unsigned)(tmbbox[BOXLEFT] - bmaporgx)>>MAPBLOCKSHIFT;
xh = (unsigned)(tmbbox[BOXRIGHT] - bmaporgx)>>MAPBLOCKSHIFT;
yl = (unsigned)(tmbbox[BOXBOTTOM] - bmaporgy)>>MAPBLOCKSHIFT;
yh = (unsigned)(tmbbox[BOXTOP] - bmaporgy)>>MAPBLOCKSHIFT;
xl = (unsigned)(tm.bbox[BOXLEFT] - bmaporgx)>>MAPBLOCKSHIFT;
xh = (unsigned)(tm.bbox[BOXRIGHT] - bmaporgx)>>MAPBLOCKSHIFT;
yl = (unsigned)(tm.bbox[BOXBOTTOM] - bmaporgy)>>MAPBLOCKSHIFT;
yh = (unsigned)(tm.bbox[BOXTOP] - bmaporgy)>>MAPBLOCKSHIFT;
for (bx = xl; bx <= xh; bx++)
for (by = yl; by <= yh; by++)

View file

@ -85,8 +85,6 @@ boolean P_BlockThingsIterator(INT32 x, INT32 y, BlockItReturn_t(*func)(mobj_t *)
extern divline_t trace;
extern fixed_t tmbbox[4]; // p_map.c
// call your user function for each line of the blockmap in the
// bbox defined by the radius
//boolean P_RadiusLinesCheck(fixed_t radius, fixed_t x, fixed_t y,

View file

@ -1491,12 +1491,12 @@ bustupdone:
//
static boolean P_CheckSkyHit(mobj_t *mo)
{
if (ceilingline && ceilingline->backsector
&& ceilingline->backsector->ceilingpic == skyflatnum
&& ceilingline->frontsector
&& ceilingline->frontsector->ceilingpic == skyflatnum
&& (mo->z >= ceilingline->frontsector->ceilingheight
|| mo->z >= ceilingline->backsector->ceilingheight))
if (tm.ceilingline && tm.ceilingline->backsector
&& tm.ceilingline->backsector->ceilingpic == skyflatnum
&& tm.ceilingline->frontsector
&& tm.ceilingline->frontsector->ceilingpic == skyflatnum
&& (mo->z >= tm.ceilingline->frontsector->ceilingheight
|| mo->z >= tm.ceilingline->backsector->ceilingheight))
return true;
return false;
}
@ -1601,7 +1601,7 @@ void P_XYMovement(mobj_t *mo)
// blocked move
moved = false;
if (LUA_HookMobjMoveBlocked(mo, tmhitthing, blockingline))
if (LUA_HookMobjMoveBlocked(mo, tm.hitthing, tm.blockingline))
{
if (P_MobjWasRemoved(mo))
return;
@ -1626,7 +1626,7 @@ void P_XYMovement(mobj_t *mo)
// draw damage on wall
//SPLAT TEST ----------------------------------------------------------
#ifdef WALLSPLATS
if (blockingline && mo->type != MT_REDRING && mo->type != MT_FIREBALL
if (tm.blockingline && mo->type != MT_REDRING && mo->type != MT_FIREBALL
&& !(mo->flags2 & (MF2_AUTOMATIC|MF2_RAILRING|MF2_BOUNCERING|MF2_EXPLOSION|MF2_SCATTER)))
// set by last P_TryMove() that failed
{
@ -1634,13 +1634,13 @@ void P_XYMovement(mobj_t *mo)
divline_t misl;
fixed_t frac;
P_MakeDivline(blockingline, &divl);
P_MakeDivline(tm.blockingline, &divl);
misl.x = mo->x;
misl.y = mo->y;
misl.dx = mo->momx;
misl.dy = mo->momy;
frac = P_InterceptVector(&divl, &misl);
R_AddWallSplat(blockingline, P_PointOnLineSide(mo->x,mo->y,blockingline),
R_AddWallSplat(tm.blockingline, P_PointOnLineSide(mo->x,mo->y,tm.blockingline),
"A_DMG3", mo->z, frac, SPLATDRAWMODE_SHADE);
}
#endif
@ -2371,11 +2371,11 @@ boolean P_ZMovement(mobj_t *mo)
if (P_MobjWasRemoved(mo)) // mobjs can be removed by P_CheckPosition -- Monster Iestyn 31/07/21
return false;
K_UpdateMobjTerrain(mo, ((mo->eflags & MFE_VERTICALFLIP) ? tmceilingpic : tmfloorpic));
K_UpdateMobjTerrain(mo, ((mo->eflags & MFE_VERTICALFLIP) ? tm.ceilingpic : tm.floorpic));
if (((mo->eflags & MFE_VERTICALFLIP) ? tmceilingslope : tmfloorslope) && (mo->type != MT_STEAM))
if (((mo->eflags & MFE_VERTICALFLIP) ? tm.ceilingslope : tm.floorslope) && (mo->type != MT_STEAM))
{
mo->standingslope = (mo->eflags & MFE_VERTICALFLIP) ? tmceilingslope : tmfloorslope;
mo->standingslope = (mo->eflags & MFE_VERTICALFLIP) ? tm.ceilingslope : tm.floorslope;
P_SetPitchRollFromSlope(mo, mo->standingslope);
P_ReverseQuantizeMomentumToSlope(&mom, mo->standingslope);
}
@ -2591,11 +2591,11 @@ boolean P_ZMovement(mobj_t *mo)
}
}
else
mom.z = (tmfloorthing ? tmfloorthing->momz : 0);
mom.z = (tm.floorthing ? tm.floorthing->momz : 0);
}
else if (tmfloorthing)
mom.z = tmfloorthing->momz;
else if (tm.floorthing)
mom.z = tm.floorthing->momz;
if (mo->standingslope) { // MT_STEAM will never have a standingslope, see above.
P_QuantizeMomentumToSlope(&mom, mo->standingslope);
@ -2834,7 +2834,7 @@ void P_PlayerZMovement(mobj_t *mo)
mo->z = mo->floorz;
}
K_UpdateMobjTerrain(mo, (mo->eflags & MFE_VERTICALFLIP ? tmceilingpic : tmfloorpic));
K_UpdateMobjTerrain(mo, (mo->eflags & MFE_VERTICALFLIP ? tm.ceilingpic : tm.floorpic));
// Get up if you fell.
if (mo->player->panim == PA_HURT && mo->player->spinouttimer == 0 && mo->player->tumbleBounces == 0)
@ -2842,10 +2842,10 @@ void P_PlayerZMovement(mobj_t *mo)
P_SetPlayerMobjState(mo, S_KART_STILL);
}
if (!mo->standingslope && (mo->eflags & MFE_VERTICALFLIP ? tmceilingslope : tmfloorslope))
if (!mo->standingslope && (mo->eflags & MFE_VERTICALFLIP ? tm.ceilingslope : tm.floorslope))
{
// Handle landing on slope during Z movement
P_HandleSlopeLanding(mo, (mo->eflags & MFE_VERTICALFLIP ? tmceilingslope : tmfloorslope));
P_HandleSlopeLanding(mo, (mo->eflags & MFE_VERTICALFLIP ? tm.ceilingslope : tm.floorslope));
}
if (P_MobjFlip(mo) * mo->momz < 0) // falling
@ -2860,12 +2860,12 @@ void P_PlayerZMovement(mobj_t *mo)
if (clipmomz)
{
mo->momz = (tmfloorthing ? tmfloorthing->momz : 0);
mo->momz = (tm.floorthing ? tm.floorthing->momz : 0);
}
}
else if (tmfloorthing)
else if (tm.floorthing)
{
mo->momz = tmfloorthing->momz;
mo->momz = tm.floorthing->momz;
}
}
else
@ -3083,9 +3083,9 @@ boolean P_SceneryZMovement(mobj_t *mo)
{
mo->eflags |= MFE_JUSTHITFLOOR; // Spin Attack
if (tmfloorthing)
mo->momz = tmfloorthing->momz;
else if (!tmfloorthing)
if (tm.floorthing)
mo->momz = tm.floorthing->momz;
else if (!tm.floorthing)
mo->momz = 0;
}
}
@ -3801,8 +3801,8 @@ boolean P_CameraThinker(player_t *player, camera_t *thiscam, boolean resetcalled
}
thiscam->subsector = R_PointInSubsector(thiscam->x, thiscam->y);
thiscam->floorz = tmfloorz;
thiscam->ceilingz = tmceilingz;
thiscam->floorz = tm.floorz;
thiscam->ceilingz = tm.ceilingz;
if (thiscam->momz || player->mo->pmomz)
{
@ -3960,8 +3960,8 @@ static void P_PlayerMobjThinker(mobj_t *mobj)
mobj->z += mobj->momz;
P_SetThingPosition(mobj);
P_CheckPosition(mobj, mobj->x, mobj->y);
mobj->floorz = tmfloorz;
mobj->ceilingz = tmceilingz;
mobj->floorz = tm.floorz;
mobj->ceilingz = tm.ceilingz;
goto animonly;
}
@ -9451,7 +9451,7 @@ void P_MobjThinker(mobj_t *mobj)
mobj->eflags &= ~(MFE_PUSHED|MFE_SPRUNG|MFE_JUSTBOUNCEDWALL|MFE_DAMAGEHITLAG|MFE_SLOPELAUNCHED);
tmfloorthing = tmhitthing = NULL;
tm.floorthing = tm.hitthing = NULL;
// Sector flag MSF_TRIGGERLINE_MOBJ allows ANY mobj to trigger a linedef exec
P_CheckMobjTrigger(mobj, false);
@ -9809,10 +9809,10 @@ void P_SceneryThinker(mobj_t *mobj)
P_CheckPosition(mobj, mobj->x, mobj->y); // Need this to pick up objects!
if (P_MobjWasRemoved(mobj))
return;
mobj->floorz = tmfloorz;
mobj->ceilingz = tmceilingz;
mobj->floorrover = tmfloorrover;
mobj->ceilingrover = tmceilingrover;
mobj->floorz = tm.floorz;
mobj->ceilingz = tm.ceilingz;
mobj->floorrover = tm.floorrover;
mobj->ceilingrover = tm.ceilingrover;
}
else
{

View file

@ -762,7 +762,7 @@ static void Polyobj_removeFromBlockmap(polyobj_t *po)
// Movement functions
// A version of Lee's routine from p_maputl.c that accepts an mobj pointer
// argument instead of using tmthing. Returns true if the line isn't contacted
// argument instead of using tm.thing. Returns true if the line isn't contacted
// and false otherwise.
static inline boolean Polyobj_untouched(line_t *ld, mobj_t *mo)
{
@ -806,10 +806,10 @@ static void Polyobj_pushThing(polyobj_t *po, line_t *line, mobj_t *mo)
if (po->damage && (mo->flags & MF_SHOOTABLE))
{
P_CheckPosition(mo, mo->x + momx, mo->y + momy);
mo->floorz = tmfloorz;
mo->ceilingz = tmceilingz;
mo->floorrover = tmfloorrover;
mo->ceilingrover = tmceilingrover;
mo->floorz = tm.floorz;
mo->ceilingz = tm.ceilingz;
mo->floorrover = tm.floorrover;
mo->ceilingrover = tm.ceilingrover;
}
}

View file

@ -7465,7 +7465,7 @@ boolean P_LoadLevel(boolean fromnetsave, boolean reloadinggamestate)
P_ResetTubeWaypoints();
P_MapStart(); // tmthing can be used starting from this point
P_MapStart(); // tm.thing can be used starting from this point
// init anything that P_SpawnSlopes/P_LoadThings needs to know
P_InitSpecials();
@ -7570,7 +7570,7 @@ boolean P_LoadLevel(boolean fromnetsave, boolean reloadinggamestate)
P_RunCachedActions();
P_MapEnd(); // tmthing is no longer needed from this point onwards
P_MapEnd(); // tm.thing is no longer needed from this point onwards
// Took me 3 hours to figure out why my progression kept on getting overwritten with the titlemap...
if (!titlemapinaction)
@ -7629,9 +7629,9 @@ boolean P_LoadLevel(boolean fromnetsave, boolean reloadinggamestate)
G_CopyTiccmd(&players[i].cmd, &netcmds[buf][i], 1);
}
P_PreTicker(2);
P_MapStart(); // just in case MapLoad modifies tmthing
P_MapStart(); // just in case MapLoad modifies tm.thing
LUA_HookInt(gamemap, HOOK(MapLoad));
P_MapEnd(); // just in case MapLoad modifies tmthing
P_MapEnd(); // just in case MapLoad modifies tm.thing
}
K_TimerReset();

View file

@ -749,10 +749,10 @@ static boolean P_CrossBotTraversalSubsector(size_t num, register traceblocking_t
}
// set openrange, opentop, openbottom
tmx = tb->compareThing->x;
tmy = tb->compareThing->y;
tm.x = tb->compareThing->x;
tm.y = tb->compareThing->y;
P_LineOpening(line, tb->compareThing);
maxstep = P_GetThingStepUp(tb->compareThing, tmx, tmy);
maxstep = P_GetThingStepUp(tb->compareThing, tm.x, tm.y);
if ((openrange < tb->compareThing->height) // doesn't fit
|| (opentop - tb->compareThing->z < tb->compareThing->height) // mobj is too high