- 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; mpoint_t p;
DAngle angle; DAngle angle;
TThinkerIterator<AActor> it(NAME_Key); auto it = Level->GetThinkerIterator<AActor>(NAME_Key);
AActor *key; AActor *key;
while ((key = it.Next()) != nullptr) while ((key = it.Next()) != nullptr)

View file

@ -73,7 +73,7 @@ bool DBot::Reachable (AActor *rtarget)
double estimated_dist = player->mo->Distance2D(rtarget); double estimated_dist = player->mo->Distance2D(rtarget);
bool reachable = true; 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; intercept_t *in;
while ((in = it.Next())) while ((in = it.Next()))
{ {

View file

@ -289,7 +289,7 @@ void DBot::ThinkForMove (ticcmd_t *cmd)
r = pr_botmove(); r = pr_botmove();
if (r < 128) 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(); auto item = it.Next();
if (item != NULL || (item = it.Next()) != NULL) 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; 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) void Net_SkipCommand (int type, uint8_t **stream)

View file

@ -560,7 +560,7 @@ void FParser::SF_Include(void)
else else
mysnprintf(tempstr, countof(tempstr), "%i", (int)t_argv[0].value.i); 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 *end = data + len;
char *rover = data; char *rover = data;
// allocate space for the tokens // allocate space for the tokens
FParser parse(&level, this); FParser parse(Level, this);
try try
{ {
while(rover < end && *rover) while(rover < end && *rover)
@ -387,11 +387,11 @@ void DFsScript::DryRunScript()
// //
//========================================================================== //==========================================================================
void DFsScript::Preprocess() void DFsScript::Preprocess(FLevelLocals *Level)
{ {
len = (int)strlen(data); len = (int)strlen(data);
ProcessFindChar(data, 0); // fill in everything 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; int lumpnum;
char *lump; char *lump;
@ -429,7 +429,7 @@ void DFsScript::ParseInclude(char *lumpname)
ProcessFindChar(lump, 0); ProcessFindChar(lump, 0);
// now parse the lump // now parse the lump
FParser parse(&level, this); FParser parse(Level, this);
parse.Run(lump, lump, lump+lumplen); parse.Run(lump, lump, lump+lumplen);
// free the lump // 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) if (position == nullptr)
{ {
@ -211,11 +211,11 @@ void DFsScript::ParseScript(char *position, AActor **pTrigger)
return; return;
} }
*pTrigger = trigger; // set trigger variable. th->trigger_obj = trigger; // set trigger variable.
try try
{ {
FParser parse(&level, this); FParser parse(th->Level, this);
parse.Run(position, data, data + len); parse.Run(position, data, data + len);
} }
catch (CFraggleScriptError &err) catch (CFraggleScriptError &err)
@ -528,7 +528,7 @@ void DFraggleThinker::Tick()
next = current->next; // save before freeing next = current->next; // save before freeing
// continue the script // 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 // free
current->Destroy(); current->Destroy();
@ -618,8 +618,8 @@ void T_PreprocessScripts(FLevelLocals *Level)
// levelscript started by player 0 'superplayer' // levelscript started by player 0 'superplayer'
th->LevelScript->trigger = players[0].mo; th->LevelScript->trigger = players[0].mo;
th->LevelScript->Preprocess(); th->LevelScript->Preprocess(Level);
th->LevelScript->ParseScript(nullptr, &th->trigger_obj); th->LevelScript->ParseScript(nullptr, th);
} }
} }
@ -667,6 +667,6 @@ CCMD(fpuke)
} }
else 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 ) #pragma pointers_to_members( full_generality, single_inheritance )
#endif #endif
class DFraggleThinker;
class CFraggleScriptError : public CDoomError class CFraggleScriptError : public CDoomError
{ {
@ -360,10 +362,10 @@ public:
DFsSection *FindSectionStart(const char *brace); DFsSection *FindSectionStart(const char *brace);
DFsSection *FindSectionEnd(const char *brace); DFsSection *FindSectionEnd(const char *brace);
char *ProcessFindChar(char *data, char find); char *ProcessFindChar(char *data, char find);
void DryRunScript(); void DryRunScript(FLevelLocals *Level);
void Preprocess(); void Preprocess(FLevelLocals *Level);
void ParseInclude(char *lumpname); void ParseInclude(FLevelLocals *Level, char *lumpname);
void ParseScript(char *rover, AActor **pTrigger); void ParseScript(char *rover, DFraggleThinker *th);
void ParseData(char *rover, char *data, char *end); void ParseData(char *rover, char *data, char *end);
}; };

View file

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

View file

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

View file

@ -286,6 +286,10 @@ public:
if (subtype == NAME_None) return TThinkerIterator<T>(statnum); if (subtype == NAME_None) return TThinkerIterator<T>(statnum);
else return TThinkerIterator<T>(subtype, 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) FActorIterator GetActorIterator(int tid)
{ {
return FActorIterator(TIDHash, 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() 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) inline FSectorPortal *sector_t::GetPortal(int plane)
@ -580,7 +585,7 @@ inline bool sector_t::PortalIsLinked(int plane)
inline FLevelLocals *line_t::GetLevel() const inline FLevelLocals *line_t::GetLevel() const
{ {
return &level; return frontsector->Level;
} }
inline FLinePortal *line_t::getPortal() const 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 x = v1->fX();
double y = v1->fY(); double y = v1->fY();
feelwall = &level.sides[feelwall->LeftSide]; feelwall = &feelwall->GetLevel()->sides[feelwall->LeftSide];
GetWallStuff (feelwall, v1, ldx, ldy); GetWallStuff (feelwall, v1, ldx, ldy);
double wallsize = Length (ldx, ldy); double wallsize = Length (ldx, ldy);
r += spread->DecalLeft; 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) while (r > wallsize && feelwall->RightSide != NO_SIDE)
{ {
feelwall = &level.sides[feelwall->RightSide]; feelwall = &feelwall->GetLevel()->sides[feelwall->RightSide];
side_t *nextwall = NextWall (feelwall); side_t *nextwall = NextWall (feelwall);
if (nextwall != NULL && nextwall->LeftSide != NO_SIDE) 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 (); return iterator.Next ();
} }
@ -230,7 +230,7 @@ void FLevelLocals::StartLightning ()
} }
} }
DLightningThinker *lightning = LocateLightning (); DLightningThinker *lightning = LocateLightning (this);
if (lightning == nullptr) if (lightning == nullptr)
{ {
CreateThinker<DLightningThinker>(); CreateThinker<DLightningThinker>();
@ -239,7 +239,7 @@ void FLevelLocals::StartLightning ()
void FLevelLocals::ForceLightning (int mode) void FLevelLocals::ForceLightning (int mode)
{ {
DLightningThinker *lightning = LocateLightning (); DLightningThinker *lightning = LocateLightning (this);
if (lightning == nullptr) if (lightning == nullptr)
{ {
lightning = CreateThinker<DLightningThinker>(); lightning = CreateThinker<DLightningThinker>();

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -6795,7 +6795,7 @@ int DLevelScript::RunScript()
case SCRIPT_PolyWait: case SCRIPT_PolyWait:
// Wait for polyobj(s) to stop moving, then enter state running // Wait for polyobj(s) to stop moving, then enter state running
if (!PO_Busy (&level, statedata)) if (!PO_Busy (Level, statedata))
{ {
state = SCRIPT_Running; state = SCRIPT_Running;
} }
@ -9908,7 +9908,7 @@ scriptwait:
int flags = STACK(1); int flags = STACK(1);
sp -= 5; sp -= 5;
P_SectorDamage(&level, tag, amount, type, protectClass, flags); P_SectorDamage(Level, tag, amount, type, protectClass, flags);
} }
break; break;
@ -10354,14 +10354,14 @@ static void addDefered (level_info_t *i, acsdefered_t::EType type, int script, c
EXTERN_CVAR (Bool, sv_cheats) 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; FBehavior *module = NULL;
const ScriptPtr *scriptdata; 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) 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; return false;
} }
} }
DLevelScript *runningScript = P_GetScriptGoing (&level, who, where, script, DLevelScript *runningScript = P_GetScriptGoing (Level, who, where, script,
scriptdata, module, args, argcount, flags); scriptdata, module, args, argcount, flags);
if (runningScript != NULL) if (runningScript != NULL)
{ {
@ -10409,20 +10409,20 @@ int P_StartScript (AActor *who, line_t *where, int script, const char *map, cons
return false; 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); addDefered (FindLevelInfo (map), acsdefered_t::defsuspend, script, NULL, 0, NULL);
else 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); addDefered (FindLevelInfo (map), acsdefered_t::defterminate, script, NULL, 0, NULL);
else 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) 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) if (state == NULL)
{ {
return numret; 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. // Make sure this is actually a player.
if (pc == nullptr || pc->player == nullptr || npc == nullptr) return; 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 // [CW] If an NPC is talking to a PC already, then don't let
// anyone else talk to the NPC. // anyone else talk to the NPC.
@ -887,7 +887,7 @@ static void HandleReply(player_t *player, bool isconsole, int nodenum, int reply
AActor *npc; AActor *npc;
bool takestuff; bool takestuff;
int i; int i;
auto Level = &level; auto Level = player->mo->Level;
if (player->ConversationNPC == nullptr || (unsigned)nodenum >= Level->StrifeDialogues.Size()) if (player->ConversationNPC == nullptr || (unsigned)nodenum >= Level->StrifeDialogues.Size())
{ {
return; return;

View file

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

View file

@ -2928,7 +2928,7 @@ void FSlide::HitSlideLine(line_t* ld)
void FSlide::SlideTraverse(const DVector2 &start, const DVector2 &end) void FSlide::SlideTraverse(const DVector2 &start, const DVector2 &end)
{ {
FLineOpening open; 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; intercept_t *in;
while ((in = it.Next())) 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) bool FSlide::BounceTraverse(const DVector2 &start, const DVector2 &end)
{ {
FLineOpening open; 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; intercept_t *in;
while ((in = it.Next())) 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 (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); 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; intercept_t *in;
if (aimdebug) if (aimdebug)
@ -5376,7 +5376,7 @@ bool P_TalkFacing(AActor *player)
bool P_UseTraverse(AActor *usething, const DVector2 &start, const DVector2 &end, bool &foundline) 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; intercept_t *in;
DVector3 xpos = { start.X, start.Y, usething->Z() }; 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) 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; intercept_t *in;
while ((in = it.Next())) while ((in = it.Next()))
@ -5596,7 +5596,7 @@ int P_UsePuzzleItem(AActor *PuzzleItemUser, int PuzzleItemType)
start = PuzzleItemUser->GetPortalTransition(PuzzleItemUser->Height / 2); start = PuzzleItemUser->GetPortalTransition(PuzzleItemUser->Height / 2);
end = PuzzleItemUser->Angles.Yaw.ToVector(usedist); 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; intercept_t *in;
while ((in = it.Next())) while ((in = it.Next()))
@ -5624,7 +5624,7 @@ int P_UsePuzzleItem(AActor *PuzzleItemUser, int PuzzleItemType)
return false; return false;
} }
int args[3] = { in->d.line->args[2], in->d.line->args[3], in->d.line->args[4] }; 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; in->d.line->special = 0;
return true; return true;
} }
@ -5639,7 +5639,7 @@ int P_UsePuzzleItem(AActor *PuzzleItemUser, int PuzzleItemType)
continue; continue;
} }
int args[3] = { mobj->args[2], mobj->args[3], mobj->args[4] }; 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; mobj->special = 0;
return true; return true;
} }

View file

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

View file

@ -435,7 +435,7 @@ void P_PlayerInSpecialSector (player_t *player, sector_t * sector)
// Has hit ground. // Has hit ground.
AActor *ironfeet; AActor *ironfeet;
auto Level = &level; auto Level = sector->Level;
// [RH] Apply any customizable damage // [RH] Apply any customizable damage
if (sector->damageamount > 0) if (sector->damageamount > 0)
@ -630,7 +630,7 @@ DEFINE_ACTION_FUNCTION(FLevelLocals, GiveSecret)
void P_PlayerOnSpecialFlat (player_t *player, int floorType) void P_PlayerOnSpecialFlat (player_t *player, int floorType)
{ {
auto Level = &level; auto Level = player->mo->Level;
if (Terrains[floorType].DamageAmount && if (Terrains[floorType].DamageAmount &&
!(Level->time & Terrains[floorType].DamageTimeMask)) !(Level->time & Terrains[floorType].DamageTimeMask))
@ -707,7 +707,6 @@ void DLightTransfer::Construct(sector_t *srcSec, int target, bool copyFloor)
CopyFloor = copyFloor; CopyFloor = copyFloor;
DoTransfer (LastLight = srcSec->lightlevel, target, copyFloor); DoTransfer (LastLight = srcSec->lightlevel, target, copyFloor);
auto Level = &level;
if (copyFloor) if (copyFloor)
{ {
auto itr = Level->GetSectorTagIterator(target); auto itr = Level->GetSectorTagIterator(target);
@ -737,7 +736,6 @@ void DLightTransfer::DoTransfer (int llevel, int target, bool floor)
{ {
int secnum; int secnum;
auto Level = &level;
if (floor) if (floor)
{ {
auto itr = Level->GetSectorTagIterator(target); 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; wallflags = WALLF_ABSLIGHTING | WALLF_NOFAKECONTRAST;
} }
auto Level = &level;
auto itr = Level->GetLineIdIterator(target); auto itr = Level->GetLineIdIterator(target);
while ((linenum = itr.Next()) >= 0) while ((linenum = itr.Next()) >= 0)
{ {
@ -814,7 +811,6 @@ void DWallLightTransfer::DoTransfer (short lightlevel, int target, uint8_t flags
{ {
int linenum; int linenum;
auto Level = &level;
auto itr = Level->GetLineIdIterator(target); auto itr = Level->GetLineIdIterator(target);
while ((linenum = itr.Next()) >= 0) 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_WANTRESULT 4
#define ACS_NET 8 #define ACS_NET 8
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);
void P_SuspendScript (int script, const char *map); void P_SuspendScript (FLevelLocals *Level, int script, const char *map);
void P_TerminateScript (int script, const char *map); void P_TerminateScript (FLevelLocals *Level, int script, const char *map);
// //
// [RH] p_quake.c // [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) static bool P_StartButton (side_t *side, int Where, FSwitchDef *Switch, const DVector2 &pos, bool useagain)
{ {
DActiveButton *button; DActiveButton *button;
TThinkerIterator<DActiveButton> iterator; auto iterator = side->GetLevel()->GetThinkerIterator<DActiveButton>();
// See if button is already pressed // See if button is already pressed
while ( (button = iterator.Next ()) ) 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; 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 // 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 // only the last one has a destination, *every* actor is scanned at least 49
// times. Yuck. // times. Yuck.
TThinkerIterator<AActor> it2(NAME_TeleportDest); auto it2 = GetThinkerIterator<AActor>(NAME_TeleportDest);
while ((searcher = it2.Next()) != NULL) while ((searcher = it2.Next()) != NULL)
{ {
if (searcher->Sector == &sectors[secnum]) 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 ptrWillChange = !!(flags & (CPXF_SETTARGET | CPXF_SETMASTER | CPXF_SETTRACER));
const bool ptrDistPref = !!(flags & (CPXF_CLOSEST | CPXF_FARTHEST)); const bool ptrDistPref = !!(flags & (CPXF_CLOSEST | CPXF_FARTHEST));
TThinkerIterator<AActor> it; auto it = self->Level->GetThinkerIterator<AActor>();
AActor *mo, *dist = nullptr; AActor *mo, *dist = nullptr;
// [MC] Process of elimination, I think, will get through this as quickly and // [MC] Process of elimination, I think, will get through this as quickly and

View file

@ -741,11 +741,6 @@ int FPolyObj::GetMirror()
return MirrorNum; return MirrorNum;
} }
FLevelLocals *FPolyObj::GetLevel() const
{
return &level;
}
//========================================================================== //==========================================================================
// //
// ThrustMobj // ThrustMobj
@ -756,7 +751,6 @@ void FPolyObj::ThrustMobj (AActor *actor, side_t *side)
{ {
DAngle thrustAngle; DAngle thrustAngle;
DPolyAction *pe; DPolyAction *pe;
auto Level = GetLevel();
double force; double force;
@ -811,7 +805,6 @@ void FPolyObj::UpdateLinks()
{ {
if (bHasPortals == 2) if (bHasPortals == 2)
{ {
auto Level = GetLevel();
TMap<int, bool> processed; TMap<int, bool> processed;
for (unsigned i = 0; i < Linedefs.Size(); i++) for (unsigned i = 0; i < Linedefs.Size(); i++)
{ {
@ -1000,7 +993,6 @@ void FPolyObj::UnLinkPolyobj ()
polyblock_t *link; polyblock_t *link;
int i, j; int i, j;
int index; int index;
auto Level = GetLevel();
// remove the polyobj from each blockmap section // remove the polyobj from each blockmap section
for(j = bbox[BOXBOTTOM]; j <= bbox[BOXTOP]; j++) for(j = bbox[BOXBOTTOM]; j <= bbox[BOXTOP]; j++)
@ -1033,7 +1025,6 @@ void FPolyObj::UnLinkPolyobj ()
bool FPolyObj::CheckMobjBlocking (side_t *sd) bool FPolyObj::CheckMobjBlocking (side_t *sd)
{ {
auto Level = GetLevel();
static TArray<AActor *> checker; static TArray<AActor *> checker;
FBlockNode *block; FBlockNode *block;
AActor *mobj; AActor *mobj;
@ -1169,7 +1160,6 @@ void FPolyObj::LinkPolyobj ()
{ {
polyblock_t **link; polyblock_t **link;
polyblock_t *tempLink; polyblock_t *tempLink;
auto Level = GetLevel();
int bmapwidth = Level->blockmap.bmapwidth; int bmapwidth = Level->blockmap.bmapwidth;
int bmapheight = Level->blockmap.bmapheight; int bmapheight = Level->blockmap.bmapheight;
@ -1666,7 +1656,6 @@ static void SplitPoly(FPolyNode *pnode, void *node, float bbox[4])
void FPolyObj::CreateSubsectorLinks() void FPolyObj::CreateSubsectorLinks()
{ {
auto Level = GetLevel();
FPolyNode *node = NewPolyNode(); FPolyNode *node = NewPolyNode();
// Even though we don't care about it, we need to initialize this // 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 // bounding box to something so that Valgrind won't complain about it
@ -1846,7 +1835,7 @@ FPolyObj *FPolyMirrorIterator::NextMirror()
if (i == NumUsedPolys) if (i == NumUsedPolys)
{ // No, it has not been returned. { // No, it has not been returned.
UsedPolys[NumUsedPolys++] = mirror; UsedPolys[NumUsedPolys++] = mirror;
nextpoly = poly->GetLevel()->GetPolyobj(mirror); nextpoly = poly->Level->GetPolyobj(mirror);
if (nextpoly == nullptr) if (nextpoly == nullptr)
{ {
Printf("Invalid mirror polyobj num %d for polyobj num %d\n", mirror, UsedPolys[i - 1]); 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 ===== // ===== Polyobj data =====
struct FPolyObj struct FPolyObj
{ {
FLevelLocals *Level;
TArray<side_t *> Sidedefs; TArray<side_t *> Sidedefs;
TArray<line_t *> Linedefs; TArray<line_t *> Linedefs;
TArray<vertex_t *> Vertices; TArray<vertex_t *> Vertices;
@ -108,9 +109,6 @@ struct FPolyObj
void UpdateLinks(); void UpdateLinks();
static void ClearAllSubsectorLinks(); static void ClearAllSubsectorLinks();
FLevelLocals *GetLevel() const;
private: private:
void ThrustMobj (AActor *actor, side_t *side); 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); R_SetupFrame(Viewpoint, Viewwindow, actor);
Level = Viewpoint.ViewLevel; Level = Viewpoint.ViewLevel;
P_FindParticleSubsectors(); P_FindParticleSubsectors();
PO_LinkToSubsectors(&level); PO_LinkToSubsectors(Level);
static bool firstcall = true; static bool firstcall = true;
if (firstcall) 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.Pitch = RAD2DEG((float)asin(angy / alen));
viewpoint.HWAngles.Roll.Degrees = (float)viewpoint.Angles.Roll.Degrees; // copied for convenience. 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 // ViewActor only gets set, if the camera actor should not be rendered
if (actor->player && actor->player - players == consoleplayer && 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; unsigned int i;
if (GSnd) if (GSnd && Level == currentUILevel)
{ {
for (i = 0; i < S_sfx.Size(); ++i) for (i = 0; i < S_sfx.Size(); ++i)
{ {
@ -483,7 +483,7 @@ void S_PrecacheLevel ()
} }
AActor *actor; AActor *actor;
TThinkerIterator<AActor> iterator; auto iterator = Level->GetThinkerIterator<AActor>();
// Precache all sounds known to be used by the currently spawned actors. // Precache all sounds known to be used by the currently spawned actors.
while ( (actor = iterator.Next()) != NULL ) 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) 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); S_StartSound (nullptr, nullptr, poly, nullptr, channel, sound_id, volume, attenuation);
} }

View file

@ -218,7 +218,7 @@ void S_Shutdown ();
void S_Start (); void S_Start ();
// Called after a level is loaded. Ensures that most sounds are loaded. // 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. // Loads a sound, including any random sounds it might reference.
void S_CacheSound (sfxinfo_t *sfx); 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) 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) DEFINE_ACTION_FUNCTION_NATIVE(AActor, GiveSecret, GiveSecret)

View file

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