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

@@ -29,7 +29,6 @@
extern TileIndex _cur_tileloop_tile;
extern uint16_t _disaster_delay;
extern byte _trees_tick_ctr;
extern std::string _savegame_id;
/* Keep track of current game position */
int _saved_scrollpos_x;
@@ -98,7 +97,7 @@ static const SaveLoad _date_desc[] = {
SLEG_VAR("company_tick_counter", _cur_company_tick_index, SLE_FILE_U8 | SLE_VAR_U32),
SLEG_VAR("trees_tick_counter", _trees_tick_ctr, SLE_UINT8),
SLEG_CONDVAR("pause_mode", _pause_mode, SLE_UINT8, SLV_4, SL_MAX_VERSION),
SLEG_CONDSSTR("id", _savegame_id, SLE_STR, SLV_SAVEGAME_ID, SL_MAX_VERSION),
SLEG_CONDSSTR("id", _game_session_stats.savegame_id, SLE_STR, SLV_SAVEGAME_ID, SL_MAX_VERSION),
/* For older savegames, we load the current value as the "period"; afterload will set the "fired" and "elapsed". */
SLEG_CONDVAR("next_competitor_start", _new_competitor_timeout.period, SLE_FILE_U16 | SLE_VAR_U32, SL_MIN_VERSION, SLV_109),
SLEG_CONDVAR("next_competitor_start", _new_competitor_timeout.period, SLE_UINT32, SLV_109, SLV_AI_START_DATE),

View File

@@ -2182,7 +2182,10 @@ struct FileReader : LoadFilter {
/** Make sure everything is cleaned up. */
~FileReader()
{
if (this->file != nullptr) fclose(this->file);
if (this->file != nullptr) {
_game_session_stats.savegame_size = ftell(this->file) - this->begin;
fclose(this->file);
}
this->file = nullptr;
}
@@ -2231,7 +2234,10 @@ struct FileWriter : SaveFilter {
void Finish() override
{
if (this->file != nullptr) fclose(this->file);
if (this->file != nullptr) {
_game_session_stats.savegame_size = ftell(this->file);
fclose(this->file);
}
this->file = nullptr;
}
};