Fixed some lines of code
authorKrabbyKrap <KrabbyKrap@78b8d119-cf0a-0410-b17c-f493084dd1d7>
Thu, 27 Mar 2008 23:49:51 +0000 (23:49 +0000)
committerKrabbyKrap <KrabbyKrap@78b8d119-cf0a-0410-b17c-f493084dd1d7>
Thu, 27 Mar 2008 23:49:51 +0000 (23:49 +0000)
git-svn-id: https://s.snth.net/svn/neverball/trunk@1960 78b8d119-cf0a-0410-b17c-f493084dd1d7

ball/game.c
putt/game.c
putt/hole.c
putt/st_all.c
share/mapc.c
share/solid.c
share/solid.h

index b495d74..d66c6c7 100644 (file)
@@ -58,8 +58,8 @@ static int   goal_e = 0;                /* Goal enabled flag                 */
 static float goal_k = 0;                /* Goal animation                    */
 static int   jump_e = 1;                /* Jumping enabled flag              */
 static int   jump_b = 0;                /* Jump-in-progress flag             */
-static float jump_dt;                   /* Jump duration                     */
 static int   jump_u = 0;                /* Which ball is jumping?            */
+static float jump_dt;                   /* Jump duration                     */
 static float jump_p[3];                 /* Jump destination                  */
 static float fade_k = 0.0;              /* Fade in/out level                 */
 static float fade_d = 0.0;              /* Fade in/out direction             */
@@ -404,16 +404,6 @@ int curr_coins(void)
 
 /*---------------------------------------------------------------------------*/
 
-/*
- * Here for any possible future implementations, eg network play
- */
-
-static void game_handle_balls(struct s_file *fp)
-{
-}
-
-/*---------------------------------------------------------------------------*/
-
 static void game_draw_balls(const struct s_file *fp,
                             const float *bill_M, float t)
 {
@@ -817,11 +807,14 @@ void game_draw(int pose, float t)
 {
     float fov = view_fov;
 
-    if (jump_b && jump_u)
-        fov /= 1.9f * fabsf(jump_dt - 0.5f);
+    if (jump_b)
+    {
+        if (jump_u == 0)
+            fov *= 2.0f * fabsf(jump_dt - 0.5f);
 
-    else if (jump_b)
-        fov *= 2.0f * fabsf(jump_dt - 0.5f);
+        else
+            fov /= 1.9f * fabsf(jump_dt - 0.5f);
+    }
 
     if (game_state)
     {
@@ -1053,39 +1046,28 @@ static int game_update_state(int bt)
 
     /* Test for a jump. */
 
-    if (!jump_u && jump_e == 1 && jump_b == 0 &&
-        sol_jump_test(fp, jump_p, 0) == 1)
-    {
-        jump_b  = 1;
-        jump_e  = 0;
-        jump_dt = 0.f;
-        jump_u  = 0;
-
-        audio_play(AUD_JUMP, 1.f);
-    }
-    if (jump_e == 0 && jump_b == 0 && sol_jump_test(fp, jump_p, 0) == 0)
-        jump_e = 1;
-    if (!jump_b && !jump_u && sol_jump_test(fp, jump_p, 0) == 0)
-        jump_u = 0;
-
     for (i = 0; i < fp->uc; i++)
     {
-        if (!jump_u && jump_e == 1 && jump_b == 0 &&
+        if (jump_e == 1 &&
+            jump_b == 0 &&
             sol_jump_test(fp, jump_p, i) == 1)
         {
             jump_b  = 1;
             jump_e  = 0;
             jump_dt = 0.f;
-            jump_u  = i + 1;
+            jump_u  = i;
 
             audio_play(AUD_JUMP, 1.f);
         }
-        if (jump_e == 0 && jump_b == 0 &&
+
+        if (jump_e == 0 &&
+            jump_b == 0 &&
+            jump_u == i &&
             sol_jump_test(fp, jump_p, i) == 0)
+        {
+            /* Enable jumping after jump finished */
             jump_e = 1;
-        if (!jump_b && jump_u && i == jump_u - 1 &&
-            sol_jump_test(fp, jump_p, i) == 0)
-            jump_u = 0;
+        }
     }
 
     /* Test for a goal. */
@@ -1165,8 +1147,6 @@ int game_step(const float g[3], float dt, int bt)
 
             float b = sol_step(fp, h, dt, 0, NULL);
 
-            game_handle_balls(fp);
-
             /* Mix the sound of a ball bounce. */
 
             if (b > 0.5f)
@@ -1211,7 +1191,6 @@ void game_clr_goal(void)
  * Set ball B's play state as S.  Additional values can be used for b:
  * -1: Set current ball to s
  * -2: Set all balls to s
- *
  */
 
 void game_set_play(int b, int s)
index 9d73efb..5aab4f7 100644 (file)
@@ -161,7 +161,7 @@ static void game_handle_balls(struct s_file *fp)
         * If there are any, reset the proper
         * ball's play state
         */
-        for (j = i + 1; j < fp->uc && (i > curr_party() || config_get_d(CONFIG_BALL_COLLISIONS)); j++)
+        for (j = i + 1; j < fp->uc; j++)
         {
             struct s_ball *u2p = fp->uv + j;
             float d[3];
@@ -245,7 +245,7 @@ static void game_draw_vect(const struct s_file *fp)
 static void game_draw_balls(const struct s_file *fp,
                             const float *bill_M, float t)
 {
-    static const GLfloat color[6][4] = {
+    static const GLfloat color[5][4] = {
         { 1.0f, 1.0f, 1.0f, 0.7f },
         { 1.0f, 0.0f, 0.0f, 1.0f },
         { 0.0f, 1.0f, 0.0f, 1.0f },
@@ -378,11 +378,14 @@ void game_draw(int pose, float t)
 
     int i = 0;
 
-    if (config_get_d(CONFIG_BALL_COLLISIONS) && jump_b && jump_u != ball * 2)
-        fov /= 1.9f * fabsf(jump_dt - 0.5f);
+    if (jump_b)
+    {
+        if (jump_u == ball)
+            fov *= 2.0f * fabsf(jump_dt - 0.5f);
 
-    else if (jump_b)
-        fov *= 2.0f * fabsf(jump_dt - 0.5f);
+        else
+            fov /= 1.9f * fabsf(jump_dt - 0.5f);
+    }
 
     config_push_persp(fov, 0.1f, FAR_DIST);
     glPushAttrib(GL_LIGHTING_BIT);
@@ -560,52 +563,40 @@ static int game_update_state(float dt)
 
     /* Test for a jump. */
 
-    if (config_get_d(CONFIG_BALL_COLLISIONS))
-    {
-        for (i = 0; i < fp->uc; i++)
-        {
-            if (!jump_u && jump_e == 1 && jump_b == 0 &&
-                           sol_jump_test(fp, jump_p, i) == 1)
-            {
-                jump_b  = 1;
-                jump_e  = 0;
-                jump_dt = 0.f;
-                jump_u  = i;
-
-                audio_play(AUD_JUMP, 1.f);
-            }
-            if (jump_e == 0 && jump_b == 0 &&
-                sol_jump_test(fp, jump_p, i) == 0)
-                jump_e = 1;
-            if (!jump_b && jump_u && i == jump_u / 2 &&
-                sol_jump_test(fp, jump_p, i) == 0)
-                jump_u = 0;
-        }
-    }
-    else
+    for (i = 0; i < fp->uc; i++)
     {
-        if (jump_e == 1 && jump_b == 0 && sol_jump_test(fp, jump_p, ball) == 1)
+        if (jump_e == 1 &&
+            jump_b == 0 &&
+            sol_jump_test(fp, jump_p, i) == 1)
         {
+            /* Initialize a jump */
             jump_b  = 1;
             jump_e  = 0;
             jump_dt = 0.f;
+            jump_u  = i;
 
             audio_play(AUD_JUMP, 1.f);
         }
-        if (jump_e == 0 && jump_b == 0 && sol_jump_test(fp, jump_p, ball) == 0)
+        if (jump_e == 0 &&
+            jump_b == 0 &&
+            jump_u == i &&
+            sol_jump_test(fp, jump_p, i) == 0)
+        {
+            /* Enable jumping after jump finished */
             jump_e = 1;
+        }
     }
 
     /* Test for fall-out. */
 
-    if (fp->uv[ball].p[1] < -10.0f)
+    if (fp->uv[ball].p[1] < -10.f)
         return GAME_FALL;
 
     /* Test for a goal or stop. */
 
-    if (t > 1.0f)
+    if (t > 1.f)
     {
-        t = 0.0f;
+        t = 0.f;
 
         switch (sol_goal_test(fp, p, ball) & ((fp->uv[ball].P) ? (3) : (1)))
         {
@@ -661,39 +652,20 @@ int game_step(const float g[3], float dt)
 
     if (jump_b)
     {
-        if (config_get_d(CONFIG_BALL_COLLISIONS))
-        {
-            jump_dt += dt;
+        jump_dt += dt;
 
-            /* Handle a jump. */
+        /* Handle a jump. */
 
-            if (0.5 < jump_dt)
-            {
-                fp->uv[jump_u].p[0] = jump_p[0];
-                fp->uv[jump_u].p[1] = jump_p[1];
-                fp->uv[jump_u].p[2] = jump_p[2];
-            }
-
-            if (1.f < jump_dt)
-            {
-                jump_b = 0;
-            }
+        if (0.5 < jump_dt)
+        {
+            fp->uv[jump_u].p[0] = jump_p[0];
+            fp->uv[jump_u].p[1] = jump_p[1];
+            fp->uv[jump_u].p[2] = jump_p[2];
         }
 
-        else
+        if (1.f < jump_dt)
         {
-            jump_dt += dt;
-
-            /* Handle a jump. */
-
-            if (0.5 < jump_dt)
-            {
-                fp->uv[ball].p[0] = jump_p[0];
-                fp->uv[ball].p[1] = jump_p[1];
-                fp->uv[ball].p[2] = jump_p[2];
-            }
-            if (1.f < jump_dt)
-                jump_b = 0;
+            jump_b = 0;
         }
     }
     else
@@ -736,19 +708,9 @@ void game_putt(void)
      * friction too early and stopping the ball prematurely.
      */
 
-    if (config_get_d(CONFIG_BALL_COLLISIONS))
-    {
-        file.uv[ball].v[0] = -4.f * view_e[2][0] * view_m;
-        file.uv[ball].v[1] = -4.f * view_e[2][1] * view_m + BALL_FUDGE;
-        file.uv[ball].v[2] = -4.f * view_e[2][2] * view_m;
-    }
-
-    else
-    {
-        file.uv[ball].v[0] = -4.f * view_e[2][0] * view_m;
-        file.uv[ball].v[1] = -4.f * view_e[2][1] * view_m + BALL_FUDGE;
-        file.uv[ball].v[2] = -4.f * view_e[2][2] * view_m;
-    }
+    file.uv[ball].v[0] = -4.f * view_e[2][0] * view_m;
+    file.uv[ball].v[1] = -4.f * view_e[2][1] * view_m + BALL_FUDGE;
+    file.uv[ball].v[2] = -4.f * view_e[2][2] * view_m;
 
     view_m = 0.f;
 }
@@ -914,3 +876,4 @@ void game_set_pos(float p[3], float e[3][3])
 }
 
 /*---------------------------------------------------------------------------*/
+
index 27311b7..30fe56f 100644 (file)
@@ -134,7 +134,7 @@ char *hole_tot(int p)
 
     if (p <= party)
     {
-        for (h = 1; h <= hole && h <= 18; h++)
+        for (h = 1; h <= hole && h < count; h++)
             T += score_v[h][p];
 
         sprintf(str, "%d", T);
@@ -152,7 +152,7 @@ char *hole_out(int p)
 
     if (p <= party)
     {
-        for (h = 1; h <= hole && h <= 9; h++)
+        for (h = 1; h <= hole && h <= count / 2; h++)
             T += score_v[h][p];
 
         sprintf(str, "%d", T);
index 12ab0ba..52031fa 100644 (file)
@@ -239,7 +239,7 @@ static void title_paint(int id, float t)
 
 static void title_timer(int id, float dt)
 {
-    float g[3] = { 0.0f, -9.8f, 0.0f };
+    float g[3] = { 0.f, -9.8f, 0.f };
 
     game_step(g, dt);
     game_set_fly(fcosf(time_state() / 10.f));
@@ -895,7 +895,7 @@ static void stroke_paint(int id, float t)
 
 static void stroke_timer(int id, float dt)
 {
-    float g[3] = { 0.0f, -9.8f, 0.0f };
+    float g[3] = { 0.f, -9.8f, 0.f };
 
     float k;
 
@@ -974,7 +974,7 @@ static void roll_paint(int id, float t)
 
 static void roll_timer(int id, float dt)
 {
-    float g[3] = { 0.0f, -9.8f, 0.0f };
+    float g[3] = { 0.f, -9.8f, 0.f };
 
     switch (game_step(g, dt))
     {
@@ -1093,7 +1093,7 @@ static void stop_paint(int id, float t)
 
 static void stop_timer(int id, float dt)
 {
-    float g[3] = { 0.0f, -9.8f, 0.0f };
+    float g[3] = { 0.f, -9.8f, 0.f };
 
     game_update_view(dt);
     game_step(g, dt);
index 4f50c3a..2c6859b 100644 (file)
@@ -2374,3 +2374,4 @@ int main(int argc, char *argv[])
 
     return 0;
 }
+
index c0e3cff..bdba148 100644 (file)
@@ -920,6 +920,7 @@ static float sol_bounce(struct s_ball *up,
     v_mad(p, q, n, up->r);
 
     /* Return the "energy" of the impact, to determine the sound amplitude. */
+
     return fabsf(v_dot(n, d));
 }
 
@@ -1494,7 +1495,6 @@ static float sol_test_file(float dt,
             t = u;
         }
     }
-
     return t;
 }
 
@@ -1542,7 +1542,7 @@ float sol_step(struct s_file *fp, const float *g, float dt, int ui, int *m)
 
                 if ((d = v_dot(r, g) / (v_len(r) * v_len(g))) > 0.999f)
                 {
-                    if ((e = (v_len(up->v) - dt)) > 0.0f) /* GDB tells me this is where the problem lies. I'll look into it */
+                    if ((e = (v_len(up->v) - dt)) > 0.0f)
                     {
                         /* Scale the linear velocity. */
 
@@ -1828,3 +1828,4 @@ void get_file_state(FILE *fin, struct s_file *fp)
 }
 
 /*---------------------------------------------------------------------------*/
+
index a97219a..e287efb 100644 (file)
@@ -53,7 +53,6 @@
  *     d  Dictionary    (struct s_dict)
  *     i  Index         (int)
  *     a  Text          (char)
-
  *
  * The Ys are as follows:
  *