Didn't know how to describe it, so just put clipped landscapes, basically the gzipped files used here:
Code:
public static void load() {
long startup = System.currentTimeMillis();
System.out.println("Loading region clipping...");
try {
File f = new File("./data/cache/map_index.dat");
byte[] buffer = new byte[(int) f.length()];
DataInputStream dis = new DataInputStream(new FileInputStream(f));
dis.readFully(buffer);
dis.close();
ByteStream in = new ByteStream(buffer);
int size = in.readUnsignedShort();
regions = new RegionClipping[size];
int[] mapRegionIds = new int[size];
int[] mapTerrains = new int[size];
int[] mapLandscapes = new int[size];
for (int i = 0; i < size; i++) {
mapRegionIds[i] = in.readUnsignedShort();
mapTerrains[i] = in.readUnsignedShort();
mapLandscapes[i] = in.readUnsignedShort();
}
for (int i = 0; i < size; i++) {
regions[i] = new RegionClipping(mapRegionIds[i]);
}
int amount = 0;
for (int i = 0; i < size; i++) {
byte[] file1 = getBuffer(new File("./data/cache/map/" + mapLandscapes[i] + ".gz"));
byte[] file2 = getBuffer(new File("./data/cache/map/" + mapTerrains[i] + ".gz"));
if (file1 == null || file2 == null)
continue;
loadMaps(mapRegionIds[i], new ByteStream(file1), new ByteStream(file2), i);
amount++;
}
System.out.println("Loaded " + amount + " region clipping" + (amount != 1 ? "s" : "") + " in " + (System.currentTimeMillis() - startup) + "ms");
} catch (Exception e) {
e.printStackTrace();
}
}
private static void loadMaps(int regionId, ByteStream landscapes, ByteStream terrains, int index) {
try {
int absX = (regionId >> 8) * 64;
int absY = (regionId & 0xff) * 64;
int[][][] someArray = new int[4][64][64];
for (int i = 0; i < 4; i++) {
for (int i2 = 0; i2 < 64; i2++) {
for (int i3 = 0; i3 < 64; i3++) {
do {
if (terrains.offset + 1 > terrains.buffer.length)
break;
int l1 = terrains.getUByte();
if (l1 == 0) {
break;
} else if (l1 == 1) {
terrains.skip(1);
break;
} else if (l1 <= 49) {
terrains.skip(1);
} else if (l1 <= 81) {
someArray[i][i2][i3] = l1 - 49;
} else {
someArray[i][i2][i3] = l1 - 81;
}
} while(true);
}
}
}
for (int i = 0; i < 4; i++) {
for (int i2 = 0; i2 < 64; i2++) {
for (int i3 = 0; i3 < 64; i3++) {
if ((someArray[i][i2][i3] & 1) == 1) {
int height = i;
if ((someArray[1][i2][i3] & 2) == 2) {
height--;
}
if (height >= 0 && height <= 3) {
addClipping(absX + i2, absY + i3, height, 0x200000);
}
}
}
}
}
int objectId = -1;
int value;
while ((value = landscapes.getUSmart()) != 0) {
System.out.println("value=" + value);
objectId += value;
int location = 0;
int increment;
while ((increment = landscapes.getUSmart()) != 0) {
System.out.println("increment=" + increment);
location += increment - 1;
System.out.println("location=" + location);
int localY = (location & 0x3f);
int localX = (location >> 6 & 0x3f);
int height = location >> 12;
int objectData = landscapes.getUByte();
int type = objectData >> 2;
int direction = objectData & 3;
int x = absX + localX;
int y = absY + localY;
if (localX < 0 || localX >= 64 || localY < 0 || localY >= 64) {
continue;
}
if ((someArray[1][localX][localY] & 2) == 2) {
height--;
}
if (height >= 0 && height <= 3) {
addObject(objectId, x, y, height, type, direction);
System.out.println("rendered object: " + objectId + "; x=" + x + "; y=" + y + "; z=" + height);
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
Thought it was this:
Code:
public void extractMapFiles(String directory) throws IOException {
File folder = new File(directory);
if (folder.mkdir()) {
System.out.println("Created new directory: " + directory);
}
for (int i = 0; i < mainCacheFile[4].size(); i++) {
System.out.println("Extracting map: " + i);
byte[] map = mainCacheFile[4].get(i);
ByteArrayOutputStream bout = new ByteArrayOutputStream();
DeflaterOutputStream os = new GZIPOutputStream(bout);
try {
os.write(map);
os.finish();
DataOutputStream output = new DataOutputStream(new FileOutputStream(directory + i + ".gz"));
output.write(bout.toByteArray());
} finally {
os.close();
}
}
}
But it wasn't as the reading was wrong, used the 317 map gzipped files (from the clipping release) and it worked fine, which is how I know that the dumped files are wrong.
Anyone know which files I need to dump?