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

View File

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

View File

@@ -53,6 +53,7 @@ Creature::Creature() : Thing()
m_skull = Otc::SkullNone;
m_shield = Otc::ShieldNone;
m_emblem = Otc::EmblemNone;
m_icon = Otc::NpcIconNone;
m_lastStepDirection = Otc::InvalidDirection;
m_nameCache.setFont(g_fonts.getFont("verdana-11px-rounded"));
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)
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->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());
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)
@@ -708,6 +714,12 @@ void Creature::setEmblem(uint8 emblem)
callLuaField("onEmblemChange", m_emblem);
}
void Creature::setIcon(uint8 icon)
{
m_icon = icon;
callLuaField("onIconChange", m_icon);
}
void Creature::setSkullTexture(const std::string& filename)
{
m_skullTexture = g_textures.getTexture(filename);
@@ -733,6 +745,12 @@ void Creature::setEmblemTexture(const std::string& 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)
{
m_speedFormula[Otc::SpeedFormulaA] = speedA;

View File

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

View File

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

View File

@@ -297,9 +297,11 @@ void LocalPlayer::onAppear()
{
Creature::onAppear();
/* Does not seem to be needed anymore
// on teleports lock the walk
if(!m_oldPosition.isInRange(m_position,1,1))
lockWalk();
*/
}
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>("getShield", &Creature::getShield);
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>("getOutfit", &Creature::getOutfit);
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>("setShieldTexture", &Creature::setShieldTexture);
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>("hideStaticSquare", &Creature::hideStaticSquare);
g_lua.bindClassMemberFunction<Creature>("isWalking", &Creature::isWalking);

View File

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

View File

@@ -1879,7 +1879,6 @@ CreaturePtr ProtocolGame::getCreature(const InputMessagePtr& msg, int type)
CreaturePtr creature;
bool known = (type != Proto::UnknownCreature);
if(type == Proto::OutdatedCreature || type == Proto::UnknownCreature) {
if(known) {
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
int emblem = -1;
int icon = -1;
bool unpass = true;
uint8 mark;
@@ -1952,6 +1952,13 @@ CreaturePtr ProtocolGame::getCreature(const InputMessagePtr& msg, int type)
if(g_game.getFeature(Otc::GameThingMarks)) {
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
msg->getU16(); // helpers
@@ -1977,6 +1984,8 @@ CreaturePtr ProtocolGame::getCreature(const InputMessagePtr& msg, int type)
creature->setLight(light);
if(emblem != -1)
creature->setEmblem(emblem);
if(icon != -1)
creature->setIcon(icon);
if(creature == m_localPlayer && !m_localPlayer->isKnown())
m_localPlayer->setKnown(true);