[gnome-nibbles/arnaudb/kill-preferences-dialog: 16/27] Do not allow multiple worms to use same control.
- From: Arnaud B. <arnaudb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-nibbles/arnaudb/kill-preferences-dialog: 16/27] Do not allow multiple worms to use same control.
- Date: Tue, 23 Jun 2020 10:24:55 +0000 (UTC)
commit c79674b239564ada29f8b5e0d7b2fbed3beedeb0
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date: Fri Jun 12 09:22:50 2020 +0200
Do not allow multiple worms to use same control.
src/nibbles-window.vala | 19 ++++++++++++++++++-
1 file changed, 18 insertions(+), 1 deletion(-)
---
diff --git a/src/nibbles-window.vala b/src/nibbles-window.vala
index 7942f89..774db18 100644
--- a/src/nibbles-window.vala
+++ b/src/nibbles-window.vala
@@ -526,17 +526,34 @@ private class NibblesWindow : ApplicationWindow
private void update_start_game_action ()
{
+ GenericSet<uint> keys = new GenericSet<uint> (direct_hash, direct_equal);
for (int i = 0; i < game.numhumans; i++)
{
WormProperties worm_prop = game.worm_props.@get (game.worms.@get (i));
if (worm_prop.up == 0
|| worm_prop.down == 0
|| worm_prop.left == 0
- || worm_prop.right == 0)
+ || worm_prop.right == 0
+ // other keys of the same worm
+ || worm_prop.up == worm_prop.down
+ || worm_prop.up == worm_prop.left
+ || worm_prop.up == worm_prop.right
+ || worm_prop.down == worm_prop.left
+ || worm_prop.down == worm_prop.right
+ || worm_prop.right == worm_prop.left
+ // keys of already checked worms
+ || keys.contains (worm_prop.up)
+ || keys.contains (worm_prop.down)
+ || keys.contains (worm_prop.left)
+ || keys.contains (worm_prop.right))
{
start_game_action.set_enabled (false);
return;
}
+ keys.add (worm_prop.up);
+ keys.add (worm_prop.down);
+ keys.add (worm_prop.left);
+ keys.add (worm_prop.right);
}
start_game_action.set_enabled (true);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]