Skip to content

Commit

Permalink
Fix assertion error when selecting allied stack
Browse files Browse the repository at this point in the history
When selecting a stack, we were trying to sort the units by nationality.
This information isn't available for allied players (unit->nationality
is null). Use unit->player instead.

This solves player.cpp:758 - Assertion nullptr != pplayer failed
  • Loading branch information
lmoureaux committed Jan 2, 2025
1 parent ecd7c71 commit 402fa2a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions client/utils/unit_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ bool units_sort(const unit *lhs, const unit *rhs)
return lhs->utype->item_number > rhs->utype->item_number;
}

// By nationality so units from the same player are grouped together
if (player_index(lhs->nationality) != player_index(rhs->nationality)) {
return player_index(lhs->nationality) < player_index(rhs->nationality);
// By owner so units from the same player are grouped together
if (player_index(lhs->owner) != player_index(rhs->owner)) {
return player_index(lhs->owner) < player_index(rhs->owner);
}

// Then unit id
Expand Down

0 comments on commit 402fa2a

Please sign in to comment.