From d70ac064b72f43361b5c65ed4d89b036b235e673 Mon Sep 17 00:00:00 2001 From: terminx Date: Mon, 12 Jan 2015 09:28:41 +0000 Subject: [PATCH] Make dist() and ldist() take void pointers so we can compare spritetype with tspritetype without inserting casts everywhere. git-svn-id: https://svn.eduke32.com/eduke32@4910 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/build/include/common.h | 4 ++-- polymer/eduke32/build/src/common.c | 12 ++++++++---- polymer/eduke32/source/sector.h | 2 -- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/polymer/eduke32/build/include/common.h b/polymer/eduke32/build/include/common.h index 30f1effba..9454c5b59 100644 --- a/polymer/eduke32/build/include/common.h +++ b/polymer/eduke32/build/include/common.h @@ -125,8 +125,8 @@ static inline int32_t sepdist(const int32_t dx, const int32_t dy, const int32_t return d.x - (d.x>>4) + (d.y>>2) + (d.y>>3); } -int32_t ldist(const spritetype *s1, const spritetype *s2); -int32_t dist(const spritetype *s1, const spritetype *s2); +int32_t ldist(const void *s1, const void *s2); +int32_t dist(const void *s1, const void *s2); void COMMON_clearbackground(int32_t numcols, int32_t numrows); diff --git a/polymer/eduke32/build/src/common.c b/polymer/eduke32/build/src/common.c index 122f9dbb1..adc8914df 100644 --- a/polymer/eduke32/build/src/common.c +++ b/polymer/eduke32/build/src/common.c @@ -188,14 +188,18 @@ int32_t maybe_append_ext(char *wbuf, int32_t wbufsiz, const char *fn, const char } -int32_t ldist(const spritetype *s1, const spritetype *s2) +int32_t ldist(const void *s1, const void *s2) { - return sepldist(s1->x-s2->x, s1->y-s2->y); + tspritetype const *const sp1 = (tspritetype *)s1; + tspritetype const *const sp2 = (tspritetype *)s2; + return sepldist(sp1->x - sp2->x, sp1->y - sp2->y); } -int32_t dist(const spritetype *s1, const spritetype *s2) +int32_t dist(const void *s1, const void *s2) { - return sepdist(s1->x-s2->x, s1->y-s2->y, s1->z-s2->z); + tspritetype const *const sp1 = (tspritetype *)s1; + tspritetype const *const sp2 = (tspritetype *)s2; + return sepdist(sp1->x - sp2->x, sp1->y - sp2->y, sp1->z - sp2->z); } diff --git a/polymer/eduke32/source/sector.h b/polymer/eduke32/source/sector.h index 0364b99b9..5ba52dd8e 100644 --- a/polymer/eduke32/source/sector.h +++ b/polymer/eduke32/source/sector.h @@ -131,8 +131,6 @@ void P_HandleSharedKeys(int32_t snum); int32_t GetAnimationGoal(const int32_t *animptr); int32_t isanearoperator(int32_t lotag); int32_t isanunderoperator(int32_t lotag); -int32_t ldist(const spritetype *s1, const spritetype *s2); -int32_t dist(const spritetype *s1, const spritetype *s2); int32_t P_ActivateSwitch(int32_t snum,int32_t w,int32_t switchissprite); void P_CheckSectors(int32_t snum); int32_t Sect_DamageCeilingOrFloor(int32_t floorp, int32_t sn);