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
@@ -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);
}
}