Created ZoneUtil for composing and decomposing qualified zone ids.

git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@767 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2001-12-13 05:46:11 +00:00
parent e670b076e6
commit 366914b4d1
2 changed files with 46 additions and 3 deletions
@@ -1,5 +1,5 @@
//
// $Id: ZoneRegistry.java,v 1.2 2001/12/04 01:06:33 mdb Exp $
// $Id: ZoneRegistry.java,v 1.3 2001/12/13 05:46:11 mdb Exp $
package com.threerings.whirled.zone.server;
@@ -10,6 +10,7 @@ import com.threerings.presents.server.InvocationManager;
import com.threerings.whirled.Log;
import com.threerings.whirled.server.SceneRegistry;
import com.threerings.whirled.zone.server.util.ZoneUtil;
/**
* The zone registry takes care of mapping zone requests to the
@@ -50,10 +51,13 @@ public class ZoneRegistry
/**
* Returns the zone manager that handles the specified zone id.
*
* @param qualifiedZoneId the qualified zone id for which the manager
* should be looked up.
*/
public ZoneManager getZoneManager (int zoneId)
public ZoneManager getZoneManager (int qualifiedZoneId)
{
int zoneType = (0xFF000000 & zoneId) >> 24;
int zoneType = ZoneUtil.zoneType(qualifiedZoneId);
return (ZoneManager)_managers.get(zoneType);
}
@@ -0,0 +1,39 @@
//
// $Id: ZoneUtil.java,v 1.1 2001/12/13 05:46:11 mdb Exp $
package com.threerings.whirled.zone.server.util;
/**
* Server-specific, zone-related utility functions.
*/
public class ZoneUtil
{
/**
* Composes the zone type and zone id into a qualified zone id. A
* qualified zone id is what should be passed around so that the
* server can determine the zone type from the zone id when necessary.
*/
public static int qualifyZoneId (byte zoneType, int zoneId)
{
int qualifiedZoneId = zoneType;
qualifiedZoneId <<= 24;
qualifiedZoneId |= zoneId;
return qualifiedZoneId;
}
/**
* Extracts the zone type from a qualified zone id.
*/
public static int zoneType (int qualifiedZoneId)
{
return (0xFF000000 & qualifiedZoneId) >> 24;
}
/**
* Extracts the zone id from a qualified zone id.
*/
public static int zoneId (int qualifiedZoneId)
{
return (0x00FFFFFF & qualifiedZoneId);
}
}