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;
@@ -86,7 +86,7 @@ public class LocationProvider extends InvocationProvider
// anything in distributed object world
if (source.location == placeId) {
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 + "].");
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;
@@ -63,8 +63,7 @@ public class SpotProvider extends InvocationProvider
_screg.getSceneManager(sceneId);
if (smgr == null) {
Log.warning("Traverse portal missing source scene " +
"[user=" + source.username +
", sceneId=" + sceneId +
"[user=" + source.who() + ", sceneId=" + sceneId +
", portalId=" + portalId + "].");
throw new ServiceFailedException(INTERNAL_ERROR);
}
@@ -77,8 +76,7 @@ public class SpotProvider extends InvocationProvider
// make sure this portal has valid info
if (destSceneId == -1) {
Log.warning("Traverse portal provided with invalid portal " +
"[user=" + source.username +
", sceneId=" + sceneId +
"[user=" + source.who() + ", sceneId=" + sceneId +
", portalId=" + portalId +
", destSceneId=" + destSceneId + "].");
throw new ServiceFailedException(NO_SUCH_PORTAL);
@@ -176,7 +174,7 @@ public class SpotProvider extends InvocationProvider
_screg.getSceneManager(sceneId);
if (smgr == null) {
Log.warning("User requested to change location in " +
"non-existent scene [user=" + source.username +
"non-existent scene [user=" + source.who() +
", sceneId=" + sceneId +
", locId=" + locationId + "].");
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;
@@ -54,12 +54,22 @@ public class SpotSceneManager extends SceneManager
/**
* Returns the locationId of an unoccupied location in this scene
* (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)
{
return SpotSceneUtil.getUnoccupiedLocation(
int locId = SpotSceneUtil.getUnoccupiedLocation(
_sscene.getModel(), _locationOccs, preferClusters);
// mark the location as pending
_locationOccs[_sscene.getLocationIndex(locId)] = -1;
return locId;
}
// documentation inherited
@@ -145,15 +155,17 @@ public class SpotSceneManager extends SceneManager
{
// make sure no one is already in the requested location
int locidx = _sscene.getLocationIndex(locationId);
if (locidx == -1 || _locationOccs[locidx] != 0) {
Log.info("Ignoring request to change to occupied or " +
"non-existent location [where=" + where() +
", user=" + source.username +
", locId=" + locationId + ", locidx=" + locidx +
", lococcs=" + StringUtil.toString(_locationOccs) +
", occinfo=" + StringUtil.listToString(
_plobj.occupantInfo.entries(),
SpotOccupantInfo.OIDS_AND_LOCS) + "].");
if (locidx == -1) {
Log.warning("Ignoring request to move to non-existent location " +
"[where=" + where() + ", user=" + source.who() +
", locId=" + locationId + "].");
throw new ServiceFailedException(LOCATION_OCCUPIED);
} else if (_locationOccs[locidx] > 0) {
Log.info("Ignoring request to move to occupied location " +
"[where=" + where() + ", user=" + source.who() +
", locId=" + locationId +
", occupantOid=" + _locationOccs[locidx] + "].");
throw new ServiceFailedException(LOCATION_OCCUPIED);
}
@@ -164,7 +176,7 @@ public class SpotSceneManager extends SceneManager
if (soi == null) {
Log.warning("Aiya! Can't update non-existent occupant info " +
"with new location [where=" + where() +
", body=" + source + "].");
", body=" + source.who() + "].");
throw new ServiceFailedException(INTERNAL_ERROR);
}
@@ -210,9 +222,9 @@ public class SpotSceneManager extends SceneManager
int locidx = _sscene.getLocationIndex(locationId);
if (locidx == -1 || _locationOccs[locidx] != sourceOid) {
Log.warning("User not in specified location for CCREQ " +
"[where=" + where() + ", body=" + source +
", locId=" + locationId + ", locidx=" + locidx +
", message=" + message + "].");
"[where=" + where() + ", chatter=" + source +
" (" + sourceOid + "), locId=" + locationId +
", locidx=" + locidx + ", message=" + message + "].");
return;
}
@@ -220,8 +232,8 @@ public class SpotSceneManager extends SceneManager
int clusterIndex = _sscene.getClusterIndex(locidx);
if (clusterIndex == -1) {
Log.warning("User in clusterless location sent CCREQ " +
"[where=" + where() + ", body=" + source +
", locId=" + locationId +
"[where=" + where() + ", chatter=" + source +
" (" + sourceOid + "), locId=" + locationId +
", message=" + message + "].");
return;
}
@@ -234,7 +246,8 @@ public class SpotSceneManager extends SceneManager
} else {
Log.warning("Have no cluster object for CCREQ " +
"[where=" + where() + ", cidx=" + clusterIndex +
", chatter=" + source + ", message=" + message + "].");
", chatter=" + source + " (" + sourceOid +
"), message=" + message + "].");
}
}