MM: MM1: Change disableAttacks view casting to a game message

This commit is contained in:
Paul Gilbert 2023-03-29 19:54:13 -07:00
parent 3a98f3acc4
commit 69a4edff7f
6 changed files with 11 additions and 15 deletions

View File

@ -321,12 +321,6 @@ public:
*/
virtual void displaySpellResult(const InfoMessage &msg) = 0;
/**
* Disable the flags for allowing attacks for
* the current character
*/
virtual void disableAttacks() = 0;
void iterateMonsters1();
void iterateMonsters2();
void resetDestMonster();

View File

@ -65,9 +65,7 @@ Common::String UseItem::combatUseItem(Inventory &inv, Inventory::Entry &invEntry
msg = STRING["dialogs.character.use_combat.not_equipped"];
}
Game::Combat *combat = dynamic_cast<Game::Combat *>(g_events->priorView());
assert(combat);
combat->disableAttacks();
g_events->send("Combat", GameMessage("DISABLE_ATTACKS"));
return msg;
}
@ -108,10 +106,6 @@ Common::String UseItem::nonCombatUseItem(Inventory &inv, Inventory::Entry &invEn
msg = STRING["dialogs.character.use_noncombat.not_equipped"];
}
Game::Combat *combat = dynamic_cast<Game::Combat *>(g_events->priorView());
assert(combat);
combat->disableAttacks();
return msg;
}

View File

@ -94,6 +94,10 @@ bool Combat::msgGame(const GameMessage &msg) {
setMode(SPELL_RESULT);
return true;
} else if (msg._name == "DISABLE_ATTACKS") {
disableAttacks();
return true;
}
return false;

View File

@ -230,7 +230,7 @@ public:
* Disable the flags for allowing attacks for
* the current character
*/
void disableAttacks() override;
void disableAttacks();
/**
* Called when the view is focused

View File

@ -105,6 +105,10 @@ bool Combat::msgGame(const GameMessage &msg) {
if (g_globals->_combatParty[charNum] != g_globals->_currCharacter)
exchangeWith(charNum);
return true;
} else if (msg._name == "DISABLE_ATTACKS") {
disableAttacks();
return true;
}
return false;

View File

@ -243,7 +243,7 @@ public:
* Disable the flags for allowing attacks for
* the current character
*/
void disableAttacks() override;
void disableAttacks();
/**
* Called when the view is focused