From 694b48423aecddad90d7c0cc7e3b0005ed42a5f3 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 27 Apr 2017 10:52:00 +0200 Subject: [PATCH] - fixed initialization of classes so that AllActorClasses only gets initialized when the game knows what is an actor and what is not. This could result in lost states for weapons because the weapon class did not get added to the array. --- src/dobjtype.cpp | 18 +++++++++++++----- src/dobjtype.h | 2 +- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/dobjtype.cpp b/src/dobjtype.cpp index ad745843e3..5f109e418c 100644 --- a/src/dobjtype.cpp +++ b/src/dobjtype.cpp @@ -220,6 +220,14 @@ void PClass::StaticInit () { ((ClassReg *)*probe)->RegisterClass (); } + probe.Reset(); + for(auto cls : AllClasses) + { + if (cls->IsDescendantOf(RUNTIME_CLASS(AActor))) + { + PClassActor::AllActorClasses.Push(static_cast(cls)); + } + } // Keep built-in classes in consistant order. I did this before, though // I'm not sure if this is really necessary to maintain any sort of sync. @@ -344,7 +352,7 @@ PClass *ClassReg::RegisterClass() PClass *cls = new PClass; SetupClass(cls); - cls->InsertIntoHash(); + cls->InsertIntoHash(true); if (ParentType != nullptr) { cls->ParentClass = ParentType->RegisterClass(); @@ -379,7 +387,7 @@ void ClassReg::SetupClass(PClass *cls) // //========================================================================== -void PClass::InsertIntoHash () +void PClass::InsertIntoHash (bool native) { auto k = ClassMap.CheckKey(TypeName); if (k != nullptr) @@ -390,7 +398,7 @@ void PClass::InsertIntoHash () { ClassMap[TypeName] = this; } - if (IsDescendantOf(RUNTIME_CLASS(AActor))) + if (!native && IsDescendantOf(RUNTIME_CLASS(AActor))) { PClassActor::AllActorClasses.Push(static_cast(this)); } @@ -690,7 +698,7 @@ PClass *PClass::CreateDerivedClass(FName name, unsigned int size) if (!notnew) { - type->InsertIntoHash(); + type->InsertIntoHash(false); } return type; } @@ -759,7 +767,7 @@ PClass *PClass::FindClassTentative(FName name) Derive(type, name); type->Size = TentativeClass; - type->InsertIntoHash(); + type->InsertIntoHash(false); return type; } diff --git a/src/dobjtype.h b/src/dobjtype.h index 22d44a2348..12a6ae287f 100644 --- a/src/dobjtype.h +++ b/src/dobjtype.h @@ -75,7 +75,7 @@ public: // The rest are all functions and static data ---------------- PClass(); ~PClass(); - void InsertIntoHash(); + void InsertIntoHash(bool native); DObject *CreateNew(); PClass *CreateDerivedClass(FName name, unsigned int size);