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
This commit is contained in:
Jamie Doornbos
2008-11-13 23:26:04 +00:00
parent e480fed7ce
commit 2d427dc407
2 changed files with 9 additions and 0 deletions
@@ -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 /** An error code returned by the table services for a request to join a table that the
* requester been banned from. */ * requester been banned from. */
public static final String BANNED_FROM_TABLE = "m.banned_from_table"; 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";
} }
@@ -245,6 +245,11 @@ public class TableManager
throw new InvocationException(NO_SUCH_TABLE); 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 // request that the user be removed from the table
if (!table.clearPlayer(leaver.getVisibleName())) { if (!table.clearPlayer(leaver.getVisibleName())) {
throw new InvocationException(NOT_AT_TABLE); throw new InvocationException(NOT_AT_TABLE);