diff --git a/src/actor.h b/src/actor.h index b6d67cd18..ffcae818c 100644 --- a/src/actor.h +++ b/src/actor.h @@ -640,7 +640,6 @@ public: AActor &operator= (const AActor &other); ~AActor (); - virtual void Finalize(FStateDefinitions &statedef); virtual void OnDestroy() override; virtual void Serialize(FSerializer &arc) override; virtual void PostSerialize() override; diff --git a/src/g_inventory/a_pickups.cpp b/src/g_inventory/a_pickups.cpp index 1399915ee..a63030a3b 100644 --- a/src/g_inventory/a_pickups.cpp +++ b/src/g_inventory/a_pickups.cpp @@ -54,12 +54,6 @@ EXTERN_CVAR(Bool, sv_unlimited_pickup) -void AInventory::Finalize(FStateDefinitions &statedef) -{ - Super::Finalize(statedef); - flags |= MF_SPECIAL; -} - IMPLEMENT_CLASS(AInventory, false, true) IMPLEMENT_POINTERS_START(AInventory) diff --git a/src/g_inventory/a_pickups.h b/src/g_inventory/a_pickups.h index 7e4ad03f1..ca11da98d 100644 --- a/src/g_inventory/a_pickups.h +++ b/src/g_inventory/a_pickups.h @@ -70,7 +70,6 @@ class AInventory : public AActor HAS_OBJECT_POINTERS public: - virtual void Finalize(FStateDefinitions &statedef) override; virtual void Serialize(FSerializer &arc) override; virtual void OnDestroy() override; virtual void Tick() override; diff --git a/src/g_inventory/a_weapons.cpp b/src/g_inventory/a_weapons.cpp index 8758a132d..94e65a33c 100644 --- a/src/g_inventory/a_weapons.cpp +++ b/src/g_inventory/a_weapons.cpp @@ -101,45 +101,6 @@ TMap Weapons_hton; static int ntoh_cmp(const void *a, const void *b); -//=========================================================================== -// -// -// -//=========================================================================== - -void AWeapon::Finalize(FStateDefinitions &statedef) -{ - Super::Finalize(statedef); - FState *ready = FindState(NAME_Ready); - FState *select = FindState(NAME_Select); - FState *deselect = FindState(NAME_Deselect); - FState *fire = FindState(NAME_Fire); - auto TypeName = GetClass()->TypeName; - - // Consider any weapon without any valid state abstract and don't output a warning - // This is for creating base classes for weapon groups that only set up some properties. - if (ready || select || deselect || fire) - { - if (!ready) - { - I_Error("Weapon %s doesn't define a ready state.", TypeName.GetChars()); - } - if (!select) - { - I_Error("Weapon %s doesn't define a select state.", TypeName.GetChars()); - } - if (!deselect) - { - I_Error("Weapon %s doesn't define a deselect state.", TypeName.GetChars()); - } - if (!fire) - { - I_Error("Weapon %s doesn't define a fire state.", TypeName.GetChars()); - } - } -} - - //=========================================================================== // // AWeapon :: Serialize diff --git a/src/g_inventory/a_weapons.h b/src/g_inventory/a_weapons.h index 4c498f7c2..39179999f 100644 --- a/src/g_inventory/a_weapons.h +++ b/src/g_inventory/a_weapons.h @@ -159,7 +159,6 @@ public: bool bAltFire; // *** only accessed from ZScript. Set when this weapon's alternate fire is used. bool bDehAmmo; - void Finalize(FStateDefinitions &statedef) override; void Serialize(FSerializer &arc) override; enum diff --git a/src/info.cpp b/src/info.cpp index cfa6b067b..00a66b45b 100644 --- a/src/info.cpp +++ b/src/info.cpp @@ -365,29 +365,6 @@ bool PClassActor::SetReplacement(FName replaceName) return true; } -//========================================================================== -// -// PClassActor :: Finalize -// -// Installs the parsed states and does some sanity checking -// -//========================================================================== - -void AActor::Finalize(FStateDefinitions &statedef) -{ - try - { - statedef.FinishStates(GetClass()); - } - catch (CRecoverableError &) - { - statedef.MakeStateDefines(nullptr); - throw; - } - statedef.InstallStates(GetClass(), this); - statedef.MakeStateDefines(nullptr); -} - //========================================================================== // // PClassActor :: RegisterIDs diff --git a/src/p_local.h b/src/p_local.h index dcc682807..8e4c415a2 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -316,6 +316,7 @@ enum // P_AimLineAttack flags ALF_CHECKCONVERSATION = 8, ALF_NOFRIENDS = 16, ALF_PORTALRESTRICT = 32, // only work through portals with a global offset (to be used for stuff that cannot remember the calculated FTranslatedLineTarget info) + ALF_NOWEAPONCHECK = 64, // ignore NOAUTOAIM flag on a player's weapon. }; enum // P_LineAttack flags diff --git a/src/scripting/decorate/thingdef_parse.cpp b/src/scripting/decorate/thingdef_parse.cpp index eb553028d..d3d633551 100644 --- a/src/scripting/decorate/thingdef_parse.cpp +++ b/src/scripting/decorate/thingdef_parse.cpp @@ -1187,7 +1187,7 @@ static void ParseActor(FScanner &sc, PNamespace *ns) } try { - GetDefaultByType(info)->Finalize(bag.statedef); + FinalizeClass(info, bag.statedef); } catch (CRecoverableError &err) { diff --git a/src/scripting/thingdef.cpp b/src/scripting/thingdef.cpp index 95206801e..4ca9a2eb5 100644 --- a/src/scripting/thingdef.cpp +++ b/src/scripting/thingdef.cpp @@ -51,6 +51,8 @@ #include "v_text.h" #include "backend/codegen.h" #include "stats.h" +#include "info.h" +#include "thingdef.h" // EXTERNAL FUNCTION PROTOTYPES -------------------------------------------- void InitThingdef(); @@ -60,6 +62,69 @@ void InitThingdef(); static TMap StateSourceLines; static FScriptPosition unknownstatesource("unknown file", 0); + +//========================================================================== +// +// PClassActor :: Finalize +// +// Installs the parsed states and does some sanity checking +// +//========================================================================== + +void FinalizeClass(PClass *ccls, FStateDefinitions &statedef) +{ + if (!ccls->IsDescendantOf(NAME_Actor)) return; + auto cls = static_cast(ccls); + try + { + statedef.FinishStates(cls); + } + catch (CRecoverableError &) + { + statedef.MakeStateDefines(nullptr); + throw; + } + auto def = GetDefaultByType(cls); + statedef.InstallStates(cls, def); + statedef.MakeStateDefines(nullptr); + + if (cls->IsDescendantOf(NAME_Inventory)) + { + def->flags |= MF_SPECIAL; + } + + if (cls->IsDescendantOf(NAME_Weapon)) + { + FState *ready = def->FindState(NAME_Ready); + FState *select = def->FindState(NAME_Select); + FState *deselect = def->FindState(NAME_Deselect); + FState *fire = def->FindState(NAME_Fire); + auto TypeName = cls->TypeName; + + // Consider any weapon without any valid state abstract and don't output a warning + // This is for creating base classes for weapon groups that only set up some properties. + if (ready || select || deselect || fire) + { + if (!ready) + { + I_Error("Weapon %s doesn't define a ready state.", TypeName.GetChars()); + } + if (!select) + { + I_Error("Weapon %s doesn't define a select state.", TypeName.GetChars()); + } + if (!deselect) + { + I_Error("Weapon %s doesn't define a deselect state.", TypeName.GetChars()); + } + if (!fire) + { + I_Error("Weapon %s doesn't define a fire state.", TypeName.GetChars()); + } + } + } +} + //========================================================================== // // Saves the state's source lines for error messages during postprocessing diff --git a/src/scripting/thingdef.h b/src/scripting/thingdef.h index 0d59dce5c..b26ddd1d7 100644 --- a/src/scripting/thingdef.h +++ b/src/scripting/thingdef.h @@ -68,6 +68,7 @@ struct FFlagDef int varflags; }; +void FinalizeClass(PClass *cls, FStateDefinitions &statedef); FFlagDef *FindFlag (const PClass *type, const char *part1, const char *part2, bool strict = false); void HandleDeprecatedFlags(AActor *defaults, PClassActor *info, bool set, int index); bool CheckDeprecatedFlags(const AActor *actor, PClassActor *info, int index); diff --git a/src/scripting/zscript/zcc_compile.cpp b/src/scripting/zscript/zcc_compile.cpp index a5b8d875a..ab31ee05f 100644 --- a/src/scripting/zscript/zcc_compile.cpp +++ b/src/scripting/zscript/zcc_compile.cpp @@ -3105,7 +3105,7 @@ void ZCCCompiler::CompileStates() } try { - GetDefaultByType(c->ClassType())->Finalize(statedef); + FinalizeClass(c->ClassType(), statedef); } catch (CRecoverableError &err) { diff --git a/wadsrc/static/zscript/constants.txt b/wadsrc/static/zscript/constants.txt index 9ea4375c6..a1248b35c 100644 --- a/wadsrc/static/zscript/constants.txt +++ b/wadsrc/static/zscript/constants.txt @@ -884,6 +884,7 @@ enum EAimFlags ALF_CHECKCONVERSATION = 8, ALF_NOFRIENDS = 16, ALF_PORTALRESTRICT = 32, // only work through portals with a global offset (to be used for stuff that cannot remember the calculated FTranslatedLineTarget info) + ALF_NOWEAPONCHECK = 64, // ignore NOAUTOAIM flag on a player's weapon. } enum ELineAttackFlags