Commit 309cb65e authored by Arnaud Bonatti's avatar Arnaud Bonatti

Add a security.

Use an infinity sign when too
much moves have been done. It
should normally never happen.
parent a980a2ef
......@@ -158,7 +158,7 @@ private class GameHeaderBar : BaseHeaderBar
private uint last_moves_count = 0;
internal void set_moves_count (ref uint moves_count)
{
history_button.set_label (moves_count.to_string ());
history_button.set_label (get_moves_count_string (ref moves_count));
history_button.set_sensitive ((moves_count != 0) || (best_score != 0));
last_moves_count = moves_count;
}
......@@ -297,9 +297,19 @@ private class GameHeaderBar : BaseHeaderBar
GLib.Menu section = new GLib.Menu ();
/* Translators: during a game that has already been finished (and possibly restarted), entry in the menu of the moves button */
section.append (_("Best score: %u").printf (best_score), null);
section.append (_("Best score: %s").printf (get_moves_count_string (ref best_score)), null);
section.freeze ();
menu.append_section (null, section);
}
private static string get_moves_count_string (ref uint moves_count)
{
string moves_count_string;
if (moves_count != uint.MAX)
moves_count_string = moves_count.to_string ();
else
moves_count_string = "∞";
return moves_count_string;
}
}
......@@ -188,11 +188,17 @@ private class Game : Object
int8 move_number = move_x_axis ? x_gap - x : y_gap - y;
if (undoing)
moves_count--;
{
if (moves_count == 0)
assert_not_reached ();
if (moves_count != uint.MAX)
moves_count--;
}
else
{
add_move (/* move_x_axis, move_number,*/ x_gap, y_gap);
moves_count++;
if (moves_count != uint.MAX)
moves_count++;
}
if (move_x_axis)
......@@ -278,11 +284,17 @@ private class Game : Object
}
if (undoing)
moves_count--;
{
if (moves_count == 0)
assert_not_reached ();
if (moves_count != uint.MAX)
moves_count--;
}
else
{
add_move (move_x_axis ? (new_coord == 0 ? -1 : size) : x, move_x_axis ? y : (new_coord == 0 ? -1 : size));
moves_count++;
if (moves_count != uint.MAX)
moves_count++;
}
move (move_x_axis,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment