mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
client networkable vars init.
This commit is contained in:
parent
0ba475b62f
commit
c0c06a14b8
@ -8,6 +8,7 @@
|
||||
#include "core/stdafx.h"
|
||||
#include "engine/server/sv_main.h"
|
||||
#include "game/server/gameinterface.h"
|
||||
#include "public/server_class.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// This is called when a new game is started. (restart, map)
|
||||
@ -47,7 +48,7 @@ void CServerGameDLL::GameShutdown(void)
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Gets the simulation tick interfal
|
||||
// Purpose: Gets the simulation tick interval
|
||||
// Output : float
|
||||
//-----------------------------------------------------------------------------
|
||||
float CServerGameDLL::GetTickInterval(void)
|
||||
@ -56,6 +57,16 @@ float CServerGameDLL::GetTickInterval(void)
|
||||
return CallVFunc<float>(index, this);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: get all server classes
|
||||
// Output : ServerClass*
|
||||
//-----------------------------------------------------------------------------
|
||||
ServerClass* CServerGameDLL::GetAllServerClasses(void)
|
||||
{
|
||||
const static int index = 12;
|
||||
return CallVFunc<ServerClass*>(index, this);
|
||||
}
|
||||
|
||||
void __fastcall CServerGameDLL::OnReceivedSayTextMessage(void* thisptr, int senderId, const char* text, bool isTeamChat)
|
||||
{
|
||||
#if defined(GAMEDLL_S3)
|
||||
|
@ -5,6 +5,8 @@
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
class ServerClass;
|
||||
|
||||
class CServerGameDLL
|
||||
{
|
||||
public:
|
||||
@ -13,6 +15,7 @@ public:
|
||||
void LevelShutdown(void);
|
||||
void GameShutdown(void);
|
||||
float GetTickInterval(void);
|
||||
ServerClass* GetAllServerClasses(void);
|
||||
|
||||
static void __fastcall OnReceivedSayTextMessage(void* thisptr, int senderId, const char* text, bool isTeamChat);
|
||||
};
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
typedef IClientNetworkable* (*CreateClientClassFn)(int entNum, int serialNum);
|
||||
typedef IClientNetworkable* (*CreateEventFn)();
|
||||
class CRecvTable;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Client side class definition
|
||||
@ -19,7 +20,7 @@ public:
|
||||
CreateClientClassFn m_pCreateFn;
|
||||
CreateEventFn m_pCreateEventFn;
|
||||
char* m_pNetworkName;
|
||||
void* m_pRecvTable; // CRecvTable*
|
||||
CRecvTable* m_pRecvTable;
|
||||
ClientClass* m_pNext;
|
||||
int m_ClassID;
|
||||
int m_ClassSize;
|
||||
|
3
r5dev/public/dt_recv.cpp
Normal file
3
r5dev/public/dt_recv.cpp
Normal file
@ -0,0 +1,3 @@
|
||||
#include "core/stdafx.h"
|
||||
#include "public/dt_recv.h"
|
||||
#include "public/dt_common.h"
|
35
r5dev/public/dt_recv.h
Normal file
35
r5dev/public/dt_recv.h
Normal file
@ -0,0 +1,35 @@
|
||||
#pragma once
|
||||
#include "public/dt_common.h"
|
||||
|
||||
class CRecvProp;
|
||||
|
||||
class CRecvTable
|
||||
{
|
||||
public:
|
||||
char pad_0000[0x8];
|
||||
CRecvProp** m_pProps;
|
||||
int m_nProps;
|
||||
char pad_0014[0x4AC];
|
||||
void* m_pDecoder;
|
||||
char* m_pNetTableName;
|
||||
bool m_bInitialized;
|
||||
bool m_bInMainList;
|
||||
};
|
||||
|
||||
class CRecvProp
|
||||
{
|
||||
public:
|
||||
SendPropType m_RecvType;
|
||||
int m_Offset;
|
||||
char pad_0008[24];
|
||||
CRecvTable* m_pDataTable;
|
||||
char* m_pVarName;
|
||||
bool m_bInsideArray;
|
||||
char pad_0031[0x7];
|
||||
CRecvProp* m_pArrayProp;
|
||||
void* m_ProxyFn;
|
||||
char pad_0048[0xC];
|
||||
int m_nFlags;
|
||||
char pad_0058[0x4];
|
||||
int m_nElements;
|
||||
};
|
7
r5dev/public/dt_send.h
Normal file
7
r5dev/public/dt_send.h
Normal file
@ -0,0 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
class SendTable
|
||||
{
|
||||
public:
|
||||
// TODO
|
||||
};
|
133
r5dev/public/networkvar.cpp
Normal file
133
r5dev/public/networkvar.cpp
Normal file
@ -0,0 +1,133 @@
|
||||
#include "core/stdafx.h"
|
||||
#include "public/networkvar.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Easier access networkable vars from memory.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef CLIENT_DLL
|
||||
//#include "game/server/gameinterface.h" // this doesn't wanna link properly and complains, gotta look at it later again.
|
||||
#endif // !CLIENT_DLL
|
||||
|
||||
#ifndef DEDICATED
|
||||
#include "client/cdll_engine_int.h"
|
||||
#include "public/dt_recv.h"
|
||||
#endif // !DEDICATED
|
||||
|
||||
CNetVarTables::CNetVarTables(bool isServer)
|
||||
{
|
||||
if (isServer)
|
||||
{
|
||||
#ifndef CLIENT_DLL
|
||||
/*
|
||||
for (ServerClass* sc = g_pServerGameDLL->GetAllServerClasses(); sc != nullptr; sc = sc->m_pNext)
|
||||
{
|
||||
if (sc->m_pSendTable)
|
||||
{
|
||||
vTables.emplace_back(LoadTable(sc->m_pSendTable));
|
||||
}
|
||||
}
|
||||
*/
|
||||
#endif // !CLIENT_DLL
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifndef DEDICATED
|
||||
for (ClientClass* cc = (*g_pHLClient)->GetAllClasses(); cc != nullptr; cc = cc->m_pNext)
|
||||
{
|
||||
if (cc->m_pRecvTable)
|
||||
{
|
||||
vTables.emplace_back(LoadTable(cc->m_pRecvTable));
|
||||
}
|
||||
}
|
||||
#endif // !DEDICATED
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef DEDICATED
|
||||
CNetVarTables::Table CNetVarTables::LoadTable(CRecvTable* recvTable)
|
||||
{
|
||||
Table nvTable = Table{};
|
||||
|
||||
nvTable.m_Offset = 0;
|
||||
nvTable.m_svNetTableName = recvTable->m_pNetTableName;
|
||||
|
||||
for (int i = 0; i < recvTable->m_nProps; i++)
|
||||
{
|
||||
CRecvProp* prop = recvTable->m_pProps[i];
|
||||
|
||||
if (!prop || std::isdigit(prop->m_pVarName[0])) // Weird edge cases. Need double checking.
|
||||
continue;
|
||||
|
||||
if (strcmp(prop->m_pVarName, "baseclass") == NULL) // No weird baseclass. Need double checking.
|
||||
continue;
|
||||
|
||||
if (prop->m_RecvType == SendPropType::DPT_DataTable && prop->m_pDataTable)
|
||||
{
|
||||
nvTable.m_vChildTables.emplace_back(LoadTable(prop->m_pDataTable));
|
||||
nvTable.m_vChildTables.back().m_Offset = prop->m_Offset;
|
||||
nvTable.m_vChildTables.back().m_pProp = prop;
|
||||
}
|
||||
else
|
||||
{
|
||||
nvTable.m_vChildProps.emplace_back(prop);
|
||||
}
|
||||
}
|
||||
|
||||
return nvTable;
|
||||
}
|
||||
#endif // !DEDICATED
|
||||
|
||||
#ifndef CLIENT_DLL
|
||||
CNetVarTables::Table CNetVarTables::LoadTable(SendTable* sendTable)
|
||||
{
|
||||
Table nvTable = Table{};
|
||||
return nvTable;
|
||||
}
|
||||
#endif // !CLIENT_DLL
|
||||
|
||||
|
||||
#ifndef DEDICATED
|
||||
int CNetVarTables::GetOffset(const string& tableName, const string& varName)
|
||||
{
|
||||
for (const auto& table : vTables)
|
||||
{
|
||||
if (table.m_svNetTableName.compare(tableName) == 0)
|
||||
{
|
||||
return GetOffset(table, varName);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CNetVarTables::GetOffset(const Table& table, const string& varName)
|
||||
{
|
||||
for (const auto& prop : table.m_vChildProps)
|
||||
{
|
||||
string svVarName = prop->m_pVarName;
|
||||
if (svVarName.compare(varName) == 0)
|
||||
return table.m_Offset + prop->m_Offset;
|
||||
}
|
||||
|
||||
for (const auto& child : table.m_vChildTables)
|
||||
{
|
||||
string svVarName = child.m_pProp->m_pVarName;
|
||||
if (svVarName.compare(varName) == 0)
|
||||
{
|
||||
return table.m_Offset + child.m_Offset;
|
||||
}
|
||||
}
|
||||
|
||||
// Try to loop through sub tables.
|
||||
for (const auto& child : table.m_vChildTables)
|
||||
{
|
||||
int propOffset = GetOffset(child, varName);
|
||||
if (propOffset != 0)
|
||||
return table.m_Offset + propOffset;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif // !DEDICATED
|
40
r5dev/public/networkvar.h
Normal file
40
r5dev/public/networkvar.h
Normal file
@ -0,0 +1,40 @@
|
||||
#pragma once
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Easier access networkable vars from memory.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class CRecvProp;
|
||||
class CRecvTable;
|
||||
class SendTable;
|
||||
|
||||
class CNetVarTables
|
||||
{
|
||||
public:
|
||||
struct Table
|
||||
{
|
||||
string m_svNetTableName;
|
||||
CRecvProp* m_pProp;
|
||||
int m_Offset;
|
||||
vector<CRecvProp*> m_vChildProps;
|
||||
vector<Table> m_vChildTables;
|
||||
};
|
||||
|
||||
CNetVarTables(bool isServer);
|
||||
|
||||
#ifndef DEDICATED
|
||||
Table LoadTable(CRecvTable* recvTable);
|
||||
#endif // !DEDICATED
|
||||
|
||||
#ifndef CLIENT_DLL
|
||||
Table LoadTable(SendTable* sendTable);
|
||||
#endif // !CLIENT_DLL
|
||||
|
||||
// DEDI still needs some work.
|
||||
#ifndef DEDICATED
|
||||
int GetOffset(const string& tableName, const string& varName);
|
||||
int GetOffset(const Table& table, const string& varName);
|
||||
#endif // !DEDICATED
|
||||
|
||||
vector<Table> vTables;
|
||||
};
|
@ -1,5 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
class SendTable;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Server side class definition
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -13,7 +15,7 @@ public:
|
||||
|
||||
public:
|
||||
char* m_pNetworkName;
|
||||
void* m_pSendTable;
|
||||
SendTable* m_pSendTable;
|
||||
ServerClass* m_pNext;
|
||||
int m_Unknown1;
|
||||
int m_ClassID;
|
||||
|
@ -95,6 +95,8 @@
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">NotUsing</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\public\datamap.cpp" />
|
||||
<ClCompile Include="..\public\dt_recv.cpp" />
|
||||
<ClCompile Include="..\public\networkvar.cpp" />
|
||||
<ClCompile Include="..\public\utility\binstream.cpp" />
|
||||
<ClCompile Include="..\public\utility\memaddr.cpp" />
|
||||
<ClCompile Include="..\public\utility\module.cpp" />
|
||||
@ -260,6 +262,7 @@
|
||||
<ClInclude Include="..\public\bitmap\stb_image.h" />
|
||||
<ClInclude Include="..\public\datamap.h" />
|
||||
<ClInclude Include="..\public\dt_common.h" />
|
||||
<ClInclude Include="..\public\dt_recv.h" />
|
||||
<ClInclude Include="..\public\iengine.h" />
|
||||
<ClInclude Include="..\public\client_class.h" />
|
||||
<ClInclude Include="..\public\const.h" />
|
||||
@ -292,6 +295,7 @@
|
||||
<ClInclude Include="..\public\ivscript.h" />
|
||||
<ClInclude Include="..\public\materialsystem\shader_vcs_version.h" />
|
||||
<ClInclude Include="..\public\model_types.h" />
|
||||
<ClInclude Include="..\public\networkvar.h" />
|
||||
<ClInclude Include="..\public\rendersystem\schema\texture.g.h" />
|
||||
<ClInclude Include="..\public\studio.h" />
|
||||
<ClInclude Include="..\core\resource.h" />
|
||||
|
@ -630,6 +630,12 @@
|
||||
<ClCompile Include="..\codecs\Miles\miles_impl.cpp">
|
||||
<Filter>sdk\codecs\miles</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\public\networkvar.cpp">
|
||||
<Filter>sdk\public</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\public\dt_recv.cpp">
|
||||
<Filter>sdk\public</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\client\cdll_engine_int.h">
|
||||
@ -1838,6 +1844,12 @@
|
||||
<ClInclude Include="..\codecs\Miles\radshal_wasapi.h">
|
||||
<Filter>sdk\codecs\miles</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\public\networkvar.h">
|
||||
<Filter>sdk\public</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\public\dt_recv.h">
|
||||
<Filter>sdk\public</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Image Include="..\shared\resource\lockedserver.png">
|
||||
|
@ -216,6 +216,7 @@
|
||||
<ClInclude Include="..\protoc\sv_rcon.pb.h" />
|
||||
<ClInclude Include="..\public\datamap.h" />
|
||||
<ClInclude Include="..\public\dt_common.h" />
|
||||
<ClInclude Include="..\public\dt_send.h" />
|
||||
<ClInclude Include="..\public\iengine.h" />
|
||||
<ClInclude Include="..\public\client_class.h" />
|
||||
<ClInclude Include="..\public\const.h" />
|
||||
@ -236,6 +237,7 @@
|
||||
<ClInclude Include="..\public\isnapshotmgr.h" />
|
||||
<ClInclude Include="..\public\ivscript.h" />
|
||||
<ClInclude Include="..\public\model_types.h" />
|
||||
<ClInclude Include="..\public\networkvar.h" />
|
||||
<ClInclude Include="..\public\server_class.h" />
|
||||
<ClInclude Include="..\public\studio.h" />
|
||||
<ClInclude Include="..\public\utility\binstream.h" />
|
||||
@ -552,6 +554,7 @@
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">NotUsing</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\public\datamap.cpp" />
|
||||
<ClCompile Include="..\public\networkvar.cpp" />
|
||||
<ClCompile Include="..\public\utility\binstream.cpp" />
|
||||
<ClCompile Include="..\public\utility\memaddr.cpp" />
|
||||
<ClCompile Include="..\public\utility\module.cpp" />
|
||||
|
@ -1269,6 +1269,12 @@
|
||||
<ClInclude Include="..\public\ipackedstore.h">
|
||||
<Filter>sdk\public</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\public\dt_send.h">
|
||||
<Filter>sdk\public</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\public\networkvar.h">
|
||||
<Filter>sdk\public</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\common\opcodes.cpp">
|
||||
@ -1595,6 +1601,9 @@
|
||||
<ClCompile Include="..\tier1\utlbuffer.cpp">
|
||||
<Filter>sdk\tier1</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\public\networkvar.cpp">
|
||||
<Filter>sdk\public</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\Dedicated.def" />
|
||||
|
@ -104,6 +104,8 @@
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">NotUsing</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\public\datamap.cpp" />
|
||||
<ClCompile Include="..\public\dt_recv.cpp" />
|
||||
<ClCompile Include="..\public\networkvar.cpp" />
|
||||
<ClCompile Include="..\public\utility\binstream.cpp" />
|
||||
<ClCompile Include="..\public\utility\memaddr.cpp" />
|
||||
<ClCompile Include="..\public\utility\module.cpp" />
|
||||
@ -287,6 +289,8 @@
|
||||
<ClInclude Include="..\public\bitmap\stb_image.h" />
|
||||
<ClInclude Include="..\public\datamap.h" />
|
||||
<ClInclude Include="..\public\dt_common.h" />
|
||||
<ClInclude Include="..\public\dt_recv.h" />
|
||||
<ClInclude Include="..\public\dt_send.h" />
|
||||
<ClInclude Include="..\public\iengine.h" />
|
||||
<ClInclude Include="..\public\client_class.h" />
|
||||
<ClInclude Include="..\public\const.h" />
|
||||
@ -321,6 +325,7 @@
|
||||
<ClInclude Include="..\public\ivscript.h" />
|
||||
<ClInclude Include="..\public\materialsystem\shader_vcs_version.h" />
|
||||
<ClInclude Include="..\public\model_types.h" />
|
||||
<ClInclude Include="..\public\networkvar.h" />
|
||||
<ClInclude Include="..\public\rendersystem\schema\texture.g.h" />
|
||||
<ClInclude Include="..\public\server_class.h" />
|
||||
<ClInclude Include="..\public\studio.h" />
|
||||
|
@ -672,6 +672,12 @@
|
||||
<ClCompile Include="..\codecs\Miles\miles_impl.cpp">
|
||||
<Filter>sdk\codecs\miles</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\public\dt_recv.cpp">
|
||||
<Filter>sdk\public</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\public\networkvar.cpp">
|
||||
<Filter>sdk\public</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\client\cdll_engine_int.h">
|
||||
@ -1937,6 +1943,15 @@
|
||||
<ClInclude Include="..\codecs\Miles\miles_types.h">
|
||||
<Filter>sdk\codecs\miles</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\public\dt_recv.h">
|
||||
<Filter>sdk\public</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\public\networkvar.h">
|
||||
<Filter>sdk\public</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\public\dt_send.h">
|
||||
<Filter>sdk\public</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Image Include="..\shared\resource\lockedserver.png">
|
||||
|
Loading…
x
Reference in New Issue
Block a user