mapio: fix load on new maps

master
Ahmed Samy 11 years ago
parent 772ec208c0
commit 9154c0a678

@ -35,16 +35,20 @@
void Map::loadOtbm(const std::string& fileName)
{
try {
if(!g_things.isOtbLoaded())
stdext::throw_exception("OTB isn't loaded yet to load a map.");
FileStreamPtr fin = g_resources.openFile(fileName);
if(!fin)
stdext::throw_exception(stdext::format("Unable to load map '%s'", fileName));
fin->cache();
if(!g_things.isOtbLoaded())
stdext::throw_exception("OTB isn't loaded yet to load a map.");
if(fin->getU32())
stdext::throw_exception("Unknown file version detected");
char identifier[4];
if(fin->read(identifier, 1, 4) < 4)
stdext::throw_exception("Could not read file identifier");
if(memcmp(identifier, "OTBM", 4) != 0 && memcmp(identifier, "\0\0\0\0", 4) != 0)
stdext::throw_exception(stdext::format("Invalid file identifier detected: %s", identifier));
BinaryTreePtr root = fin->getBinaryTree();
if(root->getU8())

Loading…
Cancel
Save