Merge branch 'master' of https://github.com/BrunoDCC/otclient
* 'master' of https://github.com/BrunoDCC/otclient: Add full npc read (it not cause bug) Fixed a npcs save Fixed a spawns and npcs load
This commit is contained in:
commit
b27352c321
|
@ -50,9 +50,9 @@ void CreatureManager::terminate()
|
||||||
void Spawn::load(TiXmlElement* node)
|
void Spawn::load(TiXmlElement* node)
|
||||||
{
|
{
|
||||||
Position centerPos;
|
Position centerPos;
|
||||||
centerPos.x = node->readType<uint16>("centerx");
|
centerPos.x = node->readType<int>("centerx");
|
||||||
centerPos.y = node->readType<uint16>("centery");
|
centerPos.y = node->readType<int>("centery");
|
||||||
centerPos.z = node->readType<uint8>("centerz");
|
centerPos.z = node->readType<int>("centerz");
|
||||||
|
|
||||||
setCenterPos(centerPos);
|
setCenterPos(centerPos);
|
||||||
setRadius(node->readType<int32>("radius"));
|
setRadius(node->readType<int32>("radius"));
|
||||||
|
@ -62,6 +62,7 @@ void Spawn::load(TiXmlElement* node)
|
||||||
if(cNode->ValueStr() != "monster" && cNode->ValueStr() != "npc")
|
if(cNode->ValueStr() != "monster" && cNode->ValueStr() != "npc")
|
||||||
stdext::throw_exception(stdext::format("invalid spawn-subnode %s", cNode->ValueStr()));
|
stdext::throw_exception(stdext::format("invalid spawn-subnode %s", cNode->ValueStr()));
|
||||||
|
|
||||||
|
setNPC(cNode->ValueStr() == "npc");
|
||||||
std::string cName = cNode->Attribute("name");
|
std::string cName = cNode->Attribute("name");
|
||||||
stdext::tolower(cName);
|
stdext::tolower(cName);
|
||||||
stdext::trim(cName);
|
stdext::trim(cName);
|
||||||
|
@ -97,7 +98,7 @@ void Spawn::save(TiXmlElement* node)
|
||||||
TiXmlElement* creatureNode = nullptr;
|
TiXmlElement* creatureNode = nullptr;
|
||||||
|
|
||||||
for(const auto& pair : m_creatures) {
|
for(const auto& pair : m_creatures) {
|
||||||
if(!(creatureNode = new TiXmlElement("monster")))
|
if(!(creatureNode = new TiXmlElement(getNPC()? "npc" : "monster")))
|
||||||
stdext::throw_exception("oom?");
|
stdext::throw_exception("oom?");
|
||||||
|
|
||||||
const CreatureTypePtr& creature = pair.second;
|
const CreatureTypePtr& creature = pair.second;
|
||||||
|
|
|
@ -40,6 +40,7 @@ enum SpawnAttr : uint8
|
||||||
{
|
{
|
||||||
SpawnAttrRadius = 0,
|
SpawnAttrRadius = 0,
|
||||||
SpawnAttrCenter = 1,
|
SpawnAttrCenter = 1,
|
||||||
|
SpawnAttrNPC = 2,
|
||||||
};
|
};
|
||||||
|
|
||||||
class Spawn : public LuaObject
|
class Spawn : public LuaObject
|
||||||
|
@ -54,6 +55,9 @@ public:
|
||||||
void setCenterPos(const Position& pos) { m_attribs.set(SpawnAttrCenter, pos); }
|
void setCenterPos(const Position& pos) { m_attribs.set(SpawnAttrCenter, pos); }
|
||||||
Position getCenterPos() { return m_attribs.get<Position>(SpawnAttrCenter); }
|
Position getCenterPos() { return m_attribs.get<Position>(SpawnAttrCenter); }
|
||||||
|
|
||||||
|
void setNPC(bool n) { m_attribs.set(SpawnAttrNPC, n); }
|
||||||
|
bool getNPC() { return m_attribs.get<bool>(SpawnAttrNPC); }
|
||||||
|
|
||||||
void addCreature(const Position& placePos, const CreatureTypePtr& cType);
|
void addCreature(const Position& placePos, const CreatureTypePtr& cType);
|
||||||
void removeCreature(const Position& pos);
|
void removeCreature(const Position& pos);
|
||||||
void clear() { m_creatures.clear(); }
|
void clear() { m_creatures.clear(); }
|
||||||
|
|
|
@ -80,9 +80,9 @@ void House::load(const TiXmlElement *elem)
|
||||||
m_isGuildHall = elem->readType<bool>("guildhall");
|
m_isGuildHall = elem->readType<bool>("guildhall");
|
||||||
|
|
||||||
Position entryPos;
|
Position entryPos;
|
||||||
entryPos.x = elem->readType<uint16>("entryx");
|
entryPos.x = elem->readType<int>("entryx");
|
||||||
entryPos.y = elem->readType<uint16>("entryy");
|
entryPos.y = elem->readType<int>("entryy");
|
||||||
entryPos.z = elem->readType<uint8>("entryz");
|
entryPos.z = elem->readType<int>("entryz");
|
||||||
setEntry(entryPos);
|
setEntry(entryPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue