mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-07 12:21:52 +09:00
using kotlin's newfangled 'x in xs.indices' instead of 'x in 0 until xs.size'
This commit is contained in:
@@ -107,7 +107,7 @@ internal object AssembleFrameBase {
|
||||
transforms.forEach { transform ->
|
||||
if (transform.joint.name == ADProperties.ALL_JOINT_SELECT_KEY) {
|
||||
// transform applies to all joints
|
||||
for (c in 0 until out.size) {
|
||||
for (c in out.indices) {
|
||||
out[c] = out[c].first to (out[c].second + transform.translate)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,8 +74,8 @@ object MinimapComposer : Disposable {
|
||||
fun update() {
|
||||
// make the queueing work
|
||||
// enqueue first
|
||||
for (y in 0 until tilemap.size) {
|
||||
for (x in 0 until tilemap[0].size) {
|
||||
for (y in tilemap.indices) {
|
||||
for (x in tilemap[0].indices) {
|
||||
if (liveTilesMeta[tilemap[y][x]].revalidate) {
|
||||
liveTilesMeta[tilemap[y][x]].revalidate = false
|
||||
updaterQueue.addLast(createUpdater(x, y))
|
||||
@@ -84,7 +84,7 @@ object MinimapComposer : Disposable {
|
||||
}
|
||||
}
|
||||
// consume the queue
|
||||
for (k in 0 until currentThreads.size) {
|
||||
for (k in currentThreads.indices) {
|
||||
if (currentThreads[k].state == Thread.State.TERMINATED && !updaterQueue.isEmpty) {
|
||||
currentThreads[k] = Thread(updaterQueue.removeFirst(), "MinimapLivetilePainter")
|
||||
printdbg(this, "Consuming from queue; queue size now: ${updaterQueue.size}")
|
||||
|
||||
@@ -407,7 +407,7 @@ open class TerrarumIngame(batch: SpriteBatch) : IngameInstance(batch) {
|
||||
}
|
||||
// scan for the one with non-null UI.
|
||||
// what if there's multiple of such fixtures? whatever, you are supposed to DISALLOW such situation.
|
||||
for (kk in 0 until actorsUnderMouse.size) {
|
||||
for (kk in actorsUnderMouse.indices) {
|
||||
actorsUnderMouse[kk].mainUI?.let {
|
||||
uiOpened = true
|
||||
|
||||
|
||||
@@ -378,8 +378,8 @@ object WorldSimulator {
|
||||
private val FALLABLE_MAX_FALL_SPEED = 2
|
||||
|
||||
private fun monitorIllegalFluidSetup() {
|
||||
for (y in 0 until fluidMap.size) {
|
||||
for (x in 0 until fluidMap[0].size) {
|
||||
for (y in fluidMap.indices) {
|
||||
for (x in fluidMap[0].indices) {
|
||||
val fluidData = world.getFluid(x + updateXFrom, y + updateYFrom)
|
||||
if (fluidData.amount < 0f) {
|
||||
throw InternalError("Negative amount of fluid at (${x + updateXFrom},${y + updateYFrom}): $fluidData")
|
||||
@@ -391,8 +391,8 @@ object WorldSimulator {
|
||||
private fun makeFluidMapFromWorld() {
|
||||
//printdbg(this, "Scan area: ($updateXFrom,$updateYFrom)..(${updateXFrom + fluidMap[0].size},${updateYFrom + fluidMap.size})")
|
||||
|
||||
for (y in 0 until fluidMap.size) {
|
||||
for (x in 0 until fluidMap[0].size) {
|
||||
for (y in fluidMap.indices) {
|
||||
for (x in fluidMap[0].indices) {
|
||||
val fluidData = world.getFluid(x + updateXFrom, y + updateYFrom)
|
||||
fluidMap[y][x] = fluidData.amount
|
||||
fluidTypeMap[y][x] = fluidData.type
|
||||
@@ -407,8 +407,8 @@ object WorldSimulator {
|
||||
}
|
||||
|
||||
private fun fluidmapToWorld() {
|
||||
for (y in 0 until fluidMap.size) {
|
||||
for (x in 0 until fluidMap[0].size) {
|
||||
for (y in fluidMap.indices) {
|
||||
for (x in fluidMap[0].indices) {
|
||||
world.setFluid(x + updateXFrom, y + updateYFrom, fluidNewTypeMap[y][x], fluidNewMap[y][x])
|
||||
}
|
||||
}
|
||||
|
||||
@@ -307,7 +307,7 @@ package net.torvald.terrarum.modulebasegame.ui
|
||||
inventorySortList.sortBy { it.item.name }
|
||||
|
||||
// map sortList to item list
|
||||
for (k in 0 until items.size) {
|
||||
for (k in items.indices) {
|
||||
// we have an item
|
||||
try {
|
||||
val sortListItem = inventorySortList[k + itemPage * items.size]
|
||||
|
||||
@@ -353,7 +353,7 @@ class UIItemInventoryDynamicList(
|
||||
inventorySortList.sortBy { ItemCodex[it.item]!!.name }
|
||||
|
||||
// map sortList to item list
|
||||
for (k in 0 until items.size) {
|
||||
for (k in items.indices) {
|
||||
// we have an item
|
||||
try {
|
||||
val sortListItem = inventorySortList[k + itemPage * items.size]
|
||||
@@ -372,7 +372,7 @@ class UIItemInventoryDynamicList(
|
||||
}
|
||||
|
||||
// set equippedslot number
|
||||
for (eq in 0 until inventory.itemEquipped.size) {
|
||||
for (eq in inventory.itemEquipped.indices) {
|
||||
if (eq < inventory.itemEquipped.size) {
|
||||
if (inventory.itemEquipped[eq] == items[k].item?.dynamicID) {
|
||||
items[k].equippedSlot = eq
|
||||
|
||||
@@ -118,7 +118,7 @@ class UIItemInventoryEquippedView(
|
||||
// sort by equip position
|
||||
|
||||
// fill the grid from fastest index, make no gap in-between of slots
|
||||
for (k in 0 until itemGrid.size) {
|
||||
for (k in itemGrid.indices) {
|
||||
val item = inventory.itemEquipped[k]
|
||||
|
||||
if (item == null) {
|
||||
|
||||
@@ -153,7 +153,7 @@ internal object ReadLayerDataLzma {
|
||||
val fluidFills = HashMap<BlockAddress, Float>()
|
||||
|
||||
// parse terrain damages
|
||||
for (c in 0 until payloadBytes["TdMG"]!!.size step 10) {
|
||||
for (c in payloadBytes["TdMG"]!!.indices step 10) {
|
||||
val bytes = payloadBytes["TdMG"]!!
|
||||
|
||||
val tileAddr = bytes.sliceArray(c..c+5)
|
||||
@@ -164,7 +164,7 @@ internal object ReadLayerDataLzma {
|
||||
|
||||
|
||||
// parse wall damages
|
||||
for (c in 0 until payloadBytes["WdMG"]!!.size step 10) {
|
||||
for (c in payloadBytes["WdMG"]!!.indices step 10) {
|
||||
val bytes = payloadBytes["WdMG"]!!
|
||||
|
||||
val tileAddr = bytes.sliceArray(c..c+5)
|
||||
|
||||
@@ -154,7 +154,7 @@ internal object ReadLayerDataZip {
|
||||
val fluidFills = HashMap<BlockAddress, Float>()
|
||||
|
||||
// parse terrain damages
|
||||
for (c in 0 until payloadBytes["TdMG"]!!.size step 10) {
|
||||
for (c in payloadBytes["TdMG"]!!.indices step 10) {
|
||||
val bytes = payloadBytes["TdMG"]!!
|
||||
|
||||
val tileAddr = bytes.sliceArray(c..c+5)
|
||||
@@ -165,7 +165,7 @@ internal object ReadLayerDataZip {
|
||||
|
||||
|
||||
// parse wall damages
|
||||
for (c in 0 until payloadBytes["WdMG"]!!.size step 10) {
|
||||
for (c in payloadBytes["WdMG"]!!.indices step 10) {
|
||||
val bytes = payloadBytes["WdMG"]!!
|
||||
|
||||
val tileAddr = bytes.sliceArray(c..c+5)
|
||||
|
||||
@@ -53,7 +53,7 @@ class RGBtoXYZBenchmark {
|
||||
|
||||
// print out captured data
|
||||
println("with LUT\tno LUT\tmult")
|
||||
for (i in 0 until timer1.size) {
|
||||
for (i in timer1.indices) {
|
||||
println("${timer1[i]}\t${timer2[i]}\t${timer1[i].toFloat() / timer2[i]}")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -130,7 +130,7 @@ void main() {
|
||||
|
||||
val mouseUp: Boolean
|
||||
get() {
|
||||
for (k in 0 until subUIs.size) {
|
||||
for (k in subUIs.indices) {
|
||||
val ret2 = subUIs[k].mouseUp
|
||||
if (ret2) return true
|
||||
}
|
||||
|
||||
@@ -410,7 +410,7 @@ internal object BlocksDrawer {
|
||||
val nearbyTiles = getNearbyTilesPos(x, y).map { world.getTileFrom(mode, it.x, it.y) ?: Block.NULL }
|
||||
|
||||
var ret = 0
|
||||
for (i in 0 until nearbyTiles.size) {
|
||||
for (i in nearbyTiles.indices) {
|
||||
if (nearbyTiles[i] == mark) {
|
||||
ret += (1 shl i) // add 1, 2, 4, 8 for i = 0, 1, 2, 3
|
||||
}
|
||||
@@ -429,7 +429,7 @@ internal object BlocksDrawer {
|
||||
val nearbyTiles = getNearbyTilesPos(x, y).map { world.getWiringBlocks(it.x, it.y).and(drawWires).toBitOrd() * 16 }
|
||||
|
||||
var ret = 0
|
||||
for (i in 0 until nearbyTiles.size) {
|
||||
for (i in nearbyTiles.indices) {
|
||||
if (nearbyTiles[i] == wire) {
|
||||
ret += (1 shl i) // add 1, 2, 4, 8 for i = 0, 1, 2, 3
|
||||
}
|
||||
@@ -442,7 +442,7 @@ internal object BlocksDrawer {
|
||||
val nearbyTiles = getNearbyTilesPos(x, y).map { world.getTileFrom(mode, it.x, it.y) ?: Block.NULL }
|
||||
|
||||
var ret = 0
|
||||
for (i in 0 until nearbyTiles.size) {
|
||||
for (i in nearbyTiles.indices) {
|
||||
if (BlockCodex[nearbyTiles[i]].isSolid) {
|
||||
ret += (1 shl i) // add 1, 2, 4, 8 for i = 0, 1, 2, 3
|
||||
}
|
||||
@@ -459,7 +459,7 @@ internal object BlocksDrawer {
|
||||
val nearbyTiles = nearbyPos.map { world.getTileFromTerrain(it.x, it.y) ?: Block.NULL }
|
||||
|
||||
var ret = 0
|
||||
for (i in 0 until nearbyTiles.size) {
|
||||
for (i in nearbyTiles.indices) {
|
||||
val fluid = world.getFluid(nearbyPos[i].x, nearbyPos[i].y)
|
||||
if (BlockCodex[nearbyTiles[i]].isSolid || (fluid.isFluid() && 0 < CreateTileAtlas.fluidFillToTileLevel(fluid.amount))) {
|
||||
ret += (1 shl i) // add 1, 2, 4, 8 for i = 0, 1, 2, 3
|
||||
|
||||
Reference in New Issue
Block a user