Skip to content
Open
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
fa453a0
Radius overlay & tooltips
morganchristiansson Jun 14, 2026
3175b05
Fix clipping, mine radius
morganchristiansson Jun 14, 2026
d489b4c
Cleaner DrawRadiusOutline
morganchristiansson Jun 14, 2026
5728636
FoW and cleaner DrawRadiusOutline
morganchristiansson Jun 14, 2026
d6c53b8
Tidy
morganchristiansson Jun 15, 2026
11df35a
Improve radius constants
morganchristiansson Jun 15, 2026
0572598
Replace boost::optional and boost::none
morganchristiansson Jun 15, 2026
cfebdce
Simpify UI/mouse changes
morganchristiansson Jun 15, 2026
795a110
Fix map wrap clipping again
morganchristiansson Jun 15, 2026
bdfd9b1
Fix "Invalid job id" from GetWorkRadius()
morganchristiansson Jun 16, 2026
7957d83
Toggle via addon
morganchristiansson Jun 16, 2026
1f70192
Ensure hover fires after leave
morganchristiansson Jun 16, 2026
4f4fa6e
Fix formatting
morganchristiansson Jun 16, 2026
7ec4ce5
Better radius ouline drawing
morganchristiansson Jun 18, 2026
ab91acd
Enable addon by default
morganchristiansson Jun 18, 2026
16840a8
Ignore game buildings when mouse over window
morganchristiansson Jun 20, 2026
0ed0c34
Revert isEnabled change: restore original semantics
morganchristiansson Jun 30, 2026
e4df373
Revert "Revert isEnabled change: restore original semantics"
morganchristiansson Jun 30, 2026
675e474
Move OnHover() callsite to Msg_MouseMove
morganchristiansson Jun 30, 2026
0f408f0
UpdateRadiusPreviewForMousePos
morganchristiansson Jun 30, 2026
caef896
SnapToNearestCopy
morganchristiansson Jun 30, 2026
ae81945
DrawRadiusOutline
morganchristiansson Jun 30, 2026
93246c4
GetBuildingRadius comment wording
morganchristiansson Jun 30, 2026
83752d2
clang-format
morganchristiansson Jun 30, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions libs/s25main/FOWObjects.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class fowBuilding : public FOWObject
void Serialize(SerializedGameData& sgd) const override;
void Draw(DrawPoint drawPt) const override;
FoW_Type GetType() const override { return FoW_Type::Building; }
BuildingType GetBuildingType() const { return type; }
};

/// Baustelle
Expand Down
5 changes: 3 additions & 2 deletions libs/s25main/GlobalGameSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ void GlobalGameSettings::registerAllAddons()
AddonForesterFarmFieldAvoidance,
AddonForesterReachRadius,
AddonWoodcutterReachRadius,
AddonStonemasonReachRadius
AddonStonemasonReachRadius,
AddonBuildingRadius
>;
// clang-format on
using namespace boost::mp11;
Expand Down Expand Up @@ -155,7 +156,7 @@ const GlobalGameSettings::AddonWithState* GlobalGameSettings::getAddon(AddonId i
bool GlobalGameSettings::isEnabled(AddonId id) const
{
const auto* addon = getAddon(id);
return addon && addon->status != addon->addon->getDefaultStatus();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't seem correct. Please revert

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is to allow default enabled addons.
Ok I find it very useful to have it default enabled for testing. Can we revert this last thing before merge.

return addon && addon->status != 0;
}

unsigned GlobalGameSettings::getSelection(AddonId id) const
Expand Down
4 changes: 2 additions & 2 deletions libs/s25main/addons/AddonBool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
#include "Window.h"
#include "controls/ctrlCheck.h"

AddonBool::AddonBool(const AddonId id, AddonGroup groups, const std::string& name, const std::string& description)
: Addon(id, groups, name, description, 0)
AddonBool::AddonBool(const AddonId id, AddonGroup groups, const std::string& name, const std::string& description, unsigned defaultStatus)
: Addon(id, groups, name, description, defaultStatus)
{}

std::unique_ptr<AddonGui> AddonBool::createGui(Window& window, bool readonly) const
Expand Down
2 changes: 1 addition & 1 deletion libs/s25main/addons/AddonBool.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class AddonBool : public Addon
};

public:
AddonBool(AddonId id, AddonGroup groups, const std::string& name, const std::string& description);
AddonBool(AddonId id, AddonGroup groups, const std::string& name, const std::string& description, unsigned defaultStatus = 0);

unsigned getNumOptions() const override;

Expand Down
22 changes: 22 additions & 0 deletions libs/s25main/addons/AddonBuildingRadius.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright (C) 2005 - 2026 Settlers Freaks (sf-team at siedler25.org)
//
// SPDX-License-Identifier: GPL-2.0-or-later

#pragma once

#include "AddonBool.h"
#include "mygettext/mygettext.h"

/**
* Show building radius information in tooltips and as map overlay
*/
class AddonBuildingRadius : public AddonBool
{
public:
AddonBuildingRadius()
: AddonBool(AddonId::BUILDING_RADIUS, AddonGroup::GamePlay, _("Show building radius"),
_("Shows the working radius of buildings in the build menu tooltip and as an overlay on the map "
"when hovering over a building icon or selecting a building."),
1) // Enabled by default
Comment on lines +19 to +20

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"when hovering over a building icon or selecting a building."),
1) // Enabled by default
"when hovering over a building icon or selecting a building."), 0)

The convention is that the default is S2-like behavior, so you can "disable" all addons and get vanilla S2

@morganchristiansson morganchristiansson Jun 30, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah can revert this. Making it default enabled allowed me to continue using my save game for testing tho so it's been nice. Also playing campaign with it enabled is lovely.

I'm addicted I can't play without it.

Let's revert to default disable last thing before merge ok?

{}
};
2 changes: 2 additions & 0 deletions libs/s25main/addons/Addons.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,5 @@
#include "addons/AddonForesterReachRadius.h"
#include "addons/AddonStonemasonReachRadius.h"
#include "addons/AddonWoodcutterReachRadius.h"

#include "addons/AddonBuildingRadius.h"
5 changes: 4 additions & 1 deletion libs/s25main/addons/const_addons.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
// 010 aztimh
// 011 DevOpsOfChaos
// 012 MichalLabuda
// 013 Morgan

// Do not forget to add your Addon to GlobalGameSettings::registerAllAddons @ GlobalGameSettings.cpp!
// Never use a number twice!
Expand Down Expand Up @@ -82,7 +83,9 @@ ENUM_WITH_STRING(AddonId, LIMIT_CATAPULTS = 0x00000000, INEXHAUSTIBLE_MINES = 0x
FORESTER_FARM_FIELD_AVOIDANCE = 0x01100000,

FORESTER_REACH_RADIUS = 0x01200000, WOODCUTTER_REACH_RADIUS = 0x01200001,
STONEMASON_REACH_RADIUS = 0x01200002)
STONEMASON_REACH_RADIUS = 0x01200002,

BUILDING_RADIUS = 0x01300000)
//-V:AddonId:801

enum class AddonGroup : unsigned
Expand Down
2 changes: 1 addition & 1 deletion libs/s25main/figures/nofCatapultMan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ void nofCatapultMan::HandleDerivedEvent(const unsigned /*id*/)
unsigned distance = world->CalcDistance(pos, building->GetPos());

// Entfernung nicht zu hoch?
if(distance < 14)
if(distance <= CATAPULT_MAX_TARGET_RANGE)
{
// Mit in die Liste aufnehmen
possibleTargets.push_back(PossibleTarget(building->GetPos(), distance));
Expand Down
3 changes: 3 additions & 0 deletions libs/s25main/figures/nofCatapultMan.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
class SerializedGameData;
class nobUsual;

/// Maximum distance to a target the catapult can attack (distance < 14 -> max 13)
constexpr unsigned CATAPULT_MAX_TARGET_RANGE = 13;

/// Arbeiter im Katapult
class nofCatapultMan : public nofBuildingWorker
{
Expand Down
6 changes: 2 additions & 4 deletions libs/s25main/figures/nofHunter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,16 +132,14 @@ void nofHunter::HandleDerivedEvent(unsigned /*id*/)
void nofHunter::TryStartHunting()
{
// Find animals in a square around building (actually should be circle, but animals are moving anyway)
Comment thread
Flamefire marked this conversation as resolved.
const int SQUARE_SIZE = 19;

// Liste mit den gefundenen Tieren
std::vector<noAnimal*> available_animals;

// Durchgehen und nach Tieren suchen
Position curPos;
for(curPos.y = pos.y - SQUARE_SIZE; curPos.y <= pos.y + SQUARE_SIZE; ++curPos.y)
for(curPos.y = pos.y - HUNTER_SEARCH_HALFSIDE; curPos.y <= pos.y + HUNTER_SEARCH_HALFSIDE; ++curPos.y)
{
for(curPos.x = pos.x - SQUARE_SIZE; curPos.x <= pos.x + SQUARE_SIZE; ++curPos.x)
for(curPos.x = pos.x - HUNTER_SEARCH_HALFSIDE; curPos.x <= pos.x + HUNTER_SEARCH_HALFSIDE; ++curPos.x)
{
MapPoint curMapPos = world->MakeMapPoint(curPos);

Expand Down
3 changes: 3 additions & 0 deletions libs/s25main/figures/nofHunter.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
#include "nofBuildingWorker.h"
#include "gameTypes/Direction.h"

/// Half-side length of the square the hunter scans for animals (centered on the building)
constexpr int HUNTER_SEARCH_HALFSIDE = 19;

class noAnimal;
class SerializedGameData;
class nobUsual;
Expand Down
51 changes: 51 additions & 0 deletions libs/s25main/gameData/BuildingConsts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@
// SPDX-License-Identifier: GPL-2.0-or-later

#include "BuildingConsts.h"
#include "figures/nofCatapultMan.h"
#include "figures/nofFarmhand.h"
#include "figures/nofHunter.h"
#include "mygettext/mygettext.h"
#include "gameTypes/BuildingTypes.h"
#include "gameData/GameConsts.h"
#include "gameData/MilitaryConsts.h"
#include <type_traits>

const helpers::EnumArray<const char*, BuildingType> BUILDING_NAMES = {
Expand Down Expand Up @@ -409,3 +415,48 @@ const helpers::MultiEnumArray<DrawPoint, Nation, BuildingType> BUILDING_ARMOR_SI
babylonians[BuildingType::Fortress] = DrawPoint(20, -34);
return result;
}();

unsigned GetBuildingRadius(BuildingType bld)
{
switch(bld)
{
// Military buildings (territory influence radius) — from MilitaryConsts.h
case BuildingType::Barracks: return MILITARY_RADIUS[0];
case BuildingType::Guardhouse: return MILITARY_RADIUS[1];
case BuildingType::Watchtower: return MILITARY_RADIUS[2];
case BuildingType::Fortress: return MILITARY_RADIUS[3];
// Headquarters
case BuildingType::Headquarters: return HQ_RADIUS;
// Harbor building
case BuildingType::HarborBuilding: return HARBOR_RADIUS;
// Lookout tower — scouting visibility range
case BuildingType::LookoutTower: return VISUALRANGE_LOOKOUTTOWER;
// Catapult attack range
case BuildingType::Catapult: return CATAPULT_MAX_TARGET_RANGE;
// Hunter searches for animals in a square of this half-side length
case BuildingType::Hunter: return HUNTER_SEARCH_HALFSIDE;
// Mines — miner stays inside and extracts from adjacent tiles
case BuildingType::GraniteMine:
case BuildingType::CoalMine:
case BuildingType::IronMine:
case BuildingType::GoldMine: return MINER_RADIUS;
// Farmhand-based buildings — worker goes out to gather resources from the map.
// Map each building type to its job via BLD_WORK_DESC, then query the work
// radius from nofFarmhand::GetWorkRadius.
case BuildingType::Woodcutter:
case BuildingType::Forester:
case BuildingType::Fishery:
case BuildingType::Quarry:
case BuildingType::Farm:
case BuildingType::Vineyard:
case BuildingType::Charburner:
{
const auto job = BLD_WORK_DESC[bld].job;
if(job)
return nofFarmhand::GetWorkRadius(*job);
return 0;
}
// All other building types have no relevant radius overlay

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// All other building types have no relevant radius overlay
// All other building types have no relevant work radius (e.g. only work inside the building)

default: return 0;
}
}
3 changes: 3 additions & 0 deletions libs/s25main/gameData/BuildingConsts.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,6 @@ constexpr std::array<DrawPoint, 4> SUPPRESS_UNUSED NUBIAN_MINE_FIRE = {{

/// Hilfetexte für Gebäude
extern const helpers::EnumArray<const char*, BuildingType> BUILDING_HELP_STRINGS;

/// Get the radius in tiles for a building type (worker reach, territory influence, attack range, etc.)
unsigned GetBuildingRadius(BuildingType bld);
34 changes: 34 additions & 0 deletions libs/s25main/ingameWindows/iwAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "nodeObjs/noFlag.h"
#include "gameData/BuildingConsts.h"
#include "gameData/const_gui_ids.h"
#include <boost/format.hpp>
#include <sstream>

// Tab - Flags
Expand Down Expand Up @@ -159,6 +160,7 @@ iwAction::iwAction(GameInterface& gi, GameWorldView& gwv, const Tabs& tabs, MapP
building_available[BuildingType::LeatherWorks] = false;
}

const bool showBuildingRadius = gwv.GetWorld().GetGGS().isEnabled(AddonId::BUILDING_RADIUS);
constexpr helpers::EnumArray<unsigned, BuildTab> NUM_TABS = {1, 2, 3, 1, 3};

for(unsigned char i = 0; i < NUM_TABS[tabs.build_tabs]; ++i)
Expand All @@ -175,6 +177,13 @@ iwAction::iwAction(GameInterface& gi, GameWorldView& gwv, const Tabs& tabs, MapP
std::stringstream tooltip;
tooltip << _(BUILDING_NAMES[bld]);

// Radius anzeigen falls vorhanden

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

English comments only (at least for new/changed ones)

unsigned radius = 0;
if(showBuildingRadius)
radius = GetBuildingRadius(bld);
Comment on lines +181 to +183

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer const variables:

Suggested change
unsigned radius = 0;
if(showBuildingRadius)
radius = GetBuildingRadius(bld);
const unsigned radius = showBuildingRadius ? GetBuildingRadius(bld) : 0;

if(radius > 0)
tooltip << boost::format(_("\nRange: %1% tiles")) % radius;

tooltip << _("\nCosts: ");
if(BUILDING_COSTS[bld].boards > 0)
tooltip << (int)BUILDING_COSTS[bld].boards << _(" boards");
Expand Down Expand Up @@ -407,6 +416,7 @@ void iwAction::Close()
{
if(ShouldBeClosed())
return;
gwv.SetRadiusPreview(std::nullopt);
IngameWindow::Close();
if(mousePosAtOpen_.isValid())
VIDEODRIVER.SetMousePos(mousePosAtOpen_);
Expand Down Expand Up @@ -526,6 +536,30 @@ void iwAction::Msg_Group_TabChange(const unsigned /*group_id*/, const unsigned c
void iwAction::Msg_PaintAfter()
{
IngameWindow::Msg_PaintAfter();

// Resolve building icon hover preview after all mouse events are processed
auto* mainTab = GetCtrl<ctrlTab>(0);
auto* buildTabCtrl =
(mainTab && mainTab->GetCurrentTab() == TAB_BUILD) ? mainTab->GetGroup(TAB_BUILD)->GetCtrl<ctrlTab>(1) : nullptr;
auto* bldGroup = buildTabCtrl ? buildTabCtrl->GetGroup(buildTabCtrl->GetCurrentTab()) : nullptr;

bool hasHoveredIcon = false;
if(bldGroup && gwv.GetWorld().GetGGS().isEnabled(AddonId::BUILDING_RADIUS))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks inefficient doing on every single draw call. What was wrong with the MouseMove-hovering?

@morganchristiansson morganchristiansson Jun 30, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's an issue with icon->SetOnHoverChanged()
When hovering icons in forward direction, the leave event fires after enter event.

Maybe there should be 2 passes, first send leave event, then send enter.

{
for(auto* icon : bldGroup->GetCtrls<ctrlBuildingIcon>())
{
const unsigned radius = GetBuildingRadius(icon->GetType());
if(icon->IsMouseOver() && radius > 0)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't you break once you found ANY mouseover?

{
gwv.SetRadiusPreview(std::make_pair(selectedPt, radius));
hasHoveredIcon = true;
break;
}
}
}
if(!hasHoveredIcon)
gwv.SetRadiusPreview(std::nullopt);

auto* tab = GetCtrl<ctrlTab>(0);
if(tab)
{
Expand Down
89 changes: 89 additions & 0 deletions libs/s25main/world/GameWorldView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
#include "GlobalGameSettings.h"
#include "Loader.h"
#include "MapGeometry.h"
#include "ReturnMapPointWithRadius.h"
#include "Settings.h"
#include "Window.h"
#include "WindowManager.h"
#include "addons/AddonMaxWaterwayLength.h"
#include "buildings/noBuildingSite.h"
#include "buildings/nobMilitary.h"
Expand All @@ -36,6 +39,7 @@
#include <glad/glad.h>
#include <boost/format.hpp>
#include <cmath>
#include <optional>

GameWorldView::GameWorldView(const GameWorldViewer& gwv, const Position& pos, const Extent& size)
: selPt(0, 0), show_bq(SETTINGS.ingame.showBQ), show_names(SETTINGS.ingame.showNames),
Expand Down Expand Up @@ -220,6 +224,37 @@ void GameWorldView::Draw(const RoadBuildState& rb, const MapPoint selected, bool
if(show_names || show_productivity)
DrawNameProductivityOverlay(terrainRenderer);

// Draw radius preview outline
if(radiusPreview_)
DrawRadiusOutline(radiusPreview_->first, radiusPreview_->second);

// Auto-detect radius for the building under the cursor.
// Do not trigger hover when the mouse is over an ingame window.
if(!radiusPreview_ && GetWorld().GetGGS().isEnabled(AddonId::BUILDING_RADIUS)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't that be rather on the outside, e.g. in dskGameInterface where it could be more efficiently in a MouseMove handler. This way it is opt-in and e.g. doesn't enable for observation windows (suspicion only, haven't checked)
And whereever this is done I'd say it makes sense to cache GetWorld().GetGGS().isEnabled(AddonId::BUILDING_RADIUS) (effectively const) instead of getting this on every draw call.

&& !WINDOWMANAGER.FindWindowAtPos(VIDEODRIVER.GetMousePos()))
{
std::optional<BuildingType> bldType;
const Visibility vis = gwv.GetVisibility(selPt);
if(vis == Visibility::Visible)
{
const auto* bld = GetWorld().GetSpecObj<noBaseBuilding>(selPt);
if(bld)
bldType = bld->GetBuildingType();
} else if(vis == Visibility::FogOfWar)
{
const FOWObject* fow = gwv.GetYoungestFOWObject(selPt);
if(fow && fow->GetType() == FoW_Type::Building)
bldType = static_cast<const fowBuilding&>(*fow).GetBuildingType();
}

if(bldType)
{
const unsigned bldRadius = GetBuildingRadius(*bldType);
if(bldRadius > 0)
DrawRadiusOutline(selPt, bldRadius);
}
}

DrawGUI(rb, terrainRenderer, selected, drawMouse);

// Draw catapult stones
Expand Down Expand Up @@ -713,6 +748,60 @@ void GameWorldView::RemoveDrawNodeCallback(IDrawNodeCallback* callbackToRemove)
drawNodeCallbacks.erase(itPos);
}

// -----------------------------------------------------------------------------
// Snap a point to the nearest toroidal copy relative to a reference position.
// Same formula as s25edit's correctMouseBlit():

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't include such references. The client should be self-contained and the code correct on its own. So rather explain why this specific code is correct as-is.
Also the arguments are not clear to me. Why pass 2 by const-ref? Should all be values.
Can mapPxSize ever be zero? When and why?
Without that it gets much easier to read as you can use e.g. pt -ref etc.

// k = round((reference - vertex) / mapSize)
// vertex += k * mapSize
//
// Reference: s25edit/external/s25edit/CMap.cpp :: correctMouseBlit() (line 1088)
// -----------------------------------------------------------------------------
DrawPoint GameWorldView::SnapToNearestCopy(DrawPoint pt, const DrawPoint& ref, const DrawPoint& mapPxSize)
{
if(mapPxSize.x > 0)
{
int kx = static_cast<int>(std::floor((ref.x - pt.x) / static_cast<double>(mapPxSize.x) + 0.5));
pt.x += kx * mapPxSize.x;
}
if(mapPxSize.y > 0)
{
int ky = static_cast<int>(std::floor((ref.y - pt.y) / static_cast<double>(mapPxSize.y) + 0.5));
pt.y += ky * mapPxSize.y;
}
return pt;
}

// -----------------------------------------------------------------------------
// Draw radius overlay using CorrectMouseBlit for toroidal wrapping.
// Reference: s25edit/external/s25edit/CMap.cpp :: render() (lines 1159, 1230)
// - Computes brush blit positions via correctMouseBlit()
// - Draws overlay sprites at those positions
// -----------------------------------------------------------------------------
void GameWorldView::DrawRadiusOutline(const MapPoint& center, unsigned radius)
{
const auto& world = GetWorld();
auto pts = world.GetPointsInRadius(center, radius, ReturnMapPointWithRadius{});

const MapExtent mapSize = world.GetSize();
constexpr unsigned BORDER_COLOR = 0xFFFF0000;
const DrawPoint mapPxSize(mapSize.x * TR_W, mapSize.y * TR_H);

// Reference: screen position of the center vertex (with seam offset).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why "reference"? Isn't this simply a position in screen coordinates? I.e. a DrawPoint from a MapPoint?

const auto centerAlt = world.GetNode(center).altitude;
const DrawPoint ref = GetNodePos(center) - DrawPoint(0, HEIGHT_FACTOR * centerAlt) + selPtOffset;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use the overload:

Suggested change
const auto centerAlt = world.GetNode(center).altitude;
const DrawPoint ref = GetNodePos(center) - DrawPoint(0, HEIGHT_FACTOR * centerAlt) + selPtOffset;
const DrawPoint ref = GetNodePos(center, world.GetNode(center).altitude) + selPtOffset;

Also where does selPtOffset come from? Would need a comment


for(const auto& [basePt, dist] : pts)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
for(const auto& [basePt, dist] : pts)
for(const auto& [pt, dist] : pts)

Or mapPt or similar, I suspected a function parameter or similar especially with scr not containing "Point" which I guess it should. Maybe mapPt and screenPt?

{
if(dist != radius)
continue;

DrawPoint scr = GetNodePos(basePt, world.GetNode(basePt).altitude);
scr = SnapToNearestCopy(scr, ref, mapPxSize) - offset;

Window::DrawRectangle(Rect(scr - DrawPoint(2, 2), Extent(5, 5)), BORDER_COLOR);
}
}

void GameWorldView::CalcFxLx()
{
// Calc first and last point in map units (with 1 extra for incomplete triangles)
Expand Down
Loading
Loading