aboutsummaryrefslogtreecommitdiff
path: root/engines/mohawk
diff options
context:
space:
mode:
authorAlyssa Milburn2013-04-19 00:48:41 +0200
committerAlyssa Milburn2013-04-19 00:48:41 +0200
commit02d81911cd10763166a7b9e58e86a396e44e52ab (patch)
treea825d9d751d69b03fe0478a68853810e5299e919 /engines/mohawk
parent16259a52e335fe2b75bb260e433c55e9c0b1360f (diff)
downloadscummvm-rg350-02d81911cd10763166a7b9e58e86a396e44e52ab.tar.gz
scummvm-rg350-02d81911cd10763166a7b9e58e86a396e44e52ab.tar.bz2
scummvm-rg350-02d81911cd10763166a7b9e58e86a396e44e52ab.zip
MOHAWK: Add LB function name aliases.
Diffstat (limited to 'engines/mohawk')
-rw-r--r--engines/mohawk/livingbooks_code.cpp26
-rw-r--r--engines/mohawk/livingbooks_code.h2
2 files changed, 24 insertions, 4 deletions
diff --git a/engines/mohawk/livingbooks_code.cpp b/engines/mohawk/livingbooks_code.cpp
index dabf8676d4..c45efb2c39 100644
--- a/engines/mohawk/livingbooks_code.cpp
+++ b/engines/mohawk/livingbooks_code.cpp
@@ -1589,12 +1589,32 @@ uint LBCode::nextFreeString() {
error("nextFreeString couldn't find a space");
}
+static const char *const functionNameAliases[][2] = {
+ { "makerect", "getRect" },
+ { "makepair", "makePt" },
+ { "getframerect", "getFrameBounds" },
+ { "dragbegin", "dragBeginFrom" },
+ { "x", "xpos" },
+ { "y", "ypos" }
+};
+
/*
* Helper function for parseCode:
* Given a name, appends the appropriate data to the provided code array and
* returns true if it's a function, or false otherwise.
*/
-bool LBCode::parseCodeSymbol(const Common::String &name, uint &pos, Common::Array<byte> &code) {
+bool LBCode::parseCodeSymbol(Common::String name, uint &pos, Common::Array<byte> &code, bool useAllAliases) {
+ // Check to see if we have one of the older function names
+ // and remap it to the newer function names
+ for (uint i = 0; i < ARRAYSIZE(functionNameAliases); i++) {
+ if (name.equalsIgnoreCase(functionNameAliases[i][0])) {
+ if (name.size() == 1 && !useAllAliases)
+ continue;
+ name = functionNameAliases[i][1];
+ break;
+ }
+ }
+
// first, check whether the name matches a known function
for (uint i = 0; i < 2; i++) {
byte cmdToken;
@@ -1805,7 +1825,7 @@ uint LBCode::parseCode(const Common::String &source) {
break;
tempString += source[pos++];
}
- wasFunction = parseCodeSymbol(tempString, pos, code);
+ wasFunction = parseCodeSymbol(tempString, pos, code, true);
if (!wasFunction)
error("while parsing script '%s', encountered explicit function call to unknown function '%s'",
source.c_str(), tempString.c_str());
@@ -1840,7 +1860,7 @@ uint LBCode::parseCode(const Common::String &source) {
} else if (tempString.equalsIgnoreCase("false")) {
code.push_back(kTokenFalse);
} else {
- wasFunction = parseCodeSymbol(tempString, pos, code);
+ wasFunction = parseCodeSymbol(tempString, pos, code, false);
}
} else {
error("while parsing script '%s', couldn't parse '%c'", source.c_str(), token);
diff --git a/engines/mohawk/livingbooks_code.h b/engines/mohawk/livingbooks_code.h
index b2b4772478..c9d9ae06e6 100644
--- a/engines/mohawk/livingbooks_code.h
+++ b/engines/mohawk/livingbooks_code.h
@@ -243,7 +243,7 @@ protected:
void runNotifyCommand();
uint nextFreeString();
- bool parseCodeSymbol(const Common::String &name, uint &pos, Common::Array<byte> &code);
+ bool parseCodeSymbol(Common::String name, uint &pos, Common::Array<byte> &code, bool useAllAliases);
public:
void cmdUnimplemented(const Common::Array<LBValue> &params);