Revert "Fixed some lines of code"
authorparasti <parasti@78b8d119-cf0a-0410-b17c-f493084dd1d7>
Fri, 28 Mar 2008 13:08:51 +0000 (13:08 +0000)
committerparasti <parasti@78b8d119-cf0a-0410-b17c-f493084dd1d7>
Fri, 28 Mar 2008 13:08:51 +0000 (13:08 +0000)
git-svn-id: https://s.snth.net/svn/neverball/trunk@1962 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 d66c6c7..b495d74 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 int   jump_u = 0;                /* Which ball is jumping?            */
 static float jump_dt;                   /* Jump duration                     */
+static int   jump_u = 0;                /* Which ball is jumping?            */
 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,6 +404,16 @@ 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)
 {
@@ -807,14 +817,11 @@ void game_draw(int pose, float t)
 {
     float fov = view_fov;
 
-    if (jump_b)
-    {
-        if (jump_u == 0)
-            fov *= 2.0f * fabsf(jump_dt - 0.5f);
+    if (jump_b && jump_u)
+        fov /= 1.9f * fabsf(jump_dt - 0.5f);
 
-        else
-            fov /= 1.9f * fabsf(jump_dt - 0.5f);
-    }
+    else if (jump_b)
+        fov *= 2.0f * fabsf(jump_dt - 0.5f);
 
     if (game_state)
     {
@@ -1046,28 +1053,39 @@ 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_e == 1 &&
-            jump_b == 0 &&
+        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;
+            jump_u  = i + 1;
 
             audio_play(AUD_JUMP, 1.f);
         }
-
-        if (jump_e == 0 &&
-            jump_b == 0 &&
-            jump_u == i &&
+        if (jump_e == 0 && jump_b == 0 &&
             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. */
@@ -1147,6 +1165,8 @@ 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)
@@ -1191,6 +1211,7 @@ 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 5aab4f7..9d73efb 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; j++)
+        for (j = i + 1; j < fp->uc && (i > curr_party() || config_get_d(CONFIG_BALL_COLLISIONS)); 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[5][4] = {
+    static const GLfloat color[6][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,14 +378,11 @@ void game_draw(int pose, float t)
 
     int i = 0;
 
-    if (jump_b)
-    {
-        if (jump_u == ball)
-            fov *= 2.0f * fabsf(jump_dt - 0.5f);
+    if (config_get_d(CONFIG_BALL_COLLISIONS) && jump_b && jump_u != ball * 2)
+        fov /= 1.9f * fabsf(jump_dt - 0.5f);
 
-        else
-            fov /= 1.9f * fabsf(jump_dt - 0.5f);
-    }
+    else if (jump_b)
+        fov *= 2.0f * fabsf(jump_dt - 0.5f);
 
     config_push_persp(fov, 0.1f, FAR_DIST);
     glPushAttrib(GL_LIGHTING_BIT);
@@ -563,40 +560,52 @@ static int game_update_state(float dt)
 
     /* Test for a jump. */
 
-    for (i = 0; i < fp->uc; i++)
+    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
     {
-        if (jump_e == 1 &&
-            jump_b == 0 &&
-            sol_jump_test(fp, jump_p, i) == 1)
+        if (jump_e == 1 && jump_b == 0 && sol_jump_test(fp, jump_p, ball) == 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 &&
-            jump_u == i &&
-            sol_jump_test(fp, jump_p, i) == 0)
-        {
-            /* Enable jumping after jump finished */
+        if (jump_e == 0 && jump_b == 0 && sol_jump_test(fp, jump_p, ball) == 0)
             jump_e = 1;
-        }
     }
 
     /* Test for fall-out. */
 
-    if (fp->uv[ball].p[1] < -10.f)
+    if (fp->uv[ball].p[1] < -10.0f)
         return GAME_FALL;
 
     /* Test for a goal or stop. */
 
-    if (t > 1.f)
+    if (t > 1.0f)
     {
-        t = 0.f;
+        t = 0.0f;
 
         switch (sol_goal_test(fp, p, ball) & ((fp->uv[ball].P) ? (3) : (1)))
         {
@@ -652,20 +661,39 @@ int game_step(const float g[3], float dt)
 
     if (jump_b)
     {
-        jump_dt += dt;
+        if (config_get_d(CONFIG_BALL_COLLISIONS))
+        {
+            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 (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 (1.f < jump_dt)
+        else
         {
-            jump_b = 0;
+            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;
         }
     }
     else
@@ -708,9 +736,19 @@ void game_putt(void)
      * friction too early and stopping the ball prematurely.
      */
 
-    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;
+    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;
+    }
 
     view_m = 0.f;
 }
@@ -876,4 +914,3 @@ void game_set_pos(float p[3], float e[3][3])
 }
 
 /*---------------------------------------------------------------------------*/
-
index 30fe56f..27311b7 100644 (file)
@@ -134,7 +134,7 @@ char *hole_tot(int p)
 
     if (p <= party)
     {
-        for (h = 1; h <= hole && h < count; h++)
+        for (h = 1; h <= hole && h <= 18; 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 <= count / 2; h++)
+        for (h = 1; h <= hole && h <= 9; h++)
             T += score_v[h][p];
 
         sprintf(str, "%d", T);
index 52031fa..12ab0ba 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.f, -9.8f, 0.f };
+    float g[3] = { 0.0f, -9.8f, 0.0f };
 
     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.f, -9.8f, 0.f };
+    float g[3] = { 0.0f, -9.8f, 0.0f };
 
     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.f, -9.8f, 0.f };
+    float g[3] = { 0.0f, -9.8f, 0.0f };
 
     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.f, -9.8f, 0.f };
+    float g[3] = { 0.0f, -9.8f, 0.0f };
 
     game_update_view(dt);
     game_step(g, dt);
index 2c6859b..4f50c3a 100644 (file)
@@ -2374,4 +2374,3 @@ int main(int argc, char *argv[])
 
     return 0;
 }
-
index bdba148..c0e3cff 100644 (file)
@@ -920,7 +920,6 @@ 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));
 }
 
@@ -1495,6 +1494,7 @@ 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)
+                    if ((e = (v_len(up->v) - dt)) > 0.0f) /* GDB tells me this is where the problem lies. I'll look into it */
                     {
                         /* Scale the linear velocity. */
 
@@ -1828,4 +1828,3 @@ void get_file_state(FILE *fin, struct s_file *fp)
 }
 
 /*---------------------------------------------------------------------------*/
-
index e287efb..a97219a 100644 (file)
@@ -53,6 +53,7 @@
  *     d  Dictionary    (struct s_dict)
  *     i  Index         (int)
  *     a  Text          (char)
+
  *
  * The Ys are as follows:
  *