[Dvar]: Cleanup cg dvars (#718)

This commit is contained in:
Edo 2023-01-12 11:50:06 +00:00 committed by GitHub
parent fca9c2d234
commit 3ff8486fc3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 10 additions and 11 deletions

View File

@ -11,9 +11,6 @@ namespace Components
Dvar::Var Chat::sv_disableChat;
Dvar::Var Chat::sv_sayName;
Game::dvar_t** Chat::cg_chatHeight = reinterpret_cast<Game::dvar_t**>(0x7ED398);
Game::dvar_t** Chat::cg_chatTime = reinterpret_cast<Game::dvar_t**>(0x9F5DE8);
bool Chat::SendChat;
Utils::Concurrency::Container<Chat::muteList> 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<float>(cg_chatWidth.get<int>());
const auto chatTime = (*cg_chatTime)->current.integer;
const auto chatTime = (*Game::cg_chatTime)->current.integer;
if (chatHeight <= 0 || static_cast<unsigned>(chatHeight) > std::extent_v<decltype(Game::cgs_t::teamChatMsgs)> || 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<int>(TEXT_COLOR_DEFAULT);
auto lastColor = static_cast<std::underlying_type_t<TextColor>>(TextColor::TEXT_COLOR_DEFAULT);
char* lastSpace = nullptr;
char* lastFontIcon = nullptr;
char* p = Game::cgsArray[0].teamChatMsgs[Game::cgsArray[0].teamChatPos % chatHeight];

View File

@ -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<std::uint64_t>;

View File

@ -2,7 +2,7 @@
namespace Components
{
enum TextColor
enum TextColor : int
{
TEXT_COLOR_BLACK = 0,
TEXT_COLOR_RED = 1,

View File

@ -67,6 +67,9 @@ namespace Game
const dvar_t** g_gametype = reinterpret_cast<const dvar_t**>(0x1A45DC8);
const dvar_t** g_password = reinterpret_cast<const dvar_t**>(0x18835C0);
const dvar_t** cg_chatHeight = reinterpret_cast<const dvar_t**>(0x7ED398);
const dvar_t** cg_chatTime = reinterpret_cast<const dvar_t**>(0x9F5DE8);
const dvar_t** version = reinterpret_cast<const dvar_t**>(0x1AD7930);
const dvar_t** viewposNow = reinterpret_cast<const dvar_t**>(0x9FD30C);

View File

@ -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;