Updates to reflect new BodyObject.location change. We now have a ScenePlace and
ScenedBodyObject goes away. git-svn-id: svn+ssh://src.earth.threerings.net/vilya/trunk@372 c613c5cb-e716-0410-b11b-feb51c14d237
This commit is contained in:
@@ -105,9 +105,9 @@ public class ClientController extends Controller
|
||||
", err=" + nfe + "].");
|
||||
}
|
||||
|
||||
} else if (_body.location != -1) {
|
||||
} else if (_body.location != null) {
|
||||
// if we were already in a location, go there
|
||||
moveOid = _body.location;
|
||||
moveOid = _body.location.placeOid;
|
||||
|
||||
} else {
|
||||
// otherwise head to the default lobby to start things off
|
||||
|
||||
@@ -84,7 +84,7 @@ public abstract class GameController extends PlaceController
|
||||
// if this place object is not our current location we'll need to add it as an auxiliary
|
||||
// chat source
|
||||
BodyObject bobj = (BodyObject)_ctx.getClient().getClientObject();
|
||||
if (bobj.location != plobj.getOid()) {
|
||||
if (bobj.location == null || bobj.location.placeOid != plobj.getOid()) {
|
||||
_ctx.getChatDirector().addAuxiliarySource(_gobj, GameCodes.GAME_CHAT_TYPE);
|
||||
}
|
||||
|
||||
|
||||
@@ -708,7 +708,7 @@ public class GameManager extends PlaceManager
|
||||
return; // body object can be null for ai players
|
||||
}
|
||||
|
||||
DObject place = CrowdServer.omgr.getObject(user.location);
|
||||
DObject place = CrowdServer.omgr.getObject(user.getPlaceOid());
|
||||
if (place != null) {
|
||||
place.postMessage(PLAYER_KNOCKED_OUT, new Object[] { new int[] { user.getOid() } });
|
||||
}
|
||||
@@ -1180,7 +1180,7 @@ public class GameManager extends PlaceManager
|
||||
for (int ii=0; ii < numPlayers; ii++) {
|
||||
BodyObject user = getPlayer(ii);
|
||||
if (user != null) {
|
||||
places.add(user.location);
|
||||
places.add(user.getPlaceOid());
|
||||
(_gameobj.isWinner(ii) ? winners : losers).add(user.getOid());
|
||||
}
|
||||
}
|
||||
|
||||
+26
-9
@@ -21,19 +21,36 @@
|
||||
|
||||
package com.threerings.whirled.data;
|
||||
|
||||
import com.threerings.crowd.data.BodyObject;
|
||||
import com.threerings.crowd.data.Place;
|
||||
|
||||
/**
|
||||
* A system that uses the whirled services must provide a body object
|
||||
* extension that implements this interface.
|
||||
* Extends {@link Place} with scene information.
|
||||
*/
|
||||
public interface ScenedBodyObject
|
||||
public class ScenePlace extends Place
|
||||
{
|
||||
/**
|
||||
* Returns the scene id currently occupied by this body.
|
||||
*/
|
||||
public int getSceneId ();
|
||||
/** The id of the scene occupied by the body. */
|
||||
public int sceneId;
|
||||
|
||||
/**
|
||||
* Sets the scene id currently occupied by this body.
|
||||
* Returns the scene id occupied by the supplied body or -1 if the body is not in a scene.
|
||||
*/
|
||||
public void setSceneId (int sceneId);
|
||||
public static int getSceneId (BodyObject bobj)
|
||||
{
|
||||
return (bobj.location instanceof ScenePlace) ? ((ScenePlace)bobj.location).sceneId : -1;
|
||||
}
|
||||
|
||||
/** Used when unserializing. */
|
||||
public ScenePlace ()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a scene place with the supplied {@link SceneObject} oid and scene id.
|
||||
*/
|
||||
public ScenePlace (int sceneOid, int sceneId)
|
||||
{
|
||||
super(sceneOid);
|
||||
this.sceneId = sceneId;
|
||||
}
|
||||
}
|
||||
@@ -24,12 +24,14 @@ package com.threerings.whirled.server;
|
||||
import com.samskivert.io.PersistenceException;
|
||||
import com.samskivert.util.Invoker;
|
||||
|
||||
import com.threerings.crowd.data.Place;
|
||||
import com.threerings.crowd.server.CrowdServer;
|
||||
import com.threerings.crowd.server.PlaceManager;
|
||||
import com.threerings.presents.server.PresentsServer;
|
||||
|
||||
import com.threerings.whirled.Log;
|
||||
import com.threerings.whirled.data.Scene;
|
||||
import com.threerings.whirled.data.SceneCodes;
|
||||
import com.threerings.whirled.data.ScenePlace;
|
||||
import com.threerings.whirled.data.SceneUpdate;
|
||||
import com.threerings.whirled.server.WhirledServer;
|
||||
import com.threerings.whirled.util.UpdateList;
|
||||
@@ -58,6 +60,12 @@ public class SceneManager extends PlaceManager
|
||||
return _updates.getUpdates(fromVersion);
|
||||
}
|
||||
|
||||
@Override // from PlaceManager
|
||||
public Place getLocation ()
|
||||
{
|
||||
return new ScenePlace(_plobj.getOid(), _scene.getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Called by the scene registry once the scene manager has been created (and initialized), but
|
||||
* before it is started up.
|
||||
@@ -100,7 +108,7 @@ public class SceneManager extends PlaceManager
|
||||
|
||||
// Wait until us and all of our subclasses have completely finished running didStartup
|
||||
// prior to registering the scene as being ready.
|
||||
PresentsServer.omgr.postRunnable(new Runnable() {
|
||||
CrowdServer.omgr.postRunnable(new Runnable() {
|
||||
public void run () {
|
||||
_screg.sceneManagerDidStart(SceneManager.this);
|
||||
}
|
||||
|
||||
@@ -32,7 +32,6 @@ import com.threerings.whirled.client.SceneService;
|
||||
import com.threerings.whirled.data.SceneCodes;
|
||||
import com.threerings.whirled.data.SceneModel;
|
||||
import com.threerings.whirled.data.SceneUpdate;
|
||||
import com.threerings.whirled.data.ScenedBodyObject;
|
||||
|
||||
/**
|
||||
* Handles a simple scene to scene move.
|
||||
@@ -49,13 +48,10 @@ public class SceneMoveHandler extends AbstractSceneMoveHandler
|
||||
protected void effectSceneMove (SceneManager scmgr)
|
||||
throws InvocationException
|
||||
{
|
||||
// move to the place object associated with this scene
|
||||
// move to location associated with this scene
|
||||
int ploid = scmgr.getPlaceObject().getOid();
|
||||
PlaceConfig config = CrowdServer.plreg.locprov.moveTo(_body, ploid);
|
||||
|
||||
// now that we've finally moved, we can update the user object with the new scene id
|
||||
((ScenedBodyObject)_body).setSceneId(scmgr.getScene().getId());
|
||||
|
||||
// check to see if they need a newer version of the scene data
|
||||
SceneService.SceneMoveListener listener = (SceneService.SceneMoveListener)_listener;
|
||||
SceneModel model = scmgr.getScene().getSceneModel();
|
||||
|
||||
@@ -43,7 +43,6 @@ import com.threerings.whirled.data.Scene;
|
||||
import com.threerings.whirled.data.SceneCodes;
|
||||
import com.threerings.whirled.data.SceneModel;
|
||||
import com.threerings.whirled.data.SceneUpdate;
|
||||
import com.threerings.whirled.data.ScenedBodyObject;
|
||||
import com.threerings.whirled.server.persist.SceneRepository;
|
||||
import com.threerings.whirled.util.SceneFactory;
|
||||
import com.threerings.whirled.util.UpdateList;
|
||||
@@ -245,13 +244,10 @@ public class SceneRegistry
|
||||
* Ejects the specified body from their current scene and zone. This is the zone equivalent to
|
||||
* {@link LocationProvider#leaveOccupiedPlace}.
|
||||
*/
|
||||
public void leaveOccupiedScene (ScenedBodyObject source)
|
||||
public void leaveOccupiedScene (BodyObject source)
|
||||
{
|
||||
// remove them from their occupied place
|
||||
CrowdServer.plreg.locprov.leaveOccupiedPlace((BodyObject)source);
|
||||
|
||||
// and clear out their scene information
|
||||
source.setSceneId(0);
|
||||
// remove them from their occupied place (clears out scene info as well)
|
||||
CrowdServer.plreg.locprov.leaveOccupiedPlace(source);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -21,19 +21,12 @@
|
||||
|
||||
package com.threerings.whirled.server;
|
||||
|
||||
import com.threerings.crowd.data.BodyObject;
|
||||
import com.threerings.crowd.server.CrowdClient;
|
||||
|
||||
import com.threerings.whirled.data.ScenedBodyObject;
|
||||
|
||||
/**
|
||||
* The client object used by client management on the Whirled server.
|
||||
*/
|
||||
public class WhirledClient extends CrowdClient
|
||||
{
|
||||
// documentation inherited from interface
|
||||
protected void clearLocation (BodyObject bobj)
|
||||
{
|
||||
WhirledServer.screg.leaveOccupiedScene((ScenedBodyObject)bobj);
|
||||
}
|
||||
// nothing needed at the moment
|
||||
}
|
||||
|
||||
@@ -38,11 +38,12 @@ import com.threerings.crowd.chat.client.ChatDirector;
|
||||
import com.threerings.crowd.chat.data.ChatCodes;
|
||||
import com.threerings.crowd.client.LocationAdapter;
|
||||
import com.threerings.crowd.client.LocationDirector;
|
||||
import com.threerings.crowd.data.BodyObject;
|
||||
import com.threerings.crowd.data.PlaceObject;
|
||||
|
||||
import com.threerings.whirled.client.SceneDirector;
|
||||
import com.threerings.whirled.data.SceneModel;
|
||||
import com.threerings.whirled.data.ScenedBodyObject;
|
||||
import com.threerings.whirled.data.ScenePlace;
|
||||
import com.threerings.whirled.util.WhirledContext;
|
||||
|
||||
import com.threerings.whirled.spot.Log;
|
||||
@@ -130,10 +131,10 @@ public class SpotSceneDirector extends BasicDirector
|
||||
|
||||
// sanity check the server's notion of what scene we're in with our notion of it
|
||||
int sceneId = _scdir.getScene().getId();
|
||||
ScenedBodyObject sbobj = (ScenedBodyObject)_ctx.getClient().getClientObject();
|
||||
if (sceneId != sbobj.getSceneId()) {
|
||||
int clSceneId = ScenePlace.getSceneId((BodyObject)_ctx.getClient().getClientObject());
|
||||
if (sceneId != clSceneId) {
|
||||
Log.warning("Client and server differ in opinion of what scene we're in " +
|
||||
"[sSceneId=" + sbobj.getSceneId() + ", cSceneId=" + sceneId + "].");
|
||||
"[sSceneId=" + clSceneId + ", cSceneId=" + sceneId + "].");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -21,13 +21,13 @@
|
||||
|
||||
package com.threerings.whirled.spot.data;
|
||||
|
||||
import com.threerings.whirled.data.ScenedBodyObject;
|
||||
import com.threerings.crowd.data.BodyObject;
|
||||
|
||||
/**
|
||||
* Defines some required methods for a {@link ScenedBodyObject} that is to
|
||||
* participate in the Whirled Spot system.
|
||||
* Defines some required methods for a {@link BodyObject} that is to participate in the Whirled
|
||||
* Spot system.
|
||||
*/
|
||||
public interface ClusteredBodyObject extends ScenedBodyObject
|
||||
public interface ClusteredBodyObject
|
||||
{
|
||||
/**
|
||||
* Returns the field name of the cluster oid distributed object field.
|
||||
@@ -35,8 +35,7 @@ public interface ClusteredBodyObject extends ScenedBodyObject
|
||||
public String getClusterField ();
|
||||
|
||||
/**
|
||||
* Returns the oid of the cluster to which this user currently
|
||||
* belongs.
|
||||
* Returns the oid of the cluster to which this user currently belongs.
|
||||
*/
|
||||
public int getClusterOid ();
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ import com.threerings.crowd.data.BodyObject;
|
||||
import com.threerings.crowd.server.PlaceRegistry;
|
||||
|
||||
import com.threerings.whirled.client.SceneService.SceneMoveListener;
|
||||
import com.threerings.whirled.data.ScenedBodyObject;
|
||||
import com.threerings.whirled.data.ScenePlace;
|
||||
import com.threerings.whirled.server.SceneManager;
|
||||
import com.threerings.whirled.server.SceneRegistry;
|
||||
|
||||
@@ -74,7 +74,8 @@ public class SpotProvider
|
||||
throws InvocationException
|
||||
{
|
||||
// le sanity check
|
||||
int cSceneId = getCallerSceneId(caller);
|
||||
BodyObject body = (BodyObject)caller;
|
||||
int cSceneId = ScenePlace.getSceneId(body);
|
||||
if (cSceneId != sceneId) {
|
||||
Log.info("Ignoring stale traverse portal request [caller=" + caller.who() +
|
||||
", oSceneId=" + sceneId + ", portalId=" + portalId +
|
||||
@@ -84,7 +85,6 @@ public class SpotProvider
|
||||
}
|
||||
|
||||
// obtain the source scene
|
||||
BodyObject body = (BodyObject)caller;
|
||||
SpotSceneManager srcmgr = (SpotSceneManager)_screg.getSceneManager(sceneId);
|
||||
if (srcmgr == null) {
|
||||
Log.warning("Traverse portal missing source scene " +
|
||||
@@ -124,7 +124,7 @@ public class SpotProvider
|
||||
throws InvocationException
|
||||
{
|
||||
BodyObject source = (BodyObject)caller;
|
||||
int cSceneId = getCallerSceneId(caller);
|
||||
int cSceneId = ScenePlace.getSceneId(source);
|
||||
if (cSceneId != sceneId) {
|
||||
Log.info("Rejecting changeLocation for invalid scene [user=" + source.who() +
|
||||
", insid=" + cSceneId + ", wantsid=" + sceneId + ", loc=" + loc + "].");
|
||||
@@ -153,8 +153,8 @@ public class SpotProvider
|
||||
SpotService.ConfirmListener listener)
|
||||
throws InvocationException
|
||||
{
|
||||
int sceneId = getCallerSceneId(caller);
|
||||
BodyObject source = (BodyObject)caller;
|
||||
int sceneId = ScenePlace.getSceneId(source);
|
||||
|
||||
// look up the scene manager for the specified scene
|
||||
SpotSceneManager smgr = (SpotSceneManager)_screg.getSceneManager(sceneId);
|
||||
@@ -184,7 +184,7 @@ public class SpotProvider
|
||||
if (errmsg != null) {
|
||||
SpeakProvider.sendFeedback(source, MessageManager.GLOBAL_BUNDLE, errmsg);
|
||||
} else {
|
||||
sendClusterChatMessage(getCallerSceneId(caller), source.getOid(),
|
||||
sendClusterChatMessage(ScenePlace.getSceneId(source), source.getOid(),
|
||||
source.getVisibleName(), null, message, mode);
|
||||
}
|
||||
}
|
||||
@@ -221,23 +221,6 @@ public class SpotProvider
|
||||
smgr.handleClusterSpeakRequest(speakerOid, speaker, bundle, message, mode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtains the scene id occupied by the supplied caller.
|
||||
*
|
||||
* @exception InvocationException thrown if the caller does not implement {@link
|
||||
* ScenedBodyObject}.
|
||||
*/
|
||||
protected static int getCallerSceneId (ClientObject caller)
|
||||
throws InvocationException
|
||||
{
|
||||
if (caller instanceof ScenedBodyObject) {
|
||||
return ((ScenedBodyObject)caller).getSceneId();
|
||||
} else {
|
||||
Log.warning("Can't get scene from non-scened caller " + caller.who() + ".");
|
||||
throw new InvocationException(INTERNAL_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
/** The place registry with which we interoperate. */
|
||||
protected PlaceRegistry _plreg;
|
||||
|
||||
|
||||
@@ -61,23 +61,25 @@ public class SpotSceneManager extends SceneManager
|
||||
*/
|
||||
public static void moveBodyToDefaultPortal (BodyObject body)
|
||||
{
|
||||
SpotSceneManager mgr = (SpotSceneManager)CrowdServer.plreg.getPlaceManager(body.location);
|
||||
if (mgr != null) {
|
||||
SpotScene scene = (SpotScene)mgr.getScene();
|
||||
if (scene == null) {
|
||||
Log.warning("No scene in moveBodyToDefaultPortal()? " +
|
||||
"[who=" + body.who() +
|
||||
", where=" + mgr.where() + "].");
|
||||
return;
|
||||
}
|
||||
try {
|
||||
Location eloc = scene.getDefaultEntrance().getLocation();
|
||||
mgr.handleChangeLoc(body, eloc);
|
||||
} catch (InvocationException ie) {
|
||||
Log.warning("Could not move user to default portal " +
|
||||
"[where=" + mgr.where() + ", who=" + body.who() +
|
||||
", error=" + ie + "].");
|
||||
}
|
||||
SpotSceneManager mgr = (SpotSceneManager)
|
||||
CrowdServer.plreg.getPlaceManager(body.getPlaceOid());
|
||||
if (mgr == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
SpotScene scene = (SpotScene)mgr.getScene();
|
||||
if (scene == null) {
|
||||
Log.warning("No scene in moveBodyToDefaultPortal()? [who=" + body.who() +
|
||||
", where=" + mgr.where() + "].");
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
Location eloc = scene.getDefaultEntrance().getLocation();
|
||||
mgr.handleChangeLoc(body, eloc);
|
||||
} catch (InvocationException ie) {
|
||||
Log.warning("Could not move user to default portal [where=" + mgr.where() +
|
||||
", who=" + body.who() + ", error=" + ie + "].");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,13 +21,13 @@
|
||||
|
||||
package com.threerings.whirled.zone.data;
|
||||
|
||||
import com.threerings.whirled.data.ScenedBodyObject;
|
||||
import com.threerings.crowd.data.BodyObject;
|
||||
|
||||
/**
|
||||
* A system that uses the zone services must provide a body object
|
||||
* extension that implements this interface.
|
||||
* A system that uses the zone services must extend {@link BodyObject} and implement this
|
||||
* interface.
|
||||
*/
|
||||
public interface ZonedBodyObject extends ScenedBodyObject
|
||||
public interface ZonedBodyObject
|
||||
{
|
||||
/**
|
||||
* Returns the zone id currently occupied by this body.
|
||||
|
||||
@@ -29,7 +29,6 @@ import com.threerings.crowd.data.PlaceConfig;
|
||||
import com.threerings.whirled.client.SceneService;
|
||||
import com.threerings.whirled.data.SceneModel;
|
||||
import com.threerings.whirled.data.SceneUpdate;
|
||||
import com.threerings.whirled.data.ScenedBodyObject;
|
||||
import com.threerings.whirled.server.AbstractSceneMoveHandler;
|
||||
import com.threerings.whirled.server.SceneManager;
|
||||
import com.threerings.whirled.server.SceneMoveHandler;
|
||||
@@ -90,7 +89,6 @@ public class ZoneMoveHandler extends AbstractSceneMoveHandler
|
||||
// now that we've moved, we can update the user object with the new scene and zone ids
|
||||
_body.startTransaction();
|
||||
try {
|
||||
((ScenedBodyObject)_body).setSceneId(scmgr.getScene().getId());
|
||||
((ZonedBodyObject)_body).setZoneId(_summary.zoneId);
|
||||
} finally {
|
||||
_body.commitTransaction();
|
||||
|
||||
@@ -33,7 +33,6 @@ import com.threerings.crowd.server.LocationProvider;
|
||||
|
||||
import com.threerings.whirled.data.SceneModel;
|
||||
import com.threerings.whirled.data.SceneUpdate;
|
||||
import com.threerings.whirled.data.ScenedBodyObject;
|
||||
import com.threerings.whirled.server.SceneManager;
|
||||
import com.threerings.whirled.server.SceneRegistry;
|
||||
|
||||
@@ -150,7 +149,7 @@ public class ZoneProvider
|
||||
}
|
||||
|
||||
// remove them from their occupied scene
|
||||
_screg.leaveOccupiedScene(source);
|
||||
_screg.leaveOccupiedScene((BodyObject)source);
|
||||
|
||||
// and clear out their zone information
|
||||
source.setZoneId(-1);
|
||||
|
||||
Reference in New Issue
Block a user