Merge branch 'fix/lobby-cleanup-blocked' into 'main'
Fix: Lobby cleanup got blocked by previous feature for rejoining lobby while game is still going See merge request cs108-fs26/Gruppe-13!184
This commit is contained in:
+5
@@ -98,9 +98,14 @@ public class GetGameStateHandler extends CommandHandler<GetGameStateRequest> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
// Remove all active players
|
||||||
for (String playerName : lobby.getPlayerNames()) {
|
for (String playerName : lobby.getPlayerNames()) {
|
||||||
lobbyManager.removePlayer(playerName);
|
lobbyManager.removePlayer(playerName);
|
||||||
}
|
}
|
||||||
|
// Also remove all absent players so the lobby can be deleted
|
||||||
|
for (String playerName : lobby.getAbsentPlayers()) {
|
||||||
|
lobbyManager.removePlayer(playerName);
|
||||||
|
}
|
||||||
lobby.initGame(null);
|
lobby.initGame(null);
|
||||||
} catch (RuntimeException e) {
|
} catch (RuntimeException e) {
|
||||||
LOGGER.log(
|
LOGGER.log(
|
||||||
|
|||||||
@@ -217,7 +217,7 @@ public class LobbyManager {
|
|||||||
for (Map.Entry<LobbyId, Lobby> e : activeLobbies.entrySet()) {
|
for (Map.Entry<LobbyId, Lobby> e : activeLobbies.entrySet()) {
|
||||||
LobbyId id = e.getKey();
|
LobbyId id = e.getKey();
|
||||||
Lobby l = e.getValue();
|
Lobby l = e.getValue();
|
||||||
if (l.getPlayerNames().isEmpty()) {
|
if (!l.hasAnyPlayers()) {
|
||||||
Instant created = creationTimes.get(id);
|
Instant created = creationTimes.get(id);
|
||||||
if (created != null && created.isBefore(cutoff)) {
|
if (created != null && created.isBefore(cutoff)) {
|
||||||
result.add(id);
|
result.add(id);
|
||||||
|
|||||||
Reference in New Issue
Block a user