Fix Thing::getTopThing
This commit is contained in:
parent
98c4240446
commit
1b0c527ad6
|
@ -82,6 +82,8 @@ public:
|
||||||
|
|
||||||
LuaObjectPtr asLuaObject() { return shared_from_this(); }
|
LuaObjectPtr asLuaObject() { return shared_from_this(); }
|
||||||
|
|
||||||
|
void operator=(const LuaObject& other) { }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int m_fieldsTableRef;
|
int m_fieldsTableRef;
|
||||||
int m_metatableRef;
|
int m_metatableRef;
|
||||||
|
|
|
@ -171,9 +171,9 @@ ThingPtr Tile::addThing(const ThingPtr& thing, int stackPos)
|
||||||
// 4 - creatures, from top to bottom
|
// 4 - creatures, from top to bottom
|
||||||
// 5 - items, from top to bottom
|
// 5 - items, from top to bottom
|
||||||
if(stackPos < 0) {
|
if(stackPos < 0) {
|
||||||
bool prepend = (stackPos == -2);
|
|
||||||
stackPos = 0;
|
stackPos = 0;
|
||||||
int priority = thing->getStackPriority();
|
int priority = thing->getStackPriority();
|
||||||
|
bool prepend = (stackPos == -2 || priority <= 3);
|
||||||
for(stackPos = 0; stackPos < (int)m_things.size(); ++stackPos) {
|
for(stackPos = 0; stackPos < (int)m_things.size(); ++stackPos) {
|
||||||
int otherPriority = m_things[stackPos]->getStackPriority();
|
int otherPriority = m_things[stackPos]->getStackPriority();
|
||||||
if(!g_game.getFeature(Otc::GameReverseCreatureStack)) {
|
if(!g_game.getFeature(Otc::GameReverseCreatureStack)) {
|
||||||
|
@ -257,28 +257,12 @@ int Tile::getThingStackpos(const ThingPtr& thing)
|
||||||
|
|
||||||
ThingPtr Tile:: getTopThing()
|
ThingPtr Tile:: getTopThing()
|
||||||
{
|
{
|
||||||
|
if(isEmpty())
|
||||||
|
return nullptr;
|
||||||
for(const ThingPtr& thing : m_things) {
|
for(const ThingPtr& thing : m_things) {
|
||||||
if(!thing->isGround() && !thing->isGroundBorder() && !thing->isOnBottom() && !thing->isOnTop() && !thing->isCreature())
|
if(!thing->isGround() && !thing->isGroundBorder() && !thing->isOnBottom() && !thing->isOnTop() && !thing->isCreature())
|
||||||
return thing;
|
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];
|
return m_things[m_things.size() - 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue