Esempio n. 1
0
//------------------------------------------------------------------------
void CServerGameTokenSynch::AddToQueueFor(int channelId, TGameTokenName name)
{
    SChannel *pChannel = GetChannel(channelId);
    assert(pChannel);

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

    SSendableHandle &msgHdl = m_queue[SChannelQueueEnt(channelId, name)];

    TGameTokenValue value;

    IGameToken *pToken=m_pGTS->FindToken(name.c_str());
    assert(pToken);

    if(!pToken)
        return;

    bool ok=pToken->GetValue(value);
    assert(ok);

    if(!ok)
        return;

    CClientGameTokenSynch::CSetMsg *pMsg=0;

    switch(value.GetType())
    {
    case eFDT_Int:
        pMsg=new CClientGameTokenSynch::CSetIntMsg(channelId, name, value);
        break;

    case eFDT_Float:
        pMsg=new CClientGameTokenSynch::CSetFloatMsg(channelId, name, value);
        break;

    case eFDT_EntityId:
        pMsg=new CClientGameTokenSynch::CSetEntityIdMsg(channelId, name, value);
        break;

    case eFDT_Vec3:
        pMsg=new CClientGameTokenSynch::CSetVec3Msg(channelId, name, value);
        break;

    case eFDT_String:
        pMsg=new CClientGameTokenSynch::CSetStringMsg(channelId, name, value);
        break;

    case eFDT_Bool:
        pMsg=new CClientGameTokenSynch::CSetBoolMsg(channelId, name, value);
        break;
    }

    if(pMsg)
        pChannel->pNetChannel->SubstituteSendable(pMsg, 1, &pChannel->lastOrderedMessage, &msgHdl);
    else
    {
        assert(!"Invalid type!");
    }
}
void CServerSynchedStorage::ResetChannel(int channelId)
{
	CryAutoCriticalSection lock(m_mutex);

	TChannelQueueMap::iterator cit=m_channelQueue.lower_bound(SChannelQueueEnt(channelId, 0));

	while(cit != m_channelQueue.end() && cit->first.channel == channelId)
	{
		TChannelQueueMap::iterator next = cit;
		++next;
		m_channelQueue.erase(cit);
		cit = next;
	}

	TChannelQueueMap::iterator git=m_globalQueue.lower_bound(SChannelQueueEnt(channelId, 0));

	while(git != m_globalQueue.end() && git->first.channel == channelId)
	{
		TChannelQueueMap::iterator next = git;
		++next;
		m_globalQueue.erase(git);
		git = next;
	}

	TChannelEntityQueueMap::iterator eit=m_entityQueue.lower_bound(SChannelEntityQueueEnt(channelId, 0, 0));

	while(eit != m_entityQueue.end() && eit->first.channel == channelId)
	{
		TChannelEntityQueueMap::iterator next = eit;
		++next;
		m_entityQueue.erase(eit);
		eit = next;
	}

	if(SChannel *pChannel = GetChannel(channelId))
	{
		if(pChannel->pNetChannel)
			pChannel->pNetChannel->AddSendable(new CClientSynchedStorage::CResetMsg(channelId, this), 1, &pChannel->lastOrderedMessage, &pChannel->lastOrderedMessage);
	}
}
//------------------------------------------------------------------------
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!");
	}
}
Esempio n. 4
0
void CServerGameTokenSynch::ResetChannel(int channelId)
{
    TChannelQueueMap::iterator cit=m_queue.lower_bound(SChannelQueueEnt(channelId, 0));

    while(cit != m_queue.end() && cit->first.channel == channelId)
    {
        TChannelQueueMap::iterator next = cit;
        ++next;
        m_queue.erase(cit);
        cit = next;
    }

    if(SChannel *pChannel = GetChannel(channelId))
    {
        if(pChannel->pNetChannel)
            pChannel->pNetChannel->AddSendable(new CClientGameTokenSynch::CResetMsg(channelId), 1, &pChannel->lastOrderedMessage, &pChannel->lastOrderedMessage);
    }
}