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
This commit is contained in:
Major Cooke 2018-11-17 10:44:06 -06:00 committed by Christoph Oelckers
parent 45ef7bca4f
commit a8d4d45e89
4 changed files with 17 additions and 21 deletions

View file

@ -4477,13 +4477,6 @@ DEFINE_ACTION_FUNCTION(AActor, A_ChangeCountFlags)
return 0; return 0;
} }
enum ERaise
{
RF_TRANSFERFRIENDLINESS = 1,
RF_NOCHECKPOSITION = 2
};
//=========================================================================== //===========================================================================
// //
// A_RaiseMaster // A_RaiseMaster
@ -4494,10 +4487,9 @@ DEFINE_ACTION_FUNCTION(AActor, A_RaiseMaster)
PARAM_SELF_PROLOGUE(AActor); PARAM_SELF_PROLOGUE(AActor);
PARAM_INT_DEF(flags); PARAM_INT_DEF(flags);
bool copy = !!(flags & RF_TRANSFERFRIENDLINESS);
if (self->master != NULL) if (self->master != NULL)
{ {
P_Thing_Raise(self->master, copy ? self : NULL, (flags & RF_NOCHECKPOSITION)); P_Thing_Raise(self->master, self, flags);
} }
return 0; return 0;
} }
@ -4515,12 +4507,11 @@ DEFINE_ACTION_FUNCTION(AActor, A_RaiseChildren)
TThinkerIterator<AActor> it; TThinkerIterator<AActor> it;
AActor *mo; AActor *mo;
bool copy = !!(flags & RF_TRANSFERFRIENDLINESS);
while ((mo = it.Next()) != NULL) while ((mo = it.Next()) != NULL)
{ {
if (mo->master == self) if (mo->master == self)
{ {
P_Thing_Raise(mo, copy ? self : NULL, (flags & RF_NOCHECKPOSITION)); P_Thing_Raise(mo, self, flags);
} }
} }
return 0; return 0;
@ -4539,14 +4530,13 @@ DEFINE_ACTION_FUNCTION(AActor, A_RaiseSiblings)
TThinkerIterator<AActor> it; TThinkerIterator<AActor> it;
AActor *mo; AActor *mo;
bool copy = !!(flags & RF_TRANSFERFRIENDLINESS);
if (self->master != NULL) if (self->master != NULL)
{ {
while ((mo = it.Next()) != NULL) while ((mo = it.Next()) != NULL)
{ {
if (mo->master == self->master && mo != self) 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_SELF_PROLOGUE(AActor);
PARAM_INT_DEF(flags); 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_SELF_PROLOGUE(AActor);
PARAM_OBJECT(other, AActor); PARAM_OBJECT(other, AActor);
PARAM_INT_DEF(flags); PARAM_INT_DEF(flags);
ACTION_RETURN_BOOL(P_Thing_Raise(other, self, (flags & RF_NOCHECKPOSITION))); ACTION_RETURN_BOOL(P_Thing_Raise(other, self, flags));
} }
//=========================================================================== //===========================================================================

View file

@ -1764,7 +1764,7 @@ FUNC(LS_Thing_Raise)
if (arg0==0) if (arg0==0)
{ {
ok = P_Thing_Raise (it,NULL, arg1); ok = P_Thing_Raise (it, it, arg1);
} }
else else
{ {
@ -1772,7 +1772,7 @@ FUNC(LS_Thing_Raise)
while ( (target = iterator.Next ()) ) while ( (target = iterator.Next ()) )
{ {
ok |= P_Thing_Raise(target,NULL, arg1); ok |= P_Thing_Raise(target, target, arg1);
} }
} }
return ok; return ok;

View file

@ -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); 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_Thing_SetVelocity(AActor *actor, const DVector3 &vec, bool add, bool setbob);
void P_RemoveThing(AActor * actor); 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_Thing_CanRaise(AActor *thing);
bool P_CanResurrect(AActor *ththing, AActor *thing); bool P_CanResurrect(AActor *ththing, AActor *thing);
PClassActor *P_GetSpawnableType(int spawnnum); PClassActor *P_GetSpawnableType(int spawnnum);
@ -475,4 +475,10 @@ enum ETexReplaceFlags
void P_ReplaceTextures(const char *fromname, const char *toname, int flags); void P_ReplaceTextures(const char *fromname, const char *toname, int flags);
enum ERaise
{
RF_TRANSFERFRIENDLINESS = 1,
RF_NOCHECKPOSITION = 2
};
#endif // __P_LOCAL__ #endif // __P_LOCAL__

View file

@ -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) if (!thing)
return false; return false;
@ -455,7 +455,7 @@ bool P_Thing_Raise(AActor *thing, AActor *raiser, int nocheck)
thing->flags |= MF_SOLID; thing->flags |= MF_SOLID;
thing->Height = info->Height; // [RH] Use real height thing->Height = info->Height; // [RH] Use real height
thing->radius = info->radius; // [RH] Use real radius 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->flags = oldflags;
thing->radius = oldradius; thing->radius = oldradius;
@ -470,7 +470,7 @@ bool P_Thing_Raise(AActor *thing, AActor *raiser, int nocheck)
thing->Revive(); thing->Revive();
if (raiser != NULL) if ((flags & RF_TRANSFERFRIENDLINESS) && raiser != nullptr)
{ {
// Let's copy the friendliness of the one who raised it. // Let's copy the friendliness of the one who raised it.
thing->CopyFriendliness(raiser, false); thing->CopyFriendliness(raiser, false);