diff --git a/src/dobject.cpp b/src/dobject.cpp index fc48960543..f5fd176f80 100644 --- a/src/dobject.cpp +++ b/src/dobject.cpp @@ -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; } //========================================================================== diff --git a/src/dobject.h b/src/dobject.h index 44ffa61fbb..c930cbe798 100644 --- a/src/dobject.h +++ b/src/dobject.h @@ -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 { diff --git a/src/p_enemy.cpp b/src/p_enemy.cpp index 986268c7ee..d65ee7bbef 100644 --- a/src/p_enemy.cpp +++ b/src/p_enemy.cpp @@ -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,26 +2759,27 @@ 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) { if ((flags & CHF_RESURRECT) && P_CheckForResurrection(self, false)) return 0; - - A_DoChase(self, !!(flags&CHF_FASTCHASE), melee, missile, !(flags&CHF_NOPLAYACTIVE), - !!(flags&CHF_NIGHTMAREFAST), !!(flags&CHF_DONTMOVE), flags & 0x3fffffff); + + A_DoChase(self, !!(flags&CHF_FASTCHASE), melee, missile, !(flags&CHF_NOPLAYACTIVE), + !!(flags&CHF_NIGHTMAREFAST), !!(flags&CHF_DONTMOVE), flags & 0x3fffffff); } else // this is the old default A_Chase { @@ -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 diff --git a/src/p_enemy.h b/src/p_enemy.h index 3a4a4e3ea9..3086cbb50c 100644 --- a/src/p_enemy.h +++ b/src/p_enemy.h @@ -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); diff --git a/src/p_linetracedata.h b/src/p_linetracedata.h index eab6e63d53..7dc74b3347 100644 --- a/src/p_linetracedata.h +++ b/src/p_linetracedata.h @@ -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); diff --git a/src/p_lnspec.cpp b/src/p_lnspec.cpp index fd98b9515c..24f23fab3a 100644 --- a/src/p_lnspec.cpp +++ b/src/p_lnspec.cpp @@ -3177,7 +3177,7 @@ FUNC(LS_NoiseAlert) emitter = iter.Next(); } - P_NoiseAlert (target, emitter); + P_NoiseAlert (emitter, target); return true; } diff --git a/src/p_local.h b/src/p_local.h index 203f30c5c8..80f4770e76 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -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 { diff --git a/src/p_map.cpp b/src/p_map.cpp index 5fb107942b..bdd380eb85 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -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; diff --git a/src/p_sectors.cpp b/src/p_sectors.cpp index b896ed08ed..968508dcc7 100644 --- a/src/p_sectors.cpp +++ b/src/p_sectors.cpp @@ -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)); diff --git a/src/p_sight.cpp b/src/p_sight.cpp index 9de3f9d614..5f15e844bb 100644 --- a/src/p_sight.cpp +++ b/src/p_sight.cpp @@ -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(); diff --git a/src/p_things.cpp b/src/p_things.cpp index 4cac8866f4..f6d5139f68 100644 --- a/src/p_things.cpp +++ b/src/p_things.cpp @@ -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. diff --git a/src/p_user.cpp b/src/p_user.cpp index 7dda187190..4bae6ee5e0 100644 --- a/src/p_user.cpp +++ b/src/p_user.cpp @@ -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 diff --git a/src/r_defs.h b/src/r_defs.h index 79c68a2dd6..4c34163b02 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -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); } diff --git a/src/s_sound.cpp b/src/s_sound.cpp index 24440835df..14977820f9 100644 --- a/src/s_sound.cpp +++ b/src/s_sound.cpp @@ -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; } //========================================================================== diff --git a/src/s_sound.h b/src/s_sound.h index 6dd06dd750..c6ee76236d 100644 --- a/src/s_sound.h +++ b/src/s_sound.h @@ -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); diff --git a/src/scripting/backend/dynarrays.cpp b/src/scripting/backend/dynarrays.cpp index bcfff6520d..15b0161665 100644 --- a/src/scripting/backend/dynarrays.cpp +++ b/src/scripting/backend/dynarrays.cpp @@ -80,7 +80,7 @@ template int ArrayPush(T *self, U val) return self->Push(static_cast(val)); } -template bool ArrayPop(T *self) +template int ArrayPop(T *self) { return self->Pop(); } diff --git a/src/scripting/vm/vm.h b/src/scripting/vm/vm.h index e52d5c1888..6e3a1f08b9 100644 --- a/src/scripting/vm/vm.h +++ b/src/scripting/vm/vm.h @@ -564,14 +564,14 @@ struct FieldDesc namespace { // Traits for the types we are interested in - template struct native_is_valid { static const bool value = false; }; - template struct native_is_valid { static const bool value = true; }; - template struct native_is_valid { static const bool value = true; }; - template<> struct native_is_valid { static const bool value = true; }; - template<> struct native_is_valid { static const bool value = true; }; - template<> struct native_is_valid { static const bool value = true; }; - template<> struct native_is_valid { static const bool value = true; }; - template<> struct native_is_valid { static const bool value = true; }; + template struct native_is_valid { static const bool value = false; static const bool retval = false; }; + template struct native_is_valid { static const bool value = true; static const bool retval = true; }; + template struct native_is_valid { static const bool value = true; static const bool retval = true; }; + template<> struct native_is_valid { static const bool value = true; static const bool retval = true; }; + template<> struct native_is_valid { static const bool value = true; static const bool retval = true; }; + template<> struct native_is_valid { static const bool value = true; static const bool retval = true; }; + template<> struct native_is_valid { static const bool value = true; static const bool retval = true; }; + template<> struct native_is_valid { 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() - template DirectNativeDesc(Ret(*func)()) : Ptr(reinterpret_cast(func)) { ValidateType(); } - template DirectNativeDesc(Ret(*func)(P1)) : Ptr(reinterpret_cast(func)) { ValidateType(); VP(1); } - template DirectNativeDesc(Ret(*func)(P1,P2)) : Ptr(reinterpret_cast(func)) { ValidateType(); VP(1); VP(2); } - template DirectNativeDesc(Ret(*func)(P1,P2,P3)) : Ptr(reinterpret_cast(func)) { ValidateType(); VP(1); VP(2); VP(3); } - template DirectNativeDesc(Ret(*func)(P1, P2, P3, P4)) : Ptr(reinterpret_cast(func)) { ValidateType(); VP(1); VP(2); VP(3); VP(4); } - template DirectNativeDesc(Ret(*func)(P1, P2, P3, P4, P5)) : Ptr(reinterpret_cast(func)) { ValidateType(); VP(1); VP(2); VP(3); VP(4); VP(5); } - template DirectNativeDesc(Ret(*func)(P1, P2, P3, P4, P5, P6)) : Ptr(reinterpret_cast(func)) { ValidateType(); VP(1); VP(2); VP(3); VP(4); VP(5); VP(6); } - template DirectNativeDesc(Ret(*func)(P1, P2, P3, P4, P5, P6, P7)) : Ptr(reinterpret_cast(func)) { ValidateType(); VP(1); VP(2); VP(3); VP(4); VP(5); VP(6); VP(7); } - template DirectNativeDesc(Ret(*func)(P1, P2, P3, P4, P5, P6, P7, P8)) : Ptr(reinterpret_cast(func)) { ValidateType(); VP(1); VP(2); VP(3); VP(4); VP(5); VP(6); VP(7); VP(8); } - template DirectNativeDesc(Ret(*func)(P1, P2, P3, P4, P5, P6, P7, P8, P9)) : Ptr(reinterpret_cast(func)) { ValidateType(); VP(1); VP(2); VP(3); VP(4); VP(5); VP(6); VP(7); VP(8); VP(9); } - template DirectNativeDesc(Ret(*func)(P1, P2, P3, P4, P5, P6, P7, P8, P9, P10)) : Ptr(reinterpret_cast(func)) { ValidateType(); VP(1); VP(2); VP(3); VP(4); VP(5); VP(6); VP(7); VP(8); VP(9); VP(10); } - template DirectNativeDesc(Ret(*func)(P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11)) : Ptr(reinterpret_cast(func)) { ValidateType(); VP(1); VP(2); VP(3); VP(4); VP(5); VP(6); VP(7); VP(8); VP(9); VP(10); VP(11); } - template DirectNativeDesc(Ret(*func)(P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12)) : Ptr(reinterpret_cast(func)) { ValidateType(); 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 DirectNativeDesc(Ret(*func)(P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13)) : Ptr(reinterpret_cast(func)) { ValidateType(); 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 DirectNativeDesc(Ret(*func)()) : Ptr(reinterpret_cast(func)) { ValidateRet(); } + template DirectNativeDesc(Ret(*func)(P1)) : Ptr(reinterpret_cast(func)) { ValidateRet(); VP(1); } + template DirectNativeDesc(Ret(*func)(P1,P2)) : Ptr(reinterpret_cast(func)) { ValidateRet(); VP(1); VP(2); } + template DirectNativeDesc(Ret(*func)(P1,P2,P3)) : Ptr(reinterpret_cast(func)) { ValidateRet(); VP(1); VP(2); VP(3); } + template DirectNativeDesc(Ret(*func)(P1, P2, P3, P4)) : Ptr(reinterpret_cast(func)) { ValidateRet(); VP(1); VP(2); VP(3); VP(4); } + template DirectNativeDesc(Ret(*func)(P1, P2, P3, P4, P5)) : Ptr(reinterpret_cast(func)) { ValidateRet(); VP(1); VP(2); VP(3); VP(4); VP(5); } + template DirectNativeDesc(Ret(*func)(P1, P2, P3, P4, P5, P6)) : Ptr(reinterpret_cast(func)) { ValidateRet(); VP(1); VP(2); VP(3); VP(4); VP(5); VP(6); } + template DirectNativeDesc(Ret(*func)(P1, P2, P3, P4, P5, P6, P7)) : Ptr(reinterpret_cast(func)) { ValidateRet(); VP(1); VP(2); VP(3); VP(4); VP(5); VP(6); VP(7); } + template DirectNativeDesc(Ret(*func)(P1, P2, P3, P4, P5, P6, P7, P8)) : Ptr(reinterpret_cast(func)) { ValidateRet(); VP(1); VP(2); VP(3); VP(4); VP(5); VP(6); VP(7); VP(8); } + template DirectNativeDesc(Ret(*func)(P1, P2, P3, P4, P5, P6, P7, P8, P9)) : Ptr(reinterpret_cast(func)) { ValidateRet(); VP(1); VP(2); VP(3); VP(4); VP(5); VP(6); VP(7); VP(8); VP(9); } + template DirectNativeDesc(Ret(*func)(P1, P2, P3, P4, P5, P6, P7, P8, P9, P10)) : Ptr(reinterpret_cast(func)) { ValidateRet(); VP(1); VP(2); VP(3); VP(4); VP(5); VP(6); VP(7); VP(8); VP(9); VP(10); } + template DirectNativeDesc(Ret(*func)(P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11)) : Ptr(reinterpret_cast(func)) { ValidateRet(); VP(1); VP(2); VP(3); VP(4); VP(5); VP(6); VP(7); VP(8); VP(9); VP(10); VP(11); } + template DirectNativeDesc(Ret(*func)(P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12)) : Ptr(reinterpret_cast(func)) { ValidateRet(); 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 DirectNativeDesc(Ret(*func)(P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13)) : Ptr(reinterpret_cast(func)) { ValidateRet(); 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 void ValidateType() { static_assert(native_is_valid::value, "Argument type is not valid as a direct native parameter or return type"); } + template void ValidateRet() { static_assert(native_is_valid::retval, "Return type is not valid as a direct native parameter or return type"); } operator void *() const { return Ptr; } diff --git a/src/scripting/vmthunks_actors.cpp b/src/scripting/vmthunks_actors.cpp index 0ed5240c2d..07c458d968 100644 --- a/src/scripting/vmthunks_actors.cpp +++ b/src/scripting/vmthunks_actors.cpp @@ -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 diff --git a/wadsrc/static/zscript/actor.txt b/wadsrc/static/zscript/actor.txt index 07e409dd89..eed1118f4c 100644 --- a/wadsrc/static/zscript/actor.txt +++ b/wadsrc/static/zscript/actor.txt @@ -1026,7 +1026,6 @@ class Actor : Thinker native native void A_FastChase(); native void A_PlayerScream(); native void A_SkullPop(class 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: