Skip to content

Commit 4e87659

Browse files
committed
engine: restore sv_hibernate_when_empty
1 parent 9008da4 commit 4e87659

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

engine/sv_main.cpp

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@
8080

8181
extern CNetworkStringTableContainer *networkStringTableContainerServer;
8282
extern CNetworkStringTableContainer *networkStringTableContainerClient;
83-
//void OnHibernateWhenEmptyChanged( IConVar *var, const char *pOldValue, float flOldValue );
84-
//ConVar sv_hibernate_when_empty( "sv_hibernate_when_empty", "1", 0, "Puts the server into extremely low CPU usage mode when no clients connected", OnHibernateWhenEmptyChanged );
83+
static void OnHibernateWhenEmptyChanged( IConVar *var, const char *pOldValue, float flOldValue );
84+
ConVar sv_hibernate_when_empty( "sv_hibernate_when_empty", "1", 0, "Puts the server into extremely low CPU usage mode when no clients connected", OnHibernateWhenEmptyChanged );
8585
//ConVar sv_hibernate_ms( "sv_hibernate_ms", "20", 0, "# of milliseconds to sleep per frame while hibernating" );
8686
//ConVar sv_hibernate_ms_vgui( "sv_hibernate_ms_vgui", "20", 0, "# of milliseconds to sleep per frame while hibernating but running the vgui dedicated server frontend" );
8787
//static ConVar sv_hibernate_postgame_delay( "sv_hibernate_postgame_delay", "5", 0, "# of seconds to wait after final client leaves before hibernating.");
@@ -1541,13 +1541,13 @@ CPureServerWhitelist * CGameServer::GetPureServerWhitelist() const
15411541
return m_pPureServerWhitelist;
15421542
}
15431543

1544-
//void OnHibernateWhenEmptyChanged( IConVar *var, const char *pOldValue, float flOldValue )
1545-
//{
1546-
// // We only need to do something special if we were preventing hibernation
1547-
// // with sv_hibernate_when_empty but we would otherwise have been hibernating.
1548-
// // In that case, punt all connected clients.
1549-
// sv.UpdateHibernationState( );
1550-
//}
1544+
static void OnHibernateWhenEmptyChanged( IConVar *var, const char *pOldValue, float flOldValue )
1545+
{
1546+
// We only need to do something special if we were preventing hibernation
1547+
// with sv_hibernate_when_empty but we would otherwise have been hibernating.
1548+
// In that case, punt all connected clients.
1549+
sv.UpdateHibernationState( );
1550+
}
15511551

15521552
static bool s_bExitWhenEmpty = false;
15531553
static ConVar sv_memlimit( "sv_memlimit", "0", 0,
@@ -1753,8 +1753,7 @@ void CGameServer::UpdateHibernationState()
17531753
s_bExitWhenEmpty = true;
17541754
}
17551755

1756-
//SetHibernating( sv_hibernate_when_empty.GetBool() && hibernateFromGCServer && !bHaveAnyClients );
1757-
SetHibernating( hibernateFromGCServer && !bHaveAnyClients );
1756+
SetHibernating( sv_hibernate_when_empty.GetBool() && hibernateFromGCServer && !bHaveAnyClients );
17581757
}
17591758

17601759
void CGameServer::FinishRestore()

0 commit comments

Comments
 (0)