From c639f232f9dcd63790f1ba5a81d2fe9aa9d7cf6d Mon Sep 17 00:00:00 2001 From: /dev/urandom Date: Thu, 1 Jun 2017 02:13:39 +0200 Subject: [PATCH] [Exception] Fix crash caused by drawing DEBUG text when no graphics initialized. --- src/Components/Modules/Exception.cpp | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/src/Components/Modules/Exception.cpp b/src/Components/Modules/Exception.cpp index e58a0867..2006f730 100644 --- a/src/Components/Modules/Exception.cpp +++ b/src/Components/Modules/Exception.cpp @@ -174,21 +174,23 @@ namespace Components #ifdef DEBUG // Display DEBUG branding, so we know we're on a debug build - Scheduler::OnFrame([]() - { - Game::Font* font = Game::R_RegisterFont("fonts/normalFont", 0); - float color[4] = { 1.0f, 1.0f, 1.0f, 1.0f }; - - // Change the color when attaching a debugger - if (IsDebuggerPresent()) + if (!Dedicated::IsEnabled() && !ZoneBuilder::IsEnabled()) { + Scheduler::OnFrame([]() { - color[0] = 0.6588f; - color[1] = 1.0000f; - color[2] = 0.0000f; - } + Game::Font* font = Game::R_RegisterFont("fonts/normalFont", 0); + float color[4] = { 1.0f, 1.0f, 1.0f, 1.0f }; - Game::R_AddCmdDrawText("DEBUG-BUILD", 0x7FFFFFFF, font, 15.0f, 10.0f + Game::R_TextHeight(font), 1.0f, 1.0f, 0.0f, color, Game::ITEM_TEXTSTYLE_SHADOWED); - }); + // Change the color when attaching a debugger + if (IsDebuggerPresent()) + { + color[0] = 0.6588f; + color[1] = 1.0000f; + color[2] = 0.0000f; + } + + Game::R_AddCmdDrawText("DEBUG-BUILD", 0x7FFFFFFF, font, 15.0f, 10.0f + Game::R_TextHeight(font), 1.0f, 1.0f, 0.0f, color, Game::ITEM_TEXTSTYLE_SHADOWED); + }); + } #endif #if !defined(DEBUG) || defined(FORCE_EXCEPTION_HANDLER) Exception::SetFilterHook.initialize(SetUnhandledExceptionFilter, Exception::SetUnhandledExceptionFilterStub, HOOK_JUMP);