Beispiel #1
0
bool MMatchChannelMap::Add(const char* pszChannelName, const char* pszRuleName, MUID* pAllocUID, MCHANNEL_TYPE nType, int nMaxPlayers, int nLevelMin, int nLevelMax,
						   const bool bIsTicketChannel, const DWORD dwTicketItemID, const bool bIsUseTicket, const char* pszChannelNameStrResId)
{
	MUID uidChannel = UseUID();

	MMatchChannel* pChannel = new MMatchChannel;
	pChannel->Create(uidChannel, pszChannelName, pszRuleName, nType, nMaxPlayers, nLevelMin, nLevelMax, bIsTicketChannel, dwTicketItemID, bIsUseTicket, pszChannelNameStrResId);
	Insert(uidChannel, pChannel);
	*pAllocUID = uidChannel;


	if ((nType >= 0) && (nType < MCHANNEL_TYPE_MAX))
	{
		m_TypesChannelMap[nType].insert(map<MUID, MMatchChannel*>::value_type(uidChannel, pChannel));
	}
	else
	{
		MMatchServer::GetInstance()->LOG(MCommandCommunicator::LOG_FILE, "invalid channel type %d",nType);
		erase(uidChannel);

		delete pChannel;
		return false;
	}

	return true;
}
void MMatchFriendInfo::UpdateDesc()
{
	MMatchServer* pServer = MMatchServer::GetInstance();
	for (MMatchFriendList::iterator i=m_FriendList.begin(); i!= m_FriendList.end(); i++) 
	{
		MMatchFriendNode* pNode = (*i);
		pNode->szDescription[0] = NULL;

		MMatchObject* pObj = pServer->GetPlayerByName(pNode->szName);
		if (pObj) {
			char szDesc[CHANNELNAME_LEN*2]="";

			pNode->nState = pObj->GetPlace();
			MMatchChannel* pChannel = pServer->FindChannel(pObj->GetChannelUID());
			if (pChannel) {
				sprintf(szDesc, "Channel '%s'", pChannel->GetName());
				strncpy(pNode->szDescription, szDesc, MATCH_SIMPLE_DESC_LENGTH);
				pNode->szDescription[MATCH_SIMPLE_DESC_LENGTH-1] = NULL;
			} else {
				strcpy(pNode->szDescription, "Unknown Channel");
			}
		} else {
			pNode->nState = MMP_OUTSIDE;
			strcpy(pNode->szDescription, "Not Logged on");
		}
	}
}
Beispiel #3
0
MMatchChannel* MMatchChannelMap::Find(const MCHANNEL_TYPE nChannelType, const char* pszChannelName)
{
	if ((nChannelType < 0) || (nChannelType >= MCHANNEL_TYPE_MAX)) return NULL;

	for(map<MUID, MMatchChannel*>::iterator i = m_TypesChannelMap[nChannelType].begin(); 
		i != m_TypesChannelMap[nChannelType].end(); i++)
	{
		MMatchChannel* pChannel = (*i).second;
		if (strcmp(pChannel->GetName(), pszChannelName) == 0) return pChannel;
	}
	return NULL;
}
Beispiel #4
0
void MMatchChannelMap::Update(u64 nClock)
{
	u32 nChannelListChecksum = 0;
	for(iterator itor=begin(); itor != end();)
	{
		MMatchChannel* pChannel = (*itor).second;
		pChannel->Tick(nClock);
		if (pChannel->CheckLifePeriod() == false) {
			Remove(pChannel->GetUID(), &itor);
			continue;
		}else {
			itor++;
		}
		nChannelListChecksum += pChannel->GetChecksum();
	}

	m_nChecksum = nChannelListChecksum;
}