Fix compability with some servers fly systems

This commit is contained in:
Eduardo Bart 2012-08-03 00:05:13 -03:00
parent ea2fa55a25
commit 06388c5673
5 changed files with 20 additions and 11 deletions

View File

@ -481,10 +481,9 @@ void Game::walk(Otc::Direction direction)
Position pos = toPos; Position pos = toPos;
if(!pos.down()) if(!pos.down())
return false; return false;
toTile = g_map.getTile(pos); TilePtr toTile = g_map.getTile(pos);
if(toTile && toTile->hasElevation(3)) { if(toTile && toTile->hasElevation(3))
return true; return true;
}
return false; return false;
}; };
@ -496,13 +495,14 @@ void Game::walk(Otc::Direction direction)
Position pos = toPos; Position pos = toPos;
if(!pos.up()) if(!pos.up())
return false; return false;
toTile = g_map.getTile(pos); TilePtr toTile = g_map.getTile(pos);
if(!toTile || !toTile->isWalkable()) if(!toTile || !toTile->isWalkable())
return false; return false;
return true; return true;
}; };
if(canChangeFloorDown() || canChangeFloorUp()) { if(canChangeFloorDown() || canChangeFloorUp() ||
(!toTile || toTile->isEmpty())) {
m_localPlayer->lockWalk(); m_localPlayer->lockWalk();
} else } else
return; return;

View File

@ -312,7 +312,7 @@ void MapView::updateVisibleTilesCache(int start)
tilePos.coveredUp(cameraPosition.z - iz); tilePos.coveredUp(cameraPosition.z - iz);
if(const TilePtr& tile = g_map.getTile(tilePos)) { if(const TilePtr& tile = g_map.getTile(tilePos)) {
// skip tiles that have nothing // skip tiles that have nothing
if(tile->isEmpty()) if(!tile->isDrawable())
continue; continue;
// skip tiles that are completely behind another tile // skip tiles that are completely behind another tile
if(g_map.isCompletelyCovered(tilePos, m_cachedFirstVisibleFloor)) if(g_map.isCompletelyCovered(tilePos, m_cachedFirstVisibleFloor))
@ -366,7 +366,7 @@ void MapView::updateVisibleTilesCache(int start)
Position tilePos = cameraPosition.translated(p.x - m_virtualCenterOffset.x, p.y - m_virtualCenterOffset.y); Position tilePos = cameraPosition.translated(p.x - m_virtualCenterOffset.x, p.y - m_virtualCenterOffset.y);
tilePos.coveredUp(cameraPosition.z - iz); tilePos.coveredUp(cameraPosition.z - iz);
if(const TilePtr& tile = g_map.getTile(tilePos)) { if(const TilePtr& tile = g_map.getTile(tilePos)) {
if(!tile->isEmpty()) if(tile->isDrawable())
m_cachedVisibleTiles.push_back(tile); m_cachedVisibleTiles.push_back(tile);
} }
} }

View File

@ -60,12 +60,15 @@ void ProtocolGame::onRecv(const InputMessagePtr& inputMessage)
{ {
if(m_firstRecv) { if(m_firstRecv) {
m_firstRecv = false; m_firstRecv = false;
if(g_game.getClientVersion() > 810) {
int size = inputMessage->getU16(); int size = inputMessage->getU16();
if(size != inputMessage->getUnreadSize()) { if(size != inputMessage->getUnreadSize()) {
g_logger.traceError("invalid message size"); g_logger.traceError("invalid message size");
return; return;
} }
} }
}
parseMessage(inputMessage); parseMessage(inputMessage);
recv(); recv();

View File

@ -504,6 +504,11 @@ bool Tile::isEmpty()
return m_things.size() == 0; return m_things.size() == 0;
} }
bool Tile::isDrawable()
{
return !m_things.empty() || !m_walkingCreatures.empty() || !m_effects.empty();
}
bool Tile::mustHookEast() bool Tile::mustHookEast()
{ {
for(const ThingPtr& thing : m_things) for(const ThingPtr& thing : m_things)

View File

@ -98,6 +98,7 @@ public:
bool isLookPossible(); bool isLookPossible();
bool isClickable(); bool isClickable();
bool isEmpty(); bool isEmpty();
bool isDrawable();
bool mustHookSouth(); bool mustHookSouth();
bool mustHookEast(); bool mustHookEast();
bool hasCreature(); bool hasCreature();