Skip to content

Make loading savegames deterministic - #1970

Draft
Flamefire wants to merge 10 commits into
masterfrom
save-rng-state
Draft

Make loading savegames deterministic#1970
Flamefire wants to merge 10 commits into
masterfrom
save-rng-state

Conversation

@Flamefire

Copy link
Copy Markdown
Member

Currently the RNGs for in savegames are seeded with zero. This means continuing a loaded savegame will be different than the game played at that point.

Implement saving the current RNG states.

After C++11 the outcome is specified by the standard for the standard
PRNGs. Hence we can use a generic function for serialization.
Add those and tests.
C++17 introduced `std::clamp` which makes passing a type from std
namespace (such as chrono-types) ambiguous in the semi-recursive call.
Use constexpr-ifs and `std::clamp` in teh final path.
It's the same as `isSoldier` so rename/remove it.
- 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant