diff options
Diffstat (limited to 'src/saveload')
-rw-r--r-- | src/saveload/saveload.cpp | 19 | ||||
-rw-r--r-- | src/saveload/saveload.h | 1 |
2 files changed, 20 insertions, 0 deletions
diff --git a/src/saveload/saveload.cpp b/src/saveload/saveload.cpp index 9be9506b1..bff85dfc6 100644 --- a/src/saveload/saveload.cpp +++ b/src/saveload/saveload.cpp @@ -350,6 +350,25 @@ void NORETURN SlErrorCorrupt(const char *msg) SlError(STR_GAME_SAVELOAD_ERROR_BROKEN_SAVEGAME, msg); } +/** + * Issue an SlErrorCorrupt with a format string. + * @param format format string + * @param ... arguments to format string + * @note This function does never return as it throws an exception to + * break out of all the saveload code. + */ +void NORETURN SlErrorCorruptFmt(const char *format, ...) +{ + va_list ap; + char msg[256]; + + va_start(ap, format); + vseprintf(msg, lastof(msg), format, ap); + va_end(ap); + + SlErrorCorrupt(msg); +} + typedef void (*AsyncSaveFinishProc)(); ///< Callback for when the savegame loading is finished. static AsyncSaveFinishProc _async_save_finish = NULL; ///< Callback to call when the savegame loading is finished. diff --git a/src/saveload/saveload.h b/src/saveload/saveload.h index e5e2e1fa2..ad6b76e05 100644 --- a/src/saveload/saveload.h +++ b/src/saveload/saveload.h @@ -836,6 +836,7 @@ void SlObject(void *object, const SaveLoad *sld); bool SlObjectMember(void *object, const SaveLoad *sld); void NORETURN SlError(StringID string, const char *extra_msg = NULL); void NORETURN SlErrorCorrupt(const char *msg); +void NORETURN SlErrorCorruptFmt(const char *format, ...); bool SaveloadCrashWithMissingNewGRFs(); |