Properly check tile elevation in older protocols

This commit is contained in:
Marcin Michalski 2016-01-28 16:35:08 +01:00 committed by Eduardo Bart
parent 7046fa1cdb
commit 13789c5612
4 changed files with 19 additions and 7 deletions

View File

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

View File

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

View File

@ -509,9 +509,6 @@ bool Tile::isWalkable(bool ignoreCreatures)
if(!getGround()) if(!getGround())
return false; return false;
if(g_game.getClientVersion() <= 740 && hasElevation(2))
return false;
for(const ThingPtr& thing : m_things) { for(const ThingPtr& thing : m_things) {
if(thing->isNotWalkable()) if(thing->isNotWalkable())
return false; return false;
@ -636,13 +633,18 @@ bool Tile::canErase()
return m_walkingCreatures.empty() && m_effects.empty() && m_things.empty() && m_flags == 0 && m_minimapColor == 0; return m_walkingCreatures.empty() && m_effects.empty() && m_things.empty() && m_flags == 0 && m_minimapColor == 0;
} }
bool Tile::hasElevation(int elevation) int Tile::getElevation() const
{ {
int count = 0; int elevation = 0;
for(const ThingPtr& thing : m_things) for(const ThingPtr& thing : m_things)
if(thing->getElevation() > 0) if(thing->getElevation() > 0)
count++; elevation++;
return count >= elevation; return elevation;
}
bool Tile::hasElevation(int elevation)
{
return getElevation() >= elevation;
} }
void Tile::checkTranslucentLight() void Tile::checkTranslucentLight()

View File

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