try to prevent an NPE if the "correct" person leaves a game, especially if it was due to ping timeout
This commit is contained in:
parent
f6d1c685b8
commit
14dbf94b27
|
@ -345,6 +345,10 @@ public class Game {
|
||||||
*/
|
*/
|
||||||
private Map<GamePlayerInfo, Object> getPlayerInfo(final Player player) {
|
private Map<GamePlayerInfo, Object> getPlayerInfo(final Player player) {
|
||||||
final Map<GamePlayerInfo, Object> playerInfo = new HashMap<GamePlayerInfo, Object>();
|
final Map<GamePlayerInfo, Object> playerInfo = new HashMap<GamePlayerInfo, Object>();
|
||||||
|
// TODO make sure this can't happen in the first place
|
||||||
|
if (player == null) {
|
||||||
|
return playerInfo;
|
||||||
|
}
|
||||||
playerInfo.put(GamePlayerInfo.NAME, player.getUser().getNickname());
|
playerInfo.put(GamePlayerInfo.NAME, player.getUser().getNickname());
|
||||||
playerInfo.put(GamePlayerInfo.SCORE, player.getScore());
|
playerInfo.put(GamePlayerInfo.SCORE, player.getScore());
|
||||||
playerInfo.put(GamePlayerInfo.STATUS, getPlayerStatus(player).toString());
|
playerInfo.put(GamePlayerInfo.STATUS, getPlayerStatus(player).toString());
|
||||||
|
@ -570,15 +574,19 @@ public class Game {
|
||||||
data.put(LongPollResponse.GAME_STATE, GameState.LOBBY.toString());
|
data.put(LongPollResponse.GAME_STATE, GameState.LOBBY.toString());
|
||||||
broadcastToPlayers(MessageType.GAME_EVENT, data);
|
broadcastToPlayers(MessageType.GAME_EVENT, data);
|
||||||
|
|
||||||
data = getEventMap();
|
if (host != null) {
|
||||||
data.put(LongPollResponse.EVENT, LongPollEvent.GAME_PLAYER_INFO_CHANGE.toString());
|
data = getEventMap();
|
||||||
data.put(LongPollResponse.PLAYER_INFO, getPlayerInfo(host));
|
data.put(LongPollResponse.EVENT, LongPollEvent.GAME_PLAYER_INFO_CHANGE.toString());
|
||||||
broadcastToPlayers(MessageType.GAME_PLAYER_EVENT, data);
|
data.put(LongPollResponse.PLAYER_INFO, getPlayerInfo(host));
|
||||||
|
broadcastToPlayers(MessageType.GAME_PLAYER_EVENT, data);
|
||||||
|
}
|
||||||
|
|
||||||
data = getEventMap();
|
if (judge != null) {
|
||||||
data.put(LongPollResponse.EVENT, LongPollEvent.GAME_PLAYER_INFO_CHANGE.toString());
|
data = getEventMap();
|
||||||
data.put(LongPollResponse.PLAYER_INFO, getPlayerInfo(judge));
|
data.put(LongPollResponse.EVENT, LongPollEvent.GAME_PLAYER_INFO_CHANGE.toString());
|
||||||
broadcastToPlayers(MessageType.GAME_PLAYER_EVENT, data);
|
data.put(LongPollResponse.PLAYER_INFO, getPlayerInfo(judge));
|
||||||
|
broadcastToPlayers(MessageType.GAME_PLAYER_EVENT, data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue