diff options
-rw-r--r-- | scumm/script_v6.cpp | 32 | ||||
-rw-r--r-- | scumm/string.cpp | 42 |
2 files changed, 45 insertions, 29 deletions
diff --git a/scumm/script_v6.cpp b/scumm/script_v6.cpp index 6ab342a4f3..6c9156e1b5 100644 --- a/scumm/script_v6.cpp +++ b/scumm/script_v6.cpp @@ -2479,32 +2479,16 @@ void ScummEngine_v6::o6_kernelSetFunctions() { break; case 16: case 17:{ - const byte *message; - byte buf_input[300], buf_output[300]; - message = buf_input; - addMessageToStack(getStringAddressVar(VAR_STRING2DRAW), buf_input, sizeof(buf_input)); + byte buf_input[300]; + const byte *message = getStringAddressVar(VAR_STRING2DRAW); + if ((_gameId == GID_DIG) && !(_features & GF_DEMO)) { - byte buf_trans[300]; - char *t_ptr = (char *)buf_input; - buf_output[0] = 0; - while (t_ptr != NULL) { - if (*t_ptr == '/') { - translateText((byte *)t_ptr, buf_trans); - // hack - if (strstr((char *)buf_trans, "%___") != 0) { - strcat((char *)buf_output, " "); - } else { - strcat((char *)buf_output, (char *)buf_trans); - } - } - t_ptr = strchr((char *)t_ptr + 1, '/'); - if (t_ptr == NULL) - break; - t_ptr = strchr((char *)t_ptr + 1, '/'); - } - message = buf_output; + translateText(message, _transText); + message = _transText; } - enqueueText(message, args[3], args[4], args[2], args[1], true); + + addMessageToStack(message, buf_input, sizeof(buf_input)); + enqueueText(buf_input, args[3], args[4], args[2], args[1], true); break;} case 20: // it's used for turn on/off 'RadioChatter' effect for voice in the dig, but i's not needed diff --git a/scumm/string.cpp b/scumm/string.cpp index 419e3e0273..d03d554336 100644 --- a/scumm/string.cpp +++ b/scumm/string.cpp @@ -589,8 +589,15 @@ void ScummEngine::addNameToStack(int var) { num = readVar(var); if (num) { const byte *ptr = getObjOrActorName(num); - if (ptr) - addMessageToStack(ptr, 0, 0); + if (ptr) { + if ((_version >= 7) && (ptr[0] == '/')) { + byte buf[128]; + translateText(ptr, buf); + addMessageToStack(buf, 0, 0); + } else { + addMessageToStack(ptr, 0, 0); + } + } } } @@ -613,9 +620,10 @@ void ScummEngine::addStringToStack(int var) { if (var) { ptr = getStringAddress(var); if (ptr) { - if ((_version == 8) && (ptr[0] == '/')) { - translateText(ptr, _transText); - addMessageToStack(_transText, 0, 0); + if ((_version >= 7) && (ptr[0] == '/')) { + byte buf[128]; + translateText(ptr, buf); + addMessageToStack(buf, 0, 0); } else { addMessageToStack(ptr, 0, 0); } @@ -898,6 +906,30 @@ void ScummEngine::translateText(const byte *text, byte *trans_buff) { found = (LangIndexNode *)bsearch(&target, _languageIndex, _languageIndexSize, sizeof(LangIndexNode), indexCompare); if (found != NULL) { strcpy((char *)trans_buff, _languageBuffer + found->offset); + + // FIXME / TODO: Maybe this should be enabled for Full Throttle, too? + if ((_gameId == GID_DIG) && !(_features & GF_DEMO)) { + // Replace any '%___' by the corresponding special codes in the source text + const byte *src = text; + char *dst = (char *)trans_buff; + + while ((dst = strstr(dst, "%___"))) { + // Search for a special code in the message. They have + // the form: 255-byte OP-byte ARG-int16 + while (*src && *src != 0xFF) { + src++; + } + + // Replace the %___ by the special code + if (*src == 0xFF) { + memcpy(dst, src, 4); + src += 4; + dst += 4; + } else + break; + } + } + return; } } |