From f314b9b4e781e5d024f2b36ccec2e3bcefd8cb84 Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Sun, 24 Jul 2022 12:59:40 +0200 Subject: [PATCH] Start of C_Player reversing --- r5dev/client/vengineclient_impl.h | 1 + r5dev/game/client/animationlayer.h | 0 r5dev/game/client/c_baseanimating.h | 0 r5dev/game/client/c_basecharacter.h | 0 r5dev/game/client/c_baseentity.cpp | 11 ++++ r5dev/game/client/c_baseplayer.h | 51 +++++++++++++++ r5dev/public/include/client_class.h | 3 +- r5dev/public/include/icliententity.h | 15 +++++ r5dev/public/include/icliententitylist.h | 4 +- r5dev/public/include/iclientnetworkable.h | 9 +++ r5dev/public/include/iclientrenderable.h | 25 ++++++++ r5dev/public/include/iclientthinkable.h | 9 +++ r5dev/public/include/iclientunknown.h | 10 +++ r5dev/public/include/ihandleentity.h | 9 +++ r5dev/public/include/ivscript.h | 22 +++++++ r5dev/tier0/basetypes.h | 75 +++++++++++++++++++++++ r5dev/vproj/clientsdk.vcxproj | 9 +++ r5dev/vproj/clientsdk.vcxproj.filters | 27 ++++++++ r5dev/vproj/dedicated.vcxproj | 1 + r5dev/vproj/dedicated.vcxproj.filters | 3 + r5dev/vproj/gamesdk.vcxproj | 9 +++ r5dev/vproj/gamesdk.vcxproj.filters | 27 ++++++++ 22 files changed, 316 insertions(+), 4 deletions(-) create mode 100644 r5dev/game/client/animationlayer.h create mode 100644 r5dev/game/client/c_baseanimating.h create mode 100644 r5dev/game/client/c_basecharacter.h create mode 100644 r5dev/game/client/c_baseentity.cpp create mode 100644 r5dev/game/client/c_baseplayer.h create mode 100644 r5dev/public/include/icliententity.h create mode 100644 r5dev/public/include/iclientnetworkable.h create mode 100644 r5dev/public/include/iclientrenderable.h create mode 100644 r5dev/public/include/iclientthinkable.h create mode 100644 r5dev/public/include/iclientunknown.h create mode 100644 r5dev/public/include/ihandleentity.h create mode 100644 r5dev/public/include/ivscript.h diff --git a/r5dev/client/vengineclient_impl.h b/r5dev/client/vengineclient_impl.h index a8b70e1d..fa8a6df7 100644 --- a/r5dev/client/vengineclient_impl.h +++ b/r5dev/client/vengineclient_impl.h @@ -30,6 +30,7 @@ class HVEngineClient : public IDetour virtual void GetAdr(void) const { spdlog::debug("| FUN: IVEngineClient::CommandExecute : {:#18x} |\n", p_CEngineClient_CommandExecute.GetPtr()); + spdlog::debug("| FUN: IVEngineClient::GetLocalPlayer : {:#18x} |\n", p_CEngineClient_GetLocalPlayer.GetPtr()); spdlog::debug("| VAR: m_bRestrictServerCommands : {:#18x} |\n", reinterpret_cast(m_bRestrictServerCommands)); spdlog::debug("| VAR: m_bRestrictClientCommands : {:#18x} |\n", reinterpret_cast(m_bRestrictClientCommands)); spdlog::debug("| CON: g_ppEngineClient : {:#18x} |\n", reinterpret_cast(g_ppEngineClient)); diff --git a/r5dev/game/client/animationlayer.h b/r5dev/game/client/animationlayer.h new file mode 100644 index 00000000..e69de29b diff --git a/r5dev/game/client/c_baseanimating.h b/r5dev/game/client/c_baseanimating.h new file mode 100644 index 00000000..e69de29b diff --git a/r5dev/game/client/c_basecharacter.h b/r5dev/game/client/c_basecharacter.h new file mode 100644 index 00000000..e69de29b diff --git a/r5dev/game/client/c_baseentity.cpp b/r5dev/game/client/c_baseentity.cpp new file mode 100644 index 00000000..8e55b350 --- /dev/null +++ b/r5dev/game/client/c_baseentity.cpp @@ -0,0 +1,11 @@ +//====== Copyright 1996-2005, Valve Corporation, All rights reserved. =======// +// +// Purpose: +// +// $NoKeywords: $ +//===========================================================================// + +#include "core/stdafx.h" +#include "game/client/c_baseentity.h" +#include "game/client/c_baseplayer.h" + diff --git a/r5dev/game/client/c_baseplayer.h b/r5dev/game/client/c_baseplayer.h new file mode 100644 index 00000000..6b6fafe8 --- /dev/null +++ b/r5dev/game/client/c_baseplayer.h @@ -0,0 +1,51 @@ +#ifndef C_BASEPLAYER_H +#define C_BASEPLAYER_H + +#include "public/include/icliententity.h" +#include "public/include/icliententitylist.h" +#include "public/include/iclientnetworkable.h" +#include "public/include/iclientrenderable.h" +#include "public/include/iclientthinkable.h" +#include "public/include/iclientunknown.h" +#include "public/include/ihandleentity.h" +#include "public/include/ivscript.h" + + +class C_BaseCombatCharacter +{ + int m_nPredictionData; // Unk + //int unk; // Padding? +}; + +class C_BaseEntity : public IClientEntity +{ + const char* m_pszModelName; + int unk0; + char pad[4]; // unk; + HSCRIPT m_hScriptInstance; + const char* m_iszScriptId; +}; + + +class C_BaseAnimating : public C_BaseEntity +{ + +}; + +class C_BaseAnimatingOverlay : public C_BaseAnimating +{ + +}; + +class C_Player : public C_BaseCombatCharacter, public C_BaseAnimatingOverlay +{ + +}; + + +void F() +{ + sizeof(C_Player); +} + +#endif // C_BASEPLAYER_H diff --git a/r5dev/public/include/client_class.h b/r5dev/public/include/client_class.h index 2b595ec3..48a7dfed 100644 --- a/r5dev/public/include/client_class.h +++ b/r5dev/public/include/client_class.h @@ -1,6 +1,5 @@ #pragma once - -class IClientNetworkable; +#include "public/include/iclientnetworkable.h" typedef IClientNetworkable* (*CreateClientClassFn)(int entNum, int serialNum); typedef IClientNetworkable* (*CreateEventFn)(); diff --git a/r5dev/public/include/icliententity.h b/r5dev/public/include/icliententity.h new file mode 100644 index 00000000..9e47c540 --- /dev/null +++ b/r5dev/public/include/icliententity.h @@ -0,0 +1,15 @@ +#ifndef ICLIENTENTITY_H +#define ICLIENTENTITY_H + +#include "iclientunknown.h" +#include "iclientrenderable.h" +#include "iclientnetworkable.h" +#include "iclientthinkable.h" + +class IClientEntity : public IClientUnknown, public IClientRenderable, public IClientNetworkable, public IClientThinkable +{ + void* __vftable /*VFT*/; +}; + + +#endif // ICLIENTENTITY_H \ No newline at end of file diff --git a/r5dev/public/include/icliententitylist.h b/r5dev/public/include/icliententitylist.h index 57355c0c..f44a1b6c 100644 --- a/r5dev/public/include/icliententitylist.h +++ b/r5dev/public/include/icliententitylist.h @@ -1,8 +1,8 @@ #pragma once +#include "iclientnetworkable.h" +#include "icliententity.h" using CBaseHandle = unsigned long; -class IClientNetworkable; -class IClientEntity; class IClientEntityList // Fully reversed beside index 0 which is probably a destructor. { diff --git a/r5dev/public/include/iclientnetworkable.h b/r5dev/public/include/iclientnetworkable.h new file mode 100644 index 00000000..7156dbb9 --- /dev/null +++ b/r5dev/public/include/iclientnetworkable.h @@ -0,0 +1,9 @@ +#ifndef ICLIENTNETWORKABLE_H +#define ICLIENTNETWORKABLE_H + +class IClientNetworkable +{ + void* __vftable /*VFT*/; +}; + +#endif // ICLIENTNETWORKABLE_H \ No newline at end of file diff --git a/r5dev/public/include/iclientrenderable.h b/r5dev/public/include/iclientrenderable.h new file mode 100644 index 00000000..68f0f9d1 --- /dev/null +++ b/r5dev/public/include/iclientrenderable.h @@ -0,0 +1,25 @@ +#ifndef ICLIENTRENDERABLE_H +#define ICLIENTRENDERABLE_H + +//----------------------------------------------------------------------------- +// Handle to an renderable in the client leaf system +//----------------------------------------------------------------------------- +typedef unsigned short ClientRenderHandle_t; + +enum +{ + INVALID_CLIENT_RENDER_HANDLE = (ClientRenderHandle_t)0xffff, +}; + +class IClientRenderable +{ + void* __vftable /*VFT*/; +}; + +class IClientModelRenderable +{ + void* __vftable /*VFT*/; +}; + + +#endif // ICLIENTRENDERABLE_H \ No newline at end of file diff --git a/r5dev/public/include/iclientthinkable.h b/r5dev/public/include/iclientthinkable.h new file mode 100644 index 00000000..026f5a60 --- /dev/null +++ b/r5dev/public/include/iclientthinkable.h @@ -0,0 +1,9 @@ +#ifndef ICLIENTTHINKABLE_H +#define ICLIENTTHINKABLE_H + +class IClientThinkable +{ + void* __vftable /*VFT*/; +}; + +#endif // ICLIENTTHINKABLE_H \ No newline at end of file diff --git a/r5dev/public/include/iclientunknown.h b/r5dev/public/include/iclientunknown.h new file mode 100644 index 00000000..cbaf419e --- /dev/null +++ b/r5dev/public/include/iclientunknown.h @@ -0,0 +1,10 @@ +#ifndef ICLIENTUNKNOWN_H +#define ICLIENTUNKNOWN_H + +class IClientUnknown +{ + void* __vftable /*VFT*/; +}; + + +#endif // ICLIENTUNKNOWN_H \ No newline at end of file diff --git a/r5dev/public/include/ihandleentity.h b/r5dev/public/include/ihandleentity.h new file mode 100644 index 00000000..4859afba --- /dev/null +++ b/r5dev/public/include/ihandleentity.h @@ -0,0 +1,9 @@ +#ifndef IHANDLEENTITY_H +#define IHANDLEENTITY_H + +class IHandleEntity +{ + void* __vftable /*VFT*/; +}; + +#endif // IHANDLEENTITY_H \ No newline at end of file diff --git a/r5dev/public/include/ivscript.h b/r5dev/public/include/ivscript.h new file mode 100644 index 00000000..042b67f5 --- /dev/null +++ b/r5dev/public/include/ivscript.h @@ -0,0 +1,22 @@ +#ifndef IVSCRIPT_H +#define IVSCRIPT_H + +enum ScriptLanguage_t +{ + SL_NONE, + SL_GAMEMONKEY, + SL_SQUIRREL, + SL_LUA, + SL_PYTHON, + + SL_DEFAULT = SL_SQUIRREL +}; + +//----------------------------------------------------------------------------- +// +//----------------------------------------------------------------------------- + +DECLARE_POINTER_HANDLE(HSCRIPT); +#define INVALID_HSCRIPT ((HSCRIPT)-1) + +#endif // IVSCRIPT_H diff --git a/r5dev/tier0/basetypes.h b/r5dev/tier0/basetypes.h index 491b5fe6..c0d51a09 100644 --- a/r5dev/tier0/basetypes.h +++ b/r5dev/tier0/basetypes.h @@ -268,3 +268,78 @@ struct vrect_t constexpr int MAX_NETCONSOLE_INPUT_LEN = 4096; constexpr int MSG_NOSIGNAL = 0; + +//----------------------------------------------------------------------------- +// Declares a type-safe handle type; you can't assign one handle to the next +//----------------------------------------------------------------------------- + +// 32-bit pointer handles. + +// Typesafe 8-bit and 16-bit handles. +template< class HandleType > +class CBaseIntHandle +{ +public: + + inline bool operator==(const CBaseIntHandle& other) { return m_Handle == other.m_Handle; } + inline bool operator!=(const CBaseIntHandle& other) { return m_Handle != other.m_Handle; } + + // Only the code that doles out these handles should use these functions. + // Everyone else should treat them as a transparent type. + inline HandleType GetHandleValue() { return m_Handle; } + inline void SetHandleValue(HandleType val) { m_Handle = val; } + + typedef HandleType HANDLE_TYPE; + +protected: + + HandleType m_Handle; +}; + +template< class DummyType > +class CIntHandle16 : public CBaseIntHandle< unsigned short > +{ +public: + inline CIntHandle16() {} + + static inline CIntHandle16 MakeHandle(HANDLE_TYPE val) + { + return CIntHandle16(val); + } + +protected: + inline CIntHandle16(HANDLE_TYPE val) + { + m_Handle = val; + } +}; + + +template< class DummyType > +class CIntHandle32 : public CBaseIntHandle< uint32 > +{ +public: + inline CIntHandle32() {} + + static inline CIntHandle32 MakeHandle(HANDLE_TYPE val) + { + return CIntHandle32(val); + } + +protected: + inline CIntHandle32(HANDLE_TYPE val) + { + m_Handle = val; + } +}; + + +// NOTE: This macro is the same as windows uses; so don't change the guts of it +#define DECLARE_HANDLE_16BIT(name) typedef CIntHandle16< struct name##__handle * > name; +#define DECLARE_HANDLE_32BIT(name) typedef CIntHandle32< struct name##__handle * > name; + +#define DECLARE_POINTER_HANDLE(name) struct name##__ { int unused; }; typedef struct name##__ *name +#define FORWARD_DECLARE_HANDLE(name) typedef struct name##__ *name + +#define DECLARE_DERIVED_POINTER_HANDLE( _name, _basehandle ) struct _name##__ : public _basehandle##__ {}; typedef struct _name##__ *_name +#define DECLARE_ALIASED_POINTER_HANDLE( _name, _alias ) typedef struct _alias##__ *name \ No newline at end of file diff --git a/r5dev/vproj/clientsdk.vcxproj b/r5dev/vproj/clientsdk.vcxproj index bcd55ce0..43876ec4 100644 --- a/r5dev/vproj/clientsdk.vcxproj +++ b/r5dev/vproj/clientsdk.vcxproj @@ -51,6 +51,7 @@ + @@ -190,6 +191,7 @@ + @@ -233,11 +235,18 @@ + + + + + + + diff --git a/r5dev/vproj/clientsdk.vcxproj.filters b/r5dev/vproj/clientsdk.vcxproj.filters index 15539df3..cf8bfd33 100644 --- a/r5dev/vproj/clientsdk.vcxproj.filters +++ b/r5dev/vproj/clientsdk.vcxproj.filters @@ -555,6 +555,9 @@ sdk\tier0 + + sdk\game\client + @@ -1613,6 +1616,30 @@ sdk\tier0 + + sdk\game\client + + + sdk\public\include + + + sdk\public\include + + + sdk\public\include + + + sdk\public\include + + + sdk\public\include + + + sdk\public\include + + + sdk\public\include + diff --git a/r5dev/vproj/dedicated.vcxproj b/r5dev/vproj/dedicated.vcxproj index 51f3ddb1..b8bb06b3 100644 --- a/r5dev/vproj/dedicated.vcxproj +++ b/r5dev/vproj/dedicated.vcxproj @@ -219,6 +219,7 @@ + diff --git a/r5dev/vproj/dedicated.vcxproj.filters b/r5dev/vproj/dedicated.vcxproj.filters index 20d95716..6cfe03d6 100644 --- a/r5dev/vproj/dedicated.vcxproj.filters +++ b/r5dev/vproj/dedicated.vcxproj.filters @@ -1173,6 +1173,9 @@ sdk\tier0 + + sdk\public\include + diff --git a/r5dev/vproj/gamesdk.vcxproj b/r5dev/vproj/gamesdk.vcxproj index c5cb08b2..26f6e1cf 100644 --- a/r5dev/vproj/gamesdk.vcxproj +++ b/r5dev/vproj/gamesdk.vcxproj @@ -53,6 +53,7 @@ + @@ -201,6 +202,7 @@ + @@ -254,13 +256,20 @@ + + + + + + + diff --git a/r5dev/vproj/gamesdk.vcxproj.filters b/r5dev/vproj/gamesdk.vcxproj.filters index 48f8597e..078d22aa 100644 --- a/r5dev/vproj/gamesdk.vcxproj.filters +++ b/r5dev/vproj/gamesdk.vcxproj.filters @@ -591,6 +591,9 @@ sdk\server + + sdk\game\client + @@ -1697,6 +1700,30 @@ sdk\tier0 + + sdk\game\client + + + sdk\public\include + + + sdk\public\include + + + sdk\public\include + + + sdk\public\include + + + sdk\public\include + + + sdk\public\include + + + sdk\public\include +