From 1b0c527ad6eed22ae82c41bd60edc3036f6130e3 Mon Sep 17 00:00:00 2001 From: Eduardo Bart Date: Sun, 15 Jul 2012 03:16:40 -0300 Subject: [PATCH] Fix Thing::getTopThing --- src/framework/luaengine/luaobject.h | 2 ++ src/otclient/tile.cpp | 22 +++------------------- 2 files changed, 5 insertions(+), 19 deletions(-) diff --git a/src/framework/luaengine/luaobject.h b/src/framework/luaengine/luaobject.h index e7722dad..dd694148 100644 --- a/src/framework/luaengine/luaobject.h +++ b/src/framework/luaengine/luaobject.h @@ -82,6 +82,8 @@ public: LuaObjectPtr asLuaObject() { return shared_from_this(); } + void operator=(const LuaObject& other) { } + private: int m_fieldsTableRef; int m_metatableRef; diff --git a/src/otclient/tile.cpp b/src/otclient/tile.cpp index b0ad32bc..7c58beff 100644 --- a/src/otclient/tile.cpp +++ b/src/otclient/tile.cpp @@ -171,9 +171,9 @@ ThingPtr Tile::addThing(const ThingPtr& thing, int stackPos) // 4 - creatures, from top to bottom // 5 - items, from top to bottom if(stackPos < 0) { - bool prepend = (stackPos == -2); stackPos = 0; int priority = thing->getStackPriority(); + bool prepend = (stackPos == -2 || priority <= 3); for(stackPos = 0; stackPos < (int)m_things.size(); ++stackPos) { int otherPriority = m_things[stackPos]->getStackPriority(); if(!g_game.getFeature(Otc::GameReverseCreatureStack)) { @@ -257,28 +257,12 @@ int Tile::getThingStackpos(const ThingPtr& thing) ThingPtr Tile:: getTopThing() { + if(isEmpty()) + return nullptr; for(const ThingPtr& thing : m_things) { if(!thing->isGround() && !thing->isGroundBorder() && !thing->isOnBottom() && !thing->isOnTop() && !thing->isCreature()) return thing; } - for(const ThingPtr& thing : m_things) { - if(!thing->isGround() && !thing->isGroundBorder() && !thing->isOnBottom() && !thing->isOnTop()) - return thing; - } - for(const ThingPtr& thing : m_things) { - if(!thing->isGround() && !thing->isGroundBorder() && !thing->isOnBottom()) - return thing; - } - for(const ThingPtr& thing : m_things) { - if(!thing->isGround() && !thing->isGroundBorder()) - return thing; - } - for(const ThingPtr& thing : m_things) { - if(!thing->isGround()) - return thing; - } - if(isEmpty()) - return nullptr; return m_things[m_things.size() - 1]; }