MM: MM1: Properly handle getting treasure after trap msg display

This commit is contained in:
Paul Gilbert 2023-03-12 21:58:31 -07:00
parent 57a8d2d8bd
commit 2cd03b2e71
4 changed files with 10 additions and 10 deletions

View File

@ -20,6 +20,7 @@
*/
#include "mm/mm1/views/search.h"
#include "mm/mm1/views/trap.h"
#include "mm/mm1/globals.h"
#include "mm/mm1/sound.h"
@ -54,7 +55,7 @@ bool Search::msgFocus(const FocusMessage &msg) {
_bounds = getLineBounds(20, 24);
_lineNum = 0;
if (_mode == FOCUS_GET_TREASURE) {
if (dynamic_cast<Trap *>(msg._priorView) != nullptr) {
// Returning from trap display
if (g_globals->_party.checkPartyDead())
return true;
@ -266,8 +267,6 @@ void Search::openContainer2() {
g_globals->_treasure._container;
if (getRandomNumber(thresold + 5) < thresold) {
// Triggered a trap
_mode = FOCUS_GET_TREASURE;
g_events->send("Trap", GameMessage("TRAP"));
return;
}

View File

@ -31,9 +31,8 @@ namespace Views {
class Search : public TextView {
private:
enum Mode {
INITIAL, OPTIONS, RESPONSE, WHO_WILL_TRY,
FOCUS_GET_TREASURE, GET_TREASURE, GET_ITEMS,
GET_ITEMS_DONE
INITIAL, OPTIONS, RESPONSE, WHO_WILL_TRY, GET_TREASURE,
GET_ITEMS, GET_ITEMS_DONE
};
enum OptionMode { OMODE_OPEN, OMODE_REMOVE_TRAP, OMODE_DETECT };
Mode _mode = INITIAL;

View File

@ -21,6 +21,7 @@
#include "mm/mm1/views_enh/search.h"
#include "mm/mm1/views_enh/select_number.h"
#include "mm/mm1/views_enh/trap.h"
#include "mm/mm1/views_enh/who_will_try.h"
#include "mm/mm1/globals.h"
#include "mm/mm1/sound.h"
@ -58,7 +59,7 @@ bool Search::msgFocus(const FocusMessage &msg) {
_lineNum = 0;
_bounds = Common::Rect(0, 144, 234, 200);
if (_mode == FOCUS_GET_TREASURE) {
if (dynamic_cast<Trap *>(msg._priorView) != nullptr) {
// Returning from trap display
if (g_globals->_party.checkPartyDead())
return true;
@ -232,7 +233,6 @@ void Search::openContainer2() {
if (getRandomNumber(thresold + 5) < thresold) {
// Triggered a trap
setMode(FOCUS_GET_TREASURE);
g_events->send("Trap", GameMessage("TRAP"));
return;
}
@ -258,6 +258,8 @@ void Search::findRemoveTrap2() {
return;
}
}
getTreasure();
}
void Search::detectMagicTrap() {

View File

@ -31,8 +31,8 @@ namespace ViewsEnh {
class Search : public SelectNumber {
private:
enum Mode {
INITIAL, OPTIONS, RESPONSE, FOCUS_GET_TREASURE,
GET_TREASURE, GET_ITEMS, GET_ITEMS_DONE
INITIAL, OPTIONS, RESPONSE, GET_TREASURE, GET_ITEMS,
GET_ITEMS_DONE
};
enum OptionMode {
OMODE_OPEN, OMODE_REMOVE_TRAP, OMODE_DETECT