From c4ef006930e54af4364e55e040944264a10f7e1a Mon Sep 17 00:00:00 2001 From: juliuss007 <157698750+juliuss007@users.noreply.github.com> Date: Wed, 27 May 2026 08:03:14 +0200 Subject: [PATCH] Fix fog gating for flying strings --- src/Misc/FlyingStrings.cpp | 27 +++++++++++++++------------ src/Misc/FlyingStrings.h | 2 +- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/Misc/FlyingStrings.cpp b/src/Misc/FlyingStrings.cpp index dcca47123c..725c3d6f48 100644 --- a/src/Misc/FlyingStrings.cpp +++ b/src/Misc/FlyingStrings.cpp @@ -8,7 +8,7 @@ std::vector FlyingStrings::Data; -bool FlyingStrings::DrawAllowed(CoordStruct& nCoords) +bool FlyingStrings::DrawAllowed(const CoordStruct& nCoords) { if (auto const pCell = MapClass::Instance.TryGetCellAt(nCoords)) return !(pCell->IsFogged() || pCell->IsShrouded()); @@ -30,7 +30,7 @@ void FlyingStrings::Add(const wchar_t* text, const CoordStruct& coords, ColorStr void FlyingStrings::AddMoneyString(int amount, ObjectClass* pSource, HouseClass* pOwner, AffectedHouse displayToHouses, const CoordStruct& coords, Point2D pixelOffset) { - if (amount == 0 || MapClass::Instance.IsLocationShrouded(coords)) + if (amount == 0 || !FlyingStrings::DrawAllowed(coords)) return; if (displayToHouses != AffectedHouse::All && !EnumFunctions::CanTargetHouse(displayToHouses, pOwner, HouseClass::CurrentPlayer)) @@ -64,17 +64,20 @@ void FlyingStrings::UpdateAll() point += dataItem.PixelOffset; - RectangleStruct bound = DSurface::Temp->GetRect(); - bound.Height -= 32; - - if (Unsorted::CurrentFrame > dataItem.CreationFrame + Duration - 70) - { - point.Y -= (Unsorted::CurrentFrame - dataItem.CreationFrame); - DSurface::Temp->DrawText(dataItem.Text, &bound, &point, dataItem.Color, 0, TextPrintType::NoShadow); - } - else + if (FlyingStrings::DrawAllowed(dataItem.Location)) { - DSurface::Temp->DrawText(dataItem.Text, &bound, &point, dataItem.Color, 0, TextPrintType::NoShadow); + RectangleStruct bound = DSurface::Temp->GetRect(); + bound.Height -= 32; + + if (Unsorted::CurrentFrame > dataItem.CreationFrame + Duration - 70) + { + point.Y -= (Unsorted::CurrentFrame - dataItem.CreationFrame); + DSurface::Temp->DrawText(dataItem.Text, &bound, &point, dataItem.Color, 0, TextPrintType::NoShadow); + } + else + { + DSurface::Temp->DrawText(dataItem.Text, &bound, &point, dataItem.Color, 0, TextPrintType::NoShadow); + } } if (Unsorted::CurrentFrame > dataItem.CreationFrame + Duration || Unsorted::CurrentFrame < dataItem.CreationFrame) diff --git a/src/Misc/FlyingStrings.h b/src/Misc/FlyingStrings.h index 88956f9a24..2def4f638a 100644 --- a/src/Misc/FlyingStrings.h +++ b/src/Misc/FlyingStrings.h @@ -26,7 +26,7 @@ class FlyingStrings static const int Duration = 75; static std::vector Data; - static bool DrawAllowed(CoordStruct& nCoords); + static bool DrawAllowed(const CoordStruct& nCoords); public: static void Add(const wchar_t* text, const CoordStruct& coords, ColorStruct color, Point2D pixelOffset = Point2D::Empty);