- took InitializeDefaults out of PClass and moved it to PClassActor.

Like so many other parts, this created a hard dependency of the low level code on very invasive game content.
This commit is contained in:
Christoph Oelckers 2020-04-11 19:25:32 +02:00
commit f02c5c0a56
8 changed files with 120 additions and 120 deletions

View file

@ -77,7 +77,8 @@ PClassActor *DecoDerivedClass(const FScriptPosition &sc, PClassActor *parent, FN
{
sc.Message(MSG_ERROR, "Parent class %s of %s not accessible to DECORATE", parent->TypeName.GetChars(), typeName.GetChars());
}
PClassActor *type = static_cast<PClassActor *>(parent->CreateDerivedClass(typeName, parent->Size));
bool newlycreated;
PClassActor *type = static_cast<PClassActor *>(parent->CreateDerivedClass(typeName, parent->Size, &newlycreated));
if (type == nullptr)
{
FString newname = typeName.GetChars();
@ -94,14 +95,15 @@ PClassActor *DecoDerivedClass(const FScriptPosition &sc, PClassActor *parent, FN
// Due to backwards compatibility issues this cannot be an unconditional error.
sc.Message(MSG_WARNING, "Tried to define class '%s' more than once. Renaming class to '%s'", typeName.GetChars(), newname.GetChars());
}
type = static_cast<PClassActor *>(parent->CreateDerivedClass(newname, parent->Size));
type = static_cast<PClassActor *>(parent->CreateDerivedClass(newname, parent->Size, &newlycreated));
if (type == nullptr)
{
// This we cannot handle cleanly anymore. Let's just abort and forget about the odd mod out that was this careless.
sc.Message(MSG_FATAL, "Tried to define class '%s' more than twice in the same file.", typeName.GetChars());
}
}
if (newlycreated) type->InitializeDefaults();
if (type != nullptr)
{
// [ZZ] DECORATE classes are always play

View file

@ -474,10 +474,11 @@ void LoadActors()
I_Error("%d errors while parsing DECORATE scripts", FScriptPosition::ErrorCounter);
}
FScriptPosition::ResetErrorCounter();
for (int i = PClassActor::AllActorClasses.Size() - 1; i >= 0; i--)
// AllActorClasses hasn'T been set up yet.
for (int i = PClass::AllClasses.Size() - 1; i >= 0; i--)
{
auto ti = PClassActor::AllActorClasses[i];
auto ti = (PClassActor*)PClass::AllClasses[i];
if (!ti->IsDescendantOf(RUNTIME_CLASS(AActor))) continue;
if (ti->Size == TentativeClass)
{
if (ti->bOptional)