Fixes missing fatal error messages (#316)

* fixes missing fatal error messages
This commit is contained in:
Dethrace Engineering Department 2023-05-02 13:01:28 +12:00 committed by GitHub
parent 33f682ce82
commit c90f24d2e0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 16 additions and 3 deletions

View File

@ -341,7 +341,7 @@ void PDFatalError(char* pThe_str) {
LOG_TRACE("(\"%s\")", pThe_str);
dr_dprintf("FATAL ERROR: %s", pThe_str);
Win32FatalError(pThe_str, NULL);
Win32FatalError(pThe_str, "");
}
void Win32FatalError(char* pStr_1, char* pStr_2) {
@ -438,7 +438,7 @@ void PDShutdownSystem() {
SendMessageA_(HWND_BROADCAST, 0x18u, 1u, 0);
if (gWin32_show_fatal_error_message) {
dr_dprintf("Displaying fatal error...");
MessageBoxA_(0, gWin32_fatal_error_message, "Carmageddon Fatal Error", 0x10u);
MessageBoxA_(0, gWin32_fatal_error_message, "Carmageddon Fatal Error", MB_ICONERROR);
}
if (gWin32_hwnd) {
dr_dprintf("Destroying window...");

View File

@ -58,6 +58,8 @@ typedef struct tHarness_platform {
uint32_t (*GetTicks)(void);
// Swap window
void (*SwapWindow)(void);
// Show error message
int (*ShowErrorMessage)(void* window, char* text, char* caption);
} tHarness_platform;

View File

@ -21,6 +21,8 @@ typedef void* HANDLE_;
#define WM_QUIT 0x0012
#define MB_ICONERROR 0x00000010
typedef struct _MEMORYSTATUS_ {
uint32_t dwLength;
uint32_t dwMemoryLoad;

View File

@ -219,6 +219,12 @@ static void set_palette(PALETTEENTRY_* pal) {
GLRenderer_SetPalette((uint8_t*)pal);
}
int show_error_message(void* window, char* text, char* caption) {
fprintf(stderr, "%s", text);
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, caption, text, window);
return 0;
}
void Harness_Platform_Init(tHarness_platform* platform) {
platform->ProcessWindowMessages = get_and_handle_message;
platform->Sleep = SDL_Delay;
@ -232,6 +238,7 @@ void Harness_Platform_Init(tHarness_platform* platform) {
platform->GetMousePosition = get_mouse_position;
platform->GetMouseButtons = get_mouse_buttons;
platform->DestroyWindow = destroy_window;
platform->ShowErrorMessage = show_error_message;
platform->Renderer_BufferModel = GLRenderer_BufferModel;
platform->Renderer_BufferMaterial = GLRenderer_BufferMaterial;

View File

@ -187,7 +187,9 @@ int SendMessageA_(void* hWnd, unsigned int Msg, unsigned int wParam, long lParam
}
int MessageBoxA_(void* hWnd, char* lpText, char* lpCaption, unsigned int uType) {
return 0;
// only ever used for errors
assert(uType == MB_ICONERROR);
return gHarness_platform.ShowErrorMessage(hWnd, lpText, lpCaption);
}
int DestroyWindow_(void* hWnd) {