From 66277273a7eb4c8ff93af9e51bf987bffe13f161 Mon Sep 17 00:00:00 2001 From: DerelictDrone Date: Sun, 19 May 2024 21:04:33 -0500 Subject: [PATCH] Copy DIV behavior for handling modulo by zero --- lua/wire/zvm/zvm_opcodes.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lua/wire/zvm/zvm_opcodes.lua b/lua/wire/zvm/zvm_opcodes.lua index 92b4e04..423a8bd 100644 --- a/lua/wire/zvm/zvm_opcodes.lua +++ b/lua/wire/zvm/zvm_opcodes.lua @@ -409,7 +409,11 @@ ZVM.OpcodeTable[58] = function(self) --FATAN self:Dyn_EmitOperand("math.atan($2)") end ZVM.OpcodeTable[59] = function(self) --MOD - self:Dyn_EmitOperand("math.fmod($1,$2)") + self:Dyn_Emit("$L OP = $2") + self:Dyn_EmitOperand("math.fmod($1,OP)") + self:Dyn_Emit("if math.abs(OP) < 1e-12 then") + self:Dyn_EmitInterrupt("3","0") + self:Dyn_Emit("end") end -------------------------------------------------------------------------------- ZVM.OpcodeTable[60] = function(self) --BIT