From 172a34e8d64ad71e6eee7871803e9faee7669ca3 Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Wed, 10 Oct 2018 19:51:04 +0200 Subject: [PATCH 1/1] fixed bug with redrawing state changes for "game of life" style elements The cause for this bug was checking the "Stop[][]" field for deciding if a "game of life" style element has changed and needs to be redrawn, but with the current implementation (which is in fact not correct), it may happen that the same element changes twice in the same game frame, causing the corresponding graphics not be updated again (and therefore showing the wrong state). Directly comparing the new with the old state fixes this problem. --- src/game.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/game.c b/src/game.c index 467b9e44..fdb77eb3 100644 --- a/src/game.c +++ b/src/game.c @@ -8916,6 +8916,7 @@ static void Life(int ax, int ay) for (y1 = -1; y1 < 2; y1++) for (x1 = -1; x1 < 2; x1++) { int xx = ax+x1, yy = ay+y1; + int old_element = Feld[xx][yy]; int nachbarn = 0; if (!IN_LEV_FIELD(xx, yy)) @@ -8941,7 +8942,7 @@ static void Life(int ax, int ay) nachbarn > life_parameter[1]) { Feld[xx][yy] = EL_EMPTY; - if (!Stop[xx][yy]) + if (Feld[xx][yy] != old_element) TEST_DrawLevelField(xx, yy); Stop[xx][yy] = TRUE; changed = TRUE; @@ -8954,7 +8955,7 @@ static void Life(int ax, int ay) { Feld[xx][yy] = element; MovDelay[xx][yy] = (element == EL_GAME_OF_LIFE ? 0 : life_time-1); - if (!Stop[xx][yy]) + if (Feld[xx][yy] != old_element) TEST_DrawLevelField(xx, yy); Stop[xx][yy] = TRUE; changed = TRUE; -- 2.34.1