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

Return-To-The-Roots / s25client / 12453286720

22 Dec 2024 10:04AM UTC coverage: 50.282% (+0.06%) from 50.225%
12453286720

Pull #1723

github

web-flow
Merge e36a78ef6 into 17844c810
Pull Request #1723: Add cheat to enable all buildings

18 of 22 new or added lines in 4 files covered. (81.82%)

6 existing lines in 3 files now uncovered.

22346 of 44441 relevant lines covered (50.28%)

36672.67 hits per line

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

84.85
/libs/s25main/mapGenerator/Rivers.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/Rivers.h"
6
#include "mapGenerator/Terrain.h"
7
#include "mapGenerator/TextureHelper.h"
8

9
namespace rttr::mapGenerator {
10

11
River CreateStream(RandomUtility& rnd, Map& map, const MapPoint& source, Direction direction, unsigned length,
30✔
12
                   unsigned splitRate)
13
{
14
    const MapExtent& size = map.size;
30✔
15

16
    River river;
30✔
17
    std::vector<Direction> exlcuded{direction + 2, direction + 3, direction + 4};
60✔
18

19
    auto& textures = map.textureMap;
30✔
20
    const auto water = textures.Find(IsWater);
30✔
21

22
    MapPoint currentNode = source;
30✔
23
    Direction currentDir = direction;
30✔
24

25
    for(unsigned node = 0; node < length; ++node)
312✔
26
    {
27
        const auto& triangles = GetTriangles(currentNode, size, currentDir);
288✔
28

29
        for(const auto& triangle : triangles)
864✔
30
        {
31
            textures.Set(triangle, water);
576✔
32

33
            const auto& edges = GetTriangleEdges(triangle, size);
576✔
34
            for(const MapPoint& edge : edges)
2,304✔
35
            {
36
                river.insert(edge);
1,728✔
37
            }
38
        }
39

40
        if(map.z[currentNode] == map.height.minimum)
288✔
41
        {
42
            return river;
6✔
43
        }
44

45
        const auto lastDir = currentDir;
282✔
46

47
        while(currentDir == lastDir || helpers::contains(exlcuded, currentDir))
709✔
48
        {
49
            currentDir = lastDir + (rnd.ByChance(50) ? 5 : 1);
427✔
50
        }
51

52
        currentNode = map.getTextures().GetNeighbour(currentNode, lastDir);
282✔
53

54
        if(rnd.ByChance(splitRate))
282✔
55
        {
UNCOV
56
            auto splitDirection = direction + (rnd.ByChance(50) ? 5 : 1);
×
UNCOV
57
            auto anotherRivers = CreateStream(rnd, map, currentNode, splitDirection, length / 2, splitRate / 2);
×
58

UNCOV
59
            for(const MapPoint& node : anotherRivers)
×
60
            {
UNCOV
61
                river.insert(node);
×
62
            }
63
        }
64
    }
65

66
    auto seaLevel = static_cast<unsigned>(map.height.minimum);
24✔
67
    auto& z = map.z;
24✔
68

69
    for(const MapPoint& node : river)
384✔
70
    {
71
        if(z[node] > 0)
360✔
72
        {
73
            z[node] = std::max(static_cast<unsigned>(z[node] - 1), seaLevel);
360✔
74
        } else
75
        {
76
            z[node] = seaLevel;
×
77
        }
78
    }
79

80
    return river;
24✔
81
}
82

83
} // 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