aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJuan J. Martinez <jjm@usebox.net>2023-07-11 07:49:49 +0100
committerJuan J. Martinez <jjm@usebox.net>2023-07-11 07:49:49 +0100
commit6ba4b68461eb55f4863e4e7b32a136b0b06ac627 (patch)
treed419f46f31b44d3bfe6880b2a5c6f2192a6f5a35
parent1ae6a63f79edd72aa39c7f7e2bca5182a68592b4 (diff)
downloadgold-mine-run-6ba4b68461eb55f4863e4e7b32a136b0b06ac627.tar.gz
gold-mine-run-6ba4b68461eb55f4863e4e7b32a136b0b06ac627.zip
Actually, use qsort properly
-rw-r--r--src/entities.c9
1 files changed, 6 insertions, 3 deletions
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()