From cb2dcdc99eaa57bb325cbee438bbd810cb894da9 Mon Sep 17 00:00:00 2001 From: terminx Date: Wed, 11 Feb 2015 05:21:53 +0000 Subject: [PATCH] Minor engine cleanup git-svn-id: https://svn.eduke32.com/eduke32@4984 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/build/src/engine.c | 95 ++++++++++++------------------ 1 file changed, 39 insertions(+), 56 deletions(-) diff --git a/polymer/eduke32/build/src/engine.c b/polymer/eduke32/build/src/engine.c index 9b1f1964e..2b01aeafd 100644 --- a/polymer/eduke32/build/src/engine.c +++ b/polymer/eduke32/build/src/engine.c @@ -417,7 +417,7 @@ uint8_t yax_gotsector[MAXSECTORS>>3]; // engine internal int16_t yax_bunchnum[MAXSECTORS][2]; int16_t yax_nextwall[MAXWALLS][2]; -static int32_t yax_islockededge(int32_t line, int32_t cf) +static inline int32_t yax_islockededge(int32_t line, int32_t cf) { return !!(wall[line].cstat&(YAX_NEXTWALLBIT(cf))); } @@ -441,7 +441,7 @@ int16_t yax_getbunch(int16_t i, int16_t cf) # define YAX_BUNCHNUM(Sect, Cf) YAX_PTRBUNCHNUM(sector, Sect, Cf) # if !defined NEW_MAP_FORMAT -static int32_t yax_islockededge(int32_t line, int32_t cf) +static inline int32_t yax_islockededge(int32_t line, int32_t cf) { return (yax_getnextwall(line, cf) >= 0); } @@ -545,12 +545,8 @@ void yax_setnextwall(int16_t wal, int16_t cf, int16_t thenextwall) // is red, return its nextsector. int16_t yax_vnextsec(int16_t line, int16_t cf) { - int16_t ynw = yax_getnextwall(line, cf); - - if (ynw < 0) - return -1; - - return wall[ynw].nextsector; + int16_t const ynw = yax_getnextwall(line, cf); + return (ynw < 0) ? -1 : wall[ynw].nextsector; } @@ -1309,8 +1305,8 @@ static vec3_t m32_viewplane; typedef struct { int16_t numsectors, numwalls; - sectortype *sector; - walltype *wall; + tsectortype *sector; + twalltype *wall; } mapinfo_t; static void mapinfo_set(mapinfo_t *bak, mapinfo_t *newmap) @@ -1319,16 +1315,16 @@ static void mapinfo_set(mapinfo_t *bak, mapinfo_t *newmap) { bak->numsectors = numsectors; bak->numwalls = numwalls; - bak->sector = sector; - bak->wall = wall; + bak->sector = (tsectortype *)sector; + bak->wall = (twalltype *)wall; } if (newmap) { numsectors = newmap->numsectors; numwalls = newmap->numwalls; - sector = newmap->sector; - wall = newmap->wall; + sector = (sectortype *)newmap->sector; + wall = (walltype *)newmap->wall; } } @@ -1353,9 +1349,9 @@ static int16_t *sectoidx, *sectq; // [numsectors] static int16_t pictoidx[MAXTILES]; // maps tile num to clipinfo[] index static int16_t *tempictoidx; -static sectortype *loadsector; -static walltype *loadwall, *loadwallinv; -static spritetype *loadsprite; +static tsectortype *loadsector; +static twalltype *loadwall, *loadwallinv; +static tspritetype *loadsprite; // sectoidx bits #undef CM_NONE @@ -1384,26 +1380,20 @@ static spritetype *loadsprite; static void clipmapinfo_init() { - int32_t i; - numclipmaps = 0; numclipsects = 0; - if (sectq) { Bfree(sectq); sectq=NULL; } - if (sectoidx) { Bfree(sectoidx); sectoidx=NULL; } - if (tempictoidx) { Bfree(tempictoidx); tempictoidx=NULL; } + DO_FREE_AND_NULL(sectq); + DO_FREE_AND_NULL(sectoidx); + DO_FREE_AND_NULL(tempictoidx); + DO_FREE_AND_NULL(loadsector); + DO_FREE_AND_NULL(loadwall); + DO_FREE_AND_NULL(loadwallinv); + DO_FREE_AND_NULL(loadsprite); - for (i=0; i w1f) swaplong(&w1c, &w1f); if (w2c > w2f) @@ -1881,8 +1869,8 @@ static int32_t getscore(int32_t w1c, int32_t w1f, int32_t w2c, int32_t w2f) // now: c <= f for each "wall-vline" - maxceil = max(w1c, w2c); - minflor = min(w1f, w2f); + int32_t maxceil = max(w1c, w2c); + int32_t minflor = min(w1f, w2f); return minflor-maxceil; } @@ -2256,7 +2244,7 @@ static inline int32_t msqrtasm(uint32_t c) static inline int32_t getclipmask(int32_t a, int32_t b, int32_t c, int32_t d) { // Ken did this - d = ((a<0)*8) + ((b<0)*4) + ((c<0)*2) + (d<0); + d = ((a<0)<<3) + ((b<0)<<2) + ((c<0)<<1) + (d<0); return(((d<<4)^0xf0)|d); } @@ -2560,9 +2548,9 @@ int32_t engine_addtsprite(int16_t z, int16_t sectnum) return 0; } -static vec2_t get_rel_coords(int32_t x, int32_t y) +static inline vec2_t get_rel_coords(int32_t const x, int32_t const y) { - vec2_t p = { + vec2_t const p = { dmulscale6(y,cosglobalang, -x,singlobalang), dmulscale6(x,cosviewingrangeglobalang, y,sinviewingrangeglobalang) }; @@ -2723,11 +2711,7 @@ static void scansector(int16_t startsectnum) } } #endif - if (w == startwall || wall[w-1].point2 != w) - p1 = get_rel_coords(x1, y1); - else - p1 = p2; - + p1 = (w == startwall || wall[w - 1].point2 != w) ? get_rel_coords(x1, y1) : p2; p2 = get_rel_coords(x2, y2); if (p1.y < 256 && p2.y < 256) @@ -10365,16 +10349,15 @@ static void set_picsiz(int32_t picnum); static const char *E_GetArtFileName(int32_t tilefilei); static int32_t E_ReadArtFile(int32_t tilefilei); -static void clearmapartfilename(void) +static inline void clearmapartfilename(void) { Bmemset(mapartfilename, 0, sizeof(mapartfilename)); mapartfnXXofs = 0; } -static void E_RecalcPicSiz(void) +static inline void E_RecalcPicSiz(void) { - int32_t i; - for (i=0; icstat&128) != (sector[j].CM_CSTAT&128))