Saveload: Improve error messages for loading unsupported versions
This commit is contained in:
@@ -5167,6 +5167,10 @@ STR_GAME_SAVELOAD_ERROR_DATA_INTEGRITY_CHECK_FAILED :Data integrity
|
|||||||
STR_GAME_SAVELOAD_NOT_AVAILABLE :<not available>
|
STR_GAME_SAVELOAD_NOT_AVAILABLE :<not available>
|
||||||
STR_WARNING_LOADGAME_REMOVED_TRAMS :{WHITE}Game was saved in version without tram support. All trams have been removed
|
STR_WARNING_LOADGAME_REMOVED_TRAMS :{WHITE}Game was saved in version without tram support. All trams have been removed
|
||||||
|
|
||||||
|
STR_GAME_SAVELOAD_FROM_VERSION : from version {PUSH_COLOUR}{ORANGE}{RAW_STRING}{POP_COLOUR}{}
|
||||||
|
STR_GAME_SAVELOAD_ERROR_TOO_NEW_FEATURE_VERSION :Savegame{0:STRING1} has version {PUSH_COLOUR}{ORANGE}{2:NUM}{POP_COLOUR} of feature '{PUSH_COLOUR}{ORANGE}{1:RAW_STRING}{POP_COLOUR}', but the maximum supported version is {PUSH_COLOUR}{ORANGE}{3:NUM}{POP_COLOUR}
|
||||||
|
STR_GAME_SAVELOAD_ERROR_UNKNOWN_FEATURE :Savegame{0:STRING1} has an unknown feature '{PUSH_COLOUR}{ORANGE}{1:RAW_STRING}{POP_COLOUR}' (version: {PUSH_COLOUR}{ORANGE}{2:NUM}{POP_COLOUR}), which is not supported
|
||||||
|
|
||||||
STR_GAME_SAVELOAD_ERROR_HUGE_AIRPORTS_PRESENT :Savegame uses huge airports
|
STR_GAME_SAVELOAD_ERROR_HUGE_AIRPORTS_PRESENT :Savegame uses huge airports
|
||||||
STR_GAME_SAVELOAD_ERROR_HELI_OILRIG_BUG :Savegame has a helicopter on approach to a buggy oil rig
|
STR_GAME_SAVELOAD_ERROR_HELI_OILRIG_BUG :Savegame has a helicopter on approach to a buggy oil rig
|
||||||
|
|
||||||
|
|||||||
@@ -43,6 +43,8 @@
|
|||||||
#include "../timetable.h"
|
#include "../timetable.h"
|
||||||
#include "../map_func.h"
|
#include "../map_func.h"
|
||||||
#include "../rev.h"
|
#include "../rev.h"
|
||||||
|
#include "../strings_func.h"
|
||||||
|
#include "table/strings.h"
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
@@ -521,6 +523,14 @@ static void Load_SLXI()
|
|||||||
SLEG_END()
|
SLEG_END()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
auto version_error = [](StringID str, const char *feature, int64 p1, int64 p2) {
|
||||||
|
char buf[256];
|
||||||
|
int64 args_array[] = { _sl_xv_version_label.empty() ? STR_EMPTY : STR_GAME_SAVELOAD_FROM_VERSION, (int64)(size_t)_sl_xv_version_label.c_str(), (int64)(size_t)feature, p1, p2 };
|
||||||
|
StringParameters tmp_params(args_array);
|
||||||
|
GetStringWithArgs(buf, str, &tmp_params, lastof(buf));
|
||||||
|
SlError(STR_JUST_RAW_STRING, buf, false);
|
||||||
|
};
|
||||||
|
|
||||||
uint32 item_count = SlReadUint32();
|
uint32 item_count = SlReadUint32();
|
||||||
for (uint32 i = 0; i < item_count; i++) {
|
for (uint32 i = 0; i < item_count; i++) {
|
||||||
SlxiSubChunkFlags flags = static_cast<SlxiSubChunkFlags>(SlReadUint32());
|
SlxiSubChunkFlags flags = static_cast<SlxiSubChunkFlags>(SlReadUint32());
|
||||||
@@ -548,7 +558,7 @@ static void Load_SLXI()
|
|||||||
}
|
}
|
||||||
DEBUG(sl, 1, "SLXI chunk: too large version for feature: '%s', version: %d, max version: %d, ignoring", name_buffer, version, info->max_version);
|
DEBUG(sl, 1, "SLXI chunk: too large version for feature: '%s', version: %d, max version: %d, ignoring", name_buffer, version, info->max_version);
|
||||||
} else {
|
} else {
|
||||||
SlErrorCorruptFmt("SLXI chunk: too large version for feature: '%s', version: %d, max version: %d", name_buffer, version, info->max_version);
|
version_error(STR_GAME_SAVELOAD_ERROR_TOO_NEW_FEATURE_VERSION, name_buffer, version, info->max_version);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// success path :)
|
// success path :)
|
||||||
@@ -580,7 +590,7 @@ static void Load_SLXI()
|
|||||||
}
|
}
|
||||||
DEBUG(sl, 1, "SLXI chunk: unknown feature: '%s', version: %d, ignoring", name_buffer, version);
|
DEBUG(sl, 1, "SLXI chunk: unknown feature: '%s', version: %d, ignoring", name_buffer, version);
|
||||||
} else {
|
} else {
|
||||||
SlErrorCorruptFmt("SLXI chunk: unknown feature: %s, version: %d", name_buffer, version);
|
version_error(STR_GAME_SAVELOAD_ERROR_UNKNOWN_FEATURE, name_buffer, version, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user