• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Return-To-The-Roots / s25client / 22021214647

14 Feb 2026 05:14PM UTC coverage: 50.814% (-0.01%) from 50.826%
22021214647

Pull #1889

github

web-flow
Merge eeeb9cde4 into e6489dca6
Pull Request #1889: Pathfinding: reject unconnected buildings / construction sites in specific scenarios

9 of 17 new or added lines in 2 files covered. (52.94%)

9 existing lines in 3 files now uncovered.

22793 of 44856 relevant lines covered (50.81%)

41111.48 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

92.86
/libs/s25main/mapGenerator/Terrain.cpp
1
// Copyright (C) 2005 - 2021 Settlers Freaks (sf-team at siedler25.org)
2
//
3
// SPDX-License-Identifier: GPL-2.0-or-later
4

5
#include "mapGenerator/Terrain.h"
6
#include "mapGenerator/Algorithms.h"
7
#include "mapGenerator/TextureHelper.h"
8

9
#include <algorithm>
10
#include <stdexcept>
11

12
namespace rttr::mapGenerator {
13

14
void Restructure(Map& map, const std::function<bool(const MapPoint&)>& predicate, double weight)
9✔
15
{
16
    auto& z = map.z;
9✔
17
    const MapExtent& size = map.size;
9✔
18
    const auto distances = DistancesTo(size, predicate);
18✔
19
    const auto maximum = *std::max_element(distances.begin(), distances.end());
9✔
20

21
    RTTR_FOREACH_PT(MapPoint, size)
20,911✔
22
    {
23
        // value between 0 and 1 - depending on the distance to focused area
24
        auto value = static_cast<double>(maximum - distances[pt]) / maximum;
20,532✔
25

26
        // combine weight, value and actual z-value
27
        z[pt] = static_cast<uint8_t>(round(std::pow(value, weight) * z[pt]));
20,532✔
28
    }
29

30
    Scale(z, map.height.minimum, map.height.maximum);
9✔
31
}
9✔
32

33
void ResetSeaLevel(Map& map, RandomUtility& rnd, unsigned seaLevel)
6✔
34
{
35
    auto& z = map.z;
6✔
36

37
    RTTR_FOREACH_PT(MapPoint, map.size)
20,740✔
38
    {
39
        if(z[pt] <= seaLevel)
20,388✔
40
        {
41
            z[pt] = map.height.minimum;
8,745✔
42
        } else
43
        {
44
            z[pt] -= seaLevel;
11,643✔
45
        }
46
    }
47

48
    const auto isCoast = [&z, &map](const MapPoint& pt) { return z[pt] == map.height.minimum; };
20,388✔
49
    auto coastDistance = DistancesTo(map.size, isCoast);
12✔
50
    auto minimum = static_cast<unsigned>(map.height.minimum);
6✔
51
    auto maximum = *std::max_element(coastDistance.begin(), coastDistance.end());
6✔
52

53
    if(maximum > map.height.maximum)
6✔
54
    {
UNCOV
55
        maximum = map.height.maximum;
×
UNCOV
56
        Scale(coastDistance, minimum, maximum);
×
57
    }
58

59
    RTTR_FOREACH_PT(MapPoint, map.size)
20,740✔
60
    {
61
        if(coastDistance[pt] > minimum)
20,388✔
62
        {
63
            const unsigned base = coastDistance[pt];
11,643✔
64

65
            z[pt] = rnd.RandomValue(std::max(minimum + 1, base), std::min(maximum, base + 1));
11,643✔
66
        }
67
    }
68
}
6✔
69

70
} // namespace rttr::mapGenerator
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc