Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 2 additions & 1 deletion libs/s25main/GlobalGameSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ void GlobalGameSettings::registerAllAddons()
AddonForesterReachRadius,
AddonWoodcutterReachRadius,
AddonStonemasonReachRadius,
AddonBuildingRadius
AddonBuildingRadius,
AddonForesterHarborAvoidance
>;
// clang-format on
using namespace boost::mp11;
Expand Down
18 changes: 18 additions & 0 deletions libs/s25main/addons/AddonForesterHarborAvoidance.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// 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"

class AddonForesterHarborAvoidance : public AddonBool
{
public:
AddonForesterHarborAvoidance()
: AddonBool(AddonId::FORESTER_HARBOR_AVOIDANCE, AddonGroup::GamePlay | AddonGroup::Economy,
_("Foresters avoid harbor spots"),
_("Prevents foresters from planting trees on spots that a harbor could be built on."))
{}
};
2 changes: 2 additions & 0 deletions libs/s25main/addons/Addons.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,5 @@
#include "addons/AddonWoodcutterReachRadius.h"

#include "addons/AddonBuildingRadius.h"

#include "addons/AddonForesterHarborAvoidance.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 @@ -29,6 +29,7 @@
// 011 DevOpsOfChaos
// 012 MichalLabuda
// 013 Morgan
// 014 LittleFox

// Do not forget to add your Addon to GlobalGameSettings::registerAllAddons @ GlobalGameSettings.cpp!
// Never use a number twice!
Expand Down Expand Up @@ -90,7 +91,9 @@ ENUM_WITH_STRING(AddonId, LIMIT_CATAPULTS = 0x00000000, INEXHAUSTIBLE_MINES = 0x
FORESTER_REACH_RADIUS = 0x01200000, WOODCUTTER_REACH_RADIUS = 0x01200001,
STONEMASON_REACH_RADIUS = 0x01200002,

BUILDING_RADIUS = 0x01300000)
BUILDING_RADIUS = 0x01300000,

FORESTER_HARBOR_AVOIDANCE = 0x1400001)
//-V:AddonId:801

enum class AddonGroup : unsigned
Expand Down
8 changes: 8 additions & 0 deletions libs/s25main/figures/nofForester.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ bool isPotentialNewFieldForOwnFarm(GameWorld& world, const MapPoint pt, const un
},
false);
}

bool IsPotentialHarborField(GameWorld& world, const MapPoint pt)
{
return world.calcDistanceToNearestHarbor(pt) <= 1;
}
} // namespace

nofForester::nofForester(const MapPoint pos, const unsigned char player, nobUsual* workplace)
Expand Down Expand Up @@ -137,6 +142,9 @@ nofFarmhand::PointQuality nofForester::getPointQuality(const MapPoint pt, bool /
&& isPotentialNewFieldForOwnFarm(*world, pt, player))
return PointQuality::NotPossible;

if(world->getGGS().isEnabled(AddonId::FORESTER_HARBOR_AVOIDANCE) && IsPotentialHarborField(*world, pt))
return PointQuality::NotPossible;

// Terrain untersuchen
if(world->isOfTerrain(pt, [](const auto& desc) { return desc.isVital(); }))
return PointQuality::Class1;
Expand Down
Loading