diff --git a/src/fios.h b/src/fios.h index 999632d313..bbe0b08b03 100644 --- a/src/fios.h +++ b/src/fios.h @@ -51,6 +51,8 @@ struct LoadCheckData { std::string debug_log_data; std::string debug_config_data; + bool sl_is_ext_version = false; + LoadCheckData() : error_data(nullptr), grfconfig(nullptr), grf_compatibility(GLC_NOT_FOUND), gamelog_action(nullptr), gamelog_actions(0) { diff --git a/src/fios_gui.cpp b/src/fios_gui.cpp index 5f66345797..0fa640130f 100644 --- a/src/fios_gui.cpp +++ b/src/fios_gui.cpp @@ -27,6 +27,7 @@ #include "core/geometry_func.hpp" #include "gamelog.h" #include "stringfilter_type.h" +#include "gamelog.h" #include "widgets/fios_widget.h" @@ -68,6 +69,8 @@ void LoadCheckData::Clear() this->debug_log_data.clear(); this->debug_config_data.clear(); + + this->sl_is_ext_version = false; } /** Load game/scenario with optional content download */ @@ -814,7 +817,21 @@ public: /* Show a caption box asking whether the user is sure to overwrite the save */ ShowQuery(STR_SAVELOAD_OVERWRITE_TITLE_DIFFERENT_ID, STR_SAVELOAD_OVERWRITE_WARNING_DIFFERENT_ID, this, SaveLoadWindow::SaveGameConfirmationCallback); } else if (_settings_client.gui.savegame_overwrite_confirm >= (known_id ? 3 : 2) && file_exists) { - ShowQuery(STR_SAVELOAD_OVERWRITE_TITLE, STR_SAVELOAD_OVERWRITE_WARNING, this, SaveLoadWindow::SaveGameConfirmationCallback); + if (!_load_check_data.sl_is_ext_version) { + const char *version = GamelogGetLastRevision(_load_check_data.gamelog_action, _load_check_data.gamelog_actions); + + SetDParam(0, STR_SAVELOAD_OVERWRITE_TITLE); + std::string caption = GetString(STR_SAVELOAD_OVERWRITE_TITLE_DIFFERENT_VERSION_SUFFIX); + + SetDParam(0, STR_SAVELOAD_OVERWRITE_WARNING); + SetDParam(1, (version != nullptr) ? STR_SAVELOAD_OVERWRITE_WARNING_VERSION_NAME : STR_EMPTY); + SetDParamStr(2, version); + std::string message = GetString(STR_SAVELOAD_OVERWRITE_WARNING_DIFFERENT_VERSION_SUFFIX); + + ShowQuery(std::move(caption), std::move(message), this, SaveLoadWindow::SaveGameConfirmationCallback); + } else { + ShowQuery(STR_SAVELOAD_OVERWRITE_TITLE, STR_SAVELOAD_OVERWRITE_WARNING, this, SaveLoadWindow::SaveGameConfirmationCallback); + } } else { _switch_mode = SM_SAVE_GAME; } diff --git a/src/gamelog.cpp b/src/gamelog.cpp index c0d2f95857..99aa178c20 100644 --- a/src/gamelog.cpp +++ b/src/gamelog.cpp @@ -809,3 +809,22 @@ void GamelogInfo(LoggedAction *gamelog_action, uint gamelog_actions, uint32 *las } } } + +const char *GamelogGetLastRevision(const LoggedAction *gamelog_action, uint gamelog_actions) +{ + for (uint i = gamelog_actions; i > 0; i--) { + const LoggedAction &la = gamelog_action[i - 1]; + const LoggedChange *lcend = &(la.change[la.changes]); + for (const LoggedChange *lc = la.change; lc != lcend; lc++) { + switch (lc->ct) { + case GLCT_REVISION: + return lc->revision.text; + break; + + default: + break; + } + } + } + return nullptr; +} diff --git a/src/gamelog.h b/src/gamelog.h index 43cd84f3a2..f9ab0a47e0 100644 --- a/src/gamelog.h +++ b/src/gamelog.h @@ -62,5 +62,6 @@ void GamelogTestMode(); bool GamelogGRFBugReverse(uint32 grfid, uint16 internal_id); void GamelogInfo(struct LoggedAction *gamelog_action, uint gamelog_actions, uint32 *last_ottd_rev, byte *ever_modified, bool *removed_newgrfs); +const char *GamelogGetLastRevision(const struct LoggedAction *gamelog_action, uint gamelog_actions); #endif /* GAMELOG_H */ diff --git a/src/lang/extra/english.txt b/src/lang/extra/english.txt index 69cbec1e9c..24035ba5ae 100644 --- a/src/lang/extra/english.txt +++ b/src/lang/extra/english.txt @@ -1198,7 +1198,10 @@ STR_LAI_BRIDGE_DESCRIPTION_RAILROAD_SIGNAL :Railway bridge STR_SAVELOAD_UNKNOWN_ID :{YELLOW}This file may be from a different game. STR_SAVELOAD_DIFFERENT_ID :{YELLOW}This file is from a different game. STR_SAVELOAD_OVERWRITE_TITLE_DIFFERENT_ID :{WHITE}Overwrite File (Different Game) +STR_SAVELOAD_OVERWRITE_TITLE_DIFFERENT_VERSION_SUFFIX :{STRING} (Different Version) STR_SAVELOAD_OVERWRITE_WARNING_DIFFERENT_ID :{YELLOW}Are you sure you want to overwrite the existing file?{}{}The file is from a different game. +STR_SAVELOAD_OVERWRITE_WARNING_DIFFERENT_VERSION_SUFFIX :{STRING}{}{}The file is from a different version{STRING1}.{}If overwritten the file will no longer be readable by the original version. +STR_SAVELOAD_OVERWRITE_WARNING_VERSION_NAME : ({RAW_STRING}) STR_MAPGEN_SNOW_LINE_HEIGHT :{BLACK}Snow line height: STR_MAPGEN_SNOW_LINE_UP :{BLACK}Move the snow line height one up diff --git a/src/saveload/saveload.cpp b/src/saveload/saveload.cpp index 5b38b11a4d..5ec0df9168 100644 --- a/src/saveload/saveload.cpp +++ b/src/saveload/saveload.cpp @@ -3587,6 +3587,7 @@ static SaveOrLoadResult DoLoad(LoadFilter *reader, bool load_check) if (load_check) { /* The only part from AfterLoadGame() we need */ if (_load_check_data.want_grf_compatibility) _load_check_data.grf_compatibility = IsGoodGRFConfigList(_load_check_data.grfconfig); + _load_check_data.sl_is_ext_version = _sl_is_ext_version; } else { GamelogStartAction(GLAT_LOAD);