MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / SlError

Function SlError

src/saveload/saveload.cpp:339–360  ·  view source on GitHub ↗

* Error handler. Sets everything up to show an error message and to clean * up the mess of a partial savegame load. * @param string The translatable error message to show. * @param extra_msg An extra error message coming from one of the APIs. * @note This function does never return as it throws an exception to * break out of all the saveload code. */

Source from the content-addressed store, hash-verified

337 * break out of all the saveload code.
338 */
339[[noreturn]] void SlError(StringID string, const std::string &extra_msg)
340{
341 /* Distinguish between loading into _load_check_data vs. normal save/load. */
342 if (_sl.action == SLA_LOAD_CHECK) {
343 _load_check_data.error = string;
344 _load_check_data.error_msg = extra_msg;
345 } else {
346 _sl.error_str = string;
347 _sl.extra_msg = extra_msg;
348 }
349
350 /* We have to nullptr all pointers here; we might be in a state where
351 * the pointers are actually filled with indices, which means that
352 * when we access them during cleaning the pool dereferences of
353 * those indices will be made with segmentation faults as result. */
354 if (_sl.action == SLA_LOAD || _sl.action == SLA_PTRS) SlNullPointers();
355
356 /* Logging could be active. */
357 _gamelog.StopAnyAction();
358
359 throw std::exception();
360}
361
362/**
363 * Error handler for corrupt savegames. Sets everything up to show the

Callers 15

WriteMethod · 0.85
FinishMethod · 0.85
AfterLoadGameFunction · 0.85
SlErrorCorruptFunction · 0.85
WriteMethod · 0.85
LZOLoadFilterMethod · 0.85
ReadMethod · 0.85
LZOSaveFilterMethod · 0.85
ZlibLoadFilterMethod · 0.85
ReadMethod · 0.85
ZlibSaveFilterMethod · 0.85
WriteLoopMethod · 0.85

Calls 3

SlNullPointersFunction · 0.85
exceptionClass · 0.85
StopAnyActionMethod · 0.80

Tested by

no test coverage detected