- fixed checks in Powerup.Type property to properly deal with the differences between DECORATE and ZScript.

- properly initialize Baggage everywhere it gets used.
- fixed a few items with incorrect Powerup.Type settings that got flagged by the above changes.
This commit is contained in:
Christoph Oelckers 2016-11-07 11:53:49 +01:00
commit 5e8c819a33
7 changed files with 21 additions and 11 deletions

View file

@ -158,6 +158,7 @@ void ParseOldDecoration(FScanner &sc, EDefinitionType def)
type = DecoDerivedClass(FScriptPosition(sc), parent, typeName);
ResetBaggage(&bag, parent);
bag.Info = type;
bag.fromDecorate = true;
#ifdef _DEBUG
bag.ClassName = type->TypeName;
#endif

View file

@ -1064,6 +1064,7 @@ static void ParseActor(FScanner &sc)
PClassActor *info = NULL;
Baggage bag;
bag.fromDecorate = true;
info = ParseActorHeader(sc, &bag);
sc.MustGetToken('{');
while (sc.MustGetAnyToken(), sc.TokenType != '}')

View file

@ -117,7 +117,7 @@ struct Baggage
PClassActor *Info;
bool DropItemSet;
bool StateSet;
bool fromZScript;
bool fromDecorate;
int CurrentState;
int Lumpnum;
FStateDefinitions statedef;
@ -132,6 +132,7 @@ inline void ResetBaggage (Baggage *bag, PClassActor *stateclass)
bag->DropItemList = NULL;
bag->DropItemSet = false;
bag->CurrentState = 0;
bag->fromDecorate = true;
bag->StateSet = false;
bag->statedef.MakeStateDefines(stateclass);
}

View file

@ -2422,11 +2422,18 @@ DEFINE_CLASS_PROPERTY_PREFIX(powerup, type, S, PowerupGiver)
// Yuck! What was I thinking when I decided to prepend "Power" to the name?
// Now it's too late to change it...
PClassActor *cls = PClass::FindActor(str);
if (cls == NULL || (!cls->IsDescendantOf(RUNTIME_CLASS(APowerup)) && !bag.fromZScript))
if (cls == nullptr || !cls->IsDescendantOf(RUNTIME_CLASS(APowerup)))
{
FString st;
st.Format("%s%s", strnicmp(str, "power", 5)? "Power" : "", str);
cls = FindClassTentativePowerup(st);
if (bag.fromDecorate)
{
FString st;
st.Format("%s%s", strnicmp(str, "power", 5) ? "Power" : "", str);
cls = FindClassTentativePowerup(st);
}
else
{
I_Error("Unknown powerup type %s", str);
}
}
defaults->PowerupType = cls;

View file

@ -1897,7 +1897,7 @@ void ZCCCompiler::InitDefaults()
bag.Info = ti;
bag.DropItemSet = false;
bag.StateSet = false;
bag.fromZScript = true;
bag.fromDecorate = false;
bag.CurrentState = 0;
bag.Lumpnum = c->cls->SourceLump;
bag.DropItemList = nullptr;