diff --git a/src/net/torvald/terrarum/CheckUpdate.kt b/src/net/torvald/terrarum/CheckUpdate.kt index 970f6ec03..2bbd48c87 100644 --- a/src/net/torvald/terrarum/CheckUpdate.kt +++ b/src/net/torvald/terrarum/CheckUpdate.kt @@ -33,7 +33,7 @@ object CheckUpdate { private val checkUpdateURL = setOf( "https://github.com/curioustorvald/Terrarum/releases/tag/v$versionNumOnly", "https://github.com/curioustorvald/Terrarum/releases/tag/v$versionNumFull", - ).toList() + ).map { it.replace(' ', '_') } private fun wget(url: String): String? { printdbg(this, "wget $url") diff --git a/src/net/torvald/terrarum/modulebasegame/gameactors/Electric.kt b/src/net/torvald/terrarum/modulebasegame/gameactors/Electric.kt index 7ea40af92..35b142723 100644 --- a/src/net/torvald/terrarum/modulebasegame/gameactors/Electric.kt +++ b/src/net/torvald/terrarum/modulebasegame/gameactors/Electric.kt @@ -17,7 +17,7 @@ open class Electric : FixtureBase { protected constructor() : super() { oldSinkStatus = Array(blockBox.width * blockBox.height) { Vector2() } - newSinkStatus = Array(blockBox.width * blockBox.height) { Vector2() } +// newSinkStatus = Array(blockBox.width * blockBox.height) { Vector2() } } /** @@ -46,7 +46,7 @@ open class Electric : FixtureBase { App.disposables.add(mainUI) oldSinkStatus = Array(blockBox.width * blockBox.height) { Vector2() } - newSinkStatus = Array(blockBox.width * blockBox.height) { Vector2() } +// newSinkStatus = Array(blockBox.width * blockBox.height) { Vector2() } } companion object { @@ -138,7 +138,7 @@ open class Electric : FixtureBase { getWireEmissionAt(offsetX, offsetY).x <= ELECTRIC_THRESHOLD_LOW protected var oldSinkStatus: Array - protected var newSinkStatus: Array +// protected var newSinkStatus: Array open fun updateOnWireGraphTraversal(offsetX: Int, offsetY: Int, sinkType: WireEmissionType) { val index = pointToBlockBoxIndex(offsetX, offsetY) @@ -150,9 +150,6 @@ open class Electric : FixtureBase { Vector2(acc.x + (it?.x ?: 0.0), acc.y + (it?.y ?: 0.0)) } } - - - oldSinkStatus[index].set(new2) } /** @@ -170,27 +167,33 @@ open class Electric : FixtureBase { // get indices of "falling edges" val index = pointToBlockBoxIndex(x, y) val type = getWireSinkAt(index) ?: "" - val new = getWireStateAt(x, y, type) - if (new.x - oldSinkStatus[index].x >= ELECTRIC_THRESHOLD_EDGE_DELTA && new.x >= ELECTRIC_THRESHOLD_HIGH) - risingEdgeIndices.add(index) - else if (oldSinkStatus[index].x - new.x >= ELECTRIC_THRESHOLD_EDGE_DELTA && new.x <= ELECTRIC_THRESHOLD_LOW) - fallingEdgeIndices.add(index) + if (type.isNotBlank()) { + val old = oldSinkStatus[index] + val new = getWireStateAt(x, y, type) + + val wx = x + worldBlockPos!!.x + val wy = y + worldBlockPos!!.y + + println("Wxy($wx,$wy) getWireState($type)=$new, oldState($type)=$old") + + if (new.x - old.x >= ELECTRIC_THRESHOLD_EDGE_DELTA && new.x >= ELECTRIC_THRESHOLD_HIGH) + risingEdgeIndices.add(index) + else if (old.x - new.x >= ELECTRIC_THRESHOLD_EDGE_DELTA && new.x <= ELECTRIC_THRESHOLD_LOW) + fallingEdgeIndices.add(index) - oldSinkStatus[index].set(new) + oldSinkStatus[index].set(new) + } } } + if (risingEdgeIndices.isNotEmpty()) { + println("risingEdgeIndices=$risingEdgeIndices") + } risingEdgeIndices.forEach { onRisingEdge(it) } fallingEdgeIndices.forEach { onFallingEdge(it) } updateSignal() - - - - /*oldSinkStatus.indices.forEach { index -> - oldSinkStatus[index].set(new) - }*/ } } \ No newline at end of file diff --git a/src/net/torvald/terrarum/modulebasegame/gameactors/FixtureTextSignCopper.kt b/src/net/torvald/terrarum/modulebasegame/gameactors/FixtureTextSignCopper.kt index 37e11ab8d..ae265ef26 100644 --- a/src/net/torvald/terrarum/modulebasegame/gameactors/FixtureTextSignCopper.kt +++ b/src/net/torvald/terrarum/modulebasegame/gameactors/FixtureTextSignCopper.kt @@ -80,7 +80,7 @@ class FixtureTextSignCopper : Electric { blockBox = BlockBox(BlockBox.NO_COLLISION, panelCount, 2) setHitboxDimension(TILE_SIZE * blockBox.width, TILE_SIZE * blockBox.height, 0, 2) oldSinkStatus = Array(blockBox.width * blockBox.height) { Vector2() } - newSinkStatus = Array(blockBox.width * blockBox.height) { Vector2() } +// newSinkStatus = Array(blockBox.width * blockBox.height) { Vector2() } } // must be re-spawned on reload to make it visible after load diff --git a/src/net/torvald/terrarum/modulebasegame/gameactors/FixtureWorldPortal.kt b/src/net/torvald/terrarum/modulebasegame/gameactors/FixtureWorldPortal.kt index b357cecb9..88e1fbd81 100644 --- a/src/net/torvald/terrarum/modulebasegame/gameactors/FixtureWorldPortal.kt +++ b/src/net/torvald/terrarum/modulebasegame/gameactors/FixtureWorldPortal.kt @@ -62,12 +62,12 @@ class FixtureWorldPortal : Electric { } override fun onRisingEdge(readFrom: BlockBoxIndex) { - printdbg(this, "readFrom=$readFrom; getWireSinkAt(readFrom)=${getWireSinkAt(readFrom)}") +// printdbg(this, "readFrom=$readFrom; getWireSinkAt(readFrom)=${getWireSinkAt(readFrom)}") if (getWireSinkAt(readFrom) != "digital_bit") return - printdbg(this, "teleport! $teleportRequest") +// printdbg(this, "teleport! $teleportRequest") teleportRequest?.let { if (it.worldDiskToLoad != null && it.worldLoadParam != null) { throw InternalError("Contradiction -- worldDiskToLoad and worldLoadParam are both not null: $teleportRequest")