From c81a623c43278af528adbd1dac0bf6b3cd7eeb38 Mon Sep 17 00:00:00 2001 From: BrunoDCC Date: Sat, 9 Nov 2013 20:04:48 -0200 Subject: [PATCH] Fixes for creatures name fixes on save houses (Now open most generate some error) First 10.22 commit (open dat to edit) Add server id for new versions --- src/client/creatures.cpp | 5 +++++ src/client/game.cpp | 4 ++-- src/client/itemtype.cpp | 28 +++++++++++++++++++++------- src/client/thingtype.cpp | 1 + src/client/thingtype.h | 1 + src/client/thingtypemanager.cpp | 27 ++++++++++++++++++++------- src/client/tile.h | 2 +- 7 files changed, 51 insertions(+), 17 deletions(-) diff --git a/src/client/creatures.cpp b/src/client/creatures.cpp index 5da0a842..230c0d34 100644 --- a/src/client/creatures.cpp +++ b/src/client/creatures.cpp @@ -65,6 +65,7 @@ void Spawn::load(TiXmlElement* node) std::string cName = cNode->Attribute("name"); stdext::tolower(cName); stdext::trim(cName); + stdext::ucwords(cName); if (!(cType = g_creatures.getCreatureByName(cName))) continue; @@ -149,6 +150,8 @@ CreaturePtr CreatureType::cast() CreaturePtr ret(new Creature); std::string cName = getName(); + stdext::tolower(cName); + stdext::trim(cName); stdext::ucwords(cName); ret->setName(cName); @@ -287,6 +290,7 @@ void CreatureManager::loadCreatureBuffer(const std::string& buffer) std::string cName = root->Attribute("name"); stdext::tolower(cName); stdext::trim(cName); + stdext::ucwords(cName); CreatureTypePtr newType(new CreatureType(cName)); for(TiXmlElement* attrib = root->FirstChildElement(); attrib; attrib = attrib->NextSiblingElement()) { @@ -333,6 +337,7 @@ const CreatureTypePtr& CreatureManager::getCreatureByName(std::string name) { stdext::tolower(name); stdext::trim(name); + stdext::ucwords(name); auto it = std::find_if(m_creatures.begin(), m_creatures.end(), [=] (const CreatureTypePtr& m) -> bool { return m->getName() == name; }); if(it != m_creatures.end()) diff --git a/src/client/game.cpp b/src/client/game.cpp index cd5c649c..34ce22b1 100644 --- a/src/client/game.cpp +++ b/src/client/game.cpp @@ -1419,7 +1419,7 @@ void Game::setProtocolVersion(int version) if(isOnline()) stdext::throw_exception("Unable to change protocol version while online"); - if(version != 0 && version != 760 && (version < 810 || version > 1010)) + if(version != 0 && version != 760 && (version < 810 || version > 1022)) stdext::throw_exception(stdext::format("Protocol version %d not supported", version)); m_features.reset(); @@ -1522,7 +1522,7 @@ void Game::setClientVersion(int version) if(isOnline()) stdext::throw_exception("Unable to change client version while online"); - if(version != 0 && version != 760 && (version < 810 || version > 1010)) + if(version != 0 && version != 760 && (version < 810 || version > 1022)) stdext::throw_exception(stdext::format("Client version %d not supported", version)); m_clientVersion = version; diff --git a/src/client/itemtype.cpp b/src/client/itemtype.cpp index 8c164df3..89d54072 100644 --- a/src/client/itemtype.cpp +++ b/src/client/itemtype.cpp @@ -23,6 +23,7 @@ #include "thingtypemanager.h" #include "thingtype.h" +#include "game.h" #include #include @@ -50,13 +51,26 @@ void ItemType::unserialize(const BinaryTreePtr& node) switch(attr) { case ItemTypeAttrServerId: { uint16 serverId = node->getU16(); - if(serverId > 20000 && serverId < 20100) { - serverId -= 20000; - } else if(lastId > 99 && lastId != serverId - 1) { - while(lastId != serverId - 1) { - ItemTypePtr tmp(new ItemType); - tmp->setServerId(lastId++); - g_things.addItemType(tmp); + if(g_game.getProtocolVersion() < 960) { + if(serverId > 20000 && serverId < 20100) { + serverId -= 20000; + } else if(lastId > 99 && lastId != serverId - 1) { + while(lastId != serverId - 1) { + ItemTypePtr tmp(new ItemType); + tmp->setServerId(lastId++); + g_things.addItemType(tmp); + } + } + } + if(g_game.getProtocolVersion() >= 960) { + if(serverId > 30000 && serverId < 30100) { + serverId -= 30000; + } else if(lastId > 99 && lastId != serverId - 1) { + while(lastId != serverId - 1) { + ItemTypePtr tmp(new ItemType); + tmp->setServerId(lastId++); + g_things.addItemType(tmp); + } } } setServerId(serverId); diff --git a/src/client/thingtype.cpp b/src/client/thingtype.cpp index 8bc46062..5a1b2287 100644 --- a/src/client/thingtype.cpp +++ b/src/client/thingtype.cpp @@ -103,6 +103,7 @@ void ThingType::unserialize(uint16 clientId, ThingCategory category, const FileS m_attribs.set(attr, market); break; } + case ThingAttrUsable: case ThingAttrElevation: { m_elevation = fin->getU16(); m_attribs.set(attr, m_elevation); diff --git a/src/client/thingtype.h b/src/client/thingtype.h index f3c28a60..44b794d2 100644 --- a/src/client/thingtype.h +++ b/src/client/thingtype.h @@ -76,6 +76,7 @@ enum ThingAttr : uint8 { ThingAttrLook = 31, ThingAttrCloth = 32, ThingAttrMarket = 33, + ThingAttrUsable = 34, // additional ThingAttrOpacity = 100, diff --git a/src/client/thingtypemanager.cpp b/src/client/thingtypemanager.cpp index f839add6..c8b4cd7b 100644 --- a/src/client/thingtypemanager.cpp +++ b/src/client/thingtypemanager.cpp @@ -27,6 +27,7 @@ #include "itemtype.h" #include "creature.h" #include "creatures.h" +#include "game.h" #include #include @@ -230,14 +231,26 @@ void ThingTypeManager::parseItemType(uint16 id, TiXmlElement* elem) { uint16 serverId = id; ItemTypePtr itemType = nullptr; - if(serverId > 20000 && serverId < 20100) { - serverId -= 20000; + if(g_game.getProtocolVersion() < 960) { + if(serverId > 20000 && serverId < 20100) { + serverId -= 20000; - itemType = ItemTypePtr(new ItemType); - itemType->setServerId(serverId); - addItemType(itemType); - } else - itemType = getItemType(serverId); + itemType = ItemTypePtr(new ItemType); + itemType->setServerId(serverId); + addItemType(itemType); + } else + itemType = getItemType(serverId); + } + if(g_game.getProtocolVersion() >= 960) { + if(serverId > 30000 && serverId < 30100) { + serverId -= 30000; + + itemType = ItemTypePtr(new ItemType); + itemType->setServerId(serverId); + addItemType(itemType); + } else + itemType = getItemType(serverId); + } itemType->setName(elem->Attribute("name")); for(TiXmlElement* attrib = elem->FirstChildElement(); attrib; attrib = attrib->NextSiblingElement()) { diff --git a/src/client/tile.h b/src/client/tile.h index 0ef41506..4dc3b95e 100644 --- a/src/client/tile.h +++ b/src/client/tile.h @@ -119,7 +119,7 @@ public: void setHouseId(uint32 hid) { m_houseId = hid; } uint32 getHouseId() { return m_houseId; } - bool isHouseTile() const { return m_houseId != 0 && (m_flags & TILESTATE_HOUSE) == TILESTATE_HOUSE; } + bool isHouseTile() const { return m_houseId != 0 or (m_flags & TILESTATE_HOUSE) == TILESTATE_HOUSE; } TilePtr asTile() { return static_self_cast(); }