aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFilippos Karapetis2014-12-16 01:58:05 +0200
committerFilippos Karapetis2014-12-16 01:58:57 +0200
commit77705752efa00ab7f6c65ff8d99e4d9c3fdc4929 (patch)
treef2c320a1eb8028a0ec6586510421418eb8462380
parent7630e3204e3b932d9b43bda7dc4b658405fabf33 (diff)
downloadscummvm-rg350-77705752efa00ab7f6c65ff8d99e4d9c3fdc4929.tar.gz
scummvm-rg350-77705752efa00ab7f6c65ff8d99e4d9c3fdc4929.tar.bz2
scummvm-rg350-77705752efa00ab7f6c65ff8d99e4d9c3fdc4929.zip
ZVISION: Move trimCommentsAndWhiteSpace() into the script manager
This allows us to remove the last remnants of utility.*
-rw-r--r--engines/zvision/core/console.cpp1
-rw-r--r--engines/zvision/core/utility.cpp45
-rw-r--r--engines/zvision/core/utility.h47
-rw-r--r--engines/zvision/module.mk1
-rw-r--r--engines/zvision/scripting/control.cpp9
-rw-r--r--engines/zvision/scripting/controls/fist_control.cpp5
-rw-r--r--engines/zvision/scripting/controls/hotmov_control.cpp5
-rw-r--r--engines/zvision/scripting/controls/input_control.cpp5
-rw-r--r--engines/zvision/scripting/controls/lever_control.cpp5
-rw-r--r--engines/zvision/scripting/controls/paint_control.cpp5
-rw-r--r--engines/zvision/scripting/controls/push_toggle_control.cpp5
-rw-r--r--engines/zvision/scripting/controls/safe_control.cpp5
-rw-r--r--engines/zvision/scripting/controls/save_control.cpp5
-rw-r--r--engines/zvision/scripting/controls/slot_control.cpp5
-rw-r--r--engines/zvision/scripting/controls/titler_control.cpp5
-rw-r--r--engines/zvision/scripting/scr_file_handling.cpp1
-rw-r--r--engines/zvision/scripting/script_manager.cpp11
-rw-r--r--engines/zvision/scripting/script_manager.h9
-rw-r--r--engines/zvision/sound/zork_raw.cpp1
19 files changed, 43 insertions, 132 deletions
diff --git a/engines/zvision/core/console.cpp b/engines/zvision/core/console.cpp
index eb4d281813..4dd10d6f40 100644
--- a/engines/zvision/core/console.cpp
+++ b/engines/zvision/core/console.cpp
@@ -30,7 +30,6 @@
#include "zvision/text/string_manager.h"
#include "zvision/video/zork_avi_decoder.h"
#include "zvision/sound/zork_raw.h"
-#include "zvision/core/utility.h"
#include "zvision/graphics/cursors/cursor.h"
#include "common/system.h"
diff --git a/engines/zvision/core/utility.cpp b/engines/zvision/core/utility.cpp
deleted file mode 100644
index dcbb41171e..0000000000
--- a/engines/zvision/core/utility.cpp
+++ /dev/null
@@ -1,45 +0,0 @@
-/* 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 "zvision/core/utility.h"
-
-#include "zvision/zvision.h"
-#include "zvision/sound/zork_raw.h"
-
-#include "common/tokenizer.h"
-#include "common/file.h"
-
-namespace ZVision {
-
-void trimCommentsAndWhiteSpace(Common::String *string) {
- for (int i = string->size() - 1; i >= 0; i--) {
- if ((*string)[i] == '#') {
- string->erase(i);
- }
- }
-
- string->trim();
-}
-
-} // End of namespace ZVision
diff --git a/engines/zvision/core/utility.h b/engines/zvision/core/utility.h
deleted file mode 100644
index 0ca26b968d..0000000000
--- a/engines/zvision/core/utility.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/* 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.
- *
- */
-
-#ifndef ZVISION_UTILITY_H
-#define ZVISION_UTILITY_H
-
-#include "common/array.h"
-
-namespace Common {
-class String;
-}
-
-namespace ZVision {
-
-class ZVision;
-
-/**
- * Removes any line comments using '#' as a sequence start.
- * Then removes any trailing and leading 'whitespace' using String::trim()
- * Note: String::trim uses isspace() to determine what is whitespace and what is not.
- *
- * @param string The string to modify. It is modified in place
- */
-void trimCommentsAndWhiteSpace(Common::String *string);
-
-} // End of namespace ZVision
-
-#endif
diff --git a/engines/zvision/module.mk b/engines/zvision/module.mk
index 18923eeb8f..00652f0824 100644
--- a/engines/zvision/module.mk
+++ b/engines/zvision/module.mk
@@ -6,7 +6,6 @@ MODULE_OBJS := \
core/events.o \
core/menu.o \
core/save_manager.o \
- core/utility.o \
detection.o \
file/lzss_read_stream.o \
file/search_manager.o \
diff --git a/engines/zvision/scripting/control.cpp b/engines/zvision/scripting/control.cpp
index 86f6a30c8f..127f35ef12 100644
--- a/engines/zvision/scripting/control.cpp
+++ b/engines/zvision/scripting/control.cpp
@@ -27,7 +27,6 @@
#include "zvision/zvision.h"
#include "zvision/graphics/render_manager.h"
-#include "zvision/core/utility.h"
#include "common/stream.h"
@@ -43,7 +42,7 @@ void Control::parsePanoramaControl(ZVision *engine, Common::SeekableReadStream &
// Loop until we find the closing brace
Common::String line = stream.readLine();
- trimCommentsAndWhiteSpace(&line);
+ engine->getScriptManager()->trimCommentsAndWhiteSpace(&line);
while (!stream.eos() && !line.contains('}')) {
if (line.matchString("angle*", true)) {
@@ -67,7 +66,7 @@ void Control::parsePanoramaControl(ZVision *engine, Common::SeekableReadStream &
}
line = stream.readLine();
- trimCommentsAndWhiteSpace(&line);
+ engine->getScriptManager()->trimCommentsAndWhiteSpace(&line);
}
renderTable->generateRenderTable();
@@ -79,7 +78,7 @@ void Control::parseTiltControl(ZVision *engine, Common::SeekableReadStream &stre
// Loop until we find the closing brace
Common::String line = stream.readLine();
- trimCommentsAndWhiteSpace(&line);
+ engine->getScriptManager()->trimCommentsAndWhiteSpace(&line);
while (!stream.eos() && !line.contains('}')) {
if (line.matchString("angle*", true)) {
@@ -99,7 +98,7 @@ void Control::parseTiltControl(ZVision *engine, Common::SeekableReadStream &stre
}
line = stream.readLine();
- trimCommentsAndWhiteSpace(&line);
+ engine->getScriptManager()->trimCommentsAndWhiteSpace(&line);
}
renderTable->generateRenderTable();
diff --git a/engines/zvision/scripting/controls/fist_control.cpp b/engines/zvision/scripting/controls/fist_control.cpp
index 40d016f360..34a64b4298 100644
--- a/engines/zvision/scripting/controls/fist_control.cpp
+++ b/engines/zvision/scripting/controls/fist_control.cpp
@@ -27,7 +27,6 @@
#include "zvision/scripting/controls/fist_control.h"
#include "zvision/graphics/render_manager.h"
#include "zvision/graphics/cursors/cursor_manager.h"
-#include "zvision/core/utility.h"
#include "zvision/video/rlf_decoder.h"
#include "common/stream.h"
@@ -63,7 +62,7 @@ FistControl::FistControl(ZVision *engine, uint32 key, Common::SeekableReadStream
// Loop until we find the closing brace
Common::String line = stream.readLine();
- trimCommentsAndWhiteSpace(&line);
+ _engine->getScriptManager()->trimCommentsAndWhiteSpace(&line);
Common::String param;
Common::String values;
getParams(line, param, values);
@@ -82,7 +81,7 @@ FistControl::FistControl(ZVision *engine, uint32 key, Common::SeekableReadStream
}
line = stream.readLine();
- trimCommentsAndWhiteSpace(&line);
+ _engine->getScriptManager()->trimCommentsAndWhiteSpace(&line);
getParams(line, param, values);
}
}
diff --git a/engines/zvision/scripting/controls/hotmov_control.cpp b/engines/zvision/scripting/controls/hotmov_control.cpp
index 4a6d2705b4..e77272ec73 100644
--- a/engines/zvision/scripting/controls/hotmov_control.cpp
+++ b/engines/zvision/scripting/controls/hotmov_control.cpp
@@ -28,7 +28,6 @@
#include "zvision/scripting/script_manager.h"
#include "zvision/graphics/render_manager.h"
#include "zvision/graphics/cursors/cursor_manager.h"
-#include "zvision/core/utility.h"
#include "common/stream.h"
#include "common/file.h"
@@ -53,7 +52,7 @@ HotMovControl::HotMovControl(ZVision *engine, uint32 key, Common::SeekableReadSt
// Loop until we find the closing brace
Common::String line = stream.readLine();
- trimCommentsAndWhiteSpace(&line);
+ _engine->getScriptManager()->trimCommentsAndWhiteSpace(&line);
Common::String param;
Common::String values;
getParams(line, param, values);
@@ -84,7 +83,7 @@ HotMovControl::HotMovControl(ZVision *engine, uint32 key, Common::SeekableReadSt
}
line = stream.readLine();
- trimCommentsAndWhiteSpace(&line);
+ _engine->getScriptManager()->trimCommentsAndWhiteSpace(&line);
getParams(line, param, values);
}
}
diff --git a/engines/zvision/scripting/controls/input_control.cpp b/engines/zvision/scripting/controls/input_control.cpp
index e17a5f6dd8..6959f9eca9 100644
--- a/engines/zvision/scripting/controls/input_control.cpp
+++ b/engines/zvision/scripting/controls/input_control.cpp
@@ -29,7 +29,6 @@
#include "zvision/scripting/script_manager.h"
#include "zvision/text/string_manager.h"
#include "zvision/graphics/render_manager.h"
-#include "zvision/core/utility.h"
#include "common/str.h"
#include "common/stream.h"
@@ -50,7 +49,7 @@ InputControl::InputControl(ZVision *engine, uint32 key, Common::SeekableReadStre
_animation(NULL) {
// Loop until we find the closing brace
Common::String line = stream.readLine();
- trimCommentsAndWhiteSpace(&line);
+ _engine->getScriptManager()->trimCommentsAndWhiteSpace(&line);
Common::String param;
Common::String values;
getParams(line, param, values);
@@ -108,7 +107,7 @@ InputControl::InputControl(ZVision *engine, uint32 key, Common::SeekableReadStre
}
line = stream.readLine();
- trimCommentsAndWhiteSpace(&line);
+ _engine->getScriptManager()->trimCommentsAndWhiteSpace(&line);
getParams(line, param, values);
}
}
diff --git a/engines/zvision/scripting/controls/lever_control.cpp b/engines/zvision/scripting/controls/lever_control.cpp
index 632554e7f2..71dd52f40f 100644
--- a/engines/zvision/scripting/controls/lever_control.cpp
+++ b/engines/zvision/scripting/controls/lever_control.cpp
@@ -28,7 +28,6 @@
#include "zvision/scripting/script_manager.h"
#include "zvision/graphics/render_manager.h"
#include "zvision/graphics/cursors/cursor_manager.h"
-#include "zvision/core/utility.h"
#include "common/stream.h"
#include "common/file.h"
@@ -53,7 +52,7 @@ LeverControl::LeverControl(ZVision *engine, uint32 key, Common::SeekableReadStre
// Loop until we find the closing brace
Common::String line = stream.readLine();
- trimCommentsAndWhiteSpace(&line);
+ _engine->getScriptManager()->trimCommentsAndWhiteSpace(&line);
Common::String param;
Common::String values;
@@ -73,7 +72,7 @@ LeverControl::LeverControl(ZVision *engine, uint32 key, Common::SeekableReadStre
}
line = stream.readLine();
- trimCommentsAndWhiteSpace(&line);
+ _engine->getScriptManager()->trimCommentsAndWhiteSpace(&line);
getParams(line, param, values);
}
diff --git a/engines/zvision/scripting/controls/paint_control.cpp b/engines/zvision/scripting/controls/paint_control.cpp
index 24306bf4db..f06dee25ad 100644
--- a/engines/zvision/scripting/controls/paint_control.cpp
+++ b/engines/zvision/scripting/controls/paint_control.cpp
@@ -28,7 +28,6 @@
#include "zvision/scripting/script_manager.h"
#include "zvision/graphics/cursors/cursor_manager.h"
#include "zvision/graphics/render_manager.h"
-#include "zvision/core/utility.h"
namespace ZVision {
@@ -44,7 +43,7 @@ PaintControl::PaintControl(ZVision *engine, uint32 key, Common::SeekableReadStre
// Loop until we find the closing brace
Common::String line = stream.readLine();
- trimCommentsAndWhiteSpace(&line);
+ _engine->getScriptManager()->trimCommentsAndWhiteSpace(&line);
Common::String param;
Common::String values;
getParams(line, param, values);
@@ -93,7 +92,7 @@ PaintControl::PaintControl(ZVision *engine, uint32 key, Common::SeekableReadStre
}
line = stream.readLine();
- trimCommentsAndWhiteSpace(&line);
+ _engine->getScriptManager()->trimCommentsAndWhiteSpace(&line);
getParams(line, param, values);
}
diff --git a/engines/zvision/scripting/controls/push_toggle_control.cpp b/engines/zvision/scripting/controls/push_toggle_control.cpp
index 28c791168a..3811498cd5 100644
--- a/engines/zvision/scripting/controls/push_toggle_control.cpp
+++ b/engines/zvision/scripting/controls/push_toggle_control.cpp
@@ -27,7 +27,6 @@
#include "zvision/zvision.h"
#include "zvision/scripting/script_manager.h"
#include "zvision/graphics/cursors/cursor_manager.h"
-#include "zvision/core/utility.h"
#include "common/stream.h"
@@ -42,7 +41,7 @@ PushToggleControl::PushToggleControl(ZVision *engine, uint32 key, Common::Seekab
// Loop until we find the closing brace
Common::String line = stream.readLine();
- trimCommentsAndWhiteSpace(&line);
+ _engine->getScriptManager()->trimCommentsAndWhiteSpace(&line);
Common::String param;
Common::String values;
getParams(line, param, values);
@@ -78,7 +77,7 @@ PushToggleControl::PushToggleControl(ZVision *engine, uint32 key, Common::Seekab
}
line = stream.readLine();
- trimCommentsAndWhiteSpace(&line);
+ _engine->getScriptManager()->trimCommentsAndWhiteSpace(&line);
getParams(line, param, values);
}
diff --git a/engines/zvision/scripting/controls/safe_control.cpp b/engines/zvision/scripting/controls/safe_control.cpp
index cb754ecbe2..71be692431 100644
--- a/engines/zvision/scripting/controls/safe_control.cpp
+++ b/engines/zvision/scripting/controls/safe_control.cpp
@@ -28,7 +28,6 @@
#include "zvision/scripting/script_manager.h"
#include "zvision/graphics/render_manager.h"
#include "zvision/graphics/cursors/cursor_manager.h"
-#include "zvision/core/utility.h"
#include "common/stream.h"
#include "common/file.h"
@@ -57,7 +56,7 @@ SafeControl::SafeControl(ZVision *engine, uint32 key, Common::SeekableReadStream
// Loop until we find the closing brace
Common::String line = stream.readLine();
- trimCommentsAndWhiteSpace(&line);
+ _engine->getScriptManager()->trimCommentsAndWhiteSpace(&line);
Common::String param;
Common::String values;
getParams(line, param, values);
@@ -102,7 +101,7 @@ SafeControl::SafeControl(ZVision *engine, uint32 key, Common::SeekableReadStream
}
line = stream.readLine();
- trimCommentsAndWhiteSpace(&line);
+ _engine->getScriptManager()->trimCommentsAndWhiteSpace(&line);
getParams(line, param, values);
}
renderFrame(_curState);
diff --git a/engines/zvision/scripting/controls/save_control.cpp b/engines/zvision/scripting/controls/save_control.cpp
index 7de138d8e3..e27faa50b6 100644
--- a/engines/zvision/scripting/controls/save_control.cpp
+++ b/engines/zvision/scripting/controls/save_control.cpp
@@ -24,7 +24,6 @@
#include "zvision/scripting/controls/input_control.h"
#include "zvision/scripting/controls/save_control.h"
-#include "zvision/core/utility.h"
#include "zvision/zvision.h"
#include "zvision/scripting/script_manager.h"
@@ -42,7 +41,7 @@ SaveControl::SaveControl(ZVision *engine, uint32 key, Common::SeekableReadStream
_saveControl(false) {
// Loop until we find the closing brace
Common::String line = stream.readLine();
- trimCommentsAndWhiteSpace(&line);
+ _engine->getScriptManager()->trimCommentsAndWhiteSpace(&line);
Common::String param;
Common::String values;
getParams(line, param, values);
@@ -66,7 +65,7 @@ SaveControl::SaveControl(ZVision *engine, uint32 key, Common::SeekableReadStream
}
line = stream.readLine();
- trimCommentsAndWhiteSpace(&line);
+ _engine->getScriptManager()->trimCommentsAndWhiteSpace(&line);
getParams(line, param, values);
}
diff --git a/engines/zvision/scripting/controls/slot_control.cpp b/engines/zvision/scripting/controls/slot_control.cpp
index 63578d54ea..292a2b4bc9 100644
--- a/engines/zvision/scripting/controls/slot_control.cpp
+++ b/engines/zvision/scripting/controls/slot_control.cpp
@@ -28,7 +28,6 @@
#include "zvision/scripting/script_manager.h"
#include "zvision/graphics/cursors/cursor_manager.h"
#include "zvision/graphics/render_manager.h"
-#include "zvision/core/utility.h"
#include "common/stream.h"
@@ -42,7 +41,7 @@ SlotControl::SlotControl(ZVision *engine, uint32 key, Common::SeekableReadStream
// Loop until we find the closing brace
Common::String line = stream.readLine();
- trimCommentsAndWhiteSpace(&line);
+ _engine->getScriptManager()->trimCommentsAndWhiteSpace(&line);
Common::String param;
Common::String values;
getParams(line, param, values);
@@ -98,7 +97,7 @@ SlotControl::SlotControl(ZVision *engine, uint32 key, Common::SeekableReadStream
}
line = stream.readLine();
- trimCommentsAndWhiteSpace(&line);
+ _engine->getScriptManager()->trimCommentsAndWhiteSpace(&line);
getParams(line, param, values);
}
diff --git a/engines/zvision/scripting/controls/titler_control.cpp b/engines/zvision/scripting/controls/titler_control.cpp
index af26aed952..10ba0af655 100644
--- a/engines/zvision/scripting/controls/titler_control.cpp
+++ b/engines/zvision/scripting/controls/titler_control.cpp
@@ -28,7 +28,6 @@
#include "zvision/text/text.h"
#include "zvision/scripting/script_manager.h"
#include "zvision/graphics/render_manager.h"
-#include "zvision/core/utility.h"
#include "common/stream.h"
@@ -42,7 +41,7 @@ TitlerControl::TitlerControl(ZVision *engine, uint32 key, Common::SeekableReadSt
// Loop until we find the closing brace
Common::String line = stream.readLine();
- trimCommentsAndWhiteSpace(&line);
+ _engine->getScriptManager()->trimCommentsAndWhiteSpace(&line);
Common::String param;
Common::String values;
getParams(line, param, values);
@@ -62,7 +61,7 @@ TitlerControl::TitlerControl(ZVision *engine, uint32 key, Common::SeekableReadSt
}
line = stream.readLine();
- trimCommentsAndWhiteSpace(&line);
+ _engine->getScriptManager()->trimCommentsAndWhiteSpace(&line);
getParams(line, param, values);
}
diff --git a/engines/zvision/scripting/scr_file_handling.cpp b/engines/zvision/scripting/scr_file_handling.cpp
index 631cb6128e..56d0c3bd7f 100644
--- a/engines/zvision/scripting/scr_file_handling.cpp
+++ b/engines/zvision/scripting/scr_file_handling.cpp
@@ -25,7 +25,6 @@
#include "zvision/zvision.h"
#include "zvision/scripting/script_manager.h"
-#include "zvision/core/utility.h"
#include "zvision/scripting/puzzle.h"
#include "zvision/scripting/actions.h"
#include "zvision/scripting/controls/push_toggle_control.h"
diff --git a/engines/zvision/scripting/script_manager.cpp b/engines/zvision/scripting/script_manager.cpp
index 605d27216e..65077dfd12 100644
--- a/engines/zvision/scripting/script_manager.cpp
+++ b/engines/zvision/scripting/script_manager.cpp
@@ -29,7 +29,6 @@
#include "zvision/graphics/cursors/cursor_manager.h"
#include "zvision/core/save_manager.h"
#include "zvision/scripting/actions.h"
-#include "zvision/core/utility.h"
#include "zvision/scripting/sidefx/timer_node.h"
#include "common/algorithm.h"
@@ -812,6 +811,16 @@ void ScriptManager::flushEvent(Common::EventType type) {
}
}
+void ScriptManager::trimCommentsAndWhiteSpace(Common::String *string) const {
+ for (int i = string->size() - 1; i >= 0; i--) {
+ if ((*string)[i] == '#') {
+ string->erase(i);
+ }
+ }
+
+ string->trim();
+}
+
ValueSlot::ValueSlot(ScriptManager *scriptManager, const char *slotValue):
_scriptManager(scriptManager) {
value = 0;
diff --git a/engines/zvision/scripting/script_manager.h b/engines/zvision/scripting/script_manager.h
index 89b961634b..1e308faf0d 100644
--- a/engines/zvision/scripting/script_manager.h
+++ b/engines/zvision/scripting/script_manager.h
@@ -247,6 +247,15 @@ public:
Location getLastLocation();
Location getLastMenuLocation();
+ /**
+ * Removes any line comments using '#' as a sequence start.
+ * Then removes any trailing and leading 'whitespace' using String::trim()
+ * Note: String::trim uses isspace() to determine what is whitespace and what is not.
+ *
+ * @param string The string to modify. It is modified in place
+ */
+ void trimCommentsAndWhiteSpace(Common::String *string) const;
+
private:
void referenceTableAddPuzzle(uint32 key, PuzzleRef ref);
void addPuzzlesToReferenceTable(ScriptScope &scope);
diff --git a/engines/zvision/sound/zork_raw.cpp b/engines/zvision/sound/zork_raw.cpp
index d8fabc419b..78c851e132 100644
--- a/engines/zvision/sound/zork_raw.cpp
+++ b/engines/zvision/sound/zork_raw.cpp
@@ -34,7 +34,6 @@
#include "zvision/sound/zork_raw.h"
#include "zvision/zvision.h"
#include "zvision/detection.h"
-#include "zvision/core/utility.h"
namespace ZVision {