Last active
August 24, 2019 17:08
-
-
Save riftrsps/cb57df3c091eb5e673edf5f6d65e3fde to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// each variousSettings index represents the bits for either a varbit or a varp | |
Client | |
int[] variousSettings = new int[2000]; | |
// a VarBit's index is used to access variousSettings | |
// lsb is where to start reading bits | |
// msb is where to stop reading bits | |
VarBit | |
static Varbit[] cache; | |
int index; | |
int lsb; | |
int msb; | |
static void unpackConfig() // read from varbit.dat into cache | |
// Object definitions are stored in cache as loc.dat. | |
// An object definition has a stream, a childIDs[] and a varbit. | |
// - The stream is used to read data loaded from loc.dat | |
// - The childIDs contain objects IDs for an object to "morph" into | |
// - The varbit acts as an array index for VarBit.cache | |
ObjectDef | |
Stream stream; | |
int[] childIDs; | |
int varbit; | |
static void unpackConfig() // load loc.dat into stream | |
ObjectDef forID(int id) | |
ObjectDef def = ...; | |
def.id = id; | |
def.readValues(); | |
return def; | |
void readValues() // read from loc.dat | |
int type; | |
do | |
type = dataStream.readByte(); | |
if(type == 77) | |
int varbit = dataStream.readShort(); | |
int childLength = data.readByte(); | |
if(childLength > 0) | |
childIDs = new int[childLength]; | |
for(int i = 0; i < childLength; i++) | |
childIDs[i] = data.readShort(); | |
while(type != 0); | |
ObjectDef morph() | |
VarBit vb = VarBit.cache[varbit]; | |
int index = vb.index; | |
int lsb = vb.lsb; | |
int msb = vb.msb; | |
int bits = Client.variousSettings[index]; | |
int childIndex = bits >> lsb & MASKS[msb]; | |
int childID = childIDs[childIndex]; | |
return forID(childID); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment