From a8d4d45e89d69afacd14b9d726c59eb33443d2a5 Mon Sep 17 00:00:00 2001 From: Major Cooke Date: Sat, 17 Nov 2018 10:44:06 -0600 Subject: [PATCH] P_Thing_Raise fixes & cleanup - Transfer flags directly into the function and process inside instead of the action functions - Pass in raiser for all function calls --- src/p_actionfunctions.cpp | 20 +++++--------------- src/p_lnspec.cpp | 4 ++-- src/p_local.h | 8 +++++++- src/p_things.cpp | 6 +++--- 4 files changed, 17 insertions(+), 21 deletions(-) diff --git a/src/p_actionfunctions.cpp b/src/p_actionfunctions.cpp index 6e6e16500..ccc6d7358 100644 --- a/src/p_actionfunctions.cpp +++ b/src/p_actionfunctions.cpp @@ -4477,13 +4477,6 @@ DEFINE_ACTION_FUNCTION(AActor, A_ChangeCountFlags) return 0; } - -enum ERaise -{ - RF_TRANSFERFRIENDLINESS = 1, - RF_NOCHECKPOSITION = 2 -}; - //=========================================================================== // // A_RaiseMaster @@ -4494,10 +4487,9 @@ DEFINE_ACTION_FUNCTION(AActor, A_RaiseMaster) PARAM_SELF_PROLOGUE(AActor); PARAM_INT_DEF(flags); - bool copy = !!(flags & RF_TRANSFERFRIENDLINESS); if (self->master != NULL) { - P_Thing_Raise(self->master, copy ? self : NULL, (flags & RF_NOCHECKPOSITION)); + P_Thing_Raise(self->master, self, flags); } return 0; } @@ -4515,12 +4507,11 @@ DEFINE_ACTION_FUNCTION(AActor, A_RaiseChildren) TThinkerIterator it; AActor *mo; - bool copy = !!(flags & RF_TRANSFERFRIENDLINESS); while ((mo = it.Next()) != NULL) { if (mo->master == self) { - P_Thing_Raise(mo, copy ? self : NULL, (flags & RF_NOCHECKPOSITION)); + P_Thing_Raise(mo, self, flags); } } return 0; @@ -4539,14 +4530,13 @@ DEFINE_ACTION_FUNCTION(AActor, A_RaiseSiblings) TThinkerIterator it; AActor *mo; - bool copy = !!(flags & RF_TRANSFERFRIENDLINESS); if (self->master != NULL) { while ((mo = it.Next()) != NULL) { if (mo->master == self->master && mo != self) { - P_Thing_Raise(mo, copy ? self : NULL, (flags & RF_NOCHECKPOSITION)); + P_Thing_Raise(mo, self, flags); } } } @@ -4562,7 +4552,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_RaiseSelf) { PARAM_SELF_PROLOGUE(AActor); PARAM_INT_DEF(flags); - ACTION_RETURN_BOOL(P_Thing_Raise(self, NULL, (flags & RF_NOCHECKPOSITION))); + ACTION_RETURN_BOOL(P_Thing_Raise(self, self, flags)); } //=========================================================================== @@ -4576,7 +4566,7 @@ DEFINE_ACTION_FUNCTION(AActor, RaiseActor) PARAM_SELF_PROLOGUE(AActor); PARAM_OBJECT(other, AActor); PARAM_INT_DEF(flags); - ACTION_RETURN_BOOL(P_Thing_Raise(other, self, (flags & RF_NOCHECKPOSITION))); + ACTION_RETURN_BOOL(P_Thing_Raise(other, self, flags)); } //=========================================================================== diff --git a/src/p_lnspec.cpp b/src/p_lnspec.cpp index 2422dfe19..58ed5d1e0 100644 --- a/src/p_lnspec.cpp +++ b/src/p_lnspec.cpp @@ -1764,7 +1764,7 @@ FUNC(LS_Thing_Raise) if (arg0==0) { - ok = P_Thing_Raise (it,NULL, arg1); + ok = P_Thing_Raise (it, it, arg1); } else { @@ -1772,7 +1772,7 @@ FUNC(LS_Thing_Raise) while ( (target = iterator.Next ()) ) { - ok |= P_Thing_Raise(target,NULL, arg1); + ok |= P_Thing_Raise(target, target, arg1); } } return ok; diff --git a/src/p_local.h b/src/p_local.h index e9c2d0f2e..9b41253a9 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -160,7 +160,7 @@ bool P_Thing_Move (int tid, AActor *source, int mapspot, bool fog); int P_Thing_Damage (int tid, AActor *whofor0, int amount, FName type); void P_Thing_SetVelocity(AActor *actor, const DVector3 &vec, bool add, bool setbob); void P_RemoveThing(AActor * actor); -bool P_Thing_Raise(AActor *thing, AActor *raiser, int nocheck = false); +bool P_Thing_Raise(AActor *thing, AActor *raiser, int flags = 0); bool P_Thing_CanRaise(AActor *thing); bool P_CanResurrect(AActor *ththing, AActor *thing); PClassActor *P_GetSpawnableType(int spawnnum); @@ -475,4 +475,10 @@ enum ETexReplaceFlags void P_ReplaceTextures(const char *fromname, const char *toname, int flags); +enum ERaise +{ + RF_TRANSFERFRIENDLINESS = 1, + RF_NOCHECKPOSITION = 2 +}; + #endif // __P_LOCAL__ diff --git a/src/p_things.cpp b/src/p_things.cpp index 0cd046c33..4d055e8f6 100644 --- a/src/p_things.cpp +++ b/src/p_things.cpp @@ -432,7 +432,7 @@ void P_RemoveThing(AActor * actor) } -bool P_Thing_Raise(AActor *thing, AActor *raiser, int nocheck) +bool P_Thing_Raise(AActor *thing, AActor *raiser, int flags) { if (!thing) return false; @@ -455,7 +455,7 @@ bool P_Thing_Raise(AActor *thing, AActor *raiser, int nocheck) thing->flags |= MF_SOLID; thing->Height = info->Height; // [RH] Use real height thing->radius = info->radius; // [RH] Use real radius - if (!nocheck && !P_CheckPosition (thing, thing->Pos())) + if (!(flags & RF_NOCHECKPOSITION) && !P_CheckPosition (thing, thing->Pos())) { thing->flags = oldflags; thing->radius = oldradius; @@ -470,7 +470,7 @@ bool P_Thing_Raise(AActor *thing, AActor *raiser, int nocheck) thing->Revive(); - if (raiser != NULL) + if ((flags & RF_TRANSFERFRIENDLINESS) && raiser != nullptr) { // Let's copy the friendliness of the one who raised it. thing->CopyFriendliness(raiser, false);