From 15ec6cc13feaafba9ce806a54162f2d49a039c9a Mon Sep 17 00:00:00 2001 From: m Date: Sat, 25 Jan 2025 21:01:53 -0600 Subject: [PATCH] fixes --- src/client/game/structs.hpp | 14 +++++++++++ src/client/game/symbols.hpp | 1 + src/common/utils/string.cpp | 48 +++++++++++++++++++++++++++++++++++++ src/common/utils/string.hpp | 8 +++++++ 4 files changed, 71 insertions(+) diff --git a/src/client/game/structs.hpp b/src/client/game/structs.hpp index dcf600c..196a238 100644 --- a/src/client/game/structs.hpp +++ b/src/client/game/structs.hpp @@ -1972,4 +1972,18 @@ namespace game char pad_0040[432]; }; static_assert(sizeof(XZone) == 496); + + struct WeaponDef + { + union + { + const char* szInternalName; + const char* name; + }; + }; + + struct XModel + { + const char* name; // 0 + }; } diff --git a/src/client/game/symbols.hpp b/src/client/game/symbols.hpp index 3e9e81d..8edec0c 100644 --- a/src/client/game/symbols.hpp +++ b/src/client/game/symbols.hpp @@ -23,6 +23,7 @@ namespace game WEAK symbol Com_GetCurrentCoDPlayMode{0, 0x1404C9690}; WEAK symbol Com_SetSlowMotion{0, 0x1403D19B0}; WEAK symbol Com_Quit_f{0x1402F9390, 0x1403D08C0}; + WEAK symbol Com_sprintf{0x0, 0x1404C97B0}; WEAK symbol Cmd_AddCommandInternal{0x1402EDDB0, 0x1403AF2C0}; WEAK symbol Cmd_ExecuteSingleCommand{0x1402EE350, 0x1403AF900}; diff --git a/src/common/utils/string.cpp b/src/common/utils/string.cpp index 8a4c1be..285c663 100644 --- a/src/common/utils/string.cpp +++ b/src/common/utils/string.cpp @@ -176,4 +176,52 @@ namespace utils::string return str; } + + bool is_numeric(const std::string& text) + { + return std::to_string(atoi(text.data())) == text; + } + + bool find_lower(const std::string& a, const std::string& b) + { + return to_lower(a).find(to_lower(b)) != std::string::npos; + } + + bool strstr_lower(const char* a, const char* b) + { + const char* a_ = a; + const char* b_ = b; + + while (*a_ != '\0' && *b_ != '\0') + { + if (*b_ == '*' || std::tolower(*a_) == std::tolower(*b_)) + { + b_++; + } + else + { + b_ = b; + } + + a_++; + } + + return *b_ == '\0'; + } + + void set_clipboard_data(const std::string& text) + { + const auto len = text.size() + 1; + const auto mem = GlobalAlloc(GMEM_MOVEABLE, len); + + memcpy(GlobalLock(mem), text.data(), len); + GlobalUnlock(mem); + + if (OpenClipboard(nullptr)) + { + EmptyClipboard(); + SetClipboardData(CF_TEXT, mem); + CloseClipboard(); + } + } } diff --git a/src/common/utils/string.hpp b/src/common/utils/string.hpp index 2757d2e..9b56188 100644 --- a/src/common/utils/string.hpp +++ b/src/common/utils/string.hpp @@ -95,4 +95,12 @@ namespace utils::string std::wstring convert(const std::string& str); std::string replace(std::string str, const std::string& from, const std::string& to); + + bool is_numeric(const std::string& text); + + bool find_lower(const std::string& a, const std::string& b); + + bool strstr_lower(const char* a, const char* b); + + void set_clipboard_data(const std::string& text); }