Commit a402453d authored by Jonathan Michalon's avatar Jonathan Michalon

Few fixes taking into account b4n's review of last days' commits

parent 12390c2c
...@@ -220,9 +220,9 @@ public int main (string[] args) ...@@ -220,9 +220,9 @@ public int main (string[] args)
opt_context.add_main_entries (options, null); opt_context.add_main_entries (options, null);
opt_context.parse (ref args); opt_context.parse (ref args);
} catch (OptionError e) { } catch (OptionError e) {
print ("error: %s\n", e.message); printerr ("error: %s\n", e.message);
print ("Run '%s --help' to see a full list of available command line options.\n", args[0]); printerr ("Run '%s --help' to see a full list of available command line options.\n", args[0]);
return 0; return 1;
} }
var loop = new MainLoop (); var loop = new MainLoop ();
......
...@@ -165,6 +165,8 @@ namespace OVCC.Network ...@@ -165,6 +165,8 @@ namespace OVCC.Network
critical ("Got signal to start game but couldn't: %s", e.message); critical ("Got signal to start game but couldn't: %s", e.message);
} }
break; break;
case OVCC.GameState.NEW:
case OVCC.GameState.PLAYER_WAITING:
case OVCC.GameState.FINISHED: case OVCC.GameState.FINISHED:
break; /* should be automatic */ break; /* should be automatic */
case OVCC.GameState.ABORTED: case OVCC.GameState.ABORTED:
......
...@@ -466,7 +466,7 @@ namespace OVCC ...@@ -466,7 +466,7 @@ namespace OVCC
*/ */
public bool @foreach (BoardForeachFunc f) public bool @foreach (BoardForeachFunc f)
{ {
HashTableIter<Position?,Tile> iter = HashTableIter<Position?,Tile> (this._board); var iter = HashTableIter<Position?,Tile> (this._board);
Position? pos; Position? pos;
Tile tile; Tile tile;
bool went_through = true; bool went_through = true;
......
...@@ -57,15 +57,15 @@ namespace OVCC ...@@ -57,15 +57,15 @@ namespace OVCC
public bool is_open() public bool is_open()
{ {
return NEW in this || PLAYER_WAITING in this; return this in (NEW | PLAYER_WAITING);
} }
public bool is_done() public bool is_done()
{ {
return FINISHED in this || ABORTED in this; return this in (FINISHED | ABORTED);
} }
public bool can_start() public bool can_start()
{ {
return PLAYER_WAITING in this; return this in PLAYER_WAITING;
} }
} }
...@@ -101,6 +101,8 @@ namespace OVCC ...@@ -101,6 +101,8 @@ namespace OVCC
{ {
private SList<Player> _players = null; private SList<Player> _players = null;
// FIXME implement UUIDs for reference over network instead of mere list index
// public string uuid { get; construct; default = Uuid.string_random(); }
public GameState state { get; private set; default = GameState.NEW; } public GameState state { get; private set; default = GameState.NEW; }
public Stack stack { private get; construct; } public Stack stack { private get; construct; }
public Board board { get; construct; } public Board board { get; construct; }
......
...@@ -115,7 +115,7 @@ namespace OVCCClient ...@@ -115,7 +115,7 @@ namespace OVCCClient
if (game != null) { if (game != null) {
game.abort (); game.abort ();
} }
if (server.is_connected()) { if (server.is_connected ()) {
server.disconnect_from (); server.disconnect_from ();
} }
/* destroy server */ /* destroy server */
......
...@@ -37,7 +37,7 @@ public class Server: ThreadedSocketService ...@@ -37,7 +37,7 @@ public class Server: ThreadedSocketService
public string name { get; construct; } public string name { get; construct; }
public uint port { get; construct; default = 0xdead; } public uint port { get; construct; default = 0xdead; }
public uint max_games { get; set; default = 5; } public uint max_games { get; set; default = 1; }
public signal void stopped (); public signal void stopped ();
...@@ -62,7 +62,7 @@ public class Server: ThreadedSocketService ...@@ -62,7 +62,7 @@ public class Server: ThreadedSocketService
lock (games) { lock (games) {
foreach (var game in games) { foreach (var game in games) {
if (game.state.is_open() && if (game.state.is_open () &&
(candidate == null || candidate.players.length() < game.players.length())) { (candidate == null || candidate.players.length() < game.players.length())) {
candidate = game; candidate = game;
} }
...@@ -144,7 +144,7 @@ public class Server: ThreadedSocketService ...@@ -144,7 +144,7 @@ public class Server: ThreadedSocketService
game = games.nth_data (msg.game_index); game = games.nth_data (msg.game_index);
} }
if (game == null || !game.state.is_open()) { if (game == null || !game.state.is_open ()) {
debug ("Bad game %d, sending fail join message", msg.game_index); debug ("Bad game %d, sending fail join message", msg.game_index);
var join = new JoinMessage (msg.game_index); var join = new JoinMessage (msg.game_index);
join.status = JoinMessage.State.FAILED; join.status = JoinMessage.State.FAILED;
......
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