* Merge fixes for bug #9694 and bug #9704 which where fixed in r2349 and r2355 respectively from the 2.0 branch into trunk
git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@2356 4a71c877-e1ca-e34f-864e-861f7616d084master
parent
7e3837a2b5
commit
0d901ea836
|
@ -48,6 +48,10 @@
|
|||
* reload time: increased from 5 mins to 8 mins
|
||||
* chance to hit in the blast radius: reduced from 99% to 90%
|
||||
|
||||
0000-00-00: Version 2.0.8
|
||||
* Fix: bug #9694: crash upon receiving invalid sound ID numbers (out of bounds array access)
|
||||
* Fix: bug #9704: prevent divide by zero errors caused by ordering a VTOL to attack a droid at the same X & Y coordinates
|
||||
|
||||
2007-06-22: Version 2.0.7
|
||||
* General:
|
||||
* New: Screenshots are now saved as PNGs for better quality
|
||||
|
|
|
@ -265,7 +265,9 @@ const char *sound_GetTrackName( SDWORD iTrack )
|
|||
{
|
||||
// If we get an invalid track ID or there are
|
||||
// currently no tracks loaded then return NULL
|
||||
if (iTrack == SAMPLE_NOT_FOUND
|
||||
if (iTrack <= 0
|
||||
|| iTrack >= MAX_TRACKS
|
||||
|| iTrack == SAMPLE_NOT_FOUND
|
||||
|| g_apTrack == NULL)
|
||||
{
|
||||
return NULL;
|
||||
|
|
33
src/action.c
33
src/action.c
|
@ -653,7 +653,7 @@ BOOL actionVisibleTarget(DROID *psDroid, BASE_OBJECT *psTarget, int weapon_slot)
|
|||
static void actionAddVtolAttackRun( DROID *psDroid )
|
||||
{
|
||||
FRACT_D fA;
|
||||
SDWORD iVNx, iVNy, iA, iX, iY;
|
||||
SDWORD deltaX, deltaY, iA, iX, iY;
|
||||
BASE_OBJECT *psTarget;
|
||||
#if 0
|
||||
SDWORD iVx, iVy;
|
||||
|
@ -675,11 +675,11 @@ static void actionAddVtolAttackRun( DROID *psDroid )
|
|||
}
|
||||
|
||||
/* get normal vector from droid to target */
|
||||
iVNx = psTarget->x - psDroid->x;
|
||||
iVNy = psTarget->y - psDroid->y;
|
||||
deltaX = psTarget->x - psDroid->x;
|
||||
deltaY = psTarget->y - psDroid->y;
|
||||
|
||||
/* get magnitude of normal vector */
|
||||
fA = trigIntSqrt( iVNx*iVNx + iVNy*iVNy );
|
||||
/* get magnitude of normal vector (Pythagorean theorem) */
|
||||
fA = trigIntSqrt( deltaX*deltaX + deltaY*deltaY );
|
||||
iA = MAKEINT(fA);
|
||||
|
||||
#if 0
|
||||
|
@ -687,8 +687,8 @@ static void actionAddVtolAttackRun( DROID *psDroid )
|
|||
* swap normal vector elements and negate y:
|
||||
* scale to attack ellipse width
|
||||
*/
|
||||
iVx = iVNy * VTOL_ATTACK_WIDTH / iA;
|
||||
iVy = -iVNx * VTOL_ATTACK_WIDTH / iA;
|
||||
iVx = deltaY * VTOL_ATTACK_WIDTH / iA;
|
||||
iVy = -deltaX * VTOL_ATTACK_WIDTH / iA;
|
||||
|
||||
/* add waypoint left perpendicular to target*/
|
||||
iX = psTarget->x + iVx;
|
||||
|
@ -696,8 +696,23 @@ static void actionAddVtolAttackRun( DROID *psDroid )
|
|||
#endif
|
||||
|
||||
/* add waypoint behind target attack length away*/
|
||||
iX = psTarget->x + (iVNx * VTOL_ATTACK_LENGTH / iA);
|
||||
iY = psTarget->y + (iVNy * VTOL_ATTACK_LENGTH / iA);
|
||||
if (iA != 0)
|
||||
{
|
||||
iX = psTarget->x + (deltaX * VTOL_ATTACK_LENGTH / iA);
|
||||
iY = psTarget->y + (deltaY * VTOL_ATTACK_LENGTH / iA);
|
||||
}
|
||||
else
|
||||
{
|
||||
// We should only ever get here if both deltaX and deltaY
|
||||
// are zero (look at the above pythagoeran theorem).
|
||||
// This code is here to prevent a divide by zero error
|
||||
//
|
||||
// The next values are valid because if both deltas are zero
|
||||
// then iA will be zero as well resulting in:
|
||||
// (deltaXY * VTOL_ATTACK_LENGTH / iA) = (0 * VTOL_ATTACK_LENGTH / 0) = (0 / 0) = 0
|
||||
iX = psTarget->x;
|
||||
iY = psTarget->y;
|
||||
}
|
||||
|
||||
if ( iX<=0 || iY<=0 ||
|
||||
iX>(SDWORD)(GetWidthOfMap()<<TILE_SHIFT) ||
|
||||
|
|
Loading…
Reference in New Issue