From 5e8c819a33abf09921f1a4ae440aed2d82f3727f Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 7 Nov 2016 11:53:49 +0100 Subject: [PATCH] - 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. --- src/scripting/decorate/olddecorations.cpp | 1 + src/scripting/decorate/thingdef_parse.cpp | 1 + src/scripting/thingdef.h | 3 ++- src/scripting/thingdef_properties.cpp | 15 +++++++++++---- src/scripting/zscript/zcc_compile.cpp | 2 +- .../static/zscript/heretic/hereticartifacts.txt | 2 +- wadsrc/static/zscript/strife/strifeitems.txt | 8 ++++---- 7 files changed, 21 insertions(+), 11 deletions(-) diff --git a/src/scripting/decorate/olddecorations.cpp b/src/scripting/decorate/olddecorations.cpp index 75e49dbaa..6ccd0051a 100644 --- a/src/scripting/decorate/olddecorations.cpp +++ b/src/scripting/decorate/olddecorations.cpp @@ -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 diff --git a/src/scripting/decorate/thingdef_parse.cpp b/src/scripting/decorate/thingdef_parse.cpp index 430895060..07da3cf57 100644 --- a/src/scripting/decorate/thingdef_parse.cpp +++ b/src/scripting/decorate/thingdef_parse.cpp @@ -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 != '}') diff --git a/src/scripting/thingdef.h b/src/scripting/thingdef.h index b2d34231d..6529059e6 100644 --- a/src/scripting/thingdef.h +++ b/src/scripting/thingdef.h @@ -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); } diff --git a/src/scripting/thingdef_properties.cpp b/src/scripting/thingdef_properties.cpp index 6f1455e43..aa4508950 100644 --- a/src/scripting/thingdef_properties.cpp +++ b/src/scripting/thingdef_properties.cpp @@ -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; diff --git a/src/scripting/zscript/zcc_compile.cpp b/src/scripting/zscript/zcc_compile.cpp index 49711afb2..981dcbc2a 100644 --- a/src/scripting/zscript/zcc_compile.cpp +++ b/src/scripting/zscript/zcc_compile.cpp @@ -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; diff --git a/wadsrc/static/zscript/heretic/hereticartifacts.txt b/wadsrc/static/zscript/heretic/hereticartifacts.txt index 94271c8cd..e239748ff 100644 --- a/wadsrc/static/zscript/heretic/hereticartifacts.txt +++ b/wadsrc/static/zscript/heretic/hereticartifacts.txt @@ -55,7 +55,7 @@ Class ArtiTomeOfPower : PowerupGiver native +FLOATBOB Inventory.PickupFlash "PickupFlash"; Inventory.Icon "ARTIPWBK"; - Powerup.Type "Weaponlevel2"; + Powerup.Type "PowerWeaponlevel2"; Inventory.PickupMessage "$TXT_ARTITOMEOFPOWER"; Tag "$TAG_ARTITOMEOFPOWER"; } diff --git a/wadsrc/static/zscript/strife/strifeitems.txt b/wadsrc/static/zscript/strife/strifeitems.txt index 3d8b4af54..cfc939413 100644 --- a/wadsrc/static/zscript/strife/strifeitems.txt +++ b/wadsrc/static/zscript/strife/strifeitems.txt @@ -198,7 +198,7 @@ class ShadowArmor : PowerupGiver RenderStyle "Translucent"; Tag "$TAG_SHADOWARMOR"; Inventory.MaxAmount 2; - Powerup.Type "Shadow"; + Powerup.Type "PowerShadow"; Inventory.Icon "I_SHD1"; Inventory.PickupSound "misc/i_pkup"; Inventory.PickupMessage "$TXT_SHADOWARMOR"; @@ -222,7 +222,7 @@ class EnvironmentalSuit : PowerupGiver +INVENTORY.INVBAR -INVENTORY.FANCYPICKUPSOUND Inventory.MaxAmount 5; - Powerup.Type "Mask"; + Powerup.Type "PowerMask"; Tag "$TAG_ENVSUIT"; Inventory.Icon "I_MASK"; Inventory.PickupSound "misc/i_pkup"; @@ -353,7 +353,7 @@ class Targeter : PowerupGiver +INVENTORY.INVBAR -INVENTORY.FANCYPICKUPSOUND Tag "$TAG_TARGETER"; - Powerup.Type "Targeter"; + Powerup.Type "PowerTargeter"; Inventory.MaxAmount 5; Inventory.Icon "I_TARG"; Inventory.PickupSound "misc/i_pkup"; @@ -478,7 +478,7 @@ class Scanner : PowerupGiver native Inventory.MaxAmount 1; Tag "$TAG_SCANNER"; Inventory.Icon "I_PMUP"; - Powerup.Type "Scanner"; + Powerup.Type "PowerScanner"; Inventory.PickupSound "misc/i_pkup"; Inventory.PickupMessage "$TXT_SCANNER"; }