Merge github.com:BrunoDCC/otclient

This commit is contained in:
Eduardo Bart 2013-11-10 19:36:06 -02:00
commit 3cff331723
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");
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())

View File

@ -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;

View File

@ -23,6 +23,7 @@
#include "thingtypemanager.h"
#include "thingtype.h"
#include "game.h"
#include <framework/core/filestream.h>
#include <framework/core/binarytree.h>
@ -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);

View File

@ -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);

View File

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

View File

@ -27,6 +27,7 @@
#include "itemtype.h"
#include "creature.h"
#include "creatures.h"
#include "game.h"
#include <framework/core/resourcemanager.h>
#include <framework/core/filestream.h>
@ -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()) {

View File

@ -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 || (m_flags & TILESTATE_HOUSE) == TILESTATE_HOUSE; }
TilePtr asTile() { return static_self_cast<Tile>(); }