Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions core/PlayerManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ bool g_OnMapStarted = false;
IForward *PreAdminCheck = NULL;
IForward *PostAdminCheck = NULL;
IForward *PostAdminFilter = NULL;
IForward *ServerEnterHibernation = NULL;
IForward *ServerExitHibernation = NULL;

const unsigned int *g_NumPlayersToAuth = NULL;
int lifestate_offset = -1;
Expand Down Expand Up @@ -203,6 +205,8 @@ void PlayerManager::OnSourceModAllInitialized()
PreAdminCheck = forwardsys->CreateForward("OnClientPreAdminCheck", ET_Event, 1, p1);
PostAdminCheck = forwardsys->CreateForward("OnClientPostAdminCheck", ET_Ignore, 1, p1);
PostAdminFilter = forwardsys->CreateForward("OnClientPostAdminFilter", ET_Ignore, 1, p1);
ServerEnterHibernation = forwardsys->CreateForward("OnServerEnterHibernation", ET_Ignore, 0, NULL);
ServerExitHibernation = forwardsys->CreateForward("OnServerExitHibernation", ET_Ignore, 0, NULL);

m_bIsListenServer = !engine->IsDedicatedServer();
m_ListenClient = 0;
Expand Down Expand Up @@ -254,6 +258,8 @@ void PlayerManager::OnSourceModShutdown()
forwardsys->ReleaseForward(PreAdminCheck);
forwardsys->ReleaseForward(PostAdminCheck);
forwardsys->ReleaseForward(PostAdminFilter);
forwardsys->ReleaseForward(ServerEnterHibernation);
forwardsys->ReleaseForward(ServerExitHibernation);

delete [] m_Players;

Expand Down Expand Up @@ -778,6 +784,11 @@ void PlayerManager::OnSourceModLevelEnd()

void PlayerManager::OnServerHibernationUpdate(bool bHibernating)
{
cell_t res;
if (bHibernating)
ServerEnterHibernation->Execute(&res);
else
ServerExitHibernation->Execute(&res);
/* If bots were added at map start, but not fully inited before hibernation, there will
* be no OnClientDisconnect for them, despite them getting booted right before this.
*/
Expand Down
12 changes: 12 additions & 0 deletions plugins/include/clients.inc
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,18 @@ forward Action OnClientPreAdminCheck(int client);
*/
forward void OnClientPostAdminFilter(int client);

/**
* Called directly before the server enters hibernation.
* This is your last chance to do anything in the plugin before
* hibernation occurs, as SV_Frame will no longer be called.
*/
forward void OnServerEnterHibernation();

/**
* Called directly before the server leaves hibernation.
*/
forward void OnServerExitHibernation();

/**
* Called once a client is authorized and fully in-game, and
* after all post-connection authorizations have been performed.
Expand Down