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
This commit is contained in:
Michael Bayne
2007-11-10 01:20:42 +00:00
parent 8059d9bc12
commit 100a7e069a
@@ -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;
}
}
}
/**