Commit 8ab1068d authored by Jonathan Michalon's avatar Jonathan Michalon
Browse files

Added PLAYER_REMOVED signal handling.

parent dff0f153
......@@ -65,6 +65,9 @@ namespace OVCC.Network
game_object.player_added.connect ((p) => {
send_to_peer (SignalType.PLAYER_ADDED, "s", p.nick);
});
game_object.player_removed.connect ((p) => {
send_to_peer (SignalType.PLAYER_REMOVED, "s", p.nick);
});
}
private bool send_to_peer (SignalType s, string format, ...)
......@@ -90,17 +93,28 @@ namespace OVCC.Network
public bool signal_received (SignalMessage msg)
{
debug ("Received signal %s", msg.stype.to_string());
ignore_next[msg.stype]++;
switch (msg.stype) {
case SignalType.PLAYER_ADDED:
ignore_next[SignalType.PLAYER_ADDED]++;
string nick;
msg.parse_data ("s", out nick);
debug ("Adding new player %s", nick);
game_object.add_player (new Player(nick));
break;
case SignalType.PLAYER_REMOVED:
string nick;
msg.parse_data ("s", out nick);
debug ("Removing player %s", nick);
foreach (var p in game_object.players) {
if (p.nick == nick) {
game_object.remove_player (p);
break;
}
}
break;
}
return true;
}
}
}
public class SignalMessage: Message
......
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