src/entity: simplify sort comparison function

This commit is contained in:
Andrei Alexeyev 2024-09-22 21:08:00 +02:00
parent 22e6f9b4de
commit 8b09cca7c2
No known key found for this signature in database
GPG key ID: 72D26128040B9690

View file

@ -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;