Partial 10.36 support, also fix #499

This commit is contained in:
Sam 2014-03-12 06:39:20 +01:00
parent 9d866a3616
commit 8d8f32b081
16 changed files with 97 additions and 11 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 795 B

View File

@ -56,7 +56,7 @@ function init()
end end
function bindKeys() function bindKeys()
gameRootPanel:setAutoRepeatDelay(80) gameRootPanel:setAutoRepeatDelay(200)
bindWalkKey('Up', North) bindWalkKey('Up', North)
bindWalkKey('Right', East) bindWalkKey('Right', East)

View File

@ -186,7 +186,7 @@ CIPSOFT_RSA = "1321277432058722840622950990822933849527763264961655079678763618"
"88792221429527047321331896351555606801473202394175817" "88792221429527047321331896351555606801473202394175817"
-- set to the latest Tibia.pic signature to make otclient compatible with official tibia -- set to the latest Tibia.pic signature to make otclient compatible with official tibia
PIC_SIGNATURE = 0x52131b61 PIC_SIGNATURE = 0x52de78da
OsTypes = { OsTypes = {
Linux = 1, Linux = 1,

View File

@ -27,6 +27,12 @@ EmblemGreen = 1
EmblemRed = 2 EmblemRed = 2
EmblemBlue = 3 EmblemBlue = 3
NpcIconNone = 0
NpcIconChat = 1
NpcIconTrade = 2
NpcIconQuest = 3
NpcIconTradeQuest = 4
-- @} -- @}
function getSkullImagePath(skullId) function getSkullImagePath(skullId)
@ -91,6 +97,20 @@ function getEmblemImagePath(emblemId)
return path return path
end end
function getIconImagePath(iconId)
local path
if iconId == NpcIconChat then
path = '/images/game/npcicons/icon_chat'
elseif iconId == NpcIconTrade then
path = '/images/game/npcicons/icon_trade'
elseif iconId == NpcIconQuest then
path = '/images/game/npcicons/icon_quest'
elseif iconId == NpcIconTradeQuest then
path = '/images/game/npcicons/icon_tradequest'
end
return path
end
function Creature:onSkullChange(skullId) function Creature:onSkullChange(skullId)
local imagePath = getSkullImagePath(skullId) local imagePath = getSkullImagePath(skullId)
if imagePath then if imagePath then
@ -111,3 +131,10 @@ function Creature:onEmblemChange(emblemId)
self:setEmblemTexture(imagePath) self:setEmblemTexture(imagePath)
end end
end end
function Creature:onIconChange(iconId)
local imagePath = getIconImagePath(iconId)
if imagePath then
self:setIconTexture(imagePath)
end
end

View File

@ -54,7 +54,7 @@ function g_game.getSupportedClients()
940, 944, 953, 954, 960, 961, 963, 940, 944, 953, 954, 960, 961, 963,
970, 980, 981, 982, 983, 984, 985, 970, 980, 981, 982, 983, 984, 985,
986, 1001, 1002, 1010, 1020, 1021, 986, 1001, 1002, 1010, 1020, 1021,
1022, 1031, 1034, 1035 1022, 1031, 1034, 1035, 1036
} }
end end

View File

@ -247,6 +247,14 @@ namespace Otc
EmblemOther EmblemOther
}; };
enum CreatureIcons {
NpcIconNone = 0,
NpcIconChat,
NpcIconTrade,
NpcIconQuest,
NpcIconTradeQuest
};
enum PlayerStates { enum PlayerStates {
IconNone = 0, IconNone = 0,
IconPoison = 1, IconPoison = 1,
@ -377,6 +385,8 @@ namespace Otc
GameWritableDate = 51, GameWritableDate = 51,
GameAdditionalVipInfo = 52, GameAdditionalVipInfo = 52,
GameBaseSkillU16 = 53, GameBaseSkillU16 = 53,
GameCreatureIcons = 54,
GameHideNpcNames = 55,
LastGameFeature = 101 LastGameFeature = 101
}; };

View File

@ -53,6 +53,7 @@ Creature::Creature() : Thing()
m_skull = Otc::SkullNone; m_skull = Otc::SkullNone;
m_shield = Otc::ShieldNone; m_shield = Otc::ShieldNone;
m_emblem = Otc::EmblemNone; m_emblem = Otc::EmblemNone;
m_icon = Otc::NpcIconNone;
m_lastStepDirection = Otc::InvalidDirection; m_lastStepDirection = Otc::InvalidDirection;
m_nameCache.setFont(g_fonts.getFont("verdana-11px-rounded")); m_nameCache.setFont(g_fonts.getFont("verdana-11px-rounded"));
m_nameCache.setAlign(Fw::AlignTopCenter); m_nameCache.setAlign(Fw::AlignTopCenter);
@ -258,7 +259,7 @@ void Creature::drawInformation(const Point& point, bool useGray, const Rect& par
if(g_game.getFeature(Otc::GameBlueNpcNameColor) && isNpc() && m_healthPercent == 100 && !useGray) if(g_game.getFeature(Otc::GameBlueNpcNameColor) && isNpc() && m_healthPercent == 100 && !useGray)
fillColor = Color(0x66, 0xcc, 0xff); fillColor = Color(0x66, 0xcc, 0xff);
if(drawFlags & Otc::DrawBars) { if(drawFlags & Otc::DrawBars && (!isNpc() || !g_game.getFeature(Otc::GameHideNpcNames))) {
g_painter->setColor(Color::black); g_painter->setColor(Color::black);
g_painter->drawFilledRect(backgroundRect); g_painter->drawFilledRect(backgroundRect);
@ -287,6 +288,11 @@ void Creature::drawInformation(const Point& point, bool useGray, const Rect& par
Rect emblemRect = Rect(backgroundRect.x() + 13.5 + 12, backgroundRect.y() + 16, m_emblemTexture->getSize()); Rect emblemRect = Rect(backgroundRect.x() + 13.5 + 12, backgroundRect.y() + 16, m_emblemTexture->getSize());
g_painter->drawTexturedRect(emblemRect, m_emblemTexture); g_painter->drawTexturedRect(emblemRect, m_emblemTexture);
} }
if(m_icon != Otc::NpcIconNone && m_iconTexture) {
g_painter->setColor(Color::white);
Rect iconRect = Rect(backgroundRect.x() + 13.5 + 12, backgroundRect.y() + 5, m_iconTexture->getSize());
g_painter->drawTexturedRect(iconRect, m_iconTexture);
}
} }
void Creature::turn(Otc::Direction direction) void Creature::turn(Otc::Direction direction)
@ -708,6 +714,12 @@ void Creature::setEmblem(uint8 emblem)
callLuaField("onEmblemChange", m_emblem); callLuaField("onEmblemChange", m_emblem);
} }
void Creature::setIcon(uint8 icon)
{
m_icon = icon;
callLuaField("onIconChange", m_icon);
}
void Creature::setSkullTexture(const std::string& filename) void Creature::setSkullTexture(const std::string& filename)
{ {
m_skullTexture = g_textures.getTexture(filename); m_skullTexture = g_textures.getTexture(filename);
@ -733,6 +745,12 @@ void Creature::setEmblemTexture(const std::string& filename)
m_emblemTexture = g_textures.getTexture(filename); m_emblemTexture = g_textures.getTexture(filename);
} }
void Creature::setIconTexture(const std::string& filename)
{
m_iconTexture = g_textures.getTexture(filename);
}
void Creature::setSpeedFormula(double speedA, double speedB, double speedC) void Creature::setSpeedFormula(double speedA, double speedB, double speedC)
{ {
m_speedFormula[Otc::SpeedFormulaA] = speedA; m_speedFormula[Otc::SpeedFormulaA] = speedA;

View File

@ -61,9 +61,11 @@ public:
void setSkull(uint8 skull); void setSkull(uint8 skull);
void setShield(uint8 shield); void setShield(uint8 shield);
void setEmblem(uint8 emblem); void setEmblem(uint8 emblem);
void setIcon(uint8 icon);
void setSkullTexture(const std::string& filename); void setSkullTexture(const std::string& filename);
void setShieldTexture(const std::string& filename, bool blink); void setShieldTexture(const std::string& filename, bool blink);
void setEmblemTexture(const std::string& filename); void setEmblemTexture(const std::string& filename);
void setIconTexture(const std::string& filename);
void setPassable(bool passable) { m_passable = passable; } void setPassable(bool passable) { m_passable = passable; }
void setSpeedFormula(double speedA, double speedB, double speedC); void setSpeedFormula(double speedA, double speedB, double speedC);
@ -83,6 +85,7 @@ public:
uint8 getSkull() { return m_skull; } uint8 getSkull() { return m_skull; }
uint8 getShield() { return m_shield; } uint8 getShield() { return m_shield; }
uint8 getEmblem() { return m_emblem; } uint8 getEmblem() { return m_emblem; }
uint8 getIcon() { return m_icon; }
bool isPassable() { return m_passable; } bool isPassable() { return m_passable; }
Point getDrawOffset(); Point getDrawOffset();
int getStepDuration(bool ignoreDiagonal = false, Otc::Direction dir = Otc::InvalidDirection); int getStepDuration(bool ignoreDiagonal = false, Otc::Direction dir = Otc::InvalidDirection);
@ -146,9 +149,11 @@ protected:
uint8 m_skull; uint8 m_skull;
uint8 m_shield; uint8 m_shield;
uint8 m_emblem; uint8 m_emblem;
uint8 m_icon;
TexturePtr m_skullTexture; TexturePtr m_skullTexture;
TexturePtr m_shieldTexture; TexturePtr m_shieldTexture;
TexturePtr m_emblemTexture; TexturePtr m_emblemTexture;
TexturePtr m_iconTexture;
stdext::boolean<true> m_showShieldTexture; stdext::boolean<true> m_showShieldTexture;
stdext::boolean<false> m_shieldBlink; stdext::boolean<false> m_shieldBlink;
stdext::boolean<false> m_passable; stdext::boolean<false> m_passable;

View File

@ -1459,7 +1459,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 > 1035)) if(version != 0 && (version < 760 || version > 1036))
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();
@ -1563,9 +1563,15 @@ void Game::setProtocolVersion(int version)
} }
if (version >= 1035) { if (version >= 1035) {
enableFeature(Otc::GameDoubleSkills); enableFeature(Otc::GameDoubleSkills);
enableFeature(Otc::GameBaseSkillU16); enableFeature(Otc::GameBaseSkillU16);
} }
if(version >= 1036) {
enableFeature(Otc::GameCreatureIcons);
enableFeature(Otc::GameHideNpcNames);
}
m_protocolVersion = version; m_protocolVersion = version;
Proto::buildMessageModesMap(version); Proto::buildMessageModesMap(version);
@ -1581,7 +1587,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 > 1035)) if(version != 0 && (version < 760 || version > 1036))
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

@ -297,9 +297,11 @@ void LocalPlayer::onAppear()
{ {
Creature::onAppear(); Creature::onAppear();
/* Does not seem to be needed anymore
// on teleports lock the walk // on teleports lock the walk
if(!m_oldPosition.isInRange(m_position,1,1)) if(!m_oldPosition.isInRange(m_position,1,1))
lockWalk(); lockWalk();
*/
} }
void LocalPlayer::onPositionChange(const Position& newPos, const Position& oldPos) void LocalPlayer::onPositionChange(const Position& newPos, const Position& oldPos)

View File

@ -436,6 +436,7 @@ void Client::registerLuaFunctions()
g_lua.bindClassMemberFunction<Creature>("getSkull", &Creature::getSkull); g_lua.bindClassMemberFunction<Creature>("getSkull", &Creature::getSkull);
g_lua.bindClassMemberFunction<Creature>("getShield", &Creature::getShield); g_lua.bindClassMemberFunction<Creature>("getShield", &Creature::getShield);
g_lua.bindClassMemberFunction<Creature>("getEmblem", &Creature::getEmblem); g_lua.bindClassMemberFunction<Creature>("getEmblem", &Creature::getEmblem);
g_lua.bindClassMemberFunction<Creature>("getIcon", &Creature::getIcon);
g_lua.bindClassMemberFunction<Creature>("setOutfit", &Creature::setOutfit); g_lua.bindClassMemberFunction<Creature>("setOutfit", &Creature::setOutfit);
g_lua.bindClassMemberFunction<Creature>("getOutfit", &Creature::getOutfit); g_lua.bindClassMemberFunction<Creature>("getOutfit", &Creature::getOutfit);
g_lua.bindClassMemberFunction<Creature>("setOutfitColor", &Creature::setOutfitColor); g_lua.bindClassMemberFunction<Creature>("setOutfitColor", &Creature::setOutfitColor);
@ -448,6 +449,7 @@ void Client::registerLuaFunctions()
g_lua.bindClassMemberFunction<Creature>("setSkullTexture", &Creature::setSkullTexture); g_lua.bindClassMemberFunction<Creature>("setSkullTexture", &Creature::setSkullTexture);
g_lua.bindClassMemberFunction<Creature>("setShieldTexture", &Creature::setShieldTexture); g_lua.bindClassMemberFunction<Creature>("setShieldTexture", &Creature::setShieldTexture);
g_lua.bindClassMemberFunction<Creature>("setEmblemTexture", &Creature::setEmblemTexture); g_lua.bindClassMemberFunction<Creature>("setEmblemTexture", &Creature::setEmblemTexture);
g_lua.bindClassMemberFunction<Creature>("setIconTexture", &Creature::setIconTexture);
g_lua.bindClassMemberFunction<Creature>("showStaticSquare", &Creature::showStaticSquare); g_lua.bindClassMemberFunction<Creature>("showStaticSquare", &Creature::showStaticSquare);
g_lua.bindClassMemberFunction<Creature>("hideStaticSquare", &Creature::hideStaticSquare); g_lua.bindClassMemberFunction<Creature>("hideStaticSquare", &Creature::hideStaticSquare);
g_lua.bindClassMemberFunction<Creature>("isWalking", &Creature::isWalking); g_lua.bindClassMemberFunction<Creature>("isWalking", &Creature::isWalking);

View File

@ -28,8 +28,15 @@ std::map<uint8, uint8> messageModesMap;
void buildMessageModesMap(int version) { void buildMessageModesMap(int version) {
messageModesMap.clear(); messageModesMap.clear();
if(version >= 900) { if(version >= 1036) {
for(int i=Otc::MessageNone;i<=Otc::MessageBeyondLast;++i) for(int i = Otc::MessageNone; i <= Otc::MessageBeyondLast; ++i) {
if(i >= Otc::MessageNpcTo)
messageModesMap[i] = i + 1;
else
messageModesMap[i] = i;
}
} else if(version >= 900) {
for(int i = Otc::MessageNone; i <= Otc::MessageBeyondLast; ++i)
messageModesMap[i] = i; messageModesMap[i] = i;
} else if(version >= 861) { } else if(version >= 861) {
messageModesMap[Otc::MessageNone] = 0; messageModesMap[Otc::MessageNone] = 0;

View File

@ -1879,7 +1879,6 @@ CreaturePtr ProtocolGame::getCreature(const InputMessagePtr& msg, int type)
CreaturePtr creature; CreaturePtr creature;
bool known = (type != Proto::UnknownCreature); bool known = (type != Proto::UnknownCreature);
if(type == Proto::OutdatedCreature || type == Proto::UnknownCreature) { if(type == Proto::OutdatedCreature || type == Proto::UnknownCreature) {
if(known) { if(known) {
uint id = msg->getU32(); uint id = msg->getU32();
@ -1944,6 +1943,7 @@ CreaturePtr ProtocolGame::getCreature(const InputMessagePtr& msg, int type)
// emblem is sent only when the creature is not known // emblem is sent only when the creature is not known
int emblem = -1; int emblem = -1;
int icon = -1;
bool unpass = true; bool unpass = true;
uint8 mark; uint8 mark;
@ -1952,6 +1952,13 @@ CreaturePtr ProtocolGame::getCreature(const InputMessagePtr& msg, int type)
if(g_game.getFeature(Otc::GameThingMarks)) { if(g_game.getFeature(Otc::GameThingMarks)) {
msg->getU8(); // creature type for summons msg->getU8(); // creature type for summons
}
if(g_game.getFeature(Otc::GameCreatureIcons)) {
icon = msg->getU8();
}
if(g_game.getFeature(Otc::GameThingMarks)) {
mark = msg->getU8(); // mark mark = msg->getU8(); // mark
msg->getU16(); // helpers msg->getU16(); // helpers
@ -1977,6 +1984,8 @@ CreaturePtr ProtocolGame::getCreature(const InputMessagePtr& msg, int type)
creature->setLight(light); creature->setLight(light);
if(emblem != -1) if(emblem != -1)
creature->setEmblem(emblem); creature->setEmblem(emblem);
if(icon != -1)
creature->setIcon(icon);
if(creature == m_localPlayer && !m_localPlayer->isKnown()) if(creature == m_localPlayer && !m_localPlayer->isKnown())
m_localPlayer->setKnown(true); m_localPlayer->setKnown(true);