Permalink
Browse files

XEEN: Fix crash after monster ranged attacks finish

  • Loading branch information...
dreammaster committed Jan 11, 2018
1 parent 9aa9cb4 commit 42aa1cc16323837aafb0f9e367ee92afbe717edc
Showing with 17 additions and 5 deletions.
  1. +6 −1 engines/xeen/combat.cpp
  2. +9 −1 engines/xeen/combat.h
  3. +2 −3 engines/xeen/interface.cpp
View
@@ -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)
View
@@ -104,7 +104,7 @@ class Combat {
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 @@ class Combat {
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);
/**
@@ -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;

0 comments on commit 42aa1cc

Please sign in to comment.