Skip to content

Commit

Permalink
Remove unused unit_list_compare
Browse files Browse the repository at this point in the history
I'm not sure since when this has been unused but I've only started seeing the
warnings recently.
  • Loading branch information
lmoureaux committed Jul 30, 2022
1 parent e978e66 commit 75518c3
Showing 1 changed file with 0 additions and 38 deletions.
38 changes: 0 additions & 38 deletions client/mapctrl_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -374,41 +374,3 @@ void update_line(int canvas_x, int canvas_y)
break;
};
}

/**
We sort according to the following logic:
- Transported units should immediately follow their transporter (note that
transporting may be recursive).
- Otherwise we sort by ID (which is what the list is originally sorted
by).
*/
static int unit_list_compare(const void *a, const void *b)
{
const struct unit *punit1 = *(struct unit **) a;
const struct unit *punit2 = *(struct unit **) b;

if (unit_transport_get(punit1) == unit_transport_get(punit2)) {
// For units with the same transporter or no transporter: sort by id.
// Perhaps we should sort by name instead?
return punit1->id - punit2->id;
} else if (unit_transport_get(punit1) == punit2) {
return 1;
} else if (unit_transport_get(punit2) == punit1) {
return -1;
} else {
/* If the transporters aren't the same, put in order by the
* transporters. */
const struct unit *ptrans1 = unit_transport_get(punit1);
const struct unit *ptrans2 = unit_transport_get(punit2);

if (!ptrans1) {
ptrans1 = punit1;
}
if (!ptrans2) {
ptrans2 = punit2;
}

return unit_list_compare(&ptrans1, &ptrans2);
}
}

0 comments on commit 75518c3

Please sign in to comment.