Ejemplo n.º 1
0
//------------------------------------------------------------------------
void CServerSynchedStorage::AddToChannelQueue(int channelId, TSynchedKey key)
{
	SChannel *pChannel = GetChannel(channelId);
	assert(pChannel);

	if(!pChannel || !pChannel->pNetChannel || pChannel->local)
		return;

	SSendableHandle &msgHdl = m_channelQueue[SChannelQueueEnt(channelId, key)];

	TSynchedValue value;
	bool ok=GetChannelValue(channelId, key, value);
	assert(ok);

	if(!ok)
		return;

	CClientSynchedStorage::CSetChannelMsg *pMsg=0;

	switch(value.GetType())
	{
	case eSVT_Bool:
		pMsg=new CClientSynchedStorage::CSetChannelBoolMsg(channelId, this, key, value);
		break;

	case eSVT_Float:
		pMsg=new CClientSynchedStorage::CSetChannelFloatMsg(channelId, this, key, value);
		break;

	case eSVT_Int:
		pMsg=new CClientSynchedStorage::CSetChannelIntMsg(channelId, this, key, value);
		break;

	case eSVT_EntityId:
		pMsg=new CClientSynchedStorage::CSetChannelEntityIdMsg(channelId, this, key, value);
		break;

	case eSVT_String:
		pMsg=new CClientSynchedStorage::CSetChannelStringMsg(channelId, this, key, value);
		break;
	}

	if(pMsg)
		pChannel->pNetChannel->SubstituteSendable(pMsg, 1, &pChannel->lastOrderedMessage, &msgHdl);
	else
	{
		assert(!"Invalid type!");
	}
}
		ValueDumper(TSynchedKey key, const TSynchedValue &value)
		{
			switch(value.GetType())
			{
				case eSVT_Bool:
					CryLogAlways("  %.08d -     bool: %s", key, *value.GetPtr<bool>() ? "true" : "false");
					break;

				case eSVT_Float:
					CryLogAlways("  %.08d -    float: %f", key, *value.GetPtr<float>());
					break;

				case eSVT_Int:
					CryLogAlways("  %.08d -      int: %d", key, *value.GetPtr<int>());
					break;

				case eSVT_EntityId:
					CryLogAlways("  %.08d - entityId: %.08x", key, *value.GetPtr<EntityId>());
					break;

				case eSVT_String:
					CryLogAlways("  %.08d -  string: %s", key, value.GetPtr<string>()->c_str());
					break;

				default:
					CryLogAlways("  %.08d - unknown: %.08x", key, *value.GetPtr<uint32>());
					break;
			}
		}