diff --git a/src/cdogs/algorithms.c b/src/cdogs/algorithms.c index 6e832f75d..6f19ce1ef 100644 --- a/src/cdogs/algorithms.c +++ b/src/cdogs/algorithms.c @@ -276,15 +276,15 @@ void XiaolinWuLineDraw(Vec2i from, Vec2i to, AlgoLineDrawData *data) XiaolinWuLine(from, to, &bData); } -bool FloodFill(Vec2i v, FloodFillData *data) +bool CFloodFill(Vec2i v, FloodFillData *data) { if (data->IsSame(data->data, v)) { data->Fill(data->data, v); - FloodFill(Vec2iNew(v.x - 1, v.y), data); - FloodFill(Vec2iNew(v.x + 1, v.y), data); - FloodFill(Vec2iNew(v.x, v.y - 1), data); - FloodFill(Vec2iNew(v.x, v.y + 1), data); + CFloodFill(Vec2iNew(v.x - 1, v.y), data); + CFloodFill(Vec2iNew(v.x + 1, v.y), data); + CFloodFill(Vec2iNew(v.x, v.y - 1), data); + CFloodFill(Vec2iNew(v.x, v.y + 1), data); return true; } return false; diff --git a/src/cdogs/algorithms.h b/src/cdogs/algorithms.h index c4f61eab5..4f2c8dd7f 100644 --- a/src/cdogs/algorithms.h +++ b/src/cdogs/algorithms.h @@ -55,6 +55,6 @@ typedef struct bool (*IsSame)(void *, Vec2i); void *data; } FloodFillData; -bool FloodFill(Vec2i v, FloodFillData *data); +bool CFloodFill(Vec2i v, FloodFillData *data); #endif diff --git a/src/cdogs/mission_convert.c b/src/cdogs/mission_convert.c index b0529f116..abf641bf2 100644 --- a/src/cdogs/mission_convert.c +++ b/src/cdogs/mission_convert.c @@ -547,7 +547,7 @@ bool MissionStaticTrySetKey(Mission *m, int k, Vec2i pos) mData.m = m; mData.mask = mask; data.data = &mData; - return FloodFill(pos, &data); + return CFloodFill(pos, &data); } static void MissionFillTile(void *data, Vec2i v) { diff --git a/src/cdogs/sounds.c b/src/cdogs/sounds.c index 8676f3f1b..494678edf 100644 --- a/src/cdogs/sounds.c +++ b/src/cdogs/sounds.c @@ -58,7 +58,9 @@ #include +#include "algorithms.h" #include "files.h" +#include "map.h" #include "music.h" #include "vector.h" @@ -318,6 +320,11 @@ void SoundPlayAt(SoundDevice *device, Mix_Chunk *data, const Vec2i pos) SoundPlayAtPlusDistance(device, data, pos, 0); } +#define OUT_OF_SIGHT_DISTANCE_PLUS 200 +static bool IsPosNoSee(void *data, Vec2i pos) +{ + return MapGetTile(data, Vec2iToTile(pos))->flags & MAPTILE_NO_SEE; +} void SoundPlayAtPlusDistance( SoundDevice *device, Mix_Chunk *data, const Vec2i pos, const int plusDistance) @@ -353,6 +360,13 @@ void SoundPlayAtPlusDistance( origin = CalcClosestPointOnLineSegmentToPoint( closestLeftEar, closestRightEar, pos); CalcChebyshevDistanceAndBearing(origin, pos, &distance, &bearing); + HasClearLineData lineData; + lineData.IsBlocked = IsPosNoSee; + lineData.data = &gMap; + if (!HasClearLineXiaolinWu(pos, origin, &lineData)) + { + distance += OUT_OF_SIGHT_DISTANCE_PLUS; + } SoundPlayAtPosition(&gSoundDevice, data, distance + plusDistance, bearing); } diff --git a/src/cdogsed/editor_brush.c b/src/cdogsed/editor_brush.c index a8a7a6870..2cb2db119 100644 --- a/src/cdogsed/editor_brush.c +++ b/src/cdogsed/editor_brush.c @@ -359,7 +359,7 @@ EditorResult EditorBrushStartPainting(EditorBrush *b, Mission *m, int isMain) pData.fromType = MissionGetTile(m, b->Pos) & MAP_MASKACCESS; pData.toType = b->PaintType; data.data = &pData; - if (FloodFill(b->Pos, &data)) + if (CFloodFill(b->Pos, &data)) { return EDITOR_RESULT_CHANGED; }