aboutsummaryrefslogtreecommitdiff
path: root/scumm
diff options
context:
space:
mode:
authorTravis Howell2005-03-03 04:54:23 +0000
committerTravis Howell2005-03-03 04:54:23 +0000
commitac493b31db8c3e2181141191d10962c38ce957e8 (patch)
tree77c437d67a798a2b8a8781d524cc68b37d9e416d /scumm
parent78e3fc94155fa760819f74b038346251a35d3905 (diff)
downloadscummvm-rg350-ac493b31db8c3e2181141191d10962c38ce957e8.tar.gz
scummvm-rg350-ac493b31db8c3e2181141191d10962c38ce957e8.tar.bz2
scummvm-rg350-ac493b31db8c3e2181141191d10962c38ce957e8.zip
Fix compare string.
svn-id: r16981
Diffstat (limited to 'scumm')
-rw-r--r--scumm/script_v7he.cpp44
1 files changed, 16 insertions, 28 deletions
diff --git a/scumm/script_v7he.cpp b/scumm/script_v7he.cpp
index ac14ae37c0..6e4654b6e3 100644
--- a/scumm/script_v7he.cpp
+++ b/scumm/script_v7he.cpp
@@ -888,44 +888,32 @@ void ScummEngine_v70he::o70_concatString() {
}
void ScummEngine_v70he::o70_compareString() {
- byte *addr, *addr2;
- int i = 0;
-
- int id = pop();
- int id2 = pop();
-
- addr = getStringAddress(id);
- if (!addr)
- error("o70_compareString: Reference to zeroed array pointer (%d)", id);
+ int result;
- addr2 = getStringAddress(id2);
- if (!addr2)
- error("o70_compareString: Reference to zeroed array pointer (%d)", id);
+ int array1 = pop();
+ int array2 = pop();
- while(1) {
- if (*addr != *addr2)
- break;
- if (*addr2 == 0) {
- push(0);
- return;
- }
+ byte *string1 = getStringAddress(array1);
+ if (!string1)
+ error("o70_compareString: Reference to zeroed array pointer (%d)", array1);
- addr++;
- addr2++;
+ byte *string2 = getStringAddress(array2);
+ if (!string2)
+ error("o70_compareString: Reference to zeroed array pointer (%d)", array2);
- if (*addr != *addr2)
- break;
- if (*addr2 == 0) {
+ while (*string1 == *string2) {
+ if (*string2 == 0) {
push(0);
return;
}
- addr++;
- addr2++;
+ string1++;
+ string2++;
}
- push (i);
- debug(1,"o70_compareString (%d, %d, %d)", id, id2, i);
+ result = (*string1 > *string2) ? -1 : 1;
+ push(result);
+ debug(1,"o70_compareString (%d, %d, %d)", array1, array2, result);
}
void ScummEngine_v70he::o70_readINI() {