Remove redundant checks for some map state function uses.

Also, prettify G_FreeMapState(), remove some duplicate function decls and
resurrect 'savestate' and 'restorestate' OSD commands for the debug build.

git-svn-id: https://svn.eduke32.com/eduke32@3791 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
helixhorned 2013-05-19 19:29:23 +00:00
parent 38d12b9441
commit 4a6fc2b94f
7 changed files with 24 additions and 29 deletions

View file

@ -9625,7 +9625,8 @@ static void G_Cleanup(void)
if (MapInfo[i].filename != NULL) Bfree(MapInfo[i].filename); if (MapInfo[i].filename != NULL) Bfree(MapInfo[i].filename);
if (MapInfo[i].musicfn != NULL) Bfree(MapInfo[i].musicfn); if (MapInfo[i].musicfn != NULL) Bfree(MapInfo[i].musicfn);
if (MapInfo[i].alt_musicfn != NULL) Bfree(MapInfo[i].alt_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--) for (i=MAXQUOTES-1; i>=0; i--)

View file

@ -3400,7 +3400,6 @@ nullquote:
continue; continue;
case CON_LOADMAPSTATE: 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++; insptr++;
continue; continue;
@ -3414,7 +3413,7 @@ nullquote:
CON_ERRPRINTF("Invalid map number: %d\n", j); CON_ERRPRINTF("Invalid map number: %d\n", j);
continue; continue;
} }
if (MapInfo[j].savedstate)
G_FreeMapState(j); G_FreeMapState(j);
} }
continue; continue;

View file

@ -146,10 +146,7 @@ int32_t A_GetFurthestAngle(int32_t iActor,int32_t angs);
void A_GetZLimits(int32_t iActor); void A_GetZLimits(int32_t iActor);
int32_t G_GetAngleDelta(int32_t a,int32_t na); int32_t G_GetAngleDelta(int32_t a,int32_t na);
void G_RestoreMapState(mapstate_t *save); 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 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); int32_t VM_OnEvent(int32_t iEventID,int32_t iActor,int32_t iPlayer,int32_t lDist, int32_t iReturn);
void VM_ScriptInfo(void); void VM_ScriptInfo(void);

View file

@ -34,9 +34,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
extern int32_t OSD_errors; 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() */ static void Gv_Free(void) /* called from Gv_ReadSave() and Gv_ResetVars() */
{ {
// call this function as many times as needed. // 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); G_FreeMapState(i);
} }

View file

@ -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_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); int32_t Gv_NewVar(const char *pszLabel,intptr_t lValue,uint32_t dwFlags);
void __fastcall A_ResetVars(register int32_t iActor); void __fastcall A_ResetVars(register int32_t iActor);
void G_FreeMapState(int32_t mapnum);
void Gv_DumpValues(void); void Gv_DumpValues(void);
void Gv_InitWeaponPointers(void); void Gv_InitWeaponPointers(void);
void Gv_RefreshPointers(void); void Gv_RefreshPointers(void);

View file

@ -1136,7 +1136,7 @@ static int32_t osdcmd_screenshot(const osdfuncparm_t *parm)
return OSDCMD_OK; return OSDCMD_OK;
} }
/* #ifdef DEBUGGINGAIDS
static int32_t osdcmd_savestate(const osdfuncparm_t *parm) static int32_t osdcmd_savestate(const osdfuncparm_t *parm)
{ {
UNREFERENCED_PARAMETER(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) static int32_t osdcmd_restorestate(const osdfuncparm_t *parm)
{ {
UNREFERENCED_PARAMETER(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; return OSDCMD_OK;
} }
*/ #endif
#ifdef DEBUGGINGAIDS #ifdef DEBUGGINGAIDS
static int32_t osdcmd_inittimer(const osdfuncparm_t *parm) 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("unbindall","unbindall: unbinds all keys", osdcmd_unbindall);
OSD_RegisterFunction("vidmode","vidmode <xdim> <ydim> <bpp> <fullscreen>: change the video mode",osdcmd_vidmode); OSD_RegisterFunction("vidmode","vidmode <xdim> <ydim> <bpp> <fullscreen>: change the video mode",osdcmd_vidmode);
// OSD_RegisterFunction("savestate","",osdcmd_savestate); #ifdef DEBUGGINGAIDS
// OSD_RegisterFunction("restorestate","",osdcmd_restorestate); OSD_RegisterFunction("savestate","",osdcmd_savestate);
OSD_RegisterFunction("restorestate","",osdcmd_restorestate);
#endif
//baselayer_onvideomodechange = onvideomodechange; //baselayer_onvideomodechange = onvideomodechange;
return 0; return 0;

View file

@ -2048,23 +2048,24 @@ int32_t G_EnterLevel(int32_t g)
void G_FreeMapState(int32_t mapnum) void G_FreeMapState(int32_t mapnum)
{ {
map_t *mapinfo = &MapInfo[mapnum];
#if !defined LUNATIC #if !defined LUNATIC
int32_t j; int32_t j;
#endif
if (mapinfo->savedstate == NULL)
return;
#if !defined LUNATIC
for (j=0; j<g_gameVarCount; j++) for (j=0; j<g_gameVarCount; j++)
{ {
if (aGameVars[j].dwFlags & GAMEVAR_NORESET) continue; if (aGameVars[j].dwFlags & GAMEVAR_NORESET) continue;
if (aGameVars[j].dwFlags & GAMEVAR_PERPLAYER) if (aGameVars[j].dwFlags & (GAMEVAR_PERPLAYER|GAMEVAR_PERACTOR))
{ {
if (MapInfo[mapnum].savedstate->vars[j]) if (mapinfo->savedstate->vars[j])
Bfree(MapInfo[mapnum].savedstate->vars[j]); Bfree(mapinfo->savedstate->vars[j]);
}
else if (aGameVars[j].dwFlags & GAMEVAR_PERACTOR)
{
if (MapInfo[mapnum].savedstate->vars[j])
Bfree(MapInfo[mapnum].savedstate->vars[j]);
} }
} }
#endif #endif
Bfree(MapInfo[mapnum].savedstate); Bfree(mapinfo->savedstate);
MapInfo[mapnum].savedstate = NULL; mapinfo->savedstate = NULL;
} }