From 2d427dc4077bac806defab00006761a111afd0bb Mon Sep 17 00:00:00 2001 From: Jamie Doornbos Date: Thu, 13 Nov 2008 23:26:04 +0000 Subject: [PATCH] Fixed edge case where the table and game go out of sync if the user manages to leave a table after the game starts... probably not too hard on a busy server or slow connection. This was the cause of 547 "WARN TableManager: No body to table mapping to clear?" lines in yesterday's log git-svn-id: svn+ssh://src.earth.threerings.net/vilya/trunk@780 c613c5cb-e716-0410-b11b-feb51c14d237 --- src/java/com/threerings/parlor/data/ParlorCodes.java | 4 ++++ src/java/com/threerings/parlor/server/TableManager.java | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/src/java/com/threerings/parlor/data/ParlorCodes.java b/src/java/com/threerings/parlor/data/ParlorCodes.java index 477abe2f..e687706b 100644 --- a/src/java/com/threerings/parlor/data/ParlorCodes.java +++ b/src/java/com/threerings/parlor/data/ParlorCodes.java @@ -70,4 +70,8 @@ public interface ParlorCodes extends InvocationCodes /** An error code returned by the table services for a request to join a table that the * requester been banned from. */ public static final String BANNED_FROM_TABLE = "m.banned_from_table"; + + /** An error code returned by the table services when a user requests to leave a table for + * which the game is already in progress. */ + public static final String GAME_ALREADY_STARTED = "m.game_already_started"; } diff --git a/src/java/com/threerings/parlor/server/TableManager.java b/src/java/com/threerings/parlor/server/TableManager.java index 03df94b9..f4aa2e39 100644 --- a/src/java/com/threerings/parlor/server/TableManager.java +++ b/src/java/com/threerings/parlor/server/TableManager.java @@ -245,6 +245,11 @@ public class TableManager throw new InvocationException(NO_SUCH_TABLE); } + // if the table is in play, the user is not allowed to leave (he must leave the game) + if (table.inPlay()) { + throw new InvocationException(GAME_ALREADY_STARTED); + } + // request that the user be removed from the table if (!table.clearPlayer(leaver.getVisibleName())) { throw new InvocationException(NOT_AT_TABLE);