aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorPaul Gilbert2018-01-10 22:13:43 -0500
committerPaul Gilbert2018-01-10 22:13:43 -0500
commit42aa1cc16323837aafb0f9e367ee92afbe717edc (patch)
tree9d1f996dcaf60167aa1d95f1f8cf178ec4223115 /engines
parent9aa9cb49977c14ac9527e82f0449071cfc7cf799 (diff)
downloadscummvm-rg350-42aa1cc16323837aafb0f9e367ee92afbe717edc.tar.gz
scummvm-rg350-42aa1cc16323837aafb0f9e367ee92afbe717edc.tar.bz2
scummvm-rg350-42aa1cc16323837aafb0f9e367ee92afbe717edc.zip
XEEN: Fix crash after monster ranged attacks finish
Diffstat (limited to 'engines')
-rw-r--r--engines/xeen/combat.cpp7
-rw-r--r--engines/xeen/combat.h10
-rw-r--r--engines/xeen/interface.cpp5
3 files changed, 17 insertions, 5 deletions
diff --git a/engines/xeen/combat.cpp b/engines/xeen/combat.cpp
index 43e6d20c19..cc42c9d06c 100644
--- a/engines/xeen/combat.cpp
+++ b/engines/xeen/combat.cpp
@@ -131,6 +131,10 @@ void Combat::clear() {
Common::fill(&_attackMonsters[0], &_attackMonsters[ATTACK_MONSTERS_COUNT], -1);
}
+void Combat::clearBlocked() {
+ Common::fill(_charsBlocked, _charsBlocked + PARTY_AND_MONSTERS, false);
+}
+
void Combat::giveCharDamage(int damage, DamageType attackType, int charIndex) {
Party &party = *_vm->_party;
Scripts &scripts = *_vm->_scripts;
@@ -773,7 +777,7 @@ void Combat::doMonsterTurn(int monsterId) {
Party &party = *_vm->_party;
Sound &sound = *_vm->_sound;
- if (_monstersAttacking) {
+ if (!_monstersAttacking) {
int monsterIndex;
switch (_whosTurn - _combatParty.size()) {
case 0:
@@ -790,6 +794,7 @@ void Combat::doMonsterTurn(int monsterId) {
intf._indoorList[153]._scale = 0;
}
+ assert(monsterIndex != -1);
MazeMonster &monster = map._mobData._monsters[monsterIndex];
MonsterStruct &monsterData = *monster._monsterData;
if (monster._damageType)
diff --git a/engines/xeen/combat.h b/engines/xeen/combat.h
index f3eaa39bd0..11c1f1d585 100644
--- a/engines/xeen/combat.h
+++ b/engines/xeen/combat.h
@@ -104,7 +104,7 @@ private:
void giveExperience(int experience);
public:
Common::Array<Character *> _combatParty;
- Common::Array<bool> _charsBlocked;
+ bool _charsBlocked[PARTY_AND_MONSTERS];
Common::Array<int> _charsGone;
SpriteResource _powSprites;
int _attackMonsters[ATTACK_MONSTERS_COUNT];
@@ -145,8 +145,16 @@ public:
public:
Combat(XeenEngine *vm);
+ /**
+ * Clear the list of attacking monsters
+ */
void clear();
+ /**
+ * Clear the list of blocked characters
+ */
+ void clearBlocked();
+
void giveCharDamage(int damage, DamageType attackType, int charIndex);
/**
diff --git a/engines/xeen/interface.cpp b/engines/xeen/interface.cpp
index 0cc509a66a..b9f1e2bb2c 100644
--- a/engines/xeen/interface.cpp
+++ b/engines/xeen/interface.cpp
@@ -1497,7 +1497,7 @@ void Interface::doCombat() {
combat._combatParty.clear();
combat._charsGone.clear();
- combat._charsBlocked.clear();
+ combat.clearBlocked();
combat._charsArray1[0] = 0;
combat._charsArray1[1] = 0;
combat._charsArray1[2] = 0;
@@ -1510,7 +1510,6 @@ void Interface::doCombat() {
// Initialize arrays for character/monster states
combat._charsGone.resize(combat._speedTable.size());
- combat._charsBlocked.resize(combat._speedTable.size());
Common::fill(&combat._charsGone[0], &combat._charsGone[0] + combat._speedTable.size(), 0);
Common::fill(&combat._charsBlocked[0], &combat._charsBlocked[0] + combat._speedTable.size(), false);
@@ -1691,7 +1690,7 @@ void Interface::doCombat() {
// Handling for if the combat turn is complete
if (combat.allHaveGone()) {
Common::fill(&combat._charsGone[0], &combat._charsGone[0] + combat._charsGone.size(), false);
- Common::fill(&combat._charsBlocked[0], &combat._charsBlocked[0] + combat._charsBlocked.size(), false);
+ combat.clearBlocked();
combat.setSpeedTable();
combat._whosTurn = -1;
combat._whosSpeed = -1;