mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-11 07:11:54 +00:00
- moved thinker storage into FLevelLocals.
This commit is contained in:
parent
99d63faea9
commit
64ac6dbc6e
10 changed files with 33 additions and 48 deletions
|
@ -2724,7 +2724,7 @@ void D_DoomMain (void)
|
|||
// clean up game state
|
||||
ST_Clear();
|
||||
D_ErrorCleanup ();
|
||||
Thinkers.DestroyThinkersInList(STAT_STATIC);
|
||||
level.Thinkers.DestroyThinkersInList(STAT_STATIC);
|
||||
E_Shutdown(false);
|
||||
P_FreeLevelData();
|
||||
|
||||
|
|
|
@ -282,7 +282,6 @@ static void MarkRoot()
|
|||
Mark(StatusBar);
|
||||
M_MarkMenus();
|
||||
Mark(DIntermissionController::CurrentIntermission);
|
||||
Thinkers.MarkRoots();
|
||||
Mark(E_FirstEventHandler);
|
||||
Mark(E_LastEventHandler);
|
||||
for (auto Level : AllLevels())
|
||||
|
|
|
@ -65,7 +65,6 @@ struct ProfileInfo
|
|||
|
||||
static TMap<FName, ProfileInfo> Profiles;
|
||||
static unsigned int profilethinkers, profilelimit;
|
||||
FThinkerCollection Thinkers;
|
||||
DThinker *NextToThink;
|
||||
|
||||
//==========================================================================
|
||||
|
@ -750,16 +749,12 @@ DThinker *FLevelLocals::FirstThinker (int statnum)
|
|||
|
||||
void DThinker::ChangeStatNum (int statnum)
|
||||
{
|
||||
FThinkerList *list;
|
||||
|
||||
FThinkerCollection *collection = &Thinkers; //Todo: get from level
|
||||
|
||||
if ((unsigned)statnum > MAX_STATNUM)
|
||||
{
|
||||
statnum = MAX_STATNUM;
|
||||
}
|
||||
Remove();
|
||||
Thinkers.Link(this, statnum);
|
||||
Level->Thinkers.Link(this, statnum);
|
||||
}
|
||||
|
||||
static void ChangeStatNum(DThinker *thinker, int statnum)
|
||||
|
@ -771,7 +766,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(DThinker, ChangeStatNum, ChangeStatNum)
|
|||
{
|
||||
PARAM_SELF_PROLOGUE(DThinker);
|
||||
PARAM_INT(stat);
|
||||
self->ChangeStatNum(stat);
|
||||
ChangeStatNum(self, stat);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -884,7 +879,7 @@ size_t DThinker::PropagateMark()
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
FThinkerIterator::FThinkerIterator (const PClass *type, int statnum)
|
||||
FThinkerIterator::FThinkerIterator (FLevelLocals *l, const PClass *type, int statnum) : Level(l)
|
||||
{
|
||||
if ((unsigned)statnum > MAX_STATNUM)
|
||||
{
|
||||
|
@ -897,8 +892,7 @@ FThinkerIterator::FThinkerIterator (const PClass *type, int statnum)
|
|||
m_SearchStats = false;
|
||||
}
|
||||
m_ParentType = type;
|
||||
m_CurrThinker = Thinkers.Thinkers[m_Stat].GetHead();
|
||||
m_SearchingFresh = false;
|
||||
Reinit();
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
@ -907,7 +901,7 @@ FThinkerIterator::FThinkerIterator (const PClass *type, int statnum)
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
FThinkerIterator::FThinkerIterator (const PClass *type, int statnum, DThinker *prev)
|
||||
FThinkerIterator::FThinkerIterator (FLevelLocals *l, const PClass *type, int statnum, DThinker *prev) : Level(l)
|
||||
{
|
||||
if ((unsigned)statnum > MAX_STATNUM)
|
||||
{
|
||||
|
@ -939,7 +933,7 @@ FThinkerIterator::FThinkerIterator (const PClass *type, int statnum, DThinker *p
|
|||
|
||||
void FThinkerIterator::Reinit ()
|
||||
{
|
||||
m_CurrThinker = Thinkers.Thinkers[m_Stat].GetHead();
|
||||
m_CurrThinker = Level->Thinkers.Thinkers[m_Stat].GetHead();
|
||||
m_SearchingFresh = false;
|
||||
}
|
||||
|
||||
|
@ -980,7 +974,7 @@ DThinker *FThinkerIterator::Next (bool exact)
|
|||
}
|
||||
if ((m_SearchingFresh = !m_SearchingFresh))
|
||||
{
|
||||
m_CurrThinker = Thinkers.FreshThinkers[m_Stat].GetHead();
|
||||
m_CurrThinker = Level->Thinkers.FreshThinkers[m_Stat].GetHead();
|
||||
}
|
||||
} while (m_SearchingFresh);
|
||||
if (m_SearchStats)
|
||||
|
@ -991,7 +985,7 @@ DThinker *FThinkerIterator::Next (bool exact)
|
|||
m_Stat = STAT_FIRST_THINKING;
|
||||
}
|
||||
}
|
||||
m_CurrThinker = Thinkers.Thinkers[m_Stat].GetHead();
|
||||
m_CurrThinker = Level->Thinkers.Thinkers[m_Stat].GetHead();
|
||||
m_SearchingFresh = false;
|
||||
} while (m_SearchStats && m_Stat != STAT_FIRST_THINKING);
|
||||
return nullptr;
|
||||
|
|
|
@ -131,14 +131,15 @@ class FThinkerIterator
|
|||
protected:
|
||||
const PClass *m_ParentType;
|
||||
private:
|
||||
FLevelLocals *Level;
|
||||
DThinker *m_CurrThinker;
|
||||
uint8_t m_Stat;
|
||||
bool m_SearchStats;
|
||||
bool m_SearchingFresh;
|
||||
|
||||
public:
|
||||
FThinkerIterator (const PClass *type, int statnum=MAX_STATNUM+1);
|
||||
FThinkerIterator (const PClass *type, int statnum, DThinker *prev);
|
||||
FThinkerIterator (FLevelLocals *Level, const PClass *type, int statnum=MAX_STATNUM+1);
|
||||
FThinkerIterator (FLevelLocals *Level, const PClass *type, int statnum, DThinker *prev);
|
||||
DThinker *Next (bool exact = false);
|
||||
void Reinit ();
|
||||
|
||||
|
@ -149,28 +150,19 @@ protected:
|
|||
template <class T> class TThinkerIterator : public FThinkerIterator
|
||||
{
|
||||
public:
|
||||
TThinkerIterator (int statnum=MAX_STATNUM+1) : FThinkerIterator (RUNTIME_CLASS(T), statnum)
|
||||
TThinkerIterator (FLevelLocals *Level, int statnum=MAX_STATNUM+1) : FThinkerIterator (Level, RUNTIME_CLASS(T), statnum)
|
||||
{
|
||||
}
|
||||
TThinkerIterator (int statnum, DThinker *prev) : FThinkerIterator (RUNTIME_CLASS(T), statnum, prev)
|
||||
TThinkerIterator (FLevelLocals *Level, int statnum, DThinker *prev) : FThinkerIterator (Level, RUNTIME_CLASS(T), statnum, prev)
|
||||
{
|
||||
}
|
||||
TThinkerIterator (const PClass *subclass, int statnum=MAX_STATNUM+1) : FThinkerIterator(subclass, statnum)
|
||||
TThinkerIterator (FLevelLocals *Level, const PClass *subclass, int statnum=MAX_STATNUM+1) : FThinkerIterator(Level, subclass, statnum)
|
||||
{
|
||||
}
|
||||
TThinkerIterator (FName subclass, int statnum=MAX_STATNUM+1) : FThinkerIterator(PClass::FindClass(subclass), statnum)
|
||||
TThinkerIterator (FLevelLocals *Level, FName subclass, int statnum=MAX_STATNUM+1) : FThinkerIterator(Level, PClass::FindClass(subclass), statnum)
|
||||
{
|
||||
}
|
||||
TThinkerIterator (ENamedName subclass, int statnum=MAX_STATNUM+1) : FThinkerIterator(PClass::FindClass(subclass), statnum)
|
||||
{
|
||||
}
|
||||
TThinkerIterator (FName subclass, int statnum, DThinker *prev) : FThinkerIterator(PClass::FindClass(subclass), statnum, prev)
|
||||
{
|
||||
}
|
||||
TThinkerIterator (ENamedName subclass, int statnum, DThinker *prev) : FThinkerIterator(PClass::FindClass(subclass), statnum, prev)
|
||||
{
|
||||
}
|
||||
TThinkerIterator (const char *subclass, int statnum=MAX_STATNUM+1) : FThinkerIterator(PClass::FindClass(subclass), statnum)
|
||||
TThinkerIterator (FLevelLocals *Level, FName subclass, int statnum, DThinker *prev) : FThinkerIterator(Level, PClass::FindClass(subclass), statnum, prev)
|
||||
{
|
||||
}
|
||||
T *Next (bool exact = false)
|
||||
|
@ -179,5 +171,5 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
extern FThinkerCollection Thinkers;
|
||||
|
||||
#endif //__DTHINKER_H__
|
||||
|
|
|
@ -356,7 +356,7 @@ void G_NewInit ()
|
|||
int i;
|
||||
|
||||
// Destory all old player refrences that may still exist
|
||||
TThinkerIterator<AActor> it(NAME_PlayerPawn, STAT_TRAVELLING);
|
||||
TThinkerIterator<AActor> it(&level, NAME_PlayerPawn, STAT_TRAVELLING);
|
||||
AActor *pawn, *next;
|
||||
|
||||
next = it.Next();
|
||||
|
@ -469,7 +469,7 @@ void G_InitNew (const char *mapname, bool bTitleLevel)
|
|||
UnlatchCVars ();
|
||||
G_VerifySkill();
|
||||
UnlatchCVars ();
|
||||
Thinkers.DestroyThinkersInList(STAT_STATIC);
|
||||
level.Thinkers.DestroyThinkersInList(STAT_STATIC);
|
||||
|
||||
if (paused)
|
||||
{
|
||||
|
@ -2117,7 +2117,7 @@ void FLevelLocals::Mark()
|
|||
GC::Mark(BotInfo.firstthing);
|
||||
GC::Mark(BotInfo.body1);
|
||||
GC::Mark(BotInfo.body2);
|
||||
|
||||
Thinkers.MarkRoots();
|
||||
canvasTextureInfo.Mark();
|
||||
for (auto &c : CorpseQueue)
|
||||
{
|
||||
|
|
|
@ -269,12 +269,12 @@ public:
|
|||
}
|
||||
template<class T> TThinkerIterator<T> GetThinkerIterator(FName subtype = NAME_None, int statnum = MAX_STATNUM+1)
|
||||
{
|
||||
if (subtype == NAME_None) return TThinkerIterator<T>(statnum);
|
||||
else return TThinkerIterator<T>(subtype, statnum);
|
||||
if (subtype == NAME_None) return TThinkerIterator<T>(this, statnum);
|
||||
else return TThinkerIterator<T>(this, subtype, statnum);
|
||||
}
|
||||
template<class T> TThinkerIterator<T> GetThinkerIterator(FName subtype, int statnum, AActor *prev)
|
||||
{
|
||||
return TThinkerIterator<T>(subtype, statnum, prev);
|
||||
return TThinkerIterator<T>(this, subtype, statnum, prev);
|
||||
}
|
||||
FActorIterator GetActorIterator(int tid)
|
||||
{
|
||||
|
@ -590,6 +590,7 @@ public:
|
|||
uint32_t InactiveParticles;
|
||||
TArray<particle_t> Particles;
|
||||
TArray<uint16_t> ParticlesInSubsec;
|
||||
FThinkerCollection Thinkers;
|
||||
|
||||
TArray<DVector2> Scrolls; // NULL if no DScrollers in this level
|
||||
|
||||
|
|
|
@ -1013,7 +1013,7 @@ void FLevelLocals::Serialize(FSerializer &arc, bool hubload)
|
|||
if (arc.isReading())
|
||||
{
|
||||
for (auto &sec : sectors)
|
||||
{
|
||||
{
|
||||
P_Recalculate3DFloors(&sec);
|
||||
}
|
||||
for (int i = 0; i < MAXPLAYERS; ++i)
|
||||
|
|
|
@ -253,6 +253,7 @@ void FLevelLocals::ClearPortals()
|
|||
|
||||
void FLevelLocals::ClearLevelData()
|
||||
{
|
||||
Thinkers.DestroyAllThinkers();
|
||||
ClearAllSubsectorLinks(); // can't be done as part of the polyobj deletion process.
|
||||
|
||||
total_monsters = total_items = total_secrets =
|
||||
|
@ -349,8 +350,6 @@ void P_FreeLevelData ()
|
|||
E_Shutdown(true);
|
||||
R_FreePastViewers();
|
||||
|
||||
Thinkers.DestroyAllThinkers ();
|
||||
|
||||
level.ClearLevelData();
|
||||
}
|
||||
|
||||
|
@ -574,7 +573,7 @@ void P_Init ()
|
|||
|
||||
static void P_Shutdown ()
|
||||
{
|
||||
Thinkers.DestroyThinkersInList(STAT_STATIC);
|
||||
level.Thinkers.DestroyThinkersInList(STAT_STATIC);
|
||||
P_FreeLevelData ();
|
||||
// [ZZ] delete global event handlers
|
||||
E_Shutdown(false);
|
||||
|
|
|
@ -151,7 +151,7 @@ void P_Ticker (void)
|
|||
E_WorldTick();
|
||||
StatusBar->CallTick (); // [RH] moved this here
|
||||
level.Tick (); // [RH] let the level tick
|
||||
Thinkers.RunThinkers(&level);
|
||||
level.Thinkers.RunThinkers(&level);
|
||||
|
||||
//if added by MC: Freeze mode.
|
||||
if (!level.isFrozen())
|
||||
|
|
|
@ -41,8 +41,8 @@ class DThinkerIterator : public DObject, public FThinkerIterator
|
|||
DECLARE_ABSTRACT_CLASS(DThinkerIterator, DObject)
|
||||
|
||||
public:
|
||||
DThinkerIterator(PClass *cls, int statnum = MAX_STATNUM + 1)
|
||||
: FThinkerIterator(cls, statnum)
|
||||
DThinkerIterator(FLevelLocals *Level, PClass *cls, int statnum = MAX_STATNUM + 1)
|
||||
: FThinkerIterator(Level, cls, statnum)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
@ -51,7 +51,7 @@ IMPLEMENT_CLASS(DThinkerIterator, true, false);
|
|||
|
||||
static DThinkerIterator *CreateThinkerIterator(PClass *type, int statnum)
|
||||
{
|
||||
return Create<DThinkerIterator>(type, statnum);
|
||||
return Create<DThinkerIterator>(&level, type, statnum);
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION_NATIVE(DThinkerIterator, Create, CreateThinkerIterator)
|
||||
|
@ -59,7 +59,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(DThinkerIterator, Create, CreateThinkerIterator)
|
|||
PARAM_PROLOGUE;
|
||||
PARAM_CLASS(type, DThinker);
|
||||
PARAM_INT(statnum);
|
||||
ACTION_RETURN_OBJECT(Create<DThinkerIterator>(type, statnum));
|
||||
ACTION_RETURN_OBJECT(CreateThinkerIterator(type, statnum));
|
||||
}
|
||||
|
||||
static DThinker *NextThinker(DThinkerIterator *self, bool exact)
|
||||
|
|
Loading…
Reference in a new issue