- 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
|
|
@ -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<FState *, FScriptPosition> 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<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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue