- corrected the export signatures of several script exports to contain the correct classes, so that the fudging in FindFunction could be removed.

- fixed PARAM_ACTION_PROLOGUE to assign correct types to the implicit pointers. It gave the actual class to the wrong one, which until now did not matter because all functions were using 'Actor', regardless of actual class association.
- fixed the definition of IceChunk and removed some redundant code here. Since A_FreezeDeathChunks already calls SetState, which in turn calls the state's action function, there is no need to call it again explicitly.
This commit is contained in:
Christoph Oelckers 2016-12-02 18:52:58 +01:00
parent 1e01e6e4df
commit fbf8084999
8 changed files with 56 additions and 87 deletions

View file

@ -13,7 +13,6 @@
#include "r_data/r_translate.h"
static FRandom pr_freezedeath ("FreezeDeath");
static FRandom pr_icesettics ("IceSetTics");
static FRandom pr_freeze ("FreezeDeathChunks");
@ -121,36 +120,6 @@ DEFINE_ACTION_FUNCTION(AActor, A_FreezeDeath)
return 0;
}
//============================================================================
//
// A_IceSetTics
//
//============================================================================
void IceSetTics(AActor *self)
{
int floor;
self->tics = 70 + (pr_icesettics() & 63);
floor = P_GetThingFloorType(self);
if (Terrains[floor].DamageMOD == NAME_Fire)
{
self->tics >>= 2;
}
else if (Terrains[floor].DamageMOD == NAME_Ice)
{
self->tics <<= 1;
}
}
DEFINE_ACTION_FUNCTION(AActor, A_IceSetTics)
{
PARAM_SELF_PROLOGUE(AActor);
IceSetTics(self);
return 0;
}
//============================================================================
//
// A_FreezeDeathChunks
@ -193,7 +162,6 @@ DEFINE_ACTION_FUNCTION(AActor, A_FreezeDeathChunks)
mo->Vel.X = pr_freeze.Random2() / 128.;
mo->Vel.Y = pr_freeze.Random2() / 128.;
mo->Vel.Z = (mo->Z() - self->Z()) / self->Height * 4;
IceSetTics(mo); // set a random tic wait
mo->RenderStyle = self->RenderStyle;
mo->Alpha = self->Alpha;
}

View file

@ -114,7 +114,7 @@ static void BridgeOrbit(AActor *self)
self->ceilingz = self->target->ceilingz;
}
DEFINE_ACTION_FUNCTION(AActor, A_BridgeOrbit)
DEFINE_ACTION_FUNCTION(ABridgeBall, A_BridgeOrbit)
{
PARAM_SELF_PROLOGUE(AActor);
BridgeOrbit(self);
@ -122,7 +122,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_BridgeOrbit)
}
DEFINE_ACTION_FUNCTION(AActor, A_BridgeInit)
DEFINE_ACTION_FUNCTION(ACustomBridge, A_BridgeInit)
{
PARAM_SELF_PROLOGUE(AActor);
PARAM_CLASS_DEF(balltype, AActor);

View file

@ -402,9 +402,9 @@ 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(AActor, A_SpawnSingleItem)
DEFINE_ACTION_FUNCTION(ASpecialSpot, A_SpawnSingleItem)
{
PARAM_SELF_PROLOGUE(AActor);
PARAM_SELF_PROLOGUE(ASpecialSpot);
PARAM_CLASS_NOT_NULL(cls, AActor);
PARAM_INT_DEF (fail_sp)
PARAM_INT_DEF (fail_co)

View file

@ -1773,9 +1773,9 @@ DEFINE_ACTION_FUNCTION(AActor, A_CustomComboAttack)
// State jump function
//
//==========================================================================
DEFINE_ACTION_FUNCTION(AActor, A_JumpIfNoAmmo)
DEFINE_ACTION_FUNCTION(AStateProvider, A_JumpIfNoAmmo)
{
PARAM_ACTION_PROLOGUE(AActor);
PARAM_ACTION_PROLOGUE(AStateProvider);
PARAM_STATE_ACTION(jump);
if (!ACTION_CALL_FROM_PSPRITE() || self->player->ReadyWeapon == nullptr)
@ -1844,9 +1844,9 @@ static void AimBulletMissile(AActor *proj, AActor *puff, int flags, bool temp, b
}
}
DEFINE_ACTION_FUNCTION(AActor, A_FireBullets)
DEFINE_ACTION_FUNCTION(AStateProvider, A_FireBullets)
{
PARAM_ACTION_PROLOGUE(AActor);
PARAM_ACTION_PROLOGUE(AStateProvider);
PARAM_ANGLE (spread_xy);
PARAM_ANGLE (spread_z);
PARAM_INT (numbullets);
@ -1974,9 +1974,9 @@ enum FP_Flags
FPF_TRANSFERTRANSLATION = 2,
FPF_NOAUTOAIM = 4,
};
DEFINE_ACTION_FUNCTION(AActor, A_FireCustomMissile)
DEFINE_ACTION_FUNCTION(AStateProvider, A_FireCustomMissile)
{
PARAM_ACTION_PROLOGUE(AActor);
PARAM_ACTION_PROLOGUE(AStateProvider);
PARAM_CLASS (ti, AActor);
PARAM_ANGLE_DEF (angle);
PARAM_BOOL_DEF (useammo);
@ -2051,9 +2051,9 @@ enum
CPF_STEALARMOR = 32,
};
DEFINE_ACTION_FUNCTION(AActor, A_CustomPunch)
DEFINE_ACTION_FUNCTION(AStateProvider, A_CustomPunch)
{
PARAM_ACTION_PROLOGUE(AActor);
PARAM_ACTION_PROLOGUE(AStateProvider);
PARAM_INT (damage);
PARAM_BOOL_DEF (norandom);
PARAM_INT_DEF (flags);
@ -2155,9 +2155,9 @@ DEFINE_ACTION_FUNCTION(AActor, A_CustomPunch)
// customizable railgun attack function
//
//==========================================================================
DEFINE_ACTION_FUNCTION(AActor, A_RailAttack)
DEFINE_ACTION_FUNCTION(AStateProvider, A_RailAttack)
{
PARAM_ACTION_PROLOGUE(AActor);
PARAM_ACTION_PROLOGUE(AStateProvider);
PARAM_INT (damage);
PARAM_INT_DEF (spawnofs_xy);
PARAM_BOOL_DEF (useammo);
@ -4443,9 +4443,9 @@ DEFINE_ACTION_FUNCTION(AActor, CheckIfInTargetLOS)
//
//===========================================================================
DEFINE_ACTION_FUNCTION(AActor, A_CheckForReload)
DEFINE_ACTION_FUNCTION(AStateProvider, A_CheckForReload)
{
PARAM_ACTION_PROLOGUE(AActor);
PARAM_ACTION_PROLOGUE(AStateProvider);
if ( self->player == NULL || self->player->ReadyWeapon == NULL )
{
@ -4496,9 +4496,9 @@ DEFINE_ACTION_FUNCTION(AActor, A_CheckForReload)
//
//===========================================================================
DEFINE_ACTION_FUNCTION(AActor, A_ResetReloadCounter)
DEFINE_ACTION_FUNCTION(AStateProvider, A_ResetReloadCounter)
{
PARAM_ACTION_PROLOGUE(AActor);
PARAM_ACTION_PROLOGUE(AStateProvider);
if (self->player == NULL || self->player->ReadyWeapon == NULL)
return 0;

View file

@ -828,7 +828,7 @@ void DoReadyWeapon(AActor *self)
DEFINE_ACTION_FUNCTION(AStateProvider, A_WeaponReady)
{
PARAM_ACTION_PROLOGUE(AActor);
PARAM_ACTION_PROLOGUE(AStateProvider);
PARAM_INT_DEF(flags);
DoReadyWeaponToSwitch(self, !(flags & WRF_NoSwitch));
@ -960,7 +960,7 @@ static void P_CheckWeaponButtons (player_t *player)
DEFINE_ACTION_FUNCTION(AStateProvider, A_ReFire)
{
PARAM_ACTION_PROLOGUE(AActor);
PARAM_ACTION_PROLOGUE(AStateProvider);
PARAM_STATE_ACTION_DEF(state);
A_ReFire(self, state);
return 0;
@ -998,7 +998,7 @@ void A_ReFire(AActor *self, FState *state)
DEFINE_ACTION_FUNCTION(AStateProvider, A_ClearReFire)
{
PARAM_ACTION_PROLOGUE(AActor);
PARAM_ACTION_PROLOGUE(AStateProvider);
player_t *player = self->player;
if (NULL != player)
@ -1020,7 +1020,7 @@ DEFINE_ACTION_FUNCTION(AStateProvider, A_ClearReFire)
DEFINE_ACTION_FUNCTION(AStateProvider, A_CheckReload)
{
PARAM_ACTION_PROLOGUE(AActor);
PARAM_ACTION_PROLOGUE(AStateProvider);
if (self->player != NULL)
{
@ -1208,7 +1208,7 @@ DEFINE_ACTION_FUNCTION(AActor, OverlayID)
DEFINE_ACTION_FUNCTION(AStateProvider, A_Lower)
{
PARAM_ACTION_PROLOGUE(AActor);
PARAM_ACTION_PROLOGUE(AStateProvider);
player_t *player = self->player;
DPSprite *psp;
@ -1254,9 +1254,9 @@ DEFINE_ACTION_FUNCTION(AStateProvider, A_Lower)
//
//---------------------------------------------------------------------------
DEFINE_ACTION_FUNCTION(AActor, A_Raise)
DEFINE_ACTION_FUNCTION(AStateProvider, A_Raise)
{
PARAM_ACTION_PROLOGUE(AActor);
PARAM_ACTION_PROLOGUE(AStateProvider);
if (self == nullptr)
{
@ -1368,7 +1368,7 @@ enum GF_Flags
DEFINE_ACTION_FUNCTION(AStateProvider, A_GunFlash)
{
PARAM_ACTION_PROLOGUE(AActor);
PARAM_ACTION_PROLOGUE(AStateProvider);
PARAM_STATE_ACTION_DEF(flash);
PARAM_INT_DEF(flags);

View file

@ -583,35 +583,24 @@ FPropertyInfo *FindProperty(const char * string)
AFuncDesc *FindFunction(PStruct *cls, const char * string)
{
for (int i = 0; i < 2; i++)
int min = 0, max = AFTable.Size() - 1;
while (min <= max)
{
// Since many functions have been declared with Actor as owning class, despite being members of something else, let's hack around this until they have been fixed or exported.
// Since most of these are expected to be scriptified anyway, there's no point fixing them all before they get exported.
if (i == 1)
int mid = (min + max) / 2;
int lexval = stricmp(cls->TypeName.GetChars(), AFTable[mid].ClassName + 1);
if (lexval == 0) lexval = stricmp(string, AFTable[mid].FuncName);
if (lexval == 0)
{
if (!cls->IsKindOf(RUNTIME_CLASS(PClassActor))) break;
cls = RUNTIME_CLASS(AActor);
return &AFTable[mid];
}
int min = 0, max = AFTable.Size() - 1;
while (min <= max)
else if (lexval > 0)
{
int mid = (min + max) / 2;
int lexval = stricmp(cls->TypeName.GetChars(), AFTable[mid].ClassName + 1);
if (lexval == 0) lexval = stricmp(string, AFTable[mid].FuncName);
if (lexval == 0)
{
return &AFTable[mid];
}
else if (lexval > 0)
{
min = mid + 1;
}
else
{
max = mid - 1;
}
min = mid + 1;
}
else
{
max = mid - 1;
}
}
return nullptr;

View file

@ -1140,8 +1140,8 @@ class AActor;
// callingstate - State this action was called from
#define PARAM_ACTION_PROLOGUE(type) \
PARAM_PROLOGUE; \
PARAM_OBJECT (self, type); \
PARAM_OBJECT (stateowner, AActor) \
PARAM_OBJECT (self, AActor); \
PARAM_OBJECT (stateowner, type) \
PARAM_POINTER (stateinfo, FStateParamInfo) \
// Number of action paramaters

View file

@ -21,12 +21,24 @@ class IceChunk : Actor
+NOBLOCKMAP
+MOVEWITHSECTOR
}
native void A_IceSetTics ();
void A_IceSetTics ()
{
tics = 70 + (random[IceTics]() & 63);
Name dtype = GetFloorTerrain().DamageMOD;
if (dtype == 'Fire')
{
tics >>= 2;
}
else if (dtype == 'Ice')
{
tics <<= 1;
}
}
States
{
Spawn:
ICEC A 1;
ICEC ABCD 10 A_IceSetTics;
Stop;
}