- sectnum reduction.

This commit is contained in:
Christoph Oelckers 2021-12-02 00:13:07 +01:00
parent 4c13f24357
commit a22634f228
10 changed files with 46 additions and 40 deletions

View file

@ -44,6 +44,7 @@ void renderPrepareMirror(int32_t dax, int32_t day, int32_t daz, fixed_t daang,
void renderCompleteMirror(void);
int32_t renderDrawRoomsQ16(int32_t daposx, int32_t daposy, int32_t daposz, fixed_t daang, fixed_t dahoriz, int dacursectnum, bool fromoutside);
int32_t renderDrawRoomsQ16(int32_t daposx, int32_t daposy, int32_t daposz, fixed_t daang, fixed_t dahoriz, sectortype* dacursect, bool fromoutside);
void renderDrawMasks(void);

View file

@ -225,7 +225,7 @@ static int32_t engineLoadTables(void)
///// sector lists of sprites /////
// insert sprite at the head of sector list, change .sectnum
// insert sprite at the head of sector list, change sectnum
static void do_insertsprite_at_headofsect(int16_t spritenum, int16_t sectnum)
{
int16_t const ohead = headspritesect[sectnum];
@ -344,7 +344,7 @@ int32_t deletesprite(int16_t spritenum)
do_deletespritesect(spritenum);
// (dummy) insert at tail of sector freelist, compat
// for code that checks .sectnum==MAXSECTOR
// for code that checks sectnum==MAXSECTOR
sprite[spritenum].sectnum = MAXSECTORS;
// insert at tail of status freelist
@ -769,34 +769,34 @@ int32_t spriteheightofsptr(uspriteptr_t spr, int32_t *height, int32_t alsotileyo
//
int32_t setsprite(int16_t spritenum, const vec3_t *newpos)
{
int tempsectnum = sprite[spritenum].sectnum;
auto tempsector = sprite[spritenum].sector();
if (newpos != &sprite[spritenum].pos)
sprite[spritenum].pos = *newpos;
updatesector(newpos->x,newpos->y,&tempsectnum);
updatesector(newpos->x,newpos->y,&tempsector);
if (tempsectnum < 0)
if (tempsector == nullptr)
return -1;
if (tempsectnum != sprite[spritenum].sectnum)
changespritesect(spritenum,tempsectnum);
if (tempsector != sprite[spritenum].sector())
changespritesect(spritenum, sectnum(tempsector));
return 0;
}
int32_t setspritez(int16_t spritenum, const vec3_t *newpos)
{
int tempsectnum = sprite[spritenum].sectnum;
auto tempsectnum = sprite[spritenum].sector();
if ((void const *)newpos != (void *)&sprite[spritenum])
sprite[spritenum].pos = *newpos;
updatesectorz(newpos->x,newpos->y,newpos->z,&tempsectnum);
if (tempsectnum < 0)
if (tempsectnum == nullptr)
return -1;
if (tempsectnum != sprite[spritenum].sectnum)
changespritesect(spritenum,tempsectnum);
if (tempsectnum != sprite[spritenum].sector())
changespritesect(spritenum, sectnum(tempsectnum));
return 0;
}

View file

@ -3306,6 +3306,11 @@ void renderCompleteMirror(void)
//
EXTERN_CVAR(Int, gl_fogmode)
int32_t renderDrawRoomsQ16(int32_t daposx, int32_t daposy, int32_t daposz, fixed_t daang, fixed_t dahoriz, sectortype* dacursect, bool fromoutside)
{
if (dacursect) return renderDrawRoomsQ16(daposx, daposy, daposz, daang, dahoriz, sectnum(dacursect), fromoutside);
}
int32_t renderDrawRoomsQ16(int32_t daposx, int32_t daposy, int32_t daposz,
fixed_t daang, fixed_t dahoriz, int dacursectnum, bool fromoutside)
{

View file

@ -302,7 +302,7 @@ void HWDrawInfo::DispatchSprites()
{
HWSprite hwsprite;
int num = tiletovox[tilenum];
if (hwsprite.ProcessVoxel(this, voxmodels[num], tspr, &sector[tspr->sectnum], voxrotate[num]))
if (hwsprite.ProcessVoxel(this, voxmodels[num], tspr, tspr->sector(), voxrotate[num]))
continue;
}
else if ((tspr->cstat & CSTAT_SPRITE_ALIGNMENT) == CSTAT_SPRITE_ALIGNMENT_SLAB && tspr->picnum < MAXVOXELS && voxmodels[tilenum])

View file

@ -233,7 +233,7 @@ static void fakeProcessInput(PLAYER *pPlayer, InputPacket *pInput)
predict.at24 = 0;
#endif
int nSector = predict.sectnum;
int nSector = predict.sector;
int florhit = predict.at75.florhit.type;
bool va = (predict.floordist < 16 && (florhit == kHitSector || florhit == 0));
@ -277,12 +277,12 @@ void fakePlayerProcess(PLAYER *pPlayer, InputPacket *pInput)
int dzt = (predict.z-top)/4;
int dw = pSprite->clipdist<<2;
int nSector = predict.sectnum;
int nSector = predict.sector;
if (!gNoClip)
{
pushmove(&predict.pos, &predict.sectnum, dw, dzt, dzb, CLIPMASK0);
if (predict.sectnum == -1)
predict.sectnum = nSector;
pushmove(&predict.pos, &predict.sector, dw, dzt, dzb, CLIPMASK0);
if (predict.sector == -1)
predict.sector = nSector;
}
fakeProcessInput(pPlayer, pInput);
@ -346,7 +346,7 @@ void fakePlayerProcess(PLAYER *pPlayer, InputPacket *pInput)
if (predict.at48 == 1)
{
predict.at72 = 1;
int nSector = predict.sectnum;
int nSector = predict.sector;
auto nLink = getLowerLink(nSector);
if (nLink && (nLink->s().type == kMarkerLowGoo || nLink->s().type == kMarkerLowWater))
{
@ -371,7 +371,7 @@ static void fakeMoveDude(spritetype *pSprite)
int bz = (bottom-predict.z)/4;
int tz = (predict.z-top)/4;
int wd = pSprite->clipdist*4;
int nSector = predict.sectnum;
int nSector = predict.sector;
assert(validSectorIndex(nSector));
if (predict.xvel || predict.yvel)
{
@ -380,7 +380,7 @@ static void fakeMoveDude(spritetype *pSprite)
predict.x += predict.xvel>>12;
predict.y += predict.yvel>>12;
if (!FindSector(predict.x, predict.y, &nSector))
nSector = predict.sectnum;
nSector = predict.sector;
}
else
{
@ -388,7 +388,7 @@ static void fakeMoveDude(spritetype *pSprite)
pSprite->cstat &= ~257;
ClipMove(&predict.pos, &nSector, predict.xvel >> 12, predict.yvel >> 12, wd, tz, bz, CLIPMASK0, predict.at75.hit);
if (nSector == -1)
nSector = predict.sectnum;
nSector = predict.sector;
if (sector[nSector].type >= kSectorPath && sector[nSector].type <= kSectorRotate)
{
@ -421,16 +421,16 @@ static void fakeMoveDude(spritetype *pSprite)
}
}
}
if (predict.sectnum != nSector)
if (predict.sector != nSector)
{
assert(validSectorIndex(nSector));
predict.sectnum = nSector;
predict.sector = nSector;
}
bool bUnderwater = 0;
bool bDepth = 0;
if (sector[sectnum].hasX())
if (sector[sector].hasX())
{
XSECTOR *pXSector = &sector[sectnum].xs();
XSECTOR *pXSector = &sector[sector].xs();
if (pXSector->Underwater)
bUnderwater = 1;
if (pXSector->Depth)
@ -454,7 +454,7 @@ static void fakeMoveDude(spritetype *pSprite)
pTempSprite->x = predict.x;
pTempSprite->y = predict.y;
pTempSprite->z = predict.z;
pTempSprite-> sectnum = predict. sectnum;
pTempSprite-> sector = predict. sector;
int ceilZ, floorZ;
Collision ceilColl, floorColl;
GetZRange(pTempSprite, &ceilZ, &ceilColl, &floorZ, &floorColl, wd, CLIPMASK0);
@ -575,8 +575,8 @@ static void fakeActAirDrag(spritetype *, int num)
#if 0
int xvec = 0;
int yvec = 0;
assert(validSectorIndex(predict.sectnum));
sectortype *pSector = &sector[predict.sectnum];
assert(validSectorIndex(predict.sector));
sectortype *pSector = &sector[predict.sector];
if (pSector->hasX())
{
XSECTOR *pXSector = &pSector->xs();
@ -601,8 +601,8 @@ void fakeActProcessSprites(void)
spritetype *pSprite = gMe->pSprite;
if (pSprite->statnum == kStatDude)
{
int nSector = predict.sectnum;
auto pSector = &sector[predict.sectnum];
int nSector = predict.sector;
auto pSector = &sector[predict.sector];
auto pXSector = pSector->hasX()? &pSector->xs() : nullptr;
if (pXSector)
{

View file

@ -91,7 +91,7 @@ void SE40_Draw(int tag, spritetype *spr, int x, int y, int z, binangle a, fixedh
offx = x - floor1->x;
offy = y - floor1->y;
renderDrawRoomsQ16(floor2->x + offx, floor2->y + offy, z, a.asq16(), h.asq16(), floor2->sectnum, false);
renderDrawRoomsQ16(floor2->x + offx, floor2->y + offy, z, a.asq16(), h.asq16(), floor2->sector(), false);
fi.animatesprites(pm_tsprite, pm_spritesortcnt, offx + floor2->x, offy + floor2->y, a.asbuild(), smoothratio);
renderDrawMasks();

View file

@ -64,7 +64,7 @@ BEGIN_DUKE_NS
//
//---------------------------------------------------------------------------
void renderView(spritetype* playersprite, int sectnum, int x, int y, int z, binangle a, fixedhoriz h, binangle rotscrnang, int smoothratio)
void renderView(spritetype* playersprite, sectortype* sect, int x, int y, int z, binangle a, fixedhoriz h, binangle rotscrnang, int smoothratio)
{
if (!testnewrenderer)
{
@ -73,13 +73,13 @@ void renderView(spritetype* playersprite, int sectnum, int x, int y, int z, bina
se40code(x, y, z, a, h, smoothratio);
renderMirror(x, y, z, a, h, smoothratio);
renderDrawRoomsQ16(x, y, z, a.asq16(), h.asq16(), sectnum, false);
renderDrawRoomsQ16(x, y, z, a.asq16(), h.asq16(), sect, false);
fi.animatesprites(pm_tsprite, pm_spritesortcnt, x, y, a.asbuild(), smoothratio);
renderDrawMasks();
}
else
{
render_drawrooms(playersprite, { x, y, z }, sectnum, a, h, rotscrnang, smoothratio);
render_drawrooms(playersprite, { x, y, z }, sectnum(sect), a, h, rotscrnang, smoothratio);
}
}
@ -117,7 +117,7 @@ void GameInterface::UpdateCameras(double smoothratio)
if (!testnewrenderer)
{
// Note: no ROR or camera here - Polymost has no means to detect these things before rendering the scene itself.
renderDrawRoomsQ16(camera->x, camera->y, camera->z, ang.asq16(), IntToFixed(camera->shade), camera->sectnum, false); // why 'shade'...?
renderDrawRoomsQ16(camera->x, camera->y, camera->z, ang.asq16(), IntToFixed(camera->shade), camera->sector(), false); // why 'shade'...?
fi.animatesprites(pm_tsprite, pm_spritesortcnt, camera->x, camera->y, ang.asbuild(), (int)smoothratio);
renderDrawMasks();
}
@ -292,7 +292,7 @@ void displayrooms(int snum, double smoothratio)
cang = buildang(interpolatedangle(ud.cameraactor->tempang, s->ang, smoothratio));
auto bh = buildhoriz(s->yvel);
renderView(s, s->sectnum, s->x, s->y, s->z - (4 << 8), cang, bh, buildang(0), (int)smoothratio);
renderView(s, s->sector(), s->x, s->y, s->z - (4 << 8), cang, bh, buildang(0), (int)smoothratio);
}
else
{
@ -410,7 +410,7 @@ void displayrooms(int snum, double smoothratio)
}
else
{
renderView(viewer, sectnum(sect), cposx, cposy, cposz, cang, choriz, rotscrnang, (int)smoothratio);
renderView(viewer, sect, cposx, cposy, cposz, cang, choriz, rotscrnang, (int)smoothratio);
}
}
//GLInterface.SetMapFog(false);

View file

@ -411,7 +411,7 @@ MOVEEND:
nVal = coll.type || coll.exbits? 1:0;
// pSprite.sectnum may have changed since we set nSectFlag ?
// pSprite's sector may have changed since we set nSectFlag ?
int nFlagVal = nSectFlag ^ pSprite->sector()->Flag;
if (nFlagVal & kSectUnderwater)
{

View file

@ -2276,7 +2276,7 @@ sectdone:
// loc_1BC57:
// CHECKME - are we finished with 'nSector' variable at this point? if so, maybe set it to pPlayerSprite->sectnum so we can make this code a bit neater. Don't assume pPlayerSprite->sectnum == nSector here!!
// CHECKME - are we finished with 'nSector' variable at this point? if so, maybe set it to pPlayerSprite->sector() so we can make this code a bit neater. Don't assume pPlayerSprite->sectnum == nSector here!!
if (nStandHeight > (pPlayerSprite->sector()->floorz - pPlayerSprite->sector()->ceilingz)) {
var_48 = 1;
}

View file

@ -285,7 +285,7 @@ void JS_DrawMirrors(PLAYERp pp, int tx, int ty, int tz, fixed_t tpq16ang, fixed
if (mirror[cnt].campic != -1)
tileDelete(mirror[cnt].campic);
renderDrawRoomsQ16(dx, dy, dz, tpq16ang, tpq16horiz, sp->sectnum, true);
renderDrawRoomsQ16(dx, dy, dz, tpq16ang, tpq16horiz, sp->sector(), true);
analyzesprites(pm_tsprite, pm_spritesortcnt, dx, dy, dz, false);
renderDrawMasks();
}