aboutsummaryrefslogtreecommitdiff
path: root/engines/glk
diff options
context:
space:
mode:
authorPaul Gilbert2019-11-02 22:02:45 -0700
committerPaul Gilbert2019-11-11 18:20:30 -0800
commitc570d6f4b29e62f6177bf3c046d0e5761c57b5cc (patch)
treeba2641875eb1cc44f51d6c340e5f78008c7f28a3 /engines/glk
parenta3c646133f9c173b23ff775e03563e337be1cdaf (diff)
downloadscummvm-rg350-c570d6f4b29e62f6177bf3c046d0e5761c57b5cc.tar.gz
scummvm-rg350-c570d6f4b29e62f6177bf3c046d0e5761c57b5cc.tar.bz2
scummvm-rg350-c570d6f4b29e62f6177bf3c046d0e5761c57b5cc.zip
GLK: ARCHETYPE: Fix array indexing to match original's 1 based
Diffstat (limited to 'engines/glk')
-rw-r--r--engines/glk/archetype/archetype.cpp2
-rw-r--r--engines/glk/archetype/array.cpp6
-rw-r--r--engines/glk/archetype/interpreter.cpp4
-rw-r--r--engines/glk/archetype/wrap.cpp2
4 files changed, 7 insertions, 7 deletions
diff --git a/engines/glk/archetype/archetype.cpp b/engines/glk/archetype/archetype.cpp
index 78ba906d3c..4f388da521 100644
--- a/engines/glk/archetype/archetype.cpp
+++ b/engines/glk/archetype/archetype.cpp
@@ -274,7 +274,7 @@ bool Archetype::send_message(int transport, int message_sent, int recipient,
void *p;
ContextType c;
- if (message_sent == -1) {
+ if (message_sent == 0) {
cleanup(result);
return false;
}
diff --git a/engines/glk/archetype/array.cpp b/engines/glk/archetype/array.cpp
index b816306fc3..79a486faf1 100644
--- a/engines/glk/archetype/array.cpp
+++ b/engines/glk/archetype/array.cpp
@@ -38,15 +38,15 @@ void append_to_xarray(XArrayType &the_xarray, void *element) {
}
bool access_xarray(XArrayType &the_xarray, int index, void *&result, AccessType direction) {
- if (index < 0 || index >= (int)the_xarray.size())
+ if (index < 1 || index > (int)the_xarray.size())
return false;
switch (direction) {
case PEEK_ACCESS:
- result = the_xarray[index];
+ result = the_xarray[index - 1];
break;
case POKE_ACCESS:
- the_xarray[index] = result;
+ the_xarray[index - 1] = result;
break;
}
diff --git a/engines/glk/archetype/interpreter.cpp b/engines/glk/archetype/interpreter.cpp
index 21f732b827..3beca744a5 100644
--- a/engines/glk/archetype/interpreter.cpp
+++ b/engines/glk/archetype/interpreter.cpp
@@ -43,14 +43,14 @@ StringPtr MakeNewDynStr(const String &s) {
int find_message(const String &message) {
void *p;
- for (uint i = 0; i < g_vm->Vocabulary.size(); ++i) {
+ for (uint i = 1; i <= g_vm->Vocabulary.size(); ++i) {
if (!index_xarray(g_vm->Vocabulary, i, p))
g_vm->writeln("Internal error - cannot index element %d of Vocabulary", i);
else if (message == *((StringPtr)p))
return i;
}
- return -1;
+ return 0;
}
bool convert_to(AclType target_type, ResultType &the_scalar) {
diff --git a/engines/glk/archetype/wrap.cpp b/engines/glk/archetype/wrap.cpp
index 6ef961f0d3..44fddb864b 100644
--- a/engines/glk/archetype/wrap.cpp
+++ b/engines/glk/archetype/wrap.cpp
@@ -72,7 +72,7 @@ void wrapout(const String &str, bool terminate) {
const char CHARS[7] = { '.', ',', ':', ';', ')', '-', '"' };
for (int i = 0; i < 7; ++i) {
- if (s[0] == CHARS[i]) {
+ if (!s.empty() && s[0] == CHARS[i]) {
maxchars += SAFETY_MARGIN;
break;
}