mirror of
https://gitlab.com/2009scape/tools/2009scape-map-viewer.git
synced 2026-08-01 14:39:25 -06:00
YEEEEEEEEEEEEEEEEEEEEEEEEEEEEEET IT WORKIES BOIIII
This commit is contained in:
parent
1a14bd7dbc
commit
687899fd0c
9 changed files with 101 additions and 14 deletions
|
|
@ -5,7 +5,7 @@ import cacheops.cache.definition.decoder.FloorUnderlayConfiguration
|
|||
import cacheops.cache.definition.decoder.MapTileParser
|
||||
import cacheops.cache.definition.decoder.NPC
|
||||
import cacheops.cache.definition.decoder.NPCSpawnParser
|
||||
import cacheops.cache.definition.encoder.MapTileWriter
|
||||
import cacheops.cache.definition.encoder.NPCSpawnEncoder
|
||||
import com.displee.cache.CacheLibrary
|
||||
import com.formdev.flatlaf.FlatDarculaLaf
|
||||
import const.Image.YELLOW_DOT
|
||||
|
|
@ -13,15 +13,14 @@ import java.awt.*
|
|||
import java.awt.event.KeyEvent
|
||||
import java.awt.event.MouseAdapter
|
||||
import java.awt.event.MouseEvent
|
||||
import java.lang.StringBuilder
|
||||
import javax.swing.*
|
||||
import javax.swing.border.*
|
||||
import kotlin.system.exitProcess
|
||||
|
||||
object Rs2MapEditor {
|
||||
|
||||
val library = CacheLibrary.create("/home/ceikry/IdeaProjects/rs09-remake/Server/data/cache/")
|
||||
var region = 7474 // Lumbridge
|
||||
val library = CacheLibrary.create("K:\\RSPSDev\\2-009Scape-578\\Server\\data\\cache")
|
||||
var region = 12853
|
||||
var npcs = NPCSpawnParser.parseNPCSpawns(region)
|
||||
val npcRows = ArrayList<NPCSpawnPanel.NPCRow>()
|
||||
lateinit var mapPanel: MapPane
|
||||
|
|
@ -504,7 +503,9 @@ object Rs2MapEditor {
|
|||
add(label)
|
||||
addActionListener {
|
||||
println("User attempting to commit")
|
||||
MapTileWriter.replaceValues()
|
||||
// TODO: DISABLED FOR NOW
|
||||
//MapTileWriter.replaceValues()
|
||||
NPCSpawnEncoder.write(npcs)
|
||||
println("Wrote data to the cache!")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
19
src/main/kotlin/cacheops/cache/definition/data/AtmosphereDefinition.kt
vendored
Normal file
19
src/main/kotlin/cacheops/cache/definition/data/AtmosphereDefinition.kt
vendored
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
package cacheops.cache.definition.data
|
||||
|
||||
import cacheops.cache.Definition
|
||||
import ext.Vector3f
|
||||
|
||||
//TODO: Maybe finish and come back who knows.
|
||||
data class AtmosphereDefinition(
|
||||
override var id: Int = -1,
|
||||
val DEFAULT_SKY_COLOR: Int = 0x17c439a8,
|
||||
val DEFAULT_SUN_COLOR: Int = 0x36dac459,
|
||||
val DEFAULT_SUN_X_POSITION: Float = 0.69921875F,
|
||||
val DEFAULT_SUN_Y_POSITION: Float = 1.2F,
|
||||
val DEFAULT_SUN_X_ANGLE: Int = -50,
|
||||
val DEFAULT_SUN_Y_ANGLE: Int = -60,
|
||||
val DEFAULT_SUN_Z_ANGLE: Int = -50,
|
||||
val DEFAULT_SUN_ANGLE: Vector3f = Vector3f(DEFAULT_SUN_X_ANGLE.toFloat(), DEFAULT_SUN_Y_ANGLE.toFloat(), DEFAULT_SUN_Z_ANGLE.toFloat()),
|
||||
val DEFAULT_SUN_SHININESS: Float = 1.1523438F,
|
||||
|
||||
) : Definition
|
||||
7
src/main/kotlin/cacheops/cache/definition/decoder/AtmosphereDecoder.kt
vendored
Normal file
7
src/main/kotlin/cacheops/cache/definition/decoder/AtmosphereDecoder.kt
vendored
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
package cacheops.cache.definition.decoder
|
||||
|
||||
class AtmosphereDecoder {
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -7,7 +7,7 @@ import java.nio.ByteBuffer
|
|||
|
||||
class MapTileDecoder {
|
||||
|
||||
fun readLoop(definition: MapDefinition, buffer: ByteBuffer) {
|
||||
fun readLoop(definition: MapDefinition, buffer: ByteBuffer): ByteArray {
|
||||
for (plane in 0 until 4) {
|
||||
for (localX in 0 until 64) {
|
||||
for (localY in 0 until 64) {
|
||||
|
|
@ -42,5 +42,6 @@ class MapTileDecoder {
|
|||
}
|
||||
}
|
||||
}
|
||||
return buffer.array().copyOfRange(buffer.position(), buffer.capacity())
|
||||
}
|
||||
}
|
||||
|
|
@ -8,6 +8,8 @@ object MapTileParser {
|
|||
|
||||
val definition = MapDefinition()
|
||||
|
||||
lateinit var atmosphereDataTail: ByteArray
|
||||
|
||||
@JvmStatic
|
||||
fun main(args: Array<String>) {
|
||||
|
||||
|
|
@ -35,8 +37,8 @@ object MapTileParser {
|
|||
val x = (region shr 8) and 0xFF
|
||||
val y = region and 0xFF
|
||||
val mapData = Rs2MapEditor.library.data(5,"m${x}_${y}")
|
||||
|
||||
MapTileDecoder().readLoop(definition, ByteBuffer.wrap(mapData))
|
||||
println(mapData!!.size)
|
||||
atmosphereDataTail = MapTileDecoder().readLoop(definition, ByteBuffer.wrap(mapData))
|
||||
}
|
||||
|
||||
fun coordinateX(x: Int): Int {
|
||||
|
|
|
|||
|
|
@ -11,12 +11,11 @@ object MapTileWriter {
|
|||
val x = (region shr 8) and 0xFF
|
||||
val y = region and 0xFF
|
||||
|
||||
//TODO: PACK ATMOSPHERE DATA ON THE END!! THE UNDERLAY DECODER ON THE CLIENT NEEDS THE ATMOSPHERE DATA
|
||||
|
||||
// val data = MapTileEncoder().write(MapTileParser.definition)
|
||||
|
||||
// if (data != null || dataSize < 50000) {
|
||||
// Rs2MapEditor.library.put(Indices.LANDSCAPES, "m${x}_${y}", mergedData)
|
||||
// val combinedData = data.plus(MapTileParser.atmosphereDataTail)
|
||||
//
|
||||
// if (data != null) {
|
||||
// Rs2MapEditor.library.put(Indices.LANDSCAPES, "m${x}_${y}", combinedData)
|
||||
// Rs2MapEditor.library.update()
|
||||
// } else {
|
||||
// System.err.println("Something went VERY wrong!")
|
||||
|
|
|
|||
34
src/main/kotlin/cacheops/cache/definition/encoder/NPCSpawnEncoder.kt
vendored
Normal file
34
src/main/kotlin/cacheops/cache/definition/encoder/NPCSpawnEncoder.kt
vendored
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
package cacheops.cache.definition.encoder
|
||||
|
||||
import Rs2MapEditor
|
||||
import cacheops.cache.definition.decoder.NPC
|
||||
import const.Indices
|
||||
import java.nio.ByteBuffer
|
||||
|
||||
object NPCSpawnEncoder {
|
||||
|
||||
fun write(npc: ArrayList<NPC>) {
|
||||
val buffer = ByteBuffer.allocate(10000)
|
||||
|
||||
npc.forEach {
|
||||
val formattedCoord = ((it.y or (it.x shl 7)) or (it.plane shl 14))
|
||||
buffer.putShort(formattedCoord.toShort())
|
||||
buffer.putShort(it.id.toShort())
|
||||
}
|
||||
|
||||
val dataArray = buffer.array().copyOf(buffer.position())
|
||||
|
||||
val region = Rs2MapEditor.region
|
||||
val baseX = ((region shr 8) shl 6)
|
||||
val baseY = ((region and 0xFF) shl 6)
|
||||
val x = (region shr 8) and 0xFF
|
||||
val y = region and 0xFF
|
||||
|
||||
if (dataArray != null) {
|
||||
Rs2MapEditor.library.put(Indices.LANDSCAPES, "n${x}_${y}", dataArray, intArrayOf(0,0,0,0))
|
||||
Rs2MapEditor.library.update()
|
||||
} else {
|
||||
System.err.println("Panic! Something went VERY wrong!")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -3,4 +3,4 @@ package const
|
|||
import cacheops.cache.Cache
|
||||
import cacheops.cache.CacheDelegate
|
||||
|
||||
val cache: Cache = CacheDelegate("/home/ceikry/IdeaProjects/rs09-remake/Server/data/cache/")
|
||||
val cache: Cache = CacheDelegate("K:\\RSPSDev\\2-009Scape-578\\Server\\data\\cache")
|
||||
|
|
|
|||
24
src/main/kotlin/ext/Vector3f.kt
Normal file
24
src/main/kotlin/ext/Vector3f.kt
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
package ext
|
||||
|
||||
class Vector3f(var x: Float, var y: Float, var z: Float) {
|
||||
|
||||
override fun hashCode(): Int {
|
||||
var result = x.hashCode()
|
||||
result = 31 * result + y.hashCode()
|
||||
result = 31 * result + z.hashCode()
|
||||
return result
|
||||
}
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
if (javaClass != other?.javaClass) return false
|
||||
|
||||
other as Vector3f
|
||||
|
||||
if (x != other.x) return false
|
||||
if (y != other.y) return false
|
||||
if (z != other.z) return false
|
||||
|
||||
return true
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue