diff --git a/source/games/sw/src/copysect.cpp b/source/games/sw/src/copysect.cpp index 564edabde..9d021659e 100644 --- a/source/games/sw/src/copysect.cpp +++ b/source/games/sw/src/copysect.cpp @@ -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; diff --git a/source/games/sw/src/game.h b/source/games/sw/src/game.h index 0d55bd815..d121d6daa 100644 --- a/source/games/sw/src/game.h +++ b/source/games/sw/src/game.h @@ -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); diff --git a/source/games/sw/src/sector.cpp b/source/games/sw/src/sector.cpp index 576a6d1f7..21d626b9d 100644 --- a/source/games/sw/src/sector.cpp +++ b/source/games/sw/src/sector.cpp @@ -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 = §or[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(§or[sect1], &sx1, &sy1, &trash); + SectorMidPoint(§or[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(§or[sectnum], &x, &y, &z); sp->ang = orig_ang; sp->x = x; sp->y = y; diff --git a/source/games/sw/src/track.cpp b/source/games/sw/src/track.cpp index 317f9fd56..d196be067 100644 --- a/source/games/sw/src/track.cpp +++ b/source/games/sw/src/track.cpp @@ -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(§or[sectnum], &sop->xmid, &sop->ymid, &sop->zmid); //sop->zmid = sector[sectnum].floorz; //sop->zmid = DIV2(sector[sectnum].floorz + sector[sectnum].ceilingz);