Removed Position dependencies inside the framework

This commit is contained in:
BeniS
2013-03-02 18:33:14 +13:00
parent 32df317163
commit 3ca85cbe87
8 changed files with 42 additions and 34 deletions

View File

@@ -49,7 +49,11 @@ void CreatureManager::terminate()
void Spawn::load(TiXmlElement* node)
{
Position centerPos = node->readPos("center");
Position centerPos;
centerPos.x = node->readType<uint16>("centerx");
centerPos.y = node->readType<uint16>("centery");
centerPos.z = node->readType<uint8>("centerz");
setCenterPos(centerPos);
setRadius(node->readType<int32>("radius"));

View File

@@ -65,7 +65,12 @@ void House::load(const TiXmlElement *elem)
setSize(elem->readType<uint32>("size"));
setTownId(elem->readType<uint32>("townid"));
m_isGuildHall = elem->readType<bool>("guildhall");
setEntry(elem->readPos("entry"));
Position entryPos;
entryPos.x = elem->readType<uint16>("entryx");
entryPos.y = elem->readType<uint16>("entryy");
entryPos.z = elem->readType<uint8>("entryz");
setEntry(entryPos);
}
void House::save(TiXmlElement*& elem)

View File

@@ -179,7 +179,7 @@ void Item::serializeItem(const OutputBinaryTreePtr& out)
Position dest = m_attribs.get<Position>(ATTR_TELE_DEST);
if(dest.isValid()) {
out->addU8(ATTR_TELE_DEST);
out->addPos(dest);
out->addPos(dest.x, dest.y, dest.z);
}
if(isDepot()) {

View File

@@ -94,7 +94,11 @@ void Map::loadOtbm(const std::string& fileName, const UIWidgetPtr& pbar)
for(const BinaryTreePtr& nodeMapData : node->getChildren()) {
uint8 mapDataType = nodeMapData->getU8();
if(mapDataType == OTBM_TILE_AREA) {
Position basePos = nodeMapData->getPosition();
Position basePos;
basePos.x = nodeMapData->getU16();
basePos.y = nodeMapData->getU16();
basePos.z = nodeMapData->getU8();
for(const BinaryTreePtr &nodeTile : nodeMapData->getChildren()) {
uint8 type = nodeTile->getU8();
@@ -187,7 +191,12 @@ void Map::loadOtbm(const std::string& fileName, const UIWidgetPtr& pbar)
uint32 townId = nodeTown->getU32();
std::string townName = nodeTown->getString();
Position townCoords = nodeTown->getPosition();
Position townCoords;
townCoords.x = nodeTown->getU16();
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);
@@ -199,7 +208,12 @@ void Map::loadOtbm(const std::string& fileName, const UIWidgetPtr& pbar)
stdext::throw_exception("invalid waypoint node.");
std::string name = nodeWaypoint->getString();
Position waypointPos = nodeWaypoint->getPosition();
Position waypointPos;
waypointPos.x = nodeWaypoint->getU16();
waypointPos.y = nodeWaypoint->getU16();
waypointPos.z = nodeWaypoint->getU8();
if(waypointPos.isValid() && !name.empty() && m_waypoints.find(waypointPos) == m_waypoints.end())
m_waypoints.insert(std::make_pair(waypointPos, name));
}
@@ -312,7 +326,7 @@ void Map::saveOtbm(const std::string& fileName, const UIWidgetPtr&/* pbar*/)
px = pos.x & 0xFF00;
py = pos.y & 0xFF00;
pz = pos.z;
root->addPos(Position(px, py, pz));
root->addPos(px, py, pz);
}
root->startNode(tile->isHouseTile() ? OTBM_HOUSETILE : OTBM_TILE);
@@ -353,7 +367,9 @@ void Map::saveOtbm(const std::string& fileName, const UIWidgetPtr&/* pbar*/)
for(const TownPtr& town : g_towns.getTowns()) {
root->addU32(town->getId());
root->addString(town->getName());
root->addPos(town->getPos());
Position townPos = town->getPos();
root->addPos(townPos.x, townPos.y, townPos.z);
}
root->endNode();
@@ -361,7 +377,9 @@ void Map::saveOtbm(const std::string& fileName, const UIWidgetPtr&/* pbar*/)
root->startNode(OTBM_WAYPOINTS);
for(const auto& it : m_waypoints) {
root->addString(it.second);
root->addPos(it.first);
Position pos = it.first;
root->addPos(pos.x, pos.y, pos.z);
}
root->endNode();
}