This commit is contained in:
m 2025-01-25 21:01:53 -06:00
parent 1d98df42b3
commit ce047e96da
3 changed files with 70 additions and 0 deletions

View File

@ -2119,4 +2119,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
};
}

View File

@ -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();
}
}
}

View File

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