IClientEntityList and CUtlDict.

* IClientEntityList is the full virtual function table.
* CUtlDict "implementation" is temporary.
This commit is contained in:
PixieCore 2022-05-01 23:03:20 +02:00
parent a23c0b1ba9
commit 096ecdd333
11 changed files with 72 additions and 8 deletions

View File

@ -13,6 +13,7 @@
#include "engine/sys_utils.h" #include "engine/sys_utils.h"
#include "rtech/rtech_utils.h" #include "rtech/rtech_utils.h"
#include "public/include/studio.h" #include "public/include/studio.h"
#include "tier1/utldict.h"
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -31,6 +32,11 @@ studiohdr_t* CMDLCache::FindMDL(CMDLCache* pMDLCache, MDLHandle_t handle, void*
v4 = handle; v4 = handle;
EnterCriticalSection(reinterpret_cast<LPCRITICAL_SECTION>(&*m_MDLMutex)); EnterCriticalSection(reinterpret_cast<LPCRITICAL_SECTION>(&*m_MDLMutex));
// Example usage.
// auto mdlDict = CUtlDict<__int64, MDLHandle_t>(m_MDLDict.Deref().GetPtr()); // __int64 is studiodata_t*
// v6 = mdlDict.Find(v4);
v6 = *(_QWORD*)(m_MDLDict.Deref().GetPtr() + 24 * v4 + 16); v6 = *(_QWORD*)(m_MDLDict.Deref().GetPtr() + 24 * v4 + 16);
LeaveCriticalSection(reinterpret_cast<LPCRITICAL_SECTION>(&*m_MDLMutex)); LeaveCriticalSection(reinterpret_cast<LPCRITICAL_SECTION>(&*m_MDLMutex));

View File

@ -0,0 +1,21 @@
#pragma once
using CBaseHandle = unsigned long;
class IClientNetworkable;
class IClientEntity;
class IClientEntityList // Fully reversed beside index 0 which is probably a destructor.
{
public:
virtual int sub_1405C5E70() = 0;
virtual IClientNetworkable* GetClientNetworkable() = 0;
virtual IClientNetworkable* GetClientNetworkableFromHandle(CBaseHandle handle) = 0;
virtual void* GetClientUnknownFromHandle(CBaseHandle handle) = 0;
virtual IClientEntity* GetClientEntity(int entNum) = 0;
virtual IClientEntity* GetClientEntityFromHandle(CBaseHandle handle) = 0; // behaves weird on r5 and doesn't really wanna work.
virtual int NumberOfEntities(bool includeNonNetworkable = false) = 0;
virtual int GetNumClientNonNetworkable() = 0;
virtual int GetHighestEntityIndex() = 0;
virtual void SetMaxEntities(int maxEnts) = 0;
virtual int GetMaxEntities() = 0;
};

26
r5dev/tier1/utldict.h Normal file
View File

@ -0,0 +1,26 @@
//============ Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: A dictionary mapping from symbol to structure
//
// $Header: $
// $NoKeywords: $
//===========================================================================//
#pragma once
template <class T, class I>
class CUtlDict
{
public:
CUtlDict<T, I>(uintptr_t ptr) : m_Elements(ptr) {};
T Find(__int64 entry);
private:
uintptr_t m_Elements;
};
template <class T, class I>
T CUtlDict<T, I>::Find(__int64 entry)
{
return *(T*)(m_Elements + 24 * entry + 16);
}

View File

@ -6,9 +6,7 @@
// //
// A growable memory class. // A growable memory class.
//===========================================================================// //===========================================================================//
#pragma once
#ifndef UTLMEMORY_H
#define UTLMEMORY_H
struct __declspec(align(8)) CUtlMemory struct __declspec(align(8)) CUtlMemory
{ {
@ -17,4 +15,3 @@ struct __declspec(align(8)) CUtlMemory
int64_t m_nGrowSize; int64_t m_nGrowSize;
}; };
#endif // UTLMEMORY_H

View File

@ -7,9 +7,7 @@
// A growable array class that maintains a free list and keeps elements // A growable array class that maintains a free list and keeps elements
// in the same location // in the same location
//===========================================================================// //===========================================================================//
#pragma once
#ifndef UTLVECTOR_H
#define UTLVECTOR_H
#include "tier1/utlmemory.h" #include "tier1/utlmemory.h"
@ -20,4 +18,4 @@ struct __declspec(align(4)) CUtlVector
int m_Size; int m_Size;
}; };
#endif // CCVECTOR_H

View File

@ -366,6 +366,7 @@
<ClInclude Include="..\tier1\cvar.h" /> <ClInclude Include="..\tier1\cvar.h" />
<ClInclude Include="..\tier1\IConVar.h" /> <ClInclude Include="..\tier1\IConVar.h" />
<ClInclude Include="..\tier1\NetAdr2.h" /> <ClInclude Include="..\tier1\NetAdr2.h" />
<ClInclude Include="..\tier1\utldict.h" />
<ClInclude Include="..\tier1\utlmemory.h" /> <ClInclude Include="..\tier1\utlmemory.h" />
<ClInclude Include="..\tier1\utlvector.h" /> <ClInclude Include="..\tier1\utlvector.h" />
<ClInclude Include="..\tier2\socketcreator.h" /> <ClInclude Include="..\tier2\socketcreator.h" />

View File

@ -1277,6 +1277,9 @@
<ClInclude Include="..\game\shared\animation.h"> <ClInclude Include="..\game\shared\animation.h">
<Filter>sdk\game\shared</Filter> <Filter>sdk\game\shared</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\tier1\utldict.h">
<Filter>sdk\tier1</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Image Include="..\shared\resource\lockedserver.png"> <Image Include="..\shared\resource\lockedserver.png">

View File

@ -358,6 +358,7 @@
<ClInclude Include="..\tier1\cvar.h" /> <ClInclude Include="..\tier1\cvar.h" />
<ClInclude Include="..\tier1\IConVar.h" /> <ClInclude Include="..\tier1\IConVar.h" />
<ClInclude Include="..\tier1\NetAdr2.h" /> <ClInclude Include="..\tier1\NetAdr2.h" />
<ClInclude Include="..\tier1\utldict.h" />
<ClInclude Include="..\tier1\utlmemory.h" /> <ClInclude Include="..\tier1\utlmemory.h" />
<ClInclude Include="..\tier1\utlvector.h" /> <ClInclude Include="..\tier1\utlvector.h" />
<ClInclude Include="..\tier2\socketcreator.h" /> <ClInclude Include="..\tier2\socketcreator.h" />

View File

@ -906,6 +906,9 @@
<ClInclude Include="..\game\shared\animation.h"> <ClInclude Include="..\game\shared\animation.h">
<Filter>sdk\game\shared</Filter> <Filter>sdk\game\shared</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\tier1\utldict.h">
<Filter>sdk\tier1</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="..\common\opcodes.cpp"> <ClCompile Include="..\common\opcodes.cpp">

View File

@ -209,6 +209,7 @@
<ClInclude Include="..\public\include\const.h" /> <ClInclude Include="..\public\include\const.h" />
<ClInclude Include="..\public\include\edict.h" /> <ClInclude Include="..\public\include\edict.h" />
<ClInclude Include="..\public\include\globalvars_base.h" /> <ClInclude Include="..\public\include\globalvars_base.h" />
<ClInclude Include="..\public\include\icliententitylist.h" />
<ClInclude Include="..\public\include\inetchannel.h" /> <ClInclude Include="..\public\include\inetchannel.h" />
<ClInclude Include="..\public\include\ivrenderview.h" /> <ClInclude Include="..\public\include\ivrenderview.h" />
<ClInclude Include="..\public\include\memaddr.h" /> <ClInclude Include="..\public\include\memaddr.h" />
@ -384,6 +385,7 @@
<ClInclude Include="..\tier1\cvar.h" /> <ClInclude Include="..\tier1\cvar.h" />
<ClInclude Include="..\tier1\IConVar.h" /> <ClInclude Include="..\tier1\IConVar.h" />
<ClInclude Include="..\tier1\NetAdr2.h" /> <ClInclude Include="..\tier1\NetAdr2.h" />
<ClInclude Include="..\tier1\utldict.h" />
<ClInclude Include="..\tier1\utlmemory.h" /> <ClInclude Include="..\tier1\utlmemory.h" />
<ClInclude Include="..\tier1\utlvector.h" /> <ClInclude Include="..\tier1\utlvector.h" />
<ClInclude Include="..\tier2\socketcreator.h" /> <ClInclude Include="..\tier2\socketcreator.h" />

View File

@ -1337,6 +1337,12 @@
<ClInclude Include="..\game\shared\animation.h"> <ClInclude Include="..\game\shared\animation.h">
<Filter>sdk\game\shared</Filter> <Filter>sdk\game\shared</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\public\include\icliententitylist.h">
<Filter>sdk\public\include</Filter>
</ClInclude>
<ClInclude Include="..\tier1\utldict.h">
<Filter>sdk\tier1</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Image Include="..\shared\resource\lockedserver.png"> <Image Include="..\shared\resource\lockedserver.png">