- 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
commit 73696e2781
6 changed files with 76 additions and 69 deletions

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;
}
}