From c323fac09d4a0f7e59dc44b713e74be41ebcce73 Mon Sep 17 00:00:00 2001 From: helixhorned Date: Wed, 11 Dec 2013 21:23:47 +0000 Subject: [PATCH] m32script: fix parsing negated labels, getnumber* with neg. 'max'. Exposed by this snippet from a.m32: getnumber256 .owner "OWNER (projection picnum): " -MAXTILES Now, Alt+KP2 works as expected in 3D mode. git-svn-id: https://svn.eduke32.com/eduke32@4196 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/source/m32def.c | 2 +- polymer/eduke32/source/m32exec.c | 2 ++ polymer/eduke32/source/m32vars.c | 2 ++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/polymer/eduke32/source/m32def.c b/polymer/eduke32/source/m32def.c index e52d74ac0..1471e6be3 100644 --- a/polymer/eduke32/source/m32def.c +++ b/polymer/eduke32/source/m32def.c @@ -1274,7 +1274,7 @@ static void C_GetNextVarType(int32_t type) { // if (!(g_numCompilerErrors || g_numCompilerWarnings) && g_scriptDebug) // initprintf("%s:%d: debug: accepted defined label `%s' instead of gamevar.\n",g_szScriptFileName,g_lineNumber,label+(id*MAXLABELLEN)); - num = (1-!!(flags&M32_FLAG_NEGATE))*labelval[id]; + num = (1-2*!!(flags&M32_FLAG_NEGATE))*labelval[id]; if (type==GV_SIMPLE && (num<0 || num>=65536)) { diff --git a/polymer/eduke32/source/m32exec.c b/polymer/eduke32/source/m32exec.c index 13c929d15..60e1142f0 100644 --- a/polymer/eduke32/source/m32exec.c +++ b/polymer/eduke32/source/m32exec.c @@ -2373,6 +2373,8 @@ badindex: if (max==0) max = INT32_MAX; + else + max = klabs(max); //OSD_Printf("max:%d, sign:%d\n", max, sign); if (tw==CON_GETNUMBERFROMUSER) diff --git a/polymer/eduke32/source/m32vars.c b/polymer/eduke32/source/m32vars.c index b8a566501..2b9367a67 100644 --- a/polymer/eduke32/source/m32vars.c +++ b/polymer/eduke32/source/m32vars.c @@ -266,6 +266,8 @@ int32_t __fastcall Gv_GetVarX(register int32_t id) if (id == M32_THISACTOR_VAR_ID) return vm.g_i; + id &= ~M32_FLAG_NEGATE; + if ((id & M32_BITS_MASK) == M32_FLAG_CONSTANT) { switch (id&3)