Refactor SourceTV instance hooking
Keep the instances in seperate wrappers to clear up the hooks. This allows for some OnServerStart and OnServerShutdown forwards. To prepare support for relay servers, CHLTVServer::Shutdown is hooked to detect shutdown instead of relying on the director unregistering the instance.
This commit is contained in:
@@ -104,6 +104,9 @@ void CForwardManager::Init()
|
||||
m_SpectatorDisconnectFwd = forwards->CreateForward("SourceTV_OnSpectatorDisconnect", ET_Ignore, 2, NULL, Param_Cell, Param_String);
|
||||
m_SpectatorDisconnectedFwd = forwards->CreateForward("SourceTV_OnSpectatorDisconnected", ET_Ignore, 2, NULL, Param_Cell, Param_String);
|
||||
m_SpectatorPutInServerFwd = forwards->CreateForward("SourceTV_OnSpectatorPutInServer", ET_Ignore, 1, NULL, Param_Cell);
|
||||
|
||||
m_ServerStartFwd = forwards->CreateForward("SourceTV_OnServerStart", ET_Ignore, 1, NULL, Param_Cell);
|
||||
m_ServerShutdownFwd = forwards->CreateForward("SourceTV_OnServerShutdown", ET_Ignore, 1, NULL, Param_Cell);
|
||||
}
|
||||
|
||||
void CForwardManager::Shutdown()
|
||||
@@ -115,6 +118,9 @@ void CForwardManager::Shutdown()
|
||||
forwards->ReleaseForward(m_SpectatorDisconnectFwd);
|
||||
forwards->ReleaseForward(m_SpectatorDisconnectedFwd);
|
||||
forwards->ReleaseForward(m_SpectatorPutInServerFwd);
|
||||
|
||||
forwards->ReleaseForward(m_ServerStartFwd);
|
||||
forwards->ReleaseForward(m_ServerShutdownFwd);
|
||||
}
|
||||
|
||||
void CForwardManager::HookRecorder(IDemoRecorder *recorder)
|
||||
@@ -188,6 +194,18 @@ void CForwardManager::UnhookClient(IClient *client)
|
||||
SH_REMOVE_HOOK(IClient, Disconnect, client, SH_MEMBER(this, &CForwardManager::OnSpectatorDisconnect), false);
|
||||
}
|
||||
|
||||
void CForwardManager::CallOnServerStart(IHLTVServer *server)
|
||||
{
|
||||
m_ServerStartFwd->PushCell(0); // TODO: Get right hltvinstance
|
||||
m_ServerStartFwd->Execute();
|
||||
}
|
||||
|
||||
void CForwardManager::CallOnServerShutdown(IHLTVServer *server)
|
||||
{
|
||||
m_ServerShutdownFwd->PushCell(0); // TODO: Get right hltvinstance
|
||||
m_ServerShutdownFwd->Execute();
|
||||
}
|
||||
|
||||
#if SOURCE_ENGINE == SE_CSGO
|
||||
static bool ExtractPlayerName(CUtlVector<NetMsg_SplitPlayerConnect *> &pSplitPlayerConnectVector, char *name, int maxlen)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user