Browse Source

Properly check tile elevation in older protocols

Marcin Michalski 5 years ago
parent
commit
13789c5612
4 changed files with 19 additions and 7 deletions
  1. 6
    0
      src/client/game.cpp
  2. 3
    0
      src/client/localplayer.cpp
  3. 9
    7
      src/client/tile.cpp
  4. 1
    0
      src/client/tile.h

+ 6
- 0
src/client/game.cpp View File

@@ -654,6 +654,12 @@ bool Game::walk(Otc::Direction direction, bool dash)
654 654
 
655 655
     m_localPlayer->stopAutoWalk();
656 656
 
657
+    if(getClientVersion() <= 740) {
658
+        const TilePtr& fromTile = g_map.getTile(m_localPlayer->getPosition());
659
+        if (fromTile && toTile && (toTile->getElevation() - 1 > fromTile->getElevation()))
660
+            return false;
661
+    }
662
+
657 663
     g_lua.callGlobalField("g_game", "onWalk", direction, dash);
658 664
 
659 665
     forceWalk(direction);

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

@@ -166,6 +166,9 @@ void LocalPlayer::cancelWalk(Otc::Direction direction)
166 166
 
167 167
 bool LocalPlayer::autoWalk(const Position& destination)
168 168
 {
169
+    if(g_game.getClientVersion() <= 740 && m_position.isInRange(destination, 1, 1))
170
+        return g_game.walk(m_position.getDirectionFromPosition(destination));
171
+
169 172
     bool tryKnownPath = false;
170 173
     if(destination != m_autoWalkDestination) {
171 174
         m_knownCompletePath = false;

+ 9
- 7
src/client/tile.cpp View File

@@ -509,9 +509,6 @@ bool Tile::isWalkable(bool ignoreCreatures)
509 509
     if(!getGround())
510 510
         return false;
511 511
 
512
-    if(g_game.getClientVersion() <= 740 && hasElevation(2))
513
-        return false;
514
-
515 512
     for(const ThingPtr& thing : m_things) {
516 513
         if(thing->isNotWalkable())
517 514
             return false;
@@ -636,13 +633,18 @@ bool Tile::canErase()
636 633
     return m_walkingCreatures.empty() && m_effects.empty() && m_things.empty() && m_flags == 0 && m_minimapColor == 0;
637 634
 }
638 635
 
639
-bool Tile::hasElevation(int elevation)
636
+int Tile::getElevation() const
640 637
 {
641
-    int count = 0;
638
+    int elevation = 0;
642 639
     for(const ThingPtr& thing : m_things)
643 640
         if(thing->getElevation() > 0)
644
-            count++;
645
-    return count >= elevation;
641
+            elevation++;
642
+    return elevation;
643
+}
644
+
645
+bool Tile::hasElevation(int elevation)
646
+{
647
+    return getElevation() >= elevation;
646 648
 }
647 649
 
648 650
 void Tile::checkTranslucentLight()

+ 1
- 0
src/client/tile.h View File

@@ -109,6 +109,7 @@ public:
109 109
     bool hasCreature();
110 110
     bool limitsFloorsView(bool isFreeView = false);
111 111
     bool canErase();
112
+    int getElevation() const;
112 113
     bool hasElevation(int elevation = 1);
113 114
     void overwriteMinimapColor(uint8 color) { m_minimapColor = color; }
114 115
 

Loading…
Cancel
Save