From b97f12a2eb6add11fd0a9cee88bf94019ea5af8f Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 20 Nov 2020 08:18:26 +0100 Subject: [PATCH] - did some global search & replace to reduce the number of accesses to the tilesiz wrapper. --- source/build/src/clip.cpp | 6 ++-- source/build/src/engine_priv.h | 4 +-- source/games/duke/src/game_misc.cpp | 6 ++-- source/games/duke/src/player_d.cpp | 10 +++---- source/games/duke/src/player_r.cpp | 8 +++--- source/games/duke/src/spawn_r.cpp | 44 ++++++++++++++--------------- source/sw/src/draw.cpp | 6 ++-- source/sw/src/sprite.cpp | 4 +-- 8 files changed, 44 insertions(+), 44 deletions(-) diff --git a/source/build/src/clip.cpp b/source/build/src/clip.cpp index ec3038d16..1d66e6cc6 100644 --- a/source/build/src/clip.cpp +++ b/source/build/src/clip.cpp @@ -1476,11 +1476,11 @@ int32_t hitscan(const vec3_t *sv, int16_t sectnum, int32_t vx, int32_t vy, int32 if (tileLoad(tilenum)) { // daz-intz > 0 && daz-intz < k - int32_t xtex = mulscale16(ucoefup16, tilesiz[tilenum].x); + int32_t xtex = mulscale16(ucoefup16, tileWidth(tilenum)); int32_t vcoefup16 = 65536-divscale16(daz-intz, k); - int32_t ytex = mulscale16(vcoefup16, tilesiz[tilenum].y); + int32_t ytex = mulscale16(vcoefup16, tileHeight(tilenum)); - auto texel = (tilePtr(tilenum) + tilesiz[tilenum].y*xtex + ytex); + auto texel = (tilePtr(tilenum) + tileHeight(tilenum)*xtex + ytex); if (*texel == TRANSPARENT_INDEX) continue; } diff --git a/source/build/src/engine_priv.h b/source/build/src/engine_priv.h index 7679b35ba..d0f874dfa 100644 --- a/source/build/src/engine_priv.h +++ b/source/build/src/engine_priv.h @@ -199,7 +199,7 @@ static inline void get_wallspr_points(T const * const spr, int32_t *x1, int32_t dax = sintable[ang&2047]*xrepeat; day = sintable[(ang+1536)&2047]*xrepeat; - l = tilesiz[tilenum].x; + l = tileWidth(tilenum); k = (l>>1)+xoff; *x1 -= mulscale16(dax,k); @@ -220,7 +220,7 @@ static inline void get_floorspr_points(T const * const spr, int32_t px, int32_t const int32_t cosang = sintable[(spr->ang+512)&2047]; const int32_t sinang = sintable[spr->ang&2047]; - vec2_t const span = { tilesiz[tilenum].x, tilesiz[tilenum].y}; + vec2_t const span = { tileWidth(tilenum), tileHeight(tilenum)}; vec2_t const repeat = { spr->xrepeat, spr->yrepeat }; vec2_t adjofs = { tileLeftOffset(tilenum) + spr->xoffset, tileTopOffset(tilenum) + spr->yoffset }; diff --git a/source/games/duke/src/game_misc.cpp b/source/games/duke/src/game_misc.cpp index 6e0b78491..cdc4b6df3 100644 --- a/source/games/duke/src/game_misc.cpp +++ b/source/games/duke/src/game_misc.cpp @@ -472,7 +472,7 @@ bool GameInterface::DrawAutomapPlayer(int cposx, int cposy, int czoom, int cang) l = spr->xrepeat; dax = sintable[k & 2047] * l; day = sintable[(k + 1536) & 2047] * l; - l = tilesiz[tilenum].x; + l = tileWidth(tilenum); k = (l >> 1) + xoff; x1 -= mulscale16(dax, k); x2 = x1 + mulscale16(dax, l); @@ -505,9 +505,9 @@ bool GameInterface::DrawAutomapPlayer(int cposx, int cposy, int czoom, int cang) k = spr->ang; cosang = sintable[(k + 512) & 2047]; sinang = sintable[k & 2047]; - xspan = tilesiz[tilenum].x; + xspan = tileWidth(tilenum); xrepeat = spr->xrepeat; - yspan = tilesiz[tilenum].y; + yspan = tileHeight(tilenum); yrepeat = spr->yrepeat; dax = ((xspan >> 1) + xoff) * xrepeat; diff --git a/source/games/duke/src/player_d.cpp b/source/games/duke/src/player_d.cpp index 98ef0e6a4..6b48f9a82 100644 --- a/source/games/duke/src/player_d.cpp +++ b/source/games/duke/src/player_d.cpp @@ -338,7 +338,7 @@ static void shootweapon(DDukeActor *actor, int p, int sx, int sy, int sz, int sa if (aimed) { - int dal = ((aimed->s.xrepeat * tilesiz[aimed->s.picnum].y) << 1) + (5 << 8); + int dal = ((aimed->s.xrepeat * tileHeight(aimed->s.picnum)) << 1) + (5 << 8); switch (aimed->s.picnum) { case GREENSLIME: @@ -590,7 +590,7 @@ static void shootstuff(DDukeActor* actor, int p, int sx, int sy, int sz, int sa, if (aimed) { - int dal = ((aimed->s.xrepeat * tilesiz[aimed->s.picnum].y) << 1) - (12 << 8); + int dal = ((aimed->s.xrepeat * tileHeight(aimed->s.picnum)) << 1) - (12 << 8); zvel = ((aimed->s.z - sz - dal) * vel) / ldist(ps[p].GetActor(), aimed); sa = getangle(aimed->s.x - sx, aimed->s.y - sy); } @@ -688,7 +688,7 @@ static void shootrpg(DDukeActor *actor, int p, int sx, int sy, int sz, int sa, i aimed = aim(actor, 48); if (aimed) { - int dal = ((aimed->s.xrepeat * tilesiz[aimed->s.picnum].y) << 1) + (8 << 8); + int dal = ((aimed->s.xrepeat * tileHeight(aimed->s.picnum)) << 1) + (8 << 8); zvel = ((aimed->s.z - sz - dal) * vel) / ldist(ps[p].GetActor(), aimed); if (aimed->s.picnum != RECON) sa = getangle(aimed->s.x - sx, aimed->s.y - sy); @@ -925,7 +925,7 @@ static void shootgrowspark(DDukeActor* actor, int p, int sx, int sy, int sz, int auto aimed = aim(actor, AUTO_AIM_ANGLE); if (aimed) { - int dal = ((aimed->s.xrepeat * tilesiz[aimed->s.picnum].y) << 1) + (5 << 8); + int dal = ((aimed->s.xrepeat * tileHeight(aimed->s.picnum)) << 1) + (5 << 8); switch (aimed->s.picnum) { case GREENSLIME: @@ -1145,7 +1145,7 @@ void shoot_d(DDukeActor* actor, int atwith) auto aimed = isNamWW2GI() ? nullptr : aim(actor, AUTO_AIM_ANGLE); if (aimed) { - dal = ((aimed->s.xrepeat * tilesiz[aimed->s.picnum].y) << 1); + dal = ((aimed->s.xrepeat * tileHeight(aimed->s.picnum)) << 1); zvel = ((aimed->s.z - sz - dal - (4 << 8)) * 768) / (ldist(ps[p].GetActor(), aimed)); sa = getangle(aimed->s.x - sx, aimed->s.y - sy); } diff --git a/source/games/duke/src/player_r.cpp b/source/games/duke/src/player_r.cpp index ab470bbae..d6221f4cb 100644 --- a/source/games/duke/src/player_r.cpp +++ b/source/games/duke/src/player_r.cpp @@ -226,7 +226,7 @@ static void shootweapon(DDukeActor* actor, int p, int sx, int sy, int sz, int sa auto aimed = aim(actor, AUTO_AIM_ANGLE); if (aimed) { - int dal = ((aimed->s.xrepeat * tilesiz[aimed->s.picnum].y) << 1) + (5 << 8); + int dal = ((aimed->s.xrepeat * tileHeight(aimed->s.picnum)) << 1) + (5 << 8); zvel = ((aimed->s.z - sz - dal) << 8) / ldist(ps[p].GetActor(), aimed); sa = getangle(aimed->s.x - sx, aimed->s.y - sy); } @@ -514,7 +514,7 @@ static void shootstuff(DDukeActor* actor, int p, int sx, int sy, int sz, int sa, { sx += sintable[(s->ang + 512 + 160) & 2047] >> 7; sy += sintable[(s->ang + 160) & 2047] >> 7; - int dal = ((aimed->s.xrepeat * tilesiz[aimed->s.picnum].y) << 1) - (12 << 8); + int dal = ((aimed->s.xrepeat * tileHeight(aimed->s.picnum)) << 1) - (12 << 8); zvel = ((aimed->s.z - sz - dal) * vel) / ldist(ps[p].GetActor(), aimed); sa = getangle(aimed->s.x - sx, aimed->s.y - sy); } @@ -631,7 +631,7 @@ static void shootrpg(DDukeActor* actor, int p, int sx, int sy, int sz, int sa, i else act90 = aimed; } - int dal = ((aimed->s.xrepeat * tilesiz[aimed->s.picnum].y) << 1) + (8 << 8); + int dal = ((aimed->s.xrepeat * tileHeight(aimed->s.picnum)) << 1) + (8 << 8); zvel = ((aimed->s.z - sz - dal) * vel) / ldist(ps[p].GetActor(), aimed); if (aimed->s.picnum != RECON) sa = getangle(aimed->s.x - sx, aimed->s.y - sy); @@ -785,7 +785,7 @@ static void shootwhip(DDukeActor* actor, int p, int sx, int sy, int sz, int sa, if (aimed) { - int dal = ((aimed->s.xrepeat * tilesiz[aimed->s.picnum].y) << 1) - (12 << 8); + int dal = ((aimed->s.xrepeat * tileHeight(aimed->s.picnum)) << 1) - (12 << 8); zvel = ((aimed->s.z - sz - dal) * vel) / ldist(ps[p].GetActor(), aimed); sa = getangle(aimed->s.x - sx, aimed->s.y - sy); } diff --git a/source/games/duke/src/spawn_r.cpp b/source/games/duke/src/spawn_r.cpp index 22217de0a..238e4a4e9 100644 --- a/source/games/duke/src/spawn_r.cpp +++ b/source/games/duke/src/spawn_r.cpp @@ -824,7 +824,7 @@ int spawn_r(int j, int pn) sp->xrepeat = 22; sp->yrepeat = 20; } - sp->clipdist = mulscale7(sp->xrepeat,tilesiz[sp->picnum].x); + sp->clipdist = mulscale7(sp->xrepeat,tileWidth(sp->picnum)); break; case HULKHANG: case HULKHANGDEAD: @@ -833,14 +833,14 @@ int spawn_r(int j, int pn) case HULKSTAYPUT: sp->xrepeat = 32; sp->yrepeat = 32; - sp->clipdist = mulscale7(sp->xrepeat,tilesiz[sp->picnum].x); + sp->clipdist = mulscale7(sp->xrepeat,tileWidth(sp->picnum)); break; case COOTPLAY: case COOT: case COOTSTAYPUT: sp->xrepeat = 24; sp->yrepeat = 18; - sp->clipdist = mulscale7(sp->xrepeat,tilesiz[sp->picnum].x); + sp->clipdist = mulscale7(sp->xrepeat,tileWidth(sp->picnum)); sp->clipdist <<= 2; break; case DRONE: @@ -857,12 +857,12 @@ int spawn_r(int j, int pn) case BUBBASTAND: sp->xrepeat = 25; sp->yrepeat = 21; - sp->clipdist = mulscale7(sp->xrepeat,tilesiz[sp->picnum].x); + sp->clipdist = mulscale7(sp->xrepeat,tileWidth(sp->picnum)); break; case COW: sp->xrepeat = 32; sp->yrepeat = 32; - sp->clipdist = mulscale7(sp->xrepeat,tilesiz[sp->picnum].x); + sp->clipdist = mulscale7(sp->xrepeat,tileWidth(sp->picnum)); break; case HEN: case HENSTAYPUT: @@ -871,7 +871,7 @@ int spawn_r(int j, int pn) { sp->xrepeat = 42; sp->yrepeat = 30; - sp->clipdist = mulscale7(sp->xrepeat,tilesiz[sp->picnum].x); + sp->clipdist = mulscale7(sp->xrepeat,tileWidth(sp->picnum)); } else { @@ -884,7 +884,7 @@ int spawn_r(int j, int pn) case MINIONSTAYPUT: sp->xrepeat = 16; sp->yrepeat = 16; - sp->clipdist = mulscale7(sp->xrepeat,tilesiz[sp->picnum].x); + sp->clipdist = mulscale7(sp->xrepeat,tileWidth(sp->picnum)); if (isRRRA() && ufospawnsminion) sp->pal = 8; break; @@ -892,12 +892,12 @@ int spawn_r(int j, int pn) case PIG: sp->xrepeat = 16; sp->yrepeat = 16; - sp->clipdist = mulscale7(sp->xrepeat,tilesiz[sp->picnum].x); + sp->clipdist = mulscale7(sp->xrepeat,tileWidth(sp->picnum)); break; case RABBIT: sp->xrepeat = 18; sp->yrepeat = 18; - sp->clipdist = mulscale7(sp->xrepeat,tilesiz[sp->picnum].x); + sp->clipdist = mulscale7(sp->xrepeat,tileWidth(sp->picnum)); break; case MAMACLOUD: sp->xrepeat = 64; @@ -947,7 +947,7 @@ int spawn_r(int j, int pn) case BIKER: sp->xrepeat = 28; sp->yrepeat = 22; - sp->clipdist = mulscale7(sp->xrepeat,tilesiz[sp->picnum].x); + sp->clipdist = mulscale7(sp->xrepeat,tileWidth(sp->picnum)); break; case CHEERB: sp->xrepeat = 28; @@ -958,46 +958,46 @@ int spawn_r(int j, int pn) case CHEERSTAYPUT: sp->xrepeat = 20; sp->yrepeat = 20; - sp->clipdist = mulscale7(sp->xrepeat,tilesiz[sp->picnum].x); + sp->clipdist = mulscale7(sp->xrepeat,tileWidth(sp->picnum)); break; case MAKEOUT: sp->xrepeat = 26; sp->yrepeat = 26; - sp->clipdist = mulscale7(sp->xrepeat,tilesiz[sp->picnum].x); + sp->clipdist = mulscale7(sp->xrepeat,tileWidth(sp->picnum)); break; case MINIONBOAT: sp->xrepeat = 16; sp->yrepeat = 16; - sp->clipdist = mulscale7(sp->xrepeat,tilesiz[sp->picnum].x); + sp->clipdist = mulscale7(sp->xrepeat,tileWidth(sp->picnum)); break; case HULKBOAT: sp->xrepeat = 48; sp->yrepeat = 48; - sp->clipdist = mulscale7(sp->xrepeat,tilesiz[sp->picnum].x); + sp->clipdist = mulscale7(sp->xrepeat,tileWidth(sp->picnum)); break; case CHEERBOAT: sp->xrepeat = 32; sp->yrepeat = 32; - sp->clipdist = mulscale7(sp->xrepeat,tilesiz[sp->picnum].x); + sp->clipdist = mulscale7(sp->xrepeat,tileWidth(sp->picnum)); break; case TORNADO: sp->xrepeat = 64; sp->yrepeat = 128; - sp->clipdist = mulscale7(sp->xrepeat,tilesiz[sp->picnum].x); + sp->clipdist = mulscale7(sp->xrepeat,tileWidth(sp->picnum)); sp->clipdist >>= 2; sp->cstat = 2; break; case LTH: sp->xrepeat = 24; sp->yrepeat = 22; - sp->clipdist = mulscale7(sp->xrepeat,tilesiz[sp->picnum].x); + sp->clipdist = mulscale7(sp->xrepeat,tileWidth(sp->picnum)); break; case ROCK: case ROCK2: sp->xrepeat = 64; sp->yrepeat = 64; - sp->clipdist = mulscale7(sp->xrepeat,tilesiz[sp->picnum].x); + sp->clipdist = mulscale7(sp->xrepeat,tileWidth(sp->picnum)); break; case UFO1_RRRA: @@ -1008,13 +1008,13 @@ int spawn_r(int j, int pn) case UFO5: sp->xrepeat = 32; sp->yrepeat = 32; - sp->clipdist = mulscale7(sp->xrepeat,tilesiz[sp->picnum].x); + sp->clipdist = mulscale7(sp->xrepeat,tileWidth(sp->picnum)); sp->extra = 50; break; case SBMOVE: sp->xrepeat = 48; sp->yrepeat = 48; - sp->clipdist = mulscale7(sp->xrepeat,tilesiz[sp->picnum].x); + sp->clipdist = mulscale7(sp->xrepeat,tileWidth(sp->picnum)); break; default: @@ -1409,7 +1409,7 @@ int spawn_r(int j, int pn) sp->pal = 0; sp->xrepeat = 18; sp->yrepeat = 18; - sp->clipdist = mulscale7(sp->xrepeat,tilesiz[sp->picnum].x); + sp->clipdist = mulscale7(sp->xrepeat,tileWidth(sp->picnum)); act->saved_ammo = 100; sp->cstat = 257; sp->lotag = 1; @@ -1425,7 +1425,7 @@ int spawn_r(int j, int pn) sp->pal = 0; sp->xrepeat = 32; sp->yrepeat = 32; - sp->clipdist = mulscale7(sp->xrepeat,tilesiz[sp->picnum].x); + sp->clipdist = mulscale7(sp->xrepeat,tileWidth(sp->picnum)); act->saved_ammo = 20; sp->cstat = 257; sp->lotag = 1; diff --git a/source/sw/src/draw.cpp b/source/sw/src/draw.cpp index c90753e1c..c0c53a08f 100644 --- a/source/sw/src/draw.cpp +++ b/source/sw/src/draw.cpp @@ -1986,7 +1986,7 @@ bool GameInterface::DrawAutomapPlayer(int cposx, int cposy, int czoom, int cang) l = spr->xrepeat; dax = sintable[k & 2047] * l; day = sintable[(k + 1536) & 2047] * l; - l = tilesiz[tilenum].x; + l = tileWidth(tilenum); k = (l >> 1) + xoff; x1 -= mulscale16(dax, k); x2 = x1 + mulscale16(dax, l); @@ -2021,9 +2021,9 @@ bool GameInterface::DrawAutomapPlayer(int cposx, int cposy, int czoom, int cang) k = spr->ang; cosang = sintable[(k + 512) & 2047]; sinang = sintable[k]; - xspan = tilesiz[tilenum].x; + xspan = tileWidth(tilenum); xrepeat = spr->xrepeat; - yspan = tilesiz[tilenum].y; + yspan = tileHeight(tilenum); yrepeat = spr->yrepeat; dax = ((xspan >> 1) + xoff) * xrepeat; diff --git a/source/sw/src/sprite.cpp b/source/sw/src/sprite.cpp index e7994b048..283102391 100644 --- a/source/sw/src/sprite.cpp +++ b/source/sw/src/sprite.cpp @@ -4787,9 +4787,9 @@ getzrangepoint(int x, int y, int z, short sectnum, // These points will already have (x,y) subtracted from them cosang = sintable[NORM_ANGLE(spr->ang + 512)]; sinang = sintable[spr->ang]; - xspan = tilesiz[tilenum].x; + xspan = tileWidth(tilenum); dax = ((xspan >> 1) + xoff) * spr->xrepeat; - yspan = tilesiz[tilenum].y; + yspan = tileHeight(tilenum); day = ((yspan >> 1) + yoff) * spr->yrepeat; x1 = spr->x + dmulscale16(sinang, dax, cosang, day) - x; y1 = spr->y + dmulscale16(sinang, day, -cosang, dax) - y;