Merge branch 'master' into jgrpp-beta

# Conflicts:
#	src/console_cmds.cpp
#	src/debug.cpp
#	src/lang/vietnamese.txt
#	src/network/core/address.cpp
#	src/network/core/address.h
#	src/network/core/config.h
#	src/network/core/os_abstraction.cpp
#	src/network/core/os_abstraction.h
#	src/network/core/tcp_listen.h
#	src/network/core/udp.cpp
#	src/network/core/udp.h
#	src/network/network.cpp
#	src/network/network_client.cpp
#	src/network/network_gamelist.cpp
#	src/network/network_server.cpp
#	src/network/network_udp.cpp
#	src/newgrf.cpp
#	src/openttd.cpp
#	src/saveload/saveload.h
#	src/settings.cpp
#	src/settings_table.cpp
#	src/settings_type.h
#	src/table/settings/network_settings.ini
This commit is contained in:
Jonathan G Rennison
2021-11-02 00:51:54 +00:00
124 changed files with 3050 additions and 1274 deletions

View File

@@ -3635,6 +3635,40 @@ SaveOrLoadResult SaveOrLoad(const std::string &filename, SaveLoadOperation fop,
}
}
/**
* Create an autosave or netsave.
* @param counter A reference to the counter variable to be used for rotating the file name.
* @param netsave Indicates if this is a regular autosave or a netsave.
*/
void DoAutoOrNetsave(int &counter, bool netsave)
{
char buf[MAX_PATH];
if (_settings_client.gui.keep_all_autosave) {
GenerateDefaultSaveName(buf, lastof(buf));
if (!netsave) {
strecat(buf, ".sav", lastof(buf));
} else {
strecat(buf, "-netsave.sav", lastof(buf));
}
} else {
/* Generate a savegame name and number according to _settings_client.gui.max_num_autosaves. */
if (!netsave) {
seprintf(buf, lastof(buf), "autosave%d.sav", counter);
} else {
seprintf(buf, lastof(buf), "netsave%d.sav", counter);
}
if (++counter >= _settings_client.gui.max_num_autosaves) counter = 0;
}
DEBUG(sl, 2, "Autosaving to '%s'", buf);
if (SaveOrLoad(buf, SLO_SAVE, DFT_GAME_FILE, AUTOSAVE_DIR, !netsave, SMF_ZSTD_OK) != SL_OK) {
ShowErrorMessage(STR_ERROR_AUTOSAVE_FAILED, INVALID_STRING_ID, WL_ERROR);
}
}
/** Do a save when exiting the game (_settings_client.gui.autosave_on_exit) */
void DoExitSave()
{