mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
This change was planned for a long time. This moves all REGISTER calls to a single translation unit, this is required as we currently added a very dirty workaround for not registering duplicates by checking if VFTable pointer was already present in the vector... Registering from single translation unit prevents duplicate instances that gets created if header is included by more cpp files. Reworking this reduced 100kb+ of compiled code. This commit also reworked the way functions/variables/constant gets logged with their addresses; the new code formats them on the fly, and allows for resize at any time. Formatting is no longer required by programmer. TODO: currently there are some compile errors for dedicated and client dll's. These will be resolved very soon as they need to be properly worked out still (server & client only stuff needs to be properly split). Use the 'main' (stable) branch for the time being if you need to compile these dll's.
90 lines
3.6 KiB
C++
90 lines
3.6 KiB
C++
//=============================================================================//
|
|
//
|
|
// Purpose: Interface server dll virtual functions to the SDK.
|
|
//
|
|
// $NoKeywords: $
|
|
//=============================================================================//
|
|
#ifndef GAMEINTERFACE_H
|
|
#define GAMEINTERFACE_H
|
|
#include "public/eiface.h"
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// Forward declarations
|
|
//-----------------------------------------------------------------------------
|
|
class ServerClass;
|
|
|
|
//-----------------------------------------------------------------------------
|
|
//
|
|
//-----------------------------------------------------------------------------
|
|
class CServerGameDLL
|
|
{
|
|
public:
|
|
void GameInit(void);
|
|
void PrecompileScriptsJob(void);
|
|
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);
|
|
};
|
|
|
|
//-----------------------------------------------------------------------------
|
|
//
|
|
//-----------------------------------------------------------------------------
|
|
class CServerGameClients : public IServerGameClients
|
|
{
|
|
};
|
|
|
|
//-----------------------------------------------------------------------------
|
|
//
|
|
//-----------------------------------------------------------------------------
|
|
class CServerGameEnts : public IServerGameEnts
|
|
{
|
|
};
|
|
|
|
inline CMemory p_CServerGameDLL__OnReceivedSayTextMessage;
|
|
inline auto CServerGameDLL__OnReceivedSayTextMessage = p_CServerGameDLL__OnReceivedSayTextMessage.RCast<void(__fastcall*)(void* thisptr, int senderId, const char* text, bool isTeamChat)>();
|
|
|
|
inline CMemory p_RunFrameServer;
|
|
inline auto v_RunFrameServer = p_RunFrameServer.RCast<void(*)(double flFrameTime, bool bRunOverlays, bool bUniformUpdate)>();
|
|
|
|
extern CServerGameDLL* g_pServerGameDLL;
|
|
extern CServerGameClients* g_pServerGameClients;
|
|
extern CServerGameEnts* g_pServerGameEntities;
|
|
|
|
extern CGlobalVars** g_pGlobals;
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
class VServerGameDLL : public IDetour
|
|
{
|
|
virtual void GetAdr(void) const
|
|
{
|
|
LogFunAdr("CServerGameDLL::OnReceivedSayTextMessage", p_CServerGameDLL__OnReceivedSayTextMessage.GetPtr());
|
|
LogFunAdr("RunFrameServer", p_RunFrameServer.GetPtr());
|
|
LogVarAdr("g_pServerGameDLL", reinterpret_cast<uintptr_t>(g_pServerGameDLL));
|
|
LogVarAdr("g_pServerGameClients", reinterpret_cast<uintptr_t>(g_pServerGameClients));
|
|
LogVarAdr("g_pServerGameEntities", reinterpret_cast<uintptr_t>(g_pServerGameEntities));
|
|
LogVarAdr("g_pGlobals", reinterpret_cast<uintptr_t>(g_pGlobals));
|
|
}
|
|
virtual void GetFun(void) const
|
|
{
|
|
#if defined(GAMEDLL_S3)
|
|
p_CServerGameDLL__OnReceivedSayTextMessage = g_GameDll.FindPatternSIMD("85 D2 0F 8E ?? ?? ?? ?? 4C 8B DC");
|
|
CServerGameDLL__OnReceivedSayTextMessage = p_CServerGameDLL__OnReceivedSayTextMessage.RCast<void(__fastcall*)(void* thisptr, int senderId, const char* text, bool isTeamChat)>();
|
|
|
|
p_RunFrameServer = g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 57 48 83 EC 30 0F 29 74 24 ?? 48 8D 0D ?? ?? ?? ??");
|
|
v_RunFrameServer = p_RunFrameServer.RCast<void(*)(double, bool, bool)>();
|
|
#endif
|
|
}
|
|
virtual void GetVar(void) const
|
|
{
|
|
g_pGlobals = g_GameDll.FindPatternSIMD("4C 8B 0D ?? ?? ?? ?? 48 8B D1").ResolveRelativeAddressSelf(0x3, 0x7).RCast<CGlobalVars**>();
|
|
}
|
|
virtual void GetCon(void) const { }
|
|
virtual void Attach(void) const;
|
|
virtual void Detach(void) const;
|
|
};
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
#endif // GAMEINTERFACE_H
|