diff options
-rw-r--r-- | engines/zvision/scr_file_handling.cpp | 14 | ||||
-rw-r--r-- | engines/zvision/utility.h | 11 |
2 files changed, 13 insertions, 12 deletions
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<ResultAction *> &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)) { diff --git a/engines/zvision/utility.h b/engines/zvision/utility.h index 4d124509ba..511b3c12f2 100644 --- a/engines/zvision/utility.h +++ b/engines/zvision/utility.h @@ -59,14 +59,15 @@ void writeFileContentsToFile(Common::String sourceFile, Common::String destFile) * * @param string The string to modify. It is modified in place */ -void trimCommentsAndWhiteSpace(Common::String &string) { - for (int i = string.size(); i >= 0; --i) { - if (string[i] == '#') { - string.erase(i); +void trimCommentsAndWhiteSpace(Common::String *string) { + for (int i = string->size() - 1; i >= 0; i--) { + if ((*string)[i] == '#') { + string->erase(i); } } - string.trim(); + string->trim(); +} } } // End of namespace ZVision |