From 54f345f78f347e7aaa33377d3bf4c9d0ea74120b Mon Sep 17 00:00:00 2001 From: helixhorned Date: Wed, 3 Aug 2011 17:22:46 +0000 Subject: [PATCH] Add a warning when calling {save,load}mapstate from EVENT_ANIMATESPRITES (forgotten from earlier changes). git-svn-id: https://svn.eduke32.com/eduke32@1956 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/source/astub.c | 3 +-- polymer/eduke32/source/gamedef.c | 9 +++++++++ polymer/eduke32/source/gameexec.c | 16 ++++++++++++++++ polymer/eduke32/source/gameexec.h | 2 ++ 4 files changed, 28 insertions(+), 2 deletions(-) diff --git a/polymer/eduke32/source/astub.c b/polymer/eduke32/source/astub.c index 165af4257..70b34ec17 100644 --- a/polymer/eduke32/source/astub.c +++ b/polymer/eduke32/source/astub.c @@ -9147,8 +9147,7 @@ static int32_t osdcmd_do(const osdfuncparm_t *parm) if (!tp) goto OUTOFMEM; Bmemcpy(tp, parm->raw+ofs, slen); - // explicitly typed space at beginning of command (really? not eaten by OSD - // code?) or M32script call from 'special functions' menu + // M32script call from 'special functions' menu dontsavehist = (slen==0 || tp[0]==' '); // needed so that subsequent commands won't execute old stuff. diff --git a/polymer/eduke32/source/gamedef.c b/polymer/eduke32/source/gamedef.c index 9ab06b19b..53f206cf5 100644 --- a/polymer/eduke32/source/gamedef.c +++ b/polymer/eduke32/source/gamedef.c @@ -3771,6 +3771,15 @@ static int32_t C_ParseCommand(int32_t loop) case CON_FLASH: case CON_SAVEMAPSTATE: case CON_LOADMAPSTATE: + if (tw != CON_FLASH) + { + if (g_currentEvent == EVENT_ANIMATESPRITES) + { + initprintf("%s:%d: warning: found `%s' inside EVENT_ANIMATESPRITES\n", + g_szScriptFileName,g_lineNumber,tempbuf); + g_numCompilerWarnings++; + } + } continue; case CON_DRAGPOINT: diff --git a/polymer/eduke32/source/gameexec.c b/polymer/eduke32/source/gameexec.c index 92a9841c8..571fa4451 100644 --- a/polymer/eduke32/source/gameexec.c +++ b/polymer/eduke32/source/gameexec.c @@ -51,6 +51,8 @@ int32_t g_errorLineNum; int32_t g_tw; extern int32_t ticrandomseed; +int32_t g_currentEventExec = -1; + GAMEEXEC_STATIC void VM_Execute(int32_t loop); #include "gamestructures.c" @@ -95,6 +97,7 @@ void VM_OnEvent(register int32_t iEventID, register int32_t iActor, register int vmstate_t tempvm = { iActor, iPlayer, lDist, &actor[iActor].t_data[0], &sprite[iActor], 0 }; + g_currentEventExec = iEventID; insptr = apScriptGameEvent[iEventID]; Bmemcpy(&vm_backup, &vm, sizeof(vmstate_t)); @@ -113,6 +116,8 @@ void VM_OnEvent(register int32_t iEventID, register int32_t iActor, register int Bmemcpy(&vm, &vm_backup, sizeof(vmstate_t)); insptr = oinsptr; + + g_currentEventExec = -1; } } @@ -4958,6 +4963,12 @@ void G_SaveMapState(mapstate_t *save) Bmemcpy(&save->numsectors,&numsectors,sizeof(numsectors)); Bmemcpy(&save->sector[0],§or[0],sizeof(sectortype)*MAXSECTORS); Bmemcpy(&save->sprite[0],&sprite[0],sizeof(spritetype)*MAXSPRITES); + + if (g_currentEventExec == EVENT_ANIMATESPRITES) + initprintf("Line %d: savemapstate called from EVENT_ANIMATESPRITES. WHY?\n", g_errorLineNum); + else + for (i=0; ispriteext[0],&spriteext[0],sizeof(spriteext_t)*MAXSPRITES); Bmemcpy(&save->headspritesect[0],&headspritesect[0],sizeof(headspritesect)); Bmemcpy(&save->prevspritesect[0],&prevspritesect[0],sizeof(prevspritesect)); @@ -5085,6 +5096,11 @@ void G_RestoreMapState(mapstate_t *save) Bmemcpy(§or[0],&save->sector[0],sizeof(sectortype)*MAXSECTORS); Bmemcpy(&sprite[0],&save->sprite[0],sizeof(spritetype)*MAXSPRITES); Bmemcpy(&spriteext[0],&save->spriteext[0],sizeof(spriteext_t)*MAXSPRITES); + if (g_currentEventExec == EVENT_ANIMATESPRITES) + initprintf("Line %d: loadmapstate called from EVENT_ANIMATESPRITES. WHY?\n",g_errorLineNum); + else + for (i=0; iheadspritesect[0],sizeof(headspritesect)); Bmemcpy(&prevspritesect[0],&save->prevspritesect[0],sizeof(prevspritesect)); Bmemcpy(&nextspritesect[0],&save->nextspritesect[0],sizeof(nextspritesect)); diff --git a/polymer/eduke32/source/gameexec.h b/polymer/eduke32/source/gameexec.h index 6a8ff7718..8d585b099 100644 --- a/polymer/eduke32/source/gameexec.h +++ b/polymer/eduke32/source/gameexec.h @@ -121,6 +121,8 @@ extern int32_t g_tw; extern int32_t ticrandomseed; extern vmstate_t vm; +extern int32_t g_currentEventExec; + void A_Execute(int32_t iActor,int32_t iPlayer,int32_t lDist); void A_Fall(int32_t iActor); int32_t A_FurthestVisiblePoint(int32_t iActor,spritetype *ts,int32_t *dax,int32_t *day);