diff options
author | Juan J. Martinez <jjm@usebox.net> | 2023-07-11 07:49:49 +0100 |
---|---|---|
committer | Juan J. Martinez <jjm@usebox.net> | 2023-07-11 07:49:49 +0100 |
commit | 6ba4b68461eb55f4863e4e7b32a136b0b06ac627 (patch) | |
tree | d419f46f31b44d3bfe6880b2a5c6f2192a6f5a35 /src | |
parent | 1ae6a63f79edd72aa39c7f7e2bca5182a68592b4 (diff) | |
download | gold-mine-run-6ba4b68461eb55f4863e4e7b32a136b0b06ac627.tar.gz gold-mine-run-6ba4b68461eb55f4863e4e7b32a136b0b06ac627.zip |
Actually, use qsort properly
Diffstat (limited to 'src')
-rw-r--r-- | src/entities.c | 9 |
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() |