1package com.runehive.fs.cache.decoder;
3import com.runehive.fs.cache.FileSystem;
4import com.runehive.fs.cache.archive.Archive;
5import com.runehive.fs.util.ByteBufferUtil;
6import com.runehive.game.world.object.GameObjectDefinition;
7import org.apache.logging.log4j.LogManager;
8import org.apache.logging.log4j.Logger;
10import java.nio.ByteBuffer;
37 LOGGER.info(
"Loading object definitions.");
39 ByteBuffer dat =
archive.getData(
"loc.dat");
40 ByteBuffer idx =
archive.getData(
"loc.idx");
42 int count = idx.getShort() & 0xFFFF;
46 LOGGER.warn(
"GameObjectDefinition count mismatch: cache has " + count +
", expected " +
52 for (
int index = 0; index < count; index++) {
55 pos += idx.getShort() & 0xFFFF;
58 LOGGER.info(
"Loaded " + loaded +
" object definitions.");
68 private static void decode(
int id, ByteBuffer buffer) {
74 boolean impenetrable =
true;
75 boolean hasActions =
false;
76 boolean interactive =
false;
78 boolean decoration =
false;
79 boolean removeClipping =
false;
80 boolean models =
false;
86 int opcode = buffer.get() & 0xff;
92 int len = buffer.get();
93 if (len > 0 && !models) {
94 for (
int idx = 0; idx < len; idx++) {
95 buffer.position(buffer.position() + Short.BYTES);
96 if (buffer.get() != 10 && idx == 0) {
101 buffer.position(buffer.position() + len * (Byte.BYTES + Short.BYTES));
103 }
else if (opcode == 2) {
105 }
else if (opcode == 3) {
107 }
else if (opcode == 5) {
108 int len = buffer.get();
111 buffer.position(buffer.position() + len * Short.BYTES);
113 }
else if (opcode == 14) {
114 width = buffer.get();
115 }
else if (opcode == 15) {
116 length = buffer.get();
117 }
else if (opcode == 17) {
119 impenetrable =
false;
120 }
else if (opcode == 18) {
121 impenetrable =
false;
122 }
else if (opcode == 19) {
123 hasActions = (buffer.get() == 1);
124 }
else if (opcode == 21) {
126 }
else if (opcode == 22) {
128 }
else if (opcode == 23) {
130 }
else if (opcode == 24) {
132 }
else if (opcode == 27) {
134 }
else if (opcode == 28) {
136 }
else if (opcode == 29) {
138 }
else if (opcode == 39) {
140 }
else if (opcode >= 30 && opcode < 35) {
143 }
else if (opcode == 40) {
144 int len = buffer.get();
145 for (
int i = 0; i < len; i++) {
149 }
else if (opcode == 41) {
150 int len = buffer.get();
151 for (
int i = 0; i < len; i++) {
155 }
else if (opcode == 61) {
157 }
else if (opcode == 62) {
159 }
else if (opcode == 64) {
161 }
else if (opcode == 65) {
163 }
else if (opcode == 66) {
165 }
else if (opcode == 67) {
167 }
else if (opcode == 68) {
169 }
else if (opcode == 69) {
170 walkingFlag = buffer.get();
171 }
else if (opcode == 70) {
173 }
else if (opcode == 71) {
175 }
else if (opcode == 72) {
177 }
else if (opcode == 73) {
179 }
else if (opcode == 74) {
180 removeClipping =
true;
181 }
else if (opcode == 75) {
183 }
else if (opcode == 77) {
187 int len = buffer.get() & 0xFF;
188 for (
int i = 0; i <= len; ++i) {
191 }
else if (opcode == 78) {
194 }
else if (opcode == 79) {
199 int len = buffer.get() & 0xFF;
200 for (
int i = 0; i < len; ++i) {
203 }
else if (opcode == 81) {
205 }
else if (opcode == 82) {
207 }
else if (opcode == 89) {
209 }
else if (opcode == 92) {
214 int len = buffer.get() & 0xFF;
215 for (
int i = 0; i <= len; ++i) {
218 }
else if (opcode == 249) {
219 int len = buffer.get();
220 for (
int i = 0; i < len; i++) {
221 boolean isString = buffer.get() == 1;
231 LOGGER.warn(
"Unknown object opcode: {} (last: {}) for object id: {}. Skipping remaining opcodes for this object.",
232 opcode, lastOpcode,
id);
238 if (!name.equals(
"null")) {
239 hasActions = models && is10;
245 if (removeClipping) {
247 impenetrable =
false;
257 name =
"Donator Box";
261 GameObjectDefinition.
addDefinition(
new GameObjectDefinition(
id, name, desc, width, length, distance, solid, impenetrable, hasActions, wall, decoration, walkingFlag));
Represents a file system of Caches and Archives.
static final int CONFIG_ARCHIVE
Represents the id of the configurations archive.
Represents an archive within the Cache.
static void decode(int id, ByteBuffer buffer)
Parses a single game object definition by reading object info from a buffer.
final FileSystem fs
The IndexedFileSystem.
static final Logger LOGGER
The logger to log process output.
ObjectDefinitionDecoder(FileSystem fs)
Creates the ObjectDefinitionDecoder.
A static-utility class containing extension or helper methods for ByteBuffers.
static String readStringCp1252NullTerminated(ByteBuffer buffer)
static int getMedium(ByteBuffer buffer)
Gets a 24-bit medium integer from the specified ByteBuffer, this method does not mark the ByteBuffers...
Represents a single type of object.
static final int MAX_DEFINITIONS
The maximum number of object definitions.
static void addDefinition(GameObjectDefinition def)
Adds a definition.