From 627b25c1202ec6aa2e9ad763e17c1a67dc635f53 Mon Sep 17 00:00:00 2001 From: PixieCore <41352111+PixieCore@users.noreply.github.com> Date: Fri, 18 Mar 2022 13:47:22 +0100 Subject: [PATCH] Initial implementation of CMaterialGlue. Some GUID's are still unknown. Class members need verification like the material resolution member. Added a ConCommand for getting the material we are currently looking it and printing it to the console. Porting to other seasons still need to be done. --- r5dev/materialsystem/cmaterialglue.cpp | 19 +++++++++ r5dev/materialsystem/cmaterialglue.h | 57 ++++++++++++++++++++++++++ r5dev/tier0/cmd.cpp | 5 +++ r5dev/tier0/completion.cpp | 29 +++++++++++++ r5dev/tier0/completion.h | 3 ++ r5dev/vproj/gamesdk.vcxproj | 2 + r5dev/vproj/gamesdk.vcxproj.filters | 6 +++ 7 files changed, 121 insertions(+) create mode 100644 r5dev/materialsystem/cmaterialglue.cpp create mode 100644 r5dev/materialsystem/cmaterialglue.h diff --git a/r5dev/materialsystem/cmaterialglue.cpp b/r5dev/materialsystem/cmaterialglue.cpp new file mode 100644 index 00000000..88a9f9d1 --- /dev/null +++ b/r5dev/materialsystem/cmaterialglue.cpp @@ -0,0 +1,19 @@ +//===========================================================================// +// +// Purpose: +// +//===========================================================================// +#include "core/stdafx.h" +#include "materialsystem/cmaterialglue.h" + + +/////////////////////////////////////////////////////////////////////////////// +void CMaterialGlue_Attach() +{ + +} + +void CMaterialGlue_Detach() +{ + +} \ No newline at end of file diff --git a/r5dev/materialsystem/cmaterialglue.h b/r5dev/materialsystem/cmaterialglue.h new file mode 100644 index 00000000..9be0b1b8 --- /dev/null +++ b/r5dev/materialsystem/cmaterialglue.h @@ -0,0 +1,57 @@ +#pragma once + +class TXTGuidMap // [ PIXIE ]: Couldn't figure out the other GUID's yet! +{ +public: + void* m_pAlbedoTextureGUID; //0x0000 + void* m_pNormalTextureGUID; //0x0008 + void* m_pSpecTextureGUID; //0x0010 + void* m_pLayerBlendTextureGUID; //0x0018 + void* m_pLightMapTextureRealTimeLightIDGUID; //0x0020 + void* m_pUnknownGUID1; //0x0028 + void* m_pUnknownGUID2; //0x0030 + void* m_pUnknownGUID3; //0x0038 + void* m_pUnknownGUID4; //0x0040 +}; //Size: 0x0048 + +class CMaterialGlue // [ PIXIE ]: Class seems mostly right, a few members are still missing though. +{ +public: + void* m_pVTable; //0x0000 + char pad_0008[8]; //0x0008 + uint64_t m_GUID; //0x0010 + char* m_pszName; //0x0018 + char* m_pszSurfaceName1; //0x0020 + char* m_pszSurfaceName2; //0x0028 + void* m_pDepthShadow; //0x0030 + void* m_pDepthPrepass; //0x0038 + void* m_pDepthVSM; //0x0040 + void* m_pDepthShadowTight; //0x0048 + void* m_pColPass; //0x0050 + void* m_pShaderGlue; //0x0058 + TXTGuidMap* m_pTextureGUID; //0x0060 + TXTGuidMap* m_pTextureGUID2; //0x0068 + char pad_0070[4]; //0x0070 + int32_t m_iTextureRes; //0x0074 + char pad_0078[184]; //0x0078 +}; //Size: 0x0130 + +namespace +{ + /* ==== CMATERIALGLUE ================================================================================================================================================== */ + +} + +void CMaterialGlue_Attach(); +void CMaterialGlue_Detach(); +/////////////////////////////////////////////////////////////////////////////// +class HCMaterialGlue : public IDetour +{ + virtual void debugp() + { + + } +}; +/////////////////////////////////////////////////////////////////////////////// + +REGISTER(HCMaterialGlue); \ No newline at end of file diff --git a/r5dev/tier0/cmd.cpp b/r5dev/tier0/cmd.cpp index e0356957..c7927745 100644 --- a/r5dev/tier0/cmd.cpp +++ b/r5dev/tier0/cmd.cpp @@ -131,6 +131,11 @@ void ConCommand::Init(void) ConCommand* net_toggletrace = new ConCommand("net_toggletrace", "Logs the sending and receiving datagram to a file on the disk.", FCVAR_CHEAT | FCVAR_DEVELOPMENTONLY, _NET_TraceNetChan_f_CompletionFunc, nullptr); ConCommand* net_setkey = new ConCommand("net_setkey", "Sets user specified base64 net key.", FCVAR_RELEASE, _NET_SetKey_f_CompletionFunc, nullptr); ConCommand* net_generatekey = new ConCommand("net_generatekey", "Generates and sets a random base64 net key.", FCVAR_RELEASE, _NET_GenerateKey_f_CompletionFunc, nullptr); +#ifndef DEDICATED + //------------------------------------------------------------------------- + // MATERIAL SYSTEM + ConCommand* mat_printmat_at_crosshair = new ConCommand("mat_printmat_at_crosshair", "Prints the material under the crosshair.", FCVAR_RELEASE | FCVAR_DEVELOPMENTONLY, _CMaterial_GetMaterialAtCrossHair_f_ComplectionFunc, nullptr); +#endif // !DEDICATED } //----------------------------------------------------------------------------- diff --git a/r5dev/tier0/completion.cpp b/r5dev/tier0/completion.cpp index cba653cd..6033993e 100644 --- a/r5dev/tier0/completion.cpp +++ b/r5dev/tier0/completion.cpp @@ -23,6 +23,10 @@ #endif // !DEDICATED #include "public/include/bansystem.h" #include "mathlib/crc32.h" +#ifndef DEDICATED +#include "materialsystem/cmaterialglue.h" +#endif // !DEDICATED + #ifndef DEDICATED /* @@ -759,3 +763,28 @@ void _RCON_Disconnect_f_CompletionFunc(const CCommand& args) } } #endif // !DEDICATED + +#ifndef DEDICATED +/* +===================== +_IMaterial_GetMaterialAtCrossHair_f_CompletionFunc + + Print the material under the crosshair. +===================== +*/ +void _CMaterial_GetMaterialAtCrossHair_f_ComplectionFunc(const CCommand& args) +{ +#if defined (GAMEDLL_S3) // [ PIXIE ]: Will do port to season 0-2 at a later date. + static auto GetMaterial = ADDRESS(0x14020B4A0).RCast(); // [ PIXIE ]: I will sigscan this later and make it for work other seasons as well. + CMaterialGlue* material = GetMaterial(); + if (material) + { + DevMsg(eDLL_T::CLIENT, "Current Material: %s", material->m_pszName); // [ PIXIE ]: Will add full CMaterialGlue description later. + } + else + { + DevMsg(eDLL_T::CLIENT, "No Material found >:("); + } +#endif +} +#endif // !DEDICATED diff --git a/r5dev/tier0/completion.h b/r5dev/tier0/completion.h index 249de46f..452a655d 100644 --- a/r5dev/tier0/completion.h +++ b/r5dev/tier0/completion.h @@ -37,6 +37,9 @@ void _NET_GenerateKey_f_CompletionFunc(const CCommand& args); void _RCON_CmdQuery_f_CompletionFunc(const CCommand& args); void _RCON_Disconnect_f_CompletionFunc(const CCommand& args); #endif // !DEDICATED +#ifndef DEDICATED +void _CMaterial_GetMaterialAtCrossHair_f_ComplectionFunc(const CCommand& args); +#endif // !DEDICATED /////////////////////////////////////////////////////////////////////////////// class HCompletion : public IDetour diff --git a/r5dev/vproj/gamesdk.vcxproj b/r5dev/vproj/gamesdk.vcxproj index 454e8db5..3adcb162 100644 --- a/r5dev/vproj/gamesdk.vcxproj +++ b/r5dev/vproj/gamesdk.vcxproj @@ -49,6 +49,7 @@ + @@ -150,6 +151,7 @@ + diff --git a/r5dev/vproj/gamesdk.vcxproj.filters b/r5dev/vproj/gamesdk.vcxproj.filters index 40816054..2fc3d1f5 100644 --- a/r5dev/vproj/gamesdk.vcxproj.filters +++ b/r5dev/vproj/gamesdk.vcxproj.filters @@ -396,6 +396,9 @@ sdk\game\server + + sdk\materialsystem + @@ -1139,6 +1142,9 @@ sdk\game\server + + sdk\materialsystem +