Changeset - r28610:cf9b62328718
[Not reviewed]
master
0 2 0
Tyler Trahan - 3 months ago 2024-01-29 22:11:00
tyler@tylertrahan.com
Fix: Use alternate timekeeping units in savegame title (#11912)
2 files changed with 21 insertions and 11 deletions:
0 comments (0 inline, 0 general)
src/lang/english.txt
Show inline comments
 
@@ -5766,8 +5766,9 @@ STR_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})
src/saveload/saveload.cpp
Show inline comments
 
@@ -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::s
 
		}
 

	
 
		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);
0 comments (0 inline, 0 general)