2021-12-25 22:36:38 +01:00
|
|
|
//=============================================================================//
|
|
|
|
//
|
|
|
|
// Purpose: Interface the engine exposes to the game DLL
|
|
|
|
//
|
|
|
|
//=============================================================================//
|
|
|
|
|
|
|
|
#include "core/stdafx.h"
|
2022-04-09 16:16:40 +02:00
|
|
|
#include "tier1/cvar.h"
|
2022-03-26 00:24:13 +01:00
|
|
|
#include "common/protocol.h"
|
2022-05-20 11:52:19 +02:00
|
|
|
#include "engine/client/client.h"
|
2022-04-02 12:27:35 +02:00
|
|
|
#include "server/vengineserver_impl.h"
|
2021-12-25 22:36:38 +01:00
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// Purpose: sets the persistence var in the CClient instance to 'ready'
|
|
|
|
//-----------------------------------------------------------------------------
|
2023-01-17 00:32:08 +01:00
|
|
|
bool CVEngineServer::PersistenceAvailable(void* entidx, int clienthandle)
|
2021-12-25 22:36:38 +01:00
|
|
|
{
|
2022-05-20 11:52:19 +02:00
|
|
|
CClient* pClient = g_pClient->GetClient(clienthandle); // Get client instance.
|
2022-03-26 00:24:13 +01:00
|
|
|
pClient->SetPersistenceState(PERSISTENCE::PERSISTENCE_READY); // Set the client instance to 'ready'.
|
2021-12-25 22:36:38 +01:00
|
|
|
|
2022-09-18 23:19:50 +02:00
|
|
|
if (!g_ServerPlayer[clienthandle].m_bPersistenceEnabled && sv_showconnecting->GetBool())
|
2021-12-25 22:36:38 +01:00
|
|
|
{
|
2022-04-02 02:48:54 +02:00
|
|
|
CNetChan* pNetChan = pClient->GetNetChan();
|
2021-12-25 22:36:38 +01:00
|
|
|
|
2022-04-06 00:49:17 +02:00
|
|
|
string svClientName = pNetChan->GetName();
|
2022-04-02 02:48:54 +02:00
|
|
|
string svIpAddress = pNetChan->GetAddress();
|
2022-08-29 15:59:12 +02:00
|
|
|
uint64_t nNucleusID = pClient->GetNucleusID();
|
2021-12-25 22:36:38 +01:00
|
|
|
|
|
|
|
DevMsg(eDLL_T::SERVER, "______________________________________________________________\n");
|
2022-08-29 15:59:12 +02:00
|
|
|
DevMsg(eDLL_T::SERVER, "+- Enabled persistence for NetChannel:\n");
|
2022-05-20 11:52:19 +02:00
|
|
|
DevMsg(eDLL_T::SERVER, " |- IDX : | '#%d'\n", clienthandle);
|
2022-04-02 02:48:54 +02:00
|
|
|
DevMsg(eDLL_T::SERVER, " |- UID : | '%s'\n", svClientName.c_str());
|
2022-08-29 15:59:12 +02:00
|
|
|
DevMsg(eDLL_T::SERVER, " |- PID : | '%llu'\n", nNucleusID);
|
2022-04-02 02:48:54 +02:00
|
|
|
DevMsg(eDLL_T::SERVER, " |- ADR : | '%s'\n", svIpAddress.c_str());
|
|
|
|
DevMsg(eDLL_T::SERVER, " -------------------------------------------------------------\n");
|
2021-12-25 22:36:38 +01:00
|
|
|
|
2022-09-18 23:19:50 +02:00
|
|
|
g_ServerPlayer[clienthandle].m_bPersistenceEnabled = true;
|
2021-12-25 22:36:38 +01:00
|
|
|
}
|
|
|
|
///////////////////////////////////////////////////////////////////////////
|
2022-05-20 11:52:19 +02:00
|
|
|
return IVEngineServer__PersistenceAvailable(entidx, clienthandle);
|
2021-12-25 22:36:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void IVEngineServer_Attach()
|
|
|
|
{
|
2023-01-17 00:32:08 +01:00
|
|
|
DetourAttach((LPVOID*)&IVEngineServer__PersistenceAvailable, &CVEngineServer::PersistenceAvailable);
|
2021-12-25 22:36:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void IVEngineServer_Detach()
|
|
|
|
{
|
2023-01-17 00:32:08 +01:00
|
|
|
DetourDetach((LPVOID*)&IVEngineServer__PersistenceAvailable, &CVEngineServer::PersistenceAvailable);
|
2021-12-25 22:36:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
2022-09-18 23:19:50 +02:00
|
|
|
ServerPlayer_t g_ServerPlayer[MAX_PLAYERS];
|
2023-01-17 00:07:53 +01:00
|
|
|
|
|
|
|
IVEngineServer* g_pEngineServerVFTable = nullptr;
|
|
|
|
CVEngineServer* g_pEngineServer = reinterpret_cast<CVEngineServer*>(&g_pEngineServerVFTable);
|