mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-24 21:21:04 +00:00
- Split thingdef.cpp into several files so that the state and property code
no longer gets in the way of the main parser. - Changed A_MissileAttack, A_MeleeAttack and A_ComboAttack so that they use metadata. Now all the hack code associated with these functions can be removed. SVN r538 (trunk)
This commit is contained in:
parent
50f75b6e8a
commit
8f6fdc1d21
14 changed files with 5416 additions and 5348 deletions
|
@ -1,4 +1,8 @@
|
|||
May 28, 2007 (Changes by Graf Zahl)
|
||||
- Split thingdef.cpp into several files so that the state and property code
|
||||
no longer gets in the way of the main parser.
|
||||
- Changed A_MissileAttack, A_MeleeAttack and A_ComboAttack so that they use
|
||||
metadata. Now all the hack code associated with these functions can be removed.
|
||||
- Fixed: deadthings.txt contained a superfluous ';' which created parsing errors
|
||||
with my changed code.
|
||||
- Cleaned up DECORATE parser a little - moved the old style parsing code into its
|
||||
|
|
|
@ -11,6 +11,7 @@ WEAPON(Light)
|
|||
ACTOR(ChangeFlag)
|
||||
ACTOR(MeleeAttack)
|
||||
ACTOR(MissileAttack)
|
||||
ACTOR(ComboAttack)
|
||||
ACTOR(BulletAttack)
|
||||
ACTOR(ScreamAndUnblock)
|
||||
ACTOR(ActiveAndUnblock)
|
||||
|
|
|
@ -49,7 +49,6 @@ FDecalLib DecalLibrary;
|
|||
|
||||
static fixed_t ReadScale ();
|
||||
static TArray<BYTE> DecalTranslations;
|
||||
extern TArray<char*> DecalNames;
|
||||
|
||||
// A decal group holds multiple decals and returns one randomly
|
||||
// when GetDecal() is called.
|
||||
|
@ -355,19 +354,12 @@ void FDecalLib::ReadAllDecals ()
|
|||
{
|
||||
AActor *def = (AActor*)GetDefaultByType (PClass::m_RuntimeActors[i]);
|
||||
|
||||
intptr_t v = (intptr_t)def->DecalGenerator;
|
||||
if (v > 0 && v <= (intptr_t)DecalNames.Size())
|
||||
FName v = ENamedName(intptr_t(def->DecalGenerator));
|
||||
if (v.IsValidName())
|
||||
{
|
||||
def->DecalGenerator = ScanTreeForName (DecalNames[v-1], Root);
|
||||
def->DecalGenerator = ScanTreeForName (v, Root);
|
||||
}
|
||||
}
|
||||
// Free the array which is no longer needed!
|
||||
for (i = 0; i < DecalNames.Size(); i++)
|
||||
{
|
||||
delete[] DecalNames[i];
|
||||
}
|
||||
DecalNames.Clear();
|
||||
DecalNames.ShrinkToFit();
|
||||
}
|
||||
|
||||
void FDecalLib::ReadDecals ()
|
||||
|
|
|
@ -77,7 +77,6 @@ enum
|
|||
TK_For,
|
||||
TK_If,
|
||||
TK_Return,
|
||||
TK_States,
|
||||
TK_Switch,
|
||||
TK_Until,
|
||||
TK_While,
|
||||
|
|
2472
src/sc_man_scanner.h
2472
src/sc_man_scanner.h
File diff suppressed because it is too large
Load diff
|
@ -68,7 +68,6 @@ std2:
|
|||
'goto' { RET(TK_Goto); }
|
||||
'if' { RET(TK_If); }
|
||||
'return' { RET(TK_Return); }
|
||||
'states' { RET(TK_States); }
|
||||
'switch' { RET(TK_Switch); }
|
||||
'until' { RET(TK_Until); }
|
||||
'volatile' { RET(TK_Volatile); }
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,9 +1,13 @@
|
|||
#ifndef __THINGDEF_H
|
||||
#define __THINGDEF_H
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// This class is for storing a name inside a const PClass* field without
|
||||
// generating compiler warnings. It does not manipulate data in any other
|
||||
// way.
|
||||
//
|
||||
//==========================================================================
|
||||
class fuglyname : public FName
|
||||
{
|
||||
public:
|
||||
|
@ -21,23 +25,12 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
// All state parameters are stored in this array now.
|
||||
extern TArray<int> StateParameters;
|
||||
extern TArray<FName> JumpParameters;
|
||||
|
||||
|
||||
int ParseExpression (bool _not, PClass *cls);
|
||||
|
||||
int EvalExpressionI (int id, AActor *self, const PClass *cls=NULL);
|
||||
float EvalExpressionF (int id, AActor *self, const PClass *cls=NULL);
|
||||
bool EvalExpressionN (int id, AActor *self, const PClass *cls=NULL);
|
||||
|
||||
void ClearStateLabels();
|
||||
void AddState (const char * statename, FState * state);
|
||||
FState * FindState(AActor * actor, const PClass * type, const char * name);
|
||||
void InstallStates(FActorInfo *info, AActor *defaults);
|
||||
void MakeStateDefines(const FStateLabels *list);
|
||||
FState *P_GetState(AActor *self, FState *CallingState, int offset);
|
||||
//==========================================================================
|
||||
//
|
||||
// Dropitem list
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
struct FDropItem
|
||||
{
|
||||
|
@ -49,6 +42,86 @@ struct FDropItem
|
|||
|
||||
FDropItem *GetDropItems(const PClass * cls);
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// Extra info maintained while defining an actor.
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
struct Baggage
|
||||
{
|
||||
FActorInfo *Info;
|
||||
bool DropItemSet;
|
||||
bool StateSet;
|
||||
int CurrentState;
|
||||
|
||||
FDropItem *DropItemList;
|
||||
};
|
||||
|
||||
inline void ResetBaggage (Baggage *bag)
|
||||
{
|
||||
bag->DropItemList = NULL;
|
||||
bag->DropItemSet = false;
|
||||
bag->CurrentState = 0;
|
||||
bag->StateSet = false;
|
||||
}
|
||||
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// Action function lookup
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
struct AFuncDesc
|
||||
{
|
||||
const char *Name;
|
||||
actionf_p Function;
|
||||
};
|
||||
|
||||
AFuncDesc * FindFunction(const char * string);
|
||||
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// State parser
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
extern TArray<int> StateParameters;
|
||||
extern TArray<FName> JumpParameters;
|
||||
|
||||
void ClearStateLabels();
|
||||
void AddState (const char * statename, FState * state);
|
||||
FState * FindState(AActor * actor, const PClass * type, const char * name);
|
||||
void InstallStates(FActorInfo *info, AActor *defaults);
|
||||
void MakeStateDefines(const FStateLabels *list);
|
||||
FState *P_GetState(AActor *self, FState *CallingState, int offset);
|
||||
int FinishStates (FActorInfo *actor, AActor *defaults, Baggage &bag);
|
||||
int ParseStates(FActorInfo * actor, AActor * defaults, Baggage &bag);
|
||||
FState *CheckState(PClass *type);
|
||||
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// Property parser
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
void ParseActorProperty(Baggage &bag);
|
||||
void ParseActorFlag (Baggage &bag, int mod);
|
||||
void FinishActor(FActorInfo *info, Baggage &bag);
|
||||
|
||||
void ParseConstant (PSymbolTable * symt, PClass *cls);
|
||||
void ParseEnum (PSymbolTable * symt, PClass *cls);
|
||||
|
||||
|
||||
int ParseExpression (bool _not, PClass *cls);
|
||||
|
||||
int EvalExpressionI (int id, AActor *self, const PClass *cls=NULL);
|
||||
float EvalExpressionF (int id, AActor *self, const PClass *cls=NULL);
|
||||
bool EvalExpressionN (int id, AActor *self, const PClass *cls=NULL);
|
||||
|
||||
|
||||
// A truly awful hack to get to the state that called an action function
|
||||
// without knowing whether it has been called from a weapon or actor.
|
||||
|
@ -64,6 +137,10 @@ enum
|
|||
ACMETA_ExplosionDamage,
|
||||
ACMETA_ExplosionRadius,
|
||||
ACMETA_DontHurtShooter,
|
||||
ACMETA_MeleeSound,
|
||||
ACMETA_MeleeDamage,
|
||||
ACMETA_MissileName,
|
||||
ACMETA_MissileHeight,
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@
|
|||
|
||||
// EXTERNAL FUNCTION PROTOTYPES --------------------------------------------
|
||||
|
||||
void ProcessActor();
|
||||
void ParseActor();
|
||||
void ParseClass();
|
||||
void ParseGlobalConst();
|
||||
void ParseGlobalEnum();
|
||||
|
@ -96,27 +96,27 @@ static void ParseDecorate ()
|
|||
break;
|
||||
|
||||
case TK_Class:
|
||||
ParseClass();
|
||||
ParseClass ();
|
||||
break;
|
||||
|
||||
case TK_Const:
|
||||
ParseGlobalConst();
|
||||
ParseConstant (&RUNTIME_CLASS(AActor)->Symbols, RUNTIME_CLASS(AActor));
|
||||
break;
|
||||
|
||||
case TK_Enum:
|
||||
ParseGlobalEnum();
|
||||
ParseEnum (&RUNTIME_CLASS(AActor)->Symbols, RUNTIME_CLASS(AActor));
|
||||
break;
|
||||
|
||||
case TK_Pickup:
|
||||
ParseOldDecoration(DEF_Pickup);
|
||||
ParseOldDecoration (DEF_Pickup);
|
||||
break;
|
||||
|
||||
case TK_Breakable:
|
||||
ParseOldDecoration(DEF_BreakableDecoration);
|
||||
ParseOldDecoration (DEF_BreakableDecoration);
|
||||
break;
|
||||
|
||||
case TK_Projectile:
|
||||
ParseOldDecoration(DEF_Projectile);
|
||||
ParseOldDecoration (DEF_Projectile);
|
||||
break;
|
||||
|
||||
case ';':
|
||||
|
@ -132,7 +132,7 @@ static void ParseDecorate ()
|
|||
// so let's do a special case for this.
|
||||
if (SC_Compare("ACTOR"))
|
||||
{
|
||||
ProcessActor ();
|
||||
ParseActor ();
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
2663
src/thingdef/thingdef_properties.cpp
Normal file
2663
src/thingdef/thingdef_properties.cpp
Normal file
File diff suppressed because it is too large
Load diff
1183
src/thingdef/thingdef_states.cpp
Normal file
1183
src/thingdef/thingdef_states.cpp
Normal file
File diff suppressed because it is too large
Load diff
|
@ -202,14 +202,27 @@ void A_UnsetFloat(AActor * self)
|
|||
static void DoAttack (AActor *self, bool domelee, bool domissile)
|
||||
{
|
||||
int index=CheckIndex(4);
|
||||
int MeleeDamage;
|
||||
int MeleeSound;
|
||||
FName MissileName;
|
||||
fixed_t MissileHeight;
|
||||
|
||||
if (index<0) return;
|
||||
if (self->target == NULL) return;
|
||||
|
||||
int MeleeDamage=StateParameters[index];
|
||||
int MeleeSound=StateParameters[index+1];
|
||||
FName MissileName=(ENamedName)StateParameters[index+2];
|
||||
fixed_t MissileHeight=StateParameters[index+3];
|
||||
if (index > 0)
|
||||
{
|
||||
MeleeDamage=StateParameters[index];
|
||||
MeleeSound=StateParameters[index+1];
|
||||
MissileName=(ENamedName)StateParameters[index+2];
|
||||
MissileHeight=StateParameters[index+3];
|
||||
}
|
||||
else
|
||||
{
|
||||
MeleeDamage = self->GetClass()->Meta.GetMetaInt (ACMETA_MeleeDamage, 0);
|
||||
MeleeSound = self->GetClass()->Meta.GetMetaInt (ACMETA_MeleeSound, 0);
|
||||
MissileName=(ENamedName) self->GetClass()->Meta.GetMetaInt (ACMETA_MissileName, NAME_None);
|
||||
MissileHeight= self->GetClass()->Meta.GetMetaFixed (ACMETA_MissileHeight, 32*FRACUNIT);
|
||||
}
|
||||
|
||||
A_FaceTarget (self);
|
||||
if (domelee && MeleeDamage>0 && self->CheckMeleeRange ())
|
||||
|
|
|
@ -115,6 +115,9 @@ class Actor extends Thinker
|
|||
action native A_FireAssaultGun();
|
||||
action native A_CheckTerrain();
|
||||
|
||||
action native A_MissileAttack();
|
||||
action native A_MeleeAttack();
|
||||
action native A_ComboAttack();
|
||||
action native A_BulletAttack();
|
||||
action native A_PlaySound(sound whattoplay);
|
||||
action native A_PlayWeaponSound(sound whattoplay);
|
||||
|
|
|
@ -4306,10 +4306,18 @@
|
|||
RelativePath=".\src\thingdef\thingdef_main.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\thingdef\thingdef_properties.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\thingdef\thingdef_specials.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\thingdef\thingdef_states.cpp"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</Filter>
|
||||
<Filter
|
||||
|
|
Loading…
Reference in a new issue