fix ordering of units in transports by size
This commit is contained in:
parent
ef1c09dc23
commit
cca28d94a6
1 changed files with 8 additions and 3 deletions
|
@ -1095,13 +1095,18 @@ void CUnit::AddInContainer(CUnit &host)
|
|||
// keep sorted by size
|
||||
int mySize = Type->BoardSize;
|
||||
NextContained = host.UnitInside;
|
||||
while (NextContained->Type->BoardSize > mySize && NextContained->PrevContained != NextContained) {
|
||||
NextContained = NextContained->PrevContained;
|
||||
bool becomeFirst = true;
|
||||
while (NextContained->Type->BoardSize > mySize) {
|
||||
becomeFirst = false;
|
||||
NextContained = NextContained->NextContained;
|
||||
if (NextContained == host.UnitInside) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
PrevContained = NextContained->PrevContained;
|
||||
NextContained->PrevContained->NextContained = this;
|
||||
NextContained->PrevContained = this;
|
||||
if (NextContained->Type->BoardSize <= mySize) {
|
||||
if (becomeFirst) {
|
||||
host.UnitInside = this;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue