Пример #1
0
void CBatchSyncVarsSink::OnAfterVarChange( ICVar *pVar )
{
	if (!pVar || (pVar->GetFlags() & VF_NET_SYNCED))
	{
		if (m_pChannel->GetNetChannel() && !m_pChannel->GetNetChannel()->IsLocal())
		{
			if (!pVar || !m_params.Add(pVar->GetName(), pVar->GetString()))
			{
				INetSendablePtr pSendable = new CSimpleNetMessage<SClientBatchConsoleVariablesParams>(m_params, CGameClientChannel::SetBatchConsoleVariables);
				pSendable->SetGroup('cvar');
				m_pChannel->GetNetChannel()->AddSendable( pSendable, 1, &m_consoleVarSendable, &m_consoleVarSendable );

				m_params.Reset();
				if (pVar)
					m_params.Add(pVar->GetName(), pVar->GetString());
			}
		}
	}
}
void CGameServerChannel::OnAfterVarChange( ICVar *pVar )
{
	if (pVar->GetFlags() & VF_NET_SYNCED)
	{
		if (GetNetChannel() && !GetNetChannel()->IsLocal())
		{
			SClientConsoleVariableParams params( pVar->GetName(), pVar->GetString() );
#if FAST_CVAR_SYNC
			SSendableHandle& id = GetConsoleStreamId( params.key );
			INetSendablePtr pSendable = new CSimpleNetMessage<SClientConsoleVariableParams>(params, CGameClientChannel::SetConsoleVariable);
			pSendable->SetGroup('cvar');
			GetNetChannel()->SubstituteSendable( pSendable, 1, &id, &id );
#else
			INetSendablePtr pSendable = new CSimpleNetMessage<SClientConsoleVariableParams>(params, CGameClientChannel::SetConsoleVariable);
			pSendable->SetGroup('cvar');
			GetNetChannel()->AddSendable( pSendable, 1, &m_consoleVarSendable, &m_consoleVarSendable );
#endif
		}
	}
}