mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2024-11-25 13:51:43 +00:00
Fix segfault when trying to spawn an MT_PLAYER from Lua
This commit is contained in:
parent
cf7adfc8ac
commit
02811b72f6
3 changed files with 19 additions and 5 deletions
|
@ -641,7 +641,7 @@ static int lib_pSpawnMobj(lua_State *L)
|
||||||
NOHUD
|
NOHUD
|
||||||
INLEVEL
|
INLEVEL
|
||||||
NOSPAWNNULL
|
NOSPAWNNULL
|
||||||
LUA_PushUserdata(L, P_SpawnMobj(x, y, z, type), META_MOBJ);
|
LUA_PushUserdata(L, P_SpawnMobj(x, y, z, type, NULL), META_MOBJ);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -657,7 +657,7 @@ static int lib_pSpawnMobjFromMobj(lua_State *L)
|
||||||
NOSPAWNNULL
|
NOSPAWNNULL
|
||||||
if (!actor)
|
if (!actor)
|
||||||
return LUA_ErrInvalid(L, "mobj_t");
|
return LUA_ErrInvalid(L, "mobj_t");
|
||||||
LUA_PushUserdata(L, P_SpawnMobjFromMobj(actor, x, y, z, type), META_MOBJ);
|
LUA_PushUserdata(L, P_SpawnMobjFromMobj(actor, x, y, z, type, NULL), META_MOBJ);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -328,7 +328,7 @@ boolean P_CheckDeathPitCollide(mobj_t *mo);
|
||||||
boolean P_CheckSolidLava(ffloor_t *rover);
|
boolean P_CheckSolidLava(ffloor_t *rover);
|
||||||
void P_AdjustMobjFloorZ_FFloors(mobj_t *mo, sector_t *sector, UINT8 motype);
|
void P_AdjustMobjFloorZ_FFloors(mobj_t *mo, sector_t *sector, UINT8 motype);
|
||||||
|
|
||||||
mobj_t *P_SpawnMobjFromMobj(mobj_t *mobj, fixed_t xofs, fixed_t yofs, fixed_t zofs, mobjtype_t type);
|
mobj_t *P_SpawnMobjFromMobj(mobj_t *mobj, fixed_t xofs, fixed_t yofs, fixed_t zofs, mobjtype_t type, ...);
|
||||||
|
|
||||||
mobj_t *P_SpawnMissile(mobj_t *source, mobj_t *dest, mobjtype_t type);
|
mobj_t *P_SpawnMissile(mobj_t *source, mobj_t *dest, mobjtype_t type);
|
||||||
mobj_t *P_SpawnXYZMissile(mobj_t *source, mobj_t *dest, mobjtype_t type, fixed_t x, fixed_t y, fixed_t z);
|
mobj_t *P_SpawnXYZMissile(mobj_t *source, mobj_t *dest, mobjtype_t type, fixed_t x, fixed_t y, fixed_t z);
|
||||||
|
|
16
src/p_mobj.c
16
src/p_mobj.c
|
@ -14420,15 +14420,29 @@ void P_FlashPal(player_t *pl, UINT16 type, UINT16 duration)
|
||||||
// Spawns an object with offsets relative to the position of another object.
|
// Spawns an object with offsets relative to the position of another object.
|
||||||
// Scale, gravity flip, etc. is taken into account automatically.
|
// Scale, gravity flip, etc. is taken into account automatically.
|
||||||
//
|
//
|
||||||
mobj_t *P_SpawnMobjFromMobj(mobj_t *mobj, fixed_t xofs, fixed_t yofs, fixed_t zofs, mobjtype_t type)
|
mobj_t *P_SpawnMobjFromMobj(mobj_t *mobj, fixed_t xofs, fixed_t yofs, fixed_t zofs, mobjtype_t type, ...)
|
||||||
{
|
{
|
||||||
|
va_list args;
|
||||||
mobj_t *newmobj;
|
mobj_t *newmobj;
|
||||||
|
|
||||||
xofs = FixedMul(xofs, mobj->scale);
|
xofs = FixedMul(xofs, mobj->scale);
|
||||||
yofs = FixedMul(yofs, mobj->scale);
|
yofs = FixedMul(yofs, mobj->scale);
|
||||||
zofs = FixedMul(zofs, mobj->scale);
|
zofs = FixedMul(zofs, mobj->scale);
|
||||||
|
|
||||||
|
if (type == MT_PLAYER)
|
||||||
|
{
|
||||||
|
player_t *player;
|
||||||
|
// MT_PLAYER requires an additional parameter for the player, so pass that forth.
|
||||||
|
va_start(args, type);
|
||||||
|
player = va_arg(args, player_t *);
|
||||||
|
va_end(args);
|
||||||
|
newmobj = P_SpawnMobj(mobj->x + xofs, mobj->y + yofs, mobj->z + zofs, type, player);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
newmobj = P_SpawnMobj(mobj->x + xofs, mobj->y + yofs, mobj->z + zofs, type);
|
newmobj = P_SpawnMobj(mobj->x + xofs, mobj->y + yofs, mobj->z + zofs, type);
|
||||||
|
}
|
||||||
|
|
||||||
if (!newmobj)
|
if (!newmobj)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue