Switch from Enum values() to entries

Signed-off-by: Graham <gpe@openrs2.org>
master
Graham 1 month ago
parent 5b9fde97eb
commit 38a341f8d2
  1. 14
      buffer-generator/src/main/kotlin/org/openrs2/buffer/generator/ByteBufExtensionGenerator.kt
  2. 6
      cache/src/main/kotlin/org/openrs2/cache/Js5CompressionType.kt
  3. 5
      cache/src/main/kotlin/org/openrs2/cache/Js5Protocol.kt
  4. 2
      cache/src/main/kotlin/org/openrs2/cache/RuneLiteStore.kt
  5. 2
      patcher/src/main/kotlin/org/openrs2/patcher/Resource.kt
  6. 2
      patcher/src/main/kotlin/org/openrs2/patcher/transform/PlatformDetectionTransformer.kt
  7. 6
      protocol/src/main/kotlin/org/openrs2/protocol/common/AntiAliasingMode.kt
  8. 6
      protocol/src/main/kotlin/org/openrs2/protocol/common/DisplayMode.kt

@ -11,9 +11,9 @@ public class ByteBufExtensionGenerator {
builder.indent(" ")
builder.addFileComment("This file is generated automatically. DO NOT EDIT.")
for (type in IntType.values()) {
for (order in ByteOrder.values()) {
for (transformation in Transformation.values()) {
for (type in IntType.entries) {
for (order in ByteOrder.entries) {
for (transformation in Transformation.entries) {
// only integers can be middle-endian
if (type != IntType.INT && (order == ByteOrder.ALT3 || order == ByteOrder.ALT3_REVERSE)) {
continue
@ -37,7 +37,7 @@ public class ByteBufExtensionGenerator {
continue
}
for (signedness in Signedness.values()) {
for (signedness in Signedness.entries) {
// unsigned integers not supported
if (type == IntType.INT && signedness == Signedness.UNSIGNED) {
continue
@ -53,8 +53,8 @@ public class ByteBufExtensionGenerator {
}
}
for (order in ArrayOrder.values()) {
for (transformation in Transformation.values()) {
for (order in ArrayOrder.entries) {
for (transformation in Transformation.entries) {
// supplied by Netty
if (order == ArrayOrder.FORWARD && transformation == Transformation.IDENTITY) {
continue
@ -87,7 +87,7 @@ public class ByteBufExtensionGenerator {
}
}
for (transformation in Transformation.values()) {
for (transformation in Transformation.entries) {
// supplied by Netty
if (transformation == Transformation.IDENTITY) {
continue

@ -39,12 +39,10 @@ public enum class Js5CompressionType {
}
public companion object {
private val values = values()
@JvmStatic
public fun fromOrdinal(ordinal: Int): Js5CompressionType? {
return if (ordinal >= 0 && ordinal < values.size) {
values[ordinal]
return if (ordinal >= 0 && ordinal < entries.size) {
entries[ordinal]
} else {
null
}

@ -10,13 +10,12 @@ public enum class Js5Protocol {
public companion object {
private const val OFFSET = 5
private val values = values()
@JvmStatic
public fun fromId(id: Int): Js5Protocol? {
val ordinal = id - OFFSET
return if (ordinal >= 0 && ordinal < values.size) {
values[ordinal]
return if (ordinal >= 0 && ordinal < entries.size) {
entries[ordinal]
} else {
null
}

@ -158,7 +158,7 @@ public class RuneLiteStore @Inject constructor(
alloc.buffer().use { uncompressed ->
index.write(uncompressed)
val matching = Js5CompressionType.values().count { type ->
val matching = Js5CompressionType.entries.count { type ->
Js5Compression.compress(uncompressed.slice(), type).use { compressed ->
val checksum = compressed.crc32()

@ -89,7 +89,7 @@ public class Resource(
val platforms = mutableListOf<List<Resource>>()
var i = 0
for (os in OperatingSystem.values()) {
for (os in OperatingSystem.entries) {
for (arch in os.architectures) {
val resources = mutableListOf<Resource>()

@ -51,7 +51,7 @@ public class PlatformDetectionTransformer : Transformer() {
val end = LabelNode()
var platform = 0
for (os in OperatingSystem.values()) {
for (os in OperatingSystem.entries) {
val nextOs = LabelNode()
list.add(VarInsnNode(Opcodes.ALOAD, nameVar))

@ -6,11 +6,9 @@ public enum class AntiAliasingMode {
X4;
public companion object {
private val values = values()
public fun fromOrdinal(ordinal: Int): AntiAliasingMode? {
return if (ordinal >= 0 && ordinal < values.size) {
values[ordinal]
return if (ordinal >= 0 && ordinal < entries.size) {
entries[ordinal]
} else {
null
}

@ -7,11 +7,9 @@ public enum class DisplayMode {
HD_FULLSCREEN;
public companion object {
private val values = values()
public fun fromOrdinal(ordinal: Int): DisplayMode? {
return if (ordinal >= 0 && ordinal < values.size) {
values[ordinal]
return if (ordinal >= 0 && ordinal < entries.size) {
entries[ordinal]
} else {
null
}

Loading…
Cancel
Save