P_RestoreTMStruct
This commit is contained in:
parent
97dc236522
commit
e4534dcf50
5 changed files with 66 additions and 25 deletions
|
|
@ -1048,7 +1048,7 @@ static int lib_pRailThinker(lua_State *L)
|
|||
if (!mobj)
|
||||
return LUA_ErrInvalid(L, "mobj_t");
|
||||
lua_pushboolean(L, P_RailThinker(mobj));
|
||||
tm = ptm;
|
||||
P_RestoreTMStruct(ptm);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
@ -1061,7 +1061,7 @@ static int lib_pXYMovement(lua_State *L)
|
|||
if (!actor)
|
||||
return LUA_ErrInvalid(L, "mobj_t");
|
||||
P_XYMovement(actor);
|
||||
tm = ptm;
|
||||
P_RestoreTMStruct(ptm);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -1074,7 +1074,7 @@ static int lib_pRingXYMovement(lua_State *L)
|
|||
if (!actor)
|
||||
return LUA_ErrInvalid(L, "mobj_t");
|
||||
P_RingXYMovement(actor);
|
||||
tm = ptm;
|
||||
P_RestoreTMStruct(ptm);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -1087,7 +1087,7 @@ static int lib_pSceneryXYMovement(lua_State *L)
|
|||
if (!actor)
|
||||
return LUA_ErrInvalid(L, "mobj_t");
|
||||
P_SceneryXYMovement(actor);
|
||||
tm = ptm;
|
||||
P_RestoreTMStruct(ptm);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -1101,7 +1101,7 @@ static int lib_pZMovement(lua_State *L)
|
|||
return LUA_ErrInvalid(L, "mobj_t");
|
||||
lua_pushboolean(L, P_ZMovement(actor));
|
||||
P_CheckPosition(actor, actor->x, actor->y);
|
||||
tm = ptm;
|
||||
P_RestoreTMStruct(ptm);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
@ -1115,7 +1115,7 @@ static int lib_pRingZMovement(lua_State *L)
|
|||
return LUA_ErrInvalid(L, "mobj_t");
|
||||
P_RingZMovement(actor);
|
||||
P_CheckPosition(actor, actor->x, actor->y);
|
||||
tm = ptm;
|
||||
P_RestoreTMStruct(ptm);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -1129,7 +1129,7 @@ static int lib_pSceneryZMovement(lua_State *L)
|
|||
return LUA_ErrInvalid(L, "mobj_t");
|
||||
lua_pushboolean(L, P_SceneryZMovement(actor));
|
||||
P_CheckPosition(actor, actor->x, actor->y);
|
||||
tm = ptm;
|
||||
P_RestoreTMStruct(ptm);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
@ -1143,7 +1143,7 @@ static int lib_pPlayerZMovement(lua_State *L)
|
|||
return LUA_ErrInvalid(L, "mobj_t");
|
||||
P_PlayerZMovement(actor);
|
||||
P_CheckPosition(actor, actor->x, actor->y);
|
||||
tm = ptm;
|
||||
P_RestoreTMStruct(ptm);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -1351,7 +1351,7 @@ static int lib_pMovePlayer(lua_State *L)
|
|||
if (!player)
|
||||
return LUA_ErrInvalid(L, "player_t");
|
||||
P_MovePlayer(player);
|
||||
tm = ptm;
|
||||
P_RestoreTMStruct(ptm);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -1433,7 +1433,7 @@ static int lib_pCheckPosition(lua_State *L)
|
|||
return LUA_ErrInvalid(L, "mobj_t");
|
||||
lua_pushboolean(L, P_CheckPosition(thing, x, y));
|
||||
LUA_PushUserdata(L, tm.thing, META_MOBJ);
|
||||
tm = ptm;
|
||||
P_RestoreTMStruct(ptm);
|
||||
return 2;
|
||||
}
|
||||
|
||||
|
|
@ -1450,7 +1450,7 @@ static int lib_pTryMove(lua_State *L)
|
|||
return LUA_ErrInvalid(L, "mobj_t");
|
||||
lua_pushboolean(L, P_TryMove(thing, x, y, allowdropoff));
|
||||
LUA_PushUserdata(L, tm.thing, META_MOBJ);
|
||||
tm = ptm;
|
||||
P_RestoreTMStruct(ptm);
|
||||
return 2;
|
||||
}
|
||||
|
||||
|
|
@ -1465,7 +1465,7 @@ static int lib_pMove(lua_State *L)
|
|||
return LUA_ErrInvalid(L, "mobj_t");
|
||||
lua_pushboolean(L, P_Move(actor, speed));
|
||||
LUA_PushUserdata(L, tm.thing, META_MOBJ);
|
||||
tm = ptm;
|
||||
P_RestoreTMStruct(ptm);
|
||||
return 2;
|
||||
}
|
||||
|
||||
|
|
@ -1483,7 +1483,7 @@ static int lib_pTeleportMove(lua_State *L)
|
|||
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);
|
||||
tm = ptm;
|
||||
P_RestoreTMStruct(ptm);
|
||||
return 2;
|
||||
}
|
||||
|
||||
|
|
@ -1500,7 +1500,7 @@ static int lib_pSetOrigin(lua_State *L)
|
|||
return LUA_ErrInvalid(L, "mobj_t");
|
||||
lua_pushboolean(L, P_SetOrigin(thing, x, y, z));
|
||||
LUA_PushUserdata(L, tm.thing, META_MOBJ);
|
||||
tm = ptm;
|
||||
P_RestoreTMStruct(ptm);
|
||||
return 2;
|
||||
}
|
||||
|
||||
|
|
@ -1517,7 +1517,7 @@ static int lib_pMoveOrigin(lua_State *L)
|
|||
return LUA_ErrInvalid(L, "mobj_t");
|
||||
lua_pushboolean(L, P_MoveOrigin(thing, x, y, z));
|
||||
LUA_PushUserdata(L, tm.thing, META_MOBJ);
|
||||
tm = ptm;
|
||||
P_RestoreTMStruct(ptm);
|
||||
return 2;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -791,7 +791,7 @@ static int sector_set(lua_State *L)
|
|||
sector->floorheight = lastpos;
|
||||
P_CheckSector(sector, true);
|
||||
}
|
||||
tm = ptm;
|
||||
P_RestoreTMStruct(ptm);
|
||||
break;
|
||||
}
|
||||
case sector_ceilingheight: { // ceilingheight
|
||||
|
|
@ -805,7 +805,7 @@ static int sector_set(lua_State *L)
|
|||
sector->ceilingheight = lastpos;
|
||||
P_CheckSector(sector, true);
|
||||
}
|
||||
tm = ptm;
|
||||
P_RestoreTMStruct(ptm);
|
||||
break;
|
||||
}
|
||||
case sector_floorpic:
|
||||
|
|
@ -2207,7 +2207,7 @@ static int ffloor_set(lua_State *L)
|
|||
*ffloor->topheight = lastpos;
|
||||
P_CheckSector(sector, true);
|
||||
}
|
||||
tm = ptm;
|
||||
P_RestoreTMStruct(ptm);
|
||||
break;
|
||||
}
|
||||
case ffloor_toppic:
|
||||
|
|
@ -2228,7 +2228,7 @@ static int ffloor_set(lua_State *L)
|
|||
*ffloor->bottomheight = lastpos;
|
||||
P_CheckSector(sector, true);
|
||||
}
|
||||
tm = ptm;
|
||||
P_RestoreTMStruct(ptm);
|
||||
break;
|
||||
}
|
||||
case ffloor_bottompic:
|
||||
|
|
|
|||
|
|
@ -517,7 +517,7 @@ static int mobj_set(lua_State *L)
|
|||
mo->ceilingz = tm.ceilingz;
|
||||
mo->floorrover = tm.floorrover;
|
||||
mo->ceilingrover = tm.ceilingrover;
|
||||
tm = ptm;
|
||||
P_RestoreTMStruct(ptm);
|
||||
break;
|
||||
}
|
||||
case mobj_snext:
|
||||
|
|
@ -590,7 +590,7 @@ static int mobj_set(lua_State *L)
|
|||
mo->ceilingz = tm.ceilingz;
|
||||
mo->floorrover = tm.floorrover;
|
||||
mo->ceilingrover = tm.ceilingrover;
|
||||
tm = ptm;
|
||||
P_RestoreTMStruct(ptm);
|
||||
break;
|
||||
}
|
||||
case mobj_height:
|
||||
|
|
@ -604,7 +604,7 @@ static int mobj_set(lua_State *L)
|
|||
mo->ceilingz = tm.ceilingz;
|
||||
mo->floorrover = tm.floorrover;
|
||||
mo->ceilingrover = tm.ceilingrover;
|
||||
tm = ptm;
|
||||
P_RestoreTMStruct(ptm);
|
||||
break;
|
||||
}
|
||||
case mobj_momx:
|
||||
|
|
|
|||
|
|
@ -424,6 +424,8 @@ typedef struct tm_s
|
|||
|
||||
extern tm_t tm;
|
||||
|
||||
void P_RestoreTMStruct(tm_t tmrestore);
|
||||
|
||||
extern camera_t *mapcampointer;
|
||||
|
||||
/* cphipps 2004/08/30 */
|
||||
|
|
|
|||
45
src/p_map.c
45
src/p_map.c
|
|
@ -44,6 +44,45 @@
|
|||
|
||||
tm_t tm = {0};
|
||||
|
||||
void P_RestoreTMStruct(tm_t tmrestore)
|
||||
{
|
||||
// Reference count management
|
||||
if (tm.thing != tmrestore.thing)
|
||||
{
|
||||
P_SetTarget(&tm.thing, NULL);
|
||||
}
|
||||
|
||||
if (tm.floorthing != tmrestore.floorthing)
|
||||
{
|
||||
P_SetTarget(&tm.floorthing, NULL);
|
||||
}
|
||||
|
||||
if (tm.hitthing != tmrestore.hitthing)
|
||||
{
|
||||
P_SetTarget(&tm.hitthing, NULL);
|
||||
}
|
||||
|
||||
// Restore state
|
||||
tm = tmrestore;
|
||||
|
||||
// Validation
|
||||
if (tm.thing && P_MobjWasRemoved(tm.thing) == true)
|
||||
{
|
||||
P_SetTarget(&tm.thing, NULL);
|
||||
}
|
||||
|
||||
if (tm.floorthing && P_MobjWasRemoved(tm.floorthing) == true)
|
||||
{
|
||||
P_SetTarget(&tm.floorthing, NULL);
|
||||
}
|
||||
|
||||
if (tm.hitthing && P_MobjWasRemoved(tm.hitthing) == true)
|
||||
{
|
||||
P_SetTarget(&tm.hitthing, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Mostly re-ported from DOOM Legacy
|
||||
// Keep track of special lines as they are hit, process them when the move is valid
|
||||
static size_t *spechit = NULL;
|
||||
|
|
@ -2293,7 +2332,7 @@ BlockItReturn_t PIT_PushableMoved(mobj_t *thing)
|
|||
P_TryMove(thing, thing->x + stand->momx, thing->y + stand->momy, true);
|
||||
|
||||
// Now restore EVERYTHING so the gargoyle doesn't keep the player's tmstuff and break
|
||||
tm = oldtm;
|
||||
P_RestoreTMStruct(oldtm);
|
||||
|
||||
thing->momz = stand->momz;
|
||||
}
|
||||
|
|
@ -4699,7 +4738,7 @@ void P_CreateSecNodeList(mobj_t *thing, fixed_t x, fixed_t y)
|
|||
* 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.
|
||||
*/
|
||||
tm = ptm;
|
||||
P_RestoreTMStruct(ptm);
|
||||
}
|
||||
|
||||
// More crazy crap Tails 08-25-2002
|
||||
|
|
@ -4766,7 +4805,7 @@ void P_CreatePrecipSecNodeList(precipmobj_t *thing,fixed_t x,fixed_t y)
|
|||
* 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.
|
||||
*/
|
||||
tm = ptm;
|
||||
P_RestoreTMStruct(ptm);
|
||||
}
|
||||
|
||||
/* cphipps 2004/08/30 -
|
||||
|
|
|
|||
Loading…
Reference in a new issue