From d7cfde9d3dafedd12ea50b08858bcc0cbcd53a1b Mon Sep 17 00:00:00 2001 From: helixhorned Date: Fri, 28 Dec 2012 17:17:58 +0000 Subject: [PATCH] Make get{zs,ceilz,florz}ofslope (now ...ptr) accept sectortype pointer. And rewrite the original functions as wrappers around these. git-svn-id: https://svn.eduke32.com/eduke32@3323 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/build/include/build.h | 25 +++++++++++++++--- polymer/eduke32/build/src/engine.c | 37 ++++++++------------------- 2 files changed, 32 insertions(+), 30 deletions(-) diff --git a/polymer/eduke32/build/include/build.h b/polymer/eduke32/build/include/build.h index f41e2e5cc..7f6604e9e 100644 --- a/polymer/eduke32/build/include/build.h +++ b/polymer/eduke32/build/include/build.h @@ -818,10 +818,27 @@ void rotatepoint(int32_t xpivot, int32_t ypivot, int32_t x, int32_t y, int16_t daang, int32_t *x2, int32_t *y2) ATTRIBUTE((nonnull(6,7))); int32_t lastwall(int16_t point); int32_t nextsectorneighborz(int16_t sectnum, int32_t thez, int16_t topbottom, int16_t direction); -int32_t getceilzofslope(int16_t sectnum, int32_t dax, int32_t day); -int32_t getflorzofslope(int16_t sectnum, int32_t dax, int32_t day); -void getzsofslope(int16_t sectnum, int32_t dax, int32_t day, - int32_t *ceilz, int32_t *florz) ATTRIBUTE((nonnull(4,5))); + +int32_t getceilzofslopeptr(const sectortype *sec, int32_t dax, int32_t day) ATTRIBUTE((nonnull(1))); +int32_t getflorzofslopeptr(const sectortype *sec, int32_t dax, int32_t day) ATTRIBUTE((nonnull(1))); +void getzsofslopeptr(const sectortype *sec, int32_t dax, int32_t day, + int32_t *ceilz, int32_t *florz) ATTRIBUTE((nonnull(1,4,5))); + +static inline int32_t getceilzofslope(int16_t sectnum, int32_t dax, int32_t day) +{ + return getceilzofslopeptr(§or[sectnum], dax, day); +} + +static inline int32_t getflorzofslope(int16_t sectnum, int32_t dax, int32_t day) +{ + return getflorzofslopeptr(§or[sectnum], dax, day); +} + +static inline void getzsofslope(int16_t sectnum, int32_t dax, int32_t day, int32_t *ceilz, int32_t *florz) +{ + getzsofslopeptr(§or[sectnum], dax, day, ceilz, florz); +} + void alignceilslope(int16_t dasect, int32_t x, int32_t y, int32_t z); void alignflorslope(int16_t dasect, int32_t x, int32_t y, int32_t z); int32_t sectorofwall(int16_t theline); diff --git a/polymer/eduke32/build/src/engine.c b/polymer/eduke32/build/src/engine.c index 059826e5e..50d31b9bf 100644 --- a/polymer/eduke32/build/src/engine.c +++ b/polymer/eduke32/build/src/engine.c @@ -14297,57 +14297,42 @@ int32_t sectorofwall_noquick(int16_t theline) } -// -// getceilzofslope -// -int32_t getceilzofslope(int16_t sectnum, int32_t dax, int32_t day) +int32_t getceilzofslopeptr(const sectortype *sec, int32_t dax, int32_t day) { - if (!(sector[sectnum].ceilingstat&2)) return(sector[sectnum].ceilingz); + if (!(sec->ceilingstat&2)) return(sec->ceilingz); { int32_t dx, dy, i, j; - walltype *wal; + const walltype *wal = &wall[sec->wallptr]; - wal = &wall[sector[sectnum].wallptr]; // floor(sqrt(2**31-1)) == 46340 dx = wall[wal->point2].x-wal->x; dy = wall[wal->point2].y-wal->y; - i = (nsqrtasm(uhypsq(dx,dy))<<5); if (i == 0) return(sector[sectnum].ceilingz); + i = (nsqrtasm(uhypsq(dx,dy))<<5); if (i == 0) return(sec->ceilingz); j = dmulscale3(dx,day-wal->y,-dy,dax-wal->x); - return(sector[sectnum].ceilingz+(scale(sector[sectnum].ceilingheinum,j>>1,i)<<1)); + return(sec->ceilingz+(scale(sec->ceilingheinum,j>>1,i)<<1)); } } - -// -// getflorzofslope -// -int32_t getflorzofslope(int16_t sectnum, int32_t dax, int32_t day) +int32_t getflorzofslopeptr(const sectortype *sec, int32_t dax, int32_t day) { - if (!(sector[sectnum].floorstat&2)) return(sector[sectnum].floorz); + if (!(sec->floorstat&2)) return(sec->floorz); { int32_t dx, dy, i, j; - walltype *wal; + const walltype *wal = &wall[sec->wallptr]; - wal = &wall[sector[sectnum].wallptr]; dx = wall[wal->point2].x-wal->x; dy = wall[wal->point2].y-wal->y; - i = (nsqrtasm(uhypsq(dx,dy))<<5); if (i == 0) return(sector[sectnum].floorz); + i = (nsqrtasm(uhypsq(dx,dy))<<5); if (i == 0) return(sec->floorz); j = dmulscale3(dx,day-wal->y,-dy,dax-wal->x); - return(sector[sectnum].floorz+(scale(sector[sectnum].floorheinum,j>>1,i)<<1)); + return(sec->floorz+(scale(sec->floorheinum,j>>1,i)<<1)); } } - -// -// getzsofslope -// -void getzsofslope(int16_t sectnum, int32_t dax, int32_t day, int32_t *ceilz, int32_t *florz) +void getzsofslopeptr(const sectortype *sec, int32_t dax, int32_t day, int32_t *ceilz, int32_t *florz) { int32_t dx, dy, i, j; walltype *wal, *wal2; - sectortype *sec; - sec = §or[sectnum]; *ceilz = sec->ceilingz; *florz = sec->floorz; if ((sec->ceilingstat|sec->floorstat)&2) {