//------------------------------------------------------------------------
CSynchedStorage::TStorage *CSynchedStorage::GetChannelStorage(int channelId, bool create)
{
	TChannelStorageMap::iterator it = m_channelStorageMap.find(channelId);

	if (it != m_channelStorageMap.end())
	{
		return &it->second;
	}
	else
	{
		INetChannel *pNetChannel = m_pGameFramework->GetNetChannel(channelId);

		if ((!gEnv->bServer && !pNetChannel) || (gEnv->bServer && pNetChannel->IsLocal()))
		{
			return &m_channelStorage;
		}

		if (gEnv->bServer && create)
		{
			std::pair<TChannelStorageMap::iterator, bool> result = m_channelStorageMap.insert(
						TEntityStorageMap::value_type(channelId, TStorage()));
			return &result.first->second;
		}
	}

	return 0;
}
Пример #2
0
//------------------------------------------------------------------------
CSynchedStorage::TStorage *CSynchedStorage::GetEntityStorage(EntityId id, bool create)
{
	TEntityStorageMap::iterator it=m_entityStorage.find(id);
	if (it!=m_entityStorage.end())
		return &it->second;
	else if (create)
	{
		std::pair<TEntityStorageMap::iterator, bool> result=m_entityStorage.insert(
			TEntityStorageMap::value_type(id, TStorage()));
		return &result.first->second;
	}

	return 0;
}