mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-11 07:12:16 +00:00
Reset FirstFreeEntry in ACSStringPool::ReadStrings()
- Fixed: When an ACS string pool was read from a savegame, FirstFreeEntry would not be updatedt, except by the Clear() function. This left FirstFreeEntry at 0, which meant the next string added to the pool would always go in slot 0, whether it was free or not.
This commit is contained in:
parent
7143ae49e1
commit
0f0d9da839
2 changed files with 21 additions and 5 deletions
|
@ -575,11 +575,7 @@ int ACSStringPool::InsertString(FString &str, unsigned int h, unsigned int bucke
|
|||
}
|
||||
else
|
||||
{ // Scan for the next free entry
|
||||
unsigned int i;
|
||||
for (i = FirstFreeEntry + 1; i < Pool.Size() && Pool[i].Next != FREE_ENTRY; ++i)
|
||||
{
|
||||
}
|
||||
FirstFreeEntry = i;
|
||||
FindFirstFreeEntry(FirstFreeEntry + 1);
|
||||
}
|
||||
PoolEntry *entry = &Pool[index];
|
||||
entry->Str = str;
|
||||
|
@ -590,6 +586,23 @@ int ACSStringPool::InsertString(FString &str, unsigned int h, unsigned int bucke
|
|||
return index | STRPOOL_LIBRARYID_OR;
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
//
|
||||
// ACSStringPool :: FindFirstFreeEntry
|
||||
//
|
||||
// Finds the first free entry, starting at base.
|
||||
//
|
||||
//============================================================================
|
||||
|
||||
void ACSStringPool::FindFirstFreeEntry(unsigned base)
|
||||
{
|
||||
while (base < Pool.Size() && Pool[base].Next != FREE_ENTRY)
|
||||
{
|
||||
base++;
|
||||
}
|
||||
FirstFreeEntry = base;
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
//
|
||||
// ACSStringPool :: ReadStrings
|
||||
|
@ -638,6 +651,7 @@ void ACSStringPool::ReadStrings(PNGHandle *png, DWORD id)
|
|||
{
|
||||
delete[] str;
|
||||
}
|
||||
FindFirstFreeEntry(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -690,6 +704,7 @@ void ACSStringPool::Dump() const
|
|||
Printf("%4u. (%2d) \"%s\"\n", i, Pool[i].LockCount, Pool[i].Str.GetChars());
|
||||
}
|
||||
}
|
||||
Printf("First free %u\n", FirstFreeEntry);
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
|
|
|
@ -100,6 +100,7 @@ public:
|
|||
private:
|
||||
int FindString(const char *str, size_t len, unsigned int h, unsigned int bucketnum);
|
||||
int InsertString(FString &str, unsigned int h, unsigned int bucketnum, const SDWORD *stack, int stackdepth);
|
||||
void FindFirstFreeEntry(unsigned int base);
|
||||
|
||||
enum { NUM_BUCKETS = 251 };
|
||||
enum { FREE_ENTRY = 0xFFFFFFFE }; // Stored in PoolEntry's Next field
|
||||
|
|
Loading…
Reference in a new issue