Use doubles instead of ints for y sorting

This commit is contained in:
Camden Dixie O'Brien 2025-01-04 13:22:06 +00:00
parent 765e2c32c8
commit 080de0da3c

View File

@ -144,7 +144,7 @@ typedef struct {
} gamestate_t; } gamestate_t;
typedef struct { typedef struct {
int y; double y;
entity_t *e; entity_t *e;
} y_entity_ref_t; } y_entity_ref_t;
@ -568,17 +568,17 @@ static inline bool tile_passable(const map_t map, int x, int y)
return true; return true;
} }
static inline int dynentity_bottom(dynentity_t *e) static inline double dynentity_bottom(dynentity_t *e)
{ {
return e->pos.y + e->ext.y / 2; return e->pos.y + (double)e->ext.y / 2.0;
} }
static inline int objentity_bottom(objentity_t *e) static inline double objentity_bottom(objentity_t *e)
{ {
return e->pos.y; return (double)e->pos.y;
} }
static inline int entity_bottom(entity_t *e) static inline double entity_bottom(entity_t *e)
{ {
switch (e->tag) { switch (e->tag) {
case ENTITY_DYN: case ENTITY_DYN:
@ -602,8 +602,8 @@ static void update_drawlist(dynentity_t *e, entity_t **drawlist)
// The entity is already at the end -- no update required. // The entity is already at the end -- no update required.
return; return;
const int y = dynentity_bottom(e); const double y = dynentity_bottom(e);
int nexty = entity_bottom(n); double nexty = entity_bottom(n);
if (y <= nexty) if (y <= nexty)
// The entity is still behind the next entity -- no update // The entity is still behind the next entity -- no update
// required. // required.
@ -653,8 +653,8 @@ static void update_drawlist(dynentity_t *e, entity_t **drawlist)
if (n == NULL) if (n == NULL)
return; return;
const int y = dynentity_bottom(e); const double y = dynentity_bottom(e);
int prevy = entity_bottom(n); double prevy = entity_bottom(n);
if (y >= prevy) if (y >= prevy)
return; return;