Skip to content

Commit

Permalink
src/entity: simplify sort comparison function
Browse files Browse the repository at this point in the history
  • Loading branch information
Akaricchi committed Sep 22, 2024
1 parent 22e6f9b commit 8b09cca
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/entity.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,11 @@ static int ent_cmp(const void *ptr1, const void *ptr2) {
const EntityInterface *ent1 = *(const EntityInterface**)ptr1;
const EntityInterface *ent2 = *(const EntityInterface**)ptr2;

int r = (ent1->draw_layer > ent2->draw_layer) - (ent1->draw_layer < ent2->draw_layer);
int r = (int)ent1->draw_layer - (int)ent2->draw_layer;

if(r == 0) {
// Same layer? Put whatever spawned later on top, then.
r = (ent1->spawn_id > ent2->spawn_id) - (ent1->spawn_id < ent2->spawn_id);
r = (int)ent1->spawn_id - (int)ent2->spawn_id;
}

return r;
Expand Down

0 comments on commit 8b09cca

Please sign in to comment.