diff options
author | Max Horn | 2003-07-15 21:30:53 +0000 |
---|---|---|
committer | Max Horn | 2003-07-15 21:30:53 +0000 |
commit | c74e2eb4d713c2d6381ca7a15dc0eeb47cf4c935 (patch) | |
tree | 039f482a913c49b0744052d81816562950a1715d | |
parent | 83a3afab42c2fe8fa9bf6c0713cd09302060feb2 (diff) | |
download | scummvm-rg350-c74e2eb4d713c2d6381ca7a15dc0eeb47cf4c935.tar.gz scummvm-rg350-c74e2eb4d713c2d6381ca7a15dc0eeb47cf4c935.tar.bz2 scummvm-rg350-c74e2eb4d713c2d6381ca7a15dc0eeb47cf4c935.zip |
factored out some duplicate code into a new method translateTextAndPlaySpeech; removed some completely useless code (why compute 'pointer' when we then throw away the result?)
svn-id: r9045
-rw-r--r-- | scumm/dialogs.cpp | 2 | ||||
-rw-r--r-- | scumm/script_v6.cpp | 38 | ||||
-rw-r--r-- | scumm/script_v8.cpp | 19 | ||||
-rw-r--r-- | scumm/scumm.h | 1 | ||||
-rw-r--r-- | scumm/string.cpp | 64 | ||||
-rw-r--r-- | scumm/verbs.cpp | 9 |
6 files changed, 30 insertions, 103 deletions
diff --git a/scumm/dialogs.cpp b/scumm/dialogs.cpp index 08a6babf33..5c4901cd00 100644 --- a/scumm/dialogs.cpp +++ b/scumm/dialogs.cpp @@ -194,6 +194,8 @@ const ScummVM::String ScummDialog::queryResString(int stringno) { if (result && *result == '/') { byte tmp[256]; _scumm->translateText(result, tmp); + + // FIXME: AARGH! We shouldn't just strcpy into the data we got from getStringAddress strcpy((char *)result, (char *)tmp); } diff --git a/scumm/script_v6.cpp b/scumm/script_v6.cpp index 4c798b0ee2..a4ef6749b0 100644 --- a/scumm/script_v6.cpp +++ b/scumm/script_v6.cpp @@ -2237,26 +2237,9 @@ void Scumm_v6::o6_printEgo() { void Scumm_v6::o6_talkActor() { _actorToPrintStrFor = pop(); - _messagePtr = _scriptPointer; + _messagePtr = translateTextAndPlaySpeech(_scriptPointer); _scriptPointer += resStrLen(_scriptPointer) + 1; - if ((_gameId == GID_DIG || _gameId == GID_CMI) && (_messagePtr[0] == '/')) { - char pointer[20]; - int i, j; - - translateText(_messagePtr, _transText); - for (i = 0, j = 0; (_messagePtr[i] != '/' || j == 0) && j < 19; i++) { - if (_messagePtr[i] != '/') - pointer[j++] = _messagePtr[i]; - } - pointer[j] = 0; - - // Play speech - _sound->playBundleSound(pointer, &_sound->_talkChannelHandle); - - _messagePtr = _transText; - } - setStringVars(0); actorTalk(); } @@ -3092,26 +3075,9 @@ void Scumm_v6::decodeParseString(int m, int n) { _string[m].no_talk_anim = true; break; case 75: - _messagePtr = _scriptPointer; + _messagePtr = translateTextAndPlaySpeech(_scriptPointer); _scriptPointer += resStrLen(_scriptPointer)+ 1; - if ((_messagePtr[0] == '/') && (_gameId == GID_DIG)) { - char pointer[20]; - int i, j; - - translateText(_messagePtr, _transText); - for (i = 0, j = 0; (_messagePtr[i] != '/' || j == 0) && j < 19; i++) { - if (_messagePtr[i] != '/') - pointer[j++] = _messagePtr[i]; - } - pointer[j] = 0; - - // Play speech - _sound->playBundleSound(pointer, &_sound->_talkChannelHandle); - - _messagePtr = _transText; - } - switch (m) { case 0: actorTalk(); diff --git a/scumm/script_v8.cpp b/scumm/script_v8.cpp index 483adac13b..252e677d10 100644 --- a/scumm/script_v8.cpp +++ b/scumm/script_v8.cpp @@ -499,26 +499,9 @@ void Scumm_v8::decodeParseString(int m, int n) { _string[m].no_talk_anim = true; break; case 0xD1: - _messagePtr = _scriptPointer; + _messagePtr = translateTextAndPlaySpeech(_scriptPointer); _scriptPointer += resStrLen(_scriptPointer)+ 1; - if (_messagePtr[0] == '/') { - char pointer[20]; - int i, j; - - translateText(_messagePtr, _transText); - for (i = 0, j = 0; (_messagePtr[i] != '/' || j == 0) && j < 19; i++) { - if (_messagePtr[i] != '/') - pointer[j++] = _messagePtr[i]; - } - pointer[j] = 0; - - // Play speech - _sound->playBundleSound(pointer, &_sound->_talkChannelHandle); - - _messagePtr = _transText; - } - switch (m) { case 0: actorTalk(); diff --git a/scumm/scumm.h b/scumm/scumm.h index b7c45a72de..07c23e5dae 100644 --- a/scumm/scumm.h +++ b/scumm/scumm.h @@ -1096,6 +1096,7 @@ protected: byte _transText[500]; void loadLanguageBundle(); + const byte *translateTextAndPlaySpeech(const byte *ptr); public: void translateText(const byte *text, byte *trans_buff); // Used by class ScummDialog diff --git a/scumm/string.cpp b/scumm/string.cpp index 4ebe58f127..ebd6baef17 100644 --- a/scumm/string.cpp +++ b/scumm/string.cpp @@ -582,26 +582,9 @@ void Scumm::addVerbToStack(int var) if (num) { for (k = 1; k < _maxVerbs; k++) { if (num == _verbs[k].verbid && !_verbs[k].type && !_verbs[k].saveid) { - byte *ptr = getResourceAddress(rtVerb, k); - if ((_version == 8) && (ptr[0] == '/')) { - char pointer[20]; - int i, j; - - translateText(ptr, _transText); - - for (i = 0, j = 0; (ptr[i] != '/' || j == 0) && j < 19; i++) { - if (ptr[i] != '/') - pointer[j++] = ptr[i]; - } - pointer[j] = 0; - - // Play speech - _sound->playBundleSound(pointer, &_sound->_talkChannelHandle); - - addMessageToStack(_transText); - } else { - addMessageToStack(ptr); - } + const byte *ptr = getResourceAddress(rtVerb, k); + ptr = translateTextAndPlaySpeech(ptr); + addMessageToStack(ptr); break; } } @@ -620,16 +603,7 @@ void Scumm::addNameToStack(int var) ptr = getObjOrActorName(num); if (ptr) { if ((_version == 8) && (ptr[0] == '/')) { - char pointer[20]; - int i, j; - translateText(ptr, _transText); - for (i = 0, j = 0; (ptr[i] != '/' || j == 0) && j < 19; i++) { - if (ptr[i] != '/') - pointer[j++] = ptr[i]; - } - pointer[j] = 0; - addMessageToStack(_transText); } else { addMessageToStack(ptr); @@ -640,7 +614,7 @@ void Scumm::addNameToStack(int var) } void Scumm::addStringToStack(int var) { - byte *ptr; + const byte *ptr; if (_version == 3 || _version >= 6) var = readVar(var); @@ -649,17 +623,7 @@ void Scumm::addStringToStack(int var) { ptr = getStringAddress(var); if (ptr) { if ((_version == 8) && (ptr[0] == '/')) { - char pointer[20]; - int i, j; - translateText(ptr, _transText); - - for (i = 0, j = 0; (ptr[i] != '/' || j == 0) && j < 19; i++) { - if (ptr[i] != '/') - pointer[j++] = ptr[i]; - } - pointer[j] = 0; - addMessageToStack(_transText); } else { addMessageToStack(ptr); @@ -908,6 +872,26 @@ void Scumm::loadLanguageBundle() { qsort(_languageIndex, _languageIndexSize, sizeof(LangIndexNode), indexCompare); } +const byte *Scumm::translateTextAndPlaySpeech(const byte *ptr) { + if ((_gameId == GID_DIG || _gameId == GID_CMI) && (ptr[0] == '/')) { + char pointer[20]; + int i, j; + + translateText(ptr, _transText); + for (i = 0, j = 0; (ptr[i] != '/' || j == 0) && j < 19; i++) { + if (ptr[i] != '/') + pointer[j++] = ptr[i]; + } + pointer[j] = 0; + + // Play speech + _sound->playBundleSound(pointer, &_sound->_talkChannelHandle); + + ptr = _transText; + } + return ptr; +} + void Scumm::translateText(const byte *text, byte *trans_buff) { int l; diff --git a/scumm/verbs.cpp b/scumm/verbs.cpp index 52116a42ca..d8d847cc56 100644 --- a/scumm/verbs.cpp +++ b/scumm/verbs.cpp @@ -437,16 +437,7 @@ void Scumm::drawVerb(int verb, int mode) { assert(_messagePtr); if ((_version == 8) && (_messagePtr[0] == '/')) { - char pointer[20]; - int i, j; - translateText(_messagePtr, _transText); - - for (i = 0, j = 0; (_messagePtr[i] != '/' || j == 0) && j < 19; i++) { - if (_messagePtr[i] != '/') - pointer[j++] = _messagePtr[i]; - } - pointer[j] = 0; _messagePtr = _transText; } |