Exemplo n.º 1
0
 public void loadDefinition(Buffer buffer) {
   while (true) {
     int attributeId = buffer.getUnsignedByte();
     if (attributeId == 0) {
       break;
     }
     if (attributeId == 1) {
       partId = buffer.getUnsignedByte();
     } else if (attributeId == 2) {
       int modelCount = buffer.getUnsignedByte();
       modelId = new int[modelCount];
       for (int model = 0; model < modelCount; model++) {
         modelId[model] = buffer.getUnsignedLEShort();
       }
     } else if (attributeId == 3) {
       widgetDisplayed = true;
     } else if (attributeId >= 40 && attributeId < 50) {
       originalModelColors[attributeId - 40] = buffer.getUnsignedLEShort();
     } else if (attributeId >= 50 && attributeId < 60) {
       modifiedModelColors[attributeId - 50] = buffer.getUnsignedLEShort();
     } else if (attributeId >= 60 && attributeId < 70) {
       headModelId[attributeId - 60] = buffer.getUnsignedLEShort();
     } else {
       System.out.println("Error unrecognised config code: " + attributeId);
     }
   }
 }
Exemplo n.º 2
0
 public ImageRGB(Archive archive, String string, int archiveIndex) {
   Buffer dataBuffer = new Buffer(archive.getFile(string + ".dat"));
   Buffer indexBuffer = new Buffer(archive.getFile("index.dat"));
   indexBuffer.offset = dataBuffer.getUnsignedLEShort();
   maxWidth = indexBuffer.getUnsignedLEShort();
   maxHeight = indexBuffer.getUnsignedLEShort();
   int length = indexBuffer.getUnsignedByte();
   int[] pixels = new int[length];
   for (int pixel = 0; pixel < (length - 1); pixel++) {
     pixels[pixel + 1] = indexBuffer.get24BitInt();
     if (pixels[pixel + 1] == 0) {
       pixels[pixel + 1] = 1;
     }
   }
   for (int index = 0; index < archiveIndex; index++) {
     indexBuffer.offset += 2;
     dataBuffer.offset += indexBuffer.getUnsignedLEShort() * indexBuffer.getUnsignedLEShort();
     indexBuffer.offset++;
   }
   offsetX = indexBuffer.getUnsignedByte();
   offsetY = indexBuffer.getUnsignedByte();
   width = indexBuffer.getUnsignedLEShort();
   height = indexBuffer.getUnsignedLEShort();
   int type = indexBuffer.getUnsignedByte();
   int pixelCount = width * height;
   this.pixels = new int[pixelCount];
   if (type == 0) {
     for (int pixel = 0; pixel < pixelCount; pixel++) {
       this.pixels[pixel] = pixels[dataBuffer.getUnsignedByte()];
     }
   } else if (type == 1) {
     for (int x = 0; x < width; x++) {
       for (int y = 0; y < height; y++) {
         this.pixels[x + (y * width)] = pixels[dataBuffer.getUnsignedByte()];
       }
     }
   }
 }
Exemplo n.º 3
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);
 }