use of org.apollo.cache.archive.ArchiveEntry in project apollo by apollo-rsps.
the class MapIndexDecoder method decode.
/**
* Decodes {@link MapIndex}s from the specified {@link IndexedFileSystem}.
*
* @return A {@link Map} of packed coordinates to their MapDefinitions.
* @throws IOException If there is an error reading or decoding the Archive.
*/
public Map<Integer, MapIndex> decode() throws IOException {
Archive archive = fs.getArchive(0, VERSIONS_ARCHIVE_FILE_ID);
ArchiveEntry entry = archive.getEntry("map_index");
Map<Integer, MapIndex> definitions = new HashMap<>();
ByteBuffer buffer = entry.getBuffer();
int count = buffer.capacity() / (3 * Short.BYTES + Byte.BYTES);
for (int times = 0; times < count; times++) {
int id = buffer.getShort() & 0xFFFF;
int terrain = buffer.getShort() & 0xFFFF;
int objects = buffer.getShort() & 0xFFFF;
boolean members = buffer.get() == 1;
definitions.put(id, new MapIndex(id, terrain, objects, members));
}
return definitions;
}
Aggregations