fix load text bug

master
Eduardo Bart 13 years ago
parent b2c61760e5
commit b80dc4d6e0

@ -58,12 +58,11 @@ bool ConfigManager::load(const std::string& fileName)
YAML::Node doc; YAML::Node doc;
parser.GetNextDocument(doc); parser.GetNextDocument(doc);
for(YAML::Iterator it = doc.begin(); it != doc.end(); it++) { for(YAML::Iterator it = doc.begin(); it != doc.end(); ++it) {
std::string key, value; std::string key, value;
it.first() >> key; it.first() >> key;
it.second() >> value; it.second() >> value;
m_confsMap[key] = value; m_confsMap[key] = value;
dump() << key << value;
} }
} catch (YAML::ParserException& e) { } catch (YAML::ParserException& e) {
error("Malformed configuration file!"); error("Malformed configuration file!");

@ -81,8 +81,9 @@ unsigned char *ResourceManager::loadFile(const std::string& fileName, unsigned i
} }
*fileSize = PHYSFS_fileLength(file); *fileSize = PHYSFS_fileLength(file);
unsigned char *buffer = new unsigned char[*fileSize]; unsigned char *buffer = new unsigned char[*fileSize + 1];
PHYSFS_read(file, (void*)buffer, 1, *fileSize); PHYSFS_read(file, (void*)buffer, 1, *fileSize);
buffer[*fileSize] = 0;
PHYSFS_close(file); PHYSFS_close(file);
return buffer; return buffer;
} }

Loading…
Cancel
Save