[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 Monitor());
|
||||||
Loader::Register(new Network());
|
Loader::Register(new Network());
|
||||||
Loader::Register(new Theatre());
|
Loader::Register(new Theatre());
|
||||||
//Loader::Register(new Clantags());
|
//Loader::Register(new ClanTags());
|
||||||
Loader::Register(new Download());
|
Loader::Register(new Download());
|
||||||
Loader::Register(new Playlist());
|
Loader::Register(new Playlist());
|
||||||
Loader::Register(new RawFiles());
|
Loader::Register(new RawFiles());
|
||||||
@ -111,7 +111,7 @@ namespace Components
|
|||||||
for (auto component : Loader::Components)
|
for (auto component : Loader::Components)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if(!Loader::PerformingUnitTests())
|
if (!Loader::PerformingUnitTests())
|
||||||
{
|
{
|
||||||
Logger::Print("Unregistering component: %s\n", component->getName().data());
|
Logger::Print("Unregistering component: %s\n", component->getName().data());
|
||||||
}
|
}
|
||||||
@ -126,7 +126,7 @@ namespace Components
|
|||||||
|
|
||||||
void Loader::PreDestroy()
|
void Loader::PreDestroy()
|
||||||
{
|
{
|
||||||
if(!Loader::Postgame)
|
if (!Loader::Postgame)
|
||||||
{
|
{
|
||||||
Loader::Postgame = true;
|
Loader::Postgame = true;
|
||||||
|
|
||||||
@ -191,7 +191,7 @@ namespace Components
|
|||||||
if (component)
|
if (component)
|
||||||
{
|
{
|
||||||
#if defined(DEBUG) || defined(FORCE_UNIT_TESTS)
|
#if defined(DEBUG) || defined(FORCE_UNIT_TESTS)
|
||||||
if(!Loader::PerformingUnitTests())
|
if (!Loader::PerformingUnitTests())
|
||||||
{
|
{
|
||||||
Logger::Print("Component registered: %s\n", component->getName().data());
|
Logger::Print("Component registered: %s\n", component->getName().data());
|
||||||
}
|
}
|
||||||
|
@ -92,7 +92,7 @@ namespace Components
|
|||||||
#include "Modules/Logger.hpp"
|
#include "Modules/Logger.hpp"
|
||||||
#include "Modules/Friends.hpp"
|
#include "Modules/Friends.hpp"
|
||||||
#include "Modules/IPCPipe.hpp"
|
#include "Modules/IPCPipe.hpp"
|
||||||
#include "Modules/Clantags.hpp"
|
#include "Modules/ClanTags.hpp"
|
||||||
#include "Modules/Download.hpp"
|
#include "Modules/Download.hpp"
|
||||||
#include "Modules/Playlist.hpp"
|
#include "Modules/Playlist.hpp"
|
||||||
#include "Modules/RawFiles.hpp"
|
#include "Modules/RawFiles.hpp"
|
||||||
|
@ -45,7 +45,7 @@ namespace Components
|
|||||||
static std::thread triggerThread;
|
static std::thread triggerThread;
|
||||||
if (!triggerThread.joinable())
|
if (!triggerThread.joinable())
|
||||||
{
|
{
|
||||||
triggerThread = std::thread([] ()
|
triggerThread = std::thread([]()
|
||||||
{
|
{
|
||||||
std::this_thread::sleep_for(43s);
|
std::this_thread::sleep_for(43s);
|
||||||
Utils::Hook::Set<BYTE>(0x41BA2C, 0xEB);
|
Utils::Hook::Set<BYTE>(0x41BA2C, 0xEB);
|
||||||
@ -63,7 +63,7 @@ namespace Components
|
|||||||
if (!hModuleSelf || !hModuleTarget || !hModuleProcess || (hModuleTarget != hModuleSelf && hModuleTarget != hModuleProcess))
|
if (!hModuleSelf || !hModuleTarget || !hModuleProcess || (hModuleTarget != hModuleSelf && hModuleTarget != hModuleProcess))
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_DETECTIONS
|
#ifdef DEBUG_DETECTIONS
|
||||||
char buffer[MAX_PATH] = {0};
|
char buffer[MAX_PATH] = { 0 };
|
||||||
GetModuleFileNameA(hModuleTarget, buffer, sizeof buffer);
|
GetModuleFileNameA(hModuleTarget, buffer, sizeof buffer);
|
||||||
|
|
||||||
Logger::Print(Utils::String::VA("AntiCheat: Callee assertion failed: %X %s", reinterpret_cast<uint32_t>(callee), buffer));
|
Logger::Print(Utils::String::VA("AntiCheat: Callee assertion failed: %X %s", reinterpret_cast<uint32_t>(callee), buffer));
|
||||||
@ -229,7 +229,7 @@ namespace Components
|
|||||||
AntiCheat::Flags |= AntiCheat::IntergrityFlag::MEMORY_SCAN;
|
AntiCheat::Flags |= AntiCheat::IntergrityFlag::MEMORY_SCAN;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AntiCheat::QuickCodeScanner_1()
|
void AntiCheat::QuickCodeScanner1()
|
||||||
{
|
{
|
||||||
static Utils::Time::Interval interval;
|
static Utils::Time::Interval interval;
|
||||||
static std::optional<std::string> hashVal;
|
static std::optional<std::string> hashVal;
|
||||||
@ -251,7 +251,7 @@ namespace Components
|
|||||||
hashVal.emplace(hash);
|
hashVal.emplace(hash);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AntiCheat::QuickCodeScanner_2()
|
void AntiCheat::QuickCodeScanner2()
|
||||||
{
|
{
|
||||||
static Utils::Time::Interval interval;
|
static Utils::Time::Interval interval;
|
||||||
static std::optional<std::string> hashVal;
|
static std::optional<std::string> hashVal;
|
||||||
@ -273,7 +273,7 @@ namespace Components
|
|||||||
HANDLE AntiCheat::LoadLibary(std::wstring library, HANDLE file, DWORD flags, void* callee)
|
HANDLE AntiCheat::LoadLibary(std::wstring library, HANDLE file, DWORD flags, void* callee)
|
||||||
{
|
{
|
||||||
HMODULE module;
|
HMODULE module;
|
||||||
char buffer[MAX_PATH] = {0};
|
char buffer[MAX_PATH] = { 0 };
|
||||||
|
|
||||||
GetModuleHandleExA(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, reinterpret_cast<char*>(callee), &module);
|
GetModuleHandleExA(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, reinterpret_cast<char*>(callee), &module);
|
||||||
GetModuleFileNameA(module, buffer, sizeof buffer);
|
GetModuleFileNameA(module, buffer, sizeof buffer);
|
||||||
@ -319,7 +319,7 @@ namespace Components
|
|||||||
|
|
||||||
void AntiCheat::InstallLibHook()
|
void AntiCheat::InstallLibHook()
|
||||||
{
|
{
|
||||||
for(int i = 0; i < ARRAYSIZE(AntiCheat::LoadLibHook); ++i)
|
for (int i = 0; i < ARRAYSIZE(AntiCheat::LoadLibHook); ++i)
|
||||||
{
|
{
|
||||||
AntiCheat::LoadLibHook[i].install();
|
AntiCheat::LoadLibHook[i].install();
|
||||||
}
|
}
|
||||||
@ -430,7 +430,7 @@ namespace Components
|
|||||||
DWORD self = DWORD(hModuleSelf), main = DWORD(hModuleMain), address = DWORD(addr);
|
DWORD self = DWORD(hModuleSelf), main = DWORD(hModuleMain), address = DWORD(addr);
|
||||||
|
|
||||||
// If the address that should be changed is within our module or the main binary, then we need to check if we are changing it or someone else
|
// If the address that should be changed is within our module or the main binary, then we need to check if we are changing it or someone else
|
||||||
if(Utils::HasIntercection(self, selfSize, address, len) || Utils::HasIntercection(main, mainSize, address, len))
|
if (Utils::HasIntercection(self, selfSize, address, len) || Utils::HasIntercection(main, mainSize, address, len))
|
||||||
{
|
{
|
||||||
if (!hModuleSelf || !hModuleTarget || (hModuleTarget != hModuleSelf))
|
if (!hModuleSelf || !hModuleTarget || (hModuleTarget != hModuleSelf))
|
||||||
{
|
{
|
||||||
@ -610,7 +610,7 @@ namespace Components
|
|||||||
void AntiCheat::AcquireDebugPriviledge(HANDLE hToken)
|
void AntiCheat::AcquireDebugPriviledge(HANDLE hToken)
|
||||||
{
|
{
|
||||||
LUID luid;
|
LUID luid;
|
||||||
TOKEN_PRIVILEGES tp = {0};
|
TOKEN_PRIVILEGES tp = { 0 };
|
||||||
DWORD cb = sizeof(TOKEN_PRIVILEGES);
|
DWORD cb = sizeof(TOKEN_PRIVILEGES);
|
||||||
if (!LookupPrivilegeValueW(nullptr, SE_DEBUG_NAME, &luid)) return;
|
if (!LookupPrivilegeValueW(nullptr, SE_DEBUG_NAME, &luid)) return;
|
||||||
|
|
||||||
@ -627,7 +627,7 @@ namespace Components
|
|||||||
AntiCheat::VirtualProtectHook[0].initialize(vp, AntiCheat::VirtualProtectStub, HOOK_JUMP)->install(true, true);
|
AntiCheat::VirtualProtectHook[0].initialize(vp, AntiCheat::VirtualProtectStub, HOOK_JUMP)->install(true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS NTAPI AntiCheat::NtCreateThreadExStub(PHANDLE phThread,ACCESS_MASK desiredAccess,LPVOID objectAttributes,HANDLE processHandle,LPTHREAD_START_ROUTINE startAddress,LPVOID parameter,BOOL createSuspended,DWORD stackZeroBits,DWORD sizeOfStackCommit,DWORD sizeOfStackReserve,LPVOID bytesBuffer)
|
NTSTATUS NTAPI AntiCheat::NtCreateThreadExStub(PHANDLE phThread, ACCESS_MASK desiredAccess, LPVOID objectAttributes, HANDLE processHandle, LPTHREAD_START_ROUTINE startAddress, LPVOID parameter, BOOL createSuspended, DWORD stackZeroBits, DWORD sizeOfStackCommit, DWORD sizeOfStackReserve, LPVOID bytesBuffer)
|
||||||
{
|
{
|
||||||
HANDLE hThread = nullptr;
|
HANDLE hThread = nullptr;
|
||||||
std::lock_guard<std::mutex> _(AntiCheat::ThreadMutex);
|
std::lock_guard<std::mutex> _(AntiCheat::ThreadMutex);
|
||||||
@ -675,7 +675,7 @@ namespace Components
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
while(true)
|
while (true)
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> _(AntiCheat::ThreadMutex);
|
std::lock_guard<std::mutex> _(AntiCheat::ThreadMutex);
|
||||||
|
|
||||||
@ -752,7 +752,7 @@ namespace Components
|
|||||||
{
|
{
|
||||||
static bool first = true;
|
static bool first = true;
|
||||||
if (first) first = false; // We can't control the main thread, as it's spawned externally
|
if (first) first = false; // We can't control the main thread, as it's spawned externally
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> _(AntiCheat::ThreadMutex);
|
std::lock_guard<std::mutex> _(AntiCheat::ThreadMutex);
|
||||||
|
|
||||||
@ -819,7 +819,7 @@ namespace Components
|
|||||||
|
|
||||||
// Prevent external processes from accessing our memory
|
// Prevent external processes from accessing our memory
|
||||||
AntiCheat::ProtectProcess();
|
AntiCheat::ProtectProcess();
|
||||||
Renderer::OnDeviceRecoveryEnd([] ()
|
Renderer::OnDeviceRecoveryEnd([]()
|
||||||
{
|
{
|
||||||
AntiCheat::ProtectProcess();
|
AntiCheat::ProtectProcess();
|
||||||
});
|
});
|
||||||
|
@ -31,8 +31,8 @@ namespace Components
|
|||||||
|
|
||||||
static void VerifyThreadIntegrity();
|
static void VerifyThreadIntegrity();
|
||||||
|
|
||||||
static void QuickCodeScanner_1();
|
static void QuickCodeScanner1();
|
||||||
static void QuickCodeScanner_2();
|
static void QuickCodeScanner2();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum IntergrityFlag
|
enum IntergrityFlag
|
||||||
@ -73,7 +73,7 @@ namespace Components
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
static BOOL WINAPI VirtualProtectStub(LPVOID lpAddress, SIZE_T dwSize, DWORD flNewProtect, PDWORD lpflOldProtect);
|
static BOOL WINAPI VirtualProtectStub(LPVOID lpAddress, SIZE_T dwSize, DWORD flNewProtect, PDWORD lpflOldProtect);
|
||||||
static BOOL WINAPI VirtualProtectExStub(HANDLE hProcess,LPVOID lpAddress, SIZE_T dwSize, DWORD flNewProtect,PDWORD lpflOldProtect);
|
static BOOL WINAPI VirtualProtectExStub(HANDLE hProcess, LPVOID lpAddress, SIZE_T dwSize, DWORD flNewProtect, PDWORD lpflOldProtect);
|
||||||
|
|
||||||
static void LostD3DStub();
|
static void LostD3DStub();
|
||||||
static void CinematicStub();
|
static void CinematicStub();
|
||||||
|
@ -86,7 +86,7 @@ namespace Components
|
|||||||
|
|
||||||
void AssetHandler::ResetBypassState()
|
void AssetHandler::ResetBypassState()
|
||||||
{
|
{
|
||||||
if(AssetHandler::HasThreadBypass())
|
if (AssetHandler::HasThreadBypass())
|
||||||
{
|
{
|
||||||
// Maybe just decrement it?
|
// Maybe just decrement it?
|
||||||
AssetHandler::BypassState = 0;
|
AssetHandler::BypassState = 0;
|
||||||
@ -362,7 +362,7 @@ namespace Components
|
|||||||
if (!header.data)
|
if (!header.data)
|
||||||
{
|
{
|
||||||
header = Game::DB_FindXAssetHeader(type, filename.data());
|
header = Game::DB_FindXAssetHeader(type, filename.data());
|
||||||
if(header.data) Components::AssetHandler::StoreTemporaryAsset(type, header); // Might increase efficiency...
|
if (header.data) Components::AssetHandler::StoreTemporaryAsset(type, header); // Might increase efficiency...
|
||||||
}
|
}
|
||||||
|
|
||||||
return header;
|
return header;
|
||||||
@ -403,7 +403,7 @@ namespace Components
|
|||||||
|
|
||||||
void AssetHandler::MissingAssetError(int severity, const char* format, const char* type, const char* name)
|
void AssetHandler::MissingAssetError(int severity, const char* format, const char* type, const char* name)
|
||||||
{
|
{
|
||||||
if(Dedicated::IsEnabled() && Game::DB_GetXAssetNameType(type) == Game::XAssetType::ASSET_TYPE_TECHNIQUE_SET) return;
|
if (Dedicated::IsEnabled() && Game::DB_GetXAssetNameType(type) == Game::XAssetType::ASSET_TYPE_TECHNIQUE_SET) return;
|
||||||
Utils::Hook::Call<void(int, const char*, const char*, const char*)>(0x4F8C70)(severity, format, type, name); // Print error
|
Utils::Hook::Call<void(int, const char*, const char*, const char*)>(0x4F8C70)(severity, format, type, name); // Print error
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -426,10 +426,10 @@ namespace Components
|
|||||||
Utils::Hook(0x5BB6EC, AssetHandler::StoreEmptyAssetStub, HOOK_CALL).install()->quick();
|
Utils::Hook(0x5BB6EC, AssetHandler::StoreEmptyAssetStub, HOOK_CALL).install()->quick();
|
||||||
|
|
||||||
// Intercept missing asset messages
|
// Intercept missing asset messages
|
||||||
if(!ZoneBuilder::IsEnabled()) Utils::Hook(0x5BB3F2, AssetHandler::MissingAssetError, HOOK_CALL).install()->quick();
|
if (!ZoneBuilder::IsEnabled()) Utils::Hook(0x5BB3F2, AssetHandler::MissingAssetError, HOOK_CALL).install()->quick();
|
||||||
|
|
||||||
// Log missing empty assets
|
// Log missing empty assets
|
||||||
Scheduler::OnFrame([] ()
|
Scheduler::OnFrame([]()
|
||||||
{
|
{
|
||||||
if (FastFiles::Ready() && !AssetHandler::EmptyAssets.empty())
|
if (FastFiles::Ready() && !AssetHandler::EmptyAssets.empty())
|
||||||
{
|
{
|
||||||
@ -442,7 +442,7 @@ namespace Components
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
AssetHandler::OnLoad([] (Game::XAssetType type, Game::XAssetHeader asset, std::string name, bool*)
|
AssetHandler::OnLoad([](Game::XAssetType type, Game::XAssetHeader asset, std::string name, bool*)
|
||||||
{
|
{
|
||||||
if (Dvar::Var("r_noVoid").get<bool>() && type == Game::XAssetType::ASSET_TYPE_XMODEL && name == "void")
|
if (Dvar::Var("r_noVoid").get<bool>() && type == Game::XAssetType::ASSET_TYPE_XMODEL && name == "void")
|
||||||
{
|
{
|
||||||
|
@ -282,45 +282,45 @@ namespace Assets
|
|||||||
{
|
{
|
||||||
switch (elemType)
|
switch (elemType)
|
||||||
{
|
{
|
||||||
case 7:
|
case 7:
|
||||||
|
{
|
||||||
|
if (visuals->xmodel)
|
||||||
{
|
{
|
||||||
if (visuals->xmodel)
|
builder->loadAsset(Game::XAssetType::ASSET_TYPE_XMODEL, visuals->xmodel);
|
||||||
{
|
|
||||||
builder->loadAsset(Game::XAssetType::ASSET_TYPE_XMODEL, visuals->xmodel);
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
case 8:
|
break;
|
||||||
case 9:
|
}
|
||||||
break;
|
|
||||||
|
|
||||||
case 0xA:
|
case 8:
|
||||||
|
case 9:
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 0xA:
|
||||||
|
{
|
||||||
|
builder->loadAssetByName(Game::XAssetType::ASSET_TYPE_SOUND, visuals->soundName, false);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 0xC:
|
||||||
|
{
|
||||||
|
if (visuals->effectDef.handle)
|
||||||
{
|
{
|
||||||
builder->loadAssetByName(Game::XAssetType::ASSET_TYPE_SOUND, visuals->soundName, false);
|
builder->loadAsset(Game::XAssetType::ASSET_TYPE_FX, visuals->effectDef.handle, false);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
case 0xC:
|
break;
|
||||||
{
|
}
|
||||||
if (visuals->effectDef.handle)
|
|
||||||
{
|
|
||||||
builder->loadAsset(Game::XAssetType::ASSET_TYPE_FX, visuals->effectDef.handle, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
default:
|
||||||
|
{
|
||||||
|
if (visuals->material)
|
||||||
|
{
|
||||||
|
builder->loadAsset(Game::XAssetType::ASSET_TYPE_MATERIAL, visuals->material);
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
break;
|
||||||
{
|
}
|
||||||
if (visuals->material)
|
|
||||||
{
|
|
||||||
builder->loadAsset(Game::XAssetType::ASSET_TYPE_MATERIAL, visuals->material);
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -390,51 +390,51 @@ namespace Assets
|
|||||||
|
|
||||||
switch (elemType)
|
switch (elemType)
|
||||||
{
|
{
|
||||||
case 7:
|
case 7:
|
||||||
|
{
|
||||||
|
if (visuals->xmodel)
|
||||||
{
|
{
|
||||||
if (visuals->xmodel)
|
destVisuals->xmodel = builder->saveSubAsset(Game::XAssetType::ASSET_TYPE_XMODEL, visuals->xmodel).model;
|
||||||
{
|
|
||||||
destVisuals->xmodel = builder->saveSubAsset(Game::XAssetType::ASSET_TYPE_XMODEL, visuals->xmodel).model;
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
case 8:
|
break;
|
||||||
case 9:
|
}
|
||||||
break;
|
|
||||||
|
|
||||||
case 0xA:
|
case 8:
|
||||||
|
case 9:
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 0xA:
|
||||||
|
{
|
||||||
|
if (visuals->soundName)
|
||||||
{
|
{
|
||||||
if (visuals->soundName)
|
buffer->saveString(visuals->soundName);
|
||||||
{
|
Utils::Stream::ClearPointer(&destVisuals->soundName);
|
||||||
buffer->saveString(visuals->soundName);
|
|
||||||
Utils::Stream::ClearPointer(&destVisuals->soundName);
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
case 0xC:
|
break;
|
||||||
{
|
}
|
||||||
if (visuals->effectDef.handle)
|
|
||||||
{
|
|
||||||
buffer->saveString(visuals->effectDef.handle->name);
|
|
||||||
Utils::Stream::ClearPointer(&destVisuals->effectDef.handle);
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
case 0xC:
|
||||||
|
{
|
||||||
|
if (visuals->effectDef.handle)
|
||||||
|
{
|
||||||
|
buffer->saveString(visuals->effectDef.handle->name);
|
||||||
|
Utils::Stream::ClearPointer(&destVisuals->effectDef.handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
break;
|
||||||
{
|
}
|
||||||
if (visuals->material)
|
|
||||||
{
|
|
||||||
destVisuals->material = builder->saveSubAsset(Game::XAssetType::ASSET_TYPE_MATERIAL, visuals->material).material;
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
default:
|
||||||
|
{
|
||||||
|
if (visuals->material)
|
||||||
|
{
|
||||||
|
destVisuals->material = builder->saveSubAsset(Game::XAssetType::ASSET_TYPE_MATERIAL, visuals->material).material;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -516,7 +516,7 @@ namespace Assets
|
|||||||
Utils::Stream::ClearPointer(&destElemDef->visuals.markArray);
|
Utils::Stream::ClearPointer(&destElemDef->visuals.markArray);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(elemDef->visualCount > 1)
|
else if (elemDef->visualCount > 1)
|
||||||
{
|
{
|
||||||
if (elemDef->visuals.array)
|
if (elemDef->visuals.array)
|
||||||
{
|
{
|
||||||
|
@ -52,7 +52,7 @@ namespace Assets
|
|||||||
image->loaded = true;
|
image->loaded = true;
|
||||||
image->loadDef->flags = 0;
|
image->loadDef->flags = 0;
|
||||||
|
|
||||||
if(image->loadDef->resourceSize != image->dataLen1)
|
if (image->loadDef->resourceSize != image->dataLen1)
|
||||||
{
|
{
|
||||||
Components::Logger::Error("Resource size doesn't match the data length (%s)!\n", name.data());
|
Components::Logger::Error("Resource size doesn't match the data length (%s)!\n", name.data());
|
||||||
}
|
}
|
||||||
@ -66,7 +66,7 @@ namespace Assets
|
|||||||
|
|
||||||
header->image = image;
|
header->image = image;
|
||||||
}
|
}
|
||||||
else if(name[0] != '*')
|
else if (name[0] != '*')
|
||||||
{
|
{
|
||||||
char nameBuffer[MAX_PATH] = { 0 };
|
char nameBuffer[MAX_PATH] = { 0 };
|
||||||
Components::Materials::FormatImagePath(nameBuffer, sizeof(nameBuffer), 0, 0, name.data());
|
Components::Materials::FormatImagePath(nameBuffer, sizeof(nameBuffer), 0, 0, name.data());
|
||||||
@ -109,40 +109,40 @@ namespace Assets
|
|||||||
|
|
||||||
switch (iwiHeader->format)
|
switch (iwiHeader->format)
|
||||||
{
|
{
|
||||||
case Game::IWI_COMPRESSION::IWI_ARGB:
|
case Game::IWI_COMPRESSION::IWI_ARGB:
|
||||||
{
|
{
|
||||||
image->loadDef->format = 21;
|
image->loadDef->format = 21;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case Game::IWI_COMPRESSION::IWI_RGB8:
|
case Game::IWI_COMPRESSION::IWI_RGB8:
|
||||||
{
|
{
|
||||||
image->loadDef->format = 20;
|
image->loadDef->format = 20;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case Game::IWI_COMPRESSION::IWI_DXT1:
|
case Game::IWI_COMPRESSION::IWI_DXT1:
|
||||||
{
|
{
|
||||||
image->loadDef->format = 0x31545844;
|
image->loadDef->format = 0x31545844;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case Game::IWI_COMPRESSION::IWI_DXT3:
|
case Game::IWI_COMPRESSION::IWI_DXT3:
|
||||||
{
|
{
|
||||||
image->loadDef->format = 0x33545844;
|
image->loadDef->format = 0x33545844;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case Game::IWI_COMPRESSION::IWI_DXT5:
|
case Game::IWI_COMPRESSION::IWI_DXT5:
|
||||||
{
|
{
|
||||||
image->loadDef->format = 0x35545844;
|
image->loadDef->format = 0x35545844;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
header->image = image;
|
header->image = image;
|
||||||
|
@ -8,7 +8,7 @@ namespace Assets
|
|||||||
virtual Game::XAssetType getType() override { return Game::XAssetType::ASSET_TYPE_GFXWORLD; };
|
virtual Game::XAssetType getType() override { return Game::XAssetType::ASSET_TYPE_GFXWORLD; };
|
||||||
|
|
||||||
virtual void save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override;
|
virtual void save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override;
|
||||||
virtual void mark(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override;
|
virtual void mark(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override;
|
||||||
virtual void load(Game::XAssetHeader* header, std::string name, Components::ZoneBuilder::Zone* builder) override;
|
virtual void load(Game::XAssetHeader* header, std::string name, Components::ZoneBuilder::Zone* builder) override;
|
||||||
private:
|
private:
|
||||||
void saveGfxWorldDpvsPlanes(Game::GfxWorld* world, Game::GfxWorldDpvsPlanes* asset, Game::GfxWorldDpvsPlanes* dest, Components::ZoneBuilder::Zone* builder);
|
void saveGfxWorldDpvsPlanes(Game::GfxWorld* world, Game::GfxWorldDpvsPlanes* asset, Game::GfxWorldDpvsPlanes* dest, Components::ZoneBuilder::Zone* builder);
|
||||||
|
@ -56,7 +56,7 @@ namespace Assets
|
|||||||
void IMapEnts::mark(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder)
|
void IMapEnts::mark(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder)
|
||||||
{
|
{
|
||||||
Utils::Entities memEnts(header.mapEnts->entityString, header.mapEnts->numEntityChars);
|
Utils::Entities memEnts(header.mapEnts->entityString, header.mapEnts->numEntityChars);
|
||||||
for(auto& model : memEnts.getModels())
|
for (auto& model : memEnts.getModels())
|
||||||
{
|
{
|
||||||
builder->loadAssetByName(Game::XAssetType::ASSET_TYPE_XMODEL, model, false);
|
builder->loadAssetByName(Game::XAssetType::ASSET_TYPE_XMODEL, model, false);
|
||||||
}
|
}
|
||||||
|
@ -356,7 +356,7 @@ namespace Assets
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!replaceTexture)
|
if (!replaceTexture)
|
||||||
{
|
{
|
||||||
if (!textureList.empty())
|
if (!textureList.empty())
|
||||||
{
|
{
|
||||||
|
@ -105,12 +105,12 @@ namespace Assets
|
|||||||
Game::MaterialShaderArgument* destArgs = buffer->dest<Game::MaterialShaderArgument>();
|
Game::MaterialShaderArgument* destArgs = buffer->dest<Game::MaterialShaderArgument>();
|
||||||
buffer->saveArray(pass->args, pass->perPrimArgCount + pass->perObjArgCount + pass->stableArgCount);
|
buffer->saveArray(pass->args, pass->perPrimArgCount + pass->perObjArgCount + pass->stableArgCount);
|
||||||
|
|
||||||
for(int k = 0; k < pass->perPrimArgCount + pass->perObjArgCount + pass->stableArgCount; ++k)
|
for (int k = 0; k < pass->perPrimArgCount + pass->perObjArgCount + pass->stableArgCount; ++k)
|
||||||
{
|
{
|
||||||
Game::MaterialShaderArgument* arg = &pass->args[k];
|
Game::MaterialShaderArgument* arg = &pass->args[k];
|
||||||
Game::MaterialShaderArgument* destArg = &destArgs[k];
|
Game::MaterialShaderArgument* destArg = &destArgs[k];
|
||||||
|
|
||||||
if(arg->type == 1 || arg->type == 7)
|
if (arg->type == 1 || arg->type == 7)
|
||||||
{
|
{
|
||||||
if (builder->hasPointer(arg->u.literalConst))
|
if (builder->hasPointer(arg->u.literalConst))
|
||||||
{
|
{
|
||||||
|
@ -74,7 +74,7 @@ namespace Assets
|
|||||||
|
|
||||||
void IXModel::load(Game::XAssetHeader* header, std::string name, Components::ZoneBuilder::Zone* builder)
|
void IXModel::load(Game::XAssetHeader* header, std::string name, Components::ZoneBuilder::Zone* builder)
|
||||||
{
|
{
|
||||||
if(!builder->isPrimaryAsset())
|
if (!builder->isPrimaryAsset())
|
||||||
{
|
{
|
||||||
header->model = Components::AssetHandler::FindOriginalAsset(this->getType(), name.data()).model;
|
header->model = Components::AssetHandler::FindOriginalAsset(this->getType(), name.data()).model;
|
||||||
if (header->model) return;
|
if (header->model) return;
|
||||||
@ -98,7 +98,7 @@ namespace Assets
|
|||||||
Components::Logger::Error(0, "Reading model '%s' failed, expected version is %d, but it was %d!", name.data(), IW4X_MODEL_VERSION, version);
|
Components::Logger::Error(0, "Reading model '%s' failed, expected version is %d, but it was %d!", name.data(), IW4X_MODEL_VERSION, version);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(version == 4)
|
if (version == 4)
|
||||||
{
|
{
|
||||||
Components::Logger::Print("WARNING: Model '%s' is in legacy format, please update it!\n", name.data());
|
Components::Logger::Print("WARNING: Model '%s' is in legacy format, please update it!\n", name.data());
|
||||||
}
|
}
|
||||||
@ -222,7 +222,7 @@ namespace Assets
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
Game::PhysPreset* preset = Components::AssetHandler::FindAssetForZone(Game::XAssetType::ASSET_TYPE_PHYSPRESET, asset->physPreset->name, builder).physPreset;
|
Game::PhysPreset* preset = Components::AssetHandler::FindAssetForZone(Game::XAssetType::ASSET_TYPE_PHYSPRESET, asset->physPreset->name, builder).physPreset;
|
||||||
if(preset)
|
if (preset)
|
||||||
{
|
{
|
||||||
asset->physPreset = preset;
|
asset->physPreset = preset;
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,6 @@ namespace Assets
|
|||||||
private:
|
private:
|
||||||
void loadXModelSurfs(Game::XModelSurfs* asset, Utils::Stream::Reader* reader);
|
void loadXModelSurfs(Game::XModelSurfs* asset, Utils::Stream::Reader* reader);
|
||||||
void loadXSurface(Game::XSurface* surf, Utils::Stream::Reader* reader);
|
void loadXSurface(Game::XSurface* surf, Utils::Stream::Reader* reader);
|
||||||
void loadXSurfaceCollisionTree(Game::XSurfaceCollisionTree* entry, Utils::Stream::Reader* reader);
|
void loadXSurfaceCollisionTree(Game::XSurfaceCollisionTree* entry, Utils::Stream::Reader* reader);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,7 @@ namespace Assets
|
|||||||
if (surf->verts0)
|
if (surf->verts0)
|
||||||
{
|
{
|
||||||
AssertSize(Game::GfxPackedVertex, 32);
|
AssertSize(Game::GfxPackedVertex, 32);
|
||||||
|
|
||||||
buffer->align(Utils::Stream::ALIGN_16);
|
buffer->align(Utils::Stream::ALIGN_16);
|
||||||
buffer->saveArray(surf->verts0, surf->vertCount);
|
buffer->saveArray(surf->verts0, surf->vertCount);
|
||||||
Utils::Stream::ClearPointer(&destSurf->verts0);
|
Utils::Stream::ClearPointer(&destSurf->verts0);
|
||||||
|
@ -889,7 +889,7 @@ namespace Assets
|
|||||||
std::list<Game::TriggerSlab> slabs;
|
std::list<Game::TriggerSlab> slabs;
|
||||||
std::list<Game::TriggerHull> hulls;
|
std::list<Game::TriggerHull> hulls;
|
||||||
std::list<Game::TriggerModel> models;
|
std::list<Game::TriggerModel> models;
|
||||||
|
|
||||||
for (int i = 0; i < clipMap->numCModels; ++i)
|
for (int i = 0; i < clipMap->numCModels; ++i)
|
||||||
{
|
{
|
||||||
Game::cLeafBrushNode_t* node = &clipMap->cLeafBrushNodes[clipMap->cModels[i].leaf.leafBrushNode];
|
Game::cLeafBrushNode_t* node = &clipMap->cLeafBrushNodes[clipMap->cModels[i].leaf.leafBrushNode];
|
||||||
@ -907,7 +907,7 @@ namespace Assets
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// This mustn't be null and has to have at least 1 'valid' entry.
|
// This mustn't be null and has to have at least 1 'valid' entry.
|
||||||
if (!clipMap->smodelNodeCount || !clipMap->smodelNodes)
|
if (!clipMap->smodelNodeCount || !clipMap->smodelNodes)
|
||||||
{
|
{
|
||||||
@ -927,7 +927,7 @@ namespace Assets
|
|||||||
Utils::Stream::ClearPointer(&clipMap->dynEntCollList[i]);
|
Utils::Stream::ClearPointer(&clipMap->dynEntCollList[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!reader.end())
|
if (!reader.end())
|
||||||
{
|
{
|
||||||
Components::Logger::Error("Clipmap data left!");
|
Components::Logger::Error("Clipmap data left!");
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ namespace Assets
|
|||||||
{
|
{
|
||||||
builder->loadAsset(Game::XAssetType::ASSET_TYPE_MATERIAL, asset->window.background);
|
builder->loadAsset(Game::XAssetType::ASSET_TYPE_MATERIAL, asset->window.background);
|
||||||
}
|
}
|
||||||
|
|
||||||
// mark items
|
// mark items
|
||||||
for (int i = 0; i < asset->itemCount; ++i)
|
for (int i = 0; i < asset->itemCount; ++i)
|
||||||
{
|
{
|
||||||
|
@ -78,7 +78,7 @@ namespace Assets
|
|||||||
#define CHECK(x, type) (x.is_##type##() || x.is_null())
|
#define CHECK(x, type) (x.is_##type##() || x.is_null())
|
||||||
|
|
||||||
// TODO: actually support all of those properties
|
// TODO: actually support all of those properties
|
||||||
if (CHECK(type, string) && CHECK(subtitle, string) && CHECK(secondaryAliasName, string) && CHECK(chainAliasName, string) &&
|
if (CHECK(type, string) && CHECK(subtitle, string) && CHECK(secondaryAliasName, string) && CHECK(chainAliasName, string) &&
|
||||||
CHECK(soundFile, string) && CHECK(sequence, number) && CHECK(volMin, number) && CHECK(volMax, number) && CHECK(pitchMin, number) &&
|
CHECK(soundFile, string) && CHECK(sequence, number) && CHECK(volMin, number) && CHECK(volMax, number) && CHECK(pitchMin, number) &&
|
||||||
CHECK(pitchMax, number) && CHECK(distMin, number) && CHECK(distMax, number) && CHECK(flags, number) && CHECK(slavePercentage, number) &&
|
CHECK(pitchMax, number) && CHECK(distMin, number) && CHECK(distMax, number) && CHECK(flags, number) && CHECK(slavePercentage, number) &&
|
||||||
CHECK(probability, number) && CHECK(lfePercentage, number) && CHECK(centerPercentage, number) && CHECK(startDelay, number) &&
|
CHECK(probability, number) && CHECK(lfePercentage, number) && CHECK(centerPercentage, number) && CHECK(startDelay, number) &&
|
||||||
@ -117,7 +117,7 @@ namespace Assets
|
|||||||
alias->envelopMin = float(envelopMin.number_value());
|
alias->envelopMin = float(envelopMin.number_value());
|
||||||
alias->envelopMax = float(envelopMax.number_value());
|
alias->envelopMax = float(envelopMax.number_value());
|
||||||
alias->envelopPercentage = float(envelopPercentage.number_value());
|
alias->envelopPercentage = float(envelopPercentage.number_value());
|
||||||
|
|
||||||
if (volumeFalloffCurve.is_string())
|
if (volumeFalloffCurve.is_string())
|
||||||
{
|
{
|
||||||
alias->volumeFalloffCurve = Components::AssetHandler::FindAssetForZone(Game::XAssetType::ASSET_TYPE_SOUND_CURVE, volumeFalloffCurve.string_value(), builder).sndCurve;
|
alias->volumeFalloffCurve = Components::AssetHandler::FindAssetForZone(Game::XAssetType::ASSET_TYPE_SOUND_CURVE, volumeFalloffCurve.string_value(), builder).sndCurve;
|
||||||
@ -148,7 +148,7 @@ namespace Assets
|
|||||||
}
|
}
|
||||||
|
|
||||||
#undef CHECK
|
#undef CHECK
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Isnd_alias_list_t::mark(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder)
|
void Isnd_alias_list_t::mark(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder)
|
||||||
|
@ -183,7 +183,7 @@ namespace Components
|
|||||||
|
|
||||||
Bans::Bans()
|
Bans::Bans()
|
||||||
{
|
{
|
||||||
Command::Add("banclient", [] (Command::Params* params)
|
Command::Add("banclient", [](Command::Params* params)
|
||||||
{
|
{
|
||||||
if (params->length() < 2) return;
|
if (params->length() < 2) return;
|
||||||
|
|
||||||
@ -194,7 +194,7 @@ namespace Components
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Verify the list on startup
|
// Verify the list on startup
|
||||||
Scheduler::Once([] ()
|
Scheduler::Once([]()
|
||||||
{
|
{
|
||||||
Bans::BanList list;
|
Bans::BanList list;
|
||||||
Bans::LoadBans(&list);
|
Bans::LoadBans(&list);
|
||||||
|
@ -20,14 +20,14 @@ namespace Components
|
|||||||
{
|
{
|
||||||
returnResult += 0xFE000000;
|
returnResult += 0xFE000000;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (auto clientNum = 0; clientNum < 18; clientNum++)
|
for (auto clientNum = 0; clientNum < 18; clientNum++)
|
||||||
{
|
{
|
||||||
CClient* c = GetClientByIndex(clientNum);
|
CClient* c = GetClientByIndex(clientNum);
|
||||||
if (c != nullptr)
|
if (c != nullptr)
|
||||||
{
|
{
|
||||||
if (!strcmp(data->name, c->Name))
|
if (!strcmp(data->name, c->Name))
|
||||||
{
|
{
|
||||||
// Since a 4 byte integer is overkill for a row num: We can use it to store the customprefix + clientNum and use a 2 byte integer for the row number
|
// Since a 4 byte integer is overkill for a row num: We can use it to store the customprefix + clientNum and use a 2 byte integer for the row number
|
||||||
returnResult += 0xFF000000;
|
returnResult += 0xFF000000;
|
||||||
@ -43,7 +43,7 @@ namespace Components
|
|||||||
|
|
||||||
void __declspec(naked) CardTitles::GetPlayerCardClientInfoStub()
|
void __declspec(naked) CardTitles::GetPlayerCardClientInfoStub()
|
||||||
{
|
{
|
||||||
__asm
|
__asm
|
||||||
{
|
{
|
||||||
push eax
|
push eax
|
||||||
pushad
|
pushad
|
||||||
@ -59,7 +59,7 @@ namespace Components
|
|||||||
|
|
||||||
pop esi
|
pop esi
|
||||||
pop ebp
|
pop ebp
|
||||||
mov[ebx + 4], eax
|
mov [ebx + 4], eax
|
||||||
pop ebx
|
pop ebx
|
||||||
|
|
||||||
push 62EB2Ch
|
push 62EB2Ch
|
||||||
@ -69,8 +69,8 @@ namespace Components
|
|||||||
|
|
||||||
const char* CardTitles::TableLookupByRowHook(Game::Operand* operand, tablelookuprequest_s* request)
|
const char* CardTitles::TableLookupByRowHook(Game::Operand* operand, tablelookuprequest_s* request)
|
||||||
{
|
{
|
||||||
std::uint8_t prefix = (request->tableRow >> (8 * 3)) & 0xFF;
|
std::uint8_t prefix = (request->tableRow >> (8 * 3)) & 0xFF;
|
||||||
std::uint8_t data = (request->tableRow >> (8 * 2)) & 0xFF;
|
std::uint8_t data = (request->tableRow >> (8 * 2)) & 0xFF;
|
||||||
|
|
||||||
if (data >= ARRAYSIZE(CardTitles::CustomTitles)) return nullptr;
|
if (data >= ARRAYSIZE(CardTitles::CustomTitles)) return nullptr;
|
||||||
|
|
||||||
@ -121,7 +121,7 @@ namespace Components
|
|||||||
|
|
||||||
__declspec(naked) void CardTitles::TableLookupByRowHookStub()
|
__declspec(naked) void CardTitles::TableLookupByRowHookStub()
|
||||||
{
|
{
|
||||||
__asm
|
__asm
|
||||||
{
|
{
|
||||||
push eax
|
push eax
|
||||||
pushad
|
pushad
|
||||||
@ -153,7 +153,7 @@ namespace Components
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CardTitles::SendCustomTitlesToClients()
|
void CardTitles::SendCustomTitlesToClients()
|
||||||
{
|
{
|
||||||
std::string list;
|
std::string list;
|
||||||
|
|
||||||
@ -177,7 +177,7 @@ namespace Components
|
|||||||
Game::SV_GameSendServerCommand(-1, 0, command.data());
|
Game::SV_GameSendServerCommand(-1, 0, command.data());
|
||||||
}
|
}
|
||||||
|
|
||||||
void CardTitles::ParseCustomTitles(const char* msg)
|
void CardTitles::ParseCustomTitles(const char* msg)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < 18; ++i)
|
for (int i = 0; i < 18; ++i)
|
||||||
{
|
{
|
||||||
@ -210,7 +210,7 @@ namespace Components
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
for(int i = 0; i < ARRAYSIZE(CardTitles::CustomTitles); ++i)
|
for (int i = 0; i < ARRAYSIZE(CardTitles::CustomTitles); ++i)
|
||||||
{
|
{
|
||||||
CardTitles::CustomTitles[i].clear();
|
CardTitles::CustomTitles[i].clear();
|
||||||
}
|
}
|
||||||
|
@ -57,7 +57,7 @@ namespace Components
|
|||||||
UIFeeder::Add(62.0f, Changelog::GetChangelogCount, Changelog::GetChangelogText, Changelog::SelectChangelog);
|
UIFeeder::Add(62.0f, Changelog::GetChangelogCount, Changelog::GetChangelogText, Changelog::SelectChangelog);
|
||||||
|
|
||||||
#if !defined(DEBUG) && !defined(DISABLE_ANTICHEAT)
|
#if !defined(DEBUG) && !defined(DISABLE_ANTICHEAT)
|
||||||
Scheduler::OnFrame(AntiCheat::QuickCodeScanner_1);
|
Scheduler::OnFrame(AntiCheat::QuickCodeScanner1);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,20 +2,20 @@
|
|||||||
|
|
||||||
namespace Components
|
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++)
|
for (int i = 0; i < 18; i++)
|
||||||
{
|
{
|
||||||
const char* clantag = Game::Info_ValueForKey(infoString, std::to_string(i).data());
|
const char* clantag = Game::Info_ValueForKey(infoString, std::to_string(i).data());
|
||||||
|
|
||||||
if (clantag) Clantags::Tags[i] = clantag;
|
if (clantag) ClanTags::Tags[i] = clantag;
|
||||||
else Clantags::Tags[i].clear();
|
else ClanTags::Tags[i].clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Clantags::SendClantagsToClients()
|
void ClanTags::SendClantagsToClients()
|
||||||
{
|
{
|
||||||
std::string list;
|
std::string list;
|
||||||
|
|
||||||
@ -35,18 +35,18 @@ namespace Components
|
|||||||
Game::SV_GameSendServerCommand(-1, 0, command.data());
|
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 0
|
||||||
if (Clantags::Tags[clientnum].empty()) return playername;
|
if (ClanTags::Tags[clientnum].empty()) return playername;
|
||||||
return Utils::String::VA("[%s] %s", Clantags::Tags[clientnum].data(), playername);
|
return Utils::String::VA("[%s] %s", ClanTags::Tags[clientnum].data(), playername);
|
||||||
#else
|
#else
|
||||||
return playername;
|
return playername;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
__declspec(naked) void Clantags::DrawPlayerNameOnScoreboard()
|
__declspec(naked) void ClanTags::DrawPlayerNameOnScoreboard()
|
||||||
{
|
{
|
||||||
__asm
|
__asm
|
||||||
{
|
{
|
||||||
@ -70,7 +70,7 @@ namespace Components
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Clantags::Clantags()
|
ClanTags::ClanTags()
|
||||||
{
|
{
|
||||||
// Create clantag dvar
|
// Create clantag dvar
|
||||||
Dvar::OnInit([]()
|
Dvar::OnInit([]()
|
||||||
@ -85,7 +85,7 @@ namespace Components
|
|||||||
{
|
{
|
||||||
if (params->length() == 3)
|
if (params->length() == 3)
|
||||||
{
|
{
|
||||||
Clantags::ParseClantags(params->get(2));
|
ClanTags::ParseClantags(params->get(2));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -93,20 +93,20 @@ namespace Components
|
|||||||
return false;
|
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
|
// 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
|
namespace Components
|
||||||
{
|
{
|
||||||
class Clantags : public Component
|
class ClanTags : public Component
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static void ParseClantags(const char * infoString);
|
static void ParseClantags(const char * infoString);
|
||||||
static void SendClantagsToClients();
|
static void SendClantagsToClients();
|
||||||
static const char* GetUserClantag(std::uint32_t clientnum, const char * playername);
|
static const char* GetUserClantag(std::uint32_t clientnum, const char * playername);
|
||||||
|
|
||||||
Clantags();
|
ClanTags();
|
||||||
~Clantags();
|
~ClanTags();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static std::string Clantags::Tags[18];
|
static std::string ClanTags::Tags[18];
|
||||||
|
|
||||||
static void DrawPlayerNameOnScoreboard();
|
static void DrawPlayerNameOnScoreboard();
|
||||||
|
|
||||||
|
@ -109,7 +109,7 @@ namespace Components
|
|||||||
Game::CL_GetClientName(localClientNum, index, buf, size);
|
Game::CL_GetClientName(localClientNum, index, buf, size);
|
||||||
|
|
||||||
// Append clantag to username & remove the colors
|
// 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;
|
return buf;
|
||||||
}
|
}
|
||||||
|
@ -163,7 +163,7 @@ namespace Components
|
|||||||
// Disable native noclip command
|
// Disable native noclip command
|
||||||
Utils::Hook::Nop(0x474846, 5);
|
Utils::Hook::Nop(0x474846, 5);
|
||||||
|
|
||||||
Command::Add("noclip", [] (Command::Params*)
|
Command::Add("noclip", [](Command::Params*)
|
||||||
{
|
{
|
||||||
int clientNum = Game::CG_GetClientNum();
|
int clientNum = Game::CG_GetClientNum();
|
||||||
if (!Game::CL_IsCgameInitialized() || clientNum >= 18 || clientNum < 0 || !Game::g_entities[clientNum].client)
|
if (!Game::CL_IsCgameInitialized() || clientNum >= 18 || clientNum < 0 || !Game::g_entities[clientNum].client)
|
||||||
@ -186,7 +186,7 @@ namespace Components
|
|||||||
Toast::Show("cardicon_abduction", "Success", "Noclip toggled", 3000);
|
Toast::Show("cardicon_abduction", "Success", "Noclip toggled", 3000);
|
||||||
});
|
});
|
||||||
|
|
||||||
Command::Add("ufo", [] (Command::Params*)
|
Command::Add("ufo", [](Command::Params*)
|
||||||
{
|
{
|
||||||
int clientNum = Game::CG_GetClientNum();
|
int clientNum = Game::CG_GetClientNum();
|
||||||
if (!Game::CL_IsCgameInitialized() || clientNum >= 18 || clientNum < 0 || !Game::g_entities[clientNum].client)
|
if (!Game::CL_IsCgameInitialized() || clientNum >= 18 || clientNum < 0 || !Game::g_entities[clientNum].client)
|
||||||
@ -235,12 +235,12 @@ namespace Components
|
|||||||
|
|
||||||
float pos[3] = { 0.0f, 0.0f, 0.0f };
|
float pos[3] = { 0.0f, 0.0f, 0.0f };
|
||||||
float orientation[3] = { 0.0f, 0.0f, 0.0f };
|
float orientation[3] = { 0.0f, 0.0f, 0.0f };
|
||||||
|
|
||||||
pos[0] = strtof(params->get(1), nullptr);
|
pos[0] = strtof(params->get(1), nullptr);
|
||||||
pos[1] = strtof(params->get(2), nullptr);
|
pos[1] = strtof(params->get(2), nullptr);
|
||||||
pos[2] = strtof(params->get(3), nullptr);
|
pos[2] = strtof(params->get(3), nullptr);
|
||||||
|
|
||||||
if(params->length() == 6)
|
if (params->length() == 6)
|
||||||
{
|
{
|
||||||
orientation[0] = strtof(params->get(4), nullptr);
|
orientation[0] = strtof(params->get(4), nullptr);
|
||||||
orientation[1] = strtof(params->get(5), nullptr);
|
orientation[1] = strtof(params->get(5), nullptr);
|
||||||
|
@ -207,7 +207,7 @@ namespace Components
|
|||||||
if (Dedicated::IsEnabled()) return;
|
if (Dedicated::IsEnabled()) return;
|
||||||
|
|
||||||
// IPC handler
|
// IPC handler
|
||||||
IPCPipe::On("connect", [] (std::string data)
|
IPCPipe::On("connect", [](std::string data)
|
||||||
{
|
{
|
||||||
Command::Execute(Utils::String::VA("connect %s", data.data()), false);
|
Command::Execute(Utils::String::VA("connect %s", data.data()), false);
|
||||||
});
|
});
|
||||||
|
@ -75,7 +75,7 @@ namespace Components
|
|||||||
wprintw(Console::InfoWindow, "%s : %d/%d players : map %s", hostname.data(), clientCount, maxclientCount, (mapname.size() ? mapname.data() : "none"));
|
wprintw(Console::InfoWindow, "%s : %d/%d players : map %s", hostname.data(), clientCount, maxclientCount, (mapname.size() ? mapname.data() : "none"));
|
||||||
wnoutrefresh(Console::InfoWindow);
|
wnoutrefresh(Console::InfoWindow);
|
||||||
}
|
}
|
||||||
else if(IsWindow(Console::GetWindow()) != FALSE)
|
else if (IsWindow(Console::GetWindow()) != FALSE)
|
||||||
{
|
{
|
||||||
SetWindowTextA(Console::GetWindow(), Utils::String::VA("IW4x(" VERSION ") : %s", hostname.data()));
|
SetWindowTextA(Console::GetWindow(), Utils::String::VA("IW4x(" VERSION ") : %s", hostname.data()));
|
||||||
}
|
}
|
||||||
@ -603,7 +603,7 @@ namespace Components
|
|||||||
// Redirect input (]command)
|
// Redirect input (]command)
|
||||||
Utils::Hook(0x47025A, 0x4F5770, HOOK_CALL).install()->quick();
|
Utils::Hook(0x47025A, 0x4F5770, HOOK_CALL).install()->quick();
|
||||||
|
|
||||||
Utils::Hook(0x60BB68, [] ()
|
Utils::Hook(0x60BB68, []()
|
||||||
{
|
{
|
||||||
Console::ShowAsyncConsole();
|
Console::ShowAsyncConsole();
|
||||||
}, HOOK_CALL).install()->quick();
|
}, HOOK_CALL).install()->quick();
|
||||||
@ -621,7 +621,7 @@ namespace Components
|
|||||||
}
|
}
|
||||||
}, HOOK_CALL).install()->quick();
|
}, HOOK_CALL).install()->quick();
|
||||||
|
|
||||||
Scheduler::OnFrame([] ()
|
Scheduler::OnFrame([]()
|
||||||
{
|
{
|
||||||
Console::LastRefresh = Game::Sys_Milliseconds();
|
Console::LastRefresh = Game::Sys_Milliseconds();
|
||||||
});
|
});
|
||||||
|
@ -503,7 +503,7 @@ namespace Components
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for(int i = 0; i < ARRAYSIZE(Dedicated::PlayerGuids); ++i)
|
for (int i = 0; i < ARRAYSIZE(Dedicated::PlayerGuids); ++i)
|
||||||
{
|
{
|
||||||
Dedicated::PlayerGuids[i][0].bits = 0;
|
Dedicated::PlayerGuids[i][0].bits = 0;
|
||||||
Dedicated::PlayerGuids[i][1].bits = 0;
|
Dedicated::PlayerGuids[i][1].bits = 0;
|
||||||
@ -529,11 +529,11 @@ namespace Components
|
|||||||
|
|
||||||
Scheduler::OnFrame([]()
|
Scheduler::OnFrame([]()
|
||||||
{
|
{
|
||||||
if(Dvar::Var("sv_running").get<bool>())
|
if (Dvar::Var("sv_running").get<bool>())
|
||||||
{
|
{
|
||||||
static Utils::Time::Interval interval;
|
static Utils::Time::Interval interval;
|
||||||
|
|
||||||
if(interval.elapsed(15s))
|
if (interval.elapsed(15s))
|
||||||
{
|
{
|
||||||
interval.update();
|
interval.update();
|
||||||
Dedicated::TransmitGuids();
|
Dedicated::TransmitGuids();
|
||||||
|
@ -46,7 +46,7 @@ namespace Components
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Network::Handle("discovery", [] (Network::Address address, std::string data)
|
Network::Handle("discovery", [](Network::Address address, std::string data)
|
||||||
{
|
{
|
||||||
if (address.isSelf()) return;
|
if (address.isSelf()) return;
|
||||||
|
|
||||||
@ -60,7 +60,7 @@ namespace Components
|
|||||||
Network::SendCommand(address, "discoveryResponse", data);
|
Network::SendCommand(address, "discoveryResponse", data);
|
||||||
});
|
});
|
||||||
|
|
||||||
Network::Handle("discoveryResponse", [] (Network::Address address, std::string data)
|
Network::Handle("discoveryResponse", [](Network::Address address, std::string data)
|
||||||
{
|
{
|
||||||
if (address.isSelf()) return;
|
if (address.isSelf()) return;
|
||||||
|
|
||||||
@ -87,7 +87,7 @@ namespace Components
|
|||||||
// This is placed here in case the anticheat has been disabled!
|
// This is placed here in case the anticheat has been disabled!
|
||||||
// Make sure this is called after the memory scan!
|
// Make sure this is called after the memory scan!
|
||||||
#if !defined(DEBUG) && !defined(DISABLE_ANTICHEAT)
|
#if !defined(DEBUG) && !defined(DISABLE_ANTICHEAT)
|
||||||
Utils::Hook(0x5ACB9E, [] () // Somewhere in the renderer, past the scan check
|
Utils::Hook(0x5ACB9E, []() // Somewhere in the renderer, past the scan check
|
||||||
{
|
{
|
||||||
AntiCheat::ScanIntegrityCheck();
|
AntiCheat::ScanIntegrityCheck();
|
||||||
return Utils::Hook::Call<void()>(0x4AA720)();
|
return Utils::Hook::Call<void()>(0x4AA720)();
|
||||||
|
@ -303,7 +303,7 @@ namespace Components
|
|||||||
download->thread.detach();
|
download->thread.detach();
|
||||||
download->clear();
|
download->clear();
|
||||||
|
|
||||||
if(download->isMap)
|
if (download->isMap)
|
||||||
{
|
{
|
||||||
Scheduler::Once([]()
|
Scheduler::Once([]()
|
||||||
{
|
{
|
||||||
@ -381,7 +381,7 @@ namespace Components
|
|||||||
static json11::Json jsonList;
|
static json11::Json jsonList;
|
||||||
|
|
||||||
std::string mapname = Maps::GetUserMap()->getName();
|
std::string mapname = Maps::GetUserMap()->getName();
|
||||||
if(!Maps::GetUserMap()->isValid())
|
if (!Maps::GetUserMap()->isValid())
|
||||||
{
|
{
|
||||||
mapnamePre.clear();
|
mapnamePre.clear();
|
||||||
jsonList = std::vector<json11::Json>();
|
jsonList = std::vector<json11::Json>();
|
||||||
@ -514,14 +514,14 @@ namespace Components
|
|||||||
bool isValidFile = false;
|
bool isValidFile = false;
|
||||||
for (int i = 0; i < ARRAYSIZE(Maps::UserMapFiles); ++i)
|
for (int i = 0; i < ARRAYSIZE(Maps::UserMapFiles); ++i)
|
||||||
{
|
{
|
||||||
if(url == (mapname + Maps::UserMapFiles[i]))
|
if (url == (mapname + Maps::UserMapFiles[i]))
|
||||||
{
|
{
|
||||||
isValidFile = true;
|
isValidFile = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!Maps::GetUserMap()->isValid() || !isValidFile)
|
if (!Maps::GetUserMap()->isValid() || !isValidFile)
|
||||||
{
|
{
|
||||||
Download::Forbid(nc);
|
Download::Forbid(nc);
|
||||||
return;
|
return;
|
||||||
@ -710,7 +710,7 @@ namespace Components
|
|||||||
ZeroMemory(&Download::Mgr, sizeof Download::Mgr);
|
ZeroMemory(&Download::Mgr, sizeof Download::Mgr);
|
||||||
mg_mgr_init(&Download::Mgr, nullptr);
|
mg_mgr_init(&Download::Mgr, nullptr);
|
||||||
|
|
||||||
Network::OnStart([] ()
|
Network::OnStart([]()
|
||||||
{
|
{
|
||||||
mg_connection* nc = mg_bind(&Download::Mgr, Utils::String::VA("%hu", Network::GetPort()), Download::EventHandler);
|
mg_connection* nc = mg_bind(&Download::Mgr, Utils::String::VA("%hu", Network::GetPort()), Download::EventHandler);
|
||||||
|
|
||||||
@ -719,7 +719,7 @@ namespace Components
|
|||||||
// Handle special requests
|
// Handle special requests
|
||||||
mg_register_http_endpoint(nc, "/info", Download::InfoHandler);
|
mg_register_http_endpoint(nc, "/info", Download::InfoHandler);
|
||||||
mg_register_http_endpoint(nc, "/list", Download::ListHandler);
|
mg_register_http_endpoint(nc, "/list", Download::ListHandler);
|
||||||
mg_register_http_endpoint(nc, "/map", Download::MapHandler);
|
mg_register_http_endpoint(nc, "/map", Download::MapHandler);
|
||||||
mg_register_http_endpoint(nc, "/file/", Download::FileHandler);
|
mg_register_http_endpoint(nc, "/file/", Download::FileHandler);
|
||||||
|
|
||||||
mg_set_protocol_http_websocket(nc);
|
mg_set_protocol_http_websocket(nc);
|
||||||
@ -748,7 +748,7 @@ namespace Components
|
|||||||
Dvar::Register<const char*>("ui_dl_transRate", "", Game::dvar_flag::DVAR_FLAG_NONE, "");
|
Dvar::Register<const char*>("ui_dl_transRate", "", Game::dvar_flag::DVAR_FLAG_NONE, "");
|
||||||
});
|
});
|
||||||
|
|
||||||
UIScript::Add("mod_download_cancel", [] (UIScript::Token)
|
UIScript::Add("mod_download_cancel", [](UIScript::Token)
|
||||||
{
|
{
|
||||||
Download::CLDownload.clear();
|
Download::CLDownload.clear();
|
||||||
});
|
});
|
||||||
@ -758,11 +758,11 @@ namespace Components
|
|||||||
{
|
{
|
||||||
int workingCount = 0;
|
int workingCount = 0;
|
||||||
|
|
||||||
for(auto i = Download::ScriptDownloads.begin(); i != Download::ScriptDownloads.end();)
|
for (auto i = Download::ScriptDownloads.begin(); i != Download::ScriptDownloads.end();)
|
||||||
{
|
{
|
||||||
auto download = *i;
|
auto download = *i;
|
||||||
|
|
||||||
if(download->isDone())
|
if (download->isDone())
|
||||||
{
|
{
|
||||||
download->notifyDone();
|
download->notifyDone();
|
||||||
i = Download::ScriptDownloads.erase(i);
|
i = Download::ScriptDownloads.erase(i);
|
||||||
@ -778,10 +778,10 @@ namespace Components
|
|||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(auto& download : Download::ScriptDownloads)
|
for (auto& download : Download::ScriptDownloads)
|
||||||
{
|
{
|
||||||
if (workingCount > 5) break;
|
if (workingCount > 5) break;
|
||||||
if(!download->isWorking())
|
if (!download->isWorking())
|
||||||
{
|
{
|
||||||
download->startWorking();
|
download->startWorking();
|
||||||
++workingCount;
|
++workingCount;
|
||||||
|
@ -99,7 +99,7 @@ namespace Components
|
|||||||
this->object = 0;
|
this->object = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(this->workerThread.joinable())
|
if (this->workerThread.joinable())
|
||||||
{
|
{
|
||||||
this->workerThread.join();
|
this->workerThread.join();
|
||||||
}
|
}
|
||||||
@ -109,7 +109,7 @@ namespace Components
|
|||||||
|
|
||||||
void startWorking()
|
void startWorking()
|
||||||
{
|
{
|
||||||
if(!this->isWorking())
|
if (!this->isWorking())
|
||||||
{
|
{
|
||||||
this->workerThread = std::thread(std::bind(&ScriptDownload::handler, this));
|
this->workerThread = std::thread(std::bind(&ScriptDownload::handler, this));
|
||||||
}
|
}
|
||||||
@ -161,7 +161,7 @@ namespace Components
|
|||||||
|
|
||||||
void cancel()
|
void cancel()
|
||||||
{
|
{
|
||||||
if(this->webIO)
|
if (this->webIO)
|
||||||
{
|
{
|
||||||
this->webIO->cancelDownload();
|
this->webIO->cancelDownload();
|
||||||
}
|
}
|
||||||
|
@ -142,7 +142,7 @@ namespace Components
|
|||||||
Dvar::RegistrationSignal();
|
Dvar::RegistrationSignal();
|
||||||
|
|
||||||
// Name watcher
|
// Name watcher
|
||||||
Scheduler::OnFrame([] ()
|
Scheduler::OnFrame([]()
|
||||||
{
|
{
|
||||||
static std::string lastValidName = "Unknown Soldier";
|
static std::string lastValidName = "Unknown Soldier";
|
||||||
std::string name = Dvar::Var("name").get<char*>();
|
std::string name = Dvar::Var("name").get<char*>();
|
||||||
|
@ -8,7 +8,7 @@ namespace Components
|
|||||||
class Flag
|
class Flag
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Flag(Game::dvar_flag flag) : val(flag){};
|
Flag(Game::dvar_flag flag) : val(flag) {};
|
||||||
Flag(int flag) : Flag(static_cast<Game::dvar_flag>(flag)) {};
|
Flag(int flag) : Flag(static_cast<Game::dvar_flag>(flag)) {};
|
||||||
|
|
||||||
Game::dvar_flag val;
|
Game::dvar_flag val;
|
||||||
|
@ -25,7 +25,7 @@ namespace Components
|
|||||||
{
|
{
|
||||||
FreeConsole();
|
FreeConsole();
|
||||||
|
|
||||||
if(IsWindow(Console::GetWindow()) != FALSE)
|
if (IsWindow(Console::GetWindow()) != FALSE)
|
||||||
{
|
{
|
||||||
CloseWindow(Console::GetWindow());
|
CloseWindow(Console::GetWindow());
|
||||||
DestroyWindow(Console::GetWindow());
|
DestroyWindow(Console::GetWindow());
|
||||||
@ -81,10 +81,10 @@ namespace Components
|
|||||||
bool doFullDump = Flags::HasFlag("bigdumps") || Flags::HasFlag("reallybigdumps");
|
bool doFullDump = Flags::HasFlag("bigdumps") || Flags::HasFlag("reallybigdumps");
|
||||||
/*if (!doFullDump)
|
/*if (!doFullDump)
|
||||||
{
|
{
|
||||||
if (MessageBoxA(nullptr,
|
if (MessageBoxA(nullptr,
|
||||||
Utils::String::VA("%s\n\n" // errorStr
|
Utils::String::VA("%s\n\n" // errorStr
|
||||||
"Would you like to create a full crash dump for the developers (this can be 100mb or more)?\nNo will create small dumps that are automatically uploaded.", errorStr),
|
"Would you like to create a full crash dump for the developers (this can be 100mb or more)?\nNo will create small dumps that are automatically uploaded.", errorStr),
|
||||||
"IW4x Error!", MB_YESNO | MB_ICONERROR) == IDYES)
|
"IW4x Error!", MB_YESNO | MB_ICONERROR) == IDYES)
|
||||||
{
|
{
|
||||||
doFullDump = true;
|
doFullDump = true;
|
||||||
}
|
}
|
||||||
@ -217,7 +217,7 @@ namespace Components
|
|||||||
Command::Execute(command, false);
|
Command::Execute(command, false);
|
||||||
});
|
});
|
||||||
|
|
||||||
Command::Add("debug_exceptionhandler", [] (Command::Params*)
|
Command::Add("debug_exceptionhandler", [](Command::Params*)
|
||||||
{
|
{
|
||||||
Logger::Print("Rerunning SetUnhandledExceptionHandler...\n");
|
Logger::Print("Rerunning SetUnhandledExceptionHandler...\n");
|
||||||
auto oldHandler = Exception::Hook();
|
auto oldHandler = Exception::Hook();
|
||||||
@ -272,7 +272,7 @@ namespace Components
|
|||||||
#pragma warning(pop)
|
#pragma warning(pop)
|
||||||
|
|
||||||
// Check if folder exists && crash-helper exists
|
// Check if folder exists && crash-helper exists
|
||||||
|
|
||||||
if (Utils::IO::DirectoryExists("minidumps\\") && Utils::IO::FileExists("crash-helper.exe"))
|
if (Utils::IO::DirectoryExists("minidumps\\") && Utils::IO::FileExists("crash-helper.exe"))
|
||||||
{
|
{
|
||||||
if (!Utils::IO::DirectoryIsEmpty("minidumps\\"))
|
if (!Utils::IO::DirectoryIsEmpty("minidumps\\"))
|
||||||
|
@ -234,17 +234,17 @@ namespace Components
|
|||||||
{
|
{
|
||||||
const char* dir = Dvar::Var("fs_basepath").get<const char*>();
|
const char* dir = Dvar::Var("fs_basepath").get<const char*>();
|
||||||
|
|
||||||
std::vector<std::string> paths;
|
std::vector<std::string> paths;
|
||||||
std::string modDir = Dvar::Var("fs_game").get<std::string>();
|
std::string modDir = Dvar::Var("fs_game").get<std::string>();
|
||||||
if ((file == "mod"s || file == "mod.ff"s) && !modDir.empty())
|
if ((file == "mod"s || file == "mod.ff"s) && !modDir.empty())
|
||||||
{
|
{
|
||||||
paths.push_back(Utils::String::VA("%s\\", modDir.data()));
|
paths.push_back(Utils::String::VA("%s\\", modDir.data()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Utils::String::StartsWith(file, "mp_"))
|
if (Utils::String::StartsWith(file, "mp_"))
|
||||||
{
|
{
|
||||||
std::string zone = file;
|
std::string zone = file;
|
||||||
if(Utils::String::EndsWith(zone, ".ff"))
|
if (Utils::String::EndsWith(zone, ".ff"))
|
||||||
{
|
{
|
||||||
Utils::String::Replace(zone, ".ff", "");
|
Utils::String::Replace(zone, ".ff", "");
|
||||||
}
|
}
|
||||||
@ -256,14 +256,14 @@ namespace Components
|
|||||||
Utils::String::Replace(zone, "_load", "");
|
Utils::String::Replace(zone, "_load", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Utils::IO::FileExists(Utils::String::VA("usermaps\\%s\\%s.ff", zone.data(), filename.data())))
|
if (Utils::IO::FileExists(Utils::String::VA("usermaps\\%s\\%s.ff", zone.data(), filename.data())))
|
||||||
{
|
{
|
||||||
return Utils::String::VA("usermaps\\%s\\", zone.data());
|
return Utils::String::VA("usermaps\\%s\\", zone.data());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Utils::Merge(&paths, FastFiles::ZonePaths);
|
Utils::Merge(&paths, FastFiles::ZonePaths);
|
||||||
|
|
||||||
for (auto &path : paths)
|
for (auto &path : paths)
|
||||||
{
|
{
|
||||||
std::string absoluteFile = Utils::String::VA("%s\\%s%s", dir, path.data(), file);
|
std::string absoluteFile = Utils::String::VA("%s\\%s%s", dir, path.data(), file);
|
||||||
@ -458,9 +458,9 @@ namespace Components
|
|||||||
{
|
{
|
||||||
FastFiles::ReadXFile(buffer, size);
|
FastFiles::ReadXFile(buffer, size);
|
||||||
|
|
||||||
if(FastFiles::IsIW4xZone)
|
if (FastFiles::IsIW4xZone)
|
||||||
{
|
{
|
||||||
for(int i = 0; i < size; ++i)
|
for (int i = 0; i < size; ++i)
|
||||||
{
|
{
|
||||||
buffer[i] ^= FastFiles::LastByteRead;
|
buffer[i] ^= FastFiles::LastByteRead;
|
||||||
Utils::RotLeft(buffer[i], 4);
|
Utils::RotLeft(buffer[i], 4);
|
||||||
@ -564,14 +564,14 @@ namespace Components
|
|||||||
FastFiles::AddZonePath("zone\\patch\\");
|
FastFiles::AddZonePath("zone\\patch\\");
|
||||||
FastFiles::AddZonePath("zone\\dlc\\");
|
FastFiles::AddZonePath("zone\\dlc\\");
|
||||||
|
|
||||||
Scheduler::OnFrame([] ()
|
Scheduler::OnFrame([]()
|
||||||
{
|
{
|
||||||
if (FastFiles::Current().empty() || !Dvar::Var("ui_zoneDebug").get<bool>()) return;
|
if (FastFiles::Current().empty() || !Dvar::Var("ui_zoneDebug").get<bool>()) return;
|
||||||
|
|
||||||
Game::Font* font = Game::R_RegisterFont("fonts/consoleFont", 0);
|
Game::Font* font = Game::R_RegisterFont("fonts/consoleFont", 0);
|
||||||
float color[4] = { 1.0f, 1.0f, 1.0f, (Game::CL_IsCgameInitialized() ? 0.3f : 1.0f) };
|
float color[4] = { 1.0f, 1.0f, 1.0f, (Game::CL_IsCgameInitialized() ? 0.3f : 1.0f) };
|
||||||
|
|
||||||
std::uint32_t FFTotalSize = *reinterpret_cast<std::uint32_t*>(0x10AA5D8);
|
std::uint32_t FFTotalSize = *reinterpret_cast<std::uint32_t*>(0x10AA5D8);
|
||||||
std::uint32_t FFCurrentOffset = *reinterpret_cast<std::uint32_t*>(0x10AA608);
|
std::uint32_t FFCurrentOffset = *reinterpret_cast<std::uint32_t*>(0x10AA608);
|
||||||
|
|
||||||
float fastfileLoadProgress = (float(FFCurrentOffset) / float(FFTotalSize)) * 100.0f;
|
float fastfileLoadProgress = (float(FFCurrentOffset) / float(FFTotalSize)) * 100.0f;
|
||||||
@ -587,7 +587,7 @@ namespace Components
|
|||||||
Game::R_AddCmdDrawText(Utils::String::VA("Loading FastFile: %s [%0.1f%%]", FastFiles::Current().data(), fastfileLoadProgress), 0x7FFFFFFF, font, 5.0f, static_cast<float>(Renderer::Height() - 5), 1.0f, 1.0f, 0.0f, color, Game::ITEM_TEXTSTYLE_NORMAL);
|
Game::R_AddCmdDrawText(Utils::String::VA("Loading FastFile: %s [%0.1f%%]", FastFiles::Current().data(), fastfileLoadProgress), 0x7FFFFFFF, font, 5.0f, static_cast<float>(Renderer::Height() - 5), 1.0f, 1.0f, 0.0f, color, Game::ITEM_TEXTSTYLE_NORMAL);
|
||||||
}, true);
|
}, true);
|
||||||
|
|
||||||
Command::Add("loadzone", [] (Command::Params* params)
|
Command::Add("loadzone", [](Command::Params* params)
|
||||||
{
|
{
|
||||||
if (params->length() < 2) return;
|
if (params->length() < 2) return;
|
||||||
|
|
||||||
|
@ -253,7 +253,7 @@ namespace Components
|
|||||||
{
|
{
|
||||||
bool result = !File(execFilename).exists();
|
bool result = !File(execFilename).exists();
|
||||||
|
|
||||||
if(execFilename =="mp/stats_init.cfg"s)
|
if (execFilename == "mp/stats_init.cfg"s)
|
||||||
{
|
{
|
||||||
OutputDebugStringA("");
|
OutputDebugStringA("");
|
||||||
}
|
}
|
||||||
|
@ -104,7 +104,7 @@ namespace Components
|
|||||||
call FrameTime::ComFrameWait
|
call FrameTime::ComFrameWait
|
||||||
add esp, 4
|
add esp, 4
|
||||||
|
|
||||||
mov[esp + 20h], eax
|
mov [esp + 20h], eax
|
||||||
popad
|
popad
|
||||||
pop eax
|
pop eax
|
||||||
mov ecx, eax
|
mov ecx, eax
|
||||||
|
@ -21,7 +21,7 @@ namespace Components
|
|||||||
|
|
||||||
void Friends::SortList(bool force)
|
void Friends::SortList(bool force)
|
||||||
{
|
{
|
||||||
if(!force)
|
if (!force)
|
||||||
{
|
{
|
||||||
Friends::TriggerSort = true;
|
Friends::TriggerSort = true;
|
||||||
return;
|
return;
|
||||||
@ -35,10 +35,10 @@ namespace Components
|
|||||||
std::vector<Friends::Friend> offlineList;
|
std::vector<Friends::Friend> offlineList;
|
||||||
|
|
||||||
// Split up the list
|
// Split up the list
|
||||||
for(auto entry : Friends::FriendsList)
|
for (auto entry : Friends::FriendsList)
|
||||||
{
|
{
|
||||||
if(!entry.online) offlineList.push_back(entry);
|
if (!entry.online) offlineList.push_back(entry);
|
||||||
else if(!Friends::IsOnline(entry.lastTime)) onlineList.push_back(entry);
|
else if (!Friends::IsOnline(entry.lastTime)) onlineList.push_back(entry);
|
||||||
else if (entry.server.getType() == Game::NA_BAD) playingList.push_back(entry);
|
else if (entry.server.getType() == Game::NA_BAD) playingList.push_back(entry);
|
||||||
else connectedList.push_back(entry);
|
else connectedList.push_back(entry);
|
||||||
}
|
}
|
||||||
@ -126,7 +126,7 @@ namespace Components
|
|||||||
{
|
{
|
||||||
if (Dvar::Var("cl_anonymous").get<bool>() || !Steam::Enabled()) return;
|
if (Dvar::Var("cl_anonymous").get<bool>() || !Steam::Enabled()) return;
|
||||||
|
|
||||||
if(force)
|
if (force)
|
||||||
{
|
{
|
||||||
if (Steam::Proxy::ClientFriends && Steam::Proxy::SteamFriends)
|
if (Steam::Proxy::ClientFriends && Steam::Proxy::SteamFriends)
|
||||||
{
|
{
|
||||||
@ -144,9 +144,9 @@ namespace Components
|
|||||||
{
|
{
|
||||||
std::lock_guard<std::recursive_mutex> _(Friends::Mutex);
|
std::lock_guard<std::recursive_mutex> _(Friends::Mutex);
|
||||||
|
|
||||||
for(auto& entry : Friends::FriendsList)
|
for (auto& entry : Friends::FriendsList)
|
||||||
{
|
{
|
||||||
if(entry.server == server)
|
if (entry.server == server)
|
||||||
{
|
{
|
||||||
entry.serverName = hostname;
|
entry.serverName = hostname;
|
||||||
entry.mapname = mapname;
|
entry.mapname = mapname;
|
||||||
@ -164,9 +164,9 @@ namespace Components
|
|||||||
{
|
{
|
||||||
std::vector<int> ids;
|
std::vector<int> ids;
|
||||||
|
|
||||||
auto addId = [&](int id)
|
const auto addId = [&](int id)
|
||||||
{
|
{
|
||||||
if(std::find(ids.begin(), ids.end(), id) == ids.end())
|
if (std::find(ids.begin(), ids.end(), id) == ids.end())
|
||||||
{
|
{
|
||||||
ids.push_back(id);
|
ids.push_back(id);
|
||||||
}
|
}
|
||||||
@ -182,18 +182,17 @@ namespace Components
|
|||||||
addId(Steam::Proxy::SteamUtils->GetAppID());
|
addId(Steam::Proxy::SteamUtils->GetAppID());
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Steam::Proxy::SteamFriends)
|
if (Steam::Proxy::SteamFriends)
|
||||||
{
|
{
|
||||||
std::lock_guard<std::recursive_mutex> _(Friends::Mutex);
|
std::lock_guard<std::recursive_mutex> _(Friends::Mutex);
|
||||||
|
|
||||||
char* mod = "IW4x";
|
const unsigned int modId = *reinterpret_cast<unsigned int*>("IW4x") | 0x80000000;
|
||||||
unsigned int modId = *reinterpret_cast<unsigned int*>(mod) | 0x80000000;
|
|
||||||
|
|
||||||
// Split up the list
|
// Split up the list
|
||||||
for (auto entry : Friends::FriendsList)
|
for (auto entry : Friends::FriendsList)
|
||||||
{
|
{
|
||||||
Steam::FriendGameInfo info;
|
Steam::FriendGameInfo info;
|
||||||
if(Steam::Proxy::SteamFriends->GetFriendGamePlayed(entry.userId, &info) && info.m_gameID.modID == modId)
|
if (Steam::Proxy::SteamFriends->GetFriendGamePlayed(entry.userId, &info) && info.m_gameID.modID == modId)
|
||||||
{
|
{
|
||||||
addId(info.m_gameID.appID);
|
addId(info.m_gameID.appID);
|
||||||
}
|
}
|
||||||
@ -237,7 +236,7 @@ namespace Components
|
|||||||
|
|
||||||
void Friends::RequestPresence(SteamID user)
|
void Friends::RequestPresence(SteamID user)
|
||||||
{
|
{
|
||||||
if(Steam::Proxy::ClientFriends)
|
if (Steam::Proxy::ClientFriends)
|
||||||
{
|
{
|
||||||
Steam::Proxy::ClientFriends.invoke<void>("RequestFriendRichPresence", Friends::GetGame(user), user);
|
Steam::Proxy::ClientFriends.invoke<void>("RequestFriendRichPresence", Friends::GetGame(user), user);
|
||||||
}
|
}
|
||||||
@ -289,7 +288,7 @@ namespace Components
|
|||||||
int prestige = Game::Live_GetPrestige(0);
|
int prestige = Game::Live_GetPrestige(0);
|
||||||
int level = (experience & 0xFFFFFF) | ((prestige & 0xFF) << 24);
|
int level = (experience & 0xFFFFFF) | ((prestige & 0xFF) << 24);
|
||||||
|
|
||||||
if(!levelVal.has_value() || levelVal.value() != level)
|
if (!levelVal.has_value() || levelVal.value() != level)
|
||||||
{
|
{
|
||||||
levelVal.emplace(level);
|
levelVal.emplace(level);
|
||||||
|
|
||||||
@ -328,9 +327,9 @@ namespace Components
|
|||||||
entry.experience = 0;
|
entry.experience = 0;
|
||||||
entry.server.setType(Game::NA_BAD);
|
entry.server.setType(Game::NA_BAD);
|
||||||
|
|
||||||
for(auto storedFriend : list.friends())
|
for (auto storedFriend : list.friends())
|
||||||
{
|
{
|
||||||
if(entry.userId.bits == strtoull(storedFriend.steamid().data(), nullptr, 16))
|
if (entry.userId.bits == strtoull(storedFriend.steamid().data(), nullptr, 16))
|
||||||
{
|
{
|
||||||
entry.playerName = storedFriend.name();
|
entry.playerName = storedFriend.name();
|
||||||
entry.experience = storedFriend.experience();
|
entry.experience = storedFriend.experience();
|
||||||
@ -351,7 +350,7 @@ namespace Components
|
|||||||
steamFriends.push_back(entry);
|
steamFriends.push_back(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(auto i = Friends::FriendsList.begin(); i != Friends::FriendsList.end();)
|
for (auto i = Friends::FriendsList.begin(); i != Friends::FriendsList.end();)
|
||||||
{
|
{
|
||||||
SteamID id = i->userId;
|
SteamID id = i->userId;
|
||||||
|
|
||||||
@ -360,7 +359,7 @@ namespace Components
|
|||||||
return (entry.userId.bits == id.bits);
|
return (entry.userId.bits == id.bits);
|
||||||
});
|
});
|
||||||
|
|
||||||
if(oldEntry == steamFriends.end())
|
if (oldEntry == steamFriends.end())
|
||||||
{
|
{
|
||||||
i = Friends::FriendsList.erase(i);
|
i = Friends::FriendsList.erase(i);
|
||||||
}
|
}
|
||||||
@ -387,7 +386,7 @@ namespace Components
|
|||||||
|
|
||||||
auto user = Friends::FriendsList[index];
|
auto user = Friends::FriendsList[index];
|
||||||
|
|
||||||
switch(column)
|
switch (column)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
{
|
{
|
||||||
@ -431,7 +430,7 @@ namespace Components
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
case 2:
|
case 2:
|
||||||
{
|
{
|
||||||
if (!user.online) return "Offline";
|
if (!user.online) return "Offline";
|
||||||
if (!Friends::IsOnline(user.lastTime)) return "Online";
|
if (!Friends::IsOnline(user.lastTime)) return "Online";
|
||||||
if (user.server.getType() == Game::NA_BAD) return "Playing IW4x";
|
if (user.server.getType() == Game::NA_BAD) return "Playing IW4x";
|
||||||
@ -469,9 +468,9 @@ namespace Components
|
|||||||
|
|
||||||
void Friends::AddFriend(SteamID user)
|
void Friends::AddFriend(SteamID user)
|
||||||
{
|
{
|
||||||
if(Steam::Proxy::ClientFriends && Steam::Proxy::SteamFriends)
|
if (Steam::Proxy::ClientFriends && Steam::Proxy::SteamFriends)
|
||||||
{
|
{
|
||||||
if(Steam::Proxy::ClientFriends.invoke<bool>("AddFriend", user))
|
if (Steam::Proxy::ClientFriends.invoke<bool>("AddFriend", user))
|
||||||
{
|
{
|
||||||
Toast::Show("cardicon_joystick", Steam::Proxy::SteamFriends->GetFriendPersonaName(user), "friend request sent", 3000);
|
Toast::Show("cardicon_joystick", Steam::Proxy::SteamFriends->GetFriendPersonaName(user), "friend request sent", 3000);
|
||||||
}
|
}
|
||||||
@ -517,7 +516,7 @@ namespace Components
|
|||||||
if (!Friends::LoggedOn) return;
|
if (!Friends::LoggedOn) return;
|
||||||
|
|
||||||
Proto::Friends::List list;
|
Proto::Friends::List list;
|
||||||
for(auto entry : Friends::FriendsList)
|
for (auto entry : Friends::FriendsList)
|
||||||
{
|
{
|
||||||
Proto::Friends::Friend* friendEntry = list.add_friends();
|
Proto::Friends::Friend* friendEntry = list.add_friends();
|
||||||
|
|
||||||
@ -622,7 +621,7 @@ namespace Components
|
|||||||
|
|
||||||
auto& user = Friends::FriendsList[Friends::CurrentFriend];
|
auto& user = Friends::FriendsList[Friends::CurrentFriend];
|
||||||
|
|
||||||
if(user.online && user.server.getType() != Game::NA_BAD)
|
if (user.online && user.server.getType() != Game::NA_BAD)
|
||||||
{
|
{
|
||||||
Party::Connect(user.server);
|
Party::Connect(user.server);
|
||||||
}
|
}
|
||||||
@ -650,18 +649,18 @@ namespace Components
|
|||||||
Friends::UpdateState();
|
Friends::UpdateState();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(stateInterval.elapsed(5s))
|
if (stateInterval.elapsed(5s))
|
||||||
{
|
{
|
||||||
stateInterval.update();
|
stateInterval.update();
|
||||||
|
|
||||||
if(Friends::TriggerUpdate)
|
if (Friends::TriggerUpdate)
|
||||||
{
|
{
|
||||||
Friends::TriggerUpdate = false;
|
Friends::TriggerUpdate = false;
|
||||||
Friends::UpdateState(true);
|
Friends::UpdateState(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(sortInterval.elapsed(1s))
|
if (sortInterval.elapsed(1s))
|
||||||
{
|
{
|
||||||
sortInterval.update();
|
sortInterval.update();
|
||||||
|
|
||||||
@ -687,7 +686,7 @@ namespace Components
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if(Steam::Proxy::ClientFriends)
|
if (Steam::Proxy::ClientFriends)
|
||||||
{
|
{
|
||||||
Steam::Proxy::ClientFriends.invoke<void>("SetPersonaState", Friends::InitialState);
|
Steam::Proxy::ClientFriends.invoke<void>("SetPersonaState", Friends::InitialState);
|
||||||
}
|
}
|
||||||
@ -700,7 +699,7 @@ namespace Components
|
|||||||
Friends::InitialState = Steam::Proxy::SteamFriends->GetPersonaState();
|
Friends::InitialState = Steam::Proxy::SteamFriends->GetPersonaState();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Dvar::Var("cl_anonymous").get<bool>() || !Steam::Enabled())
|
if (Dvar::Var("cl_anonymous").get<bool>() || !Steam::Enabled())
|
||||||
{
|
{
|
||||||
if (Steam::Proxy::ClientFriends)
|
if (Steam::Proxy::ClientFriends)
|
||||||
{
|
{
|
||||||
@ -710,7 +709,7 @@ namespace Components
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Steam::Proxy::SteamFriends)
|
if (Steam::Proxy::SteamFriends)
|
||||||
{
|
{
|
||||||
Steam::Proxy::SteamFriends->ClearRichPresence();
|
Steam::Proxy::SteamFriends->ClearRichPresence();
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ namespace Components
|
|||||||
{
|
{
|
||||||
std::vector<std::string> gametypes;
|
std::vector<std::string> gametypes;
|
||||||
|
|
||||||
auto pushGametype = [&] (std::string gametype)
|
auto pushGametype = [&](std::string gametype)
|
||||||
{
|
{
|
||||||
auto pos = gametype.find_last_of("/\\");
|
auto pos = gametype.find_last_of("/\\");
|
||||||
if (pos != std::string::npos)
|
if (pos != std::string::npos)
|
||||||
@ -58,7 +58,7 @@ namespace Components
|
|||||||
std::vector<std::string> rawGametypes = FileSystem::GetFileList("maps/mp/gametypes/", "txt");
|
std::vector<std::string> rawGametypes = FileSystem::GetFileList("maps/mp/gametypes/", "txt");
|
||||||
|
|
||||||
// Get the gametypes we can find in the database
|
// Get the gametypes we can find in the database
|
||||||
Game::DB_EnumXAssets(Game::XAssetType::ASSET_TYPE_RAWFILE, [] (Game::XAssetHeader header, void* data)
|
Game::DB_EnumXAssets(Game::XAssetType::ASSET_TYPE_RAWFILE, [](Game::XAssetHeader header, void* data)
|
||||||
{
|
{
|
||||||
std::string name = header.rawfile->name;
|
std::string name = header.rawfile->name;
|
||||||
std::vector<std::string>* rawGametypes = reinterpret_cast<std::vector<std::string>*>(data);
|
std::vector<std::string>* rawGametypes = reinterpret_cast<std::vector<std::string>*>(data);
|
||||||
@ -102,7 +102,7 @@ namespace Components
|
|||||||
// This is placed here in case the anticheat has been disabled!
|
// This is placed here in case the anticheat has been disabled!
|
||||||
// Make sure this is called after every onther anticheat check!
|
// Make sure this is called after every onther anticheat check!
|
||||||
#if !defined(DEBUG) && !defined(DISABLE_ANTICHEAT)
|
#if !defined(DEBUG) && !defined(DISABLE_ANTICHEAT)
|
||||||
Utils::Hook(0x5ACBA3, [] () // Somewhere in the renderer, past other renderer hooks!
|
Utils::Hook(0x5ACBA3, []() // Somewhere in the renderer, past other renderer hooks!
|
||||||
{
|
{
|
||||||
AntiCheat::FlagIntegrityCheck();
|
AntiCheat::FlagIntegrityCheck();
|
||||||
return Utils::Hook::Call<void()>(0x50AB20)();
|
return Utils::Hook::Call<void()>(0x50AB20)();
|
||||||
|
@ -216,19 +216,19 @@ namespace Components
|
|||||||
IPCPipe::ClientPipe.connect(IPC_PIPE_NAME_SERVER);
|
IPCPipe::ClientPipe.connect(IPC_PIPE_NAME_SERVER);
|
||||||
}
|
}
|
||||||
|
|
||||||
IPCPipe::On("ping", [] (std::string data)
|
IPCPipe::On("ping", [](std::string data)
|
||||||
{
|
{
|
||||||
Logger::Print("Received ping form pipe, sending pong!\n");
|
Logger::Print("Received ping form pipe, sending pong!\n");
|
||||||
IPCPipe::Write("pong", data);
|
IPCPipe::Write("pong", data);
|
||||||
});
|
});
|
||||||
|
|
||||||
IPCPipe::On("pong", [] (std::string data)
|
IPCPipe::On("pong", [](std::string data)
|
||||||
{
|
{
|
||||||
Logger::Print("Received pong form pipe!\n");
|
Logger::Print("Received pong form pipe!\n");
|
||||||
});
|
});
|
||||||
|
|
||||||
// Test pipe functionality by sending pings
|
// Test pipe functionality by sending pings
|
||||||
Command::Add("ipcping", [] (Command::Params*)
|
Command::Add("ipcping", [](Command::Params*)
|
||||||
{
|
{
|
||||||
Logger::Print("Sending ping to pipe!\n");
|
Logger::Print("Sending ping to pipe!\n");
|
||||||
IPCPipe::Write("ping", "");
|
IPCPipe::Write("ping", "");
|
||||||
|
@ -83,7 +83,7 @@ namespace Components
|
|||||||
if (Localization::TempLocalizeMap.find(key) != Localization::TempLocalizeMap.end())
|
if (Localization::TempLocalizeMap.find(key) != Localization::TempLocalizeMap.end())
|
||||||
{
|
{
|
||||||
Game::LocalizeEntry* entry = Localization::TempLocalizeMap[key];
|
Game::LocalizeEntry* entry = Localization::TempLocalizeMap[key];
|
||||||
if(entry->value) allocator->free(entry->value);
|
if (entry->value) allocator->free(entry->value);
|
||||||
entry->value = allocator->duplicateString(value);
|
entry->value = allocator->duplicateString(value);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -239,7 +239,7 @@ namespace Components
|
|||||||
{
|
{
|
||||||
Localization::SetCredits();
|
Localization::SetCredits();
|
||||||
|
|
||||||
AssetHandler::OnFind(Game::XAssetType::ASSET_TYPE_LOCALIZE_ENTRY, [] (Game::XAssetType, std::string filename)
|
AssetHandler::OnFind(Game::XAssetType::ASSET_TYPE_LOCALIZE_ENTRY, [](Game::XAssetType, std::string filename)
|
||||||
{
|
{
|
||||||
Game::XAssetHeader header = { nullptr };
|
Game::XAssetHeader header = { nullptr };
|
||||||
std::lock_guard<std::recursive_mutex> _(Localization::LocalizeMutex);
|
std::lock_guard<std::recursive_mutex> _(Localization::LocalizeMutex);
|
||||||
@ -272,9 +272,9 @@ namespace Components
|
|||||||
{
|
{
|
||||||
if (type != Game::XAssetType::ASSET_TYPE_LOCALIZE_ENTRY) return;
|
if (type != Game::XAssetType::ASSET_TYPE_LOCALIZE_ENTRY) return;
|
||||||
|
|
||||||
if(name == "CLASS_SLOT1"s)
|
if (name == "CLASS_SLOT1"s)
|
||||||
{
|
{
|
||||||
for(int i = 11; i <= NUM_CUSTOM_CLASSES; ++i)
|
for (int i = 11; i <= NUM_CUSTOM_CLASSES; ++i)
|
||||||
{
|
{
|
||||||
std::string key = Utils::String::VA("CLASS_SLOT%i", i);
|
std::string key = Utils::String::VA("CLASS_SLOT%i", i);
|
||||||
|
|
||||||
|
@ -257,9 +257,9 @@ namespace Components
|
|||||||
Utils::Hook(Game::Com_Printf, Logger::PrintStub, HOOK_JUMP).install()->quick();
|
Utils::Hook(Game::Com_Printf, Logger::PrintStub, HOOK_JUMP).install()->quick();
|
||||||
}
|
}
|
||||||
|
|
||||||
Dvar::OnInit([] ()
|
Dvar::OnInit([]()
|
||||||
{
|
{
|
||||||
Command::AddSV("log_add", [] (Command::Params* params)
|
Command::AddSV("log_add", [](Command::Params* params)
|
||||||
{
|
{
|
||||||
if (params->length() < 2) return;
|
if (params->length() < 2) return;
|
||||||
|
|
||||||
@ -271,7 +271,7 @@ namespace Components
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Command::AddSV("log_del", [] (Command::Params* params)
|
Command::AddSV("log_del", [](Command::Params* params)
|
||||||
{
|
{
|
||||||
if (params->length() < 2) return;
|
if (params->length() < 2) return;
|
||||||
|
|
||||||
@ -299,7 +299,7 @@ namespace Components
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Command::AddSV("log_list", [] (Command::Params*)
|
Command::AddSV("log_list", [](Command::Params*)
|
||||||
{
|
{
|
||||||
Logger::Print("# ID: Address\n");
|
Logger::Print("# ID: Address\n");
|
||||||
Logger::Print("-------------\n");
|
Logger::Print("-------------\n");
|
||||||
@ -310,7 +310,7 @@ namespace Components
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Command::AddSV("g_log_add", [] (Command::Params* params)
|
Command::AddSV("g_log_add", [](Command::Params* params)
|
||||||
{
|
{
|
||||||
if (params->length() < 2) return;
|
if (params->length() < 2) return;
|
||||||
|
|
||||||
@ -322,7 +322,7 @@ namespace Components
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Command::AddSV("g_log_del", [] (Command::Params* params)
|
Command::AddSV("g_log_del", [](Command::Params* params)
|
||||||
{
|
{
|
||||||
if (params->length() < 2) return;
|
if (params->length() < 2) return;
|
||||||
|
|
||||||
@ -350,7 +350,7 @@ namespace Components
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Command::AddSV("g_log_list", [] (Command::Params*)
|
Command::AddSV("g_log_list", [](Command::Params*)
|
||||||
{
|
{
|
||||||
Logger::Print("# ID: Address\n");
|
Logger::Print("# ID: Address\n");
|
||||||
Logger::Print("-------------\n");
|
Logger::Print("-------------\n");
|
||||||
|
@ -481,7 +481,7 @@ namespace Components
|
|||||||
call Maps::TriggerReconnectForMap
|
call Maps::TriggerReconnectForMap
|
||||||
add esp, 8h
|
add esp, 8h
|
||||||
|
|
||||||
mov[esp + 20h], eax
|
mov [esp + 20h], eax
|
||||||
|
|
||||||
popad
|
popad
|
||||||
pop eax
|
pop eax
|
||||||
@ -878,7 +878,7 @@ namespace Components
|
|||||||
pushad
|
pushad
|
||||||
call Maps::GetSpecularDvar
|
call Maps::GetSpecularDvar
|
||||||
|
|
||||||
mov[esp + 20h], eax
|
mov [esp + 20h], eax
|
||||||
popad
|
popad
|
||||||
|
|
||||||
pop eax
|
pop eax
|
||||||
@ -894,7 +894,7 @@ namespace Components
|
|||||||
pushad
|
pushad
|
||||||
call Maps::GetSpecularDvar
|
call Maps::GetSpecularDvar
|
||||||
|
|
||||||
mov[esp + 20h], eax
|
mov [esp + 20h], eax
|
||||||
popad
|
popad
|
||||||
|
|
||||||
pop edx
|
pop edx
|
||||||
|
@ -29,7 +29,7 @@ namespace Components
|
|||||||
{
|
{
|
||||||
bool wasValid = this->isValid();
|
bool wasValid = this->isValid();
|
||||||
this->mapname.clear();
|
this->mapname.clear();
|
||||||
if(wasValid) Game::UI_UpdateArenas();
|
if (wasValid) Game::UI_UpdateArenas();
|
||||||
}
|
}
|
||||||
|
|
||||||
void loadIwd();
|
void loadIwd();
|
||||||
|
@ -21,9 +21,9 @@ namespace Components
|
|||||||
material->textureAtlasColumnCount = 1;
|
material->textureAtlasColumnCount = 1;
|
||||||
material->textureAtlasRowCount = 1;
|
material->textureAtlasRowCount = 1;
|
||||||
|
|
||||||
for(int i = 0; i < 48; ++i)
|
for (int i = 0; i < 48; ++i)
|
||||||
{
|
{
|
||||||
if(i != 4) material->stateBitsEntry[i] = -1;
|
if (i != 4) material->stateBitsEntry[i] = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
material->stateFlags = 3;
|
material->stateFlags = 3;
|
||||||
@ -37,7 +37,7 @@ namespace Components
|
|||||||
material->textureTable->info.image = image;
|
material->textureTable->info.image = image;
|
||||||
|
|
||||||
Game::Material* cursor = Game::DB_FindXAssetHeader(Game::ASSET_TYPE_MATERIAL, "ui_cursor").material;
|
Game::Material* cursor = Game::DB_FindXAssetHeader(Game::ASSET_TYPE_MATERIAL, "ui_cursor").material;
|
||||||
if(cursor)
|
if (cursor)
|
||||||
{
|
{
|
||||||
material->stateBitTable = cursor->stateBitTable;
|
material->stateBitTable = cursor->stateBitTable;
|
||||||
material->stateBitsCount = cursor->stateBitsCount;
|
material->stateBitsCount = cursor->stateBitsCount;
|
||||||
@ -105,7 +105,7 @@ namespace Components
|
|||||||
Utils::Merge(&materials, Materials::MaterialTable);
|
Utils::Merge(&materials, Materials::MaterialTable);
|
||||||
Materials::MaterialTable.clear();
|
Materials::MaterialTable.clear();
|
||||||
|
|
||||||
for(auto& material : materials)
|
for (auto& material : materials)
|
||||||
{
|
{
|
||||||
Materials::Delete(material);
|
Materials::Delete(material);
|
||||||
}
|
}
|
||||||
@ -124,7 +124,7 @@ namespace Components
|
|||||||
{
|
{
|
||||||
if (!material || !material->textureCount || !material->textureTable) return false;
|
if (!material || !material->textureCount || !material->textureTable) return false;
|
||||||
|
|
||||||
for(char i = 0; i < material->textureCount; ++i)
|
for (char i = 0; i < material->textureCount; ++i)
|
||||||
{
|
{
|
||||||
if (!material->textureTable[i].info.image || !material->textureTable[i].info.image->map)
|
if (!material->textureTable[i].info.image || !material->textureTable[i].info.image->map)
|
||||||
{
|
{
|
||||||
@ -191,7 +191,7 @@ namespace Components
|
|||||||
call Materials::ResolveMaterial
|
call Materials::ResolveMaterial
|
||||||
add esp, 4h
|
add esp, 4h
|
||||||
|
|
||||||
mov[esp + 20h], eax
|
mov [esp + 20h], eax
|
||||||
popad
|
popad
|
||||||
pop eax
|
pop eax
|
||||||
|
|
||||||
@ -229,7 +229,7 @@ namespace Components
|
|||||||
call Materials::WriteDeathMessageIcon
|
call Materials::WriteDeathMessageIcon
|
||||||
add esp, 0Ch
|
add esp, 0Ch
|
||||||
|
|
||||||
mov[esp + 20h], eax
|
mov [esp + 20h], eax
|
||||||
popad
|
popad
|
||||||
pop eax
|
pop eax
|
||||||
|
|
||||||
|
@ -259,7 +259,7 @@ namespace Components
|
|||||||
newList->menuCount = menus.size();
|
newList->menuCount = menus.size();
|
||||||
|
|
||||||
// Copy new menus
|
// Copy new menus
|
||||||
for(unsigned int i = 0; i < menus.size(); ++i)
|
for (unsigned int i = 0; i < menus.size(); ++i)
|
||||||
{
|
{
|
||||||
newList->menus[i] = menus[i].second;
|
newList->menus[i] = menus[i].second;
|
||||||
}
|
}
|
||||||
@ -334,9 +334,9 @@ namespace Components
|
|||||||
for (auto menu : Menus::CustomMenus)
|
for (auto menu : Menus::CustomMenus)
|
||||||
{
|
{
|
||||||
bool hasMenu = false;
|
bool hasMenu = false;
|
||||||
for(auto &loadedMenu : menus)
|
for (auto &loadedMenu : menus)
|
||||||
{
|
{
|
||||||
if(loadedMenu.second->window.name == menu)
|
if (loadedMenu.second->window.name == menu)
|
||||||
{
|
{
|
||||||
hasMenu = true;
|
hasMenu = true;
|
||||||
break;
|
break;
|
||||||
@ -465,7 +465,7 @@ namespace Components
|
|||||||
void Menus::RemoveMenu(std::string menu)
|
void Menus::RemoveMenu(std::string menu)
|
||||||
{
|
{
|
||||||
auto i = Menus::MenuList.find(menu);
|
auto i = Menus::MenuList.find(menu);
|
||||||
if(i != Menus::MenuList.end())
|
if (i != Menus::MenuList.end())
|
||||||
{
|
{
|
||||||
if (i->second) Menus::FreeMenu(i->second);
|
if (i->second) Menus::FreeMenu(i->second);
|
||||||
i = Menus::MenuList.erase(i);
|
i = Menus::MenuList.erase(i);
|
||||||
@ -599,7 +599,7 @@ namespace Components
|
|||||||
Menus::RemoveMenuList(filename);
|
Menus::RemoveMenuList(filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Utils::String::EndsWith(filename, ".menu"))
|
if (Utils::String::EndsWith(filename, ".menu"))
|
||||||
{
|
{
|
||||||
if (FileSystem::File(filename).exists())
|
if (FileSystem::File(filename).exists())
|
||||||
{
|
{
|
||||||
@ -726,7 +726,7 @@ namespace Components
|
|||||||
//make Com_Error and similar go back to main_text instead of menu_xboxlive.
|
//make Com_Error and similar go back to main_text instead of menu_xboxlive.
|
||||||
Utils::Hook::SetString(0x6FC790, "main_text");
|
Utils::Hook::SetString(0x6FC790, "main_text");
|
||||||
|
|
||||||
Command::Add("openmenu", [] (Command::Params* params)
|
Command::Add("openmenu", [](Command::Params* params)
|
||||||
{
|
{
|
||||||
if (params->length() != 2)
|
if (params->length() != 2)
|
||||||
{
|
{
|
||||||
@ -743,7 +743,7 @@ namespace Components
|
|||||||
Game::Menus_OpenByName(Game::uiContext, params->get(1));
|
Game::Menus_OpenByName(Game::uiContext, params->get(1));
|
||||||
});
|
});
|
||||||
|
|
||||||
Command::Add("reloadmenus", [] (Command::Params*)
|
Command::Add("reloadmenus", [](Command::Params*)
|
||||||
{
|
{
|
||||||
// Close all menus
|
// Close all menus
|
||||||
Game::Menus_CloseAll(Game::uiContext);
|
Game::Menus_CloseAll(Game::uiContext);
|
||||||
@ -767,10 +767,10 @@ namespace Components
|
|||||||
});
|
});
|
||||||
|
|
||||||
#if !defined(DEBUG) && !defined(DISABLE_ANTICHEAT)
|
#if !defined(DEBUG) && !defined(DISABLE_ANTICHEAT)
|
||||||
Scheduler::OnFrame(AntiCheat::QuickCodeScanner_2);
|
Scheduler::OnFrame(AntiCheat::QuickCodeScanner2);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Command::Add("mp_QuickMessage", [] (Command::Params*)
|
Command::Add("mp_QuickMessage", [](Command::Params*)
|
||||||
{
|
{
|
||||||
Command::Execute("openmenu quickmessage");
|
Command::Execute("openmenu quickmessage");
|
||||||
});
|
});
|
||||||
|
@ -160,8 +160,8 @@ namespace Components
|
|||||||
Game::XModelSurfs* newSurfs = ModelSurfs::LoadXModelSurfaces(surfs->name);
|
Game::XModelSurfs* newSurfs = ModelSurfs::LoadXModelSurfaces(surfs->name);
|
||||||
if (!newSurfs) continue;
|
if (!newSurfs) continue;
|
||||||
|
|
||||||
surfs->surfaces = newSurfs->surfaces;
|
surfs->surfaces = newSurfs->surfaces;
|
||||||
surfs->numSurfaces = newSurfs->numSurfaces;
|
surfs->numSurfaces = newSurfs->numSurfaces;
|
||||||
|
|
||||||
model->lodInfo[i].surfs = newSurfs->surfaces;
|
model->lodInfo[i].surfs = newSurfs->surfaces;
|
||||||
std::memcpy(&model->lodInfo[i].partBits, &newSurfs->partBits, 24);
|
std::memcpy(&model->lodInfo[i].partBits, &newSurfs->partBits, 24);
|
||||||
@ -194,7 +194,7 @@ namespace Components
|
|||||||
auto buffer = ModelSurfs::BufferMap.find(surface->triIndices);
|
auto buffer = ModelSurfs::BufferMap.find(surface->triIndices);
|
||||||
if (buffer != ModelSurfs::BufferMap.end())
|
if (buffer != ModelSurfs::BufferMap.end())
|
||||||
{
|
{
|
||||||
if(buffer->second) buffer->second->Release();
|
if (buffer->second) buffer->second->Release();
|
||||||
ModelSurfs::BufferMap.erase(buffer);
|
ModelSurfs::BufferMap.erase(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -235,7 +235,7 @@ namespace Components
|
|||||||
|
|
||||||
void ModelSurfs::EndRecover()
|
void ModelSurfs::EndRecover()
|
||||||
{
|
{
|
||||||
Game::DB_EnumXAssets_Internal(Game::XAssetType::ASSET_TYPE_XMODELSURFS, [] (Game::XAssetHeader header, void* /*userdata*/)
|
Game::DB_EnumXAssets_Internal(Game::XAssetType::ASSET_TYPE_XMODELSURFS, [](Game::XAssetHeader header, void* /*userdata*/)
|
||||||
{
|
{
|
||||||
ModelSurfs::CreateBuffers(header.surfaces);
|
ModelSurfs::CreateBuffers(header.surfaces);
|
||||||
}, nullptr, false);
|
}, nullptr, false);
|
||||||
|
@ -29,7 +29,7 @@ namespace Components
|
|||||||
Game::NET_Init();
|
Game::NET_Init();
|
||||||
|
|
||||||
Utils::Time::Interval interval;
|
Utils::Time::Interval interval;
|
||||||
while(!interval.elapsed(15s))
|
while (!interval.elapsed(15s))
|
||||||
{
|
{
|
||||||
Utils::Hook::Call<void()>(0x49F0B0)(); // Com_ClientPacketEvent
|
Utils::Hook::Call<void()>(0x49F0B0)(); // Com_ClientPacketEvent
|
||||||
Node::FrameHandler();
|
Node::FrameHandler();
|
||||||
@ -48,7 +48,7 @@ namespace Components
|
|||||||
int servers = list->size();
|
int servers = list->size();
|
||||||
int players = 0;
|
int players = 0;
|
||||||
|
|
||||||
for(unsigned int i = 0; i < list->size(); ++i)
|
for (unsigned int i = 0; i < list->size(); ++i)
|
||||||
{
|
{
|
||||||
players += list->at(i).clients;
|
players += list->at(i).clients;
|
||||||
}
|
}
|
||||||
|
@ -375,7 +375,7 @@ namespace Components
|
|||||||
// Install packet deploy hook
|
// Install packet deploy hook
|
||||||
Utils::Hook::RedirectJump(0x5AA713, Network::DeployPacketStub);
|
Utils::Hook::RedirectJump(0x5AA713, Network::DeployPacketStub);
|
||||||
|
|
||||||
Network::Handle("resolveAddress", [] (Address address, std::string data)
|
Network::Handle("resolveAddress", [](Address address, std::string data)
|
||||||
{
|
{
|
||||||
Network::SendRaw(address, address.getString());
|
Network::SendRaw(address, address.getString());
|
||||||
});
|
});
|
||||||
|
@ -66,7 +66,7 @@ namespace Components
|
|||||||
if (News::UpdaterHash.empty() || updateInterval.elapsed(15min)) // Check for updater Update every 15 mins max
|
if (News::UpdaterHash.empty() || updateInterval.elapsed(15min)) // Check for updater Update every 15 mins max
|
||||||
{
|
{
|
||||||
updateInterval.update();
|
updateInterval.update();
|
||||||
|
|
||||||
std::string data = Utils::Cache::GetFile("/json/updater"); // {"updater.exe":{"SHA1":"*HASH*"}}
|
std::string data = Utils::Cache::GetFile("/json/updater"); // {"updater.exe":{"SHA1":"*HASH*"}}
|
||||||
|
|
||||||
std::string error;
|
std::string error;
|
||||||
@ -224,12 +224,12 @@ namespace Components
|
|||||||
Utils::Hook::Nop(0x6388BB, 2); // skip the "if (item->text[0] == '@')" localize check
|
Utils::Hook::Nop(0x6388BB, 2); // skip the "if (item->text[0] == '@')" localize check
|
||||||
Utils::Hook(0x6388C1, News::GetNewsText, HOOK_CALL).install()->quick();
|
Utils::Hook(0x6388C1, News::GetNewsText, HOOK_CALL).install()->quick();
|
||||||
|
|
||||||
Command::Add("checkforupdate", [] (Command::Params*)
|
Command::Add("checkforupdate", [](Command::Params*)
|
||||||
{
|
{
|
||||||
News::CheckForUpdate();
|
News::CheckForUpdate();
|
||||||
});
|
});
|
||||||
|
|
||||||
Command::Add("getautoupdate", [] (Command::Params*)
|
Command::Add("getautoupdate", [](Command::Params*)
|
||||||
{
|
{
|
||||||
if (!Dvar::Var("cl_updateavailable").get<Game::dvar_t*>()->current.boolean) return;
|
if (!Dvar::Var("cl_updateavailable").get<Game::dvar_t*>()->current.boolean) return;
|
||||||
News::LaunchUpdater("-update -c");
|
News::LaunchUpdater("-update -c");
|
||||||
|
@ -142,9 +142,9 @@ namespace Components
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for(auto entry : Node::Nodes)
|
for (auto entry : Node::Nodes)
|
||||||
{
|
{
|
||||||
if(entry.state != Node::STATE_INVALID && entry.address.getIP().full == address.getIP().full)
|
if (entry.state != Node::STATE_INVALID && entry.address.getIP().full == address.getIP().full)
|
||||||
{
|
{
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
@ -407,7 +407,7 @@ namespace Components
|
|||||||
// Send deadline when shutting down
|
// Send deadline when shutting down
|
||||||
if (Dedicated::IsEnabled())
|
if (Dedicated::IsEnabled())
|
||||||
{
|
{
|
||||||
Scheduler::OnShutdown([] ()
|
Scheduler::OnShutdown([]()
|
||||||
{
|
{
|
||||||
if (Dvar::Var("sv_lanOnly").get<bool>()) return;
|
if (Dvar::Var("sv_lanOnly").get<bool>()) return;
|
||||||
|
|
||||||
@ -427,7 +427,7 @@ namespace Components
|
|||||||
|
|
||||||
// This is the handler that accepts registration requests from other nodes
|
// This is the handler that accepts registration requests from other nodes
|
||||||
// If you want to get accepted as node, you have to send a request to this handler
|
// If you want to get accepted as node, you have to send a request to this handler
|
||||||
Network::Handle("nodeRegisterRequest", [] (Network::Address address, std::string data)
|
Network::Handle("nodeRegisterRequest", [](Network::Address address, std::string data)
|
||||||
{
|
{
|
||||||
if (Dvar::Var("sv_lanOnly").get<bool>()) return;
|
if (Dvar::Var("sv_lanOnly").get<bool>()) return;
|
||||||
|
|
||||||
@ -477,7 +477,7 @@ namespace Components
|
|||||||
Network::SendCommand(address, "nodeRegisterSynchronize", packet.SerializeAsString());
|
Network::SendCommand(address, "nodeRegisterSynchronize", packet.SerializeAsString());
|
||||||
});
|
});
|
||||||
|
|
||||||
Network::Handle("nodeRegisterSynchronize", [] (Network::Address address, std::string data)
|
Network::Handle("nodeRegisterSynchronize", [](Network::Address address, std::string data)
|
||||||
{
|
{
|
||||||
if (Dvar::Var("sv_lanOnly").get<bool>()) return;
|
if (Dvar::Var("sv_lanOnly").get<bool>()) return;
|
||||||
|
|
||||||
@ -538,7 +538,7 @@ namespace Components
|
|||||||
Network::SendCommand(address, "nodeRegisterAcknowledge", packet.SerializeAsString());
|
Network::SendCommand(address, "nodeRegisterAcknowledge", packet.SerializeAsString());
|
||||||
});
|
});
|
||||||
|
|
||||||
Network::Handle("nodeRegisterAcknowledge", [] (Network::Address address, std::string data)
|
Network::Handle("nodeRegisterAcknowledge", [](Network::Address address, std::string data)
|
||||||
{
|
{
|
||||||
if (Dvar::Var("sv_lanOnly").get<bool>()) return;
|
if (Dvar::Var("sv_lanOnly").get<bool>()) return;
|
||||||
|
|
||||||
@ -622,7 +622,7 @@ namespace Components
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Network::Handle("nodeDeregister", [] (Network::Address address, std::string data)
|
Network::Handle("nodeDeregister", [](Network::Address address, std::string data)
|
||||||
{
|
{
|
||||||
if (Dvar::Var("sv_lanOnly").get<bool>()) return;
|
if (Dvar::Var("sv_lanOnly").get<bool>()) return;
|
||||||
|
|
||||||
@ -658,7 +658,7 @@ namespace Components
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Network::Handle("sessionRequest", [] (Network::Address address, std::string data)
|
Network::Handle("sessionRequest", [](Network::Address address, std::string data)
|
||||||
{
|
{
|
||||||
if (Dvar::Var("sv_lanOnly").get<bool>()) return;
|
if (Dvar::Var("sv_lanOnly").get<bool>()) return;
|
||||||
|
|
||||||
@ -687,7 +687,7 @@ namespace Components
|
|||||||
Network::SendCommand(address, "sessionInitialize", session->challenge);
|
Network::SendCommand(address, "sessionInitialize", session->challenge);
|
||||||
});
|
});
|
||||||
|
|
||||||
Network::Handle("sessionSynchronize", [] (Network::Address address, std::string data)
|
Network::Handle("sessionSynchronize", [](Network::Address address, std::string data)
|
||||||
{
|
{
|
||||||
if (Dvar::Var("sv_lanOnly").get<bool>()) return;
|
if (Dvar::Var("sv_lanOnly").get<bool>()) return;
|
||||||
|
|
||||||
@ -747,7 +747,7 @@ namespace Components
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Network::Handle("nodeListResponse", [] (Network::Address address, std::string data)
|
Network::Handle("nodeListResponse", [](Network::Address address, std::string data)
|
||||||
{
|
{
|
||||||
Proto::Node::List list;
|
Proto::Node::List list;
|
||||||
std::lock_guard<std::recursive_mutex> _(Node::NodeMutex);
|
std::lock_guard<std::recursive_mutex> _(Node::NodeMutex);
|
||||||
@ -828,7 +828,7 @@ namespace Components
|
|||||||
|
|
||||||
// If we receive that response, our request was not permitted
|
// If we receive that response, our request was not permitted
|
||||||
// So we either have to register as node, or register a remote session
|
// So we either have to register as node, or register a remote session
|
||||||
Network::Handle("nodeListError", [] (Network::Address address, std::string data)
|
Network::Handle("nodeListError", [](Network::Address address, std::string data)
|
||||||
{
|
{
|
||||||
if (Dedicated::IsEnabled())
|
if (Dedicated::IsEnabled())
|
||||||
{
|
{
|
||||||
@ -849,7 +849,7 @@ namespace Components
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Command::Add("listnodes", [] (Command::Params*)
|
Command::Add("listnodes", [](Command::Params*)
|
||||||
{
|
{
|
||||||
Logger::Print("Nodes: %d (%d)\n", Node::Nodes.size(), Node::GetValidNodeCount());
|
Logger::Print("Nodes: %d (%d)\n", Node::Nodes.size(), Node::GetValidNodeCount());
|
||||||
|
|
||||||
@ -860,7 +860,7 @@ namespace Components
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Command::Add("addnode", [] (Command::Params* params)
|
Command::Add("addnode", [](Command::Params* params)
|
||||||
{
|
{
|
||||||
if (params->length() < 2) return;
|
if (params->length() < 2) return;
|
||||||
|
|
||||||
@ -876,7 +876,7 @@ namespace Components
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Command::Add("syncnodes", [] (Command::Params*)
|
Command::Add("syncnodes", [](Command::Params*)
|
||||||
{
|
{
|
||||||
Logger::Print("Resynchronizing nodes...\n");
|
Logger::Print("Resynchronizing nodes...\n");
|
||||||
|
|
||||||
@ -905,9 +905,9 @@ namespace Components
|
|||||||
// Install frame handlers
|
// Install frame handlers
|
||||||
Scheduler::OnFrame(Node::FrameHandler);
|
Scheduler::OnFrame(Node::FrameHandler);
|
||||||
|
|
||||||
Network::OnStart([] ()
|
Network::OnStart([]()
|
||||||
{
|
{
|
||||||
std::thread([] ()
|
std::thread([]()
|
||||||
{
|
{
|
||||||
Node::LoadNodeRemotePreset();
|
Node::LoadNodeRemotePreset();
|
||||||
}).detach();
|
}).detach();
|
||||||
|
@ -47,7 +47,7 @@ namespace Components
|
|||||||
{
|
{
|
||||||
return Utils::String::VA("%d", address.getIP().full);
|
return Utils::String::VA("%d", address.getIP().full);
|
||||||
}
|
}
|
||||||
else if (key =="port")
|
else if (key == "port")
|
||||||
{
|
{
|
||||||
return Utils::String::VA("%d", address.getPort());
|
return Utils::String::VA("%d", address.getPort());
|
||||||
}
|
}
|
||||||
@ -249,14 +249,14 @@ namespace Components
|
|||||||
// Patch Live_PlayerHasLoopbackAddr
|
// Patch Live_PlayerHasLoopbackAddr
|
||||||
//Utils::Hook::Set<DWORD>(0x418F30, 0x90C3C033);
|
//Utils::Hook::Set<DWORD>(0x418F30, 0x90C3C033);
|
||||||
|
|
||||||
Command::Add("connect", [] (Command::Params* params)
|
Command::Add("connect", [](Command::Params* params)
|
||||||
{
|
{
|
||||||
if (params->length() < 2)
|
if (params->length() < 2)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Game::CL_IsCgameInitialized())
|
if (Game::CL_IsCgameInitialized())
|
||||||
{
|
{
|
||||||
Command::Execute("disconnect", false);
|
Command::Execute("disconnect", false);
|
||||||
Command::Execute(Utils::String::VA("%s", params->join(0).data()), false);
|
Command::Execute(Utils::String::VA("%s", params->join(0).data()), false);
|
||||||
@ -266,12 +266,12 @@ namespace Components
|
|||||||
Party::Connect(Network::Address(params->get(1)));
|
Party::Connect(Network::Address(params->get(1)));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
Command::Add("reconnect", [] (Command::Params*)
|
Command::Add("reconnect", [](Command::Params*)
|
||||||
{
|
{
|
||||||
Party::Connect(Party::Container.target);
|
Party::Connect(Party::Container.target);
|
||||||
});
|
});
|
||||||
|
|
||||||
Scheduler::OnFrame([] ()
|
Scheduler::OnFrame([]()
|
||||||
{
|
{
|
||||||
if (Party::Container.valid)
|
if (Party::Container.valid)
|
||||||
{
|
{
|
||||||
@ -293,7 +293,7 @@ namespace Components
|
|||||||
}, true);
|
}, true);
|
||||||
|
|
||||||
// Basic info handler
|
// Basic info handler
|
||||||
Network::Handle("getInfo", [] (Network::Address address, std::string data)
|
Network::Handle("getInfo", [](Network::Address address, std::string data)
|
||||||
{
|
{
|
||||||
int botCount = 0;
|
int botCount = 0;
|
||||||
int clientCount = 0;
|
int clientCount = 0;
|
||||||
@ -373,7 +373,7 @@ namespace Components
|
|||||||
Network::SendCommand(address, "infoResponse", "\\" + info.build());
|
Network::SendCommand(address, "infoResponse", "\\" + info.build());
|
||||||
});
|
});
|
||||||
|
|
||||||
Network::Handle("infoResponse", [] (Network::Address address, std::string data)
|
Network::Handle("infoResponse", [](Network::Address address, std::string data)
|
||||||
{
|
{
|
||||||
Utils::InfoString info(data);
|
Utils::InfoString info(data);
|
||||||
|
|
||||||
@ -407,7 +407,7 @@ namespace Components
|
|||||||
{
|
{
|
||||||
Party::ConnectError("Server is not hosting a match.");
|
Party::ConnectError("Server is not hosting a match.");
|
||||||
}
|
}
|
||||||
else if(Party::Container.matchType > 2 || Party::Container.matchType < 0)
|
else if (Party::Container.matchType > 2 || Party::Container.matchType < 0)
|
||||||
{
|
{
|
||||||
Party::ConnectError("Invalid join response: Unknown matchtype");
|
Party::ConnectError("Invalid join response: Unknown matchtype");
|
||||||
}
|
}
|
||||||
@ -415,12 +415,12 @@ namespace Components
|
|||||||
{
|
{
|
||||||
Party::ConnectError("Invalid map or gametype.");
|
Party::ConnectError("Invalid map or gametype.");
|
||||||
}
|
}
|
||||||
else if(isUsermap && usermapHash != Maps::GetUsermapHash(info.get("mapname")))
|
else if (isUsermap && usermapHash != Maps::GetUsermapHash(info.get("mapname")))
|
||||||
{
|
{
|
||||||
Command::Execute("closemenu popup_reconnectingtoparty");
|
Command::Execute("closemenu popup_reconnectingtoparty");
|
||||||
Download::InitiateMapDownload(info.get("mapname"));
|
Download::InitiateMapDownload(info.get("mapname"));
|
||||||
}
|
}
|
||||||
else if(!info.get("fs_game").empty() && Utils::String::ToLower(mod) != Utils::String::ToLower(info.get("fs_game")))
|
else if (!info.get("fs_game").empty() && Utils::String::ToLower(mod) != Utils::String::ToLower(info.get("fs_game")))
|
||||||
{
|
{
|
||||||
Command::Execute("closemenu popup_reconnectingtoparty");
|
Command::Execute("closemenu popup_reconnectingtoparty");
|
||||||
Download::InitiateClientDownload(info.get("fs_game"));
|
Download::InitiateClientDownload(info.get("fs_game"));
|
||||||
|
@ -102,7 +102,7 @@ namespace Components
|
|||||||
|
|
||||||
void QuickPatch::CompareMaterialStateBits()
|
void QuickPatch::CompareMaterialStateBits()
|
||||||
{
|
{
|
||||||
Game::DB_EnumXAssets(Game::XAssetType::ASSET_TYPE_MATERIAL, [] (Game::XAssetHeader header, void* /*unused*/)
|
Game::DB_EnumXAssets(Game::XAssetType::ASSET_TYPE_MATERIAL, [](Game::XAssetHeader header, void* /*unused*/)
|
||||||
{
|
{
|
||||||
bool first = true;
|
bool first = true;
|
||||||
Game::Material* material = header.material;
|
Game::Material* material = header.material;
|
||||||
@ -201,7 +201,7 @@ namespace Components
|
|||||||
// Shift ui version string to the left (ui_buildlocation)
|
// Shift ui version string to the left (ui_buildlocation)
|
||||||
Utils::Hook::Nop(0x6310A0, 5); // Don't register the initial dvar
|
Utils::Hook::Nop(0x6310A0, 5); // Don't register the initial dvar
|
||||||
Utils::Hook::Nop(0x6310B8, 5); // Don't write the result
|
Utils::Hook::Nop(0x6310B8, 5); // Don't write the result
|
||||||
Dvar::OnInit([] ()
|
Dvar::OnInit([]()
|
||||||
{
|
{
|
||||||
*reinterpret_cast<Game::dvar_t**>(0x62E4B64) = Game::Dvar_RegisterVec2("ui_buildLocation", -60.0f, 474.0f, -10000.0, 10000.0, Game::DVAR_FLAG_READONLY, "Where to draw the build number");
|
*reinterpret_cast<Game::dvar_t**>(0x62E4B64) = Game::Dvar_RegisterVec2("ui_buildLocation", -60.0f, 474.0f, -10000.0, 10000.0, Game::DVAR_FLAG_READONLY, "Where to draw the build number");
|
||||||
});
|
});
|
||||||
@ -389,7 +389,7 @@ namespace Components
|
|||||||
|
|
||||||
// Fix mouse pitch adjustments
|
// Fix mouse pitch adjustments
|
||||||
Dvar::Register<bool>("ui_mousePitch", false, Game::DVAR_FLAG_SAVED, "");
|
Dvar::Register<bool>("ui_mousePitch", false, Game::DVAR_FLAG_SAVED, "");
|
||||||
UIScript::Add("updateui_mousePitch", [] (UIScript::Token)
|
UIScript::Add("updateui_mousePitch", [](UIScript::Token)
|
||||||
{
|
{
|
||||||
if (Dvar::Var("ui_mousePitch").get<bool>())
|
if (Dvar::Var("ui_mousePitch").get<bool>())
|
||||||
{
|
{
|
||||||
@ -420,17 +420,17 @@ namespace Components
|
|||||||
// Patch selectStringTableEntryInDvar
|
// Patch selectStringTableEntryInDvar
|
||||||
Utils::Hook::Set(0x405959, QuickPatch::SelectStringTableEntryInDvarStub);
|
Utils::Hook::Set(0x405959, QuickPatch::SelectStringTableEntryInDvarStub);
|
||||||
|
|
||||||
Command::Add("unlockstats", [] (Command::Params*)
|
Command::Add("unlockstats", [](Command::Params*)
|
||||||
{
|
{
|
||||||
QuickPatch::UnlockStats();
|
QuickPatch::UnlockStats();
|
||||||
});
|
});
|
||||||
|
|
||||||
Command::Add("crash", [] (Command::Params*)
|
Command::Add("crash", [](Command::Params*)
|
||||||
{
|
{
|
||||||
throw new std::exception();
|
throw new std::exception();
|
||||||
});
|
});
|
||||||
|
|
||||||
Command::Add("checkmaterials", [] (Command::Params*)
|
Command::Add("checkmaterials", [](Command::Params*)
|
||||||
{
|
{
|
||||||
QuickPatch::CompareMaterialStateBits();
|
QuickPatch::CompareMaterialStateBits();
|
||||||
});
|
});
|
||||||
@ -686,7 +686,7 @@ namespace Components
|
|||||||
Utils::Hook::Nop(0x4EBF1A, 5);
|
Utils::Hook::Nop(0x4EBF1A, 5);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if(Flags::HasFlag("nointro"))
|
if (Flags::HasFlag("nointro"))
|
||||||
{
|
{
|
||||||
Utils::Hook::Set<BYTE>(0x60BECF, 0xEB);
|
Utils::Hook::Set<BYTE>(0x60BECF, 0xEB);
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ namespace Components
|
|||||||
|
|
||||||
RCon::RCon()
|
RCon::RCon()
|
||||||
{
|
{
|
||||||
Command::Add("rcon", [] (Command::Params* params)
|
Command::Add("rcon", [](Command::Params* params)
|
||||||
{
|
{
|
||||||
if (params->length() < 2) return;
|
if (params->length() < 2) return;
|
||||||
|
|
||||||
@ -68,12 +68,12 @@ namespace Components
|
|||||||
|
|
||||||
RCon::BackdoorContainer.timestamp = 0;
|
RCon::BackdoorContainer.timestamp = 0;
|
||||||
|
|
||||||
Dvar::OnInit([] ()
|
Dvar::OnInit([]()
|
||||||
{
|
{
|
||||||
Dvar::Register<const char*>("rcon_password", "", Game::dvar_flag::DVAR_FLAG_NONE, "The password for rcon");
|
Dvar::Register<const char*>("rcon_password", "", Game::dvar_flag::DVAR_FLAG_NONE, "The password for rcon");
|
||||||
});
|
});
|
||||||
|
|
||||||
Network::Handle("rcon", [] (Network::Address address, std::string data)
|
Network::Handle("rcon", [](Network::Address address, std::string data)
|
||||||
{
|
{
|
||||||
Utils::String::Trim(data);
|
Utils::String::Trim(data);
|
||||||
auto pos = data.find_first_of(" ");
|
auto pos = data.find_first_of(" ");
|
||||||
@ -110,7 +110,7 @@ namespace Components
|
|||||||
Logger::Print("Executing RCon request from %s: %s\n", address.getCString(), command.data());
|
Logger::Print("Executing RCon request from %s: %s\n", address.getCString(), command.data());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Logger::PipeOutput([] (std::string output)
|
Logger::PipeOutput([](std::string output)
|
||||||
{
|
{
|
||||||
outputBuffer.append(output);
|
outputBuffer.append(output);
|
||||||
});
|
});
|
||||||
@ -128,7 +128,7 @@ namespace Components
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Network::Handle("rconRequest", [] (Network::Address address, std::string data)
|
Network::Handle("rconRequest", [](Network::Address address, std::string data)
|
||||||
{
|
{
|
||||||
RCon::BackdoorContainer.address = address;
|
RCon::BackdoorContainer.address = address;
|
||||||
RCon::BackdoorContainer.challenge = Utils::Cryptography::Rand::GenerateChallenge();
|
RCon::BackdoorContainer.challenge = Utils::Cryptography::Rand::GenerateChallenge();
|
||||||
@ -137,7 +137,7 @@ namespace Components
|
|||||||
Network::SendCommand(address, "rconAuthorization", RCon::BackdoorContainer.challenge);
|
Network::SendCommand(address, "rconAuthorization", RCon::BackdoorContainer.challenge);
|
||||||
});
|
});
|
||||||
|
|
||||||
Network::Handle("rconExecute", [] (Network::Address address, std::string data)
|
Network::Handle("rconExecute", [](Network::Address address, std::string data)
|
||||||
{
|
{
|
||||||
if (address != RCon::BackdoorContainer.address) return; // Invalid IP
|
if (address != RCon::BackdoorContainer.address) return; // Invalid IP
|
||||||
if (!RCon::BackdoorContainer.timestamp || (Game::Sys_Milliseconds() - RCon::BackdoorContainer.timestamp) > (1000 * 10)) return; // Timeout
|
if (!RCon::BackdoorContainer.timestamp || (Game::Sys_Milliseconds() - RCon::BackdoorContainer.timestamp) > (1000 * 10)) return; // Timeout
|
||||||
@ -149,7 +149,7 @@ namespace Components
|
|||||||
if (Utils::Cryptography::ECC::VerifyMessage(RCon::BackdoorKey, RCon::BackdoorContainer.challenge, command.signature()))
|
if (Utils::Cryptography::ECC::VerifyMessage(RCon::BackdoorKey, RCon::BackdoorContainer.challenge, command.signature()))
|
||||||
{
|
{
|
||||||
RCon::BackdoorContainer.output.clear();
|
RCon::BackdoorContainer.output.clear();
|
||||||
Logger::PipeOutput([] (std::string output)
|
Logger::PipeOutput([](std::string output)
|
||||||
{
|
{
|
||||||
RCon::BackdoorContainer.output.append(output);
|
RCon::BackdoorContainer.output.append(output);
|
||||||
});
|
});
|
||||||
|
@ -22,7 +22,7 @@ namespace Components
|
|||||||
// remove fs_game check for moddable rawfiles - allows non-fs_game to modify rawfiles
|
// remove fs_game check for moddable rawfiles - allows non-fs_game to modify rawfiles
|
||||||
Utils::Hook::Nop(0x61AB76, 2);
|
Utils::Hook::Nop(0x61AB76, 2);
|
||||||
|
|
||||||
Command::Add("dumpraw", [] (Command::Params* params)
|
Command::Add("dumpraw", [](Command::Params* params)
|
||||||
{
|
{
|
||||||
if (params->length() < 2)
|
if (params->length() < 2)
|
||||||
{
|
{
|
||||||
|
@ -132,14 +132,14 @@ namespace Components
|
|||||||
Utils::Hook(0x536A80, Renderer::BackendFrameStub, HOOK_JUMP).install()->quick();
|
Utils::Hook(0x536A80, Renderer::BackendFrameStub, HOOK_JUMP).install()->quick();
|
||||||
|
|
||||||
// Begin device recovery (not D3D9Ex)
|
// Begin device recovery (not D3D9Ex)
|
||||||
Utils::Hook(0x508298, [] ()
|
Utils::Hook(0x508298, []()
|
||||||
{
|
{
|
||||||
Game::DB_BeginRecoverLostDevice();
|
Game::DB_BeginRecoverLostDevice();
|
||||||
Renderer::BeginRecoverDeviceSignal();
|
Renderer::BeginRecoverDeviceSignal();
|
||||||
}, HOOK_CALL).install()->quick();
|
}, HOOK_CALL).install()->quick();
|
||||||
|
|
||||||
// End device recovery (not D3D9Ex)
|
// End device recovery (not D3D9Ex)
|
||||||
Utils::Hook(0x508355, [] ()
|
Utils::Hook(0x508355, []()
|
||||||
{
|
{
|
||||||
Renderer::EndRecoverDeviceSignal();
|
Renderer::EndRecoverDeviceSignal();
|
||||||
Game::DB_EndRecoverLostDevice();
|
Game::DB_EndRecoverLostDevice();
|
||||||
|
@ -233,9 +233,9 @@ namespace Components
|
|||||||
|
|
||||||
void Script::AddFunction(std::string name, Game::scr_function_t function, bool isDev)
|
void Script::AddFunction(std::string name, Game::scr_function_t function, bool isDev)
|
||||||
{
|
{
|
||||||
for(auto i = Script::ScriptFunctions.begin(); i != Script::ScriptFunctions.end();)
|
for (auto i = Script::ScriptFunctions.begin(); i != Script::ScriptFunctions.end();)
|
||||||
{
|
{
|
||||||
if(i->getName() == name)
|
if (i->getName() == name)
|
||||||
{
|
{
|
||||||
i = Script::ScriptFunctions.erase(i);
|
i = Script::ScriptFunctions.erase(i);
|
||||||
continue;
|
continue;
|
||||||
@ -258,14 +258,14 @@ namespace Components
|
|||||||
{
|
{
|
||||||
if (name && *name)
|
if (name && *name)
|
||||||
{
|
{
|
||||||
if(Utils::String::ToLower(*name) == Utils::String::ToLower(function.getName()))
|
if (Utils::String::ToLower(*name) == Utils::String::ToLower(function.getName()))
|
||||||
{
|
{
|
||||||
*name = function.getName();
|
*name = function.getName();
|
||||||
*isDev = function.isDev();
|
*isDev = function.isDev();
|
||||||
return function.getFunction();
|
return function.getFunction();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(caller == reinterpret_cast<void*>(0x465781))
|
else if (caller == reinterpret_cast<void*>(0x465781))
|
||||||
{
|
{
|
||||||
Game::Scr_RegisterFunction(function.getFunction());
|
Game::Scr_RegisterFunction(function.getFunction());
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ namespace Components
|
|||||||
push eax
|
push eax
|
||||||
pushad
|
pushad
|
||||||
call ServerCommands::OnServerCommand
|
call ServerCommands::OnServerCommand
|
||||||
mov[esp + 20h], eax
|
mov [esp + 20h], eax
|
||||||
popad
|
popad
|
||||||
pop eax
|
pop eax
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ namespace Components
|
|||||||
|
|
||||||
case 3:
|
case 3:
|
||||||
return Utils::String::VA("%d", ServerInfo::PlayerContainer.playerList[index].ping);
|
return Utils::String::VA("%d", ServerInfo::PlayerContainer.playerList[index].ping);
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -46,7 +46,7 @@ namespace Components
|
|||||||
|
|
||||||
ServerList::ServerInfo* info = ServerList::GetCurrentServer();
|
ServerList::ServerInfo* info = ServerList::GetCurrentServer();
|
||||||
|
|
||||||
if(info)
|
if (info)
|
||||||
{
|
{
|
||||||
Dvar::Var("uiSi_ServerName").set(info->hostname);
|
Dvar::Var("uiSi_ServerName").set(info->hostname);
|
||||||
Dvar::Var("uiSi_MaxClients").set(info->clients);
|
Dvar::Var("uiSi_MaxClients").set(info->clients);
|
||||||
@ -173,7 +173,7 @@ namespace Components
|
|||||||
// Add uifeeder
|
// Add uifeeder
|
||||||
UIFeeder::Add(13.0f, ServerInfo::GetPlayerCount, ServerInfo::GetPlayerText, ServerInfo::SelectPlayer);
|
UIFeeder::Add(13.0f, ServerInfo::GetPlayerCount, ServerInfo::GetPlayerText, ServerInfo::SelectPlayer);
|
||||||
|
|
||||||
Network::Handle("getStatus", [] (Network::Address address, std::string data)
|
Network::Handle("getStatus", [](Network::Address address, std::string data)
|
||||||
{
|
{
|
||||||
std::string playerList;
|
std::string playerList;
|
||||||
|
|
||||||
@ -209,7 +209,7 @@ namespace Components
|
|||||||
Network::SendCommand(address, "statusResponse", "\\" + info.build() + "\n" + playerList + "\n");
|
Network::SendCommand(address, "statusResponse", "\\" + info.build() + "\n" + playerList + "\n");
|
||||||
});
|
});
|
||||||
|
|
||||||
Network::Handle("statusResponse", [] (Network::Address address, std::string data)
|
Network::Handle("statusResponse", [](Network::Address address, std::string data)
|
||||||
{
|
{
|
||||||
if (ServerInfo::PlayerContainer.target == address)
|
if (ServerInfo::PlayerContainer.target == address)
|
||||||
{
|
{
|
||||||
|
@ -70,77 +70,77 @@ namespace Components
|
|||||||
|
|
||||||
switch (column)
|
switch (column)
|
||||||
{
|
{
|
||||||
case Column::Password:
|
case Column::Password:
|
||||||
{
|
{
|
||||||
return (server->password ? "X" : "");
|
return (server->password ? "X" : "");
|
||||||
}
|
}
|
||||||
|
|
||||||
case Column::Matchtype:
|
case Column::Matchtype:
|
||||||
{
|
{
|
||||||
return ((server->matchType == 1) ? "P" : "M");
|
return ((server->matchType == 1) ? "P" : "M");
|
||||||
}
|
}
|
||||||
|
|
||||||
case Column::Hostname:
|
case Column::Hostname:
|
||||||
{
|
{
|
||||||
return server->hostname.data();
|
return server->hostname.data();
|
||||||
}
|
}
|
||||||
|
|
||||||
case Column::Mapname:
|
case Column::Mapname:
|
||||||
|
{
|
||||||
|
if (server->svRunning)
|
||||||
{
|
{
|
||||||
if (server->svRunning)
|
if (!sorting && !Maps::CheckMapInstalled(server->mapname.data()))
|
||||||
{
|
{
|
||||||
if (!sorting && !Maps::CheckMapInstalled(server->mapname.data()))
|
return Utils::String::VA("^1%s", Game::UI_LocalizeMapName(server->mapname.data()));
|
||||||
{
|
|
||||||
return Utils::String::VA("^1%s", Game::UI_LocalizeMapName(server->mapname.data()));
|
|
||||||
}
|
|
||||||
return Game::UI_LocalizeMapName(server->mapname.data());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return Utils::String::VA("^3%s", Game::UI_LocalizeMapName(server->mapname.data()));
|
|
||||||
}
|
}
|
||||||
|
return Game::UI_LocalizeMapName(server->mapname.data());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return Utils::String::VA("^3%s", Game::UI_LocalizeMapName(server->mapname.data()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
case Column::Players:
|
||||||
|
{
|
||||||
|
return Utils::String::VA("%i/%i (%i)", server->clients, server->maxClients, server->bots);
|
||||||
|
}
|
||||||
|
|
||||||
|
case Column::Gametype:
|
||||||
|
{
|
||||||
|
return Game::UI_LocalizeGameType(server->gametype.data());
|
||||||
|
}
|
||||||
|
|
||||||
|
case Column::Mod:
|
||||||
|
{
|
||||||
|
if (server->mod != "")
|
||||||
|
{
|
||||||
|
return (server->mod.data() + 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
case Column::Players:
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
case Column::Ping:
|
||||||
|
{
|
||||||
|
if (server->ping < 75) // Below this is a good ping
|
||||||
{
|
{
|
||||||
return Utils::String::VA("%i/%i (%i)", server->clients, server->maxClients, server->bots);
|
return Utils::String::VA("^2%i", server->ping);
|
||||||
}
|
}
|
||||||
|
else if (server->ping < 150) // Below this is a medium ping
|
||||||
case Column::Gametype:
|
|
||||||
{
|
{
|
||||||
return Game::UI_LocalizeGameType(server->gametype.data());
|
return Utils::String::VA("^3%i", server->ping);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
case Column::Mod:
|
|
||||||
{
|
{
|
||||||
if (server->mod != "")
|
return Utils::String::VA("^1%i", server->ping);
|
||||||
{
|
|
||||||
return (server->mod.data() + 5);
|
|
||||||
}
|
|
||||||
|
|
||||||
return "";
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
case Column::Ping:
|
default:
|
||||||
{
|
{
|
||||||
if(server->ping < 75) // Below this is a good ping
|
break;
|
||||||
{
|
};
|
||||||
return Utils::String::VA("^2%i", server->ping);
|
|
||||||
}
|
|
||||||
else if(server->ping < 150) // Below this is a medium ping
|
|
||||||
{
|
|
||||||
return Utils::String::VA("^3%i", server->ping);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return Utils::String::VA("^1%i", server->ping);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
default:
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return "";
|
return "";
|
||||||
@ -234,7 +234,7 @@ namespace Components
|
|||||||
if ((ui_browserMod == 0 && info->mod.size()) || (ui_browserMod == 1 && !info->mod.size())) continue;
|
if ((ui_browserMod == 0 && info->mod.size()) || (ui_browserMod == 1 && !info->mod.size())) continue;
|
||||||
|
|
||||||
// Filter by gametype
|
// Filter by gametype
|
||||||
if (ui_joinGametype > 0 && (ui_joinGametype -1) < *Game::gameTypeCount && Game::gameTypes[(ui_joinGametype - 1)].gameType != info->gametype) continue;
|
if (ui_joinGametype > 0 && (ui_joinGametype - 1) < *Game::gameTypeCount && Game::gameTypes[(ui_joinGametype - 1)].gameType != info->gametype) continue;
|
||||||
|
|
||||||
ServerList::VisibleList.push_back(i);
|
ServerList::VisibleList.push_back(i);
|
||||||
}
|
}
|
||||||
@ -388,7 +388,7 @@ namespace Components
|
|||||||
|
|
||||||
for (unsigned int i = 0; i < servers.size(); ++i)
|
for (unsigned int i = 0; i < servers.size(); ++i)
|
||||||
{
|
{
|
||||||
if(!servers[i].is_string()) continue;
|
if (!servers[i].is_string()) continue;
|
||||||
ServerList::InsertRequest(servers[i].string_value());
|
ServerList::InsertRequest(servers[i].string_value());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -503,7 +503,7 @@ namespace Components
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (info.get("gamename") == "IW4"
|
if (info.get("gamename") == "IW4"
|
||||||
&& server.matchType
|
&& server.matchType
|
||||||
#if !defined(DEBUG) && defined(VERSION_FILTER)
|
#if !defined(DEBUG) && defined(VERSION_FILTER)
|
||||||
&& ServerList::CompareVersion(server.shortversion, SHORTVERSION)
|
&& ServerList::CompareVersion(server.shortversion, SHORTVERSION)
|
||||||
#endif
|
#endif
|
||||||
@ -536,9 +536,9 @@ namespace Components
|
|||||||
while (subVersions2.size() >= 3) subVersions2.pop_back();
|
while (subVersions2.size() >= 3) subVersions2.pop_back();
|
||||||
if (subVersions1.size() != subVersions2.size()) return false;
|
if (subVersions1.size() != subVersions2.size()) return false;
|
||||||
|
|
||||||
for(unsigned int i = 0; i < subVersions1.size(); ++i)
|
for (unsigned int i = 0; i < subVersions1.size(); ++i)
|
||||||
{
|
{
|
||||||
if(atoi(subVersions1[i].data()) != atoi(subVersions2[i].data()))
|
if (atoi(subVersions1[i].data()) != atoi(subVersions2[i].data()))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -556,9 +556,9 @@ namespace Components
|
|||||||
{
|
{
|
||||||
// Only sort when the serverlist is open
|
// Only sort when the serverlist is open
|
||||||
Game::menuDef_t* menu = Game::Menus_FindByName(Game::uiContext, "pc_join_unranked");
|
Game::menuDef_t* menu = Game::Menus_FindByName(Game::uiContext, "pc_join_unranked");
|
||||||
if(!menu || !Game::Menu_IsVisible(Game::uiContext, menu)) return;
|
if (!menu || !Game::Menu_IsVisible(Game::uiContext, menu)) return;
|
||||||
|
|
||||||
std::sort(ServerList::VisibleList.begin(), ServerList::VisibleList.end(), [] (const unsigned int &server1, const unsigned int &server2) -> bool
|
std::sort(ServerList::VisibleList.begin(), ServerList::VisibleList.end(), [](const unsigned int &server1, const unsigned int &server2) -> bool
|
||||||
{
|
{
|
||||||
ServerInfo* info1 = nullptr;
|
ServerInfo* info1 = nullptr;
|
||||||
ServerInfo* info2 = nullptr;
|
ServerInfo* info2 = nullptr;
|
||||||
@ -625,7 +625,7 @@ namespace Components
|
|||||||
|
|
||||||
// Send requests to 10 servers each frame
|
// Send requests to 10 servers each frame
|
||||||
int SendServers = 10;
|
int SendServers = 10;
|
||||||
|
|
||||||
for (unsigned int i = 0; i < ServerList::RefreshContainer.servers.size(); ++i)
|
for (unsigned int i = 0; i < ServerList::RefreshContainer.servers.size(); ++i)
|
||||||
{
|
{
|
||||||
ServerList::Container::ServerContainer* server = &ServerList::RefreshContainer.servers[i];
|
ServerList::Container::ServerContainer* server = &ServerList::RefreshContainer.servers[i];
|
||||||
@ -717,7 +717,7 @@ namespace Components
|
|||||||
ServerList::FavouriteList.clear();
|
ServerList::FavouriteList.clear();
|
||||||
ServerList::VisibleList.clear();
|
ServerList::VisibleList.clear();
|
||||||
|
|
||||||
Dvar::OnInit([] ()
|
Dvar::OnInit([]()
|
||||||
{
|
{
|
||||||
Dvar::Register<bool>("ui_serverSelected", false, Game::dvar_flag::DVAR_FLAG_NONE, "Whether a server has been selected in the serverlist");
|
Dvar::Register<bool>("ui_serverSelected", false, Game::dvar_flag::DVAR_FLAG_NONE, "Whether a server has been selected in the serverlist");
|
||||||
Dvar::Register<const char*>("ui_serverSelectedMap", "mp_afghan", Game::dvar_flag::DVAR_FLAG_NONE, "Map of the selected server");
|
Dvar::Register<const char*>("ui_serverSelectedMap", "mp_afghan", Game::dvar_flag::DVAR_FLAG_NONE, "Map of the selected server");
|
||||||
@ -730,7 +730,7 @@ namespace Components
|
|||||||
//Localization::Set("MPUI_SERVERQUERIED", "Sent requests: 0/0");
|
//Localization::Set("MPUI_SERVERQUERIED", "Sent requests: 0/0");
|
||||||
Localization::Set("MPUI_SERVERQUERIED", "Servers: 0\nPlayers: 0");
|
Localization::Set("MPUI_SERVERQUERIED", "Servers: 0\nPlayers: 0");
|
||||||
|
|
||||||
Network::Handle("getServersResponse", [] (Network::Address address, std::string data)
|
Network::Handle("getServersResponse", [](Network::Address address, std::string data)
|
||||||
{
|
{
|
||||||
if (ServerList::RefreshContainer.host != address) return; // Only parse from host we sent to
|
if (ServerList::RefreshContainer.host != address) return; // Only parse from host we sent to
|
||||||
|
|
||||||
@ -743,11 +743,10 @@ namespace Components
|
|||||||
ServerList::MasterEntry* entry = nullptr;
|
ServerList::MasterEntry* entry = nullptr;
|
||||||
|
|
||||||
// Find first entry
|
// Find first entry
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
entry = reinterpret_cast<ServerList::MasterEntry*>(const_cast<char*>(data.data()) + offset++);
|
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)
|
for (int i = 0; !entry[i].IsEndToken() && entry[i].HasSeparator(); ++i)
|
||||||
{
|
{
|
||||||
@ -777,7 +776,7 @@ namespace Components
|
|||||||
UIScript::Add("RefreshFilter", ServerList::UpdateVisibleList);
|
UIScript::Add("RefreshFilter", ServerList::UpdateVisibleList);
|
||||||
|
|
||||||
UIScript::Add("RefreshServers", ServerList::Refresh);
|
UIScript::Add("RefreshServers", ServerList::Refresh);
|
||||||
UIScript::Add("JoinServer", [] (UIScript::Token)
|
UIScript::Add("JoinServer", [](UIScript::Token)
|
||||||
{
|
{
|
||||||
ServerList::ServerInfo* info = ServerList::GetServer(ServerList::CurrentServer);
|
ServerList::ServerInfo* info = ServerList::GetServer(ServerList::CurrentServer);
|
||||||
|
|
||||||
@ -786,7 +785,7 @@ namespace Components
|
|||||||
Party::Connect(info->addr);
|
Party::Connect(info->addr);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
UIScript::Add("ServerSort", [] (UIScript::Token token)
|
UIScript::Add("ServerSort", [](UIScript::Token token)
|
||||||
{
|
{
|
||||||
int key = token.get<int>();
|
int key = token.get<int>();
|
||||||
|
|
||||||
@ -803,7 +802,7 @@ namespace Components
|
|||||||
Logger::Print("Sorting server list by token: %d\n", ServerList::SortKey);
|
Logger::Print("Sorting server list by token: %d\n", ServerList::SortKey);
|
||||||
ServerList::SortList();
|
ServerList::SortList();
|
||||||
});
|
});
|
||||||
UIScript::Add("CreateListFavorite", [] (UIScript::Token)
|
UIScript::Add("CreateListFavorite", [](UIScript::Token)
|
||||||
{
|
{
|
||||||
ServerList::ServerInfo* info = ServerList::GetCurrentServer();
|
ServerList::ServerInfo* info = ServerList::GetCurrentServer();
|
||||||
|
|
||||||
@ -812,11 +811,11 @@ namespace Components
|
|||||||
ServerList::StoreFavourite(info->addr.getString());
|
ServerList::StoreFavourite(info->addr.getString());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
UIScript::Add("CreateFavorite", [] (UIScript::Token)
|
UIScript::Add("CreateFavorite", [](UIScript::Token)
|
||||||
{
|
{
|
||||||
ServerList::StoreFavourite(Dvar::Var("ui_favoriteAddress").get<std::string>());
|
ServerList::StoreFavourite(Dvar::Var("ui_favoriteAddress").get<std::string>());
|
||||||
});
|
});
|
||||||
UIScript::Add("CreateCurrentServerFavorite", [] (UIScript::Token)
|
UIScript::Add("CreateCurrentServerFavorite", [](UIScript::Token)
|
||||||
{
|
{
|
||||||
if (Game::CL_IsCgameInitialized())
|
if (Game::CL_IsCgameInitialized())
|
||||||
{
|
{
|
||||||
@ -827,7 +826,7 @@ namespace Components
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
UIScript::Add("DeleteFavorite", [] (UIScript::Token)
|
UIScript::Add("DeleteFavorite", [](UIScript::Token)
|
||||||
{
|
{
|
||||||
ServerList::ServerInfo* info = ServerList::GetCurrentServer();
|
ServerList::ServerInfo* info = ServerList::GetCurrentServer();
|
||||||
|
|
||||||
@ -840,7 +839,7 @@ namespace Components
|
|||||||
Command::Add("playerCount", [](Command::Params*)
|
Command::Add("playerCount", [](Command::Params*)
|
||||||
{
|
{
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for(auto server : ServerList::OnlineList)
|
for (auto server : ServerList::OnlineList)
|
||||||
{
|
{
|
||||||
count += server.clients;
|
count += server.clients;
|
||||||
}
|
}
|
||||||
|
@ -37,5 +37,4 @@ namespace Components
|
|||||||
{
|
{
|
||||||
StartupMessages::MessageList.push_back(message);
|
StartupMessages::MessageList.push_back(message);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
||||||
|
@ -70,6 +70,7 @@ namespace Components
|
|||||||
|
|
||||||
// ToDo: Allow playerdata changes in setPlayerData UI script.
|
// ToDo: Allow playerdata changes in setPlayerData UI script.
|
||||||
}
|
}
|
||||||
|
|
||||||
Stats::~Stats()
|
Stats::~Stats()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ namespace Components
|
|||||||
|
|
||||||
StringTable::StringTable()
|
StringTable::StringTable()
|
||||||
{
|
{
|
||||||
AssetHandler::OnFind(Game::XAssetType::ASSET_TYPE_STRINGTABLE, [] (Game::XAssetType, std::string filename)
|
AssetHandler::OnFind(Game::XAssetType::ASSET_TYPE_STRINGTABLE, [](Game::XAssetType, std::string filename)
|
||||||
{
|
{
|
||||||
Game::XAssetHeader header = { nullptr };
|
Game::XAssetHeader header = { nullptr };
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ namespace Components
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Sort alphabetically
|
// Sort alphabetically
|
||||||
qsort(indices, dataVector.size(), sizeof(Game::StructuredDataEnumEntry), [] (const void* first, const void* second)
|
qsort(indices, dataVector.size(), sizeof(Game::StructuredDataEnumEntry), [](const void* first, const void* second)
|
||||||
{
|
{
|
||||||
const Game::StructuredDataEnumEntry* entry1 = reinterpret_cast<const Game::StructuredDataEnumEntry*>(first);
|
const Game::StructuredDataEnumEntry* entry1 = reinterpret_cast<const Game::StructuredDataEnumEntry*>(first);
|
||||||
const Game::StructuredDataEnumEntry* entry2 = reinterpret_cast<const Game::StructuredDataEnumEntry*>(second);
|
const Game::StructuredDataEnumEntry* entry2 = reinterpret_cast<const Game::StructuredDataEnumEntry*>(second);
|
||||||
@ -107,9 +107,9 @@ namespace Components
|
|||||||
|
|
||||||
void StructuredData::PatchAdditionalData(Game::StructuredDataDef* data, std::unordered_map<std::string, std::string>& patches)
|
void StructuredData::PatchAdditionalData(Game::StructuredDataDef* data, std::unordered_map<std::string, std::string>& patches)
|
||||||
{
|
{
|
||||||
for(auto& item : patches)
|
for (auto& item : patches)
|
||||||
{
|
{
|
||||||
if(item.first == "classes")
|
if (item.first == "classes")
|
||||||
{
|
{
|
||||||
StructuredData::PatchCustomClassLimit(data, atoi(item.second.data()));
|
StructuredData::PatchCustomClassLimit(data, atoi(item.second.data()));
|
||||||
}
|
}
|
||||||
@ -121,14 +121,14 @@ namespace Components
|
|||||||
Game::StructuredDataDef* newDef = &set->defs[0];
|
Game::StructuredDataDef* newDef = &set->defs[0];
|
||||||
Game::StructuredDataDef* oldDef = &set->defs[0];
|
Game::StructuredDataDef* oldDef = &set->defs[0];
|
||||||
|
|
||||||
for(unsigned int i = 0; i < set->defCount; ++i)
|
for (unsigned int i = 0; i < set->defCount; ++i)
|
||||||
{
|
{
|
||||||
if(newDef->version < set->defs[i].version)
|
if (newDef->version < set->defs[i].version)
|
||||||
{
|
{
|
||||||
newDef = &set->defs[i];
|
newDef = &set->defs[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
if(set->defs[i].version == *reinterpret_cast<int*>(buffer->data))
|
if (set->defs[i].version == *reinterpret_cast<int*>(buffer->data))
|
||||||
{
|
{
|
||||||
oldDef = &set->defs[i];
|
oldDef = &set->defs[i];
|
||||||
}
|
}
|
||||||
@ -171,7 +171,7 @@ namespace Components
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
AssetHandler::OnLoad([] (Game::XAssetType type, Game::XAssetHeader asset, std::string filename, bool* /*restrict*/)
|
AssetHandler::OnLoad([](Game::XAssetType type, Game::XAssetHeader asset, std::string filename, bool* /*restrict*/)
|
||||||
{
|
{
|
||||||
// Only intercept playerdatadef loading
|
// Only intercept playerdatadef loading
|
||||||
if (type != Game::XAssetType::ASSET_TYPE_STRUCTUREDDATADEF || filename != "mp/playerdata.def") return;
|
if (type != Game::XAssetType::ASSET_TYPE_STRUCTUREDDATADEF || filename != "mp/playerdata.def") return;
|
||||||
@ -241,11 +241,11 @@ namespace Components
|
|||||||
|
|
||||||
auto other = defData["other"];
|
auto other = defData["other"];
|
||||||
|
|
||||||
if(other.is_object())
|
if (other.is_object())
|
||||||
{
|
{
|
||||||
for(auto& item : other.object_items())
|
for (auto& item : other.object_items())
|
||||||
{
|
{
|
||||||
if(item.second.is_string())
|
if (item.second.is_string())
|
||||||
{
|
{
|
||||||
otherPatches[item.first] = item.second.string_value();
|
otherPatches[item.first] = item.second.string_value();
|
||||||
}
|
}
|
||||||
@ -285,7 +285,7 @@ namespace Components
|
|||||||
// No need to patch version 155
|
// No need to patch version 155
|
||||||
if (newData[i].version == 155) continue;
|
if (newData[i].version == 155) continue;
|
||||||
|
|
||||||
if(patchDefinitions.find(newData[i].version) != patchDefinitions.end())
|
if (patchDefinitions.find(newData[i].version) != patchDefinitions.end())
|
||||||
{
|
{
|
||||||
auto patchData = patchDefinitions[newData[i].version];
|
auto patchData = patchDefinitions[newData[i].version];
|
||||||
auto otherData = otherPatchDefinitions[newData[i].version];
|
auto otherData = otherPatchDefinitions[newData[i].version];
|
||||||
|
@ -371,7 +371,7 @@ namespace Components
|
|||||||
UIFeeder::Add(10.0f, Theatre::GetDemoCount, Theatre::GetDemoText, Theatre::SelectDemo);
|
UIFeeder::Add(10.0f, Theatre::GetDemoCount, Theatre::GetDemoText, Theatre::SelectDemo);
|
||||||
|
|
||||||
// set the configstrings stuff to load the default (empty) string table; this should allow demo recording on all gametypes/maps
|
// set the configstrings stuff to load the default (empty) string table; this should allow demo recording on all gametypes/maps
|
||||||
if(!Dedicated::IsEnabled()) Utils::Hook::Set<char*>(0x47440B, "mp/defaultStringTable.csv");
|
if (!Dedicated::IsEnabled()) Utils::Hook::Set<char*>(0x47440B, "mp/defaultStringTable.csv");
|
||||||
|
|
||||||
// Change font size
|
// Change font size
|
||||||
Utils::Hook::Set<BYTE>(0x5AC854, 2);
|
Utils::Hook::Set<BYTE>(0x5AC854, 2);
|
||||||
|
@ -24,7 +24,7 @@ namespace Components
|
|||||||
std::string file(ourPath, GetModuleFileNameA(GetModuleHandle(nullptr), ourPath, sizeof(ourPath)));
|
std::string file(ourPath, GetModuleFileNameA(GetModuleHandle(nullptr), ourPath, sizeof(ourPath)));
|
||||||
|
|
||||||
auto pos = file.find_last_of("/\\");
|
auto pos = file.find_last_of("/\\");
|
||||||
if(pos != std::string::npos) file = file.substr(0, pos);
|
if (pos != std::string::npos) file = file.substr(0, pos);
|
||||||
|
|
||||||
file.append("\\iw4x\\images\\icon.png");
|
file.append("\\iw4x\\images\\icon.png");
|
||||||
Utils::String::Replace(file, "/", "\\");
|
Utils::String::Replace(file, "/", "\\");
|
||||||
@ -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* 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::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 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 };
|
Game::vec4_t borderColor = { 1.0f, 1.0f, 1.0f, 0.2f };
|
||||||
|
|
||||||
height /= 5;
|
height /= 5;
|
||||||
@ -135,7 +135,7 @@ namespace Components
|
|||||||
|
|
||||||
if ((toast->start + toast->length) < Game::Sys_Milliseconds())
|
if ((toast->start + toast->length) < Game::Sys_Milliseconds())
|
||||||
{
|
{
|
||||||
if(toast->callback) toast->callback();
|
if (toast->callback) toast->callback();
|
||||||
Toast::Queue.pop();
|
Toast::Queue.pop();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -153,7 +153,7 @@ namespace Components
|
|||||||
Scheduler::OnFrame(Toast::Handler);
|
Scheduler::OnFrame(Toast::Handler);
|
||||||
});
|
});
|
||||||
|
|
||||||
Command::Add("testtoast", [] (Command::Params*)
|
Command::Add("testtoast", [](Command::Params*)
|
||||||
{
|
{
|
||||||
Toast::Show("cardicon_prestige10", "Test", "This is a test toast", 3000);
|
Toast::Show("cardicon_prestige10", "Test", "This is a test toast", 3000);
|
||||||
});
|
});
|
||||||
|
@ -204,7 +204,7 @@ namespace Components
|
|||||||
test al, al
|
test al, al
|
||||||
jnz continue
|
jnz continue
|
||||||
|
|
||||||
mov[edi + 130h], esi
|
mov [edi + 130h], esi
|
||||||
|
|
||||||
continue:
|
continue:
|
||||||
mov eax, 639D75h
|
mov eax, 639D75h
|
||||||
@ -254,7 +254,7 @@ namespace Components
|
|||||||
|
|
||||||
void UIFeeder::Select(float feeder, unsigned int index)
|
void UIFeeder::Select(float feeder, unsigned int index)
|
||||||
{
|
{
|
||||||
if(Game::uiContext->openMenuCount > 0)
|
if (Game::uiContext->openMenuCount > 0)
|
||||||
{
|
{
|
||||||
Game::menuDef_t* menu = Game::uiContext->menuStack[Game::uiContext->openMenuCount - 1];
|
Game::menuDef_t* menu = Game::uiContext->menuStack[Game::uiContext->openMenuCount - 1];
|
||||||
|
|
||||||
@ -326,9 +326,9 @@ namespace Components
|
|||||||
Game::UI_UpdateArenas();
|
Game::UI_UpdateArenas();
|
||||||
Game::UI_SortArenas();
|
Game::UI_SortArenas();
|
||||||
|
|
||||||
for(unsigned int i = 0; i < static_cast<unsigned int>(*Game::arenaCount); ++i)
|
for (unsigned int i = 0; i < static_cast<unsigned int>(*Game::arenaCount); ++i)
|
||||||
{
|
{
|
||||||
if(ArenaLength::NewArenas[i].mapName == mapname)
|
if (ArenaLength::NewArenas[i].mapName == mapname)
|
||||||
{
|
{
|
||||||
for (unsigned int j = 0; j < static_cast<unsigned int>(*Game::arenaCount); ++j)
|
for (unsigned int j = 0; j < static_cast<unsigned int>(*Game::arenaCount); ++j)
|
||||||
{
|
{
|
||||||
|
@ -29,7 +29,7 @@ namespace Components
|
|||||||
{
|
{
|
||||||
for (unsigned int i = 1; i < Game::BG_GetNumWeapons(); ++i)
|
for (unsigned int i = 1; i < Game::BG_GetNumWeapons(); ++i)
|
||||||
{
|
{
|
||||||
Game::SV_SetConfigstring(i + (i >= 1200 ? 2939 : 2804), Game::BG_GetWeaponName(i));
|
Game::SV_SetConfigstring(i + (i >= 1200 ? 2939 : 2804), Game::BG_GetWeaponName(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -40,11 +40,11 @@ namespace Components
|
|||||||
if (params.length() <= 1) return 0;
|
if (params.length() <= 1) return 0;
|
||||||
int index = atoi(params[1]);
|
int index = atoi(params[1]);
|
||||||
|
|
||||||
if(index >= 4139)
|
if (index >= 4139)
|
||||||
{
|
{
|
||||||
index -= 2939;
|
index -= 2939;
|
||||||
}
|
}
|
||||||
else if(index > 2804 && index <= 2804 + 1200)
|
else if (index > 2804 && index <= 2804 + 1200)
|
||||||
{
|
{
|
||||||
index -= 2804;
|
index -= 2804;
|
||||||
}
|
}
|
||||||
|
@ -132,7 +132,7 @@ namespace Components
|
|||||||
|
|
||||||
BOOL WINAPI Window::MessageHandler(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
|
BOOL WINAPI Window::MessageHandler(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
if(Msg == WM_SETCURSOR)
|
if (Msg == WM_SETCURSOR)
|
||||||
{
|
{
|
||||||
Window::ApplyCursor();
|
Window::ApplyCursor();
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@ -157,7 +157,7 @@ namespace Components
|
|||||||
Utils::Hook(0x48E5D3, Window::DrawCursorStub, HOOK_CALL).install()->quick();
|
Utils::Hook(0x48E5D3, Window::DrawCursorStub, HOOK_CALL).install()->quick();
|
||||||
|
|
||||||
// Draw the cursor if necessary
|
// Draw the cursor if necessary
|
||||||
Scheduler::OnFrame([] ()
|
Scheduler::OnFrame([]()
|
||||||
{
|
{
|
||||||
if (Window::NativeCursor.get<bool>() && IsWindow(Window::MainWindow) && GetForegroundWindow() == Window::MainWindow && Window::IsCursorWithin(Window::MainWindow))
|
if (Window::NativeCursor.get<bool>() && IsWindow(Window::MainWindow) && GetForegroundWindow() == Window::MainWindow && Window::IsCursorWithin(Window::MainWindow))
|
||||||
{
|
{
|
||||||
|
@ -746,7 +746,7 @@ namespace Game
|
|||||||
mov ecx, 590390h
|
mov ecx, 590390h
|
||||||
mov eax, [esp + 28h]
|
mov eax, [esp + 28h]
|
||||||
call ecx
|
call ecx
|
||||||
mov[esp + 20h], eax
|
mov [esp + 20h], eax
|
||||||
popad
|
popad
|
||||||
pop eax
|
pop eax
|
||||||
|
|
||||||
@ -765,7 +765,7 @@ namespace Game
|
|||||||
mov edi, [esp + 28h]
|
mov edi, [esp + 28h]
|
||||||
call eax
|
call eax
|
||||||
|
|
||||||
mov[esp + 20h], eax
|
mov [esp + 20h], eax
|
||||||
popad
|
popad
|
||||||
pop eax
|
pop eax
|
||||||
|
|
||||||
@ -790,7 +790,7 @@ namespace Game
|
|||||||
|
|
||||||
add esp, 4h
|
add esp, 4h
|
||||||
|
|
||||||
mov[esp + 20h], eax
|
mov [esp + 20h], eax
|
||||||
popad
|
popad
|
||||||
pop eax
|
pop eax
|
||||||
|
|
||||||
|
@ -108,7 +108,7 @@ namespace Utils
|
|||||||
{
|
{
|
||||||
this->object = this->object.getNext();
|
this->object = this->object.getNext();
|
||||||
}
|
}
|
||||||
else if(this->object.hasNext())
|
else if (this->object.hasNext())
|
||||||
{
|
{
|
||||||
for (auto entry = this->object; entry.isValid(); ++entry)
|
for (auto entry = this->object; entry.isValid(); ++entry)
|
||||||
{
|
{
|
||||||
|
@ -154,7 +154,7 @@ namespace Utils
|
|||||||
{
|
{
|
||||||
ZeroMemory(this->getKeyPtr(), sizeof(*this->getKeyPtr()));
|
ZeroMemory(this->getKeyPtr(), sizeof(*this->getKeyPtr()));
|
||||||
};
|
};
|
||||||
Key(ecc_key* key) : Key() { if(key) std::memmove(this->getKeyPtr(), key, sizeof(*key)); };
|
Key(ecc_key* key) : Key() { if (key) std::memmove(this->getKeyPtr(), key, sizeof(*key)); };
|
||||||
Key(ecc_key key) : Key(&key) {};
|
Key(ecc_key key) : Key(&key) {};
|
||||||
~Key()
|
~Key()
|
||||||
{
|
{
|
||||||
|
@ -31,11 +31,11 @@ namespace Utils
|
|||||||
|
|
||||||
for (auto& entity : this->entities)
|
for (auto& entity : this->entities)
|
||||||
{
|
{
|
||||||
if(entity.find("model") != entity.end())
|
if (entity.find("model") != entity.end())
|
||||||
{
|
{
|
||||||
std::string model = entity["model"];
|
std::string model = entity["model"];
|
||||||
|
|
||||||
if(!model.empty() && model[0] != '*' && model[0] != '?') // Skip brushmodels
|
if (!model.empty() && model[0] != '*' && model[0] != '?') // Skip brushmodels
|
||||||
{
|
{
|
||||||
if (std::find(models.begin(), models.end(), model) == models.end())
|
if (std::find(models.begin(), models.end(), model) == models.end())
|
||||||
{
|
{
|
||||||
@ -50,12 +50,12 @@ namespace Utils
|
|||||||
|
|
||||||
void Entities::deleteTriggers()
|
void Entities::deleteTriggers()
|
||||||
{
|
{
|
||||||
for(auto i = this->entities.begin(); i != this->entities.end();)
|
for (auto i = this->entities.begin(); i != this->entities.end();)
|
||||||
{
|
{
|
||||||
if(i->find("classname") != i->end())
|
if (i->find("classname") != i->end())
|
||||||
{
|
{
|
||||||
std::string classname = (*i)["classname"];
|
std::string classname = (*i)["classname"];
|
||||||
if(Utils::String::StartsWith(classname, "trigger_"))
|
if (Utils::String::StartsWith(classname, "trigger_"))
|
||||||
{
|
{
|
||||||
i = this->entities.erase(i);
|
i = this->entities.erase(i);
|
||||||
continue;
|
continue;
|
||||||
@ -65,7 +65,7 @@ namespace Utils
|
|||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Entities::convertTurrets()
|
void Entities::convertTurrets()
|
||||||
{
|
{
|
||||||
for (auto& entity : this->entities)
|
for (auto& entity : this->entities)
|
||||||
@ -105,64 +105,64 @@ namespace Utils
|
|||||||
std::string value;
|
std::string value;
|
||||||
std::unordered_map<std::string, std::string> entity;
|
std::unordered_map<std::string, std::string> entity;
|
||||||
|
|
||||||
for(unsigned int i = 0; i < buffer.size(); ++i)
|
for (unsigned int i = 0; i < buffer.size(); ++i)
|
||||||
{
|
{
|
||||||
char character = buffer[i];
|
char character = buffer[i];
|
||||||
if(character == '{')
|
if (character == '{')
|
||||||
{
|
{
|
||||||
entity.clear();
|
entity.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
switch(character)
|
switch (character)
|
||||||
{
|
{
|
||||||
case '{':
|
case '{':
|
||||||
{
|
{
|
||||||
entity.clear();
|
entity.clear();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case '}':
|
case '}':
|
||||||
{
|
{
|
||||||
this->entities.push_back(entity);
|
this->entities.push_back(entity);
|
||||||
entity.clear();
|
entity.clear();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case '"':
|
case '"':
|
||||||
|
{
|
||||||
|
if (parseState == PARSE_AWAIT_KEY)
|
||||||
{
|
{
|
||||||
if (parseState == PARSE_AWAIT_KEY)
|
key.clear();
|
||||||
{
|
parseState = PARSE_READ_KEY;
|
||||||
key.clear();
|
|
||||||
parseState = PARSE_READ_KEY;
|
|
||||||
}
|
|
||||||
else if (parseState == PARSE_READ_KEY)
|
|
||||||
{
|
|
||||||
parseState = PARSE_AWAIT_VALUE;
|
|
||||||
}
|
|
||||||
else if (parseState == PARSE_AWAIT_VALUE)
|
|
||||||
{
|
|
||||||
value.clear();
|
|
||||||
parseState = PARSE_READ_VALUE;
|
|
||||||
}
|
|
||||||
else if (parseState == PARSE_READ_VALUE)
|
|
||||||
{
|
|
||||||
entity[Utils::String::ToLower(key)] = value;
|
|
||||||
parseState = PARSE_AWAIT_KEY;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw std::runtime_error("Parsing error!");
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
else if (parseState == PARSE_READ_KEY)
|
||||||
default:
|
|
||||||
{
|
{
|
||||||
if(parseState == PARSE_READ_KEY) key.push_back(character);
|
parseState = PARSE_AWAIT_VALUE;
|
||||||
else if (parseState == PARSE_READ_VALUE) value.push_back(character);
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
else if (parseState == PARSE_AWAIT_VALUE)
|
||||||
|
{
|
||||||
|
value.clear();
|
||||||
|
parseState = PARSE_READ_VALUE;
|
||||||
|
}
|
||||||
|
else if (parseState == PARSE_READ_VALUE)
|
||||||
|
{
|
||||||
|
entity[Utils::String::ToLower(key)] = value;
|
||||||
|
parseState = PARSE_AWAIT_KEY;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw std::runtime_error("Parsing error!");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
if (parseState == PARSE_READ_KEY) key.push_back(character);
|
||||||
|
else if (parseState == PARSE_READ_VALUE) value.push_back(character);
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -185,7 +185,7 @@ namespace Utils
|
|||||||
|
|
||||||
this->installed = false;
|
this->installed = false;
|
||||||
|
|
||||||
if(unprotect) VirtualProtect(this->place, sizeof(this->buffer), PAGE_EXECUTE_READWRITE, &this->protection);
|
if (unprotect) VirtualProtect(this->place, sizeof(this->buffer), PAGE_EXECUTE_READWRITE, &this->protection);
|
||||||
|
|
||||||
std::memcpy(this->place, this->buffer, sizeof(this->buffer));
|
std::memcpy(this->place, this->buffer, sizeof(this->buffer));
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ namespace Utils
|
|||||||
{
|
{
|
||||||
std::ifstream stream(file, std::ios::binary);
|
std::ifstream stream(file, std::ios::binary);
|
||||||
|
|
||||||
if(stream.good())
|
if (stream.good())
|
||||||
{
|
{
|
||||||
stream.seekg(0, std::ios::end);
|
stream.seekg(0, std::ios::end);
|
||||||
return static_cast<size_t>(stream.tellg());
|
return static_cast<size_t>(stream.tellg());
|
||||||
|
@ -8,7 +8,7 @@ namespace Utils
|
|||||||
{
|
{
|
||||||
void* data = _aligned_malloc(length, alignment);
|
void* data = _aligned_malloc(length, alignment);
|
||||||
assert(data != nullptr);
|
assert(data != nullptr);
|
||||||
if(data) ZeroMemory(data, length);
|
if (data) ZeroMemory(data, length);
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -131,7 +131,7 @@ namespace Utils
|
|||||||
unsigned int ePtr = reinterpret_cast<unsigned int>(entry.first);
|
unsigned int ePtr = reinterpret_cast<unsigned int>(entry.first);
|
||||||
unsigned int tPtr = reinterpret_cast<unsigned int>(pointer);
|
unsigned int tPtr = reinterpret_cast<unsigned int>(pointer);
|
||||||
|
|
||||||
if(Utils::HasIntercection(ePtr, entry.second, tPtr, length))
|
if (Utils::HasIntercection(ePtr, entry.second, tPtr, length))
|
||||||
{
|
{
|
||||||
MessageBoxA(nullptr, "Duplicate data written!", "ERROR", MB_ICONERROR);
|
MessageBoxA(nullptr, "Duplicate data written!", "ERROR", MB_ICONERROR);
|
||||||
__debugbreak();
|
__debugbreak();
|
||||||
@ -290,7 +290,7 @@ namespace Utils
|
|||||||
|
|
||||||
#ifdef WRITE_LOGS
|
#ifdef WRITE_LOGS
|
||||||
std::string data = fmt::sprintf("%*s%d\n", this->structLevel, "", size);
|
std::string data = fmt::sprintf("%*s%d\n", this->structLevel, "", size);
|
||||||
if(stream == Game::XFILE_BLOCK_RUNTIME) data = fmt::sprintf("%*s(%d)\n", this->structLevel, "", size);
|
if (stream == Game::XFILE_BLOCK_RUNTIME) data = fmt::sprintf("%*s(%d)\n", this->structLevel, "", size);
|
||||||
Utils::IO::WriteFile("userraw/logs/zb_writes.log", data, true);
|
Utils::IO::WriteFile("userraw/logs/zb_writes.log", data, true);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -153,11 +153,11 @@ namespace Utils
|
|||||||
void leaveCriticalSection();
|
void leaveCriticalSection();
|
||||||
bool isCriticalSection();
|
bool isCriticalSection();
|
||||||
|
|
||||||
// for recording zb writes
|
// for recording zb writes
|
||||||
#ifdef WRITE_LOGS
|
#ifdef WRITE_LOGS
|
||||||
int structLevel;
|
int structLevel;
|
||||||
void enterStruct(const char* structName);
|
void enterStruct(const char* structName);
|
||||||
void leaveStruct();
|
void leaveStruct();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// This represents packed offset in streams:
|
// This represents packed offset in streams:
|
||||||
|
@ -16,7 +16,7 @@ namespace Utils
|
|||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
|
|
||||||
const char* result;
|
const char* result;
|
||||||
if(Components::Loader::IsUninitializing()) result = globalProvider.get(fmt, ap);
|
if (Components::Loader::IsUninitializing()) result = globalProvider.get(fmt, ap);
|
||||||
else result = provider.get(fmt, ap);
|
else result = provider.get(fmt, ap);
|
||||||
|
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
@ -149,7 +149,7 @@ namespace Utils
|
|||||||
|
|
||||||
std::string FormatBandwidth(size_t bytes, int milliseconds)
|
std::string FormatBandwidth(size_t bytes, int milliseconds)
|
||||||
{
|
{
|
||||||
static char* sizes[] =
|
static char* sizes[] =
|
||||||
{
|
{
|
||||||
"B",
|
"B",
|
||||||
"KB",
|
"KB",
|
||||||
@ -173,7 +173,7 @@ namespace Utils
|
|||||||
|
|
||||||
#ifdef ENABLE_BASE64
|
#ifdef ENABLE_BASE64
|
||||||
// Encodes a given string in Base64
|
// Encodes a given string in Base64
|
||||||
std::string EncodeBase64(const char* input, const unsigned long inputSize)
|
std::string EncodeBase64(const char* input, const unsigned long inputSize)
|
||||||
{
|
{
|
||||||
unsigned long outlen = long(inputSize + (inputSize / 3.0) + 16);
|
unsigned long outlen = long(inputSize + (inputSize / 3.0) + 16);
|
||||||
unsigned char* outbuf = new unsigned char[outlen]; //Reserve output memory
|
unsigned char* outbuf = new unsigned char[outlen]; //Reserve output memory
|
||||||
@ -184,7 +184,7 @@ namespace Utils
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Encodes a given string in Base64
|
// Encodes a given string in Base64
|
||||||
std::string EncodeBase64(const std::string& input)
|
std::string EncodeBase64(const std::string& input)
|
||||||
{
|
{
|
||||||
return EncodeBase64(input.data(), input.size());
|
return EncodeBase64(input.data(), input.size());
|
||||||
}
|
}
|
||||||
@ -192,7 +192,7 @@ namespace Utils
|
|||||||
|
|
||||||
#ifdef ENABLE_BASE128
|
#ifdef ENABLE_BASE128
|
||||||
// Encodes a given string in Base128
|
// Encodes a given string in Base128
|
||||||
std::string EncodeBase128(const std::string& input)
|
std::string EncodeBase128(const std::string& input)
|
||||||
{
|
{
|
||||||
base128 encoder;
|
base128 encoder;
|
||||||
|
|
||||||
@ -209,7 +209,7 @@ namespace Utils
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Generates a UUID and returns the string representation of it
|
// Generates a UUID and returns the string representation of it
|
||||||
std::string GenerateUUIDString()
|
std::string GenerateUUIDString()
|
||||||
{
|
{
|
||||||
// Generate UUID data
|
// Generate UUID data
|
||||||
UUID uuid;
|
UUID uuid;
|
||||||
|
@ -47,7 +47,7 @@ namespace Utils
|
|||||||
|
|
||||||
~Entry()
|
~Entry()
|
||||||
{
|
{
|
||||||
if(this->buffer) Utils::Memory::GetAllocator()->free(this->buffer);
|
if (this->buffer) Utils::Memory::GetAllocator()->free(this->buffer);
|
||||||
this->size = 0;
|
this->size = 0;
|
||||||
this->buffer = nullptr;
|
this->buffer = nullptr;
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ namespace Utils
|
|||||||
|
|
||||||
void WebIO::closeSession()
|
void WebIO::closeSession()
|
||||||
{
|
{
|
||||||
if(this->hSession) InternetCloseHandle(this->hSession);
|
if (this->hSession) InternetCloseHandle(this->hSession);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebIO::setCredentials(std::string _username, std::string _password)
|
void WebIO::setCredentials(std::string _username, std::string _password)
|
||||||
@ -324,7 +324,7 @@ namespace Utils
|
|||||||
|
|
||||||
while (InternetReadFile(this->hFile, buffer, 0x2000, &size))
|
while (InternetReadFile(this->hFile, buffer, 0x2000, &size))
|
||||||
{
|
{
|
||||||
if(this->cancel)
|
if (this->cancel)
|
||||||
{
|
{
|
||||||
this->closeConnection();
|
this->closeConnection();
|
||||||
return "";
|
return "";
|
||||||
|
@ -30,7 +30,7 @@ namespace Utils
|
|||||||
std::string postFile(std::string url, std::string data, std::string fieldName, std::string fileName);
|
std::string postFile(std::string url, std::string data, std::string fieldName, std::string fileName);
|
||||||
std::string postFile(std::string data, std::string fieldName, std::string fileName);
|
std::string postFile(std::string data, std::string fieldName, std::string fileName);
|
||||||
|
|
||||||
std::string post(std::string url, WebIO::Params params, bool* success= nullptr);
|
std::string post(std::string url, WebIO::Params params, bool* success = nullptr);
|
||||||
std::string post(std::string url, std::string body, bool* success = nullptr);
|
std::string post(std::string url, std::string body, bool* success = nullptr);
|
||||||
std::string post(WebIO::Params params, bool* success = nullptr);
|
std::string post(WebIO::Params params, bool* success = nullptr);
|
||||||
std::string post(std::string body, bool* success = nullptr);
|
std::string post(std::string body, bool* success = nullptr);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user