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
This commit is contained in:
BrunoDCC 2013-11-09 20:04:48 -02:00
parent 6f9436dd60
commit c81a623c43
7 changed files with 51 additions and 17 deletions

View File

@ -65,6 +65,7 @@ void Spawn::load(TiXmlElement* node)
std::string cName = cNode->Attribute("name"); std::string cName = cNode->Attribute("name");
stdext::tolower(cName); stdext::tolower(cName);
stdext::trim(cName); stdext::trim(cName);
stdext::ucwords(cName);
if (!(cType = g_creatures.getCreatureByName(cName))) if (!(cType = g_creatures.getCreatureByName(cName)))
continue; continue;
@ -149,6 +150,8 @@ CreaturePtr CreatureType::cast()
CreaturePtr ret(new Creature); CreaturePtr ret(new Creature);
std::string cName = getName(); std::string cName = getName();
stdext::tolower(cName);
stdext::trim(cName);
stdext::ucwords(cName); stdext::ucwords(cName);
ret->setName(cName); ret->setName(cName);
@ -287,6 +290,7 @@ void CreatureManager::loadCreatureBuffer(const std::string& buffer)
std::string cName = root->Attribute("name"); std::string cName = root->Attribute("name");
stdext::tolower(cName); stdext::tolower(cName);
stdext::trim(cName); stdext::trim(cName);
stdext::ucwords(cName);
CreatureTypePtr newType(new CreatureType(cName)); CreatureTypePtr newType(new CreatureType(cName));
for(TiXmlElement* attrib = root->FirstChildElement(); attrib; attrib = attrib->NextSiblingElement()) { for(TiXmlElement* attrib = root->FirstChildElement(); attrib; attrib = attrib->NextSiblingElement()) {
@ -333,6 +337,7 @@ const CreatureTypePtr& CreatureManager::getCreatureByName(std::string name)
{ {
stdext::tolower(name); stdext::tolower(name);
stdext::trim(name); stdext::trim(name);
stdext::ucwords(name);
auto it = std::find_if(m_creatures.begin(), m_creatures.end(), auto it = std::find_if(m_creatures.begin(), m_creatures.end(),
[=] (const CreatureTypePtr& m) -> bool { return m->getName() == name; }); [=] (const CreatureTypePtr& m) -> bool { return m->getName() == name; });
if(it != m_creatures.end()) if(it != m_creatures.end())

View File

@ -1419,7 +1419,7 @@ void Game::setProtocolVersion(int version)
if(isOnline()) if(isOnline())
stdext::throw_exception("Unable to change protocol version while online"); 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)); stdext::throw_exception(stdext::format("Protocol version %d not supported", version));
m_features.reset(); m_features.reset();
@ -1522,7 +1522,7 @@ void Game::setClientVersion(int version)
if(isOnline()) if(isOnline())
stdext::throw_exception("Unable to change client version while online"); 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)); stdext::throw_exception(stdext::format("Client version %d not supported", version));
m_clientVersion = version; m_clientVersion = version;

View File

@ -23,6 +23,7 @@
#include "thingtypemanager.h" #include "thingtypemanager.h"
#include "thingtype.h" #include "thingtype.h"
#include "game.h"
#include <framework/core/filestream.h> #include <framework/core/filestream.h>
#include <framework/core/binarytree.h> #include <framework/core/binarytree.h>
@ -50,13 +51,26 @@ void ItemType::unserialize(const BinaryTreePtr& node)
switch(attr) { switch(attr) {
case ItemTypeAttrServerId: { case ItemTypeAttrServerId: {
uint16 serverId = node->getU16(); uint16 serverId = node->getU16();
if(serverId > 20000 && serverId < 20100) { if(g_game.getProtocolVersion() < 960) {
serverId -= 20000; if(serverId > 20000 && serverId < 20100) {
} else if(lastId > 99 && lastId != serverId - 1) { serverId -= 20000;
while(lastId != serverId - 1) { } else if(lastId > 99 && lastId != serverId - 1) {
ItemTypePtr tmp(new ItemType); while(lastId != serverId - 1) {
tmp->setServerId(lastId++); ItemTypePtr tmp(new ItemType);
g_things.addItemType(tmp); 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); setServerId(serverId);

View File

@ -103,6 +103,7 @@ void ThingType::unserialize(uint16 clientId, ThingCategory category, const FileS
m_attribs.set(attr, market); m_attribs.set(attr, market);
break; break;
} }
case ThingAttrUsable:
case ThingAttrElevation: { case ThingAttrElevation: {
m_elevation = fin->getU16(); m_elevation = fin->getU16();
m_attribs.set(attr, m_elevation); m_attribs.set(attr, m_elevation);

View File

@ -76,6 +76,7 @@ enum ThingAttr : uint8 {
ThingAttrLook = 31, ThingAttrLook = 31,
ThingAttrCloth = 32, ThingAttrCloth = 32,
ThingAttrMarket = 33, ThingAttrMarket = 33,
ThingAttrUsable = 34,
// additional // additional
ThingAttrOpacity = 100, ThingAttrOpacity = 100,

View File

@ -27,6 +27,7 @@
#include "itemtype.h" #include "itemtype.h"
#include "creature.h" #include "creature.h"
#include "creatures.h" #include "creatures.h"
#include "game.h"
#include <framework/core/resourcemanager.h> #include <framework/core/resourcemanager.h>
#include <framework/core/filestream.h> #include <framework/core/filestream.h>
@ -230,14 +231,26 @@ void ThingTypeManager::parseItemType(uint16 id, TiXmlElement* elem)
{ {
uint16 serverId = id; uint16 serverId = id;
ItemTypePtr itemType = nullptr; ItemTypePtr itemType = nullptr;
if(serverId > 20000 && serverId < 20100) { if(g_game.getProtocolVersion() < 960) {
serverId -= 20000; if(serverId > 20000 && serverId < 20100) {
serverId -= 20000;
itemType = ItemTypePtr(new ItemType); itemType = ItemTypePtr(new ItemType);
itemType->setServerId(serverId); itemType->setServerId(serverId);
addItemType(itemType); addItemType(itemType);
} else } else
itemType = getItemType(serverId); 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")); itemType->setName(elem->Attribute("name"));
for(TiXmlElement* attrib = elem->FirstChildElement(); attrib; attrib = attrib->NextSiblingElement()) { for(TiXmlElement* attrib = elem->FirstChildElement(); attrib; attrib = attrib->NextSiblingElement()) {

View File

@ -119,7 +119,7 @@ public:
void setHouseId(uint32 hid) { m_houseId = hid; } void setHouseId(uint32 hid) { m_houseId = hid; }
uint32 getHouseId() { return m_houseId; } 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<Tile>(); } TilePtr asTile() { return static_self_cast<Tile>(); }