Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes missing fatal error messages #316

Merged
merged 3 commits into from
May 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/DETHRACE/pc-win95/win95sys.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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...");
Expand Down
2 changes: 2 additions & 0 deletions src/harness/include/harness/hooks.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 2 additions & 0 deletions src/harness/include/harness/win95_polyfill_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ typedef void* HANDLE_;

#define WM_QUIT 0x0012

#define MB_ICONERROR 0x00000010

typedef struct _MEMORYSTATUS_ {
uint32_t dwLength;
uint32_t dwMemoryLoad;
Expand Down
7 changes: 7 additions & 0 deletions src/harness/platforms/sdl_opengl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
4 changes: 3 additions & 1 deletion src/harness/win95/polyfill.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down