From 40c906f10d16a41aabd8cc00a7c1b29dbc3ea333 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 7 Apr 2012 20:44:28 +0000 Subject: [PATCH] - fixed new A_Facetarget pitch code which made some incorrect assumptions about variables' signedness. - fixed a few compiler warnings. SVN r3535 (trunk) --- src/p_enemy.cpp | 24 ++++++------------------ src/thingdef/thingdef_codeptr.cpp | 4 ++-- 2 files changed, 8 insertions(+), 20 deletions(-) diff --git a/src/p_enemy.cpp b/src/p_enemy.cpp index 796480c9c6..45cc9fec78 100644 --- a/src/p_enemy.cpp +++ b/src/p_enemy.cpp @@ -2784,31 +2784,19 @@ void A_Face (AActor *self, AActor *other, angle_t max_turn, angle_t max_pitch) double dist_z = self->target->z - self->z; double dist = sqrt(dist_x*dist_x + dist_y*dist_y + dist_z*dist_z); - angle_t other_pitch = rad2bam(asin(dist_z / dist)); + int other_pitch = (int)rad2bam(asin(dist_z / dist)); - if (max_pitch && (max_pitch < (angle_t)abs(self->pitch - other_pitch))) + if (max_pitch != 0) { if (self->pitch > other_pitch) { - if (self->pitch - other_pitch < ANGLE_180) - { - self->pitch -= max_pitch; - } - else - { - self->pitch += max_pitch; - } + max_pitch = MIN(max_pitch, unsigned(self->pitch - other_pitch)); + self->pitch -= max_pitch; } else { - if (other_pitch - self->pitch < ANGLE_180) - { - self->pitch += max_pitch; - } - else - { - self->pitch -= max_pitch; - } + max_pitch = MIN(max_pitch, unsigned(other_pitch - self->pitch)); + self->pitch += max_pitch; } } else diff --git a/src/thingdef/thingdef_codeptr.cpp b/src/thingdef/thingdef_codeptr.cpp index d2f5bca9df..451f365058 100644 --- a/src/thingdef/thingdef_codeptr.cpp +++ b/src/thingdef/thingdef_codeptr.cpp @@ -1428,7 +1428,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_RailAttack) slope = pr_crailgun.Random2() * (Spread_Z / 255); } - P_RailAttack (self, Damage, Spawnofs_XY, Color1, Color2, MaxDiff, (Flags & RAF_SILENT), PuffType, (!(Flags & RAF_NOPIERCE)), angle, slope, Range, (Flags & RAF_FULLBRIGHT), Duration, Sparsity, DriftSpeed, SpawnClass); + P_RailAttack (self, Damage, Spawnofs_XY, Color1, Color2, MaxDiff, !!(Flags & RAF_SILENT), PuffType, (!(Flags & RAF_NOPIERCE)), angle, slope, Range, !!(Flags & RAF_FULLBRIGHT), Duration, Sparsity, DriftSpeed, SpawnClass); } //========================================================================== @@ -1546,7 +1546,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomRailgun) slopeoffset = pr_crailgun.Random2() * (Spread_Z / 255); } - P_RailAttack (self, Damage, Spawnofs_XY, Color1, Color2, MaxDiff, (Flags & RAF_SILENT), PuffType, (!(Flags & RAF_NOPIERCE)), angleoffset, slopeoffset, Range, (Flags & RAF_FULLBRIGHT), Duration, Sparsity, DriftSpeed, SpawnClass); + P_RailAttack (self, Damage, Spawnofs_XY, Color1, Color2, MaxDiff, !!(Flags & RAF_SILENT), PuffType, (!(Flags & RAF_NOPIERCE)), angleoffset, slopeoffset, Range, !!(Flags & RAF_FULLBRIGHT), Duration, Sparsity, DriftSpeed, SpawnClass); self->x = saved_x; self->y = saved_y;