From 100a7e069aa3c0effa8802a85c109e5cc7f703e1 Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Sat, 10 Nov 2007 01:20:42 +0000 Subject: [PATCH] Added validateCanEndGame() made it possible for server entities to call invocation service methods. git-svn-id: svn+ssh://src.earth.threerings.net/vilya/trunk@485 c613c5cb-e716-0410-b11b-feb51c14d237 --- .../ezgame/server/EZGameManager.java | 33 ++++++++++++------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/src/java/com/threerings/ezgame/server/EZGameManager.java b/src/java/com/threerings/ezgame/server/EZGameManager.java index f545651e..8f4f8ce7 100644 --- a/src/java/com/threerings/ezgame/server/EZGameManager.java +++ b/src/java/com/threerings/ezgame/server/EZGameManager.java @@ -85,6 +85,19 @@ public class EZGameManager extends GameManager _winnerOids = winnerOids; } + /** + * Confirms that the caller can end the game (or restart it). Requires that they are a player + * and that the game is not in play. + */ + public void validateCanEndGame (ClientObject caller) + throws InvocationException + { + if (!_ezObj.isInPlay()) { + throw new InvocationException("e.already_ended"); + } + validateStateModification(caller, false); + } + // from TurnGameManager public void turnWillStart () { @@ -150,11 +163,7 @@ public class EZGameManager extends GameManager InvocationService.InvocationListener listener) throws InvocationException { - if (!_ezObj.isInPlay()) { - throw new InvocationException("e.already_ended"); - } - validateStateModification(caller, false); - + validateCanEndGame(caller); setWinners(winnerOids); endGame(); } @@ -164,10 +173,7 @@ public class EZGameManager extends GameManager InvocationService.InvocationListener listener) throws InvocationException { - if (_ezObj.isInPlay()) { - throw new InvocationException("e.game_in_play"); - } - validateStateModification(caller, false); + validateCanEndGame(caller); // queue up the start of the next game if (seconds > 0) { @@ -465,18 +471,23 @@ public class EZGameManager extends GameManager protected void validateUser (ClientObject caller) throws InvocationException { - BodyObject body = (BodyObject)caller; + // the server is always cool + if (caller == null) { + return; + } switch (getMatchType()) { case GameConfig.PARTY: return; // always validate. - default: + default: { + BodyObject body = (BodyObject)caller; if (getPlayerIndex(body.getVisibleName()) == -1) { throw new InvocationException(InvocationCodes.ACCESS_DENIED); } return; } + } } /**