diff --git a/build.gradle.kts b/build.gradle.kts index c98d12279..06f592886 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -17,7 +17,7 @@ allprojects { apply(plugin = "org.jetbrains.kotlin.jvm") group = "world.gregs.void" - version = "1.1.0" + version = "1.1.1" java.sourceCompatibility = JavaVersion.VERSION_19 java.targetCompatibility = java.sourceCompatibility diff --git a/cache/src/main/kotlin/world/gregs/voidps/cache/compress/BZIP2Compressor.kt b/cache/src/main/kotlin/world/gregs/voidps/cache/compress/BZIP2Compressor.kt index 1d4b241f3..4a2c56d70 100644 --- a/cache/src/main/kotlin/world/gregs/voidps/cache/compress/BZIP2Compressor.kt +++ b/cache/src/main/kotlin/world/gregs/voidps/cache/compress/BZIP2Compressor.kt @@ -68,10 +68,10 @@ internal class BZIP2Compressor { * Decompress a BZIP2 block entry. */ private fun decompress() { - var i = 0 - var intArray1 = IntArray(0) - var intArray2 = IntArray(0) - var intArray3 = IntArray(0) + var i: Int + var intArray1: IntArray + var intArray2: IntArray + var intArray3: IntArray var bool28 = true while (bool28) { var i29 = method152(8) @@ -113,9 +113,9 @@ internal class BZIP2Compressor { } } var anInt3073 = 0 - for (i in 0..255) { - if (aBooleanArray3103[i]) { - aByteArray3107[anInt3073] = i.toByte() + for (j in 0..255) { + if (aBooleanArray3103[j]) { + aByteArray3107[anInt3073] = j.toByte() anInt3073++ } } @@ -187,7 +187,7 @@ internal class BZIP2Compressor { } val i52 = anInt3073 + 1 var i53 = 0 - var i54 = 0 + var i54: Int for (i55 in 0..255) { anIntArray3075[i55] = 0 } @@ -231,11 +231,11 @@ internal class BZIP2Compressor { if (i54 == 0) { i53++ i54 = 50 - val index = aByteArray3076[i53] - i = anIntArray3090[index.toInt()] - intArray1 = anIntArrayArray3095[index.toInt()] - intArray3 = anIntArrayArray3099[index.toInt()] - intArray2 = anIntArrayArray3082[index.toInt()] + val index2 = aByteArray3076[i53] + i = anIntArray3090[index2.toInt()] + intArray1 = anIntArrayArray3095[index2.toInt()] + intArray3 = anIntArrayArray3099[index2.toInt()] + intArray2 = anIntArrayArray3082[index2.toInt()] } i54-- i61 = i @@ -353,9 +353,9 @@ internal class BZIP2Compressor { private fun method152(arg0: Int): Int { while (true) { if (anInt3088 >= arg0) { - val i_93_ = anInt3078 shr anInt3088 - arg0 and (1 shl arg0) - 1 + val i93 = anInt3078 shr anInt3088 - arg0 and (1 shl arg0) - 1 anInt3088 -= arg0 - return i_93_ + return i93 } anInt3078 = anInt3078 shl 8 or (compressed[startOffset].toInt() and 0xff) anInt3088 += 8 @@ -366,111 +366,111 @@ internal class BZIP2Compressor { private fun method151() { var i = aByte3108 - var i_81_ = anInt3080 - var i_82_ = anInt3071 - var i_83_ = anInt3070 + var i81 = anInt3080 + var i82 = anInt3071 + var i83 = anInt3070 val data = anIntArray5786 - var i_84_ = anInt3106 - val is_85_ = decompressed - var i_86_ = anInt3100 - var i_87_ = decompressedLength - val i_88_ = i_87_ - val i_89_ = anInt3077 + 1 + var i84 = anInt3106 + val decompressed = decompressed + var i86 = anInt3100 + var length = decompressedLength + val i88 = length + val i89 = anInt3077 + 1 while_68_@ while (true) { - if (i_81_ > 0) { + if (i81 > 0) { while (true) { - if (i_87_ == 0) { + if (length == 0) { break@while_68_ } - if (i_81_ == 1) { + if (i81 == 1) { break } - is_85_[i_86_] = i - i_81_-- - i_86_++ - i_87_-- + decompressed[i86] = i + i81-- + i86++ + length-- } - if (i_87_ == 0) { - i_81_ = 1 + if (length == 0) { + i81 = 1 break } - is_85_[i_86_] = i - i_86_++ - i_87_-- + decompressed[i86] = i + i86++ + length-- } var bool = true while (bool) { bool = false - if (i_82_ == i_89_) { - i_81_ = 0 + if (i82 == i89) { + i81 = 0 break@while_68_ } - i = i_83_.toByte() - i_84_ = data[i_84_] - val i_90_ = (i_84_ and 0xff).toByte().toInt() - i_84_ = i_84_ shr 8 - i_82_++ - if (i_90_ != i_83_) { - i_83_ = i_90_ - if (i_87_ == 0) { - i_81_ = 1 + i = i83.toByte() + i84 = data[i84] + val i90 = (i84 and 0xff).toByte().toInt() + i84 = i84 shr 8 + i82++ + if (i90 != i83) { + i83 = i90 + if (length == 0) { + i81 = 1 break@while_68_ } - is_85_[i_86_] = i - i_86_++ - i_87_-- + decompressed[i86] = i + i86++ + length-- bool = true - } else if (i_82_ == i_89_) { - if (i_87_ == 0) { - i_81_ = 1 + } else if (i82 == i89) { + if (length == 0) { + i81 = 1 break@while_68_ } - is_85_[i_86_] = i - i_86_++ - i_87_-- + decompressed[i86] = i + i86++ + length-- bool = true } } - i_81_ = 2 - i_84_ = data[i_84_] - var i_91_ = (i_84_ and 0xff).toByte().toInt() - i_84_ = i_84_ shr 8 - if (++i_82_ != i_89_) { - if (i_91_ != i_83_) { - i_83_ = i_91_ + i81 = 2 + i84 = data[i84] + var i91 = (i84 and 0xff).toByte().toInt() + i84 = i84 shr 8 + if (++i82 != i89) { + if (i91 != i83) { + i83 = i91 } else { - i_81_ = 3 - i_84_ = data[i_84_] - i_91_ = (i_84_ and 0xff).toByte().toInt() - i_84_ = i_84_ shr 8 - if (++i_82_ != i_89_) { - if (i_91_ != i_83_) { - i_83_ = i_91_ + i81 = 3 + i84 = data[i84] + i91 = (i84 and 0xff).toByte().toInt() + i84 = i84 shr 8 + if (++i82 != i89) { + if (i91 != i83) { + i83 = i91 } else { - i_84_ = data[i_84_] - i_91_ = (i_84_ and 0xff).toByte().toInt() - i_84_ = i_84_ shr 8 - i_82_++ - i_81_ = (i_91_ and 0xff) + 4 - i_84_ = data[i_84_] - i_83_ = (i_84_ and 0xff).toByte().toInt() - i_84_ = i_84_ shr 8 - i_82_++ + i84 = data[i84] + i91 = (i84 and 0xff).toByte().toInt() + i84 = i84 shr 8 + i82++ + i81 = (i91 and 0xff) + 4 + i84 = data[i84] + i83 = (i84 and 0xff).toByte().toInt() + i84 = i84 shr 8 + i82++ } } } } } - anInt3097 += i_88_ - i_87_ + anInt3097 += i88 - length aByte3108 = i - anInt3080 = i_81_ - anInt3071 = i_82_ - anInt3070 = i_83_ + anInt3080 = i81 + anInt3071 = i82 + anInt3070 = i83 anIntArray5786 = data - anInt3106 = i_84_ - decompressed = is_85_ - anInt3100 = i_86_ - decompressedLength = i_87_ + anInt3106 = i84 + this.decompressed = decompressed + anInt3100 = i86 + decompressedLength = length } private fun method145(arg0: IntArray, arg1: IntArray, arg2: IntArray, arg3: ByteArray, arg4: Int, arg5: Int, arg6: Int) { diff --git a/cache/src/main/kotlin/world/gregs/voidps/cache/definition/data/QuickChatType.kt b/cache/src/main/kotlin/world/gregs/voidps/cache/definition/data/QuickChatType.kt index cfc59c7b1..90321523b 100644 --- a/cache/src/main/kotlin/world/gregs/voidps/cache/definition/data/QuickChatType.kt +++ b/cache/src/main/kotlin/world/gregs/voidps/cache/definition/data/QuickChatType.kt @@ -18,10 +18,8 @@ enum class QuickChatType(var id: Int, var bitCount: Int, var length: Int) { CombatLevel(15, 0, 0); companion object { - private val types = values() - fun getType(id: Int): QuickChatType? { - return types.firstOrNull { it.id == id } + return entries.firstOrNull { it.id == id } } } } \ No newline at end of file diff --git a/cache/src/main/kotlin/world/gregs/voidps/cache/definition/decoder/ClientScriptDecoder.kt b/cache/src/main/kotlin/world/gregs/voidps/cache/definition/decoder/ClientScriptDecoder.kt index 312165264..cdbc4aeb2 100644 --- a/cache/src/main/kotlin/world/gregs/voidps/cache/definition/decoder/ClientScriptDecoder.kt +++ b/cache/src/main/kotlin/world/gregs/voidps/cache/definition/decoder/ClientScriptDecoder.kt @@ -37,8 +37,8 @@ class ClientScriptDecoder(private val revision667: Boolean = false) : Definition override fun ClientScriptDefinition.read(opcode: Int, buffer: Reader) { buffer.position(buffer.length - 2) - val i = buffer.readShort() - val length: Int = buffer.length - 2 - i - (if (revision667) 16 else 12) + val offset = buffer.readShort() + val length: Int = buffer.length - 2 - offset - (if (revision667) 16 else 12) buffer.position(length) val instructionCount = buffer.readInt() intVariableCount = buffer.readShort() diff --git a/cache/src/main/kotlin/world/gregs/voidps/cache/definition/encoder/InterfaceEncoder.kt b/cache/src/main/kotlin/world/gregs/voidps/cache/definition/encoder/InterfaceEncoder.kt index 9e89ee8a3..116d651f1 100644 --- a/cache/src/main/kotlin/world/gregs/voidps/cache/definition/encoder/InterfaceEncoder.kt +++ b/cache/src/main/kotlin/world/gregs/voidps/cache/definition/encoder/InterfaceEncoder.kt @@ -28,11 +28,11 @@ class InterfaceEncoder : DefinitionEncoder { writeByte(definition.verticalPositionMode.toInt()) writeShort(definition.parent) - var flag = 0 + var hiddenFlag = 0 if (definition.hidden) { - flag = flag or 0x1 + hiddenFlag = hiddenFlag or 0x1 } - writeByte(flag) + writeByte(hiddenFlag) when (definition.type) { 0 -> { @@ -58,14 +58,14 @@ class InterfaceEncoder : DefinitionEncoder { 5 -> { writeInt(definition.defaultImage) writeShort(definition.imageRotation) - var flag = 0 + var imageFlag = 0 if (definition.aBoolean4861) { - flag = flag or 0x1 + imageFlag = imageFlag or 0x1 } if (definition.imageRepeat) { - flag = flag or 0x2 + imageFlag = imageFlag or 0x2 } - writeByte(flag) + writeByte(imageFlag) writeByte(definition.alpha) writeByte(definition.rotation) writeInt(definition.backgroundColour) @@ -121,7 +121,7 @@ class InterfaceEncoder : DefinitionEncoder { } writeMedium(definition.setting.setting) - var startOffset = 0 + var startOffset: Int val keyRepeat = definition.keyRepeats val keyCodes = definition.keyCodes val keyModifiers = definition.keyModifiers diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/Contexts.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/Contexts.kt index 8a4772996..c830015bc 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/Contexts.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/Contexts.kt @@ -1,7 +1,10 @@ package world.gregs.voidps.engine +import kotlinx.coroutines.DelicateCoroutinesApi +import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.newSingleThreadContext +@OptIn(ExperimentalCoroutinesApi::class, DelicateCoroutinesApi::class) object Contexts { val Game = newSingleThreadContext("Game loop") } \ No newline at end of file diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/client/instruction/InstructionTask.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/client/instruction/InstructionTask.kt index a888a8b9c..ba836516e 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/client/instruction/InstructionTask.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/client/instruction/InstructionTask.kt @@ -1,6 +1,7 @@ package world.gregs.voidps.engine.client.instruction import com.github.michaelbull.logging.InlineLogger +import kotlinx.coroutines.ExperimentalCoroutinesApi import world.gregs.voidps.engine.data.definition.InterfaceDefinitions import world.gregs.voidps.engine.data.definition.ItemDefinitions import world.gregs.voidps.engine.data.definition.NPCDefinitions @@ -35,6 +36,7 @@ class InstructionTask( handler ) + @OptIn(ExperimentalCoroutinesApi::class) override fun run() { players.forEach { player -> val instructions = player.instructions diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/client/update/NPCTask.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/client/update/NPCTask.kt index 10bdca36a..d94bb55c5 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/client/update/NPCTask.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/client/update/NPCTask.kt @@ -14,18 +14,18 @@ class NPCTask( override val characters: CharacterList ) : CharacterTask(iterator) { - override fun run(npc: NPC) { - val delay = npc.delay - if (!npc.hasClock("delay") && delay != null) { - npc.delay = null + override fun run(character: NPC) { + val delay = character.delay + if (!character.hasClock("delay") && delay != null) { + character.delay = null delay.resume(Unit) } - if (npc.mode == EmptyMode && wanders(npc)) { - npc.mode = Wander(npc) + if (character.mode == EmptyMode && wanders(character)) { + character.mode = Wander(character) } - npc.softTimers.run() - npc.queue.tick() - npc.mode.tick() - checkTileFacing(npc) + character.softTimers.run() + character.queue.tick() + character.mode.tick() + checkTileFacing(character) } } \ No newline at end of file diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/client/update/PlayerTask.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/client/update/PlayerTask.kt index db44ec0b9..6d1ec5b49 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/client/update/PlayerTask.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/client/update/PlayerTask.kt @@ -12,18 +12,18 @@ class PlayerTask( override val characters: CharacterList ) : CharacterTask(iterator) { - override fun run(player: Player) { - val delay = player.delay - if (!player.hasClock("delay") && delay != null) { - player.delay = null + override fun run(character: Player) { + val delay = character.delay + if (!character.hasClock("delay") && delay != null) { + character.delay = null delay.resume(Unit) } - player.queue.tick() - if (!player.hasClock("delay") && !player.hasMenuOpen()) { - player.timers.run() + character.queue.tick() + if (!character.hasClock("delay") && !character.hasMenuOpen()) { + character.timers.run() } - player.softTimers.run() - player.mode.tick() - checkTileFacing(player) + character.softTimers.run() + character.mode.tick() + checkTileFacing(character) } } \ No newline at end of file diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/client/update/npc/NPCUpdateTask.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/client/update/npc/NPCUpdateTask.kt index 0e4198ddc..850edb09b 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/client/update/npc/NPCUpdateTask.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/client/update/npc/NPCUpdateTask.kt @@ -4,14 +4,14 @@ import it.unimi.dsi.fastutil.ints.IntSet import world.gregs.voidps.buffer.write.Writer import world.gregs.voidps.engine.client.update.view.Viewport import world.gregs.voidps.engine.client.update.view.Viewport.Companion.LOCAL_NPC_CAP -import world.gregs.voidps.type.Direction import world.gregs.voidps.engine.entity.character.npc.NPC import world.gregs.voidps.engine.entity.character.npc.NPCs import world.gregs.voidps.engine.entity.character.player.Player -import world.gregs.voidps.type.RegionLevel import world.gregs.voidps.network.encode.updateNPCs import world.gregs.voidps.network.visual.NPCVisuals import world.gregs.voidps.network.visual.VisualEncoder +import world.gregs.voidps.type.Direction +import world.gregs.voidps.type.RegionLevel class NPCUpdateTask( private val npcs: NPCs, @@ -183,14 +183,14 @@ class NPCUpdateTask( } private sealed class LocalChange(val id: Int) { - object None : LocalChange(-1) - object Update : LocalChange(0) + data object None : LocalChange(-1) + data object Update : LocalChange(0) sealed class Move(id: Int) : LocalChange(id) - object Walk : Move(1) - object Crawl : Move(2) - object Run : Move(2) - object Tele : LocalChange(3) - object Remove : LocalChange(3) + data object Walk : Move(1) + data object Crawl : Move(2) + data object Run : Move(2) + data object Tele : LocalChange(3) + data object Remove : LocalChange(3) } companion object { diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/client/update/player/PlayerUpdateTask.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/client/update/player/PlayerUpdateTask.kt index 89ad2de82..7c2fc54dd 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/client/update/player/PlayerUpdateTask.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/client/update/player/PlayerUpdateTask.kt @@ -5,11 +5,11 @@ import world.gregs.voidps.engine.client.update.view.PlayerTrackingSet import world.gregs.voidps.engine.client.update.view.Viewport import world.gregs.voidps.engine.entity.character.CharacterList import world.gregs.voidps.engine.entity.character.player.Player -import world.gregs.voidps.type.Delta import world.gregs.voidps.network.encode.updatePlayers import world.gregs.voidps.network.visual.PlayerVisuals import world.gregs.voidps.network.visual.VisualEncoder import world.gregs.voidps.network.visual.VisualMask.APPEARANCE_MASK +import world.gregs.voidps.type.Delta import kotlin.math.abs class PlayerUpdateTask( @@ -302,19 +302,19 @@ class PlayerUpdateTask( } private sealed class LocalChange(val id: Int) { - object None : LocalChange(-1) - object Update : LocalChange(0) - object Remove : LocalChange(0) - object Walk : LocalChange(1) - object Run : LocalChange(2) - object Tele : LocalChange(3) + data object None : LocalChange(-1) + data object Update : LocalChange(0) + data object Remove : LocalChange(0) + data object Walk : LocalChange(1) + data object Run : LocalChange(2) + data object Tele : LocalChange(3) } sealed class RegionChange(val id: Int) { - object None : RegionChange(-1) - object Height : RegionChange(1) - object Local : RegionChange(2) - object Global : RegionChange(3) + data object None : RegionChange(-1) + data object Height : RegionChange(1) + data object Local : RegionChange(2) + data object Global : RegionChange(3) } companion object { diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/client/variable/VariableValues.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/client/variable/VariableValues.kt index f3caf55c7..9b2380cf9 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/client/variable/VariableValues.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/client/variable/VariableValues.kt @@ -28,27 +28,27 @@ sealed class VariableValues { } } -object NoValues : VariableValues() { +data object NoValues : VariableValues() { override fun default() = null override fun toInt(value: Any) = value as? Int ?: -1 } -object IntValues : VariableValues() { +data object IntValues : VariableValues() { override fun default() = 0 override fun toInt(value: Any) = value as Int } -object StringValues : VariableValues() { +data object StringValues : VariableValues() { override fun default() = "" override fun toInt(value: Any) = -1 } -object DoubleValues : VariableValues() { +data object DoubleValues : VariableValues() { override fun default() = 0.0 override fun toInt(value: Any) = (value as Double).toInt() * 10 } -object BooleanValues : VariableValues() { +data object BooleanValues : VariableValues() { override fun default() = false override fun toInt(value: Any) = (value as Boolean).toInt() } diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/AreaDefinition.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/AreaDefinition.kt index 7b0eed883..2ff4396b9 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/AreaDefinition.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/AreaDefinition.kt @@ -14,6 +14,7 @@ data class AreaDefinition( companion object { val EMPTY = AreaDefinition("", Rectangle(0, 0, 0, 0), emptySet()) + @Suppress("UNCHECKED_CAST") fun fromMap(name: String, map: MutableMap): AreaDefinition { return AreaDefinition( name = name, diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/data/Smelting.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/data/Smelting.kt index acbb6d819..4b62b645f 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/data/Smelting.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/data/Smelting.kt @@ -14,6 +14,7 @@ data class Smelting( val message: String = "" ) { companion object { + @Suppress("UNCHECKED_CAST") operator fun invoke(map: Map) = Smelting( level = map["level"] as Int, xp = map["xp"] as Double, diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/entity/character/npc/NPCMoveType.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/entity/character/npc/NPCMoveType.kt index 21bade15d..24b615006 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/entity/character/npc/NPCMoveType.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/entity/character/npc/NPCMoveType.kt @@ -1,9 +1,9 @@ package world.gregs.voidps.engine.entity.character.npc sealed class NPCMoveType { - object None : NPCMoveType() - object Crawl : NPCMoveType() - object Walk : NPCMoveType() - object Run : NPCMoveType() - object Teleport : NPCMoveType() + data object None : NPCMoveType() + data object Crawl : NPCMoveType() + data object Walk : NPCMoveType() + data object Run : NPCMoveType() + data object Teleport : NPCMoveType() } \ No newline at end of file diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/entity/character/npc/hunt/Hunting.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/entity/character/npc/hunt/Hunting.kt index d45bfcc92..0bb827809 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/entity/character/npc/hunt/Hunting.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/entity/character/npc/hunt/Hunting.kt @@ -186,7 +186,6 @@ class Hunting( /** * Checks if [character] meets all the [definition] requirements */ - @Suppress("RedundantIf") private fun canHunt( npc: NPC, character: Character, diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/entity/character/player/chat/clan/ClanRank.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/entity/character/player/chat/clan/ClanRank.kt index 0f8d6542f..55c0b5a44 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/entity/character/player/chat/clan/ClanRank.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/entity/character/player/chat/clan/ClanRank.kt @@ -14,10 +14,8 @@ enum class ClanRank(val value: Int, val string: String) { Admin(127, ""); companion object { - val all = values() - fun of(option: String) : ClanRank { - return all.firstOrNull { it.string == option } ?: None + return entries.firstOrNull { it.string == option } ?: None } } } \ No newline at end of file diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/entity/character/player/equip/BodyParts.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/entity/character/player/equip/BodyParts.kt index 765b18dac..f58873765 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/entity/character/player/equip/BodyParts.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/entity/character/player/equip/BodyParts.kt @@ -24,7 +24,7 @@ data class BodyParts( } fun updateAll() { - BodyPart.all.forEach { + BodyPart.entries.forEach { updateConnected(it) } } diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/entity/character/player/skill/Skill.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/entity/character/player/skill/Skill.kt index 267a2c9cc..dabfa4a77 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/entity/character/player/skill/Skill.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/entity/character/player/skill/Skill.kt @@ -30,7 +30,7 @@ enum class Skill { fun maximum(): Int = if (this == Dungeoneering) 120 else if (this == Constitution) 990 else 99 companion object { - val all = values() + val all = entries.toTypedArray() val count = all.size } } \ No newline at end of file diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/entity/item/drop/TableType.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/entity/item/drop/TableType.kt index dc3abed35..55ac60bc5 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/entity/item/drop/TableType.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/entity/item/drop/TableType.kt @@ -11,6 +11,6 @@ enum class TableType { All; companion object { - fun byName(name: String) = values().first { it.name.lowercase() == name } + fun byName(name: String) = entries.first { it.name.lowercase() == name } } } \ No newline at end of file diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/inv/transact/TransactionError.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/inv/transact/TransactionError.kt index b8e58928b..8ead2e704 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/inv/transact/TransactionError.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/inv/transact/TransactionError.kt @@ -8,7 +8,7 @@ sealed class TransactionError { * An error indicating that an invalid item was encountered during the transaction. * Common reasons being index out of bounds or item restriction */ - object Invalid : TransactionError() + data object Invalid : TransactionError() /** * An error indicating that the inventory is full and cannot accept any more items. @@ -25,5 +25,5 @@ sealed class TransactionError { /** * The transaction completed without error or is no longer in progress. */ - object None : TransactionError() + data object None : TransactionError() } \ No newline at end of file diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/queue/ActionQueue.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/queue/ActionQueue.kt index 0e885db97..de1e39b67 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/queue/ActionQueue.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/queue/ActionQueue.kt @@ -65,8 +65,8 @@ class ActionQueue(private val character: Character) : CoroutineScope { } } - fun clear(name: String) { - val removed = queue.removeIf { + fun clear(name: String): Boolean { + return queue.removeIf { it.name == name } } diff --git a/engine/src/test/kotlin/world/gregs/voidps/engine/client/variable/VariablesTest.kt b/engine/src/test/kotlin/world/gregs/voidps/engine/client/variable/VariablesTest.kt index 9938c3975..8e722ee07 100644 --- a/engine/src/test/kotlin/world/gregs/voidps/engine/client/variable/VariablesTest.kt +++ b/engine/src/test/kotlin/world/gregs/voidps/engine/client/variable/VariablesTest.kt @@ -45,8 +45,8 @@ internal class VariablesTest { every { player.variables } returns variables every { player.events } returns events every { definitions.get(key) } returns variable - (variables as PlayerVariables).definitions = definitions - (variables as PlayerVariables).client = client + variables.definitions = definitions + variables.client = client } @Test diff --git a/engine/src/test/kotlin/world/gregs/voidps/engine/entity/character/player/req/RequestTest.kt b/engine/src/test/kotlin/world/gregs/voidps/engine/entity/character/player/req/RequestTest.kt index 32a0a3512..f96aa0f71 100644 --- a/engine/src/test/kotlin/world/gregs/voidps/engine/entity/character/player/req/RequestTest.kt +++ b/engine/src/test/kotlin/world/gregs/voidps/engine/entity/character/player/req/RequestTest.kt @@ -21,20 +21,20 @@ internal class RequestTest { @Test fun `Player request`() { - val request: (Player, Player) -> Unit = { a, b -> } + val request: (Player, Player) -> Unit = { _, _ -> } assertTrue(player.request(player2, "trade", request)) } @Test fun `Has player requested`() { - val request: (Player, Player) -> Unit = { a, b -> } + val request: (Player, Player) -> Unit = { _, _ -> } player.request(player2, "trade", request) assertTrue(player.hasRequest(player2, "trade")) } @Test fun `Get request`() { - val request: (Player, Player) -> Unit = { a, b -> } + val request: (Player, Player) -> Unit = { _, _ -> } player.request(player2, "trade", request) assertTrue(player.hasRequest(player2, "trade")) assertFalse(player.hasRequest(player3, "trade")) @@ -43,7 +43,7 @@ internal class RequestTest { @Test fun `Remove request`() { - val request: (Player, Player) -> Unit = { a, b -> } + val request: (Player, Player) -> Unit = { _, _ -> } player.request(player2, "trade", request) player.removeRequest(player2, "trade") assertFalse(player.hasRequest(player3, "trade")) diff --git a/engine/src/test/kotlin/world/gregs/voidps/engine/event/EventsTest.kt b/engine/src/test/kotlin/world/gregs/voidps/engine/event/EventsTest.kt index 2d51d9bb8..d9d981907 100644 --- a/engine/src/test/kotlin/world/gregs/voidps/engine/event/EventsTest.kt +++ b/engine/src/test/kotlin/world/gregs/voidps/engine/event/EventsTest.kt @@ -8,6 +8,7 @@ import kotlin.test.assertTrue internal class EventsTest { @Test + @Suppress("UNCHECKED_CAST") fun `Cancelled events stops processing`() { val events = Events(mockk()) val event = object : CancellableEvent() {} diff --git a/game/build.gradle.kts b/game/build.gradle.kts index baa585b51..d13082d5c 100644 --- a/game/build.gradle.kts +++ b/game/build.gradle.kts @@ -110,4 +110,7 @@ distributions { from(layout.buildDirectory.dir("scripts/run-server.sh")) } } -} \ No newline at end of file +} + +tasks["bundleDistTar"].dependsOn("startScripts") +tasks["bundleDistZip"].dependsOn("startScripts") \ No newline at end of file diff --git a/game/src/main/kotlin/world/gregs/voidps/bot/WalkingBot.kts b/game/src/main/kotlin/world/gregs/voidps/bot/WalkingBot.kts index e653e58fc..d5ff5bae9 100644 --- a/game/src/main/kotlin/world/gregs/voidps/bot/WalkingBot.kts +++ b/game/src/main/kotlin/world/gregs/voidps/bot/WalkingBot.kts @@ -22,7 +22,7 @@ worldSpawn { spaces = Int.MAX_VALUE, requirements = emptyList() ) -// if (TaskManager.DEBUG) { -// tasks.register(task, true) -// } + if (TaskManager.DEBUG) { + tasks.register(task, true) + } } \ No newline at end of file diff --git a/game/src/main/kotlin/world/gregs/voidps/bot/navigation/graph/NavigationGraph.kt b/game/src/main/kotlin/world/gregs/voidps/bot/navigation/graph/NavigationGraph.kt index b0e48f053..d98162dd7 100644 --- a/game/src/main/kotlin/world/gregs/voidps/bot/navigation/graph/NavigationGraph.kt +++ b/game/src/main/kotlin/world/gregs/voidps/bot/navigation/graph/NavigationGraph.kt @@ -73,10 +73,10 @@ class NavigationGraph( } } val data: Map = yaml.load(path, config) - val edges = data["edges"] as Map + val edgeMap = data["edges"] as Map val map = Object2ObjectOpenHashMap>() var count = 0 - flatten("", edges) { path, edges -> + flatten("", edgeMap) { path, edges -> for (edge in edges) { count++ val start = edge["from"] as Tile @@ -115,6 +115,7 @@ class NavigationGraph( } } + @Suppress("UNCHECKED_CAST") private fun flatten(path: String, map: Map, process: (String, List>) -> Unit): List> { val list = mutableListOf>() for ((key, value) in map) { diff --git a/game/src/main/kotlin/world/gregs/voidps/bot/skill/combat/TrainingBot.kts b/game/src/main/kotlin/world/gregs/voidps/bot/skill/combat/TrainingBot.kts index 8daf85240..4dc8a4306 100644 --- a/game/src/main/kotlin/world/gregs/voidps/bot/skill/combat/TrainingBot.kts +++ b/game/src/main/kotlin/world/gregs/voidps/bot/skill/combat/TrainingBot.kts @@ -45,8 +45,8 @@ worldSpawn { val task = Task( name = "train ${if (melee) "melee" else skill.name} at ${area.name}".toLowerSpaceCase(), block = { - val skill = if (melee) melees.filter { player.levels.getMax(it) in range }.random() else skill - train(area, skill, range) + val actualSkill = if (melee) melees.filter { player.levels.getMax(it) in range }.random() else skill + train(area, actualSkill, range) }, area = area.area, spaces = if (melee) 3 else 2, diff --git a/game/src/main/kotlin/world/gregs/voidps/world/activity/skill/Stats.kts b/game/src/main/kotlin/world/gregs/voidps/world/activity/skill/Stats.kts index bcda2eed2..3306921f2 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/activity/skill/Stats.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/activity/skill/Stats.kts @@ -8,6 +8,7 @@ import world.gregs.voidps.engine.client.ui.interfaceOption import world.gregs.voidps.engine.client.ui.open import world.gregs.voidps.engine.data.definition.InterfaceDefinitions import world.gregs.voidps.engine.entity.character.player.Player +import world.gregs.voidps.engine.entity.character.player.skill.Skill import world.gregs.voidps.engine.entity.character.player.skill.Skill.* import world.gregs.voidps.engine.inject @@ -18,7 +19,7 @@ val menu = listOf(Attack, Strength, Ranged, Magic, Defence, Constitution, Prayer interfaceOpen("stats") { player: Player -> player.sendVariable("skill_stat_flash") - values().forEach { + Skill.entries.forEach { player.experience.update(it) } } diff --git a/game/src/main/kotlin/world/gregs/voidps/world/activity/transport/Canoes.kts b/game/src/main/kotlin/world/gregs/voidps/world/activity/transport/Canoes.kts index 973512752..587cbfcf3 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/activity/transport/Canoes.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/activity/transport/Canoes.kts @@ -34,8 +34,8 @@ interfaceOpen("canoe") { player: Player -> } } -interfaceOpen("canoe_stations_map") { player: Player -> +interfaceOpen("canoe_stations_map") { _: Player -> } -interfaceOpen("canoe_travel") { player: Player -> +interfaceOpen("canoe_travel") { _: Player -> } \ No newline at end of file diff --git a/game/src/main/kotlin/world/gregs/voidps/world/command/admin/AdminCommands.kts b/game/src/main/kotlin/world/gregs/voidps/world/command/admin/AdminCommands.kts index 346952020..d813e6f77 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/command/admin/AdminCommands.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/command/admin/AdminCommands.kts @@ -1,3 +1,5 @@ +@file:Suppress("UNCHECKED_CAST") + package world.gregs.voidps.world.command.admin import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap @@ -274,7 +276,7 @@ adminCommand("pray") { } adminCommand("restore") { - Skill.values().forEach { + Skill.entries.forEach { player.levels.clear(it) } } diff --git a/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/death/DeathPlayer.kts b/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/death/DeathPlayer.kts index 249936897..ba9ed7edd 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/death/DeathPlayer.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/death/DeathPlayer.kts @@ -1,3 +1,5 @@ +@file:Suppress("OPT_IN_USAGE") + package world.gregs.voidps.world.interact.entity.death import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap diff --git a/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/player/combat/armour/barrows/ToragsSet.kts b/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/player/combat/armour/barrows/ToragsSet.kts index 573597a38..cfe2f6fd5 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/player/combat/armour/barrows/ToragsSet.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/player/combat/armour/barrows/ToragsSet.kts @@ -36,7 +36,6 @@ characterCombatAttack { character: Character -> if (type != "melee" || damage <= 0 || target !is Player || !weapon.id.startsWith("torags_hammers") || !character.contains("torags_set_effect") || random.nextInt(4) != 0) { return@characterCombatAttack } - val target = target as Player if (target.runEnergy > 0) { target.runEnergy -= target.runEnergy / 5 target.setGraphic("torags_effect") diff --git a/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/player/combat/prayer/PrayerToggle.kts b/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/player/combat/prayer/PrayerToggle.kts index c298f2e79..cc211efb8 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/player/combat/prayer/PrayerToggle.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/player/combat/prayer/PrayerToggle.kts @@ -1,3 +1,5 @@ +@file:Suppress("UNCHECKED_CAST") + package world.gregs.voidps.world.interact.entity.player.combat.prayer import net.pearx.kasechange.toSnakeCase diff --git a/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/player/equip/ItemsKeptOnDeath.kt b/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/player/equip/ItemsKeptOnDeath.kt index 8a996ef61..e76efaec0 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/player/equip/ItemsKeptOnDeath.kt +++ b/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/player/equip/ItemsKeptOnDeath.kt @@ -26,21 +26,21 @@ object ItemsKeptOnDeath { if (items.isEmpty()) { return emptyList() } - val items = LinkedList(items) + val queue = LinkedList(items) val kept = mutableListOf() val alwaysLost = enums.get(616).map!! var count = 0 while (count < save) { - val item = items.peek() ?: break + val item = queue.peek() ?: break if (alwaysLost.getOrDefault(item.def.id, 0) == 1) { - items.pop() + queue.pop() continue } if (item.amount == 1) { - kept.add(items.pop()) + kept.add(queue.pop()) } else if (item.amount > 1) { - items.pop() - items.addFirst(item.copy(amount = item.amount - 1)) + queue.pop() + queue.addFirst(item.copy(amount = item.amount - 1)) kept.add(item.copy(amount = 1)) } count++ diff --git a/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/player/music/MusicUnlock.kt b/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/player/music/MusicUnlock.kt index 3edff99b0..504af8287 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/player/music/MusicUnlock.kt +++ b/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/player/music/MusicUnlock.kt @@ -6,6 +6,7 @@ import world.gregs.voidps.engine.entity.character.player.Player import world.gregs.voidps.engine.get object MusicUnlock { + @Suppress("UNCHECKED_CAST") fun unlockTrack(player: Player, trackIndex: Int): Boolean { val name = "unlocked_music_${trackIndex / 32}" val list = get().get(name)?.values as? List diff --git a/game/src/main/kotlin/world/gregs/voidps/world/map/edgeville/WildernessIcons.kts b/game/src/main/kotlin/world/gregs/voidps/world/map/edgeville/WildernessIcons.kts index f6715ec13..0853eb30d 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/map/edgeville/WildernessIcons.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/map/edgeville/WildernessIcons.kts @@ -6,12 +6,9 @@ import world.gregs.voidps.engine.client.ui.open import world.gregs.voidps.engine.client.variable.variableClear import world.gregs.voidps.engine.client.variable.variableSet import world.gregs.voidps.engine.entity.character.player.Player -import world.gregs.voidps.engine.entity.character.player.skill.Skill -import world.gregs.voidps.engine.entity.character.player.skill.level.Level.has import world.gregs.voidps.engine.timer.timerStart import world.gregs.voidps.engine.timer.timerStop import world.gregs.voidps.world.interact.entity.combat.inWilderness -import world.gregs.voidps.world.interact.entity.player.combat.prayer.isCurses variableSet("in_wilderness", true) { player: Player -> player.options.set(1, "Attack") @@ -53,11 +50,11 @@ fun resetIcons(player: Player) = player.interfaces.apply { } fun updateIcon(player: Player) { - val component = when { - player["prayer_protect_item", false] -> "protection_active" - player.has(Skill.Prayer, if (player.isCurses()) 50 else 25) -> "protect_disabled" - else -> "no_protection" - } +// val component = when { +// player["prayer_protect_item", false] -> "protection_active" +// player.has(Skill.Prayer, if (player.isCurses()) 50 else 25) -> "protect_disabled" +// else -> "no_protection" +// } // These icons aren't displayed in this revision. // player.interfaces.sendVisibility("area_status_icon", component, true) } \ No newline at end of file diff --git a/game/src/main/kotlin/world/gregs/voidps/world/map/lumbridge/combat_hall/MeleeTutor.kts b/game/src/main/kotlin/world/gregs/voidps/world/map/lumbridge/combat_hall/MeleeTutor.kts index 9499192c9..975ca5a16 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/map/lumbridge/combat_hall/MeleeTutor.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/map/lumbridge/combat_hall/MeleeTutor.kts @@ -119,7 +119,7 @@ suspend fun CharacterContext.buySkillcape() { player.inventory.transaction { remove("coins", 99000) add("defence_hood") - val trimmed = Skill.values().any { it != Skill.Defence && player.levels.getMax(it) >= Level.MAX_LEVEL } + val trimmed = Skill.entries.any { it != Skill.Defence && player.levels.getMax(it) >= Level.MAX_LEVEL } add("defence_skillcape${if (trimmed) "_t" else ""}") } when (player.inventory.transaction.error) { diff --git a/game/src/main/kotlin/world/gregs/voidps/world/map/varrock/Delrith.kts b/game/src/main/kotlin/world/gregs/voidps/world/map/varrock/Delrith.kts index 791d9504f..60fcc10fb 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/map/varrock/Delrith.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/map/varrock/Delrith.kts @@ -231,7 +231,7 @@ combatSwing(priority = Priority.HIGHEST) { player: Player -> if (target is NPC && target.id == "delrith" && target.transform == "delrith_weakened") { cancel() player.strongQueue("banish_delrith", 1) { - player.mode = Interact(player, target, NPCOption(player, target as NPC, target.def, "Banish")) + player.mode = Interact(player, target, NPCOption(player, target, target.def, "Banish")) } } } diff --git a/game/src/test/kotlin/world/gregs/voidps/world/script/InstructionCalls.kt b/game/src/test/kotlin/world/gregs/voidps/world/script/InstructionCalls.kt index 670cbc780..24846c4db 100644 --- a/game/src/test/kotlin/world/gregs/voidps/world/script/InstructionCalls.kt +++ b/game/src/test/kotlin/world/gregs/voidps/world/script/InstructionCalls.kt @@ -97,10 +97,9 @@ fun Player.equipItem( fun Player.dialogueOption( id: String, component: String, - type: String = "make", option: Int = -1 ) { - events.emit(ContinueDialogue(id, component, /*type, */option)) + events.emit(ContinueDialogue(id, component, option)) } private fun getOptionIndex(id: String, componentId: String, option: String): Int? { diff --git a/gradle.properties b/gradle.properties index 348d30b64..e9c9d30f8 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,15 +1,15 @@ #org.gradle.java.home=C:/Users//.jdks/openjdk-19.0.1/ -junitVersion = 5.9.3 -ktorVersion = 2.3.7 -displeeCacheVersion = 7.0 -fastUtilVersion = 8.5.11 -jacksonVersion = 2.14.1 +junitVersion = 5.10.2 +ktorVersion = 2.3.8 +displeeCacheVersion = 7.1.0 +fastUtilVersion = 8.5.13 +jacksonVersion = 2.16.1 kotlinIoVersion = 0.1.16 kotlinCoroutinesVersion = 1.7.3 koinVersion = 3.5.3 koinLogVersion = 3.5.3 logbackVersion = 1.4.14 -inlineLoggingVersion = 1.0.5 +inlineLoggingVersion = 1.0.6 mockkVersion = 1.13.9 jbcryptVersion = 0.4 kaseChangeVersion = 1.4.1 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index a59520664..17655d0ef 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/network/src/main/kotlin/world/gregs/voidps/network/FileServer.kt b/network/src/main/kotlin/world/gregs/voidps/network/FileServer.kt index c7ca5dbb5..be4efba93 100644 --- a/network/src/main/kotlin/world/gregs/voidps/network/FileServer.kt +++ b/network/src/main/kotlin/world/gregs/voidps/network/FileServer.kt @@ -51,7 +51,7 @@ class FileServer( } /** - * If the client is up-to-date and in the correct state send it the [prefetchKeys] list so it knows what indices are available to request + * If the client is up-to-date and in the correct state send it the [prefetchKeys] list, so it knows what indices are available to request */ private suspend fun synchronise(read: ByteReadChannel, write: ByteWriteChannel) { val revision = read.readInt() diff --git a/network/src/main/kotlin/world/gregs/voidps/network/JagExtensions.kt b/network/src/main/kotlin/world/gregs/voidps/network/JagExtensions.kt index 948259cc9..175902ab4 100644 --- a/network/src/main/kotlin/world/gregs/voidps/network/JagExtensions.kt +++ b/network/src/main/kotlin/world/gregs/voidps/network/JagExtensions.kt @@ -1,3 +1,5 @@ +@file:OptIn(ExperimentalUnsignedTypes::class) + package world.gregs.voidps.network import io.ktor.utils.io.* diff --git a/network/src/main/kotlin/world/gregs/voidps/network/client/Client.kt b/network/src/main/kotlin/world/gregs/voidps/network/client/Client.kt index fa040fc64..f49a3129e 100644 --- a/network/src/main/kotlin/world/gregs/voidps/network/client/Client.kt +++ b/network/src/main/kotlin/world/gregs/voidps/network/client/Client.kt @@ -97,6 +97,7 @@ open class Client( } companion object { + @OptIn(ExperimentalCoroutinesApi::class, DelicateCoroutinesApi::class) val context = newSingleThreadContext("Networking") const val FIXED = 0 diff --git a/network/src/main/kotlin/world/gregs/voidps/network/client/ClientState.kt b/network/src/main/kotlin/world/gregs/voidps/network/client/ClientState.kt index 8344657c5..0fb48653e 100644 --- a/network/src/main/kotlin/world/gregs/voidps/network/client/ClientState.kt +++ b/network/src/main/kotlin/world/gregs/voidps/network/client/ClientState.kt @@ -3,10 +3,10 @@ package world.gregs.voidps.network.client import world.gregs.voidps.network.NetworkQueue sealed class ClientState { - object Connected : ClientState() + data object Connected : ClientState() /** * Waiting for [NetworkQueue] to allow disconnection */ - object Disconnecting : ClientState() - object Disconnected : ClientState() + data object Disconnecting : ClientState() + data object Disconnected : ClientState() } \ No newline at end of file diff --git a/network/src/main/kotlin/world/gregs/voidps/network/decode/ChatTypeDecoder.kt b/network/src/main/kotlin/world/gregs/voidps/network/decode/ChatTypeDecoder.kt index 6677fdff5..ae64dfa75 100644 --- a/network/src/main/kotlin/world/gregs/voidps/network/decode/ChatTypeDecoder.kt +++ b/network/src/main/kotlin/world/gregs/voidps/network/decode/ChatTypeDecoder.kt @@ -12,6 +12,7 @@ import world.gregs.voidps.network.instruct.ChatTypeChange */ class ChatTypeDecoder : Decoder(1) { + @OptIn(ExperimentalUnsignedTypes::class) override suspend fun decode(instructions: MutableSharedFlow, packet: ByteReadPacket) { instructions.emit(ChatTypeChange(packet.readUByte().toInt())) } diff --git a/network/src/main/kotlin/world/gregs/voidps/network/decode/ConsoleCommandDecoder.kt b/network/src/main/kotlin/world/gregs/voidps/network/decode/ConsoleCommandDecoder.kt index 1d103c585..89673e674 100644 --- a/network/src/main/kotlin/world/gregs/voidps/network/decode/ConsoleCommandDecoder.kt +++ b/network/src/main/kotlin/world/gregs/voidps/network/decode/ConsoleCommandDecoder.kt @@ -9,6 +9,7 @@ import world.gregs.voidps.network.readString class ConsoleCommandDecoder : Decoder(BYTE) { + @OptIn(ExperimentalUnsignedTypes::class) override suspend fun decode(instructions: MutableSharedFlow, packet: ByteReadPacket) { packet.readUByte() packet.readUByte() diff --git a/network/src/main/kotlin/world/gregs/voidps/network/decode/KeysPressedDecoder.kt b/network/src/main/kotlin/world/gregs/voidps/network/decode/KeysPressedDecoder.kt index b3de66f93..b6d00cb3a 100644 --- a/network/src/main/kotlin/world/gregs/voidps/network/decode/KeysPressedDecoder.kt +++ b/network/src/main/kotlin/world/gregs/voidps/network/decode/KeysPressedDecoder.kt @@ -10,6 +10,7 @@ import world.gregs.voidps.network.Instruction */ class KeysPressedDecoder : Decoder(BYTE) { + @OptIn(ExperimentalUnsignedTypes::class) override suspend fun decode(instructions: MutableSharedFlow, packet: ByteReadPacket) { val keys = ArrayList>() while (packet.remaining > 0) { diff --git a/network/src/main/kotlin/world/gregs/voidps/network/decode/MovedCameraDecoder.kt b/network/src/main/kotlin/world/gregs/voidps/network/decode/MovedCameraDecoder.kt index 45aab02d8..6cc32c0ae 100644 --- a/network/src/main/kotlin/world/gregs/voidps/network/decode/MovedCameraDecoder.kt +++ b/network/src/main/kotlin/world/gregs/voidps/network/decode/MovedCameraDecoder.kt @@ -7,6 +7,7 @@ import world.gregs.voidps.network.Instruction class MovedCameraDecoder : Decoder(4) { + @OptIn(ExperimentalUnsignedTypes::class) override suspend fun decode(instructions: MutableSharedFlow, packet: ByteReadPacket) { val pitch = packet.readUShort().toInt() val yaw = packet.readUShort().toInt() diff --git a/network/src/main/kotlin/world/gregs/voidps/network/decode/ObjectExamineDecoder.kt b/network/src/main/kotlin/world/gregs/voidps/network/decode/ObjectExamineDecoder.kt index e6ad917fb..1c32c1cf3 100644 --- a/network/src/main/kotlin/world/gregs/voidps/network/decode/ObjectExamineDecoder.kt +++ b/network/src/main/kotlin/world/gregs/voidps/network/decode/ObjectExamineDecoder.kt @@ -8,6 +8,7 @@ import world.gregs.voidps.network.instruct.ExamineObject class ObjectExamineDecoder : Decoder(2) { + @OptIn(ExperimentalUnsignedTypes::class) override suspend fun decode(instructions: MutableSharedFlow, packet: ByteReadPacket) { val objectId = packet.readUShort().toInt() instructions.emit(ExamineObject(objectId)) diff --git a/network/src/main/kotlin/world/gregs/voidps/network/decode/ObjectOption1Decoder.kt b/network/src/main/kotlin/world/gregs/voidps/network/decode/ObjectOption1Decoder.kt index 4e8983aad..498b94a1c 100644 --- a/network/src/main/kotlin/world/gregs/voidps/network/decode/ObjectOption1Decoder.kt +++ b/network/src/main/kotlin/world/gregs/voidps/network/decode/ObjectOption1Decoder.kt @@ -11,6 +11,7 @@ import world.gregs.voidps.network.readShortAddLittle class ObjectOption1Decoder : Decoder(7) { + @OptIn(ExperimentalUnsignedTypes::class) override suspend fun decode(instructions: MutableSharedFlow, packet: ByteReadPacket) { val run = packet.readBooleanSubtract() val x = packet.readShortAddLittle() diff --git a/network/src/main/kotlin/world/gregs/voidps/network/decode/PrivateQuickChatDecoder.kt b/network/src/main/kotlin/world/gregs/voidps/network/decode/PrivateQuickChatDecoder.kt index 9556f15d4..0ae570e11 100644 --- a/network/src/main/kotlin/world/gregs/voidps/network/decode/PrivateQuickChatDecoder.kt +++ b/network/src/main/kotlin/world/gregs/voidps/network/decode/PrivateQuickChatDecoder.kt @@ -9,6 +9,7 @@ import world.gregs.voidps.network.readString class PrivateQuickChatDecoder : Decoder(BYTE) { + @OptIn(ExperimentalUnsignedTypes::class) override suspend fun decode(instructions: MutableSharedFlow, packet: ByteReadPacket) { val name = packet.readString() val file = packet.readUShort().toInt() diff --git a/network/src/main/kotlin/world/gregs/voidps/network/decode/PublicDecoder.kt b/network/src/main/kotlin/world/gregs/voidps/network/decode/PublicDecoder.kt index 8c1966771..a6aef2c3a 100644 --- a/network/src/main/kotlin/world/gregs/voidps/network/decode/PublicDecoder.kt +++ b/network/src/main/kotlin/world/gregs/voidps/network/decode/PublicDecoder.kt @@ -10,6 +10,7 @@ import world.gregs.voidps.network.readSmart class PublicDecoder(private val huffman: Huffman) : Decoder(BYTE) { + @OptIn(ExperimentalUnsignedTypes::class) override suspend fun decode(instructions: MutableSharedFlow, packet: ByteReadPacket) { val effects = (packet.readUByte().toInt() shl 8) or packet.readUByte().toInt() val message = huffman.decompress(length = packet.readSmart(), message = packet.readBytes(packet.remaining.toInt())) ?: "" diff --git a/network/src/main/kotlin/world/gregs/voidps/network/decode/PublicQuickChatDecoder.kt b/network/src/main/kotlin/world/gregs/voidps/network/decode/PublicQuickChatDecoder.kt index 24d81d489..37ab4a8a5 100644 --- a/network/src/main/kotlin/world/gregs/voidps/network/decode/PublicQuickChatDecoder.kt +++ b/network/src/main/kotlin/world/gregs/voidps/network/decode/PublicQuickChatDecoder.kt @@ -8,6 +8,7 @@ import world.gregs.voidps.network.instruct.QuickChatPublic class PublicQuickChatDecoder : Decoder(BYTE) { + @OptIn(ExperimentalUnsignedTypes::class) override suspend fun decode(instructions: MutableSharedFlow, packet: ByteReadPacket) { val script = packet.readByte().toInt() val file = packet.readUShort().toInt() diff --git a/network/src/main/kotlin/world/gregs/voidps/network/decode/ScreenChangeDecoder.kt b/network/src/main/kotlin/world/gregs/voidps/network/decode/ScreenChangeDecoder.kt index d5cb12f2c..3bb8cc21f 100644 --- a/network/src/main/kotlin/world/gregs/voidps/network/decode/ScreenChangeDecoder.kt +++ b/network/src/main/kotlin/world/gregs/voidps/network/decode/ScreenChangeDecoder.kt @@ -8,6 +8,7 @@ import world.gregs.voidps.network.instruct.ChangeDisplayMode class ScreenChangeDecoder : Decoder(6) { + @OptIn(ExperimentalUnsignedTypes::class) override suspend fun decode(instructions: MutableSharedFlow, packet: ByteReadPacket) { instructions.emit(ChangeDisplayMode( displayMode = packet.readUByte().toInt(), diff --git a/network/src/main/kotlin/world/gregs/voidps/network/decode/SkillCapeColourDecoder.kt b/network/src/main/kotlin/world/gregs/voidps/network/decode/SkillCapeColourDecoder.kt index 8a5c206b0..c63866d53 100644 --- a/network/src/main/kotlin/world/gregs/voidps/network/decode/SkillCapeColourDecoder.kt +++ b/network/src/main/kotlin/world/gregs/voidps/network/decode/SkillCapeColourDecoder.kt @@ -7,6 +7,7 @@ import world.gregs.voidps.network.Instruction class SkillCapeColourDecoder : Decoder(2) { + @OptIn(ExperimentalUnsignedTypes::class) override suspend fun decode(instructions: MutableSharedFlow, packet: ByteReadPacket) { val colour = packet.readUShort().toInt() } diff --git a/network/src/main/kotlin/world/gregs/voidps/network/encode/InterfaceEncoders.kt b/network/src/main/kotlin/world/gregs/voidps/network/encode/InterfaceEncoders.kt index 934eb7735..18fac89e5 100644 --- a/network/src/main/kotlin/world/gregs/voidps/network/encode/InterfaceEncoders.kt +++ b/network/src/main/kotlin/world/gregs/voidps/network/encode/InterfaceEncoders.kt @@ -9,7 +9,7 @@ import world.gregs.voidps.network.client.Client.Companion.smart import world.gregs.voidps.network.client.Client.Companion.string /** - * Sends an animation to a interface component + * Sends an animation to an interface component * @param id The id of the parent interface * @param component The index of the component * @param animation The animation id diff --git a/network/src/main/kotlin/world/gregs/voidps/network/visual/update/Hitsplat.kt b/network/src/main/kotlin/world/gregs/voidps/network/visual/update/Hitsplat.kt index e9f517733..e7d477e2b 100644 --- a/network/src/main/kotlin/world/gregs/voidps/network/visual/update/Hitsplat.kt +++ b/network/src/main/kotlin/world/gregs/voidps/network/visual/update/Hitsplat.kt @@ -13,17 +13,17 @@ data class Hitsplat( ) { sealed class Mark(val id: Int) { - object Melee : Mark(0) - object Range : Mark(1) - object Magic : Mark(2) - object Regular : Mark(3) - object Reflected : Mark(4) - object Absorb : Mark(5) - object Poison : Mark(6) - object Diseased : Mark(7) - object Missed : Mark(8) - object Healed : Mark(9) - object Cannon : Mark(13) + data object Melee : Mark(0) + data object Range : Mark(1) + data object Magic : Mark(2) + data object Regular : Mark(3) + data object Reflected : Mark(4) + data object Absorb : Mark(5) + data object Poison : Mark(6) + data object Diseased : Mark(7) + data object Missed : Mark(8) + data object Healed : Mark(9) + data object Cannon : Mark(13) } fun write(writer: Writer, observer: Int, victim: Int, add: Boolean) { diff --git a/network/src/main/kotlin/world/gregs/voidps/network/visual/update/player/BodyPart.kt b/network/src/main/kotlin/world/gregs/voidps/network/visual/update/player/BodyPart.kt index 5c2eb26df..3e40e1b09 100644 --- a/network/src/main/kotlin/world/gregs/voidps/network/visual/update/player/BodyPart.kt +++ b/network/src/main/kotlin/world/gregs/voidps/network/visual/update/player/BodyPart.kt @@ -18,8 +18,7 @@ enum class BodyPart( Beard(EquipSlot.Hat, index = 1); companion object { - val all = values() - fun by(index: Int) = all.firstOrNull { it.index == index } - fun by(slot: EquipSlot) = all.firstOrNull { it.slot == slot } + fun by(index: Int) = entries.firstOrNull { it.index == index } + fun by(slot: EquipSlot) = entries.firstOrNull { it.slot == slot } } } \ No newline at end of file diff --git a/network/src/main/kotlin/world/gregs/voidps/network/visual/update/player/EquipSlot.kt b/network/src/main/kotlin/world/gregs/voidps/network/visual/update/player/EquipSlot.kt index bd8fc638e..7eed20871 100644 --- a/network/src/main/kotlin/world/gregs/voidps/network/visual/update/player/EquipSlot.kt +++ b/network/src/main/kotlin/world/gregs/voidps/network/visual/update/player/EquipSlot.kt @@ -17,11 +17,11 @@ enum class EquipSlot(val index: Int) { Ammo(13); companion object { - fun by(index: Int): EquipSlot = values().firstOrNull { it.index == index } ?: None + fun by(index: Int): EquipSlot = entries.firstOrNull { it.index == index } ?: None fun by(name: String): EquipSlot { - val name = name.replaceFirstChar { if (it.isLowerCase()) it.titlecase(Locale.getDefault()) else it.toString() } - return values().firstOrNull { it.name == name } ?: None + val formatted = name.replaceFirstChar { if (it.isLowerCase()) it.titlecase(Locale.getDefault()) else it.toString() } + return entries.firstOrNull { it.name == formatted } ?: None } } diff --git a/tools/build.gradle.kts b/tools/build.gradle.kts index ad7edb889..c1207d738 100644 --- a/tools/build.gradle.kts +++ b/tools/build.gradle.kts @@ -13,8 +13,8 @@ dependencies { implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:${findProperty("kotlinCoroutinesVersion")}") implementation("org.apache.commons:commons-compress:1.24.0") - implementation("org.jsoup:jsoup:1.13.1") - implementation("org.sweble.wikitext:swc-engine:2.0.0") + implementation("org.jsoup:jsoup:1.17.2") + implementation("org.sweble.wikitext:swc-engine:3.1.9") implementation("com.github.weisj:darklaf-core:2.7.3") implementation("javax.xml.bind:jaxb-api:2.3.1") implementation("net.pearx.kasechange:kasechange:${findProperty("kaseChangeVersion")}") diff --git a/tools/src/main/kotlin/world/gregs/voidps/tools/DropTableDefinitions.kt b/tools/src/main/kotlin/world/gregs/voidps/tools/DropTableDefinitions.kt index 4e8c6502f..13bd933ad 100644 --- a/tools/src/main/kotlin/world/gregs/voidps/tools/DropTableDefinitions.kt +++ b/tools/src/main/kotlin/world/gregs/voidps/tools/DropTableDefinitions.kt @@ -16,13 +16,14 @@ import world.gregs.yaml.Yaml object DropTableDefinitions { @JvmStatic fun main(args: Array) { - val koin = startKoin { + startKoin { fileProperties("/tool.properties") modules(module { + @Suppress("USELESS_CAST") single { CacheDelegate(getProperty("cachePath")) as Cache } single { ItemDefinitions(ItemDecoder().load(get())).load(Yaml()) } }) - }.koin + } val decoder = DropTables().load(Yaml()) val table = decoder.getValue("goblin_drop_table") diff --git a/tools/src/main/kotlin/world/gregs/voidps/tools/StructDefinitions.kt b/tools/src/main/kotlin/world/gregs/voidps/tools/StructDefinitions.kt index fcf8f2cd9..55c99926e 100644 --- a/tools/src/main/kotlin/world/gregs/voidps/tools/StructDefinitions.kt +++ b/tools/src/main/kotlin/world/gregs/voidps/tools/StructDefinitions.kt @@ -17,7 +17,7 @@ object StructDefinitions { // if (def.params != null) { // set.addAll(def.params!!.keys) // } - println("$i ${def}") + println("$i $def") } val folder = File("C:\\Users\\Greg\\Documents\\Void\\decompiled-cs2-667\\") diff --git a/tools/src/main/kotlin/world/gregs/voidps/tools/cache/DumpStyles.kt b/tools/src/main/kotlin/world/gregs/voidps/tools/cache/DumpStyles.kt index 01ddc27ac..f61d43079 100644 --- a/tools/src/main/kotlin/world/gregs/voidps/tools/cache/DumpStyles.kt +++ b/tools/src/main/kotlin/world/gregs/voidps/tools/cache/DumpStyles.kt @@ -107,9 +107,9 @@ object DumpStyles { println(""" ${names[id]}: id: $id - attack_types: ${types} - attack_styles: ${styles} - combat_styles: ${combatStyles} + attack_types: $types + attack_styles: $styles + combat_styles: $combatStyles """.trimIndent()) // return types.mapIndexed { i, s -> Triple(s, styles[i], combatStyle.getOrNull(i) ?: "") }.toTypedArray() } diff --git a/tools/src/main/kotlin/world/gregs/voidps/tools/cache/HashCodeMatcher.kt b/tools/src/main/kotlin/world/gregs/voidps/tools/cache/HashCodeMatcher.kt index 69f360691..31ecdbb12 100644 --- a/tools/src/main/kotlin/world/gregs/voidps/tools/cache/HashCodeMatcher.kt +++ b/tools/src/main/kotlin/world/gregs/voidps/tools/cache/HashCodeMatcher.kt @@ -96,7 +96,7 @@ object HashCodeMatcher { } for (a in spaced) { for (b in spaced) { - check("${a} ${b}", underscore) + check("$a $b", underscore) check("${a}${b}") } } @@ -126,8 +126,8 @@ object HashCodeMatcher { writeAll() } - private fun findScripts(keywords: Set, depth: Int) { - val keywords = keywords.filter { !it.contains(" ") } + private fun findScripts(keywordSet: Set, depth: Int) { + val keywords = keywordSet.filter { !it.contains(" ") } val underscore = listOf('_') if (depth == 1) { println("Searching individual keywords") @@ -172,8 +172,8 @@ object HashCodeMatcher { writeAll() } - private fun findSprites(keywords: Set, depth: Int) { - val keywords = keywords.filter { !it.contains(" ") } + private fun findSprites(keywordSet: Set, depth: Int) { + val keywords = keywordSet.filter { !it.contains(" ") } val comma = listOf(',') if (depth == 1) { println("Searching individual keywords") diff --git a/tools/src/main/kotlin/world/gregs/voidps/tools/convert/DropTableConverter.kt b/tools/src/main/kotlin/world/gregs/voidps/tools/convert/DropTableConverter.kt index 8519b9a45..945b8d4b4 100644 --- a/tools/src/main/kotlin/world/gregs/voidps/tools/convert/DropTableConverter.kt +++ b/tools/src/main/kotlin/world/gregs/voidps/tools/convert/DropTableConverter.kt @@ -22,10 +22,9 @@ object DropTableConverter { """.trimIndent() val all = mutableListOf() var builder = DropTable.Builder() - var name = "" for (line in string.lines()) { if (line.startsWith("=")) { - name = toIdentifier(line.replace("=", "")) + val name = toIdentifier(line.replace("=", "")) } else if (line.startsWith("{{DropsLine|")) { process(builder, line) } else if (line.startsWith("{{DropsTableBottom")) { diff --git a/tools/src/main/kotlin/world/gregs/voidps/tools/convert/InterfaceDecoder718.kt b/tools/src/main/kotlin/world/gregs/voidps/tools/convert/InterfaceDecoder718.kt index 188f12ce7..1916fbee9 100644 --- a/tools/src/main/kotlin/world/gregs/voidps/tools/convert/InterfaceDecoder718.kt +++ b/tools/src/main/kotlin/world/gregs/voidps/tools/convert/InterfaceDecoder718.kt @@ -59,11 +59,11 @@ class InterfaceDecoder718 { if (type == 6) { defaultMediaType = 1 defaultMediaId = reader.readBigSmart() - val i_4_: Int = reader.readUnsignedByte() - val bool = i_4_ and 0x1 == 1 - centreType = i_4_ and 0x2 == 2 - animated = i_4_ and 0x4 == 4 - ignoreZBuffer = i_4_ and 0x8 == 8 + val flag: Int = reader.readUnsignedByte() + val bool = flag and 0x1 == 1 + centreType = flag and 0x2 == 2 + animated = flag and 0x4 == 4 + ignoreZBuffer = flag and 0x8 == 8 if (bool) { viewportX = reader.readShort() viewportY = reader.readShort() @@ -144,14 +144,14 @@ class InterfaceDecoder718 { } } if (iconCount > 0) { - val i_14_: Int = reader.readUnsignedByte() - mouseIcon = IntArray(i_14_ + 1) - for (i_15_ in mouseIcon!!.indices) mouseIcon!![i_15_] = -1 - mouseIcon!![i_14_] = reader.readUnsignedShort() + val size: Int = reader.readUnsignedByte() + mouseIcon = IntArray(size + 1) + for (index in mouseIcon!!.indices) mouseIcon!![index] = -1 + mouseIcon!![size] = reader.readUnsignedShort() } if (iconCount > 1) { - val i_16_: Int = reader.readUnsignedByte() - mouseIcon!![i_16_] = reader.readUnsignedShort() + val index: Int = reader.readUnsignedByte() + mouseIcon!![index] = reader.readUnsignedShort() } optionOverride = reader.readString() if (optionOverride == "") optionOverride = null @@ -159,11 +159,11 @@ class InterfaceDecoder718 { anInt4795 = reader.readUnsignedByte() anInt4860 = reader.readUnsignedByte() useOption = reader.readString() - var i_17_ = -1 + var i17 = -1 if (setting shr 11 and 0x7f != 0) { - i_17_ = reader.readUnsignedShort() - if (i_17_ == 65535) { - i_17_ = -1 + i17 = reader.readUnsignedShort() + if (i17 == 65535) { + i17 = -1 } anInt4698 = reader.readUnsignedShort() if (anInt4698 == 65535) { @@ -182,15 +182,15 @@ class InterfaceDecoder718 { } // aClass298_Sub38_1219 = Class298_Sub38(i_5_, i_17_) if (flag0 >= 0) { - val i_18_: Int = reader.readUnsignedByte() - for (i_19_ in 0 until i_18_) { - val i_20_: Int = reader.readUnsignedMedium() - val i_21_: Int = reader.readInt() + val size: Int = reader.readUnsignedByte() + for (i19 in 0 until size) { + val i20: Int = reader.readUnsignedMedium() + val i21: Int = reader.readInt() // this.aClass437_1279.method5817(Class298_Sub35(i_21_), i_20_.toLong()) } - val i_22_: Int = reader.readUnsignedByte() - for (i_23_ in 0 until i_22_) { - val i_24_: Int = reader.readUnsignedMedium() + val i22: Int = reader.readUnsignedByte() + for (index in 0 until i22) { + val i24: Int = reader.readUnsignedMedium() val string: String = reader.readString() // this.aClass437_1279.method5817(string, i_24_.toLong()) } diff --git a/tools/src/main/kotlin/world/gregs/voidps/tools/convert/InventoryConverter.kt b/tools/src/main/kotlin/world/gregs/voidps/tools/convert/InventoryConverter.kt index dbfda1acd..486d5bcc3 100644 --- a/tools/src/main/kotlin/world/gregs/voidps/tools/convert/InventoryConverter.kt +++ b/tools/src/main/kotlin/world/gregs/voidps/tools/convert/InventoryConverter.kt @@ -18,9 +18,9 @@ import kotlin.collections.set /** * Converts inventories from one cache into another, dumping the default values into inventories.yml */ +@Suppress("UNCHECKED_CAST") object InventoryConverter { - @Suppress("USELESS_CAST") fun convert(target: File, provider: File) { val targetCache = CacheDelegate(target.path) val otherCache = CacheDelegate(provider.path) diff --git a/tools/src/main/kotlin/world/gregs/voidps/tools/convert/SkillDataConverter.kt b/tools/src/main/kotlin/world/gregs/voidps/tools/convert/SkillDataConverter.kt index a253d813e..ac1d92d3b 100644 --- a/tools/src/main/kotlin/world/gregs/voidps/tools/convert/SkillDataConverter.kt +++ b/tools/src/main/kotlin/world/gregs/voidps/tools/convert/SkillDataConverter.kt @@ -20,6 +20,7 @@ import world.gregs.voidps.engine.get import world.gregs.yaml.Yaml import java.io.File +@Suppress("UNCHECKED_CAST") object SkillDataConverter { @Suppress("USELESS_CAST") @JvmStatic @@ -50,7 +51,7 @@ object SkillDataConverter { for ((name, map) in data) { val map = map.toMutableMap() if (map.containsKey("skill")) { - map.replace("skill", Skill.values()[map["skill"] as Int]) + map.replace("skill", Skill.entries[map["skill"] as Int]) if (map["skill"] != Skill.Crafting) { continue } diff --git a/tools/src/main/kotlin/world/gregs/voidps/tools/definition/YamlInjector.kt b/tools/src/main/kotlin/world/gregs/voidps/tools/definition/YamlInjector.kt index 4a3123696..6bb097263 100644 --- a/tools/src/main/kotlin/world/gregs/voidps/tools/definition/YamlInjector.kt +++ b/tools/src/main/kotlin/world/gregs/voidps/tools/definition/YamlInjector.kt @@ -29,7 +29,7 @@ object YamlInjector { .replace(")", "") .replace("_axe", "_hatchet") map[key] = level to xp - println("$key - $level - $name - ${item} - $xp - $members") + println("$key - $level - $name - $item - $xp - $members") } } val output = FileWriter("items.yml") diff --git a/tools/src/main/kotlin/world/gregs/voidps/tools/definition/YamlSorter.kt b/tools/src/main/kotlin/world/gregs/voidps/tools/definition/YamlSorter.kt index ceb28722b..843c017a6 100644 --- a/tools/src/main/kotlin/world/gregs/voidps/tools/definition/YamlSorter.kt +++ b/tools/src/main/kotlin/world/gregs/voidps/tools/definition/YamlSorter.kt @@ -10,6 +10,7 @@ import world.gregs.yaml.write.YamlWriterConfiguration * name: * id: 0 */ +@Suppress("UNCHECKED_CAST") object YamlSorter { private fun anchor(key: String) = key == "<<" || key == "&" diff --git a/tools/src/main/kotlin/world/gregs/voidps/tools/definition/item/ItemDefinitionPipeline.kt b/tools/src/main/kotlin/world/gregs/voidps/tools/definition/item/ItemDefinitionPipeline.kt index 35bb54d48..74d12fe8f 100644 --- a/tools/src/main/kotlin/world/gregs/voidps/tools/definition/item/ItemDefinitionPipeline.kt +++ b/tools/src/main/kotlin/world/gregs/voidps/tools/definition/item/ItemDefinitionPipeline.kt @@ -44,7 +44,7 @@ typealias Extras = Pair> object ItemDefinitionPipeline { private val redirectRegex = "#(?:REDIRECT|redirect) ?\\[\\[(.*)]]".toRegex() - private const val debugId = -1 + private const val DEBUG_ID = -1 @JvmStatic fun main(args: Array) { @@ -90,7 +90,7 @@ object ItemDefinitionPipeline { add(ItemNoted(decoder)) } for (id in decoder.indices) { - if (debugId >= 0 && id != debugId) { + if (DEBUG_ID >= 0 && id != DEBUG_ID) { continue } val def = decoder.getOrNull(id) ?: continue @@ -130,7 +130,7 @@ object ItemDefinitionPipeline { val incomplete = mutableListOf() for (id in decoder.indices) { - if (debugId >= 0 && id != debugId) { + if (DEBUG_ID >= 0 && id != DEBUG_ID) { continue } val def = decoder.getOrNull(id) ?: continue diff --git a/tools/src/main/kotlin/world/gregs/voidps/tools/definition/item/pipe/extra/wiki/InfoBoxItem.kt b/tools/src/main/kotlin/world/gregs/voidps/tools/definition/item/pipe/extra/wiki/InfoBoxItem.kt index 14db67ada..bc213648e 100644 --- a/tools/src/main/kotlin/world/gregs/voidps/tools/definition/item/pipe/extra/wiki/InfoBoxItem.kt +++ b/tools/src/main/kotlin/world/gregs/voidps/tools/definition/item/pipe/extra/wiki/InfoBoxItem.kt @@ -63,7 +63,7 @@ class InfoBoxItem(val revision: LocalDate) : Pipeline.Modifier { "examine$suffix" -> { val t = value as? String if (t == null) { - println("Unknown examine $t") + println("Unknown examine") } else { val text = removeLinks(t).replace("adrenaline", "recover special").replace(usedInRegex, "").trim() splitExamine(text, extras, key, suffix, false) @@ -77,7 +77,7 @@ class InfoBoxItem(val revision: LocalDate) : Pipeline.Modifier { val text = value as String val use = if (text == "removed") { val removal = template["removal"] as? String - if (removal == null || removal.isBlank() || LocalDate.parse(removeLinks(removal), formatter).isBefore(revision)) { + if (removal.isNullOrBlank() || LocalDate.parse(removeLinks(removal), formatter).isBefore(revision)) { ItemUse.Removed } else { ItemUse.Surface @@ -145,7 +145,7 @@ class InfoBoxItem(val revision: LocalDate) : Pipeline.Modifier { private val linkNameRegex = "\\[\\[(.*?)]]".toRegex() - private const val linebreak = "
" + private const val LINE_BREAK = "
" private val removeParentheses = "\\(.*?\\)\\s?".toRegex() private val splitByColon = "(?:\\.|
|!|\\?)('?.*?:'?(?:\\s+)?)".toRegex() @@ -183,7 +183,7 @@ class InfoBoxItem(val revision: LocalDate) : Pipeline.Modifier { fun splitExamine(text: String, extras: MutableMap, key: String, suffix: String, override: Boolean) { val text = removeBold(formatLineBreaks(text).replace("\"", "")) - if (text.contains(linebreak) || text.contains(":") || text.contains("(")) { + if (text.contains(LINE_BREAK) || text.contains(":") || text.contains("(")) { val parts = when { text.contains(":") -> { text @@ -192,7 +192,7 @@ class InfoBoxItem(val revision: LocalDate) : Pipeline.Modifier { splitParentheses(line) } } - text.contains(linebreak) -> text.split(linebreak).map { it.trim() } + text.contains(LINE_BREAK) -> text.split(LINE_BREAK).map { it.trim() } text.contains("(") -> splitParentheses(text) else -> throw RuntimeException("Unknown split '$text'") } @@ -214,14 +214,14 @@ class InfoBoxItem(val revision: LocalDate) : Pipeline.Modifier { } fun formatLineBreaks(text: String) = text - .replace("
", linebreak) - .replace("
", linebreak) + .replace("
", LINE_BREAK) + .replace("
", LINE_BREAK) .replace("\n", " ") - .replace("\\n", linebreak) - .replace("*", linebreak) - .replace(" / ", linebreak) - .replace(" OR ", linebreak) - .replace("./", ".$linebreak") + .replace("\\n", LINE_BREAK) + .replace("*", LINE_BREAK) + .replace(" / ", LINE_BREAK) + .replace(" OR ", LINE_BREAK) + .replace("./", ".$LINE_BREAK") /** * Same as [split] but only splits by captured group not full match @@ -241,7 +241,7 @@ class InfoBoxItem(val revision: LocalDate) : Pipeline.Modifier { } private fun splitParentheses(text: String) = text - .replace(linebreak, "") + .replace(LINE_BREAK, "") .splitByMatch(splitByParentheses) .map { part -> part.split(":").last().trim() } .filter { it.isNotBlank() && it != "." } diff --git a/tools/src/main/kotlin/world/gregs/voidps/tools/definition/npc/NPCDefinitionPipeline.kt b/tools/src/main/kotlin/world/gregs/voidps/tools/definition/npc/NPCDefinitionPipeline.kt index d49e7f306..789315b72 100644 --- a/tools/src/main/kotlin/world/gregs/voidps/tools/definition/npc/NPCDefinitionPipeline.kt +++ b/tools/src/main/kotlin/world/gregs/voidps/tools/definition/npc/NPCDefinitionPipeline.kt @@ -25,7 +25,7 @@ import java.time.Month import java.util.concurrent.TimeUnit object NPCDefinitionPipeline { - private const val debugId = -1 + private const val DEBUG_ID = -1 @JvmStatic fun main(args: Array) { @@ -58,7 +58,7 @@ object NPCDefinitionPipeline { "infobox npc" to "id" ), "oldschool.runescape.wiki", - false// OSRS id's are scrambled :( + false// OSRS ids are scrambled :( ) { content, page, _ -> content.osrs = page }) @@ -85,7 +85,7 @@ object NPCDefinitionPipeline { val incomplete = mutableListOf() for (id in decoder.indices) { - if (debugId >= 0 && id != debugId) { + if (DEBUG_ID >= 0 && id != DEBUG_ID) { continue } val def = decoder.getOrNull(id) ?: continue @@ -123,7 +123,7 @@ object NPCDefinitionPipeline { add(InfoBoxNPC(revision, infoboxes)) } for (id in decoder.indices) { - if (debugId >= 0 && id != debugId) { + if (DEBUG_ID >= 0 && id != DEBUG_ID) { continue } val def = decoder.getOrNull(id) ?: continue diff --git a/tools/src/main/kotlin/world/gregs/voidps/tools/definition/npc/pipe/wiki/InfoBoxNPC.kt b/tools/src/main/kotlin/world/gregs/voidps/tools/definition/npc/pipe/wiki/InfoBoxNPC.kt index 9095034fc..526472633 100644 --- a/tools/src/main/kotlin/world/gregs/voidps/tools/definition/npc/pipe/wiki/InfoBoxNPC.kt +++ b/tools/src/main/kotlin/world/gregs/voidps/tools/definition/npc/pipe/wiki/InfoBoxNPC.kt @@ -40,7 +40,7 @@ class InfoBoxNPC(val revision: LocalDate, private val infoboxes: List) : val text = (value as String).replace("dg", "dungeoneering") val use = if (text == "removed") { val removal = template["removal"] as? String - if (removal == null || removal.isBlank() || LocalDate.parse(removeLinks(removal), InfoBoxItem.formatter).isBefore(revision)) { + if (removal.isNullOrBlank() || LocalDate.parse(removeLinks(removal), InfoBoxItem.formatter).isBefore(revision)) { ItemUse.Removed } else { ItemUse.Surface diff --git a/tools/src/main/kotlin/world/gregs/voidps/tools/definition/obj/pipe/ObjectDoorsGates.kt b/tools/src/main/kotlin/world/gregs/voidps/tools/definition/obj/pipe/ObjectDoorsGates.kt index 4cf6ad055..2ecbc8335 100644 --- a/tools/src/main/kotlin/world/gregs/voidps/tools/definition/obj/pipe/ObjectDoorsGates.kt +++ b/tools/src/main/kotlin/world/gregs/voidps/tools/definition/obj/pipe/ObjectDoorsGates.kt @@ -108,7 +108,7 @@ class ObjectDoorsGates(private val decoder: Array) : Pipel @JvmStatic fun main(args: Array) { val cache = CacheDelegate("./data/cache") - val decoder = ObjectDecoderFull(false, true).load(cache) + val decoder = ObjectDecoderFull(members = false, lowDetail = true).load(cache) val gates = ObjectDoorsGates(decoder) val match = gates.match(decoder[45849]) println("Match $match") diff --git a/tools/src/main/kotlin/world/gregs/voidps/tools/map/MissingMapFinder.kt b/tools/src/main/kotlin/world/gregs/voidps/tools/map/MissingMapFinder.kt index 1d34624ad..9800f0dbd 100644 --- a/tools/src/main/kotlin/world/gregs/voidps/tools/map/MissingMapFinder.kt +++ b/tools/src/main/kotlin/world/gregs/voidps/tools/map/MissingMapFinder.kt @@ -31,12 +31,12 @@ object MissingMapFinder { } private val results = temp.resolve("results") - private const val revision = 634 + private const val REVISION = 634 /** * Prints out only for caches which exist */ - private const val showExistingOnly = false + private const val SHOW_EXISTING_ONLY = false /** * Specify compatible revisions to search within @@ -51,8 +51,8 @@ object MissingMapFinder { .filter { c -> c.game == "runescape" && c.language == "en" } println("Found ${caches.size} cache revisions.") val target = caches - .first { c -> c.builds.any { build -> build["major"] == revision } } - println("Identified $target for revision $revision") + .first { c -> c.builds.any { build -> build["major"] == REVISION } } + println("Identified $target for revision $REVISION") val xteas = getKeys(target) println("Loaded ${xteas.size} keys.") @@ -60,7 +60,7 @@ object MissingMapFinder { println("Identified ${invalids.size} invalid maps in cache.") val index = caches.indexOf(target) - println("Target revision: $revision") + println("Target revision: $REVISION") for (i in caches.indices) { search(caches, index + i, invalids) search(caches, index - i, invalids) @@ -68,8 +68,8 @@ object MissingMapFinder { val directory = temp.resolve("caches/") for ((region, list) in found) { - val sorted = list.sortedByDescending { majorVersion(it.first).compareTo(revision) } - if (showExistingOnly) { + val sorted = list.sortedByDescending { majorVersion(it.first).compareTo(REVISION) } + if (SHOW_EXISTING_ONLY) { val remaining = sorted.filter { directory.resolve("cache-${it.first.id}/").exists() } print(region, remaining) } else { diff --git a/tools/src/main/kotlin/world/gregs/voidps/tools/map/obj/ObjectIdentifier.kt b/tools/src/main/kotlin/world/gregs/voidps/tools/map/obj/ObjectIdentifier.kt index 50955ebf5..769394e60 100644 --- a/tools/src/main/kotlin/world/gregs/voidps/tools/map/obj/ObjectIdentifier.kt +++ b/tools/src/main/kotlin/world/gregs/voidps/tools/map/obj/ObjectIdentifier.kt @@ -3,10 +3,10 @@ package world.gregs.voidps.tools.map.obj import world.gregs.voidps.engine.entity.obj.GameObject import world.gregs.voidps.engine.entity.obj.GameObjects import world.gregs.voidps.engine.get -import world.gregs.voidps.type.Tile -import world.gregs.voidps.type.equals import world.gregs.voidps.tools.map.obj.types.* import world.gregs.voidps.tools.map.view.graph.MutableNavigationGraph +import world.gregs.voidps.type.Tile +import world.gregs.voidps.type.equals import kotlin.system.exitProcess class ObjectIdentifier(private val linker: ObjectLinker, private val worldMapLinks: List>, val graph: MutableNavigationGraph) { @@ -28,6 +28,7 @@ class ObjectIdentifier(private val linker: ObjectLinker, private val worldMapLin return true } + @Suppress("UNCHECKED_CAST") fun compare(objects: List) { val interactiveObjects = objects.filter { it.def.options?.first() != null && @@ -46,7 +47,7 @@ class ObjectIdentifier(private val linker: ObjectLinker, private val worldMapLin val options = setOf( ObjectIdentification( "Ladder", - { interactiveOptions.minus(obj.getOptions()) }, + { interactiveOptions.minus(obj.getOptions().toSet()) }, listOf( sizeDifference, differenceBetweenNames, @@ -59,7 +60,7 @@ class ObjectIdentifier(private val linker: ObjectLinker, private val worldMapLin ), ObjectIdentification( "Stairs", - { interactiveOptions.minus(obj.getOptions()) }, + { interactiveOptions.minus(obj.getOptions().toSet()) }, listOf( sizeDifference, differenceBetweenNames, diff --git a/tools/src/main/kotlin/world/gregs/voidps/tools/map/obj/ObjectLinker.kt b/tools/src/main/kotlin/world/gregs/voidps/tools/map/obj/ObjectLinker.kt index 03962e12d..7ff7a2b69 100644 --- a/tools/src/main/kotlin/world/gregs/voidps/tools/map/obj/ObjectLinker.kt +++ b/tools/src/main/kotlin/world/gregs/voidps/tools/map/obj/ObjectLinker.kt @@ -1,11 +1,11 @@ package world.gregs.voidps.tools.map.obj -import world.gregs.voidps.type.Direction import world.gregs.voidps.engine.entity.obj.GameObject -import world.gregs.voidps.type.Delta -import world.gregs.voidps.type.Tile import world.gregs.voidps.engine.map.collision.Collisions import world.gregs.voidps.engine.map.collision.check +import world.gregs.voidps.type.Delta +import world.gregs.voidps.type.Direction +import world.gregs.voidps.type.Tile class ObjectLinker(private val collisions: Collisions) { fun deltaBetween(one: GameObject, two: GameObject): Delta? { @@ -92,7 +92,7 @@ class ObjectLinker(private val collisions: Collisions) { } fun isReachable(obj: GameObject): Boolean { - for (dir in Direction.values()) { + for (dir in Direction.entries) { val tile = getSizedTile(obj, dir) when (dir) { diff --git a/tools/src/main/kotlin/world/gregs/voidps/tools/map/render/draw/ObjectPainter.kt b/tools/src/main/kotlin/world/gregs/voidps/tools/map/render/draw/ObjectPainter.kt index 19a683fcb..1d647f893 100644 --- a/tools/src/main/kotlin/world/gregs/voidps/tools/map/render/draw/ObjectPainter.kt +++ b/tools/src/main/kotlin/world/gregs/voidps/tools/map/render/draw/ObjectPainter.kt @@ -162,7 +162,7 @@ class ObjectPainter( } } - internal fun MapSceneDefinition.method1606(i: Int, bool: Boolean): IndexedSprite? { + internal fun MapSceneDefinition.method1606(setting: Int, bool: Boolean): IndexedSprite? { val image = spriteDefinitions[sprite].sprites?.first() if (image != null) { image.offsetY = 0 @@ -172,7 +172,7 @@ class ObjectPainter( if (bool) { image.method4189() } - for (i_1_ in 0 until i) + for (i in 0 until setting) image.method4198() } return image @@ -191,7 +191,7 @@ class ObjectPainter( val localY = obj.y val rotation = obj.rotation val type = obj.shape - val bool_65_ = definition.animations == null && definition.transforms == null && !definition.aBoolean2998 && !definition.aBoolean2992 + val bool65 = definition.animations == null && definition.transforms == null && !definition.aBoolean2998 && !definition.aBoolean2992 val baseX = (offsetX * 64) + localX val baseY = (offsetY * 64) + localY if (type == 22) { @@ -210,7 +210,7 @@ class ObjectPainter( } else if (type == 1) { drawWall(g, definition, baseX, baseY, type, rotation) } else if (type == 2) { - drawWall(g, definition, baseX, baseY, type, rotation + if (!bool_65_) 4 else 0) + drawWall(g, definition, baseX, baseY, type, rotation + if (!bool65) 4 else 0) } else if (type == 3) { drawWall(g, definition, baseX, baseY, type, rotation) } else if (type == 9) { @@ -233,30 +233,30 @@ class ObjectPainter( val bs = raster if (alpha == null) { for (i in (height shr 1) - 1 downTo 0) { - var i_24_ = i * width - var i_25_ = (height - i - 1) * width - for (i_26_ in -width..-1) { - val b = bs[i_24_] - bs[i_24_] = bs[i_25_] - bs[i_25_] = b - i_24_++ - i_25_++ + var i24 = i * width + var i25 = (height - i - 1) * width + for (index in -width..-1) { + val b = bs[i24] + bs[i24] = bs[i25] + bs[i25] = b + i24++ + i25++ } } } else { - val bs_27_ = alpha + val alpha = alpha for (i in (height shr 1) - 1 downTo 0) { - var i_28_ = i * width - var i_29_ = (height - i - 1) * width - for (i_30_ in -width..-1) { - var b = bs[i_28_] - bs[i_28_] = bs[i_29_] - bs[i_29_] = b - b = bs_27_!![i_28_] - bs_27_[i_28_] = bs_27_[i_29_] - bs_27_[i_29_] = b - i_28_++ - i_29_++ + var i28 = i * width + var i29 = (height - i - 1) * width + for (i30 in -width..-1) { + var b = bs[i28] + bs[i28] = bs[i29] + bs[i29] = b + b = alpha!![i28] + alpha[i28] = alpha[i29] + alpha[i29] = b + i28++ + i29++ } } } @@ -269,29 +269,29 @@ class ObjectPainter( val bs = ByteArray(width * height) var i = 0 if (alpha == null) { - for (i_95_ in 0 until width) { - for (i_96_ in height - 1 downTo 0) - bs[i++] = raster[i_95_ + i_96_ * width] + for (j in 0 until width) { + for (k in height - 1 downTo 0) + bs[i++] = raster[j + k * width] } raster = bs } else { - val bs_97_ = ByteArray(width * height) - for (i_98_ in 0 until width) { - for (i_99_ in height - 1 downTo 0) { - bs[i] = raster[i_98_ + i_99_ * width] - bs_97_[i++] = alpha!![i_98_ + i_99_ * width] + val bytes = ByteArray(width * height) + for (j in 0 until width) { + for (k in height - 1 downTo 0) { + bs[i] = raster[j + k * width] + bytes[i++] = alpha!![j + k * width] } } raster = bs - alpha = bs_97_ + alpha = bytes } offsetY = offsetX offsetX = deltaHeight deltaHeight = deltaWidth deltaWidth = offsetY - val i_100_: Int = height + val temp: Int = height height = width - width = i_100_ + width = temp } companion object { diff --git a/tools/src/main/kotlin/world/gregs/voidps/tools/map/render/draw/TileLevel.kt b/tools/src/main/kotlin/world/gregs/voidps/tools/map/render/draw/TileLevel.kt index fc2db8e17..b90cec2e7 100644 --- a/tools/src/main/kotlin/world/gregs/voidps/tools/map/render/draw/TileLevel.kt +++ b/tools/src/main/kotlin/world/gregs/voidps/tools/map/render/draw/TileLevel.kt @@ -3,7 +3,7 @@ package world.gregs.voidps.tools.map.render.draw import world.gregs.voidps.cache.definition.data.MapDefinition import world.gregs.voidps.cache.definition.data.MapTile import world.gregs.voidps.cache.definition.data.TextureDefinition -import world.gregs.voidps.tools.map.render.load.MapConstants.size +import world.gregs.voidps.tools.map.render.load.MapConstants.SIZE import world.gregs.voidps.tools.map.render.load.MapTileSettings import world.gregs.voidps.tools.map.render.model.TextureColours import world.gregs.voidps.tools.map.render.model.TileColours @@ -30,18 +30,18 @@ class TileLevel( private var lightZ: Int = 0 var settings: Int = 0 - private fun setBrightness(f_246_: Float, f_247_: Float, f_248_: Float) { - val f_249_ = sqrt((f_246_ * f_246_ + f_247_ * f_247_ + f_248_ * f_248_).toDouble()).toFloat() - lightX = (f_246_ * 65535.0f / f_249_).toInt()// -36578 - lightY = (f_247_ * 65535.0f / f_249_).toInt()// -40235 - lightZ = (f_248_ * 65535.0f / f_249_).toInt()// -36578 + private fun setBrightness(brightnessX: Float, brightnessY: Float, brightnessZ: Float) { + val total = sqrt((brightnessX * brightnessX + brightnessY * brightnessY + brightnessZ * brightnessZ).toDouble()).toFloat() + lightX = (brightnessX * 65535.0f / total).toInt()// -36578 + lightY = (brightnessY * 65535.0f / total).toInt()// -40235 + lightZ = (brightnessZ * 65535.0f / total).toInt()// -36578 } fun loadBrightness() { tileColours = null textureColours = null setBrightness(-200f, -220f, -200f) - val brightness: Int = brightness shr 9 + val brightness: Int = BRIGHTNESS shr 9 for (y in 1 until height) { for (x in 1 until width) { var intensity = brightness @@ -150,17 +150,17 @@ class TileLevel( if (colours.textureId.toInt() != -1 && colours.type.toInt() and 0x2 == 0 && colours.initialColourIndex == -1) { val texture = textureColour(colours.textureId.toInt()) // water - raster.drawGouraudTriangle(x - size, x - size, x, y + size, y, y + size, light(colours.northEastColourIndex.toInt() and 0xffff, texture), light(colours.northColourIndex.toInt() and 0xffff, texture), light(colours.eastColourIndex.toInt() and 0xffff, texture)) - raster.drawGouraudTriangle(x, x, x - size, y, y + size, y, light(colours.middleColourIndex.toInt() and 0xffff, texture), light(colours.eastColourIndex.toInt() and 0xffff, texture), light(colours.northColourIndex.toInt() and 0xffff, texture)) + raster.drawGouraudTriangle(x - SIZE, x - SIZE, x, y + SIZE, y, y + SIZE, light(colours.northEastColourIndex.toInt() and 0xffff, texture), light(colours.northColourIndex.toInt() and 0xffff, texture), light(colours.eastColourIndex.toInt() and 0xffff, texture)) + raster.drawGouraudTriangle(x, x, x - SIZE, y, y + SIZE, y, light(colours.middleColourIndex.toInt() and 0xffff, texture), light(colours.eastColourIndex.toInt() and 0xffff, texture), light(colours.northColourIndex.toInt() and 0xffff, texture)) } else if (colours.initialColourIndex == -1) { // normal tiles - raster.drawGouraudTriangle(x - size, x - size, x, y + size, y, y + size, colours.northEastColourIndex.toInt() and 0xffff, colours.northColourIndex.toInt() and 0xffff, colours.eastColourIndex.toInt() and 0xffff) - raster.drawGouraudTriangle(x, x, x - size, y, y + size, y, colours.middleColourIndex.toInt() and 0xffff, colours.eastColourIndex.toInt() and 0xffff, colours.northColourIndex.toInt() and 0xffff) + raster.drawGouraudTriangle(x - SIZE, x - SIZE, x, y + SIZE, y, y + SIZE, colours.northEastColourIndex.toInt() and 0xffff, colours.northColourIndex.toInt() and 0xffff, colours.eastColourIndex.toInt() and 0xffff) + raster.drawGouraudTriangle(x, x, x - SIZE, y, y + SIZE, y, colours.middleColourIndex.toInt() and 0xffff, colours.eastColourIndex.toInt() and 0xffff, colours.northColourIndex.toInt() and 0xffff) } else { // overlay val brightness = colours.initialColourIndex - raster.drawGouraudTriangle(x - size, x - size, x, y + size, y, y + size, brightness, brightness, brightness) - raster.drawGouraudTriangle(x, x, x - size, y, y + size, y, brightness, brightness, brightness) + raster.drawGouraudTriangle(x - SIZE, x - SIZE, x, y + SIZE, y, y + SIZE, brightness, brightness, brightness) + raster.drawGouraudTriangle(x, x, x - SIZE, y, y + SIZE, y, brightness, brightness, brightness) } } else if (textureColours?.get(localX)?.get(localY) != null) { val colours = textureColours!![localX][localY]!! @@ -169,8 +169,8 @@ class TileLevel( yOffsets = IntArray(height) } for (index in 0 until colours.size) { - xOffsets[index] = y + colours.xOffsets!![index] * size / tileUnits - yOffsets[index] = x - colours.yOffsets!![index] * size / tileUnits + xOffsets[index] = y + colours.xOffsets!![index] * SIZE / tileUnits + yOffsets[index] = x - colours.yOffsets!![index] * SIZE / tileUnits } for (index in 0 until colours.count) { val i1 = colours.vertexIndices1!![index].toInt() @@ -229,10 +229,10 @@ class TileLevel( } } } - x -= size + x -= SIZE } x = actualWidth - y += size + y += SIZE } } @@ -257,9 +257,9 @@ class TileLevel( var ignore = false if (colours.size == 2 && vertexIndices1.size == 2 && (colours[0] == colours[1] || textures[0] != -1 && textures[0] == textures[1])) { ignore = true - for (i_326_ in 1..1) { - val xOffset = xOffsets[vertexIndices1[i_326_]] - val yOffset = yOffsets[vertexIndices1[i_326_]] + for (i in 1..1) { + val xOffset = xOffsets[vertexIndices1[i]] + val yOffset = yOffsets[vertexIndices1[i]] if (xOffset != 0 && xOffset != tileUnits || yOffset != 0 && yOffset != tileUnits) { ignore = false break @@ -410,6 +410,6 @@ class TileLevel( tileScale = scale } - private const val brightness = 75518 + private const val BRIGHTNESS = 75518 } } \ No newline at end of file diff --git a/tools/src/main/kotlin/world/gregs/voidps/tools/map/render/load/MapConstants.kt b/tools/src/main/kotlin/world/gregs/voidps/tools/map/render/load/MapConstants.kt index 66141f94a..ec8367d56 100644 --- a/tools/src/main/kotlin/world/gregs/voidps/tools/map/render/load/MapConstants.kt +++ b/tools/src/main/kotlin/world/gregs/voidps/tools/map/render/load/MapConstants.kt @@ -20,15 +20,15 @@ object MapConstants { BooleanArray(13) ) - const val size = 4 + const val SIZE = 4 - const val tileWater = false - const val tileLighting = false - const val sceneryShadows = -1 - const val groundBlending = -1 - const val aBoolean8715 = true - const val aBoolean10563 = false - const val waterMovement = false// method2810 + const val TILE_WATER = false + const val TILE_LIGHTING = false + const val SCENERY_SHADOWS = -1 + const val GROUND_BLENDING = -1 + const val A_BOOLEAN_8715 = true + const val A_BOOLEAN_10563 = false + const val WATER_MOVEMENT = false// method2810 val tileYOffsets = intArrayOf(0, 0, 0, 256, 512, 512, 512, 256, 256, 384, 128, 128, 256) val tileXOffsets = intArrayOf(0, 256, 512, 512, 512, 256, 0, 0, 128, 256, 128, 384, 256) diff --git a/tools/src/main/kotlin/world/gregs/voidps/tools/map/render/load/MapTileSettings.kt b/tools/src/main/kotlin/world/gregs/voidps/tools/map/render/load/MapTileSettings.kt index 931b5a83b..982b22260 100644 --- a/tools/src/main/kotlin/world/gregs/voidps/tools/map/render/load/MapTileSettings.kt +++ b/tools/src/main/kotlin/world/gregs/voidps/tools/map/render/load/MapTileSettings.kt @@ -5,16 +5,16 @@ import world.gregs.voidps.cache.config.data.UnderlayDefinition import world.gregs.voidps.cache.definition.data.MapTile import world.gregs.voidps.cache.definition.data.TextureDefinition import world.gregs.voidps.tools.map.render.draw.TileLevel +import world.gregs.voidps.tools.map.render.load.MapConstants.GROUND_BLENDING import world.gregs.voidps.tools.map.render.load.MapConstants.TILE_TYPE_HEIGHT_OVERRIDE +import world.gregs.voidps.tools.map.render.load.MapConstants.WATER_MOVEMENT import world.gregs.voidps.tools.map.render.load.MapConstants.firstTileTypeVertices -import world.gregs.voidps.tools.map.render.load.MapConstants.groundBlending import world.gregs.voidps.tools.map.render.load.MapConstants.overlaySizes import world.gregs.voidps.tools.map.render.load.MapConstants.secondTileTypeVertices import world.gregs.voidps.tools.map.render.load.MapConstants.thirdTileTypeVertices import world.gregs.voidps.tools.map.render.load.MapConstants.tileXOffsets import world.gregs.voidps.tools.map.render.load.MapConstants.tileYOffsets import world.gregs.voidps.tools.map.render.load.MapConstants.underlaySizes -import world.gregs.voidps.tools.map.render.load.MapConstants.waterMovement import world.gregs.voidps.tools.map.render.raster.ColourPalette import world.gregs.voidps.type.Region @@ -62,26 +62,26 @@ class MapTileSettings( } private fun loadSettings() = level.forEach { level -> - var i_23_ = 0 + var flag = 0 var settings = 0 - if (!waterMovement) { - if (MapConstants.tileWater) { + if (!WATER_MOVEMENT) { + if (MapConstants.TILE_WATER) { settings = settings or 0x8 } - if (MapConstants.tileLighting) { - i_23_ = i_23_ or 0x2 + if (MapConstants.TILE_LIGHTING) { + flag = flag or 0x2 } - if (MapConstants.sceneryShadows != 0) { - i_23_ = i_23_ or 0x1 - if ((level.level == 0) or MapConstants.aBoolean8715) { + if (MapConstants.SCENERY_SHADOWS != 0) { + flag = flag or 0x1 + if ((level.level == 0) or MapConstants.A_BOOLEAN_8715) { settings = settings or 0x10 } } } - if (MapConstants.tileLighting) { + if (MapConstants.TILE_LIGHTING) { settings = settings or 0x7 } - if (!MapConstants.aBoolean10563) { + if (!MapConstants.A_BOOLEAN_10563) { settings = settings or 0x20 } level.loadBrightness() @@ -161,7 +161,7 @@ class MapTileSettings( private fun loadTileVertices(level: Int, parentColours: Array, aboveLevel: TileLevel?, tileLevel: TileLevel) { for (x in 0 until width) { for (y in 0 until height) { - if (groundBlending == -1 || useUnderlay(x, y, groundBlending, level)) { + if (GROUND_BLENDING == -1 || useUnderlay(x, y, GROUND_BLENDING, level)) { val tile = tile(level, x, y) var tileType = tile.overlayPath val tileDirection = tile.overlayRotation diff --git a/tools/src/main/kotlin/world/gregs/voidps/tools/map/render/raster/ColourPalette.kt b/tools/src/main/kotlin/world/gregs/voidps/tools/map/render/raster/ColourPalette.kt index 2d86cda34..d5d73dc2f 100644 --- a/tools/src/main/kotlin/world/gregs/voidps/tools/map/render/raster/ColourPalette.kt +++ b/tools/src/main/kotlin/world/gregs/voidps/tools/map/render/raster/ColourPalette.kt @@ -18,42 +18,42 @@ object ColourPalette { var normalisedRed = 0.0f var normalisedGreen = 0.0f var normalisedBlue = 0.0f - val f_10_ = hue / 60.0f - val i_11_ = f_10_.toInt() - val type = i_11_ % 6 - val f_13_ = f_10_ - i_11_.toFloat() + val f10 = hue / 60.0f + val i11 = f10.toInt() + val type = i11 % 6 + val f13 = f10 - i11.toFloat() val chroma = value * (-saturation + 1.0f) - val f_15_ = value * (-(f_13_ * saturation) + 1.0f) - val f_16_ = (1.0f - saturation * (-f_13_ + 1.0f)) * value + val f15 = value * (-(f13 * saturation) + 1.0f) + val f16 = (1.0f - saturation * (-f13 + 1.0f)) * value when (type) { 0 -> { normalisedRed = value normalisedBlue = chroma - normalisedGreen = f_16_ + normalisedGreen = f16 } 1 -> { normalisedBlue = chroma - normalisedRed = f_15_ + normalisedRed = f15 normalisedGreen = value } 2 -> { normalisedRed = chroma normalisedGreen = value - normalisedBlue = f_16_ + normalisedBlue = f16 } 3 -> { - normalisedGreen = f_15_ + normalisedGreen = f15 normalisedRed = chroma normalisedBlue = value } 4 -> { normalisedBlue = value - normalisedRed = f_16_ + normalisedRed = f16 normalisedGreen = chroma } 5 -> { normalisedGreen = chroma - normalisedBlue = f_15_ + normalisedBlue = f15 normalisedRed = value } } diff --git a/tools/src/main/kotlin/world/gregs/voidps/tools/map/view/draw/MapView.kt b/tools/src/main/kotlin/world/gregs/voidps/tools/map/view/draw/MapView.kt index ecb6a93f3..b85b96028 100644 --- a/tools/src/main/kotlin/world/gregs/voidps/tools/map/view/draw/MapView.kt +++ b/tools/src/main/kotlin/world/gregs/voidps/tools/map/view/draw/MapView.kt @@ -46,16 +46,16 @@ class MapView(nav: NavigationGraph?, private val areaFile: String) : JPanel() { /* View bounds */ - val minX = debugBorder - val minY = debugBorder + val minX = DEBUG_BORDER + val minY = DEBUG_BORDER val maxX: Int - get() = width - debugBorder + get() = width - DEBUG_BORDER val maxY: Int - get() = height - debugBorder + get() = height - DEBUG_BORDER private val viewWidth: Int - get() = width - debugBorder * 2 + get() = width - DEBUG_BORDER * 2 private val viewHeight: Int - get() = height - debugBorder * 2 + get() = height - DEBUG_BORDER * 2 init { layout = FlowLayout(FlowLayout.LEFT) @@ -231,7 +231,7 @@ class MapView(nav: NavigationGraph?, private val areaFile: String) : JPanel() { // lc.draw(g) area.draw(g) - if (debugBorder > 0) { + if (DEBUG_BORDER > 0) { g.color = Color.RED g.drawRect(minX, minY, viewWidth, viewHeight) g.drawRect(getCentreX(), getCentreY(), 1, 1) @@ -244,6 +244,6 @@ class MapView(nav: NavigationGraph?, private val areaFile: String) : JPanel() { } companion object { - private const val debugBorder = 0 + private const val DEBUG_BORDER = 0 } } \ No newline at end of file diff --git a/tools/src/main/kotlin/world/gregs/voidps/tools/map/view/draw/WorldMap.kt b/tools/src/main/kotlin/world/gregs/voidps/tools/map/view/draw/WorldMap.kt index 7ad4a39f9..78419367c 100644 --- a/tools/src/main/kotlin/world/gregs/voidps/tools/map/view/draw/WorldMap.kt +++ b/tools/src/main/kotlin/world/gregs/voidps/tools/map/view/draw/WorldMap.kt @@ -24,10 +24,10 @@ class WorldMap(private val view: MapView) { val minY = minRegionY val maxX = maxRegionX val maxY = maxRegionY - minRegionX = view.viewToRegionX(view.minX).coerceAtLeast(mapRegionMinX) - minRegionY = view.viewToRegionY(view.minY).coerceAtLeast(mapRegionMinY) - maxRegionX = view.viewToRegionX(view.maxX).coerceAtMost(mapRegionMaxX) - maxRegionY = view.viewToRegionY(view.maxY).coerceAtMost(mapRegionMaxY) + minRegionX = view.viewToRegionX(view.minX).coerceAtLeast(MAP_REGION_MIN_X) + minRegionY = view.viewToRegionY(view.minY).coerceAtLeast(MAP_REGION_MIN_Y) + maxRegionX = view.viewToRegionX(view.maxX).coerceAtMost(MAP_REGION_MAX_X) + maxRegionY = view.viewToRegionY(view.maxY).coerceAtMost(MAP_REGION_MAX_Y) if (minRegionX > minX) { regions.remove(minX until min(minRegionX, maxX), minY..maxY) @@ -69,11 +69,11 @@ class WorldMap(private val view: MapView) { } companion object { - private const val mapRegionMinX = 0 - private const val mapRegionMinY = 0 - private const val mapRegionMaxX = 256 - private const val mapRegionMaxY = 256 + private const val MAP_REGION_MIN_X = 0 + private const val MAP_REGION_MIN_Y = 0 + private const val MAP_REGION_MAX_X = 256 + private const val MAP_REGION_MAX_Y = 256 - fun flipRegionY(regionY: Int) = mapRegionMaxY - regionY + fun flipRegionY(regionY: Int) = MAP_REGION_MAX_Y - regionY } } \ No newline at end of file diff --git a/tools/src/main/kotlin/world/gregs/voidps/tools/map/view/graph/AreaSet.kt b/tools/src/main/kotlin/world/gregs/voidps/tools/map/view/graph/AreaSet.kt index d65f4f5ba..9f6d29653 100644 --- a/tools/src/main/kotlin/world/gregs/voidps/tools/map/view/graph/AreaSet.kt +++ b/tools/src/main/kotlin/world/gregs/voidps/tools/map/view/graph/AreaSet.kt @@ -8,7 +8,7 @@ import world.gregs.yaml.Yaml class AreaSet { val areas = mutableSetOf() - var changed = false + private var changed = false fun getPointOrNull(x: Int, y: Int, z: Int): Point? { for (area in areas) { @@ -65,6 +65,7 @@ class AreaSet { // writer.writeValue(File(path), set.areas) } + @Suppress("UNCHECKED_CAST") fun load(yaml: Yaml, path: String = "./areas.yml"): AreaSet { val set = AreaSet() val map = yaml.load>>(path) diff --git a/tools/src/main/kotlin/world/gregs/voidps/tools/map/view/graph/MutableNavigationGraph.kt b/tools/src/main/kotlin/world/gregs/voidps/tools/map/view/graph/MutableNavigationGraph.kt index 5a155a1f6..8e51f4a6d 100644 --- a/tools/src/main/kotlin/world/gregs/voidps/tools/map/view/graph/MutableNavigationGraph.kt +++ b/tools/src/main/kotlin/world/gregs/voidps/tools/map/view/graph/MutableNavigationGraph.kt @@ -87,6 +87,7 @@ class MutableNavigationGraph { yaml.save(path, graph.adjacencyList.mapKeys { it.key.id }) } + @Suppress("UNCHECKED_CAST") fun load(path: String = "./navgraph.json"): MutableNavigationGraph { val graph = MutableNavigationGraph() val map: Map>> = yaml.load(path) diff --git a/tools/src/main/kotlin/world/gregs/voidps/tools/wiki/MusicInfoBoxDumper.kt b/tools/src/main/kotlin/world/gregs/voidps/tools/wiki/MusicInfoBoxDumper.kt index bee28651c..9d6aa51c1 100644 --- a/tools/src/main/kotlin/world/gregs/voidps/tools/wiki/MusicInfoBoxDumper.kt +++ b/tools/src/main/kotlin/world/gregs/voidps/tools/wiki/MusicInfoBoxDumper.kt @@ -15,6 +15,7 @@ import java.time.LocalDate import java.time.Month import java.time.format.DateTimeFormatter +@Suppress("UNCHECKED_CAST") object MusicInfoBoxDumper { @JvmStatic diff --git a/tools/src/main/kotlin/world/gregs/voidps/tools/wiki/RunescapeWikiPagesFullFilter.kt b/tools/src/main/kotlin/world/gregs/voidps/tools/wiki/RunescapeWikiPagesFullFilter.kt index 0d4ece1e9..ff39ad6f0 100644 --- a/tools/src/main/kotlin/world/gregs/voidps/tools/wiki/RunescapeWikiPagesFullFilter.kt +++ b/tools/src/main/kotlin/world/gregs/voidps/tools/wiki/RunescapeWikiPagesFullFilter.kt @@ -130,7 +130,7 @@ object RunescapeWikiPagesFullFilter { XMLStreamConstants.END_ELEMENT -> { when (event.asEndElement().name.localPart) { "namespaces" -> { - namespaces.removeAll(namespacesToDump.map { namespaceIndex[it] }) + namespaces.removeAll(namespacesToDump.map { namespaceIndex[it] }.toSet()) } "revision" -> { if (validRevision) { @@ -146,7 +146,7 @@ object RunescapeWikiPagesFullFilter { } } "page" -> { - if (!ignoreEmptyPages || mostRecentRevisionEvents.isNotEmpty()) { + if (!IGNORE_EMTPY_PAGES || mostRecentRevisionEvents.isNotEmpty()) { val pageClose = pageEvents.removeAt(pageEvents.lastIndex) var priorRedirect: String? = null pageEvents.forEach { event -> @@ -195,7 +195,7 @@ object RunescapeWikiPagesFullFilter { } } - private const val ignoreEmptyPages = true + private const val IGNORE_EMTPY_PAGES = true @JvmStatic fun main(args: Array) { diff --git a/tools/src/main/kotlin/world/gregs/voidps/tools/wiki/dialogue/Dialogue.kt b/tools/src/main/kotlin/world/gregs/voidps/tools/wiki/dialogue/Dialogue.kt index 256bd198a..329444049 100644 --- a/tools/src/main/kotlin/world/gregs/voidps/tools/wiki/dialogue/Dialogue.kt +++ b/tools/src/main/kotlin/world/gregs/voidps/tools/wiki/dialogue/Dialogue.kt @@ -73,6 +73,7 @@ internal data class Dialogue( text.replace("%", "").replace("[", "").replace("]", "").replace(";", "").replace("!", "").replace(":", "").replace("(", "").replace(")", "").replace("?", "").replace(",", "").replace("*", "").replace("'", "").toCamelCase() }()" + @Suppress("UNCHECKED_CAST") fun fromMap(map: Map, key: String) = Dialogue( key.toInt(), map["type"] as String, diff --git a/tools/src/main/kotlin/world/gregs/voidps/tools/wiki/dialogue/DialogueConverter.kt b/tools/src/main/kotlin/world/gregs/voidps/tools/wiki/dialogue/DialogueConverter.kt index 9f80354a3..1a2c4ecc3 100644 --- a/tools/src/main/kotlin/world/gregs/voidps/tools/wiki/dialogue/DialogueConverter.kt +++ b/tools/src/main/kotlin/world/gregs/voidps/tools/wiki/dialogue/DialogueConverter.kt @@ -11,6 +11,7 @@ import world.gregs.yaml.read.YamlReaderConfiguration import java.io.File import java.util.* +@Suppress("UNCHECKED_CAST") object DialogueConverter { data class DialogueOption( diff --git a/tools/src/main/kotlin/world/gregs/voidps/tools/wiki/dialogue/DialogueParsing.kt b/tools/src/main/kotlin/world/gregs/voidps/tools/wiki/dialogue/DialogueParsing.kt index 2cd1241ca..5a3e40c3d 100644 --- a/tools/src/main/kotlin/world/gregs/voidps/tools/wiki/dialogue/DialogueParsing.kt +++ b/tools/src/main/kotlin/world/gregs/voidps/tools/wiki/dialogue/DialogueParsing.kt @@ -11,6 +11,7 @@ import java.util.* * Parses dialogue yaml files into code to be queried * https://mega.nz/file/sJsRlDzI#E5U0ObIAz9CrAD2HWmJLaALdvrQyR2oaF2gcbWe5qVE */ +@Suppress("UNCHECKED_CAST") object DialogueParsing { private var printIds = false diff --git a/tools/src/main/kotlin/world/gregs/voidps/tools/wiki/dialogue/DialogueProcessing.kt b/tools/src/main/kotlin/world/gregs/voidps/tools/wiki/dialogue/DialogueProcessing.kt index 7a41c543f..34097226a 100644 --- a/tools/src/main/kotlin/world/gregs/voidps/tools/wiki/dialogue/DialogueProcessing.kt +++ b/tools/src/main/kotlin/world/gregs/voidps/tools/wiki/dialogue/DialogueProcessing.kt @@ -26,34 +26,34 @@ object DialogueProcessing { println(file.nameWithoutExtension) val readText = file.readText() val doc = Jsoup.parse(readText) - val title = doc.select("h2").first().text() + val title = doc.select("h2").first()!!.text() val type = title.take(title.indexOf(" (")) val tables = doc.select("table") - val nextRows = tables.first().select("a").map { + val nextRows = tables.first()!!.select("a").map { it.attr("href").removeSuffix(".html").toIntOrNull() ?: -1 } - val nextCountRows = tables.first().select("a").map { + val nextCountRows = tables.first()!!.select("a").map { it.text().toInt() } - val previousRows = tables.last().select("a").map { + val previousRows = tables.last()!!.select("a").map { it.attr("href").removeSuffix(".html").toIntOrNull() ?: -1 } - val previousCountRows = tables.last().select("a").map { + val previousCountRows = tables.last()!!.select("a").map { it.text().toInt() } when (type) { "DIALOGUE_OPTIONS" -> { - val list = doc.select("ol").first().select("li") + val list = doc.select("ol").first()!!.select("li") val options = list.mapNotNull { if (it.hasText()) it.text() else null } val id = file.nameWithoutExtension contents[id] = Dialogue(id.toInt(), type, nextRows, nextCountRows, previousRows, previousCountRows, options) } "DIALOGUE_PLAYER", "DIALOGUE_NPC" -> { - val text = doc.select("p").first() + val text = doc.select("p").first()!! val name = text.select("b").text() val dialogue = text.text().removePrefix("$name:").trim() val id = file.nameWithoutExtension @@ -75,7 +75,7 @@ object DialogueProcessing { private fun npcs(folder: File) { val yamlFile = folder.resolve("npcs.yaml") - val files = folder.resolve("npcs").listFiles() + val files = folder.resolve("npcs").listFiles()!! val npcs = mutableMapOf>() for (file in files) { npcs[file.nameWithoutExtension] = Jsoup.parse(file.readText()).select("a").map { it.attr("href").removePrefix("../content/").removeSuffix(".html").toInt() } diff --git a/tools/src/main/kotlin/world/gregs/voidps/tools/wiki/model/WikiPage.kt b/tools/src/main/kotlin/world/gregs/voidps/tools/wiki/model/WikiPage.kt index a247be492..5a008cc64 100644 --- a/tools/src/main/kotlin/world/gregs/voidps/tools/wiki/model/WikiPage.kt +++ b/tools/src/main/kotlin/world/gregs/voidps/tools/wiki/model/WikiPage.kt @@ -11,6 +11,7 @@ import org.sweble.wikitext.parser.nodes.* import org.w3c.dom.Node import world.gregs.voidps.tools.wiki.model.Wiki.Companion.getChildren +@Suppress("UNCHECKED_CAST") data class WikiPage( val title: String, val namespace: WikiNamespace, diff --git a/tools/src/main/kotlin/world/gregs/voidps/tools/wiki/scrape/GrandExchangeDetailDumper.kt b/tools/src/main/kotlin/world/gregs/voidps/tools/wiki/scrape/GrandExchangeDetailDumper.kt index 945f20dac..f3f9aeacf 100644 --- a/tools/src/main/kotlin/world/gregs/voidps/tools/wiki/scrape/GrandExchangeDetailDumper.kt +++ b/tools/src/main/kotlin/world/gregs/voidps/tools/wiki/scrape/GrandExchangeDetailDumper.kt @@ -27,6 +27,7 @@ object GrandExchangeDetailDumper { println("Dumping $id") file.appendText("${apiResponse},") } catch (e: FileNotFoundException) { + e.printStackTrace() } delay(100L) } diff --git a/tools/src/main/kotlin/world/gregs/voidps/tools/wiki/scrape/MonsterInfoBoxDumper.kt b/tools/src/main/kotlin/world/gregs/voidps/tools/wiki/scrape/MonsterInfoBoxDumper.kt index 147af90d9..7bd16b2f4 100644 --- a/tools/src/main/kotlin/world/gregs/voidps/tools/wiki/scrape/MonsterInfoBoxDumper.kt +++ b/tools/src/main/kotlin/world/gregs/voidps/tools/wiki/scrape/MonsterInfoBoxDumper.kt @@ -88,7 +88,7 @@ object MonsterInfoBoxDumper { } val aka = infobox["aka"] as? String if (aka != null) { - println(" aka: [ ${aka} ]") + println(" aka: [ $aka ]") } val respawn = infobox["respawn"] as? String ?: infobox["respawn$version"] as? String if (respawn != null) { diff --git a/tools/src/main/kotlin/world/gregs/voidps/tools/wiki/scrape/RunescapeWikiAutoExporter.kt b/tools/src/main/kotlin/world/gregs/voidps/tools/wiki/scrape/RunescapeWikiAutoExporter.kt index ce4bf64c9..eff52b934 100644 --- a/tools/src/main/kotlin/world/gregs/voidps/tools/wiki/scrape/RunescapeWikiAutoExporter.kt +++ b/tools/src/main/kotlin/world/gregs/voidps/tools/wiki/scrape/RunescapeWikiAutoExporter.kt @@ -2,6 +2,7 @@ package world.gregs.voidps.tools.wiki.scrape import world.gregs.voidps.tools.wiki.model.Wiki +@Suppress("UNCHECKED_CAST") internal object RunescapeWikiAutoExporter { @JvmStatic diff --git a/tools/src/main/kotlin/world/gregs/voidps/tools/wiki/scrape/RunescapeWikiModifier.kt b/tools/src/main/kotlin/world/gregs/voidps/tools/wiki/scrape/RunescapeWikiModifier.kt index ca5f00e87..33fd0ac56 100644 --- a/tools/src/main/kotlin/world/gregs/voidps/tools/wiki/scrape/RunescapeWikiModifier.kt +++ b/tools/src/main/kotlin/world/gregs/voidps/tools/wiki/scrape/RunescapeWikiModifier.kt @@ -95,6 +95,7 @@ internal object RunescapeWikiModifier { save(output.toSortedMap(), "Items667") } + @Suppress("UNCHECKED_CAST") private fun identifyMissingIds( raw: MutableMap>, decoder: Array, @@ -128,7 +129,7 @@ internal object RunescapeWikiModifier { } } - fun MutableMap.replaceMultilines(key: String) { + private fun MutableMap.replaceMultilines(key: String) { val value = this[key] as? String ?: "?" if (value.contains("•")) { val parts = value.split("•") @@ -143,9 +144,9 @@ internal object RunescapeWikiModifier { } } - val exceptions = setOf("incense", "warning", "size:", "village:", "clairvoyance:", "disclaimer:", "bonus:", "incubator:", "parts:", "says:", "pork:", "danger:") + private val exceptions = setOf("incense", "warning", "size:", "village:", "clairvoyance:", "disclaimer:", "bonus:", "incubator:", "parts:", "says:", "pork:", "danger:") - fun MutableMap.replaceBool(key: String, default: Boolean) { + private fun MutableMap.replaceBool(key: String, default: Boolean) { val value = remove(key) as? String ?: "?" if (value != "?") { when (value) { @@ -166,7 +167,7 @@ internal object RunescapeWikiModifier { } } - fun MutableMap.trimWeight() { + private fun MutableMap.trimWeight() { val weight = this["Weight"] as? String ?: "?" if (weight != "?") { val kg = weight.removeSuffix(" kg").toDoubleOrNull() @@ -181,7 +182,7 @@ internal object RunescapeWikiModifier { } } - fun MutableMap.formatInt(key: String) { + private fun MutableMap.formatInt(key: String) { val value = this[key] as? String ?: "?" if (value != "?") { val kg = value.replace(",", "").toIntOrNull() @@ -196,14 +197,14 @@ internal object RunescapeWikiModifier { } } - fun MutableMap.updateDestroy() { + private fun MutableMap.updateDestroy() { val key = "Destroy" var value = this[key] as? String ?: return value = value.replace(" (It is immediately removed from your inventory)", "") this[key] = value } - fun MutableMap.updateExamines() { + private fun MutableMap.updateExamines() { val key = "Examine" var value = this[key] as? String ?: return value = value.replace("improved to be held in the off-hand.", "improved") @@ -225,7 +226,7 @@ internal object RunescapeWikiModifier { this[key] = value.trim() } - val examineExceptions = setOf( + private val examineExceptions = setOf( "yes", "normal", "oak", @@ -272,13 +273,13 @@ internal object RunescapeWikiModifier { "clairvoyance", "overheat" ) - val regex = "Used (in|with) (.*)\\([0-9,\\s&]+\\)".toRegex() - val regex2 = "Requires (.*)\\([0-9,\\s&]+\\)".toRegex() - val regex3 = "\\(.*\\)".toRegex() + private val regex = "Used (in|with) (.*)\\([0-9,\\s&]+\\)".toRegex() + private val regex2 = "Requires (.*)\\([0-9,\\s&]+\\)".toRegex() + private val regex3 = "\\(.*\\)".toRegex() - val gods = setOf("Ancient", "Armadyl", "Bandos", "Gilded", "Guthix", "Saradomin", "Zamorak", "Zaros") + private val gods = setOf("Ancient", "Armadyl", "Bandos", "Gilded", "Guthix", "Saradomin", "Zamorak", "Zaros") - fun MutableMap.updateNames(key: String) { + private fun MutableMap.updateNames(key: String) { var value = this[key] as? String ?: return if (value == "Dragon claw") { value = "Dragon claws" @@ -311,21 +312,21 @@ internal object RunescapeWikiModifier { this[key] = value } - fun MutableMap.dropTypes() { + private fun MutableMap.dropTypes() { val value = this["Destroy"] as? String ?: return if (value == "?" || value.startsWith("Drop", true) || value == "Destroy") { remove("Destroy") } } - fun MutableMap.alch() { + private fun MutableMap.alch() { val value = remove("Alchemy") as? String ?: return if (value == "Not alchemisable") { this["Alchable"] = false } } - fun MutableMap.onDeathTypes() { + private fun MutableMap.onDeathTypes() { // Default is "Drop" val value = remove("On death") as? String ?: return if (value.contains("Reclaimable")) { @@ -345,19 +346,16 @@ internal object RunescapeWikiModifier { } } - fun releasedBefore(map: MutableMap, revision: LocalDate): Boolean { + private fun releasedBefore(map: MutableMap, revision: LocalDate): Boolean { val date = map.getRelease() - if (date != null && date.isBefore(revision)) { - return true - } - return false + return date != null && date.isBefore(revision) } - const val maxItemId = 22323 + const val MAX_ITEM_ID = 22323 private val formatter: DateTimeFormatter = DateTimeFormatter.ofPattern("d MMMM yyyy") val revision: LocalDate = LocalDate.of(2011, Month.OCTOBER, 4) - fun Map.getRelease(): LocalDate? { + private fun Map.getRelease(): LocalDate? { val release = this["Release"] ?: "?" if (release == "?") { return null @@ -365,9 +363,10 @@ internal object RunescapeWikiModifier { return LocalDate.parse(release, formatter) } - var spaceCount = 0 - var commaCount = 0 - fun Map.getIds(): List { + private var spaceCount = 0 + private var commaCount = 0 + + private fun Map.getIds(): List { val list = mutableListOf() val property = this["Item ID"] ?: "?" if (property != "?") { diff --git a/tools/src/main/kotlin/world/gregs/voidps/tools/wiki/scrape/RunescapeWikiParser.kt b/tools/src/main/kotlin/world/gregs/voidps/tools/wiki/scrape/RunescapeWikiParser.kt index 60853accb..dd13a29ee 100644 --- a/tools/src/main/kotlin/world/gregs/voidps/tools/wiki/scrape/RunescapeWikiParser.kt +++ b/tools/src/main/kotlin/world/gregs/voidps/tools/wiki/scrape/RunescapeWikiParser.kt @@ -86,6 +86,7 @@ internal object RunescapeWikiParser { map[key] = value.removeSuffix(" (edit)") } + @Suppress("UNCHECKED_CAST") fun flatten(map: MutableMap, name: String) { val properties = map.remove(name) as? MutableMap ?: return properties.forEach { (key, value) -> diff --git a/tools/src/main/kotlin/world/gregs/voidps/tools/wiki/scrape/RunescapeWikiScraper.kt b/tools/src/main/kotlin/world/gregs/voidps/tools/wiki/scrape/RunescapeWikiScraper.kt index 9250c5b16..e70d648f1 100644 --- a/tools/src/main/kotlin/world/gregs/voidps/tools/wiki/scrape/RunescapeWikiScraper.kt +++ b/tools/src/main/kotlin/world/gregs/voidps/tools/wiki/scrape/RunescapeWikiScraper.kt @@ -7,6 +7,7 @@ import kotlinx.coroutines.runBlocking import org.jsoup.Jsoup import java.io.File import java.net.URLDecoder +import java.nio.charset.Charset import kotlin.system.measureTimeMillis /** @@ -78,7 +79,7 @@ internal object RunescapeWikiScraper { for (item in ele.select("ul li a")) { val link = item.attr("href") val title = item.attr("title") - list.add(Link(URLDecoder.decode(link), title)) + list.add(Link(URLDecoder.decode(link, Charset.defaultCharset()), title)) } } val nextPage = element.select("a:contains(next page)").attr("href") diff --git a/tools/src/main/kotlin/world/gregs/voidps/tools/wiki/scrape/WebsiteScraper.kt b/tools/src/main/kotlin/world/gregs/voidps/tools/wiki/scrape/WebsiteScraper.kt index 543f69392..4b7671bba 100644 --- a/tools/src/main/kotlin/world/gregs/voidps/tools/wiki/scrape/WebsiteScraper.kt +++ b/tools/src/main/kotlin/world/gregs/voidps/tools/wiki/scrape/WebsiteScraper.kt @@ -24,6 +24,7 @@ object WebsiteScraper { downloadThreaded(folder, "https://chisel.weirdgloop.org/dialogue/", contentPages, 5_000) } + @Suppress("OPT_IN_USAGE") private fun downloadThreaded(folder: File, url: String, pages: List, chunkSize: Int) { runBlocking { supervisorScope { diff --git a/tools/src/test/kotlin/world/gregs/voidps/tools/graph/MapGraphTest.kt b/tools/src/test/kotlin/world/gregs/voidps/tools/graph/MapGraphTest.kt index db43a0964..e45d4ce52 100644 --- a/tools/src/test/kotlin/world/gregs/voidps/tools/graph/MapGraphTest.kt +++ b/tools/src/test/kotlin/world/gregs/voidps/tools/graph/MapGraphTest.kt @@ -2,7 +2,6 @@ package world.gregs.voidps.tools.graph import io.mockk.every import io.mockk.mockk -import org.junit.Ignore import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Disabled @@ -12,7 +11,6 @@ import world.gregs.voidps.engine.map.collision.Collisions import world.gregs.voidps.type.Direction import world.gregs.voidps.type.Tile -@Ignore @Disabled internal class MapGraphTest { diff --git a/types/src/main/kotlin/world/gregs/voidps/type/Direction.kt b/types/src/main/kotlin/world/gregs/voidps/type/Direction.kt index 476dc4c16..cf98ed962 100644 --- a/types/src/main/kotlin/world/gregs/voidps/type/Direction.kt +++ b/types/src/main/kotlin/world/gregs/voidps/type/Direction.kt @@ -59,12 +59,12 @@ enum class Direction(deltaX: Int, deltaY: Int) { } companion object { - val size = values().size - val cardinal = values().filter { it.isCardinal() && it.delta.x != it.delta.y } - val ordinal = values().filter { it.isDiagonal() } - val values = values() - val reversed = values().reversed() - val all = values().copyOfRange(0, size - 1) + val size = entries.size + val cardinal = entries.filter { it.isCardinal() && it.delta.x != it.delta.y } + val ordinal = entries.filter { it.isDiagonal() } + val values = entries.toTypedArray() + val reversed = entries.reversed() + val all = entries.toTypedArray().copyOfRange(0, size - 1) val clockwise = arrayOf(NORTH, NORTH_EAST, EAST, SOUTH_EAST, SOUTH, SOUTH_WEST, WEST, NORTH_WEST) val westClockwise = arrayOf(WEST, NORTH, EAST, SOUTH) diff --git a/types/src/main/kotlin/world/gregs/voidps/type/area/Cuboid.kt b/types/src/main/kotlin/world/gregs/voidps/type/area/Cuboid.kt index 5af98288c..8c78db0bb 100644 --- a/types/src/main/kotlin/world/gregs/voidps/type/area/Cuboid.kt +++ b/types/src/main/kotlin/world/gregs/voidps/type/area/Cuboid.kt @@ -37,14 +37,14 @@ data class Cuboid( return list } - override fun toZones(l: Int): List { + override fun toZones(level: Int): List { val list = mutableListOf() val max = Tile(maxX, maxY, maxLevel).zone val min = Tile(minX, minY, minLevel).zone - for (level in min.level..max.level) { + for (lvl in min.level..max.level) { for (x in min.x..max.x) { for (y in min.y..max.y) { - list.add(Zone(x, y, level)) + list.add(Zone(x, y, lvl)) } } } diff --git a/yaml/src/main/kotlin/world/gregs/yaml/read/YamlReaderConfiguration.kt b/yaml/src/main/kotlin/world/gregs/yaml/read/YamlReaderConfiguration.kt index dec6ce7e8..f795486b3 100644 --- a/yaml/src/main/kotlin/world/gregs/yaml/read/YamlReaderConfiguration.kt +++ b/yaml/src/main/kotlin/world/gregs/yaml/read/YamlReaderConfiguration.kt @@ -40,6 +40,7 @@ open class YamlReaderConfiguration( map[key] = value } + @Suppress("UNCHECKED_CAST") open fun anchor(anchor: Any): Any { return when (anchor) { is List<*> -> createList().apply { diff --git a/yaml/src/main/kotlin/world/gregs/yaml/write/ExplicitCollectionWriter.kt b/yaml/src/main/kotlin/world/gregs/yaml/write/ExplicitCollectionWriter.kt index 0fbf1e94f..cff3d215f 100644 --- a/yaml/src/main/kotlin/world/gregs/yaml/write/ExplicitCollectionWriter.kt +++ b/yaml/src/main/kotlin/world/gregs/yaml/write/ExplicitCollectionWriter.kt @@ -30,7 +30,7 @@ class ExplicitCollectionWriter(writer: CharWriter, config: YamlWriterConfigurati override fun map(map: Map<*, *>, indent: Int, parentMap: String?) { if (config.formatExplicitMap) { - formattedMap(map, indent, parentMap) + formattedMap(map, indent) return } writer.append('{') @@ -69,7 +69,7 @@ class ExplicitCollectionWriter(writer: CharWriter, config: YamlWriterConfigurati writer.append(']') } - private fun formattedMap(map: Map<*, *>, indent: Int, parentMap: String?) { + private fun formattedMap(map: Map<*, *>, indent: Int) { writer.append('{') if (map.isNotEmpty()) { writer.appendLine() diff --git a/yaml/src/test/kotlin/world/gregs/yaml/read/YamlReaderAnchorTest.kt b/yaml/src/test/kotlin/world/gregs/yaml/read/YamlReaderAnchorTest.kt index f1730ba0c..99b9e81c3 100644 --- a/yaml/src/test/kotlin/world/gregs/yaml/read/YamlReaderAnchorTest.kt +++ b/yaml/src/test/kotlin/world/gregs/yaml/read/YamlReaderAnchorTest.kt @@ -7,6 +7,7 @@ import world.gregs.yaml.Yaml class YamlReaderAnchorTest { + @Suppress("UNCHECKED_CAST") private val config = object : YamlReaderConfiguration() { override fun set(map: MutableMap, key: String, value: Any, indent: Int, parentMap: String?) { when (key) { diff --git a/yaml/src/test/kotlin/world/gregs/yaml/read/YamlReaderScenarioTest.kt b/yaml/src/test/kotlin/world/gregs/yaml/read/YamlReaderScenarioTest.kt index 4f9e93624..9157388ea 100644 --- a/yaml/src/test/kotlin/world/gregs/yaml/read/YamlReaderScenarioTest.kt +++ b/yaml/src/test/kotlin/world/gregs/yaml/read/YamlReaderScenarioTest.kt @@ -13,6 +13,7 @@ class YamlReaderScenarioTest { } @Test + @Suppress("UNCHECKED_CAST") fun `Parse list with modifier`() { val config = object : YamlReaderConfiguration() { override fun addListItem(reader: YamlReader, list: MutableList, indentOffset: Int, parentMap: String?) {