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 /scumm/string.cpp | |
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
Diffstat (limited to 'scumm/string.cpp')
-rw-r--r-- | scumm/string.cpp | 64 |
1 files changed, 24 insertions, 40 deletions
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; |