From 3a0d966ae408aecc0bdad3325c1cc75927d58e89 Mon Sep 17 00:00:00 2001 From: rubidium Date: Fri, 2 Jan 2009 22:49:43 +0000 Subject: (svn r14790) -Codechange: unify generation of default savegame/screenshot names (PhilSophus) --- src/saveload.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/saveload.cpp') diff --git a/src/saveload.cpp b/src/saveload.cpp index 968e48911..79c81731c 100644 --- a/src/saveload.cpp +++ b/src/saveload.cpp @@ -29,6 +29,8 @@ #include "functions.h" #include "core/endian_func.hpp" #include "vehicle_base.h" +#include "company_func.h" +#include "date_func.h" #include "autoreplace_base.h" #include "statusbar_gui.h" #include "fileio_func.h" @@ -1817,6 +1819,21 @@ void DoExitSave() SaveOrLoad("exit.sav", SL_SAVE, AUTOSAVE_DIR); } +/** + * Fill the buffer with the default name for a savegame *or* screenshot. + * @param buf the buffer to write to. + * @param last the last element in the buffer. + */ +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); + SetDParam(1, _date); + GetString(buf, STR_4004, last); + SanitizeFilename(buf); +} + #if 0 /** * Function to get the type of the savegame by looking at the file header. -- cgit v1.2.3-54-g00ecf