- use sectnum and wallnum to get an index from pointers instead of subtracting the array base.

This commit is contained in:
Christoph Oelckers 2021-11-11 20:20:00 +01:00
parent 3a259c9c46
commit adf3133fdc
24 changed files with 81 additions and 78 deletions

View file

@ -19,7 +19,7 @@ typedef struct
int32_t x1, y1, x2, y2;
} linetype;
extern int16_t clipsectorlist[MAXCLIPSECTORS];
extern int clipsectorlist[MAXCLIPSECTORS];
int clipinsidebox(vec2_t *vect, int wallnum, int walldist);
inline int clipinsidebox(int x, int y, int wall, int dist)

View file

@ -14,11 +14,11 @@
enum { MAXCLIPDIST = 1024 };
static int16_t clipnum;
static int clipnum;
static linetype clipit[MAXCLIPNUM];
static int32_t clipsectnum, origclipsectnum, clipspritenum;
int16_t clipsectorlist[MAXCLIPSECTORS];
static int16_t origclipsectorlist[MAXCLIPSECTORS];
int clipsectorlist[MAXCLIPSECTORS];
static int origclipsectorlist[MAXCLIPSECTORS];
static uint8_t clipsectormap[(MAXSECTORS+7)>>3];
static uint8_t origclipsectormap[(MAXSECTORS+7)>>3];
static int16_t clipobjectval[MAXCLIPNUM];
@ -1047,7 +1047,7 @@ void getzrange(const vec3_t *pos, int16_t sectnum,
for (bssize_t i=0; i<clipsectnum; i++)
{
int j;
if (clipsectorlist[i] == MAXSECTORS) continue; // we got a deleted sprite in here somewhere. Skip this entry.
if (!validSectorIndex(clipsectorlist[i])) continue; // we got a deleted sprite in here somewhere. Skip this entry.
SectIterator it(clipsectorlist[i]);
while ((j = it.NextIndex()) >= 0)
{
@ -1233,9 +1233,9 @@ static int32_t hitscan_trysector(const vec3_t *sv, usectorptr_t sec, hitdata_t *
{
if (tmp==NULL)
{
if (inside(x1,y1,int(sec-sector)) == 1)
if (inside(x1,y1,sectnum(sec)) == 1)
{
hit_set(hit, int(sec-sector), -1, -1, x1, y1, z1);
hit_set(hit, sectnum(sec), -1, -1, x1, y1, z1);
hitscan_hitsectcf = (how+1)>>1;
}
}
@ -1247,7 +1247,7 @@ static int32_t hitscan_trysector(const vec3_t *sv, usectorptr_t sec, hitdata_t *
if (!thislastsec)
{
if (inside(x1,y1,int(sec-sector)) == 1)
if (inside(x1,y1,sectnum(sec)) == 1)
hit_set(hit, int(curspr->sectnum), -1, int(curspr-sprite), x1, y1, z1);
}
}

View file

@ -237,12 +237,12 @@ inline int32_t getangle(walltype* wal)
inline TArrayView<sectortype> sectors()
{
return TArrayView<sectortype>(sector, numsectors);
return TArrayView<sectortype>(&sector[0], numsectors);
}
inline TArrayView<walltype> walls()
{
return TArrayView<walltype>(wall, numwalls);
return TArrayView<walltype>(&wall[0], numwalls);
}
inline TArrayView<walltype> wallsofsector(sectortype* sec)
@ -256,12 +256,12 @@ inline TArrayView<walltype> wallsofsector(int sec)
}
// these are mainly meant as refactoring aids to mark function calls to work on.
inline int wallnum(walltype* wal)
inline int wallnum(const walltype* wal)
{
return int(wal - wall);
}
inline int sectnum(sectortype* sect)
inline int sectnum(const sectortype* sect)
{
return int(sect - sector);
}

View file

@ -150,7 +150,7 @@ void HWFlat::DrawFlat(HWDrawInfo *di, FRenderState &state, bool translucent)
}
#ifdef _DEBUG
if (sec - sector == gl_breaksec)
if (sectnum(sec) == gl_breaksec)
{
int a = 0;
}
@ -241,7 +241,7 @@ void HWFlat::PutFlat(HWDrawInfo *di, int whichplane)
void HWFlat::ProcessSector(HWDrawInfo *di, sectortype * frontsector, int section_, int which)
{
#ifdef _DEBUG
if (frontsector - sector == gl_breaksec)
if (sectnum(sec) == gl_breaksec)
{
int a = 0;
}

View file

@ -968,7 +968,7 @@ void HWWall::Process(HWDrawInfo* di, walltype* wal, sectortype* frontsector, sec
#ifdef _DEBUG
if (wal - wall == 6468)
if (wallnum(wal) == 6468)
{
int a = 0;
}
@ -1036,7 +1036,7 @@ void HWWall::Process(HWDrawInfo* di, walltype* wal, sectortype* frontsector, sec
int tilenum = ((wal->cstat & CSTAT_WALL_1WAY) && wal->nextwall != -1) ? wal->overpicnum : wal->picnum;
setgotpic(tilenum);
tileUpdatePicnum(&tilenum, int(wal-wall) + 16384, wal->cstat);
tileUpdatePicnum(&tilenum, wallnum(wal) + 16384, wal->cstat);
texture = tileGetTexture(tilenum);
if (texture && texture->isValid())
{
@ -1074,7 +1074,7 @@ void HWWall::Process(HWDrawInfo* di, walltype* wal, sectortype* frontsector, sec
{
int tilenum = wal->picnum;
setgotpic(tilenum);
tileUpdatePicnum(&tilenum, int(wal - wall) + 16384, wal->cstat);
tileUpdatePicnum(&tilenum, wallnum(wal) + 16384, wal->cstat);
texture = tileGetTexture(tilenum);
if (texture && texture->isValid())
{
@ -1087,7 +1087,7 @@ void HWWall::Process(HWDrawInfo* di, walltype* wal, sectortype* frontsector, sec
{
int tilenum = wal->overpicnum;
setgotpic(tilenum);
tileUpdatePicnum(&tilenum, int(wal - wall) + 16384, wal->cstat);
tileUpdatePicnum(&tilenum, wallnum(wal) + 16384, wal->cstat);
texture = tileGetTexture(tilenum);
if (texture && texture->isValid())
{
@ -1113,7 +1113,7 @@ void HWWall::Process(HWDrawInfo* di, walltype* wal, sectortype* frontsector, sec
auto w = (wal->cstat & CSTAT_WALL_BOTTOM_SWAP) ? backwall : wal;
int tilenum = w->picnum;
setgotpic(tilenum);
tileUpdatePicnum(&tilenum, int(wal - wall) + 16384, w->cstat);
tileUpdatePicnum(&tilenum, wallnum(wal) + 16384, w->cstat);
texture = tileGetTexture(tilenum);
if (texture && texture->isValid())
{

View file

@ -2,6 +2,7 @@
#include "resourcefile.h"
#include "build.h"
#include "gamefuncs.h"
extern FixedBitArray<MAXSPRITES> activeSprites;
@ -32,17 +33,17 @@ inline FSerializer& Serialize(FSerializer& arc, const char* keyname, spritetype*
inline FSerializer& Serialize(FSerializer& arc, const char* keyname, sectortype*& w, sectortype** def)
{
int ndx = w ? int(w - sector) : -1;
int ndx = w ? sectnum(w) : -1;
arc(keyname, ndx);
w = ndx == -1 ? nullptr : sector + ndx;
w = ndx == -1 ? nullptr : &sector[ndx];
return arc;
}
inline FSerializer& Serialize(FSerializer& arc, const char* keyname, walltype*& w, walltype** def)
{
int ndx = w ? int(w - wall) : -1;
int ndx = w ? wallnum(w) : -1;
arc(keyname, ndx);
w = ndx == -1 ? nullptr : wall + ndx;
w = ndx == -1 ? nullptr : &wall[ndx];
return arc;
}

View file

@ -1850,7 +1850,7 @@ void ProcessMotion(void)
{
sectortype *pSector;
int nSector;
for (pSector = sector, nSector = 0; nSector < numsectors; nSector++, pSector++)
for (pSector = &sector[0], nSector = 0; nSector < numsectors; nSector++, pSector++)
{
int nXSector = pSector->extra;
if (nXSector <= 0)
@ -1927,7 +1927,7 @@ void AlignSlopes(void)
{
sectortype *pSector;
int nSector;
for (pSector = sector, nSector = 0; nSector < numsectors; nSector++, pSector++)
for (pSector = &sector[0], nSector = 0; nSector < numsectors; nSector++, pSector++)
{
if (qsector_filler[nSector])
{

View file

@ -38,6 +38,7 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms
#include "tags.h"
#include "weapon.h"
#include "sprite.h"
#include "gamefuncs.h"
BEGIN_SW_NS
@ -525,8 +526,8 @@ void KeepActorOnFloor(DSWActor* actor)
if (TEST(u->Flags, SPR_JUMPING | SPR_FALLING))
return;
if (u->lo_sectp && SectUser[u->lo_sectp - sector].Data())
depth = FixedToInt(SectUser[u->lo_sectp - sector]->depth_fixed);
if (u->lo_sectp && SectUser[sectnum(u->lo_sectp)].Data())
depth = FixedToInt(SectUser[sectnum(u->lo_sectp)]->depth_fixed);
else
depth = 0;
@ -690,9 +691,6 @@ int DoActorJump(DSWActor* actor)
// have started falling
if ((u->jump_speed += jump_adj) > 0)
{
//DSPRINTF(ds,"Actor Jump Height %d", labs(sp->z - sector[sp->sectnum].floorz)>>8 );
MONO_PRINT(ds);
// Start falling
DoActorBeginFall(actor);
return 0;

View file

@ -809,7 +809,7 @@ bool HitBreakWall(WALLp wp, int hit_x, int hit_y, int hit_z, short ang, short ty
//if (hit_x == INT32_MAX)
{
int sectnum;
WallBreakPosition(short(wp - wall), &sectnum, &hit_x, &hit_y, &hit_z, &ang);
WallBreakPosition(wallnum(wp), &sectnum, &hit_x, &hit_y, &hit_z, &ang);
}
AutoBreakWall(wp, hit_x, hit_y, hit_z, ang, type);

View file

@ -77,7 +77,7 @@ void precacheMap(void)
WALLp wp;
SPRITEp sp;
for (sectp = sector; sectp < &sector[numsectors]; sectp++)
for (sectp = &sector[0]; sectp < &sector[numsectors]; sectp++)
{
j = sectp->ceilingpicnum;
markTileForPrecache(j, sectp->ceilingpal);
@ -104,7 +104,7 @@ void precacheMap(void)
}
for (wp = wall; wp < &wall[numwalls]; wp++)
for (wp = &wall[0]; wp < &wall[numwalls]; wp++)
{
j = wp->picnum;

View file

@ -654,8 +654,8 @@ int DoCoolgMatchPlayerZ(DSWActor* actor)
hiz = u->hiz;
// adjust loz/hiz for water depth
if (u->lo_sectp && SectUser[u->lo_sectp - sector].Data() && FixedToInt(SectUser[u->lo_sectp - sector]->depth_fixed))
loz -= Z(FixedToInt(SectUser[u->lo_sectp - sector]->depth_fixed)) - Z(8);
if (u->lo_sectp && SectUser[sectnum(u->lo_sectp)].Data() && FixedToInt(SectUser[sectnum(u->lo_sectp)]->depth_fixed))
loz -= Z(FixedToInt(SectUser[sectnum(u->lo_sectp)]->depth_fixed)) - Z(8);
// lower bound
if (u->lowActor)

View file

@ -474,15 +474,15 @@ void EnemyDefaults(DSWActor* actor, ACTOR_ACTION_SETp action, PERSONALITYp perso
if (u->lo_sectp) // && SectUser[u->lo_sectp - sector])
{
int i;
short sectnum = short(u->lo_sectp - sector);
int sectno = sectnum(u->lo_sectp);
if (SectUser[sectnum].Data() && TEST(u->lo_sectp->extra, SECTFX_SINK))
if (SectUser[sectno].Data() && TEST(u->lo_sectp->extra, SECTFX_SINK))
{
depth = FixedToInt(SectUser[sectnum]->depth_fixed);
depth = FixedToInt(SectUser[sectno]->depth_fixed);
}
else
{
SWSectIterator it(sectnum);
SWSectIterator it(sectno);
while (auto itActor = it.Next())
{
SPRITEp np = &itActor->s();

View file

@ -98,7 +98,7 @@ void CopySectorWalls(short dest_sectnum, short src_sectnum)
continue;
for (sectp = sop->sectp; *sectp; sectp++)
if (*sectp - sector == dest_sectnum)
if (sectnum(*sectp) == dest_sectnum)
{
so_setinterpolationtics(sop, 0);
break;

View file

@ -471,8 +471,8 @@ int DoEelMatchPlayerZ(DSWActor* actor)
hiz = u->hiz;
// adjust loz/hiz for water depth
if (u->lo_sectp && SectUser[u->lo_sectp - sector].Data() && FixedToInt(SectUser[u->lo_sectp - sector]->depth_fixed))
loz -= Z(FixedToInt(SectUser[u->lo_sectp - sector]->depth_fixed)) - Z(8);
if (u->lo_sectp && SectUser[sectnum(u->lo_sectp)].Data() && FixedToInt(SectUser[sectnum(u->lo_sectp)]->depth_fixed))
loz -= Z(FixedToInt(SectUser[sectnum(u->lo_sectp)]->depth_fixed)) - Z(8);
// lower bound
if (u->lowActor && u->targetActor == u->highActor) // this doesn't look right...

View file

@ -377,8 +377,8 @@ int DoHornetMatchPlayerZ(DSWActor* actor)
hiz = u->hiz;
// adjust loz/hiz for water depth
if (u->lo_sectp && SectUser[u->lo_sectp - sector].Data() && FixedToInt(SectUser[u->lo_sectp - sector]->depth_fixed))
loz -= Z(FixedToInt(SectUser[u->lo_sectp - sector]->depth_fixed)) - Z(8);
if (u->lo_sectp && SectUser[sectnum(u->lo_sectp)].Data() && FixedToInt(SectUser[sectnum(u->lo_sectp)]->depth_fixed))
loz -= Z(FixedToInt(SectUser[sectnum(u->lo_sectp)]->depth_fixed)) - Z(8);
// lower bound
if (u->lowActor)

View file

@ -206,8 +206,8 @@ void so_addinterpolation(SECTOR_OBJECTp sop)
if (!interp->hasvator)
for (sectp = sop->sectp; *sectp; sectp++)
{
so_setpointinterpolation(interp, int(*sectp - sector) | soi_floor);
so_setpointinterpolation(interp, int(*sectp - sector) | soi_ceil);
so_setpointinterpolation(interp, sectnum(*sectp) | soi_floor);
so_setpointinterpolation(interp, sectnum(*sectp) | soi_ceil);
}
// interpolate midpoint, for aiming at a remote controlled SO

View file

@ -357,8 +357,8 @@ MorphTornado(SECTOR_OBJECTp sop)
for (sectp = sop->sectp, j = 0; *sectp; sectp++, j++)
{
if (SectUser[*sectp - sector].Data() &&
TEST(SectUser[*sectp - sector]->flags, SECTFU_SO_SLOPE_CEILING_TO_POINT))
if (SectUser[sectnum(*sectp)].Data() &&
TEST(SectUser[sectnum(*sectp)]->flags, SECTFU_SO_SLOPE_CEILING_TO_POINT))
{
#define TOR_LOW (floorz)
if (sop->morph_z > TOR_LOW)
@ -372,7 +372,7 @@ MorphTornado(SECTOR_OBJECTp sop)
sop->morph_z = ceilingz;
}
alignceilslope(int16_t(*sectp - sector), mx, my, sop->morph_z);
alignceilslope(sectnum(*sectp), mx, my, sop->morph_z);
}
}
}
@ -450,10 +450,10 @@ MorphFloor(SECTOR_OBJECTp sop)
for (sectp = sop->sectp, j = 0; *sectp; sectp++, j++)
{
if (SectUser[*sectp - sector].Data() &&
TEST(SectUser[*sectp - sector]->flags, SECTFU_SO_SLOPE_CEILING_TO_POINT))
if (SectUser[sectnum(*sectp)].Data() &&
TEST(SectUser[sectnum(*sectp)]->flags, SECTFU_SO_SLOPE_CEILING_TO_POINT))
{
alignflorslope(int16_t(*sectp - sector), mx, my, floorz + sop->morph_z);
alignflorslope(sectnum(*sectp), mx, my, floorz + sop->morph_z);
}
}
}
@ -466,10 +466,10 @@ SOBJ_AlignFloorToPoint(SECTOR_OBJECTp sop, int x, int y, int z)
for (sectp = sop->sectp, j = 0; *sectp; sectp++, j++)
{
if (SectUser[*sectp - sector].Data() &&
TEST(SectUser[*sectp - sector]->flags, SECTFU_SO_SLOPE_CEILING_TO_POINT))
if (SectUser[sectnum(*sectp)].Data() &&
TEST(SectUser[sectnum(*sectp)]->flags, SECTFU_SO_SLOPE_CEILING_TO_POINT))
{
alignflorslope(int16_t(*sectp - sector), x, y, z);
alignflorslope(int16_t(sectnum(*sectp)), x, y, z);
}
}
}
@ -482,10 +482,10 @@ SOBJ_AlignCeilingToPoint(SECTOR_OBJECTp sop, int x, int y, int z)
for (sectp = sop->sectp, j = 0; *sectp; sectp++, j++)
{
if (SectUser[*sectp - sector].Data() &&
TEST(SectUser[*sectp - sector]->flags, SECTFU_SO_SLOPE_CEILING_TO_POINT))
if (SectUser[sectnum(*sectp)].Data() &&
TEST(SectUser[sectnum(*sectp)]->flags, SECTFU_SO_SLOPE_CEILING_TO_POINT))
{
alignceilslope(int16_t(*sectp - sector), x, y, z);
alignceilslope(int16_t(sectnum(*sectp)), x, y, z);
}
}
}
@ -498,11 +498,11 @@ SOBJ_AlignFloorCeilingToPoint(SECTOR_OBJECTp sop, int x, int y, int z)
for (sectp = sop->sectp, j = 0; *sectp; sectp++, j++)
{
if (SectUser[*sectp - sector].Data() &&
TEST(SectUser[*sectp - sector]->flags, SECTFU_SO_SLOPE_CEILING_TO_POINT))
if (SectUser[sectnum(*sectp)].Data() &&
TEST(SectUser[sectnum(*sectp)]->flags, SECTFU_SO_SLOPE_CEILING_TO_POINT))
{
alignflorslope(int16_t(*sectp - sector), x, y, z);
alignceilslope(int16_t(*sectp - sector), x, y, z);
alignflorslope(sectnum(*sectp), x, y, z);
alignceilslope(sectnum(*sectp), x, y, z);
}
}
}

View file

@ -1442,8 +1442,8 @@ void DoPlayerSetWadeDepth(PLAYERp pp)
if (TEST(sectp->extra, SECTFX_SINK))
{
// make sure your even in the water
if (pp->posz + PLAYER_HEIGHT > pp->lo_sectp->floorz - Z(FixedToInt(SectUser[pp->lo_sectp - sector]->depth_fixed)))
pp->WadeDepth = FixedToInt(SectUser[pp->lo_sectp - sector]->depth_fixed);
if (pp->posz + PLAYER_HEIGHT > pp->lo_sectp->floorz - Z(FixedToInt(SectUser[sectnum(pp->lo_sectp)]->depth_fixed)))
pp->WadeDepth = FixedToInt(SectUser[sectnum(pp->lo_sectp)]->depth_fixed);
}
}

View file

@ -131,7 +131,7 @@ void WallSetupDontMove(void)
if (spu->lotag == spl->lotag)
{
for (wallp = wall; wallp < &wall[numwalls]; wallp++)
for (wallp = &wall[0]; wallp < &wall[numwalls]; wallp++)
{
if (wallp->x < spl->x && wallp->x > spu->x && wallp->y < spl->y && wallp->y > spu->y)
{
@ -177,7 +177,7 @@ void WallSetup(void)
extern int x_min_bound, y_min_bound, x_max_bound, y_max_bound;
for (wp = wall, i = 0; i < numwalls; i++, wp++)
for (wp = &wall[0]; wp < &wall[numwalls]; wp++)
{
if (wp->picnum == FAF_PLACE_MIRROR_PIC)
wp->picnum = FAF_MIRROR_PIC;

View file

@ -6730,7 +6730,7 @@ int MissileWaterAdjust(DSWActor* actor)
if (u->lo_sectp)
{
SECT_USERp sectu = SectUser[u->lo_sectp - sector].Data();
SECT_USERp sectu = SectUser[sectnum(u->lo_sectp)].Data();
if (sectu && FixedToInt(sectu->depth_fixed))
u->loz -= Z(FixedToInt(sectu->depth_fixed));
}

View file

@ -80,6 +80,10 @@ public:
{
}
SWSectIterator(sectortype* stat) : SectIterator(stat)
{
}
DSWActor* Next()
{
int n = NextIndex();

View file

@ -1753,13 +1753,13 @@ PlayerPart:
if (!pp->lo_sectp)
continue;
if (TEST(sector[pp->lo_sectp - sector].extra, SECTFX_NO_RIDE))
if (TEST(sector[sectnum(pp->lo_sectp)].extra, SECTFX_NO_RIDE))
{
continue;
}
// move the player
if (pp->lo_sectp - sector == sop->sector[j])
if (sectnum(pp->lo_sectp) == sop->sector[j])
{
if (PlayerMove)
MovePlayer(pp, sop, nx, ny);
@ -2169,7 +2169,7 @@ void MoveZ(SECTOR_OBJECTp sop)
{
for (i = 0, sectp = &sop->sectp[0]; *sectp; sectp++, i++)
{
AnimSet(ANIM_Floorz, int(*sectp - sector), nullptr, sop->zorig_floor[i] + sop->z_tgt, sop->z_rate);
AnimSet(ANIM_Floorz, sectnum(*sectp), nullptr, sop->zorig_floor[i] + sop->z_tgt, sop->z_rate);
}
RESET(sop->flags, SOBJ_ZDOWN);
@ -2178,7 +2178,7 @@ void MoveZ(SECTOR_OBJECTp sop)
{
for (i = 0, sectp = &sop->sectp[0]; *sectp; sectp++, i++)
{
AnimSet(ANIM_Floorz, int(*sectp - sector), nullptr, sop->zorig_floor[i] + sop->z_tgt, sop->z_rate);
AnimSet(ANIM_Floorz, sectnum(*sectp), nullptr, sop->zorig_floor[i] + sop->z_tgt, sop->z_rate);
}
RESET(sop->flags, SOBJ_ZUP);
@ -2514,7 +2514,7 @@ void DoTrack(SECTOR_OBJECTp sop, short locktics, int *nx, int *ny)
if (SectUser[sop->sector[i]].Data() && TEST(SectUser[sop->sector[i]]->flags, SECTFU_SO_DONT_SINK))
continue;
ndx = AnimSet(ANIM_Floorz, int(*sectp-sector), nullptr, sector[dest_sector].floorz, tpoint->tag_high);
ndx = AnimSet(ANIM_Floorz, sectnum(*sectp), nullptr, sector[dest_sector].floorz, tpoint->tag_high);
AnimSetCallback(ndx, CallbackSOsink, sop);
AnimSetVelAdj(ndx, 6);
}
@ -2531,11 +2531,11 @@ void DoTrack(SECTOR_OBJECTp sop, short locktics, int *nx, int *ny)
for (i = 0, sectp = &sop->sectp[0]; *sectp; sectp++, i++)
{
sectu = SectUser[*sectp - sector].Data();
sectu = SectUser[sectnum(*sectp)].Data();
if (sectu && sectu->stag == SECT_SO_FORM_WHIRLPOOL)
{
AnimSet(ANIM_Floorz, int(*sectp - sector), nullptr, (*sectp)->floorz + Z(sectu->height), 128);
AnimSet(ANIM_Floorz, sectnum(*sectp), nullptr, (*sectp)->floorz + Z(sectu->height), 128);
(*sectp)->floorshade += sectu->height/6;
RESET((*sectp)->extra, SECTFX_NO_RIDE);
@ -2760,7 +2760,7 @@ void VehicleSetSmoke(SECTOR_OBJECTp sop, ANIMATORp animator)
for (sectp = sop->sectp; *sectp; sectp++)
{
SWSectIterator it(int(*sectp - sector));
SWSectIterator it(*sectp);
while (auto actor = it.Next())
{
USERp u = actor->u();

View file

@ -106,7 +106,7 @@ int DoWallMove(DSWActor* actor)
nx = MulScale(dist, bcos(ang), 14);
ny = MulScale(dist, bsin(ang), 14);
for (wallp = wall; wallp < &wall[numwalls]; wallp++)
for (wallp = &wall[0]; wallp < &wall[numwalls]; wallp++)
{
if (wallp->x == sp->x && wallp->y == sp->y)
{
@ -134,7 +134,7 @@ int DoWallMove(DSWActor* actor)
wallp->picnum = picnum1;
// find the previous wall
prev_wall = PrevWall(short(wallp - wall));
prev_wall = PrevWall(wallnum(wallp));
if (shade2)
wall[prev_wall].shade = int8_t(shade2);
if (picnum2)

View file

@ -18479,7 +18479,7 @@ int DoBubble(DSWActor* actor)
if (sp->z < sector[sp->sectnum].ceilingz)
{
if (SectorIsUnderwaterArea(int(u->hi_sectp - sector)))
if (SectorIsUnderwaterArea(sectnum(u->hi_sectp)))
{
if (!SpriteWarpToSurface(actor))
{