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] })