mirror of
https://github.com/vcmi/vcmi.git
synced 2025-03-21 21:17:49 +02:00
Fix possible crash on opening unit window if unit has both ability and
artifact bonus
This commit is contained in:
parent
2823bf5848
commit
9cf75713d0
@ -838,7 +838,11 @@ void CStackWindow::initBonusesList()
|
|||||||
|
|
||||||
std::sort(input.begin(), input.end(), [this](std::shared_ptr<Bonus> v1, std::shared_ptr<Bonus> & v2){
|
std::sort(input.begin(), input.end(), [this](std::shared_ptr<Bonus> v1, std::shared_ptr<Bonus> & v2){
|
||||||
if (v1->source != v2->source)
|
if (v1->source != v2->source)
|
||||||
return v1->source == BonusSource::CREATURE_ABILITY || (v1->source < v2->source);
|
{
|
||||||
|
int priorityV1 = v1->source == BonusSource::CREATURE_ABILITY ? -1 : static_cast<int>(v1->source);
|
||||||
|
int priorityV2 = v2->source == BonusSource::CREATURE_ABILITY ? -1 : static_cast<int>(v2->source);
|
||||||
|
return priorityV1 < priorityV2;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
return info->stackNode->bonusToString(v1, false) < info->stackNode->bonusToString(v2, false);
|
return info->stackNode->bonusToString(v1, false) < info->stackNode->bonusToString(v2, false);
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user