From f9cf18b95f1065449307cfb13d82eeeef77727e8 Mon Sep 17 00:00:00 2001 From: D G Turner Date: Mon, 30 Sep 2013 04:27:42 +0100 Subject: COMPOSER: Fix uninitialized class variables and divide by zero bugs. This was highlighted by Coverity in CID 1003844 and 1003410. --- engines/composer/composer.cpp | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) (limited to 'engines') diff --git a/engines/composer/composer.cpp b/engines/composer/composer.cpp index 5db778dfda..2d7075cba1 100644 --- a/engines/composer/composer.cpp +++ b/engines/composer/composer.cpp @@ -48,6 +48,15 @@ namespace Composer { ComposerEngine::ComposerEngine(OSystem *syst, const ComposerGameDescription *gameDesc) : Engine(syst), _gameDescription(gameDesc) { _rnd = new Common::RandomSource("composer"); _audioStream = NULL; + _currSoundPriority = 0; + _currentTime = 0; + _lastTime = 0; + _needsUpdate = true; + _directoriesToStrip = 1; + _mouseVisible = true; + _mouseEnabled = false; + _mouseSpriteId = 0; + _lastButton = NULL; } ComposerEngine::~ComposerEngine() { @@ -79,12 +88,6 @@ Common::Error ComposerEngine::run() { _queuedScripts[i]._scriptId = 0; } - _mouseVisible = true; - _mouseEnabled = false; - _mouseSpriteId = 0; - _lastButton = NULL; - - _directoriesToStrip = 1; if (!_bookIni.loadFromFile("book.ini")) { _directoriesToStrip = 0; if (!_bookIni.loadFromFile("programs/book.ini")) { @@ -103,7 +106,6 @@ Common::Error ComposerEngine::run() { height = atoi(getStringFromConfig("Common", "Height").c_str()); initGraphics(width, height, true); _screen.create(width, height, Graphics::PixelFormat::createFormatCLUT8()); - _needsUpdate = true; Graphics::Cursor *cursor = Graphics::makeDefaultWinCursor(); CursorMan.replaceCursor(cursor->getSurface(), cursor->getWidth(), cursor->getHeight(), cursor->getHotspotX(), @@ -113,11 +115,12 @@ Common::Error ComposerEngine::run() { loadLibrary(0); - _currentTime = 0; - _lastTime = 0; - uint fps = atoi(getStringFromConfig("Common", "FPS").c_str()); - uint frameTime = 1000 / fps; + uint frameTime = 125; // Default to 125ms (1000/8) + if (fps != 0) + frameTime = 1000 / fps; + else + warning("FPS in book.ini is zero. Defaulting to 8..."); uint32 lastDrawTime = 0; while (!shouldQuit()) { -- cgit v1.2.3