Fix: Use alternate timekeeping units in savegame title (#11912)

pull/661/head
Tyler Trahan 5 months ago committed by GitHub
parent 435d48e182
commit 2b1f78d2ca
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -5766,8 +5766,9 @@ STR_UNKNOWN_STATION :unknown station
STR_DEFAULT_SIGN_NAME :Sign
STR_COMPANY_SOMEONE :someone
STR_SAVEGAME_NAME_DEFAULT :{COMPANY}, {STRING1}
STR_SAVEGAME_NAME_SPECTATOR :Spectator, {1:STRING1}
STR_SAVEGAME_DURATION_REALTIME :{NUM}h {NUM}m
STR_SAVEGAME_NAME_DEFAULT :{COMPANY}, {STRING2}
STR_SAVEGAME_NAME_SPECTATOR :Spectator, {1:STRING2}
# Viewport strings
STR_VIEWPORT_TOWN_POP :{WHITE}{TOWN} ({COMMA})

@ -31,7 +31,7 @@
#include "../core/endian_func.hpp"
#include "../vehicle_base.h"
#include "../company_func.h"
#include "../timer/timer_game_calendar.h"
#include "../timer/timer_game_economy.h"
#include "../autoreplace_base.h"
#include "../roadstop_base.h"
#include "../linkgraph/linkgraph.h"
@ -3111,7 +3111,7 @@ SaveOrLoadResult SaveOrLoad(const std::string &filename, SaveLoadOperation fop,
}
if (fop == SLO_SAVE) { // SAVE game
Debug(desync, 1, "save: {:08x}; {:02x}; {}", TimerGameCalendar::date, TimerGameCalendar::date_fract, filename);
Debug(desync, 1, "save: {:08x}; {:02x}; {}", TimerGameEconomy::date, TimerGameEconomy::date_fract, filename);
if (!_settings_client.gui.threaded_saves) threaded = false;
return DoSave(new FileWriter(fh), threaded);
@ -3179,14 +3179,23 @@ std::string GenerateDefaultSaveName()
SetDParam(0, cid);
/* Insert current date */
switch (_settings_client.gui.date_format_in_default_names) {
case 0: SetDParam(1, STR_JUST_DATE_LONG); break;
case 1: SetDParam(1, STR_JUST_DATE_TINY); break;
case 2: SetDParam(1, STR_JUST_DATE_ISO); break;
default: NOT_REACHED();
/* We show the current game time differently depending on the timekeeping units used by this game. */
if (TimerGameEconomy::UsingWallclockUnits()) {
/* Insert time played. */
const auto play_time = TimerGameTick::counter / Ticks::TICKS_PER_SECOND;
SetDParam(1, STR_SAVEGAME_DURATION_REALTIME);
SetDParam(2, play_time / 60 / 60);
SetDParam(3, (play_time / 60) % 60);
} else {
/* Insert current date */
switch (_settings_client.gui.date_format_in_default_names) {
case 0: SetDParam(1, STR_JUST_DATE_LONG); break;
case 1: SetDParam(1, STR_JUST_DATE_TINY); break;
case 2: SetDParam(1, STR_JUST_DATE_ISO); break;
default: NOT_REACHED();
}
SetDParam(2, TimerGameEconomy::date);
}
SetDParam(2, TimerGameCalendar::date);
/* Get the correct string (special string for when there's not company) */
std::string filename = GetString(!Company::IsValidID(cid) ? STR_SAVEGAME_NAME_SPECTATOR : STR_SAVEGAME_NAME_DEFAULT);

Loading…
Cancel
Save