mirror of https://github.com/axmolengine/axmol.git
[BUG] Fix TMX Tiled Map `CSV`, `BASE64`, & `ZLIB` incorrect parsing (#1131)
* Fix TMX Tiled Map `CSV`, `BASE64`, & `ZLIB` incorrect parsing
* Revert "Fix TMX Tiled Map `CSV`, `BASE64`, & `ZLIB` incorrect parsing"
This reverts commit 3088123a20
.
* Use `std::regex_replace` instead
* Avoid copying strings
* Update CCTMXXMLParser.cpp
This commit is contained in:
parent
4c90ac17a4
commit
eae2ffabcb
|
@ -30,6 +30,7 @@ THE SOFTWARE.
|
||||||
#include "2d/CCTMXXMLParser.h"
|
#include "2d/CCTMXXMLParser.h"
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
#include <regex>
|
||||||
// #include "2d/CCTMXTiledMap.h"
|
// #include "2d/CCTMXTiledMap.h"
|
||||||
#include "base/ZipUtils.h"
|
#include "base/ZipUtils.h"
|
||||||
#include "base/CCDirector.h"
|
#include "base/CCDirector.h"
|
||||||
|
@ -687,8 +688,8 @@ void TMXMapInfo::endElement(void* /*ctx*/, const char* name)
|
||||||
tmxMapInfo->setStoringCharacters(false);
|
tmxMapInfo->setStoringCharacters(false);
|
||||||
|
|
||||||
TMXLayerInfo* layer = tmxMapInfo->getLayers().back();
|
TMXLayerInfo* layer = tmxMapInfo->getLayers().back();
|
||||||
|
|
||||||
auto currentString = tmxMapInfo->getCurrentString();
|
auto currentString = tmxMapInfo->getCurrentString();
|
||||||
|
|
||||||
unsigned char* buffer;
|
unsigned char* buffer;
|
||||||
auto len = utils::base64Decode((unsigned char*)currentString.data(), (unsigned int)currentString.length(),
|
auto len = utils::base64Decode((unsigned char*)currentString.data(), (unsigned int)currentString.length(),
|
||||||
&buffer);
|
&buffer);
|
||||||
|
@ -808,6 +809,7 @@ void TMXMapInfo::textHandler(void* /*ctx*/, const char* ch, size_t len)
|
||||||
{
|
{
|
||||||
TMXMapInfo* tmxMapInfo = this;
|
TMXMapInfo* tmxMapInfo = this;
|
||||||
std::string text(ch, 0, len);
|
std::string text(ch, 0, len);
|
||||||
|
text = std::regex_replace(text, std::regex("[\n\r ]"), "");
|
||||||
|
|
||||||
if (tmxMapInfo->isStoringCharacters())
|
if (tmxMapInfo->isStoringCharacters())
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue