Skip to content

Commit

Permalink
Format code and update dependencies (#441)
Browse files Browse the repository at this point in the history
* Inspection fixes

* Update dependency versions

* Update gradle version

* Fix kotlin compile warnings

* Version 1.1.1
  • Loading branch information
GregHib authored Feb 10, 2024
1 parent ab4ab86 commit bf4bac4
Show file tree
Hide file tree
Showing 111 changed files with 502 additions and 464 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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++
}
}
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ class InterfaceEncoder : DefinitionEncoder<InterfaceComponentDefinitionFull> {
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 -> {
Expand All @@ -58,14 +58,14 @@ class InterfaceEncoder : DefinitionEncoder<InterfaceComponentDefinitionFull> {
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)
Expand Down Expand Up @@ -121,7 +121,7 @@ class InterfaceEncoder : DefinitionEncoder<InterfaceComponentDefinitionFull> {
}

writeMedium(definition.setting.setting)
var startOffset = 0
var startOffset: Int
val keyRepeat = definition.keyRepeats
val keyCodes = definition.keyCodes
val keyModifiers = definition.keyModifiers
Expand Down
3 changes: 3 additions & 0 deletions engine/src/main/kotlin/world/gregs/voidps/engine/Contexts.kt
Original file line number Diff line number Diff line change
@@ -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")
}
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -35,6 +36,7 @@ class InstructionTask(
handler
)

@OptIn(ExperimentalCoroutinesApi::class)
override fun run() {
players.forEach { player ->
val instructions = player.instructions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,18 @@ class NPCTask(
override val characters: CharacterList<NPC>
) : CharacterTask<NPC>(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)
}
}
Loading

0 comments on commit bf4bac4

Please sign in to comment.