Removed special handling that is now confined to Yohoho and its particular
requirements. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3155 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -1,27 +1,8 @@
|
||||
//
|
||||
// $Id: PuzzleDispatcher.java,v 1.4 2004/08/27 02:20:32 mdb Exp $
|
||||
//
|
||||
// Narya library - tools for developing networked games
|
||||
// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved
|
||||
// http://www.threerings.net/code/narya/
|
||||
//
|
||||
// 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
|
||||
// $Id: PuzzleDispatcher.java,v 1.5 2004/10/21 02:54:44 mdb Exp $
|
||||
|
||||
package com.threerings.puzzle.server;
|
||||
|
||||
import com.threerings.crowd.data.PlaceConfig;
|
||||
import com.threerings.presents.client.Client;
|
||||
import com.threerings.presents.client.InvocationService.ConfirmListener;
|
||||
import com.threerings.presents.data.ClientObject;
|
||||
@@ -29,7 +10,6 @@ import com.threerings.presents.data.InvocationMarshaller;
|
||||
import com.threerings.presents.server.InvocationDispatcher;
|
||||
import com.threerings.presents.server.InvocationException;
|
||||
import com.threerings.puzzle.client.PuzzleService;
|
||||
import com.threerings.puzzle.client.PuzzleService.EnterPuzzleListener;
|
||||
import com.threerings.puzzle.data.PuzzleMarshaller;
|
||||
import com.threerings.puzzle.data.SolitairePuzzleConfig;
|
||||
|
||||
@@ -66,20 +46,6 @@ public class PuzzleDispatcher extends InvocationDispatcher
|
||||
);
|
||||
return;
|
||||
|
||||
case PuzzleMarshaller.ENTER_PUZZLE:
|
||||
((PuzzleProvider)provider).enterPuzzle(
|
||||
source,
|
||||
((Integer)args[0]).intValue(), (EnterPuzzleListener)args[1]
|
||||
);
|
||||
return;
|
||||
|
||||
case PuzzleMarshaller.LEAVE_PUZZLE:
|
||||
((PuzzleProvider)provider).leavePuzzle(
|
||||
source
|
||||
|
||||
);
|
||||
return;
|
||||
|
||||
default:
|
||||
super.dispatchRequest(source, methodId, args);
|
||||
}
|
||||
|
||||
@@ -1,23 +1,5 @@
|
||||
//
|
||||
// $Id: PuzzleGameDispatcher.java,v 1.2 2004/08/27 02:20:32 mdb Exp $
|
||||
//
|
||||
// Narya library - tools for developing networked games
|
||||
// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved
|
||||
// http://www.threerings.net/code/narya/
|
||||
//
|
||||
// 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
|
||||
// $Id: PuzzleGameDispatcher.java,v 1.3 2004/10/21 02:54:44 mdb Exp $
|
||||
|
||||
package com.threerings.puzzle.server;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: PuzzleManager.java,v 1.15 2004/09/01 21:03:11 ray Exp $
|
||||
// $Id: PuzzleManager.java,v 1.16 2004/10/21 02:54:44 mdb Exp $
|
||||
//
|
||||
// Narya library - tools for developing networked games
|
||||
// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved
|
||||
@@ -28,14 +28,12 @@ import com.samskivert.util.IntervalManager;
|
||||
import com.samskivert.util.StringUtil;
|
||||
|
||||
import com.threerings.presents.data.ClientObject;
|
||||
import com.threerings.presents.dobj.AttributeChangedEvent;
|
||||
import com.threerings.presents.dobj.DObject;
|
||||
import com.threerings.presents.dobj.OidList;
|
||||
import com.threerings.presents.server.util.SafeInterval;
|
||||
|
||||
import com.threerings.crowd.data.BodyObject;
|
||||
import com.threerings.crowd.server.CrowdServer;
|
||||
import com.threerings.crowd.server.PlaceManagerDelegate;
|
||||
|
||||
import com.threerings.parlor.game.GameManager;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: PuzzleProvider.java,v 1.6 2004/08/27 02:20:32 mdb Exp $
|
||||
// $Id: PuzzleProvider.java,v 1.7 2004/10/21 02:54:44 mdb Exp $
|
||||
//
|
||||
// Narya library - tools for developing networked games
|
||||
// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved
|
||||
@@ -32,16 +32,13 @@ import com.threerings.presents.server.InvocationProvider;
|
||||
import com.threerings.crowd.data.BodyObject;
|
||||
import com.threerings.crowd.data.PlaceConfig;
|
||||
import com.threerings.crowd.data.PlaceObject;
|
||||
import com.threerings.crowd.server.PlaceManager;
|
||||
import com.threerings.crowd.server.PlaceRegistry;
|
||||
|
||||
import com.threerings.parlor.game.GameManager;
|
||||
|
||||
import com.threerings.puzzle.Log;
|
||||
import com.threerings.puzzle.client.PuzzleService.EnterPuzzleListener;
|
||||
import com.threerings.puzzle.data.PuzzleCodes;
|
||||
import com.threerings.puzzle.data.PuzzleObject;
|
||||
import com.threerings.puzzle.data.PuzzlerObject;
|
||||
import com.threerings.puzzle.data.SolitairePuzzleConfig;
|
||||
|
||||
/**
|
||||
@@ -93,152 +90,6 @@ public class PuzzleProvider
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes a request from a client to enter a puzzle.
|
||||
*/
|
||||
public void enterPuzzle (
|
||||
ClientObject caller, int puzzleOid, EnterPuzzleListener listener)
|
||||
throws InvocationException
|
||||
{
|
||||
// do the entry and send the response
|
||||
listener.puzzleEntered(enterPuzzle((BodyObject)caller, puzzleOid));
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes a request from a client to leave their current puzzle.
|
||||
*/
|
||||
public void leavePuzzle (ClientObject caller)
|
||||
{
|
||||
BodyObject user = (BodyObject)caller;
|
||||
int puzzleOid = ((PuzzlerObject)user).getPuzzleLoc();
|
||||
|
||||
// make sure they're currently in a puzzle
|
||||
if (puzzleOid == -1) {
|
||||
Log.warning("Received leave puzzle request from user that " +
|
||||
"isn't in a puzzle [user=" + user.who() + "].");
|
||||
return;
|
||||
}
|
||||
|
||||
// make sure the puzzle in question actually exists
|
||||
PlaceManager pmgr = _plreg.getPlaceManager(puzzleOid);
|
||||
if (pmgr == null) {
|
||||
Log.info("Requested to leave a non-existent puzzle " +
|
||||
"[user=" + user.who() + "].");
|
||||
return;
|
||||
}
|
||||
|
||||
// depart their old puzzle
|
||||
departPuzzle(user);
|
||||
|
||||
// set their puzzle location to -1 to indicate that they're no
|
||||
// longer in a puzzle
|
||||
((PuzzlerObject)user).setPuzzleLoc(-1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Moves the specified body from whatever puzzle they currently occupy
|
||||
* to the puzzle identified by the supplied oid.
|
||||
*
|
||||
* @return the config object for the new location.
|
||||
*
|
||||
* @exception InvocationException thrown if the entry was not
|
||||
* successful for some reason (which will be communicated as an error
|
||||
* code in the exception's message data).
|
||||
*/
|
||||
public PlaceConfig enterPuzzle (BodyObject user, int puzzleOid)
|
||||
throws InvocationException
|
||||
{
|
||||
int bodoid = user.getOid();
|
||||
int puzzleLoc = ((PuzzlerObject)user).getPuzzleLoc();
|
||||
|
||||
// make sure the place in question actually exists
|
||||
PlaceManager pmgr = _plreg.getPlaceManager(puzzleOid);
|
||||
if (pmgr == null) {
|
||||
Log.info("Requested to move to non-existent place " +
|
||||
"[user=" + user.who() + ", puzzle=" + puzzleOid + "].");
|
||||
throw new InvocationException(NO_SUCH_PUZZLE);
|
||||
}
|
||||
|
||||
// acquire a lock on the body object to ensure that rapid fire
|
||||
// enterPuzzle requests don't break things
|
||||
if (!user.acquireLock("enterPuzzleLock")) {
|
||||
// if we're still locked, a previous enterPuzzle request
|
||||
// hasn't been fully processed
|
||||
throw new InvocationException(ENTER_IN_PROGRESS);
|
||||
}
|
||||
|
||||
// make sure they're not already in the puzzle they're entering
|
||||
if (puzzleLoc == puzzleOid) {
|
||||
throw new InvocationException(ALREADY_IN_PUZZLE);
|
||||
}
|
||||
|
||||
// depart any previously occupied puzzle
|
||||
departPuzzle(user);
|
||||
|
||||
// set the body's new puzzle location
|
||||
PlaceObject place = pmgr.getPlaceObject();
|
||||
((PuzzlerObject)user).setPuzzleLoc(place.getOid());
|
||||
|
||||
// prepare to update their new puzzle location
|
||||
place.startTransaction();
|
||||
try {
|
||||
// generate a new occupant info record (which will add it to
|
||||
// the target location)
|
||||
pmgr.buildOccupantInfo(user);
|
||||
|
||||
// add the body object id to the place object's occupant list
|
||||
place.addToOccupants(bodoid);
|
||||
} finally {
|
||||
place.commitTransaction();
|
||||
}
|
||||
|
||||
// and finally queue up a lock release event to release the lock
|
||||
// once all these events are processed
|
||||
user.releaseLock("enterPuzzleLock");
|
||||
|
||||
return pmgr.getConfig();
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the user's occupant information from the puzzle object that
|
||||
* they are now departing.
|
||||
*/
|
||||
protected void departPuzzle (BodyObject user)
|
||||
{
|
||||
int puzzleOid = ((PuzzlerObject)user).getPuzzleLoc();
|
||||
if (puzzleOid == -1) {
|
||||
return;
|
||||
}
|
||||
int bodoid = user.getOid();
|
||||
|
||||
// remove them from the occupant list of the previous puzzle
|
||||
try {
|
||||
PlaceObject pold = (PlaceObject)_omgr.getObject(puzzleOid);
|
||||
if (pold != null) {
|
||||
Integer key = new Integer(bodoid);
|
||||
// remove their occupant info (which is keyed on oid) and
|
||||
// remove them from the occupant list
|
||||
pold.startTransaction();
|
||||
try {
|
||||
pold.removeFromOccupantInfo(key);
|
||||
pold.removeFromOccupants(bodoid);
|
||||
} finally {
|
||||
pold.commitTransaction();
|
||||
}
|
||||
|
||||
} else {
|
||||
Log.info("Body's prior puzzle no longer around? " +
|
||||
"[boid=" + bodoid +
|
||||
", puzoid=" + puzzleOid + "].");
|
||||
}
|
||||
|
||||
} catch (ClassCastException cce) {
|
||||
Log.warning("Body claims to be in puzzle which references " +
|
||||
"non-PlaceObject!? [boid=" + bodoid +
|
||||
", puzoid=" + puzzleOid + "].");
|
||||
}
|
||||
}
|
||||
|
||||
/** The distributed object manager with which we interoperate. */
|
||||
protected RootDObjectManager _omgr;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user