mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-24 13:01:47 +00:00
- moved the 'Finalize' methods back into a single function in the parser code.
It has been like this initially but was changed when ZDoom gained an overly complicated polymorphic class descriptor object that required a lot of support code. All these complications have long been removed but these methods remained. Since they prevent a class from being moved to the script side entirely they had to be removed. This was the last major blocker to make Weapon a purely scripted class, the only remaining native method is Serialize which is of no concern for the coming work.
This commit is contained in:
parent
7012179904
commit
00a48b09e5
12 changed files with 70 additions and 73 deletions
|
@ -640,7 +640,6 @@ public:
|
||||||
AActor &operator= (const AActor &other);
|
AActor &operator= (const AActor &other);
|
||||||
~AActor ();
|
~AActor ();
|
||||||
|
|
||||||
virtual void Finalize(FStateDefinitions &statedef);
|
|
||||||
virtual void OnDestroy() override;
|
virtual void OnDestroy() override;
|
||||||
virtual void Serialize(FSerializer &arc) override;
|
virtual void Serialize(FSerializer &arc) override;
|
||||||
virtual void PostSerialize() override;
|
virtual void PostSerialize() override;
|
||||||
|
|
|
@ -54,12 +54,6 @@
|
||||||
|
|
||||||
EXTERN_CVAR(Bool, sv_unlimited_pickup)
|
EXTERN_CVAR(Bool, sv_unlimited_pickup)
|
||||||
|
|
||||||
void AInventory::Finalize(FStateDefinitions &statedef)
|
|
||||||
{
|
|
||||||
Super::Finalize(statedef);
|
|
||||||
flags |= MF_SPECIAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
IMPLEMENT_CLASS(AInventory, false, true)
|
IMPLEMENT_CLASS(AInventory, false, true)
|
||||||
|
|
||||||
IMPLEMENT_POINTERS_START(AInventory)
|
IMPLEMENT_POINTERS_START(AInventory)
|
||||||
|
|
|
@ -70,7 +70,6 @@ class AInventory : public AActor
|
||||||
HAS_OBJECT_POINTERS
|
HAS_OBJECT_POINTERS
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual void Finalize(FStateDefinitions &statedef) override;
|
|
||||||
virtual void Serialize(FSerializer &arc) override;
|
virtual void Serialize(FSerializer &arc) override;
|
||||||
virtual void OnDestroy() override;
|
virtual void OnDestroy() override;
|
||||||
virtual void Tick() override;
|
virtual void Tick() override;
|
||||||
|
|
|
@ -101,45 +101,6 @@ TMap<PClassActor *, int> Weapons_hton;
|
||||||
|
|
||||||
static int ntoh_cmp(const void *a, const void *b);
|
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
|
// AWeapon :: Serialize
|
||||||
|
|
|
@ -159,7 +159,6 @@ public:
|
||||||
bool bAltFire; // *** only accessed from ZScript. Set when this weapon's alternate fire is used.
|
bool bAltFire; // *** only accessed from ZScript. Set when this weapon's alternate fire is used.
|
||||||
bool bDehAmmo;
|
bool bDehAmmo;
|
||||||
|
|
||||||
void Finalize(FStateDefinitions &statedef) override;
|
|
||||||
void Serialize(FSerializer &arc) override;
|
void Serialize(FSerializer &arc) override;
|
||||||
|
|
||||||
enum
|
enum
|
||||||
|
|
23
src/info.cpp
23
src/info.cpp
|
@ -365,29 +365,6 @@ bool PClassActor::SetReplacement(FName replaceName)
|
||||||
return true;
|
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
|
// PClassActor :: RegisterIDs
|
||||||
|
|
|
@ -316,6 +316,7 @@ enum // P_AimLineAttack flags
|
||||||
ALF_CHECKCONVERSATION = 8,
|
ALF_CHECKCONVERSATION = 8,
|
||||||
ALF_NOFRIENDS = 16,
|
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_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
|
enum // P_LineAttack flags
|
||||||
|
|
|
@ -1187,7 +1187,7 @@ static void ParseActor(FScanner &sc, PNamespace *ns)
|
||||||
}
|
}
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
GetDefaultByType(info)->Finalize(bag.statedef);
|
FinalizeClass(info, bag.statedef);
|
||||||
}
|
}
|
||||||
catch (CRecoverableError &err)
|
catch (CRecoverableError &err)
|
||||||
{
|
{
|
||||||
|
|
|
@ -51,6 +51,8 @@
|
||||||
#include "v_text.h"
|
#include "v_text.h"
|
||||||
#include "backend/codegen.h"
|
#include "backend/codegen.h"
|
||||||
#include "stats.h"
|
#include "stats.h"
|
||||||
|
#include "info.h"
|
||||||
|
#include "thingdef.h"
|
||||||
|
|
||||||
// EXTERNAL FUNCTION PROTOTYPES --------------------------------------------
|
// EXTERNAL FUNCTION PROTOTYPES --------------------------------------------
|
||||||
void InitThingdef();
|
void InitThingdef();
|
||||||
|
@ -60,6 +62,69 @@ void InitThingdef();
|
||||||
static TMap<FState *, FScriptPosition> StateSourceLines;
|
static TMap<FState *, FScriptPosition> StateSourceLines;
|
||||||
static FScriptPosition unknownstatesource("unknown file", 0);
|
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<PClassActor*>(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
|
// Saves the state's source lines for error messages during postprocessing
|
||||||
|
|
|
@ -68,6 +68,7 @@ struct FFlagDef
|
||||||
int varflags;
|
int varflags;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void FinalizeClass(PClass *cls, FStateDefinitions &statedef);
|
||||||
FFlagDef *FindFlag (const PClass *type, const char *part1, const char *part2, bool strict = false);
|
FFlagDef *FindFlag (const PClass *type, const char *part1, const char *part2, bool strict = false);
|
||||||
void HandleDeprecatedFlags(AActor *defaults, PClassActor *info, bool set, int index);
|
void HandleDeprecatedFlags(AActor *defaults, PClassActor *info, bool set, int index);
|
||||||
bool CheckDeprecatedFlags(const AActor *actor, PClassActor *info, int index);
|
bool CheckDeprecatedFlags(const AActor *actor, PClassActor *info, int index);
|
||||||
|
|
|
@ -3105,7 +3105,7 @@ void ZCCCompiler::CompileStates()
|
||||||
}
|
}
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
GetDefaultByType(c->ClassType())->Finalize(statedef);
|
FinalizeClass(c->ClassType(), statedef);
|
||||||
}
|
}
|
||||||
catch (CRecoverableError &err)
|
catch (CRecoverableError &err)
|
||||||
{
|
{
|
||||||
|
|
|
@ -884,6 +884,7 @@ enum EAimFlags
|
||||||
ALF_CHECKCONVERSATION = 8,
|
ALF_CHECKCONVERSATION = 8,
|
||||||
ALF_NOFRIENDS = 16,
|
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_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
|
enum ELineAttackFlags
|
||||||
|
|
Loading…
Reference in a new issue