ZVISION: Fix for script bug #6783 (no sound in the ZNem fist puzzle)

This is a bug in the original game script of the Zork Nemesis fist
puzzle, which we now patch so that the sound checks are correct for the
left fist animation
This commit is contained in:
Filippos Karapetis 2015-02-03 12:31:30 +02:00
parent f1c64c2afe
commit 6c07f918c6
2 changed files with 26 additions and 3 deletions

View File

@ -83,7 +83,7 @@ void ScriptManager::parsePuzzle(Puzzle *puzzle, Common::SeekableReadStream &stre
while (!stream.eos() && !line.contains('}')) {
if (line.matchString("criteria {", true)) {
parseCriteria(stream, puzzle->criteriaList);
parseCriteria(stream, puzzle->criteriaList, puzzle->key);
} else if (line.matchString("results {", true)) {
parseResults(stream, puzzle->resultActions);
} else if (line.matchString("flags {", true)) {
@ -97,7 +97,7 @@ void ScriptManager::parsePuzzle(Puzzle *puzzle, Common::SeekableReadStream &stre
puzzle->addedBySetState = false;
}
bool ScriptManager::parseCriteria(Common::SeekableReadStream &stream, Common::List<Common::List<Puzzle::CriteriaEntry> > &criteriaList) const {
bool ScriptManager::parseCriteria(Common::SeekableReadStream &stream, Common::List<Common::List<Puzzle::CriteriaEntry> > &criteriaList, uint32 key) const {
// Loop until we find the closing brace
Common::String line = stream.readLine();
trimCommentsAndWhiteSpace(&line);
@ -117,6 +117,21 @@ bool ScriptManager::parseCriteria(Common::SeekableReadStream &stream, Common::Li
// Create a new List to hold the CriteriaEntries
criteriaList.push_back(Common::List<Puzzle::CriteriaEntry>());
// WORKAROUND for a script bug in Zork: Nemesis, room td9e (fist puzzle)
// Since we patch the script that triggers when manipulating the left fist
// (below), we add an additional check for the left fist sound, so that it
// doesn't get killed immediately when the left fist animation starts.
// Together with the workaround below, it fixes bug #6783.
if (_engine->getGameId() == GID_NEMESIS && key == 3594) {
Puzzle::CriteriaEntry entry;
entry.key = 567;
entry.criteriaOperator = Puzzle::NOT_EQUAL_TO;
entry.argumentIsAKey = false;
entry.argument = 1;
criteriaList.back().push_back(entry);
}
while (!stream.eos() && !line.contains('}')) {
Puzzle::CriteriaEntry entry;
@ -128,6 +143,13 @@ bool ScriptManager::parseCriteria(Common::SeekableReadStream &stream, Common::Li
token = tokenizer.nextToken();
sscanf(token.c_str(), "[%u]", &(entry.key));
// WORKAROUND for a script bug in Zork: Nemesis, room td9e (fist puzzle)
// Check for the state of animation 567 (left fist) when manipulating
// the fingers of the left fist (puzzle slots 3582, 3583).
// Together with the workaround above, it fixes bug #6783.
if (_engine->getGameId() == GID_NEMESIS && (key == 3582 || key == 3583) && entry.key == 568)
entry.key = 567;
// Parse the operator out of the second token
token = tokenizer.nextToken();
if (token.c_str()[0] == '=')

View File

@ -312,9 +312,10 @@ private:
*
* @param criteria Pointer to the Criteria object to fill
* @param stream Scr file stream
* @param key Puzzle key (for workarounds)
* @return Whether any criteria were read
*/
bool parseCriteria(Common::SeekableReadStream &stream, Common::List<Common::List<Puzzle::CriteriaEntry> > &criteriaList) const;
bool parseCriteria(Common::SeekableReadStream &stream, Common::List<Common::List<Puzzle::CriteriaEntry> > &criteriaList, uint32 key) const;
/**
* Parses the stream into a ResultAction objects