Exemple #1
0
//--------------------------------------------------------------------------
void EntityS::SyncToClient()
{
	if(m_pkAgent)
	{
		if(m_kSyncDirty.Size())
		{
			BitStream kStream;
			kStream.Reset();
			kStream << VeUInt8(ID_CLIENT_ENTITY_UPDATE);
			kStream << (const VeChar8*)m_kName;
			VE_ASSERT(m_kSyncDirty.Size() <= VE_UINT16_MAX);
			kStream << VeUInt16(m_kSyncDirty.Size());
			m_kSyncDirty.BeginIterator();
			while(!m_kSyncDirty.IsEnd())
			{
				PropertySValue* pkValue = m_kSyncDirty.GetIterNode()->m_tContent;
				m_kSyncDirty.Next();
				VE_ASSERT(pkValue);
				kStream << pkValue->GetField();
				VE_ASSERT(pkValue->GetSize() <= 0xff);
				kStream.WriteAlignedBytesSafe((const VeChar8*)pkValue->GetClientData(), pkValue->GetClientSize(), VE_UINT8_MAX);
			}
			m_kSyncDirty.Clear();
			m_pkAgent->SendPacket(kStream);
		}
	}
}
Exemple #2
0
//--------------------------------------------------------------------------
void EntityS::SyncAllToClient()
{
	if(m_pkAgent)
	{
		BitStream kStream;
		kStream.Reset();
		kStream << VeUInt8(ID_CLIENT_ENTITY_UPDATE);
		kStream << (const VeChar8*)m_kName;
		VE_ASSERT(m_kSyncChildren.Size() <= VE_UINT16_MAX);
		kStream << VeUInt16(m_kSyncChildren.Size());
		for(VeUInt32 i(0); i < m_kSyncChildren.Size(); ++i)
		{
			PropertySValue* pkValue = m_kSyncChildren[i];
			kStream << pkValue->GetField();
			VE_ASSERT(pkValue->GetSize() <= 0xff);
			kStream.WriteAlignedBytesSafe((const VeChar8*)pkValue->GetClientData(), pkValue->GetClientSize(), VE_UINT8_MAX);
		}
		m_pkAgent->SendPacket(kStream);
	}
}