diff --git a/source/simulation/EntityManager.cpp b/source/simulation/EntityManager.cpp index 77613b73d7..4a206884dd 100644 --- a/source/simulation/EntityManager.cpp +++ b/source/simulation/EntityManager.cpp @@ -91,6 +91,8 @@ void CEntityManager::DeleteAll() void CEntityManager::updateObstacle( CEntity* tempHandle ) { + (void)tempHandle; + #ifdef USE_DCDT if(g_Pathfinder.dcdtInitialized) { diff --git a/source/tools/atlas/AtlasObject/AtlasObjectXML.cpp b/source/tools/atlas/AtlasObject/AtlasObjectXML.cpp index e1ce139c48..f039a49038 100644 --- a/source/tools/atlas/AtlasObject/AtlasObjectXML.cpp +++ b/source/tools/atlas/AtlasObject/AtlasObjectXML.cpp @@ -45,7 +45,7 @@ public: case 4: *--target = ((ch | 0x80) & 0xBF); ch >>= 6; case 3: *--target = ((ch | 0x80) & 0xBF); ch >>= 6; case 2: *--target = ((ch | 0x80) & 0xBF); ch >>= 6; - case 1: *--target = (ch | firstByteMark[bytesToWrite]); + case 1: *--target = (char)(ch | firstByteMark[bytesToWrite]); } data += std::string(buf, bytesToWrite); } @@ -66,7 +66,7 @@ std::wstring fromXmlChar(const xmlChar* str) const xmlChar* sourceEnd = str + strlen((const char*)str); while (source < sourceEnd) { - wchar_t ch = 0; + unsigned long ch = 0; int extraBytesToRead = trailingBytesForUTF8[*source]; assert(source + extraBytesToRead < sourceEnd); switch (extraBytesToRead) @@ -79,8 +79,11 @@ std::wstring fromXmlChar(const xmlChar* str) case 0: ch += *source++; } ch -= offsetsFromUTF8[extraBytesToRead]; + // Make sure it fits in a 16-bit wchar_t + if (ch > 0xFFFF) + ch = 0xFFFD; - result += ch; + result += (wchar_t)ch; } return result; } diff --git a/source/tools/atlas/AtlasObject/tests/test_AtlasObjectXML.h b/source/tools/atlas/AtlasObject/tests/test_AtlasObjectXML.h index 9f11c4636f..7ddcf36102 100644 --- a/source/tools/atlas/AtlasObject/tests/test_AtlasObjectXML.h +++ b/source/tools/atlas/AtlasObject/tests/test_AtlasObjectXML.h @@ -119,6 +119,15 @@ public: ); } + void test_parse_unicode_nonbmp() + { + try_parse_save( + "�𐀀􏿿", + "\n" + "\xEF\xBF\xBC\xEF\xBF\xBD\xEF\xBF\xBD\xEF\xBF\xBD\n" + ); + } + void test_parse_iso88591() { try_parse_save(