From: Holger Schemel Date: Wed, 10 Oct 2018 17:51:04 +0000 (+0200) Subject: fixed bug with redrawing state changes for "game of life" style elements X-Git-Tag: 4.1.2.0~147 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=172a34e8d64ad71e6eee7871803e9faee7669ca3;p=rocksndiamonds.git 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. --- 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;