Esempio n. 1
0
 public final void init(Archive archive, Game client) {
   String[] versionFiles = {"model_version", "anim_version", "midi_version", "map_version"};
   for (int version = 0; version < 4; version++) {
     byte[] data = archive.getFile(versionFiles[version]);
     int versionCount = data.length / 2;
     Buffer buffer = new Buffer(data);
     fileVersions[version] = new int[versionCount];
     filePriorities[version] = new byte[versionCount];
     for (int file = 0; file < versionCount; file++) {
       fileVersions[version][file] = buffer.getUnsignedLEShort();
     }
   }
   String[] crcFiles = {"model_crc", "anim_crc", "midi_crc", "map_crc"};
   for (int crc = 0; crc < 4; crc++) {
     byte[] data = archive.getFile(crcFiles[crc]);
     int crcCount = data.length / 4;
     Buffer buffer = new Buffer(data);
     fileCrc[crc] = new int[crcCount];
     for (int file = 0; file < crcCount; file++) {
       fileCrc[crc][file] = buffer.getInt();
     }
   }
   byte[] data = archive.getFile("model_index");
   int count = fileVersions[0].length;
   modelIndex = new byte[count];
   for (int i = 0; i < count; i++) {
     if (i < data.length) {
       modelIndex[i] = data[i];
     } else {
       modelIndex[i] = (byte) 0;
     }
   }
   data = archive.getFile("map_index");
   Buffer buffer = new Buffer(data);
   count = data.length / 7;
   regHash = new int[count];
   regMapIndex = new int[count];
   regLandIndex = new int[count];
   regShouldPreload = new int[count];
   for (int reg = 0; reg < count; reg++) {
     regHash[reg] = buffer.getUnsignedLEShort();
     regMapIndex[reg] = buffer.getUnsignedLEShort();
     regLandIndex[reg] = buffer.getUnsignedLEShort();
     regShouldPreload[reg] = buffer.getUnsignedByte();
   }
   data = archive.getFile("anim_index");
   buffer = new Buffer(data);
   count = data.length / 2;
   animIndex = new int[count];
   for (int i = 0; i < count; i++) {
     animIndex[i] = buffer.getUnsignedLEShort();
   }
   data = archive.getFile("midi_index");
   buffer = new Buffer(data);
   count = data.length;
   midiIndex = new int[count];
   for (int i = 0; i < count; i++) {
     midiIndex[i] = buffer.getUnsignedByte();
   }
   this.client = client;
   running = true;
   this.client.startRunnable(this, 2);
 }