- handled most level references in actorinlines.h and p_mobj.cpp.

This commit is contained in:
Christoph Oelckers 2019-01-27 16:08:22 +01:00
parent c94f0f47a2
commit 73696e2781
6 changed files with 76 additions and 69 deletions

View file

@ -8,22 +8,22 @@
inline DVector3 AActor::PosRelative(int portalgroup) const
{
return Pos() + level.Displacements.getOffset(Sector->PortalGroup, portalgroup);
return Pos() + Level->Displacements.getOffset(Sector->PortalGroup, portalgroup);
}
inline DVector3 AActor::PosRelative(const AActor *other) const
{
return Pos() + level.Displacements.getOffset(Sector->PortalGroup, other->Sector->PortalGroup);
return Pos() + Level->Displacements.getOffset(Sector->PortalGroup, other->Sector->PortalGroup);
}
inline DVector3 AActor::PosRelative(sector_t *sec) const
{
return Pos() + level.Displacements.getOffset(Sector->PortalGroup, sec->PortalGroup);
return Pos() + Level->Displacements.getOffset(Sector->PortalGroup, sec->PortalGroup);
}
inline DVector3 AActor::PosRelative(const line_t *line) const
{
return Pos() + level.Displacements.getOffset(Sector->PortalGroup, line->frontsector->PortalGroup);
return Pos() + Level->Displacements.getOffset(Sector->PortalGroup, line->frontsector->PortalGroup);
}
inline DVector3 PosRelative(const DVector3 &pos, line_t *line, sector_t *refsec = NULL)
@ -61,7 +61,7 @@ inline double AActor::GetBobOffset(double ticfrac) const
{
return 0;
}
return BobSin(FloatBobPhase + level.maptime + ticfrac) * FloatBobStrength;
return BobSin(FloatBobPhase + Level->maptime + ticfrac) * FloatBobStrength;
}
inline double AActor::GetCameraHeight() const
@ -78,7 +78,7 @@ inline FDropItem *AActor::GetDropItems() const
inline double AActor::GetGravity() const
{
if (flags & MF_NOGRAVITY) return 0;
return level.gravity * Sector->gravity * Gravity * 0.00125;
return Level->gravity * Sector->gravity * Gravity * 0.00125;
}
inline double AActor::AttackOffset(double offset)
@ -102,7 +102,7 @@ inline DVector2 AActor::Vec2Offset(double dx, double dy, bool absolute)
}
else
{
return level.GetPortalOffsetPosition(X(), Y(), dx, dy);
return Level->GetPortalOffsetPosition(X(), Y(), dx, dy);
}
}
@ -115,7 +115,7 @@ inline DVector3 AActor::Vec2OffsetZ(double dx, double dy, double atz, bool absol
}
else
{
DVector2 v = level.GetPortalOffsetPosition(X(), Y(), dx, dy);
DVector2 v = Level->GetPortalOffsetPosition(X(), Y(), dx, dy);
return DVector3(v, atz);
}
}
@ -128,7 +128,7 @@ inline DVector2 AActor::Vec2Angle(double length, DAngle angle, bool absolute)
}
else
{
return level.GetPortalOffsetPosition(X(), Y(), length*angle.Cos(), length*angle.Sin());
return Level->GetPortalOffsetPosition(X(), Y(), length*angle.Cos(), length*angle.Sin());
}
}
@ -140,7 +140,7 @@ inline DVector3 AActor::Vec3Offset(double dx, double dy, double dz, bool absolut
}
else
{
DVector2 v = level.GetPortalOffsetPosition(X(), Y(), dx, dy);
DVector2 v = Level->GetPortalOffsetPosition(X(), Y(), dx, dy);
return DVector3(v, Z() + dz);
}
}
@ -158,7 +158,7 @@ inline DVector3 AActor::Vec3Angle(double length, DAngle angle, double dz, bool a
}
else
{
DVector2 v = level.GetPortalOffsetPosition(X(), Y(), length*angle.Cos(), length*angle.Sin());
DVector2 v = Level->GetPortalOffsetPosition(X(), Y(), length*angle.Cos(), length*angle.Sin());
return DVector3(v, Z() + dz);
}
}

View file

@ -204,6 +204,9 @@ public:
void DoDeferedScripts();
void AdjustPusher(int tag, int magnitude, int angle, bool wind);
int Massacre(bool baddies = false, FName cls = NAME_None);
AActor *SpawnMapThing(FMapThing *mthing, int position);
AActor *SpawnMapThing(int index, FMapThing *mt, int position);
AActor *SpawnPlayer(FPlayerStart *mthing, int playernum, int flags);
bool EV_DoPlat(int tag, line_t *line, DPlat::EPlatType type, double height, double speed, int delay, int lip, int change);
void EV_StopPlat(int tag, bool remove);
@ -592,3 +595,9 @@ inline bool line_t::hitSkyWall(AActor* mo) const
backsector->GetTexture(sector_t::ceiling) == skyflatnum &&
mo->Z() >= backsector->ceilingplane.ZatPoint(mo->PosRelative(this));
}
// Work for later.
inline AActor *P_SpawnPlayer(FPlayerStart *mthing, int playernum, int flags = 0)
{
return level.SpawnPlayer(mthing, playernum, flags);
}

View file

@ -111,7 +111,6 @@ void BloodCrypt (void *data, int key, int len);
void P_ClearUDMFKeys();
void InitRenderInfo();
extern AActor *SpawnMapThing (int index, FMapThing *mthing, int position);
EXTERN_CVAR(Bool, am_textured)
@ -1448,7 +1447,7 @@ void MapLoader::SpawnThings (int position)
for (int i=0; i < numthings; i++)
{
AActor *actor = SpawnMapThing (i, &MapThingsConverted[i], position);
AActor *actor = Level->SpawnMapThing (i, &MapThingsConverted[i], position);
unsigned *udi = MapThingsUserDataIndex.CheckKey((unsigned)i);
if (udi != nullptr)
{

View file

@ -97,8 +97,6 @@ void P_PredictionLerpReset();
#define SPF_TEMPPLAYER 1 // spawning a short-lived dummy player
#define SPF_WEAPONFULLYUP 2 // spawn with weapon already raised
AActor *P_SpawnPlayer (FPlayerStart *mthing, int playernum, int flags=0);
int P_FaceMobj (AActor *source, AActor *target, DAngle *delta);
bool P_SeekerMissile (AActor *actor, double thresh, double turnMax, bool precise = false, bool usecurspeed=false);

View file

@ -774,7 +774,7 @@ void AActor::ClearInventory()
void AActor::CopyFriendliness (AActor *other, bool changeTarget, bool resetHealth)
{
level.total_monsters -= CountsAsKill();
Level->total_monsters -= CountsAsKill();
TIDtoHate = other->TIDtoHate;
LastLookActor = other->LastLookActor;
LastLookPlayerNumber = other->LastLookPlayerNumber;
@ -789,7 +789,7 @@ void AActor::CopyFriendliness (AActor *other, bool changeTarget, bool resetHealt
LastHeard = target = other->target;
}
if (resetHealth) health = SpawnHealth();
level.total_monsters += CountsAsKill();
Level->total_monsters += CountsAsKill();
}
DEFINE_ACTION_FUNCTION(AActor, CopyFriendliness)
@ -2215,15 +2215,16 @@ explode:
(!(mo->flags2 & MF2_FLY) || !(mo->flags & MF_NOGRAVITY)) &&
!mo->waterlevel)
{ // [RH] Friction when falling is available for larger aircontrols
if (player != NULL && level.airfriction != 1.)
auto airfriction = mo->Level->airfriction;
if (player != NULL && airfriction != 1.)
{
mo->Vel.X *= level.airfriction;
mo->Vel.Y *= level.airfriction;
mo->Vel.X *= airfriction;
mo->Vel.Y *= airfriction;
if (player->mo == mo) // Not voodoo dolls
{
player->Vel.X *= level.airfriction;
player->Vel.Y *= level.airfriction;
player->Vel.X *= airfriction;
player->Vel.Y *= airfriction;
}
}
return Oldfloorz;
@ -2326,7 +2327,7 @@ void P_MonsterFallingDamage (AActor *mo)
int damage;
double vel;
if (!(level.flags2 & LEVEL2_MONSTERFALLINGDAMAGE))
if (!(mo->Level->flags2 & LEVEL2_MONSTERFALLINGDAMAGE))
return;
if (mo->floorsector->Flags & SECF_NOFALLINGDAMAGE)
return;
@ -2474,7 +2475,7 @@ void P_ZMovement (AActor *mo, double oldfloorz)
{
if (!mo->IsNoClip2())
{
mo->AddZ(DAngle(360 / 80.f * level.maptime).Sin() / 8);
mo->AddZ(DAngle(360 / 80.f * mo->Level->maptime).Sin() / 8);
}
if (!(mo->flags8 & MF8_NOFRICTION))
@ -2903,7 +2904,7 @@ void AActor::AddToHash ()
else
{
int hash = TIDHASH (tid);
auto &slot = level.TIDHash[hash];
auto &slot = Level->TIDHash[hash];
inext = slot;
iprev = &slot;
@ -3504,7 +3505,7 @@ void AActor::Tick ()
if (!(flags5 & MF5_NOTIMEFREEZE))
{
//Added by MC: Freeze mode.
if (bglobal.freeze || level.flags2 & LEVEL2_FROZEN)
if (bglobal.freeze || Level->flags2 & LEVEL2_FROZEN)
{
// Boss cubes shouldn't be accelerated by timefreeze
if (flags6 & MF6_BOSSCUBE)
@ -3565,7 +3566,7 @@ void AActor::Tick ()
}
// Apply freeze mode.
if ((level.flags2 & LEVEL2_FROZEN) && (player == NULL || player->timefreezer == 0))
if ((Level->flags2 & LEVEL2_FROZEN) && (player == NULL || player->timefreezer == 0))
{
return;
}
@ -3682,7 +3683,7 @@ void AActor::Tick ()
// [RH] Consider carrying sectors here
DVector2 cumm(0, 0);
if ((((flags8 & MF8_INSCROLLSEC) && level.Scrolls.Size() > 0) || player != NULL) && !(flags & MF_NOCLIP) && !(flags & MF_NOSECTOR))
if ((((flags8 & MF8_INSCROLLSEC) && Level->Scrolls.Size() > 0) || player != NULL) && !(flags & MF_NOCLIP) && !(flags & MF_NOSECTOR))
{
double height, waterheight; // killough 4/4/98: add waterheight
const msecnode_t *node;
@ -3706,9 +3707,9 @@ void AActor::Tick ()
sector_t *sec = node->m_sector;
DVector2 scrollv;
if (level.Scrolls.Size() > unsigned(sec->Index()))
if (Level->Scrolls.Size() > unsigned(sec->Index()))
{
scrollv = level.Scrolls[sec->Index()];
scrollv = Level->Scrolls[sec->Index()];
}
else
{
@ -3764,7 +3765,7 @@ void AActor::Tick ()
}
else if (scrolltype == Scroll_StrifeCurrent)
{ // Strife scroll special
int anglespeed = level.GetFirstSectorTag(sec) - 100;
int anglespeed = Level->GetFirstSectorTag(sec) - 100;
double carryspeed = (anglespeed % 10) / (16 * CARRYFACTOR);
DAngle angle = ((anglespeed / 10) * 45.);
scrollv += angle.ToVector(carryspeed);
@ -3909,7 +3910,7 @@ void AActor::Tick ()
{
if (player)
{
if (Vel.Z < level.gravity * Sector->gravity * (-1./100)// -655.36f)
if (Vel.Z < Level->gravity * Sector->gravity * (-1./100)// -655.36f)
&& !(flags&MF_NOGRAVITY))
{
PlayerLandedOnThing (this, onmo);
@ -3937,12 +3938,12 @@ void AActor::Tick ()
if ((onmo->flags6 & MF6_BUMPSPECIAL) && ((player != NULL)
|| ((onmo->activationtype & THINGSPEC_MonsterTrigger) && (flags3 & MF3_ISMONSTER))
|| ((onmo->activationtype & THINGSPEC_MissileTrigger) && (flags & MF_MISSILE))
) && (level.maptime > onmo->lastbump)) // Leave the bumper enough time to go away
) && (Level->maptime > onmo->lastbump)) // Leave the bumper enough time to go away
{
if (player == NULL || !(player->cheats & CF_PREDICTING))
{
if (P_ActivateThingSpecial(onmo, this))
onmo->lastbump = level.maptime + TICRATE;
onmo->lastbump = Level->maptime + TICRATE;
}
}
if (Vel.Z != 0 && (BounceFlags & BOUNCE_Actors))
@ -3983,7 +3984,7 @@ void AActor::Tick ()
}
// Check for poison damage, but only once per PoisonPeriod tics (or once per second if none).
if (PoisonDurationReceived && (level.time % (PoisonPeriodReceived ? PoisonPeriodReceived : TICRATE) == 0))
if (PoisonDurationReceived && (Level->time % (PoisonPeriodReceived ? PoisonPeriodReceived : TICRATE) == 0))
{
P_DamageMobj(this, NULL, Poisoner, PoisonDamageReceived, PoisonDamageTypeReceived ? PoisonDamageTypeReceived : (FName)NAME_Poison, 0);
@ -4037,7 +4038,7 @@ void AActor::Tick ()
if (movecount < respawn_monsters)
return;
if (level.time & 31)
if (Level->time & 31)
return;
if (pr_nightmarerespawn() > 4)
@ -4883,7 +4884,7 @@ EXTERN_CVAR(Float, fov)
extern bool demonew;
AActor *P_SpawnPlayer (FPlayerStart *mthing, int playernum, int flags)
AActor *FLevelLocals::SpawnPlayer (FPlayerStart *mthing, int playernum, int flags)
{
player_t *p;
AActor *mobj, *oldactor;
@ -4969,7 +4970,7 @@ AActor *P_SpawnPlayer (FPlayerStart *mthing, int playernum, int flags)
mobj = Spawn (p->cls, spawn, NO_REPLACE);
if (level.flags & LEVEL_USEPLAYERSTARTZ)
if (flags & LEVEL_USEPLAYERSTARTZ)
{
if (spawn.Z == ONFLOORZ)
mobj->AddZ(mthing->pos.Z);
@ -4995,7 +4996,7 @@ AActor *P_SpawnPlayer (FPlayerStart *mthing, int playernum, int flags)
VMValue params[] = { mobj, oldactor };
VMCall(func, params, 2, nullptr, 0);
}
level.Behaviors.StopMyScripts (oldactor); // cancel all ENTER/RESPAWN scripts for the voodoo doll
Behaviors.StopMyScripts (oldactor); // cancel all ENTER/RESPAWN scripts for the voodoo doll
}
// [GRB] Reset skin
@ -5078,7 +5079,7 @@ AActor *P_SpawnPlayer (FPlayerStart *mthing, int playernum, int flags)
VMCall(func, params, 1, nullptr, 0);
}
}
else if ((multiplayer || (level.flags2 & LEVEL2_ALLOWRESPAWN) || sv_singleplayerrespawn ||
else if ((multiplayer || (flags2 & LEVEL2_ALLOWRESPAWN) || sv_singleplayerrespawn ||
!!G_SkillProperty(SKILLP_PlayerRespawn)) && state == PST_REBORN && oldactor != NULL)
{ // Special inventory handling for respawning in coop
IFVM(PlayerPawn, FilterCoopRespawnInventory)
@ -5124,7 +5125,7 @@ AActor *P_SpawnPlayer (FPlayerStart *mthing, int playernum, int flags)
{
if (state == PST_ENTER || (state == PST_LIVE && !savegamerestore))
{
level.Behaviors.StartTypedScripts (SCRIPT_Enter, p->mo, true);
Behaviors.StartTypedScripts (SCRIPT_Enter, p->mo, true);
}
else if (state == PST_REBORN)
{
@ -5140,7 +5141,7 @@ AActor *P_SpawnPlayer (FPlayerStart *mthing, int playernum, int flags)
{
if (th->LastHeard == oldactor) th->LastHeard = nullptr;
}
for(auto &sec : level.sectors)
for(auto &sec : sectors)
{
if (sec.SoundTarget == oldactor) sec.SoundTarget = nullptr;
}
@ -5148,7 +5149,7 @@ AActor *P_SpawnPlayer (FPlayerStart *mthing, int playernum, int flags)
DObject::StaticPointerSubstitution (oldactor, p->mo);
E_PlayerRespawned(int(p - players));
level.Behaviors.StartTypedScripts (SCRIPT_Respawn, p->mo, true);
Behaviors.StartTypedScripts (SCRIPT_Respawn, p->mo, true);
}
}
return mobj;
@ -5161,7 +5162,7 @@ AActor *P_SpawnPlayer (FPlayerStart *mthing, int playernum, int flags)
// already be in host byte order.
//
// [RH] position is used to weed out unwanted start spots
AActor *P_SpawnMapThing (FMapThing *mthing, int position)
AActor *FLevelLocals::SpawnMapThing (FMapThing *mthing, int position)
{
PClassActor *i;
int mask;
@ -5207,7 +5208,7 @@ AActor *P_SpawnMapThing (FMapThing *mthing, int position)
{
// count deathmatch start positions
FPlayerStart start(mthing, 0);
level.deathmatchstarts.Push(start);
deathmatchstarts.Push(start);
return NULL;
}
@ -5235,7 +5236,7 @@ AActor *P_SpawnMapThing (FMapThing *mthing, int position)
}
}
if (pnum == -1 || (level.flags & LEVEL_FILTERSTARTS))
if (pnum == -1 || (flags & LEVEL_FILTERSTARTS))
{
// check for appropriate game type
if (deathmatch)
@ -5300,10 +5301,10 @@ AActor *P_SpawnMapThing (FMapThing *mthing, int position)
// save spots for respawning in network games
FPlayerStart start(mthing, pnum+1);
level.playerstarts[pnum] = start;
if (level.flags2 & LEVEL2_RANDOMPLAYERSTARTS)
playerstarts[pnum] = start;
if (flags2 & LEVEL2_RANDOMPLAYERSTARTS)
{ // When using random player starts, all starts count
level.AllPlayerStarts.Push(start);
AllPlayerStarts.Push(start);
}
else
{ // When not using random player starts, later single player
@ -5311,22 +5312,22 @@ AActor *P_SpawnMapThing (FMapThing *mthing, int position)
// ones are for voodoo dolls and not likely to be ideal for
// spawning regular players.
unsigned i;
for (i = 0; i < level.AllPlayerStarts.Size(); ++i)
for (i = 0; i < AllPlayerStarts.Size(); ++i)
{
if (level.AllPlayerStarts[i].type == pnum+1)
if (AllPlayerStarts[i].type == pnum+1)
{
level.AllPlayerStarts[i] = start;
AllPlayerStarts[i] = start;
break;
}
}
if (i == level.AllPlayerStarts.Size())
if (i == AllPlayerStarts.Size())
{
level.AllPlayerStarts.Push(start);
AllPlayerStarts.Push(start);
}
}
if (!deathmatch && !(level.flags2 & LEVEL2_RANDOMPLAYERSTARTS))
if (!deathmatch && !(flags2 & LEVEL2_RANDOMPLAYERSTARTS))
{
return P_SpawnPlayer(&start, pnum, (level.flags2 & LEVEL2_PRERAISEWEAPON) ? SPF_WEAPONFULLYUP : 0);
return P_SpawnPlayer(&start, pnum, (flags2 & LEVEL2_PRERAISEWEAPON) ? SPF_WEAPONFULLYUP : 0);
}
return NULL;
}
@ -5386,7 +5387,7 @@ AActor *P_SpawnMapThing (FMapThing *mthing, int position)
}
// don't spawn any monsters if -nomonsters
if (((level.flags2 & LEVEL2_NOMONSTERS) || (dmflags & DF_NO_MONSTERS)) && info->flags3 & MF3_ISMONSTER )
if (((flags2 & LEVEL2_NOMONSTERS) || (dmflags & DF_NO_MONSTERS)) && info->flags3 & MF3_ISMONSTER )
{
return NULL;
}
@ -5462,11 +5463,11 @@ AActor *P_SpawnMapThing (FMapThing *mthing, int position)
if (mthing->Conversation > 0)
{
// Make sure that this does not partially overwrite the default dialogue settings.
int root = level.GetConversation(mthing->Conversation);
int root = GetConversation(mthing->Conversation);
if (root != -1)
{
mobj->ConversationRoot = root;
mobj->Conversation = level.StrifeDialogues[mobj->ConversationRoot];
mobj->Conversation = StrifeDialogues[mobj->ConversationRoot];
}
}
@ -5538,16 +5539,16 @@ AActor *P_SpawnMapThing (FMapThing *mthing, int position)
//===========================================================================
CVAR(Bool, dumpspawnedthings, false, 0)
AActor *SpawnMapThing(int index, FMapThing *mt, int position)
AActor *FLevelLocals::SpawnMapThing(int index, FMapThing *mt, int position)
{
AActor *spawned = P_SpawnMapThing(mt, position);
AActor *spawned = SpawnMapThing(mt, position);
if (dumpspawnedthings)
{
Printf("%5d: (%5f, %5f, %5f), doomednum = %5d, flags = %04x, type = %s\n",
index, mt->pos.X, mt->pos.Y, mt->pos.Z, mt->EdNum, mt->flags,
spawned ? spawned->GetClass()->TypeName.GetChars() : "(none)");
}
T_AddSpawnedThing(&level, spawned);
T_AddSpawnedThing(this, spawned);
return spawned;
}
@ -6667,7 +6668,7 @@ AActor *P_SpawnPlayerMissile (AActor *source, double x, double y, double z,
if (source->player != NULL &&
!nofreeaim &&
level.IsFreelookAllowed() &&
source->Level->IsFreelookAllowed() &&
source->player->userinfo.GetAimDist() <= 0.5)
{
break;
@ -6677,7 +6678,7 @@ AActor *P_SpawnPlayerMissile (AActor *source, double x, double y, double z,
if (pLineTarget->linetarget == NULL)
{
an = angle;
if (nofreeaim || !level.IsFreelookAllowed())
if (nofreeaim || !source->Level->IsFreelookAllowed())
{
pitch = 0.;
}
@ -7188,19 +7189,19 @@ void AActor::ClearCounters()
{
if (CountsAsKill() && health > 0)
{
level.total_monsters--;
Level->total_monsters--;
flags &= ~MF_COUNTKILL;
}
// Same, for items
if (flags & MF_COUNTITEM)
{
level.total_items--;
Level->total_items--;
flags &= ~MF_COUNTITEM;
}
// And finally for secrets
if (flags5 & MF5_COUNTSECRET)
{
level.total_secrets--;
Level->total_secrets--;
flags5 &= ~MF5_COUNTSECRET;
}
}

View file

@ -965,8 +965,8 @@ DAngle P_BulletSlope (AActor *mo, FTranslatedLineTarget *pLineTarget, int aimfla
an = mo->Angles.Yaw + angdiff[i];
pitch = P_AimLineAttack (mo, an, 16.*64, pLineTarget, 0., aimflags);
if (mo->player != NULL &&
level.IsFreelookAllowed() &&
if (mo->player != nullptr &&
mo->Level->IsFreelookAllowed() &&
mo->player->userinfo.GetAimDist() <= 0.5)
{
break;