From ee30817b75d5d61cf4af2b6f47c665246a11f5da Mon Sep 17 00:00:00 2001 From: Paul Date: Thu, 26 Oct 2000 16:50:54 +0000 Subject: [PATCH] --- source/game/game.cpp | 6 ++++++ source/game/game.h | 11 ++++++----- source/paul/paul.h | 11 ++++++----- source/system/gstate.cpp | 25 +++++++++++++++---------- source/system/gstate.h | 1 + 5 files changed, 34 insertions(+), 20 deletions(-) diff --git a/source/game/game.cpp b/source/game/game.cpp index 9f424e5ae..bcda938f0 100644 --- a/source/game/game.cpp +++ b/source/game/game.cpp @@ -110,3 +110,9 @@ void CGameScene::think(int _frames) } /*****************************************************************************/ +int CGameScene::readyToShutdown() +{ + return false; +} + +/*****************************************************************************/ diff --git a/source/game/game.h b/source/game/game.h index dca50896f..2b5f87324 100644 --- a/source/game/game.h +++ b/source/game/game.h @@ -18,11 +18,12 @@ public: virtual ~CGameScene() {;} - void init(); - void shutdown(); - void render(); - void think(int _frames); - char *getSceneName() {return "Game";} + void init(); + void shutdown(); + void render(); + void think(int _frames); + int readyToShutdown(); + char *getSceneName() {return "Game";} private: diff --git a/source/paul/paul.h b/source/paul/paul.h index 5a74efaee..ea423d843 100644 --- a/source/paul/paul.h +++ b/source/paul/paul.h @@ -36,11 +36,12 @@ class CPaulScene : public CScene { public: - void init(); - void shutdown(); - void render(); - void think(int _frames); - char *getSceneName() {return"PaulsScene";} + void init(); + void shutdown(); + void render(); + void think(int _frames); + int readyToShutdown() {return false;} + char *getSceneName() {return"PaulsScene";} }; diff --git a/source/system/gstate.cpp b/source/system/gstate.cpp index 03a9c8f2d..6cd44104b 100644 --- a/source/system/gstate.cpp +++ b/source/system/gstate.cpp @@ -46,21 +46,26 @@ void GameState::think() { updateTimer(); - if( s_pendingScene ) + + if(s_pendingScene) + { + if(s_currentScene) { - if( !s_currentScene) + if(s_currentScene->readyToShutdown()) { - if( s_currentScene ) - { + ASSERT(s_pendingScene); // There really should be a scene pending before you shutdown..! s_currentScene->shutdown(); - } - - s_currentScene=s_pendingScene; - s_pendingScene=NULL; - - s_currentScene->init(); + s_currentScene=NULL; } } + if(!s_currentScene) + { + s_currentScene=s_pendingScene; + s_currentScene->init(); + s_pendingScene=NULL; + } + } + ASSERT(s_currentScene); s_currentScene->think(getFramesSinceLast()); } diff --git a/source/system/gstate.h b/source/system/gstate.h index f8d988c08..ea0c8a048 100644 --- a/source/system/gstate.h +++ b/source/system/gstate.h @@ -31,6 +31,7 @@ public: virtual void shutdown()=0; virtual void render()=0; virtual void think(int _frames)=0; + virtual int readyToShutdown()=0; virtual char *getSceneName()=0; protected: