Skip to content

Commit

Permalink
- use access functions, all done by search & replace.
Browse files Browse the repository at this point in the history
  • Loading branch information
coelckers committed Dec 4, 2021
1 parent 98544d3 commit 480070b
Show file tree
Hide file tree
Showing 13 changed files with 110 additions and 107 deletions.
33 changes: 17 additions & 16 deletions source/build/src/clip.cpp
Expand Up @@ -494,7 +494,7 @@ int32_t clipmove_(vec3_t * const pos, int * const sectnum, int32_t xvect, int32_

for (native_t j=startwall; j<endwall; j++, wal++)
{
auto const wal2 = (uwallptr_t)&wall[wal->point2];
auto const wal2 = (uwallptr_t)wal->point2Wall();

if ((wal->x < clipMin.x && wal2->x < clipMin.x) || (wal->x > clipMax.x && wal2->x > clipMax.x) ||
(wal->y < clipMin.y && wal2->y < clipMin.y) || (wal->y > clipMax.y && wal2->y > clipMax.y))
Expand Down Expand Up @@ -884,8 +884,8 @@ int pushmove_(vec3_t *const vect, int *const sectnum,
else
{
//Find closest point on wall (dax, day) to (vect->x, vect->y)
int32_t dax = wall[wal->point2].x-wal->x;
int32_t day = wall[wal->point2].y-wal->y;
int32_t dax = wal->point2Wall()->x-wal->x;
int32_t day = wal->point2Wall()->y-wal->y;
int32_t daz = dax*((vect->x)-wal->x) + day*((vect->y)-wal->y);
int32_t t;
if (daz <= 0)
Expand All @@ -906,7 +906,7 @@ int pushmove_(vec3_t *const vect, int *const sectnum,

if (j != 0)
{
j = getangle(wall[wal->point2].x-wal->x, wall[wal->point2].y-wal->y);
j = getangle(wal->point2Wall()->x-wal->x, wal->point2Wall()->y-wal->y);
int32_t dx = -bsin(j, -11);
int32_t dy = bcos(j, -11);
int bad2 = 16;
Expand Down Expand Up @@ -1051,24 +1051,25 @@ void getzrange_(const vec3_t *pos, int16_t sectnum,
SectIterator it(clipsectorlist[i]);
while ((j = it.NextIndex()) >= 0)
{
const int32_t cstat = sprite[j].cstat;
auto spr = &sprite[j];
const int32_t cstat = spr->cstat;
int32_t daz = 0, daz2 = 0;

if (sprite[j].cstat2 & CSTAT2_SPRITE_NOFIND) continue;
if (spr->cstat2 & CSTAT2_SPRITE_NOFIND) continue;
if (cstat&dasprclipmask)
{
int32_t clipyou = 0;

vec2_t v1 = sprite[j].pos.vec2;
vec2_t v1 = spr->pos.vec2;

switch (cstat & CSTAT_SPRITE_ALIGNMENT_MASK)
{
case CSTAT_SPRITE_ALIGNMENT_FACING:
{
int32_t k = walldist+(sprite[j].clipdist<<2)+1;
int32_t k = walldist+(spr->clipdist<<2)+1;
if ((abs(v1.x-pos->x) <= k) && (abs(v1.y-pos->y) <= k))
{
daz = sprite[j].z + spriteheightofs(j, &k, 1);
daz = spr->z + spriteheightofs(j, &k, 1);
daz2 = daz - k;
clipyou = 1;
}
Expand All @@ -1083,7 +1084,7 @@ void getzrange_(const vec3_t *pos, int16_t sectnum,
if (clipinsideboxline(pos->x,pos->y,v1.x,v1.y,v2.x,v2.y,walldist+1) != 0)
{
int32_t k;
daz = sprite[j].z + spriteheightofs(j, &k, 1);
daz = spr->z + spriteheightofs(j, &k, 1);
daz2 = daz-k;
clipyou = 1;
}
Expand All @@ -1092,7 +1093,7 @@ void getzrange_(const vec3_t *pos, int16_t sectnum,

case CSTAT_SPRITE_ALIGNMENT_FLOOR:
{
daz = sprite[j].z; daz2 = daz;
daz = spr->z; daz2 = daz;

if ((cstat&64) != 0 && (pos->z > daz) == ((cstat&8)==0))
continue;
Expand All @@ -1101,8 +1102,8 @@ void getzrange_(const vec3_t *pos, int16_t sectnum,
get_floorspr_points((uspriteptr_t) &sprite[j], pos->x, pos->y, &v1.x, &v2.x, &v3.x, &v4.x,
&v1.y, &v2.y, &v3.y, &v4.y);

vec2_t const da = { MulScale(bcos(sprite[j].ang - 256), walldist + 4, 14),
MulScale(bsin(sprite[j].ang - 256), walldist + 4, 14) };
vec2_t const da = { MulScale(bcos(spr->ang - 256), walldist + 4, 14),
MulScale(bsin(spr->ang - 256), walldist + 4, 14) };

v1.x += da.x; v2.x -= da.y; v3.x -= da.x; v4.x += da.y;
v1.y += da.y; v2.y += da.x; v3.y -= da.y; v4.y -= da.x;
Expand Down Expand Up @@ -1197,8 +1198,8 @@ static int32_t hitscan_trysector(const vec3_t *sv, usectorptr_t sec, hitdata_t *

if (stat&2)
{
auto const wal = (uwallptr_t)&wall[sec->wallptr];
auto const wal2 = (uwallptr_t)&wall[wal->point2];
auto const wal = (uwallptr_t)sec->firstWall();
auto const wal2 = (uwallptr_t)wal->point2Wall();
int32_t j, dax=wal2->x-wal->x, day=wal2->y-wal->y;

i = ksqrt(compat_maybe_truncate_to_int32(uhypsq(dax,day))); if (i == 0) return 1; //continue;
Expand Down Expand Up @@ -1306,7 +1307,7 @@ int32_t hitscan_(const vec3_t *sv, int16_t sectnum, int32_t vx, int32_t vy, int3
for (z=startwall; z<endwall; z++)
{
auto const wal = (uwallptr_t)&wall[z];
auto const wal2 = (uwallptr_t)&wall[wal->point2];
auto const wal2 = (uwallptr_t)wal->point2Wall();

int const nextsector = wal->nextsector;

Expand Down
43 changes: 22 additions & 21 deletions source/build/src/engine.cpp
Expand Up @@ -690,15 +690,15 @@ int32_t inside(int32_t x, int32_t y, int sectnum)
if (validSectorIndex(sectnum))
{
uint32_t cnt = 0;
auto wal = (uwallptr_t)&wall[sector[sectnum].wallptr];
auto wal = (uwallptr_t)sector[sectnum].firstWall();
int wallsleft = sector[sectnum].wallnum;

do
{
// Get the x and y components of the [tested point]-->[wall
// point{1,2}] vectors.
vec2_t v1 = { wal->x - x, wal->y - y };
auto const &wal2 = *(uwallptr_t)&wall[wal->point2];
auto const &wal2 = *(uwallptr_t)wal->point2Wall();
vec2_t v2 = { wal2.x - x, wal2.y - y };

// If their signs differ[*], ...
Expand Down Expand Up @@ -813,7 +813,7 @@ int32_t nextsectorneighborz(int16_t sectnum, int32_t refz, int16_t topbottom, in
int32_t nextz = (direction==1) ? INT32_MAX : INT32_MIN;
int32_t sectortouse = -1;

auto wal = (uwallptr_t)&wall[sector[sectnum].wallptr];
auto wal = (uwallptr_t)sector[sectnum].firstWall();
int32_t i = sector[sectnum].wallnum;

do
Expand Down Expand Up @@ -863,9 +863,9 @@ int32_t cansee(int32_t x1, int32_t y1, int32_t z1, int16_t sect1, int32_t x2, in
auto const sec = (usectorptr_t)&sector[dasectnum];
uwallptr_t wal;
bssize_t cnt;
for (cnt=sec->wallnum,wal=(uwallptr_t)&wall[sec->wallptr]; cnt>0; cnt--,wal++)
for (cnt=sec->wallnum,wal=(uwallptr_t)sec->firstWall(); cnt>0; cnt--,wal++)
{
auto const wal2 = (uwallptr_t)&wall[wal->point2];
auto const wal2 = (uwallptr_t)wal->point2Wall();
const int32_t x31 = wal->x-x1, x34 = wal->x-wal2->x;
const int32_t y31 = wal->y-y1, y34 = wal->y-wal2->y;

Expand Down Expand Up @@ -943,7 +943,7 @@ void neartag_(int32_t xs, int32_t ys, int32_t zs, int16_t sectnum, int16_t ange,

for (z=startwall,wal=(uwallptr_t)&wall[startwall]; z<=endwall; z++,wal++)
{
auto const wal2 = (uwallptr_t)&wall[wal->point2];
auto const wal2 = (uwallptr_t)wal->point2Wall();
const int32_t nextsector = wal->nextsector;

const int32_t x1=wal->x, y1=wal->y, x2=wal2->x, y2=wal2->y;
Expand Down Expand Up @@ -1020,15 +1020,16 @@ void dragpoint(int w, int32_t dax, int32_t day)

while (1)
{
sector[wall[w].sector].dirty = 255;
wall[w].x = dax;
wall[w].y = day;
auto wal = &wall[w];
sector[wal->sector].dirty = 255;
wal->x = dax;
wal->y = day;
walbitmap.Set(w);

if (!clockwise) //search points CCW
{
if (wall[w].nextwall >= 0)
w = wall[wall[w].nextwall].point2;
if (wal->nextwall >= 0)
w = wall[wal->nextwall].point2;
else
{
w = tmpstartwall;
Expand Down Expand Up @@ -1340,8 +1341,8 @@ int32_t getceilzofslopeptr(usectorptr_t sec, int32_t dax, int32_t day)
if (!(sec->ceilingstat&2))
return sec->ceilingz;

auto const wal = (uwallptr_t)&wall[sec->wallptr];
auto const wal2 = (uwallptr_t)&wall[wal->point2];
auto const wal = (uwallptr_t)sec->firstWall();
auto const wal2 = (uwallptr_t)wal->point2Wall();

vec2_t const w = *(vec2_t const *)wal;
vec2_t const d = { wal2->x - w.x, wal2->y - w.y };
Expand All @@ -1359,8 +1360,8 @@ int32_t getflorzofslopeptr(usectorptr_t sec, int32_t dax, int32_t day)
if (!(sec->floorstat&2))
return sec->floorz;

auto const wal = (uwallptr_t)&wall[sec->wallptr];
auto const wal2 = (uwallptr_t)&wall[wal->point2];
auto const wal = (uwallptr_t)sec->firstWall();
auto const wal2 = (uwallptr_t)wal->point2Wall();

vec2_t const w = *(vec2_t const *)wal;
vec2_t const d = { wal2->x - w.x, wal2->y - w.y };
Expand All @@ -1380,8 +1381,8 @@ void getzsofslopeptr(usectorptr_t sec, int32_t dax, int32_t day, int32_t *ceilz,
if (((sec->ceilingstat|sec->floorstat)&2) != 2)
return;

auto const wal = (uwallptr_t)&wall[sec->wallptr];
auto const wal2 = (uwallptr_t)&wall[wal->point2];
auto const wal = (uwallptr_t)sec->firstWall();
auto const wal2 = (uwallptr_t)wal->point2Wall();

vec2_t const d = { wal2->x - wal->x, wal2->y - wal->y };

Expand All @@ -1402,8 +1403,8 @@ void getzsofslopeptr(usectorptr_t sec, int32_t dax, int32_t day, int32_t *ceilz,
void alignceilslope(int16_t dasect, int32_t x, int32_t y, int32_t z)
{
auto const wal = (uwallptr_t)&wall[sector[dasect].wallptr];
const int32_t dax = wall[wal->point2].x-wal->x;
const int32_t day = wall[wal->point2].y-wal->y;
const int32_t dax = wal->point2Wall()->x-wal->x;
const int32_t day = wal->point2Wall()->y-wal->y;

const int32_t i = (y-wal->y)*dax - (x-wal->x)*day;
if (i == 0)
Expand All @@ -1423,8 +1424,8 @@ 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)
{
auto const wal = (uwallptr_t)&wall[sector[dasect].wallptr];
const int32_t dax = wall[wal->point2].x-wal->x;
const int32_t day = wall[wal->point2].y-wal->y;
const int32_t dax = wal->point2Wall()->x-wal->x;
const int32_t day = wal->point2Wall()->y-wal->y;

const int32_t i = (y-wal->y)*dax - (x-wal->x)*day;
if (i == 0)
Expand Down
30 changes: 15 additions & 15 deletions source/build/src/polymost.cpp
Expand Up @@ -999,8 +999,8 @@ static void polymost_internal_nonparallaxed(vec2f_t n0, vec2f_t n1, float ryp0,
if (globalorientation & 64)
{
//relative alignment
vec2_t const xy = { wall[wall[sec->wallptr].point2].x - wall[sec->wallptr].x,
wall[wall[sec->wallptr].point2].y - wall[sec->wallptr].y };
vec2_t const xy = { wall[sec->firstWall()->point2].x - sec->firstWall()->x,
wall[sec->firstWall()->point2].y - sec->firstWall()->y };
float r;

int length = ksqrt(uhypsq(xy.x, xy.y));
Expand All @@ -1016,8 +1016,8 @@ static void polymost_internal_nonparallaxed(vec2f_t n0, vec2f_t n1, float ryp0,

vec2f_t const fxy = { xy.x*r, xy.y*r };

ft[0] = ((float)(globalposx - wall[sec->wallptr].x)) * fxy.x + ((float)(globalposy - wall[sec->wallptr].y)) * fxy.y;
ft[1] = ((float)(globalposy - wall[sec->wallptr].y)) * fxy.x - ((float)(globalposx - wall[sec->wallptr].x)) * fxy.y;
ft[0] = ((float)(globalposx - sec->firstWall()->x)) * fxy.x + ((float)(globalposy - sec->firstWall()->y)) * fxy.y;
ft[1] = ((float)(globalposy - sec->firstWall()->y)) * fxy.x - ((float)(globalposx - sec->firstWall()->x)) * fxy.y;
ft[2] = fcosglobalang * fxy.x + fsinglobalang * fxy.y;
ft[3] = fsinglobalang * fxy.x - fcosglobalang * fxy.y;

Expand Down Expand Up @@ -1247,8 +1247,8 @@ static float fgetceilzofslope(usectorptr_t sec, float dax, float day)
if (!(sec->ceilingstat&2))
return float(sec->ceilingz);

auto const wal = (uwallptr_t)&wall[sec->wallptr];
auto const wal2 = (uwallptr_t)&wall[wal->point2];
auto const wal = (uwallptr_t)sec->firstWall();
auto const wal2 = (uwallptr_t)wal->point2Wall();

vec2_t const w = *(vec2_t const *)wal;
vec2_t const d = { wal2->x - w.x, wal2->y - w.y };
Expand All @@ -1265,8 +1265,8 @@ static float fgetflorzofslope(usectorptr_t sec, float dax, float day)
if (!(sec->floorstat&2))
return float(sec->floorz);

auto const wal = (uwallptr_t)&wall[sec->wallptr];
auto const wal2 = (uwallptr_t)&wall[wal->point2];
auto const wal = (uwallptr_t)sec->firstWall();
auto const wal2 = (uwallptr_t)wal->point2Wall();

vec2_t const w = *(vec2_t const *)wal;
vec2_t const d = { wal2->x - w.x, wal2->y - w.y };
Expand All @@ -1285,8 +1285,8 @@ static void fgetzsofslope(usectorptr_t sec, float dax, float day, float* ceilz,
if (((sec->ceilingstat|sec->floorstat)&2) != 2)
return;

auto const wal = (uwallptr_t)&wall[sec->wallptr];
auto const wal2 = (uwallptr_t)&wall[wal->point2];
auto const wal = (uwallptr_t)sec->firstWall();
auto const wal2 = (uwallptr_t)wal->point2Wall();

vec2_t const d = { wal2->x - wal->x, wal2->y - wal->y };

Expand Down Expand Up @@ -1515,7 +1515,7 @@ static void polymost_drawalls(int32_t const bunch)
int32_t const wallnum = thewall[z];

auto const wal = (uwallptr_t)&wall[wallnum];
auto const wal2 = (uwallptr_t)&wall[wal->point2];
auto const wal2 = (uwallptr_t)wal->point2Wall();
int32_t const nextsectnum = wal->nextsector;
auto const nextsec = nextsectnum>=0 ? (usectorptr_t)&sector[nextsectnum] : NULL;

Expand Down Expand Up @@ -1949,7 +1949,7 @@ void polymost_scansector(int32_t sectnum)

for (z=startwall,wal=(uwallptr_t)&wall[z]; z<endwall; z++,wal++)
{
auto const wal2 = (uwallptr_t)&wall[wal->point2];
auto const wal2 = (uwallptr_t)wal->point2Wall();

DVector2 const fp1 = { double(wal->x - globalposx), double(wal->y - globalposy) };
DVector2 const fp2 = { double(wal2->x - globalposx), double(wal2->y - globalposy) };
Expand Down Expand Up @@ -2332,16 +2332,16 @@ void polymost_drawrooms()
static void polymost_drawmaskwallinternal(int32_t wallIndex)
{
auto const wal = (uwallptr_t)&wall[wallIndex];
auto const wal2 = (uwallptr_t)&wall[wal->point2];
auto const wal2 = (uwallptr_t)wal->point2Wall();
if (wal->nextwall == -1) return;
int32_t const sectnum = wall[wal->nextwall].nextsector;
int32_t const sectnum = wal->nextWall()->nextsector;
auto const sec = (usectorptr_t)&sector[sectnum];

// if (wal->nextsector < 0) return;
// Without MASKWALL_BAD_ACCESS fix:
// wal->nextsector is -1, WGR2 SVN Lochwood Hollow (Til' Death L1) (or trueror1.map)

auto const nsec = (usectorptr_t)&sector[wal->nextsector];
auto const nsec = (usectorptr_t)wal->nextSector();

polymost_outputGLDebugMessage(3, "polymost_drawmaskwallinternal(wallIndex:%d)", wallIndex);

Expand Down

0 comments on commit 480070b

Please sign in to comment.