Add: track savegame size to report with survey (#12304)

This commit is contained in:
Patric Stout
2024-03-16 08:58:56 +01:00
committed by GitHub
parent b394c20519
commit 3e625b5b1a
12 changed files with 48 additions and 17 deletions

View File

@@ -235,6 +235,20 @@ void SurveyOpenTTD(nlohmann::json &survey)
;
}
/**
* Convert game session information to JSON.
*
* @param survey The JSON object.
*/
void SurveyGameSession(nlohmann::json &survey)
{
survey["id"] = _game_session_stats.savegame_id;
survey["seconds"] = std::chrono::duration_cast<std::chrono::seconds>(std::chrono::steady_clock::now() - _game_session_stats.start_time).count();
if (_game_session_stats.savegame_size.has_value()) {
survey["savegame_size"] = _game_session_stats.savegame_size.value();
}
}
/**
* Convert generic game information to JSON.
*
@@ -330,7 +344,6 @@ void SurveyCompanies(nlohmann::json &survey)
void SurveyTimers(nlohmann::json &survey)
{
survey["ticks"] = TimerGameTick::counter;
survey["seconds"] = std::chrono::duration_cast<std::chrono::seconds>(std::chrono::steady_clock::now() - _switch_mode_time).count();
TimerGameEconomy::YearMonthDay economy_ymd = TimerGameEconomy::ConvertDateToYMD(TimerGameEconomy::date);
survey["economy"] = fmt::format("{:04}-{:02}-{:02} ({})", economy_ymd.year, economy_ymd.month + 1, economy_ymd.day, TimerGameEconomy::date_fract);