Attempt to fix houses and spawns save

This commit is contained in:
Allan Ference 2013-08-19 10:38:22 +02:00
parent 05f7f6a4cf
commit 092209c0bb
2 changed files with 11 additions and 6 deletions

View File

@ -119,11 +119,14 @@ void Spawn::addCreature(const Position& placePos, const CreatureTypePtr& cType)
{ {
const Position& centerPos = getCenterPos(); const Position& centerPos = getCenterPos();
int m_radius = getRadius(); int m_radius = getRadius();
if(!isInZone(placePos, centerPos, m_radius)) if(!isInZone(placePos, centerPos, m_radius)) {
stdext::throw_exception(stdext::format("cannot place creature at %s %s %d (increment radius)", g_logger.warning(stdext::format("cannot place creature at %s (spawn's center position: %s, spawn radius: %d) (increment radius)",
stdext::to_string(placePos), stdext::to_string(centerPos), stdext::to_string(placePos), stdext::to_string(centerPos),
m_radius m_radius
)); ));
return;
}
g_map.addThing(cType->cast(), placePos, 4); g_map.addThing(cType->cast(), placePos, 4);
m_creatures.insert(std::make_pair(placePos, cType)); m_creatures.insert(std::make_pair(placePos, cType));
} }
@ -255,8 +258,9 @@ void CreatureManager::saveSpawns(const std::string& fileName)
root->LinkEndChild(elem); root->LinkEndChild(elem);
} }
if(!doc.SaveFile(fileName)) std::string savePath = g_resources.getRealDir(fileName) + "/" + fileName;
stdext::throw_exception(stdext::format("failed to save spawns XML %s: %s", fileName, doc.ErrorDesc())); if(!doc.SaveFile(savePath))
stdext::throw_exception(stdext::format("failed to save spawns XML %s: %s", savePath, doc.ErrorDesc()));
} }
void CreatureManager::loadCreatureBuffer(const std::string& buffer) void CreatureManager::loadCreatureBuffer(const std::string& buffer)

View File

@ -173,8 +173,9 @@ void HouseManager::save(const std::string& fileName)
root->LinkEndChild(elem); root->LinkEndChild(elem);
} }
if(!doc.SaveFile(fileName)) std::string savePath = g_resources.getRealDir(fileName) + "/" + fileName;
stdext::throw_exception(stdext::format("failed to save houses XML %s: %s", fileName, doc.ErrorDesc())); if(!doc.SaveFile(savePath))
stdext::throw_exception(stdext::format("failed to save houses XML %s: %s", savePath, doc.ErrorDesc()));
} }
HouseList HouseManager::filterHouses(uint32 townId) HouseList HouseManager::filterHouses(uint32 townId)