Fix protocol 860 stackpos regression

This commit is contained in:
Eduardo Bart 2012-08-02 12:18:45 -03:00
parent a5c3029e5b
commit ea2fa55a25
1 changed files with 16 additions and 10 deletions

View File

@ -158,25 +158,31 @@ void Tile::addThing(const ThingPtr& thing, int stackPos)
if(thing->isEffect()) { if(thing->isEffect()) {
m_effects.push_back(thing->static_self_cast<Effect>()); m_effects.push_back(thing->static_self_cast<Effect>());
} else { } else {
// the items stackpos follows this order: // priority 854
// 0 - ground // 0 - ground, --> -->
// 1 - ground borders // 1 - ground borders --> -->
// 2 - bottom (walls) // 2 - bottom (walls), --> -->
// 3 - on top (doors) // 3 - on top (doors) --> -->
// 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 || stackPos == 255) { if(stackPos < 0 || stackPos == 255) {
int priority = thing->getStackPriority(); int priority = thing->getStackPriority();
bool prepend = (stackPos == -2 || priority <= 3); // -1 or 255 => auto detect position
// -2 => append
bool append = (stackPos == -2 || priority <= 3);
// newer protocols does not store creatures in reverse order // newer protocols does not store creatures in reverse order
if(g_game.getClientVersion() >= 854 && priority == 4) if(g_game.getClientVersion() >= 854 && priority == 4)
prepend = !prepend; append = !append;
if(g_game.getClientVersion() < 900 && priority == 4 && stackPos == -2)
append = !append;
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((prepend && otherPriority > priority) || (!prepend && otherPriority >= priority)) if((append && otherPriority > priority) || (!append && otherPriority >= priority))
break; break;
} }
} else if(stackPos > (int)m_things.size()) } else if(stackPos > (int)m_things.size())