Browse Source

Fixed encoding of strings in h3m maps

Ivan Savenko 2 years ago
parent
commit
f653d22f99
3 changed files with 9 additions and 1 deletions
  1. 2 0
      client/renderSDL/CBitmapFont.h
  2. 4 1
      lib/mapping/MapFormatH3M.cpp
  3. 3 0
      lib/mapping/MapFormatH3M.h

+ 2 - 0
client/renderSDL/CBitmapFont.h

@@ -11,7 +11,9 @@
 
 #include "../render/IFont.h"
 
+VCMI_LIB_NAMESPACE_BEGIN
 class ResourceID;
+VCMI_LIB_NAMESPACE_END
 
 class CBitmapFont : public IFont
 {

+ 4 - 1
lib/mapping/MapFormatH3M.cpp

@@ -25,6 +25,7 @@
 #include "../mapObjects/CObjectClassesHandler.h"
 #include "../mapObjects/MapObjects.h"
 #include "../VCMI_Lib.h"
+#include "../TextOperations.h"
 #include "../TerrainHandler.h"
 #include "../RoadHandler.h"
 #include "../RiverHandler.h"
@@ -38,6 +39,8 @@ CMapLoaderH3M::CMapLoaderH3M(const std::string & mapName, const std::string & en
 	: map(nullptr)
 	, reader(new CBinaryReader(stream))
 	, inputStream(stream)
+	, mapName(mapName)
+	, fileEncoding(encodingName)
 {
 }
 
@@ -2242,7 +2245,7 @@ int3 CMapLoaderH3M::readInt3()
 
 std::string CMapLoaderH3M::readLocalizedString()
 {
-	return reader->readBaseString();
+	return TextOperations::toUnicode(reader->readBaseString(), fileEncoding);
 }
 
 void CMapLoaderH3M::afterRead()

+ 3 - 0
lib/mapping/MapFormatH3M.h

@@ -256,6 +256,9 @@ private:
 	std::unique_ptr<CBinaryReader> reader;
 	CInputStream * inputStream;
 
+	std::string mapName;
+	std::string fileEncoding;
+
 };
 
 VCMI_LIB_NAMESPACE_END