Show savegame version/info in load window if sl debug enabled

This commit is contained in:
Jonathan G Rennison 2023-11-18 13:24:25 +00:00
parent bea18ffc18
commit 9c29950956
3 changed files with 67 additions and 0 deletions

View File

@ -66,6 +66,7 @@ void LoadCheckData::Clear()
this->debug_config_data.clear();
this->sl_is_ext_version = false;
this->version_name.clear();
}
/** Load game/scenario with optional content download */
@ -490,6 +491,11 @@ public:
tr.bottom -= FONT_HEIGHT_NORMAL - 1;
if (tr.top > tr.bottom) return;
if (!_load_check_data.version_name.empty()) {
SetDParamStr(0, _load_check_data.version_name);
tr.top = DrawStringMultiLine(tr, STR_JUST_RAW_STRING, TC_GREEN);
}
if (!_load_check_data.checkable) {
/* Old savegame, no information available */
DrawString(tr, STR_SAVELOAD_DETAIL_NOT_AVAILABLE);

View File

@ -48,6 +48,7 @@ struct LoadCheckData {
std::string debug_config_data;
bool sl_is_ext_version = false;
std::string version_name;
LoadCheckData() : grfconfig(nullptr),
grf_compatibility(GLC_NOT_FOUND)

View File

@ -3478,6 +3478,8 @@ static SaveOrLoadResult DoLoad(LoadFilter *reader, bool load_check)
uint32 hdr[2];
if (_sl.lf->Read((byte*)hdr, sizeof(hdr)) != sizeof(hdr)) SlError(STR_GAME_SAVELOAD_ERROR_FILE_NOT_READABLE);
SaveLoadVersion original_sl_version = SL_MIN_VERSION;
/* see if we have any loader for this type. */
const SaveLoadFormat *fmt = _saveload_formats;
for (;;) {
@ -3518,6 +3520,8 @@ static SaveOrLoadResult DoLoad(LoadFilter *reader, bool load_check)
special_version = SlXvCheckSpecialSavegameVersions();
}
original_sl_version = _sl_version;
if (_sl_version >= SLV_SAVELOAD_LIST_LENGTH) {
if (_sl_is_ext_version) {
DEBUG(sl, 0, "Got an extended savegame version with a base version in the upstream mode range, giving up");
@ -3609,6 +3613,62 @@ static SaveOrLoadResult DoLoad(LoadFilter *reader, bool 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;
if (_debug_sl_level > 0) {
_load_check_data.version_name = stdstr_fmt("Version %d%s%s", original_sl_version, _sl_is_ext_version ? ", extended" : "", _sl_upstream_mode ? ", upstream mode" : "");
if (_sl_version != original_sl_version) {
_load_check_data.version_name += stdstr_fmt(" as %d", _sl_version);
}
if (_sl_xv_feature_versions[XSLFI_CHILLPP] >= SL_CHILLPP_232) {
_load_check_data.version_name += ", ChillPP v14.7";
} else if (_sl_xv_feature_versions[XSLFI_CHILLPP] > 0) {
_load_check_data.version_name += ", ChillPP v8";
}
if (_sl_xv_feature_versions[XSLFI_SPRINGPP] > 0) {
_load_check_data.version_name += ", SpringPP 2013 ";
switch (_sl_xv_feature_versions[XSLFI_SPRINGPP]) {
case 1:
_load_check_data.version_name += "v2.0.102";
break;
case 2:
_load_check_data.version_name += "v2.0.108";
break;
case 3:
_load_check_data.version_name += "v2.3.xxx"; // Note that this break in numbering is deliberate
break;
case 4:
_load_check_data.version_name += "v2.1.147"; // Note that this break in numbering is deliberate
break;
case 5:
_load_check_data.version_name += "v2.3.b3";
break;
case 6:
_load_check_data.version_name += "v2.3.b4";
break;
case 7:
_load_check_data.version_name += "v2.3.b5";
break;
case 8:
_load_check_data.version_name += "v2.4";
break;
default:
_load_check_data.version_name += "???";
break;
}
}
if (_sl_xv_feature_versions[XSLFI_JOKERPP] > 0) {
_load_check_data.version_name += ", JokerPP";
}
extern std::string _sl_xv_version_label;
extern SaveLoadVersion _sl_xv_upstream_version;
if (!_sl_xv_version_label.empty()) {
_load_check_data.version_name += stdstr_fmt(", labelled: %s", _sl_xv_version_label.c_str());
}
if (_sl_xv_upstream_version > 0) {
_load_check_data.version_name += stdstr_fmt(", upstream version: %d", _sl_xv_upstream_version);
}
}
} else {
GamelogStartAction(GLAT_LOAD);