diff --git a/src/f_finale.c b/src/f_finale.c index a0ae60cf2..ca5b44fb3 100644 --- a/src/f_finale.c +++ b/src/f_finale.c @@ -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 { diff --git a/src/k_collide.c b/src/k_collide.c index d3b9bc60c..6a67e5a04 100644 --- a/src/k_collide.c +++ b/src/k_collide.c @@ -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 diff --git a/src/lua_baselib.c b/src/lua_baselib.c index fcdf86624..a55703cbd 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -999,108 +999,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); + P_RestoreTMStruct(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); + P_RestoreTMStruct(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); + P_RestoreTMStruct(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); + P_RestoreTMStruct(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); + P_RestoreTMStruct(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); + P_RestoreTMStruct(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); + P_RestoreTMStruct(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); + P_RestoreTMStruct(ptm); return 0; } @@ -1302,13 +1302,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); + P_RestoreTMStruct(ptm); return 0; } @@ -1380,7 +1380,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); @@ -1389,14 +1389,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); + P_RestoreTMStruct(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); @@ -1406,14 +1406,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); + P_RestoreTMStruct(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 @@ -1421,14 +1421,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); + P_RestoreTMStruct(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); @@ -1439,14 +1439,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); + P_RestoreTMStruct(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); @@ -1456,14 +1456,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); + P_RestoreTMStruct(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); @@ -1473,8 +1473,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); + P_RestoreTMStruct(ptm); return 2; } diff --git a/src/lua_maplib.c b/src/lua_maplib.c index f89059402..0557456b2 100644 --- a/src/lua_maplib.c +++ b/src/lua_maplib.c @@ -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); + P_RestoreTMStruct(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); + P_RestoreTMStruct(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 = §ors[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); + P_RestoreTMStruct(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 = §ors[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); + P_RestoreTMStruct(ptm); break; } case ffloor_bottompic: diff --git a/src/lua_mobjlib.c b/src/lua_mobjlib.c index ecd87f49f..8f38df115 100644 --- a/src/lua_mobjlib.c +++ b/src/lua_mobjlib.c @@ -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; + P_RestoreTMStruct(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; + P_RestoreTMStruct(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; + P_RestoreTMStruct(ptm); break; } case mobj_momx: diff --git a/src/p_enemy.c b/src/p_enemy.c index 439e5c16e..eb2098280 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -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); } } } diff --git a/src/p_local.h b/src/p_local.h index f5d613e97..61a836c09 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -381,25 +381,48 @@ 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; + +void P_RestoreTMStruct(tm_t tmrestore); + 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; diff --git a/src/p_map.c b/src/p_map.c index 677954b43..13a814dda 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -44,36 +44,46 @@ #include "m_perfstats.h" // ps_checkposition_calls -fixed_t tmbbox[4]; -mobj_t *tmthing; -static INT32 tmflags; -fixed_t tmx; -fixed_t tmy; +tm_t tm = {0}; -static precipmobj_t *tmprecipthing; -static fixed_t preciptmbbox[4]; +void P_RestoreTMStruct(tm_t tmrestore) +{ + // Reference count management + if (tm.thing != tmrestore.thing) + { + P_SetTarget(&tm.thing, NULL); + } -// If "floatok" true, move would be ok -// if within "tmfloorz - tmceilingz". -boolean floatok; + if (tm.floorthing != tmrestore.floorthing) + { + P_SetTarget(&tm.floorthing, NULL); + } -fixed_t tmfloorz, tmceilingz; -static fixed_t tmdropoffz, tmdrpoffceilz; // drop-off floor/ceiling heights -mobj_t *tmfloorthing; // the thing corresponding to tmfloorz or NULL if tmfloorz is from a sector -mobj_t *tmhitthing; // the solid thing you bumped into (for collisions) -ffloor_t *tmfloorrover, *tmceilingrover; -pslope_t *tmfloorslope, *tmceilingslope; -INT32 tmfloorpic, tmceilingpic; -static fixed_t tmfloorstep; -static fixed_t tmceilingstep; + if (tm.hitthing != tmrestore.hitthing) + { + P_SetTarget(&tm.hitthing, NULL); + } -// keep track of the line that lowers the ceiling, -// so missiles don't explode against sky hack walls -line_t *ceilingline; + // Restore state + tm = tmrestore; + + // Validation + if (tm.thing && P_MobjWasRemoved(tm.thing) == true) + { + P_SetTarget(&tm.thing, NULL); + } + + if (tm.floorthing && P_MobjWasRemoved(tm.floorthing) == true) + { + P_SetTarget(&tm.floorthing, NULL); + } + + if (tm.hitthing && P_MobjWasRemoved(tm.hitthing) == true) + { + P_SetTarget(&tm.hitthing, NULL); + } +} -// set by PIT_CheckLine() for any line that stopped the PIT_CheckLine() -// that is, for any line which is 'solid' -line_t *blockingline; // Mostly re-ported from DOOM Legacy // Keep track of special lines as they are hit, process them when the move is valid @@ -126,10 +136,10 @@ static boolean P_TeleportMove(mobj_t *thing, fixed_t x, fixed_t y, fixed_t z) if (P_MobjWasRemoved(thing)) return true; - thing->floorz = tmfloorz; - thing->ceilingz = tmceilingz; - thing->floorrover = tmfloorrover; - thing->ceilingrover = tmceilingrover; + thing->floorz = tm.floorz; + thing->ceilingz = tm.ceilingz; + thing->floorrover = tm.floorrover; + thing->ceilingrover = tm.ceilingrover; return true; } @@ -529,32 +539,32 @@ static BlockItReturn_t PIT_CheckThing(mobj_t *thing) { fixed_t blockdist; - if (tmthing == NULL || P_MobjWasRemoved(tmthing) == true) - return BMIT_STOP; // func just popped our tmthing, cannot continue. + if (tm.thing == NULL || P_MobjWasRemoved(tm.thing) == true) + return BMIT_STOP; // func just popped our tm.thing, cannot continue. // Ignore... things. if (thing == NULL || P_MobjWasRemoved(thing) == true) return BMIT_CONTINUE; // don't clip against self - if (thing == tmthing) + if (thing == tm.thing) return BMIT_CONTINUE; // Ignore spectators - if ((tmthing->player && tmthing->player->spectator) + if ((tm.thing->player && tm.thing->player->spectator) || (thing->player && thing->player->spectator)) return BMIT_CONTINUE; // Ignore the collision if BOTH things are in hitlag. - if (thing->hitlag > 0 && tmthing->hitlag > 0) + if (thing->hitlag > 0 && tm.thing->hitlag > 0) return BMIT_CONTINUE; if ((thing->flags & MF_NOCLIPTHING) || !(thing->flags & (MF_SOLID|MF_SPECIAL|MF_PAIN|MF_SHOOTABLE|MF_SPRING))) return BMIT_CONTINUE; - blockdist = thing->radius + tmthing->radius; + blockdist = thing->radius + tm.thing->radius; - if (abs(thing->x - tmx) >= blockdist || abs(thing->y - tmy) >= blockdist) + if (abs(thing->x - tm.x) >= blockdist || abs(thing->y - tm.y) >= blockdist) return BMIT_CONTINUE; // didn't hit it if (thing->flags & MF_PAPERCOLLISION) // CAUTION! Very easy to get stuck inside MF_SOLID objects. Giving the player MF_PAPERCOLLISION is a bad idea unless you know what you're doing. @@ -576,47 +586,47 @@ static BlockItReturn_t PIT_CheckThing(mobj_t *thing) junk.dx = 2*cosradius; // v2.x - v1.x; junk.dy = 2*sinradius; // v2.y - v1.y; - if (tmthing->flags & MF_PAPERCOLLISION) // more strenuous checking to prevent clipping issues + if (tm.thing->flags & MF_PAPERCOLLISION) // more strenuous checking to prevent clipping issues { INT32 check1, check2, check3, check4; - fixed_t tmcosradius = FixedMul(tmthing->radius, FINECOSINE(tmthing->angle>>ANGLETOFINESHIFT)); - fixed_t tmsinradius = FixedMul(tmthing->radius, FINESINE(tmthing->angle>>ANGLETOFINESHIFT)); - if (abs(thing->x - tmx) >= (abs(tmcosradius) + abs(cosradius)) || abs(thing->y - tmy) >= (abs(tmsinradius) + abs(sinradius))) + fixed_t tmcosradius = FixedMul(tm.thing->radius, FINECOSINE(tm.thing->angle>>ANGLETOFINESHIFT)); + fixed_t tmsinradius = FixedMul(tm.thing->radius, FINESINE(tm.thing->angle>>ANGLETOFINESHIFT)); + if (abs(thing->x - tm.x) >= (abs(tmcosradius) + abs(cosradius)) || abs(thing->y - tm.y) >= (abs(tmsinradius) + abs(sinradius))) return BMIT_CONTINUE; // didn't hit it - check1 = P_PointOnLineSide(tmx - tmcosradius, tmy - tmsinradius, &junk); - check2 = P_PointOnLineSide(tmx + tmcosradius, tmy + tmsinradius, &junk); - check3 = P_PointOnLineSide(tmx + tmthing->momx - tmcosradius, tmy + tmthing->momy - tmsinradius, &junk); - check4 = P_PointOnLineSide(tmx + tmthing->momx + tmcosradius, tmy + tmthing->momy + tmsinradius, &junk); + check1 = P_PointOnLineSide(tm.x - tmcosradius, tm.y - tmsinradius, &junk); + check2 = P_PointOnLineSide(tm.x + tmcosradius, tm.y + tmsinradius, &junk); + check3 = P_PointOnLineSide(tm.x + tm.thing->momx - tmcosradius, tm.y + tm.thing->momy - tmsinradius, &junk); + check4 = P_PointOnLineSide(tm.x + tm.thing->momx + tmcosradius, tm.y + tm.thing->momy + tmsinradius, &junk); if ((check1 == check2) && (check2 == check3) && (check3 == check4)) return BMIT_CONTINUE; // the line doesn't cross between collider's start or end } else { - if (abs(thing->x - tmx) >= (tmthing->radius + abs(cosradius)) || abs(thing->y - tmy) >= (tmthing->radius + abs(sinradius))) + if (abs(thing->x - tm.x) >= (tm.thing->radius + abs(cosradius)) || abs(thing->y - tm.y) >= (tm.thing->radius + abs(sinradius))) return BMIT_CONTINUE; // didn't hit it - if ((P_PointOnLineSide(tmx - tmthing->radius, tmy - tmthing->radius, &junk) - == P_PointOnLineSide(tmx + tmthing->radius, tmy + tmthing->radius, &junk)) - && (P_PointOnLineSide(tmx + tmthing->radius, tmy - tmthing->radius, &junk) - == P_PointOnLineSide(tmx - tmthing->radius, tmy + tmthing->radius, &junk))) + if ((P_PointOnLineSide(tm.x - tm.thing->radius, tm.y - tm.thing->radius, &junk) + == P_PointOnLineSide(tm.x + tm.thing->radius, tm.y + tm.thing->radius, &junk)) + && (P_PointOnLineSide(tm.x + tm.thing->radius, tm.y - tm.thing->radius, &junk) + == P_PointOnLineSide(tm.x - tm.thing->radius, tm.y + tm.thing->radius, &junk))) return BMIT_CONTINUE; // the line doesn't cross between either pair of opposite corners } } - else if (tmthing->flags & MF_PAPERCOLLISION) + else if (tm.thing->flags & MF_PAPERCOLLISION) { fixed_t tmcosradius, tmsinradius; vertex_t v1, v2; // fake vertexes line_t junk; // fake linedef - tmcosradius = FixedMul(tmthing->radius, FINECOSINE(tmthing->angle>>ANGLETOFINESHIFT)); - tmsinradius = FixedMul(tmthing->radius, FINESINE(tmthing->angle>>ANGLETOFINESHIFT)); + tmcosradius = FixedMul(tm.thing->radius, FINECOSINE(tm.thing->angle>>ANGLETOFINESHIFT)); + tmsinradius = FixedMul(tm.thing->radius, FINESINE(tm.thing->angle>>ANGLETOFINESHIFT)); - if (abs(thing->x - tmx) >= (thing->radius + abs(tmcosradius)) || abs(thing->y - tmy) >= (thing->radius + abs(tmsinradius))) + if (abs(thing->x - tm.x) >= (thing->radius + abs(tmcosradius)) || abs(thing->y - tm.y) >= (thing->radius + abs(tmsinradius))) return BMIT_CONTINUE; // didn't hit it - v1.x = tmx - tmcosradius; - v1.y = tmy - tmsinradius; - v2.x = tmx + tmcosradius; - v2.y = tmy + tmsinradius; + v1.x = tm.x - tmcosradius; + v1.y = tm.y - tmsinradius; + v2.x = tm.x + tmcosradius; + v2.y = tm.y + tmsinradius; junk.v1 = &v1; junk.v2 = &v2; @@ -632,16 +642,16 @@ static BlockItReturn_t PIT_CheckThing(mobj_t *thing) } { - UINT8 shouldCollide = LUA_Hook2Mobj(thing, tmthing, MOBJ_HOOK(MobjCollide)); // checks hook for thing's type - if (P_MobjWasRemoved(tmthing) || P_MobjWasRemoved(thing)) + UINT8 shouldCollide = LUA_Hook2Mobj(thing, tm.thing, MOBJ_HOOK(MobjCollide)); // checks hook for thing's type + if (P_MobjWasRemoved(tm.thing) || P_MobjWasRemoved(thing)) return BMIT_CONTINUE; // one of them was removed??? if (shouldCollide == 1) return BMIT_ABORT; // force collide else if (shouldCollide == 2) return BMIT_CONTINUE; // force no collide - shouldCollide = LUA_Hook2Mobj(tmthing, thing, MOBJ_HOOK(MobjMoveCollide)); // checks hook for tmthing's type - if (P_MobjWasRemoved(tmthing) || P_MobjWasRemoved(thing)) + shouldCollide = LUA_Hook2Mobj(tm.thing, thing, MOBJ_HOOK(MobjMoveCollide)); // checks hook for tm.thing's type + if (P_MobjWasRemoved(tm.thing) || P_MobjWasRemoved(thing)) return BMIT_CONTINUE; // one of them was removed??? if (shouldCollide == 1) return BMIT_ABORT; // force collide @@ -650,66 +660,66 @@ static BlockItReturn_t PIT_CheckThing(mobj_t *thing) } // When solid spikes move, assume they just popped up and teleport things on top of them to hurt. - if (tmthing->type == MT_SPIKE && tmthing->flags & MF_SOLID) + if (tm.thing->type == MT_SPIKE && tm.thing->flags & MF_SOLID) { - if (thing->z > tmthing->z + tmthing->height) + if (thing->z > tm.thing->z + tm.thing->height) return BMIT_CONTINUE; // overhead - if (thing->z + thing->height < tmthing->z) + if (thing->z + thing->height < tm.thing->z) return BMIT_CONTINUE; // underneath - if (tmthing->eflags & MFE_VERTICALFLIP) - P_SetOrigin(thing, thing->x, thing->y, tmthing->z - thing->height - FixedMul(FRACUNIT, tmthing->scale)); + if (tm.thing->eflags & MFE_VERTICALFLIP) + P_SetOrigin(thing, thing->x, thing->y, tm.thing->z - thing->height - FixedMul(FRACUNIT, tm.thing->scale)); else - P_SetOrigin(thing, thing->x, thing->y, tmthing->z + tmthing->height + FixedMul(FRACUNIT, tmthing->scale)); + P_SetOrigin(thing, thing->x, thing->y, tm.thing->z + tm.thing->height + FixedMul(FRACUNIT, tm.thing->scale)); if (thing->flags & MF_SHOOTABLE) - P_DamageMobj(thing, tmthing, tmthing, 1, 0); + P_DamageMobj(thing, tm.thing, tm.thing, 1, 0); return BMIT_CONTINUE; } if (thing->flags & MF_PAIN) { // Player touches painful thing sitting on the floor // see if it went over / under - if (thing->z > tmthing->z + tmthing->height) + if (thing->z > tm.thing->z + tm.thing->height) return BMIT_CONTINUE; // overhead - if (thing->z + thing->height < tmthing->z) + if (thing->z + thing->height < tm.thing->z) return BMIT_CONTINUE; // underneath - if (tmthing->flags & MF_SHOOTABLE && thing->health > 0) + if (tm.thing->flags & MF_SHOOTABLE && thing->health > 0) { UINT32 damagetype = (thing->info->mass & 0xFF); - if (P_DamageMobj(tmthing, thing, thing, 1, damagetype) && (damagetype = (thing->info->mass>>8))) + if (P_DamageMobj(tm.thing, thing, thing, 1, damagetype) && (damagetype = (thing->info->mass>>8))) S_StartSound(thing, damagetype); } return BMIT_CONTINUE; } - else if (tmthing->flags & MF_PAIN && thing->player) + else if (tm.thing->flags & MF_PAIN && thing->player) { // Painful thing splats player in the face // see if it went over / under - if (tmthing->z > thing->z + thing->height) + if (tm.thing->z > thing->z + thing->height) return BMIT_CONTINUE; // overhead - if (tmthing->z + tmthing->height < thing->z) + if (tm.thing->z + tm.thing->height < thing->z) return BMIT_CONTINUE; // underneath - if (thing->flags & MF_SHOOTABLE && tmthing->health > 0) + if (thing->flags & MF_SHOOTABLE && tm.thing->health > 0) { - UINT32 damagetype = (tmthing->info->mass & 0xFF); + UINT32 damagetype = (tm.thing->info->mass & 0xFF); - if (P_DamageMobj(thing, tmthing, tmthing, 1, damagetype) && (damagetype = (tmthing->info->mass>>8))) - S_StartSound(tmthing, damagetype); + if (P_DamageMobj(thing, tm.thing, tm.thing, 1, damagetype) && (damagetype = (tm.thing->info->mass>>8))) + S_StartSound(tm.thing, damagetype); } return BMIT_CONTINUE; } // check for skulls slamming into things - if (tmthing->flags2 & MF2_SKULLFLY) + if (tm.thing->flags2 & MF2_SKULLFLY) { // see if it went over / under - if (tmthing->z > thing->z + thing->height) + if (tm.thing->z > thing->z + thing->height) return BMIT_CONTINUE; // overhead - if (tmthing->z + tmthing->height < thing->z) + if (tm.thing->z + tm.thing->height < thing->z) return BMIT_CONTINUE; // underneath - tmthing->flags2 &= ~MF2_SKULLFLY; - tmthing->momx = tmthing->momy = tmthing->momz = 0; + tm.thing->flags2 &= ~MF2_SKULLFLY; + tm.thing->momx = tm.thing->momy = tm.thing->momz = 0; return BMIT_ABORT; // stop moving } @@ -717,7 +727,7 @@ static BlockItReturn_t PIT_CheckThing(mobj_t *thing) if (thing->type == MT_SHRINK_GUN || thing->type == MT_SHRINK_PARTICLE) { - if (tmthing->type != MT_PLAYER) + if (tm.thing->type != MT_PLAYER) { return BMIT_CONTINUE; } @@ -727,334 +737,334 @@ static BlockItReturn_t PIT_CheckThing(mobj_t *thing) // Use special collision for the laser gun. // The laser sprite itself is just a visual, // the gun itself does the colliding for us. - if (tmthing->z > thing->z) + if (tm.thing->z > thing->z) { return BMIT_CONTINUE; // overhead } - if (tmthing->z + tmthing->height < thing->floorz) + if (tm.thing->z + tm.thing->height < thing->floorz) { return BMIT_CONTINUE; // underneath } } else { - if (tmthing->z > thing->z + thing->height) + if (tm.thing->z > thing->z + thing->height) { return BMIT_CONTINUE; // overhead } - if (tmthing->z + tmthing->height < thing->z) + if (tm.thing->z + tm.thing->height < thing->z) { return BMIT_CONTINUE; // underneath } } - return Obj_ShrinkLaserCollide(thing, tmthing) ? BMIT_CONTINUE : BMIT_ABORT; + return Obj_ShrinkLaserCollide(thing, tm.thing) ? BMIT_CONTINUE : BMIT_ABORT; } - else if (tmthing->type == MT_SHRINK_GUN || tmthing->type == MT_SHRINK_PARTICLE) + else if (tm.thing->type == MT_SHRINK_GUN || tm.thing->type == MT_SHRINK_PARTICLE) { if (thing->type != MT_PLAYER) { return BMIT_CONTINUE; } - if (tmthing->type == MT_SHRINK_GUN) + if (tm.thing->type == MT_SHRINK_GUN) { // Use special collision for the laser gun. // The laser sprite itself is just a visual, // the gun itself does the colliding for us. - if (thing->z > tmthing->z) + if (thing->z > tm.thing->z) { return BMIT_CONTINUE; // overhead } - if (thing->z + thing->height < tmthing->floorz) + if (thing->z + thing->height < tm.thing->floorz) { return BMIT_CONTINUE; // underneath } } else { - if (tmthing->z > thing->z + thing->height) + if (tm.thing->z > thing->z + thing->height) { return BMIT_CONTINUE; // overhead } - if (tmthing->z + tmthing->height < thing->z) + if (tm.thing->z + tm.thing->height < thing->z) { return BMIT_CONTINUE; // underneath } } - return Obj_ShrinkLaserCollide(tmthing, thing) ? BMIT_CONTINUE : BMIT_ABORT; + return Obj_ShrinkLaserCollide(tm.thing, thing) ? BMIT_CONTINUE : BMIT_ABORT; } - if (tmthing->type == MT_SMK_ICEBLOCK) + if (tm.thing->type == MT_SMK_ICEBLOCK) { // see if it went over / under - if (tmthing->z > thing->z + thing->height) + if (tm.thing->z > thing->z + thing->height) return BMIT_CONTINUE; // overhead - if (tmthing->z + tmthing->height < thing->z) + if (tm.thing->z + tm.thing->height < thing->z) return BMIT_CONTINUE; // underneath - return K_SMKIceBlockCollide(tmthing, thing) ? BMIT_CONTINUE : BMIT_ABORT; + return K_SMKIceBlockCollide(tm.thing, thing) ? BMIT_CONTINUE : BMIT_ABORT; } else if (thing->type == MT_SMK_ICEBLOCK) { // see if it went over / under - if (tmthing->z > thing->z + thing->height) + if (tm.thing->z > thing->z + thing->height) return BMIT_CONTINUE; // overhead - if (tmthing->z + tmthing->height < thing->z) + if (tm.thing->z + tm.thing->height < thing->z) return BMIT_CONTINUE; // underneath - return K_SMKIceBlockCollide(thing, tmthing) ? BMIT_CONTINUE : BMIT_ABORT; + return K_SMKIceBlockCollide(thing, tm.thing) ? BMIT_CONTINUE : BMIT_ABORT; } - if (tmthing->type == MT_EGGMANITEM || tmthing->type == MT_EGGMANITEM_SHIELD) + if (tm.thing->type == MT_EGGMANITEM || tm.thing->type == MT_EGGMANITEM_SHIELD) { // see if it went over / under - if (tmthing->z > thing->z + thing->height) + if (tm.thing->z > thing->z + thing->height) return BMIT_CONTINUE; // overhead - if (tmthing->z + tmthing->height < thing->z) + if (tm.thing->z + tm.thing->height < thing->z) return BMIT_CONTINUE; // underneath - return K_EggItemCollide(tmthing, thing) ? BMIT_CONTINUE : BMIT_ABORT; + return K_EggItemCollide(tm.thing, thing) ? BMIT_CONTINUE : BMIT_ABORT; } else if (thing->type == MT_EGGMANITEM || thing->type == MT_EGGMANITEM_SHIELD) { // see if it went over / under - if (tmthing->z > thing->z + thing->height) + if (tm.thing->z > thing->z + thing->height) return BMIT_CONTINUE; // overhead - if (tmthing->z + tmthing->height < thing->z) + if (tm.thing->z + tm.thing->height < thing->z) return BMIT_CONTINUE; // underneath - return K_EggItemCollide(thing, tmthing) ? BMIT_CONTINUE : BMIT_ABORT; + return K_EggItemCollide(thing, tm.thing) ? BMIT_CONTINUE : BMIT_ABORT; } - if (tmthing->type == MT_RANDOMITEM) + if (tm.thing->type == MT_RANDOMITEM) return BMIT_CONTINUE; // Bubble Shield reflect if (((thing->type == MT_BUBBLESHIELD && thing->target->player && thing->target->player->bubbleblowup) || (thing->player && thing->player->bubbleblowup)) - && (tmthing->type == MT_ORBINAUT || tmthing->type == MT_JAWZ - || tmthing->type == MT_BANANA || tmthing->type == MT_EGGMANITEM || tmthing->type == MT_BALLHOG - || tmthing->type == MT_SSMINE || tmthing->type == MT_LANDMINE || tmthing->type == MT_SINK - || tmthing->type == MT_GARDENTOP - || (tmthing->type == MT_PLAYER && thing->target != tmthing))) + && (tm.thing->type == MT_ORBINAUT || tm.thing->type == MT_JAWZ + || tm.thing->type == MT_BANANA || tm.thing->type == MT_EGGMANITEM || tm.thing->type == MT_BALLHOG + || tm.thing->type == MT_SSMINE || tm.thing->type == MT_LANDMINE || tm.thing->type == MT_SINK + || tm.thing->type == MT_GARDENTOP + || (tm.thing->type == MT_PLAYER && thing->target != tm.thing))) { // see if it went over / under - if (tmthing->z > thing->z + thing->height) + if (tm.thing->z > thing->z + thing->height) return BMIT_CONTINUE; // overhead - if (tmthing->z + tmthing->height < thing->z) + if (tm.thing->z + tm.thing->height < thing->z) return BMIT_CONTINUE; // underneath - return K_BubbleShieldCollide(thing, tmthing) ? BMIT_CONTINUE : BMIT_ABORT; + return K_BubbleShieldCollide(thing, tm.thing) ? BMIT_CONTINUE : BMIT_ABORT; } - else if (((tmthing->type == MT_BUBBLESHIELD && tmthing->target->player && tmthing->target->player->bubbleblowup) - || (tmthing->player && tmthing->player->bubbleblowup)) + else if (((tm.thing->type == MT_BUBBLESHIELD && tm.thing->target->player && tm.thing->target->player->bubbleblowup) + || (tm.thing->player && tm.thing->player->bubbleblowup)) && (thing->type == MT_ORBINAUT || thing->type == MT_JAWZ || thing->type == MT_BANANA || thing->type == MT_EGGMANITEM || thing->type == MT_BALLHOG - || thing->type == MT_SSMINE || tmthing->type == MT_LANDMINE || thing->type == MT_SINK + || thing->type == MT_SSMINE || tm.thing->type == MT_LANDMINE || thing->type == MT_SINK || thing->type == MT_GARDENTOP - || (thing->type == MT_PLAYER && tmthing->target != thing))) + || (thing->type == MT_PLAYER && tm.thing->target != thing))) { // see if it went over / under - if (tmthing->z > thing->z + thing->height) + if (tm.thing->z > thing->z + thing->height) return BMIT_CONTINUE; // overhead - if (tmthing->z + tmthing->height < thing->z) + if (tm.thing->z + tm.thing->height < thing->z) return BMIT_CONTINUE; // underneath - return K_BubbleShieldCollide(tmthing, thing) ? BMIT_CONTINUE : BMIT_ABORT; + return K_BubbleShieldCollide(tm.thing, thing) ? BMIT_CONTINUE : BMIT_ABORT; } // double make sure bubbles won't collide with anything else - if (thing->type == MT_BUBBLESHIELD || tmthing->type == MT_BUBBLESHIELD) + if (thing->type == MT_BUBBLESHIELD || tm.thing->type == MT_BUBBLESHIELD) return BMIT_CONTINUE; // Droptarget reflect if ((thing->type == MT_DROPTARGET || thing->type == MT_DROPTARGET_SHIELD) - && (tmthing->type == MT_ORBINAUT || tmthing->type == MT_JAWZ - || tmthing->type == MT_BANANA || tmthing->type == MT_EGGMANITEM || tmthing->type == MT_BALLHOG - || tmthing->type == MT_SSMINE || tmthing->type == MT_LANDMINE || tmthing->type == MT_SINK - || tmthing->type == MT_GARDENTOP - || (tmthing->type == MT_PLAYER))) + && (tm.thing->type == MT_ORBINAUT || tm.thing->type == MT_JAWZ + || tm.thing->type == MT_BANANA || tm.thing->type == MT_EGGMANITEM || tm.thing->type == MT_BALLHOG + || tm.thing->type == MT_SSMINE || tm.thing->type == MT_LANDMINE || tm.thing->type == MT_SINK + || tm.thing->type == MT_GARDENTOP + || (tm.thing->type == MT_PLAYER))) { // see if it went over / under - if (tmthing->z > thing->z + thing->height) + if (tm.thing->z > thing->z + thing->height) return BMIT_CONTINUE; // overhead - if (tmthing->z + tmthing->height < thing->z) + if (tm.thing->z + tm.thing->height < thing->z) return BMIT_CONTINUE; // underneath - return K_DropTargetCollide(thing, tmthing) ? BMIT_CONTINUE : BMIT_ABORT; + return K_DropTargetCollide(thing, tm.thing) ? BMIT_CONTINUE : BMIT_ABORT; } - else if ((tmthing->type == MT_DROPTARGET || tmthing->type == MT_DROPTARGET_SHIELD) + else if ((tm.thing->type == MT_DROPTARGET || tm.thing->type == MT_DROPTARGET_SHIELD) && (thing->type == MT_ORBINAUT || thing->type == MT_JAWZ || thing->type == MT_BANANA || thing->type == MT_EGGMANITEM || thing->type == MT_BALLHOG - || thing->type == MT_SSMINE || tmthing->type == MT_LANDMINE || thing->type == MT_SINK + || thing->type == MT_SSMINE || tm.thing->type == MT_LANDMINE || thing->type == MT_SINK || thing->type == MT_GARDENTOP || (thing->type == MT_PLAYER))) { // see if it went over / under - if (tmthing->z > thing->z + thing->height) + if (tm.thing->z > thing->z + thing->height) return BMIT_CONTINUE; // overhead - if (tmthing->z + tmthing->height < thing->z) + if (tm.thing->z + tm.thing->height < thing->z) return BMIT_CONTINUE; // underneath - return K_DropTargetCollide(tmthing, thing) ? BMIT_CONTINUE : BMIT_ABORT; + return K_DropTargetCollide(tm.thing, thing) ? BMIT_CONTINUE : BMIT_ABORT; } // double make sure drop targets won't collide with anything else - if (thing->type == MT_DROPTARGET || tmthing->type == MT_DROPTARGET - || thing->type == MT_DROPTARGET_SHIELD || tmthing->type == MT_DROPTARGET_SHIELD) + if (thing->type == MT_DROPTARGET || tm.thing->type == MT_DROPTARGET + || thing->type == MT_DROPTARGET_SHIELD || tm.thing->type == MT_DROPTARGET_SHIELD) return BMIT_CONTINUE; - if (tmthing->type == MT_ORBINAUT || tmthing->type == MT_JAWZ - || tmthing->type == MT_ORBINAUT_SHIELD || tmthing->type == MT_JAWZ_SHIELD - || tmthing->type == MT_GARDENTOP) + if (tm.thing->type == MT_ORBINAUT || tm.thing->type == MT_JAWZ + || tm.thing->type == MT_ORBINAUT_SHIELD || tm.thing->type == MT_JAWZ_SHIELD + || tm.thing->type == MT_GARDENTOP) { // see if it went over / under - if (tmthing->z > thing->z + thing->height) + if (tm.thing->z > thing->z + thing->height) return BMIT_CONTINUE; // overhead - if (tmthing->z + tmthing->height < thing->z) + if (tm.thing->z + tm.thing->height < thing->z) return BMIT_CONTINUE; // underneath - return Obj_OrbinautJawzCollide(tmthing, thing) ? BMIT_CONTINUE : BMIT_ABORT; + return Obj_OrbinautJawzCollide(tm.thing, thing) ? BMIT_CONTINUE : BMIT_ABORT; } else if (thing->type == MT_ORBINAUT || thing->type == MT_JAWZ || thing->type == MT_ORBINAUT_SHIELD || thing->type == MT_JAWZ_SHIELD || thing->type == MT_GARDENTOP) { // see if it went over / under - if (tmthing->z > thing->z + thing->height) + if (tm.thing->z > thing->z + thing->height) return BMIT_CONTINUE; // overhead - if (tmthing->z + tmthing->height < thing->z) + if (tm.thing->z + tm.thing->height < thing->z) return BMIT_CONTINUE; // underneath - return Obj_OrbinautJawzCollide(thing, tmthing) ? BMIT_CONTINUE : BMIT_ABORT; + return Obj_OrbinautJawzCollide(thing, tm.thing) ? BMIT_CONTINUE : BMIT_ABORT; } - if (tmthing->type == MT_BANANA || tmthing->type == MT_BANANA_SHIELD || tmthing->type == MT_BALLHOG) + if (tm.thing->type == MT_BANANA || tm.thing->type == MT_BANANA_SHIELD || tm.thing->type == MT_BALLHOG) { // see if it went over / under - if (tmthing->z > thing->z + thing->height) + if (tm.thing->z > thing->z + thing->height) return BMIT_CONTINUE; // overhead - if (tmthing->z + tmthing->height < thing->z) + if (tm.thing->z + tm.thing->height < thing->z) return BMIT_CONTINUE; // underneath - return K_BananaBallhogCollide(tmthing, thing) ? BMIT_CONTINUE : BMIT_ABORT; + return K_BananaBallhogCollide(tm.thing, thing) ? BMIT_CONTINUE : BMIT_ABORT; } else if (thing->type == MT_BANANA || thing->type == MT_BANANA_SHIELD || thing->type == MT_BALLHOG) { // see if it went over / under - if (tmthing->z > thing->z + thing->height) + if (tm.thing->z > thing->z + thing->height) return BMIT_CONTINUE; // overhead - if (tmthing->z + tmthing->height < thing->z) + if (tm.thing->z + tm.thing->height < thing->z) return BMIT_CONTINUE; // underneath - return K_BananaBallhogCollide(thing, tmthing) ? BMIT_CONTINUE : BMIT_ABORT; + return K_BananaBallhogCollide(thing, tm.thing) ? BMIT_CONTINUE : BMIT_ABORT; } - if (tmthing->type == MT_SSMINE || tmthing->type == MT_SSMINE_SHIELD) + if (tm.thing->type == MT_SSMINE || tm.thing->type == MT_SSMINE_SHIELD) { // see if it went over / under - if (tmthing->z > thing->z + thing->height) + if (tm.thing->z > thing->z + thing->height) return BMIT_CONTINUE; // overhead - if (tmthing->z + tmthing->height < thing->z) + if (tm.thing->z + tm.thing->height < thing->z) return BMIT_CONTINUE; // underneath - return K_MineCollide(tmthing, thing) ? BMIT_CONTINUE : BMIT_ABORT; + return K_MineCollide(tm.thing, thing) ? BMIT_CONTINUE : BMIT_ABORT; } else if (thing->type == MT_SSMINE || thing->type == MT_SSMINE_SHIELD) { // see if it went over / under - if (tmthing->z > thing->z + thing->height) + if (tm.thing->z > thing->z + thing->height) return BMIT_CONTINUE; // overhead - if (tmthing->z + tmthing->height < thing->z) + if (tm.thing->z + tm.thing->height < thing->z) return BMIT_CONTINUE; // underneath - return K_MineCollide(thing, tmthing) ? BMIT_CONTINUE : BMIT_ABORT; + return K_MineCollide(thing, tm.thing) ? BMIT_CONTINUE : BMIT_ABORT; } - if (tmthing->type == MT_LANDMINE) + if (tm.thing->type == MT_LANDMINE) { // see if it went over / under - if (tmthing->z > thing->z + thing->height) + if (tm.thing->z > thing->z + thing->height) return BMIT_CONTINUE; // overhead - if (tmthing->z + tmthing->height < thing->z) + if (tm.thing->z + tm.thing->height < thing->z) return BMIT_CONTINUE; // underneath - return K_LandMineCollide(tmthing, thing) ? BMIT_CONTINUE : BMIT_ABORT; + return K_LandMineCollide(tm.thing, thing) ? BMIT_CONTINUE : BMIT_ABORT; } else if (thing->type == MT_LANDMINE) { // see if it went over / under - if (tmthing->z > thing->z + thing->height) + if (tm.thing->z > thing->z + thing->height) return BMIT_CONTINUE; // overhead - if (tmthing->z + tmthing->height < thing->z) + if (tm.thing->z + tm.thing->height < thing->z) return BMIT_CONTINUE; // underneath - return K_LandMineCollide(thing, tmthing) ? BMIT_CONTINUE : BMIT_ABORT; + return K_LandMineCollide(thing, tm.thing) ? BMIT_CONTINUE : BMIT_ABORT; } - if (tmthing->type == MT_SINK) + if (tm.thing->type == MT_SINK) { // see if it went over / under - if (tmthing->z > thing->z + thing->height) + if (tm.thing->z > thing->z + thing->height) return BMIT_CONTINUE; // overhead - if (tmthing->z + tmthing->height < thing->z) + if (tm.thing->z + tm.thing->height < thing->z) return BMIT_CONTINUE; // underneath - return K_KitchenSinkCollide(tmthing, thing) ? BMIT_CONTINUE : BMIT_ABORT; + return K_KitchenSinkCollide(tm.thing, thing) ? BMIT_CONTINUE : BMIT_ABORT; } else if (thing->type == MT_SINK) { // see if it went over / under - if (tmthing->z > thing->z + thing->height) + if (tm.thing->z > thing->z + thing->height) return BMIT_CONTINUE; // overhead - if (tmthing->z + tmthing->height < thing->z) + if (tm.thing->z + tm.thing->height < thing->z) return BMIT_CONTINUE; // underneath - return K_KitchenSinkCollide(thing, tmthing) ? BMIT_CONTINUE : BMIT_ABORT; + return K_KitchenSinkCollide(thing, tm.thing) ? BMIT_CONTINUE : BMIT_ABORT; } - if (tmthing->type == MT_FALLINGROCK) + if (tm.thing->type == MT_FALLINGROCK) { // see if it went over / under - if (tmthing->z > thing->z + thing->height) + if (tm.thing->z > thing->z + thing->height) return BMIT_CONTINUE; // overhead - if (tmthing->z + tmthing->height < thing->z) + if (tm.thing->z + tm.thing->height < thing->z) return BMIT_CONTINUE; // underneath - return K_FallingRockCollide(tmthing, thing) ? BMIT_CONTINUE : BMIT_ABORT; + return K_FallingRockCollide(tm.thing, thing) ? BMIT_CONTINUE : BMIT_ABORT; } else if (thing->type == MT_FALLINGROCK) { // see if it went over / under - if (tmthing->z > thing->z + thing->height) + if (tm.thing->z > thing->z + thing->height) return BMIT_CONTINUE; // overhead - if (tmthing->z + tmthing->height < thing->z) + if (tm.thing->z + tm.thing->height < thing->z) return BMIT_CONTINUE; // underneath - return K_FallingRockCollide(thing, tmthing) ? BMIT_CONTINUE : BMIT_ABORT; + return K_FallingRockCollide(thing, tm.thing) ? BMIT_CONTINUE : BMIT_ABORT; } //} if ((thing->type == MT_SPRINGSHELL || thing->type == MT_YELLOWSHELL) && thing->health > 0 - && (tmthing->player || (tmthing->flags & MF_PUSHABLE)) && tmthing->health > 0) + && (tm.thing->player || (tm.thing->flags & MF_PUSHABLE)) && tm.thing->health > 0) { // Multiplying by -1 inherently flips "less than" and "greater than" - fixed_t tmz = ((thing->eflags & MFE_VERTICALFLIP) ? -(tmthing->z + tmthing->height) : tmthing->z); - fixed_t tmznext = ((thing->eflags & MFE_VERTICALFLIP) ? -tmthing->momz : tmthing->momz) + tmz; + fixed_t tmz = ((thing->eflags & MFE_VERTICALFLIP) ? -(tm.thing->z + tm.thing->height) : tm.thing->z); + fixed_t tmznext = ((thing->eflags & MFE_VERTICALFLIP) ? -tm.thing->momz : tm.thing->momz) + tmz; fixed_t thzh = ((thing->eflags & MFE_VERTICALFLIP) ? -thing->z : thing->z + thing->height); //fixed_t sprarea = FixedMul(8*FRACUNIT, thing->scale) * P_MobjFlip(thing); //if ((tmznext <= thzh && tmz > thzh) || (tmznext > thzh - sprarea && tmznext < thzh)) if (tmznext <= thzh) { - P_DoSpring(thing, tmthing); + P_DoSpring(thing, tm.thing); // return BMIT_CONTINUE; } //else if (tmz > thzh - sprarea && tmz < thzh) // Don't damage people springing up / down @@ -1062,20 +1072,20 @@ static BlockItReturn_t PIT_CheckThing(mobj_t *thing) } // missiles can hit other things - if (tmthing->flags & MF_MISSILE) + if (tm.thing->flags & MF_MISSILE) { - UINT8 damagetype = (tmthing->info->mass ^ DMG_WOMBO); + UINT8 damagetype = (tm.thing->info->mass ^ DMG_WOMBO); // see if it went over / under - if (tmthing->z > thing->z + thing->height) + if (tm.thing->z > thing->z + thing->height) return BMIT_CONTINUE; // overhead - if (tmthing->z + tmthing->height < thing->z) + if (tm.thing->z + tm.thing->height < thing->z) return BMIT_CONTINUE; // underneath - if (tmthing->target && tmthing->target->type == thing->type) + if (tm.thing->target && tm.thing->target->type == thing->type) { // Don't hit same species as originator. - if (thing == tmthing->target) + if (thing == tm.thing->target) return BMIT_CONTINUE; if (thing->type != MT_PLAYER) @@ -1093,40 +1103,40 @@ static BlockItReturn_t PIT_CheckThing(mobj_t *thing) } // damage / explode - P_DamageMobj(thing, tmthing, tmthing->target, 1, damagetype); + P_DamageMobj(thing, tm.thing, tm.thing->target, 1, damagetype); // don't traverse any more return BMIT_ABORT; } - if (thing->flags & MF_PUSHABLE && (tmthing->player || tmthing->flags & MF_PUSHABLE) - && tmthing->z + tmthing->height > thing->z && tmthing->z < thing->z + thing->height - && !(netgame && tmthing->player && tmthing->player->spectator)) // Push thing! + if (thing->flags & MF_PUSHABLE && (tm.thing->player || tm.thing->flags & MF_PUSHABLE) + && tm.thing->z + tm.thing->height > thing->z && tm.thing->z < thing->z + thing->height + && !(netgame && tm.thing->player && tm.thing->player->spectator)) // Push thing! { if (thing->flags2 & MF2_SLIDEPUSH) // Make it slide { - if (tmthing->momy > 0 && tmthing->momy > FixedMul(4*FRACUNIT, thing->scale) && tmthing->momy > thing->momy) + if (tm.thing->momy > 0 && tm.thing->momy > FixedMul(4*FRACUNIT, thing->scale) && tm.thing->momy > thing->momy) { thing->momy += FixedMul(PUSHACCEL, thing->scale); - tmthing->momy -= FixedMul(PUSHACCEL, thing->scale); + tm.thing->momy -= FixedMul(PUSHACCEL, thing->scale); } - else if (tmthing->momy < 0 && tmthing->momy < FixedMul(-4*FRACUNIT, thing->scale) - && tmthing->momy < thing->momy) + else if (tm.thing->momy < 0 && tm.thing->momy < FixedMul(-4*FRACUNIT, thing->scale) + && tm.thing->momy < thing->momy) { thing->momy -= FixedMul(PUSHACCEL, thing->scale); - tmthing->momy += FixedMul(PUSHACCEL, thing->scale); + tm.thing->momy += FixedMul(PUSHACCEL, thing->scale); } - if (tmthing->momx > 0 && tmthing->momx > FixedMul(4*FRACUNIT, thing->scale) - && tmthing->momx > thing->momx) + if (tm.thing->momx > 0 && tm.thing->momx > FixedMul(4*FRACUNIT, thing->scale) + && tm.thing->momx > thing->momx) { thing->momx += FixedMul(PUSHACCEL, thing->scale); - tmthing->momx -= FixedMul(PUSHACCEL, thing->scale); + tm.thing->momx -= FixedMul(PUSHACCEL, thing->scale); } - else if (tmthing->momx < 0 && tmthing->momx < FixedMul(-4*FRACUNIT, thing->scale) - && tmthing->momx < thing->momx) + else if (tm.thing->momx < 0 && tm.thing->momx < FixedMul(-4*FRACUNIT, thing->scale) + && tm.thing->momx < thing->momx) { thing->momx -= FixedMul(PUSHACCEL, thing->scale); - tmthing->momx += FixedMul(PUSHACCEL, thing->scale); + tm.thing->momx += FixedMul(PUSHACCEL, thing->scale); } if (thing->momx > FixedMul(thing->info->speed, thing->scale)) @@ -1140,88 +1150,88 @@ static BlockItReturn_t PIT_CheckThing(mobj_t *thing) } else { - if (tmthing->momx > FixedMul(4*FRACUNIT, thing->scale)) - tmthing->momx = FixedMul(4*FRACUNIT, thing->scale); - else if (tmthing->momx < FixedMul(-4*FRACUNIT, thing->scale)) - tmthing->momx = FixedMul(-4*FRACUNIT, thing->scale); - if (tmthing->momy > FixedMul(4*FRACUNIT, thing->scale)) - tmthing->momy = FixedMul(4*FRACUNIT, thing->scale); - else if (tmthing->momy < FixedMul(-4*FRACUNIT, thing->scale)) - tmthing->momy = FixedMul(-4*FRACUNIT, thing->scale); + if (tm.thing->momx > FixedMul(4*FRACUNIT, thing->scale)) + tm.thing->momx = FixedMul(4*FRACUNIT, thing->scale); + else if (tm.thing->momx < FixedMul(-4*FRACUNIT, thing->scale)) + tm.thing->momx = FixedMul(-4*FRACUNIT, thing->scale); + if (tm.thing->momy > FixedMul(4*FRACUNIT, thing->scale)) + tm.thing->momy = FixedMul(4*FRACUNIT, thing->scale); + else if (tm.thing->momy < FixedMul(-4*FRACUNIT, thing->scale)) + tm.thing->momy = FixedMul(-4*FRACUNIT, thing->scale); - thing->momx = tmthing->momx; - thing->momy = tmthing->momy; + thing->momx = tm.thing->momx; + thing->momy = tm.thing->momy; } if (thing->type != MT_GARGOYLE || P_IsObjectOnGround(thing)) S_StartSound(thing, thing->info->activesound); - P_SetTarget(&thing->target, tmthing); + P_SetTarget(&thing->target, tm.thing); } // check for special pickup - if (thing->flags & MF_SPECIAL && tmthing->player) + if (thing->flags & MF_SPECIAL && tm.thing->player) { - P_TouchSpecialThing(thing, tmthing, true); // can remove thing + P_TouchSpecialThing(thing, tm.thing, true); // can remove thing return BMIT_CONTINUE; } // check again for special pickup - if (tmthing->flags & MF_SPECIAL && thing->player) + if (tm.thing->flags & MF_SPECIAL && thing->player) { - P_TouchSpecialThing(tmthing, thing, true); // can remove thing + P_TouchSpecialThing(tm.thing, thing, true); // can remove thing return BMIT_CONTINUE; } // Sprite Spikes! // Do not return because solidity code comes below. - if (tmthing->type == MT_SPIKE && tmthing->flags & MF_SOLID && thing->player) // moving spike rams into player?! + if (tm.thing->type == MT_SPIKE && tm.thing->flags & MF_SOLID && thing->player) // moving spike rams into player?! { - if (tmthing->eflags & MFE_VERTICALFLIP) + if (tm.thing->eflags & MFE_VERTICALFLIP) { - if (thing->z + thing->height <= tmthing->z + FixedMul(FRACUNIT, tmthing->scale) - && thing->z + thing->height + thing->momz >= tmthing->z + FixedMul(FRACUNIT, tmthing->scale) + tmthing->momz) - P_DamageMobj(thing, tmthing, tmthing, 1, DMG_NORMAL); + if (thing->z + thing->height <= tm.thing->z + FixedMul(FRACUNIT, tm.thing->scale) + && thing->z + thing->height + thing->momz >= tm.thing->z + FixedMul(FRACUNIT, tm.thing->scale) + tm.thing->momz) + P_DamageMobj(thing, tm.thing, tm.thing, 1, DMG_NORMAL); } - else if (thing->z >= tmthing->z + tmthing->height - FixedMul(FRACUNIT, tmthing->scale) - && thing->z + thing->momz <= tmthing->z + tmthing->height - FixedMul(FRACUNIT, tmthing->scale) + tmthing->momz) - P_DamageMobj(thing, tmthing, tmthing, 1, DMG_NORMAL); + else if (thing->z >= tm.thing->z + tm.thing->height - FixedMul(FRACUNIT, tm.thing->scale) + && thing->z + thing->momz <= tm.thing->z + tm.thing->height - FixedMul(FRACUNIT, tm.thing->scale) + tm.thing->momz) + P_DamageMobj(thing, tm.thing, tm.thing, 1, DMG_NORMAL); } - else if (thing->type == MT_SPIKE && thing->flags & MF_SOLID && tmthing->player) // unfortunate player falls into spike?! + else if (thing->type == MT_SPIKE && thing->flags & MF_SOLID && tm.thing->player) // unfortunate player falls into spike?! { if (thing->eflags & MFE_VERTICALFLIP) { - if (tmthing->z + tmthing->height <= thing->z - FixedMul(FRACUNIT, thing->scale) - && tmthing->z + tmthing->height + tmthing->momz >= thing->z - FixedMul(FRACUNIT, thing->scale)) - P_DamageMobj(tmthing, thing, thing, 1, DMG_NORMAL); + if (tm.thing->z + tm.thing->height <= thing->z - FixedMul(FRACUNIT, thing->scale) + && tm.thing->z + tm.thing->height + tm.thing->momz >= thing->z - FixedMul(FRACUNIT, thing->scale)) + P_DamageMobj(tm.thing, thing, thing, 1, DMG_NORMAL); } - else if (tmthing->z >= thing->z + thing->height + FixedMul(FRACUNIT, thing->scale) - && tmthing->z + tmthing->momz <= thing->z + thing->height + FixedMul(FRACUNIT, thing->scale)) - P_DamageMobj(tmthing, thing, thing, 1, DMG_NORMAL); + else if (tm.thing->z >= thing->z + thing->height + FixedMul(FRACUNIT, thing->scale) + && tm.thing->z + tm.thing->momz <= thing->z + thing->height + FixedMul(FRACUNIT, thing->scale)) + P_DamageMobj(tm.thing, thing, thing, 1, DMG_NORMAL); } - if (tmthing->type == MT_WALLSPIKE && tmthing->flags & MF_SOLID && thing->player) // wall spike impales player + if (tm.thing->type == MT_WALLSPIKE && tm.thing->flags & MF_SOLID && thing->player) // wall spike impales player { fixed_t bottomz, topz; - bottomz = tmthing->z; - topz = tmthing->z + tmthing->height; - if (tmthing->eflags & MFE_VERTICALFLIP) - bottomz -= FixedMul(FRACUNIT, tmthing->scale); + bottomz = tm.thing->z; + topz = tm.thing->z + tm.thing->height; + if (tm.thing->eflags & MFE_VERTICALFLIP) + bottomz -= FixedMul(FRACUNIT, tm.thing->scale); else - topz += FixedMul(FRACUNIT, tmthing->scale); + topz += FixedMul(FRACUNIT, tm.thing->scale); if (thing->z + thing->height > bottomz // above bottom && thing->z < topz) // below top // don't check angle, the player was clearly in the way in this case - P_DamageMobj(thing, tmthing, tmthing, 1, DMG_NORMAL); + P_DamageMobj(thing, tm.thing, tm.thing, 1, DMG_NORMAL); } - else if (thing->type == MT_WALLSPIKE && thing->flags & MF_SOLID && tmthing->player) + else if (thing->type == MT_WALLSPIKE && thing->flags & MF_SOLID && tm.thing->player) { fixed_t bottomz, topz; - angle_t touchangle = R_PointToAngle2(thing->tracer->x, thing->tracer->y, tmthing->x, tmthing->y); + angle_t touchangle = R_PointToAngle2(thing->tracer->x, thing->tracer->y, tm.thing->x, tm.thing->y); - if (P_PlayerInPain(tmthing->player) && (tmthing->momx || tmthing->momy)) + if (P_PlayerInPain(tm.thing->player) && (tm.thing->momx || tm.thing->momy)) { - angle_t playerangle = R_PointToAngle2(0, 0, tmthing->momx, tmthing->momy) - touchangle; + angle_t playerangle = R_PointToAngle2(0, 0, tm.thing->momx, tm.thing->momy) - touchangle; if (playerangle > ANGLE_180) playerangle = InvAngle(playerangle); if (playerangle < ANGLE_90) @@ -1236,103 +1246,103 @@ static BlockItReturn_t PIT_CheckThing(mobj_t *thing) else topz += FixedMul(FRACUNIT, thing->scale); - if (tmthing->z + tmthing->height > bottomz // above bottom - && tmthing->z < topz // below top + if (tm.thing->z + tm.thing->height > bottomz // above bottom + && tm.thing->z < topz // below top && !P_MobjWasRemoved(thing->tracer)) // this probably wouldn't work if we didn't have a tracer { // use base as a reference point to determine what angle you touched the spike at touchangle = thing->angle - touchangle; if (touchangle > ANGLE_180) touchangle = InvAngle(touchangle); if (touchangle <= ANGLE_22h) // if you touched it at this close an angle, you get poked! - P_DamageMobj(tmthing, thing, thing, 1, DMG_NORMAL); + P_DamageMobj(tm.thing, thing, thing, 1, DMG_NORMAL); } } if (thing->flags & MF_PUSHABLE) { - if (tmthing->type == MT_FAN || tmthing->type == MT_STEAM) - P_DoFanAndGasJet(tmthing, thing); + if (tm.thing->type == MT_FAN || tm.thing->type == MT_STEAM) + P_DoFanAndGasJet(tm.thing, thing); } - if (tmthing->flags & MF_PUSHABLE) + if (tm.thing->flags & MF_PUSHABLE) { if (thing->type == MT_FAN || thing->type == MT_STEAM) { - P_DoFanAndGasJet(thing, tmthing); + P_DoFanAndGasJet(thing, tm.thing); return BMIT_CONTINUE; } else if (thing->flags & MF_SPRING) { - if ( thing->z <= tmthing->z + tmthing->height - && tmthing->z <= thing->z + thing->height) - if (P_DoSpring(thing, tmthing)) + if ( thing->z <= tm.thing->z + tm.thing->height + && tm.thing->z <= thing->z + thing->height) + if (P_DoSpring(thing, tm.thing)) return BMIT_ABORT; return BMIT_CONTINUE; } } // thanks to sal for solidenemies dot lua - if (thing->flags & (MF_ENEMY|MF_BOSS) && tmthing->flags & (MF_ENEMY|MF_BOSS)) + if (thing->flags & (MF_ENEMY|MF_BOSS) && tm.thing->flags & (MF_ENEMY|MF_BOSS)) { - if ((thing->z + thing->height >= tmthing->z) - && (tmthing->z + tmthing->height >= thing->z)) + if ((thing->z + thing->height >= tm.thing->z) + && (tm.thing->z + tm.thing->height >= thing->z)) return BMIT_ABORT; } if (thing->player) { - if (tmthing->type == MT_FAN || tmthing->type == MT_STEAM) - P_DoFanAndGasJet(tmthing, thing); + if (tm.thing->type == MT_FAN || tm.thing->type == MT_STEAM) + P_DoFanAndGasJet(tm.thing, thing); } - if (tmthing->player) // Is the moving/interacting object the player? + if (tm.thing->player) // Is the moving/interacting object the player? { - if (!tmthing->health) + if (!tm.thing->health) return BMIT_CONTINUE; if (thing->type == MT_FAN || thing->type == MT_STEAM) - P_DoFanAndGasJet(thing, tmthing); + P_DoFanAndGasJet(thing, tm.thing); else if (thing->flags & MF_SPRING) { - if ( thing->z <= tmthing->z + tmthing->height - && tmthing->z <= thing->z + thing->height) - if (P_DoSpring(thing, tmthing)) + if ( thing->z <= tm.thing->z + tm.thing->height + && tm.thing->z <= thing->z + thing->height) + if (P_DoSpring(thing, tm.thing)) return BMIT_ABORT; return BMIT_CONTINUE; } else if (thing->player) // bounce when players collide { // see if it went over / under - if (tmthing->z > thing->z + thing->height) + if (tm.thing->z > thing->z + thing->height) return BMIT_CONTINUE; // overhead - if (tmthing->z + tmthing->height < thing->z) + if (tm.thing->z + tm.thing->height < thing->z) return BMIT_CONTINUE; // underneath - if (thing->player->hyudorotimer || tmthing->player->hyudorotimer) + if (thing->player->hyudorotimer || tm.thing->player->hyudorotimer) { return BMIT_CONTINUE; } if ((gametyperules & GTR_BUMPERS) - && ((thing->player->bumpers && !tmthing->player->bumpers) - || (tmthing->player->bumpers && !thing->player->bumpers))) + && ((thing->player->bumpers && !tm.thing->player->bumpers) + || (tm.thing->player->bumpers && !thing->player->bumpers))) { return BMIT_CONTINUE; } // The bump has to happen last - if (P_IsObjectOnGround(thing) && tmthing->momz < 0 && tmthing->player->trickpanel) + if (P_IsObjectOnGround(thing) && tm.thing->momz < 0 && tm.thing->player->trickpanel) { - P_DamageMobj(thing, tmthing, tmthing, 1, DMG_WIPEOUT|DMG_STEAL); + P_DamageMobj(thing, tm.thing, tm.thing, 1, DMG_WIPEOUT|DMG_STEAL); } - else if (P_IsObjectOnGround(tmthing) && thing->momz < 0 && thing->player->trickpanel) + else if (P_IsObjectOnGround(tm.thing) && thing->momz < 0 && thing->player->trickpanel) { - P_DamageMobj(tmthing, thing, thing, 1, DMG_WIPEOUT|DMG_STEAL); + P_DamageMobj(tm.thing, thing, thing, 1, DMG_WIPEOUT|DMG_STEAL); } - if (K_KartBouncing(tmthing, thing) == true) + if (K_KartBouncing(tm.thing, thing) == true) { - K_PvPTouchDamage(tmthing, thing); + K_PvPTouchDamage(tm.thing, thing); } return BMIT_CONTINUE; @@ -1340,48 +1350,48 @@ static BlockItReturn_t PIT_CheckThing(mobj_t *thing) else if (thing->type == MT_BLUEROBRA_HEAD || thing->type == MT_BLUEROBRA_JOINT) { // see if it went over / under - if (tmthing->z > thing->z + thing->height) + if (tm.thing->z > thing->z + thing->height) return BMIT_CONTINUE; // overhead - if (tmthing->z + tmthing->height < thing->z) + if (tm.thing->z + tm.thing->height < thing->z) return BMIT_CONTINUE; // underneath if (!thing->health) return BMIT_CONTINUE; // dead - if (tmthing->player->invincibilitytimer > 0 - || K_IsBigger(tmthing, thing) == true) + if (tm.thing->player->invincibilitytimer > 0 + || K_IsBigger(tm.thing, thing) == true) { if (thing->type == MT_BLUEROBRA_JOINT) - P_KillMobj(thing->target, tmthing, tmthing, DMG_NORMAL); + P_KillMobj(thing->target, tm.thing, tm.thing, DMG_NORMAL); else - P_KillMobj(thing, tmthing, tmthing, DMG_NORMAL); + P_KillMobj(thing, tm.thing, tm.thing, DMG_NORMAL); return BMIT_CONTINUE; } else { - K_KartSolidBounce(tmthing, thing); + K_KartSolidBounce(tm.thing, thing); return BMIT_CONTINUE; } } else if (thing->type == MT_SMK_PIPE) { // see if it went over / under - if (tmthing->z > thing->z + thing->height) + if (tm.thing->z > thing->z + thing->height) return BMIT_CONTINUE; // overhead - if (tmthing->z + tmthing->height < thing->z) + if (tm.thing->z + tm.thing->height < thing->z) return BMIT_CONTINUE; // underneath if (!thing->health) return BMIT_CONTINUE; // dead - if (tmthing->player->invincibilitytimer > 0 - || K_IsBigger(tmthing, thing) == true) + if (tm.thing->player->invincibilitytimer > 0 + || K_IsBigger(tm.thing, thing) == true) { - P_KillMobj(thing, tmthing, tmthing, DMG_NORMAL); + P_KillMobj(thing, tm.thing, tm.thing, DMG_NORMAL); return BMIT_CONTINUE; // kill } - K_KartSolidBounce(tmthing, thing); + K_KartSolidBounce(tm.thing, thing); return BMIT_CONTINUE; } else if (thing->type == MT_SMK_THWOMP) @@ -1392,38 +1402,38 @@ static BlockItReturn_t PIT_CheckThing(mobj_t *thing) if (!thwompsactive) return BMIT_CONTINUE; // not active yet - if ((tmthing->z < thing->z) && (thing->z >= thing->movefactor-(256<z < thing->z) && (thing->z >= thing->movefactor-(256<extravalue1 = 1; // purposely try to stomp on players early //S_StartSound(thing, sfx_s1bb); } // see if it went over / under - if (tmthing->z > thing->z + thing->height) + if (tm.thing->z > thing->z + thing->height) return BMIT_CONTINUE; // overhead - if (tmthing->z + tmthing->height < thing->z) + if (tm.thing->z + tm.thing->height < thing->z) return BMIT_CONTINUE; // underneath // kill - if (tmthing->player->invincibilitytimer > 0 - || K_IsBigger(tmthing, thing) == true) + if (tm.thing->player->invincibilitytimer > 0 + || K_IsBigger(tm.thing, thing) == true) { - P_KillMobj(thing, tmthing, tmthing, DMG_NORMAL); + P_KillMobj(thing, tm.thing, tm.thing, DMG_NORMAL); return BMIT_CONTINUE; } // no interaction - if (tmthing->player->flashing > 0 || tmthing->player->hyudorotimer > 0 || tmthing->player->spinouttimer > 0) + if (tm.thing->player->flashing > 0 || tm.thing->player->hyudorotimer > 0 || tm.thing->player->spinouttimer > 0) return BMIT_CONTINUE; // collide - if (tmthing->z < thing->z && thing->momz < 0) - P_DamageMobj(tmthing, thing, thing, 1, DMG_TUMBLE); + if (tm.thing->z < thing->z && thing->momz < 0) + P_DamageMobj(tm.thing, thing, thing, 1, DMG_TUMBLE); else { - if ((K_KartSolidBounce(tmthing, thing) == true) && (thing->flags2 & MF2_AMBUSH)) + if ((K_KartSolidBounce(tm.thing, thing) == true) && (thing->flags2 & MF2_AMBUSH)) { - P_DamageMobj(tmthing, thing, thing, 1, DMG_WIPEOUT); + P_DamageMobj(tm.thing, thing, thing, 1, DMG_WIPEOUT); } } @@ -1432,49 +1442,49 @@ static BlockItReturn_t PIT_CheckThing(mobj_t *thing) else if (thing->type == MT_KART_LEFTOVER) { // see if it went over / under - if (tmthing->z > thing->z + thing->height) + if (tm.thing->z > thing->z + thing->height) return BMIT_CONTINUE; // overhead - if (tmthing->z + tmthing->height < thing->z) + if (tm.thing->z + tm.thing->height < thing->z) return BMIT_CONTINUE; // underneath - K_KartBouncing(tmthing, thing); + K_KartBouncing(tm.thing, thing); return BMIT_CONTINUE; } else if (thing->flags & MF_SOLID) { // see if it went over / under - if (tmthing->z > thing->z + thing->height) + if (tm.thing->z > thing->z + thing->height) return BMIT_CONTINUE; // overhead - if (tmthing->z + tmthing->height < thing->z) + if (tm.thing->z + tm.thing->height < thing->z) return BMIT_CONTINUE; // underneath - K_KartSolidBounce(tmthing, thing); + K_KartSolidBounce(tm.thing, thing); return BMIT_CONTINUE; } } - if ((tmthing->flags & MF_SPRING || tmthing->type == MT_STEAM || tmthing->type == MT_SPIKE || tmthing->type == MT_WALLSPIKE) && (thing->player)) + if ((tm.thing->flags & MF_SPRING || tm.thing->type == MT_STEAM || tm.thing->type == MT_SPIKE || tm.thing->type == MT_WALLSPIKE) && (thing->player)) ; // springs, gas jets and springs should never be able to step up onto a player // z checking at last // Treat noclip things as non-solid! else if ((thing->flags & (MF_SOLID|MF_NOCLIP)) == MF_SOLID - && (tmthing->flags & (MF_SOLID|MF_NOCLIP)) == MF_SOLID) + && (tm.thing->flags & (MF_SOLID|MF_NOCLIP)) == MF_SOLID) { fixed_t topz, tmtopz; - if (tmthing->eflags & MFE_VERTICALFLIP) + if (tm.thing->eflags & MFE_VERTICALFLIP) { // pass under - tmtopz = tmthing->z; + tmtopz = tm.thing->z; if (tmtopz > thing->z + thing->height) { - if (thing->z + thing->height > tmfloorz) + if (thing->z + thing->height > tm.floorz) { - tmfloorz = thing->z + thing->height; - tmfloorrover = NULL; - tmfloorslope = NULL; - tmfloorpic = -1; + tm.floorz = thing->z + thing->height; + tm.floorrover = NULL; + tm.floorslope = NULL; + tm.floorpic = -1; } return BMIT_CONTINUE; } @@ -1485,40 +1495,40 @@ static BlockItReturn_t PIT_CheckThing(mobj_t *thing) // (dont climb max. 24units while already in air) // since return false doesn't handle momentum properly, // we lie to P_TryMove() so it's always too high - if (tmthing->player && tmthing->z + tmthing->height > topz - && tmthing->z + tmthing->height < tmthing->ceilingz) + if (tm.thing->player && tm.thing->z + tm.thing->height > topz + && tm.thing->z + tm.thing->height < tm.thing->ceilingz) { if (thing->flags & MF_GRENADEBOUNCE && (thing->flags & MF_MONITOR || thing->info->flags & MF_MONITOR)) // Gold monitor hack... return BMIT_ABORT; - tmfloorz = tmceilingz = topz; // block while in air - tmceilingrover = NULL; - tmceilingslope = NULL; - tmceilingpic = -1; - tmfloorthing = thing; // needed for side collision + tm.floorz = tm.ceilingz = topz; // block while in air + tm.ceilingrover = NULL; + tm.ceilingslope = NULL; + tm.ceilingpic = -1; + P_SetTarget(&tm.floorthing, thing); // needed for side collision } - else if (topz < tmceilingz && tmthing->z <= thing->z+thing->height) + else if (topz < tm.ceilingz && tm.thing->z <= thing->z+thing->height) { - tmceilingz = topz; - tmceilingrover = NULL; - tmceilingslope = NULL; - tmceilingpic = -1; - tmfloorthing = thing; // thing we may stand on + tm.ceilingz = topz; + tm.ceilingrover = NULL; + tm.ceilingslope = NULL; + tm.ceilingpic = -1; + P_SetTarget(&tm.floorthing, thing); // thing we may stand on } } else { // pass under - tmtopz = tmthing->z + tmthing->height; + tmtopz = tm.thing->z + tm.thing->height; if (tmtopz < thing->z) { - if (thing->z < tmceilingz) + if (thing->z < tm.ceilingz) { - tmceilingz = thing->z; - tmceilingrover = NULL; - tmceilingslope = NULL; - tmceilingpic = -1; + tm.ceilingz = thing->z; + tm.ceilingrover = NULL; + tm.ceilingslope = NULL; + tm.ceilingpic = -1; } return BMIT_CONTINUE; } @@ -1529,25 +1539,25 @@ static BlockItReturn_t PIT_CheckThing(mobj_t *thing) // (dont climb max. 24units while already in air) // since return false doesn't handle momentum properly, // we lie to P_TryMove() so it's always too high - if (tmthing->player && tmthing->z < topz - && tmthing->z > tmthing->floorz) + if (tm.thing->player && tm.thing->z < topz + && tm.thing->z > tm.thing->floorz) { if (thing->flags & MF_GRENADEBOUNCE && (thing->flags & MF_MONITOR || thing->info->flags & MF_MONITOR)) // Gold monitor hack... return BMIT_ABORT; - tmfloorz = tmceilingz = topz; // block while in air - tmfloorrover = NULL; - tmfloorslope = NULL; - tmfloorpic = -1; - tmfloorthing = thing; // needed for side collision + tm.floorz = tm.ceilingz = topz; // block while in air + tm.floorrover = NULL; + tm.floorslope = NULL; + tm.floorpic = -1; + P_SetTarget(&tm.floorthing, thing); // needed for side collision } - else if (topz > tmfloorz && tmthing->z+tmthing->height >= thing->z) + else if (topz > tm.floorz && tm.thing->z+tm.thing->height >= thing->z) { - tmfloorz = topz; - tmfloorrover = NULL; - tmfloorslope = NULL; - tmfloorpic = -1; - tmfloorthing = thing; // thing we may stand on + tm.floorz = topz; + tm.floorrover = NULL; + tm.floorslope = NULL; + tm.floorpic = -1; + P_SetTarget(&tm.floorthing, thing); // thing we may stand on } } } @@ -1557,19 +1567,19 @@ static BlockItReturn_t PIT_CheckThing(mobj_t *thing) } // PIT_CheckCameraLine -// Adjusts tmfloorz and tmceilingz as lines are contacted - FOR CAMERA ONLY +// Adjusts tm.floorz and tm.ceilingz as lines are contacted - FOR CAMERA ONLY static BlockItReturn_t PIT_CheckCameraLine(line_t *ld) { if (ld->polyobj && !(ld->polyobj->flags & POF_SOLID)) return BMIT_CONTINUE; - if (tmbbox[BOXRIGHT] <= ld->bbox[BOXLEFT] || tmbbox[BOXLEFT] >= ld->bbox[BOXRIGHT] - || tmbbox[BOXTOP] <= ld->bbox[BOXBOTTOM] || tmbbox[BOXBOTTOM] >= ld->bbox[BOXTOP]) + if (tm.bbox[BOXRIGHT] <= ld->bbox[BOXLEFT] || tm.bbox[BOXLEFT] >= ld->bbox[BOXRIGHT] + || tm.bbox[BOXTOP] <= ld->bbox[BOXBOTTOM] || tm.bbox[BOXBOTTOM] >= ld->bbox[BOXTOP]) { return BMIT_CONTINUE; } - if (P_BoxOnLineSide(tmbbox, ld) != -1) + if (P_BoxOnLineSide(tm.bbox, ld) != -1) return BMIT_CONTINUE; // A line has been hit @@ -1584,7 +1594,7 @@ static BlockItReturn_t PIT_CheckCameraLine(line_t *ld) // could be crossed in either order. // this line is out of the if so upper and lower textures can be hit by a splat - blockingline = ld; + tm.blockingline = ld; if (!ld->backsector) // one sided line { if (P_PointOnLineSide(mapcampointer->x, mapcampointer->y, ld)) @@ -1596,22 +1606,22 @@ static BlockItReturn_t PIT_CheckCameraLine(line_t *ld) P_CameraLineOpening(ld); // adjust floor / ceiling heights - if (opentop < tmceilingz) + if (opentop < tm.ceilingz) { - tmceilingz = opentop; - ceilingline = ld; + tm.ceilingz = opentop; + tm.ceilingline = ld; } - if (openbottom > tmfloorz) + if (openbottom > tm.floorz) { - tmfloorz = openbottom; + tm.floorz = openbottom; } - if (highceiling > tmdrpoffceilz) - tmdrpoffceilz = highceiling; + if (highceiling > tm.drpoffceilz) + tm.drpoffceilz = highceiling; - if (lowfloor < tmdropoffz) - tmdropoffz = lowfloor; + if (lowfloor < tm.dropoffz) + tm.dropoffz = lowfloor; return BMIT_CONTINUE; } @@ -1657,44 +1667,44 @@ boolean P_IsLineTripWire(const line_t *ld) // // PIT_CheckLine -// Adjusts tmfloorz and tmceilingz as lines are contacted +// Adjusts tm.floorz and tm.ceilingz as lines are contacted // static BlockItReturn_t PIT_CheckLine(line_t *ld) { - const fixed_t thingtop = tmthing->z + tmthing->height; + const fixed_t thingtop = tm.thing->z + tm.thing->height; if (ld->polyobj && !(ld->polyobj->flags & POF_SOLID)) return BMIT_CONTINUE; - if (tmbbox[BOXRIGHT] <= ld->bbox[BOXLEFT] || tmbbox[BOXLEFT] >= ld->bbox[BOXRIGHT] - || tmbbox[BOXTOP] <= ld->bbox[BOXBOTTOM] || tmbbox[BOXBOTTOM] >= ld->bbox[BOXTOP]) + if (tm.bbox[BOXRIGHT] <= ld->bbox[BOXLEFT] || tm.bbox[BOXLEFT] >= ld->bbox[BOXRIGHT] + || tm.bbox[BOXTOP] <= ld->bbox[BOXBOTTOM] || tm.bbox[BOXBOTTOM] >= ld->bbox[BOXTOP]) return BMIT_CONTINUE; - if (P_BoxOnLineSide(tmbbox, ld) != -1) + if (P_BoxOnLineSide(tm.bbox, ld) != -1) return BMIT_CONTINUE; - if (tmthing->flags & MF_PAPERCOLLISION) // Caution! Turning whilst up against a wall will get you stuck. You probably shouldn't give the player this flag. + if (tm.thing->flags & MF_PAPERCOLLISION) // Caution! Turning whilst up against a wall will get you stuck. You probably shouldn't give the player this flag. { fixed_t cosradius, sinradius; - cosradius = FixedMul(tmthing->radius, FINECOSINE(tmthing->angle>>ANGLETOFINESHIFT)); - sinradius = FixedMul(tmthing->radius, FINESINE(tmthing->angle>>ANGLETOFINESHIFT)); - if (P_PointOnLineSide(tmx - cosradius, tmy - sinradius, ld) - == P_PointOnLineSide(tmx + cosradius, tmy + sinradius, ld)) + cosradius = FixedMul(tm.thing->radius, FINECOSINE(tm.thing->angle>>ANGLETOFINESHIFT)); + sinradius = FixedMul(tm.thing->radius, FINESINE(tm.thing->angle>>ANGLETOFINESHIFT)); + if (P_PointOnLineSide(tm.x - cosradius, tm.y - sinradius, ld) + == P_PointOnLineSide(tm.x + cosradius, tm.y + sinradius, ld)) return BMIT_CONTINUE; // the line doesn't cross between collider's start or end #ifdef PAPER_COLLISIONCORRECTION { fixed_t dist; vertex_t result; angle_t langle; - P_ClosestPointOnLine(tmx, tmy, ld, &result); + P_ClosestPointOnLine(tm.x, tm.y, ld, &result); langle = R_PointToAngle2(ld->v1->x, ld->v1->y, ld->v2->x, ld->v2->y); - langle += ANGLE_90*(P_PointOnLineSide(tmx, tmy, ld) ? -1 : 1); - dist = abs(FixedMul(tmthing->radius, FINECOSINE((tmthing->angle - langle)>>ANGLETOFINESHIFT))); + langle += ANGLE_90*(P_PointOnLineSide(tm.x, tm.y, ld) ? -1 : 1); + dist = abs(FixedMul(tm.thing->radius, FINECOSINE((tm.thing->angle - langle)>>ANGLETOFINESHIFT))); cosradius = FixedMul(dist, FINECOSINE(langle>>ANGLETOFINESHIFT)); sinradius = FixedMul(dist, FINESINE(langle>>ANGLETOFINESHIFT)); - tmthing->flags |= MF_NOCLIP; - P_MoveOrigin(tmthing, result.x + cosradius - tmthing->momx, result.y + sinradius - tmthing->momy, tmthing->z); - tmthing->flags &= ~MF_NOCLIP; + tm.thing->flags |= MF_NOCLIP; + P_MoveOrigin(tm.thing, result.x + cosradius - tm.thing->momx, result.y + sinradius - tm.thing->momy, tm.thing->z); + tm.thing->flags &= ~MF_NOCLIP; } #endif } @@ -1711,11 +1721,11 @@ static BlockItReturn_t PIT_CheckLine(line_t *ld) // could be crossed in either order. // this line is out of the if so upper and lower textures can be hit by a splat - blockingline = ld; + tm.blockingline = ld; { - UINT8 shouldCollide = LUA_HookMobjLineCollide(tmthing, blockingline); // checks hook for thing's type - if (P_MobjWasRemoved(tmthing)) + UINT8 shouldCollide = LUA_HookMobjLineCollide(tm.thing, tm.blockingline); // checks hook for thing's type + if (P_MobjWasRemoved(tm.thing)) return BMIT_CONTINUE; // one of them was removed??? if (shouldCollide == 1) return BMIT_ABORT; // force collide @@ -1725,50 +1735,50 @@ static BlockItReturn_t PIT_CheckLine(line_t *ld) if (!ld->backsector) // one sided line { - if (P_PointOnLineSide(tmthing->x, tmthing->y, ld)) + if (P_PointOnLineSide(tm.thing->x, tm.thing->y, ld)) return BMIT_CONTINUE; // don't hit the back side return BMIT_ABORT; } - if (P_IsLineBlocking(ld, tmthing)) + if (P_IsLineBlocking(ld, tm.thing)) return BMIT_ABORT; // set openrange, opentop, openbottom - P_LineOpening(ld, tmthing); + P_LineOpening(ld, tm.thing); // adjust floor / ceiling heights - if (opentop < tmceilingz) + if (opentop < tm.ceilingz) { - tmceilingz = opentop; - ceilingline = ld; - tmceilingrover = openceilingrover; - tmceilingslope = opentopslope; - tmceilingpic = opentoppic; - tmceilingstep = openceilingstep; - if (thingtop == tmthing->ceilingz) + tm.ceilingz = opentop; + tm.ceilingline = ld; + tm.ceilingrover = openceilingrover; + tm.ceilingslope = opentopslope; + tm.ceilingpic = opentoppic; + tm.ceilingstep = openceilingstep; + if (thingtop == tm.thing->ceilingz) { - tmthing->ceilingdrop = openceilingdrop; + tm.thing->ceilingdrop = openceilingdrop; } } - if (openbottom > tmfloorz) + if (openbottom > tm.floorz) { - tmfloorz = openbottom; - tmfloorrover = openfloorrover; - tmfloorslope = openbottomslope; - tmfloorpic = openbottompic; - tmfloorstep = openfloorstep; - if (tmthing->z == tmthing->floorz) + tm.floorz = openbottom; + tm.floorrover = openfloorrover; + tm.floorslope = openbottomslope; + tm.floorpic = openbottompic; + tm.floorstep = openfloorstep; + if (tm.thing->z == tm.thing->floorz) { - tmthing->floordrop = openfloordrop; + tm.thing->floordrop = openfloordrop; } } - if (highceiling > tmdrpoffceilz) - tmdrpoffceilz = highceiling; + if (highceiling > tm.drpoffceilz) + tm.drpoffceilz = highceiling; - if (lowfloor < tmdropoffz) - tmdropoffz = lowfloor; + if (lowfloor < tm.dropoffz) + tm.dropoffz = lowfloor; // we've crossed the line if (P_SpecialIsLinedefCrossType(ld)) @@ -1779,14 +1789,14 @@ static BlockItReturn_t PIT_CheckLine(line_t *ld) { fixed_t textop, texbottom; - P_GetMidtextureTopBottom(ld, tmx, tmy, + P_GetMidtextureTopBottom(ld, tm.x, tm.y, &textop, &texbottom); /* The effect handling is done later but it won't know the height values anymore. So don't even add this line to the list unless this thing clips the tripwire's midtexture. */ - if (tmthing->z <= textop && thingtop >= texbottom) + if (tm.thing->z <= textop && thingtop >= texbottom) add_spechit(ld); } @@ -1813,20 +1823,20 @@ static BlockItReturn_t PIT_CheckLine(line_t *ld) // // out: // newsubsec -// tmfloorz -// tmceilingz -// tmdropoffz -// tmdrpoffceilz +// tm.floorz +// tm.ceilingz +// tm.dropoffz +// tm.drpoffceilz // the lowest point contacted // (monsters won't move to a dropoff) // speciallines[] // numspeciallines // -// tmfloorz -// the nearest floor or thing's top under tmthing -// tmceilingz -// the nearest ceiling or thing's bottom over tmthing +// tm.floorz +// the nearest floor or thing's top under tm.thing +// tm.ceilingz +// the nearest ceiling or thing's bottom over tm.thing // boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) { @@ -1843,35 +1853,35 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) I_Error("Previously-removed Thing of type %u crashes P_CheckPosition!", thing->type); #endif - P_SetTarget(&tmthing, thing); - tmflags = thing->flags; + P_SetTarget(&tm.thing, thing); + tm.flags = thing->flags; - tmx = x; - tmy = y; + tm.x = x; + tm.y = y; - tmbbox[BOXTOP] = y + tmthing->radius; - tmbbox[BOXBOTTOM] = y - tmthing->radius; - tmbbox[BOXRIGHT] = x + tmthing->radius; - tmbbox[BOXLEFT] = x - tmthing->radius; + tm.bbox[BOXTOP] = y + tm.thing->radius; + tm.bbox[BOXBOTTOM] = y - tm.thing->radius; + tm.bbox[BOXRIGHT] = x + tm.thing->radius; + tm.bbox[BOXLEFT] = x - tm.thing->radius; newsubsec = R_PointInSubsector(x, y); - ceilingline = blockingline = NULL; + tm.ceilingline = tm.blockingline = NULL; // The base floor / ceiling is from the subsector // that contains the point. // Any contacted lines the step closer together // will adjust them. - tmfloorz = tmdropoffz = P_GetFloorZ(thing, newsubsec->sector, x, y, NULL); //newsubsec->sector->floorheight; - tmceilingz = P_GetCeilingZ(thing, newsubsec->sector, x, y, NULL); //newsubsec->sector->ceilingheight; - tmfloorrover = NULL; - tmceilingrover = NULL; - tmfloorslope = newsubsec->sector->f_slope; - tmceilingslope = newsubsec->sector->c_slope; - tmfloorpic = newsubsec->sector->floorpic; - tmceilingpic = newsubsec->sector->ceilingpic; + tm.floorz = tm.dropoffz = P_GetFloorZ(thing, newsubsec->sector, x, y, NULL); //newsubsec->sector->floorheight; + tm.ceilingz = P_GetCeilingZ(thing, newsubsec->sector, x, y, NULL); //newsubsec->sector->ceilingheight; + tm.floorrover = NULL; + tm.ceilingrover = NULL; + tm.floorslope = newsubsec->sector->f_slope; + tm.ceilingslope = newsubsec->sector->c_slope; + tm.floorpic = newsubsec->sector->floorpic; + tm.ceilingpic = newsubsec->sector->ceilingpic; - tmfloorstep = 0; - tmceilingstep = 0; + tm.floorstep = 0; + tm.ceilingstep = 0; if (thingtop < thing->ceilingz) { @@ -1883,7 +1893,7 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) thing->floordrop = 0; } - // Check list of fake floors and see if tmfloorz/tmceilingz need to be altered. + // Check list of fake floors and see if tm.floorz/tm.ceilingz need to be altered. if (newsubsec->sector->ffloors) { ffloor_t *rover; @@ -1918,20 +1928,22 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) // Land on the top or the bottom, depending on gravity flip. if (!(thing->eflags & MFE_VERTICALFLIP) && thing->z >= topheight - sinklevel && thing->momz <= 0) { - if (tmfloorz < topheight - sinklevel) { - tmfloorz = topheight - sinklevel; - tmfloorrover = rover; - tmfloorslope = *rover->t_slope; - tmfloorpic = *rover->toppic; + if (tm.floorz < topheight - sinklevel) + { + tm.floorz = topheight - sinklevel; + tm.floorrover = rover; + tm.floorslope = *rover->t_slope; + tm.floorpic = *rover->toppic; } } else if (thing->eflags & MFE_VERTICALFLIP && thingtop <= bottomheight + sinklevel && thing->momz >= 0) { - if (tmceilingz > bottomheight + sinklevel) { - tmceilingz = bottomheight + sinklevel; - tmceilingrover = rover; - tmceilingslope = *rover->b_slope; - tmceilingpic = *rover->bottompic; + if (tm.ceilingz > bottomheight + sinklevel) + { + tm.ceilingz = bottomheight + sinklevel; + tm.ceilingrover = rover; + tm.ceilingslope = *rover->b_slope; + tm.ceilingpic = *rover->bottompic; } } } @@ -1951,11 +1963,12 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) { if (thing->z < topheight && bottomheight < thingtop) { - if (tmfloorz < thing->z) { - tmfloorz = thing->z; - tmfloorrover = rover; - tmfloorslope = NULL; - tmfloorpic = *rover->toppic; + if (tm.floorz < thing->z) + { + tm.floorz = thing->z; + tm.floorrover = rover; + tm.floorslope = NULL; + tm.floorpic = *rover->toppic; } } // Quicksand blocks never change heights otherwise. @@ -1967,22 +1980,23 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) delta2 = thingtop - (bottomheight + ((topheight - bottomheight)/2)); - if (topheight > tmfloorz && abs(delta1) < abs(delta2) + if (topheight > tm.floorz && abs(delta1) < abs(delta2) && !(rover->fofflags & FOF_REVERSEPLATFORM)) { - tmfloorz = tmdropoffz = topheight; - tmfloorrover = rover; - tmfloorslope = *rover->t_slope; - tmfloorpic = *rover->toppic; + tm.floorz = tm.dropoffz = topheight; + tm.floorrover = rover; + tm.floorslope = *rover->t_slope; + tm.floorpic = *rover->toppic; } - if (bottomheight < tmceilingz && abs(delta1) >= abs(delta2) + + if (bottomheight < tm.ceilingz && abs(delta1) >= abs(delta2) && !(rover->fofflags & FOF_PLATFORM) && !(thing->type == MT_SKIM && (rover->fofflags & FOF_SWIMMABLE))) { - tmceilingz = tmdrpoffceilz = bottomheight; - tmceilingrover = rover; - tmceilingslope = *rover->b_slope; - tmceilingpic = *rover->bottompic; + tm.ceilingz = tm.drpoffceilz = bottomheight; + tm.ceilingrover = rover; + tm.ceilingslope = *rover->b_slope; + tm.ceilingpic = *rover->bottompic; } } } @@ -1992,18 +2006,19 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) // based on their origin point, and can overlap // into adjacent blocks by up to MAXRADIUS units. - xl = (unsigned)(tmbbox[BOXLEFT] - bmaporgx - MAXRADIUS)>>MAPBLOCKSHIFT; - xh = (unsigned)(tmbbox[BOXRIGHT] - bmaporgx + MAXRADIUS)>>MAPBLOCKSHIFT; - yl = (unsigned)(tmbbox[BOXBOTTOM] - bmaporgy - MAXRADIUS)>>MAPBLOCKSHIFT; - yh = (unsigned)(tmbbox[BOXTOP] - bmaporgy + MAXRADIUS)>>MAPBLOCKSHIFT; + xl = (unsigned)(tm.bbox[BOXLEFT] - bmaporgx - MAXRADIUS)>>MAPBLOCKSHIFT; + xh = (unsigned)(tm.bbox[BOXRIGHT] - bmaporgx + MAXRADIUS)>>MAPBLOCKSHIFT; + yl = (unsigned)(tm.bbox[BOXBOTTOM] - bmaporgy - MAXRADIUS)>>MAPBLOCKSHIFT; + yh = (unsigned)(tm.bbox[BOXTOP] - bmaporgy + MAXRADIUS)>>MAPBLOCKSHIFT; BMBOUNDFIX(xl, xh, yl, yh); - // Check polyobjects and see if tmfloorz/tmceilingz need to be altered + // Check polyobjects and see if tm.floorz/tm.ceilingz need to be altered { validcount++; for (by = yl; by <= yh; by++) + { for (bx = xl; bx <= xh; bx++) { INT32 offset; @@ -2029,7 +2044,7 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) po->validcount = validcount; - if (!P_BBoxInsidePolyobj(po, tmbbox) + if (!P_BBoxInsidePolyobj(po, tm.bbox) || !(po->flags & POF_SOLID)) { plink = (polymaplink_t *)(plink->link.next); @@ -2053,35 +2068,38 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) delta1 = thing->z - (polybottom + ((polytop - polybottom)/2)); delta2 = thingtop - (polybottom + ((polytop - polybottom)/2)); - if (polytop > tmfloorz && abs(delta1) < abs(delta2)) { - tmfloorz = tmdropoffz = polytop; - tmfloorslope = NULL; - tmfloorrover = NULL; - tmfloorpic = polysec->ceilingpic; + if (polytop > tm.floorz && abs(delta1) < abs(delta2)) + { + tm.floorz = tm.dropoffz = polytop; + tm.floorslope = NULL; + tm.floorrover = NULL; + tm.floorpic = polysec->ceilingpic; } - if (polybottom < tmceilingz && abs(delta1) >= abs(delta2)) { - tmceilingz = tmdrpoffceilz = polybottom; - tmceilingslope = NULL; - tmceilingrover = NULL; - tmceilingpic = polysec->floorpic; + if (polybottom < tm.ceilingz && abs(delta1) >= abs(delta2)) + { + tm.ceilingz = tm.drpoffceilz = polybottom; + tm.ceilingslope = NULL; + tm.ceilingrover = NULL; + tm.ceilingpic = polysec->floorpic; } } plink = (polymaplink_t *)(plink->link.next); } } + } } - // tmfloorthing is set when tmfloorz comes from a thing's top - tmfloorthing = NULL; - tmhitthing = NULL; + // tm.floorthing is set when tm.floorz comes from a thing's top + P_SetTarget(&tm.floorthing, NULL); + P_SetTarget(&tm.hitthing, NULL); validcount++; // reset special lines numspechit = 0U; - if (tmflags & MF_NOCLIP) + if (tm.flags & MF_NOCLIP) return true; // Check things first, possibly picking things up. @@ -2093,10 +2111,15 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) for (by = yl; by <= yh; by++) { if (!P_BlockThingsIterator(bx, by, PIT_CheckThing)) + { blockval = false; + } else - tmhitthing = tmfloorthing; - if (P_MobjWasRemoved(tmthing)) + { + P_SetTarget(&tm.hitthing, tm.floorthing); + } + + if (P_MobjWasRemoved(tm.thing)) return false; } } @@ -2105,9 +2128,15 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) // check lines for (bx = xl; bx <= xh; bx++) + { for (by = yl; by <= yh; by++) + { if (!P_BlockLinesIterator(bx, by, PIT_CheckLine)) + { blockval = false; + } + } + } return blockval; } @@ -2147,23 +2176,23 @@ boolean P_CheckCameraPosition(fixed_t x, fixed_t y, camera_t *thiscam) INT32 xl, xh, yl, yh, bx, by; subsector_t *newsubsec; - tmx = x; - tmy = y; + tm.x = x; + tm.y = y; - tmbbox[BOXTOP] = y + thiscam->radius; - tmbbox[BOXBOTTOM] = y - thiscam->radius; - tmbbox[BOXRIGHT] = x + thiscam->radius; - tmbbox[BOXLEFT] = x - thiscam->radius; + tm.bbox[BOXTOP] = y + thiscam->radius; + tm.bbox[BOXBOTTOM] = y - thiscam->radius; + tm.bbox[BOXRIGHT] = x + thiscam->radius; + tm.bbox[BOXLEFT] = x - thiscam->radius; newsubsec = R_PointInSubsector(x, y); - ceilingline = blockingline = NULL; + tm.ceilingline = tm.blockingline = NULL; mapcampointer = thiscam; if (newsubsec->sector->flags & MSF_NOCLIPCAMERA) { // Camera noclip on entire sector. - tmfloorz = tmdropoffz = thiscam->z; - tmceilingz = tmdrpoffceilz = thiscam->z + thiscam->height; + tm.floorz = tm.dropoffz = thiscam->z; + tm.ceilingz = tm.drpoffceilz = thiscam->z + thiscam->height; return true; } @@ -2171,26 +2200,26 @@ boolean P_CheckCameraPosition(fixed_t x, fixed_t y, camera_t *thiscam) // that contains the point. // Any contacted lines the step closer together // will adjust them. - tmfloorz = tmdropoffz = P_CameraGetFloorZ(thiscam, newsubsec->sector, x, y, NULL); + tm.floorz = tm.dropoffz = P_CameraGetFloorZ(thiscam, newsubsec->sector, x, y, NULL); - tmceilingz = P_CameraGetCeilingZ(thiscam, newsubsec->sector, x, y, NULL); + tm.ceilingz = P_CameraGetCeilingZ(thiscam, newsubsec->sector, x, y, NULL); // Cameras use the heightsec's heights rather then the actual sector heights. // If you can see through it, why not move the camera through it too? if (newsubsec->sector->heightsec >= 0) { - tmfloorz = tmdropoffz = sectors[newsubsec->sector->heightsec].floorheight; - tmceilingz = tmdrpoffceilz = sectors[newsubsec->sector->heightsec].ceilingheight; + tm.floorz = tm.dropoffz = sectors[newsubsec->sector->heightsec].floorheight; + tm.ceilingz = tm.drpoffceilz = sectors[newsubsec->sector->heightsec].ceilingheight; } // Use preset camera clipping heights if set with Sector Special Parameters whose control sector has Camera Intangible special -Red if (newsubsec->sector->camsec >= 0) { - tmfloorz = tmdropoffz = sectors[newsubsec->sector->camsec].floorheight; - tmceilingz = tmdrpoffceilz = sectors[newsubsec->sector->camsec].ceilingheight; + tm.floorz = tm.dropoffz = sectors[newsubsec->sector->camsec].floorheight; + tm.ceilingz = tm.drpoffceilz = sectors[newsubsec->sector->camsec].ceilingheight; } - // Check list of fake floors and see if tmfloorz/tmceilingz need to be altered. + // Check list of fake floors and see if tm.floorz/tm.ceilingz need to be altered. if (newsubsec->sector->ffloors) { ffloor_t *rover; @@ -2210,13 +2239,13 @@ boolean P_CheckCameraPosition(fixed_t x, fixed_t y, camera_t *thiscam) + ((topheight - bottomheight)/2)); delta2 = thingtop - (bottomheight + ((topheight - bottomheight)/2)); - if (topheight > tmfloorz && abs(delta1) < abs(delta2)) + if (topheight > tm.floorz && abs(delta1) < abs(delta2)) { - tmfloorz = tmdropoffz = topheight; + tm.floorz = tm.dropoffz = topheight; } - if (bottomheight < tmceilingz && abs(delta1) >= abs(delta2)) + if (bottomheight < tm.ceilingz && abs(delta1) >= abs(delta2)) { - tmceilingz = tmdrpoffceilz = bottomheight; + tm.ceilingz = tm.drpoffceilz = bottomheight; } } } @@ -2226,14 +2255,14 @@ boolean P_CheckCameraPosition(fixed_t x, fixed_t y, camera_t *thiscam) // based on their origin point, and can overlap // into adjacent blocks by up to MAXRADIUS units. - 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; BMBOUNDFIX(xl, xh, yl, yh); - // Check polyobjects and see if tmfloorz/tmceilingz need to be altered + // Check polyobjects and see if tm.floorz/tm.ceilingz need to be altered { validcount++; @@ -2293,11 +2322,11 @@ boolean P_CheckCameraPosition(fixed_t x, fixed_t y, camera_t *thiscam) delta1 = thiscam->z - (polybottom + ((polytop - polybottom)/2)); delta2 = thingtop - (polybottom + ((polytop - polybottom)/2)); - if (polytop > tmfloorz && abs(delta1) < abs(delta2)) - tmfloorz = tmdropoffz = polytop; + if (polytop > tm.floorz && abs(delta1) < abs(delta2)) + tm.floorz = tm.dropoffz = polytop; - if (polybottom < tmceilingz && abs(delta1) >= abs(delta2)) - tmceilingz = tmdrpoffceilz = polybottom; + if (polybottom < tm.ceilingz && abs(delta1) >= abs(delta2)) + tm.ceilingz = tm.drpoffceilz = polybottom; } plink = (polymaplink_t *)(plink->link.next); } @@ -2330,7 +2359,7 @@ boolean P_TryCameraMove(fixed_t x, fixed_t y, camera_t *thiscam) UINT8 i; - floatok = false; + tm.floatok = false; for (i = 0; i <= r_splitscreen; i++) { @@ -2354,7 +2383,7 @@ boolean P_TryCameraMove(fixed_t x, fixed_t y, camera_t *thiscam) if (!(players[displayplayers[i]].pflags & PF_NOCONTEST)) // Time Over should not clip through walls { - floatok = true; + tm.floatok = true; thiscam->floorz = thiscam->z; thiscam->ceilingz = thiscam->z + thiscam->height; thiscam->x = x; @@ -2380,18 +2409,18 @@ boolean P_TryCameraMove(fixed_t x, fixed_t y, camera_t *thiscam) if (!P_CheckCameraPosition(tryx, tryy, thiscam)) return false; // solid wall or thing - if (tmceilingz - tmfloorz < thiscam->height) + if (tm.ceilingz - tm.floorz < thiscam->height) return false; // doesn't fit - floatok = true; + tm.floatok = true; - if (tmceilingz - thiscam->z < thiscam->height) + if (tm.ceilingz - thiscam->z < thiscam->height) { - if (s == thiscam->subsector && tmceilingz >= thiscam->z) + if (s == thiscam->subsector && tm.ceilingz >= thiscam->z) { - floatok = true; - thiscam->floorz = tmfloorz; - thiscam->ceilingz = tmfloorz + thiscam->height; + tm.floatok = true; + thiscam->floorz = tm.floorz; + thiscam->ceilingz = tm.floorz + thiscam->height; thiscam->x = x; thiscam->y = y; thiscam->subsector = s; @@ -2401,21 +2430,21 @@ boolean P_TryCameraMove(fixed_t x, fixed_t y, camera_t *thiscam) return false; // mobj must lower itself to fit } - if ((tmfloorz - thiscam->z > MAXCAMERASTEPMOVE)) + if ((tm.floorz - thiscam->z > MAXCAMERASTEPMOVE)) return false; // too big a step up } while(tryx != x || tryy != y); } else { - tmfloorz = P_CameraGetFloorZ(thiscam, thiscam->subsector->sector, x, y, NULL); - tmceilingz = P_CameraGetCeilingZ(thiscam, thiscam->subsector->sector, x, y, NULL); + tm.floorz = P_CameraGetFloorZ(thiscam, thiscam->subsector->sector, x, y, NULL); + tm.ceilingz = P_CameraGetCeilingZ(thiscam, thiscam->subsector->sector, x, y, NULL); } // the move is ok, // so link the thing into its new position - thiscam->floorz = tmfloorz; - thiscam->ceilingz = tmceilingz; + thiscam->floorz = tm.floorz; + thiscam->ceilingz = tm.ceilingz; thiscam->x = x; thiscam->y = y; thiscam->subsector = s; @@ -2467,37 +2496,14 @@ BlockItReturn_t PIT_PushableMoved(mobj_t *thing) // These are all non-static map variables that are changed for each and every single mobj // See, changing player's momx/y would possibly trigger stuff as if the player were running somehow, so this must be done to keep the player standing // All this so players can ride gargoyles! - boolean oldfltok = floatok; - fixed_t oldflrz = tmfloorz; - fixed_t oldceilz = tmceilingz; - mobj_t *oldflrthing = tmfloorthing; - mobj_t *oldthing = tmthing; - line_t *oldceilline = ceilingline; - line_t *oldblockline = blockingline; - ffloor_t *oldflrrover = tmfloorrover; - ffloor_t *oldceilrover = tmceilingrover; - pslope_t *oldfslope = tmfloorslope; - pslope_t *oldcslope = tmceilingslope; - INT32 oldfpic = tmfloorpic; - INT32 oldcpic = tmceilingpic; + tm_t oldtm = tm; // Move the player - P_TryMove(thing, thing->x+stand->momx, thing->y+stand->momy, true); + P_TryMove(thing, thing->x + stand->momx, thing->y + stand->momy, true); // Now restore EVERYTHING so the gargoyle doesn't keep the player's tmstuff and break - floatok = oldfltok; - tmfloorz = oldflrz; - tmceilingz = oldceilz; - tmfloorthing = oldflrthing; - P_SetTarget(&tmthing, oldthing); - ceilingline = oldceilline; - blockingline = oldblockline; - tmfloorrover = oldflrrover; - tmceilingrover = oldceilrover; - tmfloorslope = oldfslope; - tmceilingslope = oldcslope; - tmfloorpic = oldfpic; - tmceilingpic = oldcpic; + P_RestoreTMStruct(oldtm); + thing->momz = stand->momz; } else @@ -2566,7 +2572,7 @@ increment_move fixed_t radius = thing->radius; fixed_t thingtop; fixed_t stairjank = 0; - floatok = false; + tm.floatok = false; // reset this to 0 at the start of each trymove call as it's only used here numspechitint = 0U; @@ -2578,14 +2584,6 @@ increment_move // And Big Large (tm) movements can skip over slopes. radius = min(radius, 16*mapobjectscale); -#if 0 - if (thing->hitlag > 0) - { - // Do not move during hitlag - return false; - } -#endif - do { if (thing->flags & MF_NOCLIP) { @@ -2620,14 +2618,17 @@ increment_move //All things are affected by their scale. fixed_t maxstep = P_GetThingStepUp(thing, tryx, tryy); - if (tmceilingz - tmfloorz < thing->height) + if (tm.ceilingz - tm.floorz < thing->height) { - if (tmfloorthing) - tmhitthing = tmfloorthing; + if (tm.floorthing != NULL) + { + P_SetTarget(&tm.hitthing, tm.floorthing); + } + return false; // doesn't fit } - floatok = true; + tm.floatok = true; if (maxstep > 0) { @@ -2637,15 +2638,15 @@ increment_move thingtop = thing->z + thing->height; // Step up - if (thing->z < tmfloorz) + if (thing->z < tm.floorz) { - if (tmfloorstep <= maxstep) + if (tm.floorstep <= maxstep) { if (!flipped) - stairjank = tmfloorstep; + stairjank = tm.floorstep; - thing->z = thing->floorz = tmfloorz; - thing->floorrover = tmfloorrover; + thing->z = thing->floorz = tm.floorz; + thing->floorrover = tm.floorrover; thing->eflags |= MFE_JUSTSTEPPEDDOWN; } else @@ -2653,15 +2654,15 @@ increment_move return false; // mobj must raise itself to fit } } - else if (tmceilingz < thingtop) + else if (tm.ceilingz < thingtop) { - if (tmceilingstep <= maxstep) + if (tm.ceilingstep <= maxstep) { if (flipped) - stairjank = tmceilingstep; + stairjank = tm.ceilingstep; - thing->z = ( thing->ceilingz = tmceilingz ) - thing->height; - thing->ceilingrover = tmceilingrover; + thing->z = ( thing->ceilingz = tm.ceilingz ) - thing->height; + thing->ceilingrover = tm.ceilingrover; thing->eflags |= MFE_JUSTSTEPPEDDOWN; } else @@ -2676,37 +2677,37 @@ increment_move // If the floor difference is MAXSTEPMOVE or less, and the sector isn't Section1:14, ALWAYS // step down! Formerly required a Section1:13 sector for the full MAXSTEPMOVE, but no more. - if (thingtop == thing->ceilingz && tmceilingz > thingtop && tmceilingz - thingtop <= maxstep) + if (thingtop == thing->ceilingz && tm.ceilingz > thingtop && tm.ceilingz - thingtop <= maxstep) { if (flipped) - stairjank = (tmceilingz - thingtop); + stairjank = (tm.ceilingz - thingtop); - thing->z = (thing->ceilingz = tmceilingz) - thing->height; - thing->ceilingrover = tmceilingrover; + thing->z = (thing->ceilingz = tm.ceilingz) - thing->height; + thing->ceilingrover = tm.ceilingrover; thing->eflags |= MFE_JUSTSTEPPEDDOWN; thing->ceilingdrop = 0; } - else if (thing->z == thing->floorz && tmfloorz < thing->z && thing->z - tmfloorz <= maxstep) + else if (thing->z == thing->floorz && tm.floorz < thing->z && thing->z - tm.floorz <= maxstep) { if (!flipped) - stairjank = (thing->z - tmfloorz); + stairjank = (thing->z - tm.floorz); - thing->z = thing->floorz = tmfloorz; - thing->floorrover = tmfloorrover; + thing->z = thing->floorz = tm.floorz; + thing->floorrover = tm.floorrover; thing->eflags |= MFE_JUSTSTEPPEDDOWN; thing->floordrop = 0; } } } - if (!allowdropoff && !(thing->flags & MF_FLOAT) && thing->type != MT_SKIM && !tmfloorthing) + if (!allowdropoff && !(thing->flags & MF_FLOAT) && thing->type != MT_SKIM && !tm.floorthing) { if (thing->eflags & MFE_VERTICALFLIP) { - if (tmdrpoffceilz - tmceilingz > maxstep) + if (tm.drpoffceilz - tm.ceilingz > maxstep) return false; } - else if (tmfloorz - tmdropoffz > maxstep) + else if (tm.floorz - tm.dropoffz > maxstep) return false; // don't stand over a dropoff } } @@ -2724,7 +2725,7 @@ increment_move // boolean P_CheckMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff) { - boolean moveok; + boolean moveok = false; mobj_t *hack = P_SpawnMobjFromMobj(thing, 0, 0, 0, MT_RAY); hack->radius = thing->radius; @@ -2748,9 +2749,11 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff) fixed_t stairjank = 0; pslope_t *oldslope = thing->standingslope; - // The move is ok! - if (!increment_move(thing, x, y, allowdropoff, &stairjank)) + // Is the move OK? + if (increment_move(thing, x, y, allowdropoff, &stairjank) == false) + { return false; + } // If it's a pushable object, check if anything is // standing on top and move it, too. @@ -2777,21 +2780,21 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff) // Link the thing into its new position P_UnsetThingPosition(thing); - thing->floorz = tmfloorz; - thing->ceilingz = tmceilingz; - thing->floorrover = tmfloorrover; - thing->ceilingrover = tmceilingrover; + thing->floorz = tm.floorz; + thing->ceilingz = tm.ceilingz; + thing->floorrover = tm.floorrover; + thing->ceilingrover = tm.ceilingrover; if (!(thing->flags & MF_NOCLIPHEIGHT)) { // Assign thing's standingslope if needed - if (thing->z <= tmfloorz && !(thing->eflags & MFE_VERTICALFLIP)) + if (thing->z <= tm.floorz && !(thing->eflags & MFE_VERTICALFLIP)) { - K_UpdateMobjTerrain(thing, tmfloorpic); + K_UpdateMobjTerrain(thing, tm.floorpic); - if (!startingonground && tmfloorslope) + if (!startingonground && tm.floorslope) { - P_HandleSlopeLanding(thing, tmfloorslope); + P_HandleSlopeLanding(thing, tm.floorslope); } if (thing->momz <= 0) @@ -2799,7 +2802,7 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff) angle_t oldPitch = thing->pitch; angle_t oldRoll = thing->roll; - thing->standingslope = tmfloorslope; + thing->standingslope = tm.floorslope; P_SetPitchRollFromSlope(thing, thing->standingslope); if (thing->player) @@ -2808,13 +2811,13 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff) } } } - else if (thing->z+thing->height >= tmceilingz && (thing->eflags & MFE_VERTICALFLIP)) + else if (thing->z+thing->height >= tm.ceilingz && (thing->eflags & MFE_VERTICALFLIP)) { - K_UpdateMobjTerrain(thing, tmceilingpic); + K_UpdateMobjTerrain(thing, tm.ceilingpic); - if (!startingonground && tmceilingslope) + if (!startingonground && tm.ceilingslope) { - P_HandleSlopeLanding(thing, tmceilingslope); + P_HandleSlopeLanding(thing, tm.ceilingslope); } if (thing->momz >= 0) @@ -2822,7 +2825,7 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff) angle_t oldPitch = thing->pitch; angle_t oldRoll = thing->roll; - thing->standingslope = tmceilingslope; + thing->standingslope = tm.ceilingslope; P_SetPitchRollFromSlope(thing, thing->standingslope); if (thing->player) @@ -2869,7 +2872,7 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff) thing->x = x; thing->y = y; - if (tmfloorthing) + if (tm.floorthing) thing->eflags &= ~MFE_ONGROUND; // not on real floor else thing->eflags |= MFE_ONGROUND; @@ -2926,13 +2929,13 @@ boolean P_SceneryTryMove(mobj_t *thing, fixed_t x, fixed_t y) { const fixed_t maxstep = P_BaseStepUp(); - if (tmceilingz - tmfloorz < thing->height) + if (tm.ceilingz - tm.floorz < thing->height) return false; // doesn't fit - if (tmceilingz - thing->z < thing->height) + if (tm.ceilingz - thing->z < thing->height) return false; // mobj must lower itself to fit - if (tmfloorz - thing->z > maxstep) + if (tm.floorz - thing->z > maxstep) return false; // too big a step up } } while(tryx != x || tryy != y); @@ -2941,14 +2944,14 @@ boolean P_SceneryTryMove(mobj_t *thing, fixed_t x, fixed_t y) // so link the thing into its new position P_UnsetThingPosition(thing); - thing->floorz = tmfloorz; - thing->ceilingz = tmceilingz; - thing->floorrover = tmfloorrover; - thing->ceilingrover = tmceilingrover; + thing->floorz = tm.floorz; + thing->ceilingz = tm.ceilingz; + thing->floorrover = tm.floorrover; + thing->ceilingrover = tm.ceilingrover; thing->x = x; thing->y = y; - if (tmfloorthing) + if (tm.floorthing) thing->eflags &= ~MFE_ONGROUND; // not on real floor else thing->eflags |= MFE_ONGROUND; @@ -3076,17 +3079,17 @@ 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); + floormoved = (thing->eflags & MFE_VERTICALFLIP && tm.ceilingz != thing->ceilingz) + || (!(thing->eflags & MFE_VERTICALFLIP) && tm.floorz != thing->floorz); - thing->floorz = tmfloorz; - thing->ceilingz = tmceilingz; - thing->floorrover = tmfloorrover; - thing->ceilingrover = tmceilingrover; + thing->floorz = tm.floorz; + thing->ceilingz = tm.ceilingz; + thing->floorrover = tm.floorrover; + thing->ceilingrover = tm.ceilingrover; // Ugly hack?!?! As long as just ceilingz is the lowest, // you'll still get crushed, right? - if (tmfloorz > oldfloorz+thing->height) + if (tm.floorz > oldfloorz+thing->height) return true; if (onfloor && !(thing->flags & MF_NOGRAVITY) && floormoved) @@ -3110,15 +3113,15 @@ static boolean P_ThingHeightClip(mobj_t *thing) thing->z = thing->floorz; } } - else if (!tmfloorthing) + else if (!tm.floorthing) { // don't adjust a floating monster unless forced to if (thing->eflags & MFE_VERTICALFLIP) { - if (!onfloor && thing->z < tmfloorz) + if (!onfloor && thing->z < tm.floorz) thing->z = thing->floorz; } - else if (!onfloor && thing->z + thing->height > tmceilingz) + else if (!onfloor && thing->z + thing->height > tm.ceilingz) thing->z = thing->ceilingz - thing->height; } @@ -3590,13 +3593,13 @@ void P_SlideMove(mobj_t *mo) if (P_MobjWasRemoved(mo)) return; - if (tmhitthing && mo->z + mo->height > tmhitthing->z && mo->z < tmhitthing->z + tmhitthing->height) + if (tm.hitthing && mo->z + mo->height > tm.hitthing->z && mo->z < tm.hitthing->z + tm.hitthing->height) { // Don't mess with your momentum if it's a pushable object. Pushables do their own crazy things already. - if (tmhitthing->flags & MF_PUSHABLE) + if (tm.hitthing->flags & MF_PUSHABLE) return; - if (tmhitthing->flags & MF_PAPERCOLLISION) + if (tm.hitthing->flags & MF_PAPERCOLLISION) { fixed_t cosradius, sinradius, num, den; @@ -3627,13 +3630,13 @@ void P_SlideMove(mobj_t *mo) slidemo = mo; bestslideline = &junk; - cosradius = FixedMul(tmhitthing->radius, FINECOSINE(tmhitthing->angle>>ANGLETOFINESHIFT)); - sinradius = FixedMul(tmhitthing->radius, FINESINE(tmhitthing->angle>>ANGLETOFINESHIFT)); + cosradius = FixedMul(tm.hitthing->radius, FINECOSINE(tm.hitthing->angle>>ANGLETOFINESHIFT)); + sinradius = FixedMul(tm.hitthing->radius, FINESINE(tm.hitthing->angle>>ANGLETOFINESHIFT)); - v1.x = tmhitthing->x - cosradius; - v1.y = tmhitthing->y - sinradius; - v2.x = tmhitthing->x + cosradius; - v2.y = tmhitthing->y + sinradius; + v1.x = tm.hitthing->x - cosradius; + v1.y = tm.hitthing->y - sinradius; + v2.x = tm.hitthing->x + cosradius; + v2.y = tm.hitthing->y + sinradius; // Can we box collision our way into smooth movement..? if (sinradius && mo->y + mo->radius <= min(v1.y, v2.y)) @@ -3694,25 +3697,25 @@ void P_SlideMove(mobj_t *mo) } // Thankfully box collisions are a lot simpler than arbitrary lines. There's only four possible cases. - if (mo->y + mo->radius <= tmhitthing->y - tmhitthing->radius) + if (mo->y + mo->radius <= tm.hitthing->y - tm.hitthing->radius) { mo->momy = 0; - P_TryMove(mo, mo->x + mo->momx, tmhitthing->y - tmhitthing->radius - mo->radius, true); + P_TryMove(mo, mo->x + mo->momx, tm.hitthing->y - tm.hitthing->radius - mo->radius, true); } - else if (mo->y - mo->radius >= tmhitthing->y + tmhitthing->radius) + else if (mo->y - mo->radius >= tm.hitthing->y + tm.hitthing->radius) { mo->momy = 0; - P_TryMove(mo, mo->x + mo->momx, tmhitthing->y + tmhitthing->radius + mo->radius, true); + P_TryMove(mo, mo->x + mo->momx, tm.hitthing->y + tm.hitthing->radius + mo->radius, true); } - else if (mo->x + mo->radius <= tmhitthing->x - tmhitthing->radius) + else if (mo->x + mo->radius <= tm.hitthing->x - tm.hitthing->radius) { mo->momx = 0; - P_TryMove(mo, tmhitthing->x - tmhitthing->radius - mo->radius, mo->y + mo->momy, true); + P_TryMove(mo, tm.hitthing->x - tm.hitthing->radius - mo->radius, mo->y + mo->momy, true); } - else if (mo->x - mo->radius >= tmhitthing->x + tmhitthing->radius) + else if (mo->x - mo->radius >= tm.hitthing->x + tm.hitthing->radius) { mo->momx = 0; - P_TryMove(mo, tmhitthing->x + tmhitthing->radius + mo->radius, mo->y + mo->momy, true); + P_TryMove(mo, tm.hitthing->x + tm.hitthing->radius + mo->radius, mo->y + mo->momy, true); } else mo->momx = mo->momy = 0; @@ -4779,13 +4782,13 @@ void P_DelPrecipSeclist(mprecipsecnode_t *node) static inline BlockItReturn_t PIT_GetSectors(line_t *ld) { - if (tmbbox[BOXRIGHT] <= ld->bbox[BOXLEFT] || - tmbbox[BOXLEFT] >= ld->bbox[BOXRIGHT] || - tmbbox[BOXTOP] <= ld->bbox[BOXBOTTOM] || - tmbbox[BOXBOTTOM] >= ld->bbox[BOXTOP]) + if (tm.bbox[BOXRIGHT] <= ld->bbox[BOXLEFT] || + tm.bbox[BOXLEFT] >= ld->bbox[BOXRIGHT] || + tm.bbox[BOXTOP] <= ld->bbox[BOXBOTTOM] || + tm.bbox[BOXBOTTOM] >= ld->bbox[BOXTOP]) return BMIT_CONTINUE; - if (P_BoxOnLineSide(tmbbox, ld) != -1) + if (P_BoxOnLineSide(tm.bbox, ld) != -1) return BMIT_CONTINUE; if (ld->polyobj) // line belongs to a polyobject, don't add it @@ -4798,7 +4801,7 @@ static inline BlockItReturn_t PIT_GetSectors(line_t *ld) // allowed to move to this position, then the sector_list // will be attached to the Thing's mobj_t at touching_sectorlist. - sector_list = P_AddSecnode(ld->frontsector,tmthing,sector_list); + sector_list = P_AddSecnode(ld->frontsector,tm.thing,sector_list); // Don't assume all lines are 2-sided, since some Things // like MT_TFOG are allowed regardless of whether their radius takes @@ -4806,7 +4809,7 @@ static inline BlockItReturn_t PIT_GetSectors(line_t *ld) // Use sidedefs instead of 2s flag to determine two-sidedness. if (ld->backsector) - sector_list = P_AddSecnode(ld->backsector, tmthing, sector_list); + sector_list = P_AddSecnode(ld->backsector, tm.thing, sector_list); return BMIT_CONTINUE; } @@ -4814,13 +4817,13 @@ static inline BlockItReturn_t PIT_GetSectors(line_t *ld) // Tails 08-25-2002 static inline BlockItReturn_t PIT_GetPrecipSectors(line_t *ld) { - if (preciptmbbox[BOXRIGHT] <= ld->bbox[BOXLEFT] || - preciptmbbox[BOXLEFT] >= ld->bbox[BOXRIGHT] || - preciptmbbox[BOXTOP] <= ld->bbox[BOXBOTTOM] || - preciptmbbox[BOXBOTTOM] >= ld->bbox[BOXTOP]) + if (tm.precipbbox[BOXRIGHT] <= ld->bbox[BOXLEFT] || + tm.precipbbox[BOXLEFT] >= ld->bbox[BOXRIGHT] || + tm.precipbbox[BOXTOP] <= ld->bbox[BOXBOTTOM] || + tm.precipbbox[BOXBOTTOM] >= ld->bbox[BOXTOP]) return BMIT_CONTINUE; - if (P_BoxOnLineSide(preciptmbbox, ld) != -1) + if (P_BoxOnLineSide(tm.precipbbox, ld) != -1) return BMIT_CONTINUE; if (ld->polyobj) // line belongs to a polyobject, don't add it @@ -4833,7 +4836,7 @@ static inline BlockItReturn_t PIT_GetPrecipSectors(line_t *ld) // allowed to move to this position, then the sector_list // will be attached to the Thing's mobj_t at touching_sectorlist. - precipsector_list = P_AddPrecipSecnode(ld->frontsector, tmprecipthing, precipsector_list); + precipsector_list = P_AddPrecipSecnode(ld->frontsector, tm.precipthing, precipsector_list); // Don't assume all lines are 2-sided, since some Things // like MT_TFOG are allowed regardless of whether their radius takes @@ -4841,7 +4844,7 @@ static inline BlockItReturn_t PIT_GetPrecipSectors(line_t *ld) // Use sidedefs instead of 2s flag to determine two-sidedness. if (ld->backsector) - precipsector_list = P_AddPrecipSecnode(ld->backsector, tmprecipthing, precipsector_list); + precipsector_list = P_AddPrecipSecnode(ld->backsector, tm.precipthing, precipsector_list); return BMIT_CONTINUE; } @@ -4853,8 +4856,7 @@ void P_CreateSecNodeList(mobj_t *thing, fixed_t x, fixed_t y) { INT32 xl, xh, yl, yh, bx, by; msecnode_t *node = sector_list; - mobj_t *saved_tmthing = tmthing; /* cph - see comment at func end */ - fixed_t saved_tmx = tmx, saved_tmy = tmy; /* ditto */ + tm_t ptm = tm; /* cph - see comment at func end */ // First, clear out the existing m_thing fields. As each node is // added or verified as needed, m_thing will be set properly. When @@ -4867,23 +4869,23 @@ void P_CreateSecNodeList(mobj_t *thing, fixed_t x, fixed_t y) node = node->m_sectorlist_next; } - P_SetTarget(&tmthing, thing); - tmflags = thing->flags; + P_SetTarget(&tm.thing, thing); + tm.flags = thing->flags; - tmx = x; - tmy = y; + tm.x = x; + tm.y = y; - tmbbox[BOXTOP] = y + tmthing->radius; - tmbbox[BOXBOTTOM] = y - tmthing->radius; - tmbbox[BOXRIGHT] = x + tmthing->radius; - tmbbox[BOXLEFT] = x - tmthing->radius; + tm.bbox[BOXTOP] = y + tm.thing->radius; + tm.bbox[BOXBOTTOM] = y - tm.thing->radius; + tm.bbox[BOXRIGHT] = x + tm.thing->radius; + tm.bbox[BOXLEFT] = x - tm.thing->radius; validcount++; // used to make sure we only process a line once - 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; BMBOUNDFIX(xl, xh, yl, yh); @@ -4910,26 +4912,14 @@ void P_CreateSecNodeList(mobj_t *thing, fixed_t x, fixed_t y) } /* cph - - * This is the strife we get into for using global variables. tmthing + * This is the strife we get into for using global variables. tm.thing * is being used by several different functions calling * P_BlockThingIterator, including functions that can be called *from* - * P_BlockThingIterator. Using a global tmthing is not reentrant. + * P_BlockThingIterator. Using a global tm.thing is not reentrant. * OTOH for Boom/MBF demos we have to preserve the buggy behavior. * Fun. We restore its previous value unless we're in a Boom/MBF demo. */ - P_SetTarget(&tmthing, saved_tmthing); - - /* And, duh, the same for tmx/y - cph 2002/09/22 - * And for tmbbox - cph 2003/08/10 */ - tmx = saved_tmx, tmy = saved_tmy; - - if (tmthing) - { - tmbbox[BOXTOP] = tmy + tmthing->radius; - tmbbox[BOXBOTTOM] = tmy - tmthing->radius; - tmbbox[BOXRIGHT] = tmx + tmthing->radius; - tmbbox[BOXLEFT] = tmx - tmthing->radius; - } + P_RestoreTMStruct(ptm); } // More crazy crap Tails 08-25-2002 @@ -4937,7 +4927,7 @@ void P_CreatePrecipSecNodeList(precipmobj_t *thing,fixed_t x,fixed_t y) { INT32 xl, xh, yl, yh, bx, by; mprecipsecnode_t *node = precipsector_list; - precipmobj_t *saved_tmthing = tmprecipthing; /* cph - see comment at func end */ + tm_t ptm = tm; /* cph - see comment at func end */ // First, clear out the existing m_thing fields. As each node is // added or verified as needed, m_thing will be set properly. When @@ -4950,19 +4940,19 @@ void P_CreatePrecipSecNodeList(precipmobj_t *thing,fixed_t x,fixed_t y) node = node->m_sectorlist_next; } - tmprecipthing = thing; + tm.precipthing = thing; - preciptmbbox[BOXTOP] = y + 2*FRACUNIT; - preciptmbbox[BOXBOTTOM] = y - 2*FRACUNIT; - preciptmbbox[BOXRIGHT] = x + 2*FRACUNIT; - preciptmbbox[BOXLEFT] = x - 2*FRACUNIT; + tm.precipbbox[BOXTOP] = y + 2*FRACUNIT; + tm.precipbbox[BOXBOTTOM] = y - 2*FRACUNIT; + tm.precipbbox[BOXRIGHT] = x + 2*FRACUNIT; + tm.precipbbox[BOXLEFT] = x - 2*FRACUNIT; validcount++; // used to make sure we only process a line once - xl = (unsigned)(preciptmbbox[BOXLEFT] - bmaporgx)>>MAPBLOCKSHIFT; - xh = (unsigned)(preciptmbbox[BOXRIGHT] - bmaporgx)>>MAPBLOCKSHIFT; - yl = (unsigned)(preciptmbbox[BOXBOTTOM] - bmaporgy)>>MAPBLOCKSHIFT; - yh = (unsigned)(preciptmbbox[BOXTOP] - bmaporgy)>>MAPBLOCKSHIFT; + xl = (unsigned)(tm.precipbbox[BOXLEFT] - bmaporgx)>>MAPBLOCKSHIFT; + xh = (unsigned)(tm.precipbbox[BOXRIGHT] - bmaporgx)>>MAPBLOCKSHIFT; + yl = (unsigned)(tm.precipbbox[BOXBOTTOM] - bmaporgy)>>MAPBLOCKSHIFT; + yh = (unsigned)(tm.precipbbox[BOXTOP] - bmaporgy)>>MAPBLOCKSHIFT; BMBOUNDFIX(xl, xh, yl, yh); @@ -4989,27 +4979,27 @@ void P_CreatePrecipSecNodeList(precipmobj_t *thing,fixed_t x,fixed_t y) } /* cph - - * This is the strife we get into for using global variables. tmthing + * This is the strife we get into for using global variables. tm.thing * is being used by several different functions calling * P_BlockThingIterator, including functions that can be called *from* - * P_BlockThingIterator. Using a global tmthing is not reentrant. + * P_BlockThingIterator. Using a global tm.thing is not reentrant. * OTOH for Boom/MBF demos we have to preserve the buggy behavior. * Fun. We restore its previous value unless we're in a Boom/MBF demo. */ - tmprecipthing = saved_tmthing; + P_RestoreTMStruct(ptm); } /* cphipps 2004/08/30 - - * Must clear tmthing at tic end, as it might contain a pointer to a removed thinker, or the level might have ended/been ended and we clear the objects it was pointing too. Hopefully we don't need to carry this between tics for sync. */ + * Must clear tm.thing at tic end, as it might contain a pointer to a removed thinker, or the level might have ended/been ended and we clear the objects it was pointing too. Hopefully we don't need to carry this between tics for sync. */ void P_MapStart(void) { - if (tmthing) - I_Error("P_MapStart: tmthing set!"); + if (tm.thing) + I_Error("P_MapStart: tm.thing set!"); } void P_MapEnd(void) { - P_SetTarget(&tmthing, NULL); + P_SetTarget(&tm.thing, NULL); } // P_FloorzAtPos diff --git a/src/p_maputl.c b/src/p_maputl.c index ab810e437..7eb4a7e19 100644 --- a/src/p_maputl.c +++ b/src/p_maputl.c @@ -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++) diff --git a/src/p_maputl.h b/src/p_maputl.h index 29e7d4de9..7ac6baa3f 100644 --- a/src/p_maputl.h +++ b/src/p_maputl.h @@ -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, diff --git a/src/p_mobj.c b/src/p_mobj.c index d5924de51..88d9c3994 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -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,9 @@ void P_MobjThinker(mobj_t *mobj) mobj->eflags &= ~(MFE_PUSHED|MFE_SPRUNG|MFE_JUSTBOUNCEDWALL|MFE_DAMAGEHITLAG|MFE_SLOPELAUNCHED); - tmfloorthing = tmhitthing = NULL; + // sal: what the hell? is there any reason this isn't done, like, literally ANYWHERE else? + P_SetTarget(&tm.floorthing, NULL); + P_SetTarget(&tm.hitthing, NULL); // Sector flag MSF_TRIGGERLINE_MOBJ allows ANY mobj to trigger a linedef exec P_CheckMobjTrigger(mobj, false); @@ -9809,10 +9811,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 { diff --git a/src/p_polyobj.c b/src/p_polyobj.c index cd946e5ee..04f2c0d0c 100644 --- a/src/p_polyobj.c +++ b/src/p_polyobj.c @@ -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; } } diff --git a/src/p_setup.c b/src/p_setup.c index efadfedd9..92f054eb6 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -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(); diff --git a/src/p_sight.c b/src/p_sight.c index 4a8ccab39..64bba3969 100644 --- a/src/p_sight.c +++ b/src/p_sight.c @@ -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