Emberveil source

tests/AgilityAssetCheck.java

import java.io.*;
import java.util.zip.GZIPInputStream;
public final class AgilityAssetCheck {
 static int checks;
 static void check(boolean value,String label){checks++;if(!value)throw new AssertionError(label);}
 static byte[] inflate(byte[] raw)throws Exception {
  try(GZIPInputStream input=new GZIPInputStream(new ByteArrayInputStream(raw));ByteArrayOutputStream output=new ByteArrayOutputStream()) {
   byte[] buffer=new byte[8192];int n;while((n=input.read(buffer))!=-1)output.write(buffer,0,n);return output.toByteArray();
  }
 }
 public static void main(String[] args)throws Exception {
  String root="runtime/client-cache/";
  try(RandomAccessFile dat=new RandomAccessFile(root+"main_file_cache.dat","r");RandomAccessFile idx=new RandomAccessFile(root+"main_file_cache.idx0","r");RandomAccessFile framesIdx=new RandomAccessFile(root+"main_file_cache.idx2","r")) {
   Decompressor configStore=new Decompressor(dat,idx,1), frameStore=new Decompressor(dat,framesIdx,3);
   StreamLoader config=new StreamLoader(configStore.decompress(2));
   Animation.unpackConfig(config);ObjectDef.unpackConfig(config);Class36.method528(65535);
   StreamLoader versions=new StreamLoader(configStore.decompress(5));Stream stream=new Stream(versions.getDataForName("anim_version"));
   for(int id=0;id<stream.buffer.length/2;id++)if(stream.readUnsignedWord()!=0)Class36.method529(inflate(frameStore.decompress(id)));
   for(int id:new int[]{762,844,828,827,3487,840,748,3067,1604,1148,756,3480,3483,3485,3494,3482,744,743,2750,2753}) {
    check(id<Animation.anims.length && Animation.anims[id]!=null,"Animation definition "+id);
    for(int frame:Animation.anims[id].anIntArray353)if(frame!=-1)check(Class36.method531(frame)!=null,"Animation frame "+id+":"+frame);
   }
   for(int id:new int[]{2295,2285,2313,2312,2314,2286,154,4058,2282,2294,2284,2302,3205,1948,2288,2283,2311,2297,2328,5138,5133,5134,5135,5152,5136,5141,5139,12568,12570,12573,12576,12578,12618,10857,10865,10868,10884,10882,10861,10859,10860,10886,10888,10852}) {
    ObjectDef object=ObjectDef.forID(id);check(object!=null && object.name!=null,"Obstacle definition "+id);
   }
   System.out.println("PASS: "+checks+" agility animation/frame/object asset checks");
  }
 }
}