From afe8efbc2ae2e6f349b0c2e9ddad0cbb6143072a Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Thu, 19 Jan 2023 16:11:48 +0100 Subject: [PATCH] Add CUserCmd class to SDK Implemented CUserCmd to SDK. Constructor resets the class using the game's 'Reset' implementation as the majority of the structure is unknown. --- r5dev/game/shared/usercmd.h | 76 +++++++++++++++++++++++++++ r5dev/vproj/clientsdk.vcxproj | 1 + r5dev/vproj/clientsdk.vcxproj.filters | 3 ++ r5dev/vproj/dedicated.vcxproj | 1 + r5dev/vproj/dedicated.vcxproj.filters | 3 ++ r5dev/vproj/gamesdk.vcxproj | 1 + r5dev/vproj/gamesdk.vcxproj.filters | 3 ++ 7 files changed, 88 insertions(+) create mode 100644 r5dev/game/shared/usercmd.h diff --git a/r5dev/game/shared/usercmd.h b/r5dev/game/shared/usercmd.h new file mode 100644 index 00000000..a4a493d7 --- /dev/null +++ b/r5dev/game/shared/usercmd.h @@ -0,0 +1,76 @@ +//====== Copyright � 1996-2005, Valve Corporation, All rights reserved. =======// +// +// Purpose: +// +// $NoKeywords: $ +// +//=============================================================================// +#if !defined( USERCMD_H ) +#define USERCMD_H +#ifdef _WIN32 +#pragma once +#endif + +#include "public/utility/memaddr.h" +#include "mathlib/vector.h" + +//------------------------------------------------------------------------------------- +// Forward declarations +//------------------------------------------------------------------------------------- +class CUserCmd; + +inline CMemory p_CUserCmd__Reset; +inline auto v_CUserCmd__Reset = p_CUserCmd__Reset.RCast(); + +//------------------------------------------------------------------------------------- +// +//------------------------------------------------------------------------------------- +class CUserCmd +{ +public: + CUserCmd() // Cannot be constructed during DLL init. + { + v_CUserCmd__Reset(this); + } + + int32_t command_number; + int32_t tick_count; + float curtime; + QAngle viewangles; + char pad_0x0018[12]; + float forwardmove; + float sidemove; + float upmove; + int32_t buttons; + char pad_0x0034[336]; + int32_t randomseed; + char pad_0x0188[8]; + Vector3D headposition; + float maxpitch; + char pad_0x01A0[224]; +}; + + +/////////////////////////////////////////////////////////////////////////////// +class VUserCmd : public IDetour +{ + virtual void GetAdr(void) const + { + spdlog::debug("| FUN: CUserCmd::Reset : {:#18x} |\n", p_CUserCmd__Reset.GetPtr()); + spdlog::debug("+----------------------------------------------------------------+\n"); + } + virtual void GetFun(void) const + { + p_CUserCmd__Reset = g_GameDll.FindPatternSIMD("E8 ?? ?? ?? ?? 83 FD FF 74 0A").FollowNearCallSelf(); + v_CUserCmd__Reset = p_CUserCmd__Reset.RCast(); + } + virtual void GetVar(void) const { } + virtual void GetCon(void) const { } + virtual void Attach(void) const { } + virtual void Detach(void) const { } +}; +/////////////////////////////////////////////////////////////////////////////// + +REGISTER(VUserCmd); + +#endif // USERCMD_H diff --git a/r5dev/vproj/clientsdk.vcxproj b/r5dev/vproj/clientsdk.vcxproj index 013f3e78..49e80c6f 100644 --- a/r5dev/vproj/clientsdk.vcxproj +++ b/r5dev/vproj/clientsdk.vcxproj @@ -241,6 +241,7 @@ + diff --git a/r5dev/vproj/clientsdk.vcxproj.filters b/r5dev/vproj/clientsdk.vcxproj.filters index b17cc3d8..c998a0ad 100644 --- a/r5dev/vproj/clientsdk.vcxproj.filters +++ b/r5dev/vproj/clientsdk.vcxproj.filters @@ -1931,6 +1931,9 @@ sdk\game\shared + + sdk\game\shared + diff --git a/r5dev/vproj/dedicated.vcxproj b/r5dev/vproj/dedicated.vcxproj index 307bad28..43f996b7 100644 --- a/r5dev/vproj/dedicated.vcxproj +++ b/r5dev/vproj/dedicated.vcxproj @@ -197,6 +197,7 @@ + diff --git a/r5dev/vproj/dedicated.vcxproj.filters b/r5dev/vproj/dedicated.vcxproj.filters index e2f24bab..fc963c5b 100644 --- a/r5dev/vproj/dedicated.vcxproj.filters +++ b/r5dev/vproj/dedicated.vcxproj.filters @@ -1362,6 +1362,9 @@ sdk\game\shared + + sdk\game\shared + diff --git a/r5dev/vproj/gamesdk.vcxproj b/r5dev/vproj/gamesdk.vcxproj index 93b914cb..c4f10dab 100644 --- a/r5dev/vproj/gamesdk.vcxproj +++ b/r5dev/vproj/gamesdk.vcxproj @@ -273,6 +273,7 @@ + diff --git a/r5dev/vproj/gamesdk.vcxproj.filters b/r5dev/vproj/gamesdk.vcxproj.filters index e2e5529a..bdbe3a19 100644 --- a/r5dev/vproj/gamesdk.vcxproj.filters +++ b/r5dev/vproj/gamesdk.vcxproj.filters @@ -2075,6 +2075,9 @@ sdk\game\shared + + sdk\game\shared +