Skip to content

Commit f51d6bb

Browse files
committed
Remove use of SUPPRESS_UNUSED
- Use `constexpr` instead of `const` - Use `[[maybe_unused]]` where applicable - Remove includes - Also shorten array-types to use CTAD instead of specifying the template params explicitely
1 parent 3deea9b commit f51d6bb

23 files changed

Lines changed: 70 additions & 95 deletions

cpp.hint

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (C) 2005 - 2021 Settlers Freaks <sf-team at siedler25.org>
1+
// Copyright (C) 2005 - 2026 Settlers Freaks <sf-team at siedler25.org>
22
//
33
// SPDX-License-Identifier: BSL-1.0
44

@@ -15,5 +15,4 @@
1515
#define BOOST_REQUIRE_GT(x,y) BOOST_REQUIRE((x) > (y))
1616

1717
#define RTTR_FOREACH_PT(PtType, size) for(PtType pt;;)
18-
#define SUPPRESS_UNUSED
1918
#define RTTR_Assert(cond) assert(cond)

external/s25update

libs/common/include/helpers/OptionalEnum.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (C) 2005 - 2025 Settlers Freaks (sf-team at siedler25.org)
1+
// Copyright (C) 2005 - 2026 Settlers Freaks (sf-team at siedler25.org)
22
//
33
// SPDX-License-Identifier: GPL-2.0-or-later
44

@@ -25,7 +25,7 @@ class OptionalEnum
2525
using value_type = T;
2626

2727
constexpr OptionalEnum() noexcept = default;
28-
OptionalEnum(std::nullopt_t) noexcept {}
28+
constexpr OptionalEnum(std::nullopt_t) noexcept {}
2929
constexpr OptionalEnum(const T& value) noexcept : value_(static_cast<underlying_type>(value)) {}
3030
constexpr OptionalEnum& operator=(const T& value) noexcept
3131
{

libs/s25main/addons/AddonDurableGeologistSigns.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (C) 2005 - 2021 Settlers Freaks (sf-team at siedler25.org)
1+
// Copyright (C) 2005 - 2026 Settlers Freaks (sf-team at siedler25.org)
22
//
33
// SPDX-License-Identifier: GPL-2.0-or-later
44

@@ -7,7 +7,7 @@
77
#include "AddonList.h"
88
#include <boost/format.hpp>
99

10-
const std::array<unsigned, 4> SUPPRESS_UNUSED signDurabilityFactor = {{1, 2, 4, 10}};
10+
constexpr std::array signDurabilityFactor{1u, 2u, 4u, 10u};
1111

1212
/**
1313
* Addon makes resource signs stay visible longer than normal

libs/s25main/addons/AddonMaxWaterwayLength.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
1-
// Copyright (C) 2005 - 2021 Settlers Freaks (sf-team at siedler25.org)
1+
// Copyright (C) 2005 - 2026 Settlers Freaks (sf-team at siedler25.org)
22
//
33
// SPDX-License-Identifier: GPL-2.0-or-later
44

55
#pragma once
66

77
#include "AddonList.h"
88
#include "mygettext/mygettext.h"
9-
#include "s25util/warningSuppression.h"
109
#include <array>
1110

12-
const std::array<unsigned, 6> SUPPRESS_UNUSED waterwayLengths = {{3, 5, 9, 13, 21, 0}};
11+
inline constexpr std::array waterwayLengths{3u, 5u, 9u, 13u, 21u, 0u};
1312

1413
/**
1514
* Addon for changing the maximum length of waterways.

libs/s25main/ai/AIResource.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
// Copyright (C) 2005 - 2021 Settlers Freaks (sf-team at siedler25.org)
1+
// Copyright (C) 2005 - 2026 Settlers Freaks (sf-team at siedler25.org)
22
//
33
// SPDX-License-Identifier: GPL-2.0-or-later
44

55
#pragma once
66

77
#include "helpers/EnumArray.h"
8-
#include "s25util/warningSuppression.h"
98

109
// Note: This enums are constructed for performance and easy conversion.
1110
// AIResource must be contiguous and it is assumed that only valid enumerators are used
@@ -86,7 +85,7 @@ constexpr bool operator==(AINodeResource lhs, AIResource rhs) noexcept
8685
return lhs == convertToNodeResource(rhs);
8786
}
8887

89-
constexpr helpers::EnumArray<unsigned, AIResource> SUPPRESS_UNUSED RES_RADIUS = {
88+
constexpr helpers::EnumArray<unsigned, AIResource> RES_RADIUS = {
9089
2, // Gold
9190
2, // Ironore
9291
2, // Coal

libs/s25main/drivers/DriverWrapper.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (C) 2005 - 2021 Settlers Freaks (sf-team at siedler25.org)
1+
// Copyright (C) 2005 - 2026 Settlers Freaks (sf-team at siedler25.org)
22
//
33
// SPDX-License-Identifier: GPL-2.0-or-later
44

@@ -13,7 +13,6 @@
1313
#include "mygettext/mygettext.h"
1414
#include "s25util/Log.h"
1515
#include "s25util/error.h"
16-
#include "s25util/warningSuppression.h"
1716
#include <array>
1817

1918
namespace dll = boost::dll;

libs/s25main/gameData/BuildingConsts.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (C) 2005 - 2021 Settlers Freaks (sf-team at siedler25.org)
1+
// Copyright (C) 2005 - 2026 Settlers Freaks (sf-team at siedler25.org)
22
//
33
// SPDX-License-Identifier: GPL-2.0-or-later
44

@@ -13,13 +13,13 @@
1313

1414
extern const helpers::EnumArray<const char*, BuildingType> BUILDING_NAMES;
1515

16-
constexpr helpers::EnumArray<BuildingCost, BuildingType> SUPPRESS_UNUSED BUILDING_COSTS = {
16+
constexpr helpers::EnumArray<BuildingCost, BuildingType> BUILDING_COSTS = {
1717
{{0, 0}, {2, 0}, {2, 3}, {2, 0}, {3, 5}, {4, 4}, {2, 3}, {4, 7}, {2, 2}, {4, 7}, {4, 0}, {4, 0}, {4, 0}, {4, 0},
1818
{4, 0}, {2, 2}, {4, 2}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 2}, {2, 0}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {4, 3},
1919
{3, 3}, {4, 3}, {0, 0}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 0}, {2, 3}, {3, 3}, {3, 3}, {4, 6}}};
2020

2121
// Bauqualitäten der Gebäude
22-
constexpr helpers::EnumArray<BuildingQuality, BuildingType> SUPPRESS_UNUSED BUILDING_SIZE = {
22+
constexpr helpers::EnumArray<BuildingQuality, BuildingType> BUILDING_SIZE = {
2323
{BuildingQuality::Castle, BuildingQuality::Hut, BuildingQuality::Hut, BuildingQuality::Hut,
2424
BuildingQuality::House, BuildingQuality::Castle, BuildingQuality::House, BuildingQuality::Castle,
2525
BuildingQuality::House, BuildingQuality::Castle, BuildingQuality::Mine, BuildingQuality::Mine,
@@ -31,7 +31,7 @@ constexpr helpers::EnumArray<BuildingQuality, BuildingType> SUPPRESS_UNUSED BUIL
3131
BuildingQuality::House, BuildingQuality::House, BuildingQuality::House, BuildingQuality::Hut,
3232
BuildingQuality::House, BuildingQuality::Castle, BuildingQuality::Castle, BuildingQuality::Harbor}};
3333

34-
const helpers::EnumArray<BldWorkDescription, BuildingType> SUPPRESS_UNUSED BLD_WORK_DESC = {{
34+
constexpr helpers::EnumArray<BldWorkDescription, BuildingType> BLD_WORK_DESC = {{
3535
{}, // HQ
3636
{Job::Private, std::nullopt, WaresNeeded(GoodType::Coins), 1},
3737
{Job::Private, std::nullopt, WaresNeeded(GoodType::Coins), 2},
@@ -78,7 +78,7 @@ const helpers::EnumArray<BldWorkDescription, BuildingType> SUPPRESS_UNUSED BLD_W
7878
extern const helpers::MultiEnumArray<SmokeConst, Nation, BuildingType> BUILDING_SMOKE_CONSTS;
7979

8080
/// Offset of the production-/gold- stop signs per building
81-
constexpr helpers::MultiEnumArray<DrawPoint, Nation, BuildingType> SUPPRESS_UNUSED BUILDING_SIGN_CONSTS = {
81+
constexpr helpers::MultiEnumArray<DrawPoint, Nation, BuildingType> BUILDING_SIGN_CONSTS = {
8282
{// Nubier
8383
{{{0, 0}, {19, -4}, {19, -3}, {-14, -1}, {23, -19}, {22, -7}, {-8, -10}, {9, -24}, {-16, -10}, {29, -23},
8484
{-2, -15}, {2, -13}, {-5, -16}, {-5, -15}, {0, 0}, {22, -6}, {0, 0}, {4, -16}, {9, -12}, {7, -10},
@@ -110,7 +110,7 @@ extern const helpers::MultiEnumArray<DrawPoint, Nation, BuildingType> BUILDING_A
110110

111111
/// Position der nubischen Feuer für alle 4 Bergwerke
112112
/// (Granit, Kohle, Eisen, Gold)
113-
constexpr std::array<DrawPoint, 4> SUPPRESS_UNUSED NUBIAN_MINE_FIRE = {{
113+
constexpr std::array<DrawPoint, 4> NUBIAN_MINE_FIRE = {{
114114
{31, -18},
115115
{34, -10},
116116
{30, -11},

libs/s25main/gameData/GameConsts.h

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (C) 2005 - 2025 Settlers Freaks (sf-team at siedler25.org)
1+
// Copyright (C) 2005 - 2026 Settlers Freaks (sf-team at siedler25.org)
22
//
33
// SPDX-License-Identifier: GPL-2.0-or-later
44

@@ -12,8 +12,7 @@
1212

1313
using namespace std::chrono_literals;
1414
/// Length of GameFrames for each speed level
15-
constexpr helpers::EnumArray<std::chrono::duration<unsigned, std::milli>, GameSpeed> SUPPRESS_UNUSED
16-
SPEED_GF_LENGTHS = {{80ms, 60ms, 50ms, 40ms, 30ms}};
15+
constexpr helpers::EnumArray<std::chrono::milliseconds, GameSpeed> SPEED_GF_LENGTHS = {{80ms, 60ms, 50ms, 40ms, 30ms}};
1716
constexpr auto MAX_SPEED = 10ms;
1817
constexpr auto MIN_SPEED = SPEED_GF_LENGTHS[GameSpeed::VerySlow];
1918
/// Max/Max speed for debug mode (includes replays)
@@ -29,7 +28,7 @@ constexpr auto REFERENCE_SPEED = SPEED_GF_LENGTHS[GameSpeed::Normal];
2928
template<class Rep, class Period>
3029
constexpr auto duration_to_gfs(const std::chrono::duration<Rep, Period> d)
3130
{
32-
return d / REFERENCE_SPEED;
31+
return static_cast<unsigned>(d / REFERENCE_SPEED);
3332
}
3433

3534
/// Get normalized duration for the given number of game frames
@@ -44,8 +43,8 @@ constexpr unsigned MINER_RADIUS = 2;
4443
/// Konstante für die Pfadrichtung bei einer Schiffsverbindung
4544
constexpr unsigned char SHIP_DIR = 100;
4645
constexpr unsigned char INVALID_DIR = 0xFF;
47-
constexpr unsigned SUPPRESS_UNUSED NO_MAX_LEN = std::numeric_limits<unsigned>::max();
46+
constexpr auto NO_MAX_LEN = std::numeric_limits<unsigned>::max();
4847

4948
/// tournament modes
50-
constexpr std::array SUPPRESS_UNUSED TOURNAMENT_MODES_DURATION{30min, 60min, 90min, 120min, 240min};
49+
constexpr std::array TOURNAMENT_MODES_DURATION{30min, 60min, 90min, 120min, 240min};
5150
static_assert(TOURNAMENT_MODES_DURATION.size() == NUM_TOURNAMENT_MODES);

0 commit comments

Comments
 (0)