[General] Small code fixes and optimization
This commit is contained in:
parent
8f4a145c3c
commit
08bc848267
@ -61,7 +61,7 @@ namespace Components
|
||||
Loader::Register(new Monitor());
|
||||
Loader::Register(new Network());
|
||||
Loader::Register(new Theatre());
|
||||
//Loader::Register(new Clantags());
|
||||
//Loader::Register(new ClanTags());
|
||||
Loader::Register(new Download());
|
||||
Loader::Register(new Playlist());
|
||||
Loader::Register(new RawFiles());
|
||||
|
@ -92,7 +92,7 @@ namespace Components
|
||||
#include "Modules/Logger.hpp"
|
||||
#include "Modules/Friends.hpp"
|
||||
#include "Modules/IPCPipe.hpp"
|
||||
#include "Modules/Clantags.hpp"
|
||||
#include "Modules/ClanTags.hpp"
|
||||
#include "Modules/Download.hpp"
|
||||
#include "Modules/Playlist.hpp"
|
||||
#include "Modules/RawFiles.hpp"
|
||||
|
@ -229,7 +229,7 @@ namespace Components
|
||||
AntiCheat::Flags |= AntiCheat::IntergrityFlag::MEMORY_SCAN;
|
||||
}
|
||||
|
||||
void AntiCheat::QuickCodeScanner_1()
|
||||
void AntiCheat::QuickCodeScanner1()
|
||||
{
|
||||
static Utils::Time::Interval interval;
|
||||
static std::optional<std::string> hashVal;
|
||||
@ -251,7 +251,7 @@ namespace Components
|
||||
hashVal.emplace(hash);
|
||||
}
|
||||
|
||||
void AntiCheat::QuickCodeScanner_2()
|
||||
void AntiCheat::QuickCodeScanner2()
|
||||
{
|
||||
static Utils::Time::Interval interval;
|
||||
static std::optional<std::string> hashVal;
|
||||
|
@ -31,8 +31,8 @@ namespace Components
|
||||
|
||||
static void VerifyThreadIntegrity();
|
||||
|
||||
static void QuickCodeScanner_1();
|
||||
static void QuickCodeScanner_2();
|
||||
static void QuickCodeScanner1();
|
||||
static void QuickCodeScanner2();
|
||||
|
||||
private:
|
||||
enum IntergrityFlag
|
||||
|
@ -57,7 +57,7 @@ namespace Components
|
||||
UIFeeder::Add(62.0f, Changelog::GetChangelogCount, Changelog::GetChangelogText, Changelog::SelectChangelog);
|
||||
|
||||
#if !defined(DEBUG) && !defined(DISABLE_ANTICHEAT)
|
||||
Scheduler::OnFrame(AntiCheat::QuickCodeScanner_1);
|
||||
Scheduler::OnFrame(AntiCheat::QuickCodeScanner1);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -2,20 +2,20 @@
|
||||
|
||||
namespace Components
|
||||
{
|
||||
std::string Clantags::Tags[18];
|
||||
std::string ClanTags::Tags[18];
|
||||
|
||||
void Clantags::ParseClantags(const char* infoString)
|
||||
void ClanTags::ParseClantags(const char* infoString)
|
||||
{
|
||||
for (int i = 0; i < 18; i++)
|
||||
{
|
||||
const char* clantag = Game::Info_ValueForKey(infoString, std::to_string(i).data());
|
||||
|
||||
if (clantag) Clantags::Tags[i] = clantag;
|
||||
else Clantags::Tags[i].clear();
|
||||
if (clantag) ClanTags::Tags[i] = clantag;
|
||||
else ClanTags::Tags[i].clear();
|
||||
}
|
||||
}
|
||||
|
||||
void Clantags::SendClantagsToClients()
|
||||
void ClanTags::SendClantagsToClients()
|
||||
{
|
||||
std::string list;
|
||||
|
||||
@ -35,18 +35,18 @@ namespace Components
|
||||
Game::SV_GameSendServerCommand(-1, 0, command.data());
|
||||
}
|
||||
|
||||
const char* Clantags::GetUserClantag(std::uint32_t /*clientnum*/, const char* playername)
|
||||
const char* ClanTags::GetUserClantag(std::uint32_t /*clientnum*/, const char* playername)
|
||||
{
|
||||
#if 0
|
||||
if (Clantags::Tags[clientnum].empty()) return playername;
|
||||
return Utils::String::VA("[%s] %s", Clantags::Tags[clientnum].data(), playername);
|
||||
if (ClanTags::Tags[clientnum].empty()) return playername;
|
||||
return Utils::String::VA("[%s] %s", ClanTags::Tags[clientnum].data(), playername);
|
||||
#else
|
||||
return playername;
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
__declspec(naked) void Clantags::DrawPlayerNameOnScoreboard()
|
||||
__declspec(naked) void ClanTags::DrawPlayerNameOnScoreboard()
|
||||
{
|
||||
__asm
|
||||
{
|
||||
@ -70,7 +70,7 @@ namespace Components
|
||||
}
|
||||
}
|
||||
|
||||
Clantags::Clantags()
|
||||
ClanTags::ClanTags()
|
||||
{
|
||||
// Create clantag dvar
|
||||
Dvar::OnInit([]()
|
||||
@ -85,7 +85,7 @@ namespace Components
|
||||
{
|
||||
if (params->length() == 3)
|
||||
{
|
||||
Clantags::ParseClantags(params->get(2));
|
||||
ClanTags::ParseClantags(params->get(2));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -93,20 +93,20 @@ namespace Components
|
||||
return false;
|
||||
});
|
||||
|
||||
for (int i = 0; i < ARRAYSIZE(Clantags::Tags); ++i)
|
||||
for (int i = 0; i < ARRAYSIZE(ClanTags::Tags); ++i)
|
||||
{
|
||||
Clantags::Tags[i].clear();
|
||||
ClanTags::Tags[i].clear();
|
||||
}
|
||||
|
||||
// Draw clantag before playername
|
||||
Utils::Hook(0x591242, Clantags::DrawPlayerNameOnScoreboard).install()->quick();
|
||||
Utils::Hook(0x591242, ClanTags::DrawPlayerNameOnScoreboard).install()->quick();
|
||||
}
|
||||
|
||||
Clantags::~Clantags()
|
||||
ClanTags::~ClanTags()
|
||||
{
|
||||
for (int i = 0; i < ARRAYSIZE(Clantags::Tags); ++i)
|
||||
for (int i = 0; i < ARRAYSIZE(ClanTags::Tags); ++i)
|
||||
{
|
||||
Clantags::Tags[i].clear();
|
||||
ClanTags::Tags[i].clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,18 +2,18 @@
|
||||
|
||||
namespace Components
|
||||
{
|
||||
class Clantags : public Component
|
||||
class ClanTags : public Component
|
||||
{
|
||||
public:
|
||||
static void ParseClantags(const char * infoString);
|
||||
static void SendClantagsToClients();
|
||||
static const char* GetUserClantag(std::uint32_t clientnum, const char * playername);
|
||||
|
||||
Clantags();
|
||||
~Clantags();
|
||||
ClanTags();
|
||||
~ClanTags();
|
||||
|
||||
private:
|
||||
static std::string Clantags::Tags[18];
|
||||
static std::string ClanTags::Tags[18];
|
||||
|
||||
static void DrawPlayerNameOnScoreboard();
|
||||
|
||||
|
@ -109,7 +109,7 @@ namespace Components
|
||||
Game::CL_GetClientName(localClientNum, index, buf, size);
|
||||
|
||||
// Append clantag to username & remove the colors
|
||||
strncpy_s(buf, size, Colors::Strip(Clantags::GetUserClantag(index, buf)).data(), size);
|
||||
strncpy_s(buf, size, Colors::Strip(ClanTags::GetUserClantag(index, buf)).data(), size);
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
@ -164,7 +164,7 @@ namespace Components
|
||||
{
|
||||
std::vector<int> ids;
|
||||
|
||||
auto addId = [&](int id)
|
||||
const auto addId = [&](int id)
|
||||
{
|
||||
if (std::find(ids.begin(), ids.end(), id) == ids.end())
|
||||
{
|
||||
@ -186,8 +186,7 @@ namespace Components
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> _(Friends::Mutex);
|
||||
|
||||
char* mod = "IW4x";
|
||||
unsigned int modId = *reinterpret_cast<unsigned int*>(mod) | 0x80000000;
|
||||
const unsigned int modId = *reinterpret_cast<unsigned int*>("IW4x") | 0x80000000;
|
||||
|
||||
// Split up the list
|
||||
for (auto entry : Friends::FriendsList)
|
||||
|
@ -767,7 +767,7 @@ namespace Components
|
||||
});
|
||||
|
||||
#if !defined(DEBUG) && !defined(DISABLE_ANTICHEAT)
|
||||
Scheduler::OnFrame(AntiCheat::QuickCodeScanner_2);
|
||||
Scheduler::OnFrame(AntiCheat::QuickCodeScanner2);
|
||||
#endif
|
||||
|
||||
Command::Add("mp_QuickMessage", [](Command::Params*)
|
||||
|
@ -746,8 +746,7 @@ namespace Components
|
||||
do
|
||||
{
|
||||
entry = reinterpret_cast<ServerList::MasterEntry*>(const_cast<char*>(data.data()) + offset++);
|
||||
}
|
||||
while (!entry->HasSeparator() && !entry->IsEndToken());
|
||||
} while (!entry->HasSeparator() && !entry->IsEndToken());
|
||||
|
||||
for (int i = 0; !entry[i].IsEndToken() && entry[i].HasSeparator(); ++i)
|
||||
{
|
||||
|
@ -37,5 +37,4 @@ namespace Components
|
||||
{
|
||||
StartupMessages::MessageList.push_back(message);
|
||||
}
|
||||
|
||||
}
|
@ -70,6 +70,7 @@ namespace Components
|
||||
|
||||
// ToDo: Allow playerdata changes in setPlayerData UI script.
|
||||
}
|
||||
|
||||
Stats::~Stats()
|
||||
{
|
||||
|
||||
|
@ -55,7 +55,7 @@ namespace Components
|
||||
Game::Font* font = Game::DB_FindXAssetHeader(Game::XAssetType::ASSET_TYPE_FONT, "fonts/objectiveFont").font; if (!font) return;
|
||||
Game::Font* descfont = Game::DB_FindXAssetHeader(Game::XAssetType::ASSET_TYPE_FONT, "fonts/normalFont").font; if (!descfont) return;
|
||||
Game::vec4_t wColor = { 1.0f, 1.0f, 1.0f, 1.0f };
|
||||
Game::vec4_t bgColor = { 0.0f, 0.0f, 0.0f, 0.5f };
|
||||
Game::vec4_t bgColor = { 0.0f, 0.0f, 0.0f, 0.8f };
|
||||
Game::vec4_t borderColor = { 1.0f, 1.0f, 1.0f, 0.2f };
|
||||
|
||||
height /= 5;
|
||||
|
Loading…
x
Reference in New Issue
Block a user