mirror of
https://github.com/correl/mage.git
synced 2024-11-16 03:00:12 +00:00
* 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:
parent
a21f7f315d
commit
7b349c856f
2 changed files with 6 additions and 7 deletions
|
@ -186,14 +186,10 @@ 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) {
|
|
||||||
match.leave(playerId);
|
|
||||||
} else {
|
|
||||||
seats[i].setPlayer(null);
|
seats[i].setPlayer(null);
|
||||||
if (state == TableState.STARTING) {
|
if (state == TableState.STARTING) {
|
||||||
state = TableState.WAITING;
|
state = TableState.WAITING;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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();
|
||||||
|
|
Loading…
Reference in a new issue