From 3e5829545a06f364c4dfc6a7973916f3f6c6520f Mon Sep 17 00:00:00 2001 From: TheApadayo Date: Mon, 26 Dec 2016 13:55:36 -0500 Subject: [PATCH] [QuickPatch] add statebitsentry check code --- src/Components/Modules/QuickPatch.cpp | 44 +++++++++++++++++++++++++++ src/Components/Modules/QuickPatch.hpp | 2 ++ 2 files changed, 46 insertions(+) diff --git a/src/Components/Modules/QuickPatch.cpp b/src/Components/Modules/QuickPatch.cpp index 048cf17e..88fa34c8 100644 --- a/src/Components/Modules/QuickPatch.cpp +++ b/src/Components/Modules/QuickPatch.cpp @@ -141,6 +141,45 @@ namespace Components Game::CL_SelectStringTableEntryInDvar_f(); } + void QuickPatch::CompareMaterialStateBits() + { + Game::DB_EnumXAssets(Game::XAssetType::ASSET_TYPE_MATERIAL, [] (Game::XAssetHeader header, void* /*unused*/) + { + bool first = true; + Game::Material* material = header.material; + Logger::Print(6, "Checking material %s...", material->name); + #define COMPARE_TECHNIQUES(x) if(!(material->stateBitsEntry[(Game::MaterialTechniqueType:: ## x)] == material->stateBitsEntry[(Game::MaterialTechniqueType:: ## x ## _DFOG)])) \ + { \ + if(first) { Logger::Print("\nMismatch in material %s:\n", material->name); first = false; } \ + Logger::Print(6, #x " != " #x "_DFOG\n"); \ + Logger::Print("0x02%hhx %hhb\n", material->stateBitsEntry[(Game::MaterialTechniqueType:: ## x)], material->stateBitsEntry[(Game::MaterialTechniqueType:: ## x)]); \ + Logger::Print("0x02%hhx %hhb\n", material->stateBitsEntry[(Game::MaterialTechniqueType:: ## x ## _DFOG)], material->stateBitsEntry[(Game::MaterialTechniqueType:: ## x ## _DFOG)]); \ + } + COMPARE_TECHNIQUES(TECHNIQUE_EMISSIVE) + COMPARE_TECHNIQUES(TECHNIQUE_EMISSIVE_SHADOW) + COMPARE_TECHNIQUES(TECHNIQUE_LIT) + COMPARE_TECHNIQUES(TECHNIQUE_LIT_SUN) + COMPARE_TECHNIQUES(TECHNIQUE_LIT_SUN_SHADOW) + COMPARE_TECHNIQUES(TECHNIQUE_LIT_SPOT) + COMPARE_TECHNIQUES(TECHNIQUE_LIT_SPOT_SHADOW) + COMPARE_TECHNIQUES(TECHNIQUE_LIT_OMNI) + COMPARE_TECHNIQUES(TECHNIQUE_LIT_OMNI_SHADOW) + COMPARE_TECHNIQUES(TECHNIQUE_LIT_INSTANCED) + COMPARE_TECHNIQUES(TECHNIQUE_LIT_INSTANCED_SUN) + COMPARE_TECHNIQUES(TECHNIQUE_LIT_INSTANCED_SUN_SHADOW) + COMPARE_TECHNIQUES(TECHNIQUE_LIT_INSTANCED_SPOT) + COMPARE_TECHNIQUES(TECHNIQUE_LIT_INSTANCED_SPOT_SHADOW) + COMPARE_TECHNIQUES(TECHNIQUE_LIT_INSTANCED_OMNI) + COMPARE_TECHNIQUES(TECHNIQUE_LIT_INSTANCED_OMNI_SHADOW) + #undef COMPARE_TECHNIQUES + if(first) + { + Logger::Print(6, "no mismatches found\n"); + } + + }, nullptr, false); + } + QuickPatch::QuickPatch() { // protocol version (workaround for hacks) @@ -402,6 +441,11 @@ namespace Components throw new std::exception(); }); + Command::Add("checkmaterials", [] (Command::Params*) + { + QuickPatch::CompareMaterialStateBits(); + }); + // Dvars Dvar::Register("ui_streamFriendly", 0, Game::DVAR_FLAG_SAVED, "Stream friendly UI"); diff --git a/src/Components/Modules/QuickPatch.hpp b/src/Components/Modules/QuickPatch.hpp index fb57d931..483df061 100644 --- a/src/Components/Modules/QuickPatch.hpp +++ b/src/Components/Modules/QuickPatch.hpp @@ -31,5 +31,7 @@ namespace Components static int MsgReadBitsCompressCheckSV(const char *from, char *to, int size); static int MsgReadBitsCompressCheckCL(const char *from, char *to, int size); static void CL_HandleRelayPacketCheck(Game::msg_t* msg, int client); + + static void CompareMaterialStateBits(); }; }