MOHAWK: Riven: Patch prison island dome switch sound change

Fixes #9958.
This commit is contained in:
Bastien Bouclet 2017-07-14 08:16:01 +02:00
parent 6edb991bf9
commit 69dc56ad0f
5 changed files with 98 additions and 4 deletions

View file

@ -249,6 +249,53 @@ const char *RivenScript::getTypeName(uint16 type) {
return names[type];
}
void RivenScript::applyCardPatches(MohawkEngine_Riven *vm, uint32 cardGlobalId, int scriptType) {
bool shouldApplyPatches = false;
// On Prison Island when pressing the dome viewer switch to close the dome,
// the game schedules an ambient sound change using kRivenCommandStoreMovieOpcode
// but does not play the associated video in a blocking way. The stored opcode
// is not immediately used, stays in memory and may be triggered by some
// other action. (Bug #9958)
// We replace kRivenCommandStoreMovieOpcode by kRivenCommandActivateSLST
// to make the ambient sound change happen immediately.
//
// Script before patch:
// playMovieBlocking(3); // Dome closing
// playMovie(4); // Dome spinning up
// activatePLST(2); // Dome closed
// playMovieBlocking(4); // Dome spinning up
// storeMovieOpcode(1, 0, 0, 40, 2); // Schedule ambient sound change to "dome spinning"
// after movie 1 finishes blocking playback
// playMovie(1); // Dome spinning
//
// Script after patch:
// playMovieBlocking(3); // Dome closing
// playMovie(4); // Dome spinning up
// activatePLST(2); // Dome closed
// playMovieBlocking(4); // Dome spinning up
// activateSLST(2); // Ambient sound change to "dome spinning"
// playMovie(1); // Dome spinning
if (cardGlobalId == 0x1AC1 && scriptType == kCardEnterScript) {
shouldApplyPatches = true;
for (uint i = 0; i < _commands.size(); i++) {
if (_commands[i]->getType() == kRivenCommandStoreMovieOpcode) {
RivenSimpleCommand::ArgumentArray arguments;
arguments.push_back(2);
_commands[i] = RivenCommandPtr(new RivenSimpleCommand(vm, kRivenCommandActivateSLST, arguments));
debugC(kRivenDebugPatches, "Applied immediate ambient sound patch to card %x", cardGlobalId);
break;
}
}
}
if (shouldApplyPatches) {
for (uint i = 0; i < _commands.size(); i++) {
_commands[i]->applyCardPatches(cardGlobalId, scriptType);
}
}
}
RivenScriptPtr &operator+=(RivenScriptPtr &lhs, const RivenScriptPtr &rhs) {
if (rhs) {
*lhs += *rhs;
@ -691,6 +738,10 @@ void RivenSimpleCommand::execute() {
(this->*(_opcodes[_type].proc)) (_type, _arguments);
}
RivenCommandType RivenSimpleCommand::getType() const {
return _type;
}
RivenSwitchCommand::RivenSwitchCommand(MohawkEngine_Riven *vm) :
RivenCommand(vm),
_variableId(0) {
@ -768,6 +819,16 @@ void RivenSwitchCommand::execute() {
}
}
RivenCommandType RivenSwitchCommand::getType() const {
return kRivenCommandSwitch;
}
void RivenSwitchCommand::applyCardPatches(uint32 globalId, int scriptType) {
for (uint i = 0; i < _branches.size(); i++) {
_branches[i].script->applyCardPatches(_vm, globalId, scriptType);
}
}
RivenStackChangeCommand::RivenStackChangeCommand(MohawkEngine_Riven *vm, uint16 stackId, uint32 globalCardId, bool byStackId) :
RivenCommand(vm),
_stackId(stackId),
@ -813,6 +874,10 @@ void RivenStackChangeCommand::dump(byte tabs) {
debugN("changeStack(%d, %d);\n", _stackId, _cardId);
}
RivenCommandType RivenStackChangeCommand::getType() const {
return kRivenCommandChangeStack;
}
RivenTimerCommand::RivenTimerCommand(MohawkEngine_Riven *vm, const Common::SharedPtr<RivenStack::TimerProc> &timerProc) :
RivenCommand(vm),
_timerProc(timerProc) {
@ -828,4 +893,8 @@ void RivenTimerCommand::dump(byte tabs) {
debugN("doTimer();\n");
}
RivenCommandType RivenTimerCommand::getType() const {
return kRivenCommandTimer;
}
} // End of namespace Mohawk