CRenderView init, GetWorldMatrixForView()

* Fixed .gitignore for root /game/
* Fixed bug in WalkVTable where it would offset self.
* General clean up: VAR -> CON, CON -> VAR
This commit is contained in:
Marvin D 2022-11-10 00:53:12 +01:00
parent 4af22ede90
commit d00aaa933d
12 changed files with 82 additions and 50 deletions

2
.gitignore vendored
View File

@ -31,7 +31,7 @@ bld/
[Ll]ib/
[Ll]og/
[Ll]ogs/
[Gg]ame/
/[Gg]ame/
# Visual Studio 2015/2017 cache/options directory
.vs/

View File

@ -107,7 +107,7 @@
#include "game/server/gameinterface.h"
#endif // !CLIENT_DLL
#ifndef DEDICATED
#include "game/client/view.h"
#include "game/client/viewrender.h"
#endif // !DEDICATED
#include "public/edict.h"
#ifndef DEDICATED

View File

@ -1,34 +0,0 @@
#ifndef CL_VIEW_H
#define CL_VIEW_H
const Vector3D& MainViewOrigin();
const QAngle& MainViewAngles();
inline Vector3D* g_vecRenderOrigin = nullptr;
inline QAngle* g_vecRenderAngles = nullptr;
///////////////////////////////////////////////////////////////////////////////
class V_View : public IDetour
{
virtual void GetAdr(void) const
{
spdlog::debug("| VAR: g_vecRenderOrigin : {:#18x} |\n", reinterpret_cast<uintptr_t>(g_vecRenderOrigin));
spdlog::debug("| VAR: g_vecRenderAngles : {:#18x} |\n", reinterpret_cast<uintptr_t>(g_vecRenderAngles));
spdlog::debug("+----------------------------------------------------------------+\n");
}
virtual void GetFun(void) const { }
virtual void GetVar(void) const
{
CMemory base = g_GameDll.FindPatternSIMD(reinterpret_cast<rsig_t>("\x48\x89\x74\x24\x00\x57\x48\x83\xEC\x30\xF3\x0F\x10\x05\x00\x00\x00\x00\x00\x8B\x00"), "xxxx?xxxxxxxxx?????x?");
g_vecRenderOrigin = base.Offset(0x00).FindPatternSelf("F3 0F 10 05").ResolveRelativeAddressSelf(0x4, 0x8).RCast<Vector3D*>();
g_vecRenderAngles = base.Offset(0x30).FindPatternSelf("F3 0F 10 0D").ResolveRelativeAddressSelf(0x4, 0x8).RCast<QAngle*>();
}
virtual void GetCon(void) const { }
virtual void Attach(void) const { }
virtual void Detach(void) const { }
};
///////////////////////////////////////////////////////////////////////////////
REGISTER(V_View);
#endif // CL_VIEW_H

View File

@ -6,7 +6,12 @@
#include "core/stdafx.h"
#include "mathlib/vector.h"
#include "game/client/view.h"
#include "game/client/viewrender.h"
VMatrix* CViewRender::GetWorldMatrixForView(int8_t slot)
{
return CViewRender_GetWorldMatrixForView(this, slot);
}
const Vector3D& MainViewOrigin()
{

View File

@ -0,0 +1,61 @@
#pragma once
//-------------------------------------------------------------------------------------
// Forward declarations
//-------------------------------------------------------------------------------------
class VMatrix;
class CViewRender
{
public:
VMatrix* GetWorldMatrixForView(int8_t slot);
};
///////////////////////////////////////////////////////////////////////////////
const Vector3D& MainViewOrigin();
const QAngle& MainViewAngles();
inline CMemory p_CViewRender_GetWorldMatrixForView;
inline auto CViewRender_GetWorldMatrixForView = p_CViewRender_GetWorldMatrixForView.RCast<VMatrix*(*)(CViewRender*, int8_t)>();
inline Vector3D* g_vecRenderOrigin = nullptr;
inline QAngle* g_vecRenderAngles = nullptr;
inline CViewRender* g_pViewRender = nullptr;
inline CMemory g_pViewRender_VFTable;
///////////////////////////////////////////////////////////////////////////////
class V_ViewRender : public IDetour
{
virtual void GetAdr(void) const
{
spdlog::debug("| FUN: CViewRender::GetWorldMatrixForView : {:#18x} |\n", p_CViewRender_GetWorldMatrixForView.GetPtr());
spdlog::debug("| VAR: g_vecRenderOrigin : {:#18x} |\n", reinterpret_cast<uintptr_t>(g_vecRenderOrigin));
spdlog::debug("| VAR: g_vecRenderAngles : {:#18x} |\n", reinterpret_cast<uintptr_t>(g_vecRenderAngles));
spdlog::debug("| VAR: g_pViewRender : {:#18x} |\n", reinterpret_cast<uintptr_t>(g_pViewRender));
spdlog::debug("| CON: CViewRender (VFTable) : {:#18x} |\n", g_pViewRender_VFTable.GetPtr());
spdlog::debug("+----------------------------------------------------------------+\n");
}
virtual void GetFun(void) const
{
g_pViewRender_VFTable = g_GameDll.GetVirtualMethodTable(".?AVCViewRender@@");
p_CViewRender_GetWorldMatrixForView = g_pViewRender_VFTable.WalkVTable(16).Deref(); // 16th vfunc.
CViewRender_GetWorldMatrixForView = p_CViewRender_GetWorldMatrixForView.RCast<VMatrix* (*)(CViewRender*, int8_t)>();
}
virtual void GetVar(void) const
{
CMemory base = g_GameDll.FindPatternSIMD(reinterpret_cast<rsig_t>("\x48\x89\x74\x24\x00\x57\x48\x83\xEC\x30\xF3\x0F\x10\x05\x00\x00\x00\x00\x00\x8B\x00"), "xxxx?xxxxxxxxx?????x?");
g_vecRenderOrigin = base.Offset(0x00).FindPatternSelf("F3 0F 10 05").ResolveRelativeAddressSelf(0x4, 0x8).RCast<Vector3D*>();
g_vecRenderAngles = base.Offset(0x30).FindPatternSelf("F3 0F 10 0D").ResolveRelativeAddressSelf(0x4, 0x8).RCast<QAngle*>();
g_pViewRender = g_GameDll.FindPatternSIMD(reinterpret_cast<rsig_t>("\x48\x8D\x05\x00\x00\x00\x00\xC3\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC\x48\x8B\xC4"), "xxx????xxxxxxxxxxxxxx").ResolveRelativeAddressSelf(0x3, 0x7).RCast<CViewRender*>(); /*48 8D 05 ?? ?? ?? ?? C3 CC CC CC CC CC CC CC CC CC CC 48 8B C4*/
}
virtual void GetCon(void) const { }
virtual void Attach(void) const { }
virtual void Detach(void) const { }
};
///////////////////////////////////////////////////////////////////////////////
REGISTER(V_ViewRender);

View File

@ -16,7 +16,7 @@
#include "game/server/ai_utility.h"
#include "game/server/ai_networkmanager.h"
#include "game/server/ai_network.h"
#include "game/client/view.h"
#include "game/client/viewrender.h"
#include "thirdparty/recast/detour/include/detourcommon.h"
#include "thirdparty/recast/detour/include/detournavmesh.h"

View File

@ -105,8 +105,8 @@ public:
inline CMemory WalkVTable(ptrdiff_t vfuncIndex)
{
ptr += (8 * vfuncIndex);
return CMemory(this);
uintptr_t reference = ptr + (8 * vfuncIndex);
return CMemory(reference);
}
inline CMemory WalkVTableSelf(ptrdiff_t vfuncIndex)

View File

@ -122,8 +122,8 @@ class VConVar : public IDetour
spdlog::debug("| FUN: ConVar::IsFlagSet : {:#18x} |\n", p_ConVar_IsFlagSet.GetPtr());
spdlog::debug("| FUN: ConVar::Register : {:#18x} |\n", p_ConVar_Register.GetPtr());
spdlog::debug("| FUN: ConVar_PrintDescription : {:#18x} |\n", p_ConVar_PrintDescription.GetPtr());
spdlog::debug("| VAR: g_pConVarVFTable : {:#18x} |\n", g_pConVarVFTable.GetPtr());
spdlog::debug("| VAR: g_pIConVarVFTable : {:#18x} |\n", g_pIConVarVFTable.GetPtr());
spdlog::debug("| CON: g_pConVarVFTable : {:#18x} |\n", g_pConVarVFTable.GetPtr());
spdlog::debug("| CON: g_pIConVarVFTable : {:#18x} |\n", g_pIConVarVFTable.GetPtr());
spdlog::debug("+----------------------------------------------------------------+\n");
}
virtual void GetFun(void) const

View File

@ -201,7 +201,7 @@ class VConCommand : public IDetour
spdlog::debug("| FUN: CallbackStub : {:#18x} |\n", p_CallbackStub.GetPtr());
spdlog::debug("| FUN: NullSub : {:#18x} |\n", p_NullSub.GetPtr());
spdlog::debug("+----------------------------------------------------------------+\n");
spdlog::debug("| VAR: g_pConCommandVFTable : {:#18x} |\n", g_pConCommandVFTable.GetPtr());
spdlog::debug("| CON: g_pConCommandVFTable : {:#18x} |\n", g_pConCommandVFTable.GetPtr());
spdlog::debug("+----------------------------------------------------------------+\n");
}
virtual void GetFun(void) const
@ -220,11 +220,11 @@ class VConCommand : public IDetour
NullSub = p_NullSub.RCast<void(*)(void)>(); /*C2 00 00 CC CC CC CC CC CC CC CC CC CC CC CC CC 40 53 48 83 EC 20 48 8D 05 ?? ?? ?? ??*/
CallbackStub = p_CallbackStub.RCast<FnCommandCompletionCallback>(); /*33 C0 C3 CC CC CC CC CC CC CC CC CC CC CC CC CC 80 49 68 08*/ /*UserMathErrorFunction*/
}
virtual void GetVar(void) const
virtual void GetVar(void) const { }
virtual void GetCon(void) const
{
g_pConCommandVFTable = g_GameDll.GetVirtualMethodTable(".?AVConCommand@@");
}
virtual void GetCon(void) const { }
virtual void Attach(void) const { }
virtual void Detach(void) const { }
};

View File

@ -61,7 +61,7 @@
<ClCompile Include="..\gameui\IBrowser.cpp" />
<ClCompile Include="..\game\client\c_baseentity.cpp" />
<ClCompile Include="..\game\client\spritemodel.cpp" />
<ClCompile Include="..\game\client\view.cpp" />
<ClCompile Include="..\game\client\viewrender.cpp" />
<ClCompile Include="..\game\server\ai_network.cpp" />
<ClCompile Include="..\game\server\ai_networkmanager.cpp" />
<ClCompile Include="..\game\server\ai_utility.cpp" />
@ -225,7 +225,7 @@
<ClInclude Include="..\game\client\c_baseplayer.h" />
<ClInclude Include="..\game\client\enginesprite.h" />
<ClInclude Include="..\game\client\hud.h" />
<ClInclude Include="..\game\client\view.h" />
<ClInclude Include="..\game\client\viewrender.h" />
<ClInclude Include="..\game\server\ai_network.h" />
<ClInclude Include="..\game\server\ai_networkmanager.h" />
<ClInclude Include="..\game\server\ai_node.h" />

View File

@ -597,7 +597,7 @@
<ClCompile Include="..\game\client\c_baseentity.cpp">
<Filter>sdk\game\client</Filter>
</ClCompile>
<ClCompile Include="..\game\client\view.cpp">
<ClCompile Include="..\game\client\viewrender.cpp">
<Filter>sdk\game\client</Filter>
</ClCompile>
<ClCompile Include="..\game\shared\ai_utility_shared.cpp">
@ -1760,7 +1760,7 @@
<ClInclude Include="..\public\ivscript.h">
<Filter>sdk\public</Filter>
</ClInclude>
<ClInclude Include="..\game\client\view.h">
<ClInclude Include="..\game\client\viewrender.h">
<Filter>sdk\game\client</Filter>
</ClInclude>
<ClInclude Include="..\game\shared\ai_utility_shared.h">

View File

@ -53,7 +53,7 @@
#include "game/server/detour_impl.h"
#endif // !CLIENT_DLL
#ifndef DEDICATED
#include "game/client/view.h"
#include "game/client/viewrender.h"
#endif // !DEDICATED