mirror of
https://gitlab.com/2009scape/tools/2009scape-map-viewer.git
synced 2026-08-28 05:45:25 -06:00
Added rest of the decoders + cache lib. Added npc spawn parser for the "nx_y" archive
This commit is contained in:
parent
c83268feab
commit
c75fa8e8c9
13 changed files with 86 additions and 182 deletions
46
src/main/kotlin/cacheops/cache/definition/decoder/MapTileDecoder.kt
vendored
Normal file
46
src/main/kotlin/cacheops/cache/definition/decoder/MapTileDecoder.kt
vendored
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
package cacheops.cache.definition.decoder
|
||||
|
||||
import cacheops.cache.definition.data.MapDefinition
|
||||
import cacheops.cache.definition.data.MapTile
|
||||
import ext.unsignedByte
|
||||
import java.nio.ByteBuffer
|
||||
|
||||
class MapTileDecoder {
|
||||
|
||||
fun readLoop(definition: MapDefinition, buffer: ByteBuffer) {
|
||||
for (plane in 0 until 4) {
|
||||
for (localX in 0 until 64) {
|
||||
for (localY in 0 until 64) {
|
||||
var height = 0
|
||||
var attrOpcode = 0
|
||||
var overlayPath = 0
|
||||
var overlayRotation = 0
|
||||
var overlayId = 0
|
||||
var settings = 0
|
||||
var underlayId = 0
|
||||
loop@ while (true) {
|
||||
val config = buffer.unsignedByte()
|
||||
if (config == 0) {
|
||||
break@loop
|
||||
} else if (config == 1) {
|
||||
height = buffer.unsignedByte()
|
||||
break@loop
|
||||
} else if (config <= 49) {
|
||||
attrOpcode = config
|
||||
overlayId = buffer.unsignedByte()
|
||||
overlayPath = (config - 2) / 4
|
||||
overlayRotation = 3 and (config - 2)
|
||||
} else if (config <= 81) {
|
||||
settings = config - 49
|
||||
} else {
|
||||
underlayId = (config - 81) and 0xff
|
||||
}
|
||||
}
|
||||
if (height != 0 || attrOpcode != 0 || overlayPath != 0 || overlayRotation != 0 || overlayId != 0 || settings != 0 || underlayId != 0) {
|
||||
definition.setTile(localX, localY, plane, MapTile(height, attrOpcode, overlayId, overlayPath, overlayRotation, settings, underlayId))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue