diff --git a/src/os/macosx/crashlog_osx.cpp b/src/os/macosx/crashlog_osx.cpp --- a/src/os/macosx/crashlog_osx.cpp +++ b/src/os/macosx/crashlog_osx.cpp @@ -13,6 +13,7 @@ #include "../../crashlog.h" #include "../../string_func.h" #include "../../gamelog.h" +#include "../../saveload/saveload.h" #include "macos.h" #include @@ -230,6 +231,13 @@ void CDECL HandleCrash(int signum) abort(); } + if (SaveloadCrashWithMissingNewGRFs()) { + ShowMacDialog("A serious fault condition occured in the game. The game will shut down.", + "As you loaded an savegame for which you do not have the required NewGRFs no crash information will be generated.\n", + "Quit"); + abort(); + } + CrashLogOSX log(signum); log.MakeCrashLog(); log.DisplayCrashDialog(); diff --git a/src/os/unix/crashlog_unix.cpp b/src/os/unix/crashlog_unix.cpp --- a/src/os/unix/crashlog_unix.cpp +++ b/src/os/unix/crashlog_unix.cpp @@ -13,6 +13,7 @@ #include "../../crashlog.h" #include "../../string_func.h" #include "../../gamelog.h" +#include "../../saveload/saveload.h" #include #include @@ -156,6 +157,13 @@ static void CDECL HandleCrash(int signum abort(); } + if (SaveloadCrashWithMissingNewGRFs()) { + printf("A serious fault condition occured in the game. The game will shut down.\n"); + printf("As you loaded an savegame for which you do not have the required NewGRFs\n"); + printf("no crash information will be generated.\n"); + abort(); + } + CrashLogUnix log(signum); log.MakeCrashLog(); diff --git a/src/os/windows/crashlog_win.cpp b/src/os/windows/crashlog_win.cpp --- a/src/os/windows/crashlog_win.cpp +++ b/src/os/windows/crashlog_win.cpp @@ -18,6 +18,7 @@ #include "../../fileio_func.h" #include "../../strings_func.h" #include "../../gamelog.h" +#include "../../saveload/saveload.h" #include #include @@ -378,6 +379,15 @@ static LONG WINAPI ExceptionHandler(EXCE ExitProcess(3); } + if (SaveloadCrashWithMissingNewGRFs()) { + static const TCHAR _saveload_crash[] = + _T("A serious fault condition occured in the game. The game will shut down.\n") + _T("As you loaded an savegame for which you do not have the required NewGRFs\n") + _T("no crash information will be generated.\n"); + MessageBox(NULL, _saveload_crash, _T("Fatal Application Failure"), MB_ICONERROR); + ExitProcess(3); + } + CrashLogWindows *log = new CrashLogWindows(ep); CrashLogWindows::current = log; log->FillCrashLog(log->crashlog, lastof(log->crashlog)); diff --git a/src/saveload/afterload.cpp b/src/saveload/afterload.cpp --- a/src/saveload/afterload.cpp +++ b/src/saveload/afterload.cpp @@ -311,6 +311,19 @@ static const GRFIdentifier *GetOverridde return c; } +/** Was the saveload crash because of missing NewGRFs? */ +static bool _saveload_crash_with_missing_newgrfs = false; + +/** + * Did loading the savegame cause a crash? If so, + * were NewGRFs missing? + * @return when the saveload crashed due to missing NewGRFs. + */ +bool SaveloadCrashWithMissingNewGRFs() +{ + return _saveload_crash_with_missing_newgrfs; +} + /** * Signal handler used to give a user a more useful report for crashes during * the savegame loading process; especially when there's problems with the @@ -342,11 +355,13 @@ static void CDECL HandleSavegameLoadCras char buf[40]; md5sumToString(buf, lastof(buf), replaced->md5sum); p += seprintf(p, lastof(buffer), "NewGRF %08X (checksum %s) not found.\n Loaded NewGRF \"%s\" with same GRF ID instead.\n", BSWAP32(c->grfid), buf, c->filename); + _saveload_crash_with_missing_newgrfs = true; } if (c->status == GCS_NOT_FOUND) { char buf[40]; md5sumToString(buf, lastof(buf), c->md5sum); p += seprintf(p, lastof(buffer), "NewGRF %08X (%s) not found; checksum %s.\n", BSWAP32(c->grfid), c->filename, buf); + _saveload_crash_with_missing_newgrfs = true; } } diff --git a/src/saveload/saveload.h b/src/saveload/saveload.h --- a/src/saveload/saveload.h +++ b/src/saveload/saveload.h @@ -324,6 +324,8 @@ void SlArray(void *array, size_t length, void SlObject(void *object, const SaveLoad *sld); bool SlObjectMember(void *object, const SaveLoad *sld); +bool SaveloadCrashWithMissingNewGRFs(); + extern char _savegame_format[8]; #endif /* SAVELOAD_H */