Added global iterator for behaviors

Imported Behaviors to the engine to allow them to properly clean up their level list. Restrict Behaviors from being new'd in ZScript as they need an owner to function.
This commit is contained in:
Boondorl 2025-01-24 12:15:48 -05:00 committed by Ricardo Luís Vaz Silva
commit 14f7a10ae6
9 changed files with 140 additions and 45 deletions

View file

@ -226,15 +226,15 @@ FSerializer& FDoomSerializer::StatePointer(const char* key, void* ptraddr, bool
}
FSerializer& Serialize(FSerializer& arc, const char* key, TMap<FName, DObject*>& value, TMap<FName, DObject*>* def)
FSerializer& Serialize(FSerializer& arc, const char* key, TMap<FName, DBehavior*>& value, TMap<FName, DBehavior*>* def)
{
if (!arc.BeginObject(key))
return arc;
if (arc.isWriting())
{
TMap<FName, DObject*>::Iterator it = { value };
TMap<FName, DObject*>::Pair* pair = nullptr;
TMap<FName, DBehavior*>::Iterator it = { value };
TMap<FName, DBehavior*>::Pair* pair = nullptr;
while (it.NextPair(pair))
arc(pair->Key.GetChars(), pair->Value);
}
@ -243,7 +243,7 @@ FSerializer& Serialize(FSerializer& arc, const char* key, TMap<FName, DObject*>&
const char* k = nullptr;
while ((k = arc.GetKey()) != nullptr)
{
DObject* obj = nullptr;
DBehavior* obj = nullptr;
arc(k, obj);
value[k] = obj;
}