From 69a4edff7f9bec6557a37d44aa68ab6dce7516b8 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 29 Mar 2023 19:54:13 -0700 Subject: [PATCH] MM: MM1: Change disableAttacks view casting to a game message --- engines/mm/mm1/game/combat.h | 6 ------ engines/mm/mm1/game/use_item.cpp | 8 +------- engines/mm/mm1/views/combat.cpp | 4 ++++ engines/mm/mm1/views/combat.h | 2 +- engines/mm/mm1/views_enh/combat.cpp | 4 ++++ engines/mm/mm1/views_enh/combat.h | 2 +- 6 files changed, 11 insertions(+), 15 deletions(-) diff --git a/engines/mm/mm1/game/combat.h b/engines/mm/mm1/game/combat.h index 720d86eb023..5d7ee271b42 100644 --- a/engines/mm/mm1/game/combat.h +++ b/engines/mm/mm1/game/combat.h @@ -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(); diff --git a/engines/mm/mm1/game/use_item.cpp b/engines/mm/mm1/game/use_item.cpp index caf7508dfb5..8ea271f85df 100644 --- a/engines/mm/mm1/game/use_item.cpp +++ b/engines/mm/mm1/game/use_item.cpp @@ -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(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(g_events->priorView()); - assert(combat); - combat->disableAttacks(); - return msg; } diff --git a/engines/mm/mm1/views/combat.cpp b/engines/mm/mm1/views/combat.cpp index 7c63ed8cbc8..94a88655ab1 100644 --- a/engines/mm/mm1/views/combat.cpp +++ b/engines/mm/mm1/views/combat.cpp @@ -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; diff --git a/engines/mm/mm1/views/combat.h b/engines/mm/mm1/views/combat.h index c8ef562358f..5038d5082bb 100644 --- a/engines/mm/mm1/views/combat.h +++ b/engines/mm/mm1/views/combat.h @@ -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 diff --git a/engines/mm/mm1/views_enh/combat.cpp b/engines/mm/mm1/views_enh/combat.cpp index ebb76e69330..923fa53a67d 100644 --- a/engines/mm/mm1/views_enh/combat.cpp +++ b/engines/mm/mm1/views_enh/combat.cpp @@ -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; diff --git a/engines/mm/mm1/views_enh/combat.h b/engines/mm/mm1/views_enh/combat.h index ce83815893f..6d673c81a1a 100644 --- a/engines/mm/mm1/views_enh/combat.h +++ b/engines/mm/mm1/views_enh/combat.h @@ -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