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