From 3ff8486fc372e181fa746c8e0ad09bf558c1753d Mon Sep 17 00:00:00 2001 From: Edo Date: Thu, 12 Jan 2023 11:50:06 +0000 Subject: [PATCH] [Dvar]: Cleanup cg dvars (#718) --- src/Components/Modules/Chat.cpp | 9 +++------ src/Components/Modules/Chat.hpp | 4 ---- src/Components/Modules/TextRenderer.hpp | 2 +- src/Game/Dvars.cpp | 3 +++ src/Game/Dvars.hpp | 3 +++ 5 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/Components/Modules/Chat.cpp b/src/Components/Modules/Chat.cpp index ef7e8eb3..6613ee65 100644 --- a/src/Components/Modules/Chat.cpp +++ b/src/Components/Modules/Chat.cpp @@ -11,9 +11,6 @@ namespace Components Dvar::Var Chat::sv_disableChat; Dvar::Var Chat::sv_sayName; - Game::dvar_t** Chat::cg_chatHeight = reinterpret_cast(0x7ED398); - Game::dvar_t** Chat::cg_chatTime = reinterpret_cast(0x9F5DE8); - bool Chat::SendChat; Utils::Concurrency::Container Chat::MutedList; @@ -167,9 +164,9 @@ namespace Components // Text can only be 150 characters maximum. This is bigger than the teamChatMsgs buffers with 160 characters // Therefore it is not needed to check for buffer lengths - const auto chatHeight = (*cg_chatHeight)->current.integer; + const auto chatHeight = (*Game::cg_chatHeight)->current.integer; const auto chatWidth = static_cast(cg_chatWidth.get()); - const auto chatTime = (*cg_chatTime)->current.integer; + const auto chatTime = (*Game::cg_chatTime)->current.integer; if (chatHeight <= 0 || static_cast(chatHeight) > std::extent_v || chatWidth <= 0 || chatTime <= 0) { Game::cgsArray[0].teamLastChatPos = 0; @@ -179,7 +176,7 @@ namespace Components TextRenderer::FontIconInfo fontIconInfo{}; auto len = 0.0f; - auto lastColor = static_cast(TEXT_COLOR_DEFAULT); + auto lastColor = static_cast>(TextColor::TEXT_COLOR_DEFAULT); char* lastSpace = nullptr; char* lastFontIcon = nullptr; char* p = Game::cgsArray[0].teamChatMsgs[Game::cgsArray[0].teamChatPos % chatHeight]; diff --git a/src/Components/Modules/Chat.hpp b/src/Components/Modules/Chat.hpp index 55a37738..f96e29e4 100644 --- a/src/Components/Modules/Chat.hpp +++ b/src/Components/Modules/Chat.hpp @@ -13,10 +13,6 @@ namespace Components static Dvar::Var sv_disableChat; static Dvar::Var sv_sayName; - // Game dvars - static Game::dvar_t** cg_chatHeight; - static Game::dvar_t** cg_chatTime; - static bool SendChat; using muteList = std::unordered_set; diff --git a/src/Components/Modules/TextRenderer.hpp b/src/Components/Modules/TextRenderer.hpp index 29bfc725..6bbfb204 100644 --- a/src/Components/Modules/TextRenderer.hpp +++ b/src/Components/Modules/TextRenderer.hpp @@ -2,7 +2,7 @@ namespace Components { - enum TextColor + enum TextColor : int { TEXT_COLOR_BLACK = 0, TEXT_COLOR_RED = 1, diff --git a/src/Game/Dvars.cpp b/src/Game/Dvars.cpp index 1fa87f3b..3986092d 100644 --- a/src/Game/Dvars.cpp +++ b/src/Game/Dvars.cpp @@ -67,6 +67,9 @@ namespace Game const dvar_t** g_gametype = reinterpret_cast(0x1A45DC8); const dvar_t** g_password = reinterpret_cast(0x18835C0); + const dvar_t** cg_chatHeight = reinterpret_cast(0x7ED398); + const dvar_t** cg_chatTime = reinterpret_cast(0x9F5DE8); + const dvar_t** version = reinterpret_cast(0x1AD7930); const dvar_t** viewposNow = reinterpret_cast(0x9FD30C); diff --git a/src/Game/Dvars.hpp b/src/Game/Dvars.hpp index ba5fafc9..38463a3b 100644 --- a/src/Game/Dvars.hpp +++ b/src/Game/Dvars.hpp @@ -119,6 +119,9 @@ namespace Game extern const dvar_t** g_gametype; extern const dvar_t** g_password; + extern const dvar_t** cg_chatHeight; + extern const dvar_t** cg_chatTime; + extern const dvar_t** version; extern const dvar_t** viewposNow;