Use std::optional instead of sentinel values for absent data

This commit is contained in:
2026-07-20 20:27:20 +02:00
parent 1cdafb7bcd
commit 9622fa4345
32 changed files with 228 additions and 209 deletions

View File

@@ -58,7 +58,7 @@ struct ArenaStatus
TeamStatus teams[2];
bool finished = false;
int winnerTeam = -1; // 0 or 1 when finished; -1 while running
std::optional<int> winnerTeam; // 0 or 1 when finished; nullopt while running
// Game time the fight has lasted (simulated ticks * fixed tick duration).
// Meaningful once finished; the battle duration shown for completed runs.
double durationSeconds = 0.0;
@@ -80,7 +80,7 @@ public:
ArenaStatus getStatus() const;
bool isFinished() const;
int getWinnerTeam() const;
std::optional<int> getWinnerTeam() const;
Tick getCurrentTick() const;
const ArenaConfig& getArenaConfig() const;
@@ -122,7 +122,7 @@ private:
entt::entity m_team2HqEntity;
bool m_finished;
int m_winnerTeam;
std::optional<int> m_winnerTeam;
std::atomic<bool> m_stopRequested;
// Static accumulated threat per team, computed once from the configured roster.