mirror of
https://github.com/edubart/otclient.git
synced 2025-10-14 11:34:54 +02:00
Fixes for last commits
This commit is contained in:
@@ -489,9 +489,10 @@ void Map::saveOtcm(const std::string& fileName)
|
||||
const auto& list = tile->getThings();
|
||||
auto first = std::find_if(list.begin(), list.end(), [](const ThingPtr& thing) { return thing->isItem(); });
|
||||
for(auto it = first, end = list.end(); it != end; ++it) {
|
||||
ItemPtr item = (*it)->asItem();
|
||||
fin->addU16(item->getId());
|
||||
fin->addU8(item->getCountOrSubType());
|
||||
if(ItemPtr item = (*it)->asItem()) {
|
||||
fin->addU16(item->getId());
|
||||
fin->addU8(item->getCountOrSubType());
|
||||
}
|
||||
}
|
||||
|
||||
// end of tile
|
||||
|
@@ -512,7 +512,13 @@ void ProtocolGame::parseCreatureMove(const InputMessagePtr& msg)
|
||||
if(!g_map.removeThing(thing))
|
||||
g_logger.traceError("could not remove thing");
|
||||
|
||||
g_map.addThing(thing, newPos, -1);
|
||||
int stackPos = -2;
|
||||
|
||||
// older protocols stores creatures in reverse order
|
||||
if(!g_game.getFeature(Otc::GameReverseCreatureStack))
|
||||
stackPos = -1;
|
||||
|
||||
g_map.addThing(thing, newPos, stackPos);
|
||||
}
|
||||
|
||||
void ProtocolGame::parseOpenContainer(const InputMessagePtr& msg)
|
||||
@@ -1144,7 +1150,7 @@ void ProtocolGame::parseOpenOutfitWindow(const InputMessagePtr& msg)
|
||||
for(int i = 0; i < mountCount; ++i) {
|
||||
int mountId = msg->getU16(); // mount type
|
||||
std::string mountName = msg->getString(); // mount name
|
||||
|
||||
|
||||
mountList.push_back(std::make_tuple(mountId, mountName));
|
||||
}
|
||||
}
|
||||
|
@@ -171,16 +171,10 @@ ThingPtr Tile::addThing(const ThingPtr& thing, int stackPos)
|
||||
// 4 - creatures, from top to bottom
|
||||
// 5 - items, from top to bottom
|
||||
if(stackPos < 0) {
|
||||
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)) {
|
||||
// older protocols stores creatures in reverse order
|
||||
if(priority == 4 && otherPriority == 4)
|
||||
break;
|
||||
}
|
||||
if((prepend && otherPriority > priority) || (!prepend && otherPriority >= priority))
|
||||
break;
|
||||
}
|
||||
|
@@ -64,7 +64,7 @@ public:
|
||||
void addWalkingCreature(const CreaturePtr& creature);
|
||||
void removeWalkingCreature(const CreaturePtr& creature);
|
||||
|
||||
ThingPtr addThing(const ThingPtr& thing, int stackPos = -1);
|
||||
ThingPtr addThing(const ThingPtr& thing, int stackPos);
|
||||
bool removeThing(ThingPtr thing);
|
||||
ThingPtr getThing(int stackPos);
|
||||
EffectPtr getEffect(uint16 id);
|
||||
|
Reference in New Issue
Block a user