diff options
author | F1F7Y <64418963+F1F7Y@users.noreply.github.com> | 2024-08-25 13:58:17 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-25 13:58:17 +0200 |
commit | 5aae42126a062f1d184aff1c8217ef50259ccc53 (patch) | |
tree | 7916afa1200f0df6d9e09057c6563b4b467dbef2 /primedev | |
parent | 2dce58a733f1ac275e611bd050c2482c5d7cf68b (diff) | |
download | NorthstarLauncher-5aae42126a062f1d184aff1c8217ef50259ccc53.tar.gz NorthstarLauncher-5aae42126a062f1d184aff1c8217ef50259ccc53.zip |
engine: restore `mat_crosshair_printmaterial` concommand (#763)
Restores the `mat_crosshair_printmaterial` concommand by reimplementing it's callback. Adds `CMaterialGlue` and `CShaderGlue` classes.
Diffstat (limited to 'primedev')
-rw-r--r-- | primedev/Northstar.cmake | 1 | ||||
-rw-r--r-- | primedev/engine/gl_matsysiface.cpp | 50 | ||||
-rw-r--r-- | primedev/materialsystem/cmaterialglue.h | 47 | ||||
-rw-r--r-- | primedev/materialsystem/cshaderglue.h | 7 |
4 files changed, 105 insertions, 0 deletions
diff --git a/primedev/Northstar.cmake b/primedev/Northstar.cmake index 9e9d1ed6..b8038073 100644 --- a/primedev/Northstar.cmake +++ b/primedev/Northstar.cmake @@ -62,6 +62,7 @@ add_library( "dedicated/dedicatedlogtoclient.cpp" "dedicated/dedicatedlogtoclient.h" "dedicated/dedicatedmaterialsystem.cpp" + "engine/gl_matsysiface.cpp" "engine/host.cpp" "engine/hoststate.cpp" "engine/hoststate.h" diff --git a/primedev/engine/gl_matsysiface.cpp b/primedev/engine/gl_matsysiface.cpp new file mode 100644 index 00000000..903a0113 --- /dev/null +++ b/primedev/engine/gl_matsysiface.cpp @@ -0,0 +1,50 @@ +#include "materialsystem/cmaterialglue.h" + +CMaterialGlue* (*GetMaterialAtCrossHair)(); + +AUTOHOOK_INIT() + +AUTOHOOK(CC_mat_crosshair_printmaterial_f, engine.dll + 0xB3C40, void, __fastcall, (const CCommand& args)) +{ + CMaterialGlue* pMat = GetMaterialAtCrossHair(); + + if (!pMat) + { + spdlog::error("Not looking at a material!"); + return; + } + + std::function<void(CMaterialGlue * pGlue, const char* szName)> fnPrintGlue = [](CMaterialGlue* pGlue, const char* szName) + { + spdlog::info("|-----------------------------------------------"); + + if (!pGlue) + { + spdlog::info("|-- {} is NULL", szName); + return; + } + + spdlog::info("|-- Name: {}", szName); + spdlog::info("|-- GUID: {:#x}", pGlue->m_GUID); + spdlog::info("|-- Name: {}", pGlue->m_pszName); + spdlog::info("|-- Width : {}", pGlue->m_iWidth); + spdlog::info("|-- Height: {}", pGlue->m_iHeight); + }; + + spdlog::info("|- GUID: {:#x}", pMat->m_GUID); + spdlog::info("|- Name: {}", pMat->m_pszName); + spdlog::info("|- Width : {}", pMat->m_iWidth); + spdlog::info("|- Height: {}", pMat->m_iHeight); + + fnPrintGlue(pMat->m_pDepthShadow, "DepthShadow"); + fnPrintGlue(pMat->m_pDepthPrepass, "DepthPrepass"); + fnPrintGlue(pMat->m_pDepthVSM, "DepthVSM"); + fnPrintGlue(pMat->m_pColPass, "ColPass"); +} + +ON_DLL_LOAD("engine.dll", GlMatSysIFace, (CModule module)) +{ + AUTOHOOK_DISPATCH() + + GetMaterialAtCrossHair = module.Offset(0xB37D0).RCast<CMaterialGlue* (*)()>(); +} diff --git a/primedev/materialsystem/cmaterialglue.h b/primedev/materialsystem/cmaterialglue.h new file mode 100644 index 00000000..1738a91a --- /dev/null +++ b/primedev/materialsystem/cmaterialglue.h @@ -0,0 +1,47 @@ +#pragma once + +#include "materialsystem/cshaderglue.h" + +class CMaterialGlue +{ +public: + void* m_pVFTable; + char m_unk[8]; + + uint64_t m_GUID; + + const char* m_pszName; + const char* m_pszSurfaceProp; + const char* m_pszSurfaceProp2; + + CMaterialGlue* m_pDepthShadow; + CMaterialGlue* m_pDepthPrepass; + CMaterialGlue* m_pDepthVSM; + CMaterialGlue* m_pColPass; + + char gap_50[64]; + + CShaderGlue* m_pShaderGlue; + void** m_pTextureHandles; + void** m_pStreamingTextures; + int16_t m_iStreamingTextureCount; + uint8_t m_iSamplersIndices[4]; + int16_t m_iUnknown0; + char gap_B0[12]; + + int16_t aword_BC[2]; + int32_t flags2; + int32_t flags3; + int16_t m_iWidth; + int16_t m_iHeight; + int16_t m_iUnknown1; + int16_t m_iUnknown2; + + void** m_pUnkD3D11Ptr; + void* m_pD3D11Buffer; + void* qword_E0; + void* pointer_E8; + + int32_t dword_F0; + char gap_F4[12]; +}; diff --git a/primedev/materialsystem/cshaderglue.h b/primedev/materialsystem/cshaderglue.h new file mode 100644 index 00000000..8194f1fb --- /dev/null +++ b/primedev/materialsystem/cshaderglue.h @@ -0,0 +1,7 @@ +#pragma once + +class CShaderGlue +{ +public: + void* vftable; +}; |