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-04-01 10:36:09 +02:00
|
|
|
bool CVEngineServer::PersistenceAvailable(void* entidx, int clientidx)
|
2021-12-25 22:36:38 +01:00
|
|
|
{
|
2023-04-01 10:36:09 +02:00
|
|
|
CClient* pClient = g_pClient->GetClient(clientidx); // 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
|
|
|
|
2023-04-01 10:36:09 +02:00
|
|
|
if (!g_ServerPlayer[clientidx].m_bPersistenceEnabled && sv_showconnecting->GetBool())
|
2021-12-25 22:36:38 +01:00
|
|
|
{
|
2023-04-01 10:36:09 +02:00
|
|
|
g_ServerPlayer[clientidx].m_bPersistenceEnabled = true;
|
2022-04-02 02:48:54 +02:00
|
|
|
CNetChan* pNetChan = pClient->GetNetChan();
|
2021-12-25 22:36:38 +01:00
|
|
|
|
2023-04-01 10:36:09 +02:00
|
|
|
DevMsg(eDLL_T::SERVER, "Enabled persistence for client #%d; channel %s(%s) ('%llu')\n",
|
|
|
|
clientidx, pNetChan->GetName(), pNetChan->GetAddress(), pClient->GetNucleusID());
|
2021-12-25 22:36:38 +01:00
|
|
|
}
|
|
|
|
///////////////////////////////////////////////////////////////////////////
|
2023-04-01 10:36:09 +02:00
|
|
|
return IVEngineServer__PersistenceAvailable(entidx, clientidx);
|
2021-12-25 22:36:38 +01:00
|
|
|
}
|
|
|
|
|
2023-01-25 02:26:52 +01:00
|
|
|
void HVEngineServer::Attach() const
|
2021-12-25 22:36:38 +01:00
|
|
|
{
|
2023-01-25 02:26:52 +01:00
|
|
|
DetourAttach(&IVEngineServer__PersistenceAvailable, &CVEngineServer::PersistenceAvailable);
|
2021-12-25 22:36:38 +01:00
|
|
|
}
|
|
|
|
|
2023-01-25 02:26:52 +01:00
|
|
|
void HVEngineServer::Detach() const
|
2021-12-25 22:36:38 +01:00
|
|
|
{
|
2023-01-25 02:26:52 +01:00
|
|
|
DetourDetach(&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);
|