RuneHive-Tarnish
Neural OSRS Enhancement Framework
Loading...
Searching...
No Matches
MapDefinitionDecoder.java
1package com.osroyale.fs.cache.decoder;
2
3import com.osroyale.fs.cache.FileSystem;
4import com.osroyale.fs.cache.archive.Archive;
5import com.osroyale.game.world.region.RegionDefinition;
6import org.apache.logging.log4j.LogManager;
7import org.apache.logging.log4j.Logger;
8
9import java.nio.ByteBuffer;
10
38
39* A class which parses {@link RegionDefinition}s
40 *
41 * @author Ryley Kimmel <ryley.kimmel@live.com>
42 * @author Artem Batutin <artembatutin@gmail.com>
43 */
44public final class MapDefinitionDecoder implements Runnable {
45
47 private final static Logger LOGGER = LogManager.getLogger(MapDefinitionDecoder.class);
48
50 private final FileSystem fs;
51
57 public MapDefinitionDecoder(FileSystem fs) {
58 this.fs = fs;
59 }
60
61 @Override
62 public void run() {
63 LOGGER.info("Loading region definitions.");
64 Archive archive = fs.getArchive(FileSystem.MANIFEST_ARCHIVE);
65 ByteBuffer buffer = archive.getData("map_index");
66 int count = (buffer.getShort() & 0xFFFF);
67 for (int i = 0; i < count; i++) {
68 int hash = buffer.getShort() & 0xFFFF;
69 int terrainFile = buffer.getShort() & 0xFFFF;
70 int objectFile = buffer.getShort() & 0xFFFF;
71 RegionDefinition.set(new RegionDefinition(hash, terrainFile, objectFile));
72 }
73 LOGGER.info("Loaded " + count + " region definitions.");
74 }
75
76}