diff --git a/src/otclient/map.cpp b/src/otclient/map.cpp index 3d36ef50..0ad5d238 100644 --- a/src/otclient/map.cpp +++ b/src/otclient/map.cpp @@ -305,6 +305,7 @@ void Map::setCentralPosition(const Position& centralPosition) localPlayer->onDisappear(); localPlayer->setPosition(pos); localPlayer->onAppear(); + g_logger.debug("forced player position update"); } }); diff --git a/src/otclient/protocolgameparse.cpp b/src/otclient/protocolgameparse.cpp index 21f434e0..42c063c2 100644 --- a/src/otclient/protocolgameparse.cpp +++ b/src/otclient/protocolgameparse.cpp @@ -497,7 +497,8 @@ void ProtocolGame::parseTileRemoveThing(const InputMessagePtr& msg) return; } - g_map.removeThing(thing); + if(!g_map.removeThing(thing)) + g_logger.traceError("unable to remove thing"); } void ProtocolGame::parseCreatureMove(const InputMessagePtr& msg) @@ -510,7 +511,11 @@ void ProtocolGame::parseCreatureMove(const InputMessagePtr& msg) return; } - g_map.removeThing(thing); + if(!g_map.removeThing(thing)) { + g_logger.traceError("unable to remove creature"); + return; + } + g_map.addThing(thing, newPos, -1); } @@ -1399,7 +1404,7 @@ int ProtocolGame::setTileDescription(const InputMessagePtr& msg, Position positi g_logger.traceError(stdext::format("too many things, pos=%s, stackpos=%d", stdext::to_string(position), stackPos)); ThingPtr thing = getThing(msg); - g_map.addThing(thing, position, -2); + g_map.addThing(thing, position, stackPos); } return 0; diff --git a/src/otclient/tile.cpp b/src/otclient/tile.cpp index abb8dbab..3b560ff0 100644 --- a/src/otclient/tile.cpp +++ b/src/otclient/tile.cpp @@ -171,14 +171,17 @@ void Tile::addThing(const ThingPtr& thing, int stackPos) // -1 or 255 => auto detect position // -2 => append - bool append = (stackPos == -2 || priority <= 3); - - // newer protocols does not store creatures in reverse order - if(g_game.getClientVersion() >= 854 && priority == 4) - append = !append; + bool append; + if(stackPos == -2) + append = true; + else { + append = (priority <= 3); + + // newer protocols does not store creatures in reverse order + if(g_game.getClientVersion() >= 854 && priority == 4) + append = !append; + } - if(g_game.getClientVersion() < 900 && priority == 4 && stackPos == -2) - append = !append; for(stackPos = 0; stackPos < (int)m_things.size(); ++stackPos) { int otherPriority = m_things[stackPos]->getStackPriority();