aboutsummaryrefslogtreecommitdiff
path: root/engines/hdb
diff options
context:
space:
mode:
authorStrangerke2019-08-19 00:47:34 +0200
committerEugene Sandulenko2019-09-03 17:17:34 +0200
commit2178770898938b5b13e5ece25ea8f0b26e0c728c (patch)
tree0ccc0b00ab2170bfd9978f6d7604041f113ca9e2 /engines/hdb
parent23c7dc8ebd6f6443f476de010129bb01aff210b4 (diff)
downloadscummvm-rg350-2178770898938b5b13e5ece25ea8f0b26e0c728c.tar.gz
scummvm-rg350-2178770898938b5b13e5ece25ea8f0b26e0c728c.tar.bz2
scummvm-rg350-2178770898938b5b13e5ece25ea8f0b26e0c728c.zip
HDB: Change init functions to handle errors
Diffstat (limited to 'engines/hdb')
-rw-r--r--engines/hdb/ai-init.cpp3
-rw-r--r--engines/hdb/ai-inventory.cpp3
-rw-r--r--engines/hdb/ai.h2
-rw-r--r--engines/hdb/file-manager.cpp18
-rw-r--r--engines/hdb/file-manager.h2
-rw-r--r--engines/hdb/gfx.cpp9
-rw-r--r--engines/hdb/gfx.h2
-rw-r--r--engines/hdb/hdb.cpp28
-rw-r--r--engines/hdb/input.cpp4
-rw-r--r--engines/hdb/input.h2
-rw-r--r--engines/hdb/lua-script.cpp5
-rw-r--r--engines/hdb/lua-script.h2
-rw-r--r--engines/hdb/sound.cpp4
-rw-r--r--engines/hdb/sound.h2
-rw-r--r--engines/hdb/window.cpp5
-rw-r--r--engines/hdb/window.h2
16 files changed, 29 insertions, 64 deletions
diff --git a/engines/hdb/ai-init.cpp b/engines/hdb/ai-init.cpp
index 1e6336e252..32229d9908 100644
--- a/engines/hdb/ai-init.cpp
+++ b/engines/hdb/ai-init.cpp
@@ -1012,7 +1012,7 @@ AI::~AI() {
}
}
-bool AI::init() {
+void AI::init() {
_debugQMark = g_hdb->_gfx->loadIcon("icon_question_mark");
// Clear Waypoint list and load Waypoint graphics
@@ -1114,7 +1114,6 @@ bool AI::init() {
_weaponSelGfx = NULL;
restartSystem();
- return true;
}
void AI::clearPersistent() {
diff --git a/engines/hdb/ai-inventory.cpp b/engines/hdb/ai-inventory.cpp
index 85fde5e731..c67c11c7d0 100644
--- a/engines/hdb/ai-inventory.cpp
+++ b/engines/hdb/ai-inventory.cpp
@@ -300,7 +300,7 @@ void AI::newDelivery(const char *itemTextName, const char *itemGfxName, const ch
}
bool AI::completeDelivery(const char *id) {
- for (int i = 0; i < _numDeliveries; i++)
+ for (int i = 0; i < _numDeliveries; i++) {
if (!scumm_stricmp(_deliveries[i].id, id)) {
for (; i < _numDeliveries; i++)
memcpy(&_deliveries[i], &_deliveries[i + 1], sizeof(_deliveries[0]));
@@ -311,6 +311,7 @@ bool AI::completeDelivery(const char *id) {
g_hdb->_sound->playVoice(GUY_COMPLETED, 1);
return true;
}
+ }
return false;
}
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index bd418904a5..572ab79186 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -803,7 +803,7 @@ public:
AI();
~AI();
- bool init();
+ void init();
void clearPersistent();
void restartSystem();
const char *funcLookUp(void(*function)(AIEntity *e));
diff --git a/engines/hdb/file-manager.cpp b/engines/hdb/file-manager.cpp
index 1e23032108..e38d44f40e 100644
--- a/engines/hdb/file-manager.cpp
+++ b/engines/hdb/file-manager.cpp
@@ -39,33 +39,27 @@ FileMan::~FileMan() {
delete _dir[i];
}
-bool FileMan::openMPC(const Common::String &filename) {
- uint32 offset;
-
+void FileMan::openMPC(const Common::String &filename) {
if (!_mpcFile->open(filename)) {
error("FileMan::openMPC(): Error reading the MSD/MPC file %s", filename.c_str());
- return false;
}
_dataHeader.id = _mpcFile->readUint32BE();
if (_dataHeader.id == MKTAG('M', 'P', 'C', 'C')) {
- debug("COMPRESSED MPC FILE");
- return false;
+ 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')) {
- debug("UNCOMPRESSED MSD FILE");
- return false;
+ error("FileMan::openMPC: Uncompressed MSD File");
} else {
- error("Invalid MPC/MSD File.");
- return false;
+ error("FileMan::openMPC: Invalid MPC/MSD File.");
}
// read the directory
- offset = _mpcFile->readUint32LE();
+ uint32 offset = _mpcFile->readUint32LE();
_mpcFile->seek((int32)offset);
// Note: The MPC archive format assumes the offset to be uint32,
@@ -91,8 +85,6 @@ bool FileMan::openMPC(const Common::String &filename) {
_dir.push_back(dirEntry);
}
-
- return true;
}
void FileMan::closeMPC() {
diff --git a/engines/hdb/file-manager.h b/engines/hdb/file-manager.h
index faa8e84062..62caaadf84 100644
--- a/engines/hdb/file-manager.h
+++ b/engines/hdb/file-manager.h
@@ -68,7 +68,7 @@ public:
uint32 dirSize;
} _dataHeader;
- bool openMPC(const Common::String &filename);
+ void openMPC(const Common::String &filename);
void closeMPC();
void seek(int32 offset, int flag);
diff --git a/engines/hdb/gfx.cpp b/engines/hdb/gfx.cpp
index 8d352f77ab..635157f34f 100644
--- a/engines/hdb/gfx.cpp
+++ b/engines/hdb/gfx.cpp
@@ -85,8 +85,7 @@ Gfx::~Gfx() {
delete _skyClouds;
}
-bool Gfx::init() {
-
+void Gfx::init() {
// Set the default cursor pos & char clipping
setCursor(0, 0);
@@ -109,12 +108,12 @@ bool Gfx::init() {
// Load Game Font
if (!loadFont(HDB_FONT))
- return false;
+ error("Gfx::init: Couldn't load fonts");
// Read total number of tiles in game
_numTiles = g_hdb->_fileMan->getCount("t32_", TYPE_TILE32);
if (!_numTiles)
- return false;
+ error("Gfx::init: No tiles in game");
// Setup Tile Lookup Array
_tLookupArray = new TileLookup[_numTiles];
@@ -199,7 +198,6 @@ bool Gfx::init() {
}
_systemInit = true;
- return true;
}
void Gfx::save(Common::OutSaveFile *out) {
@@ -835,7 +833,6 @@ int Gfx::animateTile(int tileIndex) {
}
bool Gfx::loadFont(const char *string) {
-
Common::SeekableReadStream *stream = g_hdb->_fileMan->findFirstData(string, TYPE_FONT);
if (!stream)
return false;
diff --git a/engines/hdb/gfx.h b/engines/hdb/gfx.h
index a138e9fb13..b0c4ca749d 100644
--- a/engines/hdb/gfx.h
+++ b/engines/hdb/gfx.h
@@ -77,7 +77,7 @@ public:
Graphics::ManagedSurface _globalSurface;
- bool init();
+ void init();
void save(Common::OutSaveFile *out);
void loadSaveFile(Common::InSaveFile *in);
void fillScreen(uint32 color);
diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index 488158152e..b1fbb6f5e7 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -137,28 +137,14 @@ bool HDBGame::init() {
// Init fileMan
- if (!_fileMan->openMPC(getGameFile())) {
- error("FileMan::openMPC: Cannot find the %s data file", getGameFile());
- }
- if (!_gfx->init()) {
- error("Gfx::init: Couldn't initialize Gfx");
- }
- if (!_sound->init()) {
- error("Window::init: Couldn't initialize Sound");
- }
- if (!_ai->init()) {
- error("AI::init: Couldn't initialize AI");
- }
- if (!_window->init()) {
- error("Window::init: Couldn't initialize Window");
- }
- if (!_input->init()) {
- error("Input::init: Couldn't initialize Input");
- }
- if (!_lua->init()) {
- error("LuaScript::init: Couldn't load the GLOBAL.LUA code.");
- }
+ _fileMan->openMPC(getGameFile());
+ _gfx->init();
+ _sound->init();
+ _ai->init();
+ _window->init();
+ _input->init();
+ _lua->init();
_menu->init();
_debugLogo = _gfx->loadIcon("icon_debug_logo");
diff --git a/engines/hdb/input.cpp b/engines/hdb/input.cpp
index 333c227d64..3078d69291 100644
--- a/engines/hdb/input.cpp
+++ b/engines/hdb/input.cpp
@@ -31,7 +31,7 @@
namespace HDB {
-bool Input::init() {
+void Input::init() {
_stylusDown = false;
_buttons = 0;
@@ -49,8 +49,6 @@ bool Input::init() {
_mouseY = g_hdb->_screenHeight / 2;
_mouseLButton = _mouseMButton = _mouseRButton = 0;
-
- return true;
}
void Input::setButtons(uint16 b) {
diff --git a/engines/hdb/input.h b/engines/hdb/input.h
index 9ea364a4e1..3d469946ee 100644
--- a/engines/hdb/input.h
+++ b/engines/hdb/input.h
@@ -42,7 +42,7 @@ enum Button {
class Input {
public:
- bool init();
+ void init();
void setButtons(uint16 b);
uint16 getButtons();
diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index c8f562d579..b19feb6046 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -125,16 +125,13 @@ LuaScript::~LuaScript() {
delete _globalLuaStream;
}
-bool LuaScript::init() {
+void LuaScript::init() {
// Load Global Lua Code
_globalLuaStream = g_hdb->_fileMan->findFirstData("GLOBAL.LUA", TYPE_BINARY);
_globalLuaLength = g_hdb->_fileMan->getLength("GLOBAL.LUA", TYPE_BINARY);
if (_globalLuaStream == NULL || _globalLuaLength == 0) {
error("LuaScript::initScript: 'global code' failed to load");
- return false;
}
-
- return true;
}
bool LuaScript::loadLua(const char *name) {
diff --git a/engines/hdb/lua-script.h b/engines/hdb/lua-script.h
index a239aa212a..362ad124c7 100644
--- a/engines/hdb/lua-script.h
+++ b/engines/hdb/lua-script.h
@@ -52,7 +52,7 @@ public:
void save(Common::OutSaveFile *out);
void loadSaveFile(Common::InSaveFile *in);
- bool init();
+ void init();
bool initScript(Common::SeekableReadStream *stream, const char *scriptName, int32 length);
void pushInt(int value);
diff --git a/engines/hdb/sound.cpp b/engines/hdb/sound.cpp
index 28cee431ae..bcfcaac518 100644
--- a/engines/hdb/sound.cpp
+++ b/engines/hdb/sound.cpp
@@ -1418,7 +1418,7 @@ void Sound::test() {
#endif
}
-bool Sound::init() {
+void Sound::init() {
_song1.playing = _song2.playing = false;
//
@@ -1448,8 +1448,6 @@ bool Sound::init() {
// voices are on by default
_voicesOn = 1;
memset(&_voicePlayed[0], 0, sizeof(_voicePlayed));
-
- return true;
}
void Sound::save(Common::OutSaveFile *out) {
diff --git a/engines/hdb/sound.h b/engines/hdb/sound.h
index bbc4174f63..b4661e42f1 100644
--- a/engines/hdb/sound.h
+++ b/engines/hdb/sound.h
@@ -1487,7 +1487,7 @@ public:
void test(); // FIXME. Remove
- bool init();
+ void init();
void save(Common::OutSaveFile *out);
void loadSaveFile(Common::InSaveFile *in);
void setMusicVolume(int value);
diff --git a/engines/hdb/window.cpp b/engines/hdb/window.cpp
index 853f4e617d..d10ccacb74 100644
--- a/engines/hdb/window.cpp
+++ b/engines/hdb/window.cpp
@@ -131,8 +131,7 @@ Window::~Window() {
delete _gemGfx;
}
-bool Window::init() {
-
+void Window::init() {
_gfxTL = g_hdb->_gfx->loadPic(MENU_BACK_TOPLEFT);
_gfxTM = g_hdb->_gfx->loadPic(MENU_BACK_TOP);
_gfxTR = g_hdb->_gfx->loadPic(MENU_BACK_TOPRIGHT);
@@ -207,8 +206,6 @@ bool Window::init() {
_gemGfx = NULL;
restartSystem();
-
- return true;
}
void Window::save(Common::OutSaveFile *out) {
diff --git a/engines/hdb/window.h b/engines/hdb/window.h
index b511ba33f9..d6b8384185 100644
--- a/engines/hdb/window.h
+++ b/engines/hdb/window.h
@@ -171,7 +171,7 @@ public:
Window();
~Window();
- bool init();
+ void init();
void save(Common::OutSaveFile *out);
void loadSaveFile(Common::InSaveFile *in);
void restartSystem();