mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-22 22:13:35 +02:00
fix artifact sort by slot crash
This commit is contained in:
parent
3a45e6dae1
commit
17dd8ffb48
@ -2771,8 +2771,29 @@ bool CGameHandler::manageBackpackArtifacts(const PlayerColor & player, const Obj
|
||||
if(sortType == ManageBackpackArtifacts::ManageCmd::SORT_BY_SLOT)
|
||||
{
|
||||
makeSortBackpackRequest([](const ArtSlotInfo & inf) -> int32_t
|
||||
{
|
||||
auto possibleSlots = inf.getArt()->artType->getPossibleSlots();
|
||||
if (possibleSlots.find(ArtBearer::ALTAR) != possibleSlots.end() && !possibleSlots.at(ArtBearer::ALTAR).empty())
|
||||
{
|
||||
return -3;
|
||||
}
|
||||
else if (possibleSlots.find(ArtBearer::CREATURE) != possibleSlots.end() && !possibleSlots.at(ArtBearer::CREATURE).empty())
|
||||
{
|
||||
return -2;
|
||||
}
|
||||
else if (possibleSlots.find(ArtBearer::COMMANDER) != possibleSlots.end() && !possibleSlots.at(ArtBearer::COMMANDER).empty())
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
else if (possibleSlots.find(ArtBearer::HERO) != possibleSlots.end() && !possibleSlots.at(ArtBearer::HERO).empty())
|
||||
{
|
||||
return inf.getArt()->artType->getPossibleSlots().at(ArtBearer::HERO).front().num;
|
||||
}
|
||||
else
|
||||
{
|
||||
logGlobal->error("Unable to get artifact %s slot.", inf.getArt()->artType->getNameTextID());
|
||||
return -4;
|
||||
}
|
||||
});
|
||||
}
|
||||
else if(sortType == ManageBackpackArtifacts::ManageCmd::SORT_BY_COST)
|
||||
|
Loading…
Reference in New Issue
Block a user