From 00729bbc2ea8e359d9ab626db8a1154055110f02 Mon Sep 17 00:00:00 2001 From: BrunoDCC Date: Thu, 22 Aug 2013 20:54:09 -0300 Subject: [PATCH 1/2] Fixed a npcs save Fixed a spawns and npcs load --- src/client/creatures.cpp | 9 +++++---- src/client/creatures.h | 4 ++++ src/client/houses.cpp | 6 +++--- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/client/creatures.cpp b/src/client/creatures.cpp index d9f9b157..6f2a1d7e 100644 --- a/src/client/creatures.cpp +++ b/src/client/creatures.cpp @@ -50,9 +50,9 @@ void CreatureManager::terminate() void Spawn::load(TiXmlElement* node) { Position centerPos; - centerPos.x = node->readType("centerx"); - centerPos.y = node->readType("centery"); - centerPos.z = node->readType("centerz"); + centerPos.x = node->readType("centerx"); + centerPos.y = node->readType("centery"); + centerPos.z = node->readType("centerz"); setCenterPos(centerPos); setRadius(node->readType("radius")); @@ -62,6 +62,7 @@ void Spawn::load(TiXmlElement* node) if(cNode->ValueStr() != "monster" && cNode->ValueStr() != "npc") stdext::throw_exception(stdext::format("invalid spawn-subnode %s", cNode->ValueStr())); + setNPC(cNode->ValueStr() != "npc"); std::string cName = cNode->Attribute("name"); stdext::tolower(cName); stdext::trim(cName); @@ -97,7 +98,7 @@ void Spawn::save(TiXmlElement* node) TiXmlElement* creatureNode = nullptr; for(const auto& pair : m_creatures) { - if(!(creatureNode = new TiXmlElement("monster"))) + if(!(creatureNode = new TiXmlElement(getNPC()? "monster" : "npc"))) stdext::throw_exception("oom?"); const CreatureTypePtr& creature = pair.second; diff --git a/src/client/creatures.h b/src/client/creatures.h index 94d6504c..81617770 100644 --- a/src/client/creatures.h +++ b/src/client/creatures.h @@ -40,6 +40,7 @@ enum SpawnAttr : uint8 { SpawnAttrRadius = 0, SpawnAttrCenter = 1, + SpawnAttrNPC = 2, }; class Spawn : public LuaObject @@ -54,6 +55,9 @@ public: void setCenterPos(const Position& pos) { m_attribs.set(SpawnAttrCenter, pos); } Position getCenterPos() { return m_attribs.get(SpawnAttrCenter); } + void setNPC(bool n) { m_attribs.set(SpawnAttrNPC, n); } + bool getNPC() { return m_attribs.get(SpawnAttrNPC); } + void addCreature(const Position& placePos, const CreatureTypePtr& cType); void removeCreature(const Position& pos); void clear() { m_creatures.clear(); } diff --git a/src/client/houses.cpp b/src/client/houses.cpp index f77653d7..62d5dc1d 100644 --- a/src/client/houses.cpp +++ b/src/client/houses.cpp @@ -80,9 +80,9 @@ void House::load(const TiXmlElement *elem) m_isGuildHall = elem->readType("guildhall"); Position entryPos; - entryPos.x = elem->readType("entryx"); - entryPos.y = elem->readType("entryy"); - entryPos.z = elem->readType("entryz"); + entryPos.x = elem->readType("entryx"); + entryPos.y = elem->readType("entryy"); + entryPos.z = elem->readType("entryz"); setEntry(entryPos); } From a6be9ae525a99ec7a0b30ad10cfd1a09bf1c9c35 Mon Sep 17 00:00:00 2001 From: BrunoDCC Date: Thu, 22 Aug 2013 21:00:48 -0300 Subject: [PATCH 2/2] Add full npc read (it not cause bug) --- src/client/creatures.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/client/creatures.cpp b/src/client/creatures.cpp index 6f2a1d7e..ee001e47 100644 --- a/src/client/creatures.cpp +++ b/src/client/creatures.cpp @@ -62,7 +62,7 @@ void Spawn::load(TiXmlElement* node) if(cNode->ValueStr() != "monster" && cNode->ValueStr() != "npc") stdext::throw_exception(stdext::format("invalid spawn-subnode %s", cNode->ValueStr())); - setNPC(cNode->ValueStr() != "npc"); + setNPC(cNode->ValueStr() == "npc"); std::string cName = cNode->Attribute("name"); stdext::tolower(cName); stdext::trim(cName); @@ -98,7 +98,7 @@ void Spawn::save(TiXmlElement* node) TiXmlElement* creatureNode = nullptr; for(const auto& pair : m_creatures) { - if(!(creatureNode = new TiXmlElement(getNPC()? "monster" : "npc"))) + if(!(creatureNode = new TiXmlElement(getNPC()? "npc" : "monster"))) stdext::throw_exception("oom?"); const CreatureTypePtr& creature = pair.second;