From 4b8f6991e9a859fedd200dddb3e51d0256737fbb Mon Sep 17 00:00:00 2001 From: Paul Date: Fri, 24 Nov 2000 21:08:03 +0000 Subject: [PATCH] --- source/system/dbg.cpp | 4 ++-- source/system/gstate.cpp | 39 ++++++++++++++++++++++++++++++++++++++- 2 files changed, 40 insertions(+), 3 deletions(-) diff --git a/source/system/dbg.cpp b/source/system/dbg.cpp index 7a16bb233..eee7925e7 100644 --- a/source/system/dbg.cpp +++ b/source/system/dbg.cpp @@ -55,12 +55,12 @@ Available options are: #define DBG_OUTPUT_TO_DEBUGGER #define DBG_SHOW_MESSAGE_ORIGIN #define DBG_FILENAME_LENGTH 16 - #define DBG_DEFAULT_CHANNEL DC_CHARLES|DC_SYSTEM|DC_SOUND + #define DBG_DEFAULT_CHANNEL DC_CHARLES|DC_SYSTEM #elif __USER_dave__ #define DBG_OUTPUT_TO_DEBUGGER #define DBG_SHOW_MESSAGE_ORIGIN #define DBG_FILENAME_LENGTH 16 - #define DBG_DEFAULT_CHANNEL DC_DAVE|DC_SYSTEM|DC_SOUND + #define DBG_DEFAULT_CHANNEL DC_DAVE|DC_SYSTEM #elif __USER_paul__ #define DBG_OUTPUT_TO_DEBUGGER #define DBG_OUTPUT_TO_LOG diff --git a/source/system/gstate.cpp b/source/system/gstate.cpp index b135be8bd..316f572a0 100644 --- a/source/system/gstate.cpp +++ b/source/system/gstate.cpp @@ -19,6 +19,9 @@ #include "system\clickcount.h" #endif +#ifndef __MEMORY_HEADER__ +#include "mem\memory.h" +#endif /*****************************************************************************/ @@ -28,6 +31,12 @@ static CScene *s_pendingScene; int GameState::s_timeSinceLast; static CClickCount s_clickCounter; +#ifdef __VERSION_DEBUG__ +static int s_baseMemory=0; +static int s_baseSceneMemory=0; +#endif + + /*****************************************************************************/ /*****************************************************************************/ @@ -54,16 +63,44 @@ void GameState::think() if(s_currentScene->readyToShutdown()) { SYSTEM_DBGMSG("GameState: Closing down scene.."); +#ifdef __VERSION_DEBUG__ + int gain; + gain=MainRam.RamUsed-s_baseSceneMemory; + if(gain) + { + SYSTEM_DBGMSG("Scene allocated an extra %d bytes after init()",gain); + } +#endif ASSERT(s_pendingScene); // There really should be a scene pending before you shutdown..! s_currentScene->shutdown(); s_currentScene=NULL; +#ifdef __VERSION_DEBUG__ + int loss; + loss=MainRam.RamUsed-s_baseMemory; + if(loss) + { + SYSTEM_DBGMSG("MEMORY HAS CHANGED BY %d BYTES DURING SCENE!",loss); + ASSERT(0); + s_baseMemory=0; + } +#endif } } if(!s_currentScene) { - SYSTEM_DBGMSG("GameState: Opening new scene.."); +#ifdef __VERSION_DEBUG__ + if(s_baseMemory==0) + { + s_baseMemory=MainRam.RamUsed; + } + SYSTEM_DBGMSG("GameState: Opening new scene ( with %d bytes used )",s_baseMemory); +#endif s_currentScene=s_pendingScene; s_currentScene->init(); +#ifdef __VERSION_DEBUG__ + s_baseSceneMemory=MainRam.RamUsed; + SYSTEM_DBGMSG("GameState: Scene has used %d bytes during init()",s_baseSceneMemory-s_baseMemory); +#endif s_pendingScene=NULL; } }