mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-25 13:42:37 +00:00
cleanup
svn-id: r13441
This commit is contained in:
parent
67c6df86d4
commit
15aa7c3343
@ -858,18 +858,19 @@ void ScummEngine::playSpeech(const byte *ptr) {
|
|||||||
|
|
||||||
void ScummEngine::translateText(const byte *text, byte *trans_buff) {
|
void ScummEngine::translateText(const byte *text, byte *trans_buff) {
|
||||||
LangIndexNode target;
|
LangIndexNode target;
|
||||||
|
LangIndexNode *found = NULL;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (_version >= 7 && text[0] == '/') {
|
if (_version >= 7 && text[0] == '/') {
|
||||||
// copy name from text /..../
|
// Extract the string tag from the text: /..../
|
||||||
for (i = 0; (i < 12) && (text[i + 1] != '/'); i++)
|
for (i = 0; (i < 12) && (text[i + 1] != '/'); i++)
|
||||||
_lastStringTag[i] = target.tag[i] = toupper(text[i + 1]);
|
_lastStringTag[i] = target.tag[i] = toupper(text[i + 1]);
|
||||||
_lastStringTag[i] = target.tag[i] = 0;
|
_lastStringTag[i] = target.tag[i] = 0;
|
||||||
text += i + 2;
|
text += i + 2;
|
||||||
|
|
||||||
|
// If a language file was loaded, try to find a translated version
|
||||||
|
// by doing a lookup on the string tag.
|
||||||
if (_existLanguageFile) {
|
if (_existLanguageFile) {
|
||||||
LangIndexNode *found = NULL;
|
|
||||||
|
|
||||||
// HACK: These are used for the object line when
|
// HACK: These are used for the object line when
|
||||||
// using one object on another. I don't know if the
|
// using one object on another. I don't know if the
|
||||||
// text in the language file is a placeholder or if
|
// text in the language file is a placeholder or if
|
||||||
@ -879,6 +880,9 @@ void ScummEngine::translateText(const byte *text, byte *trans_buff) {
|
|||||||
|
|
||||||
if (strcmp(target.tag, "PU_M001") != 0 && strcmp(target.tag, "PU_M002") != 0)
|
if (strcmp(target.tag, "PU_M001") != 0 && strcmp(target.tag, "PU_M002") != 0)
|
||||||
found = (LangIndexNode *)bsearch(&target, _languageIndex, _languageIndexSize, sizeof(LangIndexNode), indexCompare);
|
found = (LangIndexNode *)bsearch(&target, _languageIndex, _languageIndexSize, sizeof(LangIndexNode), indexCompare);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (found != NULL) {
|
if (found != NULL) {
|
||||||
strcpy((char *)trans_buff, _languageBuffer + found->offset);
|
strcpy((char *)trans_buff, _languageBuffer + found->offset);
|
||||||
|
|
||||||
@ -889,13 +893,13 @@ void ScummEngine::translateText(const byte *text, byte *trans_buff) {
|
|||||||
char *dst = (char *)trans_buff;
|
char *dst = (char *)trans_buff;
|
||||||
|
|
||||||
while ((dst = strstr(dst, "%___"))) {
|
while ((dst = strstr(dst, "%___"))) {
|
||||||
// Search for a special code in the message. They have
|
// Search for a special code in the message.
|
||||||
// the form: 255-byte OP-byte ARG-int16
|
|
||||||
while (*src && *src != 0xFF) {
|
while (*src && *src != 0xFF) {
|
||||||
src++;
|
src++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Replace the %___ by the special code
|
// Replace the %___ by the special code. Luckily, we can do
|
||||||
|
// that in-place.
|
||||||
if (*src == 0xFF) {
|
if (*src == 0xFF) {
|
||||||
memcpy(dst, src, 4);
|
memcpy(dst, src, 4);
|
||||||
src += 4;
|
src += 4;
|
||||||
@ -904,14 +908,10 @@ void ScummEngine::translateText(const byte *text, byte *trans_buff) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Default: just copy the string
|
// Default: just copy the string
|
||||||
memcpy(trans_buff, text, resStrLen(text) + 1);
|
memcpy(trans_buff, text, resStrLen(text) + 1);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} // End of namespace Scumm
|
} // End of namespace Scumm
|
||||||
|
Loading…
x
Reference in New Issue
Block a user