Engine: add command line statics for dedicated server and light cleanup

CGameServer::SpawnServer() pointer to engine/server/server.h, and renamed it to CServer::SpawnServer().
This commit is contained in:
Kawe Mazidjatari 2024-04-20 00:59:39 +02:00
parent 50d38af63a
commit 85b7f84d47
2 changed files with 50 additions and 3 deletions

View File

@ -129,6 +129,7 @@ inline void(*CServer__RunFrame)(CServer* pServer);
inline CClient*(*CServer__ConnectClient)(CServer* pServer, user_creds_s* pCreds);
inline void*(*CServer__RejectConnection)(CServer* pServer, int iSocket, netadr_t* pNetAdr, const char* szMessage);
inline void (*CServer__BroadcastMessage)(CServer* pServer, CNetMessage* const msg, const bool onlyActive, const bool reliable);
inline bool(*CServer__SpawnServer)(CServer* pServer, const char* pszMapName, const char* pszMapGroupName);
///////////////////////////////////////////////////////////////////////////////
class VServer : public IDetour
@ -141,6 +142,7 @@ class VServer : public IDetour
LogFunAdr("CServer::ConnectClient", CServer__ConnectClient);
LogFunAdr("CServer::RejectConnection", CServer__RejectConnection);
LogFunAdr("CServer::BroadcastMessage", CServer__BroadcastMessage);
LogFunAdr("CServer::SpawnServer", CServer__SpawnServer);
LogVarAdr("g_Server", g_pServer);
#endif // !CLIENT_DLL
}
@ -153,6 +155,7 @@ class VServer : public IDetour
g_GameDll.FindPatternSIMD("E8 ?? ?? ?? ?? E8 ?? ?? ?? ?? 48 8B 0D ?? ?? ?? ?? 88 05 ?? ?? ?? ??").FollowNearCallSelf().GetPtr(CServer__RunFrame);
g_GameDll.FindPatternSIMD("4C 89 4C 24 ?? 53 55 56 57 48 81 EC ?? ?? ?? ?? 49 8B D9").GetPtr(CServer__RejectConnection);
g_GameDll.FindPatternSIMD("4C 8B DC 45 88 43 18 56").GetPtr(CServer__BroadcastMessage);
g_GameDll.FindPatternSIMD("48 8B C4 53 55 56 57 41 54 41 55 41 57").GetPtr(CServer__SpawnServer);
#endif // !CLIENT_DLL
}
virtual void GetVar(void) const

View File

@ -8,7 +8,6 @@ class CClient;
class CClient;
/* ==== SV_MAIN ======================================================================================================================================================= */
inline bool(*CGameServer__SpawnServer)(void* thisptr, const char* pszMapName, const char* pszMapGroupName);
inline void(*v_SV_InitGameDLL)(void);
inline void(*v_SV_ShutdownGameDLL)(void);
inline bool(*v_SV_ActivateServer)(void);
@ -17,12 +16,50 @@ inline void(*v_SV_BroadcastVoiceData)(CClient* cl, int nBytes, char* data);
inline bool* s_bIsDedicated = nullptr;
inline bool* s_bPartyDediOnly = nullptr;
inline bool* s_bTrainingDedi = nullptr;
inline bool* s_bStagingDedi = nullptr;
inline bool* s_bFiringRangeDedi = nullptr;
// Returns true if this is a dedicated server.
inline bool IsDedicated()
{
return *s_bIsDedicated;
}
// If this is true, a maximum of 2 teams will be enforced. No voice data will
// be processed or broad casted to clients.
// This is set with command line option '-partyDediOnly'.
inline bool IsPartyDedi()
{
return *s_bPartyDediOnly;
}
// If this is true, no playlist matching checks will be performed. No voice
// data will be processed or broad casted to clients.
// This is set with command line option '-trainingDedi'.
inline bool IsTrainingDedi()
{
return *s_bTrainingDedi;
}
// If this is true, no playlist matching checks will be performed.
// This is set with command line option '-stagingDedi'.
inline bool IsStagingDedi()
{
return *s_bStagingDedi;
}
// If this is true, no playlist matching checks will be performed.
// The system expects a 'max_team_size' key in the playlists file
// that will be used to enforce the max team size, which defaults
// to '3' if key is absent.
// This is set with command line option '-firingRangeDedi'.
inline bool IsFiringRangeDedi()
{
return *s_bFiringRangeDedi;
}
///////////////////////////////////////////////////////////////////////////////
void SV_InitGameDLL();
@ -38,17 +75,16 @@ class HSV_Main : public IDetour
{
virtual void GetAdr(void) const
{
LogFunAdr("CGameServer::SpawnServer", CGameServer__SpawnServer);
LogFunAdr("SV_InitGameDLL", v_SV_InitGameDLL);
LogFunAdr("SV_ShutdownGameDLL", v_SV_ShutdownGameDLL);
LogFunAdr("SV_ActivateServer", v_SV_ActivateServer);
LogFunAdr("SV_CreateBaseline", v_SV_CreateBaseline);
LogFunAdr("SV_BroadcastVoiceData", v_SV_BroadcastVoiceData);
LogVarAdr("s_bIsDedicated", s_bIsDedicated);
}
virtual void GetFun(void) const
{
g_GameDll.FindPatternSIMD("48 8B C4 53 55 56 57 41 54 41 55 41 57").GetPtr(CGameServer__SpawnServer);
g_GameDll.FindPatternSIMD("48 81 EC ?? ?? ?? ?? E8 ?? ?? ?? ?? 80 3D ?? ?? ?? ?? ?? 0F 85 ?? ?? ?? ??").GetPtr(v_SV_InitGameDLL);
g_GameDll.FindPatternSIMD("48 83 EC 28 80 3D ?? ?? ?? ?? ?? 0F 84 ?? ?? ?? ?? 48 8B 0D ?? ?? ?? ?? 48").GetPtr(v_SV_ShutdownGameDLL);
g_GameDll.FindPatternSIMD("48 8B C4 56 48 81 EC ?? ?? ?? ?? 48 89 ?? ?? 48 8D").GetPtr(v_SV_ActivateServer);
@ -59,6 +95,14 @@ class HSV_Main : public IDetour
{
s_bIsDedicated = g_GameDll.FindPatternSIMD("48 89 4C 24 ?? 48 89 54 24 ?? 4C 89 44 24 ?? 4C 89 4C 24 ?? 53 57 B8 ?? ?? ?? ?? E8 ?? ?? ?? ?? 48 2B E0 48 8B D9 48 8D BC 24 ?? ?? ?? ?? E8 ?? ?? ?? ?? 48 89 7C 24 ?? 48 8D 54 24 ?? 33 FF")
.FindPatternSelf("40 38 3D", CMemory::Direction::DOWN).ResolveRelativeAddressSelf(0x3, 0x7).RCast<bool*>();
CMemory baseAdr = g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 57 48 83 EC 20 48 83 3D ?? ?? ?? ?? ?? 75 2A").OffsetSelf(0x100);
// Grab the 4 globals in a row (FindPatternSelf moves the base address to found address).
baseAdr.FindPatternSelf("0F 95 05").ResolveRelativeAddress(3, 7).GetPtr(s_bPartyDediOnly);
baseAdr.FindPatternSelf("0F 95 05").ResolveRelativeAddress(3, 7).GetPtr(s_bTrainingDedi);
baseAdr.FindPatternSelf("0F 95 05").ResolveRelativeAddress(3, 7).GetPtr(s_bStagingDedi);
baseAdr.FindPatternSelf("0F 95 05").ResolveRelativeAddress(3, 7).GetPtr(s_bFiringRangeDedi);
}
virtual void GetCon(void) const { }
///////////////////////////////////////////////////////////////////////////////