From 1b1ffca73484100be7c3b0f958665fb4fd4e8bbf Mon Sep 17 00:00:00 2001 From: Skye Date: Sun, 25 Aug 2024 02:13:29 +0900 Subject: [PATCH] Don't throw TMI in OpDuplicateN to remove mishap message discrepancy --- .../common/casting/actions/stack/OpDuplicateN.kt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/actions/stack/OpDuplicateN.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/actions/stack/OpDuplicateN.kt index b704853a5..ca92c7f08 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/actions/stack/OpDuplicateN.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/actions/stack/OpDuplicateN.kt @@ -4,7 +4,6 @@ import at.petrak.hexcasting.api.casting.castables.ConstMediaAction import at.petrak.hexcasting.api.casting.eval.CastingEnvironment import at.petrak.hexcasting.api.casting.getPositiveInt import at.petrak.hexcasting.api.casting.iota.Iota -import at.petrak.hexcasting.api.casting.mishaps.MishapStackSize import at.petrak.hexcasting.common.lib.hex.HexIotaTypes object OpDuplicateN : ConstMediaAction { @@ -12,10 +11,13 @@ object OpDuplicateN : ConstMediaAction { get() = 2 override fun execute(args: List, env: CastingEnvironment): List { - val count = args.getPositiveInt(1, argc) + var count = args.getPositiveInt(1, argc) if (count > HexIotaTypes.MAX_SERIALIZATION_TOTAL) { - throw MishapStackSize() + // If we throw here, the message will point to us, which usually doesn't happen. + // So ensure that this check has no user-facing effects, just cap to MAX_SERIALIZATION_TOTAL, + // which will unconditionally trigger Too Many Iotas after we return. + count = HexIotaTypes.MAX_SERIALIZATION_TOTAL } return (List(count) { args[0] })