From eb11652f2cb1f3dbcba84c14b2312005bcf0ce5c Mon Sep 17 00:00:00 2001 From: FutureRave Date: Sat, 7 May 2022 14:59:15 +0100 Subject: [PATCH] [Branding] Address review --- src/Components/Modules/Branding.cpp | 35 +++++++++++----------------- src/Components/Modules/Exception.cpp | 18 -------------- 2 files changed, 13 insertions(+), 40 deletions(-) diff --git a/src/Components/Modules/Branding.cpp b/src/Components/Modules/Branding.cpp index a5a4c954..6d560719 100644 --- a/src/Components/Modules/Branding.cpp +++ b/src/Components/Modules/Branding.cpp @@ -22,10 +22,10 @@ namespace Components const auto width = Game::UI_TextWidth((*Version)->current.string, 0, font, fontScale); const auto height = Game::UI_TextHeight(font, fontScale); - Game::UI_DrawText(placement, (*Version)->current.string, maxChars, font, 1.0f - (CGDrawVersionX.get() + width), - 1.0f - (CGDrawVersionY.get() + height), 3, 3, fontScale, shadowColor, 0); - Game::UI_DrawText(placement, (*Version)->current.string, maxChars, font, (0.0f - width) - CGDrawVersionX.get(), - (0.0f - height) - CGDrawVersionY.get(), 3, 3, fontScale, color, 0); + Game::UI_DrawText(placement, (*Version)->current.string, maxChars, font, 1.0f - (CGDrawVersionX.get() + static_cast(width)), + 1.0f - (CGDrawVersionY.get() + static_cast(height)), 3, 3, fontScale, shadowColor, 0); + Game::UI_DrawText(placement, (*Version)->current.string, maxChars, font, (0.0f - static_cast(width)) - CGDrawVersionX.get(), + (0.0f - static_cast(height)) - CGDrawVersionY.get(), 3, 3, fontScale, color, 0); } void Branding::CG_DrawVersion_Hk(int localClientNum) @@ -40,12 +40,7 @@ namespace Components const char* Branding::GetBuildNumber() { - static char buf[128]; // Length the game uses - - const auto* data = "latest " __DATE__ " " __TIME__; - sprintf_s(buf, "%s %s", SHORTVERSION, data); - - return buf; + return SHORTVERSION " latest " __DATE__ " " __TIME__; } const char* Branding::GetVersionString() @@ -63,28 +58,24 @@ namespace Components return result; } - void Branding::Dvar_SetVersionString(const Game::dvar_t* dvar, const char* /*value*/) + void Branding::Dvar_SetVersionString(const Game::dvar_t* dvar, [[maybe_unused]] const char* value) { const auto* result = Branding::GetVersionString(); Utils::Hook::Call(0x4A9580)(dvar, result); } // Branding this might be a good idea in case this LSP logging ever gets turned on for some reason - void Branding::MSG_WriteVersionStringHeader(Game::msg_t* msg, const char* /*string*/) + void Branding::MSG_WriteVersionStringHeader(Game::msg_t* msg, [[maybe_unused]] const char* string) { const auto* result = Branding::GetVersionString(); Utils::Hook::Call(0x463820)(msg, result); } - Game::dvar_t* Branding::Dvar_RegisterUIBuildLocation(const char* dvarName, - float /*x*/, float /*y*/, float min, float max, int /*flags*/, const char* description) + Game::dvar_t* Branding::Dvar_RegisterUIBuildLocation(const char* dvarName, [[maybe_unused]] float x, + [[maybe_unused]] float y, float min, float max, [[maybe_unused]] int flags, const char* description) { -#ifdef _DEBUG - constexpr auto flag = Game::dvar_flag::DVAR_NONE; -#else - constexpr auto flag = Game::dvar_flag::DVAR_READONLY; -#endif - return Game::Dvar_RegisterVec2(dvarName, -60.0f, 474.0f, min, max, flag, description); + return Game::Dvar_RegisterVec2(dvarName, -60.0f, + 474.0f, min, max, Game::dvar_flag::DVAR_READONLY, description); } void Branding::RegisterBrandingDvars() @@ -96,9 +87,9 @@ namespace Components #endif Branding::CGDrawVersion = Dvar::Register("cg_drawVersion", value, Game::dvar_flag::DVAR_NONE, "Draw the game version"); - Branding::CGDrawVersionX = Dvar::Register("cg_drawVersionX", 50.0f, + Branding::CGDrawVersionX = Dvar::Register("cg_drawVersionX", 10.0f, 0.0f, 512.0f, Game::dvar_flag::DVAR_NONE, "X offset for the version string"); - Branding::CGDrawVersionY = Dvar::Register("cg_drawVersionY", 18.0f, + Branding::CGDrawVersionY = Dvar::Register("cg_drawVersionY", 455.0f, 0.0f, 512.0f, Game::dvar_flag::DVAR_NONE, "Y offset for the version string"); } diff --git a/src/Components/Modules/Exception.cpp b/src/Components/Modules/Exception.cpp index 572bfdfd..a58dfefa 100644 --- a/src/Components/Modules/Exception.cpp +++ b/src/Components/Modules/Exception.cpp @@ -193,24 +193,6 @@ namespace Components { Exception::SetMiniDumpType(Flags::HasFlag("bigminidumps"), Flags::HasFlag("reallybigminidumps")); -#ifdef DEBUG - // Display DEBUG branding, so we know we're on a debug build - Scheduler::OnFrame([]() - { - auto* font = Game::R_RegisterFont("fonts/normalFont", 0); - Game::vec4_t color = { 1.0f, 1.0f, 1.0f, 1.0f }; - - // 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); - }, true); -#endif #if !defined(DEBUG) || defined(FORCE_EXCEPTION_HANDLER) Exception::SetFilterHook.initialize(SetUnhandledExceptionFilter, Exception::SetUnhandledExceptionFilterStub, HOOK_JUMP); Exception::SetFilterHook.install();