mirror of
https://github.com/vcmi/vcmi.git
synced 2025-08-13 19:54:17 +02:00
Fix CMP_stack to follow strict weak ordering of elements
This commit is contained in:
@@ -1071,14 +1071,14 @@ bool CMP_stack::operator()(const battle::Unit * a, const battle::Unit * b)
|
|||||||
int as = a->getInitiative(turn), bs = b->getInitiative(turn);
|
int as = a->getInitiative(turn), bs = b->getInitiative(turn);
|
||||||
if(as != bs)
|
if(as != bs)
|
||||||
return as > bs;
|
return as > bs;
|
||||||
else
|
|
||||||
{
|
if (a->unitSide() == b->unitSide())
|
||||||
if(a->unitSide() == b->unitSide())
|
|
||||||
return a->unitSlot() < b->unitSlot();
|
return a->unitSlot() < b->unitSlot();
|
||||||
else
|
else if (a->unitSide() == side || b->unitSide() == side)
|
||||||
return a->unitSide() == side ? false : true;
|
return a->unitSide() != side;
|
||||||
}
|
|
||||||
//FIXME: what about summoned stacks
|
//FIXME: what about summoned stacks
|
||||||
|
|
||||||
|
return std::addressof(a) > std::addressof(b);
|
||||||
}
|
}
|
||||||
case 2: //fastest last, upper slot first
|
case 2: //fastest last, upper slot first
|
||||||
case 3: //fastest last, upper slot first
|
case 3: //fastest last, upper slot first
|
||||||
@@ -1086,18 +1086,21 @@ bool CMP_stack::operator()(const battle::Unit * a, const battle::Unit * b)
|
|||||||
int as = a->getInitiative(turn), bs = b->getInitiative(turn);
|
int as = a->getInitiative(turn), bs = b->getInitiative(turn);
|
||||||
if(as != bs)
|
if(as != bs)
|
||||||
return as > bs;
|
return as > bs;
|
||||||
else
|
|
||||||
{
|
|
||||||
if(a->unitSide() == b->unitSide())
|
if(a->unitSide() == b->unitSide())
|
||||||
return a->unitSlot() < b->unitSlot();
|
return a->unitSlot() < b->unitSlot();
|
||||||
else
|
else if (a->unitSide() == side || b->unitSide() == side)
|
||||||
return a->unitSide() == side ? false : true;
|
return a->unitSide() != side;
|
||||||
}
|
|
||||||
|
return std::addressof(a) > std::addressof(b);
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
assert(0);
|
assert(false);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
assert(false);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
CMP_stack::CMP_stack(int Phase, int Turn, uint8_t Side)
|
CMP_stack::CMP_stack(int Phase, int Turn, uint8_t Side)
|
||||||
|
Reference in New Issue
Block a user