- scriptified two of the Acolyte's functions.

- added a DActorIterator class.
- fixed: It was not possible to have functions of the same name in two different classes because the name they were searched for was not qualified by the class. Changed so that the class name is included now, but to avoid renaming several hundreds of functions all at once, if the search fails, it will repeat with 'Actor' as class name.

This commit contains preparations for scriptifying Hexen's Dragon, but that doesn't work yet so it's not included.
This commit is contained in:
Christoph Oelckers 2016-11-16 01:36:21 +01:00
parent a2e17c0ab5
commit 633da6e5d8
32 changed files with 334 additions and 260 deletions

View File

@ -881,7 +881,6 @@ set( NOT_COMPILED_SOURCE_FILES
g_hexen/a_clericholy.cpp
g_hexen/a_clericmace.cpp
g_hexen/a_clericstaff.cpp
g_hexen/a_dragon.cpp
g_hexen/a_fighteraxe.cpp
g_hexen/a_fighterhammer.cpp
g_hexen/a_fighterplayer.cpp

View File

@ -1442,6 +1442,10 @@ public:
return base;
}
void Reinit()
{
base = nullptr;
}
private:
AActor *base;
int id;

View File

@ -185,17 +185,17 @@ DECLARE_ACTION(A_FireRailgun)
// Default ammo use of the various weapon attacks
static AmmoPerAttack AmmoPerAttacks[] = {
{ &A_Punch_VMPtr, 0},
{ &A_FirePistol_VMPtr, 1},
{ &A_FireShotgun_VMPtr, 1},
{ &A_FireShotgun2_VMPtr, 2},
{ &A_FireCGun_VMPtr, 1},
{ &A_FireMissile_VMPtr, 1},
{ &A_Saw_VMPtr, 0},
{ &A_FirePlasma_VMPtr, 1},
{ &A_FireBFG_VMPtr, -1}, // uses deh.BFGCells
{ &A_FireOldBFG_VMPtr, 1},
{ &A_FireRailgun_VMPtr, 1},
{ &AActor_A_Punch_VMPtr, 0},
{ &AActor_A_FirePistol_VMPtr, 1},
{ &AActor_A_FireShotgun_VMPtr, 1},
{ &AActor_A_FireShotgun2_VMPtr, 2},
{ &AActor_A_FireCGun_VMPtr, 1},
{ &AActor_A_FireMissile_VMPtr, 1},
{ &AActor_A_Saw_VMPtr, 0},
{ &AActor_A_FirePlasma_VMPtr, 1},
{ &AActor_A_FireBFG_VMPtr, -1}, // uses deh.BFGCells
{ &AActor_A_FireOldBFG_VMPtr, 1},
{ &AActor_A_FireRailgun_VMPtr, 1},
{ NULL, 0}
};

View File

@ -14,7 +14,7 @@
static FRandom pr_spawnfly ("SpawnFly");
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_BrainSpit)
DEFINE_ACTION_FUNCTION(AActor, A_BrainSpit)
{
PARAM_SELF_PROLOGUE(AActor);
PARAM_CLASS_DEF(spawntype, AActor);

View File

@ -113,7 +113,7 @@ enum SAW_Flags
SF_STEALARMOR = 128,
};
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Saw)
DEFINE_ACTION_FUNCTION(AActor, A_Saw)
{
PARAM_ACTION_PROLOGUE(AActor);
PARAM_SOUND_DEF (fullsound)
@ -454,7 +454,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireMissile)
//
// A_FireSTGrenade: not exactly backported from ST, but should work the same
//
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FireSTGrenade)
DEFINE_ACTION_FUNCTION(AActor, A_FireSTGrenade)
{
PARAM_ACTION_PROLOGUE(AActor);
PARAM_CLASS_DEF(grenade, AActor);
@ -607,7 +607,7 @@ enum BFG_Flags
BFGF_MISSILEORIGIN = 2,
};
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_BFGSpray)
DEFINE_ACTION_FUNCTION(AActor, A_BFGSpray)
{
PARAM_SELF_PROLOGUE(AActor);
PARAM_CLASS_DEF (spraytype, AActor)

View File

@ -148,7 +148,7 @@ void AScriptedMarine::Tick ()
//
//============================================================================
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_M_Refire)
DEFINE_ACTION_FUNCTION(AActor, A_M_Refire)
{
PARAM_SELF_PROLOGUE(AActor);
PARAM_BOOL_DEF(ignoremissile);
@ -247,7 +247,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_MarineLook)
//
//============================================================================
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_M_Saw)
DEFINE_ACTION_FUNCTION(AActor, A_M_Saw)
{
PARAM_SELF_PROLOGUE(AActor);
PARAM_SOUND_DEF (fullsound)
@ -345,7 +345,7 @@ static void MarinePunch(AActor *self, int damagemul)
}
}
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_M_Punch)
DEFINE_ACTION_FUNCTION(AActor, A_M_Punch)
{
PARAM_SELF_PROLOGUE(AActor);
PARAM_INT(mult);
@ -382,7 +382,7 @@ void P_GunShot2 (AActor *mo, bool accurate, DAngle pitch, PClassActor *pufftype)
//
//============================================================================
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_M_FirePistol)
DEFINE_ACTION_FUNCTION(AActor, A_M_FirePistol)
{
PARAM_SELF_PROLOGUE(AActor);
PARAM_BOOL(accurate);
@ -481,7 +481,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_M_FireShotgun2)
//
//============================================================================
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_M_FireCGun)
DEFINE_ACTION_FUNCTION(AActor, A_M_FireCGun)
{
PARAM_SELF_PROLOGUE(AActor);
PARAM_BOOL(accurate);

View File

@ -42,7 +42,7 @@ static FRandom pr_volcimpact ("VolcBallImpact");
//
//----------------------------------------------------------------------------
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_PodPain)
DEFINE_ACTION_FUNCTION(AActor, A_PodPain)
{
PARAM_SELF_PROLOGUE(AActor);
PARAM_CLASS_DEF (gootype, AActor)
@ -97,7 +97,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_RemovePod)
#define MAX_GEN_PODS 16
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_MakePod)
DEFINE_ACTION_FUNCTION(AActor, A_MakePod)
{
PARAM_SELF_PROLOGUE(AActor);
PARAM_CLASS_DEF(podtype, AActor)

View File

@ -59,7 +59,7 @@ extern bool P_AutoUseChaosDevice (player_t *player);
//
//----------------------------------------------------------------------------
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_StaffAttack)
DEFINE_ACTION_FUNCTION(AActor, A_StaffAttack)
{
PARAM_ACTION_PROLOGUE(AActor);
@ -245,7 +245,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireCrossbowPL2)
//
//---------------------------------------------------------------------------
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_GauntletAttack)
DEFINE_ACTION_FUNCTION(AActor, A_GauntletAttack)
{
PARAM_ACTION_PROLOGUE(AActor);

View File

@ -93,7 +93,7 @@ enum
//
//==========================================================================
DEFINE_ACTION_FUNCTION_PARAMS (AActor, A_Blast)
DEFINE_ACTION_FUNCTION (AActor, A_Blast)
{
PARAM_ACTION_PROLOGUE(AActor);
PARAM_INT_DEF (blastflags)

View File

@ -24,7 +24,7 @@ static FRandom pr_fswordflame ("FSwordFlame");
//
//============================================================================
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_DropWeaponPieces)
DEFINE_ACTION_FUNCTION(AActor, A_DropWeaponPieces)
{
PARAM_SELF_PROLOGUE(AActor);
PARAM_CLASS(p1, AActor);

View File

@ -255,7 +255,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_LightningZap)
//
//============================================================================
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_MLightningAttack)
DEFINE_ACTION_FUNCTION(AActor, A_MLightningAttack)
{
PARAM_ACTION_PROLOGUE(AActor);
PARAM_CLASS_DEF(floor, AActor);

View File

@ -119,7 +119,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_BridgeOrbit)
}
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_BridgeInit)
DEFINE_ACTION_FUNCTION(AActor, A_BridgeInit)
{
PARAM_SELF_PROLOGUE(AActor);
PARAM_CLASS_DEF(balltype, AActor);

View File

@ -377,7 +377,7 @@ void ASpecialSpot::Destroy()
// will build a list of all mace spots in the level and spawn a
// mace. The rest of the spots will do nothing.
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SpawnSingleItem)
DEFINE_ACTION_FUNCTION(AActor, A_SpawnSingleItem)
{
PARAM_SELF_PROLOGUE(AActor);
PARAM_CLASS (cls, AActor);

View File

@ -1923,7 +1923,7 @@ PClassWeapon *Net_ReadWeapon(BYTE **stream)
//
//===========================================================================
DEFINE_ACTION_FUNCTION_PARAMS(AWeapon, A_ZoomFactor)
DEFINE_ACTION_FUNCTION(AWeapon, A_ZoomFactor)
{
PARAM_ACTION_PROLOGUE(AActor);
PARAM_FLOAT_DEF(zoom);
@ -1951,7 +1951,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AWeapon, A_ZoomFactor)
//
//===========================================================================
DEFINE_ACTION_FUNCTION_PARAMS(AWeapon, A_SetCrosshair)
DEFINE_ACTION_FUNCTION(AWeapon, A_SetCrosshair)
{
PARAM_ACTION_PROLOGUE(AActor);
PARAM_INT(xhair);

View File

@ -84,47 +84,3 @@ DEFINE_ACTION_FUNCTION(AActor, A_AcolyteDie)
return 0;
}
//============================================================================
//
// A_BeShadowyFoe
//
//============================================================================
DEFINE_ACTION_FUNCTION(AActor, A_BeShadowyFoe)
{
PARAM_SELF_PROLOGUE(AActor);
self->RenderStyle = STYLE_Translucent;
self->Alpha = HR_SHADOW;
self->flags &= ~MF_FRIENDLY;
return 0;
}
//============================================================================
//
// A_AcolyteBits
//
//============================================================================
DEFINE_ACTION_FUNCTION(AActor, A_AcolyteBits)
{
PARAM_SELF_PROLOGUE(AActor);
if (self->SpawnFlags & MTF_SHADOW)
{
CALL_ACTION(A_BeShadowyFoe, self);
}
if (self->SpawnFlags & MTF_ALTSHADOW)
{
//self->flags |= MF_STRIFEx8000000;
if (self->flags & MF_SHADOW)
{
// I dunno.
}
else
{
self->RenderStyle.BlendOp = STYLEOP_None;
}
}
return 0;
}

View File

@ -144,7 +144,7 @@ enum
AMF_EMITFROMTARGET = 4,
};
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_AlertMonsters)
DEFINE_ACTION_FUNCTION(AActor, A_AlertMonsters)
{
PARAM_SELF_PROLOGUE(AActor);
PARAM_FLOAT_DEF(maxdist);
@ -246,7 +246,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_ShowElectricFlash)
//
//============================================================================
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FireArrow)
DEFINE_ACTION_FUNCTION(AActor, A_FireArrow)
{
PARAM_ACTION_PROLOGUE(AActor);
PARAM_CLASS(ti, AActor);
@ -686,7 +686,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_Burnination)
//
//============================================================================
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FireGrenade)
DEFINE_ACTION_FUNCTION(AActor, A_FireGrenade)
{
PARAM_ACTION_PROLOGUE(AActor);
PARAM_CLASS(grenadetype, AActor);

View File

@ -26,7 +26,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_Bang4Cloud)
// -------------------------------------------------------------------
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_GiveQuestItem)
DEFINE_ACTION_FUNCTION(AActor, A_GiveQuestItem)
{
PARAM_SELF_PROLOGUE(AActor);
PARAM_INT(questitem);

File diff suppressed because it is too large Load Diff

View File

@ -1942,7 +1942,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_Look)
//
//==========================================================================
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_LookEx)
DEFINE_ACTION_FUNCTION(AActor, A_LookEx)
{
PARAM_SELF_PROLOGUE(AActor);
PARAM_INT_DEF (flags)
@ -2159,7 +2159,7 @@ enum ChaseFlags
CHF_STOPIFBLOCKED = 256,
};
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Wander)
DEFINE_ACTION_FUNCTION(AActor, A_Wander)
{
PARAM_SELF_PROLOGUE(AActor);
PARAM_INT_DEF(flags);
@ -2801,7 +2801,7 @@ static bool P_CheckForResurrection(AActor *self, bool usevilestates)
//
//==========================================================================
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Chase)
DEFINE_ACTION_FUNCTION(AActor, A_Chase)
{
PARAM_SELF_PROLOGUE(AActor);
PARAM_STATE_DEF (melee)
@ -2840,7 +2840,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_VileChase)
return 0;
}
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_ExtChase)
DEFINE_ACTION_FUNCTION(AActor, A_ExtChase)
{
PARAM_SELF_PROLOGUE(AActor);
PARAM_BOOL (domelee);
@ -2980,7 +2980,7 @@ void A_FaceTarget(AActor *self)
A_Face(self, self->target);
}
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Face)
DEFINE_ACTION_FUNCTION(AActor, A_Face)
{
PARAM_SELF_PROLOGUE(AActor);
PARAM_OBJECT(faceto, AActor)

View File

@ -3098,6 +3098,13 @@ void AActor::RemoveFromHash ()
tid = 0;
}
DEFINE_ACTION_FUNCTION(AActor, RemoveFromHash)
{
PARAM_SELF_PROLOGUE(AActor);
self->RemoveFromHash();
return 0;
}
//==========================================================================
//
// P_IsTIDUsed
@ -6886,6 +6893,42 @@ void AActor::SetTranslation(const char *trname)
// silently ignore if the name does not exist, this would create some insane message spam otherwise.
}
class DActorIterator : public DObject, public NActorIterator
{
DECLARE_CLASS(DActorIterator, DObject)
public:
DActorIterator(PClassActor *cls= nullptr, int tid = 0)
: NActorIterator(cls, tid)
{
}
};
IMPLEMENT_CLASS(DActorIterator, false, false, false, false);
DEFINE_ACTION_FUNCTION(DActorIterator, Create)
{
PARAM_PROLOGUE;
PARAM_INT_DEF(tid);
PARAM_CLASS_DEF(type, AActor);
ACTION_RETURN_OBJECT(new DActorIterator(type, tid));
}
DEFINE_ACTION_FUNCTION(DActorIterator, Next)
{
PARAM_SELF_PROLOGUE(DActorIterator);
ACTION_RETURN_OBJECT(self->Next());
}
DEFINE_ACTION_FUNCTION(DActorIterator, Reinit)
{
PARAM_SELF_PROLOGUE(DActorIterator);
self->Reinit();
return 0;
}
DEFINE_ACTION_FUNCTION(AActor, deltaangle) // should this be global?
{
PARAM_PROLOGUE;
@ -6894,6 +6937,14 @@ DEFINE_ACTION_FUNCTION(AActor, deltaangle) // should this be global?
ACTION_RETURN_FLOAT(deltaangle(DAngle(a1), DAngle(a2)).Degrees);
}
DEFINE_ACTION_FUNCTION(AActor, absangle) // should this be global?
{
PARAM_PROLOGUE;
PARAM_FLOAT(a1);
PARAM_FLOAT(a2);
ACTION_RETURN_FLOAT(absangle(DAngle(a1), DAngle(a2)).Degrees);
}
DEFINE_ACTION_FUNCTION(AActor, Distance2D)
{
PARAM_SELF_PROLOGUE(AActor);

View File

@ -772,7 +772,7 @@ void DoReadyWeapon(AActor *self)
DoReadyWeaponToGeneric(self, ~0);
}
DEFINE_ACTION_FUNCTION_PARAMS(AInventory, A_WeaponReady)
DEFINE_ACTION_FUNCTION(AStateProvider, A_WeaponReady)
{
PARAM_ACTION_PROLOGUE(AActor);
PARAM_INT_DEF(flags);
@ -904,7 +904,7 @@ static void P_CheckWeaponButtons (player_t *player)
//
//---------------------------------------------------------------------------
DEFINE_ACTION_FUNCTION_PARAMS(AInventory, A_ReFire)
DEFINE_ACTION_FUNCTION(AStateProvider, A_ReFire)
{
PARAM_ACTION_PROLOGUE(AActor);
PARAM_STATE_ACTION_DEF(state);
@ -942,7 +942,7 @@ void A_ReFire(AActor *self, FState *state)
}
}
DEFINE_ACTION_FUNCTION(AInventory, A_ClearReFire)
DEFINE_ACTION_FUNCTION(AStateProvider, A_ClearReFire)
{
PARAM_ACTION_PROLOGUE(AActor);
player_t *player = self->player;
@ -964,7 +964,7 @@ DEFINE_ACTION_FUNCTION(AInventory, A_ClearReFire)
//
//---------------------------------------------------------------------------
DEFINE_ACTION_FUNCTION(AInventory, A_CheckReload)
DEFINE_ACTION_FUNCTION(AStateProvider, A_CheckReload)
{
PARAM_ACTION_PROLOGUE(AActor);
@ -1152,7 +1152,7 @@ DEFINE_ACTION_FUNCTION(AActor, OverlayID)
//
//---------------------------------------------------------------------------
DEFINE_ACTION_FUNCTION(AInventory, A_Lower)
DEFINE_ACTION_FUNCTION(AStateProvider, A_Lower)
{
PARAM_ACTION_PROLOGUE(AActor);
@ -1200,7 +1200,7 @@ DEFINE_ACTION_FUNCTION(AInventory, A_Lower)
//
//---------------------------------------------------------------------------
DEFINE_ACTION_FUNCTION(AInventory, A_Raise)
DEFINE_ACTION_FUNCTION(AActor, A_Raise)
{
PARAM_ACTION_PROLOGUE(AActor);
@ -1241,7 +1241,7 @@ DEFINE_ACTION_FUNCTION(AInventory, A_Raise)
//
//---------------------------------------------------------------------------
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Overlay)
DEFINE_ACTION_FUNCTION(AActor, A_Overlay)
{
PARAM_ACTION_PROLOGUE(AActor);
PARAM_INT (layer);
@ -1261,7 +1261,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Overlay)
ACTION_RETURN_BOOL(true);
}
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_ClearOverlays)
DEFINE_ACTION_FUNCTION(AActor, A_ClearOverlays)
{
PARAM_SELF_PROLOGUE(AActor);
PARAM_INT_DEF(start);
@ -1312,7 +1312,7 @@ enum GF_Flags
GFF_NOEXTCHANGE = 1,
};
DEFINE_ACTION_FUNCTION_PARAMS(AInventory, A_GunFlash)
DEFINE_ACTION_FUNCTION(AStateProvider, A_GunFlash)
{
PARAM_ACTION_PROLOGUE(AActor);
PARAM_STATE_ACTION_DEF(flash);
@ -1415,7 +1415,7 @@ void P_GunShot (AActor *mo, bool accurate, PClassActor *pufftype, DAngle pitch)
P_LineAttack (mo, angle, PLAYERMISSILERANGE, pitch, damage, NAME_Hitscan, pufftype);
}
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Light)
DEFINE_ACTION_FUNCTION(AActor, A_Light)
{
PARAM_SELF_PROLOGUE(AActor);
PARAM_INT(light);

View File

@ -343,7 +343,7 @@ DEFINE_ACTION_FUNCTION(AActor, FindState)
}
// same as above but context aware.
DEFINE_ACTION_FUNCTION_PARAMS(AActor, ResolveState)
DEFINE_ACTION_FUNCTION(AActor, ResolveState)
{
PARAM_ACTION_PROLOGUE(AActor);
PARAM_STATE_ACTION(newstate);

View File

@ -1626,7 +1626,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_PlayerScream)
//
//----------------------------------------------------------------------------
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SkullPop)
DEFINE_ACTION_FUNCTION(AActor, A_SkullPop)
{
PARAM_SELF_PROLOGUE(AActor);
PARAM_CLASS_DEF(spawntype, APlayerChunk);

View File

@ -7962,7 +7962,7 @@ FxExpression *FxReturnStatement::Resolve(FCompileContext &ctx)
else
{
// If we already know the real return type we need at least try to cast the value to its proper type (unless in an anonymous function.)
if (ctx.ReturnProto != nullptr && ctx.Function->SymbolName != NAME_None)
if (ctx.ReturnProto != nullptr && ctx.ReturnProto->ReturnTypes.Size() > 0 && ctx.Function->SymbolName != NAME_None)
{
Value = new FxTypeCast(Value, ctx.ReturnProto->ReturnTypes[0], false, false);
Value = Value->Resolve(ctx);

View File

@ -147,7 +147,7 @@ inline void ResetBaggage (Baggage *bag, PClassActor *stateclass)
//
//==========================================================================
AFuncDesc *FindFunction(const char * string);
AFuncDesc *FindFunction(PClass *cls, const char * string);
FxExpression *ParseExpression(FScanner &sc, PClassActor *cls, bool mustresolve = false);

View File

@ -571,28 +571,33 @@ FPropertyInfo *FindProperty(const char * string)
//
//==========================================================================
AFuncDesc *FindFunction(const char * string)
AFuncDesc *FindFunction(PClass *cls, const char * string)
{
int min = 0, max = AFTable.Size()-1;
while (min <= max)
for (int i = 0; i < 2; i++)
{
int mid = (min + max) / 2;
int lexval = stricmp (string, AFTable[mid].Name);
if (lexval == 0)
if (i == 1 && !cls->IsDescendantOf(RUNTIME_CLASS(AActor))) break;
FStringf fullname("%s_%s", i == 0 ? cls->TypeName.GetChars() : "Actor", string);
int min = 0, max = AFTable.Size() - 1;
while (min <= max)
{
return &AFTable[mid];
}
else if (lexval > 0)
{
min = mid + 1;
}
else
{
max = mid - 1;
int mid = (min + max) / 2;
int lexval = stricmp(fullname, AFTable[mid].Name + 1);
if (lexval == 0)
{
return &AFTable[mid];
}
else if (lexval > 0)
{
min = mid + 1;
}
else
{
max = mid - 1;
}
}
}
return NULL;
return nullptr;
}
@ -627,7 +632,7 @@ static int propcmp(const void * a, const void * b)
static int funccmp(const void * a, const void * b)
{
return stricmp( ((AFuncDesc*)a)->Name, ((AFuncDesc*)b)->Name);
return stricmp(((AFuncDesc*)a)->Name + 1, ((AFuncDesc*)b)->Name + 1); // +1 to get past the prefix letter of the native class name, which gets omitted by the FName for the class.
}
//==========================================================================

View File

@ -1020,26 +1020,21 @@ struct AFuncDesc
// Macros to handle action functions. These are here so that I don't have to
// change every single use in case the parameters change.
#define DECLARE_ACTION(name) extern VMNativeFunction *name##_VMPtr;
#define DECLARE_ACTION(name) extern VMNativeFunction *AActor_##name##_VMPtr;
// This distinction is here so that CALL_ACTION produces errors when trying to
// access a function that requires parameters.
#define DEFINE_ACTION_FUNCTION(cls, name) \
static int AF_##name(VM_ARGS); \
VMNativeFunction *name##_VMPtr; \
static const AFuncDesc cls##_##name##_Hook = { #name, AF_##name, &name##_VMPtr }; \
static int AF_##cls##_##name(VM_ARGS); \
VMNativeFunction *cls##_##name##_VMPtr; \
static const AFuncDesc cls##_##name##_Hook = { #cls "_" #name, AF_##cls##_##name, &cls##_##name##_VMPtr }; \
extern AFuncDesc const *const cls##_##name##_HookPtr; \
MSVC_ASEG AFuncDesc const *const cls##_##name##_HookPtr GCC_ASEG = &cls##_##name##_Hook; \
static int AF_##name(VM_ARGS)
#define DEFINE_ACTION_FUNCTION_PARAMS(cls, name) DEFINE_ACTION_FUNCTION(cls, name)
//#define DECLARE_PARAMINFO AActor *self, AActor *stateowner, FState *CallingState, int ParameterIndex, StateCallData *statecall
//#define PUSH_PARAMINFO self, stateowner, CallingState, ParameterIndex, statecall
static int AF_##cls##_##name(VM_ARGS)
class AActor;
void CallAction(VMFrameStack *stack, VMFunction *vmfunc, AActor *self);
#define CALL_ACTION(name, self) CallAction(stack, name##_VMPtr, self);
#define CALL_ACTION(name, self) CallAction(stack, AActor_##name##_VMPtr, self);
#define ACTION_RETURN_STATE(v) do { FState *state = v; if (numret > 0) { assert(ret != NULL); ret->SetPointer(state, ATAG_STATE); return 1; } return 0; } while(0)

View File

@ -2128,7 +2128,7 @@ void ZCCCompiler::InitFunctions()
if (f->Flags & ZCC_Native)
{
varflags |= VARF_Native;
afd = FindFunction(FName(f->Name).GetChars());
afd = FindFunction(c->Type(), FName(f->Name).GetChars());
if (afd == nullptr)
{
Error(f, "The function '%s' has not been exported from the executable.", FName(f->Name).GetChars());

View File

@ -63,7 +63,9 @@ class Actor : Thinker native
native static readonly<Actor> GetDefaultByType(class<Actor> cls);
native static float deltaangle(float ang1, float ang2);
native static float absangle(float ang1, float ang2);
native static float GetDefaultSpeed(class<Actor> type);
native void RemoveFromHash();
native float GetBobOffset(float frac = 0);
native void SetDamage(int dmg);
native static bool isDehState(state st);

View File

@ -20,6 +20,13 @@ class ThinkerIterator : Object native
native void Reinit();
}
class ActorIterator : Object native
{
native static ActorIterator Create(int tid, class<Actor> type = "Actor");
native Actor Next();
native void Reinit();
}
class DropItem : Object native
{
/* native fields listed for reference only for now

View File

@ -898,3 +898,22 @@ const HR_SHADOW = (0x6800 / 65536.);
// Hexen's TINTTAB is the same as Heretic's, just reversed.
const HX_SHADOW = (0x9800 / 65536.);
const HX_ALTSHADOW = (0x6800 / 65536.);
enum EMapThingFlags
{
MTF_AMBUSH = 0x0008, // Thing is deaf
MTF_DORMANT = 0x0010, // Thing is dormant (use Thing_Activate)
MTF_SINGLE = 0x0100, // Thing appears in single-player games
MTF_COOPERATIVE = 0x0200, // Thing appears in cooperative games
MTF_DEATHMATCH = 0x0400, // Thing appears in deathmatch games
MTF_SHADOW = 0x0800,
MTF_ALTSHADOW = 0x1000,
MTF_FRIENDLY = 0x2000,
MTF_STANDSTILL = 0x4000,
MTF_STRIFESOMETHING = 0x8000,
MTF_SECRET = 0x080000, // Secret pickup
MTF_NOINFIGHTING = 0x100000,
};

View File

@ -26,8 +26,6 @@ class Acolyte : StrifeHumanoid
Obituary "$OB_ACOLYTE";
}
native void A_BeShadowyFoe ();
native void A_AcolyteBits ();
native void A_AcolyteDie ();
States
@ -76,6 +74,44 @@ class Acolyte : StrifeHumanoid
GIBS L 1400;
Stop;
}
//============================================================================
//
// A_BeShadowyFoe
//
//============================================================================
void A_BeShadowyFoe()
{
A_SetRenderStyle(HR_SHADOW, STYLE_Translucent);
bFriendly = false;
}
//============================================================================
//
// A_AcolyteBits
//
//============================================================================
void A_AcolyteBits()
{
if (SpawnFlags & MTF_SHADOW)
{
A_BeShadowyFoe();
}
if (SpawnFlags & MTF_ALTSHADOW)
{
if (bShadow)
{
// I dunno.
}
else
{
A_SetRenderStyle(0, STYLE_None);
}
}
}
}