From d1b9e1db7a7bf8394492d3c82a9598d2ba2a98cf Mon Sep 17 00:00:00 2001 From: Strangerke Date: Fri, 6 Sep 2019 08:02:29 +0200 Subject: HDB: Initialize some more uninitialized variables. --- engines/hdb/file-manager.cpp | 19 +++++++------------ engines/hdb/hdb.cpp | 28 ++++++++++++++++++++++++---- engines/hdb/hdb.h | 6 +++--- engines/hdb/map.cpp | 14 ++++++++++++++ 4 files changed, 48 insertions(+), 19 deletions(-) (limited to 'engines/hdb') diff --git a/engines/hdb/file-manager.cpp b/engines/hdb/file-manager.cpp index bc751749f5..9c2eca1a11 100644 --- a/engines/hdb/file-manager.cpp +++ b/engines/hdb/file-manager.cpp @@ -31,6 +31,8 @@ namespace HDB { FileMan::FileMan() { _mpcFile = new Common::File; + _dataHeader.id = 0; + _dataHeader.dirSize = 0; } FileMan::~FileMan() { @@ -40,23 +42,17 @@ FileMan::~FileMan() { } void FileMan::openMPC(const Common::String &filename) { - if (!_mpcFile->open(filename)) { + if (!_mpcFile->open(filename)) error("FileMan::openMPC(): Error reading the MSD/MPC file %s", filename.c_str()); - } _dataHeader.id = _mpcFile->readUint32BE(); - if (_dataHeader.id == MKTAG('M', 'P', 'C', 'C')) { + if (_dataHeader.id == MKTAG('M', 'P', 'C', 'C')) error("FileMan::openMPC: Compressed MPC File"); - } else if (_dataHeader.id == MKTAG('M', 'P', 'C', 'U')) { - // we're fine - } else if (_dataHeader.id == MKTAG('M', 'S', 'D', 'C')) { - // we're fine - } else if (_dataHeader.id == MKTAG('M', 'S', 'D', 'U')) { + else if (_dataHeader.id == MKTAG('M', 'S', 'D', 'U')) error("FileMan::openMPC: Uncompressed MSD File"); - } else { + else if (_dataHeader.id != MKTAG('M', 'P', 'C', 'U') && _dataHeader.id != MKTAG('M', 'S', 'D', 'C')) error("FileMan::openMPC: Invalid MPC/MSD File."); - } // read the directory uint32 offset = _mpcFile->readUint32LE(); @@ -72,9 +68,8 @@ void FileMan::openMPC(const Common::String &filename) { for (uint32 fileIndex = 0; fileIndex < _dataHeader.dirSize; fileIndex++) { MPCEntry *dirEntry = new MPCEntry(); - for (int i = 0; i < 64; i++) { + for (int i = 0; i < 64; i++) dirEntry->filename[i] = tolower(_mpcFile->readByte()); - } dirEntry->offset = _mpcFile->readUint32LE(); dirEntry->length = _mpcFile->readUint32LE(); diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp index c7c206c145..5b09f3de09 100644 --- a/engines/hdb/hdb.cpp +++ b/engines/hdb/hdb.cpp @@ -90,6 +90,27 @@ HDBGame::HDBGame(OSystem *syst, const ADGameDescription *gameDesc) : Engine(syst _monkeystone14 = STARS_MONKEYSTONE_14_FAKE; _monkeystone21 = STARS_MONKEYSTONE_21_FAKE; + _gameShutdown = false; + _progressGfx = nullptr; + _progressMarkGfx = nullptr; + _loadingScreenGfx = nullptr; + _logoGfx = nullptr; + _progressCurrent = -1; + _progressXOffset = -1; + _progressMax = -1; + _gameState = GAME_TITLE; + _actionMode = -1; + _pauseFlag = false; + _debugFlag = -1; + _debugLogo = nullptr; + _dx = 0; + _dy = 0; + _changeLevel = false; + _saveInfo.active = false; + _saveInfo.slot = 0; + _loadInfo.active = false; + _loadInfo.slot = 0; + syncSoundSettings(); } @@ -159,7 +180,7 @@ bool HDBGame::init() { _menu->startTitle(); _gameShutdown = false; - _pauseFlag = 0; + _pauseFlag = false; _systemInit = true; if (!g_hdb->isPPC()) _loadingScreenGfx = _gfx->loadPic(PIC_LOADSCREEN); @@ -355,11 +376,10 @@ void HDBGame::paint() { } // Draw FPS on Screen in Debug Mode - if (_debugFlag == 1) { + if (_debugFlag == 1) _gfx->drawDebugInfo(_debugLogo, _frames.size()); - } else if (_debugFlag == 2) { + else if (_debugFlag == 2) _debugLogo->drawMasked(_screenWidth - 32, 0); - } _gfx->updateVideo(); } diff --git a/engines/hdb/hdb.h b/engines/hdb/hdb.h index eb3a81886a..8a23bdb6a6 100644 --- a/engines/hdb/hdb.h +++ b/engines/hdb/hdb.h @@ -248,10 +248,10 @@ public: } void togglePause() { - _pauseFlag ^= 1; + _pauseFlag ^= true; } - int getPause() { + bool getPause() { return _pauseFlag; } @@ -345,7 +345,7 @@ private: int _actionMode; // 0 or 1 // Misc Variables - int _pauseFlag; + bool _pauseFlag; bool _cheating; int _debugFlag; Tile *_debugLogo; diff --git a/engines/hdb/map.cpp b/engines/hdb/map.cpp index a0eedcb58c..0edc51389b 100644 --- a/engines/hdb/map.cpp +++ b/engines/hdb/map.cpp @@ -55,6 +55,20 @@ Map::Map() { _background = NULL; _foreground = NULL; _iconList = NULL; + + _width = 0; + _height = 0; + _mapX = 0; + _mapY = 0; + _mapTileX = 0; + _mapTileY = 0; + _mapTileXOff = 0; + _mapTileYOff = 0; + _backgroundOffset = 0; + _foregroundOffset = 0; + _iconNum = 0; + _iconListOffset = 0; + _infoNum = 0; } Map::~Map() { -- cgit v1.2.3