- roughly 50 more, mostly search and replace.

This commit is contained in:
Christoph Oelckers 2019-01-27 19:16:14 +01:00
parent 06ba8c4c00
commit b4a95ccaa9
12 changed files with 74 additions and 65 deletions

View file

@ -1023,11 +1023,6 @@ void G_DoLoadLevel (int position, bool autosave, bool newGame)
P_SetupLevel (&level, position, newGame);
// [RH] Start lightning, if MAPINFO tells us to
if (level.flags & LEVEL_STARTLIGHTNING)
{
P_StartLightning ();
}
gameaction = ga_nothing;

View file

@ -207,6 +207,8 @@ public:
AActor *SpawnMapThing(FMapThing *mthing, int position);
AActor *SpawnMapThing(int index, FMapThing *mt, int position);
AActor *SpawnPlayer(FPlayerStart *mthing, int playernum, int flags);
void StartLightning();
void ForceLightning(int mode);
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);

View file

@ -111,7 +111,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_QueueCorpse)
if (sv_corpsequeuesize > 0)
{
auto &corpsequeue = level.CorpseQueue;
auto &corpsequeue = self->Level->CorpseQueue;
while (corpsequeue.Size() >= (unsigned)sv_corpsequeuesize)
{
AActor *corpse = corpsequeue[0];
@ -128,7 +128,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_DeQueueCorpse)
{
PARAM_SELF_PROLOGUE(AActor);
auto &corpsequeue = level.CorpseQueue;
auto &corpsequeue = self->Level->CorpseQueue;
auto index = corpsequeue.FindEx([=](auto &element) { return element == self; });
if (index < corpsequeue.Size())
{

View file

@ -100,7 +100,7 @@ DEFINE_CLASS_PROPERTY(type, S, DynamicLight)
//
//==========================================================================
static FDynamicLight *GetLight()
static FDynamicLight *GetLight(FLevelLocals *Level)
{
FDynamicLight *ret;
if (FreeList.Size())
@ -109,11 +109,12 @@ static FDynamicLight *GetLight()
}
else ret = (FDynamicLight*)DynLightArena.Alloc(sizeof(FDynamicLight));
memset(ret, 0, sizeof(*ret));
ret->next = level.lights;
level.lights = ret;
ret->next = Level->lights;
Level->lights = ret;
if (ret->next) ret->next->prev = ret;
ret->visibletoplayer = true;
ret->mShadowmapIndex = 1024;
ret->Level = Level;
ret->Pos.X = -10000000; // not a valid coordinate.
return ret;
}
@ -128,7 +129,7 @@ static FDynamicLight *GetLight()
void AttachLight(AActor *self)
{
auto light = GetLight();
auto light = GetLight(self->Level);
light->pSpotInnerAngle = &self->AngleVar(NAME_SpotInnerAngle);
light->pSpotOuterAngle = &self->AngleVar(NAME_SpotOuterAngle);
@ -221,9 +222,9 @@ DEFINE_ACTION_FUNCTION_NATIVE(ADynamicLight, SetOffset, SetOffset)
void FDynamicLight::ReleaseLight()
{
assert(prev != nullptr || this == level.lights);
assert(prev != nullptr || this == Level->lights);
if (prev != nullptr) prev->next = next;
else level.lights = next;
else Level->lights = next;
if (next != nullptr) next->prev = prev;
next = prev = nullptr;
FreeList.Push(this);
@ -245,7 +246,7 @@ void FDynamicLight::Activate()
{
float pulseTime = float(specialf1 / TICRATE);
m_lastUpdate = level.maptime;
m_lastUpdate = Level->maptime;
if (!swapped) m_cycler.SetParams(float(GetSecondaryIntensity()), float(GetIntensity()), pulseTime);
else m_cycler.SetParams(float(GetIntensity()), float(GetSecondaryIntensity()), pulseTime);
m_cycler.ShouldCycle(true);
@ -294,9 +295,9 @@ void FDynamicLight::Tick()
{
case PulseLight:
{
float diff = (level.maptime - m_lastUpdate) / (float)TICRATE;
float diff = (Level->maptime - m_lastUpdate) / (float)TICRATE;
m_lastUpdate = level.maptime;
m_lastUpdate = Level->maptime;
m_cycler.Update(diff);
m_currentRadius = float(m_cycler.GetVal());
break;
@ -760,7 +761,7 @@ void AActor::AttachLight(unsigned int count, const FLightDefaults *lightdef)
}
else
{
light = GetLight();
light = GetLight(Level);
light->SetActor(this, true);
AttachedLights.Push(light);
}

View file

@ -233,6 +233,7 @@ public:
double specialf1;
FDynamicLight *next, *prev;
sector_t *Sector;
FLevelLocals *Level;
TObjPtr<AActor *> target;
FLightNode * touching_sides;
FLightNode * touching_sector;

View file

@ -47,7 +47,7 @@ void DLightningThinker::Construct()
LightningFlashCount = 0;
NextLightningFlash = ((pr_lightning()&15)+5)*35; // don't flash at level start
LightningLightLevels.Resize(level.sectors.Size());
LightningLightLevels.Resize(Level->sectors.Size());
fillshort(&LightningLightLevels[0], LightningLightLevels.Size(), SHRT_MAX);
}
@ -88,8 +88,8 @@ void DLightningThinker::LightningFlash ()
LightningFlashCount--;
if (LightningFlashCount)
{ // reduce the brightness of the flash
tempSec = &level.sectors[0];
for (i = level.sectors.Size(), j = 0; i > 0; ++j, --i, ++tempSec)
tempSec = &Level->sectors[0];
for (i = Level->sectors.Size(), j = 0; i > 0; ++j, --i, ++tempSec)
{
// [RH] Checking this sector's applicability to lightning now
// is not enough to know if we should lower its light level,
@ -104,24 +104,24 @@ void DLightningThinker::LightningFlash ()
}
else
{ // remove the alternate lightning flash special
tempSec = &level.sectors[0];
for (i = level.sectors.Size(), j = 0; i > 0; ++j, --i, ++tempSec)
tempSec = &Level->sectors[0];
for (i = Level->sectors.Size(), j = 0; i > 0; ++j, --i, ++tempSec)
{
if (LightningLightLevels[j] != SHRT_MAX)
{
tempSec->SetLightLevel(LightningLightLevels[j]);
}
}
fillshort(&LightningLightLevels[0], level.sectors.Size(), SHRT_MAX);
level.flags &= ~LEVEL_SWAPSKIES;
fillshort(&LightningLightLevels[0], Level->sectors.Size(), SHRT_MAX);
Level->flags &= ~LEVEL_SWAPSKIES;
}
return;
}
LightningFlashCount = (pr_lightning()&7)+8;
flashLight = 200+(pr_lightning()&31);
tempSec = &level.sectors[0];
for (i = level.sectors.Size(), j = 0; i > 0; ++j, --i, ++tempSec)
tempSec = &Level->sectors[0];
for (i = Level->sectors.Size(), j = 0; i > 0; ++j, --i, ++tempSec)
{
// allow combination of the lightning sector specials with bit masks
int special = tempSec->special;
@ -151,12 +151,12 @@ void DLightningThinker::LightningFlash ()
}
}
level.flags |= LEVEL_SWAPSKIES; // set alternate sky
Level->flags |= LEVEL_SWAPSKIES; // set alternate sky
S_Sound (CHAN_AUTO, "world/thunder", 1.0, ATTN_NONE);
// [ZZ] just in case
E_WorldLightning();
// start LIGHTNING scripts
level.Behaviors.StartTypedScripts (SCRIPT_Lightning, NULL, false); // [RH] Run lightning scripts
Level->Behaviors.StartTypedScripts (SCRIPT_Lightning, NULL, false); // [RH] Run lightning scripts
// Calculate the next lighting flash
if (!NextLightningFlash)
@ -167,7 +167,7 @@ void DLightningThinker::LightningFlash ()
}
else
{
if (pr_lightning() < 128 && !(level.time&32))
if (pr_lightning() < 128 && !(Level->time&32))
{
NextLightningFlash = ((pr_lightning()&7)+2)*35;
}
@ -202,16 +202,16 @@ static DLightningThinker *LocateLightning ()
return iterator.Next ();
}
void P_StartLightning ()
void FLevelLocals::StartLightning ()
{
const bool isOriginalHexen = (gameinfo.gametype == GAME_Hexen)
&& (level.flags2 & LEVEL2_HEXENHACK);
&& (flags2 & LEVEL2_HEXENHACK);
if (isOriginalHexen)
{
bool hasLightning = false;
for (const sector_t &sector : level.sectors)
for (const sector_t &sector : sectors)
{
hasLightning = sector.GetTexture(sector_t::ceiling) == skyflatnum
|| sector.special == Light_IndoorLightning1
@ -225,7 +225,7 @@ void P_StartLightning ()
if (!hasLightning)
{
level.flags &= ~LEVEL_STARTLIGHTNING;
flags &= ~LEVEL_STARTLIGHTNING;
return;
}
}
@ -233,16 +233,16 @@ void P_StartLightning ()
DLightningThinker *lightning = LocateLightning ();
if (lightning == nullptr)
{
level.CreateThinker<DLightningThinker>();
CreateThinker<DLightningThinker>();
}
}
void P_ForceLightning (int mode)
void FLevelLocals::ForceLightning (int mode)
{
DLightningThinker *lightning = LocateLightning ();
if (lightning == nullptr)
{
lightning = level.CreateThinker<DLightningThinker>();
lightning = CreateThinker<DLightningThinker>();
}
if (lightning != nullptr)
{

View file

@ -28,7 +28,5 @@ protected:
TArray<short> LightningLightLevels;
};
void P_StartLightning ();
void P_ForceLightning (int mode);
#endif //__A_LIGHTNING_H__

View file

@ -2069,7 +2069,7 @@ FUNC(LS_Elevator_LowerToNearest)
FUNC(LS_Light_ForceLightning)
// Light_ForceLightning (mode)
{
P_ForceLightning (arg0);
Level->ForceLightning (arg0);
return true;
}

View file

@ -413,7 +413,7 @@ bool P_TeleportMove(AActor* thing, const DVector3 &pos, bool telefrag, bool modi
spechit.Clear(); // this is needed so that no more specials get activated after crossing a teleporter.
bool StompAlwaysFrags = ((thing->flags2 & MF2_TELESTOMP) || (level.flags & LEVEL_MONSTERSTELEFRAG) || telefrag) && !(thing->flags7 & MF7_NOTELESTOMP);
bool StompAlwaysFrags = ((thing->flags2 & MF2_TELESTOMP) || (thing->Level->flags & LEVEL_MONSTERSTELEFRAG) || telefrag) && !(thing->flags7 & MF7_NOTELESTOMP);
// P_LineOpening requires the thing's z to be the destination z in order to work.
double savedz = thing->Z();
@ -975,7 +975,7 @@ bool PIT_CheckLine(FMultiBlockLinesIterator &mit, FMultiBlockLinesIterator::Chec
// better than Strife's handling of rails, which lets you jump into rails
// from either side. How long until somebody reports this as a bug and I'm
// forced to say, "It's not a bug. It's a feature?" Ugh.
(!(level.flags2 & LEVEL2_RAILINGHACK) ||
(!(tm.thing->Level->flags2 & LEVEL2_RAILINGHACK) ||
open.bottom == tm.thing->Sector->floorplane.ZatPoint(ref)))
{
open.bottom += 32;
@ -1365,10 +1365,10 @@ bool PIT_CheckThing(FMultiBlockThingsIterator &it, FMultiBlockThingsIterator::Ch
if ((thing->flags6 & MF6_BUMPSPECIAL) && ((tm.thing->player != NULL)
|| ((thing->activationtype & THINGSPEC_MonsterTrigger) && (tm.thing->flags3 & MF3_ISMONSTER))
|| ((thing->activationtype & THINGSPEC_MissileTrigger) && (tm.thing->flags & MF_MISSILE))
) && (level.maptime > thing->lastbump)) // Leave the bumper enough time to go away
) && (thing->Level->maptime > thing->lastbump)) // Leave the bumper enough time to go away
{
if (P_ActivateThingSpecial(thing, tm.thing))
thing->lastbump = level.maptime + TICRATE;
thing->lastbump = thing->Level->maptime + TICRATE;
}
}
@ -2041,7 +2041,7 @@ void P_FakeZMovement(AActor *mo)
}
if (mo->player && mo->flags&MF_NOGRAVITY && (mo->Z() > mo->floorz) && !mo->IsNoClip2())
{
mo->AddZ(DAngle(4.5 * level.maptime).Sin());
mo->AddZ(DAngle(4.5 * mo->Level->maptime).Sin());
}
//
@ -2111,7 +2111,7 @@ static void CheckForPushSpecial(line_t *line, int side, AActor *mobj, DVector2 *
}
else if (mobj->flags2 & MF2_IMPACT)
{
if ((level.flags2 & LEVEL2_MISSILESACTIVATEIMPACT) ||
if ((mobj->Level->flags2 & LEVEL2_MISSILESACTIVATEIMPACT) ||
!(mobj->flags & MF_MISSILE) ||
(mobj->target == NULL))
{
@ -4269,7 +4269,7 @@ DAngle P_AimLineAttack(AActor *t1, DAngle angle, double distance, FTranslatedLin
// can't shoot outside view angles
if (vrange == 0)
{
if (t1->player == NULL || !level.IsFreelookAllowed())
if (t1->player == NULL || !t1->Level->IsFreelookAllowed())
{
vrange = 35.;
}
@ -4539,7 +4539,7 @@ AActor *P_LineAttack(AActor *t1, DAngle angle, double distance,
// position a bit closer for puffs
if (nointeract || trace.HitType != TRACE_HitWall || ((trace.Line->special != Line_Horizon) || spawnSky))
{
DVector2 pos = level.GetPortalOffsetPosition(trace.HitPos.X, trace.HitPos.Y, -trace.HitVector.X * 4, -trace.HitVector.Y * 4);
DVector2 pos = t1->Level->GetPortalOffsetPosition(trace.HitPos.X, trace.HitPos.Y, -trace.HitVector.X * 4, -trace.HitVector.Y * 4);
puff = P_SpawnPuff(t1, pufftype, DVector3(pos, trace.HitPos.Z - trace.HitVector.Z * 4), trace.SrcAngleFromTarget,
trace.SrcAngleFromTarget - 90, 0, puffFlags);
puff->radius = 1/65536.;
@ -4590,7 +4590,7 @@ AActor *P_LineAttack(AActor *t1, DAngle angle, double distance,
// position a bit closer for puffs/blood if using compatibility mode.
if (i_compatflags & COMPATF_HITSCAN)
{
DVector2 ofs = level.GetPortalOffsetPosition(bleedpos.X, bleedpos.Y, -10 * trace.HitVector.X, -10 * trace.HitVector.Y);
DVector2 ofs = t1->Level->GetPortalOffsetPosition(bleedpos.X, bleedpos.Y, -10 * trace.HitVector.X, -10 * trace.HitVector.Y);
bleedpos.X = ofs.X;
bleedpos.Y = ofs.Y;
bleedpos.Z -= -10 * trace.HitVector.Z;
@ -5101,7 +5101,7 @@ static ETraceStatus ProcessRailHit(FTraceResults &res, void *userdata)
newhit.HitAngle = res.SrcAngleFromTarget;
if (i_compatflags & COMPATF_HITSCAN)
{
DVector2 ofs = level.GetPortalOffsetPosition(newhit.HitPos.X, newhit.HitPos.Y, -10 * res.HitVector.X, -10 * res.HitVector.Y);
DVector2 ofs = res.Actor->Level->GetPortalOffsetPosition(newhit.HitPos.X, newhit.HitPos.Y, -10 * res.HitVector.X, -10 * res.HitVector.Y);
newhit.HitPos.X = ofs.X;
newhit.HitPos.Y = ofs.Y;
newhit.HitPos.Z -= -10 * res.HitVector.Z;
@ -6167,7 +6167,7 @@ void P_DoCrunch(AActor *thing, FChangePosition *cpos)
if (!(thing && thing->CallGrind(true) && cpos)) return;
cpos->nofit = true;
if ((cpos->crushchange > 0) && !(level.maptime & 3))
if ((cpos->crushchange > 0) && !(thing->Level->maptime & 3))
{
int newdam = P_DamageMobj(thing, NULL, NULL, cpos->crushchange, NAME_Crush);
@ -6829,14 +6829,14 @@ bool P_ActivateThingSpecial(AActor * thing, AActor * trigger, bool death)
{
res = !!P_ExecuteSpecial(thing->special, NULL,
// TriggerActs overrides the level flag, which only concerns thing activated by death
(((death && level.flags & LEVEL_ACTOWNSPECIAL && !(thing->activationtype & THINGSPEC_TriggerActs))
(((death && thing->Level->flags & LEVEL_ACTOWNSPECIAL && !(thing->activationtype & THINGSPEC_TriggerActs))
|| (thing->activationtype & THINGSPEC_ThingActs)) // Who triggers?
? thing : trigger),
false, thing->args[0], thing->args[1], thing->args[2], thing->args[3], thing->args[4]);
// Clears the special if it was run on thing's death or if flag is set.
// Note that Hexen originally did not clear the special which some original maps depend on (e.g. the bell in HEXDD.)
if ((death && !(level.flags2 & LEVEL2_HEXENHACK)) || (thing->activationtype & THINGSPEC_ClearSpecial && res)) thing->special = 0;
if ((death && !(thing->Level->flags2 & LEVEL2_HEXENHACK)) || (thing->activationtype & THINGSPEC_ClearSpecial && res)) thing->special = 0;
}
// Returns the result

View file

@ -551,6 +551,13 @@ void P_SetupLevel(FLevelLocals *Level, int position, bool newGame)
Level->automap = AM_Create(Level);
Level->automap->LevelInit();
// [RH] Start lightning, if MAPINFO tells us to
if (Level->flags & LEVEL_STARTLIGHTNING)
{
Level->StartLightning();
}
}
//

View file

@ -148,6 +148,7 @@ bool ModActorFlag(AActor *actor, const FString &flagname, bool set, bool printer
if (actor != NULL)
{
auto Level = actor->Level;
const char *dot = strchr(flagname, '.');
FFlagDef *fd;
PClassActor *cls = actor->GetClass();
@ -166,9 +167,9 @@ bool ModActorFlag(AActor *actor, const FString &flagname, bool set, bool printer
{
found = true;
if (actor->CountsAsKill() && actor->health > 0) --level.total_monsters;
if (actor->flags & MF_COUNTITEM) --level.total_items;
if (actor->flags5 & MF5_COUNTSECRET) --level.total_secrets;
if (actor->CountsAsKill() && actor->health > 0) --Level->total_monsters;
if (actor->flags & MF_COUNTITEM) --Level->total_items;
if (actor->flags5 & MF5_COUNTSECRET) --Level->total_secrets;
if (fd->structoffset == -1)
{
@ -187,9 +188,9 @@ bool ModActorFlag(AActor *actor, const FString &flagname, bool set, bool printer
if (linkchange) actor->LinkToWorld(&ctx);
}
if (actor->CountsAsKill() && actor->health > 0) ++level.total_monsters;
if (actor->flags & MF_COUNTITEM) ++level.total_items;
if (actor->flags5 & MF5_COUNTSECRET) ++level.total_secrets;
if (actor->CountsAsKill() && actor->health > 0) ++Level->total_monsters;
if (actor->flags & MF_COUNTITEM) ++Level->total_items;
if (actor->flags5 & MF5_COUNTSECRET) ++Level->total_secrets;
}
else if (printerror)
{

View file

@ -1166,7 +1166,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(_Sector, RemoveForceField, RemoveForceField)
static void SetEnvironmentID(sector_t *self, int envnum)
{
level.Zones[self->ZoneNumber].Environment = S_FindEnvironment(envnum);
self->Level->Zones[self->ZoneNumber].Environment = S_FindEnvironment(envnum);
}
DEFINE_ACTION_FUNCTION_NATIVE(_Sector, SetEnvironmentID, SetEnvironmentID)
@ -1179,7 +1179,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(_Sector, RemoveForceField, RemoveForceField)
static void SetEnvironment(sector_t *self, const FString &env)
{
level.Zones[self->ZoneNumber].Environment = S_FindEnvironment(env);
self->Level->Zones[self->ZoneNumber].Environment = S_FindEnvironment(env);
}
DEFINE_ACTION_FUNCTION_NATIVE(_Sector, SetEnvironment, SetEnvironment)
@ -2352,19 +2352,21 @@ DEFINE_ACTION_FUNCTION_NATIVE(DBaseStatusBar, SetClipRect, SBar_SetClipRect)
static void GetGlobalACSString(int index, FString *result)
{
*result = level.Behaviors.LookupString(ACS_GlobalVars[index]);
*result = currentUILevel->Behaviors.LookupString(ACS_GlobalVars[index]);
}
DEFINE_ACTION_FUNCTION_NATIVE(DBaseStatusBar, GetGlobalACSString, GetGlobalACSString)
{
PARAM_PROLOGUE;
PARAM_INT(index);
ACTION_RETURN_STRING(level.Behaviors.LookupString(ACS_GlobalVars[index]));
FString res;
GetGlobalACSString(index, &res);
ACTION_RETURN_STRING(res);
}
static void GetGlobalACSArrayString(int arrayno, int index, FString *result)
{
*result = level.Behaviors.LookupString(ACS_GlobalVars[index]);
*result = currentUILevel->Behaviors.LookupString(ACS_GlobalVars[index]);
}
DEFINE_ACTION_FUNCTION_NATIVE(DBaseStatusBar, GetGlobalACSArrayString, GetGlobalACSArrayString)
@ -2372,7 +2374,9 @@ DEFINE_ACTION_FUNCTION_NATIVE(DBaseStatusBar, GetGlobalACSArrayString, GetGlobal
PARAM_PROLOGUE;
PARAM_INT(arrayno);
PARAM_INT(index);
ACTION_RETURN_STRING(level.Behaviors.LookupString(ACS_GlobalArrays[arrayno][index]));
FString res;
GetGlobalACSArrayString(arrayno, index, &res);
ACTION_RETURN_STRING(res);
}
static int GetGlobalACSValue(int index)
@ -2592,7 +2596,7 @@ DEFINE_ACTION_FUNCTION(FLevelLocals, GetChecksum)
for (int j = 0; j < 16; ++j)
{
sprintf(md5string + j * 2, "%02x", level.md5[j]);
sprintf(md5string + j * 2, "%02x", self->md5[j]);
}
ACTION_RETURN_STRING((const char*)md5string);