diff --git a/src/common/engine/d_event.cpp b/src/common/engine/d_event.cpp index 9c612cf3dc..effb5dc3aa 100644 --- a/src/common/engine/d_event.cpp +++ b/src/common/engine/d_event.cpp @@ -137,7 +137,7 @@ void D_PostEvent(event_t* ev) { return; } - if (sysCallbacks && sysCallbacks->DispatchEvent && sysCallbacks->DispatchEvent(ev)) + if (sysCallbacks.DispatchEvent && sysCallbacks.DispatchEvent(ev)) return; events[eventhead] = *ev; diff --git a/src/common/engine/i_interface.cpp b/src/common/engine/i_interface.cpp index 90d0df385d..613c3d5deb 100644 --- a/src/common/engine/i_interface.cpp +++ b/src/common/engine/i_interface.cpp @@ -1,7 +1,7 @@ #include "i_interface.h" // Some global engine variables taken out of the backend code. -SystemCallbacks *sysCallbacks; +SystemCallbacks sysCallbacks; FString endoomName; bool batchrun; float menuBlurAmount; diff --git a/src/common/engine/i_interface.h b/src/common/engine/i_interface.h index 7207df14f4..80cc3b1e94 100644 --- a/src/common/engine/i_interface.h +++ b/src/common/engine/i_interface.h @@ -24,7 +24,7 @@ struct SystemCallbacks bool (*DispatchEvent)(event_t* ev); }; -extern SystemCallbacks *sysCallbacks; +extern SystemCallbacks sysCallbacks; struct WadStuff { diff --git a/src/common/engine/i_net.cpp b/src/common/engine/i_net.cpp index d20673dfb3..94388656f1 100644 --- a/src/common/engine/i_net.cpp +++ b/src/common/engine/i_net.cpp @@ -162,7 +162,7 @@ uint8_t TransmitBuffer[TRANSMIT_SIZE]; FString GetPlayerName(int num) { - if (sysCallbacks && sysCallbacks->GetPlayerName) return sysCallbacks->GetPlayerName(sendplayer[num]); + if (sysCallbacks.GetPlayerName) return sysCallbacks.GetPlayerName(sendplayer[num]); else return FStringf("Player %d", sendplayer[num] + 1); } diff --git a/src/common/platform/posix/cocoa/i_input.mm b/src/common/platform/posix/cocoa/i_input.mm index a9b9443a0a..6782eca785 100644 --- a/src/common/platform/posix/cocoa/i_input.mm +++ b/src/common/platform/posix/cocoa/i_input.mm @@ -73,7 +73,7 @@ size_t s_skipMouseMoves; void CheckGUICapture() { - bool wantCapt = sysCallbacks && sysCallbacks->WantGuiCapture && sysCallbacks->WantGuiCapture(); + bool wantCapt = sysCallbacks.WantGuiCapture && sysCallbacks.WantGuiCapture(); if (wantCapt != GUICapture) { @@ -149,7 +149,7 @@ void CheckNativeMouse() } else { - bool captureModeInGame = sysCallbacks && sysCallbacks->CaptureModeInGame && sysCallbacks->CaptureModeInGame(); + bool captureModeInGame = sysCallbacks.CaptureModeInGame && sysCallbacks.CaptureModeInGame(); wantNative = (!m_use_mouse || MENU_WaitKey != menuactive) && (!captureModeInGame || GUICapture); } @@ -161,7 +161,7 @@ void CheckNativeMouse() && (MENU_On == menuactive || MENU_OnNoPause == menuactive); } - if (!wantNative && sysCallbacks && sysCallbacks->WantNativeMouse && sysCallbacks->WantNativeMouse()) + if (!wantNative && sysCallbacks.WantNativeMouse && sysCallbacks.WantNativeMouse()) wantNative = true; I_SetNativeMouse(wantNative); diff --git a/src/common/platform/posix/sdl/i_input.cpp b/src/common/platform/posix/sdl/i_input.cpp index 1ad9fa65d6..a102b38a89 100644 --- a/src/common/platform/posix/sdl/i_input.cpp +++ b/src/common/platform/posix/sdl/i_input.cpp @@ -165,7 +165,7 @@ static const TMap KeyScanToDIK(InitKeyScanMap()); static void I_CheckGUICapture () { - bool wantCapt = sysCallbacks && sysCallbacks->WantGuiCapture && sysCallbacks->WantGuiCapture(); + bool wantCapt = sysCallbacks.WantGuiCapture && sysCallbacks.WantGuiCapture(); if (wantCapt != GUICapture) { @@ -206,10 +206,10 @@ static void I_CheckNativeMouse () { bool focus = SDL_GetKeyboardFocus() != NULL; - bool captureModeInGame = sysCallbacks && sysCallbacks->CaptureModeInGame && sysCallbacks->CaptureModeInGame(); + bool captureModeInGame = sysCallbacks.CaptureModeInGame && sysCallbacks.CaptureModeInGame(); bool wantNative = !focus || (!use_mouse || GUICapture || !captureModeInGame); - if (!wantNative && sysCallbacks && sysCallbacks->WantNativeMouse && sysCallbacks->WantNativeMouse()) + if (!wantNative && sysCallbacks.WantNativeMouse && sysCallbacks.WantNativeMouse()) wantNative = true; if (wantNative != NativeMouse) diff --git a/src/common/platform/posix/sdl/i_main.cpp b/src/common/platform/posix/sdl/i_main.cpp index 7fc179a510..a984721fc0 100644 --- a/src/common/platform/posix/sdl/i_main.cpp +++ b/src/common/platform/posix/sdl/i_main.cpp @@ -87,7 +87,7 @@ FArgs *Args; static int GetCrashInfo (char *buffer, char *end) { - if (sysCallbacks && sysCallbacks->CrashInfo) sysCallbacks->CrashInfo(buffer, end - buffer, "\n"); + if (sysCallbacks.CrashInfo) sysCallbacks.CrashInfo(buffer, end - buffer, "\n"); return strlen(buffer); } diff --git a/src/common/platform/win32/i_input.cpp b/src/common/platform/win32/i_input.cpp index c9cc136092..1b49f5680a 100644 --- a/src/common/platform/win32/i_input.cpp +++ b/src/common/platform/win32/i_input.cpp @@ -147,7 +147,7 @@ extern int chatmodeon; static void I_CheckGUICapture () { - bool wantCapt = sysCallbacks && sysCallbacks->WantGuiCapture && sysCallbacks->WantGuiCapture(); + bool wantCapt = sysCallbacks.WantGuiCapture && sysCallbacks.WantGuiCapture(); if (wantCapt != GUICapture) { @@ -394,7 +394,7 @@ LRESULT CALLBACK WndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) return result; } - if (message == WM_LBUTTONDOWN && sysCallbacks && sysCallbacks->WantLeftButton() && sysCallbacks->WantLeftButton()) + if (message == WM_LBUTTONDOWN && sysCallbacks.WantLeftButton() && sysCallbacks.WantLeftButton()) { if (GUIWndProcHook(hWnd, message, wParam, lParam, &result)) { @@ -504,7 +504,7 @@ LRESULT CALLBACK WndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { SetPriorityClass (GetCurrentProcess (), INGAME_PRIORITY_CLASS); } - else if (!noidle && !(sysCallbacks && sysCallbacks->NetGame && sysCallbacks->NetGame())) + else if (!noidle && !(sysCallbacks.NetGame && sysCallbacks.NetGame())) { SetPriorityClass (GetCurrentProcess (), IDLE_PRIORITY_CLASS); } @@ -749,7 +749,7 @@ void I_StartTic () BlockMouseMove--; buttonMap.ResetButtonTriggers (); I_CheckGUICapture (); - EventHandlerResultForNativeMouse = sysCallbacks && sysCallbacks->WantNativeMouse && sysCallbacks->WantNativeMouse(); + EventHandlerResultForNativeMouse = sysCallbacks.WantNativeMouse && sysCallbacks.WantNativeMouse(); I_CheckNativeMouse (false, EventHandlerResultForNativeMouse); I_GetEvent (); } diff --git a/src/common/platform/win32/i_main.cpp b/src/common/platform/win32/i_main.cpp index f0bacc0b78..6e1b2ea33f 100644 --- a/src/common/platform/win32/i_main.cpp +++ b/src/common/platform/win32/i_main.cpp @@ -1108,7 +1108,7 @@ LONG WINAPI CatchAllExceptions (LPEXCEPTION_POINTERS info) char *custominfo = (char *)HeapAlloc (GetProcessHeap(), 0, 16384); CrashPointers = *info; - if (sysCallbacks && sysCallbacks->CrashInfo && custominfo) sysCallbacks->CrashInfo(custominfo, 16384, "\r\n"); + if (sysCallbacks.CrashInfo && custominfo) sysCallbacks.CrashInfo(custominfo, 16384, "\r\n"); CreateCrashLog (custominfo, (DWORD)strlen(custominfo), ConWindow); // If the main thread crashed, then make it clean up after itself. diff --git a/src/common/platform/win32/i_mouse.cpp b/src/common/platform/win32/i_mouse.cpp index b4a15a4944..a3042236a5 100644 --- a/src/common/platform/win32/i_mouse.cpp +++ b/src/common/platform/win32/i_mouse.cpp @@ -269,7 +269,7 @@ void I_CheckNativeMouse(bool preferNative, bool eventhandlerresult) else { bool pauseState = false; - bool captureModeInGame = sysCallbacks && sysCallbacks->CaptureModeInGame && sysCallbacks->CaptureModeInGame(); + bool captureModeInGame = sysCallbacks.CaptureModeInGame && sysCallbacks.CaptureModeInGame(); want_native = ((!m_use_mouse || menuactive != MENU_WaitKey) && (!captureModeInGame || GUICapture)); } diff --git a/src/common/platform/win32/st_start_util.cpp b/src/common/platform/win32/st_start_util.cpp index 047aa83108..8c6074863e 100644 --- a/src/common/platform/win32/st_start_util.cpp +++ b/src/common/platform/win32/st_start_util.cpp @@ -396,8 +396,8 @@ static const int StrifeStartupPicSizes[4 + 2 + 1] = static void ST_Sound(const char* sndname) { - if (sysCallbacks && sysCallbacks->PlayStartupSound) - sysCallbacks->PlayStartupSound(sndname); + if (sysCallbacks.PlayStartupSound) + sysCallbacks.PlayStartupSound(sndname); } //========================================================================== diff --git a/src/common/rendering/gl/gl_samplers.cpp b/src/common/rendering/gl/gl_samplers.cpp index efe4204746..b4110d5f05 100644 --- a/src/common/rendering/gl/gl_samplers.cpp +++ b/src/common/rendering/gl/gl_samplers.cpp @@ -119,7 +119,7 @@ void FSamplerManager::SetTextureFilterMode() glBindSampler(i, 0); } - int filter = sysCallbacks && sysCallbacks->DisableTextureFilter && sysCallbacks->DisableTextureFilter() ? 0 : gl_texture_filter; + int filter = sysCallbacks.DisableTextureFilter && sysCallbacks.DisableTextureFilter() ? 0 : gl_texture_filter; for (int i = 0; i < 4; i++) { diff --git a/src/common/rendering/hwrenderer/data/hw_clock.cpp b/src/common/rendering/hwrenderer/data/hw_clock.cpp index 84576875bb..e9affdbe69 100644 --- a/src/common/rendering/hwrenderer/data/hw_clock.cpp +++ b/src/common/rendering/hwrenderer/data/hw_clock.cpp @@ -166,7 +166,7 @@ void CheckBench() FString compose; - if (sysCallbacks && sysCallbacks->GetLocationDescription) compose = sysCallbacks->GetLocationDescription(); + if (sysCallbacks.GetLocationDescription) compose = sysCallbacks.GetLocationDescription(); AppendRenderStats(compose); AppendRenderTimes(compose); diff --git a/src/common/rendering/hwrenderer/data/hw_vrmodes.cpp b/src/common/rendering/hwrenderer/data/hw_vrmodes.cpp index 17bfefaef9..bde88b5a70 100644 --- a/src/common/rendering/hwrenderer/data/hw_vrmodes.cpp +++ b/src/common/rendering/hwrenderer/data/hw_vrmodes.cpp @@ -61,7 +61,7 @@ static VRMode vrmi_checker = { 2, isqrt2, isqrt2, 1.f,{ { -.5f, 1.f },{ .5f, 1.f const VRMode *VRMode::GetVRMode(bool toscreen) { #ifdef VR3D_ENABLED - int mode = !toscreen || (sysCallbacks && sysCallbacks->DisableTextureFilter && sysCallbacks->DisableTextureFilter()) ? 0 : vr_mode; + int mode = !toscreen || (sysCallbacks.DisableTextureFilter && sysCallbacks.DisableTextureFilter()) ? 0 : vr_mode; switch (mode) { diff --git a/src/common/rendering/r_videoscale.cpp b/src/common/rendering/r_videoscale.cpp index dee86723ed..1f5a7bb385 100644 --- a/src/common/rendering/r_videoscale.cpp +++ b/src/common/rendering/r_videoscale.cpp @@ -107,7 +107,7 @@ namespace static bool lastspecialUI = false; bool isInActualMenu = false; - bool specialUI = sysCallbacks && (!sysCallbacks->IsSpecialUI || sysCallbacks->IsSpecialUI()); + bool specialUI = (!sysCallbacks.IsSpecialUI || sysCallbacks.IsSpecialUI()); if (specialUI == lastspecialUI) return; diff --git a/src/common/rendering/v_framebuffer.cpp b/src/common/rendering/v_framebuffer.cpp index 4d55989c33..747a37c6e7 100644 --- a/src/common/rendering/v_framebuffer.cpp +++ b/src/common/rendering/v_framebuffer.cpp @@ -200,7 +200,7 @@ void DFrameBuffer::SetViewportRects(IntRect *bounds) mScreenViewport.height = screenHeight; // Viewport for the 3D scene - if (sysCallbacks && sysCallbacks->GetSceneRect) mSceneViewport = sysCallbacks->GetSceneRect(); + if (sysCallbacks.GetSceneRect) mSceneViewport = sysCallbacks.GetSceneRect(); else mSceneViewport = mScreenViewport; // Scale viewports to fit letterbox diff --git a/src/common/rendering/v_video.cpp b/src/common/rendering/v_video.cpp index 435768c981..3cf9f7bb1a 100644 --- a/src/common/rendering/v_video.cpp +++ b/src/common/rendering/v_video.cpp @@ -116,8 +116,8 @@ CUSTOM_CVAR(Int, uiscale, 0, CVAR_ARCHIVE | CVAR_NOINITCALL) self = 0; return; } - if (sysCallbacks && sysCallbacks->OnScreenSizeChanged) - sysCallbacks->OnScreenSizeChanged(); + if (sysCallbacks.OnScreenSizeChanged) + sysCallbacks.OnScreenSizeChanged(); setsizeneeded = true; } @@ -294,8 +294,8 @@ void V_OutputResized (int width, int height) twod->End(); setsizeneeded = true; C_NewModeAdjust(); - if (sysCallbacks && sysCallbacks->OnScreenSizeChanged) - sysCallbacks->OnScreenSizeChanged(); + if (sysCallbacks.OnScreenSizeChanged) + sysCallbacks.OnScreenSizeChanged(); } bool IVideo::SetResolution () @@ -392,8 +392,8 @@ void V_Init2() CUSTOM_CVAR (Int, vid_aspect, 0, CVAR_GLOBALCONFIG|CVAR_ARCHIVE) { setsizeneeded = true; - if (sysCallbacks && sysCallbacks->OnScreenSizeChanged) - sysCallbacks->OnScreenSizeChanged(); + if (sysCallbacks.OnScreenSizeChanged) + sysCallbacks.OnScreenSizeChanged(); } DEFINE_ACTION_FUNCTION(_Screen, GetAspectRatio) diff --git a/src/common/rendering/vulkan/textures/vk_samplers.cpp b/src/common/rendering/vulkan/textures/vk_samplers.cpp index 2a616e2931..adc6dd2b41 100644 --- a/src/common/rendering/vulkan/textures/vk_samplers.cpp +++ b/src/common/rendering/vulkan/textures/vk_samplers.cpp @@ -81,7 +81,7 @@ void VkSamplerManager::SetTextureFilterMode() void VkSamplerManager::Create() { - int filter = sysCallbacks && sysCallbacks->DisableTextureFilter && sysCallbacks->DisableTextureFilter()? 0 : gl_texture_filter; + int filter = sysCallbacks.DisableTextureFilter && sysCallbacks.DisableTextureFilter()? 0 : gl_texture_filter; for (int i = CLAMP_NONE; i <= CLAMP_XY; i++) { diff --git a/src/d_main.cpp b/src/d_main.cpp index 8dab5f93f1..22c5217ab1 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -3057,8 +3057,7 @@ static int D_DoomMain_Internal (void) }; GStrings.SetCallbacks(&stblcb); - static SystemCallbacks syscb = - { + sysCallbacks = { System_WantGuiCapture, System_WantLeftButton, System_NetGame, @@ -3075,7 +3074,7 @@ static int D_DoomMain_Internal (void) System_GetPlayerName, System_DispatchEvent, }; - sysCallbacks = &syscb; + std::set_new_handler(NewFailure); const char *batchout = Args->CheckValue("-errorlog"); diff --git a/src/menu/menu.cpp b/src/menu/menu.cpp index 2780826f99..10ffd54111 100644 --- a/src/menu/menu.cpp +++ b/src/menu/menu.cpp @@ -747,7 +747,7 @@ void M_Drawer (void) if (!CurrentMenu->DontBlur) screen->BlurScene(menuBlurAmount); if (!CurrentMenu->DontDim) { - if (sysCallbacks && sysCallbacks->MenuDim) sysCallbacks->MenuDim(); + if (sysCallbacks.MenuDim) sysCallbacks.MenuDim(); } CurrentMenu->CallDrawer(); }