[Scummvm-cvs-logs] SF.net SVN: scummvm:[54235] scummvm/trunk/common/translation.cpp

criezy at users.sourceforge.net criezy at users.sourceforge.net
Sun Nov 14 00:27:14 CET 2010


Revision: 54235
          http://scummvm.svn.sourceforge.net/scummvm/?rev=54235&view=rev
Author:   criezy
Date:     2010-11-13 23:27:13 +0000 (Sat, 13 Nov 2010)

Log Message:
-----------
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.

Revision Links:
--------------
    http://scummvm.svn.sourceforge.net/scummvm/?rev=54206&view=rev

Modified Paths:
--------------
    scummvm/trunk/common/translation.cpp

Modified: scummvm/trunk/common/translation.cpp
===================================================================
--- scummvm/trunk/common/translation.cpp	2010-11-13 20:16:44 UTC (rev 54234)
+++ scummvm/trunk/common/translation.cpp	2010-11-13 23:27:13 UTC (rev 54235)
@@ -258,7 +258,7 @@
 		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 @@
 	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 @@
 	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 @@
 	// 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);
 		}
 	}
 }


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list