From 0a5704cbb7e0987f3c856496e0144d687084bb93 Mon Sep 17 00:00:00 2001 From: navarchus Date: Tue, 20 Aug 2024 21:44:54 -0400 Subject: [PATCH 1/6] ugly but valid bugfix --- .../common/casting/actions/eval/OpForEach.kt | 23 ++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/actions/eval/OpForEach.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/actions/eval/OpForEach.kt index bb5ccafa8b..b56c04fc00 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/actions/eval/OpForEach.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/actions/eval/OpForEach.kt @@ -1,5 +1,6 @@ package at.petrak.hexcasting.common.casting.actions.eval +import at.petrak.hexcasting.api.casting.SpellList import at.petrak.hexcasting.api.casting.castables.Action import at.petrak.hexcasting.api.casting.eval.CastingEnvironment import at.petrak.hexcasting.api.casting.eval.OperationResult @@ -7,6 +8,8 @@ import at.petrak.hexcasting.api.casting.eval.vm.CastingImage import at.petrak.hexcasting.api.casting.eval.vm.FrameForEach import at.petrak.hexcasting.api.casting.eval.vm.SpellContinuation import at.petrak.hexcasting.api.casting.getList +import at.petrak.hexcasting.api.casting.iota.Iota +import at.petrak.hexcasting.api.casting.mishaps.MishapInvalidIota import at.petrak.hexcasting.api.casting.mishaps.MishapNotEnoughArgs import at.petrak.hexcasting.common.lib.hex.HexEvalSounds @@ -17,14 +20,28 @@ object OpForEach : Action { if (stack.size < 2) throw MishapNotEnoughArgs(2, stack.size) - val instrs = stack.getList(stack.lastIndex - 1) - val datums = stack.getList(stack.lastIndex) + val newStack = stack.takeLast(2) + + val instrs: SpellList + val datums: SpellList + + try { + instrs = newStack.getList(newStack.lastIndex - 1) + } catch (m: MishapInvalidIota) { + throw MishapInvalidIota.ofType(m.perpetrator, 1, "list") + } + + try { + datums = newStack.getList(newStack.lastIndex) + } catch (m: MishapInvalidIota) { + throw MishapInvalidIota.ofType(m.perpetrator, 0, "list") + } + stack.removeLastOrNull() stack.removeLastOrNull() val frame = FrameForEach(datums, instrs, null, mutableListOf()) val image2 = image.withUsedOp().copy(stack = stack) - return OperationResult(image2, listOf(), continuation.pushFrame(frame), HexEvalSounds.THOTH) } } From 752aa3c204fab5ebe841e82c813e47c2806283cc Mon Sep 17 00:00:00 2001 From: navarchus Date: Tue, 20 Aug 2024 21:53:05 -0400 Subject: [PATCH 2/6] slightly less ugly bugfux --- .../common/casting/actions/eval/OpForEach.kt | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/actions/eval/OpForEach.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/actions/eval/OpForEach.kt index b56c04fc00..5847f3d819 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/actions/eval/OpForEach.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/actions/eval/OpForEach.kt @@ -22,20 +22,8 @@ object OpForEach : Action { val newStack = stack.takeLast(2) - val instrs: SpellList - val datums: SpellList - - try { - instrs = newStack.getList(newStack.lastIndex - 1) - } catch (m: MishapInvalidIota) { - throw MishapInvalidIota.ofType(m.perpetrator, 1, "list") - } - - try { - datums = newStack.getList(newStack.lastIndex) - } catch (m: MishapInvalidIota) { - throw MishapInvalidIota.ofType(m.perpetrator, 0, "list") - } + val instrs = newStack.getList(0, 2) + val datums = newStack.getList(1, 2) stack.removeLastOrNull() stack.removeLastOrNull() From c16b37e6cdd662b94a94e89595ac3cc34a1b1171 Mon Sep 17 00:00:00 2001 From: navarchus Date: Tue, 20 Aug 2024 21:57:54 -0400 Subject: [PATCH 3/6] nice bugfix --- .../hexcasting/common/casting/actions/eval/OpForEach.kt | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/actions/eval/OpForEach.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/actions/eval/OpForEach.kt index 5847f3d819..e124a3008a 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/actions/eval/OpForEach.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/actions/eval/OpForEach.kt @@ -20,10 +20,9 @@ object OpForEach : Action { if (stack.size < 2) throw MishapNotEnoughArgs(2, stack.size) - val newStack = stack.takeLast(2) - val instrs = newStack.getList(0, 2) - val datums = newStack.getList(1, 2) + val instrs = stack.getList(stack.lastIndex - 1, stack.size) + val datums = stack.getList(stack.lastIndex, stack.size) stack.removeLastOrNull() stack.removeLastOrNull() From 76b04bdc98647be16d533dbde39509efe357566e Mon Sep 17 00:00:00 2001 From: navarchus Date: Wed, 21 Aug 2024 07:39:06 -0400 Subject: [PATCH 4/6] remove vestigial imports --- .../petrak/hexcasting/common/casting/actions/eval/OpForEach.kt | 3 --- 1 file changed, 3 deletions(-) diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/actions/eval/OpForEach.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/actions/eval/OpForEach.kt index e124a3008a..fd0ee636b5 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/actions/eval/OpForEach.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/actions/eval/OpForEach.kt @@ -1,6 +1,5 @@ package at.petrak.hexcasting.common.casting.actions.eval -import at.petrak.hexcasting.api.casting.SpellList import at.petrak.hexcasting.api.casting.castables.Action import at.petrak.hexcasting.api.casting.eval.CastingEnvironment import at.petrak.hexcasting.api.casting.eval.OperationResult @@ -8,8 +7,6 @@ import at.petrak.hexcasting.api.casting.eval.vm.CastingImage import at.petrak.hexcasting.api.casting.eval.vm.FrameForEach import at.petrak.hexcasting.api.casting.eval.vm.SpellContinuation import at.petrak.hexcasting.api.casting.getList -import at.petrak.hexcasting.api.casting.iota.Iota -import at.petrak.hexcasting.api.casting.mishaps.MishapInvalidIota import at.petrak.hexcasting.api.casting.mishaps.MishapNotEnoughArgs import at.petrak.hexcasting.common.lib.hex.HexEvalSounds From 843a0e7daf315c7046b8113512010376e141e520 Mon Sep 17 00:00:00 2001 From: Toby Vestal Date: Wed, 21 Aug 2024 12:34:05 -0400 Subject: [PATCH 5/6] reverse whitespace change --- .../petrak/hexcasting/common/casting/actions/eval/OpForEach.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/actions/eval/OpForEach.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/actions/eval/OpForEach.kt index fd0ee636b5..99138ae00b 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/actions/eval/OpForEach.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/actions/eval/OpForEach.kt @@ -26,6 +26,7 @@ object OpForEach : Action { val frame = FrameForEach(datums, instrs, null, mutableListOf()) val image2 = image.withUsedOp().copy(stack = stack) + return OperationResult(image2, listOf(), continuation.pushFrame(frame), HexEvalSounds.THOTH) } } From 37fc8d29fa86be102d36d8d93cee0089734dbc45 Mon Sep 17 00:00:00 2001 From: Toby Vestal Date: Wed, 21 Aug 2024 12:34:49 -0400 Subject: [PATCH 6/6] reverse whitespace change - 2 --- .../petrak/hexcasting/common/casting/actions/eval/OpForEach.kt | 2 -- 1 file changed, 2 deletions(-) diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/actions/eval/OpForEach.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/actions/eval/OpForEach.kt index 99138ae00b..bdd4f76f7a 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/actions/eval/OpForEach.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/actions/eval/OpForEach.kt @@ -17,10 +17,8 @@ object OpForEach : Action { if (stack.size < 2) throw MishapNotEnoughArgs(2, stack.size) - val instrs = stack.getList(stack.lastIndex - 1, stack.size) val datums = stack.getList(stack.lastIndex, stack.size) - stack.removeLastOrNull() stack.removeLastOrNull()