mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-28 15:02:01 +00:00
- pass level num to string locking functions as a parameter.
This commit is contained in:
parent
cf7ab6d085
commit
8ead5a3a6b
3 changed files with 29 additions and 84 deletions
|
@ -854,7 +854,7 @@ void G_DoCompleted (void)
|
|||
G_SnapshotLevel ();
|
||||
// Do not free any global strings this level might reference
|
||||
// while it's not loaded.
|
||||
level.Behaviors.LockLevelVarStrings();
|
||||
level.Behaviors.LockLevelVarStrings(level.levelnum);
|
||||
}
|
||||
else
|
||||
{ // Make sure we don't have a snapshot lying around from before.
|
||||
|
@ -1718,7 +1718,7 @@ void G_UnSnapshotLevel (bool hubLoad)
|
|||
if (hubLoad)
|
||||
{
|
||||
// Unlock ACS global strings that were locked when the snapshot was made.
|
||||
level.Behaviors.UnlockLevelVarStrings();
|
||||
level.Behaviors.UnlockLevelVarStrings(level.levelnum);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -687,13 +687,9 @@ public:
|
|||
{
|
||||
GlobalACSStrings.MarkStringArray(&Localvars[0], Localvars.Size());
|
||||
}
|
||||
void LockLocalVarStrings() const
|
||||
void LockLocalVarStrings(int levelnum) const
|
||||
{
|
||||
GlobalACSStrings.LockStringArray(&Localvars[0], Localvars.Size());
|
||||
}
|
||||
void UnlockLocalVarStrings() const
|
||||
{
|
||||
GlobalACSStrings.UnlockStringArray(&Localvars[0], Localvars.Size());
|
||||
GlobalACSStrings.LockStringArray(levelnum, &Localvars[0], Localvars.Size());
|
||||
}
|
||||
|
||||
protected:
|
||||
|
@ -929,17 +925,17 @@ FACSStack::~FACSStack()
|
|||
|
||||
ACSStringPool GlobalACSStrings;
|
||||
|
||||
void ACSStringPool::PoolEntry::Lock()
|
||||
void ACSStringPool::PoolEntry::Lock(int levelnum)
|
||||
{
|
||||
if (Locks.Find(level.levelnum) == Locks.Size())
|
||||
if (Locks.Find(levelnum) == Locks.Size())
|
||||
{
|
||||
Locks.Push(level.levelnum);
|
||||
Locks.Push(levelnum);
|
||||
}
|
||||
}
|
||||
|
||||
void ACSStringPool::PoolEntry::Unlock()
|
||||
void ACSStringPool::PoolEntry::Unlock(int levelnum)
|
||||
{
|
||||
auto ndx = Locks.Find(level.levelnum);
|
||||
auto ndx = Locks.Find(levelnum);
|
||||
if (ndx < Locks.Size())
|
||||
{
|
||||
Locks.Delete(ndx);
|
||||
|
@ -1028,28 +1024,12 @@ const char *ACSStringPool::GetString(int strnum)
|
|||
//
|
||||
//============================================================================
|
||||
|
||||
void ACSStringPool::LockString(int strnum)
|
||||
void ACSStringPool::LockString(int levelnum, int strnum)
|
||||
{
|
||||
assert((strnum & LIBRARYID_MASK) == STRPOOL_LIBRARYID_OR);
|
||||
strnum &= ~LIBRARYID_MASK;
|
||||
assert((unsigned)strnum < Pool.Size());
|
||||
Pool[strnum].Lock();
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
//
|
||||
// ACSStringPool :: UnlockString
|
||||
//
|
||||
// When equally mated with LockString, allows this string to be purged.
|
||||
//
|
||||
//============================================================================
|
||||
|
||||
void ACSStringPool::UnlockString(int strnum)
|
||||
{
|
||||
assert((strnum & LIBRARYID_MASK) == STRPOOL_LIBRARYID_OR);
|
||||
strnum &= ~LIBRARYID_MASK;
|
||||
assert((unsigned)strnum < Pool.Size());
|
||||
Pool[strnum].Unlock();
|
||||
Pool[strnum].Lock(levelnum);
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
|
@ -1081,7 +1061,7 @@ void ACSStringPool::MarkString(int strnum)
|
|||
//
|
||||
//============================================================================
|
||||
|
||||
void ACSStringPool::LockStringArray(const int *strnum, unsigned int count)
|
||||
void ACSStringPool::LockStringArray(int levelnum, const int *strnum, unsigned int count)
|
||||
{
|
||||
for (unsigned int i = 0; i < count; ++i)
|
||||
{
|
||||
|
@ -1091,31 +1071,7 @@ void ACSStringPool::LockStringArray(const int *strnum, unsigned int count)
|
|||
num &= ~LIBRARYID_MASK;
|
||||
if ((unsigned)num < Pool.Size())
|
||||
{
|
||||
Pool[num].Lock();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
//
|
||||
// ACSStringPool :: UnlockStringArray
|
||||
//
|
||||
// Reverse of LockStringArray.
|
||||
//
|
||||
//============================================================================
|
||||
|
||||
void ACSStringPool::UnlockStringArray(const int *strnum, unsigned int count)
|
||||
{
|
||||
for (unsigned int i = 0; i < count; ++i)
|
||||
{
|
||||
int num = strnum[i];
|
||||
if ((num & LIBRARYID_MASK) == STRPOOL_LIBRARYID_OR)
|
||||
{
|
||||
num &= ~LIBRARYID_MASK;
|
||||
if ((unsigned)num < Pool.Size())
|
||||
{
|
||||
Pool[num].Unlock();
|
||||
Pool[num].Lock(levelnum);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2074,26 +2030,26 @@ void FBehaviorContainer::MarkLevelVarStrings()
|
|||
}
|
||||
}
|
||||
|
||||
void FBehaviorContainer::LockLevelVarStrings()
|
||||
void FBehaviorContainer::LockLevelVarStrings(int levelnum)
|
||||
{
|
||||
// Lock map variables.
|
||||
for (uint32_t modnum = 0; modnum < StaticModules.Size(); ++modnum)
|
||||
{
|
||||
StaticModules[modnum]->LockMapVarStrings();
|
||||
StaticModules[modnum]->LockMapVarStrings(levelnum);
|
||||
}
|
||||
// Lock running scripts' local variables.
|
||||
if (level.ACSThinker != nullptr)
|
||||
{
|
||||
for (DLevelScript *script = level.ACSThinker->Scripts; script != NULL; script = script->GetNext())
|
||||
{
|
||||
script->LockLocalVarStrings();
|
||||
script->LockLocalVarStrings(levelnum);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void FBehaviorContainer::UnlockLevelVarStrings()
|
||||
void FBehaviorContainer::UnlockLevelVarStrings(int levelnum)
|
||||
{
|
||||
GlobalACSStrings.UnlockForLevel(level.levelnum);
|
||||
GlobalACSStrings.UnlockForLevel(levelnum);
|
||||
}
|
||||
|
||||
void FBehavior::MarkMapVarStrings() const
|
||||
|
@ -2105,21 +2061,12 @@ void FBehavior::MarkMapVarStrings() const
|
|||
}
|
||||
}
|
||||
|
||||
void FBehavior::LockMapVarStrings() const
|
||||
void FBehavior::LockMapVarStrings(int levelnum) const
|
||||
{
|
||||
GlobalACSStrings.LockStringArray(MapVarStore, NUM_MAPVARS);
|
||||
GlobalACSStrings.LockStringArray(levelnum, MapVarStore, NUM_MAPVARS);
|
||||
for (int i = 0; i < NumArrays; ++i)
|
||||
{
|
||||
GlobalACSStrings.LockStringArray(ArrayStore[i].Elements, ArrayStore[i].ArraySize);
|
||||
}
|
||||
}
|
||||
|
||||
void FBehavior::UnlockMapVarStrings() const
|
||||
{
|
||||
GlobalACSStrings.UnlockStringArray(MapVarStore, NUM_MAPVARS);
|
||||
for (int i = 0; i < NumArrays; ++i)
|
||||
{
|
||||
GlobalACSStrings.UnlockStringArray(ArrayStore[i].Elements, ArrayStore[i].ArraySize);
|
||||
GlobalACSStrings.LockStringArray(levelnum, ArrayStore[i].Elements, ArrayStore[i].ArraySize);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
18
src/p_acs.h
18
src/p_acs.h
|
@ -102,12 +102,10 @@ public:
|
|||
int AddString(const char *str);
|
||||
int AddString(FString &str);
|
||||
const char *GetString(int strnum);
|
||||
void LockString(int strnum);
|
||||
void UnlockString(int strnum);
|
||||
void LockString(int levelnum, int strnum);
|
||||
void UnlockAll();
|
||||
void MarkString(int strnum);
|
||||
void LockStringArray(const int *strnum, unsigned int count);
|
||||
void UnlockStringArray(const int *strnum, unsigned int count);
|
||||
void LockStringArray(int levelnum, const int *strnum, unsigned int count);
|
||||
void MarkStringArray(const int *strnum, unsigned int count);
|
||||
void MarkStringMap(const FWorldGlobalArray &array);
|
||||
void PurgeStrings();
|
||||
|
@ -134,8 +132,8 @@ private:
|
|||
bool Mark;
|
||||
TArray<int> Locks;
|
||||
|
||||
void Lock();
|
||||
void Unlock();
|
||||
void Lock(int levelnum);
|
||||
void Unlock(int levelnum);
|
||||
};
|
||||
TArray<PoolEntry> Pool;
|
||||
unsigned int PoolBuckets[NUM_BUCKETS];
|
||||
|
@ -419,8 +417,7 @@ private:
|
|||
void SerializeVarSet (FSerializer &arc, int32_t *vars, int max);
|
||||
|
||||
void MarkMapVarStrings() const;
|
||||
void LockMapVarStrings() const;
|
||||
void UnlockMapVarStrings() const;
|
||||
void LockMapVarStrings(int levelnum) const;
|
||||
|
||||
friend void ArrangeScriptProfiles(TArray<ProfileCollector> &profiles);
|
||||
friend void ArrangeFunctionProfiles(TArray<ProfileCollector> &profiles);
|
||||
|
@ -438,8 +435,8 @@ struct FBehaviorContainer
|
|||
FBehavior *GetModule(int lib);
|
||||
void SerializeModuleStates(FSerializer &arc);
|
||||
void MarkLevelVarStrings();
|
||||
void LockLevelVarStrings();
|
||||
void UnlockLevelVarStrings();
|
||||
void LockLevelVarStrings(int levelnum);
|
||||
void UnlockLevelVarStrings(int levelnum);
|
||||
|
||||
const ScriptPtr *FindScript(int script, FBehavior *&module);
|
||||
const char *LookupString(uint32_t index);
|
||||
|
@ -450,4 +447,5 @@ struct FBehaviorContainer
|
|||
|
||||
|
||||
|
||||
|
||||
#endif //__P_ACS_H__
|
||||
|
|
Loading…
Reference in a new issue