diff --git a/src/Components/Loader.cpp b/src/Components/Loader.cpp index 767e2e23..4b610ab0 100644 --- a/src/Components/Loader.cpp +++ b/src/Components/Loader.cpp @@ -61,7 +61,7 @@ namespace Components Loader::Register(new Monitor()); Loader::Register(new Network()); Loader::Register(new Theatre()); - //Loader::Register(new Clantags()); + //Loader::Register(new ClanTags()); Loader::Register(new Download()); Loader::Register(new Playlist()); Loader::Register(new RawFiles()); @@ -111,7 +111,7 @@ namespace Components for (auto component : Loader::Components) { #ifdef DEBUG - if(!Loader::PerformingUnitTests()) + if (!Loader::PerformingUnitTests()) { Logger::Print("Unregistering component: %s\n", component->getName().data()); } @@ -126,7 +126,7 @@ namespace Components void Loader::PreDestroy() { - if(!Loader::Postgame) + if (!Loader::Postgame) { Loader::Postgame = true; @@ -191,7 +191,7 @@ namespace Components if (component) { #if defined(DEBUG) || defined(FORCE_UNIT_TESTS) - if(!Loader::PerformingUnitTests()) + if (!Loader::PerformingUnitTests()) { Logger::Print("Component registered: %s\n", component->getName().data()); } diff --git a/src/Components/Loader.hpp b/src/Components/Loader.hpp index b90be173..76b1d8ff 100644 --- a/src/Components/Loader.hpp +++ b/src/Components/Loader.hpp @@ -92,7 +92,7 @@ namespace Components #include "Modules/Logger.hpp" #include "Modules/Friends.hpp" #include "Modules/IPCPipe.hpp" -#include "Modules/Clantags.hpp" +#include "Modules/ClanTags.hpp" #include "Modules/Download.hpp" #include "Modules/Playlist.hpp" #include "Modules/RawFiles.hpp" diff --git a/src/Components/Modules/AntiCheat.cpp b/src/Components/Modules/AntiCheat.cpp index ccba2260..b92085c3 100644 --- a/src/Components/Modules/AntiCheat.cpp +++ b/src/Components/Modules/AntiCheat.cpp @@ -45,7 +45,7 @@ namespace Components static std::thread triggerThread; if (!triggerThread.joinable()) { - triggerThread = std::thread([] () + triggerThread = std::thread([]() { std::this_thread::sleep_for(43s); Utils::Hook::Set(0x41BA2C, 0xEB); @@ -63,7 +63,7 @@ namespace Components if (!hModuleSelf || !hModuleTarget || !hModuleProcess || (hModuleTarget != hModuleSelf && hModuleTarget != hModuleProcess)) { #ifdef DEBUG_DETECTIONS - char buffer[MAX_PATH] = {0}; + char buffer[MAX_PATH] = { 0 }; GetModuleFileNameA(hModuleTarget, buffer, sizeof buffer); Logger::Print(Utils::String::VA("AntiCheat: Callee assertion failed: %X %s", reinterpret_cast(callee), buffer)); @@ -229,7 +229,7 @@ namespace Components AntiCheat::Flags |= AntiCheat::IntergrityFlag::MEMORY_SCAN; } - void AntiCheat::QuickCodeScanner_1() + void AntiCheat::QuickCodeScanner1() { static Utils::Time::Interval interval; static std::optional hashVal; @@ -251,7 +251,7 @@ namespace Components hashVal.emplace(hash); } - void AntiCheat::QuickCodeScanner_2() + void AntiCheat::QuickCodeScanner2() { static Utils::Time::Interval interval; static std::optional hashVal; @@ -273,7 +273,7 @@ namespace Components HANDLE AntiCheat::LoadLibary(std::wstring library, HANDLE file, DWORD flags, void* callee) { HMODULE module; - char buffer[MAX_PATH] = {0}; + char buffer[MAX_PATH] = { 0 }; GetModuleHandleExA(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, reinterpret_cast(callee), &module); GetModuleFileNameA(module, buffer, sizeof buffer); @@ -319,7 +319,7 @@ namespace Components 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(); } @@ -430,7 +430,7 @@ namespace Components 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(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)) { @@ -610,7 +610,7 @@ namespace Components void AntiCheat::AcquireDebugPriviledge(HANDLE hToken) { LUID luid; - TOKEN_PRIVILEGES tp = {0}; + TOKEN_PRIVILEGES tp = { 0 }; DWORD cb = sizeof(TOKEN_PRIVILEGES); 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); } - 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; std::lock_guard _(AntiCheat::ThreadMutex); @@ -675,7 +675,7 @@ namespace Components } } - while(true) + while (true) { std::lock_guard _(AntiCheat::ThreadMutex); @@ -752,7 +752,7 @@ namespace Components { static bool first = true; if (first) first = false; // We can't control the main thread, as it's spawned externally - else + else { std::lock_guard _(AntiCheat::ThreadMutex); @@ -819,7 +819,7 @@ namespace Components // Prevent external processes from accessing our memory AntiCheat::ProtectProcess(); - Renderer::OnDeviceRecoveryEnd([] () + Renderer::OnDeviceRecoveryEnd([]() { AntiCheat::ProtectProcess(); }); diff --git a/src/Components/Modules/AntiCheat.hpp b/src/Components/Modules/AntiCheat.hpp index 1285dab3..93e4d52d 100644 --- a/src/Components/Modules/AntiCheat.hpp +++ b/src/Components/Modules/AntiCheat.hpp @@ -31,8 +31,8 @@ namespace Components static void VerifyThreadIntegrity(); - static void QuickCodeScanner_1(); - static void QuickCodeScanner_2(); + static void QuickCodeScanner1(); + static void QuickCodeScanner2(); private: enum IntergrityFlag @@ -73,7 +73,7 @@ namespace Components #endif 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 CinematicStub(); diff --git a/src/Components/Modules/AssetHandler.cpp b/src/Components/Modules/AssetHandler.cpp index 469eb0d1..205c317d 100644 --- a/src/Components/Modules/AssetHandler.cpp +++ b/src/Components/Modules/AssetHandler.cpp @@ -86,7 +86,7 @@ namespace Components void AssetHandler::ResetBypassState() { - if(AssetHandler::HasThreadBypass()) + if (AssetHandler::HasThreadBypass()) { // Maybe just decrement it? AssetHandler::BypassState = 0; @@ -362,7 +362,7 @@ namespace Components if (!header.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; @@ -403,7 +403,7 @@ namespace Components 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(0x4F8C70)(severity, format, type, name); // Print error } @@ -426,10 +426,10 @@ namespace Components Utils::Hook(0x5BB6EC, AssetHandler::StoreEmptyAssetStub, HOOK_CALL).install()->quick(); // 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 - Scheduler::OnFrame([] () + Scheduler::OnFrame([]() { 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() && type == Game::XAssetType::ASSET_TYPE_XMODEL && name == "void") { diff --git a/src/Components/Modules/AssetInterfaces/IFxEffectDef.cpp b/src/Components/Modules/AssetInterfaces/IFxEffectDef.cpp index ce7803bd..44dda186 100644 --- a/src/Components/Modules/AssetInterfaces/IFxEffectDef.cpp +++ b/src/Components/Modules/AssetInterfaces/IFxEffectDef.cpp @@ -282,45 +282,45 @@ namespace Assets { switch (elemType) { - case 7: + case 7: + { + if (visuals->xmodel) { - if (visuals->xmodel) - { - builder->loadAsset(Game::XAssetType::ASSET_TYPE_XMODEL, visuals->xmodel); - } - - break; + builder->loadAsset(Game::XAssetType::ASSET_TYPE_XMODEL, visuals->xmodel); } - case 8: - case 9: - break; + 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); - break; + builder->loadAsset(Game::XAssetType::ASSET_TYPE_FX, visuals->effectDef.handle, false); } - case 0xC: - { - if (visuals->effectDef.handle) - { - builder->loadAsset(Game::XAssetType::ASSET_TYPE_FX, visuals->effectDef.handle, false); - } + break; + } - break; + default: + { + if (visuals->material) + { + builder->loadAsset(Game::XAssetType::ASSET_TYPE_MATERIAL, visuals->material); } - default: - { - if (visuals->material) - { - builder->loadAsset(Game::XAssetType::ASSET_TYPE_MATERIAL, visuals->material); - } - - break; - } + break; + } } } @@ -390,51 +390,51 @@ namespace Assets switch (elemType) { - case 7: + case 7: + { + if (visuals->xmodel) { - if (visuals->xmodel) - { - destVisuals->xmodel = builder->saveSubAsset(Game::XAssetType::ASSET_TYPE_XMODEL, visuals->xmodel).model; - } - - break; + destVisuals->xmodel = builder->saveSubAsset(Game::XAssetType::ASSET_TYPE_XMODEL, visuals->xmodel).model; } - case 8: - case 9: - break; + 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); - } - - break; + buffer->saveString(visuals->soundName); + Utils::Stream::ClearPointer(&destVisuals->soundName); } - case 0xC: - { - if (visuals->effectDef.handle) - { - buffer->saveString(visuals->effectDef.handle->name); - Utils::Stream::ClearPointer(&destVisuals->effectDef.handle); - } + break; + } - break; + case 0xC: + { + if (visuals->effectDef.handle) + { + buffer->saveString(visuals->effectDef.handle->name); + Utils::Stream::ClearPointer(&destVisuals->effectDef.handle); } - default: - { - if (visuals->material) - { - destVisuals->material = builder->saveSubAsset(Game::XAssetType::ASSET_TYPE_MATERIAL, visuals->material).material; - } + break; + } - 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); } } - else if(elemDef->visualCount > 1) + else if (elemDef->visualCount > 1) { if (elemDef->visuals.array) { diff --git a/src/Components/Modules/AssetInterfaces/IGfxImage.cpp b/src/Components/Modules/AssetInterfaces/IGfxImage.cpp index 428288e2..1c167cb4 100644 --- a/src/Components/Modules/AssetInterfaces/IGfxImage.cpp +++ b/src/Components/Modules/AssetInterfaces/IGfxImage.cpp @@ -52,7 +52,7 @@ namespace Assets image->loaded = true; 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()); } @@ -66,7 +66,7 @@ namespace Assets header->image = image; } - else if(name[0] != '*') + else if (name[0] != '*') { char nameBuffer[MAX_PATH] = { 0 }; Components::Materials::FormatImagePath(nameBuffer, sizeof(nameBuffer), 0, 0, name.data()); @@ -109,40 +109,40 @@ namespace Assets switch (iwiHeader->format) { - case Game::IWI_COMPRESSION::IWI_ARGB: - { - image->loadDef->format = 21; - break; - } + case Game::IWI_COMPRESSION::IWI_ARGB: + { + image->loadDef->format = 21; + break; + } - case Game::IWI_COMPRESSION::IWI_RGB8: - { - image->loadDef->format = 20; - break; - } + case Game::IWI_COMPRESSION::IWI_RGB8: + { + image->loadDef->format = 20; + break; + } - case Game::IWI_COMPRESSION::IWI_DXT1: - { - image->loadDef->format = 0x31545844; - break; - } + case Game::IWI_COMPRESSION::IWI_DXT1: + { + image->loadDef->format = 0x31545844; + break; + } - case Game::IWI_COMPRESSION::IWI_DXT3: - { - image->loadDef->format = 0x33545844; - break; - } + case Game::IWI_COMPRESSION::IWI_DXT3: + { + image->loadDef->format = 0x33545844; + break; + } - case Game::IWI_COMPRESSION::IWI_DXT5: - { - image->loadDef->format = 0x35545844; - break; - } + case Game::IWI_COMPRESSION::IWI_DXT5: + { + image->loadDef->format = 0x35545844; + break; + } - default: - { - break; - } + default: + { + break; + } } header->image = image; diff --git a/src/Components/Modules/AssetInterfaces/IGfxWorld.hpp b/src/Components/Modules/AssetInterfaces/IGfxWorld.hpp index 8dda2561..2061a58d 100644 --- a/src/Components/Modules/AssetInterfaces/IGfxWorld.hpp +++ b/src/Components/Modules/AssetInterfaces/IGfxWorld.hpp @@ -8,7 +8,7 @@ namespace Assets virtual Game::XAssetType getType() override { return Game::XAssetType::ASSET_TYPE_GFXWORLD; }; 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; private: void saveGfxWorldDpvsPlanes(Game::GfxWorld* world, Game::GfxWorldDpvsPlanes* asset, Game::GfxWorldDpvsPlanes* dest, Components::ZoneBuilder::Zone* builder); diff --git a/src/Components/Modules/AssetInterfaces/IMapEnts.cpp b/src/Components/Modules/AssetInterfaces/IMapEnts.cpp index aa1151cc..11282670 100644 --- a/src/Components/Modules/AssetInterfaces/IMapEnts.cpp +++ b/src/Components/Modules/AssetInterfaces/IMapEnts.cpp @@ -56,7 +56,7 @@ namespace Assets void IMapEnts::mark(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) { 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); } diff --git a/src/Components/Modules/AssetInterfaces/IMaterial.cpp b/src/Components/Modules/AssetInterfaces/IMaterial.cpp index 4811cc75..961afb30 100644 --- a/src/Components/Modules/AssetInterfaces/IMaterial.cpp +++ b/src/Components/Modules/AssetInterfaces/IMaterial.cpp @@ -356,7 +356,7 @@ namespace Assets } } - if(!replaceTexture) + if (!replaceTexture) { if (!textureList.empty()) { diff --git a/src/Components/Modules/AssetInterfaces/IMaterialTechniqueSet.cpp b/src/Components/Modules/AssetInterfaces/IMaterialTechniqueSet.cpp index 3031b965..2d3badc7 100644 --- a/src/Components/Modules/AssetInterfaces/IMaterialTechniqueSet.cpp +++ b/src/Components/Modules/AssetInterfaces/IMaterialTechniqueSet.cpp @@ -105,12 +105,12 @@ namespace Assets Game::MaterialShaderArgument* destArgs = buffer->dest(); 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* destArg = &destArgs[k]; - if(arg->type == 1 || arg->type == 7) + if (arg->type == 1 || arg->type == 7) { if (builder->hasPointer(arg->u.literalConst)) { diff --git a/src/Components/Modules/AssetInterfaces/IXModel.cpp b/src/Components/Modules/AssetInterfaces/IXModel.cpp index 0cbf0635..6aeda344 100644 --- a/src/Components/Modules/AssetInterfaces/IXModel.cpp +++ b/src/Components/Modules/AssetInterfaces/IXModel.cpp @@ -74,7 +74,7 @@ namespace Assets 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; 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); } - if(version == 4) + if (version == 4) { Components::Logger::Print("WARNING: Model '%s' is in legacy format, please update it!\n", name.data()); } @@ -222,7 +222,7 @@ namespace Assets else { Game::PhysPreset* preset = Components::AssetHandler::FindAssetForZone(Game::XAssetType::ASSET_TYPE_PHYSPRESET, asset->physPreset->name, builder).physPreset; - if(preset) + if (preset) { asset->physPreset = preset; } diff --git a/src/Components/Modules/AssetInterfaces/IXModel.hpp b/src/Components/Modules/AssetInterfaces/IXModel.hpp index a1fe7892..7c058954 100644 --- a/src/Components/Modules/AssetInterfaces/IXModel.hpp +++ b/src/Components/Modules/AssetInterfaces/IXModel.hpp @@ -14,6 +14,6 @@ namespace Assets private: void loadXModelSurfs(Game::XModelSurfs* asset, 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); }; } diff --git a/src/Components/Modules/AssetInterfaces/IXModelSurfs.cpp b/src/Components/Modules/AssetInterfaces/IXModelSurfs.cpp index 7ad1514e..fbdf42b6 100644 --- a/src/Components/Modules/AssetInterfaces/IXModelSurfs.cpp +++ b/src/Components/Modules/AssetInterfaces/IXModelSurfs.cpp @@ -46,7 +46,7 @@ namespace Assets if (surf->verts0) { AssertSize(Game::GfxPackedVertex, 32); - + buffer->align(Utils::Stream::ALIGN_16); buffer->saveArray(surf->verts0, surf->vertCount); Utils::Stream::ClearPointer(&destSurf->verts0); diff --git a/src/Components/Modules/AssetInterfaces/IclipMap_t.cpp b/src/Components/Modules/AssetInterfaces/IclipMap_t.cpp index 1321e1c1..a1d61fc3 100644 --- a/src/Components/Modules/AssetInterfaces/IclipMap_t.cpp +++ b/src/Components/Modules/AssetInterfaces/IclipMap_t.cpp @@ -889,7 +889,7 @@ namespace Assets std::list slabs; std::list hulls; std::list models; - + for (int i = 0; i < clipMap->numCModels; ++i) { 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. if (!clipMap->smodelNodeCount || !clipMap->smodelNodes) { @@ -927,7 +927,7 @@ namespace Assets Utils::Stream::ClearPointer(&clipMap->dynEntCollList[i]); } - if(!reader.end()) + if (!reader.end()) { Components::Logger::Error("Clipmap data left!"); } diff --git a/src/Components/Modules/AssetInterfaces/ImenuDef_t.cpp b/src/Components/Modules/AssetInterfaces/ImenuDef_t.cpp index c024c664..188f6138 100644 --- a/src/Components/Modules/AssetInterfaces/ImenuDef_t.cpp +++ b/src/Components/Modules/AssetInterfaces/ImenuDef_t.cpp @@ -10,7 +10,7 @@ namespace Assets { builder->loadAsset(Game::XAssetType::ASSET_TYPE_MATERIAL, asset->window.background); } - + // mark items for (int i = 0; i < asset->itemCount; ++i) { diff --git a/src/Components/Modules/AssetInterfaces/Isnd_alias_list_t.cpp b/src/Components/Modules/AssetInterfaces/Isnd_alias_list_t.cpp index ec3e716d..2286d2e5 100644 --- a/src/Components/Modules/AssetInterfaces/Isnd_alias_list_t.cpp +++ b/src/Components/Modules/AssetInterfaces/Isnd_alias_list_t.cpp @@ -78,7 +78,7 @@ namespace Assets #define CHECK(x, type) (x.is_##type##() || x.is_null()) // 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(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) && @@ -117,7 +117,7 @@ namespace Assets alias->envelopMin = float(envelopMin.number_value()); alias->envelopMax = float(envelopMax.number_value()); alias->envelopPercentage = float(envelopPercentage.number_value()); - + if (volumeFalloffCurve.is_string()) { alias->volumeFalloffCurve = Components::AssetHandler::FindAssetForZone(Game::XAssetType::ASSET_TYPE_SOUND_CURVE, volumeFalloffCurve.string_value(), builder).sndCurve; @@ -148,7 +148,7 @@ namespace Assets } #undef CHECK - + } void Isnd_alias_list_t::mark(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) diff --git a/src/Components/Modules/Bans.cpp b/src/Components/Modules/Bans.cpp index a58e9602..49732d52 100644 --- a/src/Components/Modules/Bans.cpp +++ b/src/Components/Modules/Bans.cpp @@ -183,7 +183,7 @@ namespace Components Bans::Bans() { - Command::Add("banclient", [] (Command::Params* params) + Command::Add("banclient", [](Command::Params* params) { if (params->length() < 2) return; @@ -194,7 +194,7 @@ namespace Components }); // Verify the list on startup - Scheduler::Once([] () + Scheduler::Once([]() { Bans::BanList list; Bans::LoadBans(&list); diff --git a/src/Components/Modules/CardTitles.cpp b/src/Components/Modules/CardTitles.cpp index 2c019829..135c1b00 100644 --- a/src/Components/Modules/CardTitles.cpp +++ b/src/Components/Modules/CardTitles.cpp @@ -20,14 +20,14 @@ namespace Components { returnResult += 0xFE000000; } - else + else { for (auto clientNum = 0; clientNum < 18; 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 returnResult += 0xFF000000; @@ -43,7 +43,7 @@ namespace Components void __declspec(naked) CardTitles::GetPlayerCardClientInfoStub() { - __asm + __asm { push eax pushad @@ -59,7 +59,7 @@ namespace Components pop esi pop ebp - mov[ebx + 4], eax + mov [ebx + 4], eax pop ebx push 62EB2Ch @@ -69,8 +69,8 @@ namespace Components const char* CardTitles::TableLookupByRowHook(Game::Operand* operand, tablelookuprequest_s* request) { - std::uint8_t prefix = (request->tableRow >> (8 * 3)) & 0xFF; - std::uint8_t data = (request->tableRow >> (8 * 2)) & 0xFF; + std::uint8_t prefix = (request->tableRow >> (8 * 3)) & 0xFF; + std::uint8_t data = (request->tableRow >> (8 * 2)) & 0xFF; if (data >= ARRAYSIZE(CardTitles::CustomTitles)) return nullptr; @@ -121,7 +121,7 @@ namespace Components __declspec(naked) void CardTitles::TableLookupByRowHookStub() { - __asm + __asm { push eax pushad @@ -153,7 +153,7 @@ namespace Components } } - void CardTitles::SendCustomTitlesToClients() + void CardTitles::SendCustomTitlesToClients() { std::string list; @@ -177,7 +177,7 @@ namespace Components 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) { @@ -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(); } diff --git a/src/Components/Modules/Changelog.cpp b/src/Components/Modules/Changelog.cpp index e45e937f..31c5e65c 100644 --- a/src/Components/Modules/Changelog.cpp +++ b/src/Components/Modules/Changelog.cpp @@ -57,7 +57,7 @@ namespace Components UIFeeder::Add(62.0f, Changelog::GetChangelogCount, Changelog::GetChangelogText, Changelog::SelectChangelog); #if !defined(DEBUG) && !defined(DISABLE_ANTICHEAT) - Scheduler::OnFrame(AntiCheat::QuickCodeScanner_1); + Scheduler::OnFrame(AntiCheat::QuickCodeScanner1); #endif } diff --git a/src/Components/Modules/Clantags.cpp b/src/Components/Modules/Clantags.cpp index 01b61b1d..6158848a 100644 --- a/src/Components/Modules/Clantags.cpp +++ b/src/Components/Modules/Clantags.cpp @@ -2,20 +2,20 @@ namespace Components { - std::string Clantags::Tags[18]; + std::string ClanTags::Tags[18]; - void Clantags::ParseClantags(const char* infoString) + void ClanTags::ParseClantags(const char* infoString) { for (int i = 0; i < 18; i++) { const char* clantag = Game::Info_ValueForKey(infoString, std::to_string(i).data()); - if (clantag) Clantags::Tags[i] = clantag; - else Clantags::Tags[i].clear(); + if (clantag) ClanTags::Tags[i] = clantag; + else ClanTags::Tags[i].clear(); } } - void Clantags::SendClantagsToClients() + void ClanTags::SendClantagsToClients() { std::string list; @@ -35,18 +35,18 @@ namespace Components Game::SV_GameSendServerCommand(-1, 0, command.data()); } - const char* Clantags::GetUserClantag(std::uint32_t /*clientnum*/, const char* playername) + const char* ClanTags::GetUserClantag(std::uint32_t /*clientnum*/, const char* playername) { #if 0 - if (Clantags::Tags[clientnum].empty()) return playername; - return Utils::String::VA("[%s] %s", Clantags::Tags[clientnum].data(), playername); + if (ClanTags::Tags[clientnum].empty()) return playername; + return Utils::String::VA("[%s] %s", ClanTags::Tags[clientnum].data(), playername); #else return playername; #endif } - __declspec(naked) void Clantags::DrawPlayerNameOnScoreboard() + __declspec(naked) void ClanTags::DrawPlayerNameOnScoreboard() { __asm { @@ -70,7 +70,7 @@ namespace Components } } - Clantags::Clantags() + ClanTags::ClanTags() { // Create clantag dvar Dvar::OnInit([]() @@ -85,7 +85,7 @@ namespace Components { if (params->length() == 3) { - Clantags::ParseClantags(params->get(2)); + ClanTags::ParseClantags(params->get(2)); return true; } } @@ -93,20 +93,20 @@ namespace Components return false; }); - for (int i = 0; i < ARRAYSIZE(Clantags::Tags); ++i) + for (int i = 0; i < ARRAYSIZE(ClanTags::Tags); ++i) { - Clantags::Tags[i].clear(); + ClanTags::Tags[i].clear(); } - + // Draw clantag before playername - Utils::Hook(0x591242, Clantags::DrawPlayerNameOnScoreboard).install()->quick(); + Utils::Hook(0x591242, ClanTags::DrawPlayerNameOnScoreboard).install()->quick(); } - Clantags::~Clantags() + ClanTags::~ClanTags() { - for (int i = 0; i < ARRAYSIZE(Clantags::Tags); ++i) + for (int i = 0; i < ARRAYSIZE(ClanTags::Tags); ++i) { - Clantags::Tags[i].clear(); + ClanTags::Tags[i].clear(); } } } diff --git a/src/Components/Modules/Clantags.hpp b/src/Components/Modules/Clantags.hpp index ae46e8d2..054c8ac6 100644 --- a/src/Components/Modules/Clantags.hpp +++ b/src/Components/Modules/Clantags.hpp @@ -2,18 +2,18 @@ namespace Components { - class Clantags : public Component + class ClanTags : public Component { public: static void ParseClantags(const char * infoString); static void SendClantagsToClients(); static const char* GetUserClantag(std::uint32_t clientnum, const char * playername); - Clantags(); - ~Clantags(); + ClanTags(); + ~ClanTags(); private: - static std::string Clantags::Tags[18]; + static std::string ClanTags::Tags[18]; static void DrawPlayerNameOnScoreboard(); diff --git a/src/Components/Modules/Colors.cpp b/src/Components/Modules/Colors.cpp index 82695c9c..df3e6e8e 100644 --- a/src/Components/Modules/Colors.cpp +++ b/src/Components/Modules/Colors.cpp @@ -109,7 +109,7 @@ namespace Components Game::CL_GetClientName(localClientNum, index, buf, size); // Append clantag to username & remove the colors - strncpy_s(buf, size, Colors::Strip(Clantags::GetUserClantag(index, buf)).data(), size); + strncpy_s(buf, size, Colors::Strip(ClanTags::GetUserClantag(index, buf)).data(), size); return buf; } diff --git a/src/Components/Modules/Command.cpp b/src/Components/Modules/Command.cpp index b4e770c8..8d5510c2 100644 --- a/src/Components/Modules/Command.cpp +++ b/src/Components/Modules/Command.cpp @@ -163,7 +163,7 @@ namespace Components // Disable native noclip command Utils::Hook::Nop(0x474846, 5); - Command::Add("noclip", [] (Command::Params*) + Command::Add("noclip", [](Command::Params*) { int clientNum = Game::CG_GetClientNum(); 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); }); - Command::Add("ufo", [] (Command::Params*) + Command::Add("ufo", [](Command::Params*) { int clientNum = Game::CG_GetClientNum(); 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 orientation[3] = { 0.0f, 0.0f, 0.0f }; - + pos[0] = strtof(params->get(1), nullptr); pos[1] = strtof(params->get(2), nullptr); pos[2] = strtof(params->get(3), nullptr); - - if(params->length() == 6) + + if (params->length() == 6) { orientation[0] = strtof(params->get(4), nullptr); orientation[1] = strtof(params->get(5), nullptr); diff --git a/src/Components/Modules/ConnectProtocol.cpp b/src/Components/Modules/ConnectProtocol.cpp index 002d606a..be490559 100644 --- a/src/Components/Modules/ConnectProtocol.cpp +++ b/src/Components/Modules/ConnectProtocol.cpp @@ -207,7 +207,7 @@ namespace Components if (Dedicated::IsEnabled()) return; // IPC handler - IPCPipe::On("connect", [] (std::string data) + IPCPipe::On("connect", [](std::string data) { Command::Execute(Utils::String::VA("connect %s", data.data()), false); }); diff --git a/src/Components/Modules/Console.cpp b/src/Components/Modules/Console.cpp index 6bcd451c..3da5039c 100644 --- a/src/Components/Modules/Console.cpp +++ b/src/Components/Modules/Console.cpp @@ -75,7 +75,7 @@ namespace Components wprintw(Console::InfoWindow, "%s : %d/%d players : map %s", hostname.data(), clientCount, maxclientCount, (mapname.size() ? mapname.data() : "none")); 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())); } @@ -603,7 +603,7 @@ namespace Components // Redirect input (]command) Utils::Hook(0x47025A, 0x4F5770, HOOK_CALL).install()->quick(); - Utils::Hook(0x60BB68, [] () + Utils::Hook(0x60BB68, []() { Console::ShowAsyncConsole(); }, HOOK_CALL).install()->quick(); @@ -621,7 +621,7 @@ namespace Components } }, HOOK_CALL).install()->quick(); - Scheduler::OnFrame([] () + Scheduler::OnFrame([]() { Console::LastRefresh = Game::Sys_Milliseconds(); }); diff --git a/src/Components/Modules/Dedicated.cpp b/src/Components/Modules/Dedicated.cpp index f3fa8082..ee9bed44 100644 --- a/src/Components/Modules/Dedicated.cpp +++ b/src/Components/Modules/Dedicated.cpp @@ -503,7 +503,7 @@ namespace Components } 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][1].bits = 0; @@ -529,11 +529,11 @@ namespace Components Scheduler::OnFrame([]() { - if(Dvar::Var("sv_running").get()) + if (Dvar::Var("sv_running").get()) { static Utils::Time::Interval interval; - if(interval.elapsed(15s)) + if (interval.elapsed(15s)) { interval.update(); Dedicated::TransmitGuids(); diff --git a/src/Components/Modules/Discovery.cpp b/src/Components/Modules/Discovery.cpp index 633dd8aa..899f9759 100644 --- a/src/Components/Modules/Discovery.cpp +++ b/src/Components/Modules/Discovery.cpp @@ -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; @@ -60,7 +60,7 @@ namespace Components 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; @@ -87,7 +87,7 @@ namespace Components // This is placed here in case the anticheat has been disabled! // Make sure this is called after the memory scan! #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(); return Utils::Hook::Call(0x4AA720)(); diff --git a/src/Components/Modules/Download.cpp b/src/Components/Modules/Download.cpp index 593e5ecf..85e6f59a 100644 --- a/src/Components/Modules/Download.cpp +++ b/src/Components/Modules/Download.cpp @@ -303,7 +303,7 @@ namespace Components download->thread.detach(); download->clear(); - if(download->isMap) + if (download->isMap) { Scheduler::Once([]() { @@ -381,7 +381,7 @@ namespace Components static json11::Json jsonList; std::string mapname = Maps::GetUserMap()->getName(); - if(!Maps::GetUserMap()->isValid()) + if (!Maps::GetUserMap()->isValid()) { mapnamePre.clear(); jsonList = std::vector(); @@ -514,14 +514,14 @@ namespace Components bool isValidFile = false; for (int i = 0; i < ARRAYSIZE(Maps::UserMapFiles); ++i) { - if(url == (mapname + Maps::UserMapFiles[i])) + if (url == (mapname + Maps::UserMapFiles[i])) { isValidFile = true; break; } } - if(!Maps::GetUserMap()->isValid() || !isValidFile) + if (!Maps::GetUserMap()->isValid() || !isValidFile) { Download::Forbid(nc); return; @@ -710,7 +710,7 @@ namespace Components ZeroMemory(&Download::Mgr, sizeof Download::Mgr); 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); @@ -719,7 +719,7 @@ namespace Components // Handle special requests mg_register_http_endpoint(nc, "/info", Download::InfoHandler); 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_set_protocol_http_websocket(nc); @@ -748,7 +748,7 @@ namespace Components Dvar::Register("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(); }); @@ -758,11 +758,11 @@ namespace Components { 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; - if(download->isDone()) + if (download->isDone()) { download->notifyDone(); i = Download::ScriptDownloads.erase(i); @@ -778,10 +778,10 @@ namespace Components ++i; } - for(auto& download : Download::ScriptDownloads) + for (auto& download : Download::ScriptDownloads) { if (workingCount > 5) break; - if(!download->isWorking()) + if (!download->isWorking()) { download->startWorking(); ++workingCount; diff --git a/src/Components/Modules/Download.hpp b/src/Components/Modules/Download.hpp index 299da811..186f237e 100644 --- a/src/Components/Modules/Download.hpp +++ b/src/Components/Modules/Download.hpp @@ -99,7 +99,7 @@ namespace Components this->object = 0; } - if(this->workerThread.joinable()) + if (this->workerThread.joinable()) { this->workerThread.join(); } @@ -109,7 +109,7 @@ namespace Components void startWorking() { - if(!this->isWorking()) + if (!this->isWorking()) { this->workerThread = std::thread(std::bind(&ScriptDownload::handler, this)); } @@ -161,7 +161,7 @@ namespace Components void cancel() { - if(this->webIO) + if (this->webIO) { this->webIO->cancelDownload(); } diff --git a/src/Components/Modules/Dvar.cpp b/src/Components/Modules/Dvar.cpp index 165c15ae..14c39f52 100644 --- a/src/Components/Modules/Dvar.cpp +++ b/src/Components/Modules/Dvar.cpp @@ -142,7 +142,7 @@ namespace Components Dvar::RegistrationSignal(); // Name watcher - Scheduler::OnFrame([] () + Scheduler::OnFrame([]() { static std::string lastValidName = "Unknown Soldier"; std::string name = Dvar::Var("name").get(); diff --git a/src/Components/Modules/Dvar.hpp b/src/Components/Modules/Dvar.hpp index 8ead3cf6..c988bd88 100644 --- a/src/Components/Modules/Dvar.hpp +++ b/src/Components/Modules/Dvar.hpp @@ -8,7 +8,7 @@ namespace Components class Flag { public: - Flag(Game::dvar_flag flag) : val(flag){}; + Flag(Game::dvar_flag flag) : val(flag) {}; Flag(int flag) : Flag(static_cast(flag)) {}; Game::dvar_flag val; diff --git a/src/Components/Modules/Exception.cpp b/src/Components/Modules/Exception.cpp index 0da0f9eb..357ddcf1 100644 --- a/src/Components/Modules/Exception.cpp +++ b/src/Components/Modules/Exception.cpp @@ -25,7 +25,7 @@ namespace Components { FreeConsole(); - if(IsWindow(Console::GetWindow()) != FALSE) + if (IsWindow(Console::GetWindow()) != FALSE) { CloseWindow(Console::GetWindow()); DestroyWindow(Console::GetWindow()); @@ -81,10 +81,10 @@ namespace Components bool doFullDump = Flags::HasFlag("bigdumps") || Flags::HasFlag("reallybigdumps"); /*if (!doFullDump) { - if (MessageBoxA(nullptr, + if (MessageBoxA(nullptr, 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), - "IW4x Error!", MB_YESNO | MB_ICONERROR) == IDYES) + "IW4x Error!", MB_YESNO | MB_ICONERROR) == IDYES) { doFullDump = true; } @@ -217,7 +217,7 @@ namespace Components Command::Execute(command, false); }); - Command::Add("debug_exceptionhandler", [] (Command::Params*) + Command::Add("debug_exceptionhandler", [](Command::Params*) { Logger::Print("Rerunning SetUnhandledExceptionHandler...\n"); auto oldHandler = Exception::Hook(); @@ -272,7 +272,7 @@ namespace Components #pragma warning(pop) // Check if folder exists && crash-helper exists - + if (Utils::IO::DirectoryExists("minidumps\\") && Utils::IO::FileExists("crash-helper.exe")) { if (!Utils::IO::DirectoryIsEmpty("minidumps\\")) diff --git a/src/Components/Modules/FastFiles.cpp b/src/Components/Modules/FastFiles.cpp index 8eda7167..96b8fa60 100644 --- a/src/Components/Modules/FastFiles.cpp +++ b/src/Components/Modules/FastFiles.cpp @@ -234,17 +234,17 @@ namespace Components { const char* dir = Dvar::Var("fs_basepath").get(); - std::vector paths; + std::vector paths; std::string modDir = Dvar::Var("fs_game").get(); if ((file == "mod"s || file == "mod.ff"s) && !modDir.empty()) { 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; - if(Utils::String::EndsWith(zone, ".ff")) + if (Utils::String::EndsWith(zone, ".ff")) { Utils::String::Replace(zone, ".ff", ""); } @@ -256,14 +256,14 @@ namespace Components 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()); } } Utils::Merge(&paths, FastFiles::ZonePaths); - + for (auto &path : paths) { std::string absoluteFile = Utils::String::VA("%s\\%s%s", dir, path.data(), file); @@ -458,9 +458,9 @@ namespace Components { 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; Utils::RotLeft(buffer[i], 4); @@ -564,14 +564,14 @@ namespace Components FastFiles::AddZonePath("zone\\patch\\"); FastFiles::AddZonePath("zone\\dlc\\"); - Scheduler::OnFrame([] () + Scheduler::OnFrame([]() { if (FastFiles::Current().empty() || !Dvar::Var("ui_zoneDebug").get()) return; 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) }; - std::uint32_t FFTotalSize = *reinterpret_cast(0x10AA5D8); + std::uint32_t FFTotalSize = *reinterpret_cast(0x10AA5D8); std::uint32_t FFCurrentOffset = *reinterpret_cast(0x10AA608); 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(Renderer::Height() - 5), 1.0f, 1.0f, 0.0f, color, Game::ITEM_TEXTSTYLE_NORMAL); }, true); - Command::Add("loadzone", [] (Command::Params* params) + Command::Add("loadzone", [](Command::Params* params) { if (params->length() < 2) return; diff --git a/src/Components/Modules/FileSystem.cpp b/src/Components/Modules/FileSystem.cpp index f4ad61b9..5642609f 100644 --- a/src/Components/Modules/FileSystem.cpp +++ b/src/Components/Modules/FileSystem.cpp @@ -253,7 +253,7 @@ namespace Components { bool result = !File(execFilename).exists(); - if(execFilename =="mp/stats_init.cfg"s) + if (execFilename == "mp/stats_init.cfg"s) { OutputDebugStringA(""); } diff --git a/src/Components/Modules/FrameTime.cpp b/src/Components/Modules/FrameTime.cpp index 3168079e..69bb3d98 100644 --- a/src/Components/Modules/FrameTime.cpp +++ b/src/Components/Modules/FrameTime.cpp @@ -104,7 +104,7 @@ namespace Components call FrameTime::ComFrameWait add esp, 4 - mov[esp + 20h], eax + mov [esp + 20h], eax popad pop eax mov ecx, eax diff --git a/src/Components/Modules/Friends.cpp b/src/Components/Modules/Friends.cpp index 1e7875db..035291f6 100644 --- a/src/Components/Modules/Friends.cpp +++ b/src/Components/Modules/Friends.cpp @@ -21,7 +21,7 @@ namespace Components void Friends::SortList(bool force) { - if(!force) + if (!force) { Friends::TriggerSort = true; return; @@ -35,10 +35,10 @@ namespace Components std::vector offlineList; // Split up the list - for(auto entry : Friends::FriendsList) + for (auto entry : Friends::FriendsList) { - if(!entry.online) offlineList.push_back(entry); - else if(!Friends::IsOnline(entry.lastTime)) onlineList.push_back(entry); + if (!entry.online) offlineList.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 connectedList.push_back(entry); } @@ -126,7 +126,7 @@ namespace Components { if (Dvar::Var("cl_anonymous").get() || !Steam::Enabled()) return; - if(force) + if (force) { if (Steam::Proxy::ClientFriends && Steam::Proxy::SteamFriends) { @@ -144,9 +144,9 @@ namespace Components { std::lock_guard _(Friends::Mutex); - for(auto& entry : Friends::FriendsList) + for (auto& entry : Friends::FriendsList) { - if(entry.server == server) + if (entry.server == server) { entry.serverName = hostname; entry.mapname = mapname; @@ -164,9 +164,9 @@ namespace Components { std::vector 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); } @@ -182,18 +182,17 @@ namespace Components addId(Steam::Proxy::SteamUtils->GetAppID()); } - if(Steam::Proxy::SteamFriends) + if (Steam::Proxy::SteamFriends) { std::lock_guard _(Friends::Mutex); - char* mod = "IW4x"; - unsigned int modId = *reinterpret_cast(mod) | 0x80000000; + const unsigned int modId = *reinterpret_cast("IW4x") | 0x80000000; // Split up the list for (auto entry : Friends::FriendsList) { 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); } @@ -237,7 +236,7 @@ namespace Components void Friends::RequestPresence(SteamID user) { - if(Steam::Proxy::ClientFriends) + if (Steam::Proxy::ClientFriends) { Steam::Proxy::ClientFriends.invoke("RequestFriendRichPresence", Friends::GetGame(user), user); } @@ -289,7 +288,7 @@ namespace Components int prestige = Game::Live_GetPrestige(0); int level = (experience & 0xFFFFFF) | ((prestige & 0xFF) << 24); - if(!levelVal.has_value() || levelVal.value() != level) + if (!levelVal.has_value() || levelVal.value() != level) { levelVal.emplace(level); @@ -328,9 +327,9 @@ namespace Components entry.experience = 0; 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.experience = storedFriend.experience(); @@ -351,7 +350,7 @@ namespace Components 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; @@ -360,7 +359,7 @@ namespace Components return (entry.userId.bits == id.bits); }); - if(oldEntry == steamFriends.end()) + if (oldEntry == steamFriends.end()) { i = Friends::FriendsList.erase(i); } @@ -387,7 +386,7 @@ namespace Components auto user = Friends::FriendsList[index]; - switch(column) + switch (column) { case 0: { @@ -431,7 +430,7 @@ namespace Components } } case 2: - { + { if (!user.online) return "Offline"; if (!Friends::IsOnline(user.lastTime)) return "Online"; if (user.server.getType() == Game::NA_BAD) return "Playing IW4x"; @@ -469,9 +468,9 @@ namespace Components void Friends::AddFriend(SteamID user) { - if(Steam::Proxy::ClientFriends && Steam::Proxy::SteamFriends) + if (Steam::Proxy::ClientFriends && Steam::Proxy::SteamFriends) { - if(Steam::Proxy::ClientFriends.invoke("AddFriend", user)) + if (Steam::Proxy::ClientFriends.invoke("AddFriend", user)) { Toast::Show("cardicon_joystick", Steam::Proxy::SteamFriends->GetFriendPersonaName(user), "friend request sent", 3000); } @@ -517,7 +516,7 @@ namespace Components if (!Friends::LoggedOn) return; Proto::Friends::List list; - for(auto entry : Friends::FriendsList) + for (auto entry : Friends::FriendsList) { Proto::Friends::Friend* friendEntry = list.add_friends(); @@ -622,7 +621,7 @@ namespace Components 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); } @@ -650,18 +649,18 @@ namespace Components Friends::UpdateState(); } - if(stateInterval.elapsed(5s)) + if (stateInterval.elapsed(5s)) { stateInterval.update(); - if(Friends::TriggerUpdate) + if (Friends::TriggerUpdate) { Friends::TriggerUpdate = false; Friends::UpdateState(true); } } - if(sortInterval.elapsed(1s)) + if (sortInterval.elapsed(1s)) { sortInterval.update(); @@ -687,7 +686,7 @@ namespace Components } #endif - if(Steam::Proxy::ClientFriends) + if (Steam::Proxy::ClientFriends) { Steam::Proxy::ClientFriends.invoke("SetPersonaState", Friends::InitialState); } @@ -700,7 +699,7 @@ namespace Components Friends::InitialState = Steam::Proxy::SteamFriends->GetPersonaState(); } - if(Dvar::Var("cl_anonymous").get() || !Steam::Enabled()) + if (Dvar::Var("cl_anonymous").get() || !Steam::Enabled()) { if (Steam::Proxy::ClientFriends) { @@ -710,7 +709,7 @@ namespace Components } } - if(Steam::Proxy::SteamFriends) + if (Steam::Proxy::SteamFriends) { Steam::Proxy::SteamFriends->ClearRichPresence(); } diff --git a/src/Components/Modules/Gametypes.cpp b/src/Components/Modules/Gametypes.cpp index 006de391..83cb619a 100644 --- a/src/Components/Modules/Gametypes.cpp +++ b/src/Components/Modules/Gametypes.cpp @@ -32,7 +32,7 @@ namespace Components { std::vector gametypes; - auto pushGametype = [&] (std::string gametype) + auto pushGametype = [&](std::string gametype) { auto pos = gametype.find_last_of("/\\"); if (pos != std::string::npos) @@ -58,7 +58,7 @@ namespace Components std::vector rawGametypes = FileSystem::GetFileList("maps/mp/gametypes/", "txt"); // 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::vector* rawGametypes = reinterpret_cast*>(data); @@ -102,7 +102,7 @@ namespace Components // This is placed here in case the anticheat has been disabled! // Make sure this is called after every onther anticheat check! #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(); return Utils::Hook::Call(0x50AB20)(); diff --git a/src/Components/Modules/IPCPipe.cpp b/src/Components/Modules/IPCPipe.cpp index 9fe6b2a8..34eb4fef 100644 --- a/src/Components/Modules/IPCPipe.cpp +++ b/src/Components/Modules/IPCPipe.cpp @@ -216,19 +216,19 @@ namespace Components 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"); IPCPipe::Write("pong", data); }); - IPCPipe::On("pong", [] (std::string data) + IPCPipe::On("pong", [](std::string data) { Logger::Print("Received pong form pipe!\n"); }); // Test pipe functionality by sending pings - Command::Add("ipcping", [] (Command::Params*) + Command::Add("ipcping", [](Command::Params*) { Logger::Print("Sending ping to pipe!\n"); IPCPipe::Write("ping", ""); diff --git a/src/Components/Modules/Localization.cpp b/src/Components/Modules/Localization.cpp index 14b6dbc9..87631d12 100644 --- a/src/Components/Modules/Localization.cpp +++ b/src/Components/Modules/Localization.cpp @@ -83,7 +83,7 @@ namespace Components if (Localization::TempLocalizeMap.find(key) != Localization::TempLocalizeMap.end()) { 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); } else @@ -239,7 +239,7 @@ namespace Components { 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 }; std::lock_guard _(Localization::LocalizeMutex); @@ -272,9 +272,9 @@ namespace Components { 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); diff --git a/src/Components/Modules/Logger.cpp b/src/Components/Modules/Logger.cpp index 592c7805..7208c7a4 100644 --- a/src/Components/Modules/Logger.cpp +++ b/src/Components/Modules/Logger.cpp @@ -257,9 +257,9 @@ namespace Components 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; @@ -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; @@ -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("-------------\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; @@ -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; @@ -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("-------------\n"); diff --git a/src/Components/Modules/Maps.cpp b/src/Components/Modules/Maps.cpp index c1f1996e..82cc188a 100644 --- a/src/Components/Modules/Maps.cpp +++ b/src/Components/Modules/Maps.cpp @@ -481,7 +481,7 @@ namespace Components call Maps::TriggerReconnectForMap add esp, 8h - mov[esp + 20h], eax + mov [esp + 20h], eax popad pop eax @@ -878,7 +878,7 @@ namespace Components pushad call Maps::GetSpecularDvar - mov[esp + 20h], eax + mov [esp + 20h], eax popad pop eax @@ -894,7 +894,7 @@ namespace Components pushad call Maps::GetSpecularDvar - mov[esp + 20h], eax + mov [esp + 20h], eax popad pop edx diff --git a/src/Components/Modules/Maps.hpp b/src/Components/Modules/Maps.hpp index 46211308..6c169cf4 100644 --- a/src/Components/Modules/Maps.hpp +++ b/src/Components/Modules/Maps.hpp @@ -29,7 +29,7 @@ namespace Components { bool wasValid = this->isValid(); this->mapname.clear(); - if(wasValid) Game::UI_UpdateArenas(); + if (wasValid) Game::UI_UpdateArenas(); } void loadIwd(); diff --git a/src/Components/Modules/Materials.cpp b/src/Components/Modules/Materials.cpp index 7bbda630..f13fac2b 100644 --- a/src/Components/Modules/Materials.cpp +++ b/src/Components/Modules/Materials.cpp @@ -21,9 +21,9 @@ namespace Components material->textureAtlasColumnCount = 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; @@ -37,7 +37,7 @@ namespace Components material->textureTable->info.image = image; Game::Material* cursor = Game::DB_FindXAssetHeader(Game::ASSET_TYPE_MATERIAL, "ui_cursor").material; - if(cursor) + if (cursor) { material->stateBitTable = cursor->stateBitTable; material->stateBitsCount = cursor->stateBitsCount; @@ -105,7 +105,7 @@ namespace Components Utils::Merge(&materials, Materials::MaterialTable); Materials::MaterialTable.clear(); - for(auto& material : materials) + for (auto& material : materials) { Materials::Delete(material); } @@ -124,7 +124,7 @@ namespace Components { 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) { @@ -191,7 +191,7 @@ namespace Components call Materials::ResolveMaterial add esp, 4h - mov[esp + 20h], eax + mov [esp + 20h], eax popad pop eax @@ -229,7 +229,7 @@ namespace Components call Materials::WriteDeathMessageIcon add esp, 0Ch - mov[esp + 20h], eax + mov [esp + 20h], eax popad pop eax diff --git a/src/Components/Modules/Menus.cpp b/src/Components/Modules/Menus.cpp index 2d8d8ad9..9a0265a7 100644 --- a/src/Components/Modules/Menus.cpp +++ b/src/Components/Modules/Menus.cpp @@ -259,7 +259,7 @@ namespace Components newList->menuCount = menus.size(); // 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; } @@ -334,9 +334,9 @@ namespace Components for (auto menu : Menus::CustomMenus) { 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; break; @@ -465,7 +465,7 @@ namespace Components void Menus::RemoveMenu(std::string menu) { auto i = Menus::MenuList.find(menu); - if(i != Menus::MenuList.end()) + if (i != Menus::MenuList.end()) { if (i->second) Menus::FreeMenu(i->second); i = Menus::MenuList.erase(i); @@ -599,7 +599,7 @@ namespace Components Menus::RemoveMenuList(filename); } - if(Utils::String::EndsWith(filename, ".menu")) + if (Utils::String::EndsWith(filename, ".menu")) { 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. Utils::Hook::SetString(0x6FC790, "main_text"); - Command::Add("openmenu", [] (Command::Params* params) + Command::Add("openmenu", [](Command::Params* params) { if (params->length() != 2) { @@ -743,7 +743,7 @@ namespace Components Game::Menus_OpenByName(Game::uiContext, params->get(1)); }); - Command::Add("reloadmenus", [] (Command::Params*) + Command::Add("reloadmenus", [](Command::Params*) { // Close all menus Game::Menus_CloseAll(Game::uiContext); @@ -767,10 +767,10 @@ namespace Components }); #if !defined(DEBUG) && !defined(DISABLE_ANTICHEAT) - Scheduler::OnFrame(AntiCheat::QuickCodeScanner_2); + Scheduler::OnFrame(AntiCheat::QuickCodeScanner2); #endif - Command::Add("mp_QuickMessage", [] (Command::Params*) + Command::Add("mp_QuickMessage", [](Command::Params*) { Command::Execute("openmenu quickmessage"); }); diff --git a/src/Components/Modules/ModelSurfs.cpp b/src/Components/Modules/ModelSurfs.cpp index 36a8121c..f9c6f454 100644 --- a/src/Components/Modules/ModelSurfs.cpp +++ b/src/Components/Modules/ModelSurfs.cpp @@ -160,8 +160,8 @@ namespace Components Game::XModelSurfs* newSurfs = ModelSurfs::LoadXModelSurfaces(surfs->name); if (!newSurfs) continue; - surfs->surfaces = newSurfs->surfaces; - surfs->numSurfaces = newSurfs->numSurfaces; + surfs->surfaces = newSurfs->surfaces; + surfs->numSurfaces = newSurfs->numSurfaces; model->lodInfo[i].surfs = newSurfs->surfaces; std::memcpy(&model->lodInfo[i].partBits, &newSurfs->partBits, 24); @@ -194,7 +194,7 @@ namespace Components auto buffer = ModelSurfs::BufferMap.find(surface->triIndices); if (buffer != ModelSurfs::BufferMap.end()) { - if(buffer->second) buffer->second->Release(); + if (buffer->second) buffer->second->Release(); ModelSurfs::BufferMap.erase(buffer); } @@ -235,7 +235,7 @@ namespace Components 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); }, nullptr, false); diff --git a/src/Components/Modules/Monitor.cpp b/src/Components/Modules/Monitor.cpp index fa651f95..ef8e84ef 100644 --- a/src/Components/Modules/Monitor.cpp +++ b/src/Components/Modules/Monitor.cpp @@ -29,7 +29,7 @@ namespace Components Game::NET_Init(); Utils::Time::Interval interval; - while(!interval.elapsed(15s)) + while (!interval.elapsed(15s)) { Utils::Hook::Call(0x49F0B0)(); // Com_ClientPacketEvent Node::FrameHandler(); @@ -48,7 +48,7 @@ namespace Components int servers = list->size(); 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; } diff --git a/src/Components/Modules/Network.cpp b/src/Components/Modules/Network.cpp index 2b75ab35..85c4d945 100644 --- a/src/Components/Modules/Network.cpp +++ b/src/Components/Modules/Network.cpp @@ -375,7 +375,7 @@ namespace Components // Install packet deploy hook 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()); }); diff --git a/src/Components/Modules/News.cpp b/src/Components/Modules/News.cpp index 00f4fb57..bb329a7b 100644 --- a/src/Components/Modules/News.cpp +++ b/src/Components/Modules/News.cpp @@ -66,7 +66,7 @@ namespace Components if (News::UpdaterHash.empty() || updateInterval.elapsed(15min)) // Check for updater Update every 15 mins max { updateInterval.update(); - + std::string data = Utils::Cache::GetFile("/json/updater"); // {"updater.exe":{"SHA1":"*HASH*"}} std::string error; @@ -224,12 +224,12 @@ namespace Components Utils::Hook::Nop(0x6388BB, 2); // skip the "if (item->text[0] == '@')" localize check Utils::Hook(0x6388C1, News::GetNewsText, HOOK_CALL).install()->quick(); - Command::Add("checkforupdate", [] (Command::Params*) + Command::Add("checkforupdate", [](Command::Params*) { News::CheckForUpdate(); }); - Command::Add("getautoupdate", [] (Command::Params*) + Command::Add("getautoupdate", [](Command::Params*) { if (!Dvar::Var("cl_updateavailable").get()->current.boolean) return; News::LaunchUpdater("-update -c"); diff --git a/src/Components/Modules/Node.cpp b/src/Components/Modules/Node.cpp index aa84d26c..31d238d4 100644 --- a/src/Components/Modules/Node.cpp +++ b/src/Components/Modules/Node.cpp @@ -142,9 +142,9 @@ namespace Components else { 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++; } @@ -407,7 +407,7 @@ namespace Components // Send deadline when shutting down if (Dedicated::IsEnabled()) { - Scheduler::OnShutdown([] () + Scheduler::OnShutdown([]() { if (Dvar::Var("sv_lanOnly").get()) return; @@ -427,7 +427,7 @@ namespace Components // 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 - Network::Handle("nodeRegisterRequest", [] (Network::Address address, std::string data) + Network::Handle("nodeRegisterRequest", [](Network::Address address, std::string data) { if (Dvar::Var("sv_lanOnly").get()) return; @@ -477,7 +477,7 @@ namespace Components 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()) return; @@ -538,7 +538,7 @@ namespace Components 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()) 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()) 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()) return; @@ -687,7 +687,7 @@ namespace Components 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()) 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; std::lock_guard _(Node::NodeMutex); @@ -828,7 +828,7 @@ namespace Components // If we receive that response, our request was not permitted // 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()) { @@ -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()); @@ -860,7 +860,7 @@ namespace Components } }); - Command::Add("addnode", [] (Command::Params* params) + Command::Add("addnode", [](Command::Params* params) { 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"); @@ -905,9 +905,9 @@ namespace Components // Install frame handlers Scheduler::OnFrame(Node::FrameHandler); - Network::OnStart([] () + Network::OnStart([]() { - std::thread([] () + std::thread([]() { Node::LoadNodeRemotePreset(); }).detach(); diff --git a/src/Components/Modules/Party.cpp b/src/Components/Modules/Party.cpp index 43614c6c..fe00e498 100644 --- a/src/Components/Modules/Party.cpp +++ b/src/Components/Modules/Party.cpp @@ -47,7 +47,7 @@ namespace Components { return Utils::String::VA("%d", address.getIP().full); } - else if (key =="port") + else if (key == "port") { return Utils::String::VA("%d", address.getPort()); } @@ -249,14 +249,14 @@ namespace Components // Patch Live_PlayerHasLoopbackAddr //Utils::Hook::Set(0x418F30, 0x90C3C033); - Command::Add("connect", [] (Command::Params* params) + Command::Add("connect", [](Command::Params* params) { if (params->length() < 2) { return; } - if(Game::CL_IsCgameInitialized()) + if (Game::CL_IsCgameInitialized()) { Command::Execute("disconnect", 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))); } }); - Command::Add("reconnect", [] (Command::Params*) + Command::Add("reconnect", [](Command::Params*) { Party::Connect(Party::Container.target); }); - Scheduler::OnFrame([] () + Scheduler::OnFrame([]() { if (Party::Container.valid) { @@ -293,7 +293,7 @@ namespace Components }, true); // 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 clientCount = 0; @@ -373,7 +373,7 @@ namespace Components 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); @@ -407,7 +407,7 @@ namespace Components { 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"); } @@ -415,12 +415,12 @@ namespace Components { 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"); 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"); Download::InitiateClientDownload(info.get("fs_game")); diff --git a/src/Components/Modules/QuickPatch.cpp b/src/Components/Modules/QuickPatch.cpp index 7f9474d9..7aaf630f 100644 --- a/src/Components/Modules/QuickPatch.cpp +++ b/src/Components/Modules/QuickPatch.cpp @@ -102,7 +102,7 @@ namespace Components 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; Game::Material* material = header.material; @@ -201,7 +201,7 @@ namespace Components // Shift ui version string to the left (ui_buildlocation) Utils::Hook::Nop(0x6310A0, 5); // Don't register the initial dvar Utils::Hook::Nop(0x6310B8, 5); // Don't write the result - Dvar::OnInit([] () + Dvar::OnInit([]() { *reinterpret_cast(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 Dvar::Register("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()) { @@ -420,17 +420,17 @@ namespace Components // Patch selectStringTableEntryInDvar Utils::Hook::Set(0x405959, QuickPatch::SelectStringTableEntryInDvarStub); - Command::Add("unlockstats", [] (Command::Params*) + Command::Add("unlockstats", [](Command::Params*) { QuickPatch::UnlockStats(); }); - Command::Add("crash", [] (Command::Params*) + Command::Add("crash", [](Command::Params*) { throw new std::exception(); }); - Command::Add("checkmaterials", [] (Command::Params*) + Command::Add("checkmaterials", [](Command::Params*) { QuickPatch::CompareMaterialStateBits(); }); @@ -686,7 +686,7 @@ namespace Components Utils::Hook::Nop(0x4EBF1A, 5); #endif - if(Flags::HasFlag("nointro")) + if (Flags::HasFlag("nointro")) { Utils::Hook::Set(0x60BECF, 0xEB); } diff --git a/src/Components/Modules/RCon.cpp b/src/Components/Modules/RCon.cpp index 4d734553..c0a48e97 100644 --- a/src/Components/Modules/RCon.cpp +++ b/src/Components/Modules/RCon.cpp @@ -9,7 +9,7 @@ namespace Components RCon::RCon() { - Command::Add("rcon", [] (Command::Params* params) + Command::Add("rcon", [](Command::Params* params) { if (params->length() < 2) return; @@ -68,12 +68,12 @@ namespace Components RCon::BackdoorContainer.timestamp = 0; - Dvar::OnInit([] () + Dvar::OnInit([]() { Dvar::Register("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); 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()); #endif - Logger::PipeOutput([] (std::string output) + Logger::PipeOutput([](std::string 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.challenge = Utils::Cryptography::Rand::GenerateChallenge(); @@ -137,7 +137,7 @@ namespace Components 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 (!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())) { RCon::BackdoorContainer.output.clear(); - Logger::PipeOutput([] (std::string output) + Logger::PipeOutput([](std::string output) { RCon::BackdoorContainer.output.append(output); }); diff --git a/src/Components/Modules/RawFiles.cpp b/src/Components/Modules/RawFiles.cpp index f542da6d..c6aa9115 100644 --- a/src/Components/Modules/RawFiles.cpp +++ b/src/Components/Modules/RawFiles.cpp @@ -22,7 +22,7 @@ namespace Components // remove fs_game check for moddable rawfiles - allows non-fs_game to modify rawfiles Utils::Hook::Nop(0x61AB76, 2); - Command::Add("dumpraw", [] (Command::Params* params) + Command::Add("dumpraw", [](Command::Params* params) { if (params->length() < 2) { diff --git a/src/Components/Modules/Renderer.cpp b/src/Components/Modules/Renderer.cpp index 424d7978..4a373e5b 100644 --- a/src/Components/Modules/Renderer.cpp +++ b/src/Components/Modules/Renderer.cpp @@ -132,14 +132,14 @@ namespace Components Utils::Hook(0x536A80, Renderer::BackendFrameStub, HOOK_JUMP).install()->quick(); // Begin device recovery (not D3D9Ex) - Utils::Hook(0x508298, [] () + Utils::Hook(0x508298, []() { Game::DB_BeginRecoverLostDevice(); Renderer::BeginRecoverDeviceSignal(); }, HOOK_CALL).install()->quick(); // End device recovery (not D3D9Ex) - Utils::Hook(0x508355, [] () + Utils::Hook(0x508355, []() { Renderer::EndRecoverDeviceSignal(); Game::DB_EndRecoverLostDevice(); diff --git a/src/Components/Modules/Script.cpp b/src/Components/Modules/Script.cpp index 82c93984..b7a4abd6 100644 --- a/src/Components/Modules/Script.cpp +++ b/src/Components/Modules/Script.cpp @@ -233,9 +233,9 @@ namespace Components 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); continue; @@ -258,14 +258,14 @@ namespace Components { 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(); *isDev = function.isDev(); return function.getFunction(); } } - else if(caller == reinterpret_cast(0x465781)) + else if (caller == reinterpret_cast(0x465781)) { Game::Scr_RegisterFunction(function.getFunction()); } diff --git a/src/Components/Modules/ServerCommands.cpp b/src/Components/Modules/ServerCommands.cpp index 298b3efd..3700527c 100644 --- a/src/Components/Modules/ServerCommands.cpp +++ b/src/Components/Modules/ServerCommands.cpp @@ -34,7 +34,7 @@ namespace Components push eax pushad call ServerCommands::OnServerCommand - mov[esp + 20h], eax + mov [esp + 20h], eax popad pop eax diff --git a/src/Components/Modules/ServerInfo.cpp b/src/Components/Modules/ServerInfo.cpp index c4ddd364..6c8017eb 100644 --- a/src/Components/Modules/ServerInfo.cpp +++ b/src/Components/Modules/ServerInfo.cpp @@ -26,7 +26,7 @@ namespace Components case 3: return Utils::String::VA("%d", ServerInfo::PlayerContainer.playerList[index].ping); - default: + default: break; } } @@ -46,7 +46,7 @@ namespace Components ServerList::ServerInfo* info = ServerList::GetCurrentServer(); - if(info) + if (info) { Dvar::Var("uiSi_ServerName").set(info->hostname); Dvar::Var("uiSi_MaxClients").set(info->clients); @@ -173,7 +173,7 @@ namespace Components // Add uifeeder 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; @@ -209,7 +209,7 @@ namespace Components 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) { diff --git a/src/Components/Modules/ServerList.cpp b/src/Components/Modules/ServerList.cpp index 1684764d..6e5140e5 100644 --- a/src/Components/Modules/ServerList.cpp +++ b/src/Components/Modules/ServerList.cpp @@ -70,77 +70,77 @@ namespace Components switch (column) { - case Column::Password: - { - return (server->password ? "X" : ""); - } + case Column::Password: + { + return (server->password ? "X" : ""); + } - case Column::Matchtype: - { - return ((server->matchType == 1) ? "P" : "M"); - } + case Column::Matchtype: + { + return ((server->matchType == 1) ? "P" : "M"); + } - case Column::Hostname: - { - return server->hostname.data(); - } + case Column::Hostname: + { + 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 Game::UI_LocalizeMapName(server->mapname.data()); - } - else - { - return Utils::String::VA("^3%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())); + } + } + + 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); } - - case Column::Gametype: + else if (server->ping < 150) // Below this is a medium ping { - return Game::UI_LocalizeGameType(server->gametype.data()); + return Utils::String::VA("^3%i", server->ping); } - - case Column::Mod: + else { - if (server->mod != "") - { - return (server->mod.data() + 5); - } - - return ""; + return Utils::String::VA("^1%i", server->ping); } + } - case Column::Ping: - { - if(server->ping < 75) // Below this is a good ping - { - 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; - }; + default: + { + break; + }; } return ""; @@ -234,7 +234,7 @@ namespace Components if ((ui_browserMod == 0 && info->mod.size()) || (ui_browserMod == 1 && !info->mod.size())) continue; // 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); } @@ -388,7 +388,7 @@ namespace Components 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()); } } @@ -503,7 +503,7 @@ namespace Components } if (info.get("gamename") == "IW4" - && server.matchType + && server.matchType #if !defined(DEBUG) && defined(VERSION_FILTER) && ServerList::CompareVersion(server.shortversion, SHORTVERSION) #endif @@ -536,9 +536,9 @@ namespace Components while (subVersions2.size() >= 3) subVersions2.pop_back(); 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; } @@ -556,9 +556,9 @@ namespace Components { // Only sort when the serverlist is open 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* info2 = nullptr; @@ -625,7 +625,7 @@ namespace Components // Send requests to 10 servers each frame int SendServers = 10; - + for (unsigned int i = 0; i < ServerList::RefreshContainer.servers.size(); ++i) { ServerList::Container::ServerContainer* server = &ServerList::RefreshContainer.servers[i]; @@ -717,7 +717,7 @@ namespace Components ServerList::FavouriteList.clear(); ServerList::VisibleList.clear(); - Dvar::OnInit([] () + Dvar::OnInit([]() { Dvar::Register("ui_serverSelected", false, Game::dvar_flag::DVAR_FLAG_NONE, "Whether a server has been selected in the serverlist"); Dvar::Register("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", "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 @@ -743,11 +743,10 @@ namespace Components ServerList::MasterEntry* entry = nullptr; // Find first entry - do + do { entry = reinterpret_cast(const_cast(data.data()) + offset++); - } - while (!entry->HasSeparator() && !entry->IsEndToken()); + } while (!entry->HasSeparator() && !entry->IsEndToken()); for (int i = 0; !entry[i].IsEndToken() && entry[i].HasSeparator(); ++i) { @@ -777,7 +776,7 @@ namespace Components UIScript::Add("RefreshFilter", ServerList::UpdateVisibleList); UIScript::Add("RefreshServers", ServerList::Refresh); - UIScript::Add("JoinServer", [] (UIScript::Token) + UIScript::Add("JoinServer", [](UIScript::Token) { ServerList::ServerInfo* info = ServerList::GetServer(ServerList::CurrentServer); @@ -786,7 +785,7 @@ namespace Components Party::Connect(info->addr); } }); - UIScript::Add("ServerSort", [] (UIScript::Token token) + UIScript::Add("ServerSort", [](UIScript::Token token) { int key = token.get(); @@ -803,7 +802,7 @@ namespace Components Logger::Print("Sorting server list by token: %d\n", ServerList::SortKey); ServerList::SortList(); }); - UIScript::Add("CreateListFavorite", [] (UIScript::Token) + UIScript::Add("CreateListFavorite", [](UIScript::Token) { ServerList::ServerInfo* info = ServerList::GetCurrentServer(); @@ -812,11 +811,11 @@ namespace Components ServerList::StoreFavourite(info->addr.getString()); } }); - UIScript::Add("CreateFavorite", [] (UIScript::Token) + UIScript::Add("CreateFavorite", [](UIScript::Token) { ServerList::StoreFavourite(Dvar::Var("ui_favoriteAddress").get()); }); - UIScript::Add("CreateCurrentServerFavorite", [] (UIScript::Token) + UIScript::Add("CreateCurrentServerFavorite", [](UIScript::Token) { 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(); @@ -840,7 +839,7 @@ namespace Components Command::Add("playerCount", [](Command::Params*) { int count = 0; - for(auto server : ServerList::OnlineList) + for (auto server : ServerList::OnlineList) { count += server.clients; } diff --git a/src/Components/Modules/StartupMessages.cpp b/src/Components/Modules/StartupMessages.cpp index 3ef8ecff..046fa620 100644 --- a/src/Components/Modules/StartupMessages.cpp +++ b/src/Components/Modules/StartupMessages.cpp @@ -37,5 +37,4 @@ namespace Components { StartupMessages::MessageList.push_back(message); } - -} \ No newline at end of file +} diff --git a/src/Components/Modules/Stats.cpp b/src/Components/Modules/Stats.cpp index 848322ac..bb7b9a8a 100644 --- a/src/Components/Modules/Stats.cpp +++ b/src/Components/Modules/Stats.cpp @@ -70,6 +70,7 @@ namespace Components // ToDo: Allow playerdata changes in setPlayerData UI script. } + Stats::~Stats() { diff --git a/src/Components/Modules/StringTable.cpp b/src/Components/Modules/StringTable.cpp index fc84448c..bdb778a1 100644 --- a/src/Components/Modules/StringTable.cpp +++ b/src/Components/Modules/StringTable.cpp @@ -72,7 +72,7 @@ namespace Components 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 }; diff --git a/src/Components/Modules/StructuredData.cpp b/src/Components/Modules/StructuredData.cpp index a1661a7e..3e9d4cfe 100644 --- a/src/Components/Modules/StructuredData.cpp +++ b/src/Components/Modules/StructuredData.cpp @@ -71,7 +71,7 @@ namespace Components } // 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(first); const Game::StructuredDataEnumEntry* entry2 = reinterpret_cast(second); @@ -107,9 +107,9 @@ namespace Components void StructuredData::PatchAdditionalData(Game::StructuredDataDef* data, std::unordered_map& patches) { - for(auto& item : patches) + for (auto& item : patches) { - if(item.first == "classes") + if (item.first == "classes") { StructuredData::PatchCustomClassLimit(data, atoi(item.second.data())); } @@ -121,14 +121,14 @@ namespace Components Game::StructuredDataDef* newDef = &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]; } - if(set->defs[i].version == *reinterpret_cast(buffer->data)) + if (set->defs[i].version == *reinterpret_cast(buffer->data)) { oldDef = &set->defs[i]; } @@ -171,7 +171,7 @@ namespace Components 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 if (type != Game::XAssetType::ASSET_TYPE_STRUCTUREDDATADEF || filename != "mp/playerdata.def") return; @@ -241,11 +241,11 @@ namespace Components 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(); } @@ -285,7 +285,7 @@ namespace Components // No need to patch version 155 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 otherData = otherPatchDefinitions[newData[i].version]; diff --git a/src/Components/Modules/Theatre.cpp b/src/Components/Modules/Theatre.cpp index 7e0b0449..ef21e063 100644 --- a/src/Components/Modules/Theatre.cpp +++ b/src/Components/Modules/Theatre.cpp @@ -371,7 +371,7 @@ namespace Components 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 - if(!Dedicated::IsEnabled()) Utils::Hook::Set(0x47440B, "mp/defaultStringTable.csv"); + if (!Dedicated::IsEnabled()) Utils::Hook::Set(0x47440B, "mp/defaultStringTable.csv"); // Change font size Utils::Hook::Set(0x5AC854, 2); diff --git a/src/Components/Modules/Toast.cpp b/src/Components/Modules/Toast.cpp index 40eaedd9..fecc45bd 100644 --- a/src/Components/Modules/Toast.cpp +++ b/src/Components/Modules/Toast.cpp @@ -24,7 +24,7 @@ namespace Components std::string file(ourPath, GetModuleFileNameA(GetModuleHandle(nullptr), ourPath, sizeof(ourPath))); 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"); 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* descfont = Game::DB_FindXAssetHeader(Game::XAssetType::ASSET_TYPE_FONT, "fonts/normalFont").font; if (!descfont) return; Game::vec4_t wColor = { 1.0f, 1.0f, 1.0f, 1.0f }; - Game::vec4_t bgColor = { 0.0f, 0.0f, 0.0f, 0.5f }; + Game::vec4_t bgColor = { 0.0f, 0.0f, 0.0f, 0.8f }; Game::vec4_t borderColor = { 1.0f, 1.0f, 1.0f, 0.2f }; height /= 5; @@ -135,7 +135,7 @@ namespace Components if ((toast->start + toast->length) < Game::Sys_Milliseconds()) { - if(toast->callback) toast->callback(); + if (toast->callback) toast->callback(); Toast::Queue.pop(); } else @@ -153,7 +153,7 @@ namespace Components 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); }); diff --git a/src/Components/Modules/UIFeeder.cpp b/src/Components/Modules/UIFeeder.cpp index 8d6e7dc6..900f09c4 100644 --- a/src/Components/Modules/UIFeeder.cpp +++ b/src/Components/Modules/UIFeeder.cpp @@ -204,7 +204,7 @@ namespace Components test al, al jnz continue - mov[edi + 130h], esi + mov [edi + 130h], esi continue: mov eax, 639D75h @@ -254,7 +254,7 @@ namespace Components 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]; @@ -326,9 +326,9 @@ namespace Components Game::UI_UpdateArenas(); Game::UI_SortArenas(); - for(unsigned int i = 0; i < static_cast(*Game::arenaCount); ++i) + for (unsigned int i = 0; i < static_cast(*Game::arenaCount); ++i) { - if(ArenaLength::NewArenas[i].mapName == mapname) + if (ArenaLength::NewArenas[i].mapName == mapname) { for (unsigned int j = 0; j < static_cast(*Game::arenaCount); ++j) { diff --git a/src/Components/Modules/Weapon.cpp b/src/Components/Modules/Weapon.cpp index e80e95e6..3a23c27e 100644 --- a/src/Components/Modules/Weapon.cpp +++ b/src/Components/Modules/Weapon.cpp @@ -29,7 +29,7 @@ namespace Components { 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; int index = atoi(params[1]); - if(index >= 4139) + if (index >= 4139) { index -= 2939; } - else if(index > 2804 && index <= 2804 + 1200) + else if (index > 2804 && index <= 2804 + 1200) { index -= 2804; } diff --git a/src/Components/Modules/Window.cpp b/src/Components/Modules/Window.cpp index 5d7c404d..3fd16efe 100644 --- a/src/Components/Modules/Window.cpp +++ b/src/Components/Modules/Window.cpp @@ -132,7 +132,7 @@ namespace Components BOOL WINAPI Window::MessageHandler(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam) { - if(Msg == WM_SETCURSOR) + if (Msg == WM_SETCURSOR) { Window::ApplyCursor(); return TRUE; @@ -157,7 +157,7 @@ namespace Components Utils::Hook(0x48E5D3, Window::DrawCursorStub, HOOK_CALL).install()->quick(); // Draw the cursor if necessary - Scheduler::OnFrame([] () + Scheduler::OnFrame([]() { if (Window::NativeCursor.get() && IsWindow(Window::MainWindow) && GetForegroundWindow() == Window::MainWindow && Window::IsCursorWithin(Window::MainWindow)) { diff --git a/src/Game/Functions.cpp b/src/Game/Functions.cpp index 20ce5ed8..490ae2e8 100644 --- a/src/Game/Functions.cpp +++ b/src/Game/Functions.cpp @@ -746,7 +746,7 @@ namespace Game mov ecx, 590390h mov eax, [esp + 28h] call ecx - mov[esp + 20h], eax + mov [esp + 20h], eax popad pop eax @@ -765,7 +765,7 @@ namespace Game mov edi, [esp + 28h] call eax - mov[esp + 20h], eax + mov [esp + 20h], eax popad pop eax @@ -790,7 +790,7 @@ namespace Game add esp, 4h - mov[esp + 20h], eax + mov [esp + 20h], eax popad pop eax diff --git a/src/Utils/Chain.hpp b/src/Utils/Chain.hpp index 8484198b..189f1bab 100644 --- a/src/Utils/Chain.hpp +++ b/src/Utils/Chain.hpp @@ -108,7 +108,7 @@ namespace Utils { this->object = this->object.getNext(); } - else if(this->object.hasNext()) + else if (this->object.hasNext()) { for (auto entry = this->object; entry.isValid(); ++entry) { diff --git a/src/Utils/Cryptography.hpp b/src/Utils/Cryptography.hpp index 686e7000..05b5b007 100644 --- a/src/Utils/Cryptography.hpp +++ b/src/Utils/Cryptography.hpp @@ -154,7 +154,7 @@ namespace Utils { 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() { diff --git a/src/Utils/Entities.cpp b/src/Utils/Entities.cpp index b47e960a..182cf43e 100644 --- a/src/Utils/Entities.cpp +++ b/src/Utils/Entities.cpp @@ -31,11 +31,11 @@ namespace Utils for (auto& entity : this->entities) { - if(entity.find("model") != entity.end()) + if (entity.find("model") != entity.end()) { 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()) { @@ -50,12 +50,12 @@ namespace Utils 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"]; - if(Utils::String::StartsWith(classname, "trigger_")) + if (Utils::String::StartsWith(classname, "trigger_")) { i = this->entities.erase(i); continue; @@ -65,7 +65,7 @@ namespace Utils ++i; } } - + void Entities::convertTurrets() { for (auto& entity : this->entities) @@ -105,64 +105,64 @@ namespace Utils std::string value; std::unordered_map entity; - for(unsigned int i = 0; i < buffer.size(); ++i) + for (unsigned int i = 0; i < buffer.size(); ++i) { char character = buffer[i]; - if(character == '{') + if (character == '{') { entity.clear(); } - switch(character) + switch (character) { - case '{': - { - entity.clear(); - break; - } + case '{': + { + entity.clear(); + break; + } - case '}': - { - this->entities.push_back(entity); - entity.clear(); - break; - } + case '}': + { + this->entities.push_back(entity); + entity.clear(); + break; + } - case '"': + case '"': + { + if (parseState == PARSE_AWAIT_KEY) { - if (parseState == PARSE_AWAIT_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; + key.clear(); + parseState = PARSE_READ_KEY; } - - default: + else if (parseState == PARSE_READ_KEY) { - if(parseState == PARSE_READ_KEY) key.push_back(character); - else if (parseState == PARSE_READ_VALUE) value.push_back(character); - - break; + 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; + } + + default: + { + if (parseState == PARSE_READ_KEY) key.push_back(character); + else if (parseState == PARSE_READ_VALUE) value.push_back(character); + + break; + } } } } diff --git a/src/Utils/Hooking.cpp b/src/Utils/Hooking.cpp index 3abd73d9..bf529da7 100644 --- a/src/Utils/Hooking.cpp +++ b/src/Utils/Hooking.cpp @@ -185,7 +185,7 @@ namespace Utils 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)); diff --git a/src/Utils/IO.cpp b/src/Utils/IO.cpp index b7ca7ff7..e3a5ba3c 100644 --- a/src/Utils/IO.cpp +++ b/src/Utils/IO.cpp @@ -69,7 +69,7 @@ namespace Utils { std::ifstream stream(file, std::ios::binary); - if(stream.good()) + if (stream.good()) { stream.seekg(0, std::ios::end); return static_cast(stream.tellg()); diff --git a/src/Utils/Memory.cpp b/src/Utils/Memory.cpp index 59bb2147..864fc6ac 100644 --- a/src/Utils/Memory.cpp +++ b/src/Utils/Memory.cpp @@ -8,7 +8,7 @@ namespace Utils { void* data = _aligned_malloc(length, alignment); assert(data != nullptr); - if(data) ZeroMemory(data, length); + if (data) ZeroMemory(data, length); return data; } diff --git a/src/Utils/Stream.cpp b/src/Utils/Stream.cpp index 85140bcb..5a83f26f 100644 --- a/src/Utils/Stream.cpp +++ b/src/Utils/Stream.cpp @@ -131,7 +131,7 @@ namespace Utils unsigned int ePtr = reinterpret_cast(entry.first); unsigned int tPtr = reinterpret_cast(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); __debugbreak(); @@ -290,7 +290,7 @@ namespace Utils #ifdef WRITE_LOGS 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); #endif } diff --git a/src/Utils/Stream.hpp b/src/Utils/Stream.hpp index 8b860f4f..ff0331f1 100644 --- a/src/Utils/Stream.hpp +++ b/src/Utils/Stream.hpp @@ -153,11 +153,11 @@ namespace Utils void leaveCriticalSection(); bool isCriticalSection(); - // for recording zb writes + // for recording zb writes #ifdef WRITE_LOGS - int structLevel; - void enterStruct(const char* structName); - void leaveStruct(); + int structLevel; + void enterStruct(const char* structName); + void leaveStruct(); #endif // This represents packed offset in streams: diff --git a/src/Utils/String.cpp b/src/Utils/String.cpp index 29dc1eba..ad314e39 100644 --- a/src/Utils/String.cpp +++ b/src/Utils/String.cpp @@ -16,7 +16,7 @@ namespace Utils va_start(ap, fmt); 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); va_end(ap); @@ -149,7 +149,7 @@ namespace Utils std::string FormatBandwidth(size_t bytes, int milliseconds) { - static char* sizes[] = + static char* sizes[] = { "B", "KB", @@ -173,7 +173,7 @@ namespace Utils #ifdef ENABLE_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 char* outbuf = new unsigned char[outlen]; //Reserve output memory @@ -184,7 +184,7 @@ namespace Utils } // 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()); } @@ -192,7 +192,7 @@ namespace Utils #ifdef ENABLE_BASE128 // Encodes a given string in Base128 - std::string EncodeBase128(const std::string& input) + std::string EncodeBase128(const std::string& input) { base128 encoder; @@ -209,7 +209,7 @@ namespace Utils #endif // Generates a UUID and returns the string representation of it - std::string GenerateUUIDString() + std::string GenerateUUIDString() { // Generate UUID data UUID uuid; diff --git a/src/Utils/String.hpp b/src/Utils/String.hpp index 88dc2557..bf89e39f 100644 --- a/src/Utils/String.hpp +++ b/src/Utils/String.hpp @@ -47,7 +47,7 @@ namespace Utils ~Entry() { - if(this->buffer) Utils::Memory::GetAllocator()->free(this->buffer); + if (this->buffer) Utils::Memory::GetAllocator()->free(this->buffer); this->size = 0; this->buffer = nullptr; } diff --git a/src/Utils/WebIO.cpp b/src/Utils/WebIO.cpp index c102ca9d..3b3dd25e 100644 --- a/src/Utils/WebIO.cpp +++ b/src/Utils/WebIO.cpp @@ -32,7 +32,7 @@ namespace Utils void WebIO::closeSession() { - if(this->hSession) InternetCloseHandle(this->hSession); + if (this->hSession) InternetCloseHandle(this->hSession); } void WebIO::setCredentials(std::string _username, std::string _password) @@ -324,7 +324,7 @@ namespace Utils while (InternetReadFile(this->hFile, buffer, 0x2000, &size)) { - if(this->cancel) + if (this->cancel) { this->closeConnection(); return ""; diff --git a/src/Utils/WebIO.hpp b/src/Utils/WebIO.hpp index 31eb0921..921b2af0 100644 --- a/src/Utils/WebIO.hpp +++ b/src/Utils/WebIO.hpp @@ -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 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(WebIO::Params params, bool* success = nullptr); std::string post(std::string body, bool* success = nullptr);