aboutsummaryrefslogtreecommitdiff
path: root/engines/gob
diff options
context:
space:
mode:
Diffstat (limited to 'engines/gob')
-rw-r--r--engines/gob/game_v1.cpp4
-rw-r--r--engines/gob/game_v2.cpp4
-rw-r--r--engines/gob/game_v6.cpp4
-rw-r--r--engines/gob/inter.h2
-rw-r--r--engines/gob/inter_v1.cpp6
-rw-r--r--engines/gob/util.cpp9
-rw-r--r--engines/gob/util.h2
7 files changed, 17 insertions, 14 deletions
diff --git a/engines/gob/game_v1.cpp b/engines/gob/game_v1.cpp
index cf1641928c..7db4f65f2c 100644
--- a/engines/gob/game_v1.cpp
+++ b/engines/gob/game_v1.cpp
@@ -928,7 +928,7 @@ void Game_v1::collisionsBlock(void) {
strncpy0(_tempStr, GET_VARO_STR(_collisionAreas[i].key), 255);
if ((_collisionAreas[i].flags & 0x0F) < 7)
- _vm->_util->prepareStr(_tempStr);
+ _vm->_util->cleanupStr(_tempStr);
int16 pos = 0;
do {
@@ -938,7 +938,7 @@ void Game_v1::collisionsBlock(void) {
str += strlen(str) + 1;
if ((_collisionAreas[i].flags & 0x0F) < 7)
- _vm->_util->prepareStr(_collStr);
+ _vm->_util->cleanupStr(_collStr);
if (strcmp(_tempStr, _collStr) == 0) {
WRITE_VAR(17, VAR(17) + 1);
diff --git a/engines/gob/game_v2.cpp b/engines/gob/game_v2.cpp
index e910b5278e..9d494ad6fe 100644
--- a/engines/gob/game_v2.cpp
+++ b/engines/gob/game_v2.cpp
@@ -935,7 +935,7 @@ void Game_v2::collisionsBlock(void) {
strncpy0(_tempStr, GET_VARO_STR(_collisionAreas[i].key), 255);
if ((_collisionAreas[i].flags & 0x0F) < 7)
- _vm->_util->prepareStr(_tempStr);
+ _vm->_util->cleanupStr(_tempStr);
int16 pos = 0;
do {
@@ -945,7 +945,7 @@ void Game_v2::collisionsBlock(void) {
str += strlen(str) + 1;
if ((_collisionAreas[i].flags & 0x0F) < 7)
- _vm->_util->prepareStr(_collStr);
+ _vm->_util->cleanupStr(_collStr);
if (strcmp(_tempStr, _collStr) == 0) {
WRITE_VAR(17, VAR(17) + 1);
diff --git a/engines/gob/game_v6.cpp b/engines/gob/game_v6.cpp
index dade2adddf..e2c0c52919 100644
--- a/engines/gob/game_v6.cpp
+++ b/engines/gob/game_v6.cpp
@@ -839,7 +839,7 @@ void Game_v6::collisionsBlock(void) {
strncpy0(_tempStr, GET_VARO_STR(_collisionAreas[i].key), 255);
if ((_collisionAreas[i].flags & 0x0F) < 7)
- _vm->_util->prepareStr(_tempStr);
+ _vm->_util->cleanupStr(_tempStr);
int16 pos = 0;
do {
@@ -849,7 +849,7 @@ void Game_v6::collisionsBlock(void) {
str += strlen(str) + 1;
if ((_collisionAreas[i].flags & 0x0F) < 7)
- _vm->_util->prepareStr(_collStr);
+ _vm->_util->cleanupStr(_collStr);
if (strcmp(_tempStr, _collStr) == 0) {
WRITE_VAR(17, VAR(17) + 1);
diff --git a/engines/gob/inter.h b/engines/gob/inter.h
index d4ed2d3240..9d983f4fe7 100644
--- a/engines/gob/inter.h
+++ b/engines/gob/inter.h
@@ -238,7 +238,7 @@ protected:
bool o1_playComposition(OpFuncParams &params);
bool o1_getFreeMem(OpFuncParams &params);
bool o1_checkData(OpFuncParams &params);
- bool o1_prepareStr(OpFuncParams &params);
+ bool o1_cleanupStr(OpFuncParams &params);
bool o1_insertStr(OpFuncParams &params);
bool o1_cutStr(OpFuncParams &params);
bool o1_strstr(OpFuncParams &params);
diff --git a/engines/gob/inter_v1.cpp b/engines/gob/inter_v1.cpp
index 96ecfc6b25..23c9351dd4 100644
--- a/engines/gob/inter_v1.cpp
+++ b/engines/gob/inter_v1.cpp
@@ -147,7 +147,7 @@ void Inter_v1::setupOpcodesFunc() {
OPCODEFUNC(0x3E, o1_getFreeMem);
OPCODEFUNC(0x3F, o1_checkData);
- OPCODEFUNC(0x41, o1_prepareStr);
+ OPCODEFUNC(0x41, o1_cleanupStr);
OPCODEFUNC(0x42, o1_insertStr);
OPCODEFUNC(0x43, o1_cutStr);
@@ -1601,11 +1601,11 @@ bool Inter_v1::o1_checkData(OpFuncParams &params) {
return false;
}
-bool Inter_v1::o1_prepareStr(OpFuncParams &params) {
+bool Inter_v1::o1_cleanupStr(OpFuncParams &params) {
int16 strVar;
strVar = _vm->_game->_script->readVarIndex();
- _vm->_util->prepareStr(GET_VARO_FSTR(strVar));
+ _vm->_util->cleanupStr(GET_VARO_FSTR(strVar));
return false;
}
diff --git a/engines/gob/util.cpp b/engines/gob/util.cpp
index 6c38dcb5a9..4830c4be51 100644
--- a/engines/gob/util.cpp
+++ b/engines/gob/util.cpp
@@ -452,7 +452,7 @@ static const char trStr2[] =
" ";
static const char trStr3[] = " ";
-void Util::prepareStr(char *str) {
+void Util::cleanupStr(char *str) {
char *start, *end;
char buf[300];
@@ -460,17 +460,20 @@ void Util::prepareStr(char *str) {
strcat(buf, trStr2);
strcat(buf, trStr3);
+ // Translating "wrong" characters
for (size_t i = 0; i < strlen(str); i++)
- str[i] = buf[str[i] - 32];
+ str[i] = buf[MIN<int>(str[i] - 32, 32)];
+ // Trim spaces left
while (str[0] == ' ')
cutFromStr(str, 0, 1);
+ // Trim spaces right
while ((strlen(str) > 0) && (str[strlen(str) - 1] == ' '))
cutFromStr(str, strlen(str) - 1, 1);
+ // Merge double spaces
start = strchr(str, ' ');
-
while (start) {
if (start[1] == ' ') {
cutFromStr(str, start - str, 1);
diff --git a/engines/gob/util.h b/engines/gob/util.h
index 2b6ea7fdc3..b0bcf70d0c 100644
--- a/engines/gob/util.h
+++ b/engines/gob/util.h
@@ -92,7 +92,7 @@ public:
static void insertStr(const char *str1, char *str2, int16 pos);
static void cutFromStr(char *str, int16 from, int16 cutlen);
- static void prepareStr(char *str);
+ static void cleanupStr(char *str);
static void replaceChar(char *str, char c1, char c2);
static void listInsertFront(List *list, void *data);