diff --git a/src/f_finale.c b/src/f_finale.c index ff3690ea1..157f0dc48 100644 --- a/src/f_finale.c +++ b/src/f_finale.c @@ -1951,7 +1951,7 @@ void F_EndTextPrompt(boolean forceexec, boolean noexec) // \todo net safety, maybe loop all player thinkers? if ((promptwasactive || forceexec) && !noexec && promptpostexectag) { - if (tm.thing) // edge case where starting an invalid prompt immediately on level load will make P_MapStart fail + if (g_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 d98a9893d..da9283ed5 100644 --- a/src/k_collide.c +++ b/src/k_collide.c @@ -720,12 +720,12 @@ boolean K_BubbleShieldCollide(mobj_t *t1, mobj_t *t2) { // Counter desyncs /*mobj_t *oldthing = thing; - mobj_t *oldtm.thing = tm.thing; + mobj_t *oldg_tm.thing = g_tm.thing; - P_Thrust(tm.thing, R_PointToAngle2(thing->x, thing->y, tm.thing->x, tm.thing->y), 4*thing->scale); + P_Thrust(g_tm.thing, R_PointToAngle2(thing->x, thing->y, g_tm.thing->x, g_tm.thing->y), 4*thing->scale); thing = oldthing; - P_SetTarget(&tm.thing, oldtm.thing);*/ + P_SetTarget(&g_tm.thing, oldg_tm.thing);*/ if (P_PlayerInPain(t2->player) || t2->player->flashing || t2->player->hyudorotimer diff --git a/src/k_kart.c b/src/k_kart.c index 6c2ea08f5..7ed7eecd8 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -7589,7 +7589,7 @@ boolean K_SafeRespawnPosition(mobj_t * mo) po->validcount = validcount; - if (!P_BBoxInsidePolyobj(po, tm.bbox) + if (!P_BBoxInsidePolyobj(po, g_tm.bbox) || !(po->flags & POF_SOLID)) { plink = (polymaplink_t *)(plink->link.next); diff --git a/src/lua_baselib.c b/src/lua_baselib.c index c0b678234..36d6e174d 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -1041,7 +1041,8 @@ 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)); - tm_t ptm = tm; + tm_t ptm = g_tm; + NOHUD INLEVEL if (!mobj) @@ -1054,7 +1055,8 @@ static int lib_pRailThinker(lua_State *L) static int lib_pXYMovement(lua_State *L) { mobj_t *actor = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); - tm_t ptm = tm; + tm_t ptm = g_tm; + NOHUD INLEVEL if (!actor) @@ -1067,7 +1069,8 @@ static int lib_pXYMovement(lua_State *L) static int lib_pRingXYMovement(lua_State *L) { mobj_t *actor = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); - tm_t ptm = tm; + tm_t ptm = g_tm; + NOHUD INLEVEL if (!actor) @@ -1080,7 +1083,8 @@ static int lib_pRingXYMovement(lua_State *L) static int lib_pSceneryXYMovement(lua_State *L) { mobj_t *actor = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); - tm_t ptm = tm; + tm_t ptm = g_tm; + NOHUD INLEVEL if (!actor) @@ -1093,7 +1097,8 @@ static int lib_pSceneryXYMovement(lua_State *L) static int lib_pZMovement(lua_State *L) { mobj_t *actor = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); - tm_t ptm = tm; + tm_t ptm = g_tm; + NOHUD INLEVEL if (!actor) @@ -1107,7 +1112,8 @@ static int lib_pZMovement(lua_State *L) static int lib_pRingZMovement(lua_State *L) { mobj_t *actor = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); - tm_t ptm = tm; + tm_t ptm = g_tm; + NOHUD INLEVEL if (!actor) @@ -1121,7 +1127,8 @@ static int lib_pRingZMovement(lua_State *L) static int lib_pSceneryZMovement(lua_State *L) { mobj_t *actor = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); - tm_t ptm = tm; + tm_t ptm = g_tm; + NOHUD INLEVEL if (!actor) @@ -1135,7 +1142,8 @@ static int lib_pSceneryZMovement(lua_State *L) static int lib_pPlayerZMovement(lua_State *L) { mobj_t *actor = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); - tm_t ptm = tm; + tm_t ptm = g_tm; + NOHUD INLEVEL if (!actor) @@ -1354,7 +1362,8 @@ 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)); - tm_t ptm = tm; + tm_t ptm = g_tm; + NOHUD INLEVEL if (!player) @@ -1432,7 +1441,8 @@ static int lib_pNukeEnemies(lua_State *L) static int lib_pCheckPosition(lua_State *L) { - tm_t ptm = tm; + tm_t ptm = g_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); @@ -1441,14 +1451,15 @@ static int lib_pCheckPosition(lua_State *L) if (!thing) return LUA_ErrInvalid(L, "mobj_t"); lua_pushboolean(L, P_CheckPosition(thing, x, y, NULL)); - LUA_PushUserdata(L, tm.thing, META_MOBJ); + LUA_PushUserdata(L, g_tm.thing, META_MOBJ); P_RestoreTMStruct(ptm); return 2; } static int lib_pTryMove(lua_State *L) { - tm_t ptm = tm; + tm_t ptm = g_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); @@ -1458,14 +1469,15 @@ static int lib_pTryMove(lua_State *L) if (!thing) return LUA_ErrInvalid(L, "mobj_t"); lua_pushboolean(L, P_TryMove(thing, x, y, allowdropoff, NULL)); - LUA_PushUserdata(L, tm.thing, META_MOBJ); + LUA_PushUserdata(L, g_tm.thing, META_MOBJ); P_RestoreTMStruct(ptm); return 2; } static int lib_pMove(lua_State *L) { - tm_t ptm = tm; + tm_t ptm = g_tm; + mobj_t *actor = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); fixed_t speed = luaL_checkfixed(L, 2); NOHUD @@ -1473,14 +1485,15 @@ 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, tm.thing, META_MOBJ); + LUA_PushUserdata(L, g_tm.thing, META_MOBJ); P_RestoreTMStruct(ptm); return 2; } static int lib_pTeleportMove(lua_State *L) { - tm_t ptm = tm; + tm_t ptm = g_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); @@ -1491,14 +1504,15 @@ 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, tm.thing, META_MOBJ); + LUA_PushUserdata(L, g_tm.thing, META_MOBJ); P_RestoreTMStruct(ptm); return 2; } static int lib_pSetOrigin(lua_State *L) { - tm_t ptm = tm; + tm_t ptm = g_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); @@ -1508,14 +1522,15 @@ 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, tm.thing, META_MOBJ); + LUA_PushUserdata(L, g_tm.thing, META_MOBJ); P_RestoreTMStruct(ptm); return 2; } static int lib_pMoveOrigin(lua_State *L) { - tm_t ptm = tm; + tm_t ptm = g_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); @@ -1525,7 +1540,7 @@ 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, tm.thing, META_MOBJ); + LUA_PushUserdata(L, g_tm.thing, META_MOBJ); P_RestoreTMStruct(ptm); return 2; } diff --git a/src/lua_maplib.c b/src/lua_maplib.c index 77a3e6174..841141a26 100644 --- a/src/lua_maplib.c +++ b/src/lua_maplib.c @@ -812,7 +812,8 @@ static int sector_set(lua_State *L) return luaL_error(L, "sector_t has no field named " LUA_QS ".", lua_tostring(L, 2)); case sector_floorheight: { // floorheight boolean flag; - tm_t ptm = tm; + tm_t ptm = g_tm; + fixed_t lastpos = sector->floorheight; sector->floorheight = luaL_checkfixed(L, 3); flag = P_CheckSector(sector, true); @@ -826,7 +827,8 @@ static int sector_set(lua_State *L) } case sector_ceilingheight: { // ceilingheight boolean flag; - tm_t ptm = tm; + tm_t ptm = g_tm; + fixed_t lastpos = sector->ceilingheight; sector->ceilingheight = luaL_checkfixed(L, 3); flag = P_CheckSector(sector, true); @@ -2264,7 +2266,8 @@ static int ffloor_set(lua_State *L) case ffloor_topheight: { // topheight boolean flag; fixed_t lastpos = *ffloor->topheight; - tm_t ptm = tm; + tm_t ptm = g_tm; + sector_t *sector = §ors[ffloor->secnum]; sector->ceilingheight = luaL_checkfixed(L, 3); flag = P_CheckSector(sector, true); @@ -2285,7 +2288,8 @@ static int ffloor_set(lua_State *L) case ffloor_bottomheight: { // bottomheight boolean flag; fixed_t lastpos = *ffloor->bottomheight; - tm_t ptm = tm; + tm_t ptm = g_tm; + sector_t *sector = §ors[ffloor->secnum]; sector->floorheight = luaL_checkfixed(L, 3); flag = P_CheckSector(sector, true); diff --git a/src/lua_mobjlib.c b/src/lua_mobjlib.c index d86e3be04..4876325e8 100644 --- a/src/lua_mobjlib.c +++ b/src/lua_mobjlib.c @@ -648,13 +648,14 @@ static int mobj_set(lua_State *L) case mobj_z: { // z doesn't cross sector bounds so it's okay. - tm_t ptm = tm; + tm_t ptm = g_tm; + mo->z = luaL_checkfixed(L, 3); P_CheckPosition(mo, mo->x, mo->y, NULL); - mo->floorz = tm.floorz; - mo->ceilingz = tm.ceilingz; - mo->floorrover = tm.floorrover; - mo->ceilingrover = tm.ceilingrover; + mo->floorz = g_tm.floorz; + mo->ceilingz = g_tm.ceilingz; + mo->floorrover = g_tm.floorrover; + mo->ceilingrover = g_tm.ceilingrover; P_RestoreTMStruct(ptm); break; } @@ -726,29 +727,31 @@ static int mobj_set(lua_State *L) return NOSET; case mobj_radius: { - tm_t ptm = tm; + tm_t ptm = g_tm; + mo->radius = luaL_checkfixed(L, 3); if (mo->radius < 0) mo->radius = 0; P_CheckPosition(mo, mo->x, mo->y, NULL); - mo->floorz = tm.floorz; - mo->ceilingz = tm.ceilingz; - mo->floorrover = tm.floorrover; - mo->ceilingrover = tm.ceilingrover; + mo->floorz = g_tm.floorz; + mo->ceilingz = g_tm.ceilingz; + mo->floorrover = g_tm.floorrover; + mo->ceilingrover = g_tm.ceilingrover; P_RestoreTMStruct(ptm); break; } case mobj_height: { - tm_t ptm = tm; + tm_t ptm = g_tm; + mo->height = luaL_checkfixed(L, 3); if (mo->height < 0) mo->height = 0; P_CheckPosition(mo, mo->x, mo->y, NULL); - mo->floorz = tm.floorz; - mo->ceilingz = tm.ceilingz; - mo->floorrover = tm.floorrover; - mo->ceilingrover = tm.ceilingrover; + mo->floorz = g_tm.floorz; + mo->ceilingz = g_tm.ceilingz; + mo->floorrover = g_tm.floorrover; + mo->ceilingrover = g_tm.ceilingrover; P_RestoreTMStruct(ptm); break; } diff --git a/src/p_enemy.c b/src/p_enemy.c index 4b2720b5d..f9a08a5bf 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -269,10 +269,10 @@ boolean P_Move(mobj_t *actor, fixed_t speed) if (!P_TryMove(actor, tryx, tryy, false, NULL)) { - if (actor->flags & MF_FLOAT && tm.floatok) + if (actor->flags & MF_FLOAT && g_tm.floatok) { // must adjust height - if (actor->z < tm.floorz) + if (actor->z < g_tm.floorz) actor->z += FixedMul(FLOATSPEED, actor->scale); else actor->z -= FixedMul(FLOATSPEED, actor->scale); @@ -10312,13 +10312,13 @@ void A_FlickyCenter(mobj_t *actor) { actor->extravalue2 = 1; P_SetOrigin(actor, actor->target->x, actor->target->y, actor->target->z); - P_SetTarget(&tm.thing, NULL); + P_SetTarget(&g_tm.thing, NULL); } else if(actor->extravalue2) { actor->extravalue2 = 0; P_SetOrigin(actor, originx, originy, originz); - P_SetTarget(&tm.thing, NULL); + P_SetTarget(&g_tm.thing, NULL); } } } @@ -12997,7 +12997,7 @@ void A_ItemPop(mobj_t *actor) remains->skin = NULL; remains->spawnpoint = actor->spawnpoint; - P_SetTarget(&tm.thing, remains); + P_SetTarget(&g_tm.thing, remains); //if (actor->info->deathsound) //S_StartSound(remains, actor->info->deathsound); diff --git a/src/p_local.h b/src/p_local.h index c58ff19cf..dda30a5b8 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -405,12 +405,12 @@ struct tm_t fixed_t precipbbox[4]; // If "floatok" true, move would be ok - // if within "tm.floorz - tm.ceilingz". + // if within "g_tm.floorz - g_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 *floorthing; // the thing corresponding to g_tm.floorz or NULL if g_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; @@ -429,11 +429,11 @@ struct tm_t // lines boolean sweep; - // sweep: max step up at tm.x, tm.y + // sweep: max step up at g_tm.x, g_tm.y fixed_t maxstep; }; -extern tm_t tm; +extern tm_t g_tm; void P_RestoreTMStruct(tm_t tmrestore); diff --git a/src/p_map.c b/src/p_map.c index caa54063f..38e8a5beb 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -42,33 +42,33 @@ #include "m_perfstats.h" // ps_checkposition_calls -tm_t tm = {0}; +tm_t g_tm = {0}; void P_RestoreTMStruct(tm_t tmrestore) { // Reference count management // These are effectively a no-op if mobj remains the same - P_SetTarget(&tm.thing, tmrestore.thing); - P_SetTarget(&tm.floorthing, tmrestore.floorthing); - P_SetTarget(&tm.hitthing, tmrestore.hitthing); + P_SetTarget(&g_tm.thing, tmrestore.thing); + P_SetTarget(&g_tm.floorthing, tmrestore.floorthing); + P_SetTarget(&g_tm.hitthing, tmrestore.hitthing); // Restore state - tm = tmrestore; + g_tm = tmrestore; // Validation - if (tm.thing && P_MobjWasRemoved(tm.thing) == true) + if (g_tm.thing && P_MobjWasRemoved(g_tm.thing) == true) { - P_SetTarget(&tm.thing, NULL); + P_SetTarget(&g_tm.thing, NULL); } - if (tm.floorthing && P_MobjWasRemoved(tm.floorthing) == true) + if (g_tm.floorthing && P_MobjWasRemoved(g_tm.floorthing) == true) { - P_SetTarget(&tm.floorthing, NULL); + P_SetTarget(&g_tm.floorthing, NULL); } - if (tm.hitthing && P_MobjWasRemoved(tm.hitthing) == true) + if (g_tm.hitthing && P_MobjWasRemoved(g_tm.hitthing) == true) { - P_SetTarget(&tm.hitthing, NULL); + P_SetTarget(&g_tm.hitthing, NULL); } } @@ -124,10 +124,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 = tm.floorz; - thing->ceilingz = tm.ceilingz; - thing->floorrover = tm.floorrover; - thing->ceilingrover = tm.ceilingrover; + thing->floorz = g_tm.floorz; + thing->ceilingz = g_tm.ceilingz; + thing->floorrover = g_tm.floorrover; + thing->ceilingrover = g_tm.ceilingrover; return true; } @@ -469,28 +469,28 @@ static BlockItReturn_t PIT_CheckThing(mobj_t *thing) { fixed_t blockdist; - if (tm.thing == NULL || P_MobjWasRemoved(tm.thing) == true) - return BMIT_STOP; // func just popped our tm.thing, cannot continue. + if (g_tm.thing == NULL || P_MobjWasRemoved(g_tm.thing) == true) + return BMIT_STOP; // func just popped our g_tm.thing, cannot continue. // Ignore... things. if (thing == NULL || P_MobjWasRemoved(thing) == true) return BMIT_CONTINUE; // don't clip against self - if (thing == tm.thing) + if (thing == g_tm.thing) return BMIT_CONTINUE; // Ignore spectators - if ((tm.thing->player && tm.thing->player->spectator) + if ((g_tm.thing->player && g_tm.thing->player->spectator) || (thing->player && thing->player->spectator)) 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 + tm.thing->radius; + blockdist = thing->radius + g_tm.thing->radius; - if (abs(thing->x - tm.x) >= blockdist || abs(thing->y - tm.y) >= blockdist) + if (abs(thing->x - g_tm.x) >= blockdist || abs(thing->y - g_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. @@ -512,47 +512,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 (tm.thing->flags & MF_PAPERCOLLISION) // more strenuous checking to prevent clipping issues + if (g_tm.thing->flags & MF_PAPERCOLLISION) // more strenuous checking to prevent clipping issues { INT32 check1, check2, check3, check4; - 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))) + fixed_t tmcosradius = FixedMul(g_tm.thing->radius, FINECOSINE(g_tm.thing->angle>>ANGLETOFINESHIFT)); + fixed_t tmsinradius = FixedMul(g_tm.thing->radius, FINESINE(g_tm.thing->angle>>ANGLETOFINESHIFT)); + if (abs(thing->x - g_tm.x) >= (abs(tmcosradius) + abs(cosradius)) || abs(thing->y - g_tm.y) >= (abs(tmsinradius) + abs(sinradius))) return BMIT_CONTINUE; // didn't hit it - 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); + check1 = P_PointOnLineSide(g_tm.x - tmcosradius, g_tm.y - tmsinradius, &junk); + check2 = P_PointOnLineSide(g_tm.x + tmcosradius, g_tm.y + tmsinradius, &junk); + check3 = P_PointOnLineSide(g_tm.x + g_tm.thing->momx - tmcosradius, g_tm.y + g_tm.thing->momy - tmsinradius, &junk); + check4 = P_PointOnLineSide(g_tm.x + g_tm.thing->momx + tmcosradius, g_tm.y + g_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 - tm.x) >= (tm.thing->radius + abs(cosradius)) || abs(thing->y - tm.y) >= (tm.thing->radius + abs(sinradius))) + if (abs(thing->x - g_tm.x) >= (g_tm.thing->radius + abs(cosradius)) || abs(thing->y - g_tm.y) >= (g_tm.thing->radius + abs(sinradius))) return BMIT_CONTINUE; // didn't hit it - 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))) + if ((P_PointOnLineSide(g_tm.x - g_tm.thing->radius, g_tm.y - g_tm.thing->radius, &junk) + == P_PointOnLineSide(g_tm.x + g_tm.thing->radius, g_tm.y + g_tm.thing->radius, &junk)) + && (P_PointOnLineSide(g_tm.x + g_tm.thing->radius, g_tm.y - g_tm.thing->radius, &junk) + == P_PointOnLineSide(g_tm.x - g_tm.thing->radius, g_tm.y + g_tm.thing->radius, &junk))) return BMIT_CONTINUE; // the line doesn't cross between either pair of opposite corners } } - else if (tm.thing->flags & MF_PAPERCOLLISION) + else if (g_tm.thing->flags & MF_PAPERCOLLISION) { fixed_t tmcosradius, tmsinradius; vertex_t v1, v2; // fake vertexes line_t junk; // fake linedef - tmcosradius = FixedMul(tm.thing->radius, FINECOSINE(tm.thing->angle>>ANGLETOFINESHIFT)); - tmsinradius = FixedMul(tm.thing->radius, FINESINE(tm.thing->angle>>ANGLETOFINESHIFT)); + tmcosradius = FixedMul(g_tm.thing->radius, FINECOSINE(g_tm.thing->angle>>ANGLETOFINESHIFT)); + tmsinradius = FixedMul(g_tm.thing->radius, FINESINE(g_tm.thing->angle>>ANGLETOFINESHIFT)); - if (abs(thing->x - tm.x) >= (thing->radius + abs(tmcosradius)) || abs(thing->y - tm.y) >= (thing->radius + abs(tmsinradius))) + if (abs(thing->x - g_tm.x) >= (thing->radius + abs(tmcosradius)) || abs(thing->y - g_tm.y) >= (thing->radius + abs(tmsinradius))) return BMIT_CONTINUE; // didn't hit it - v1.x = tm.x - tmcosradius; - v1.y = tm.y - tmsinradius; - v2.x = tm.x + tmcosradius; - v2.y = tm.y + tmsinradius; + v1.x = g_tm.x - tmcosradius; + v1.y = g_tm.y - tmsinradius; + v2.x = g_tm.x + tmcosradius; + v2.y = g_tm.y + tmsinradius; junk.v1 = &v1; junk.v2 = &v2; @@ -568,16 +568,16 @@ static BlockItReturn_t PIT_CheckThing(mobj_t *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)) + UINT8 shouldCollide = LUA_Hook2Mobj(thing, g_tm.thing, MOBJ_HOOK(MobjCollide)); // checks hook for thing's type + if (P_MobjWasRemoved(g_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(tm.thing, thing, MOBJ_HOOK(MobjMoveCollide)); // checks hook for tm.thing's type - if (P_MobjWasRemoved(tm.thing) || P_MobjWasRemoved(thing)) + shouldCollide = LUA_Hook2Mobj(g_tm.thing, thing, MOBJ_HOOK(MobjMoveCollide)); // checks hook for g_tm.thing's type + if (P_MobjWasRemoved(g_tm.thing) || P_MobjWasRemoved(thing)) return BMIT_CONTINUE; // one of them was removed??? if (shouldCollide == 1) return BMIT_ABORT; // force collide @@ -586,66 +586,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 (tm.thing->type == MT_SPIKE && tm.thing->flags & MF_SOLID) + if (g_tm.thing->type == MT_SPIKE && g_tm.thing->flags & MF_SOLID) { - if (thing->z > tm.thing->z + tm.thing->height) + if (thing->z > g_tm.thing->z + g_tm.thing->height) return BMIT_CONTINUE; // overhead - if (thing->z + thing->height < tm.thing->z) + if (thing->z + thing->height < g_tm.thing->z) return BMIT_CONTINUE; // underneath - if (tm.thing->eflags & MFE_VERTICALFLIP) - P_SetOrigin(thing, thing->x, thing->y, tm.thing->z - thing->height - FixedMul(FRACUNIT, tm.thing->scale)); + if (g_tm.thing->eflags & MFE_VERTICALFLIP) + P_SetOrigin(thing, thing->x, thing->y, g_tm.thing->z - thing->height - FixedMul(FRACUNIT, g_tm.thing->scale)); else - P_SetOrigin(thing, thing->x, thing->y, tm.thing->z + tm.thing->height + FixedMul(FRACUNIT, tm.thing->scale)); + P_SetOrigin(thing, thing->x, thing->y, g_tm.thing->z + g_tm.thing->height + FixedMul(FRACUNIT, g_tm.thing->scale)); if (thing->flags & MF_SHOOTABLE) - P_DamageMobj(thing, tm.thing, tm.thing, 1, 0); + P_DamageMobj(thing, g_tm.thing, g_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 > tm.thing->z + tm.thing->height) + if (thing->z > g_tm.thing->z + g_tm.thing->height) return BMIT_CONTINUE; // overhead - if (thing->z + thing->height < tm.thing->z) + if (thing->z + thing->height < g_tm.thing->z) return BMIT_CONTINUE; // underneath - if (tm.thing->player && tm.thing->flags & MF_SHOOTABLE && thing->health > 0) + if (g_tm.thing->player && g_tm.thing->flags & MF_SHOOTABLE && thing->health > 0) { - UINT32 damagetype = (tm.thing->info->mass & DMG_TYPEMASK); + UINT32 damagetype = (g_tm.thing->info->mass & DMG_TYPEMASK); if (!damagetype && thing->flags & MF_FIRE) // BURN! damagetype = DMG_NORMAL; - P_DamageMobj(tm.thing, thing, thing, 1, damagetype); + P_DamageMobj(g_tm.thing, thing, thing, 1, damagetype); } return BMIT_CONTINUE; } - else if (tm.thing->flags & MF_PAIN) + else if (g_tm.thing->flags & MF_PAIN) { // Painful thing splats player in the face // see if it went over / under - if (tm.thing->z > thing->z + thing->height) + if (g_tm.thing->z > thing->z + thing->height) return BMIT_CONTINUE; // overhead - if (tm.thing->z + tm.thing->height < thing->z) + if (g_tm.thing->z + g_tm.thing->height < thing->z) return BMIT_CONTINUE; // underneath - if (thing->player && thing->flags & MF_SHOOTABLE && tm.thing->health > 0) + if (thing->player && thing->flags & MF_SHOOTABLE && g_tm.thing->health > 0) { - UINT32 damagetype = (tm.thing->info->mass & DMG_TYPEMASK); - if (!damagetype && tm.thing->flags & MF_FIRE) // BURN! + UINT32 damagetype = (g_tm.thing->info->mass & DMG_TYPEMASK); + if (!damagetype && g_tm.thing->flags & MF_FIRE) // BURN! damagetype = DMG_NORMAL; - P_DamageMobj(thing, tm.thing, tm.thing, 1, damagetype); + P_DamageMobj(thing, g_tm.thing, g_tm.thing, 1, damagetype); } return BMIT_CONTINUE; } // check for skulls slamming into things - if (tm.thing->flags2 & MF2_SKULLFLY) + if (g_tm.thing->flags2 & MF2_SKULLFLY) { // see if it went over / under - if (tm.thing->z > thing->z + thing->height) + if (g_tm.thing->z > thing->z + thing->height) return BMIT_CONTINUE; // overhead - if (tm.thing->z + tm.thing->height < thing->z) + if (g_tm.thing->z + g_tm.thing->height < thing->z) return BMIT_CONTINUE; // underneath - tm.thing->flags2 &= ~MF2_SKULLFLY; - tm.thing->momx = tm.thing->momy = tm.thing->momz = 0; + g_tm.thing->flags2 &= ~MF2_SKULLFLY; + g_tm.thing->momx = g_tm.thing->momy = g_tm.thing->momz = 0; return BMIT_ABORT; // stop moving } @@ -654,252 +654,252 @@ static BlockItReturn_t PIT_CheckThing(mobj_t *thing) if (thing->type == MT_SMK_ICEBLOCK) { // see if it went over / under - if (tm.thing->z > thing->z + thing->height) + if (g_tm.thing->z > thing->z + thing->height) return BMIT_CONTINUE; // overhead - if (tm.thing->z + tm.thing->height < thing->z) + if (g_tm.thing->z + g_tm.thing->height < thing->z) return BMIT_CONTINUE; // underneath - return K_SMKIceBlockCollide(thing, tm.thing) ? BMIT_CONTINUE : BMIT_ABORT; + return K_SMKIceBlockCollide(thing, g_tm.thing) ? BMIT_CONTINUE : BMIT_ABORT; } - if (tm.thing->type == MT_EGGMANITEM || tm.thing->type == MT_EGGMANITEM_SHIELD) + if (g_tm.thing->type == MT_EGGMANITEM || g_tm.thing->type == MT_EGGMANITEM_SHIELD) { // see if it went over / under - if (tm.thing->z > thing->z + thing->height) + if (g_tm.thing->z > thing->z + thing->height) return BMIT_CONTINUE; // overhead - if (tm.thing->z + tm.thing->height < thing->z) + if (g_tm.thing->z + g_tm.thing->height < thing->z) return BMIT_CONTINUE; // underneath - return K_EggItemCollide(tm.thing, thing) ? BMIT_CONTINUE : BMIT_ABORT; + return K_EggItemCollide(g_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 (tm.thing->z > thing->z + thing->height) + if (g_tm.thing->z > thing->z + thing->height) return BMIT_CONTINUE; // overhead - if (tm.thing->z + tm.thing->height < thing->z) + if (g_tm.thing->z + g_tm.thing->height < thing->z) return BMIT_CONTINUE; // underneath - return K_EggItemCollide(thing, tm.thing) ? BMIT_CONTINUE : BMIT_ABORT; + return K_EggItemCollide(thing, g_tm.thing) ? BMIT_CONTINUE : BMIT_ABORT; } - if (tm.thing->type == MT_RANDOMITEM) + if (g_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)) - && (tm.thing->type == MT_ORBINAUT || tm.thing->type == MT_JAWZ || tm.thing->type == MT_JAWZ_DUD - || 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_PLAYER && thing->target != tm.thing))) + && (g_tm.thing->type == MT_ORBINAUT || g_tm.thing->type == MT_JAWZ || g_tm.thing->type == MT_JAWZ_DUD + || g_tm.thing->type == MT_BANANA || g_tm.thing->type == MT_EGGMANITEM || g_tm.thing->type == MT_BALLHOG + || g_tm.thing->type == MT_SSMINE || g_tm.thing->type == MT_LANDMINE || g_tm.thing->type == MT_SINK + || (g_tm.thing->type == MT_PLAYER && thing->target != g_tm.thing))) { // see if it went over / under - if (tm.thing->z > thing->z + thing->height) + if (g_tm.thing->z > thing->z + thing->height) return BMIT_CONTINUE; // overhead - if (tm.thing->z + tm.thing->height < thing->z) + if (g_tm.thing->z + g_tm.thing->height < thing->z) return BMIT_CONTINUE; // underneath - return K_BubbleShieldCollide(thing, tm.thing) ? BMIT_CONTINUE : BMIT_ABORT; + return K_BubbleShieldCollide(thing, g_tm.thing) ? BMIT_CONTINUE : BMIT_ABORT; } - else if (((tm.thing->type == MT_BUBBLESHIELD && tm.thing->target->player && tm.thing->target->player->bubbleblowup) - || (tm.thing->player && tm.thing->player->bubbleblowup)) + else if (((g_tm.thing->type == MT_BUBBLESHIELD && g_tm.thing->target->player && g_tm.thing->target->player->bubbleblowup) + || (g_tm.thing->player && g_tm.thing->player->bubbleblowup)) && (thing->type == MT_ORBINAUT || thing->type == MT_JAWZ || thing->type == MT_JAWZ_DUD || thing->type == MT_BANANA || thing->type == MT_EGGMANITEM || thing->type == MT_BALLHOG - || thing->type == MT_SSMINE || tm.thing->type == MT_LANDMINE || thing->type == MT_SINK - || (thing->type == MT_PLAYER && tm.thing->target != thing))) + || thing->type == MT_SSMINE || g_tm.thing->type == MT_LANDMINE || thing->type == MT_SINK + || (thing->type == MT_PLAYER && g_tm.thing->target != thing))) { // see if it went over / under - if (tm.thing->z > thing->z + thing->height) + if (g_tm.thing->z > thing->z + thing->height) return BMIT_CONTINUE; // overhead - if (tm.thing->z + tm.thing->height < thing->z) + if (g_tm.thing->z + g_tm.thing->height < thing->z) return BMIT_CONTINUE; // underneath - return K_BubbleShieldCollide(tm.thing, thing) ? BMIT_CONTINUE : BMIT_ABORT; + return K_BubbleShieldCollide(g_tm.thing, thing) ? BMIT_CONTINUE : BMIT_ABORT; } // double make sure bubbles won't collide with anything else - if (thing->type == MT_BUBBLESHIELD || tm.thing->type == MT_BUBBLESHIELD) + if (thing->type == MT_BUBBLESHIELD || g_tm.thing->type == MT_BUBBLESHIELD) return BMIT_CONTINUE; // Droptarget reflect if ((thing->type == MT_DROPTARGET || thing->type == MT_DROPTARGET_SHIELD) - && (tm.thing->type == MT_ORBINAUT || tm.thing->type == MT_JAWZ || tm.thing->type == MT_JAWZ_DUD - || 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_PLAYER))) + && (g_tm.thing->type == MT_ORBINAUT || g_tm.thing->type == MT_JAWZ || g_tm.thing->type == MT_JAWZ_DUD + || g_tm.thing->type == MT_BANANA || g_tm.thing->type == MT_EGGMANITEM || g_tm.thing->type == MT_BALLHOG + || g_tm.thing->type == MT_SSMINE || g_tm.thing->type == MT_LANDMINE || g_tm.thing->type == MT_SINK + || (g_tm.thing->type == MT_PLAYER))) { // see if it went over / under - if (tm.thing->z > thing->z + thing->height) + if (g_tm.thing->z > thing->z + thing->height) return BMIT_CONTINUE; // overhead - if (tm.thing->z + tm.thing->height < thing->z) + if (g_tm.thing->z + g_tm.thing->height < thing->z) return BMIT_CONTINUE; // underneath - return K_DropTargetCollide(thing, tm.thing) ? BMIT_CONTINUE : BMIT_ABORT; + return K_DropTargetCollide(thing, g_tm.thing) ? BMIT_CONTINUE : BMIT_ABORT; } - else if ((tm.thing->type == MT_DROPTARGET || tm.thing->type == MT_DROPTARGET_SHIELD) + else if ((g_tm.thing->type == MT_DROPTARGET || g_tm.thing->type == MT_DROPTARGET_SHIELD) && (thing->type == MT_ORBINAUT || thing->type == MT_JAWZ || thing->type == MT_JAWZ_DUD || thing->type == MT_BANANA || thing->type == MT_EGGMANITEM || thing->type == MT_BALLHOG - || thing->type == MT_SSMINE || tm.thing->type == MT_LANDMINE || thing->type == MT_SINK + || thing->type == MT_SSMINE || g_tm.thing->type == MT_LANDMINE || thing->type == MT_SINK || (thing->type == MT_PLAYER))) { // see if it went over / under - if (tm.thing->z > thing->z + thing->height) + if (g_tm.thing->z > thing->z + thing->height) return BMIT_CONTINUE; // overhead - if (tm.thing->z + tm.thing->height < thing->z) + if (g_tm.thing->z + g_tm.thing->height < thing->z) return BMIT_CONTINUE; // underneath - return K_DropTargetCollide(tm.thing, thing) ? BMIT_CONTINUE : BMIT_ABORT; + return K_DropTargetCollide(g_tm.thing, thing) ? BMIT_CONTINUE : BMIT_ABORT; } // double make sure drop targets won't collide with anything else - if (thing->type == MT_DROPTARGET || tm.thing->type == MT_DROPTARGET - || thing->type == MT_DROPTARGET_SHIELD || tm.thing->type == MT_DROPTARGET_SHIELD) + if (thing->type == MT_DROPTARGET || g_tm.thing->type == MT_DROPTARGET + || thing->type == MT_DROPTARGET_SHIELD || g_tm.thing->type == MT_DROPTARGET_SHIELD) return BMIT_CONTINUE; - if (tm.thing->type == MT_ORBINAUT || tm.thing->type == MT_JAWZ || tm.thing->type == MT_JAWZ_DUD - || tm.thing->type == MT_ORBINAUT_SHIELD || tm.thing->type == MT_JAWZ_SHIELD) + if (g_tm.thing->type == MT_ORBINAUT || g_tm.thing->type == MT_JAWZ || g_tm.thing->type == MT_JAWZ_DUD + || g_tm.thing->type == MT_ORBINAUT_SHIELD || g_tm.thing->type == MT_JAWZ_SHIELD) { // see if it went over / under - if (tm.thing->z > thing->z + thing->height) + if (g_tm.thing->z > thing->z + thing->height) return BMIT_CONTINUE; // overhead - if (tm.thing->z + tm.thing->height < thing->z) + if (g_tm.thing->z + g_tm.thing->height < thing->z) return BMIT_CONTINUE; // underneath - return K_OrbinautJawzCollide(tm.thing, thing) ? BMIT_CONTINUE : BMIT_ABORT; + return K_OrbinautJawzCollide(g_tm.thing, thing) ? BMIT_CONTINUE : BMIT_ABORT; } else if (thing->type == MT_ORBINAUT || thing->type == MT_JAWZ || thing->type == MT_JAWZ_DUD || thing->type == MT_ORBINAUT_SHIELD || thing->type == MT_JAWZ_SHIELD) { // see if it went over / under - if (tm.thing->z > thing->z + thing->height) + if (g_tm.thing->z > thing->z + thing->height) return BMIT_CONTINUE; // overhead - if (tm.thing->z + tm.thing->height < thing->z) + if (g_tm.thing->z + g_tm.thing->height < thing->z) return BMIT_CONTINUE; // underneath - return K_OrbinautJawzCollide(thing, tm.thing) ? BMIT_CONTINUE : BMIT_ABORT; + return K_OrbinautJawzCollide(thing, g_tm.thing) ? BMIT_CONTINUE : BMIT_ABORT; } - if (tm.thing->type == MT_BANANA || tm.thing->type == MT_BANANA_SHIELD || tm.thing->type == MT_BALLHOG) + if (g_tm.thing->type == MT_BANANA || g_tm.thing->type == MT_BANANA_SHIELD || g_tm.thing->type == MT_BALLHOG) { // see if it went over / under - if (tm.thing->z > thing->z + thing->height) + if (g_tm.thing->z > thing->z + thing->height) return BMIT_CONTINUE; // overhead - if (tm.thing->z + tm.thing->height < thing->z) + if (g_tm.thing->z + g_tm.thing->height < thing->z) return BMIT_CONTINUE; // underneath - return K_BananaBallhogCollide(tm.thing, thing) ? BMIT_CONTINUE : BMIT_ABORT; + return K_BananaBallhogCollide(g_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 (tm.thing->z > thing->z + thing->height) + if (g_tm.thing->z > thing->z + thing->height) return BMIT_CONTINUE; // overhead - if (tm.thing->z + tm.thing->height < thing->z) + if (g_tm.thing->z + g_tm.thing->height < thing->z) return BMIT_CONTINUE; // underneath - return K_BananaBallhogCollide(thing, tm.thing) ? BMIT_CONTINUE : BMIT_ABORT; + return K_BananaBallhogCollide(thing, g_tm.thing) ? BMIT_CONTINUE : BMIT_ABORT; } - if (tm.thing->type == MT_SSMINE || tm.thing->type == MT_SSMINE_SHIELD) + if (g_tm.thing->type == MT_SSMINE || g_tm.thing->type == MT_SSMINE_SHIELD) { // see if it went over / under - if (tm.thing->z > thing->z + thing->height) + if (g_tm.thing->z > thing->z + thing->height) return BMIT_CONTINUE; // overhead - if (tm.thing->z + tm.thing->height < thing->z) + if (g_tm.thing->z + g_tm.thing->height < thing->z) return BMIT_CONTINUE; // underneath - return K_MineCollide(tm.thing, thing) ? BMIT_CONTINUE : BMIT_ABORT; + return K_MineCollide(g_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 (tm.thing->z > thing->z + thing->height) + if (g_tm.thing->z > thing->z + thing->height) return BMIT_CONTINUE; // overhead - if (tm.thing->z + tm.thing->height < thing->z) + if (g_tm.thing->z + g_tm.thing->height < thing->z) return BMIT_CONTINUE; // underneath - return K_MineCollide(thing, tm.thing) ? BMIT_CONTINUE : BMIT_ABORT; + return K_MineCollide(thing, g_tm.thing) ? BMIT_CONTINUE : BMIT_ABORT; } - if (tm.thing->type == MT_LANDMINE) + if (g_tm.thing->type == MT_LANDMINE) { // see if it went over / under - if (tm.thing->z > thing->z + thing->height) + if (g_tm.thing->z > thing->z + thing->height) return BMIT_CONTINUE; // overhead - if (tm.thing->z + tm.thing->height < thing->z) + if (g_tm.thing->z + g_tm.thing->height < thing->z) return BMIT_CONTINUE; // underneath - return K_LandMineCollide(tm.thing, thing) ? BMIT_CONTINUE : BMIT_ABORT; + return K_LandMineCollide(g_tm.thing, thing) ? BMIT_CONTINUE : BMIT_ABORT; } else if (thing->type == MT_LANDMINE) { // see if it went over / under - if (tm.thing->z > thing->z + thing->height) + if (g_tm.thing->z > thing->z + thing->height) return BMIT_CONTINUE; // overhead - if (tm.thing->z + tm.thing->height < thing->z) + if (g_tm.thing->z + g_tm.thing->height < thing->z) return BMIT_CONTINUE; // underneath - return K_LandMineCollide(thing, tm.thing) ? BMIT_CONTINUE : BMIT_ABORT; + return K_LandMineCollide(thing, g_tm.thing) ? BMIT_CONTINUE : BMIT_ABORT; } - if (tm.thing->type == MT_SINK) + if (g_tm.thing->type == MT_SINK) { // see if it went over / under - if (tm.thing->z > thing->z + thing->height) + if (g_tm.thing->z > thing->z + thing->height) return BMIT_CONTINUE; // overhead - if (tm.thing->z + tm.thing->height < thing->z) + if (g_tm.thing->z + g_tm.thing->height < thing->z) return BMIT_CONTINUE; // underneath - return K_KitchenSinkCollide(tm.thing, thing) ? BMIT_CONTINUE : BMIT_ABORT; + return K_KitchenSinkCollide(g_tm.thing, thing) ? BMIT_CONTINUE : BMIT_ABORT; } else if (thing->type == MT_SINK) { // see if it went over / under - if (tm.thing->z > thing->z + thing->height) + if (g_tm.thing->z > thing->z + thing->height) return BMIT_CONTINUE; // overhead - if (tm.thing->z + tm.thing->height < thing->z) + if (g_tm.thing->z + g_tm.thing->height < thing->z) return BMIT_CONTINUE; // underneath - return K_KitchenSinkCollide(thing, tm.thing) ? BMIT_CONTINUE : BMIT_ABORT; + return K_KitchenSinkCollide(thing, g_tm.thing) ? BMIT_CONTINUE : BMIT_ABORT; } - if (tm.thing->type == MT_FALLINGROCK) + if (g_tm.thing->type == MT_FALLINGROCK) { // see if it went over / under - if (tm.thing->z > thing->z + thing->height) + if (g_tm.thing->z > thing->z + thing->height) return BMIT_CONTINUE; // overhead - if (tm.thing->z + tm.thing->height < thing->z) + if (g_tm.thing->z + g_tm.thing->height < thing->z) return BMIT_CONTINUE; // underneath - return K_FallingRockCollide(tm.thing, thing) ? BMIT_CONTINUE : BMIT_ABORT; + return K_FallingRockCollide(g_tm.thing, thing) ? BMIT_CONTINUE : BMIT_ABORT; } else if (thing->type == MT_FALLINGROCK) { // see if it went over / under - if (tm.thing->z > thing->z + thing->height) + if (g_tm.thing->z > thing->z + thing->height) return BMIT_CONTINUE; // overhead - if (tm.thing->z + tm.thing->height < thing->z) + if (g_tm.thing->z + g_tm.thing->height < thing->z) return BMIT_CONTINUE; // underneath - return K_FallingRockCollide(thing, tm.thing) ? BMIT_CONTINUE : BMIT_ABORT; + return K_FallingRockCollide(thing, g_tm.thing) ? BMIT_CONTINUE : BMIT_ABORT; } //} if ((thing->type == MT_SPRINGSHELL || thing->type == MT_YELLOWSHELL) && thing->health > 0 - && (tm.thing->player || (tm.thing->flags & MF_PUSHABLE)) && tm.thing->health > 0) + && (g_tm.thing->player || (g_tm.thing->flags & MF_PUSHABLE)) && g_tm.thing->health > 0) { // Multiplying by -1 inherently flips "less than" and "greater than" - 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 tmz = ((thing->eflags & MFE_VERTICALFLIP) ? -(g_tm.thing->z + g_tm.thing->height) : g_tm.thing->z); + fixed_t tmznext = ((thing->eflags & MFE_VERTICALFLIP) ? -g_tm.thing->momz : g_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, tm.thing); + P_DoSpring(thing, g_tm.thing); // return BMIT_CONTINUE; } //else if (tmz > thzh - sprarea && tmz < thzh) // Don't damage people springing up / down @@ -907,20 +907,20 @@ static BlockItReturn_t PIT_CheckThing(mobj_t *thing) } // missiles can hit other things - if (tm.thing->flags & MF_MISSILE) + if (g_tm.thing->flags & MF_MISSILE) { - UINT8 damagetype = tm.thing->info->mass; + UINT8 damagetype = g_tm.thing->info->mass; // see if it went over / under - if (tm.thing->z > thing->z + thing->height) + if (g_tm.thing->z > thing->z + thing->height) return BMIT_CONTINUE; // overhead - if (tm.thing->z + tm.thing->height < thing->z) + if (g_tm.thing->z + g_tm.thing->height < thing->z) return BMIT_CONTINUE; // underneath - if (tm.thing->target && tm.thing->target->type == thing->type) + if (g_tm.thing->target && g_tm.thing->target->type == thing->type) { // Don't hit same species as originator. - if (thing == tm.thing->target) + if (thing == g_tm.thing->target) return BMIT_CONTINUE; if (thing->type != MT_PLAYER) @@ -938,40 +938,40 @@ static BlockItReturn_t PIT_CheckThing(mobj_t *thing) } // damage / explode - P_DamageMobj(thing, tm.thing, tm.thing->target, 1, damagetype); + P_DamageMobj(thing, g_tm.thing, g_tm.thing->target, 1, damagetype); // don't traverse any more return BMIT_ABORT; } - 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->flags & MF_PUSHABLE && (g_tm.thing->player || g_tm.thing->flags & MF_PUSHABLE) + && g_tm.thing->z + g_tm.thing->height > thing->z && g_tm.thing->z < thing->z + thing->height + && !(netgame && g_tm.thing->player && g_tm.thing->player->spectator)) // Push thing! { if (thing->flags2 & MF2_SLIDEPUSH) // Make it slide { - if (tm.thing->momy > 0 && tm.thing->momy > FixedMul(4*FRACUNIT, thing->scale) && tm.thing->momy > thing->momy) + if (g_tm.thing->momy > 0 && g_tm.thing->momy > FixedMul(4*FRACUNIT, thing->scale) && g_tm.thing->momy > thing->momy) { thing->momy += FixedMul(PUSHACCEL, thing->scale); - tm.thing->momy -= FixedMul(PUSHACCEL, thing->scale); + g_tm.thing->momy -= FixedMul(PUSHACCEL, thing->scale); } - else if (tm.thing->momy < 0 && tm.thing->momy < FixedMul(-4*FRACUNIT, thing->scale) - && tm.thing->momy < thing->momy) + else if (g_tm.thing->momy < 0 && g_tm.thing->momy < FixedMul(-4*FRACUNIT, thing->scale) + && g_tm.thing->momy < thing->momy) { thing->momy -= FixedMul(PUSHACCEL, thing->scale); - tm.thing->momy += FixedMul(PUSHACCEL, thing->scale); + g_tm.thing->momy += FixedMul(PUSHACCEL, thing->scale); } - if (tm.thing->momx > 0 && tm.thing->momx > FixedMul(4*FRACUNIT, thing->scale) - && tm.thing->momx > thing->momx) + if (g_tm.thing->momx > 0 && g_tm.thing->momx > FixedMul(4*FRACUNIT, thing->scale) + && g_tm.thing->momx > thing->momx) { thing->momx += FixedMul(PUSHACCEL, thing->scale); - tm.thing->momx -= FixedMul(PUSHACCEL, thing->scale); + g_tm.thing->momx -= FixedMul(PUSHACCEL, thing->scale); } - else if (tm.thing->momx < 0 && tm.thing->momx < FixedMul(-4*FRACUNIT, thing->scale) - && tm.thing->momx < thing->momx) + else if (g_tm.thing->momx < 0 && g_tm.thing->momx < FixedMul(-4*FRACUNIT, thing->scale) + && g_tm.thing->momx < thing->momx) { thing->momx -= FixedMul(PUSHACCEL, thing->scale); - tm.thing->momx += FixedMul(PUSHACCEL, thing->scale); + g_tm.thing->momx += FixedMul(PUSHACCEL, thing->scale); } if (thing->momx > FixedMul(thing->info->speed, thing->scale)) @@ -985,88 +985,88 @@ static BlockItReturn_t PIT_CheckThing(mobj_t *thing) } else { - 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); + if (g_tm.thing->momx > FixedMul(4*FRACUNIT, thing->scale)) + g_tm.thing->momx = FixedMul(4*FRACUNIT, thing->scale); + else if (g_tm.thing->momx < FixedMul(-4*FRACUNIT, thing->scale)) + g_tm.thing->momx = FixedMul(-4*FRACUNIT, thing->scale); + if (g_tm.thing->momy > FixedMul(4*FRACUNIT, thing->scale)) + g_tm.thing->momy = FixedMul(4*FRACUNIT, thing->scale); + else if (g_tm.thing->momy < FixedMul(-4*FRACUNIT, thing->scale)) + g_tm.thing->momy = FixedMul(-4*FRACUNIT, thing->scale); - thing->momx = tm.thing->momx; - thing->momy = tm.thing->momy; + thing->momx = g_tm.thing->momx; + thing->momy = g_tm.thing->momy; } if (thing->type != MT_GARGOYLE || P_IsObjectOnGround(thing)) S_StartSound(thing, thing->info->activesound); - P_SetTarget(&thing->target, tm.thing); + P_SetTarget(&thing->target, g_tm.thing); } // check for special pickup - if (thing->flags & MF_SPECIAL && tm.thing->player) + if (thing->flags & MF_SPECIAL && g_tm.thing->player) { - P_TouchSpecialThing(thing, tm.thing, true); // can remove thing + P_TouchSpecialThing(thing, g_tm.thing, true); // can remove thing return BMIT_CONTINUE; } // check again for special pickup - if (tm.thing->flags & MF_SPECIAL && thing->player) + if (g_tm.thing->flags & MF_SPECIAL && thing->player) { - P_TouchSpecialThing(tm.thing, thing, true); // can remove thing + P_TouchSpecialThing(g_tm.thing, thing, true); // can remove thing return BMIT_CONTINUE; } // Sprite Spikes! // Do not return because solidity code comes below. - if (tm.thing->type == MT_SPIKE && tm.thing->flags & MF_SOLID && thing->player) // moving spike rams into player?! + if (g_tm.thing->type == MT_SPIKE && g_tm.thing->flags & MF_SOLID && thing->player) // moving spike rams into player?! { - if (tm.thing->eflags & MFE_VERTICALFLIP) + if (g_tm.thing->eflags & MFE_VERTICALFLIP) { - 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); + if (thing->z + thing->height <= g_tm.thing->z + FixedMul(FRACUNIT, g_tm.thing->scale) + && thing->z + thing->height + thing->momz >= g_tm.thing->z + FixedMul(FRACUNIT, g_tm.thing->scale) + g_tm.thing->momz) + P_DamageMobj(thing, g_tm.thing, g_tm.thing, 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->z >= g_tm.thing->z + g_tm.thing->height - FixedMul(FRACUNIT, g_tm.thing->scale) + && thing->z + thing->momz <= g_tm.thing->z + g_tm.thing->height - FixedMul(FRACUNIT, g_tm.thing->scale) + g_tm.thing->momz) + P_DamageMobj(thing, g_tm.thing, g_tm.thing, 1, DMG_NORMAL); } - else if (thing->type == MT_SPIKE && thing->flags & MF_SOLID && tm.thing->player) // unfortunate player falls into spike?! + else if (thing->type == MT_SPIKE && thing->flags & MF_SOLID && g_tm.thing->player) // unfortunate player falls into spike?! { if (thing->eflags & MFE_VERTICALFLIP) { - 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); + if (g_tm.thing->z + g_tm.thing->height <= thing->z - FixedMul(FRACUNIT, thing->scale) + && g_tm.thing->z + g_tm.thing->height + g_tm.thing->momz >= thing->z - FixedMul(FRACUNIT, thing->scale)) + P_DamageMobj(g_tm.thing, 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); + else if (g_tm.thing->z >= thing->z + thing->height + FixedMul(FRACUNIT, thing->scale) + && g_tm.thing->z + g_tm.thing->momz <= thing->z + thing->height + FixedMul(FRACUNIT, thing->scale)) + P_DamageMobj(g_tm.thing, thing, thing, 1, DMG_NORMAL); } - if (tm.thing->type == MT_WALLSPIKE && tm.thing->flags & MF_SOLID && thing->player) // wall spike impales player + if (g_tm.thing->type == MT_WALLSPIKE && g_tm.thing->flags & MF_SOLID && thing->player) // wall spike impales player { fixed_t bottomz, topz; - bottomz = tm.thing->z; - topz = tm.thing->z + tm.thing->height; - if (tm.thing->eflags & MFE_VERTICALFLIP) - bottomz -= FixedMul(FRACUNIT, tm.thing->scale); + bottomz = g_tm.thing->z; + topz = g_tm.thing->z + g_tm.thing->height; + if (g_tm.thing->eflags & MFE_VERTICALFLIP) + bottomz -= FixedMul(FRACUNIT, g_tm.thing->scale); else - topz += FixedMul(FRACUNIT, tm.thing->scale); + topz += FixedMul(FRACUNIT, g_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, tm.thing, tm.thing, 1, DMG_NORMAL); + P_DamageMobj(thing, g_tm.thing, g_tm.thing, 1, DMG_NORMAL); } - else if (thing->type == MT_WALLSPIKE && thing->flags & MF_SOLID && tm.thing->player) + else if (thing->type == MT_WALLSPIKE && thing->flags & MF_SOLID && g_tm.thing->player) { fixed_t bottomz, topz; - angle_t touchangle = R_PointToAngle2(thing->tracer->x, thing->tracer->y, tm.thing->x, tm.thing->y); + angle_t touchangle = R_PointToAngle2(thing->tracer->x, thing->tracer->y, g_tm.thing->x, g_tm.thing->y); - if (P_PlayerInPain(tm.thing->player) && (tm.thing->momx || tm.thing->momy)) + if (P_PlayerInPain(g_tm.thing->player) && (g_tm.thing->momx || g_tm.thing->momy)) { - angle_t playerangle = R_PointToAngle2(0, 0, tm.thing->momx, tm.thing->momy) - touchangle; + angle_t playerangle = R_PointToAngle2(0, 0, g_tm.thing->momx, g_tm.thing->momy) - touchangle; if (playerangle > ANGLE_180) playerangle = InvAngle(playerangle); if (playerangle < ANGLE_90) @@ -1081,150 +1081,150 @@ static BlockItReturn_t PIT_CheckThing(mobj_t *thing) else topz += FixedMul(FRACUNIT, thing->scale); - if (tm.thing->z + tm.thing->height > bottomz // above bottom - && tm.thing->z < topz // below top + if (g_tm.thing->z + g_tm.thing->height > bottomz // above bottom + && g_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(tm.thing, thing, thing, 1, DMG_NORMAL); + P_DamageMobj(g_tm.thing, thing, thing, 1, DMG_NORMAL); } } if (thing->flags & MF_PUSHABLE) { - if (tm.thing->type == MT_FAN || tm.thing->type == MT_STEAM) - P_DoFanAndGasJet(tm.thing, thing); + if (g_tm.thing->type == MT_FAN || g_tm.thing->type == MT_STEAM) + P_DoFanAndGasJet(g_tm.thing, thing); } - if (tm.thing->flags & MF_PUSHABLE) + if (g_tm.thing->flags & MF_PUSHABLE) { if (thing->type == MT_FAN || thing->type == MT_STEAM) { - P_DoFanAndGasJet(thing, tm.thing); + P_DoFanAndGasJet(thing, g_tm.thing); return BMIT_CONTINUE; } else if (thing->flags & MF_SPRING) { - if ( thing->z <= tm.thing->z + tm.thing->height - && tm.thing->z <= thing->z + thing->height) - if (P_DoSpring(thing, tm.thing)) + if ( thing->z <= g_tm.thing->z + g_tm.thing->height + && g_tm.thing->z <= thing->z + thing->height) + if (P_DoSpring(thing, g_tm.thing)) return BMIT_ABORT; return BMIT_CONTINUE; } } // thanks to sal for solidenemies dot lua - if (thing->flags & (MF_ENEMY|MF_BOSS) && tm.thing->flags & (MF_ENEMY|MF_BOSS)) + if (thing->flags & (MF_ENEMY|MF_BOSS) && g_tm.thing->flags & (MF_ENEMY|MF_BOSS)) { - if ((thing->z + thing->height >= tm.thing->z) - && (tm.thing->z + tm.thing->height >= thing->z)) + if ((thing->z + thing->height >= g_tm.thing->z) + && (g_tm.thing->z + g_tm.thing->height >= thing->z)) return BMIT_ABORT; } if (thing->player) { - if (tm.thing->type == MT_FAN || tm.thing->type == MT_STEAM) - P_DoFanAndGasJet(tm.thing, thing); + if (g_tm.thing->type == MT_FAN || g_tm.thing->type == MT_STEAM) + P_DoFanAndGasJet(g_tm.thing, thing); } - if (tm.thing->player) // Is the moving/interacting object the player? + if (g_tm.thing->player) // Is the moving/interacting object the player? { - if (!tm.thing->health) + if (!g_tm.thing->health) return BMIT_CONTINUE; if (thing->type == MT_FAN || thing->type == MT_STEAM) - P_DoFanAndGasJet(thing, tm.thing); + P_DoFanAndGasJet(thing, g_tm.thing); else if (thing->flags & MF_SPRING) { - if ( thing->z <= tm.thing->z + tm.thing->height - && tm.thing->z <= thing->z + thing->height) - if (P_DoSpring(thing, tm.thing)) + if ( thing->z <= g_tm.thing->z + g_tm.thing->height + && g_tm.thing->z <= thing->z + thing->height) + if (P_DoSpring(thing, g_tm.thing)) return BMIT_ABORT; return BMIT_CONTINUE; } else if (thing->player) // bounce when players collide { // see if it went over / under - if (tm.thing->z > thing->z + thing->height) + if (g_tm.thing->z > thing->z + thing->height) return BMIT_CONTINUE; // overhead - if (tm.thing->z + tm.thing->height < thing->z) + if (g_tm.thing->z + g_tm.thing->height < thing->z) return BMIT_CONTINUE; // underneath - if (thing->player->hyudorotimer || tm.thing->player->hyudorotimer) + if (thing->player->hyudorotimer || g_tm.thing->player->hyudorotimer) { return BMIT_CONTINUE; } if ((gametyperules & GTR_BUMPERS) - && ((thing->player->bumper && !tm.thing->player->bumper) - || (tm.thing->player->bumper && !thing->player->bumper))) + && ((thing->player->bumper && !g_tm.thing->player->bumper) + || (g_tm.thing->player->bumper && !thing->player->bumper))) { return BMIT_CONTINUE; } // The bump has to happen last - if (P_IsObjectOnGround(thing) && tm.thing->momz < 0 && tm.thing->player->pogospring) + if (P_IsObjectOnGround(thing) && g_tm.thing->momz < 0 && g_tm.thing->player->pogospring) { - P_DamageMobj(thing, tm.thing, tm.thing, 1, DMG_WIPEOUT|DMG_STEAL); + P_DamageMobj(thing, g_tm.thing, g_tm.thing, 1, DMG_WIPEOUT|DMG_STEAL); } - else if (P_IsObjectOnGround(tm.thing) && thing->momz < 0 && thing->player->pogospring) + else if (P_IsObjectOnGround(g_tm.thing) && thing->momz < 0 && thing->player->pogospring) { - P_DamageMobj(tm.thing, thing, thing, 1, DMG_WIPEOUT|DMG_STEAL); + P_DamageMobj(g_tm.thing, thing, thing, 1, DMG_WIPEOUT|DMG_STEAL); } - K_PvPTouchDamage(tm.thing, thing); - K_KartBouncing(tm.thing, thing); + K_PvPTouchDamage(g_tm.thing, thing); + K_KartBouncing(g_tm.thing, thing); return BMIT_CONTINUE; } else if (thing->type == MT_BLUEROBRA_HEAD || thing->type == MT_BLUEROBRA_JOINT) { // see if it went over / under - if (tm.thing->z > thing->z + thing->height) + if (g_tm.thing->z > thing->z + thing->height) return BMIT_CONTINUE; // overhead - if (tm.thing->z + tm.thing->height < thing->z) + if (g_tm.thing->z + g_tm.thing->height < thing->z) return BMIT_CONTINUE; // underneath if (!thing->health) return BMIT_CONTINUE; // dead - if (tm.thing->player->invincibilitytimer > 0 - || tm.thing->player->growshrinktimer > 0) + if (g_tm.thing->player->invincibilitytimer > 0 + || g_tm.thing->player->growshrinktimer > 0) { if (thing->type == MT_BLUEROBRA_JOINT) - P_KillMobj(thing->target, tm.thing, tm.thing, DMG_NORMAL); + P_KillMobj(thing->target, g_tm.thing, g_tm.thing, DMG_NORMAL); else - P_KillMobj(thing, tm.thing, tm.thing, DMG_NORMAL); + P_KillMobj(thing, g_tm.thing, g_tm.thing, DMG_NORMAL); return BMIT_CONTINUE; } else { - K_KartSolidBounce(tm.thing, thing); + K_KartSolidBounce(g_tm.thing, thing); return BMIT_CONTINUE; } } else if (thing->type == MT_SMK_PIPE) { // see if it went over / under - if (tm.thing->z > thing->z + thing->height) + if (g_tm.thing->z > thing->z + thing->height) return BMIT_CONTINUE; // overhead - if (tm.thing->z + tm.thing->height < thing->z) + if (g_tm.thing->z + g_tm.thing->height < thing->z) return BMIT_CONTINUE; // underneath if (!thing->health) return BMIT_CONTINUE; // dead - if (tm.thing->player->invincibilitytimer > 0 - || tm.thing->player->growshrinktimer > 0) + if (g_tm.thing->player->invincibilitytimer > 0 + || g_tm.thing->player->growshrinktimer > 0) { - P_KillMobj(thing, tm.thing, tm.thing, DMG_NORMAL); + P_KillMobj(thing, g_tm.thing, g_tm.thing, DMG_NORMAL); return BMIT_CONTINUE; // kill } - K_KartSolidBounce(tm.thing, thing); + K_KartSolidBounce(g_tm.thing, thing); return BMIT_CONTINUE; } else if (thing->type == MT_SMK_THWOMP) @@ -1235,38 +1235,38 @@ static BlockItReturn_t PIT_CheckThing(mobj_t *thing) if (!thwompsactive) return BMIT_CONTINUE; // not active yet - if ((tm.thing->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 (tm.thing->z > thing->z + thing->height) + if (g_tm.thing->z > thing->z + thing->height) return BMIT_CONTINUE; // overhead - if (tm.thing->z + tm.thing->height < thing->z) + if (g_tm.thing->z + g_tm.thing->height < thing->z) return BMIT_CONTINUE; // underneath // kill - if (tm.thing->player->invincibilitytimer > 0 - || tm.thing->player->growshrinktimer > 0) + if (g_tm.thing->player->invincibilitytimer > 0 + || g_tm.thing->player->growshrinktimer > 0) { - P_KillMobj(thing, tm.thing, tm.thing, DMG_NORMAL); + P_KillMobj(thing, g_tm.thing, g_tm.thing, DMG_NORMAL); return BMIT_CONTINUE; } // no interaction - if (tm.thing->player->flashing > 0 || tm.thing->player->hyudorotimer > 0 || tm.thing->player->spinouttimer > 0) + if (g_tm.thing->player->flashing > 0 || g_tm.thing->player->hyudorotimer > 0 || g_tm.thing->player->spinouttimer > 0) return BMIT_CONTINUE; // collide - if (tm.thing->z < thing->z && thing->momz < 0) - P_DamageMobj(tm.thing, thing, thing, 1, DMG_SQUISH); + if (g_tm.thing->z < thing->z && thing->momz < 0) + P_DamageMobj(g_tm.thing, thing, thing, 1, DMG_SQUISH); else { - if ((K_KartSolidBounce(tm.thing, thing) == true) && (thing->flags2 & MF2_AMBUSH)) + if ((K_KartSolidBounce(g_tm.thing, thing) == true) && (thing->flags2 & MF2_AMBUSH)) { - P_DamageMobj(tm.thing, thing, thing, 1, DMG_WIPEOUT); + P_DamageMobj(g_tm.thing, thing, thing, 1, DMG_WIPEOUT); } } @@ -1275,38 +1275,38 @@ static BlockItReturn_t PIT_CheckThing(mobj_t *thing) else if (thing->flags & MF_SOLID) { // see if it went over / under - if (tm.thing->z > thing->z + thing->height) + if (g_tm.thing->z > thing->z + thing->height) return BMIT_CONTINUE; // overhead - if (tm.thing->z + tm.thing->height < thing->z) + if (g_tm.thing->z + g_tm.thing->height < thing->z) return BMIT_CONTINUE; // underneath - K_KartSolidBounce(tm.thing, thing); + K_KartSolidBounce(g_tm.thing, thing); return BMIT_CONTINUE; } } #if 0 - if ((tm.thing->flags & MF_SPRING || tm.thing->type == MT_STEAM || tm.thing->type == MT_SPIKE || tm.thing->type == MT_WALLSPIKE) && (thing->player)) + if ((g_tm.thing->flags & MF_SPRING || g_tm.thing->type == MT_STEAM || g_tm.thing->type == MT_SPIKE || g_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 - && (tm.thing->flags & (MF_SOLID|MF_NOCLIP)) == MF_SOLID) + && (g_tm.thing->flags & (MF_SOLID|MF_NOCLIP)) == MF_SOLID) { fixed_t topz, tmtopz; - if (tm.thing->eflags & MFE_VERTICALFLIP) + if (g_tm.thing->eflags & MFE_VERTICALFLIP) { // pass under - tmtopz = tm.thing->z; + tmtopz = g_tm.thing->z; if (tmtopz > thing->z + thing->height) { - if (thing->z + thing->height > tm.floorz) + if (thing->z + thing->height > g_tm.floorz) { - tm.floorz = thing->z + thing->height; - tm.floorrover = NULL; - tm.floorslope = NULL; - tm.floorpic = -1; + g_tm.floorz = thing->z + thing->height; + g_tm.floorrover = NULL; + g_tm.floorslope = NULL; + g_tm.floorpic = -1; } return BMIT_CONTINUE; } @@ -1317,40 +1317,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 (tm.thing->player && tm.thing->z + tm.thing->height > topz - && tm.thing->z + tm.thing->height < tm.thing->ceilingz) + if (g_tm.thing->player && g_tm.thing->z + g_tm.thing->height > topz + && g_tm.thing->z + g_tm.thing->height < g_tm.thing->ceilingz) { if (thing->flags & MF_GRENADEBOUNCE && (thing->flags & MF_MONITOR || thing->info->flags & MF_MONITOR)) // Gold monitor hack... return BMIT_ABORT; - 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 + g_tm.floorz = g_tm.ceilingz = topz; // block while in air + g_tm.ceilingrover = NULL; + g_tm.ceilingslope = NULL; + g_tm.ceilingpic = -1; + P_SetTarget(&g_tm.floorthing, thing); // needed for side collision } - else if (topz < tm.ceilingz && tm.thing->z <= thing->z+thing->height) + else if (topz < g_tm.ceilingz && g_tm.thing->z <= thing->z+thing->height) { - tm.ceilingz = topz; - tm.ceilingrover = NULL; - tm.ceilingslope = NULL; - tm.ceilingpic = -1; - P_SetTarget(&tm.floorthing, thing); // thing we may stand on + g_tm.ceilingz = topz; + g_tm.ceilingrover = NULL; + g_tm.ceilingslope = NULL; + g_tm.ceilingpic = -1; + P_SetTarget(&g_tm.floorthing, thing); // thing we may stand on } } else { // pass under - tmtopz = tm.thing->z + tm.thing->height; + tmtopz = g_tm.thing->z + g_tm.thing->height; if (tmtopz < thing->z) { - if (thing->z < tm.ceilingz) + if (thing->z < g_tm.ceilingz) { - tm.ceilingz = thing->z; - tm.ceilingrover = NULL; - tm.ceilingslope = NULL; - tm.ceilingpic = -1; + g_tm.ceilingz = thing->z; + g_tm.ceilingrover = NULL; + g_tm.ceilingslope = NULL; + g_tm.ceilingpic = -1; } return BMIT_CONTINUE; } @@ -1361,25 +1361,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 (tm.thing->player && tm.thing->z < topz - && tm.thing->z > tm.thing->floorz) + if (g_tm.thing->player && g_tm.thing->z < topz + && g_tm.thing->z > g_tm.thing->floorz) { if (thing->flags & MF_GRENADEBOUNCE && (thing->flags & MF_MONITOR || thing->info->flags & MF_MONITOR)) // Gold monitor hack... return BMIT_ABORT; - 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 + g_tm.floorz = g_tm.ceilingz = topz; // block while in air + g_tm.floorrover = NULL; + g_tm.floorslope = NULL; + g_tm.floorpic = -1; + P_SetTarget(&g_tm.floorthing, thing); // needed for side collision } - else if (topz > tm.floorz && tm.thing->z+tm.thing->height >= thing->z) + else if (topz > g_tm.floorz && g_tm.thing->z+g_tm.thing->height >= thing->z) { - tm.floorz = topz; - tm.floorrover = NULL; - tm.floorslope = NULL; - tm.floorpic = -1; - P_SetTarget(&tm.floorthing, thing); // thing we may stand on + g_tm.floorz = topz; + g_tm.floorrover = NULL; + g_tm.floorslope = NULL; + g_tm.floorpic = -1; + P_SetTarget(&g_tm.floorthing, thing); // thing we may stand on } } } @@ -1389,7 +1389,7 @@ static BlockItReturn_t PIT_CheckThing(mobj_t *thing) } // PIT_CheckCameraLine -// Adjusts tm.floorz and tm.ceilingz as lines are contacted - FOR CAMERA ONLY +// Adjusts g_tm.floorz and g_tm.ceilingz as lines are contacted - FOR CAMERA ONLY static BlockItReturn_t PIT_CheckCameraLine(line_t *ld) { opening_t open = {0}; @@ -1397,13 +1397,13 @@ static BlockItReturn_t PIT_CheckCameraLine(line_t *ld) if (ld->polyobj && !(ld->polyobj->flags & POF_SOLID)) return BMIT_CONTINUE; - 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]) + if (g_tm.bbox[BOXRIGHT] <= ld->bbox[BOXLEFT] || g_tm.bbox[BOXLEFT] >= ld->bbox[BOXRIGHT] + || g_tm.bbox[BOXTOP] <= ld->bbox[BOXBOTTOM] || g_tm.bbox[BOXBOTTOM] >= ld->bbox[BOXTOP]) { return BMIT_CONTINUE; } - if (P_BoxOnLineSide(tm.bbox, ld) != -1) + if (P_BoxOnLineSide(g_tm.bbox, ld) != -1) return BMIT_CONTINUE; // A line has been hit @@ -1429,22 +1429,22 @@ static BlockItReturn_t PIT_CheckCameraLine(line_t *ld) P_CameraLineOpening(ld, &open); // adjust floor / ceiling heights - if (open.ceiling < tm.ceilingz) + if (open.ceiling < g_tm.ceilingz) { - tm.ceilingz = open.ceiling; - tm.ceilingline = ld; + g_tm.ceilingz = open.ceiling; + g_tm.ceilingline = ld; } - if (open.floor > tm.floorz) + if (open.floor > g_tm.floorz) { - tm.floorz = open.floor; + g_tm.floorz = open.floor; } - if (open.highceiling > tm.drpoffceilz) - tm.drpoffceilz = open.highceiling; + if (open.highceiling > g_tm.drpoffceilz) + g_tm.drpoffceilz = open.highceiling; - if (open.lowfloor < tm.dropoffz) - tm.dropoffz = open.lowfloor; + if (open.lowfloor < g_tm.dropoffz) + g_tm.dropoffz = open.lowfloor; return BMIT_CONTINUE; } @@ -1506,45 +1506,45 @@ static boolean P_UsingStepUp(mobj_t *thing) // // PIT_CheckLine -// Adjusts tm.floorz and tm.ceilingz as lines are contacted +// Adjusts g_tm.floorz and g_tm.ceilingz as lines are contacted // static BlockItReturn_t PIT_CheckLine(line_t *ld) { - const fixed_t thingtop = tm.thing->z + tm.thing->height; + const fixed_t thingtop = g_tm.thing->z + g_tm.thing->height; opening_t open = {0}; if (ld->polyobj && !(ld->polyobj->flags & POF_SOLID)) return BMIT_CONTINUE; - 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]) + if (g_tm.bbox[BOXRIGHT] <= ld->bbox[BOXLEFT] || g_tm.bbox[BOXLEFT] >= ld->bbox[BOXRIGHT] + || g_tm.bbox[BOXTOP] <= ld->bbox[BOXBOTTOM] || g_tm.bbox[BOXBOTTOM] >= ld->bbox[BOXTOP]) return BMIT_CONTINUE; - if (P_BoxOnLineSide(tm.bbox, ld) != -1) + if (P_BoxOnLineSide(g_tm.bbox, ld) != -1) return BMIT_CONTINUE; - 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. + if (g_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(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)) + cosradius = FixedMul(g_tm.thing->radius, FINECOSINE(g_tm.thing->angle>>ANGLETOFINESHIFT)); + sinradius = FixedMul(g_tm.thing->radius, FINESINE(g_tm.thing->angle>>ANGLETOFINESHIFT)); + if (P_PointOnLineSide(g_tm.x - cosradius, g_tm.y - sinradius, ld) + == P_PointOnLineSide(g_tm.x + cosradius, g_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(tm.x, tm.y, ld, &result); + P_ClosestPointOnLine(g_tm.x, g_tm.y, ld, &result); langle = R_PointToAngle2(ld->v1->x, ld->v1->y, ld->v2->x, ld->v2->y); - langle += ANGLE_90*(P_PointOnLineSide(tm.x, tm.y, ld) ? -1 : 1); - dist = abs(FixedMul(tm.thing->radius, FINECOSINE((tm.thing->angle - langle)>>ANGLETOFINESHIFT))); + langle += ANGLE_90*(P_PointOnLineSide(g_tm.x, g_tm.y, ld) ? -1 : 1); + dist = abs(FixedMul(g_tm.thing->radius, FINECOSINE((g_tm.thing->angle - langle)>>ANGLETOFINESHIFT))); cosradius = FixedMul(dist, FINECOSINE(langle>>ANGLETOFINESHIFT)); sinradius = FixedMul(dist, FINESINE(langle>>ANGLETOFINESHIFT)); - 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; + g_tm.thing->flags |= MF_NOCLIP; + P_MoveOrigin(g_tm.thing, result.x + cosradius - g_tm.thing->momx, result.y + sinradius - g_tm.thing->momy, g_tm.thing->z); + g_tm.thing->flags &= ~MF_NOCLIP; } #endif } @@ -1563,16 +1563,16 @@ static BlockItReturn_t PIT_CheckLine(line_t *ld) // this line is out of the if so upper and lower textures can be hit by a splat { - UINT8 shouldCollide = LUA_HookMobjLineCollide(tm.thing, ld); // checks hook for thing's type - if (P_MobjWasRemoved(tm.thing)) + UINT8 shouldCollide = LUA_HookMobjLineCollide(g_tm.thing, ld); // checks hook for thing's type + if (P_MobjWasRemoved(g_tm.thing)) return BMIT_CONTINUE; // one of them was removed??? if (shouldCollide == 1) { - if (tm.sweep) + if (g_tm.sweep) { P_TestLine(ld); } - tm.blocking = true; // force collide + g_tm.blocking = true; // force collide return BMIT_CONTINUE; } else if (shouldCollide == 2) @@ -1581,50 +1581,50 @@ static BlockItReturn_t PIT_CheckLine(line_t *ld) if (!ld->backsector) // one sided line { - if (P_PointOnLineSide(tm.thing->x, tm.thing->y, ld)) + if (P_PointOnLineSide(g_tm.thing->x, g_tm.thing->y, ld)) return BMIT_CONTINUE; // don't hit the back side - if (tm.sweep) + if (g_tm.sweep) { P_TestLine(ld); } - tm.blocking = true; + g_tm.blocking = true; return BMIT_CONTINUE; } - if (P_IsLineBlocking(ld, tm.thing)) + if (P_IsLineBlocking(ld, g_tm.thing)) { - if (tm.sweep) + if (g_tm.sweep) { P_TestLine(ld); } - tm.blocking = true; + g_tm.blocking = true; return BMIT_CONTINUE; } // set openrange, opentop, openbottom - P_LineOpening(ld, tm.thing, &open); + P_LineOpening(ld, g_tm.thing, &open); - if (tm.sweep && P_UsingStepUp(tm.thing)) + if (g_tm.sweep && P_UsingStepUp(g_tm.thing)) { // copied from P_TryMove // TODO: refactor this into one place - if (open.range < tm.thing->height) + if (open.range < g_tm.thing->height) { P_TestLine(ld); } - else if (tm.maxstep > 0) + else if (g_tm.maxstep > 0) { - if (tm.thing->z < open.floor) + if (g_tm.thing->z < open.floor) { - if (open.floorstep > tm.maxstep) + if (open.floorstep > g_tm.maxstep) { P_TestLine(ld); } } - else if (open.ceiling < tm.thing->z + tm.thing->height) + else if (open.ceiling < g_tm.thing->z + g_tm.thing->height) { - if (open.ceilingstep > tm.maxstep) + if (open.ceilingstep > g_tm.maxstep) { P_TestLine(ld); } @@ -1633,38 +1633,38 @@ static BlockItReturn_t PIT_CheckLine(line_t *ld) } // adjust floor / ceiling heights - if (open.ceiling < tm.ceilingz) + if (open.ceiling < g_tm.ceilingz) { - tm.ceilingz = open.ceiling; - tm.ceilingline = ld; - tm.ceilingrover = open.ceilingrover; - tm.ceilingslope = open.ceilingslope; - tm.ceilingpic = open.ceilingpic; - tm.ceilingstep = open.ceilingstep; - if (thingtop == tm.thing->ceilingz) + g_tm.ceilingz = open.ceiling; + g_tm.ceilingline = ld; + g_tm.ceilingrover = open.ceilingrover; + g_tm.ceilingslope = open.ceilingslope; + g_tm.ceilingpic = open.ceilingpic; + g_tm.ceilingstep = open.ceilingstep; + if (thingtop == g_tm.thing->ceilingz) { - tm.thing->ceilingdrop = open.ceilingdrop; + g_tm.thing->ceilingdrop = open.ceilingdrop; } } - if (open.floor > tm.floorz) + if (open.floor > g_tm.floorz) { - tm.floorz = open.floor; - tm.floorrover = open.floorrover; - tm.floorslope = open.floorslope; - tm.floorpic = open.floorpic; - tm.floorstep = open.floorstep; - if (tm.thing->z == tm.thing->floorz) + g_tm.floorz = open.floor; + g_tm.floorrover = open.floorrover; + g_tm.floorslope = open.floorslope; + g_tm.floorpic = open.floorpic; + g_tm.floorstep = open.floorstep; + if (g_tm.thing->z == g_tm.thing->floorz) { - tm.thing->floordrop = open.floordrop; + g_tm.thing->floordrop = open.floordrop; } } - if (open.highceiling > tm.drpoffceilz) - tm.drpoffceilz = open.highceiling; + if (open.highceiling > g_tm.drpoffceilz) + g_tm.drpoffceilz = open.highceiling; - if (open.lowfloor < tm.dropoffz) - tm.dropoffz = open.lowfloor; + if (open.lowfloor < g_tm.dropoffz) + g_tm.dropoffz = open.lowfloor; // we've crossed the line if (P_SpecialIsLinedefCrossType(ld)) @@ -1682,7 +1682,7 @@ static BlockItReturn_t PIT_CheckLine(line_t *ld) know the height values anymore. So don't even add this line to the list unless this thing clips the tripwire's midtexture. */ - if (tm.thing->z <= textop && thingtop >= texbottom) + if (g_tm.thing->z <= textop && thingtop >= texbottom) add_spechit(ld); } @@ -1709,20 +1709,20 @@ static BlockItReturn_t PIT_CheckLine(line_t *ld) // // out: // newsubsec -// tm.floorz -// tm.ceilingz -// tm.dropoffz -// tm.drpoffceilz +// g_tm.floorz +// g_tm.ceilingz +// g_tm.dropoffz +// g_tm.drpoffceilz // the lowest point contacted // (monsters won't move to a dropoff) // speciallines[] // numspeciallines // -// tm.floorz -// the nearest floor or thing's top under tm.thing -// tm.ceilingz -// the nearest ceiling or thing's bottom over tm.thing +// g_tm.floorz +// the nearest floor or thing's top under g_tm.thing +// g_tm.ceilingz +// the nearest ceiling or thing's bottom over g_tm.thing // static const fixed_t hoopblockdist = 16*FRACUNIT + 8*FRACUNIT; @@ -1743,36 +1743,36 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y, TryMoveResult_t *re I_Error("Previously-removed Thing of type %u crashes P_CheckPosition!", thing->type); #endif - P_SetTarget(&tm.thing, thing); - tm.flags = thing->flags; + P_SetTarget(&g_tm.thing, thing); + g_tm.flags = thing->flags; - tm.x = x; - tm.y = y; + g_tm.x = x; + g_tm.y = y; - 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; + g_tm.bbox[BOXTOP] = y + g_tm.thing->radius; + g_tm.bbox[BOXBOTTOM] = y - g_tm.thing->radius; + g_tm.bbox[BOXRIGHT] = x + g_tm.thing->radius; + g_tm.bbox[BOXLEFT] = x - g_tm.thing->radius; newsubsec = R_PointInSubsector(x, y); - tm.ceilingline = NULL; - tm.blocking = false; + g_tm.ceilingline = NULL; + g_tm.blocking = false; // The base floor / ceiling is from the subsector // that contains the point. // Any contacted lines the step closer together // will adjust them. - 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; + g_tm.floorz = g_tm.dropoffz = P_GetFloorZ(thing, newsubsec->sector, x, y, NULL); //newsubsec->sector->floorheight; + g_tm.ceilingz = P_GetCeilingZ(thing, newsubsec->sector, x, y, NULL); //newsubsec->sector->ceilingheight; + g_tm.floorrover = NULL; + g_tm.ceilingrover = NULL; + g_tm.floorslope = newsubsec->sector->f_slope; + g_tm.ceilingslope = newsubsec->sector->c_slope; + g_tm.floorpic = newsubsec->sector->floorpic; + g_tm.ceilingpic = newsubsec->sector->ceilingpic; - tm.floorstep = 0; - tm.ceilingstep = 0; + g_tm.floorstep = 0; + g_tm.ceilingstep = 0; if (thingtop < thing->ceilingz) { @@ -1784,7 +1784,7 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y, TryMoveResult_t *re thing->floordrop = 0; } - // Check list of fake floors and see if tm.floorz/tm.ceilingz need to be altered. + // Check list of fake floors and see if g_tm.floorz/g_tm.ceilingz need to be altered. if (newsubsec->sector->ffloors) { ffloor_t *rover; @@ -1819,22 +1819,22 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y, TryMoveResult_t *re // Land on the top or the bottom, depending on gravity flip. if (!(thing->eflags & MFE_VERTICALFLIP) && thing->z >= topheight - sinklevel && thing->momz <= 0) { - if (tm.floorz < topheight - sinklevel) + if (g_tm.floorz < topheight - sinklevel) { - tm.floorz = topheight - sinklevel; - tm.floorrover = rover; - tm.floorslope = *rover->t_slope; - tm.floorpic = *rover->toppic; + g_tm.floorz = topheight - sinklevel; + g_tm.floorrover = rover; + g_tm.floorslope = *rover->t_slope; + g_tm.floorpic = *rover->toppic; } } else if (thing->eflags & MFE_VERTICALFLIP && thingtop <= bottomheight + sinklevel && thing->momz >= 0) { - if (tm.ceilingz > bottomheight + sinklevel) + if (g_tm.ceilingz > bottomheight + sinklevel) { - tm.ceilingz = bottomheight + sinklevel; - tm.ceilingrover = rover; - tm.ceilingslope = *rover->b_slope; - tm.ceilingpic = *rover->bottompic; + g_tm.ceilingz = bottomheight + sinklevel; + g_tm.ceilingrover = rover; + g_tm.ceilingslope = *rover->b_slope; + g_tm.ceilingpic = *rover->bottompic; } } } @@ -1854,12 +1854,12 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y, TryMoveResult_t *re { if (thing->z < topheight && bottomheight < thingtop) { - if (tm.floorz < thing->z) + if (g_tm.floorz < thing->z) { - tm.floorz = thing->z; - tm.floorrover = rover; - tm.floorslope = NULL; - tm.floorpic = *rover->toppic; + g_tm.floorz = thing->z; + g_tm.floorrover = rover; + g_tm.floorslope = NULL; + g_tm.floorpic = *rover->toppic; } } // Quicksand blocks never change heights otherwise. @@ -1871,23 +1871,23 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y, TryMoveResult_t *re delta2 = thingtop - (bottomheight + ((topheight - bottomheight)/2)); - if (topheight > tm.floorz && abs(delta1) < abs(delta2) + if (topheight > g_tm.floorz && abs(delta1) < abs(delta2) && !(rover->fofflags & FOF_REVERSEPLATFORM)) { - tm.floorz = tm.dropoffz = topheight; - tm.floorrover = rover; - tm.floorslope = *rover->t_slope; - tm.floorpic = *rover->toppic; + g_tm.floorz = g_tm.dropoffz = topheight; + g_tm.floorrover = rover; + g_tm.floorslope = *rover->t_slope; + g_tm.floorpic = *rover->toppic; } - if (bottomheight < tm.ceilingz && abs(delta1) >= abs(delta2) + if (bottomheight < g_tm.ceilingz && abs(delta1) >= abs(delta2) && !(rover->fofflags & FOF_PLATFORM) && !(thing->type == MT_SKIM && (rover->fofflags & FOF_SWIMMABLE))) { - tm.ceilingz = tm.drpoffceilz = bottomheight; - tm.ceilingrover = rover; - tm.ceilingslope = *rover->b_slope; - tm.ceilingpic = *rover->bottompic; + g_tm.ceilingz = g_tm.drpoffceilz = bottomheight; + g_tm.ceilingrover = rover; + g_tm.ceilingslope = *rover->b_slope; + g_tm.ceilingpic = *rover->bottompic; } } } @@ -1899,14 +1899,14 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y, TryMoveResult_t *re // based on their origin point, and can overlap // into adjacent blocks by up to MAXRADIUS units. - 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; + xl = (unsigned)(g_tm.bbox[BOXLEFT] - bmaporgx - MAXRADIUS)>>MAPBLOCKSHIFT; + xh = (unsigned)(g_tm.bbox[BOXRIGHT] - bmaporgx + MAXRADIUS)>>MAPBLOCKSHIFT; + yl = (unsigned)(g_tm.bbox[BOXBOTTOM] - bmaporgy - MAXRADIUS)>>MAPBLOCKSHIFT; + yh = (unsigned)(g_tm.bbox[BOXTOP] - bmaporgy + MAXRADIUS)>>MAPBLOCKSHIFT; BMBOUNDFIX(xl, xh, yl, yh); - // Check polyobjects and see if tm.floorz/tm.ceilingz need to be altered + // Check polyobjects and see if g_tm.floorz/g_tm.ceilingz need to be altered { validcount++; @@ -1937,7 +1937,7 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y, TryMoveResult_t *re po->validcount = validcount; - if (!P_BBoxInsidePolyobj(po, tm.bbox) + if (!P_BBoxInsidePolyobj(po, g_tm.bbox) || !(po->flags & POF_SOLID)) { plink = (polymaplink_t *)(plink->link.next); @@ -1961,20 +1961,20 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y, TryMoveResult_t *re delta1 = thing->z - (polybottom + ((polytop - polybottom)/2)); delta2 = thingtop - (polybottom + ((polytop - polybottom)/2)); - if (polytop > tm.floorz && abs(delta1) < abs(delta2)) + if (polytop > g_tm.floorz && abs(delta1) < abs(delta2)) { - tm.floorz = tm.dropoffz = polytop; - tm.floorslope = NULL; - tm.floorrover = NULL; - tm.floorpic = polysec->ceilingpic; + g_tm.floorz = g_tm.dropoffz = polytop; + g_tm.floorslope = NULL; + g_tm.floorrover = NULL; + g_tm.floorpic = polysec->ceilingpic; } - if (polybottom < tm.ceilingz && abs(delta1) >= abs(delta2)) + if (polybottom < g_tm.ceilingz && abs(delta1) >= abs(delta2)) { - tm.ceilingz = tm.drpoffceilz = polybottom; - tm.ceilingslope = NULL; - tm.ceilingrover = NULL; - tm.ceilingpic = polysec->floorpic; + g_tm.ceilingz = g_tm.drpoffceilz = polybottom; + g_tm.ceilingslope = NULL; + g_tm.ceilingrover = NULL; + g_tm.ceilingpic = polysec->floorpic; } } plink = (polymaplink_t *)(plink->link.next); @@ -1983,9 +1983,9 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y, TryMoveResult_t *re } } - // tm.floorthing is set when tm.floorz comes from a thing's top - P_SetTarget(&tm.floorthing, NULL); - P_SetTarget(&tm.hitthing, NULL); + // g_tm.floorthing is set when g_tm.floorz comes from a thing's top + P_SetTarget(&g_tm.floorthing, NULL); + P_SetTarget(&g_tm.hitthing, NULL); validcount++; @@ -2008,10 +2008,10 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y, TryMoveResult_t *re } else { - P_SetTarget(&tm.hitthing, tm.floorthing); + P_SetTarget(&g_tm.hitthing, g_tm.floorthing); } - if (P_MobjWasRemoved(tm.thing)) + if (P_MobjWasRemoved(g_tm.thing)) { return false; } @@ -2019,7 +2019,7 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y, TryMoveResult_t *re } } - if (tm.flags & MF_NOCLIP) + if (g_tm.flags & MF_NOCLIP) { // Sal 12/19/2022 -- PIT_CheckThing code will still run // with MF_NOCLIP enabled, but they won't be blocked @@ -2040,7 +2040,7 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y, TryMoveResult_t *re } } - if (tm.blocking) + if (g_tm.blocking) { blockval = false; } @@ -2048,14 +2048,14 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y, TryMoveResult_t *re if (result != NULL) { result->line = NULL; - result->mo = tm.hitthing; + result->mo = g_tm.hitthing; } else { P_ClearTestLines(); } - tm.sweep = false; + g_tm.sweep = false; return blockval; } @@ -2092,23 +2092,23 @@ boolean P_CheckCameraPosition(fixed_t x, fixed_t y, camera_t *thiscam) INT32 xl, xh, yl, yh, bx, by; subsector_t *newsubsec; - tm.x = x; - tm.y = y; + g_tm.x = x; + g_tm.y = y; - tm.bbox[BOXTOP] = y + thiscam->radius; - tm.bbox[BOXBOTTOM] = y - thiscam->radius; - tm.bbox[BOXRIGHT] = x + thiscam->radius; - tm.bbox[BOXLEFT] = x - thiscam->radius; + g_tm.bbox[BOXTOP] = y + thiscam->radius; + g_tm.bbox[BOXBOTTOM] = y - thiscam->radius; + g_tm.bbox[BOXRIGHT] = x + thiscam->radius; + g_tm.bbox[BOXLEFT] = x - thiscam->radius; newsubsec = R_PointInSubsector(x, y); - tm.ceilingline = NULL; + g_tm.ceilingline = NULL; mapcampointer = thiscam; if (newsubsec->sector->flags & MSF_NOCLIPCAMERA) { // Camera noclip on entire sector. - tm.floorz = tm.dropoffz = thiscam->z; - tm.ceilingz = tm.drpoffceilz = thiscam->z + thiscam->height; + g_tm.floorz = g_tm.dropoffz = thiscam->z; + g_tm.ceilingz = g_tm.drpoffceilz = thiscam->z + thiscam->height; return true; } @@ -2116,26 +2116,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. - tm.floorz = tm.dropoffz = P_CameraGetFloorZ(thiscam, newsubsec->sector, x, y, NULL); + g_tm.floorz = g_tm.dropoffz = P_CameraGetFloorZ(thiscam, newsubsec->sector, x, y, NULL); - tm.ceilingz = P_CameraGetCeilingZ(thiscam, newsubsec->sector, x, y, NULL); + g_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) { - tm.floorz = tm.dropoffz = sectors[newsubsec->sector->heightsec].floorheight; - tm.ceilingz = tm.drpoffceilz = sectors[newsubsec->sector->heightsec].ceilingheight; + g_tm.floorz = g_tm.dropoffz = sectors[newsubsec->sector->heightsec].floorheight; + g_tm.ceilingz = g_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) { - tm.floorz = tm.dropoffz = sectors[newsubsec->sector->camsec].floorheight; - tm.ceilingz = tm.drpoffceilz = sectors[newsubsec->sector->camsec].ceilingheight; + g_tm.floorz = g_tm.dropoffz = sectors[newsubsec->sector->camsec].floorheight; + g_tm.ceilingz = g_tm.drpoffceilz = sectors[newsubsec->sector->camsec].ceilingheight; } - // Check list of fake floors and see if tm.floorz/tm.ceilingz need to be altered. + // Check list of fake floors and see if g_tm.floorz/g_tm.ceilingz need to be altered. if (newsubsec->sector->ffloors) { ffloor_t *rover; @@ -2155,13 +2155,13 @@ boolean P_CheckCameraPosition(fixed_t x, fixed_t y, camera_t *thiscam) + ((topheight - bottomheight)/2)); delta2 = thingtop - (bottomheight + ((topheight - bottomheight)/2)); - if (topheight > tm.floorz && abs(delta1) < abs(delta2)) + if (topheight > g_tm.floorz && abs(delta1) < abs(delta2)) { - tm.floorz = tm.dropoffz = topheight; + g_tm.floorz = g_tm.dropoffz = topheight; } - if (bottomheight < tm.ceilingz && abs(delta1) >= abs(delta2)) + if (bottomheight < g_tm.ceilingz && abs(delta1) >= abs(delta2)) { - tm.ceilingz = tm.drpoffceilz = bottomheight; + g_tm.ceilingz = g_tm.drpoffceilz = bottomheight; } } } @@ -2171,14 +2171,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)(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; + xl = (unsigned)(g_tm.bbox[BOXLEFT] - bmaporgx)>>MAPBLOCKSHIFT; + xh = (unsigned)(g_tm.bbox[BOXRIGHT] - bmaporgx)>>MAPBLOCKSHIFT; + yl = (unsigned)(g_tm.bbox[BOXBOTTOM] - bmaporgy)>>MAPBLOCKSHIFT; + yh = (unsigned)(g_tm.bbox[BOXTOP] - bmaporgy)>>MAPBLOCKSHIFT; BMBOUNDFIX(xl, xh, yl, yh); - // Check polyobjects and see if tm.floorz/tm.ceilingz need to be altered + // Check polyobjects and see if g_tm.floorz/g_tm.ceilingz need to be altered { validcount++; @@ -2238,11 +2238,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 > tm.floorz && abs(delta1) < abs(delta2)) - tm.floorz = tm.dropoffz = polytop; + if (polytop > g_tm.floorz && abs(delta1) < abs(delta2)) + g_tm.floorz = g_tm.dropoffz = polytop; - if (polybottom < tm.ceilingz && abs(delta1) >= abs(delta2)) - tm.ceilingz = tm.drpoffceilz = polybottom; + if (polybottom < g_tm.ceilingz && abs(delta1) >= abs(delta2)) + g_tm.ceilingz = g_tm.drpoffceilz = polybottom; } plink = (polymaplink_t *)(plink->link.next); } @@ -2275,7 +2275,7 @@ boolean P_TryCameraMove(fixed_t x, fixed_t y, camera_t *thiscam) UINT8 i; - tm.floatok = false; + g_tm.floatok = false; for (i = 0; i <= r_splitscreen; i++) { @@ -2303,7 +2303,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 #endif { - tm.floatok = true; + g_tm.floatok = true; thiscam->floorz = thiscam->z; thiscam->ceilingz = thiscam->z + thiscam->height; thiscam->x = x; @@ -2329,18 +2329,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 (tm.ceilingz - tm.floorz < thiscam->height) + if (g_tm.ceilingz - g_tm.floorz < thiscam->height) return false; // doesn't fit - tm.floatok = true; + g_tm.floatok = true; - if (tm.ceilingz - thiscam->z < thiscam->height) + if (g_tm.ceilingz - thiscam->z < thiscam->height) { - if (s == thiscam->subsector && tm.ceilingz >= thiscam->z) + if (s == thiscam->subsector && g_tm.ceilingz >= thiscam->z) { - tm.floatok = true; - thiscam->floorz = tm.floorz; - thiscam->ceilingz = tm.floorz + thiscam->height; + g_tm.floatok = true; + thiscam->floorz = g_tm.floorz; + thiscam->ceilingz = g_tm.floorz + thiscam->height; thiscam->x = x; thiscam->y = y; thiscam->subsector = s; @@ -2350,21 +2350,21 @@ boolean P_TryCameraMove(fixed_t x, fixed_t y, camera_t *thiscam) return false; // mobj must lower itself to fit } - if ((tm.floorz - thiscam->z > MAXCAMERASTEPMOVE)) + if ((g_tm.floorz - thiscam->z > MAXCAMERASTEPMOVE)) return false; // too big a step up } while(tryx != x || tryy != y); } else { - tm.floorz = P_CameraGetFloorZ(thiscam, thiscam->subsector->sector, x, y, NULL); - tm.ceilingz = P_CameraGetCeilingZ(thiscam, thiscam->subsector->sector, x, y, NULL); + g_tm.floorz = P_CameraGetFloorZ(thiscam, thiscam->subsector->sector, x, y, NULL); + g_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 = tm.floorz; - thiscam->ceilingz = tm.ceilingz; + thiscam->floorz = g_tm.floorz; + thiscam->ceilingz = g_tm.ceilingz; thiscam->x = x; thiscam->y = y; thiscam->subsector = s; @@ -2416,7 +2416,7 @@ 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! - tm_t oldtm = tm; + tm_t oldtm = g_tm; // Move the player P_TryMove(thing, thing->x + stand->momx, thing->y + stand->momy, true, NULL); @@ -2493,7 +2493,7 @@ increment_move fixed_t tryy = thing->y; fixed_t radius = thing->radius; fixed_t thingtop; - tm.floatok = false; + g_tm.floatok = false; // reset this to 0 at the start of each trymove call as it's only used here numspechitint = 0U; @@ -2535,12 +2535,12 @@ increment_move if (P_UsingStepUp(thing)) { - tm.maxstep = P_GetThingStepUp(thing, tryx, tryy); + g_tm.maxstep = P_GetThingStepUp(thing, tryx, tryy); } if (result) { - tm.sweep = true; + g_tm.sweep = true; } boolean move_ok = P_CheckPosition(thing, tryx, tryy, result); @@ -2571,26 +2571,26 @@ increment_move if (thing->type == MT_SKIM) maxstep = 0; - if (tm.ceilingz - tm.floorz < thing->height) + if (g_tm.ceilingz - g_tm.floorz < thing->height) { - if (tm.floorthing != NULL) + if (g_tm.floorthing != NULL) { - P_SetTarget(&tm.hitthing, tm.floorthing); + P_SetTarget(&g_tm.hitthing, g_tm.floorthing); } return false; // doesn't fit } - tm.floatok = true; + g_tm.floatok = true; thingtop = thing->z + thing->height; // Step up - if (thing->z < tm.floorz) + if (thing->z < g_tm.floorz) { - if (tm.floorz - thing->z <= maxstep) + if (g_tm.floorz - thing->z <= maxstep) { - thing->z = thing->floorz = tm.floorz; + thing->z = thing->floorz = g_tm.floorz; thing->eflags |= MFE_JUSTSTEPPEDDOWN; } else @@ -2598,11 +2598,11 @@ increment_move return false; // mobj must raise itself to fit } } - else if (tm.ceilingz < thingtop) + else if (g_tm.ceilingz < thingtop) { - if (thingtop - tm.ceilingz <= maxstep) + if (thingtop - g_tm.ceilingz <= maxstep) { - thing->z = ( thing->ceilingz = tm.ceilingz ) - thing->height; + thing->z = ( thing->ceilingz = g_tm.ceilingz ) - thing->height; thing->eflags |= MFE_JUSTSTEPPEDDOWN; } else @@ -2619,28 +2619,28 @@ 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 && tm.ceilingz > thingtop && tm.ceilingz - thingtop <= maxstep) + if (thingtop == thing->ceilingz && g_tm.ceilingz > thingtop && g_tm.ceilingz - thingtop <= maxstep) { - thing->z = (thing->ceilingz = tm.ceilingz) - thing->height; + thing->z = (thing->ceilingz = g_tm.ceilingz) - thing->height; thing->eflags |= MFE_JUSTSTEPPEDDOWN; thing->ceilingdrop = 0; } - else if (thing->z == thing->floorz && tm.floorz < thing->z && thing->z - tm.floorz <= maxstep) + else if (thing->z == thing->floorz && g_tm.floorz < thing->z && thing->z - g_tm.floorz <= maxstep) { - thing->z = thing->floorz = tm.floorz; + thing->z = thing->floorz = g_tm.floorz; thing->eflags |= MFE_JUSTSTEPPEDDOWN; thing->floordrop = 0; } } - if (!allowdropoff && !(thing->flags & MF_FLOAT) && thing->type != MT_SKIM && !tm.floorthing) + if (!allowdropoff && !(thing->flags & MF_FLOAT) && thing->type != MT_SKIM && !g_tm.floorthing) { if (thing->eflags & MFE_VERTICALFLIP) { - if (tm.drpoffceilz - tm.ceilingz > maxstep) + if (g_tm.drpoffceilz - g_tm.ceilingz > maxstep) return false; } - else if (tm.floorz - tm.dropoffz > maxstep) + else if (g_tm.floorz - g_tm.dropoffz > maxstep) return false; // don't stand over a dropoff } } @@ -2712,26 +2712,26 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff, Try // Link the thing into its new position P_UnsetThingPosition(thing); - thing->floorz = tm.floorz; - thing->ceilingz = tm.ceilingz; - thing->floorrover = tm.floorrover; - thing->ceilingrover = tm.ceilingrover; + thing->floorz = g_tm.floorz; + thing->ceilingz = g_tm.ceilingz; + thing->floorrover = g_tm.floorrover; + thing->ceilingrover = g_tm.ceilingrover; if (!(thing->flags & MF_NOCLIPHEIGHT)) { // Assign thing's standingslope if needed - if (thing->z <= tm.floorz && !(thing->eflags & MFE_VERTICALFLIP)) + if (thing->z <= g_tm.floorz && !(thing->eflags & MFE_VERTICALFLIP)) { - K_UpdateMobjTerrain(thing, tm.floorpic); + K_UpdateMobjTerrain(thing, g_tm.floorpic); - if (!startingonground && tm.floorslope) + if (!startingonground && g_tm.floorslope) { - P_HandleSlopeLanding(thing, tm.floorslope); + P_HandleSlopeLanding(thing, g_tm.floorslope); } if (thing->momz <= 0) { - thing->standingslope = tm.floorslope; + thing->standingslope = g_tm.floorslope; P_SetPitchRollFromSlope(thing, thing->standingslope); if (thing->momz == 0 && thing->player && !startingonground) @@ -2740,18 +2740,18 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff, Try } } } - else if (thing->z+thing->height >= tm.ceilingz && (thing->eflags & MFE_VERTICALFLIP)) + else if (thing->z+thing->height >= g_tm.ceilingz && (thing->eflags & MFE_VERTICALFLIP)) { - K_UpdateMobjTerrain(thing, tm.ceilingpic); + K_UpdateMobjTerrain(thing, g_tm.ceilingpic); - if (!startingonground && tm.ceilingslope) + if (!startingonground && g_tm.ceilingslope) { - P_HandleSlopeLanding(thing, tm.ceilingslope); + P_HandleSlopeLanding(thing, g_tm.ceilingslope); } if (thing->momz >= 0) { - thing->standingslope = tm.ceilingslope; + thing->standingslope = g_tm.ceilingslope; P_SetPitchRollFromSlope(thing, thing->standingslope); if (thing->momz == 0 && thing->player && !startingonground) @@ -2771,7 +2771,7 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff, Try thing->x = x; thing->y = y; - if (tm.floorthing) + if (g_tm.floorthing) thing->eflags &= ~MFE_ONGROUND; // not on real floor else thing->eflags |= MFE_ONGROUND; @@ -2833,13 +2833,13 @@ boolean P_SceneryTryMove(mobj_t *thing, fixed_t x, fixed_t y, TryMoveResult_t *r { const fixed_t maxstep = P_BaseStepUp(); - if (tm.ceilingz - tm.floorz < thing->height) + if (g_tm.ceilingz - g_tm.floorz < thing->height) return false; // doesn't fit - if (tm.ceilingz - thing->z < thing->height) + if (g_tm.ceilingz - thing->z < thing->height) return false; // mobj must lower itself to fit - if (tm.floorz - thing->z > maxstep) + if (g_tm.floorz - thing->z > maxstep) return false; // too big a step up } } while(tryx != x || tryy != y); @@ -2848,14 +2848,14 @@ boolean P_SceneryTryMove(mobj_t *thing, fixed_t x, fixed_t y, TryMoveResult_t *r // so link the thing into its new position P_UnsetThingPosition(thing); - thing->floorz = tm.floorz; - thing->ceilingz = tm.ceilingz; - thing->floorrover = tm.floorrover; - thing->ceilingrover = tm.ceilingrover; + thing->floorz = g_tm.floorz; + thing->ceilingz = g_tm.ceilingz; + thing->floorrover = g_tm.floorrover; + thing->ceilingrover = g_tm.ceilingrover; thing->x = x; thing->y = y; - if (tm.floorthing) + if (g_tm.floorthing) thing->eflags &= ~MFE_ONGROUND; // not on real floor else thing->eflags |= MFE_ONGROUND; @@ -2983,17 +2983,17 @@ static boolean P_ThingHeightClip(mobj_t *thing) if (P_MobjWasRemoved(thing)) return true; - floormoved = (thing->eflags & MFE_VERTICALFLIP && tm.ceilingz != thing->ceilingz) - || (!(thing->eflags & MFE_VERTICALFLIP) && tm.floorz != thing->floorz); + floormoved = (thing->eflags & MFE_VERTICALFLIP && g_tm.ceilingz != thing->ceilingz) + || (!(thing->eflags & MFE_VERTICALFLIP) && g_tm.floorz != thing->floorz); - thing->floorz = tm.floorz; - thing->ceilingz = tm.ceilingz; - thing->floorrover = tm.floorrover; - thing->ceilingrover = tm.ceilingrover; + thing->floorz = g_tm.floorz; + thing->ceilingz = g_tm.ceilingz; + thing->floorrover = g_tm.floorrover; + thing->ceilingrover = g_tm.ceilingrover; // Ugly hack?!?! As long as just ceilingz is the lowest, // you'll still get crushed, right? - if (tm.floorz > oldfloorz+thing->height) + if (g_tm.floorz > oldfloorz+thing->height) return true; if (onfloor && !(thing->flags & MF_NOGRAVITY) && floormoved) @@ -3017,15 +3017,15 @@ static boolean P_ThingHeightClip(mobj_t *thing) thing->z = thing->floorz; } } - else if (!tm.floorthing) + else if (!g_tm.floorthing) { // don't adjust a floating monster unless forced to if (thing->eflags & MFE_VERTICALFLIP) { - if (!onfloor && thing->z < tm.floorz) + if (!onfloor && thing->z < g_tm.floorz) thing->z = thing->floorz; } - else if (!onfloor && thing->z + thing->height > tm.ceilingz) + else if (!onfloor && thing->z + thing->height > g_tm.ceilingz) thing->z = thing->ceilingz - thing->height; } @@ -4475,13 +4475,13 @@ void P_DelPrecipSeclist(mprecipsecnode_t *node) static inline BlockItReturn_t PIT_GetSectors(line_t *ld) { - 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]) + if (g_tm.bbox[BOXRIGHT] <= ld->bbox[BOXLEFT] || + g_tm.bbox[BOXLEFT] >= ld->bbox[BOXRIGHT] || + g_tm.bbox[BOXTOP] <= ld->bbox[BOXBOTTOM] || + g_tm.bbox[BOXBOTTOM] >= ld->bbox[BOXTOP]) return BMIT_CONTINUE; - if (P_BoxOnLineSide(tm.bbox, ld) != -1) + if (P_BoxOnLineSide(g_tm.bbox, ld) != -1) return BMIT_CONTINUE; if (ld->polyobj) // line belongs to a polyobject, don't add it @@ -4494,7 +4494,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,tm.thing,sector_list); + sector_list = P_AddSecnode(ld->frontsector,g_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 @@ -4502,7 +4502,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, tm.thing, sector_list); + sector_list = P_AddSecnode(ld->backsector, g_tm.thing, sector_list); return BMIT_CONTINUE; } @@ -4510,13 +4510,13 @@ static inline BlockItReturn_t PIT_GetSectors(line_t *ld) // Tails 08-25-2002 static inline BlockItReturn_t PIT_GetPrecipSectors(line_t *ld) { - 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]) + if (g_tm.precipbbox[BOXRIGHT] <= ld->bbox[BOXLEFT] || + g_tm.precipbbox[BOXLEFT] >= ld->bbox[BOXRIGHT] || + g_tm.precipbbox[BOXTOP] <= ld->bbox[BOXBOTTOM] || + g_tm.precipbbox[BOXBOTTOM] >= ld->bbox[BOXTOP]) return BMIT_CONTINUE; - if (P_BoxOnLineSide(tm.precipbbox, ld) != -1) + if (P_BoxOnLineSide(g_tm.precipbbox, ld) != -1) return BMIT_CONTINUE; if (ld->polyobj) // line belongs to a polyobject, don't add it @@ -4529,7 +4529,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, tm.precipthing, precipsector_list); + precipsector_list = P_AddPrecipSecnode(ld->frontsector, g_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 @@ -4537,7 +4537,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, tm.precipthing, precipsector_list); + precipsector_list = P_AddPrecipSecnode(ld->backsector, g_tm.precipthing, precipsector_list); return BMIT_CONTINUE; } @@ -4549,7 +4549,8 @@ void P_CreateSecNodeList(mobj_t *thing, fixed_t x, fixed_t y) { INT32 xl, xh, yl, yh, bx, by; msecnode_t *node = sector_list; - tm_t ptm = tm; /* cph - see comment at func end */ + tm_t ptm = g_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 @@ -4562,23 +4563,23 @@ void P_CreateSecNodeList(mobj_t *thing, fixed_t x, fixed_t y) node = node->m_sectorlist_next; } - P_SetTarget(&tm.thing, thing); - tm.flags = thing->flags; + P_SetTarget(&g_tm.thing, thing); + g_tm.flags = thing->flags; - tm.x = x; - tm.y = y; + g_tm.x = x; + g_tm.y = y; - 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; + g_tm.bbox[BOXTOP] = y + g_tm.thing->radius; + g_tm.bbox[BOXBOTTOM] = y - g_tm.thing->radius; + g_tm.bbox[BOXRIGHT] = x + g_tm.thing->radius; + g_tm.bbox[BOXLEFT] = x - g_tm.thing->radius; validcount++; // used to make sure we only process a line once - 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; + xl = (unsigned)(g_tm.bbox[BOXLEFT] - bmaporgx)>>MAPBLOCKSHIFT; + xh = (unsigned)(g_tm.bbox[BOXRIGHT] - bmaporgx)>>MAPBLOCKSHIFT; + yl = (unsigned)(g_tm.bbox[BOXBOTTOM] - bmaporgy)>>MAPBLOCKSHIFT; + yh = (unsigned)(g_tm.bbox[BOXTOP] - bmaporgy)>>MAPBLOCKSHIFT; BMBOUNDFIX(xl, xh, yl, yh); @@ -4605,10 +4606,10 @@ void P_CreateSecNodeList(mobj_t *thing, fixed_t x, fixed_t y) } /* cph - - * This is the strife we get into for using global variables. tm.thing + * This is the strife we get into for using global variables. g_tm.thing * is being used by several different functions calling * P_BlockThingIterator, including functions that can be called *from* - * P_BlockThingIterator. Using a global tm.thing is not reentrant. + * P_BlockThingIterator. Using a global g_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. */ @@ -4620,7 +4621,8 @@ void P_CreatePrecipSecNodeList(precipmobj_t *thing,fixed_t x,fixed_t y) { INT32 xl, xh, yl, yh, bx, by; mprecipsecnode_t *node = precipsector_list; - tm_t ptm = tm; /* cph - see comment at func end */ + tm_t ptm = g_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 @@ -4633,19 +4635,19 @@ void P_CreatePrecipSecNodeList(precipmobj_t *thing,fixed_t x,fixed_t y) node = node->m_sectorlist_next; } - tm.precipthing = thing; + g_tm.precipthing = thing; - tm.precipbbox[BOXTOP] = y + 2*FRACUNIT; - tm.precipbbox[BOXBOTTOM] = y - 2*FRACUNIT; - tm.precipbbox[BOXRIGHT] = x + 2*FRACUNIT; - tm.precipbbox[BOXLEFT] = x - 2*FRACUNIT; + g_tm.precipbbox[BOXTOP] = y + 2*FRACUNIT; + g_tm.precipbbox[BOXBOTTOM] = y - 2*FRACUNIT; + g_tm.precipbbox[BOXRIGHT] = x + 2*FRACUNIT; + g_tm.precipbbox[BOXLEFT] = x - 2*FRACUNIT; validcount++; // used to make sure we only process a line once - 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; + xl = (unsigned)(g_tm.precipbbox[BOXLEFT] - bmaporgx)>>MAPBLOCKSHIFT; + xh = (unsigned)(g_tm.precipbbox[BOXRIGHT] - bmaporgx)>>MAPBLOCKSHIFT; + yl = (unsigned)(g_tm.precipbbox[BOXBOTTOM] - bmaporgy)>>MAPBLOCKSHIFT; + yh = (unsigned)(g_tm.precipbbox[BOXTOP] - bmaporgy)>>MAPBLOCKSHIFT; BMBOUNDFIX(xl, xh, yl, yh); @@ -4672,10 +4674,10 @@ void P_CreatePrecipSecNodeList(precipmobj_t *thing,fixed_t x,fixed_t y) } /* cph - - * This is the strife we get into for using global variables. tm.thing + * This is the strife we get into for using global variables. g_tm.thing * is being used by several different functions calling * P_BlockThingIterator, including functions that can be called *from* - * P_BlockThingIterator. Using a global tm.thing is not reentrant. + * P_BlockThingIterator. Using a global g_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. */ @@ -4683,16 +4685,16 @@ void P_CreatePrecipSecNodeList(precipmobj_t *thing,fixed_t x,fixed_t y) } /* cphipps 2004/08/30 - - * 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. */ + * Must clear g_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 (tm.thing) - I_Error("P_MapStart: tm.thing set!"); + if (g_tm.thing) + I_Error("P_MapStart: g_tm.thing set!"); } void P_MapEnd(void) { - P_SetTarget(&tm.thing, NULL); + P_SetTarget(&g_tm.thing, NULL); } // P_FloorzAtPos diff --git a/src/p_maputl.c b/src/p_maputl.c index f67ed5994..867e2b1a4 100644 --- a/src/p_maputl.c +++ b/src/p_maputl.c @@ -315,8 +315,8 @@ void P_CameraLineOpening(line_t *linedef, opening_t *open) } else { - frontfloor = P_CameraGetFloorZ (mapcampointer, front, tm.x, tm.y, linedef); - frontceiling = P_CameraGetCeilingZ(mapcampointer, front, tm.x, tm.y, linedef); + frontfloor = P_CameraGetFloorZ (mapcampointer, front, g_tm.x, g_tm.y, linedef); + frontceiling = P_CameraGetCeilingZ(mapcampointer, front, g_tm.x, g_tm.y, linedef); } if (back->camsec >= 0) @@ -333,8 +333,8 @@ void P_CameraLineOpening(line_t *linedef, opening_t *open) } else { - backfloor = P_CameraGetFloorZ(mapcampointer, back, tm.x, tm.y, linedef); - backceiling = P_CameraGetCeilingZ(mapcampointer, back, tm.x, tm.y, linedef); + backfloor = P_CameraGetFloorZ(mapcampointer, back, g_tm.x, g_tm.y, linedef); + backceiling = P_CameraGetCeilingZ(mapcampointer, back, g_tm.x, g_tm.y, linedef); } thingtop = mapcampointer->z + mapcampointer->height; @@ -375,8 +375,8 @@ void P_CameraLineOpening(line_t *linedef, opening_t *open) if (!(rover->fofflags & FOF_BLOCKOTHERS) || !(rover->fofflags & FOF_RENDERALL) || !(rover->fofflags & FOF_EXISTS) ) continue; - topheight = P_CameraGetFOFTopZ(mapcampointer, front, rover, tm.x, tm.y, linedef); - bottomheight = P_CameraGetFOFBottomZ(mapcampointer, front, rover, tm.x, tm.y, linedef); + topheight = P_CameraGetFOFTopZ(mapcampointer, front, rover, g_tm.x, g_tm.y, linedef); + bottomheight = P_CameraGetFOFBottomZ(mapcampointer, front, rover, g_tm.x, g_tm.y, linedef); delta1 = abs(mapcampointer->z - (bottomheight + ((topheight - bottomheight)/2))); delta2 = abs(thingtop - (bottomheight + ((topheight - bottomheight)/2))); @@ -399,8 +399,8 @@ void P_CameraLineOpening(line_t *linedef, opening_t *open) if (!(rover->fofflags & FOF_BLOCKOTHERS) || !(rover->fofflags & FOF_RENDERALL) || !(rover->fofflags & FOF_EXISTS) ) continue; - topheight = P_CameraGetFOFTopZ(mapcampointer, back, rover, tm.x, tm.y, linedef); - bottomheight = P_CameraGetFOFBottomZ(mapcampointer, back, rover, tm.x, tm.y, linedef); + topheight = P_CameraGetFOFTopZ(mapcampointer, back, rover, g_tm.x, g_tm.y, linedef); + bottomheight = P_CameraGetFOFBottomZ(mapcampointer, back, rover, g_tm.x, g_tm.y, linedef); delta1 = abs(mapcampointer->z - (bottomheight + ((topheight - bottomheight)/2))); delta2 = abs(thingtop - (bottomheight + ((topheight - bottomheight)/2))); @@ -539,7 +539,7 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj, opening_t *open) return; } - P_ClosestPointOnLine(tm.x, tm.y, linedef, &cross); + P_ClosestPointOnLine(g_tm.x, g_tm.y, linedef, &cross); // Treat polyobjects kind of like 3D Floors if (linedef->polyobj && (linedef->polyobj->flags & POF_TESTHEIGHT)) @@ -567,8 +567,8 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj, opening_t *open) fixed_t height[2]; const sector_t * sector[2] = { front, back }; - height[FRONT] = P_GetCeilingZ(mobj, front, tm.x, tm.y, linedef); - height[BACK] = P_GetCeilingZ(mobj, back, tm.x, tm.y, linedef); + height[FRONT] = P_GetCeilingZ(mobj, front, g_tm.x, g_tm.y, linedef); + height[BACK] = P_GetCeilingZ(mobj, back, g_tm.x, g_tm.y, linedef); hi = ( height[0] < height[1] ); lo = ! hi; @@ -587,8 +587,8 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj, opening_t *open) open->ceilingdrop = ( topedge[hi] - topedge[lo] ); } - height[FRONT] = P_GetFloorZ(mobj, front, tm.x, tm.y, linedef); - height[BACK] = P_GetFloorZ(mobj, back, tm.x, tm.y, linedef); + height[FRONT] = P_GetFloorZ(mobj, front, g_tm.x, g_tm.y, linedef); + height[BACK] = P_GetFloorZ(mobj, back, g_tm.x, g_tm.y, linedef); hi = ( height[0] < height[1] ); lo = ! hi; @@ -777,8 +777,8 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj, opening_t *open) } else { - topheight = P_GetFOFTopZ(mobj, front, rover, tm.x, tm.y, linedef); - bottomheight = P_GetFOFBottomZ(mobj, front, rover, tm.x, tm.y, linedef); + topheight = P_GetFOFTopZ(mobj, front, rover, g_tm.x, g_tm.y, linedef); + bottomheight = P_GetFOFBottomZ(mobj, front, rover, g_tm.x, g_tm.y, linedef); } switch (open->fofType) @@ -869,8 +869,8 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj, opening_t *open) } else { - topheight = P_GetFOFTopZ(mobj, back, rover, tm.x, tm.y, linedef); - bottomheight = P_GetFOFBottomZ(mobj, back, rover, tm.x, tm.y, linedef); + topheight = P_GetFOFTopZ(mobj, back, rover, g_tm.x, g_tm.y, linedef); + bottomheight = P_GetFOFBottomZ(mobj, back, rover, g_tm.x, g_tm.y, linedef); } switch (open->fofType) @@ -1834,16 +1834,16 @@ boolean P_RadiusLinesCheck(fixed_t radius, fixed_t x, fixed_t y, INT32 xl, xh, yl, yh; INT32 bx, by; - tm.bbox[BOXTOP] = y + radius; - tm.bbox[BOXBOTTOM] = y - radius; - tm.bbox[BOXRIGHT] = x + radius; - tm.bbox[BOXLEFT] = x - radius; + g_tm.bbox[BOXTOP] = y + radius; + g_tm.bbox[BOXBOTTOM] = y - radius; + g_tm.bbox[BOXRIGHT] = x + radius; + g_tm.bbox[BOXLEFT] = x - radius; // check lines - 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; + xl = (unsigned)(g_tm.bbox[BOXLEFT] - bmaporgx)>>MAPBLOCKSHIFT; + xh = (unsigned)(g_tm.bbox[BOXRIGHT] - bmaporgx)>>MAPBLOCKSHIFT; + yl = (unsigned)(g_tm.bbox[BOXBOTTOM] - bmaporgy)>>MAPBLOCKSHIFT; + yh = (unsigned)(g_tm.bbox[BOXTOP] - bmaporgy)>>MAPBLOCKSHIFT; for (bx = xl; bx <= xh; bx++) for (by = yl; by <= yh; by++) diff --git a/src/p_mobj.c b/src/p_mobj.c index f8a564c23..da50672d0 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -1508,12 +1508,12 @@ bustupdone: // static boolean P_CheckSkyHit(mobj_t *mo) { - 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)) + if (g_tm.ceilingline && g_tm.ceilingline->backsector + && g_tm.ceilingline->backsector->ceilingpic == skyflatnum + && g_tm.ceilingline->frontsector + && g_tm.ceilingline->frontsector->ceilingpic == skyflatnum + && (mo->z >= g_tm.ceilingline->frontsector->ceilingheight + || mo->z >= g_tm.ceilingline->backsector->ceilingheight)) return true; return false; } @@ -1610,7 +1610,7 @@ void P_XYMovement(mobj_t *mo) // blocked move moved = false; - if (LUA_HookMobjMoveBlocked(mo, tm.hitthing, result.line)) + if (LUA_HookMobjMoveBlocked(mo, g_tm.hitthing, result.line)) { if (P_MobjWasRemoved(mo)) return; @@ -1651,7 +1651,7 @@ void P_XYMovement(mobj_t *mo) // draw damage on wall //SPLAT TEST ---------------------------------------------------------- #ifdef WALLSPLATS - if (tm.blockingline && mo->type != MT_REDRING && mo->type != MT_FIREBALL + if (g_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 { @@ -1659,13 +1659,13 @@ void P_XYMovement(mobj_t *mo) divline_t misl; fixed_t frac; - P_MakeDivline(tm.blockingline, &divl); + P_MakeDivline(g_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(tm.blockingline, P_PointOnLineSide(mo->x,mo->y,tm.blockingline), + R_AddWallSplat(g_tm.blockingline, P_PointOnLineSide(mo->x,mo->y,g_tm.blockingline), "A_DMG3", mo->z, frac, SPLATDRAWMODE_SHADE); } #endif @@ -2388,11 +2388,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) ? tm.ceilingpic : tm.floorpic)); + K_UpdateMobjTerrain(mo, ((mo->eflags & MFE_VERTICALFLIP) ? g_tm.ceilingpic : g_tm.floorpic)); - if (((mo->eflags & MFE_VERTICALFLIP) ? tm.ceilingslope : tm.floorslope) && (mo->type != MT_STEAM)) + if (((mo->eflags & MFE_VERTICALFLIP) ? g_tm.ceilingslope : g_tm.floorslope) && (mo->type != MT_STEAM)) { - mo->standingslope = (mo->eflags & MFE_VERTICALFLIP) ? tm.ceilingslope : tm.floorslope; + mo->standingslope = (mo->eflags & MFE_VERTICALFLIP) ? g_tm.ceilingslope : g_tm.floorslope; P_SetPitchRollFromSlope(mo, mo->standingslope); P_ReverseQuantizeMomentumToSlope(&mom, mo->standingslope); } @@ -2525,11 +2525,11 @@ boolean P_ZMovement(mobj_t *mo) } } else - mom.z = (tm.floorthing ? tm.floorthing->momz : 0); + mom.z = (g_tm.floorthing ? g_tm.floorthing->momz : 0); } - else if (tm.floorthing) - mom.z = tm.floorthing->momz; + else if (g_tm.floorthing) + mom.z = g_tm.floorthing->momz; if (mo->standingslope) { // MT_STEAM will never have a standingslope, see above. P_QuantizeMomentumToSlope(&mom, mo->standingslope); @@ -2763,7 +2763,7 @@ void P_PlayerZMovement(mobj_t *mo) mo->z = mo->floorz; } - K_UpdateMobjTerrain(mo, (mo->eflags & MFE_VERTICALFLIP ? tm.ceilingpic : tm.floorpic)); + K_UpdateMobjTerrain(mo, (mo->eflags & MFE_VERTICALFLIP ? g_tm.ceilingpic : g_tm.floorpic)); // Get up if you fell. if (mo->player->panim == PA_HURT && mo->player->spinouttimer == 0 && mo->player->squishedtimer == 0) @@ -2771,10 +2771,10 @@ void P_PlayerZMovement(mobj_t *mo) P_SetPlayerMobjState(mo, S_KART_STILL); } - if (!mo->standingslope && (mo->eflags & MFE_VERTICALFLIP ? tm.ceilingslope : tm.floorslope)) + if (!mo->standingslope && (mo->eflags & MFE_VERTICALFLIP ? g_tm.ceilingslope : g_tm.floorslope)) { // Handle landing on slope during Z movement - P_HandleSlopeLanding(mo, (mo->eflags & MFE_VERTICALFLIP ? tm.ceilingslope : tm.floorslope)); + P_HandleSlopeLanding(mo, (mo->eflags & MFE_VERTICALFLIP ? g_tm.ceilingslope : g_tm.floorslope)); } if (P_MobjFlip(mo) * mo->momz < 0) // falling @@ -2789,12 +2789,12 @@ void P_PlayerZMovement(mobj_t *mo) if (clipmomz) { - mo->momz = (tm.floorthing ? tm.floorthing->momz : 0); + mo->momz = (g_tm.floorthing ? g_tm.floorthing->momz : 0); } } - else if (tm.floorthing) + else if (g_tm.floorthing) { - mo->momz = tm.floorthing->momz; + mo->momz = g_tm.floorthing->momz; } } else @@ -2963,9 +2963,9 @@ boolean P_SceneryZMovement(mobj_t *mo) { mo->eflags |= MFE_JUSTHITFLOOR; // Spin Attack - if (tm.floorthing) - mo->momz = tm.floorthing->momz; - else if (!tm.floorthing) + if (g_tm.floorthing) + mo->momz = g_tm.floorthing->momz; + else if (!g_tm.floorthing) mo->momz = 0; } } @@ -3633,8 +3633,8 @@ boolean P_CameraThinker(player_t *player, camera_t *thiscam, boolean resetcalled } thiscam->subsector = R_PointInSubsectorFast(thiscam->x, thiscam->y); - thiscam->floorz = tm.floorz; - thiscam->ceilingz = tm.ceilingz; + thiscam->floorz = g_tm.floorz; + thiscam->ceilingz = g_tm.ceilingz; if (thiscam->momz || player->mo->pmomz) { @@ -3781,8 +3781,8 @@ static void P_PlayerMobjThinker(mobj_t *mobj) mobj->z += mobj->momz; P_SetThingPosition(mobj); P_CheckPosition(mobj, mobj->x, mobj->y, NULL); - mobj->floorz = tm.floorz; - mobj->ceilingz = tm.ceilingz; + mobj->floorz = g_tm.floorz; + mobj->ceilingz = g_tm.ceilingz; mobj->terrain = NULL; goto animonly; } @@ -8662,8 +8662,8 @@ void P_MobjThinker(mobj_t *mobj) mobj->eflags &= ~(MFE_PUSHED|MFE_SPRUNG|MFE_JUSTBOUNCEDWALL|MFE_SLOPELAUNCHED); // 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); + P_SetTarget(&g_tm.floorthing, NULL); + P_SetTarget(&g_tm.hitthing, NULL); if (udmf) { @@ -9047,10 +9047,10 @@ void P_SceneryThinker(mobj_t *mobj) P_CheckPosition(mobj, mobj->x, mobj->y, NULL); // Need this to pick up objects! if (P_MobjWasRemoved(mobj)) return; - mobj->floorz = tm.floorz; - mobj->ceilingz = tm.ceilingz; - mobj->floorrover = tm.floorrover; - mobj->ceilingrover = tm.ceilingrover; + mobj->floorz = g_tm.floorz; + mobj->ceilingz = g_tm.ceilingz; + mobj->floorrover = g_tm.floorrover; + mobj->ceilingrover = g_tm.ceilingrover; } else { diff --git a/src/p_polyobj.c b/src/p_polyobj.c index ae73fd31f..a1f1463b3 100644 --- a/src/p_polyobj.c +++ b/src/p_polyobj.c @@ -200,7 +200,7 @@ boolean P_BBoxInsidePolyobj(polyobj_t *po, fixed_t *bbox) { if (P_BoxOnLineSide(bbox, po->lines[i]) == 0) return false; - if (tm.sweep) + if (g_tm.sweep) { P_TestLine(po->lines[i]); } @@ -801,7 +801,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 tm.thing. Returns true if the line isn't contacted +// argument instead of using g_tm.thing. Returns true if the line isn't contacted // and false otherwise. static inline boolean Polyobj_untouched(line_t *ld, mobj_t *mo) { @@ -845,10 +845,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, NULL); - mo->floorz = tm.floorz; - mo->ceilingz = tm.ceilingz; - mo->floorrover = tm.floorrover; - mo->ceilingrover = tm.ceilingrover; + mo->floorz = g_tm.floorz; + mo->ceilingz = g_tm.ceilingz; + mo->floorrover = g_tm.floorrover; + mo->ceilingrover = g_tm.ceilingrover; } } diff --git a/src/p_setup.c b/src/p_setup.c index 446996af5..e4c2d46a7 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -8625,7 +8625,7 @@ boolean P_LoadLevel(boolean fromnetsave, boolean reloadinggamestate) P_ResetTubeWaypoints(); - P_MapStart(); // tm.thing can be used starting from this point + P_MapStart(); // g_tm.thing can be used starting from this point // init anything that P_SpawnSlopes/P_LoadThings needs to know P_InitSpecials(); @@ -8740,7 +8740,7 @@ boolean P_LoadLevel(boolean fromnetsave, boolean reloadinggamestate) G_AddMapToBuffer(gamemap-1); - P_MapEnd(); // tm.thing is no longer needed from this point onwards + P_MapEnd(); // g_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) @@ -8825,7 +8825,7 @@ boolean P_LoadLevel(boolean fromnetsave, boolean reloadinggamestate) void P_PostLoadLevel(void) { TracyCZone(__zone, true); - P_MapStart(); // tm.thing can be used starting from this point + P_MapStart(); // g_tm.thing can be used starting from this point if (G_GametypeHasSpectators()) { diff --git a/src/p_sight.c b/src/p_sight.c index 373cc1581..ca4608a1a 100644 --- a/src/p_sight.c +++ b/src/p_sight.c @@ -335,13 +335,13 @@ static boolean P_CanBotTraverse(seg_t *seg, divline_t *divl, register los_t *los frac = P_InterceptVector(&los->strace, divl); // calculate position at intercept - tm.x = los->strace.x + FixedMul(los->strace.dx, frac); - tm.y = los->strace.y + FixedMul(los->strace.dy, frac); + g_tm.x = los->strace.x + FixedMul(los->strace.dx, frac); + g_tm.y = los->strace.y + FixedMul(los->strace.dy, frac); // set openrange, opentop, openbottom open.fofType = (flip ? LO_FOF_CEILINGS : LO_FOF_FLOORS); P_LineOpening(line, los->t1, &open); - maxstep = P_GetThingStepUp(los->t1, tm.x, tm.y); + maxstep = P_GetThingStepUp(los->t1, g_tm.x, g_tm.y); if (open.range < los->t1->height) { @@ -363,7 +363,7 @@ static boolean P_CanBotTraverse(seg_t *seg, divline_t *divl, register los_t *los UINT8 side = P_DivlineSide(los->t2x, los->t2y, divl) & 1; sector_t *sector = (side == 1) ? seg->backsector : seg->frontsector; - if (K_BotHatesThisSector(los->t1->player, sector, tm.x, tm.y)) + if (K_BotHatesThisSector(los->t1->player, sector, g_tm.x, g_tm.y)) { // This line does not block us, but we don't want to cross it regardless. return false; @@ -403,13 +403,13 @@ static boolean P_CanWaypointTraverse(seg_t *seg, divline_t *divl, register los_t frac = P_InterceptVector(&los->strace, divl); // calculate position at intercept - tm.x = los->strace.x + FixedMul(los->strace.dx, frac); - tm.y = los->strace.y + FixedMul(los->strace.dy, frac); + g_tm.x = los->strace.x + FixedMul(los->strace.dx, frac); + g_tm.y = los->strace.y + FixedMul(los->strace.dy, frac); // set openrange, opentop, openbottom open.fofType = (flip ? LO_FOF_CEILINGS : LO_FOF_FLOORS); P_LineOpening(line, los->t1, &open); - maxstep = P_GetThingStepUp(los->t1, tm.x, tm.y); + maxstep = P_GetThingStepUp(los->t1, g_tm.x, g_tm.y); #if 0 if (los->t2->type == MT_WAYPOINT)