RuneHive-Game
Loading...
Searching...
No Matches
MapDefinitionDecoder.java
Go to the documentation of this file.
1package com.runehive.fs.cache.decoder;
2
3import com.runehive.fs.cache.FileSystem;
4import com.runehive.fs.cache.archive.Archive;
5import com.runehive.game.world.region.RegionDefinition;
6import org.apache.logging.log4j.LogManager;
7import org.apache.logging.log4j.Logger;
8
9import java.nio.ByteBuffer;
10
11/**
12 * A class which parses {@link RegionDefinition}s
13 *
14 * @author Ryley Kimmel <ryley.kimmel@live.com>
15 * @author Artem Batutin <artembatutin@gmail.com>
16 */
17public final class MapDefinitionDecoder implements Runnable {
18
19 /** The logger that will print important information. */
20 private final static Logger LOGGER = LogManager.getLogger(MapDefinitionDecoder.class);
21
22 /** The IndexedFileSystem. */
23 private final FileSystem fs;
24
25 /**
26 * Creates the {@link MapDefinitionDecoder}.
27 *
28 * @param fs The {@link FileSystem}.
29 */
31 this.fs = fs;
32 }
33
34 @Override
35 public void run() {
36 LOGGER.info("Loading region definitions.");
38 ByteBuffer buffer = archive.getData("map_index");
39 int count = (buffer.getShort() & 0xFFFF);
40 for (int i = 0; i < count; i++) {
41 int hash = buffer.getShort() & 0xFFFF;
42 int terrainFile = buffer.getShort() & 0xFFFF;
43 int objectFile = buffer.getShort() & 0xFFFF;
44 RegionDefinition.set(new RegionDefinition(hash, terrainFile, objectFile));
45 }
46 LOGGER.info("Loaded " + count + " region definitions.");
47 }
48
49}
Represents a file system of Caches and Archives.
static final int MANIFEST_ARCHIVE
Represents the id of the manifest archive.
Represents an archive within the Cache.
Definition Archive.java:25
static final Logger LOGGER
The logger that will print important information.
MapDefinitionDecoder(FileSystem fs)
Creates the MapDefinitionDecoder.
Represents a single region definition.
static void set(RegionDefinition definition)
Adds a RegionDefinition.