Package: airstrike
Version: 0.99+1.0pre6a-3
Severity: important

There is a bug in the function that calculates collisions, when one of the
sprites has speed 0, it tries to do a division by zero (resulting in a nan).
This problem causes weird "out of playable window" sprites, making it unusable.

I could only reproduce this bug in amd64.

The patch attached fixes the problem.

-- System Information:
Debian Release: 4.0
  APT prefers unstable
  APT policy: (500, 'unstable'), (500, 'testing'), (1, 'experimental')
Architecture: amd64 (x86_64)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.18-3-amd64
Locale: LANG=es_AR.UTF-8, LC_CTYPE=es_AR.UTF-8 (charmap=UTF-8)

Versions of packages airstrike depends on:
ii  airstrike-common         0.99+1.0pre6a-3 2d dogfight game in the tradition 
ii  libc6                    2.3.6.ds1-10    GNU C Library: Shared libraries
ii  libsdl-image1.2          1.2.5-2+b1      image loading library for Simple D
ii  libsdl1.2debian          1.2.11-7        Simple DirectMedia Layer

airstrike recommends no packages.

-- no debconf information
diff -ruNa airstrike-0.99+1.0pre6a/src/mech.c 
airstrike-0.99+1.0pre6a.new/src/mech.c
--- airstrike-0.99+1.0pre6a/src/mech.c  2003-01-18 16:48:05.000000000 -0300
+++ airstrike-0.99+1.0pre6a.new/src/mech.c      2007-01-14 16:04:06.000000000 
-0300
@@ -335,11 +335,10 @@
     n[2]*((mech_sprite_t *)s1)->ang_vel +
     n[3]*((mech_sprite_t *)s2)->ang_vel;
 
-  if (a > 0)
-    {
-      b = n[0]*delta[0] + n[1]*delta[1] + n[2]*delta[2] 
+  b = n[0]*delta[0] + n[1]*delta[1] + n[2]*delta[2] 
        - n[0]*delta[3] - n[1]*delta[4] + n[3]*delta[5];
-      
+  if ( (a > 0) && (abs(b) > 0) )
+    {
       c = -1.4*a/b;
       
       s1->vel[0] += c*delta[0];
@@ -479,10 +478,9 @@
   a = n[0]*s1->vel[0] + n[1]*s1->vel[1] + 
     n[2]*((mech_sprite_t *)s1)->ang_vel;
 
-  if (a > 0)
+  b = n[0]*delta[0] + n[1]*delta[1] + n[2]*delta[2];
+  if ( (a > 0) && (abs(b) > 0) )
     {
-      b = n[0]*delta[0] + n[1]*delta[1] + n[2]*delta[2];
-      
       c = -1.2*a/b;
       
       s1->vel[0] += c*delta[0];

Reply via email to