From d8daf039694bce542e39ae8c57e21a35713480f4 Mon Sep 17 00:00:00 2001 From: avolkov Date: Wed, 28 Oct 2009 05:00:07 +0000 Subject: [PATCH] Do not try an orbital insertion when the ship is not moving; bug #648 git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@3259 8092fc87-c524-0410-9efc-e669fe64eaf9 --- sc2/ChangeLog | 1 + sc2/src/uqm/cyborg.c | 7 ++++--- sc2/src/uqm/velocity.h | 8 ++++++++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/sc2/ChangeLog b/sc2/ChangeLog index b95df910b..f6d9b4f1a 100644 --- a/sc2/ChangeLog +++ b/sc2/ChangeLog @@ -1,4 +1,5 @@ Changes towards version 0.7: +- Fixed AI ship not moving on warp in (bug #648) - Alex - Revert gfx settings entirely when a mode switch fails (bug #1056) - Alex - Fixed the Syreen lights-out scene timing (bug #1011) - Alex - Added a native error box for MacOSX (like we have for Windows) - Alex diff --git a/sc2/src/uqm/cyborg.c b/sc2/src/uqm/cyborg.c index f2e6c329d..f8fc5ba23 100644 --- a/sc2/src/uqm/cyborg.c +++ b/sc2/src/uqm/cyborg.c @@ -1124,13 +1124,14 @@ if (!(ShipPtr->state_flags & FINITE_LIFE) ed.facing = ARCTAN (-dx, -dy); if (UltraManeuverable) ed.MoveState = AVOID; - else + else // Try a gravity whip ed.MoveState = ENTICE; ObjectsOfConcern[GRAVITY_MASS_INDEX] = ed; } - else if (!UltraManeuverable) - { + else if (!UltraManeuverable && + !IsVelocityZero (&Ship.velocity)) + { // Try an orbital insertion, don't thrust ++Ship.thrust_wait; if (Ship.turn_wait) ShipMoved = TRUE; diff --git a/sc2/src/uqm/velocity.h b/sc2/src/uqm/velocity.h index 29d19cf6e..eb2585b17 100644 --- a/sc2/src/uqm/velocity.h +++ b/sc2/src/uqm/velocity.h @@ -45,6 +45,14 @@ extern void SetVelocityComponents (VELOCITY_DESC *velocityptr, SIZE dx, extern void DeltaVelocityComponents (VELOCITY_DESC *velocityptr, SIZE dx, SIZE dy); +static inline BOOLEAN +IsVelocityZero (VELOCITY_DESC *vptr) +{ + return vptr->vector.width == 0 && vptr->vector.height == 0 && + vptr->incr.width == 0 && vptr->incr.height == 0 && + vptr->fract.width == 0 && vptr->fract.height == 0; +} + static inline DWORD VelocitySquared (SIZE dx, SIZE dy) {