diff options
author | Bastien Bouclet | 2011-01-09 15:31:08 +0000 |
---|---|---|
committer | Bastien Bouclet | 2011-01-09 15:31:08 +0000 |
commit | 9058a83ad9ec3eb0325ac4b13428a3828c884b3a (patch) | |
tree | 928d15fb79728db2f943c3d51e74453a8259228c | |
parent | db11b626c7314db14a4db89158b3b9d31fc16120 (diff) | |
download | scummvm-rg350-9058a83ad9ec3eb0325ac4b13428a3828c884b3a.tar.gz scummvm-rg350-9058a83ad9ec3eb0325ac4b13428a3828c884b3a.tar.bz2 scummvm-rg350-9058a83ad9ec3eb0325ac4b13428a3828c884b3a.zip |
MOHAWK: Myst zip mode improvements
- Save visited zip destinations in the game state
- Only allow zipping to visited zip destinations
- Save zip mode setting in the game state
svn-id: r55185
-rw-r--r-- | engines/mohawk/dialogs.cpp | 8 | ||||
-rw-r--r-- | engines/mohawk/myst.cpp | 6 | ||||
-rw-r--r-- | engines/mohawk/myst.h | 7 | ||||
-rw-r--r-- | engines/mohawk/myst_areas.cpp | 3 | ||||
-rw-r--r-- | engines/mohawk/myst_state.cpp | 91 | ||||
-rw-r--r-- | engines/mohawk/myst_state.h | 21 |
6 files changed, 114 insertions, 22 deletions
diff --git a/engines/mohawk/dialogs.cpp b/engines/mohawk/dialogs.cpp index a4ac2da66c..f1a5586127 100644 --- a/engines/mohawk/dialogs.cpp +++ b/engines/mohawk/dialogs.cpp @@ -91,17 +91,17 @@ MystOptionsDialog::~MystOptionsDialog() { void MystOptionsDialog::open() { Dialog::open(); - _zipModeCheckbox->setState(_vm->_zipMode); - _transitionsCheckbox->setState(_vm->_transitionsEnabled); + _zipModeCheckbox->setState(_vm->_gameState->_globals.zipMode); + _transitionsCheckbox->setState(_vm->_gameState->_globals.transitions); } void MystOptionsDialog::handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data) { switch (cmd) { case kZipCmd: - _vm->_zipMode = _zipModeCheckbox->getState(); + _vm->_gameState->_globals.zipMode = _zipModeCheckbox->getState(); break; case kTransCmd: - _vm->_transitionsEnabled = _transitionsCheckbox->getState(); + _vm->_gameState->_globals.transitions = _transitionsCheckbox->getState(); break; case GUI::kCloseCmd: close(); diff --git a/engines/mohawk/myst.cpp b/engines/mohawk/myst.cpp index 487180be22..1dbeca5a35 100644 --- a/engines/mohawk/myst.cpp +++ b/engines/mohawk/myst.cpp @@ -67,9 +67,6 @@ MohawkEngine_Myst::MohawkEngine_Myst(OSystem *syst, const MohawkGameDescription DebugMan.addDebugChannel(kDebugHelp, "Help", "Track Help File (HELP) Parsing"); DebugMan.addDebugChannel(kDebugCache, "Cache", "Track Resource Cache Accesses"); - _zipMode = false; - _transitionsEnabled = false; - // Engine tweaks // Disabling this makes engine behavior as per // original, including bugs, missing bits etc. :) @@ -621,6 +618,9 @@ void MohawkEngine_Myst::changeToCard(uint16 card, bool updateScreen) { error("Unknown sound action %d", soundAction); } + if (_view.flags & kMystZipDestination) + _gameState->addZipDest(_curStack, card); + // Run the entrance script (if present) runInitScript(); diff --git a/engines/mohawk/myst.h b/engines/mohawk/myst.h index 048f3fe5b7..893c1b3a5d 100644 --- a/engines/mohawk/myst.h +++ b/engines/mohawk/myst.h @@ -96,6 +96,11 @@ enum { // Other positive values are PlayNewSound of that id }; +// View flags +enum { + kMystZipDestination = (1 << 0) +}; + struct MystView { uint16 flags; @@ -166,8 +171,6 @@ public: MystVar *_varStore; - bool _zipMode; - bool _transitionsEnabled; bool _tweaksEnabled; bool _needsUpdate; diff --git a/engines/mohawk/myst_areas.cpp b/engines/mohawk/myst_areas.cpp index 7a65ecf701..311d553d04 100644 --- a/engines/mohawk/myst_areas.cpp +++ b/engines/mohawk/myst_areas.cpp @@ -80,7 +80,8 @@ bool MystResource::canBecomeActive() { } bool MystResource::unreachableZipDest() { - return (_flags & kMystZipModeEnableFlag) && !_vm->_zipMode; + return (_flags & kMystZipModeEnableFlag) + && !_vm->_gameState->isReachableZipDest(_vm->getCurStack() , _dest); } bool MystResource::isEnabled() { diff --git a/engines/mohawk/myst_state.cpp b/engines/mohawk/myst_state.cpp index da1ca727f1..d16fff63fe 100644 --- a/engines/mohawk/myst_state.cpp +++ b/engines/mohawk/myst_state.cpp @@ -40,6 +40,11 @@ MystGameState::MystGameState(MohawkEngine_Myst *vm, Common::SaveFileManager *sav memset(&_mechanical, 0, sizeof(_mechanical)); memset(&_selenitic, 0, sizeof(_selenitic)); memset(&_stoneship, 0, sizeof(_stoneship)); + memset(&_mystReachableZipDests, 0, sizeof(_mystReachableZipDests)); + memset(&_channelwoodReachableZipDests, 0, sizeof(_channelwoodReachableZipDests)); + memset(&_mechReachableZipDests, 0, sizeof(_mechReachableZipDests)); + memset(&_seleniticReachableZipDests, 0, sizeof(_seleniticReachableZipDests)); + memset(&_stoneshipReachableZipDests, 0, sizeof(_stoneshipReachableZipDests)); // Unknown _globals.u0 = 2; @@ -295,19 +300,19 @@ void MystGameState::syncGameState(Common::Serializer &s, bool isME) { // 41 uint16 values. for (byte i = 0; i < 41; i++) - s.syncAsUint16LE(mystReachableZipDests[i]); + s.syncAsUint16LE(_mystReachableZipDests[i]); for (byte i = 0; i < 41; i++) - s.syncAsUint16LE(channelwoodReachableZipDests[i]); + s.syncAsUint16LE(_channelwoodReachableZipDests[i]); for (byte i = 0; i < 41; i++) - s.syncAsUint16LE(mechReachableZipDests[i]); + s.syncAsUint16LE(_mechReachableZipDests[i]); for (byte i = 0; i < 41; i++) - s.syncAsUint16LE(seleniticReachableZipDests[i]); + s.syncAsUint16LE(_seleniticReachableZipDests[i]); for (byte i = 0; i < 41; i++) - s.syncAsUint16LE(stoneshipReachableZipDests[i]); + s.syncAsUint16LE(_stoneshipReachableZipDests[i]); if ((isME && s.bytesSynced() != 664) || (!isME && s.bytesSynced() != 601)) warning("Unexpected File Position 0x%03X At End of Save/Load", s.bytesSynced()); @@ -318,4 +323,80 @@ void MystGameState::deleteSave(const Common::String &saveName) { _saveFileMan->removeSavefile(saveName.c_str()); } +void MystGameState::addZipDest(uint16 stack, uint16 view) { + ZipDests *zipDests = 0; + + // Select stack + switch (stack) { + case kChannelwoodStack: + zipDests = &_channelwoodReachableZipDests; + break; + case kMechanicalStack: + zipDests = &_mechReachableZipDests; + break; + case kMystStack: + zipDests = &_mystReachableZipDests; + break; + case kSeleniticStack: + zipDests = &_seleniticReachableZipDests; + break; + case kStoneshipStack: + zipDests = &_stoneshipReachableZipDests; + break; + default: + error("Stack does not have zip destination storage"); + } + + // Check if not already in list + int16 firstEmpty = -1; + bool found = false; + for (uint i = 0; i < ARRAYSIZE(*zipDests); i++) { + if (firstEmpty == -1 && (*zipDests)[i] == 0) + firstEmpty = i; + + if ((*zipDests)[i] == view) + found = true; + } + + // Add view to array + if (!found && firstEmpty >= 0) + (*zipDests)[firstEmpty] = view; +} + +bool MystGameState::isReachableZipDest(uint16 stack, uint16 view) { + // Zip mode enabled + if (!_globals.zipMode) + return false; + + // Select stack + ZipDests *zipDests; + switch (stack) { + case kChannelwoodStack: + zipDests = &_channelwoodReachableZipDests; + break; + case kMechanicalStack: + zipDests = &_mechReachableZipDests; + break; + case kMystStack: + zipDests = &_mystReachableZipDests; + break; + case kSeleniticStack: + zipDests = &_seleniticReachableZipDests; + break; + case kStoneshipStack: + zipDests = &_stoneshipReachableZipDests; + break; + default: + error("Stack does not have zip destination storage"); + } + + // Check if in list + for (uint i = 0; i < ARRAYSIZE(*zipDests); i++) { + if ((*zipDests)[i] == view) + return true; + } + + return false; +} + } // End of namespace Mohawk diff --git a/engines/mohawk/myst_state.h b/engines/mohawk/myst_state.h index 400f379502..f21a1ddcda 100644 --- a/engines/mohawk/myst_state.h +++ b/engines/mohawk/myst_state.h @@ -48,6 +48,9 @@ public: bool save(const Common::String &); void deleteSave(const Common::String &); + void addZipDest(uint16 stack, uint16 view); + bool isReachableZipDest(uint16 stack, uint16 view); + /* 8 Game Global Variables : 0 = Unknown - Fixed at 2 1 = Current Age / Stack @@ -269,19 +272,23 @@ public: uint16 generatorPowerLevel[5]; } _stoneship; +private: + void syncGameState(Common::Serializer &s, bool isME); + // The values in these regions are lists of VIEW resources // which correspond to visited zip destinations - uint16 mystReachableZipDests[41]; - uint16 channelwoodReachableZipDests[41]; + typedef uint16 ZipDests[41]; - uint16 mechReachableZipDests[41]; + ZipDests _mystReachableZipDests; - uint16 seleniticReachableZipDests[41]; + ZipDests _channelwoodReachableZipDests; - uint16 stoneshipReachableZipDests[41]; -private: - void syncGameState(Common::Serializer &s, bool isME); + ZipDests _mechReachableZipDests; + + ZipDests _seleniticReachableZipDests; + + ZipDests _stoneshipReachableZipDests; MohawkEngine_Myst *_vm; Common::SaveFileManager *_saveFileMan; |