diff --git a/polymer/eduke32/source/game.c b/polymer/eduke32/source/game.c index efb66f946..b4d0c39c4 100644 --- a/polymer/eduke32/source/game.c +++ b/polymer/eduke32/source/game.c @@ -9625,7 +9625,8 @@ static void G_Cleanup(void) if (MapInfo[i].filename != NULL) Bfree(MapInfo[i].filename); if (MapInfo[i].musicfn != NULL) Bfree(MapInfo[i].musicfn); if (MapInfo[i].alt_musicfn != NULL) Bfree(MapInfo[i].alt_musicfn); - if (MapInfo[i].savedstate != NULL) G_FreeMapState(i); + + G_FreeMapState(i); } for (i=MAXQUOTES-1; i>=0; i--) diff --git a/polymer/eduke32/source/gameexec.c b/polymer/eduke32/source/gameexec.c index 32da02f21..9eb58c655 100644 --- a/polymer/eduke32/source/gameexec.c +++ b/polymer/eduke32/source/gameexec.c @@ -3400,8 +3400,7 @@ nullquote: continue; case CON_LOADMAPSTATE: - if (MapInfo[ud.volume_number*MAXLEVELS+ud.level_number].savedstate) - G_RestoreMapState(MapInfo[ud.volume_number*MAXLEVELS+ud.level_number].savedstate); + G_RestoreMapState(MapInfo[ud.volume_number*MAXLEVELS+ud.level_number].savedstate); insptr++; continue; @@ -3414,8 +3413,8 @@ nullquote: CON_ERRPRINTF("Invalid map number: %d\n", j); continue; } - if (MapInfo[j].savedstate) - G_FreeMapState(j); + + G_FreeMapState(j); } continue; diff --git a/polymer/eduke32/source/gameexec.h b/polymer/eduke32/source/gameexec.h index 671ce3ec1..4155201b7 100644 --- a/polymer/eduke32/source/gameexec.h +++ b/polymer/eduke32/source/gameexec.h @@ -146,10 +146,7 @@ int32_t A_GetFurthestAngle(int32_t iActor,int32_t angs); void A_GetZLimits(int32_t iActor); int32_t G_GetAngleDelta(int32_t a,int32_t na); void G_RestoreMapState(mapstate_t *save); -void G_RestoreMapState(mapstate_t *save); void G_SaveMapState(mapstate_t *save); -void G_SaveMapState(mapstate_t *save); -//void Gv_RefreshPointers(void); int32_t VM_OnEvent(int32_t iEventID,int32_t iActor,int32_t iPlayer,int32_t lDist, int32_t iReturn); void VM_ScriptInfo(void); diff --git a/polymer/eduke32/source/gamevars.c b/polymer/eduke32/source/gamevars.c index 354415cef..9fb1c9dc1 100644 --- a/polymer/eduke32/source/gamevars.c +++ b/polymer/eduke32/source/gamevars.c @@ -34,9 +34,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. extern int32_t OSD_errors; -void Gv_RefreshPointers(void); -extern void G_FreeMapState(int32_t mapnum); - static void Gv_Free(void) /* called from Gv_ReadSave() and Gv_ResetVars() */ { // call this function as many times as needed. @@ -192,7 +189,7 @@ int32_t Gv_ReadSave(int32_t fil, int32_t newbehav) } } } - else if (MapInfo[i].savedstate) + else { G_FreeMapState(i); } diff --git a/polymer/eduke32/source/gamevars.h b/polymer/eduke32/source/gamevars.h index 61b32ef52..31ef8a6c2 100644 --- a/polymer/eduke32/source/gamevars.h +++ b/polymer/eduke32/source/gamevars.h @@ -105,7 +105,6 @@ int32_t Gv_GetVarByLabel(const char *szGameLabel,int32_t lDefault,int32_t iActor int32_t Gv_NewArray(const char *pszLabel,void *arrayptr,intptr_t asize,uint32_t dwFlags); int32_t Gv_NewVar(const char *pszLabel,intptr_t lValue,uint32_t dwFlags); void __fastcall A_ResetVars(register int32_t iActor); -void G_FreeMapState(int32_t mapnum); void Gv_DumpValues(void); void Gv_InitWeaponPointers(void); void Gv_RefreshPointers(void); diff --git a/polymer/eduke32/source/osdcmds.c b/polymer/eduke32/source/osdcmds.c index b1356126f..1120b26c3 100644 --- a/polymer/eduke32/source/osdcmds.c +++ b/polymer/eduke32/source/osdcmds.c @@ -1136,7 +1136,7 @@ static int32_t osdcmd_screenshot(const osdfuncparm_t *parm) return OSDCMD_OK; } -/* +#ifdef DEBUGGINGAIDS static int32_t osdcmd_savestate(const osdfuncparm_t *parm) { UNREFERENCED_PARAMETER(parm); @@ -1149,11 +1149,10 @@ static int32_t osdcmd_savestate(const osdfuncparm_t *parm) static int32_t osdcmd_restorestate(const osdfuncparm_t *parm) { UNREFERENCED_PARAMETER(parm); - if (MapInfo[ud.volume_number*MAXLEVELS+ud.level_number].savedstate) - G_RestoreMapState(MapInfo[ud.volume_number*MAXLEVELS+ud.level_number].savedstate); + G_RestoreMapState(MapInfo[ud.volume_number*MAXLEVELS+ud.level_number].savedstate); return OSDCMD_OK; } -*/ +#endif #ifdef DEBUGGINGAIDS static int32_t osdcmd_inittimer(const osdfuncparm_t *parm) @@ -1608,8 +1607,10 @@ int32_t registerosdcommands(void) OSD_RegisterFunction("unbindall","unbindall: unbinds all keys", osdcmd_unbindall); OSD_RegisterFunction("vidmode","vidmode : change the video mode",osdcmd_vidmode); -// OSD_RegisterFunction("savestate","",osdcmd_savestate); -// OSD_RegisterFunction("restorestate","",osdcmd_restorestate); +#ifdef DEBUGGINGAIDS + OSD_RegisterFunction("savestate","",osdcmd_savestate); + OSD_RegisterFunction("restorestate","",osdcmd_restorestate); +#endif //baselayer_onvideomodechange = onvideomodechange; return 0; diff --git a/polymer/eduke32/source/premap.c b/polymer/eduke32/source/premap.c index 4020490a3..50678cf51 100644 --- a/polymer/eduke32/source/premap.c +++ b/polymer/eduke32/source/premap.c @@ -2048,23 +2048,24 @@ int32_t G_EnterLevel(int32_t g) void G_FreeMapState(int32_t mapnum) { + map_t *mapinfo = &MapInfo[mapnum]; #if !defined LUNATIC int32_t j; +#endif + if (mapinfo->savedstate == NULL) + return; + +#if !defined LUNATIC for (j=0; jvars[j]) - Bfree(MapInfo[mapnum].savedstate->vars[j]); - } - else if (aGameVars[j].dwFlags & GAMEVAR_PERACTOR) - { - if (MapInfo[mapnum].savedstate->vars[j]) - Bfree(MapInfo[mapnum].savedstate->vars[j]); + if (mapinfo->savedstate->vars[j]) + Bfree(mapinfo->savedstate->vars[j]); } } #endif - Bfree(MapInfo[mapnum].savedstate); - MapInfo[mapnum].savedstate = NULL; + Bfree(mapinfo->savedstate); + mapinfo->savedstate = NULL; }