* Fixed a bug that players that left a match before the match was started were not removed correctly from the match.

This commit is contained in:
LevelX2 2013-09-12 21:03:07 +02:00
parent a21f7f315d
commit 7b349c856f
2 changed files with 6 additions and 7 deletions

View file

@ -186,13 +186,9 @@ public class Table implements Serializable {
for (int i = 0; i < numSeats; i++ ) { for (int i = 0; i < numSeats; i++ ) {
Player player = seats[i].getPlayer(); Player player = seats[i].getPlayer();
if (player != null && player.getId().equals(playerId)) { if (player != null && player.getId().equals(playerId)) {
if (match != null) { seats[i].setPlayer(null);
match.leave(playerId); if (state == TableState.STARTING) {
} else { state = TableState.WAITING;
seats[i].setPlayer(null);
if (state == TableState.STARTING) {
state = TableState.WAITING;
}
} }
break; break;
} }

View file

@ -90,6 +90,9 @@ public abstract class MatchImpl implements Match {
public boolean leave(UUID playerId) { public boolean leave(UUID playerId) {
MatchPlayer mPlayer = getPlayer(playerId); MatchPlayer mPlayer = getPlayer(playerId);
if (mPlayer != null) { if (mPlayer != null) {
if (games.isEmpty() ) {
return players.remove(mPlayer);
}
mPlayer.setQuit(true); mPlayer.setQuit(true);
synchronized (this) { synchronized (this) {
this.notifyAll(); this.notifyAll();