diff --git a/src/openttd.cpp b/src/openttd.cpp index 0c8a6049a2..b69874d752 100644 --- a/src/openttd.cpp +++ b/src/openttd.cpp @@ -123,6 +123,7 @@ extern Company *DoStartupNewCompany(bool is_ai, CompanyID company = INVALID_COMP extern void OSOpenBrowser(const char *url); extern void RebuildTownCaches(bool cargo_update_required, bool old_map_position); extern void ShowOSErrorBox(const char *buf, bool system); +extern void NORETURN DoOSAbort(); extern std::string _config_file; bool _save_config = false; @@ -180,7 +181,7 @@ void CDECL error(const char *s, ...) /* Set the error message for the crash log and then invoke it. */ CrashLog::SetErrorMessage(buf); - abort(); + DoOSAbort(); } void CDECL assert_msg_error(int line, const char *file, const char *expr, const char *extra, const char *str, ...) @@ -203,7 +204,7 @@ void CDECL assert_msg_error(int line, const char *file, const char *expr, const /* Set the error message for the crash log and then invoke it. */ CrashLog::SetErrorMessage(buf); - abort(); + DoOSAbort(); } const char *assert_tile_info(uint32 tile) { diff --git a/src/os/macosx/macos.mm b/src/os/macosx/macos.mm index 90bcd6dc40..ac9fdb93a4 100644 --- a/src/os/macosx/macos.mm +++ b/src/os/macosx/macos.mm @@ -158,6 +158,11 @@ void ShowOSErrorBox(const char *buf, bool system) } } +void DoOSAbort() +{ + abort(); +} + void OSOpenBrowser(const char *url) { [ [ NSWorkspace sharedWorkspace ] openURL:[ NSURL URLWithString:[ NSString stringWithUTF8String:url ] ] ]; diff --git a/src/os/os2/os2.cpp b/src/os/os2/os2.cpp index 505b0ffb16..2558bd4dc0 100644 --- a/src/os/os2/os2.cpp +++ b/src/os/os2/os2.cpp @@ -170,6 +170,11 @@ void ShowOSErrorBox(const char *buf, bool system) WinTerminate(hab); } +void DoOSAbort() +{ + abort(); +} + int CDECL main(int argc, char *argv[]) { SetRandomSeed(time(nullptr)); diff --git a/src/os/unix/unix.cpp b/src/os/unix/unix.cpp index 3c486da878..a960726f60 100644 --- a/src/os/unix/unix.cpp +++ b/src/os/unix/unix.cpp @@ -233,6 +233,11 @@ void ShowOSErrorBox(const char *buf, bool system) fprintf(stderr, "Error: %s\n", buf); } } + +void NORETURN DoOSAbort() +{ + abort(); +} #endif #ifdef WITH_COCOA diff --git a/src/os/windows/win32.cpp b/src/os/windows/win32.cpp index a7f8810d8b..00acc6ca55 100644 --- a/src/os/windows/win32.cpp +++ b/src/os/windows/win32.cpp @@ -86,6 +86,11 @@ void ShowOSErrorBox(const char *buf, bool system) MessageBox(GetActiveWindow(), OTTD2FS(buf).c_str(), L"Error!", MB_ICONSTOP | MB_TASKMODAL); } +void NORETURN DoOSAbort() +{ + RaiseException(0xE1212012, 0, 0, nullptr); +} + void OSOpenBrowser(const char *url) { ShellExecute(GetActiveWindow(), L"open", OTTD2FS(url).c_str(), nullptr, nullptr, SW_SHOWNORMAL);