Commit fedb066d authored by Jonathan Michalon's avatar Jonathan Michalon
Browse files

Fix ovccclient's warnings and corresponding bot warnings

parent b56aff20
......@@ -51,11 +51,19 @@ public class Bot : OVCCClient.Client
debug ("Game started!");
break;
case OVCC.GameState.FINISHED:
leave ();
try {
leave ();
} catch (Error e) {
warning ("Could not leave: %s", e.message);
}
debug ("We're done, bye!");
break;
case OVCC.GameState.ABORTED:
leave ();
try {
leave ();
} catch (Error e) {
warning ("Could not leave: %s", e.message);
}
debug ("Abnormal game termination!");
break;
}
......@@ -116,6 +124,7 @@ public class Bot : OVCCClient.Client
}
public new void leave ()
throws OVCCClient.ServerError
{
sigqueue.remove_all ();
......
......@@ -62,6 +62,7 @@ namespace OVCCClient
}
public bool leave ()
throws ServerError
{
sigqueue.remove_all ();
......
......@@ -34,6 +34,7 @@ namespace OVCCClient
NICKNAME_IN_USE,
MISSING_AUTHENTICATION,
NO_OPEN_TABLE,
DATA_UNREACHABLE,
FAILED
}
......@@ -239,8 +240,7 @@ namespace OVCCClient
new DisconnectMessage ().send (output);
connection.socket.close();
} catch (Error e) {
/* FIXME ? */
warning ("disconnection failed: %s", e.message);
throw new ServerError.COMMUNICATION_FAILED ("disconnection failed: %s", e.message);
}
connection = null;
input = null;
......@@ -299,15 +299,29 @@ namespace OVCCClient
}
/* create our game */
tiles.load (File.new_for_path (data.tiles_filename));
tileset.load (tiles, File.new_for_path (data.tileset_filename));
try {
tiles.load (File.new_for_path (data.tiles_filename));
} catch (Error e1) {
throw new ServerError.DATA_UNREACHABLE ("Could not load tiles data from '%s': %s",
data.tiles_filename, e1.message);
}
try {
tileset.load (tiles, File.new_for_path (data.tileset_filename));
} catch (Error e2) {
throw new ServerError.DATA_UNREACHABLE ("Could not load tileset data from '%s': %s",
data.tileset_filename, e2.message);
}
var stack = new Stack.from_tile_ids (data.stack_ids, tiles);
Game game = new Game (tileset, stack);
foreach (var nick in data.player_nicks) {
game.add_player (new Player (nick));
try {
game.add_player (new Player (nick));
} catch (GameError e3) {
throw new ServerError.COMMUNICATION_FAILED ("Could not add a player (%s) as requested, you may be out of sync", e3.message);
}
}
/* start listening to game signals */
......@@ -324,7 +338,11 @@ namespace OVCCClient
signal_handle = null;
}));
game.add_player (player);
try {
game.add_player (player);
} catch (GameError e4) {
throw new ServerError.INVALID_NICKNAME (e4.message);
}
return game;
}
......
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