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
1212
1313using 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> SUPPRESS_UNUSED SPEED_GF_LENGTHS = {
16+ {80ms, 60ms, 50ms, 40ms, 30ms}};
1717constexpr auto MAX_SPEED = 10ms;
1818constexpr auto MIN_SPEED = SPEED_GF_LENGTHS [GameSpeed::VerySlow];
1919// / Max/Max speed for debug mode (includes replays)
@@ -24,12 +24,15 @@ constexpr auto SPEED_STEP = 10ms;
2424
2525// / Normal speed as reference speed for ingame time computations
2626constexpr auto REFERENCE_SPEED = SPEED_GF_LENGTHS [GameSpeed::Normal];
27+ // When using unsigned as the type for number of GFs check that we can represent
28+ // game durations of at least a year in units of our chosen (reference) speed.
29+ static_assert (REFERENCE_SPEED * std::numeric_limits<unsigned >::max() >= 24h * 365 );
2730
2831// / Get normalized number of game frames for the given duration
2932template <class Rep , class Period >
3033constexpr auto duration_to_gfs (const std::chrono::duration<Rep, Period> d)
3134{
32- return d / REFERENCE_SPEED ;
35+ return static_cast < unsigned >( d / REFERENCE_SPEED ) ;
3336}
3437
3538// / Get normalized duration for the given number of game frames
0 commit comments