mirror of
https://github.com/2006-Scape/apollo.git
synced 2026-07-04 16:49:11 +00:00
Refactor map loading code
Refactors the map file loading code by importing existing code from the Vicis cache editor project. Adds classes for decoding objects and tiles for a given map file index. Only the new MapIndex decoder code is used when loading GameObjects at the moment , which will later be updated.
This commit is contained in:
@@ -8,10 +8,10 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apollo.cache.IndexedFileSystem;
|
||||
import org.apollo.cache.decoder.MapFileDecoder;
|
||||
import org.apollo.cache.decoder.MapFileDecoder.MapDefinition;
|
||||
import org.apollo.cache.decoder.ObjectDefinitionDecoder;
|
||||
import org.apollo.cache.def.ObjectDefinition;
|
||||
import org.apollo.cache.map.MapIndex;
|
||||
import org.apollo.cache.map.MapIndexDecoder;
|
||||
import org.apollo.game.io.player.PlayerSerializer;
|
||||
import org.apollo.game.model.Position;
|
||||
import org.apollo.game.model.World;
|
||||
@@ -85,10 +85,13 @@ public final class GameObjectDecoder implements Runnable {
|
||||
ObjectDefinitionDecoder decoder = new ObjectDefinitionDecoder(fs);
|
||||
decoder.run();
|
||||
|
||||
try {
|
||||
Map<Integer, MapDefinition> definitions = MapFileDecoder.decode(fs);
|
||||
MapIndexDecoder mapIndexDecoder = new MapIndexDecoder(fs);
|
||||
mapIndexDecoder.run();
|
||||
|
||||
for (MapDefinition definition : definitions.values()) {
|
||||
try {
|
||||
Map<Integer, MapIndex> indices = MapIndex.getIndices();
|
||||
|
||||
for (MapIndex definition : indices.values()) {
|
||||
int packed = definition.getPackedCoordinates();
|
||||
int x = (packed >> 8 & 0xFF) * (Region.SIZE * Region.SIZE);
|
||||
int y = (packed & 0xFF) * (Region.SIZE * Region.SIZE);
|
||||
@@ -97,7 +100,7 @@ public final class GameObjectDecoder implements Runnable {
|
||||
ByteBuffer decompressed = ByteBuffer.wrap(CompressionUtil.degzip(objects));
|
||||
decodeObjects(decompressed, x, y);
|
||||
|
||||
ByteBuffer terrain = fs.getFile(4, definition.getTerrainFile());
|
||||
ByteBuffer terrain = fs.getFile(4, definition.getMapFile());
|
||||
decompressed = ByteBuffer.wrap(CompressionUtil.degzip(terrain));
|
||||
decodeTerrain(decompressed, x, y);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user