|
|
|
@ -34,6 +34,7 @@
|
|
|
|
|
|
|
|
|
|
void Map::loadOtbm(const std::string& fileName)
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
FileStreamPtr fin = g_resources.openFile(fileName);
|
|
|
|
|
if(!fin)
|
|
|
|
|
stdext::throw_exception(stdext::format("Unable to load map '%s'", fileName));
|
|
|
|
@ -195,10 +196,8 @@ void Map::loadOtbm(const std::string& fileName)
|
|
|
|
|
townCoords.y = nodeTown->getU16();
|
|
|
|
|
townCoords.z = nodeTown->getU8();
|
|
|
|
|
|
|
|
|
|
if(!(town = g_towns.getTown(townId))) {
|
|
|
|
|
town = TownPtr(new Town(townId, townName, townCoords));
|
|
|
|
|
g_towns.addTown(town);
|
|
|
|
|
}
|
|
|
|
|
if(!(town = g_towns.getTown(townId)))
|
|
|
|
|
g_towns.addTown(TownPtr(new Town(townId, townName, townCoords)));
|
|
|
|
|
}
|
|
|
|
|
} else if(mapDataType == OTBM_WAYPOINTS && headerVersion > 1) {
|
|
|
|
|
for(const BinaryTreePtr &nodeWaypoint : nodeMapData->getChildren()) {
|
|
|
|
@ -220,10 +219,14 @@ void Map::loadOtbm(const std::string& fileName)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fin->close();
|
|
|
|
|
} catch(std::exception& e) {
|
|
|
|
|
g_logger.error(stdext::format("Failed to load '%s': %s", fileName, e.what()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Map::saveOtbm(const std::string& fileName)
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
FileStreamPtr fin = g_resources.createFile(fileName);
|
|
|
|
|
if(!fin)
|
|
|
|
|
stdext::throw_exception(stdext::format("failed to open file '%s' for write", fileName));
|
|
|
|
@ -391,6 +394,9 @@ void Map::saveOtbm(const std::string& fileName)
|
|
|
|
|
|
|
|
|
|
fin->flush();
|
|
|
|
|
fin->close();
|
|
|
|
|
} catch(std::exception& e) {
|
|
|
|
|
g_logger.error(stdext::format("Failed to save '%s': %s", fileName, e.what()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool Map::loadOtcm(const std::string& fileName)
|
|
|
|
@ -538,3 +544,5 @@ void Map::saveOtcm(const std::string& fileName)
|
|
|
|
|
g_logger.error(stdext::format("failed to save OTCM map: %s", e.what()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* vim: set ts=4 sw=4 et: */
|
|
|
|
|