private boolean load(ByteBuffer databuffer) throws InvalidClassException {
// read the version and the header
try {
info = new MVER(buff);
} catch (ChunkNotFoundException e) {
throw new InvalidClassException("No ADT Version found.");
}
try {
header = new MHDR(buff);
} catch (ChunkNotFoundException e) {
throw new InvalidClassException("No ADT Headers found.");
}
checkVersion();
// load stuff using the offsets
int base_offs = header.getBaseOffs();
try {
buff.position(base_offs + header.getInfoOffs());
fieldInfo = new MCIN(buff);
buff.position(base_offs + header.getTexOffs());
mtex = new MTEX(buff);
buff.position(base_offs + header.getModelOffs());
mmdx = new MMDX(buff);
buff.position(base_offs + header.getModelIDOffs());
mmid = new MMID(buff);
buff.position(base_offs + header.getMapObjOffs());
mwmo = new MWMO(buff);
buff.position(base_offs + header.getMapObjIDOffs());
mwid = new MWID(buff);
buff.position(base_offs + header.getDooDsDefOffs());
mddf = new MDDF(buff);
buff.position(base_offs + header.getObjDefOffs());
modf = new MODF(buff);
if (version_flag >= ADT_VERSION_EXPANSION_TBC)
if (header.getoffsMH2O() != 0) {
buff.position(base_offs + header.getoffsMH2O());
mh2o = new unkChunk(buff, "O2HM");
}
} catch (ChunkNotFoundException e) {
// TODO: try to find it manually
throw new InvalidClassException(e.getMessage());
}
try {
mcnk = new MCNK[256];
for (int c = 0; c < 256; c++) {
buff.position(fieldInfo.getOffs(c));
mcnk[c] = new MCNK(buff, version_flag);
}
} catch (SubChunkNotFoundException e) {
throw new InvalidClassException(e.getMessage());
} catch (ChunkNotFoundException e) {
// TODO: try to find it manually
throw new InvalidClassException(e.getMessage());
}
if (version_flag >= ADT_VERSION_EXPANSION_TBC)
try {
if (header.getoffsFlightBoundary() != 0) {
buff.position(base_offs + header.getoffsFlightBoundary());
mfbo = new MFBO(buff);
}
} catch (ChunkNotFoundException e) {
// TODO: try to find it manually
throw new InvalidClassException(e.getMessage());
}
if (version_flag >= ADT_VERSION_EXPANSION_WOTLK){
try{
if (header.getoffsMTFX() != 0) {
buff.position(base_offs + header.getoffsMTFX());
mtfx = new MTFX(buff);
}
}
catch(ChunkNotFoundException e){
// TODO: try to find it manually
throw new InvalidClassException(e.getMessage());
}
}
// clean return
buff.limit(buff.position());