- handled approx. half of all cases where the address of level is taken.

This commit is contained in:
Christoph Oelckers 2019-01-28 00:55:21 +01:00
parent b4acb857ad
commit 648e472744
38 changed files with 122 additions and 128 deletions

View File

@ -2824,7 +2824,7 @@ void DAutomap::drawKeys ()
mpoint_t p;
DAngle angle;
TThinkerIterator<AActor> it(NAME_Key);
auto it = Level->GetThinkerIterator<AActor>(NAME_Key);
AActor *key;
while ((key = it.Next()) != nullptr)

View File

@ -73,7 +73,7 @@ bool DBot::Reachable (AActor *rtarget)
double estimated_dist = player->mo->Distance2D(rtarget);
bool reachable = true;
FPathTraverse it(&level, player->mo->X()+player->mo->Vel.X, player->mo->Y()+player->mo->Vel.Y, rtarget->X(), rtarget->Y(), PT_ADDLINES|PT_ADDTHINGS);
FPathTraverse it(Level, player->mo->X()+player->mo->Vel.X, player->mo->Y()+player->mo->Vel.Y, rtarget->X(), rtarget->Y(), PT_ADDLINES|PT_ADDTHINGS);
intercept_t *in;
while ((in = it.Next()))
{

View File

@ -289,7 +289,7 @@ void DBot::ThinkForMove (ticcmd_t *cmd)
r = pr_botmove();
if (r < 128)
{
TThinkerIterator<AActor> it (NAME_Inventory, MAX_STATNUM+1, bglobal.firstthing);
auto it = player->mo->Level->GetThinkerIterator<AActor>(NAME_Inventory, MAX_STATNUM+1, bglobal.firstthing);
auto item = it.Next();
if (item != NULL || (item = it.Next()) != NULL)

View File

@ -2697,7 +2697,7 @@ static void RunScript(uint8_t **stream, AActor *pawn, int snum, int argn, int al
arg[i] = argval;
}
}
P_StartScript(pawn, NULL, snum, level.MapName, arg, MIN<int>(countof(arg), argn), ACS_NET | always);
P_StartScript(pawn->Level, pawn, NULL, snum, level.MapName, arg, MIN<int>(countof(arg), argn), ACS_NET | always);
}
void Net_SkipCommand (int type, uint8_t **stream)

View File

@ -560,7 +560,7 @@ void FParser::SF_Include(void)
else
mysnprintf(tempstr, countof(tempstr), "%i", (int)t_argv[0].value.i);
Script->ParseInclude(tempstr);
Script->ParseInclude(Level, tempstr);
}
}

View File

@ -333,13 +333,13 @@ char *DFsScript::ProcessFindChar(char *datap, char find)
//
//==========================================================================
void DFsScript::DryRunScript()
void DFsScript::DryRunScript(FLevelLocals *Level)
{
char *end = data + len;
char *rover = data;
// allocate space for the tokens
FParser parse(&level, this);
FParser parse(Level, this);
try
{
while(rover < end && *rover)
@ -387,11 +387,11 @@ void DFsScript::DryRunScript()
//
//==========================================================================
void DFsScript::Preprocess()
void DFsScript::Preprocess(FLevelLocals *Level)
{
len = (int)strlen(data);
ProcessFindChar(data, 0); // fill in everything
DryRunScript();
DryRunScript(Level);
}
//==========================================================================
@ -406,7 +406,7 @@ void DFsScript::Preprocess()
//
//==========================================================================
void DFsScript::ParseInclude(char *lumpname)
void DFsScript::ParseInclude(FLevelLocals *Level, char *lumpname)
{
int lumpnum;
char *lump;
@ -429,7 +429,7 @@ void DFsScript::ParseInclude(char *lumpname)
ProcessFindChar(lump, 0);
// now parse the lump
FParser parse(&level, this);
FParser parse(Level, this);
parse.Run(lump, lump, lump+lumplen);
// free the lump

View File

@ -196,7 +196,7 @@ void DFsScript::Serialize(FSerializer &arc)
//
//==========================================================================
void DFsScript::ParseScript(char *position, AActor **pTrigger)
void DFsScript::ParseScript(char *position, DFraggleThinker *th)
{
if (position == nullptr)
{
@ -211,11 +211,11 @@ void DFsScript::ParseScript(char *position, AActor **pTrigger)
return;
}
*pTrigger = trigger; // set trigger variable.
th->trigger_obj = trigger; // set trigger variable.
try
{
FParser parse(&level, this);
FParser parse(th->Level, this);
parse.Run(position, data, data + len);
}
catch (CFraggleScriptError &err)
@ -528,7 +528,7 @@ void DFraggleThinker::Tick()
next = current->next; // save before freeing
// continue the script
current->script->ParseScript (current->script->data + current->save_point, &trigger_obj);
current->script->ParseScript (current->script->data + current->save_point, this);
// free
current->Destroy();
@ -618,8 +618,8 @@ void T_PreprocessScripts(FLevelLocals *Level)
// levelscript started by player 0 'superplayer'
th->LevelScript->trigger = players[0].mo;
th->LevelScript->Preprocess();
th->LevelScript->ParseScript(nullptr, &th->trigger_obj);
th->LevelScript->Preprocess(Level);
th->LevelScript->ParseScript(nullptr, th);
}
}
@ -667,6 +667,6 @@ CCMD(fpuke)
}
else
{
T_RunScript(&level, atoi(argv[1]), players[consoleplayer].mo);
T_RunScript(currentUILevel, atoi(argv[1]), players[consoleplayer].mo);
}
}

View File

@ -35,6 +35,8 @@
#pragma pointers_to_members( full_generality, single_inheritance )
#endif
class DFraggleThinker;
class CFraggleScriptError : public CDoomError
{
@ -360,10 +362,10 @@ public:
DFsSection *FindSectionStart(const char *brace);
DFsSection *FindSectionEnd(const char *brace);
char *ProcessFindChar(char *data, char find);
void DryRunScript();
void Preprocess();
void ParseInclude(char *lumpname);
void ParseScript(char *rover, AActor **pTrigger);
void DryRunScript(FLevelLocals *Level);
void Preprocess(FLevelLocals *Level);
void ParseInclude(FLevelLocals *Level, char *lumpname);
void ParseScript(char *rover, DFraggleThinker *th);
void ParseData(char *rover, char *data, char *end);
};

View File

@ -429,7 +429,7 @@ void FParser::spec_script()
newscript->parent = Script; // remember parent
// preprocess the newscript now
newscript->Preprocess();
newscript->Preprocess(Level);
// we dont want to run the newscript, only add it
// jump past the newscript in parsing

View File

@ -2012,11 +2012,11 @@ void FLevelLocals::AddScroller (int secnum)
void FLevelLocals::SetInterMusic(const char *nextmap)
{
auto mus = level.info->MapInterMusic.CheckKey(nextmap);
auto mus = info->MapInterMusic.CheckKey(nextmap);
if (mus != nullptr)
S_ChangeMusic(mus->first, mus->second);
else if (level.info->InterMusic.IsNotEmpty())
S_ChangeMusic(level.info->InterMusic, level.info->intermusicorder);
else if (info->InterMusic.IsNotEmpty())
S_ChangeMusic(info->InterMusic, info->intermusicorder);
else
S_ChangeMusic(gameinfo.intermissionMusic.GetChars(), gameinfo.intermissionOrder);
}

View File

@ -286,6 +286,10 @@ public:
if (subtype == NAME_None) return TThinkerIterator<T>(statnum);
else return TThinkerIterator<T>(subtype, statnum);
}
template<class T> TThinkerIterator<T> GetThinkerIterator(FName subtype, int statnum, AActor *prev)
{
return TThinkerIterator<T>(subtype, statnum, prev);
}
FActorIterator GetActorIterator(int tid)
{
return FActorIterator(TIDHash, tid);
@ -524,7 +528,8 @@ extern FLevelLocals *currentUILevel; // level for which to display the user inte
inline FSectorPortal *line_t::GetTransferredPortal()
{
return portaltransferred >= level.sectorPortals.Size() ? (FSectorPortal*)nullptr : &level.sectorPortals[portaltransferred];
auto Level = GetLevel();
return portaltransferred >= Level->sectorPortals.Size() ? (FSectorPortal*)nullptr : &Level->sectorPortals[portaltransferred];
}
inline FSectorPortal *sector_t::GetPortal(int plane)
@ -580,7 +585,7 @@ inline bool sector_t::PortalIsLinked(int plane)
inline FLevelLocals *line_t::GetLevel() const
{
return &level;
return frontsector->Level;
}
inline FLinePortal *line_t::getPortal() const
{

View File

@ -407,7 +407,7 @@ void DBaseDecal::SpreadLeft (double r, vertex_t *v1, side_t *feelwall, F3DFloor
double x = v1->fX();
double y = v1->fY();
feelwall = &level.sides[feelwall->LeftSide];
feelwall = &feelwall->GetLevel()->sides[feelwall->LeftSide];
GetWallStuff (feelwall, v1, ldx, ldy);
double wallsize = Length (ldx, ldy);
r += spread->DecalLeft;
@ -447,7 +447,7 @@ void DBaseDecal::SpreadRight (double r, side_t *feelwall, double wallsize, F3DFl
while (r > wallsize && feelwall->RightSide != NO_SIDE)
{
feelwall = &level.sides[feelwall->RightSide];
feelwall = &feelwall->GetLevel()->sides[feelwall->RightSide];
side_t *nextwall = NextWall (feelwall);
if (nextwall != NULL && nextwall->LeftSide != NO_SIDE)

View File

@ -196,9 +196,9 @@ void DLightningThinker::ForceLightning (int mode)
}
}
static DLightningThinker *LocateLightning ()
static DLightningThinker *LocateLightning (FLevelLocals *Level)
{
TThinkerIterator<DLightningThinker> iterator (STAT_LIGHTNING);
auto iterator = Level->GetThinkerIterator<DLightningThinker>(NAME_None, STAT_LIGHTNING);
return iterator.Next ();
}
@ -230,7 +230,7 @@ void FLevelLocals::StartLightning ()
}
}
DLightningThinker *lightning = LocateLightning ();
DLightningThinker *lightning = LocateLightning (this);
if (lightning == nullptr)
{
CreateThinker<DLightningThinker>();
@ -239,7 +239,7 @@ void FLevelLocals::StartLightning ()
void FLevelLocals::ForceLightning (int mode)
{
DLightningThinker *lightning = LocateLightning ();
DLightningThinker *lightning = LocateLightning (this);
if (lightning == nullptr)
{
lightning = CreateThinker<DLightningThinker>();

View File

@ -288,7 +288,7 @@ int DEarthquake::StaticGetQuakeIntensities(double ticFrac, AActor *victim, FQuak
return 0;
}
TThinkerIterator<DEarthquake> iterator(STAT_EARTHQUAKE);
auto iterator = victim->Level->GetThinkerIterator<DEarthquake>(NAME_None, STAT_EARTHQUAKE);
DEarthquake *quake;
int count = 0;

View File

@ -788,7 +788,7 @@ void DBaseStatusBar::RefreshViewBorder ()
{
return;
}
auto tex = GetBorderTexture(&level);
auto tex = GetBorderTexture(currentUILevel);
screen->DrawBorder (tex, 0, 0, Width, viewwindowy);
screen->DrawBorder (tex, 0, viewwindowy, viewwindowx, viewheight + viewwindowy);
screen->DrawBorder (tex, viewwindowx + viewwidth, viewwindowy, Width, viewheight + viewwindowy);
@ -814,7 +814,7 @@ void DBaseStatusBar::RefreshBackground () const
if (x == 0 && y == SCREENHEIGHT) return;
auto tex = GetBorderTexture(&level);
auto tex = GetBorderTexture(currentUILevel);
if(!CompleteBorder)
{

View File

@ -254,7 +254,7 @@ sector_t *FGLRenderer::RenderView(player_t* player)
bool saved_niv = NoInterpolateView;
NoInterpolateView = false;
// prepare all camera textures that have been used in the last frame
auto Level = &level;
auto Level = r_viewpoint.ViewLevel;
gl_RenderState.CheckTimer(Level->ShaderStartTime);
Level->canvasTextureInfo.UpdateAll([&](AActor *camera, FCanvasTexture *camtex, double fov)
{

View File

@ -351,6 +351,10 @@ void MapLoader::PO_Init (void)
InitSideLists ();
Level->Polyobjects.Resize(NumPolyobjs);
for (auto p : Level->Polyobjects)
{
p.Level = Level;
}
polyIndex = 0; // index polyobj number
// Find the startSpot points, and spawn each polyobj

View File

@ -54,17 +54,17 @@ const int AAPreference = 16;
#define D(x) do{}while(0)
#endif
FNodeBuilder::FNodeBuilder(FLevel &level)
: Level(level), GLNodes(false), SegsStuffed(0)
FNodeBuilder::FNodeBuilder(FLevel &lev)
: Level(lev), GLNodes(false), SegsStuffed(0)
{
VertexMap = NULL;
OldVertexTable = NULL;
}
FNodeBuilder::FNodeBuilder (FLevel &level,
FNodeBuilder::FNodeBuilder (FLevel &lev,
TArray<FPolyStart> &polyspots, TArray<FPolyStart> &anchors,
bool makeGLNodes)
: Level(level), GLNodes(makeGLNodes), SegsStuffed(0)
: Level(lev), GLNodes(makeGLNodes), SegsStuffed(0)
{
VertexMap = new FVertexMap (*this, Level.MinX, Level.MinY, Level.MaxX, Level.MaxY);
FindUsedVertices (Level.Vertices, Level.NumVertices);

View File

@ -228,13 +228,13 @@ public:
fixed_t x, y;
};
FNodeBuilder (FLevel &level);
FNodeBuilder (FLevel &level,
FNodeBuilder (FLevel &lev);
FNodeBuilder (FLevel &lev,
TArray<FPolyStart> &polyspots, TArray<FPolyStart> &anchors,
bool makeGLNodes);
~FNodeBuilder ();
void Extract(FLevelLocals &level);
void Extract(FLevelLocals &lev);
const int *GetOldVertexTable();
// These are used for building sub-BSP trees for polyobjects.

View File

@ -6795,7 +6795,7 @@ int DLevelScript::RunScript()
case SCRIPT_PolyWait:
// Wait for polyobj(s) to stop moving, then enter state running
if (!PO_Busy (&level, statedata))
if (!PO_Busy (Level, statedata))
{
state = SCRIPT_Running;
}
@ -9908,7 +9908,7 @@ scriptwait:
int flags = STACK(1);
sp -= 5;
P_SectorDamage(&level, tag, amount, type, protectClass, flags);
P_SectorDamage(Level, tag, amount, type, protectClass, flags);
}
break;
@ -10354,14 +10354,14 @@ static void addDefered (level_info_t *i, acsdefered_t::EType type, int script, c
EXTERN_CVAR (Bool, sv_cheats)
int P_StartScript (AActor *who, line_t *where, int script, const char *map, const int *args, int argcount, int flags)
int P_StartScript (FLevelLocals *Level, AActor *who, line_t *where, int script, const char *map, const int *args, int argcount, int flags)
{
if (map == NULL || 0 == strnicmp (level.MapName, map, 8))
if (map == NULL || 0 == strnicmp (Level->MapName, map, 8))
{
FBehavior *module = NULL;
const ScriptPtr *scriptdata;
if ((scriptdata = level.Behaviors.FindScript (script, module)) != NULL)
if ((scriptdata = Level->Behaviors.FindScript (script, module)) != NULL)
{
if ((flags & ACS_NET) && netgame && !sv_cheats)
{
@ -10379,7 +10379,7 @@ int P_StartScript (AActor *who, line_t *where, int script, const char *map, cons
return false;
}
}
DLevelScript *runningScript = P_GetScriptGoing (&level, who, where, script,
DLevelScript *runningScript = P_GetScriptGoing (Level, who, where, script,
scriptdata, module, args, argcount, flags);
if (runningScript != NULL)
{
@ -10409,20 +10409,20 @@ int P_StartScript (AActor *who, line_t *where, int script, const char *map, cons
return false;
}
void P_SuspendScript (int script, const char *map)
void P_SuspendScript (FLevelLocals *Level, int script, const char *map)
{
if (strnicmp (level.MapName, map, 8))
if (strnicmp (Level->MapName, map, 8))
addDefered (FindLevelInfo (map), acsdefered_t::defsuspend, script, NULL, 0, NULL);
else
SetScriptState (level.ACSThinker, script, DLevelScript::SCRIPT_Suspended);
SetScriptState (Level->ACSThinker, script, DLevelScript::SCRIPT_Suspended);
}
void P_TerminateScript (int script, const char *map)
void P_TerminateScript (FLevelLocals *Level, int script, const char *map)
{
if (strnicmp (level.MapName, map, 8))
if (strnicmp (Level->MapName, map, 8))
addDefered (FindLevelInfo (map), acsdefered_t::defterminate, script, NULL, 0, NULL);
else
SetScriptState (level.ACSThinker, script, DLevelScript::SCRIPT_PleaseRemove);
SetScriptState (Level->ACSThinker, script, DLevelScript::SCRIPT_PleaseRemove);
}
FSerializer &Serialize(FSerializer &arc, const char *key, acsdefered_t &defer, acsdefered_t *def)

View File

@ -3049,7 +3049,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_Teleport)
}
}
DSpotState *state = GetSpotState(&level, false);
DSpotState *state = GetSpotState(self->Level, false);
if (state == NULL)
{
return numret;

View File

@ -739,7 +739,7 @@ void P_StartConversation (AActor *npc, AActor *pc, bool facetalker, bool saveang
// Make sure this is actually a player.
if (pc == nullptr || pc->player == nullptr || npc == nullptr) return;
auto Level = &level;
auto Level = pc->Level;
// [CW] If an NPC is talking to a PC already, then don't let
// anyone else talk to the NPC.
@ -887,7 +887,7 @@ static void HandleReply(player_t *player, bool isconsole, int nodenum, int reply
AActor *npc;
bool takestuff;
int i;
auto Level = &level;
auto Level = player->mo->Level;
if (player->ConversationNPC == nullptr || (unsigned)nodenum >= Level->StrifeDialogues.Size())
{
return;

View File

@ -1923,7 +1923,7 @@ FUNC(LS_ACS_Execute)
{
return false;
}
return P_StartScript(it, ln, arg0, mapname, args, 3, flags);
return P_StartScript(Level, it, ln, arg0, mapname, args, 3, flags);
}
FUNC(LS_ACS_ExecuteAlways)
@ -1946,7 +1946,7 @@ FUNC(LS_ACS_ExecuteAlways)
{
return false;
}
return P_StartScript(it, ln, arg0, mapname, args, 3, flags);
return P_StartScript(Level, it, ln, arg0, mapname, args, 3, flags);
}
FUNC(LS_ACS_LockedExecute)
@ -1976,7 +1976,7 @@ FUNC(LS_ACS_ExecuteWithResult)
int args[4] = { arg1, arg2, arg3, arg4 };
int flags = (backSide ? ACS_BACKSIDE : 0) | ACS_ALWAYS | ACS_WANTRESULT;
return P_StartScript (it, ln, arg0, Level->MapName, args, 4, flags);
return P_StartScript (Level, it, ln, arg0, Level->MapName, args, 4, flags);
}
FUNC(LS_ACS_Suspend)
@ -1985,9 +1985,9 @@ FUNC(LS_ACS_Suspend)
level_info_t *info;
if (arg1 == 0)
P_SuspendScript (arg0, Level->MapName);
P_SuspendScript (Level, arg0, Level->MapName);
else if ((info = FindLevelByNum (arg1)) )
P_SuspendScript (arg0, info->MapName);
P_SuspendScript (Level, arg0, info->MapName);
return true;
}
@ -1998,9 +1998,9 @@ FUNC(LS_ACS_Terminate)
level_info_t *info;
if (arg1 == 0)
P_TerminateScript (arg0, Level->MapName);
P_TerminateScript (Level, arg0, Level->MapName);
else if ((info = FindLevelByNum (arg1)) )
P_TerminateScript (arg0, info->MapName);
P_TerminateScript (Level, arg0, info->MapName);
return true;
}
@ -2016,7 +2016,7 @@ FUNC(LS_FS_Execute)
{
if (arg1 && ln && backSide) return false;
if (arg2!=0 && !P_CheckKeys(it, arg2, !!arg3)) return false;
return T_RunScript(&level, arg0, it);
return T_RunScript(Level, arg0, it);
}
@ -2251,7 +2251,7 @@ FUNC(LS_Sector_SetCurrent)
FUNC(LS_Sector_SetFriction)
// Sector_SetFriction (tag, amount)
{
P_SetSectorFriction (&level, arg0, arg1, true);
P_SetSectorFriction (Level, arg0, arg1, true);
return true;
}
@ -2310,7 +2310,7 @@ FUNC(LS_Scroll_Texture_Both)
sidechoice = 0;
}
SetWallScroller (&level, arg0, sidechoice, dx, dy, scw_all);
SetWallScroller (Level, arg0, sidechoice, dx, dy, scw_all);
return true;
}
@ -2321,7 +2321,7 @@ FUNC(LS_Scroll_Wall)
if (arg0 == 0)
return false;
SetWallScroller (&level, arg0, !!arg3, arg1 / 65536., arg2 / 65536., EScrollPos(arg4));
SetWallScroller (Level, arg0, !!arg3, arg1 / 65536., arg2 / 65536., EScrollPos(arg4));
return true;
}
@ -2337,19 +2337,19 @@ FUNC(LS_Scroll_Floor)
if (arg3 == 0 || arg3 == 2)
{
SetScroller (&level, arg0, EScroll::sc_floor, -dx, dy);
SetScroller (Level, arg0, EScroll::sc_floor, -dx, dy);
}
else
{
SetScroller (&level, arg0, EScroll::sc_floor, 0, 0);
SetScroller (Level, arg0, EScroll::sc_floor, 0, 0);
}
if (arg3 > 0)
{
SetScroller (&level, arg0, EScroll::sc_carry, dx, dy);
SetScroller (Level, arg0, EScroll::sc_carry, dx, dy);
}
else
{
SetScroller (&level, arg0, EScroll::sc_carry, 0, 0);
SetScroller (Level, arg0, EScroll::sc_carry, 0, 0);
}
return true;
}
@ -2360,7 +2360,7 @@ FUNC(LS_Scroll_Ceiling)
double dx = arg1 / 32.;
double dy = arg2 / 32.;
SetScroller (&level, arg0, EScroll::sc_ceiling, -dx, dy);
SetScroller (Level, arg0, EScroll::sc_ceiling, -dx, dy);
return true;
}

View File

@ -2928,7 +2928,7 @@ void FSlide::HitSlideLine(line_t* ld)
void FSlide::SlideTraverse(const DVector2 &start, const DVector2 &end)
{
FLineOpening open;
FPathTraverse it(&level, start.X, start.Y, end.X, end.Y, PT_ADDLINES);
FPathTraverse it(slidemo->Level, start.X, start.Y, end.X, end.Y, PT_ADDLINES);
intercept_t *in;
while ((in = it.Next()))
@ -3285,7 +3285,7 @@ const secplane_t * P_CheckSlopeWalk(AActor *actor, DVector2 &move)
bool FSlide::BounceTraverse(const DVector2 &start, const DVector2 &end)
{
FLineOpening open;
FPathTraverse it(&level, start.X, start.Y, end.X, end.Y, PT_ADDLINES);
FPathTraverse it(slidemo->Level, start.X, start.Y, end.X, end.Y, PT_ADDLINES);
intercept_t *in;
while ((in = it.Next()))
@ -3977,7 +3977,7 @@ struct aim_t
if (ceilingportalstate) EnterSectorPortal(sector_t::ceiling, 0, lastsector, toppitch, MIN<DAngle>(0., bottompitch));
if (floorportalstate) EnterSectorPortal(sector_t::floor, 0, lastsector, MAX<DAngle>(0., toppitch), bottompitch);
FPathTraverse it(&level, startpos.X, startpos.Y, aimtrace.X, aimtrace.Y, PT_ADDLINES | PT_ADDTHINGS | PT_COMPATIBLE | PT_DELTA, startfrac);
FPathTraverse it(lastsector->Level, startpos.X, startpos.Y, aimtrace.X, aimtrace.Y, PT_ADDLINES | PT_ADDTHINGS | PT_COMPATIBLE | PT_DELTA, startfrac);
intercept_t *in;
if (aimdebug)
@ -5376,7 +5376,7 @@ bool P_TalkFacing(AActor *player)
bool P_UseTraverse(AActor *usething, const DVector2 &start, const DVector2 &end, bool &foundline)
{
FPathTraverse it(&level, start.X, start.Y, end.X, end.Y, PT_ADDLINES | PT_ADDTHINGS);
FPathTraverse it(usething->Level, start.X, start.Y, end.X, end.Y, PT_ADDLINES | PT_ADDTHINGS);
intercept_t *in;
DVector3 xpos = { start.X, start.Y, usething->Z() };
@ -5519,7 +5519,7 @@ bool P_UseTraverse(AActor *usething, const DVector2 &start, const DVector2 &end,
bool P_NoWayTraverse(AActor *usething, const DVector2 &start, const DVector2 &end)
{
FPathTraverse it(&level, start.X, start.Y, end.X, end.Y, PT_ADDLINES);
FPathTraverse it(usething->Level, start.X, start.Y, end.X, end.Y, PT_ADDLINES);
intercept_t *in;
while ((in = it.Next()))
@ -5596,7 +5596,7 @@ int P_UsePuzzleItem(AActor *PuzzleItemUser, int PuzzleItemType)
start = PuzzleItemUser->GetPortalTransition(PuzzleItemUser->Height / 2);
end = PuzzleItemUser->Angles.Yaw.ToVector(usedist);
FPathTraverse it(&level, start.X, start.Y, end.X, end.Y, PT_DELTA | PT_ADDLINES | PT_ADDTHINGS);
FPathTraverse it(PuzzleItemUser->Level, start.X, start.Y, end.X, end.Y, PT_DELTA | PT_ADDLINES | PT_ADDTHINGS);
intercept_t *in;
while ((in = it.Next()))
@ -5624,7 +5624,7 @@ int P_UsePuzzleItem(AActor *PuzzleItemUser, int PuzzleItemType)
return false;
}
int args[3] = { in->d.line->args[2], in->d.line->args[3], in->d.line->args[4] };
P_StartScript(PuzzleItemUser, in->d.line, in->d.line->args[1], NULL, args, 3, ACS_ALWAYS);
P_StartScript(PuzzleItemUser->Level, PuzzleItemUser, in->d.line, in->d.line->args[1], NULL, args, 3, ACS_ALWAYS);
in->d.line->special = 0;
return true;
}
@ -5639,7 +5639,7 @@ int P_UsePuzzleItem(AActor *PuzzleItemUser, int PuzzleItemType)
continue;
}
int args[3] = { mobj->args[2], mobj->args[3], mobj->args[4] };
P_StartScript(PuzzleItemUser, NULL, mobj->args[1], NULL, args, 3, ACS_ALWAYS);
P_StartScript(PuzzleItemUser->Level, PuzzleItemUser, NULL, mobj->args[1], NULL, args, 3, ACS_ALWAYS);
mobj->special = 0;
return true;
}

View File

@ -143,7 +143,7 @@ static void PrecacheLevel(FLevelLocals *Level)
memset(hitlist.Data(), 0, cnt);
AActor *actor;
TThinkerIterator<AActor> iterator;
auto iterator = Level->GetThinkerIterator<AActor>();
while ((actor = iterator.Next()))
{
@ -485,7 +485,7 @@ void P_SetupLevel(FLevelLocals *Level, int position, bool newGame)
// Don't count monsters in end-of-level sectors if option is on
if (dmflags2 & DF2_NOCOUNTENDMONST)
{
TThinkerIterator<AActor> it;
auto it = Level->GetThinkerIterator<AActor>();
AActor * mo;
while ((mo = it.Next()))
@ -500,7 +500,7 @@ void P_SetupLevel(FLevelLocals *Level, int position, bool newGame)
}
}
T_PreprocessScripts(&level); // preprocess FraggleScript scripts
T_PreprocessScripts(Level); // preprocess FraggleScript scripts
// build subsector connect matrix
// UNUSED P_ConnectSubsectors ();
@ -513,8 +513,8 @@ void P_SetupLevel(FLevelLocals *Level, int position, bool newGame)
// preload graphics and sounds
if (precache)
{
PrecacheLevel(&level);
S_PrecacheLevel();
PrecacheLevel(Level);
S_PrecacheLevel(Level);
}
if (deathmatch)
@ -663,7 +663,7 @@ CUSTOM_CVAR(Bool, forcewater, false, CVAR_ARCHIVE | CVAR_SERVERINFO)
{
if (gamestate == GS_LEVEL)
{
auto Level = &level;
auto Level = currentUILevel;
for (auto &sec : Level->sectors)
{
sector_t *hsec = sec.GetHeightSec();

View File

@ -435,7 +435,7 @@ void P_PlayerInSpecialSector (player_t *player, sector_t * sector)
// Has hit ground.
AActor *ironfeet;
auto Level = &level;
auto Level = sector->Level;
// [RH] Apply any customizable damage
if (sector->damageamount > 0)
@ -630,7 +630,7 @@ DEFINE_ACTION_FUNCTION(FLevelLocals, GiveSecret)
void P_PlayerOnSpecialFlat (player_t *player, int floorType)
{
auto Level = &level;
auto Level = player->mo->Level;
if (Terrains[floorType].DamageAmount &&
!(Level->time & Terrains[floorType].DamageTimeMask))
@ -707,7 +707,6 @@ void DLightTransfer::Construct(sector_t *srcSec, int target, bool copyFloor)
CopyFloor = copyFloor;
DoTransfer (LastLight = srcSec->lightlevel, target, copyFloor);
auto Level = &level;
if (copyFloor)
{
auto itr = Level->GetSectorTagIterator(target);
@ -737,7 +736,6 @@ void DLightTransfer::DoTransfer (int llevel, int target, bool floor)
{
int secnum;
auto Level = &level;
if (floor)
{
auto itr = Level->GetSectorTagIterator(target);
@ -783,7 +781,6 @@ void DWallLightTransfer::Construct(sector_t *srcSec, int target, uint8_t flags)
wallflags = WALLF_ABSLIGHTING | WALLF_NOFAKECONTRAST;
}
auto Level = &level;
auto itr = Level->GetLineIdIterator(target);
while ((linenum = itr.Next()) >= 0)
{
@ -814,7 +811,6 @@ void DWallLightTransfer::DoTransfer (short lightlevel, int target, uint8_t flags
{
int linenum;
auto Level = &level;
auto itr = Level->GetLineIdIterator(target);
while ((linenum = itr.Next()) >= 0)
{

View File

@ -595,9 +595,9 @@ bool P_Teleport(AActor *thing, DVector3 pos, DAngle angle, int flags);
#define ACS_WANTRESULT 4
#define ACS_NET 8
int P_StartScript (AActor *who, line_t *where, int script, const char *map, const int *args, int argcount, int flags);
void P_SuspendScript (int script, const char *map);
void P_TerminateScript (int script, const char *map);
int P_StartScript (FLevelLocals *Level, AActor *who, line_t *where, int script, const char *map, const int *args, int argcount, int flags);
void P_SuspendScript (FLevelLocals *Level, int script, const char *map);
void P_TerminateScript (FLevelLocals *Level, int script, const char *map);
//
// [RH] p_quake.c

View File

@ -85,7 +85,7 @@ protected:
static bool P_StartButton (side_t *side, int Where, FSwitchDef *Switch, const DVector2 &pos, bool useagain)
{
DActiveButton *button;
TThinkerIterator<DActiveButton> iterator;
auto iterator = side->GetLevel()->GetThinkerIterator<DActiveButton>();
// See if button is already pressed
while ( (button = iterator.Next ()) )
@ -97,7 +97,7 @@ static bool P_StartButton (side_t *side, int Where, FSwitchDef *Switch, const DV
}
}
side->sector->Level->CreateThinker<DActiveButton> (side, Where, Switch, pos, useagain);
side->GetLevel()->CreateThinker<DActiveButton> (side, Where, Switch, pos, useagain);
return true;
}

View File

@ -316,7 +316,7 @@ AActor *FLevelLocals::SelectTeleDest (int tid, int tag, bool norandom)
// teleport destination. This means if 50 sectors have a matching tag and
// only the last one has a destination, *every* actor is scanned at least 49
// times. Yuck.
TThinkerIterator<AActor> it2(NAME_TeleportDest);
auto it2 = GetThinkerIterator<AActor>(NAME_TeleportDest);
while ((searcher = it2.Next()) != NULL)
{
if (searcher->Sector == &sectors[secnum])

View File

@ -754,7 +754,7 @@ int P_Thing_CheckProximity(AActor *self, PClass *classname, double distance, int
const bool ptrWillChange = !!(flags & (CPXF_SETTARGET | CPXF_SETMASTER | CPXF_SETTRACER));
const bool ptrDistPref = !!(flags & (CPXF_CLOSEST | CPXF_FARTHEST));
TThinkerIterator<AActor> it;
auto it = self->Level->GetThinkerIterator<AActor>();
AActor *mo, *dist = nullptr;
// [MC] Process of elimination, I think, will get through this as quickly and

View File

@ -741,11 +741,6 @@ int FPolyObj::GetMirror()
return MirrorNum;
}
FLevelLocals *FPolyObj::GetLevel() const
{
return &level;
}
//==========================================================================
//
// ThrustMobj
@ -756,7 +751,6 @@ void FPolyObj::ThrustMobj (AActor *actor, side_t *side)
{
DAngle thrustAngle;
DPolyAction *pe;
auto Level = GetLevel();
double force;
@ -811,7 +805,6 @@ void FPolyObj::UpdateLinks()
{
if (bHasPortals == 2)
{
auto Level = GetLevel();
TMap<int, bool> processed;
for (unsigned i = 0; i < Linedefs.Size(); i++)
{
@ -1000,7 +993,6 @@ void FPolyObj::UnLinkPolyobj ()
polyblock_t *link;
int i, j;
int index;
auto Level = GetLevel();
// remove the polyobj from each blockmap section
for(j = bbox[BOXBOTTOM]; j <= bbox[BOXTOP]; j++)
@ -1033,7 +1025,6 @@ void FPolyObj::UnLinkPolyobj ()
bool FPolyObj::CheckMobjBlocking (side_t *sd)
{
auto Level = GetLevel();
static TArray<AActor *> checker;
FBlockNode *block;
AActor *mobj;
@ -1169,7 +1160,6 @@ void FPolyObj::LinkPolyobj ()
{
polyblock_t **link;
polyblock_t *tempLink;
auto Level = GetLevel();
int bmapwidth = Level->blockmap.bmapwidth;
int bmapheight = Level->blockmap.bmapheight;
@ -1666,7 +1656,6 @@ static void SplitPoly(FPolyNode *pnode, void *node, float bbox[4])
void FPolyObj::CreateSubsectorLinks()
{
auto Level = GetLevel();
FPolyNode *node = NewPolyNode();
// Even though we don't care about it, we need to initialize this
// bounding box to something so that Valgrind won't complain about it
@ -1846,7 +1835,7 @@ FPolyObj *FPolyMirrorIterator::NextMirror()
if (i == NumUsedPolys)
{ // No, it has not been returned.
UsedPolys[NumUsedPolys++] = mirror;
nextpoly = poly->GetLevel()->GetPolyobj(mirror);
nextpoly = poly->Level->GetPolyobj(mirror);
if (nextpoly == nullptr)
{
Printf("Invalid mirror polyobj num %d for polyobj num %d\n", mirror, UsedPolys[i - 1]);

View File

@ -67,6 +67,7 @@ struct FPolyNode
// ===== Polyobj data =====
struct FPolyObj
{
FLevelLocals *Level;
TArray<side_t *> Sidedefs;
TArray<line_t *> Linedefs;
TArray<vertex_t *> Vertices;
@ -108,9 +109,6 @@ struct FPolyObj
void UpdateLinks();
static void ClearAllSubsectorLinks();
FLevelLocals *GetLevel() const;
private:
void ThrustMobj (AActor *actor, side_t *side);

View File

@ -136,7 +136,7 @@ void PolyRenderer::RenderActorView(AActor *actor, bool dontmaplines)
R_SetupFrame(Viewpoint, Viewwindow, actor);
Level = Viewpoint.ViewLevel;
P_FindParticleSubsectors();
PO_LinkToSubsectors(&level);
PO_LinkToSubsectors(Level);
static bool firstcall = true;
if (firstcall)

View File

@ -1034,7 +1034,7 @@ void R_SetupFrame (FRenderViewpoint &viewpoint, FViewWindow &viewwindow, AActor
viewpoint.HWAngles.Pitch = RAD2DEG((float)asin(angy / alen));
viewpoint.HWAngles.Roll.Degrees = (float)viewpoint.Angles.Roll.Degrees; // copied for convenience.
viewpoint.ViewLevel = &level;
viewpoint.ViewLevel = actor->Level;
// ViewActor only gets set, if the camera actor should not be rendered
if (actor->player && actor->player - players == consoleplayer &&

View File

@ -471,11 +471,11 @@ void S_Start ()
//
//==========================================================================
void S_PrecacheLevel ()
void S_PrecacheLevel (FLevelLocals *Level)
{
unsigned int i;
if (GSnd)
if (GSnd && Level == currentUILevel)
{
for (i = 0; i < S_sfx.Size(); ++i)
{
@ -483,7 +483,7 @@ void S_PrecacheLevel ()
}
AActor *actor;
TThinkerIterator<AActor> iterator;
auto iterator = Level->GetThinkerIterator<AActor>();
// Precache all sounds known to be used by the currently spawned actors.
while ( (actor = iterator.Next()) != NULL )
@ -1371,7 +1371,7 @@ void S_SoundMinMaxDist(AActor *ent, int channel, FSoundID sound_id, float volume
void S_Sound (const FPolyObj *poly, int channel, FSoundID sound_id, float volume, float attenuation)
{
if (poly->GetLevel() != currentUILevel) return;
if (poly->Level != currentUILevel) return;
S_StartSound (nullptr, nullptr, poly, nullptr, channel, sound_id, volume, attenuation);
}

View File

@ -218,7 +218,7 @@ void S_Shutdown ();
void S_Start ();
// Called after a level is loaded. Ensures that most sounds are loaded.
void S_PrecacheLevel ();
void S_PrecacheLevel (FLevelLocals *l);
// Loads a sound, including any random sounds it might reference.
void S_CacheSound (sfxinfo_t *sfx);

View File

@ -1330,7 +1330,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(AActor, CheckSight, P_CheckSight)
static void GiveSecret(AActor *self, bool printmessage, bool playsound)
{
P_GiveSecret(&level, self, printmessage, playsound, -1);
P_GiveSecret(self->Level, self, printmessage, playsound, -1);
}
DEFINE_ACTION_FUNCTION_NATIVE(AActor, GiveSecret, GiveSecret)

View File

@ -577,7 +577,7 @@ FString GetStatString()
CCMD(printstats)
{
StoreLevelStats(&level); // Refresh the current level's results.
StoreLevelStats(currentUILevel); // Refresh the current level's results.
Printf("%s", GetStatString().GetChars());
}
@ -596,6 +596,6 @@ CCMD(finishgame)
ADD_STAT(statistics)
{
StoreLevelStats(&level); // Refresh the current level's results.
StoreLevelStats(currentUILevel); // Refresh the current level's results.
return GetStatString();
}