aboutsummaryrefslogtreecommitdiff
path: root/engines/wintermute/base/scriptables/debuggable
diff options
context:
space:
mode:
authorTobia Tesan2016-02-29 11:37:06 +0100
committerTobia Tesan2016-03-01 20:40:45 +0100
commitdae732814c7c368f74f09174080e9bdd610982d2 (patch)
tree352a7e6237f7fd4908d82bfc71356580fb9f5af6 /engines/wintermute/base/scriptables/debuggable
parentde82216dff8fc3339c493cb1a4913eea119d614f (diff)
downloadscummvm-rg350-dae732814c7c368f74f09174080e9bdd610982d2.tar.gz
scummvm-rg350-dae732814c7c368f74f09174080e9bdd610982d2.tar.bz2
scummvm-rg350-dae732814c7c368f74f09174080e9bdd610982d2.zip
WINTERMUTE: Add name resolution to DebuggableScript
Diffstat (limited to 'engines/wintermute/base/scriptables/debuggable')
-rw-r--r--engines/wintermute/base/scriptables/debuggable/debuggable_script.cpp38
-rw-r--r--engines/wintermute/base/scriptables/debuggable/debuggable_script.h1
2 files changed, 39 insertions, 0 deletions
diff --git a/engines/wintermute/base/scriptables/debuggable/debuggable_script.cpp b/engines/wintermute/base/scriptables/debuggable/debuggable_script.cpp
index 670a6d4045..1aa318bdbf 100644
--- a/engines/wintermute/base/scriptables/debuggable/debuggable_script.cpp
+++ b/engines/wintermute/base/scriptables/debuggable/debuggable_script.cpp
@@ -20,6 +20,7 @@
*
*/
+#include "common/tokenizer.h"
#include "debuggable_script.h"
#include "engines/wintermute/base/scriptables/debuggable/debuggable_script_engine.h"
#include "engines/wintermute/base/scriptables/script_stack.h"
@@ -64,6 +65,43 @@ void DebuggableScript::stepFinish() {
setStepDepth(_callStack->_sP - 1);
}
+ScValue *DebuggableScript::resolveName(const Common::String &name) {
+
+ Common::String trimmed = name;
+ trimmed.trim();
+ Common::StringTokenizer st = Common::StringTokenizer(trimmed.c_str(), ".");
+ Common::String nextToken;
+
+ nextToken = st.nextToken();
+
+
+ char cstr[256]; // TODO not pretty
+ Common::strlcpy(cstr, nextToken.c_str(), nextToken.size() + 1);
+ cstr[255] = '\0'; // We 0-terminate it just in case it's > 256 chars.
+
+ ScValue *value = getVar(cstr);
+ ScValue *res = new ScValue(_gameRef);
+
+ if (value == nullptr) {
+ return res;
+ }
+
+ nextToken = st.nextToken();
+
+ while (nextToken.size() > 0 && (value->isObject() || value->isNative())) {
+ value = value->getProp(nextToken.c_str());
+ nextToken = st.nextToken();
+ if (value == nullptr) {
+ return res;
+ }
+ }
+
+ res->copy(value);
+ delete value;
+
+ return res;
+}
+
uint DebuggableScript::dbgGetLine() const {
return _currentLine;
}
diff --git a/engines/wintermute/base/scriptables/debuggable/debuggable_script.h b/engines/wintermute/base/scriptables/debuggable/debuggable_script.h
index dc9accece9..c5c0896f11 100644
--- a/engines/wintermute/base/scriptables/debuggable/debuggable_script.h
+++ b/engines/wintermute/base/scriptables/debuggable/debuggable_script.h
@@ -39,6 +39,7 @@ class DebuggableScript : public ScScript {
public:
DebuggableScript(BaseGame *inGame, DebuggableScEngine *engine);
virtual ~DebuggableScript();
+ ScValue *resolveName(const Common::String &name);
/**
* Return argument to last II_DBG_LINE encountered
*/