fix some issues with stackpos

This commit is contained in:
Eduardo Bart 2012-02-08 02:20:14 -02:00
parent 1013ae279b
commit a24fe38174
2 changed files with 9 additions and 2 deletions

View File

@ -157,11 +157,18 @@ ThingPtr Tile::addThing(const ThingPtr& thing, int stackPos)
} }
if(stackPos < 0) { if(stackPos < 0) {
// the items stackpos follows this order:
// 0 - ground
// 1 - ground borders
// 2 - bottom (walls)
// 3 - on top (doors)
// 4 - creatures, from top to bottom
// 5 - items, from top to bottom
stackPos = 0; stackPos = 0;
int priority = thing->getStackPriority(); int priority = thing->getStackPriority();
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(otherPriority > priority || (otherPriority == priority && otherPriority == 5)) if(otherPriority > priority)
break; break;
} }
} else if(stackPos > (int)m_things.size()) } else if(stackPos > (int)m_things.size())

View File

@ -994,7 +994,7 @@ void ProtocolGame::setTileDescription(InputMessage& msg, Position position)
ThingPtr thing = internalGetThing(msg); ThingPtr thing = internalGetThing(msg);
if(thing) if(thing)
g_map.addThing(thing, position, 255); g_map.addThing(thing, position, -1);
} }
stackPos++; stackPos++;
} }