From 4546df7dc32519520ff05d2be6b562b582a91658 Mon Sep 17 00:00:00 2001 From: Edoardo Prezioso Date: Thu, 28 May 2015 00:41:07 +0200 Subject: [PATCH] - Fixed SetActorPitch and ChangeActorPitch issue. The code did not take into account the player's limited pitch. --- src/actor.h | 2 +- src/p_mobj.cpp | 18 +++++++++++++++++- src/thingdef/thingdef_codeptr.cpp | 18 +----------------- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/actor.h b/src/actor.h index 81b0a8b7b..b38d4b2e0 100644 --- a/src/actor.h +++ b/src/actor.h @@ -823,7 +823,7 @@ public: } // These also set CF_INTERPVIEW for players. - void SetPitch(int p, bool interpolate); + void SetPitch(int p, bool interpolate, bool forceclamp = false); void SetAngle(angle_t ang, bool interpolate); void SetRoll(angle_t roll, bool interpolate); diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index 588bc2dcc..b0fc0d08e 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -3115,8 +3115,24 @@ void AActor::SetShade (int r, int g, int b) fillcolor = MAKEARGB(ColorMatcher.Pick (r, g, b), r, g, b); } -void AActor::SetPitch(int p, bool interpolate) +void AActor::SetPitch(int p, bool interpolate, bool forceclamp) { + if (player != NULL || forceclamp) + { // clamp the pitch we set + int min, max; + + if (player != NULL) + { + min = player->MinPitch; + max = player->MaxPitch; + } + else + { + min = -ANGLE_90 + (1 << ANGLETOFINESHIFT); + max = ANGLE_90 - (1 << ANGLETOFINESHIFT); + } + p = clamp(p, min, max); + } if (p != pitch) { pitch = p; diff --git a/src/thingdef/thingdef_codeptr.cpp b/src/thingdef/thingdef_codeptr.cpp index 6ac0f115b..15d8291fc 100644 --- a/src/thingdef/thingdef_codeptr.cpp +++ b/src/thingdef/thingdef_codeptr.cpp @@ -3989,23 +3989,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetPitch) return; } - if (ref->player != NULL || (flags & SPF_FORCECLAMP)) - { // clamp the pitch we set - int min, max; - - if (ref->player != NULL) - { - min = ref->player->MinPitch; - max = ref->player->MaxPitch; - } - else - { - min = -ANGLE_90 + (1 << ANGLETOFINESHIFT); - max = ANGLE_90 - (1 << ANGLETOFINESHIFT); - } - pitch = clamp(pitch, min, max); - } - ref->SetPitch(pitch, !!(flags & SPF_INTERPOLATE)); + ref->SetPitch(pitch, !!(flags & SPF_INTERPOLATE), !!(flags & SPF_FORCECLAMP)); } //===========================================================================