diff --git a/source/sw/src/game.h b/source/sw/src/game.h index 6e9b815e4..bffb576cc 100644 --- a/source/sw/src/game.h +++ b/source/sw/src/game.h @@ -2164,6 +2164,7 @@ void SetBorder(PLAYERp pp, int); void SetFragBar(PLAYERp pp); int Distance(int x1, int y1, int x2, int y2); short GetDeltaAngle(short, short); +fix16_t GetDeltaQ16Angle(fix16_t, fix16_t); int SetActorRotation(short SpriteNum,int,int); int NewStateGroup(short SpriteNum, STATEp SpriteGroup[]); diff --git a/source/sw/src/player.cpp b/source/sw/src/player.cpp index aac32f886..7ec50d68d 100644 --- a/source/sw/src/player.cpp +++ b/source/sw/src/player.cpp @@ -1153,6 +1153,25 @@ GetDeltaAngle(short ang1, short ang2) } +fix16_t +GetDeltaQ16Angle(fix16_t ang1, fix16_t ang2) +{ + // Look at the smaller angle if > 1024 (180 degrees) + if (fix16_abs(ang1 - ang2) > fix16_from_int(1024)) + { + if (ang1 <= fix16_from_int(1024)) + ang1 += fix16_from_int(2048); + + if (ang2 <= fix16_from_int(1024)) + ang2 += fix16_from_int(2048); + } + + //if (ang1 - ang2 == -fix16_from_int(1024)) + // return(fix16_from_int(1024)); + + return ang1 - ang2; +} + TARGET_SORT TargetSort[MAX_TARGET_SORT]; unsigned TargetSortCount;