[Scummvm-cvs-logs] scummvm master -> e50f93f2987f41b6c9d193dcf07383ba415cb96d
bgK
bastien.bouclet at gmail.com
Sun Feb 7 15:31:17 CET 2016
This automated email contains information about 25 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
47bc90f5a3 MOHAWK: Remove some dead code
25330c714e MOHAWK: Add missing virtual attributes to MystResourceType11
ce25cdf8dc MOHAWK: Add override qualifiers to the Myst code
0c8d8bbd40 MOHAWK: Use nullptr where applicable in the Myst code
085f3700f7 MOHAWK: Make MystResourceType8::_subImages private
cddb5cd53a MOHAWK: Rename Myst's Area classes
ae93f24267 MOHAWK: Turn MystAreaDrag::ValueList into a Common::Array
afdcbbae98 MOHAWK: Remove MystAreaImageSwitch::_numSubImages
91097d735e MOHAWK: Factor the MystAreaActionSwitch switch code
e9bab23c79 MOHAWK: Remove MystAreaActionSwitch::_numSubResources
989fe4d0cd MOHAWK: Turn MystView::conditionalImages into a Common::Array
ef14781456 MOHAWK: Turn MystCondition::values into a Common::Array
32f1ee73ad MOHAWK: Turn MystView::soundList into a Common::Array
a3064b9027 MOHAWK: Turn MystView::scriptResources into a Common::Array
316dc9c829 MOHAWK: Turn ScriptResource::resourceList into a Common::Array
6e3719199e MOHAWK: Remove some dead code
bff0dd1915 MOHAWK: Turn MystEngine::_cursorHints into a Common::Array
0463e00fb6 MOHAWK: Don't downcast _invokingResource using static_cast
727ee86a44 MOHAWK: Don't use static_cast to downcast view resources
de5015dce4 MOHAWK: Fix some incorrect MystArea casts
eb47dcf2c9 MOHAWK: Implement preloading conditional script resources
01bfd37919 MOHAWK: Adjust MystAreaVideo::playAreaVideo for the refactored VideoManager
22882f54e1 MOHAWK: Fix uninitialized memory accesses in the Myst stacks
bc687c7216 MOHAWK: Fix two Myst resource stream memory leaks
e50f93f298 MOHAWK: Fix Myst's fortress simulator using a hack
Commit: 47bc90f5a3057e3eeedf06d864c55ad7fd1741e4
https://github.com/scummvm/scummvm/commit/47bc90f5a3057e3eeedf06d864c55ad7fd1741e4
Author: Bastien Bouclet (bastien.bouclet at gmail.com)
Date: 2016-02-07T15:27:03+01:00
Commit Message:
MOHAWK: Remove some dead code
Changed paths:
engines/mohawk/myst.cpp
engines/mohawk/myst.h
engines/mohawk/myst_areas.cpp
engines/mohawk/myst_scripts.cpp
engines/mohawk/myst_scripts.h
diff --git a/engines/mohawk/myst.cpp b/engines/mohawk/myst.cpp
index b6a6c27..2f6444a 100644
--- a/engines/mohawk/myst.cpp
+++ b/engines/mohawk/myst.cpp
@@ -78,7 +78,6 @@ MohawkEngine_Myst::MohawkEngine_Myst(OSystem *syst, const MohawkGameDescription
_needsUpdate = false;
_curResource = -1;
_hoverResource = 0;
- _dragResource = 0;
_gfx = NULL;
_console = NULL;
@@ -644,7 +643,6 @@ void MohawkEngine_Myst::changeToCard(uint16 card, TransitionType transition) {
}
// Make sure we have the right cursor showing
- _dragResource = 0;
_hoverResource = 0;
_curResource = -1;
checkCurrentResource();
diff --git a/engines/mohawk/myst.h b/engines/mohawk/myst.h
index 4d86642..b2f93ae 100644
--- a/engines/mohawk/myst.h
+++ b/engines/mohawk/myst.h
@@ -168,8 +168,6 @@ public:
Common::String wrapMovieFilename(const Common::String &movieName, uint16 stack);
- void reloadSaveList();
-
void changeToStack(uint16 stack, uint16 card, uint16 linkSrcSound, uint16 linkDstSound);
void changeToCard(uint16 card, TransitionType transition);
uint16 getCurCard() { return _curCard; }
@@ -191,7 +189,6 @@ public:
MystGameState *_gameState;
MystScriptParser *_scriptParser;
Common::Array<MystResource *> _resources;
- MystResource *_dragResource;
Common::RandomSource *_rnd;
bool _showResourceRects;
diff --git a/engines/mohawk/myst_areas.cpp b/engines/mohawk/myst_areas.cpp
index 7a9596d..802e5e9 100644
--- a/engines/mohawk/myst_areas.cpp
+++ b/engines/mohawk/myst_areas.cpp
@@ -554,9 +554,6 @@ void MystResourceType10::restoreBackground() {
}
void MystResourceType10::handleMouseDown() {
- // Tell the engine we are dragging a resource
- _vm->_dragResource = this;
-
const Common::Point &mouse = _vm->_system->getEventManager()->getMousePos();
updatePosition(mouse);
@@ -596,9 +593,6 @@ void MystResourceType10::handleMouseUp() {
_vm->_scriptParser->setVarValue(_var8, value);
MystResourceType11::handleMouseUp();
-
- // No longer in drag mode
- _vm->_dragResource = 0;
}
void MystResourceType10::handleMouseDrag() {
diff --git a/engines/mohawk/myst_scripts.cpp b/engines/mohawk/myst_scripts.cpp
index 487d0f4..99970e6 100644
--- a/engines/mohawk/myst_scripts.cpp
+++ b/engines/mohawk/myst_scripts.cpp
@@ -260,15 +260,6 @@ bool MystScriptParser::setVarValue(uint16 var, uint16 value) {
return false;
}
-// NOTE: Check to be used on Opcodes where var is thought
-// not to be used. This emits a warning if var is nonzero.
-// It is possible that the opcode does use var 0 in this case,
-// but this will catch the majority of missed cases.
-void MystScriptParser::varUnusedCheck(uint16 op, uint16 var) {
- if (var != 0)
- warning("Opcode %d: Unused Var %d", op, var);
-}
-
void MystScriptParser::animatedUpdate(uint16 argc, uint16 *argv, uint16 delay) {
uint16 argsRead = 0;
diff --git a/engines/mohawk/myst_scripts.h b/engines/mohawk/myst_scripts.h
index 7d8165c..cce4d7f 100644
--- a/engines/mohawk/myst_scripts.h
+++ b/engines/mohawk/myst_scripts.h
@@ -163,7 +163,6 @@ protected:
static const uint16 _startCard[];
void setupCommonOpcodes();
- void varUnusedCheck(uint16 op, uint16 var);
};
} // End of namespace Mohawk
Commit: 25330c714ebc5690fc51cf1ba854de2c30356fe6
https://github.com/scummvm/scummvm/commit/25330c714ebc5690fc51cf1ba854de2c30356fe6
Author: Bastien Bouclet (bastien.bouclet at gmail.com)
Date: 2016-02-07T15:27:03+01:00
Commit Message:
MOHAWK: Add missing virtual attributes to MystResourceType11
Changed paths:
engines/mohawk/myst_areas.h
diff --git a/engines/mohawk/myst_areas.h b/engines/mohawk/myst_areas.h
index 97ec882..dadabee 100644
--- a/engines/mohawk/myst_areas.h
+++ b/engines/mohawk/myst_areas.h
@@ -170,9 +170,9 @@ public:
virtual ~MystResourceType11();
const Common::String describe();
- void handleMouseDown();
- void handleMouseUp();
- void handleMouseDrag();
+ virtual void handleMouseDown();
+ virtual void handleMouseUp();
+ virtual void handleMouseDrag();
uint16 getList1(uint16 index);
uint16 getList2(uint16 index);
Commit: ce25cdf8dcefc0755c4232fb40eb1a98d28e20b4
https://github.com/scummvm/scummvm/commit/ce25cdf8dcefc0755c4232fb40eb1a98d28e20b4
Author: Bastien Bouclet (bastien.bouclet at gmail.com)
Date: 2016-02-07T15:27:03+01:00
Commit Message:
MOHAWK: Add override qualifiers to the Myst code
Changed paths:
engines/mohawk/myst.h
engines/mohawk/myst_areas.h
engines/mohawk/myst_graphics.h
engines/mohawk/myst_stacks/channelwood.h
engines/mohawk/myst_stacks/credits.h
engines/mohawk/myst_stacks/demo.h
engines/mohawk/myst_stacks/dni.h
engines/mohawk/myst_stacks/intro.h
engines/mohawk/myst_stacks/makingof.h
engines/mohawk/myst_stacks/mechanical.h
engines/mohawk/myst_stacks/myst.h
engines/mohawk/myst_stacks/preview.h
engines/mohawk/myst_stacks/selenitic.h
engines/mohawk/myst_stacks/slides.h
engines/mohawk/myst_stacks/stoneship.h
diff --git a/engines/mohawk/myst.h b/engines/mohawk/myst.h
index b2f93ae..0e0755b 100644
--- a/engines/mohawk/myst.h
+++ b/engines/mohawk/myst.h
@@ -158,13 +158,13 @@ struct MystCursorHint {
class MohawkEngine_Myst : public MohawkEngine {
protected:
- Common::Error run();
+ Common::Error run() override;
public:
MohawkEngine_Myst(OSystem *syst, const MohawkGameDescription *gamedesc);
virtual ~MohawkEngine_Myst();
- Common::SeekableReadStream *getResource(uint32 tag, uint16 id);
+ Common::SeekableReadStream *getResource(uint32 tag, uint16 id) override;
Common::String wrapMovieFilename(const Common::String &movieName, uint16 stack);
@@ -203,13 +203,13 @@ public:
void setCacheState(bool state) { _cache.enabled = state; }
bool getCacheState() { return _cache.enabled; }
- GUI::Debugger *getDebugger() { return _console; }
+ GUI::Debugger *getDebugger() override { return _console; }
- bool canLoadGameStateCurrently();
- bool canSaveGameStateCurrently();
- Common::Error loadGameState(int slot);
- Common::Error saveGameState(int slot, const Common::String &desc);
- bool hasFeature(EngineFeature f) const;
+ bool canLoadGameStateCurrently() override;
+ bool canSaveGameStateCurrently() override;
+ Common::Error loadGameState(int slot) override;
+ Common::Error saveGameState(int slot, const Common::String &desc) override;
+ bool hasFeature(EngineFeature f) const override;
private:
MystConsole *_console;
diff --git a/engines/mohawk/myst_areas.h b/engines/mohawk/myst_areas.h
index dadabee..46abc9a 100644
--- a/engines/mohawk/myst_areas.h
+++ b/engines/mohawk/myst_areas.h
@@ -95,8 +95,8 @@ protected:
class MystResourceType5 : public MystResource {
public:
MystResourceType5(MohawkEngine_Myst *vm, Common::SeekableReadStream *rlstStream, MystResource *parent);
- void handleMouseUp();
- const Common::String describe();
+ void handleMouseUp() override;
+ const Common::String describe() override;
protected:
MystScript _script;
@@ -106,7 +106,7 @@ class MystResourceType6 : public MystResourceType5 {
public:
MystResourceType6(MohawkEngine_Myst *vm, Common::SeekableReadStream *rlstStream, MystResource *parent);
VideoHandle playMovie();
- void handleCardChange();
+ void handleCardChange() override;
bool isPlaying();
void setDirection(int16 direction) { _direction = direction; }
void setBlocking(bool blocking) { _playBlocking = blocking; }
@@ -129,11 +129,11 @@ public:
MystResourceType7(MohawkEngine_Myst *vm, Common::SeekableReadStream *rlstStream, MystResource *parent);
virtual ~MystResourceType7();
- virtual void drawDataToScreen();
- virtual void handleCardChange();
+ virtual void drawDataToScreen() override;
+ virtual void handleCardChange() override;
- virtual void handleMouseUp();
- virtual void handleMouseDown();
+ virtual void handleMouseUp() override;
+ virtual void handleMouseDown() override;
MystResource *getSubResource(uint16 index) { return _subResources[index]; }
protected:
@@ -146,11 +146,11 @@ class MystResourceType8 : public MystResourceType7 {
public:
MystResourceType8(MohawkEngine_Myst *vm, Common::SeekableReadStream *rlstStream, MystResource *parent);
virtual ~MystResourceType8();
- virtual const Common::String describe();
+ virtual const Common::String describe() override;
- virtual void drawDataToScreen();
+ virtual void drawDataToScreen() override;
void drawConditionalDataToScreen(uint16 state, bool update = true);
- uint16 getType8Var();
+ uint16 getType8Var() override;
struct SubImage {
uint16 wdib;
@@ -168,11 +168,11 @@ class MystResourceType11 : public MystResourceType8 {
public:
MystResourceType11(MohawkEngine_Myst *vm, Common::SeekableReadStream *rlstStream, MystResource *parent);
virtual ~MystResourceType11();
- const Common::String describe();
+ const Common::String describe() override;
- virtual void handleMouseDown();
- virtual void handleMouseUp();
- virtual void handleMouseDrag();
+ virtual void handleMouseDown() override;
+ virtual void handleMouseUp() override;
+ virtual void handleMouseDrag() override;
uint16 getList1(uint16 index);
uint16 getList2(uint16 index);
@@ -209,9 +209,9 @@ public:
MystResourceType10(MohawkEngine_Myst *vm, Common::SeekableReadStream *rlstStream, MystResource *parent);
virtual ~MystResourceType10();
- void handleMouseDown();
- void handleMouseUp();
- void handleMouseDrag();
+ void handleMouseDown() override;
+ void handleMouseUp() override;
+ void handleMouseDrag() override;
void setStep(uint16 step);
void setPosition(uint16 pos);
void restoreBackground();
@@ -246,9 +246,9 @@ private:
class MystResourceType13 : public MystResource {
public:
MystResourceType13(MohawkEngine_Myst *vm, Common::SeekableReadStream *rlstStream, MystResource *parent);
- const Common::String describe();
+ const Common::String describe() override;
- void handleMouseUp();
+ void handleMouseUp() override;
void handleMouseEnter();
void handleMouseLeave();
diff --git a/engines/mohawk/myst_graphics.h b/engines/mohawk/myst_graphics.h
index 6281c94..93e388c 100644
--- a/engines/mohawk/myst_graphics.h
+++ b/engines/mohawk/myst_graphics.h
@@ -61,8 +61,8 @@ public:
const byte *getPalette() const { return _palette; }
protected:
- MohawkSurface *decodeImage(uint16 id);
- MohawkEngine *getVM() { return (MohawkEngine *)_vm; }
+ MohawkSurface *decodeImage(uint16 id) override;
+ MohawkEngine *getVM() override { return (MohawkEngine *)_vm; }
private:
MohawkEngine_Myst *_vm;
diff --git a/engines/mohawk/myst_stacks/channelwood.h b/engines/mohawk/myst_stacks/channelwood.h
index bd5d7ff..719257f 100644
--- a/engines/mohawk/myst_stacks/channelwood.h
+++ b/engines/mohawk/myst_stacks/channelwood.h
@@ -40,16 +40,16 @@ public:
Channelwood(MohawkEngine_Myst *vm);
~Channelwood();
- void disablePersistentScripts();
- void runPersistentScripts();
+ void disablePersistentScripts() override;
+ void runPersistentScripts() override;
private:
void setupOpcodes();
- uint16 getVar(uint16 var);
- void toggleVar(uint16 var);
- bool setVarValue(uint16 var, uint16 value);
+ uint16 getVar(uint16 var) override;
+ void toggleVar(uint16 var) override;
+ bool setVarValue(uint16 var, uint16 value) override;
- virtual uint16 getMap() { return 9932; }
+ virtual uint16 getMap() override { return 9932; }
DECLARE_OPCODE(o_bridgeToggle);
DECLARE_OPCODE(o_pipeExtend);
diff --git a/engines/mohawk/myst_stacks/credits.h b/engines/mohawk/myst_stacks/credits.h
index 3c0f969..c2c2037 100644
--- a/engines/mohawk/myst_stacks/credits.h
+++ b/engines/mohawk/myst_stacks/credits.h
@@ -40,12 +40,12 @@ public:
Credits(MohawkEngine_Myst *vm);
~Credits();
- void disablePersistentScripts();
- void runPersistentScripts();
+ void disablePersistentScripts() override;
+ void runPersistentScripts() override;
private:
void setupOpcodes();
- uint16 getVar(uint16 var);
+ uint16 getVar(uint16 var) override;
DECLARE_OPCODE(o_runCredits);
diff --git a/engines/mohawk/myst_stacks/demo.h b/engines/mohawk/myst_stacks/demo.h
index f19b9a6..64a3925 100644
--- a/engines/mohawk/myst_stacks/demo.h
+++ b/engines/mohawk/myst_stacks/demo.h
@@ -40,8 +40,8 @@ public:
Demo(MohawkEngine_Myst *vm);
~Demo();
- void disablePersistentScripts();
- void runPersistentScripts();
+ void disablePersistentScripts() override;
+ void runPersistentScripts() override;
private:
void setupOpcodes();
diff --git a/engines/mohawk/myst_stacks/dni.h b/engines/mohawk/myst_stacks/dni.h
index 3dc4645..1a5f091 100644
--- a/engines/mohawk/myst_stacks/dni.h
+++ b/engines/mohawk/myst_stacks/dni.h
@@ -40,12 +40,12 @@ public:
Dni(MohawkEngine_Myst *vm);
~Dni();
- void disablePersistentScripts();
- void runPersistentScripts();
+ void disablePersistentScripts() override;
+ void runPersistentScripts() override;
private:
void setupOpcodes();
- uint16 getVar(uint16 var);
+ uint16 getVar(uint16 var) override;
void atrus_run();
void loopVideo_run();
diff --git a/engines/mohawk/myst_stacks/intro.h b/engines/mohawk/myst_stacks/intro.h
index a6c4a59..acff03e 100644
--- a/engines/mohawk/myst_stacks/intro.h
+++ b/engines/mohawk/myst_stacks/intro.h
@@ -41,12 +41,12 @@ public:
Intro(MohawkEngine_Myst *vm);
~Intro();
- void disablePersistentScripts();
- void runPersistentScripts();
+ void disablePersistentScripts() override;
+ void runPersistentScripts() override;
private:
void setupOpcodes();
- uint16 getVar(uint16 var);
+ uint16 getVar(uint16 var) override;
DECLARE_OPCODE(o_useLinkBook);
diff --git a/engines/mohawk/myst_stacks/makingof.h b/engines/mohawk/myst_stacks/makingof.h
index 79ef913..41f91bc 100644
--- a/engines/mohawk/myst_stacks/makingof.h
+++ b/engines/mohawk/myst_stacks/makingof.h
@@ -40,8 +40,8 @@ public:
MakingOf(MohawkEngine_Myst *vm);
~MakingOf();
- void disablePersistentScripts();
- void runPersistentScripts();
+ void disablePersistentScripts() override;
+ void runPersistentScripts() override;
private:
void setupOpcodes();
diff --git a/engines/mohawk/myst_stacks/mechanical.h b/engines/mohawk/myst_stacks/mechanical.h
index 6360b2b..ccc2783 100644
--- a/engines/mohawk/myst_stacks/mechanical.h
+++ b/engines/mohawk/myst_stacks/mechanical.h
@@ -40,16 +40,16 @@ public:
Mechanical(MohawkEngine_Myst *vm);
~Mechanical();
- void disablePersistentScripts();
- void runPersistentScripts();
+ void disablePersistentScripts() override;
+ void runPersistentScripts() override;
private:
void setupOpcodes();
- uint16 getVar(uint16 var);
- void toggleVar(uint16 var);
- bool setVarValue(uint16 var, uint16 value);
+ uint16 getVar(uint16 var) override;
+ void toggleVar(uint16 var) override;
+ bool setVarValue(uint16 var, uint16 value) override;
- virtual uint16 getMap() { return 9931; }
+ virtual uint16 getMap() override { return 9931; }
void birdSing_run();
void elevatorRotation_run();
diff --git a/engines/mohawk/myst_stacks/myst.h b/engines/mohawk/myst_stacks/myst.h
index a83609f..38b6d99 100644
--- a/engines/mohawk/myst_stacks/myst.h
+++ b/engines/mohawk/myst_stacks/myst.h
@@ -40,16 +40,16 @@ public:
Myst(MohawkEngine_Myst *vm);
~Myst();
- virtual void disablePersistentScripts();
- virtual void runPersistentScripts();
+ virtual void disablePersistentScripts() override;
+ virtual void runPersistentScripts() override;
protected:
void setupOpcodes();
- uint16 getVar(uint16 var);
- void toggleVar(uint16 var);
- bool setVarValue(uint16 var, uint16 value);
+ uint16 getVar(uint16 var) override;
+ void toggleVar(uint16 var) override;
+ bool setVarValue(uint16 var, uint16 value) override;
- virtual uint16 getMap() { return 9934; }
+ virtual uint16 getMap() override { return 9934; }
void towerRotationMap_run();
virtual void libraryBookcaseTransform_run();
diff --git a/engines/mohawk/myst_stacks/preview.h b/engines/mohawk/myst_stacks/preview.h
index 0959e93..04ad6c3 100644
--- a/engines/mohawk/myst_stacks/preview.h
+++ b/engines/mohawk/myst_stacks/preview.h
@@ -40,8 +40,8 @@ public:
Preview(MohawkEngine_Myst *vm);
~Preview();
- void disablePersistentScripts();
- void runPersistentScripts();
+ void disablePersistentScripts() override;
+ void runPersistentScripts() override;
private:
void setupOpcodes();
@@ -67,7 +67,7 @@ private:
void speech_run();
void speechUpdateCue();
- void libraryBookcaseTransform_run();
+ void libraryBookcaseTransform_run() override;
};
} // End of namespace MystStacks
diff --git a/engines/mohawk/myst_stacks/selenitic.h b/engines/mohawk/myst_stacks/selenitic.h
index c669d01..7654ffd 100644
--- a/engines/mohawk/myst_stacks/selenitic.h
+++ b/engines/mohawk/myst_stacks/selenitic.h
@@ -41,16 +41,16 @@ public:
Selenitic(MohawkEngine_Myst *vm);
~Selenitic();
- void disablePersistentScripts();
- void runPersistentScripts();
+ void disablePersistentScripts() override;
+ void runPersistentScripts() override;
private:
void setupOpcodes();
- uint16 getVar(uint16 var);
- void toggleVar(uint16 var);
- bool setVarValue(uint16 var, uint16 value);
+ uint16 getVar(uint16 var) override;
+ void toggleVar(uint16 var) override;
+ bool setVarValue(uint16 var, uint16 value) override;
- virtual uint16 getMap() { return 9930; }
+ virtual uint16 getMap() override { return 9930; }
DECLARE_OPCODE(o_mazeRunnerMove);
DECLARE_OPCODE(o_mazeRunnerSoundRepeat);
diff --git a/engines/mohawk/myst_stacks/slides.h b/engines/mohawk/myst_stacks/slides.h
index fb7868a..a0c9ae5 100644
--- a/engines/mohawk/myst_stacks/slides.h
+++ b/engines/mohawk/myst_stacks/slides.h
@@ -40,8 +40,8 @@ public:
Slides(MohawkEngine_Myst *vm);
~Slides();
- void disablePersistentScripts();
- void runPersistentScripts();
+ void disablePersistentScripts() override;
+ void runPersistentScripts() override;
private:
void setupOpcodes();
diff --git a/engines/mohawk/myst_stacks/stoneship.h b/engines/mohawk/myst_stacks/stoneship.h
index 4e1b42f..b77776f 100644
--- a/engines/mohawk/myst_stacks/stoneship.h
+++ b/engines/mohawk/myst_stacks/stoneship.h
@@ -40,16 +40,16 @@ public:
Stoneship(MohawkEngine_Myst *vm);
~Stoneship();
- void disablePersistentScripts();
- void runPersistentScripts();
+ void disablePersistentScripts() override;
+ void runPersistentScripts() override;
private:
void setupOpcodes();
- uint16 getVar(uint16 var);
- void toggleVar(uint16 var);
- bool setVarValue(uint16 var, uint16 value);
+ uint16 getVar(uint16 var) override;
+ void toggleVar(uint16 var) override;
+ bool setVarValue(uint16 var, uint16 value) override;
- virtual uint16 getMap() { return 9933; }
+ virtual uint16 getMap() override { return 9933; }
DECLARE_OPCODE(o_pumpTurnOff);
DECLARE_OPCODE(o_brotherDoorOpen);
Commit: 0c8d8bbd40e4806e1b63196e283bcbff21431080
https://github.com/scummvm/scummvm/commit/0c8d8bbd40e4806e1b63196e283bcbff21431080
Author: Bastien Bouclet (bastien.bouclet at gmail.com)
Date: 2016-02-07T15:27:03+01:00
Commit Message:
MOHAWK: Use nullptr where applicable in the Myst code
Changed paths:
engines/mohawk/myst.cpp
engines/mohawk/myst_areas.cpp
engines/mohawk/myst_graphics.cpp
engines/mohawk/myst_scripts.cpp
engines/mohawk/myst_scripts.h
engines/mohawk/myst_stacks/myst.cpp
engines/mohawk/myst_stacks/selenitic.cpp
engines/mohawk/myst_state.cpp
diff --git a/engines/mohawk/myst.cpp b/engines/mohawk/myst.cpp
index 2f6444a..8df6b01 100644
--- a/engines/mohawk/myst.cpp
+++ b/engines/mohawk/myst.cpp
@@ -77,26 +77,26 @@ MohawkEngine_Myst::MohawkEngine_Myst(OSystem *syst, const MohawkGameDescription
_curCard = 0;
_needsUpdate = false;
_curResource = -1;
- _hoverResource = 0;
+ _hoverResource = nullptr;
- _gfx = NULL;
- _console = NULL;
- _scriptParser = NULL;
- _gameState = NULL;
- _loadDialog = NULL;
- _optionsDialog = NULL;
+ _gfx = nullptr;
+ _console = nullptr;
+ _scriptParser = nullptr;
+ _gameState = nullptr;
+ _loadDialog = nullptr;
+ _optionsDialog = nullptr;
_cursorHintCount = 0;
- _cursorHints = NULL;
+ _cursorHints = nullptr;
- _prevStack = NULL;
+ _prevStack = nullptr;
_view.conditionalImageCount = 0;
- _view.conditionalImages = NULL;
- _view.soundList = NULL;
- _view.soundListVolume = NULL;
+ _view.conditionalImages = nullptr;
+ _view.soundList = nullptr;
+ _view.soundListVolume = nullptr;
_view.scriptResCount = 0;
- _view.scriptResources = NULL;
+ _view.scriptResources = nullptr;
}
MohawkEngine_Myst::~MohawkEngine_Myst() {
@@ -137,7 +137,7 @@ Common::SeekableReadStream *MohawkEngine_Myst::getResource(uint32 tag, uint16 id
}
error("Could not find a \'%s\' resource with ID %04x", tag2str(tag), id);
- return NULL;
+ return nullptr;
}
void MohawkEngine_Myst::cachePreload(uint32 tag, uint16 id) {
@@ -501,7 +501,7 @@ void MohawkEngine_Myst::changeToStack(uint16 stack, uint16 card, uint16 linkSrcS
if (getFeatures() & GF_ME) {
// Play Flyby Entry Movie on Masterpiece Edition.
- const char *flyby = 0;
+ const char *flyby = nullptr;
switch (_curStack) {
case kSeleniticStack:
@@ -643,7 +643,7 @@ void MohawkEngine_Myst::changeToCard(uint16 card, TransitionType transition) {
}
// Make sure we have the right cursor showing
- _hoverResource = 0;
+ _hoverResource = nullptr;
_curResource = -1;
checkCurrentResource();
@@ -669,7 +669,7 @@ void MohawkEngine_Myst::checkCurrentResource() {
// Tell previous resource the mouse is no longer hovering it
if (_hoverResource && !_hoverResource->contains(mouse)) {
_hoverResource->handleMouseLeave();
- _hoverResource = 0;
+ _hoverResource = nullptr;
}
for (uint16 i = 0; i < _resources.size(); i++)
@@ -698,7 +698,7 @@ MystResource *MohawkEngine_Myst::updateCurrentResource() {
if (_curResource >= 0)
return _resources[_curResource];
else
- return 0;
+ return nullptr;
}
void MohawkEngine_Myst::loadCard() {
@@ -810,7 +810,7 @@ void MohawkEngine_Myst::loadCard() {
debugC(kDebugView, "\t\t Resource List %d: %d", j, _view.scriptResources[i].resource_list[j]);
}
} else {
- _view.scriptResources[i].resource_list = NULL;
+ _view.scriptResources[i].resource_list = nullptr;
_view.scriptResources[i].id = viewStream->readUint16LE();
debugC(kDebugView, "\t\t Id: %d", _view.scriptResources[i].id);
}
@@ -881,18 +881,18 @@ void MohawkEngine_Myst::unloadCard() {
delete[] _view.conditionalImages;
_view.conditionalImageCount = 0;
- _view.conditionalImages = NULL;
+ _view.conditionalImages = nullptr;
delete[] _view.soundList;
- _view.soundList = NULL;
+ _view.soundList = nullptr;
delete[] _view.soundListVolume;
- _view.soundListVolume = NULL;
+ _view.soundListVolume = nullptr;
for (uint16 i = 0; i < _view.scriptResCount; i++)
delete[] _view.scriptResources[i].resource_list;
delete[] _view.scriptResources;
- _view.scriptResources = NULL;
+ _view.scriptResources = nullptr;
_view.scriptResCount = 0;
}
@@ -973,7 +973,7 @@ void MohawkEngine_Myst::loadCursorHints() {
delete[] _cursorHints[i].variableHint.values;
_cursorHintCount = 0;
delete[] _cursorHints;
- _cursorHints = NULL;
+ _cursorHints = nullptr;
if (!_view.hint) {
debugC(kDebugHint, "No HINT Present");
@@ -1008,7 +1008,7 @@ void MohawkEngine_Myst::loadCursorHints() {
} else {
_cursorHints[i].variableHint.var = 0;
_cursorHints[i].variableHint.numStates = 0;
- _cursorHints[i].variableHint.values = NULL;
+ _cursorHints[i].variableHint.values = nullptr;
}
}
@@ -1085,11 +1085,11 @@ void MohawkEngine_Myst::redrawArea(uint16 var, bool update) {
}
MystResource *MohawkEngine_Myst::loadResource(Common::SeekableReadStream *rlstStream, MystResource *parent) {
- MystResource *resource = 0;
+ MystResource *resource = nullptr;
ResourceType type = static_cast<ResourceType>(rlstStream->readUint16LE());
debugC(kDebugResource, "\tType: %d", type);
- debugC(kDebugResource, "\tSub_Record: %d", (parent == NULL) ? 0 : 1);
+ debugC(kDebugResource, "\tSub_Record: %d", (parent == nullptr) ? 0 : 1);
switch (type) {
case kMystAction:
@@ -1143,7 +1143,7 @@ void MohawkEngine_Myst::loadResources() {
for (uint16 i = 0; i < resourceCount; i++) {
debugC(kDebugResource, "Resource #%d:", i);
- _resources.push_back(loadResource(rlstStream, NULL));
+ _resources.push_back(loadResource(rlstStream, nullptr));
}
delete rlstStream;
diff --git a/engines/mohawk/myst_areas.cpp b/engines/mohawk/myst_areas.cpp
index 802e5e9..2221ef1 100644
--- a/engines/mohawk/myst_areas.cpp
+++ b/engines/mohawk/myst_areas.cpp
@@ -36,7 +36,7 @@ MystResource::MystResource(MohawkEngine_Myst *vm, Common::SeekableReadStream *rl
_vm = vm;
_parent = parent;
- if (parent == NULL) {
+ if (parent == nullptr) {
_flags = rlstStream->readUint16LE();
_rect.left = rlstStream->readSint16LE();
_rect.top = rlstStream->readSint16LE();
diff --git a/engines/mohawk/myst_graphics.cpp b/engines/mohawk/myst_graphics.cpp
index 49f97cc..7cb3280 100644
--- a/engines/mohawk/myst_graphics.cpp
+++ b/engines/mohawk/myst_graphics.cpp
@@ -40,7 +40,7 @@ MystGraphics::MystGraphics(MohawkEngine_Myst* vm) : GraphicsManager(), _vm(vm) {
if (_vm->getFeatures() & GF_ME) {
// High color
- initGraphics(_viewport.width(), _viewport.height(), true, NULL);
+ initGraphics(_viewport.width(), _viewport.height(), true, nullptr);
if (_vm->_system->getScreenFormat().bytesPerPixel == 1)
error("Myst ME requires greater than 256 colors to run");
@@ -73,7 +73,7 @@ MohawkSurface *MystGraphics::decodeImage(uint16 id) {
// if it's a PICT or WDIB resource. If it's Myst ME it's most likely a PICT, and if it's
// original it's definitely a WDIB. However, Myst ME throws us another curve ball in
// that PICT resources can contain WDIB's instead of PICT's.
- Common::SeekableReadStream *dataStream = NULL;
+ Common::SeekableReadStream *dataStream = nullptr;
if (_vm->getFeatures() & GF_ME && _vm->hasResource(ID_PICT, id)) {
// The PICT resource exists. However, it could still contain a MystBitmap
@@ -95,7 +95,7 @@ MohawkSurface *MystGraphics::decodeImage(uint16 id) {
dataStream->seek(0);
}
- MohawkSurface *mhkSurface = 0;
+ MohawkSurface *mhkSurface = nullptr;
if (isPict) {
Image::PICTDecoder pict;
diff --git a/engines/mohawk/myst_scripts.cpp b/engines/mohawk/myst_scripts.cpp
index 99970e6..14a95ee 100644
--- a/engines/mohawk/myst_scripts.cpp
+++ b/engines/mohawk/myst_scripts.cpp
@@ -38,7 +38,7 @@ MystScriptEntry::MystScriptEntry() {
type = kMystScriptNone;
var = 0;
argc = 0;
- argv = 0;
+ argv = nullptr;
resourceId = 0;
u1 = 0;
}
@@ -81,7 +81,7 @@ MystScriptParser::MystScriptParser(MohawkEngine_Myst *vm) :
_vm(vm),
_globals(vm->_gameState->_globals) {
setupCommonOpcodes();
- _invokingResource = NULL;
+ _invokingResource = nullptr;
_savedCardId = 0;
_savedCursorId = 0;
_tempVar = 0;
@@ -322,7 +322,7 @@ void MystScriptParser::o_changeCardSwitch4(uint16 op, uint16 var, uint16 argc, u
if (value)
_vm->changeToCard(argv[value -1 ], kTransitionDissolve);
- else if (_invokingResource != NULL)
+ else if (_invokingResource != nullptr)
_vm->changeToCard(_invokingResource->getDest(), kTransitionDissolve);
else
warning("Missing invokingResource in altDest call");
@@ -335,7 +335,7 @@ void MystScriptParser::o_changeCardSwitchLtR(uint16 op, uint16 var, uint16 argc,
if (value)
_vm->changeToCard(argv[value -1 ], kTransitionLeftToRight);
- else if (_invokingResource != NULL)
+ else if (_invokingResource != nullptr)
_vm->changeToCard(_invokingResource->getDest(), kTransitionLeftToRight);
else
warning("Missing invokingResource in altDest call");
@@ -348,7 +348,7 @@ void MystScriptParser::o_changeCardSwitchRtL(uint16 op, uint16 var, uint16 argc,
if (value)
_vm->changeToCard(argv[value -1 ], kTransitionRightToLeft);
- else if (_invokingResource != NULL)
+ else if (_invokingResource != nullptr)
_vm->changeToCard(_invokingResource->getDest(), kTransitionRightToLeft);
else
warning("Missing invokingResource in altDest call");
@@ -389,7 +389,7 @@ void MystScriptParser::o_redrawCard(uint16 op, uint16 var, uint16 argc, uint16 *
void MystScriptParser::o_goToDest(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Change To Dest of Invoking Resource", op);
- if (_invokingResource != NULL)
+ if (_invokingResource != nullptr)
_vm->changeToCard(_invokingResource->getDest(), kTransitionCopy);
else
warning("Opcode %d: Missing invokingResource", op);
@@ -398,7 +398,7 @@ void MystScriptParser::o_goToDest(uint16 op, uint16 var, uint16 argc, uint16 *ar
void MystScriptParser::o_goToDestForward(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Change To Dest of Invoking Resource", op);
- if (_invokingResource != NULL)
+ if (_invokingResource != nullptr)
_vm->changeToCard(_invokingResource->getDest(), kTransitionDissolve);
else
warning("Opcode %d: Missing invokingResource", op);
@@ -407,7 +407,7 @@ void MystScriptParser::o_goToDestForward(uint16 op, uint16 var, uint16 argc, uin
void MystScriptParser::o_goToDestLeft(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Change To Dest of Invoking Resource", op);
- if (_invokingResource != NULL)
+ if (_invokingResource != nullptr)
_vm->changeToCard(_invokingResource->getDest(), kTransitionPartToRight);
else
warning("Opcode %d: Missing invokingResource", op);
@@ -416,7 +416,7 @@ void MystScriptParser::o_goToDestLeft(uint16 op, uint16 var, uint16 argc, uint16
void MystScriptParser::o_goToDestRight(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Change To Dest of Invoking Resource", op);
- if (_invokingResource != NULL)
+ if (_invokingResource != nullptr)
_vm->changeToCard(_invokingResource->getDest(), kTransitionPartToLeft);
else
warning("Opcode %d: Missing invokingResource", op);
@@ -425,7 +425,7 @@ void MystScriptParser::o_goToDestRight(uint16 op, uint16 var, uint16 argc, uint1
void MystScriptParser::o_goToDestUp(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Change To Dest of Invoking Resource", op);
- if (_invokingResource != NULL)
+ if (_invokingResource != nullptr)
_vm->changeToCard(_invokingResource->getDest(), kTransitionTopToBottom);
else
warning("Opcode %d: Missing invokingResource", op);
@@ -522,7 +522,7 @@ void MystScriptParser::o_enableAreas(uint16 op, uint16 var, uint16 argc, uint16
for (uint16 i = 0; i < count; i++) {
debugC(kDebugScript, "Enable hotspot index %d", argv[i + 1]);
- MystResource *resource = 0;
+ MystResource *resource = nullptr;
if (argv[i + 1] == 0xFFFF)
resource = _invokingResource;
else
@@ -547,7 +547,7 @@ void MystScriptParser::o_disableAreas(uint16 op, uint16 var, uint16 argc, uint16
for (uint16 i = 0; i < count; i++) {
debugC(kDebugScript, "Disable hotspot index %d", argv[i + 1]);
- MystResource *resource = 0;
+ MystResource *resource = nullptr;
if (argv[i + 1] == 0xFFFF)
resource = _invokingResource;
else
@@ -578,7 +578,7 @@ void MystScriptParser::o_toggleAreasActivation(uint16 op, uint16 var, uint16 arg
for (uint16 i = 0; i < count; i++) {
debugC(kDebugScript, "Enable/Disable hotspot index %d", argv[i + 1]);
- MystResource *resource = 0;
+ MystResource *resource = nullptr;
if (argv[i + 1] == 0xFFFF)
resource = _invokingResource;
else
@@ -681,8 +681,8 @@ void MystScriptParser::o_copyImageToBackBuffer(uint16 op, uint16 var, uint16 arg
// by Channelwood Card 3280 (Tank Valve) and water flow sound behavior in pipe
// on cards leading from shed...
void MystScriptParser::o_changeBackgroundSound(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
- int16 *soundList = NULL;
- uint16 *soundListVolume = NULL;
+ int16 *soundList = nullptr;
+ uint16 *soundListVolume = nullptr;
// Used on Stoneship Card 2080
// Used on Channelwood Card 3225 with argc = 8 i.e. Conditional Sound List
@@ -746,9 +746,9 @@ void MystScriptParser::o_changeBackgroundSound(uint16 op, uint16 var, uint16 arg
warning("Unknown arg count in opcode %d", op);
delete[] soundList;
- soundList = NULL;
+ soundList = nullptr;
delete[] soundListVolume;
- soundListVolume = NULL;
+ soundListVolume = nullptr;
}
void MystScriptParser::o_soundPlaySwitch(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
diff --git a/engines/mohawk/myst_scripts.h b/engines/mohawk/myst_scripts.h
index cce4d7f..3cf5c2d 100644
--- a/engines/mohawk/myst_scripts.h
+++ b/engines/mohawk/myst_scripts.h
@@ -63,8 +63,8 @@ public:
MystScriptParser(MohawkEngine_Myst *vm);
virtual ~MystScriptParser();
- void runScript(MystScript script, MystResource *invokingResource = NULL);
- void runOpcode(uint16 op, uint16 var = 0, uint16 argc = 0, uint16 *argv = NULL);
+ void runScript(MystScript script, MystResource *invokingResource = nullptr);
+ void runOpcode(uint16 op, uint16 var = 0, uint16 argc = 0, uint16 *argv = nullptr);
const Common::String getOpcodeDesc(uint16 op);
MystScript readScript(Common::SeekableReadStream *stream, MystScriptType type);
void setInvokingResource(MystResource *resource) { _invokingResource = resource; }
diff --git a/engines/mohawk/myst_stacks/myst.cpp b/engines/mohawk/myst_stacks/myst.cpp
index 9ad1635..c449ccc 100644
--- a/engines/mohawk/myst_stacks/myst.cpp
+++ b/engines/mohawk/myst_stacks/myst.cpp
@@ -52,12 +52,12 @@ Myst::Myst(MohawkEngine_Myst *vm) :
_cabinDoorOpened = 0;
_cabinMatchState = 2;
_matchBurning = false;
- _tree = 0;
- _treeAlcove = 0;
+ _tree = nullptr;
+ _treeAlcove = nullptr;
_treeStopped = false;
_treeMinPosition = 0;
_imagerValidationStep = 0;
- _observatoryCurrentSlider = 0;
+ _observatoryCurrentSlider = nullptr;
_butterfliesMoviePlayed = false;
_state.treeLastMoveTime = _vm->_system->getMillis();
}
@@ -2838,7 +2838,7 @@ void Myst::o_observatoryChangeSettingStop(uint16 op, uint16 var, uint16 argc, ui
_vm->_gfx->copyBackBufferToScreen(_invokingResource->getRect());
if (_observatoryCurrentSlider) {
_vm->redrawResource(_observatoryCurrentSlider);
- _observatoryCurrentSlider = 0;
+ _observatoryCurrentSlider = nullptr;
}
_vm->_sound->resumeBackgroundMyst();
}
@@ -3828,13 +3828,13 @@ void Myst::o_bookAddSpecialPage_exit(uint16 op, uint16 var, uint16 argc, uint16
void Myst::o_treeCard_exit(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Exit tree card", op);
- _tree = 0;
+ _tree = nullptr;
}
void Myst::o_treeEntry_exit(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Exit tree card with entry", op);
- _treeAlcove = 0;
+ _treeAlcove = nullptr;
}
void Myst::o_boiler_exit(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
diff --git a/engines/mohawk/myst_stacks/selenitic.cpp b/engines/mohawk/myst_stacks/selenitic.cpp
index 8b95c7f..0cf89eb 100644
--- a/engines/mohawk/myst_stacks/selenitic.cpp
+++ b/engines/mohawk/myst_stacks/selenitic.cpp
@@ -39,7 +39,7 @@ namespace MystStacks {
Selenitic::Selenitic(MohawkEngine_Myst *vm) :
MystScriptParser(vm), _state(vm->_gameState->_selenitic) {
setupOpcodes();
- _invokingResource = NULL;
+ _invokingResource = nullptr;
_mazeRunnerPosition = 288;
_mazeRunnerDirection = 8;
}
@@ -784,7 +784,7 @@ MystResourceType10 *Selenitic::soundLockSliderFromVar(uint16 var) {
return _soundLockSlider5;
}
- return 0;
+ return nullptr;
}
void Selenitic::o_soundLockMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
diff --git a/engines/mohawk/myst_state.cpp b/engines/mohawk/myst_state.cpp
index 3e54017..9bfbba6 100644
--- a/engines/mohawk/myst_state.cpp
+++ b/engines/mohawk/myst_state.cpp
@@ -96,7 +96,7 @@ bool MystGameState::load(const Common::String &filename) {
return false;
}
- Common::Serializer s(loadFile, 0);
+ Common::Serializer s(loadFile, nullptr);
syncGameState(s, size == 664);
delete loadFile;
@@ -131,7 +131,7 @@ bool MystGameState::save(const Common::String &fname) {
debugC(kDebugSaveLoad, "Saving game to '%s'", filename.c_str());
- Common::Serializer s(0, saveFile);
+ Common::Serializer s(nullptr, saveFile);
syncGameState(s, _vm->getFeatures() & GF_ME);
saveFile->finalize();
delete saveFile;
@@ -321,7 +321,7 @@ void MystGameState::deleteSave(const Common::String &saveName) {
}
void MystGameState::addZipDest(uint16 stack, uint16 view) {
- ZipDests *zipDests = 0;
+ ZipDests *zipDests = nullptr;
// The demo has no zip dest storage
if (_vm->getFeatures() & GF_DEMO)
Commit: 085f3700f7cd6ddb23abe3719ca21b7025695da4
https://github.com/scummvm/scummvm/commit/085f3700f7cd6ddb23abe3719ca21b7025695da4
Author: Bastien Bouclet (bastien.bouclet at gmail.com)
Date: 2016-02-07T15:27:03+01:00
Commit Message:
MOHAWK: Make MystResourceType8::_subImages private
Changed paths:
engines/mohawk/myst_areas.cpp
engines/mohawk/myst_areas.h
engines/mohawk/myst_stacks/myst.cpp
engines/mohawk/myst_stacks/selenitic.cpp
diff --git a/engines/mohawk/myst_areas.cpp b/engines/mohawk/myst_areas.cpp
index 2221ef1..45840bc 100644
--- a/engines/mohawk/myst_areas.cpp
+++ b/engines/mohawk/myst_areas.cpp
@@ -369,37 +369,37 @@ MystResourceType8::MystResourceType8(MohawkEngine_Myst *vm, Common::SeekableRead
debugC(kDebugResource, "\tvar8: %d", _var8);
debugC(kDebugResource, "\tnumSubImages: %d", _numSubImages);
- _subImages = new MystResourceType8::SubImage[_numSubImages];
-
for (uint16 i = 0; i < _numSubImages; i++) {
debugC(kDebugResource, "\tSubimage %d:", i);
- _subImages[i].wdib = rlstStream->readUint16LE();
- _subImages[i].rect.left = rlstStream->readSint16LE();
+ SubImage subImage;
+ subImage.wdib = rlstStream->readUint16LE();
+ subImage.rect.left = rlstStream->readSint16LE();
- if (_subImages[i].rect.left != -1) {
- _subImages[i].rect.top = rlstStream->readSint16LE();
- _subImages[i].rect.right = rlstStream->readSint16LE();
- _subImages[i].rect.bottom = rlstStream->readSint16LE();
+ if (subImage.rect.left != -1) {
+ subImage.rect.top = rlstStream->readSint16LE();
+ subImage.rect.right = rlstStream->readSint16LE();
+ subImage.rect.bottom = rlstStream->readSint16LE();
} else {
// Use the hotspot rect as the source rect since the subimage is fullscreen
// Convert to bitmap coordinates (upside down)
- _subImages[i].rect.left = _rect.left;
- _subImages[i].rect.top = 333 - _rect.bottom;
- _subImages[i].rect.right = _rect.right;
- _subImages[i].rect.bottom = 333 - _rect.top;
+ subImage.rect.left = _rect.left;
+ subImage.rect.top = 333 - _rect.bottom;
+ subImage.rect.right = _rect.right;
+ subImage.rect.bottom = 333 - _rect.top;
}
- debugC(kDebugResource, "\twdib: %d", _subImages[i].wdib);
- debugC(kDebugResource, "\tleft: %d", _subImages[i].rect.left);
- debugC(kDebugResource, "\ttop: %d", _subImages[i].rect.top);
- debugC(kDebugResource, "\tright: %d", _subImages[i].rect.right);
- debugC(kDebugResource, "\tbottom: %d", _subImages[i].rect.bottom);
+ debugC(kDebugResource, "\twdib: %d", subImage.wdib);
+ debugC(kDebugResource, "\tleft: %d", subImage.rect.left);
+ debugC(kDebugResource, "\ttop: %d", subImage.rect.top);
+ debugC(kDebugResource, "\tright: %d", subImage.rect.right);
+ debugC(kDebugResource, "\tbottom: %d", subImage.rect.bottom);
+
+ _subImages.push_back(subImage);
}
}
MystResourceType8::~MystResourceType8() {
- delete[] _subImages;
}
void MystResourceType8::drawDataToScreen() {
@@ -480,6 +480,14 @@ uint16 MystResourceType8::getType8Var() {
return _var8;
}
+MystResourceType8::SubImage MystResourceType8::getSubImage(uint index) const {
+ return _subImages[index];
+}
+
+void MystResourceType8::setSubImageRect(uint index, const Common::Rect &rect) {
+ _subImages[index].rect = rect;
+}
+
const Common::String MystResourceType8::describe() {
Common::String desc = Common::String::format("%s var: %2d",
MystResourceType7::describe().c_str(), _var8);
diff --git a/engines/mohawk/myst_areas.h b/engines/mohawk/myst_areas.h
index 46abc9a..881edf2 100644
--- a/engines/mohawk/myst_areas.h
+++ b/engines/mohawk/myst_areas.h
@@ -146,20 +146,24 @@ class MystResourceType8 : public MystResourceType7 {
public:
MystResourceType8(MohawkEngine_Myst *vm, Common::SeekableReadStream *rlstStream, MystResource *parent);
virtual ~MystResourceType8();
- virtual const Common::String describe() override;
+ struct SubImage {
+ uint16 wdib;
+ Common::Rect rect;
+ };
+
+ virtual const Common::String describe() override;
virtual void drawDataToScreen() override;
void drawConditionalDataToScreen(uint16 state, bool update = true);
uint16 getType8Var() override;
- struct SubImage {
- uint16 wdib;
- Common::Rect rect;
- } *_subImages;
+ SubImage getSubImage(uint index) const;
+ void setSubImageRect(uint index, const Common::Rect &rect);
protected:
uint16 _var8;
uint16 _numSubImages;
+ Common::Array<SubImage> _subImages;
};
// No MystResourceType9!
diff --git a/engines/mohawk/myst_stacks/myst.cpp b/engines/mohawk/myst_stacks/myst.cpp
index c449ccc..c5f76fe 100644
--- a/engines/mohawk/myst_stacks/myst.cpp
+++ b/engines/mohawk/myst_stacks/myst.cpp
@@ -2302,14 +2302,14 @@ void Myst::o_rocketPianoStart(uint16 op, uint16 var, uint16 argc, uint16 *argv)
MystResourceType11 *key = static_cast<MystResourceType11 *>(_invokingResource);
// What the hell??
- Common::Rect src = key->_subImages[1].rect;
- Common::Rect rect = key->_subImages[0].rect;
+ Common::Rect src = key->getSubImage(1).rect;
+ Common::Rect rect = key->getSubImage(0).rect;
Common::Rect dest = rect;
dest.top = 332 - rect.bottom;
dest.bottom = 332 - rect.top;
// Draw pressed piano key
- _vm->_gfx->copyImageSectionToScreen(key->_subImages[1].wdib, src, dest);
+ _vm->_gfx->copyImageSectionToScreen(key->getSubImage(0).wdib, src, dest);
_vm->_system->updateScreen();
// Play note
@@ -2328,27 +2328,27 @@ void Myst::o_rocketPianoMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
// Unpress previous key
MystResourceType11 *key = static_cast<MystResourceType11 *>(_invokingResource);
- Common::Rect src = key->_subImages[0].rect;
+ Common::Rect src = key->getSubImage(0).rect;
Common::Rect dest = src;
dest.top = 332 - src.bottom;
dest.bottom = 332 - src.top;
// Draw unpressed piano key
- _vm->_gfx->copyImageSectionToScreen(key->_subImages[0].wdib, src, dest);
+ _vm->_gfx->copyImageSectionToScreen(key->getSubImage(0).wdib, src, dest);
if (piano.contains(mouse)) {
MystResource *resource = _vm->updateCurrentResource();
if (resource && resource->type == kMystDragArea) {
// Press new key
key = static_cast<MystResourceType11 *>(resource);
- src = key->_subImages[1].rect;
- Common::Rect rect = key->_subImages[0].rect;
+ src = key->getSubImage(1).rect;
+ Common::Rect rect = key->getSubImage(0).rect;
dest = rect;
dest.top = 332 - rect.bottom;
dest.bottom = 332 - rect.top;
// Draw pressed piano key
- _vm->_gfx->copyImageSectionToScreen(key->_subImages[1].wdib, src, dest);
+ _vm->_gfx->copyImageSectionToScreen(key->getSubImage(1).wdib, src, dest);
// Play note
if (_state.generatorVoltage == 59 && !_state.generatorBreakers) {
@@ -2370,13 +2370,13 @@ void Myst::o_rocketPianoStop(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
MystResourceType8 *key = static_cast<MystResourceType8 *>(_invokingResource);
- Common::Rect &src = key->_subImages[0].rect;
+ Common::Rect src = key->getSubImage(0).rect;
Common::Rect dest = src;
dest.top = 332 - src.bottom;
dest.bottom = 332 - src.top;
// Draw unpressed piano key
- _vm->_gfx->copyImageSectionToScreen(key->_subImages[0].wdib, src, dest);
+ _vm->_gfx->copyImageSectionToScreen(key->getSubImage(0).wdib, src, dest);
_vm->_system->updateScreen();
_vm->_sound->stopSound();
@@ -3503,18 +3503,14 @@ bool Myst::observatoryIsDDMMYYYY2400() {
}
void Myst::observatoryUpdateVisualizer(uint16 x, uint16 y) {
- Common::Rect &visu0 = _observatoryVisualizer->_subImages[0].rect;
- Common::Rect &visu1 = _observatoryVisualizer->_subImages[1].rect;
-
- visu0.left = x;
- visu0.right = visu0.left + 105;
- visu0.bottom = 512 - y;
- visu0.top = visu0.bottom - 106;
-
- visu1.left = visu0.left;
- visu1.top = visu0.top;
- visu1.right = visu0.right;
- visu1.bottom = visu0.bottom;
+ Common::Rect visu;
+ visu.left = x;
+ visu.right = visu.left + 105;
+ visu.bottom = 512 - y;
+ visu.top = visu.bottom - 106;
+
+ _observatoryVisualizer->setSubImageRect(0, visu);
+ _observatoryVisualizer->setSubImageRect(1, visu);
}
void Myst::observatorySetTargetToSetting() {
diff --git a/engines/mohawk/myst_stacks/selenitic.cpp b/engines/mohawk/myst_stacks/selenitic.cpp
index 0cf89eb..7d1e1b9 100644
--- a/engines/mohawk/myst_stacks/selenitic.cpp
+++ b/engines/mohawk/myst_stacks/selenitic.cpp
@@ -671,9 +671,12 @@ void Selenitic::soundReceiverUpdate() {
void Selenitic::soundReceiverDrawView() {
uint32 left = ((*_soundReceiverPosition) * 1800) / 3600;
- _soundReceiverViewer->_subImages->rect.left = left;
- _soundReceiverViewer->_subImages->rect.right = left + 136;
+ Common::Rect rect = _soundReceiverViewer->getSubImage(0).rect;
+ rect.left = left;
+ rect.right = left + 136;
+
+ _soundReceiverViewer->setSubImageRect(0, rect);
_soundReceiverViewer->drawConditionalDataToScreen(0);
soundReceiverDrawAngle();
Commit: cddb5cd53a8fb5bb64c15a02950b05f5898f7e34
https://github.com/scummvm/scummvm/commit/cddb5cd53a8fb5bb64c15a02950b05f5898f7e34
Author: Bastien Bouclet (bastien.bouclet at gmail.com)
Date: 2016-02-07T15:27:03+01:00
Commit Message:
MOHAWK: Rename Myst's Area classes
Changed paths:
engines/mohawk/myst.cpp
engines/mohawk/myst.h
engines/mohawk/myst_areas.cpp
engines/mohawk/myst_areas.h
engines/mohawk/myst_scripts.cpp
engines/mohawk/myst_scripts.h
engines/mohawk/myst_stacks/channelwood.cpp
engines/mohawk/myst_stacks/channelwood.h
engines/mohawk/myst_stacks/intro.cpp
engines/mohawk/myst_stacks/intro.h
engines/mohawk/myst_stacks/mechanical.cpp
engines/mohawk/myst_stacks/mechanical.h
engines/mohawk/myst_stacks/myst.cpp
engines/mohawk/myst_stacks/myst.h
engines/mohawk/myst_stacks/preview.cpp
engines/mohawk/myst_stacks/preview.h
engines/mohawk/myst_stacks/selenitic.cpp
engines/mohawk/myst_stacks/selenitic.h
engines/mohawk/myst_stacks/stoneship.cpp
engines/mohawk/myst_stacks/stoneship.h
diff --git a/engines/mohawk/myst.cpp b/engines/mohawk/myst.cpp
index 8df6b01..3b132cf 100644
--- a/engines/mohawk/myst.cpp
+++ b/engines/mohawk/myst.cpp
@@ -674,8 +674,8 @@ void MohawkEngine_Myst::checkCurrentResource() {
for (uint16 i = 0; i < _resources.size(); i++)
if (_resources[i]->contains(mouse)) {
- if (_hoverResource != _resources[i] && _resources[i]->type == kMystHoverArea) {
- _hoverResource = static_cast<MystResourceType13 *>(_resources[i]);
+ if (_hoverResource != _resources[i] && _resources[i]->type == kMystAreaHover) {
+ _hoverResource = static_cast<MystAreaHover *>(_resources[i]);
_hoverResource->handleMouseEnter();
}
@@ -692,7 +692,7 @@ void MohawkEngine_Myst::checkCurrentResource() {
checkCursorHints();
}
-MystResource *MohawkEngine_Myst::updateCurrentResource() {
+MystArea *MohawkEngine_Myst::updateCurrentResource() {
checkCurrentResource();
if (_curResource >= 0)
@@ -1074,50 +1074,50 @@ void MohawkEngine_Myst::drawResourceImages() {
_resources[i]->drawDataToScreen();
}
-void MohawkEngine_Myst::redrawResource(MystResourceType8 *resource, bool update) {
- resource->drawConditionalDataToScreen(_scriptParser->getVar(resource->getType8Var()), update);
+void MohawkEngine_Myst::redrawResource(MystAreaImageSwitch *resource, bool update) {
+ resource->drawConditionalDataToScreen(_scriptParser->getVar(resource->getImageSwitchVar()), update);
}
void MohawkEngine_Myst::redrawArea(uint16 var, bool update) {
for (uint16 i = 0; i < _resources.size(); i++)
- if (_resources[i]->type == kMystConditionalImage && _resources[i]->getType8Var() == var)
- redrawResource(static_cast<MystResourceType8 *>(_resources[i]), update);
+ if (_resources[i]->type == kMystAreaImageSwitch && _resources[i]->getImageSwitchVar() == var)
+ redrawResource(static_cast<MystAreaImageSwitch *>(_resources[i]), update);
}
-MystResource *MohawkEngine_Myst::loadResource(Common::SeekableReadStream *rlstStream, MystResource *parent) {
- MystResource *resource = nullptr;
+MystArea *MohawkEngine_Myst::loadResource(Common::SeekableReadStream *rlstStream, MystArea *parent) {
+ MystArea *resource = nullptr;
ResourceType type = static_cast<ResourceType>(rlstStream->readUint16LE());
debugC(kDebugResource, "\tType: %d", type);
debugC(kDebugResource, "\tSub_Record: %d", (parent == nullptr) ? 0 : 1);
switch (type) {
- case kMystAction:
- resource = new MystResourceType5(this, rlstStream, parent);
+ case kMystAreaAction:
+ resource = new MystAreaAction(this, rlstStream, parent);
break;
- case kMystVideo:
- resource = new MystResourceType6(this, rlstStream, parent);
+ case kMystAreaVideo:
+ resource = new MystAreaVideo(this, rlstStream, parent);
break;
- case kMystSwitch:
- resource = new MystResourceType7(this, rlstStream, parent);
+ case kMystAreaActionSwitch:
+ resource = new MystAreaActionSwitch(this, rlstStream, parent);
break;
- case kMystConditionalImage:
- resource = new MystResourceType8(this, rlstStream, parent);
+ case kMystAreaImageSwitch:
+ resource = new MystAreaImageSwitch(this, rlstStream, parent);
break;
- case kMystSlider:
- resource = new MystResourceType10(this, rlstStream, parent);
+ case kMystAreaSlider:
+ resource = new MystAreaSlider(this, rlstStream, parent);
break;
- case kMystDragArea:
- resource = new MystResourceType11(this, rlstStream, parent);
+ case kMystAreaDrag:
+ resource = new MystAreaDrag(this, rlstStream, parent);
break;
case kMystVideoInfo:
- resource = new MystResourceType12(this, rlstStream, parent);
+ resource = new MystVideoInfo(this, rlstStream, parent);
break;
- case kMystHoverArea:
- resource = new MystResourceType13(this, rlstStream, parent);
+ case kMystAreaHover:
+ resource = new MystAreaHover(this, rlstStream, parent);
break;
default:
- resource = new MystResource(this, rlstStream, parent);
+ resource = new MystArea(this, rlstStream, parent);
break;
}
diff --git a/engines/mohawk/myst.h b/engines/mohawk/myst.h
index 0e0755b..1cf5858 100644
--- a/engines/mohawk/myst.h
+++ b/engines/mohawk/myst.h
@@ -41,9 +41,9 @@ class MystScriptParser;
class MystConsole;
class MystGameState;
class MystOptionsDialog;
-class MystResource;
-class MystResourceType8;
-class MystResourceType13;
+class MystArea;
+class MystAreaImageSwitch;
+class MystAreaHover;
// Engine Debug Flags
enum {
@@ -175,7 +175,7 @@ public:
void setMainCursor(uint16 cursor);
uint16 getMainCursor() { return _mainCursor; }
void checkCursorHints();
- MystResource *updateCurrentResource();
+ MystArea *updateCurrentResource();
bool skippableWait(uint32 duration);
bool _tweaksEnabled;
@@ -184,18 +184,16 @@ public:
bool _needsShowMap;
bool _needsShowDemoMenu;
- MystView _view;
MystGraphics *_gfx;
MystGameState *_gameState;
MystScriptParser *_scriptParser;
- Common::Array<MystResource *> _resources;
+ Common::Array<MystArea *> _resources;
Common::RandomSource *_rnd;
- bool _showResourceRects;
- MystResource *loadResource(Common::SeekableReadStream *rlstStream, MystResource *parent);
+ MystArea *loadResource(Common::SeekableReadStream *rlstStream, MystArea *parent);
void setResourceEnabled(uint16 resourceId, bool enable);
void redrawArea(uint16 var, bool update = true);
- void redrawResource(MystResourceType8 *resource, bool update = true);
+ void redrawResource(MystAreaImageSwitch *resource, bool update = true);
void drawResourceImages();
void drawCardBackground();
uint16 getCardBackgroundId();
@@ -221,7 +219,9 @@ private:
uint16 _curStack;
uint16 _curCard;
+ MystView _view;
+ bool _showResourceRects;
bool _runExitScript;
void dropPage();
@@ -237,7 +237,7 @@ private:
void drawResourceRects();
void checkCurrentResource();
int16 _curResource;
- MystResourceType13 *_hoverResource;
+ MystAreaHover *_hoverResource;
uint16 _cursorHintCount;
MystCursorHint *_cursorHints;
diff --git a/engines/mohawk/myst_areas.cpp b/engines/mohawk/myst_areas.cpp
index 45840bc..298fc56 100644
--- a/engines/mohawk/myst_areas.cpp
+++ b/engines/mohawk/myst_areas.cpp
@@ -32,7 +32,7 @@
namespace Mohawk {
-MystResource::MystResource(MohawkEngine_Myst *vm, Common::SeekableReadStream *rlstStream, MystResource *parent) {
+MystArea::MystArea(MohawkEngine_Myst *vm, Common::SeekableReadStream *rlstStream, MystArea *parent) {
_vm = vm;
_parent = parent;
@@ -66,10 +66,10 @@ MystResource::MystResource(MohawkEngine_Myst *vm, Common::SeekableReadStream *rl
debugC(kDebugResource, "\tdest: %d", _dest);
}
-MystResource::~MystResource() {
+MystArea::~MystArea() {
}
-void MystResource::handleMouseUp() {
+void MystArea::handleMouseUp() {
if (_dest == 0) {
warning("Movement type resource with null destination at position (%d, %d), (%d, %d)", _rect.left, _rect.top, _rect.right, _rect.bottom);
return;
@@ -78,13 +78,13 @@ void MystResource::handleMouseUp() {
uint16 opcode;
switch (type) {
- case kMystForwardArea:
+ case kMystAreaForward:
opcode = 6;
break;
- case kMystLeftArea:
+ case kMystAreaLeft:
opcode = 8;
break;
- case kMystRightArea:
+ case kMystAreaRight:
opcode = 7;
break;
default:
@@ -96,27 +96,27 @@ void MystResource::handleMouseUp() {
_vm->_scriptParser->runOpcode(opcode, 0);
}
-bool MystResource::canBecomeActive() {
+bool MystArea::canBecomeActive() {
return !unreachableZipDest() && (isEnabled() || (_flags & kMystUnknownFlag));
}
-bool MystResource::unreachableZipDest() {
+bool MystArea::unreachableZipDest() {
return (_flags & kMystZipModeEnableFlag)
&& !_vm->_gameState->isReachableZipDest(_vm->getCurStack() , _dest);
}
-bool MystResource::isEnabled() {
+bool MystArea::isEnabled() {
return _flags & kMystHotspotEnableFlag;
}
-void MystResource::setEnabled(bool enabled) {
+void MystArea::setEnabled(bool enabled) {
if (enabled)
_flags |= kMystHotspotEnableFlag;
else
_flags &= ~kMystHotspotEnableFlag;
}
-const Common::String MystResource::describe() {
+const Common::String MystArea::describe() {
Common::String desc = Common::String::format("type: %2d rect: (%3d %3d %3d %3d)",
type, _rect.left, _rect.top, _rect.width(), _rect.height());
@@ -126,7 +126,7 @@ const Common::String MystResource::describe() {
return desc;
}
-void MystResource::drawBoundingRect() {
+void MystArea::drawBoundingRect() {
if (_rect.isValidRect()) {
if (!canBecomeActive())
_vm->_gfx->drawRect(_rect, kRectUnreachable);
@@ -137,18 +137,19 @@ void MystResource::drawBoundingRect() {
}
}
-MystResourceType5::MystResourceType5(MohawkEngine_Myst *vm, Common::SeekableReadStream *rlstStream, MystResource *parent) : MystResource(vm, rlstStream, parent) {
+MystAreaAction::MystAreaAction(MohawkEngine_Myst *vm, Common::SeekableReadStream *rlstStream, MystArea *parent) :
+ MystArea(vm, rlstStream, parent) {
debugC(kDebugResource, "\tResource Type 5 Script:");
_script = vm->_scriptParser->readScript(rlstStream, kMystScriptNormal);
}
-void MystResourceType5::handleMouseUp() {
+void MystAreaAction::handleMouseUp() {
_vm->_scriptParser->runScript(_script, this);
}
-const Common::String MystResourceType5::describe() {
- Common::String desc = MystResource::describe();
+const Common::String MystAreaAction::describe() {
+ Common::String desc = MystArea::describe();
if (_script->size() != 0) {
desc += " ops:";
@@ -161,7 +162,7 @@ const Common::String MystResourceType5::describe() {
}
// In Myst/Making of Myst, the paths are hardcoded ala Windows style without extension. Convert them.
-Common::String MystResourceType6::convertMystVideoName(Common::String name) {
+Common::String MystAreaVideo::convertMystVideoName(Common::String name) {
Common::String temp;
for (uint32 i = 1; i < name.size(); i++) {
@@ -174,7 +175,8 @@ Common::String MystResourceType6::convertMystVideoName(Common::String name) {
return temp + ".mov";
}
-MystResourceType6::MystResourceType6(MohawkEngine_Myst *vm, Common::SeekableReadStream *rlstStream, MystResource *parent) : MystResourceType5(vm, rlstStream, parent) {
+MystAreaVideo::MystAreaVideo(MohawkEngine_Myst *vm, Common::SeekableReadStream *rlstStream, MystArea *parent) :
+ MystAreaAction(vm, rlstStream, parent) {
char c = 0;
do {
@@ -218,7 +220,7 @@ MystResourceType6::MystResourceType6(MohawkEngine_Myst *vm, Common::SeekableRead
debugC(kDebugResource, "\tu3: %d", _u3);
}
-VideoHandle MystResourceType6::playMovie() {
+VideoHandle MystAreaVideo::playMovie() {
// Check if the video is already running
VideoHandle handle = _vm->_video->findVideoHandle(_videoFile);
@@ -248,33 +250,34 @@ VideoHandle MystResourceType6::playMovie() {
return handle;
}
-void MystResourceType6::handleCardChange() {
+void MystAreaVideo::handleCardChange() {
if (_playOnCardChange)
playMovie();
}
-bool MystResourceType6::isPlaying() {
+bool MystAreaVideo::isPlaying() {
VideoHandle handle = _vm->_video->findVideoHandle(_videoFile);
return handle && !handle->endOfVideo();
}
-void MystResourceType6::pauseMovie(bool pause) {
+void MystAreaVideo::pauseMovie(bool pause) {
VideoHandle handle = _vm->_video->findVideoHandle(_videoFile);
if (handle && !handle->endOfVideo())
handle->pause(pause);
}
-MystResourceType7::MystResourceType7(MohawkEngine_Myst *vm, Common::SeekableReadStream *rlstStream, MystResource *parent) : MystResource(vm, rlstStream, parent) {
- _var7 = rlstStream->readUint16LE();
+MystAreaActionSwitch::MystAreaActionSwitch(MohawkEngine_Myst *vm, Common::SeekableReadStream *rlstStream, MystArea *parent) :
+ MystArea(vm, rlstStream, parent) {
+ _actionSwitchVar = rlstStream->readUint16LE();
_numSubResources = rlstStream->readUint16LE();
- debugC(kDebugResource, "\tvar7: %d", _var7);
+ debugC(kDebugResource, "\tvar7: %d", _actionSwitchVar);
debugC(kDebugResource, "\tnumSubResources: %d", _numSubResources);
for (uint16 i = 0; i < _numSubResources; i++)
_subResources.push_back(vm->loadResource(rlstStream, this));
}
-MystResourceType7::~MystResourceType7() {
+MystAreaActionSwitch::~MystAreaActionSwitch() {
for (uint32 i = 0; i < _subResources.size(); i++)
delete _subResources[i];
@@ -283,14 +286,14 @@ MystResourceType7::~MystResourceType7() {
// TODO: All these functions to switch subresource are very similar.
// Find way to share code (function pointer pass?)
-void MystResourceType7::drawDataToScreen() {
- if (_var7 == 0xFFFF) {
+void MystAreaActionSwitch::drawDataToScreen() {
+ if (_actionSwitchVar == 0xFFFF) {
if (_numSubResources == 1)
_subResources[0]->drawDataToScreen();
else if (_numSubResources != 0)
warning("Type 7 Resource with _numSubResources of %d, but no control variable", _numSubResources);
} else {
- uint16 varValue = _vm->_scriptParser->getVar(_var7);
+ uint16 varValue = _vm->_scriptParser->getVar(_actionSwitchVar);
if (_numSubResources == 1 && varValue != 0)
_subResources[0]->drawDataToScreen();
@@ -298,19 +301,19 @@ void MystResourceType7::drawDataToScreen() {
if (varValue < _numSubResources)
_subResources[varValue]->drawDataToScreen();
else
- warning("Type 7 Resource Var %d: %d exceeds number of sub resources %d", _var7, varValue, _numSubResources);
+ warning("Type 7 Resource Var %d: %d exceeds number of sub resources %d", _actionSwitchVar, varValue, _numSubResources);
}
}
}
-void MystResourceType7::handleCardChange() {
- if (_var7 == 0xFFFF) {
+void MystAreaActionSwitch::handleCardChange() {
+ if (_actionSwitchVar == 0xFFFF) {
if (_numSubResources == 1)
_subResources[0]->handleCardChange();
else if (_numSubResources != 0)
warning("Type 7 Resource with _numSubResources of %d, but no control variable", _numSubResources);
} else {
- uint16 varValue = _vm->_scriptParser->getVar(_var7);
+ uint16 varValue = _vm->_scriptParser->getVar(_actionSwitchVar);
if (_numSubResources == 1 && varValue != 0)
_subResources[0]->handleCardChange();
@@ -318,19 +321,19 @@ void MystResourceType7::handleCardChange() {
if (varValue < _numSubResources)
_subResources[varValue]->handleCardChange();
else
- warning("Type 7 Resource Var %d: %d exceeds number of sub resources %d", _var7, varValue, _numSubResources);
+ warning("Type 7 Resource Var %d: %d exceeds number of sub resources %d", _actionSwitchVar, varValue, _numSubResources);
}
}
}
-void MystResourceType7::handleMouseUp() {
- if (_var7 == 0xFFFF) {
+void MystAreaActionSwitch::handleMouseUp() {
+ if (_actionSwitchVar == 0xFFFF) {
if (_numSubResources == 1)
_subResources[0]->handleMouseUp();
else if (_numSubResources != 0)
warning("Type 7 Resource with _numSubResources of %d, but no control variable", _numSubResources);
} else {
- uint16 varValue = _vm->_scriptParser->getVar(_var7);
+ uint16 varValue = _vm->_scriptParser->getVar(_actionSwitchVar);
if (_numSubResources == 1 && varValue != 0)
_subResources[0]->handleMouseUp();
@@ -338,19 +341,19 @@ void MystResourceType7::handleMouseUp() {
if (varValue < _numSubResources)
_subResources[varValue]->handleMouseUp();
else
- warning("Type 7 Resource Var %d: %d exceeds number of sub resources %d", _var7, varValue, _numSubResources);
+ warning("Type 7 Resource Var %d: %d exceeds number of sub resources %d", _actionSwitchVar, varValue, _numSubResources);
}
}
}
-void MystResourceType7::handleMouseDown() {
- if (_var7 == 0xFFFF) {
+void MystAreaActionSwitch::handleMouseDown() {
+ if (_actionSwitchVar == 0xFFFF) {
if (_numSubResources == 1)
_subResources[0]->handleMouseDown();
else if (_numSubResources != 0)
warning("Type 7 Resource with _numSubResources of %d, but no control variable", _numSubResources);
} else {
- uint16 varValue = _vm->_scriptParser->getVar(_var7);
+ uint16 varValue = _vm->_scriptParser->getVar(_actionSwitchVar);
if (_numSubResources == 1 && varValue != 0)
_subResources[0]->handleMouseDown();
@@ -358,15 +361,16 @@ void MystResourceType7::handleMouseDown() {
if (varValue < _numSubResources)
_subResources[varValue]->handleMouseDown();
else
- warning("Type 7 Resource Var %d: %d exceeds number of sub resources %d", _var7, varValue, _numSubResources);
+ warning("Type 7 Resource Var %d: %d exceeds number of sub resources %d", _actionSwitchVar, varValue, _numSubResources);
}
}
}
-MystResourceType8::MystResourceType8(MohawkEngine_Myst *vm, Common::SeekableReadStream *rlstStream, MystResource *parent) : MystResourceType7(vm, rlstStream, parent) {
- _var8 = rlstStream->readUint16LE();
+MystAreaImageSwitch::MystAreaImageSwitch(MohawkEngine_Myst *vm, Common::SeekableReadStream *rlstStream, MystArea *parent) :
+ MystAreaActionSwitch(vm, rlstStream, parent) {
+ _imageSwitchVar = rlstStream->readUint16LE();
_numSubImages = rlstStream->readUint16LE();
- debugC(kDebugResource, "\tvar8: %d", _var8);
+ debugC(kDebugResource, "\tvar8: %d", _imageSwitchVar);
debugC(kDebugResource, "\tnumSubImages: %d", _numSubImages);
for (uint16 i = 0; i < _numSubImages; i++) {
@@ -399,25 +403,25 @@ MystResourceType8::MystResourceType8(MohawkEngine_Myst *vm, Common::SeekableRead
}
}
-MystResourceType8::~MystResourceType8() {
+MystAreaImageSwitch::~MystAreaImageSwitch() {
}
-void MystResourceType8::drawDataToScreen() {
+void MystAreaImageSwitch::drawDataToScreen() {
// Need to call overidden Type 7 function to ensure
// switch section is processed correctly.
- MystResourceType7::drawDataToScreen();
+ MystAreaActionSwitch::drawDataToScreen();
bool drawSubImage = false;
int16 subImageId = 0;
- if (_var8 == 0xFFFF) {
+ if (_imageSwitchVar == 0xFFFF) {
if (_numSubImages == 1) {
subImageId = 0;
drawSubImage = true;
} else if (_numSubImages != 0)
warning("Type 8 Resource with _numSubImages of %d, but no control variable", _numSubImages);
} else {
- uint16 varValue = _vm->_scriptParser->getVar(_var8);
+ uint16 varValue = _vm->_scriptParser->getVar(_imageSwitchVar);
if (_numSubImages == 1 && varValue != 0) {
subImageId = 0;
@@ -427,7 +431,7 @@ void MystResourceType8::drawDataToScreen() {
subImageId = varValue;
drawSubImage = true;
} else
- warning("Type 8 Image Var %d: %d exceeds number of subImages %d", _var8, varValue, _numSubImages);
+ warning("Type 8 Image Var %d: %d exceeds number of subImages %d", _imageSwitchVar, varValue, _numSubImages);
}
}
@@ -442,7 +446,7 @@ void MystResourceType8::drawDataToScreen() {
}
}
-void MystResourceType8::drawConditionalDataToScreen(uint16 state, bool update) {
+void MystAreaImageSwitch::drawConditionalDataToScreen(uint16 state, bool update) {
bool drawSubImage = false;
int16 subImageId = 0;
@@ -455,7 +459,7 @@ void MystResourceType8::drawConditionalDataToScreen(uint16 state, bool update) {
subImageId = state;
drawSubImage = true;
} else
- warning("Type 8 Image Var %d: %d exceeds number of subImages %d", _var8, state, _numSubImages);
+ warning("Type 8 Image Var %d: %d exceeds number of subImages %d", _imageSwitchVar, state, _numSubImages);
}
@@ -476,21 +480,21 @@ void MystResourceType8::drawConditionalDataToScreen(uint16 state, bool update) {
}
}
-uint16 MystResourceType8::getType8Var() {
- return _var8;
+uint16 MystAreaImageSwitch::getImageSwitchVar() {
+ return _imageSwitchVar;
}
-MystResourceType8::SubImage MystResourceType8::getSubImage(uint index) const {
+MystAreaImageSwitch::SubImage MystAreaImageSwitch::getSubImage(uint index) const {
return _subImages[index];
}
-void MystResourceType8::setSubImageRect(uint index, const Common::Rect &rect) {
+void MystAreaImageSwitch::setSubImageRect(uint index, const Common::Rect &rect) {
_subImages[index].rect = rect;
}
-const Common::String MystResourceType8::describe() {
+const Common::String MystAreaImageSwitch::describe() {
Common::String desc = Common::String::format("%s var: %2d",
- MystResourceType7::describe().c_str(), _var8);
+ MystAreaActionSwitch::describe().c_str(), _imageSwitchVar);
if (_numSubImages > 0) {
desc += " subImgs:";
@@ -504,7 +508,8 @@ const Common::String MystResourceType8::describe() {
// No MystResourceType9!
-MystResourceType10::MystResourceType10(MohawkEngine_Myst *vm, Common::SeekableReadStream *rlstStream, MystResource *parent) : MystResourceType11(vm, rlstStream, parent) {
+MystAreaSlider::MystAreaSlider(MohawkEngine_Myst *vm, Common::SeekableReadStream *rlstStream, MystArea *parent) :
+ MystAreaDrag(vm, rlstStream, parent) {
_dragSound = rlstStream->readUint16LE();
debugC(kDebugResource, "\tdrag sound : %d", _dragSound);
@@ -513,23 +518,23 @@ MystResourceType10::MystResourceType10(MohawkEngine_Myst *vm, Common::SeekableRe
_sliderHeight = _rect.bottom - _rect.top;
}
-MystResourceType10::~MystResourceType10() {
+MystAreaSlider::~MystAreaSlider() {
}
-void MystResourceType10::setStep(uint16 step) {
+void MystAreaSlider::setStep(uint16 step) {
_rect.top = _minV + _stepV * step - _sliderHeight / 2;
_rect.bottom = _rect.top + _sliderHeight;
_subImages[0].rect.top = 333 - _rect.bottom - 1;
_subImages[0].rect.bottom = 333 - _rect.top - 1;
}
-void MystResourceType10::setPosition(uint16 pos) {
+void MystAreaSlider::setPosition(uint16 pos) {
Common::Point mouse;
mouse.y = pos;
updatePosition(mouse);
}
-Common::Rect MystResourceType10::boundingBox() {
+Common::Rect MystAreaSlider::boundingBox() {
Common::Rect bb;
bb.top = _rect.top;
@@ -552,7 +557,7 @@ Common::Rect MystResourceType10::boundingBox() {
return bb;
}
-void MystResourceType10::restoreBackground() {
+void MystAreaSlider::restoreBackground() {
// Restore background
Common::Rect src = boundingBox();
Common::Rect dest = boundingBox();
@@ -561,11 +566,11 @@ void MystResourceType10::restoreBackground() {
_vm->_gfx->copyImageSectionToScreen(_vm->getCardBackgroundId(), src, dest);
}
-void MystResourceType10::handleMouseDown() {
+void MystAreaSlider::handleMouseDown() {
const Common::Point &mouse = _vm->_system->getEventManager()->getMousePos();
updatePosition(mouse);
- MystResourceType11::handleMouseDown();
+ MystAreaDrag::handleMouseDown();
// Restore background
restoreBackground();
@@ -574,7 +579,7 @@ void MystResourceType10::handleMouseDown() {
drawConditionalDataToScreen(2);
}
-void MystResourceType10::handleMouseUp() {
+void MystAreaSlider::handleMouseUp() {
const Common::Point &mouse = _vm->_system->getEventManager()->getMousePos();
updatePosition(mouse);
@@ -598,16 +603,16 @@ void MystResourceType10::handleMouseUp() {
value = _pos.x;
}
- _vm->_scriptParser->setVarValue(_var8, value);
+ _vm->_scriptParser->setVarValue(_imageSwitchVar, value);
- MystResourceType11::handleMouseUp();
+ MystAreaDrag::handleMouseUp();
}
-void MystResourceType10::handleMouseDrag() {
+void MystAreaSlider::handleMouseDrag() {
const Common::Point &mouse = _vm->_system->getEventManager()->getMousePos();
updatePosition(mouse);
- MystResourceType11::handleMouseDrag();
+ MystAreaDrag::handleMouseDrag();
// Restore background
restoreBackground();
@@ -616,7 +621,7 @@ void MystResourceType10::handleMouseDrag() {
drawConditionalDataToScreen(2);
}
-void MystResourceType10::updatePosition(const Common::Point &mouse) {
+void MystAreaSlider::updatePosition(const Common::Point &mouse) {
bool positionChanged = false;
Common::Point mouseClipped;
@@ -669,7 +674,8 @@ void MystResourceType10::updatePosition(const Common::Point &mouse) {
_vm->_sound->replaceSoundMyst(_dragSound);
}
-MystResourceType11::MystResourceType11(MohawkEngine_Myst *vm, Common::SeekableReadStream *rlstStream, MystResource *parent) : MystResourceType8(vm, rlstStream, parent) {
+MystAreaDrag::MystAreaDrag(MohawkEngine_Myst *vm, Common::SeekableReadStream *rlstStream, MystArea *parent) :
+ MystAreaImageSwitch(vm, rlstStream, parent) {
_flagHV = rlstStream->readUint16LE();
_minH = rlstStream->readUint16LE();
_maxH = rlstStream->readUint16LE();
@@ -719,44 +725,44 @@ MystResourceType11::MystResourceType11(MohawkEngine_Myst *vm, Common::SeekableRe
_stepV = (_maxV - _minV) / (_stepsV - 1);
}
-MystResourceType11::~MystResourceType11() {
+MystAreaDrag::~MystAreaDrag() {
for (byte i = 0; i < 3; i++)
delete[] _lists[i].list;
}
-void MystResourceType11::handleMouseDown() {
+void MystAreaDrag::handleMouseDown() {
const Common::Point &mouse = _vm->_system->getEventManager()->getMousePos();
setPositionClipping(mouse, _pos);
_vm->_scriptParser->setInvokingResource(this);
- _vm->_scriptParser->runOpcode(_mouseDownOpcode, _var8);
+ _vm->_scriptParser->runOpcode(_mouseDownOpcode, _imageSwitchVar);
}
-void MystResourceType11::handleMouseUp() {
+void MystAreaDrag::handleMouseUp() {
const Common::Point &mouse = _vm->_system->getEventManager()->getMousePos();
setPositionClipping(mouse, _pos);
_vm->_scriptParser->setInvokingResource(this);
- _vm->_scriptParser->runOpcode(_mouseUpOpcode, _var8);
+ _vm->_scriptParser->runOpcode(_mouseUpOpcode, _imageSwitchVar);
}
-void MystResourceType11::handleMouseDrag() {
+void MystAreaDrag::handleMouseDrag() {
const Common::Point &mouse = _vm->_system->getEventManager()->getMousePos();
setPositionClipping(mouse, _pos);
_vm->_scriptParser->setInvokingResource(this);
- _vm->_scriptParser->runOpcode(_mouseDragOpcode, _var8);
+ _vm->_scriptParser->runOpcode(_mouseDragOpcode, _imageSwitchVar);
}
-const Common::String MystResourceType11::describe() {
+const Common::String MystAreaDrag::describe() {
return Common::String::format("%s down: %s drag: %s up: %s",
- MystResourceType8::describe().c_str(),
+ MystAreaImageSwitch::describe().c_str(),
_vm->_scriptParser->getOpcodeDesc(_mouseDownOpcode).c_str(),
_vm->_scriptParser->getOpcodeDesc(_mouseDragOpcode).c_str(),
_vm->_scriptParser->getOpcodeDesc(_mouseUpOpcode).c_str());
}
-void MystResourceType11::setPositionClipping(const Common::Point &mouse, Common::Point &dest) {
+void MystAreaDrag::setPositionClipping(const Common::Point &mouse, Common::Point &dest) {
if (_flagHV & 2)
dest.y = CLIP<uint16>(mouse.y, _minV, _maxV);
@@ -764,19 +770,20 @@ void MystResourceType11::setPositionClipping(const Common::Point &mouse, Common:
dest.x = CLIP<uint16>(mouse.x, _minH, _maxH);
}
-uint16 MystResourceType11::getList1(uint16 index) {
+uint16 MystAreaDrag::getList1(uint16 index) {
return (index < _lists[0].listCount) ? _lists[0].list[index] : 0;
}
-uint16 MystResourceType11::getList2(uint16 index) {
+uint16 MystAreaDrag::getList2(uint16 index) {
return (index < _lists[1].listCount) ? _lists[1].list[index] : 0;
}
-uint16 MystResourceType11::getList3(uint16 index) {
+uint16 MystAreaDrag::getList3(uint16 index) {
return (index < _lists[2].listCount) ? _lists[2].list[index] : 0;
}
-MystResourceType12::MystResourceType12(MohawkEngine_Myst *vm, Common::SeekableReadStream *rlstStream, MystResource *parent) : MystResourceType11(vm, rlstStream, parent) {
+MystVideoInfo::MystVideoInfo(MohawkEngine_Myst *vm, Common::SeekableReadStream *rlstStream, MystArea *parent) :
+ MystAreaDrag(vm, rlstStream, parent) {
_numFrames = rlstStream->readUint16LE();
_firstFrame = rlstStream->readUint16LE();
uint16 frameWidth = rlstStream->readUint16LE();
@@ -797,16 +804,16 @@ MystResourceType12::MystResourceType12(MohawkEngine_Myst *vm, Common::SeekableRe
debugC(kDebugResource, "\t_frameRect.bottom: %d", _frameRect.bottom);
}
-MystResourceType12::~MystResourceType12() {
+MystVideoInfo::~MystVideoInfo() {
}
-void MystResourceType12::drawFrame(uint16 frame) {
+void MystVideoInfo::drawFrame(uint16 frame) {
_currentFrame = _firstFrame + frame;
_vm->_gfx->copyImageToScreen(_currentFrame, _frameRect);
_vm->_system->updateScreen();
}
-bool MystResourceType12::pullLeverV() {
+bool MystVideoInfo::pullLeverV() {
const Common::Point &mouse = _vm->_system->getEventManager()->getMousePos();
// Make the handle follow the mouse
@@ -822,7 +829,7 @@ bool MystResourceType12::pullLeverV() {
return step == maxStep;
}
-void MystResourceType12::releaseLeverV() {
+void MystVideoInfo::releaseLeverV() {
const Common::Point &mouse = _vm->_system->getEventManager()->getMousePos();
// Get current lever frame
@@ -838,7 +845,8 @@ void MystResourceType12::releaseLeverV() {
}
}
-MystResourceType13::MystResourceType13(MohawkEngine_Myst *vm, Common::SeekableReadStream *rlstStream, MystResource *parent) : MystResource(vm, rlstStream, parent) {
+MystAreaHover::MystAreaHover(MohawkEngine_Myst *vm, Common::SeekableReadStream *rlstStream, MystArea *parent) :
+ MystArea(vm, rlstStream, parent) {
_enterOpcode = rlstStream->readUint16LE();
_leaveOpcode = rlstStream->readUint16LE();
@@ -846,27 +854,27 @@ MystResourceType13::MystResourceType13(MohawkEngine_Myst *vm, Common::SeekableRe
debugC(kDebugResource, "\t_leaveOpcode: %d", _leaveOpcode);
}
-void MystResourceType13::handleMouseEnter() {
+void MystAreaHover::handleMouseEnter() {
// Pass along the enter opcode to the script parser
// The variable to use is stored in the dest field
_vm->_scriptParser->runOpcode(_enterOpcode, _dest);
}
-void MystResourceType13::handleMouseLeave() {
+void MystAreaHover::handleMouseLeave() {
// Pass along the leave opcode (with no parameters) to the script parser
// The variable to use is stored in the dest field
_vm->_scriptParser->runOpcode(_leaveOpcode, _dest);
}
-void MystResourceType13::handleMouseUp() {
+void MystAreaHover::handleMouseUp() {
// Type 13 Resources do nothing on Mouse Clicks.
// This is required to override the inherited default
- // i.e. MystResource::handleMouseUp
+ // i.e. MystArea::handleMouseUp
}
-const Common::String MystResourceType13::describe() {
+const Common::String MystAreaHover::describe() {
return Common::String::format("%s enter: %s leave: %s",
- MystResource::describe().c_str(),
+ MystArea::describe().c_str(),
_vm->_scriptParser->getOpcodeDesc(_enterOpcode).c_str(),
_vm->_scriptParser->getOpcodeDesc(_leaveOpcode).c_str());
}
diff --git a/engines/mohawk/myst_areas.h b/engines/mohawk/myst_areas.h
index 881edf2..2b16b6e 100644
--- a/engines/mohawk/myst_areas.h
+++ b/engines/mohawk/myst_areas.h
@@ -32,19 +32,19 @@ namespace Mohawk {
// Myst Resource Types
enum ResourceType {
- kMystForwardArea = 0,
- kMystLeftArea = 1,
- kMystRightArea = 2,
- kMystDownArea = 3,
- kMystUpArea = 4,
- kMystAction = 5,
- kMystVideo = 6,
- kMystSwitch = 7,
- kMystConditionalImage = 8,
- kMystSlider = 10,
- kMystDragArea = 11,
+ kMystAreaForward = 0,
+ kMystAreaLeft = 1,
+ kMystAreaRight = 2,
+ kMystAreaDown = 3,
+ kMystAreaUp = 4,
+ kMystAreaAction = 5,
+ kMystAreaVideo = 6,
+ kMystAreaActionSwitch = 7,
+ kMystAreaImageSwitch = 8,
+ kMystAreaSlider = 10,
+ kMystAreaDrag = 11,
kMystVideoInfo = 12,
- kMystHoverArea = 13
+ kMystAreaHover = 13
};
// Myst Resource Flags
@@ -56,16 +56,14 @@ enum {
kMystZipModeEnableFlag = (1 << 3)
};
-class MystResource {
+class MystArea {
public:
- MystResource(MohawkEngine_Myst *vm, Common::SeekableReadStream *rlstStream, MystResource *parent);
- virtual ~MystResource();
+ MystArea(MohawkEngine_Myst *vm, Common::SeekableReadStream *rlstStream, MystArea *parent);
+ virtual ~MystArea();
+
virtual const Common::String describe();
void drawBoundingRect();
- MystResource *_parent;
- ResourceType type;
-
bool contains(Common::Point point) { return _rect.contains(point); }
virtual void drawDataToScreen() {}
virtual void handleCardChange() {}
@@ -75,7 +73,7 @@ public:
void setEnabled(bool enabled);
bool isDrawSubimages() { return _flags & kMystSubimageEnableFlag; }
uint16 getDest() { return _dest; }
- virtual uint16 getType8Var() { return 0xFFFF; }
+ virtual uint16 getImageSwitchVar() { return 0xFFFF; }
bool unreachableZipDest();
bool canBecomeActive();
@@ -84,6 +82,8 @@ public:
virtual void handleMouseDown() {}
virtual void handleMouseDrag() {}
+ MystArea *_parent;
+ ResourceType type;
protected:
MohawkEngine_Myst *_vm;
@@ -92,9 +92,10 @@ protected:
uint16 _dest;
};
-class MystResourceType5 : public MystResource {
+class MystAreaAction : public MystArea {
public:
- MystResourceType5(MohawkEngine_Myst *vm, Common::SeekableReadStream *rlstStream, MystResource *parent);
+ MystAreaAction(MohawkEngine_Myst *vm, Common::SeekableReadStream *rlstStream, MystArea *parent);
+
void handleMouseUp() override;
const Common::String describe() override;
@@ -102,9 +103,10 @@ protected:
MystScript _script;
};
-class MystResourceType6 : public MystResourceType5 {
+class MystAreaVideo : public MystAreaAction {
public:
- MystResourceType6(MohawkEngine_Myst *vm, Common::SeekableReadStream *rlstStream, MystResource *parent);
+ MystAreaVideo(MohawkEngine_Myst *vm, Common::SeekableReadStream *rlstStream, MystArea *parent);
+
VideoHandle playMovie();
void handleCardChange() override;
bool isPlaying();
@@ -114,6 +116,7 @@ public:
protected:
static Common::String convertMystVideoName(Common::String name);
+
Common::String _videoFile;
int16 _left;
int16 _top;
@@ -124,10 +127,10 @@ protected:
uint16 _u3;
};
-class MystResourceType7 : public MystResource {
+class MystAreaActionSwitch : public MystArea {
public:
- MystResourceType7(MohawkEngine_Myst *vm, Common::SeekableReadStream *rlstStream, MystResource *parent);
- virtual ~MystResourceType7();
+ MystAreaActionSwitch(MohawkEngine_Myst *vm, Common::SeekableReadStream *rlstStream, MystArea *parent);
+ virtual ~MystAreaActionSwitch();
virtual void drawDataToScreen() override;
virtual void handleCardChange() override;
@@ -135,17 +138,17 @@ public:
virtual void handleMouseUp() override;
virtual void handleMouseDown() override;
- MystResource *getSubResource(uint16 index) { return _subResources[index]; }
+ MystArea *getSubResource(uint16 index) { return _subResources[index]; }
protected:
- uint16 _var7;
+ uint16 _actionSwitchVar;
uint16 _numSubResources;
- Common::Array<MystResource *> _subResources;
+ Common::Array<MystArea *> _subResources;
};
-class MystResourceType8 : public MystResourceType7 {
+class MystAreaImageSwitch : public MystAreaActionSwitch {
public:
- MystResourceType8(MohawkEngine_Myst *vm, Common::SeekableReadStream *rlstStream, MystResource *parent);
- virtual ~MystResourceType8();
+ MystAreaImageSwitch(MohawkEngine_Myst *vm, Common::SeekableReadStream *rlstStream, MystArea *parent);
+ virtual ~MystAreaImageSwitch();
struct SubImage {
uint16 wdib;
@@ -155,23 +158,22 @@ public:
virtual const Common::String describe() override;
virtual void drawDataToScreen() override;
void drawConditionalDataToScreen(uint16 state, bool update = true);
- uint16 getType8Var() override;
+ uint16 getImageSwitchVar() override;
SubImage getSubImage(uint index) const;
void setSubImageRect(uint index, const Common::Rect &rect);
protected:
- uint16 _var8;
+ uint16 _imageSwitchVar;
uint16 _numSubImages;
Common::Array<SubImage> _subImages;
};
-// No MystResourceType9!
-
-class MystResourceType11 : public MystResourceType8 {
+class MystAreaDrag : public MystAreaImageSwitch {
public:
- MystResourceType11(MohawkEngine_Myst *vm, Common::SeekableReadStream *rlstStream, MystResource *parent);
- virtual ~MystResourceType11();
+ MystAreaDrag(MohawkEngine_Myst *vm, Common::SeekableReadStream *rlstStream, MystArea *parent);
+ virtual ~MystAreaDrag();
+
const Common::String describe() override;
virtual void handleMouseDown() override;
@@ -187,6 +189,11 @@ public:
Common::Point _pos;
protected:
+ struct ValueList {
+ uint16 listCount;
+ uint16 *list;
+ };
+
void setPositionClipping(const Common::Point &mouse, Common::Point &dest);
uint16 _flagHV;
@@ -201,17 +208,13 @@ protected:
uint16 _mouseDownOpcode;
uint16 _mouseDragOpcode;
uint16 _mouseUpOpcode;
- struct {
- uint16 listCount;
- uint16 *list;
- } _lists[3];
-
+ ValueList _lists[3];
};
-class MystResourceType10 : public MystResourceType11 {
+class MystAreaSlider : public MystAreaDrag {
public:
- MystResourceType10(MohawkEngine_Myst *vm, Common::SeekableReadStream *rlstStream, MystResource *parent);
- virtual ~MystResourceType10();
+ MystAreaSlider(MohawkEngine_Myst *vm, Common::SeekableReadStream *rlstStream, MystArea *parent);
+ virtual ~MystAreaSlider();
void handleMouseDown() override;
void handleMouseUp() override;
@@ -229,10 +232,11 @@ protected:
uint16 _sliderHeight;
};
-class MystResourceType12 : public MystResourceType11 {
+class MystVideoInfo : public MystAreaDrag {
public:
- MystResourceType12(MohawkEngine_Myst *vm, Common::SeekableReadStream *rlstStream, MystResource *parent);
- virtual ~MystResourceType12();
+ MystVideoInfo(MohawkEngine_Myst *vm, Common::SeekableReadStream *rlstStream, MystArea *parent);
+ virtual ~MystVideoInfo();
+
void drawFrame(uint16 frame);
bool pullLeverV();
void releaseLeverV();
@@ -247,9 +251,10 @@ private:
uint16 _currentFrame;
};
-class MystResourceType13 : public MystResource {
+class MystAreaHover : public MystArea {
public:
- MystResourceType13(MohawkEngine_Myst *vm, Common::SeekableReadStream *rlstStream, MystResource *parent);
+ MystAreaHover(MohawkEngine_Myst *vm, Common::SeekableReadStream *rlstStream, MystArea *parent);
+
const Common::String describe() override;
void handleMouseUp() override;
diff --git a/engines/mohawk/myst_scripts.cpp b/engines/mohawk/myst_scripts.cpp
index 14a95ee..aee9372 100644
--- a/engines/mohawk/myst_scripts.cpp
+++ b/engines/mohawk/myst_scripts.cpp
@@ -154,7 +154,7 @@ void MystScriptParser::setupCommonOpcodes() {
#undef OPCODE
-void MystScriptParser::runScript(MystScript script, MystResource *invokingResource) {
+void MystScriptParser::runScript(MystScript script, MystArea *invokingResource) {
debugC(kDebugScript, "Script Size: %d", script->size());
// Scripted drawing takes more time to simulate older hardware
@@ -442,7 +442,7 @@ void MystScriptParser::o_triggerMovie(uint16 op, uint16 var, uint16 argc, uint16
debugC(kDebugScript, "\tDirection: %d", direction);
// Trigger resource 6 movie overriding play direction
- MystResourceType6 *resource = static_cast<MystResourceType6 *>(_invokingResource);
+ MystAreaVideo *resource = static_cast<MystAreaVideo *>(_invokingResource);
resource->setDirection(direction);
resource->playMovie();
@@ -459,7 +459,7 @@ void MystScriptParser::o_drawAreaState(uint16 op, uint16 var, uint16 argc, uint1
debugC(kDebugScript, "Opcode %d: drawAreaState, state: %d", op, argv[0]);
debugC(kDebugScript, "\tVar: %d", var);
- MystResourceType8 *parent = static_cast<MystResourceType8 *>(_invokingResource->_parent);
+ MystAreaImageSwitch *parent = static_cast<MystAreaImageSwitch *>(_invokingResource->_parent);
parent->drawConditionalDataToScreen(argv[0]);
}
@@ -522,7 +522,7 @@ void MystScriptParser::o_enableAreas(uint16 op, uint16 var, uint16 argc, uint16
for (uint16 i = 0; i < count; i++) {
debugC(kDebugScript, "Enable hotspot index %d", argv[i + 1]);
- MystResource *resource = nullptr;
+ MystArea *resource = nullptr;
if (argv[i + 1] == 0xFFFF)
resource = _invokingResource;
else
@@ -547,7 +547,7 @@ void MystScriptParser::o_disableAreas(uint16 op, uint16 var, uint16 argc, uint16
for (uint16 i = 0; i < count; i++) {
debugC(kDebugScript, "Disable hotspot index %d", argv[i + 1]);
- MystResource *resource = nullptr;
+ MystArea *resource = nullptr;
if (argv[i + 1] == 0xFFFF)
resource = _invokingResource;
else
@@ -578,7 +578,7 @@ void MystScriptParser::o_toggleAreasActivation(uint16 op, uint16 var, uint16 arg
for (uint16 i = 0; i < count; i++) {
debugC(kDebugScript, "Enable/Disable hotspot index %d", argv[i + 1]);
- MystResource *resource = nullptr;
+ MystArea *resource = nullptr;
if (argv[i + 1] == 0xFFFF)
resource = _invokingResource;
else
diff --git a/engines/mohawk/myst_scripts.h b/engines/mohawk/myst_scripts.h
index 3cf5c2d..835bb7c 100644
--- a/engines/mohawk/myst_scripts.h
+++ b/engines/mohawk/myst_scripts.h
@@ -34,7 +34,7 @@ namespace Mohawk {
#define DECLARE_OPCODE(x) void x(uint16 op, uint16 var, uint16 argc, uint16 *argv)
class MohawkEngine_Myst;
-class MystResource;
+class MystArea;
enum MystScriptType {
kMystScriptNone,
@@ -63,11 +63,11 @@ public:
MystScriptParser(MohawkEngine_Myst *vm);
virtual ~MystScriptParser();
- void runScript(MystScript script, MystResource *invokingResource = nullptr);
+ void runScript(MystScript script, MystArea *invokingResource = nullptr);
void runOpcode(uint16 op, uint16 var = 0, uint16 argc = 0, uint16 *argv = nullptr);
const Common::String getOpcodeDesc(uint16 op);
MystScript readScript(Common::SeekableReadStream *stream, MystScriptType type);
- void setInvokingResource(MystResource *resource) { _invokingResource = resource; }
+ void setInvokingResource(MystArea *resource) { _invokingResource = resource; }
virtual void disablePersistentScripts() = 0;
virtual void runPersistentScripts() = 0;
@@ -151,7 +151,7 @@ protected:
Common::Array<MystOpcode *> _opcodes;
- MystResource *_invokingResource;
+ MystArea *_invokingResource;
uint16 _savedCardId;
uint16 _savedMapCardId;
diff --git a/engines/mohawk/myst_stacks/channelwood.cpp b/engines/mohawk/myst_stacks/channelwood.cpp
index 0718f8e..7b38e37 100644
--- a/engines/mohawk/myst_stacks/channelwood.cpp
+++ b/engines/mohawk/myst_stacks/channelwood.cpp
@@ -377,7 +377,7 @@ void Channelwood::o_waterTankValveOpen(uint16 op, uint16 var, uint16 argc, uint1
void Channelwood::o_leverStartMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Generic lever start move", op);
- MystResourceType12 *lever = static_cast<MystResourceType12 *>(_invokingResource);
+ MystVideoInfo *lever = static_cast<MystVideoInfo *>(_invokingResource);
lever->drawFrame(0);
_vm->_cursor->setCursor(700);
_leverPulled = false;
@@ -386,7 +386,7 @@ void Channelwood::o_leverStartMove(uint16 op, uint16 var, uint16 argc, uint16 *a
void Channelwood::o_leverMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Generic lever move", op);
- MystResourceType12 *lever = static_cast<MystResourceType12 *>(_invokingResource);
+ MystVideoInfo *lever = static_cast<MystVideoInfo *>(_invokingResource);
if (lever->pullLeverV()) {
if (!_leverPulled) {
@@ -401,7 +401,7 @@ void Channelwood::o_leverMove(uint16 op, uint16 var, uint16 argc, uint16 *argv)
void Channelwood::o_leverMoveFail(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Generic lever move", op);
- MystResourceType12 *lever = static_cast<MystResourceType12 *>(_invokingResource);
+ MystVideoInfo *lever = static_cast<MystVideoInfo *>(_invokingResource);
if (lever->pullLeverV()) {
if (!_leverPulled) {
@@ -419,7 +419,7 @@ void Channelwood::o_leverEndMove(uint16 op, uint16 var, uint16 argc, uint16 *arg
debugC(kDebugScript, "Opcode %d: Generic lever end move", op);
// Get current lever frame
- MystResourceType12 *lever = static_cast<MystResourceType12 *>(_invokingResource);
+ MystVideoInfo *lever = static_cast<MystVideoInfo *>(_invokingResource);
// Release lever
lever->releaseLeverV();
@@ -439,7 +439,7 @@ void Channelwood::o_leverEndMoveResumeBackground(uint16 op, uint16 var, uint16 a
void Channelwood::o_leverEndMoveWithSound(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
o_leverEndMove(op, var, argc, argv);
- MystResourceType12 *lever = static_cast<MystResourceType12 *>(_invokingResource);
+ MystVideoInfo *lever = static_cast<MystVideoInfo *>(_invokingResource);
uint16 soundId = lever->getList3(0);
if (soundId)
_vm->_sound->replaceSoundMyst(soundId);
@@ -461,7 +461,7 @@ void Channelwood::o_leverElev3EndMove(uint16 op, uint16 var, uint16 argc, uint16
void Channelwood::o_pumpLeverMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Pump lever move", op);
- MystResourceType12 *lever = static_cast<MystResourceType12 *>(_invokingResource);
+ MystVideoInfo *lever = static_cast<MystVideoInfo *>(_invokingResource);
if (lever->pullLeverV()) {
uint16 soundId = lever->getList2(0);
@@ -475,7 +475,7 @@ void Channelwood::o_pumpLeverMove(uint16 op, uint16 var, uint16 argc, uint16 *ar
void Channelwood::o_pumpLeverEndMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
o_leverEndMove(op, var, argc, argv);
- MystResourceType12 *lever = static_cast<MystResourceType12 *>(_invokingResource);
+ MystVideoInfo *lever = static_cast<MystVideoInfo *>(_invokingResource);
uint16 soundId = lever->getList3(0);
if (soundId)
_vm->_sound->replaceBackgroundMyst(soundId, 36864);
@@ -484,7 +484,7 @@ void Channelwood::o_pumpLeverEndMove(uint16 op, uint16 var, uint16 argc, uint16
void Channelwood::o_stairsDoorToggle(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Play stairs door video", op);
- MystResourceType6 *movie = static_cast<MystResourceType6 *>(_invokingResource);
+ MystAreaVideo *movie = static_cast<MystAreaVideo *>(_invokingResource);
if (_state.stairsUpperDoorState) {
// Close door, play the open movie backwards
@@ -500,7 +500,7 @@ void Channelwood::o_stairsDoorToggle(uint16 op, uint16 var, uint16 argc, uint16
void Channelwood::o_valveHandleMove1(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Valve handle move", op);
- MystResourceType12 *handle = static_cast<MystResourceType12 *>(_invokingResource);
+ MystVideoInfo *handle = static_cast<MystVideoInfo *>(_invokingResource);
const Common::Point &mouse = _vm->_system->getEventManager()->getMousePos();
if (handle->getRect().contains(mouse)) {
@@ -516,7 +516,7 @@ void Channelwood::o_valveHandleMove1(uint16 op, uint16 var, uint16 argc, uint16
void Channelwood::o_valveHandleMoveStart1(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Valve handle move start", op);
- MystResourceType12 *handle = static_cast<MystResourceType12 *>(_invokingResource);
+ MystVideoInfo *handle = static_cast<MystVideoInfo *>(_invokingResource);
uint16 soundId = handle->getList1(0);
if (soundId)
_vm->_sound->replaceSoundMyst(soundId);
@@ -528,7 +528,7 @@ void Channelwood::o_valveHandleMoveStart1(uint16 op, uint16 var, uint16 argc, ui
void Channelwood::o_valveHandleMoveStop(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Valve handle move stop", op);
- MystResourceType12 *handle = static_cast<MystResourceType12 *>(_invokingResource);
+ MystVideoInfo *handle = static_cast<MystVideoInfo *>(_invokingResource);
// Update state with valve position
if (_tempVar <= 5)
@@ -551,7 +551,7 @@ void Channelwood::o_valveHandleMoveStop(uint16 op, uint16 var, uint16 argc, uint
void Channelwood::o_valveHandleMove2(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Valve handle move", op);
- MystResourceType12 *handle = static_cast<MystResourceType12 *>(_invokingResource);
+ MystVideoInfo *handle = static_cast<MystVideoInfo *>(_invokingResource);
const Common::Point &mouse = _vm->_system->getEventManager()->getMousePos();
if (handle->getRect().contains(mouse)) {
@@ -567,7 +567,7 @@ void Channelwood::o_valveHandleMove2(uint16 op, uint16 var, uint16 argc, uint16
void Channelwood::o_valveHandleMoveStart2(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Valve handle move start", op);
- MystResourceType12 *handle = static_cast<MystResourceType12 *>(_invokingResource);
+ MystVideoInfo *handle = static_cast<MystVideoInfo *>(_invokingResource);
uint16 soundId = handle->getList1(0);
if (soundId)
_vm->_sound->replaceSoundMyst(soundId);
@@ -579,7 +579,7 @@ void Channelwood::o_valveHandleMoveStart2(uint16 op, uint16 var, uint16 argc, ui
void Channelwood::o_valveHandleMove3(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Valve handle move", op);
- MystResourceType12 *handle = static_cast<MystResourceType12 *>(_invokingResource);
+ MystVideoInfo *handle = static_cast<MystVideoInfo *>(_invokingResource);
const Common::Point &mouse = _vm->_system->getEventManager()->getMousePos();
if (handle->getRect().contains(mouse)) {
@@ -595,7 +595,7 @@ void Channelwood::o_valveHandleMove3(uint16 op, uint16 var, uint16 argc, uint16
void Channelwood::o_valveHandleMoveStart3(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Valve handle move start", op);
- MystResourceType12 *handle = static_cast<MystResourceType12 *>(_invokingResource);
+ MystVideoInfo *handle = static_cast<MystVideoInfo *>(_invokingResource);
uint16 soundId = handle->getList1(0);
if (soundId)
_vm->_sound->replaceSoundMyst(soundId);
@@ -680,7 +680,7 @@ void Channelwood::o_hologramTemple(uint16 op, uint16 var, uint16 argc, uint16 *a
void Channelwood::o_executeMouseUp(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Execute mouse up", op);
- MystResourceType5 *resource = static_cast<MystResourceType5 *>(_vm->_resources[argv[0]]);
+ MystAreaAction *resource = static_cast<MystAreaAction *>(_vm->_resources[argv[0]]);
resource->handleMouseUp();
}
@@ -753,7 +753,7 @@ void Channelwood::o_soundReplace(uint16 op, uint16 var, uint16 argc, uint16 *arg
void Channelwood::o_lever_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Generic lever init", op);
- _leverAction = static_cast<MystResourceType5 *>(_invokingResource);
+ _leverAction = static_cast<MystAreaAction *>(_invokingResource);
}
void Channelwood::o_pipeValve_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
diff --git a/engines/mohawk/myst_stacks/channelwood.h b/engines/mohawk/myst_stacks/channelwood.h
index 719257f..c141a62 100644
--- a/engines/mohawk/myst_stacks/channelwood.h
+++ b/engines/mohawk/myst_stacks/channelwood.h
@@ -94,7 +94,7 @@ private:
uint16 _doorOpened; // 68
bool _leverPulled;
- MystResourceType5 *_leverAction; // 72
+ MystAreaAction *_leverAction; // 72
bool pipeChangeValve(bool open, uint16 mask);
};
diff --git a/engines/mohawk/myst_stacks/intro.cpp b/engines/mohawk/myst_stacks/intro.cpp
index dc66984..a139ca2 100644
--- a/engines/mohawk/myst_stacks/intro.cpp
+++ b/engines/mohawk/myst_stacks/intro.cpp
@@ -170,7 +170,7 @@ void Intro::mystLinkBook_run() {
void Intro::o_mystLinkBook_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Myst link book init", op);
- _linkBookMovie = static_cast<MystResourceType6 *>(_invokingResource);
+ _linkBookMovie = static_cast<MystAreaVideo *>(_invokingResource);
_startTime = 1;
_linkBookRunning = true;
}
diff --git a/engines/mohawk/myst_stacks/intro.h b/engines/mohawk/myst_stacks/intro.h
index acff03e..0095706 100644
--- a/engines/mohawk/myst_stacks/intro.h
+++ b/engines/mohawk/myst_stacks/intro.h
@@ -29,7 +29,7 @@
namespace Mohawk {
-class MystResourceType6;
+class MystAreaVideo;
struct MystScriptEntry;
namespace MystStacks {
@@ -60,7 +60,7 @@ private:
uint16 _introStep;
bool _linkBookRunning;
- MystResourceType6 *_linkBookMovie;
+ MystAreaVideo *_linkBookMovie;
};
} // End of namespace MystStacks
diff --git a/engines/mohawk/myst_stacks/mechanical.cpp b/engines/mohawk/myst_stacks/mechanical.cpp
index ffcaa22..3f1fbf9 100644
--- a/engines/mohawk/myst_stacks/mechanical.cpp
+++ b/engines/mohawk/myst_stacks/mechanical.cpp
@@ -277,7 +277,7 @@ void Mechanical::o_throneEnablePassage(uint16 op, uint16 var, uint16 argc, uint1
void Mechanical::o_birdCrankStart(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Mechanical bird crank start", op);
- MystResourceType11 *crank = static_cast<MystResourceType11 *>(_invokingResource);
+ MystAreaDrag *crank = static_cast<MystAreaDrag *>(_invokingResource);
uint16 crankSoundId = crank->getList2(0);
_vm->_sound->replaceSoundMyst(crankSoundId, Audio::Mixer::kMaxChannelVolume, true);
@@ -285,16 +285,16 @@ void Mechanical::o_birdCrankStart(uint16 op, uint16 var, uint16 argc, uint16 *ar
_birdSingEndTime = 0;
_birdCrankStartTime = _vm->_system->getMillis();
- MystResourceType6 *crankMovie = static_cast<MystResourceType6 *>(crank->getSubResource(0));
+ MystAreaVideo *crankMovie = static_cast<MystAreaVideo *>(crank->getSubResource(0));
crankMovie->playMovie();
}
void Mechanical::o_birdCrankStop(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Mechanical bird crank stop", op);
- MystResourceType11 *crank = static_cast<MystResourceType11 *>(_invokingResource);
+ MystAreaDrag *crank = static_cast<MystAreaDrag *>(_invokingResource);
- MystResourceType6 *crankMovie = static_cast<MystResourceType6 *>(crank->getSubResource(0));
+ MystAreaVideo *crankMovie = static_cast<MystAreaVideo *>(crank->getSubResource(0));
crankMovie->pauseMovie(true);
uint16 crankSoundId = crank->getList2(1);
@@ -334,7 +334,7 @@ void Mechanical::o_fortressStaircaseMovie(uint16 op, uint16 var, uint16 argc, ui
void Mechanical::o_elevatorRotationStart(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Elevator rotation lever start", op);
- MystResourceType12 *lever = static_cast<MystResourceType12 *>(_invokingResource);
+ MystVideoInfo *lever = static_cast<MystVideoInfo *>(_invokingResource);
lever->drawFrame(0);
_elevatorRotationLeverMoving = true;
@@ -349,7 +349,7 @@ void Mechanical::o_elevatorRotationMove(uint16 op, uint16 var, uint16 argc, uint
debugC(kDebugScript, "Opcode %d: Elevator rotation lever move", op);
const Common::Point &mouse = _vm->_system->getEventManager()->getMousePos();
- MystResourceType12 *lever = static_cast<MystResourceType12 *>(_invokingResource);
+ MystVideoInfo *lever = static_cast<MystVideoInfo *>(_invokingResource);
// Make the handle follow the mouse
int16 maxStep = lever->getNumFrames() - 1;
@@ -367,7 +367,7 @@ void Mechanical::o_elevatorRotationStop(uint16 op, uint16 var, uint16 argc, uint
debugC(kDebugScript, "Opcode %d: Elevator rotation lever stop", op);
const Common::Point &mouse = _vm->_system->getEventManager()->getMousePos();
- MystResourceType12 *lever = static_cast<MystResourceType12 *>(_invokingResource);
+ MystVideoInfo *lever = static_cast<MystVideoInfo *>(_invokingResource);
// Get current lever frame
int16 maxStep = lever->getNumFrames() - 1;
@@ -416,7 +416,7 @@ void Mechanical::o_fortressRotationSpeedStart(uint16 op, uint16 var, uint16 argc
_vm->_cursor->setCursor(700);
- MystResourceType12 *lever = static_cast<MystResourceType12 *>(_invokingResource);
+ MystVideoInfo *lever = static_cast<MystVideoInfo *>(_invokingResource);
lever->drawFrame(0);
}
@@ -424,7 +424,7 @@ void Mechanical::o_fortressRotationSpeedMove(uint16 op, uint16 var, uint16 argc,
debugC(kDebugScript, "Opcode %d Fortress rotation speed lever move", op);
const Common::Point &mouse = _vm->_system->getEventManager()->getMousePos();
- MystResourceType12 *lever = static_cast<MystResourceType12 *>(_invokingResource);
+ MystVideoInfo *lever = static_cast<MystVideoInfo *>(_invokingResource);
// Make the handle follow the mouse
int16 maxStep = lever->getNumFrames() - 1;
@@ -441,7 +441,7 @@ void Mechanical::o_fortressRotationSpeedMove(uint16 op, uint16 var, uint16 argc,
void Mechanical::o_fortressRotationSpeedStop(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d Fortress rotation speed lever stop", op);
- MystResourceType12 *lever = static_cast<MystResourceType12 *>(_invokingResource);
+ MystVideoInfo *lever = static_cast<MystVideoInfo *>(_invokingResource);
// Release lever
for (int i = _fortressRotationSpeed; i >= 0; i--) {
@@ -459,7 +459,7 @@ void Mechanical::o_fortressRotationBrakeStart(uint16 op, uint16 var, uint16 argc
_vm->_cursor->setCursor(700);
- MystResourceType12 *lever = static_cast<MystResourceType12 *>(_invokingResource);
+ MystVideoInfo *lever = static_cast<MystVideoInfo *>(_invokingResource);
lever->drawFrame(_fortressRotationBrake);
}
@@ -467,7 +467,7 @@ void Mechanical::o_fortressRotationBrakeMove(uint16 op, uint16 var, uint16 argc,
debugC(kDebugScript, "Opcode %d Fortress rotation brake lever move", op);
const Common::Point &mouse = _vm->_system->getEventManager()->getMousePos();
- MystResourceType12 *lever = static_cast<MystResourceType12 *>(_invokingResource);
+ MystVideoInfo *lever = static_cast<MystVideoInfo *>(_invokingResource);
// Make the handle follow the mouse
int16 maxStep = lever->getNumFrames() - 1;
@@ -484,7 +484,7 @@ void Mechanical::o_fortressRotationBrakeMove(uint16 op, uint16 var, uint16 argc,
void Mechanical::o_fortressRotationBrakeStop(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d Fortress rotation brake lever stop", op);
- MystResourceType12 *lever = static_cast<MystResourceType12 *>(_invokingResource);
+ MystVideoInfo *lever = static_cast<MystVideoInfo *>(_invokingResource);
lever->drawFrame(_fortressRotationBrake);
_vm->checkCursorHints();
@@ -495,7 +495,7 @@ void Mechanical::o_fortressSimulationSpeedStart(uint16 op, uint16 var, uint16 ar
_vm->_cursor->setCursor(700);
- MystResourceType12 *lever = static_cast<MystResourceType12 *>(_invokingResource);
+ MystVideoInfo *lever = static_cast<MystVideoInfo *>(_invokingResource);
lever->drawFrame(0);
}
@@ -503,7 +503,7 @@ void Mechanical::o_fortressSimulationSpeedMove(uint16 op, uint16 var, uint16 arg
debugC(kDebugScript, "Opcode %d Fortress rotation simulator speed lever move", op);
const Common::Point &mouse = _vm->_system->getEventManager()->getMousePos();
- MystResourceType12 *lever = static_cast<MystResourceType12 *>(_invokingResource);
+ MystVideoInfo *lever = static_cast<MystVideoInfo *>(_invokingResource);
// Make the handle follow the mouse
int16 maxStep = lever->getNumFrames() - 1;
@@ -520,7 +520,7 @@ void Mechanical::o_fortressSimulationSpeedMove(uint16 op, uint16 var, uint16 arg
void Mechanical::o_fortressSimulationSpeedStop(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d Fortress rotation simulator speed lever stop", op);
- MystResourceType12 *lever = static_cast<MystResourceType12 *>(_invokingResource);
+ MystVideoInfo *lever = static_cast<MystVideoInfo *>(_invokingResource);
// Release lever
for (int i = _fortressSimulationSpeed; i >= 0; i--) {
@@ -538,7 +538,7 @@ void Mechanical::o_fortressSimulationBrakeStart(uint16 op, uint16 var, uint16 ar
_vm->_cursor->setCursor(700);
- MystResourceType12 *lever = static_cast<MystResourceType12 *>(_invokingResource);
+ MystVideoInfo *lever = static_cast<MystVideoInfo *>(_invokingResource);
lever->drawFrame(_fortressSimulationBrake);
}
@@ -546,7 +546,7 @@ void Mechanical::o_fortressSimulationBrakeMove(uint16 op, uint16 var, uint16 arg
debugC(kDebugScript, "Opcode %d Fortress rotation simulator brake lever move", op);
const Common::Point &mouse = _vm->_system->getEventManager()->getMousePos();
- MystResourceType12 *lever = static_cast<MystResourceType12 *>(_invokingResource);
+ MystVideoInfo *lever = static_cast<MystVideoInfo *>(_invokingResource);
// Make the handle follow the mouse
int16 maxStep = lever->getNumFrames() - 1;
@@ -563,7 +563,7 @@ void Mechanical::o_fortressSimulationBrakeMove(uint16 op, uint16 var, uint16 arg
void Mechanical::o_fortressSimulationBrakeStop(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d Fortress rotation simulator brake lever stop", op);
- MystResourceType12 *lever = static_cast<MystResourceType12 *>(_invokingResource);
+ MystVideoInfo *lever = static_cast<MystVideoInfo *>(_invokingResource);
lever->drawFrame(_fortressSimulationBrake);
_vm->checkCursorHints();
@@ -763,13 +763,13 @@ void Mechanical::o_bird_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
_birdSinging = false;
_birdSingEndTime = 0;
- _bird = static_cast<MystResourceType6 *>(_invokingResource);
+ _bird = static_cast<MystAreaVideo *>(_invokingResource);
}
void Mechanical::o_snakeBox_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Snake box init", op);
- _snakeBox = static_cast<MystResourceType6 *>(_invokingResource);
+ _snakeBox = static_cast<MystAreaVideo *>(_invokingResource);
}
void Mechanical::elevatorRotation_run() {
@@ -872,7 +872,7 @@ void Mechanical::fortressRotation_run() {
void Mechanical::o_fortressRotation_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Fortress rotation init", op);
- _fortressRotationGears = static_cast<MystResourceType6 *>(_invokingResource);
+ _fortressRotationGears = static_cast<MystAreaVideo *>(_invokingResource);
VideoHandle gears = _fortressRotationGears->playMovie();
gears->setLooping(true);
@@ -997,7 +997,7 @@ void Mechanical::fortressSimulation_run() {
void Mechanical::o_fortressSimulation_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Fortress rotation simulator init", op);
- _fortressSimulationHolo = static_cast<MystResourceType6 *>(_invokingResource);
+ _fortressSimulationHolo = static_cast<MystAreaVideo *>(_invokingResource);
_fortressSimulationStartSound1 = argv[0];
_fortressSimulationStartSound2 = argv[1];
@@ -1019,7 +1019,7 @@ void Mechanical::o_fortressSimulation_init(uint16 op, uint16 var, uint16 argc, u
void Mechanical::o_fortressSimulationStartup_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Fortress rotation simulator startup init", op);
- _fortressSimulationStartup = static_cast<MystResourceType6 *>(_invokingResource);
+ _fortressSimulationStartup = static_cast<MystAreaVideo *>(_invokingResource);
}
} // End of namespace MystStacks
diff --git a/engines/mohawk/myst_stacks/mechanical.h b/engines/mohawk/myst_stacks/mechanical.h
index ccc2783..159a330 100644
--- a/engines/mohawk/myst_stacks/mechanical.h
+++ b/engines/mohawk/myst_stacks/mechanical.h
@@ -109,7 +109,7 @@ private:
uint16 _fortressRotationBrake; // 80
uint16 _fortressPosition; // 82
uint16 _fortressRotationSounds[4]; // 86 to 92
- MystResourceType6 *_fortressRotationGears; // 172
+ MystAreaVideo *_fortressRotationGears; // 172
bool _fortressRotationShortMovieWorkaround;
uint32 _fortressRotationShortMovieCount;
@@ -121,8 +121,8 @@ private:
uint16 _fortressSimulationBrake; // 98
uint16 _fortressSimulationStartSound1; // 102
uint16 _fortressSimulationStartSound2; // 100
- MystResourceType6 *_fortressSimulationHolo; // 160
- MystResourceType6 *_fortressSimulationStartup; // 164
+ MystAreaVideo *_fortressSimulationHolo; // 160
+ MystAreaVideo *_fortressSimulationStartup; // 164
uint16 _elevatorGoingDown; // 112
@@ -143,10 +143,10 @@ private:
bool _birdSinging; // 144
uint32 _birdCrankStartTime; // 136
uint32 _birdSingEndTime; // 140
- MystResourceType6 *_bird; // 152
+ MystAreaVideo *_bird; // 152
- MystResourceType6 *_snakeBox; // 156
+ MystAreaVideo *_snakeBox; // 156
};
} // End of namespace MystStacks
diff --git a/engines/mohawk/myst_stacks/myst.cpp b/engines/mohawk/myst_stacks/myst.cpp
index c5f76fe..8d2e732 100644
--- a/engines/mohawk/myst_stacks/myst.cpp
+++ b/engines/mohawk/myst_stacks/myst.cpp
@@ -1251,7 +1251,7 @@ void Myst::o_imagerPlayButton(uint16 op, uint16 var, uint16 argc, uint16 *argv)
void Myst::o_imagerEraseButton(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Imager erase button", op);
- _imagerRedButton = static_cast<MystResourceType8 *>(_invokingResource->_parent);
+ _imagerRedButton = static_cast<MystAreaImageSwitch *>(_invokingResource->_parent);
for (uint i = 0; i < 4; i++)
_imagerSound[i] = argv[i];
_imagerValidationCard = argv[4];
@@ -1351,7 +1351,7 @@ void Myst::o_towerElevatorAnimation(uint16 op, uint16 var, uint16 argc, uint16 *
void Myst::o_generatorButtonPressed(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Generator button pressed", op);
- MystResource *button = _invokingResource->_parent;
+ MystArea *button = _invokingResource->_parent;
generatorRedrawRocket();
@@ -1385,7 +1385,7 @@ void Myst::o_generatorButtonPressed(uint16 op, uint16 var, uint16 argc, uint16 *
}
// Redraw button
- _vm->redrawArea(button->getType8Var());
+ _vm->redrawArea(button->getImageSwitchVar());
// Blow breaker
if (_state.generatorVoltage > 59)
@@ -1398,8 +1398,8 @@ void Myst::generatorRedrawRocket() {
_vm->redrawArea(97);
}
-void Myst::generatorButtonValue(MystResource *button, uint16 &mask, uint16 &value) {
- switch (button->getType8Var()) {
+void Myst::generatorButtonValue(MystArea *button, uint16 &mask, uint16 &value) {
+ switch (button->getImageSwitchVar()) {
case 52: // Generator Switch #1
mask = 1;
value = 10;
@@ -1466,7 +1466,7 @@ void Myst::o_cabinSafeHandleStartMove(uint16 op, uint16 var, uint16 argc, uint16
debugC(kDebugScript, "Opcode %d: Cabin safe handle start move", op);
// Used on Card 4100
- MystResourceType12 *handle = static_cast<MystResourceType12 *>(_invokingResource);
+ MystVideoInfo *handle = static_cast<MystVideoInfo *>(_invokingResource);
handle->drawFrame(0);
_vm->_cursor->setCursor(700);
_tempVar = 0;
@@ -1476,7 +1476,7 @@ void Myst::o_cabinSafeHandleMove(uint16 op, uint16 var, uint16 argc, uint16 *arg
debugC(kDebugScript, "Opcode %d: Cabin safe handle move", op);
// Used on Card 4100
- MystResourceType12 *handle = static_cast<MystResourceType12 *>(_invokingResource);
+ MystVideoInfo *handle = static_cast<MystVideoInfo *>(_invokingResource);
if (handle->pullLeverV()) {
// Sound not played yet
@@ -1506,7 +1506,7 @@ void Myst::o_cabinSafeHandleEndMove(uint16 op, uint16 var, uint16 argc, uint16 *
debugC(kDebugScript, "Opcode %d: Cabin safe handle end move", op);
// Used on Card 4100
- MystResourceType12 *handle = static_cast<MystResourceType12 *>(_invokingResource);
+ MystVideoInfo *handle = static_cast<MystVideoInfo *>(_invokingResource);
handle->drawFrame(0);
_vm->checkCursorHints();
}
@@ -1804,7 +1804,7 @@ void Myst::o_observatoryTimeSliderMove(uint16 op, uint16 var, uint16 argc, uint1
void Myst::o_circuitBreakerStartMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Circuit breaker start move", op);
- MystResourceType12 *breaker = static_cast<MystResourceType12 *>(_invokingResource);
+ MystVideoInfo *breaker = static_cast<MystVideoInfo *>(_invokingResource);
breaker->drawFrame(0);
_vm->_cursor->setCursor(700);
_tempVar = 0;
@@ -1813,7 +1813,7 @@ void Myst::o_circuitBreakerStartMove(uint16 op, uint16 var, uint16 argc, uint16
void Myst::o_circuitBreakerMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Circuit breaker move", op);
- MystResourceType12 *breaker = static_cast<MystResourceType12 *>(_invokingResource);
+ MystVideoInfo *breaker = static_cast<MystVideoInfo *>(_invokingResource);
const Common::Point &mouse = _vm->_system->getEventManager()->getMousePos();
int16 maxStep = breaker->getStepsV() - 1;
@@ -1828,7 +1828,7 @@ void Myst::o_circuitBreakerMove(uint16 op, uint16 var, uint16 argc, uint16 *argv
// Breaker switched
if (step == maxStep) {
// Choose breaker
- if (breaker->getType8Var() == 93) {
+ if (breaker->getImageSwitchVar() == 93) {
// Voltage is still too high or not broken
if (_state.generatorVoltage > 59 || _state.generatorBreakers != 1) {
uint16 soundId = breaker->getList2(1);
@@ -1864,8 +1864,8 @@ void Myst::o_circuitBreakerMove(uint16 op, uint16 var, uint16 argc, uint16 *argv
void Myst::o_circuitBreakerEndMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Circuit breaker end move", op);
- MystResourceType12 *breaker = static_cast<MystResourceType12 *>(_invokingResource);
- _vm->redrawArea(breaker->getType8Var());
+ MystVideoInfo *breaker = static_cast<MystVideoInfo *>(_invokingResource);
+ _vm->redrawArea(breaker->getImageSwitchVar());
_vm->checkCursorHints();
}
@@ -2202,7 +2202,7 @@ void Myst::o_rocketSoundSliderEndMove(uint16 op, uint16 var, uint16 argc, uint16
}
void Myst::rocketSliderMove() {
- MystResourceType10 *slider = static_cast<MystResourceType10 *>(_invokingResource);
+ MystAreaSlider *slider = static_cast<MystAreaSlider *>(_invokingResource);
if (_state.generatorVoltage == 59 && !_state.generatorBreakers) {
uint16 soundId = rocketSliderGetSound(slider->_pos.y);
@@ -2262,7 +2262,7 @@ void Myst::rocketCheckSolution() {
if (solved) {
// Reset lever position
- MystResourceType12 *lever = static_cast<MystResourceType12 *>(_invokingResource);
+ MystVideoInfo *lever = static_cast<MystVideoInfo *>(_invokingResource);
lever->drawFrame(0);
// Book appearing
@@ -2299,7 +2299,7 @@ void Myst::rocketCheckSolution() {
void Myst::o_rocketPianoStart(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Rocket piano start move", op);
- MystResourceType11 *key = static_cast<MystResourceType11 *>(_invokingResource);
+ MystAreaDrag *key = static_cast<MystAreaDrag *>(_invokingResource);
// What the hell??
Common::Rect src = key->getSubImage(1).rect;
@@ -2326,7 +2326,7 @@ void Myst::o_rocketPianoMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
Common::Rect piano = Common::Rect(85, 123, 460, 270);
// Unpress previous key
- MystResourceType11 *key = static_cast<MystResourceType11 *>(_invokingResource);
+ MystAreaDrag *key = static_cast<MystAreaDrag *>(_invokingResource);
Common::Rect src = key->getSubImage(0).rect;
Common::Rect dest = src;
@@ -2337,10 +2337,10 @@ void Myst::o_rocketPianoMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
_vm->_gfx->copyImageSectionToScreen(key->getSubImage(0).wdib, src, dest);
if (piano.contains(mouse)) {
- MystResource *resource = _vm->updateCurrentResource();
- if (resource && resource->type == kMystDragArea) {
+ MystArea *resource = _vm->updateCurrentResource();
+ if (resource && resource->type == kMystAreaDrag) {
// Press new key
- key = static_cast<MystResourceType11 *>(resource);
+ key = static_cast<MystAreaDrag *>(resource);
src = key->getSubImage(1).rect;
Common::Rect rect = key->getSubImage(0).rect;
dest = rect;
@@ -2368,7 +2368,7 @@ void Myst::o_rocketPianoMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
void Myst::o_rocketPianoStop(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Rocket piano end move", op);
- MystResourceType8 *key = static_cast<MystResourceType8 *>(_invokingResource);
+ MystAreaImageSwitch *key = static_cast<MystAreaImageSwitch *>(_invokingResource);
Common::Rect src = key->getSubImage(0).rect;
Common::Rect dest = src;
@@ -2386,7 +2386,7 @@ void Myst::o_rocketPianoStop(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
void Myst::o_rocketLeverStartMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Rocket lever start move", op);
- MystResourceType12 *lever = static_cast<MystResourceType12 *>(_invokingResource);
+ MystVideoInfo *lever = static_cast<MystVideoInfo *>(_invokingResource);
_vm->_cursor->setCursor(700);
_rocketLeverPosition = 0;
@@ -2406,7 +2406,7 @@ void Myst::o_rocketOpenBook(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
void Myst::o_rocketLeverMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Rocket lever move", op);
- MystResourceType12 *lever = static_cast<MystResourceType12 *>(_invokingResource);
+ MystVideoInfo *lever = static_cast<MystVideoInfo *>(_invokingResource);
const Common::Point &mouse = _vm->_system->getEventManager()->getMousePos();
// Make the lever follow the mouse
@@ -2435,7 +2435,7 @@ void Myst::o_rocketLeverMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
void Myst::o_rocketLeverEndMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Rocket lever end move", op);
- MystResourceType12 *lever = static_cast<MystResourceType12 *>(_invokingResource);
+ MystVideoInfo *lever = static_cast<MystVideoInfo *>(_invokingResource);
_vm->checkCursorHints();
_rocketLeverPosition = 0;
@@ -2712,7 +2712,7 @@ void Myst::clockWheel_run() {
}
void Myst::clockWheelStartTurn(uint16 wheel) {
- MystResourceType11 *resource = static_cast<MystResourceType11 *>(_invokingResource);
+ MystAreaDrag *resource = static_cast<MystAreaDrag *>(_invokingResource);
uint16 soundId = resource->getList1(0);
if (soundId)
@@ -2874,7 +2874,7 @@ void Myst::o_imagerEraseStop(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
void Myst::o_clockLeverStartMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Clock lever start move", op);
- MystResourceType12 *lever = static_cast<MystResourceType12 *>(_invokingResource);
+ MystVideoInfo *lever = static_cast<MystVideoInfo *>(_invokingResource);
lever->drawFrame(0);
_vm->_cursor->setCursor(700);
_clockMiddleGearMovedAlone = false;
@@ -2885,7 +2885,7 @@ void Myst::o_clockLeverMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Clock left lever move", op);
if (!_clockLeverPulled) {
- MystResourceType12 *lever = static_cast<MystResourceType12 *>(_invokingResource);
+ MystVideoInfo *lever = static_cast<MystVideoInfo *>(_invokingResource);
// If lever pulled
if (lever->pullLeverV()) {
@@ -2977,7 +2977,7 @@ void Myst::o_clockLeverEndMove(uint16 op, uint16 var, uint16 argc, uint16 *argv)
_vm->_sound->replaceSoundMyst(8113);
// Release lever
- MystResourceType12 *lever = static_cast<MystResourceType12 *>(_invokingResource);
+ MystVideoInfo *lever = static_cast<MystVideoInfo *>(_invokingResource);
lever->releaseLeverV();
// Check if puzzle is solved
@@ -3021,7 +3021,7 @@ void Myst::clockGearsCheckSolution() {
void Myst::o_clockResetLeverStartMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Clock reset lever start move", op);
- MystResourceType12 *lever = static_cast<MystResourceType12 *>(_invokingResource);
+ MystVideoInfo *lever = static_cast<MystVideoInfo *>(_invokingResource);
lever->drawFrame(0);
_vm->_cursor->setCursor(700);
}
@@ -3029,7 +3029,7 @@ void Myst::o_clockResetLeverStartMove(uint16 op, uint16 var, uint16 argc, uint16
void Myst::o_clockResetLeverMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Clock reset lever move", op);
- MystResourceType12 *lever = static_cast<MystResourceType12 *>(_invokingResource);
+ MystVideoInfo *lever = static_cast<MystVideoInfo *>(_invokingResource);
// If pulled
if (lever->pullLeverV() && _clockWeightPosition != 0)
@@ -3125,7 +3125,7 @@ void Myst::o_clockResetLeverEndMove(uint16 op, uint16 var, uint16 argc, uint16 *
debugC(kDebugScript, "Opcode %d: Clock reset lever end move", op);
// Get current lever frame
- MystResourceType12 *lever = static_cast<MystResourceType12 *>(_invokingResource);
+ MystVideoInfo *lever = static_cast<MystVideoInfo *>(_invokingResource);
lever->releaseLeverV();
@@ -3189,8 +3189,8 @@ void Myst::towerRotationMap_run() {
void Myst::o_towerRotationMap_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
_towerRotationMapRunning = true;
- _towerRotationMapTower = static_cast<MystResourceType11 *>(_invokingResource);
- _towerRotationMapLabel = static_cast<MystResourceType8 *>(_vm->_resources[argv[0]]);
+ _towerRotationMapTower = static_cast<MystAreaDrag *>(_invokingResource);
+ _towerRotationMapLabel = static_cast<MystAreaImageSwitch *>(_vm->_resources[argv[0]]);
_tempVar = 0;
_startTime = 0;
_towerRotationMapClicked = false;
@@ -3202,7 +3202,7 @@ void Myst::towerRotationDrawBuildings() {
// Draw other resources
for (uint i = 1; i <= 10; i++) {
- MystResourceType8 *resource = static_cast<MystResourceType8 *>(_vm->_resources[i]);
+ MystAreaImageSwitch *resource = static_cast<MystAreaImageSwitch *>(_vm->_resources[i]);
_vm->redrawResource(resource, false);
}
}
@@ -3322,7 +3322,7 @@ void Myst::o_butterflies_init(uint16 op, uint16 var, uint16 argc, uint16 *argv)
// Used for Card 4256 (Butterfly Movie Activation)
if (!_butterfliesMoviePlayed) {
- MystResourceType6 *butterflies = static_cast<MystResourceType6 *>(_invokingResource);
+ MystAreaVideo *butterflies = static_cast<MystAreaVideo *>(_invokingResource);
butterflies->playMovie();
_butterfliesMoviePlayed = true;
@@ -3333,8 +3333,8 @@ void Myst::o_imager_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Imager init", op);
debugC(kDebugScript, "Var: %d", var);
- MystResourceType7 *select = static_cast<MystResourceType7 *>(_invokingResource);
- _imagerMovie = static_cast<MystResourceType6 *>(select->getSubResource(getVar(var)));
+ MystAreaActionSwitch *select = static_cast<MystAreaActionSwitch *>(_invokingResource);
+ _imagerMovie = static_cast<MystAreaVideo *>(select->getSubResource(getVar(var)));
_imagerRunning = true;
}
@@ -3377,8 +3377,8 @@ void Myst::libraryBookcaseTransform_run(void) {
void Myst::o_libraryBookcaseTransform_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
if (_libraryBookcaseChanged) {
- MystResourceType7 *resource = static_cast<MystResourceType7 *>(_invokingResource);
- _libraryBookcaseMovie = static_cast<MystResourceType6 *>(resource->getSubResource(getVar(0)));
+ MystAreaActionSwitch *resource = static_cast<MystAreaActionSwitch *>(_invokingResource);
+ _libraryBookcaseMovie = static_cast<MystAreaVideo *>(resource->getSubResource(getVar(0)));
_libraryBookcaseSoundId = argv[0];
_libraryBookcaseMoving = true;
}
@@ -3471,17 +3471,17 @@ void Myst::o_observatory_init(uint16 op, uint16 var, uint16 argc, uint16 *argv)
_tempVar = 0;
_observatoryNotInitialized = true;
- _observatoryVisualizer = static_cast<MystResourceType8 *>(_invokingResource);
- _observatoryGoButton = static_cast<MystResourceType8 *>(_vm->_resources[argv[0]]);
+ _observatoryVisualizer = static_cast<MystAreaImageSwitch *>(_invokingResource);
+ _observatoryGoButton = static_cast<MystAreaImageSwitch *>(_vm->_resources[argv[0]]);
if (observatoryIsDDMMYYYY2400()) {
- _observatoryDaySlider = static_cast<MystResourceType10 *>(_vm->_resources[argv[1]]);
- _observatoryMonthSlider = static_cast<MystResourceType10 *>(_vm->_resources[argv[2]]);
+ _observatoryDaySlider = static_cast<MystAreaSlider *>(_vm->_resources[argv[1]]);
+ _observatoryMonthSlider = static_cast<MystAreaSlider *>(_vm->_resources[argv[2]]);
} else {
- _observatoryMonthSlider = static_cast<MystResourceType10 *>(_vm->_resources[argv[1]]);
- _observatoryDaySlider = static_cast<MystResourceType10 *>(_vm->_resources[argv[2]]);
+ _observatoryMonthSlider = static_cast<MystAreaSlider *>(_vm->_resources[argv[1]]);
+ _observatoryDaySlider = static_cast<MystAreaSlider *>(_vm->_resources[argv[2]]);
}
- _observatoryYearSlider = static_cast<MystResourceType10 *>(_vm->_resources[argv[3]]);
- _observatoryTimeSlider = static_cast<MystResourceType10 *>(_vm->_resources[argv[4]]);
+ _observatoryYearSlider = static_cast<MystAreaSlider *>(_vm->_resources[argv[3]]);
+ _observatoryTimeSlider = static_cast<MystAreaSlider *>(_vm->_resources[argv[4]]);
// Set date selection sliders position
_observatoryDaySlider->setPosition(_state.observatoryDaySlider);
@@ -3614,13 +3614,13 @@ void Myst::gullsFly2_run() {
void Myst::o_treeCard_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Enter tree card", op);
- _tree = static_cast<MystResourceType8 *>(_invokingResource);
+ _tree = static_cast<MystAreaImageSwitch *>(_invokingResource);
}
void Myst::o_treeEntry_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Enter tree card with entry", op);
- _treeAlcove = static_cast<MystResourceType5 *>(_invokingResource);
+ _treeAlcove = static_cast<MystAreaAction *>(_invokingResource);
_treeMinAccessiblePosition = argv[0];
_treeMaxAccessiblePosition = argv[1];
@@ -3704,11 +3704,11 @@ void Myst::boilerGaugeInit() {
void Myst::o_rocketSliders_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Rocket sliders init", op);
- _rocketSlider1 = static_cast<MystResourceType10 *>(_vm->_resources[argv[0]]);
- _rocketSlider2 = static_cast<MystResourceType10 *>(_vm->_resources[argv[1]]);
- _rocketSlider3 = static_cast<MystResourceType10 *>(_vm->_resources[argv[2]]);
- _rocketSlider4 = static_cast<MystResourceType10 *>(_vm->_resources[argv[3]]);
- _rocketSlider5 = static_cast<MystResourceType10 *>(_vm->_resources[argv[4]]);
+ _rocketSlider1 = static_cast<MystAreaSlider *>(_vm->_resources[argv[0]]);
+ _rocketSlider2 = static_cast<MystAreaSlider *>(_vm->_resources[argv[1]]);
+ _rocketSlider3 = static_cast<MystAreaSlider *>(_vm->_resources[argv[2]]);
+ _rocketSlider4 = static_cast<MystAreaSlider *>(_vm->_resources[argv[3]]);
+ _rocketSlider5 = static_cast<MystAreaSlider *>(_vm->_resources[argv[4]]);
// Initialize sliders position
for (uint i = 0; i < 5; i++)
diff --git a/engines/mohawk/myst_stacks/myst.h b/engines/mohawk/myst_stacks/myst.h
index 38b6d99..576f929 100644
--- a/engines/mohawk/myst_stacks/myst.h
+++ b/engines/mohawk/myst_stacks/myst.h
@@ -192,11 +192,11 @@ protected:
bool _generatorControlRoomRunning;
uint16 _generatorVoltage; // 58
- MystResourceType10 *_rocketSlider1; // 248
- MystResourceType10 *_rocketSlider2; // 252
- MystResourceType10 *_rocketSlider3; // 256
- MystResourceType10 *_rocketSlider4; // 260
- MystResourceType10 *_rocketSlider5; // 264
+ MystAreaSlider *_rocketSlider1; // 248
+ MystAreaSlider *_rocketSlider2; // 252
+ MystAreaSlider *_rocketSlider3; // 256
+ MystAreaSlider *_rocketSlider4; // 260
+ MystAreaSlider *_rocketSlider5; // 264
uint16 _rocketSliderSound; // 294
uint16 _rocketLeverPosition; // 296
VideoHandle _rocketLinkBook;
@@ -214,7 +214,7 @@ protected:
uint32 _gullsNextTime; // 216
bool _libraryBookcaseMoving;
- MystResourceType6 *_libraryBookcaseMovie; // 104
+ MystAreaVideo *_libraryBookcaseMovie; // 104
uint16 _libraryBookcaseSoundId; // 284
bool _libraryBookcaseChanged; // 288
uint16 _libraryBookSound1; // 298
@@ -223,13 +223,13 @@ protected:
uint16 _courtyardBoxSound; // 302
bool _imagerValidationRunning;
- MystResourceType8 *_imagerRedButton; // 304
+ MystAreaImageSwitch *_imagerRedButton; // 304
uint16 _imagerSound[4]; // 308 to 314
uint16 _imagerValidationCard; // 316
uint16 _imagerValidationStep; // 318
bool _imagerRunning;
- MystResourceType6 *_imagerMovie; // 64
+ MystAreaVideo *_imagerMovie; // 64
uint16 _fireplaceLines[6]; // 74 to 84
@@ -248,8 +248,8 @@ protected:
bool _towerRotationBlinkLabel;
uint16 _towerRotationBlinkLabelCount;
uint16 _towerRotationMapInitialized; // 292
- MystResourceType11 *_towerRotationMapTower; // 108
- MystResourceType8 *_towerRotationMapLabel; // 112
+ MystAreaDrag *_towerRotationMapTower; // 108
+ MystAreaImageSwitch *_towerRotationMapLabel; // 112
uint16 _towerRotationSpeed; // 124
bool _towerRotationMapClicked; // 132
bool _towerRotationOverSpot; // 136
@@ -269,8 +269,8 @@ protected:
bool _basementPressureDecreasing;
bool _treeStopped; // 236
- MystResourceType8 *_tree; // 220
- MystResourceType5 *_treeAlcove; // 224
+ MystAreaImageSwitch *_tree; // 220
+ MystAreaAction *_treeAlcove; // 224
uint16 _treeMinPosition; // 228
uint16 _treeMinAccessiblePosition; // 230
uint16 _treeMaxAccessiblePosition; // 232
@@ -280,21 +280,21 @@ protected:
bool _observatoryDayChanging;
bool _observatoryYearChanging;
bool _observatoryTimeChanging;
- MystResourceType8 *_observatoryVisualizer; // 184
- MystResourceType8 *_observatoryGoButton; // 188
- MystResourceType10 *_observatoryDaySlider; // 192
- MystResourceType10 *_observatoryMonthSlider; // 196
- MystResourceType10 *_observatoryYearSlider; // 200
- MystResourceType10 *_observatoryTimeSlider; // 204
+ MystAreaImageSwitch *_observatoryVisualizer; // 184
+ MystAreaImageSwitch *_observatoryGoButton; // 188
+ MystAreaSlider *_observatoryDaySlider; // 192
+ MystAreaSlider *_observatoryMonthSlider; // 196
+ MystAreaSlider *_observatoryYearSlider; // 200
+ MystAreaSlider *_observatoryTimeSlider; // 204
uint32 _observatoryLastTime; // 208
bool _observatoryNotInitialized; // 212
int16 _observatoryIncrement; // 346
- MystResourceType10 *_observatoryCurrentSlider; // 348
+ MystAreaSlider *_observatoryCurrentSlider; // 348
bool _greenBookRunning;
void generatorRedrawRocket();
- void generatorButtonValue(MystResource *button, uint16 &offset, uint16 &value);
+ void generatorButtonValue(MystArea *button, uint16 &offset, uint16 &value);
void rocketSliderMove();
uint16 rocketSliderGetSound(uint16 pos);
diff --git a/engines/mohawk/myst_stacks/preview.cpp b/engines/mohawk/myst_stacks/preview.cpp
index 4cae4aa..7f6d38d 100644
--- a/engines/mohawk/myst_stacks/preview.cpp
+++ b/engines/mohawk/myst_stacks/preview.cpp
@@ -239,13 +239,13 @@ void Preview::o_library_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Library init", op);
// Used for Card 3002 (Myst Island Overview)
- _library = static_cast<MystResourceType8 *>(_invokingResource);
+ _library = static_cast<MystAreaImageSwitch *>(_invokingResource);
}
void Preview::o_libraryBookcaseTransformDemo_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
if (_libraryBookcaseChanged) {
- MystResourceType7 *resource = static_cast<MystResourceType7 *>(_invokingResource);
- _libraryBookcaseMovie = static_cast<MystResourceType6 *>(resource->getSubResource(getVar(303)));
+ MystAreaActionSwitch *resource = static_cast<MystAreaActionSwitch *>(_invokingResource);
+ _libraryBookcaseMovie = static_cast<MystAreaVideo *>(resource->getSubResource(getVar(303)));
_libraryBookcaseSoundId = argv[0];
_libraryBookcaseMoving = true;
}
diff --git a/engines/mohawk/myst_stacks/preview.h b/engines/mohawk/myst_stacks/preview.h
index 04ad6c3..9d833b3 100644
--- a/engines/mohawk/myst_stacks/preview.h
+++ b/engines/mohawk/myst_stacks/preview.h
@@ -56,7 +56,7 @@ private:
DECLARE_OPCODE(o_library_init);
uint16 _libraryState; // 4
- MystResourceType8 *_library; // 32
+ MystAreaImageSwitch *_library; // 32
bool _speechRunning;
uint _speechStep;
diff --git a/engines/mohawk/myst_stacks/selenitic.cpp b/engines/mohawk/myst_stacks/selenitic.cpp
index 7d1e1b9..30333ec 100644
--- a/engines/mohawk/myst_stacks/selenitic.cpp
+++ b/engines/mohawk/myst_stacks/selenitic.cpp
@@ -773,7 +773,7 @@ uint16 Selenitic::soundLockCurrentSound(uint16 position, bool pixels) {
return 0;
}
-MystResourceType10 *Selenitic::soundLockSliderFromVar(uint16 var) {
+MystAreaSlider *Selenitic::soundLockSliderFromVar(uint16 var) {
switch (var) {
case 20:
return _soundLockSlider1;
@@ -793,7 +793,7 @@ MystResourceType10 *Selenitic::soundLockSliderFromVar(uint16 var) {
void Selenitic::o_soundLockMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Sound lock move", op);
- MystResourceType10 *slider = soundLockSliderFromVar(var);
+ MystAreaSlider *slider = soundLockSliderFromVar(var);
uint16 soundId = soundLockCurrentSound(slider->_pos.y, true);
if (_soundLockSoundId != soundId) {
@@ -805,7 +805,7 @@ void Selenitic::o_soundLockMove(uint16 op, uint16 var, uint16 argc, uint16 *argv
void Selenitic::o_soundLockStartMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Sound lock start move", op);
- MystResourceType10 *slider = soundLockSliderFromVar(var);
+ MystAreaSlider *slider = soundLockSliderFromVar(var);
_vm->_cursor->setCursor(700);
_vm->_sound->pauseBackgroundMyst();
@@ -817,7 +817,7 @@ void Selenitic::o_soundLockStartMove(uint16 op, uint16 var, uint16 argc, uint16
void Selenitic::o_soundLockEndMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Sound lock end move", op);
- MystResourceType10 *slider = soundLockSliderFromVar(var);
+ MystAreaSlider *slider = soundLockSliderFromVar(var);
uint16 *value = &_state.soundLockSliderPositions[0];
switch (var) {
@@ -861,7 +861,7 @@ void Selenitic::o_soundLockEndMove(uint16 op, uint16 var, uint16 argc, uint16 *a
_vm->_sound->resumeBackgroundMyst();
}
-void Selenitic::soundLockCheckSolution(MystResourceType10 *slider, uint16 value, uint16 solution, bool &solved) {
+void Selenitic::soundLockCheckSolution(MystAreaSlider *slider, uint16 value, uint16 solution, bool &solved) {
slider->drawConditionalDataToScreen(2);
_vm->_sound->replaceSoundMyst(soundLockCurrentSound(value / 12, false));
_vm->_system->delayMillis(1500);
@@ -929,15 +929,15 @@ void Selenitic::o_soundReceiverEndMove(uint16 op, uint16 var, uint16 argc, uint1
}
void Selenitic::o_mazeRunnerCompass_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
- _mazeRunnerCompass = static_cast<MystResourceType8 *>(_invokingResource);
+ _mazeRunnerCompass = static_cast<MystAreaImageSwitch *>(_invokingResource);
}
void Selenitic::o_mazeRunnerWindow_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
- _mazeRunnerWindow = static_cast<MystResourceType8 *>(_invokingResource);
+ _mazeRunnerWindow = static_cast<MystAreaImageSwitch *>(_invokingResource);
}
void Selenitic::o_mazeRunnerLight_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
- _mazeRunnerLight = static_cast<MystResourceType8 *>(_invokingResource);
+ _mazeRunnerLight = static_cast<MystAreaImageSwitch *>(_invokingResource);
}
void Selenitic::soundReceiver_run() {
@@ -1059,19 +1059,19 @@ void Selenitic::o_soundReceiver_init(uint16 op, uint16 var, uint16 argc, uint16
// Used for Card 1245 (Sound Receiver)
_soundReceiverRunning = true;
- _soundReceiverRightButton = static_cast<MystResourceType8 *>(_vm->_resources[0]);
- _soundReceiverLeftButton = static_cast<MystResourceType8 *>(_vm->_resources[1]);
- _soundReceiverSigmaButton = static_cast<MystResourceType8 *>(_vm->_resources[2]);
- _soundReceiverSources[4] = static_cast<MystResourceType8 *>(_vm->_resources[3]);
- _soundReceiverSources[3] = static_cast<MystResourceType8 *>(_vm->_resources[4]);
- _soundReceiverSources[2] = static_cast<MystResourceType8 *>(_vm->_resources[5]);
- _soundReceiverSources[1] = static_cast<MystResourceType8 *>(_vm->_resources[6]);
- _soundReceiverSources[0] = static_cast<MystResourceType8 *>(_vm->_resources[7]);
- _soundReceiverViewer = static_cast<MystResourceType8 *>(_vm->_resources[8]);
- _soundReceiverAngle1 = static_cast<MystResourceType8 *>(_vm->_resources[10]);
- _soundReceiverAngle2 = static_cast<MystResourceType8 *>(_vm->_resources[11]);
- _soundReceiverAngle3 = static_cast<MystResourceType8 *>(_vm->_resources[12]);
- _soundReceiverAngle4 = static_cast<MystResourceType8 *>(_vm->_resources[13]);
+ _soundReceiverRightButton = static_cast<MystAreaImageSwitch *>(_vm->_resources[0]);
+ _soundReceiverLeftButton = static_cast<MystAreaImageSwitch *>(_vm->_resources[1]);
+ _soundReceiverSigmaButton = static_cast<MystAreaImageSwitch *>(_vm->_resources[2]);
+ _soundReceiverSources[4] = static_cast<MystAreaImageSwitch *>(_vm->_resources[3]);
+ _soundReceiverSources[3] = static_cast<MystAreaImageSwitch *>(_vm->_resources[4]);
+ _soundReceiverSources[2] = static_cast<MystAreaImageSwitch *>(_vm->_resources[5]);
+ _soundReceiverSources[1] = static_cast<MystAreaImageSwitch *>(_vm->_resources[6]);
+ _soundReceiverSources[0] = static_cast<MystAreaImageSwitch *>(_vm->_resources[7]);
+ _soundReceiverViewer = static_cast<MystAreaImageSwitch *>(_vm->_resources[8]);
+ _soundReceiverAngle1 = static_cast<MystAreaImageSwitch *>(_vm->_resources[10]);
+ _soundReceiverAngle2 = static_cast<MystAreaImageSwitch *>(_vm->_resources[11]);
+ _soundReceiverAngle3 = static_cast<MystAreaImageSwitch *>(_vm->_resources[12]);
+ _soundReceiverAngle4 = static_cast<MystAreaImageSwitch *>(_vm->_resources[13]);
uint16 currentSource = _state.soundReceiverCurrentSource;
_soundReceiverPosition = &_state.soundReceiverPositions[currentSource];
@@ -1084,31 +1084,31 @@ void Selenitic::o_soundLock_init(uint16 op, uint16 var, uint16 argc, uint16 *arg
debugC(kDebugScript, "Opcode %d: Sound lock init", op);
for (uint i = 0; i < _vm->_resources.size(); i++) {
- if (_vm->_resources[i]->type == kMystSlider) {
- switch (_vm->_resources[i]->getType8Var()) {
+ if (_vm->_resources[i]->type == kMystAreaSlider) {
+ switch (_vm->_resources[i]->getImageSwitchVar()) {
case 20:
- _soundLockSlider1 = static_cast<MystResourceType10 *>(_vm->_resources[i]);
+ _soundLockSlider1 = static_cast<MystAreaSlider *>(_vm->_resources[i]);
_soundLockSlider1->setStep(_state.soundLockSliderPositions[0]);
break;
case 21:
- _soundLockSlider2 = static_cast<MystResourceType10 *>(_vm->_resources[i]);
+ _soundLockSlider2 = static_cast<MystAreaSlider *>(_vm->_resources[i]);
_soundLockSlider2->setStep(_state.soundLockSliderPositions[1]);
break;
case 22:
- _soundLockSlider3 = static_cast<MystResourceType10 *>(_vm->_resources[i]);
+ _soundLockSlider3 = static_cast<MystAreaSlider *>(_vm->_resources[i]);
_soundLockSlider3->setStep(_state.soundLockSliderPositions[2]);
break;
case 23:
- _soundLockSlider4 = static_cast<MystResourceType10 *>(_vm->_resources[i]);
+ _soundLockSlider4 = static_cast<MystAreaSlider *>(_vm->_resources[i]);
_soundLockSlider4->setStep(_state.soundLockSliderPositions[3]);
break;
case 24:
- _soundLockSlider5 = static_cast<MystResourceType10 *>(_vm->_resources[i]);
+ _soundLockSlider5 = static_cast<MystAreaSlider *>(_vm->_resources[i]);
_soundLockSlider5->setStep(_state.soundLockSliderPositions[4]);
break;
}
- } else if (_vm->_resources[i]->type == kMystConditionalImage && _vm->_resources[i]->getType8Var() == 28) {
- _soundLockButton = static_cast<MystResourceType8 *>(_vm->_resources[i]);
+ } else if (_vm->_resources[i]->type == kMystAreaImageSwitch && _vm->_resources[i]->getImageSwitchVar() == 28) {
+ _soundLockButton = static_cast<MystAreaImageSwitch *>(_vm->_resources[i]);
}
}
@@ -1116,11 +1116,11 @@ void Selenitic::o_soundLock_init(uint16 op, uint16 var, uint16 argc, uint16 *arg
}
void Selenitic::o_mazeRunnerRight_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
- _mazeRunnerRightButton = static_cast<MystResourceType8 *>(_invokingResource);
+ _mazeRunnerRightButton = static_cast<MystAreaImageSwitch *>(_invokingResource);
}
void Selenitic::o_mazeRunnerLeft_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
- _mazeRunnerLeftButton = static_cast<MystResourceType8 *>(_invokingResource);
+ _mazeRunnerLeftButton = static_cast<MystAreaImageSwitch *>(_invokingResource);
}
const uint16 Selenitic::_mazeRunnerMap[300][4] = {
diff --git a/engines/mohawk/myst_stacks/selenitic.h b/engines/mohawk/myst_stacks/selenitic.h
index 7654ffd..ffd8941 100644
--- a/engines/mohawk/myst_stacks/selenitic.h
+++ b/engines/mohawk/myst_stacks/selenitic.h
@@ -29,7 +29,7 @@
namespace Mohawk {
-class MystResourceType8;
+class MystAreaImageSwitch;
struct MystScriptEntry;
namespace MystStacks {
@@ -80,40 +80,40 @@ private:
bool _soundReceiverRunning;
bool _soundReceiverSigmaPressed; // 6
- MystResourceType8 *_soundReceiverSources[5]; // 92 -> 108
- MystResourceType8 *_soundReceiverCurrentSource; // 112
+ MystAreaImageSwitch *_soundReceiverSources[5]; // 92 -> 108
+ MystAreaImageSwitch *_soundReceiverCurrentSource; // 112
uint16 *_soundReceiverPosition; // 116
uint16 _soundReceiverDirection; // 120
uint16 _soundReceiverSpeed; // 122
uint32 _soundReceiverStartTime; //124
- MystResourceType8 *_soundReceiverViewer; // 128
- MystResourceType8 *_soundReceiverRightButton; // 132
- MystResourceType8 *_soundReceiverLeftButton; // 136
- MystResourceType8 *_soundReceiverAngle1; // 140
- MystResourceType8 *_soundReceiverAngle2; // 144
- MystResourceType8 *_soundReceiverAngle3; // 148
- MystResourceType8 *_soundReceiverAngle4; // 152
- MystResourceType8 *_soundReceiverSigmaButton; // 156
+ MystAreaImageSwitch *_soundReceiverViewer; // 128
+ MystAreaImageSwitch *_soundReceiverRightButton; // 132
+ MystAreaImageSwitch *_soundReceiverLeftButton; // 136
+ MystAreaImageSwitch *_soundReceiverAngle1; // 140
+ MystAreaImageSwitch *_soundReceiverAngle2; // 144
+ MystAreaImageSwitch *_soundReceiverAngle3; // 148
+ MystAreaImageSwitch *_soundReceiverAngle4; // 152
+ MystAreaImageSwitch *_soundReceiverSigmaButton; // 156
static const uint16 _mazeRunnerMap[300][4];
static const uint8 _mazeRunnerVideos[300][4];
uint16 _mazeRunnerPosition; // 56
uint16 _mazeRunnerDirection; // 58
- MystResourceType8 *_mazeRunnerWindow; // 68
- MystResourceType8 *_mazeRunnerCompass; // 72
- MystResourceType8 *_mazeRunnerLight; // 76
- MystResourceType8 *_mazeRunnerRightButton; // 80
- MystResourceType8 *_mazeRunnerLeftButton; // 84
+ MystAreaImageSwitch *_mazeRunnerWindow; // 68
+ MystAreaImageSwitch *_mazeRunnerCompass; // 72
+ MystAreaImageSwitch *_mazeRunnerLight; // 76
+ MystAreaImageSwitch *_mazeRunnerRightButton; // 80
+ MystAreaImageSwitch *_mazeRunnerLeftButton; // 84
bool _mazeRunnerDoorOpened; // 160
uint16 _soundLockSoundId;
- MystResourceType10 *_soundLockSlider1; // 164
- MystResourceType10 *_soundLockSlider2; // 168
- MystResourceType10 *_soundLockSlider3; // 172
- MystResourceType10 *_soundLockSlider4; // 176
- MystResourceType10 *_soundLockSlider5; // 180
- MystResourceType8 *_soundLockButton; // 184
+ MystAreaSlider *_soundLockSlider1; // 164
+ MystAreaSlider *_soundLockSlider2; // 168
+ MystAreaSlider *_soundLockSlider3; // 172
+ MystAreaSlider *_soundLockSlider4; // 176
+ MystAreaSlider *_soundLockSlider5; // 180
+ MystAreaImageSwitch *_soundLockButton; // 184
void soundReceiverLeftRight(uint direction);
void soundReceiverUpdate();
@@ -125,8 +125,8 @@ private:
void soundReceiverSolution(uint16 source, uint16 &solution, bool &enabled);
uint16 soundLockCurrentSound(uint16 position, bool pixels);
- MystResourceType10 *soundLockSliderFromVar(uint16 var);
- void soundLockCheckSolution(MystResourceType10 *slider, uint16 value, uint16 solution, bool &solved);
+ MystAreaSlider *soundLockSliderFromVar(uint16 var);
+ void soundLockCheckSolution(MystAreaSlider *slider, uint16 value, uint16 solution, bool &solved);
bool mazeRunnerForwardAllowed(uint16 position);
void mazeRunnerUpdateCompass();
diff --git a/engines/mohawk/myst_stacks/stoneship.cpp b/engines/mohawk/myst_stacks/stoneship.cpp
index 1113cee..d20ed32 100644
--- a/engines/mohawk/myst_stacks/stoneship.cpp
+++ b/engines/mohawk/myst_stacks/stoneship.cpp
@@ -402,9 +402,9 @@ void Stoneship::o_pumpTurnOff(uint16 op, uint16 var, uint16 argc, uint16 *argv)
}
for (uint i = 0; i < _vm->_resources.size(); i++) {
- MystResource *resource = _vm->_resources[i];
- if (resource->type == kMystConditionalImage && resource->getType8Var() == buttonVar) {
- static_cast<MystResourceType8 *>(resource)->drawConditionalDataToScreen(0, true);
+ MystArea *resource = _vm->_resources[i];
+ if (resource->type == kMystAreaImageSwitch && resource->getImageSwitchVar() == buttonVar) {
+ static_cast<MystAreaImageSwitch *>(resource)->drawConditionalDataToScreen(0, true);
break;
}
}
@@ -437,9 +437,9 @@ void Stoneship::o_cabinBookMovie(uint16 op, uint16 var, uint16 argc, uint16 *arg
void Stoneship::o_drawerOpenSirius(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Open drawer", op);
- MystResourceType8 *drawer = static_cast<MystResourceType8 *>(_vm->_resources[argv[0]]);
+ MystAreaImageSwitch *drawer = static_cast<MystAreaImageSwitch *>(_vm->_resources[argv[0]]);
- if (drawer->getType8Var() == 35) {
+ if (drawer->getImageSwitchVar() == 35) {
drawer->drawConditionalDataToScreen(getVar(102), 0);
} else {
drawer->drawConditionalDataToScreen(0, 0);
@@ -466,7 +466,7 @@ void Stoneship::o_telescopeStart(uint16 op, uint16 var, uint16 argc, uint16 *arg
void Stoneship::o_telescopeMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Telescope move", op);
- MystResourceType11 *display = static_cast<MystResourceType11 *>(_invokingResource);
+ MystAreaDrag *display = static_cast<MystAreaDrag *>(_invokingResource);
const Common::Point &mouse = _vm->_system->getEventManager()->getMousePos();
// Compute telescope position
@@ -489,7 +489,7 @@ void Stoneship::o_telescopeStop(uint16 op, uint16 var, uint16 argc, uint16 *argv
void Stoneship::o_generatorStart(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Generator start", op);
- MystResourceType11 *handle = static_cast<MystResourceType11 *>(_invokingResource);
+ MystAreaDrag *handle = static_cast<MystAreaDrag *>(_invokingResource);
uint16 soundId = handle->getList1(0);
if (soundId)
@@ -504,7 +504,7 @@ void Stoneship::o_generatorStart(uint16 op, uint16 var, uint16 argc, uint16 *arg
_batteryNextTime = _vm->_system->getMillis() + 1000;
// Start handle movie
- MystResourceType6 *movie = static_cast<MystResourceType6 *>(handle->getSubResource(0));
+ MystAreaVideo *movie = static_cast<MystAreaVideo *>(handle->getSubResource(0));
movie->playMovie();
soundId = handle->getList2(0);
@@ -530,8 +530,8 @@ void Stoneship::o_generatorStop(uint16 op, uint16 var, uint16 argc, uint16 *argv
}
// Pause handle movie
- MystResourceType11 *handle = static_cast<MystResourceType11 *>(_invokingResource);
- MystResourceType6 *movie = static_cast<MystResourceType6 *>(handle->getSubResource(0));
+ MystAreaDrag *handle = static_cast<MystAreaDrag *>(_invokingResource);
+ MystAreaVideo *movie = static_cast<MystAreaVideo *>(handle->getSubResource(0));
movie->pauseMovie(true);
uint16 soundId = handle->getList3(0);
@@ -582,7 +582,7 @@ void Stoneship::batteryDeplete_run() {
void Stoneship::o_drawerOpenAchenar(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Open drawer", op);
- MystResourceType8 *drawer = static_cast<MystResourceType8 *>(_vm->_resources[argv[0]]);
+ MystAreaImageSwitch *drawer = static_cast<MystAreaImageSwitch *>(_vm->_resources[argv[0]]);
drawer->drawConditionalDataToScreen(0, 0);
_vm->_gfx->runTransition(kTransitionTopToBottom, drawer->getRect(), 25, 5);
}
@@ -617,7 +617,7 @@ void Stoneship::o_hologramSelectionStart(uint16 op, uint16 var, uint16 argc, uin
void Stoneship::o_hologramSelectionMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Hologram move", op);
- MystResourceType11 *handle = static_cast<MystResourceType11 *>(_invokingResource);
+ MystAreaDrag *handle = static_cast<MystAreaDrag *>(_invokingResource);
const Common::Point &mouse = _vm->_system->getEventManager()->getMousePos();
if (handle->getRect().contains(mouse)) {
@@ -822,20 +822,20 @@ void Stoneship::drawerClose(uint16 drawer) {
_vm->drawCardBackground();
_vm->drawResourceImages();
- MystResource *res = _vm->_resources[drawer];
+ MystArea *res = _vm->_resources[drawer];
_vm->_gfx->runTransition(kTransitionBottomToTop, res->getRect(), 25, 5);
}
void Stoneship::o_hologramDisplay_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Hologram display init", op);
- _hologramDisplay = static_cast<MystResourceType6 *>(_invokingResource);
+ _hologramDisplay = static_cast<MystAreaVideo *>(_invokingResource);
_hologramDisplayPos = 0;
}
void Stoneship::o_hologramSelection_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Hologram selection init", op);
- _hologramSelection = static_cast<MystResourceType6 *>(_invokingResource);
+ _hologramSelection = static_cast<MystAreaVideo *>(_invokingResource);
}
void Stoneship::batteryGaugeUpdate() {
@@ -856,7 +856,7 @@ void Stoneship::o_battery_init(uint16 op, uint16 var, uint16 argc, uint16 *argv)
// Used for Card 2160 (Lighthouse Battery Pack Closeup)
debugC(kDebugScript, "Opcode %d: Battery init", op);
- _batteryGauge = static_cast<MystResourceType8 *>(_invokingResource);
+ _batteryGauge = static_cast<MystAreaImageSwitch *>(_invokingResource);
batteryGaugeUpdate();
}
@@ -1014,7 +1014,7 @@ void Stoneship::o_achenarDrawers_init(uint16 op, uint16 var, uint16 argc, uint16
void Stoneship::o_cloudOrb_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Cloud orb init", op);
- _cloudOrbMovie = static_cast<MystResourceType6 *>(_invokingResource);
+ _cloudOrbMovie = static_cast<MystAreaVideo *>(_invokingResource);
_cloudOrbSound = argv[0];
_cloudOrbStopSound = argv[1];
}
diff --git a/engines/mohawk/myst_stacks/stoneship.h b/engines/mohawk/myst_stacks/stoneship.h
index b77776f..776641a 100644
--- a/engines/mohawk/myst_stacks/stoneship.h
+++ b/engines/mohawk/myst_stacks/stoneship.h
@@ -98,7 +98,7 @@ private:
bool _batteryGaugeRunning;
uint16 _batteryLastCharge; // 92
- MystResourceType8 *_batteryGauge; // 96
+ MystAreaImageSwitch *_batteryGauge; // 96
void batteryGaugeUpdate();
void batteryGauge_run();
@@ -113,8 +113,8 @@ private:
void drawerClose(uint16 drawer);
uint16 _hologramTurnedOn; // 80
- MystResourceType6 *_hologramDisplay; // 84
- MystResourceType6 *_hologramSelection; // 88
+ MystAreaVideo *_hologramDisplay; // 84
+ MystAreaVideo *_hologramSelection; // 88
uint16 _hologramDisplayPos;
bool _tunnelRunning;
@@ -135,7 +135,7 @@ private:
void telescope_run();
void telescopeLighthouseDraw();
- MystResourceType6 *_cloudOrbMovie; // 136
+ MystAreaVideo *_cloudOrbMovie; // 136
uint16 _cloudOrbSound; // 140
uint16 _cloudOrbStopSound; // 142
Commit: ae93f2426763e7965caf5484682d7ad98ffbf4b0
https://github.com/scummvm/scummvm/commit/ae93f2426763e7965caf5484682d7ad98ffbf4b0
Author: Bastien Bouclet (bastien.bouclet at gmail.com)
Date: 2016-02-07T15:27:03+01:00
Commit Message:
MOHAWK: Turn MystAreaDrag::ValueList into a Common::Array
Changed paths:
engines/mohawk/myst_areas.cpp
engines/mohawk/myst_areas.h
diff --git a/engines/mohawk/myst_areas.cpp b/engines/mohawk/myst_areas.cpp
index 298fc56..00c1629 100644
--- a/engines/mohawk/myst_areas.cpp
+++ b/engines/mohawk/myst_areas.cpp
@@ -702,16 +702,15 @@ MystAreaDrag::MystAreaDrag(MohawkEngine_Myst *vm, Common::SeekableReadStream *rl
debugCN(kDebugResource, "Type 11 _mouseDragOpcode: %d\n", _mouseDragOpcode);
debugCN(kDebugResource, "Type 11 _mouseUpOpcode: %d\n", _mouseUpOpcode);
- for (byte i = 0; i < 3; i++) {
+ for (byte i = 0; i < ARRAYSIZE(_lists); i++) {
debugC(kDebugResource, "\tList %d:", i);
- _lists[i].listCount = rlstStream->readUint16LE();
- debugC(kDebugResource, "\t%d values", _lists[i].listCount);
+ uint16 listCount = rlstStream->readUint16LE();
+ debugC(kDebugResource, "\t%d values", listCount);
- _lists[i].list = new uint16[_lists[i].listCount];
- for (uint16 j = 0; j < _lists[i].listCount; j++) {
- _lists[i].list[j] = rlstStream->readUint16LE();
- debugC(kDebugResource, "\tValue %d: %d", j, _lists[i].list[j]);
+ for (uint16 j = 0; j < listCount; j++) {
+ _lists[i].push_back(rlstStream->readUint16LE());
+ debugC(kDebugResource, "\tValue %d: %d", j, _lists[i][j]);
}
}
@@ -726,8 +725,6 @@ MystAreaDrag::MystAreaDrag(MohawkEngine_Myst *vm, Common::SeekableReadStream *rl
}
MystAreaDrag::~MystAreaDrag() {
- for (byte i = 0; i < 3; i++)
- delete[] _lists[i].list;
}
void MystAreaDrag::handleMouseDown() {
@@ -771,15 +768,15 @@ void MystAreaDrag::setPositionClipping(const Common::Point &mouse, Common::Point
}
uint16 MystAreaDrag::getList1(uint16 index) {
- return (index < _lists[0].listCount) ? _lists[0].list[index] : 0;
+ return (index < _lists[0].size()) ? _lists[0][index] : 0;
}
uint16 MystAreaDrag::getList2(uint16 index) {
- return (index < _lists[1].listCount) ? _lists[1].list[index] : 0;
+ return (index < _lists[1].size()) ? _lists[1][index] : 0;
}
uint16 MystAreaDrag::getList3(uint16 index) {
- return (index < _lists[2].listCount) ? _lists[2].list[index] : 0;
+ return (index < _lists[2].size()) ? _lists[2][index] : 0;
}
MystVideoInfo::MystVideoInfo(MohawkEngine_Myst *vm, Common::SeekableReadStream *rlstStream, MystArea *parent) :
diff --git a/engines/mohawk/myst_areas.h b/engines/mohawk/myst_areas.h
index 2b16b6e..80bfb3b 100644
--- a/engines/mohawk/myst_areas.h
+++ b/engines/mohawk/myst_areas.h
@@ -189,10 +189,7 @@ public:
Common::Point _pos;
protected:
- struct ValueList {
- uint16 listCount;
- uint16 *list;
- };
+ typedef Common::Array<uint16> ValueList;
void setPositionClipping(const Common::Point &mouse, Common::Point &dest);
Commit: afdcbbae9866d92a434172635d7732b4bb118bdd
https://github.com/scummvm/scummvm/commit/afdcbbae9866d92a434172635d7732b4bb118bdd
Author: Bastien Bouclet (bastien.bouclet at gmail.com)
Date: 2016-02-07T15:27:03+01:00
Commit Message:
MOHAWK: Remove MystAreaImageSwitch::_numSubImages
Changed paths:
engines/mohawk/myst_areas.cpp
engines/mohawk/myst_areas.h
diff --git a/engines/mohawk/myst_areas.cpp b/engines/mohawk/myst_areas.cpp
index 00c1629..824aa42 100644
--- a/engines/mohawk/myst_areas.cpp
+++ b/engines/mohawk/myst_areas.cpp
@@ -369,11 +369,11 @@ void MystAreaActionSwitch::handleMouseDown() {
MystAreaImageSwitch::MystAreaImageSwitch(MohawkEngine_Myst *vm, Common::SeekableReadStream *rlstStream, MystArea *parent) :
MystAreaActionSwitch(vm, rlstStream, parent) {
_imageSwitchVar = rlstStream->readUint16LE();
- _numSubImages = rlstStream->readUint16LE();
+ uint16 numSubImages = rlstStream->readUint16LE();
debugC(kDebugResource, "\tvar8: %d", _imageSwitchVar);
- debugC(kDebugResource, "\tnumSubImages: %d", _numSubImages);
+ debugC(kDebugResource, "\tnumSubImages: %d", numSubImages);
- for (uint16 i = 0; i < _numSubImages; i++) {
+ for (uint16 i = 0; i < numSubImages; i++) {
debugC(kDebugResource, "\tSubimage %d:", i);
SubImage subImage;
@@ -415,23 +415,23 @@ void MystAreaImageSwitch::drawDataToScreen() {
int16 subImageId = 0;
if (_imageSwitchVar == 0xFFFF) {
- if (_numSubImages == 1) {
+ if (_subImages.size() == 1) {
subImageId = 0;
drawSubImage = true;
- } else if (_numSubImages != 0)
- warning("Type 8 Resource with _numSubImages of %d, but no control variable", _numSubImages);
+ } else if (_subImages.size() != 0)
+ warning("Image Switch resource with _numSubImages of %d, but no control variable", _subImages.size());
} else {
uint16 varValue = _vm->_scriptParser->getVar(_imageSwitchVar);
- if (_numSubImages == 1 && varValue != 0) {
+ if (_subImages.size() == 1 && varValue != 0) {
subImageId = 0;
drawSubImage = true;
- } else if (_numSubImages != 0) {
- if (varValue < _numSubImages) {
+ } else if (_subImages.size() != 0) {
+ if (varValue < _subImages.size()) {
subImageId = varValue;
drawSubImage = true;
} else
- warning("Type 8 Image Var %d: %d exceeds number of subImages %d", _imageSwitchVar, varValue, _numSubImages);
+ warning("Image Switch Var %d: %d exceeds number of subImages %d", _imageSwitchVar, varValue, _subImages.size());
}
}
@@ -451,15 +451,15 @@ void MystAreaImageSwitch::drawConditionalDataToScreen(uint16 state, bool update)
int16 subImageId = 0;
- if (_numSubImages == 1 && state != 0) {
+ if (_subImages.size() == 1 && state != 0) {
subImageId = 0;
drawSubImage = true;
- } else if (_numSubImages != 0) {
- if (state < _numSubImages) {
+ } else if (_subImages.size() != 0) {
+ if (state < _subImages.size()) {
subImageId = state;
drawSubImage = true;
} else
- warning("Type 8 Image Var %d: %d exceeds number of subImages %d", _imageSwitchVar, state, _numSubImages);
+ warning("Image Switch Var %d: %d exceeds number of subImages %d", _imageSwitchVar, state, _subImages.size());
}
@@ -496,10 +496,10 @@ const Common::String MystAreaImageSwitch::describe() {
Common::String desc = Common::String::format("%s var: %2d",
MystAreaActionSwitch::describe().c_str(), _imageSwitchVar);
- if (_numSubImages > 0) {
+ if (_subImages.size() > 0) {
desc += " subImgs:";
- for (uint i = 0; i < _numSubImages; i++)
+ for (uint i = 0; i < _subImages.size(); i++)
desc += Common::String::format(" %d", (int16)_subImages[i].wdib);
}
diff --git a/engines/mohawk/myst_areas.h b/engines/mohawk/myst_areas.h
index 80bfb3b..dfaa90e 100644
--- a/engines/mohawk/myst_areas.h
+++ b/engines/mohawk/myst_areas.h
@@ -165,7 +165,6 @@ public:
protected:
uint16 _imageSwitchVar;
- uint16 _numSubImages;
Common::Array<SubImage> _subImages;
};
Commit: 91097d735ef4a1f5645c2918a7d136b64364ef91
https://github.com/scummvm/scummvm/commit/91097d735ef4a1f5645c2918a7d136b64364ef91
Author: Bastien Bouclet (bastien.bouclet at gmail.com)
Date: 2016-02-07T15:27:03+01:00
Commit Message:
MOHAWK: Factor the MystAreaActionSwitch switch code
Changed paths:
engines/mohawk/myst_areas.cpp
engines/mohawk/myst_areas.h
diff --git a/engines/mohawk/myst_areas.cpp b/engines/mohawk/myst_areas.cpp
index 824aa42..cfaaccc 100644
--- a/engines/mohawk/myst_areas.cpp
+++ b/engines/mohawk/myst_areas.cpp
@@ -284,86 +284,40 @@ MystAreaActionSwitch::~MystAreaActionSwitch() {
_subResources.clear();
}
-// TODO: All these functions to switch subresource are very similar.
-// Find way to share code (function pointer pass?)
-void MystAreaActionSwitch::drawDataToScreen() {
+void MystAreaActionSwitch::doSwitch(AreaHandler handler) {
if (_actionSwitchVar == 0xFFFF) {
if (_numSubResources == 1)
- _subResources[0]->drawDataToScreen();
+ (_subResources[0]->*handler)();
else if (_numSubResources != 0)
- warning("Type 7 Resource with _numSubResources of %d, but no control variable", _numSubResources);
+ warning("Action switch resource with _numSubResources of %d, but no control variable", _numSubResources);
} else {
uint16 varValue = _vm->_scriptParser->getVar(_actionSwitchVar);
if (_numSubResources == 1 && varValue != 0)
- _subResources[0]->drawDataToScreen();
+ (_subResources[0]->*handler)();
else if (_numSubResources != 0) {
if (varValue < _numSubResources)
- _subResources[varValue]->drawDataToScreen();
+ (_subResources[varValue]->*handler)();
else
- warning("Type 7 Resource Var %d: %d exceeds number of sub resources %d", _actionSwitchVar, varValue, _numSubResources);
+ warning("Action switch resource Var %d: %d exceeds number of sub resources %d", _actionSwitchVar, varValue, _numSubResources);
}
}
}
-void MystAreaActionSwitch::handleCardChange() {
- if (_actionSwitchVar == 0xFFFF) {
- if (_numSubResources == 1)
- _subResources[0]->handleCardChange();
- else if (_numSubResources != 0)
- warning("Type 7 Resource with _numSubResources of %d, but no control variable", _numSubResources);
- } else {
- uint16 varValue = _vm->_scriptParser->getVar(_actionSwitchVar);
+void MystAreaActionSwitch::drawDataToScreen() {
+ doSwitch(&MystArea::drawDataToScreen);
+}
- if (_numSubResources == 1 && varValue != 0)
- _subResources[0]->handleCardChange();
- else if (_numSubResources != 0) {
- if (varValue < _numSubResources)
- _subResources[varValue]->handleCardChange();
- else
- warning("Type 7 Resource Var %d: %d exceeds number of sub resources %d", _actionSwitchVar, varValue, _numSubResources);
- }
- }
+void MystAreaActionSwitch::handleCardChange() {
+ doSwitch(&MystArea::handleCardChange);
}
void MystAreaActionSwitch::handleMouseUp() {
- if (_actionSwitchVar == 0xFFFF) {
- if (_numSubResources == 1)
- _subResources[0]->handleMouseUp();
- else if (_numSubResources != 0)
- warning("Type 7 Resource with _numSubResources of %d, but no control variable", _numSubResources);
- } else {
- uint16 varValue = _vm->_scriptParser->getVar(_actionSwitchVar);
-
- if (_numSubResources == 1 && varValue != 0)
- _subResources[0]->handleMouseUp();
- else if (_numSubResources != 0) {
- if (varValue < _numSubResources)
- _subResources[varValue]->handleMouseUp();
- else
- warning("Type 7 Resource Var %d: %d exceeds number of sub resources %d", _actionSwitchVar, varValue, _numSubResources);
- }
- }
+ doSwitch(&MystArea::handleMouseUp);
}
void MystAreaActionSwitch::handleMouseDown() {
- if (_actionSwitchVar == 0xFFFF) {
- if (_numSubResources == 1)
- _subResources[0]->handleMouseDown();
- else if (_numSubResources != 0)
- warning("Type 7 Resource with _numSubResources of %d, but no control variable", _numSubResources);
- } else {
- uint16 varValue = _vm->_scriptParser->getVar(_actionSwitchVar);
-
- if (_numSubResources == 1 && varValue != 0)
- _subResources[0]->handleMouseDown();
- else if (_numSubResources != 0) {
- if (varValue < _numSubResources)
- _subResources[varValue]->handleMouseDown();
- else
- warning("Type 7 Resource Var %d: %d exceeds number of sub resources %d", _actionSwitchVar, varValue, _numSubResources);
- }
- }
+ doSwitch(&MystArea::handleMouseDown);
}
MystAreaImageSwitch::MystAreaImageSwitch(MohawkEngine_Myst *vm, Common::SeekableReadStream *rlstStream, MystArea *parent) :
@@ -407,7 +361,7 @@ MystAreaImageSwitch::~MystAreaImageSwitch() {
}
void MystAreaImageSwitch::drawDataToScreen() {
- // Need to call overidden Type 7 function to ensure
+ // Need to call overridden function to ensure
// switch section is processed correctly.
MystAreaActionSwitch::drawDataToScreen();
diff --git a/engines/mohawk/myst_areas.h b/engines/mohawk/myst_areas.h
index dfaa90e..b4b6fab 100644
--- a/engines/mohawk/myst_areas.h
+++ b/engines/mohawk/myst_areas.h
@@ -140,6 +140,10 @@ public:
MystArea *getSubResource(uint16 index) { return _subResources[index]; }
protected:
+ typedef void (MystArea::*AreaHandler)();
+
+ void doSwitch(AreaHandler handler);
+
uint16 _actionSwitchVar;
uint16 _numSubResources;
Common::Array<MystArea *> _subResources;
Commit: e9bab23c795622459ba43cb1c970459467727702
https://github.com/scummvm/scummvm/commit/e9bab23c795622459ba43cb1c970459467727702
Author: Bastien Bouclet (bastien.bouclet at gmail.com)
Date: 2016-02-07T15:27:03+01:00
Commit Message:
MOHAWK: Remove MystAreaActionSwitch::_numSubResources
Changed paths:
engines/mohawk/myst_areas.cpp
engines/mohawk/myst_areas.h
diff --git a/engines/mohawk/myst_areas.cpp b/engines/mohawk/myst_areas.cpp
index cfaaccc..f8ee56f 100644
--- a/engines/mohawk/myst_areas.cpp
+++ b/engines/mohawk/myst_areas.cpp
@@ -269,11 +269,11 @@ void MystAreaVideo::pauseMovie(bool pause) {
MystAreaActionSwitch::MystAreaActionSwitch(MohawkEngine_Myst *vm, Common::SeekableReadStream *rlstStream, MystArea *parent) :
MystArea(vm, rlstStream, parent) {
_actionSwitchVar = rlstStream->readUint16LE();
- _numSubResources = rlstStream->readUint16LE();
- debugC(kDebugResource, "\tvar7: %d", _actionSwitchVar);
- debugC(kDebugResource, "\tnumSubResources: %d", _numSubResources);
+ uint16 numSubResources = rlstStream->readUint16LE();
+ debugC(kDebugResource, "\tactionSwitchVar: %d", _actionSwitchVar);
+ debugC(kDebugResource, "\tnumSubResources: %d", numSubResources);
- for (uint16 i = 0; i < _numSubResources; i++)
+ for (uint16 i = 0; i < numSubResources; i++)
_subResources.push_back(vm->loadResource(rlstStream, this));
}
@@ -286,20 +286,20 @@ MystAreaActionSwitch::~MystAreaActionSwitch() {
void MystAreaActionSwitch::doSwitch(AreaHandler handler) {
if (_actionSwitchVar == 0xFFFF) {
- if (_numSubResources == 1)
+ if (_subResources.size() == 1)
(_subResources[0]->*handler)();
- else if (_numSubResources != 0)
- warning("Action switch resource with _numSubResources of %d, but no control variable", _numSubResources);
+ else if (_subResources.size() != 0)
+ warning("Action switch resource with _numSubResources of %d, but no control variable", _subResources.size());
} else {
uint16 varValue = _vm->_scriptParser->getVar(_actionSwitchVar);
- if (_numSubResources == 1 && varValue != 0)
+ if (_subResources.size() == 1 && varValue != 0)
(_subResources[0]->*handler)();
- else if (_numSubResources != 0) {
- if (varValue < _numSubResources)
+ else if (_subResources.size() != 0) {
+ if (varValue < _subResources.size())
(_subResources[varValue]->*handler)();
else
- warning("Action switch resource Var %d: %d exceeds number of sub resources %d", _actionSwitchVar, varValue, _numSubResources);
+ warning("Action switch resource Var %d: %d exceeds number of sub resources %d", _actionSwitchVar, varValue, _subResources.size());
}
}
}
diff --git a/engines/mohawk/myst_areas.h b/engines/mohawk/myst_areas.h
index b4b6fab..63357e5 100644
--- a/engines/mohawk/myst_areas.h
+++ b/engines/mohawk/myst_areas.h
@@ -145,7 +145,6 @@ protected:
void doSwitch(AreaHandler handler);
uint16 _actionSwitchVar;
- uint16 _numSubResources;
Common::Array<MystArea *> _subResources;
};
Commit: 989fe4d0cd88e3d25ad983c8513c4a386fc63e2b
https://github.com/scummvm/scummvm/commit/989fe4d0cd88e3d25ad983c8513c4a386fc63e2b
Author: Bastien Bouclet (bastien.bouclet at gmail.com)
Date: 2016-02-07T15:27:03+01:00
Commit Message:
MOHAWK: Turn MystView::conditionalImages into a Common::Array
Changed paths:
engines/mohawk/myst.cpp
engines/mohawk/myst.h
diff --git a/engines/mohawk/myst.cpp b/engines/mohawk/myst.cpp
index 3b132cf..a6b0908 100644
--- a/engines/mohawk/myst.cpp
+++ b/engines/mohawk/myst.cpp
@@ -91,8 +91,6 @@ MohawkEngine_Myst::MohawkEngine_Myst(OSystem *syst, const MohawkGameDescription
_prevStack = nullptr;
- _view.conditionalImageCount = 0;
- _view.conditionalImages = nullptr;
_view.soundList = nullptr;
_view.soundListVolume = nullptr;
_view.scriptResCount = 0;
@@ -113,8 +111,7 @@ MohawkEngine_Myst::~MohawkEngine_Myst() {
delete[] _cursorHints;
- delete[] _view.conditionalImages;
- delete[] _view.scriptResources;
+ unloadCard();
for (uint32 i = 0; i < _resources.size(); i++)
delete _resources[i];
@@ -538,10 +535,10 @@ void MohawkEngine_Myst::changeToStack(uint16 stack, uint16 card, uint16 linkSrcS
uint16 MohawkEngine_Myst::getCardBackgroundId() {
uint16 imageToDraw = 0;
- if (_view.conditionalImageCount == 0)
+ if (_view.conditionalImages.size() == 0)
imageToDraw = _view.mainImage;
else {
- for (uint16 i = 0; i < _view.conditionalImageCount; i++) {
+ for (uint16 i = 0; i < _view.conditionalImages.size(); i++) {
uint16 varValue = _scriptParser->getVar(_view.conditionalImages[i].var);
if (varValue < _view.conditionalImages[i].numStates)
imageToDraw = _view.conditionalImages[i].values[varValue];
@@ -711,21 +708,24 @@ void MohawkEngine_Myst::loadCard() {
debugC(kDebugView, "Flags: 0x%04X", _view.flags);
// The Image Block (Reminiscent of Riven PLST resources)
- _view.conditionalImageCount = viewStream->readUint16LE();
- debugC(kDebugView, "Conditional Image Count: %d", _view.conditionalImageCount);
- if (_view.conditionalImageCount != 0) {
- _view.conditionalImages = new MystCondition[_view.conditionalImageCount];
- for (uint16 i = 0; i < _view.conditionalImageCount; i++) {
+ uint16 conditionalImageCount = viewStream->readUint16LE();
+ debugC(kDebugView, "Conditional Image Count: %d", conditionalImageCount);
+ if (conditionalImageCount != 0) {
+ for (uint16 i = 0; i < conditionalImageCount; i++) {
+ MystCondition conditionalImage;
+
debugC(kDebugView, "\tImage %d:", i);
- _view.conditionalImages[i].var = viewStream->readUint16LE();
- debugC(kDebugView, "\t\tVar: %d", _view.conditionalImages[i].var);
- _view.conditionalImages[i].numStates = viewStream->readUint16LE();
- debugC(kDebugView, "\t\tNumber of States: %d", _view.conditionalImages[i].numStates);
- _view.conditionalImages[i].values = new uint16[_view.conditionalImages[i].numStates];
- for (uint16 j = 0; j < _view.conditionalImages[i].numStates; j++) {
- _view.conditionalImages[i].values[j] = viewStream->readUint16LE();
- debugC(kDebugView, "\t\tState %d -> Value %d", j, _view.conditionalImages[i].values[j]);
+ conditionalImage.var = viewStream->readUint16LE();
+ debugC(kDebugView, "\t\tVar: %d", conditionalImage.var);
+ conditionalImage.numStates = viewStream->readUint16LE();
+ debugC(kDebugView, "\t\tNumber of States: %d", conditionalImage.numStates);
+ conditionalImage.values = new uint16[conditionalImage.numStates];
+ for (uint16 j = 0; j < conditionalImage.numStates; j++) {
+ conditionalImage.values[j] = viewStream->readUint16LE();
+ debugC(kDebugView, "\t\tState %d -> Value %d", j, conditionalImage.values[j]);
}
+
+ _view.conditionalImages.push_back(conditionalImage);
}
_view.mainImage = 0;
} else {
@@ -837,8 +837,8 @@ void MohawkEngine_Myst::loadCard() {
cacheImageType = ID_WDIB;
// Precache Image Block data
- if (_view.conditionalImageCount != 0) {
- for (uint16 i = 0; i < _view.conditionalImageCount; i++)
+ if (_view.conditionalImages.size() != 0) {
+ for (uint16 i = 0; i < _view.conditionalImages.size(); i++)
for (uint16 j = 0; j < _view.conditionalImages[i].numStates; j++)
cachePreload(cacheImageType, _view.conditionalImages[i].values[j]);
} else
@@ -876,12 +876,10 @@ void MohawkEngine_Myst::loadCard() {
}
void MohawkEngine_Myst::unloadCard() {
- for (uint16 i = 0; i < _view.conditionalImageCount; i++)
+ for (uint16 i = 0; i < _view.conditionalImages.size(); i++)
delete[] _view.conditionalImages[i].values;
- delete[] _view.conditionalImages;
- _view.conditionalImageCount = 0;
- _view.conditionalImages = nullptr;
+ _view.conditionalImages.clear();
delete[] _view.soundList;
_view.soundList = nullptr;
diff --git a/engines/mohawk/myst.h b/engines/mohawk/myst.h
index 1cf5858..6e1cbef 100644
--- a/engines/mohawk/myst.h
+++ b/engines/mohawk/myst.h
@@ -118,8 +118,7 @@ struct MystView {
uint16 flags;
// Image Data
- uint16 conditionalImageCount;
- MystCondition *conditionalImages;
+ Common::Array<MystCondition> conditionalImages;
uint16 mainImage;
// Sound Data
Commit: ef14781456a100956ea9bf52da23a416f59cc44b
https://github.com/scummvm/scummvm/commit/ef14781456a100956ea9bf52da23a416f59cc44b
Author: Bastien Bouclet (bastien.bouclet at gmail.com)
Date: 2016-02-07T15:27:03+01:00
Commit Message:
MOHAWK: Turn MystCondition::values into a Common::Array
Changed paths:
engines/mohawk/myst.cpp
engines/mohawk/myst.h
diff --git a/engines/mohawk/myst.cpp b/engines/mohawk/myst.cpp
index a6b0908..7868434 100644
--- a/engines/mohawk/myst.cpp
+++ b/engines/mohawk/myst.cpp
@@ -540,7 +540,7 @@ uint16 MohawkEngine_Myst::getCardBackgroundId() {
else {
for (uint16 i = 0; i < _view.conditionalImages.size(); i++) {
uint16 varValue = _scriptParser->getVar(_view.conditionalImages[i].var);
- if (varValue < _view.conditionalImages[i].numStates)
+ if (varValue < _view.conditionalImages[i].values.size())
imageToDraw = _view.conditionalImages[i].values[varValue];
}
}
@@ -717,11 +717,10 @@ void MohawkEngine_Myst::loadCard() {
debugC(kDebugView, "\tImage %d:", i);
conditionalImage.var = viewStream->readUint16LE();
debugC(kDebugView, "\t\tVar: %d", conditionalImage.var);
- conditionalImage.numStates = viewStream->readUint16LE();
- debugC(kDebugView, "\t\tNumber of States: %d", conditionalImage.numStates);
- conditionalImage.values = new uint16[conditionalImage.numStates];
- for (uint16 j = 0; j < conditionalImage.numStates; j++) {
- conditionalImage.values[j] = viewStream->readUint16LE();
+ uint16 numStates = viewStream->readUint16LE();
+ debugC(kDebugView, "\t\tNumber of States: %d", numStates);
+ for (uint16 j = 0; j < numStates; j++) {
+ conditionalImage.values.push_back(viewStream->readUint16LE());
debugC(kDebugView, "\t\tState %d -> Value %d", j, conditionalImage.values[j]);
}
@@ -839,7 +838,7 @@ void MohawkEngine_Myst::loadCard() {
// Precache Image Block data
if (_view.conditionalImages.size() != 0) {
for (uint16 i = 0; i < _view.conditionalImages.size(); i++)
- for (uint16 j = 0; j < _view.conditionalImages[i].numStates; j++)
+ for (uint16 j = 0; j < _view.conditionalImages[i].values.size(); j++)
cachePreload(cacheImageType, _view.conditionalImages[i].values[j]);
} else
cachePreload(cacheImageType, _view.mainImage);
@@ -876,9 +875,6 @@ void MohawkEngine_Myst::loadCard() {
}
void MohawkEngine_Myst::unloadCard() {
- for (uint16 i = 0; i < _view.conditionalImages.size(); i++)
- delete[] _view.conditionalImages[i].values;
-
_view.conditionalImages.clear();
delete[] _view.soundList;
@@ -967,8 +963,6 @@ void MohawkEngine_Myst::loadHelp(uint16 id) {
}
void MohawkEngine_Myst::loadCursorHints() {
- for (uint16 i = 0; i < _cursorHintCount; i++)
- delete[] _cursorHints[i].variableHint.values;
_cursorHintCount = 0;
delete[] _cursorHints;
_cursorHints = nullptr;
@@ -996,17 +990,14 @@ void MohawkEngine_Myst::loadCursorHints() {
debugC(kDebugHint, "\tConditional Cursor Hints:");
_cursorHints[i].variableHint.var = hintStream->readUint16LE();
debugC(kDebugHint, "\tVar: %d", _cursorHints[i].variableHint.var);
- _cursorHints[i].variableHint.numStates = hintStream->readUint16LE();
- debugC(kDebugHint, "\tNumber of States: %d", _cursorHints[i].variableHint.numStates);
- _cursorHints[i].variableHint.values = new uint16[_cursorHints[i].variableHint.numStates];
- for (uint16 j = 0; j < _cursorHints[i].variableHint.numStates; j++) {
- _cursorHints[i].variableHint.values[j] = hintStream->readUint16LE();
+ uint16 numStates = hintStream->readUint16LE();
+ debugC(kDebugHint, "\tNumber of States: %d", numStates);
+ for (uint16 j = 0; j < numStates; j++) {
+ _cursorHints[i].variableHint.values.push_back(hintStream->readUint16LE());
debugC(kDebugHint, "\t\t State %d: Cursor %d", j, _cursorHints[i].variableHint.values[j]);
}
} else {
_cursorHints[i].variableHint.var = 0;
- _cursorHints[i].variableHint.numStates = 0;
- _cursorHints[i].variableHint.values = nullptr;
}
}
@@ -1034,7 +1025,7 @@ void MohawkEngine_Myst::checkCursorHints() {
if (_cursorHints[i].cursor == -1) {
uint16 var_value = _scriptParser->getVar(_cursorHints[i].variableHint.var);
- if (var_value >= _cursorHints[i].variableHint.numStates)
+ if (var_value >= _cursorHints[i].variableHint.values.size())
warning("Variable %d Out of Range in variable HINT Resource %d", _cursorHints[i].variableHint.var, i);
else {
_currentCursor = _cursorHints[i].variableHint.values[var_value];
diff --git a/engines/mohawk/myst.h b/engines/mohawk/myst.h
index 6e1cbef..fbe0e35 100644
--- a/engines/mohawk/myst.h
+++ b/engines/mohawk/myst.h
@@ -96,8 +96,7 @@ const uint16 kMasterpieceOnly = 0xFFFF;
struct MystCondition {
uint16 var;
- uint16 numStates;
- uint16 *values;
+ Common::Array<uint16> values;
};
// View Sound Action Type
Commit: 32f1ee73addb717b22dbf6db8a0da493627abd82
https://github.com/scummvm/scummvm/commit/32f1ee73addb717b22dbf6db8a0da493627abd82
Author: Bastien Bouclet (bastien.bouclet at gmail.com)
Date: 2016-02-07T15:27:03+01:00
Commit Message:
MOHAWK: Turn MystView::soundList into a Common::Array
Changed paths:
engines/mohawk/myst.cpp
engines/mohawk/myst.h
diff --git a/engines/mohawk/myst.cpp b/engines/mohawk/myst.cpp
index 7868434..9ad2757 100644
--- a/engines/mohawk/myst.cpp
+++ b/engines/mohawk/myst.cpp
@@ -91,8 +91,6 @@ MohawkEngine_Myst::MohawkEngine_Myst(OSystem *syst, const MohawkGameDescription
_prevStack = nullptr;
- _view.soundList = nullptr;
- _view.soundListVolume = nullptr;
_view.scriptResCount = 0;
_view.scriptResources = nullptr;
}
@@ -587,11 +585,11 @@ void MohawkEngine_Myst::changeToCard(uint16 card, TransitionType transition) {
if (_view.sound == kMystSoundActionConditional) {
uint16 soundVarValue = _scriptParser->getVar(_view.soundVar);
- if (soundVarValue >= _view.soundCount)
+ if (soundVarValue >= _view.soundList.size())
warning("Conditional sound variable outside range");
else {
- soundAction = _view.soundList[soundVarValue];
- soundActionVolume = _view.soundListVolume[soundVarValue];
+ soundAction = _view.soundList[soundVarValue].action;
+ soundActionVolume = _view.soundList[soundVarValue].volume;
}
} else {
soundAction = _view.sound;
@@ -752,18 +750,20 @@ void MohawkEngine_Myst::loadCard() {
debugC(kDebugView, "Conditional sound list");
_view.soundVar = viewStream->readUint16LE();
debugC(kDebugView, "\tVar: %d", _view.soundVar);
- _view.soundCount = viewStream->readUint16LE();
- debugC(kDebugView, "\tCount: %d", _view.soundCount);
- _view.soundList = new int16[_view.soundCount];
- _view.soundListVolume = new uint16[_view.soundCount];
-
- for (uint16 i = 0; i < _view.soundCount; i++) {
- _view.soundList[i] = viewStream->readSint16LE();
- debugC(kDebugView, "\t\tCondition %d: Action %d", i, _view.soundList[i]);
- if (_view.soundList[i] == kMystSoundActionChangeVolume || _view.soundList[i] >= 0) {
- _view.soundListVolume[i] = viewStream->readUint16LE();
- debugC(kDebugView, "\t\tCondition %d: Volume %d", i, _view.soundListVolume[i]);
+ uint16 soundCount = viewStream->readUint16LE();
+ debugC(kDebugView, "\tCount: %d", soundCount);
+
+ for (uint16 i = 0; i < soundCount; i++) {
+ MystSoundItem sound;
+
+ sound.action = viewStream->readSint16LE();
+ debugC(kDebugView, "\t\tCondition %d: Action %d", i, sound.action);
+ if (sound.action == kMystSoundActionChangeVolume || sound.action >= 0) {
+ sound.volume = viewStream->readUint16LE();
+ debugC(kDebugView, "\t\tCondition %d: Volume %d", i, sound.volume);
}
+
+ _view.soundList.push_back(sound);
}
} else {
debugC(kDebugView, "Unknown");
@@ -847,9 +847,9 @@ void MohawkEngine_Myst::loadCard() {
if (_view.sound > 0)
cachePreload(ID_MSND, _view.sound);
else if (_view.sound == kMystSoundActionConditional) {
- for (uint16 i = 0; i < _view.soundCount; i++) {
- if (_view.soundList[i] > 0)
- cachePreload(ID_MSND, _view.soundList[i]);
+ for (uint16 i = 0; i < _view.soundList.size(); i++) {
+ if (_view.soundList[i].action > 0)
+ cachePreload(ID_MSND, _view.soundList[i].action);
}
}
@@ -876,11 +876,7 @@ void MohawkEngine_Myst::loadCard() {
void MohawkEngine_Myst::unloadCard() {
_view.conditionalImages.clear();
-
- delete[] _view.soundList;
- _view.soundList = nullptr;
- delete[] _view.soundListVolume;
- _view.soundListVolume = nullptr;
+ _view.soundList.clear();
for (uint16 i = 0; i < _view.scriptResCount; i++)
delete[] _view.scriptResources[i].resource_list;
diff --git a/engines/mohawk/myst.h b/engines/mohawk/myst.h
index fbe0e35..8d68092 100644
--- a/engines/mohawk/myst.h
+++ b/engines/mohawk/myst.h
@@ -99,6 +99,11 @@ struct MystCondition {
Common::Array<uint16> values;
};
+struct MystSoundItem {
+ int16 action;
+ uint16 volume;
+};
+
// View Sound Action Type
enum {
kMystSoundActionConditional = -4,
@@ -124,9 +129,7 @@ struct MystView {
int16 sound;
uint16 soundVolume;
uint16 soundVar;
- uint16 soundCount;
- int16 *soundList;
- uint16 *soundListVolume;
+ Common::Array<MystSoundItem> soundList;
// Script Resources
uint16 scriptResCount;
Commit: a3064b9027569c44a24d84b4e4a6da4abcdadee5
https://github.com/scummvm/scummvm/commit/a3064b9027569c44a24d84b4e4a6da4abcdadee5
Author: Bastien Bouclet (bastien.bouclet at gmail.com)
Date: 2016-02-07T15:27:03+01:00
Commit Message:
MOHAWK: Turn MystView::scriptResources into a Common::Array
Changed paths:
engines/mohawk/myst.cpp
engines/mohawk/myst.h
diff --git a/engines/mohawk/myst.cpp b/engines/mohawk/myst.cpp
index 9ad2757..f42822f 100644
--- a/engines/mohawk/myst.cpp
+++ b/engines/mohawk/myst.cpp
@@ -90,9 +90,6 @@ MohawkEngine_Myst::MohawkEngine_Myst(OSystem *syst, const MohawkGameDescription
_cursorHints = nullptr;
_prevStack = nullptr;
-
- _view.scriptResCount = 0;
- _view.scriptResources = nullptr;
}
MohawkEngine_Myst::~MohawkEngine_Myst() {
@@ -771,49 +768,50 @@ void MohawkEngine_Myst::loadCard() {
}
// Resources that scripts can call upon
- _view.scriptResCount = viewStream->readUint16LE();
- debugC(kDebugView, "Script Resource Count: %d", _view.scriptResCount);
- if (_view.scriptResCount != 0) {
- _view.scriptResources = new MystView::ScriptResource[_view.scriptResCount];
- for (uint16 i = 0; i < _view.scriptResCount; i++) {
- debugC(kDebugView, "\tResource %d:", i);
- _view.scriptResources[i].type = viewStream->readUint16LE();
- debugC(kDebugView, "\t\t Type: %d", _view.scriptResources[i].type);
-
- switch (_view.scriptResources[i].type) {
- case 1:
- debugC(kDebugView, "\t\t\t\t= Image");
- break;
- case 2:
- debugC(kDebugView, "\t\t\t\t= Sound");
- break;
- case 3:
- debugC(kDebugView, "\t\t\t\t= Resource List");
- break;
- default:
- debugC(kDebugView, "\t\t\t\t= Unknown");
- break;
- }
+ uint16 scriptResCount = viewStream->readUint16LE();
+ debugC(kDebugView, "Script Resource Count: %d", scriptResCount);
+ for (uint16 i = 0; i < scriptResCount; i++) {
+ MystView::ScriptResource scriptResource;
+
+ debugC(kDebugView, "\tResource %d:", i);
+ scriptResource.type = viewStream->readUint16LE();
+ debugC(kDebugView, "\t\t Type: %d", scriptResource.type);
+
+ switch (scriptResource.type) {
+ case 1:
+ debugC(kDebugView, "\t\t\t\t= Image");
+ break;
+ case 2:
+ debugC(kDebugView, "\t\t\t\t= Sound");
+ break;
+ case 3:
+ debugC(kDebugView, "\t\t\t\t= Resource List");
+ break;
+ default:
+ debugC(kDebugView, "\t\t\t\t= Unknown");
+ break;
+ }
- if (_view.scriptResources[i].type == 3) {
- _view.scriptResources[i].var = viewStream->readUint16LE();
- debugC(kDebugView, "\t\t Var: %d", _view.scriptResources[i].var);
- _view.scriptResources[i].count = viewStream->readUint16LE();
- debugC(kDebugView, "\t\t Resource List Count: %d", _view.scriptResources[i].count);
- _view.scriptResources[i].u0 = viewStream->readUint16LE();
- debugC(kDebugView, "\t\t u0: %d", _view.scriptResources[i].u0);
- _view.scriptResources[i].resource_list = new int16[_view.scriptResources[i].count];
-
- for (uint16 j = 0; j < _view.scriptResources[i].count; j++) {
- _view.scriptResources[i].resource_list[j] = viewStream->readSint16LE();
- debugC(kDebugView, "\t\t Resource List %d: %d", j, _view.scriptResources[i].resource_list[j]);
- }
- } else {
- _view.scriptResources[i].resource_list = nullptr;
- _view.scriptResources[i].id = viewStream->readUint16LE();
- debugC(kDebugView, "\t\t Id: %d", _view.scriptResources[i].id);
+ if (scriptResource.type == 3) {
+ scriptResource.var = viewStream->readUint16LE();
+ debugC(kDebugView, "\t\t Var: %d", scriptResource.var);
+ scriptResource.count = viewStream->readUint16LE();
+ debugC(kDebugView, "\t\t Resource List Count: %d", scriptResource.count);
+ scriptResource.u0 = viewStream->readUint16LE();
+ debugC(kDebugView, "\t\t u0: %d", scriptResource.u0);
+ scriptResource.resource_list = new int16[scriptResource.count];
+
+ for (uint16 j = 0; j < scriptResource.count; j++) {
+ scriptResource.resource_list[j] = viewStream->readSint16LE();
+ debugC(kDebugView, "\t\t Resource List %d: %d", j, scriptResource.resource_list[j]);
}
+ } else {
+ scriptResource.resource_list = nullptr;
+ scriptResource.id = viewStream->readUint16LE();
+ debugC(kDebugView, "\t\t Id: %d", scriptResource.id);
}
+
+ _view.scriptResources.push_back(scriptResource);
}
// Identifiers for other resources. 0 if non existent. There is always an RLST.
@@ -854,8 +852,8 @@ void MohawkEngine_Myst::loadCard() {
}
// Precache Script Resources
- if (_view.scriptResCount != 0) {
- for (uint16 i = 0; i < _view.scriptResCount; i++) {
+ if (_view.scriptResources.size() != 0) {
+ for (uint16 i = 0; i < _view.scriptResources.size(); i++) {
switch (_view.scriptResources[i].type) {
case 1:
cachePreload(cacheImageType, _view.scriptResources[i].id);
@@ -878,12 +876,10 @@ void MohawkEngine_Myst::unloadCard() {
_view.conditionalImages.clear();
_view.soundList.clear();
- for (uint16 i = 0; i < _view.scriptResCount; i++)
+ for (uint16 i = 0; i < _view.scriptResources.size(); i++)
delete[] _view.scriptResources[i].resource_list;
- delete[] _view.scriptResources;
- _view.scriptResources = nullptr;
- _view.scriptResCount = 0;
+ _view.scriptResources.clear();
}
void MohawkEngine_Myst::runInitScript() {
diff --git a/engines/mohawk/myst.h b/engines/mohawk/myst.h
index 8d68092..1e5ddd8 100644
--- a/engines/mohawk/myst.h
+++ b/engines/mohawk/myst.h
@@ -132,7 +132,6 @@ struct MystView {
Common::Array<MystSoundItem> soundList;
// Script Resources
- uint16 scriptResCount;
struct ScriptResource {
uint16 type;
uint16 id; // Not used by type 3
@@ -141,7 +140,8 @@ struct MystView {
uint16 count; // Used by type 3 only
uint16 u0; // Used by type 3 only
int16 *resource_list; // Used by type 3 only
- } *scriptResources;
+ };
+ Common::Array<ScriptResource> scriptResources;
// Resource ID's
uint16 rlst;
Commit: 316dc9c829767f339f66861f016faa4b2bca60df
https://github.com/scummvm/scummvm/commit/316dc9c829767f339f66861f016faa4b2bca60df
Author: Bastien Bouclet (bastien.bouclet at gmail.com)
Date: 2016-02-07T15:27:03+01:00
Commit Message:
MOHAWK: Turn ScriptResource::resourceList into a Common::Array
Changed paths:
engines/mohawk/myst.cpp
engines/mohawk/myst.h
diff --git a/engines/mohawk/myst.cpp b/engines/mohawk/myst.cpp
index f42822f..0cc5a01 100644
--- a/engines/mohawk/myst.cpp
+++ b/engines/mohawk/myst.cpp
@@ -795,18 +795,16 @@ void MohawkEngine_Myst::loadCard() {
if (scriptResource.type == 3) {
scriptResource.var = viewStream->readUint16LE();
debugC(kDebugView, "\t\t Var: %d", scriptResource.var);
- scriptResource.count = viewStream->readUint16LE();
- debugC(kDebugView, "\t\t Resource List Count: %d", scriptResource.count);
+ uint16 count = viewStream->readUint16LE();
+ debugC(kDebugView, "\t\t Resource List Count: %d", count);
scriptResource.u0 = viewStream->readUint16LE();
debugC(kDebugView, "\t\t u0: %d", scriptResource.u0);
- scriptResource.resource_list = new int16[scriptResource.count];
- for (uint16 j = 0; j < scriptResource.count; j++) {
- scriptResource.resource_list[j] = viewStream->readSint16LE();
- debugC(kDebugView, "\t\t Resource List %d: %d", j, scriptResource.resource_list[j]);
+ for (uint16 j = 0; j < count; j++) {
+ scriptResource.resourceList.push_back(viewStream->readSint16LE());
+ debugC(kDebugView, "\t\t Resource List %d: %d", j, scriptResource.resourceList[j]);
}
} else {
- scriptResource.resource_list = nullptr;
scriptResource.id = viewStream->readUint16LE();
debugC(kDebugView, "\t\t Id: %d", scriptResource.id);
}
@@ -875,10 +873,6 @@ void MohawkEngine_Myst::loadCard() {
void MohawkEngine_Myst::unloadCard() {
_view.conditionalImages.clear();
_view.soundList.clear();
-
- for (uint16 i = 0; i < _view.scriptResources.size(); i++)
- delete[] _view.scriptResources[i].resource_list;
-
_view.scriptResources.clear();
}
diff --git a/engines/mohawk/myst.h b/engines/mohawk/myst.h
index 1e5ddd8..12ec21b 100644
--- a/engines/mohawk/myst.h
+++ b/engines/mohawk/myst.h
@@ -137,9 +137,8 @@ struct MystView {
uint16 id; // Not used by type 3
// TODO: Type 3 has more. Maybe use a union?
uint16 var; // Used by type 3 only
- uint16 count; // Used by type 3 only
uint16 u0; // Used by type 3 only
- int16 *resource_list; // Used by type 3 only
+ Common::Array<int16> resourceList; // Used by type 3 only
};
Common::Array<ScriptResource> scriptResources;
Commit: 6e3719199e81c1d236f58459f7a9776e3a59e94e
https://github.com/scummvm/scummvm/commit/6e3719199e81c1d236f58459f7a9776e3a59e94e
Author: Bastien Bouclet (bastien.bouclet at gmail.com)
Date: 2016-02-07T15:27:03+01:00
Commit Message:
MOHAWK: Remove some dead code
Changed paths:
engines/mohawk/myst.cpp
engines/mohawk/myst.h
diff --git a/engines/mohawk/myst.cpp b/engines/mohawk/myst.cpp
index 0cc5a01..126d464 100644
--- a/engines/mohawk/myst.cpp
+++ b/engines/mohawk/myst.cpp
@@ -83,7 +83,6 @@ MohawkEngine_Myst::MohawkEngine_Myst(OSystem *syst, const MohawkGameDescription
_console = nullptr;
_scriptParser = nullptr;
_gameState = nullptr;
- _loadDialog = nullptr;
_optionsDialog = nullptr;
_cursorHintCount = 0;
@@ -99,7 +98,6 @@ MohawkEngine_Myst::~MohawkEngine_Myst() {
delete _console;
delete _scriptParser;
delete _gameState;
- delete _loadDialog;
delete _optionsDialog;
delete _prevStack;
delete _rnd;
@@ -233,7 +231,6 @@ Common::Error MohawkEngine_Myst::run() {
_gfx = new MystGraphics(this);
_console = new MystConsole(this);
_gameState = new MystGameState(this, _saveFileMan);
- _loadDialog = new GUI::SaveLoadChooser(_("Load game:"), _("Load"), false);
_optionsDialog = new MystOptionsDialog(this);
_cursor = new MystCursorManager(this);
_rnd = new Common::RandomSource("myst");
diff --git a/engines/mohawk/myst.h b/engines/mohawk/myst.h
index 12ec21b..2264e07 100644
--- a/engines/mohawk/myst.h
+++ b/engines/mohawk/myst.h
@@ -30,8 +30,6 @@
#include "common/random.h"
-#include "gui/saveload.h"
-
namespace Mohawk {
class MohawkEngine_Myst;
@@ -211,7 +209,6 @@ public:
private:
MystConsole *_console;
- GUI::SaveLoadChooser *_loadDialog;
MystOptionsDialog *_optionsDialog;
MystScriptParser *_prevStack;
ResourceCache _cache;
Commit: bff0dd191540b7698c9615a213916d1adf562bbb
https://github.com/scummvm/scummvm/commit/bff0dd191540b7698c9615a213916d1adf562bbb
Author: Bastien Bouclet (bastien.bouclet at gmail.com)
Date: 2016-02-07T15:27:03+01:00
Commit Message:
MOHAWK: Turn MystEngine::_cursorHints into a Common::Array
Changed paths:
engines/mohawk/myst.cpp
engines/mohawk/myst.h
diff --git a/engines/mohawk/myst.cpp b/engines/mohawk/myst.cpp
index 126d464..e4f77af 100644
--- a/engines/mohawk/myst.cpp
+++ b/engines/mohawk/myst.cpp
@@ -85,9 +85,6 @@ MohawkEngine_Myst::MohawkEngine_Myst(OSystem *syst, const MohawkGameDescription
_gameState = nullptr;
_optionsDialog = nullptr;
- _cursorHintCount = 0;
- _cursorHints = nullptr;
-
_prevStack = nullptr;
}
@@ -102,14 +99,8 @@ MohawkEngine_Myst::~MohawkEngine_Myst() {
delete _prevStack;
delete _rnd;
- delete[] _cursorHints;
-
- unloadCard();
-
for (uint32 i = 0; i < _resources.size(); i++)
delete _resources[i];
-
- _resources.clear();
}
// Uses cached data objects in preference to disk access
@@ -946,9 +937,7 @@ void MohawkEngine_Myst::loadHelp(uint16 id) {
}
void MohawkEngine_Myst::loadCursorHints() {
- _cursorHintCount = 0;
- delete[] _cursorHints;
- _cursorHints = nullptr;
+ _cursorHints.clear();
if (!_view.hint) {
debugC(kDebugHint, "No HINT Present");
@@ -958,30 +947,33 @@ void MohawkEngine_Myst::loadCursorHints() {
debugC(kDebugHint, "Loading Cursor Hints:");
Common::SeekableReadStream *hintStream = getResource(ID_HINT, _curCard);
- _cursorHintCount = hintStream->readUint16LE();
- debugC(kDebugHint, "Cursor Hint Count: %d", _cursorHintCount);
- _cursorHints = new MystCursorHint[_cursorHintCount];
+ uint16 cursorHintCount = hintStream->readUint16LE();
+ debugC(kDebugHint, "Cursor Hint Count: %d", cursorHintCount);
+
+ for (uint16 i = 0; i < cursorHintCount; i++) {
+ MystCursorHint hint;
- for (uint16 i = 0; i < _cursorHintCount; i++) {
debugC(kDebugHint, "Cursor Hint %d:", i);
- _cursorHints[i].id = hintStream->readUint16LE();
- debugC(kDebugHint, "\tId: %d", _cursorHints[i].id);
- _cursorHints[i].cursor = hintStream->readSint16LE();
- debugC(kDebugHint, "\tCursor: %d", _cursorHints[i].cursor);
+ hint.id = hintStream->readUint16LE();
+ debugC(kDebugHint, "\tId: %d", hint.id);
+ hint.cursor = hintStream->readSint16LE();
+ debugC(kDebugHint, "\tCursor: %d", hint.cursor);
- if (_cursorHints[i].cursor == -1) {
+ if (hint.cursor == -1) {
debugC(kDebugHint, "\tConditional Cursor Hints:");
- _cursorHints[i].variableHint.var = hintStream->readUint16LE();
- debugC(kDebugHint, "\tVar: %d", _cursorHints[i].variableHint.var);
+ hint.variableHint.var = hintStream->readUint16LE();
+ debugC(kDebugHint, "\tVar: %d", hint.variableHint.var);
uint16 numStates = hintStream->readUint16LE();
debugC(kDebugHint, "\tNumber of States: %d", numStates);
for (uint16 j = 0; j < numStates; j++) {
- _cursorHints[i].variableHint.values.push_back(hintStream->readUint16LE());
- debugC(kDebugHint, "\t\t State %d: Cursor %d", j, _cursorHints[i].variableHint.values[j]);
+ hint.variableHint.values.push_back(hintStream->readUint16LE());
+ debugC(kDebugHint, "\t\t State %d: Cursor %d", j, hint.variableHint.values[j]);
}
} else {
- _cursorHints[i].variableHint.var = 0;
+ hint.variableHint.var = 0;
}
+
+ _cursorHints.push_back(hint);
}
delete hintStream;
@@ -1003,7 +995,7 @@ void MohawkEngine_Myst::checkCursorHints() {
}
// Check all the cursor hints to see if we're in a hotspot that contains a hint.
- for (uint16 i = 0; i < _cursorHintCount; i++)
+ for (uint16 i = 0; i < _cursorHints.size(); i++)
if (_cursorHints[i].id == _curResource && _resources[_cursorHints[i].id]->isEnabled()) {
if (_cursorHints[i].cursor == -1) {
uint16 var_value = _scriptParser->getVar(_cursorHints[i].variableHint.var);
diff --git a/engines/mohawk/myst.h b/engines/mohawk/myst.h
index 2264e07..4439cb9 100644
--- a/engines/mohawk/myst.h
+++ b/engines/mohawk/myst.h
@@ -236,8 +236,7 @@ private:
int16 _curResource;
MystAreaHover *_hoverResource;
- uint16 _cursorHintCount;
- MystCursorHint *_cursorHints;
+ Common::Array<MystCursorHint> _cursorHints;
void loadCursorHints();
uint16 _currentCursor;
uint16 _mainCursor; // Also defines the current page being held (white, blue, red, or none)
Commit: 0463e00fb6b776c7774c4e1f06261e78732788f6
https://github.com/scummvm/scummvm/commit/0463e00fb6b776c7774c4e1f06261e78732788f6
Author: Bastien Bouclet (bastien.bouclet at gmail.com)
Date: 2016-02-07T15:27:03+01:00
Commit Message:
MOHAWK: Don't downcast _invokingResource using static_cast
Changed paths:
engines/mohawk/myst_scripts.cpp
engines/mohawk/myst_scripts.h
engines/mohawk/myst_stacks/channelwood.cpp
engines/mohawk/myst_stacks/intro.cpp
engines/mohawk/myst_stacks/mechanical.cpp
engines/mohawk/myst_stacks/myst.cpp
engines/mohawk/myst_stacks/myst.h
engines/mohawk/myst_stacks/preview.cpp
engines/mohawk/myst_stacks/selenitic.cpp
engines/mohawk/myst_stacks/stoneship.cpp
diff --git a/engines/mohawk/myst_scripts.cpp b/engines/mohawk/myst_scripts.cpp
index aee9372..b2a2221 100644
--- a/engines/mohawk/myst_scripts.cpp
+++ b/engines/mohawk/myst_scripts.cpp
@@ -442,7 +442,7 @@ void MystScriptParser::o_triggerMovie(uint16 op, uint16 var, uint16 argc, uint16
debugC(kDebugScript, "\tDirection: %d", direction);
// Trigger resource 6 movie overriding play direction
- MystAreaVideo *resource = static_cast<MystAreaVideo *>(_invokingResource);
+ MystAreaVideo *resource = getInvokingResource<MystAreaVideo>();
resource->setDirection(direction);
resource->playMovie();
@@ -459,7 +459,7 @@ void MystScriptParser::o_drawAreaState(uint16 op, uint16 var, uint16 argc, uint1
debugC(kDebugScript, "Opcode %d: drawAreaState, state: %d", op, argv[0]);
debugC(kDebugScript, "\tVar: %d", var);
- MystAreaImageSwitch *parent = static_cast<MystAreaImageSwitch *>(_invokingResource->_parent);
+ MystAreaImageSwitch *parent = static_cast<MystAreaImageSwitch *>(getInvokingResource<MystArea>()->_parent);
parent->drawConditionalDataToScreen(argv[0]);
}
diff --git a/engines/mohawk/myst_scripts.h b/engines/mohawk/myst_scripts.h
index 835bb7c..69052b1 100644
--- a/engines/mohawk/myst_scripts.h
+++ b/engines/mohawk/myst_scripts.h
@@ -151,8 +151,6 @@ protected:
Common::Array<MystOpcode *> _opcodes;
- MystArea *_invokingResource;
-
uint16 _savedCardId;
uint16 _savedMapCardId;
uint16 _savedCursorId;
@@ -163,8 +161,25 @@ protected:
static const uint16 _startCard[];
void setupCommonOpcodes();
+
+ template<class T>
+ T *getInvokingResource() const;
+
+private:
+ MystArea *_invokingResource;
};
+template<class T>
+T *MystScriptParser::getInvokingResource() const {
+ T *resource = dynamic_cast<T *>(_invokingResource);
+
+ if (!resource) {
+ error("Invoking resource has unexpected type");
+ }
+
+ return resource;
+}
+
} // End of namespace Mohawk
#undef DECLARE_OPCODE
diff --git a/engines/mohawk/myst_stacks/channelwood.cpp b/engines/mohawk/myst_stacks/channelwood.cpp
index 7b38e37..9036328 100644
--- a/engines/mohawk/myst_stacks/channelwood.cpp
+++ b/engines/mohawk/myst_stacks/channelwood.cpp
@@ -363,7 +363,7 @@ void Channelwood::o_drawImageChangeCardAndVolume(uint16 op, uint16 var, uint16 a
void Channelwood::o_waterTankValveOpen(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Do Water Tank Valve Open Animation", op);
- Common::Rect rect = _invokingResource->getRect();
+ Common::Rect rect = getInvokingResource<MystArea>()->getRect();
for (uint i = 0; i < 2; i++)
for (uint16 imageId = 3601; imageId >= 3595; imageId--) {
@@ -377,7 +377,7 @@ void Channelwood::o_waterTankValveOpen(uint16 op, uint16 var, uint16 argc, uint1
void Channelwood::o_leverStartMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Generic lever start move", op);
- MystVideoInfo *lever = static_cast<MystVideoInfo *>(_invokingResource);
+ MystVideoInfo *lever = getInvokingResource<MystVideoInfo>();
lever->drawFrame(0);
_vm->_cursor->setCursor(700);
_leverPulled = false;
@@ -386,7 +386,7 @@ void Channelwood::o_leverStartMove(uint16 op, uint16 var, uint16 argc, uint16 *a
void Channelwood::o_leverMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Generic lever move", op);
- MystVideoInfo *lever = static_cast<MystVideoInfo *>(_invokingResource);
+ MystVideoInfo *lever = getInvokingResource<MystVideoInfo>();
if (lever->pullLeverV()) {
if (!_leverPulled) {
@@ -401,7 +401,7 @@ void Channelwood::o_leverMove(uint16 op, uint16 var, uint16 argc, uint16 *argv)
void Channelwood::o_leverMoveFail(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Generic lever move", op);
- MystVideoInfo *lever = static_cast<MystVideoInfo *>(_invokingResource);
+ MystVideoInfo *lever = getInvokingResource<MystVideoInfo>();
if (lever->pullLeverV()) {
if (!_leverPulled) {
@@ -419,7 +419,7 @@ void Channelwood::o_leverEndMove(uint16 op, uint16 var, uint16 argc, uint16 *arg
debugC(kDebugScript, "Opcode %d: Generic lever end move", op);
// Get current lever frame
- MystVideoInfo *lever = static_cast<MystVideoInfo *>(_invokingResource);
+ MystVideoInfo *lever = getInvokingResource<MystVideoInfo>();
// Release lever
lever->releaseLeverV();
@@ -439,7 +439,7 @@ void Channelwood::o_leverEndMoveResumeBackground(uint16 op, uint16 var, uint16 a
void Channelwood::o_leverEndMoveWithSound(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
o_leverEndMove(op, var, argc, argv);
- MystVideoInfo *lever = static_cast<MystVideoInfo *>(_invokingResource);
+ MystVideoInfo *lever = getInvokingResource<MystVideoInfo>();
uint16 soundId = lever->getList3(0);
if (soundId)
_vm->_sound->replaceSoundMyst(soundId);
@@ -461,7 +461,7 @@ void Channelwood::o_leverElev3EndMove(uint16 op, uint16 var, uint16 argc, uint16
void Channelwood::o_pumpLeverMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Pump lever move", op);
- MystVideoInfo *lever = static_cast<MystVideoInfo *>(_invokingResource);
+ MystVideoInfo *lever = getInvokingResource<MystVideoInfo>();
if (lever->pullLeverV()) {
uint16 soundId = lever->getList2(0);
@@ -475,7 +475,7 @@ void Channelwood::o_pumpLeverMove(uint16 op, uint16 var, uint16 argc, uint16 *ar
void Channelwood::o_pumpLeverEndMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
o_leverEndMove(op, var, argc, argv);
- MystVideoInfo *lever = static_cast<MystVideoInfo *>(_invokingResource);
+ MystVideoInfo *lever = getInvokingResource<MystVideoInfo>();
uint16 soundId = lever->getList3(0);
if (soundId)
_vm->_sound->replaceBackgroundMyst(soundId, 36864);
@@ -484,7 +484,7 @@ void Channelwood::o_pumpLeverEndMove(uint16 op, uint16 var, uint16 argc, uint16
void Channelwood::o_stairsDoorToggle(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Play stairs door video", op);
- MystAreaVideo *movie = static_cast<MystAreaVideo *>(_invokingResource);
+ MystAreaVideo *movie = getInvokingResource<MystAreaVideo>();
if (_state.stairsUpperDoorState) {
// Close door, play the open movie backwards
@@ -500,7 +500,7 @@ void Channelwood::o_stairsDoorToggle(uint16 op, uint16 var, uint16 argc, uint16
void Channelwood::o_valveHandleMove1(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Valve handle move", op);
- MystVideoInfo *handle = static_cast<MystVideoInfo *>(_invokingResource);
+ MystVideoInfo *handle = getInvokingResource<MystVideoInfo>();
const Common::Point &mouse = _vm->_system->getEventManager()->getMousePos();
if (handle->getRect().contains(mouse)) {
@@ -516,7 +516,7 @@ void Channelwood::o_valveHandleMove1(uint16 op, uint16 var, uint16 argc, uint16
void Channelwood::o_valveHandleMoveStart1(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Valve handle move start", op);
- MystVideoInfo *handle = static_cast<MystVideoInfo *>(_invokingResource);
+ MystVideoInfo *handle = getInvokingResource<MystVideoInfo>();
uint16 soundId = handle->getList1(0);
if (soundId)
_vm->_sound->replaceSoundMyst(soundId);
@@ -528,7 +528,7 @@ void Channelwood::o_valveHandleMoveStart1(uint16 op, uint16 var, uint16 argc, ui
void Channelwood::o_valveHandleMoveStop(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Valve handle move stop", op);
- MystVideoInfo *handle = static_cast<MystVideoInfo *>(_invokingResource);
+ MystVideoInfo *handle = getInvokingResource<MystVideoInfo>();
// Update state with valve position
if (_tempVar <= 5)
@@ -551,7 +551,7 @@ void Channelwood::o_valveHandleMoveStop(uint16 op, uint16 var, uint16 argc, uint
void Channelwood::o_valveHandleMove2(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Valve handle move", op);
- MystVideoInfo *handle = static_cast<MystVideoInfo *>(_invokingResource);
+ MystVideoInfo *handle = getInvokingResource<MystVideoInfo>();
const Common::Point &mouse = _vm->_system->getEventManager()->getMousePos();
if (handle->getRect().contains(mouse)) {
@@ -567,7 +567,7 @@ void Channelwood::o_valveHandleMove2(uint16 op, uint16 var, uint16 argc, uint16
void Channelwood::o_valveHandleMoveStart2(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Valve handle move start", op);
- MystVideoInfo *handle = static_cast<MystVideoInfo *>(_invokingResource);
+ MystVideoInfo *handle = getInvokingResource<MystVideoInfo>();
uint16 soundId = handle->getList1(0);
if (soundId)
_vm->_sound->replaceSoundMyst(soundId);
@@ -579,7 +579,7 @@ void Channelwood::o_valveHandleMoveStart2(uint16 op, uint16 var, uint16 argc, ui
void Channelwood::o_valveHandleMove3(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Valve handle move", op);
- MystVideoInfo *handle = static_cast<MystVideoInfo *>(_invokingResource);
+ MystVideoInfo *handle = getInvokingResource<MystVideoInfo>();
const Common::Point &mouse = _vm->_system->getEventManager()->getMousePos();
if (handle->getRect().contains(mouse)) {
@@ -595,7 +595,7 @@ void Channelwood::o_valveHandleMove3(uint16 op, uint16 var, uint16 argc, uint16
void Channelwood::o_valveHandleMoveStart3(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Valve handle move start", op);
- MystVideoInfo *handle = static_cast<MystVideoInfo *>(_invokingResource);
+ MystVideoInfo *handle = getInvokingResource<MystVideoInfo>();
uint16 soundId = handle->getList1(0);
if (soundId)
_vm->_sound->replaceSoundMyst(soundId);
@@ -686,7 +686,7 @@ void Channelwood::o_executeMouseUp(uint16 op, uint16 var, uint16 argc, uint16 *a
void Channelwood::o_waterTankValveClose(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Do Water Tank Valve Close Animation", op);
- Common::Rect rect = _invokingResource->getRect();
+ Common::Rect rect = getInvokingResource<MystArea>()->getRect();
for (uint i = 0; i < 2; i++)
for (uint16 imageId = 3595; imageId <= 3601; imageId++) {
@@ -753,7 +753,7 @@ void Channelwood::o_soundReplace(uint16 op, uint16 var, uint16 argc, uint16 *arg
void Channelwood::o_lever_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Generic lever init", op);
- _leverAction = static_cast<MystAreaAction *>(_invokingResource);
+ _leverAction = getInvokingResource<MystAreaAction>();
}
void Channelwood::o_pipeValve_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
diff --git a/engines/mohawk/myst_stacks/intro.cpp b/engines/mohawk/myst_stacks/intro.cpp
index a139ca2..1d733d8 100644
--- a/engines/mohawk/myst_stacks/intro.cpp
+++ b/engines/mohawk/myst_stacks/intro.cpp
@@ -170,7 +170,7 @@ void Intro::mystLinkBook_run() {
void Intro::o_mystLinkBook_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Myst link book init", op);
- _linkBookMovie = static_cast<MystAreaVideo *>(_invokingResource);
+ _linkBookMovie = getInvokingResource<MystAreaVideo>();
_startTime = 1;
_linkBookRunning = true;
}
diff --git a/engines/mohawk/myst_stacks/mechanical.cpp b/engines/mohawk/myst_stacks/mechanical.cpp
index 3f1fbf9..b1f23d3 100644
--- a/engines/mohawk/myst_stacks/mechanical.cpp
+++ b/engines/mohawk/myst_stacks/mechanical.cpp
@@ -277,7 +277,7 @@ void Mechanical::o_throneEnablePassage(uint16 op, uint16 var, uint16 argc, uint1
void Mechanical::o_birdCrankStart(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Mechanical bird crank start", op);
- MystAreaDrag *crank = static_cast<MystAreaDrag *>(_invokingResource);
+ MystAreaDrag *crank = getInvokingResource<MystAreaDrag>();
uint16 crankSoundId = crank->getList2(0);
_vm->_sound->replaceSoundMyst(crankSoundId, Audio::Mixer::kMaxChannelVolume, true);
@@ -292,7 +292,7 @@ void Mechanical::o_birdCrankStart(uint16 op, uint16 var, uint16 argc, uint16 *ar
void Mechanical::o_birdCrankStop(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Mechanical bird crank stop", op);
- MystAreaDrag *crank = static_cast<MystAreaDrag *>(_invokingResource);
+ MystAreaDrag *crank = getInvokingResource<MystAreaDrag>();
MystAreaVideo *crankMovie = static_cast<MystAreaVideo *>(crank->getSubResource(0));
crankMovie->pauseMovie(true);
@@ -334,7 +334,7 @@ void Mechanical::o_fortressStaircaseMovie(uint16 op, uint16 var, uint16 argc, ui
void Mechanical::o_elevatorRotationStart(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Elevator rotation lever start", op);
- MystVideoInfo *lever = static_cast<MystVideoInfo *>(_invokingResource);
+ MystVideoInfo *lever = getInvokingResource<MystVideoInfo>();
lever->drawFrame(0);
_elevatorRotationLeverMoving = true;
@@ -349,7 +349,7 @@ void Mechanical::o_elevatorRotationMove(uint16 op, uint16 var, uint16 argc, uint
debugC(kDebugScript, "Opcode %d: Elevator rotation lever move", op);
const Common::Point &mouse = _vm->_system->getEventManager()->getMousePos();
- MystVideoInfo *lever = static_cast<MystVideoInfo *>(_invokingResource);
+ MystVideoInfo *lever = getInvokingResource<MystVideoInfo>();
// Make the handle follow the mouse
int16 maxStep = lever->getNumFrames() - 1;
@@ -367,7 +367,7 @@ void Mechanical::o_elevatorRotationStop(uint16 op, uint16 var, uint16 argc, uint
debugC(kDebugScript, "Opcode %d: Elevator rotation lever stop", op);
const Common::Point &mouse = _vm->_system->getEventManager()->getMousePos();
- MystVideoInfo *lever = static_cast<MystVideoInfo *>(_invokingResource);
+ MystVideoInfo *lever = getInvokingResource<MystVideoInfo>();
// Get current lever frame
int16 maxStep = lever->getNumFrames() - 1;
@@ -416,7 +416,7 @@ void Mechanical::o_fortressRotationSpeedStart(uint16 op, uint16 var, uint16 argc
_vm->_cursor->setCursor(700);
- MystVideoInfo *lever = static_cast<MystVideoInfo *>(_invokingResource);
+ MystVideoInfo *lever = getInvokingResource<MystVideoInfo>();
lever->drawFrame(0);
}
@@ -424,7 +424,7 @@ void Mechanical::o_fortressRotationSpeedMove(uint16 op, uint16 var, uint16 argc,
debugC(kDebugScript, "Opcode %d Fortress rotation speed lever move", op);
const Common::Point &mouse = _vm->_system->getEventManager()->getMousePos();
- MystVideoInfo *lever = static_cast<MystVideoInfo *>(_invokingResource);
+ MystVideoInfo *lever = getInvokingResource<MystVideoInfo>();
// Make the handle follow the mouse
int16 maxStep = lever->getNumFrames() - 1;
@@ -441,7 +441,7 @@ void Mechanical::o_fortressRotationSpeedMove(uint16 op, uint16 var, uint16 argc,
void Mechanical::o_fortressRotationSpeedStop(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d Fortress rotation speed lever stop", op);
- MystVideoInfo *lever = static_cast<MystVideoInfo *>(_invokingResource);
+ MystVideoInfo *lever = getInvokingResource<MystVideoInfo>();
// Release lever
for (int i = _fortressRotationSpeed; i >= 0; i--) {
@@ -459,7 +459,7 @@ void Mechanical::o_fortressRotationBrakeStart(uint16 op, uint16 var, uint16 argc
_vm->_cursor->setCursor(700);
- MystVideoInfo *lever = static_cast<MystVideoInfo *>(_invokingResource);
+ MystVideoInfo *lever = getInvokingResource<MystVideoInfo>();
lever->drawFrame(_fortressRotationBrake);
}
@@ -467,7 +467,7 @@ void Mechanical::o_fortressRotationBrakeMove(uint16 op, uint16 var, uint16 argc,
debugC(kDebugScript, "Opcode %d Fortress rotation brake lever move", op);
const Common::Point &mouse = _vm->_system->getEventManager()->getMousePos();
- MystVideoInfo *lever = static_cast<MystVideoInfo *>(_invokingResource);
+ MystVideoInfo *lever = getInvokingResource<MystVideoInfo>();
// Make the handle follow the mouse
int16 maxStep = lever->getNumFrames() - 1;
@@ -484,7 +484,7 @@ void Mechanical::o_fortressRotationBrakeMove(uint16 op, uint16 var, uint16 argc,
void Mechanical::o_fortressRotationBrakeStop(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d Fortress rotation brake lever stop", op);
- MystVideoInfo *lever = static_cast<MystVideoInfo *>(_invokingResource);
+ MystVideoInfo *lever = getInvokingResource<MystVideoInfo>();
lever->drawFrame(_fortressRotationBrake);
_vm->checkCursorHints();
@@ -495,7 +495,7 @@ void Mechanical::o_fortressSimulationSpeedStart(uint16 op, uint16 var, uint16 ar
_vm->_cursor->setCursor(700);
- MystVideoInfo *lever = static_cast<MystVideoInfo *>(_invokingResource);
+ MystVideoInfo *lever = getInvokingResource<MystVideoInfo>();
lever->drawFrame(0);
}
@@ -503,7 +503,7 @@ void Mechanical::o_fortressSimulationSpeedMove(uint16 op, uint16 var, uint16 arg
debugC(kDebugScript, "Opcode %d Fortress rotation simulator speed lever move", op);
const Common::Point &mouse = _vm->_system->getEventManager()->getMousePos();
- MystVideoInfo *lever = static_cast<MystVideoInfo *>(_invokingResource);
+ MystVideoInfo *lever = getInvokingResource<MystVideoInfo>();
// Make the handle follow the mouse
int16 maxStep = lever->getNumFrames() - 1;
@@ -520,7 +520,7 @@ void Mechanical::o_fortressSimulationSpeedMove(uint16 op, uint16 var, uint16 arg
void Mechanical::o_fortressSimulationSpeedStop(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d Fortress rotation simulator speed lever stop", op);
- MystVideoInfo *lever = static_cast<MystVideoInfo *>(_invokingResource);
+ MystVideoInfo *lever = getInvokingResource<MystVideoInfo>();
// Release lever
for (int i = _fortressSimulationSpeed; i >= 0; i--) {
@@ -538,7 +538,7 @@ void Mechanical::o_fortressSimulationBrakeStart(uint16 op, uint16 var, uint16 ar
_vm->_cursor->setCursor(700);
- MystVideoInfo *lever = static_cast<MystVideoInfo *>(_invokingResource);
+ MystVideoInfo *lever = getInvokingResource<MystVideoInfo>();
lever->drawFrame(_fortressSimulationBrake);
}
@@ -546,7 +546,7 @@ void Mechanical::o_fortressSimulationBrakeMove(uint16 op, uint16 var, uint16 arg
debugC(kDebugScript, "Opcode %d Fortress rotation simulator brake lever move", op);
const Common::Point &mouse = _vm->_system->getEventManager()->getMousePos();
- MystVideoInfo *lever = static_cast<MystVideoInfo *>(_invokingResource);
+ MystVideoInfo *lever = getInvokingResource<MystVideoInfo>();
// Make the handle follow the mouse
int16 maxStep = lever->getNumFrames() - 1;
@@ -563,7 +563,7 @@ void Mechanical::o_fortressSimulationBrakeMove(uint16 op, uint16 var, uint16 arg
void Mechanical::o_fortressSimulationBrakeStop(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d Fortress rotation simulator brake lever stop", op);
- MystVideoInfo *lever = static_cast<MystVideoInfo *>(_invokingResource);
+ MystVideoInfo *lever = getInvokingResource<MystVideoInfo>();
lever->drawFrame(_fortressSimulationBrake);
_vm->checkCursorHints();
@@ -737,7 +737,7 @@ void Mechanical::o_throne_init(uint16 op, uint16 var, uint16 argc, uint16 *argv)
// Used on Card 6238 (Sirrus' Throne) and Card 6027 (Achenar's Throne)
debugC(kDebugScript, "Opcode %d: Brother throne init", op);
- _invokingResource->setEnabled(getVar(var));
+ getInvokingResource<MystArea>()->setEnabled(getVar(var));
}
void Mechanical::o_fortressStaircase_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
@@ -763,13 +763,13 @@ void Mechanical::o_bird_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
_birdSinging = false;
_birdSingEndTime = 0;
- _bird = static_cast<MystAreaVideo *>(_invokingResource);
+ _bird = getInvokingResource<MystAreaVideo>();
}
void Mechanical::o_snakeBox_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Snake box init", op);
- _snakeBox = static_cast<MystAreaVideo *>(_invokingResource);
+ _snakeBox = getInvokingResource<MystAreaVideo>();
}
void Mechanical::elevatorRotation_run() {
@@ -872,7 +872,7 @@ void Mechanical::fortressRotation_run() {
void Mechanical::o_fortressRotation_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Fortress rotation init", op);
- _fortressRotationGears = static_cast<MystAreaVideo *>(_invokingResource);
+ _fortressRotationGears = getInvokingResource<MystAreaVideo>();
VideoHandle gears = _fortressRotationGears->playMovie();
gears->setLooping(true);
@@ -997,7 +997,7 @@ void Mechanical::fortressSimulation_run() {
void Mechanical::o_fortressSimulation_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Fortress rotation simulator init", op);
- _fortressSimulationHolo = static_cast<MystAreaVideo *>(_invokingResource);
+ _fortressSimulationHolo = getInvokingResource<MystAreaVideo>();
_fortressSimulationStartSound1 = argv[0];
_fortressSimulationStartSound2 = argv[1];
@@ -1019,7 +1019,7 @@ void Mechanical::o_fortressSimulation_init(uint16 op, uint16 var, uint16 argc, u
void Mechanical::o_fortressSimulationStartup_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Fortress rotation simulator startup init", op);
- _fortressSimulationStartup = static_cast<MystAreaVideo *>(_invokingResource);
+ _fortressSimulationStartup = getInvokingResource<MystAreaVideo>();
}
} // End of namespace MystStacks
diff --git a/engines/mohawk/myst_stacks/myst.cpp b/engines/mohawk/myst_stacks/myst.cpp
index 8d2e732..d928887 100644
--- a/engines/mohawk/myst_stacks/myst.cpp
+++ b/engines/mohawk/myst_stacks/myst.cpp
@@ -860,14 +860,14 @@ void Myst::o_fireplaceToggleButton(uint16 op, uint16 var, uint16 argc, uint16 *a
if (line & bitmask) {
// Unset button
for (uint i = 4795; i >= 4779; i--) {
- _vm->_gfx->copyImageToScreen(i, _invokingResource->getRect());
+ _vm->_gfx->copyImageToScreen(i, getInvokingResource<MystArea>()->getRect());
_vm->_system->updateScreen();
}
_fireplaceLines[var - 17] &= ~bitmask;
} else {
// Set button
for (uint i = 4779; i <= 4795; i++) {
- _vm->_gfx->copyImageToScreen(i, _invokingResource->getRect());
+ _vm->_gfx->copyImageToScreen(i, getInvokingResource<MystArea>()->getRect());
_vm->_system->updateScreen();
}
_fireplaceLines[var - 17] |= bitmask;
@@ -1251,7 +1251,7 @@ void Myst::o_imagerPlayButton(uint16 op, uint16 var, uint16 argc, uint16 *argv)
void Myst::o_imagerEraseButton(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Imager erase button", op);
- _imagerRedButton = static_cast<MystAreaImageSwitch *>(_invokingResource->_parent);
+ _imagerRedButton = static_cast<MystAreaImageSwitch *>(getInvokingResource<MystArea>()->_parent);
for (uint i = 0; i < 4; i++)
_imagerSound[i] = argv[i];
_imagerValidationCard = argv[4];
@@ -1351,7 +1351,7 @@ void Myst::o_towerElevatorAnimation(uint16 op, uint16 var, uint16 argc, uint16 *
void Myst::o_generatorButtonPressed(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Generator button pressed", op);
- MystArea *button = _invokingResource->_parent;
+ MystArea *button = getInvokingResource<MystArea>()->_parent;
generatorRedrawRocket();
@@ -1466,7 +1466,7 @@ void Myst::o_cabinSafeHandleStartMove(uint16 op, uint16 var, uint16 argc, uint16
debugC(kDebugScript, "Opcode %d: Cabin safe handle start move", op);
// Used on Card 4100
- MystVideoInfo *handle = static_cast<MystVideoInfo *>(_invokingResource);
+ MystVideoInfo *handle = getInvokingResource<MystVideoInfo>();
handle->drawFrame(0);
_vm->_cursor->setCursor(700);
_tempVar = 0;
@@ -1476,7 +1476,7 @@ void Myst::o_cabinSafeHandleMove(uint16 op, uint16 var, uint16 argc, uint16 *arg
debugC(kDebugScript, "Opcode %d: Cabin safe handle move", op);
// Used on Card 4100
- MystVideoInfo *handle = static_cast<MystVideoInfo *>(_invokingResource);
+ MystVideoInfo *handle = getInvokingResource<MystVideoInfo>();
if (handle->pullLeverV()) {
// Sound not played yet
@@ -1506,7 +1506,7 @@ void Myst::o_cabinSafeHandleEndMove(uint16 op, uint16 var, uint16 argc, uint16 *
debugC(kDebugScript, "Opcode %d: Cabin safe handle end move", op);
// Used on Card 4100
- MystVideoInfo *handle = static_cast<MystVideoInfo *>(_invokingResource);
+ MystVideoInfo *handle = getInvokingResource<MystVideoInfo>();
handle->drawFrame(0);
_vm->checkCursorHints();
}
@@ -1804,7 +1804,7 @@ void Myst::o_observatoryTimeSliderMove(uint16 op, uint16 var, uint16 argc, uint1
void Myst::o_circuitBreakerStartMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Circuit breaker start move", op);
- MystVideoInfo *breaker = static_cast<MystVideoInfo *>(_invokingResource);
+ MystVideoInfo *breaker = getInvokingResource<MystVideoInfo>();
breaker->drawFrame(0);
_vm->_cursor->setCursor(700);
_tempVar = 0;
@@ -1813,7 +1813,7 @@ void Myst::o_circuitBreakerStartMove(uint16 op, uint16 var, uint16 argc, uint16
void Myst::o_circuitBreakerMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Circuit breaker move", op);
- MystVideoInfo *breaker = static_cast<MystVideoInfo *>(_invokingResource);
+ MystVideoInfo *breaker = getInvokingResource<MystVideoInfo>();
const Common::Point &mouse = _vm->_system->getEventManager()->getMousePos();
int16 maxStep = breaker->getStepsV() - 1;
@@ -1864,7 +1864,7 @@ void Myst::o_circuitBreakerMove(uint16 op, uint16 var, uint16 argc, uint16 *argv
void Myst::o_circuitBreakerEndMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Circuit breaker end move", op);
- MystVideoInfo *breaker = static_cast<MystVideoInfo *>(_invokingResource);
+ MystVideoInfo *breaker = getInvokingResource<MystVideoInfo>();
_vm->redrawArea(breaker->getImageSwitchVar());
_vm->checkCursorHints();
}
@@ -2187,22 +2187,22 @@ void Myst::o_rocketSoundSliderEndMove(uint16 op, uint16 var, uint16 argc, uint16
if (_state.generatorVoltage == 59 && !_state.generatorBreakers && _rocketSliderSound)
_vm->_sound->stopSound();
- if (_invokingResource == _rocketSlider1)
+ if (getInvokingResource<MystArea>() == _rocketSlider1)
_state.rocketSliderPosition[0] = _rocketSlider1->_pos.y;
- else if (_invokingResource == _rocketSlider2)
+ else if (getInvokingResource<MystArea>() == _rocketSlider2)
_state.rocketSliderPosition[1] = _rocketSlider2->_pos.y;
- else if (_invokingResource == _rocketSlider3)
+ else if (getInvokingResource<MystArea>() == _rocketSlider3)
_state.rocketSliderPosition[2] = _rocketSlider3->_pos.y;
- else if (_invokingResource == _rocketSlider4)
+ else if (getInvokingResource<MystArea>() == _rocketSlider4)
_state.rocketSliderPosition[3] = _rocketSlider4->_pos.y;
- else if (_invokingResource == _rocketSlider5)
+ else if (getInvokingResource<MystArea>() == _rocketSlider5)
_state.rocketSliderPosition[4] = _rocketSlider5->_pos.y;
_vm->_sound->resumeBackgroundMyst();
}
void Myst::rocketSliderMove() {
- MystAreaSlider *slider = static_cast<MystAreaSlider *>(_invokingResource);
+ MystAreaSlider *slider = getInvokingResource<MystAreaSlider>();
if (_state.generatorVoltage == 59 && !_state.generatorBreakers) {
uint16 soundId = rocketSliderGetSound(slider->_pos.y);
@@ -2262,7 +2262,7 @@ void Myst::rocketCheckSolution() {
if (solved) {
// Reset lever position
- MystVideoInfo *lever = static_cast<MystVideoInfo *>(_invokingResource);
+ MystVideoInfo *lever = getInvokingResource<MystVideoInfo>();
lever->drawFrame(0);
// Book appearing
@@ -2299,7 +2299,7 @@ void Myst::rocketCheckSolution() {
void Myst::o_rocketPianoStart(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Rocket piano start move", op);
- MystAreaDrag *key = static_cast<MystAreaDrag *>(_invokingResource);
+ MystAreaDrag *key = getInvokingResource<MystAreaDrag>();
// What the hell??
Common::Rect src = key->getSubImage(1).rect;
@@ -2326,7 +2326,7 @@ void Myst::o_rocketPianoMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
Common::Rect piano = Common::Rect(85, 123, 460, 270);
// Unpress previous key
- MystAreaDrag *key = static_cast<MystAreaDrag *>(_invokingResource);
+ MystAreaDrag *key = getInvokingResource<MystAreaDrag>();
Common::Rect src = key->getSubImage(0).rect;
Common::Rect dest = src;
@@ -2368,7 +2368,7 @@ void Myst::o_rocketPianoMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
void Myst::o_rocketPianoStop(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Rocket piano end move", op);
- MystAreaImageSwitch *key = static_cast<MystAreaImageSwitch *>(_invokingResource);
+ MystAreaImageSwitch *key = getInvokingResource<MystAreaImageSwitch>();
Common::Rect src = key->getSubImage(0).rect;
Common::Rect dest = src;
@@ -2386,7 +2386,7 @@ void Myst::o_rocketPianoStop(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
void Myst::o_rocketLeverStartMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Rocket lever start move", op);
- MystVideoInfo *lever = static_cast<MystVideoInfo *>(_invokingResource);
+ MystVideoInfo *lever = getInvokingResource<MystVideoInfo>();
_vm->_cursor->setCursor(700);
_rocketLeverPosition = 0;
@@ -2406,7 +2406,7 @@ void Myst::o_rocketOpenBook(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
void Myst::o_rocketLeverMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Rocket lever move", op);
- MystVideoInfo *lever = static_cast<MystVideoInfo *>(_invokingResource);
+ MystVideoInfo *lever = getInvokingResource<MystVideoInfo>();
const Common::Point &mouse = _vm->_system->getEventManager()->getMousePos();
// Make the lever follow the mouse
@@ -2435,7 +2435,7 @@ void Myst::o_rocketLeverMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
void Myst::o_rocketLeverEndMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Rocket lever end move", op);
- MystVideoInfo *lever = static_cast<MystVideoInfo *>(_invokingResource);
+ MystVideoInfo *lever = getInvokingResource<MystVideoInfo>();
_vm->checkCursorHints();
_rocketLeverPosition = 0;
@@ -2712,7 +2712,7 @@ void Myst::clockWheel_run() {
}
void Myst::clockWheelStartTurn(uint16 wheel) {
- MystAreaDrag *resource = static_cast<MystAreaDrag *>(_invokingResource);
+ MystAreaDrag *resource = getInvokingResource<MystAreaDrag>();
uint16 soundId = resource->getList1(0);
if (soundId)
@@ -2835,7 +2835,7 @@ void Myst::o_observatoryChangeSettingStop(uint16 op, uint16 var, uint16 argc, ui
_observatoryIncrement = 0;
// Restore button and slider
- _vm->_gfx->copyBackBufferToScreen(_invokingResource->getRect());
+ _vm->_gfx->copyBackBufferToScreen(getInvokingResource<MystArea>()->getRect());
if (_observatoryCurrentSlider) {
_vm->redrawResource(_observatoryCurrentSlider);
_observatoryCurrentSlider = nullptr;
@@ -2874,7 +2874,7 @@ void Myst::o_imagerEraseStop(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
void Myst::o_clockLeverStartMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Clock lever start move", op);
- MystVideoInfo *lever = static_cast<MystVideoInfo *>(_invokingResource);
+ MystVideoInfo *lever = getInvokingResource<MystVideoInfo>();
lever->drawFrame(0);
_vm->_cursor->setCursor(700);
_clockMiddleGearMovedAlone = false;
@@ -2885,7 +2885,7 @@ void Myst::o_clockLeverMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Clock left lever move", op);
if (!_clockLeverPulled) {
- MystVideoInfo *lever = static_cast<MystVideoInfo *>(_invokingResource);
+ MystVideoInfo *lever = getInvokingResource<MystVideoInfo>();
// If lever pulled
if (lever->pullLeverV()) {
@@ -2977,7 +2977,7 @@ void Myst::o_clockLeverEndMove(uint16 op, uint16 var, uint16 argc, uint16 *argv)
_vm->_sound->replaceSoundMyst(8113);
// Release lever
- MystVideoInfo *lever = static_cast<MystVideoInfo *>(_invokingResource);
+ MystVideoInfo *lever = getInvokingResource<MystVideoInfo>();
lever->releaseLeverV();
// Check if puzzle is solved
@@ -3021,7 +3021,7 @@ void Myst::clockGearsCheckSolution() {
void Myst::o_clockResetLeverStartMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Clock reset lever start move", op);
- MystVideoInfo *lever = static_cast<MystVideoInfo *>(_invokingResource);
+ MystVideoInfo *lever = getInvokingResource<MystVideoInfo>();
lever->drawFrame(0);
_vm->_cursor->setCursor(700);
}
@@ -3029,7 +3029,7 @@ void Myst::o_clockResetLeverStartMove(uint16 op, uint16 var, uint16 argc, uint16
void Myst::o_clockResetLeverMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Clock reset lever move", op);
- MystVideoInfo *lever = static_cast<MystVideoInfo *>(_invokingResource);
+ MystVideoInfo *lever = getInvokingResource<MystVideoInfo>();
// If pulled
if (lever->pullLeverV() && _clockWeightPosition != 0)
@@ -3125,7 +3125,7 @@ void Myst::o_clockResetLeverEndMove(uint16 op, uint16 var, uint16 argc, uint16 *
debugC(kDebugScript, "Opcode %d: Clock reset lever end move", op);
// Get current lever frame
- MystVideoInfo *lever = static_cast<MystVideoInfo *>(_invokingResource);
+ MystVideoInfo *lever = getInvokingResource<MystVideoInfo>();
lever->releaseLeverV();
@@ -3189,7 +3189,7 @@ void Myst::towerRotationMap_run() {
void Myst::o_towerRotationMap_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
_towerRotationMapRunning = true;
- _towerRotationMapTower = static_cast<MystAreaDrag *>(_invokingResource);
+ _towerRotationMapTower = getInvokingResource<MystAreaDrag>();
_towerRotationMapLabel = static_cast<MystAreaImageSwitch *>(_vm->_resources[argv[0]]);
_tempVar = 0;
_startTime = 0;
@@ -3313,7 +3313,7 @@ void Myst::o_forechamberDoor_init(uint16 op, uint16 var, uint16 argc, uint16 *ar
void Myst::o_shipAccess_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
// Enable acces to the ship
if (_state.shipFloating) {
- _invokingResource->setEnabled(true);
+ getInvokingResource<MystArea>()->setEnabled(true);
}
}
@@ -3322,7 +3322,7 @@ void Myst::o_butterflies_init(uint16 op, uint16 var, uint16 argc, uint16 *argv)
// Used for Card 4256 (Butterfly Movie Activation)
if (!_butterfliesMoviePlayed) {
- MystAreaVideo *butterflies = static_cast<MystAreaVideo *>(_invokingResource);
+ MystAreaVideo *butterflies = getInvokingResource<MystAreaVideo>();
butterflies->playMovie();
_butterfliesMoviePlayed = true;
@@ -3333,7 +3333,7 @@ void Myst::o_imager_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Imager init", op);
debugC(kDebugScript, "Var: %d", var);
- MystAreaActionSwitch *select = static_cast<MystAreaActionSwitch *>(_invokingResource);
+ MystAreaActionSwitch *select = getInvokingResource<MystAreaActionSwitch>();
_imagerMovie = static_cast<MystAreaVideo *>(select->getSubResource(getVar(var)));
_imagerRunning = true;
}
@@ -3377,7 +3377,7 @@ void Myst::libraryBookcaseTransform_run(void) {
void Myst::o_libraryBookcaseTransform_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
if (_libraryBookcaseChanged) {
- MystAreaActionSwitch *resource = static_cast<MystAreaActionSwitch *>(_invokingResource);
+ MystAreaActionSwitch *resource = getInvokingResource<MystAreaActionSwitch>();
_libraryBookcaseMovie = static_cast<MystAreaVideo *>(resource->getSubResource(getVar(0)));
_libraryBookcaseSoundId = argv[0];
_libraryBookcaseMoving = true;
@@ -3471,7 +3471,7 @@ void Myst::o_observatory_init(uint16 op, uint16 var, uint16 argc, uint16 *argv)
_tempVar = 0;
_observatoryNotInitialized = true;
- _observatoryVisualizer = static_cast<MystAreaImageSwitch *>(_invokingResource);
+ _observatoryVisualizer = getInvokingResource<MystAreaImageSwitch>();
_observatoryGoButton = static_cast<MystAreaImageSwitch *>(_vm->_resources[argv[0]]);
if (observatoryIsDDMMYYYY2400()) {
_observatoryDaySlider = static_cast<MystAreaSlider *>(_vm->_resources[argv[1]]);
@@ -3614,13 +3614,13 @@ void Myst::gullsFly2_run() {
void Myst::o_treeCard_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Enter tree card", op);
- _tree = static_cast<MystAreaImageSwitch *>(_invokingResource);
+ _tree = getInvokingResource<MystAreaImageSwitch>();
}
void Myst::o_treeEntry_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Enter tree card with entry", op);
- _treeAlcove = static_cast<MystAreaAction *>(_invokingResource);
+ _treeAlcove = getInvokingResource<MystAreaAction>();
_treeMinAccessiblePosition = argv[0];
_treeMaxAccessiblePosition = argv[1];
diff --git a/engines/mohawk/myst_stacks/myst.h b/engines/mohawk/myst_stacks/myst.h
index 576f929..704ca81 100644
--- a/engines/mohawk/myst_stacks/myst.h
+++ b/engines/mohawk/myst_stacks/myst.h
@@ -54,7 +54,6 @@ protected:
void towerRotationMap_run();
virtual void libraryBookcaseTransform_run();
void generatorControlRoom_run();
- void opcode_212_run();
void libraryCombinationBook_run();
void clockWheel_run();
void matchBurn_run();
diff --git a/engines/mohawk/myst_stacks/preview.cpp b/engines/mohawk/myst_stacks/preview.cpp
index 7f6d38d..4245875 100644
--- a/engines/mohawk/myst_stacks/preview.cpp
+++ b/engines/mohawk/myst_stacks/preview.cpp
@@ -239,12 +239,12 @@ void Preview::o_library_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Library init", op);
// Used for Card 3002 (Myst Island Overview)
- _library = static_cast<MystAreaImageSwitch *>(_invokingResource);
+ _library = getInvokingResource<MystAreaImageSwitch>();
}
void Preview::o_libraryBookcaseTransformDemo_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
if (_libraryBookcaseChanged) {
- MystAreaActionSwitch *resource = static_cast<MystAreaActionSwitch *>(_invokingResource);
+ MystAreaActionSwitch *resource = getInvokingResource<MystAreaActionSwitch>();
_libraryBookcaseMovie = static_cast<MystAreaVideo *>(resource->getSubResource(getVar(303)));
_libraryBookcaseSoundId = argv[0];
_libraryBookcaseMoving = true;
diff --git a/engines/mohawk/myst_stacks/selenitic.cpp b/engines/mohawk/myst_stacks/selenitic.cpp
index 30333ec..5fdd37f 100644
--- a/engines/mohawk/myst_stacks/selenitic.cpp
+++ b/engines/mohawk/myst_stacks/selenitic.cpp
@@ -39,7 +39,6 @@ namespace MystStacks {
Selenitic::Selenitic(MohawkEngine_Myst *vm) :
MystScriptParser(vm), _state(vm->_gameState->_selenitic) {
setupOpcodes();
- _invokingResource = nullptr;
_mazeRunnerPosition = 288;
_mazeRunnerDirection = 8;
}
@@ -929,15 +928,15 @@ void Selenitic::o_soundReceiverEndMove(uint16 op, uint16 var, uint16 argc, uint1
}
void Selenitic::o_mazeRunnerCompass_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
- _mazeRunnerCompass = static_cast<MystAreaImageSwitch *>(_invokingResource);
+ _mazeRunnerCompass = getInvokingResource<MystAreaImageSwitch>();
}
void Selenitic::o_mazeRunnerWindow_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
- _mazeRunnerWindow = static_cast<MystAreaImageSwitch *>(_invokingResource);
+ _mazeRunnerWindow = getInvokingResource<MystAreaImageSwitch>();
}
void Selenitic::o_mazeRunnerLight_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
- _mazeRunnerLight = static_cast<MystAreaImageSwitch *>(_invokingResource);
+ _mazeRunnerLight = getInvokingResource<MystAreaImageSwitch>();
}
void Selenitic::soundReceiver_run() {
@@ -1116,11 +1115,11 @@ void Selenitic::o_soundLock_init(uint16 op, uint16 var, uint16 argc, uint16 *arg
}
void Selenitic::o_mazeRunnerRight_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
- _mazeRunnerRightButton = static_cast<MystAreaImageSwitch *>(_invokingResource);
+ _mazeRunnerRightButton = getInvokingResource<MystAreaImageSwitch>();
}
void Selenitic::o_mazeRunnerLeft_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
- _mazeRunnerLeftButton = static_cast<MystAreaImageSwitch *>(_invokingResource);
+ _mazeRunnerLeftButton = getInvokingResource<MystAreaImageSwitch>();
}
const uint16 Selenitic::_mazeRunnerMap[300][4] = {
diff --git a/engines/mohawk/myst_stacks/stoneship.cpp b/engines/mohawk/myst_stacks/stoneship.cpp
index d20ed32..77a7718 100644
--- a/engines/mohawk/myst_stacks/stoneship.cpp
+++ b/engines/mohawk/myst_stacks/stoneship.cpp
@@ -466,7 +466,7 @@ void Stoneship::o_telescopeStart(uint16 op, uint16 var, uint16 argc, uint16 *arg
void Stoneship::o_telescopeMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Telescope move", op);
- MystAreaDrag *display = static_cast<MystAreaDrag *>(_invokingResource);
+ MystAreaDrag *display = getInvokingResource<MystAreaDrag>();
const Common::Point &mouse = _vm->_system->getEventManager()->getMousePos();
// Compute telescope position
@@ -489,7 +489,7 @@ void Stoneship::o_telescopeStop(uint16 op, uint16 var, uint16 argc, uint16 *argv
void Stoneship::o_generatorStart(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Generator start", op);
- MystAreaDrag *handle = static_cast<MystAreaDrag *>(_invokingResource);
+ MystAreaDrag *handle = getInvokingResource<MystAreaDrag>();
uint16 soundId = handle->getList1(0);
if (soundId)
@@ -530,7 +530,7 @@ void Stoneship::o_generatorStop(uint16 op, uint16 var, uint16 argc, uint16 *argv
}
// Pause handle movie
- MystAreaDrag *handle = static_cast<MystAreaDrag *>(_invokingResource);
+ MystAreaDrag *handle = getInvokingResource<MystAreaDrag>();
MystAreaVideo *movie = static_cast<MystAreaVideo *>(handle->getSubResource(0));
movie->pauseMovie(true);
@@ -617,7 +617,7 @@ void Stoneship::o_hologramSelectionStart(uint16 op, uint16 var, uint16 argc, uin
void Stoneship::o_hologramSelectionMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Hologram move", op);
- MystAreaDrag *handle = static_cast<MystAreaDrag *>(_invokingResource);
+ MystAreaDrag *handle = getInvokingResource<MystAreaDrag>();
const Common::Point &mouse = _vm->_system->getEventManager()->getMousePos();
if (handle->getRect().contains(mouse)) {
@@ -806,7 +806,7 @@ void Stoneship::o_cloudOrbLeave(uint16 op, uint16 var, uint16 argc, uint16 *argv
_cloudOrbMovie->pauseMovie(true);
_vm->_sound->replaceSoundMyst(_cloudOrbStopSound);
- _vm->_gfx->runTransition(kTransitionTopToBottom, _invokingResource->getRect(), 4, 0);
+ _vm->_gfx->runTransition(kTransitionTopToBottom, getInvokingResource<MystArea>()->getRect(), 4, 0);
}
void Stoneship::o_drawerCloseOpened(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
@@ -828,14 +828,14 @@ void Stoneship::drawerClose(uint16 drawer) {
void Stoneship::o_hologramDisplay_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Hologram display init", op);
- _hologramDisplay = static_cast<MystAreaVideo *>(_invokingResource);
+ _hologramDisplay = getInvokingResource<MystAreaVideo>();
_hologramDisplayPos = 0;
}
void Stoneship::o_hologramSelection_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Hologram selection init", op);
- _hologramSelection = static_cast<MystAreaVideo *>(_invokingResource);
+ _hologramSelection = getInvokingResource<MystAreaVideo>();
}
void Stoneship::batteryGaugeUpdate() {
@@ -856,7 +856,7 @@ void Stoneship::o_battery_init(uint16 op, uint16 var, uint16 argc, uint16 *argv)
// Used for Card 2160 (Lighthouse Battery Pack Closeup)
debugC(kDebugScript, "Opcode %d: Battery init", op);
- _batteryGauge = static_cast<MystAreaImageSwitch *>(_invokingResource);
+ _batteryGauge = getInvokingResource<MystAreaImageSwitch>();
batteryGaugeUpdate();
}
@@ -1014,7 +1014,7 @@ void Stoneship::o_achenarDrawers_init(uint16 op, uint16 var, uint16 argc, uint16
void Stoneship::o_cloudOrb_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Cloud orb init", op);
- _cloudOrbMovie = static_cast<MystAreaVideo *>(_invokingResource);
+ _cloudOrbMovie = getInvokingResource<MystAreaVideo>();
_cloudOrbSound = argv[0];
_cloudOrbStopSound = argv[1];
}
Commit: 727ee86a443b48d68e22027c7691e5b4c5088641
https://github.com/scummvm/scummvm/commit/727ee86a443b48d68e22027c7691e5b4c5088641
Author: Bastien Bouclet (bastien.bouclet at gmail.com)
Date: 2016-02-07T15:27:03+01:00
Commit Message:
MOHAWK: Don't use static_cast to downcast view resources
Changed paths:
engines/mohawk/myst.h
engines/mohawk/myst_stacks/channelwood.cpp
engines/mohawk/myst_stacks/myst.cpp
engines/mohawk/myst_stacks/selenitic.cpp
engines/mohawk/myst_stacks/stoneship.cpp
diff --git a/engines/mohawk/myst.h b/engines/mohawk/myst.h
index 4439cb9..7fd2145 100644
--- a/engines/mohawk/myst.h
+++ b/engines/mohawk/myst.h
@@ -196,6 +196,9 @@ public:
void drawCardBackground();
uint16 getCardBackgroundId();
+ template<class T>
+ T *getViewResource(uint index);
+
void setCacheState(bool state) { _cache.enabled = state; }
bool getCacheState() { return _cache.enabled; }
@@ -242,6 +245,17 @@ private:
uint16 _mainCursor; // Also defines the current page being held (white, blue, red, or none)
};
+template<class T>
+T *MohawkEngine_Myst::getViewResource(uint index) {
+ T *resource = dynamic_cast<T *>(_resources[index]);
+
+ if (!resource) {
+ error("View resource '%d' has unexpected type", index);
+ }
+
+ return resource;
+}
+
} // End of namespace Mohawk
#endif
diff --git a/engines/mohawk/myst_stacks/channelwood.cpp b/engines/mohawk/myst_stacks/channelwood.cpp
index 9036328..fe93770 100644
--- a/engines/mohawk/myst_stacks/channelwood.cpp
+++ b/engines/mohawk/myst_stacks/channelwood.cpp
@@ -680,7 +680,7 @@ void Channelwood::o_hologramTemple(uint16 op, uint16 var, uint16 argc, uint16 *a
void Channelwood::o_executeMouseUp(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Execute mouse up", op);
- MystAreaAction *resource = static_cast<MystAreaAction *>(_vm->_resources[argv[0]]);
+ MystAreaAction *resource = _vm->getViewResource<MystAreaAction>(argv[0]);
resource->handleMouseUp();
}
diff --git a/engines/mohawk/myst_stacks/myst.cpp b/engines/mohawk/myst_stacks/myst.cpp
index d928887..c5e151c 100644
--- a/engines/mohawk/myst_stacks/myst.cpp
+++ b/engines/mohawk/myst_stacks/myst.cpp
@@ -3190,7 +3190,7 @@ void Myst::towerRotationMap_run() {
void Myst::o_towerRotationMap_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
_towerRotationMapRunning = true;
_towerRotationMapTower = getInvokingResource<MystAreaDrag>();
- _towerRotationMapLabel = static_cast<MystAreaImageSwitch *>(_vm->_resources[argv[0]]);
+ _towerRotationMapLabel = _vm->getViewResource<MystAreaImageSwitch>(argv[0]);
_tempVar = 0;
_startTime = 0;
_towerRotationMapClicked = false;
@@ -3202,7 +3202,7 @@ void Myst::towerRotationDrawBuildings() {
// Draw other resources
for (uint i = 1; i <= 10; i++) {
- MystAreaImageSwitch *resource = static_cast<MystAreaImageSwitch *>(_vm->_resources[i]);
+ MystAreaImageSwitch *resource = _vm->getViewResource<MystAreaImageSwitch>(i);
_vm->redrawResource(resource, false);
}
}
@@ -3472,16 +3472,16 @@ void Myst::o_observatory_init(uint16 op, uint16 var, uint16 argc, uint16 *argv)
_tempVar = 0;
_observatoryNotInitialized = true;
_observatoryVisualizer = getInvokingResource<MystAreaImageSwitch>();
- _observatoryGoButton = static_cast<MystAreaImageSwitch *>(_vm->_resources[argv[0]]);
+ _observatoryGoButton = _vm->getViewResource<MystAreaImageSwitch>(argv[0]);
if (observatoryIsDDMMYYYY2400()) {
- _observatoryDaySlider = static_cast<MystAreaSlider *>(_vm->_resources[argv[1]]);
- _observatoryMonthSlider = static_cast<MystAreaSlider *>(_vm->_resources[argv[2]]);
+ _observatoryDaySlider = _vm->getViewResource<MystAreaSlider>(argv[1]);
+ _observatoryMonthSlider = _vm->getViewResource<MystAreaSlider>(argv[2]);
} else {
- _observatoryMonthSlider = static_cast<MystAreaSlider *>(_vm->_resources[argv[1]]);
- _observatoryDaySlider = static_cast<MystAreaSlider *>(_vm->_resources[argv[2]]);
+ _observatoryMonthSlider = _vm->getViewResource<MystAreaSlider>(argv[1]);
+ _observatoryDaySlider = _vm->getViewResource<MystAreaSlider>(argv[2]);
}
- _observatoryYearSlider = static_cast<MystAreaSlider *>(_vm->_resources[argv[3]]);
- _observatoryTimeSlider = static_cast<MystAreaSlider *>(_vm->_resources[argv[4]]);
+ _observatoryYearSlider = _vm->getViewResource<MystAreaSlider>(argv[3]);
+ _observatoryTimeSlider = _vm->getViewResource<MystAreaSlider>(argv[4]);
// Set date selection sliders position
_observatoryDaySlider->setPosition(_state.observatoryDaySlider);
@@ -3704,11 +3704,11 @@ void Myst::boilerGaugeInit() {
void Myst::o_rocketSliders_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Rocket sliders init", op);
- _rocketSlider1 = static_cast<MystAreaSlider *>(_vm->_resources[argv[0]]);
- _rocketSlider2 = static_cast<MystAreaSlider *>(_vm->_resources[argv[1]]);
- _rocketSlider3 = static_cast<MystAreaSlider *>(_vm->_resources[argv[2]]);
- _rocketSlider4 = static_cast<MystAreaSlider *>(_vm->_resources[argv[3]]);
- _rocketSlider5 = static_cast<MystAreaSlider *>(_vm->_resources[argv[4]]);
+ _rocketSlider1 = _vm->getViewResource<MystAreaSlider>(argv[0]);
+ _rocketSlider2 = _vm->getViewResource<MystAreaSlider>(argv[1]);
+ _rocketSlider3 = _vm->getViewResource<MystAreaSlider>(argv[2]);
+ _rocketSlider4 = _vm->getViewResource<MystAreaSlider>(argv[3]);
+ _rocketSlider5 = _vm->getViewResource<MystAreaSlider>(argv[4]);
// Initialize sliders position
for (uint i = 0; i < 5; i++)
diff --git a/engines/mohawk/myst_stacks/selenitic.cpp b/engines/mohawk/myst_stacks/selenitic.cpp
index 5fdd37f..034c6c8 100644
--- a/engines/mohawk/myst_stacks/selenitic.cpp
+++ b/engines/mohawk/myst_stacks/selenitic.cpp
@@ -1058,19 +1058,19 @@ void Selenitic::o_soundReceiver_init(uint16 op, uint16 var, uint16 argc, uint16
// Used for Card 1245 (Sound Receiver)
_soundReceiverRunning = true;
- _soundReceiverRightButton = static_cast<MystAreaImageSwitch *>(_vm->_resources[0]);
- _soundReceiverLeftButton = static_cast<MystAreaImageSwitch *>(_vm->_resources[1]);
- _soundReceiverSigmaButton = static_cast<MystAreaImageSwitch *>(_vm->_resources[2]);
- _soundReceiverSources[4] = static_cast<MystAreaImageSwitch *>(_vm->_resources[3]);
- _soundReceiverSources[3] = static_cast<MystAreaImageSwitch *>(_vm->_resources[4]);
- _soundReceiverSources[2] = static_cast<MystAreaImageSwitch *>(_vm->_resources[5]);
- _soundReceiverSources[1] = static_cast<MystAreaImageSwitch *>(_vm->_resources[6]);
- _soundReceiverSources[0] = static_cast<MystAreaImageSwitch *>(_vm->_resources[7]);
- _soundReceiverViewer = static_cast<MystAreaImageSwitch *>(_vm->_resources[8]);
- _soundReceiverAngle1 = static_cast<MystAreaImageSwitch *>(_vm->_resources[10]);
- _soundReceiverAngle2 = static_cast<MystAreaImageSwitch *>(_vm->_resources[11]);
- _soundReceiverAngle3 = static_cast<MystAreaImageSwitch *>(_vm->_resources[12]);
- _soundReceiverAngle4 = static_cast<MystAreaImageSwitch *>(_vm->_resources[13]);
+ _soundReceiverRightButton = _vm->getViewResource<MystAreaImageSwitch>(0);
+ _soundReceiverLeftButton = _vm->getViewResource<MystAreaImageSwitch>(1);
+ _soundReceiverSigmaButton = _vm->getViewResource<MystAreaImageSwitch>(2);
+ _soundReceiverSources[4] = _vm->getViewResource<MystAreaImageSwitch>(3);
+ _soundReceiverSources[3] = _vm->getViewResource<MystAreaImageSwitch>(4);
+ _soundReceiverSources[2] = _vm->getViewResource<MystAreaImageSwitch>(5);
+ _soundReceiverSources[1] = _vm->getViewResource<MystAreaImageSwitch>(6);
+ _soundReceiverSources[0] = _vm->getViewResource<MystAreaImageSwitch>(7);
+ _soundReceiverViewer = _vm->getViewResource<MystAreaImageSwitch>(8);
+ _soundReceiverAngle1 = _vm->getViewResource<MystAreaImageSwitch>(10);
+ _soundReceiverAngle2 = _vm->getViewResource<MystAreaImageSwitch>(11);
+ _soundReceiverAngle3 = _vm->getViewResource<MystAreaImageSwitch>(12);
+ _soundReceiverAngle4 = _vm->getViewResource<MystAreaImageSwitch>(13);
uint16 currentSource = _state.soundReceiverCurrentSource;
_soundReceiverPosition = &_state.soundReceiverPositions[currentSource];
@@ -1086,28 +1086,28 @@ void Selenitic::o_soundLock_init(uint16 op, uint16 var, uint16 argc, uint16 *arg
if (_vm->_resources[i]->type == kMystAreaSlider) {
switch (_vm->_resources[i]->getImageSwitchVar()) {
case 20:
- _soundLockSlider1 = static_cast<MystAreaSlider *>(_vm->_resources[i]);
+ _soundLockSlider1 = _vm->getViewResource<MystAreaSlider>(i);
_soundLockSlider1->setStep(_state.soundLockSliderPositions[0]);
break;
case 21:
- _soundLockSlider2 = static_cast<MystAreaSlider *>(_vm->_resources[i]);
+ _soundLockSlider2 = _vm->getViewResource<MystAreaSlider>(i);
_soundLockSlider2->setStep(_state.soundLockSliderPositions[1]);
break;
case 22:
- _soundLockSlider3 = static_cast<MystAreaSlider *>(_vm->_resources[i]);
+ _soundLockSlider3 = _vm->getViewResource<MystAreaSlider>(i);
_soundLockSlider3->setStep(_state.soundLockSliderPositions[2]);
break;
case 23:
- _soundLockSlider4 = static_cast<MystAreaSlider *>(_vm->_resources[i]);
+ _soundLockSlider4 = _vm->getViewResource<MystAreaSlider>(i);
_soundLockSlider4->setStep(_state.soundLockSliderPositions[3]);
break;
case 24:
- _soundLockSlider5 = static_cast<MystAreaSlider *>(_vm->_resources[i]);
+ _soundLockSlider5 = _vm->getViewResource<MystAreaSlider>(i);
_soundLockSlider5->setStep(_state.soundLockSliderPositions[4]);
break;
}
} else if (_vm->_resources[i]->type == kMystAreaImageSwitch && _vm->_resources[i]->getImageSwitchVar() == 28) {
- _soundLockButton = static_cast<MystAreaImageSwitch *>(_vm->_resources[i]);
+ _soundLockButton = _vm->getViewResource<MystAreaImageSwitch>(i);
}
}
diff --git a/engines/mohawk/myst_stacks/stoneship.cpp b/engines/mohawk/myst_stacks/stoneship.cpp
index 77a7718..939e840 100644
--- a/engines/mohawk/myst_stacks/stoneship.cpp
+++ b/engines/mohawk/myst_stacks/stoneship.cpp
@@ -437,7 +437,7 @@ void Stoneship::o_cabinBookMovie(uint16 op, uint16 var, uint16 argc, uint16 *arg
void Stoneship::o_drawerOpenSirius(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Open drawer", op);
- MystAreaImageSwitch *drawer = static_cast<MystAreaImageSwitch *>(_vm->_resources[argv[0]]);
+ MystAreaImageSwitch *drawer = _vm->getViewResource<MystAreaImageSwitch>(argv[0]);
if (drawer->getImageSwitchVar() == 35) {
drawer->drawConditionalDataToScreen(getVar(102), 0);
@@ -582,7 +582,7 @@ void Stoneship::batteryDeplete_run() {
void Stoneship::o_drawerOpenAchenar(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Open drawer", op);
- MystAreaImageSwitch *drawer = static_cast<MystAreaImageSwitch *>(_vm->_resources[argv[0]]);
+ MystAreaImageSwitch *drawer = _vm->getViewResource<MystAreaImageSwitch>(argv[0]);
drawer->drawConditionalDataToScreen(0, 0);
_vm->_gfx->runTransition(kTransitionTopToBottom, drawer->getRect(), 25, 5);
}
Commit: de5015dce4bbdaa49c9595610af636b3b700be90
https://github.com/scummvm/scummvm/commit/de5015dce4bbdaa49c9595610af636b3b700be90
Author: Bastien Bouclet (bastien.bouclet at gmail.com)
Date: 2016-02-07T15:27:03+01:00
Commit Message:
MOHAWK: Fix some incorrect MystArea casts
Changed paths:
engines/mohawk/myst_stacks/channelwood.cpp
engines/mohawk/myst_stacks/channelwood.h
engines/mohawk/myst_stacks/myst.cpp
engines/mohawk/myst_stacks/myst.h
diff --git a/engines/mohawk/myst_stacks/channelwood.cpp b/engines/mohawk/myst_stacks/channelwood.cpp
index fe93770..cd6935b 100644
--- a/engines/mohawk/myst_stacks/channelwood.cpp
+++ b/engines/mohawk/myst_stacks/channelwood.cpp
@@ -680,7 +680,7 @@ void Channelwood::o_hologramTemple(uint16 op, uint16 var, uint16 argc, uint16 *a
void Channelwood::o_executeMouseUp(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Execute mouse up", op);
- MystAreaAction *resource = _vm->getViewResource<MystAreaAction>(argv[0]);
+ MystArea *resource = _vm->getViewResource<MystArea>(argv[0]);
resource->handleMouseUp();
}
@@ -753,7 +753,7 @@ void Channelwood::o_soundReplace(uint16 op, uint16 var, uint16 argc, uint16 *arg
void Channelwood::o_lever_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Generic lever init", op);
- _leverAction = getInvokingResource<MystAreaAction>();
+ _leverAction = getInvokingResource<MystArea>();
}
void Channelwood::o_pipeValve_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
diff --git a/engines/mohawk/myst_stacks/channelwood.h b/engines/mohawk/myst_stacks/channelwood.h
index c141a62..ac875e5 100644
--- a/engines/mohawk/myst_stacks/channelwood.h
+++ b/engines/mohawk/myst_stacks/channelwood.h
@@ -94,7 +94,7 @@ private:
uint16 _doorOpened; // 68
bool _leverPulled;
- MystAreaAction *_leverAction; // 72
+ MystArea *_leverAction; // 72
bool pipeChangeValve(bool open, uint16 mask);
};
diff --git a/engines/mohawk/myst_stacks/myst.cpp b/engines/mohawk/myst_stacks/myst.cpp
index c5e151c..4009d0d 100644
--- a/engines/mohawk/myst_stacks/myst.cpp
+++ b/engines/mohawk/myst_stacks/myst.cpp
@@ -3189,7 +3189,7 @@ void Myst::towerRotationMap_run() {
void Myst::o_towerRotationMap_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
_towerRotationMapRunning = true;
- _towerRotationMapTower = getInvokingResource<MystAreaDrag>();
+ _towerRotationMapTower = getInvokingResource<MystAreaImageSwitch>();
_towerRotationMapLabel = _vm->getViewResource<MystAreaImageSwitch>(argv[0]);
_tempVar = 0;
_startTime = 0;
@@ -3620,7 +3620,7 @@ void Myst::o_treeCard_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
void Myst::o_treeEntry_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Enter tree card with entry", op);
- _treeAlcove = getInvokingResource<MystAreaAction>();
+ _treeAlcove = getInvokingResource<MystArea>();
_treeMinAccessiblePosition = argv[0];
_treeMaxAccessiblePosition = argv[1];
diff --git a/engines/mohawk/myst_stacks/myst.h b/engines/mohawk/myst_stacks/myst.h
index 704ca81..5c84cd7 100644
--- a/engines/mohawk/myst_stacks/myst.h
+++ b/engines/mohawk/myst_stacks/myst.h
@@ -247,7 +247,7 @@ protected:
bool _towerRotationBlinkLabel;
uint16 _towerRotationBlinkLabelCount;
uint16 _towerRotationMapInitialized; // 292
- MystAreaDrag *_towerRotationMapTower; // 108
+ MystAreaImageSwitch *_towerRotationMapTower; // 108
MystAreaImageSwitch *_towerRotationMapLabel; // 112
uint16 _towerRotationSpeed; // 124
bool _towerRotationMapClicked; // 132
@@ -269,7 +269,7 @@ protected:
bool _treeStopped; // 236
MystAreaImageSwitch *_tree; // 220
- MystAreaAction *_treeAlcove; // 224
+ MystArea *_treeAlcove; // 224
uint16 _treeMinPosition; // 228
uint16 _treeMinAccessiblePosition; // 230
uint16 _treeMaxAccessiblePosition; // 232
Commit: eb47dcf2c95ee4eb731aa0385403dce7665aec75
https://github.com/scummvm/scummvm/commit/eb47dcf2c95ee4eb731aa0385403dce7665aec75
Author: Bastien Bouclet (bastien.bouclet at gmail.com)
Date: 2016-02-07T15:27:03+01:00
Commit Message:
MOHAWK: Implement preloading conditional script resources
Changed paths:
engines/mohawk/myst.cpp
engines/mohawk/myst.h
diff --git a/engines/mohawk/myst.cpp b/engines/mohawk/myst.cpp
index e4f77af..91cb9a4 100644
--- a/engines/mohawk/myst.cpp
+++ b/engines/mohawk/myst.cpp
@@ -682,7 +682,7 @@ MystArea *MohawkEngine_Myst::updateCurrentResource() {
}
void MohawkEngine_Myst::loadCard() {
- debugC(kDebugView, "Loading Card View:");
+ debugC(kDebugView, "Loading Card View: %d", _curCard);
Common::SeekableReadStream *viewStream = getResource(ID_VIEW, _curCard);
@@ -752,7 +752,7 @@ void MohawkEngine_Myst::loadCard() {
}
} else {
debugC(kDebugView, "Unknown");
- warning("Unknown sound control value in card");
+ warning("Unknown sound control value '%d' in card '%d'", _view.sound, _curCard);
}
// Resources that scripts can call upon
@@ -762,35 +762,42 @@ void MohawkEngine_Myst::loadCard() {
MystView::ScriptResource scriptResource;
debugC(kDebugView, "\tResource %d:", i);
- scriptResource.type = viewStream->readUint16LE();
+ scriptResource.type = (MystView::ScriptResourceType) viewStream->readUint16LE();
debugC(kDebugView, "\t\t Type: %d", scriptResource.type);
switch (scriptResource.type) {
- case 1:
+ case MystView::kResourceImage:
debugC(kDebugView, "\t\t\t\t= Image");
break;
- case 2:
+ case MystView::kResourceSound:
debugC(kDebugView, "\t\t\t\t= Sound");
break;
- case 3:
- debugC(kDebugView, "\t\t\t\t= Resource List");
+ case MystView::kResourceSwitch:
+ debugC(kDebugView, "\t\t\t\t= Resource Switch");
+ break;
+ case MystView::kResourceImageNoCache:
+ debugC(kDebugView, "\t\t\t\t= Image - Caching disabled");
+ break;
+ case MystView::kResourceSoundNoCache:
+ debugC(kDebugView, "\t\t\t\t= Sound - Caching disabled");
break;
default:
debugC(kDebugView, "\t\t\t\t= Unknown");
+ warning("Unknown script resource type '%d' in card '%d'", scriptResource.type, _curCard);
break;
}
- if (scriptResource.type == 3) {
- scriptResource.var = viewStream->readUint16LE();
- debugC(kDebugView, "\t\t Var: %d", scriptResource.var);
+ if (scriptResource.type == MystView::kResourceSwitch) {
+ scriptResource.switchVar = viewStream->readUint16LE();
+ debugC(kDebugView, "\t\t Var: %d", scriptResource.switchVar);
uint16 count = viewStream->readUint16LE();
debugC(kDebugView, "\t\t Resource List Count: %d", count);
- scriptResource.u0 = viewStream->readUint16LE();
- debugC(kDebugView, "\t\t u0: %d", scriptResource.u0);
+ scriptResource.switchResourceType = (MystView::ScriptResourceType) viewStream->readUint16LE();
+ debugC(kDebugView, "\t\t u0: %d", scriptResource.switchResourceType);
for (uint16 j = 0; j < count; j++) {
- scriptResource.resourceList.push_back(viewStream->readSint16LE());
- debugC(kDebugView, "\t\t Resource List %d: %d", j, scriptResource.resourceList[j]);
+ scriptResource.switchResourceIds.push_back(viewStream->readSint16LE());
+ debugC(kDebugView, "\t\t Resource List %d: %d", j, scriptResource.switchResourceIds[j]);
}
} else {
scriptResource.id = viewStream->readUint16LE();
@@ -812,7 +819,6 @@ void MohawkEngine_Myst::loadCard() {
delete viewStream;
// Precache Card Resources
- // TODO: Deal with Mac ME External Picture File
uint32 cacheImageType;
if (getFeatures() & GF_ME)
cacheImageType = ID_PICT;
@@ -821,39 +827,49 @@ void MohawkEngine_Myst::loadCard() {
// Precache Image Block data
if (_view.conditionalImages.size() != 0) {
- for (uint16 i = 0; i < _view.conditionalImages.size(); i++)
- for (uint16 j = 0; j < _view.conditionalImages[i].values.size(); j++)
- cachePreload(cacheImageType, _view.conditionalImages[i].values[j]);
- } else
+ for (uint16 i = 0; i < _view.conditionalImages.size(); i++) {
+ uint16 value = _scriptParser->getVar(_view.conditionalImages[i].var);
+ cachePreload(cacheImageType, _view.conditionalImages[i].values[value]);
+ }
+ } else {
cachePreload(cacheImageType, _view.mainImage);
+ }
// Precache Sound Block data
if (_view.sound > 0)
cachePreload(ID_MSND, _view.sound);
else if (_view.sound == kMystSoundActionConditional) {
- for (uint16 i = 0; i < _view.soundList.size(); i++) {
- if (_view.soundList[i].action > 0)
- cachePreload(ID_MSND, _view.soundList[i].action);
+ uint16 value = _scriptParser->getVar(_view.soundVar);
+ if (_view.soundList[value].action > 0) {
+ cachePreload(ID_MSND, _view.soundList[value].action);
}
}
// Precache Script Resources
- if (_view.scriptResources.size() != 0) {
- for (uint16 i = 0; i < _view.scriptResources.size(); i++) {
- switch (_view.scriptResources[i].type) {
- case 1:
- cachePreload(cacheImageType, _view.scriptResources[i].id);
- break;
- case 2:
- cachePreload(ID_MSND, _view.scriptResources[i].id);
- break;
- case 3:
- warning("TODO: Precaching of Script Resource List not supported");
- break;
- default:
- warning("Unknown Resource in Script Resource List Precaching");
- break;
- }
+ for (uint16 i = 0; i < _view.scriptResources.size(); i++) {
+ MystView::ScriptResourceType type;
+ int16 id;
+ if (_view.scriptResources[i].type == MystView::kResourceSwitch) {
+ type = _view.scriptResources[i].switchResourceType;
+ uint16 value = _scriptParser->getVar(_view.scriptResources[i].switchVar);
+ id = _view.scriptResources[i].switchResourceIds[value];
+ } else {
+ type = _view.scriptResources[i].type;
+ id = _view.scriptResources[i].id;
+ }
+
+ if (id < 0) continue;
+
+ switch (type) {
+ case MystView::kResourceImage:
+ cachePreload(cacheImageType, id);
+ break;
+ case MystView::kResourceSound:
+ cachePreload(ID_MSND, id);
+ break;
+ default:
+ // The other resource types should not be cached
+ break;
}
}
}
diff --git a/engines/mohawk/myst.h b/engines/mohawk/myst.h
index 7fd2145..34607d8 100644
--- a/engines/mohawk/myst.h
+++ b/engines/mohawk/myst.h
@@ -130,13 +130,20 @@ struct MystView {
Common::Array<MystSoundItem> soundList;
// Script Resources
+ enum ScriptResourceType {
+ kResourceImage = 1,
+ kResourceSound = 2,
+ kResourceSwitch = 3,
+ kResourceImageNoCache = 4,
+ kResourceSoundNoCache = 5
+ };
+
struct ScriptResource {
- uint16 type;
- uint16 id; // Not used by type 3
- // TODO: Type 3 has more. Maybe use a union?
- uint16 var; // Used by type 3 only
- uint16 u0; // Used by type 3 only
- Common::Array<int16> resourceList; // Used by type 3 only
+ ScriptResourceType type;
+ uint16 id;
+ uint16 switchVar;
+ ScriptResourceType switchResourceType;
+ Common::Array<int16> switchResourceIds;
};
Common::Array<ScriptResource> scriptResources;
Commit: 01bfd37919514355513263bb6dfe6d7964b34695
https://github.com/scummvm/scummvm/commit/01bfd37919514355513263bb6dfe6d7964b34695
Author: Bastien Bouclet (bastien.bouclet at gmail.com)
Date: 2016-02-07T15:27:03+01:00
Commit Message:
MOHAWK: Adjust MystAreaVideo::playAreaVideo for the refactored VideoManager
The refactoring in 7e6c8be7db2449c1f793b6fb01af5613282e7f27
changed the behavior of VideoManager::playMovie to start stopped
movies.
The refactoring in 9665efa39a4df000eb695329a9b81c1657f4dc10
changed the behavior of MystAreaVideo::playAreaVideo to set the position
and looping flag for already playing movies.
This commit hopefuly reverts to the previous behavior for videos
already loaded in VideoManager.
Changed paths:
engines/mohawk/myst_areas.cpp
diff --git a/engines/mohawk/myst_areas.cpp b/engines/mohawk/myst_areas.cpp
index f8ee56f..82213fa 100644
--- a/engines/mohawk/myst_areas.cpp
+++ b/engines/mohawk/myst_areas.cpp
@@ -225,7 +225,7 @@ VideoHandle MystAreaVideo::playMovie() {
VideoHandle handle = _vm->_video->findVideoHandle(_videoFile);
// If the video is not running, play it
- if (!handle || handle->endOfVideo()) {
+ if (!handle) {
handle = _vm->_video->playMovie(_videoFile);
if (!handle)
error("Failed to open '%s'", _videoFile.c_str());
Commit: 22882f54e19c1317d89e92e0578bcc94e2007e7f
https://github.com/scummvm/scummvm/commit/22882f54e19c1317d89e92e0578bcc94e2007e7f
Author: Bastien Bouclet (bastien.bouclet at gmail.com)
Date: 2016-02-07T15:27:03+01:00
Commit Message:
MOHAWK: Fix uninitialized memory accesses in the Myst stacks
Changed paths:
engines/mohawk/myst_stacks/credits.cpp
engines/mohawk/myst_stacks/mechanical.cpp
engines/mohawk/myst_stacks/selenitic.cpp
engines/mohawk/myst_stacks/stoneship.cpp
diff --git a/engines/mohawk/myst_stacks/credits.cpp b/engines/mohawk/myst_stacks/credits.cpp
index b9ff8b2..6548dd3 100644
--- a/engines/mohawk/myst_stacks/credits.cpp
+++ b/engines/mohawk/myst_stacks/credits.cpp
@@ -37,6 +37,7 @@ namespace MystStacks {
Credits::Credits(MohawkEngine_Myst *vm) : MystScriptParser(vm) {
setupOpcodes();
+ _curImage = 0;
}
Credits::~Credits() {
diff --git a/engines/mohawk/myst_stacks/mechanical.cpp b/engines/mohawk/myst_stacks/mechanical.cpp
index b1f23d3..4f8ce54 100644
--- a/engines/mohawk/myst_stacks/mechanical.cpp
+++ b/engines/mohawk/myst_stacks/mechanical.cpp
@@ -40,6 +40,9 @@ Mechanical::Mechanical(MohawkEngine_Myst *vm) :
setupOpcodes();
_elevatorGoingMiddle = false;
+ _elevatorPosition = 0;
+
+ _crystalLit = 0;
_mystStaircaseState = false;
_fortressPosition = 0;
diff --git a/engines/mohawk/myst_stacks/selenitic.cpp b/engines/mohawk/myst_stacks/selenitic.cpp
index 034c6c8..2617bd0 100644
--- a/engines/mohawk/myst_stacks/selenitic.cpp
+++ b/engines/mohawk/myst_stacks/selenitic.cpp
@@ -41,6 +41,10 @@ Selenitic::Selenitic(MohawkEngine_Myst *vm) :
setupOpcodes();
_mazeRunnerPosition = 288;
_mazeRunnerDirection = 8;
+ _mazeRunnerDoorOpened = false;
+
+ _soundReceiverDirection = 0;
+ _soundReceiverStartTime = 0;
}
Selenitic::~Selenitic() {
diff --git a/engines/mohawk/myst_stacks/stoneship.cpp b/engines/mohawk/myst_stacks/stoneship.cpp
index 939e840..293c0f9 100644
--- a/engines/mohawk/myst_stacks/stoneship.cpp
+++ b/engines/mohawk/myst_stacks/stoneship.cpp
@@ -50,6 +50,8 @@ Stoneship::Stoneship(MohawkEngine_Myst *vm) :
_chestDrawersOpen = 0;
_chestAchenarBottomDrawerClosed = 1;
+ _brotherDoorOpen = 0;
+
// Drop key
if (_state.trapdoorKeyState == 1)
_state.trapdoorKeyState = 2;
Commit: bc687c72162809c8848065f46166513aeea69223
https://github.com/scummvm/scummvm/commit/bc687c72162809c8848065f46166513aeea69223
Author: Bastien Bouclet (bastien.bouclet at gmail.com)
Date: 2016-02-07T15:27:03+01:00
Commit Message:
MOHAWK: Fix two Myst resource stream memory leaks
Changed paths:
engines/mohawk/myst.cpp
engines/mohawk/myst_graphics.cpp
diff --git a/engines/mohawk/myst.cpp b/engines/mohawk/myst.cpp
index 91cb9a4..9ee2caf 100644
--- a/engines/mohawk/myst.cpp
+++ b/engines/mohawk/myst.cpp
@@ -950,6 +950,8 @@ void MohawkEngine_Myst::loadHelp(uint16 id) {
debugC(kDebugHelp, "\thelpText: \"%s\"", helpText.c_str());
delete[] u0;
+
+ delete helpStream;
}
void MohawkEngine_Myst::loadCursorHints() {
diff --git a/engines/mohawk/myst_graphics.cpp b/engines/mohawk/myst_graphics.cpp
index 7cb3280..6c93f98 100644
--- a/engines/mohawk/myst_graphics.cpp
+++ b/engines/mohawk/myst_graphics.cpp
@@ -103,6 +103,8 @@ MohawkSurface *MystGraphics::decodeImage(uint16 id) {
if (!pict.loadStream(*dataStream))
error("Could not decode Myst ME PICT");
+ delete dataStream;
+
mhkSurface = new MohawkSurface(pict.getSurface()->convertTo(_pixelFormat));
} else {
mhkSurface = _bmpDecoder->decodeImage(dataStream);
Commit: e50f93f2987f41b6c9d193dcf07383ba415cb96d
https://github.com/scummvm/scummvm/commit/e50f93f2987f41b6c9d193dcf07383ba415cb96d
Author: Bastien Bouclet (bastien.bouclet at gmail.com)
Date: 2016-02-07T15:27:03+01:00
Commit Message:
MOHAWK: Fix Myst's fortress simulator using a hack
The proper solution implies support for playing movies with edit lists backwards
in QT code.
Changed paths:
engines/mohawk/myst_stacks/mechanical.cpp
engines/mohawk/myst_stacks/mechanical.h
diff --git a/engines/mohawk/myst_stacks/mechanical.cpp b/engines/mohawk/myst_stacks/mechanical.cpp
index 4f8ce54..20d01f5 100644
--- a/engines/mohawk/myst_stacks/mechanical.cpp
+++ b/engines/mohawk/myst_stacks/mechanical.cpp
@@ -941,6 +941,10 @@ void Mechanical::fortressSimulation_run() {
holo->setLooping(true);
holo->setRate(0);
+ // HACK: Support negative rates with edit lists
+ _fortressSimulationHoloRate = 0;
+ // END HACK
+
_vm->_cursor->showCursor();
_fortressSimulationInit = false;
@@ -948,6 +952,11 @@ void Mechanical::fortressSimulation_run() {
VideoHandle holo = _fortressSimulationHolo->playMovie();
double oldRate = holo->getRate().toDouble();
+
+ // HACK: Support negative rates with edit lists
+ oldRate = _fortressSimulationHoloRate;
+ // END HACK
+
uint32 moviePosition = Audio::Timestamp(holo->getTime(), 600).totalNumberOfFrames();
int32 positionInQuarter = 900 - (moviePosition + 900) % 1800;
@@ -981,7 +990,26 @@ void Mechanical::fortressSimulation_run() {
newRate = CLIP<double>(newRate, -2.5, 2.5);
- holo->setRate(Common::Rational((int)(newRate * 1000.0), 1000));
+ // HACK: Support negative rates with edit lists
+
+ // Our current QuickTime implementation does not support negative
+ // playback rates for movies using edit lists.
+ // The fortress rotation simulator movie this code handles is the
+ // only movie in the game requiring that feature.
+
+ // This hack approximates the next frame to display when the rate
+ // is negative, and seeks to it. It's not intended to be precise.
+
+ _fortressSimulationHoloRate = newRate;
+
+ if (_fortressSimulationHoloRate < 0) {
+ uint32 newMoviePosition = moviePosition + _fortressSimulationHoloRate * 10;
+ holo->setRate(0);
+ holo->seek(Audio::Timestamp(0, newMoviePosition, 600));
+ } else {
+ holo->setRate(Common::Rational((int)(newRate * 1000.0), 1000));
+ }
+ // END HACK
_gearsWereRunning = true;
} else if (_gearsWereRunning) {
@@ -989,6 +1017,11 @@ void Mechanical::fortressSimulation_run() {
uint16 simulationPosition = (moviePosition + 900) / 1800 % 4;
holo->setRate(0);
+
+ // HACK: Support negative rates with edit lists
+ _fortressSimulationHoloRate = 0;
+ // END HACK
+
holo->seek(Audio::Timestamp(0, 1800 * simulationPosition, 600));
_vm->_sound->playSoundBlocking( _fortressRotationSounds[simulationPosition]);
diff --git a/engines/mohawk/myst_stacks/mechanical.h b/engines/mohawk/myst_stacks/mechanical.h
index 159a330..aae02df 100644
--- a/engines/mohawk/myst_stacks/mechanical.h
+++ b/engines/mohawk/myst_stacks/mechanical.h
@@ -124,6 +124,10 @@ private:
MystAreaVideo *_fortressSimulationHolo; // 160
MystAreaVideo *_fortressSimulationStartup; // 164
+ // HACK: Support negative rates with edit lists
+ double _fortressSimulationHoloRate;
+ // END HACK
+
uint16 _elevatorGoingDown; // 112
float _elevatorRotationSpeed; // 120
More information about the Scummvm-git-logs
mailing list