Browse Source

Fixed baseSpeed not being parsed (10.59+)

TheSumm 6 years ago
parent
commit
63f95317a2

+ 9
- 0
src/client/creature.cpp View File

@@ -696,6 +696,15 @@ void Creature::setSpeed(uint16 speed)
696 696
     callLuaField("onSpeedChange", m_speed, oldSpeed);
697 697
 }
698 698
 
699
+void Creature::setBaseSpeed(double baseSpeed)
700
+{
701
+    if(m_baseSpeed != baseSpeed) {
702
+        double oldBaseSpeed = m_baseSpeed;
703
+        m_baseSpeed = baseSpeed;
704
+
705
+        callLuaField("onBaseSpeedChange", baseSpeed, oldBaseSpeed);
706
+    }
707
+}
699 708
 void Creature::setSkull(uint8 skull)
700 709
 {
701 710
     m_skull = skull;

+ 3
- 0
src/client/creature.h View File

@@ -58,6 +58,7 @@ public:
58 58
     void setOutfitColor(const Color& color, int duration);
59 59
     void setLight(const Light& light) { m_light = light; }
60 60
     void setSpeed(uint16 speed);
61
+    void setBaseSpeed(double baseSpeed);
61 62
     void setSkull(uint8 skull);
62 63
     void setShield(uint8 shield);
63 64
     void setEmblem(uint8 emblem);
@@ -82,6 +83,7 @@ public:
82 83
     Outfit getOutfit() { return m_outfit; }
83 84
     Light getLight() { return m_light; }
84 85
     uint16 getSpeed() { return m_speed; }
86
+    double getBaseSpeed() { return m_baseSpeed; }
85 87
     uint8 getSkull() { return m_skull; }
86 88
     uint8 getShield() { return m_shield; }
87 89
     uint8 getEmblem() { return m_emblem; }
@@ -147,6 +149,7 @@ protected:
147 149
     Outfit m_outfit;
148 150
     Light m_light;
149 151
     int m_speed;
152
+    double m_baseSpeed;
150 153
     uint8 m_skull;
151 154
     uint8 m_shield;
152 155
     uint8 m_emblem;

+ 0
- 10
src/client/localplayer.cpp View File

@@ -507,16 +507,6 @@ void LocalPlayer::setPremium(bool premium)
507 507
     }
508 508
 }
509 509
 
510
-void LocalPlayer::setBaseSpeed(double baseSpeed)
511
-{
512
-    if(m_baseSpeed != baseSpeed) {
513
-        double oldBaseSpeed = m_baseSpeed;
514
-        m_baseSpeed = baseSpeed;
515
-
516
-        callLuaField("onBaseSpeedChange", baseSpeed, oldBaseSpeed);
517
-    }
518
-}
519
-
520 510
 void LocalPlayer::setRegenerationTime(double regenerationTime)
521 511
 {
522 512
     if(m_regenerationTime != regenerationTime) {

+ 0
- 3
src/client/localplayer.h View File

@@ -59,7 +59,6 @@ public:
59 59
     void setInventoryItem(Otc::InventorySlot inventory, const ItemPtr& item);
60 60
     void setVocation(int vocation);
61 61
     void setPremium(bool premium);
62
-    void setBaseSpeed(double baseSpeed);
63 62
     void setRegenerationTime(double regenerationTime);
64 63
     void setOfflineTrainingTime(double offlineTrainingTime);
65 64
     void setSpells(const std::vector<int>& spells);
@@ -84,7 +83,6 @@ public:
84 83
     double getBaseMagicLevel() { return m_baseMagicLevel; }
85 84
     double getSoul() { return m_soul; }
86 85
     double getStamina() { return m_stamina; }
87
-    double getBaseSpeed() { return m_baseSpeed; }
88 86
     double getRegenerationTime() { return m_regenerationTime; }
89 87
     double getOfflineTrainingTime() { return m_offlineTrainingTime; }
90 88
     std::vector<int> getSpells() { return m_spells; }
@@ -162,7 +160,6 @@ private:
162 160
     double m_baseMagicLevel;
163 161
     double m_soul;
164 162
     double m_stamina;
165
-    double m_baseSpeed;
166 163
     double m_regenerationTime;
167 164
     double m_offlineTrainingTime;
168 165
 };

+ 1
- 3
src/client/luafunctions.cpp View File

@@ -238,9 +238,7 @@ void Client::registerLuaFunctions()
238 238
     g_lua.bindSingletonFunction("g_game", "getChaseMode", &Game::getChaseMode, &g_game);
239 239
     g_lua.bindSingletonFunction("g_game", "getFightMode", &Game::getFightMode, &g_game);
240 240
     g_lua.bindSingletonFunction("g_game", "getPVPMode", &Game::getPVPMode, &g_game);
241
-    g_lua.bindSingletonFunction("g_game", "setUnjustifiedPoints", &Game::setUnjustifiedPoints, &g_game);
242 241
     g_lua.bindSingletonFunction("g_game", "getUnjustifiedPoints", &Game::getUnjustifiedPoints, &g_game);
243
-    g_lua.bindSingletonFunction("g_game", "setOpenPvpSituations", &Game::setOpenPvpSituations, &g_game);
244 242
     g_lua.bindSingletonFunction("g_game", "getOpenPvpSituations", &Game::getOpenPvpSituations, &g_game);
245 243
     g_lua.bindSingletonFunction("g_game", "isSafeFight", &Game::isSafeFight, &g_game);
246 244
     g_lua.bindSingletonFunction("g_game", "inspectNpcTrade", &Game::inspectNpcTrade, &g_game);
@@ -444,6 +442,7 @@ void Client::registerLuaFunctions()
444 442
     g_lua.bindClassMemberFunction<Creature>("getName", &Creature::getName);
445 443
     g_lua.bindClassMemberFunction<Creature>("getHealthPercent", &Creature::getHealthPercent);
446 444
     g_lua.bindClassMemberFunction<Creature>("getSpeed", &Creature::getSpeed);
445
+    g_lua.bindClassMemberFunction<Creature>("getBaseSpeed", &Creature::getBaseSpeed);
447 446
     g_lua.bindClassMemberFunction<Creature>("getSkull", &Creature::getSkull);
448 447
     g_lua.bindClassMemberFunction<Creature>("getShield", &Creature::getShield);
449 448
     g_lua.bindClassMemberFunction<Creature>("getEmblem", &Creature::getEmblem);
@@ -630,7 +629,6 @@ void Client::registerLuaFunctions()
630 629
     g_lua.bindClassMemberFunction<LocalPlayer>("getStamina", &LocalPlayer::getStamina);
631 630
     g_lua.bindClassMemberFunction<LocalPlayer>("getOfflineTrainingTime", &LocalPlayer::getOfflineTrainingTime);
632 631
     g_lua.bindClassMemberFunction<LocalPlayer>("getRegenerationTime", &LocalPlayer::getRegenerationTime);
633
-    g_lua.bindClassMemberFunction<LocalPlayer>("getBaseSpeed", &LocalPlayer::getBaseSpeed);
634 632
     g_lua.bindClassMemberFunction<LocalPlayer>("getBaseMagicLevel", &LocalPlayer::getBaseMagicLevel);
635 633
     g_lua.bindClassMemberFunction<LocalPlayer>("getTotalCapacity", &LocalPlayer::getTotalCapacity);
636 634
     g_lua.bindClassMemberFunction<LocalPlayer>("getInventoryItem", &LocalPlayer::getInventoryItem);

+ 9
- 1
src/client/protocolgameparse.cpp View File

@@ -1004,11 +1004,19 @@ void ProtocolGame::parseCreatureOutfit(const InputMessagePtr& msg)
1004 1004
 void ProtocolGame::parseCreatureSpeed(const InputMessagePtr& msg)
1005 1005
 {
1006 1006
     uint id = msg->getU32();
1007
+
1008
+    int baseSpeed = -1;
1009
+    if(g_game.getClientVersion() >= 1059)
1010
+        baseSpeed = msg->getU16();
1011
+
1007 1012
     int speed = msg->getU16();
1008 1013
 
1009 1014
     CreaturePtr creature = g_map.getCreatureById(id);
1010
-    if(creature)
1015
+    if(creature) {
1011 1016
         creature->setSpeed(speed);
1017
+        if(baseSpeed != -1)
1018
+            creature->setBaseSpeed(baseSpeed);
1019
+    }
1012 1020
 
1013 1021
     // some servers has a bug in get spectators and sends unknown creatures updates
1014 1022
     // so this code is disabled

Loading…
Cancel
Save