[Scummvm-cvs-logs] SF.net SVN: scummvm:[55185] scummvm/trunk/engines/mohawk
bgk at users.sourceforge.net
bgk at users.sourceforge.net
Sun Jan 9 16:31:08 CET 2011
Revision: 55185
http://scummvm.svn.sourceforge.net/scummvm/?rev=55185&view=rev
Author: bgk
Date: 2011-01-09 15:31:08 +0000 (Sun, 09 Jan 2011)
Log Message:
-----------
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
Modified Paths:
--------------
scummvm/trunk/engines/mohawk/dialogs.cpp
scummvm/trunk/engines/mohawk/myst.cpp
scummvm/trunk/engines/mohawk/myst.h
scummvm/trunk/engines/mohawk/myst_areas.cpp
scummvm/trunk/engines/mohawk/myst_state.cpp
scummvm/trunk/engines/mohawk/myst_state.h
Modified: scummvm/trunk/engines/mohawk/dialogs.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/dialogs.cpp 2011-01-09 13:28:34 UTC (rev 55184)
+++ scummvm/trunk/engines/mohawk/dialogs.cpp 2011-01-09 15:31:08 UTC (rev 55185)
@@ -91,17 +91,17 @@
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();
Modified: scummvm/trunk/engines/mohawk/myst.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/myst.cpp 2011-01-09 13:28:34 UTC (rev 55184)
+++ scummvm/trunk/engines/mohawk/myst.cpp 2011-01-09 15:31:08 UTC (rev 55185)
@@ -67,9 +67,6 @@
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 @@
error("Unknown sound action %d", soundAction);
}
+ if (_view.flags & kMystZipDestination)
+ _gameState->addZipDest(_curStack, card);
+
// Run the entrance script (if present)
runInitScript();
Modified: scummvm/trunk/engines/mohawk/myst.h
===================================================================
--- scummvm/trunk/engines/mohawk/myst.h 2011-01-09 13:28:34 UTC (rev 55184)
+++ scummvm/trunk/engines/mohawk/myst.h 2011-01-09 15:31:08 UTC (rev 55185)
@@ -96,6 +96,11 @@
// Other positive values are PlayNewSound of that id
};
+// View flags
+enum {
+ kMystZipDestination = (1 << 0)
+};
+
struct MystView {
uint16 flags;
@@ -166,8 +171,6 @@
MystVar *_varStore;
- bool _zipMode;
- bool _transitionsEnabled;
bool _tweaksEnabled;
bool _needsUpdate;
Modified: scummvm/trunk/engines/mohawk/myst_areas.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/myst_areas.cpp 2011-01-09 13:28:34 UTC (rev 55184)
+++ scummvm/trunk/engines/mohawk/myst_areas.cpp 2011-01-09 15:31:08 UTC (rev 55185)
@@ -80,7 +80,8 @@
}
bool MystResource::unreachableZipDest() {
- return (_flags & kMystZipModeEnableFlag) && !_vm->_zipMode;
+ return (_flags & kMystZipModeEnableFlag)
+ && !_vm->_gameState->isReachableZipDest(_vm->getCurStack() , _dest);
}
bool MystResource::isEnabled() {
Modified: scummvm/trunk/engines/mohawk/myst_state.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/myst_state.cpp 2011-01-09 13:28:34 UTC (rev 55184)
+++ scummvm/trunk/engines/mohawk/myst_state.cpp 2011-01-09 15:31:08 UTC (rev 55185)
@@ -40,6 +40,11 @@
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 @@
// 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 @@
_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
Modified: scummvm/trunk/engines/mohawk/myst_state.h
===================================================================
--- scummvm/trunk/engines/mohawk/myst_state.h 2011-01-09 13:28:34 UTC (rev 55184)
+++ scummvm/trunk/engines/mohawk/myst_state.h 2011-01-09 15:31:08 UTC (rev 55185)
@@ -48,6 +48,9 @@
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,20 +272,24 @@
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;
};
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list