From 3d4d640be320142d908f2ae8aae863ecadd49dc4 Mon Sep 17 00:00:00 2001 From: terminx Date: Sat, 15 Dec 2018 01:38:38 +0000 Subject: [PATCH] Attempting to compile a CON with something stupid like "mul var 0" or "div var 0" in it now throws an error git-svn-id: https://svn.eduke32.com/eduke32@7270 1a8010ca-5511-0410-912e-c29ae57300e0 --- source/duke3d/src/gamedef.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/source/duke3d/src/gamedef.cpp b/source/duke3d/src/gamedef.cpp index fc4430ea9..826b0ab69 100644 --- a/source/duke3d/src/gamedef.cpp +++ b/source/duke3d/src/gamedef.cpp @@ -3735,10 +3735,18 @@ setvar: C_GetNextVarType(GAMEVAR_READONLY); C_GetNextValue(LABEL_DEFINE); - if (tw == CON_DIVVAR || tw == CON_MULVAR) + + // replace divides and multiplies by 0 with an error asking if the user is stupid + if (ins[2] == 0 && (tw == CON_MODVAR || tw == CON_MULVAR || tw == CON_DIVVAR)) + { + g_errorCnt++; + C_ReportError(-1); + initprintf("%s:%d: error: divide or multiply by zero! What are you doing?\n", g_scriptFileName, g_lineNumber); + continue; + } + else if (tw == CON_DIVVAR || tw == CON_MULVAR) { auto const i = ins[2]; - // replace multiplies or divides by 1 with nullop if (i == 1) {