From 6ba4b68461eb55f4863e4e7b32a136b0b06ac627 Mon Sep 17 00:00:00 2001 From: "Juan J. Martinez" Date: Tue, 11 Jul 2023 07:49:49 +0100 Subject: Actually, use qsort properly --- src/entities.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/entities.c b/src/entities.c index 65c0bfd..fe05ef8 100644 --- a/src/entities.c +++ b/src/entities.c @@ -61,10 +61,13 @@ void entities_update() static int cmp_entities(const void *a, const void *b) { - const Entity *ea = (const Entity *) a; - const Entity *eb = (const Entity *) b; + const Entity **ea = (const Entity **)a; + const Entity **eb = (const Entity **)b; - return (ea->y << ea->used) - (eb->y << eb->used); + if (((*ea)->y >> 4) == ((*eb)->y >> 4)) + return (*ea)->used - (*eb)->used; + else + return (*ea)->y - (*eb)->y; } void entities_sort() -- cgit v1.2.3