aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Gilbert2018-04-05 20:06:14 -0400
committerPaul Gilbert2018-04-05 20:06:14 -0400
commit8648a48080895308cf79c7fe99ecfebcb08c7528 (patch)
tree765d2f851681fc4da9e782c4e7c4426ec89ef1ff
parenta54850cae0e84089a07188f3ef264a0ab3c412c8 (diff)
downloadscummvm-rg350-8648a48080895308cf79c7fe99ecfebcb08c7528.tar.gz
scummvm-rg350-8648a48080895308cf79c7fe99ecfebcb08c7528.tar.bz2
scummvm-rg350-8648a48080895308cf79c7fe99ecfebcb08c7528.zip
XEEN: Move check code for nearby monsters to it's own method
-rw-r--r--engines/xeen/combat.cpp9
-rw-r--r--engines/xeen/combat.h5
-rw-r--r--engines/xeen/party.cpp5
3 files changed, 15 insertions, 4 deletions
diff --git a/engines/xeen/combat.cpp b/engines/xeen/combat.cpp
index 2bd0187fed..e8ae670288 100644
--- a/engines/xeen/combat.cpp
+++ b/engines/xeen/combat.cpp
@@ -2087,4 +2087,13 @@ void Combat::shootRangedWeapon() {
rangedAttack(POW_ARROW);
}
+bool Combat::areMonstersPresent() const {
+ for (int idx = 0; idx < 26; ++idx) {
+ if (_attackMonsters[idx] != -1)
+ return true;
+ }
+
+ return false;
+}
+
} // End of namespace Xeen
diff --git a/engines/xeen/combat.h b/engines/xeen/combat.h
index 5d27dc5c4e..deefe33874 100644
--- a/engines/xeen/combat.h
+++ b/engines/xeen/combat.h
@@ -305,6 +305,11 @@ public:
* Fires off a ranged attack at all oncoming monsters
*/
void shootRangedWeapon();
+
+ /**
+ * Returns true if there are any monsters in the vacinity
+ */
+ bool areMonstersPresent() const;
};
} // End of namespace Xeen
diff --git a/engines/xeen/party.cpp b/engines/xeen/party.cpp
index 8852b51ca2..d53c1f2450 100644
--- a/engines/xeen/party.cpp
+++ b/engines/xeen/party.cpp
@@ -689,10 +689,7 @@ void Party::giveTreasure() {
if (!_treasure._hasItems && !_treasure._gold && !_treasure._gems)
return;
- bool monstersPresent = false;
- for (int idx = 0; idx < 26 && !monstersPresent; ++idx)
- monstersPresent = combat._attackMonsters[idx] != -1;
-
+ bool monstersPresent = combat.areMonstersPresent();
if (_vm->_mode != MODE_RECORD_EVENTS && monstersPresent)
return;