mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-13 07:57:58 +00:00
- moved the global ACS ActiveThinker variable into FLevelLocals.
This commit is contained in:
parent
b386a09358
commit
6f6dc60e2b
4 changed files with 29 additions and 36 deletions
|
@ -1970,6 +1970,7 @@ void FLevelLocals::Mark()
|
||||||
{
|
{
|
||||||
GC::Mark(SpotState);
|
GC::Mark(SpotState);
|
||||||
GC::Mark(FraggleScriptThinker);
|
GC::Mark(FraggleScriptThinker);
|
||||||
|
GC::Mark(ACSThinker);
|
||||||
canvasTextureInfo.Mark();
|
canvasTextureInfo.Mark();
|
||||||
for (auto &c : CorpseQueue)
|
for (auto &c : CorpseQueue)
|
||||||
{
|
{
|
||||||
|
|
|
@ -48,6 +48,7 @@
|
||||||
#include "r_data/r_sections.h"
|
#include "r_data/r_sections.h"
|
||||||
#include "r_data/r_canvastexture.h"
|
#include "r_data/r_canvastexture.h"
|
||||||
|
|
||||||
|
class DACSThinker;
|
||||||
class DFraggleThinker;
|
class DFraggleThinker;
|
||||||
class DSpotState;
|
class DSpotState;
|
||||||
|
|
||||||
|
@ -207,6 +208,8 @@ struct FLevelLocals : public FLevelData
|
||||||
// links to global game objects
|
// links to global game objects
|
||||||
TArray<TObjPtr<AActor *>> CorpseQueue;
|
TArray<TObjPtr<AActor *>> CorpseQueue;
|
||||||
TObjPtr<DFraggleThinker *> FraggleScriptThinker = nullptr;
|
TObjPtr<DFraggleThinker *> FraggleScriptThinker = nullptr;
|
||||||
|
TObjPtr<DACSThinker*> ACSThinker = nullptr;
|
||||||
|
|
||||||
TObjPtr<DSpotState *> SpotState = nullptr;
|
TObjPtr<DSpotState *> SpotState = nullptr;
|
||||||
|
|
||||||
bool IsJumpingAllowed() const;
|
bool IsJumpingAllowed() const;
|
||||||
|
|
|
@ -782,7 +782,6 @@ public:
|
||||||
|
|
||||||
typedef TMap<int, DLevelScript *> ScriptMap;
|
typedef TMap<int, DLevelScript *> ScriptMap;
|
||||||
ScriptMap RunningScripts; // Array of all synchronous scripts
|
ScriptMap RunningScripts; // Array of all synchronous scripts
|
||||||
static TObjPtr<DACSThinker*> ActiveThinker;
|
|
||||||
|
|
||||||
void DumpScriptStatus();
|
void DumpScriptStatus();
|
||||||
void StopScriptsFor(AActor *actor);
|
void StopScriptsFor(AActor *actor);
|
||||||
|
@ -2066,9 +2065,9 @@ void FBehaviorContainer::MarkLevelVarStrings()
|
||||||
StaticModules[modnum]->MarkMapVarStrings();
|
StaticModules[modnum]->MarkMapVarStrings();
|
||||||
}
|
}
|
||||||
// Mark running scripts' local variables.
|
// Mark running scripts' local variables.
|
||||||
if (DACSThinker::ActiveThinker != NULL)
|
if (level.ACSThinker != nullptr)
|
||||||
{
|
{
|
||||||
for (DLevelScript *script = DACSThinker::ActiveThinker->Scripts; script != NULL; script = script->GetNext())
|
for (DLevelScript *script = level.ACSThinker->Scripts; script != NULL; script = script->GetNext())
|
||||||
{
|
{
|
||||||
script->MarkLocalVarStrings();
|
script->MarkLocalVarStrings();
|
||||||
}
|
}
|
||||||
|
@ -2083,9 +2082,9 @@ void FBehaviorContainer::LockLevelVarStrings()
|
||||||
StaticModules[modnum]->LockMapVarStrings();
|
StaticModules[modnum]->LockMapVarStrings();
|
||||||
}
|
}
|
||||||
// Lock running scripts' local variables.
|
// Lock running scripts' local variables.
|
||||||
if (DACSThinker::ActiveThinker != NULL)
|
if (level.ACSThinker != nullptr)
|
||||||
{
|
{
|
||||||
for (DLevelScript *script = DACSThinker::ActiveThinker->Scripts; script != NULL; script = script->GetNext())
|
for (DLevelScript *script = level.ACSThinker->Scripts; script != NULL; script = script->GetNext())
|
||||||
{
|
{
|
||||||
script->LockLocalVarStrings();
|
script->LockLocalVarStrings();
|
||||||
}
|
}
|
||||||
|
@ -3359,7 +3358,7 @@ void FBehavior::StartTypedScripts (uint16_t type, AActor *activator, bool always
|
||||||
|
|
||||||
void FBehaviorContainer::StopMyScripts (AActor *actor)
|
void FBehaviorContainer::StopMyScripts (AActor *actor)
|
||||||
{
|
{
|
||||||
DACSThinker *controller = DACSThinker::ActiveThinker;
|
DACSThinker *controller = level.ACSThinker;
|
||||||
|
|
||||||
if (controller != NULL)
|
if (controller != NULL)
|
||||||
{
|
{
|
||||||
|
@ -3377,28 +3376,17 @@ IMPLEMENT_POINTERS_START(DACSThinker)
|
||||||
IMPLEMENT_POINTER(Scripts)
|
IMPLEMENT_POINTER(Scripts)
|
||||||
IMPLEMENT_POINTERS_END
|
IMPLEMENT_POINTERS_END
|
||||||
|
|
||||||
TObjPtr<DACSThinker*> DACSThinker::ActiveThinker;
|
|
||||||
|
|
||||||
DACSThinker::DACSThinker ()
|
DACSThinker::DACSThinker ()
|
||||||
: DThinker(STAT_SCRIPTS)
|
: DThinker(STAT_SCRIPTS)
|
||||||
{
|
{
|
||||||
if (ActiveThinker)
|
Scripts = nullptr;
|
||||||
{
|
LastScript = nullptr;
|
||||||
I_Error ("Only one ACSThinker is allowed to exist at a time.\nCheck your code.");
|
RunningScripts.Clear();
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ActiveThinker = this;
|
|
||||||
Scripts = NULL;
|
|
||||||
LastScript = NULL;
|
|
||||||
RunningScripts.Clear();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DACSThinker::~DACSThinker ()
|
DACSThinker::~DACSThinker ()
|
||||||
{
|
{
|
||||||
Scripts = NULL;
|
Scripts = nullptr;
|
||||||
ActiveThinker = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
@ -3563,9 +3551,9 @@ void DLevelScript::Serialize(FSerializer &arc)
|
||||||
|
|
||||||
DLevelScript::DLevelScript ()
|
DLevelScript::DLevelScript ()
|
||||||
{
|
{
|
||||||
next = prev = NULL;
|
next = prev = nullptr;
|
||||||
if (DACSThinker::ActiveThinker == NULL)
|
if (level.ACSThinker == nullptr)
|
||||||
Create<DACSThinker>();
|
level.ACSThinker = Create<DACSThinker>();
|
||||||
activefont = SmallFont;
|
activefont = SmallFont;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3575,7 +3563,7 @@ DLevelScript::~DLevelScript ()
|
||||||
|
|
||||||
void DLevelScript::Unlink ()
|
void DLevelScript::Unlink ()
|
||||||
{
|
{
|
||||||
DACSThinker *controller = DACSThinker::ActiveThinker;
|
DACSThinker *controller = level.ACSThinker;
|
||||||
|
|
||||||
if (controller->LastScript == this)
|
if (controller->LastScript == this)
|
||||||
{
|
{
|
||||||
|
@ -3601,7 +3589,7 @@ void DLevelScript::Unlink ()
|
||||||
|
|
||||||
void DLevelScript::Link ()
|
void DLevelScript::Link ()
|
||||||
{
|
{
|
||||||
DACSThinker *controller = DACSThinker::ActiveThinker;
|
DACSThinker *controller = level.ACSThinker;
|
||||||
|
|
||||||
next = controller->Scripts;
|
next = controller->Scripts;
|
||||||
GC::WriteBarrier(this, next);
|
GC::WriteBarrier(this, next);
|
||||||
|
@ -3621,7 +3609,7 @@ void DLevelScript::Link ()
|
||||||
|
|
||||||
void DLevelScript::PutLast ()
|
void DLevelScript::PutLast ()
|
||||||
{
|
{
|
||||||
DACSThinker *controller = DACSThinker::ActiveThinker;
|
DACSThinker *controller = level.ACSThinker;
|
||||||
|
|
||||||
if (controller->LastScript == this)
|
if (controller->LastScript == this)
|
||||||
return;
|
return;
|
||||||
|
@ -3643,7 +3631,7 @@ void DLevelScript::PutLast ()
|
||||||
|
|
||||||
void DLevelScript::PutFirst ()
|
void DLevelScript::PutFirst ()
|
||||||
{
|
{
|
||||||
DACSThinker *controller = DACSThinker::ActiveThinker;
|
DACSThinker *controller = level.ACSThinker;
|
||||||
|
|
||||||
if (controller->Scripts == this)
|
if (controller->Scripts == this)
|
||||||
return;
|
return;
|
||||||
|
@ -6853,7 +6841,7 @@ static bool CharArrayParms(int &capacity, int &offset, int &a, FACSStackMemory&
|
||||||
|
|
||||||
int DLevelScript::RunScript ()
|
int DLevelScript::RunScript ()
|
||||||
{
|
{
|
||||||
DACSThinker *controller = DACSThinker::ActiveThinker;
|
DACSThinker *controller = level.ACSThinker;
|
||||||
ACSLocalVariables locals(Localvars);
|
ACSLocalVariables locals(Localvars);
|
||||||
ACSLocalArrays noarrays;
|
ACSLocalArrays noarrays;
|
||||||
ACSLocalArrays *localarrays = &noarrays;
|
ACSLocalArrays *localarrays = &noarrays;
|
||||||
|
@ -10313,7 +10301,7 @@ scriptwait:
|
||||||
static DLevelScript *P_GetScriptGoing (AActor *who, line_t *where, int num, const ScriptPtr *code, FBehavior *module,
|
static DLevelScript *P_GetScriptGoing (AActor *who, line_t *where, int num, const ScriptPtr *code, FBehavior *module,
|
||||||
const int *args, int argcount, int flags)
|
const int *args, int argcount, int flags)
|
||||||
{
|
{
|
||||||
DACSThinker *controller = DACSThinker::ActiveThinker;
|
DACSThinker *controller = level.ACSThinker;
|
||||||
DLevelScript **running;
|
DLevelScript **running;
|
||||||
|
|
||||||
if (controller && !(flags & ACS_ALWAYS) && (running = controller->RunningScripts.CheckKey(num)) != NULL)
|
if (controller && !(flags & ACS_ALWAYS) && (running = controller->RunningScripts.CheckKey(num)) != NULL)
|
||||||
|
@ -10333,8 +10321,8 @@ DLevelScript::DLevelScript (AActor *who, line_t *where, int num, const ScriptPtr
|
||||||
const int *args, int argcount, int flags)
|
const int *args, int argcount, int flags)
|
||||||
: activeBehavior (module)
|
: activeBehavior (module)
|
||||||
{
|
{
|
||||||
if (DACSThinker::ActiveThinker == NULL)
|
if (level.ACSThinker == nullptr)
|
||||||
Create<DACSThinker>();
|
level.ACSThinker = Create<DACSThinker>();
|
||||||
|
|
||||||
script = num;
|
script = num;
|
||||||
assert(code->VarCount >= code->ArgCount);
|
assert(code->VarCount >= code->ArgCount);
|
||||||
|
@ -10362,7 +10350,7 @@ DLevelScript::DLevelScript (AActor *who, line_t *where, int num, const ScriptPtr
|
||||||
// goes by while they're in their default state.
|
// goes by while they're in their default state.
|
||||||
|
|
||||||
if (!(flags & ACS_ALWAYS))
|
if (!(flags & ACS_ALWAYS))
|
||||||
DACSThinker::ActiveThinker->RunningScripts[num] = this;
|
level.ACSThinker->RunningScripts[num] = this;
|
||||||
|
|
||||||
Link();
|
Link();
|
||||||
|
|
||||||
|
@ -10376,7 +10364,7 @@ DLevelScript::DLevelScript (AActor *who, line_t *where, int num, const ScriptPtr
|
||||||
|
|
||||||
static void SetScriptState (int script, DLevelScript::EScriptState state)
|
static void SetScriptState (int script, DLevelScript::EScriptState state)
|
||||||
{
|
{
|
||||||
DACSThinker *controller = DACSThinker::ActiveThinker;
|
DACSThinker *controller = level.ACSThinker;
|
||||||
DLevelScript **running;
|
DLevelScript **running;
|
||||||
|
|
||||||
if (controller != NULL && (running = controller->RunningScripts.CheckKey(script)) != NULL)
|
if (controller != NULL && (running = controller->RunningScripts.CheckKey(script)) != NULL)
|
||||||
|
@ -10545,13 +10533,13 @@ FSerializer &Serialize(FSerializer &arc, const char *key, acsdefered_t &defer, a
|
||||||
|
|
||||||
CCMD (scriptstat)
|
CCMD (scriptstat)
|
||||||
{
|
{
|
||||||
if (DACSThinker::ActiveThinker == NULL)
|
if (level.ACSThinker == NULL)
|
||||||
{
|
{
|
||||||
Printf ("No scripts are running.\n");
|
Printf ("No scripts are running.\n");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
DACSThinker::ActiveThinker->DumpScriptStatus ();
|
level.ACSThinker->DumpScriptStatus ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -979,6 +979,7 @@ void G_SerializeLevel(FSerializer &arc, bool hubload)
|
||||||
("level.corpsequeue", level.CorpseQueue)
|
("level.corpsequeue", level.CorpseQueue)
|
||||||
("level.spotstate", level.SpotState)
|
("level.spotstate", level.SpotState)
|
||||||
("level.fragglethinker", level.FraggleScriptThinker);
|
("level.fragglethinker", level.FraggleScriptThinker);
|
||||||
|
("level.acsthinker", level.ACSThinker);
|
||||||
|
|
||||||
// Hub transitions must keep the current total time
|
// Hub transitions must keep the current total time
|
||||||
if (!hubload)
|
if (!hubload)
|
||||||
|
|
Loading…
Reference in a new issue