From 11387eb08f377f3a1a4f38bbe16ba64944c136a0 Mon Sep 17 00:00:00 2001 From: Eduardo Bart Date: Thu, 2 Aug 2012 11:47:32 -0300 Subject: [PATCH] Fix floor change stackpos bug? --- src/otclient/map.cpp | 8 ++++---- src/otclient/protocolgameparse.cpp | 7 +------ src/otclient/tile.cpp | 6 ++++++ 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/otclient/map.cpp b/src/otclient/map.cpp index 28764f87..95225815 100644 --- a/src/otclient/map.cpp +++ b/src/otclient/map.cpp @@ -183,7 +183,7 @@ bool Map::removeThingByPos(const Position& pos, int stackPos) const TilePtr& Map::createTile(const Position& pos) { - if(!pos.isValid()) + if(!pos.isMapPosition()) return m_nulltile; if(pos.x < m_tilesRect.left()) m_tilesRect.setLeft(pos.x); @@ -212,7 +212,7 @@ const TilePtr& Map::createTileEx(const Position& pos, const Items&... items) const TilePtr& Map::getOrCreateTile(const Position& pos) { - if(!pos.isValid()) + if(!pos.isMapPosition()) return m_nulltile; if(pos.x < m_tilesRect.left()) m_tilesRect.setLeft(pos.x); @@ -228,7 +228,7 @@ const TilePtr& Map::getOrCreateTile(const Position& pos) const TilePtr& Map::getTile(const Position& pos) { - if(!pos.isValid()) + if(!pos.isMapPosition()) return m_nulltile; auto it = m_tileBlocks[pos.z].find(getBlockIndex(pos)); if(it != m_tileBlocks[pos.z].end()) @@ -238,7 +238,7 @@ const TilePtr& Map::getTile(const Position& pos) void Map::cleanTile(const Position& pos) { - if(!pos.isValid()) + if(!pos.isMapPosition()) return; auto it = m_tileBlocks[pos.z].find(getBlockIndex(pos)); if(it != m_tileBlocks[pos.z].end()) { diff --git a/src/otclient/protocolgameparse.cpp b/src/otclient/protocolgameparse.cpp index c3b88a42..1a32a08d 100644 --- a/src/otclient/protocolgameparse.cpp +++ b/src/otclient/protocolgameparse.cpp @@ -499,13 +499,8 @@ void ProtocolGame::parseCreatureMove(const InputMessagePtr& msg) return; } - int stackPos = -2; - // newer protocols stores creatures in reverse order - if(!g_game.getClientVersion() >= 854) - stackPos = -1; - g_map.removeThing(thing); - g_map.addThing(thing, newPos, stackPos); + g_map.addThing(thing, newPos, -1); } void ProtocolGame::parseOpenContainer(const InputMessagePtr& msg) diff --git a/src/otclient/tile.cpp b/src/otclient/tile.cpp index bf78578b..1e5ae53e 100644 --- a/src/otclient/tile.cpp +++ b/src/otclient/tile.cpp @@ -167,7 +167,13 @@ void Tile::addThing(const ThingPtr& thing, int stackPos) // 5 - items, from top to bottom if(stackPos < 0 || stackPos == 255) { int priority = thing->getStackPriority(); + bool prepend = (stackPos == -2 || priority <= 3); + + // newer protocols does not store creatures in reverse order + if(g_game.getClientVersion() >= 854 && priority == 4) + prepend = !prepend; + for(stackPos = 0; stackPos < (int)m_things.size(); ++stackPos) { int otherPriority = m_things[stackPos]->getStackPriority(); if((prepend && otherPriority > priority) || (!prepend && otherPriority >= priority))