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.
This commit is contained in:
PixieCore 2022-03-18 13:47:22 +01:00
parent 35ad8554a5
commit 627b25c120
7 changed files with 121 additions and 0 deletions

View File

@ -0,0 +1,19 @@
//===========================================================================//
//
// Purpose:
//
//===========================================================================//
#include "core/stdafx.h"
#include "materialsystem/cmaterialglue.h"
///////////////////////////////////////////////////////////////////////////////
void CMaterialGlue_Attach()
{
}
void CMaterialGlue_Detach()
{
}

View File

@ -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);

View File

@ -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
}
//-----------------------------------------------------------------------------

View File

@ -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<CMaterialGlue*(*)(void)>(); // [ 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

View File

@ -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

View File

@ -49,6 +49,7 @@
<ClCompile Include="..\game\server\gameinterface.cpp" />
<ClCompile Include="..\inputsystem\inputsystem.cpp" />
<ClCompile Include="..\launcher\IApplication.cpp" />
<ClCompile Include="..\materialsystem\cmaterialglue.cpp" />
<ClCompile Include="..\materialsystem\materialsystem.cpp" />
<ClCompile Include="..\mathlib\adler32.cpp" />
<ClCompile Include="..\mathlib\bits.cpp" />
@ -150,6 +151,7 @@
<ClInclude Include="..\inputsystem\ButtonCode.h" />
<ClInclude Include="..\inputsystem\inputsystem.h" />
<ClInclude Include="..\launcher\IApplication.h" />
<ClInclude Include="..\materialsystem\cmaterialglue.h" />
<ClInclude Include="..\materialsystem\materialsystem.h" />
<ClInclude Include="..\mathlib\adler32.h" />
<ClInclude Include="..\mathlib\bits.h" />

View File

@ -396,6 +396,9 @@
<ClCompile Include="..\game\server\ai_utility.cpp">
<Filter>sdk\game\server</Filter>
</ClCompile>
<ClCompile Include="..\materialsystem\cmaterialglue.cpp">
<Filter>sdk\materialsystem</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\client\cdll_engine_int.h">
@ -1139,6 +1142,9 @@
<ClInclude Include="..\game\server\ai_utility.h">
<Filter>sdk\game\server</Filter>
</ClInclude>
<ClInclude Include="..\materialsystem\cmaterialglue.h">
<Filter>sdk\materialsystem</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Image Include="..\shared\resource\lockedserver.png">