From 5ab826f135524e81d3719ded11970b6b5753eb61 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 24 Sep 2017 12:46:32 -0400 Subject: TITANIC: Add some guards against using the game manager during game exit --- engines/titanic/core/game_object.cpp | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) (limited to 'engines') diff --git a/engines/titanic/core/game_object.cpp b/engines/titanic/core/game_object.cpp index d52fa27669..b6923c27a4 100644 --- a/engines/titanic/core/game_object.cpp +++ b/engines/titanic/core/game_object.cpp @@ -845,24 +845,34 @@ int CGameObject::addTimer(uint firstDuration, uint repeatDuration) { CTimeEventInfo *timer = new CTimeEventInfo(getTicksCount(), repeatDuration != 0, firstDuration, repeatDuration, this, 0, CString()); - getGameManager()->addTimer(timer); + CGameManager *gameMan = getGameManager(); + if (gameMan) + gameMan->addTimer(timer); return timer->_id; } void CGameObject::stopTimer(int id) { - getGameManager()->stopTimer(id); + CGameManager *gameMan = getGameManager(); + if (gameMan) + gameMan->stopTimer(id); } int CGameObject::startAnimTimer(const CString &action, uint firstDuration, uint repeatDuration) { - CTimeEventInfo *timer = new CTimeEventInfo(getTicksCount(), repeatDuration > 0, - firstDuration, repeatDuration, this, 0, action); - getGameManager()->addTimer(timer); + CGameManager *gameMan = getGameManager(); + if (gameMan) { + CTimeEventInfo *timer = new CTimeEventInfo(getTicksCount(), repeatDuration > 0, + firstDuration, repeatDuration, this, 0, action); + gameMan->addTimer(timer); + return timer->_id; + } - return timer->_id; + return -1; } void CGameObject::stopAnimTimer(int id) { - getGameManager()->stopTimer(id); + CGameManager *gameMan = getGameManager(); + if (gameMan) + gameMan->stopTimer(id); } void CGameObject::gotoView(const CString &viewName, const CString &clipName) { -- cgit v1.2.3