diff --git a/desktop_version/src/FileSystemUtils.cpp b/desktop_version/src/FileSystemUtils.cpp index f0fa1ce4..2a8f7f22 100644 --- a/desktop_version/src/FileSystemUtils.cpp +++ b/desktop_version/src/FileSystemUtils.cpp @@ -139,7 +139,7 @@ void FILESYSTEM_loadFileToMemory(const char *name, unsigned char **mem, if (addnull) { *mem = (unsigned char *) malloc(length + 1); - mem[length] = 0; + (*mem)[length] = 0; } else { diff --git a/desktop_version/src/editor.cpp b/desktop_version/src/editor.cpp index edcb3404..cd0b0c94 100644 --- a/desktop_version/src/editor.cpp +++ b/desktop_version/src/editor.cpp @@ -116,19 +116,13 @@ void editorclass::getDirectoryData() } bool editorclass::getLevelMetaData(std::string& _path, LevelMetaData& _data ) { - unsigned char *mem = NULL; - FILESYSTEM_loadFileToMemory(_path.c_str(), &mem, NULL); - - if (mem == NULL) + TiXmlDocument doc; + if (!FILESYSTEM_loadTiXmlDocument(_path.c_str(), &doc)) { printf("Level %s not found :(\n", _path.c_str()); return false; } - TiXmlDocument doc; - doc.Parse((const char*) mem); - FILESYSTEM_freeMemory(&mem); - TiXmlHandle hDoc(&doc); TiXmlElement* pElem; TiXmlHandle hRoot(0); @@ -1712,23 +1706,19 @@ void editorclass::load(std::string& _path) { reset(); - unsigned char *mem = NULL; static const char *levelDir = "levels/"; if (_path.compare(0, strlen(levelDir), levelDir) != 0) { _path = levelDir + _path; } - FILESYSTEM_loadFileToMemory(_path.c_str(), &mem, NULL); - if (mem == NULL) + TiXmlDocument doc; + if (!FILESYSTEM_loadTiXmlDocument(_path.c_str(), &doc)) { printf("No level %s to load :(\n", _path.c_str()); return; } - TiXmlDocument doc; - doc.Parse((const char*) mem); - FILESYSTEM_freeMemory(&mem); TiXmlHandle hDoc(&doc); TiXmlElement* pElem;