Skip to content

Commit 2656646

Browse files
authored
Fix incorrect rendering with tilemaps with csv data on windows (#20483)
Each tilemap row would be shifted to the right a certain number of tiles. This is caused by the carriage return in windows being '\r\n' and the way each csv line is parsed. The '\r' at the beginning of each line would be parsed as a tile id. On windows we must remove all 'r' from the csv string.
1 parent 63d3408 commit 2656646

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

cocos/2d/CCTMXXMLParser.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -726,6 +726,12 @@ void TMXMapInfo::endElement(void* /*ctx*/, const char *name)
726726
tmxMapInfo->setStoringCharacters(false);
727727
std::string currentString = tmxMapInfo->getCurrentString();
728728

729+
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
730+
// Fix bug when tilemap data is in csv format.
731+
// We have to remove all '\r' from the string
732+
currentString.erase(std::remove(currentString.begin(), currentString.end(), '\r'), currentString.end());
733+
#endif
734+
729735
vector<string> gidTokens;
730736
istringstream filestr(currentString);
731737
string sRow;

0 commit comments

Comments
 (0)