From 3aac0c1bd4c8db12542c4a8e16f2bf4f9a9bbd63 Mon Sep 17 00:00:00 2001 From: helixhorned Date: Sun, 4 Dec 2011 21:20:48 +0000 Subject: [PATCH] M32Script: when failing to compile a state with a menu name, don't keep the menu entry. git-svn-id: https://svn.eduke32.com/eduke32@2154 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/source/m32def.c | 18 ++++++++++++++---- polymer/eduke32/source/m32exec.c | 2 +- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/polymer/eduke32/source/m32def.c b/polymer/eduke32/source/m32def.c index 7ad7c288f..9b7714620 100644 --- a/polymer/eduke32/source/m32def.c +++ b/polymer/eduke32/source/m32def.c @@ -43,6 +43,7 @@ typedef struct { int32_t currentStateIdx; ofstype currentStateOfs; // the offset to the start of the currently parsed states' code + char *curStateMenuName; int32_t currentEvent; ofstype parsingEventOfs; @@ -57,7 +58,7 @@ typedef struct } compilerstate_t; static compilerstate_t cs; -static compilerstate_t cs_default = {-1, -1, -1, -1, 0, 0, NULL, NULL, 0, 0, 0, 0}; +static compilerstate_t cs_default = {-1, -1, NULL, -1, -1, 0, 0, NULL, NULL, 0, 0, 0, 0}; ////// ------------------- instype *script = NULL; @@ -1831,15 +1832,17 @@ static int32_t C_ParseCommand(void) statesinfo[j].numlocals = 0; Bsprintf(g_szCurrentBlockName, "%s", statesinfo[j].name); + if (cs.curStateMenuName) + Bfree(cs.curStateMenuName); + cs.curStateMenuName = NULL; + if (C_GetKeyword() < 0) { ofstype *oscriptptr = g_scriptPtr; if (C_GetNextVarOrString() == 1) // inline string { - const char *menufuncname = (const char *)(oscriptptr+1); - registerMenuFunction(menufuncname, j); - + cs.curStateMenuName = Bstrdup((const char *)(oscriptptr+1)); g_scriptPtr = oscriptptr; } else @@ -1969,6 +1972,13 @@ static int32_t C_ParseCommand(void) g_scriptPtr -= osize; } + if (cs.curStateMenuName) + { + registerMenuFunction(cs.curStateMenuName, j); + Bfree(cs.curStateMenuName); + cs.curStateMenuName = NULL; + } + g_didDefineSomething = 1; cs.currentStateOfs = -1; diff --git a/polymer/eduke32/source/m32exec.c b/polymer/eduke32/source/m32exec.c index 402805f40..a7c356332 100644 --- a/polymer/eduke32/source/m32exec.c +++ b/polymer/eduke32/source/m32exec.c @@ -3073,7 +3073,7 @@ dodefault: "Please e-mail the file mapster32.log along with every M32 file\n" "you're using and instructions how to reproduce this error to\n" "helixhorned@gmail.com.\n\n" - "Thank you!"); + "Thank you!\n"); vm.flags |= VMFLAG_ERROR; return 1; }