- more direct native entry points.

- disallow bool as a return value for direct native calls because it only sets the lowest 8 bits of the return register.
- changed return type for several functions from bool to int where the return type was the only thing blocking use as direct native call.
This commit is contained in:
Christoph Oelckers 2018-12-05 20:10:44 +01:00
parent 2e7e6cba9d
commit 494a113920
19 changed files with 284 additions and 262 deletions

View file

@ -484,7 +484,7 @@ size_t DObject::PointerSubstitution (DObject *old, DObject *notOld)
//
//==========================================================================
size_t DObject::StaticPointerSubstitution (AActor *old, AActor *notOld)
void DObject::StaticPointerSubstitution (AActor *old, AActor *notOld)
{
DObject *probe;
size_t changed = 0;
@ -521,8 +521,6 @@ size_t DObject::StaticPointerSubstitution (AActor *old, AActor *notOld)
{
if (sec.SoundTarget == old) sec.SoundTarget = notOld;
}
return changed;
}
//==========================================================================

View file

@ -254,7 +254,7 @@ public:
// This is only needed for swapping out PlayerPawns and absolutely nothing else!
virtual size_t PointerSubstitution (DObject *old, DObject *notOld);
static size_t StaticPointerSubstitution (AActor *old, AActor *notOld);
static void StaticPointerSubstitution (AActor *old, AActor *notOld);
PClass *GetClass() const
{

View file

@ -99,9 +99,6 @@ dirtype_t diags[4] =
double xspeed[8] = {1,SQRTHALF,0,-SQRTHALF,-1,-SQRTHALF,0,SQRTHALF};
double yspeed[8] = {0,SQRTHALF,1,SQRTHALF,0,-SQRTHALF,-1,-SQRTHALF};
void P_RandomChaseDir (AActor *actor);
//
// ENEMY THINKING
// Enemies are always spawned
@ -240,7 +237,7 @@ static void P_RecursiveSound(sector_t *sec, AActor *soundtarget, bool splash, AA
//
//----------------------------------------------------------------------------
void P_NoiseAlert (AActor *target, AActor *emitter, bool splash, double maxdist)
void P_NoiseAlert (AActor *emitter, AActor *target, bool splash, double maxdist)
{
if (emitter == NULL)
return;
@ -257,17 +254,6 @@ void P_NoiseAlert (AActor *target, AActor *emitter, bool splash, double maxdist)
}
}
DEFINE_ACTION_FUNCTION(AActor, SoundAlert)
{
PARAM_SELF_PROLOGUE(AActor);
PARAM_OBJECT(target, AActor);
PARAM_BOOL(splash);
PARAM_FLOAT(maxdist);
// Note that the emitter is self, not the target of the alert! Target can be NULL.
P_NoiseAlert(target, self, splash, maxdist);
return 0;
}
//----------------------------------------------------------------------------
//
// AActor :: CheckMeleeRange
@ -409,7 +395,7 @@ bool AActor::SuggestMissileAttack (double dist)
//
//=============================================================================
bool P_HitFriend(AActor * self)
int P_HitFriend(AActor * self)
{
FTranslatedLineTarget t;
@ -426,19 +412,13 @@ bool P_HitFriend(AActor * self)
return false;
}
DEFINE_ACTION_FUNCTION(AActor, HitFriend)
{
PARAM_SELF_PROLOGUE(AActor);
ACTION_RETURN_BOOL(P_HitFriend(self));
}
//
// P_Move
// Move in the current direction,
// returns false if the move is blocked.
//
bool P_Move (AActor *actor)
int P_Move (AActor *actor)
{
double tryx, tryy, deltax, deltay, origx, origy;
@ -670,12 +650,6 @@ bool P_Move (AActor *actor)
}
return true;
}
DEFINE_ACTION_FUNCTION(AActor, MonsterMove)
{
PARAM_SELF_PROLOGUE(AActor);
ACTION_RETURN_BOOL(P_Move(self));
}
//=============================================================================
//
@ -999,14 +973,6 @@ void P_NewChaseDir(AActor * actor)
}
DEFINE_ACTION_FUNCTION(AActor, NewChaseDir)
{
PARAM_SELF_PROLOGUE(AActor);
P_NewChaseDir(self);
return 0;
}
//=============================================================================
//
// P_RandomChaseDir
@ -1165,14 +1131,6 @@ void P_RandomChaseDir (AActor *actor)
actor->movedir = DI_NODIR; // cannot move
}
DEFINE_ACTION_FUNCTION(AActor, RandomChaseDir)
{
PARAM_SELF_PROLOGUE(AActor);
P_RandomChaseDir(self);
return 0;
}
//---------------------------------------------------------------------------
//
// P_IsVisible
@ -1182,7 +1140,7 @@ DEFINE_ACTION_FUNCTION(AActor, RandomChaseDir)
//
//---------------------------------------------------------------------------
bool P_IsVisible(AActor *lookee, AActor *other, INTBOOL allaround, FLookExParams *params)
int P_IsVisible(AActor *lookee, AActor *other, INTBOOL allaround, FLookExParams *params)
{
double maxdist;
double mindist;
@ -1230,15 +1188,6 @@ bool P_IsVisible(AActor *lookee, AActor *other, INTBOOL allaround, FLookExParams
return P_CheckSight(lookee, other, SF_SEEPASTSHOOTABLELINES);
}
DEFINE_ACTION_FUNCTION(AActor, IsVisible)
{
PARAM_SELF_PROLOGUE(AActor);
PARAM_OBJECT(other, AActor);
PARAM_BOOL(allaround);
PARAM_POINTER(params, FLookExParams);
ACTION_RETURN_BOOL(P_IsVisible(self, other, allaround, params));
}
//---------------------------------------------------------------------------
//
// FUNC P_LookForMonsters
@ -1248,7 +1197,7 @@ DEFINE_ACTION_FUNCTION(AActor, IsVisible)
#define MONS_LOOK_RANGE (20*64)
#define MONS_LOOK_LIMIT 64
bool P_LookForMonsters (AActor *actor)
int P_LookForMonsters (AActor *actor)
{
int count;
AActor *mo;
@ -1292,12 +1241,6 @@ bool P_LookForMonsters (AActor *actor)
return false;
}
DEFINE_ACTION_FUNCTION(AActor, LookForMonsters)
{
PARAM_SELF_PROLOGUE(AActor);
ACTION_RETURN_BOOL(P_LookForMonsters(self));
}
//============================================================================
//
// LookForTIDinBlock
@ -1369,7 +1312,7 @@ AActor *LookForTIDInBlock (AActor *lookee, int index, void *extparams)
//
//============================================================================
bool P_LookForTID (AActor *actor, INTBOOL allaround, FLookExParams *params)
int P_LookForTID (AActor *actor, INTBOOL allaround, FLookExParams *params)
{
AActor *other;
bool reachedend = false;
@ -1470,14 +1413,6 @@ bool P_LookForTID (AActor *actor, INTBOOL allaround, FLookExParams *params)
return false;
}
DEFINE_ACTION_FUNCTION(AActor, LookForTID)
{
PARAM_SELF_PROLOGUE(AActor);
PARAM_BOOL(allaround);
PARAM_POINTER(params, FLookExParams);
ACTION_RETURN_BOOL(P_LookForTID(self, allaround, params));
}
//============================================================================
//
// LookForEnemiesinBlock
@ -1575,7 +1510,7 @@ AActor *LookForEnemiesInBlock (AActor *lookee, int index, void *extparam)
//
//============================================================================
bool P_LookForEnemies (AActor *actor, INTBOOL allaround, FLookExParams *params)
int P_LookForEnemies (AActor *actor, INTBOOL allaround, FLookExParams *params)
{
AActor *other;
@ -1617,14 +1552,6 @@ bool P_LookForEnemies (AActor *actor, INTBOOL allaround, FLookExParams *params)
return false;
}
DEFINE_ACTION_FUNCTION(AActor, LookForEnemies)
{
PARAM_SELF_PROLOGUE(AActor);
PARAM_BOOL(allaround);
PARAM_POINTER(params, FLookExParams);
ACTION_RETURN_BOOL(P_LookForEnemies(self, allaround, params));
}
/*
================
@ -1636,7 +1563,7 @@ DEFINE_ACTION_FUNCTION(AActor, LookForEnemies)
================
*/
bool P_LookForPlayers (AActor *actor, INTBOOL allaround, FLookExParams *params)
int P_LookForPlayers (AActor *actor, INTBOOL allaround, FLookExParams *params)
{
int c;
int pnum;
@ -1812,14 +1739,6 @@ bool P_LookForPlayers (AActor *actor, INTBOOL allaround, FLookExParams *params)
}
}
DEFINE_ACTION_FUNCTION(AActor, LookForPlayers)
{
PARAM_SELF_PROLOGUE(AActor);
PARAM_BOOL(allaround);
PARAM_POINTER(params, FLookExParams);
ACTION_RETURN_BOOL(P_LookForPlayers(self, allaround, params));
}
//
// ACTION ROUTINES
//
@ -2166,14 +2085,6 @@ enum ChaseFlags
CHF_STOPIFBLOCKED = 256,
};
DEFINE_ACTION_FUNCTION(AActor, A_Wander)
{
PARAM_SELF_PROLOGUE(AActor);
PARAM_INT(flags);
A_Wander(self, flags);
return 0;
}
void A_Wander(AActor *self, int flags)
{
// [RH] Strife probably clears this flag somewhere, but I couldn't find where.
@ -2702,7 +2613,7 @@ bool P_CanResurrect(AActor *raiser, AActor *thing)
//
//==========================================================================
static bool P_CheckForResurrection(AActor *self, bool usevilestates)
bool P_CheckForResurrection(AActor *self, bool usevilestates)
{
const AActor *info;
AActor *temp;
@ -2848,18 +2759,19 @@ static bool P_CheckForResurrection(AActor *self, bool usevilestates)
return false;
}
//==========================================================================
//
// A_Chase and variations
//
//==========================================================================
// for internal use
void A_Chase(AActor *self)
{
A_DoChase(self, false, self->MeleeState, self->MissileState, true, gameinfo.nightmarefast, false, 0);
}
DEFINE_ACTION_FUNCTION(AActor, A_Chase)
{
PARAM_SELF_PROLOGUE(AActor);
PARAM_STATE (melee)
PARAM_STATE (missile)
PARAM_INT (flags)
PARAM_STATE(melee);
PARAM_STATE(missile);
PARAM_INT(flags);
if (melee != nullptr || missile != nullptr || flags != 0x40000000)
{
@ -2876,50 +2788,6 @@ DEFINE_ACTION_FUNCTION(AActor, A_Chase)
return 0;
}
DEFINE_ACTION_FUNCTION(AActor, A_FastChase)
{
PARAM_SELF_PROLOGUE(AActor);
A_DoChase(self, true, self->MeleeState, self->MissileState, true, true, false, 0);
return 0;
}
DEFINE_ACTION_FUNCTION(AActor, A_VileChase)
{
PARAM_SELF_PROLOGUE(AActor);
if (!P_CheckForResurrection(self, true))
{
A_DoChase(self, false, self->MeleeState, self->MissileState, true, gameinfo.nightmarefast, false, 0);
}
return 0;
}
DEFINE_ACTION_FUNCTION(AActor, A_ExtChase)
{
PARAM_SELF_PROLOGUE(AActor);
PARAM_BOOL (domelee);
PARAM_BOOL (domissile);
PARAM_BOOL (playactive);
PARAM_BOOL (nightmarefast);
// Now that A_Chase can handle state label parameters, this function has become rather useless...
A_DoChase(self, false,
domelee ? self->MeleeState : NULL, domissile ? self->MissileState : NULL,
playactive, nightmarefast, false, 0);
return 0;
}
DEFINE_ACTION_FUNCTION(AActor, A_CheckForResurrection)
{
PARAM_SELF_PROLOGUE(AActor);
ACTION_RETURN_BOOL(P_CheckForResurrection(self, false));
}
// for internal use
void A_Chase(AActor *self)
{
A_DoChase(self, false, self->MeleeState, self->MissileState, true, gameinfo.nightmarefast, false, 0);
}
//=============================================================================
//
// A_FaceTarget
@ -3039,21 +2907,6 @@ void A_FaceTarget(AActor *self)
A_Face(self, self->target);
}
DEFINE_ACTION_FUNCTION(AActor, A_Face)
{
PARAM_SELF_PROLOGUE(AActor);
PARAM_OBJECT(faceto, AActor)
PARAM_ANGLE(max_turn)
PARAM_ANGLE(max_pitch)
PARAM_ANGLE(ang_offset)
PARAM_ANGLE(pitch_offset)
PARAM_INT(flags)
PARAM_FLOAT(z_add)
A_Face(self, faceto, max_turn, max_pitch, ang_offset, pitch_offset, flags, z_add);
return 0;
}
//===========================================================================
//
// [RH] A_MonsterRail
@ -3174,7 +3027,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_Pain)
return 0;
}
bool CheckBossDeath (AActor *actor)
int CheckBossDeath (AActor *actor)
{
int i;
@ -3204,12 +3057,6 @@ bool CheckBossDeath (AActor *actor)
return true;
}
DEFINE_ACTION_FUNCTION(AActor, CheckBossDeath)
{
PARAM_SELF_PROLOGUE(AActor);
ACTION_RETURN_BOOL(CheckBossDeath(self));
}
//
// A_BossDeath
// Possibly trigger special effects if on a boss level
@ -3314,13 +3161,6 @@ void A_BossDeath(AActor *self)
G_ExitLevel (0, false);
}
DEFINE_ACTION_FUNCTION(AActor, A_BossDeath)
{
PARAM_SELF_PROLOGUE(AActor);
A_BossDeath(self);
return 0;
}
//----------------------------------------------------------------------------
//
// PROC P_Massacre

View file

@ -45,27 +45,35 @@ struct FLookExParams
FState *seestate;
};
bool P_HitFriend (AActor *self);
void P_NoiseAlert (AActor *target, AActor *emmiter, bool splash=false, double maxdist=0);
int P_HitFriend (AActor *self);
void P_NoiseAlert (AActor *emmiter, AActor *target, bool splash=false, double maxdist=0);
bool P_CheckMeleeRange2 (AActor *actor);
bool P_Move (AActor *actor);
int P_Move (AActor *actor);
bool P_TryWalk (AActor *actor);
void P_NewChaseDir (AActor *actor);
void P_RandomChaseDir(AActor *actor);;
int P_IsVisible(AActor *lookee, AActor *other, INTBOOL allaround, FLookExParams *params);
AActor *P_DropItem (AActor *source, PClassActor *type, int special, int chance);
void P_TossItem (AActor *item);
bool P_LookForPlayers (AActor *actor, INTBOOL allaround, FLookExParams *params);
int P_LookForMonsters(AActor *actor);
int P_LookForTID(AActor *actor, INTBOOL allaround, FLookExParams *params);
int P_LookForEnemies(AActor *actor, INTBOOL allaround, FLookExParams *params);
int P_LookForPlayers (AActor *actor, INTBOOL allaround, FLookExParams *params);
void A_Weave(AActor *self, int xyspeed, int zspeed, double xydist, double zdist);
void A_Unblock(AActor *self, bool drop);
void A_BossDeath(AActor *self);
void A_Wander(AActor *self, int flags = 0);
void A_DoChase(AActor *actor, bool fastchase, FState *meleestate, FState *missilestate, bool playactive, bool nightmarefast, bool dontmove, int flags);
void A_Chase(AActor *self);
void A_FaceTarget(AActor *actor);
void A_Face(AActor *self, AActor *other, DAngle max_turn = 0., DAngle max_pitch = 270., DAngle ang_offset = 0., DAngle pitch_offset = 0., int flags = 0, double z_add = 0);
bool P_CheckForResurrection(AActor *self, bool usevilestates);
bool CheckBossDeath (AActor *);
int CheckBossDeath (AActor *);
int P_Massacre (bool baddies = false, PClassActor *cls = nullptr);
bool P_CheckMissileRange (AActor *actor);

View file

@ -23,7 +23,7 @@ struct FLineTraceData
ETraceResult HitType;
};
bool P_LineTrace(AActor *t1, DAngle angle, double distance,
int P_LineTrace(AActor *t1, DAngle angle, double distance,
DAngle pitch, int flags, double sz, double offsetforward,
double offsetside, FLineTraceData *outdata);

View file

@ -3177,7 +3177,7 @@ FUNC(LS_NoiseAlert)
emitter = iter.Next();
}
P_NoiseAlert (target, emitter);
P_NoiseAlert (emitter, target);
return true;
}

View file

@ -276,7 +276,7 @@ void P_PlayerStartStomp (AActor *actor, bool mononly=false); // [RH] Stomp on t
void P_SlideMove (AActor* mo, const DVector2 &pos, int numsteps);
bool P_BounceWall (AActor *mo);
bool P_BounceActor (AActor *mo, AActor *BlockingMobj, bool ontop);
bool P_CheckSight (AActor *t1, AActor *t2, int flags=0);
int P_CheckSight (AActor *t1, AActor *t2, int flags=0);
enum ESightFlags
{
@ -289,7 +289,7 @@ enum ESightFlags
void P_ResetSightCounters (bool full);
bool P_TalkFacing (AActor *player);
void P_UseLines (player_t* player);
bool P_UsePuzzleItem (AActor *actor, int itemType);
int P_UsePuzzleItem (AActor *actor, int itemType);
enum
{

View file

@ -4754,7 +4754,7 @@ static ETraceStatus CheckLineTrace(FTraceResults &res, void *userdata)
return TRACE_Stop;
}
bool P_LineTrace(AActor *t1, DAngle angle, double distance,
int P_LineTrace(AActor *t1, DAngle angle, double distance,
DAngle pitch, int flags, double sz, double offsetforward,
double offsetside, FLineTraceData *outdata)
{
@ -5612,7 +5612,7 @@ void P_UseLines(player_t *player)
//
//==========================================================================
bool P_UsePuzzleItem(AActor *PuzzleItemUser, int PuzzleItemType)
int P_UsePuzzleItem(AActor *PuzzleItemUser, int PuzzleItemType)
{
DVector2 start;
DVector2 end;

View file

@ -798,7 +798,7 @@ void sector_t::ClosestPoint(const DVector2 &in, DVector2 &out) const
//
//=====================================================================================
bool PlaneMoving(sector_t *sector, int pos)
int PlaneMoving(sector_t *sector, int pos)
{
if (pos == sector_t::floor)
return (sector->floordata != nullptr || (sector->planes[sector_t::floor].Flags & PLANEF_BLOCKED));

View file

@ -834,7 +834,7 @@ sightcounts[2]++;
=====================
*/
bool P_CheckSight (AActor *t1, AActor *t2, int flags)
int P_CheckSight (AActor *t1, AActor *t2, int flags)
{
SightCycles.Clock();

View file

@ -552,13 +552,6 @@ PClassActor *P_GetSpawnableType(int spawnnum)
return NULL;
}
DEFINE_ACTION_FUNCTION(AActor, GetSpawnableType)
{
PARAM_PROLOGUE;
PARAM_INT(num);
ACTION_RETURN_POINTER(P_GetSpawnableType(num));
}
struct MapinfoSpawnItem
{
FName classname; // DECORATE is read after MAPINFO so we do not have the actual classes available here yet.

View file

@ -293,14 +293,6 @@ CCMD (playerclasses)
}
}
DEFINE_ACTION_FUNCTION(AActor, Substitute)
{
PARAM_SELF_PROLOGUE(AActor);
PARAM_OBJECT(replace, AActor);
DObject::StaticPointerSubstitution(self, replace);
return 0;
}
//
// Movement.
//
@ -1245,23 +1237,6 @@ DEFINE_ACTION_FUNCTION(AActor, A_SkullPop)
return 0;
}
//----------------------------------------------------------------------------
//
// PROC A_CheckSkullDone
//
//----------------------------------------------------------------------------
DEFINE_ACTION_FUNCTION(AActor, A_CheckPlayerDone)
{
PARAM_SELF_PROLOGUE(AActor);
if (self->player == NULL)
{
self->Destroy();
}
return 0;
}
//===========================================================================
//
// P_CheckPlayerSprites

View file

@ -1612,7 +1612,7 @@ double NextLowestFloorAt(sector_t *sec, double x, double y, double z, int flags
// This setup is to allow the VM call directily into the implementation.
// With a member function this may be subject to OS implementation details, e.g. on Windows 32 bit members use a different calling convention than regular functions.
void RemoveForceField(sector_t *sec);
bool PlaneMoving(sector_t *sector, int pos);
int PlaneMoving(sector_t *sector, int pos);
void TransferSpecial(sector_t *self, sector_t *model);
void GetSpecial(sector_t *self, secspecial_t *spec);
void SetSpecial(sector_t *self, const secspecial_t *spec);
@ -1628,7 +1628,7 @@ double HighestCeilingAt(sector_t *sec, double x, double y, sector_t **resultsec
double LowestFloorAt(sector_t *sec, double x, double y, sector_t **resultsec = nullptr);
inline void sector_t::RemoveForceField() { return ::RemoveForceField(this); }
inline bool sector_t::PlaneMoving(int pos) { return ::PlaneMoving(this, pos); }
inline bool sector_t::PlaneMoving(int pos) { return !!::PlaneMoving(this, pos); }
inline void sector_t::TransferSpecial(sector_t *model) { return ::TransferSpecial(this, model); }
inline void sector_t::GetSpecial(secspecial_t *spec) { ::GetSpecial(this, spec); }
inline void sector_t::SetSpecial(const secspecial_t *spec) { ::SetSpecial(this, spec); }

View file

@ -1813,7 +1813,7 @@ void S_RelinkSound (AActor *from, AActor *to)
//
//==========================================================================
bool S_ChangeSoundVolume(AActor *actor, int channel, double dvolume)
void S_ChangeSoundVolume(AActor *actor, int channel, double dvolume)
{
float volume = float(dvolume);
// don't let volume get out of bounds
@ -1830,10 +1830,10 @@ bool S_ChangeSoundVolume(AActor *actor, int channel, double dvolume)
{
GSnd->ChannelVolume(chan, volume);
chan->Volume = volume;
return true;
return;
}
}
return false;
return;
}
//==========================================================================

View file

@ -307,7 +307,7 @@ bool S_GetSoundPlayingInfo (const FPolyObj *poly, int sound_id);
bool S_IsActorPlayingSomething (AActor *actor, int channel, int sound_id);
// Change a playing sound's volume
bool S_ChangeSoundVolume(AActor *actor, int channel, double volume);
void S_ChangeSoundVolume(AActor *actor, int channel, double volume);
// Moves all sounds from one mobj to another
void S_RelinkSound (AActor *from, AActor *to);

View file

@ -80,7 +80,7 @@ template<class T, class U> int ArrayPush(T *self, U val)
return self->Push(static_cast<typename T::value_type>(val));
}
template<class T> bool ArrayPop(T *self)
template<class T> int ArrayPop(T *self)
{
return self->Pop();
}

View file

@ -564,14 +564,14 @@ struct FieldDesc
namespace
{
// Traits for the types we are interested in
template<typename T> struct native_is_valid { static const bool value = false; };
template<typename T> struct native_is_valid<T*> { static const bool value = true; };
template<typename T> struct native_is_valid<T&> { static const bool value = true; };
template<> struct native_is_valid<void> { static const bool value = true; };
template<> struct native_is_valid<int> { static const bool value = true; };
template<> struct native_is_valid<unsigned int> { static const bool value = true; };
template<> struct native_is_valid<double> { static const bool value = true; };
template<> struct native_is_valid<bool> { static const bool value = true; };
template<typename T> struct native_is_valid { static const bool value = false; static const bool retval = false; };
template<typename T> struct native_is_valid<T*> { static const bool value = true; static const bool retval = true; };
template<typename T> struct native_is_valid<T&> { static const bool value = true; static const bool retval = true; };
template<> struct native_is_valid<void> { static const bool value = true; static const bool retval = true; };
template<> struct native_is_valid<int> { static const bool value = true; static const bool retval = true; };
template<> struct native_is_valid<unsigned int> { static const bool value = true; static const bool retval = true; };
template<> struct native_is_valid<double> { static const bool value = true; static const bool retval = true; };
template<> struct native_is_valid<bool> { static const bool value = true; static const bool retval = false;}; // Bool as return does not work!
}
// Compile time validation of direct native functions
@ -581,24 +581,25 @@ struct DirectNativeDesc
#define TP(n) typename P##n
#define VP(n) ValidateType<P##n>()
template<typename Ret> DirectNativeDesc(Ret(*func)()) : Ptr(reinterpret_cast<void*>(func)) { ValidateType<Ret>(); }
template<typename Ret, TP(1)> DirectNativeDesc(Ret(*func)(P1)) : Ptr(reinterpret_cast<void*>(func)) { ValidateType<Ret>(); VP(1); }
template<typename Ret, TP(1), TP(2)> DirectNativeDesc(Ret(*func)(P1,P2)) : Ptr(reinterpret_cast<void*>(func)) { ValidateType<Ret>(); VP(1); VP(2); }
template<typename Ret, TP(1), TP(2), TP(3)> DirectNativeDesc(Ret(*func)(P1,P2,P3)) : Ptr(reinterpret_cast<void*>(func)) { ValidateType<Ret>(); VP(1); VP(2); VP(3); }
template<typename Ret, TP(1), TP(2), TP(3), TP(4)> DirectNativeDesc(Ret(*func)(P1, P2, P3, P4)) : Ptr(reinterpret_cast<void*>(func)) { ValidateType<Ret>(); VP(1); VP(2); VP(3); VP(4); }
template<typename Ret, TP(1), TP(2), TP(3), TP(4), TP(5)> DirectNativeDesc(Ret(*func)(P1, P2, P3, P4, P5)) : Ptr(reinterpret_cast<void*>(func)) { ValidateType<Ret>(); VP(1); VP(2); VP(3); VP(4); VP(5); }
template<typename Ret, TP(1), TP(2), TP(3), TP(4), TP(5), TP(6)> DirectNativeDesc(Ret(*func)(P1, P2, P3, P4, P5, P6)) : Ptr(reinterpret_cast<void*>(func)) { ValidateType<Ret>(); VP(1); VP(2); VP(3); VP(4); VP(5); VP(6); }
template<typename Ret, TP(1), TP(2), TP(3), TP(4), TP(5), TP(6), TP(7)> DirectNativeDesc(Ret(*func)(P1, P2, P3, P4, P5, P6, P7)) : Ptr(reinterpret_cast<void*>(func)) { ValidateType<Ret>(); VP(1); VP(2); VP(3); VP(4); VP(5); VP(6); VP(7); }
template<typename Ret, TP(1), TP(2), TP(3), TP(4), TP(5), TP(6), TP(7), TP(8)> DirectNativeDesc(Ret(*func)(P1, P2, P3, P4, P5, P6, P7, P8)) : Ptr(reinterpret_cast<void*>(func)) { ValidateType<Ret>(); VP(1); VP(2); VP(3); VP(4); VP(5); VP(6); VP(7); VP(8); }
template<typename Ret, TP(1), TP(2), TP(3), TP(4), TP(5), TP(6), TP(7), TP(8), TP(9)> DirectNativeDesc(Ret(*func)(P1, P2, P3, P4, P5, P6, P7, P8, P9)) : Ptr(reinterpret_cast<void*>(func)) { ValidateType<Ret>(); VP(1); VP(2); VP(3); VP(4); VP(5); VP(6); VP(7); VP(8); VP(9); }
template<typename Ret, TP(1), TP(2), TP(3), TP(4), TP(5), TP(6), TP(7), TP(8), TP(9), TP(10)> DirectNativeDesc(Ret(*func)(P1, P2, P3, P4, P5, P6, P7, P8, P9, P10)) : Ptr(reinterpret_cast<void*>(func)) { ValidateType<Ret>(); VP(1); VP(2); VP(3); VP(4); VP(5); VP(6); VP(7); VP(8); VP(9); VP(10); }
template<typename Ret, TP(1), TP(2), TP(3), TP(4), TP(5), TP(6), TP(7), TP(8), TP(9), TP(10), TP(11)> DirectNativeDesc(Ret(*func)(P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11)) : Ptr(reinterpret_cast<void*>(func)) { ValidateType<Ret>(); VP(1); VP(2); VP(3); VP(4); VP(5); VP(6); VP(7); VP(8); VP(9); VP(10); VP(11); }
template<typename Ret, TP(1), TP(2), TP(3), TP(4), TP(5), TP(6), TP(7), TP(8), TP(9), TP(10), TP(11), TP(12)> DirectNativeDesc(Ret(*func)(P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12)) : Ptr(reinterpret_cast<void*>(func)) { ValidateType<Ret>(); VP(1); VP(2); VP(3); VP(4); VP(5); VP(6); VP(7); VP(8); VP(9); VP(10); VP(11); VP(12); }
template<typename Ret, TP(1), TP(2), TP(3), TP(4), TP(5), TP(6), TP(7), TP(8), TP(9), TP(10), TP(11), TP(12), TP(13)> DirectNativeDesc(Ret(*func)(P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13)) : Ptr(reinterpret_cast<void*>(func)) { ValidateType<Ret>(); VP(1); VP(2); VP(3); VP(4); VP(5); VP(6); VP(7); VP(8); VP(9); VP(10); VP(11); VP(12); VP(13); }
template<typename Ret> DirectNativeDesc(Ret(*func)()) : Ptr(reinterpret_cast<void*>(func)) { ValidateRet<Ret>(); }
template<typename Ret, TP(1)> DirectNativeDesc(Ret(*func)(P1)) : Ptr(reinterpret_cast<void*>(func)) { ValidateRet<Ret>(); VP(1); }
template<typename Ret, TP(1), TP(2)> DirectNativeDesc(Ret(*func)(P1,P2)) : Ptr(reinterpret_cast<void*>(func)) { ValidateRet<Ret>(); VP(1); VP(2); }
template<typename Ret, TP(1), TP(2), TP(3)> DirectNativeDesc(Ret(*func)(P1,P2,P3)) : Ptr(reinterpret_cast<void*>(func)) { ValidateRet<Ret>(); VP(1); VP(2); VP(3); }
template<typename Ret, TP(1), TP(2), TP(3), TP(4)> DirectNativeDesc(Ret(*func)(P1, P2, P3, P4)) : Ptr(reinterpret_cast<void*>(func)) { ValidateRet<Ret>(); VP(1); VP(2); VP(3); VP(4); }
template<typename Ret, TP(1), TP(2), TP(3), TP(4), TP(5)> DirectNativeDesc(Ret(*func)(P1, P2, P3, P4, P5)) : Ptr(reinterpret_cast<void*>(func)) { ValidateRet<Ret>(); VP(1); VP(2); VP(3); VP(4); VP(5); }
template<typename Ret, TP(1), TP(2), TP(3), TP(4), TP(5), TP(6)> DirectNativeDesc(Ret(*func)(P1, P2, P3, P4, P5, P6)) : Ptr(reinterpret_cast<void*>(func)) { ValidateRet<Ret>(); VP(1); VP(2); VP(3); VP(4); VP(5); VP(6); }
template<typename Ret, TP(1), TP(2), TP(3), TP(4), TP(5), TP(6), TP(7)> DirectNativeDesc(Ret(*func)(P1, P2, P3, P4, P5, P6, P7)) : Ptr(reinterpret_cast<void*>(func)) { ValidateRet<Ret>(); VP(1); VP(2); VP(3); VP(4); VP(5); VP(6); VP(7); }
template<typename Ret, TP(1), TP(2), TP(3), TP(4), TP(5), TP(6), TP(7), TP(8)> DirectNativeDesc(Ret(*func)(P1, P2, P3, P4, P5, P6, P7, P8)) : Ptr(reinterpret_cast<void*>(func)) { ValidateRet<Ret>(); VP(1); VP(2); VP(3); VP(4); VP(5); VP(6); VP(7); VP(8); }
template<typename Ret, TP(1), TP(2), TP(3), TP(4), TP(5), TP(6), TP(7), TP(8), TP(9)> DirectNativeDesc(Ret(*func)(P1, P2, P3, P4, P5, P6, P7, P8, P9)) : Ptr(reinterpret_cast<void*>(func)) { ValidateRet<Ret>(); VP(1); VP(2); VP(3); VP(4); VP(5); VP(6); VP(7); VP(8); VP(9); }
template<typename Ret, TP(1), TP(2), TP(3), TP(4), TP(5), TP(6), TP(7), TP(8), TP(9), TP(10)> DirectNativeDesc(Ret(*func)(P1, P2, P3, P4, P5, P6, P7, P8, P9, P10)) : Ptr(reinterpret_cast<void*>(func)) { ValidateRet<Ret>(); VP(1); VP(2); VP(3); VP(4); VP(5); VP(6); VP(7); VP(8); VP(9); VP(10); }
template<typename Ret, TP(1), TP(2), TP(3), TP(4), TP(5), TP(6), TP(7), TP(8), TP(9), TP(10), TP(11)> DirectNativeDesc(Ret(*func)(P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11)) : Ptr(reinterpret_cast<void*>(func)) { ValidateRet<Ret>(); VP(1); VP(2); VP(3); VP(4); VP(5); VP(6); VP(7); VP(8); VP(9); VP(10); VP(11); }
template<typename Ret, TP(1), TP(2), TP(3), TP(4), TP(5), TP(6), TP(7), TP(8), TP(9), TP(10), TP(11), TP(12)> DirectNativeDesc(Ret(*func)(P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12)) : Ptr(reinterpret_cast<void*>(func)) { ValidateRet<Ret>(); VP(1); VP(2); VP(3); VP(4); VP(5); VP(6); VP(7); VP(8); VP(9); VP(10); VP(11); VP(12); }
template<typename Ret, TP(1), TP(2), TP(3), TP(4), TP(5), TP(6), TP(7), TP(8), TP(9), TP(10), TP(11), TP(12), TP(13)> DirectNativeDesc(Ret(*func)(P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13)) : Ptr(reinterpret_cast<void*>(func)) { ValidateRet<Ret>(); VP(1); VP(2); VP(3); VP(4); VP(5); VP(6); VP(7); VP(8); VP(9); VP(10); VP(11); VP(12); VP(13); }
#undef TP
#undef VP
template<typename T> void ValidateType() { static_assert(native_is_valid<T>::value, "Argument type is not valid as a direct native parameter or return type"); }
template<typename T> void ValidateRet() { static_assert(native_is_valid<T>::retval, "Return type is not valid as a direct native parameter or return type"); }
operator void *() const { return Ptr; }

View file

@ -53,6 +53,8 @@
#include "p_effect.h"
#include "p_spec.h"
#include "actorinlines.h"
#include "p_enemy.h"
#include "gi.h"
DVector2 AM_GetPosition();
int Net_GetLatency(int *ld, int *ad);
@ -1092,7 +1094,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(AActor, LineAttack, ZS_LineAttack)
return numret;
}
static bool LineTrace(AActor *self, double angle, double distance, double pitch, int flags, double offsetz, double offsetforward, double offsetside, FLineTraceData *data)
static int LineTrace(AActor *self, double angle, double distance, double pitch, int flags, double offsetz, double offsetforward, double offsetside, FLineTraceData *data)
{
return P_LineTrace(self,angle,distance,pitch,flags,offsetz,offsetforward,offsetside,data);
}
@ -1345,6 +1347,199 @@ DEFINE_ACTION_FUNCTION_NATIVE(AActor, GetMissileDamage, ZS_GetMissileDamage)
ACTION_RETURN_INT(ZS_GetMissileDamage(self, mask, add, pick_pointer));
}
DEFINE_ACTION_FUNCTION_NATIVE(AActor, SoundAlert, P_NoiseAlert)
{
PARAM_SELF_PROLOGUE(AActor);
PARAM_OBJECT(target, AActor);
PARAM_BOOL(splash);
PARAM_FLOAT(maxdist);
P_NoiseAlert(self, target, splash, maxdist);
return 0;
}
DEFINE_ACTION_FUNCTION_NATIVE(AActor, HitFriend, P_HitFriend)
{
PARAM_SELF_PROLOGUE(AActor);
ACTION_RETURN_BOOL(P_HitFriend(self));
}
DEFINE_ACTION_FUNCTION_NATIVE(AActor, MonsterMove, P_Move)
{
PARAM_SELF_PROLOGUE(AActor);
ACTION_RETURN_BOOL(P_Move(self));
}
DEFINE_ACTION_FUNCTION_NATIVE(AActor, NewChaseDir, P_NewChaseDir)
{
PARAM_SELF_PROLOGUE(AActor);
P_NewChaseDir(self);
return 0;
}
DEFINE_ACTION_FUNCTION_NATIVE(AActor, RandomChaseDir, P_RandomChaseDir)
{
PARAM_SELF_PROLOGUE(AActor);
P_RandomChaseDir(self);
return 0;
}
DEFINE_ACTION_FUNCTION_NATIVE(AActor, IsVisible, P_IsVisible)
{
PARAM_SELF_PROLOGUE(AActor);
PARAM_OBJECT(other, AActor);
PARAM_BOOL(allaround);
PARAM_POINTER(params, FLookExParams);
ACTION_RETURN_BOOL(P_IsVisible(self, other, allaround, params));
}
DEFINE_ACTION_FUNCTION_NATIVE(AActor, LookForMonsters, P_LookForMonsters)
{
PARAM_SELF_PROLOGUE(AActor);
ACTION_RETURN_BOOL(P_LookForMonsters(self));
}
DEFINE_ACTION_FUNCTION_NATIVE(AActor, LookForTID, P_LookForTID)
{
PARAM_SELF_PROLOGUE(AActor);
PARAM_BOOL(allaround);
PARAM_POINTER(params, FLookExParams);
ACTION_RETURN_BOOL(P_LookForTID(self, allaround, params));
}
DEFINE_ACTION_FUNCTION_NATIVE(AActor, LookForEnemies, P_LookForEnemies)
{
PARAM_SELF_PROLOGUE(AActor);
PARAM_BOOL(allaround);
PARAM_POINTER(params, FLookExParams);
ACTION_RETURN_BOOL(P_LookForEnemies(self, allaround, params));
}
DEFINE_ACTION_FUNCTION_NATIVE(AActor, LookForPlayers, P_LookForPlayers)
{
PARAM_SELF_PROLOGUE(AActor);
PARAM_BOOL(allaround);
PARAM_POINTER(params, FLookExParams);
ACTION_RETURN_BOOL(P_LookForPlayers(self, allaround, params));
}
DEFINE_ACTION_FUNCTION_NATIVE(AActor, A_Wander, A_Wander)
{
PARAM_SELF_PROLOGUE(AActor);
PARAM_INT(flags);
A_Wander(self, flags);
return 0;
}
//==========================================================================
//
// A_Chase and variations
//
//==========================================================================
static void A_FastChase(AActor *self)
{
A_DoChase(self, true, self->MeleeState, self->MissileState, true, true, false, 0);
}
DEFINE_ACTION_FUNCTION_NATIVE(AActor, A_FastChase, A_FastChase)
{
PARAM_SELF_PROLOGUE(AActor);
A_FastChase(self);
return 0;
}
static void A_VileChase(AActor *self)
{
if (!P_CheckForResurrection(self, true))
{
A_DoChase(self, false, self->MeleeState, self->MissileState, true, gameinfo.nightmarefast, false, 0);
}
}
DEFINE_ACTION_FUNCTION_NATIVE(AActor, A_VileChase, A_VileChase)
{
PARAM_SELF_PROLOGUE(AActor);
A_VileChase(self);
return 0;
}
static void A_ExtChase(AActor *self, bool domelee, bool domissile, bool playactive, bool nightmarefast)
{
// Now that A_Chase can handle state label parameters, this function has become rather useless...
A_DoChase(self, false,
domelee ? self->MeleeState : NULL, domissile ? self->MissileState : NULL,
playactive, nightmarefast, false, 0);
}
DEFINE_ACTION_FUNCTION_NATIVE(AActor, A_ExtChase, A_ExtChase)
{
PARAM_SELF_PROLOGUE(AActor);
PARAM_BOOL(domelee);
PARAM_BOOL(domissile);
PARAM_BOOL(playactive);
PARAM_BOOL(nightmarefast);
A_ExtChase(self, domelee, domissile, playactive, nightmarefast);
return 0;
}
int CheckForResurrection(AActor *self)
{
return P_CheckForResurrection(self, false);
}
DEFINE_ACTION_FUNCTION_NATIVE(AActor, A_CheckForResurrection, CheckForResurrection)
{
PARAM_SELF_PROLOGUE(AActor);
ACTION_RETURN_BOOL(P_CheckForResurrection(self, false));
}
static void ZS_Face(AActor *self, AActor *faceto, double max_turn, double max_pitch, double ang_offset, double pitch_offset, int flags, double z_add)
{
A_Face(self, faceto, max_turn, max_pitch, ang_offset, pitch_offset, flags, z_add);
}
DEFINE_ACTION_FUNCTION_NATIVE(AActor, A_Face, ZS_Face)
{
PARAM_SELF_PROLOGUE(AActor);
PARAM_OBJECT(faceto, AActor)
PARAM_ANGLE(max_turn)
PARAM_ANGLE(max_pitch)
PARAM_ANGLE(ang_offset)
PARAM_ANGLE(pitch_offset)
PARAM_INT(flags)
PARAM_FLOAT(z_add)
A_Face(self, faceto, max_turn, max_pitch, ang_offset, pitch_offset, flags, z_add);
return 0;
}
DEFINE_ACTION_FUNCTION_NATIVE(AActor, CheckBossDeath, CheckBossDeath)
{
PARAM_SELF_PROLOGUE(AActor);
ACTION_RETURN_BOOL(CheckBossDeath(self));
}
DEFINE_ACTION_FUNCTION_NATIVE(AActor, A_BossDeath, A_BossDeath)
{
PARAM_SELF_PROLOGUE(AActor);
A_BossDeath(self);
return 0;
}
DEFINE_ACTION_FUNCTION_NATIVE(AActor, Substitute, DObject::StaticPointerSubstitution)
{
PARAM_SELF_PROLOGUE(AActor);
PARAM_OBJECT(replace, AActor);
DObject::StaticPointerSubstitution(self, replace);
return 0;
}
DEFINE_ACTION_FUNCTION_NATIVE(AActor, GetSpawnableType, P_GetSpawnableType)
{
PARAM_PROLOGUE;
PARAM_INT(num);
ACTION_RETURN_POINTER(P_GetSpawnableType(num));
}
//=====================================================================================
//
// Inventory exports

View file

@ -1026,7 +1026,6 @@ class Actor : Thinker native
native void A_FastChase();
native void A_PlayerScream();
native void A_SkullPop(class<PlayerChunk> skulltype = "BloodySkull");
native void A_CheckPlayerDone();
native void A_CheckTerrain();
native void A_Wander(int flags = 0);
@ -1208,6 +1207,19 @@ class Actor : Thinker native
}
}
//----------------------------------------------------------------------------
//
// PROC A_CheckSkullDone
//
//----------------------------------------------------------------------------
void A_CheckPlayerDone()
{
if (player == NULL) Destroy();
}
States(Actor, Overlay, Weapon, Item)
{
Spawn: