- SectorMidPoint

This commit is contained in:
Christoph Oelckers 2021-11-24 22:34:39 +01:00
parent da8a5f282d
commit 3b16db7a0f
4 changed files with 9 additions and 10 deletions

View file

@ -173,8 +173,8 @@ void CopySectorMatch(int match)
// move sprites from source to dest - use center offset
// get center of src and dest sect
SectorMidPoint(src_sp->sectnum, &sx, &sy, &trash);
SectorMidPoint(dest_sp->sectnum, &dx, &dy, &trash);
SectorMidPoint(src_sp->sector(), &sx, &sy, &trash);
SectorMidPoint(dest_sp->sector(), &dx, &dy, &trash);
// get offset
src_xoff = sx - sp->x;

View file

@ -1805,7 +1805,7 @@ ANIMATOR NullAnimator;
int Distance(int x1, int y1, int x2, int y2);
int NewStateGroup(DSWActor* actor, STATEp SpriteGroup[]);
void SectorMidPoint(short sectnum, int *xmid, int *ymid, int *zmid);
void SectorMidPoint(sectortype* sectnum, int *xmid, int *ymid, int *zmid);
USERp SpawnUser(DSWActor* actor, short id, STATEp state);
short ActorFindTrack(DSWActor* actor, int8_t player_dir, int track_type, int *track_point_num, int *track_dir);

View file

@ -591,12 +591,11 @@ void SectorSetup(void)
}
}
void SectorMidPoint(short sectnum, int *xmid, int *ymid, int *zmid)
void SectorMidPoint(sectortype* sectp, int *xmid, int *ymid, int *zmid)
{
auto sectp = &sector[sectnum];
int xsum = 0, ysum = 0;
for(auto& wal : wallsofsector(sectnum))
for(auto& wal : wallsofsector(sectp))
{
xsum += wal.x;
ysum += wal.y;
@ -685,8 +684,8 @@ int SectorDistanceByMid(short sect1, int sect2)
{
int sx1, sy1, sx2, sy2, trash;
SectorMidPoint(sect1, &sx1, &sy1, &trash);
SectorMidPoint(sect2, &sx2, &sy2, &trash);
SectorMidPoint(&sector[sect1], &sx1, &sy1, &trash);
SectorMidPoint(&sector[sect2], &sx2, &sy2, &trash);
// return the distance between the two sectors.
return Distance(sx1, sy1, sx2, sy2);
@ -880,7 +879,7 @@ void SectorExp(DSWActor* actor, short sectnum, short orig_ang, int zh)
int x,y,z;
RESET(sp->cstat, CSTAT_SPRITE_ALIGNMENT_WALL|CSTAT_SPRITE_ALIGNMENT_FLOOR);
SectorMidPoint(sectnum, &x, &y, &z);
SectorMidPoint(&sector[sectnum], &x, &y, &z);
sp->ang = orig_ang;
sp->x = x;
sp->y = y;

View file

@ -1091,7 +1091,7 @@ void SetupSectorObject(short sectnum, short tag)
case TAG_OBJECT_CENTER - 500:
sop->mid_sector = sectnum;
SectorMidPoint(sectnum, &sop->xmid, &sop->ymid, &sop->zmid);
SectorMidPoint(&sector[sectnum], &sop->xmid, &sop->ymid, &sop->zmid);
//sop->zmid = sector[sectnum].floorz;
//sop->zmid = DIV2(sector[sectnum].floorz + sector[sectnum].ceilingz);