[gnome-2048] Fix setting of grid size
- From: Juan R. Garcia Blanco <juanrgar src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-2048] Fix setting of grid size
- Date: Thu, 12 Feb 2015 21:45:00 +0000 (UTC)
commit c77e7edc681f735e17c0531af3efcb8fc7da1171
Author: Juan R. GarcĂa Blanco <juanrgar gmail com>
Date: Thu Feb 12 22:42:55 2015 +0100
Fix setting of grid size
Changing the grid size crashed the game. Now the background structure is
only initialized when appropriate, i.e. when it has been cleared and
when grid has the new settings applied.
src/game.vala | 10 ++++++++--
1 files changed, 8 insertions(+), 2 deletions(-)
---
diff --git a/src/game.vala b/src/game.vala
index eedaf6f..6c6f5e0 100644
--- a/src/game.vala
+++ b/src/game.vala
@@ -128,6 +128,8 @@ public class Game : GLib.Object
lines = contents.split ("\n");
score = (uint)int.parse (lines[lines.length-2]);
+ if (_background != null)
+ _clear_background ();
_init_background ();
_restore_foreground ();
@@ -163,12 +165,13 @@ public class Game : GLib.Object
if ((rows != _grid.rows) || (cols != _grid.cols)) {
_clear_foreground ();
- _clear_background ();
- _init_background ();
+ _clear_background ();
_grid = new Grid (rows, cols);
+ _init_background ();
+
return true;
}
@@ -223,6 +226,8 @@ public class Game : GLib.Object
rect.actor.show ();
_background[i,j] = rect;
+ _foreground_cur[i,j] = null;
+ _foreground_nxt[i,j] = null;
}
}
}
@@ -507,6 +512,7 @@ public class Game : GLib.Object
tile.actor.hide ();
_view.remove_child (tile.actor);
_foreground_cur[i,j] = null;
+ _foreground_nxt[i,j] = null;
}
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]