aboutsummaryrefslogtreecommitdiff
path: root/scumm/script.cpp
diff options
context:
space:
mode:
authorMax Horn2002-12-28 01:57:19 +0000
committerMax Horn2002-12-28 01:57:19 +0000
commitae5b30df3d67644f341a30997de5192fed8bcbdc (patch)
treedb63a860f15229ec901e9b6d0bedaaf9f6f2435f /scumm/script.cpp
parent319facc9c3a54bff3adab663e32f37bddb07c9e9 (diff)
downloadscummvm-rg350-ae5b30df3d67644f341a30997de5192fed8bcbdc.tar.gz
scummvm-rg350-ae5b30df3d67644f341a30997de5192fed8bcbdc.tar.bz2
scummvm-rg350-ae5b30df3d67644f341a30997de5192fed8bcbdc.zip
get rid of getStringLen and use the more powerful resStrLen instead; moved resStrLen from common/ to scumm/, where it belongs; enhanced resStrLen to suport V8; fixed translateText to support embeded vars (in strings I mean) - it may still not be fully correct but at least is better now; rewrote o6_arrayOps to parallel the V8 version - needs testing
svn-id: r6215
Diffstat (limited to 'scumm/script.cpp')
-rw-r--r--scumm/script.cpp56
1 files changed, 33 insertions, 23 deletions
diff --git a/scumm/script.cpp b/scumm/script.cpp
index 3f5d5edd9b..81e3d14501 100644
--- a/scumm/script.cpp
+++ b/scumm/script.cpp
@@ -1097,33 +1097,43 @@ int Scumm::getArrayId()
return -1;
}
-void Scumm::copyString(byte *dst, byte *src, int len)
+void Scumm::copyScriptString(byte *dst)
{
- if (!src) {
- while (--len >= 0)
- *dst++ = fetchScriptByte();
- } else {
- while (--len >= 0)
- *dst++ = *src++;
- }
+ int len = resStrLen(_scriptPointer) + 1;
+ while (len--)
+ *dst++ = fetchScriptByte();
}
-int Scumm::getStringLen(byte *ptr)
+//
+// Given a pointer to a Scumm string, this function returns the total byte length
+// of the string data in that resource. To do so it has to understand certain
+// special characters embedded into the string. The reason for this function is that
+// sometimes this embedded data contains zero bytes, thus we can't just use strlen.
+//
+int Scumm::resStrLen(const byte *src) const
{
- int len;
- byte c;
- if (!ptr)
- ptr = _scriptPointer;
- len = 0;
- do {
- c = *ptr++;
- if (!c)
- break;
- len++;
- if (c == 0xFF)
- ptr += 3, len += 3;
- } while (1);
- return len + 1;
+ int num = 0;
+ byte chr;
+ if (src == NULL)
+ src = _scriptPointer;
+ while ((chr = *src++) != 0) {
+ num++;
+ if (chr == 255) {
+ chr = *src++;
+ num++;
+
+ if (chr != 1 && chr != 2 && chr != 3 && chr != 8) {
+ if (_features & GF_AFTER_V8) {
+ src += 4;
+ num += 4;
+ } else {
+ src += 2;
+ num += 2;
+ }
+ }
+ }
+ }
+ return num;
}
void Scumm::exitCutscene()