- ->sectnum in ai.cpp and draw.cpp.

This commit is contained in:
Christoph Oelckers 2021-11-25 18:52:10 +01:00
parent cf6e75ad54
commit 98c3d57b73
2 changed files with 22 additions and 33 deletions

View file

@ -233,9 +233,6 @@ bool CanSeePlayer(DSWActor* actor)
// if actor can still see the player
int look_height = SPRITEp_TOS(sp);
//if (FAF_Sector(sp->sectnum))
// return(true);
if (u->targetActor && FAFcansee(sp->x, sp->y, look_height, sp->sector(), u->targetActor->s().x, u->targetActor->s().y, ActorUpper(u->targetActor), u->targetActor->s().sector()))
return true;
else
@ -469,9 +466,6 @@ int DoActorOperate(DSWActor* actor)
if ((u->WaitTics -= ACTORMOVETICS) > 0)
return false;
//DSPRINTF(ds,"sp->x = %ld, sp->y = %ld, sp->sector = %d, tp->x = %ld, tp->y = %ld, tp->ang = %d\n",sp->x,sp->y,sp->sectnum,tpoint->x,tpoint->y,tpoint->ang);
//MONO_PRINT(ds);
z[0] = sp->z - SPRITEp_SIZE_Z(sp) + Z(5);
z[1] = sp->z - DIV2(SPRITEp_SIZE_Z(sp));
@ -1469,7 +1463,7 @@ int DoActorMoveJump(DSWActor* actor)
}
Collision move_scan(DSWActor* actor, int ang, int dist, int *stopx, int *stopy, int *stopz, int *stopsect)
Collision move_scan(DSWActor* actor, int ang, int dist, int *stopx, int *stopy, int *stopz)
{
USERp u = actor->u();
SPRITEp sp = &actor->s();
@ -1477,11 +1471,11 @@ Collision move_scan(DSWActor* actor, int ang, int dist, int *stopx, int *stopy,
int nx,ny;
uint32_t cliptype = CLIPMASK_ACTOR;
int sang,ss;
int sang;
int x, y, z, loz, hiz;
DSWActor* highActor;
DSWActor* lowActor;
SECTORp lo_sectp, hi_sectp;
sectortype* lo_sectp,* hi_sectp, *ssp;
// moves out a bit but keeps the sprites original postion/sector.
@ -1497,7 +1491,7 @@ Collision move_scan(DSWActor* actor, int ang, int dist, int *stopx, int *stopy,
highActor = u->highActor;
lo_sectp = u->lo_sectp;
hi_sectp = u->hi_sectp;
ss = sp->sectnum;
ssp = sp->sector();
// do the move
sp->ang = ang;
@ -1513,7 +1507,6 @@ Collision move_scan(DSWActor* actor, int ang, int dist, int *stopx, int *stopy,
*stopx = sp->x;
*stopy = sp->y;
*stopz = sp->z;
*stopsect = sp->sectnum;
// reset position information
sp->x = x;
@ -1526,7 +1519,7 @@ Collision move_scan(DSWActor* actor, int ang, int dist, int *stopx, int *stopy,
u->highActor = highActor;
u->lo_sectp = lo_sectp;
u->hi_sectp = hi_sectp;
ChangeActorSect(actor, ss);
ChangeActorSect(actor, ssp);
return ret;
}
@ -1566,7 +1559,6 @@ int FindNewAngle(DSWActor* actor, int dir, int DistToMove)
int set;
int dist, stopx, stopy, stopz;
int stopsect;
// start out with mininum distance that will be accepted as a move
int save_dist = 500;
@ -1619,7 +1611,7 @@ int FindNewAngle(DSWActor* actor, int dir, int DistToMove)
#endif
// check to see how far we can move
auto ret = move_scan(actor, new_ang, DistToMove, &stopx, &stopy, &stopz, &stopsect);
auto ret = move_scan(actor, new_ang, DistToMove, &stopx, &stopy, &stopz);
if (ret.type == kHitNone)
{

View file

@ -268,24 +268,22 @@ DoShadows(spritetype* tsprite, int& spritesortcnt, tspriteptr_t tsp, int viewz,
int loz;
int xrepeat;
int yrepeat;
int sectnum;
sectnum = tsp->sectnum;
auto sect = tsp->sector();
// make sure its the correct sector
// DoShadowFindGroundPoint calls FAFgetzrangepoint and this is sensitive
//updatesectorz(tsp->x, tsp->y, tsp->z, &sectnum);
updatesector(tsp->x, tsp->y, &sectnum);
updatesector(tsp->x, tsp->y, &sect);
if (sectnum < 0)
if (sect == nullptr)
{
return;
}
tsp->sectnum = sectnum;
tsp->setsector(sect);
*tSpr = *tsp;
// shadow is ALWAYS draw last - status is priority
tSpr->statnum = MAXSTATUS;
tSpr->sectnum = sectnum;
tSpr->setsector(sect);
if ((tsp->yrepeat >> 2) > 4)
{
@ -452,7 +450,6 @@ void WarpCopySprite(spritetype* tsprite, int& spritesortcnt)
int spnum;
int xoff,yoff,zoff;
int match;
int sect1, sect2;
// look for the first one
SWStatIterator it(STAT_WARP_COPY_SPRITE1);
@ -470,8 +467,8 @@ void WarpCopySprite(spritetype* tsprite, int& spritesortcnt)
if (sp->lotag == match)
{
sp2 = sp;
sect1 = sp1->sectnum;
sect2 = sp2->sectnum;
auto sect1 = sp1->sector();
auto sect2 = sp2->sector();
SWSectIterator it2(sect1);
while (auto itActor2 = it.Next())
@ -496,8 +493,8 @@ void WarpCopySprite(spritetype* tsprite, int& spritesortcnt)
newTSpr->setsector(sp2->sector());
}
it.Reset(sect2);
while (auto itActor2 = it.Next())
it2.Reset(sect2);
while (auto itActor2 = it2.Next())
{
auto spit = &itActor2->s();
if (spit == sp2)
@ -516,7 +513,7 @@ void WarpCopySprite(spritetype* tsprite, int& spritesortcnt)
newTSpr->x = sp1->x - xoff;
newTSpr->y = sp1->y - yoff;
newTSpr->z = sp1->z - zoff;
newTSpr->sectnum = sp1->sectnum;
newTSpr->setsector(sp1->sector());
}
}
}
@ -1222,7 +1219,7 @@ PostDraw(void)
}
}
DSWActor* CopySprite(spritetype const * tsp, int newsector)
DSWActor* CopySprite(spritetype const * tsp, sectortype* newsector)
{
SPRITEp sp;
@ -1252,18 +1249,18 @@ DSWActor* CopySprite(spritetype const * tsp, int newsector)
DSWActor* ConnectCopySprite(spritetype const * tsp)
{
int newsector;
sectortype* newsector;
int testz;
if (FAF_ConnectCeiling(tsp->sector()))
{
newsector = tsp->sectnum;
newsector = tsp->sector();
testz = SPRITEp_TOS(tsp) - Z(10);
if (testz < tsp->sector()->ceilingz)
updatesectorz(tsp->x, tsp->y, testz, &newsector);
if (newsector >= 0 && newsector != tsp->sectnum)
if (newsector != nullptr && newsector != tsp->sector())
{
return CopySprite(tsp, newsector);
}
@ -1271,13 +1268,13 @@ DSWActor* ConnectCopySprite(spritetype const * tsp)
if (FAF_ConnectFloor(tsp->sector()))
{
newsector = tsp->sectnum;
newsector = tsp->sector();
testz = SPRITEp_BOS(tsp) + Z(10);
if (testz > tsp->sector()->floorz)
updatesectorz(tsp->x, tsp->y, testz, &newsector);
if (newsector >= 0 && newsector != tsp->sectnum)
if (newsector != nullptr && newsector != tsp->sector())
{
return CopySprite(tsp, newsector);
}