summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/lang/english.txt1
-rw-r--r--src/saveload.cpp22
2 files changed, 19 insertions, 4 deletions
diff --git a/src/lang/english.txt b/src/lang/english.txt
index 5b1224f9f..5875c7bf1 100644
--- a/src/lang/english.txt
+++ b/src/lang/english.txt
@@ -2017,6 +2017,7 @@ STR_4001_LOAD_GAME :{WHITE}Load Gam
STR_4002_SAVE :{BLACK}Save
STR_4003_DELETE :{BLACK}Delete
STR_4004 :{COMPANY}, {STRING1}
+STR_GAME_SAVELOAD_SPECTATOR_SAVEGAME :Spectator, {SKIP}{STRING1}
STR_4005_BYTES_FREE :{BLACK}{COMMA} megabyte{P "" s} free
STR_4006_UNABLE_TO_READ_DRIVE :{BLACK}Unable to read drive
STR_4007_GAME_SAVE_FAILED :{WHITE}Game Save Failed{}{STRING}
diff --git a/src/saveload.cpp b/src/saveload.cpp
index 2fb119e17..a5de05b06 100644
--- a/src/saveload.cpp
+++ b/src/saveload.cpp
@@ -1826,9 +1826,21 @@ void DoExitSave()
*/
void GenerateDefaultSaveName(char *buf, const char *last)
{
- /* Check if we are not a spectator who wants to generate a name..
- * Let's use the name of company #0 for now. */
- SetDParam(0, IsValidCompanyID(_local_company) ? _local_company : COMPANY_FIRST);
+ /* Check if we have a name for this map, which is the name of the first
+ * available company. When there's no company available we'll use
+ * '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) {
case 0: SetDParam(1, STR_JUST_DATE_LONG); break;
case 1: SetDParam(1, STR_JUST_DATE_TINY); break;
@@ -1836,7 +1848,9 @@ void GenerateDefaultSaveName(char *buf, const char *last)
default: NOT_REACHED();
}
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);
}