From 3b032cacacc6e767938e1d2814c8df9104f6d8e9 Mon Sep 17 00:00:00 2001 From: Par Winzell Date: Thu, 31 Jul 2008 17:28:09 +0000 Subject: [PATCH] Move PlayManager*.java from crowd.server to parlor.server. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@5280 542714f4-19e9-0310-aa3c-eee0fc999fb1 --- .../threerings/crowd/server/PlayManager.java | 51 --------- .../crowd/server/PlayManagerDelegate.java | 106 ------------------ 2 files changed, 157 deletions(-) delete mode 100644 src/java/com/threerings/crowd/server/PlayManager.java delete mode 100644 src/java/com/threerings/crowd/server/PlayManagerDelegate.java diff --git a/src/java/com/threerings/crowd/server/PlayManager.java b/src/java/com/threerings/crowd/server/PlayManager.java deleted file mode 100644 index 4716de55d..000000000 --- a/src/java/com/threerings/crowd/server/PlayManager.java +++ /dev/null @@ -1,51 +0,0 @@ -// -// $Id: GameManagerDelegate.java 487 2007-11-10 04:41:44Z mdb $ -// -// Vilya library - tools for developing networked games -// Copyright (C) 2002-2007 Three Rings Design, Inc., All Rights Reserved -// http://www.threerings.net/code/vilya/ -// -// This library is free software; you can redistribute it and/or modify it -// under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation; either version 2.1 of the License, or -// (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -package com.threerings.crowd.server; - -import com.threerings.crowd.data.BodyObject; - -import com.threerings.presents.data.ClientObject; - -/** - * An interface to be implemented by a {@code PlaceManager} that wishes to host - * places that have players. This generalizes the idea of a game further than what - * is afforded by {@code GameManager}, linking it up with {@code AVRGameManager}. - */ -public interface PlayManager -{ - /** - * Return true if the given client is a player in this place. - */ - boolean isPlayer (ClientObject client); - - /** - * Return true if the given client is a server-side agent in this place. - */ - boolean isAgent (ClientObject client); - - /** - * Make sure that the given caller is a player or an agent and can write to the data - * of the given playerId. - * @return the resolved player object to write to - **/ - BodyObject checkWritePermission (ClientObject client, int playerId); -} diff --git a/src/java/com/threerings/crowd/server/PlayManagerDelegate.java b/src/java/com/threerings/crowd/server/PlayManagerDelegate.java deleted file mode 100644 index 8fc8efc34..000000000 --- a/src/java/com/threerings/crowd/server/PlayManagerDelegate.java +++ /dev/null @@ -1,106 +0,0 @@ -// -// $Id: GameManagerDelegate.java 487 2007-11-10 04:41:44Z mdb $ -// -// Vilya library - tools for developing networked games -// Copyright (C) 2002-2007 Three Rings Design, Inc., All Rights Reserved -// http://www.threerings.net/code/vilya/ -// -// This library is free software; you can redistribute it and/or modify it -// under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation; either version 2.1 of the License, or -// (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -package com.threerings.crowd.server; - -import com.threerings.presents.data.ClientObject; -import com.threerings.presents.data.InvocationCodes; -import com.threerings.presents.server.InvocationException; - -import com.threerings.crowd.data.BodyObject; -import com.threerings.crowd.data.PlaceConfig; -import com.threerings.crowd.server.PlaceManagerDelegate; - -/** - * The base class for any delegate that wishes to service both {@code GameManager} - * games and {@code AVRGameManager} games -- or, in fact, any {@code PlaceManager} - * that implements {@code PlayManager}. - */ -public class PlayManagerDelegate extends PlaceManagerDelegate -{ - @Override - public void didInit (PlaceConfig config) - { - super.didInit(config); - _gmgr = (PlayManager)_plmgr; - } - - /** - * Returns true if the supplied occupant is a player, false if not. - */ - protected boolean isPlayer (ClientObject occupant) - { - return (occupant != null) && _gmgr.isPlayer(occupant); - } - - /** - * Returns true if the supplied occupant is an agent, false if not. - */ - protected boolean isAgent (ClientObject occupant) - { - return (occupant != null) && _gmgr.isAgent(occupant); - } - - /** - * Checks that the caller in question is a player if the game is not a party game. - * - * @return a casted {@link PlayerObject} reference if the method returns at all. - */ - protected void verifyIsPlayer (ClientObject caller) - throws InvocationException - { - if (!isPlayer(caller)) { - throw new InvocationException(InvocationCodes.E_ACCESS_DENIED); - } - } - - /** - * Checks that the caller in question is a player if the game is not a party game - * or an agent for games that use server-side code. - */ - protected void verifyIsPlayerOrAgent (ClientObject caller) - throws InvocationException - { - if (!isPlayer(caller) && !isAgent(caller)) { - throw new InvocationException(InvocationCodes.E_ACCESS_DENIED); - } - } - - /** - * Make sure that the given caller is a player or an agent and can write to the data - * of the given playerId. - * @return the resolved player object to write to - **/ - protected BodyObject verifyWritePermission (ClientObject caller, int playerId) - throws InvocationException - { - verifyIsPlayerOrAgent(caller); - - BodyObject player = _gmgr.checkWritePermission(caller, playerId); - if (player == null) { - throw new InvocationException(InvocationCodes.ACCESS_DENIED); - } - return player; - } - - /** A reference to our manager. */ - protected PlayManager _gmgr; -}