Move PlayManager*.java from crowd.server to parlor.server.
git-svn-id: svn+ssh://src.earth.threerings.net/vilya/trunk@696 c613c5cb-e716-0410-b11b-feb51c14d237
This commit is contained in:
@@ -42,7 +42,6 @@ import com.threerings.crowd.chat.server.SpeakUtil;
|
||||
import com.threerings.crowd.data.BodyObject;
|
||||
import com.threerings.crowd.server.PlaceManager;
|
||||
import com.threerings.crowd.server.PlaceManagerDelegate;
|
||||
import com.threerings.crowd.server.PlayManager;
|
||||
|
||||
import com.threerings.parlor.data.ParlorCodes;
|
||||
import com.threerings.parlor.game.data.GameAI;
|
||||
@@ -50,6 +49,7 @@ import com.threerings.parlor.game.data.GameCodes;
|
||||
import com.threerings.parlor.game.data.GameConfig;
|
||||
import com.threerings.parlor.game.data.GameObject;
|
||||
import com.threerings.parlor.server.ParlorSender;
|
||||
import com.threerings.parlor.server.PlayManager;
|
||||
|
||||
import com.threerings.util.MessageBundle;
|
||||
|
||||
|
||||
@@ -21,11 +21,11 @@
|
||||
|
||||
package com.threerings.parlor.game.server;
|
||||
|
||||
import com.threerings.crowd.server.PlayManagerDelegate;
|
||||
|
||||
import com.threerings.util.Name;
|
||||
|
||||
import com.threerings.parlor.game.data.GameAI;
|
||||
import com.threerings.parlor.server.PlayManagerDelegate;
|
||||
|
||||
/**
|
||||
* Extends the {@link PlayManagerDelegate} mechanism with game manager specific methods.
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
//
|
||||
// $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.parlor.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);
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
//
|
||||
// $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.parlor.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;
|
||||
}
|
||||
Reference in New Issue
Block a user