aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorD G Turner2013-09-30 04:27:42 +0100
committerD G Turner2013-09-30 04:27:42 +0100
commitf9cf18b95f1065449307cfb13d82eeeef77727e8 (patch)
tree19e2ae188e4a48644be69cec4c535e9d71e23bd8 /engines
parentdd18159578722c64841c9427f56fb5255bb4535e (diff)
downloadscummvm-rg350-f9cf18b95f1065449307cfb13d82eeeef77727e8.tar.gz
scummvm-rg350-f9cf18b95f1065449307cfb13d82eeeef77727e8.tar.bz2
scummvm-rg350-f9cf18b95f1065449307cfb13d82eeeef77727e8.zip
COMPOSER: Fix uninitialized class variables and divide by zero bugs.
This was highlighted by Coverity in CID 1003844 and 1003410.
Diffstat (limited to 'engines')
-rw-r--r--engines/composer/composer.cpp25
1 files changed, 14 insertions, 11 deletions
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()) {