Skip to content

Commit 5aae421

Browse files
authored
engine: restore mat_crosshair_printmaterial concommand (#763)
Restores the `mat_crosshair_printmaterial` concommand by reimplementing it's callback. Adds `CMaterialGlue` and `CShaderGlue` classes.
1 parent 2dce58a commit 5aae421

File tree

4 files changed

+105
-0
lines changed

4 files changed

+105
-0
lines changed

primedev/Northstar.cmake

+1
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ add_library(
6262
"dedicated/dedicatedlogtoclient.cpp"
6363
"dedicated/dedicatedlogtoclient.h"
6464
"dedicated/dedicatedmaterialsystem.cpp"
65+
"engine/gl_matsysiface.cpp"
6566
"engine/host.cpp"
6667
"engine/hoststate.cpp"
6768
"engine/hoststate.h"

primedev/engine/gl_matsysiface.cpp

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#include "materialsystem/cmaterialglue.h"
2+
3+
CMaterialGlue* (*GetMaterialAtCrossHair)();
4+
5+
AUTOHOOK_INIT()
6+
7+
AUTOHOOK(CC_mat_crosshair_printmaterial_f, engine.dll + 0xB3C40, void, __fastcall, (const CCommand& args))
8+
{
9+
CMaterialGlue* pMat = GetMaterialAtCrossHair();
10+
11+
if (!pMat)
12+
{
13+
spdlog::error("Not looking at a material!");
14+
return;
15+
}
16+
17+
std::function<void(CMaterialGlue * pGlue, const char* szName)> fnPrintGlue = [](CMaterialGlue* pGlue, const char* szName)
18+
{
19+
spdlog::info("|-----------------------------------------------");
20+
21+
if (!pGlue)
22+
{
23+
spdlog::info("|-- {} is NULL", szName);
24+
return;
25+
}
26+
27+
spdlog::info("|-- Name: {}", szName);
28+
spdlog::info("|-- GUID: {:#x}", pGlue->m_GUID);
29+
spdlog::info("|-- Name: {}", pGlue->m_pszName);
30+
spdlog::info("|-- Width : {}", pGlue->m_iWidth);
31+
spdlog::info("|-- Height: {}", pGlue->m_iHeight);
32+
};
33+
34+
spdlog::info("|- GUID: {:#x}", pMat->m_GUID);
35+
spdlog::info("|- Name: {}", pMat->m_pszName);
36+
spdlog::info("|- Width : {}", pMat->m_iWidth);
37+
spdlog::info("|- Height: {}", pMat->m_iHeight);
38+
39+
fnPrintGlue(pMat->m_pDepthShadow, "DepthShadow");
40+
fnPrintGlue(pMat->m_pDepthPrepass, "DepthPrepass");
41+
fnPrintGlue(pMat->m_pDepthVSM, "DepthVSM");
42+
fnPrintGlue(pMat->m_pColPass, "ColPass");
43+
}
44+
45+
ON_DLL_LOAD("engine.dll", GlMatSysIFace, (CModule module))
46+
{
47+
AUTOHOOK_DISPATCH()
48+
49+
GetMaterialAtCrossHair = module.Offset(0xB37D0).RCast<CMaterialGlue* (*)()>();
50+
}
+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#pragma once
2+
3+
#include "materialsystem/cshaderglue.h"
4+
5+
class CMaterialGlue
6+
{
7+
public:
8+
void* m_pVFTable;
9+
char m_unk[8];
10+
11+
uint64_t m_GUID;
12+
13+
const char* m_pszName;
14+
const char* m_pszSurfaceProp;
15+
const char* m_pszSurfaceProp2;
16+
17+
CMaterialGlue* m_pDepthShadow;
18+
CMaterialGlue* m_pDepthPrepass;
19+
CMaterialGlue* m_pDepthVSM;
20+
CMaterialGlue* m_pColPass;
21+
22+
char gap_50[64];
23+
24+
CShaderGlue* m_pShaderGlue;
25+
void** m_pTextureHandles;
26+
void** m_pStreamingTextures;
27+
int16_t m_iStreamingTextureCount;
28+
uint8_t m_iSamplersIndices[4];
29+
int16_t m_iUnknown0;
30+
char gap_B0[12];
31+
32+
int16_t aword_BC[2];
33+
int32_t flags2;
34+
int32_t flags3;
35+
int16_t m_iWidth;
36+
int16_t m_iHeight;
37+
int16_t m_iUnknown1;
38+
int16_t m_iUnknown2;
39+
40+
void** m_pUnkD3D11Ptr;
41+
void* m_pD3D11Buffer;
42+
void* qword_E0;
43+
void* pointer_E8;
44+
45+
int32_t dword_F0;
46+
char gap_F4[12];
47+
};

primedev/materialsystem/cshaderglue.h

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#pragma once
2+
3+
class CShaderGlue
4+
{
5+
public:
6+
void* vftable;
7+
};

0 commit comments

Comments
 (0)