mirror of https://github.com/OpenTTD/OpenTTD
(svn r14802) -Fix [FS#2490]: "(undefined string)" in default savegame/screenshot names when there's no company in the game.
parent
d428da5a35
commit
fa2bf69a53
|
@ -2017,6 +2017,7 @@ STR_4001_LOAD_GAME :{WHITE}Load Gam
|
||||||
STR_4002_SAVE :{BLACK}Save
|
STR_4002_SAVE :{BLACK}Save
|
||||||
STR_4003_DELETE :{BLACK}Delete
|
STR_4003_DELETE :{BLACK}Delete
|
||||||
STR_4004 :{COMPANY}, {STRING1}
|
STR_4004 :{COMPANY}, {STRING1}
|
||||||
|
STR_GAME_SAVELOAD_SPECTATOR_SAVEGAME :Spectator, {SKIP}{STRING1}
|
||||||
STR_4005_BYTES_FREE :{BLACK}{COMMA} megabyte{P "" s} free
|
STR_4005_BYTES_FREE :{BLACK}{COMMA} megabyte{P "" s} free
|
||||||
STR_4006_UNABLE_TO_READ_DRIVE :{BLACK}Unable to read drive
|
STR_4006_UNABLE_TO_READ_DRIVE :{BLACK}Unable to read drive
|
||||||
STR_4007_GAME_SAVE_FAILED :{WHITE}Game Save Failed{}{STRING}
|
STR_4007_GAME_SAVE_FAILED :{WHITE}Game Save Failed{}{STRING}
|
||||||
|
|
|
@ -1826,9 +1826,21 @@ void DoExitSave()
|
||||||
*/
|
*/
|
||||||
void GenerateDefaultSaveName(char *buf, const char *last)
|
void GenerateDefaultSaveName(char *buf, const char *last)
|
||||||
{
|
{
|
||||||
/* Check if we are not a spectator who wants to generate a name..
|
/* Check if we have a name for this map, which is the name of the first
|
||||||
* Let's use the name of company #0 for now. */
|
* available company. When there's no company available we'll use
|
||||||
SetDParam(0, IsValidCompanyID(_local_company) ? _local_company : COMPANY_FIRST);
|
* 'Spectator' as "company" name. */
|
||||||
|
CompanyID cid = _local_company;
|
||||||
|
if (!IsValidCompanyID(cid)) {
|
||||||
|
const Company *c;
|
||||||
|
FOR_ALL_COMPANIES(c) {
|
||||||
|
cid = c->index;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SetDParam(0, cid);
|
||||||
|
|
||||||
|
/* Insert current date */
|
||||||
switch (_settings_client.gui.date_format_in_default_names) {
|
switch (_settings_client.gui.date_format_in_default_names) {
|
||||||
case 0: SetDParam(1, STR_JUST_DATE_LONG); break;
|
case 0: SetDParam(1, STR_JUST_DATE_LONG); break;
|
||||||
case 1: SetDParam(1, STR_JUST_DATE_TINY); break;
|
case 1: SetDParam(1, STR_JUST_DATE_TINY); break;
|
||||||
|
@ -1836,7 +1848,9 @@ void GenerateDefaultSaveName(char *buf, const char *last)
|
||||||
default: NOT_REACHED();
|
default: NOT_REACHED();
|
||||||
}
|
}
|
||||||
SetDParam(2, _date);
|
SetDParam(2, _date);
|
||||||
GetString(buf, STR_4004, last);
|
|
||||||
|
/* Get the correct string (special string for when there's not company) */
|
||||||
|
GetString(buf, IsValidCompanyID(cid) ? STR_GAME_SAVELOAD_SPECTATOR_SAVEGAME : STR_4004, last);
|
||||||
SanitizeFilename(buf);
|
SanitizeFilename(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue