diff --git a/source/games/sw/src/game.h b/source/games/sw/src/game.h index 25d2a54ec..42c4e7033 100644 --- a/source/games/sw/src/game.h +++ b/source/games/sw/src/game.h @@ -1597,6 +1597,7 @@ double Distance(const DVector2& pos1, const DVector2& pos2) int NewStateGroup(DSWActor* actor, STATE* SpriteGroup[]); void SectorMidPoint(sectortype* sect, int *xmid, int *ymid, int *zmid); +DVector3 SectorMidPoint(sectortype* sectp); void SpawnUser(DSWActor* actor, short id, STATE* state); short ActorFindTrack(DSWActor* actor, int8_t player_dir, int track_type, int *track_point_num, int *track_dir); @@ -1640,6 +1641,11 @@ inline void PlaySound(int num, const vec3_t &pos, int flags, int channel = 8, EC { _PlaySound(num, nullptr, nullptr, &pos, flags, channel, sndflags); } +inline void PlaySound(int num, const DVector3& pos, int flags, int channel = 8, EChanFlags sndflags = CHANF_NONE) +{ + vec3_t ppos = { int(pos.X * worldtoint), int(pos.Y * worldtoint), int(pos.Z * zworldtoint) }; + _PlaySound(num, nullptr, nullptr, &ppos, flags, channel, sndflags); +} int _PlayerSound(int num, PLAYER* pp); inline int PlayerSound(int num, int flags, PLAYER* pp) { return _PlayerSound(num, pp); } diff --git a/source/games/sw/src/sector.cpp b/source/games/sw/src/sector.cpp index 34873c073..ebe50494d 100644 --- a/source/games/sw/src/sector.cpp +++ b/source/games/sw/src/sector.cpp @@ -604,6 +604,18 @@ void SectorMidPoint(sectortype* sectp, int *xmid, int *ymid, int *zmid) *zmid = (sectp->int_floorz() + sectp->int_ceilingz()) >> 1; } +DVector3 SectorMidPoint(sectortype* sectp) +{ + DVector3 sum(0,0,0); + + for (auto& wal : wallsofsector(sectp)) + { + sum += wal.pos; + } + sum /= sectp->wallnum; + sum.Z = (sectp->floorz + sectp->ceilingz) * 0.5; + return sum; +} void DoSpringBoard(PLAYER* pp) {