Move P_GetMobjSpawnHeight to p_mapthing.cpp

This commit is contained in:
James R 2023-03-29 20:20:08 -07:00
parent 0f5370efbb
commit 75d5c5b68f
3 changed files with 33 additions and 16 deletions

View file

@ -50,6 +50,7 @@ add_executable(SRB2SDL2 MACOSX_BUNDLE WIN32
p_lights.c
p_loop.c
p_map.c
p_mapthing.cpp
p_maputl.c
p_mobj.c
p_polyobj.c

32
src/p_mapthing.cpp Normal file
View file

@ -0,0 +1,32 @@
#include "doomstat.h" // mapobjectscale
#include "info.h"
#include "m_fixed.h"
#include "p_local.h" // ONFLOORZ
#include "p_mobj.h"
#include "p_slopes.h"
#include "r_defs.h"
#include "r_main.h"
fixed_t P_GetMobjSpawnHeight(
const mobjtype_t mobjtype,
const fixed_t x,
const fixed_t y,
const fixed_t dz,
const fixed_t offset,
const boolean flip,
const fixed_t scale
)
{
const fixed_t finalScale = FixedMul(scale, mapobjectscale);
const sector_t* sector = R_PointInSubsector(x, y)->sector;
// Axis objects snap to the floor.
if (mobjtype == MT_AXIS || mobjtype == MT_AXISTRANSFER || mobjtype == MT_AXISTRANSFERLINE)
return ONFLOORZ;
// Establish height.
if (flip)
return P_GetSectorCeilingZAt(sector, x, y) - dz - FixedMul(finalScale, offset + mobjinfo[mobjtype].height);
else
return P_GetSectorFloorZAt(sector, x, y) + dz + FixedMul(finalScale, offset);
}

View file

@ -12089,22 +12089,6 @@ void P_MovePlayerToStarpost(INT32 playernum)
P_AfterPlayerSpawn(playernum);
}
fixed_t P_GetMobjSpawnHeight(const mobjtype_t mobjtype, const fixed_t x, const fixed_t y, const fixed_t dz, const fixed_t offset, const boolean flip, const fixed_t scale)
{
const fixed_t finalScale = FixedMul(scale, mapobjectscale);
const subsector_t *ss = R_PointInSubsector(x, y);
// Axis objects snap to the floor.
if (mobjtype == MT_AXIS || mobjtype == MT_AXISTRANSFER || mobjtype == MT_AXISTRANSFERLINE)
return ONFLOORZ;
// Establish height.
if (flip)
return P_GetSectorCeilingZAt(ss->sector, x, y) - dz - FixedMul(finalScale, offset + mobjinfo[mobjtype].height);
else
return P_GetSectorFloorZAt(ss->sector, x, y) + dz + FixedMul(finalScale, offset);
}
fixed_t P_GetMapThingSpawnHeight(const mobjtype_t mobjtype, const mapthing_t* mthing, const fixed_t x, const fixed_t y)
{
fixed_t dz = mthing->z << FRACBITS; // Base offset from the floor.