From 7906de17112aed4fb88ff79d04f532e724baf0cc Mon Sep 17 00:00:00 2001 From: minjaesong Date: Fri, 1 Mar 2024 03:17:16 +0900 Subject: [PATCH] fix: two clashing signal switches confusing the wire sim --- src/net/torvald/terrarum/gameworld/GameWorld.kt | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/net/torvald/terrarum/gameworld/GameWorld.kt b/src/net/torvald/terrarum/gameworld/GameWorld.kt index 4ef57cf2b..4692fd268 100644 --- a/src/net/torvald/terrarum/gameworld/GameWorld.kt +++ b/src/net/torvald/terrarum/gameworld/GameWorld.kt @@ -524,9 +524,17 @@ open class GameWorld( if (wiringGraph[blockAddr]!![itemID] == null) wiringGraph[blockAddr]!![itemID] = WiringSimCell(0, vector) - wiringGraph[blockAddr]!![itemID]!!.emt.set(vector) + // out = max(old, new) + val old = wiringGraph[blockAddr]!![itemID]!!.emt + + wiringGraph[blockAddr]!![itemID]!!.emt.set(old max vector) } + private infix fun Vector2.max(other: Vector2) = Vector2( + maxOf(this.x, other.x), + maxOf(this.y, other.y) + ) + fun addWireRecvStateOf(x: Int, y: Int, itemID: ItemID, state: WireReceptionState) { val (x, y) = coerceXY(x, y) val blockAddr = LandUtil.getBlockAddr(this, x, y)