Fixed baseSpeed not being parsed (10.59+)

This commit is contained in:
TheSumm 2015-01-19 01:08:18 +01:00
parent 26fb35fd4d
commit 63f95317a2
6 changed files with 22 additions and 17 deletions

View File

@ -696,6 +696,15 @@ void Creature::setSpeed(uint16 speed)
callLuaField("onSpeedChange", m_speed, oldSpeed);
}
void Creature::setBaseSpeed(double baseSpeed)
{
if(m_baseSpeed != baseSpeed) {
double oldBaseSpeed = m_baseSpeed;
m_baseSpeed = baseSpeed;
callLuaField("onBaseSpeedChange", baseSpeed, oldBaseSpeed);
}
}
void Creature::setSkull(uint8 skull)
{
m_skull = skull;

View File

@ -58,6 +58,7 @@ public:
void setOutfitColor(const Color& color, int duration);
void setLight(const Light& light) { m_light = light; }
void setSpeed(uint16 speed);
void setBaseSpeed(double baseSpeed);
void setSkull(uint8 skull);
void setShield(uint8 shield);
void setEmblem(uint8 emblem);
@ -82,6 +83,7 @@ public:
Outfit getOutfit() { return m_outfit; }
Light getLight() { return m_light; }
uint16 getSpeed() { return m_speed; }
double getBaseSpeed() { return m_baseSpeed; }
uint8 getSkull() { return m_skull; }
uint8 getShield() { return m_shield; }
uint8 getEmblem() { return m_emblem; }
@ -147,6 +149,7 @@ protected:
Outfit m_outfit;
Light m_light;
int m_speed;
double m_baseSpeed;
uint8 m_skull;
uint8 m_shield;
uint8 m_emblem;

View File

@ -507,16 +507,6 @@ void LocalPlayer::setPremium(bool premium)
}
}
void LocalPlayer::setBaseSpeed(double baseSpeed)
{
if(m_baseSpeed != baseSpeed) {
double oldBaseSpeed = m_baseSpeed;
m_baseSpeed = baseSpeed;
callLuaField("onBaseSpeedChange", baseSpeed, oldBaseSpeed);
}
}
void LocalPlayer::setRegenerationTime(double regenerationTime)
{
if(m_regenerationTime != regenerationTime) {

View File

@ -59,7 +59,6 @@ public:
void setInventoryItem(Otc::InventorySlot inventory, const ItemPtr& item);
void setVocation(int vocation);
void setPremium(bool premium);
void setBaseSpeed(double baseSpeed);
void setRegenerationTime(double regenerationTime);
void setOfflineTrainingTime(double offlineTrainingTime);
void setSpells(const std::vector<int>& spells);
@ -84,7 +83,6 @@ public:
double getBaseMagicLevel() { return m_baseMagicLevel; }
double getSoul() { return m_soul; }
double getStamina() { return m_stamina; }
double getBaseSpeed() { return m_baseSpeed; }
double getRegenerationTime() { return m_regenerationTime; }
double getOfflineTrainingTime() { return m_offlineTrainingTime; }
std::vector<int> getSpells() { return m_spells; }
@ -162,7 +160,6 @@ private:
double m_baseMagicLevel;
double m_soul;
double m_stamina;
double m_baseSpeed;
double m_regenerationTime;
double m_offlineTrainingTime;
};

View File

@ -238,9 +238,7 @@ void Client::registerLuaFunctions()
g_lua.bindSingletonFunction("g_game", "getChaseMode", &Game::getChaseMode, &g_game);
g_lua.bindSingletonFunction("g_game", "getFightMode", &Game::getFightMode, &g_game);
g_lua.bindSingletonFunction("g_game", "getPVPMode", &Game::getPVPMode, &g_game);
g_lua.bindSingletonFunction("g_game", "setUnjustifiedPoints", &Game::setUnjustifiedPoints, &g_game);
g_lua.bindSingletonFunction("g_game", "getUnjustifiedPoints", &Game::getUnjustifiedPoints, &g_game);
g_lua.bindSingletonFunction("g_game", "setOpenPvpSituations", &Game::setOpenPvpSituations, &g_game);
g_lua.bindSingletonFunction("g_game", "getOpenPvpSituations", &Game::getOpenPvpSituations, &g_game);
g_lua.bindSingletonFunction("g_game", "isSafeFight", &Game::isSafeFight, &g_game);
g_lua.bindSingletonFunction("g_game", "inspectNpcTrade", &Game::inspectNpcTrade, &g_game);
@ -444,6 +442,7 @@ void Client::registerLuaFunctions()
g_lua.bindClassMemberFunction<Creature>("getName", &Creature::getName);
g_lua.bindClassMemberFunction<Creature>("getHealthPercent", &Creature::getHealthPercent);
g_lua.bindClassMemberFunction<Creature>("getSpeed", &Creature::getSpeed);
g_lua.bindClassMemberFunction<Creature>("getBaseSpeed", &Creature::getBaseSpeed);
g_lua.bindClassMemberFunction<Creature>("getSkull", &Creature::getSkull);
g_lua.bindClassMemberFunction<Creature>("getShield", &Creature::getShield);
g_lua.bindClassMemberFunction<Creature>("getEmblem", &Creature::getEmblem);
@ -630,7 +629,6 @@ void Client::registerLuaFunctions()
g_lua.bindClassMemberFunction<LocalPlayer>("getStamina", &LocalPlayer::getStamina);
g_lua.bindClassMemberFunction<LocalPlayer>("getOfflineTrainingTime", &LocalPlayer::getOfflineTrainingTime);
g_lua.bindClassMemberFunction<LocalPlayer>("getRegenerationTime", &LocalPlayer::getRegenerationTime);
g_lua.bindClassMemberFunction<LocalPlayer>("getBaseSpeed", &LocalPlayer::getBaseSpeed);
g_lua.bindClassMemberFunction<LocalPlayer>("getBaseMagicLevel", &LocalPlayer::getBaseMagicLevel);
g_lua.bindClassMemberFunction<LocalPlayer>("getTotalCapacity", &LocalPlayer::getTotalCapacity);
g_lua.bindClassMemberFunction<LocalPlayer>("getInventoryItem", &LocalPlayer::getInventoryItem);

View File

@ -1004,11 +1004,19 @@ void ProtocolGame::parseCreatureOutfit(const InputMessagePtr& msg)
void ProtocolGame::parseCreatureSpeed(const InputMessagePtr& msg)
{
uint id = msg->getU32();
int baseSpeed = -1;
if(g_game.getClientVersion() >= 1059)
baseSpeed = msg->getU16();
int speed = msg->getU16();
CreaturePtr creature = g_map.getCreatureById(id);
if(creature)
if(creature) {
creature->setSpeed(speed);
if(baseSpeed != -1)
creature->setBaseSpeed(baseSpeed);
}
// some servers has a bug in get spectators and sends unknown creatures updates
// so this code is disabled