diff options
author | Thierry Crozat | 2010-11-13 23:27:13 +0000 |
---|---|---|
committer | Thierry Crozat | 2010-11-13 23:27:13 +0000 |
commit | 4e357549d57c1d820e320461450d52e36d10f477 (patch) | |
tree | 04874813de72b155b3a5650e1ee3a944a5d6112f /common | |
parent | f4af4d2366fe0c3994da5186d5d232b353fd1b25 (diff) | |
download | scummvm-rg350-4e357549d57c1d820e320461450d52e36d10f477.tar.gz scummvm-rg350-4e357549d57c1d820e320461450d52e36d10f477.tar.bz2 scummvm-rg350-4e357549d57c1d820e320461450d52e36d10f477.zip |
COMMON: Fix TranslationManager
Revision 54206 broke translations support because it uncovered a bug in
the TranslationManager when reading the translations.dat file. In that file
all the stored string lengths include the terminating 0 but Common::String
expect a length without the terminating 0. Therefore all String objects
created from reading the translations.dat file had an incorrect size. This
caused the font file names to be wrong after adding the charset.
svn-id: r54235
Diffstat (limited to 'common')
-rw-r--r-- | common/translation.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/common/translation.cpp b/common/translation.cpp index 9e81816234..70dac7a318 100644 --- a/common/translation.cpp +++ b/common/translation.cpp @@ -258,7 +258,7 @@ String TranslationManager::getLangById(int id) const { return "C"; default: if (id >= 0 && id - 1 < (int)_langs.size()) - return _langs[id - 1].c_str(); + return _langs[id - 1]; } // In case an invalid ID was specified, we will output a warning @@ -336,10 +336,10 @@ void TranslationManager::loadTranslationsInfoDat() { for (int i = 0; i < nbTranslations; ++i) { len = in.readUint16BE(); in.read(buf, len); - _langs[i] = String(buf, len); + _langs[i] = String(buf, len-1); len = in.readUint16BE(); in.read(buf, len); - _langNames[i] = String(buf, len); + _langNames[i] = String(buf, len-1); } // Read messages @@ -348,7 +348,7 @@ void TranslationManager::loadTranslationsInfoDat() { for (int i = 0; i < numMessages; ++i) { len = in.readUint16BE(); in.read(buf, len); - _messageIds[i] = String(buf, len); + _messageIds[i] = String(buf, len-1); } } @@ -396,18 +396,18 @@ void TranslationManager::loadLanguageDat(int index) { // Read charset len = in.readUint16BE(); in.read(buf, len); - _currentCharset = String(buf, len); + _currentCharset = String(buf, len-1); // Read messages for (int i = 0; i < nbMessages; ++i) { _currentTranslationMessages[i].msgid = in.readUint16BE(); len = in.readUint16BE(); in.read(buf, len); - _currentTranslationMessages[i].msgstr = String(buf, len); + _currentTranslationMessages[i].msgstr = String(buf, len-1); len = in.readUint16BE(); if (len > 0) { in.read(buf, len); - _currentTranslationMessages[i].msgctxt = String(buf, len); + _currentTranslationMessages[i].msgctxt = String(buf, len-1); } } } |