aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugene Sandulenko2017-08-24 09:06:39 +0200
committerEugene Sandulenko2017-08-24 09:25:25 +0200
commit265fc48d1590cdd503187c79dc254d65623c8d7b (patch)
treea9f1ace3d8c9ec937d7930d59c35c4258a5acc4d
parent7cf83cab6a9879f9543ffabff59ca639231896bd (diff)
downloadscummvm-rg350-265fc48d1590cdd503187c79dc254d65623c8d7b.tar.gz
scummvm-rg350-265fc48d1590cdd503187c79dc254d65623c8d7b.tar.bz2
scummvm-rg350-265fc48d1590cdd503187c79dc254d65623c8d7b.zip
WAGE: Do something when player is not defined instead of crashes
-rw-r--r--engines/wage/gui.cpp4
-rw-r--r--engines/wage/world.cpp18
2 files changed, 20 insertions, 2 deletions
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index 7d1014b913..9c76418a59 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -209,6 +209,10 @@ void Gui::regenWeaponsMenu() {
_menu->clearSubMenu(_weaponsMenuId);
Chr *player = _engine->_world->_player;
+ if (!player) {
+ warning("regenWeaponsMenu: player is not defined");
+ return;
+ }
ObjArray *weapons = player->getWeapons(true);
bool empty = true;
diff --git a/engines/wage/world.cpp b/engines/wage/world.cpp
index df9fcaf022..c0c802ff8d 100644
--- a/engines/wage/world.cpp
+++ b/engines/wage/world.cpp
@@ -252,11 +252,25 @@ bool World::loadWorld(Common::MacResManager *resMan) {
Chr *chr = new Chr(resMan->getResName(MKTAG('A','C','H','R'), *iter), res);
chr->_resourceId = *iter;
addChr(chr);
- // TODO: What if there's more than one player character?
- if (chr->_playerCharacter)
+
+ if (chr->_playerCharacter) {
+ if (_player)
+ warning("loadWorld: Player is redefined");
+
_player = chr;
+ }
+ }
+
+ if (!_player) {
+ warning("loadWorld: Player is not defined");
+
+ if (_chrs.empty()) {
+ error("loadWorld: and I have no characters");
+ }
+ _player = _chrs[0];
}
+
// Load Sounds
resArray = resMan->getResIDArray(MKTAG('A','S','N','D'));
debug(3, "Loading %d sounds", resArray.size());