From a5b0e35626f3ceb3fa65ea05a40f8b06f193c51d Mon Sep 17 00:00:00 2001 From: Bastien Bouclet Date: Sat, 5 Mar 2016 16:12:42 +0100 Subject: MOHAWK: Add a method to get a video handle from a MystAreaVideo Use it to fix the fortress rotation controls once more --- engines/mohawk/myst_areas.cpp | 14 ++++++++++++++ engines/mohawk/myst_areas.h | 2 ++ engines/mohawk/myst_stacks/mechanical.cpp | 6 +++--- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/engines/mohawk/myst_areas.cpp b/engines/mohawk/myst_areas.cpp index 193def2a32..4b9cf546fa 100644 --- a/engines/mohawk/myst_areas.cpp +++ b/engines/mohawk/myst_areas.cpp @@ -251,6 +251,20 @@ VideoHandle MystAreaVideo::playMovie() { return handle; } +VideoHandle MystAreaVideo::getMovieHandle() { + // If the video is already in the manager, just return the handle + VideoHandle handle = _vm->_video->findVideoHandle(_videoFile); + if (!handle) { + // If the video has not been loaded yet, do it but don't start playing it + handle = _vm->_video->playMovie(_videoFile); + if (!handle) + error("Failed to open '%s'", _videoFile.c_str()); + handle->stop(); + } + + return handle; +} + void MystAreaVideo::handleCardChange() { if (_playOnCardChange) playMovie(); diff --git a/engines/mohawk/myst_areas.h b/engines/mohawk/myst_areas.h index 09ec6a2742..b19a2df9e2 100644 --- a/engines/mohawk/myst_areas.h +++ b/engines/mohawk/myst_areas.h @@ -108,6 +108,8 @@ public: MystAreaVideo(MohawkEngine_Myst *vm, Common::SeekableReadStream *rlstStream, MystArea *parent); VideoHandle playMovie(); + VideoHandle getMovieHandle(); + void handleCardChange() override; bool isPlaying(); void setDirection(int16 direction) { _direction = direction; } diff --git a/engines/mohawk/myst_stacks/mechanical.cpp b/engines/mohawk/myst_stacks/mechanical.cpp index 3214c643a5..3324c9a22d 100644 --- a/engines/mohawk/myst_stacks/mechanical.cpp +++ b/engines/mohawk/myst_stacks/mechanical.cpp @@ -667,7 +667,7 @@ void Mechanical::o_elevatorTopMovie(uint16 op, uint16 var, uint16 argc, uint16 * void Mechanical::o_fortressRotationSetPosition(uint16 op, uint16 var, uint16 argc, uint16 *argv) { debugC(kDebugScript, "Opcode %d: Set fortress position", op); - VideoHandle gears = _fortressRotationGears->playMovie(); + VideoHandle gears = _fortressRotationGears->getMovieHandle(); uint32 moviePosition = Audio::Timestamp(gears->getTime(), 600).totalNumberOfFrames(); // Myst ME short movie workaround, explained in o_fortressRotation_init @@ -801,7 +801,7 @@ void Mechanical::o_elevatorRotation_init(uint16 op, uint16 var, uint16 argc, uin } void Mechanical::fortressRotation_run() { - VideoHandle gears = _fortressRotationGears->playMovie(); + VideoHandle gears = _fortressRotationGears->getMovieHandle(); double oldRate = gears->getRate().toDouble(); uint32 moviePosition = Audio::Timestamp(gears->getTime(), 600).totalNumberOfFrames(); @@ -949,7 +949,7 @@ void Mechanical::fortressSimulation_run() { _fortressSimulationInit = false; } else { - VideoHandle holo = _fortressSimulationHolo->playMovie(); + VideoHandle holo = _fortressSimulationHolo->getMovieHandle(); double oldRate = holo->getRate().toDouble(); -- cgit v1.2.3