diff options
author | Bastien Bouclet | 2019-02-02 13:30:44 +0100 |
---|---|---|
committer | Bastien Bouclet | 2019-02-02 13:30:44 +0100 |
commit | 04edc22635f18178263b52bfcde91127f3d41a4a (patch) | |
tree | 173724c22de5cbd27b34497bfa2bf09db1196729 /engines/mohawk | |
parent | f72f71a6cc1a6bcd1b92199457165e35a6362cee (diff) | |
download | scummvm-rg350-04edc22635f18178263b52bfcde91127f3d41a4a.tar.gz scummvm-rg350-04edc22635f18178263b52bfcde91127f3d41a4a.tar.bz2 scummvm-rg350-04edc22635f18178263b52bfcde91127f3d41a4a.zip |
MOHAWK: RIVEN: Add a console to quickly test all the cards
Goes through all the cards clicking on hotspots at random.
Diffstat (limited to 'engines/mohawk')
-rw-r--r-- | engines/mohawk/console.cpp | 84 | ||||
-rw-r--r-- | engines/mohawk/console.h | 1 | ||||
-rw-r--r-- | engines/mohawk/riven.cpp | 11 | ||||
-rw-r--r-- | engines/mohawk/riven.h | 1 | ||||
-rw-r--r-- | engines/mohawk/riven_stack.h | 1 | ||||
-rw-r--r-- | engines/mohawk/riven_stacks/gspit.cpp | 10 |
6 files changed, 93 insertions, 15 deletions
diff --git a/engines/mohawk/console.cpp b/engines/mohawk/console.cpp index bd0e5c7551..1cb6c8daee 100644 --- a/engines/mohawk/console.cpp +++ b/engines/mohawk/console.cpp @@ -374,23 +374,24 @@ bool MystConsole::Cmd_QuickTest(int argc, const char **argv) { #ifdef ENABLE_RIVEN RivenConsole::RivenConsole(MohawkEngine_Riven *vm) : GUI::Debugger(), _vm(vm) { - registerCmd("changeCard", WRAP_METHOD(RivenConsole, Cmd_ChangeCard)); - registerCmd("curCard", WRAP_METHOD(RivenConsole, Cmd_CurCard)); - registerCmd("dumpCard", WRAP_METHOD(RivenConsole, Cmd_DumpCard)); - registerCmd("var", WRAP_METHOD(RivenConsole, Cmd_Var)); - registerCmd("playSound", WRAP_METHOD(RivenConsole, Cmd_PlaySound)); + registerCmd("changeCard", WRAP_METHOD(RivenConsole, Cmd_ChangeCard)); + registerCmd("curCard", WRAP_METHOD(RivenConsole, Cmd_CurCard)); + registerCmd("dumpCard", WRAP_METHOD(RivenConsole, Cmd_DumpCard)); + registerCmd("var", WRAP_METHOD(RivenConsole, Cmd_Var)); + registerCmd("playSound", WRAP_METHOD(RivenConsole, Cmd_PlaySound)); registerCmd("playSLST", WRAP_METHOD(RivenConsole, Cmd_PlaySLST)); - registerCmd("stopSound", WRAP_METHOD(RivenConsole, Cmd_StopSound)); - registerCmd("curStack", WRAP_METHOD(RivenConsole, Cmd_CurStack)); - registerCmd("dumpStack", WRAP_METHOD(RivenConsole, Cmd_DumpStack)); - registerCmd("changeStack", WRAP_METHOD(RivenConsole, Cmd_ChangeStack)); - registerCmd("hotspots", WRAP_METHOD(RivenConsole, Cmd_Hotspots)); - registerCmd("zipMode", WRAP_METHOD(RivenConsole, Cmd_ZipMode)); + registerCmd("stopSound", WRAP_METHOD(RivenConsole, Cmd_StopSound)); + registerCmd("curStack", WRAP_METHOD(RivenConsole, Cmd_CurStack)); + registerCmd("dumpStack", WRAP_METHOD(RivenConsole, Cmd_DumpStack)); + registerCmd("changeStack", WRAP_METHOD(RivenConsole, Cmd_ChangeStack)); + registerCmd("hotspots", WRAP_METHOD(RivenConsole, Cmd_Hotspots)); + registerCmd("zipMode", WRAP_METHOD(RivenConsole, Cmd_ZipMode)); registerCmd("dumpScript", WRAP_METHOD(RivenConsole, Cmd_DumpScript)); registerCmd("listZipCards", WRAP_METHOD(RivenConsole, Cmd_ListZipCards)); - registerCmd("getRMAP", WRAP_METHOD(RivenConsole, Cmd_GetRMAP)); + registerCmd("getRMAP", WRAP_METHOD(RivenConsole, Cmd_GetRMAP)); registerCmd("combos", WRAP_METHOD(RivenConsole, Cmd_Combos)); registerCmd("sliderState", WRAP_METHOD(RivenConsole, Cmd_SliderState)); + registerCmd("quickTest", WRAP_METHOD(RivenConsole, Cmd_QuickTest)); registerVar("show_hotspots", &_vm->_showHotspots); } @@ -687,6 +688,65 @@ bool RivenConsole::Cmd_SliderState(int argc, const char **argv) { return true; } +bool RivenConsole::Cmd_QuickTest(int argc, const char **argv) { + _vm->pauseEngine(false); + + // Go through all the stacks, all the cards and click random stuff + for (uint16 stackId = kStackFirst; stackId <= kStackLast; stackId++) { + + debug("Loading stack %s", RivenStacks::getName(stackId)); + _vm->changeToStack(stackId); + + Common::Array<uint16> cardIds = _vm->getResourceIDList(ID_CARD); + for (uint16 i = 0; i < cardIds.size(); i++) { + if (_vm->shouldQuit()) break; + + uint16 cardId = cardIds[i]; + if (stackId == kStackTspit && cardId == 366) continue; // Cut card with invalid links + if (stackId == kStackTspit && cardId == 412) continue; // Cut card with invalid links + if (stackId == kStackTspit && cardId == 486) continue; // Cut card with invalid links + if (stackId == kStackBspit && cardId == 465) continue; // Cut card with invalid links + if (stackId == kStackJspit && cardId == 737) continue; // Cut card with invalid links + + debug("Loading card %d", cardId); + RivenScriptPtr script = _vm->_scriptMan->createScriptFromData(1, + kRivenCommandChangeCard, 1, cardId); + _vm->_scriptMan->runScript(script, true); + + _vm->_gfx->setTransitionMode(kRivenTransitionModeDisabled); + + while (_vm->_scriptMan->hasQueuedScripts()) { + _vm->doFrame(); + } + + // Click on a random hotspot + Common::Array<RivenHotspot *> hotspots = _vm->getCard()->getHotspots(); + if (!hotspots.empty() && _vm->getStack()->getId() != kStackAspit) { + uint hotspotIndex = _vm->_rnd->getRandomNumberRng(0, hotspots.size() - 1); + RivenHotspot *hotspot = hotspots[hotspotIndex]; + if (hotspot->isEnabled()) { + Common::Rect hotspotRect = hotspot->getRect(); + Common::Point hotspotPoint((hotspotRect.left + hotspotRect.right) / 2, (hotspotRect.top + hotspotRect.bottom) / 2); + _vm->getStack()->onMouseDown(hotspotPoint); + _vm->getStack()->onMouseUp(hotspotPoint); + } + + while (_vm->_scriptMan->hasQueuedScripts()) { + _vm->doFrame(); + } + } + + if (_vm->getStack()->getId() != stackId) { + // Clicking may have linked us to another age + _vm->changeToStack(stackId); + } + } + } + + _vm->pauseEngine(true); + return true; +} + #endif // ENABLE_RIVEN LivingBooksConsole::LivingBooksConsole(MohawkEngine_LivingBooks *vm) : GUI::Debugger(), _vm(vm) { diff --git a/engines/mohawk/console.h b/engines/mohawk/console.h index 7d94bf576f..88db580ca8 100644 --- a/engines/mohawk/console.h +++ b/engines/mohawk/console.h @@ -89,6 +89,7 @@ private: bool Cmd_GetRMAP(int argc, const char **argv); bool Cmd_Combos(int argc, const char **argv); bool Cmd_SliderState(int argc, const char **argv); + bool Cmd_QuickTest(int argc, const char **argv); }; #endif diff --git a/engines/mohawk/riven.cpp b/engines/mohawk/riven.cpp index b2997690c4..2545c686b4 100644 --- a/engines/mohawk/riven.cpp +++ b/engines/mohawk/riven.cpp @@ -636,6 +636,17 @@ Common::SeekableReadStream *MohawkEngine_Riven::getExtrasResource(uint32 tag, ui return _extrasFile->getResource(tag, id); } +Common::Array<uint16> MohawkEngine_Riven::getResourceIDList(uint32 type) const { + Common::Array<uint16> ids; + + for (uint i = 0; i < _mhk.size(); i++) { + ids.push_back(_mhk[i]->getResourceIDList(type)); + } + + return ids; +} + + void MohawkEngine_Riven::delay(uint32 ms) { uint32 startTime = _system->getMillis(); diff --git a/engines/mohawk/riven.h b/engines/mohawk/riven.h index b4084caec8..7a0d8b51c3 100644 --- a/engines/mohawk/riven.h +++ b/engines/mohawk/riven.h @@ -153,6 +153,7 @@ public: uint32 &getStackVar(uint32 index); // Miscellaneous + Common::Array<uint16> getResourceIDList(uint32 type) const; Common::SeekableReadStream *getExtrasResource(uint32 tag, uint16 id); bool _activatedPLST; bool _activatedSLST; diff --git a/engines/mohawk/riven_stack.h b/engines/mohawk/riven_stack.h index 671f4f9116..aba6cc9e73 100644 --- a/engines/mohawk/riven_stack.h +++ b/engines/mohawk/riven_stack.h @@ -30,7 +30,6 @@ #include "common/str-array.h" #include "mohawk/riven_graphics.h" -#include "mohawk/riven_stack.h" namespace Mohawk { diff --git a/engines/mohawk/riven_stacks/gspit.cpp b/engines/mohawk/riven_stacks/gspit.cpp index 05f46c60dc..d2440ecd48 100644 --- a/engines/mohawk/riven_stacks/gspit.cpp +++ b/engines/mohawk/riven_stacks/gspit.cpp @@ -157,7 +157,13 @@ void GSpit::xgpincontrols(const ArgumentArray &args) { } // Now check to see if this section of the island exists - uint32 islandIndex = _vm->_vars["glkbtns"] - 1; + uint32 islandIndex = _vm->_vars["glkbtns"]; + if (islandIndex == 0) { + // No island selected. Probably we jumped to the card. + warning("xgpincontrols called without an island selected."); + return; + } + uint16 imagePos = mousePos.x + mousePos.y; static const uint16 islandImages[5][11] = { @@ -172,7 +178,7 @@ void GSpit::xgpincontrols(const ArgumentArray &args) { uint32 imageCount = _vm->_vars["gimagemax"]; uint32 image = 0; for (; image < imageCount; image++) - if (islandImages[islandIndex][image] == imagePos) + if (islandImages[islandIndex - 1][image] == imagePos) break; // If we past it, we don't have a valid map coordinate |