Fix undefined C usage
authorparasti <parasti@78b8d119-cf0a-0410-b17c-f493084dd1d7>
Mon, 25 Oct 2010 21:07:37 +0000 (21:07 +0000)
committerparasti <parasti@78b8d119-cf0a-0410-b17c-f493084dd1d7>
Mon, 25 Oct 2010 21:07:37 +0000 (21:07 +0000)
Subtracting to before the first item in an array is apparently asking
for trouble even if I don't intend to use the value.

git-svn-id: https://s.snth.net/svn/neverball/trunk@3325 78b8d119-cf0a-0410-b17c-f493084dd1d7

share/solid_sim_sol.c

index b4f2f6c..f2dd8fb 100644 (file)
@@ -704,16 +704,17 @@ float sol_step(struct s_file *fp, const float *g, float dt, int ui, int *m)
             for (bi = 0; bi < fp->bc; bi++)
             {
                 struct s_body *bp = fp->bv + bi;
-                struct s_path *pp = fp->pv + bp->pi;
 
-                if (bp->pi < 0)
-                    continue;
+                if (bp->pi >= 0)
+                {
+                    struct s_path *pp = fp->pv + bp->pi;
 
-                if (!pp->f)
-                    continue;
+                    if (!pp->f)
+                        continue;
 
-                if (bp->t + st > pp->t)
-                    st = pp->t - bp->t;
+                    if (bp->t + st > pp->t)
+                        st = pp->t - bp->t;
+                }
             }
 
             nt = sol_test_file(st, P, V, up, fp);