Removed Position dependencies inside the framework

master
BeniS 11 years ago
parent 32df317163
commit 3ca85cbe87

@ -49,7 +49,11 @@ void CreatureManager::terminate()
void Spawn::load(TiXmlElement* node) 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); setCenterPos(centerPos);
setRadius(node->readType<int32>("radius")); setRadius(node->readType<int32>("radius"));

@ -65,7 +65,12 @@ void House::load(const TiXmlElement *elem)
setSize(elem->readType<uint32>("size")); setSize(elem->readType<uint32>("size"));
setTownId(elem->readType<uint32>("townid")); setTownId(elem->readType<uint32>("townid"));
m_isGuildHall = elem->readType<bool>("guildhall"); 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) void House::save(TiXmlElement*& elem)

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

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

@ -165,15 +165,6 @@ std::string BinaryTree::getString(uint16 len)
return ret; return ret;
} }
Position BinaryTree::getPosition()
{
Position ret;
ret.x = getU16();
ret.y = getU16();
ret.z = getU8();
return ret;
}
Point BinaryTree::getPoint() Point BinaryTree::getPoint()
{ {
Point ret; Point ret;
@ -216,11 +207,11 @@ void OutputBinaryTree::addString(const std::string& v)
write((const uint8*)v.c_str(), v.length()); write((const uint8*)v.c_str(), v.length());
} }
void OutputBinaryTree::addPos(const Position& pos) void OutputBinaryTree::addPos(uint16 x, uint16 y, uint8 z)
{ {
addU16(pos.x); addU16(x);
addU16(pos.y); addU16(y);
addU8(pos.z); addU8(z);
} }
void OutputBinaryTree::addPoint(const Point& point) void OutputBinaryTree::addPoint(const Point& point)

@ -49,7 +49,6 @@ public:
uint32 getU32(); uint32 getU32();
uint64 getU64(); uint64 getU64();
std::string getString(uint16 len = 0); std::string getString(uint16 len = 0);
Position getPosition();
Point getPoint(); Point getPoint();
BinaryTreeVec getChildren(); BinaryTreeVec getChildren();
@ -74,7 +73,7 @@ public:
void addU16(uint16 v); void addU16(uint16 v);
void addU32(uint32 v); void addU32(uint32 v);
void addString(const std::string& v); void addString(const std::string& v);
void addPos(const Position& pos); void addPos(uint16 x, uint16 y, uint8 z);
void addPoint(const Point& point); void addPoint(const Point& point);
void startNode(uint8 node); void startNode(uint8 node);

@ -65,7 +65,7 @@ public:
void addU32(uint32 v); void addU32(uint32 v);
void addU64(uint64 v); void addU64(uint64 v);
void addString(const std::string& v); void addString(const std::string& v);
void addPos(const Position& pos) { addU16(pos.x); addU16(pos.y); addU8(pos.z); } void addPos(uint16 x, uint16 y, uint8 z) { addU16(x); addU16(y); addU8(z); }
void addPoint(const Point& p) { addU8(p.x); addU8(p.y); } void addPoint(const Point& p) { addU8(p.x); addU8(p.y); }
FileStreamPtr asFileStream() { return static_self_cast<FileStream>(); } FileStreamPtr asFileStream() { return static_self_cast<FileStream>(); }

@ -962,15 +962,6 @@ public:
return ret; return ret;
} }
Position readPos(const std::string& base = std::string()) const
{
Position ret;
ret.x = readType<uint16>(base + "x");
ret.y = readType<uint16>(base + "y");
ret.z = readType<uint8>(base + "z");
return ret;
}
/** Template form of the attribute query which will try to read the /** Template form of the attribute query which will try to read the
attribute into the specified type. Very easy, very powerful, but attribute into the specified type. Very easy, very powerful, but
be careful to make sure to call this with the correct type. be careful to make sure to call this with the correct type.

Loading…
Cancel
Save