fixed bugs in game logic of "game of life" and "biomaze" elements
authorHolger Schemel <info@artsoft.org>
Wed, 10 Oct 2018 20:45:55 +0000 (22:45 +0200)
committerHolger Schemel <info@artsoft.org>
Wed, 10 Oct 2018 20:46:17 +0000 (22:46 +0200)
src/game.c

index fefe353d0e1194cd12a2349fdcda8981961c8895..18d020bdf802d695ae9d10429b854a4613916456 100644 (file)
@@ -8896,6 +8896,7 @@ static void Life(int ax, int ay)
   int *life_parameter = (element == EL_GAME_OF_LIFE ? level.game_of_life :
                         level.biomaze);
   boolean changed = FALSE;
   int *life_parameter = (element == EL_GAME_OF_LIFE ? level.game_of_life :
                         level.biomaze);
   boolean changed = FALSE;
+  boolean use_life_bugs = FALSE;
 
   if (IS_ANIMATED(graphic))
     DrawLevelGraphicAnimationIfNeeded(ax, ay, graphic);
 
   if (IS_ANIMATED(graphic))
     DrawLevelGraphicAnimationIfNeeded(ax, ay, graphic);
@@ -8929,13 +8930,28 @@ static void Life(int ax, int ay)
       if (!IN_LEV_FIELD(x, y) || (x == xx && y == yy))
        continue;
 
       if (!IN_LEV_FIELD(x, y) || (x == xx && y == yy))
        continue;
 
-      if (((Feld[x][y] == element ||
-           (element == EL_GAME_OF_LIFE && IS_PLAYER(x, y))) &&
-          !Stop[x][y]) ||
-         (IS_FREE(x, y) && Stop[x][y]))
+      boolean is_player_cell = (element == EL_GAME_OF_LIFE && IS_PLAYER(x, y));
+      boolean is_neighbour = FALSE;
+
+      if (use_life_bugs)
+       is_neighbour =
+         (((Feld[x][y] == element || is_player_cell) && !Stop[x][y]) ||
+          (IS_FREE(x, y)                             &&  Stop[x][y]));
+      else
+       is_neighbour =
+         (Last[x][y] == element || is_player_cell);
+
+      if (is_neighbour)
        num_neighbours++;
     }
 
        num_neighbours++;
     }
 
+    boolean is_free = FALSE;
+
+    if (use_life_bugs)
+      is_free = (IS_FREE(xx, yy));
+    else
+      is_free = (IS_FREE(xx, yy) && Last[xx][yy] == EL_EMPTY);
+
     if (xx == ax && yy == ay)          /* field in the middle */
     {
       if (num_neighbours < life_parameter[0] ||
     if (xx == ax && yy == ay)          /* field in the middle */
     {
       if (num_neighbours < life_parameter[0] ||
@@ -8948,7 +8964,7 @@ static void Life(int ax, int ay)
        changed = TRUE;
       }
     }
        changed = TRUE;
       }
     }
-    else if (IS_FREE(xx, yy) || CAN_GROW_INTO(Feld[xx][yy]))
+    else if (is_free || CAN_GROW_INTO(Feld[xx][yy]))
     {                                  /* free border field */
       if (num_neighbours >= life_parameter[2] &&
          num_neighbours <= life_parameter[3])
     {                                  /* free border field */
       if (num_neighbours >= life_parameter[2] &&
          num_neighbours <= life_parameter[3])