From f99d613dcb1022a6c30b0c299ffada11fb7eba6b Mon Sep 17 00:00:00 2001 From: richiesams Date: Wed, 3 Jul 2013 15:12:24 -0500 Subject: ZVISION: Rename files to use underscores instead of camelCase --- engines/zvision/scr_file_handling.cpp | 287 ++++++++++++++++++++++++++++++++++ 1 file changed, 287 insertions(+) create mode 100644 engines/zvision/scr_file_handling.cpp (limited to 'engines/zvision/scr_file_handling.cpp') diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp new file mode 100644 index 0000000000..61feb12b7e --- /dev/null +++ b/engines/zvision/scr_file_handling.cpp @@ -0,0 +1,287 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "common/scummsys.h" + +#include + +#include "zvision/scriptManager.h" +#include "zvision/utility.h" +#include "zvision/puzzle.h" + +#include "common/textconsole.h" +#include "common/file.h" +#include "common/tokenizer.h" + +namespace ZVision { + +void ScriptManager::parseScrFile(Common::String fileName) { + Common::File file; + if (!file.open(fileName)) + return; // File.open already throws a warning if the file doesn't exist, so there is no need to throw another + + while(!file.eos()) { + Common::String line = file.readLine(); + if (file.err()) { + warning("Error parsing scr file: %s", fileName); + return; + } + + trimCommentsAndWhiteSpace(line); + if (line.empty()) + continue; + + if (line.matchString("puzzle:*", true)) { + Puzzle puzzle; + sscanf(line.c_str(),"puzzle:%u",&(puzzle.id)); + + parsePuzzle(puzzle, file); + _puzzles.push_back(puzzle); + } else if (line.matchString("control:*", true)) { + Control control; + char controlType[20]; + sscanf(line.c_str(),"control:%u %s",&(control.id), controlType); + + parseControl(control, file); + _controls.push_back(control); + } + } +} + +void ScriptManager::parsePuzzle(Puzzle &puzzle, Common::SeekableReadStream &stream) { + Common::String line = stream.readLine(); + trimCommentsAndWhiteSpace(line); + + while (!line.contains('}')) { + if (line.matchString("criteria {", true)) + puzzle.criteriaList.push_back(parseCriteria(stream)); + else if (line.matchString("results {", true)) + parseResult(stream, puzzle.resultActions); + else if (line.matchString("flags {", true)) + puzzle.flags = parseFlags(stream); + } +} + +Criteria ScriptManager::parseCriteria(Common::SeekableReadStream &stream) const { + Criteria criteria; + + // Loop until we find the closing brace + Common::String line = stream.readLine(); + trimCommentsAndWhiteSpace(line); + + while (!line.contains('}')) { + // Split the string into tokens using ' ' as a delimiter + Common::StringTokenizer tokenizer(line); + Common::String token; + + // Parse the id out of the first token + token = tokenizer.nextToken(); + sscanf(token.c_str(), "[%u]", &(criteria.id)); + + // Parse the operator out of the second token + token = tokenizer.nextToken(); + if (token.c_str()[0] == '=') + criteria.criteriaOperator = EQUAL_TO; + else if (token.c_str()[0] == '!') + criteria.criteriaOperator = NOT_EQUAL_TO; + else if (token.c_str()[0] == '>') + criteria.criteriaOperator = GREATER_THAN; + else if (token.c_str()[0] == '<') + criteria.criteriaOperator = LESS_THAN; + + // First determine if the last token is an id or a value + // Then parse it into 'argument' + token = tokenizer.nextToken(); + if (token.contains('[')) { + sscanf(token.c_str(), "[%u]", &(criteria.argument)); + criteria.isArgumentAnId = true; + } else { + sscanf(token.c_str(), "%u", &(criteria.argument)); + criteria.isArgumentAnId = false; + } + + line = stream.readLine(); + trimCommentsAndWhiteSpace(line); + } + + return criteria; +} + +void ScriptManager::parseResult(Common::SeekableReadStream &stream, Common::List &actionList) const { + // Loop until we find the closing brace + Common::String line = stream.readLine(); + trimCommentsAndWhiteSpace(line); + + while (!line.contains('}')) { + // Parse for the action type + if (line.matchString("*:add*", true)) { + actionList.push_back(ActionAdd(line)); + } else if (line.matchString("*:animplay*", true)) { + + + } else if (line.matchString("*:animpreload*", true)) { + + + } else if (line.matchString("*:animunload*", true)) { + + + } else if (line.matchString("*:attenuate*", true)) { + + + } else if (line.matchString("*:assign*", true)) { + + + } else if (line.matchString("*:change_location*", true)) { + + + } else if (line.matchString("*:crossfade*", true)) { + + + } else if (line.matchString("*:debug*", true)) { + + + } else if (line.matchString("*:delay_render*", true)) { + + + } else if (line.matchString("*:disable_control*", true)) { + + + } else if (line.matchString("*:disable_venus*", true)) { + + + } else if (line.matchString("*:display_message*", true)) { + + + } else if (line.matchString("*:dissolve*", true)) { + + + } else if (line.matchString("*:distort*", true)) { + + + } else if (line.matchString("*:enable_control*", true)) { + + + } else if (line.matchString("*:flush_mouse_events*", true)) { + + + } else if (line.matchString("*:inventory*", true)) { + + + } else if (line.matchString("*:kill*", true)) { + + + } else if (line.matchString("*:menu_bar_enable*", true)) { + + + } else if (line.matchString("*:music*", true)) { + + + } else if (line.matchString("*:pan_track*", true)) { + + + } else if (line.matchString("*:playpreload*", true)) { + + + } else if (line.matchString("*:preferences*", true)) { + + + } else if (line.matchString("*:quit*", true)) { + + + } else if (line.matchString("*:random*", true)) { + + + } else if (line.matchString("*:region*", true)) { + + + } else if (line.matchString("*:restore_game*", true)) { + + + } else if (line.matchString("*:rotate_to*", true)) { + + + } else if (line.matchString("*:save_game*", true)) { + + + } else if (line.matchString("*:set_partial_screen*", true)) { + + + } else if (line.matchString("*:set_screen*", true)) { + + + } else if (line.matchString("*:set_venus*", true)) { + + + } else if (line.matchString("*:stop*", true)) { + + + } else if (line.matchString("*:streamvideo*", true)) { + + + } else if (line.matchString("*:syncsound*", true)) { + + + } else if (line.matchString("*:timer*", true)) { + + + } else if (line.matchString("*:ttytext*", true)) { + + + } else if (line.matchString("*:universe_music*", true)) { + + + } else { + warning("Unhandled result action type: ", line); + } + + line = stream.readLine(); + trimCommentsAndWhiteSpace(line); + } + + return; +} + +byte ScriptManager::parseFlags(Common::SeekableReadStream &stream) const { + byte flags; + + // Loop until we find the closing brace + Common::String line = stream.readLine(); + trimCommentsAndWhiteSpace(line); + + while (!line.contains('}')) { + if (line.matchString("ONCE_PER_INST", true)) { + flags |= ONCE_PER_INST; + } else if (line.matchString("DO_ME_NOW", true)) { + flags |= DO_ME_NOW; + } else if (line.matchString("DISABLED", true)) { + flags |= DISABLED; + } + } + + return flags; +} + +void ScriptManager::parseControl(Control &control, Common::SeekableReadStream &stream) { + +} + +} // End of namespace ZVision -- cgit v1.2.3 From 1710468121648d494a393f7176c81027fec573c4 Mon Sep 17 00:00:00 2001 From: richiesams Date: Wed, 3 Jul 2013 15:45:46 -0500 Subject: ZVISION: Fix includes to use new underscore names --- engines/zvision/scr_file_handling.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/zvision/scr_file_handling.cpp') diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp index 61feb12b7e..d18e042815 100644 --- a/engines/zvision/scr_file_handling.cpp +++ b/engines/zvision/scr_file_handling.cpp @@ -24,7 +24,7 @@ #include -#include "zvision/scriptManager.h" +#include "zvision/script_manager.h" #include "zvision/utility.h" #include "zvision/puzzle.h" -- cgit v1.2.3 From 0b9dce40a08020499aab20d8c9d967f53f7d84ea Mon Sep 17 00:00:00 2001 From: richiesams Date: Wed, 3 Jul 2013 15:46:36 -0500 Subject: ZVISION: Fix usage of Puzzle struct to use 'key' instead of 'id' --- engines/zvision/scr_file_handling.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/zvision/scr_file_handling.cpp') diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp index d18e042815..073d0eaaa4 100644 --- a/engines/zvision/scr_file_handling.cpp +++ b/engines/zvision/scr_file_handling.cpp @@ -52,7 +52,7 @@ void ScriptManager::parseScrFile(Common::String fileName) { if (line.matchString("puzzle:*", true)) { Puzzle puzzle; - sscanf(line.c_str(),"puzzle:%u",&(puzzle.id)); + sscanf(line.c_str(),"puzzle:%u",&(puzzle.key)); parsePuzzle(puzzle, file); _puzzles.push_back(puzzle); @@ -95,7 +95,7 @@ Criteria ScriptManager::parseCriteria(Common::SeekableReadStream &stream) const // Parse the id out of the first token token = tokenizer.nextToken(); - sscanf(token.c_str(), "[%u]", &(criteria.id)); + sscanf(token.c_str(), "[%u]", &(criteria.key)); // Parse the operator out of the second token token = tokenizer.nextToken(); -- cgit v1.2.3 From 187c119e934fd5887fb26e2dada5e1a4c856e056 Mon Sep 17 00:00:00 2001 From: richiesams Date: Wed, 3 Jul 2013 17:21:21 -0500 Subject: ZVISION: Create ResultAction 's for Add and Random. Create class templates for PlayAnimation, PreloadAnimation, and Attenuate --- engines/zvision/scr_file_handling.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'engines/zvision/scr_file_handling.cpp') diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp index 073d0eaaa4..3171492717 100644 --- a/engines/zvision/scr_file_handling.cpp +++ b/engines/zvision/scr_file_handling.cpp @@ -131,16 +131,15 @@ void ScriptManager::parseResult(Common::SeekableReadStream &stream, Common::List Common::String line = stream.readLine(); trimCommentsAndWhiteSpace(line); + // TODO: Re-order the if-then statements in order of highest occurrence while (!line.contains('}')) { // Parse for the action type if (line.matchString("*:add*", true)) { actionList.push_back(ActionAdd(line)); } else if (line.matchString("*:animplay*", true)) { - - + actionList.push_back(ActionPlayAnimation(line)); } else if (line.matchString("*:animpreload*", true)) { - - + actionList.push_back(ActionPreloadAnimation(line)); } else if (line.matchString("*:animunload*", true)) { -- cgit v1.2.3 From 3822de2aec0d41df7c2beeb5a1269577e9c3df84 Mon Sep 17 00:00:00 2001 From: richiesams Date: Wed, 3 Jul 2013 18:24:06 -0500 Subject: ZVISION: Change Puzzle::resultActions to a List of pointers instead of ResultAction objects ResultAction is abstract, therefore, it can't be directly stored in the list --- engines/zvision/scr_file_handling.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'engines/zvision/scr_file_handling.cpp') diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp index 3171492717..eb867fa0a2 100644 --- a/engines/zvision/scr_file_handling.cpp +++ b/engines/zvision/scr_file_handling.cpp @@ -126,7 +126,7 @@ Criteria ScriptManager::parseCriteria(Common::SeekableReadStream &stream) const return criteria; } -void ScriptManager::parseResult(Common::SeekableReadStream &stream, Common::List &actionList) const { +void ScriptManager::parseResult(Common::SeekableReadStream &stream, Common::List &actionList) const { // Loop until we find the closing brace Common::String line = stream.readLine(); trimCommentsAndWhiteSpace(line); @@ -135,11 +135,11 @@ void ScriptManager::parseResult(Common::SeekableReadStream &stream, Common::List while (!line.contains('}')) { // Parse for the action type if (line.matchString("*:add*", true)) { - actionList.push_back(ActionAdd(line)); + actionList.push_back(new ActionAdd(line)); } else if (line.matchString("*:animplay*", true)) { - actionList.push_back(ActionPlayAnimation(line)); + actionList.push_back(new ActionPlayAnimation(line)); } else if (line.matchString("*:animpreload*", true)) { - actionList.push_back(ActionPreloadAnimation(line)); + actionList.push_back(new ActionPreloadAnimation(line)); } else if (line.matchString("*:animunload*", true)) { -- cgit v1.2.3 From 3f93f7d27fe58690a4b94c22247bb00a9af2c92e Mon Sep 17 00:00:00 2001 From: richiesams Date: Fri, 5 Jul 2013 20:14:50 -0500 Subject: ZVISION: Change trimCommentsAndWhiteSpace to use a pointer instead of a reference. --- engines/zvision/scr_file_handling.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'engines/zvision/scr_file_handling.cpp') diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp index eb867fa0a2..285e635c61 100644 --- a/engines/zvision/scr_file_handling.cpp +++ b/engines/zvision/scr_file_handling.cpp @@ -46,7 +46,7 @@ void ScriptManager::parseScrFile(Common::String fileName) { return; } - trimCommentsAndWhiteSpace(line); + trimCommentsAndWhiteSpace(&line); if (line.empty()) continue; @@ -69,7 +69,7 @@ void ScriptManager::parseScrFile(Common::String fileName) { void ScriptManager::parsePuzzle(Puzzle &puzzle, Common::SeekableReadStream &stream) { Common::String line = stream.readLine(); - trimCommentsAndWhiteSpace(line); + trimCommentsAndWhiteSpace(&line); while (!line.contains('}')) { if (line.matchString("criteria {", true)) @@ -86,7 +86,7 @@ Criteria ScriptManager::parseCriteria(Common::SeekableReadStream &stream) const // Loop until we find the closing brace Common::String line = stream.readLine(); - trimCommentsAndWhiteSpace(line); + trimCommentsAndWhiteSpace(&line); while (!line.contains('}')) { // Split the string into tokens using ' ' as a delimiter @@ -120,7 +120,7 @@ Criteria ScriptManager::parseCriteria(Common::SeekableReadStream &stream) const } line = stream.readLine(); - trimCommentsAndWhiteSpace(line); + trimCommentsAndWhiteSpace(&line); } return criteria; @@ -129,7 +129,7 @@ Criteria ScriptManager::parseCriteria(Common::SeekableReadStream &stream) const void ScriptManager::parseResult(Common::SeekableReadStream &stream, Common::List &actionList) const { // Loop until we find the closing brace Common::String line = stream.readLine(); - trimCommentsAndWhiteSpace(line); + trimCommentsAndWhiteSpace(&line); // TODO: Re-order the if-then statements in order of highest occurrence while (!line.contains('}')) { @@ -253,7 +253,7 @@ void ScriptManager::parseResult(Common::SeekableReadStream &stream, Common::List } line = stream.readLine(); - trimCommentsAndWhiteSpace(line); + trimCommentsAndWhiteSpace(&line); } return; @@ -264,7 +264,7 @@ byte ScriptManager::parseFlags(Common::SeekableReadStream &stream) const { // Loop until we find the closing brace Common::String line = stream.readLine(); - trimCommentsAndWhiteSpace(line); + trimCommentsAndWhiteSpace(&line); while (!line.contains('}')) { if (line.matchString("ONCE_PER_INST", true)) { -- cgit v1.2.3 From c882f796950c4ada93b5ea85c69b62f2613b0aea Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sun, 7 Jul 2013 16:29:47 +0300 Subject: ZVISION: Remove direct inclusion of stdio.h --- engines/zvision/scr_file_handling.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'engines/zvision/scr_file_handling.cpp') diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp index 285e635c61..a0ecf6bb4c 100644 --- a/engines/zvision/scr_file_handling.cpp +++ b/engines/zvision/scr_file_handling.cpp @@ -22,8 +22,6 @@ #include "common/scummsys.h" -#include - #include "zvision/script_manager.h" #include "zvision/utility.h" #include "zvision/puzzle.h" -- cgit v1.2.3 From 4e55d7ba9476cd47a3118ecdeb0d0618e6d32211 Mon Sep 17 00:00:00 2001 From: richiesams Date: Thu, 11 Jul 2013 00:08:00 -0500 Subject: ZVISION: Clean up includes --- engines/zvision/scr_file_handling.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/zvision/scr_file_handling.cpp') diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp index a0ecf6bb4c..6bf73733e5 100644 --- a/engines/zvision/scr_file_handling.cpp +++ b/engines/zvision/scr_file_handling.cpp @@ -111,10 +111,10 @@ Criteria ScriptManager::parseCriteria(Common::SeekableReadStream &stream) const token = tokenizer.nextToken(); if (token.contains('[')) { sscanf(token.c_str(), "[%u]", &(criteria.argument)); - criteria.isArgumentAnId = true; + criteria.argumentIsAKey = true; } else { sscanf(token.c_str(), "%u", &(criteria.argument)); - criteria.isArgumentAnId = false; + criteria.argumentIsAKey = false; } line = stream.readLine(); -- cgit v1.2.3 From 78daaeb583a371edddd67b5399cbc14201fe7ee1 Mon Sep 17 00:00:00 2001 From: richiesams Date: Thu, 11 Jul 2013 00:23:36 -0500 Subject: ZVISION: Create main containers in ScriptManager --- engines/zvision/scr_file_handling.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'engines/zvision/scr_file_handling.cpp') diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp index 6bf73733e5..2371c350f7 100644 --- a/engines/zvision/scr_file_handling.cpp +++ b/engines/zvision/scr_file_handling.cpp @@ -25,6 +25,7 @@ #include "zvision/script_manager.h" #include "zvision/utility.h" #include "zvision/puzzle.h" +#include "zvision/actions.h" #include "common/textconsole.h" #include "common/file.h" @@ -53,14 +54,15 @@ void ScriptManager::parseScrFile(Common::String fileName) { sscanf(line.c_str(),"puzzle:%u",&(puzzle.key)); parsePuzzle(puzzle, file); - _puzzles.push_back(puzzle); + _activePuzzles.push_back(puzzle); } else if (line.matchString("control:*", true)) { Control control; char controlType[20]; sscanf(line.c_str(),"control:%u %s",&(control.id), controlType); parseControl(control, file); - _controls.push_back(control); + /** Holds the currently active puzzles */ + _activeControls.push_back(control); } } } -- cgit v1.2.3 From f88127104b6b59a336761966e9652412083402b7 Mon Sep 17 00:00:00 2001 From: richiesams Date: Mon, 15 Jul 2013 10:32:56 -0500 Subject: ZVISION: Fix implicit conversion for scanf-type functions --- engines/zvision/scr_file_handling.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/zvision/scr_file_handling.cpp') diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp index 2371c350f7..6a2e8cf701 100644 --- a/engines/zvision/scr_file_handling.cpp +++ b/engines/zvision/scr_file_handling.cpp @@ -41,7 +41,7 @@ void ScriptManager::parseScrFile(Common::String fileName) { while(!file.eos()) { Common::String line = file.readLine(); if (file.err()) { - warning("Error parsing scr file: %s", fileName); + warning("Error parsing scr file: %s", fileName.c_str()); return; } @@ -249,7 +249,7 @@ void ScriptManager::parseResult(Common::SeekableReadStream &stream, Common::List } else { - warning("Unhandled result action type: ", line); + warning("Unhandled result action type: %s", line.c_str()); } line = stream.readLine(); -- cgit v1.2.3 From 7644e00bf3e55c1b6b2ea0d74db89d8539cb9f31 Mon Sep 17 00:00:00 2001 From: richiesams Date: Wed, 17 Jul 2013 19:24:39 -0500 Subject: ZVISION: Convert ResultActions to take a String pointer in their constructors There's no point in copying the String since it's just being parsed --- engines/zvision/scr_file_handling.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'engines/zvision/scr_file_handling.cpp') diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp index 6a2e8cf701..168a6d830a 100644 --- a/engines/zvision/scr_file_handling.cpp +++ b/engines/zvision/scr_file_handling.cpp @@ -135,11 +135,11 @@ void ScriptManager::parseResult(Common::SeekableReadStream &stream, Common::List while (!line.contains('}')) { // Parse for the action type if (line.matchString("*:add*", true)) { - actionList.push_back(new ActionAdd(line)); + actionList.push_back(new ActionAdd(&line)); } else if (line.matchString("*:animplay*", true)) { - actionList.push_back(new ActionPlayAnimation(line)); + actionList.push_back(new ActionPlayAnimation(&line)); } else if (line.matchString("*:animpreload*", true)) { - actionList.push_back(new ActionPreloadAnimation(line)); + actionList.push_back(new ActionPreloadAnimation(&line)); } else if (line.matchString("*:animunload*", true)) { -- cgit v1.2.3 From b20437a17d1a740e70dd1fa0bbf3bc6cfeb6c494 Mon Sep 17 00:00:00 2001 From: richiesams Date: Mon, 29 Jul 2013 21:49:06 -0500 Subject: ZVISION: Modify Criteria parsing to handle empty Criteria --- engines/zvision/scr_file_handling.cpp | 46 +++++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 18 deletions(-) (limited to 'engines/zvision/scr_file_handling.cpp') diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp index 168a6d830a..cebb57a786 100644 --- a/engines/zvision/scr_file_handling.cpp +++ b/engines/zvision/scr_file_handling.cpp @@ -72,22 +72,32 @@ void ScriptManager::parsePuzzle(Puzzle &puzzle, Common::SeekableReadStream &stre trimCommentsAndWhiteSpace(&line); while (!line.contains('}')) { - if (line.matchString("criteria {", true)) - puzzle.criteriaList.push_back(parseCriteria(stream)); - else if (line.matchString("results {", true)) - parseResult(stream, puzzle.resultActions); - else if (line.matchString("flags {", true)) + if (line.matchString("criteria {", true)) { + Criteria criteria; + if (parseCriteria(&criteria, stream)) { + puzzle.criteriaList.push_back(criteria); + } + } else if (line.matchString("results {", true)) { + parseResults(stream, puzzle.resultActions); + } else if (line.matchString("flags {", true)) { puzzle.flags = parseFlags(stream); + } + + line = stream.readLine(); + trimCommentsAndWhiteSpace(&line); } } -Criteria ScriptManager::parseCriteria(Common::SeekableReadStream &stream) const { - Criteria criteria; - +bool ScriptManager::parseCriteria(Criteria *criteria, Common::SeekableReadStream &stream) const { // Loop until we find the closing brace Common::String line = stream.readLine(); trimCommentsAndWhiteSpace(&line); + // Criteria can be empty + if (line.contains('}')) { + return false; + } + while (!line.contains('}')) { // Split the string into tokens using ' ' as a delimiter Common::StringTokenizer tokenizer(line); @@ -95,35 +105,35 @@ Criteria ScriptManager::parseCriteria(Common::SeekableReadStream &stream) const // Parse the id out of the first token token = tokenizer.nextToken(); - sscanf(token.c_str(), "[%u]", &(criteria.key)); + sscanf(token.c_str(), "[%u]", &(criteria->key)); // Parse the operator out of the second token token = tokenizer.nextToken(); if (token.c_str()[0] == '=') - criteria.criteriaOperator = EQUAL_TO; + criteria->criteriaOperator = EQUAL_TO; else if (token.c_str()[0] == '!') - criteria.criteriaOperator = NOT_EQUAL_TO; + criteria->criteriaOperator = NOT_EQUAL_TO; else if (token.c_str()[0] == '>') - criteria.criteriaOperator = GREATER_THAN; + criteria->criteriaOperator = GREATER_THAN; else if (token.c_str()[0] == '<') - criteria.criteriaOperator = LESS_THAN; + criteria->criteriaOperator = LESS_THAN; // First determine if the last token is an id or a value // Then parse it into 'argument' token = tokenizer.nextToken(); if (token.contains('[')) { - sscanf(token.c_str(), "[%u]", &(criteria.argument)); - criteria.argumentIsAKey = true; + sscanf(token.c_str(), "[%u]", &(criteria->argument)); + criteria->argumentIsAKey = true; } else { - sscanf(token.c_str(), "%u", &(criteria.argument)); - criteria.argumentIsAKey = false; + sscanf(token.c_str(), "%u", &(criteria->argument)); + criteria->argumentIsAKey = false; } line = stream.readLine(); trimCommentsAndWhiteSpace(&line); } - return criteria; + return true; } void ScriptManager::parseResult(Common::SeekableReadStream &stream, Common::List &actionList) const { -- cgit v1.2.3 From d4ae293f881ae07afd243173ddd11d5b0cfa12b3 Mon Sep 17 00:00:00 2001 From: richiesams Date: Mon, 29 Jul 2013 21:54:10 -0500 Subject: ZVISION: Rename parseResult() to parseResults() --- engines/zvision/scr_file_handling.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/zvision/scr_file_handling.cpp') diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp index cebb57a786..ca66e3bccd 100644 --- a/engines/zvision/scr_file_handling.cpp +++ b/engines/zvision/scr_file_handling.cpp @@ -136,7 +136,7 @@ bool ScriptManager::parseCriteria(Criteria *criteria, Common::SeekableReadStream return true; } -void ScriptManager::parseResult(Common::SeekableReadStream &stream, Common::List &actionList) const { +void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::List &actionList) const { // Loop until we find the closing brace Common::String line = stream.readLine(); trimCommentsAndWhiteSpace(&line); -- cgit v1.2.3 From 070042fcb4ea473cd2bfbebf9838957cdb9150b8 Mon Sep 17 00:00:00 2001 From: richiesams Date: Mon, 29 Jul 2013 21:56:50 -0500 Subject: ZVISION: Modify Control parsing to use new Control class structure --- engines/zvision/scr_file_handling.cpp | 39 ++++++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 8 deletions(-) (limited to 'engines/zvision/scr_file_handling.cpp') diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp index ca66e3bccd..ec73fa1fdf 100644 --- a/engines/zvision/scr_file_handling.cpp +++ b/engines/zvision/scr_file_handling.cpp @@ -56,13 +56,11 @@ void ScriptManager::parseScrFile(Common::String fileName) { parsePuzzle(puzzle, file); _activePuzzles.push_back(puzzle); } else if (line.matchString("control:*", true)) { - Control control; - char controlType[20]; - sscanf(line.c_str(),"control:%u %s",&(control.id), controlType); - - parseControl(control, file); - /** Holds the currently active puzzles */ - _activeControls.push_back(control); + Control *control = parseControl(line, file); + // Some controls don't require nodes. They just initialize the scene + if (control != 0) { + _activeControls.push_back(control); + } } } } @@ -284,13 +282,38 @@ byte ScriptManager::parseFlags(Common::SeekableReadStream &stream) const { } else if (line.matchString("DISABLED", true)) { flags |= DISABLED; } + + line = stream.readLine(); + trimCommentsAndWhiteSpace(&line); } return flags; } -void ScriptManager::parseControl(Control &control, Common::SeekableReadStream &stream) { +Control *ScriptManager::parseControl(Common::String &line, Common::SeekableReadStream &stream) { + Control *control = 0; + uint32 key; + char controlTypeBuffer[20]; + + sscanf(line.c_str(), "control:%u %s {", &key, controlTypeBuffer); + + Common::String controlType(controlTypeBuffer); + + if (controlType.equalsIgnoreCase("push_toggle")) { + + } else if (controlType.equalsIgnoreCase("flat")) { + Control::parseFlatControl(_engine); + return 0; + } else if (controlType.equalsIgnoreCase("pana")) { + Control::parsePanoramaControl(_engine, stream); + return 0; + } + else if (controlType.equalsIgnoreCase("tilt")) { + Control::parseTiltControl(_engine, stream); + return 0; + } + return control; } } // End of namespace ZVision -- cgit v1.2.3 From f39e1fdc43a97c0d06bfcda0e5c6dfdfb4e95ef7 Mon Sep 17 00:00:00 2001 From: richiesams Date: Mon, 29 Jul 2013 22:16:21 -0500 Subject: ZVISION: Move CriteriaOperator, Criteria, and StateFlag inside the Puzzle class --- engines/zvision/scr_file_handling.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'engines/zvision/scr_file_handling.cpp') diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp index ec73fa1fdf..5f2140d45a 100644 --- a/engines/zvision/scr_file_handling.cpp +++ b/engines/zvision/scr_file_handling.cpp @@ -71,7 +71,7 @@ void ScriptManager::parsePuzzle(Puzzle &puzzle, Common::SeekableReadStream &stre while (!line.contains('}')) { if (line.matchString("criteria {", true)) { - Criteria criteria; + Puzzle::Criteria criteria; if (parseCriteria(&criteria, stream)) { puzzle.criteriaList.push_back(criteria); } @@ -86,7 +86,7 @@ void ScriptManager::parsePuzzle(Puzzle &puzzle, Common::SeekableReadStream &stre } } -bool ScriptManager::parseCriteria(Criteria *criteria, Common::SeekableReadStream &stream) const { +bool ScriptManager::parseCriteria(Puzzle::Criteria *criteria, Common::SeekableReadStream &stream) const { // Loop until we find the closing brace Common::String line = stream.readLine(); trimCommentsAndWhiteSpace(&line); @@ -108,13 +108,13 @@ bool ScriptManager::parseCriteria(Criteria *criteria, Common::SeekableReadStream // Parse the operator out of the second token token = tokenizer.nextToken(); if (token.c_str()[0] == '=') - criteria->criteriaOperator = EQUAL_TO; + criteria->criteriaOperator = Puzzle::EQUAL_TO; else if (token.c_str()[0] == '!') - criteria->criteriaOperator = NOT_EQUAL_TO; + criteria->criteriaOperator = Puzzle::NOT_EQUAL_TO; else if (token.c_str()[0] == '>') - criteria->criteriaOperator = GREATER_THAN; + criteria->criteriaOperator = Puzzle::GREATER_THAN; else if (token.c_str()[0] == '<') - criteria->criteriaOperator = LESS_THAN; + criteria->criteriaOperator = Puzzle::LESS_THAN; // First determine if the last token is an id or a value // Then parse it into 'argument' @@ -276,11 +276,11 @@ byte ScriptManager::parseFlags(Common::SeekableReadStream &stream) const { while (!line.contains('}')) { if (line.matchString("ONCE_PER_INST", true)) { - flags |= ONCE_PER_INST; + flags |= Puzzle::ONCE_PER_INST; } else if (line.matchString("DO_ME_NOW", true)) { - flags |= DO_ME_NOW; + flags |= Puzzle::DO_ME_NOW; } else if (line.matchString("DISABLED", true)) { - flags |= DISABLED; + flags |= Puzzle::DISABLED; } line = stream.readLine(); -- cgit v1.2.3 From f1135292d0d714187b719988dba8d5a7d487fe94 Mon Sep 17 00:00:00 2001 From: richiesams Date: Tue, 30 Jul 2013 14:25:31 -0500 Subject: ZVISION: Optimize integer type usages The general thought is int is faster than int16 or byte. So if you can afford the space, use it over int16 or byte. Also, only use int32 when you specifically need the 32 bits. --- engines/zvision/scr_file_handling.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/zvision/scr_file_handling.cpp') diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp index 5f2140d45a..fe78a82d8f 100644 --- a/engines/zvision/scr_file_handling.cpp +++ b/engines/zvision/scr_file_handling.cpp @@ -267,8 +267,8 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis return; } -byte ScriptManager::parseFlags(Common::SeekableReadStream &stream) const { - byte flags; +uint ScriptManager::parseFlags(Common::SeekableReadStream &stream) const { + uint flags = 0; // Loop until we find the closing brace Common::String line = stream.readLine(); -- cgit v1.2.3 From 5e442c363ee870b63b13c6325c07be04bfb28fab Mon Sep 17 00:00:00 2001 From: richiesams Date: Tue, 30 Jul 2013 14:28:47 -0500 Subject: ZVISION: Convert String pointers to const references --- engines/zvision/scr_file_handling.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'engines/zvision/scr_file_handling.cpp') diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp index fe78a82d8f..0bd28ec4a9 100644 --- a/engines/zvision/scr_file_handling.cpp +++ b/engines/zvision/scr_file_handling.cpp @@ -143,11 +143,11 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis while (!line.contains('}')) { // Parse for the action type if (line.matchString("*:add*", true)) { - actionList.push_back(new ActionAdd(&line)); + actionList.push_back(new ActionAdd(line)); } else if (line.matchString("*:animplay*", true)) { - actionList.push_back(new ActionPlayAnimation(&line)); + actionList.push_back(new ActionPlayAnimation(line)); } else if (line.matchString("*:animpreload*", true)) { - actionList.push_back(new ActionPreloadAnimation(&line)); + actionList.push_back(new ActionPreloadAnimation(line)); } else if (line.matchString("*:animunload*", true)) { -- cgit v1.2.3 From 2faaf8488bb5bdace2c017b37f825bc38f41ef84 Mon Sep 17 00:00:00 2001 From: richiesams Date: Fri, 2 Aug 2013 15:30:02 -0500 Subject: ZVISION: Convert ResultAction pointers to SharePtr This gets rid of the need for specific destruction as well as making the copy swap operations in the ScriptManger _referenceTable more efficient --- engines/zvision/scr_file_handling.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'engines/zvision/scr_file_handling.cpp') diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp index 0bd28ec4a9..860e77147d 100644 --- a/engines/zvision/scr_file_handling.cpp +++ b/engines/zvision/scr_file_handling.cpp @@ -134,7 +134,7 @@ bool ScriptManager::parseCriteria(Puzzle::Criteria *criteria, Common::SeekableRe return true; } -void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::List &actionList) const { +void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::List > &actionList) const { // Loop until we find the closing brace Common::String line = stream.readLine(); trimCommentsAndWhiteSpace(&line); @@ -143,14 +143,13 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis while (!line.contains('}')) { // Parse for the action type if (line.matchString("*:add*", true)) { - actionList.push_back(new ActionAdd(line)); + actionList.push_back(Common::SharedPtr(new ActionAdd(line))); } else if (line.matchString("*:animplay*", true)) { - actionList.push_back(new ActionPlayAnimation(line)); + actionList.push_back(Common::SharedPtr(new ActionPlayAnimation(line))); } else if (line.matchString("*:animpreload*", true)) { - actionList.push_back(new ActionPreloadAnimation(line)); + actionList.push_back(Common::SharedPtr(new ActionPreloadAnimation(line))); } else if (line.matchString("*:animunload*", true)) { - - + actionList.push_back(Common::SharedPtr(new ActionUnloadAnimation(line))); } else if (line.matchString("*:attenuate*", true)) { -- cgit v1.2.3 From 9e996c4fec6477395d98ddc670df8732db3d7f28 Mon Sep 17 00:00:00 2001 From: richiesams Date: Sat, 3 Aug 2013 14:56:52 -0500 Subject: ZVISION: Convert _activeNodes and _activeControls to Lists of SharedPtr --- engines/zvision/scr_file_handling.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'engines/zvision/scr_file_handling.cpp') diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp index 860e77147d..8c8c6c488a 100644 --- a/engines/zvision/scr_file_handling.cpp +++ b/engines/zvision/scr_file_handling.cpp @@ -56,9 +56,10 @@ void ScriptManager::parseScrFile(Common::String fileName) { parsePuzzle(puzzle, file); _activePuzzles.push_back(puzzle); } else if (line.matchString("control:*", true)) { - Control *control = parseControl(line, file); + Common::SharedPtr control; + // Some controls don't require nodes. They just initialize the scene - if (control != 0) { + if (parseControl(line, file, control)) { _activeControls.push_back(control); } } @@ -289,8 +290,7 @@ uint ScriptManager::parseFlags(Common::SeekableReadStream &stream) const { return flags; } -Control *ScriptManager::parseControl(Common::String &line, Common::SeekableReadStream &stream) { - Control *control = 0; +bool ScriptManager::parseControl(Common::String &line, Common::SeekableReadStream &stream, Common::SharedPtr &control) { uint32 key; char controlTypeBuffer[20]; @@ -302,17 +302,17 @@ Control *ScriptManager::parseControl(Common::String &line, Common::SeekableReadS } else if (controlType.equalsIgnoreCase("flat")) { Control::parseFlatControl(_engine); - return 0; + return false; } else if (controlType.equalsIgnoreCase("pana")) { Control::parsePanoramaControl(_engine, stream); - return 0; + return false; } else if (controlType.equalsIgnoreCase("tilt")) { Control::parseTiltControl(_engine, stream); - return 0; + return false; } - return control; + return true; } } // End of namespace ZVision -- cgit v1.2.3 From 32b3363acddcc25fb2380fbb66df829832d5200d Mon Sep 17 00:00:00 2001 From: richiesams Date: Sat, 3 Aug 2013 15:00:58 -0500 Subject: ZVISION: Add ActionSetScreen --- engines/zvision/scr_file_handling.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'engines/zvision/scr_file_handling.cpp') diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp index 8c8c6c488a..1dc8ee5d4e 100644 --- a/engines/zvision/scr_file_handling.cpp +++ b/engines/zvision/scr_file_handling.cpp @@ -233,8 +233,7 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis } else if (line.matchString("*:set_screen*", true)) { - - + actionList.push_back(Common::SharedPtr(new ActionSetScreen(line))); } else if (line.matchString("*:set_venus*", true)) { -- cgit v1.2.3 From 20c892092907e66c6c13d1598b973486ba2fc95c Mon Sep 17 00:00:00 2001 From: richiesams Date: Mon, 5 Aug 2013 00:01:20 -0500 Subject: ZVISION: Pass the scr fileName as a const reference --- engines/zvision/scr_file_handling.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/zvision/scr_file_handling.cpp') diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp index 1dc8ee5d4e..cd3cfe4269 100644 --- a/engines/zvision/scr_file_handling.cpp +++ b/engines/zvision/scr_file_handling.cpp @@ -33,7 +33,7 @@ namespace ZVision { -void ScriptManager::parseScrFile(Common::String fileName) { +void ScriptManager::parseScrFile(const Common::String &fileName) { Common::File file; if (!file.open(fileName)) return; // File.open already throws a warning if the file doesn't exist, so there is no need to throw another -- cgit v1.2.3 From 6515e2d31bbbad55168b8b27142cdc50f366795d Mon Sep 17 00:00:00 2001 From: richiesams Date: Mon, 5 Aug 2013 00:14:20 -0500 Subject: ZVISION: Add ActionMusic --- engines/zvision/scr_file_handling.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'engines/zvision/scr_file_handling.cpp') diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp index cd3cfe4269..9759fd89b1 100644 --- a/engines/zvision/scr_file_handling.cpp +++ b/engines/zvision/scr_file_handling.cpp @@ -200,8 +200,7 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis } else if (line.matchString("*:music*", true)) { - - + actionList.push_back(Common::SharedPtr(new ActionMusic(line))); } else if (line.matchString("*:pan_track*", true)) { -- cgit v1.2.3 From 76d4fb569d2d158ca05b3fb09095efc35ed27a12 Mon Sep 17 00:00:00 2001 From: richiesams Date: Mon, 5 Aug 2013 11:55:52 -0500 Subject: ZVISION: Comment out usage of ActionUnloadAnimation until it is implemented --- engines/zvision/scr_file_handling.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/zvision/scr_file_handling.cpp') diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp index 9759fd89b1..06fb0fab89 100644 --- a/engines/zvision/scr_file_handling.cpp +++ b/engines/zvision/scr_file_handling.cpp @@ -150,7 +150,7 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis } else if (line.matchString("*:animpreload*", true)) { actionList.push_back(Common::SharedPtr(new ActionPreloadAnimation(line))); } else if (line.matchString("*:animunload*", true)) { - actionList.push_back(Common::SharedPtr(new ActionUnloadAnimation(line))); + //actionList.push_back(Common::SharedPtr(new ActionUnloadAnimation(line))); } else if (line.matchString("*:attenuate*", true)) { -- cgit v1.2.3 From 694a6099a6f4da7807b1ac1efba75953522da206 Mon Sep 17 00:00:00 2001 From: richiesams Date: Sat, 10 Aug 2013 17:12:23 -0500 Subject: ZVISION: Implement ActionQuit --- engines/zvision/scr_file_handling.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'engines/zvision/scr_file_handling.cpp') diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp index 06fb0fab89..0bb8d2690b 100644 --- a/engines/zvision/scr_file_handling.cpp +++ b/engines/zvision/scr_file_handling.cpp @@ -211,8 +211,7 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis } else if (line.matchString("*:quit*", true)) { - - + actionList.push_back(Common::SharedPtr(new ActionQuit())); } else if (line.matchString("*:random*", true)) { -- cgit v1.2.3 From 2176aa55fc71fb7ac8b44f81fcc070c927e3d505 Mon Sep 17 00:00:00 2001 From: richiesams Date: Sat, 10 Aug 2013 17:18:29 -0500 Subject: ZVISION: Implement ActionStreamVideo --- engines/zvision/scr_file_handling.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'engines/zvision/scr_file_handling.cpp') diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp index 0bb8d2690b..061079cd85 100644 --- a/engines/zvision/scr_file_handling.cpp +++ b/engines/zvision/scr_file_handling.cpp @@ -239,8 +239,7 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis } else if (line.matchString("*:streamvideo*", true)) { - - + actionList.push_back(Common::SharedPtr(new ActionStreamVideo(line))); } else if (line.matchString("*:syncsound*", true)) { -- cgit v1.2.3 From 5bba509db8a84a5d6c2ab4863990683977203e60 Mon Sep 17 00:00:00 2001 From: richiesams Date: Sat, 10 Aug 2013 17:23:47 -0500 Subject: ZVISION: Create a global puzzle list and parse universe.scr into it during ScriptManager::initialize() --- engines/zvision/scr_file_handling.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'engines/zvision/scr_file_handling.cpp') diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp index 061079cd85..efd122994d 100644 --- a/engines/zvision/scr_file_handling.cpp +++ b/engines/zvision/scr_file_handling.cpp @@ -33,7 +33,7 @@ namespace ZVision { -void ScriptManager::parseScrFile(const Common::String &fileName) { +void ScriptManager::parseScrFile(const Common::String &fileName, bool isGlobal) { Common::File file; if (!file.open(fileName)) return; // File.open already throws a warning if the file doesn't exist, so there is no need to throw another @@ -54,7 +54,11 @@ void ScriptManager::parseScrFile(const Common::String &fileName) { sscanf(line.c_str(),"puzzle:%u",&(puzzle.key)); parsePuzzle(puzzle, file); - _activePuzzles.push_back(puzzle); + if (isGlobal) { + _globalPuzzles.push_back(puzzle); + } else { + _activePuzzles.push_back(puzzle); + } } else if (line.matchString("control:*", true)) { Common::SharedPtr control; -- cgit v1.2.3 From 327d4a1ccff41af28b010679a29168b7e839de29 Mon Sep 17 00:00:00 2001 From: richiesams Date: Sat, 10 Aug 2013 17:32:57 -0500 Subject: ZVISION: Implement ActionChangeLocation::execute() --- engines/zvision/scr_file_handling.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'engines/zvision/scr_file_handling.cpp') diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp index efd122994d..a47bf0fc0c 100644 --- a/engines/zvision/scr_file_handling.cpp +++ b/engines/zvision/scr_file_handling.cpp @@ -162,8 +162,7 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis } else if (line.matchString("*:change_location*", true)) { - - + actionList.push_back(Common::SharedPtr(new ActionChangeLocation(line))); } else if (line.matchString("*:crossfade*", true)) { -- cgit v1.2.3 From 17a806a01b6def7ef59cc2501cf53dacc902b4e2 Mon Sep 17 00:00:00 2001 From: richiesams Date: Sat, 10 Aug 2013 17:38:33 -0500 Subject: ZVISION: Add parsing skip for action::copy_file. It is not used. I don't really know what it is used for, but Marisa Chan completely ignores it. --- engines/zvision/scr_file_handling.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'engines/zvision/scr_file_handling.cpp') diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp index a47bf0fc0c..f116774546 100644 --- a/engines/zvision/scr_file_handling.cpp +++ b/engines/zvision/scr_file_handling.cpp @@ -255,6 +255,8 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis } else if (line.matchString("*:universe_music*", true)) { + } else if (line.matchString("*:copy_file*", true)) { + // Not used. Purposely left empty } else { warning("Unhandled result action type: %s", line.c_str()); } -- cgit v1.2.3 From 668b0e6c892c67253fe5d763ab752bf7dfbd1c3f Mon Sep 17 00:00:00 2001 From: richiesams Date: Sun, 11 Aug 2013 15:03:30 -0500 Subject: ZVISION: Throw a warning when a .scr file isn't opened --- engines/zvision/scr_file_handling.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'engines/zvision/scr_file_handling.cpp') diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp index f116774546..6a71fe474a 100644 --- a/engines/zvision/scr_file_handling.cpp +++ b/engines/zvision/scr_file_handling.cpp @@ -35,8 +35,10 @@ namespace ZVision { void ScriptManager::parseScrFile(const Common::String &fileName, bool isGlobal) { Common::File file; - if (!file.open(fileName)) - return; // File.open already throws a warning if the file doesn't exist, so there is no need to throw another + if (!file.open(fileName)) { + warning("Script file not found: %s", fileName.c_str()); + return; + } while(!file.eos()) { Common::String line = file.readLine(); -- cgit v1.2.3 From 19e829ae95bc69f470d285bdf90d4b45b42248a4 Mon Sep 17 00:00:00 2001 From: richiesams Date: Sun, 11 Aug 2013 15:04:03 -0500 Subject: ZVISION: Ignore .scr file lines that are empty --- engines/zvision/scr_file_handling.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'engines/zvision/scr_file_handling.cpp') diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp index 6a71fe474a..cd4baa34f0 100644 --- a/engines/zvision/scr_file_handling.cpp +++ b/engines/zvision/scr_file_handling.cpp @@ -148,6 +148,13 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis // TODO: Re-order the if-then statements in order of highest occurrence while (!line.contains('}')) { + if (line.empty()) { + line = stream.readLine(); + trimCommentsAndWhiteSpace(&line); + + continue; + } + // Parse for the action type if (line.matchString("*:add*", true)) { actionList.push_back(Common::SharedPtr(new ActionAdd(line))); -- cgit v1.2.3 From 00a17a66d0e8317001829fe36639ef9201d15798 Mon Sep 17 00:00:00 2001 From: richiesams Date: Sun, 11 Aug 2013 15:12:01 -0500 Subject: ZVISION: Implement push_toggle control handling --- engines/zvision/scr_file_handling.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'engines/zvision/scr_file_handling.cpp') diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp index cd4baa34f0..5b8af48047 100644 --- a/engines/zvision/scr_file_handling.cpp +++ b/engines/zvision/scr_file_handling.cpp @@ -309,7 +309,8 @@ bool ScriptManager::parseControl(Common::String &line, Common::SeekableReadStrea Common::String controlType(controlTypeBuffer); if (controlType.equalsIgnoreCase("push_toggle")) { - + Control::parsePushToggleControl(key, _engine, stream); + return false; } else if (controlType.equalsIgnoreCase("flat")) { Control::parseFlatControl(_engine); return false; -- cgit v1.2.3 From bdd9b18292105b2cd8d894d2e042accecd001913 Mon Sep 17 00:00:00 2001 From: richiesams Date: Fri, 16 Aug 2013 10:43:12 -0500 Subject: ZVISION: Disable videos until I can figure out how to fix the decoder --- engines/zvision/scr_file_handling.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/zvision/scr_file_handling.cpp') diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp index 5b8af48047..ff7df20ac5 100644 --- a/engines/zvision/scr_file_handling.cpp +++ b/engines/zvision/scr_file_handling.cpp @@ -251,7 +251,7 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis } else if (line.matchString("*:streamvideo*", true)) { - actionList.push_back(Common::SharedPtr(new ActionStreamVideo(line))); + //actionList.push_back(Common::SharedPtr(new ActionStreamVideo(line))); } else if (line.matchString("*:syncsound*", true)) { -- cgit v1.2.3 From 8fafde8a33a84fd5819e2a3a9ff9ebf6a66889a5 Mon Sep 17 00:00:00 2001 From: richiesams Date: Sat, 17 Aug 2013 09:51:24 -0500 Subject: ZVISION: Re-enable video handling now that AVI code is fixed --- engines/zvision/scr_file_handling.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/zvision/scr_file_handling.cpp') diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp index ff7df20ac5..5b8af48047 100644 --- a/engines/zvision/scr_file_handling.cpp +++ b/engines/zvision/scr_file_handling.cpp @@ -251,7 +251,7 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis } else if (line.matchString("*:streamvideo*", true)) { - //actionList.push_back(Common::SharedPtr(new ActionStreamVideo(line))); + actionList.push_back(Common::SharedPtr(new ActionStreamVideo(line))); } else if (line.matchString("*:syncsound*", true)) { -- cgit v1.2.3 From 77219705e6f225c4296b5d5346b2abd8fe2aaade Mon Sep 17 00:00:00 2001 From: richiesams Date: Sat, 17 Aug 2013 20:35:57 -0500 Subject: ZVISION: Prevent endless looping due to incorrect file structure Some of the .scr files don't properly close the last curly brace --- engines/zvision/scr_file_handling.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'engines/zvision/scr_file_handling.cpp') diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp index 5b8af48047..9c99ce184d 100644 --- a/engines/zvision/scr_file_handling.cpp +++ b/engines/zvision/scr_file_handling.cpp @@ -76,7 +76,7 @@ void ScriptManager::parsePuzzle(Puzzle &puzzle, Common::SeekableReadStream &stre Common::String line = stream.readLine(); trimCommentsAndWhiteSpace(&line); - while (!line.contains('}')) { + while (!stream.eos() && !line.contains('}')) { if (line.matchString("criteria {", true)) { Puzzle::Criteria criteria; if (parseCriteria(&criteria, stream)) { @@ -103,7 +103,7 @@ bool ScriptManager::parseCriteria(Puzzle::Criteria *criteria, Common::SeekableRe return false; } - while (!line.contains('}')) { + while (!stream.eos() && !line.contains('}')) { // Split the string into tokens using ' ' as a delimiter Common::StringTokenizer tokenizer(line); Common::String token; @@ -147,7 +147,7 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis trimCommentsAndWhiteSpace(&line); // TODO: Re-order the if-then statements in order of highest occurrence - while (!line.contains('}')) { + while (!stream.eos() && !line.contains('}')) { if (line.empty()) { line = stream.readLine(); trimCommentsAndWhiteSpace(&line); @@ -284,7 +284,7 @@ uint ScriptManager::parseFlags(Common::SeekableReadStream &stream) const { Common::String line = stream.readLine(); trimCommentsAndWhiteSpace(&line); - while (!line.contains('}')) { + while (!stream.eos() && !line.contains('}')) { if (line.matchString("ONCE_PER_INST", true)) { flags |= Puzzle::ONCE_PER_INST; } else if (line.matchString("DO_ME_NOW", true)) { -- cgit v1.2.3 From 3a23873c45f8b274836eacd8d1de471da6defb5b Mon Sep 17 00:00:00 2001 From: richiesams Date: Sun, 18 Aug 2013 15:25:34 -0500 Subject: ZVISION: Convert _activeControls from a List to a HashMap --- engines/zvision/scr_file_handling.cpp | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) (limited to 'engines/zvision/scr_file_handling.cpp') diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp index 9c99ce184d..10e5c8f0eb 100644 --- a/engines/zvision/scr_file_handling.cpp +++ b/engines/zvision/scr_file_handling.cpp @@ -62,12 +62,7 @@ void ScriptManager::parseScrFile(const Common::String &fileName, bool isGlobal) _activePuzzles.push_back(puzzle); } } else if (line.matchString("control:*", true)) { - Common::SharedPtr control; - - // Some controls don't require nodes. They just initialize the scene - if (parseControl(line, file, control)) { - _activeControls.push_back(control); - } + parseControl(line, file); } } } @@ -300,7 +295,7 @@ uint ScriptManager::parseFlags(Common::SeekableReadStream &stream) const { return flags; } -bool ScriptManager::parseControl(Common::String &line, Common::SeekableReadStream &stream, Common::SharedPtr &control) { +void ScriptManager::parseControl(Common::String &line, Common::SeekableReadStream &stream) { uint32 key; char controlTypeBuffer[20]; @@ -309,21 +304,19 @@ bool ScriptManager::parseControl(Common::String &line, Common::SeekableReadStrea Common::String controlType(controlTypeBuffer); if (controlType.equalsIgnoreCase("push_toggle")) { - Control::parsePushToggleControl(key, _engine, stream); - return false; + _activeControls[key] = new PushToggleControl(key, stream); + return; } else if (controlType.equalsIgnoreCase("flat")) { Control::parseFlatControl(_engine); - return false; + return; } else if (controlType.equalsIgnoreCase("pana")) { Control::parsePanoramaControl(_engine, stream); - return false; + return; } else if (controlType.equalsIgnoreCase("tilt")) { Control::parseTiltControl(_engine, stream); - return false; + return; } - - return true; } } // End of namespace ZVision -- cgit v1.2.3 From 5a86355e7dae3b00924ce95275f1fea9346a6211 Mon Sep 17 00:00:00 2001 From: richiesams Date: Sun, 18 Aug 2013 15:29:23 -0500 Subject: ZVISION: Implement ActionEnableControl and ActionDisableControl --- engines/zvision/scr_file_handling.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'engines/zvision/scr_file_handling.cpp') diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp index 10e5c8f0eb..3fee767135 100644 --- a/engines/zvision/scr_file_handling.cpp +++ b/engines/zvision/scr_file_handling.cpp @@ -177,8 +177,7 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis } else if (line.matchString("*:disable_control*", true)) { - - + actionList.push_back(Common::SharedPtr(new ActionDisableControl(line))); } else if (line.matchString("*:disable_venus*", true)) { @@ -192,8 +191,7 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis } else if (line.matchString("*:enable_control*", true)) { - - + actionList.push_back(Common::SharedPtr(new ActionEnableControl(line))); } else if (line.matchString("*:flush_mouse_events*", true)) { -- cgit v1.2.3 From 46ab3557660221b2896c0d5cd4a7d3fb0464d1d1 Mon Sep 17 00:00:00 2001 From: richiesams Date: Sun, 18 Aug 2013 15:38:56 -0500 Subject: ZVISION: Allow Puzzles to have mutiple 'sets' of CriteriaEntries --- engines/zvision/scr_file_handling.cpp | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) (limited to 'engines/zvision/scr_file_handling.cpp') diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp index 3fee767135..dd2754c12f 100644 --- a/engines/zvision/scr_file_handling.cpp +++ b/engines/zvision/scr_file_handling.cpp @@ -73,10 +73,7 @@ void ScriptManager::parsePuzzle(Puzzle &puzzle, Common::SeekableReadStream &stre while (!stream.eos() && !line.contains('}')) { if (line.matchString("criteria {", true)) { - Puzzle::Criteria criteria; - if (parseCriteria(&criteria, stream)) { - puzzle.criteriaList.push_back(criteria); - } + parseCriteria(stream, puzzle.criteriaList); } else if (line.matchString("results {", true)) { parseResults(stream, puzzle.resultActions); } else if (line.matchString("flags {", true)) { @@ -88,7 +85,7 @@ void ScriptManager::parsePuzzle(Puzzle &puzzle, Common::SeekableReadStream &stre } } -bool ScriptManager::parseCriteria(Puzzle::Criteria *criteria, Common::SeekableReadStream &stream) const { +bool ScriptManager::parseCriteria(Common::SeekableReadStream &stream, Common::List > &criteriaList) const { // Loop until we find the closing brace Common::String line = stream.readLine(); trimCommentsAndWhiteSpace(&line); @@ -98,37 +95,44 @@ bool ScriptManager::parseCriteria(Puzzle::Criteria *criteria, Common::SeekableRe return false; } + // Create a new List to hold the CriteriaEntries + criteriaList.push_back(Common::List()); + while (!stream.eos() && !line.contains('}')) { + Puzzle::CriteriaEntry entry; + // Split the string into tokens using ' ' as a delimiter Common::StringTokenizer tokenizer(line); Common::String token; // Parse the id out of the first token token = tokenizer.nextToken(); - sscanf(token.c_str(), "[%u]", &(criteria->key)); + sscanf(token.c_str(), "[%u]", &(entry.key)); // Parse the operator out of the second token token = tokenizer.nextToken(); if (token.c_str()[0] == '=') - criteria->criteriaOperator = Puzzle::EQUAL_TO; + entry.criteriaOperator = Puzzle::EQUAL_TO; else if (token.c_str()[0] == '!') - criteria->criteriaOperator = Puzzle::NOT_EQUAL_TO; + entry.criteriaOperator = Puzzle::NOT_EQUAL_TO; else if (token.c_str()[0] == '>') - criteria->criteriaOperator = Puzzle::GREATER_THAN; + entry.criteriaOperator = Puzzle::GREATER_THAN; else if (token.c_str()[0] == '<') - criteria->criteriaOperator = Puzzle::LESS_THAN; + entry.criteriaOperator = Puzzle::LESS_THAN; // First determine if the last token is an id or a value // Then parse it into 'argument' token = tokenizer.nextToken(); if (token.contains('[')) { - sscanf(token.c_str(), "[%u]", &(criteria->argument)); - criteria->argumentIsAKey = true; + sscanf(token.c_str(), "[%u]", &(entry.argument)); + entry.argumentIsAKey = true; } else { - sscanf(token.c_str(), "%u", &(criteria->argument)); - criteria->argumentIsAKey = false; + sscanf(token.c_str(), "%u", &(entry.argument)); + entry.argumentIsAKey = false; } + criteriaList.back().push_back(entry); + line = stream.readLine(); trimCommentsAndWhiteSpace(&line); } -- cgit v1.2.3 From b0635edff8c0d5b05cef8a22c74c569921a8346b Mon Sep 17 00:00:00 2001 From: richiesams Date: Sun, 18 Aug 2013 19:51:27 -0500 Subject: ZVISION: Revert to normal pointers instead of shared pointers --- engines/zvision/scr_file_handling.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'engines/zvision/scr_file_handling.cpp') diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp index dd2754c12f..eb15d04070 100644 --- a/engines/zvision/scr_file_handling.cpp +++ b/engines/zvision/scr_file_handling.cpp @@ -140,7 +140,7 @@ bool ScriptManager::parseCriteria(Common::SeekableReadStream &stream, Common::Li return true; } -void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::List > &actionList) const { +void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::List &actionList) const { // Loop until we find the closing brace Common::String line = stream.readLine(); trimCommentsAndWhiteSpace(&line); @@ -156,13 +156,13 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis // Parse for the action type if (line.matchString("*:add*", true)) { - actionList.push_back(Common::SharedPtr(new ActionAdd(line))); + actionList.push_back(new ActionAdd(line)); } else if (line.matchString("*:animplay*", true)) { - actionList.push_back(Common::SharedPtr(new ActionPlayAnimation(line))); + actionList.push_back(new ActionPlayAnimation(line)); } else if (line.matchString("*:animpreload*", true)) { - actionList.push_back(Common::SharedPtr(new ActionPreloadAnimation(line))); + actionList.push_back(new ActionPreloadAnimation(line)); } else if (line.matchString("*:animunload*", true)) { - //actionList.push_back(Common::SharedPtr(new ActionUnloadAnimation(line))); + //actionList.push_back(new ActionUnloadAnimation(line)); } else if (line.matchString("*:attenuate*", true)) { @@ -170,7 +170,7 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis } else if (line.matchString("*:change_location*", true)) { - actionList.push_back(Common::SharedPtr(new ActionChangeLocation(line))); + actionList.push_back(new ActionChangeLocation(line)); } else if (line.matchString("*:crossfade*", true)) { @@ -181,7 +181,7 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis } else if (line.matchString("*:disable_control*", true)) { - actionList.push_back(Common::SharedPtr(new ActionDisableControl(line))); + actionList.push_back(new ActionDisableControl(line)); } else if (line.matchString("*:disable_venus*", true)) { @@ -195,7 +195,7 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis } else if (line.matchString("*:enable_control*", true)) { - actionList.push_back(Common::SharedPtr(new ActionEnableControl(line))); + actionList.push_back(new ActionEnableControl(line)); } else if (line.matchString("*:flush_mouse_events*", true)) { @@ -209,7 +209,7 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis } else if (line.matchString("*:music*", true)) { - actionList.push_back(Common::SharedPtr(new ActionMusic(line))); + actionList.push_back(new ActionMusic(line)); } else if (line.matchString("*:pan_track*", true)) { @@ -220,7 +220,7 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis } else if (line.matchString("*:quit*", true)) { - actionList.push_back(Common::SharedPtr(new ActionQuit())); + actionList.push_back(new ActionQuit()); } else if (line.matchString("*:random*", true)) { @@ -240,7 +240,7 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis } else if (line.matchString("*:set_screen*", true)) { - actionList.push_back(Common::SharedPtr(new ActionSetScreen(line))); + actionList.push_back(new ActionSetScreen(line)); } else if (line.matchString("*:set_venus*", true)) { @@ -248,7 +248,7 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis } else if (line.matchString("*:streamvideo*", true)) { - actionList.push_back(Common::SharedPtr(new ActionStreamVideo(line))); + actionList.push_back(new ActionStreamVideo(line)); } else if (line.matchString("*:syncsound*", true)) { -- cgit v1.2.3 From aba3ba634cbadd6f245580171322fa5debc6ffd3 Mon Sep 17 00:00:00 2001 From: richiesams Date: Tue, 20 Aug 2013 20:29:28 -0500 Subject: ZVISION: Add TODO's of what is left for the engine to be complete --- engines/zvision/scr_file_handling.cpp | 84 ++++++++++++----------------------- 1 file changed, 28 insertions(+), 56 deletions(-) (limited to 'engines/zvision/scr_file_handling.cpp') diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp index eb15d04070..f4d4563c63 100644 --- a/engines/zvision/scr_file_handling.cpp +++ b/engines/zvision/scr_file_handling.cpp @@ -164,103 +164,75 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis } else if (line.matchString("*:animunload*", true)) { //actionList.push_back(new ActionUnloadAnimation(line)); } else if (line.matchString("*:attenuate*", true)) { - - + // TODO: Implement ActionAttenuate } else if (line.matchString("*:assign*", true)) { - - + // TODO: Implement ActionAssign } else if (line.matchString("*:change_location*", true)) { actionList.push_back(new ActionChangeLocation(line)); } else if (line.matchString("*:crossfade*", true)) { - - + // TODO: Implement ActionCrossfade } else if (line.matchString("*:debug*", true)) { - - + // TODO: Implement ActionDebug } else if (line.matchString("*:delay_render*", true)) { - - + // TODO: Implement ActionDelayRender } else if (line.matchString("*:disable_control*", true)) { actionList.push_back(new ActionDisableControl(line)); } else if (line.matchString("*:disable_venus*", true)) { - - + // TODO: Implement ActionDisableVenus } else if (line.matchString("*:display_message*", true)) { - - + // TODO: Implement ActionDisplayMessage } else if (line.matchString("*:dissolve*", true)) { - - + // TODO: Implement ActionDissolve } else if (line.matchString("*:distort*", true)) { - - + // TODO: Implement ActionDistort } else if (line.matchString("*:enable_control*", true)) { actionList.push_back(new ActionEnableControl(line)); } else if (line.matchString("*:flush_mouse_events*", true)) { - - + // TODO: Implement ActionFlushMouseEvents } else if (line.matchString("*:inventory*", true)) { - - + // TODO: Implement ActionInventory } else if (line.matchString("*:kill*", true)) { - - + // TODO: Implement ActionKill } else if (line.matchString("*:menu_bar_enable*", true)) { - - + // TODO: Implement ActionMenuBarEnable } else if (line.matchString("*:music*", true)) { actionList.push_back(new ActionMusic(line)); } else if (line.matchString("*:pan_track*", true)) { - - + // TODO: Implement ActionPanTrack } else if (line.matchString("*:playpreload*", true)) { - - + // TODO: Implement ActionPlayPreload } else if (line.matchString("*:preferences*", true)) { - - + // TODO: Implement ActionPreferences } else if (line.matchString("*:quit*", true)) { actionList.push_back(new ActionQuit()); } else if (line.matchString("*:random*", true)) { - - + // TODO: Implement ActionRandom } else if (line.matchString("*:region*", true)) { - - + // TODO: Implement ActionRegion } else if (line.matchString("*:restore_game*", true)) { - - + // TODO: Implement ActionRestoreGame } else if (line.matchString("*:rotate_to*", true)) { - - + // TODO: Implement ActionRotateTo } else if (line.matchString("*:save_game*", true)) { - - + // TODO: Implement ActionSaveGame } else if (line.matchString("*:set_partial_screen*", true)) { - - + actionList.push_back(new ActionSetPartialScreen(line)); } else if (line.matchString("*:set_screen*", true)) { actionList.push_back(new ActionSetScreen(line)); } else if (line.matchString("*:set_venus*", true)) { - - + // TODO: Implement ActionSetVenus } else if (line.matchString("*:stop*", true)) { - - + // TODO: Implement ActionStop } else if (line.matchString("*:streamvideo*", true)) { actionList.push_back(new ActionStreamVideo(line)); } else if (line.matchString("*:syncsound*", true)) { - - + // TODO: Implement ActionSyncSound } else if (line.matchString("*:timer*", true)) { - - + // TODO: Implement ActionTimer } else if (line.matchString("*:ttytext*", true)) { - - + // TODO: Implement ActionTTYText } else if (line.matchString("*:universe_music*", true)) { - - + // TODO: Implement ActionUniverseMusic } else if (line.matchString("*:copy_file*", true)) { // Not used. Purposely left empty } else { -- cgit v1.2.3 From 35622827f8e8b507e6c2450773857975f2864a56 Mon Sep 17 00:00:00 2001 From: richiesams Date: Tue, 20 Aug 2013 20:50:14 -0500 Subject: ZVISION: Store the Puzzles in _activePuzzles and _globalPuzzles on the heap This allows List::push_back() to not cause a data copy --- engines/zvision/scr_file_handling.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'engines/zvision/scr_file_handling.cpp') diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp index f4d4563c63..7ccd939e54 100644 --- a/engines/zvision/scr_file_handling.cpp +++ b/engines/zvision/scr_file_handling.cpp @@ -52,8 +52,8 @@ void ScriptManager::parseScrFile(const Common::String &fileName, bool isGlobal) continue; if (line.matchString("puzzle:*", true)) { - Puzzle puzzle; - sscanf(line.c_str(),"puzzle:%u",&(puzzle.key)); + Puzzle *puzzle = new Puzzle(); + sscanf(line.c_str(),"puzzle:%u",&(puzzle->key)); parsePuzzle(puzzle, file); if (isGlobal) { @@ -67,17 +67,17 @@ void ScriptManager::parseScrFile(const Common::String &fileName, bool isGlobal) } } -void ScriptManager::parsePuzzle(Puzzle &puzzle, Common::SeekableReadStream &stream) { +void ScriptManager::parsePuzzle(Puzzle *puzzle, Common::SeekableReadStream &stream) { Common::String line = stream.readLine(); trimCommentsAndWhiteSpace(&line); while (!stream.eos() && !line.contains('}')) { if (line.matchString("criteria {", true)) { - parseCriteria(stream, puzzle.criteriaList); + parseCriteria(stream, puzzle->criteriaList); } else if (line.matchString("results {", true)) { - parseResults(stream, puzzle.resultActions); + parseResults(stream, puzzle->resultActions); } else if (line.matchString("flags {", true)) { - puzzle.flags = parseFlags(stream); + puzzle->flags = parseFlags(stream); } line = stream.readLine(); -- cgit v1.2.3 From 3054489a8bcc9604028ac16a0b074e13bff258eb Mon Sep 17 00:00:00 2001 From: richiesams Date: Sat, 24 Aug 2013 00:06:20 -0500 Subject: ZVISION: Have PushToggleControl inherit from MouseEvent and handle the methods internally. Rather than creating an instance of MouseEvent and passing argument around. --- engines/zvision/scr_file_handling.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/zvision/scr_file_handling.cpp') diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp index 7ccd939e54..921c1d5b44 100644 --- a/engines/zvision/scr_file_handling.cpp +++ b/engines/zvision/scr_file_handling.cpp @@ -278,7 +278,7 @@ void ScriptManager::parseControl(Common::String &line, Common::SeekableReadStrea Common::String controlType(controlTypeBuffer); if (controlType.equalsIgnoreCase("push_toggle")) { - _activeControls[key] = new PushToggleControl(key, stream); + _activeControls[key] = new PushToggleControl(_engine, key, stream); return; } else if (controlType.equalsIgnoreCase("flat")) { Control::parseFlatControl(_engine); -- cgit v1.2.3 From ff97bb2eadcd26abb9a085f266e33b76594d2a21 Mon Sep 17 00:00:00 2001 From: richiesams Date: Sat, 24 Aug 2013 01:47:12 -0500 Subject: ZVISION: Move PushToggleControl and LeverControl to their own files --- engines/zvision/scr_file_handling.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'engines/zvision/scr_file_handling.cpp') diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp index 921c1d5b44..c4aed70ac5 100644 --- a/engines/zvision/scr_file_handling.cpp +++ b/engines/zvision/scr_file_handling.cpp @@ -26,6 +26,7 @@ #include "zvision/utility.h" #include "zvision/puzzle.h" #include "zvision/actions.h" +#include "zvision/push_toggle_control.h" #include "common/textconsole.h" #include "common/file.h" -- cgit v1.2.3 From 7fb024c7fccb58442440f06af1bbd32b95122d72 Mon Sep 17 00:00:00 2001 From: richiesams Date: Mon, 26 Aug 2013 14:07:47 -0500 Subject: ZVISION: Change PushToggleControl to comply with new Control base class --- engines/zvision/scr_file_handling.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/zvision/scr_file_handling.cpp') diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp index c4aed70ac5..212d7140b0 100644 --- a/engines/zvision/scr_file_handling.cpp +++ b/engines/zvision/scr_file_handling.cpp @@ -279,7 +279,7 @@ void ScriptManager::parseControl(Common::String &line, Common::SeekableReadStrea Common::String controlType(controlTypeBuffer); if (controlType.equalsIgnoreCase("push_toggle")) { - _activeControls[key] = new PushToggleControl(_engine, key, stream); + _activeControls.push_back(new PushToggleControl(_engine, key, stream)); return; } else if (controlType.equalsIgnoreCase("flat")) { Control::parseFlatControl(_engine); -- cgit v1.2.3 From f1f36e7c9db0b78a5ae04ebdadebe431e2840bfc Mon Sep 17 00:00:00 2001 From: richiesams Date: Wed, 28 Aug 2013 09:18:18 -0500 Subject: ZVISION: Add LeverControl to scr file parsing --- engines/zvision/scr_file_handling.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'engines/zvision/scr_file_handling.cpp') diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp index 212d7140b0..06767c5340 100644 --- a/engines/zvision/scr_file_handling.cpp +++ b/engines/zvision/scr_file_handling.cpp @@ -27,6 +27,7 @@ #include "zvision/puzzle.h" #include "zvision/actions.h" #include "zvision/push_toggle_control.h" +#include "zvision/lever_control.h" #include "common/textconsole.h" #include "common/file.h" @@ -287,10 +288,12 @@ void ScriptManager::parseControl(Common::String &line, Common::SeekableReadStrea } else if (controlType.equalsIgnoreCase("pana")) { Control::parsePanoramaControl(_engine, stream); return; - } - else if (controlType.equalsIgnoreCase("tilt")) { + } else if (controlType.equalsIgnoreCase("tilt")) { Control::parseTiltControl(_engine, stream); return; + } else if (controlType.equalsIgnoreCase("lever")) { + _activeControls.push_back(new LeverControl(_engine, key, stream)); + return; } } -- cgit v1.2.3 From acfa7ff3e11bf9024451a6e3505f5f07d5646e1f Mon Sep 17 00:00:00 2001 From: RichieSams Date: Sat, 7 Sep 2013 18:05:15 -0500 Subject: ZVISION: Add scr parse line for ActionAssign It was already implemented, just not added to the scr parsing --- engines/zvision/scr_file_handling.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/zvision/scr_file_handling.cpp') diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp index 06767c5340..378408df66 100644 --- a/engines/zvision/scr_file_handling.cpp +++ b/engines/zvision/scr_file_handling.cpp @@ -168,7 +168,7 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis } else if (line.matchString("*:attenuate*", true)) { // TODO: Implement ActionAttenuate } else if (line.matchString("*:assign*", true)) { - // TODO: Implement ActionAssign + actionList.push_back(new ActionAssign(line)); } else if (line.matchString("*:change_location*", true)) { actionList.push_back(new ActionChangeLocation(line)); } else if (line.matchString("*:crossfade*", true)) { -- cgit v1.2.3 From b1587f8ba0f335aff7133f7422953be83aa4c5ae Mon Sep 17 00:00:00 2001 From: RichieSams Date: Sat, 7 Sep 2013 18:08:49 -0500 Subject: ZVISION: Implement ActionPlayPreloadAnimation --- engines/zvision/scr_file_handling.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/zvision/scr_file_handling.cpp') diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp index 378408df66..3d4718557f 100644 --- a/engines/zvision/scr_file_handling.cpp +++ b/engines/zvision/scr_file_handling.cpp @@ -202,7 +202,7 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis } else if (line.matchString("*:pan_track*", true)) { // TODO: Implement ActionPanTrack } else if (line.matchString("*:playpreload*", true)) { - // TODO: Implement ActionPlayPreload + actionList.push_back(new ActionPlayPreloadAnimation(line)); } else if (line.matchString("*:preferences*", true)) { // TODO: Implement ActionPreferences } else if (line.matchString("*:quit*", true)) { -- cgit v1.2.3 From 259d11762dbf32ec1db6869510657331bb8c88e9 Mon Sep 17 00:00:00 2001 From: RichieSams Date: Sun, 15 Sep 2013 14:42:55 -0500 Subject: ZVISION: Add support for ActionRandom and ActionTimer They were already implemented, they just weren't being used --- engines/zvision/scr_file_handling.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/zvision/scr_file_handling.cpp') diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp index 3d4718557f..fa89f756e4 100644 --- a/engines/zvision/scr_file_handling.cpp +++ b/engines/zvision/scr_file_handling.cpp @@ -208,7 +208,7 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis } else if (line.matchString("*:quit*", true)) { actionList.push_back(new ActionQuit()); } else if (line.matchString("*:random*", true)) { - // TODO: Implement ActionRandom + actionList.push_back(new ActionRandom(line)); } else if (line.matchString("*:region*", true)) { // TODO: Implement ActionRegion } else if (line.matchString("*:restore_game*", true)) { @@ -230,7 +230,7 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis } else if (line.matchString("*:syncsound*", true)) { // TODO: Implement ActionSyncSound } else if (line.matchString("*:timer*", true)) { - // TODO: Implement ActionTimer + actionList.push_back(new ActionTimer(line)); } else if (line.matchString("*:ttytext*", true)) { // TODO: Implement ActionTTYText } else if (line.matchString("*:universe_music*", true)) { -- cgit v1.2.3 From bad28dc15872e208bf21f1e6fa2ab906bca598c4 Mon Sep 17 00:00:00 2001 From: RichieSams Date: Tue, 1 Oct 2013 20:08:41 -0500 Subject: ZVISION: Standardize includes order and format Format is: common/scummsys.h (Only if a .cpp file) header file for this file (Only if a .cpp file) zengine includes other includes, grouped by module --- engines/zvision/scr_file_handling.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'engines/zvision/scr_file_handling.cpp') diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp index fa89f756e4..e90408cf0d 100644 --- a/engines/zvision/scr_file_handling.cpp +++ b/engines/zvision/scr_file_handling.cpp @@ -23,6 +23,7 @@ #include "common/scummsys.h" #include "zvision/script_manager.h" + #include "zvision/utility.h" #include "zvision/puzzle.h" #include "zvision/actions.h" @@ -33,6 +34,7 @@ #include "common/file.h" #include "common/tokenizer.h" + namespace ZVision { void ScriptManager::parseScrFile(const Common::String &fileName, bool isGlobal) { -- cgit v1.2.3