Fixed up logging; added code to mark a location as reserved when we return

it from a call to getUnoccupiedLocation(). Anyone can move into the
location (regardless of who reserved it), but it won't be reported as
unoccupied until someone enters it and leaves from it once again.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@1520 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2002-06-20 22:38:58 +00:00
parent 01d2318133
commit b32ca52809
3 changed files with 38 additions and 27 deletions
@@ -1,5 +1,5 @@
// //
// $Id: LocationProvider.java,v 1.14 2002/05/26 02:24:46 mdb Exp $ // $Id: LocationProvider.java,v 1.15 2002/06/20 22:38:58 mdb Exp $
package com.threerings.crowd.server; package com.threerings.crowd.server;
@@ -86,7 +86,7 @@ public class LocationProvider extends InvocationProvider
// anything in distributed object world // anything in distributed object world
if (source.location == placeId) { if (source.location == placeId) {
Log.info("Going along with client request to move to where " + Log.info("Going along with client request to move to where " +
"they already are [source=" + source.username + "they already are [source=" + source.who() +
", placeId=" + placeId + "]."); ", placeId=" + placeId + "].");
return pmgr.getConfig(); return pmgr.getConfig();
} }
@@ -1,5 +1,5 @@
// //
// $Id: SpotProvider.java,v 1.9 2002/06/19 20:27:07 ray Exp $ // $Id: SpotProvider.java,v 1.10 2002/06/20 22:38:58 mdb Exp $
package com.threerings.whirled.spot.server; package com.threerings.whirled.spot.server;
@@ -63,8 +63,7 @@ public class SpotProvider extends InvocationProvider
_screg.getSceneManager(sceneId); _screg.getSceneManager(sceneId);
if (smgr == null) { if (smgr == null) {
Log.warning("Traverse portal missing source scene " + Log.warning("Traverse portal missing source scene " +
"[user=" + source.username + "[user=" + source.who() + ", sceneId=" + sceneId +
", sceneId=" + sceneId +
", portalId=" + portalId + "]."); ", portalId=" + portalId + "].");
throw new ServiceFailedException(INTERNAL_ERROR); throw new ServiceFailedException(INTERNAL_ERROR);
} }
@@ -77,8 +76,7 @@ public class SpotProvider extends InvocationProvider
// make sure this portal has valid info // make sure this portal has valid info
if (destSceneId == -1) { if (destSceneId == -1) {
Log.warning("Traverse portal provided with invalid portal " + Log.warning("Traverse portal provided with invalid portal " +
"[user=" + source.username + "[user=" + source.who() + ", sceneId=" + sceneId +
", sceneId=" + sceneId +
", portalId=" + portalId + ", portalId=" + portalId +
", destSceneId=" + destSceneId + "]."); ", destSceneId=" + destSceneId + "].");
throw new ServiceFailedException(NO_SUCH_PORTAL); throw new ServiceFailedException(NO_SUCH_PORTAL);
@@ -176,7 +174,7 @@ public class SpotProvider extends InvocationProvider
_screg.getSceneManager(sceneId); _screg.getSceneManager(sceneId);
if (smgr == null) { if (smgr == null) {
Log.warning("User requested to change location in " + Log.warning("User requested to change location in " +
"non-existent scene [user=" + source.username + "non-existent scene [user=" + source.who() +
", sceneId=" + sceneId + ", sceneId=" + sceneId +
", locId=" + locationId + "]."); ", locId=" + locationId + "].");
throw new ServiceFailedException(INTERNAL_ERROR); throw new ServiceFailedException(INTERNAL_ERROR);
@@ -1,5 +1,5 @@
// //
// $Id: SpotSceneManager.java,v 1.11 2002/06/20 22:16:09 mdb Exp $ // $Id: SpotSceneManager.java,v 1.12 2002/06/20 22:38:58 mdb Exp $
package com.threerings.whirled.spot.server; package com.threerings.whirled.spot.server;
@@ -54,12 +54,22 @@ public class SpotSceneManager extends SceneManager
/** /**
* Returns the locationId of an unoccupied location in this scene * Returns the locationId of an unoccupied location in this scene
* (portals are not included when selecting). If no locations are * (portals are not included when selecting). If no locations are
* unoccupied, this method returns -1. * unoccupied, this method returns -1. This will mark the location as
* pending so that subsequent calls to
* <code>getUnoccupiedLocation()</code> do not return the previously
* returned location as unoccupied, giving the caller a chance to
* actually occupy the location. However, if another user moves to
* that location bewteen the call to this method and the caller's own
* request to move to the location, the caller's move request will
* fail.
*/ */
public int getUnoccupiedLocation (boolean preferClusters) public int getUnoccupiedLocation (boolean preferClusters)
{ {
return SpotSceneUtil.getUnoccupiedLocation( int locId = SpotSceneUtil.getUnoccupiedLocation(
_sscene.getModel(), _locationOccs, preferClusters); _sscene.getModel(), _locationOccs, preferClusters);
// mark the location as pending
_locationOccs[_sscene.getLocationIndex(locId)] = -1;
return locId;
} }
// documentation inherited // documentation inherited
@@ -145,15 +155,17 @@ public class SpotSceneManager extends SceneManager
{ {
// make sure no one is already in the requested location // make sure no one is already in the requested location
int locidx = _sscene.getLocationIndex(locationId); int locidx = _sscene.getLocationIndex(locationId);
if (locidx == -1 || _locationOccs[locidx] != 0) { if (locidx == -1) {
Log.info("Ignoring request to change to occupied or " + Log.warning("Ignoring request to move to non-existent location " +
"non-existent location [where=" + where() + "[where=" + where() + ", user=" + source.who() +
", user=" + source.username + ", locId=" + locationId + "].");
", locId=" + locationId + ", locidx=" + locidx + throw new ServiceFailedException(LOCATION_OCCUPIED);
", lococcs=" + StringUtil.toString(_locationOccs) +
", occinfo=" + StringUtil.listToString( } else if (_locationOccs[locidx] > 0) {
_plobj.occupantInfo.entries(), Log.info("Ignoring request to move to occupied location " +
SpotOccupantInfo.OIDS_AND_LOCS) + "]."); "[where=" + where() + ", user=" + source.who() +
", locId=" + locationId +
", occupantOid=" + _locationOccs[locidx] + "].");
throw new ServiceFailedException(LOCATION_OCCUPIED); throw new ServiceFailedException(LOCATION_OCCUPIED);
} }
@@ -164,7 +176,7 @@ public class SpotSceneManager extends SceneManager
if (soi == null) { if (soi == null) {
Log.warning("Aiya! Can't update non-existent occupant info " + Log.warning("Aiya! Can't update non-existent occupant info " +
"with new location [where=" + where() + "with new location [where=" + where() +
", body=" + source + "]."); ", body=" + source.who() + "].");
throw new ServiceFailedException(INTERNAL_ERROR); throw new ServiceFailedException(INTERNAL_ERROR);
} }
@@ -210,9 +222,9 @@ public class SpotSceneManager extends SceneManager
int locidx = _sscene.getLocationIndex(locationId); int locidx = _sscene.getLocationIndex(locationId);
if (locidx == -1 || _locationOccs[locidx] != sourceOid) { if (locidx == -1 || _locationOccs[locidx] != sourceOid) {
Log.warning("User not in specified location for CCREQ " + Log.warning("User not in specified location for CCREQ " +
"[where=" + where() + ", body=" + source + "[where=" + where() + ", chatter=" + source +
", locId=" + locationId + ", locidx=" + locidx + " (" + sourceOid + "), locId=" + locationId +
", message=" + message + "]."); ", locidx=" + locidx + ", message=" + message + "].");
return; return;
} }
@@ -220,8 +232,8 @@ public class SpotSceneManager extends SceneManager
int clusterIndex = _sscene.getClusterIndex(locidx); int clusterIndex = _sscene.getClusterIndex(locidx);
if (clusterIndex == -1) { if (clusterIndex == -1) {
Log.warning("User in clusterless location sent CCREQ " + Log.warning("User in clusterless location sent CCREQ " +
"[where=" + where() + ", body=" + source + "[where=" + where() + ", chatter=" + source +
", locId=" + locationId + " (" + sourceOid + "), locId=" + locationId +
", message=" + message + "]."); ", message=" + message + "].");
return; return;
} }
@@ -234,7 +246,8 @@ public class SpotSceneManager extends SceneManager
} else { } else {
Log.warning("Have no cluster object for CCREQ " + Log.warning("Have no cluster object for CCREQ " +
"[where=" + where() + ", cidx=" + clusterIndex + "[where=" + where() + ", cidx=" + clusterIndex +
", chatter=" + source + ", message=" + message + "]."); ", chatter=" + source + " (" + sourceOid +
"), message=" + message + "].");
} }
} }