Skip to content

Commit c90f24d

Browse files
Fixes missing fatal error messages (#316)
* fixes missing fatal error messages
1 parent 33f682c commit c90f24d

File tree

5 files changed

+16
-3
lines changed

5 files changed

+16
-3
lines changed

src/DETHRACE/pc-win95/win95sys.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ void PDFatalError(char* pThe_str) {
341341
LOG_TRACE("(\"%s\")", pThe_str);
342342

343343
dr_dprintf("FATAL ERROR: %s", pThe_str);
344-
Win32FatalError(pThe_str, NULL);
344+
Win32FatalError(pThe_str, "");
345345
}
346346

347347
void Win32FatalError(char* pStr_1, char* pStr_2) {
@@ -438,7 +438,7 @@ void PDShutdownSystem() {
438438
SendMessageA_(HWND_BROADCAST, 0x18u, 1u, 0);
439439
if (gWin32_show_fatal_error_message) {
440440
dr_dprintf("Displaying fatal error...");
441-
MessageBoxA_(0, gWin32_fatal_error_message, "Carmageddon Fatal Error", 0x10u);
441+
MessageBoxA_(0, gWin32_fatal_error_message, "Carmageddon Fatal Error", MB_ICONERROR);
442442
}
443443
if (gWin32_hwnd) {
444444
dr_dprintf("Destroying window...");

src/harness/include/harness/hooks.h

+2
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ typedef struct tHarness_platform {
5858
uint32_t (*GetTicks)(void);
5959
// Swap window
6060
void (*SwapWindow)(void);
61+
// Show error message
62+
int (*ShowErrorMessage)(void* window, char* text, char* caption);
6163

6264
} tHarness_platform;
6365

src/harness/include/harness/win95_polyfill_defs.h

+2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ typedef void* HANDLE_;
2121

2222
#define WM_QUIT 0x0012
2323

24+
#define MB_ICONERROR 0x00000010
25+
2426
typedef struct _MEMORYSTATUS_ {
2527
uint32_t dwLength;
2628
uint32_t dwMemoryLoad;

src/harness/platforms/sdl_opengl.c

+7
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,12 @@ static void set_palette(PALETTEENTRY_* pal) {
219219
GLRenderer_SetPalette((uint8_t*)pal);
220220
}
221221

222+
int show_error_message(void* window, char* text, char* caption) {
223+
fprintf(stderr, "%s", text);
224+
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, caption, text, window);
225+
return 0;
226+
}
227+
222228
void Harness_Platform_Init(tHarness_platform* platform) {
223229
platform->ProcessWindowMessages = get_and_handle_message;
224230
platform->Sleep = SDL_Delay;
@@ -232,6 +238,7 @@ void Harness_Platform_Init(tHarness_platform* platform) {
232238
platform->GetMousePosition = get_mouse_position;
233239
platform->GetMouseButtons = get_mouse_buttons;
234240
platform->DestroyWindow = destroy_window;
241+
platform->ShowErrorMessage = show_error_message;
235242

236243
platform->Renderer_BufferModel = GLRenderer_BufferModel;
237244
platform->Renderer_BufferMaterial = GLRenderer_BufferMaterial;

src/harness/win95/polyfill.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,9 @@ int SendMessageA_(void* hWnd, unsigned int Msg, unsigned int wParam, long lParam
187187
}
188188

189189
int MessageBoxA_(void* hWnd, char* lpText, char* lpCaption, unsigned int uType) {
190-
return 0;
190+
// only ever used for errors
191+
assert(uType == MB_ICONERROR);
192+
return gHarness_platform.ShowErrorMessage(hWnd, lpText, lpCaption);
191193
}
192194

193195
int DestroyWindow_(void* hWnd) {

0 commit comments

Comments
 (0)